2006-02-24 04:48:15 +00:00
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// $Log:$
|
|
|
|
//
|
|
|
|
// DESCRIPTION:
|
|
|
|
// Do all the WAD I/O, get map description,
|
|
|
|
// set up initial state and misc. LUTs.
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#include <malloc.h> // for alloca()
|
|
|
|
#endif
|
2008-08-10 11:29:19 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
#include "templates.h"
|
|
|
|
#include "m_argv.h"
|
|
|
|
#include "m_swap.h"
|
|
|
|
#include "m_bbox.h"
|
|
|
|
#include "g_game.h"
|
2008-08-10 11:29:19 +00:00
|
|
|
#include "i_system.h"
|
2008-08-10 03:25:08 +00:00
|
|
|
#include "x86.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
#include "w_wad.h"
|
|
|
|
#include "doomdef.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "p_effect.h"
|
|
|
|
#include "p_terrain.h"
|
|
|
|
#include "nodebuild.h"
|
|
|
|
#include "s_sound.h"
|
|
|
|
#include "doomstat.h"
|
|
|
|
#include "p_lnspec.h"
|
|
|
|
#include "v_palette.h"
|
|
|
|
#include "c_console.h"
|
2008-04-05 12:14:33 +00:00
|
|
|
#include "c_cvars.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
#include "p_acs.h"
|
|
|
|
#include "announcer.h"
|
|
|
|
#include "wi_stuff.h"
|
|
|
|
#include "stats.h"
|
|
|
|
#include "doomerrors.h"
|
|
|
|
#include "gi.h"
|
|
|
|
#include "p_conversation.h"
|
|
|
|
#include "a_keys.h"
|
2006-05-11 04:00:58 +00:00
|
|
|
#include "s_sndseq.h"
|
|
|
|
#include "sbar.h"
|
2006-06-14 15:56:56 +00:00
|
|
|
#include "p_setup.h"
|
2011-07-06 08:50:15 +00:00
|
|
|
#include "r_data/r_translate.h"
|
|
|
|
#include "r_data/r_interpolate.h"
|
2008-06-15 18:36:26 +00:00
|
|
|
#include "r_sky.h"
|
2008-09-14 23:54:38 +00:00
|
|
|
#include "cmdlib.h"
|
|
|
|
#include "g_level.h"
|
2009-02-05 02:55:28 +00:00
|
|
|
#include "md5.h"
|
|
|
|
#include "compatibility.h"
|
2010-07-23 05:56:25 +00:00
|
|
|
#include "po_man.h"
|
2011-07-07 21:43:49 +00:00
|
|
|
#include "r_renderer.h"
|
2011-07-06 07:35:36 +00:00
|
|
|
#include "r_data/colormaps.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2011-01-29 11:09:38 +00:00
|
|
|
#include "fragglescript/t_fs.h"
|
|
|
|
|
2011-05-08 00:30:32 +00:00
|
|
|
#define MISSING_TEXTURE_WARN_LIMIT 20
|
|
|
|
|
2012-02-21 21:52:42 +00:00
|
|
|
void P_SpawnSlopeMakers (FMapThing *firstmt, FMapThing *lastmt, const int *oldvertextable);
|
2008-05-02 16:59:38 +00:00
|
|
|
void P_SetSlopes ();
|
2010-01-30 22:53:37 +00:00
|
|
|
void P_CopySlopes();
|
2009-04-23 22:49:38 +00:00
|
|
|
void BloodCrypt (void *data, int key, int len);
|
2009-05-11 21:05:40 +00:00
|
|
|
void P_ClearUDMFKeys();
|
2008-05-02 16:59:38 +00:00
|
|
|
|
2008-05-08 08:06:26 +00:00
|
|
|
extern AActor *P_SpawnMapThing (FMapThing *mthing, int position);
|
|
|
|
extern bool P_LoadBuildMap (BYTE *mapdata, size_t len, FMapThing **things, int *numthings);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
extern void P_TranslateTeleportThings (void);
|
|
|
|
|
2011-05-08 00:30:32 +00:00
|
|
|
void P_ParseTextMap(MapData *map, FMissingTextureTracker &);
|
2008-05-11 21:16:32 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
extern int numinterpolations;
|
|
|
|
extern unsigned int R_OldBlend;
|
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
EXTERN_CVAR(Bool, am_textured)
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
CVAR (Bool, genblockmap, false, CVAR_SERVERINFO|CVAR_GLOBALCONFIG);
|
|
|
|
CVAR (Bool, gennodes, false, CVAR_SERVERINFO|CVAR_GLOBALCONFIG);
|
|
|
|
CVAR (Bool, genglnodes, false, CVAR_SERVERINFO);
|
|
|
|
CVAR (Bool, showloadtimes, false, 0);
|
|
|
|
|
|
|
|
static void P_InitTagLists ();
|
2006-05-12 03:14:40 +00:00
|
|
|
static void P_Shutdown ();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-05-15 17:16:32 +00:00
|
|
|
bool P_IsBuildMap(MapData *map);
|
2006-06-14 15:56:56 +00:00
|
|
|
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
// MAP related Lookup tables.
|
|
|
|
// Store VERTEXES, LINEDEFS, SIDEDEFS, etc.
|
|
|
|
//
|
|
|
|
int numvertexes;
|
|
|
|
vertex_t* vertexes;
|
2010-12-14 00:56:44 +00:00
|
|
|
int numvertexdatas;
|
|
|
|
vertexdata_t* vertexdatas;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
int numsegs;
|
|
|
|
seg_t* segs;
|
2010-08-27 15:20:05 +00:00
|
|
|
glsegextra_t* glsegextras;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
int numsectors;
|
|
|
|
sector_t* sectors;
|
|
|
|
|
|
|
|
int numsubsectors;
|
|
|
|
subsector_t* subsectors;
|
|
|
|
|
|
|
|
int numnodes;
|
|
|
|
node_t* nodes;
|
|
|
|
|
|
|
|
int numlines;
|
|
|
|
line_t* lines;
|
|
|
|
|
|
|
|
int numsides;
|
|
|
|
side_t* sides;
|
|
|
|
|
|
|
|
int numzones;
|
|
|
|
zone_t* zones;
|
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
node_t * gamenodes;
|
|
|
|
int numgamenodes;
|
|
|
|
|
|
|
|
subsector_t * gamesubsectors;
|
|
|
|
int numgamesubsectors;
|
|
|
|
|
|
|
|
bool hasglnodes;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
TArray<FMapThing> MapThingsConverted;
|
2008-05-08 08:06:26 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
int sidecount;
|
2010-08-01 05:16:09 +00:00
|
|
|
sidei_t *sidetemp;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
TArray<int> linemap;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// BLOCKMAP
|
|
|
|
// Created from axis aligned bounding box
|
|
|
|
// of the map, a rectangular array of
|
|
|
|
// blocks of size 256x256.
|
|
|
|
// Used to speed up collision detection
|
|
|
|
// by spatial subdivision in 2D.
|
|
|
|
//
|
|
|
|
// Blockmap size.
|
|
|
|
int bmapwidth;
|
|
|
|
int bmapheight; // size in mapblocks
|
|
|
|
|
|
|
|
int *blockmap; // int for larger maps ([RH] Made int because BOOM does)
|
|
|
|
int *blockmaplump; // offsets in blockmap are from here
|
|
|
|
|
|
|
|
fixed_t bmaporgx; // origin of block map
|
|
|
|
fixed_t bmaporgy;
|
2012-03-28 03:49:38 +00:00
|
|
|
int bmapnegx; // min negs of block map before wrapping
|
|
|
|
int bmapnegy;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
FBlockNode** blocklinks; // for thing chains
|
|
|
|
|
|
|
|
|
|
|
|
// REJECT
|
|
|
|
// For fast sight rejection.
|
|
|
|
// Speeds up enemy AI by skipping detailed
|
|
|
|
// LineOf Sight calculation.
|
|
|
|
// Without special effect, this could be
|
|
|
|
// used as a PVS lookup as well.
|
|
|
|
//
|
2006-09-14 00:02:31 +00:00
|
|
|
BYTE* rejectmatrix;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
bool ForceNodeBuild;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// Maintain single and multi player starting spots.
|
2012-07-08 02:18:15 +00:00
|
|
|
TArray<FPlayerStart> deathmatchstarts (16);
|
|
|
|
FPlayerStart playerstarts[MAXPLAYERS];
|
|
|
|
TArray<FPlayerStart> AllPlayerStarts;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
static void P_AllocateSideDefs (int count);
|
2006-06-14 15:56:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// GetMapIndex
|
|
|
|
//
|
2006-06-15 03:31:19 +00:00
|
|
|
// Gets the type of map lump or -1 if invalid or -2 if required and not found.
|
2006-06-14 15:56:56 +00:00
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2006-06-15 03:31:19 +00:00
|
|
|
struct checkstruct
|
2006-06-14 15:56:56 +00:00
|
|
|
{
|
2006-12-29 03:38:37 +00:00
|
|
|
const char lumpname[9];
|
2006-06-15 03:31:19 +00:00
|
|
|
bool required;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int GetMapIndex(const char *mapname, int lastindex, const char *lumpname, bool needrequired)
|
|
|
|
{
|
|
|
|
static const checkstruct check[] =
|
2006-06-14 15:56:56 +00:00
|
|
|
{
|
2006-12-29 03:38:37 +00:00
|
|
|
{"", true},
|
2006-06-15 03:31:19 +00:00
|
|
|
{"THINGS", true},
|
2006-06-14 15:56:56 +00:00
|
|
|
{"LINEDEFS", true},
|
|
|
|
{"SIDEDEFS", true},
|
|
|
|
{"VERTEXES", true},
|
2006-06-15 03:31:19 +00:00
|
|
|
{"SEGS", false},
|
2006-06-14 15:56:56 +00:00
|
|
|
{"SSECTORS", false},
|
2006-06-15 03:31:19 +00:00
|
|
|
{"NODES", false},
|
|
|
|
{"SECTORS", true},
|
|
|
|
{"REJECT", false},
|
2006-06-14 15:56:56 +00:00
|
|
|
{"BLOCKMAP", false},
|
|
|
|
{"BEHAVIOR", false},
|
2006-06-15 08:26:13 +00:00
|
|
|
//{"SCRIPTS", false},
|
2006-06-14 15:56:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (lumpname==NULL) lumpname="";
|
|
|
|
|
|
|
|
for(size_t i=lastindex+1;i<countof(check);i++)
|
|
|
|
{
|
|
|
|
if (!strnicmp(lumpname, check[i].lumpname, 8))
|
|
|
|
return (int)i;
|
|
|
|
|
|
|
|
if (check[i].required)
|
|
|
|
{
|
2006-06-15 03:31:19 +00:00
|
|
|
if (needrequired)
|
|
|
|
{
|
|
|
|
I_Error("'%s' not found in %s\n", check[i].lumpname, mapname);
|
|
|
|
}
|
|
|
|
return -2;
|
2006-06-14 15:56:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1; // End of map reached
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Opens a map for reading
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2006-06-15 03:31:19 +00:00
|
|
|
MapData *P_OpenMapData(const char * mapname)
|
2006-06-14 15:56:56 +00:00
|
|
|
{
|
|
|
|
MapData * map = new MapData;
|
2012-10-22 01:28:11 +00:00
|
|
|
FileReader * wadReader = NULL;
|
2006-06-14 15:56:56 +00:00
|
|
|
bool externalfile = !strnicmp(mapname, "file:", 5);
|
|
|
|
|
|
|
|
if (externalfile)
|
|
|
|
{
|
2006-06-15 03:31:19 +00:00
|
|
|
mapname += 5;
|
2006-06-14 15:56:56 +00:00
|
|
|
if (!FileExists(mapname))
|
|
|
|
{
|
|
|
|
delete map;
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-10-22 01:28:11 +00:00
|
|
|
map->resource = FResourceFile::OpenResourceFile(mapname, NULL, true);
|
|
|
|
wadReader = map->resource->GetReader();
|
2006-06-14 15:56:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FString fmt;
|
|
|
|
int lump_wad;
|
|
|
|
int lump_map;
|
|
|
|
int lump_name;
|
|
|
|
|
|
|
|
// Check for both *.wad and *.map in order to load Build maps
|
|
|
|
// as well. The higher one will take precedence.
|
|
|
|
lump_name = Wads.CheckNumForName(mapname);
|
|
|
|
fmt.Format("maps/%s.wad", mapname);
|
|
|
|
lump_wad = Wads.CheckNumForFullName(fmt);
|
|
|
|
fmt.Format("maps/%s.map", mapname);
|
|
|
|
lump_map = Wads.CheckNumForFullName(fmt);
|
|
|
|
|
|
|
|
if (lump_name > lump_wad && lump_name > lump_map && lump_name != -1)
|
|
|
|
{
|
2009-03-15 01:41:53 +00:00
|
|
|
int lumpfile = Wads.GetLumpFile(lump_name);
|
|
|
|
int nextfile = Wads.GetLumpFile(lump_name+1);
|
|
|
|
|
|
|
|
map->lumpnum = lump_name;
|
2006-08-17 22:10:50 +00:00
|
|
|
|
|
|
|
if (lumpfile != nextfile)
|
|
|
|
{
|
|
|
|
// The following lump is from a different file so whatever this is,
|
2008-04-05 12:14:33 +00:00
|
|
|
// it is not a multi-lump Doom level so let's assume it is a Build map.
|
2012-10-22 01:28:11 +00:00
|
|
|
map->MapLumps[0].Reader = map->file = Wads.ReopenLumpNum(lump_name);
|
2008-05-15 17:16:32 +00:00
|
|
|
if (!P_IsBuildMap(map))
|
|
|
|
{
|
|
|
|
delete map;
|
|
|
|
return NULL;
|
|
|
|
}
|
2006-08-17 22:10:50 +00:00
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This case can only happen if the lump is inside a real WAD file.
|
|
|
|
// As such any special handling for other types of lumps is skipped.
|
2012-11-19 00:43:45 +00:00
|
|
|
map->MapLumps[0].Reader = map->file = Wads.ReopenLumpNum(lump_name);
|
2006-06-15 03:31:19 +00:00
|
|
|
map->Encrypted = Wads.IsEncryptedFile(lump_name);
|
2013-02-14 05:06:05 +00:00
|
|
|
map->InWad = true;
|
2006-06-14 15:56:56 +00:00
|
|
|
|
2006-06-15 03:31:19 +00:00
|
|
|
if (map->Encrypted)
|
|
|
|
{ // If it's encrypted, then it's a Blood file, presumably a map.
|
2012-10-22 01:28:11 +00:00
|
|
|
map->MapLumps[0].Reader = map->file = Wads.ReopenLumpNum(lump_name);
|
2008-05-15 17:16:32 +00:00
|
|
|
if (!P_IsBuildMap(map))
|
|
|
|
{
|
|
|
|
delete map;
|
|
|
|
return NULL;
|
|
|
|
}
|
2006-06-15 03:31:19 +00:00
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
|
|
|
int index = 0;
|
2006-06-14 15:56:56 +00:00
|
|
|
|
2010-03-18 01:07:50 +00:00
|
|
|
if (stricmp(Wads.GetLumpFullName(lump_name + 1), "TEXTMAP") != 0)
|
2008-05-08 08:06:26 +00:00
|
|
|
{
|
|
|
|
for(int i = 1;; i++)
|
|
|
|
{
|
|
|
|
// Since levels must be stored in WADs they can't really have full
|
|
|
|
// names and for any valid level lump this always returns the short name.
|
|
|
|
const char * lumpname = Wads.GetLumpFullName(lump_name + i);
|
2012-10-22 01:28:11 +00:00
|
|
|
index = GetMapIndex(mapname, index, lumpname, i != 1 || Wads.LumpLength(lump_name + i) == 0);
|
2008-05-08 08:06:26 +00:00
|
|
|
if (index == ML_BEHAVIOR) map->HasBehavior = true;
|
|
|
|
|
|
|
|
// The next lump is not part of this map anymore
|
|
|
|
if (index < 0) break;
|
|
|
|
|
2012-10-22 01:28:11 +00:00
|
|
|
map->MapLumps[index].Reader = Wads.ReopenLumpNum(lump_name + i);
|
2008-05-08 08:06:26 +00:00
|
|
|
strncpy(map->MapLumps[index].Name, lumpname, 8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-05-11 21:16:32 +00:00
|
|
|
map->isText = true;
|
2012-10-22 01:28:11 +00:00
|
|
|
map->MapLumps[1].Reader = Wads.ReopenLumpNum(lump_name + 1);
|
2008-05-08 08:06:26 +00:00
|
|
|
for(int i = 2;; i++)
|
|
|
|
{
|
|
|
|
const char * lumpname = Wads.GetLumpFullName(lump_name + i);
|
2006-06-14 15:56:56 +00:00
|
|
|
|
2008-05-08 08:06:26 +00:00
|
|
|
if (lumpname == NULL)
|
|
|
|
{
|
|
|
|
I_Error("Invalid map definition for %s", mapname);
|
|
|
|
}
|
|
|
|
else if (!stricmp(lumpname, "ZNODES"))
|
|
|
|
{
|
|
|
|
index = ML_GLZNODES;
|
|
|
|
}
|
|
|
|
else if (!stricmp(lumpname, "BLOCKMAP"))
|
|
|
|
{
|
|
|
|
// there is no real point in creating a blockmap but let's use it anyway
|
|
|
|
index = ML_BLOCKMAP;
|
|
|
|
}
|
|
|
|
else if (!stricmp(lumpname, "REJECT"))
|
|
|
|
{
|
|
|
|
index = ML_REJECT;
|
|
|
|
}
|
|
|
|
else if (!stricmp(lumpname, "DIALOGUE"))
|
|
|
|
{
|
|
|
|
index = ML_CONVERSATION;
|
|
|
|
}
|
|
|
|
else if (!stricmp(lumpname, "BEHAVIOR"))
|
|
|
|
{
|
|
|
|
index = ML_BEHAVIOR;
|
2008-05-22 19:35:38 +00:00
|
|
|
map->HasBehavior = true;
|
2008-05-08 08:06:26 +00:00
|
|
|
}
|
|
|
|
else if (!stricmp(lumpname, "ENDMAP"))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else continue;
|
2012-10-22 01:28:11 +00:00
|
|
|
map->MapLumps[index].Reader = Wads.ReopenLumpNum(lump_name + i);
|
2008-05-08 08:06:26 +00:00
|
|
|
strncpy(map->MapLumps[index].Name, lumpname, 8);
|
|
|
|
}
|
2006-06-14 15:56:56 +00:00
|
|
|
}
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (lump_map > lump_wad)
|
|
|
|
{
|
|
|
|
lump_wad = lump_map;
|
|
|
|
}
|
|
|
|
if (lump_wad == -1)
|
|
|
|
{
|
|
|
|
delete map;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
map->lumpnum = lump_wad;
|
2012-10-22 01:28:11 +00:00
|
|
|
map->resource = FResourceFile::OpenResourceFile(Wads.GetLumpFullName(lump_wad), Wads.ReopenLumpNum(lump_wad), true);
|
|
|
|
wadReader = map->resource->GetReader();
|
2006-06-14 15:56:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
DWORD id;
|
2010-03-18 00:48:56 +00:00
|
|
|
|
2012-10-22 01:28:11 +00:00
|
|
|
// Although we're using the resource system, we still want to be sure we're
|
|
|
|
// reading from a wad file.
|
|
|
|
wadReader->Seek(0, SEEK_SET);
|
|
|
|
wadReader->Read(&id, sizeof(id));
|
2006-06-14 15:56:56 +00:00
|
|
|
|
|
|
|
if (id == IWAD_ID || id == PWAD_ID)
|
|
|
|
{
|
|
|
|
char maplabel[9]="";
|
|
|
|
int index=0;
|
|
|
|
|
2012-10-22 01:28:11 +00:00
|
|
|
map->MapLumps[0].Reader = map->resource->GetLump(0)->NewReader();
|
2006-06-14 15:56:56 +00:00
|
|
|
|
2012-10-22 01:28:11 +00:00
|
|
|
for(DWORD i = 1; i < map->resource->LumpCount(); i++)
|
2006-06-14 15:56:56 +00:00
|
|
|
{
|
2012-10-22 01:28:11 +00:00
|
|
|
const char* lumpname = map->resource->GetLump(i)->Name;
|
2006-06-14 15:56:56 +00:00
|
|
|
|
2008-05-08 08:06:26 +00:00
|
|
|
if (i == 1 && !strnicmp(lumpname, "TEXTMAP", 8))
|
|
|
|
{
|
2008-05-11 21:16:32 +00:00
|
|
|
map->isText = true;
|
2012-10-24 23:49:34 +00:00
|
|
|
map->MapLumps[ML_TEXTMAP].Reader = map->resource->GetLump(i)->NewReader();
|
|
|
|
strncpy(map->MapLumps[ML_TEXTMAP].Name, lumpname, 8);
|
2008-05-08 08:06:26 +00:00
|
|
|
for(int i = 2;; i++)
|
|
|
|
{
|
2012-10-22 01:28:11 +00:00
|
|
|
lumpname = map->resource->GetLump(i)->Name;
|
2012-10-24 23:49:34 +00:00
|
|
|
if (!strnicmp(lumpname, "ZNODES",8))
|
2008-05-08 08:06:26 +00:00
|
|
|
{
|
|
|
|
index = ML_GLZNODES;
|
|
|
|
}
|
2008-05-22 19:35:38 +00:00
|
|
|
else if (!strnicmp(lumpname, "BLOCKMAP",8))
|
2008-05-08 08:06:26 +00:00
|
|
|
{
|
|
|
|
// there is no real point in creating a blockmap but let's use it anyway
|
|
|
|
index = ML_BLOCKMAP;
|
|
|
|
}
|
2008-05-22 19:35:38 +00:00
|
|
|
else if (!strnicmp(lumpname, "REJECT",8))
|
2008-05-08 08:06:26 +00:00
|
|
|
{
|
|
|
|
index = ML_REJECT;
|
|
|
|
}
|
2008-05-22 19:35:38 +00:00
|
|
|
else if (!strnicmp(lumpname, "DIALOGUE",8))
|
2008-05-08 08:06:26 +00:00
|
|
|
{
|
|
|
|
index = ML_CONVERSATION;
|
|
|
|
}
|
2008-05-22 19:35:38 +00:00
|
|
|
else if (!strnicmp(lumpname, "BEHAVIOR",8))
|
2008-05-08 08:06:26 +00:00
|
|
|
{
|
|
|
|
index = ML_BEHAVIOR;
|
2008-05-22 19:35:38 +00:00
|
|
|
map->HasBehavior = true;
|
2008-05-08 08:06:26 +00:00
|
|
|
}
|
2008-05-22 19:35:38 +00:00
|
|
|
else if (!strnicmp(lumpname, "ENDMAP",8))
|
2008-05-08 08:06:26 +00:00
|
|
|
{
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
else continue;
|
2012-10-22 01:28:11 +00:00
|
|
|
map->MapLumps[index].Reader = map->resource->GetLump(i)->NewReader();
|
2008-05-08 08:06:26 +00:00
|
|
|
strncpy(map->MapLumps[index].Name, lumpname, 8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
if (i>0)
|
|
|
|
{
|
2006-06-15 03:31:19 +00:00
|
|
|
index = GetMapIndex(maplabel, index, lumpname, true);
|
2006-06-15 16:23:41 +00:00
|
|
|
if (index == ML_BEHAVIOR) map->HasBehavior = true;
|
2006-06-14 15:56:56 +00:00
|
|
|
|
|
|
|
// The next lump is not part of this map anymore
|
|
|
|
if (index < 0) break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strncpy(maplabel, lumpname, 8);
|
|
|
|
maplabel[8]=0;
|
|
|
|
}
|
|
|
|
|
2012-10-22 01:28:11 +00:00
|
|
|
map->MapLumps[index].Reader = map->resource->GetLump(i)->NewReader();
|
2006-06-15 08:26:13 +00:00
|
|
|
strncpy(map->MapLumps[index].Name, lumpname, 8);
|
2006-06-14 15:56:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// This is a Build map and not subject to WAD consistency checks.
|
2012-10-22 01:28:11 +00:00
|
|
|
//map->MapLumps[0].Size = wadReader->GetLength();
|
2008-05-15 17:16:32 +00:00
|
|
|
if (!P_IsBuildMap(map))
|
|
|
|
{
|
|
|
|
delete map;
|
|
|
|
return NULL;
|
|
|
|
}
|
2006-06-14 15:56:56 +00:00
|
|
|
}
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
2008-04-05 12:14:33 +00:00
|
|
|
bool P_CheckMapData(const char *mapname)
|
|
|
|
{
|
|
|
|
MapData *mapd = P_OpenMapData(mapname);
|
|
|
|
if (mapd == NULL) return false;
|
|
|
|
delete mapd;
|
|
|
|
return true;
|
|
|
|
}
|
2006-06-14 15:56:56 +00:00
|
|
|
|
2009-02-05 02:55:28 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// MapData :: GetChecksum
|
|
|
|
//
|
|
|
|
// Hashes a map based on its header, THINGS, LINEDEFS, SIDEDEFS, SECTORS,
|
|
|
|
// and BEHAVIOR lumps. Node-builder generated lumps are not included.
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void MapData::GetChecksum(BYTE cksum[16])
|
|
|
|
{
|
|
|
|
MD5Context md5;
|
|
|
|
|
|
|
|
if (file != NULL)
|
|
|
|
{
|
|
|
|
if (isText)
|
|
|
|
{
|
2012-10-22 01:28:11 +00:00
|
|
|
Seek(ML_TEXTMAP);
|
|
|
|
md5.Update(file, Size(ML_TEXTMAP));
|
2009-02-05 02:55:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-10-22 01:28:11 +00:00
|
|
|
if (Size(ML_LABEL) != 0)
|
2009-02-05 02:55:28 +00:00
|
|
|
{
|
2012-10-22 01:28:11 +00:00
|
|
|
Seek(ML_LABEL);
|
|
|
|
md5.Update(file, Size(ML_LABEL));
|
2009-02-05 02:55:28 +00:00
|
|
|
}
|
2012-10-22 01:28:11 +00:00
|
|
|
Seek(ML_THINGS);
|
|
|
|
md5.Update(file, Size(ML_THINGS));
|
|
|
|
Seek(ML_LINEDEFS);
|
|
|
|
md5.Update(file, Size(ML_LINEDEFS));
|
|
|
|
Seek(ML_SIDEDEFS);
|
|
|
|
md5.Update(file, Size(ML_SIDEDEFS));
|
|
|
|
Seek(ML_SECTORS);
|
|
|
|
md5.Update(file, Size(ML_SECTORS));
|
2009-02-05 02:55:28 +00:00
|
|
|
}
|
|
|
|
if (HasBehavior)
|
|
|
|
{
|
2012-10-22 01:28:11 +00:00
|
|
|
Seek(ML_BEHAVIOR);
|
|
|
|
md5.Update(file, Size(ML_BEHAVIOR));
|
2009-02-05 02:55:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
md5.Final(cksum);
|
|
|
|
}
|
|
|
|
|
2009-05-02 09:14:01 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Sets a sidedef's texture and prints a message if it's not present.
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2011-05-08 00:30:32 +00:00
|
|
|
static void SetTexture (side_t *side, int position, const char *name8, FMissingTextureTracker &track)
|
2009-05-02 09:14:01 +00:00
|
|
|
{
|
|
|
|
static const char *positionnames[] = { "top", "middle", "bottom" };
|
|
|
|
static const char *sidenames[] = { "first", "second" };
|
|
|
|
char name[9];
|
|
|
|
strncpy (name, name8, 8);
|
|
|
|
name[8] = 0;
|
|
|
|
FTextureID texture = TexMan.CheckForTexture (name, FTexture::TEX_Wall,
|
|
|
|
FTextureManager::TEXMAN_Overridable|FTextureManager::TEXMAN_TryAny);
|
|
|
|
|
|
|
|
if (!texture.Exists())
|
|
|
|
{
|
2011-05-08 00:30:32 +00:00
|
|
|
if (++track[name].Count <= MISSING_TEXTURE_WARN_LIMIT)
|
2009-05-02 09:14:01 +00:00
|
|
|
{
|
2011-05-08 00:30:32 +00:00
|
|
|
// Print an error that lists all references to this sidedef.
|
|
|
|
// We must scan the linedefs manually for all references to this sidedef.
|
|
|
|
for(int i = 0; i < numlines; i++)
|
2009-05-02 09:14:01 +00:00
|
|
|
{
|
2011-05-08 00:30:32 +00:00
|
|
|
for(int j = 0; j < 2; j++)
|
2009-05-02 09:14:01 +00:00
|
|
|
{
|
2011-05-08 00:30:32 +00:00
|
|
|
if (lines[i].sidedef[j] == side)
|
|
|
|
{
|
2011-05-08 00:35:17 +00:00
|
|
|
Printf(TEXTCOLOR_RED"Unknown %s texture '"
|
|
|
|
TEXTCOLOR_ORANGE "%s" TEXTCOLOR_RED
|
|
|
|
"' on %s side of linedef %d\n",
|
2011-05-08 00:30:32 +00:00
|
|
|
positionnames[position], name, sidenames[j], i);
|
|
|
|
}
|
2009-05-02 09:14:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
texture = TexMan.GetDefaultTexture();
|
|
|
|
}
|
|
|
|
side->SetTexture(position, texture);
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Sets a sidedef's texture and prints a message if it's not present.
|
|
|
|
// (Passing index separately is for UDMF which does not have sectors allocated yet)
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2011-05-08 00:30:32 +00:00
|
|
|
void SetTexture (sector_t *sector, int index, int position, const char *name8, FMissingTextureTracker &track)
|
2009-05-02 09:14:01 +00:00
|
|
|
{
|
|
|
|
static const char *positionnames[] = { "floor", "ceiling" };
|
|
|
|
char name[9];
|
|
|
|
strncpy (name, name8, 8);
|
|
|
|
name[8] = 0;
|
|
|
|
FTextureID texture = TexMan.CheckForTexture (name, FTexture::TEX_Flat,
|
|
|
|
FTextureManager::TEXMAN_Overridable|FTextureManager::TEXMAN_TryAny);
|
|
|
|
|
|
|
|
if (!texture.Exists())
|
|
|
|
{
|
2011-05-08 00:30:32 +00:00
|
|
|
if (++track[name].Count <= MISSING_TEXTURE_WARN_LIMIT)
|
|
|
|
{
|
2011-05-08 00:35:17 +00:00
|
|
|
Printf(TEXTCOLOR_RED"Unknown %s texture '"
|
|
|
|
TEXTCOLOR_ORANGE "%s" TEXTCOLOR_RED
|
|
|
|
"' in sector %d\n",
|
2011-05-08 00:30:32 +00:00
|
|
|
positionnames[position], name, index);
|
|
|
|
}
|
2009-05-02 09:14:01 +00:00
|
|
|
texture = TexMan.GetDefaultTexture();
|
|
|
|
}
|
|
|
|
sector->SetTexture(position, texture);
|
|
|
|
}
|
|
|
|
|
2011-05-08 00:30:32 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// SummarizeMissingTextures
|
|
|
|
//
|
|
|
|
// Lists textures that were missing more than MISSING_TEXTURE_WARN_LIMIT
|
|
|
|
// times.
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
static void SummarizeMissingTextures(const FMissingTextureTracker &missing)
|
|
|
|
{
|
|
|
|
FMissingTextureTracker::ConstIterator it(missing);
|
|
|
|
FMissingTextureTracker::ConstPair *pair;
|
|
|
|
|
|
|
|
while (it.NextPair(pair))
|
|
|
|
{
|
|
|
|
if (pair->Value.Count > MISSING_TEXTURE_WARN_LIMIT)
|
|
|
|
{
|
2011-05-08 00:35:17 +00:00
|
|
|
Printf(TEXTCOLOR_RED "Missing texture '"
|
|
|
|
TEXTCOLOR_ORANGE "%s" TEXTCOLOR_RED
|
|
|
|
"' is used %d more times\n",
|
2011-05-08 00:30:32 +00:00
|
|
|
pair->Key.GetChars(), pair->Value.Count - MISSING_TEXTURE_WARN_LIMIT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
2006-02-24 04:48:15 +00:00
|
|
|
// [RH] Figure out blends for deep water sectors
|
2006-06-14 15:56:56 +00:00
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-03-21 17:35:49 +00:00
|
|
|
static void SetTexture (side_t *side, int position, DWORD *blend, char *name8)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
char name[9];
|
|
|
|
strncpy (name, name8, 8);
|
|
|
|
name[8] = 0;
|
2008-06-15 18:36:26 +00:00
|
|
|
FTextureID texture;
|
2006-02-24 04:48:15 +00:00
|
|
|
if ((*blend = R_ColormapNumForName (name)) == 0)
|
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
texture = TexMan.CheckForTexture (name, FTexture::TEX_Wall,
|
|
|
|
FTextureManager::TEXMAN_Overridable|FTextureManager::TEXMAN_TryAny);
|
|
|
|
if (!texture.Exists())
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
char name2[9];
|
|
|
|
char *stop;
|
|
|
|
strncpy (name2, name, 8);
|
|
|
|
name2[8] = 0;
|
|
|
|
*blend = strtoul (name2, &stop, 16);
|
2008-06-15 18:36:26 +00:00
|
|
|
texture = FNullTextureID();
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*blend = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
texture = FNullTextureID();
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-03-21 17:35:49 +00:00
|
|
|
side->SetTexture(position, texture);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2011-01-29 11:09:38 +00:00
|
|
|
static void SetTextureNoErr (side_t *side, int position, DWORD *color, char *name8, bool *validcolor, bool isFog)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
char name[9];
|
2008-06-15 18:36:26 +00:00
|
|
|
FTextureID texture;
|
2006-02-24 04:48:15 +00:00
|
|
|
strncpy (name, name8, 8);
|
|
|
|
name[8] = 0;
|
2011-01-29 11:09:38 +00:00
|
|
|
*validcolor = false;
|
2008-06-15 18:36:26 +00:00
|
|
|
texture = TexMan.CheckForTexture (name, FTexture::TEX_Wall,
|
|
|
|
FTextureManager::TEXMAN_Overridable|FTextureManager::TEXMAN_TryAny);
|
|
|
|
if (!texture.Exists())
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
char name2[9];
|
|
|
|
char *stop;
|
2011-01-29 11:09:38 +00:00
|
|
|
strncpy (name2, name+1, 7);
|
|
|
|
name2[7] = 0;
|
|
|
|
if (*name != '#')
|
|
|
|
{
|
|
|
|
*color = strtoul (name, &stop, 16);
|
|
|
|
texture = FNullTextureID();
|
|
|
|
*validcolor = (*stop == 0) && (stop >= name + 2) && (stop <= name + 6);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else // Support for Legacy's color format!
|
|
|
|
{
|
|
|
|
int l=(int)strlen(name);
|
|
|
|
texture = FNullTextureID();
|
|
|
|
*validcolor = false;
|
|
|
|
if (l>=7)
|
|
|
|
{
|
|
|
|
for(stop=name2;stop<name2+6;stop++) if (!isxdigit(*stop)) *stop='0';
|
|
|
|
|
|
|
|
int factor = l==7? 0 : clamp<int> ((name2[6]&223)-'A', 0, 25);
|
|
|
|
|
|
|
|
name2[6]=0; int blue=strtol(name2+4,NULL,16);
|
|
|
|
name2[4]=0; int green=strtol(name2+2,NULL,16);
|
|
|
|
name2[2]=0; int red=strtol(name2,NULL,16);
|
|
|
|
|
|
|
|
if (!isFog)
|
|
|
|
{
|
|
|
|
if (factor==0)
|
|
|
|
{
|
|
|
|
*validcolor=false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
factor = factor * 255 / 25;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
factor=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
*color=MAKEARGB(factor, red, green, blue);
|
|
|
|
texture = FNullTextureID();
|
|
|
|
*validcolor = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2008-06-15 18:36:26 +00:00
|
|
|
texture = FNullTextureID();
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-03-21 17:35:49 +00:00
|
|
|
side->SetTexture(position, texture);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Sound enviroment handling
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
void P_FloodZone (sector_t *sec, int zonenum)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (sec->ZoneNumber == zonenum)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sec->ZoneNumber = zonenum;
|
|
|
|
|
|
|
|
for (i = 0; i < sec->linecount; ++i)
|
|
|
|
{
|
|
|
|
line_t *check = sec->lines[i];
|
|
|
|
sector_t *other;
|
|
|
|
|
2009-09-06 20:45:56 +00:00
|
|
|
if (check->sidedef[1] == NULL || (check->flags & ML_ZONEBOUNDARY))
|
2006-02-24 04:48:15 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (check->frontsector == sec)
|
2010-03-18 02:09:08 +00:00
|
|
|
{
|
|
|
|
assert(check->backsector != NULL);
|
2006-02-24 04:48:15 +00:00
|
|
|
other = check->backsector;
|
2010-03-18 02:09:08 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
else
|
2010-03-18 02:09:08 +00:00
|
|
|
{
|
|
|
|
assert(check->frontsector != NULL);
|
2006-02-24 04:48:15 +00:00
|
|
|
other = check->frontsector;
|
2010-03-18 02:09:08 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (other->ZoneNumber != zonenum)
|
|
|
|
P_FloodZone (other, zonenum);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void P_FloodZones ()
|
|
|
|
{
|
|
|
|
int z = 0, i;
|
2010-03-31 03:48:16 +00:00
|
|
|
ReverbContainer *reverb;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
for (i = 0; i < numsectors; ++i)
|
|
|
|
{
|
|
|
|
if (sectors[i].ZoneNumber == 0xFFFF)
|
|
|
|
{
|
|
|
|
P_FloodZone (§ors[i], z++);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
numzones = z;
|
|
|
|
zones = new zone_t[z];
|
2010-03-31 03:48:16 +00:00
|
|
|
reverb = S_FindEnvironment(level.DefaultEnvironment);
|
|
|
|
if (reverb == NULL)
|
|
|
|
{
|
|
|
|
Printf("Sound environment %d, %d not found\n", level.DefaultEnvironment >> 8, level.DefaultEnvironment & 255);
|
|
|
|
reverb = DefaultEnvironments[0];
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
for (i = 0; i < z; ++i)
|
|
|
|
{
|
2010-03-31 03:48:16 +00:00
|
|
|
zones[i].Environment = reverb;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
//===========================================================================
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
// P_LoadVertexes
|
|
|
|
//
|
2006-06-14 15:56:56 +00:00
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void P_LoadVertexes (MapData * map)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
// Determine number of vertices:
|
|
|
|
// total lump length / vertex record length.
|
2012-10-22 01:28:11 +00:00
|
|
|
numvertexes = map->Size(ML_VERTEXES) / sizeof(mapvertex_t);
|
2010-12-14 00:56:44 +00:00
|
|
|
numvertexdatas = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (numvertexes == 0)
|
|
|
|
{
|
|
|
|
I_Error ("Map has no vertices.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Allocate memory for buffer.
|
|
|
|
vertexes = new vertex_t[numvertexes];
|
2010-12-14 00:56:44 +00:00
|
|
|
vertexdatas = NULL;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
map->Seek(ML_VERTEXES);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// Copy and convert vertex coordinates, internal representation as fixed.
|
|
|
|
for (i = 0; i < numvertexes; i++)
|
|
|
|
{
|
|
|
|
SWORD x, y;
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
(*map->file) >> x >> y;
|
2006-02-24 04:48:15 +00:00
|
|
|
vertexes[i].x = x << FRACBITS;
|
|
|
|
vertexes[i].y = y << FRACBITS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
//===========================================================================
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
// P_LoadZSegs
|
|
|
|
//
|
2006-06-14 15:56:56 +00:00
|
|
|
//===========================================================================
|
|
|
|
|
2010-04-17 20:49:18 +00:00
|
|
|
void P_LoadZSegs (FileReaderBase &data)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
for (int i = 0; i < numsegs; ++i)
|
|
|
|
{
|
|
|
|
line_t *ldef;
|
|
|
|
DWORD v1, v2;
|
|
|
|
WORD line;
|
|
|
|
BYTE side;
|
|
|
|
|
|
|
|
data >> v1 >> v2 >> line >> side;
|
|
|
|
|
|
|
|
segs[i].v1 = &vertexes[v1];
|
|
|
|
segs[i].v2 = &vertexes[v2];
|
|
|
|
segs[i].linedef = ldef = &lines[line];
|
2009-09-06 20:45:56 +00:00
|
|
|
segs[i].sidedef = ldef->sidedef[side];
|
|
|
|
segs[i].frontsector = ldef->sidedef[side]->sector;
|
|
|
|
if (ldef->flags & ML_TWOSIDED && ldef->sidedef[side^1] != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-09-06 20:45:56 +00:00
|
|
|
segs[i].backsector = ldef->sidedef[side^1]->sector;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
segs[i].backsector = 0;
|
|
|
|
ldef->flags &= ~ML_TWOSIDED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
//===========================================================================
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
// P_LoadGLZSegs
|
|
|
|
//
|
|
|
|
// This is the GL nodes version of the above function.
|
|
|
|
//
|
2006-06-14 15:56:56 +00:00
|
|
|
//===========================================================================
|
|
|
|
|
2010-04-17 20:49:18 +00:00
|
|
|
void P_LoadGLZSegs (FileReaderBase &data, int type)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
for (int i = 0; i < numsubsectors; ++i)
|
|
|
|
{
|
|
|
|
for (size_t j = 0; j < subsectors[i].numlines; ++j)
|
|
|
|
{
|
|
|
|
seg_t *seg;
|
|
|
|
DWORD v1, partner;
|
2009-03-17 03:34:31 +00:00
|
|
|
DWORD line;
|
|
|
|
WORD lineword;
|
2006-02-24 04:48:15 +00:00
|
|
|
BYTE side;
|
|
|
|
|
2009-03-17 03:34:31 +00:00
|
|
|
data >> v1 >> partner;
|
2012-12-07 06:16:07 +00:00
|
|
|
if (type >= 2)
|
2009-03-17 03:34:31 +00:00
|
|
|
{
|
|
|
|
data >> line;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
data >> lineword;
|
|
|
|
line = lineword == 0xFFFF ? 0xFFFFFFFF : lineword;
|
|
|
|
}
|
|
|
|
data >> side;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-08-01 02:41:56 +00:00
|
|
|
seg = subsectors[i].firstline + j;
|
2006-02-24 04:48:15 +00:00
|
|
|
seg->v1 = &vertexes[v1];
|
|
|
|
if (j == 0)
|
|
|
|
{
|
|
|
|
seg[subsectors[i].numlines - 1].v2 = seg->v1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
seg[-1].v2 = seg->v1;
|
|
|
|
}
|
2010-08-27 15:20:05 +00:00
|
|
|
glsegextras[seg - segs].PartnerSeg = partner;
|
2009-03-17 03:34:31 +00:00
|
|
|
if (line != 0xFFFFFFFF)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
line_t *ldef;
|
|
|
|
|
|
|
|
seg->linedef = ldef = &lines[line];
|
2009-09-06 20:45:56 +00:00
|
|
|
seg->sidedef = ldef->sidedef[side];
|
|
|
|
seg->frontsector = ldef->sidedef[side]->sector;
|
|
|
|
if (ldef->flags & ML_TWOSIDED && ldef->sidedef[side^1] != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-09-06 20:45:56 +00:00
|
|
|
seg->backsector = ldef->sidedef[side^1]->sector;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
seg->backsector = 0;
|
|
|
|
ldef->flags &= ~ML_TWOSIDED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
seg->linedef = NULL;
|
|
|
|
seg->sidedef = NULL;
|
2010-08-01 02:41:56 +00:00
|
|
|
seg->frontsector = seg->backsector = subsectors[i].firstline->frontsector;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
//===========================================================================
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
// P_LoadZNodes
|
|
|
|
//
|
2006-06-14 15:56:56 +00:00
|
|
|
//===========================================================================
|
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
void LoadZNodes(FileReaderBase &data, int glnodes)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// Read extra vertices added during node building
|
|
|
|
DWORD orgVerts, newVerts;
|
|
|
|
vertex_t *newvertarray;
|
2010-04-17 20:49:18 +00:00
|
|
|
unsigned int i;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
data >> orgVerts >> newVerts;
|
2012-03-23 23:04:32 +00:00
|
|
|
if (orgVerts > (DWORD)numvertexes)
|
|
|
|
{ // These nodes are based on a map with more vertex data than we have.
|
|
|
|
// We can't use them.
|
|
|
|
throw CRecoverableError("Incorrect number of vertexes in nodes.\n");
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
if (orgVerts + newVerts == (DWORD)numvertexes)
|
|
|
|
{
|
|
|
|
newvertarray = vertexes;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newvertarray = new vertex_t[orgVerts + newVerts];
|
|
|
|
memcpy (newvertarray, vertexes, orgVerts * sizeof(vertex_t));
|
|
|
|
}
|
|
|
|
for (i = 0; i < newVerts; ++i)
|
|
|
|
{
|
|
|
|
data >> newvertarray[i + orgVerts].x >> newvertarray[i + orgVerts].y;
|
|
|
|
}
|
|
|
|
if (vertexes != newvertarray)
|
|
|
|
{
|
|
|
|
for (i = 0; i < (DWORD)numlines; ++i)
|
|
|
|
{
|
|
|
|
lines[i].v1 = lines[i].v1 - vertexes + newvertarray;
|
|
|
|
lines[i].v2 = lines[i].v2 - vertexes + newvertarray;
|
|
|
|
}
|
|
|
|
delete[] vertexes;
|
|
|
|
vertexes = newvertarray;
|
|
|
|
numvertexes = orgVerts + newVerts;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Read the subsectors
|
|
|
|
DWORD numSubs, currSeg;
|
|
|
|
|
|
|
|
data >> numSubs;
|
|
|
|
numsubsectors = numSubs;
|
|
|
|
subsectors = new subsector_t[numSubs];
|
|
|
|
memset (subsectors, 0, numsubsectors*sizeof(subsector_t));
|
|
|
|
|
|
|
|
for (i = currSeg = 0; i < numSubs; ++i)
|
|
|
|
{
|
|
|
|
DWORD numsegs;
|
|
|
|
|
|
|
|
data >> numsegs;
|
2010-08-01 02:41:56 +00:00
|
|
|
subsectors[i].firstline = (seg_t *)(size_t)currSeg; // Oh damn. I should have stored the seg count sooner.
|
2006-02-24 04:48:15 +00:00
|
|
|
subsectors[i].numlines = numsegs;
|
|
|
|
currSeg += numsegs;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Read the segs
|
|
|
|
DWORD numSegs;
|
|
|
|
|
|
|
|
data >> numSegs;
|
|
|
|
|
|
|
|
// The number of segs stored should match the number of
|
|
|
|
// segs used by subsectors.
|
|
|
|
if (numSegs != currSeg)
|
|
|
|
{
|
2012-03-23 23:04:32 +00:00
|
|
|
throw CRecoverableError("Incorrect number of segs in nodes.\n");
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
numsegs = numSegs;
|
|
|
|
segs = new seg_t[numsegs];
|
|
|
|
memset (segs, 0, numsegs*sizeof(seg_t));
|
2010-08-27 15:20:05 +00:00
|
|
|
glsegextras = NULL;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-08-01 02:41:56 +00:00
|
|
|
for (i = 0; i < numSubs; ++i)
|
|
|
|
{
|
|
|
|
subsectors[i].firstline = &segs[(size_t)subsectors[i].firstline];
|
|
|
|
}
|
|
|
|
|
2010-04-17 20:49:18 +00:00
|
|
|
if (glnodes == 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
P_LoadZSegs (data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
glsegextras = new glsegextra_t[numsegs];
|
2010-04-17 20:49:18 +00:00
|
|
|
P_LoadGLZSegs (data, glnodes);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Read nodes
|
|
|
|
DWORD numNodes;
|
|
|
|
|
|
|
|
data >> numNodes;
|
|
|
|
numnodes = numNodes;
|
|
|
|
nodes = new node_t[numNodes];
|
|
|
|
memset (nodes, 0, sizeof(node_t)*numNodes);
|
|
|
|
|
|
|
|
for (i = 0; i < numNodes; ++i)
|
|
|
|
{
|
2012-12-07 06:16:07 +00:00
|
|
|
if (glnodes < 3)
|
|
|
|
{
|
|
|
|
SWORD x, y, dx, dy;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2012-12-07 06:16:07 +00:00
|
|
|
data >> x >> y >> dx >> dy;
|
|
|
|
nodes[i].x = x << FRACBITS;
|
|
|
|
nodes[i].y = y << FRACBITS;
|
|
|
|
nodes[i].dx = dx << FRACBITS;
|
|
|
|
nodes[i].dy = dy << FRACBITS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
data >> nodes[i].x >> nodes[i].y >> nodes[i].dx >> nodes[i].dy;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
for (int j = 0; j < 2; ++j)
|
|
|
|
{
|
|
|
|
for (int k = 0; k < 4; ++k)
|
|
|
|
{
|
|
|
|
SWORD coord;
|
|
|
|
data >> coord;
|
|
|
|
nodes[i].bbox[j][k] = coord << FRACBITS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int m = 0; m < 2; ++m)
|
|
|
|
{
|
|
|
|
DWORD child;
|
|
|
|
data >> child;
|
|
|
|
if (child & 0x80000000)
|
|
|
|
{
|
|
|
|
nodes[i].children[m] = (BYTE *)&subsectors[child & 0x7FFFFFFF] + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nodes[i].children[m] = &nodes[child];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
void P_LoadZNodes (FileReader &dalump, DWORD id)
|
2010-04-17 20:49:18 +00:00
|
|
|
{
|
|
|
|
int type;
|
|
|
|
bool compressed;
|
|
|
|
|
|
|
|
switch (id)
|
|
|
|
{
|
|
|
|
case MAKE_ID('Z','N','O','D'):
|
|
|
|
type = 0;
|
|
|
|
compressed = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MAKE_ID('Z','G','L','N'):
|
|
|
|
type = 1;
|
|
|
|
compressed = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MAKE_ID('Z','G','L','2'):
|
|
|
|
type = 2;
|
|
|
|
compressed = true;
|
|
|
|
break;
|
|
|
|
|
2012-12-07 06:16:07 +00:00
|
|
|
case MAKE_ID('Z','G','L','3'):
|
|
|
|
type = 3;
|
|
|
|
compressed = true;
|
|
|
|
break;
|
|
|
|
|
2010-04-17 20:49:18 +00:00
|
|
|
case MAKE_ID('X','N','O','D'):
|
|
|
|
type = 0;
|
|
|
|
compressed = false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MAKE_ID('X','G','L','N'):
|
|
|
|
type = 1;
|
|
|
|
compressed = false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MAKE_ID('X','G','L','2'):
|
|
|
|
type = 2;
|
|
|
|
compressed = false;
|
|
|
|
break;
|
|
|
|
|
2012-12-07 06:16:07 +00:00
|
|
|
case MAKE_ID('X','G','L','3'):
|
|
|
|
type = 3;
|
|
|
|
compressed = false;
|
|
|
|
break;
|
|
|
|
|
2010-04-17 20:49:18 +00:00
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (compressed)
|
|
|
|
{
|
|
|
|
FileReaderZ data (dalump);
|
|
|
|
LoadZNodes(data, type);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LoadZNodes(dalump, type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-04-17 08:53:32 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// P_CheckV4Nodes
|
|
|
|
// http://www.sbsoftware.com/files/DeePBSPV4specs.txt
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
static bool P_CheckV4Nodes(MapData *map)
|
|
|
|
{
|
|
|
|
char header[8];
|
|
|
|
|
|
|
|
map->Read(ML_NODES, header, 8);
|
|
|
|
return !memcmp(header, "xNd4\0\0\0\0", 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
//===========================================================================
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
// P_LoadSegs
|
|
|
|
//
|
|
|
|
// killough 5/3/98: reformatted, cleaned up
|
2006-06-14 15:56:56 +00:00
|
|
|
//
|
|
|
|
//===========================================================================
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-08-29 03:52:02 +00:00
|
|
|
struct badseg
|
|
|
|
{
|
|
|
|
badseg(int t, int s, int d) : badtype(t), badsegnum(s), baddata(d) {}
|
|
|
|
int badtype;
|
|
|
|
int badsegnum;
|
|
|
|
int baddata;
|
|
|
|
};
|
|
|
|
|
2010-04-17 08:53:32 +00:00
|
|
|
template<class segtype>
|
2006-06-14 15:56:56 +00:00
|
|
|
void P_LoadSegs (MapData * map)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int i;
|
2006-09-14 00:02:31 +00:00
|
|
|
BYTE *data;
|
|
|
|
BYTE *vertchanged = new BYTE[numvertexes]; // phares 10/4/98
|
2006-02-24 04:48:15 +00:00
|
|
|
DWORD segangle;
|
|
|
|
line_t* line; // phares 10/4/98
|
|
|
|
int ptp_angle; // phares 10/4/98
|
|
|
|
int delta_angle; // phares 10/4/98
|
|
|
|
int dis; // phares 10/4/98
|
|
|
|
int dx,dy; // phares 10/4/98
|
|
|
|
int vnum1,vnum2; // phares 10/4/98
|
2012-10-22 01:28:11 +00:00
|
|
|
int lumplen = map->Size(ML_SEGS);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
memset (vertchanged,0,numvertexes); // phares 10/4/98
|
|
|
|
|
2010-04-17 08:53:32 +00:00
|
|
|
numsegs = lumplen / sizeof(segtype);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (numsegs == 0)
|
|
|
|
{
|
|
|
|
Printf ("This map has no segs.\n");
|
|
|
|
delete[] subsectors;
|
|
|
|
delete[] nodes;
|
2006-04-16 13:29:50 +00:00
|
|
|
delete[] vertchanged;
|
2006-02-24 04:48:15 +00:00
|
|
|
ForceNodeBuild = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
segs = new seg_t[numsegs];
|
|
|
|
memset (segs, 0, numsegs*sizeof(seg_t));
|
2006-06-14 15:56:56 +00:00
|
|
|
|
2006-09-14 00:02:31 +00:00
|
|
|
data = new BYTE[lumplen];
|
2006-06-14 15:56:56 +00:00
|
|
|
map->Read(ML_SEGS, data);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-08-01 02:41:56 +00:00
|
|
|
for (i = 0; i < numsubsectors; ++i)
|
|
|
|
{
|
|
|
|
subsectors[i].firstline = &segs[(size_t)subsectors[i].firstline];
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// phares: 10/4/98: Vertchanged is an array that represents the vertices.
|
|
|
|
// Mark those used by linedefs. A marked vertex is one that is not a
|
|
|
|
// candidate for movement further down.
|
|
|
|
|
|
|
|
line = lines;
|
|
|
|
for (i = 0; i < numlines ; i++, line++)
|
|
|
|
{
|
|
|
|
vertchanged[line->v1 - vertexes] = vertchanged[line->v2 - vertexes] = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
for (i = 0; i < numsegs; i++)
|
|
|
|
{
|
2010-04-17 08:53:32 +00:00
|
|
|
seg_t *li = segs + i;
|
|
|
|
segtype *ml = ((segtype *) data) + i;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
int side, linedef;
|
|
|
|
line_t *ldef;
|
|
|
|
|
2010-04-17 08:53:32 +00:00
|
|
|
vnum1 = ml->V1();
|
|
|
|
vnum2 = ml->V2();
|
2006-09-01 22:09:03 +00:00
|
|
|
|
|
|
|
if (vnum1 >= numvertexes || vnum2 >= numvertexes)
|
|
|
|
{
|
2010-08-29 03:52:02 +00:00
|
|
|
throw badseg(0, i, MAX(vnum1, vnum2));
|
2006-09-01 22:09:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
li->v1 = &vertexes[vnum1];
|
|
|
|
li->v2 = &vertexes[vnum2];
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
segangle = (WORD)LittleShort(ml->angle);
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
// phares 10/4/98: In the case of a lineseg that was created by splitting
|
|
|
|
// another line, it appears that the line angle is inherited from the
|
|
|
|
// father line. Due to roundoff, the new vertex may have been placed 'off
|
|
|
|
// the line'. When you get close to such a line, and it is very short,
|
|
|
|
// it's possible that the roundoff error causes 'firelines', the thin
|
|
|
|
// lines that can draw from screen top to screen bottom occasionally. This
|
|
|
|
// is due to all the angle calculations that are done based on the line
|
|
|
|
// angle, the angles from the viewer to the vertices, and the viewer's
|
|
|
|
// angle in the world. In the case of firelines, the rounded-off position
|
|
|
|
// of one of the vertices determines one of these angles, and introduces
|
|
|
|
// an error in the scaling factor for mapping textures and determining
|
|
|
|
// where on the screen the ceiling and floor spans should be shown. For a
|
|
|
|
// fireline, the engine thinks the ceiling bottom and floor top are at the
|
|
|
|
// midpoint of the screen. So you get ceilings drawn all the way down to the
|
|
|
|
// screen midpoint, and floors drawn all the way up. Thus 'firelines'. The
|
|
|
|
// name comes from the original sighting, which involved a fire texture.
|
|
|
|
//
|
|
|
|
// To correct this, reset the vertex that was added so that it sits ON the
|
|
|
|
// split line.
|
|
|
|
//
|
|
|
|
// To know which of the two vertices was added, its number is greater than
|
|
|
|
// that of the last of the author-created vertices. If both vertices of the
|
|
|
|
// line were added by splitting, pick the higher-numbered one. Once you've
|
|
|
|
// changed a vertex, don't change it again if it shows up in another seg.
|
|
|
|
//
|
|
|
|
// To determine if there's an error in the first place, find the
|
|
|
|
// angle of the line between the two seg vertices. If it's one degree or more
|
|
|
|
// off, then move one vertex. This may seem insignificant, but one degree
|
|
|
|
// errors _can_ cause firelines.
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
ptp_angle = R_PointToAngle2 (li->v1->x, li->v1->y, li->v2->x, li->v2->y);
|
|
|
|
dis = 0;
|
|
|
|
delta_angle = (abs(ptp_angle-(segangle<<16))>>ANGLETOFINESHIFT)*360/FINEANGLES;
|
|
|
|
|
|
|
|
if (delta_angle != 0)
|
|
|
|
{
|
|
|
|
segangle >>= (ANGLETOFINESHIFT-16);
|
|
|
|
dx = (li->v1->x - li->v2->x)>>FRACBITS;
|
|
|
|
dy = (li->v1->y - li->v2->y)>>FRACBITS;
|
|
|
|
dis = ((int) sqrt((double)(dx*dx + dy*dy)))<<FRACBITS;
|
|
|
|
dx = finecosine[segangle];
|
|
|
|
dy = finesine[segangle];
|
|
|
|
if ((vnum2 > vnum1) && (vertchanged[vnum2] == 0))
|
|
|
|
{
|
|
|
|
li->v2->x = li->v1->x + FixedMul(dis,dx);
|
|
|
|
li->v2->y = li->v1->y + FixedMul(dis,dy);
|
|
|
|
vertchanged[vnum2] = 1; // this was changed
|
|
|
|
}
|
|
|
|
else if (vertchanged[vnum1] == 0)
|
|
|
|
{
|
|
|
|
li->v1->x = li->v2->x - FixedMul(dis,dx);
|
|
|
|
li->v1->y = li->v2->y - FixedMul(dis,dy);
|
|
|
|
vertchanged[vnum1] = 1; // this was changed
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
linedef = LittleShort(ml->linedef);
|
|
|
|
if ((unsigned)linedef >= (unsigned)numlines)
|
|
|
|
{
|
2010-08-29 03:52:02 +00:00
|
|
|
throw badseg(1, i, linedef);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
ldef = &lines[linedef];
|
|
|
|
li->linedef = ldef;
|
|
|
|
side = LittleShort(ml->side);
|
2009-09-06 20:45:56 +00:00
|
|
|
if ((unsigned)(ldef->sidedef[side] - sides) >= (unsigned)numsides)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-08-29 03:52:02 +00:00
|
|
|
throw badseg(2, i, int(ldef->sidedef[side] - sides));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2009-09-06 20:45:56 +00:00
|
|
|
li->sidedef = ldef->sidedef[side];
|
|
|
|
li->frontsector = ldef->sidedef[side]->sector;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// killough 5/3/98: ignore 2s flag if second sidedef missing:
|
2009-09-06 20:45:56 +00:00
|
|
|
if (ldef->flags & ML_TWOSIDED && ldef->sidedef[side^1] != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-09-06 20:45:56 +00:00
|
|
|
li->backsector = ldef->sidedef[side^1]->sector;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
li->backsector = 0;
|
|
|
|
ldef->flags &= ~ML_TWOSIDED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-08-29 03:52:02 +00:00
|
|
|
catch (badseg bad)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-08-29 03:52:02 +00:00
|
|
|
switch (bad.badtype)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
case 0:
|
2010-08-29 03:52:02 +00:00
|
|
|
Printf ("Seg %d references a nonexistant vertex %d (max %d).\n", bad.badsegnum, bad.baddata, numvertexes);
|
2006-02-24 04:48:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2010-08-29 03:52:02 +00:00
|
|
|
Printf ("Seg %d references a nonexistant linedef %d (max %d).\n", bad.badsegnum, bad.baddata, numlines);
|
2006-02-24 04:48:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2010-08-29 03:52:02 +00:00
|
|
|
Printf ("The linedef for seg %d references a nonexistant sidedef %d (max %d).\n", bad.badsegnum, bad.baddata, numsides);
|
2006-02-24 04:48:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
Printf ("The BSP will be rebuilt.\n");
|
|
|
|
delete[] segs;
|
|
|
|
delete[] subsectors;
|
|
|
|
delete[] nodes;
|
|
|
|
ForceNodeBuild = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
delete[] vertchanged; // phares 10/4/98
|
2006-06-14 15:56:56 +00:00
|
|
|
delete[] data;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
//===========================================================================
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
// P_LoadSubsectors
|
|
|
|
//
|
2006-06-14 15:56:56 +00:00
|
|
|
//===========================================================================
|
|
|
|
|
2010-04-17 08:53:32 +00:00
|
|
|
template<class subsectortype, class segtype>
|
2006-06-14 15:56:56 +00:00
|
|
|
void P_LoadSubsectors (MapData * map)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int i;
|
2010-04-17 08:53:32 +00:00
|
|
|
DWORD maxseg = map->Size(ML_SEGS) / sizeof(segtype);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2012-10-22 01:28:11 +00:00
|
|
|
numsubsectors = map->Size(ML_SSECTORS) / sizeof(subsectortype);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
if (numsubsectors == 0 || maxseg == 0 )
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
Printf ("This map has an incomplete BSP tree.\n");
|
|
|
|
delete[] nodes;
|
|
|
|
ForceNodeBuild = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
subsectors = new subsector_t[numsubsectors];
|
2006-06-14 15:56:56 +00:00
|
|
|
map->Seek(ML_SSECTORS);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
memset (subsectors, 0, numsubsectors*sizeof(subsector_t));
|
|
|
|
|
|
|
|
for (i = 0; i < numsubsectors; i++)
|
|
|
|
{
|
2010-04-17 08:53:32 +00:00
|
|
|
subsectortype subd;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-04-17 08:53:32 +00:00
|
|
|
(*map->file) >> subd.numsegs >> subd.firstseg;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-04-17 08:53:32 +00:00
|
|
|
if (subd.numsegs == 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
Printf ("Subsector %i is empty.\n", i);
|
|
|
|
delete[] subsectors;
|
|
|
|
delete[] nodes;
|
|
|
|
ForceNodeBuild = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-04-17 08:53:32 +00:00
|
|
|
subsectors[i].numlines = subd.numsegs;
|
2010-08-01 02:41:56 +00:00
|
|
|
subsectors[i].firstline = (seg_t *)(size_t)subd.firstseg;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-08-01 02:41:56 +00:00
|
|
|
if ((size_t)subsectors[i].firstline >= maxseg)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-09-14 00:02:31 +00:00
|
|
|
Printf ("Subsector %d contains invalid segs %u-%u\n"
|
2010-08-14 21:01:49 +00:00
|
|
|
"The BSP will be rebuilt.\n", i, (unsigned)((size_t)subsectors[i].firstline),
|
|
|
|
(unsigned)((size_t)subsectors[i].firstline) + subsectors[i].numlines - 1);
|
2006-02-24 04:48:15 +00:00
|
|
|
ForceNodeBuild = true;
|
|
|
|
delete[] nodes;
|
|
|
|
delete[] subsectors;
|
|
|
|
break;
|
|
|
|
}
|
2010-08-01 02:41:56 +00:00
|
|
|
else if ((size_t)subsectors[i].firstline + subsectors[i].numlines > maxseg)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-09-14 00:02:31 +00:00
|
|
|
Printf ("Subsector %d contains invalid segs %u-%u\n"
|
2006-02-24 04:48:15 +00:00
|
|
|
"The BSP will be rebuilt.\n", i, maxseg,
|
2010-08-14 21:01:49 +00:00
|
|
|
(unsigned)((size_t)subsectors[i].firstline) + subsectors[i].numlines - 1);
|
2006-02-24 04:48:15 +00:00
|
|
|
ForceNodeBuild = true;
|
|
|
|
delete[] nodes;
|
|
|
|
delete[] subsectors;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
//===========================================================================
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
// P_LoadSectors
|
|
|
|
//
|
2006-06-14 15:56:56 +00:00
|
|
|
//===========================================================================
|
|
|
|
|
2011-05-08 00:30:32 +00:00
|
|
|
void P_LoadSectors (MapData *map, FMissingTextureTracker &missingtex)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
char fname[9];
|
|
|
|
int i;
|
2006-06-14 15:56:56 +00:00
|
|
|
char *msp;
|
|
|
|
mapsector_t *ms;
|
2006-02-24 04:48:15 +00:00
|
|
|
sector_t* ss;
|
|
|
|
int defSeqType;
|
|
|
|
FDynamicColormap *fogMap, *normMap;
|
2006-06-14 15:56:56 +00:00
|
|
|
int lumplen = map->Size(ML_SECTORS);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
numsectors = lumplen / sizeof(mapsector_t);
|
2006-02-24 04:48:15 +00:00
|
|
|
sectors = new sector_t[numsectors];
|
|
|
|
memset (sectors, 0, numsectors*sizeof(sector_t));
|
|
|
|
|
|
|
|
if (level.flags & LEVEL_SNDSEQTOTALCTRL)
|
|
|
|
defSeqType = 0;
|
|
|
|
else
|
|
|
|
defSeqType = -1;
|
|
|
|
|
|
|
|
fogMap = normMap = NULL;
|
|
|
|
fname[8] = 0;
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
msp = new char[lumplen];
|
|
|
|
map->Read(ML_SECTORS, msp);
|
|
|
|
ms = (mapsector_t*)msp;
|
2006-02-24 04:48:15 +00:00
|
|
|
ss = sectors;
|
2008-03-18 18:18:18 +00:00
|
|
|
|
|
|
|
// Extended properties
|
|
|
|
sectors[0].e = new extsector_t[numsectors];
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
for (i = 0; i < numsectors; i++, ss++, ms++)
|
|
|
|
{
|
2008-03-18 18:18:18 +00:00
|
|
|
ss->e = §ors[0].e[i];
|
2008-05-22 19:35:38 +00:00
|
|
|
if (!map->HasBehavior) ss->Flags |= SECF_FLOORDROP;
|
2008-08-16 20:19:35 +00:00
|
|
|
ss->SetPlaneTexZ(sector_t::floor, LittleShort(ms->floorheight)<<FRACBITS);
|
|
|
|
ss->floorplane.d = -ss->GetPlaneTexZ(sector_t::floor);
|
2006-02-24 04:48:15 +00:00
|
|
|
ss->floorplane.c = FRACUNIT;
|
|
|
|
ss->floorplane.ic = FRACUNIT;
|
2008-08-16 20:19:35 +00:00
|
|
|
ss->SetPlaneTexZ(sector_t::ceiling, LittleShort(ms->ceilingheight)<<FRACBITS);
|
|
|
|
ss->ceilingplane.d = ss->GetPlaneTexZ(sector_t::ceiling);
|
2006-02-24 04:48:15 +00:00
|
|
|
ss->ceilingplane.c = -FRACUNIT;
|
|
|
|
ss->ceilingplane.ic = -FRACUNIT;
|
2011-05-08 00:30:32 +00:00
|
|
|
SetTexture(ss, i, sector_t::floor, ms->floorpic, missingtex);
|
|
|
|
SetTexture(ss, i, sector_t::ceiling, ms->ceilingpic, missingtex);
|
2011-06-11 23:58:33 +00:00
|
|
|
ss->lightlevel = LittleShort(ms->lightlevel);
|
2006-06-14 15:56:56 +00:00
|
|
|
if (map->HasBehavior)
|
2006-02-24 04:48:15 +00:00
|
|
|
ss->special = LittleShort(ms->special);
|
|
|
|
else // [RH] Translate to new sector special
|
|
|
|
ss->special = P_TranslateSectorSpecial (LittleShort(ms->special));
|
2009-08-30 10:43:51 +00:00
|
|
|
ss->secretsector = !!(ss->special&SECRET_MASK);
|
2006-02-24 04:48:15 +00:00
|
|
|
ss->tag = LittleShort(ms->tag);
|
|
|
|
ss->thinglist = NULL;
|
|
|
|
ss->touching_thinglist = NULL; // phares 3/14/98
|
|
|
|
ss->seqType = defSeqType;
|
2010-08-07 04:32:18 +00:00
|
|
|
ss->SeqName = NAME_None;
|
2006-02-24 04:48:15 +00:00
|
|
|
ss->nextsec = -1; //jff 2/26/98 add fields to support locking out
|
|
|
|
ss->prevsec = -1; // stair retriggering until build completes
|
|
|
|
|
2010-11-08 20:18:06 +00:00
|
|
|
ss->SetAlpha(sector_t::floor, FRACUNIT);
|
2010-11-07 16:17:14 +00:00
|
|
|
ss->SetAlpha(sector_t::ceiling, FRACUNIT);
|
2008-06-14 15:26:16 +00:00
|
|
|
ss->SetXScale(sector_t::floor, FRACUNIT); // [RH] floor and ceiling scaling
|
|
|
|
ss->SetYScale(sector_t::floor, FRACUNIT);
|
|
|
|
ss->SetXScale(sector_t::ceiling, FRACUNIT);
|
|
|
|
ss->SetYScale(sector_t::ceiling, FRACUNIT);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
ss->heightsec = NULL; // sector used to get floor and ceiling height
|
|
|
|
// killough 3/7/98: end changes
|
|
|
|
|
|
|
|
ss->gravity = 1.f; // [RH] Default sector gravity of 1.0
|
|
|
|
ss->ZoneNumber = 0xFFFF;
|
|
|
|
|
|
|
|
// [RH] Sectors default to white light with the default fade.
|
|
|
|
// If they are outside (have a sky ceiling), they use the outside fog.
|
2008-08-16 20:19:35 +00:00
|
|
|
if (level.outsidefog != 0xff000000 && (ss->GetTexture(sector_t::ceiling) == skyflatnum || (ss->special&0xff) == Sector_Outside))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (fogMap == NULL)
|
|
|
|
fogMap = GetSpecialLights (PalEntry (255,255,255), level.outsidefog, 0);
|
|
|
|
ss->ColorMap = fogMap;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (normMap == NULL)
|
|
|
|
normMap = GetSpecialLights (PalEntry (255,255,255), level.fadeto, NormalLight.Desaturate);
|
|
|
|
ss->ColorMap = normMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
// killough 8/28/98: initialize all sectors to normal friction
|
|
|
|
ss->friction = ORIG_FRICTION;
|
|
|
|
ss->movefactor = ORIG_FRICTION_FACTOR;
|
2009-01-04 15:00:29 +00:00
|
|
|
ss->sectornum = i;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-06-14 15:56:56 +00:00
|
|
|
delete[] msp;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
//===========================================================================
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
// P_LoadNodes
|
|
|
|
//
|
2006-06-14 15:56:56 +00:00
|
|
|
//===========================================================================
|
|
|
|
|
2010-04-17 08:53:32 +00:00
|
|
|
template<class nodetype, class subsectortype>
|
2006-06-14 15:56:56 +00:00
|
|
|
void P_LoadNodes (MapData * map)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
FMemLump data;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int k;
|
2006-06-14 15:56:56 +00:00
|
|
|
char *mnp;
|
2010-04-17 08:53:32 +00:00
|
|
|
nodetype *mn;
|
2006-02-24 04:48:15 +00:00
|
|
|
node_t* no;
|
|
|
|
WORD* used;
|
2006-06-14 15:56:56 +00:00
|
|
|
int lumplen = map->Size(ML_NODES);
|
2010-04-17 08:53:32 +00:00
|
|
|
int maxss = map->Size(ML_SSECTORS) / sizeof(subsectortype);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-04-17 08:53:32 +00:00
|
|
|
numnodes = (lumplen - nodetype::NF_LUMPOFFSET) / sizeof(nodetype);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if ((numnodes == 0 && maxss != 1) || maxss == 0)
|
|
|
|
{
|
|
|
|
ForceNodeBuild = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nodes = new node_t[numnodes];
|
|
|
|
used = (WORD *)alloca (sizeof(WORD)*numnodes);
|
|
|
|
memset (used, 0, sizeof(WORD)*numnodes);
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
mnp = new char[lumplen];
|
2010-04-17 08:53:32 +00:00
|
|
|
mn = (nodetype*)(mnp + nodetype::NF_LUMPOFFSET);
|
|
|
|
map->Read(ML_NODES, mnp);
|
2006-02-24 04:48:15 +00:00
|
|
|
no = nodes;
|
|
|
|
|
|
|
|
for (i = 0; i < numnodes; i++, no++, mn++)
|
|
|
|
{
|
|
|
|
no->x = LittleShort(mn->x)<<FRACBITS;
|
|
|
|
no->y = LittleShort(mn->y)<<FRACBITS;
|
|
|
|
no->dx = LittleShort(mn->dx)<<FRACBITS;
|
|
|
|
no->dy = LittleShort(mn->dy)<<FRACBITS;
|
|
|
|
for (j = 0; j < 2; j++)
|
|
|
|
{
|
2010-04-17 08:53:32 +00:00
|
|
|
int child = mn->Child(j);
|
|
|
|
if (child & nodetype::NF_SUBSECTOR)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-04-17 08:53:32 +00:00
|
|
|
child &= ~nodetype::NF_SUBSECTOR;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (child >= maxss)
|
|
|
|
{
|
|
|
|
Printf ("BSP node %d references invalid subsector %d.\n"
|
|
|
|
"The BSP will be rebuilt.\n", i, child);
|
|
|
|
ForceNodeBuild = true;
|
|
|
|
delete[] nodes;
|
2006-06-14 15:56:56 +00:00
|
|
|
delete[] mnp;
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
no->children[j] = (BYTE *)&subsectors[child] + 1;
|
|
|
|
}
|
|
|
|
else if (child >= numnodes)
|
|
|
|
{
|
2008-05-14 03:39:30 +00:00
|
|
|
Printf ("BSP node %d references invalid node %td.\n"
|
2006-02-24 04:48:15 +00:00
|
|
|
"The BSP will be rebuilt.\n", i, (node_t *)no->children[j] - nodes);
|
|
|
|
ForceNodeBuild = true;
|
|
|
|
delete[] nodes;
|
2006-06-14 15:56:56 +00:00
|
|
|
delete[] mnp;
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (used[child])
|
|
|
|
{
|
|
|
|
Printf ("BSP node %d references node %d,\n"
|
|
|
|
"which is already used by node %d.\n"
|
|
|
|
"The BSP will be rebuilt.\n", i, child, used[child]-1);
|
|
|
|
ForceNodeBuild = true;
|
|
|
|
delete[] nodes;
|
2006-06-14 15:56:56 +00:00
|
|
|
delete[] mnp;
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
no->children[j] = &nodes[child];
|
|
|
|
used[child] = j + 1;
|
|
|
|
}
|
|
|
|
for (k = 0; k < 4; k++)
|
|
|
|
{
|
|
|
|
no->bbox[j][k] = LittleShort(mn->bbox[j][k])<<FRACBITS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-06-14 15:56:56 +00:00
|
|
|
delete[] mnp;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-04-05 12:14:33 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// SpawnMapThing
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
CVAR(Bool, dumpspawnedthings, false, 0)
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
void SpawnMapThing(int index, FMapThing *mt, int position)
|
2008-04-05 12:14:33 +00:00
|
|
|
{
|
|
|
|
AActor *spawned = P_SpawnMapThing(mt, position);
|
|
|
|
if (dumpspawnedthings)
|
|
|
|
{
|
|
|
|
Printf("%5d: (%5d, %5d, %5d), doomednum = %5d, flags = %04x, type = %s\n",
|
2008-05-08 08:06:26 +00:00
|
|
|
index, mt->x>>FRACBITS, mt->y>>FRACBITS, mt->z>>FRACBITS, mt->type, mt->flags,
|
2008-04-05 12:14:33 +00:00
|
|
|
spawned? spawned->GetClass()->TypeName.GetChars() : "(none)");
|
|
|
|
}
|
2011-01-29 11:09:38 +00:00
|
|
|
T_AddSpawnedThing(spawned);
|
2008-04-05 12:14:33 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
//===========================================================================
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
// P_LoadThings
|
|
|
|
//
|
2006-06-14 15:56:56 +00:00
|
|
|
//===========================================================================
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
WORD MakeSkill(int flags)
|
|
|
|
{
|
|
|
|
WORD res = 0;
|
|
|
|
if (flags & 1) res |= 1+2;
|
|
|
|
if (flags & 2) res |= 4;
|
|
|
|
if (flags & 4) res |= 8+16;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
void P_LoadThings (MapData * map)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-06-14 15:56:56 +00:00
|
|
|
int lumplen = map->Size(ML_THINGS);
|
|
|
|
int numthings = lumplen / sizeof(mapthing_t);
|
|
|
|
|
|
|
|
char *mtp;
|
|
|
|
mapthing_t *mt;
|
|
|
|
|
|
|
|
mtp = new char[lumplen];
|
|
|
|
map->Read(ML_THINGS, mtp);
|
|
|
|
mt = (mapthing_t*)mtp;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
MapThingsConverted.Resize(numthings);
|
|
|
|
FMapThing *mti = &MapThingsConverted[0];
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// [RH] ZDoom now uses Hexen-style maps as its native format.
|
|
|
|
// Since this is the only place where Doom-style Things are ever
|
|
|
|
// referenced, we translate them into a Hexen-style thing.
|
2006-06-14 15:56:56 +00:00
|
|
|
for (int i=0 ; i < numthings; i++, mt++)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// [RH] At this point, monsters unique to Doom II were weeded out
|
|
|
|
// if the IWAD wasn't for Doom II. R_SpawnMapThing() can now
|
|
|
|
// handle these and more cases better, so we just pass it
|
|
|
|
// everything and let it decide what to do with them.
|
|
|
|
|
|
|
|
// [RH] Need to translate the spawn flags to Hexen format.
|
|
|
|
short flags = LittleShort(mt->options);
|
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
memset (&mti[i], 0, sizeof(mti[i]));
|
2008-05-11 21:16:32 +00:00
|
|
|
|
2011-02-02 02:07:36 +00:00
|
|
|
mti[i].Conversation = 0;
|
2008-05-30 06:56:50 +00:00
|
|
|
mti[i].SkillFilter = MakeSkill(flags);
|
|
|
|
mti[i].ClassFilter = 0xffff; // Doom map format doesn't have class flags so spawn for all player classes
|
2008-05-11 21:16:32 +00:00
|
|
|
flags &= ~MTF_SKILLMASK;
|
2008-05-30 06:56:50 +00:00
|
|
|
mti[i].flags = (short)((flags & 0xf) | 0x7e0);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (gameinfo.gametype == GAME_Strife)
|
|
|
|
{
|
2008-05-30 06:56:50 +00:00
|
|
|
mti[i].flags &= ~MTF_AMBUSH;
|
|
|
|
if (flags & STF_SHADOW) mti[i].flags |= MTF_SHADOW;
|
|
|
|
if (flags & STF_ALTSHADOW) mti[i].flags |= MTF_ALTSHADOW;
|
|
|
|
if (flags & STF_STANDSTILL) mti[i].flags |= MTF_STANDSTILL;
|
|
|
|
if (flags & STF_AMBUSH) mti[i].flags |= MTF_AMBUSH;
|
|
|
|
if (flags & STF_FRIENDLY) mti[i].flags |= MTF_FRIENDLY;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (flags & BTF_BADEDITORCHECK)
|
|
|
|
{
|
|
|
|
flags &= 0x1F;
|
|
|
|
}
|
2008-05-30 06:56:50 +00:00
|
|
|
if (flags & BTF_NOTDEATHMATCH) mti[i].flags &= ~MTF_DEATHMATCH;
|
|
|
|
if (flags & BTF_NOTCOOPERATIVE) mti[i].flags &= ~MTF_COOPERATIVE;
|
|
|
|
if (flags & BTF_FRIENDLY) mti[i].flags |= MTF_FRIENDLY;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-05-30 06:56:50 +00:00
|
|
|
if (flags & BTF_NOTSINGLE) mti[i].flags &= ~MTF_SINGLE;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
mti[i].x = LittleShort(mt->x) << FRACBITS;
|
|
|
|
mti[i].y = LittleShort(mt->y) << FRACBITS;
|
|
|
|
mti[i].angle = LittleShort(mt->angle);
|
|
|
|
mti[i].type = LittleShort(mt->type);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-06-14 15:56:56 +00:00
|
|
|
delete [] mtp;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
2006-02-24 04:48:15 +00:00
|
|
|
// [RH]
|
|
|
|
// P_LoadThings2
|
|
|
|
//
|
|
|
|
// Same as P_LoadThings() except it assumes Things are
|
|
|
|
// saved Hexen-style. Position also controls which single-
|
|
|
|
// player start spots are spawned by filtering out those
|
|
|
|
// whose first parameter don't match position.
|
|
|
|
//
|
2006-06-14 15:56:56 +00:00
|
|
|
//===========================================================================
|
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
void P_LoadThings2 (MapData * map)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2012-10-22 01:28:11 +00:00
|
|
|
int lumplen = map->Size(ML_THINGS);
|
2008-05-08 08:06:26 +00:00
|
|
|
int numthings = lumplen / sizeof(mapthinghexen_t);
|
2006-06-14 15:56:56 +00:00
|
|
|
|
|
|
|
char *mtp;
|
2008-05-08 08:06:26 +00:00
|
|
|
|
|
|
|
MapThingsConverted.Resize(numthings);
|
|
|
|
FMapThing *mti = &MapThingsConverted[0];
|
2006-06-14 15:56:56 +00:00
|
|
|
|
|
|
|
mtp = new char[lumplen];
|
|
|
|
map->Read(ML_THINGS, mtp);
|
2008-05-08 08:06:26 +00:00
|
|
|
mapthinghexen_t *mth = (mapthinghexen_t*)mtp;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-05-08 08:06:26 +00:00
|
|
|
for(int i = 0; i< numthings; i++)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-05-12 08:31:29 +00:00
|
|
|
mti[i].thingid = LittleShort(mth[i].thingid);
|
2008-05-11 21:16:32 +00:00
|
|
|
mti[i].x = LittleShort(mth[i].x)<<FRACBITS;
|
|
|
|
mti[i].y = LittleShort(mth[i].y)<<FRACBITS;
|
|
|
|
mti[i].z = LittleShort(mth[i].z)<<FRACBITS;
|
|
|
|
mti[i].angle = LittleShort(mth[i].angle);
|
|
|
|
mti[i].type = LittleShort(mth[i].type);
|
|
|
|
mti[i].flags = LittleShort(mth[i].flags);
|
|
|
|
mti[i].special = mth[i].special;
|
|
|
|
for(int j=0;j<5;j++) mti[i].args[j] = mth[i].args[j];
|
|
|
|
mti[i].SkillFilter = MakeSkill(mti[i].flags);
|
|
|
|
mti[i].ClassFilter = (mti[i].flags & MTF_CLASS_MASK) >> MTF_CLASS_SHIFT;
|
|
|
|
mti[i].flags &= ~(MTF_SKILLMASK|MTF_CLASS_MASK);
|
2011-02-02 02:07:36 +00:00
|
|
|
mti[i].Conversation = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-05-08 08:06:26 +00:00
|
|
|
delete[] mtp;
|
2008-05-30 06:56:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void P_SpawnThings (int position)
|
|
|
|
{
|
|
|
|
int numthings = MapThingsConverted.Size();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
for (int i=0; i < numthings; i++)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-05-30 06:56:50 +00:00
|
|
|
SpawnMapThing (i, &MapThingsConverted[i], position);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-06-10 09:16:01 +00:00
|
|
|
for(int i=0; i<MAXPLAYERS; i++)
|
|
|
|
{
|
2008-06-15 23:09:01 +00:00
|
|
|
if (playeringame[i] && players[i].mo != NULL)
|
2008-06-10 09:16:01 +00:00
|
|
|
P_PlayerStartStomp(players[i].mo);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
//===========================================================================
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
// P_LoadLineDefs
|
|
|
|
//
|
|
|
|
// killough 4/4/98: split into two functions, to allow sidedef overloading
|
|
|
|
//
|
|
|
|
// [RH] Actually split into four functions to allow for Hexen and Doom
|
|
|
|
// linedefs.
|
2006-06-14 15:56:56 +00:00
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
void P_AdjustLine (line_t *ld)
|
|
|
|
{
|
|
|
|
vertex_t *v1, *v2;
|
|
|
|
|
|
|
|
v1 = ld->v1;
|
|
|
|
v2 = ld->v2;
|
|
|
|
|
|
|
|
ld->dx = v2->x - v1->x;
|
|
|
|
ld->dy = v2->y - v1->y;
|
|
|
|
|
|
|
|
if (ld->dx == 0)
|
|
|
|
ld->slopetype = ST_VERTICAL;
|
|
|
|
else if (ld->dy == 0)
|
|
|
|
ld->slopetype = ST_HORIZONTAL;
|
|
|
|
else
|
|
|
|
ld->slopetype = ((ld->dy ^ ld->dx) >= 0) ? ST_POSITIVE : ST_NEGATIVE;
|
|
|
|
|
|
|
|
if (v1->x < v2->x)
|
|
|
|
{
|
|
|
|
ld->bbox[BOXLEFT] = v1->x;
|
|
|
|
ld->bbox[BOXRIGHT] = v2->x;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ld->bbox[BOXLEFT] = v2->x;
|
|
|
|
ld->bbox[BOXRIGHT] = v1->x;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (v1->y < v2->y)
|
|
|
|
{
|
|
|
|
ld->bbox[BOXBOTTOM] = v1->y;
|
|
|
|
ld->bbox[BOXTOP] = v2->y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ld->bbox[BOXBOTTOM] = v2->y;
|
|
|
|
ld->bbox[BOXTOP] = v1->y;
|
|
|
|
}
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
void P_SetLineID (line_t *ld)
|
|
|
|
{
|
2006-02-24 04:48:15 +00:00
|
|
|
// [RH] Set line id (as appropriate) here
|
2006-05-11 17:56:35 +00:00
|
|
|
// for Doom format maps this must be done in P_TranslateLineDef because
|
|
|
|
// the tag doesn't always go into the first arg.
|
2011-01-29 11:09:38 +00:00
|
|
|
if (level.maptype == MAPTYPE_HEXEN)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-08-24 19:19:15 +00:00
|
|
|
switch (ld->special)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-08-24 19:19:15 +00:00
|
|
|
case Line_SetIdentification:
|
2009-02-03 19:11:43 +00:00
|
|
|
if (!(level.flags2 & LEVEL2_HEXENHACK))
|
2008-06-16 22:38:23 +00:00
|
|
|
{
|
|
|
|
ld->id = ld->args[0] + 256 * ld->args[4];
|
|
|
|
ld->flags |= ld->args[1]<<16;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ld->id = ld->args[0];
|
|
|
|
}
|
2010-12-15 00:14:42 +00:00
|
|
|
ld->special = 0;
|
2006-08-24 19:19:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TranslucentLine:
|
2006-05-11 17:56:35 +00:00
|
|
|
ld->id = ld->args[0];
|
|
|
|
ld->flags |= ld->args[3]<<16;
|
2006-08-24 19:19:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Teleport_Line:
|
|
|
|
case Scroll_Texture_Model:
|
2006-02-24 04:48:15 +00:00
|
|
|
ld->id = ld->args[0];
|
2006-08-24 19:19:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Polyobj_StartLine:
|
|
|
|
ld->id = ld->args[3];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Polyobj_ExplicitLine:
|
|
|
|
ld->id = ld->args[4];
|
|
|
|
break;
|
2010-01-28 23:46:38 +00:00
|
|
|
|
|
|
|
case Plane_Align:
|
|
|
|
ld->id = ld->args[2];
|
|
|
|
break;
|
|
|
|
|
2008-03-20 21:12:03 +00:00
|
|
|
case Static_Init:
|
|
|
|
if (ld->args[1] == Init_SectorLink) ld->id = ld->args[0];
|
|
|
|
break;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void P_SaveLineSpecial (line_t *ld)
|
|
|
|
{
|
2009-09-06 20:45:56 +00:00
|
|
|
if (ld->sidedef[0] == NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
|
2009-09-06 20:45:56 +00:00
|
|
|
DWORD sidenum = DWORD(ld->sidedef[0]-sides);
|
2006-02-24 04:48:15 +00:00
|
|
|
// killough 4/4/98: support special sidedef interpretation below
|
2009-09-06 20:45:56 +00:00
|
|
|
// [RH] Save Static_Init only if it's interested in the textures
|
|
|
|
if (ld->special != Static_Init || ld->args[1] == Init_Color)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-09-06 20:45:56 +00:00
|
|
|
sidetemp[sidenum].a.special = ld->special;
|
|
|
|
sidetemp[sidenum].a.tag = ld->args[0];
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-09-06 20:45:56 +00:00
|
|
|
sidetemp[sidenum].a.special = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
void P_FinishLoadingLineDef(line_t *ld, int alpha)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-09-06 18:09:41 +00:00
|
|
|
bool additive = false;
|
|
|
|
|
2009-09-06 20:45:56 +00:00
|
|
|
ld->frontsector = ld->sidedef[0] != NULL ? ld->sidedef[0]->sector : NULL;
|
|
|
|
ld->backsector = ld->sidedef[1] != NULL ? ld->sidedef[1]->sector : NULL;
|
2010-11-07 14:39:09 +00:00
|
|
|
double dx = FIXED2DBL(ld->v2->x - ld->v1->x);
|
|
|
|
double dy = FIXED2DBL(ld->v2->y - ld->v1->y);
|
2009-05-15 10:39:40 +00:00
|
|
|
int linenum = int(ld-lines);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
if (ld->frontsector == NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-05-11 21:16:32 +00:00
|
|
|
Printf ("Line %d has no front sector\n", linemap[linenum]);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
// [RH] Set some new sidedef properties
|
2010-11-07 14:39:09 +00:00
|
|
|
int len = (int)(sqrt (dx*dx + dy*dy) + 0.5f);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-09-06 20:45:56 +00:00
|
|
|
if (ld->sidedef[0] != NULL)
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
2009-09-06 20:45:56 +00:00
|
|
|
ld->sidedef[0]->linedef = ld;
|
|
|
|
ld->sidedef[0]->TexelLength = len;
|
2008-09-06 18:09:41 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
2009-09-06 20:45:56 +00:00
|
|
|
if (ld->sidedef[1] != NULL)
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
2009-09-06 20:45:56 +00:00
|
|
|
ld->sidedef[1]->linedef = ld;
|
|
|
|
ld->sidedef[1]->TexelLength = len;
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
switch (ld->special)
|
|
|
|
{ // killough 4/11/98: handle special types
|
|
|
|
int j;
|
|
|
|
|
|
|
|
case TranslucentLine: // killough 4/11/98: translucent 2s textures
|
|
|
|
// [RH] Second arg controls how opaque it is.
|
2009-08-29 03:33:36 +00:00
|
|
|
if (alpha == SHRT_MIN)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-05-11 21:16:32 +00:00
|
|
|
alpha = ld->args[1];
|
2008-09-06 18:09:41 +00:00
|
|
|
additive = !!ld->args[2];
|
|
|
|
}
|
|
|
|
else if (alpha < 0)
|
|
|
|
{
|
|
|
|
alpha = -alpha;
|
|
|
|
additive = true;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-09-06 18:09:41 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
alpha = Scale(alpha, FRACUNIT, 255);
|
|
|
|
if (!ld->args[0])
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-05-11 21:16:32 +00:00
|
|
|
ld->Alpha = alpha;
|
2008-09-06 18:09:41 +00:00
|
|
|
if (additive)
|
2006-07-20 05:13:39 +00:00
|
|
|
{
|
2008-05-30 06:56:50 +00:00
|
|
|
ld->flags |= ML_ADDTRANS;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (j = 0; j < numlines; j++)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-05-11 21:16:32 +00:00
|
|
|
if (lines[j].id == ld->args[0])
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-05-11 21:16:32 +00:00
|
|
|
lines[j].Alpha = alpha;
|
2008-09-06 18:09:41 +00:00
|
|
|
if (additive)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-05-30 06:56:50 +00:00
|
|
|
lines[j].flags |= ML_ADDTRANS;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-05-11 21:16:32 +00:00
|
|
|
ld->special = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// killough 4/4/98: delay using sidedefs until they are loaded
|
|
|
|
void P_FinishLoadingLineDefs ()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < numlines; i++)
|
|
|
|
{
|
2009-09-06 20:45:56 +00:00
|
|
|
P_FinishLoadingLineDef(&lines[i], sidetemp[lines[i].sidedef[0]-sides].a.alpha);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void P_SetSideNum (side_t **sidenum_p, WORD sidenum)
|
|
|
|
{
|
|
|
|
if (sidenum == NO_INDEX)
|
|
|
|
{
|
|
|
|
*sidenum_p = NULL;
|
|
|
|
}
|
|
|
|
else if (sidecount < numsides)
|
|
|
|
{
|
|
|
|
sidetemp[sidecount].a.map = sidenum;
|
|
|
|
*sidenum_p = &sides[sidecount++];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
I_Error ("%d sidedefs is not enough\n", sidecount);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
void P_LoadLineDefs (MapData * map)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int i, skipped;
|
|
|
|
line_t *ld;
|
2006-06-14 15:56:56 +00:00
|
|
|
int lumplen = map->Size(ML_LINEDEFS);
|
|
|
|
char * mldf;
|
|
|
|
maplinedef_t *mld;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
numlines = lumplen / sizeof(maplinedef_t);
|
2006-02-24 04:48:15 +00:00
|
|
|
lines = new line_t[numlines];
|
2008-05-11 21:16:32 +00:00
|
|
|
linemap.Resize(numlines);
|
2006-02-24 04:48:15 +00:00
|
|
|
memset (lines, 0, numlines*sizeof(line_t));
|
2006-06-14 15:56:56 +00:00
|
|
|
|
|
|
|
mldf = new char[lumplen];
|
|
|
|
map->Read(ML_LINEDEFS, mldf);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// [RH] Count the number of sidedef references. This is the number of
|
|
|
|
// sidedefs we need. The actual number in the SIDEDEFS lump might be less.
|
|
|
|
// Lines with 0 length are also removed.
|
|
|
|
|
|
|
|
for (skipped = sidecount = i = 0; i < numlines; )
|
|
|
|
{
|
2006-06-14 15:56:56 +00:00
|
|
|
mld = ((maplinedef_t*)mldf) + i;
|
2006-02-24 04:48:15 +00:00
|
|
|
int v1 = LittleShort(mld->v1);
|
|
|
|
int v2 = LittleShort(mld->v2);
|
|
|
|
|
|
|
|
if (v1 >= numvertexes || v2 >= numvertexes)
|
|
|
|
{
|
2006-06-14 15:56:56 +00:00
|
|
|
delete [] mldf;
|
2006-02-24 04:48:15 +00:00
|
|
|
I_Error ("Line %d has invalid vertices: %d and/or %d.\nThe map only contains %d vertices.", i+skipped, v1, v2, numvertexes);
|
|
|
|
}
|
|
|
|
else if (v1 == v2 ||
|
|
|
|
(vertexes[LittleShort(mld->v1)].x == vertexes[LittleShort(mld->v2)].x &&
|
|
|
|
vertexes[LittleShort(mld->v1)].y == vertexes[LittleShort(mld->v2)].y))
|
|
|
|
{
|
|
|
|
Printf ("Removing 0-length line %d\n", i+skipped);
|
|
|
|
memmove (mld, mld+1, sizeof(*mld)*(numlines-i-1));
|
|
|
|
ForceNodeBuild = true;
|
|
|
|
skipped++;
|
|
|
|
numlines--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-05-29 09:11:12 +00:00
|
|
|
// patch missing first sides instead of crashing out.
|
|
|
|
// Visual glitches are better than not being able to play.
|
|
|
|
if (LittleShort(mld->sidenum[0]) == NO_INDEX)
|
|
|
|
{
|
|
|
|
Printf("Line %d has no first side.\n", i);
|
|
|
|
mld->sidenum[0] = 0;
|
|
|
|
}
|
|
|
|
sidecount++;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (LittleShort(mld->sidenum[1]) != NO_INDEX)
|
|
|
|
sidecount++;
|
|
|
|
linemap[i] = i+skipped;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
P_AllocateSideDefs (sidecount);
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
mld = (maplinedef_t *)mldf;
|
2006-02-24 04:48:15 +00:00
|
|
|
ld = lines;
|
|
|
|
for (i = numlines; i > 0; i--, mld++, ld++)
|
|
|
|
{
|
2008-05-02 10:55:48 +00:00
|
|
|
ld->Alpha = FRACUNIT; // [RH] Opaque by default
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// [RH] Translate old linedef special and flags to be
|
|
|
|
// compatible with the new format.
|
|
|
|
P_TranslateLineDef (ld, mld);
|
|
|
|
|
|
|
|
ld->v1 = &vertexes[LittleShort(mld->v1)];
|
|
|
|
ld->v2 = &vertexes[LittleShort(mld->v2)];
|
|
|
|
//ld->id = -1; ID has been assigned in P_TranslateLineDef
|
|
|
|
|
2009-09-06 20:45:56 +00:00
|
|
|
P_SetSideNum (&ld->sidedef[0], LittleShort(mld->sidenum[0]));
|
|
|
|
P_SetSideNum (&ld->sidedef[1], LittleShort(mld->sidenum[1]));
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
P_AdjustLine (ld);
|
|
|
|
P_SaveLineSpecial (ld);
|
2009-02-03 19:11:43 +00:00
|
|
|
if (level.flags2 & LEVEL2_CLIPMIDTEX) ld->flags |= ML_CLIP_MIDTEX;
|
|
|
|
if (level.flags2 & LEVEL2_WRAPMIDTEX) ld->flags |= ML_WRAP_MIDTEX;
|
|
|
|
if (level.flags2 & LEVEL2_CHECKSWITCHRANGE) ld->flags |= ML_CHECKSWITCHRANGE;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-06-14 15:56:56 +00:00
|
|
|
delete[] mldf;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// [RH] Same as P_LoadLineDefs() except it uses Hexen-style LineDefs.
|
2006-06-14 15:56:56 +00:00
|
|
|
void P_LoadLineDefs2 (MapData * map)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-06-14 15:56:56 +00:00
|
|
|
int i, skipped;
|
|
|
|
line_t *ld;
|
|
|
|
int lumplen = map->Size(ML_LINEDEFS);
|
|
|
|
char * mldf;
|
|
|
|
maplinedef2_t *mld;
|
|
|
|
|
|
|
|
numlines = lumplen / sizeof(maplinedef2_t);
|
2006-02-24 04:48:15 +00:00
|
|
|
lines = new line_t[numlines];
|
2008-05-11 21:16:32 +00:00
|
|
|
linemap.Resize(numlines);
|
2006-02-24 04:48:15 +00:00
|
|
|
memset (lines, 0, numlines*sizeof(line_t));
|
2006-06-14 15:56:56 +00:00
|
|
|
|
|
|
|
mldf = new char[lumplen];
|
|
|
|
map->Read(ML_LINEDEFS, mldf);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// [RH] Remove any lines that have 0 length and count sidedefs used
|
|
|
|
for (skipped = sidecount = i = 0; i < numlines; )
|
|
|
|
{
|
2006-06-14 15:56:56 +00:00
|
|
|
mld = ((maplinedef2_t*)mldf) + i;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (mld->v1 == mld->v2 ||
|
|
|
|
(vertexes[LittleShort(mld->v1)].x == vertexes[LittleShort(mld->v2)].x &&
|
|
|
|
vertexes[LittleShort(mld->v1)].y == vertexes[LittleShort(mld->v2)].y))
|
|
|
|
{
|
|
|
|
Printf ("Removing 0-length line %d\n", i+skipped);
|
|
|
|
memmove (mld, mld+1, sizeof(*mld)*(numlines-i-1));
|
|
|
|
skipped++;
|
|
|
|
numlines--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-05-29 09:11:12 +00:00
|
|
|
// patch missing first sides instead of crashing out.
|
|
|
|
// Visual glitches are better than not being able to play.
|
|
|
|
if (LittleShort(mld->sidenum[0]) == NO_INDEX)
|
|
|
|
{
|
|
|
|
Printf("Line %d has no first side.\n", i);
|
|
|
|
mld->sidenum[0] = 0;
|
|
|
|
}
|
|
|
|
sidecount++;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (LittleShort(mld->sidenum[1]) != NO_INDEX)
|
|
|
|
sidecount++;
|
|
|
|
linemap[i] = i+skipped;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (skipped > 0)
|
|
|
|
{
|
|
|
|
ForceNodeBuild = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
P_AllocateSideDefs (sidecount);
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
mld = (maplinedef2_t *)mldf;
|
2006-02-24 04:48:15 +00:00
|
|
|
ld = lines;
|
|
|
|
for (i = numlines; i > 0; i--, mld++, ld++)
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for (j = 0; j < 5; j++)
|
|
|
|
ld->args[j] = mld->args[j];
|
|
|
|
|
|
|
|
ld->flags = LittleShort(mld->flags);
|
|
|
|
ld->special = mld->special;
|
|
|
|
|
|
|
|
ld->v1 = &vertexes[LittleShort(mld->v1)];
|
|
|
|
ld->v2 = &vertexes[LittleShort(mld->v2)];
|
2008-05-02 10:55:48 +00:00
|
|
|
ld->Alpha = FRACUNIT; // [RH] Opaque by default
|
2006-02-24 04:48:15 +00:00
|
|
|
ld->id = -1;
|
|
|
|
|
2009-09-06 20:45:56 +00:00
|
|
|
P_SetSideNum (&ld->sidedef[0], LittleShort(mld->sidenum[0]));
|
|
|
|
P_SetSideNum (&ld->sidedef[1], LittleShort(mld->sidenum[1]));
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
P_AdjustLine (ld);
|
2008-05-11 21:16:32 +00:00
|
|
|
P_SetLineID(ld);
|
2006-02-24 04:48:15 +00:00
|
|
|
P_SaveLineSpecial (ld);
|
2009-02-03 19:11:43 +00:00
|
|
|
if (level.flags2 & LEVEL2_CLIPMIDTEX) ld->flags |= ML_CLIP_MIDTEX;
|
|
|
|
if (level.flags2 & LEVEL2_WRAPMIDTEX) ld->flags |= ML_WRAP_MIDTEX;
|
|
|
|
if (level.flags2 & LEVEL2_CHECKSWITCHRANGE) ld->flags |= ML_CHECKSWITCHRANGE;
|
2008-05-02 10:55:48 +00:00
|
|
|
|
|
|
|
// convert the activation type
|
|
|
|
ld->activation = 1 << GET_SPAC(ld->flags);
|
2012-03-15 22:57:00 +00:00
|
|
|
if (ld->activation == SPAC_AnyCross)
|
|
|
|
{ // this is really PTouch
|
|
|
|
ld->activation = SPAC_Impact | SPAC_PCross;
|
|
|
|
}
|
|
|
|
else if (ld->activation == SPAC_Impact)
|
|
|
|
{ // In non-UMDF maps, Impact implies PCross
|
|
|
|
ld->activation = SPAC_Impact | SPAC_PCross;
|
|
|
|
}
|
2008-05-02 10:55:48 +00:00
|
|
|
ld->flags &= ~ML_SPAC_MASK;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-06-14 15:56:56 +00:00
|
|
|
delete[] mldf;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// P_LoadSideDefs
|
|
|
|
//
|
|
|
|
// killough 4/4/98: split into two functions
|
2006-06-14 15:56:56 +00:00
|
|
|
void P_LoadSideDefs (MapData * map)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-06-14 15:56:56 +00:00
|
|
|
numsides = map->Size(ML_SIDEDEFS) / sizeof(mapsidedef_t);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void P_AllocateSideDefs (int count)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
sides = new side_t[count];
|
|
|
|
memset (sides, 0, count*sizeof(side_t));
|
|
|
|
|
|
|
|
sidetemp = new sidei_t[MAX(count,numvertexes)];
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
sidetemp[i].a.special = sidetemp[i].a.tag = 0;
|
2009-08-29 03:33:36 +00:00
|
|
|
sidetemp[i].a.alpha = SHRT_MIN;
|
2006-02-24 04:48:15 +00:00
|
|
|
sidetemp[i].a.map = NO_SIDE;
|
|
|
|
}
|
|
|
|
if (count < numsides)
|
|
|
|
{
|
|
|
|
Printf ("Map has %d unused sidedefs\n", numsides - count);
|
|
|
|
}
|
|
|
|
numsides = count;
|
|
|
|
sidecount = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// [RH] Group sidedefs into loops so that we can easily determine
|
|
|
|
// what walls any particular wall neighbors.
|
|
|
|
|
2010-08-15 14:09:17 +00:00
|
|
|
static void P_LoopSidedefs (bool firstloop)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2010-08-14 20:00:47 +00:00
|
|
|
if (sidetemp != NULL)
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
2010-08-14 20:00:47 +00:00
|
|
|
delete[] sidetemp;
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
2010-08-14 20:00:47 +00:00
|
|
|
sidetemp = new sidei_t[MAX(numvertexes, numsides)];
|
2008-05-11 21:16:32 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
for (i = 0; i < numvertexes; ++i)
|
|
|
|
{
|
|
|
|
sidetemp[i].b.first = NO_SIDE;
|
|
|
|
sidetemp[i].b.next = NO_SIDE;
|
|
|
|
}
|
|
|
|
for (; i < numsides; ++i)
|
|
|
|
{
|
|
|
|
sidetemp[i].b.next = NO_SIDE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < numsides; ++i)
|
|
|
|
{
|
|
|
|
// For each vertex, build a list of sidedefs that use that vertex
|
|
|
|
// as their left edge.
|
2009-09-06 18:19:28 +00:00
|
|
|
line_t *line = sides[i].linedef;
|
2009-09-06 20:45:56 +00:00
|
|
|
int lineside = (line->sidedef[0] != &sides[i]);
|
2009-05-15 10:39:40 +00:00
|
|
|
int vert = int((lineside ? line->v2 : line->v1) - vertexes);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
sidetemp[i].b.lineside = lineside;
|
|
|
|
sidetemp[i].b.next = sidetemp[vert].b.first;
|
|
|
|
sidetemp[vert].b.first = i;
|
|
|
|
|
|
|
|
// Set each side so that it is the only member of its loop
|
|
|
|
sides[i].LeftSide = NO_SIDE;
|
|
|
|
sides[i].RightSide = NO_SIDE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// For each side, find the side that is to its right and set the
|
|
|
|
// loop pointers accordingly. If two sides share a left vertex, the
|
|
|
|
// one that forms the smallest angle is assumed to be the right one.
|
|
|
|
for (i = 0; i < numsides; ++i)
|
|
|
|
{
|
|
|
|
DWORD right;
|
2009-09-06 18:19:28 +00:00
|
|
|
line_t *line = sides[i].linedef;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// If the side's line only exists in a single sector,
|
|
|
|
// then consider that line to be a self-contained loop
|
|
|
|
// instead of as part of another loop
|
|
|
|
if (line->frontsector == line->backsector)
|
|
|
|
{
|
2009-09-06 20:45:56 +00:00
|
|
|
right = DWORD(line->sidedef[!sidetemp[i].b.lineside] - sides);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (sidetemp[i].b.lineside)
|
|
|
|
{
|
2009-05-15 10:39:40 +00:00
|
|
|
right = int(line->v1 - vertexes);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-05-15 10:39:40 +00:00
|
|
|
right = int(line->v2 - vertexes);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
right = sidetemp[right].b.first;
|
|
|
|
|
2010-09-08 08:53:39 +00:00
|
|
|
if (right == NO_SIDE)
|
|
|
|
{
|
|
|
|
// There is no right side!
|
|
|
|
if (firstloop) Printf ("Line %d's right edge is unconnected\n", linemap[unsigned(line-lines)]);
|
2006-02-24 04:48:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sidetemp[right].b.next != NO_SIDE)
|
|
|
|
{
|
|
|
|
int bestright = right; // Shut up, GCC
|
|
|
|
angle_t bestang = ANGLE_MAX;
|
|
|
|
line_t *leftline, *rightline;
|
|
|
|
angle_t ang1, ang2, ang;
|
|
|
|
|
2009-09-06 18:19:28 +00:00
|
|
|
leftline = sides[i].linedef;
|
2006-02-24 04:48:15 +00:00
|
|
|
ang1 = R_PointToAngle2 (0, 0, leftline->dx, leftline->dy);
|
|
|
|
if (!sidetemp[i].b.lineside)
|
|
|
|
{
|
|
|
|
ang1 += ANGLE_180;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (right != NO_SIDE)
|
|
|
|
{
|
|
|
|
if (sides[right].LeftSide == NO_SIDE)
|
|
|
|
{
|
2009-09-06 18:19:28 +00:00
|
|
|
rightline = sides[right].linedef;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (rightline->frontsector != rightline->backsector)
|
|
|
|
{
|
|
|
|
ang2 = R_PointToAngle2 (0, 0, rightline->dx, rightline->dy);
|
|
|
|
if (sidetemp[right].b.lineside)
|
|
|
|
{
|
|
|
|
ang2 += ANGLE_180;
|
|
|
|
}
|
|
|
|
|
|
|
|
ang = ang2 - ang1;
|
|
|
|
|
|
|
|
if (ang != 0 && ang <= bestang)
|
|
|
|
{
|
|
|
|
bestright = right;
|
|
|
|
bestang = ang;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
right = sidetemp[right].b.next;
|
|
|
|
}
|
|
|
|
right = bestright;
|
|
|
|
}
|
|
|
|
}
|
2010-09-24 14:27:52 +00:00
|
|
|
assert((unsigned)i<(unsigned)numsides);
|
|
|
|
assert(right<(unsigned)numsides);
|
2006-02-24 04:48:15 +00:00
|
|
|
sides[i].RightSide = right;
|
|
|
|
sides[right].LeftSide = i;
|
|
|
|
}
|
|
|
|
|
2010-08-01 05:16:09 +00:00
|
|
|
// We keep the sidedef init info around until after polyobjects are initialized,
|
|
|
|
// so don't delete just yet.
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-07-20 05:13:39 +00:00
|
|
|
int P_DetermineTranslucency (int lumpnum)
|
|
|
|
{
|
|
|
|
FWadLump tranmap = Wads.OpenLumpNum (lumpnum);
|
|
|
|
BYTE index;
|
|
|
|
PalEntry newcolor;
|
2008-09-06 18:09:41 +00:00
|
|
|
PalEntry newcolor2;
|
2006-07-20 05:13:39 +00:00
|
|
|
|
|
|
|
tranmap.Seek (GPalette.BlackIndex * 256 + GPalette.WhiteIndex, SEEK_SET);
|
|
|
|
tranmap.Read (&index, 1);
|
|
|
|
|
|
|
|
newcolor = GPalette.BaseColors[GPalette.Remap[index]];
|
|
|
|
|
2008-09-06 18:09:41 +00:00
|
|
|
tranmap.Seek (GPalette.WhiteIndex * 256 + GPalette.BlackIndex, SEEK_SET);
|
|
|
|
tranmap.Read (&index, 1);
|
|
|
|
newcolor2 = GPalette.BaseColors[GPalette.Remap[index]];
|
|
|
|
if (newcolor2.r == 255) // if black on white results in white it's either
|
|
|
|
// fully transparent or additive
|
|
|
|
{
|
|
|
|
if (developer)
|
|
|
|
{
|
|
|
|
char lumpname[9];
|
|
|
|
lumpname[8] = 0;
|
|
|
|
Wads.GetLumpName (lumpname, lumpnum);
|
|
|
|
Printf ("%s appears to be additive translucency %d (%d%%)\n", lumpname, newcolor.r,
|
|
|
|
newcolor.r*100/255);
|
|
|
|
}
|
|
|
|
return -newcolor.r;
|
|
|
|
}
|
|
|
|
|
2006-07-20 05:13:39 +00:00
|
|
|
if (developer)
|
|
|
|
{
|
|
|
|
char lumpname[9];
|
|
|
|
lumpname[8] = 0;
|
|
|
|
Wads.GetLumpName (lumpname, lumpnum);
|
|
|
|
Printf ("%s appears to be translucency %d (%d%%)\n", lumpname, newcolor.r,
|
|
|
|
newcolor.r*100/255);
|
|
|
|
}
|
|
|
|
return newcolor.r;
|
|
|
|
}
|
|
|
|
|
2011-05-08 00:30:32 +00:00
|
|
|
void P_ProcessSideTextures(bool checktranmap, side_t *sd, sector_t *sec, mapsidedef_t *msd, int special, int tag, short *alpha, FMissingTextureTracker &missingtex)
|
2008-05-11 21:16:32 +00:00
|
|
|
{
|
|
|
|
char name[9];
|
|
|
|
name[8] = 0;
|
|
|
|
|
|
|
|
switch (special)
|
|
|
|
{
|
|
|
|
case Transfer_Heights: // variable colormap via 242 linedef
|
|
|
|
// [RH] The colormap num we get here isn't really a colormap,
|
|
|
|
// but a packed ARGB word for blending, so we also allow
|
|
|
|
// the blend to be specified directly by the texture names
|
|
|
|
// instead of figuring something out from the colormap.
|
|
|
|
if (sec != NULL)
|
|
|
|
{
|
|
|
|
SetTexture (sd, side_t::bottom, &sec->bottommap, msd->bottomtexture);
|
|
|
|
SetTexture (sd, side_t::mid, &sec->midmap, msd->midtexture);
|
|
|
|
SetTexture (sd, side_t::top, &sec->topmap, msd->toptexture);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Static_Init:
|
|
|
|
// [RH] Set sector color and fog
|
|
|
|
// upper "texture" is light color
|
|
|
|
// lower "texture" is fog color
|
|
|
|
{
|
2008-07-25 01:37:44 +00:00
|
|
|
DWORD color = MAKERGB(255,255,255), fog = 0;
|
2008-05-11 21:16:32 +00:00
|
|
|
bool colorgood, foggood;
|
|
|
|
|
2011-01-29 11:09:38 +00:00
|
|
|
SetTextureNoErr (sd, side_t::bottom, &fog, msd->bottomtexture, &foggood, true);
|
|
|
|
SetTextureNoErr (sd, side_t::top, &color, msd->toptexture, &colorgood, false);
|
2008-05-11 21:16:32 +00:00
|
|
|
strncpy (name, msd->midtexture, 8);
|
2011-05-08 00:30:32 +00:00
|
|
|
SetTexture(sd, side_t::mid, msd->midtexture, missingtex);
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
if (colorgood | foggood)
|
|
|
|
{
|
|
|
|
int s;
|
|
|
|
FDynamicColormap *colormap = NULL;
|
|
|
|
|
|
|
|
for (s = 0; s < numsectors; s++)
|
|
|
|
{
|
|
|
|
if (sectors[s].tag == tag)
|
|
|
|
{
|
|
|
|
if (!colorgood) color = sectors[s].ColorMap->Color;
|
|
|
|
if (!foggood) fog = sectors[s].ColorMap->Fade;
|
|
|
|
if (colormap == NULL ||
|
|
|
|
colormap->Color != color ||
|
|
|
|
colormap->Fade != fog)
|
|
|
|
{
|
|
|
|
colormap = GetSpecialLights (color, fog, 0);
|
|
|
|
}
|
|
|
|
sectors[s].ColorMap = colormap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-01-04 15:00:29 +00:00
|
|
|
#ifdef _3DFLOORS
|
|
|
|
case Sector_Set3DFloor:
|
|
|
|
if (msd->toptexture[0]=='#')
|
|
|
|
{
|
|
|
|
strncpy (name, msd->toptexture, 8);
|
|
|
|
sd->SetTexture(side_t::top, FNullTextureID() +(-strtol(name+1, NULL, 10))); // store the alpha as a negative texture index
|
|
|
|
// This will be sorted out by the 3D-floor code later.
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-05-08 00:30:32 +00:00
|
|
|
SetTexture(sd, side_t::top, msd->toptexture, missingtex);
|
2009-01-04 15:00:29 +00:00
|
|
|
}
|
|
|
|
|
2011-05-08 00:30:32 +00:00
|
|
|
SetTexture(sd, side_t::mid, msd->midtexture, missingtex);
|
|
|
|
SetTexture(sd, side_t::bottom, msd->bottomtexture, missingtex);
|
2009-01-04 15:00:29 +00:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
case TranslucentLine: // killough 4/11/98: apply translucency to 2s normal texture
|
|
|
|
if (checktranmap)
|
|
|
|
{
|
|
|
|
int lumpnum;
|
|
|
|
|
|
|
|
if (strnicmp ("TRANMAP", msd->midtexture, 8) == 0)
|
|
|
|
{
|
|
|
|
// The translator set the alpha argument already; no reason to do it again.
|
2008-06-15 18:36:26 +00:00
|
|
|
sd->SetTexture(side_t::mid, FNullTextureID());
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
|
|
|
else if ((lumpnum = Wads.CheckNumForName (msd->midtexture)) > 0 &&
|
|
|
|
Wads.LumpLength (lumpnum) == 65536)
|
|
|
|
{
|
|
|
|
*alpha = (short)P_DetermineTranslucency (lumpnum);
|
2008-06-15 18:36:26 +00:00
|
|
|
sd->SetTexture(side_t::mid, FNullTextureID());
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-05-08 00:30:32 +00:00
|
|
|
SetTexture(sd, side_t::mid, msd->midtexture, missingtex);
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
|
|
|
|
2011-05-08 00:30:32 +00:00
|
|
|
SetTexture(sd, side_t::top, msd->toptexture, missingtex);
|
|
|
|
SetTexture(sd, side_t::bottom, msd->bottomtexture, missingtex);
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Fallthrough for Hexen maps is intentional
|
|
|
|
|
|
|
|
default: // normal cases
|
|
|
|
|
2011-05-08 00:30:32 +00:00
|
|
|
SetTexture(sd, side_t::mid, msd->midtexture, missingtex);
|
|
|
|
SetTexture(sd, side_t::top, msd->toptexture, missingtex);
|
|
|
|
SetTexture(sd, side_t::bottom, msd->bottomtexture, missingtex);
|
2008-05-11 21:16:32 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// killough 4/4/98: delay using texture names until
|
|
|
|
// after linedefs are loaded, to allow overloading.
|
|
|
|
// killough 5/3/98: reformatted, cleaned up
|
|
|
|
|
2011-05-08 00:30:32 +00:00
|
|
|
void P_LoadSideDefs2 (MapData *map, FMissingTextureTracker &missingtex)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int i;
|
2006-06-21 15:40:42 +00:00
|
|
|
char * msdf = new char[map->Size(ML_SIDEDEFS)];
|
2006-06-14 15:56:56 +00:00
|
|
|
map->Read(ML_SIDEDEFS, msdf);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
for (i = 0; i < numsides; i++)
|
|
|
|
{
|
2006-06-21 15:40:42 +00:00
|
|
|
mapsidedef_t *msd = ((mapsidedef_t*)msdf) + sidetemp[i].a.map;
|
2006-02-24 04:48:15 +00:00
|
|
|
side_t *sd = sides + i;
|
|
|
|
sector_t *sec;
|
|
|
|
|
|
|
|
// [RH] The Doom renderer ignored the patch y locations when
|
|
|
|
// drawing mid textures. ZDoom does not, so fix the laser beams in Strife.
|
|
|
|
if (gameinfo.gametype == GAME_Strife &&
|
|
|
|
strncmp (msd->midtexture, "LASERB01", 8) == 0)
|
|
|
|
{
|
|
|
|
msd->rowoffset += 102;
|
|
|
|
}
|
|
|
|
|
2008-03-21 17:35:49 +00:00
|
|
|
sd->SetTextureXOffset(LittleShort(msd->textureoffset)<<FRACBITS);
|
|
|
|
sd->SetTextureYOffset(LittleShort(msd->rowoffset)<<FRACBITS);
|
2009-06-07 01:14:14 +00:00
|
|
|
sd->SetTextureXScale(FRACUNIT);
|
|
|
|
sd->SetTextureYScale(FRACUNIT);
|
2009-09-06 18:19:28 +00:00
|
|
|
sd->linedef = NULL;
|
2008-08-21 08:04:21 +00:00
|
|
|
sd->Flags = 0;
|
2009-05-11 21:05:40 +00:00
|
|
|
sd->Index = i;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// killough 4/4/98: allow sidedef texture names to be overloaded
|
|
|
|
// killough 4/11/98: refined to allow colormaps to work as wall
|
|
|
|
// textures if invalid as colormaps but valid as textures.
|
|
|
|
|
|
|
|
if ((unsigned)LittleShort(msd->sector)>=(unsigned)numsectors)
|
|
|
|
{
|
|
|
|
Printf (PRINT_HIGH, "Sidedef %d has a bad sector\n", i);
|
|
|
|
sd->sector = sec = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sd->sector = sec = §ors[LittleShort(msd->sector)];
|
|
|
|
}
|
2008-05-11 21:16:32 +00:00
|
|
|
P_ProcessSideTextures(!map->HasBehavior, sd, sec, msd,
|
2011-05-08 00:30:32 +00:00
|
|
|
sidetemp[i].a.special, sidetemp[i].a.tag, &sidetemp[i].a.alpha, missingtex);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-06-14 15:56:56 +00:00
|
|
|
delete[] msdf;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// [RH] My own blockmap builder, not Killough's or TeamTNT's.
|
|
|
|
//
|
|
|
|
// Killough's turned out not to be correct enough, and I had
|
|
|
|
// written this for ZDBSP before I discovered that, so
|
|
|
|
// replacing the one he wrote for MBF seemed like the easiest
|
|
|
|
// thing to do. (Doom E3M6, near vertex 0--the one furthest east
|
|
|
|
// on the map--had problems.)
|
|
|
|
//
|
|
|
|
// Using a hash table to get the minimum possible blockmap size
|
|
|
|
// seems like overkill, but I wanted to change the code as little
|
|
|
|
// as possible from its ZDBSP incarnation.
|
|
|
|
//
|
|
|
|
|
2011-01-09 11:01:04 +00:00
|
|
|
static unsigned int BlockHash (TArray<int> *block)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int hash = 0;
|
2011-01-09 11:01:04 +00:00
|
|
|
int *ar = &(*block)[0];
|
2006-02-24 04:48:15 +00:00
|
|
|
for (size_t i = 0; i < block->Size(); ++i)
|
|
|
|
{
|
|
|
|
hash = hash * 12235 + ar[i];
|
|
|
|
}
|
|
|
|
return hash & 0x7fffffff;
|
|
|
|
}
|
|
|
|
|
2011-01-09 11:01:04 +00:00
|
|
|
static bool BlockCompare (TArray<int> *block1, TArray<int> *block2)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
size_t size = block1->Size();
|
|
|
|
|
|
|
|
if (size != block2->Size())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (size == 0)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2011-01-09 11:01:04 +00:00
|
|
|
int *ar1 = &(*block1)[0];
|
|
|
|
int *ar2 = &(*block2)[0];
|
2006-02-24 04:48:15 +00:00
|
|
|
for (size_t i = 0; i < size; ++i)
|
|
|
|
{
|
|
|
|
if (ar1[i] != ar2[i])
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-01-09 11:01:04 +00:00
|
|
|
static void CreatePackedBlockmap (TArray<int> &BlockMap, TArray<int> *blocks, int bmapwidth, int bmapheight)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int buckets[4096];
|
|
|
|
int *hashes, hashblock;
|
2011-01-09 11:01:04 +00:00
|
|
|
TArray<int> *block;
|
2006-02-24 04:48:15 +00:00
|
|
|
int zero = 0;
|
|
|
|
int terminator = -1;
|
2011-01-09 11:01:04 +00:00
|
|
|
int *array;
|
2006-02-24 04:48:15 +00:00
|
|
|
int i, hash;
|
|
|
|
int hashed = 0, nothashed = 0;
|
|
|
|
|
|
|
|
hashes = new int[bmapwidth * bmapheight];
|
|
|
|
|
2011-01-09 11:01:04 +00:00
|
|
|
memset (hashes, 0xff, sizeof(int)*bmapwidth*bmapheight);
|
2006-02-24 04:48:15 +00:00
|
|
|
memset (buckets, 0xff, sizeof(buckets));
|
|
|
|
|
|
|
|
for (i = 0; i < bmapwidth * bmapheight; ++i)
|
|
|
|
{
|
|
|
|
block = &blocks[i];
|
|
|
|
hash = BlockHash (block) % 4096;
|
|
|
|
hashblock = buckets[hash];
|
|
|
|
while (hashblock != -1)
|
|
|
|
{
|
|
|
|
if (BlockCompare (block, &blocks[hashblock]))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
hashblock = hashes[hashblock];
|
|
|
|
}
|
|
|
|
if (hashblock != -1)
|
|
|
|
{
|
|
|
|
BlockMap[4+i] = BlockMap[4+hashblock];
|
|
|
|
hashed++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hashes[i] = buckets[hash];
|
|
|
|
buckets[hash] = i;
|
|
|
|
BlockMap[4+i] = BlockMap.Size ();
|
|
|
|
BlockMap.Push (zero);
|
|
|
|
array = &(*block)[0];
|
|
|
|
for (size_t j = 0; j < block->Size(); ++j)
|
|
|
|
{
|
|
|
|
BlockMap.Push (array[j]);
|
|
|
|
}
|
|
|
|
BlockMap.Push (terminator);
|
|
|
|
nothashed++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delete[] hashes;
|
|
|
|
|
|
|
|
// printf ("%d blocks written, %d blocks saved\n", nothashed, hashed);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define BLOCKBITS 7
|
|
|
|
#define BLOCKSIZE 128
|
|
|
|
|
|
|
|
static void P_CreateBlockMap ()
|
|
|
|
{
|
2011-01-09 11:01:04 +00:00
|
|
|
TArray<int> *BlockLists, *block, *endblock;
|
|
|
|
int adder;
|
2006-02-24 04:48:15 +00:00
|
|
|
int bmapwidth, bmapheight;
|
|
|
|
int minx, maxx, miny, maxy;
|
|
|
|
int i;
|
2011-01-09 11:01:04 +00:00
|
|
|
int line;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (numvertexes <= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Find map extents for the blockmap
|
|
|
|
minx = maxx = vertexes[0].x;
|
|
|
|
miny = maxy = vertexes[0].y;
|
|
|
|
|
|
|
|
for (i = 1; i < numvertexes; ++i)
|
|
|
|
{
|
|
|
|
if (vertexes[i].x < minx) minx = vertexes[i].x;
|
|
|
|
else if (vertexes[i].x > maxx) maxx = vertexes[i].x;
|
|
|
|
if (vertexes[i].y < miny) miny = vertexes[i].y;
|
|
|
|
else if (vertexes[i].y > maxy) maxy = vertexes[i].y;
|
|
|
|
}
|
|
|
|
|
|
|
|
maxx >>= FRACBITS;
|
|
|
|
minx >>= FRACBITS;
|
|
|
|
maxy >>= FRACBITS;
|
|
|
|
miny >>= FRACBITS;
|
|
|
|
|
|
|
|
bmapwidth = ((maxx - minx) >> BLOCKBITS) + 1;
|
|
|
|
bmapheight = ((maxy - miny) >> BLOCKBITS) + 1;
|
|
|
|
|
|
|
|
TArray<int> BlockMap (bmapwidth * bmapheight * 3 + 4);
|
|
|
|
|
|
|
|
adder = minx; BlockMap.Push (adder);
|
|
|
|
adder = miny; BlockMap.Push (adder);
|
|
|
|
adder = bmapwidth; BlockMap.Push (adder);
|
|
|
|
adder = bmapheight; BlockMap.Push (adder);
|
|
|
|
|
2011-01-09 11:01:04 +00:00
|
|
|
BlockLists = new TArray<int>[bmapwidth * bmapheight];
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
for (line = 0; line < numlines; ++line)
|
|
|
|
{
|
|
|
|
int x1 = lines[line].v1->x >> FRACBITS;
|
|
|
|
int y1 = lines[line].v1->y >> FRACBITS;
|
|
|
|
int x2 = lines[line].v2->x >> FRACBITS;
|
|
|
|
int y2 = lines[line].v2->y >> FRACBITS;
|
|
|
|
int dx = x2 - x1;
|
|
|
|
int dy = y2 - y1;
|
|
|
|
int bx = (x1 - minx) >> BLOCKBITS;
|
|
|
|
int by = (y1 - miny) >> BLOCKBITS;
|
|
|
|
int bx2 = (x2 - minx) >> BLOCKBITS;
|
|
|
|
int by2 = (y2 - miny) >> BLOCKBITS;
|
|
|
|
|
|
|
|
block = &BlockLists[bx + by * bmapwidth];
|
|
|
|
endblock = &BlockLists[bx2 + by2 * bmapwidth];
|
|
|
|
|
|
|
|
if (block == endblock) // Single block
|
|
|
|
{
|
|
|
|
block->Push (line);
|
|
|
|
}
|
|
|
|
else if (by == by2) // Horizontal line
|
|
|
|
{
|
|
|
|
if (bx > bx2)
|
|
|
|
{
|
2010-07-23 21:19:59 +00:00
|
|
|
swapvalues (block, endblock);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
do
|
|
|
|
{
|
|
|
|
block->Push (line);
|
|
|
|
block += 1;
|
|
|
|
} while (block <= endblock);
|
|
|
|
}
|
|
|
|
else if (bx == bx2) // Vertical line
|
|
|
|
{
|
|
|
|
if (by > by2)
|
|
|
|
{
|
2010-07-23 21:19:59 +00:00
|
|
|
swapvalues (block, endblock);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
do
|
|
|
|
{
|
|
|
|
block->Push (line);
|
|
|
|
block += bmapwidth;
|
|
|
|
} while (block <= endblock);
|
|
|
|
}
|
|
|
|
else // Diagonal line
|
|
|
|
{
|
|
|
|
int xchange = (dx < 0) ? -1 : 1;
|
|
|
|
int ychange = (dy < 0) ? -1 : 1;
|
|
|
|
int ymove = ychange * bmapwidth;
|
|
|
|
int adx = abs (dx);
|
|
|
|
int ady = abs (dy);
|
|
|
|
|
|
|
|
if (adx == ady) // 45 degrees
|
|
|
|
{
|
|
|
|
int xb = (x1 - minx) & (BLOCKSIZE-1);
|
|
|
|
int yb = (y1 - miny) & (BLOCKSIZE-1);
|
|
|
|
if (dx < 0)
|
|
|
|
{
|
|
|
|
xb = BLOCKSIZE-xb;
|
|
|
|
}
|
|
|
|
if (dy < 0)
|
|
|
|
{
|
|
|
|
yb = BLOCKSIZE-yb;
|
|
|
|
}
|
|
|
|
if (xb < yb)
|
|
|
|
adx--;
|
|
|
|
}
|
|
|
|
if (adx >= ady) // X-major
|
|
|
|
{
|
|
|
|
int yadd = dy < 0 ? -1 : BLOCKSIZE;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
int stop = (Scale ((by << BLOCKBITS) + yadd - (y1 - miny), dx, dy) + (x1 - minx)) >> BLOCKBITS;
|
|
|
|
while (bx != stop)
|
|
|
|
{
|
|
|
|
block->Push (line);
|
|
|
|
block += xchange;
|
|
|
|
bx += xchange;
|
|
|
|
}
|
|
|
|
block->Push (line);
|
|
|
|
block += ymove;
|
|
|
|
by += ychange;
|
|
|
|
} while (by != by2);
|
|
|
|
while (block != endblock)
|
|
|
|
{
|
|
|
|
block->Push (line);
|
|
|
|
block += xchange;
|
|
|
|
}
|
|
|
|
block->Push (line);
|
|
|
|
}
|
|
|
|
else // Y-major
|
|
|
|
{
|
|
|
|
int xadd = dx < 0 ? -1 : BLOCKSIZE;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
int stop = (Scale ((bx << BLOCKBITS) + xadd - (x1 - minx), dy, dx) + (y1 - miny)) >> BLOCKBITS;
|
|
|
|
while (by != stop)
|
|
|
|
{
|
|
|
|
block->Push (line);
|
|
|
|
block += ymove;
|
|
|
|
by += ychange;
|
|
|
|
}
|
|
|
|
block->Push (line);
|
|
|
|
block += xchange;
|
|
|
|
bx += xchange;
|
|
|
|
} while (bx != bx2);
|
|
|
|
while (block != endblock)
|
|
|
|
{
|
|
|
|
block->Push (line);
|
|
|
|
block += ymove;
|
|
|
|
}
|
|
|
|
block->Push (line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BlockMap.Reserve (bmapwidth * bmapheight);
|
|
|
|
CreatePackedBlockmap (BlockMap, BlockLists, bmapwidth, bmapheight);
|
|
|
|
delete[] BlockLists;
|
|
|
|
|
|
|
|
blockmaplump = new int[BlockMap.Size()];
|
|
|
|
for (unsigned int ii = 0; ii < BlockMap.Size(); ++ii)
|
|
|
|
{
|
|
|
|
blockmaplump[ii] = BlockMap[ii];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-12 10:17:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// P_VerifyBlockMap
|
|
|
|
//
|
|
|
|
// haleyjd 03/04/10: do verification on validity of blockmap.
|
|
|
|
//
|
|
|
|
static bool P_VerifyBlockMap(int count)
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
int *maxoffs = blockmaplump + count;
|
|
|
|
|
|
|
|
int bmapwidth = blockmaplump[2];
|
|
|
|
int bmapheight = blockmaplump[3];
|
|
|
|
|
|
|
|
for(y = 0; y < bmapheight; y++)
|
|
|
|
{
|
|
|
|
for(x = 0; x < bmapwidth; x++)
|
|
|
|
{
|
|
|
|
int offset;
|
|
|
|
int *list, *tmplist;
|
|
|
|
int *blockoffset;
|
|
|
|
|
|
|
|
offset = y * bmapwidth + x;
|
|
|
|
blockoffset = blockmaplump + offset + 4;
|
|
|
|
|
|
|
|
|
|
|
|
// check that block offset is in bounds
|
|
|
|
if(blockoffset >= maxoffs)
|
|
|
|
{
|
|
|
|
Printf(PRINT_HIGH, "P_VerifyBlockMap: block offset overflow\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
offset = *blockoffset;
|
|
|
|
|
|
|
|
// check that list offset is in bounds
|
|
|
|
if(offset < 4 || offset >= count)
|
|
|
|
{
|
|
|
|
Printf(PRINT_HIGH, "P_VerifyBlockMap: list offset overflow\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
list = blockmaplump + offset;
|
|
|
|
|
|
|
|
// scan forward for a -1 terminator before maxoffs
|
|
|
|
for(tmplist = list; ; tmplist++)
|
|
|
|
{
|
|
|
|
// we have overflowed the lump?
|
|
|
|
if(tmplist >= maxoffs)
|
|
|
|
{
|
|
|
|
Printf(PRINT_HIGH, "P_VerifyBlockMap: open blocklist\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(*tmplist == -1) // found -1
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// scan the list for out-of-range linedef indicies in list
|
|
|
|
for(tmplist = list; *tmplist != -1; tmplist++)
|
|
|
|
{
|
|
|
|
if(*tmplist < 0 || *tmplist >= numlines)
|
|
|
|
{
|
|
|
|
Printf(PRINT_HIGH, "P_VerifyBlockMap: index >= numlines\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
// P_LoadBlockMap
|
|
|
|
//
|
|
|
|
// killough 3/1/98: substantially modified to work
|
|
|
|
// towards removing blockmap limit (a wad limitation)
|
|
|
|
//
|
|
|
|
// killough 3/30/98: Rewritten to remove blockmap limit
|
|
|
|
//
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
void P_LoadBlockMap (MapData * map)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-06-14 15:56:56 +00:00
|
|
|
int count = map->Size(ML_BLOCKMAP);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (ForceNodeBuild || genblockmap ||
|
2006-06-14 15:56:56 +00:00
|
|
|
count/2 >= 0x10000 || count == 0 ||
|
2008-03-12 02:56:11 +00:00
|
|
|
Args->CheckParm("-blockmap")
|
2006-06-14 15:56:56 +00:00
|
|
|
)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
DPrintf ("Generating BLOCKMAP\n");
|
|
|
|
P_CreateBlockMap ();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-09-14 00:02:31 +00:00
|
|
|
BYTE *data = new BYTE[count];
|
2006-06-14 15:56:56 +00:00
|
|
|
map->Read(ML_BLOCKMAP, data);
|
|
|
|
const short *wadblockmaplump = (short *)data;
|
2006-02-24 04:48:15 +00:00
|
|
|
int i;
|
2006-06-14 15:56:56 +00:00
|
|
|
|
|
|
|
count/=2;
|
2006-02-24 04:48:15 +00:00
|
|
|
blockmaplump = new int[count];
|
|
|
|
|
|
|
|
// killough 3/1/98: Expand wad blockmap into larger internal one,
|
|
|
|
// by treating all offsets except -1 as unsigned and zero-extending
|
|
|
|
// them. This potentially doubles the size of blockmaps allowed,
|
|
|
|
// because Doom originally considered the offsets as always signed.
|
|
|
|
|
|
|
|
blockmaplump[0] = LittleShort(wadblockmaplump[0]);
|
|
|
|
blockmaplump[1] = LittleShort(wadblockmaplump[1]);
|
|
|
|
blockmaplump[2] = (DWORD)(LittleShort(wadblockmaplump[2])) & 0xffff;
|
|
|
|
blockmaplump[3] = (DWORD)(LittleShort(wadblockmaplump[3])) & 0xffff;
|
|
|
|
|
|
|
|
for (i = 4; i < count; i++)
|
|
|
|
{
|
|
|
|
short t = LittleShort(wadblockmaplump[i]); // killough 3/1/98
|
|
|
|
blockmaplump[i] = t == -1 ? (DWORD)0xffffffff : (DWORD) t & 0xffff;
|
|
|
|
}
|
2006-06-14 15:56:56 +00:00
|
|
|
delete[] data;
|
2010-05-12 10:17:08 +00:00
|
|
|
|
|
|
|
if (!P_VerifyBlockMap(count))
|
|
|
|
{
|
|
|
|
DPrintf ("Generating BLOCKMAP\n");
|
|
|
|
P_CreateBlockMap();
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2012-03-28 03:49:38 +00:00
|
|
|
bmaporgx = blockmaplump[0] << FRACBITS;
|
|
|
|
bmaporgy = blockmaplump[1] << FRACBITS;
|
2006-02-24 04:48:15 +00:00
|
|
|
bmapwidth = blockmaplump[2];
|
|
|
|
bmapheight = blockmaplump[3];
|
2012-03-28 03:49:38 +00:00
|
|
|
// MAES: set blockmapxneg and blockmapyneg
|
|
|
|
// E.g. for a full 512x512 map, they should be both
|
|
|
|
// -1. For a 257*257, they should be both -255 etc.
|
|
|
|
bmapnegx = bmapwidth > 255 ? bmapwidth - 512 : -257;
|
|
|
|
bmapnegy = bmapheight > 255 ? bmapheight - 512 : -257;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// clear out mobj chains
|
|
|
|
count = bmapwidth*bmapheight;
|
|
|
|
blocklinks = new FBlockNode *[count];
|
|
|
|
memset (blocklinks, 0, count*sizeof(*blocklinks));
|
|
|
|
blockmap = blockmaplump+4;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// P_GroupLines
|
|
|
|
// Builds sector line lists and subsector sector numbers.
|
|
|
|
// Finds block bounding boxes for sectors.
|
|
|
|
// [RH] Handles extra lights
|
|
|
|
//
|
|
|
|
struct linf { short tag; WORD count; };
|
|
|
|
line_t** linebuffer;
|
|
|
|
|
|
|
|
static void P_GroupLines (bool buildmap)
|
|
|
|
{
|
2008-08-10 03:25:08 +00:00
|
|
|
cycle_t times[16];
|
2006-02-24 04:48:15 +00:00
|
|
|
int* linesDoneInEachSector;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int total;
|
|
|
|
int totallights;
|
|
|
|
line_t* li;
|
|
|
|
sector_t* sector;
|
2008-03-12 02:56:11 +00:00
|
|
|
FBoundingBox bbox;
|
2006-02-24 04:48:15 +00:00
|
|
|
bool flaggedNoFronts = false;
|
2011-01-29 11:09:38 +00:00
|
|
|
unsigned int jj;
|
2008-08-10 11:29:19 +00:00
|
|
|
|
|
|
|
for (i = 0; i < (int)countof(times); ++i)
|
|
|
|
{
|
|
|
|
times[i].Reset();
|
|
|
|
}
|
2008-08-10 03:25:08 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// look up sector number for each subsector
|
2008-08-10 03:25:08 +00:00
|
|
|
times[0].Clock();
|
2006-02-24 04:48:15 +00:00
|
|
|
for (i = 0; i < numsubsectors; i++)
|
|
|
|
{
|
2010-08-01 02:41:56 +00:00
|
|
|
subsectors[i].sector = subsectors[i].firstline->sidedef->sector;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-08-27 15:20:05 +00:00
|
|
|
if (glsegextras != NULL)
|
|
|
|
{
|
|
|
|
for (i = 0; i < numsubsectors; i++)
|
|
|
|
{
|
|
|
|
for (jj = 0; jj < subsectors[i].numlines; ++jj)
|
|
|
|
{
|
|
|
|
glsegextras[subsectors[i].firstline - segs + jj].Subsector = &subsectors[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-08-10 03:25:08 +00:00
|
|
|
times[0].Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// count number of lines in each sector
|
2008-08-10 03:25:08 +00:00
|
|
|
times[1].Clock();
|
2006-02-24 04:48:15 +00:00
|
|
|
total = 0;
|
|
|
|
totallights = 0;
|
|
|
|
for (i = 0, li = lines; i < numlines; i++, li++)
|
|
|
|
{
|
|
|
|
if (li->frontsector == NULL)
|
|
|
|
{
|
|
|
|
if (!flaggedNoFronts)
|
|
|
|
{
|
|
|
|
flaggedNoFronts = true;
|
|
|
|
Printf ("The following lines do not have a front sidedef:\n");
|
|
|
|
}
|
|
|
|
Printf (" %d\n", i);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
li->frontsector->linecount++;
|
|
|
|
total++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (li->backsector && li->backsector != li->frontsector)
|
|
|
|
{
|
|
|
|
li->backsector->linecount++;
|
|
|
|
total++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (flaggedNoFronts)
|
|
|
|
{
|
|
|
|
I_Error ("You need to fix these lines to play this map.\n");
|
|
|
|
}
|
2008-08-10 03:25:08 +00:00
|
|
|
times[1].Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// build line tables for each sector
|
2008-08-10 03:25:08 +00:00
|
|
|
times[3].Clock();
|
2006-02-24 04:48:15 +00:00
|
|
|
linebuffer = new line_t *[total];
|
|
|
|
line_t **lineb_p = linebuffer;
|
|
|
|
linesDoneInEachSector = new int[numsectors];
|
|
|
|
memset (linesDoneInEachSector, 0, sizeof(int)*numsectors);
|
|
|
|
|
|
|
|
for (sector = sectors, i = 0; i < numsectors; i++, sector++)
|
|
|
|
{
|
|
|
|
if (sector->linecount == 0)
|
|
|
|
{
|
|
|
|
Printf ("Sector %i (tag %i) has no lines\n", i, sector->tag);
|
|
|
|
// 0 the sector's tag so that no specials can use it
|
|
|
|
sector->tag = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sector->lines = lineb_p;
|
|
|
|
lineb_p += sector->linecount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = numlines, li = lines; i > 0; --i, ++li)
|
|
|
|
{
|
|
|
|
if (li->frontsector != NULL)
|
|
|
|
{
|
|
|
|
li->frontsector->lines[linesDoneInEachSector[li->frontsector - sectors]++] = li;
|
|
|
|
}
|
|
|
|
if (li->backsector != NULL && li->backsector != li->frontsector)
|
|
|
|
{
|
|
|
|
li->backsector->lines[linesDoneInEachSector[li->backsector - sectors]++] = li;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0, sector = sectors; i < numsectors; ++i, ++sector)
|
|
|
|
{
|
|
|
|
if (linesDoneInEachSector[i] != sector->linecount)
|
|
|
|
{
|
|
|
|
I_Error ("P_GroupLines: miscounted");
|
|
|
|
}
|
|
|
|
if (sector->linecount != 0)
|
|
|
|
{
|
|
|
|
bbox.ClearBox ();
|
|
|
|
for (j = 0; j < sector->linecount; ++j)
|
|
|
|
{
|
|
|
|
li = sector->lines[j];
|
|
|
|
bbox.AddToBox (li->v1->x, li->v1->y);
|
|
|
|
bbox.AddToBox (li->v2->x, li->v2->y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// set the soundorg to the middle of the bounding box
|
|
|
|
sector->soundorg[0] = bbox.Right()/2 + bbox.Left()/2;
|
|
|
|
sector->soundorg[1] = bbox.Top()/2 + bbox.Bottom()/2;
|
2012-04-04 17:33:43 +00:00
|
|
|
|
|
|
|
// For triangular sectors the above does not calculate good points unless the longest of the triangle's lines is perfectly horizontal and vertical
|
|
|
|
if (sector->linecount == 3)
|
|
|
|
{
|
|
|
|
vertex_t *Triangle[2];
|
|
|
|
Triangle[0] = sector->lines[0]->v1;
|
|
|
|
Triangle[1] = sector->lines[0]->v2;
|
|
|
|
if (sector->linecount > 1)
|
|
|
|
{
|
|
|
|
fixed_t dx = Triangle[1]->x - Triangle[0]->x;
|
|
|
|
fixed_t dy = Triangle[1]->y - Triangle[0]->y;
|
|
|
|
// Find another point in the sector that does not lie
|
|
|
|
// on the same line as the first two points.
|
|
|
|
for (j = 0; j < 2; ++j)
|
|
|
|
{
|
|
|
|
vertex_t *v;
|
|
|
|
|
|
|
|
v = (j == 1) ? sector->lines[1]->v1 : sector->lines[1]->v2;
|
|
|
|
if (DMulScale32 (v->y - Triangle[0]->y, dx,
|
|
|
|
Triangle[0]->x - v->x, dy) != 0)
|
|
|
|
{
|
|
|
|
sector->soundorg[0] = Triangle[0]->x / 3 + Triangle[1]->x / 3 + v->x / 3;
|
|
|
|
sector->soundorg[1] = Triangle[0]->y / 3 + Triangle[1]->y / 3 + v->y / 3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
delete[] linesDoneInEachSector;
|
2008-08-10 03:25:08 +00:00
|
|
|
times[3].Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// [RH] Moved this here
|
2008-08-10 03:25:08 +00:00
|
|
|
times[4].Clock();
|
2006-02-24 04:48:15 +00:00
|
|
|
P_InitTagLists(); // killough 1/30/98: Create xref tables for tags
|
2008-08-10 03:25:08 +00:00
|
|
|
times[4].Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 03:25:08 +00:00
|
|
|
times[5].Clock();
|
2006-02-24 04:48:15 +00:00
|
|
|
if (!buildmap)
|
|
|
|
{
|
|
|
|
P_SetSlopes ();
|
|
|
|
}
|
2008-08-10 03:25:08 +00:00
|
|
|
times[5].Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (showloadtimes)
|
|
|
|
{
|
|
|
|
Printf ("---Group Lines Times---\n");
|
|
|
|
for (i = 0; i < 7; ++i)
|
|
|
|
{
|
2008-08-23 02:38:00 +00:00
|
|
|
Printf (" time %d:%9.4f ms\n", i, times[i].TimeMS());
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// P_LoadReject
|
|
|
|
//
|
2006-06-14 15:56:56 +00:00
|
|
|
void P_LoadReject (MapData * map, bool junk)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
const int neededsize = (numsectors * numsectors + 7) >> 3;
|
|
|
|
int rejectsize;
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
if (strnicmp (map->MapLumps[ML_REJECT].Name, "REJECT", 8) != 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
rejectsize = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-06-14 15:56:56 +00:00
|
|
|
rejectsize = junk ? 0 : map->Size(ML_REJECT);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rejectsize < neededsize)
|
|
|
|
{
|
|
|
|
if (rejectsize > 0)
|
|
|
|
{
|
|
|
|
Printf ("REJECT is %d byte%s too small.\n", neededsize - rejectsize,
|
|
|
|
neededsize-rejectsize==1?"":"s");
|
|
|
|
}
|
|
|
|
rejectmatrix = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Check if the reject has some actual content. If not, free it.
|
|
|
|
rejectsize = MIN (rejectsize, neededsize);
|
|
|
|
rejectmatrix = new BYTE[rejectsize];
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
map->Seek(ML_REJECT);
|
|
|
|
map->file->Read (rejectmatrix, rejectsize);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
int qwords = rejectsize / 8;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (qwords > 0)
|
|
|
|
{
|
|
|
|
const QWORD *qreject = (const QWORD *)rejectmatrix;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (qreject[i] != 0)
|
|
|
|
return;
|
|
|
|
} while (++i < qwords);
|
|
|
|
}
|
|
|
|
rejectsize &= 7;
|
|
|
|
qwords *= 8;
|
|
|
|
for (i = 0; i < rejectsize; ++i)
|
|
|
|
{
|
2012-03-20 02:09:48 +00:00
|
|
|
if (rejectmatrix[qwords + i] != 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reject has no data, so pretend it isn't there.
|
|
|
|
delete[] rejectmatrix;
|
|
|
|
rejectmatrix = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// [RH] P_LoadBehavior
|
|
|
|
//
|
2006-06-14 15:56:56 +00:00
|
|
|
void P_LoadBehavior (MapData * map)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-06-14 15:56:56 +00:00
|
|
|
map->Seek(ML_BEHAVIOR);
|
|
|
|
FBehavior::StaticLoadModule (-1, map->file, map->Size(ML_BEHAVIOR));
|
2006-02-24 04:48:15 +00:00
|
|
|
if (!FBehavior::StaticCheckAllGood ())
|
|
|
|
{
|
|
|
|
Printf ("ACS scripts unloaded.\n");
|
|
|
|
FBehavior::StaticUnloadModules ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Hash the sector tags across the sectors and linedefs.
|
|
|
|
static void P_InitTagLists ()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=numsectors; --i>=0; ) // Initially make all slots empty.
|
|
|
|
sectors[i].firsttag = -1;
|
|
|
|
for (i=numsectors; --i>=0; ) // Proceed from last to first sector
|
|
|
|
{ // so that lower sectors appear first
|
|
|
|
int j = (unsigned) sectors[i].tag % (unsigned) numsectors; // Hash func
|
|
|
|
sectors[i].nexttag = sectors[j].firsttag; // Prepend sector to chain
|
|
|
|
sectors[j].firsttag = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
// killough 4/17/98: same thing, only for linedefs
|
|
|
|
|
|
|
|
for (i=numlines; --i>=0; ) // Initially make all slots empty.
|
|
|
|
lines[i].firstid = -1;
|
|
|
|
for (i=numlines; --i>=0; ) // Proceed from last to first linedef
|
|
|
|
{ // so that lower linedefs appear first
|
|
|
|
int j = (unsigned) lines[i].id % (unsigned) numlines; // Hash func
|
|
|
|
lines[i].nextid = lines[j].firstid; // Prepend linedef to chain
|
|
|
|
lines[j].firstid = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
void P_GetPolySpots (MapData * map, TArray<FNodeBuilder::FPolyStart> &spots, TArray<FNodeBuilder::FPolyStart> &anchors)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-06-14 15:56:56 +00:00
|
|
|
if (map->HasBehavior)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int spot1, spot2, spot3, anchor;
|
2006-06-14 15:56:56 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
if (gameinfo.gametype == GAME_Hexen)
|
|
|
|
{
|
2008-05-08 08:06:26 +00:00
|
|
|
spot1 = PO_HEX_SPAWN_TYPE;
|
|
|
|
spot2 = PO_HEX_SPAWNCRUSH_TYPE;
|
|
|
|
anchor = PO_HEX_ANCHOR_TYPE;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-05-08 08:06:26 +00:00
|
|
|
spot1 = PO_SPAWN_TYPE;
|
|
|
|
spot2 = PO_SPAWNCRUSH_TYPE;
|
|
|
|
anchor = PO_ANCHOR_TYPE;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-05-08 08:06:26 +00:00
|
|
|
spot3 = PO_SPAWNHURT_TYPE;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-05-08 08:06:26 +00:00
|
|
|
for (unsigned int i = 0; i < MapThingsConverted.Size(); ++i)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-05-08 08:06:26 +00:00
|
|
|
if (MapThingsConverted[i].type == spot1 || MapThingsConverted[i].type == spot2 ||
|
|
|
|
MapThingsConverted[i].type == spot3 || MapThingsConverted[i].type == anchor)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
FNodeBuilder::FPolyStart newvert;
|
2008-05-08 08:06:26 +00:00
|
|
|
newvert.x = MapThingsConverted[i].x;
|
|
|
|
newvert.y = MapThingsConverted[i].y;
|
|
|
|
newvert.polynum = MapThingsConverted[i].angle;
|
|
|
|
if (MapThingsConverted[i].type == anchor)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
anchors.Push (newvert);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spots.Push (newvert);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extern polyblock_t **PolyBlockMap;
|
|
|
|
|
|
|
|
void P_FreeLevelData ()
|
|
|
|
{
|
2011-07-07 21:43:49 +00:00
|
|
|
Renderer->CleanLevelData();
|
2010-07-23 05:56:25 +00:00
|
|
|
FPolyObj::ClearAllSubsectorLinks(); // can't be done as part of the polyobj deletion process.
|
2006-05-11 04:00:58 +00:00
|
|
|
SN_StopAllSequences ();
|
2006-02-24 04:48:15 +00:00
|
|
|
DThinker::DestroyAllThinkers ();
|
|
|
|
level.total_monsters = level.total_items = level.total_secrets =
|
|
|
|
level.killed_monsters = level.found_items = level.found_secrets =
|
|
|
|
wminfo.maxfrags = 0;
|
2008-03-18 18:18:18 +00:00
|
|
|
|
2006-05-12 03:14:40 +00:00
|
|
|
FBehavior::StaticUnloadModules ();
|
2006-02-24 04:48:15 +00:00
|
|
|
if (vertexes != NULL)
|
|
|
|
{
|
|
|
|
delete[] vertexes;
|
|
|
|
vertexes = NULL;
|
|
|
|
}
|
2010-12-15 23:10:08 +00:00
|
|
|
numvertexes = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (segs != NULL)
|
|
|
|
{
|
|
|
|
delete[] segs;
|
|
|
|
segs = NULL;
|
|
|
|
}
|
2010-12-15 23:10:08 +00:00
|
|
|
numsegs = 0;
|
2010-08-27 15:20:05 +00:00
|
|
|
if (glsegextras != NULL)
|
|
|
|
{
|
|
|
|
delete[] glsegextras;
|
|
|
|
glsegextras = NULL;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
if (sectors != NULL)
|
|
|
|
{
|
2008-03-18 18:18:18 +00:00
|
|
|
delete[] sectors[0].e;
|
2006-02-24 04:48:15 +00:00
|
|
|
delete[] sectors;
|
|
|
|
sectors = NULL;
|
|
|
|
}
|
2010-12-15 23:10:08 +00:00
|
|
|
numsectors = 0;
|
2010-09-03 02:11:35 +00:00
|
|
|
if (gamenodes != NULL && gamenodes != nodes)
|
2010-08-27 15:20:05 +00:00
|
|
|
{
|
2010-09-03 02:11:35 +00:00
|
|
|
delete[] gamenodes;
|
2010-08-27 15:20:05 +00:00
|
|
|
}
|
2010-09-03 02:11:35 +00:00
|
|
|
if (gamesubsectors != NULL && gamesubsectors != subsectors)
|
2010-08-27 15:20:05 +00:00
|
|
|
{
|
2010-09-03 02:11:35 +00:00
|
|
|
delete[] gamesubsectors;
|
2010-08-27 15:20:05 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
if (subsectors != NULL)
|
|
|
|
{
|
2010-08-01 02:41:56 +00:00
|
|
|
for (int i = 0; i < numsubsectors; ++i)
|
|
|
|
{
|
|
|
|
if (subsectors[i].BSP != NULL)
|
|
|
|
{
|
|
|
|
delete subsectors[i].BSP;
|
|
|
|
}
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
delete[] subsectors;
|
|
|
|
}
|
|
|
|
if (nodes != NULL)
|
|
|
|
{
|
|
|
|
delete[] nodes;
|
|
|
|
}
|
2010-09-03 02:11:35 +00:00
|
|
|
subsectors = gamesubsectors = NULL;
|
|
|
|
numsubsectors = numgamesubsectors = 0;
|
|
|
|
nodes = gamenodes = NULL;
|
|
|
|
numnodes = numgamenodes = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (lines != NULL)
|
|
|
|
{
|
|
|
|
delete[] lines;
|
|
|
|
lines = NULL;
|
|
|
|
}
|
2010-12-15 23:10:08 +00:00
|
|
|
numlines = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (sides != NULL)
|
|
|
|
{
|
|
|
|
delete[] sides;
|
|
|
|
sides = NULL;
|
|
|
|
}
|
2010-12-15 23:10:08 +00:00
|
|
|
numsides = 0;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
if (blockmaplump != NULL)
|
|
|
|
{
|
|
|
|
delete[] blockmaplump;
|
|
|
|
blockmaplump = NULL;
|
|
|
|
}
|
|
|
|
if (blocklinks != NULL)
|
|
|
|
{
|
|
|
|
delete[] blocklinks;
|
|
|
|
blocklinks = NULL;
|
|
|
|
}
|
|
|
|
if (PolyBlockMap != NULL)
|
|
|
|
{
|
|
|
|
for (int i = bmapwidth*bmapheight-1; i >= 0; --i)
|
|
|
|
{
|
|
|
|
polyblock_t *link = PolyBlockMap[i];
|
|
|
|
while (link != NULL)
|
|
|
|
{
|
|
|
|
polyblock_t *next = link->next;
|
|
|
|
delete link;
|
|
|
|
link = next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delete[] PolyBlockMap;
|
|
|
|
PolyBlockMap = NULL;
|
|
|
|
}
|
|
|
|
if (rejectmatrix != NULL)
|
|
|
|
{
|
|
|
|
delete[] rejectmatrix;
|
|
|
|
rejectmatrix = NULL;
|
|
|
|
}
|
|
|
|
if (linebuffer != NULL)
|
|
|
|
{
|
|
|
|
delete[] linebuffer;
|
|
|
|
linebuffer = NULL;
|
|
|
|
}
|
|
|
|
if (polyobjs != NULL)
|
|
|
|
{
|
|
|
|
delete[] polyobjs;
|
|
|
|
polyobjs = NULL;
|
|
|
|
}
|
2006-05-18 04:25:26 +00:00
|
|
|
po_NumPolyobjs = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (zones != NULL)
|
|
|
|
{
|
|
|
|
delete[] zones;
|
2006-05-11 04:00:58 +00:00
|
|
|
zones = NULL;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-12-15 23:10:08 +00:00
|
|
|
numzones = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
P_FreeStrifeConversations ();
|
2006-06-14 23:22:14 +00:00
|
|
|
if (level.Scrolls != NULL)
|
|
|
|
{
|
|
|
|
delete[] level.Scrolls;
|
|
|
|
level.Scrolls = NULL;
|
|
|
|
}
|
2009-05-11 21:05:40 +00:00
|
|
|
P_ClearUDMFKeys();
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-11 04:00:58 +00:00
|
|
|
extern msecnode_t *headsecnode;
|
|
|
|
|
2006-05-12 03:14:40 +00:00
|
|
|
void P_FreeExtraLevelData()
|
2006-05-11 04:00:58 +00:00
|
|
|
{
|
2006-05-12 03:14:40 +00:00
|
|
|
// Free all blocknodes and msecnodes.
|
|
|
|
// *NEVER* call this function without calling
|
|
|
|
// P_FreeLevelData() first, or they might not all be freed.
|
2006-05-11 04:00:58 +00:00
|
|
|
{
|
2006-05-12 03:14:40 +00:00
|
|
|
FBlockNode *node = FBlockNode::FreeBlocks;
|
|
|
|
while (node != NULL)
|
2006-05-11 04:00:58 +00:00
|
|
|
{
|
2006-05-12 03:14:40 +00:00
|
|
|
FBlockNode *next = node->NextBlock;
|
|
|
|
delete node;
|
|
|
|
node = next;
|
2006-05-11 04:00:58 +00:00
|
|
|
}
|
2010-12-14 00:50:02 +00:00
|
|
|
FBlockNode::FreeBlocks = NULL;
|
2006-05-12 03:14:40 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
msecnode_t *node = headsecnode;
|
2006-05-11 04:00:58 +00:00
|
|
|
|
2006-05-12 03:14:40 +00:00
|
|
|
while (node != NULL)
|
2006-05-11 04:00:58 +00:00
|
|
|
{
|
2006-05-12 03:14:40 +00:00
|
|
|
msecnode_t *next = node->m_snext;
|
2008-02-17 02:40:03 +00:00
|
|
|
M_Free (node);
|
2006-05-12 03:14:40 +00:00
|
|
|
node = next;
|
2006-05-11 04:00:58 +00:00
|
|
|
}
|
2006-05-12 03:14:40 +00:00
|
|
|
headsecnode = NULL;
|
2006-05-11 04:00:58 +00:00
|
|
|
}
|
2006-05-12 03:14:40 +00:00
|
|
|
}
|
2006-05-11 04:00:58 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
// P_SetupLevel
|
|
|
|
//
|
|
|
|
|
|
|
|
// [RH] position indicates the start spot to spawn at
|
|
|
|
void P_SetupLevel (char *lumpname, int position)
|
|
|
|
{
|
2008-08-10 03:25:08 +00:00
|
|
|
cycle_t times[20];
|
2008-05-08 08:06:26 +00:00
|
|
|
FMapThing *buildthings;
|
2006-02-24 04:48:15 +00:00
|
|
|
int numbuildthings;
|
2006-06-14 15:56:56 +00:00
|
|
|
int i;
|
2006-02-24 04:48:15 +00:00
|
|
|
bool buildmap;
|
2012-02-21 21:52:42 +00:00
|
|
|
const int *oldvertextable = NULL;
|
2008-08-10 11:29:19 +00:00
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
// This is motivated as follows:
|
2011-07-07 21:43:49 +00:00
|
|
|
|
|
|
|
bool RequireGLNodes = Renderer->RequireGLNodes() || am_textured;
|
2010-08-27 15:20:05 +00:00
|
|
|
|
2008-08-10 11:29:19 +00:00
|
|
|
for (i = 0; i < (int)countof(times); ++i)
|
|
|
|
{
|
|
|
|
times[i].Reset();
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2011-01-29 11:09:38 +00:00
|
|
|
level.maptype = MAPTYPE_UNKNOWN;
|
2006-02-24 04:48:15 +00:00
|
|
|
wminfo.partime = 180;
|
|
|
|
|
2010-12-14 00:50:02 +00:00
|
|
|
MapThingsConverted.Clear();
|
|
|
|
linemap.Clear();
|
2006-02-24 04:48:15 +00:00
|
|
|
FCanvasTextureInfo::EmptyList ();
|
|
|
|
R_FreePastViewers ();
|
2010-12-14 00:50:02 +00:00
|
|
|
P_ClearUDMFKeys();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (!savegamerestore)
|
|
|
|
{
|
|
|
|
for (i = 0; i < MAXPLAYERS; ++i)
|
|
|
|
{
|
|
|
|
players[i].killcount = players[i].secretcount
|
|
|
|
= players[i].itemcount = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i = 0; i < MAXPLAYERS; ++i)
|
|
|
|
{
|
|
|
|
players[i].mo = NULL;
|
|
|
|
}
|
- Discovered that Shader Model 1.4 clamps my constants, so I can't use
palettes smaller than 256 entries with the shader I wrote for it. Is there
a list of gotchas like this listed some where? I'd really like to see it.
Well, when compiled with SM2.0, the PalTex shader seems to be every-so-
slightly faster on my GF7950GT than the SM1.4 version, so I guess it's a
minor win for cards that support it.
- Fixed: ST_Endoom() failed to free the bitmap it used.
- Added the DTA_ColorOverlay attribute to blend a color with the texture
being drawn. For software, this (currently) only works with black. For
hardware, it works with any color. The motiviation for this was so I could
rewrite the status bar calls that passed DIM_MAP to DTA_Translation to
draw darker icons into something that didn't require making a whole new
remap table.
- After having an "OMG! How could I have been so stupid?" moment, I have
removed the off-by-one check from D3DFB. I had thought the off-by-one error
was caused by rounding errors by the shader hardware. Not so. Rather, I
wasn't sampling what I thought I was sampling. A texture that uses palette
index 255 passes the value 1.0 to the shader. The shader needs to adjust the
range of its palette indexes, or it will end up trying to read color 256
from the palette texture when it should be reading color 255. Doh!
- The TranslationToTable() function has been added to map from translation
numbers used by actors to the tables those numbers represent. This function
performs validation for the input and returns NULL if the input value
is invalid.
- Major changes to the way translation tables work: No longer are they each a
256-byte array. Instead, the FRemapTable structure is used to represent each
one. It includes a remap array for the software renderer, a palette array
for a hardware renderer, and a native texture pointer for D3DFB. The
translationtables array itself is now an array of TArrays that point to the
real tables. The DTA_Translation attribute must also be passed a pointer
to a FRemapTable, not a byte array as previously.
- Modified DFrameBuffer::DrawRateStuff() so that it can do its thing properly
for D3DFB's 2D mode. Before, any fullscreen graphics (like help images)
covered it up.
SVN r640 (trunk)
2007-12-26 04:42:15 +00:00
|
|
|
// [RH] Clear any scripted translation colors the previous level may have set.
|
2007-12-26 05:03:14 +00:00
|
|
|
for (i = 0; i < int(translationtables[TRANSLATION_LevelScripted].Size()); ++i)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
- Discovered that Shader Model 1.4 clamps my constants, so I can't use
palettes smaller than 256 entries with the shader I wrote for it. Is there
a list of gotchas like this listed some where? I'd really like to see it.
Well, when compiled with SM2.0, the PalTex shader seems to be every-so-
slightly faster on my GF7950GT than the SM1.4 version, so I guess it's a
minor win for cards that support it.
- Fixed: ST_Endoom() failed to free the bitmap it used.
- Added the DTA_ColorOverlay attribute to blend a color with the texture
being drawn. For software, this (currently) only works with black. For
hardware, it works with any color. The motiviation for this was so I could
rewrite the status bar calls that passed DIM_MAP to DTA_Translation to
draw darker icons into something that didn't require making a whole new
remap table.
- After having an "OMG! How could I have been so stupid?" moment, I have
removed the off-by-one check from D3DFB. I had thought the off-by-one error
was caused by rounding errors by the shader hardware. Not so. Rather, I
wasn't sampling what I thought I was sampling. A texture that uses palette
index 255 passes the value 1.0 to the shader. The shader needs to adjust the
range of its palette indexes, or it will end up trying to read color 256
from the palette texture when it should be reading color 255. Doh!
- The TranslationToTable() function has been added to map from translation
numbers used by actors to the tables those numbers represent. This function
performs validation for the input and returns NULL if the input value
is invalid.
- Major changes to the way translation tables work: No longer are they each a
256-byte array. Instead, the FRemapTable structure is used to represent each
one. It includes a remap array for the software renderer, a palette array
for a hardware renderer, and a native texture pointer for D3DFB. The
translationtables array itself is now an array of TArrays that point to the
real tables. The DTA_Translation attribute must also be passed a pointer
to a FRemapTable, not a byte array as previously.
- Modified DFrameBuffer::DrawRateStuff() so that it can do its thing properly
for D3DFB's 2D mode. Before, any fullscreen graphics (like help images)
covered it up.
SVN r640 (trunk)
2007-12-26 04:42:15 +00:00
|
|
|
FRemapTable *table = translationtables[TRANSLATION_LevelScripted][i];
|
|
|
|
if (table != NULL)
|
|
|
|
{
|
|
|
|
delete table;
|
|
|
|
translationtables[TRANSLATION_LevelScripted][i] = NULL;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
- Discovered that Shader Model 1.4 clamps my constants, so I can't use
palettes smaller than 256 entries with the shader I wrote for it. Is there
a list of gotchas like this listed some where? I'd really like to see it.
Well, when compiled with SM2.0, the PalTex shader seems to be every-so-
slightly faster on my GF7950GT than the SM1.4 version, so I guess it's a
minor win for cards that support it.
- Fixed: ST_Endoom() failed to free the bitmap it used.
- Added the DTA_ColorOverlay attribute to blend a color with the texture
being drawn. For software, this (currently) only works with black. For
hardware, it works with any color. The motiviation for this was so I could
rewrite the status bar calls that passed DIM_MAP to DTA_Translation to
draw darker icons into something that didn't require making a whole new
remap table.
- After having an "OMG! How could I have been so stupid?" moment, I have
removed the off-by-one check from D3DFB. I had thought the off-by-one error
was caused by rounding errors by the shader hardware. Not so. Rather, I
wasn't sampling what I thought I was sampling. A texture that uses palette
index 255 passes the value 1.0 to the shader. The shader needs to adjust the
range of its palette indexes, or it will end up trying to read color 256
from the palette texture when it should be reading color 255. Doh!
- The TranslationToTable() function has been added to map from translation
numbers used by actors to the tables those numbers represent. This function
performs validation for the input and returns NULL if the input value
is invalid.
- Major changes to the way translation tables work: No longer are they each a
256-byte array. Instead, the FRemapTable structure is used to represent each
one. It includes a remap array for the software renderer, a palette array
for a hardware renderer, and a native texture pointer for D3DFB. The
translationtables array itself is now an array of TArrays that point to the
real tables. The DTA_Translation attribute must also be passed a pointer
to a FRemapTable, not a byte array as previously.
- Modified DFrameBuffer::DrawRateStuff() so that it can do its thing properly
for D3DFB's 2D mode. Before, any fullscreen graphics (like help images)
covered it up.
SVN r640 (trunk)
2007-12-26 04:42:15 +00:00
|
|
|
translationtables[TRANSLATION_LevelScripted].Clear();
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// Initial height of PointOfView will be set by player think.
|
|
|
|
players[consoleplayer].viewz = 1;
|
|
|
|
|
|
|
|
// Make sure all sounds are stopped before Z_FreeTags.
|
|
|
|
S_Start ();
|
|
|
|
// [RH] Clear all ThingID hash chains.
|
|
|
|
AActor::ClearTIDHashes ();
|
|
|
|
|
|
|
|
// [RH] clear out the mid-screen message
|
2008-11-27 17:43:36 +00:00
|
|
|
C_MidPrint (NULL, NULL);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// Free all level data from the previous map
|
|
|
|
P_FreeLevelData ();
|
2008-06-04 17:53:15 +00:00
|
|
|
interpolator.ClearInterpolations(); // [RH] Nothing to interpolate on a fresh level.
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-03-18 01:07:50 +00:00
|
|
|
MapData *map = P_OpenMapData(lumpname);
|
2006-06-14 15:56:56 +00:00
|
|
|
if (map == NULL)
|
|
|
|
{
|
|
|
|
I_Error("Unable to open map '%s'\n", lumpname);
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// find map num
|
2006-06-14 15:56:56 +00:00
|
|
|
level.lumpnum = map->lumpnum;
|
2010-08-27 15:20:05 +00:00
|
|
|
hasglnodes = false;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// [RH] Support loading Build maps (because I felt like it. :-)
|
|
|
|
buildmap = false;
|
2012-10-22 01:28:11 +00:00
|
|
|
if (map->Size(0) > 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2012-10-22 01:28:11 +00:00
|
|
|
BYTE *mapdata = new BYTE[map->Size(0)];
|
2006-06-15 03:31:19 +00:00
|
|
|
map->Seek(0);
|
2012-10-22 01:28:11 +00:00
|
|
|
map->file->Read(mapdata, map->Size(0));
|
2010-03-18 01:07:50 +00:00
|
|
|
times[0].Clock();
|
2012-10-22 01:28:11 +00:00
|
|
|
buildmap = P_LoadBuildMap (mapdata, map->Size(0), &buildthings, &numbuildthings);
|
2010-03-18 01:07:50 +00:00
|
|
|
times[0].Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
delete[] mapdata;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!buildmap)
|
|
|
|
{
|
|
|
|
// note: most of this ordering is important
|
|
|
|
ForceNodeBuild = gennodes;
|
2009-02-05 02:55:28 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// [RH] Load in the BEHAVIOR lump
|
|
|
|
FBehavior::StaticUnloadModules ();
|
2006-06-14 15:56:56 +00:00
|
|
|
if (map->HasBehavior)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-06-14 15:56:56 +00:00
|
|
|
P_LoadBehavior (map);
|
2011-01-29 11:09:38 +00:00
|
|
|
level.maptype = MAPTYPE_HEXEN;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-05-11 21:16:32 +00:00
|
|
|
// We need translators only for Doom format maps.
|
2010-02-06 15:31:26 +00:00
|
|
|
const char *translator;
|
|
|
|
|
|
|
|
if (!level.info->Translator.IsEmpty())
|
|
|
|
{
|
|
|
|
// The map defines its own translator.
|
|
|
|
translator = level.info->Translator.GetChars();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Has the user overridden the game's default translator with a commandline parameter?
|
|
|
|
translator = Args->CheckValue("-xlat");
|
|
|
|
if (translator == NULL)
|
|
|
|
{
|
|
|
|
// Use the game's default.
|
|
|
|
translator = gameinfo.translator.GetChars();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
P_LoadTranslator(translator);
|
2011-01-29 11:09:38 +00:00
|
|
|
level.maptype = MAPTYPE_DOOM;
|
|
|
|
}
|
|
|
|
if (map->isText)
|
|
|
|
{
|
|
|
|
level.maptype = MAPTYPE_UDMF;
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
2009-02-08 22:35:23 +00:00
|
|
|
CheckCompatibility(map);
|
2013-02-07 21:32:06 +00:00
|
|
|
if (ib_compatflags & BCOMPATF_REBUILDNODES)
|
|
|
|
{
|
|
|
|
ForceNodeBuild = true;
|
|
|
|
}
|
2011-01-29 11:09:38 +00:00
|
|
|
T_LoadScripts(map);
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
if (!map->HasBehavior || map->isText)
|
|
|
|
{
|
|
|
|
// Doom format and UDMF text maps get strict monster activation unless the mapinfo
|
2006-02-24 04:48:15 +00:00
|
|
|
// specifies differently.
|
2009-02-03 19:11:43 +00:00
|
|
|
if (!(level.flags2 & LEVEL2_LAXACTIVATIONMAPINFO))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-02-03 19:11:43 +00:00
|
|
|
level.flags2 &= ~LEVEL2_LAXMONSTERACTIVATION;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-11 21:16:32 +00:00
|
|
|
|
2008-05-22 19:35:38 +00:00
|
|
|
if (!map->HasBehavior && !map->isText)
|
|
|
|
{
|
|
|
|
// set compatibility flags
|
|
|
|
if (gameinfo.gametype == GAME_Strife)
|
|
|
|
{
|
2009-02-03 19:11:43 +00:00
|
|
|
level.flags2 |= LEVEL2_RAILINGHACK;
|
2008-05-22 19:35:38 +00:00
|
|
|
}
|
2009-02-03 19:11:43 +00:00
|
|
|
level.flags2 |= LEVEL2_DUMMYSWITCHES;
|
2008-05-22 19:35:38 +00:00
|
|
|
}
|
|
|
|
|
2006-05-17 01:38:07 +00:00
|
|
|
FBehavior::StaticLoadDefaultModules ();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-05-08 08:06:26 +00:00
|
|
|
P_LoadStrifeConversations (map, lumpname);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2011-05-08 00:30:32 +00:00
|
|
|
FMissingTextureTracker missingtex;
|
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
if (!map->isText)
|
|
|
|
{
|
2008-08-10 03:25:08 +00:00
|
|
|
times[0].Clock();
|
2008-05-11 21:16:32 +00:00
|
|
|
P_LoadVertexes (map);
|
2008-08-10 03:25:08 +00:00
|
|
|
times[0].Unclock();
|
2008-05-11 21:16:32 +00:00
|
|
|
|
|
|
|
// Check for maps without any BSP data at all (e.g. SLIGE)
|
2008-08-10 03:25:08 +00:00
|
|
|
times[1].Clock();
|
2011-05-08 00:30:32 +00:00
|
|
|
P_LoadSectors (map, missingtex);
|
2008-08-10 03:25:08 +00:00
|
|
|
times[1].Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 03:25:08 +00:00
|
|
|
times[2].Clock();
|
2008-05-11 21:16:32 +00:00
|
|
|
P_LoadSideDefs (map);
|
2008-08-10 03:25:08 +00:00
|
|
|
times[2].Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 03:25:08 +00:00
|
|
|
times[3].Clock();
|
2008-05-11 21:16:32 +00:00
|
|
|
if (!map->HasBehavior)
|
|
|
|
P_LoadLineDefs (map);
|
|
|
|
else
|
|
|
|
P_LoadLineDefs2 (map); // [RH] Load Hexen-style linedefs
|
2008-08-10 03:25:08 +00:00
|
|
|
times[3].Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 03:25:08 +00:00
|
|
|
times[4].Clock();
|
2011-05-08 00:30:32 +00:00
|
|
|
P_LoadSideDefs2 (map, missingtex);
|
2008-08-10 03:25:08 +00:00
|
|
|
times[4].Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 03:25:08 +00:00
|
|
|
times[5].Clock();
|
2008-05-11 21:16:32 +00:00
|
|
|
P_FinishLoadingLineDefs ();
|
2008-08-10 03:25:08 +00:00
|
|
|
times[5].Unclock();
|
2008-05-11 21:16:32 +00:00
|
|
|
|
2008-05-30 06:56:50 +00:00
|
|
|
if (!map->HasBehavior)
|
|
|
|
P_LoadThings (map);
|
|
|
|
else
|
|
|
|
P_LoadThings2 (map); // [RH] Load Hexen-style things
|
2009-02-06 00:16:57 +00:00
|
|
|
|
2010-04-11 11:18:33 +00:00
|
|
|
SetCompatibilityParams();
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-05-08 00:30:32 +00:00
|
|
|
P_ParseTextMap(map, missingtex);
|
2008-05-11 21:16:32 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 03:25:08 +00:00
|
|
|
times[6].Clock();
|
2010-08-15 14:09:17 +00:00
|
|
|
P_LoopSidedefs (true);
|
2008-08-10 03:25:08 +00:00
|
|
|
times[6].Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
linemap.Clear();
|
|
|
|
linemap.ShrinkToFit();
|
2011-05-08 00:30:32 +00:00
|
|
|
|
|
|
|
SummarizeMissingTextures(missingtex);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ForceNodeBuild = true;
|
2011-01-29 11:09:38 +00:00
|
|
|
level.maptype = MAPTYPE_BUILD;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-08-27 15:20:05 +00:00
|
|
|
bool reloop = false;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (!ForceNodeBuild)
|
|
|
|
{
|
|
|
|
// Check for compressed nodes first, then uncompressed nodes
|
|
|
|
FWadLump test;
|
2012-12-07 06:16:07 +00:00
|
|
|
DWORD id = MAKE_ID('X','x','X','x'), idcheck = 0, idcheck2 = 0, idcheck3 = 0, idcheck4 = 0, idcheck5 = 0, idcheck6 = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2012-10-22 01:28:11 +00:00
|
|
|
if (map->Size(ML_ZNODES) != 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-08-27 15:20:05 +00:00
|
|
|
// Test normal nodes first
|
2006-06-14 15:56:56 +00:00
|
|
|
map->Seek(ML_ZNODES);
|
2006-02-24 04:48:15 +00:00
|
|
|
idcheck = MAKE_ID('Z','N','O','D');
|
2010-04-17 20:49:18 +00:00
|
|
|
idcheck2 = MAKE_ID('X','N','O','D');
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2012-10-22 01:28:11 +00:00
|
|
|
else if (map->Size(ML_GLZNODES) != 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-06-14 15:56:56 +00:00
|
|
|
map->Seek(ML_GLZNODES);
|
2006-02-24 04:48:15 +00:00
|
|
|
idcheck = MAKE_ID('Z','G','L','N');
|
2009-03-17 03:34:31 +00:00
|
|
|
idcheck2 = MAKE_ID('Z','G','L','2');
|
2012-12-07 06:16:07 +00:00
|
|
|
idcheck3 = MAKE_ID('Z','G','L','3');
|
|
|
|
idcheck4 = MAKE_ID('X','G','L','N');
|
|
|
|
idcheck5 = MAKE_ID('X','G','L','2');
|
|
|
|
idcheck6 = MAKE_ID('X','G','L','3');
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-06-14 15:56:56 +00:00
|
|
|
map->file->Read (&id, 4);
|
2012-12-07 07:40:41 +00:00
|
|
|
if (id != 0 && (id == idcheck || id == idcheck2 || id == idcheck3 || id == idcheck4 || id == idcheck5 || id == idcheck6))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2006-06-14 15:56:56 +00:00
|
|
|
P_LoadZNodes (*map->file, id);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
catch (CRecoverableError &error)
|
|
|
|
{
|
|
|
|
Printf ("Error loading nodes: %s\n", error.GetMessage());
|
|
|
|
|
|
|
|
ForceNodeBuild = true;
|
|
|
|
if (subsectors != NULL)
|
|
|
|
{
|
|
|
|
delete[] subsectors;
|
|
|
|
subsectors = NULL;
|
|
|
|
}
|
|
|
|
if (segs != NULL)
|
|
|
|
{
|
|
|
|
delete[] segs;
|
|
|
|
segs = NULL;
|
|
|
|
}
|
|
|
|
if (nodes != NULL)
|
|
|
|
{
|
|
|
|
delete[] nodes;
|
|
|
|
nodes = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-05-11 21:16:32 +00:00
|
|
|
else if (!map->isText) // regular nodes are not supported for text maps
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-06 15:31:26 +00:00
|
|
|
// If all 3 node related lumps are empty there's no need to output a message.
|
|
|
|
// This just means that the map has no nodes and the engine is supposed to build them.
|
|
|
|
if (map->Size(ML_SEGS) != 0 || map->Size(ML_SSECTORS) != 0 || map->Size(ML_NODES) != 0)
|
|
|
|
{
|
2010-04-17 08:53:32 +00:00
|
|
|
if (!P_CheckV4Nodes(map))
|
|
|
|
{
|
|
|
|
times[7].Clock();
|
|
|
|
P_LoadSubsectors<mapsubsector_t, mapseg_t> (map);
|
|
|
|
times[7].Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-04-17 08:53:32 +00:00
|
|
|
times[8].Clock();
|
|
|
|
if (!ForceNodeBuild) P_LoadNodes<mapnode_t, mapsubsector_t> (map);
|
|
|
|
times[8].Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-04-17 08:53:32 +00:00
|
|
|
times[9].Clock();
|
|
|
|
if (!ForceNodeBuild) P_LoadSegs<mapseg_t> (map);
|
|
|
|
times[9].Unclock();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
times[7].Clock();
|
|
|
|
P_LoadSubsectors<mapsubsector4_t, mapseg4_t> (map);
|
|
|
|
times[7].Unclock();
|
|
|
|
|
|
|
|
times[8].Clock();
|
|
|
|
if (!ForceNodeBuild) P_LoadNodes<mapnode4_t, mapsubsector4_t> (map);
|
|
|
|
times[8].Unclock();
|
|
|
|
|
|
|
|
times[9].Clock();
|
|
|
|
if (!ForceNodeBuild) P_LoadSegs<mapseg4_t> (map);
|
|
|
|
times[9].Unclock();
|
|
|
|
}
|
2010-02-06 15:31:26 +00:00
|
|
|
}
|
|
|
|
else ForceNodeBuild = true;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-05-11 21:16:32 +00:00
|
|
|
else ForceNodeBuild = true;
|
2010-08-27 15:20:05 +00:00
|
|
|
|
|
|
|
// If loading the regular nodes failed try GL nodes before considering a rebuild
|
|
|
|
if (ForceNodeBuild)
|
|
|
|
{
|
|
|
|
if (P_LoadGLNodes(map))
|
|
|
|
{
|
2012-03-23 23:04:32 +00:00
|
|
|
ForceNodeBuild = false;
|
2010-08-27 15:20:05 +00:00
|
|
|
reloop = true;
|
|
|
|
}
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-08-27 15:20:05 +00:00
|
|
|
else reloop = true;
|
|
|
|
|
|
|
|
unsigned int startTime=0, endTime=0;
|
|
|
|
|
2010-08-27 17:34:25 +00:00
|
|
|
bool BuildGLNodes;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (ForceNodeBuild)
|
|
|
|
{
|
2012-02-21 21:52:42 +00:00
|
|
|
BuildGLNodes = RequireGLNodes || multiplayer || demoplayback || demorecording || genglnodes;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-01-03 10:04:56 +00:00
|
|
|
startTime = I_FPSTime ();
|
2006-02-24 04:48:15 +00:00
|
|
|
TArray<FNodeBuilder::FPolyStart> polyspots, anchors;
|
2006-06-14 15:56:56 +00:00
|
|
|
P_GetPolySpots (map, polyspots, anchors);
|
2006-02-24 04:48:15 +00:00
|
|
|
FNodeBuilder::FLevel leveldata =
|
|
|
|
{
|
|
|
|
vertexes, numvertexes,
|
|
|
|
sides, numsides,
|
2011-02-19 08:59:43 +00:00
|
|
|
lines, numlines,
|
|
|
|
0, 0, 0, 0
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
2006-06-06 21:39:08 +00:00
|
|
|
leveldata.FindMapBounds ();
|
2010-08-27 15:20:05 +00:00
|
|
|
// We need GL nodes if am_textured is on.
|
|
|
|
// In case a sync critical game mode is started, also build GL nodes to avoid problems
|
|
|
|
// if the different machines' am_textured setting differs.
|
|
|
|
FNodeBuilder builder (leveldata, polyspots, anchors, BuildGLNodes);
|
2006-02-24 04:48:15 +00:00
|
|
|
delete[] vertexes;
|
|
|
|
builder.Extract (nodes, numnodes,
|
2010-08-27 15:20:05 +00:00
|
|
|
segs, glsegextras, numsegs,
|
2006-02-24 04:48:15 +00:00
|
|
|
subsectors, numsubsectors,
|
|
|
|
vertexes, numvertexes);
|
2010-01-03 10:04:56 +00:00
|
|
|
endTime = I_FPSTime ();
|
2008-03-18 18:18:18 +00:00
|
|
|
DPrintf ("BSP generation took %.3f sec (%d segs)\n", (endTime - startTime) * 0.001, numsegs);
|
2012-02-21 21:52:42 +00:00
|
|
|
oldvertextable = builder.GetOldVertexTable();
|
2010-08-27 15:20:05 +00:00
|
|
|
reloop = true;
|
|
|
|
}
|
2010-08-27 16:53:11 +00:00
|
|
|
else
|
|
|
|
{
|
2010-08-27 17:34:25 +00:00
|
|
|
BuildGLNodes = false;
|
2010-08-27 16:53:11 +00:00
|
|
|
// Older ZDBSPs had problems with compressed sidedefs and assigned wrong sides to the segs if both sides were the same sidedef.
|
|
|
|
for(i=0;i<numsegs;i++)
|
|
|
|
{
|
|
|
|
seg_t * seg=&segs[i];
|
|
|
|
if (seg->backsector == seg->frontsector && seg->linedef)
|
|
|
|
{
|
|
|
|
fixed_t d1=P_AproxDistance(seg->v1->x-seg->linedef->v1->x,seg->v1->y-seg->linedef->v1->y);
|
|
|
|
fixed_t d2=P_AproxDistance(seg->v2->x-seg->linedef->v1->x,seg->v2->y-seg->linedef->v1->y);
|
|
|
|
|
|
|
|
if (d2<d1) // backside
|
|
|
|
{
|
|
|
|
seg->sidedef = seg->linedef->sidedef[1];
|
|
|
|
}
|
|
|
|
else // front side
|
|
|
|
{
|
|
|
|
seg->sidedef = seg->linedef->sidedef[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-08-27 15:20:05 +00:00
|
|
|
|
|
|
|
// Copy pointers to the old nodes so that R_PointInSubsector can use them
|
|
|
|
if (nodes && subsectors)
|
|
|
|
{
|
|
|
|
gamenodes = nodes;
|
|
|
|
numgamenodes = numnodes;
|
|
|
|
gamesubsectors = subsectors;
|
|
|
|
numgamesubsectors = numsubsectors;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gamenodes=NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RequireGLNodes)
|
|
|
|
{
|
|
|
|
// Build GL nodes if we want a textured automap or GL nodes are forced to be built.
|
|
|
|
// If the original nodes being loaded are not GL nodes they will be kept around for
|
|
|
|
// use in P_PointInSubsector to avoid problems with maps that depend on the specific
|
|
|
|
// nodes they were built with (P:AR E1M3 is a good example for a map where this is the case.)
|
2010-08-27 17:34:25 +00:00
|
|
|
reloop |= P_CheckNodes(map, BuildGLNodes, endTime - startTime);
|
2010-08-27 15:20:05 +00:00
|
|
|
hasglnodes = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hasglnodes = P_CheckForGLNodes();
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 03:25:08 +00:00
|
|
|
times[10].Clock();
|
2006-06-14 15:56:56 +00:00
|
|
|
P_LoadBlockMap (map);
|
2008-08-10 03:25:08 +00:00
|
|
|
times[10].Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 03:25:08 +00:00
|
|
|
times[11].Clock();
|
2006-06-14 15:56:56 +00:00
|
|
|
P_LoadReject (map, buildmap);
|
2008-08-10 03:25:08 +00:00
|
|
|
times[11].Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 03:25:08 +00:00
|
|
|
times[12].Clock();
|
2006-02-24 04:48:15 +00:00
|
|
|
P_GroupLines (buildmap);
|
2008-08-10 03:25:08 +00:00
|
|
|
times[12].Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 03:25:08 +00:00
|
|
|
times[13].Clock();
|
2006-02-24 04:48:15 +00:00
|
|
|
P_FloodZones ();
|
2008-08-10 03:25:08 +00:00
|
|
|
times[13].Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-08-27 15:20:05 +00:00
|
|
|
if (hasglnodes)
|
|
|
|
{
|
|
|
|
P_SetRenderSector();
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
bodyqueslot = 0;
|
|
|
|
// phares 8/10/98: Clear body queue so the corpses from previous games are
|
|
|
|
// not assumed to be from this one.
|
|
|
|
|
|
|
|
for (i = 0; i < BODYQUESIZE; i++)
|
|
|
|
bodyque[i] = NULL;
|
|
|
|
|
2012-07-08 01:43:47 +00:00
|
|
|
deathmatchstarts.Clear();
|
|
|
|
AllPlayerStarts.Clear();
|
|
|
|
memset(playerstarts, 0, sizeof(playerstarts));
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (!buildmap)
|
|
|
|
{
|
2009-12-28 00:01:07 +00:00
|
|
|
// [RH] Spawn slope creating things first.
|
2012-02-21 21:52:42 +00:00
|
|
|
P_SpawnSlopeMakers (&MapThingsConverted[0], &MapThingsConverted[MapThingsConverted.Size()], oldvertextable);
|
2010-01-30 22:53:37 +00:00
|
|
|
P_CopySlopes();
|
2009-12-28 00:01:07 +00:00
|
|
|
|
|
|
|
// Spawn 3d floors - must be done before spawning things so it can't be done in P_SpawnSpecials
|
|
|
|
P_Spawn3DFloors();
|
|
|
|
|
2008-08-10 03:25:08 +00:00
|
|
|
times[14].Clock();
|
2008-05-30 06:56:50 +00:00
|
|
|
P_SpawnThings(position);
|
2008-05-11 21:16:32 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
for (i = 0; i < MAXPLAYERS; ++i)
|
|
|
|
{
|
|
|
|
if (playeringame[i] && players[i].mo != NULL)
|
|
|
|
players[i].health = players[i].mo->health;
|
|
|
|
}
|
2008-08-10 03:25:08 +00:00
|
|
|
times[14].Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 03:25:08 +00:00
|
|
|
times[15].Clock();
|
2008-05-30 06:56:50 +00:00
|
|
|
if (!map->HasBehavior && !map->isText)
|
2006-02-24 04:48:15 +00:00
|
|
|
P_TranslateTeleportThings (); // [RH] Assign teleport destination TIDs
|
2008-08-10 03:25:08 +00:00
|
|
|
times[15].Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 0; i < numbuildthings; ++i)
|
|
|
|
{
|
2008-04-05 12:14:33 +00:00
|
|
|
SpawnMapThing (i, &buildthings[i], 0);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
delete[] buildthings;
|
|
|
|
}
|
2006-06-14 15:56:56 +00:00
|
|
|
delete map;
|
2012-02-21 21:52:42 +00:00
|
|
|
if (oldvertextable != NULL)
|
|
|
|
{
|
|
|
|
delete[] oldvertextable;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-03-18 18:18:18 +00:00
|
|
|
// set up world state
|
|
|
|
P_SpawnSpecials ();
|
|
|
|
|
2011-07-07 21:43:49 +00:00
|
|
|
// This must be done BEFORE the PolyObj Spawn!!!
|
|
|
|
Renderer->PreprocessLevel();
|
|
|
|
|
2008-08-10 03:25:08 +00:00
|
|
|
times[16].Clock();
|
2010-08-27 15:20:05 +00:00
|
|
|
if (reloop) P_LoopSidedefs (false);
|
2006-02-24 04:48:15 +00:00
|
|
|
PO_Init (); // Initialize the polyobjs
|
2008-08-10 03:25:08 +00:00
|
|
|
times[16].Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-08-01 05:16:09 +00:00
|
|
|
assert(sidetemp != NULL);
|
|
|
|
delete[] sidetemp;
|
|
|
|
sidetemp = NULL;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// if deathmatch, randomly spawn the active players
|
|
|
|
if (deathmatch)
|
|
|
|
{
|
|
|
|
for (i=0 ; i<MAXPLAYERS ; i++)
|
|
|
|
{
|
|
|
|
if (playeringame[i])
|
|
|
|
{
|
|
|
|
players[i].mo = NULL;
|
|
|
|
G_DeathMatchSpawnPlayer (i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-07-08 01:43:47 +00:00
|
|
|
// the same, but for random single/coop player starts
|
|
|
|
else if (level.flags2 & LEVEL2_RANDOMPLAYERSTARTS)
|
|
|
|
{
|
|
|
|
for (i = 0; i < MAXPLAYERS; ++i)
|
|
|
|
{
|
|
|
|
if (playeringame[i])
|
|
|
|
{
|
|
|
|
players[i].mo = NULL;
|
2012-07-08 02:18:15 +00:00
|
|
|
FPlayerStart *mthing = G_PickPlayerStart(i);
|
2013-01-03 02:08:08 +00:00
|
|
|
P_SpawnPlayer(mthing, i, (level.flags2 & LEVEL2_PRERAISEWEAPON) ? SPF_WEAPONFULLYUP : 0);
|
2012-07-08 01:43:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2011-07-07 21:55:55 +00:00
|
|
|
// Don't count monsters in end-of-level sectors if option is on
|
|
|
|
if (dmflags2 & DF2_NOCOUNTENDMONST)
|
|
|
|
{
|
|
|
|
TThinkerIterator<AActor> it;
|
|
|
|
AActor * mo;
|
|
|
|
|
|
|
|
while ((mo=it.Next()))
|
|
|
|
{
|
|
|
|
if (mo->flags & MF_COUNTKILL)
|
|
|
|
{
|
|
|
|
if (mo->Sector->special == dDamage_End)
|
|
|
|
{
|
|
|
|
mo->ClearCounters();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-29 11:09:38 +00:00
|
|
|
T_PreprocessScripts(); // preprocess FraggleScript scripts
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// build subsector connect matrix
|
|
|
|
// UNUSED P_ConnectSubsectors ();
|
|
|
|
|
|
|
|
R_OldBlend = 0xffffffff;
|
|
|
|
|
|
|
|
// [RH] Remove all particles
|
2011-07-06 15:31:05 +00:00
|
|
|
P_ClearParticles ();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 03:25:08 +00:00
|
|
|
times[17].Clock();
|
2006-02-24 04:48:15 +00:00
|
|
|
// preload graphics and sounds
|
|
|
|
if (precache)
|
|
|
|
{
|
2011-07-05 10:02:38 +00:00
|
|
|
TexMan.PrecacheLevel ();
|
2006-02-24 04:48:15 +00:00
|
|
|
S_PrecacheLevel ();
|
|
|
|
}
|
2008-08-10 03:25:08 +00:00
|
|
|
times[17].Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (deathmatch)
|
|
|
|
{
|
|
|
|
AnnounceGameStart ();
|
|
|
|
}
|
|
|
|
|
|
|
|
P_ResetSightCounters (true);
|
|
|
|
//Printf ("free memory: 0x%x\n", Z_FreeMemory());
|
|
|
|
|
|
|
|
if (showloadtimes)
|
|
|
|
{
|
|
|
|
Printf ("---Total load times---\n");
|
|
|
|
for (i = 0; i < 18; ++i)
|
|
|
|
{
|
|
|
|
static const char *timenames[] =
|
|
|
|
{
|
|
|
|
"load vertexes",
|
|
|
|
"load sectors",
|
|
|
|
"load sides",
|
|
|
|
"load lines",
|
|
|
|
"load sides 2",
|
|
|
|
"load lines 2",
|
|
|
|
"loop sides",
|
|
|
|
"load subsectors",
|
|
|
|
"load nodes",
|
|
|
|
"load segs",
|
|
|
|
"load blockmap",
|
|
|
|
"load reject",
|
|
|
|
"group lines",
|
|
|
|
"flood zones",
|
|
|
|
"load things",
|
|
|
|
"translate teleports",
|
|
|
|
"init polys",
|
|
|
|
"precache"
|
|
|
|
};
|
2008-08-23 02:38:00 +00:00
|
|
|
Printf ("Time%3d:%9.4f ms (%s)\n", i, times[i].TimeMS(), timenames[i]);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-08 08:06:26 +00:00
|
|
|
MapThingsConverted.Clear();
|
2010-08-27 15:20:05 +00:00
|
|
|
|
|
|
|
if (glsegextras != NULL)
|
|
|
|
{
|
|
|
|
delete[] glsegextras;
|
|
|
|
glsegextras = NULL;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// P_Init
|
|
|
|
//
|
|
|
|
void P_Init ()
|
|
|
|
{
|
2006-05-12 03:14:40 +00:00
|
|
|
atterm (P_Shutdown);
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
P_InitEffects (); // [RH]
|
|
|
|
P_InitTerrainTypes ();
|
|
|
|
P_InitKeyMessages ();
|
|
|
|
R_InitSprites ();
|
|
|
|
}
|
|
|
|
|
2006-05-12 03:14:40 +00:00
|
|
|
static void P_Shutdown ()
|
|
|
|
{
|
2011-07-07 19:53:42 +00:00
|
|
|
R_DeinitSpriteData ();
|
2006-05-12 03:14:40 +00:00
|
|
|
P_DeinitKeyMessages ();
|
|
|
|
P_FreeLevelData ();
|
|
|
|
P_FreeExtraLevelData ();
|
2010-12-15 00:09:31 +00:00
|
|
|
ST_Clear();
|
2006-05-12 03:14:40 +00:00
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
#if 0
|
|
|
|
#include "c_dispatch.h"
|
|
|
|
CCMD (lineloc)
|
|
|
|
{
|
|
|
|
if (argv.argc() != 2)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int linenum = atoi (argv[1]);
|
|
|
|
if (linenum < 0 || linenum >= numlines)
|
|
|
|
{
|
|
|
|
Printf ("No such line\n");
|
|
|
|
}
|
2006-09-14 00:02:31 +00:00
|
|
|
Printf ("(%d,%d) -> (%d,%d)\n", lines[linenum].v1->x >> FRACBITS,
|
2006-02-24 04:48:15 +00:00
|
|
|
lines[linenum].v1->y >> FRACBITS,
|
|
|
|
lines[linenum].v2->x >> FRACBITS,
|
|
|
|
lines[linenum].v2->y >> FRACBITS);
|
|
|
|
}
|
|
|
|
#endif
|