- merged 3dfloors2 branch into trunk.

SVN r3124 (trunk)
This commit is contained in:
Christoph Oelckers 2011-01-29 11:09:38 +00:00
commit fae8ed444c
41 changed files with 12358 additions and 445 deletions

View file

@ -67,6 +67,8 @@
#include "compatibility.h"
#include "po_man.h"
#include "fragglescript/t_fs.h"
void P_SpawnSlopeMakers (FMapThing *firstmt, FMapThing *lastmt);
void P_SetSlopes ();
void P_CopySlopes();
@ -135,9 +137,6 @@ int numgamesubsectors;
bool hasglnodes;
FExtraLight* ExtraLights;
FLightStack* LightStacks;
TArray<FMapThing> MapThingsConverted;
int sidecount;
@ -653,28 +652,64 @@ static void SetTexture (side_t *side, int position, DWORD *blend, char *name8)
side->SetTexture(position, texture);
}
static void SetTextureNoErr (side_t *side, int position, DWORD *color, char *name8, bool *validcolor)
static void SetTextureNoErr (side_t *side, int position, DWORD *color, char *name8, bool *validcolor, bool isFog)
{
char name[9];
FTextureID texture;
strncpy (name, name8, 8);
name[8] = 0;
*validcolor = false;
texture = TexMan.CheckForTexture (name, FTexture::TEX_Wall,
FTextureManager::TEXMAN_Overridable|FTextureManager::TEXMAN_TryAny);
if (!texture.Exists())
{
char name2[9];
char *stop;
strncpy (name2, name, 8);
name2[8] = 0;
*color = strtoul (name2, &stop, 16);
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;
}
}
texture = FNullTextureID();
*validcolor = (*stop == 0) && (stop >= name2 + 2) && (stop <= name2 + 6);
}
else
{
*validcolor = false;
}
side->SetTexture(position, texture);
}
@ -1570,6 +1605,7 @@ void SpawnMapThing(int index, FMapThing *mt, int position)
index, mt->x>>FRACBITS, mt->y>>FRACBITS, mt->z>>FRACBITS, mt->type, mt->flags,
spawned? spawned->GetClass()->TypeName.GetChars() : "(none)");
}
T_AddSpawnedThing(spawned);
}
//===========================================================================
@ -1767,7 +1803,7 @@ void P_SetLineID (line_t *ld)
// [RH] Set line id (as appropriate) here
// for Doom format maps this must be done in P_TranslateLineDef because
// the tag doesn't always go into the first arg.
if (level.flags & LEVEL_HEXENFORMAT)
if (level.maptype == MAPTYPE_HEXEN)
{
switch (ld->special)
{
@ -2334,8 +2370,8 @@ void P_ProcessSideTextures(bool checktranmap, side_t *sd, sector_t *sec, mapside
DWORD color = MAKERGB(255,255,255), fog = 0;
bool colorgood, foggood;
SetTextureNoErr (sd, side_t::bottom, &fog, msd->bottomtexture, &foggood);
SetTextureNoErr (sd, side_t::top, &color, msd->toptexture, &colorgood);
SetTextureNoErr (sd, side_t::bottom, &fog, msd->bottomtexture, &foggood, true);
SetTextureNoErr (sd, side_t::top, &color, msd->toptexture, &colorgood, false);
strncpy (name, msd->midtexture, 8);
SetTexture(sd, side_t::mid, msd->midtexture);
@ -2899,7 +2935,6 @@ line_t** linebuffer;
static void P_GroupLines (bool buildmap)
{
cycle_t times[16];
TArray<linf> exLightTags;
int* linesDoneInEachSector;
int i;
int j;
@ -2909,7 +2944,7 @@ static void P_GroupLines (bool buildmap)
sector_t* sector;
FBoundingBox bbox;
bool flaggedNoFronts = false;
unsigned int ii, jj;
unsigned int jj;
for (i = 0; i < (int)countof(times); ++i)
{
@ -2960,29 +2995,6 @@ static void P_GroupLines (bool buildmap)
li->backsector->linecount++;
total++;
}
// [RH] Count extra lights
if (li->special == ExtraFloor_LightOnly)
{
int adder = li->args[1] == 1 ? 2 : 1;
for (ii = 0; ii < exLightTags.Size(); ++ii)
{
if (exLightTags[ii].tag == li->args[0])
break;
}
if (ii == exLightTags.Size())
{
linf info = { li->args[0], adder };
exLightTags.Push (info);
totallights += adder;
}
else
{
totallights += adder;
exLightTags[ii].count += adder;
}
}
}
if (flaggedNoFronts)
{
@ -2990,21 +3002,6 @@ static void P_GroupLines (bool buildmap)
}
times[1].Unclock();
// collect extra light info
times[2].Clock();
LightStacks = new FLightStack[totallights];
ExtraLights = new FExtraLight[exLightTags.Size()];
memset (ExtraLights, 0, exLightTags.Size()*sizeof(FExtraLight));
for (ii = 0, jj = 0; ii < exLightTags.Size(); ++ii)
{
ExtraLights[ii].Tag = exLightTags[ii].tag;
ExtraLights[ii].NumLights = exLightTags[ii].count;
ExtraLights[ii].Lights = &LightStacks[jj];
jj += ExtraLights[ii].NumLights;
}
times[2].Unclock();
// build line tables for each sector
times[3].Clock();
linebuffer = new line_t *[total];
@ -3060,43 +3057,6 @@ static void P_GroupLines (bool buildmap)
sector->soundorg[0] = bbox.Right()/2 + bbox.Left()/2;
sector->soundorg[1] = bbox.Top()/2 + bbox.Bottom()/2;
sector->soundorg[2] = sector->floorplane.ZatPoint (sector->soundorg[0], sector->soundorg[1]);
// Find a triangle in the sector for sorting extra lights
// The points must be in the sector, because intersecting
// planes are okay so long as they intersect beyond all
// sectors that use them.
if (sector->linecount == 0)
{ // If the sector has no lines, its tag is guaranteed to be 0, which
// means it cannot be used for extralights. So just use some dummy
// vertices for the triangle.
sector->Triangle[0] = vertexes;
sector->Triangle[1] = vertexes;
sector->Triangle[2] = vertexes;
}
else
{
sector->Triangle[0] = sector->lines[0]->v1;
sector->Triangle[1] = sector->lines[0]->v2;
sector->Triangle[2] = sector->Triangle[0]; // failsafe
if (sector->linecount > 1)
{
fixed_t dx = sector->Triangle[1]->x - sector->Triangle[0]->x;
fixed_t dy = sector->Triangle[1]->y - sector->Triangle[1]->y;
// Find another point in the sector that does not lie
// on the same line as the first two points.
for (j = 2; j < sector->linecount*2; ++j)
{
vertex_t *v;
v = (j & 1) ? sector->lines[j>>1]->v1 : sector->lines[j>>1]->v2;
if (DMulScale32 (v->y - sector->Triangle[0]->y, dx,
sector->Triangle[0]->x - v->x, dy) != 0)
{
sector->Triangle[2] = v;
}
}
}
}
}
delete[] linesDoneInEachSector;
times[3].Unclock();
@ -3113,33 +3073,6 @@ static void P_GroupLines (bool buildmap)
}
times[5].Unclock();
times[6].Clock();
for (i = 0, li = lines; i < numlines; ++i, ++li)
{
if (li->special == ExtraFloor_LightOnly)
{
for (ii = 0; ii < exLightTags.Size(); ++ii)
{
if (ExtraLights[ii].Tag == li->args[0])
break;
}
if (ii < exLightTags.Size())
{
ExtraLights[ii].InsertLight (li->frontsector->ceilingplane, li, li->args[1] == 2);
if (li->args[1] == 1)
{
ExtraLights[ii].InsertLight (li->frontsector->floorplane, li, 2);
}
j = -1;
while ((j = P_FindSectorFromTag (li->args[0], j)) >= 0)
{
sectors[j].ExtraLights = &ExtraLights[ii];
}
}
}
}
times[6].Unclock();
if (showloadtimes)
{
Printf ("---Group Lines Times---\n");
@ -3150,56 +3083,6 @@ static void P_GroupLines (bool buildmap)
}
}
void FExtraLight::InsertLight (const secplane_t &inplane, line_t *line, int type)
{
// type 0 : !bottom, !flooder
// type 1 : !bottom, flooder
// type 2 : bottom, !flooder
vertex_t **triangle = line->frontsector->Triangle;
int i, j;
fixed_t diff = FIXED_MAX;
secplane_t plane = inplane;
if (type != 2)
{
plane.FlipVert ();
}
// Find the first plane this light is above and insert it there
for (i = 0; i < NumUsedLights; ++i)
{
for (j = 0; j < 3; ++j)
{
diff = plane.ZatPoint (triangle[j]) - Lights[i].Plane.ZatPoint (triangle[j]);
if (diff != 0)
{
break;
}
}
if (diff >= 0)
{
break;
}
}
if (i < NumLights)
{
for (j = MIN<int>(NumUsedLights, NumLights-1); j > i; --j)
{
Lights[j] = Lights[j-1];
}
Lights[i].Plane = plane;
Lights[i].Master = type == 2 ? NULL : line->frontsector;
Lights[i].bBottom = type == 2;
Lights[i].bFlooder = type == 1;
Lights[i].bOverlaps = diff == 0;
if (NumUsedLights < NumLights)
{
++NumUsedLights;
}
}
}
//
// P_LoadReject
//
@ -3451,16 +3334,6 @@ void P_FreeLevelData ()
delete[] rejectmatrix;
rejectmatrix = NULL;
}
if (LightStacks != NULL)
{
delete[] LightStacks;
LightStacks = NULL;
}
if (ExtraLights != NULL)
{
delete[] ExtraLights;
ExtraLights = NULL;
}
if (linebuffer != NULL)
{
delete[] linebuffer;
@ -3538,6 +3411,7 @@ void P_SetupLevel (char *lumpname, int position)
times[i].Reset();
}
level.maptype = MAPTYPE_UNKNOWN;
wminfo.partime = 180;
MapThingsConverted.Clear();
@ -3618,7 +3492,7 @@ void P_SetupLevel (char *lumpname, int position)
if (map->HasBehavior)
{
P_LoadBehavior (map);
level.flags |= LEVEL_HEXENFORMAT;
level.maptype = MAPTYPE_HEXEN;
}
else
{
@ -3641,9 +3515,14 @@ void P_SetupLevel (char *lumpname, int position)
}
}
P_LoadTranslator(translator);
level.maptype = MAPTYPE_DOOM;
}
if (map->isText)
{
level.maptype = MAPTYPE_UDMF;
}
CheckCompatibility(map);
T_LoadScripts(map);
if (!map->HasBehavior || map->isText)
{
@ -3721,6 +3600,7 @@ void P_SetupLevel (char *lumpname, int position)
else
{
ForceNodeBuild = true;
level.maptype = MAPTYPE_BUILD;
}
bool reloop = false;
@ -3996,6 +3876,7 @@ void P_SetupLevel (char *lumpname, int position)
}
}
T_PreprocessScripts(); // preprocess FraggleScript scripts
// build subsector connect matrix
// UNUSED P_ConnectSubsectors ();