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
+121 -120
View File
@@ -61,73 +61,73 @@ UINT16 GetCaveTileIndexFromPerimeterValue( UINT8 ubTotal )
UINT16 usType = FIRSTWALL;
UINT16 usIndex;
UINT16 usTileIndex;
switch( ubTotal )
{
case 0x00: case 0x10: case 0x20: case 0x30: case 0x40: case 0x50: case 0x60: case 0x70:
case 0x00: case 0x10: case 0x20: case 0x30: case 0x40: case 0x50: case 0x60: case 0x70:
case 0x80: case 0x90: case 0xa0: case 0xb0: case 0xc0: case 0xd0: case 0xe0: case 0xf0:
//usIndex = 0;
//usIndex = 0;
//break;
return 0xffff;
case 0x01: case 0x11: case 0x21: case 0x31: case 0x41: case 0x51: case 0x61: case 0x71:
case 0x01: case 0x11: case 0x21: case 0x31: case 0x41: case 0x51: case 0x61: case 0x71:
case 0x81: case 0x91: case 0xa1: case 0xb1: case 0xc1: case 0xd1: case 0xe1: case 0xf1:
usType = SECONDWALL;
usIndex = 1 + (UINT16)Random( 4 );
usIndex = 1 + (UINT16)Random( 4 );
break;
case 0x02: case 0x12: case 0x22: case 0x32: case 0x42: case 0x52: case 0x62: case 0x72:
case 0x02: case 0x12: case 0x22: case 0x32: case 0x42: case 0x52: case 0x62: case 0x72:
case 0x82: case 0x92: case 0xa2: case 0xb2: case 0xc2: case 0xd2: case 0xe2: case 0xf2:
usType = SECONDWALL;
usIndex = 5 + (UINT16)Random( 4 );
usIndex = 5 + (UINT16)Random( 4 );
break;
case 0x03: case 0x13: case 0x43: case 0x53: case 0x83: case 0x93: case 0xc3: case 0xd3:
usIndex = 1;
case 0x03: case 0x13: case 0x43: case 0x53: case 0x83: case 0x93: case 0xc3: case 0xd3:
usIndex = 1;
break;
case 0x04: case 0x14: case 0x24: case 0x34: case 0x44: case 0x54: case 0x64: case 0x74:
case 0x04: case 0x14: case 0x24: case 0x34: case 0x44: case 0x54: case 0x64: case 0x74:
case 0x84: case 0x94: case 0xa4: case 0xb4: case 0xc4: case 0xd4: case 0xe4: case 0xf4:
usType = SECONDWALL;
usIndex = 9 + (UINT16)Random( 4 );
usIndex = 9 + (UINT16)Random( 4 );
break;
case 0x05: case 0x15: case 0x25: case 0x35: case 0x45: case 0x55: case 0x65: case 0x75:
case 0x05: case 0x15: case 0x25: case 0x35: case 0x45: case 0x55: case 0x65: case 0x75:
case 0x85: case 0x95: case 0xa5: case 0xb5: case 0xc5: case 0xd5: case 0xe5: case 0xf5:
usIndex = 2 + (UINT16)Random( 2 );
break;
case 0x06: case 0x16: case 0x26: case 0x36: case 0x86: case 0x96: case 0xa6: case 0xb6:
case 0x06: case 0x16: case 0x26: case 0x36: case 0x86: case 0x96: case 0xa6: case 0xb6:
usIndex = 4;
break;
case 0x07: case 0x17: case 0x87: case 0x97:
usIndex = 5;
break;
case 0x08: case 0x18: case 0x28: case 0x38: case 0x48: case 0x58: case 0x68: case 0x78:
case 0x08: case 0x18: case 0x28: case 0x38: case 0x48: case 0x58: case 0x68: case 0x78:
case 0x88: case 0x98: case 0xa8: case 0xb8: case 0xc8: case 0xd8: case 0xe8: case 0xf8:
usType = SECONDWALL;
usIndex = 13 + (UINT16)Random( 4 );
usIndex = 13 + (UINT16)Random( 4 );
break;
case 0x09: case 0x29: case 0x49: case 0x69: case 0x89: case 0xa9: case 0xc9: case 0xe9:
case 0x09: case 0x29: case 0x49: case 0x69: case 0x89: case 0xa9: case 0xc9: case 0xe9:
usIndex = 6;
break;
case 0x0a: case 0x1a: case 0x2a: case 0x3a: case 0x4a: case 0x5a: case 0x6a: case 0x7a:
case 0x0a: case 0x1a: case 0x2a: case 0x3a: case 0x4a: case 0x5a: case 0x6a: case 0x7a:
case 0x8a: case 0x9a: case 0xaa: case 0xba: case 0xca: case 0xda: case 0xea: case 0xfa:
usIndex = 7 + (UINT16)Random( 2 );
break;
case 0x0b: case 0x4b: case 0x8b: case 0xcb:
case 0x0b: case 0x4b: case 0x8b: case 0xcb:
usIndex = 9;
break;
case 0x0c: case 0x1c: case 0x2c: case 0x3c: case 0x4c: case 0x5c: case 0x6c: case 0x7c:
case 0x0c: case 0x1c: case 0x2c: case 0x3c: case 0x4c: case 0x5c: case 0x6c: case 0x7c:
usIndex = 10;
break;
case 0x0d: case 0x2d: case 0x4d: case 0x6d:
usIndex = 11;
break;
case 0x0e: case 0x1e: case 0x2e: case 0x3e:
case 0x0e: case 0x1e: case 0x2e: case 0x3e:
usIndex = 12;
break;
case 0x0f:
case 0x0f:
usIndex = 13;
break;
case 0x19: case 0x39: case 0x59: case 0x79: case 0x99: case 0xb9: case 0xd9: case 0xf9:
case 0x19: case 0x39: case 0x59: case 0x79: case 0x99: case 0xb9: case 0xd9: case 0xf9:
usIndex = 14 + (UINT16)Random( 2 );
break;
case 0x1b: case 0x5b: case 0x9b: case 0xdb:
case 0x1b: case 0x5b: case 0x9b: case 0xdb:
usIndex = 16;
break;
case 0x1d: case 0x3d: case 0x5d: case 0x7d:
@@ -136,31 +136,31 @@ UINT16 GetCaveTileIndexFromPerimeterValue( UINT8 ubTotal )
case 0x1f:
usIndex = 18;
break;
case 0x23: case 0x33: case 0x63: case 0x73: case 0xa3: case 0xb3: case 0xe3: case 0xf3:
case 0x23: case 0x33: case 0x63: case 0x73: case 0xa3: case 0xb3: case 0xe3: case 0xf3:
usIndex = 19 + (UINT16)Random( 2 );
break;
case 0x27: case 0x37: case 0xa7: case 0xb7:
usIndex = 21;
break;
case 0x2b: case 0x6b: case 0xab: case 0xeb:
case 0x2b: case 0x6b: case 0xab: case 0xeb:
usIndex = 22;
break;
case 0x2f:
usIndex = 23;
break;
case 0x3b: case 0x7b: case 0xbb: case 0xfb:
case 0x3b: case 0x7b: case 0xbb: case 0xfb:
usIndex = 24 + (UINT16)Random( 3 );
break;
case 0x3f:
usIndex = 27;
break;
case 0x46: case 0x56: case 0x66: case 0x76: case 0xc6: case 0xd6: case 0xe6: case 0xf6:
case 0x46: case 0x56: case 0x66: case 0x76: case 0xc6: case 0xd6: case 0xe6: case 0xf6:
usIndex = 28 + (UINT16)Random( 2 );
break;
case 0x47: case 0x57: case 0xc7: case 0xd7:
usIndex = 30;
break;
case 0x4e: case 0x5e: case 0x6e: case 0x7e:
case 0x4e: case 0x5e: case 0x6e: case 0x7e:
usIndex = 31;
break;
case 0x4f:
@@ -184,7 +184,7 @@ UINT16 GetCaveTileIndexFromPerimeterValue( UINT8 ubTotal )
case 0x8d: case 0xad: case 0xcd: case 0xed:
usIndex = 42;
break;
case 0x8e: case 0x9e: case 0xae: case 0xbe:
case 0x8e: case 0x9e: case 0xae: case 0xbe:
usIndex = 43;
break;
case 0x8f:
@@ -202,7 +202,7 @@ UINT16 GetCaveTileIndexFromPerimeterValue( UINT8 ubTotal )
case 0xbf:
usIndex = 50 + (UINT16)Random( 2 );
break;
case 0xce: case 0xde: case 0xee: case 0xfe:
case 0xce: case 0xde: case 0xee: case 0xfe:
usIndex = 52 + (UINT16)Random( 3 );
break;
case 0xcf:
@@ -227,14 +227,14 @@ UINT16 GetCaveTileIndexFromPerimeterValue( UINT8 ubTotal )
// 16 | 1 | 32
// ---+---+---
// 8 | | 2
// 8 | | 2
// ---+---+---
// 128| 4 | 64
//These values are combined in any possible order ranging in
//values from 0 - 255. If there is a cave existing in any of
//These values are combined in any possible order ranging in
//values from 0 - 255. If there is a cave existing in any of
//these bordering gridnos, then the corresponding number is added
//to this total. The lookup table has been precalculated to know
//which piece to use for all of these combinations. In many cases,
//to this total. The lookup table has been precalculated to know
//which piece to use for all of these combinations. In many cases,
//up to 16 combinations can share the same graphic image, as corners
//may not effect the look of the piece.
UINT8 CalcNewCavePerimeterValue( INT32 iMapIndex )
@@ -245,7 +245,7 @@ UINT8 CalcNewCavePerimeterValue( INT32 iMapIndex )
if( CaveAtGridNo( iMapIndex + 1 ) )
ubTotal += 0x02; //east
if( CaveAtGridNo( iMapIndex + WORLD_COLS ) )
ubTotal += 0x04; //south
ubTotal += 0x04; //south
if( CaveAtGridNo( iMapIndex - 1 ) )
ubTotal += 0x08; //west
if( CaveAtGridNo( iMapIndex - WORLD_COLS - 1 ) )
@@ -281,24 +281,24 @@ void AddCave( INT32 iMapIndex, UINT16 usIndex )
#define INTERIOR_BOTTOMEND_SHADOW_INDEX 31
//Wall Look Up Table containing variants and indices with each row being a different walltype.
INT8 gbWallTileLUT[NUM_WALL_TYPES][7] =
{
INT8 gbWallTileLUT[NUM_WALL_TYPES][7] =
{
// The number of variants of this tile type.
// | The first relative index of the wall type (FIRSTWALL, SECONDWALL, etc. ) walltype + 10
// | | The 2nd relative index ( walltype + 11 )
// | The first relative index of the wall type (FIRSTWALL, SECONDWALL, etc. ) walltype + 10
// | | The 2nd relative index ( walltype + 11 )
// | | | 3rd 4th 5th 6th
// | | | | | | |
// | | | | | | |
6, 10, 11, 12, 27, 28, 29, //INTERIOR_L
6, 7, 8, 9, 24, 25, 26, //INTERIOR_R
6, 4, 5, 6, 21, 22, 23, //EXTERIOR_L
6, 1, 2, 3, 18, 19, 20, //EXTERIOR_R
1, 14, 0, 0, 0, 0, 0, //INTERIOR_CORNER
1, 15, 0, 0, 0, 0, 0, //INTERIOR_BOTTOMEND
1, 13, 0, 0, 0, 0, 0, //EXTERIOR_BOTTOMEND
1, 16, 0, 0, 0, 0, 0, //INTERIOR_EXTENDED
1, 57, 0, 0, 0, 0, 0, //EXTERIOR_EXTENDED
1, 56, 0, 0, 0, 0, 0, //INTERIOR_EXTENDED_BOTTOMEND
1, 17, 0, 0, 0, 0, 0, //EXTERIOR_EXTENDED_BOTTOMEND
6, 7, 8, 9, 24, 25, 26, //INTERIOR_R
6, 4, 5, 6, 21, 22, 23, //EXTERIOR_L
6, 1, 2, 3, 18, 19, 20, //EXTERIOR_R
1, 14, 0, 0, 0, 0, 0, //INTERIOR_CORNER
1, 15, 0, 0, 0, 0, 0, //INTERIOR_BOTTOMEND
1, 13, 0, 0, 0, 0, 0, //EXTERIOR_BOTTOMEND
1, 16, 0, 0, 0, 0, 0, //INTERIOR_EXTENDED
1, 57, 0, 0, 0, 0, 0, //EXTERIOR_EXTENDED
1, 56, 0, 0, 0, 0, 0, //INTERIOR_EXTENDED_BOTTOMEND
1, 17, 0, 0, 0, 0, 0, //EXTERIOR_EXTENDED_BOTTOMEND
};
//Roof table -- such a small table, using definitions instead.
@@ -333,9 +333,9 @@ INT8 gbWallTileLUT[NUM_WALL_TYPES][7] =
//PRIVATELY "ENCAPSULATED" FUNCTIONS
//These construction functions do all the smoothing.
//NOTE: passing null for wall/roof type will force the function to search for the nearest
// existing respective type.
void BuildSlantRoof( INT32 iLeft, INT32 iTop, INT32 iRight, INT32 iBottom, UINT16 usWallType, UINT16 usRoofType, BOOLEAN fVertical );
//NOTE: passing null for wall/roof type will force the function to search for the nearest
// existing respective type.
void BuildSlantRoof( INT32 iLeft, INT32 iTop, INT32 iRight, INT32 iBottom, UINT16 usWallType, UINT16 usRoofType, BOOLEAN fVertical );
void BulldozeNature( UINT32 iMapIndex );
void EraseRoof( UINT32 iMapIndex );
@@ -356,10 +356,10 @@ void BuildSlantRoof( INT32 iLeft, INT32 iTop, INT32 iRight, INT32 iBottom, UINT1
if( fVertical )
{
iMapIndex = iBottom * WORLD_COLS + iLeft;
//This happens to be the only mapindex that needs to be backed up. The rest have already been
//This happens to be the only mapindex that needs to be backed up. The rest have already been
//done because of the building code before this.
AddToUndoList( iMapIndex + 8 );
//Add the closest viewable pieces. There are two aframe walls pieces, and extended aframe roof pieces.
//Add the closest viewable pieces. There are two aframe walls pieces, and extended aframe roof pieces.
GetTileIndexFromTypeSubIndex( usWallType, VWALL_LEFT, &usTileIndex );
AddRoofToHead( iMapIndex + 4, usTileIndex );
GetTileIndexFromTypeSubIndex( usWallType, VWALL_RIGHT, &usTileIndex );
@@ -385,10 +385,10 @@ void BuildSlantRoof( INT32 iLeft, INT32 iTop, INT32 iRight, INT32 iBottom, UINT1
else
{
iMapIndex = iTop * WORLD_COLS + iRight;
//This happens to be the only mapindex that needs to be backed up. The rest have already been
//This happens to be the only mapindex that needs to be backed up. The rest have already been
//done because of the building code before this.
AddToUndoList( iMapIndex + 8*WORLD_COLS );
//Add the closest viewable pieces. There are two aframe walls pieces, and extended aframe roof pieces.
//Add the closest viewable pieces. There are two aframe walls pieces, and extended aframe roof pieces.
GetTileIndexFromTypeSubIndex( usWallType, HWALL_LEFT, &usTileIndex );
AddRoofToHead( iMapIndex + 4*WORLD_COLS, usTileIndex );
GetTileIndexFromTypeSubIndex( usWallType, HWALL_RIGHT, &usTileIndex );
@@ -427,16 +427,16 @@ UINT16 PickAWallPiece( UINT16 usWallPieceType )
return usWallPieceChosen;
}
//From a given gridNo and perspective (wallpiece), it will calculate the new piece, and
//From a given gridNo and perspective (wallpiece), it will calculate the new piece, and
//where to place it as well as handle the special cases.
//NOTE: Placing top and left pieces are placed relative to the gridno, and the gridNo will
// shift accordingly to place the piece. Pretend you are the floor, and you want to place a piece to
// the left. You pass your position, and INTERIOR_LEFT, with interior meaning from the inside of a
// building. If you were outside the building, you would call EXTERIOR_LEFT. The left tile will be
// placed on gridNo - 1! Up tiles will be placed on gridNo - 160.
//NOTE: Passing NULL for usWallType will force it to calculate the closest existing wall type, and
// use that for building this new wall. It is necessary for restructuring a building, but not for
// adding on to an existing building, where the type is already known.
//NOTE: Placing top and left pieces are placed relative to the gridno, and the gridNo will
// shift accordingly to place the piece. Pretend you are the floor, and you want to place a piece to
// the left. You pass your position, and INTERIOR_LEFT, with interior meaning from the inside of a
// building. If you were outside the building, you would call EXTERIOR_LEFT. The left tile will be
// placed on gridNo - 1! Up tiles will be placed on gridNo - 160.
//NOTE: Passing NULL for usWallType will force it to calculate the closest existing wall type, and
// use that for building this new wall. It is necessary for restructuring a building, but not for
// adding on to an existing building, where the type is already known.
void BuildWallPiece( UINT32 iMapIndex, UINT8 ubWallPiece, UINT16 usWallType )
{
INT16 sIndex;
@@ -461,7 +461,7 @@ void BuildWallPiece( UINT32 iMapIndex, UINT8 ubWallPiece, UINT16 usWallType )
AddExclusiveShadow( iMapIndex - 1, usTileIndex );
}
if ( pStruct = GetVerticalWall( iMapIndex ) ) //right corner
{ //Special case where placing the new wall will generate a corner to the right, so replace
{ //Special case where placing the new wall will generate a corner to the right, so replace
//the vertical piece with a bottomend.
sIndex = PickAWallPiece( EXTERIOR_BOTTOMEND );
AddToUndoList( iMapIndex );
@@ -489,7 +489,7 @@ void BuildWallPiece( UINT32 iMapIndex, UINT8 ubWallPiece, UINT16 usWallType )
ubWallClass = EXTERIOR_R;
iMapIndex--;
if( GetHorizontalWall( iMapIndex ) )
{ //Special case where placing the new wall will generate a corner. This piece
{ //Special case where placing the new wall will generate a corner. This piece
//becomes an exterior bottomend, but nothing else is effected.
ubWallClass = EXTERIOR_BOTTOMEND;
}
@@ -522,7 +522,7 @@ void BuildWallPiece( UINT32 iMapIndex, UINT8 ubWallPiece, UINT16 usWallType )
AddToUndoList( iMapIndex + WORLD_COLS - 1 );
GetTileIndexFromTypeSubIndex( usWallType, sIndex, &usTileIndex );
ReplaceStructIndex( iMapIndex + WORLD_COLS - 1, pStruct->usIndex, usTileIndex );
//NOTE: Not yet checking for interior extended bottomend!
//NOTE: Not yet checking for interior extended bottomend!
}
if( pStruct = GetVerticalWall( iMapIndex ) )
{
@@ -535,7 +535,7 @@ void BuildWallPiece( UINT32 iMapIndex, UINT8 ubWallPiece, UINT16 usWallType )
case INTERIOR_BOTTOM:
ubWallClass = EXTERIOR_L;
if( pStruct = GetVerticalWall( iMapIndex ) ) //right corner
{ //Special case where placing the new wall will generate a corner to the right, so replace
{ //Special case where placing the new wall will generate a corner to the right, so replace
//the vertical piece with a bottomend.
sIndex = PickAWallPiece( EXTERIOR_BOTTOMEND );
AddToUndoList( iMapIndex );
@@ -580,7 +580,7 @@ void BuildWallPiece( UINT32 iMapIndex, UINT8 ubWallPiece, UINT16 usWallType )
case INTERIOR_RIGHT:
ubWallClass = EXTERIOR_R;
if( GetHorizontalWall( iMapIndex ) )
{ //Special case where placing the new wall will generate a corner. This piece
{ //Special case where placing the new wall will generate a corner. This piece
//becomes an exterior bottomend, but nothing else is effected.
ubWallClass = EXTERIOR_BOTTOMEND;
}
@@ -591,8 +591,8 @@ void BuildWallPiece( UINT32 iMapIndex, UINT8 ubWallPiece, UINT16 usWallType )
else
ubWallClass = EXTERIOR_EXTENDED;
}
if( !gfBasement && GetHorizontalWall( iMapIndex + 1 ) && !GetHorizontalWall( iMapIndex )
&& !FloorAtGridNo( iMapIndex + WORLD_COLS ) )
if( !gfBasement && GetHorizontalWall( iMapIndex + 1 ) && !GetHorizontalWall( iMapIndex )
&& !FloorAtGridNo( iMapIndex + WORLD_COLS ) )
{
GetTileIndexFromTypeSubIndex( usWallType, INTERIOR_BOTTOMEND_SHADOW_INDEX, &usTileIndex );
AddExclusiveShadow( iMapIndex, usTileIndex );
@@ -618,9 +618,9 @@ void RebuildRoofUsingFloorInfo( INT32 iMapIndex, UINT16 usRoofType )
usRoofType = SearchForRoofType( iMapIndex );
}
if( usRoofType == 0xffff )
return; //no roof type around, so don't draw one.
return; //no roof type around, so don't draw one.
//Analyse the mapindex for walls and set the flags.
//NOTE: There is no support for more than 2 side on a roof, so if there is, draw TOPLEFT
//NOTE: There is no support for more than 2 side on a roof, so if there is, draw TOPLEFT
AddToUndoList( iMapIndex );
EraseRoof( iMapIndex );
@@ -648,8 +648,8 @@ void RebuildRoofUsingFloorInfo( INT32 iMapIndex, UINT16 usRoofType )
//Given a gridno, it will erase the current roof, and calculate the new roof piece based on the
//wall orientions giving priority to the top and left walls before anything else.
//NOTE: passing NULL for usRoofType will force the function to calculate the nearest roof type,
// and use that for the new roof. This is needed when erasing parts of multiple buildings simultaneously.
//NOTE: passing NULL for usRoofType will force the function to calculate the nearest roof type,
// and use that for the new roof. This is needed when erasing parts of multiple buildings simultaneously.
void RebuildRoof( UINT32 iMapIndex, UINT16 usRoofType )
{
UINT16 usRoofIndex, usTileIndex;
@@ -659,9 +659,9 @@ void RebuildRoof( UINT32 iMapIndex, UINT16 usRoofType )
usRoofType = SearchForRoofType( iMapIndex );
}
if( usRoofType == 0xffff )
return; //no roof type around, so don't draw one.
return; //no roof type around, so don't draw one.
//Analyse the mapindex for walls and set the flags.
//NOTE: There is no support for more than 2 side on a roof, so if there is, draw TOPLEFT
//NOTE: There is no support for more than 2 side on a roof, so if there is, draw TOPLEFT
AddToUndoList( iMapIndex );
EraseRoof( iMapIndex );
@@ -685,7 +685,7 @@ void RebuildRoof( UINT32 iMapIndex, UINT16 usRoofType )
{
HideStructOfGivenType( iMapIndex, usRoofType, TRUE );
}
}
}
void BulldozeNature( UINT32 iMapIndex )
{
@@ -702,7 +702,7 @@ void BulldozeNature( UINT32 iMapIndex )
void EraseRoof( UINT32 iMapIndex )
{
AddToUndoList( iMapIndex );
RemoveAllRoofsOfTypeRange( iMapIndex, FIRSTTEXTURE, LASTITEM );
RemoveAllRoofsOfTypeRange( iMapIndex, FIRSTTEXTURE, LASTITEM );
RemoveAllOnRoofsOfTypeRange( iMapIndex, FIRSTTEXTURE, LASTITEM );
RemoveAllShadowsOfTypeRange( iMapIndex, FIRSTROOF, LASTSLANTROOF );
}
@@ -737,7 +737,7 @@ void EraseBuilding( UINT32 iMapIndex )
//and the TOP_LEFT oriented wall in the gridno up one as well as the other building information at this
//gridno.
void EraseFloorOwnedBuildingPieces( UINT32 iMapIndex )
{
{
LEVELNODE *pStruct = NULL;
UINT32 uiTileType;
UINT16 usWallOrientation;
@@ -755,7 +755,7 @@ void EraseFloorOwnedBuildingPieces( UINT32 iMapIndex )
{
GetTileType( pStruct->usIndex, &uiTileType );
if ( uiTileType >= FIRSTWALL && uiTileType <= LASTWALL ||
uiTileType >= FIRSTDOOR && uiTileType <= LASTDOOR )
uiTileType >= FIRSTDOOR && uiTileType <= LASTDOOR )
{
GetWallOrientation( pStruct->usIndex, &usWallOrientation );
if( usWallOrientation == INSIDE_TOP_RIGHT || usWallOrientation == OUTSIDE_TOP_RIGHT )
@@ -777,7 +777,7 @@ void EraseFloorOwnedBuildingPieces( UINT32 iMapIndex )
{
GetTileType( pStruct->usIndex, &uiTileType );
if ( uiTileType >= FIRSTWALL && uiTileType <= LASTWALL ||
uiTileType >= FIRSTDOOR && uiTileType <= LASTDOOR )
uiTileType >= FIRSTDOOR && uiTileType <= LASTDOOR )
{
GetWallOrientation( pStruct->usIndex, &usWallOrientation );
if( usWallOrientation == INSIDE_TOP_LEFT || usWallOrientation == OUTSIDE_TOP_LEFT )
@@ -810,20 +810,20 @@ void RemoveCaveSectionFromWorld( SGPRect *pSelectRegion )
left = pSelectRegion->iLeft;
right = pSelectRegion->iRight;
bottom = pSelectRegion->iBottom;
//Pass 1: Remove all pieces in area
//Pass 1: Remove all pieces in area
for( y = top; y <= bottom; y++ ) for( x = left; x <= right; x++ )
{
iMapIndex = y * WORLD_COLS + x;
AddToUndoList( iMapIndex );
RemoveAllStructsOfTypeRange( iMapIndex, FIRSTWALL, LASTWALL );
RemoveAllStructsOfTypeRange( iMapIndex, FIRSTWALL, LASTWALL );
}
//Past 2: Go around outside perimeter and smooth each piece
//Past 2: Go around outside perimeter and smooth each piece
for( y = top - 1; y <= bottom + 1; y++ ) for( x = left - 1; x <= right + 1; x++ )
{
iMapIndex = y * WORLD_COLS + x;
if( CaveAtGridNo( iMapIndex ) )
{
ubPerimeterValue = CalcNewCavePerimeterValue( iMapIndex );
ubPerimeterValue = CalcNewCavePerimeterValue( iMapIndex );
usIndex = GetCaveTileIndexFromPerimeterValue( ubPerimeterValue );
AddToUndoList( iMapIndex );
if( usIndex != 0xffff )
@@ -846,7 +846,7 @@ void AddCaveSectionToWorld( SGPRect *pSelectRegion )
left = pSelectRegion->iLeft;
right = pSelectRegion->iRight;
bottom = pSelectRegion->iBottom;
//Pass 1: Add bogus piece to each gridno in region
//Pass 1: Add bogus piece to each gridno in region
for( y = top; y <= bottom; y++ ) for( x = left; x <= right; x++ )
{
uiMapIndex = y * WORLD_COLS + x;
@@ -857,7 +857,7 @@ void AddCaveSectionToWorld( SGPRect *pSelectRegion )
AddCave( uiMapIndex, usIndex );
}
}
//Past 2: Go around outside perimeter and smooth each piece
//Past 2: Go around outside perimeter and smooth each piece
for( y = top - 1; y <= bottom + 1; y++ ) for( x = left - 1; x <= right + 1; x++ )
{
uiMapIndex = y * WORLD_COLS + x;
@@ -889,9 +889,9 @@ void AddCaveSectionToWorld( SGPRect *pSelectRegion )
// BEGIN PUBLIC FUNCTION IMPLEMENTATION
//--------------------------------------------------------------------------------------------------
//When the user removes a section from a building, it will not only erase the
//When the user removes a section from a building, it will not only erase the
//entire highlighted area, it'll repair the building itself so there are no
//outside walls missing from the new building.
//outside walls missing from the new building.
void RemoveBuildingSectionFromWorld( SGPRect *pSelectRegion )
{
UINT32 top, left, right, bottom, x, y;
@@ -905,17 +905,17 @@ void RemoveBuildingSectionFromWorld( SGPRect *pSelectRegion )
right = pSelectRegion->iRight;
bottom = pSelectRegion->iBottom;
//1ST PASS: Erase all building owned by the floor tile if there is one.
//1ST PASS: Erase all building owned by the floor tile if there is one.
for( y = top; y <= bottom; y++ ) for( x = left; x <= right; x++ )
{
iMapIndex = y * WORLD_COLS + x;
EraseFloorOwnedBuildingPieces( iMapIndex ); //Erase possible top and left walls in bordering tiles.
}
//2ND PASS: Build new walls whereever there are neighboring floor tiles.
//2ND PASS: Build new walls whereever there are neighboring floor tiles.
for( y = top; y <= bottom; y++ ) for( x = left; x <= right; x++ )
{
iMapIndex = y * WORLD_COLS + x;
//NOTE: Top and bottom walls MUST be placed first -- it minimizes the number of special cases.
//NOTE: Top and bottom walls MUST be placed first -- it minimizes the number of special cases.
if( y == top )
{
fFloor = FloorAtGridNo( iMapIndex - WORLD_COLS );
@@ -937,15 +937,15 @@ void RemoveBuildingSectionFromWorld( SGPRect *pSelectRegion )
if( x == right )
{
fFloor = FloorAtGridNo( iMapIndex + 1);
if( gfBasement && !fFloor || !gfBasement && fFloor && !GetVerticalWall( iMapIndex ) )
if( gfBasement && !fFloor || !gfBasement && fFloor && !GetVerticalWall( iMapIndex ) )
BuildWallPiece( iMapIndex, EXTERIOR_RIGHT, 0 );
}
}
//3RD PASS: Go around the outside of the region, and rebuild the roof.
//3RD PASS: Go around the outside of the region, and rebuild the roof.
if( gfBasement )
{
usFloorType = GetRandomIndexByRange( FIRSTFLOOR, LASTFLOOR );
if( usFloorType == 0xffff )
if( usFloorType == 0xffff )
usFloorType = FIRSTFLOOR;
for( y = top; y <= bottom; y++ ) for( x = left; x <= right; x++ )
{
@@ -983,7 +983,7 @@ void AddBuildingSectionToWorld( SGPRect *pSelectRegion )
bottom = pSelectRegion->iBottom;
//Special case scenario:
//If the user selects a floor without walls, then it is implied that the user wishes to
//If the user selects a floor without walls, then it is implied that the user wishes to
//change the floor for say a kitchen which might have a different floor type.
usWallType = GetRandomIndexByRange( FIRSTWALL, LASTWALL );
usFloorType = GetRandomIndexByRange( FIRSTFLOOR, LASTFLOOR );
@@ -1002,10 +1002,10 @@ void AddBuildingSectionToWorld( SGPRect *pSelectRegion )
return;
}
//1ST PASS: Determine if there are any floor tiles in this region. If there are, then
// that signifies that we are concantenating this building to an existing one. Otherwise,
// we are just drawing an individual building. If we find a floor, extract the type so
// we know how to draw it later.
//1ST PASS: Determine if there are any floor tiles in this region. If there are, then
// that signifies that we are concantenating this building to an existing one. Otherwise,
// we are just drawing an individual building. If we find a floor, extract the type so
// we know how to draw it later.
fNewBuilding = TRUE;
for( y = top; y <= bottom; y++ ) for( x = left; x <= right; x++ )
{
@@ -1016,13 +1016,13 @@ void AddBuildingSectionToWorld( SGPRect *pSelectRegion )
UINT32 uiTileType;
//If a floor is found, then we are adding to an existing structure.
fNewBuilding = FALSE;
//Extract the floor type. We already checked if there was a floor here, so it is assumed.
//Extract the floor type. We already checked if there was a floor here, so it is assumed.
pFloor = gpWorldLevelData[ iMapIndex ].pLandHead;
while( pFloor )
{
GetTileType( pFloor->usIndex, &uiTileType );
if( uiTileType >= FIRSTFLOOR && uiTileType <= LASTFLOOR )
{
{
usFloorType = (UINT16)uiTileType;
break;
}
@@ -1036,7 +1036,7 @@ void AddBuildingSectionToWorld( SGPRect *pSelectRegion )
}
}
}
if( fNewBuilding )
{
//if( gfBasement )
@@ -1060,19 +1060,19 @@ void AddBuildingSectionToWorld( SGPRect *pSelectRegion )
return;
}
//2ND PASS: Remove all walls in the region that border no floor tile, or simply walls
// that are considered exterior walls. That way, it won't wreck the inside of a building
// if you select too much interior. Also, gridnos that delete walls will also delete the
// floor and roof tiles there. That signifies that the floorless parts will be resmoothed,
// and rebuilt in the third pass.
//2ND PASS: Remove all walls in the region that border no floor tile, or simply walls
// that are considered exterior walls. That way, it won't wreck the inside of a building
// if you select too much interior. Also, gridnos that delete walls will also delete the
// floor and roof tiles there. That signifies that the floorless parts will be resmoothed,
// and rebuilt in the third pass.
for( y = top; y <= bottom; y++ ) for( x = left; x <= right; x++ )
{
iMapIndex = y * WORLD_COLS + x;
if( gfBasement )
{
EraseBuilding( iMapIndex );
EraseBuilding( iMapIndex );
}
else if( FloorAtGridNo( iMapIndex ) && !fNewBuilding)
else if( FloorAtGridNo( iMapIndex ) && !fNewBuilding)
{
if( y >= top && !FloorAtGridNo( iMapIndex - WORLD_COLS ) )
{
@@ -1104,11 +1104,11 @@ void AddBuildingSectionToWorld( SGPRect *pSelectRegion )
BulldozeNature( iMapIndex );
}
}
//3RD PASS: Process the region, and all walls of floorless tiles are rebuilt from interior perspective.
//3RD PASS: Process the region, and all walls of floorless tiles are rebuilt from interior perspective.
for( y = top; y <= bottom; y++ ) for( x = left; x <= right; x++ )
{
iMapIndex = y * WORLD_COLS + x;
if( !FloorAtGridNo( iMapIndex ) )
if( !FloorAtGridNo( iMapIndex ) )
{
if( y == top && !GetHorizontalWall( iMapIndex - WORLD_COLS ) )
{
@@ -1142,14 +1142,14 @@ void AddBuildingSectionToWorld( SGPRect *pSelectRegion )
if( fSlantRoof )
{
fVertical = (bottom - top == 7) ? FALSE : TRUE;
BuildSlantRoof( left, top, right, bottom, usWallType, usRoofType, fVertical );
BuildSlantRoof( left, top, right, bottom, usWallType, usRoofType, fVertical );
}
//4TH PASS: Process the region, and all floorless tiles get new roofs and floors.
//4TH PASS: Process the region, and all floorless tiles get new roofs and floors.
for( y = top; y <= bottom; y++ ) for( x = left; x <= right; x++ )
{
iMapIndex = y * WORLD_COLS + x;
if( !FloorAtGridNo( iMapIndex ) )
if( !FloorAtGridNo( iMapIndex ) )
{
if( !fSlantRoof )
RebuildRoof( iMapIndex, usRoofType );
@@ -1194,6 +1194,7 @@ void AnalyseCaveMapForStructureInfo()