Fixed templatetypeclass land_type. Template's can be placed but only the first tile seems to work.

This commit is contained in:
Justin Marshall
2020-07-01 11:14:03 -07:00
parent f6beb9b4ee
commit c7748a616d
11 changed files with 117 additions and 435 deletions
+3 -6
View File
@@ -142,11 +142,8 @@ Height=30
99=8256 99=8256
[MapPack] [MapPack]
1=BwAAIIH//v8f/4AHAAAggf/+/x//gAcAACCB//7/H/+ABwAAIIH//v8f/4AHAAAggQD+/x 1=BwAAIIH//v8f/4AVAAAggf/+dR7/hAEAAQD+/AD//4oAdh6ABwAAIIH//v8f/4AHAAAggf
2=8AgAcAACCBAP7/HwCA 2=/+/x//gBQAACCBAP47HwCBAf5+AACCAgP+QwAAgAcAACCBAP7/HwCA
[UNITS]
0=USSR,4TNK,256,7867,0,Guard,None
[Base] [Base]
Player=USSR Player=USSR
@@ -162,5 +159,5 @@ Count=0
4=Direct Tanya to destroy the westmost power plants to take them off-line. 4=Direct Tanya to destroy the westmost power plants to take them off-line.
[Digest] [Digest]
1=EwOfEw8wu+RAo5MXzV1zOUK2LeU= 1=dWjOPCEhb7UG7SsNlAGLf6N5iyc=
+37 -29
View File
@@ -2309,31 +2309,29 @@ void TemplateTypeClass::Init_Heap(void)
*=============================================================================================*/ *=============================================================================================*/
LandType TemplateTypeClass::Land_Type(int icon) const LandType TemplateTypeClass::Land_Type(int icon) const
{ {
IconsetClass const * icontrol = (IconsetClass const *)Get_Image_Data(); IsoTile* icontrol = (IsoTile *)Get_Image_Data();
if (icontrol != NULL) { if (icontrol != NULL) {
unsigned char const * map = icontrol->Control_Map(); IsoTileImageHeader* image = icontrol->GetTileInfo(icon);
if (map != NULL) { if (image != NULL) {
static LandType _land[16] = { static LandType _land[16] = {
LAND_CLEAR, LAND_CLEAR,
LAND_CLEAR, LAND_ROAD ,
LAND_CLEAR, LAND_WATER,
LAND_CLEAR, // Clear LAND_ROCK,
LAND_CLEAR, LAND_WALL,
LAND_CLEAR, LAND_TIBERIUM,
LAND_BEACH, // Beach LAND_BEACH,
LAND_CLEAR, LAND_ROUGH,
LAND_ROCK, // Rock LAND_ICE,
LAND_ROAD, // Road LAND_RAILROAD,
LAND_WATER, // Water LAND_TUNNEL,
LAND_RIVER, // River LAND_WEEDS,
LAND_CLEAR, LAND_COUNT,
LAND_CLEAR,
LAND_ROUGH, // Rough
LAND_CLEAR,
}; };
return(_land[map[icon % (icontrol->Map_Width() * icontrol->Map_Height())]]); //return(_land[map[icon % (icontrol->Map_Width() * icontrol->Map_Height())]]);
return _land[image->TileType % LAND_COUNT];
} }
} }
return(LAND_CLEAR); return(LAND_CLEAR);
@@ -2394,14 +2392,19 @@ short const * TemplateTypeClass::Occupy_List(bool) const
static short _occupy[13*8+5]; static short _occupy[13*8+5];
short * ptr; short * ptr;
IconsetClass const * iconset = (IconsetClass const *)Get_Image_Data(); IsoTile * iconset = (IsoTile *)Get_Image_Data();
unsigned char const * map = iconset->Map_Data(); //unsigned char const * map = iconset->Map_Data();
ptr = &_occupy[0]; ptr = &_occupy[0];
for (int index = 0; index < Width * Height; index++) { for (int index = 0; index < iconset->NumTiles(); index++) {
if (*map++ != 0xFF) { //if (*map++ != 0xFF) {
*ptr++ = (index % Width) + ((index / Width)*MAP_CELL_W); // *ptr++ = (index % Width) + ((index / Width)*MAP_CELL_W);
} //}
IsoTileImageHeader* tileimg = iconset->GetTileInfo(index);
if (tileimg == NULL)
continue;
*ptr++ = (index % Width) + ((index / Width) * MAP_CELL_W);
} }
*ptr = REFRESH_EOL; *ptr = REFRESH_EOL;
@@ -2435,9 +2438,9 @@ void TemplateTypeClass::Init(TheaterType theater)
void *terrainPalette = (void *)MFCD::Retrieve(Theaters[theater].IsoPalette); void *terrainPalette = (void *)MFCD::Retrieve(Theaters[theater].IsoPalette);
for (TemplateType index = TEMPLATE_FIRST; index < TEMPLATE_COUNT; index++) { for (TemplateType index = TEMPLATE_FIRST; index < TEMPLATE_COUNT; index++) {
TemplateTypeClass const & tplate = As_Reference(index); TemplateTypeClass& tplate = As_Reference(index);
// jmarshall - temp hack // jmarshall - temp hack
if (index > TEMPLATE_SHORE41) if (index > TEMPLATE_ROAD43)
break; break;
// jmarshall end // jmarshall end
((void const *&)tplate.ImageData) = NULL; ((void const *&)tplate.ImageData) = NULL;
@@ -2466,8 +2469,11 @@ void TemplateTypeClass::Init(TheaterType theater)
sprintf(tmp, "icon_%s", fullname); sprintf(tmp, "icon_%s", fullname);
((void const*&)tplate.HDImageData) = Load_Stamp(fullname, tplate.ImageData, terrainPalette); ((void const*&)tplate.HDImageData) = Load_Stamp(fullname, tplate.ImageData, terrainPalette);
} }
}
}
} }
} }
@@ -2496,6 +2502,8 @@ void TemplateTypeClass::Display(int x, int y, WindowNumberType window, HousesTyp
bool scale; // Should the template be half sized? bool scale; // Should the template be half sized?
Image_t* img = Get_HDImage_Data(); Image_t* img = Get_HDImage_Data();
if (img == NULL)
return;
w = Bound(img->width, 1, 13); w = Bound(img->width, 1, 13);
h = Bound(img->height, 1, 8); h = Bound(img->height, 1, 8);
@@ -2546,7 +2554,7 @@ void TemplateTypeClass::Prep_For_Add(void)
{ {
for (TemplateType index = TEMPLATE_CLEAR1; index < TEMPLATE_COUNT; index++) { for (TemplateType index = TEMPLATE_CLEAR1; index < TEMPLATE_COUNT; index++) {
// jmarshall // jmarshall
if (index > TEMPLATE_SHORE41) if (index > TEMPLATE_ROAD43)
return; return;
// jmarshall end // jmarshall end
if (As_Reference(index).Get_Image_Data()) { if (As_Reference(index).Get_Image_Data()) {
+2 -71
View File
@@ -130,43 +130,9 @@ typedef enum MenuIndexType {
#define DKGRAY GREY #define DKGRAY GREY
#define LTGRAY LTGREY #define LTGRAY LTGREY
int Get_IconSet_MapWidth(void const* data);
int Get_IconSet_MapHeight(void const* data);
class IconsetClass;
#ifndef WIN32
typedef struct {
short Width; // Width of icons (pixels).
short Height; // Height of icons (pixels).
short Count; // Number of (logical) icons in this set.
short Allocated; // Was this iconset allocated?
short MapWidth; // Width of map (in icons).
short MapHeight; // Height of map (in icons).
long Size; // Size of entire iconset memory block.
long Icons; // Offset from buffer start to icon data.
// unsigned char * Icons; // Offset from buffer start to icon data.
long Palettes; // Offset from buffer start to palette data.
long Remaps; // Offset from buffer start to remap index data.
long TransFlag; // Offset for transparency flag table.
long ColorMap; // Offset for color control value table.
long Map; // Icon map offset (if present).
// unsigned char * Map; // Icon map offset (if present).
} IControl_Type;
#endif
inline int Get_IconSet_MapWidth(void const * data)
{
if (data) {
return(((IControl_Type *)data)->MapWidth);
}
return(0);
}
inline int Get_IconSet_MapHeight(void const * data)
{
if (data) {
return(((IControl_Type *)data)->MapHeight);
}
return(0);
}
inline unsigned char const * Get_IconSet_ControlMap(void const * data) inline unsigned char const * Get_IconSet_ControlMap(void const * data)
{ {
@@ -176,39 +142,4 @@ inline unsigned char const * Get_IconSet_ControlMap(void const * data)
return(0); return(0);
} }
class IconsetClass : protected IControl_Type
{
public:
/*
** Query functions.
*/
int Map_Width(void) const {return(MapWidth);};
int Map_Height(void) const {return(MapHeight);};
unsigned char * Control_Map(void) {return((unsigned char *)this + ColorMap);};
unsigned char const * Control_Map(void) const {return((unsigned char const *)this + ColorMap);};
int Icon_Count(void) const {return(Count);};
int Pixel_Width(void) const {return(Width);};
int Pixel_Height(void) const {return(Height);};
int Total_Size(void) const {return(Size);};
unsigned char const * Palette_Data(void) const {return((unsigned char const *)this + Palettes);};
unsigned char * Palette_Data(void) {return((unsigned char *)this + Palettes);};
unsigned char const * Icon_Data(void) const {return((unsigned char const *)this + Icons);};
unsigned char * Icon_Data(void) {return((unsigned char *)this + Icons);};
unsigned char const * Map_Data(void) const {return((unsigned char const *)this + Map);};
unsigned char * Map_Data(void) {return((unsigned char *)this + Map);};
unsigned char const * Remap_Data(void) const {return((unsigned char const *)this + Remaps);};
unsigned char * Remap_Data(void) {return((unsigned char *)this + Remaps);};
unsigned char const * Trans_Data(void) const {return((unsigned char const *)this + TransFlag);};
unsigned char * Trans_Data(void) {return((unsigned char *)this + TransFlag);};
/*
** Disallow these operations with an IconsetClass object.
*/
private:
IconsetClass & operator = (IconsetClass const &);
IconsetClass(void);
static void * operator new(size_t);
};
#endif #endif
+4
View File
@@ -2928,6 +2928,10 @@ typedef enum LandType : char {
LAND_BEACH, // Beach terrain. LAND_BEACH, // Beach terrain.
LAND_ROUGH, // Rocky terrain. LAND_ROUGH, // Rocky terrain.
LAND_RIVER, // Rocky riverbed. LAND_RIVER, // Rocky riverbed.
LAND_ICE,
LAND_RAILROAD,
LAND_TUNNEL,
LAND_WEEDS,
LAND_COUNT, LAND_COUNT,
LAND_NONE=-1, LAND_NONE=-1,
+2 -2
View File
@@ -1003,7 +1003,7 @@ void DisplayClass::Cursor_Mark(CELL pos, bool on)
CELL cell = pos + *ptr++; CELL cell = pos + *ptr++;
if (In_Radar(cell)) { if (In_Radar(cell)) {
cellptr = &(*this)[cell]; cellptr = &(*this)[cell];
cellptr->Redraw_Objects(); cellptr->Redraw_Objects(true); // jmarshall: Force redraw all cursor tiles.
if (on) { if (on) {
cellptr->IsCursorHere = true; cellptr->IsCursorHere = true;
} else { } else {
@@ -1022,7 +1022,7 @@ void DisplayClass::Cursor_Mark(CELL pos, bool on)
CELL cell = pos + *ptr++; CELL cell = pos + *ptr++;
if (In_Radar(cell)) { if (In_Radar(cell)) {
cellptr = &(*this)[cell]; cellptr = &(*this)[cell];
cellptr->Redraw_Objects(); cellptr->Redraw_Objects(true); // jmarshall: Force redraw all cursor tiles.
} }
} }
} }
+2
View File
@@ -156,6 +156,8 @@ public:
return tileImageHeaders; return tileImageHeaders;
} }
int NumTiles(void) { return header.TileWidth * header.TileHeight; } int NumTiles(void) { return header.TileWidth * header.TileHeight; }
int NumTilesX(void) { return header.TileWidth; }
int NumTilesY(void) { return header.TileHeight; }
private: private:
IsoTileHeader_t header; IsoTileHeader_t header;
}; };
+10 -9
View File
@@ -1299,15 +1299,16 @@ if (BlubCell->Overlapper[1]) {
** icon. If the icon value is out of range or points to an invalid spot, ** icon. If the icon value is out of range or points to an invalid spot,
** return an error. ** return an error.
*/ */
if (ttype != TEMPLATE_NONE) { // jmarshall - readd this check?
tclass = &TemplateTypeClass::As_Reference(ttype); //if (ttype != TEMPLATE_NONE) {
ticon = (*this)[cell].TIcon; // tclass = &TemplateTypeClass::As_Reference(ttype);
Mem_Copy(Get_Icon_Set_Map(tclass->Get_Image_Data()), map, tclass->Width * tclass->Height); // ticon = (*this)[cell].TIcon;
if (ticon < 0 || ticon >= (tclass->Width * tclass->Height) || map[ticon]==0xff) { // Mem_Copy(Get_Icon_Set_Map(tclass->Get_Image_Data()), map, tclass->Width * tclass->Height);
return (false); // if (ticon < 0 || ticon >= (tclass->Width * tclass->Height) || map[ticon]==0xff) {
} // return (false);
} // }
//}
// jmarshall end
/* /*
** Validate Overlay ** Validate Overlay
*/ */
+19 -19
View File
@@ -1081,25 +1081,25 @@ void RadarClass::Plot_Radar_Pixel(CELL cell)
ptr = &TemplateTypeClass::As_Reference(TEMPLATE_CLEAR1); ptr = &TemplateTypeClass::As_Reference(TEMPLATE_CLEAR1);
icon = cellptr->Clear_Icon(); icon = cellptr->Clear_Icon();
} }
// jmarshall - fix radar
IconsetClass const * iconset = (IconsetClass const *)ptr->Get_Image_Data(); // IconsetClass const * iconset = (IconsetClass const *)ptr->Get_Image_Data();
unsigned char const * icondata = iconset->Icon_Data(); // unsigned char const * icondata = iconset->Icon_Data();
//
//
/* // /*
** Convert the logical icon number into the actual icon number. // ** Convert the logical icon number into the actual icon number.
*/ // */
icon &= 0x00FF; // icon &= 0x00FF;
icon = *(iconset->Map_Data() + icon); // icon = *(iconset->Map_Data() + icon);
// jmarshall //// jmarshall
unsigned char * data = (unsigned char *)icondata + icon*(24*24); // unsigned char * data = (unsigned char *)icondata + icon*(24*24);
Image_t* image; // Image_t* image;
{ // {
char tmp[512]; // char tmp[512];
sprintf(tmp, "radar_%d_%d", ptr->Type, icon); // sprintf(tmp, "radar_%d_%d", ptr->Type, icon);
image = Image_CreateImageFrom8Bit(tmp, 24, 24, (unsigned char*)data); // image = Image_CreateImageFrom8Bit(tmp, 24, 24, (unsigned char*)data);
} // }
GL_RenderImage(image, x, y, ZoomFactor, ZoomFactor); // GL_RenderImage(image, x, y, ZoomFactor, ZoomFactor);
// jmarshall end // jmarshall end
//Buffer_To_Page(0, 0, 24, 24, data, _TileStage); //Buffer_To_Page(0, 0, 24, 24, data, _TileStage);
//_TileStage.Scale(*LogicPage, 0, 0, x, y, 24, 24, ZoomFactor, ZoomFactor, TRUE); //_TileStage.Scale(*LogicPage, 0, 0, x, y, 24, 24, ZoomFactor, ZoomFactor, TRUE);
+4 -4
View File
@@ -90,7 +90,7 @@ bool TemplateClass::Mark(MarkType mark)
void const * iset = Get_Image_Data(); void const * iset = Get_Image_Data();
if (iset && ObjectClass::Mark(mark)) { if (iset && ObjectClass::Mark(mark)) {
void * map = Get_Icon_Set_Map(iset); //void * map = Get_Icon_Set_Map(iset);
for (int y = 0; y < Class->Height; y++) { for (int y = 0; y < Class->Height; y++) {
for (int x = 0; x < Class->Width; x++) { for (int x = 0; x < Class->Width; x++) {
@@ -104,10 +104,10 @@ bool TemplateClass::Mark(MarkType mark)
** icon is associated with this logical position, then don't do any action ** icon is associated with this logical position, then don't do any action
** since none is required. ** since none is required.
*/ */
char * mapptr = (char*)map; //char * mapptr = (char*)map;
bool real = (mapptr[number] != -1); //bool real = (mapptr[number] != -1);
if (real) { {
/* /*
** Lift the terrain object from the map. ** Lift the terrain object from the map.
*/ */
+34 -2
View File
@@ -31,6 +31,28 @@ using std::memcpy;
class GraphicViewPortClass; class GraphicViewPortClass;
byte TempTSStampData[48 * 24 * 4]; byte TempTSStampData[48 * 24 * 4];
int Get_IconSet_MapWidth(void const* data)
{
// jmarshall
if (data) {
return ((IsoTile*)data)->NumTilesX();
}
// jmarshall end
return(0);
}
int Get_IconSet_MapHeight(void const* data)
{
// jmarshall
if (data) {
return ((IsoTile*)data)->NumTilesY();
}
// jmarshall end
return(0);
}
Image_t* Load_StampHD(int theater, const char* iconName, const void* icondata) { Image_t* Load_StampHD(int theater, const char* iconName, const void* icondata) {
char filename[2048]; char filename[2048];
Image_t* image = NULL; Image_t* image = NULL;
@@ -124,7 +146,12 @@ Image_t * Load_Stamp(const char *name, const void* icondata, void* terrainPalett
} }
} }
uint8_t* src = isoTile->GetTileInfo(0)->GetRasterizedData(); IsoTileImageHeader* initialTile = isoTile->GetTileInfo(0);
if(initialTile == NULL) {
return NULL;
}
uint8_t* src = initialTile->GetRasterizedData();
Image_t *image = Image_CreateImageFrom8Bit(name, isoTile->TileImageWidth(), isoTile->TileImageHeight(), (unsigned char*)src, NULL, (unsigned char *)terrainPalette); Image_t *image = Image_CreateImageFrom8Bit(name, isoTile->TileImageWidth(), isoTile->TileImageHeight(), (unsigned char*)src, NULL, (unsigned char *)terrainPalette);
if (image == NULL) { if (image == NULL) {
return NULL; return NULL;
@@ -133,7 +160,12 @@ Image_t * Load_Stamp(const char *name, const void* icondata, void* terrainPalett
image->isoTileInfo = isoTile; image->isoTileInfo = isoTile;
for (int i = 1; i < isoTile->NumTiles(); i++) { for (int i = 1; i < isoTile->NumTiles(); i++) {
src = isoTile->GetTileInfo(i)->GetRasterizedData(); IsoTileImageHeader* tile = isoTile->GetTileInfo(i);
if(tile == NULL) {
continue;
}
src = tile->GetRasterizedData();
Image_Add8BitImage(image, 0, i, isoTile->TileImageWidth(), isoTile->TileImageHeight(), src, NULL, (unsigned char*)terrainPalette); Image_Add8BitImage(image, 0, i, isoTile->TileImageWidth(), isoTile->TileImageHeight(), src, NULL, (unsigned char*)terrainPalette);
} }
-293
View File
@@ -46,296 +46,3 @@
#include <file.h> #include <file.h>
#include "tile.h" #include "tile.h"
#include <iff.h> #include <iff.h>
// Misc? ST - 1/3/2019 10:40AM
//extern int Misc;
int Misc;
void * Load_Icon_Set(char const *filename, void *iconsetptr, long buffsize);
void Free_Icon_Set(void const *iconset);
long Get_Icon_Set_Size(void const *iconset);
int Get_Icon_Set_Width(void const *iconset);
int Get_Icon_Set_Height(void const *iconset);
void * Get_Icon_Set_Icondata(void const *iconset);
void * Get_Icon_Set_Trans(void const *iconset);
void * Get_Icon_Set_Remapdata(void const *iconset);
void * Get_Icon_Set_Palettedata(void const *iconset);
int Get_Icon_Set_Count(void const *iconset);
void * Get_Icon_Set_Map(void const *iconset);
//#define ICON_PALETTE_BYTES 16
//#define ICON_MAX 256
/***************************************************************************
** The terrain is rendered by using icons. These are the buffers that hold
** the icon data, remap tables, and remap index arrays.
*/
//PRIVATE char *IconPalette = NULL; // MCGA only.
//PRIVATE char *IconRemap = NULL; // MCGA only.
#define FORM_RPAL MAKE_ID('R','P','A','L')
#define FORM_RTBL MAKE_ID('R','T','B','L')
#define FORM_SSET MAKE_ID('S','S','E','T')
#define FORM_SINF MAKE_ID('S','I','N','F')
#define FORM_ICON MAKE_ID('I','C','O','N')
#define FORM_TRNS MAKE_ID('T','R','N','S')
#define FORM_MAP MAKE_ID('M','A','P',' ')
/***************************************************************************
* LOAD_ICON_SET -- Loads an icons set and initializes it. *
* *
* This routine will load an IFF icon set from disk. It handles all *
* of the necessary allocations. *
* *
* INPUT: filename -- Name of the icon file. *
* *
* buffer -- Pointer to paragraph aligned buffer to hold data. *
* *
* size -- Size of the buffer (in bytes). *
* *
* OUTPUT: none *
* *
* WARNINGS: In EEGA mode the iconset buffer will be free because the *
* icons will have been transferred to card ram. *
* *
* HISTORY: *
* 06/21/1991 JLB : Created. *
* 07/01/1991 JLB : Determines icon size from file. *
* 07/15/1991 JLB : Load and uncompress onto the same buffer. *
* 09/15/1993 JLB : Added EMS support. *
*=========================================================================*/
void * Load_Icon_Set(char const *filename, void *iconsetptr, long buffsize)
{
int fh; // File handle of iconset.
int bytespericon; // The number of bytes per icon.
unsigned long icons=0; // Number of icons loaded.
unsigned long size; // Size of the icon chunk (raw).
unsigned long transsize;
void *transptr=NULL;
unsigned long mapsize; // Icon map chunk size.
void *mapptr=NULL; // Icon map pointer.
void *returnptr=NULL; // Iconset pointer returned by routine.
BOOL allocated=FALSE; // Was the iconset block allocated?
IControl_Type *idata=NULL; // Icon data loaded.
long id; // ID of file openned.
struct {
char Width; // Width of icon in bytes.
char Height; // Height of icon in bytes.
char Format; // Graphic mode.
//lint -esym(754,Format)
char Bitplanes; // Number of bitplanes per icon.
} sinf;
/*
** Open the icon set for loading. If it is not a legal icon set
** data file, then abort.
*/
fh = Open_Iff_File(filename);
if (fh != WW_ERROR) {
Read_File(fh, &id, sizeof(long));
if (id == FORM_ICON) {
/*
** Determine the size of the icons and set up the graphic
** system accordingly. Also get the sizes of the various
** data blocks that have to be loaded.
*/
Read_Iff_Chunk(fh, FORM_SINF, &sinf, sizeof(sinf));
bytespericon = ((((int)sinf.Width)<<3)*(((int)sinf.Height)<<3)*(int)sinf.Bitplanes)>>3;
size = Get_Iff_Chunk_Size(fh,FORM_SSET);
transsize = Get_Iff_Chunk_Size(fh, FORM_TRNS);
mapsize = Get_Iff_Chunk_Size(fh, FORM_MAP);
/*
** Allocate the icon buffer if one isn't provided. First try EMS and
** then try conventional RAM.
*/
allocated = FALSE;
if (!iconsetptr) {
buffsize = size + transsize + mapsize + sizeof(IControl_Type);
Misc = buffsize;
iconsetptr = Alloc(buffsize, MEM_NORMAL);
allocated = (iconsetptr != NULL);
}
if (iconsetptr && (size+transsize+mapsize+sizeof(IControl_Type)) <= (unsigned long)buffsize) {
idata = (IControl_Type *)iconsetptr;
memset(idata, 0, sizeof(IControl_Type));
/*
** Initialize the iconset header structure.
*/
idata->Width = (short)(((short)sinf.Width)<<3);
idata->Height = (short)(((short)sinf.Height)<<3);
idata->Allocated = (short)allocated;
idata->Icons = (long)iconsetptr + sizeof(IControl_Type);
idata->Map = idata->Icons + size;
idata->TransFlag = sizeof(IControl_Type) + size + mapsize;
idata->Size = buffsize;
{
long val;
val = Read_Iff_Chunk(fh, FORM_SSET, Add_Long_To_Pointer(iconsetptr, sizeof(IControl_Type)), size);
icons = (int)(val/(long)bytespericon);
idata = (IControl_Type *)iconsetptr;
}
if (mapsize) {
icons = mapsize;
}
idata->Count = (short)icons;
/*
** Limit buffer to only the size needed. This is done AFTER loading of the
** raw icon data because it might have been compressed and thus need any
** extra space to perform an overlapped decompression.
*/
if ((unsigned long)buffsize > size + transsize + mapsize + sizeof(IControl_Type)) {
buffsize = size + transsize + mapsize + sizeof(IControl_Type);
}
transptr = Add_Long_To_Pointer(iconsetptr, idata->TransFlag);
Read_Iff_Chunk(fh, FORM_TRNS, transptr, transsize);
idata = (IControl_Type *)iconsetptr;
mapptr = (void*)idata->Map;
Read_Iff_Chunk(fh, FORM_MAP, mapptr, mapsize);
/*
** Let the graphic overlay know of the icon data. This could involve
** translation and other data manipulations.
*/
//Init_Stamps(iconsetptr);
returnptr = iconsetptr;
}
}
Close_Iff_File(fh);
}
return (returnptr); // Return with icon pointer.
}
/***************************************************************************
* FREE_ICON_SET -- Frees allocations made by Load_Icon_Set(). *
* *
* This routine is used to free up any allocations by Load_Icon_Set(). *
* Use this routine when a new icon set is to be loaded. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 06/21/1991 JLB : Created. *
*=========================================================================*/
void Free_Icon_Set(void const *iconset)
{
IControl_Type *icontrol;
icontrol = (IControl_Type *)iconset;
if (icontrol) {
if (icontrol->Allocated) {
Free((void *)iconset);
}
}
}
long Get_Icon_Set_Size(void const *iconset)
{
IControl_Type *icontrol;
long size=0;
icontrol = (IControl_Type *)iconset;
if (icontrol) {
size = icontrol->Size;
}
return(size);
}
int Get_Icon_Set_Width(void const *iconset)
{
IControl_Type *icontrol;
int width=0;
icontrol = (IControl_Type *)iconset;
if (icontrol) {
width = icontrol->Width;
}
return(width);
}
int Get_Icon_Set_Height(void const *iconset)
{
IControl_Type *icontrol;
int height=0;
icontrol = (IControl_Type *)iconset;
if (icontrol) {
height = icontrol->Height;
}
return(height);
}
void * Get_Icon_Set_Icondata(void const *iconset)
{
IControl_Type *icontrol;
icontrol = (IControl_Type *)iconset;
if (icontrol)
return(Add_Long_To_Pointer(iconset, (LONG)icontrol->Icons));
return(NULL);
}
void * Get_Icon_Set_Trans(void const *iconset)
{
IControl_Type *icontrol;
void *ptr=NULL;
icontrol = (IControl_Type *)iconset;
if (icontrol) {
ptr = Add_Long_To_Pointer((void *)iconset, icontrol->TransFlag);
}
return(ptr);
}
int Get_Icon_Set_Count(void const *iconset)
{
IControl_Type *icontrol;
int count;
icontrol = (IControl_Type *)iconset;
if (icontrol) {
count = icontrol->Count;
}
return(count);
}
void * Get_Icon_Set_Map(void const *iconset)
{
IControl_Type *icontrol;
icontrol = (IControl_Type *)iconset;
if (icontrol)
return(Add_Long_To_Pointer(iconset, (LONG)icontrol->Map));
return(NULL);
}