2001-04-17 18:42:07 +02:00
|
|
|
/*******************/
|
|
|
|
/*** Layer Thing ***/
|
|
|
|
/*******************/
|
|
|
|
|
|
|
|
#include <DaveLib.h>
|
|
|
|
//#include <List2d.h>
|
|
|
|
|
|
|
|
#include "..\MkLevel.h"
|
|
|
|
#include "MkLevelLayer.h"
|
|
|
|
#include "MkLevelLayerThing.h"
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
CMkLevelLayerThing::CMkLevelLayerThing(sExpLayerHdr *LayerHdr)
|
|
|
|
{
|
|
|
|
u8 *Ptr=(u8*)LayerHdr;
|
|
|
|
|
|
|
|
Type=LayerHdr->Type;
|
|
|
|
SubType=LayerHdr->SubType;
|
|
|
|
Width=LayerHdr->Width;
|
|
|
|
Height=LayerHdr->Height;
|
|
|
|
|
|
|
|
int *iPtr=(int*)(Ptr+sizeof(sExpLayerHdr));
|
|
|
|
|
|
|
|
int i,ListSize=*iPtr++;
|
|
|
|
ThingList.resize(ListSize);
|
|
|
|
Ptr=(u8*)iPtr;
|
|
|
|
for (i=0; i<ListSize; i++)
|
|
|
|
{
|
|
|
|
Ptr=LoadThing(ThingList[i],Ptr);
|
|
|
|
}
|
|
|
|
LoadThingNames((char*)Ptr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
u8 *CMkLevelLayerThing::LoadThing(sMkLevelLayerThing &ThisThing,u8 *Ptr)
|
|
|
|
{
|
|
|
|
int i,ListSize;
|
|
|
|
|
|
|
|
sLayerThingData *DPtr=(sLayerThingData*)Ptr;
|
|
|
|
|
|
|
|
ThisThing.Data=*DPtr++;
|
|
|
|
int *iPtr=(int*)DPtr;
|
|
|
|
|
|
|
|
ListSize=ThisThing.Data.WaypointCount;
|
|
|
|
ThisThing.XY.resize(ListSize);
|
|
|
|
for (i=0; i<ListSize; i++)
|
|
|
|
{
|
|
|
|
ThisThing.XY[i].x=*iPtr++;
|
|
|
|
ThisThing.XY[i].y=*iPtr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return((u8*)iPtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
void CMkLevelLayerThing::LoadThingNames(char *Ptr)
|
|
|
|
{
|
|
|
|
int i,ListSize=ThingList.size();
|
|
|
|
|
|
|
|
for (i=0; i<ListSize; i++)
|
|
|
|
{
|
|
|
|
sMkLevelLayerThing &ThisThing=ThingList[i];
|
|
|
|
|
|
|
|
ThisThing.Name=Ptr;
|
|
|
|
Ptr+=strlen(Ptr)+1;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2001-04-19 17:12:21 +02:00
|
|
|
void CMkLevelLayerThing::ProcessList(CMkLevel *Core)
|
2001-04-17 18:42:07 +02:00
|
|
|
{
|
|
|
|
int i,ListSize=ThingList.size();
|
2001-04-19 17:12:21 +02:00
|
|
|
CIni &Config=Core->GetConfig();
|
2001-05-23 18:03:10 +02:00
|
|
|
int KeyCount=Config.GetKeyCount(GetTypeName());
|
|
|
|
vector<int> Counts;
|
|
|
|
|
|
|
|
Counts.resize(KeyCount);
|
|
|
|
for (i=0;i<KeyCount;i++)
|
|
|
|
{
|
|
|
|
Counts[i]=0;
|
|
|
|
}
|
2001-04-17 18:42:07 +02:00
|
|
|
|
|
|
|
for (i=0; i<ListSize; i++)
|
|
|
|
{
|
|
|
|
sMkLevelLayerThing &ThisThing=ThingList[i];
|
2001-04-19 17:12:21 +02:00
|
|
|
bool Found=Config.GetInt(GetTypeName(),ThisThing.Name,ThisThing.Type);
|
2001-05-23 22:02:48 +02:00
|
|
|
|
|
|
|
int Idx=Config.FindKey(GetTypeName(),ThisThing.Name);
|
|
|
|
Counts[Idx]++;
|
|
|
|
ASSERT(Idx<KeyCount);
|
2001-04-17 18:42:07 +02:00
|
|
|
if (!Found)
|
|
|
|
GObject::Error(ERR_FATAL,"%s not found in list\n",ThisThing.Name);
|
|
|
|
}
|
2001-05-23 18:03:10 +02:00
|
|
|
// Create Inf Data
|
|
|
|
|
|
|
|
|
|
|
|
for (i=0; i<KeyCount; i++)
|
|
|
|
{
|
|
|
|
GString OutName="TOTAL_";
|
|
|
|
char *Name=Config.GetKeyName(GetTypeName(),i);
|
|
|
|
|
|
|
|
OutName+=GetTypeName();
|
|
|
|
OutName+="_";
|
|
|
|
OutName+=Name;
|
|
|
|
|
2001-05-30 19:02:54 +02:00
|
|
|
// if (Counts[i])
|
|
|
|
{
|
|
|
|
Core->AddInfItem(OutName,Counts[i]);
|
|
|
|
}
|
2001-05-23 18:03:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
int CMkLevelLayerThing::CountThing(CMkLevel *Core,const char *Name)
|
|
|
|
{
|
|
|
|
int i,ListSize=ThingList.size();
|
|
|
|
int Count=0;
|
|
|
|
|
|
|
|
for (i=0; i<ListSize; i++)
|
|
|
|
{
|
|
|
|
sMkLevelLayerThing &ThisThing=ThingList[i];
|
|
|
|
if (ThisThing.Name=Name)
|
|
|
|
{
|
|
|
|
Count++;
|
|
|
|
}
|
|
|
|
}
|
2001-04-19 17:12:21 +02:00
|
|
|
|
2001-05-23 18:03:10 +02:00
|
|
|
return(Count);
|
2001-04-17 18:42:07 +02:00
|
|
|
}
|