2016-03-01 15:47:10 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//
|
2017-04-17 11:33:19 +00:00
|
|
|
// Copyright 1993-1996 id Software
|
|
|
|
// Copyright 1999-2016 Randy Heit
|
|
|
|
// Copyright 2002-2016 Christoph Oelckers
|
2016-03-01 15:47:10 +00:00
|
|
|
//
|
2017-04-17 11:33:19 +00:00
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
2016-03-01 15:47:10 +00:00
|
|
|
//
|
2017-04-17 11:33:19 +00:00
|
|
|
// This program is distributed in the hope that it will be useful,
|
2016-03-01 15:47:10 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2017-04-17 11:33:19 +00:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see http://www.gnu.org/licenses/
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
2016-03-01 15:47:10 +00:00
|
|
|
//
|
|
|
|
// DESCRIPTION:
|
|
|
|
// Setup a game, startup stuff.
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __P_SETUP__
|
|
|
|
#define __P_SETUP__
|
|
|
|
|
|
|
|
#include "resourcefiles/resourcefile.h"
|
|
|
|
#include "doomdata.h"
|
2018-03-19 14:39:50 +00:00
|
|
|
#include "r_defs.h"
|
2018-12-27 08:44:49 +00:00
|
|
|
#include "nodebuild.h"
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
struct MapData
|
|
|
|
{
|
2018-03-10 20:48:33 +00:00
|
|
|
private:
|
2018-06-22 12:40:28 +00:00
|
|
|
struct ResourceHolder
|
|
|
|
{
|
|
|
|
FResourceFile *data = nullptr;
|
|
|
|
|
|
|
|
~ResourceHolder()
|
|
|
|
{
|
|
|
|
delete data;
|
|
|
|
}
|
|
|
|
|
|
|
|
ResourceHolder &operator=(FResourceFile *other) { data = other; return *this; }
|
|
|
|
FResourceFile *operator->() { return data; }
|
|
|
|
operator FResourceFile *() const { return data; }
|
|
|
|
};
|
|
|
|
|
|
|
|
// The order of members here is important
|
|
|
|
// Resource should be destructed after MapLumps as readers may share FResourceLump objects
|
|
|
|
// For example, this is the case when map .wad is loaded from .pk3 file
|
|
|
|
ResourceHolder resource;
|
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
struct MapLump
|
|
|
|
{
|
2018-03-10 20:48:33 +00:00
|
|
|
char Name[8] = { 0 };
|
2018-03-11 17:32:00 +00:00
|
|
|
FileReader Reader;
|
2016-03-01 15:47:10 +00:00
|
|
|
} MapLumps[ML_MAX];
|
2018-03-11 17:32:00 +00:00
|
|
|
FileReader nofile;
|
2018-03-10 20:48:33 +00:00
|
|
|
public:
|
|
|
|
bool HasBehavior = false;
|
|
|
|
bool Encrypted = false;
|
|
|
|
bool isText = false;
|
|
|
|
bool InWad = false;
|
|
|
|
int lumpnum = -1;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2018-03-10 20:48:33 +00:00
|
|
|
/*
|
2016-03-01 15:47:10 +00:00
|
|
|
void Seek(unsigned int lumpindex)
|
|
|
|
{
|
|
|
|
if (lumpindex<countof(MapLumps))
|
|
|
|
{
|
2018-03-10 20:48:33 +00:00
|
|
|
file = &MapLumps[lumpindex].Reader;
|
2018-03-11 17:32:00 +00:00
|
|
|
file->Seek(0, FileReader::SeekSet);
|
2018-03-10 20:48:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2018-03-11 17:32:00 +00:00
|
|
|
FileReader &Reader(unsigned int lumpindex)
|
2018-03-10 20:48:33 +00:00
|
|
|
{
|
|
|
|
if (lumpindex < countof(MapLumps))
|
|
|
|
{
|
|
|
|
auto &file = MapLumps[lumpindex].Reader;
|
2018-03-11 17:32:00 +00:00
|
|
|
file.Seek(0, FileReader::SeekSet);
|
2018-03-10 20:48:33 +00:00
|
|
|
return file;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2018-03-10 20:48:33 +00:00
|
|
|
return nofile;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Read(unsigned int lumpindex, void * buffer, int size = -1)
|
|
|
|
{
|
|
|
|
if (lumpindex<countof(MapLumps))
|
|
|
|
{
|
2018-03-10 20:48:33 +00:00
|
|
|
if (size == -1) size = Size(lumpindex);
|
|
|
|
if (size > 0)
|
|
|
|
{
|
|
|
|
auto &file = MapLumps[lumpindex].Reader;
|
2018-03-11 17:32:00 +00:00
|
|
|
file.Seek(0, FileReader::SeekSet);
|
2018-03-10 20:48:33 +00:00
|
|
|
file.Read(buffer, size);
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-10 10:56:18 +00:00
|
|
|
TArray<uint8_t> Read(unsigned lumpindex)
|
|
|
|
{
|
|
|
|
TArray<uint8_t> buffer(Size(lumpindex), true);
|
|
|
|
Read(lumpindex, buffer.Data(), (int)buffer.Size());
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2017-03-08 14:20:00 +00:00
|
|
|
uint32_t Size(unsigned int lumpindex)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2018-03-10 20:48:33 +00:00
|
|
|
if (lumpindex<countof(MapLumps) && MapLumps[lumpindex].Reader.isOpen())
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2018-03-10 20:48:33 +00:00
|
|
|
return (uint32_t)MapLumps[lumpindex].Reader.GetLength();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-10 20:48:33 +00:00
|
|
|
bool CheckName(unsigned int lumpindex, const char *name)
|
|
|
|
{
|
|
|
|
if (lumpindex < countof(MapLumps))
|
|
|
|
{
|
|
|
|
return !strnicmp(MapLumps[lumpindex].Name, name, 8);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-03-08 14:20:00 +00:00
|
|
|
void GetChecksum(uint8_t cksum[16]);
|
2018-03-10 20:48:33 +00:00
|
|
|
|
2018-12-27 08:44:49 +00:00
|
|
|
friend class MapLoader;
|
2018-03-10 20:48:33 +00:00
|
|
|
friend MapData *P_OpenMapData(const char * mapname, bool justcheck);
|
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
MapData * P_OpenMapData(const char * mapname, bool justcheck);
|
|
|
|
bool P_CheckMapData(const char * mapname);
|
|
|
|
|
|
|
|
|
|
|
|
// NOT called by W_Ticker. Fixme. [RH] Is that bad?
|
|
|
|
//
|
|
|
|
// [RH] The only parameter used is mapname, so I removed playermask and skill.
|
|
|
|
// On September 1, 1998, I added the position to indicate which set
|
|
|
|
// of single-player start spots should be spawned in the level.
|
2018-10-31 07:15:56 +00:00
|
|
|
void P_SetupLevel (const char *mapname, int position, bool newGame);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
void P_FreeLevelData();
|
|
|
|
|
|
|
|
// Called by startup code.
|
|
|
|
void P_Init (void);
|
|
|
|
|
|
|
|
struct line_t;
|
|
|
|
struct maplinedef_t;
|
|
|
|
|
|
|
|
void P_LoadTranslator(const char *lumpname);
|
|
|
|
void P_TranslateLineDef (line_t *ld, maplinedef_t *mld, int lineindexforid = -1);
|
|
|
|
int P_TranslateSectorSpecial (int);
|
|
|
|
|
2017-02-15 00:03:47 +00:00
|
|
|
int GetUDMFInt(int type, int index, FName key);
|
|
|
|
double GetUDMFFloat(int type, int index, FName key);
|
2018-12-04 22:12:16 +00:00
|
|
|
FString GetUDMFString(int type, int index, FName key);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2018-11-04 15:47:45 +00:00
|
|
|
void FixMinisegReferences();
|
|
|
|
void FixHoles();
|
|
|
|
void ReportUnpairedMinisegs();
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2018-12-27 16:11:10 +00:00
|
|
|
// To be moved to maploader later!
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2018-12-27 11:10:52 +00:00
|
|
|
extern TArray<FMapThing> MapThingsConverted;
|
|
|
|
extern bool ForceNodeBuild;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
#endif
|