Merge branch 'next' of http://git.magicalgirl.moe/STJr/SRB2.git into lua-sector-lines

This commit is contained in:
Monster Iestyn 2016-01-20 12:31:21 +00:00
commit 103027124b
71 changed files with 7486 additions and 3714 deletions

View File

@ -103,7 +103,8 @@ set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary")
include(GitUtilities)
git_describe(SRB2_GIT_DESCRIBE "${CMAKE_SOURCE_DIR}")
git_current_branch(SRB2_GIT_BRANCH "${CMAKE_SOURCE_DIR}")
set(SRB2_COMP_REVISION "${SRB2_GIT_DESCRIBE}-<${SRB2_GIT_BRANCH}>")
set(SRB2_COMP_BRANCH "${SRB2_GIT_BRANCH}")
set(SRB2_COMP_REVISION "${SRB2_GIT_DESCRIBE}")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
##### PACKAGE CONFIGURATION #####

View File

@ -1,10 +1,32 @@
@ECHO OFF
set REV=Unknown
set BRA=Unknown
set REV=illegal
copy nul: /b +%1\comptime.c tmp.$$$ > nul
move tmp.$$$ %1\comptime.c > nul
SET REV=illegal
FOR /F "usebackq" %%s IN (`svnversion %1`) DO @SET REV=%%s
if exist .git goto gitrev
if exist ..\.git goto gitrev
if exist .svn goto svnrev
goto filwri
:gitrev
set GIT=%2
if "%GIT%"=="" set GIT=git
FOR /F "usebackq" %%s IN (`%GIT% rev-parse --abbrev-ref HEAD`) DO @SET BRA=%%s
FOR /F "usebackq" %%s IN (`%GIT% rev-parse HEAD`) DO @SET REV=%%s
set REV=%REV:~0,8%
goto filwri
:svnrev
set BRA=Subversion
FOR /F "usebackq" %%s IN (`svnversion .`) DO @SET REV=%%s
set REV=r%REV%
goto filwri
:filwri
ECHO // Do not edit! This file was autogenerated > %1\comptime.h
ECHO // by the %0 batch file >> %1\comptime.h
ECHO // >> %1\comptime.h
ECHO const char* comprevision = "r%REV%"; >> %1\comptime.h
ECHO const char* compbranch = "%BRA%"; >> %1\comptime.h
ECHO const char* comprevision = "%REV%"; >> %1\comptime.h

View File

@ -5,13 +5,15 @@ if [ x"$1" != x ]; then
fi
versiongit() {
gitversion=`git describe`
gitbranch=`git rev-parse --abbrev-ref HEAD`
gitversion=`git rev-parse HEAD`
cat <<EOF > $path/comptime.h
// Do not edit! This file was autogenerated
// by the $0 script with git svn
// by the $0 script with git
//
const char* comprevision = "$gitversion";
const char* compbranch = "$gitbranch";
const char* comprevision = "${gitversion:0:8}";
EOF
exit 0
}
@ -23,6 +25,7 @@ versionsvn() {
// Do not edit! This file was autogenerated
// by the $0 script with subversion
//
const char* compbranch = "Subversion";
const char* comprevision = "r$svnrevision";
EOF
exit 0
@ -34,6 +37,7 @@ versionfake() {
// Do not edit! This file was autogenerated
// by the $0 script with an unknown or nonexist SCM
//
const char* compbranch = "Unknown";
const char* comprevision = "illegal";
EOF
}

View File

@ -150,6 +150,7 @@ set(SRB2_CORE_GAME_SOURCES
p_saveg.c
p_setup.c
p_sight.c
p_slopes.c
p_spec.c
p_telept.c
p_tick.c
@ -162,6 +163,7 @@ set(SRB2_CORE_GAME_SOURCES
p_pspr.h
p_saveg.h
p_setup.h
p_slopes.h
p_spec.h
p_tick.h
)

View File

@ -454,6 +454,7 @@ OBJS:=$(i_main_o) \
$(OBJDIR)/p_telept.o \
$(OBJDIR)/p_tick.o \
$(OBJDIR)/p_user.o \
$(OBJDIR)/p_slopes.o \
$(OBJDIR)/tables.o \
$(OBJDIR)/r_bsp.o \
$(OBJDIR)/r_data.o \

View File

@ -11,6 +11,13 @@
#include <limits.h>
#include <stddef.h>
#ifdef _MSC_VER
#define INT32 __int32
#else
#include <stdint.h>
#define INT32 int32_t
#endif
/*
** ==================================================================
@ -140,7 +147,7 @@
** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
** machines, ptrdiff_t gives a good choice between int or long.)
*/
#define LUA_INTEGER ptrdiff_t
#define LUA_INTEGER INT32
/*
@ -502,13 +509,13 @@
*/
//#define LUA_NUMBER_DOUBLE
#define LUA_NUMBER ptrdiff_t
#define LUA_NUMBER INT32
/*
@@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
@* over a number.
*/
#define LUAI_UACNUMBER ptrdiff_t
#define LUAI_UACNUMBER INT32
/*
@ -519,14 +526,14 @@
@@ lua_str2number converts a string to a number.
*/
#ifdef LUA_WIN
#define LUA_NUMBER_SCAN "%Ii"
#define LUA_NUMBER_FMT "%Ii"
#define LUA_NUMBER_SCAN "%d"
#define LUA_NUMBER_FMT "%d"
#else
#define LUA_NUMBER_SCAN "%ti"
#define LUA_NUMBER_FMT "%ti"
#define LUA_NUMBER_SCAN "%d"
#define LUA_NUMBER_FMT "%d"
#endif
#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
#define LUAI_MAXNUMBER2STR 12 /* 10 digits, sign, and \0 */
#define lua_str2number(s,p) strtol((s), (p), 10)

View File

@ -9,12 +9,14 @@
#if (defined(CMAKECONFIG))
#include "config.h"
const char *compbranch = SRB2_COMP_BRANCH;
const char *comprevision = SRB2_COMP_REVISION;
#elif (defined(COMPVERSION))
#include "comptime.h"
#else
const char *compbranch = "Unknown";
const char *comprevision = "illegal";
#endif

View File

@ -18,6 +18,7 @@
#define ASSET_HASH_PATCH_DTA "${SRB2_ASSET_patch.dta_HASH}"
#define SRB2_COMP_REVISION "${SRB2_COMP_REVISION}"
#define SRB2_COMP_BRANCH "${SRB2_COMP_BRANCH}"
#define SRB2_GIT_DESCRIBE "${SRB2_GIT_DESCRIBE}"
#define SRB2_GIT_BRANCH "${SRB2_GIT_BRANCH}"

View File

@ -96,6 +96,10 @@ int snprintf(char *str, size_t n, const char *fmt, ...);
#include "hardware/hw3sound.h"
#endif
#ifdef HAVE_BLUA
#include "lua_script.h"
#endif
// platform independant focus loss
UINT8 window_notinfocus = false;
@ -634,6 +638,10 @@ void D_SRB2Loop(void)
#ifdef HW3SOUND
HW3S_EndFrameUpdate();
#endif
#ifdef HAVE_BLUA
LUA_Step();
#endif
}
}

View File

@ -3179,7 +3179,11 @@ static void Command_ListWADS_f(void)
*/
static void Command_Version_f(void)
{
#ifdef DEVELOP
CONS_Printf("Sonic Robo Blast 2 %s-%s (%s %s)\n", compbranch, comprevision, compdate, comptime);
#else
CONS_Printf("Sonic Robo Blast 2 %s (%s %s %s)\n", VERSIONSTRING, compdate, comptime, comprevision);
#endif
}
#ifdef UPDATE_ALERT

View File

@ -1132,6 +1132,10 @@ static void readlevelheader(MYFILE *f, INT32 num)
}
else if (fastcmp(word, "NEXTLEVEL"))
{
if (fastcmp(word2, "TITLE")) i = 1100;
else if (fastcmp(word2, "EVALUATION")) i = 1101;
else if (fastcmp(word2, "CREDITS")) i = 1102;
else
// Support using the actual map name,
// i.e., Nextlevel = AB, Nextlevel = FZ, etc.
@ -7207,6 +7211,7 @@ static const char *const MOBJEFLAG_LIST[] = {
"GOOWATER", // Goo water
"PUSHED", // Mobj was already pushed this tic
"SPRUNG", // Mobj was already sprung this tic
"APPLYPMOMZ", // Platform movement
NULL
};
@ -7756,36 +7761,36 @@ struct {
{"FF_GOOWATER",FF_GOOWATER}, ///< Used with ::FF_SWIMMABLE. Makes thick bouncey goop.
// Angles
{"ANG1",ANG1},
{"ANG2",ANG2},
{"ANG10",ANG10},
{"ANG15",ANG15},
{"ANG20",ANG20},
{"ANG30",ANG30},
{"ANG60",ANG60},
{"ANG64h",ANG64h},
{"ANG105",ANG105},
{"ANG210",ANG210},
{"ANG255",ANG255},
{"ANG340",ANG340},
{"ANG350",ANG350},
{"ANGLE_11hh",ANGLE_11hh},
{"ANGLE_22h",ANGLE_22h},
{"ANGLE_45",ANGLE_45},
{"ANGLE_67h",ANGLE_67h},
{"ANGLE_90",ANGLE_90},
{"ANGLE_112h",ANGLE_112h},
{"ANGLE_135",ANGLE_135},
{"ANGLE_157h",ANGLE_157h},
{"ANGLE_180",ANGLE_180},
{"ANGLE_202h",ANGLE_202h},
{"ANGLE_225",ANGLE_225},
{"ANGLE_247h",ANGLE_247h},
{"ANGLE_270",ANGLE_270},
{"ANGLE_292h",ANGLE_292h},
{"ANGLE_315",ANGLE_315},
{"ANGLE_337h",ANGLE_337h},
{"ANGLE_MAX",ANGLE_MAX},
{"ANG1",ANG1>>16},
{"ANG2",ANG2>>16},
{"ANG10",ANG10>>16},
{"ANG15",ANG15>>16},
{"ANG20",ANG20>>16},
{"ANG30",ANG30>>16},
{"ANG60",ANG60>>16},
{"ANG64h",ANG64h>>16},
{"ANG105",ANG105>>16},
{"ANG210",ANG210>>16},
{"ANG255",ANG255>>16},
{"ANG340",ANG340>>16},
{"ANG350",ANG350>>16},
{"ANGLE_11hh",ANGLE_11hh>>16},
{"ANGLE_22h",ANGLE_22h>>16},
{"ANGLE_45",ANGLE_45>>16},
{"ANGLE_67h",ANGLE_67h>>16},
{"ANGLE_90",ANGLE_90>>16},
{"ANGLE_112h",ANGLE_112h>>16},
{"ANGLE_135",ANGLE_135>>16},
{"ANGLE_157h",ANGLE_157h>>16},
{"ANGLE_180",ANGLE_180>>16},
{"ANGLE_202h",ANGLE_202h>>16},
{"ANGLE_225",ANGLE_225>>16},
{"ANGLE_247h",ANGLE_247h>>16},
{"ANGLE_270",ANGLE_270>>16},
{"ANGLE_292h",ANGLE_292h>>16},
{"ANGLE_315",ANGLE_315>>16},
{"ANGLE_337h",ANGLE_337h>>16},
{"ANGLE_MAX",ANGLE_MAX>>16},
// P_Chase directions (dirtype_t)
{"DI_NODIR",DI_NODIR},

View File

@ -142,8 +142,10 @@ extern FILE *logstream;
#ifdef DEVELOP
#define VERSION 0 // Game version
#define SUBVERSION 0 // more precise version number
#define VERSIONSTRING "Trunk"
#define VERSIONSTRINGW L"Trunk"
#define VERSIONSTRING "Development EXE"
#define VERSIONSTRINGW L"Development EXE"
// most interface strings are ignored in development mode.
// we use comprevision and compbranch instead.
#else
#define VERSION 201 // Game version
#define SUBVERSION 14 // more precise version number
@ -426,7 +428,7 @@ INT32 I_GetKey(void);
#endif
// Compile date and time and revision.
extern const char *compdate, *comptime, *comprevision;
extern const char *compdate, *comptime, *comprevision, *compbranch;
// Disabled code and code under testing
// None of these that are disabled in the normal build are guaranteed to work perfectly
@ -439,6 +441,9 @@ extern const char *compdate, *comptime, *comprevision;
/// Fun experimental slope stuff!
//#define SLOPENESS
/// Kalaron/Eternity Engine slope code (SRB2CB ported)
#define ESLOPE
/// Delete file while the game is running.
/// \note EXTREMELY buggy, tends to crash game.
//#define DELFILE

View File

@ -100,11 +100,13 @@ typedef long ssize_t;
#if defined (_MSC_VER) || defined (__OS2__)
// Microsoft VisualC++
#ifdef _MSC_VER
#if (_MSC_VER <= 1800) // MSVC 2013 and back
#define snprintf _snprintf
#if (_MSC_VER <= 1200) // MSVC 2012 and back
#define vsnprintf _vsnprintf
#endif
#endif
#endif
#define strncasecmp strnicmp
#define strcasecmp stricmp
@ -177,6 +179,8 @@ size_t strlcpy(char *dst, const char *src, size_t siz);
// not the number of bytes in the buffer.
#define STRBUFCPY(dst,src) strlcpy(dst, src, sizeof dst)
// \note __BYTEBOOL__ used to be set above if "macintosh" was defined,
// if macintosh's version of boolean type isn't needed anymore, then isn't this macro pointless now?
#ifndef __BYTEBOOL__
#define __BYTEBOOL__
@ -193,7 +197,6 @@ size_t strlcpy(char *dst, const char *src, size_t siz);
#else
typedef enum {false, true} boolean;
#endif
//#endif // __cplusplus
#endif // __BYTEBOOL__
/* 7.18.2.1 Limits of exact-width integer types */

View File

@ -982,6 +982,7 @@ static const char *credits[] = {
"",
"\1Programming",
"\1Assistance",
"\"chi.miru\"", // Red's secret weapon, the REAL reason slopes exist (also helped port drawing code from ZDoom)
"Andrew \"orospakr\" Clunis",
"Gregor \"Oogaland\" Dick",
"Julio \"Chaos Zero 64\" Guir",

View File

@ -231,34 +231,52 @@ static void F_DoWipe(fademask_t *fademask)
maskx = masky = 0;
do
{
// pointer to transtable that this mask would use
transtbl = transtables + ((9 - *mask)<<FF_TRANSSHIFT);
// (ignore that it goes out of bounds if *mask is 0 or 10 --
// it wouldn't be used in those cases anyway)
draw_rowstart = scrxpos[maskx];
draw_rowend = scrxpos[maskx + 1];
draw_linestart = scrypos[masky];
draw_lineend = scrypos[masky + 1];
// DRAWING LOOP
relativepos = (draw_linestart * vid.width) + draw_rowstart;
draw_linestogo = draw_lineend - draw_linestart;
while (draw_linestogo--)
if (*mask == 0)
{
w = w_base + relativepos;
s = s_base + relativepos;
e = e_base + relativepos;
draw_rowstogo = draw_rowend - draw_rowstart;
while (draw_rowstogo--)
// shortcut - memcpy source to work
while (draw_linestogo--)
{
if (*s != *e)
*w = ((*mask == 0) ? *s : (*mask == 10) ? *e : transtbl[(*e<<8) + *s]);
++w, ++s, ++e;
M_Memcpy(w_base+relativepos, s_base+relativepos, draw_rowend-draw_rowstart);
relativepos += vid.width;
}
relativepos += vid.width;
}
// END DRAWING LOOP
else if (*mask == 10)
{
// shortcut - memcpy target to work
while (draw_linestogo--)
{
M_Memcpy(w_base+relativepos, e_base+relativepos, draw_rowend-draw_rowstart);
relativepos += vid.width;
}
}
else
{
// pointer to transtable that this mask would use
transtbl = transtables + ((9 - *mask)<<FF_TRANSSHIFT);
// DRAWING LOOP
while (draw_linestogo--)
{
w = w_base + relativepos;
s = s_base + relativepos;
e = e_base + relativepos;
draw_rowstogo = draw_rowend - draw_rowstart;
while (draw_rowstogo--)
*w++ = transtbl[ ( *e++ << 8 ) + *s++ ];
relativepos += vid.width;
}
// END DRAWING LOOP
}
if (++maskx >= fademask->width)
++masky, maskx = 0;

View File

@ -297,9 +297,6 @@ static CV_PossibleValue_t joyaxis_cons_t[] = {{0, "None"},
#if JOYAXISSET > 3
{7, "Pitch"}, {8, "Roll"}, {-7, "Pitch-"}, {-8, "Roll-"},
#endif
#if JOYAXISSET > 3
{7, "Pitch"}, {8, "Roll"}, {-7, "Pitch-"}, {-8, "Roll-"},
#endif
#if JOYAXISSET > 4
{7, "Yaw"}, {8, "Dummy"}, {-7, "Yaw-"}, {-8, "Dummy-"},
#endif

View File

@ -79,6 +79,7 @@ typedef struct gr_vissprite_s
boolean vflip;
//Hurdler: 25/04/2000: now support colormap in hardware mode
UINT8 *colormap;
INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing
} gr_vissprite_t;
// --------

View File

@ -3998,6 +3998,7 @@ static void HWR_SortVisSprites(void)
gr_vissprite_t *best = NULL;
gr_vissprite_t unsorted;
float bestdist;
INT32 bestdispoffset;
if (!gr_visspritecount)
return;
@ -4025,11 +4026,19 @@ static void HWR_SortVisSprites(void)
for (i = 0; i < gr_visspritecount; i++)
{
bestdist = ZCLIP_PLANE-1;
bestdispoffset = INT32_MAX;
for (ds = unsorted.next; ds != &unsorted; ds = ds->next)
{
if (ds->tz > bestdist)
{
bestdist = ds->tz;
bestdispoffset = ds->dispoffset;
best = ds;
}
// order visprites of same scale by dispoffset, smallest first
else if (ds->tz == bestdist && ds->dispoffset < bestdispoffset)
{
bestdispoffset = ds->dispoffset;
best = ds;
}
}
@ -4653,6 +4662,7 @@ static void HWR_ProjectSprite(mobj_t *thing)
#endif
vis->x2 = tx;
vis->tz = tz;
vis->dispoffset = thing->info->dispoffset; // Monster Iestyn: 23/11/15: HARDWARE SUPPORT AT LAST
vis->patchlumpnum = sprframe->lumppat[rot];
vis->flip = flip;
vis->mobj = thing;
@ -4769,6 +4779,7 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
vis->x1 = x1;
vis->x2 = tx;
vis->tz = tz;
vis->dispoffset = 0; // Monster Iestyn: 23/11/15: HARDWARE SUPPORT AT LAST
vis->patchlumpnum = sprframe->lumppat[rot];
vis->flip = flip;
vis->mobj = (mobj_t *)thing;

View File

@ -926,7 +926,7 @@ void HWR_InitMD2(void)
CONS_Printf("MD2 for sprite PLAY detected in md2.dat, use a player skin instead!\n");
continue;
}
for (i = 0; i < NUMSPRITES; i++)
{
if (stricmp(name, sprnames[i]) == 0)
@ -1085,7 +1085,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
if (!cv_grmd2.value)
return;
if (!spr->precip)
if (spr->precip)
return;
// MD2 colormap fix

View File

@ -85,13 +85,6 @@ static int lib_print(lua_State *L)
return 0;
}
static int lib_evalMath(lua_State *L)
{
const char *word = luaL_checkstring(L, 1);
lua_pushinteger(L, LUA_EvalMath(word));
return 1;
}
// M_RANDOM
//////////////
@ -138,25 +131,25 @@ static int lib_pRandomRange(lua_State *L)
static int lib_pAproxDistance(lua_State *L)
{
fixed_t dx = (fixed_t)luaL_checkinteger(L, 1);
fixed_t dy = (fixed_t)luaL_checkinteger(L, 2);
fixed_t dx = luaL_checkfixed(L, 1);
fixed_t dy = luaL_checkfixed(L, 2);
//HUDSAFE
lua_pushinteger(L, P_AproxDistance(dx, dy));
lua_pushfixed(L, P_AproxDistance(dx, dy));
return 1;
}
static int lib_pClosestPointOnLine(lua_State *L)
{
fixed_t x = (fixed_t)luaL_checkinteger(L, 1);
fixed_t y = (fixed_t)luaL_checkinteger(L, 2);
fixed_t x = luaL_checkfixed(L, 1);
fixed_t y = luaL_checkfixed(L, 2);
line_t *line = *((line_t **)luaL_checkudata(L, 3, META_LINE));
vertex_t result;
//HUDSAFE
if (!line)
return LUA_ErrInvalid(L, "line_t");
P_ClosestPointOnLine(x, y, line, &result);
lua_pushinteger(L, result.x);
lua_pushinteger(L, result.y);
lua_pushfixed(L, result.x);
lua_pushfixed(L, result.y);
return 2;
}
@ -241,9 +234,9 @@ static int lib_pLookForPlayers(lua_State *L)
static int lib_pSpawnMobj(lua_State *L)
{
fixed_t x = (fixed_t)luaL_checkinteger(L, 1);
fixed_t y = (fixed_t)luaL_checkinteger(L, 2);
fixed_t z = (fixed_t)luaL_checkinteger(L, 3);
fixed_t x = luaL_checkfixed(L, 1);
fixed_t y = luaL_checkfixed(L, 2);
fixed_t z = luaL_checkfixed(L, 3);
mobjtype_t type = luaL_checkinteger(L, 4);
NOHUD
if (type > MT_LASTFREESLOT)
@ -283,9 +276,9 @@ static int lib_pSpawnXYZMissile(lua_State *L)
mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobj_t *dest = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
mobjtype_t type = luaL_checkinteger(L, 3);
fixed_t x = (fixed_t)luaL_checkinteger(L, 4);
fixed_t y = (fixed_t)luaL_checkinteger(L, 5);
fixed_t z = (fixed_t)luaL_checkinteger(L, 6);
fixed_t x = luaL_checkfixed(L, 4);
fixed_t y = luaL_checkfixed(L, 5);
fixed_t z = luaL_checkfixed(L, 6);
NOHUD
if (!source || !dest)
return LUA_ErrInvalid(L, "mobj_t");
@ -298,13 +291,13 @@ static int lib_pSpawnXYZMissile(lua_State *L)
static int lib_pSpawnPointMissile(lua_State *L)
{
mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t xa = (fixed_t)luaL_checkinteger(L, 2);
fixed_t ya = (fixed_t)luaL_checkinteger(L, 3);
fixed_t za = (fixed_t)luaL_checkinteger(L, 4);
fixed_t xa = luaL_checkfixed(L, 2);
fixed_t ya = luaL_checkfixed(L, 3);
fixed_t za = luaL_checkfixed(L, 4);
mobjtype_t type = luaL_checkinteger(L, 5);
fixed_t x = (fixed_t)luaL_checkinteger(L, 6);
fixed_t y = (fixed_t)luaL_checkinteger(L, 7);
fixed_t z = (fixed_t)luaL_checkinteger(L, 8);
fixed_t x = luaL_checkfixed(L, 6);
fixed_t y = luaL_checkfixed(L, 7);
fixed_t z = luaL_checkfixed(L, 8);
NOHUD
if (!source)
return LUA_ErrInvalid(L, "mobj_t");
@ -318,9 +311,9 @@ static int lib_pSpawnAlteredDirectionMissile(lua_State *L)
{
mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobjtype_t type = luaL_checkinteger(L, 2);
fixed_t x = (fixed_t)luaL_checkinteger(L, 3);
fixed_t y = (fixed_t)luaL_checkinteger(L, 4);
fixed_t z = (fixed_t)luaL_checkinteger(L, 5);
fixed_t x = luaL_checkfixed(L, 3);
fixed_t y = luaL_checkfixed(L, 4);
fixed_t z = luaL_checkfixed(L, 5);
INT32 shiftingAngle = (INT32)luaL_checkinteger(L, 5);
NOHUD
if (!source)
@ -348,7 +341,7 @@ static int lib_pSPMAngle(lua_State *L)
{
mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobjtype_t type = luaL_checkinteger(L, 2);
angle_t angle = (angle_t)luaL_checkinteger(L, 3);
angle_t angle = luaL_checkangle(L, 3);
UINT8 allowaim = (UINT8)luaL_optinteger(L, 4, 0);
UINT32 flags2 = (UINT32)luaL_optinteger(L, 5, 0);
NOHUD
@ -418,13 +411,13 @@ static int lib_pGetClosestAxis(lua_State *L)
static int lib_pSpawnParaloop(lua_State *L)
{
fixed_t x = (fixed_t)luaL_checkinteger(L, 1);
fixed_t y = (fixed_t)luaL_checkinteger(L, 2);
fixed_t z = (fixed_t)luaL_checkinteger(L, 3);
fixed_t radius = (fixed_t)luaL_checkinteger(L, 4);
fixed_t x = luaL_checkfixed(L, 1);
fixed_t y = luaL_checkfixed(L, 2);
fixed_t z = luaL_checkfixed(L, 3);
fixed_t radius = luaL_checkfixed(L, 4);
INT32 number = (INT32)luaL_checkinteger(L, 5);
mobjtype_t type = luaL_checkinteger(L, 6);
angle_t rotangle = (angle_t)luaL_checkinteger(L, 7);
angle_t rotangle = luaL_checkangle(L, 7);
statenum_t nstate = luaL_optinteger(L, 8, S_NULL);
boolean spawncenter = lua_optboolean(L, 9);
NOHUD
@ -458,7 +451,7 @@ static int lib_pSupermanLook4Players(lua_State *L)
static int lib_pSetScale(lua_State *L)
{
mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t newscale = (fixed_t)luaL_checkinteger(L, 2);
fixed_t newscale = luaL_checkfixed(L, 2);
NOHUD
if (!mobj)
return LUA_ErrInvalid(L, "mobj_t");
@ -526,7 +519,7 @@ static int lib_pGetPlayerHeight(lua_State *L)
//HUDSAFE
if (!player)
return LUA_ErrInvalid(L, "player_t");
lua_pushinteger(L, P_GetPlayerHeight(player));
lua_pushfixed(L, P_GetPlayerHeight(player));
return 1;
}
@ -536,7 +529,7 @@ static int lib_pGetPlayerSpinHeight(lua_State *L)
//HUDSAFE
if (!player)
return LUA_ErrInvalid(L, "player_t");
lua_pushinteger(L, P_GetPlayerSpinHeight(player));
lua_pushfixed(L, P_GetPlayerSpinHeight(player));
return 1;
}
@ -639,7 +632,7 @@ static int lib_pInQuicksand(lua_State *L)
static int lib_pSetObjectMomZ(lua_State *L)
{
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t value = (fixed_t)luaL_checkinteger(L, 2);
fixed_t value = luaL_checkfixed(L, 2);
boolean relative = lua_optboolean(L, 3);
NOHUD
if (!mo)
@ -753,8 +746,8 @@ static int lib_pDoPlayerExit(lua_State *L)
static int lib_pInstaThrust(lua_State *L)
{
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
angle_t angle = (angle_t)luaL_checkinteger(L, 2);
fixed_t move = (fixed_t)luaL_checkinteger(L, 3);
angle_t angle = luaL_checkangle(L, 2);
fixed_t move = luaL_checkfixed(L, 3);
NOHUD
if (!mo)
return LUA_ErrInvalid(L, "mobj_t");
@ -768,10 +761,10 @@ static int lib_pReturnThrustX(lua_State *L)
fixed_t move;
if (lua_isnil(L, 1) || lua_isuserdata(L, 1))
lua_remove(L, 1); // ignore mobj as arg1
angle = (angle_t)luaL_checkinteger(L, 1);
move = (fixed_t)luaL_checkinteger(L, 2);
angle = luaL_checkangle(L, 1);
move = luaL_checkfixed(L, 2);
//HUDSAFE
lua_pushinteger(L, P_ReturnThrustX(NULL, angle, move));
lua_pushfixed(L, P_ReturnThrustX(NULL, angle, move));
return 1;
}
@ -781,10 +774,10 @@ static int lib_pReturnThrustY(lua_State *L)
fixed_t move;
if (lua_isnil(L, 1) || lua_isuserdata(L, 1))
lua_remove(L, 1); // ignore mobj as arg1
angle = (angle_t)luaL_checkinteger(L, 1);
move = (fixed_t)luaL_checkinteger(L, 2);
angle = luaL_checkangle(L, 1);
move = luaL_checkfixed(L, 2);
//HUDSAFE
lua_pushinteger(L, P_ReturnThrustY(NULL, angle, move));
lua_pushfixed(L, P_ReturnThrustY(NULL, angle, move));
return 1;
}
@ -802,7 +795,7 @@ static int lib_pNukeEnemies(lua_State *L)
{
mobj_t *inflictor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobj_t *source = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
fixed_t radius = (fixed_t)luaL_checkinteger(L, 3);
fixed_t radius = luaL_checkfixed(L, 3);
NOHUD
if (!inflictor || !source)
return LUA_ErrInvalid(L, "mobj_t");
@ -868,8 +861,8 @@ static int lib_pSpawnSpinMobj(lua_State *L)
static int lib_pTelekinesis(lua_State *L)
{
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
fixed_t thrust = (fixed_t)luaL_checkinteger(L, 2);
fixed_t range = (fixed_t)luaL_checkinteger(L, 3);
fixed_t thrust = luaL_checkfixed(L, 2);
fixed_t range = luaL_checkfixed(L, 3);
NOHUD
if (!player)
return LUA_ErrInvalid(L, "player_t");
@ -884,8 +877,8 @@ static int lib_pCheckPosition(lua_State *L)
{
mobj_t *ptmthing = tmthing;
mobj_t *thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t x = (fixed_t)luaL_checkinteger(L, 2);
fixed_t y = (fixed_t)luaL_checkinteger(L, 3);
fixed_t x = luaL_checkfixed(L, 2);
fixed_t y = luaL_checkfixed(L, 3);
NOHUD
if (!thing)
return LUA_ErrInvalid(L, "mobj_t");
@ -899,8 +892,8 @@ static int lib_pTryMove(lua_State *L)
{
mobj_t *ptmthing = tmthing;
mobj_t *thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t x = (fixed_t)luaL_checkinteger(L, 2);
fixed_t y = (fixed_t)luaL_checkinteger(L, 3);
fixed_t x = luaL_checkfixed(L, 2);
fixed_t y = luaL_checkfixed(L, 3);
boolean allowdropoff = lua_optboolean(L, 4);
NOHUD
if (!thing)
@ -915,7 +908,7 @@ static int lib_pMove(lua_State *L)
{
mobj_t *ptmthing = tmthing;
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t speed = (fixed_t)luaL_checkinteger(L, 2);
fixed_t speed = luaL_checkfixed(L, 2);
NOHUD
if (!actor)
return LUA_ErrInvalid(L, "mobj_t");
@ -929,9 +922,9 @@ static int lib_pTeleportMove(lua_State *L)
{
mobj_t *ptmthing = tmthing;
mobj_t *thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t x = (fixed_t)luaL_checkinteger(L, 2);
fixed_t y = (fixed_t)luaL_checkinteger(L, 3);
fixed_t z = (fixed_t)luaL_checkinteger(L, 4);
fixed_t x = luaL_checkfixed(L, 2);
fixed_t y = luaL_checkfixed(L, 3);
fixed_t z = luaL_checkfixed(L, 4);
NOHUD
if (!thing)
return LUA_ErrInvalid(L, "mobj_t");
@ -975,10 +968,10 @@ static int lib_pCheckSight(lua_State *L)
static int lib_pCheckHoopPosition(lua_State *L)
{
mobj_t *hoopthing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t x = (fixed_t)luaL_checkinteger(L, 2);
fixed_t y = (fixed_t)luaL_checkinteger(L, 3);
fixed_t z = (fixed_t)luaL_checkinteger(L, 4);
fixed_t radius = (fixed_t)luaL_checkinteger(L, 5);
fixed_t x = luaL_checkfixed(L, 2);
fixed_t y = luaL_checkfixed(L, 3);
fixed_t z = luaL_checkfixed(L, 4);
fixed_t radius = luaL_checkfixed(L, 5);
NOHUD
if (!hoopthing)
return LUA_ErrInvalid(L, "mobj_t");
@ -990,7 +983,7 @@ static int lib_pRadiusAttack(lua_State *L)
{
mobj_t *spot = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobj_t *source = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
fixed_t damagedist = (fixed_t)luaL_checkinteger(L, 3);
fixed_t damagedist = luaL_checkfixed(L, 3);
NOHUD
if (!spot || !source)
return LUA_ErrInvalid(L, "mobj_t");
@ -1000,12 +993,12 @@ static int lib_pRadiusAttack(lua_State *L)
static int lib_pFloorzAtPos(lua_State *L)
{
fixed_t x = (fixed_t)luaL_checkinteger(L, 1);
fixed_t y = (fixed_t)luaL_checkinteger(L, 2);
fixed_t z = (fixed_t)luaL_checkinteger(L, 3);
fixed_t height = (fixed_t)luaL_checkinteger(L, 4);
fixed_t x = luaL_checkfixed(L, 1);
fixed_t y = luaL_checkfixed(L, 2);
fixed_t z = luaL_checkfixed(L, 3);
fixed_t height = luaL_checkfixed(L, 4);
//HUDSAFE
lua_pushinteger(L, P_FloorzAtPos(x, y, z, height));
lua_pushfixed(L, P_FloorzAtPos(x, y, z, height));
return 1;
}
@ -1016,8 +1009,8 @@ static int lib_pDoSpring(lua_State *L)
NOHUD
if (!spring || !object)
return LUA_ErrInvalid(L, "mobj_t");
P_DoSpring(spring, object);
return 0;
lua_pushboolean(L, P_DoSpring(spring, object));
return 1;
}
// P_INTER
@ -1209,8 +1202,8 @@ static int lib_pDoNightsScore(lua_State *L)
static int lib_pThrust(lua_State *L)
{
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
angle_t angle = (angle_t)luaL_checkinteger(L, 2);
fixed_t move = (fixed_t)luaL_checkinteger(L, 3);
angle_t angle = luaL_checkangle(L, 2);
fixed_t move = luaL_checkfixed(L, 3);
NOHUD
if (!mo)
return LUA_ErrInvalid(L, "mobj_t");
@ -1485,48 +1478,48 @@ static int lib_evCrumbleChain(lua_State *L)
static int lib_rPointToAngle(lua_State *L)
{
fixed_t x = (fixed_t)luaL_checkinteger(L, 1);
fixed_t y = (fixed_t)luaL_checkinteger(L, 2);
fixed_t x = luaL_checkfixed(L, 1);
fixed_t y = luaL_checkfixed(L, 2);
//HUDSAFE
lua_pushinteger(L, R_PointToAngle(x, y));
lua_pushangle(L, R_PointToAngle(x, y));
return 1;
}
static int lib_rPointToAngle2(lua_State *L)
{
fixed_t px2 = (fixed_t)luaL_checkinteger(L, 1);
fixed_t py2 = (fixed_t)luaL_checkinteger(L, 2);
fixed_t px1 = (fixed_t)luaL_checkinteger(L, 3);
fixed_t py1 = (fixed_t)luaL_checkinteger(L, 4);
fixed_t px2 = luaL_checkfixed(L, 1);
fixed_t py2 = luaL_checkfixed(L, 2);
fixed_t px1 = luaL_checkfixed(L, 3);
fixed_t py1 = luaL_checkfixed(L, 4);
//HUDSAFE
lua_pushinteger(L, R_PointToAngle2(px2, py2, px1, py1));
lua_pushangle(L, R_PointToAngle2(px2, py2, px1, py1));
return 1;
}
static int lib_rPointToDist(lua_State *L)
{
fixed_t x = (fixed_t)luaL_checkinteger(L, 1);
fixed_t y = (fixed_t)luaL_checkinteger(L, 2);
fixed_t x = luaL_checkfixed(L, 1);
fixed_t y = luaL_checkfixed(L, 2);
//HUDSAFE
lua_pushinteger(L, R_PointToDist(x, y));
lua_pushfixed(L, R_PointToDist(x, y));
return 1;
}
static int lib_rPointToDist2(lua_State *L)
{
fixed_t px2 = (fixed_t)luaL_checkinteger(L, 1);
fixed_t py2 = (fixed_t)luaL_checkinteger(L, 2);
fixed_t px1 = (fixed_t)luaL_checkinteger(L, 3);
fixed_t py1 = (fixed_t)luaL_checkinteger(L, 4);
fixed_t px2 = luaL_checkfixed(L, 1);
fixed_t py2 = luaL_checkfixed(L, 2);
fixed_t px1 = luaL_checkfixed(L, 3);
fixed_t py1 = luaL_checkfixed(L, 4);
//HUDSAFE
lua_pushinteger(L, R_PointToDist2(px2, py2, px1, py1));
lua_pushfixed(L, R_PointToDist2(px2, py2, px1, py1));
return 1;
}
static int lib_rPointInSubsector(lua_State *L)
{
fixed_t x = (fixed_t)luaL_checkinteger(L, 1);
fixed_t y = (fixed_t)luaL_checkinteger(L, 2);
fixed_t x = luaL_checkfixed(L, 1);
fixed_t y = luaL_checkfixed(L, 2);
//HUDSAFE
LUA_PushUserdata(L, R_PointInSubsector(x, y), META_SUBSECTOR);
return 1;
@ -1660,7 +1653,7 @@ static int lib_sChangeMusic(lua_State *L)
static int lib_sSpeedMusic(lua_State *L)
{
fixed_t fixedspeed = (fixed_t)luaL_checkinteger(L, 1);
fixed_t fixedspeed = luaL_checkfixed(L, 1);
float speed = FIXED_TO_FLOAT(fixedspeed);
player_t *player = NULL;
NOHUD
@ -1861,7 +1854,6 @@ static int lib_gTicsToMilliseconds(lua_State *L)
static luaL_Reg lib[] = {
{"print", lib_print},
{"EvalMath", lib_evalMath},
// m_random
{"P_Random",lib_pRandom},

View File

@ -41,7 +41,7 @@ enum hook {
hook_BotAI,
hook_LinedefExecute,
hook_PlayerMsg,
hook_DeathMsg,
hook_HurtMsg,
hook_MAX // last hook
};
@ -54,8 +54,9 @@ void LUAh_ThinkFrame(void); // Hook for frame (after mobj and player thinkers)
boolean LUAh_MobjHook(mobj_t *mo, enum hook which);
boolean LUAh_PlayerHook(player_t *plr, enum hook which);
#define LUAh_MobjSpawn(mo) LUAh_MobjHook(mo, hook_MobjSpawn) // Hook for P_SpawnMobj by mobj type
UINT8 LUAh_MobjCollide(mobj_t *thing1, mobj_t *thing2); // Hook for PIT_CheckThing by (thing) mobj type
UINT8 LUAh_MobjMoveCollide(mobj_t *thing1, mobj_t *thing2); // Hook for PIT_CheckThing by (tmthing) mobj type
UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which);
#define LUAh_MobjCollide(thing1, thing2) LUAh_MobjCollideHook(thing1, thing2, hook_MobjCollide) // Hook for PIT_CheckThing by (thing) mobj type
#define LUAh_MobjMoveCollide(thing1, thing2) LUAh_MobjCollideHook(thing1, thing2, hook_MobjMoveCollide) // Hook for PIT_CheckThing by (tmthing) mobj type
boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher); // Hook for P_TouchSpecialThing by mobj type
#define LUAh_MobjFuse(mo) LUAh_MobjHook(mo, hook_MobjFuse) // Hook for mobj->fuse == 0 by mobj type
#define LUAh_MobjThinker(mo) LUAh_MobjHook(mo, hook_MobjThinker) // Hook for P_MobjThinker or P_SceneryThinker by mobj type
@ -73,6 +74,6 @@ boolean LUAh_BotTiccmd(player_t *bot, ticcmd_t *cmd); // Hook for B_BuildTiccmd
boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd); // Hook for B_BuildTailsTiccmd by skin name
boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector); // Hook for linedef executors
boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg); // Hook for chat messages
boolean LUAh_DeathMsg(player_t *player, mobj_t *inflictor, mobj_t *source); // Hook for hurt messages
boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source); // Hook for hurt messages
#endif

File diff suppressed because it is too large Load Diff

View File

@ -674,8 +674,6 @@ void LUAh_GameHUD(player_t *stplayr)
LUA_Call(gL, 3);
}
lua_pop(gL, -1);
lua_gc(gL, LUA_GCCOLLECT, 0);
hud_running = false;
}
@ -701,8 +699,6 @@ void LUAh_ScoresHUD(void)
LUA_Call(gL, 1);
}
lua_pop(gL, -1);
lua_gc(gL, LUA_GCCOLLECT, 0);
hud_running = false;
}

View File

@ -137,8 +137,6 @@ static void A_Lua(mobj_t *actor)
--superstack;
superactions[superstack] = NULL;
}
lua_gc(gL, LUA_GCSTEP, 1);
}
// Arbitrary states[] table index -> state_t *
@ -510,11 +508,11 @@ static int lib_setMobjInfo(lua_State *L)
else if (i == 15 || (str && fastcmp(str,"deathsound")))
info->deathsound = luaL_checkinteger(L, 3);
else if (i == 16 || (str && fastcmp(str,"speed")))
info->speed = (fixed_t)luaL_checkinteger(L, 3);
info->speed = luaL_checkfixed(L, 3);
else if (i == 17 || (str && fastcmp(str,"radius")))
info->radius = (fixed_t)luaL_checkinteger(L, 3);
info->radius = luaL_checkfixed(L, 3);
else if (i == 18 || (str && fastcmp(str,"height")))
info->height = (fixed_t)luaL_checkinteger(L, 3);
info->height = luaL_checkfixed(L, 3);
else if (i == 19 || (str && fastcmp(str,"dispoffset")))
info->dispoffset = (INT32)luaL_checkinteger(L, 3);
else if (i == 20 || (str && fastcmp(str,"mass")))
@ -580,11 +578,11 @@ static int mobjinfo_get(lua_State *L)
else if (fastcmp(field,"deathsound"))
lua_pushinteger(L, info->deathsound);
else if (fastcmp(field,"speed"))
lua_pushinteger(L, info->speed);
lua_pushinteger(L, info->speed); // sometimes it's fixed_t, sometimes it's not...
else if (fastcmp(field,"radius"))
lua_pushinteger(L, info->radius);
lua_pushfixed(L, info->radius);
else if (fastcmp(field,"height"))
lua_pushinteger(L, info->height);
lua_pushfixed(L, info->height);
else if (fastcmp(field,"dispoffset"))
lua_pushinteger(L, info->dispoffset);
else if (fastcmp(field,"mass"))
@ -656,11 +654,11 @@ static int mobjinfo_set(lua_State *L)
else if (fastcmp(field,"deathsound"))
info->deathsound = luaL_checkinteger(L, 3);
else if (fastcmp(field,"speed"))
info->speed = (fixed_t)luaL_checkinteger(L, 3);
info->speed = luaL_checkfixed(L, 3);
else if (fastcmp(field,"radius"))
info->radius = (fixed_t)luaL_checkinteger(L, 3);
info->radius = luaL_checkfixed(L, 3);
else if (fastcmp(field,"height"))
info->height = (fixed_t)luaL_checkinteger(L, 3);
info->height = luaL_checkfixed(L, 3);
else if (fastcmp(field,"dispoffset"))
info->dispoffset = (INT32)luaL_checkinteger(L, 3);
else if (fastcmp(field,"mass"))

View File

@ -325,10 +325,10 @@ static int sector_get(lua_State *L)
lua_pushboolean(L, 1);
return 1;
case sector_floorheight:
lua_pushinteger(L, sector->floorheight);
lua_pushfixed(L, sector->floorheight);
return 1;
case sector_ceilingheight:
lua_pushinteger(L, sector->ceilingheight);
lua_pushfixed(L, sector->ceilingheight);
return 1;
case sector_floorpic: { // floorpic
levelflat_t *levelflat;
@ -444,26 +444,30 @@ static int sector_set(lua_State *L)
return luaL_error(L, "sector_t field " LUA_QS " cannot be set.", sector_opt[field]);
case sector_floorheight: { // floorheight
boolean flag;
mobj_t *ptmthing = tmthing;
fixed_t lastpos = sector->floorheight;
sector->floorheight = (fixed_t)luaL_checkinteger(L, 3);
sector->floorheight = luaL_checkfixed(L, 3);
flag = P_CheckSector(sector, true);
if (flag && sector->numattached)
{
sector->floorheight = lastpos;
P_CheckSector(sector, true);
}
P_SetTarget(&tmthing, ptmthing);
break;
}
case sector_ceilingheight: { // ceilingheight
boolean flag;
mobj_t *ptmthing = tmthing;
fixed_t lastpos = sector->ceilingheight;
sector->ceilingheight = (fixed_t)luaL_checkinteger(L, 3);
sector->ceilingheight = luaL_checkfixed(L, 3);
flag = P_CheckSector(sector, true);
if (flag && sector->numattached)
{
sector->ceilingheight = lastpos;
P_CheckSector(sector, true);
}
P_SetTarget(&tmthing, ptmthing);
break;
}
case sector_floorpic:
@ -557,10 +561,10 @@ static int line_get(lua_State *L)
LUA_PushUserdata(L, line->v2, META_VERTEX);
return 1;
case line_dx:
lua_pushinteger(L, line->dx);
lua_pushfixed(L, line->dx);
return 1;
case line_dy:
lua_pushinteger(L, line->dy);
lua_pushfixed(L, line->dy);
return 1;
case line_flags:
lua_pushinteger(L, line->flags);
@ -676,10 +680,10 @@ static int side_get(lua_State *L)
lua_pushboolean(L, 1);
return 1;
case side_textureoffset:
lua_pushinteger(L, side->textureoffset);
lua_pushfixed(L, side->textureoffset);
return 1;
case side_rowoffset:
lua_pushinteger(L, side->rowoffset);
lua_pushfixed(L, side->rowoffset);
return 1;
case side_toptexture:
lua_pushinteger(L, side->toptexture);
@ -706,6 +710,50 @@ static int side_get(lua_State *L)
return 0;
}
static int side_set(lua_State *L)
{
side_t *side = *((side_t **)luaL_checkudata(L, 1, META_SIDE));
enum side_e field = luaL_checkoption(L, 2, side_opt[0], side_opt);
if (!side)
{
if (field == side_valid) {
lua_pushboolean(L, 0);
return 1;
}
return luaL_error(L, "accessed side_t doesn't exist anymore.");
}
switch(field)
{
case side_valid: // valid
case side_sector:
case side_special:
case side_text:
default:
return luaL_error(L, "side_t field " LUA_QS " cannot be set.", side_opt[field]);
case side_textureoffset:
side->textureoffset = luaL_checkfixed(L, 3);
break;
case side_rowoffset:
side->rowoffset = luaL_checkfixed(L, 3);
break;
case side_toptexture:
side->toptexture = luaL_checkinteger(L, 3);
break;
case side_bottomtexture:
side->bottomtexture = luaL_checkinteger(L, 3);
break;
case side_midtexture:
side->midtexture = luaL_checkinteger(L, 3);
break;
case side_repeatcnt:
side->repeatcnt = luaL_checkinteger(L, 3);
break;
}
return 0;
}
static int side_num(lua_State *L)
{
side_t *side = *((side_t **)luaL_checkudata(L, 1, META_SIDE));
@ -733,13 +781,13 @@ static int vertex_get(lua_State *L)
lua_pushboolean(L, 1);
return 1;
case vertex_x:
lua_pushinteger(L, vertex->x);
lua_pushfixed(L, vertex->x);
return 1;
case vertex_y:
lua_pushinteger(L, vertex->y);
lua_pushfixed(L, vertex->y);
return 1;
case vertex_z:
lua_pushinteger(L, vertex->z);
lua_pushfixed(L, vertex->z);
return 1;
}
return 0;
@ -1002,7 +1050,7 @@ static int ffloor_get(lua_State *L)
lua_pushboolean(L, 1);
return 1;
case ffloor_topheight:
lua_pushinteger(L, *ffloor->topheight);
lua_pushfixed(L, *ffloor->topheight);
return 1;
case ffloor_toppic: { // toppic
levelflat_t *levelflat;
@ -1016,7 +1064,7 @@ static int ffloor_get(lua_State *L)
lua_pushinteger(L, *ffloor->toplightlevel);
return 1;
case ffloor_bottomheight:
lua_pushinteger(L, *ffloor->bottomheight);
lua_pushfixed(L, *ffloor->bottomheight);
return 1;
case ffloor_bottompic: { // bottompic
levelflat_t *levelflat;
@ -1075,14 +1123,16 @@ static int ffloor_set(lua_State *L)
case ffloor_topheight: { // topheight
boolean flag;
fixed_t lastpos = *ffloor->topheight;
mobj_t *ptmthing = tmthing;
sector_t *sector = &sectors[ffloor->secnum];
sector->ceilingheight = (fixed_t)luaL_checkinteger(L, 3);
sector->ceilingheight = luaL_checkfixed(L, 3);
flag = P_CheckSector(sector, true);
if (flag && sector->numattached)
{
*ffloor->topheight = lastpos;
P_CheckSector(sector, true);
}
P_SetTarget(&tmthing, ptmthing);
break;
}
case ffloor_toppic:
@ -1094,14 +1144,16 @@ static int ffloor_set(lua_State *L)
case ffloor_bottomheight: { // bottomheight
boolean flag;
fixed_t lastpos = *ffloor->bottomheight;
mobj_t *ptmthing = tmthing;
sector_t *sector = &sectors[ffloor->secnum];
sector->floorheight = (fixed_t)luaL_checkinteger(L, 3);
sector->floorheight = luaL_checkfixed(L, 3);
flag = P_CheckSector(sector, true);
if (flag && sector->numattached)
{
*ffloor->bottomheight = lastpos;
P_CheckSector(sector, true);
}
P_SetTarget(&tmthing, ptmthing);
break;
}
case ffloor_bottompic:
@ -1267,6 +1319,9 @@ int LUA_MapLib(lua_State *L)
lua_pushcfunction(L, side_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, side_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, side_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);

View File

@ -47,37 +47,39 @@ static int lib_max(lua_State *L)
static int lib_fixedangle(lua_State *L)
{
lua_pushinteger(L, FixedAngle((fixed_t)luaL_checkinteger(L, 1)));
lua_pushangle(L, FixedAngle(luaL_checkfixed(L, 1)));
return 1;
}
static int lib_anglefixed(lua_State *L)
{
lua_pushinteger(L, AngleFixed((angle_t)luaL_checkinteger(L, 1)));
lua_pushfixed(L, AngleFixed(luaL_checkangle(L, 1)));
return 1;
}
static int lib_invangle(lua_State *L)
{
lua_pushinteger(L, InvAngle((angle_t)luaL_checkinteger(L, 1)));
lua_pushangle(L, InvAngle(luaL_checkangle(L, 1)));
return 1;
}
static int lib_finesine(lua_State *L)
{
lua_pushinteger(L, FINESINE((luaL_checkinteger(L, 1)>>ANGLETOFINESHIFT) & FINEMASK));
lua_pushfixed(L, FINESINE((luaL_checkangle(L, 1)>>ANGLETOFINESHIFT) & FINEMASK));
return 1;
}
static int lib_finecosine(lua_State *L)
{
lua_pushinteger(L, FINECOSINE((luaL_checkinteger(L, 1)>>ANGLETOFINESHIFT) & FINEMASK));
lua_pushfixed(L, FINECOSINE((luaL_checkangle(L, 1)>>ANGLETOFINESHIFT) & FINEMASK));
return 1;
}
static int lib_finetangent(lua_State *L)
{
lua_pushinteger(L, FINETANGENT((luaL_checkinteger(L, 1)>>ANGLETOFINESHIFT) & FINEMASK));
// HACK: add ANGLE_90 to make tan() in Lua start at 0 like it should
// use & 4095 instead of & FINEMASK (8191), so it doesn't go out of the array's bounds
lua_pushfixed(L, FINETANGENT(((luaL_checkangle(L, 1)+ANGLE_90)>>ANGLETOFINESHIFT) & 4095));
return 1;
}
@ -86,61 +88,61 @@ static int lib_finetangent(lua_State *L)
static int lib_fixedmul(lua_State *L)
{
lua_pushinteger(L, FixedMul((fixed_t)luaL_checkinteger(L, 1), (fixed_t)luaL_checkinteger(L, 2)));
lua_pushfixed(L, FixedMul(luaL_checkfixed(L, 1), luaL_checkfixed(L, 2)));
return 1;
}
static int lib_fixedint(lua_State *L)
{
lua_pushinteger(L, FixedInt((fixed_t)luaL_checkinteger(L, 1)));
lua_pushinteger(L, FixedInt(luaL_checkfixed(L, 1)));
return 1;
}
static int lib_fixeddiv(lua_State *L)
{
lua_pushinteger(L, FixedDiv((fixed_t)luaL_checkinteger(L, 1), (fixed_t)luaL_checkinteger(L, 2)));
lua_pushfixed(L, FixedDiv(luaL_checkfixed(L, 1), luaL_checkfixed(L, 2)));
return 1;
}
static int lib_fixedrem(lua_State *L)
{
lua_pushinteger(L, FixedRem((fixed_t)luaL_checkinteger(L, 1), (fixed_t)luaL_checkinteger(L, 2)));
lua_pushfixed(L, FixedRem(luaL_checkfixed(L, 1), luaL_checkfixed(L, 2)));
return 1;
}
static int lib_fixedsqrt(lua_State *L)
{
lua_pushinteger(L, FixedSqrt((fixed_t)luaL_checkinteger(L, 1)));
lua_pushfixed(L, FixedSqrt(luaL_checkfixed(L, 1)));
return 1;
}
static int lib_fixedhypot(lua_State *L)
{
lua_pushinteger(L, FixedHypot((fixed_t)luaL_checkinteger(L, 1), (fixed_t)luaL_checkinteger(L, 2)));
lua_pushfixed(L, FixedHypot(luaL_checkfixed(L, 1), luaL_checkfixed(L, 2)));
return 1;
}
static int lib_fixedfloor(lua_State *L)
{
lua_pushinteger(L, FixedFloor((fixed_t)luaL_checkinteger(L, 1)));
lua_pushfixed(L, FixedFloor(luaL_checkfixed(L, 1)));
return 1;
}
static int lib_fixedtrunc(lua_State *L)
{
lua_pushinteger(L, FixedTrunc((fixed_t)luaL_checkinteger(L, 1)));
lua_pushfixed(L, FixedTrunc(luaL_checkfixed(L, 1)));
return 1;
}
static int lib_fixedceil(lua_State *L)
{
lua_pushinteger(L, FixedCeil((fixed_t)luaL_checkinteger(L, 1)));
lua_pushfixed(L, FixedCeil(luaL_checkfixed(L, 1)));
return 1;
}
static int lib_fixedround(lua_State *L)
{
lua_pushinteger(L, FixedRound((fixed_t)luaL_checkinteger(L, 1)));
lua_pushfixed(L, FixedRound(luaL_checkfixed(L, 1)));
return 1;
}
@ -156,7 +158,7 @@ static int lib_getsecspecial(lua_State *L)
static int lib_all7emeralds(lua_State *L)
{
lua_pushinteger(L, ALL7EMERALDS(luaL_checkinteger(L, 1)));
lua_pushboolean(L, ALL7EMERALDS(luaL_checkinteger(L, 1)));
return 1;
}

View File

@ -162,13 +162,13 @@ static int mobj_get(lua_State *L)
lua_pushboolean(L, 1);
break;
case mobj_x:
lua_pushinteger(L, mo->x);
lua_pushfixed(L, mo->x);
break;
case mobj_y:
lua_pushinteger(L, mo->y);
lua_pushfixed(L, mo->y);
break;
case mobj_z:
lua_pushinteger(L, mo->z);
lua_pushfixed(L, mo->z);
break;
case mobj_snext:
LUA_PushUserdata(L, mo->snext, META_MOBJ);
@ -179,7 +179,7 @@ static int mobj_get(lua_State *L)
// i.e. it will always ultimately point to THIS mobj -- so that's actually not useful to Lua and won't be included.
return UNIMPLEMENTED;
case mobj_angle:
lua_pushinteger(L, mo->angle);
lua_pushangle(L, mo->angle);
break;
case mobj_sprite:
lua_pushinteger(L, mo->sprite);
@ -193,28 +193,28 @@ static int mobj_get(lua_State *L)
LUA_PushUserdata(L, mo->subsector, META_SUBSECTOR);
break;
case mobj_floorz:
lua_pushinteger(L, mo->floorz);
lua_pushfixed(L, mo->floorz);
break;
case mobj_ceilingz:
lua_pushinteger(L, mo->ceilingz);
lua_pushfixed(L, mo->ceilingz);
break;
case mobj_radius:
lua_pushinteger(L, mo->radius);
lua_pushfixed(L, mo->radius);
break;
case mobj_height:
lua_pushinteger(L, mo->height);
lua_pushfixed(L, mo->height);
break;
case mobj_momx:
lua_pushinteger(L, mo->momx);
lua_pushfixed(L, mo->momx);
break;
case mobj_momy:
lua_pushinteger(L, mo->momy);
lua_pushfixed(L, mo->momy);
break;
case mobj_momz:
lua_pushinteger(L, mo->momz);
lua_pushfixed(L, mo->momz);
break;
case mobj_pmomz:
lua_pushinteger(L, mo->pmomz);
lua_pushfixed(L, mo->pmomz);
break;
case mobj_tics:
lua_pushinteger(L, mo->tics);
@ -299,32 +299,32 @@ static int mobj_get(lua_State *L)
LUA_PushUserdata(L, mo->tracer, META_MOBJ);
break;
case mobj_friction:
lua_pushinteger(L, mo->friction);
lua_pushfixed(L, mo->friction);
break;
case mobj_movefactor:
lua_pushinteger(L, mo->movefactor);
lua_pushfixed(L, mo->movefactor);
break;
case mobj_fuse:
lua_pushinteger(L, mo->fuse);
break;
case mobj_watertop:
lua_pushinteger(L, mo->watertop);
lua_pushfixed(L, mo->watertop);
break;
case mobj_waterbottom:
lua_pushinteger(L, mo->waterbottom);
lua_pushfixed(L, mo->waterbottom);
break;
case mobj_mobjnum:
// mobjnum is a networking thing generated for $$$.sav
// and therefore shouldn't be used by Lua.
return UNIMPLEMENTED;
case mobj_scale:
lua_pushinteger(L, mo->scale);
lua_pushfixed(L, mo->scale);
break;
case mobj_destscale:
lua_pushinteger(L, mo->destscale);
lua_pushfixed(L, mo->destscale);
break;
case mobj_scalespeed:
lua_pushinteger(L, mo->scalespeed);
lua_pushfixed(L, mo->scalespeed);
break;
case mobj_extravalue1:
lua_pushinteger(L, mo->extravalue1);
@ -382,7 +382,7 @@ static int mobj_set(lua_State *L)
{
// z doesn't cross sector bounds so it's okay.
mobj_t *ptmthing = tmthing;
mo->z = (fixed_t)luaL_checkinteger(L, 3);
mo->z = luaL_checkfixed(L, 3);
P_CheckPosition(mo, mo->x, mo->y);
mo->floorz = tmfloorz;
mo->ceilingz = tmceilingz;
@ -394,7 +394,7 @@ static int mobj_set(lua_State *L)
case mobj_sprev:
return UNIMPLEMENTED;
case mobj_angle:
mo->angle = (angle_t)luaL_checkinteger(L, 3);
mo->angle = luaL_checkangle(L, 3);
if (mo->player == &players[consoleplayer])
localangle = mo->angle;
else if (mo->player == &players[secondarydisplayplayer])
@ -417,7 +417,7 @@ static int mobj_set(lua_State *L)
case mobj_radius:
{
mobj_t *ptmthing = tmthing;
mo->radius = (fixed_t)luaL_checkinteger(L, 3);
mo->radius = luaL_checkfixed(L, 3);
if (mo->radius < 0)
mo->radius = 0;
P_CheckPosition(mo, mo->x, mo->y);
@ -429,7 +429,7 @@ static int mobj_set(lua_State *L)
case mobj_height:
{
mobj_t *ptmthing = tmthing;
mo->height = (fixed_t)luaL_checkinteger(L, 3);
mo->height = luaL_checkfixed(L, 3);
if (mo->height < 0)
mo->height = 0;
P_CheckPosition(mo, mo->x, mo->y);
@ -439,16 +439,17 @@ static int mobj_set(lua_State *L)
break;
}
case mobj_momx:
mo->momx = (fixed_t)luaL_checkinteger(L, 3);
mo->momx = luaL_checkfixed(L, 3);
break;
case mobj_momy:
mo->momy = (fixed_t)luaL_checkinteger(L, 3);
mo->momy = luaL_checkfixed(L, 3);
break;
case mobj_momz:
mo->momz = (fixed_t)luaL_checkinteger(L, 3);
mo->momz = luaL_checkfixed(L, 3);
break;
case mobj_pmomz:
mo->pmomz = (fixed_t)luaL_checkinteger(L, 3);
mo->pmomz = luaL_checkfixed(L, 3);
mo->eflags |= MFE_APPLYPMOMZ;
break;
case mobj_tics:
mo->tics = luaL_checkinteger(L, 3);
@ -572,25 +573,25 @@ static int mobj_set(lua_State *L)
}
break;
case mobj_friction:
mo->friction = (fixed_t)luaL_checkinteger(L, 3);
mo->friction = luaL_checkfixed(L, 3);
break;
case mobj_movefactor:
mo->movefactor = (fixed_t)luaL_checkinteger(L, 3);
mo->movefactor = luaL_checkfixed(L, 3);
break;
case mobj_fuse:
mo->fuse = luaL_checkinteger(L, 3);
break;
case mobj_watertop:
mo->watertop = (fixed_t)luaL_checkinteger(L, 3);
mo->watertop = luaL_checkfixed(L, 3);
break;
case mobj_waterbottom:
mo->waterbottom = (fixed_t)luaL_checkinteger(L, 3);
mo->waterbottom = luaL_checkfixed(L, 3);
break;
case mobj_mobjnum:
return UNIMPLEMENTED;
case mobj_scale:
{
fixed_t scale = (fixed_t)luaL_checkinteger(L, 3);
fixed_t scale = luaL_checkfixed(L, 3);
if (scale < FRACUNIT/100)
scale = FRACUNIT/100;
mo->destscale = scale;
@ -599,14 +600,14 @@ static int mobj_set(lua_State *L)
}
case mobj_destscale:
{
fixed_t scale = (fixed_t)luaL_checkinteger(L, 3);
fixed_t scale = luaL_checkfixed(L, 3);
if (scale < FRACUNIT/100)
scale = FRACUNIT/100;
mo->destscale = scale;
break;
}
case mobj_scalespeed:
mo->scalespeed = (fixed_t)luaL_checkinteger(L, 3);
mo->scalespeed = luaL_checkfixed(L, 3);
break;
case mobj_extravalue1:
mo->extravalue1 = luaL_checkinteger(L, 3);

View File

@ -109,15 +109,15 @@ static int player_get(lua_State *L)
else if (fastcmp(field,"playerstate"))
lua_pushinteger(L, plr->playerstate);
else if (fastcmp(field,"viewz"))
lua_pushinteger(L, plr->viewz);
lua_pushfixed(L, plr->viewz);
else if (fastcmp(field,"viewheight"))
lua_pushinteger(L, plr->viewheight);
lua_pushfixed(L, plr->viewheight);
else if (fastcmp(field,"deltaviewheight"))
lua_pushinteger(L, plr->deltaviewheight);
lua_pushfixed(L, plr->deltaviewheight);
else if (fastcmp(field,"bob"))
lua_pushinteger(L, plr->bob);
lua_pushfixed(L, plr->bob);
else if (fastcmp(field,"aiming"))
lua_pushinteger(L, plr->aiming);
lua_pushangle(L, plr->aiming);
else if (fastcmp(field,"health"))
lua_pushinteger(L, plr->health);
else if (fastcmp(field,"pity"))
@ -141,13 +141,13 @@ static int player_get(lua_State *L)
else if (fastcmp(field,"score"))
lua_pushinteger(L, plr->score);
else if (fastcmp(field,"dashspeed"))
lua_pushinteger(L, plr->dashspeed);
lua_pushfixed(L, plr->dashspeed);
else if (fastcmp(field,"dashtime"))
lua_pushinteger(L, plr->dashtime);
else if (fastcmp(field,"normalspeed"))
lua_pushinteger(L, plr->normalspeed);
lua_pushfixed(L, plr->normalspeed);
else if (fastcmp(field,"runspeed"))
lua_pushinteger(L, plr->runspeed);
lua_pushfixed(L, plr->runspeed);
else if (fastcmp(field,"thrustfactor"))
lua_pushinteger(L, plr->thrustfactor);
else if (fastcmp(field,"accelstart"))
@ -167,13 +167,13 @@ static int player_get(lua_State *L)
else if (fastcmp(field,"revitem"))
lua_pushinteger(L, plr->revitem);
else if (fastcmp(field,"actionspd"))
lua_pushinteger(L, plr->actionspd);
lua_pushfixed(L, plr->actionspd);
else if (fastcmp(field,"mindash"))
lua_pushinteger(L, plr->mindash);
lua_pushfixed(L, plr->mindash);
else if (fastcmp(field,"maxdash"))
lua_pushinteger(L, plr->maxdash);
lua_pushfixed(L, plr->maxdash);
else if (fastcmp(field,"jumpfactor"))
lua_pushinteger(L, plr->jumpfactor);
lua_pushfixed(L, plr->jumpfactor);
else if (fastcmp(field,"lives"))
lua_pushinteger(L, plr->lives);
else if (fastcmp(field,"continues"))
@ -183,7 +183,7 @@ static int player_get(lua_State *L)
else if (fastcmp(field,"gotcontinue"))
lua_pushinteger(L, plr->gotcontinue);
else if (fastcmp(field,"speed"))
lua_pushinteger(L, plr->speed);
lua_pushfixed(L, plr->speed);
else if (fastcmp(field,"jumping"))
lua_pushboolean(L, plr->jumping);
else if (fastcmp(field,"secondjump"))
@ -205,13 +205,13 @@ static int player_get(lua_State *L)
else if (fastcmp(field,"skidtime"))
lua_pushinteger(L, plr->skidtime);
else if (fastcmp(field,"cmomx"))
lua_pushinteger(L, plr->cmomx);
lua_pushfixed(L, plr->cmomx);
else if (fastcmp(field,"cmomy"))
lua_pushinteger(L, plr->cmomy);
lua_pushfixed(L, plr->cmomy);
else if (fastcmp(field,"rmomx"))
lua_pushinteger(L, plr->rmomx);
lua_pushfixed(L, plr->rmomx);
else if (fastcmp(field,"rmomy"))
lua_pushinteger(L, plr->rmomy);
lua_pushfixed(L, plr->rmomy);
else if (fastcmp(field,"numboxes"))
lua_pushinteger(L, plr->numboxes);
else if (fastcmp(field,"totalring"))
@ -239,11 +239,11 @@ static int player_get(lua_State *L)
else if (fastcmp(field,"starposttime"))
lua_pushinteger(L, plr->starposttime);
else if (fastcmp(field,"starpostangle"))
lua_pushinteger(L, plr->starpostangle);
lua_pushangle(L, plr->starpostangle);
else if (fastcmp(field,"angle_pos"))
lua_pushinteger(L, plr->angle_pos);
lua_pushangle(L, plr->angle_pos);
else if (fastcmp(field,"old_angle_pos"))
lua_pushinteger(L, plr->old_angle_pos);
lua_pushangle(L, plr->old_angle_pos);
else if (fastcmp(field,"axis1"))
LUA_PushUserdata(L, plr->axis1, META_MOBJ);
else if (fastcmp(field,"axis2"))
@ -305,16 +305,16 @@ static int player_get(lua_State *L)
else if (fastcmp(field,"awayviewtics"))
lua_pushinteger(L, plr->awayviewtics);
else if (fastcmp(field,"awayviewaiming"))
lua_pushinteger(L, plr->awayviewaiming);
lua_pushangle(L, plr->awayviewaiming);
else if (fastcmp(field,"spectator"))
lua_pushinteger(L, plr->spectator);
lua_pushboolean(L, plr->spectator);
else if (fastcmp(field,"bot"))
lua_pushinteger(L, plr->bot);
else if (fastcmp(field,"jointime"))
lua_pushinteger(L, plr->jointime);
#ifdef HWRENDER
else if (fastcmp(field,"fovadd"))
lua_pushinteger(L, plr->fovadd);
lua_pushfixed(L, plr->fovadd);
#endif
else {
lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS);
@ -354,15 +354,15 @@ static int player_set(lua_State *L)
else if (fastcmp(field,"playerstate"))
plr->playerstate = luaL_checkinteger(L, 3);
else if (fastcmp(field,"viewz"))
plr->viewz = (fixed_t)luaL_checkinteger(L, 3);
plr->viewz = luaL_checkfixed(L, 3);
else if (fastcmp(field,"viewheight"))
plr->viewheight = (fixed_t)luaL_checkinteger(L, 3);
plr->viewheight = luaL_checkfixed(L, 3);
else if (fastcmp(field,"deltaviewheight"))
plr->deltaviewheight = (fixed_t)luaL_checkinteger(L, 3);
plr->deltaviewheight = luaL_checkfixed(L, 3);
else if (fastcmp(field,"bob"))
plr->bob = (fixed_t)luaL_checkinteger(L, 3);
plr->bob = luaL_checkfixed(L, 3);
else if (fastcmp(field,"aiming")) {
plr->aiming = (angle_t)luaL_checkinteger(L, 3);
plr->aiming = luaL_checkangle(L, 3);
if (plr == &players[consoleplayer])
localaiming = plr->aiming;
else if (plr == &players[secondarydisplayplayer])
@ -391,13 +391,13 @@ static int player_set(lua_State *L)
else if (fastcmp(field,"score"))
plr->score = (UINT32)luaL_checkinteger(L, 3);
else if (fastcmp(field,"dashspeed"))
plr->dashspeed = (fixed_t)luaL_checkinteger(L, 3);
plr->dashspeed = luaL_checkfixed(L, 3);
else if (fastcmp(field,"dashtime"))
plr->dashtime = (INT32)luaL_checkinteger(L, 3);
else if (fastcmp(field,"normalspeed"))
plr->normalspeed = (fixed_t)luaL_checkinteger(L, 3);
plr->normalspeed = luaL_checkfixed(L, 3);
else if (fastcmp(field,"runspeed"))
plr->runspeed = (fixed_t)luaL_checkinteger(L, 3);
plr->runspeed = luaL_checkfixed(L, 3);
else if (fastcmp(field,"thrustfactor"))
plr->thrustfactor = (UINT8)luaL_checkinteger(L, 3);
else if (fastcmp(field,"accelstart"))
@ -433,7 +433,7 @@ static int player_set(lua_State *L)
else if (fastcmp(field,"gotcontinue"))
plr->gotcontinue = (UINT8)luaL_checkinteger(L, 3);
else if (fastcmp(field,"speed"))
plr->speed = (fixed_t)luaL_checkinteger(L, 3);
plr->speed = luaL_checkfixed(L, 3);
else if (fastcmp(field,"jumping"))
plr->jumping = luaL_checkboolean(L, 3);
else if (fastcmp(field,"secondjump"))
@ -455,13 +455,13 @@ static int player_set(lua_State *L)
else if (fastcmp(field,"skidtime"))
plr->skidtime = (tic_t)luaL_checkinteger(L, 3);
else if (fastcmp(field,"cmomx"))
plr->cmomx = (fixed_t)luaL_checkinteger(L, 3);
plr->cmomx = luaL_checkfixed(L, 3);
else if (fastcmp(field,"cmomy"))
plr->cmomy = (fixed_t)luaL_checkinteger(L, 3);
plr->cmomy = luaL_checkfixed(L, 3);
else if (fastcmp(field,"rmomx"))
plr->rmomx = (fixed_t)luaL_checkinteger(L, 3);
plr->rmomx = luaL_checkfixed(L, 3);
else if (fastcmp(field,"rmomy"))
plr->rmomy = (fixed_t)luaL_checkinteger(L, 3);
plr->rmomy = luaL_checkfixed(L, 3);
else if (fastcmp(field,"numboxes"))
plr->numboxes = (INT16)luaL_checkinteger(L, 3);
else if (fastcmp(field,"totalring"))
@ -489,11 +489,11 @@ static int player_set(lua_State *L)
else if (fastcmp(field,"starposttime"))
plr->starposttime = (tic_t)luaL_checkinteger(L, 3);
else if (fastcmp(field,"starpostangle"))
plr->starpostangle = (angle_t)luaL_checkinteger(L, 3);
plr->starpostangle = luaL_checkangle(L, 3);
else if (fastcmp(field,"angle_pos"))
plr->angle_pos = (angle_t)luaL_checkinteger(L, 3);
plr->angle_pos = luaL_checkangle(L, 3);
else if (fastcmp(field,"old_angle_pos"))
plr->old_angle_pos = (angle_t)luaL_checkinteger(L, 3);
plr->old_angle_pos = luaL_checkangle(L, 3);
else if (fastcmp(field,"axis1"))
P_SetTarget(&plr->axis1, *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)));
else if (fastcmp(field,"axis2"))
@ -569,7 +569,7 @@ static int player_set(lua_State *L)
P_SetTarget(&plr->awayviewmobj, plr->mo); // but since the script might set awayviewmobj immediately AFTER setting awayviewtics, use player mobj as filler for now.
}
else if (fastcmp(field,"awayviewaiming"))
plr->awayviewaiming = (angle_t)luaL_checkinteger(L, 3);
plr->awayviewaiming = luaL_checkangle(L, 3);
else if (fastcmp(field,"spectator"))
plr->spectator = lua_toboolean(L, 3);
else if (fastcmp(field,"bot"))
@ -578,7 +578,7 @@ static int player_set(lua_State *L)
plr->jointime = (tic_t)luaL_checkinteger(L, 3);
#ifdef HWRENDER
else if (fastcmp(field,"fovadd"))
plr->fovadd = (fixed_t)luaL_checkinteger(L, 3);
plr->fovadd = luaL_checkfixed(L, 3);
#endif
else {
lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS);

View File

@ -442,7 +442,6 @@ enum
ARCH_NULL=0,
ARCH_BOOLEAN,
ARCH_SIGNED,
ARCH_UNSIGNED,
ARCH_STRING,
ARCH_TABLE,
@ -522,13 +521,8 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex)
case LUA_TNUMBER:
{
lua_Integer number = lua_tointeger(gL, myindex);
if (number < 0) {
WRITEUINT8(save_p, ARCH_SIGNED);
WRITEFIXED(save_p, number);
} else {
WRITEUINT8(save_p, ARCH_UNSIGNED);
WRITEANGLE(save_p, number);
}
WRITEUINT8(save_p, ARCH_SIGNED);
WRITEFIXED(save_p, number);
break;
}
case LUA_TSTRING:
@ -743,7 +737,7 @@ static int NetArchive(lua_State *L)
{
int TABLESINDEX = lua_upvalueindex(1);
int i, n = lua_gettop(L);
for (i = 0; i < n; i++)
for (i = 1; i <= n; i++)
ArchiveValue(TABLESINDEX, i);
return n;
}
@ -797,9 +791,6 @@ static UINT8 UnArchiveValue(int TABLESINDEX)
case ARCH_SIGNED:
lua_pushinteger(gL, READFIXED(save_p));
break;
case ARCH_UNSIGNED:
lua_pushinteger(gL, READANGLE(save_p));
break;
case ARCH_STRING:
{
char value[1024];
@ -893,7 +884,7 @@ static int NetUnArchive(lua_State *L)
{
int TABLESINDEX = lua_upvalueindex(1);
int i, n = lua_gettop(L);
for (i = 0; i < n; i++)
for (i = 1; i <= n; i++)
UnArchiveValue(TABLESINDEX);
return n;
}
@ -948,6 +939,14 @@ static void NetArchiveHook(lua_CFunction archFunc)
lua_pop(gL, 2);
}
void LUA_Step(void)
{
if (!gL)
return;
lua_settop(gL, 0);
lua_gc(gL, LUA_GCSTEP, 1);
}
void LUA_Archive(void)
{
INT32 i;

View File

@ -19,9 +19,21 @@
#include "blua/lua.h"
#include "blua/lualib.h"
#include "blua/lauxlib.h"
#define lua_optboolean(L, i) (!lua_isnoneornil(L, i) && lua_toboolean(L, i))
#define lua_opttrueboolean(L, i) (lua_isnoneornil(L, i) || lua_toboolean(L, i))
// fixed_t casting
// TODO add some distinction between fixed numbers and integer numbers
// for at least the purpose of printing and maybe math.
#define luaL_checkfixed(L, i) luaL_checkinteger(L, i)
#define lua_pushfixed(L, f) lua_pushinteger(L, f)
// angle_t casting
// we reduce the angle to a fixed point between 0.0 and 1.0
#define luaL_checkangle(L, i) (((angle_t)(luaL_checkfixed(L, i)&0xFFFF))<<16)
#define lua_pushangle(L, a) lua_pushfixed(L, a>>16)
#ifdef _DEBUG
void LUA_ClearExtVars(void);
#endif
@ -36,6 +48,7 @@ void LUA_InvalidateUserdata(void *data);
void LUA_InvalidateLevel(void);
void LUA_InvalidateMapthings(void);
void LUA_InvalidatePlayer(player_t *player);
void LUA_Step(void);
void LUA_Archive(void);
void LUA_UnArchive(void);
void Got_Luacmd(UINT8 **cp, INT32 playernum); // lua_consolelib.c

View File

@ -147,19 +147,19 @@ static int skin_get(lua_State *L)
lua_pushinteger(L, skin->revitem);
break;
case skin_actionspd:
lua_pushinteger(L, skin->actionspd);
lua_pushfixed(L, skin->actionspd);
break;
case skin_mindash:
lua_pushinteger(L, skin->mindash);
lua_pushfixed(L, skin->mindash);
break;
case skin_maxdash:
lua_pushinteger(L, skin->maxdash);
lua_pushfixed(L, skin->maxdash);
break;
case skin_normalspeed:
lua_pushinteger(L, skin->normalspeed);
lua_pushfixed(L, skin->normalspeed);
break;
case skin_runspeed:
lua_pushinteger(L, skin->runspeed);
lua_pushfixed(L, skin->runspeed);
break;
case skin_thrustfactor:
lua_pushinteger(L, skin->thrustfactor);
@ -171,7 +171,7 @@ static int skin_get(lua_State *L)
lua_pushinteger(L, skin->acceleration);
break;
case skin_jumpfactor:
lua_pushinteger(L, skin->jumpfactor);
lua_pushfixed(L, skin->jumpfactor);
break;
case skin_starttranscolor:
lua_pushinteger(L, skin->starttranscolor);

View File

@ -880,12 +880,33 @@ static boolean OP_HeightOkay(player_t *player, UINT8 ceiling)
static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean ceiling)
{
mapthing_t *mt;
mapthing_t *mt = mapthings;
#ifdef HAVE_BLUA
LUA_InvalidateMapthings();
#endif
mapthings = Z_Realloc(mapthings, ++nummapthings * sizeof (*mapthings), PU_LEVEL, NULL);
// as Z_Realloc can relocate mapthings, quickly go through thinker list and correct
// the spawnpoints of any objects that have them to the new location
if (mt != mapthings)
{
thinker_t *th;
mobj_t *mo;
for (th = thinkercap.next; th != &thinkercap; th = th->next)
{
if (th->function.acp1 != (actionf_p1)P_MobjThinker)
continue;
mo = (mobj_t *)th;
// get offset from mt, which points to old mapthings, then add new location
if (mo->spawnpoint)
mo->spawnpoint = (mo->spawnpoint - mt) + mapthings;
}
}
mt = (mapthings+nummapthings-1);
mt->type = type;

View File

@ -119,8 +119,6 @@ fixed_t FixedHypot(fixed_t x, fixed_t y)
return FixedMul(ax, yx1); // |x|*((1 + (x/y)^2)^1/2)
}
#ifdef NEED_FIXED_VECTOR
vector2_t *FV2_Load(vector2_t *vec, fixed_t x, fixed_t y)
{
vec->x = x;
@ -863,8 +861,6 @@ void FM_Scale(matrix_t *dest, fixed_t x, fixed_t y, fixed_t z)
#undef M
}
#endif
#ifdef M_TESTCASE
//#define MULDIV_TEST
#define SQRT_TEST

View File

@ -357,8 +357,6 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedRound(fixed_t x)
return INT32_MAX;
}
#ifdef NEED_FIXED_VECTOR
typedef struct
{
fixed_t x;
@ -437,6 +435,4 @@ void FM_MultMatrix(matrix_t *dest, const matrix_t *multme);
void FM_Translate(matrix_t *dest, fixed_t x, fixed_t y, fixed_t z);
void FM_Scale(matrix_t *dest, fixed_t x, fixed_t y, fixed_t z);
#endif // defined NEED_FIXED_VECTOR
#endif //m_fixed.h

View File

@ -2203,6 +2203,7 @@ boolean M_Responder(event_t *ev)
if (modeattacking)
return true;
M_StartControlPanel();
M_Options(0);
currentMenu = &OP_SoundOptionsDef;
itemOn = 0;
return true;
@ -2212,6 +2213,7 @@ boolean M_Responder(event_t *ev)
if (modeattacking)
return true;
M_StartControlPanel();
M_Options(0);
M_VideoModeMenu(0);
return true;
#endif
@ -2223,6 +2225,7 @@ boolean M_Responder(event_t *ev)
if (modeattacking)
return true;
M_StartControlPanel();
M_Options(0);
M_SetupNextMenu(&OP_MainDef);
return true;
@ -2460,11 +2463,14 @@ void M_Drawer(void)
V_DrawThinString(vid.dupx, vid.height - 9*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, customversionstring);
}
else
#if VERSION > 0 || SUBVERSION > 0
{
#ifdef DEVELOP // Development -- show revision / branch info
V_DrawThinString(vid.dupx, vid.height - 17*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, compbranch);
V_DrawThinString(vid.dupx, vid.height - 9*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, comprevision);
#else // Regular build
V_DrawThinString(vid.dupx, vid.height - 9*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, va("%s", VERSIONSTRING));
#else // Trunk build, show revision info
V_DrawThinString(vid.dupx, vid.height - 9*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, va("%s (%s)", VERSIONSTRING, comprevision));
#endif
}
}
}

View File

@ -1800,16 +1800,14 @@ UINT8 M_HighestBit(UINT32 num)
const char *GetRevisionString(void)
{
INT32 vinfo;
static char rev[8] = {0};
static char rev[9] = {0};
if (rev[0])
return rev;
vinfo = atoi(&comprevision[1]);
if (vinfo)
snprintf(rev, 7, "r%d", vinfo);
if (comprevision[0] == 'r')
strncpy(rev, comprevision, 7);
else
strcpy(rev, "rNULL");
snprintf(rev, 7, "r%s", comprevision);
rev[7] = '\0';
return rev;

View File

@ -5606,8 +5606,13 @@ void A_MixUp(mobj_t *actor)
P_SetThingPosition(players[i].mo);
#ifdef ESLOPE
players[i].mo->floorz = P_GetFloorZ(players[i].mo, players[i].mo->subsector->sector, players[i].mo->x, players[i].mo->y, NULL);
players[i].mo->ceilingz = P_GetCeilingZ(players[i].mo, players[i].mo->subsector->sector, players[i].mo->x, players[i].mo->y, NULL);
#else
players[i].mo->floorz = players[i].mo->subsector->sector->floorheight;
players[i].mo->ceilingz = players[i].mo->subsector->sector->ceilingheight;
#endif
P_CheckPosition(players[i].mo, players[i].mo->x, players[i].mo->y);
}
@ -7592,48 +7597,35 @@ void A_SetTargetsTarget(mobj_t *actor)
{
INT32 locvar1 = var1;
INT32 locvar2 = var2;
mobj_t *targetedmobj = NULL;
thinker_t *th;
mobj_t *mo2;
mobj_t *oldtarg = NULL, *newtarg = NULL;
#ifdef HAVE_BLUA
if (LUA_CallAction("A_SetTargetsTarget", actor))
return;
#endif
if ((!locvar1 && (!actor->target)) || (locvar1 && (!actor->tracer)))
// actor's target
if (locvar1) // or tracer
oldtarg = actor->tracer;
else
oldtarg = actor->target;
if (P_MobjWasRemoved(oldtarg))
return;
if ((!locvar1 && !locvar2 && (!actor->target->target))
|| (!locvar1 && locvar2 && (!actor->target->tracer))
|| (locvar1 && !locvar2 && (!actor->tracer->target))
|| (locvar1 && locvar2 && (!actor->tracer->tracer)))
return; // Don't search for nothing.
// scan the thinkers
for (th = thinkercap.next; th != &thinkercap; th = th->next)
{
if (th->function.acp1 != (actionf_p1)P_MobjThinker)
continue;
mo2 = (mobj_t *)th;
if ((!locvar1 && !locvar2 && (mo2 == actor->target->target))
|| (!locvar1 && locvar2 && (mo2 == actor->target->tracer))
|| (locvar1 && !locvar2 && (mo2 == actor->tracer->target))
|| (locvar1 && locvar2 && (mo2 == actor->tracer->tracer)))
{
targetedmobj = mo2;
break;
}
}
if (!targetedmobj)
return; // Oops, nothing found..
if (!locvar1)
P_SetTarget(&actor->target, targetedmobj);
// actor's target's target!
if (locvar2) // or tracer
newtarg = oldtarg->tracer;
else
P_SetTarget(&actor->tracer, targetedmobj);
newtarg = oldtarg->target;
if (P_MobjWasRemoved(newtarg))
return;
// set actor's new target
if (locvar1) // or tracer
P_SetTarget(&actor->tracer, newtarg);
else
P_SetTarget(&actor->target, newtarg);
}
// Function: A_SetObjectFlags
@ -7650,26 +7642,33 @@ void A_SetObjectFlags(mobj_t *actor)
{
INT32 locvar1 = var1;
INT32 locvar2 = var2;
boolean unlinkthings = false;
#ifdef HAVE_BLUA
if (LUA_CallAction("A_SetObjectFlags", actor))
return;
#endif
P_UnsetThingPosition(actor);
if (sector_list)
{
P_DelSeclist(sector_list);
sector_list = NULL;
if (locvar2 == 2)
locvar1 = actor->flags | locvar1;
else if (locvar2 == 1)
locvar1 = actor->flags & ~locvar1;
if ((locvar1 & (MF_NOBLOCKMAP|MF_NOSECTOR)) != (actor->flags & (MF_NOBLOCKMAP|MF_NOSECTOR))) // Blockmap/sector status has changed, so reset the links
unlinkthings = true;
if (unlinkthings) {
P_UnsetThingPosition(actor);
if (sector_list)
{
P_DelSeclist(sector_list);
sector_list = NULL;
}
}
if (locvar2 == 2)
actor->flags |= locvar1;
else if (locvar2 == 1)
actor->flags &= ~locvar1;
else
actor->flags = locvar1;
actor->flags = locvar1;
P_SetThingPosition(actor);
if (unlinkthings)
P_SetThingPosition(actor);
}
// Function: A_SetObjectFlags2

View File

@ -1174,12 +1174,15 @@ void T_SpikeSector(levelspecthink_t *spikes)
if (affectsec == spikes->sector) // Applied to an actual sector
{
fixed_t affectfloor = P_GetSpecialBottomZ(thing, affectsec, affectsec);
fixed_t affectceil = P_GetSpecialTopZ(thing, affectsec, affectsec);
if (affectsec->flags & SF_FLIPSPECIAL_FLOOR)
{
if (!(thing->eflags & MFE_VERTICALFLIP) && thing->momz > 0)
continue;
if (thing->z == affectsec->floorheight)
if (thing->z == affectfloor)
dothepain = true;
}
@ -1188,18 +1191,20 @@ void T_SpikeSector(levelspecthink_t *spikes)
if ((thing->eflags & MFE_VERTICALFLIP) && thing->momz < 0)
continue;
if (thing->z + thing->height == affectsec->ceilingheight)
if (thing->z + thing->height == affectceil)
dothepain = true;
}
}
else
{
fixed_t affectfloor = P_GetSpecialBottomZ(thing, affectsec, spikes->sector);
fixed_t affectceil = P_GetSpecialTopZ(thing, affectsec, spikes->sector);
if (affectsec->flags & SF_FLIPSPECIAL_FLOOR)
{
if (!(thing->eflags & MFE_VERTICALFLIP) && thing->momz > 0)
continue;
if (thing->z == affectsec->ceilingheight)
if (thing->z == affectceil)
dothepain = true;
}
@ -1208,7 +1213,7 @@ void T_SpikeSector(levelspecthink_t *spikes)
if ((thing->eflags & MFE_VERTICALFLIP) && thing->momz < 0)
continue;
if (thing->z + thing->height == affectsec->floorheight)
if (thing->z + thing->height == affectfloor)
dothepain = true;
}
}
@ -2087,6 +2092,7 @@ void T_EachTimeThinker(levelspecthink_t *eachtime)
boolean FOFsector = false;
boolean inAndOut = false;
boolean floortouch = false;
fixed_t bottomheight, topheight;
for (i = 0; i < MAXPLAYERS; i++)
{
@ -2151,10 +2157,13 @@ void T_EachTimeThinker(levelspecthink_t *eachtime)
if (players[j].mo->subsector->sector != targetsec)
continue;
if (players[j].mo->z > sec->ceilingheight)
topheight = P_GetSpecialTopZ(players[j].mo, sec, targetsec);
bottomheight = P_GetSpecialBottomZ(players[j].mo, sec, targetsec);
if (players[j].mo->z > topheight)
continue;
if (players[j].mo->z + players[j].mo->height < sec->floorheight)
if (players[j].mo->z + players[j].mo->height < bottomheight)
continue;
if (floortouch == true && P_IsObjectOnGroundIn(players[j].mo, targetsec))
@ -2314,7 +2323,7 @@ void T_RaiseSector(levelspecthink_t *raise)
if (raise->vars[1] && !(thing->player->pflags & PF_STARTDASH))
continue;
if (!(thing->z == raise->sector->ceilingheight))
if (!(thing->z == P_GetSpecialTopZ(thing, raise->sector, sector)))
continue;
playeronme = true;

View File

@ -1478,7 +1478,7 @@ static void P_HitDeathMessages(player_t *player, mobj_t *inflictor, mobj_t *sour
return; // Presumably it's obvious what's happening in splitscreen.
#ifdef HAVE_BLUA
if (LUAh_DeathMsg(player, inflictor, source))
if (LUAh_HurtMsg(player, inflictor, source))
return;
#endif
@ -1641,11 +1641,126 @@ static void P_HitDeathMessages(player_t *player, mobj_t *inflictor, mobj_t *sour
CONS_Printf(str, targetname, deadtarget ? M_GetText("killed") : M_GetText("hit"));
}
/** Checks if the level timer is over the timelimit and the round should end,
* unless you are in overtime. In which case leveltime may stretch out beyond
* timelimitintics and overtime's status will be checked here each tick.
* Verify that the value of ::cv_timelimit is greater than zero before
* calling this function.
*
* \sa cv_timelimit, P_CheckPointLimit, P_UpdateSpecials
*/
void P_CheckTimeLimit(void)
{
INT32 i, k;
if (!cv_timelimit.value)
return;
if (!(multiplayer || netgame))
return;
if (G_PlatformGametype())
return;
if (leveltime < timelimitintics)
return;
if (gameaction == ga_completed)
return;
//Tagmode round end but only on the tic before the
//XD_EXITLEVEL packet is recieved by all players.
if (G_TagGametype())
{
if (leveltime == (timelimitintics + 1))
{
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i] || players[i].spectator
|| (players[i].pflags & PF_TAGGED) || (players[i].pflags & PF_TAGIT))
continue;
CONS_Printf(M_GetText("%s recieved double points for surviving the round.\n"), player_names[i]);
P_AddPlayerScore(&players[i], players[i].score);
}
}
if (server)
SendNetXCmd(XD_EXITLEVEL, NULL, 0);
}
//Optional tie-breaker for Match/CTF
else if (cv_overtime.value)
{
INT32 playerarray[MAXPLAYERS];
INT32 tempplayer = 0;
INT32 spectators = 0;
INT32 playercount = 0;
//Figure out if we have enough participating players to care.
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i] && players[i].spectator)
spectators++;
}
if ((D_NumPlayers() - spectators) > 1)
{
// Play the starpost sfx after the first second of overtime.
if (gamestate == GS_LEVEL && (leveltime == (timelimitintics + TICRATE)))
S_StartSound(NULL, sfx_strpst);
// Normal Match
if (!G_GametypeHasTeams())
{
//Store the nodes of participating players in an array.
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i] && !players[i].spectator)
{
playerarray[playercount] = i;
playercount++;
}
}
//Sort 'em.
for (i = 1; i < playercount; i++)
{
for (k = i; k < playercount; k++)
{
if (players[playerarray[i-1]].score < players[playerarray[k]].score)
{
tempplayer = playerarray[i-1];
playerarray[i-1] = playerarray[k];
playerarray[k] = tempplayer;
}
}
}
//End the round if the top players aren't tied.
if (players[playerarray[0]].score == players[playerarray[1]].score)
return;
}
else
{
//In team match and CTF, determining a tie is much simpler. =P
if (redscore == bluescore)
return;
}
}
if (server)
SendNetXCmd(XD_EXITLEVEL, NULL, 0);
}
if (server)
SendNetXCmd(XD_EXITLEVEL, NULL, 0);
}
/** Checks if a player's score is over the pointlimit and the round should end.
* Verify that the value of ::cv_pointlimit is greater than zero before
* calling this function.
*
* \sa cv_pointlimit, P_UpdateSpecials
* \sa cv_pointlimit, P_CheckTimeLimit, P_UpdateSpecials
*/
void P_CheckPointLimit(void)
{
@ -1988,7 +2103,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source)
// allow them to try again, rather than sitting the whole thing out.
if (leveltime >= hidetime * TICRATE)
{
if (gametype == GT_HIDEANDSEEK)//suiciding in survivor makes you IT.
if (gametype == GT_TAG)//suiciding in survivor makes you IT.
{
target->player->pflags |= PF_TAGIT;
CONS_Printf(M_GetText("%s is now IT!\n"), player_names[target->player-players]); // Tell everyone who is it!

View File

@ -217,6 +217,23 @@ boolean P_RailThinker(mobj_t *mobj);
void P_PushableThinker(mobj_t *mobj);
void P_SceneryThinker(mobj_t *mobj);
fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect);
fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect);
#define P_GetFloorZ(mobj, sector, x, y, line) P_MobjFloorZ(mobj, sector, NULL, x, y, line, false, false)
#define P_GetCeilingZ(mobj, sector, x, y, line) P_MobjCeilingZ(mobj, sector, NULL, x, y, line, true, false)
#define P_GetFOFTopZ(mobj, sector, fof, x, y, line) P_MobjCeilingZ(mobj, sectors + fof->secnum, sector, x, y, line, false, false)
#define P_GetFOFBottomZ(mobj, sector, fof, x, y, line) P_MobjFloorZ(mobj, sectors + fof->secnum, sector, x, y, line, true, false)
#define P_GetSpecialBottomZ(mobj, src, bound) P_MobjFloorZ(mobj, src, bound, mobj->x, mobj->y, NULL, src != bound, true)
#define P_GetSpecialTopZ(mobj, src, bound) P_MobjCeilingZ(mobj, src, bound, mobj->x, mobj->y, NULL, src == bound, true)
fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect);
fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect);
#define P_CameraGetFloorZ(mobj, sector, x, y, line) P_CameraFloorZ(mobj, sector, NULL, x, y, line, false, false)
#define P_CameraGetCeilingZ(mobj, sector, x, y, line) P_CameraCeilingZ(mobj, sector, NULL, x, y, line, true, false)
#define P_CameraGetFOFTopZ(mobj, sector, fof, x, y, line) P_CameraCeilingZ(mobj, sectors + fof->secnum, sector, x, y, line, false, false)
#define P_CameraGetFOFBottomZ(mobj, sector, fof, x, y, line) P_CameraFloorZ(mobj, sectors + fof->secnum, sector, x, y, line, true, false)
boolean P_InsideANonSolidFFloor(mobj_t *mobj, ffloor_t *rover);
boolean P_CheckDeathPitCollide(mobj_t *mo);
boolean P_CheckSolidLava(mobj_t *mo, ffloor_t *rover);
@ -276,8 +293,13 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed
extern boolean floatok;
extern fixed_t tmfloorz;
extern fixed_t tmceilingz;
extern mobj_t *tmfloorthing, *tmthing;
extern mobj_t *tmfloorthing, *tmhitthing, *tmthing;
extern camera_t *mapcampointer;
extern fixed_t tmx;
extern fixed_t tmy;
#ifdef ESLOPE
extern pslope_t *tmfloorslope, *tmceilingslope;
#endif
/* cphipps 2004/08/30 */
extern void P_MapStart(void);
@ -316,7 +338,7 @@ void P_RadiusAttack(mobj_t *spot, mobj_t *source, fixed_t damagedist);
fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height);
boolean PIT_PushableMoved(mobj_t *thing);
void P_DoSpring(mobj_t *spring, mobj_t *object);
boolean P_DoSpring(mobj_t *spring, mobj_t *object);
//
// P_SETUP
@ -358,6 +380,7 @@ void P_PlayerEmeraldBurst(player_t *player, boolean toss);
void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck);
void P_PlayerFlagBurst(player_t *player, boolean toss);
void P_CheckTimeLimit(void);
void P_CheckPointLimit(void);
void P_CheckSurvivors(void);
boolean P_CheckRacers(void);

View File

@ -27,6 +27,10 @@
#include "r_splats.h"
#ifdef ESLOPE
#include "p_slopes.h"
#endif
#include "z_zone.h"
#include "lua_hook.h"
@ -34,8 +38,8 @@
fixed_t tmbbox[4];
mobj_t *tmthing;
static INT32 tmflags;
static fixed_t tmx;
static fixed_t tmy;
fixed_t tmx;
fixed_t tmy;
static precipmobj_t *tmprecipthing;
static fixed_t preciptmbbox[4];
@ -47,7 +51,10 @@ boolean floatok;
fixed_t tmfloorz, tmceilingz;
static fixed_t tmdropoffz, tmdrpoffceilz; // drop-off floor/ceiling heights
mobj_t *tmfloorthing; // the thing corresponding to tmfloorz or NULL if tmfloorz is from a sector
static mobj_t *tmhitthing; // the solid thing you bumped into (for collisions)
mobj_t *tmhitthing; // the solid thing you bumped into (for collisions)
#ifdef ESLOPE
pslope_t *tmfloorslope, *tmceilingslope;
#endif
// keep track of the line that lowers the ceiling,
// so missiles don't explode against sky hack walls
@ -102,7 +109,7 @@ boolean P_TeleportMove(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z)
// MOVEMENT ITERATOR FUNCTIONS
// =========================================================================
void P_DoSpring(mobj_t *spring, mobj_t *object)
boolean P_DoSpring(mobj_t *spring, mobj_t *object)
{
INT32 pflags;
fixed_t offx, offy;
@ -110,18 +117,18 @@ void P_DoSpring(mobj_t *spring, mobj_t *object)
fixed_t horizspeed = spring->info->damage;
if (object->eflags & MFE_SPRUNG) // Object was already sprung this tic
return;
return false;
// Spectators don't trigger springs.
if (object->player && object->player->spectator)
return;
return false;
if (object->player && (object->player->pflags & PF_NIGHTSMODE))
{
/*Someone want to make these work like bumpers?*/
return;
return false;
}
object->eflags |= MFE_SPRUNG; // apply this flag asap!
spring->flags &= ~(MF_SOLID|MF_SPECIAL); // De-solidify
@ -209,6 +216,7 @@ void P_DoSpring(mobj_t *spring, mobj_t *object)
P_SetPlayerMobjState(object, S_PLAY_ATK1);
}
}
return true;
}
static void P_DoFanAndGasJet(mobj_t *spring, mobj_t *object)
@ -365,6 +373,7 @@ static void P_DoTailsCarry(player_t *sonic, player_t *tails)
static boolean PIT_CheckThing(mobj_t *thing)
{
fixed_t blockdist;
boolean iwassprung = false;
// don't clip against self
if (thing == tmthing)
@ -819,7 +828,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
{
if ( thing->z <= tmthing->z + tmthing->height
&& tmthing->z <= thing->z + thing->height)
P_DoSpring(thing, tmthing);
iwassprung = P_DoSpring(thing, tmthing);
}
}
@ -906,7 +915,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
{
if ( thing->z <= tmthing->z + tmthing->height
&& tmthing->z <= thing->z + thing->height)
P_DoSpring(thing, tmthing);
iwassprung = P_DoSpring(thing, tmthing);
}
// Are you touching the side of the object you're interacting with?
else if (thing->z - FixedMul(FRACUNIT, thing->scale) <= tmthing->z + tmthing->height
@ -928,12 +937,14 @@ static boolean PIT_CheckThing(mobj_t *thing)
}
}
if (thing->flags & MF_SPRING && (tmthing->player || tmthing->flags & MF_PUSHABLE));
else
if (thing->flags & MF_SPRING && (tmthing->player || tmthing->flags & MF_PUSHABLE))
{
if (iwassprung) // this spring caused you to gain MFE_SPRUNG just now...
return false; // "cancel" P_TryMove via blocking so you keep your current position
}
// Monitors are not treated as solid to players who are jumping, spinning or gliding,
// unless it's a CTF team monitor and you're on the wrong team
if (thing->flags & MF_MONITOR && tmthing->player && tmthing->player->pflags & (PF_JUMPED|PF_SPINNING|PF_GLIDING)
else if (thing->flags & MF_MONITOR && tmthing->player && tmthing->player->pflags & (PF_JUMPED|PF_SPINNING|PF_GLIDING)
&& !((thing->type == MT_REDRINGBOX && tmthing->player->ctfteam != 1) || (thing->type == MT_BLUERINGBOX && tmthing->player->ctfteam != 2)))
;
// z checking at last
@ -953,6 +964,9 @@ static boolean PIT_CheckThing(mobj_t *thing)
if (thing->z + thing->height > tmfloorz)
{
tmfloorz = thing->z + thing->height;
#ifdef ESLOPE
tmfloorslope = NULL;
#endif
}
return true;
}
@ -971,6 +985,9 @@ static boolean PIT_CheckThing(mobj_t *thing)
else if (topz < tmceilingz && tmthing->z+tmthing->height <= thing->z+thing->height)
{
tmceilingz = topz;
#ifdef ESLOPE
tmceilingslope = NULL;
#endif
tmfloorthing = thing; // thing we may stand on
}
}
@ -984,6 +1001,9 @@ static boolean PIT_CheckThing(mobj_t *thing)
if (thing->z < tmceilingz)
{
tmceilingz = thing->z;
#ifdef ESLOPE
tmceilingslope = NULL;
#endif
}
return true;
}
@ -1001,6 +1021,9 @@ static boolean PIT_CheckThing(mobj_t *thing)
else if (topz > tmfloorz && tmthing->z >= thing->z)
{
tmfloorz = topz;
#ifdef ESLOPE
tmfloorslope = NULL;
#endif
tmfloorthing = thing; // thing we may stand on
}
}
@ -1123,11 +1146,13 @@ static boolean PIT_CheckLine(line_t *ld)
{
tmceilingz = opentop;
ceilingline = ld;
tmceilingslope = opentopslope;
}
if (openbottom > tmfloorz)
{
tmfloorz = openbottom;
tmfloorslope = openbottomslope;
}
if (highceiling > tmdrpoffceilz)
@ -1204,8 +1229,12 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
// that contains the point.
// Any contacted lines the step closer together
// will adjust them.
tmfloorz = tmdropoffz = newsubsec->sector->floorheight;
tmceilingz = tmdrpoffceilz = newsubsec->sector->ceilingheight;
tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->floorheight;
tmceilingz = P_GetCeilingZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->ceilingheight;
#ifdef ESLOPE
tmfloorslope = newsubsec->sector->f_slope;
tmceilingslope = newsubsec->sector->c_slope;
#endif
// Check list of fake floors and see if tmfloorz/tmceilingz need to be altered.
if (newsubsec->sector->ffloors)
@ -1216,35 +1245,48 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
for (rover = newsubsec->sector->ffloors; rover; rover = rover->next)
{
fixed_t topheight, bottomheight;
if (!(rover->flags & FF_EXISTS))
continue;
topheight = P_GetFOFTopZ(thing, newsubsec->sector, rover, x, y, NULL);
bottomheight = P_GetFOFBottomZ(thing, newsubsec->sector, rover, x, y, NULL);
if (rover->flags & FF_GOOWATER && !(thing->flags & MF_NOGRAVITY))
{
// If you're inside goowater and slowing down
fixed_t sinklevel = FixedMul(thing->info->height/6, thing->scale);
fixed_t minspeed = FixedMul(thing->info->height/12, thing->scale);
if (thing->z < *rover->topheight && *rover->bottomheight < thingtop
fixed_t minspeed = FixedMul(thing->info->height/9, thing->scale);
if (thing->z < topheight && bottomheight < thingtop
&& abs(thing->momz) < minspeed)
{
// Oh no! The object is stick in between the surface of the goo and sinklevel! help them out!
if (!(thing->eflags & MFE_VERTICALFLIP) && thing->z > *rover->topheight - sinklevel
if (!(thing->eflags & MFE_VERTICALFLIP) && thing->z > topheight - sinklevel
&& thing->momz >= 0 && thing->momz < (minspeed>>2))
thing->momz += minspeed>>2;
else if (thing->eflags & MFE_VERTICALFLIP && thingtop < *rover->bottomheight + sinklevel
else if (thing->eflags & MFE_VERTICALFLIP && thingtop < bottomheight + sinklevel
&& thing->momz <= 0 && thing->momz > -(minspeed>>2))
thing->momz -= minspeed>>2;
// Land on the top or the bottom, depending on gravity flip.
if (!(thing->eflags & MFE_VERTICALFLIP) && thing->z >= *rover->topheight - sinklevel && thing->momz <= 0)
if (!(thing->eflags & MFE_VERTICALFLIP) && thing->z >= topheight - sinklevel && thing->momz <= 0)
{
if (tmfloorz < *rover->topheight - sinklevel)
tmfloorz = *rover->topheight - sinklevel;
if (tmfloorz < topheight - sinklevel) {
tmfloorz = topheight - sinklevel;
#ifdef ESLOPE
tmfloorslope = *rover->t_slope;
#endif
}
}
else if (thing->eflags & MFE_VERTICALFLIP && thingtop <= *rover->bottomheight + sinklevel && thing->momz >= 0)
else if (thing->eflags & MFE_VERTICALFLIP && thingtop <= bottomheight + sinklevel && thing->momz >= 0)
{
if (tmceilingz > *rover->bottomheight + sinklevel)
tmceilingz = *rover->bottomheight + sinklevel;
if (tmceilingz > bottomheight + sinklevel) {
tmceilingz = bottomheight + sinklevel;
#ifdef ESLOPE
tmceilingslope = *rover->b_slope;
#endif
}
}
}
continue;
@ -1261,30 +1303,40 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
if (rover->flags & FF_QUICKSAND)
{
if (thing->z < *rover->topheight && *rover->bottomheight < thingtop)
if (thing->z < topheight && bottomheight < thingtop)
{
if (tmfloorz < thing->z)
if (tmfloorz < thing->z) {
tmfloorz = thing->z;
#ifdef ESLOPE
tmfloorslope = NULL;
#endif
}
}
// Quicksand blocks never change heights otherwise.
continue;
}
delta1 = thing->z - (*rover->bottomheight
+ ((*rover->topheight - *rover->bottomheight)/2));
delta2 = thingtop - (*rover->bottomheight
+ ((*rover->topheight - *rover->bottomheight)/2));
delta1 = thing->z - (bottomheight
+ ((topheight - bottomheight)/2));
delta2 = thingtop - (bottomheight
+ ((topheight - bottomheight)/2));
if (*rover->topheight > tmfloorz && abs(delta1) < abs(delta2)
if (topheight > tmfloorz && abs(delta1) < abs(delta2)
&& !(rover->flags & FF_REVERSEPLATFORM))
{
tmfloorz = tmdropoffz = *rover->topheight;
tmfloorz = tmdropoffz = topheight;
#ifdef ESLOPE
tmfloorslope = *rover->t_slope;
#endif
}
if (*rover->bottomheight < tmceilingz && abs(delta1) >= abs(delta2)
if (bottomheight < tmceilingz && abs(delta1) >= abs(delta2)
&& !(rover->flags & FF_PLATFORM)
&& !(thing->type == MT_SKIM && (rover->flags & FF_SWIMMABLE)))
{
tmceilingz = tmdrpoffceilz = *rover->bottomheight;
tmceilingz = tmdrpoffceilz = bottomheight;
#ifdef ESLOPE
tmceilingslope = *rover->b_slope;
#endif
}
}
}
@ -1357,11 +1409,19 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
delta1 = thing->z - (polybottom + ((polytop - polybottom)/2));
delta2 = thingtop - (polybottom + ((polytop - polybottom)/2));
if (polytop > tmfloorz && abs(delta1) < abs(delta2))
if (polytop > tmfloorz && abs(delta1) < abs(delta2)) {
tmfloorz = tmdropoffz = polytop;
#ifdef ESLOPE
tmfloorslope = NULL;
#endif
}
if (polybottom < tmceilingz && abs(delta1) >= abs(delta2))
if (polybottom < tmceilingz && abs(delta1) >= abs(delta2)) {
tmceilingz = tmdrpoffceilz = polybottom;
#ifdef ESLOPE
tmceilingslope = NULL;
#endif
}
}
plink = (polymaplink_t *)(plink->link.next);
}
@ -1463,8 +1523,9 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam)
// that contains the point.
// Any contacted lines the step closer together
// will adjust them.
tmfloorz = tmdropoffz = newsubsec->sector->floorheight;
tmceilingz = tmdrpoffceilz = newsubsec->sector->ceilingheight;
tmfloorz = tmdropoffz = P_CameraGetFloorZ(thiscam, newsubsec->sector, x, y, NULL);
tmceilingz = P_CameraGetCeilingZ(thiscam, newsubsec->sector, x, y, NULL);
// Cameras use the heightsec's heights rather then the actual sector heights.
// If you can see through it, why not move the camera through it too?
@ -1490,20 +1551,24 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam)
for (rover = newsubsec->sector->ffloors; rover; rover = rover->next)
{
fixed_t topheight, bottomheight;
if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERALL) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12)
continue;
delta1 = thiscam->z - (*rover->bottomheight
+ ((*rover->topheight - *rover->bottomheight)/2));
delta2 = thingtop - (*rover->bottomheight
+ ((*rover->topheight - *rover->bottomheight)/2));
if (*rover->topheight > tmfloorz && abs(delta1) < abs(delta2))
topheight = P_CameraGetFOFTopZ(thiscam, newsubsec->sector, rover, x, y, NULL);
bottomheight = P_CameraGetFOFBottomZ(thiscam, newsubsec->sector, rover, x, y, NULL);
delta1 = thiscam->z - (bottomheight
+ ((topheight - bottomheight)/2));
delta2 = thingtop - (bottomheight
+ ((topheight - bottomheight)/2));
if (topheight > tmfloorz && abs(delta1) < abs(delta2))
{
tmfloorz = tmdropoffz = *rover->topheight;
tmfloorz = tmdropoffz = topheight;
}
if (*rover->bottomheight < tmceilingz && abs(delta1) >= abs(delta2))
if (bottomheight < tmceilingz && abs(delta1) >= abs(delta2))
{
tmceilingz = tmdrpoffceilz = *rover->bottomheight;
tmceilingz = tmdrpoffceilz = bottomheight;
}
}
}
@ -1698,8 +1763,8 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam)
}
else
{
tmfloorz = thiscam->subsector->sector->floorheight;
tmceilingz = thiscam->subsector->sector->ceilingheight;
tmfloorz = P_CameraGetFloorZ(thiscam, thiscam->subsector->sector, x, y, NULL);
tmceilingz = P_CameraGetCeilingZ(thiscam, thiscam->subsector->sector, x, y, NULL);
}
// the move is ok,
@ -1765,6 +1830,10 @@ boolean PIT_PushableMoved(mobj_t *thing)
mobj_t *oldthing = tmthing;
line_t *oldceilline = ceilingline;
line_t *oldblockline = blockingline;
#ifdef ESLOPE
pslope_t *oldfslope = tmfloorslope;
pslope_t *oldcslope = tmceilingslope;
#endif
// Move the player
P_TryMove(thing, thing->x+stand->momx, thing->y+stand->momy, true);
@ -1777,6 +1846,10 @@ boolean PIT_PushableMoved(mobj_t *thing)
P_SetTarget(&tmthing, oldthing);
ceilingline = oldceilline;
blockingline = oldblockline;
#ifdef ESLOPE
tmfloorslope = oldfslope;
tmceilingslope = oldcslope;
#endif
thing->momz = stand->momz;
}
else
@ -1798,6 +1871,9 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
fixed_t tryy = thing->y;
fixed_t radius = thing->radius;
fixed_t thingtop = thing->z + thing->height;
#ifdef ESLOPE
fixed_t startingonground = P_IsObjectOnGround(thing);
#endif
floatok = false;
if (radius < MAXRADIUS/2)
@ -1886,13 +1962,23 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
{
if (thingtop == thing->ceilingz && tmceilingz > thingtop && tmceilingz - thingtop <= maxstep)
{
thing->z = tmceilingz - thing->height;
thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height;
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
}
else if (tmceilingz < thingtop && thingtop - tmceilingz <= maxstep)
{
thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height;
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
}
}
else if (thing->z == thing->floorz && tmfloorz < thing->z && thing->z - tmfloorz <= maxstep)
{
thing->z = tmfloorz;
thing->z = thing->floorz = tmfloorz;
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
}
else if (tmfloorz > thing->z && tmfloorz - thing->z <= maxstep)
{
thing->z = thing->floorz = tmfloorz;
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
}
}
@ -1963,6 +2049,25 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
thing->floorz = tmfloorz;
thing->ceilingz = tmceilingz;
#ifdef ESLOPE
// Assign thing's standingslope if needed
if (thing->z <= tmfloorz && !(thing->eflags & MFE_VERTICALFLIP)) {
if (!startingonground && tmfloorslope)
P_HandleSlopeLanding(thing, tmfloorslope);
if (thing->momz <= 0)
thing->standingslope = tmfloorslope;
}
else if (thing->z+thing->height >= tmceilingz && (thing->eflags & MFE_VERTICALFLIP)) {
if (!startingonground && tmceilingslope)
P_HandleSlopeLanding(thing, tmceilingslope);
if (thing->momz >= 0)
thing->standingslope = tmceilingslope;
}
#endif
thing->x = x;
thing->y = y;
@ -1978,6 +2083,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y)
{
fixed_t tryx, tryy;
tryx = thing->x;
tryy = thing->y;
do {
@ -2042,6 +2148,7 @@ boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y)
//
static boolean P_ThingHeightClip(mobj_t *thing)
{
boolean floormoved;
fixed_t oldfloorz = thing->floorz;
boolean onfloor = P_IsObjectOnGround(thing);//(thing->z <= thing->floorz);
@ -2053,6 +2160,9 @@ static boolean P_ThingHeightClip(mobj_t *thing)
if (P_MobjWasRemoved(thing))
return true;
floormoved = (thing->eflags & MFE_VERTICALFLIP && tmceilingz != thing->ceilingz)
|| (!(thing->eflags & MFE_VERTICALFLIP) && tmfloorz != thing->floorz);
thing->floorz = tmfloorz;
thing->ceilingz = tmceilingz;
@ -2061,20 +2171,13 @@ static boolean P_ThingHeightClip(mobj_t *thing)
if (tmfloorz > oldfloorz+thing->height)
return true;
if (/*!tmfloorthing && */onfloor && !(thing->flags & MF_NOGRAVITY))
if (onfloor && !(thing->flags & MF_NOGRAVITY) && floormoved)
{
if (thing->eflags & MFE_VERTICALFLIP)
thing->pmomz = thing->ceilingz - (thing->z + thing->height);
else
thing->pmomz = thing->floorz - thing->z;
if (thing->player)
{
if (splitscreen && camera2.chase && thing->player == &players[secondarydisplayplayer])
camera2.z += thing->pmomz;
else if (camera.chase && thing->player == &players[displayplayer])
camera.z += thing->pmomz;
}
thing->eflags |= MFE_APPLYPMOMZ;
if (thing->eflags & MFE_VERTICALFLIP)
thing->z = thing->ceilingz - thing->height;
@ -2303,15 +2406,25 @@ static boolean P_IsClimbingValid(player_t *player, angle_t angle)
{
fixed_t platx, platy;
subsector_t *glidesector;
fixed_t floorz, ceilingz;
platx = P_ReturnThrustX(player->mo, angle, player->mo->radius + FixedMul(8*FRACUNIT, player->mo->scale));
platy = P_ReturnThrustY(player->mo, angle, player->mo->radius + FixedMul(8*FRACUNIT, player->mo->scale));
glidesector = R_PointInSubsector(player->mo->x + platx, player->mo->y + platy);
#ifdef ESLOPE
floorz = glidesector->sector->f_slope ? P_GetZAt(glidesector->sector->f_slope, player->mo->x, player->mo->y) : glidesector->sector->floorheight;
ceilingz = glidesector->sector->c_slope ? P_GetZAt(glidesector->sector->c_slope, player->mo->x, player->mo->y) : glidesector->sector->ceilingheight;
#else
floorz = glidesector->sector->floorheight;
ceilingz = glidesector->sector->ceilingheight;
#endif
if (glidesector->sector != player->mo->subsector->sector)
{
boolean floorclimb = false;
fixed_t topheight, bottomheight;
if (glidesector->sector->ffloors)
{
@ -2321,34 +2434,44 @@ static boolean P_IsClimbingValid(player_t *player, angle_t angle)
if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER))
continue;
topheight = *rover->topheight;
bottomheight = *rover->bottomheight;
#ifdef ESLOPE
if (*rover->t_slope)
topheight = P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y);
if (*rover->b_slope)
bottomheight = P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y);
#endif
floorclimb = true;
if (player->mo->eflags & MFE_VERTICALFLIP)
{
if ((*rover->topheight < player->mo->z + player->mo->height) && ((player->mo->z + player->mo->height + player->mo->momz) < *rover->topheight))
if ((topheight < player->mo->z + player->mo->height) && ((player->mo->z + player->mo->height + player->mo->momz) < topheight))
{
floorclimb = true;
}
if (*rover->topheight < player->mo->z) // Waaaay below the ledge.
if (topheight < player->mo->z) // Waaaay below the ledge.
{
floorclimb = false;
}
if (*rover->bottomheight > player->mo->z + player->mo->height - FixedMul(16*FRACUNIT,player->mo->scale))
if (bottomheight > player->mo->z + player->mo->height - FixedMul(16*FRACUNIT,player->mo->scale))
{
floorclimb = false;
}
}
else
{
if ((*rover->bottomheight > player->mo->z) && ((player->mo->z - player->mo->momz) > *rover->bottomheight))
if ((bottomheight > player->mo->z) && ((player->mo->z - player->mo->momz) > bottomheight))
{
floorclimb = true;
}
if (*rover->bottomheight > player->mo->z + player->mo->height) // Waaaay below the ledge.
if (bottomheight > player->mo->z + player->mo->height) // Waaaay below the ledge.
{
floorclimb = false;
}
if (*rover->topheight < player->mo->z + FixedMul(16*FRACUNIT,player->mo->scale))
if (topheight < player->mo->z + FixedMul(16*FRACUNIT,player->mo->scale))
{
floorclimb = false;
}
@ -2361,30 +2484,30 @@ static boolean P_IsClimbingValid(player_t *player, angle_t angle)
if (player->mo->eflags & MFE_VERTICALFLIP)
{
if ((glidesector->sector->floorheight <= player->mo->z + player->mo->height)
&& ((player->mo->z + player->mo->height - player->mo->momz) <= glidesector->sector->floorheight))
if ((floorz <= player->mo->z + player->mo->height)
&& ((player->mo->z + player->mo->height - player->mo->momz) <= floorz))
floorclimb = true;
if ((glidesector->sector->floorheight > player->mo->z)
if ((floorz > player->mo->z)
&& glidesector->sector->floorpic == skyflatnum)
return false;
if ((player->mo->z + player->mo->height - FixedMul(16*FRACUNIT,player->mo->scale) > glidesector->sector->ceilingheight)
|| (player->mo->z + player->mo->height <= glidesector->sector->floorheight))
if ((player->mo->z + player->mo->height - FixedMul(16*FRACUNIT,player->mo->scale) > ceilingz)
|| (player->mo->z + player->mo->height <= floorz))
floorclimb = true;
}
else
{
if ((glidesector->sector->ceilingheight >= player->mo->z)
&& ((player->mo->z - player->mo->momz) >= glidesector->sector->ceilingheight))
if ((ceilingz >= player->mo->z)
&& ((player->mo->z - player->mo->momz) >= ceilingz))
floorclimb = true;
if ((glidesector->sector->ceilingheight < player->mo->z+player->mo->height)
if ((ceilingz < player->mo->z+player->mo->height)
&& glidesector->sector->ceilingpic == skyflatnum)
return false;
if ((player->mo->z + FixedMul(16*FRACUNIT,player->mo->scale) < glidesector->sector->floorheight)
|| (player->mo->z >= glidesector->sector->ceilingheight))
if ((player->mo->z + FixedMul(16*FRACUNIT,player->mo->scale) < ceilingz)
|| (player->mo->z >= ceilingz))
floorclimb = true;
}
@ -2456,6 +2579,7 @@ isblocking:
line_t *checkline = li;
sector_t *checksector;
ffloor_t *rover;
fixed_t topheight, bottomheight;
boolean fofline = false;
INT32 side = P_PointOnLineSide(slidemo->x, slidemo->y, li);
@ -2471,13 +2595,23 @@ isblocking:
if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP))
continue;
if (*rover->topheight < slidemo->z)
topheight = *rover->topheight;
bottomheight = *rover->bottomheight;
#ifdef ESLOPE
if (*rover->t_slope)
topheight = P_GetZAt(*rover->t_slope, slidemo->x, slidemo->y);
if (*rover->b_slope)
bottomheight = P_GetZAt(*rover->b_slope, slidemo->x, slidemo->y);
#endif
if (topheight < slidemo->z)
continue;
if (*rover->bottomheight > slidemo->z + slidemo->height)
if (bottomheight > slidemo->z + slidemo->height)
continue;
// Got this far, so I guess it's climbable.
// Got this far, so I guess it's climbable. // TODO: Climbing check, also, better method to do this?
if (rover->master->flags & ML_TFERLINE)
{
size_t linenum = li-checksector->lines[0];
@ -3097,6 +3231,7 @@ static boolean PIT_ChangeSector(mobj_t *thing, boolean realcrush)
if (thing->subsector->sector->ffloors && (realcrush || thing->flags & MF_PUSHABLE))
{
ffloor_t *rover;
fixed_t topheight, bottomheight;
fixed_t delta1, delta2;
INT32 thingtop = thing->z + thing->height;
@ -3106,9 +3241,19 @@ static boolean PIT_ChangeSector(mobj_t *thing, boolean realcrush)
|| ((rover->flags & FF_BLOCKOTHERS) && !thing->player)) || !(rover->flags & FF_EXISTS))
continue;
delta1 = thing->z - (*rover->bottomheight + *rover->topheight)/2;
delta2 = thingtop - (*rover->bottomheight + *rover->topheight)/2;
if (*rover->bottomheight <= thing->ceilingz && abs(delta1) >= abs(delta2))
topheight = *rover->topheight;
bottomheight = *rover->bottomheight;
/*#ifdef ESLOPE
if (rover->t_slope)
topheight = P_GetZAt(rover->t_slope, thing->x, thing->y);
if (rover->b_slope)
bottomheight = P_GetZAt(rover->b_slope, thing->x, thing->y);
#endif*/
delta1 = thing->z - (bottomheight + topheight)/2;
delta2 = thingtop - (bottomheight + topheight)/2;
if (bottomheight <= thing->ceilingz && abs(delta1) >= abs(delta2))
{
if (thing->flags & MF_PUSHABLE)
{
@ -3786,7 +3931,7 @@ void P_MapEnd(void)
}
// P_FloorzAtPos
// Returns the floorz of the XYZ position
// Returns the floorz of the XYZ position // TODO: Need ceilingpos function too
// Tails 05-26-2003
fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height)
{
@ -3801,15 +3946,26 @@ fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height)
for (rover = sec->ffloors; rover; rover = rover->next)
{
fixed_t topheight, bottomheight;
if (!(rover->flags & FF_EXISTS))
continue;
if ((!(rover->flags & FF_SOLID || rover->flags & FF_QUICKSAND) || (rover->flags & FF_SWIMMABLE)))
continue;
topheight = *rover->topheight;
bottomheight = *rover->bottomheight;
#ifdef ESLOPE
if (*rover->t_slope)
topheight = P_GetZAt(*rover->t_slope, x, y);
if (*rover->b_slope)
bottomheight = P_GetZAt(*rover->b_slope, x, y);
#endif
if (rover->flags & FF_QUICKSAND)
{
if (z < *rover->topheight && *rover->bottomheight < thingtop)
if (z < topheight && bottomheight < thingtop)
{
if (floorz < z)
floorz = z;
@ -3817,10 +3973,10 @@ fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height)
continue;
}
delta1 = z - (*rover->bottomheight + ((*rover->topheight - *rover->bottomheight)/2));
delta2 = thingtop - (*rover->bottomheight + ((*rover->topheight - *rover->bottomheight)/2));
if (*rover->topheight > floorz && abs(delta1) < abs(delta2))
floorz = *rover->topheight;
delta1 = z - (bottomheight + ((topheight - bottomheight)/2));
delta2 = thingtop - (bottomheight + ((topheight - bottomheight)/2));
if (topheight > floorz && abs(delta1) < abs(delta2))
floorz = topheight;
}
}

View File

@ -20,6 +20,7 @@
#include "r_data.h"
#include "p_maputl.h"
#include "p_polyobj.h"
#include "p_slopes.h"
#include "z_zone.h"
//
@ -322,6 +323,9 @@ fixed_t P_InterceptVector(divline_t *v2, divline_t *v1)
// OPTIMIZE: keep this precalculated
//
fixed_t opentop, openbottom, openrange, lowfloor, highceiling;
#ifdef ESLOPE
pslope_t *opentopslope, *openbottomslope;
#endif
// P_CameraLineOpening
// P_LineOpening, but for camera
@ -348,31 +352,56 @@ void P_CameraLineOpening(line_t *linedef)
{
frontfloor = sectors[front->camsec].floorheight;
frontceiling = sectors[front->camsec].ceilingheight;
#ifdef ESLOPE
if (sectors[front->camsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope)
frontfloor = P_GetZAt(sectors[front->camsec].f_slope, camera.x, camera.y);
if (sectors[front->camsec].c_slope)
frontceiling = P_GetZAt(sectors[front->camsec].c_slope, camera.x, camera.y);
#endif
}
else if (front->heightsec >= 0)
{
frontfloor = sectors[front->heightsec].floorheight;
frontceiling = sectors[front->heightsec].ceilingheight;
#ifdef ESLOPE
if (sectors[front->heightsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope)
frontfloor = P_GetZAt(sectors[front->heightsec].f_slope, camera.x, camera.y);
if (sectors[front->heightsec].c_slope)
frontceiling = P_GetZAt(sectors[front->heightsec].c_slope, camera.x, camera.y);
#endif
}
else
{
frontfloor = front->floorheight;
frontceiling = front->ceilingheight;
frontfloor = P_CameraGetFloorZ(mapcampointer, front, tmx, tmy, linedef);
frontceiling = P_CameraGetCeilingZ(mapcampointer, front, tmx, tmy, linedef);
}
if (back->camsec >= 0)
{
backfloor = sectors[back->camsec].floorheight;
backceiling = sectors[back->camsec].ceilingheight;
#ifdef ESLOPE
if (sectors[back->camsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope)
frontfloor = P_GetZAt(sectors[back->camsec].f_slope, camera.x, camera.y);
if (sectors[back->camsec].c_slope)
frontceiling = P_GetZAt(sectors[back->camsec].c_slope, camera.x, camera.y);
#endif
}
else if (back->heightsec >= 0)
{
backfloor = sectors[back->heightsec].floorheight;
backceiling = sectors[back->heightsec].ceilingheight;
#ifdef ESLOPE
if (sectors[back->heightsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope)
frontfloor = P_GetZAt(sectors[back->heightsec].f_slope, camera.x, camera.y);
if (sectors[back->heightsec].c_slope)
frontceiling = P_GetZAt(sectors[back->heightsec].c_slope, camera.x, camera.y);
#endif
}
else
{
backfloor = back->floorheight;
backceiling = back->ceilingheight;
backfloor = P_CameraGetFloorZ(mapcampointer, back, tmx, tmy, linedef);
backceiling = P_CameraGetCeilingZ(mapcampointer, back, tmx, tmy, linedef);
}
{
@ -414,40 +443,48 @@ void P_CameraLineOpening(line_t *linedef)
if (front->ffloors)
for (rover = front->ffloors; rover; rover = rover->next)
{
fixed_t topheight, bottomheight;
if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_RENDERALL) || !(rover->flags & FF_EXISTS) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12)
continue;
delta1 = abs(mapcampointer->z - (*rover->bottomheight + ((*rover->topheight - *rover->bottomheight)/2)));
delta2 = abs(thingtop - (*rover->bottomheight + ((*rover->topheight - *rover->bottomheight)/2)));
if (*rover->bottomheight < lowestceiling && delta1 >= delta2)
lowestceiling = *rover->bottomheight;
else if (*rover->bottomheight < highestceiling && delta1 >= delta2)
highestceiling = *rover->bottomheight;
topheight = P_CameraGetFOFTopZ(mapcampointer, front, rover, tmx, tmy, linedef);
bottomheight = P_CameraGetFOFBottomZ(mapcampointer, front, rover, tmx, tmy, linedef);
if (*rover->topheight > highestfloor && delta1 < delta2)
highestfloor = *rover->topheight;
else if (*rover->topheight > lowestfloor && delta1 < delta2)
lowestfloor = *rover->topheight;
delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2)));
delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2)));
if (bottomheight < lowestceiling && delta1 >= delta2)
lowestceiling = bottomheight;
else if (bottomheight < highestceiling && delta1 >= delta2)
highestceiling = bottomheight;
if (topheight > highestfloor && delta1 < delta2)
highestfloor = topheight;
else if (topheight > lowestfloor && delta1 < delta2)
lowestfloor = topheight;
}
// Check for backsectors fake floors
if (back->ffloors)
for (rover = back->ffloors; rover; rover = rover->next)
{
fixed_t topheight, bottomheight;
if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_RENDERALL) || !(rover->flags & FF_EXISTS) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12)
continue;
delta1 = abs(mapcampointer->z - (*rover->bottomheight + ((*rover->topheight - *rover->bottomheight)/2)));
delta2 = abs(thingtop - (*rover->bottomheight + ((*rover->topheight - *rover->bottomheight)/2)));
if (*rover->bottomheight < lowestceiling && delta1 >= delta2)
lowestceiling = *rover->bottomheight;
else if (*rover->bottomheight < highestceiling && delta1 >= delta2)
highestceiling = *rover->bottomheight;
topheight = P_CameraGetFOFTopZ(mapcampointer, back, rover, tmx, tmy, linedef);
bottomheight = P_CameraGetFOFBottomZ(mapcampointer, back, rover, tmx, tmy, linedef);
if (*rover->topheight > highestfloor && delta1 < delta2)
highestfloor = *rover->topheight;
else if (*rover->topheight > lowestfloor && delta1 < delta2)
lowestfloor = *rover->topheight;
delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2)));
delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2)));
if (bottomheight < lowestceiling && delta1 >= delta2)
lowestceiling = bottomheight;
else if (bottomheight < highestceiling && delta1 >= delta2)
highestceiling = bottomheight;
if (topheight > highestfloor && delta1 < delta2)
highestfloor = topheight;
else if (topheight > lowestfloor && delta1 < delta2)
lowestfloor = topheight;
}
if (highestceiling < highceiling)
@ -495,26 +532,40 @@ void P_LineOpening(line_t *linedef)
I_Assert(front != NULL);
I_Assert(back != NULL);
if (front->ceilingheight < back->ceilingheight)
{
opentop = front->ceilingheight;
highceiling = back->ceilingheight;
}
else
{
opentop = back->ceilingheight;
highceiling = front->ceilingheight;
}
{ // Set open and high/low values here
fixed_t frontheight, backheight;
if (front->floorheight > back->floorheight)
{
openbottom = front->floorheight;
lowfloor = back->floorheight;
}
else
{
openbottom = back->floorheight;
lowfloor = front->floorheight;
frontheight = P_GetCeilingZ(tmthing, front, tmx, tmy, linedef);
backheight = P_GetCeilingZ(tmthing, back, tmx, tmy, linedef);
if (frontheight < backheight)
{
opentop = frontheight;
highceiling = backheight;
opentopslope = front->c_slope;
}
else
{
opentop = backheight;
highceiling = frontheight;
opentopslope = back->c_slope;
}
frontheight = P_GetFloorZ(tmthing, front, tmx, tmy, linedef);
backheight = P_GetFloorZ(tmthing, back, tmx, tmy, linedef);
if (frontheight > backheight)
{
openbottom = frontheight;
lowfloor = backheight;
openbottomslope = front->f_slope;
}
else
{
openbottom = backheight;
lowfloor = frontheight;
openbottomslope = back->f_slope;
}
}
if (tmthing)
@ -580,10 +631,15 @@ void P_LineOpening(line_t *linedef)
fixed_t highestfloor = openbottom;
fixed_t lowestfloor = lowfloor;
fixed_t delta1, delta2;
#ifdef ESLOPE
pslope_t *ceilingslope = opentopslope;
pslope_t *floorslope = openbottomslope;
#endif
// Check for frontsector's fake floors
for (rover = front->ffloors; rover; rover = rover->next)
{
fixed_t topheight, bottomheight;
if (!(rover->flags & FF_EXISTS))
continue;
@ -593,29 +649,41 @@ void P_LineOpening(line_t *linedef)
|| (rover->flags & FF_BLOCKOTHERS && !tmthing->player)))
continue;
delta1 = abs(tmthing->z - (*rover->bottomheight + ((*rover->topheight - *rover->bottomheight)/2)));
delta2 = abs(thingtop - (*rover->bottomheight + ((*rover->topheight - *rover->bottomheight)/2)));
topheight = P_GetFOFTopZ(tmthing, front, rover, tmx, tmy, linedef);
bottomheight = P_GetFOFBottomZ(tmthing, front, rover, tmx, tmy, linedef);
delta1 = abs(tmthing->z - (bottomheight + ((topheight - bottomheight)/2)));
delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2)));
if (delta1 >= delta2 && !(rover->flags & FF_PLATFORM)) // thing is below FOF
{
if (*rover->bottomheight < lowestceiling)
lowestceiling = *rover->bottomheight;
else if (*rover->bottomheight < highestceiling)
highestceiling = *rover->bottomheight;
if (bottomheight < lowestceiling) {
lowestceiling = bottomheight;
#ifdef ESLOPE
ceilingslope = *rover->b_slope;
#endif
}
else if (bottomheight < highestceiling)
highestceiling = bottomheight;
}
if (delta1 < delta2 && !(rover->flags & FF_REVERSEPLATFORM)) // thing is above FOF
{
if (*rover->topheight > highestfloor)
highestfloor = *rover->topheight;
else if (*rover->topheight > lowestfloor)
lowestfloor = *rover->topheight;
if (topheight > highestfloor) {
highestfloor = topheight;
#ifdef ESLOPE
floorslope = *rover->t_slope;
#endif
}
else if (topheight > lowestfloor)
lowestfloor = topheight;
}
}
// Check for backsectors fake floors
for (rover = back->ffloors; rover; rover = rover->next)
{
fixed_t topheight, bottomheight;
if (!(rover->flags & FF_EXISTS))
continue;
@ -625,23 +693,34 @@ void P_LineOpening(line_t *linedef)
|| (rover->flags & FF_BLOCKOTHERS && !tmthing->player)))
continue;
delta1 = abs(tmthing->z - (*rover->bottomheight + ((*rover->topheight - *rover->bottomheight)/2)));
delta2 = abs(thingtop - (*rover->bottomheight + ((*rover->topheight - *rover->bottomheight)/2)));
topheight = P_GetFOFTopZ(tmthing, back, rover, tmx, tmy, linedef);
bottomheight = P_GetFOFBottomZ(tmthing, back, rover, tmx, tmy, linedef);
delta1 = abs(tmthing->z - (bottomheight + ((topheight - bottomheight)/2)));
delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2)));
if (delta1 >= delta2 && !(rover->flags & FF_PLATFORM)) // thing is below FOF
{
if (*rover->bottomheight < lowestceiling)
lowestceiling = *rover->bottomheight;
else if (*rover->bottomheight < highestceiling)
highestceiling = *rover->bottomheight;
if (bottomheight < lowestceiling) {
lowestceiling = bottomheight;
#ifdef ESLOPE
ceilingslope = *rover->b_slope;
#endif
}
else if (bottomheight < highestceiling)
highestceiling = bottomheight;
}
if (delta1 < delta2 && !(rover->flags & FF_REVERSEPLATFORM)) // thing is above FOF
{
if (*rover->topheight > highestfloor)
highestfloor = *rover->topheight;
else if (*rover->topheight > lowestfloor)
lowestfloor = *rover->topheight;
if (topheight > highestfloor) {
highestfloor = topheight;
#ifdef ESLOPE
floorslope = *rover->t_slope;
#endif
}
else if (topheight > lowestfloor)
lowestfloor = topheight;
}
}
@ -653,13 +732,21 @@ void P_LineOpening(line_t *linedef)
delta1 = abs(tmthing->z - (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight)/2)));
delta2 = abs(thingtop - (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight)/2)));
if (polysec->floorheight < lowestceiling && delta1 >= delta2)
if (polysec->floorheight < lowestceiling && delta1 >= delta2) {
lowestceiling = polysec->floorheight;
#ifdef ESLOPE
ceilingslope = NULL;
#endif
}
else if (polysec->floorheight < highestceiling && delta1 >= delta2)
highestceiling = polysec->floorheight;
if (polysec->ceilingheight > highestfloor && delta1 < delta2)
if (polysec->ceilingheight > highestfloor && delta1 < delta2) {
highestfloor = polysec->ceilingheight;
#ifdef ESLOPE
floorslope = NULL;
#endif
}
else if (polysec->ceilingheight > lowestfloor && delta1 < delta2)
lowestfloor = polysec->ceilingheight;
}
@ -667,11 +754,19 @@ void P_LineOpening(line_t *linedef)
if (highestceiling < highceiling)
highceiling = highestceiling;
if (highestfloor > openbottom)
if (highestfloor > openbottom) {
openbottom = highestfloor;
#ifdef ESLOPE
openbottomslope = floorslope;
#endif
}
if (lowestceiling < opentop)
if (lowestceiling < opentop) {
opentop = lowestceiling;
#ifdef ESLOPE
opentopslope = ceilingslope;
#endif
}
if (lowestfloor > lowfloor)
lowfloor = lowestfloor;
@ -769,6 +864,7 @@ void P_SetThingPosition(mobj_t *thing)
{ // link into subsector
subsector_t *ss;
sector_t *oldsec = NULL;
fixed_t tfloorz, tceilz;
I_Assert(thing != NULL);
I_Assert(!P_MobjWasRemoved(thing));
@ -838,12 +934,15 @@ void P_SetThingPosition(mobj_t *thing)
// sector's floor is the same height.
if (thing->player && oldsec != NULL && thing->subsector && oldsec != thing->subsector->sector)
{
tfloorz = P_GetFloorZ(thing, ss->sector, thing->x, thing->y, NULL);
tceilz = P_GetCeilingZ(thing, ss->sector, thing->x, thing->y, NULL);
if (thing->eflags & MFE_VERTICALFLIP)
{
if (thing->z + thing->height >= thing->subsector->sector->ceilingheight)
if (thing->z + thing->height >= tceilz)
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
}
else if (thing->z <= thing->subsector->sector->floorheight)
else if (thing->z <= tfloorz)
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
}
}

View File

@ -55,6 +55,9 @@ void P_CreatePrecipSecNodeList(precipmobj_t *thing, fixed_t x,fixed_t y);
boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y);
extern fixed_t opentop, openbottom, openrange, lowfloor, highceiling;
#ifdef ESLOPE
extern pslope_t *opentopslope, *openbottomslope;
#endif
void P_LineOpening(line_t *plinedef);

File diff suppressed because it is too large Load Diff

View File

@ -235,6 +235,8 @@ typedef enum
MFE_PUSHED = 1<<7,
// Mobj was already sprung this tic
MFE_SPRUNG = 1<<8,
// Platform movement
MFE_APPLYPMOMZ = 1<<9,
// free: to and including 1<<15
} mobjeflag_t;
@ -352,6 +354,10 @@ typedef struct mobj_s
INT32 cusval;
INT32 cvmem;
#ifdef ESLOPE
struct pslope_s *standingslope; // The slope that the object is standing on (shouldn't need synced in savegames, right?)
#endif
// WARNING: New fields must be added separately to savegame and Lua.
} mobj_t;

View File

@ -30,6 +30,9 @@
#include "r_sky.h"
#include "p_polyobj.h"
#include "lua_script.h"
#ifdef ESLOPE
#include "p_slopes.h"
#endif
savedata_t savedata;
UINT8 *save_p;
@ -633,7 +636,7 @@ static void P_NetArchiveWorld(void)
if (li->special != SHORT(mld->special))
diff |= LD_SPECIAL;
if (mld->special == 321 || mld->special == 322) // only reason li->callcount would be non-zero is if either of these are involved
if (SHORT(mld->special) == 321 || SHORT(mld->special) == 322) // only reason li->callcount would be non-zero is if either of these are involved
diff |= LD_CLLCOUNT;
if (li->sidenum[0] != 0xffff)
@ -921,7 +924,8 @@ typedef enum
MD2_EXTVAL1 = 1<<5,
MD2_EXTVAL2 = 1<<6,
MD2_HNEXT = 1<<7,
MD2_HPREV = 1<<8
MD2_HPREV = 1<<8,
MD2_SLOPE = 1<<9
} mobj_diff2_t;
typedef enum
@ -1109,6 +1113,8 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type)
diff2 |= MD2_HNEXT;
if (mobj->hprev)
diff2 |= MD2_HPREV;
if (mobj->standingslope)
diff2 |= MD2_SLOPE;
if (diff2 != 0)
diff |= MD_MORE;
@ -1221,6 +1227,8 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type)
WRITEUINT32(save_p, mobj->hnext->mobjnum);
if (diff2 & MD2_HPREV)
WRITEUINT32(save_p, mobj->hprev->mobjnum);
if (diff2 & MD2_SLOPE)
WRITEUINT16(save_p, mobj->standingslope->id);
WRITEUINT32(save_p, mobj->mobjnum);
}
@ -2068,6 +2076,9 @@ static void LoadMobjThinker(actionf_p1 thinker)
mobj->hnext = (mobj_t *)(size_t)READUINT32(save_p);
if (diff2 & MD2_HPREV)
mobj->hprev = (mobj_t *)(size_t)READUINT32(save_p);
if (diff2 & MD2_SLOPE)
mobj->standingslope = P_SlopeById(READUINT16(save_p));
if (diff & MD_REDFLAG)
{

View File

@ -72,6 +72,10 @@
#include "hardware/hw_light.h"
#endif
#ifdef ESLOPE
#include "p_slopes.h"
#endif
//
// Map MD5, calculated on level load.
// Sent to clients in PT_SERVERINFO.
@ -846,7 +850,7 @@ void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum)
//
// P_LoadThings
//
static void P_LoadThings(lumpnum_t lumpnum)
static void P_PrepareThings(lumpnum_t lumpnum)
{
size_t i;
mapthing_t *mt;
@ -884,13 +888,27 @@ static void P_LoadThings(lumpnum_t lumpnum)
}
Z_Free(datastart);
}
static void P_LoadThings(void)
{
size_t i;
mapthing_t *mt;
// Loading the things lump itself into memory is now handled in P_PrepareThings, above
mt = mapthings;
numhuntemeralds = 0;
for (i = 0; i < nummapthings; i++, mt++)
{
sector_t *mtsector = R_PointInSubsector(mt->x << FRACBITS, mt->y << FRACBITS)->sector;
// Z for objects
mt->z = (INT16)(R_PointInSubsector(mt->x << FRACBITS, mt->y << FRACBITS)
->sector->floorheight>>FRACBITS);
mt->z = (INT16)(
#ifdef ESLOPE
mtsector->f_slope ? P_GetZAt(mtsector->f_slope, mt->x << FRACBITS, mt->y << FRACBITS) :
#endif
mtsector->floorheight)>>FRACBITS;
if (mt->type == 1700 // MT_AXIS
|| mt->type == 1701 // MT_AXISTRANSFER
@ -2114,7 +2132,8 @@ void P_LoadThingsOnly(void)
P_LevelInitStuff();
P_LoadThings(lastloadedmaplumpnum + ML_THINGS);
P_PrepareThings(lastloadedmaplumpnum + ML_THINGS);
P_LoadThings();
P_SpawnSecretItems(true);
}
@ -2531,7 +2550,13 @@ boolean P_SetupLevel(boolean skipprecip)
P_MapStart();
P_LoadThings(lastloadedmaplumpnum + ML_THINGS);
P_PrepareThings(lastloadedmaplumpnum + ML_THINGS);
#ifdef ESLOPE
P_ResetDynamicSlopes();
#endif
P_LoadThings();
P_SpawnSecretItems(loademblems);

1139
src/p_slopes.c Normal file

File diff suppressed because it is too large Load Diff

80
src/p_slopes.h Normal file
View File

@ -0,0 +1,80 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright(C) 2004 Stephen McGranahan
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
//--------------------------------------------------------------------------
//
// DESCRIPTION:
// Slopes
// SoM created 05/10/09
//
//-----------------------------------------------------------------------------
#ifndef P_SLOPES_H__
#define P_SLOPES_H__
#ifdef ESLOPE
void P_ResetDynamicSlopes(void);
void P_RunDynamicSlopes(void);
// P_SpawnSlope_Line
// Creates one or more slopes based on the given line type and front/back
// sectors.
void P_SpawnSlope_Line(int linenum);
#ifdef SPRINGCLEAN
// Loads just map objects that make slopes,
// terrain affecting objects have to be spawned first
void P_SetSlopesFromVertexHeights(lumpnum_t lumpnum);
typedef 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,
} slopething_e;
#endif
//
// P_CopySectorSlope
//
// Searches through tagged sectors and copies
//
void P_CopySectorSlope(line_t *line);
pslope_t *P_SlopeById(UINT16 id);
// Returns the height of the sloped plane at (x, y) as a fixed_t
fixed_t P_GetZAt(pslope_t *slope, fixed_t x, fixed_t y);
// Lots of physics-based bullshit
void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope);
void P_SlopeLaunch(mobj_t *mo);
void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope);
void P_ButteredSlope(mobj_t *mo);
#endif
// EOF
#endif // #ifdef ESLOPE

View File

@ -29,6 +29,7 @@
#include "r_main.h" //Two extra includes.
#include "r_sky.h"
#include "p_polyobj.h"
#include "p_slopes.h"
#include "hu_stuff.h"
#include "m_misc.h"
#include "m_cond.h" //unlock triggers
@ -3365,6 +3366,7 @@ sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 n
static boolean P_ThingIsOnThe3DFloor(mobj_t *mo, sector_t *sector, sector_t *targetsec)
{
ffloor_t *rover;
fixed_t top, bottom;
if (!mo->player) // should NEVER happen
return false;
@ -3381,6 +3383,9 @@ static boolean P_ThingIsOnThe3DFloor(mobj_t *mo, sector_t *sector, sector_t *tar
//if (!(rover->flags & FF_EXISTS))
// return false;
top = P_GetSpecialTopZ(mo, sector, targetsec);
bottom = P_GetSpecialBottomZ(mo, sector, targetsec);
// Check the 3D floor's type...
if (rover->flags & FF_BLOCKPLAYER)
{
@ -3388,27 +3393,27 @@ static boolean P_ThingIsOnThe3DFloor(mobj_t *mo, sector_t *sector, sector_t *tar
if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)
&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING))
{
if ((mo->eflags & MFE_VERTICALFLIP) || mo->z != *rover->topheight)
if ((mo->eflags & MFE_VERTICALFLIP) || mo->z != top)
return false;
}
else if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING)
&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR))
{
if (!(mo->eflags & MFE_VERTICALFLIP)
|| mo->z + mo->height != *rover->bottomheight)
|| mo->z + mo->height != bottom)
return false;
}
else if (rover->master->frontsector->flags & SF_FLIPSPECIAL_BOTH)
{
if (!((mo->eflags & MFE_VERTICALFLIP && mo->z + mo->height == *rover->bottomheight)
|| (!(mo->eflags & MFE_VERTICALFLIP) && mo->z == *rover->topheight)))
if (!((mo->eflags & MFE_VERTICALFLIP && mo->z + mo->height == bottom)
|| (!(mo->eflags & MFE_VERTICALFLIP) && mo->z == top)))
return false;
}
}
else
{
// Water and intangible FOFs
if (mo->z > *rover->topheight || (mo->z + mo->height) < *rover->bottomheight)
if (mo->z > top || (mo->z + mo->height) < bottom)
return false;
}
@ -3426,9 +3431,9 @@ static boolean P_ThingIsOnThe3DFloor(mobj_t *mo, sector_t *sector, sector_t *tar
static inline boolean P_MobjReadyToTrigger(mobj_t *mo, sector_t *sec)
{
if (mo->eflags & MFE_VERTICALFLIP)
return (mo->z+mo->height == sec->ceilingheight && sec->flags & SF_FLIPSPECIAL_CEILING);
return (mo->z+mo->height == P_GetSpecialTopZ(mo, sec, sec) && sec->flags & SF_FLIPSPECIAL_CEILING);
else
return (mo->z == sec->floorheight && sec->flags & SF_FLIPSPECIAL_FLOOR);
return (mo->z == P_GetSpecialBottomZ(mo, sec, sec) && sec->flags & SF_FLIPSPECIAL_FLOOR);
}
/** Applies a sector special to a player.
@ -4389,27 +4394,27 @@ static void P_PlayerOnSpecial3DFloor(player_t *player, sector_t *sector)
if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)
&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING))
{
if ((player->mo->eflags & MFE_VERTICALFLIP) || player->mo->z != *rover->topheight)
if ((player->mo->eflags & MFE_VERTICALFLIP) || player->mo->z != P_GetSpecialTopZ(player->mo, sectors + rover->secnum, sector))
continue;
}
else if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING)
&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR))
{
if (!(player->mo->eflags & MFE_VERTICALFLIP)
|| player->mo->z + player->mo->height != *rover->bottomheight)
|| player->mo->z + player->mo->height != P_GetSpecialBottomZ(player->mo, sectors + rover->secnum, sector))
continue;
}
else if (rover->master->frontsector->flags & SF_FLIPSPECIAL_BOTH)
{
if (!((player->mo->eflags & MFE_VERTICALFLIP && player->mo->z + player->mo->height == *rover->bottomheight)
|| (!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z == *rover->topheight)))
if (!((player->mo->eflags & MFE_VERTICALFLIP && player->mo->z + player->mo->height == P_GetSpecialBottomZ(player->mo, sectors + rover->secnum, sector))
|| (!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z == P_GetSpecialTopZ(player->mo, sectors + rover->secnum, sector))))
continue;
}
}
else
{
// Water and DEATH FOG!!! heh
if (player->mo->z > *rover->topheight || (player->mo->z + player->mo->height) < *rover->bottomheight)
if (player->mo->z > P_GetSpecialTopZ(player->mo, sectors + rover->secnum, sector) || (player->mo->z + player->mo->height) < P_GetSpecialBottomZ(player->mo, sectors + rover->secnum, sector))
continue;
}
@ -4519,6 +4524,7 @@ static void P_PlayerOnSpecial3DFloor(player_t *player, sector_t *sector)
static void P_RunSpecialSectorCheck(player_t *player, sector_t *sector)
{
boolean nofloorneeded = false;
fixed_t f_affectpoint, c_affectpoint;
if (!sector->special) // nothing special, exit
return;
@ -4581,16 +4587,19 @@ static void P_RunSpecialSectorCheck(player_t *player, sector_t *sector)
return;
}
f_affectpoint = P_GetSpecialBottomZ(player->mo, sector, sector);
c_affectpoint = P_GetSpecialTopZ(player->mo, sector, sector);
// Only go further if on the ground
if ((sector->flags & SF_FLIPSPECIAL_FLOOR) && !(sector->flags & SF_FLIPSPECIAL_CEILING) && player->mo->z != sector->floorheight)
if ((sector->flags & SF_FLIPSPECIAL_FLOOR) && !(sector->flags & SF_FLIPSPECIAL_CEILING) && player->mo->z != f_affectpoint)
return;
if ((sector->flags & SF_FLIPSPECIAL_CEILING) && !(sector->flags & SF_FLIPSPECIAL_FLOOR) && player->mo->z + player->mo->height != sector->ceilingheight)
if ((sector->flags & SF_FLIPSPECIAL_CEILING) && !(sector->flags & SF_FLIPSPECIAL_FLOOR) && player->mo->z + player->mo->height != c_affectpoint)
return;
if ((sector->flags & SF_FLIPSPECIAL_BOTH)
&& player->mo->z != sector->floorheight
&& player->mo->z + player->mo->height != sector->ceilingheight)
&& player->mo->z != f_affectpoint
&& player->mo->z + player->mo->height != c_affectpoint)
return;
P_ProcessSpecialSector(player, sector, NULL);
@ -4639,118 +4648,26 @@ void P_PlayerInSpecialSector(player_t *player)
/** Animate planes, scroll walls, etc. and keeps track of level timelimit and exits if time is up.
*
* \sa cv_timelimit, P_CheckPointLimit
* \sa P_CheckTimeLimit, P_CheckPointLimit
*/
void P_UpdateSpecials(void)
{
anim_t *anim;
INT32 i, k;
INT32 i;
INT32 pic;
size_t j;
levelflat_t *foundflats; // for flat animation
// LEVEL TIMER
// Exit if the timer is equal to or greater the timelimit, unless you are
// in overtime. In which case leveltime may stretch out beyond timelimitintics
// and overtime's status will be checked here each tick.
if (cv_timelimit.value && timelimitintics <= leveltime && (multiplayer || netgame)
&& G_RingSlingerGametype() && (gameaction != ga_completed))
{
boolean pexit = false;
//Tagmode round end but only on the tic before the
//XD_EXITLEVEL packet is recieved by all players.
if (G_TagGametype())
{
if (leveltime == (timelimitintics + 1))
{
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i] || players[i].spectator
|| (players[i].pflags & PF_TAGGED) || (players[i].pflags & PF_TAGIT))
continue;
CONS_Printf(M_GetText("%s recieved double points for surviving the round.\n"), player_names[i]);
P_AddPlayerScore(&players[i], players[i].score);
}
}
pexit = true;
}
//Optional tie-breaker for Match/CTF
else if (G_RingSlingerGametype() && cv_overtime.value)
{
INT32 playerarray[MAXPLAYERS];
INT32 tempplayer = 0;
INT32 spectators = 0;
INT32 playercount = 0;
//Figure out if we have enough participating players to care.
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i] && players[i].spectator)
spectators++;
}
if ((D_NumPlayers() - spectators) > 1)
{
// Play the starpost sfx after the first second of overtime.
if (gamestate == GS_LEVEL && (leveltime == (timelimitintics + TICRATE)))
S_StartSound(NULL, sfx_strpst);
// Normal Match
if (!G_GametypeHasTeams())
{
//Store the nodes of participating players in an array.
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i] && !players[i].spectator)
{
playerarray[playercount] = i;
playercount++;
}
}
//Sort 'em.
for (i = 1; i < playercount; i++)
{
for (k = i; k < playercount; k++)
{
if (players[playerarray[i-1]].score < players[playerarray[k]].score)
{
tempplayer = playerarray[i-1];
playerarray[i-1] = playerarray[k];
playerarray[k] = tempplayer;
}
}
}
//End the round if the top players aren't tied.
if (!(players[playerarray[0]].score == players[playerarray[1]].score))
pexit = true;
}
else
{
//In team match and CTF, determining a tie is much simpler. =P
if (!(redscore == bluescore))
pexit = true;
}
}
else
pexit = true;
}
else
pexit = true;
if (server && pexit)
SendNetXCmd(XD_EXITLEVEL, NULL, 0);
}
P_CheckTimeLimit();
// POINT LIMIT
P_CheckPointLimit();
// Dynamic slopeness
P_RunDynamicSlopes();
// ANIMATE TEXTURES
for (anim = anims; anim < lastanim; anim++)
{
@ -4894,6 +4811,12 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f
ffloor->topyoffs = &sec2->ceiling_yoffs;
ffloor->topangle = &sec2->ceilingpic_angle;
#ifdef ESLOPE
// Add slopes
ffloor->t_slope = &sec2->c_slope;
ffloor->b_slope = &sec2->f_slope;
#endif
if ((flags & FF_SOLID) && (master->flags & ML_EFFECT1)) // Block player only
flags &= ~FF_BLOCKOTHERS;
@ -5327,6 +5250,7 @@ void T_LaserFlash(laserthink_t *flash)
sector_t *sourcesec;
ffloor_t *ffloor = flash->ffloor;
sector_t *sector = flash->sector;
fixed_t top, bottom;
if (!ffloor || !(ffloor->flags & FF_EXISTS))
return;
@ -5350,8 +5274,11 @@ void T_LaserFlash(laserthink_t *flash)
&& thing->flags & MF_BOSS)
continue; // Don't hurt bosses
if (thing->z >= sourcesec->ceilingheight
|| thing->z + thing->height <= sourcesec->floorheight)
top = P_GetSpecialTopZ(thing, sourcesec, sector);
bottom = P_GetSpecialBottomZ(thing, sourcesec, sector);
if (thing->z >= top
|| thing->z + thing->height <= bottom)
continue;
if (thing->flags & MF_SHOOTABLE)
@ -6430,6 +6357,14 @@ void P_SpawnSpecials(INT32 fromnetsave)
sectors[s].midmap = lines[i].frontsector->midmap;
break;
#ifdef ESLOPE // Slope copy specials. Handled here for sanity.
case 720:
case 721:
case 722:
P_CopySectorSlope(&lines[i]);
break;
#endif
default:
break;
}
@ -6634,6 +6569,8 @@ void T_Scroll(scroll_t *s)
if (thing->eflags & MFE_PUSHED) // Already pushed this tic by an exclusive pusher.
continue;
height = P_GetSpecialBottomZ(thing, sec, psec);
if (!(thing->flags & MF_NOCLIP)) // Thing must be clipped
if (!(thing->flags & MF_NOGRAVITY || thing->z+thing->height != height)) // Thing must a) be non-floating and have z+height == height
{
@ -6654,6 +6591,8 @@ void T_Scroll(scroll_t *s)
if (thing->eflags & MFE_PUSHED)
continue;
height = P_GetSpecialBottomZ(thing, sec, sec);
if (!(thing->flags & MF_NOCLIP) &&
(!(thing->flags & MF_NOGRAVITY || thing->z > height)))
{
@ -6693,6 +6632,8 @@ void T_Scroll(scroll_t *s)
if (thing->eflags & MFE_PUSHED)
continue;
height = P_GetSpecialTopZ(thing, sec, psec);
if (!(thing->flags & MF_NOCLIP)) // Thing must be clipped
if (!(thing->flags & MF_NOGRAVITY || thing->z != height))// Thing must a) be non-floating and have z == height
{
@ -6713,6 +6654,8 @@ void T_Scroll(scroll_t *s)
if (thing->eflags & MFE_PUSHED)
continue;
height = P_GetSpecialTopZ(thing, sec, sec);
if (!(thing->flags & MF_NOCLIP) &&
(!(thing->flags & MF_NOGRAVITY || thing->z+thing->height < height)))
{
@ -7006,7 +6949,7 @@ static void Add_Friction(INT32 friction, INT32 movefactor, INT32 affectee, INT32
*/
void T_Friction(friction_t *f)
{
sector_t *sec;
sector_t *sec, *referrer = NULL;
mobj_t *thing;
msecnode_t *node;
@ -7015,7 +6958,7 @@ void T_Friction(friction_t *f)
// Make sure the sector type hasn't changed
if (f->roverfriction)
{
sector_t *referrer = sectors + f->referrer;
referrer = sectors + f->referrer;
if (!(GETSECSPECIAL(referrer->special, 3) == 1
|| GETSECSPECIAL(referrer->special, 3) == 3))
@ -7047,9 +6990,7 @@ void T_Friction(friction_t *f)
{
if (f->roverfriction)
{
sector_t *referrer = &sectors[f->referrer];
if (thing->floorz != referrer->ceilingheight)
if (thing->floorz != P_GetSpecialTopZ(thing, referrer, sec))
{
node = node->m_snext;
continue;
@ -7062,7 +7003,7 @@ void T_Friction(friction_t *f)
thing->movefactor = f->movefactor;
}
}
else if (sec->floorheight == thing->floorz && (thing->friction == ORIG_FRICTION // normal friction?
else if (P_GetSpecialBottomZ(thing, sec, sec) == thing->floorz && (thing->friction == ORIG_FRICTION // normal friction?
|| f->friction < thing->friction))
{
thing->friction = f->friction;
@ -7336,7 +7277,7 @@ static inline boolean PIT_PushThing(mobj_t *thing)
*/
void T_Pusher(pusher_t *p)
{
sector_t *sec;
sector_t *sec, *referrer = NULL;
mobj_t *thing;
msecnode_t *node;
INT32 xspeed = 0,yspeed = 0;
@ -7345,7 +7286,6 @@ void T_Pusher(pusher_t *p)
//INT32 ht = 0;
boolean inFOF;
boolean touching;
boolean foundfloor = false;
boolean moved;
xspeed = yspeed = 0;
@ -7357,19 +7297,16 @@ void T_Pusher(pusher_t *p)
if (p->roverpusher)
{
sector_t *referrer = &sectors[p->referrer];
referrer = &sectors[p->referrer];
if (GETSECSPECIAL(referrer->special, 3) == 2
|| GETSECSPECIAL(referrer->special, 3) == 3)
foundfloor = true;
if (!(GETSECSPECIAL(referrer->special, 3) == 2
|| GETSECSPECIAL(referrer->special, 3) == 3))
return;
}
else if (!(GETSECSPECIAL(sec->special, 3) == 2
|| GETSECSPECIAL(sec->special, 3) == 3))
return;
if (p->roverpusher && foundfloor == false) // Not even a 3d floor has the PUSH_MASK.
return;
// For constant pushers (wind/current) there are 3 situations:
//
// 1) Affected Thing is above the floor.
@ -7444,41 +7381,38 @@ void T_Pusher(pusher_t *p)
// Find the area that the 'thing' is in
if (p->roverpusher)
{
sector_t *referrer = &sectors[p->referrer];
INT32 special;
fixed_t top, bottom;
special = GETSECSPECIAL(referrer->special, 3);
if (!(special == 2 || special == 3))
return;
top = P_GetSpecialTopZ(thing, referrer, sec);
bottom = P_GetSpecialBottomZ(thing, referrer, sec);
if (thing->eflags & MFE_VERTICALFLIP)
{
if (referrer->floorheight > thing->z + thing->height
|| referrer->ceilingheight < (thing->z + (thing->height >> 1)))
if (bottom > thing->z + thing->height
|| top < (thing->z + (thing->height >> 1)))
continue;
if (thing->z < referrer->floorheight)
if (thing->z < bottom)
touching = true;
if (thing->z + (thing->height >> 1) > referrer->floorheight)
if (thing->z + (thing->height >> 1) > bottom)
inFOF = true;
}
else
{
if (referrer->ceilingheight < thing->z || referrer->floorheight > (thing->z + (thing->height >> 1)))
if (top < thing->z || referrer->floorheight > (thing->z + (thing->height >> 1)))
continue;
if (thing->z + thing->height > referrer->ceilingheight)
if (thing->z + thing->height > top)
touching = true;
if (thing->z + (thing->height >> 1) < referrer->ceilingheight)
if (thing->z + (thing->height >> 1) < top)
inFOF = true;
}
}
else // Treat the entire sector as one big FOF
{
if (thing->z == thing->subsector->sector->floorheight)
if (thing->z == P_GetSpecialBottomZ(thing, sec, sec))
touching = true;
else if (p->type != p_current)
inFOF = true;

View File

@ -29,6 +29,7 @@
#include "m_random.h"
#include "m_misc.h"
#include "i_video.h"
#include "p_slopes.h"
#include "p_spec.h"
#include "r_splats.h"
#include "z_zone.h"
@ -1212,7 +1213,7 @@ boolean P_IsObjectOnGroundIn(mobj_t *mo, sector_t *sec)
if (mo->eflags & MFE_VERTICALFLIP)
{
// Detect if the player is on the ceiling.
if (mo->z+mo->height >= sec->ceilingheight)
if (mo->z+mo->height >= P_GetSpecialTopZ(mo, sec, sec))
return true;
// Otherwise, detect if the player is on the bottom of a FOF.
else
@ -1236,7 +1237,7 @@ boolean P_IsObjectOnGroundIn(mobj_t *mo, sector_t *sec)
continue;
// Actually check if the player is on the suitable FOF.
if (mo->z+mo->height == *rover->bottomheight)
if (mo->z+mo->height == P_GetSpecialBottomZ(mo, sectors + rover->secnum, sec))
return true;
}
}
@ -1245,7 +1246,7 @@ boolean P_IsObjectOnGroundIn(mobj_t *mo, sector_t *sec)
else
{
// Detect if the player is on the floor.
if (mo->z <= sec->floorheight)
if (mo->z <= P_GetSpecialBottomZ(mo, sec, sec))
return true;
// Otherwise, detect if the player is on the top of a FOF.
else
@ -1269,7 +1270,7 @@ boolean P_IsObjectOnGroundIn(mobj_t *mo, sector_t *sec)
continue;
// Actually check if the player is on the suitable FOF.
if (mo->z == *rover->topheight)
if (mo->z == P_GetSpecialTopZ(mo, sectors + rover->secnum, sec))
return true;
}
}
@ -1789,6 +1790,9 @@ static void P_CheckBouncySectors(player_t *player)
fixed_t oldx;
fixed_t oldy;
fixed_t oldz;
#ifdef ESLOPE
vector3_t momentum;
#endif
oldx = player->mo->x;
oldy = player->mo->y;
@ -1809,16 +1813,21 @@ static void P_CheckBouncySectors(player_t *player)
{
ffloor_t *rover;
boolean top = true;
fixed_t topheight, bottomheight;
for (rover = node->m_sector->ffloors; rover; rover = rover->next)
{
if (player->mo->z > *rover->topheight)
topheight = P_GetFOFTopZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL);
bottomheight = P_GetFOFBottomZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL);
if (player->mo->z > topheight)
continue;
if (player->mo->z + player->mo->height < *rover->bottomheight)
if (player->mo->z + player->mo->height < bottomheight)
continue;
if (oldz < *rover->topheight && oldz > *rover->bottomheight)
if (oldz < P_GetFOFTopZ(player->mo, node->m_sector, rover, oldx, oldy, NULL)
&& oldz + player->mo->height > P_GetFOFBottomZ(player->mo, node->m_sector, rover, oldx, oldy, NULL))
top = false;
if (GETSECSPECIAL(rover->master->frontsector->special, 1) == 15)
@ -1833,7 +1842,29 @@ static void P_CheckBouncySectors(player_t *player)
{
fixed_t newmom;
#ifdef ESLOPE
pslope_t *slope;
if (abs(oldz - topheight) < abs(oldz + player->mo->height - bottomheight)) { // Hit top
slope = *rover->t_slope;
} else { // Hit bottom
slope = *rover->b_slope;
}
momentum.x = player->mo->momx;
momentum.y = player->mo->momy;
momentum.z = player->mo->momz*2;
if (slope) {
// Reverse quantizing might could use its own function later
slope->zangle = ANGLE_MAX-slope->zangle;
P_QuantizeMomentumToSlope(&momentum, slope);
slope->zangle = ANGLE_MAX-slope->zangle;
}
newmom = momentum.z = -FixedMul(momentum.z,linedist)/2;
#else
newmom = -FixedMul(player->mo->momz,linedist);
#endif
if (abs(newmom) < (linedist*2))
{
@ -1856,7 +1887,18 @@ static void P_CheckBouncySectors(player_t *player)
else if (newmom < -P_GetPlayerHeight(player)/2)
newmom = -P_GetPlayerHeight(player)/2;
#ifdef ESLOPE
momentum.z = newmom*2;
if (slope)
P_QuantizeMomentumToSlope(&momentum, slope);
player->mo->momx = momentum.x;
player->mo->momy = momentum.y;
player->mo->momz = momentum.z/2;
#else
player->mo->momz = newmom;
#endif
if (player->pflags & PF_SPINNING)
{
@ -2078,30 +2120,7 @@ static void P_CheckInvincibilityTimer(player_t *player)
player->mo->color = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1)));
else if (leveltime % (TICRATE/7) == 0)
{
fixed_t destx, desty;
mobj_t *sparkle;
if (!splitscreen && rendermode != render_soft)
{
angle_t viewingangle;
if (players[displayplayer].awayviewtics)
viewingangle = R_PointToAngle2(player->mo->x, player->mo->y, players[displayplayer].awayviewmobj->x, players[displayplayer].awayviewmobj->y);
else if (!camera.chase && players[displayplayer].mo)
viewingangle = R_PointToAngle2(player->mo->x, player->mo->y, players[displayplayer].mo->x, players[displayplayer].mo->y);
else
viewingangle = R_PointToAngle2(player->mo->x, player->mo->y, camera.x, camera.y);
destx = player->mo->x + P_ReturnThrustX(player->mo, viewingangle, FixedMul(FRACUNIT, player->mo->scale));
desty = player->mo->y + P_ReturnThrustY(player->mo, viewingangle, FixedMul(FRACUNIT, player->mo->scale));
}
else
{
destx = player->mo->x;
desty = player->mo->y;
}
sparkle = P_SpawnMobj(destx, desty, player->mo->z, MT_IVSP);
mobj_t *sparkle = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_IVSP);
sparkle->destscale = player->mo->scale;
P_SetScale(sparkle, player->mo->scale);
}
@ -2276,14 +2295,27 @@ static void P_DoClimbing(player_t *player)
boolean thrust;
boolean boostup;
boolean skyclimber;
fixed_t floorheight, ceilingheight; // ESLOPE
thrust = false;
floorclimb = false;
boostup = false;
skyclimber = false;
#ifdef ESLOPE
floorheight = glidesector->sector->f_slope ? P_GetZAt(glidesector->sector->f_slope, player->mo->x, player->mo->y)
: glidesector->sector->floorheight;
ceilingheight = glidesector->sector->c_slope ? P_GetZAt(glidesector->sector->c_slope, player->mo->x, player->mo->y)
: glidesector->sector->ceilingheight;
#else
floorheight = glidesector->sector->floorheight;
ceilingheight = glidesector->sector->ceilingheight;
#endif
if (glidesector->sector->ffloors)
{
ffloor_t *rover;
fixed_t topheight, bottomheight; // ESLOPE
for (rover = glidesector->sector->ffloors; rover; rover = rover->next)
{
if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP))
@ -2291,13 +2323,21 @@ static void P_DoClimbing(player_t *player)
floorclimb = true;
#ifdef ESLOPE
bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight;
topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight;
#else
bottomheight = *rover->bottomheight;
topheight = *rover->topheight;
#endif
// Only supports rovers that are moving like an 'elevator', not just the top or bottom.
if (rover->master->frontsector->floorspeed && rover->master->frontsector->ceilspeed == 42)
{
if ((!(player->mo->eflags & MFE_VERTICALFLIP) && (*rover->bottomheight < player->mo->z+player->mo->height)
&& (*rover->topheight >= player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale)))
|| ((player->mo->eflags & MFE_VERTICALFLIP) && (*rover->topheight > player->mo->z)
&& (*rover->bottomheight <= player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale))))
if ((!(player->mo->eflags & MFE_VERTICALFLIP) && (bottomheight < player->mo->z+player->mo->height)
&& (topheight >= player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale)))
|| ((player->mo->eflags & MFE_VERTICALFLIP) && (topheight > player->mo->z)
&& (bottomheight <= player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale))))
{
if (cmd->forwardmove != 0)
player->mo->momz += rover->master->frontsector->floorspeed;
@ -2313,8 +2353,9 @@ static void P_DoClimbing(player_t *player)
if (player->mo->eflags & MFE_VERTICALFLIP)
{
// Trying to climb down past the bottom of the FOF
if ((*rover->topheight >= player->mo->z + player->mo->height) && ((player->mo->z + player->mo->height + player->mo->momz) >= *rover->topheight))
if ((topheight >= player->mo->z + player->mo->height) && ((player->mo->z + player->mo->height + player->mo->momz) >= topheight))
{
fixed_t bottomheight2;
ffloor_t *roverbelow;
boolean foundfof = false;
floorclimb = true;
@ -2329,7 +2370,13 @@ static void P_DoClimbing(player_t *player)
if (roverbelow == rover)
continue;
if (*roverbelow->bottomheight < *rover->topheight + FixedMul(16*FRACUNIT, player->mo->scale))
#ifdef ESLOPE
bottomheight2 = *roverbelow->b_slope ? P_GetZAt(*roverbelow->b_slope, player->mo->x, player->mo->y) : *roverbelow->bottomheight;
#else
bottomheight2 = *roverbelow->bottomheight;
#endif
if (bottomheight2 < topheight + FixedMul(16*FRACUNIT, player->mo->scale))
foundfof = true;
}
@ -2338,7 +2385,7 @@ static void P_DoClimbing(player_t *player)
}
// Below the FOF
if (*rover->topheight <= player->mo->z)
if (topheight <= player->mo->z)
{
floorclimb = false;
boostup = false;
@ -2346,7 +2393,7 @@ static void P_DoClimbing(player_t *player)
}
// Above the FOF
if (*rover->bottomheight > player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale))
if (bottomheight > player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale))
{
floorclimb = false;
thrust = true;
@ -2356,8 +2403,9 @@ static void P_DoClimbing(player_t *player)
else
{
// Trying to climb down past the bottom of a FOF
if ((*rover->bottomheight <= player->mo->z) && ((player->mo->z + player->mo->momz) <= *rover->bottomheight))
if ((bottomheight <= player->mo->z) && ((player->mo->z + player->mo->momz) <= bottomheight))
{
fixed_t topheight2;
ffloor_t *roverbelow;
boolean foundfof = false;
floorclimb = true;
@ -2372,7 +2420,13 @@ static void P_DoClimbing(player_t *player)
if (roverbelow == rover)
continue;
if (*roverbelow->topheight > *rover->bottomheight - FixedMul(16*FRACUNIT, player->mo->scale))
#ifdef ESLOPE
topheight2 = *roverbelow->t_slope ? P_GetZAt(*roverbelow->t_slope, player->mo->x, player->mo->y) : *roverbelow->topheight;
#else
topheight2 = *roverbelow->topheight;
#endif
if (topheight2 > bottomheight - FixedMul(16*FRACUNIT, player->mo->scale))
foundfof = true;
}
@ -2381,7 +2435,7 @@ static void P_DoClimbing(player_t *player)
}
// Below the FOF
if (*rover->bottomheight >= player->mo->z + player->mo->height)
if (bottomheight >= player->mo->z + player->mo->height)
{
floorclimb = false;
boostup = false;
@ -2389,7 +2443,7 @@ static void P_DoClimbing(player_t *player)
}
// Above the FOF
if (*rover->topheight < player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale))
if (topheight < player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale))
{
floorclimb = false;
thrust = true;
@ -2410,7 +2464,7 @@ static void P_DoClimbing(player_t *player)
if (player->mo->eflags & MFE_VERTICALFLIP)
{
// Trying to climb down past the upper texture area
if ((glidesector->sector->floorheight >= player->mo->z + player->mo->height) && ((player->mo->z + player->mo->height + player->mo->momz) >= glidesector->sector->floorheight))
if ((floorheight >= player->mo->z + player->mo->height) && ((player->mo->z + player->mo->height + player->mo->momz) >= floorheight))
{
boolean foundfof = false;
floorclimb = true;
@ -2418,13 +2472,20 @@ static void P_DoClimbing(player_t *player)
// Is there a FOF directly below that we can move onto?
if (glidesector->sector->ffloors)
{
fixed_t bottomheight;
ffloor_t *rover;
for (rover = glidesector->sector->ffloors; rover; rover = rover->next)
{
if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP))
continue;
if (*rover->bottomheight < glidesector->sector->floorheight + FixedMul(16*FRACUNIT, player->mo->scale))
#ifdef ESLOPE
bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight;
#else
bottomheight = *rover->bottomheight;
#endif
if (bottomheight < floorheight + FixedMul(16*FRACUNIT, player->mo->scale))
{
foundfof = true;
break;
@ -2437,8 +2498,8 @@ static void P_DoClimbing(player_t *player)
}
// Reached the top of the lower texture area
if (!floorclimb && glidesector->sector->ceilingheight > player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale)
&& (glidesector->sector->ceilingpic == skyflatnum || glidesector->sector->floorheight < (player->mo->z - FixedMul(8*FRACUNIT, player->mo->scale))))
if (!floorclimb && ceilingheight > player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale)
&& (glidesector->sector->ceilingpic == skyflatnum || floorheight < (player->mo->z - FixedMul(8*FRACUNIT, player->mo->scale))))
{
thrust = true;
boostup = true;
@ -2448,7 +2509,7 @@ static void P_DoClimbing(player_t *player)
else
{
// Trying to climb down past the upper texture area
if ((glidesector->sector->ceilingheight <= player->mo->z) && ((player->mo->z + player->mo->momz) <= glidesector->sector->ceilingheight))
if ((ceilingheight <= player->mo->z) && ((player->mo->z + player->mo->momz) <= ceilingheight))
{
boolean foundfof = false;
floorclimb = true;
@ -2462,7 +2523,7 @@ static void P_DoClimbing(player_t *player)
if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP))
continue;
if (*rover->topheight > glidesector->sector->ceilingheight - FixedMul(16*FRACUNIT, player->mo->scale))
if (*rover->topheight > ceilingheight - FixedMul(16*FRACUNIT, player->mo->scale))
{
foundfof = true;
break;
@ -2475,7 +2536,7 @@ static void P_DoClimbing(player_t *player)
}
// Allow climbing from a FOF or lower texture onto the upper texture and vice versa.
if (player->mo->z > glidesector->sector->ceilingheight - FixedMul(16*FRACUNIT, player->mo->scale))
if (player->mo->z > ceilingheight - FixedMul(16*FRACUNIT, player->mo->scale))
{
floorclimb = true;
thrust = false;
@ -2483,8 +2544,8 @@ static void P_DoClimbing(player_t *player)
}
// Reached the top of the lower texture area
if (!floorclimb && glidesector->sector->floorheight < player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale)
&& (glidesector->sector->ceilingpic == skyflatnum || glidesector->sector->ceilingheight > (player->mo->z + player->mo->height + FixedMul(8*FRACUNIT, player->mo->scale))))
if (!floorclimb && floorheight < player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale)
&& (glidesector->sector->ceilingpic == skyflatnum || ceilingheight > (player->mo->z + player->mo->height + FixedMul(8*FRACUNIT, player->mo->scale))))
{
thrust = true;
boostup = true;
@ -2493,14 +2554,14 @@ static void P_DoClimbing(player_t *player)
}
// Trying to climb on the sky
if ((glidesector->sector->ceilingheight < player->mo->z) && glidesector->sector->ceilingpic == skyflatnum)
if ((ceilingheight < player->mo->z) && glidesector->sector->ceilingpic == skyflatnum)
{
skyclimber = true;
}
// Climbing on the lower texture area?
if ((!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale) < glidesector->sector->floorheight)
|| ((player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z + player->mo->height <= glidesector->sector->floorheight))
if ((!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale) < floorheight)
|| ((player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z + player->mo->height <= floorheight))
{
floorclimb = true;
@ -2516,8 +2577,8 @@ static void P_DoClimbing(player_t *player)
}
}
// Climbing on the upper texture area?
else if ((!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z >= glidesector->sector->ceilingheight)
|| ((player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale) > glidesector->sector->ceilingheight))
else if ((!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z >= ceilingheight)
|| ((player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale) > ceilingheight))
{
floorclimb = true;
@ -3635,11 +3696,22 @@ void P_DoJump(player_t *player, boolean soundandstate)
// set just an eensy above the ground
if (player->mo->eflags & MFE_VERTICALFLIP)
{
player->mo->z--;
if (player->mo->pmomz < 0)
player->mo->momz += player->mo->pmomz; // Add the platform's momentum to your jump.
else
player->mo->pmomz = 0;
}
else
{
player->mo->z++;
player->mo->z += player->mo->pmomz; // Solves problem of 'hitting around again after jumping on a moving platform'.
if (player->mo->pmomz > 0)
player->mo->momz += player->mo->pmomz; // Add the platform's momentum to your jump.
else
player->mo->pmomz = 0;
}
player->mo->eflags &= ~MFE_APPLYPMOMZ;
player->pflags |= PF_JUMPED;
@ -3677,7 +3749,11 @@ static void P_DoSpinDash(player_t *player, ticcmd_t *cmd)
if ((player->charability2 == CA2_SPINDASH) && !(player->pflags & PF_SLIDING) && !player->exiting
&& !P_PlayerInPain(player)) // subsequent revs
{
if ((cmd->buttons & BT_USE) && player->speed < FixedMul(5<<FRACBITS, player->mo->scale) && !player->mo->momz && onground && !(player->pflags & PF_USEDOWN) && !(player->pflags & PF_SPINNING))
if ((cmd->buttons & BT_USE) && player->speed < FixedMul(5<<FRACBITS, player->mo->scale) && !player->mo->momz && onground && !(player->pflags & PF_USEDOWN) && !(player->pflags & PF_SPINNING)
#ifdef ESLOPE
&& (!player->mo->standingslope || abs(player->mo->standingslope->zdelta) < FRACUNIT/2)
#endif
)
{
player->mo->momx = player->cmomx;
player->mo->momy = player->cmomy;
@ -3706,7 +3782,11 @@ static void P_DoSpinDash(player_t *player, ticcmd_t *cmd)
// down the spin button and not spinning.
// AKA Just go into a spin on the ground, you idiot. ;)
else if ((cmd->buttons & BT_USE || ((twodlevel || (player->mo->flags2 & MF2_TWOD)) && cmd->forwardmove < -20))
&& !player->climbing && !player->mo->momz && onground && player->speed > FixedMul(5<<FRACBITS, player->mo->scale) && !(player->pflags & PF_USEDOWN) && !(player->pflags & PF_SPINNING))
&& !player->climbing && !player->mo->momz && onground && (player->speed > FixedMul(5<<FRACBITS, player->mo->scale)
#ifdef ESLOPE
|| (player->mo->standingslope && abs(player->mo->standingslope->zdelta) >= FRACUNIT/2)
#endif
) && !(player->pflags & PF_USEDOWN) && !(player->pflags & PF_SPINNING))
{
player->pflags |= PF_SPINNING;
P_SetPlayerMobjState(player->mo, S_PLAY_ATK1);
@ -3718,7 +3798,11 @@ static void P_DoSpinDash(player_t *player, ticcmd_t *cmd)
// Rolling normally
if (onground && player->pflags & PF_SPINNING && !(player->pflags & PF_STARTDASH)
&& player->speed < FixedMul(5*FRACUNIT,player->mo->scale))
&& player->speed < FixedMul(5*FRACUNIT,player->mo->scale)
#ifdef ESLOPE
&& (!player->mo->standingslope || abs(player->mo->standingslope->zdelta) < FRACUNIT/2)
#endif
)
{
if (GETSECSPECIAL(player->mo->subsector->sector->special, 4) == 7 || (player->mo->ceilingz - player->mo->floorz < P_GetPlayerHeight(player)))
P_InstaThrust(player->mo, player->mo->angle, FixedMul(10*FRACUNIT, player->mo->scale));
@ -4422,12 +4506,16 @@ static void P_3dMovement(player_t *player)
angle_t dangle; // replaces old quadrants bits
fixed_t normalspd = FixedMul(player->normalspeed, player->mo->scale);
boolean analogmove = false;
#ifndef OLD_MOVEMENT_CODE
fixed_t oldMagnitude, newMagnitude;
#ifdef ESLOPE
vector3_t totalthrust;
totalthrust.x = totalthrust.y = 0; // I forget if this is needed
totalthrust.z = FRACUNIT*P_MobjFlip(player->mo)/3; // A bit of extra push-back on slopes
#endif // ESLOPE
// Get the old momentum; this will be needed at the end of the function! -SH
oldMagnitude = R_PointToDist2(player->mo->momx - player->cmomx, player->mo->momy - player->cmomy, 0, 0);
#endif
analogmove = P_AnalogMove(player);
@ -4604,17 +4692,10 @@ static void P_3dMovement(player_t *player)
}
movepushforward = FixedMul(movepushforward, player->mo->scale);
#ifdef OLD_MOVEMENT_CODE
if (player->speed < topspeed && mforward && cmd->forwardmove > 0) // Sonic's Speed
P_Thrust(player->mo, movepushangle, movepushforward);
else if (mforward && cmd->forwardmove < 0)
P_Thrust(player->mo, movepushangle, movepushforward);
else if (player->speed < topspeed && mbackward && cmd->forwardmove < 0)
P_Thrust(player->mo, movepushangle, movepushforward);
else if (mbackward && cmd->forwardmove > 0)
P_Thrust(player->mo, movepushangle, movepushforward);
else if (!mforward && !mbackward)
P_Thrust(player->mo, movepushangle, movepushforward);
#ifdef ESLOPE
totalthrust.x += P_ReturnThrustX(player->mo, movepushangle, movepushforward);
totalthrust.y += P_ReturnThrustY(player->mo, movepushangle, movepushforward);
#else
P_Thrust(player->mo, movepushangle, movepushforward);
#endif
@ -4633,33 +4714,12 @@ static void P_3dMovement(player_t *player)
if (!(player->pflags & PF_GLIDING || player->exiting || P_PlayerInPain(player)))
{
angle_t controldirection;
#ifdef OLD_MOVEMENT_CODE
angle_t controlplayerdirection;
boolean cforward; // controls pointing forward from the player
boolean cbackward; // controls pointing backward from the player
angle_t dangle;
cforward = cbackward = false;
#endif
// Calculate the angle at which the controls are pointing
// to figure out the proper mforward and mbackward.
// (Why was it so complicated before? ~Red)
controldirection = R_PointToAngle2(0, 0, cmd->forwardmove*FRACUNIT, -cmd->sidemove*FRACUNIT)+movepushangle;
#ifdef OLD_MOVEMENT_CODE
controlplayerdirection = player->mo->angle;
dangle = controldirection - controlplayerdirection;
if (dangle > ANGLE_180) //flip to keep to one side
dangle = InvAngle(dangle);
if (dangle > ANGLE_90)
cbackward = true; // Controls pointing backwards from player
else
cforward = true; // Controls pointing in player's general direction
#endif
movepushforward = max(abs(cmd->sidemove), abs(cmd->forwardmove)) * (thrustfactor * acceleration);
// allow very small movement while in air for gameplay
@ -4682,13 +4742,10 @@ static void P_3dMovement(player_t *player)
movepushsideangle = controldirection;
movepushforward = FixedMul(movepushforward, player->mo->scale);
#ifdef OLD_MOVEMENT_CODE
if (player->speed < topspeed)
P_Thrust(player->mo, controldirection, movepushforward);
else if ((mforward) && (cbackward))
P_Thrust(player->mo, controldirection, movepushforward);
else if ((mbackward) && (cforward))
P_Thrust(player->mo, controldirection, movepushforward);
#ifdef ESLOPE
totalthrust.x += P_ReturnThrustX(player->mo, controldirection, movepushforward);
totalthrust.y += P_ReturnThrustY(player->mo, controldirection, movepushforward);
#else
P_Thrust(player->mo, controldirection, movepushforward);
#endif
@ -4696,29 +4753,6 @@ static void P_3dMovement(player_t *player)
}
else if (cmd->sidemove && !(player->pflags & PF_GLIDING) && !player->exiting && !P_PlayerInPain(player))
{
#ifdef OLD_MOVEMENT_CODE
boolean mright = 0;
boolean mleft = 0;
angle_t sideangle;
sideangle = player->mo->angle - ANGLE_90;
// Monster Iestyn - 04-11-13
// Quadrants are stupid, excessive and broken, let's do this a much simpler way!
// Get delta angle from rmom angle and player angle first
dangle = R_PointToAngle2(0,0, player->rmomx, player->rmomy) - sideangle;
if (dangle > ANGLE_180)
dangle = InvAngle(dangle);
// now use it to determine direction!
if (dangle <= ANGLE_45) // angles 0-45 or 315-360
mright = 1; // going right
else if (dangle >= ANGLE_135) // angles 135-225
mleft = 1; // going left
// anything else will leave both at 0, so no need to do anything else
#endif
movepushside = cmd->sidemove * (thrustfactor * acceleration);
if (!onground)
@ -4741,19 +4775,37 @@ static void P_3dMovement(player_t *player)
// Finally move the player now that his speed/direction has been decided.
movepushside = FixedMul(movepushside, player->mo->scale);
#ifdef OLD_MOVEMENT_CODE
if (player->speed < topspeed)
P_Thrust(player->mo, movepushsideangle, movepushside);
else if (mright && cmd->sidemove < 0)
P_Thrust(player->mo, movepushsideangle, movepushside);
else if (mleft && cmd->sidemove > 0)
P_Thrust(player->mo, movepushsideangle, movepushside);
#ifdef ESLOPE
totalthrust.x += P_ReturnThrustX(player->mo, movepushsideangle, movepushside);
totalthrust.y += P_ReturnThrustY(player->mo, movepushsideangle, movepushside);
#else
P_Thrust(player->mo, movepushsideangle, movepushside);
#endif
}
#ifndef OLD_MOVEMENT_CODE
#ifdef ESLOPE
if ((totalthrust.x || totalthrust.y)
&& player->mo->standingslope && abs(player->mo->standingslope->zdelta) > FRACUNIT/2) {
// Factor thrust to slope, but only for the part pushing up it!
// The rest is unaffected.
angle_t thrustangle = R_PointToAngle2(0, 0, totalthrust.x, totalthrust.y)-player->mo->standingslope->xydirection;
if (player->mo->standingslope->zdelta < 0) { // Direction goes down, so thrustangle needs to face toward
if (thrustangle < ANGLE_90 || thrustangle > ANGLE_270) {
P_QuantizeMomentumToSlope(&totalthrust, player->mo->standingslope);
}
} else { // Direction goes up, so thrustangle needs to face away
if (thrustangle > ANGLE_90 && thrustangle < ANGLE_270) {
P_QuantizeMomentumToSlope(&totalthrust, player->mo->standingslope);
}
}
}
player->mo->momx += totalthrust.x;
player->mo->momy += totalthrust.y;
#endif
// Time to ask three questions:
// 1) Are we over topspeed?
// 2) If "yes" to 1, were we moving over topspeed to begin with?
@ -4787,7 +4839,6 @@ static void P_3dMovement(player_t *player)
player->mo->momy = tempmomy + player->cmomy;
}
}
#endif
}
//
@ -9046,7 +9097,6 @@ void P_PlayerThink(player_t *player)
player->mo->tracer->flags2 &= ~MF2_DONTDRAW;
}
player->mo->pmomz = 0;
player->pflags &= ~PF_SLIDING;
/*
@ -9399,4 +9449,7 @@ void P_PlayerAfterThink(player_t *player)
player->mo->flags2 |= MF2_DONTDRAW;
player->mo->flags |= MF_NOGRAVITY;
}
if (P_IsObjectOnGround(player->mo))
player->mo->pmomz = 0;
}

View File

@ -18,6 +18,7 @@
#include "r_splats.h"
#include "p_local.h" // camera
#include "p_slopes.h"
#include "z_zone.h" // Check R_Prep3DFloors
seg_t *curline;
@ -459,6 +460,11 @@ static void R_AddLine(seg_t *line)
doorclosed = 0;
// Closed door.
#ifdef ESLOPE
// Just don't bother checking this if one side is sloped. This is probably inefficient, but it's better than
// random renderer stopping around slopes...
if (!(frontsector->f_slope || frontsector->c_slope || backsector->f_slope || backsector->c_slope))
#endif
if (backsector->ceilingheight <= frontsector->floorheight
|| backsector->floorheight >= frontsector->ceilingheight)
{
@ -487,6 +493,10 @@ static void R_AddLine(seg_t *line)
#endif
backsector->ceilingpic == frontsector->ceilingpic
&& backsector->floorpic == frontsector->floorpic
#ifdef ESLOPE
&& backsector->f_slope == frontsector->f_slope
&& backsector->c_slope == frontsector->c_slope
#endif
&& backsector->lightlevel == frontsector->lightlevel
&& !curline->sidedef->midtexture
// Check offsets too!
@ -842,11 +852,19 @@ static void R_Subsector(size_t num)
sub->sector->moved = frontsector->moved = false;
}
light = R_GetPlaneLight(frontsector, frontsector->floorheight, false);
light = R_GetPlaneLight(frontsector,
#ifdef ESLOPE
frontsector->f_slope ? P_GetZAt(frontsector->f_slope, frontsector->soundorg.x, frontsector->soundorg.y) :
#endif
frontsector->floorheight, false);
if (frontsector->floorlightsec == -1)
floorlightlevel = *frontsector->lightlist[light].lightlevel;
floorcolormap = frontsector->lightlist[light].extra_colormap;
light = R_GetPlaneLight(frontsector, frontsector->ceilingheight, false);
light = R_GetPlaneLight(frontsector,
#ifdef ESLOPE
frontsector->c_slope ? P_GetZAt(frontsector->c_slope, frontsector->soundorg.x, frontsector->soundorg.y) :
#endif
frontsector->ceilingheight, false);
if (frontsector->ceilinglightsec == -1)
ceilinglightlevel = *frontsector->lightlist[light].lightlevel;
ceilingcolormap = frontsector->lightlist[light].extra_colormap;
@ -854,32 +872,52 @@ static void R_Subsector(size_t num)
sub->sector->extra_colormap = frontsector->extra_colormap;
if ((frontsector->floorheight < viewz || (frontsector->heightsec != -1
if (((
#ifdef ESLOPE
frontsector->f_slope ? P_GetZAt(frontsector->f_slope, viewx, viewy) :
#endif
frontsector->floorheight) < viewz || (frontsector->heightsec != -1
&& sectors[frontsector->heightsec].ceilingpic == skyflatnum)))
{
floorplane = R_FindPlane(frontsector->floorheight, frontsector->floorpic, floorlightlevel,
frontsector->floor_xoffs, frontsector->floor_yoffs, frontsector->floorpic_angle, floorcolormap, NULL);
frontsector->floor_xoffs, frontsector->floor_yoffs, frontsector->floorpic_angle, floorcolormap, NULL
#ifdef ESLOPE
, frontsector->f_slope
#endif
);
}
else
floorplane = NULL;
if ((frontsector->ceilingheight > viewz || frontsector->ceilingpic == skyflatnum
if (((
#ifdef ESLOPE
frontsector->c_slope ? P_GetZAt(frontsector->c_slope, viewx, viewy) :
#endif
frontsector->ceilingheight) > viewz || frontsector->ceilingpic == skyflatnum
|| (frontsector->heightsec != -1
&& sectors[frontsector->heightsec].floorpic == skyflatnum)))
{
ceilingplane = R_FindPlane(frontsector->ceilingheight, frontsector->ceilingpic,
ceilinglightlevel, frontsector->ceiling_xoffs, frontsector->ceiling_yoffs, frontsector->ceilingpic_angle,
ceilingcolormap, NULL);
ceilingcolormap, NULL
#ifdef ESLOPE
, frontsector->c_slope
#endif
);
}
else
ceilingplane = NULL;
numffloors = 0;
#ifdef ESLOPE
ffloor[numffloors].slope = NULL;
#endif
ffloor[numffloors].plane = NULL;
ffloor[numffloors].polyobj = NULL;
if (frontsector->ffloors)
{
ffloor_t *rover;
fixed_t heightcheck, planecenterz, floorcenterz, ceilingcenterz;
for (rover = frontsector->ffloors; rover && numffloors < MAXFFLOORS; rover = rover->next)
{
@ -897,18 +935,60 @@ static void R_Subsector(size_t num)
ffloor[numffloors].plane = NULL;
ffloor[numffloors].polyobj = NULL;
if (*rover->bottomheight <= frontsector->ceilingheight
&& *rover->bottomheight >= frontsector->floorheight
&& ((viewz < *rover->bottomheight && !(rover->flags & FF_INVERTPLANES))
|| (viewz > *rover->bottomheight && (rover->flags & FF_BOTHPLANES))))
floorcenterz =
#ifdef ESLOPE
frontsector->f_slope ? P_GetZAt(frontsector->f_slope, frontsector->soundorg.x, frontsector->soundorg.y) :
#endif
frontsector->floorheight;
ceilingcenterz =
#ifdef ESLOPE
frontsector->c_slope ? P_GetZAt(frontsector->c_slope, frontsector->soundorg.x, frontsector->soundorg.y) :
#endif
frontsector->ceilingheight;
heightcheck =
#ifdef ESLOPE
*rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) :
#endif
*rover->bottomheight;
planecenterz =
#ifdef ESLOPE
*rover->b_slope ? P_GetZAt(*rover->b_slope, frontsector->soundorg.x, frontsector->soundorg.y) :
#endif
*rover->bottomheight;
if (planecenterz <= ceilingcenterz
&& planecenterz >= floorcenterz
&& ((viewz < heightcheck && !(rover->flags & FF_INVERTPLANES))
|| (viewz > heightcheck && (rover->flags & FF_BOTHPLANES))))
{
light = R_GetPlaneLight(frontsector, *rover->bottomheight,
light = R_GetPlaneLight(frontsector, planecenterz,
viewz < *rover->bottomheight);
ffloor[numffloors].plane = R_FindPlane(*rover->bottomheight, *rover->bottompic,
*frontsector->lightlist[light].lightlevel, *rover->bottomxoffs,
*rover->bottomyoffs, *rover->bottomangle, frontsector->lightlist[light].extra_colormap, rover);
*rover->bottomyoffs, *rover->bottomangle, frontsector->lightlist[light].extra_colormap, rover
#ifdef ESLOPE
, *rover->b_slope
#endif
);
#ifdef ESLOPE
ffloor[numffloors].slope = *rover->b_slope;
// Tell the renderer this sector has slopes in it.
if (ffloor[numffloors].slope)
frontsector->hasslope = true;
#endif
ffloor[numffloors].height =
#ifdef ESLOPE
*rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) :
#endif
*rover->bottomheight;
ffloor[numffloors].height = *rover->bottomheight;
ffloor[numffloors].ffloor = rover;
numffloors++;
}
@ -916,16 +996,47 @@ static void R_Subsector(size_t num)
break;
ffloor[numffloors].plane = NULL;
ffloor[numffloors].polyobj = NULL;
if (*rover->topheight >= frontsector->floorheight
&& *rover->topheight <= frontsector->ceilingheight
&& ((viewz > *rover->topheight && !(rover->flags & FF_INVERTPLANES))
|| (viewz < *rover->topheight && (rover->flags & FF_BOTHPLANES))))
heightcheck =
#ifdef ESLOPE
*rover->t_slope ? P_GetZAt(*rover->t_slope, viewx, viewy) :
#endif
*rover->topheight;
planecenterz =
#ifdef ESLOPE
*rover->t_slope ? P_GetZAt(*rover->t_slope, frontsector->soundorg.x, frontsector->soundorg.y) :
#endif
*rover->topheight;
if (planecenterz >= floorcenterz
&& planecenterz <= ceilingcenterz
&& ((viewz > heightcheck && !(rover->flags & FF_INVERTPLANES))
|| (viewz < heightcheck && (rover->flags & FF_BOTHPLANES))))
{
light = R_GetPlaneLight(frontsector, *rover->topheight, viewz < *rover->topheight);
light = R_GetPlaneLight(frontsector, planecenterz, viewz < *rover->topheight);
ffloor[numffloors].plane = R_FindPlane(*rover->topheight, *rover->toppic,
*frontsector->lightlist[light].lightlevel, *rover->topxoffs, *rover->topyoffs, *rover->topangle,
frontsector->lightlist[light].extra_colormap, rover);
ffloor[numffloors].height = *rover->topheight;
frontsector->lightlist[light].extra_colormap, rover
#ifdef ESLOPE
, *rover->t_slope
#endif
);
#ifdef ESLOPE
ffloor[numffloors].slope = *rover->t_slope;
// Tell the renderer this sector has slopes in it.
if (ffloor[numffloors].slope)
frontsector->hasslope = true;
#endif
ffloor[numffloors].height =
#ifdef ESLOPE
*rover->t_slope ? P_GetZAt(*rover->t_slope, viewx, viewy) :
#endif
*rover->topheight;
ffloor[numffloors].ffloor = rover;
numffloors++;
}
@ -977,11 +1088,18 @@ static void R_Subsector(size_t num)
polysec->lightlevel, xoff, yoff,
polysec->floorpic_angle-po->angle,
NULL,
NULL);
NULL
#ifdef ESLOPE
, NULL // will ffloors be slopable eventually?
#endif
);
//ffloor[numffloors].plane->polyobj = po;
ffloor[numffloors].height = polysec->floorheight;
ffloor[numffloors].polyobj = po;
#ifdef ESLOPE
ffloor[numffloors].slope = NULL;
#endif
// ffloor[numffloors].ffloor = rover;
po->visplane = ffloor[numffloors].plane;
numffloors++;
@ -1014,11 +1132,18 @@ static void R_Subsector(size_t num)
light = 0;
ffloor[numffloors].plane = R_FindPlane(polysec->ceilingheight, polysec->ceilingpic,
polysec->lightlevel, xoff, yoff, polysec->ceilingpic_angle-po->angle,
NULL, NULL);
NULL, NULL
#ifdef ESLOPE
, NULL // will ffloors be slopable eventually?
#endif
);
//ffloor[numffloors].plane->polyobj = po;
ffloor[numffloors].polyobj = po;
ffloor[numffloors].height = polysec->ceilingheight;
#ifdef ESLOPE
ffloor[numffloors].slope = NULL;
#endif
// ffloor[numffloors].ffloor = rover;
po->visplane = ffloor[numffloors].plane;
numffloors++;
@ -1077,6 +1202,11 @@ void R_Prep3DFloors(sector_t *sector)
fixed_t bestheight, maxheight;
INT32 count, i, mapnum;
sector_t *sec;
#ifdef ESLOPE
pslope_t *bestslope;
fixed_t heighttest; // I think it's better to check the Z height at the sector's center
// than assume unsloped heights are accurate indicators of order in sloped sectors. -Red
#endif
count = 1;
for (rover = sector->ffloors; rover; rover = rover->next)
@ -1099,7 +1229,14 @@ void R_Prep3DFloors(sector_t *sector)
else
memset(sector->lightlist, 0, sizeof (lightlist_t) * count);
#ifdef ESLOPE
heighttest = sector->c_slope ? P_GetZAt(sector->c_slope, sector->soundorg.x, sector->soundorg.y) : sector->ceilingheight;
sector->lightlist[0].height = heighttest + 1;
sector->lightlist[0].slope = sector->c_slope;
#else
sector->lightlist[0].height = sector->ceilingheight + 1;
#endif
sector->lightlist[0].lightlevel = &sector->lightlevel;
sector->lightlist[0].caster = NULL;
sector->lightlist[0].extra_colormap = sector->extra_colormap;
@ -1117,6 +1254,29 @@ void R_Prep3DFloors(sector_t *sector)
&& !(rover->flags & FF_CUTLEVEL) && !(rover->flags & FF_CUTSPRITES)))
continue;
#ifdef ESLOPE
heighttest = *rover->t_slope ? P_GetZAt(*rover->t_slope, sector->soundorg.x, sector->soundorg.y) : *rover->topheight;
if (heighttest > bestheight && heighttest < maxheight)
{
best = rover;
bestheight = heighttest;
bestslope = *rover->t_slope;
continue;
}
if (rover->flags & FF_DOUBLESHADOW) {
heighttest = *rover->b_slope ? P_GetZAt(*rover->b_slope, sector->soundorg.x, sector->soundorg.y) : *rover->bottomheight;
if (heighttest > bestheight
&& heighttest < maxheight)
{
best = rover;
bestheight = heighttest;
bestslope = *rover->b_slope;
continue;
}
}
#else
if (*rover->topheight > bestheight && *rover->topheight < maxheight)
{
best = rover;
@ -1130,6 +1290,7 @@ void R_Prep3DFloors(sector_t *sector)
bestheight = *rover->bottomheight;
continue;
}
#endif
}
if (!best)
{
@ -1140,6 +1301,9 @@ void R_Prep3DFloors(sector_t *sector)
sector->lightlist[i].height = maxheight = bestheight;
sector->lightlist[i].caster = best;
sector->lightlist[i].flags = best->flags;
#ifdef ESLOPE
sector->lightlist[i].slope = bestslope;
#endif
sec = &sectors[best->secnum];
mapnum = sec->midmap;
if (mapnum >= 0 && (size_t)mapnum < num_extra_colormaps)
@ -1165,7 +1329,12 @@ void R_Prep3DFloors(sector_t *sector)
if (best->flags & FF_DOUBLESHADOW)
{
#ifdef ESLOPE
heighttest = *best->b_slope ? P_GetZAt(*best->b_slope, sector->soundorg.x, sector->soundorg.y) : *best->bottomheight;
if (bestheight == heighttest) ///TODO: do this in a more efficient way -Red
#else
if (bestheight == *best->bottomheight)
#endif
{
sector->lightlist[i].lightlevel = sector->lightlist[best->lastlight].lightlevel;
sector->lightlist[i].extra_colormap =

View File

@ -155,6 +155,12 @@ typedef struct ffloor_s
fixed_t *bottomyoffs;
angle_t *bottomangle;
#ifdef ESLOPE
// Pointers to pointers. Yup.
struct pslope_s **t_slope;
struct pslope_s **b_slope;
#endif
size_t secnum;
ffloortype_e flags;
struct line_s *master;
@ -184,6 +190,9 @@ typedef struct lightlist_s
extracolormap_t *extra_colormap;
INT32 flags;
ffloor_t *caster;
#ifdef ESLOPE
struct pslope_s *slope; // FF_DOUBLESHADOW makes me have to store this pointer here. Bluh bluh.
#endif
} lightlist_t;
@ -224,6 +233,52 @@ typedef struct secplane_t
fixed_t a, b, c, d, ic;
} secplane_t;
// Slopes
#ifdef ESLOPE
typedef enum {
SL_NOPHYSICS = 1, // Don't do momentum adjustment with this slope
SL_NODYNAMIC = 1<<1, // Slope will never need to move during the level, so don't fuss with recalculating it
SL_ANCHORVERTEX = 1<<2, // Slope is using a Slope Vertex Thing to anchor its position
SL_VERTEXSLOPE = 1<<3, // Slope is built from three Slope Vertex Things
} slopeflags_t;
typedef struct pslope_s
{
UINT16 id; // The number of the slope, mostly used for netgame syncing purposes
// --- Information used in clipping/projection ---
// Origin vector for the plane
vector3_t o;
// 2-Dimentional vector (x, y) normalized. Used to determine distance from
// the origin in 2d mapspace. (Basically a thrust of FRACUNIT in xydirection angle)
vector2_t d;
// The rate at which z changes based on distance from the origin plane.
fixed_t zdelta;
// The normal of the slope; will always point upward, and thus be inverted on ceilings. I think it's only needed for physics? -Red
vector3_t normal;
// For comparing when a slope should be rendered
fixed_t lowz;
fixed_t highz;
// This values only check and must be updated if the slope itself is modified
angle_t zangle; // Angle of the plane going up from the ground (not mesured in degrees)
angle_t xydirection; // The direction the slope is facing (north, west, south, etc.)
struct line_s *sourceline; // The line that generated the slope
fixed_t extent; // Distance value used for recalculating zdelta
UINT8 refpos; // 1=front floor 2=front ceiling 3=back floor 4=back ceiling (used for dynamic sloping)
UINT8 flags; // Slope options
mapthing_t **vertices; // List should be three long for slopes made by vertex things, or one long for slopes using one vertex thing to anchor
struct pslope_s *next; // Make a linked list of dynamic slopes, for easy reference later
} pslope_t;
#endif
typedef enum
{
SF_FLIPSPECIAL_FLOOR = 1,
@ -337,6 +392,13 @@ typedef struct sector_s
precipmobj_t *preciplist;
struct mprecipsecnode_s *touching_preciplist;
#ifdef ESLOPE
// Eternity engine slope
pslope_t *f_slope; // floor slope
pslope_t *c_slope; // ceiling slope
boolean hasslope; // The sector, or one of its visible FOFs, contains a slope
#endif
// these are saved for netgames, so do not let Lua touch these!
// offsets sector spawned with (via linedef type 7)
@ -612,6 +674,12 @@ typedef struct drawseg_s
INT16 *thicksidecol;
INT32 numthicksides;
fixed_t frontscale[MAXVIDWIDTH];
#ifdef ESLOPE
fixed_t maskedtextureheight[MAXVIDWIDTH]; // For handling sloped midtextures
vertex_t leftpos, rightpos; // Used for rendering FOF walls with slopes
#endif
} drawseg_t;
typedef enum

View File

@ -103,6 +103,12 @@ fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep;
UINT8 *ds_source; // start of a 64*64 tile image
UINT8 *ds_transmap; // one of the translucency tables
#ifdef ESLOPE
pslope_t *ds_slope; // Current slope being used
floatv3_t ds_su, ds_sv, ds_sz; // Vectors for... stuff?
float focallengthf, zeroheight;
#endif
/** \brief Variable flat sizes
*/

View File

@ -60,6 +60,16 @@ extern fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep;
extern UINT8 *ds_source; // start of a 64*64 tile image
extern UINT8 *ds_transmap;
#ifdef ESLOPE
typedef struct {
float x, y, z;
} floatv3_t;
extern pslope_t *ds_slope; // Current slope being used
extern floatv3_t ds_su, ds_sv, ds_sz; // Vectors for... stuff?
extern float focallengthf, zeroheight;
#endif
// Variable flat sizes
extern UINT32 nflatxshift;
extern UINT32 nflatyshift;
@ -141,6 +151,12 @@ void ASMCALL R_DrawSpan_8_MMX(void);
void R_DrawTranslatedColumn_8(void);
void R_DrawTranslatedTranslucentColumn_8(void);
void R_DrawSpan_8(void);
#ifdef ESLOPE
void R_CalcTiltedLighting(fixed_t start, fixed_t end);
void R_DrawTiltedSpan_8(void);
void R_DrawTiltedTranslucentSpan_8(void);
void R_DrawTiltedSplat_8(void);
#endif
void R_DrawSplat_8(void);
void R_DrawTranslucentSplat_8(void);
void R_DrawTranslucentSpan_8(void);

View File

@ -526,6 +526,447 @@ void R_DrawSpan_8 (void)
}
}
#ifdef ESLOPE
// R_CalcTiltedLighting
// Exactly what it says on the tin. I wish I wasn't too lazy to explain things properly.
static INT32 tiltlighting[MAXVIDWIDTH];
void R_CalcTiltedLighting(fixed_t start, fixed_t end)
{
// ZDoom uses a different lighting setup to us, and I couldn't figure out how to adapt their version
// of this function. Here's my own.
INT32 left = ds_x1, right = ds_x2;
fixed_t step = (end-start)/(ds_x2-ds_x1+1);
INT32 i;
// I wanna do some optimizing by checking for out-of-range segments on either side to fill in all at once,
// but I'm too bad at coding to not crash the game trying to do that. I guess this is fast enough for now...
for (i = left; i <= right; i++) {
tiltlighting[i] = (start += step) >> FRACBITS;
if (tiltlighting[i] < 0)
tiltlighting[i] = 0;
else if (tiltlighting[i] >= MAXLIGHTSCALE)
tiltlighting[i] = MAXLIGHTSCALE-1;
}
}
/** \brief The R_DrawTiltedSpan_8 function
Draw slopes! Holy sheit!
*/
void R_DrawTiltedSpan_8(void)
{
// x1, x2 = ds_x1, ds_x2
int width = ds_x2 - ds_x1;
double iz, uz, vz;
UINT32 u, v;
int i;
UINT8 *source;
UINT8 *colormap;
UINT8 *dest;
double startz, startu, startv;
double izstep, uzstep, vzstep;
double endz, endu, endv;
UINT32 stepu, stepv;
iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx);
// Lighting is simple. It's just linear interpolation from start to end
{
float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f;
float lightstart, lightend;
lightend = (iz + ds_sz.x*width) * planelightfloat;
lightstart = iz * planelightfloat;
R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend));
//CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf);
}
uz = ds_su.z + ds_su.y*(centery-ds_y) + ds_su.x*(ds_x1-centerx);
vz = ds_sv.z + ds_sv.y*(centery-ds_y) + ds_sv.x*(ds_x1-centerx);
dest = ylookup[ds_y] + columnofs[ds_x1];
source = ds_source;
//colormap = ds_colormap;
#if 0 // The "perfect" reference version of this routine. Pretty slow.
// Use it only to see how things are supposed to look.
i = 0;
do
{
double z = 1.f/iz;
u = (INT64)(uz*z) + viewx;
v = (INT64)(vz*z) + viewy;
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
*dest = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]];
dest++;
iz += ds_sz.x;
uz += ds_su.x;
vz += ds_sv.x;
} while (--width >= 0);
#else
#define SPANSIZE 16
#define INVSPAN 0.0625f
startz = 1.f/iz;
startu = uz*startz;
startv = vz*startz;
izstep = ds_sz.x * SPANSIZE;
uzstep = ds_su.x * SPANSIZE;
vzstep = ds_sv.x * SPANSIZE;
//x1 = 0;
width++;
while (width >= SPANSIZE)
{
iz += izstep;
uz += uzstep;
vz += vzstep;
endz = 1.f/iz;
endu = uz*endz;
endv = vz*endz;
stepu = (INT64)((endu - startu) * INVSPAN);
stepv = (INT64)((endv - startv) * INVSPAN);
u = (INT64)(startu) + viewx;
v = (INT64)(startv) + viewy;
for (i = SPANSIZE-1; i >= 0; i--)
{
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
*dest = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]];
dest++;
u += stepu;
v += stepv;
}
startu = endu;
startv = endv;
width -= SPANSIZE;
}
if (width > 0)
{
if (width == 1)
{
u = (INT64)(startu);
v = (INT64)(startv);
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
*dest = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]];
}
else
{
double left = width;
iz += ds_sz.x * left;
uz += ds_su.x * left;
vz += ds_sv.x * left;
endz = 1.f/iz;
endu = uz*endz;
endv = vz*endz;
left = 1.f/left;
stepu = (INT64)((endu - startu) * left);
stepv = (INT64)((endv - startv) * left);
u = (INT64)(startu) + viewx;
v = (INT64)(startv) + viewy;
for (; width != 0; width--)
{
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
*dest = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]];
dest++;
u += stepu;
v += stepv;
}
}
}
#endif
}
/** \brief The R_DrawTiltedTranslucentSpan_8 function
Like DrawTiltedSpan, but translucent
*/
void R_DrawTiltedTranslucentSpan_8(void)
{
// x1, x2 = ds_x1, ds_x2
int width = ds_x2 - ds_x1;
double iz, uz, vz;
UINT32 u, v;
int i;
UINT8 *source;
UINT8 *colormap;
UINT8 *dest;
double startz, startu, startv;
double izstep, uzstep, vzstep;
double endz, endu, endv;
UINT32 stepu, stepv;
iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx);
// Lighting is simple. It's just linear interpolation from start to end
{
float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f;
float lightstart, lightend;
lightend = (iz + ds_sz.x*width) * planelightfloat;
lightstart = iz * planelightfloat;
R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend));
//CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf);
}
uz = ds_su.z + ds_su.y*(centery-ds_y) + ds_su.x*(ds_x1-centerx);
vz = ds_sv.z + ds_sv.y*(centery-ds_y) + ds_sv.x*(ds_x1-centerx);
dest = ylookup[ds_y] + columnofs[ds_x1];
source = ds_source;
//colormap = ds_colormap;
#if 0 // The "perfect" reference version of this routine. Pretty slow.
// Use it only to see how things are supposed to look.
i = 0;
do
{
double z = 1.f/iz;
u = (INT64)(uz*z) + viewx;
v = (INT64)(vz*z) + viewy;
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
*dest = colormap[*(ds_transmap + (source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)] << 8) + dest[0])];
dest++;
iz += ds_sz.x;
uz += ds_su.x;
vz += ds_sv.x;
} while (--width >= 0);
#else
#define SPANSIZE 16
#define INVSPAN 0.0625f
startz = 1.f/iz;
startu = uz*startz;
startv = vz*startz;
izstep = ds_sz.x * SPANSIZE;
uzstep = ds_su.x * SPANSIZE;
vzstep = ds_sv.x * SPANSIZE;
//x1 = 0;
width++;
while (width >= SPANSIZE)
{
iz += izstep;
uz += uzstep;
vz += vzstep;
endz = 1.f/iz;
endu = uz*endz;
endv = vz*endz;
stepu = (INT64)((endu - startu) * INVSPAN);
stepv = (INT64)((endv - startv) * INVSPAN);
u = (INT64)(startu) + viewx;
v = (INT64)(startv) + viewy;
for (i = SPANSIZE-1; i >= 0; i--)
{
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
*dest = colormap[*(ds_transmap + (source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)] << 8) + dest[0])];
dest++;
u += stepu;
v += stepv;
}
startu = endu;
startv = endv;
width -= SPANSIZE;
}
if (width > 0)
{
if (width == 1)
{
u = (INT64)(startu);
v = (INT64)(startv);
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
*dest = colormap[*(ds_transmap + (source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)] << 8) + dest[0])];
}
else
{
double left = width;
iz += ds_sz.x * left;
uz += ds_su.x * left;
vz += ds_sv.x * left;
endz = 1.f/iz;
endu = uz*endz;
endv = vz*endz;
left = 1.f/left;
stepu = (INT64)((endu - startu) * left);
stepv = (INT64)((endv - startv) * left);
u = (INT64)(startu) + viewx;
v = (INT64)(startv) + viewy;
for (; width != 0; width--)
{
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
*dest = colormap[*(ds_transmap + (source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)] << 8) + dest[0])];
dest++;
u += stepu;
v += stepv;
}
}
}
#endif
}
void R_DrawTiltedSplat_8(void)
{
// x1, x2 = ds_x1, ds_x2
int width = ds_x2 - ds_x1;
double iz, uz, vz;
UINT32 u, v;
int i;
UINT8 *source;
UINT8 *colormap;
UINT8 *dest;
UINT8 val;
double startz, startu, startv;
double izstep, uzstep, vzstep;
double endz, endu, endv;
UINT32 stepu, stepv;
iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx);
// Lighting is simple. It's just linear interpolation from start to end
{
float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f;
float lightstart, lightend;
lightend = (iz + ds_sz.x*width) * planelightfloat;
lightstart = iz * planelightfloat;
R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend));
//CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf);
}
uz = ds_su.z + ds_su.y*(centery-ds_y) + ds_su.x*(ds_x1-centerx);
vz = ds_sv.z + ds_sv.y*(centery-ds_y) + ds_sv.x*(ds_x1-centerx);
dest = ylookup[ds_y] + columnofs[ds_x1];
source = ds_source;
//colormap = ds_colormap;
#if 0 // The "perfect" reference version of this routine. Pretty slow.
// Use it only to see how things are supposed to look.
i = 0;
do
{
double z = 1.f/iz;
u = (INT64)(uz*z) + viewx;
v = (INT64)(vz*z) + viewy;
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
val = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]];
if (val != TRANSPARENTPIXEL)
*dest = val;
dest++;
iz += ds_sz.x;
uz += ds_su.x;
vz += ds_sv.x;
} while (--width >= 0);
#else
#define SPANSIZE 16
#define INVSPAN 0.0625f
startz = 1.f/iz;
startu = uz*startz;
startv = vz*startz;
izstep = ds_sz.x * SPANSIZE;
uzstep = ds_su.x * SPANSIZE;
vzstep = ds_sv.x * SPANSIZE;
//x1 = 0;
width++;
while (width >= SPANSIZE)
{
iz += izstep;
uz += uzstep;
vz += vzstep;
endz = 1.f/iz;
endu = uz*endz;
endv = vz*endz;
stepu = (INT64)((endu - startu) * INVSPAN);
stepv = (INT64)((endv - startv) * INVSPAN);
u = (INT64)(startu) + viewx;
v = (INT64)(startv) + viewy;
for (i = SPANSIZE-1; i >= 0; i--)
{
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
val = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]];
if (val != TRANSPARENTPIXEL)
*dest = val;
dest++;
u += stepu;
v += stepv;
}
startu = endu;
startv = endv;
width -= SPANSIZE;
}
if (width > 0)
{
if (width == 1)
{
u = (INT64)(startu);
v = (INT64)(startv);
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
val = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]];
if (val != TRANSPARENTPIXEL)
*dest = val;
}
else
{
double left = width;
iz += ds_sz.x * left;
uz += ds_su.x * left;
vz += ds_sv.x * left;
endz = 1.f/iz;
endu = uz*endz;
endv = vz*endz;
left = 1.f/left;
stepu = (INT64)((endu - startu) * left);
stepv = (INT64)((endv - startv) * left);
u = (INT64)(startu) + viewx;
v = (INT64)(startv) + viewy;
for (; width != 0; width--)
{
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
val = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]];
if (val != TRANSPARENTPIXEL)
*dest = val;
dest++;
u += stepu;
v += stepv;
}
}
}
#endif
}
#endif // ESLOPE
/** \brief The R_DrawSplat_8 function
Just like R_DrawSpan_8, but skips transparent pixels.
*/

View File

@ -114,15 +114,6 @@ INT32 viewangletox[FINEANGLES/2];
// from clipangle to -clipangle.
angle_t xtoviewangle[MAXVIDWIDTH+1];
// UNUSED.
// The finetangentgent[angle+FINEANGLES/4] table
// holds the fixed_t tangent values for view angles,
// ranging from INT32_MIN to 0 to INT32_MAX.
#if !(defined _NDS) || !(defined NONET)
fixed_t *finecosine = &finesine[FINEANGLES/4];
#endif
lighttable_t *scalelight[LIGHTLEVELS][MAXLIGHTSCALE];
lighttable_t *scalelightfixed[MAXLIGHTSCALE];
lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ];
@ -316,13 +307,13 @@ angle_t R_PointToAngle(fixed_t x, fixed_t y)
x >= 0 ?
y >= 0 ?
(x > y) ? tantoangle[SlopeDiv(y,x)] : // octant 0
ANGLE_90-1-tantoangle[SlopeDiv(x,y)] : // octant 1
ANGLE_90-tantoangle[SlopeDiv(x,y)] : // octant 1
x > (y = -y) ? 0-tantoangle[SlopeDiv(y,x)] : // octant 8
ANGLE_270+tantoangle[SlopeDiv(x,y)] : // octant 7
y >= 0 ? (x = -x) > y ? ANGLE_180-1-tantoangle[SlopeDiv(y,x)] :// octant 3
y >= 0 ? (x = -x) > y ? ANGLE_180-tantoangle[SlopeDiv(y,x)] : // octant 3
ANGLE_90 + tantoangle[SlopeDiv(x,y)] : // octant 2
(x = -x) > (y = -y) ? ANGLE_180+tantoangle[ SlopeDiv(y,x)] : // octant 4
ANGLE_270-1-tantoangle[SlopeDiv(x,y)] : // octant 5
(x = -x) > (y = -y) ? ANGLE_180+tantoangle[SlopeDiv(y,x)] : // octant 4
ANGLE_270-tantoangle[SlopeDiv(x,y)] : // octant 5
0;
}
@ -332,13 +323,13 @@ angle_t R_PointToAngle2(fixed_t pviewx, fixed_t pviewy, fixed_t x, fixed_t y)
x >= 0 ?
y >= 0 ?
(x > y) ? tantoangle[SlopeDiv(y,x)] : // octant 0
ANGLE_90-1-tantoangle[SlopeDiv(x,y)] : // octant 1
ANGLE_90-tantoangle[SlopeDiv(x,y)] : // octant 1
x > (y = -y) ? 0-tantoangle[SlopeDiv(y,x)] : // octant 8
ANGLE_270+tantoangle[SlopeDiv(x,y)] : // octant 7
y >= 0 ? (x = -x) > y ? ANGLE_180-1-tantoangle[SlopeDiv(y,x)] :// octant 3
y >= 0 ? (x = -x) > y ? ANGLE_180-tantoangle[SlopeDiv(y,x)] : // octant 3
ANGLE_90 + tantoangle[SlopeDiv(x,y)] : // octant 2
(x = -x) > (y = -y) ? ANGLE_180+tantoangle[ SlopeDiv(y,x)] : // octant 4
ANGLE_270-1-tantoangle[SlopeDiv(x,y)] : // octant 5
(x = -x) > (y = -y) ? ANGLE_180+tantoangle[SlopeDiv(y,x)] : // octant 4
ANGLE_270-tantoangle[SlopeDiv(x,y)] : // octant 5
0;
}
@ -527,6 +518,8 @@ static void R_InitTextureMapping(void)
focallength = FixedDiv(centerxfrac,
FINETANGENT(FINEANGLES/4+/*cv_fov.value*/ FIELDOFVIEW/2));
focallengthf = FIXED_TO_FLOAT(focallength);
for (i = 0; i < FINEANGLES/2; i++)
{
if (FINETANGENT(i) > FRACUNIT*2)

View File

@ -28,6 +28,8 @@
#include "p_setup.h" // levelflats
#include "p_slopes.h"
//
// opening
//
@ -74,7 +76,7 @@ static INT32 spanstart[MAXVIDHEIGHT];
//
// texture mapping
//
static lighttable_t **planezlight;
lighttable_t **planezlight;
static fixed_t planeheight;
//added : 10-02-98: yslopetab is what yslope used to be,
@ -327,6 +329,11 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2)
if (pindex >= MAXLIGHTZ)
pindex = MAXLIGHTZ - 1;
#ifdef ESLOPE
if (currentplane->slope)
ds_colormap = colormaps;
else
#endif
ds_colormap = planezlight[pindex];
if (currentplane->extra_colormap)
@ -423,11 +430,18 @@ static visplane_t *new_visplane(unsigned hash)
//
visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
fixed_t xoff, fixed_t yoff, angle_t plangle, extracolormap_t *planecolormap,
ffloor_t *pfloor)
ffloor_t *pfloor
#ifdef ESLOPE
, pslope_t *slope
#endif
)
{
visplane_t *check;
unsigned hash;
#ifdef ESLOPE
if (slope); else // Don't mess with this right now if a slope is involved
#endif
if (plangle != 0)
{
// Add the view offset, rotated by the plane angle.
@ -462,7 +476,11 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
&& xoff == check->xoffs && yoff == check->yoffs
&& planecolormap == check->extra_colormap
&& !pfloor && !check->ffloor && check->viewz == viewz
&& check->viewangle == viewangle)
&& check->viewangle == viewangle
#ifdef ESLOPE
&& check->slope == slope
#endif
)
{
return check;
}
@ -485,6 +503,9 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
#ifdef POLYOBJECTS_PLANES
check->polyobj = NULL;
#endif
#ifdef ESLOPE
check->slope = slope;
#endif
memset(check->top, 0xff, sizeof (check->top));
memset(check->bottom, 0x00, sizeof (check->bottom));
@ -551,6 +572,9 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop)
new_pl->plangle = pl->plangle;
#ifdef POLYOBJECTS_PLANES
new_pl->polyobj = pl->polyobj;
#endif
#ifdef ESLOPE
new_pl->slope = pl->slope;
#endif
pl = new_pl;
pl->minx = start;
@ -726,31 +750,15 @@ void R_DrawSinglePlane(visplane_t *pl)
// Hacked up support for alpha value in software mode Tails 09-24-2002 (sidenote: ported to polys 10-15-2014, there was no time travel involved -Red)
if (pl->polyobj->translucency >= 10)
return; // Don't even draw it
else if (pl->polyobj->translucency == 9)
ds_transmap = ((tr_trans90)<<FF_TRANSSHIFT) - 0x10000 + transtables;
else if (pl->polyobj->translucency == 8)
ds_transmap = ((tr_trans80)<<FF_TRANSSHIFT) - 0x10000 + transtables;
else if (pl->polyobj->translucency == 7)
ds_transmap = ((tr_trans70)<<FF_TRANSSHIFT) - 0x10000 + transtables;
else if (pl->polyobj->translucency == 6)
ds_transmap = ((tr_trans60)<<FF_TRANSSHIFT) - 0x10000 + transtables;
else if (pl->polyobj->translucency == 5)
ds_transmap = ((tr_trans50)<<FF_TRANSSHIFT) - 0x10000 + transtables;
else if (pl->polyobj->translucency == 4)
ds_transmap = ((tr_trans40)<<FF_TRANSSHIFT) - 0x10000 + transtables;
else if (pl->polyobj->translucency == 3)
ds_transmap = ((tr_trans30)<<FF_TRANSSHIFT) - 0x10000 + transtables;
else if (pl->polyobj->translucency == 2)
ds_transmap = ((tr_trans20)<<FF_TRANSSHIFT) - 0x10000 + transtables;
else if (pl->polyobj->translucency == 1)
ds_transmap = ((tr_trans10)<<FF_TRANSSHIFT) - 0x10000 + transtables;
else if (pl->polyobj->translucency > 0)
ds_transmap = transtables + ((pl->polyobj->translucency-1)<<FF_TRANSSHIFT);
else // Opaque, but allow transparent flat pixels
spanfunc = splatfunc;
if (pl->extra_colormap && pl->extra_colormap->fog)
light = (pl->lightlevel >> LIGHTSEGSHIFT);
else
light = LIGHTLEVELS-1;
light = LIGHTLEVELS-1;
} else
#endif
@ -781,23 +789,23 @@ void R_DrawSinglePlane(visplane_t *pl)
if (pl->ffloor->alpha < 12)
return; // Don't even draw it
else if (pl->ffloor->alpha < 38)
ds_transmap = ((tr_trans90)<<FF_TRANSSHIFT) - 0x10000 + transtables;
ds_transmap = transtables + ((tr_trans90-1)<<FF_TRANSSHIFT);
else if (pl->ffloor->alpha < 64)
ds_transmap = ((tr_trans80)<<FF_TRANSSHIFT) - 0x10000 + transtables;
ds_transmap = transtables + ((tr_trans80-1)<<FF_TRANSSHIFT);
else if (pl->ffloor->alpha < 89)
ds_transmap = ((tr_trans70)<<FF_TRANSSHIFT) - 0x10000 + transtables;
ds_transmap = transtables + ((tr_trans70-1)<<FF_TRANSSHIFT);
else if (pl->ffloor->alpha < 115)
ds_transmap = ((tr_trans60)<<FF_TRANSSHIFT) - 0x10000 + transtables;
ds_transmap = transtables + ((tr_trans60-1)<<FF_TRANSSHIFT);
else if (pl->ffloor->alpha < 140)
ds_transmap = ((tr_trans50)<<FF_TRANSSHIFT) - 0x10000 + transtables;
ds_transmap = transtables + ((tr_trans50-1)<<FF_TRANSSHIFT);
else if (pl->ffloor->alpha < 166)
ds_transmap = ((tr_trans40)<<FF_TRANSSHIFT) - 0x10000 + transtables;
ds_transmap = transtables + ((tr_trans40-1)<<FF_TRANSSHIFT);
else if (pl->ffloor->alpha < 192)
ds_transmap = ((tr_trans30)<<FF_TRANSSHIFT) - 0x10000 + transtables;
ds_transmap = transtables + ((tr_trans30-1)<<FF_TRANSSHIFT);
else if (pl->ffloor->alpha < 217)
ds_transmap = ((tr_trans20)<<FF_TRANSSHIFT) - 0x10000 + transtables;
ds_transmap = transtables + ((tr_trans20-1)<<FF_TRANSSHIFT);
else if (pl->ffloor->alpha < 243)
ds_transmap = ((tr_trans10)<<FF_TRANSSHIFT) - 0x10000 + transtables;
ds_transmap = transtables + ((tr_trans10-1)<<FF_TRANSSHIFT);
else // Opaque, but allow transparent flat pixels
spanfunc = splatfunc;
@ -814,7 +822,11 @@ void R_DrawSinglePlane(visplane_t *pl)
else light = (pl->lightlevel >> LIGHTSEGSHIFT);
#ifndef NOWATER
if (pl->ffloor->flags & FF_RIPPLE)
if (pl->ffloor->flags & FF_RIPPLE
#ifdef ESLOPE
&& !pl->slope
#endif
)
{
INT32 top, bottom;
@ -842,6 +854,9 @@ void R_DrawSinglePlane(visplane_t *pl)
}
else light = (pl->lightlevel >> LIGHTSEGSHIFT);
#ifdef ESLOPE
if (!pl->slope) // Don't mess with angle on slopes! We'll handle this ourselves later
#endif
if (viewangle != pl->viewangle)
{
memset(cachedheight, 0, sizeof (cachedheight));
@ -915,6 +930,106 @@ void R_DrawSinglePlane(visplane_t *pl)
if (light < 0)
light = 0;
#ifdef ESLOPE
if (pl->slope) {
// Potentially override other stuff for now cus we're mean. :< But draw a slope plane!
// I copied ZDoom's code and adapted it to SRB2... -Red
floatv3_t p, m, n;
float ang;
float vx, vy, vz;
float fudge;
// compiler complains when P_GetZAt is used in FLOAT_TO_FIXED directly
// use this as a temp var to store P_GetZAt's return value each time
fixed_t temp;
xoffs &= ((1 << (32-nflatshiftup))-1);
yoffs &= ((1 << (32-nflatshiftup))-1);
xoffs -= (pl->slope->o.x + (1 << (31-nflatshiftup))) & ~((1 << (32-nflatshiftup))-1);
yoffs += (pl->slope->o.y + (1 << (31-nflatshiftup))) & ~((1 << (32-nflatshiftup))-1);
// Okay, look, don't ask me why this works, but without this setup there's a disgusting-looking misalignment with the textures. -Red
fudge = ((1<<nflatshiftup)+1.0f)/(1<<nflatshiftup);
xoffs *= fudge;
yoffs /= fudge;
vx = FIXED_TO_FLOAT(viewx+xoffs);
vy = FIXED_TO_FLOAT(viewy-yoffs);
vz = FIXED_TO_FLOAT(viewz);
temp = P_GetZAt(pl->slope, viewx, viewy);
zeroheight = FIXED_TO_FLOAT(temp);
#define ANG2RAD(angle) ((float)((angle)*M_PI)/ANGLE_180)
// p is the texture origin in view space
// Don't add in the offsets at this stage, because doing so can result in
// errors if the flat is rotated.
ang = ANG2RAD(ANGLE_270 - viewangle);
p.x = vx * cos(ang) - vy * sin(ang);
p.z = vx * sin(ang) + vy * cos(ang);
temp = P_GetZAt(pl->slope, -xoffs, yoffs);
p.y = FIXED_TO_FLOAT(temp) - vz;
// m is the v direction vector in view space
ang = ANG2RAD(ANGLE_180 - viewangle - pl->plangle);
m.x = cos(ang);
m.z = sin(ang);
// n is the u direction vector in view space
n.x = sin(ang);
n.z = -cos(ang);
ang = ANG2RAD(pl->plangle);
temp = P_GetZAt(pl->slope, viewx + FLOAT_TO_FIXED(sin(ang)), viewy + FLOAT_TO_FIXED(cos(ang)));
m.y = FIXED_TO_FLOAT(temp) - zeroheight;
temp = P_GetZAt(pl->slope, viewx + FLOAT_TO_FIXED(cos(ang)), viewy - FLOAT_TO_FIXED(sin(ang)));
n.y = FIXED_TO_FLOAT(temp) - zeroheight;
m.x /= fudge;
m.y /= fudge;
m.z /= fudge;
n.x *= fudge;
n.y *= fudge;
n.z *= fudge;
// Eh. I tried making this stuff fixed-point and it exploded on me. Here's a macro for the only floating-point vector function I recall using.
#define CROSS(d, v1, v2) \
d.x = (v1.y * v2.z) - (v1.z * v2.y);\
d.y = (v1.z * v2.x) - (v1.x * v2.z);\
d.z = (v1.x * v2.y) - (v1.y * v2.x)
CROSS(ds_su, p, m);
CROSS(ds_sv, p, n);
CROSS(ds_sz, m, n);
#undef CROSS
ds_su.z *= focallengthf;
ds_sv.z *= focallengthf;
ds_sz.z *= focallengthf;
// Premultiply the texture vectors with the scale factors
#define SFMULT 65536.f*(1<<nflatshiftup)
ds_su.x *= SFMULT;
ds_su.y *= SFMULT;
ds_su.z *= SFMULT;
ds_sv.x *= SFMULT;
ds_sv.y *= SFMULT;
ds_sv.z *= SFMULT;
#undef SFMULT
if (spanfunc == R_DrawTranslucentSpan_8)
spanfunc = R_DrawTiltedTranslucentSpan_8;
else if (spanfunc == splatfunc)
spanfunc = R_DrawTiltedSplat_8;
else
spanfunc = R_DrawTiltedSpan_8;
planezlight = scalelight[light];
} else
#endif // ESLOPE
planezlight = zlight[light];
// set the maximum value for unsigned
@ -951,7 +1066,7 @@ using the palette colors.
if (spanfunc == R_DrawSpan_8)
{
INT32 i;
ds_transmap = ((tr_trans50)<<FF_TRANSSHIFT) - 0x10000 + transtables;
ds_transmap = transtables + ((tr_trans50-1)<<FF_TRANSSHIFT);
spanfunc = R_DrawTranslucentSpan_8;
for (i=0; i<4; i++)
{

View File

@ -61,6 +61,9 @@ typedef struct visplane_s
#ifdef POLYOBJECTS_PLANES
polyobj_t *polyobj;
#endif
#ifdef ESLOPE
pslope_t *slope;
#endif
} visplane_t;
extern visplane_t *floorplane;
@ -79,6 +82,8 @@ extern fixed_t cachedxstep[MAXVIDHEIGHT];
extern fixed_t cachedystep[MAXVIDHEIGHT];
extern fixed_t basexscale, baseyscale;
extern lighttable_t **planezlight;
extern fixed_t *yslope;
extern fixed_t distscale[MAXVIDWIDTH];
@ -91,7 +96,11 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2);
void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2);
void R_DrawPlanes(void);
visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, fixed_t xoff, fixed_t yoff, angle_t plangle,
extracolormap_t *planecolormap, ffloor_t *ffloor);
extracolormap_t *planecolormap, ffloor_t *ffloor
#ifdef ESLOPE
, pslope_t *slope
#endif
);
visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop);
void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop);
void R_PlaneBounds(visplane_t *plane);
@ -110,6 +119,14 @@ typedef struct planemgr_s
INT16 f_clip[MAXVIDWIDTH];
INT16 c_clip[MAXVIDWIDTH];
#ifdef ESLOPE
// For slope rendering; the height at the other end
fixed_t f_pos_slope;
fixed_t b_pos_slope;
struct pslope_s *slope;
#endif
struct ffloor_s *ffloor;
#ifdef POLYOBJECTS_PLANES
polyobj_t *polyobj;

File diff suppressed because it is too large Load Diff

View File

@ -503,7 +503,7 @@ static void R_RenderFloorSplat(floorsplat_t *pSplat, vertex_t *verts, UINT8 *pTe
{
ds_x1 = x1;
ds_x2 = x2;
ds_transmap = ((tr_trans50)<<FF_TRANSSHIFT) - 0x10000 + transtables;
ds_transmap = transtables + ((tr_trans50-1)<<FF_TRANSSHIFT);
splatfunc();
}

View File

@ -24,6 +24,7 @@
#include "r_plane.h"
#include "p_tick.h"
#include "p_local.h"
#include "p_slopes.h"
#include "dehacked.h" // get_number (for thok)
#include "d_netfil.h" // blargh. for nameonly().
#include "m_cheat.h" // objectplace
@ -950,12 +951,22 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing)
for (i = 1; i < sector->numlights; i++)
{
if (sector->lightlist[i].height >= sprite->gzt || !(sector->lightlist[i].caster->flags & FF_CUTSPRITES))
fixed_t testheight = sector->lightlist[i].height;
if (!(sector->lightlist[i].caster->flags & FF_CUTSPRITES))
continue;
if (sector->lightlist[i].height <= sprite->gz)
#ifdef ESLOPE
if (sector->lightlist[i].slope)
testheight = P_GetZAt(sector->lightlist[i].slope, sprite->gx, sprite->gy);
#endif
if (testheight >= sprite->gzt)
continue;
if (testheight <= sprite->gz)
return;
cutfrac = (INT16)((centeryfrac - FixedMul(sector->lightlist[i].height - viewz, sprite->scale))>>FRACBITS);
cutfrac = (INT16)((centeryfrac - FixedMul(testheight - viewz, sprite->scale))>>FRACBITS);
if (cutfrac < 0)
continue;
if (cutfrac > vid.height)
@ -966,15 +977,15 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing)
newsprite = M_Memcpy(R_NewVisSprite(), sprite, sizeof (vissprite_t));
sprite->cut |= SC_BOTTOM;
sprite->gz = sector->lightlist[i].height;
sprite->gz = testheight;
newsprite->gzt = sprite->gz;
sprite->sz = cutfrac;
newsprite->szt = (INT16)(sprite->sz - 1);
if (sector->lightlist[i].height < sprite->pzt && sector->lightlist[i].height > sprite->pz)
sprite->pz = newsprite->pzt = sector->lightlist[i].height;
if (testheight < sprite->pzt && testheight > sprite->pz)
sprite->pz = newsprite->pzt = testheight;
else
{
newsprite->pz = newsprite->gz;
@ -1191,7 +1202,20 @@ static void R_ProjectSprite(mobj_t *thing)
if (thing->subsector->sector->numlights)
{
INT32 lightnum;
#ifdef ESLOPE // R_GetPlaneLight won't work on sloped lights!
light = thing->subsector->sector->numlights - 1;
for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) {
fixed_t h = thing->subsector->sector->lightlist[lightnum].slope ? P_GetZAt(thing->subsector->sector->lightlist[lightnum].slope, thing->x, thing->y)
: thing->subsector->sector->lightlist[lightnum].height;
if (h <= gzt) {
light = lightnum - 1;
break;
}
}
#else
light = R_GetPlaneLight(thing->subsector->sector, gzt, false);
#endif
lightnum = (*thing->subsector->sector->lightlist[light].lightlevel >> LIGHTSEGSHIFT);
if (lightnum < 0)
@ -1233,7 +1257,8 @@ static void R_ProjectSprite(mobj_t *thing)
vis = R_NewVisSprite();
vis->heightsec = heightsec; //SoM: 3/17/2000
vis->mobjflags = thing->flags;
vis->scale = yscale + thing->info->dispoffset; //<<detailshift;
vis->scale = yscale; //<<detailshift;
vis->dispoffset = thing->info->dispoffset; // Monster Iestyn: 23/11/15
vis->gx = thing->x;
vis->gy = thing->y;
vis->gz = gz;
@ -1296,9 +1321,9 @@ static void R_ProjectSprite(mobj_t *thing)
if (!cv_translucency.value)
; // no translucency
else if (thing->flags2 & MF2_SHADOW) // actually only the player should use this (temporary invisibility)
vis->transmap = ((tr_trans80-1)<<FF_TRANSSHIFT) + transtables; // because now the translucency is set through FF_TRANSMASK
vis->transmap = transtables + ((tr_trans80-1)<<FF_TRANSSHIFT); // because now the translucency is set through FF_TRANSMASK
else if (thing->frame & FF_TRANSMASK)
vis->transmap = (thing->frame & FF_TRANSMASK) - 0x10000 + transtables;
vis->transmap = transtables + (thing->frame & FF_TRANSMASK) - 0x10000;
if (((thing->frame & FF_FULLBRIGHT) || (thing->flags2 & MF2_SHADOW))
&& (!vis->extra_colormap || !vis->extra_colormap->fog))
@ -1449,6 +1474,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
// store information in a vissprite
vis = R_NewVisSprite();
vis->scale = yscale; //<<detailshift;
vis->dispoffset = 0; // Monster Iestyn: 23/11/15
vis->gx = thing->x;
vis->gy = thing->y;
vis->gz = gz;
@ -1600,6 +1626,7 @@ void R_SortVisSprites(void)
vissprite_t *best = NULL;
vissprite_t unsorted;
fixed_t bestscale;
INT32 bestdispoffset;
if (!visspritecount)
return;
@ -1630,12 +1657,19 @@ void R_SortVisSprites(void)
vsprsortedhead.next = vsprsortedhead.prev = &vsprsortedhead;
for (i = 0; i < visspritecount; i++)
{
bestscale = INT32_MAX;
bestscale = bestdispoffset = INT32_MAX;
for (ds = unsorted.next; ds != &unsorted; ds = ds->next)
{
if (ds->scale < bestscale)
{
bestscale = ds->scale;
bestdispoffset = ds->dispoffset;
best = ds;
}
// order visprites of same scale by dispoffset, smallest first
else if (ds->scale == bestscale && ds->dispoffset < bestdispoffset)
{
bestdispoffset = ds->dispoffset;
best = ds;
}
}
@ -1752,24 +1786,34 @@ static void R_CreateDrawNodes(void)
{
if (r2->plane)
{
fixed_t planeobjectz, planecameraz;
if (r2->plane->minx > rover->x2 || r2->plane->maxx < rover->x1)
continue;
if (rover->szt > r2->plane->low || rover->sz < r2->plane->high)
continue;
#ifdef ESLOPE
// Effective height may be different for each comparison in the case of slopes
if (r2->plane->slope) {
planeobjectz = P_GetZAt(r2->plane->slope, rover->gx, rover->gy);
planecameraz = P_GetZAt(r2->plane->slope, viewx, viewy);
} else
#endif
planeobjectz = planecameraz = r2->plane->height;
if (rover->mobjflags & MF_NOCLIPHEIGHT)
{
//Objects with NOCLIPHEIGHT can appear halfway in.
if (r2->plane->height < viewz && rover->pz+(rover->thingheight/2) >= r2->plane->height)
if (planecameraz < viewz && rover->pz+(rover->thingheight/2) >= planeobjectz)
continue;
if (r2->plane->height > viewz && rover->pzt-(rover->thingheight/2) <= r2->plane->height)
if (planecameraz > viewz && rover->pzt-(rover->thingheight/2) <= planeobjectz)
continue;
}
else
{
if (r2->plane->height < viewz && rover->pz >= r2->plane->height)
if (planecameraz < viewz && rover->pz >= planeobjectz)
continue;
if (r2->plane->height > viewz && rover->pzt <= r2->plane->height)
if (planecameraz > viewz && rover->pzt <= planeobjectz)
continue;
}
@ -1799,6 +1843,7 @@ static void R_CreateDrawNodes(void)
}
else if (r2->thickseg)
{
fixed_t topplaneobjectz, topplanecameraz, botplaneobjectz, botplanecameraz;
if (rover->x1 > r2->thickseg->x2 || rover->x2 < r2->thickseg->x1)
continue;
@ -1809,9 +1854,25 @@ static void R_CreateDrawNodes(void)
if (scale <= rover->scale)
continue;
if ((*r2->ffloor->topheight > viewz && *r2->ffloor->bottomheight < viewz) ||
(*r2->ffloor->topheight < viewz && rover->gzt < *r2->ffloor->topheight) ||
(*r2->ffloor->bottomheight > viewz && rover->gz > *r2->ffloor->bottomheight))
#ifdef ESLOPE
if (*r2->ffloor->t_slope) {
topplaneobjectz = P_GetZAt(*r2->ffloor->t_slope, rover->gx, rover->gy);
topplanecameraz = P_GetZAt(*r2->ffloor->t_slope, viewx, viewy);
} else
#endif
topplaneobjectz = topplanecameraz = *r2->ffloor->topheight;
#ifdef ESLOPE
if (*r2->ffloor->b_slope) {
botplaneobjectz = P_GetZAt(*r2->ffloor->b_slope, rover->gx, rover->gy);
botplanecameraz = P_GetZAt(*r2->ffloor->b_slope, viewx, viewy);
} else
#endif
botplaneobjectz = botplanecameraz = *r2->ffloor->bottomheight;
if ((topplanecameraz > viewz && botplanecameraz < viewz) ||
(topplanecameraz < viewz && rover->gzt < topplaneobjectz) ||
(botplanecameraz > viewz && rover->gz > botplaneobjectz))
{
entry = R_CreateDrawNode(NULL);
(entry->prev = r2->prev)->next = entry;
@ -1860,7 +1921,8 @@ static void R_CreateDrawNodes(void)
if (r2->sprite->szt > rover->sz || r2->sprite->sz < rover->szt)
continue;
if (r2->sprite->scale > rover->scale)
if (r2->sprite->scale > rover->scale
|| (r2->sprite->scale == rover->scale && r2->sprite->dispoffset > rover->dispoffset))
{
entry = R_CreateDrawNode(NULL);
(entry->prev = r2->prev)->next = entry;
@ -2030,21 +2092,21 @@ void R_ClipSprites(void)
if (spr->gzt <= ds->tsilheight)
silhouette &= ~SIL_TOP;
if (silhouette == 1)
if (silhouette == SIL_BOTTOM)
{
// bottom sil
for (x = r1; x <= r2; x++)
if (spr->clipbot[x] == -2)
spr->clipbot[x] = ds->sprbottomclip[x];
}
else if (silhouette == 2)
else if (silhouette == SIL_TOP)
{
// top sil
for (x = r1; x <= r2; x++)
if (spr->cliptop[x] == -2)
spr->cliptop[x] = ds->sprtopclip[x];
}
else if (silhouette == 3)
else if (silhouette == (SIL_TOP|SIL_BOTTOM))
{
// both
for (x = r1; x <= r2; x++)

View File

@ -162,6 +162,7 @@ typedef struct vissprite_s
boolean precip;
boolean vflip; // Flip vertically
boolean isScaled;
INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing
} vissprite_t;
// A drawnode is something that points to a 3D floor, 3D side, or masked

View File

@ -23,7 +23,7 @@
#ifdef CMAKECONFIG
#include "config.h"
#else
#include "config.h.in"
#include "../config.h.in"
#endif
#ifndef _WIN32_WCE

View File

@ -217,10 +217,12 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
}
}
#ifdef HWRENDER
if (rendermode == render_opengl)
{
OglSdlSurface(vid.width, vid.height);
}
#endif
if (rendermode == render_soft)
{
@ -401,9 +403,11 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code)
default:
break;
}
#ifdef HWRENDER
DBG_Printf("Unknown incoming scancode: %d, represented %c\n",
code,
SDL_GetKeyName(SDL_GetKeyFromScancode(code)));
#endif
return 0;
}

View File

@ -1842,37 +1842,6 @@ static void ST_overlayDrawer(void)
LUAh_GameHUD(stplyr);
#endif
#if 0 // Pope XVI
if (!(netgame || multiplayer) && !modifiedgame && gamemap == 11 && ALL7EMERALDS(emeralds)
&& stplyr->mo && stplyr->mo->subsector && stplyr->mo->subsector->sector-sectors == 1361)
{
if (grade & 2048) // NAGZ
{
V_DrawCenteredString(BASEVIDWIDTH/2, 70, 0, M_GetText("I, Pope Rededict XVI proclaim"));
V_DrawCenteredString(BASEVIDWIDTH/2, 80, 0, M_GetText("AJ & Amy"));
V_DrawCenteredString(BASEVIDWIDTH/2, 90, 0, M_GetText("Husband & Wife"));
V_DrawCenteredString(BASEVIDWIDTH/2, 100, 0, M_GetText("on this day"));
V_DrawCenteredString(BASEVIDWIDTH/2, 110, 0, M_GetText("May 16, 2009"));
P_GivePlayerRings(stplyr, 9999);
}
else
{
V_DrawCenteredString(BASEVIDWIDTH/2, 60, 0, M_GetText("Oh... it's you again..."));
V_DrawCenteredString(BASEVIDWIDTH/2, 80, 0, M_GetText("Look, I wanted to apologize for the way"));
V_DrawCenteredString(BASEVIDWIDTH/2, 90, 0, M_GetText("I've acted in the past."));
V_DrawCenteredString(BASEVIDWIDTH/2, 110, 0, M_GetText("I've seen the error of my ways"));
V_DrawCenteredString(BASEVIDWIDTH/2, 120, 0, M_GetText("and turned over a new leaf."));
V_DrawCenteredString(BASEVIDWIDTH/2, 140, 0, M_GetText("Instead of sending people to hell,"));
V_DrawCenteredString(BASEVIDWIDTH/2, 150, 0, M_GetText("I now send them to heaven!"));
P_LinedefExecute(4200, stplyr->mo, stplyr->mo->subsector->sector);
P_LinedefExecute(4201, stplyr->mo, stplyr->mo->subsector->sector);
stplyr->mo->momx = stplyr->mo->momy = 0;
}
}
#endif
// draw level title Tails
if (*mapheaderinfo[gamemap-1]->lvlttl != '\0' && !(hu_showscores && (netgame || multiplayer))
#ifdef HAVE_BLUA

File diff suppressed because it is too large Load Diff

View File

@ -96,9 +96,6 @@ FUNCMATH angle_t FixedAngle(fixed_t fa);
// and with a factor, with +factor for (fa/factor) and -factor for (fa*factor)
FUNCMATH angle_t FixedAngleC(fixed_t fa, fixed_t factor);
#ifdef NEED_FIXED_VECTOR
/// The FixedAcos function
FUNCMATH angle_t FixedAcos(fixed_t x);
@ -112,8 +109,6 @@ void FV3_Rotate(vector3_t *rotVec, const vector3_t *axisVec, const angle_t angle
/// Fixed Point Matrix functions
void FM_Rotate(matrix_t *dest, angle_t angle, fixed_t x, fixed_t y, fixed_t z);
#endif // defined NEED_FIXED_VECTOR
// The table values in tables.c are calculated with this many fractional bits.
#define FINE_FRACBITS 16

View File

@ -366,7 +366,7 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t
}
if (alphalevel)
{
v_translevel = ((alphalevel)<<FF_TRANSSHIFT) - 0x10000 + transtables;
v_translevel = transtables + ((alphalevel-1)<<FF_TRANSSHIFT);
patchdrawfunc = translucentpdraw;
}
@ -1869,7 +1869,7 @@ void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param)
angle_t disStart = (leveltime * 128) & FINEMASK; // in 0 to FINEANGLE
INT32 newpix;
INT32 sine;
//UINT8 *transme = ((tr_trans50)<<FF_TRANSSHIFT) + transtables;
//UINT8 *transme = transtables + ((tr_trans50-1)<<FF_TRANSSHIFT);
for (y = yoffset; y < yoffset+height; y++)
{
@ -1926,7 +1926,7 @@ Unoptimized version
INT32 x, y;
// TODO: Add a postimg_param so that we can pick the translucency level...
UINT8 *transme = ((param)<<FF_TRANSSHIFT) - 0x10000 + transtables;
UINT8 *transme = transtables + ((param-1)<<FF_TRANSSHIFT);
for (y = yoffset; y < yoffset+height; y++)
{

View File

@ -16,8 +16,6 @@
#ifdef HWRENDER
#include "hardware/hw_data.h"
#else
typedef void GLPatch_t;
#endif
#ifdef __GNUG__

View File

@ -351,6 +351,13 @@ int main(int argc, char** argv)
return 0;
}
static void *cpu_cpy(void *dest, const void *src, size_t n)
{
return memcpy(dest, src, n);
}
void *(*M_Memcpy)(void* dest, const void* src, size_t n) = cpu_cpy;
void I_Error(const char *error, ...)
{
(void)error;