Merged New Inventory Project into main branch

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1871 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
lalien
2008-03-08 15:15:25 +00:00
parent e16d166277
commit 43ca24dda8
649 changed files with 93359 additions and 82507 deletions
+172 -175
View File
@@ -39,9 +39,9 @@ void PasteTextureEx( INT16 sGridNo, UINT16 usType );
void PasteTextureFromRadiusEx( INT16 sGridNo, UINT16 usType, UINT8 ubRadius );
BOOLEAN gfWarning = FALSE;
BOOLEAN gfWarning = FALSE;
BOOLEAN gfDoFill = FALSE;
BOOLEAN gfDoFill = FALSE;
UINT16 CurrentPaste = NO_TILE;
UINT16 gDebrisPaste = NO_TILE;
UINT16 gChangeElevation = FALSE;
@@ -78,9 +78,9 @@ void DeleteStuffFromMapTile( UINT32 iMapIndex )
//UINT32 uiCheckType;
//UINT16 usDummy;
//GetTileType( gpWorldLevelData[ iMapIndex ].pLandHead->usIndex, &uiCheckType );
//RemoveLand( iMapIndex, gpWorldLevelData[ iMapIndex ].pLandHead->usIndex );
//SmoothTerrainRadius( iMapIndex, uiCheckType, 1, TRUE );
//GetTileType( gpWorldLevelData[ iMapIndex ].pLandHead->usIndex, &uiCheckType );
//RemoveLand( iMapIndex, gpWorldLevelData[ iMapIndex ].pLandHead->usIndex );
//SmoothTerrainRadius( iMapIndex, uiCheckType, 1, TRUE );
RemoveExitGridFromWorld( iMapIndex );
RemoveAllStructsOfTypeRange( iMapIndex, FIRSTTEXTURE, WIREFRAMES );
@@ -122,20 +122,20 @@ void EraseMapTile( UINT32 iMapIndex )
case DRAW_MODE_EXITGRID:
AddToUndoList( iMapIndex );
RemoveExitGridFromWorld( iMapIndex );
RemoveTopmost( (UINT16)iMapIndex, FIRSTPOINTERS8 );
RemoveTopmost( (INT16)iMapIndex, FIRSTPOINTERS8 );
break;
case DRAW_MODE_GROUND:
case DRAW_MODE_GROUND:
// Is there ground on this tile? if not, get out o here
if ( gpWorldLevelData[ iMapIndex ].pLandHead == NULL )
break;
// is there only 1 ground tile here? if so, get out o here
if ( gpWorldLevelData[ iMapIndex ].pLandHead->pNext == NULL )
break;
AddToUndoList( iMapIndex );
GetTileType( gpWorldLevelData[ iMapIndex ].pLandHead->usIndex, &uiCheckType );
RemoveLand( iMapIndex, gpWorldLevelData[ iMapIndex ].pLandHead->usIndex );
SmoothTerrainRadius( iMapIndex, uiCheckType, 1, TRUE );
GetTileType( gpWorldLevelData[ iMapIndex ].pLandHead->usIndex, &uiCheckType );
RemoveLand( iMapIndex, gpWorldLevelData[ iMapIndex ].pLandHead->usIndex );
SmoothTerrainRadius( iMapIndex, uiCheckType, 1, TRUE );
break;
case DRAW_MODE_OSTRUCTS:
case DRAW_MODE_OSTRUCTS1:
@@ -217,7 +217,7 @@ void EraseMapTile( UINT32 iMapIndex )
//---------------------------------------------------------------------------------------------------------------
// PasteDebris
//
//
// Place some "debris" on the map at the current mouse coordinates. This function is called repeatedly if
// the current brush size is larger than 1 tile.
//
@@ -232,7 +232,7 @@ void PasteDebris( UINT32 iMapIndex )
pNumSelList = &iNumDebrisSelected;
if ( iMapIndex < 0x8000 )
{
{
AddToUndoList( iMapIndex );
// Remove any debris that is currently at this map location
@@ -343,7 +343,7 @@ void PasteSingleToilet( UINT32 iMapIndex )
// PasteSingleWallCommon
//
// Common paste routine for PasteSingleWall, PasteSingleDoor, PasteSingleDecoration, and
// PasteSingleDecor (above).
// PasteSingleDecor (above).
//
void PasteSingleWallCommon( UINT32 iMapIndex )
{
@@ -352,7 +352,7 @@ void PasteSingleWallCommon( UINT32 iMapIndex )
UINT16 usTempIndex;
if ( iMapIndex < 0x8000 )
{
{
AddToUndoList( iMapIndex );
usUseIndex = pSelList[ iCurBank ].usIndex;
@@ -360,7 +360,7 @@ void PasteSingleWallCommon( UINT32 iMapIndex )
// TEMP STUFF FOR ONROOF THINGS!
if ( (usUseObjIndex >= FIRSTONROOF) && (usUseObjIndex <= SECONDONROOF ) )
{
{
// Add to onroof section!
AddOnRoofToTail( iMapIndex, (UINT16)(gTileTypeStartIndex[ usUseObjIndex ] + usUseIndex) );
@@ -382,7 +382,7 @@ void PasteSingleWallCommon( UINT32 iMapIndex )
{
// PLace shadow for doors
if( !gfBasement )
AddExclusiveShadow( iMapIndex, (UINT16)(gTileTypeStartIndex[ usUseObjIndex - FIRSTDOOR + FIRSTDOORSHADOW ] + usUseIndex ) );
AddExclusiveShadow( iMapIndex, (UINT16)(gTileTypeStartIndex[ usUseObjIndex - FIRSTDOOR + FIRSTDOORSHADOW ] + usUseIndex ) );
}
// Is it a wall?
@@ -399,15 +399,15 @@ void PasteSingleWallCommon( UINT32 iMapIndex )
// Slap down wall/window/door/decoration (no smoothing)
AddWallToStructLayer( iMapIndex, (UINT16)(gTileTypeStartIndex[ usUseObjIndex ] + usUseIndex), TRUE );
}
}
}
// Is it a door/window/decoration?
else if ( ( (usUseObjIndex >= FIRSTDOOR) && (usUseObjIndex <= LASTDOOR)) ||
((usUseObjIndex >= FIRSTDECORATIONS) && (usUseObjIndex <= LASTDECORATIONS)) )
((usUseObjIndex >= FIRSTDECORATIONS) && (usUseObjIndex <= LASTDECORATIONS)) )
{
// Slap down wall/window/door/decoration (no smoothing)
AddWallToStructLayer( iMapIndex, (UINT16)(gTileTypeStartIndex[ usUseObjIndex ] + usUseIndex), TRUE );
}
else if ( ((usUseObjIndex >= FIRSTROOF) && (usUseObjIndex <= LASTROOF)) ||
else if ( ((usUseObjIndex >= FIRSTROOF) && (usUseObjIndex <= LASTROOF)) ||
((usUseObjIndex >= FIRSTSLANTROOF) && (usUseObjIndex <= LASTSLANTROOF)) )
{
// Put a roof on this tile (even if nothing else is here)
@@ -423,7 +423,7 @@ void PasteSingleWallCommon( UINT32 iMapIndex )
AddLandToHead( iMapIndex, (UINT16)(gTileTypeStartIndex[ usUseObjIndex ] + usUseIndex) );
}
else if( usUseObjIndex >= FIRSTWALLDECAL && usUseObjIndex <= LASTWALLDECAL ||
usUseObjIndex >= FIFTHWALLDECAL && usUseObjIndex <= EIGTHWALLDECAL )
usUseObjIndex >= FIFTHWALLDECAL && usUseObjIndex <= EIGTHWALLDECAL )
{
// Plop a decal here
RemoveAllStructsOfTypeRange( iMapIndex, FIRSTWALLDECAL, LASTWALLDECAL );
@@ -431,7 +431,7 @@ void PasteSingleWallCommon( UINT32 iMapIndex )
AddStructToTail( iMapIndex, (UINT16)( gTileTypeStartIndex[ usUseObjIndex ] + usUseIndex ) );
}
else if ( usUseObjIndex >= FIRSTISTRUCT && usUseObjIndex <= LASTISTRUCT ||
else if ( usUseObjIndex >= FIRSTISTRUCT && usUseObjIndex <= LASTISTRUCT ||
usUseObjIndex >= FIFTHISTRUCT && usUseObjIndex <= EIGHTISTRUCT )
{
AddStructToHead( iMapIndex, (UINT16)( gTileTypeStartIndex[ usUseObjIndex ] + usUseIndex ) );
@@ -460,7 +460,7 @@ UINT16 GetRandomIndexByRange( UINT16 usRangeStart, UINT16 usRangeEnd )
usNumInPickList = 0;
for ( usWhich = 0; usWhich < *pNumSelList; usWhich++ )
{
usObject = (UINT16)pSelList[ usWhich ].uiObject;
usObject = (UINT16)pSelList[ usWhich ].uiObject;
if ( (usObject >= usRangeStart) && (usObject <= usRangeEnd) )
{
usPickList[ usNumInPickList ] = usObject;
@@ -476,15 +476,15 @@ UINT16 GetRandomTypeByRange( UINT16 usRangeStart, UINT16 usRangeEnd )
UINT16 usNumInPickList;
UINT16 i;
UINT16 usObject;
UINT32 uiType;
UINT32 uiType;
// Get a list of valid object to select from
usNumInPickList = 0;
for ( i = 0; i < *pNumSelList; i++ )
{
usObject = (UINT16)pSelList[ i ].uiObject;
usObject = (UINT16)pSelList[ i ].uiObject;
if ( (usObject >= usRangeStart) && (usObject <= usRangeEnd) )
{
GetTileType( usObject, &uiType );
GetTileType( usObject, &uiType );
usPickList[ usNumInPickList ] = (UINT16)uiType;
usNumInPickList++;
}
@@ -495,7 +495,7 @@ UINT16 GetRandomTypeByRange( UINT16 usRangeStart, UINT16 usRangeEnd )
//---------------------------------------------------------------------------------------------------------------
// PasteStructure (See also PasteStructure1, PasteStructure2, and PasteStructureCommon)
//
//
// Puts a structure (trees, trucks, etc.) into the world
//
void PasteStructure( UINT32 iMapIndex )
@@ -508,7 +508,7 @@ void PasteStructure( UINT32 iMapIndex )
//---------------------------------------------------------------------------------------------------------------
// PasteStructure1 (See also PasteStructure, PasteStructure2, and PasteStructureCommon)
//
//
// Puts a structure (trees, trucks, etc.) into the world
//
void PasteStructure1( UINT32 iMapIndex )
@@ -521,7 +521,7 @@ void PasteStructure1( UINT32 iMapIndex )
//---------------------------------------------------------------------------------------------------------------
// PasteStructure2 (See also PasteStructure, PasteStructure1, and PasteStructureCommon)
//
//
// Puts a structure (trees, trucks, etc.) into the world
//
void PasteStructure2( UINT32 iMapIndex )
@@ -541,7 +541,6 @@ void PasteStructure2( UINT32 iMapIndex )
//
void PasteStructureCommon( UINT32 iMapIndex )
{
// BOOLEAN fDoPaste = FALSE;
UINT32 fHeadType;
UINT16 usUseIndex;
UINT16 usUseObjIndex;
@@ -549,7 +548,7 @@ void PasteStructureCommon( UINT32 iMapIndex )
BOOLEAN fOkayToAdd;
if ( iMapIndex < 0x8000 )
{
{
/*
if ( gpWorldLevelData[ iMapIndex ].pStructHead != NULL )
{
@@ -566,7 +565,7 @@ void PasteStructureCommon( UINT32 iMapIndex )
iRandSelIndex = GetRandomSelection( );
if ( iRandSelIndex == -1 )
{
return;
return;
}
AddToUndoList( iMapIndex );
@@ -581,9 +580,9 @@ void PasteStructureCommon( UINT32 iMapIndex )
// Actual structure info is added by the functions below
AddStructToHead( iMapIndex, (UINT16)(gTileTypeStartIndex[ usUseObjIndex ] + usUseIndex) );
// For now, adjust to shadows by a hard-coded amount,
// Add mask if in long grass
GetLandHeadType( iMapIndex, &fHeadType );
GetLandHeadType( iMapIndex, &fHeadType );
}
}
}
@@ -606,7 +605,7 @@ void PasteBanks( UINT32 iMapIndex, UINT16 usStructIndex , BOOLEAN fReplace)
UINT16 usUseIndex;
UINT16 usUseObjIndex;
UINT16 usIndex;
pSelList = SelBanks;
pNumSelList = &iNumBanksSelected;
@@ -614,10 +613,10 @@ void PasteBanks( UINT32 iMapIndex, UINT16 usStructIndex , BOOLEAN fReplace)
usUseObjIndex = (UINT16)pSelList[ iCurBank ].uiObject;
if ( iMapIndex < 0x8000 )
{
{
fDoPaste = TRUE;
if ( gpWorldLevelData[ iMapIndex ].pStructHead != NULL )
if ( gpWorldLevelData[ iMapIndex ].pStructHead != NULL )
{
// CHECK IF THE SAME TILE IS HERE
if ( gpWorldLevelData[ iMapIndex ].pStructHead->usIndex == (UINT16)( gTileTypeStartIndex[ usUseObjIndex ] + usUseIndex ) )
@@ -647,7 +646,7 @@ void PasteBanks( UINT32 iMapIndex, UINT16 usStructIndex , BOOLEAN fReplace)
{
AddStructToHead( iMapIndex, (UINT16)( gTileTypeStartIndex[ usUseObjIndex ] + usUseIndex ) );
// Add shadows
if ( !gfBasement && usUseObjIndex == FIRSTCLIFF )
if ( !gfBasement && usUseObjIndex == FIRSTCLIFF )
{
//AddShadowToHead( iMapIndex, (UINT16)( gTileTypeStartIndex[ usUseObjIndex - FIRSTCLIFF + FIRSTCLIFFSHADOW ] + usUseIndex ) );
AddObjectToHead( iMapIndex, (UINT16)( gTileTypeStartIndex[ usUseObjIndex - FIRSTCLIFF + FIRSTCLIFFHANG ] + usUseIndex ) );
@@ -661,7 +660,7 @@ void PasteBanks( UINT32 iMapIndex, UINT16 usStructIndex , BOOLEAN fReplace)
void PasteRoads( UINT32 iMapIndex )
{
UINT16 usUseIndex;
pSelList = SelRoads;
pNumSelList = &iNumRoadsSelected;
@@ -691,56 +690,56 @@ void PasteTexture( UINT32 iMapIndex )
//
void PasteTextureCommon( UINT32 iMapIndex )
{
UINT8 ubLastHighLevel;
UINT16 usTileIndex;
//UINT16 Dummy;
if ( CurrentPaste != NO_TILE && iMapIndex < 0x8000 )
{
UINT8 ubLastHighLevel;
UINT16 usTileIndex;
//UINT16 Dummy;
// Set undo, then set new
AddToUndoList( iMapIndex );
if ( CurrentPaste != NO_TILE && iMapIndex < 0x8000 )
{
if ( CurrentPaste == DEEPWATERTEXTURE )
{
// IF WE ARE PASTING DEEP WATER AND WE ARE NOT OVER WATER, IGNORE!
if ( TypeExistsInLandLayer( iMapIndex, REGWATERTEXTURE, &usTileIndex ) )
{
// Set undo, then set new
AddToUndoList( iMapIndex );
if ( CurrentPaste == DEEPWATERTEXTURE )
{
// IF WE ARE PASTING DEEP WATER AND WE ARE NOT OVER WATER, IGNORE!
if ( TypeExistsInLandLayer( iMapIndex, REGWATERTEXTURE, &usTileIndex ) )
{
if ( !gTileDatabase[ usTileIndex ].ubFullTile )
{
return;
return;
}
}
else
{
}
else
{
return;
}
}
}
}
// Don't draw over floors
if ( TypeRangeExistsInLandLayer( iMapIndex, FIRSTFLOOR, FOURTHFLOOR, &usTileIndex ) )
{
return;
}
// Don't draw over floors
if ( TypeRangeExistsInLandLayer( iMapIndex, FIRSTFLOOR, FOURTHFLOOR, &usTileIndex ) )
{
return;
}
// Compare heights and do appropriate action
if ( AnyHeigherLand( iMapIndex, CurrentPaste, &ubLastHighLevel ) )
{
// Here we do the following:
// - Remove old type from layer
// - Smooth World with old type
// - Add a 3 by 3 square of new type at head
// - Smooth World with new type
PasteHigherTexture( iMapIndex, CurrentPaste );
// Compare heights and do appropriate action
if ( AnyHeigherLand( iMapIndex, CurrentPaste, &ubLastHighLevel ) )
{
// Here we do the following:
// - Remove old type from layer
// - Smooth World with old type
// - Add a 3 by 3 square of new type at head
// - Smooth World with new type
PasteHigherTexture( iMapIndex, CurrentPaste );
}
else
{
}
else
{
PasteTextureEx( (INT16)iMapIndex, CurrentPaste );
SmoothTerrainRadius( iMapIndex, CurrentPaste, 1, TRUE );
}
}
}
}
@@ -753,17 +752,17 @@ void PasteTextureCommon( UINT32 iMapIndex )
//
void PasteHigherTexture( UINT32 iMapIndex, UINT32 fNewType )
{
UINT16 NewTile;
UINT8 ubLastHighLevel;
UINT32 *puiDeletedTypes = NULL;
UINT8 ubNumTypes;
UINT8 cnt;
UINT16 NewTile;
UINT8 ubLastHighLevel;
UINT32 *puiDeletedTypes = NULL;
UINT8 ubNumTypes;
UINT8 cnt;
// Here we do the following:
// - Remove old type from layer
// - Smooth World with old type
// - Add a 3 by 3 square of new type at head
// - Smooth World with new type
// Here we do the following:
// - Remove old type from layer
// - Smooth World with old type
// - Add a 3 by 3 square of new type at head
// - Smooth World with new type
//if ( iMapIndex < 0x8000 && TypeRangeExistsInLandLayer( iMapIndex, FIRSTFLOOR, LASTFLOOR, &NewTile ) )
//ATE: DONOT DO THIS!!!!!!! - I know what was intended - not to draw over floors - this
@@ -771,41 +770,41 @@ void PasteHigherTexture( UINT32 iMapIndex, UINT32 fNewType )
//return;
if ( iMapIndex < 0x8000 && AnyHeigherLand( iMapIndex, fNewType, &ubLastHighLevel ))
{
AddToUndoList( iMapIndex );
if ( iMapIndex < 0x8000 && AnyHeigherLand( iMapIndex, fNewType, &ubLastHighLevel ))
{
AddToUndoList( iMapIndex );
// - For all heigher level, remove
RemoveHigherLandLevels( iMapIndex, fNewType, &puiDeletedTypes, &ubNumTypes );
// - For all heigher level, remove
RemoveHigherLandLevels( iMapIndex, fNewType, &puiDeletedTypes, &ubNumTypes );
// Set with a radius of 1 and smooth according to height difference
SetLowerLandIndexWithRadius( iMapIndex, fNewType, 1 , TRUE );
// Set with a radius of 1 and smooth according to height difference
SetLowerLandIndexWithRadius( iMapIndex, fNewType, 1 , TRUE );
// Smooth all deleted levels
for ( cnt = 0; cnt < ubNumTypes; cnt++ )
{
// Smooth all deleted levels
for ( cnt = 0; cnt < ubNumTypes; cnt++ )
{
SmoothTerrainRadius( iMapIndex, puiDeletedTypes[ cnt ], 1, TRUE );
}
}
MemFree( puiDeletedTypes );
MemFree( puiDeletedTypes );
}
else if ( iMapIndex < 0x8000 )
{
}
else if ( iMapIndex < 0x8000 )
{
AddToUndoList( iMapIndex );
GetTileIndexFromTypeSubIndex( fNewType, REQUIRES_SMOOTHING_TILE, &NewTile );
GetTileIndexFromTypeSubIndex( fNewType, REQUIRES_SMOOTHING_TILE, &NewTile );
SetLandIndex( iMapIndex, NewTile, fNewType, FALSE );
// Smooth item then adding here
SmoothTerrain( iMapIndex, fNewType, &NewTile, FALSE );
if ( NewTile != NO_TILE )
{
if ( NewTile != NO_TILE )
{
// Change tile
SetLandIndex( iMapIndex, NewTile, fNewType, FALSE );
}
}
}
}
}
@@ -816,17 +815,17 @@ void PasteHigherTexture( UINT32 iMapIndex, UINT32 fNewType )
//
BOOLEAN PasteHigherTextureFromRadius( INT32 iMapIndex, UINT32 uiNewType, UINT8 ubRadius )
{
INT16 sTop, sBottom;
INT16 sLeft, sRight;
INT16 cnt1, cnt2;
INT16 sTop, sBottom;
INT16 sLeft, sRight;
INT16 cnt1, cnt2;
INT32 iNewIndex;
INT32 iXPos,iYPos;
// Determine start and end indicies and num rows
sTop = ubRadius;
sBottom = -ubRadius;
sLeft = -ubRadius;
sRight = ubRadius;
sLeft = -ubRadius;
sRight = ubRadius;
iXPos = (iMapIndex % WORLD_COLS);
iYPos = (iMapIndex - iXPos) / WORLD_COLS;
@@ -870,7 +869,7 @@ BOOLEAN PasteExistingTexture( UINT32 iMapIndex, UINT16 usIndex )
//UINT16 Dummy;
// If here, we want to make, esentially, what is a type in
// a level other than TOP-MOST the TOP-MOST level.
// a level other than TOP-MOST the TOP-MOST level.
// We should:
// - remove what was top-most
// - re-adjust the world to reflect missing top-most peice
@@ -881,7 +880,7 @@ BOOLEAN PasteExistingTexture( UINT32 iMapIndex, UINT16 usIndex )
//if ( TypeRangeExistsInLandLayer( iMapIndex, FIRSTFLOOR, LASTFLOOR, &Dummy ) )
// return( FALSE );
// Get top tile index
// Get top tile index
// Remove all land peices except
GetTileType( usIndex, &uiNewType );
@@ -899,7 +898,7 @@ BOOLEAN PasteExistingTexture( UINT32 iMapIndex, UINT16 usIndex )
SetLandIndex( iMapIndex, usIndex, uiNewType, FALSE );
// ATE: Set this land peice to require smoothing again!
SmoothAllTerrainTypeRadius( iMapIndex, 2, TRUE );
SmoothAllTerrainTypeRadius( iMapIndex, 2, TRUE );
return( TRUE );
}
@@ -912,21 +911,21 @@ BOOLEAN PasteExistingTexture( UINT32 iMapIndex, UINT16 usIndex )
//
BOOLEAN PasteExistingTextureFromRadius( INT32 iMapIndex, UINT16 usIndex, UINT8 ubRadius )
{
INT16 sTop, sBottom;
INT16 sLeft, sRight;
INT16 cnt1, cnt2;
INT16 sTop, sBottom;
INT16 sLeft, sRight;
INT16 cnt1, cnt2;
INT32 iNewIndex;
INT32 leftmost;
// Determine start end end indicies and num rows
sTop = ubRadius;
sBottom = -ubRadius;
sLeft = - ubRadius;
sRight = ubRadius;
sLeft = - ubRadius;
sRight = ubRadius;
if ( iMapIndex >= 0x8000 )
return ( FALSE );
for( cnt1 = sBottom; cnt1 <= sTop; cnt1++ )
{
@@ -936,8 +935,8 @@ BOOLEAN PasteExistingTextureFromRadius( INT32 iMapIndex, UINT16 usIndex, UINT8 u
{
iNewIndex = iMapIndex + ( WORLD_COLS * cnt1 ) + cnt2;
if ( iNewIndex >=0 && iNewIndex < WORLD_MAX &&
iNewIndex >= leftmost && iNewIndex < ( leftmost + WORLD_COLS ) )
if ( iNewIndex >=0 && iNewIndex < WORLD_MAX &&
iNewIndex >= leftmost && iNewIndex < ( leftmost + WORLD_COLS ) )
{
AddToUndoList( iMapIndex );
PasteExistingTexture( iNewIndex, usIndex );
@@ -961,20 +960,20 @@ BOOLEAN SetLowerLandIndexWithRadius( INT32 iMapIndex, UINT32 uiNewType, UINT8 ub
INT16 sTop, sBottom;
INT16 sLeft, sRight;
INT16 cnt1, cnt2;
INT32 iNewIndex;
INT32 iNewIndex;
BOOLEAN fDoPaste = FALSE;
INT32 leftmost;
UINT8 ubLastHighLevel;
UINT32 *puiSmoothTiles = NULL;
INT16 sNumSmoothTiles = 0;
UINT32 *puiSmoothTiles = NULL;
INT16 sNumSmoothTiles = 0;
UINT16 usTemp;
UINT16 NewTile; //,Dummy;
// Determine start end end indicies and num rows
sTop = ubRadius;
sBottom = -ubRadius;
sLeft = - ubRadius;
sRight = ubRadius;
sLeft = - ubRadius;
sRight = ubRadius;
if ( iMapIndex >= 0x8000 )
return ( FALSE );
@@ -988,8 +987,8 @@ BOOLEAN SetLowerLandIndexWithRadius( INT32 iMapIndex, UINT32 uiNewType, UINT8 ub
{
iNewIndex = iMapIndex + ( WORLD_COLS * cnt1 ) + cnt2;
if ( iNewIndex >=0 && iNewIndex < WORLD_MAX &&
iNewIndex >= leftmost && iNewIndex < ( leftmost + WORLD_COLS ) )
if ( iNewIndex >=0 && iNewIndex < WORLD_MAX &&
iNewIndex >= leftmost && iNewIndex < ( leftmost + WORLD_COLS ) )
{
if ( fReplace )
@@ -1003,9 +1002,9 @@ BOOLEAN SetLowerLandIndexWithRadius( INT32 iMapIndex, UINT32 uiNewType, UINT8 ub
fDoPaste = TRUE;
}
}
//if ( fDoPaste && !TypeRangeExistsInLandLayer( iMapIndex, FIRSTFLOOR, LASTFLOOR, &Dummy ) )
if ( fDoPaste )
if ( fDoPaste )
{
if ( iMapIndex == iNewIndex )
{
@@ -1046,7 +1045,7 @@ BOOLEAN SetLowerLandIndexWithRadius( INT32 iMapIndex, UINT32 uiNewType, UINT8 ub
// Once here, smooth any tiles that need it
if ( sNumSmoothTiles > 0 )
{
for ( cnt1 = 0; cnt1 < sNumSmoothTiles; cnt1++ )
for ( cnt1 = 0; cnt1 < sNumSmoothTiles; cnt1++ )
{
SmoothTerrainRadius( puiSmoothTiles[ cnt1 ], uiNewType, 10, FALSE );
@@ -1062,17 +1061,17 @@ BOOLEAN SetLowerLandIndexWithRadius( INT32 iMapIndex, UINT32 uiNewType, UINT8 ub
void PasteTextureEx( INT16 sGridNo, UINT16 usType )
{
UINT16 usIndex;
UINT8 ubTypeLevel;
UINT8 ubTypeLevel;
UINT16 NewTile;
// CHECK IF THIS TEXTURE EXISTS!
if ( TypeExistsInLandLayer( sGridNo, usType, &usIndex ) )
{
if ( TypeExistsInLandLayer( sGridNo, usType, &usIndex ) )
{
if ( GetTypeLandLevel( sGridNo, usType, &ubTypeLevel ) )
{
// If top-land , do not change
if ( ubTypeLevel != LANDHEAD )
{
{
PasteExistingTexture( sGridNo, usIndex );
}
}
@@ -1080,10 +1079,10 @@ void PasteTextureEx( INT16 sGridNo, UINT16 usType )
else
{
// Fill with just first tile, smoothworld() will pick proper piece later
GetTileIndexFromTypeSubIndex( usType, REQUIRES_SMOOTHING_TILE, &NewTile );
// Fill with just first tile, smoothworld() will pick proper piece later
GetTileIndexFromTypeSubIndex( usType, REQUIRES_SMOOTHING_TILE, &NewTile );
SetLandIndex( sGridNo, NewTile, usType, FALSE );
SetLandIndex( sGridNo, NewTile, usType, FALSE );
}
}
@@ -1091,21 +1090,21 @@ void PasteTextureEx( INT16 sGridNo, UINT16 usType )
void PasteTextureFromRadiusEx( INT16 sGridNo, UINT16 usType, UINT8 ubRadius )
{
INT16 sTop, sBottom;
INT16 sLeft, sRight;
INT16 cnt1, cnt2;
INT16 sTop, sBottom;
INT16 sLeft, sRight;
INT16 cnt1, cnt2;
INT32 iNewIndex;
INT32 leftmost;
// Determine start end end indicies and num rows
sTop = ubRadius;
sBottom = -ubRadius;
sLeft = - ubRadius;
sRight = ubRadius;
sLeft = - ubRadius;
sRight = ubRadius;
if ( sGridNo >= 0x8000 )
return;
for( cnt1 = sBottom; cnt1 <= sTop; cnt1++ )
{
@@ -1115,8 +1114,8 @@ void PasteTextureFromRadiusEx( INT16 sGridNo, UINT16 usType, UINT8 ubRadius )
{
iNewIndex = sGridNo + ( WORLD_COLS * cnt1 ) + cnt2;
if ( iNewIndex >=0 && iNewIndex < WORLD_MAX &&
iNewIndex >= leftmost && iNewIndex < ( leftmost + WORLD_COLS ) )
if ( iNewIndex >=0 && iNewIndex < WORLD_MAX &&
iNewIndex >= leftmost && iNewIndex < ( leftmost + WORLD_COLS ) )
{
PasteTextureEx( sGridNo, usType );
}
@@ -1145,12 +1144,10 @@ void RaiseWorldLand( )
BOOLEAN fSomethingRaised = FALSE;
UINT8 ubLoop;
UINT16 usIndex;
BOOLEAN fStopRaise = FALSE;
INT32 iCounterA = 0, iCounterB = 0;
INT32 iStartNumberOfRaises = 0;
INT32 iNumberOfRaises = 0;
BOOLEAN fAboutToRaise = FALSE;
fRaise=FALSE;
fRaiseSet=FALSE;
@@ -1160,7 +1157,7 @@ void RaiseWorldLand( )
gpWorldLevelData[cnt].uiFlags &= (~MAPELEMENT_RAISE_LAND_END );
}
for ( cnt = 0; cnt < WORLD_MAX; cnt++ )
{
@@ -1176,13 +1173,12 @@ void RaiseWorldLand( )
pStruct = pStruct->pNext;
continue;
}
pTileElement = &(gTileDatabase[ pStruct->usIndex ]);
if (pTileElement->fType==FIRSTCLIFF)
{
{
fSomethingRaised = TRUE;
usIndex=pStruct->usIndex;
// DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("Cliff found at count=%d",cnt));
// DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("Cliff found at count=%d",cnt));
if( pTileElement->ubNumberOfTiles > 1 )
{
// DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("Cliff has %d children", pTileElement->ubNumberOfTiles));
@@ -1194,7 +1190,7 @@ void RaiseWorldLand( )
// presently by CLIFF object/tileset 1
// so simply detect this tile set and turn off instead of on
// element 1 is 12 tiles and is unique
sTempGridNo = cnt + pTileElement->pTileLocData[ubLoop].bTileOffsetX + pTileElement->pTileLocData[ubLoop].bTileOffsetY * WORLD_COLS;
// Check for valid gridno
if ( OutOfBounds( (INT16)cnt, (INT16)sTempGridNo ) )
@@ -1202,7 +1198,7 @@ void RaiseWorldLand( )
continue;
}
//if (pTileElement->ubNumberOfTiles==10)
if((usIndex==LAND_DROP_1)||(usIndex==LAND_DROP_2) ||(usIndex==LAND_DROP_4))
if((usIndex==LAND_DROP_1)||(usIndex==LAND_DROP_2) ||(usIndex==LAND_DROP_4))
{
gpWorldLevelData[sTempGridNo].uiFlags &= (~MAPELEMENT_RAISE_LAND_START );
gpWorldLevelData[sTempGridNo].uiFlags |= MAPELEMENT_RAISE_LAND_END;
@@ -1267,10 +1263,10 @@ void RaiseWorldLand( )
}
if (gpWorldLevelData[cnt].uiFlags&MAPELEMENT_RAISE_LAND_START)
{
fRaiseSet=TRUE;
fRaiseSet=TRUE;
}
else if((gpWorldLevelData[cnt].uiFlags&MAPELEMENT_RAISE_LAND_END)&&(!fRaiseSet))
{
{
// there is a dropoff without a rise.
// back up and set beginning to raiseland start
gpWorldLevelData[cnt+((WORLD_ROWS-1)-(cnt%WORLD_ROWS))].uiFlags &= (~MAPELEMENT_RAISE_LAND_END );
@@ -1302,7 +1298,7 @@ void RaiseWorldLand( )
fRaiseSet = FALSE;
}
else if((gpWorldLevelData[cnt].uiFlags&MAPELEMENT_RAISE_LAND_END)||(gpWorldLevelData[cnt-1].uiFlags&MAPELEMENT_RAISE_LAND_END) || ( gpWorldLevelData[cnt+1].uiFlags&MAPELEMENT_RAISE_LAND_END) )
{
{
fRaiseSet=FALSE;
}
if (fRaiseSet)
@@ -1319,20 +1315,20 @@ void RaiseWorldLand( )
// Now go through the world, starting at x=max(x) and y=max(y) and work backwards
// if a cliff is found turn raise flag on, if the end of a screen is found, turn off
// the system uses world_cord=x+y*(row_size)
// the system uses world_cord=x+y*(row_size)
for (cnt=WORLD_MAX-1; cnt >= 0; cnt--)
for (cnt=WORLD_MAX-1; cnt >= 0; cnt--)
{
// reset the RAISE to FALSE
// End of the row
// reset the RAISE to FALSE
// End of the row
if ( !(cnt % WORLD_ROWS) )
{
iNumberOfRaises = 0;
iStartNumberOfRaises = 0;
}
if( ( gpWorldLevelData[cnt].uiFlags & MAPELEMENT_RAISE_LAND_END ) )
if( ( gpWorldLevelData[cnt].uiFlags & MAPELEMENT_RAISE_LAND_END ) )
{
if( cnt > 1 )
{
@@ -1344,11 +1340,11 @@ void RaiseWorldLand( )
}
else if( gpWorldLevelData[cnt].uiFlags & MAPELEMENT_RAISE_LAND_START )
{
// check tile before and after, if either are raise land flagged, then don't increment number of
// check tile before and after, if either are raise land flagged, then don't increment number of
// raises
if( cnt < WORLD_MAX - 2 )
{
if( ( !( gpWorldLevelData[ cnt + 1 ].uiFlags & MAPELEMENT_RAISE_LAND_START) && !( gpWorldLevelData[ cnt + 2 ].uiFlags & MAPELEMENT_RAISE_LAND_START ) ) )
if( ( !( gpWorldLevelData[ cnt + 1 ].uiFlags & MAPELEMENT_RAISE_LAND_START) && !( gpWorldLevelData[ cnt + 2 ].uiFlags & MAPELEMENT_RAISE_LAND_START ) ) )
{
iNumberOfRaises++;
}
@@ -1365,7 +1361,7 @@ void RaiseWorldLand( )
iNumberOfRaises = iStartNumberOfRaises;
continue;
}
if( iNumberOfRaises >= 0 )
{
//DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("Land Raise start at count: %d is raised",cnt ));
@@ -1373,19 +1369,19 @@ void RaiseWorldLand( )
}
}
for (cnt=WORLD_MAX-1; cnt >= 0; cnt--)
for (cnt=WORLD_MAX-1; cnt >= 0; cnt--)
{
if( ( cnt < WORLD_MAX - WORLD_ROWS ) && ( cnt > WORLD_ROWS ) )
{
if( ( gpWorldLevelData[cnt + WORLD_ROWS ].sHeight == gpWorldLevelData[cnt - WORLD_ROWS ].sHeight ) && ( gpWorldLevelData[ cnt ].sHeight!= gpWorldLevelData[cnt - WORLD_ROWS ].sHeight ) )
if( ( gpWorldLevelData[cnt + WORLD_ROWS ].sHeight == gpWorldLevelData[cnt - WORLD_ROWS ].sHeight ) && ( gpWorldLevelData[ cnt ].sHeight!= gpWorldLevelData[cnt - WORLD_ROWS ].sHeight ) )
{
gpWorldLevelData[cnt].sHeight = gpWorldLevelData[cnt + WORLD_ROWS ].sHeight;
}
else if( ( gpWorldLevelData[ cnt ].sHeight > gpWorldLevelData[cnt - WORLD_ROWS ].sHeight )&& ( gpWorldLevelData[cnt + WORLD_ROWS ].sHeight != gpWorldLevelData[cnt - WORLD_ROWS ].sHeight ) && ( gpWorldLevelData[cnt ].sHeight > gpWorldLevelData[cnt + WORLD_ROWS ].sHeight ) )
else if( ( gpWorldLevelData[ cnt ].sHeight > gpWorldLevelData[cnt - WORLD_ROWS ].sHeight )&& ( gpWorldLevelData[cnt + WORLD_ROWS ].sHeight != gpWorldLevelData[cnt - WORLD_ROWS ].sHeight ) && ( gpWorldLevelData[cnt ].sHeight > gpWorldLevelData[cnt + WORLD_ROWS ].sHeight ) )
{
if( gpWorldLevelData[cnt - WORLD_ROWS ].sHeight > gpWorldLevelData[cnt + WORLD_ROWS ].sHeight )
{
gpWorldLevelData[ cnt ].sHeight = gpWorldLevelData[cnt - WORLD_ROWS ].sHeight;
gpWorldLevelData[ cnt ].sHeight = gpWorldLevelData[cnt - WORLD_ROWS ].sHeight;
}
else
{
@@ -1448,6 +1444,7 @@ void EliminateObjectLayerRedundancy()