SBSPSS/Utils/MkLevel/Layers/MkLevelLayerHazard.cpp

89 lines
3.0 KiB
C++
Raw Normal View History

2001-04-30 23:14:13 +02:00
/**********************/
2001-04-30 23:49:54 +02:00
/*** Layer Hazard ***/
2001-04-30 23:14:13 +02:00
/**********************/
#include <Davelib.h>
#include <List2d.h>
//#include "MkLevel.h"
2001-04-30 23:49:54 +02:00
#include "MkLevelLayerHazard.h"
2001-04-30 23:14:13 +02:00
/*****************************************************************************/
/*****************************************************************************/
/*** Pre-Process *************************************************************/
/*****************************************************************************/
/*****************************************************************************/
2001-04-30 23:49:54 +02:00
void CMkLevelLayerHazard::PreProcess(CMkLevel *Core)
2001-04-30 23:14:13 +02:00
{
int i,ListSize;
ProcessList(Core);
ListSize=ThingList.size();
RemapTable.resize(ListSize);
for (i=0; i<ListSize; i++)
{
sMkLevelLayerThing &ThisThing=ThingList[i];
2001-04-30 23:49:54 +02:00
RemapTable[i]=Core->AddModel(ThisThing.Name,ThisThing.Data.Hazard.HazardTriStart,ThisThing.Data.Hazard.HazardTriCount);
2001-04-30 23:14:13 +02:00
}
2001-04-30 23:49:54 +02:00
printf("%i Hazards\n",ThingList.size());
2001-04-30 23:14:13 +02:00
}
/*****************************************************************************/
/*****************************************************************************/
/*** Process *****************************************************************/
/*****************************************************************************/
/*****************************************************************************/
2001-04-30 23:49:54 +02:00
void CMkLevelLayerHazard::Process(CMkLevel *Core)
2001-04-30 23:14:13 +02:00
{
}
/*****************************************************************************/
/*****************************************************************************/
/** Write ********************************************************************/
/*****************************************************************************/
/*****************************************************************************/
2001-04-30 23:49:54 +02:00
int CMkLevelLayerHazard::Write(FILE *File,const char *LayerName,const char *MapName)
2001-04-30 23:14:13 +02:00
{
int ThisPos=ftell(File);
sThingHdr Hdr;
int i,ListSize=ThingList.size();
Hdr.Count=ListSize;
fwrite(&Hdr,sizeof(sThingHdr),1,File);
for (i=0; i<ListSize; i++)
{
sMkLevelLayerThing &ThisThing=ThingList[i];
int p,PointCount=ThisThing.XY.size();
2001-04-30 23:49:54 +02:00
sThingHazard OutThing;
2001-04-30 23:14:13 +02:00
OutThing.Type=ThisThing.Type;
2001-04-30 23:49:54 +02:00
OutThing.Speed=ThisThing.Data.Hazard.HazardSpeed;
OutThing.TurnRate=ThisThing.Data.Hazard.HazardTurnRate;
2001-05-09 23:56:48 +02:00
OutThing.Flags=0;
if (ThisThing.Data.Hazard.HazardCollisionFlag) OutThing.Flags|=THING_FLAG_COLLISION;
if (ThisThing.Data.Flip & PC_TILE_FLAG_MIRROR_X) OutThing.Flags|=THING_FLAG_MIRRORX;
if (ThisThing.Data.Flip & PC_TILE_FLAG_MIRROR_Y) OutThing.Flags|=THING_FLAG_MIRRORY;
2001-04-30 23:14:13 +02:00
OutThing.PointCount=PointCount;
2001-04-30 23:49:54 +02:00
OutThing.Respawn=ThisThing.Data.Hazard.HazardRespawn;
2001-04-30 23:14:13 +02:00
OutThing.Gfx=RemapTable[i];
2001-04-30 23:49:54 +02:00
fwrite(&OutThing,sizeof(sThingHazard),1,File);
2001-04-30 23:14:13 +02:00
for (p=0;p<PointCount;p++)
{
sThingPoint Pnt;
Pnt.X=ThisThing.XY[p].x;
Pnt.Y=ThisThing.XY[p].y;
fwrite(&Pnt,sizeof(sThingPoint),1,File);
}
}
return(ThisPos);
}
/*****************************************************************************/