2008-08-04 12:05:52 +03:00
|
|
|
#include "../stdafx.h"
|
|
|
|
#include "SDL.h"
|
|
|
|
#include "CDefHandler.h"
|
|
|
|
#include <sstream>
|
2010-12-20 23:22:53 +02:00
|
|
|
#include "../lib/CLodHandler.h"
|
2009-05-09 19:18:27 +03:00
|
|
|
#include "../lib/VCMI_Lib.h"
|
2010-12-20 23:22:53 +02:00
|
|
|
#include "CBitmapHandler.h"
|
2009-04-15 17:03:31 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* CDefHandler.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-10-31 00:53:41 +03:00
|
|
|
#ifdef unused
|
2009-05-24 01:57:39 +03:00
|
|
|
static long long pow(long long a, int b)
|
2008-08-04 12:05:52 +03:00
|
|
|
{
|
|
|
|
if (!b) return 1;
|
|
|
|
long c = a;
|
|
|
|
while (--b)
|
|
|
|
a*=c;
|
|
|
|
return a;
|
|
|
|
}
|
2010-10-31 00:53:41 +03:00
|
|
|
#endif
|
|
|
|
|
2008-08-04 12:05:52 +03:00
|
|
|
CDefHandler::CDefHandler()
|
|
|
|
{
|
|
|
|
notFreeImgs = false;
|
|
|
|
}
|
|
|
|
CDefHandler::~CDefHandler()
|
|
|
|
{
|
|
|
|
if (notFreeImgs)
|
|
|
|
return;
|
2008-12-21 21:17:35 +02:00
|
|
|
for (size_t i=0; i<ourImages.size(); ++i)
|
2008-08-04 12:05:52 +03:00
|
|
|
{
|
|
|
|
if (ourImages[i].bitmap)
|
|
|
|
{
|
|
|
|
SDL_FreeSurface(ourImages[i].bitmap);
|
|
|
|
ourImages[i].bitmap=NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CDefEssential::~CDefEssential()
|
|
|
|
{
|
2008-12-21 21:17:35 +02:00
|
|
|
for(size_t i=0; i < ourImages.size(); ++i)
|
2008-08-04 12:05:52 +03:00
|
|
|
SDL_FreeSurface(ourImages[i].bitmap);
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:07:24 +02:00
|
|
|
void CDefHandler::openFromMemory(unsigned char *table, const std::string & name)
|
2008-08-04 12:05:52 +03:00
|
|
|
{
|
2008-11-11 17:17:58 +02:00
|
|
|
BMPPalette palette[256];
|
2009-10-14 15:44:44 +03:00
|
|
|
SDefEntry &de = * reinterpret_cast<SDefEntry *>(table);
|
2009-10-11 21:26:36 +03:00
|
|
|
unsigned char *p;
|
|
|
|
|
|
|
|
defName = name;
|
|
|
|
DEFType = SDL_SwapLE32(de.DEFType);
|
|
|
|
width = SDL_SwapLE32(de.width);
|
|
|
|
height = SDL_SwapLE32(de.height);
|
2009-10-25 16:36:11 +02:00
|
|
|
unsigned int totalBlocks = SDL_SwapLE32(de.totalBlocks);
|
2009-10-11 21:26:36 +03:00
|
|
|
|
|
|
|
for (unsigned int it=0;it<256;it++)
|
2008-08-04 12:05:52 +03:00
|
|
|
{
|
2009-10-11 21:26:36 +03:00
|
|
|
palette[it].R = de.palette[it].R;
|
|
|
|
palette[it].G = de.palette[it].G;
|
|
|
|
palette[it].B = de.palette[it].B;
|
2008-08-04 12:05:52 +03:00
|
|
|
palette[it].F = 0;
|
|
|
|
}
|
2009-10-11 21:26:36 +03:00
|
|
|
|
2009-10-16 17:56:57 +03:00
|
|
|
// The SDefEntryBlock starts just after the SDefEntry
|
|
|
|
p = reinterpret_cast<unsigned char *>(&de);
|
|
|
|
p += sizeof(de);
|
|
|
|
|
2009-10-25 16:36:11 +02:00
|
|
|
int totalEntries=0;
|
2009-10-11 21:26:36 +03:00
|
|
|
for (unsigned int z=0; z<totalBlocks; z++)
|
2008-08-04 12:05:52 +03:00
|
|
|
{
|
2009-10-14 15:44:44 +03:00
|
|
|
SDefEntryBlock &block = * reinterpret_cast<SDefEntryBlock *>(p);
|
2009-10-11 21:26:36 +03:00
|
|
|
unsigned int totalInBlock;
|
|
|
|
|
2010-02-11 07:25:17 +02:00
|
|
|
totalInBlock = SDL_SwapLE32(read_unaligned_u32(&block.totalInBlock));
|
2009-10-11 21:26:36 +03:00
|
|
|
|
|
|
|
for (unsigned int j=SEntries.size(); j<totalEntries+totalInBlock; j++)
|
2008-08-04 12:05:52 +03:00
|
|
|
SEntries.push_back(SEntry());
|
2009-10-11 21:26:36 +03:00
|
|
|
|
|
|
|
p = block.data;
|
|
|
|
for (unsigned int j=0; j<totalInBlock; j++)
|
2008-08-04 12:05:52 +03:00
|
|
|
{
|
2009-08-19 08:00:59 +03:00
|
|
|
char Buffer[13];
|
2009-10-11 21:26:36 +03:00
|
|
|
memcpy(Buffer, p, 12);
|
2009-08-19 08:00:59 +03:00
|
|
|
Buffer[12] = 0;
|
2008-08-04 12:05:52 +03:00
|
|
|
SEntries[totalEntries+j].name=Buffer;
|
2009-10-11 21:26:36 +03:00
|
|
|
p += 13;
|
2008-08-04 12:05:52 +03:00
|
|
|
}
|
2009-10-11 21:26:36 +03:00
|
|
|
for (unsigned int j=0; j<totalInBlock; j++)
|
2008-08-04 12:05:52 +03:00
|
|
|
{
|
2010-02-11 07:25:17 +02:00
|
|
|
SEntries[totalEntries+j].offset = SDL_SwapLE32(read_unaligned_u32(p));
|
|
|
|
p += 4;
|
2008-08-04 12:05:52 +03:00
|
|
|
}
|
|
|
|
//totalEntries+=totalInBlock;
|
2009-10-11 21:26:36 +03:00
|
|
|
for(unsigned int hh=0; hh<totalInBlock; ++hh)
|
2008-08-04 12:05:52 +03:00
|
|
|
{
|
|
|
|
SEntries[totalEntries].group = z;
|
|
|
|
++totalEntries;
|
|
|
|
}
|
|
|
|
}
|
2009-10-11 21:26:36 +03:00
|
|
|
|
|
|
|
for(unsigned int j=0; j<SEntries.size(); ++j)
|
2008-08-04 12:05:52 +03:00
|
|
|
{
|
|
|
|
SEntries[j].name = SEntries[j].name.substr(0, SEntries[j].name.find('.')+4);
|
|
|
|
}
|
2009-09-18 15:50:00 +03:00
|
|
|
//RWEntries = new unsigned int[height];
|
2009-10-11 21:26:36 +03:00
|
|
|
for(unsigned int i=0; i < SEntries.size(); ++i)
|
2008-08-04 12:05:52 +03:00
|
|
|
{
|
|
|
|
Cimage nimg;
|
2008-11-11 17:17:58 +02:00
|
|
|
nimg.bitmap = getSprite(i, table, palette);
|
2008-08-04 12:05:52 +03:00
|
|
|
nimg.imName = SEntries[i].name;
|
|
|
|
nimg.groupNumber = SEntries[i].group;
|
|
|
|
ourImages.push_back(nimg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDefHandler::expand(unsigned char N,unsigned char & BL, unsigned char & BR)
|
|
|
|
{
|
|
|
|
BL = (N & 0xE0) >> 5;
|
|
|
|
BR = N & 0x1F;
|
|
|
|
}
|
|
|
|
|
2009-10-25 16:36:11 +02:00
|
|
|
SDL_Surface * CDefHandler::getSprite (int SIndex, const unsigned char * FDef, const BMPPalette * palette) const
|
2008-08-04 12:05:52 +03:00
|
|
|
{
|
|
|
|
SDL_Surface * ret=NULL;
|
|
|
|
|
2009-10-11 21:26:36 +03:00
|
|
|
unsigned int BaseOffset,
|
2010-02-21 20:07:24 +02:00
|
|
|
SpriteWidth, SpriteHeight, //format of sprite
|
|
|
|
TotalRowLength, // length of read segment
|
2009-10-11 21:26:36 +03:00
|
|
|
add, FullHeight,FullWidth,
|
|
|
|
RowAdd, //, NextSpriteOffset; //TODO use me
|
|
|
|
prSize,
|
|
|
|
defType2;
|
|
|
|
int LeftMargin, RightMargin, TopMargin, BottomMargin;
|
|
|
|
|
2008-08-04 12:05:52 +03:00
|
|
|
|
2009-05-23 07:22:21 +03:00
|
|
|
unsigned char SegmentType;//, BL, BR; //TODO use me
|
2008-08-04 12:05:52 +03:00
|
|
|
|
2009-10-14 15:44:44 +03:00
|
|
|
BaseOffset = SEntries[SIndex].offset;
|
2009-10-25 16:36:11 +02:00
|
|
|
SSpriteDef sd = * reinterpret_cast<const SSpriteDef *>(FDef + BaseOffset);
|
2009-10-11 21:26:36 +03:00
|
|
|
|
|
|
|
prSize = SDL_SwapLE32(sd.prSize); //TODO use me
|
|
|
|
defType2 = SDL_SwapLE32(sd.defType2);
|
|
|
|
FullWidth = SDL_SwapLE32(sd.FullWidth);
|
|
|
|
FullHeight = SDL_SwapLE32(sd.FullHeight);
|
|
|
|
SpriteWidth = SDL_SwapLE32(sd.SpriteWidth);
|
|
|
|
SpriteHeight = SDL_SwapLE32(sd.SpriteHeight);
|
|
|
|
LeftMargin = SDL_SwapLE32(sd.LeftMargin);
|
|
|
|
TopMargin = SDL_SwapLE32(sd.TopMargin);
|
2008-08-04 12:05:52 +03:00
|
|
|
RightMargin = FullWidth - SpriteWidth - LeftMargin;
|
|
|
|
BottomMargin = FullHeight - SpriteHeight - TopMargin;
|
|
|
|
|
|
|
|
//if(LeftMargin + RightMargin < 0)
|
|
|
|
// SpriteWidth += LeftMargin + RightMargin; //ugly construction... TODO: check how to do it nicer
|
|
|
|
if(LeftMargin<0)
|
|
|
|
SpriteWidth+=LeftMargin;
|
|
|
|
if(RightMargin<0)
|
|
|
|
SpriteWidth+=RightMargin;
|
|
|
|
|
2009-05-23 07:22:21 +03:00
|
|
|
// Note: this looks bogus because we allocate only FullWidth, not FullWidth+add
|
2008-08-04 12:05:52 +03:00
|
|
|
add = 4 - FullWidth%4;
|
|
|
|
if (add==4)
|
|
|
|
add=0;
|
|
|
|
|
|
|
|
ret = SDL_CreateRGBSurface(SDL_SWSURFACE, FullWidth, FullHeight, 8, 0, 0, 0, 0);
|
|
|
|
//int tempee2 = readNormalNr(0,4,((unsigned char *)tempee.c_str()));
|
|
|
|
|
2009-10-14 15:44:44 +03:00
|
|
|
BaseOffset += sizeof(SSpriteDef);
|
2009-10-11 21:26:36 +03:00
|
|
|
int BaseOffsetor = BaseOffset;
|
2008-08-04 12:05:52 +03:00
|
|
|
|
|
|
|
for(int i=0; i<256; ++i)
|
|
|
|
{
|
|
|
|
SDL_Color pr;
|
|
|
|
pr.r = palette[i].R;
|
|
|
|
pr.g = palette[i].G;
|
|
|
|
pr.b = palette[i].B;
|
|
|
|
pr.unused = palette[i].F;
|
|
|
|
(*(ret->format->palette->colors+i))=pr;
|
|
|
|
}
|
|
|
|
|
2009-05-23 07:22:21 +03:00
|
|
|
int ftcp=0;
|
|
|
|
|
|
|
|
// If there's a margin anywhere, just blank out the whole surface.
|
|
|
|
if (TopMargin > 0 || BottomMargin > 0 || LeftMargin > 0 || RightMargin > 0) {
|
2009-10-25 16:36:11 +02:00
|
|
|
memset( reinterpret_cast<char*>(ret->pixels), 0, FullHeight*FullWidth);
|
2009-05-23 07:22:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Skip top margin
|
|
|
|
if (TopMargin > 0)
|
|
|
|
ftcp += TopMargin*(FullWidth+add);
|
|
|
|
|
2009-05-24 17:32:36 +03:00
|
|
|
switch(defType2)
|
|
|
|
{
|
2009-05-23 07:22:21 +03:00
|
|
|
case 0:
|
2008-08-04 12:05:52 +03:00
|
|
|
{
|
2009-10-11 21:26:36 +03:00
|
|
|
for (unsigned int i=0;i<SpriteHeight;i++)
|
2008-08-04 12:05:52 +03:00
|
|
|
{
|
|
|
|
if (LeftMargin>0)
|
2009-05-23 07:22:21 +03:00
|
|
|
ftcp += LeftMargin;
|
|
|
|
|
2009-10-25 16:36:11 +02:00
|
|
|
memcpy(reinterpret_cast<char*>(ret->pixels)+ftcp, &FDef[BaseOffset], SpriteWidth);
|
2009-05-23 07:22:21 +03:00
|
|
|
ftcp += SpriteWidth;
|
|
|
|
BaseOffset += SpriteWidth;
|
|
|
|
|
2008-08-04 12:05:52 +03:00
|
|
|
if (RightMargin>0)
|
2009-05-23 07:22:21 +03:00
|
|
|
ftcp += RightMargin;
|
2008-08-04 12:05:52 +03:00
|
|
|
}
|
|
|
|
}
|
2009-05-23 07:22:21 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2008-08-04 12:05:52 +03:00
|
|
|
{
|
2009-10-25 16:36:11 +02:00
|
|
|
const unsigned int * RWEntriesLoc = reinterpret_cast<const unsigned int *>(FDef+BaseOffset);
|
2008-11-12 20:59:33 +02:00
|
|
|
BaseOffset += sizeof(int) * SpriteHeight;
|
2009-10-11 21:26:36 +03:00
|
|
|
for (unsigned int i=0;i<SpriteHeight;i++)
|
2008-08-04 12:05:52 +03:00
|
|
|
{
|
2010-02-11 07:25:17 +02:00
|
|
|
BaseOffset=BaseOffsetor + SDL_SwapLE32(read_unaligned_u32(RWEntriesLoc + i));
|
2008-08-04 12:05:52 +03:00
|
|
|
if (LeftMargin>0)
|
2009-05-23 07:22:21 +03:00
|
|
|
ftcp += LeftMargin;
|
|
|
|
|
2008-08-04 12:05:52 +03:00
|
|
|
TotalRowLength=0;
|
|
|
|
do
|
|
|
|
{
|
2009-05-23 07:22:21 +03:00
|
|
|
unsigned int SegmentLength;
|
|
|
|
|
2008-08-04 12:05:52 +03:00
|
|
|
SegmentType=FDef[BaseOffset++];
|
2009-05-23 07:22:21 +03:00
|
|
|
SegmentLength=FDef[BaseOffset++] + 1;
|
|
|
|
|
2008-08-04 12:05:52 +03:00
|
|
|
if (SegmentType==0xFF)
|
|
|
|
{
|
2010-07-15 19:21:53 +03:00
|
|
|
memcpy(reinterpret_cast<char*>(ret->pixels)+ftcp, FDef + BaseOffset, SegmentLength);
|
2009-05-23 07:22:21 +03:00
|
|
|
BaseOffset+=SegmentLength;
|
2008-08-04 12:05:52 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-10-25 16:36:11 +02:00
|
|
|
memset(reinterpret_cast<char*>(ret->pixels)+ftcp, SegmentType, SegmentLength);
|
2008-08-04 12:05:52 +03:00
|
|
|
}
|
2010-07-15 19:21:53 +03:00
|
|
|
ftcp += SegmentLength;
|
|
|
|
TotalRowLength += SegmentLength;
|
2008-08-04 12:05:52 +03:00
|
|
|
}while(TotalRowLength<SpriteWidth);
|
2009-05-23 07:22:21 +03:00
|
|
|
|
2008-08-04 12:05:52 +03:00
|
|
|
RowAdd=SpriteWidth-TotalRowLength;
|
2009-05-23 07:22:21 +03:00
|
|
|
|
2008-08-04 12:05:52 +03:00
|
|
|
if (RightMargin>0)
|
2009-05-23 07:22:21 +03:00
|
|
|
ftcp += RightMargin;
|
|
|
|
|
2008-08-04 12:05:52 +03:00
|
|
|
if (add>0)
|
2009-05-23 07:22:21 +03:00
|
|
|
ftcp += add+RowAdd;
|
2008-08-04 12:05:52 +03:00
|
|
|
}
|
|
|
|
}
|
2009-05-23 07:22:21 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2008-08-04 12:05:52 +03:00
|
|
|
{
|
2010-02-11 07:25:17 +02:00
|
|
|
BaseOffset = BaseOffsetor + SDL_SwapLE16(read_unaligned_u16(FDef + BaseOffsetor));
|
|
|
|
|
2009-10-11 21:26:36 +03:00
|
|
|
for (unsigned int i=0;i<SpriteHeight;i++)
|
2008-08-04 12:05:52 +03:00
|
|
|
{
|
|
|
|
//BaseOffset = BaseOffsetor+RWEntries[i];
|
|
|
|
if (LeftMargin>0)
|
2009-05-23 07:22:21 +03:00
|
|
|
ftcp += LeftMargin;
|
|
|
|
|
2008-08-04 12:05:52 +03:00
|
|
|
TotalRowLength=0;
|
2009-05-23 07:22:21 +03:00
|
|
|
|
2008-08-04 12:05:52 +03:00
|
|
|
do
|
|
|
|
{
|
|
|
|
SegmentType=FDef[BaseOffset++];
|
|
|
|
unsigned char code = SegmentType / 32;
|
|
|
|
unsigned char value = (SegmentType & 31) + 1;
|
|
|
|
if(code==7)
|
|
|
|
{
|
2009-10-25 16:36:11 +02:00
|
|
|
memcpy(reinterpret_cast<char*>(ret->pixels)+ftcp, &FDef[BaseOffset], value);
|
2009-05-23 07:22:21 +03:00
|
|
|
ftcp += value;
|
|
|
|
BaseOffset += value;
|
2008-08-04 12:05:52 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-10-25 16:36:11 +02:00
|
|
|
memset(reinterpret_cast<char*>(ret->pixels)+ftcp, code, value);
|
2009-05-23 07:22:21 +03:00
|
|
|
ftcp += value;
|
2008-08-04 12:05:52 +03:00
|
|
|
}
|
|
|
|
TotalRowLength+=value;
|
|
|
|
} while(TotalRowLength<SpriteWidth);
|
2009-05-23 07:22:21 +03:00
|
|
|
|
2008-08-04 12:05:52 +03:00
|
|
|
if (RightMargin>0)
|
2009-05-23 07:22:21 +03:00
|
|
|
ftcp += RightMargin;
|
|
|
|
|
2009-05-24 17:32:36 +03:00
|
|
|
RowAdd=SpriteWidth-TotalRowLength;
|
|
|
|
|
2008-08-04 12:05:52 +03:00
|
|
|
if (add>0)
|
2009-05-23 07:22:21 +03:00
|
|
|
ftcp += add+RowAdd;
|
2008-08-04 12:05:52 +03:00
|
|
|
}
|
|
|
|
}
|
2009-05-23 07:22:21 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
2008-08-04 12:05:52 +03:00
|
|
|
{
|
2009-10-11 21:26:36 +03:00
|
|
|
for (unsigned int i=0;i<SpriteHeight;i++)
|
2008-08-04 12:05:52 +03:00
|
|
|
{
|
2010-02-11 07:25:17 +02:00
|
|
|
BaseOffset = BaseOffsetor + SDL_SwapLE16(read_unaligned_u16(FDef + BaseOffsetor+i*2*(SpriteWidth/32)));
|
2008-08-04 12:05:52 +03:00
|
|
|
if (LeftMargin>0)
|
2009-05-23 07:22:21 +03:00
|
|
|
ftcp += LeftMargin;
|
|
|
|
|
2008-08-04 12:05:52 +03:00
|
|
|
TotalRowLength=0;
|
2009-05-23 07:22:21 +03:00
|
|
|
|
2008-08-04 12:05:52 +03:00
|
|
|
do
|
|
|
|
{
|
|
|
|
SegmentType=FDef[BaseOffset++];
|
|
|
|
unsigned char code = SegmentType / 32;
|
|
|
|
unsigned char value = (SegmentType & 31) + 1;
|
2010-04-04 11:47:00 +03:00
|
|
|
|
|
|
|
int len = std::min<unsigned int>(value, SpriteWidth - TotalRowLength) - std::max(0, -LeftMargin);
|
2010-07-15 19:21:53 +03:00
|
|
|
amax(len, 0);
|
2010-04-04 11:47:00 +03:00
|
|
|
|
2008-08-04 12:05:52 +03:00
|
|
|
if(code==7)
|
|
|
|
{
|
2010-04-04 11:47:00 +03:00
|
|
|
memcpy((ui8*)ret->pixels + ftcp, FDef + BaseOffset, len);
|
|
|
|
ftcp += len;
|
|
|
|
BaseOffset += len;
|
2008-08-04 12:05:52 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-04-04 11:47:00 +03:00
|
|
|
memset((ui8*)ret->pixels + ftcp, code, len);
|
|
|
|
ftcp += len;
|
2008-08-04 12:05:52 +03:00
|
|
|
}
|
|
|
|
TotalRowLength+=( LeftMargin>=0 ? value : value+LeftMargin );
|
|
|
|
}while(TotalRowLength<SpriteWidth);
|
2009-05-23 07:22:21 +03:00
|
|
|
|
2008-08-04 12:05:52 +03:00
|
|
|
if (RightMargin>0)
|
2009-05-23 07:22:21 +03:00
|
|
|
ftcp += RightMargin;
|
|
|
|
|
2009-05-24 17:32:36 +03:00
|
|
|
RowAdd=SpriteWidth-TotalRowLength;
|
|
|
|
|
2008-08-04 12:05:52 +03:00
|
|
|
if (add>0)
|
2009-05-23 07:22:21 +03:00
|
|
|
ftcp += add+RowAdd;
|
2008-08-04 12:05:52 +03:00
|
|
|
}
|
|
|
|
}
|
2009-05-23 07:22:21 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
throw std::string("Unknown sprite format.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-08-04 12:05:52 +03:00
|
|
|
SDL_Color ttcol = ret->format->palette->colors[0];
|
|
|
|
Uint32 keycol = SDL_MapRGBA(ret->format, ttcol.r, ttcol.b, ttcol.g, ttcol.unused);
|
|
|
|
SDL_SetColorKey(ret, SDL_SRCCOLORKEY, keycol);
|
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
|
|
|
|
CDefEssential * CDefHandler::essentialize()
|
|
|
|
{
|
|
|
|
CDefEssential * ret = new CDefEssential;
|
|
|
|
ret->ourImages = ourImages;
|
|
|
|
notFreeImgs = true;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:07:24 +02:00
|
|
|
CDefHandler * CDefHandler::giveDef(const std::string & defName)
|
2008-08-04 12:05:52 +03:00
|
|
|
{
|
2010-11-09 13:27:58 +02:00
|
|
|
unsigned char * data = spriteh->giveFile(defName, FILE_ANIMATION);
|
2008-09-24 19:25:14 +03:00
|
|
|
if(!data)
|
|
|
|
throw "bad def name!";
|
2008-08-04 12:05:52 +03:00
|
|
|
CDefHandler * nh = new CDefHandler();
|
|
|
|
nh->openFromMemory(data, defName);
|
|
|
|
delete [] data;
|
|
|
|
return nh;
|
|
|
|
}
|
2010-02-21 20:07:24 +02:00
|
|
|
CDefEssential * CDefHandler::giveDefEss(const std::string & defName)
|
2008-08-04 12:05:52 +03:00
|
|
|
{
|
|
|
|
CDefEssential * ret;
|
2009-05-09 19:18:27 +03:00
|
|
|
CDefHandler * temp = giveDef(defName);
|
2008-08-04 12:05:52 +03:00
|
|
|
ret = temp->essentialize();
|
|
|
|
delete temp;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|