mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
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:
+65
-64
@@ -28,7 +28,7 @@ void CalcSmartWallDefault( UINT16 *pusObjIndex, UINT16 *pusUseIndex )
|
||||
void CalcSmartDoorDefault( UINT16 *pusObjIndex, UINT16 *pusUseIndex )
|
||||
{
|
||||
*pusUseIndex = 4 * ( gubDoorUIValue % 2 ); //open or closed -- odd or even
|
||||
*pusObjIndex = FIRSTDOOR + gubDoorUIValue / 2;
|
||||
*pusObjIndex = FIRSTDOOR + gubDoorUIValue / 2;
|
||||
}
|
||||
|
||||
void CalcSmartWindowDefault( UINT16 *pusObjIndex, UINT16 *pusUseIndex )
|
||||
@@ -42,8 +42,8 @@ void CalcSmartBrokenWallDefault( UINT16 *pusObjIndex, UINT16 *pusUseIndex )
|
||||
switch( gubBrokenWallUIValue )
|
||||
{
|
||||
case 0:case 1: *pusUseIndex = 49 + gubBrokenWallUIValue; break;
|
||||
case 3: *pusUseIndex = 62; break;
|
||||
case 4: *pusUseIndex = 64; break;
|
||||
case 3: *pusUseIndex = 62; break;
|
||||
case 4: *pusUseIndex = 64; break;
|
||||
}
|
||||
*pusObjIndex = FIRSTWALL;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ UINT16 CalcSmartWindowIndex( UINT16 usWallOrientation )
|
||||
UINT16 CalcSmartDoorIndex( UINT16 usWallOrientation )
|
||||
{
|
||||
//convert the orientation values as the graphics are in reverse order
|
||||
//orientation values: INSIDE_TOP_LEFT=1, INSIDE_TOP_RIGHT=2, OUTSIDE_TOP_LEFT=3, OUTSIDE_TOP_RIGHT=4
|
||||
//orientation values: INSIDE_TOP_LEFT=1, INSIDE_TOP_RIGHT=2, OUTSIDE_TOP_LEFT=3, OUTSIDE_TOP_RIGHT=4
|
||||
//door graphics order: INSIDE_TOP_LEFT=15, INSIDE_TOP_RIGHT=10, OUTSIDE_TOP_LEFT=5, OUTSIDE_TOP_RIGHT=0
|
||||
usWallOrientation = (4 - usWallOrientation) * 5;
|
||||
//4 * (gubDoorUIValue%2) evaluates to +4 if the door is open, 0 if closed
|
||||
@@ -75,19 +75,19 @@ UINT16 CalcSmartBrokenWallIndex( UINT16 usWallOrientation )
|
||||
if( gubBrokenWallUIValue < 2 ) //broken walls
|
||||
{
|
||||
//convert the orientation value as the graphics are in a different order.
|
||||
//orientation values: INSIDE_TOP_LEFT=1, INSIDE_TOP_RIGHT=2, OUTSIDE_TOP_LEFT=3, OUTSIDE_TOP_RIGHT=4
|
||||
// 4 6 8 10
|
||||
//door graphics order: INSIDE_TOP_LEFT=4, INSIDE_TOP_RIGHT=6, OUTSIDE_TOP_LEFT=0, OUTSIDE_TOP_RIGHT=2
|
||||
//orientation values: INSIDE_TOP_LEFT=1, INSIDE_TOP_RIGHT=2, OUTSIDE_TOP_LEFT=3, OUTSIDE_TOP_RIGHT=4
|
||||
// 4 6 8 10
|
||||
//door graphics order: INSIDE_TOP_LEFT=4, INSIDE_TOP_RIGHT=6, OUTSIDE_TOP_LEFT=0, OUTSIDE_TOP_RIGHT=2
|
||||
usWallOrientation = usWallOrientation * 2 + 2;
|
||||
usWallOrientation -= usWallOrientation > 6 ? 8 : 0;
|
||||
return (UINT16)( usWallOrientation + 48 + gubBrokenWallUIValue );
|
||||
}
|
||||
|
||||
|
||||
//cracked and smudged walls
|
||||
|
||||
//convert the orientation value as the graphics are in a different order.
|
||||
//orientation values: INSIDE_TOP_LEFT=1, INSIDE_TOP_RIGHT=2, OUTSIDE_TOP_LEFT=3, OUTSIDE_TOP_RIGHT=4
|
||||
//door graphics order: INSIDE_TOP_LEFT=1, INSIDE_TOP_RIGHT=2, OUTSIDE_TOP_LEFT=5, OUTSIDE_TOP_RIGHT=6
|
||||
//orientation values: INSIDE_TOP_LEFT=1, INSIDE_TOP_RIGHT=2, OUTSIDE_TOP_LEFT=3, OUTSIDE_TOP_RIGHT=4
|
||||
//door graphics order: INSIDE_TOP_LEFT=1, INSIDE_TOP_RIGHT=2, OUTSIDE_TOP_LEFT=5, OUTSIDE_TOP_RIGHT=6
|
||||
usWallOrientation += usWallOrientation > 1 ? 2 : 0;
|
||||
usWallOrientation += gubBrokenWallUIValue == 4 ? 2 : 0; //smudged type which is 2 index values higher.
|
||||
return (UINT16)( usWallOrientation + 57 );
|
||||
@@ -135,7 +135,7 @@ void DecSmartBrokenWallUIValue()
|
||||
|
||||
BOOLEAN CalcWallInfoUsingSmartMethod( UINT32 iMapIndex, UINT16 *pusWallType, UINT16 *pusIndex )
|
||||
{
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOLEAN CalcDoorInfoUsingSmartMethod( UINT32 iMapIndex, UINT16 *pusDoorType, UINT16 *pusIndex )
|
||||
@@ -205,7 +205,7 @@ BOOLEAN CalcBrokenWallInfoUsingSmartMethod( UINT32 iMapIndex, UINT16 *pusWallTyp
|
||||
LEVELNODE *pWall = NULL;
|
||||
UINT32 uiTileType;
|
||||
UINT16 usWallOrientation;
|
||||
|
||||
|
||||
if( gubBrokenWallUIValue == 2 ) //the hole in the wall
|
||||
{
|
||||
*pusWallType = 0xffff;
|
||||
@@ -247,25 +247,25 @@ BOOLEAN CalcBrokenWallInfoUsingSmartMethod( UINT32 iMapIndex, UINT16 *pusWallTyp
|
||||
}
|
||||
|
||||
|
||||
//This is a very difficult function to document properly. The reason being is that it is sooo
|
||||
//subliminal by nature. I have thought up of priorities and choose the best piece to draw based
|
||||
//on the surrounding conditions. Here are the priorities which are referenced below via comments:
|
||||
//A) If there is currently a bottom piece and a right piece, immediately exit.
|
||||
//B) We are currently over a bottom piece. Now, we don't automatically want to draw a right piece here
|
||||
// for multiple reasons. First, the UI will be too quick and place bottom and right pieces for every
|
||||
// place the user clicks, which isn't what we want. Therefore, we look to see if there is a right
|
||||
// piece in the y-1 gridno. It would then make sense to place a right piece down here. Regardless,
|
||||
//This is a very difficult function to document properly. The reason being is that it is sooo
|
||||
//subliminal by nature. I have thought up of priorities and choose the best piece to draw based
|
||||
//on the surrounding conditions. Here are the priorities which are referenced below via comments:
|
||||
//A) If there is currently a bottom piece and a right piece, immediately exit.
|
||||
//B) We are currently over a bottom piece. Now, we don't automatically want to draw a right piece here
|
||||
// for multiple reasons. First, the UI will be too quick and place bottom and right pieces for every
|
||||
// place the user clicks, which isn't what we want. Therefore, we look to see if there is a right
|
||||
// piece in the y-1 gridno. It would then make sense to place a right piece down here. Regardless,
|
||||
// if we encounter a bottom piece here, we will exit.
|
||||
//C) This is the counterpart to B, but we are looking at a current right piece, and are determining if
|
||||
//C) This is the counterpart to B, but we are looking at a current right piece, and are determining if
|
||||
// we should place a bottom piece based on another bottom piece existing in the x-1 gridno.
|
||||
//D) Now, we analyse the neighboring tiles and determine the orientations that would add weight to the
|
||||
// current tile either towards drawing a horizontal piece or a vertical piece.
|
||||
//E) Now that we have the information, we give the highest priority to any weights that match the current
|
||||
// wall piece type selected by the user. Based on that, we will only consider the best match of the
|
||||
// type and use it. If there are no matches on type, we continue.
|
||||
//F) We failed to find weights matching the current wall type, but before we give up using the user's wall
|
||||
// type, there are two more cases. When there is a bottom wall in the y+1 position or a right wall in
|
||||
// the x+1 position. If there are matching walls, there, then we draw two pieces to connect the current
|
||||
//D) Now, we analyse the neighboring tiles and determine the orientations that would add weight to the
|
||||
// current tile either towards drawing a horizontal piece or a vertical piece.
|
||||
//E) Now that we have the information, we give the highest priority to any weights that match the current
|
||||
// wall piece type selected by the user. Based on that, we will only consider the best match of the
|
||||
// type and use it. If there are no matches on type, we continue.
|
||||
//F) We failed to find weights matching the current wall type, but before we give up using the user's wall
|
||||
// type, there are two more cases. When there is a bottom wall in the y+1 position or a right wall in
|
||||
// the x+1 position. If there are matching walls, there, then we draw two pieces to connect the current
|
||||
// gridno with the respective position.
|
||||
void PasteSmartWall( UINT32 iMapIndex )
|
||||
{
|
||||
@@ -273,7 +273,7 @@ void PasteSmartWall( UINT32 iMapIndex )
|
||||
static UINT32 iAloneMapIndex = 0x8000;
|
||||
UINT16 usWallType;
|
||||
|
||||
//These are the counters for the walls of each type
|
||||
//These are the counters for the walls of each type
|
||||
UINT16 usNumV[4]={0,0,0,0}; //vertical wall weights
|
||||
UINT16 usNumH[4]={0,0,0,0}; //horizontal wall weights
|
||||
|
||||
@@ -282,8 +282,8 @@ void PasteSmartWall( UINT32 iMapIndex )
|
||||
return;
|
||||
//*B* See above documentation
|
||||
usWallType = GetHorizontalWallType( iMapIndex );
|
||||
if( usWallType )
|
||||
{
|
||||
if( usWallType )
|
||||
{
|
||||
if( usWallType == gubWallUIValue )
|
||||
{
|
||||
usWallType = GetVerticalWallType( iMapIndex - WORLD_COLS );
|
||||
@@ -312,12 +312,12 @@ void PasteSmartWall( UINT32 iMapIndex )
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
return;
|
||||
}
|
||||
//*C* See above documentation
|
||||
usWallType = GetVerticalWallType( iMapIndex );
|
||||
if( usWallType )
|
||||
{
|
||||
if( usWallType )
|
||||
{
|
||||
if( usWallType == gubWallUIValue )
|
||||
{
|
||||
usWallType = GetHorizontalWallType( iMapIndex - 1 );
|
||||
@@ -329,25 +329,25 @@ void PasteSmartWall( UINT32 iMapIndex )
|
||||
BuildWallPiece( iMapIndex, INTERIOR_BOTTOM, gubWallUIValue );
|
||||
}
|
||||
}
|
||||
return;
|
||||
return;
|
||||
}
|
||||
//*D* See above documentation
|
||||
//Evaluate left adjacent tile
|
||||
//Evaluate left adjacent tile
|
||||
if( usWallType = GetVerticalWallType( iMapIndex - 1 ) )
|
||||
usNumH[ usWallType - FIRSTWALL ]++;
|
||||
usNumH[ usWallType - FIRSTWALL ]++;
|
||||
if( usWallType = GetHorizontalWallType( iMapIndex - 1 ) )
|
||||
usNumH[ usWallType - FIRSTWALL ]++;
|
||||
//Evaluate right adjacent tile
|
||||
//Evaluate right adjacent tile
|
||||
if( usWallType = GetHorizontalWallType( iMapIndex + 1 ) )
|
||||
usNumH[ usWallType - FIRSTWALL ]++;
|
||||
//Evaluate upper adjacent tile
|
||||
usNumH[ usWallType - FIRSTWALL ]++;
|
||||
//Evaluate upper adjacent tile
|
||||
if( usWallType = GetVerticalWallType( iMapIndex - WORLD_COLS ) )
|
||||
usNumV[ usWallType - FIRSTWALL ]++;
|
||||
usNumV[ usWallType - FIRSTWALL ]++;
|
||||
if( usWallType = GetHorizontalWallType( iMapIndex - WORLD_COLS ) )
|
||||
usNumV[ usWallType - FIRSTWALL ]++;
|
||||
//Evaluate lower adjacent tile
|
||||
//Evaluate lower adjacent tile
|
||||
if( usWallType = GetVerticalWallType( iMapIndex + WORLD_COLS ) )
|
||||
usNumV[ usWallType - FIRSTWALL ]++;
|
||||
usNumV[ usWallType - FIRSTWALL ]++;
|
||||
//*E* See above documentation
|
||||
if( usNumV[gubWallUIValue - FIRSTWALL] | usNumH[gubWallUIValue - FIRSTWALL] )
|
||||
{
|
||||
@@ -357,11 +357,11 @@ void PasteSmartWall( UINT32 iMapIndex )
|
||||
{ //inside
|
||||
BuildWallPiece( iMapIndex, EXTERIOR_RIGHT, gubWallUIValue );
|
||||
//Change to extended piece if it is a new top right corner to cover the end part.
|
||||
if( GetHorizontalWall( iMapIndex - WORLD_COLS ) && !GetHorizontalWall( iMapIndex - WORLD_COLS + 1 )
|
||||
if( GetHorizontalWall( iMapIndex - WORLD_COLS ) && !GetHorizontalWall( iMapIndex - WORLD_COLS + 1 )
|
||||
&& !GetVerticalWall( iMapIndex - WORLD_COLS ) )
|
||||
ChangeVerticalWall( iMapIndex, INTERIOR_EXTENDED );
|
||||
else if( GetHorizontalWall( iMapIndex - WORLD_COLS ) && !GetHorizontalWall( iMapIndex - WORLD_COLS - 1 )
|
||||
&& !GetVerticalWall( iMapIndex - WORLD_COLS - 1 ) )
|
||||
else if( GetHorizontalWall( iMapIndex - WORLD_COLS ) && !GetHorizontalWall( iMapIndex - WORLD_COLS - 1 )
|
||||
&& !GetVerticalWall( iMapIndex - WORLD_COLS - 1 ) )
|
||||
{
|
||||
ChangeVerticalWall( iMapIndex, INTERIOR_EXTENDED );
|
||||
EraseHorizontalWall( iMapIndex - WORLD_COLS );
|
||||
@@ -370,11 +370,11 @@ void PasteSmartWall( UINT32 iMapIndex )
|
||||
else
|
||||
{ //outside
|
||||
BuildWallPiece( iMapIndex, INTERIOR_RIGHT, gubWallUIValue );
|
||||
if( GetHorizontalWall( iMapIndex - WORLD_COLS ) && !GetHorizontalWall( iMapIndex - WORLD_COLS + 1 )
|
||||
if( GetHorizontalWall( iMapIndex - WORLD_COLS ) && !GetHorizontalWall( iMapIndex - WORLD_COLS + 1 )
|
||||
&& !GetVerticalWall( iMapIndex - WORLD_COLS ) )
|
||||
ChangeVerticalWall( iMapIndex, EXTERIOR_EXTENDED );
|
||||
else if( GetHorizontalWall( iMapIndex - WORLD_COLS ) && !GetHorizontalWall( iMapIndex - WORLD_COLS - 1 )
|
||||
&& !GetVerticalWall( iMapIndex - WORLD_COLS - 1 ) )
|
||||
else if( GetHorizontalWall( iMapIndex - WORLD_COLS ) && !GetHorizontalWall( iMapIndex - WORLD_COLS - 1 )
|
||||
&& !GetVerticalWall( iMapIndex - WORLD_COLS - 1 ) )
|
||||
{
|
||||
ChangeVerticalWall( iMapIndex, EXTERIOR_EXTENDED );
|
||||
EraseHorizontalWall( iMapIndex - WORLD_COLS );
|
||||
@@ -383,29 +383,29 @@ void PasteSmartWall( UINT32 iMapIndex )
|
||||
}
|
||||
else
|
||||
{
|
||||
if( GetVerticalWall( iMapIndex - 1 ) && !GetVerticalWall( iMapIndex - WORLD_COLS - 1 )
|
||||
&& !GetHorizontalWall( iMapIndex - WORLD_COLS - 1 ) )
|
||||
if( GetVerticalWall( iMapIndex - 1 ) && !GetVerticalWall( iMapIndex - WORLD_COLS - 1 )
|
||||
&& !GetHorizontalWall( iMapIndex - WORLD_COLS - 1 ) )
|
||||
EraseVerticalWall( iMapIndex - 1);
|
||||
if( FloorAtGridNo( iMapIndex + WORLD_COLS ) )
|
||||
{ //inside
|
||||
BuildWallPiece( iMapIndex, EXTERIOR_BOTTOM, gubWallUIValue );
|
||||
if( GetVerticalWall( iMapIndex + WORLD_COLS ) )
|
||||
if( GetVerticalWall( iMapIndex + WORLD_COLS ) )
|
||||
ChangeVerticalWall( iMapIndex + WORLD_COLS, INTERIOR_EXTENDED );
|
||||
if( GetVerticalWall( iMapIndex + WORLD_COLS - 1 ) && !GetVerticalWall( iMapIndex - 1 ) )
|
||||
ChangeVerticalWall( iMapIndex + WORLD_COLS - 1, INTERIOR_EXTENDED );
|
||||
else if( GetVerticalWall( iMapIndex - 1 ) && !GetVerticalWall( iMapIndex + WORLD_COLS - 1 )
|
||||
&& FloorAtGridNo( iMapIndex ) )
|
||||
ChangeVerticalWall( iMapIndex + WORLD_COLS - 1, INTERIOR_EXTENDED );
|
||||
else if( GetVerticalWall( iMapIndex - 1 ) && !GetVerticalWall( iMapIndex + WORLD_COLS - 1 )
|
||||
&& FloorAtGridNo( iMapIndex ) )
|
||||
ChangeVerticalWall( iMapIndex - 1, INTERIOR_BOTTOMEND );
|
||||
}
|
||||
else
|
||||
{ //outside
|
||||
BuildWallPiece( iMapIndex, INTERIOR_BOTTOM, gubWallUIValue );
|
||||
if( GetVerticalWall( iMapIndex + WORLD_COLS ) )
|
||||
if( GetVerticalWall( iMapIndex + WORLD_COLS ) )
|
||||
ChangeVerticalWall( iMapIndex + WORLD_COLS, EXTERIOR_EXTENDED );
|
||||
if( GetVerticalWall( iMapIndex + WORLD_COLS - 1 ) && !GetVerticalWall( iMapIndex - 1 ) )
|
||||
ChangeVerticalWall( iMapIndex + WORLD_COLS - 1, EXTERIOR_EXTENDED );
|
||||
else if( GetVerticalWall( iMapIndex - 1 ) && !GetVerticalWall( iMapIndex + WORLD_COLS - 1 )
|
||||
&& FloorAtGridNo( iMapIndex ) )
|
||||
ChangeVerticalWall( iMapIndex + WORLD_COLS - 1, EXTERIOR_EXTENDED );
|
||||
else if( GetVerticalWall( iMapIndex - 1 ) && !GetVerticalWall( iMapIndex + WORLD_COLS - 1 )
|
||||
&& FloorAtGridNo( iMapIndex ) )
|
||||
ChangeVerticalWall( iMapIndex - 1, EXTERIOR_BOTTOMEND );
|
||||
}
|
||||
}
|
||||
@@ -441,7 +441,7 @@ void PasteSmartWall( UINT32 iMapIndex )
|
||||
if( usWallType == gubWallUIValue )
|
||||
{
|
||||
if(FloorAtGridNo( iMapIndex + WORLD_COLS ) )
|
||||
{ //inside
|
||||
{ //inside
|
||||
BuildWallPiece( iMapIndex + 1, EXTERIOR_BOTTOM, gubWallUIValue );
|
||||
BuildWallPiece( iMapIndex, EXTERIOR_BOTTOM, gubWallUIValue );
|
||||
if( !GetVerticalWall( iMapIndex - WORLD_COLS + 1 ) )
|
||||
@@ -457,7 +457,7 @@ void PasteSmartWall( UINT32 iMapIndex )
|
||||
else
|
||||
ChangeVerticalWall( iMapIndex + 1, INTERIOR_BOTTOMEND );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ //outside
|
||||
BuildWallPiece( iMapIndex + 1, INTERIOR_BOTTOM, gubWallUIValue );
|
||||
@@ -533,7 +533,7 @@ void PasteSmartWindow( UINT32 iMapIndex )
|
||||
GetWallOrientation( pWall->usIndex, &usWallOrientation );
|
||||
usIndex = CalcSmartWindowIndex( usWallOrientation );
|
||||
//Calculate the new graphic for the window type selected.
|
||||
|
||||
|
||||
AddToUndoList( iMapIndex );
|
||||
GetTileIndexFromTypeSubIndex( usWallType, usIndex, &usNewWallIndex );
|
||||
ReplaceStructIndex( iMapIndex, pWall->usIndex, usNewWallIndex );
|
||||
@@ -623,6 +623,7 @@ void PasteSmartBrokenWall( UINT32 iMapIndex )
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user