diff --git a/docs/rh-log.txt b/docs/rh-log.txt
index a8790374b6..25c1b91af7 100644
--- a/docs/rh-log.txt
+++ b/docs/rh-log.txt
@@ -1,4 +1,5 @@
 May 2, 2008 (Changes by Graf Zahl)
+- Split off the slope creation code from p_Setup.cpp into its own file.
 - Separated the linedef activation types into a bit mask that allows combination
   of all types on the same linedef. Also added a 'first side only' flag. This
   is not usable from Hexen or Doom format maps though but in preparation of
diff --git a/src/p_setup.cpp b/src/p_setup.cpp
index 893fe0994d..cd0d58e147 100644
--- a/src/p_setup.cpp
+++ b/src/p_setup.cpp
@@ -61,6 +61,9 @@
 #include "p_setup.h"
 #include "r_translate.h"
 
+void P_SpawnSlopeMakers (mapthing2_t *firstmt, mapthing2_t *lastmt);
+void P_SetSlopes ();
+
 extern AActor *P_SpawnMapThing (mapthing2_t *mthing, int position);
 extern bool P_LoadBuildMap (BYTE *mapdata, size_t len, mapthing2_t **things, int *numthings);
 
@@ -1298,403 +1301,6 @@ void P_LoadThings (MapData * map, int position)
 	delete [] mtp;
 }
 
-//===========================================================================
-//
-// P_SpawnSlopeMakers
-//
-//===========================================================================
-
-static void P_SlopeLineToPoint (int lineid, fixed_t x, fixed_t y, fixed_t z, bool slopeCeil)
-{
-	int linenum = -1;
-
-	while ((linenum = P_FindLineFromID (lineid, linenum)) != -1)
-	{
-		const line_t *line = &lines[linenum];
-		sector_t *sec;
-		secplane_t *plane;
-		
-		if (P_PointOnLineSide (x, y, line) == 0)
-		{
-			sec = line->frontsector;
-		}
-		else
-		{
-			sec = line->backsector;
-		}
-		if (sec == NULL)
-		{
-			continue;
-		}
-		if (slopeCeil)
-		{
-			plane = &sec->ceilingplane;
-		}
-		else
-		{
-			plane = &sec->floorplane;
-		}
-
-		FVector3 p, v1, v2, cross;
-
-		p[0] = FIXED2FLOAT (line->v1->x);
-		p[1] = FIXED2FLOAT (line->v1->y);
-		p[2] = FIXED2FLOAT (plane->ZatPoint (line->v1->x, line->v1->y));
-		v1[0] = FIXED2FLOAT (line->dx);
-		v1[1] = FIXED2FLOAT (line->dy);
-		v1[2] = FIXED2FLOAT (plane->ZatPoint (line->v2->x, line->v2->y)) - p[2];
-		v2[0] = FIXED2FLOAT (x - line->v1->x);
-		v2[1] = FIXED2FLOAT (y - line->v1->y);
-		v2[2] = FIXED2FLOAT (z) - p[2];
-
-		cross = v1 ^ v2;
-		double len = cross.Length();
-		if (len == 0)
-		{
-			Printf ("Slope thing at (%d,%d) lies directly on its target line.\n", int(x>>16), int(y>>16));
-			return;
-		}
-		cross /= len;
-		// Fix backward normals
-		if ((cross.Z < 0 && !slopeCeil) || (cross.Z > 0 && slopeCeil))
-		{
-			cross = -cross;
-		}
-
-		plane->a = FLOAT2FIXED (cross[0]);
-		plane->b = FLOAT2FIXED (cross[1]);
-		plane->c = FLOAT2FIXED (cross[2]);
-		//plane->ic = FLOAT2FIXED (1.f/cross[2]);
-		plane->ic = DivScale32 (1, plane->c);
-		plane->d = -TMulScale16 (plane->a, x,
-								 plane->b, y,
-								 plane->c, z);
-	}
-}
-
-//===========================================================================
-//
-// P_CopyPlane
-//
-//===========================================================================
-
-static void P_CopyPlane (int tag, fixed_t x, fixed_t y, bool copyCeil)
-{
-	sector_t *dest = P_PointInSector (x, y);
-	sector_t *source;
-	int secnum;
-	size_t planeofs;
-
-	secnum = P_FindSectorFromTag (tag, -1);
-	if (secnum == -1)
-	{
-		return;
-	}
-
-	source = &sectors[secnum];
-
-	if (copyCeil)
-	{
-		planeofs = myoffsetof(sector_t, ceilingplane);
-	}
-	else
-	{
-		planeofs = myoffsetof(sector_t, floorplane);
-	}
-	*(secplane_t *)((BYTE *)dest + planeofs) = *(secplane_t *)((BYTE *)source + planeofs);
-}
-
-//===========================================================================
-//
-// P_SetSlope
-//
-//===========================================================================
-
-void P_SetSlope (secplane_t *plane, bool setCeil, int xyangi, int zangi,
-	fixed_t x, fixed_t y, fixed_t z)
-{
-	angle_t xyang;
-	angle_t zang;
-
-	if (zangi >= 180)
-	{
-		zang = ANGLE_180-ANGLE_1;
-	}
-	else if (zangi <= 0)
-	{
-		zang = ANGLE_1;
-	}
-	else
-	{
-		zang = Scale (zangi, ANGLE_90, 90);
-	}
-	if (setCeil)
-	{
-		zang += ANGLE_180;
-	}
-	zang >>= ANGLETOFINESHIFT;
-
-	xyang = (angle_t)Scale (xyangi, ANGLE_90, 90 << ANGLETOFINESHIFT);
-
-	FVector3 norm;
-
-	norm[0] = float(finecosine[zang]) * float(finecosine[xyang]);
-	norm[1] = float(finecosine[zang]) * float(finesine[xyang]);
-	norm[2] = float(finesine[zang]) * 65536.f;
-	norm.MakeUnit();
-	plane->a = (int)(norm[0] * 65536.f);
-	plane->b = (int)(norm[1] * 65536.f);
-	plane->c = (int)(norm[2] * 65536.f);
-	//plane->ic = (int)(65536.f / norm[2]);
-	plane->ic = DivScale32 (1, plane->c);
-	plane->d = -TMulScale16 (plane->a, x,
-							 plane->b, y,
-							 plane->c, z);
-}
-
-
-//===========================================================================
-//
-// P_VavoomSlope
-//
-//===========================================================================
-
-void P_VavoomSlope(sector_t * sec, int id, fixed_t x, fixed_t y, fixed_t z, int which)
-{
-	for (int i=0;i<sec->linecount;i++)
-	{
-		line_t * l=sec->lines[i];
-
-		if (l->args[0]==id)
-		{
-			FVector3 v1, v2, cross;
-			secplane_t *srcplane = (which == 0) ? &sec->floorplane : &sec->ceilingplane;
-			fixed_t srcheight = (which == 0) ? sec->floortexz : sec->ceilingtexz;
-
-			v1[0] = FIXED2FLOAT (x - l->v2->x);
-			v1[1] = FIXED2FLOAT (y - l->v2->y);
-			v1[2] = FIXED2FLOAT (z - srcheight);
-			
-			v2[0] = FIXED2FLOAT (x - l->v1->x);
-			v2[1] = FIXED2FLOAT (y - l->v1->y);
-			v2[2] = FIXED2FLOAT (z - srcheight);
-
-			cross = v1 ^ v2;
-			double len = cross.Length();
-			if (len == 0)
-			{
-				Printf ("Slope thing at (%d,%d) lies directly on its target line.\n", int(x>>16), int(y>>16));
-				return;
-			}
-			cross /= len;
-
-			// Fix backward normals
-			if ((cross.Z < 0 && which == 0) || (cross.Z > 0 && which == 1))
-			{
-				cross = -cross;
-			}
-
-
-			srcplane->a = FLOAT2FIXED (cross[0]);
-			srcplane->b = FLOAT2FIXED (cross[1]);
-			srcplane->c = FLOAT2FIXED (cross[2]);
-			//plane->ic = FLOAT2FIXED (1.f/cross[2]);
-			srcplane->ic = DivScale32 (1, srcplane->c);
-			srcplane->d = -TMulScale16 (srcplane->a, x,
-										srcplane->b, y,
-										srcplane->c, z);
-			return;
-		}
-	}
-}
-				   
-enum
-{
-	THING_SlopeFloorPointLine = 9500,
-	THING_SlopeCeilingPointLine = 9501,
-	THING_SetFloorSlope = 9502,
-	THING_SetCeilingSlope = 9503,
-	THING_CopyFloorPlane = 9510,
-	THING_CopyCeilingPlane = 9511,
-	THING_VavoomFloor=1500,
-	THING_VavoomCeiling=1501,
-	THING_VertexFloorZ=1504,
-	THING_VertexCeilingZ=1505,
-};
-
-//==========================================================================
-//
-//	P_SetSlopesFromVertexHeights
-//
-//==========================================================================
-
-static void P_SetSlopesFromVertexHeights(mapthing2_t *firstmt, mapthing2_t *lastmt)
-{
-	TMap<int, fixed_t> vt_heights[2];
-	mapthing2_t *mt;
-	bool vt_found = false;
-
-	for (mt = firstmt; mt < lastmt; ++mt)
-	{
-		if (mt->type == THING_VertexFloorZ || mt->type == THING_VertexCeilingZ)
-		{
-			for(int i=0; i<numvertexes; i++)
-			{
-				if (vertexes[i].x == mt->x << FRACBITS && vertexes[i].y == mt->y << FRACBITS)
-				{
-					if (mt->type == THING_VertexFloorZ) 
-					{
-						vt_heights[0][i] = mt->z << FRACBITS;
-					}
-					else 
-					{
-						vt_heights[1][i] = mt->z << FRACBITS;
-					}
-					vt_found = true;
-				}
-			}
-			mt->type = 0;
-		}
-	}
-	if (vt_found)
-	{
-		for (int i = 0; i < numsectors; i++)
-		{
-			sector_t *sec = &sectors[i];
-			if (sec->linecount != 3) continue;	// only works with triangular sectors
-
-			FVector3 vt1, vt2, vt3, cross;
-			FVector3 vec1, vec2;
-			int vi1, vi2, vi3;
-
-			vi1 = sec->lines[0]->v1 - vertexes;
-			vi2 = sec->lines[0]->v2 - vertexes;
-			vi3 = (sec->lines[1]->v1 == sec->lines[0]->v1 || sec->lines[1]->v1 == sec->lines[0]->v2)?
-				sec->lines[1]->v2 - vertexes : sec->lines[1]->v1 - vertexes;
-
-			vt1.X = FIXED2FLOAT(vertexes[vi1].x);
-			vt1.Y = FIXED2FLOAT(vertexes[vi1].y);
-			vt2.X = FIXED2FLOAT(vertexes[vi2].x);
-			vt2.Y = FIXED2FLOAT(vertexes[vi2].y);
-			vt3.X = FIXED2FLOAT(vertexes[vi3].x);
-			vt3.Y = FIXED2FLOAT(vertexes[vi3].y);
-
-			for(int j=0; j<2; j++)
-			{
-				fixed_t *h1 = vt_heights[j].CheckKey(vi1);
-				fixed_t *h2 = vt_heights[j].CheckKey(vi2);
-				fixed_t *h3 = vt_heights[j].CheckKey(vi3);
-				fixed_t z3;
-				if (h1==NULL && h2==NULL && h3==NULL) continue;
-
-				vt1.Z = FIXED2FLOAT(h1? *h1 : j==0? sec->floortexz : sec->ceilingtexz);
-				vt2.Z = FIXED2FLOAT(h2? *h2 : j==0? sec->floortexz : sec->ceilingtexz);
-				z3 = h3? *h3 : j==0? sec->floortexz : sec->ceilingtexz;
-				vt3.Z = FIXED2FLOAT(z3);
-
-				if (P_PointOnLineSide(vertexes[vi3].x, vertexes[vi3].y, sec->lines[0]) == 0)
-				{
-					vec1 = vt2 - vt3;
-					vec2 = vt1 - vt3;
-				}
-				else
-				{
-					vec1 = vt1 - vt3;
-					vec2 = vt2 - vt3;
-				}
-
-				FVector3 cross = vec1 ^ vec2;
-
-				double len = cross.Length();
-				if (len == 0)
-				{
-					// Only happens when all vertices in this sector are on the same line.
-					// Let's just ignore this case.
-					continue;
-				}
-				cross /= len;
-
-				// Fix backward normals
-				if ((cross.Z < 0 && j == 0) || (cross.Z > 0 && j == 1))
-				{
-					cross = -cross;
-				}
-
-				secplane_t *srcplane = j==0? &sec->floorplane : &sec->ceilingplane;
-
-				srcplane->a = FLOAT2FIXED (cross[0]);
-				srcplane->b = FLOAT2FIXED (cross[1]);
-				srcplane->c = FLOAT2FIXED (cross[2]);
-				srcplane->ic = DivScale32 (1, srcplane->c);
-				srcplane->d = -TMulScale16 (srcplane->a, vertexes[vi3].x,
-											srcplane->b, vertexes[vi3].y,
-											srcplane->c, z3);
-			}
-		}
-	}
-}
-
-//===========================================================================
-//
-// P_SpawnSlopeMakers
-//
-//===========================================================================
-
-static void P_SpawnSlopeMakers (mapthing2_t *firstmt, mapthing2_t *lastmt)
-{
-	mapthing2_t *mt;
-
-	for (mt = firstmt; mt < lastmt; ++mt)
-	{
-		if ((mt->type >= THING_SlopeFloorPointLine &&
-			 mt->type <= THING_SetCeilingSlope) ||
-			mt->type==THING_VavoomFloor || mt->type==THING_VavoomCeiling)
-		{
-			fixed_t x, y, z;
-			secplane_t *refplane;
-			sector_t *sec;
-
-			x = mt->x << FRACBITS;
-			y = mt->y << FRACBITS;
-			sec = P_PointInSector (x, y);
-			if (mt->type & 1)
-			{
-				refplane = &sec->ceilingplane;
-			}
-			else
-			{
-				refplane = &sec->floorplane;
-			}
-			z = refplane->ZatPoint (x, y) + (mt->z << FRACBITS);
-			if (mt->type==THING_VavoomFloor || mt->type==THING_VavoomCeiling)
-			{
-				P_VavoomSlope(sec, mt->thingid, x, y, mt->z<<FRACBITS, mt->type & 1); 
-			}
-			else if (mt->type <= THING_SlopeCeilingPointLine)
-			{
-				P_SlopeLineToPoint (mt->args[0], x, y, z, mt->type & 1);
-			}
-			else
-			{
-				P_SetSlope (refplane, mt->type & 1, mt->angle, mt->args[0], x, y, z);
-			}
-			mt->type = 0;
-		}
-	}
-
-	for (mt = firstmt; mt < lastmt; ++mt)
-	{
-		if (mt->type == THING_CopyFloorPlane ||
-			mt->type == THING_CopyCeilingPlane)
-		{
-			P_CopyPlane (mt->args[0], mt->x << FRACBITS, mt->y << FRACBITS, mt->type & 1);
-			mt->type = 0;
-		}
-	}
-
-	P_SetSlopesFromVertexHeights(firstmt, lastmt);
-}
-
 //===========================================================================
 //
 // [RH]
@@ -2433,129 +2039,6 @@ void P_LoadSideDefs2 (MapData * map)
 	delete[] msdf;
 }
 
-// [RH] Set slopes for sectors, based on line specials
-//
-// P_AlignPlane
-//
-// Aligns the floor or ceiling of a sector to the corresponding plane
-// on the other side of the reference line. (By definition, line must be
-// two-sided.)
-//
-// If (which & 1), sets floor.
-// If (which & 2), sets ceiling.
-//
-
-static void P_AlignPlane (sector_t *sec, line_t *line, int which)
-{
-	sector_t *refsec;
-	int bestdist;
-	vertex_t *refvert = (*sec->lines)->v1;	// Shut up, GCC
-	int i;
-	line_t **probe;
-
-	if (line->backsector == NULL)
-		return;
-
-	// Find furthest vertex from the reference line. It, along with the two ends
-	// of the line will define the plane.
-	bestdist = 0;
-	for (i = sec->linecount*2, probe = sec->lines; i > 0; i--)
-	{
-		int dist;
-		vertex_t *vert;
-
-		// Do calculations with only the upper bits, because the lower ones
-		// are all zero, and we would overflow for a lot of distances if we
-		// kept them around.
-
-		if (i & 1)
-			vert = (*probe++)->v2;
-		else
-			vert = (*probe)->v1;
-		dist = abs (((line->v1->y - vert->y) >> FRACBITS) * (line->dx >> FRACBITS) -
-					((line->v1->x - vert->x) >> FRACBITS) * (line->dy >> FRACBITS));
-
-		if (dist > bestdist)
-		{
-			bestdist = dist;
-			refvert = vert;
-		}
-	}
-
-	refsec = line->frontsector == sec ? line->backsector : line->frontsector;
-
-	FVector3 p, v1, v2, cross;
-
-	const secplane_t *refplane;
-	secplane_t *srcplane;
-	fixed_t srcheight, destheight;
-
-	refplane = (which == 0) ? &refsec->floorplane : &refsec->ceilingplane;
-	srcplane = (which == 0) ? &sec->floorplane : &sec->ceilingplane;
-	srcheight = (which == 0) ? sec->floortexz : sec->ceilingtexz;
-	destheight = (which == 0) ? refsec->floortexz : refsec->ceilingtexz;
-
-	p[0] = FIXED2FLOAT (line->v1->x);
-	p[1] = FIXED2FLOAT (line->v1->y);
-	p[2] = FIXED2FLOAT (destheight);
-	v1[0] = FIXED2FLOAT (line->dx);
-	v1[1] = FIXED2FLOAT (line->dy);
-	v1[2] = 0;
-	v2[0] = FIXED2FLOAT (refvert->x - line->v1->x);
-	v2[1] = FIXED2FLOAT (refvert->y - line->v1->y);
-	v2[2] = FIXED2FLOAT (srcheight - destheight);
-
-	cross = (v1 ^ v2).Unit();
-
-	// Fix backward normals
-	if ((cross.Z < 0 && which == 0) || (cross.Z > 0 && which == 1))
-	{
-		cross = -cross;
-	}
-
-	srcplane->a = FLOAT2FIXED (cross[0]);
-	srcplane->b = FLOAT2FIXED (cross[1]);
-	srcplane->c = FLOAT2FIXED (cross[2]);
-	//srcplane->ic = FLOAT2FIXED (1.f/cross[2]);
-	srcplane->ic = DivScale32 (1, srcplane->c);
-	srcplane->d = -TMulScale16 (srcplane->a, line->v1->x,
-								srcplane->b, line->v1->y,
-								srcplane->c, destheight);
-}
-
-void P_SetSlopes ()
-{
-	int i, s;
-
-	for (i = 0; i < numlines; i++)
-	{
-		if (lines[i].special == Plane_Align)
-		{
-			lines[i].special = 0;
-			lines[i].id = lines[i].args[2];
-			if (lines[i].backsector != NULL)
-			{
-				// args[0] is for floor, args[1] is for ceiling
-				//
-				// As a special case, if args[1] is 0,
-				// then args[0], bits 2-3 are for ceiling.
-				for (s = 0; s < 2; s++)
-				{
-					int bits = lines[i].args[s] & 3;
-
-					if (s == 1 && bits == 0)
-						bits = (lines[i].args[0] >> 2) & 3;
-
-					if (bits == 1)			// align front side to back
-						P_AlignPlane (lines[i].frontsector, lines + i, s);
-					else if (bits == 2)		// align back side to front
-						P_AlignPlane (lines[i].backsector, lines + i, s);
-				}
-			}
-		}
-	}
-}
-
 
 //
 // [RH] My own blockmap builder, not Killough's or TeamTNT's.
diff --git a/src/p_setup.h b/src/p_setup.h
index a0921e34b7..aeb4254aa7 100644
--- a/src/p_setup.h
+++ b/src/p_setup.h
@@ -83,6 +83,7 @@ struct MapData
 MapData * P_OpenMapData(const char * mapname);
 bool P_CheckMapData(const char * mapname);
 
+
 // NOT called by W_Ticker. Fixme. [RH] Is that bad?
 //
 // [RH] The only parameter used is mapname, so I removed playermask and skill.
diff --git a/src/p_slopes.cpp b/src/p_slopes.cpp
new file mode 100644
index 0000000000..04f37ba880
--- /dev/null
+++ b/src/p_slopes.cpp
@@ -0,0 +1,571 @@
+/*
+** p_slopes.cpp
+** Slope creation
+**
+**---------------------------------------------------------------------------
+** Copyright 1998-2008 Randy Heit
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** 1. Redistributions of source code must retain the above copyright
+**    notice, this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright
+**    notice, this list of conditions and the following disclaimer in the
+**    documentation and/or other materials provided with the distribution.
+** 3. The name of the author may not be used to endorse or promote products
+**    derived from this software without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**---------------------------------------------------------------------------
+**
+*/
+
+#include "doomtype.h"
+#include "vectors.h"
+#include "p_local.h"
+#include "r_data.h"
+#include "cmdlib.h"
+#include "p_lnspec.h"
+
+//===========================================================================
+//
+// P_SpawnSlopeMakers
+//
+//===========================================================================
+
+static void P_SlopeLineToPoint (int lineid, fixed_t x, fixed_t y, fixed_t z, bool slopeCeil)
+{
+	int linenum = -1;
+
+	while ((linenum = P_FindLineFromID (lineid, linenum)) != -1)
+	{
+		const line_t *line = &lines[linenum];
+		sector_t *sec;
+		secplane_t *plane;
+		
+		if (P_PointOnLineSide (x, y, line) == 0)
+		{
+			sec = line->frontsector;
+		}
+		else
+		{
+			sec = line->backsector;
+		}
+		if (sec == NULL)
+		{
+			continue;
+		}
+		if (slopeCeil)
+		{
+			plane = &sec->ceilingplane;
+		}
+		else
+		{
+			plane = &sec->floorplane;
+		}
+
+		FVector3 p, v1, v2, cross;
+
+		p[0] = FIXED2FLOAT (line->v1->x);
+		p[1] = FIXED2FLOAT (line->v1->y);
+		p[2] = FIXED2FLOAT (plane->ZatPoint (line->v1->x, line->v1->y));
+		v1[0] = FIXED2FLOAT (line->dx);
+		v1[1] = FIXED2FLOAT (line->dy);
+		v1[2] = FIXED2FLOAT (plane->ZatPoint (line->v2->x, line->v2->y)) - p[2];
+		v2[0] = FIXED2FLOAT (x - line->v1->x);
+		v2[1] = FIXED2FLOAT (y - line->v1->y);
+		v2[2] = FIXED2FLOAT (z) - p[2];
+
+		cross = v1 ^ v2;
+		double len = cross.Length();
+		if (len == 0)
+		{
+			Printf ("Slope thing at (%d,%d) lies directly on its target line.\n", int(x>>16), int(y>>16));
+			return;
+		}
+		cross /= len;
+		// Fix backward normals
+		if ((cross.Z < 0 && !slopeCeil) || (cross.Z > 0 && slopeCeil))
+		{
+			cross = -cross;
+		}
+
+		plane->a = FLOAT2FIXED (cross[0]);
+		plane->b = FLOAT2FIXED (cross[1]);
+		plane->c = FLOAT2FIXED (cross[2]);
+		//plane->ic = FLOAT2FIXED (1.f/cross[2]);
+		plane->ic = DivScale32 (1, plane->c);
+		plane->d = -TMulScale16 (plane->a, x,
+								 plane->b, y,
+								 plane->c, z);
+	}
+}
+
+//===========================================================================
+//
+// P_CopyPlane
+//
+//===========================================================================
+
+static void P_CopyPlane (int tag, fixed_t x, fixed_t y, bool copyCeil)
+{
+	sector_t *dest = P_PointInSector (x, y);
+	sector_t *source;
+	int secnum;
+	size_t planeofs;
+
+	secnum = P_FindSectorFromTag (tag, -1);
+	if (secnum == -1)
+	{
+		return;
+	}
+
+	source = &sectors[secnum];
+
+	if (copyCeil)
+	{
+		planeofs = myoffsetof(sector_t, ceilingplane);
+	}
+	else
+	{
+		planeofs = myoffsetof(sector_t, floorplane);
+	}
+	*(secplane_t *)((BYTE *)dest + planeofs) = *(secplane_t *)((BYTE *)source + planeofs);
+}
+
+//===========================================================================
+//
+// P_SetSlope
+//
+//===========================================================================
+
+void P_SetSlope (secplane_t *plane, bool setCeil, int xyangi, int zangi,
+	fixed_t x, fixed_t y, fixed_t z)
+{
+	angle_t xyang;
+	angle_t zang;
+
+	if (zangi >= 180)
+	{
+		zang = ANGLE_180-ANGLE_1;
+	}
+	else if (zangi <= 0)
+	{
+		zang = ANGLE_1;
+	}
+	else
+	{
+		zang = Scale (zangi, ANGLE_90, 90);
+	}
+	if (setCeil)
+	{
+		zang += ANGLE_180;
+	}
+	zang >>= ANGLETOFINESHIFT;
+
+	xyang = (angle_t)Scale (xyangi, ANGLE_90, 90 << ANGLETOFINESHIFT);
+
+	FVector3 norm;
+
+	norm[0] = float(finecosine[zang]) * float(finecosine[xyang]);
+	norm[1] = float(finecosine[zang]) * float(finesine[xyang]);
+	norm[2] = float(finesine[zang]) * 65536.f;
+	norm.MakeUnit();
+	plane->a = (int)(norm[0] * 65536.f);
+	plane->b = (int)(norm[1] * 65536.f);
+	plane->c = (int)(norm[2] * 65536.f);
+	//plane->ic = (int)(65536.f / norm[2]);
+	plane->ic = DivScale32 (1, plane->c);
+	plane->d = -TMulScale16 (plane->a, x,
+							 plane->b, y,
+							 plane->c, z);
+}
+
+
+//===========================================================================
+//
+// P_VavoomSlope
+//
+//===========================================================================
+
+void P_VavoomSlope(sector_t * sec, int id, fixed_t x, fixed_t y, fixed_t z, int which)
+{
+	for (int i=0;i<sec->linecount;i++)
+	{
+		line_t * l=sec->lines[i];
+
+		if (l->args[0]==id)
+		{
+			FVector3 v1, v2, cross;
+			secplane_t *srcplane = (which == 0) ? &sec->floorplane : &sec->ceilingplane;
+			fixed_t srcheight = (which == 0) ? sec->floortexz : sec->ceilingtexz;
+
+			v1[0] = FIXED2FLOAT (x - l->v2->x);
+			v1[1] = FIXED2FLOAT (y - l->v2->y);
+			v1[2] = FIXED2FLOAT (z - srcheight);
+			
+			v2[0] = FIXED2FLOAT (x - l->v1->x);
+			v2[1] = FIXED2FLOAT (y - l->v1->y);
+			v2[2] = FIXED2FLOAT (z - srcheight);
+
+			cross = v1 ^ v2;
+			double len = cross.Length();
+			if (len == 0)
+			{
+				Printf ("Slope thing at (%d,%d) lies directly on its target line.\n", int(x>>16), int(y>>16));
+				return;
+			}
+			cross /= len;
+
+			// Fix backward normals
+			if ((cross.Z < 0 && which == 0) || (cross.Z > 0 && which == 1))
+			{
+				cross = -cross;
+			}
+
+
+			srcplane->a = FLOAT2FIXED (cross[0]);
+			srcplane->b = FLOAT2FIXED (cross[1]);
+			srcplane->c = FLOAT2FIXED (cross[2]);
+			//plane->ic = FLOAT2FIXED (1.f/cross[2]);
+			srcplane->ic = DivScale32 (1, srcplane->c);
+			srcplane->d = -TMulScale16 (srcplane->a, x,
+										srcplane->b, y,
+										srcplane->c, z);
+			return;
+		}
+	}
+}
+				   
+enum
+{
+	THING_SlopeFloorPointLine = 9500,
+	THING_SlopeCeilingPointLine = 9501,
+	THING_SetFloorSlope = 9502,
+	THING_SetCeilingSlope = 9503,
+	THING_CopyFloorPlane = 9510,
+	THING_CopyCeilingPlane = 9511,
+	THING_VavoomFloor=1500,
+	THING_VavoomCeiling=1501,
+	THING_VertexFloorZ=1504,
+	THING_VertexCeilingZ=1505,
+};
+
+//==========================================================================
+//
+//	P_SetSlopesFromVertexHeights
+//
+//==========================================================================
+
+static void P_SetSlopesFromVertexHeights(mapthing2_t *firstmt, mapthing2_t *lastmt)
+{
+	TMap<int, fixed_t> vt_heights[2];
+	mapthing2_t *mt;
+	bool vt_found = false;
+
+	for (mt = firstmt; mt < lastmt; ++mt)
+	{
+		if (mt->type == THING_VertexFloorZ || mt->type == THING_VertexCeilingZ)
+		{
+			for(int i=0; i<numvertexes; i++)
+			{
+				if (vertexes[i].x == mt->x << FRACBITS && vertexes[i].y == mt->y << FRACBITS)
+				{
+					if (mt->type == THING_VertexFloorZ) 
+					{
+						vt_heights[0][i] = mt->z << FRACBITS;
+					}
+					else 
+					{
+						vt_heights[1][i] = mt->z << FRACBITS;
+					}
+					vt_found = true;
+				}
+			}
+			mt->type = 0;
+		}
+	}
+	if (vt_found)
+	{
+		for (int i = 0; i < numsectors; i++)
+		{
+			sector_t *sec = &sectors[i];
+			if (sec->linecount != 3) continue;	// only works with triangular sectors
+
+			FVector3 vt1, vt2, vt3, cross;
+			FVector3 vec1, vec2;
+			int vi1, vi2, vi3;
+
+			vi1 = sec->lines[0]->v1 - vertexes;
+			vi2 = sec->lines[0]->v2 - vertexes;
+			vi3 = (sec->lines[1]->v1 == sec->lines[0]->v1 || sec->lines[1]->v1 == sec->lines[0]->v2)?
+				sec->lines[1]->v2 - vertexes : sec->lines[1]->v1 - vertexes;
+
+			vt1.X = FIXED2FLOAT(vertexes[vi1].x);
+			vt1.Y = FIXED2FLOAT(vertexes[vi1].y);
+			vt2.X = FIXED2FLOAT(vertexes[vi2].x);
+			vt2.Y = FIXED2FLOAT(vertexes[vi2].y);
+			vt3.X = FIXED2FLOAT(vertexes[vi3].x);
+			vt3.Y = FIXED2FLOAT(vertexes[vi3].y);
+
+			for(int j=0; j<2; j++)
+			{
+				fixed_t *h1 = vt_heights[j].CheckKey(vi1);
+				fixed_t *h2 = vt_heights[j].CheckKey(vi2);
+				fixed_t *h3 = vt_heights[j].CheckKey(vi3);
+				fixed_t z3;
+				if (h1==NULL && h2==NULL && h3==NULL) continue;
+
+				vt1.Z = FIXED2FLOAT(h1? *h1 : j==0? sec->floortexz : sec->ceilingtexz);
+				vt2.Z = FIXED2FLOAT(h2? *h2 : j==0? sec->floortexz : sec->ceilingtexz);
+				z3 = h3? *h3 : j==0? sec->floortexz : sec->ceilingtexz;
+				vt3.Z = FIXED2FLOAT(z3);
+
+				if (P_PointOnLineSide(vertexes[vi3].x, vertexes[vi3].y, sec->lines[0]) == 0)
+				{
+					vec1 = vt2 - vt3;
+					vec2 = vt1 - vt3;
+				}
+				else
+				{
+					vec1 = vt1 - vt3;
+					vec2 = vt2 - vt3;
+				}
+
+				FVector3 cross = vec1 ^ vec2;
+
+				double len = cross.Length();
+				if (len == 0)
+				{
+					// Only happens when all vertices in this sector are on the same line.
+					// Let's just ignore this case.
+					continue;
+				}
+				cross /= len;
+
+				// Fix backward normals
+				if ((cross.Z < 0 && j == 0) || (cross.Z > 0 && j == 1))
+				{
+					cross = -cross;
+				}
+
+				secplane_t *srcplane = j==0? &sec->floorplane : &sec->ceilingplane;
+
+				srcplane->a = FLOAT2FIXED (cross[0]);
+				srcplane->b = FLOAT2FIXED (cross[1]);
+				srcplane->c = FLOAT2FIXED (cross[2]);
+				srcplane->ic = DivScale32 (1, srcplane->c);
+				srcplane->d = -TMulScale16 (srcplane->a, vertexes[vi3].x,
+											srcplane->b, vertexes[vi3].y,
+											srcplane->c, z3);
+			}
+		}
+	}
+}
+
+//===========================================================================
+//
+// P_SpawnSlopeMakers
+//
+//===========================================================================
+
+void P_SpawnSlopeMakers (mapthing2_t *firstmt, mapthing2_t *lastmt)
+{
+	mapthing2_t *mt;
+
+	for (mt = firstmt; mt < lastmt; ++mt)
+	{
+		if ((mt->type >= THING_SlopeFloorPointLine &&
+			 mt->type <= THING_SetCeilingSlope) ||
+			mt->type==THING_VavoomFloor || mt->type==THING_VavoomCeiling)
+		{
+			fixed_t x, y, z;
+			secplane_t *refplane;
+			sector_t *sec;
+
+			x = mt->x << FRACBITS;
+			y = mt->y << FRACBITS;
+			sec = P_PointInSector (x, y);
+			if (mt->type & 1)
+			{
+				refplane = &sec->ceilingplane;
+			}
+			else
+			{
+				refplane = &sec->floorplane;
+			}
+			z = refplane->ZatPoint (x, y) + (mt->z << FRACBITS);
+			if (mt->type==THING_VavoomFloor || mt->type==THING_VavoomCeiling)
+			{
+				P_VavoomSlope(sec, mt->thingid, x, y, mt->z<<FRACBITS, mt->type & 1); 
+			}
+			else if (mt->type <= THING_SlopeCeilingPointLine)
+			{
+				P_SlopeLineToPoint (mt->args[0], x, y, z, mt->type & 1);
+			}
+			else
+			{
+				P_SetSlope (refplane, mt->type & 1, mt->angle, mt->args[0], x, y, z);
+			}
+			mt->type = 0;
+		}
+	}
+
+	for (mt = firstmt; mt < lastmt; ++mt)
+	{
+		if (mt->type == THING_CopyFloorPlane ||
+			mt->type == THING_CopyCeilingPlane)
+		{
+			P_CopyPlane (mt->args[0], mt->x << FRACBITS, mt->y << FRACBITS, mt->type & 1);
+			mt->type = 0;
+		}
+	}
+
+	P_SetSlopesFromVertexHeights(firstmt, lastmt);
+}
+
+
+//===========================================================================
+//
+// [RH] Set slopes for sectors, based on line specials
+//
+// P_AlignPlane
+//
+// Aligns the floor or ceiling of a sector to the corresponding plane
+// on the other side of the reference line. (By definition, line must be
+// two-sided.)
+//
+// If (which & 1), sets floor.
+// If (which & 2), sets ceiling.
+//
+//===========================================================================
+
+static void P_AlignPlane (sector_t *sec, line_t *line, int which)
+{
+	sector_t *refsec;
+	int bestdist;
+	vertex_t *refvert = (*sec->lines)->v1;	// Shut up, GCC
+	int i;
+	line_t **probe;
+
+	if (line->backsector == NULL)
+		return;
+
+	// Find furthest vertex from the reference line. It, along with the two ends
+	// of the line will define the plane.
+	bestdist = 0;
+	for (i = sec->linecount*2, probe = sec->lines; i > 0; i--)
+	{
+		int dist;
+		vertex_t *vert;
+
+		// Do calculations with only the upper bits, because the lower ones
+		// are all zero, and we would overflow for a lot of distances if we
+		// kept them around.
+
+		if (i & 1)
+			vert = (*probe++)->v2;
+		else
+			vert = (*probe)->v1;
+		dist = abs (((line->v1->y - vert->y) >> FRACBITS) * (line->dx >> FRACBITS) -
+					((line->v1->x - vert->x) >> FRACBITS) * (line->dy >> FRACBITS));
+
+		if (dist > bestdist)
+		{
+			bestdist = dist;
+			refvert = vert;
+		}
+	}
+
+	refsec = line->frontsector == sec ? line->backsector : line->frontsector;
+
+	FVector3 p, v1, v2, cross;
+
+	const secplane_t *refplane;
+	secplane_t *srcplane;
+	fixed_t srcheight, destheight;
+
+	refplane = (which == 0) ? &refsec->floorplane : &refsec->ceilingplane;
+	srcplane = (which == 0) ? &sec->floorplane : &sec->ceilingplane;
+	srcheight = (which == 0) ? sec->floortexz : sec->ceilingtexz;
+	destheight = (which == 0) ? refsec->floortexz : refsec->ceilingtexz;
+
+	p[0] = FIXED2FLOAT (line->v1->x);
+	p[1] = FIXED2FLOAT (line->v1->y);
+	p[2] = FIXED2FLOAT (destheight);
+	v1[0] = FIXED2FLOAT (line->dx);
+	v1[1] = FIXED2FLOAT (line->dy);
+	v1[2] = 0;
+	v2[0] = FIXED2FLOAT (refvert->x - line->v1->x);
+	v2[1] = FIXED2FLOAT (refvert->y - line->v1->y);
+	v2[2] = FIXED2FLOAT (srcheight - destheight);
+
+	cross = (v1 ^ v2).Unit();
+
+	// Fix backward normals
+	if ((cross.Z < 0 && which == 0) || (cross.Z > 0 && which == 1))
+	{
+		cross = -cross;
+	}
+
+	srcplane->a = FLOAT2FIXED (cross[0]);
+	srcplane->b = FLOAT2FIXED (cross[1]);
+	srcplane->c = FLOAT2FIXED (cross[2]);
+	//srcplane->ic = FLOAT2FIXED (1.f/cross[2]);
+	srcplane->ic = DivScale32 (1, srcplane->c);
+	srcplane->d = -TMulScale16 (srcplane->a, line->v1->x,
+								srcplane->b, line->v1->y,
+								srcplane->c, destheight);
+}
+
+//===========================================================================
+//
+// P_SetSlopes
+//
+//===========================================================================
+
+void P_SetSlopes ()
+{
+	int i, s;
+
+	for (i = 0; i < numlines; i++)
+	{
+		if (lines[i].special == Plane_Align)
+		{
+			lines[i].special = 0;
+			lines[i].id = lines[i].args[2];
+			if (lines[i].backsector != NULL)
+			{
+				// args[0] is for floor, args[1] is for ceiling
+				//
+				// As a special case, if args[1] is 0,
+				// then args[0], bits 2-3 are for ceiling.
+				for (s = 0; s < 2; s++)
+				{
+					int bits = lines[i].args[s] & 3;
+
+					if (s == 1 && bits == 0)
+						bits = (lines[i].args[0] >> 2) & 3;
+
+					if (bits == 1)			// align front side to back
+						P_AlignPlane (lines[i].frontsector, lines + i, s);
+					else if (bits == 2)		// align back side to front
+						P_AlignPlane (lines[i].backsector, lines + i, s);
+				}
+			}
+		}
+	}
+}
+
diff --git a/zdoom.vcproj b/zdoom.vcproj
index 674c212cea..7421857ce4 100644
--- a/zdoom.vcproj
+++ b/zdoom.vcproj
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="8.00"
+	Version="8,00"
 	Name="zdoom"
 	ProjectGUID="{8049475B-5C87-46F9-9358-635218A4EF18}"
 	RootNamespace=" zdoom"
@@ -135,6 +135,112 @@
 				Name="VCPostBuildEventTool"
 			/>
 		</Configuration>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory=".\Debug"
+			IntermediateDirectory=".\Debug"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+				Description="Checking svnrevision.h..."
+				CommandLine="$(OutDir)\updaterevision.exe src src/svnrevision.h"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				PreprocessorDefinitions="_DEBUG"
+				MkTypLibCompatible="true"
+				SuppressStartupBanner="true"
+				TargetEnvironment="1"
+				TypeLibraryName=".\Debug/zdoom.tlb"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="src\win32;src\sound;src;zlib;src\g_shared;src\g_doom;src\g_raven;src\g_heretic;src\g_hexen;src\g_strife;jpeg-6b;snes_spc\snes_spc"
+				PreprocessorDefinitions="WIN32,_DEBUG,_WIN32,_WINDOWS,USEASM,_CRTDBG_MAP_ALLOC,HAVE_STRUPR,HAVE_FILELENGTH"
+				MinimalRebuild="true"
+				RuntimeLibrary="1"
+				EnableFunctionLevelLinking="true"
+				ForceConformanceInForLoopScope="true"
+				PrecompiledHeaderFile=""
+				AssemblerOutput="0"
+				AssemblerListingLocation=".\Debug/"
+				ObjectFile=".\Debug/"
+				ProgramDataBaseFileName=".\Debug/"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+				CompileAs="0"
+				DisableSpecificWarnings="4996"
+				ForcedIncludeFiles=""
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="1033"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalOptions="/MACHINE:I386"
+				AdditionalDependencies="gdi32.lib user32.lib comctl32.lib shell32.lib advapi32.lib comdlg32.lib ole32.lib dxguid.lib dsound.lib dinput8.lib strmiids.lib wsock32.lib winmm.lib fmodex_vc.lib setupapi.lib ws2_32.lib"
+				OutputFile="../zdoomd.exe"
+				LinkIncremental="2"
+				SuppressStartupBanner="true"
+				AdditionalLibraryDirectories=""
+				IgnoreDefaultLibraryNames="libcmt;msvcrtd;msvcrt"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile=".\Debug/zdoomd.pdb"
+				SubSystem="2"
+				StackReserveSize="0"
+				TerminalServerAware="2"
+				SetChecksum="false"
+				TargetMachine="0"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
 		<Configuration
 			Name="Release|x64"
 			OutputDirectory="$(PlatformName)\$(ConfigurationName)"
@@ -246,112 +352,6 @@
 				Name="VCPostBuildEventTool"
 			/>
 		</Configuration>
-		<Configuration
-			Name="Debug|Win32"
-			OutputDirectory=".\Debug"
-			IntermediateDirectory=".\Debug"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="false"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-				Description="Checking svnrevision.h..."
-				CommandLine="$(OutDir)\updaterevision.exe src src/svnrevision.h"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				PreprocessorDefinitions="_DEBUG"
-				MkTypLibCompatible="true"
-				SuppressStartupBanner="true"
-				TargetEnvironment="1"
-				TypeLibraryName=".\Debug/zdoom.tlb"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories="src\win32;src\sound;src;zlib;src\g_shared;src\g_doom;src\g_raven;src\g_heretic;src\g_hexen;src\g_strife;jpeg-6b;snes_spc\snes_spc"
-				PreprocessorDefinitions="WIN32,_DEBUG,_WIN32,_WINDOWS,USEASM,_CRTDBG_MAP_ALLOC,HAVE_STRUPR,HAVE_FILELENGTH"
-				MinimalRebuild="true"
-				RuntimeLibrary="1"
-				EnableFunctionLevelLinking="true"
-				ForceConformanceInForLoopScope="true"
-				PrecompiledHeaderFile=""
-				AssemblerOutput="0"
-				AssemblerListingLocation=".\Debug/"
-				ObjectFile=".\Debug/"
-				ProgramDataBaseFileName=".\Debug/"
-				WarningLevel="3"
-				SuppressStartupBanner="true"
-				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
-				CompileAs="0"
-				DisableSpecificWarnings="4996"
-				ForcedIncludeFiles=""
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="_DEBUG"
-				Culture="1033"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalOptions="/MACHINE:I386"
-				AdditionalDependencies="gdi32.lib user32.lib comctl32.lib shell32.lib advapi32.lib comdlg32.lib ole32.lib dxguid.lib dsound.lib dinput8.lib strmiids.lib wsock32.lib winmm.lib fmodex_vc.lib setupapi.lib ws2_32.lib"
-				OutputFile="../zdoomd.exe"
-				LinkIncremental="2"
-				SuppressStartupBanner="true"
-				AdditionalLibraryDirectories=""
-				IgnoreDefaultLibraryNames="libcmt;msvcrtd;msvcrt"
-				GenerateDebugInformation="true"
-				ProgramDatabaseFile=".\Debug/zdoomd.pdb"
-				SubSystem="2"
-				StackReserveSize="0"
-				TerminalServerAware="2"
-				SetChecksum="false"
-				TargetMachine="0"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
 		<Configuration
 			Name="Debug|x64"
 			OutputDirectory="$(PlatformName)\$(ConfigurationName)"
@@ -833,6 +833,10 @@
 				RelativePath=".\src\p_sight.cpp"
 				>
 			</File>
+			<File
+				RelativePath=".\src\p_slopes.cpp"
+				>
+			</File>
 			<File
 				RelativePath=".\src\p_spec.cpp"
 				>
@@ -922,16 +926,6 @@
 						Outputs="&quot;src/$(InputName).h&quot;"
 					/>
 				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|x64"
-					>
-					<Tool
-						Name="VCCustomBuildTool"
-						Description="Creating $(InputName).h from src/$(InputFileName)"
-						CommandLine="tools\re2c\re2c -s -o &quot;src/$(InputName).h&quot; &quot;src/$(InputFileName)&quot;&#x0D;&#x0A;"
-						Outputs="&quot;src/$(InputName).h&quot;"
-					/>
-				</FileConfiguration>
 				<FileConfiguration
 					Name="Debug|Win32"
 					>
@@ -942,6 +936,16 @@
 						Outputs="&quot;src/$(InputName).h&quot;"
 					/>
 				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|x64"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+						Description="Creating $(InputName).h from src/$(InputFileName)"
+						CommandLine="tools\re2c\re2c -s -o &quot;src/$(InputName).h&quot; &quot;src/$(InputFileName)&quot;&#x0D;&#x0A;"
+						Outputs="&quot;src/$(InputName).h&quot;"
+					/>
+				</FileConfiguration>
 				<FileConfiguration
 					Name="Debug|x64"
 					>
@@ -1536,6 +1540,16 @@
 						Outputs="$(IntDir)\$(InputName).obj"
 					/>
 				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+						Description="Assembling $(InputPath)..."
+						CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
+						Outputs="$(IntDir)\$(InputName).obj"
+					/>
+				</FileConfiguration>
 				<FileConfiguration
 					Name="Release|x64"
 					ExcludedFromBuild="true"
@@ -1547,16 +1561,6 @@
 						Outputs="$(IntDir)/$(InputName).obj"
 					/>
 				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCustomBuildTool"
-						Description="Assembling $(InputPath)..."
-						CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
-						Outputs="$(IntDir)\$(InputName).obj"
-					/>
-				</FileConfiguration>
 				<FileConfiguration
 					Name="Debug|x64"
 					ExcludedFromBuild="true"
@@ -1582,6 +1586,16 @@
 						Outputs="$(IntDir)\$(InputName).obj"
 					/>
 				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+						Description="Assembling $(InputPath)..."
+						CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
+						Outputs="$(IntDir)\$(InputName).obj"
+					/>
+				</FileConfiguration>
 				<FileConfiguration
 					Name="Release|x64"
 					ExcludedFromBuild="true"
@@ -1593,16 +1607,6 @@
 						Outputs="$(IntDir)/$(InputName).obj"
 					/>
 				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCustomBuildTool"
-						Description="Assembling $(InputPath)..."
-						CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
-						Outputs="$(IntDir)\$(InputName).obj"
-					/>
-				</FileConfiguration>
 				<FileConfiguration
 					Name="Debug|x64"
 					ExcludedFromBuild="true"
@@ -1628,6 +1632,16 @@
 						Outputs="$(IntDir)\$(InputName).obj"
 					/>
 				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+						Description="Assembling $(InputPath)..."
+						CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
+						Outputs="$(IntDir)\$(InputName).obj"
+					/>
+				</FileConfiguration>
 				<FileConfiguration
 					Name="Release|x64"
 					ExcludedFromBuild="true"
@@ -1639,16 +1653,6 @@
 						Outputs="$(IntDir)\$(InputName).obj"
 					/>
 				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCustomBuildTool"
-						Description="Assembling $(InputPath)..."
-						CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
-						Outputs="$(IntDir)\$(InputName).obj"
-					/>
-				</FileConfiguration>
 				<FileConfiguration
 					Name="Debug|x64"
 					ExcludedFromBuild="true"
@@ -1674,6 +1678,16 @@
 						Outputs="$(IntDir)\$(InputName).obj"
 					/>
 				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+						Description="Assembling $(InputPath)..."
+						CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
+						Outputs="$(IntDir)\$(InputName).obj"
+					/>
+				</FileConfiguration>
 				<FileConfiguration
 					Name="Release|x64"
 					ExcludedFromBuild="true"
@@ -1685,16 +1699,6 @@
 						Outputs="$(IntDir)\$(InputName).obj"
 					/>
 				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCustomBuildTool"
-						Description="Assembling $(InputPath)..."
-						CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
-						Outputs="$(IntDir)\$(InputName).obj"
-					/>
-				</FileConfiguration>
 				<FileConfiguration
 					Name="Debug|x64"
 					ExcludedFromBuild="true"
@@ -1720,6 +1724,16 @@
 						Outputs="$(IntDir)\$(InputName).obj"
 					/>
 				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+						Description="Assembling $(InputPath)..."
+						CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
+						Outputs="$(IntDir)\$(InputName).obj"
+					/>
+				</FileConfiguration>
 				<FileConfiguration
 					Name="Release|x64"
 					ExcludedFromBuild="true"
@@ -1731,16 +1745,6 @@
 						Outputs="$(IntDir)\$(InputName).obj"
 					/>
 				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCustomBuildTool"
-						Description="Assembling $(InputPath)..."
-						CommandLine="nasm -g -o &quot;$(IntDir)\$(InputName).obj&quot; -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;$(OutDir)\fixrtext &quot;$(IntDir)\$(InputName).obj&quot;&#x0D;&#x0A;"
-						Outputs="$(IntDir)\$(InputName).obj"
-					/>
-				</FileConfiguration>
 				<FileConfiguration
 					Name="Debug|x64"
 					ExcludedFromBuild="true"
@@ -1906,14 +1910,6 @@
 						Outputs="$(IntDir)\$(InputName).obj"
 					/>
 				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|x64"
-					ExcludedFromBuild="true"
-					>
-					<Tool
-						Name="VCCustomBuildTool"
-					/>
-				</FileConfiguration>
 				<FileConfiguration
 					Name="Debug|Win32"
 					>
@@ -1924,6 +1920,14 @@
 						Outputs="$(IntDir)\$(InputName).obj"
 					/>
 				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|x64"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+					/>
+				</FileConfiguration>
 				<FileConfiguration
 					Name="Debug|x64"
 					ExcludedFromBuild="true"
@@ -2781,14 +2785,6 @@
 						AdditionalIncludeDirectories="src\win32;$(NoInherit)"
 					/>
 				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|x64"
-					>
-					<Tool
-						Name="VCResourceCompilerTool"
-						AdditionalIncludeDirectories="src\win32;$(NoInherit)"
-					/>
-				</FileConfiguration>
 				<FileConfiguration
 					Name="Debug|Win32"
 					>
@@ -2798,6 +2794,14 @@
 						AdditionalIncludeDirectories="src\win32;$(NoInherit)"
 					/>
 				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|x64"
+					>
+					<Tool
+						Name="VCResourceCompilerTool"
+						AdditionalIncludeDirectories="src\win32;$(NoInherit)"
+					/>
+				</FileConfiguration>
 				<FileConfiguration
 					Name="Debug|x64"
 					>
@@ -3040,7 +3044,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Release|x64"
+					Name="Debug|Win32"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3048,7 +3052,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Debug|Win32"
+					Name="Release|x64"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3080,7 +3084,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Release|x64"
+					Name="Debug|Win32"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3088,7 +3092,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Debug|Win32"
+					Name="Release|x64"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3117,7 +3121,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Release|x64"
+					Name="Debug|Win32"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3126,7 +3130,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Debug|Win32"
+					Name="Release|x64"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3156,7 +3160,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Release|x64"
+					Name="Debug|Win32"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3164,7 +3168,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Debug|Win32"
+					Name="Release|x64"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3193,7 +3197,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Release|x64"
+					Name="Debug|Win32"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3202,7 +3206,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Debug|Win32"
+					Name="Release|x64"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3233,7 +3237,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Release|x64"
+					Name="Debug|Win32"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3242,7 +3246,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Debug|Win32"
+					Name="Release|x64"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3272,7 +3276,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Release|x64"
+					Name="Debug|Win32"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3280,7 +3284,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Debug|Win32"
+					Name="Release|x64"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3309,7 +3313,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Release|x64"
+					Name="Debug|Win32"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3318,7 +3322,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Debug|Win32"
+					Name="Release|x64"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3349,7 +3353,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Release|x64"
+					Name="Debug|Win32"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3358,7 +3362,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Debug|Win32"
+					Name="Release|x64"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3389,7 +3393,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Release|x64"
+					Name="Debug|Win32"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3398,7 +3402,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Debug|Win32"
+					Name="Release|x64"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3428,7 +3432,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Release|x64"
+					Name="Debug|Win32"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3436,7 +3440,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Debug|Win32"
+					Name="Release|x64"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3464,7 +3468,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Release|x64"
+					Name="Debug|Win32"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3472,7 +3476,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Debug|Win32"
+					Name="Release|x64"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3500,7 +3504,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Release|x64"
+					Name="Debug|Win32"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3508,7 +3512,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Debug|Win32"
+					Name="Release|x64"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3536,7 +3540,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Release|x64"
+					Name="Debug|Win32"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3544,7 +3548,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Debug|Win32"
+					Name="Release|x64"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3574,7 +3578,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Release|x64"
+					Name="Debug|Win32"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3584,7 +3588,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Debug|Win32"
+					Name="Release|x64"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3628,7 +3632,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Release|x64"
+					Name="Debug|Win32"
 					ExcludedFromBuild="true"
 					>
 					<Tool
@@ -3636,7 +3640,7 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="Debug|Win32"
+					Name="Release|x64"
 					ExcludedFromBuild="true"
 					>
 					<Tool