gzdoom/src/p_setup.h

173 lines
3.8 KiB
C
Raw Normal View History

// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// $Id:$
//
// Copyright (C) 1993-1996 by id Software, Inc.
//
// This source is available for distribution and/or modification
// only under the terms of the DOOM Source Code License as
// published by id Software. All rights reserved.
//
// The source is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
// for more details.
//
// DESCRIPTION:
// Setup a game, startup stuff.
//
//-----------------------------------------------------------------------------
#ifndef __P_SETUP__
#define __P_SETUP__
#include "resourcefiles/resourcefile.h"
#include "doomdata.h"
struct MapData
{
struct MapLump
{
char Name[8];
FileReader *Reader;
} MapLumps[ML_MAX];
bool HasBehavior;
2006-06-15 03:31:19 +00:00
bool Encrypted;
bool isText;
bool InWad;
int lumpnum;
FileReader * file;
FResourceFile * resource;
MapData()
{
memset(MapLumps, 0, sizeof(MapLumps));
file = NULL;
resource = NULL;
2006-06-15 03:31:19 +00:00
lumpnum = -1;
HasBehavior = false;
Encrypted = false;
isText = false;
InWad = false;
}
~MapData()
{
for (unsigned int i = 0;i < ML_MAX;++i)
delete MapLumps[i].Reader;
delete resource;
resource = NULL;
}
2006-06-14 20:24:43 +00:00
void Seek(unsigned int lumpindex)
{
2006-06-14 20:24:43 +00:00
if (lumpindex<countof(MapLumps))
{
file = MapLumps[lumpindex].Reader;
file->Seek(0, SEEK_SET);
}
}
void Read(unsigned int lumpindex, void * buffer, int size = -1)
{
2006-06-14 20:24:43 +00:00
if (lumpindex<countof(MapLumps))
{
if (size == -1) size = MapLumps[lumpindex].Reader->GetLength();
Seek(lumpindex);
file->Read(buffer, size);
}
}
2006-06-14 20:24:43 +00:00
DWORD Size(unsigned int lumpindex)
{
if (lumpindex<countof(MapLumps) && MapLumps[lumpindex].Reader)
{
return MapLumps[lumpindex].Reader->GetLength();
}
return 0;
}
void GetChecksum(BYTE cksum[16]);
};
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.
void P_SetupLevel (char *mapname, int position);
- Yay! We now seem to be free of memory leaks! The next step will be to merge a lot of these static destructor-only structs into regular functions added to the exit chain with atterm so that they can be called in a deterministic order and not whatever order the linker decides to put them in. (Interestingly, the amount of memory used when repeatedly executing the same map command at the console varies up and down, but it now stays relatively stable rather than increasing unbounded.) - Fixed: The list of resolutions in the video modes menu was not freed at exit. - Fixed: mus_playing.name was not freed at exit. - Fixed: SN_StopAllSequences() should be called at the start of P_FreeLevelData(), not just before the call to P_SetupLevel() in G_DoLoadLevel(), so it can run even at exit. And C_FullConsole() can call P_FreeLevelData() to free more memory too. - Fixed: StatusBar was not freed at exit. - Fixed: spritesorter was not freed at exit. - Fixed: Bad things happened if FString's data pool was destroyed before all C_RemoveTabCommand() calls were made. - Added an overload for FArchive << FString. - Fixed: The players' log text was not freed at exit. - Fixed: Bot information was not freed at exit. - Fixed: doomcom was not freed at exit. But since it's always created, there's no reason why it needs to be allocated from the heap. My guess is that in the DOS days, the external packet driver was responsible for allocating doomcom and passed its location with the -net parameter. - Fixed: FBlockNodes were not freed at exit. - Fixed: Openings were not freed at exit. - Fixed: Drawsegs were not freed at exit. - Fixed: Vissprites were not freed at exit. - Fixed: Console command history was not freed at exit. - Fixed: Visplanes were not freed at exit. - Fixed: Call P_FreeLevelData() at exit. - Fixed: Channel, SoundCurve, and PlayList in s_sound.cpp were not freed at exit. - Fixed: Sound sequences were not freed at exit. - Fixed: DSeqNode::Serialize() did not resize the m_SequenceChoices array when loading. SVN r106 (trunk)
2006-05-11 04:00:58 +00:00
void P_FreeLevelData();
void P_FreeExtraLevelData();
- Yay! We now seem to be free of memory leaks! The next step will be to merge a lot of these static destructor-only structs into regular functions added to the exit chain with atterm so that they can be called in a deterministic order and not whatever order the linker decides to put them in. (Interestingly, the amount of memory used when repeatedly executing the same map command at the console varies up and down, but it now stays relatively stable rather than increasing unbounded.) - Fixed: The list of resolutions in the video modes menu was not freed at exit. - Fixed: mus_playing.name was not freed at exit. - Fixed: SN_StopAllSequences() should be called at the start of P_FreeLevelData(), not just before the call to P_SetupLevel() in G_DoLoadLevel(), so it can run even at exit. And C_FullConsole() can call P_FreeLevelData() to free more memory too. - Fixed: StatusBar was not freed at exit. - Fixed: spritesorter was not freed at exit. - Fixed: Bad things happened if FString's data pool was destroyed before all C_RemoveTabCommand() calls were made. - Added an overload for FArchive << FString. - Fixed: The players' log text was not freed at exit. - Fixed: Bot information was not freed at exit. - Fixed: doomcom was not freed at exit. But since it's always created, there's no reason why it needs to be allocated from the heap. My guess is that in the DOS days, the external packet driver was responsible for allocating doomcom and passed its location with the -net parameter. - Fixed: FBlockNodes were not freed at exit. - Fixed: Openings were not freed at exit. - Fixed: Drawsegs were not freed at exit. - Fixed: Vissprites were not freed at exit. - Fixed: Console command history was not freed at exit. - Fixed: Visplanes were not freed at exit. - Fixed: Call P_FreeLevelData() at exit. - Fixed: Channel, SoundCurve, and PlayList in s_sound.cpp were not freed at exit. - Fixed: Sound sequences were not freed at exit. - Fixed: DSeqNode::Serialize() did not resize the m_SequenceChoices array when loading. SVN r106 (trunk)
2006-05-11 04:00:58 +00:00
// 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 P_TranslateSectorSpecial (int);
int GetUDMFInt(int type, int index, const char *key);
fixed_t GetUDMFFixed(int type, int index, const char *key);
bool P_LoadGLNodes(MapData * map);
bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime);
bool P_CheckForGLNodes();
void P_SetRenderSector();
struct sidei_t // [RH] Only keep BOOM sidedef init stuff around for init
{
union
{
// Used when unpacking sidedefs and assigning
// properties based on linedefs.
struct
{
short tag, special;
short alpha;
DWORD map;
} a;
// Used when grouping sidedefs into loops.
struct
{
DWORD first, next;
char lineside;
} b;
};
};
extern sidei_t *sidetemp;
extern bool hasglnodes;
extern struct glsegextra_t *glsegextras;
struct FMissingCount
{
FMissingCount() : Count(0) {}
int Count;
};
typedef TMap<FString,FMissingCount> FMissingTextureTracker;
// Record of user data for UDMF maps
struct FMapThingUserData
{
FName Property;
int Value;
};
extern TMap<unsigned,unsigned> MapThingsUserDataIndex; // from mapthing idx -> user data idx
extern TArray<FMapThingUserData> MapThingsUserData;
#endif