mirror of
https://github.com/ZDoom/ZDRay.git
synced 2024-11-22 20:11:11 +00:00
- remove unused stuff
This commit is contained in:
parent
5399e988c7
commit
7efc998f6e
8 changed files with 9 additions and 552 deletions
|
@ -149,7 +149,6 @@ set( SOURCES
|
||||||
src/lightmap/mapdata.cpp
|
src/lightmap/mapdata.cpp
|
||||||
src/lightmap/surfaces.cpp
|
src/lightmap/surfaces.cpp
|
||||||
src/lightmap/trace.cpp
|
src/lightmap/trace.cpp
|
||||||
src/lightmap/wad.cpp
|
|
||||||
src/lightmap/worker.cpp
|
src/lightmap/worker.cpp
|
||||||
src/lightmap/collision.cpp
|
src/lightmap/collision.cpp
|
||||||
src/lightmap/halffloat.cpp
|
src/lightmap/halffloat.cpp
|
||||||
|
@ -192,7 +191,6 @@ set( HEADERS
|
||||||
src/lightmap/mapdata.h
|
src/lightmap/mapdata.h
|
||||||
src/lightmap/surfaces.h
|
src/lightmap/surfaces.h
|
||||||
src/lightmap/trace.h
|
src/lightmap/trace.h
|
||||||
src/lightmap/wad.h
|
|
||||||
src/lightmap/worker.h
|
src/lightmap/worker.h
|
||||||
src/lightmap/collision.h
|
src/lightmap/collision.h
|
||||||
src/lightmap/halffloat.h
|
src/lightmap/halffloat.h
|
||||||
|
|
|
@ -617,7 +617,7 @@ void FProcessor::BuildLightmaps()
|
||||||
LMBuilder.textureHeight = LMDims;
|
LMBuilder.textureHeight = LMDims;
|
||||||
|
|
||||||
Level.SetupDlight();
|
Level.SetupDlight();
|
||||||
Surface_AllocateFromMap(Level);
|
CreateSurfaces(Level);
|
||||||
Level.CreateLights();
|
Level.CreateLights();
|
||||||
|
|
||||||
LMBuilder.CreateLightmaps(Level);
|
LMBuilder.CreateLightmaps(Level);
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
#include "lightmap.h"
|
#include "lightmap.h"
|
||||||
#include "worker.h"
|
#include "worker.h"
|
||||||
#include "kexlib/binfile.h"
|
#include "kexlib/binfile.h"
|
||||||
#include "wad.h"
|
|
||||||
#include "framework/templates.h"
|
#include "framework/templates.h"
|
||||||
#include "halffloat.h"
|
#include "halffloat.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -855,53 +854,3 @@ void kexLightmapBuilder::WriteMeshToOBJ()
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// kexLightmapBuilder::ExportTexelsToObjFile
|
|
||||||
//
|
|
||||||
|
|
||||||
void kexLightmapBuilder::ExportTexelsToObjFile(FILE *f, const kexVec3 &org, int indices)
|
|
||||||
{
|
|
||||||
#define BLOCK(idx, offs) (org[idx] + offs)/256.0f
|
|
||||||
fprintf(f, "o texel_%03d\n", indices);
|
|
||||||
fprintf(f, "v %f %f %f\n", -BLOCK(1, -6), BLOCK(2, -6), -BLOCK(0, 6));
|
|
||||||
fprintf(f, "v %f %f %f\n", -BLOCK(1, -6), BLOCK(2, 6), -BLOCK(0, 6));
|
|
||||||
fprintf(f, "v %f %f %f\n", -BLOCK(1, -6), BLOCK(2, 6), -BLOCK(0, -6));
|
|
||||||
fprintf(f, "v %f %f %f\n", -BLOCK(1, -6), BLOCK(2, -6), -BLOCK(0, -6));
|
|
||||||
fprintf(f, "v %f %f %f\n", -BLOCK(1, 6), BLOCK(2, -6), -BLOCK(0, 6));
|
|
||||||
fprintf(f, "v %f %f %f\n", -BLOCK(1, 6), BLOCK(2, 6), -BLOCK(0, 6));
|
|
||||||
fprintf(f, "v %f %f %f\n", -BLOCK(1, 6), BLOCK(2, 6), -BLOCK(0, -6));
|
|
||||||
fprintf(f, "v %f %f %f\n", -BLOCK(1, 6), BLOCK(2, -6), -BLOCK(0, -6));
|
|
||||||
fprintf(f, "f %i %i %i %i\n", indices+1, indices+2, indices+3, indices+4);
|
|
||||||
fprintf(f, "f %i %i %i %i\n", indices+5, indices+8, indices+7, indices+6);
|
|
||||||
fprintf(f, "f %i %i %i %i\n", indices+1, indices+5, indices+6, indices+2);
|
|
||||||
fprintf(f, "f %i %i %i %i\n", indices+2, indices+6, indices+7, indices+3);
|
|
||||||
fprintf(f, "f %i %i %i %i\n", indices+3, indices+7, indices+8, indices+4);
|
|
||||||
fprintf(f, "f %i %i %i %i\n\n", indices+5, indices+1, indices+4, indices+8);
|
|
||||||
#undef BLOCK
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// kexLightmapBuilder::WriteBlock
|
|
||||||
//
|
|
||||||
|
|
||||||
void kexLightmapBuilder::WriteBlock(FILE *f, const int i, const kexVec3 &org, int indices, kexBBox &box)
|
|
||||||
{
|
|
||||||
#define BLOCK(idx, offs) (org[idx] + box[offs][idx])/256.0f
|
|
||||||
fprintf(f, "o texel_%03d\n", i);
|
|
||||||
fprintf(f, "v %f %f %f\n", -BLOCK(1, 0), BLOCK(2, 0), -BLOCK(0, 1));
|
|
||||||
fprintf(f, "v %f %f %f\n", -BLOCK(1, 0), BLOCK(2, 1), -BLOCK(0, 1));
|
|
||||||
fprintf(f, "v %f %f %f\n", -BLOCK(1, 0), BLOCK(2, 1), -BLOCK(0, 0));
|
|
||||||
fprintf(f, "v %f %f %f\n", -BLOCK(1, 0), BLOCK(2, 0), -BLOCK(0, 0));
|
|
||||||
fprintf(f, "v %f %f %f\n", -BLOCK(1, 1), BLOCK(2, 0), -BLOCK(0, 1));
|
|
||||||
fprintf(f, "v %f %f %f\n", -BLOCK(1, 1), BLOCK(2, 1), -BLOCK(0, 1));
|
|
||||||
fprintf(f, "v %f %f %f\n", -BLOCK(1, 1), BLOCK(2, 1), -BLOCK(0, 0));
|
|
||||||
fprintf(f, "v %f %f %f\n", -BLOCK(1, 1), BLOCK(2, 0), -BLOCK(0, 0));
|
|
||||||
fprintf(f, "f %i %i %i %i\n", indices+1, indices+2, indices+3, indices+4);
|
|
||||||
fprintf(f, "f %i %i %i %i\n", indices+5, indices+8, indices+7, indices+6);
|
|
||||||
fprintf(f, "f %i %i %i %i\n", indices+1, indices+5, indices+6, indices+2);
|
|
||||||
fprintf(f, "f %i %i %i %i\n", indices+2, indices+6, indices+7, indices+3);
|
|
||||||
fprintf(f, "f %i %i %i %i\n", indices+3, indices+7, indices+8, indices+4);
|
|
||||||
fprintf(f, "f %i %i %i %i\n\n", indices+5, indices+1, indices+4, indices+8);
|
|
||||||
#undef BLOCK
|
|
||||||
}
|
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "wad.h"
|
|
||||||
#include "mapdata.h"
|
#include "mapdata.h"
|
||||||
#include "lightsurface.h"
|
#include "lightsurface.h"
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
kexArray<surface_t*> surfaces;
|
kexArray<surface_t*> surfaces;
|
||||||
|
|
||||||
static void Surface_AllocateFromSide(FLevel &doomMap, IntSideDef *side)
|
static void CreateSideSurfaces(FLevel &doomMap, IntSideDef *side)
|
||||||
{
|
{
|
||||||
surface_t *surf;
|
surface_t *surf;
|
||||||
IntSector *front;
|
IntSector *front;
|
||||||
|
@ -172,7 +172,7 @@ static void Surface_AllocateFromSide(FLevel &doomMap, IntSideDef *side)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Surface_AllocateFromLeaf(FLevel &doomMap)
|
static void CreateSubsectorSurfaces(FLevel &doomMap)
|
||||||
{
|
{
|
||||||
surface_t *surf;
|
surface_t *surf;
|
||||||
IntSector *sector = NULL;
|
IntSector *sector = NULL;
|
||||||
|
@ -198,7 +198,7 @@ static void Surface_AllocateFromLeaf(FLevel &doomMap)
|
||||||
// sector hacks
|
// sector hacks
|
||||||
if(sector == NULL)
|
if(sector == NULL)
|
||||||
{
|
{
|
||||||
Error("Surface_AllocateFromLeaf: subsector %i has no sector\n", i);
|
Error("CreateSubsectorSurfaces: subsector %i has no sector\n", i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ static bool IsDegenerate(const kexVec3 &v0, const kexVec3 &v1, const kexVec3 &v2
|
||||||
return crosslengthsqr <= 1.e-6f;
|
return crosslengthsqr <= 1.e-6f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Surface_AllocateFromMap(FLevel &doomMap)
|
void CreateSurfaces(FLevel &doomMap)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < surfaces.Length(); i++)
|
for (unsigned int i = 0; i < surfaces.Length(); i++)
|
||||||
Mem_Free(surfaces[i]);
|
Mem_Free(surfaces[i]);
|
||||||
|
@ -313,17 +313,17 @@ void Surface_AllocateFromMap(FLevel &doomMap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("------------- Building seg surfaces -------------\n");
|
printf("------------- Building side surfaces -------------\n");
|
||||||
|
|
||||||
for(unsigned int i = 0; i < doomMap.Sides.Size(); i++)
|
for(unsigned int i = 0; i < doomMap.Sides.Size(); i++)
|
||||||
{
|
{
|
||||||
Surface_AllocateFromSide(doomMap, &doomMap.Sides[i]);
|
CreateSideSurfaces(doomMap, &doomMap.Sides[i]);
|
||||||
printf("sides: %i / %i\r", i+1, doomMap.Sides.Size());
|
printf("sides: %i / %i\r", i+1, doomMap.Sides.Size());
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\nSide surfaces: %i\n", surfaces.Length());
|
printf("\nSide surfaces: %i\n", surfaces.Length());
|
||||||
|
|
||||||
Surface_AllocateFromLeaf(doomMap);
|
CreateSubsectorSurfaces(doomMap);
|
||||||
|
|
||||||
printf("Surfaces total: %i\n\n", surfaces.Length());
|
printf("Surfaces total: %i\n\n", surfaces.Length());
|
||||||
|
|
||||||
|
|
|
@ -59,13 +59,11 @@ struct surface_t
|
||||||
float *lightmapCoords;
|
float *lightmapCoords;
|
||||||
surfaceType_t type;
|
surfaceType_t type;
|
||||||
int typeIndex;
|
int typeIndex;
|
||||||
//void *data;
|
|
||||||
bool bSky;
|
bool bSky;
|
||||||
//MapSubsectorEx *subSector;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern kexArray<surface_t*> surfaces;
|
extern kexArray<surface_t*> surfaces;
|
||||||
|
|
||||||
struct FLevel;
|
struct FLevel;
|
||||||
|
|
||||||
void Surface_AllocateFromMap(FLevel &doomMap);
|
void CreateSurfaces(FLevel &doomMap);
|
||||||
|
|
|
@ -1,326 +0,0 @@
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Note: this is a modified version of dlight. It is not the original software.
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (c) 2013-2014 Samuel Villarreal
|
|
||||||
// svkaiser@gmail.com
|
|
||||||
//
|
|
||||||
// This software is provided 'as-is', without any express or implied
|
|
||||||
// warranty. In no event will the authors be held liable for any damages
|
|
||||||
// arising from the use of this software.
|
|
||||||
//
|
|
||||||
// Permission is granted to anyone to use this software for any purpose,
|
|
||||||
// including commercial applications, and to alter it and redistribute it
|
|
||||||
// freely, subject to the following restrictions:
|
|
||||||
//
|
|
||||||
// 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
// claim that you wrote the original software. If you use this software
|
|
||||||
// in a product, an acknowledgment in the product documentation would be
|
|
||||||
// appreciated but is not required.
|
|
||||||
//
|
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
// misrepresented as being the original software.
|
|
||||||
//
|
|
||||||
// 3. This notice may not be removed or altered from any source
|
|
||||||
// distribution.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// DESCRIPTION: General wad loading mechanics
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "common.h"
|
|
||||||
#include "wad.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// kexWadFile::~kexWadFile
|
|
||||||
//
|
|
||||||
|
|
||||||
kexWadFile::~kexWadFile()
|
|
||||||
{
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// kexWadFile::Open
|
|
||||||
//
|
|
||||||
|
|
||||||
bool kexWadFile::Open(const char *fileName)
|
|
||||||
{
|
|
||||||
if(!file.Open(fileName))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(&header, file.Buffer(), sizeof(wadHeader_t));
|
|
||||||
lumps = (lump_t*)file.GetOffset(2);
|
|
||||||
wadName = fileName;
|
|
||||||
bWriting = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// kexWadFile::Write
|
|
||||||
//
|
|
||||||
|
|
||||||
void kexWadFile::Write(const char *fileName)
|
|
||||||
{
|
|
||||||
assert(bWriting == true);
|
|
||||||
|
|
||||||
file.Create(fileName);
|
|
||||||
file.Write8(header.id[0]);
|
|
||||||
file.Write8(header.id[1]);
|
|
||||||
file.Write8(header.id[2]);
|
|
||||||
file.Write8(header.id[3]);
|
|
||||||
file.Write32(header.lmpcount);
|
|
||||||
file.Write32(header.lmpdirpos);
|
|
||||||
|
|
||||||
for(unsigned int i = 0; i < writeLumpList.Length(); i++)
|
|
||||||
{
|
|
||||||
byte *data = writeDataList[i];
|
|
||||||
|
|
||||||
if(!data)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int j = 0; j < writeLumpList[i].size; j++)
|
|
||||||
{
|
|
||||||
file.Write8(data[j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(unsigned int i = 0; i < writeLumpList.Length(); i++)
|
|
||||||
{
|
|
||||||
file.Write32(writeLumpList[i].filepos);
|
|
||||||
file.Write32(writeLumpList[i].size);
|
|
||||||
for(int j = 0; j < 8; j++)
|
|
||||||
{
|
|
||||||
file.Write8(writeLumpList[i].name[j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// kexWadFile::Close
|
|
||||||
//
|
|
||||||
|
|
||||||
void kexWadFile::Close()
|
|
||||||
{
|
|
||||||
if(file.Opened())
|
|
||||||
{
|
|
||||||
file.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// kexWadFile::GetLumpFromName
|
|
||||||
//
|
|
||||||
|
|
||||||
lump_t *kexWadFile::GetLumpFromName(const char *name)
|
|
||||||
{
|
|
||||||
char n[9];
|
|
||||||
|
|
||||||
for(int i = 0; i < header.lmpcount; i++)
|
|
||||||
{
|
|
||||||
// could be optimized here but I really don't feel like
|
|
||||||
// wasting time on this
|
|
||||||
strncpy(n, lumps[i].name, 8);
|
|
||||||
n[8] = 0;
|
|
||||||
|
|
||||||
if(!strncmp(n, name, 8))
|
|
||||||
{
|
|
||||||
return &lumps[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// kexWadFile::GetLumpData
|
|
||||||
//
|
|
||||||
|
|
||||||
byte *kexWadFile::GetLumpData(const lump_t *lump)
|
|
||||||
{
|
|
||||||
file.SetOffset(lump->filepos);
|
|
||||||
return &file.Buffer()[lump->filepos];
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// kexWadFile::GetLumpData
|
|
||||||
//
|
|
||||||
|
|
||||||
byte *kexWadFile::GetLumpData(const char *name)
|
|
||||||
{
|
|
||||||
lump_t *lump = GetLumpFromName(name);
|
|
||||||
|
|
||||||
if(!lump)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
file.SetOffset(lump->filepos);
|
|
||||||
return &file.Buffer()[lump->filepos];
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// kexWadFile::SetCurrentMap
|
|
||||||
//
|
|
||||||
|
|
||||||
void kexWadFile::SetCurrentMap(const int map)
|
|
||||||
{
|
|
||||||
lump_t *lump = GetLumpFromName(Va("MAP%02d", map));
|
|
||||||
|
|
||||||
if(lump == NULL)
|
|
||||||
{
|
|
||||||
Error("kexWadFile::SetCurrentMap: MAP%02d not found\n", map);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mapLumpID = lump - lumps;
|
|
||||||
|
|
||||||
lump = GetLumpFromName(Va("GL_MAP%02d", map));
|
|
||||||
|
|
||||||
if(lump == NULL)
|
|
||||||
{
|
|
||||||
Error("kexWadFile::SetCurrentMap: GL_MAP%02d not found\n", map);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
glMapLumpID = lump - lumps;
|
|
||||||
currentmap = map;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// kexWadFile::GetMapLump
|
|
||||||
//
|
|
||||||
|
|
||||||
lump_t *kexWadFile::GetMapLump(mapLumps_t lumpID)
|
|
||||||
{
|
|
||||||
if(mapLumpID + lumpID >= header.lmpcount)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return &lumps[mapLumpID + lumpID];
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// kexWadFile::GetGLMapLump
|
|
||||||
//
|
|
||||||
|
|
||||||
lump_t *kexWadFile::GetGLMapLump(glMapLumps_t lumpID)
|
|
||||||
{
|
|
||||||
if(glMapLumpID + lumpID >= header.lmpcount)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return &lumps[glMapLumpID + lumpID];
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// kexWadFile::InitForWrite
|
|
||||||
//
|
|
||||||
|
|
||||||
void kexWadFile::InitForWrite()
|
|
||||||
{
|
|
||||||
header.id[0] = 'P';
|
|
||||||
header.id[1] = 'W';
|
|
||||||
header.id[2] = 'A';
|
|
||||||
header.id[3] = 'D';
|
|
||||||
|
|
||||||
writePos = sizeof(wadHeader_t);
|
|
||||||
bWriting = true;
|
|
||||||
|
|
||||||
header.lmpcount = 0;
|
|
||||||
header.lmpdirpos = writePos;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// kexWadFile::CopyLumpsFromWadFile
|
|
||||||
//
|
|
||||||
|
|
||||||
void kexWadFile::CopyLumpsFromWadFile(kexWadFile &wadFile)
|
|
||||||
{
|
|
||||||
lump_t lump;
|
|
||||||
|
|
||||||
assert(bWriting == true);
|
|
||||||
|
|
||||||
for(int i = 0; i < wadFile.header.lmpcount; ++i)
|
|
||||||
{
|
|
||||||
lump = wadFile.lumps[i];
|
|
||||||
AddLump(wadFile.lumps[i].name, lump.size, &wadFile.file.Buffer()[lump.filepos]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// kexWadFile::CopyLumpsFromWadFile
|
|
||||||
//
|
|
||||||
|
|
||||||
void kexWadFile::CopyLumpsFromWadFile(kexWadFile &wadFile, kexArray<int> &lumpIgnoreList)
|
|
||||||
{
|
|
||||||
lump_t lump;
|
|
||||||
unsigned int j;
|
|
||||||
bool bSkip;
|
|
||||||
|
|
||||||
assert(bWriting == true);
|
|
||||||
|
|
||||||
for(int i = 0; i < wadFile.header.lmpcount; ++i)
|
|
||||||
{
|
|
||||||
lump = wadFile.lumps[i];
|
|
||||||
bSkip = false;
|
|
||||||
|
|
||||||
for(j = 0; j < lumpIgnoreList.Length(); ++j)
|
|
||||||
{
|
|
||||||
if(lumpIgnoreList[j] == i)
|
|
||||||
{
|
|
||||||
bSkip = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(bSkip)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
AddLump(wadFile.lumps[i].name, lump.size, &wadFile.file.Buffer()[lump.filepos]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// kexWadFile::AddLump
|
|
||||||
//
|
|
||||||
|
|
||||||
void kexWadFile::AddLump(const char *name, const int size, byte *data)
|
|
||||||
{
|
|
||||||
lump_t lump;
|
|
||||||
|
|
||||||
assert(bWriting == true);
|
|
||||||
|
|
||||||
lump.filepos = writePos;
|
|
||||||
lump.size = size;
|
|
||||||
strncpy(lump.name, name, 8);
|
|
||||||
|
|
||||||
writeLumpList.Push(lump);
|
|
||||||
writeDataList.Push(data);
|
|
||||||
|
|
||||||
header.lmpcount++;
|
|
||||||
header.lmpdirpos += lump.size;
|
|
||||||
writePos += lump.size;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// kexWadFile::CreateBackup
|
|
||||||
//
|
|
||||||
|
|
||||||
void kexWadFile::CreateBackup()
|
|
||||||
{
|
|
||||||
kexStr backupName = wadName;
|
|
||||||
|
|
||||||
backupName.StripExtension();
|
|
||||||
file.Duplicate(backupName + ".wad.bak");
|
|
||||||
}
|
|
|
@ -1,161 +0,0 @@
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Note: this is a modified version of dlight. It is not the original software.
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (c) 2013-2014 Samuel Villarreal
|
|
||||||
// svkaiser@gmail.com
|
|
||||||
//
|
|
||||||
// This software is provided 'as-is', without any express or implied
|
|
||||||
// warranty. In no event will the authors be held liable for any damages
|
|
||||||
// arising from the use of this software.
|
|
||||||
//
|
|
||||||
// Permission is granted to anyone to use this software for any purpose,
|
|
||||||
// including commercial applications, and to alter it and redistribute it
|
|
||||||
// freely, subject to the following restrictions:
|
|
||||||
//
|
|
||||||
// 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
// claim that you wrote the original software. If you use this software
|
|
||||||
// in a product, an acknowledgment in the product documentation would be
|
|
||||||
// appreciated but is not required.
|
|
||||||
//
|
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
// misrepresented as being the original software.
|
|
||||||
//
|
|
||||||
// 3. This notice may not be removed or altered from any source
|
|
||||||
// distribution.
|
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "kexlib/binfile.h"
|
|
||||||
|
|
||||||
enum mapLumps_t
|
|
||||||
{
|
|
||||||
ML_HEADER = 0,
|
|
||||||
ML_THINGS,
|
|
||||||
ML_LINEDEFS,
|
|
||||||
ML_SIDEDEFS,
|
|
||||||
ML_VERTEXES,
|
|
||||||
ML_SEGS,
|
|
||||||
ML_SUBSECTORS,
|
|
||||||
ML_NODES,
|
|
||||||
ML_SECTORS,
|
|
||||||
ML_REJECT,
|
|
||||||
ML_BLOCKMAP,
|
|
||||||
ML_LIGHTMAP,
|
|
||||||
ML_NUMLUMPS
|
|
||||||
};
|
|
||||||
|
|
||||||
enum glMapLumps_t
|
|
||||||
{
|
|
||||||
ML_GL_LABEL = 0, // A separator name, GL_ExMx or GL_MAPxx
|
|
||||||
ML_GL_VERTS, // Extra Vertices
|
|
||||||
ML_GL_SEGS, // Segs, from linedefs & minisegs
|
|
||||||
ML_GL_SSECT, // SubSectors, list of segs
|
|
||||||
ML_GL_NODES, // GL BSP nodes
|
|
||||||
ML_GL_PVS // PVS portals
|
|
||||||
};
|
|
||||||
|
|
||||||
enum lmMapLumps_t
|
|
||||||
{
|
|
||||||
ML_LM_LABEL = 0,
|
|
||||||
ML_LM_CELLS,
|
|
||||||
ML_LM_SUN,
|
|
||||||
ML_LM_SURFS,
|
|
||||||
ML_LM_TXCRD,
|
|
||||||
ML_LM_LMAPS
|
|
||||||
};
|
|
||||||
|
|
||||||
#define gNd2 0x32644E67
|
|
||||||
|
|
||||||
#define GL_VERT_OFFSET 4
|
|
||||||
|
|
||||||
struct wadHeader_t
|
|
||||||
{
|
|
||||||
char id[4];
|
|
||||||
int lmpcount;
|
|
||||||
int lmpdirpos;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct lump_t
|
|
||||||
{
|
|
||||||
int filepos;
|
|
||||||
int size;
|
|
||||||
char name[8];
|
|
||||||
};
|
|
||||||
|
|
||||||
class kexWadFile
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
~kexWadFile();
|
|
||||||
|
|
||||||
wadHeader_t header;
|
|
||||||
lump_t *lumps;
|
|
||||||
unsigned int size;
|
|
||||||
int mapLumpID;
|
|
||||||
int glMapLumpID;
|
|
||||||
kexStr wadName;
|
|
||||||
int currentmap;
|
|
||||||
|
|
||||||
lump_t *GetLumpFromName(const char *name);
|
|
||||||
lump_t *GetMapLump(mapLumps_t lumpID);
|
|
||||||
lump_t *GetGLMapLump(glMapLumps_t lumpID);
|
|
||||||
byte *GetLumpData(const lump_t *lump);
|
|
||||||
byte *GetLumpData(const char *name);
|
|
||||||
void SetCurrentMap(const int map);
|
|
||||||
bool Open(const char *fileName);
|
|
||||||
void Write(const char *fileName);
|
|
||||||
void Close();
|
|
||||||
void CreateBackup();
|
|
||||||
void InitForWrite();
|
|
||||||
void CopyLumpsFromWadFile(kexWadFile &wadFile);
|
|
||||||
void CopyLumpsFromWadFile(kexWadFile &wadFile, kexArray<int> &lumpIgnoreList);
|
|
||||||
void AddLump(const char *name, const int size, byte *data);
|
|
||||||
|
|
||||||
template<typename type>
|
|
||||||
void GetMapLump(mapLumps_t lumpID, type **ptr, int *count)
|
|
||||||
{
|
|
||||||
if(mapLumpID + lumpID >= header.lmpcount)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
lump_t *lump = GetMapLump(lumpID);
|
|
||||||
if(lump == NULL || lump->size == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*ptr = (type*)GetLumpData(lump);
|
|
||||||
|
|
||||||
if(count)
|
|
||||||
{
|
|
||||||
*count = lump->size / sizeof(type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename type>
|
|
||||||
void GetGLMapLump(glMapLumps_t lumpID, type **ptr, int *count)
|
|
||||||
{
|
|
||||||
if(glMapLumpID + lumpID >= header.lmpcount)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
lump_t *lump = GetGLMapLump(lumpID);
|
|
||||||
if(lump == NULL || lump->size == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*ptr = (type*)GetLumpData(lump);
|
|
||||||
|
|
||||||
if(count)
|
|
||||||
{
|
|
||||||
*count = lump->size / sizeof(type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
kexBinFile file;
|
|
||||||
bool bWriting;
|
|
||||||
int writePos;
|
|
||||||
kexArray<lump_t> writeLumpList;
|
|
||||||
kexArray<byte*> writeDataList;
|
|
||||||
};
|
|
Loading…
Reference in a new issue