- reformat files

This commit is contained in:
Magnus Norddahl 2018-11-02 23:17:46 +01:00
parent 8eee053896
commit b588b809ea
25 changed files with 3375 additions and 3705 deletions

View file

@ -61,27 +61,18 @@ protected:
unsigned int aidx;
};
//
// kexArray::kexArray
//
template<class type>
kexArray<type>::kexArray()
{
Init();
}
//
// kexArray::~kexArray
//
template<class type>
kexArray<type>::~kexArray()
{
Empty();
}
//
// kexArray::Init
//
template<class type>
void kexArray<type>::Init()
{
@ -90,9 +81,6 @@ void kexArray<type>::Init()
aidx = 0;
}
//
// kexArray::Resize
//
template<class type>
void kexArray<type>::Resize(unsigned int size)
{
@ -130,9 +118,6 @@ void kexArray<type>::Resize(unsigned int size)
delete[] tmp;
}
//
// kexArray::Push
//
template<class type>
void kexArray<type>::Push(type o)
{
@ -140,9 +125,6 @@ void kexArray<type>::Push(type o)
data[aidx++] = o;
}
//
// kexArray::Pop
//
template<class type>
void kexArray<type>::Pop()
{
@ -155,9 +137,6 @@ void kexArray<type>::Pop()
aidx--;
}
//
// kexArray::Empty
//
template<class type>
void kexArray<type>::Empty()
{
@ -170,9 +149,6 @@ void kexArray<type>::Empty()
}
}
//
// kexArray::IndexOf
//
template<class type>
type kexArray<type>::IndexOf(unsigned int index) const
{
@ -184,9 +160,6 @@ type kexArray<type>::IndexOf(unsigned int index) const
return data[index];
}
//
// kexArray::Contains
//
template<class type>
bool kexArray<type>::Contains(const type check) const
{
@ -201,9 +174,6 @@ bool kexArray<type>::Contains(const type check) const
return false;
}
//
// kexArray::Splice
//
template<class type>
void kexArray<type>::Splice(const unsigned int start, unsigned int len)
{
@ -230,12 +200,7 @@ void kexArray<type>::Splice(const unsigned int start, unsigned int len)
aidx = length - 1;
}
//
// kexArray::Sort
//
// Note that data will be shuffled around, so this could invalidate any
// pointers that relies on the array/data
//
// Note that data will be shuffled around, so this could invalidate any pointers that relies on the array/data
template<class type>
void kexArray<type>::Sort(compare_t *function)
{
@ -250,12 +215,7 @@ void kexArray<type>::Sort(compare_t *function)
qsort((void*)data, length, sizeof(type), cmpFunc);
}
//
// kexArray::Sort
//
// Note that data will be shuffled around, so this could invalidate any
// pointers that relies on the array/data
//
// Note that data will be shuffled around, so this could invalidate any pointers that relies on the array/data
template<class type>
void kexArray<type>::Sort(compare_t *function, unsigned int count)
{
@ -270,9 +230,6 @@ void kexArray<type>::Sort(compare_t *function, unsigned int count)
qsort((void*)data, count, sizeof(type), cmpFunc);
}
//
// kexArray::operator[]
//
template <class type>
type &kexArray<type>::operator[](unsigned int index)
{
@ -280,9 +237,6 @@ type &kexArray<type>::operator[](unsigned int index)
return data[index];
}
//
// kexArray::operator=
//
template <class type>
kexArray<type> &kexArray<type>::operator=(const kexArray<type> &arr)
{

View file

@ -33,10 +33,6 @@
#include "lightmap/common.h"
#include "lightmap/kexlib/binfile.h"
//
// kexBinFile::kexBinFile
//
kexBinFile::kexBinFile()
{
this->handle = NULL;
@ -45,19 +41,11 @@ kexBinFile::kexBinFile()
this->bOpened = false;
}
//
// kexBinFile::~kexBinFile
//
kexBinFile::~kexBinFile()
{
Close();
}
//
// kexBinFile::Open
//
bool kexBinFile::Open(const char *file, kexHeapBlock &heapBlock)
{
if ((handle = fopen(file, "rb")))
@ -88,10 +76,6 @@ bool kexBinFile::Open(const char *file, kexHeapBlock &heapBlock)
return false;
}
//
// kexBinFile::Create
//
bool kexBinFile::Create(const char *file)
{
if ((handle = fopen(file, "wb")))
@ -104,10 +88,6 @@ bool kexBinFile::Create(const char *file)
return false;
}
//
// kexBinFile::Close
//
void kexBinFile::Close()
{
if (bOpened == false)
@ -127,10 +107,6 @@ void kexBinFile::Close()
bOpened = false;
}
//
// kexBinFile::Exists
//
bool kexBinFile::Exists(const char *file)
{
FILE *fstream;
@ -157,10 +133,6 @@ bool kexBinFile::Exists(const char *file)
return false;
}
//
// kexBinFile::Duplicate
//
void kexBinFile::Duplicate(const char *newFileName)
{
FILE *f;
@ -181,10 +153,6 @@ void kexBinFile::Duplicate(const char *newFileName)
fclose(f);
}
//
// kexBinFile::Length
//
int kexBinFile::Length()
{
long savedpos;
@ -208,10 +176,6 @@ int kexBinFile::Length()
return length;
}
//
// kexBinFile::Read8
//
byte kexBinFile::Read8()
{
byte result;
@ -219,10 +183,6 @@ byte kexBinFile::Read8()
return result;
}
//
// kexBinFile::Read16
//
short kexBinFile::Read16()
{
int result;
@ -231,10 +191,6 @@ short kexBinFile::Read16()
return result;
}
//
// kexBinFile::Read32
//
int kexBinFile::Read32()
{
int result;
@ -245,10 +201,6 @@ int kexBinFile::Read32()
return result;
}
//
// kexBinFile::ReadFloat
//
float kexBinFile::ReadFloat()
{
fint_t fi;
@ -256,10 +208,6 @@ float kexBinFile::ReadFloat()
return fi.f;
}
//
// kexBinFile::ReadVector
//
kexVec3 kexBinFile::ReadVector()
{
kexVec3 vec;
@ -271,10 +219,6 @@ kexVec3 kexBinFile::ReadVector()
return vec;
}
//
// kexBinFile::ReadString
//
kexStr kexBinFile::ReadString()
{
kexStr str;
@ -293,10 +237,6 @@ kexStr kexBinFile::ReadString()
return str;
}
//
// kexBinFile::Write8
//
void kexBinFile::Write8(const byte val)
{
if (bOpened)
@ -310,20 +250,12 @@ void kexBinFile::Write8(const byte val)
bufferOffset++;
}
//
// kexBinFile::Write16
//
void kexBinFile::Write16(const short val)
{
Write8(val & 0xff);
Write8((val >> 8) & 0xff);
}
//
// kexBinFile::Write32
//
void kexBinFile::Write32(const int val)
{
Write8(val & 0xff);
@ -332,10 +264,6 @@ void kexBinFile::Write32(const int val)
Write8((val >> 24) & 0xff);
}
//
// kexBinFile::WriteFloat
//
void kexBinFile::WriteFloat(const float val)
{
fint_t fi;
@ -343,10 +271,6 @@ void kexBinFile::WriteFloat(const float val)
Write32(fi.i);
}
//
// kexBinFile::WriteVector
//
void kexBinFile::WriteVector(const kexVec3 &val)
{
WriteFloat(val.x);
@ -354,10 +278,6 @@ void kexBinFile::WriteVector(const kexVec3 &val)
WriteFloat(val.z);
}
//
// kexBinFile::WriteString
//
void kexBinFile::WriteString(const kexStr &val)
{
const char *c = val.c_str();
@ -370,19 +290,11 @@ void kexBinFile::WriteString(const kexStr &val)
Write8(0);
}
//
// kexBinFile::GetOffsetValue
//
int kexBinFile::GetOffsetValue(int id)
{
return *(int*)(buffer + (id << 2));
}
//
// kexBinFile::GetOffset
//
byte *kexBinFile::GetOffset(int id, byte *subdata, int *count)
{
byte *data = (subdata == NULL) ? buffer : subdata;

View file

@ -57,9 +57,7 @@ public:
void WriteString(const kexStr &val);
int GetOffsetValue(int id);
byte *GetOffset(int id,
byte *subdata = NULL,
int *count = NULL);
byte *GetOffset(int id, byte *subdata = NULL, int *count = NULL);
FILE *Handle() const { return handle; }
byte *Buffer() const { return buffer; }

View file

@ -33,10 +33,6 @@
#include <ctype.h>
#include "kstring.h"
//
// kexStr::Init
//
void kexStr::Init()
{
length = 0;
@ -45,10 +41,6 @@ void kexStr::Init()
charPtr[0] = '\0';
}
//
// kexStr::CheckSize
//
void kexStr::CheckSize(int size, bool bKeepString)
{
if (size <= bufferLength)
@ -59,10 +51,6 @@ void kexStr::CheckSize(int size, bool bKeepString)
Resize(size, bKeepString);
}
//
// kexStr::CopyNew
//
void kexStr::CopyNew(const char *string, int len)
{
CheckSize(len + 1, false);
@ -70,19 +58,11 @@ void kexStr::CopyNew(const char *string, int len)
length = len;
}
//
// kexStr::kexStr
//
kexStr::kexStr()
{
Init();
}
//
// kexStr::kexStr
//
kexStr::kexStr(const char *string)
{
Init();
@ -95,10 +75,6 @@ kexStr::kexStr(const char *string)
CopyNew(string, strlen(string));
}
//
// kexStr::kexStr
//
kexStr::kexStr(const char *string, const int length)
{
Init();
@ -111,10 +87,6 @@ kexStr::kexStr(const char *string, const int length)
CopyNew(string, length);
}
//
// kexStr::kexStr
//
kexStr::kexStr(const kexStr &string)
{
Init();
@ -127,10 +99,6 @@ kexStr::kexStr(const kexStr &string)
CopyNew(string.charPtr, string.Length());
}
//
// kexStr::~kexStr
//
kexStr::~kexStr()
{
if (charPtr != defaultBuffer)
@ -143,19 +111,11 @@ kexStr::~kexStr()
length = 0;
}
//
// kexStr::Concat
//
kexStr &kexStr::Concat(const char *string)
{
return Concat(string, strlen(string));
}
//
// kexStr::Concat
//
kexStr &kexStr::Concat(const char c)
{
CheckSize((length + 1) + 1, true);
@ -164,10 +124,6 @@ kexStr &kexStr::Concat(const char c)
return *this;
}
//
// kexStr::Concat
//
kexStr &kexStr::Concat(const char *string, int len)
{
CheckSize((length + len) + 1, true);
@ -183,10 +139,6 @@ kexStr &kexStr::Concat(const char *string, int len)
return *this;
}
//
// kexStr::Copy
//
kexStr &kexStr::Copy(const kexStr &src, int len)
{
int i = 0;
@ -202,19 +154,11 @@ kexStr &kexStr::Copy(const kexStr &src, int len)
return *this;
}
//
// kexStr::Copy
//
kexStr &kexStr::Copy(const kexStr &src)
{
return Copy(src, src.Length());
}
//
// kexStr::operator=
//
kexStr &kexStr::operator=(const kexStr &str)
{
int len = str.Length();
@ -227,10 +171,6 @@ kexStr &kexStr::operator=(const kexStr &str)
return *this;
}
//
// kexStr::operator=
//
kexStr &kexStr::operator=(const char *str)
{
int len = strlen(str);
@ -243,10 +183,6 @@ kexStr &kexStr::operator=(const char *str)
return *this;
}
//
// kexStr::operator=
//
kexStr &kexStr::operator=(const bool b)
{
const char *str = b ? "true" : "false";
@ -260,10 +196,6 @@ kexStr &kexStr::operator=(const bool b)
return *this;
}
//
// kexStr::operator+
//
kexStr kexStr::operator+(const kexStr &str)
{
kexStr out(*this);
@ -271,10 +203,6 @@ kexStr kexStr::operator+(const kexStr &str)
return out.Concat(str.c_str());
}
//
// kexStr::operator+
//
kexStr kexStr::operator+(const char *str)
{
kexStr out(*this);
@ -282,10 +210,6 @@ kexStr kexStr::operator+(const char *str)
return out.Concat(str);
}
//
// kexStr::operator+
//
kexStr kexStr::operator+(const bool b)
{
kexStr out(*this);
@ -293,10 +217,6 @@ kexStr kexStr::operator+(const bool b)
return out.Concat(b ? "true" : "false");
}
//
// kexStr::operator+
//
kexStr kexStr::operator+(const int i)
{
kexStr out(*this);
@ -307,10 +227,6 @@ kexStr kexStr::operator+(const int i)
return out.Concat(tmp);
}
//
// kexStr::operator+
//
kexStr kexStr::operator+(const float f)
{
kexStr out(*this);
@ -321,56 +237,32 @@ kexStr kexStr::operator+(const float f)
return out.Concat(tmp);
}
//
// kexStr::operator+=
//
kexStr &kexStr::operator+=(const kexStr &str)
{
return Concat(str.c_str());
}
//
// kexStr::operator+=
//
kexStr &kexStr::operator+=(const char *str)
{
return Concat(str);
}
//
// kexStr::operator+=
//
kexStr &kexStr::operator+=(const char c)
{
return Concat(c);
}
//
// kexStr::operator+=
//
kexStr &kexStr::operator+=(const bool b)
{
return Concat(b ? "true" : "false");
}
//
// kexStr::operator[]
//
const char kexStr::operator[](int index) const
{
assert(index >= 0 && index < length);
return charPtr[index];
}
//
// kexStr::Resize
//
void kexStr::Resize(int size, bool bKeepString)
{
@ -396,10 +288,6 @@ void kexStr::Resize(int size, bool bKeepString)
bufferLength = newsize;
}
//
// kexStr::IndexOf
//
int kexStr::IndexOf(const char *pattern) const
{
int patlen = strlen(pattern);
@ -425,10 +313,6 @@ int kexStr::IndexOf(const char *pattern) const
return -1;
}
//
// kexStr::IndexOf
//
int kexStr::IndexOf(const char *string, const char *pattern)
{
int patlen = strlen(pattern);
@ -454,19 +338,11 @@ int kexStr::IndexOf(const char *string, const char *pattern)
return -1;
}
//
// kexStr::IndexOf
//
int kexStr::IndexOf(const kexStr &pattern) const
{
return IndexOf(pattern.c_str());
}
//
// kexStr::NormalizeSlashes
//
kexStr &kexStr::NormalizeSlashes()
{
for (int i = 0; i < length; i++)
@ -480,10 +356,6 @@ kexStr &kexStr::NormalizeSlashes()
return *this;
}
//
// kexStr::StripPath
//
kexStr &kexStr::StripPath()
{
int pos = 0;
@ -509,10 +381,6 @@ kexStr &kexStr::StripPath()
return *this;
}
//
// kexStr::StripExtension
//
kexStr &kexStr::StripExtension()
{
int pos = IndexOf(".");
@ -529,10 +397,6 @@ kexStr &kexStr::StripExtension()
return *this;
}
//
// kexStr::StripFile
//
kexStr &kexStr::StripFile()
{
int pos = 0;
@ -560,10 +424,6 @@ kexStr &kexStr::StripFile()
return *this;
}
//
// kexStr::Hash
//
int kexStr::Hash()
{
unsigned int hash = 0;
@ -578,10 +438,6 @@ int kexStr::Hash()
return hash & (MAX_HASH - 1);
}
//
// kexStr::Hash
//
int kexStr::Hash(const char *s)
{
unsigned int hash = 0;
@ -596,10 +452,6 @@ int kexStr::Hash(const char *s)
return hash & (MAX_HASH - 1);
}
//
// kexStr::Format
//
char *kexStr::Format(const char *str, ...)
{
va_list v;
@ -612,10 +464,6 @@ char *kexStr::Format(const char *str, ...)
return vastr;
}
//
// kexStr::Substr
//
kexStr kexStr::Substr(int start, int len) const
{
kexStr str;
@ -634,10 +482,6 @@ kexStr kexStr::Substr(int start, int len) const
return str.Concat((const char*)&charPtr[start], len);
}
//
// kexStr::Split
//
void kexStr::Split(kexStrList &list, const char seperator)
{
int splitLen = 0;
@ -666,28 +510,16 @@ void kexStr::Split(kexStrList &list, const char seperator)
}
}
//
// kexStr::Atoi
//
int kexStr::Atoi()
{
return atoi(charPtr);
}
//
// kexStr::Atof
//
float kexStr::Atof()
{
return (float)atof(charPtr);
}
//
// kexStr::WriteToFile
//
void kexStr::WriteToFile(const char *file)
{
if (length <= 0)
@ -700,10 +532,6 @@ void kexStr::WriteToFile(const char *file)
fclose(f);
}
//
// kexStr::ToUpper
//
kexStr &kexStr::ToUpper()
{
char c;
@ -720,10 +548,6 @@ kexStr &kexStr::ToUpper()
return *this;
}
//
// kexStr::ToLower
//
kexStr &kexStr::ToLower()
{
char c;
@ -740,10 +564,6 @@ kexStr &kexStr::ToLower()
return *this;
}
//
// kexStr::CompareCase
//
bool kexStr::CompareCase(const char *s1, const char *s2)
{
while (*s1 && *s2)
@ -763,19 +583,11 @@ bool kexStr::CompareCase(const char *s1, const char *s2)
return false;
}
//
// kexStr::CompareCase
//
bool kexStr::CompareCase(const kexStr &a, const kexStr &b)
{
return CompareCase(a.c_str(), b.c_str());
}
//
// kexStr::Compare
//
bool kexStr::Compare(const char *s1, const char *s2)
{
const byte *us1 = (const byte*)s1;
@ -794,10 +606,6 @@ bool kexStr::Compare(const char *s1, const char *s2)
return (tolower(*us1) - tolower(*us2)) != 0;
}
//
// kexStr::Compare
//
bool kexStr::Compare(const kexStr &a, const kexStr &b)
{
return Compare(a.c_str(), b.c_str());

View file

@ -62,8 +62,6 @@ private:
kexBBox GetBoundsFromSurface(const surface_t *surface);
kexVec3 LightTexelSample(kexTrace &trace, const kexVec3 &origin, surface_t *surface);
bool EmitFromCeiling(kexTrace &trace, const surface_t *surface, const kexVec3 &origin, const kexVec3 &normal, kexVec3 &color);
void ExportTexelsToObjFile(FILE *f, const kexVec3 &org, int indices);
void WriteBlock(FILE *f, const int i, const kexVec3 &org, int indices, kexBBox &box);
FLevel *map;
kexArray<uint16_t*> textures;

View file

@ -31,7 +31,7 @@ struct MapSubsectorEx;
enum surfaceType_t
{
ST_UNKNOWN = 0,
ST_UNKNOWN,
ST_MIDDLESIDE,
ST_UPPERSIDE,
ST_LOWERSIDE,