Merge remote-tracking branch 'upstream/next' into next-newcontrols

This commit is contained in:
fickleheart 2020-01-07 23:43:43 -06:00
commit c133e645f7
22 changed files with 360 additions and 155 deletions

View file

@ -9,7 +9,7 @@ environment:
# c:\mingw-w64 i686 has gcc 6.3.0, so use c:\msys64 7.3.0 instead # c:\mingw-w64 i686 has gcc 6.3.0, so use c:\msys64 7.3.0 instead
MINGW_SDK: c:\msys64\mingw32 MINGW_SDK: c:\msys64\mingw32
# c:\msys64 x86_64 has gcc 8.2.0, so use c:\mingw-w64 7.3.0 instead # c:\msys64 x86_64 has gcc 8.2.0, so use c:\mingw-w64 7.3.0 instead
MINGW_SDK_64: C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64 MINGW_SDK_64: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64
CFLAGS: -Wall -W -Werror -Wno-error=implicit-fallthrough -Wimplicit-fallthrough=3 -Wno-tautological-compare -Wno-error=suggest-attribute=noreturn CFLAGS: -Wall -W -Werror -Wno-error=implicit-fallthrough -Wimplicit-fallthrough=3 -Wno-tautological-compare -Wno-error=suggest-attribute=noreturn
NASM_ZIP: nasm-2.12.01 NASM_ZIP: nasm-2.12.01
NASM_URL: http://www.nasm.us/pub/nasm/releasebuilds/2.12.01/win64/nasm-2.12.01-win64.zip NASM_URL: http://www.nasm.us/pub/nasm/releasebuilds/2.12.01/win64/nasm-2.12.01-win64.zip
@ -83,8 +83,8 @@ before_build:
- ccache -V - ccache -V
- ccache -s - ccache -s
- if [%NOUPX%] == [1] ( set "NOUPX=NOUPX=1" ) else ( set "NOUPX=" ) - if [%NOUPX%] == [1] ( set "NOUPX=NOUPX=1" ) else ( set "NOUPX=" )
- set "SRB2_MFLAGS=-C src WARNINGMODE=1 CCACHE=1 GCC73=1 NOOBJDUMP=1 %NOUPX%" - set "SRB2_MFLAGS=-C src WARNINGMODE=1 CCACHE=1 NOOBJDUMP=1 %NOUPX%"
- if [%X86_64%] == [1] ( set "MINGW_FLAGS=MINGW64=1 X86_64=1" ) else ( set "MINGW_FLAGS=MINGW=1 GCC91=1" ) - if [%X86_64%] == [1] ( set "MINGW_FLAGS=MINGW64=1 X86_64=1 GCC81=1" ) else ( set "MINGW_FLAGS=MINGW=1 GCC91=1" )
- set "SRB2_MFLAGS=%SRB2_MFLAGS% %MINGW_FLAGS% %CONFIGURATION%=1" - set "SRB2_MFLAGS=%SRB2_MFLAGS% %MINGW_FLAGS% %CONFIGURATION%=1"
build_script: build_script:

View file

@ -449,8 +449,12 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 count, poly_t *poly)
// for each seg of the subsector // for each seg of the subsector
for (; count--; lseg++) for (; count--; lseg++)
{ {
//x,y,dx,dy (like a divline)
line_t *line = lseg->linedef; line_t *line = lseg->linedef;
if (lseg->glseg)
continue;
//x,y,dx,dy (like a divline)
p1.x = FIXED_TO_FLOAT(lseg->side ? line->v2->x : line->v1->x); p1.x = FIXED_TO_FLOAT(lseg->side ? line->v2->x : line->v1->x);
p1.y = FIXED_TO_FLOAT(lseg->side ? line->v2->y : line->v1->y); p1.y = FIXED_TO_FLOAT(lseg->side ? line->v2->y : line->v1->y);
p2.x = FIXED_TO_FLOAT(lseg->side ? line->v1->x : line->v2->x); p2.x = FIXED_TO_FLOAT(lseg->side ? line->v1->x : line->v2->x);

View file

@ -2714,8 +2714,6 @@ static void HWR_AddLine(seg_t * line)
static sector_t tempsec; static sector_t tempsec;
fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t
if (line->glseg)
return;
#ifdef POLYOBJECTS #ifdef POLYOBJECTS
if (line->polyseg && !(line->polyseg->flags & POF_RENDERSIDES)) if (line->polyseg && !(line->polyseg->flags & POF_RENDERSIDES))
return; return;
@ -3773,11 +3771,16 @@ static void HWR_Subsector(size_t num)
while (count--) while (count--)
{ {
if (!line->glseg
#ifdef POLYOBJECTS #ifdef POLYOBJECTS
if (!line->polyseg) // ignore segs that belong to polyobjects && !line->polyseg // ignore segs that belong to polyobjects
#endif #endif
)
{
HWR_AddLine(line); HWR_AddLine(line);
line++; }
line++;
} }
} }

View file

@ -20,9 +20,12 @@ enum hook {
hook_MapChange, hook_MapChange,
hook_MapLoad, hook_MapLoad,
hook_PlayerJoin, hook_PlayerJoin,
hook_PreThinkFrame,
hook_ThinkFrame, hook_ThinkFrame,
hook_PostThinkFrame,
hook_MobjSpawn, hook_MobjSpawn,
hook_MobjCollide, hook_MobjCollide,
hook_MobjLineCollide,
hook_MobjMoveCollide, hook_MobjMoveCollide,
hook_TouchSpecial, hook_TouchSpecial,
hook_MobjFuse, hook_MobjFuse,
@ -62,12 +65,16 @@ extern const char *const hookNames[];
void LUAh_MapChange(INT16 mapnumber); // Hook for map change (before load) void LUAh_MapChange(INT16 mapnumber); // Hook for map change (before load)
void LUAh_MapLoad(void); // Hook for map load void LUAh_MapLoad(void); // Hook for map load
void LUAh_PlayerJoin(int playernum); // Hook for Got_AddPlayer void LUAh_PlayerJoin(int playernum); // Hook for Got_AddPlayer
void LUAh_PreThinkFrame(void); // Hook for frame (before mobj and player thinkers)
void LUAh_ThinkFrame(void); // Hook for frame (after mobj and player thinkers) void LUAh_ThinkFrame(void); // Hook for frame (after mobj and player thinkers)
void LUAh_PostThinkFrame(void); // Hook for frame (at end of tick, ie after overlays, precipitation, specials)
boolean LUAh_MobjHook(mobj_t *mo, enum hook which); boolean LUAh_MobjHook(mobj_t *mo, enum hook which);
boolean LUAh_PlayerHook(player_t *plr, 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 #define LUAh_MobjSpawn(mo) LUAh_MobjHook(mo, hook_MobjSpawn) // Hook for P_SpawnMobj by mobj type
UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which); UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which);
UINT8 LUAh_MobjLineCollideHook(mobj_t *thing, line_t *line, enum hook which);
#define LUAh_MobjCollide(thing1, thing2) LUAh_MobjCollideHook(thing1, thing2, hook_MobjCollide) // Hook for PIT_CheckThing by (thing) mobj type #define LUAh_MobjCollide(thing1, thing2) LUAh_MobjCollideHook(thing1, thing2, hook_MobjCollide) // Hook for PIT_CheckThing by (thing) mobj type
#define LUAh_MobjLineCollide(thing, line) LUAh_MobjLineCollideHook(thing, line, hook_MobjLineCollide) // 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 #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 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_MobjFuse(mo) LUAh_MobjHook(mo, hook_MobjFuse) // Hook for mobj->fuse == 0 by mobj type

View file

@ -31,9 +31,12 @@ const char *const hookNames[hook_MAX+1] = {
"MapChange", "MapChange",
"MapLoad", "MapLoad",
"PlayerJoin", "PlayerJoin",
"PreThinkFrame",
"ThinkFrame", "ThinkFrame",
"PostThinkFrame",
"MobjSpawn", "MobjSpawn",
"MobjCollide", "MobjCollide",
"MobjLineCollide",
"MobjMoveCollide", "MobjMoveCollide",
"TouchSpecial", "TouchSpecial",
"MobjFuse", "MobjFuse",
@ -124,6 +127,7 @@ static int lib_addHook(lua_State *L)
// Take a mobjtype enum which this hook is specifically for. // Take a mobjtype enum which this hook is specifically for.
case hook_MobjSpawn: case hook_MobjSpawn:
case hook_MobjCollide: case hook_MobjCollide:
case hook_MobjLineCollide:
case hook_MobjMoveCollide: case hook_MobjMoveCollide:
case hook_TouchSpecial: case hook_TouchSpecial:
case hook_MobjFuse: case hook_MobjFuse:
@ -183,6 +187,7 @@ static int lib_addHook(lua_State *L)
lastp = &mobjthinkerhooks[hook.s.mt]; lastp = &mobjthinkerhooks[hook.s.mt];
break; break;
case hook_MobjCollide: case hook_MobjCollide:
case hook_MobjLineCollide:
case hook_MobjMoveCollide: case hook_MobjMoveCollide:
lastp = &mobjcollidehooks[hook.s.mt]; lastp = &mobjcollidehooks[hook.s.mt];
break; break;
@ -413,6 +418,29 @@ void LUAh_PlayerJoin(int playernum)
lua_settop(gL, 0); lua_settop(gL, 0);
} }
// Hook for frame (before mobj and player thinkers)
void LUAh_PreThinkFrame(void)
{
hook_p hookp;
if (!gL || !(hooksAvailable[hook_PreThinkFrame/8] & (1<<(hook_PreThinkFrame%8))))
return;
for (hookp = roothook; hookp; hookp = hookp->next)
{
if (hookp->type != hook_PreThinkFrame)
continue;
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
if (lua_pcall(gL, 0, 0, 0)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
}
}
}
// Hook for frame (after mobj and player thinkers) // Hook for frame (after mobj and player thinkers)
void LUAh_ThinkFrame(void) void LUAh_ThinkFrame(void)
{ {
@ -436,6 +464,30 @@ void LUAh_ThinkFrame(void)
} }
} }
// Hook for frame (at end of tick, ie after overlays, precipitation, specials)
void LUAh_PostThinkFrame(void)
{
hook_p hookp;
if (!gL || !(hooksAvailable[hook_PostThinkFrame/8] & (1<<(hook_PostThinkFrame%8))))
return;
for (hookp = roothook; hookp; hookp = hookp->next)
{
if (hookp->type != hook_PostThinkFrame)
continue;
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
if (lua_pcall(gL, 0, 0, 0)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
}
}
}
// Hook for mobj collisions // Hook for mobj collisions
UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which) UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which)
{ {
@ -515,6 +567,84 @@ UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which)
return shouldCollide; return shouldCollide;
} }
UINT8 LUAh_MobjLineCollideHook(mobj_t *thing, line_t *line, enum hook which)
{
hook_p hookp;
UINT8 shouldCollide = 0; // 0 = default, 1 = force yes, 2 = force no.
if (!gL || !(hooksAvailable[which/8] & (1<<(which%8))))
return 0;
I_Assert(thing->type < NUMMOBJTYPES);
lua_settop(gL, 0);
// Look for all generic mobj collision hooks
for (hookp = mobjcollidehooks[MT_NULL]; hookp; hookp = hookp->next)
{
if (hookp->type != which)
continue;
if (lua_gettop(gL) == 0)
{
LUA_PushUserdata(gL, thing, META_MOBJ);
LUA_PushUserdata(gL, line, META_LINE);
}
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
lua_pushvalue(gL, -3);
lua_pushvalue(gL, -3);
if (lua_pcall(gL, 2, 1, 0)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
continue;
}
if (!lua_isnil(gL, -1))
{ // if nil, leave shouldCollide = 0.
if (lua_toboolean(gL, -1))
shouldCollide = 1; // Force yes
else
shouldCollide = 2; // Force no
}
lua_pop(gL, 1);
}
for (hookp = mobjcollidehooks[thing->type]; hookp; hookp = hookp->next)
{
if (hookp->type != which)
continue;
if (lua_gettop(gL) == 0)
{
LUA_PushUserdata(gL, thing, META_MOBJ);
LUA_PushUserdata(gL, line, META_LINE);
}
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
lua_pushvalue(gL, -3);
lua_pushvalue(gL, -3);
if (lua_pcall(gL, 2, 1, 0)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
continue;
}
if (!lua_isnil(gL, -1))
{ // if nil, leave shouldCollide = 0.
if (lua_toboolean(gL, -1))
shouldCollide = 1; // Force yes
else
shouldCollide = 2; // Force no
}
lua_pop(gL, 1);
}
lua_settop(gL, 0);
return shouldCollide;
}
// Hook for mobj thinkers // Hook for mobj thinkers
boolean LUAh_MobjThinker(mobj_t *mo) boolean LUAh_MobjThinker(mobj_t *mo)
{ {

View file

@ -157,15 +157,13 @@ static const char *const side_opt[] = {
enum vertex_e { enum vertex_e {
vertex_valid = 0, vertex_valid = 0,
vertex_x, vertex_x,
vertex_y, vertex_y
vertex_z
}; };
static const char *const vertex_opt[] = { static const char *const vertex_opt[] = {
"valid", "valid",
"x", "x",
"y", "y",
"z",
NULL}; NULL};
enum ffloor_e { enum ffloor_e {
@ -970,9 +968,6 @@ static int vertex_get(lua_State *L)
case vertex_y: case vertex_y:
lua_pushfixed(L, vertex->y); lua_pushfixed(L, vertex->y);
return 1; return 1;
case vertex_z:
lua_pushfixed(L, vertex->z);
return 1;
} }
return 0; return 0;
} }

View file

@ -10730,15 +10730,78 @@ static void M_HandleConnectIP(INT32 choice)
break; break;
case KEY_DEL: case KEY_DEL:
if (setupm_ip[0]) if (setupm_ip[0] && !shiftdown) // Shift+Delete is used for something else.
{ {
S_StartSound(NULL,sfx_menu1); // Tails S_StartSound(NULL,sfx_menu1); // Tails
setupm_ip[0] = 0; setupm_ip[0] = 0;
} }
break; if (!shiftdown) // Shift+Delete is used for something else.
break;
/* FALLTHRU */
default: default:
l = strlen(setupm_ip); l = strlen(setupm_ip);
if ( ctrldown ) {
switch (choice) {
case 'v':
case 'V': // ctrl+v, pasting
{
const char *paste = I_ClipboardPaste();
if (paste != NULL) {
strncat(setupm_ip, paste, 28-1 - l); // Concat the ip field with clipboard
if (strlen(paste) != 0) // Don't play sound if nothing was pasted
S_StartSound(NULL,sfx_menu1); // Tails
}
break;
}
case KEY_INS:
case 'c':
case 'C': // ctrl+c, ctrl+insert, copying
I_ClipboardCopy(setupm_ip, l);
S_StartSound(NULL,sfx_menu1); // Tails
break;
case 'x':
case 'X': // ctrl+x, cutting
I_ClipboardCopy(setupm_ip, l);
S_StartSound(NULL,sfx_menu1); // Tails
setupm_ip[0] = 0;
break;
default: // otherwise do nothing
break;
}
break; // don't check for typed keys
}
if ( shiftdown ) {
switch (choice) {
case KEY_INS: // shift+insert, pasting
{
const char *paste = I_ClipboardPaste();
if (paste != NULL) {
strncat(setupm_ip, paste, 28-1 - l); // Concat the ip field with clipboard
if (strlen(paste) != 0) // Don't play sound if nothing was pasted
S_StartSound(NULL,sfx_menu1); // Tails
}
break;
}
case KEY_DEL: // shift+delete, cutting
I_ClipboardCopy(setupm_ip, l);
S_StartSound(NULL,sfx_menu1); // Tails
setupm_ip[0] = 0;
break;
default: // otherwise do nothing.
break;
}
break; // don't check for typed keys
}
if (l >= 28-1) if (l >= 28-1)
break; break;

View file

@ -1948,6 +1948,19 @@ static boolean PIT_CheckLine(line_t *ld)
// this line is out of the if so upper and lower textures can be hit by a splat // this line is out of the if so upper and lower textures can be hit by a splat
blockingline = ld; blockingline = ld;
#ifdef HAVE_BLUA
{
UINT8 shouldCollide = LUAh_MobjLineCollide(tmthing, blockingline); // checks hook for thing's type
if (P_MobjWasRemoved(tmthing))
return true; // one of them was removed???
if (shouldCollide == 1)
return false; // force collide
else if (shouldCollide == 2)
return true; // force no collide
}
#endif
if (!ld->backsector) // one sided line if (!ld->backsector) // one sided line
{ {
if (P_PointOnLineSide(tmthing->x, tmthing->y, ld)) if (P_PointOnLineSide(tmthing->x, tmthing->y, ld))

View file

@ -78,68 +78,37 @@ void P_ClosestPointOnLine(fixed_t x, fixed_t y, line_t *line, vertex_t *result)
return; return;
} }
// /// Similar to FV3_ClosestPointOnLine() except it actually works.
// P_ClosestPointOnLine3D void P_ClosestPointOnLine3D(const vector3_t *p, const vector3_t *Line, vector3_t *result)
// Finds the closest point on a given line to the supplied point IN 3D!!!
//
void P_ClosestPointOnLine3D(fixed_t x, fixed_t y, fixed_t z, line_t *line, vertex_t *result)
{ {
fixed_t startx = line->v1->x; const vector3_t* v1 = &Line[0];
fixed_t starty = line->v1->y; const vector3_t* v2 = &Line[1];
fixed_t startz = line->v1->z; vector3_t c, V, n;
fixed_t dx = line->dx; fixed_t t, d;
fixed_t dy = line->dy; FV3_SubEx(v2, v1, &V);
fixed_t dz = line->v2->z - line->v1->z; FV3_SubEx(p, v1, &c);
// Determine t (the length of the vector from <20>Line[0]<5D> to <20>p<EFBFBD>) d = R_PointToDist2(0, v2->z, R_PointToDist2(v2->x, v2->y, v1->x, v1->y), v1->z);
fixed_t cx, cy, cz; FV3_Copy(&n, &V);
fixed_t vx, vy, vz; FV3_Divide(&n, d);
fixed_t magnitude;
fixed_t t;
//Sub (p, &Line[0], &c); t = FV3_Dot(&n, &c);
cx = x - startx;
cy = y - starty;
cz = z - startz;
//Sub (&Line[1], &Line[0], &V);
vx = dx;
vy = dy;
vz = dz;
//Normalize (&V, &V);
magnitude = R_PointToDist2(0, line->v2->z, R_PointToDist2(line->v2->x, line->v2->y, startx, starty), startz);
vx = FixedDiv(vx, magnitude);
vy = FixedDiv(vy, magnitude);
vz = FixedDiv(vz, magnitude);
t = (FixedMul(vx, cx) + FixedMul(vy, cy) + FixedMul(vz, cz));
// Set closest point to the end if it extends past -Red // Set closest point to the end if it extends past -Red
if (t <= 0) if (t <= 0)
{ {
result->x = line->v1->x; FV3_Copy(result, v1);
result->y = line->v1->y;
result->z = line->v1->z;
return; return;
} }
else if (t >= magnitude) else if (t >= d)
{ {
result->x = line->v2->x; FV3_Copy(result, v2);
result->y = line->v2->y;
result->z = line->v2->z;
return; return;
} }
// Return the point between <20>Line[0]<5D> and <20>Line[1]<5D> FV3_Mul(&n, t);
vx = FixedMul(vx, t);
vy = FixedMul(vy, t);
vz = FixedMul(vz, t);
//Add (&Line[0], &V, out); FV3_AddEx(v1, &n, result);
result->x = startx + vx;
result->y = starty + vy;
result->z = startz + vz;
return; return;
} }

View file

@ -43,7 +43,7 @@ boolean P_PathTraverse(fixed_t px1, fixed_t py1, fixed_t px2, fixed_t py2,
FUNCMATH fixed_t P_AproxDistance(fixed_t dx, fixed_t dy); FUNCMATH fixed_t P_AproxDistance(fixed_t dx, fixed_t dy);
void P_ClosestPointOnLine(fixed_t x, fixed_t y, line_t *line, vertex_t *result); void P_ClosestPointOnLine(fixed_t x, fixed_t y, line_t *line, vertex_t *result);
void P_ClosestPointOnLine3D(fixed_t x, fixed_t y, fixed_t z, line_t *line, vertex_t *result); void P_ClosestPointOnLine3D(const vector3_t *p, const vector3_t *line, vector3_t *result);
INT32 P_PointOnLineSide(fixed_t x, fixed_t y, line_t *line); INT32 P_PointOnLineSide(fixed_t x, fixed_t y, line_t *line);
void P_MakeDivline(line_t *li, divline_t *dl); void P_MakeDivline(line_t *li, divline_t *dl);
void P_CameraLineOpening(line_t *plinedef); void P_CameraLineOpening(line_t *plinedef);

View file

@ -7977,15 +7977,19 @@ static void P_MobjSceneryThink(mobj_t *mobj)
mobj->x = mobj->extravalue1 + P_ReturnThrustX(mobj, mobj->movedir, mobj->cvmem*mobj->scale); mobj->x = mobj->extravalue1 + P_ReturnThrustX(mobj, mobj->movedir, mobj->cvmem*mobj->scale);
mobj->y = mobj->extravalue2 + P_ReturnThrustY(mobj, mobj->movedir, mobj->cvmem*mobj->scale); mobj->y = mobj->extravalue2 + P_ReturnThrustY(mobj, mobj->movedir, mobj->cvmem*mobj->scale);
P_SetThingPosition(mobj); P_SetThingPosition(mobj);
if ((--mobj->fuse) < 6)
if (!mobj->fuse)
{ {
if (!mobj->fuse) #ifdef HAVE_BLUA
{ if (!LUAh_MobjFuse(mobj))
#endif
P_RemoveMobj(mobj); P_RemoveMobj(mobj);
return; return;
}
mobj->frame = (mobj->frame & ~FF_TRANSMASK) | ((10 - (mobj->fuse*2)) << (FF_TRANSSHIFT));
} }
if (mobj->fuse < 0)
return;
if ((--mobj->fuse) < 6)
mobj->frame = (mobj->frame & ~FF_TRANSMASK) | ((10 - (mobj->fuse*2)) << (FF_TRANSSHIFT));
} }
break; break;
case MT_VWREF: case MT_VWREF:

View file

@ -846,7 +846,6 @@ static void P_LoadVertices(UINT8 *data)
{ {
v->x = SHORT(mv->x)<<FRACBITS; v->x = SHORT(mv->x)<<FRACBITS;
v->y = SHORT(mv->y)<<FRACBITS; v->y = SHORT(mv->y)<<FRACBITS;
v->z = 0;
} }
} }
@ -1575,7 +1574,6 @@ static void P_LoadTextmap(void)
{ {
// Defaults. // Defaults.
vt->x = vt->y = INT32_MAX; vt->x = vt->y = INT32_MAX;
vt->z = 0;
TextmapParse(vertexesPos[i], i, ParseTextmapVertexParameter); TextmapParse(vertexesPos[i], i, ParseTextmapVertexParameter);
@ -1665,6 +1663,37 @@ static void P_LoadTextmap(void)
} }
} }
static void P_ProcessLinedefsAfterSidedefs(void)
{
size_t i = numlines;
register line_t *ld = lines;
for (; i--; ld++)
{
ld->frontsector = sides[ld->sidenum[0]].sector; //e6y: Can't be -1 here
ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : 0;
// Compile linedef 'text' from both sidedefs 'text' for appropriate specials.
switch (ld->special)
{
case 331: // Trigger linedef executor: Skin - Continuous
case 332: // Trigger linedef executor: Skin - Each time
case 333: // Trigger linedef executor: Skin - Once
case 443: // Calls a named Lua function
if (sides[ld->sidenum[0]].text)
{
size_t len = strlen(sides[ld->sidenum[0]].text) + 1;
if (ld->sidenum[1] != 0xffff && sides[ld->sidenum[1]].text)
len += strlen(sides[ld->sidenum[1]].text);
ld->text = Z_Malloc(len, PU_LEVEL, NULL);
M_Memcpy(ld->text, sides[ld->sidenum[0]].text, strlen(sides[ld->sidenum[0]].text) + 1);
if (ld->sidenum[1] != 0xffff && sides[ld->sidenum[1]].text)
M_Memcpy(ld->text + strlen(ld->text) + 1, sides[ld->sidenum[1]].text, strlen(sides[ld->sidenum[1]].text) + 1);
}
break;
}
}
}
static boolean P_LoadMapData(const virtres_t *virt) static boolean P_LoadMapData(const virtres_t *virt)
{ {
virtlump_t *virtvertexes = NULL, *virtsectors = NULL, *virtsidedefs = NULL, *virtlinedefs = NULL, *virtthings = NULL; virtlump_t *virtvertexes = NULL, *virtsectors = NULL, *virtsidedefs = NULL, *virtlinedefs = NULL, *virtthings = NULL;
@ -1738,6 +1767,8 @@ static boolean P_LoadMapData(const virtres_t *virt)
P_LoadThings(virtthings->data); P_LoadThings(virtthings->data);
} }
P_ProcessLinedefsAfterSidedefs();
R_ClearTextureNumCache(true); R_ClearTextureNumCache(true);
// set the sky flat num // set the sky flat num
@ -1750,15 +1781,6 @@ static boolean P_LoadMapData(const virtres_t *virt)
// search for animated flats and set up // search for animated flats and set up
P_SetupLevelFlatAnims(); P_SetupLevelFlatAnims();
// Copy relevant map data for NetArchive purposes.
spawnsectors = Z_Calloc(numsectors * sizeof (*sectors), PU_LEVEL, NULL);
spawnlines = Z_Calloc(numlines * sizeof (*lines), PU_LEVEL, NULL);
spawnsides = Z_Calloc(numsides * sizeof (*sides), PU_LEVEL, NULL);
memcpy(spawnsectors, sectors, numsectors * sizeof (*sectors));
memcpy(spawnlines, lines, numlines * sizeof (*lines));
memcpy(spawnsides, sides, numsides * sizeof (*sides));
return true; return true;
} }
@ -2517,37 +2539,6 @@ static void P_LoadMapLUT(const virtres_t *virt)
P_CreateBlockMap(); P_CreateBlockMap();
} }
static void P_ProcessLinedefsWithSidedefs(void)
{
size_t i = numlines;
register line_t *ld = lines;
for (;i--;ld++)
{
ld->frontsector = sides[ld->sidenum[0]].sector; //e6y: Can't be -1 here
ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : 0;
// Compile linedef 'text' from both sidedefs 'text' for appropriate specials.
switch(ld->special)
{
case 331: // Trigger linedef executor: Skin - Continuous
case 332: // Trigger linedef executor: Skin - Each time
case 333: // Trigger linedef executor: Skin - Once
case 443: // Calls a named Lua function
if (sides[ld->sidenum[0]].text)
{
size_t len = strlen(sides[ld->sidenum[0]].text)+1;
if (ld->sidenum[1] != 0xffff && sides[ld->sidenum[1]].text)
len += strlen(sides[ld->sidenum[1]].text);
ld->text = Z_Malloc(len, PU_LEVEL, NULL);
M_Memcpy(ld->text, sides[ld->sidenum[0]].text, strlen(sides[ld->sidenum[0]].text)+1);
if (ld->sidenum[1] != 0xffff && sides[ld->sidenum[1]].text)
M_Memcpy(ld->text+strlen(ld->text)+1, sides[ld->sidenum[1]].text, strlen(sides[ld->sidenum[1]].text)+1);
}
break;
}
}
}
// //
// P_LinkMapData // P_LinkMapData
// Builds sector line lists and subsector sector numbers. // Builds sector line lists and subsector sector numbers.
@ -2713,9 +2704,17 @@ static boolean P_LoadMapFromFile(void)
P_LoadMapBSP(virt); P_LoadMapBSP(virt);
P_LoadMapLUT(virt); P_LoadMapLUT(virt);
P_ProcessLinedefsWithSidedefs();
P_LinkMapData(); P_LinkMapData();
// Copy relevant map data for NetArchive purposes.
spawnsectors = Z_Calloc(numsectors * sizeof(*sectors), PU_LEVEL, NULL);
spawnlines = Z_Calloc(numlines * sizeof(*lines), PU_LEVEL, NULL);
spawnsides = Z_Calloc(numsides * sizeof(*sides), PU_LEVEL, NULL);
memcpy(spawnsectors, sectors, numsectors * sizeof(*sectors));
memcpy(spawnlines, lines, numlines * sizeof(*lines));
memcpy(spawnsides, sides, numsides * sizeof(*sides));
P_MakeMapMD5(virt, &mapmd5); P_MakeMapMD5(virt, &mapmd5);
vres_Free(virt); vres_Free(virt);

View file

@ -222,6 +222,9 @@ static boolean P_CrossSubsector(size_t num, register los_t *los)
fixed_t fracx, fracy; fixed_t fracx, fracy;
#endif #endif
if (seg->glseg)
continue;
// already checked other side? // already checked other side?
if (line->validcount == validcount) if (line->validcount == validcount)
continue; continue;

View file

@ -50,10 +50,10 @@ static void ReconfigureViaVertexes (pslope_t *slope, const vector3_t v1, const v
// Set some defaults for a non-sloped "slope" // Set some defaults for a non-sloped "slope"
if (vec1.z == 0 && vec2.z == 0) if (vec1.z == 0 && vec2.z == 0)
{ {
/// \todo Fix fully flat cases.
slope->zangle = slope->xydirection = 0; slope->zangle = slope->xydirection = 0;
slope->zdelta = slope->d.x = slope->d.y = 0; slope->zdelta = slope->d.x = slope->d.y = 0;
slope->normal.x = slope->normal.y = 0;
slope->normal.z = FRACUNIT;
} }
else else
{ {
@ -653,7 +653,9 @@ void P_ReverseQuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope)
// Handles slope ejection for objects // Handles slope ejection for objects
void P_SlopeLaunch(mobj_t *mo) void P_SlopeLaunch(mobj_t *mo)
{ {
if (!(mo->standingslope->flags & SL_NOPHYSICS)) // If there's physics, time for launching. if (!(mo->standingslope->flags & SL_NOPHYSICS) // If there's physics, time for launching.
&& (mo->standingslope->normal.x != 0
|| mo->standingslope->normal.y != 0))
{ {
// Double the pre-rotation Z, then halve the post-rotation Z. This reduces the // Double the pre-rotation Z, then halve the post-rotation Z. This reduces the
// vertical launch given from slopes while increasing the horizontal launch // vertical launch given from slopes while increasing the horizontal launch
@ -710,8 +712,7 @@ fixed_t P_GetWallTransferMomZ(mobj_t *mo, pslope_t *slope)
void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope)
{ {
vector3_t mom; // Ditto. vector3_t mom; // Ditto.
if (slope->flags & SL_NOPHYSICS || (slope->normal.x == 0 && slope->normal.y == 0)) { // No physics, no need to make anything complicated.
if (slope->flags & SL_NOPHYSICS) { // No physics, no need to make anything complicated.
if (P_MobjFlip(thing)*(thing->momz) < 0) // falling, land on slope if (P_MobjFlip(thing)*(thing->momz) < 0) // falling, land on slope
{ {
thing->standingslope = slope; thing->standingslope = slope;

View file

@ -5038,8 +5038,7 @@ DoneSection2:
mobj_t *waypointlow = NULL; mobj_t *waypointlow = NULL;
mobj_t *mo2; mobj_t *mo2;
mobj_t *closest = NULL; mobj_t *closest = NULL;
line_t junk; vector3_t p, line[2], resulthigh, resultlow;
vertex_t v1, v2, resulthigh, resultlow;
mobj_t *highest = NULL; mobj_t *highest = NULL;
if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT && player->powers[pw_carry] == CR_ROPEHANG) if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT && player->powers[pw_carry] == CR_ROPEHANG)
@ -5186,38 +5185,34 @@ DoneSection2:
// Next, we need to find the closest point on the line between each set, and determine which one we're // Next, we need to find the closest point on the line between each set, and determine which one we're
// closest to. // closest to.
p.x = player->mo->x;
p.y = player->mo->y;
p.z = player->mo->z;
// Waypointmid and Waypointlow: // Waypointmid and Waypointlow:
if (waypointlow) if (waypointlow)
{ {
v1.x = waypointmid->x; line[0].x = waypointmid->x;
v1.y = waypointmid->y; line[0].y = waypointmid->y;
v1.z = waypointmid->z; line[0].z = waypointmid->z;
v2.x = waypointlow->x; line[1].x = waypointlow->x;
v2.y = waypointlow->y; line[1].y = waypointlow->y;
v2.z = waypointlow->z; line[1].z = waypointlow->z;
junk.v1 = &v1;
junk.v2 = &v2;
junk.dx = v2.x - v1.x;
junk.dy = v2.y - v1.y;
P_ClosestPointOnLine3D(player->mo->x, player->mo->y, player->mo->z, &junk, &resultlow); P_ClosestPointOnLine3D(&p, line, &resultlow);
} }
// Waypointmid and Waypointhigh: // Waypointmid and Waypointhigh:
if (waypointhigh) if (waypointhigh)
{ {
v1.x = waypointmid->x; line[0].x = waypointmid->x;
v1.y = waypointmid->y; line[0].y = waypointmid->y;
v1.z = waypointmid->z; line[0].z = waypointmid->z;
v2.x = waypointhigh->x; line[1].x = waypointhigh->x;
v2.y = waypointhigh->y; line[1].y = waypointhigh->y;
v2.z = waypointhigh->z; line[1].z = waypointhigh->z;
junk.v1 = &v1;
junk.v2 = &v2;
junk.dx = v2.x - v1.x;
junk.dy = v2.y - v1.y;
P_ClosestPointOnLine3D(player->mo->x, player->mo->y, player->mo->z, &junk, &resulthigh); P_ClosestPointOnLine3D(&p, line, &resulthigh);
} }
// 3D support now available. Disregard the previous notice here. -Red // 3D support now available. Disregard the previous notice here. -Red

View file

@ -629,6 +629,10 @@ void P_Ticker(boolean run)
if (demoplayback) if (demoplayback)
G_ReadDemoTiccmd(&players[consoleplayer].cmd, 0); G_ReadDemoTiccmd(&players[consoleplayer].cmd, 0);
#ifdef HAVE_BLUA
LUAh_PreThinkFrame();
#endif
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
P_PlayerThink(&players[i]); P_PlayerThink(&players[i]);
@ -726,6 +730,10 @@ void P_Ticker(boolean run)
G_ConsGhostTic(); G_ConsGhostTic();
if (modeattacking) if (modeattacking)
G_GhostTicker(); G_GhostTicker();
#ifdef HAVE_BLUA
LUAh_PostThinkFrame();
#endif
} }
P_MapEnd(); P_MapEnd();
@ -745,6 +753,9 @@ void P_PreTicker(INT32 frames)
{ {
P_MapStart(); P_MapStart();
#ifdef HAVE_BLUA
LUAh_PreThinkFrame();
#endif
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
{ {
@ -779,6 +790,10 @@ void P_PreTicker(INT32 frames)
P_UpdateSpecials(); P_UpdateSpecials();
P_RespawnSpecials(); P_RespawnSpecials();
#ifdef HAVE_BLUA
LUAh_PostThinkFrame();
#endif
P_MapEnd(); P_MapEnd();
} }
} }

View file

@ -324,8 +324,8 @@ UINT8 ASTBlendPixel_8bpp(UINT8 background, UINT8 foreground, int style, UINT8 al
else if (style != AST_TRANSLUCENT) else if (style != AST_TRANSLUCENT)
{ {
RGBA_t texel; RGBA_t texel;
RGBA_t bg = V_GetColor(background); RGBA_t bg = V_GetMasterColor(background);
RGBA_t fg = V_GetColor(foreground); RGBA_t fg = V_GetMasterColor(foreground);
texel.rgba = ASTBlendPixel(bg, fg, style, alpha); texel.rgba = ASTBlendPixel(bg, fg, style, alpha);
return NearestColor(texel.s.red, texel.s.green, texel.s.blue); return NearestColor(texel.s.red, texel.s.green, texel.s.blue);
} }
@ -1664,7 +1664,7 @@ static void R_CreateFadeColormaps(void)
#define GETCOLOR \ #define GETCOLOR \
px = colormaps[i%256]; \ px = colormaps[i%256]; \
fade = (i/256) * (256 / FADECOLORMAPROWS); \ fade = (i/256) * (256 / FADECOLORMAPROWS); \
rgba = V_GetColor(px); rgba = V_GetMasterColor(px);
// to black // to black
makeblack: makeblack:

View file

@ -83,7 +83,7 @@ typedef struct extracolormap_s
*/ */
typedef struct typedef struct
{ {
fixed_t x, y, z; fixed_t x, y;
} vertex_t; } vertex_t;
// Forward of linedefs, for sectors. // Forward of linedefs, for sectors.

View file

@ -698,6 +698,7 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y)
INT32 side, i; INT32 side, i;
size_t nodenum; size_t nodenum;
subsector_t *ret; subsector_t *ret;
seg_t *seg;
// single subsector is a special case // single subsector is a special case
if (numnodes == 0) if (numnodes == 0)
@ -713,10 +714,15 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y)
} }
ret = &subsectors[nodenum & ~NF_SUBSECTOR]; ret = &subsectors[nodenum & ~NF_SUBSECTOR];
for (i = 0; i < ret->numlines; i++) for (i = 0, seg = &segs[ret->firstline]; i < ret->numlines; i++, seg++)
//if (R_PointOnSegSide(x, y, &segs[ret->firstline + i])) -- breaks in ogl because polyvertex_t cast over vertex pointers {
if (P_PointOnLineSide(x, y, segs[ret->firstline + i].linedef) != segs[ret->firstline + i].side) if (seg->glseg)
continue;
//if (R_PointOnSegSide(x, y, seg)) -- breaks in ogl because polyvertex_t cast over vertex pointers
if (P_PointOnLineSide(x, y, seg->linedef) != seg->side)
return 0; return 0;
}
return ret; return ret;
} }

View file

@ -309,9 +309,6 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
// OPTIMIZE: get rid of LIGHTSEGSHIFT globally // OPTIMIZE: get rid of LIGHTSEGSHIFT globally
curline = ds->curline; curline = ds->curline;
if (curline->glseg)
return;
frontsector = curline->frontsector; frontsector = curline->frontsector;
backsector = curline->backsector; backsector = curline->backsector;
texnum = R_GetTextureNum(curline->sidedef->midtexture); texnum = R_GetTextureNum(curline->sidedef->midtexture);

View file

@ -388,7 +388,7 @@ void I_UpdateMouseGrab(void)
{ {
if (SDL_WasInit(SDL_INIT_VIDEO) == SDL_INIT_VIDEO && window != NULL if (SDL_WasInit(SDL_INIT_VIDEO) == SDL_INIT_VIDEO && window != NULL
&& SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window && SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window
&& !IGNORE_MOUSE) && USE_MOUSEINPUT && !IGNORE_MOUSE)
SDLdoGrabMouse(); SDLdoGrabMouse();
} }

View file

@ -64,6 +64,7 @@ void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue);
// Retrieve the ARGB value from a palette color index // Retrieve the ARGB value from a palette color index
#define V_GetColor(color) (pLocalPalette[color&0xFF]) #define V_GetColor(color) (pLocalPalette[color&0xFF])
#define V_GetMasterColor(color) (pMasterPalette[color&0xFF])
// Bottom 8 bits are used for parameter (screen or character) // Bottom 8 bits are used for parameter (screen or character)
#define V_PARAMMASK 0x000000FF #define V_PARAMMASK 0x000000FF