This commit is contained in:
parent
c582c425f8
commit
3149023193
25 changed files with 2648 additions and 0 deletions
112
Utils/MkLevel/Layers/MkLevelLayerTile.cpp
Normal file
112
Utils/MkLevel/Layers/MkLevelLayerTile.cpp
Normal file
|
@ -0,0 +1,112 @@
|
|||
/******************/
|
||||
/*** Layer Tile ***/
|
||||
/******************/
|
||||
|
||||
#include <DaveLib.h>
|
||||
#include <List2d.h>
|
||||
|
||||
#include "MkLevelLayer.h"
|
||||
#include "MkLevelLayerTile.h"
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
CMkLevelLayerTile::CMkLevelLayerTile(sExpLayerHdr *LayerHdr)
|
||||
{
|
||||
Type=LayerHdr->Type;
|
||||
SubType=LayerHdr->SubType;
|
||||
Width=LayerHdr->Width;
|
||||
Height=LayerHdr->Height;
|
||||
|
||||
sExpLayerTile *MapPtr=(sExpLayerTile *)((int)LayerHdr+sizeof(sExpLayerHdr));
|
||||
|
||||
InMap.SetSize(Width,Height);
|
||||
|
||||
for (int Y=0; Y<Height; Y++)
|
||||
{
|
||||
for (int X=0; X<Width; X++)
|
||||
{
|
||||
sExpLayerTile ThisTile;
|
||||
|
||||
ThisTile.Tile=MapPtr->Tile;
|
||||
ThisTile.Flags=MapPtr->Flags;
|
||||
InMap.Set(X,Y,ThisTile);
|
||||
MapPtr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*** Pre-Process *************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
void CMkLevelLayerTile::PreProcess(CMkLevel *Core)
|
||||
{
|
||||
int Width=InMap.GetWidth();
|
||||
int Height=InMap.GetHeight();
|
||||
|
||||
OutMap.SetSize(Width,Height);
|
||||
|
||||
for (int Y=0; Y<Height; Y++)
|
||||
{
|
||||
for (int X=0; X<Width; X++)
|
||||
{
|
||||
sExpLayerTile &InElem=InMap.Get(X,Y);
|
||||
sMkLevelElem &OutElem=OutMap.Get(X,Y);
|
||||
|
||||
OutElem.Elem=0;
|
||||
if (InElem.Tile)
|
||||
{ // Dont process blanks
|
||||
OutElem.Elem=Core->AddTile2d(InElem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*** Process *****************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
void CMkLevelLayerTile::Process(CMkLevel *Core)
|
||||
{
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/** Write ********************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
int CMkLevelLayerTile::Write(FILE *File,const char *LayerName,const char *MapName)
|
||||
{
|
||||
sLayerHdr Hdr;
|
||||
int ThisPos=ftell(File);
|
||||
int Width=OutMap.GetWidth();
|
||||
int Height=OutMap.GetHeight();
|
||||
|
||||
Hdr.Type=Type;
|
||||
Hdr.SubType=SubType;
|
||||
Hdr.Width=Width;
|
||||
Hdr.Height=Height;
|
||||
fwrite(&Hdr,sizeof(sLayerHdr),1,File);
|
||||
|
||||
for (int Y=0; Y<Height; Y++)
|
||||
{
|
||||
for (int X=0; X<Width; X++)
|
||||
{
|
||||
sMkLevelElem &ThisElem=OutMap.Get(X,Y);
|
||||
|
||||
ASSERT(Hdr.SubType!=LAYER_SUBTYPE_ACTION);
|
||||
fwrite(&ThisElem.Elem,sizeof(u16),1,File);
|
||||
|
||||
}
|
||||
}
|
||||
PadFile(File);
|
||||
|
||||
return(ThisPos);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
Loading…
Add table
Add a link
Reference in a new issue