This commit is contained in:
Daveo 2001-04-30 21:49:54 +00:00
parent a115ed8b39
commit b31a2e39dc
52 changed files with 1841 additions and 886 deletions

View file

@ -72,11 +72,11 @@ int i,ListSize=ThingList.size();
sThingActor OutThing;
OutThing.Type=ThisThing.Type;
OutThing.Health=ThisThing.Data.Health;
OutThing.AttackStrength=ThisThing.Data.AttackStrength;
OutThing.Speed=ThisThing.Data.Speed;
OutThing.TurnRate=ThisThing.Data.TurnRate;
OutThing.Flags=ThisThing.Data.CollisionFlag;
OutThing.Health=ThisThing.Data.Actor.ActorHealth;
OutThing.AttackStrength=ThisThing.Data.Actor.ActorAttackStrength;
OutThing.Speed=ThisThing.Data.Actor.ActorSpeed;
OutThing.TurnRate=ThisThing.Data.Actor.ActorTurnRate;
OutThing.Flags=ThisThing.Data.Actor.ActorCollisionFlag;
OutThing.PointCount=PointCount;
fwrite(&OutThing,sizeof(sThingActor),1,File);

View file

@ -50,11 +50,11 @@ int i,ListSize=ThingList.size();
sThingFX OutThing;
OutThing.Type=ThisThing.Type;
OutThing.Speed=ThisThing.Data.Speed;
OutThing.Speed=ThisThing.Data.FX.FXSpeed;
OutThing.Pos.X=ThisThing.XY[0].x;
OutThing.Pos.Y=ThisThing.XY[0].y;
OutThing.Size.X=ThisThing.Data.Width;
OutThing.Size.Y=ThisThing.Data.Height;
OutThing.Size.X=ThisThing.Data.FX.FXWidth;
OutThing.Size.Y=ThisThing.Data.FX.FXHeight;
fwrite(&OutThing,sizeof(sThingFX),1,File);
}

View file

@ -1,12 +1,12 @@
/**********************/
/*** Layer Platform ***/
/*** Layer Hazard ***/
/**********************/
#include <Davelib.h>
#include <List2d.h>
//#include "MkLevel.h"
#include "MkLevelLayerPlatform.h"
#include "MkLevelLayerHazard.h"
/*****************************************************************************/
@ -14,7 +14,7 @@
/*** Pre-Process *************************************************************/
/*****************************************************************************/
/*****************************************************************************/
void CMkLevelLayerPlatform::PreProcess(CMkLevel *Core)
void CMkLevelLayerHazard::PreProcess(CMkLevel *Core)
{
int i,ListSize;
ProcessList(Core);
@ -24,10 +24,11 @@ int i,ListSize;
for (i=0; i<ListSize; i++)
{
sMkLevelLayerThing &ThisThing=ThingList[i];
RemapTable[i]=Core->AddModel(ThisThing);
RemapTable[i]=Core->AddModel(ThisThing.Name,ThisThing.Data.Hazard.HazardTriStart,ThisThing.Data.Hazard.HazardTriCount);
}
printf("%i Platforms\n",ThingList.size());
printf("%i Hazards\n",ThingList.size());
}
/*****************************************************************************/
@ -35,7 +36,7 @@ int i,ListSize;
/*** Process *****************************************************************/
/*****************************************************************************/
/*****************************************************************************/
void CMkLevelLayerPlatform::Process(CMkLevel *Core)
void CMkLevelLayerHazard::Process(CMkLevel *Core)
{
}
@ -44,7 +45,7 @@ void CMkLevelLayerPlatform::Process(CMkLevel *Core)
/** Write ********************************************************************/
/*****************************************************************************/
/*****************************************************************************/
int CMkLevelLayerPlatform::Write(FILE *File,const char *LayerName,const char *MapName)
int CMkLevelLayerHazard::Write(FILE *File,const char *LayerName,const char *MapName)
{
int ThisPos=ftell(File);
sThingHdr Hdr;
@ -57,15 +58,16 @@ int i,ListSize=ThingList.size();
{
sMkLevelLayerThing &ThisThing=ThingList[i];
int p,PointCount=ThisThing.XY.size();
sThingPlatform OutThing;
sThingHazard OutThing;
OutThing.Type=ThisThing.Type;
OutThing.Speed=ThisThing.Data.Platform.PlatformSpeed;
OutThing.TurnRate=ThisThing.Data.Platform.PlatformTurnRate;
OutThing.Flags=ThisThing.Data.Platform.PlatformCollisionFlag;
OutThing.Speed=ThisThing.Data.Hazard.HazardSpeed;
OutThing.TurnRate=ThisThing.Data.Hazard.HazardTurnRate;
OutThing.Flags=ThisThing.Data.Hazard.HazardCollisionFlag;
OutThing.PointCount=PointCount;
OutThing.Respawn=ThisThing.Data.Hazard.HazardRespawn;
OutThing.Gfx=RemapTable[i];
fwrite(&OutThing,sizeof(sThingPlatform),1,File);
fwrite(&OutThing,sizeof(sThingHazard),1,File);
for (p=0;p<PointCount;p++)
{

View file

@ -1,19 +1,19 @@
/**********************/
/*** Layer Platform ***/
/**********************/
/********************/
/*** Layer Hazard ***/
/********************/
#ifndef __MKLEVEL_LAYER_PLATFORM_HEADER__
#define __MKLEVEL_LAYER_PLATFORM_HEADER__
#ifndef __MKLEVEL_LAYER_HAZARD_HEADER__
#define __MKLEVEL_LAYER_HAZARD_HEADER__
#include "MkLevelLayerThing.h"
#include <List2d.h>
/*****************************************************************************/
class CMkLevelLayerPlatform : public CMkLevelLayerThing
class CMkLevelLayerHazard : public CMkLevelLayerThing
{
public:
CMkLevelLayerPlatform(sExpLayerHdr *LayerHdr) : CMkLevelLayerThing(LayerHdr){};
const char *GetTypeName() {return("PLATFORM");}
CMkLevelLayerHazard(sExpLayerHdr *LayerHdr) : CMkLevelLayerThing(LayerHdr){};
const char *GetTypeName() {return("HAZARD");}
void PreProcess(CMkLevel *Core);
void Process(CMkLevel *Core);

View file

@ -24,7 +24,7 @@ int i,ListSize;
for (i=0; i<ListSize; i++)
{
sMkLevelLayerThing &ThisThing=ThingList[i];
RemapTable[i]=Core->AddModel(ThisThing);
RemapTable[i]=Core->AddModel(ThisThing.Name,ThisThing.Data.Platform.PlatformTriStart,ThisThing.Data.Platform.PlatformTriCount);
}
printf("%i Platforms\n",ThingList.size());
@ -60,9 +60,9 @@ int i,ListSize=ThingList.size();
sThingPlatform OutThing;
OutThing.Type=ThisThing.Type;
OutThing.Speed=ThisThing.Data.Speed;
OutThing.TurnRate=ThisThing.Data.TurnRate;
OutThing.Flags=ThisThing.Data.CollisionFlag;
OutThing.Speed=ThisThing.Data.Platform.PlatformSpeed;
OutThing.TurnRate=ThisThing.Data.Platform.PlatformTurnRate;
OutThing.Flags=ThisThing.Data.Platform.PlatformCollisionFlag;
OutThing.PointCount=PointCount;
OutThing.Gfx=RemapTable[i];
fwrite(&OutThing,sizeof(sThingPlatform),1,File);

View file

@ -13,9 +13,9 @@
/*****************************************************************************/
CMkLevelLayerShade::CMkLevelLayerShade(sExpLayerHdr *LayerHdr)
{
int i,ListSize;
int *iPtr;
u8 *Ptr=(u8*)LayerHdr;
u8 *RGB;
Type=LayerHdr->Type;
SubType=LayerHdr->SubType;
@ -24,32 +24,37 @@ u8 *RGB;
iPtr=(int*)(Ptr+sizeof(sExpLayerHdr));
Count=*iPtr++;
List.resize(LAYER_SHADE_RGB_MAX);
for (int i=0; i<LAYER_SHADE_RGB_MAX; i++)
ShadeHdr.BandCount=*iPtr++;
sRGBCol *RGB=(sRGBCol*)iPtr;
for (i=0; i<LAYER_SHADE_RGB_MAX; i++)
{
List[i].Pos=*iPtr++;
RGB=(u8*)(iPtr);
List[i].RGB[0]=RGB[0];
List[i].RGB[1]=RGB[1];
List[i].RGB[2]=RGB[2];
iPtr+=4/sizeof(int);
ShadeHdr.RGB[i][0]=RGB->R;
ShadeHdr.RGB[i][1]=RGB->G;
ShadeHdr.RGB[i][2]=RGB->B;
RGB++;
}
Trans[0]=*iPtr++;
Flags[0]=*iPtr++;
Trans[1]=*iPtr++;
Flags[1]=*iPtr++;
iPtr=(int*)RGB;
// Load back gfx
char *c=(char*)iPtr;
BackGfx[0]=c;
c+=strlen(c)+1;
BackGfx[1]=c;
ListSize=*iPtr++;
GfxList.resize(ListSize);
sLayerShadeGfx *GfxPtr=(sLayerShadeGfx*)iPtr;
for (i=0; i<ListSize; i++)
{
GfxList[i]=*GfxPtr++;
}
iPtr=(int*)GfxPtr;
ListSize=*iPtr++;
TypeNameList.resize(ListSize);
char *TypePtr=(char*)iPtr;
for (i=0; i<ListSize; i++)
{
TypeNameList[i]=TypePtr;
TypePtr+=strlen(TypePtr)+1;
}
}
/*****************************************************************************/
/*****************************************************************************/
/*** Pre-Process *************************************************************/
@ -58,40 +63,29 @@ char *c=(char*)iPtr;
// Build unique tiles, including pre-genned flips, and replace tile idx with new one
void CMkLevelLayerShade::PreProcess(CMkLevel *Core)
{
GString Path=Core->GetConfigStr("MISC","BackGfxDir");
int i,ListSize=GfxList.size();
int Idx;
GString Path=Core->GetConfigStr("MISC","BackGfxDir");
CTexGrab &TexGrab=Core->GetTexGrab();
for (int i=0; i<2; i++)
{
if (!BackGfx[i].Empty())
for (i=0; i<ListSize; i++)
{
TexID[i]=AddBackGfx(Core,Path+BackGfx[i]+".Bmp");
}
else
{
TexID[i]=-1;
}
}
}
sLayerShadeGfx &ThisGfx=GfxList[i];
sBackGfxList NewType;
NewType.Name=Path+TypeNameList[ThisGfx.Gfx]+".Bmp";
Idx=OutTypeList.Find(NewType);
/*****************************************************************************/
int CMkLevelLayerShade::AddBackGfx(CMkLevel *Core,const char *Filename)
{
sBackGfxList NewGfx;
CTexGrab &TexGrab=Core->GetTexGrab();
NewGfx.Name=Filename;
NewGfx.TexID=-1;
int Idx=BackGfxList.Add(NewGfx);
if (BackGfxList[Idx].TexID==-1)
if (Idx==-1)
{
TexGrab.ZeroColZero(true);
BackGfxList[Idx].TexID=TexGrab.AddFile(BackGfxList[Idx].Name);
NewType.TexID=TexGrab.AddFile(NewType.Name);
TexGrab.ZeroColZero(false);
Idx=OutTypeList.Add(NewType);
}
return(BackGfxList[Idx].TexID);
ThisGfx.Gfx=Idx;
}
}
@ -102,30 +96,24 @@ int Idx=BackGfxList.Add(NewGfx);
/*****************************************************************************/
void CMkLevelLayerShade::Process(CMkLevel *Core)
{
int i,ListSize=OutTypeList.size();
CTexGrab &TexGrab=Core->GetTexGrab();
//printf("Process Shade Layer\n");
for (int i=0; i<2; i++)
for (i=0; i<ListSize; i++)
{
sLayerShadeGfx &ThisGfx=Data.BackGfx[i];
if (TexID[i]==-1)
{
ThisGfx.TPage=0;
}
else
{
sTexOutInfo &ThisTex=TexGrab.GetTexInfo()[TexID[i]];
ThisGfx.TPage=ThisTex.Tpage;
ThisGfx.Clut=ThisTex.Clut;
ThisGfx.U=ThisTex.u;
ThisGfx.V=ThisTex.v;
ThisGfx.W=ThisTex.w;
ThisGfx.H=ThisTex.h;
ThisGfx.TPage|=Trans[i]<<5;
ThisGfx.Flags=Flags[i];
}
sBackGfxList &ThisType=OutTypeList[i];
sTexOutInfo &ThisTex=TexGrab.GetTexInfo()[ThisType.TexID];
ThisType.Out.TPage=ThisTex.Tpage;
ThisType.Out.Clut=ThisTex.Clut;
ThisType.Out.U=ThisTex.u;
ThisType.Out.V=ThisTex.v;
ThisType.Out.W=ThisTex.w;
ThisType.Out.H=ThisTex.h;
// ThisType.TPage|=Trans[i]<<5;
}
}
/*****************************************************************************/
@ -144,19 +132,57 @@ int ThisPos=ftell(File);
Hdr.Height=Height;
fwrite(&Hdr,sizeof(sLayerHdr),1,File);
Data.Count=Count;
for (int i=0; i<Count; i++)
{
Data.Data[i].Ofs=List[i].Pos;
Data.Data[i].RGB[0]=List[i].RGB[0];
Data.Data[i].RGB[1]=List[i].RGB[1];
Data.Data[i].RGB[2]=List[i].RGB[2];
}
// Write Gfx Stuff
ShadeHdr.TypeList=(sLayerShadeBackGfxType*)WriteTypeList(File);
ShadeHdr.GfxList=(sLayerShadeBackGfx*)WriteGfxList(File);
fwrite(&Data,sizeof(sLayerShadeHdr),1,File);
fwrite(&ShadeHdr,sizeof(sLayerShadeHdr),1,File);
PadFile(File);
return(ThisPos);
}
/*****************************************************************************/
int CMkLevelLayerShade::WriteTypeList(FILE *File)
{
int Pos=ftell(File);
int i,ListSize=OutTypeList.size();
for (i=0; i<ListSize; i++)
{
sBackGfxList &ThisType=OutTypeList[i];
fwrite(&ThisType.Out,sizeof(sLayerShadeBackGfxType),1,File);
}
return(Pos);
}
/*****************************************************************************/
int CMkLevelLayerShade::WriteGfxList(FILE *File)
{
int Pos=ftell(File);
int i,ListSize=GfxList.size();
ShadeHdr.GfxCount=GfxList.size();
for (i=0; i<ListSize; i++)
{
sLayerShadeGfx &ThisGfx=GfxList[i];
sLayerShadeBackGfx Out;
Out.Type=ThisGfx.Gfx;
Out.PosX=ThisGfx.Pos.x;
Out.PosY=ThisGfx.Pos.y;
Out.Trans=ThisGfx.TransMode;
for (int p=0; p<4; p++)
{
Out.Ofs[i][0]=ThisGfx.Ofs[i].x;
Out.Ofs[i][1]=ThisGfx.Ofs[i].y;
Out.RGB[i][0]=ThisGfx.RGB[i].R;
Out.RGB[i][1]=ThisGfx.RGB[i].G;
Out.RGB[i][2]=ThisGfx.RGB[i].B;
}
}
return(Pos);
}

View file

@ -8,18 +8,12 @@
#include "MkLevelLayer.h"
#include <List2d.h>
/*****************************************************************************/
struct SMkLayerShadeRGB
{
int Pos;
u8 RGB[3];
};
/*****************************************************************************/
struct sBackGfxList
{
GString Name;
int TexID;
GString Name;
int TexID;
sLayerShadeBackGfxType Out;
bool operator ==(sBackGfxList const &v1) {return(Name==v1.Name);}
};
@ -33,18 +27,16 @@ public:
void PreProcess(CMkLevel *Core);
void Process(CMkLevel *Core);
int Write(FILE *File,const char *LayerName,const char *MapName);
int AddBackGfx(CMkLevel *Core,const char *Filename);
protected:
int Count;
vector<SMkLayerShadeRGB> List;
GString BackGfx[2];
int Flags[2];
int Trans[2];
int WriteTypeList(FILE *File);
int WriteGfxList(FILE *File);
CList<sBackGfxList> BackGfxList;
int TexID[2];
sLayerShadeHdr Data;
CList<GString> TypeNameList;
CList<sLayerShadeGfx> GfxList;
CList<sBackGfxList> OutTypeList;
sLayerShadeHdr ShadeHdr;
};
/*****************************************************************************/

View file

@ -52,8 +52,8 @@ int i,ListSize=ThingList.size();
OutThing.Type=ThisThing.Type;
OutThing.Pos.X=ThisThing.XY[0].x;
OutThing.Pos.Y=ThisThing.XY[0].y;
OutThing.Width=ThisThing.Data.Width;
OutThing.Height=ThisThing.Data.Height;
OutThing.Width=ThisThing.Data.Trigger.TriggerWidth;
OutThing.Height=ThisThing.Data.Trigger.TriggerHeight;
fwrite(&OutThing,sizeof(sThingTrigger),1,File);
}

View file

@ -23,6 +23,7 @@
#include "Layers\MkLevelLayerPlatform.h"
#include "Layers\MkLevelLayerFX.h"
#include "Layers\MkLevelLayerTrigger.h"
#include "Layers\MkLevelLayerHazard.h"
//***************************************************************************
const GString ConfigFilename="MkLevel.ini";
@ -172,12 +173,12 @@ int ChildCount=ThisNode.GetPruneChildCount();
}
//***************************************************************************
int CMkLevel::AddModel(sMkLevelLayerThing &ThisThing)
int CMkLevel::AddModel(const char *Name,int TriStart,int TriCount)
{
sMkLevelModel ThisModel;
int Idx;
ThisModel.Name=ThisThing.Name;
ThisModel.Name=Name;
Idx=ModelList.Find(ThisModel);
if (Idx!=-1)
@ -186,13 +187,13 @@ int Idx;
}
Idx=ModelList.size();
ThisModel.TriStart=ModelFaceList.GetFaceCount();
ThisModel.TriCount=ThisThing.Data.TriCount;
ThisModel.TriCount=TriCount;
// Add tri data
for (int i=0;i<ThisModel.TriCount; i++)
for (int i=0;i<TriCount; i++)
{
sExpTri &ThisTri=InTriList[ThisThing.Data.TriStart+i];
sExpTri &ThisTri=InTriList[TriStart+i];
CFace F;
ExpTri2Face(ThisTri,F);
@ -371,6 +372,9 @@ u8 *ByteHdr=(u8*)FileHdr;
case LAYER_TYPE_FX:
LayerList.push_back(new CMkLevelLayerFX(LayerHdr));
break;
case LAYER_TYPE_HAZARD:
LayerList.push_back(new CMkLevelLayerHazard(LayerHdr));
break;
default:
GObject::Error(ERR_FATAL,"Unknown Layer Type\n");
}
@ -997,6 +1001,7 @@ void CMkLevel::WriteLayers()
LevelHdr.PlatformList=WriteThings(LAYER_TYPE_PLATFORM,"Platform List");
LevelHdr.TriggerList=WriteThings(LAYER_TYPE_TRIGGER,"Trigger List");
LevelHdr.FXList=WriteThings(LAYER_TYPE_FX,"FX List");
LevelHdr.HazardList=WriteThings(LAYER_TYPE_HAZARD,"Hazard List");
LevelHdr.ModelList=(sModel*)WriteModelList();
}

View file

@ -60,7 +60,8 @@ public:
void LoadModels();
int AddModel(GString &Filename);
int AddModel(sMkLevelLayerThing &ThisThing);
int AddModel(const char *Name,int TriStart,int TriCount);
void Load();
void Process();