mirror of
https://github.com/1dot13/source.git
synced 2026-09-16 14:47:17 +02:00
Use std::vector for HVSURFACE->RegionList
Replaces the use of old custom list implementation in container.cpp
This commit is contained in:
@@ -110,6 +110,7 @@ HVSURFACE ghFrameBuffer = NULL;
|
|||||||
HVSURFACE ghMouseBuffer = NULL;
|
HVSURFACE ghMouseBuffer = NULL;
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
extern std::map<UINT32,ClipRectangle> g_SurfaceRectangle;
|
extern std::map<UINT32,ClipRectangle> g_SurfaceRectangle;
|
||||||
|
|
||||||
@@ -1161,11 +1162,7 @@ HVSURFACE CreateVideoSurface( VSURFACE_DESC *VSurfaceDesc )
|
|||||||
//
|
//
|
||||||
// Allocate memory for Video Surface data and initialize
|
// Allocate memory for Video Surface data and initialize
|
||||||
//
|
//
|
||||||
|
hVSurface = new SGPVSurface{};
|
||||||
hVSurface = (HVSURFACE) MemAlloc( sizeof( SGPVSurface ) );
|
|
||||||
memset( hVSurface, 0, sizeof( SGPVSurface ) );
|
|
||||||
CHECKF( hVSurface != NULL );
|
|
||||||
|
|
||||||
hVSurface->usHeight = usHeight;
|
hVSurface->usHeight = usHeight;
|
||||||
hVSurface->usWidth = usWidth;
|
hVSurface->usWidth = usWidth;
|
||||||
// BF : since we use a 16bpp framebuffer and images are converted to that format,
|
// BF : since we use a 16bpp framebuffer and images are converted to that format,
|
||||||
@@ -1178,7 +1175,6 @@ HVSURFACE CreateVideoSurface( VSURFACE_DESC *VSurfaceDesc )
|
|||||||
hVSurface->pPalette = NULL;
|
hVSurface->pPalette = NULL;
|
||||||
hVSurface->p16BPPPalette = NULL;
|
hVSurface->p16BPPPalette = NULL;
|
||||||
hVSurface->TransparentColor = FROMRGB( 0, 0, 0 );
|
hVSurface->TransparentColor = FROMRGB( 0, 0, 0 );
|
||||||
hVSurface->RegionList = CreateList( DEFAULT_NUM_REGIONS, sizeof( VSURFACE_REGION ) );
|
|
||||||
hVSurface->fFlags = 0;
|
hVSurface->fFlags = 0;
|
||||||
hVSurface->pClipper = NULL;
|
hVSurface->pClipper = NULL;
|
||||||
|
|
||||||
@@ -1647,12 +1643,6 @@ BOOLEAN DeleteVideoSurface( HVSURFACE hVSurface )
|
|||||||
hVSurface->pPalette = NULL;
|
hVSurface->pPalette = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if ( hVSurface->pClipper != NULL )
|
|
||||||
//{
|
|
||||||
// Release Clipper
|
|
||||||
// DDReleaseClipper( (LPDIRECTDRAWCLIPPER)hVSurface->pClipper );
|
|
||||||
//}
|
|
||||||
|
|
||||||
// Get surface pointer
|
// Get surface pointer
|
||||||
lpDDSurface = (LPDIRECTDRAWSURFACE2)hVSurface->pSurfaceData;
|
lpDDSurface = (LPDIRECTDRAWSURFACE2)hVSurface->pSurfaceData;
|
||||||
|
|
||||||
@@ -1670,7 +1660,7 @@ BOOLEAN DeleteVideoSurface( HVSURFACE hVSurface )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Release region data
|
// Release region data
|
||||||
DeleteList( hVSurface->RegionList );
|
hVSurface->RegionList.clear();
|
||||||
|
|
||||||
//If there is a 16bpp palette, free it
|
//If there is a 16bpp palette, free it
|
||||||
if( hVSurface->p16BPPPalette != NULL )
|
if( hVSurface->p16BPPPalette != NULL )
|
||||||
@@ -1682,8 +1672,7 @@ BOOLEAN DeleteVideoSurface( HVSURFACE hVSurface )
|
|||||||
giMemUsedInSurfaces -= ( hVSurface->usHeight * hVSurface->usWidth * ( hVSurface->ubBitDepth / 8 ) );
|
giMemUsedInSurfaces -= ( hVSurface->usHeight * hVSurface->usWidth * ( hVSurface->ubBitDepth / 8 ) );
|
||||||
|
|
||||||
// Release object
|
// Release object
|
||||||
MemFree( hVSurface );
|
delete hVSurface;
|
||||||
|
|
||||||
return( TRUE );
|
return( TRUE );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1768,7 +1757,7 @@ BOOLEAN GetNumRegions( HVSURFACE hVSurface , UINT32 *puiNumRegions )
|
|||||||
{
|
{
|
||||||
Assert( hVSurface );
|
Assert( hVSurface );
|
||||||
|
|
||||||
*puiNumRegions = ListSize( hVSurface->RegionList );
|
*puiNumRegions = hVSurface->RegionList.size();
|
||||||
|
|
||||||
return( TRUE );
|
return( TRUE );
|
||||||
|
|
||||||
@@ -1780,7 +1769,7 @@ BOOLEAN AddVSurfaceRegion( HVSURFACE hVSurface, VSURFACE_REGION *pNewRegion )
|
|||||||
Assert( pNewRegion != NULL );
|
Assert( pNewRegion != NULL );
|
||||||
|
|
||||||
// Add new region to list
|
// Add new region to list
|
||||||
hVSurface->RegionList = AddtoList( hVSurface->RegionList, pNewRegion, ListSize( hVSurface->RegionList ) );
|
hVSurface->RegionList.push_back(*pNewRegion);
|
||||||
|
|
||||||
return( TRUE );
|
return( TRUE );
|
||||||
}
|
}
|
||||||
@@ -1801,29 +1790,10 @@ BOOLEAN AddVSurfaceRegions( HVSURFACE hVSurface, VSURFACE_REGION **ppNewRegions,
|
|||||||
return( TRUE );
|
return( TRUE );
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN RemoveVSurfaceRegion( HVSURFACE hVSurface, UINT16 usIndex )
|
|
||||||
{
|
|
||||||
VSURFACE_REGION aRegion;
|
|
||||||
|
|
||||||
Assert( hVSurface != NULL );
|
|
||||||
|
|
||||||
return( RemfromList( hVSurface->RegionList, &aRegion, usIndex ) );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOLEAN ClearAllVSurfaceRegions( HVSURFACE hVSurface )
|
BOOLEAN ClearAllVSurfaceRegions( HVSURFACE hVSurface )
|
||||||
{
|
{
|
||||||
UINT32 uiListSize;
|
|
||||||
|
|
||||||
Assert( hVSurface != NULL );
|
Assert( hVSurface != NULL );
|
||||||
|
hVSurface->RegionList.clear();
|
||||||
uiListSize = ListSize( hVSurface->RegionList );
|
|
||||||
|
|
||||||
for ( INT32 cnt = uiListSize - 1; cnt >= 0; cnt-- )
|
|
||||||
{
|
|
||||||
RemoveVSurfaceRegion( hVSurface, (UINT16)cnt );
|
|
||||||
}
|
|
||||||
|
|
||||||
return( TRUE );
|
return( TRUE );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1831,12 +1801,13 @@ BOOLEAN GetVSurfaceRegion( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_REGION
|
|||||||
{
|
{
|
||||||
Assert( hVSurface != NULL );
|
Assert( hVSurface != NULL );
|
||||||
|
|
||||||
if ( !PeekList( hVSurface->RegionList, aRegion, usIndex ) )
|
if (usIndex < hVSurface->RegionList.size())
|
||||||
{
|
{
|
||||||
return( FALSE );
|
*aRegion = hVSurface->RegionList[usIndex];
|
||||||
|
return( TRUE );
|
||||||
}
|
}
|
||||||
|
|
||||||
return( TRUE );
|
return( FALSE );
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN GetVSurfaceRect( HVSURFACE hVSurface, RECT *pRect)
|
BOOLEAN GetVSurfaceRect( HVSURFACE hVSurface, RECT *pRect)
|
||||||
@@ -1858,16 +1829,13 @@ BOOLEAN ReplaceVSurfaceRegion( HVSURFACE hVSurface , UINT16 usIndex, VSURFACE_RE
|
|||||||
|
|
||||||
Assert( hVSurface != NULL );
|
Assert( hVSurface != NULL );
|
||||||
|
|
||||||
// Validate index given
|
if (usIndex < hVSurface->RegionList.size())
|
||||||
if ( !PeekList( hVSurface->RegionList, &OldRegion, usIndex ) )
|
|
||||||
{
|
{
|
||||||
return( FALSE );
|
hVSurface->RegionList[usIndex] = *aRegion;
|
||||||
|
return( TRUE );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace information
|
return( FALSE );
|
||||||
hVSurface->RegionList = AddtoList( hVSurface->RegionList, aRegion, usIndex );
|
|
||||||
|
|
||||||
return( TRUE );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN AddVSurfaceRegionAtIndex( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_REGION *pNewRegion )
|
BOOLEAN AddVSurfaceRegionAtIndex( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_REGION *pNewRegion )
|
||||||
@@ -1876,10 +1844,14 @@ BOOLEAN AddVSurfaceRegionAtIndex( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_
|
|||||||
Assert( pNewRegion != NULL );
|
Assert( pNewRegion != NULL );
|
||||||
|
|
||||||
// Add new region to list
|
// Add new region to list
|
||||||
hVSurface->RegionList = AddtoList( hVSurface->RegionList, pNewRegion, usIndex );
|
if (usIndex < hVSurface->RegionList.size())
|
||||||
|
{
|
||||||
return( TRUE );
|
auto pos = hVSurface->RegionList.begin() + usIndex;
|
||||||
|
hVSurface->RegionList.insert(pos, *pNewRegion);
|
||||||
|
return(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// *******************************************************************
|
// *******************************************************************
|
||||||
@@ -2161,7 +2133,7 @@ HVSURFACE CreateVideoSurfaceFromDDSurface( LPDIRECTDRAWSURFACE2 lpDDSurface )
|
|||||||
|
|
||||||
|
|
||||||
// Allocate Video Surface struct
|
// Allocate Video Surface struct
|
||||||
hVSurface = (HVSURFACE) MemAlloc( sizeof( SGPVSurface ) );
|
hVSurface = new SGPVSurface{};
|
||||||
|
|
||||||
// Set values based on DD Surface given
|
// Set values based on DD Surface given
|
||||||
DDGetSurfaceDescription ( lpDDSurface, &DDSurfaceDesc );
|
DDGetSurfaceDescription ( lpDDSurface, &DDSurfaceDesc );
|
||||||
@@ -2173,7 +2145,6 @@ HVSURFACE CreateVideoSurfaceFromDDSurface( LPDIRECTDRAWSURFACE2 lpDDSurface )
|
|||||||
hVSurface->pSurfaceData = (PTR)lpDDSurface;
|
hVSurface->pSurfaceData = (PTR)lpDDSurface;
|
||||||
hVSurface->pSurfaceData1 = NULL;
|
hVSurface->pSurfaceData1 = NULL;
|
||||||
hVSurface->pSavedSurfaceData = NULL;
|
hVSurface->pSavedSurfaceData = NULL;
|
||||||
hVSurface->RegionList = CreateList( DEFAULT_NUM_REGIONS, sizeof( VSURFACE_REGION ) );
|
|
||||||
hVSurface->fFlags = 0;
|
hVSurface->fFlags = 0;
|
||||||
|
|
||||||
// Get and Set palette, if attached, allow to fail
|
// Get and Set palette, if attached, allow to fail
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "container.h"
|
#include "container.h"
|
||||||
#include "himage.h"
|
#include "himage.h"
|
||||||
#include "vobject.h"
|
#include "vobject.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
@@ -105,7 +106,7 @@ typedef struct
|
|||||||
UINT16 *p16BPPPalette; // A 16BPP palette used for 8->16 blits
|
UINT16 *p16BPPPalette; // A 16BPP palette used for 8->16 blits
|
||||||
COLORVAL TransparentColor; // Defaults to 0,0,0
|
COLORVAL TransparentColor; // Defaults to 0,0,0
|
||||||
PTR pClipper; // A void pointer encapsolated as a clipper Surface
|
PTR pClipper; // A void pointer encapsolated as a clipper Surface
|
||||||
HLIST RegionList; // A List of regions within the video Surface
|
std::vector<VSURFACE_REGION> RegionList; // A List of regions within the video Surface
|
||||||
|
|
||||||
} SGPVSurface, *HVSURFACE;
|
} SGPVSurface, *HVSURFACE;
|
||||||
|
|
||||||
@@ -240,7 +241,6 @@ BOOLEAN DeleteVideoSurfaceFromIndex( UINT32 uiIndex );
|
|||||||
BOOLEAN AddVSurfaceRegion( HVSURFACE hVSurface, VSURFACE_REGION *pNewRegion );
|
BOOLEAN AddVSurfaceRegion( HVSURFACE hVSurface, VSURFACE_REGION *pNewRegion );
|
||||||
BOOLEAN AddVSurfaceRegionAtIndex( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_REGION *pNewRegion );
|
BOOLEAN AddVSurfaceRegionAtIndex( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_REGION *pNewRegion );
|
||||||
BOOLEAN AddVSurfaceRegions( HVSURFACE hVSurface, VSURFACE_REGION **ppNewRegions, UINT16 uiNumRegions );
|
BOOLEAN AddVSurfaceRegions( HVSURFACE hVSurface, VSURFACE_REGION **ppNewRegions, UINT16 uiNumRegions );
|
||||||
BOOLEAN RemoveVSurfaceRegion( HVSURFACE hVSurface, UINT16 usIndex );
|
|
||||||
BOOLEAN ClearAllVSurfaceRegions( HVSURFACE hVSurface );
|
BOOLEAN ClearAllVSurfaceRegions( HVSURFACE hVSurface );
|
||||||
BOOLEAN GetVSurfaceRegion( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_REGION *aRegion );
|
BOOLEAN GetVSurfaceRegion( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_REGION *aRegion );
|
||||||
BOOLEAN GetNumRegions( HVSURFACE hVSurface , UINT32 *puiNumRegions );
|
BOOLEAN GetNumRegions( HVSURFACE hVSurface , UINT32 *puiNumRegions );
|
||||||
|
|||||||
Reference in New Issue
Block a user