Merge branch 'Saturn-Next' into unglobsavep

This commit is contained in:
Alug committed 2024-12-29 15:51:25 +01:00
commit 72383520cb
136 files changed
+8972 -11876

No files matched your search

+5 -1
View File
@@ -134,6 +134,7 @@ set(SRB2_CORE_RENDER_SOURCES
r_sky.c
r_splats.c
r_things.c
r_portal.c
r_bsp.h
r_data.h
@@ -149,6 +150,7 @@ set(SRB2_CORE_RENDER_SOURCES
r_splats.h
r_state.h
r_things.h
r_portal.h
)
set(SRB2_CORE_GAME_SOURCES
@@ -470,6 +472,7 @@ if(${SRB2_CONFIG_HWRENDER})
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_draw.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_portal.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md3load.c
@@ -484,9 +487,10 @@ if(${SRB2_CONFIG_HWRENDER})
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_data.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_defs.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_dll.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_drv.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_gl.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glob.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_portal.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md3load.h
+8 -6
View File
@@ -229,6 +229,7 @@ endif
ifdef LINUX
UNIXCOMMON=1
NOOBJDUMP=1
ifndef NOGME
HAVE_LIBGME=1
endif
@@ -293,11 +294,11 @@ ifdef NOHW
else
OPTS+=-DHWRENDER
OBJS+=$(OBJDIR)/hw_bsp.o $(OBJDIR)/hw_draw.o \
$(OBJDIR)/hw_main.o $(OBJDIR)/hw_clip.o $(OBJDIR)/hw_md2.o $(OBJDIR)/hw_cache.o \
$(OBJDIR)/hw_main.o $(OBJDIR)/hw_clip.o $(OBJDIR)/hw_md2.o $(OBJDIR)/hw_cache.o $(OBJDIR)/hw_portal.o\
$(OBJDIR)/hw_md2load.o $(OBJDIR)/hw_md3load.o $(OBJDIR)/hw_model.o $(OBJDIR)/u_list.o $(OBJDIR)/hw_batching.o $(OBJDIR)/hw_shaders.o
endif
OPTS += -DCOMPVERSION -fwrapv
OPTS += -DCOMPVERSION
ifndef NONX86
ifndef GCC29
@@ -563,6 +564,7 @@ OBJS:=$(i_main_o) \
$(OBJDIR)/r_splats.o \
$(OBJDIR)/r_patch.o \
$(OBJDIR)/r_things.o \
$(OBJDIR)/r_portal.o \
$(OBJDIR)/screen.o \
$(OBJDIR)/v_video.o \
$(OBJDIR)/s_sound.o \
@@ -736,18 +738,18 @@ else
ifdef SDL
ifdef MINGW
$(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h \
doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \
doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_gl.h screen.h \
command.h hardware/hw_data.h hardware/hw_defs.h hardware/hw_md2.h \
hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \
hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h hardware/hw_portal.h\
hardware/hw_md2load.h hardware/hw_md3load.h hardware/hw_model.h hardware/u_list.h \
am_map.h d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \
p_mobj.h doomdata.h d_ticcmd.h r_defs.h hardware/hw_dll.h
$(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@
else
$(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h \
doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \
doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_gl.h screen.h \
command.h hardware/hw_data.h hardware/hw_defs.h hardware/hw_md2.h \
hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \
hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h hardware/hw_portal.h \
hardware/hw_md2load.h hardware/hw_md3load.h hardware/hw_model.h hardware/u_list.h \
am_map.h d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \
p_mobj.h doomdata.h d_ticcmd.h r_defs.h hardware/hw_dll.h
+372 -111
View File
@@ -1,8 +1,10 @@
// SONIC ROBO BLAST 2
// SONIC ROBO BLAST 2 KART
//-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2018 by Sonic Team Junior.
// Copyright (C) 2024 by Vivian "toastergrl" Grannell.
// Copyright (C) 2024 by Kart Krew.
// Copyright (C) 2020 by Sonic Team Junior.
// Copyright (C) 2000 by DooM Legacy Team.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
@@ -26,43 +28,37 @@
#endif
// For use if I do walls with outsides/insides
static const UINT8 REDS = (8*16);
static const UINT8 REDS = (2*16);
static const UINT8 REDRANGE = 16;
static const UINT8 GRAYS = (1*16);
static const UINT8 GRAYSRANGE = 16;
static const UINT8 BROWNS = (3*16);
static const UINT8 YELLOWS = (7*16);
static const UINT8 GREENS = (10*16);
static const UINT8 BROWNS = (15*16);
static const UINT8 YELLOWS = (5*16)+8;
static const UINT8 GREENS = (6*16);
static const UINT8 BLUES = (9*16);
static const UINT8 DBLACK = 31;
static const UINT8 DWHITE = 0;
static const UINT8 NOCLIMBREDS = 248;
static const UINT8 NOCLIMBREDRANGE = 8;
static const UINT8 NOCLIMBGRAYS = 204;
static const UINT8 NOCLIMBBROWNS = (2*16);
static const UINT8 NOCLIMBYELLOWS = (11*16);
// Automap colors
#define BACKGROUND DBLACK
#define WALLCOLORS (REDS + REDRANGE/2)
#define WALLRANGE (REDRANGE/2)
#define NOCLIMBWALLCOLORS (NOCLIMBREDS + NOCLIMBREDRANGE/2)
#define NOCLIMBWALLRANGE (NOCLIMBREDRANGE/2)
#define THOKWALLCOLORS REDS
#define THOKWALLRANGE REDRANGE
#define NOCLIMBTHOKWALLCOLORS NOCLIMBREDS
#define NOCLIMBTHOKWALLRANGE NOCLIMBREDRANGE
#define TSWALLCOLORS GRAYS
#define TSWALLRANGE GRAYSRANGE
#define NOCLIMBTSWALLCOLORS NOCLIMBGRAYS
#define TSWALLCOLORS DWHITE
#define TSFINISHLINE GRAYS
#define TSFOFINFO (BLUES + 4)
#define FDWALLCOLORS BROWNS
#define NOCLIMBFDWALLCOLORS NOCLIMBBROWNS
#define CDWALLCOLORS YELLOWS
#define NOCLIMBCDWALLCOLORS NOCLIMBYELLOWS
#define THINGCOLORS GREENS
#define GRIDCOLORS (GRAYS + GRAYSRANGE/2)
#define XHAIRCOLORS GRAYS
// Automap passes
#define PASS_SOLID 1
#define PASS_INTANGIBLE 2
#define PASS_FOF 4
// controls
#define AM_PANUPKEY KEY_UPARROW
#define AM_PANDOWNKEY KEY_DOWNARROW
@@ -110,11 +106,6 @@ typedef struct
mpoint_t a, b;
} mline_t;
typedef struct
{
fixed_t slp, islp;
} islope_t;
//
// The vector graphics for the automap.
// A line drawing of the player pointing right,
@@ -136,16 +127,14 @@ static const mline_t player_arrow[] = {
#undef R
#define NUMPLYRLINES (sizeof (player_arrow)/sizeof (mline_t))
#if 0
#define R (FRACUNIT)
static mline_t triangle_guy[] = {
{ { (fixed_t)-.867f*R, (fixed_t)-.5f*R }, { (fixed_t) .867f*R, (fixed_t)-.5f*R } },
{ { (fixed_t) .867f*R, (fixed_t)-.5f*R }, { (fixed_t) 0, (fixed_t) R } },
{ { (fixed_t) 0, (fixed_t) R }, { (fixed_t)-.867f*R, (fixed_t)-.5f*R } }
static const mline_t cross_mark[] =
{
{ { -R, 0 }, { R, 0} },
{ { 0, -R }, { 0, R } },
};
#undef R
#define NUMTRIANGLEGUYLINES (sizeof (triangle_guy)/sizeof (mline_t))
#endif
#define NUMCROSSMARKLINES (sizeof(cross_mark)/sizeof(mline_t))
#define R (FRACUNIT)
static const mline_t thintriangle_guy[] = {
@@ -162,10 +151,14 @@ static boolean draw_grid = false;
boolean automapactive = false;
boolean am_recalc = false; //added : 05-02-98 : true when screen size changes
static boolean am_stopped = true;
static boolean am_minigen = false;
static UINT8 *am_buf = NULL;
static INT32 f_x, f_y; // location of window on screen (always zero for both)
static INT32 f_w, f_h; // size of window on screen (always the screen width and height respectively)
static boolean m_keydown[4]; // which window panning keys are being pressed down?
static mpoint_t m_paninc; // how far the window pans each tic (map coords)
static fixed_t mtof_zoommul; // how far the window zooms in each tic (map coords)
static fixed_t ftom_zoommul; // how far the window zooms in each tic (fb coords)
@@ -205,12 +198,13 @@ static fixed_t scale_ftom;
static player_t *plr; // the player represented by an arrow
static INT32 followplayer = true; // specifies whether to follow the player around
static boolean followplayer = true; // specifies whether to follow the player around
// function for drawing lines, depends on rendermode
typedef void (*AMDRAWFLINEFUNC) (const fline_t *fl, INT32 color);
static AMDRAWFLINEFUNC AM_drawFline;
static void AM_drawPixel(INT32 xx, INT32 yy, INT32 cc);
static void AM_drawFline_soft(const fline_t *fl, INT32 color);
static void AM_activateNewScale(void)
@@ -340,22 +334,23 @@ static void AM_initVariables(void)
old_m_h = m_h;
}
//
// Called when the screen size changes.
//
static void AM_FrameBufferInit(void)
{
f_x = f_y = 0;
f_w = vid.width;
f_h = vid.height;
am_buf = screens[0];
}
//
// should be called at the start of every level
// right now, i figure it out myself
//
static void AM_LevelInit(void)
{
f_x = f_y = 0;
f_w = vid.width;
f_h = vid.height;
AM_drawFline = AM_drawFline_soft;
#ifdef HWRENDER
if (rendermode == render_opengl)
AM_drawFline = HWR_drawAMline;
#endif
AM_findMinMaxBoundaries();
scale_mtof = FixedDiv(min_scale_mtof*10, 7*FRACUNIT);
if (scale_mtof > max_scale_mtof)
@@ -377,7 +372,7 @@ void AM_Stop(void)
*
* \sa AM_Stop
*/
static inline void AM_Start(void)
void AM_Start(void)
{
static INT32 lastlevel = -1;
@@ -386,8 +381,12 @@ static inline void AM_Start(void)
am_stopped = false;
if (lastlevel != gamemap || am_recalc) // screen size changed
{
AM_LevelInit();
lastlevel = gamemap;
AM_FrameBufferInit();
if (lastlevel != gamemap)
{
AM_LevelInit();
lastlevel = gamemap;
}
am_recalc = false;
}
AM_initVariables();
@@ -413,6 +412,27 @@ static void AM_maxOutWindowScale(void)
AM_activateNewScale();
}
//
// set window panning
//
static void AM_setWindowPanning(void)
{
// up and down
if (m_keydown[2]) // pan up
m_paninc.y = FTOM(F_PANINC);
else if (m_keydown[3]) // pan down
m_paninc.y = -FTOM(F_PANINC);
else
m_paninc.y = 0;
// left and right
if (m_keydown[0]) // pan right
m_paninc.x = FTOM(F_PANINC);
else if (m_keydown[1]) // pan left
m_paninc.x = -FTOM(F_PANINC);
else
m_paninc.x = 0;
}
/** Responds to user inputs in automap mode.
*
* \param ev Event to possibly respond to.
@@ -445,35 +465,49 @@ boolean AM_Responder(event_t *ev)
{
case AM_PANRIGHTKEY: // pan right
if (!followplayer)
m_paninc.x = FTOM(F_PANINC);
{
m_keydown[0] = true;
AM_setWindowPanning();
}
else
rc = false;
break;
case AM_PANLEFTKEY: // pan left
if (!followplayer)
m_paninc.x = -FTOM(F_PANINC);
{
m_keydown[1] = true;
AM_setWindowPanning();
}
else
rc = false;
break;
case AM_PANUPKEY: // pan up
if (!followplayer)
m_paninc.y = FTOM(F_PANINC);
{
m_keydown[2] = true;
AM_setWindowPanning();
}
else
rc = false;
break;
case AM_PANDOWNKEY: // pan down
if (!followplayer)
m_paninc.y = -FTOM(F_PANINC);
{
m_keydown[3] = true;
AM_setWindowPanning();
}
else
rc = false;
break;
case AM_ZOOMOUTKEY: // zoom out
mtof_zoommul = M_ZOOMOUT;
ftom_zoommul = M_ZOOMIN;
AM_setWindowPanning();
break;
case AM_ZOOMINKEY: // zoom in
mtof_zoommul = M_ZOOMIN;
ftom_zoommul = M_ZOOMOUT;
AM_setWindowPanning();
break;
case AM_TOGGLEKEY:
AM_Stop();
@@ -487,6 +521,7 @@ boolean AM_Responder(event_t *ev)
}
else
AM_restoreScaleAndLoc();
AM_setWindowPanning();
break;
case AM_FOLLOWKEY:
followplayer = !followplayer;
@@ -506,14 +541,32 @@ boolean AM_Responder(event_t *ev)
switch (ev->data1)
{
case AM_PANRIGHTKEY:
if (!followplayer)
{
m_keydown[0] = false;
AM_setWindowPanning();
}
break;
case AM_PANLEFTKEY:
if (!followplayer)
m_paninc.x = 0;
{
m_keydown[1] = false;
AM_setWindowPanning();
}
break;
case AM_PANUPKEY:
if (!followplayer)
{
m_keydown[2] = false;
AM_setWindowPanning();
}
break;
case AM_PANDOWNKEY:
if (!followplayer)
m_paninc.y = 0;
{
m_keydown[3] = false;
AM_setWindowPanning();
}
break;
case AM_ZOOMOUTKEY:
case AM_ZOOMINKEY:
@@ -714,6 +767,16 @@ static boolean AM_clipMline(const mline_t *ml, fline_t *fl)
}
#undef DOOUTCODE
//
// Draws a pixel.
//
static void AM_drawPixel(INT32 xx, INT32 yy, INT32 cc)
{
if (xx < 0 || yy < 0 || xx >= f_w || yy >= f_h)
return; // off the screen
am_buf[(yy*f_w) + xx] = cc;
}
//
// Classic Bresenham w/ whatever optimizations needed for speed
//
@@ -735,8 +798,6 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color)
}
#endif
#define PUTDOT(xx,yy,cc) V_DrawFill(xx,yy,1,1,cc|V_NOSCALESTART);
dx = fl->b.x - fl->a.x;
ax = 2 * (dx < 0 ? -dx : dx);
sx = dx < 0 ? -1 : 1;
@@ -753,7 +814,7 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color)
d = ay - ax/2;
for (;;)
{
PUTDOT(x, y, color)
AM_drawPixel(x, y, color);
if (x == fl->b.x)
return;
if (d >= 0)
@@ -770,7 +831,7 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color)
d = ax - ay/2;
for (;;)
{
PUTDOT(x, y, color)
AM_drawPixel(x, y, color);
if (y == fl->b.y)
return;
if (d >= 0)
@@ -782,8 +843,6 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color)
d += ax;
}
}
#undef PUTDOT
}
//
@@ -805,17 +864,18 @@ static void AM_drawGrid(INT32 color)
fixed_t x, y;
fixed_t start, end;
mline_t ml;
fixed_t gridsize = (MAPBLOCKUNITS<<MAPBITS);
// Figure out start of vertical gridlines
start = m_x;
if ((start - bmaporgx) % (MAPBLOCKUNITS<<FRACBITS))
start += (MAPBLOCKUNITS<<FRACBITS) - ((start - bmaporgx) % (MAPBLOCKUNITS<<FRACBITS));
if ((start - (bmaporgx>>FRACTOMAPBITS)) % gridsize)
start += gridsize - ((start - (bmaporgx>>FRACTOMAPBITS)) % gridsize);
end = m_x + m_w;
// draw vertical gridlines
ml.a.y = m_y;
ml.b.y = m_y + m_h;
for (x = start; x < end; x += (MAPBLOCKUNITS<<FRACBITS))
for (x = start; x < end; x += gridsize)
{
ml.a.x = x;
ml.b.x = x;
@@ -824,14 +884,14 @@ static void AM_drawGrid(INT32 color)
// Figure out start of horizontal gridlines
start = m_y;
if ((start - bmaporgy) % (MAPBLOCKUNITS<<FRACBITS))
start += (MAPBLOCKUNITS<<FRACBITS) - ((start - bmaporgy) % (MAPBLOCKUNITS<<FRACBITS));
if ((start - (bmaporgy>>FRACTOMAPBITS)) % gridsize)
start += gridsize - ((start - (bmaporgy>>FRACTOMAPBITS)) % gridsize);
end = m_y + m_h;
// draw horizontal gridlines
ml.a.x = m_x;
ml.b.x = m_x + m_w;
for (y = start; y < end; y += (MAPBLOCKUNITS<<FRACBITS))
for (y = start; y < end; y += gridsize)
{
ml.a.y = y;
ml.b.y = y;
@@ -839,14 +899,63 @@ static void AM_drawGrid(INT32 color)
}
}
#define SLOPEPARAMS(slope, end1, end2, normalheight) \
if (slope) { \
end1 = (P_GetZAt(slope, lines[i].v1->x, lines[i].v1->y) + FRACUNIT/2) >> FRACBITS; \
end2 = (P_GetZAt(slope, lines[i].v2->x, lines[i].v2->y) + FRACUNIT/2) >> FRACBITS; \
} else \
end1 = end2 = (normalheight + FRACUNIT/2) >> FRACBITS;
static ffloor_t *AM_CompareFOFs(size_t i, ffloor_t *rover, ffloor_t *secondarystore)
{
ffloor_t *secondaryrover = NULL;
for (; rover; rover = rover->next)
{
fixed_t rovt1, rovt2;
fixed_t rovb1, rovb2;
if (!(rover->flags & FF_EXISTS))
continue;
if (!(rover->flags & FF_BLOCKPLAYER))
continue;
SLOPEPARAMS(*rover->t_slope, rovt1, rovt2, *rover->topheight)
SLOPEPARAMS(*rover->b_slope, rovb1, rovb2, *rover->bottomheight)
for (secondaryrover = secondarystore; secondaryrover; secondaryrover = secondaryrover->next)
{
fixed_t sect1, sect2;
fixed_t secb1, secb2;
if (!(secondaryrover->flags & FF_EXISTS))
continue;
if (!(secondaryrover->flags & FF_BLOCKPLAYER))
continue;
if (secondaryrover->secnum == rover->secnum)
break;
SLOPEPARAMS(*secondaryrover->t_slope, sect1, sect2, *secondaryrover->topheight)
SLOPEPARAMS(*secondaryrover->b_slope, secb1, secb2, *secondaryrover->bottomheight)
if (rovt1 != sect1)
continue;
if (rovt2 != sect2)
continue;
if (rovb1 != secb1)
continue;
if (rovb2 != secb2)
continue;
break;
}
if (secondaryrover == NULL)
break;
}
return rover;
}
//
// Determines visible lines, draws them.
// This is LineDef based, not LineSeg based.
//
static inline void AM_drawWalls(void)
static void AM_drawWalls(UINT8 pass)
{
size_t i;
static mline_t l;
const fixed_t maxstep = FixedMul(MAXSTEPMOVE, mapobjectscale)>>FRACBITS;
fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends
fixed_t backf1 = 0, backf2 = 0, backc1 = 0, backc2 = 0; // back floor ceiling ends
@@ -856,74 +965,143 @@ static inline void AM_drawWalls(void)
l.a.y = lines[i].v1->y >> FRACTOMAPBITS;
l.b.x = lines[i].v2->x >> FRACTOMAPBITS;
l.b.y = lines[i].v2->y >> FRACTOMAPBITS;
#define SLOPEPARAMS(slope, end1, end2, normalheight) \
if (slope) { \
end1 = P_GetZAt(slope, lines[i].v1->x, lines[i].v1->y); \
end2 = P_GetZAt(slope, lines[i].v2->x, lines[i].v2->y); \
} else \
end1 = end2 = normalheight;
SLOPEPARAMS(lines[i].frontsector->f_slope, frontf1, frontf2, lines[i].frontsector->floorheight)
SLOPEPARAMS(lines[i].frontsector->c_slope, frontc1, frontc2, lines[i].frontsector->ceilingheight)
if (lines[i].backsector) {
SLOPEPARAMS(lines[i].backsector->f_slope, backf1, backf2, lines[i].backsector->floorheight)
SLOPEPARAMS(lines[i].backsector->c_slope, backc1, backc2, lines[i].backsector->ceilingheight)
}
#undef SLOPEPARAMS
if (!lines[i].backsector) // 1-sided
{
if (lines[i].flags & ML_NOCLIMB)
AM_drawMline(&l, NOCLIMBWALLCOLORS);
else
if (!(pass & PASS_SOLID))
;
else if (frontf1 != frontc1 || frontf2 != frontc2 || lines[i].frontsector->f_slope)
{
AM_drawMline(&l, TSWALLCOLORS);
}
else if (!am_minigen)
{
AM_drawMline(&l, WALLCOLORS);
}
continue;
}
else if ((backf1 == backc1 && backf2 == backc2) // Back is thok barrier
SLOPEPARAMS(lines[i].backsector->f_slope, backf1, backf2, lines[i].backsector->floorheight)
SLOPEPARAMS(lines[i].backsector->c_slope, backc1, backc2, lines[i].backsector->ceilingheight)
if ((backf1 == backc1 && backf2 == backc2) // Back is thok barrier
|| (frontf1 == frontc1 && frontf2 == frontc2)) // Front is thok barrier
{
if (backf1 == backc1 && backf2 == backc2
&& frontf1 == frontc1 && frontf2 == frontc2) // BOTH are thok barriers
{
if (lines[i].flags & ML_NOCLIMB)
AM_drawMline(&l, NOCLIMBTSWALLCOLORS);
else
AM_drawMline(&l, TSWALLCOLORS);
if (!am_minigen && (pass & PASS_INTANGIBLE))
{
AM_drawMline(&l, GRIDCOLORS);
}
}
else
else if (pass & PASS_SOLID)
{
if (lines[i].flags & ML_NOCLIMB)
AM_drawMline(&l, NOCLIMBTHOKWALLCOLORS);
else
AM_drawMline(&l, THOKWALLCOLORS);
AM_drawMline(&l, TSWALLCOLORS);
}
}
else
{
if (lines[i].flags & ML_NOCLIMB) {
if (backf1 != frontf1 || backf2 != frontf2) {
AM_drawMline(&l, NOCLIMBFDWALLCOLORS); // floor level change
}
else if (backc1 != frontc1 || backc2 != frontc2) {
AM_drawMline(&l, NOCLIMBCDWALLCOLORS); // ceiling level change
//dont think kart even supports those idk?
/*if (lines[i].flags & (ML_IMPASSABLE|ML_BLOCKPLAYERS))
{
if (pass & PASS_SOLID)
AM_drawMline(&l, TSWALLCOLORS); // Completely solid course boundary
}
else if ((lines[i].flags & ML_MIDSOLID)
&& sides[lines->sidenum[0]].midtexture)
{
if (pass & PASS_SOLID)
AM_drawMline(&l, TSWALLCOLORS); // solid midtexture, likely a course boundary
}*/
if ((backf1 != frontf1 && abs(backf1 - frontf1) > maxstep)
|| (backf2 != frontf2 && abs(backf2 - frontf2) > maxstep))
{
if (pass & PASS_SOLID)
AM_drawMline(&l, TSWALLCOLORS); // floor-wall, likely a course boundary
}
/*else if (lines[i].special == 2001) // guh its a sector effect in kart idk how to make it work tbh lol
{
if (pass & PASS_SOLID)
AM_drawMline(&l, TSFINISHLINE); // finish line
}*/
else if (backf1 != frontf1 || backf2 != frontf2)
{
if (pass & PASS_INTANGIBLE)
AM_drawMline(&l, FDWALLCOLORS); // floorlevel change
}
else if (backc1 != frontc1 || backc2 != frontc2)
{
if (!(pass & PASS_INTANGIBLE))
;
else if (abs(backc1 - frontc1) < maxstep
|| abs(backc2 - frontc2) < maxstep)
{
AM_drawMline(&l, CDWALLCOLORS); // ceilinglevel change
}
else
AM_drawMline(&l, NOCLIMBTSWALLCOLORS);
{
AM_drawMline(&l, GRIDCOLORS); // ceiling-wall, not likely to be a course boundary but flagged up just in case
}
}
else
{
if (backf1 != frontf1 || backf2 != frontf2) {
AM_drawMline(&l, FDWALLCOLORS); // floor level change
{
ffloor_t *rover = NULL;
if (lines[i].frontsector->ffloors || lines[i].backsector->ffloors)
{
if (lines[i].backsector->ffloors == NULL)
{
// Check frontside for one solid
for (rover = lines[i].frontsector->ffloors; rover; rover = rover->next)
{
if (!(rover->flags & FF_EXISTS))
continue;
if (!(rover->flags & FF_BLOCKPLAYER))
continue;
break;
}
}
else if (lines[i].frontsector->ffloors == NULL)
{
// Check backside for one solid
for (rover = lines[i].backsector->ffloors; rover; rover = rover->next)
{
if (!(rover->flags & FF_EXISTS))
continue;
if (!(rover->flags & FF_BLOCKPLAYER))
continue;
break;
}
}
else
{
// Check to see if any secnums exist in one but not the other.
rover = AM_CompareFOFs(i, lines[i].frontsector->ffloors, lines[i].backsector->ffloors);
if (rover == NULL)
rover = AM_CompareFOFs(i, lines[i].backsector->ffloors, lines[i].frontsector->ffloors);
}
}
if (rover != NULL)
{
if (pass & PASS_FOF)
AM_drawMline(&l, TSFOFINFO); // a FOF is here but we don't know how to distinguish them yet
}
else if (!am_minigen)
{
if (pass & PASS_INTANGIBLE)
AM_drawMline(&l, GRIDCOLORS); // likely low-relevance line
}
}
else if (backc1 != frontc1 || backc2 != frontc2) {
AM_drawMline(&l, CDWALLCOLORS); // ceiling level change
}
else
AM_drawMline(&l, TSWALLCOLORS);
}
}
}
}
#undef SLOPEPARAMS
//
// Rotation in 2D.
// Used to rotate player arrow line character.
@@ -996,7 +1174,7 @@ static inline void AM_drawPlayers(void)
if (!multiplayer)
{
AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 0, plr->mo->angle, DWHITE, plr->mo->x, plr->mo->y);
AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 16<<FRACBITS, plr->mo->angle, DWHITE, plr->mo->x, plr->mo->y);
return;
}
@@ -1013,7 +1191,7 @@ static inline void AM_drawPlayers(void)
if (p->skincolor > 0)
color = R_GetTranslationColormap(TC_DEFAULT, p->skincolor, GTC_CACHE)[GREENS + 8];
AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 0, p->mo->angle, color, p->mo->x, p->mo->y);
AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 16<<FRACBITS, p->mo->angle, color, p->mo->x, p->mo->y);
}
}
@@ -1033,13 +1211,27 @@ static inline void AM_drawThings(UINT8 colors)
}
}
/** Draws the crosshair, actually just a dot in software mode.
/** Draws the crosshair.
*
* \param color Color for the crosshair.
*/
static inline void AM_drawCrosshair(UINT8 color)
{
V_DrawFill(f_w/2 + f_x, f_h/2 + f_y, 1, 1, color|V_NOSCALESTART);
const fixed_t scale = 4<<FRACBITS;
size_t i;
fline_t fl;
for (i = 0; i < NUMCROSSMARKLINES; i++)
{
fl.a.x = FixedMul(cross_mark[i].a.x, scale) >> FRACBITS;
fl.a.y = FixedMul(cross_mark[i].a.y, scale) >> FRACBITS;
fl.b.x = FixedMul(cross_mark[i].b.x, scale) >> FRACBITS;
fl.b.y = FixedMul(cross_mark[i].b.y, scale) >> FRACBITS;
fl.a.x += f_x + (f_w / 2);
fl.a.y += f_y + (f_h / 2);
fl.b.x += f_x + (f_w / 2);
fl.b.y += f_y + (f_h / 2);
AM_drawFline(&fl, color);
}
}
/** Draws the automap.
@@ -1049,11 +1241,80 @@ void AM_Drawer(void)
if (!automapactive)
return;
AM_drawFline = AM_drawFline_soft;
#ifdef HWRENDER
if (rendermode == render_opengl)
AM_drawFline = HWR_drawAMline;
#endif
AM_clearFB(BACKGROUND);
if (draw_grid) AM_drawGrid(GRIDCOLORS);
AM_drawWalls();
AM_drawWalls(PASS_FOF|PASS_INTANGIBLE|PASS_SOLID);
AM_drawPlayers();
AM_drawThings(THINGCOLORS);
AM_drawCrosshair(XHAIRCOLORS);
if (!followplayer) AM_drawCrosshair(XHAIRCOLORS);
}
minigen_t *AM_MinimapGenerate(INT32 mul)
{
static minigen_t ret = {0};
if (automapactive)
return NULL;
am_minigen = true;
AM_drawFline = AM_drawFline_soft; // yes, even in GL
//AM_FrameBufferInit();
f_x = f_y = 0;
ret.w = f_w = minimapinfo.minimap_w * mul;
ret.h = f_h = minimapinfo.minimap_h * mul;
am_buf = ret.buf = NULL;
//AM_LevelInit();
AM_findMinMaxBoundaries();
scale_mtof = min_scale_mtof - (min_scale_mtof/20);
scale_ftom = FixedDiv(FRACUNIT, scale_mtof);
//AM_initVariables();
f_oldloc.x = INT32_MAX;
m_paninc.x = m_paninc.y = 0;
ftom_zoommul = FRACUNIT;
mtof_zoommul = FRACUNIT;
m_w = FTOM(f_w);
m_h = FTOM(f_h);
//AM_changeWindowLoc();
m_x = min_x - FixedMul(m_w, FRACUNIT/40);
m_y = min_y - FixedMul(m_h, FRACUNIT/40);
m_x2 = m_x + m_w;
m_y2 = m_y + m_h;
// for saving & restoring
old_m_x = m_x;
old_m_y = m_y;
old_m_w = m_w;
old_m_h = m_h;
am_buf = ret.buf = malloc((f_w*f_h));
if (ret.buf == NULL)
return NULL;
//AM_clearFB(BACKGROUND);
memset(am_buf, 0xff, (f_w*f_h));
AM_drawWalls(PASS_FOF);
AM_drawWalls(PASS_INTANGIBLE);
AM_drawWalls(PASS_SOLID);
am_buf = NULL;
am_recalc = true;
am_minigen = false;
return &ret;
}
+17 -8
View File
@@ -1,8 +1,10 @@
// SONIC ROBO BLAST 2
// SONIC ROBO BLAST 2 KART
//-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2018 by Sonic Team Junior.
// Copyright (C) 2024 by Vivian "toastergrl" Grannell.
// Copyright (C) 2024 by Kart Krew.
// Copyright (C) 2020 by Sonic Team Junior.
// Copyright (C) 2000 by DooM Legacy Team.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
@@ -26,11 +28,6 @@ typedef struct
fpoint_t a, b;
} fline_t;
// Used by ST StatusBar stuff.
#define AM_MSGHEADER (('a'<<24)+('m'<<16))
#define AM_MSGENTERED (AM_MSGHEADER | ('e'<<8))
#define AM_MSGEXITED (AM_MSGHEADER | ('x'<<8))
extern boolean am_recalc; // true if screen size changes
extern boolean automapactive; // In AutoMap mode?
@@ -43,7 +40,19 @@ void AM_Ticker(void);
// Called by main loop, instead of view drawer if automap is active.
void AM_Drawer(void);
// Enables the automap.
void AM_Start(void);
// Called to force the automap to quit if the level is completed while it is up.
void AM_Stop(void);
typedef struct
{
INT32 w, h;
UINT8 *buf;
} minigen_t;
// Minimap generation
minigen_t *AM_MinimapGenerate(INT32 mul);
#endif
+2 -5
View File
@@ -36,7 +36,7 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm
return;
// Lua can handle it!
if (LUAh_BotAI(sonic, tails, cmd))
if (LUA_HookBotAI(sonic, tails, cmd))
return;
if (tails->player->pflags & (PF_MACESPIN|PF_ITEMHANG))
@@ -118,11 +118,8 @@ void B_BuildTiccmd(player_t *player, ticcmd_t *cmd)
return;
}
// Bot AI isn't programmed in analog.
//CV_SetValue(&cv_analog2, false);
// Let Lua scripts build ticcmds
if (LUAh_BotTiccmd(player, cmd))
if (LUA_HookTiccmd(player, cmd, HOOK(BotTiccmd)))
return;
// We don't have any main character AI, sorry. D:
+28 -23
View File
@@ -1,7 +1,7 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2018 by Sonic Team Junior.
// Copyright (C) 1999-2024 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
@@ -11,6 +11,9 @@
/// \brief Macros to read/write from/to a UINT8 *,
/// used for packet creation and such
#ifndef __BYTEPTR_H__
#define __BYTEPTR_H__
#if defined (__alpha__) || defined (__arm__) || defined (__mips__) || defined (__ia64__) || defined (__clang__)
#define DEALIGNED
#endif
@@ -150,7 +153,7 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr)
#undef DEALIGNED
#define WRITESTRINGN(p, s, n) ({ \
#define WRITESTRINGN(p, s, n) do { \
size_t tmp_i; \
\
for (tmp_i = 0; tmp_i < n && s[tmp_i] != '\0'; tmp_i++) \
@@ -158,70 +161,72 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr)
\
if (tmp_i < n) \
WRITECHAR(p, '\0'); \
})
} while (0)
#define WRITESTRINGL(p, s, n) ({ \
#define WRITESTRINGL(p, s, n) do { \
size_t tmp_i; \
\
for (tmp_i = 0; tmp_i < n - 1 && s[tmp_i] != '\0'; tmp_i++) \
WRITECHAR(p, s[tmp_i]); \
\
WRITECHAR(p, '\0'); \
})
} while (0)
#define WRITESTRING(p, s) ({ \
#define WRITESTRING(p, s) do { \
size_t tmp_i; \
\
for (tmp_i = 0; s[tmp_i] != '\0'; tmp_i++) \
WRITECHAR(p, s[tmp_i]); \
\
WRITECHAR(p, '\0'); \
})
} while (0)
#define WRITEMEM(p, s, n) ({ \
memcpy(p, s, n); \
p += n; \
})
#define WRITEMEM(p, s, n) do { \
memcpy(p, s, n); \
p += n; \
} while (0)
#define SKIPSTRING(p) while (READCHAR(p) != '\0')
#define SKIPSTRINGN(p, n) ({ \
#define SKIPSTRINGN(p, n) do { \
size_t tmp_i = 0; \
\
while (tmp_i < n && READCHAR(p) != '\0') \
tmp_i++; \
})
} while (0)
#define SKIPSTRINGL(p, n) SKIPSTRINGN(p, n)
#define READSTRINGN(p, s, n) ({ \
#define READSTRINGN(p, s, n) do { \
size_t tmp_i = 0; \
\
while (tmp_i < n && (s[tmp_i] = READCHAR(p)) != '\0') \
tmp_i++; \
\
s[tmp_i] = '\0'; \
})
} while (0)
#define READSTRINGL(p, s, n) ({ \
#define READSTRINGL(p, s, n) do { \
size_t tmp_i = 0; \
\
while (tmp_i < n - 1 && (s[tmp_i] = READCHAR(p)) != '\0') \
tmp_i++; \
\
s[tmp_i] = '\0'; \
})
} while (0)
#define READSTRING(p, s) ({ \
#define READSTRING(p, s) do { \
size_t tmp_i = 0; \
\
while ((s[tmp_i] = READCHAR(p)) != '\0') \
tmp_i++; \
\
s[tmp_i] = '\0'; \
})
} while (0)
#define READMEM(p, s, n) ({ \
memcpy(s, p, n); \
p += n; \
})
#define READMEM(p, s, n) do { \
memcpy(s, p, n); \
p += n; \
} while (0)
#endif // __BYTEPTR_H__
+1 -1
View File
@@ -628,7 +628,7 @@ static void COM_ExecuteString(char *ptext)
// check cvars
// Hurdler: added at Ebola's request ;)
// (don't flood the console in software mode with bad gr_xxx command)
// (don't flood the console in software mode with bad gl_xxx command)
if (!CV_Command() && con_destlines)
CONS_Printf(M_GetText("Unknown command '%s'\n"), COM_Argv(0));
}
+1 -1
View File
@@ -1236,7 +1236,7 @@ void CONS_Printf(const char *fmt, ...)
txt = malloc(8192);
va_start(argptr, fmt);
vsprintf(txt, fmt, argptr);
vsnprintf(txt, 8192, fmt, argptr);
va_end(argptr);
// echo console prints to log file
+254 -324
View File
@@ -50,6 +50,7 @@
#include "s_sound.h" // sfx_syfail
#include "m_perfstats.h"
#include "d_main.h"
#include "r_fps.h"
#ifdef CLIENT_LOADINGSCREEN
// cl loading screen
@@ -139,10 +140,7 @@ static UINT8 gamestate_resend_counter[MAXNETNODES];
boolean hu_stopped = false;
// Client specific
static ticcmd_t localcmds;
static ticcmd_t localcmds2;
static ticcmd_t localcmds3;
static ticcmd_t localcmds4;
static ticcmd_t localcmds[MAXSPLITSCREENPLAYERS];
static boolean cl_packetmissed;
// here it is for the secondary local player (splitscreen)
static UINT8 mynode; // my address pointofview server
@@ -159,10 +157,7 @@ boolean is_client_saturn[MAXNETNODES];
#define ISSATURN 69
#endif
static UINT8 localtextcmd[MAXTEXTCMD];
static UINT8 localtextcmd2[MAXTEXTCMD]; // splitscreen
static UINT8 localtextcmd3[MAXTEXTCMD]; // splitscreen == 2
static UINT8 localtextcmd4[MAXTEXTCMD]; // splitscreen == 3
static UINT8 localtextcmd[MAXSPLITSCREENPLAYERS][MAXTEXTCMD];
static tic_t neededtic;
SINT8 servernode = 0; // the number of the server node
char connectedservername[MAXSERVERNAME+1];
@@ -276,77 +271,30 @@ void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(UINT8 **p, INT32 playernum))
listnetxcmd[id] = cmd_f;
}
void SendNetXCmd(netxcmd_t id, const void *param, size_t nparam)
void SendNetXCmdForPlayer(UINT8 playerid, netxcmd_t id, const void *param, size_t nparam)
{
if (localtextcmd[0]+2+nparam > MAXTEXTCMD)
if ((localtextcmd[playerid])[0]+2+nparam > MAXTEXTCMD)
{
// for future reference: if (cv_debug) != debug disabled.
CONS_Alert(CONS_ERROR, M_GetText("NetXCmd buffer full, cannot add netcmd %d! (size: %d, needed: %s)\n"), id, localtextcmd[0], sizeu1(nparam));
// for future reference: if (cht_debug) != debug disabled.
CONS_Alert(CONS_ERROR, M_GetText("NetXCmd buffer full, cannot add netcmd %d! (size: %d, needed: %s)\n"), id, localtextcmd[playerid][0], sizeu1(nparam));
return;
}
localtextcmd[0]++;
localtextcmd[localtextcmd[0]] = (UINT8)id;
localtextcmd[playerid][0]++;
localtextcmd[playerid][localtextcmd[playerid][0]] = (UINT8)id;
if (param && nparam)
{
M_Memcpy(&localtextcmd[localtextcmd[0]+1], param, nparam);
localtextcmd[0] = (UINT8)(localtextcmd[0] + (UINT8)nparam);
M_Memcpy(&localtextcmd[playerid][localtextcmd[playerid][0] + 1], param, nparam);
localtextcmd[playerid][0] = (UINT8)(localtextcmd[playerid][0] + (UINT8)nparam);
}
}
// splitscreen player
void SendNetXCmd2(netxcmd_t id, const void *param, size_t nparam)
{
if (localtextcmd2[0]+2+nparam > MAXTEXTCMD)
{
I_Error("No more place in the buffer for netcmd %d\n",id);
return;
}
localtextcmd2[0]++;
localtextcmd2[localtextcmd2[0]] = (UINT8)id;
if (param && nparam)
{
M_Memcpy(&localtextcmd2[localtextcmd2[0]+1], param, nparam);
localtextcmd2[0] = (UINT8)(localtextcmd2[0] + (UINT8)nparam);
}
}
void SendNetXCmd3(netxcmd_t id, const void *param, size_t nparam)
{
if (localtextcmd3[0]+2+nparam > MAXTEXTCMD)
{
I_Error("No more place in the buffer for netcmd %d\n",id);
return;
}
localtextcmd3[0]++;
localtextcmd3[localtextcmd3[0]] = (UINT8)id;
if (param && nparam)
{
M_Memcpy(&localtextcmd3[localtextcmd3[0]+1], param, nparam);
localtextcmd3[0] = (UINT8)(localtextcmd3[0] + (UINT8)nparam);
}
}
void SendNetXCmd4(netxcmd_t id, const void *param, size_t nparam)
{
if (localtextcmd4[0]+2+nparam > MAXTEXTCMD)
{
I_Error("No more place in the buffer for netcmd %d\n",id);
return;
}
localtextcmd4[0]++;
localtextcmd4[localtextcmd4[0]] = (UINT8)id;
if (param && nparam)
{
M_Memcpy(&localtextcmd4[localtextcmd4[0]+1], param, nparam);
localtextcmd4[0] = (UINT8)(localtextcmd4[0] + (UINT8)nparam);
}
}
UINT8 GetFreeXCmdSize(void)
/*UINT8 GetFreeXCmdSize(UINT8 playerid)
{
// -1 for the size and another -1 for the ID.
return (UINT8)(localtextcmd[0] - 2);
}
return (UINT8)(localtextcmd[playerid][0] - 2);
}*/
// Frees all textcmd memory for the specified tic
static void D_FreeTextcmd(tic_t tic)
@@ -510,10 +458,8 @@ void D_ResetTiccmds(void)
{
INT32 i;
memset(&localcmds, 0, sizeof(ticcmd_t));
memset(&localcmds2, 0, sizeof(ticcmd_t));
memset(&localcmds3, 0, sizeof(ticcmd_t));
memset(&localcmds4, 0, sizeof(ticcmd_t));
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
memset(&localcmds[i], 0, sizeof(ticcmd_t));
// Reset the net command list
for (i = 0; i < TEXTCMD_HASH_SIZE; i++)
@@ -1228,7 +1174,7 @@ static inline void CL_DrawConnectionStatus(void)
//Draw bottom box
M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1);
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, V_YELLOWMAP, "Press ESC to abort");
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, V_YELLOWMAP|MENUCAPS, "Press ESC to abort");
for (i = 0; i < 16; ++i)
V_DrawFill((BASEVIDWIDTH/2-128) + (i * 16), BASEVIDHEIGHT-24, 16, 8, palstart + ((animtime - i) & 15));
@@ -1275,7 +1221,7 @@ static inline void CL_DrawConnectionStatus(void)
cltext = M_GetText("Connecting to server...");
break;
}
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP, cltext);
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP|MENUCAPS, cltext);
}
else
{
@@ -1285,7 +1231,7 @@ static inline void CL_DrawConnectionStatus(void)
INT32 checkednum = 0;
INT32 i;
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, V_YELLOWMAP, "Press ESC to abort");
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, V_YELLOWMAP|MENUCAPS, "Press ESC to abort");
//ima just count files here
for (i = 0; i < fileneedednum; i++)
@@ -1293,12 +1239,12 @@ static inline void CL_DrawConnectionStatus(void)
checkednum++;
// Loading progress
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP, "Checking server addons...");
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP|MENUCAPS, "Checking server addons...");
totalfileslength = (INT32)((checkednum/(double)(fileneedednum)) * 256);
M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1);
V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175);
V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160);
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE,
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS,
va(" %2u/%2u Files",checkednum,fileneedednum));
}
else if (cl_mode == CL_LOADFILES)
@@ -1307,7 +1253,7 @@ static inline void CL_DrawConnectionStatus(void)
INT32 loadcompletednum = 0;
INT32 i;
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, V_YELLOWMAP, "Press ESC to abort");
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, V_YELLOWMAP|MENUCAPS, "Press ESC to abort");
//ima just count files here
for (i = 0; i < fileneedednum; i++)
@@ -1315,12 +1261,12 @@ static inline void CL_DrawConnectionStatus(void)
loadcompletednum++;
// Loading progress
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP, "Loading server addons...");
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP|MENUCAPS, "Loading server addons...");
totalfileslength = (INT32)((loadcompletednum/(double)(fileneedednum)) * 256);
M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1);
V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175);
V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160);
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE,
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS,
va(" %2u/%2u Files",loadcompletednum,fileneedednum));
}
else if (lastfilenum != -1)
@@ -1334,7 +1280,7 @@ static inline void CL_DrawConnectionStatus(void)
// Draw the bottom box.
M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-58-8, 32, 1);
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-14, V_YELLOWMAP, "Press ESC to abort");
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-14, V_YELLOWMAP|MENUCAPS, "Press ESC to abort");
Net_GetNetStat();
dldlength = (INT32)((file->currentsize/(double)file->totalsize) * 256);
@@ -1359,17 +1305,17 @@ static inline void CL_DrawConnectionStatus(void)
strncpy(tempname, filename, sizeof(tempname)-1);
}
#ifdef HAVE_CURL
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-30, 0,
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-30, MENUCAPS,
va(M_GetText("%s downloading"), ((cl_mode == CL_DOWNLOADHTTPFILES) ? "\x82""HTTP" : "\x85""Direct")));
#else
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-30, 0,
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-30, MENUCAPS,
va(M_GetText("%s downloading"),("\x85""Direct")));
#endif
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-22, V_YELLOWMAP,
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-22, V_YELLOWMAP|MENUCAPS,
va(M_GetText("\"%s\""), tempname));
V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, V_20TRANS|V_MONOSPACE,
V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, V_20TRANS|V_MONOSPACE|MENUCAPS,
va(" %4uK/%4uK",fileneeded[lastfilenum].currentsize>>10,file->totalsize>>10));
V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-58, V_20TRANS|V_MONOSPACE,
V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-58, V_20TRANS|V_MONOSPACE|MENUCAPS,
va("%3.1fK/s ", ((double)getbps)/1024));
// Download progress
@@ -1379,20 +1325,20 @@ static inline void CL_DrawConnectionStatus(void)
else
totaldldsize = downloadcompletedsize;
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-14, V_YELLOWMAP, "Overall Download Progress");
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-14, V_YELLOWMAP|MENUCAPS, "Overall Download Progress");
totalfileslength = (INT32)((totaldldsize/(double)totalfilesrequestedsize) * 256);
M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1);
V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175);
V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160);
if (totalfilesrequestedsize>>20 >= 10) //display in MB if over 10MB
V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE,
V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS,
va(" %4uM/%4uM",totaldldsize>>20,totalfilesrequestedsize>>20));
else
V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE,
V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS,
va(" %4uK/%4uK",totaldldsize>>10,totalfilesrequestedsize>>10));
V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE,
V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS,
va("%2u/%2u Files ",downloadcompletednum,totalfilesrequestednum));
}
else
@@ -1403,12 +1349,12 @@ static inline void CL_DrawConnectionStatus(void)
//Draw bottom box
M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1);
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, V_YELLOWMAP, "Press ESC to abort");
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, V_YELLOWMAP|MENUCAPS, "Press ESC to abort");
for (i = 0; i < 16; ++i)
V_DrawFill((BASEVIDWIDTH/2-128) + (i * 16), BASEVIDHEIGHT-24, 16, 8, palstart + ((animtime - i) & 15));
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP,
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP|MENUCAPS,
M_GetText("Waiting to download files..."));
}
}
@@ -1796,7 +1742,7 @@ static boolean SV_ResendingSavegameToAnyone(void)
INT32 i;
for (i = 0; i < MAXNETNODES; i++)
if (resendingsavegame[i])
if (nodeingame[i] && resendingsavegame[i])
return true;
return false;
}
@@ -2008,12 +1954,12 @@ static void CL_ReloadReceivedSavegame(void)
// we dont have P_ForceLocalAngle so were setting it manually here
for (i = 0; i <= splitscreen; i++)
{
localangle[i] = (angle_t)(players[displayplayers[i]].cmd.angleturn<<16);
localangle[i] = (angle_t)(players[displayplayers[i]].cmd.angleturn << 16);
}
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
camera[i].subsector = R_PointInSubsector(camera[i].x, camera[i].y);
camera[i].subsector = R_PointInSubsectorFast(camera[i].x, camera[i].y);
}
cl_redownloadinggamestate = false;
@@ -3240,7 +3186,7 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason)
demo_extradata[playernum] |= DXD_PLAYSTATE;
if (server && !demo.playback)
if (server && !demo.playback && playernode[playernum] != UINT8_MAX)
{
INT32 node = playernode[playernum];
//playerpernode[node] = 0; // It'd be better to remove them all at once, but ghosting happened, so continue to let CL_RemovePlayer do it one-by-one
@@ -3249,13 +3195,7 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason)
{
SV_InitResynchVars(node); // If a resynch was in progress, well, it no longer needs to be.
nodeingame[node] = false;
#ifdef SATURNPAK
is_client_saturn[node] = false;
#endif
#ifdef SATURNSYNCH
can_receive_gamestate[node] = false;
#endif
nodeingame[node] = false; // do we even need this?
Net_CloseConnection(node);
ResetNode(node);
}
@@ -3297,7 +3237,10 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason)
}
}
LUAh_PlayerQuit(&players[playernum], reason); // Lua hook for player quitting
LUA_HookPlayerQuit(&players[playernum], reason); // Lua hook for player quitting
if (playernum == displayplayers[0] && !demo.playback)
displayplayers[0] = consoleplayer; // don't look through someone's view who isn't there
// Reset player data
CL_ClearPlayer(playernum);
@@ -3318,9 +3261,6 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason)
RemoveAdminPlayer(playernum); // don't stay admin after you're gone
}
if (playernum == displayplayers[0] && !demo.playback)
displayplayers[0] = consoleplayer; // don't look through someone's view who isn't there
LUA_InvalidatePlayer(&players[playernum]);
if (G_BattleGametype()) // SRB2Kart
@@ -3361,9 +3301,6 @@ void CL_Reset(void)
if (servernode > 0 && servernode < MAXNETNODES)
{
nodeingame[(UINT8)servernode] = false;
#ifdef SATURNPAK
is_client_saturn[(UINT8)servernode] = false;
#endif
Net_CloseConnection(servernode);
}
D_CloseConnection(); // netgame = false
@@ -3708,16 +3645,13 @@ static void Command_Kick(void)
if (pn == -1 || pn == 0)
return;
if (server)
// Special case if we are trying to kick a player who is downloading the game state:
// trigger a timeout instead of kicking them, because a kick would only
// take effect after they have finished downloading
if (server && playernode[pn] != UINT8_MAX && sendingsavegame[playernode[pn]])
{
// Special case if we are trying to kick a player who is downloading the game state:
// trigger a timeout instead of kicking them, because a kick would only
// take effect after they have finished downloading
if (sendingsavegame[playernode[pn]])
{
Net_ConnectionTimeout(playernode[pn]);
return;
}
Net_ConnectionTimeout(playernode[pn]);
return;
}
WRITESINT8(p, pn);
@@ -3773,7 +3707,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum)
// Is playernum authorized to make this kick?
if (playernum != serverplayer && !IsPlayerAdmin(playernum)
/*&& !(playerpernode[playernode[playernum]] == 2
/*&& !(playernode[playernum] != UINT8_MAX && playerpernode[playernode[playernum]] == 2
//&& nodetoplayer2[playernode[playernum]] == pnum)*/)
{
// We received a kick command from someone who isn't the
@@ -4275,14 +4209,20 @@ void SV_ResetServer(void)
for (i = 0; i < MAXPLAYERS; i++)
{
LUA_InvalidatePlayer(&players[i]);
playeringame[i] = false;
playernode[i] = UINT8_MAX;
sprintf(player_names[i], "Player %d", i + 1);
adminplayers[i] = -1; // Populate the entire adminplayers array with -1.
}
memset(player_name_changes, 0, sizeof player_name_changes);
memset(playeringame, false, sizeof playeringame);
memset(playernode, UINT8_MAX, sizeof playernode);
pingmeasurecount = 1;
memset(realpingtable, 0, sizeof realpingtable);
memset(playerpingtable, 0, sizeof playerpingtable);
ClearAdminPlayers();
mynode = 0;
cl_packetmissed = false;
#ifdef SATURNSYNCH
@@ -4464,12 +4404,12 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
if (server && multiplayer && motd[0] != '\0')
COM_BufAddText(va("sayto %d %s\n", newplayernum, motd));
D_AddAutoloadFiles();
D_AddPostloadFiles();
LUAh_PlayerJoin(newplayernum);
LUA_HookInt(newplayernum, HOOK(PlayerJoin));
if (newplayernum == consoleplayer)
LUAh_ServerJoin();
LUA_HookVoid(HOOK(ServerJoin));
#ifdef HAVE_DISCORDRPC
DRPC_UpdatePresence();
@@ -4551,7 +4491,9 @@ static boolean SV_AddWaitingPlayers(void)
buf[0] = (UINT8)node;
buf[1] = newplayernum;
if (playerpernode[node] < 1)
{
nodetoplayer[node] = newplayernum;
}
else if (playerpernode[node] < 2)
{
nodetoplayer2[node] = newplayernum;
@@ -4649,10 +4591,8 @@ void SV_StopServer(void)
Y_EndVote();
gamestate = wipegamestate = GS_NULL;
localtextcmd[0] = 0;
localtextcmd2[0] = 0;
localtextcmd3[0] = 0;
localtextcmd4[0] = 0;
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
localtextcmd[i][0] = 0;
for (i = firstticstosend; i < firstticstosend + TICQUEUE; i++)
D_Clearticcmd(i);
@@ -5391,11 +5331,10 @@ static void HandlePacketFromPlayer(SINT8 node)
}
// Check player consistancy during the level
if (((!can_receive_gamestate[node]) && realstart <= gametic && realstart > gametic - TICQUEUE+1 && gamestate == GS_LEVEL
&& consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy)) || (can_receive_gamestate[node] && realstart <= gametic && realstart + TICQUEUE - 1 > gametic && gamestate == GS_LEVEL
if (gamestate == GS_LEVEL
&& (realstart > gametic - TICQUEUE+1 && realstart <= gametic)
&& consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy)
&& !resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime()
&& !SV_ResendingSavegameToAnyone()))
&& (!can_receive_gamestate[node] || (!resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime() && !SV_ResendingSavegameToAnyone())))
{
//#ifndef SATURNPAK // lug: keep this behaviour for v7.1 atleast
// we need to send this so the client can tell us if it can receive the savegame
@@ -5453,8 +5392,6 @@ static void HandlePacketFromPlayer(SINT8 node)
DEBFILE(va("player %d kicked (synch failure) [%u] %d!=%d\n",
netconsole, realstart, consistancy[realstart%TICQUEUE],
SHORT(netbuffer->u.clientpak.consistancy)));
gamestate_resend_counter[node] = 0;
DEBFILE(va("gamestate counter %d for node %d\n", gamestate_resend_counter[node], netconsole));
break;
}
}
@@ -5607,12 +5544,6 @@ static void HandlePacketFromPlayer(SINT8 node)
}
Net_CloseConnection(node);
nodeingame[node] = false;
#ifdef SATURNPAK
is_client_saturn[node] = false;
#endif
#ifdef SATURNSYNCH
can_receive_gamestate[node] = false;
#endif
break;
// -------------------------------------------- CLIENT RECEIVE ----------
case PT_RESYNCHEND:
@@ -6074,26 +6005,26 @@ static void CL_SendClientCmd(void)
else if (gamestate != GS_NULL)
{
packetsize = sizeof (clientcmd_pak);
G_MoveTiccmd(&netbuffer->u.clientpak.cmd, &localcmds, 1);
G_MoveTiccmd(&netbuffer->u.clientpak.cmd, &localcmds[0], 1);
netbuffer->u.clientpak.consistancy = SHORT(consistancy[gametic%TICQUEUE]);
if (splitscreen || botingame) // Send a special packet with 2 cmd for splitscreen
{
netbuffer->packettype = (mis ? PT_CLIENT2MIS : PT_CLIENT2CMD);
packetsize = sizeof (client2cmd_pak);
G_MoveTiccmd(&netbuffer->u.client2pak.cmd2, &localcmds2, 1);
G_MoveTiccmd(&netbuffer->u.client2pak.cmd2, &localcmds[1], 1);
if (splitscreen > 1)
{
netbuffer->packettype = (mis ? PT_CLIENT3MIS : PT_CLIENT3CMD);
packetsize = sizeof (client3cmd_pak);
G_MoveTiccmd(&netbuffer->u.client3pak.cmd3, &localcmds3, 1);
G_MoveTiccmd(&netbuffer->u.client3pak.cmd3, &localcmds[2], 1);
if (splitscreen > 2)
{
netbuffer->packettype = (mis ? PT_CLIENT4MIS : PT_CLIENT4CMD);
packetsize = sizeof (client4cmd_pak);
G_MoveTiccmd(&netbuffer->u.client4pak.cmd4, &localcmds4, 1);
G_MoveTiccmd(&netbuffer->u.client4pak.cmd4, &localcmds[3], 1);
}
}
}
@@ -6103,44 +6034,33 @@ static void CL_SendClientCmd(void)
if (cl_mode == CL_CONNECTED || dedicated)
{
UINT8 i;
// Send extra data if needed
if (localtextcmd[0])
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
netbuffer->packettype = PT_TEXTCMD;
M_Memcpy(netbuffer->u.textcmd,localtextcmd, localtextcmd[0]+1);
// All extra data have been sent
if (HSendPacket(servernode, true, 0, localtextcmd[0]+1)) // Send can fail...
localtextcmd[0] = 0;
}
if (localtextcmd[i][0])
{
switch (i)
{
case 3:
netbuffer->packettype = PT_TEXTCMD4;
break;
case 2:
netbuffer->packettype = PT_TEXTCMD3;
break;
case 1:
netbuffer->packettype = PT_TEXTCMD2;
break;
default:
netbuffer->packettype = PT_TEXTCMD;
break;
}
// Send extra data if needed for player 2 (splitscreen == 1)
if (localtextcmd2[0])
{
netbuffer->packettype = PT_TEXTCMD2;
M_Memcpy(netbuffer->u.textcmd, localtextcmd2, localtextcmd2[0]+1);
// All extra data have been sent
if (HSendPacket(servernode, true, 0, localtextcmd2[0]+1)) // Send can fail...
localtextcmd2[0] = 0;
}
// Send extra data if needed for player 3 (splitscreen == 2)
if (localtextcmd3[0])
{
netbuffer->packettype = PT_TEXTCMD3;
M_Memcpy(netbuffer->u.textcmd, localtextcmd3, localtextcmd3[0]+1);
// All extra data have been sent
if (HSendPacket(servernode, true, 0, localtextcmd3[0]+1)) // Send can fail...
localtextcmd3[0] = 0;
}
// Send extra data if needed for player 4 (splitscreen == 3)
if (localtextcmd4[0])
{
netbuffer->packettype = PT_TEXTCMD4;
M_Memcpy(netbuffer->u.textcmd, localtextcmd4, localtextcmd4[0]+1);
// All extra data have been sent
if (HSendPacket(servernode, true, 0, localtextcmd4[0]+1)) // Send can fail...
localtextcmd4[0] = 0;
M_Memcpy(netbuffer->u.textcmd, localtextcmd[i], localtextcmd[i][0]+1);
// All extra data have been sent
if (HSendPacket(servernode, true, 0, localtextcmd[i][0]+1)) // Send can fail...
localtextcmd[i][0] = 0;
}
}
}
}
@@ -6160,106 +6080,108 @@ static void SV_SendTics(void)
// for each node create a packet with x tics and send it
// x is computed using supposedtics[n], max packet size and maketic
for (n = 1; n < MAXNETNODES; n++)
if (nodeingame[n])
{
if (!nodeingame[n])
continue;
// assert supposedtics[n]>=nettics[n]
realfirsttic = supposedtics[n];
lasttictosend = maketic;
if (lasttictosend - nettics[n] >= BACKUPTICS)
lasttictosend = nettics[n] + BACKUPTICS-1;
if (realfirsttic >= lasttictosend)
{
// assert supposedtics[n]>=nettics[n]
realfirsttic = supposedtics[n];
lasttictosend = maketic;
if (lasttictosend - nettics[n] >= BACKUPTICS)
lasttictosend = nettics[n] + BACKUPTICS-1;
if (realfirsttic >= lasttictosend)
{
// well we have sent all tics we will so use extrabandwidth
// to resent packet that are supposed lost (this is necessary since lost
// packet detection work when we have received packet with firsttic > neededtic
// (getpacket servertics case)
DEBFILE(va("Nothing to send node %u mak=%u sup=%u net=%u \n",
n, lasttictosend, supposedtics[n], nettics[n]));
realfirsttic = nettics[n];
if (realfirsttic >= lasttictosend || (I_GetTime() + n)&3)
// all tic are ok
continue;
DEBFILE(va("Sent %d anyway\n", realfirsttic));
}
if (realfirsttic < firstticstosend)
realfirsttic = firstticstosend;
// compute the length of the packet and cut it if too large
packsize = BASESERVERTICSSIZE;
for (i = realfirsttic; i < lasttictosend; i++)
{
packsize += sizeof (ticcmd_t) * doomcom->numslots;
packsize += TotalTextCmdPerTic(i);
if (packsize > software_MAXPACKETLENGTH)
{
DEBFILE(va("packet too large (%s) at tic %d (should be from %d to %d)\n",
sizeu1(packsize), i, realfirsttic, lasttictosend));
lasttictosend = i;
// too bad: too much player have send extradata and there is too
// much data in one tic.
// To avoid it put the data on the next tic. (see getpacket
// textcmd case) but when numplayer changes the computation can be different
if (lasttictosend == realfirsttic)
{
if (packsize > MAXPACKETLENGTH)
I_Error("Too many players: can't send %s data for %d players to node %d\n"
"Well sorry nobody is perfect....\n",
sizeu1(packsize), doomcom->numslots, n);
else
{
lasttictosend++; // send it anyway!
DEBFILE("sending it anyway\n");
}
}
break;
}
}
// Send the tics
netbuffer->packettype = PT_SERVERTICS;
netbuffer->u.serverpak.starttic = (UINT8)realfirsttic;
netbuffer->u.serverpak.numtics = (UINT8)(lasttictosend - realfirsttic);
netbuffer->u.serverpak.numslots = (UINT8)SHORT(doomcom->numslots);
bufpos = (UINT8 *)&netbuffer->u.serverpak.cmds;
for (i = realfirsttic; i < lasttictosend; i++)
{
bufpos = G_DcpyTiccmd(bufpos, netcmds[i%TICQUEUE], doomcom->numslots * sizeof (ticcmd_t));
}
// add textcmds
for (i = realfirsttic; i < lasttictosend; i++)
{
ntextcmd = bufpos++;
*ntextcmd = 0;
for (j = 0; j < MAXPLAYERS; j++)
{
UINT8 *textcmd = D_GetExistingTextcmd(i, j);
INT32 size = textcmd ? textcmd[0] : 0;
if ((!j || playeringame[j]) && size)
{
(*ntextcmd)++;
WRITEUINT8(bufpos, j);
M_Memcpy(bufpos, textcmd, size + 1);
bufpos += size + 1;
}
}
}
packsize = bufpos - (UINT8 *)&(netbuffer->u);
HSendPacket(n, false, 0, packsize);
// when tic are too large, only one tic is sent so don't go backward!
if (lasttictosend-doomcom->extratics > realfirsttic)
supposedtics[n] = lasttictosend-doomcom->extratics;
else
supposedtics[n] = lasttictosend;
if (supposedtics[n] < nettics[n]) supposedtics[n] = nettics[n];
// well we have sent all tics we will so use extrabandwidth
// to resent packet that are supposed lost (this is necessary since lost
// packet detection work when we have received packet with firsttic > neededtic
// (getpacket servertics case)
DEBFILE(va("Nothing to send node %u mak=%u sup=%u net=%u \n",
n, lasttictosend, supposedtics[n], nettics[n]));
realfirsttic = nettics[n];
if (realfirsttic >= lasttictosend || (I_GetTime() + n)&3)
// all tic are ok
continue;
DEBFILE(va("Sent %d anyway\n", realfirsttic));
}
if (realfirsttic < firstticstosend)
realfirsttic = firstticstosend;
// compute the length of the packet and cut it if too large
packsize = BASESERVERTICSSIZE;
for (i = realfirsttic; i < lasttictosend; i++)
{
packsize += sizeof (ticcmd_t) * doomcom->numslots;
packsize += TotalTextCmdPerTic(i);
if (packsize > software_MAXPACKETLENGTH)
{
DEBFILE(va("packet too large (%s) at tic %d (should be from %d to %d)\n",
sizeu1(packsize), i, realfirsttic, lasttictosend));
lasttictosend = i;
// too bad: too much player have send extradata and there is too
// much data in one tic.
// To avoid it put the data on the next tic. (see getpacket
// textcmd case) but when numplayer changes the computation can be different
if (lasttictosend == realfirsttic)
{
if (packsize > MAXPACKETLENGTH)
I_Error("Too many players: can't send %s data for %d players to node %d\n"
"Well sorry nobody is perfect....\n",
sizeu1(packsize), doomcom->numslots, n);
else
{
lasttictosend++; // send it anyway!
DEBFILE("sending it anyway\n");
}
}
break;
}
}
// Send the tics
netbuffer->packettype = PT_SERVERTICS;
netbuffer->u.serverpak.starttic = (UINT8)realfirsttic;
netbuffer->u.serverpak.numtics = (UINT8)(lasttictosend - realfirsttic);
netbuffer->u.serverpak.numslots = (UINT8)SHORT(doomcom->numslots);
bufpos = (UINT8 *)&netbuffer->u.serverpak.cmds;
for (i = realfirsttic; i < lasttictosend; i++)
{
bufpos = G_DcpyTiccmd(bufpos, netcmds[i%TICQUEUE], doomcom->numslots * sizeof (ticcmd_t));
}
// add textcmds
for (i = realfirsttic; i < lasttictosend; i++)
{
ntextcmd = bufpos++;
*ntextcmd = 0;
for (j = 0; j < MAXPLAYERS; j++)
{
UINT8 *textcmd = D_GetExistingTextcmd(i, j);
INT32 size = textcmd ? textcmd[0] : 0;
if ((!j || playeringame[j]) && size)
{
(*ntextcmd)++;
WRITEUINT8(bufpos, j);
M_Memcpy(bufpos, textcmd, size + 1);
bufpos += size + 1;
}
}
}
packsize = bufpos - (UINT8 *)&(netbuffer->u);
HSendPacket(n, false, 0, packsize);
// when tic are too large, only one tic is sent so don't go backward!
if (lasttictosend-doomcom->extratics > realfirsttic)
supposedtics[n] = lasttictosend-doomcom->extratics;
else
supposedtics[n] = lasttictosend;
if (supposedtics[n] < nettics[n]) supposedtics[n] = nettics[n];
}
// node 0 is me!
supposedtics[0] = maketic;
}
@@ -6267,27 +6189,27 @@ static void SV_SendTics(void)
//
// TryRunTics
//
static inline void CreateNewLocalCMD(UINT8 p, INT32 realtics)
{
G_BuildTiccmd(&localcmds[p], realtics, p+1);
localcmds[p].angleturn |= TICCMD_RECEIVED;
}
static void Local_Maketic(INT32 realtics)
{
INT32 i;
I_OsPolling(); // I_Getevent
D_ProcessEvents(); // menu responder, cons responder,
// game responder calls HU_Responder, AM_Responder, F_Responder,
// and G_MapEventsToControls
if (!dedicated) rendergametic = gametic;
// translate inputs (keyboard/mouse/joystick) into game controls
G_BuildTiccmd(&localcmds, realtics, 1);
if (splitscreen || botingame)
{
G_BuildTiccmd(&localcmds2, realtics, 2);
if (splitscreen > 1)
{
G_BuildTiccmd(&localcmds3, realtics, 3);
if (splitscreen > 2)
G_BuildTiccmd(&localcmds4, realtics, 4);
}
}
localcmds.angleturn |= TICCMD_RECEIVED;
for (i = 0; i <= splitscreen; i++)
{
CreateNewLocalCMD(i, realtics);
}
}
void SV_SpawnPlayer(INT32 playernum, INT32 x, INT32 y, angle_t angle)
@@ -6326,29 +6248,31 @@ static void SV_Maketic(void)
INT32 j;
for (j = 0; j < MAXNETNODES; j++)
if (playerpernode[j])
{
INT32 player = nodetoplayer[j];
if ((netcmds[maketic%TICQUEUE][player].angleturn & TICCMD_RECEIVED) == 0)
{ // we didn't receive this tic
INT32 i;
{
if (!playerpernode[j])
continue;
DEBFILE(va("MISS tic%4d for node %d\n", maketic, j));
INT32 player = nodetoplayer[j];
if ((netcmds[maketic%TICQUEUE][player].angleturn & TICCMD_RECEIVED) == 0)
{ // we didn't receive this tic
INT32 i;
DEBFILE(va("MISS tic%4d for node %d\n", maketic, j));
#if defined(PARANOIA) && 0
CONS_Debug(DBG_NETPLAY, "Client Misstic %d\n", maketic);
CONS_Debug(DBG_NETPLAY, "Client Misstic %d\n", maketic);
#endif
// copy the old tic
for (i = 0; i < playerpernode[j]; i++)
{
if (i == 0) player = nodetoplayer[j];
else if (i == 1) player = nodetoplayer2[j];
else if (i == 2) player = nodetoplayer3[j];
else if (i == 3) player = nodetoplayer4[j];
netcmds[maketic%TICQUEUE][player] = netcmds[(maketic-1)%TICQUEUE][player];
netcmds[maketic%TICQUEUE][player].angleturn &= ~TICCMD_RECEIVED;
}
// copy the old tic
for (i = 0; i < playerpernode[j]; i++)
{
if (i == 0) player = nodetoplayer[j];
else if (i == 1) player = nodetoplayer2[j];
else if (i == 2) player = nodetoplayer3[j];
else if (i == 3) player = nodetoplayer4[j];
netcmds[maketic%TICQUEUE][player] = netcmds[(maketic-1)%TICQUEUE][player];
netcmds[maketic%TICQUEUE][player].angleturn &= ~TICCMD_RECEIVED;
}
}
}
// all tic are now proceed make the next
maketic++;
@@ -6401,19 +6325,21 @@ boolean TryRunTics(tic_t realtics)
}
#endif
if (neededtic > gametic)
ticking = neededtic > gametic;
if (ticking)
{
hu_stopped = false;
if (realtics)
hu_stopped = false;
}
if (player_joining)
{
hu_stopped = true;
if (realtics)
hu_stopped = true;
return false;
}
ticking = neededtic > gametic;
if (ticking)
{
// run the count * tics
@@ -6444,7 +6370,8 @@ boolean TryRunTics(tic_t realtics)
}
else
{
hu_stopped = true;
if (realtics)
hu_stopped = true;
}
return ticking;
@@ -6574,7 +6501,7 @@ static void UpdatePingTable(void)
PingUpdate();
// update node latency values so we can take an average later.
for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i])
if (playeringame[i] && playernode[i] != UINT8_MAX)
realpingtable[i] += GetLag(playernode[i]);
pingmeasurecount++;
}
@@ -6672,6 +6599,14 @@ void NetUpdate(void)
if (realtics <= 0) // nothing new to update
return;
if (realtics > 5)
{
if (server)
realtics = 1;
else
realtics = 5;
}
#ifdef DEDICATEDIDLETIME
if (server && dedicated && gamestate == GS_LEVEL)
{
@@ -6720,14 +6655,6 @@ void NetUpdate(void)
}
#endif
if (realtics > 5)
{
if (server)
realtics = 1;
else
realtics = 5;
}
gametime = nowtime;
UpdatePingTable();
@@ -6820,6 +6747,9 @@ void NetUpdate(void)
}
Net_AckTicker();
HandleNodeTimeouts();
nowtime /= NEWTICRATERATIO;
if (nowtime > resptime)
{
resptime = nowtime;
+3 -5
View File
@@ -600,10 +600,8 @@ void D_ClientServerInit(void);
// Initialise the other field
void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(UINT8 **p, INT32 playernum));
void SendNetXCmd(netxcmd_t id, const void *param, size_t nparam);
void SendNetXCmd2(netxcmd_t id, const void *param, size_t nparam); // splitsreen player
void SendNetXCmd3(netxcmd_t id, const void *param, size_t nparam); // splitsreen3 player
void SendNetXCmd4(netxcmd_t id, const void *param, size_t nparam); // splitsreen4 player
void SendNetXCmdForPlayer(UINT8 playerid, netxcmd_t id, const void *param, size_t nparam);
#define SendNetXCmd(id, param, nparam) SendNetXCmdForPlayer(0, id, param, nparam) // Shortcut for P1
// Create any new ticcmds and broadcast to other players.
void NetKeepAlive(void);
@@ -650,7 +648,7 @@ INT32 D_NumPlayers(void);
void D_ResetTiccmds(void);
tic_t GetLag(INT32 node);
UINT8 GetFreeXCmdSize(void);
//UINT8 GetFreeXCmdSize(UINT8 playerid);
extern UINT8 hu_resynching;
#ifdef SATURNSYNCH
+42 -65
View File
@@ -15,6 +15,7 @@
/// plus functions to parse command line parameters, configure game
/// parameters, and call the startup functions.
#include "d_netcmd.h"
#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON)
#include <sys/stat.h>
#include <sys/types.h>
@@ -99,7 +100,6 @@ UINT8 window_notinfocus = false;
// DEMO LOOP
//
//static INT32 demosequence;
static const char *pagename = "MAP1PIC";
static char *startupwadfiles[MAX_WADFILES];
static char *startuppwads[MAX_WADFILES];
@@ -116,7 +116,6 @@ boolean devparm = false; // started game with -devparm
boolean singletics = false; // timedemo
boolean lastdraw = false;
postimg_t postimgtype[MAXSPLITSCREENPLAYERS];
INT32 postimgparam[MAXSPLITSCREENPLAYERS];
// These variables are only true if
@@ -183,7 +182,7 @@ static inline void D_DeviceLEDTick(void)
for (i = 0; i <= splitscreen; i++)
{
if (G_GetDeviceForPlayer(i) == 0)
if (cv_usejoystick[i].value == 0)
continue;
color[i] = G_GetSkinColor(i);
@@ -451,6 +450,8 @@ static boolean D_Display(void)
{
if (players[displayplayers[i]].mo || players[displayplayers[i]].playerstate == PST_DEAD)
{
viewssnum = i;
if (i == 0) // Initialize for P1
{
viewwindowy = 0;
@@ -460,8 +461,6 @@ static boolean D_Display(void)
objectsdrawn = 0;
}
viewssnum = i;
#ifdef HWRENDER
if (rendermode == render_opengl)
HWR_RenderPlayerView(i, &players[displayplayers[i]]);
@@ -513,15 +512,12 @@ static boolean D_Display(void)
if (rendermode == render_soft)
{
if (!splitscreen)
R_ApplyViewMorph();
if (!splitscreen)
R_ApplyViewMorph();
for (i = 0; i <= splitscreen; i++)
{
if (!postimgtype[i])
continue;
V_DoPostProcessor(i, postimgtype[i], postimgparam[i]);
V_DoPostProcessor(i, &players[displayplayers[i]], postimgparam[i]);
}
}
@@ -542,6 +538,8 @@ static boolean D_Display(void)
PS_START_TIMING(ps_uitime);
ST_Drawer();
HU_Drawer();
NetUpdate(); // TEST: run this EVERY frame
}
else
{
@@ -745,10 +743,10 @@ void D_SRB2Loop(void)
renderisnewtic = (realtics > 0 || singletics);
refreshdirmenu = 0; // not sure where to put this, here as good as any?
if (renderisnewtic)
{
refreshdirmenu = 0; // not sure where to put this, here as good as any?
// don't skip more than 10 frames at a time
// (fadein / fadeout cause massive frame skip!)
if (realtics > 8)
@@ -818,7 +816,7 @@ void D_SRB2Loop(void)
{
renderdeltatics = FLOAT_TO_FIXED(deltatics);
if (!(paused || P_AutoPause()) && deltatics < 1.0 && !hu_stopped)
if (!(paused || P_AutoPause()) && !hu_stopped)
{
rendertimefrac = g_time.timefrac;
}
@@ -857,7 +855,7 @@ void D_SRB2Loop(void)
LUA_Step();
#ifdef HAVE_DISCORDRPC
if (! dedicated)
if (!dedicated)
{
Discord_RunCallbacks();
}
@@ -966,6 +964,9 @@ void D_StartTitle(void)
//demosequence = -1;
gametype = GT_RACE; // SRB2kart
paused = false;
S_ResetKeepAndSpecialMus(); // just in case
F_StartTitleScreen();
// Reset the palette -- SRB2Kart: actually never mind let's do this in the middle of every fade
@@ -1072,8 +1073,7 @@ static void D_FindAddonsToAutoload(void)
const char *autoloadpath;
boolean postload;
INT32 i, len;
boolean hasprefix = false;
INT32 i;
char wadsToAutoload[256] = "";
// does it exist tho
@@ -1095,7 +1095,8 @@ static void D_FindAddonsToAutoload(void)
|| (wadsToAutoload[0] == '#'))
continue;
// this marks it so that it loads after loading server addons
else if (fastncmp(wadsToAutoload, "postload ", 9)) {
else if (fastncmp(wadsToAutoload, "postload ", 9))
{
strremove(wadsToAutoload, "postload ");
postload = true;
}
@@ -1107,34 +1108,10 @@ static void D_FindAddonsToAutoload(void)
wadsToAutoload[i] = '\0';
}
len = strlen(wadsToAutoload);
hasprefix = false;
for (i = 0; i < len; ++i)
if (!postload && W_CheckPostLoadList(wadsToAutoload))
{
if (wadsToAutoload[i] == '_')
{
hasprefix = true;
break;
}
}
// Lets just hope no one adds bonuschars in autoload
if (hasprefix)
{
// We searching for c in prefix, which stands for "character" and doesn't work well with
// autoload atm, only fine for postload
for (i = 0; i < len; ++i)
{
if (wadsToAutoload[i] == '_') break; // Prefix end
if (wadsToAutoload[i] == 'c' || wadsToAutoload[i] == 'C')
{
CONS_Alert(CONS_WARNING, "forcing postload for %s as local skin\n", wadsToAutoload);
postload = true;
break; // Found it
}
}
CONS_Printf("forcing postload for file %s\n", wadsToAutoload);
postload = true;
}
// LOAD IT
@@ -1152,30 +1129,30 @@ static void D_FindAddonsToAutoload(void)
fclose(autoloadconfigfile);
}
void D_AddAutoloadFiles(void)
static void D_AddAutoloadFiles(void)
{
if (wasautoloaded && postautoloaded)
if (wasautoloaded)
return;
if (!wasautoloaded && !modeattacking)
{
CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n");
if (W_AddAutoloadedLocalFiles(autoloadwadfiles) == 0)
CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n");
D_CleanFile(autoloadwadfiles);
CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n");
if (W_AddAutoloadedLocalFiles(autoloadwadfiles) == 0)
CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n");
D_CleanFile(autoloadwadfiles);
wasautoloaded = true;
}
wasautoloaded = true;
}
if ((!postautoloaded) && netgame)
{
CONS_Printf("D_AutoloadFile(): Loading postloaded addons...\n");
if (W_AddAutoloadedLocalFiles(autoloadwadfilespost) == 0)
CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n");
D_CleanFile(autoloadwadfilespost);
void D_AddPostloadFiles(void)
{
if (postautoloaded || !netgame)
return;
postautoloaded = true;
}
CONS_Printf("D_AddPostloadFiles(): Loading postloaded addons...\n");
if (W_AddAutoloadedLocalFiles(autoloadwadfilespost) == 0)
CONS_Printf("D_AddPostloadFiles(): Are you sure you put in valid files or what?\n");
D_CleanFile(autoloadwadfilespost);
postautoloaded = true;
}
void D_CleanFile(char **filearray)
@@ -1865,11 +1842,12 @@ void D_SRB2Main(void)
}
S_InitMusicDefs();
S_InitMTDefs();
CONS_Printf("ST_Init(): Init status bar.\n");
ST_Init();
D_AddAutoloadFiles();
// Set up splitscreen players before joining!
if (!dedicated && (M_CheckParm("-splitscreen") && M_IsNextParm()))
{
@@ -2071,7 +2049,6 @@ void D_SRB2Main(void)
if (dedicated && server)
{
pagename = "TITLESKY";
levelstarttic = gametic;
G_SetGamestate(GS_LEVEL);
if (!P_SetupLevel(false, false))
+3 -3
View File
@@ -45,12 +45,12 @@ extern boolean statdp; // stat display for extended player setup
extern boolean nametaggfx; // Nametag stuffs
extern boolean driftgaugegfx;
void D_AddAutoloadFiles(void);
// autoload stuff
extern boolean autoloading;
extern boolean autoloaded;
extern boolean postautoloaded;
extern boolean wasautoloaded;
void D_AddPostloadFiles(void);
extern char *autoloadwadfilespost[MAX_WADFILES];
extern char *autoloadwadfiles[MAX_WADFILES];
+1 -13
View File
@@ -69,8 +69,6 @@ INT16 hardware_MAXPACKETLENGTH;
boolean (*I_NetGet)(void) = NULL;
void (*I_NetSend)(void) = NULL;
boolean (*I_NetCanSend)(void) = NULL;
boolean (*I_NetCanGet)(void) = NULL;
void (*I_NetCloseSocket)(void) = NULL;
void (*I_NetFreeNodenum)(INT32 nodenum) = NULL;
SINT8 (*I_NetMakeNodewPort)(const char *address, const char* port) = NULL;
@@ -1087,15 +1085,7 @@ boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlen
netbuffer->ackreturn = 0;
if (reliable)
{
if (I_NetCanSend && !I_NetCanSend())
{
if (netbuffer->packettype < PT_CANFAIL)
GetFreeAcknum(&netbuffer->ack, true);
DEBFILE("HSendPacket: Out of bandwidth\n");
return false;
}
else if (!GetFreeAcknum(&netbuffer->ack, false))
if (!GetFreeAcknum(&netbuffer->ack, false))
return false;
}
else
@@ -1292,7 +1282,6 @@ boolean D_CheckNetGame(void)
I_NetGet = Internal_Get;
I_NetSend = Internal_Send;
I_NetCanSend = NULL;
I_NetCloseSocket = NULL;
I_NetFreeNodenum = Internal_FreeNodenum;
I_NetMakeNodewPort = NULL;
@@ -1491,7 +1480,6 @@ void D_CloseConnection(void)
I_NetGet = Internal_Get;
I_NetSend = Internal_Send;
I_NetCanSend = NULL;
I_NetCloseSocket = NULL;
I_NetFreeNodenum = Internal_FreeNodenum;
I_NetMakeNodewPort = NULL;
+241 -203
View File
@@ -16,6 +16,7 @@
#include "console.h"
#include "command.h"
#include "dehacked.h"
#include "i_time.h"
#include "i_system.h"
#include "g_game.h"
@@ -141,6 +142,8 @@ static void Command_Addfile(void);
static void Command_Addskins(void);
static void Command_GLocalSkin(void);
static void Command_ListWADS_f(void);
static void Command_ListDoomednums_f(void);
static void Command_ListUnusedSprites_f(void);
static void Command_RunSOC(void);
static void Command_Pause(void);
static void Command_Respawn(void);
@@ -303,14 +306,12 @@ consvar_t cv_mouseturn = {"mouseturn", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL,
consvar_t cv_laglesscam = {"laglesscamera", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
#if defined(HAVE_SDL) || defined(_WINDOWS) //joystick 1 and 2
consvar_t cv_usejoystick = {"use_joystick", "1", CV_SAVE|CV_CALL, usejoystick_cons_t,
I_InitJoystick, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_usejoystick2 = {"use_joystick2", "2", CV_SAVE|CV_CALL, usejoystick_cons_t,
I_InitJoystick2, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_usejoystick3 = {"use_joystick3", "3", CV_SAVE|CV_CALL, usejoystick_cons_t,
I_InitJoystick3, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_usejoystick4 = {"use_joystick4", "4", CV_SAVE|CV_CALL, usejoystick_cons_t,
I_InitJoystick4, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_usejoystick[MAXSPLITSCREENPLAYERS] = {
{"use_joystick", "1", CV_SAVE|CV_CALL, usejoystick_cons_t, I_InitJoystick1, 0, NULL, NULL, 0, 0, NULL},
{"use_joystick2", "2", CV_SAVE|CV_CALL, usejoystick_cons_t, I_InitJoystick2, 0, NULL, NULL, 0, 0, NULL},
{"use_joystick3", "3", CV_SAVE|CV_CALL, usejoystick_cons_t, I_InitJoystick3, 0, NULL, NULL, 0, 0, NULL},
{"use_joystick4", "4", CV_SAVE|CV_CALL, usejoystick_cons_t, I_InitJoystick4, 0, NULL, NULL, 0, 0, NULL}
};
#endif
#if (defined (LJOYSTICK) || defined (HAVE_SDL))
@@ -318,13 +319,17 @@ consvar_t cv_usejoystick4 = {"use_joystick4", "4", CV_SAVE|CV_CALL, usejoystick_
consvar_t cv_joyport = {"joyport", "/dev/js0", CV_SAVE, joyport_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_joyport2 = {"joyport2", "/dev/js0", CV_SAVE, joyport_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; //Alam: for later
#endif
consvar_t cv_joyscale = {"joyscale", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_joyscale2 = {"joyscale2", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale2, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_joyscale3 = {"joyscale3", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale3, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_joyscale4 = {"joyscale4", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale4, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_joyscale[MAXSPLITSCREENPLAYERS] = {
{"joyscale", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale, 0, NULL, NULL, 0, 0, NULL},
{"joyscale2", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale2, 0, NULL, NULL, 0, 0, NULL},
{"joyscale3", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale3, 0, NULL, NULL, 0, 0, NULL},
{"joyscale4", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale4, 0, NULL, NULL, 0, 0, NULL}
};
#else
consvar_t cv_joyscale = {"joyscale", "1", CV_SAVE|CV_HIDEN, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; //Alam: Dummy for save
consvar_t cv_joyscale2 = {"joyscale2", "1", CV_SAVE|CV_HIDEN, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; //Alam: Dummy for save
consvar_t cv_joyscale[2] = { //Alam: Dummy for save
{"joyscale", "1", CV_SAVE|CV_HIDEN, NULL, NULL, 0, NULL, NULL, 0, 0, NULL},
{"joyscale", "1", CV_SAVE|CV_HIDEN, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}
};
#endif
#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON)
consvar_t cv_mouse2port = {"mouse2port", "/dev/gpmdata", CV_SAVE, mouse2port_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -539,9 +544,9 @@ consvar_t cv_nametagscore = {"kartnametagscore", "Off", CV_SAVE, CV_OnOff, NULL,
consvar_t cv_shownametagfinish = {"kartshownametagfinished", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_shownametagspectator = {"kartshownametagspectator", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t driftgaugeoffset_cons_t[] = {
{-FRACUNIT*128, "MIN"}, {FRACUNIT*128, "MAX"}, {0, NULL}};
static CV_PossibleValue_t driftgaugestyle_cons_t[] = {
{1, "Default"}, {2, "Small"}, {3, "Big Numbers"}, {4, "Numbers Only"}, {0, NULL}};
@@ -703,6 +708,8 @@ void D_RegisterServerCommands(void)
COM_AddCommand("addskins", Command_Addskins);
COM_AddCommand("localskin", Command_GLocalSkin);
COM_AddCommand("listwad", Command_ListWADS_f);
COM_AddCommand("listmapthings", Command_ListDoomednums_f);
COM_AddCommand("listunusedsprites", Command_ListUnusedSprites_f);
COM_AddCommand("runsoc", Command_RunSOC);
COM_AddCommand("pause", Command_Pause);
@@ -900,6 +907,7 @@ void D_RegisterClientCommands(void)
COM_AddCommand("screenshot", M_ScreenShot);
COM_AddCommand("startmovie", Command_StartMovie_f);
COM_AddCommand("stopmovie", Command_StopMovie_f);
COM_AddCommand("minigen", M_MinimapGenerate);
CV_RegisterVar(&cv_screenshot_option);
CV_RegisterVar(&cv_screenshot_folder);
@@ -1019,58 +1027,22 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_pauseifunfocused);
// g_input.c
CV_RegisterVar(&cv_turnaxis);
CV_RegisterVar(&cv_turnaxis2);
CV_RegisterVar(&cv_turnaxis3);
CV_RegisterVar(&cv_turnaxis4);
CV_RegisterVar(&cv_moveaxis);
CV_RegisterVar(&cv_moveaxis2);
CV_RegisterVar(&cv_moveaxis3);
CV_RegisterVar(&cv_moveaxis4);
CV_RegisterVar(&cv_brakeaxis);
CV_RegisterVar(&cv_brakeaxis2);
CV_RegisterVar(&cv_brakeaxis3);
CV_RegisterVar(&cv_brakeaxis4);
CV_RegisterVar(&cv_aimaxis);
CV_RegisterVar(&cv_aimaxis2);
CV_RegisterVar(&cv_aimaxis3);
CV_RegisterVar(&cv_aimaxis4);
CV_RegisterVar(&cv_lookaxis);
CV_RegisterVar(&cv_lookaxis2);
CV_RegisterVar(&cv_lookaxis3);
CV_RegisterVar(&cv_lookaxis4);
CV_RegisterVar(&cv_fireaxis);
CV_RegisterVar(&cv_fireaxis2);
CV_RegisterVar(&cv_fireaxis3);
CV_RegisterVar(&cv_fireaxis4);
CV_RegisterVar(&cv_driftaxis);
CV_RegisterVar(&cv_driftaxis2);
CV_RegisterVar(&cv_driftaxis3);
CV_RegisterVar(&cv_driftaxis4);
CV_RegisterVar(&cv_lookbackaxis);
CV_RegisterVar(&cv_lookbackaxis2);
CV_RegisterVar(&cv_lookbackaxis3);
CV_RegisterVar(&cv_lookbackaxis4);
CV_RegisterVar(&cv_custom1axis);
CV_RegisterVar(&cv_custom1axis2);
CV_RegisterVar(&cv_custom1axis3);
CV_RegisterVar(&cv_custom1axis4);
CV_RegisterVar(&cv_custom2axis);
CV_RegisterVar(&cv_custom2axis2);
CV_RegisterVar(&cv_custom2axis3);
CV_RegisterVar(&cv_custom2axis4);
CV_RegisterVar(&cv_custom3axis);
CV_RegisterVar(&cv_custom3axis2);
CV_RegisterVar(&cv_custom3axis3);
CV_RegisterVar(&cv_custom3axis4);
CV_RegisterVar(&cv_xdeadzone);
CV_RegisterVar(&cv_ydeadzone);
CV_RegisterVar(&cv_xdeadzone2);
CV_RegisterVar(&cv_ydeadzone2);
CV_RegisterVar(&cv_xdeadzone3);
CV_RegisterVar(&cv_ydeadzone3);
CV_RegisterVar(&cv_xdeadzone4);
CV_RegisterVar(&cv_ydeadzone4);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
CV_RegisterVar(&cv_turnaxis[i]);
CV_RegisterVar(&cv_moveaxis[i]);
CV_RegisterVar(&cv_brakeaxis[i]);
CV_RegisterVar(&cv_aimaxis[i]);
CV_RegisterVar(&cv_lookaxis[i]);
CV_RegisterVar(&cv_fireaxis[i]);
CV_RegisterVar(&cv_driftaxis[i]);
CV_RegisterVar(&cv_lookbackaxis[i]);
CV_RegisterVar(&cv_custom1axis[i]);
CV_RegisterVar(&cv_custom2axis[i]);
CV_RegisterVar(&cv_custom3axis[i]);
CV_RegisterVar(&cv_xdeadzone[i]);
CV_RegisterVar(&cv_ydeadzone[i]);
}
// filesrch.c
CV_RegisterVar(&cv_addons_option);
@@ -1107,28 +1079,19 @@ void D_RegisterClientCommands(void)
//CV_RegisterVar(&cv_mousemove);
//CV_RegisterVar(&cv_mousemove2);
CV_RegisterVar(&cv_usejoystick);
CV_RegisterVar(&cv_usejoystick2);
CV_RegisterVar(&cv_usejoystick3);
CV_RegisterVar(&cv_usejoystick4);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
CV_RegisterVar(&cv_usejoystick[i]);
}
#ifdef LJOYSTICK
CV_RegisterVar(&cv_joyport);
CV_RegisterVar(&cv_joyport2);
#endif
CV_RegisterVar(&cv_joyscale);
CV_RegisterVar(&cv_joyscale2);
CV_RegisterVar(&cv_joyscale3);
CV_RegisterVar(&cv_joyscale4);
// Analog Control
/*CV_RegisterVar(&cv_analog);
CV_RegisterVar(&cv_analog2);
CV_RegisterVar(&cv_analog3);
CV_RegisterVar(&cv_analog4);
CV_RegisterVar(&cv_useranalog);
CV_RegisterVar(&cv_useranalog2);
CV_RegisterVar(&cv_useranalog3);
CV_RegisterVar(&cv_useranalog4);*/
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
CV_RegisterVar(&cv_joyscale[i]);
}
// s_sound.c
CV_RegisterVar(&cv_soundvolume);
@@ -1157,7 +1120,7 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_scr_height);
CV_RegisterVar(&cv_soundtest);
CV_RegisterVar(&cv_nametag);
CV_RegisterVar(&cv_nametagtrans);
CV_RegisterVar(&cv_nametagfacerank);
@@ -1172,7 +1135,7 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_nametagscore);
CV_RegisterVar(&cv_shownametagfinish);
CV_RegisterVar(&cv_shownametagspectator);
CV_RegisterVar(&cv_driftgauge);
CV_RegisterVar(&cv_driftgaugeofs);
CV_RegisterVar(&cv_driftgaugetrans);
@@ -1675,25 +1638,9 @@ static void SendNameAndColor(void)
}
else if ((foundskin = R_SkinAvailable(cv_skin.string)) != -1)
{
//boolean notsame;
cv_skin.value = foundskin;
//notsame = (cv_skin.value != players[consoleplayer].skin);
SetPlayerSkin(consoleplayer, cv_skin.string);
CV_StealthSet(&cv_skin, skins[cv_skin.value].name);
// SRB2Kart
/*if (notsame)
{
CV_StealthSetValue(&cv_playercolor, skins[cv_skin.value].prefcolor);
players[consoleplayer].skincolor = (cv_playercolor.value&0x3F) % MAXSKINCOLORS;
if (players[consoleplayer].mo)
players[consoleplayer].mo->color = (UINT8)players[consoleplayer].skincolor;
}*/
}
else
{
@@ -1737,7 +1684,7 @@ static void SendNameAndColor(void)
WRITESTRINGN(p, cv_playername.zstring, MAXPLAYERNAME);
WRITEUINT8(p, (UINT8)cv_playercolor.value);
WRITEUINT8(p, (UINT8)cv_skin.value);
SendNetXCmd(XD_NAMEANDCOLOR, buf, p - buf);
SendNetXCmdForPlayer(0, XD_NAMEANDCOLOR, buf, p - buf);
}
// splitscreen
@@ -1807,24 +1754,8 @@ static void SendNameAndColor2(void)
if ((foundskin = R_SkinAvailable(cv_skin2.string)) != -1)
{
//boolean notsame;
cv_skin2.value = foundskin;
//notsame = (cv_skin2.value != players[secondplaya].skin);
SetPlayerSkin(secondplaya, cv_skin2.string);
// SRB2Kart
/*if (notsame)
{
CV_StealthSetValue(&cv_playercolor2, skins[players[secondplaya].skin].prefcolor);
players[secondplaya].skincolor = (cv_playercolor2.value&0x3F) % MAXSKINCOLORS;
if (players[secondplaya].mo)
players[secondplaya].mo->color = players[secondplaya].skincolor;
}*/
}
else
{
@@ -1867,7 +1798,7 @@ static void SendNameAndColor2(void)
WRITESTRINGN(p, cv_playername2.zstring, MAXPLAYERNAME);
WRITEUINT8(p, (UINT8)cv_playercolor2.value);
WRITEUINT8(p, (UINT8)cv_skin2.value);
SendNetXCmd2(XD_NAMEANDCOLOR, buf, p - buf);
SendNetXCmdForPlayer(1, XD_NAMEANDCOLOR, buf, p - buf);
}
static void SendNameAndColor3(void)
@@ -1988,7 +1919,7 @@ static void SendNameAndColor3(void)
WRITESTRINGN(p, cv_playername3.zstring, MAXPLAYERNAME);
WRITEUINT8(p, (UINT8)cv_playercolor3.value);
WRITEUINT8(p, (UINT8)cv_skin3.value);
SendNetXCmd3(XD_NAMEANDCOLOR, buf, p - buf);
SendNetXCmdForPlayer(2, XD_NAMEANDCOLOR, buf, p - buf);
}
static void SendNameAndColor4(void)
@@ -2057,24 +1988,8 @@ static void SendNameAndColor4(void)
if ((foundskin = R_SkinAvailable(cv_skin4.string)) != -1)
{
//boolean notsame;
cv_skin4.value = foundskin;
//notsame = (cv_skin4.value != players[fourthplaya].skin);
SetPlayerSkin(fourthplaya, cv_skin4.string);
// SRB2Kart
/*if (notsame)
{
CV_StealthSetValue(&cv_playercolor4, skins[players[fourthplaya].skin].prefcolor);
players[fourthplaya].skincolor = (cv_playercolor4.value&0x3F) % MAXSKINCOLORS;
if (players[fourthplaya].mo)
players[fourthplaya].mo->color = players[fourthplaya].skincolor;
}*/
}
else
{
@@ -2117,7 +2032,7 @@ static void SendNameAndColor4(void)
WRITESTRINGN(p, cv_playername4.zstring, MAXPLAYERNAME);
WRITEUINT8(p, (UINT8)cv_playercolor4.value);
WRITEUINT8(p, (UINT8)cv_skin4.value);
SendNetXCmd4(XD_NAMEANDCOLOR, buf, p - buf);
SendNetXCmdForPlayer(3, XD_NAMEANDCOLOR, buf, p - buf);
}
static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
@@ -2222,11 +2137,9 @@ void SendWeaponPref(void)
UINT8 buf[1];
buf[0] = 0;
if (cv_flipcam.value)
if (cv_flipcam[0].value)
buf[0] |= 1;
if (cv_analog.value)
buf[0] |= 2;
SendNetXCmd(XD_WEAPONPREF, buf, 1);
SendNetXCmdForPlayer(0, XD_WEAPONPREF, buf, 1);
}
void SendWeaponPref2(void)
@@ -2234,11 +2147,9 @@ void SendWeaponPref2(void)
UINT8 buf[1];
buf[0] = 0;
if (cv_flipcam2.value)
if (cv_flipcam[1].value)
buf[0] |= 1;
if (cv_analog2.value)
buf[0] |= 2;
SendNetXCmd2(XD_WEAPONPREF, buf, 1);
SendNetXCmdForPlayer(1, XD_WEAPONPREF, buf, 1);
}
void SendWeaponPref3(void)
@@ -2246,11 +2157,9 @@ void SendWeaponPref3(void)
UINT8 buf[1];
buf[0] = 0;
if (cv_flipcam3.value)
if (cv_flipcam[2].value)
buf[0] |= 1;
if (cv_analog3.value)
buf[0] |= 2;
SendNetXCmd3(XD_WEAPONPREF, buf, 1);
SendNetXCmdForPlayer(2, XD_WEAPONPREF, buf, 1);
}
void SendWeaponPref4(void)
@@ -2258,11 +2167,9 @@ void SendWeaponPref4(void)
UINT8 buf[1];
buf[0] = 0;
if (cv_flipcam4.value)
if (cv_flipcam[3].value)
buf[0] |= 1;
if (cv_analog4.value)
buf[0] |= 2;
SendNetXCmd4(XD_WEAPONPREF, buf, 1);
SendNetXCmdForPlayer(3, XD_WEAPONPREF, buf, 1);
}
static void Got_WeaponPref(UINT8 **cp,INT32 playernum)
@@ -2521,6 +2428,12 @@ static void Command_Playdemo_f(void)
return;
}
if (!demo.playback && gamestate == GS_LEVEL) // special case: allow starting another demo while watching a demo
{
CONS_Printf(M_GetText("You can't time a demo while in a game.\n"));
return;
}
// disconnect from server here?
if (demo.playback)
G_StopDemo();
@@ -2560,6 +2473,12 @@ static void Command_Timedemo_f(void)
return;
}
if (!demo.playback && gamestate == GS_LEVEL) // special case: allow starting another demo while watching a demo
{
CONS_Printf(M_GetText("You can't time a demo while in a game.\n"));
return;
}
// disconnect from server here?
if (demo.playback)
G_StopDemo();
@@ -2983,6 +2902,14 @@ static void Command_Map_f(void)
// G_TOLFlag handles both multiplayer gametype and ignores it for !multiplayer
else
{
if (!mapheaderinfo[newmapnum-1] || mapheaderinfo[newmapnum-1] == NULL)
{
CONS_Alert(CONS_WARNING, M_GetText("Invalid mapheaderinfo for Course %s (%s)\n"), realmapname, G_BuildMapName(newmapnum));
Z_Free(realmapname);
Z_Free(mapname);
return;
}
if (!(mapheaderinfo[newmapnum-1]->typeoflevel & G_TOLFlag(newgametype)))
{
CONS_Alert(CONS_WARNING, M_GetText("Course %s (%s) doesn't support %s mode!\n(Use -force to override)\n"), realmapname, G_BuildMapName(newmapnum),
@@ -3015,9 +2942,14 @@ static void Command_Map_f(void)
}
}
// spend atleast 35 seconds in one map
if (cv_demochangemap.value && demo.recording && demo.savemode != DSM_NOTSAVING && (timeinmap > 1463) && ((cv_demochangemap.value == 2 && newmapnum == gamemap) || newmapnum != gamemap))
G_SaveDemo();
if (cv_demochangemap.value && demo.recording)
{
// spend atleast 40 seconds in one map
if (demo.savemode != DSM_NOTSAVING && (timeinmap > (TICRATE * 40)) && ((cv_demochangemap.value == 2 && newmapnum == gamemap) || newmapnum != gamemap))
G_SaveDemo();
else
G_ResetDemoRecording();
}
fromlevelselect = false;
D_MapChange(newmapnum, newgametype, newencoremode, newresetplayers, 0, false, false);
@@ -3106,7 +3038,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
SetPlayerSkinByNum(0, cv_chooseskin.value-1);
//mapnumber = M_MapNumber(mapname[3], mapname[4]);
//LUAh_MapChange(mapnumber);
//LUA_HookInt(mapnumber, HOOK(MapChange));
demo.savemode = (cv_recordmultiplayerdemos.value == 2) ? DSM_WILLAUTOSAVE : DSM_NOTSAVING;
demo.savebutton = 0;
@@ -3466,7 +3398,7 @@ static void Command_Teamchange_f(void)
}
usvalue = SHORT(NetPacket.value.l|NetPacket.value.b);
SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
SendNetXCmdForPlayer(0, XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
}
static void Command_Teamchange2_f(void)
@@ -3557,7 +3489,7 @@ static void Command_Teamchange2_f(void)
}
usvalue = SHORT(NetPacket.value.l|NetPacket.value.b);
SendNetXCmd2(XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
SendNetXCmdForPlayer(1, XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
}
static void Command_Teamchange3_f(void)
@@ -3648,7 +3580,7 @@ static void Command_Teamchange3_f(void)
}
usvalue = SHORT(NetPacket.value.l|NetPacket.value.b);
SendNetXCmd3(XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
SendNetXCmdForPlayer(2, XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
}
static void Command_Teamchange4_f(void)
@@ -3739,7 +3671,7 @@ static void Command_Teamchange4_f(void)
}
usvalue = SHORT(NetPacket.value.l|NetPacket.value.b);
SendNetXCmd4(XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
SendNetXCmdForPlayer(3, XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
}
static void Command_ServerTeamChange_f(void)
@@ -4005,19 +3937,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum)
if (!players[playernum].spectator)
{
if (players[playernum].mo)
{
//if (!players[playernum].spectator)
P_DamageMobj(players[playernum].mo, NULL, NULL, 10000);
/*else
{
if (players[playernum].mo)
{
P_RemoveMobj(players[playernum].mo);
players[playernum].mo = NULL;
}
players[playernum].playerstate = PST_REBORN;
}*/
}
P_DamageMobj(players[playernum].mo, NULL, NULL, 10000);
else
players[playernum].playerstate = PST_REBORN;
}
@@ -4151,10 +4071,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum)
players[playernum].mo->health = 1;
}
// In tag, check to see if you still have a game.
/*if (G_TagGametype())
P_CheckSurvivors();
else*/ if (G_BattleGametype())
if (G_BattleGametype())
K_CheckBumpers(); // SRB2Kart
else if (G_RaceGametype())
P_CheckRacers(); // also SRB2Kart
@@ -4878,10 +4795,6 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum)
boolean kick = false;
boolean toomany = false;
INT32 i,j;
serverinfo_pak *dummycheck = NULL;
// Shut the compiler up.
(void)dummycheck;
READSTRINGN(*cp, filename, 240);
READMEM(*cp, md5sum, 16);
@@ -5009,6 +4922,151 @@ static void Command_ListWADS_f(void)
}
}
#define MAXDOOMEDNUM 4095
static void Command_ListDoomednums_f(void)
{
INT16 i, j, k = 0, l = 0;
INT32 argc = COM_Argc();
INT16 table[MAXDOOMEDNUM];
switch (argc)
{
case 1:
l = MAXDOOMEDNUM;
break;
case 3:
l = atoi(COM_Argv(2));
if (l < 1 || l > MAXDOOMEDNUM)
{
CONS_Printf("arg 2: doomednum \x82""%d \x85out of range (1-4095)\n", k);
return;
}
//FALLTHRU
case 2:
k = atoi(COM_Argv(1));
if (k < 1 || k > MAXDOOMEDNUM)
{
CONS_Printf("arg 1: doomednum \x82""%d \x85out of range (1-4095)\n", k);
return;
}
if (!l)
l = k;
else if (l < k) // silently and helpfully swap.
{
j = k;
k = l;
l = j;
}
break;
default:
CONS_Printf("listmapthings: \x86too many arguments!\n");
return;
}
// see P_SpawnNonMobjMapThing
memset(table, 0, sizeof(table));
for (i = 1; i <= MAXPLAYERS; i++)
table[i-1] = MT_PLAYER; // playerstarts
table[33-1] = table[34-1] = table[35-1] = MT_PLAYER; // battle/team starts
table[750-1] = table[777-1] = table[778-1] = MT_UNKNOWN; // slopes
for (i = 600; i <= 609; i++)
table[i-1] = MT_RING; // placement patterns
table[1705-1] = table[1713-1] = MT_HOOP; // types of hoop
CONS_Printf("\x82""Checking for double defines...\n");
for (i = 1; i < MT_FIRSTFREESLOT+NUMMOBJFREESLOTS; i++)
{
j = mobjinfo[i].doomednum;
if (j < (k ? k : 1) || j > (l ? l : MAXDOOMEDNUM))
continue;
if (table[j-1])
{
CONS_Printf(" doomednum \x82""%d""\x80 is \x85""double-defined\x80 by ", j);
if (i < MT_FIRSTFREESLOT)
{
CONS_Printf("\x87""hardcode %s <-- MAJOR ERROR\n", MOBJTYPE_LIST[i]);
continue;
}
CONS_Printf("\x81""freeslot MT_""%s\n", FREE_MOBJS[i-MT_FIRSTFREESLOT]);
continue;
}
table[j-1] = i;
}
CONS_Printf("\x82Printing doomednum usage...\n");
if (!k)
{
i = 35; // skip MT_PLAYER spam
CONS_Printf(" doomednums \x82""1-35""\x80 are used by ""\x87""hardcode MT_PLAYER\n");
}
else
i = k-1;
for (; i < l; i++)
{
if (!table[i])
{
if (k)
{
CONS_Printf(" doomednum \x82""%d""\x80 is \x83""free!", i+1);
if (i < 99) // above the humble crawla? how dare you
CONS_Printf(" (Don't freeslot this low...)");
CONS_Printf("\n");
}
continue;
}
CONS_Printf(" doomednum \x82""%d""\x80 is used by ", i+1);
if (table[i] < MT_FIRSTFREESLOT)
{
CONS_Printf("\x87""hardcode %s\n", MOBJTYPE_LIST[table[i]]);
continue;
}
CONS_Printf("\x81""freeslot MT_""%s\n", FREE_MOBJS[table[i]-MT_FIRSTFREESLOT]);
}
}
#undef MAXDOOMEDNUM
void Command_ListUnusedSprites_f(void)
{
size_t i, j;
CONS_Printf("\x82Printing sprite non-usage...\n");
for (i = 0; i < NUMSPRITES; i++)
{
if (sprites[i].numframes)
{
// We're only showing unused sprites...
continue;
}
if (i < SPR_FIRSTFREESLOT)
{
CONS_Printf(" \x87""hardcode SPR_""%.4s\n", sprnames[i]);
continue;
}
if (used_spr[(i-SPR_FIRSTFREESLOT)/8] == 0xFF)
{
for (j = 0; j < 8; j++)
{
CONS_Printf(" \x81""freeslot SPR_""%.4s\n", sprnames[i+j]);
}
i += j;
}
if (used_spr[(i-SPR_FIRSTFREESLOT)/8] & (1<<(i%8)))
{
CONS_Printf(" \x81""freeslot SPR_""%.4s\n", sprnames[i]);
continue;
}
break;
}
}
// =========================================================================
// MISC. COMMANDS
// =========================================================================
@@ -5298,9 +5356,6 @@ void D_GameTypeChanged(INT32 lastgametype)
else if (!multiplayer && !netgame)
{
gametype = GT_RACE; // SRB2kart
// These shouldn't matter anymore
//CV_Set(&cv_itemrespawntime, cv_itemrespawntime.defaultvalue);
//CV_SetValue(&cv_itemrespawn, 0);
}
// reset timelimit and pointlimit in race/coop, prevent stupid cheats
@@ -5322,19 +5377,6 @@ void D_GameTypeChanged(INT32 lastgametype)
}
}
// When swapping to a gametype that supports spectators,
// make everyone a spectator initially.
/*if (G_GametypeHasSpectators())
{
INT32 i;
for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i])
{
players[i].ctfteam = 0;
players[i].spectator = true;
}
}*/
// don't retain teams in other modes or between changes from ctf to team match.
// also, stop any and all forms of team scrambling that might otherwise take place.
if (G_GametypeHasTeams())
@@ -5785,10 +5827,6 @@ void Command_Retry_f(void)
CONS_Printf(M_GetText("You must be in a level to use this.\n"));
else if (netgame || multiplayer)
CONS_Printf(M_GetText("This only works in single player.\n"));
/*else if (!&players[consoleplayer] || players[consoleplayer].lives <= 1)
CONS_Printf(M_GetText("You can't retry without any lives remaining!\n"));
else if (G_IsSpecialStage(gamemap))
CONS_Printf(M_GetText("You can't retry special stages!\n"));*/
else
{
M_ClearMenus(true);
+2 -8
View File
@@ -43,18 +43,12 @@ extern consvar_t cv_seenames, cv_allowseenames;
extern consvar_t cv_usemouse;
//WTF
extern consvar_t cv_mouseturn;
extern consvar_t cv_usejoystick;
extern consvar_t cv_usejoystick2;
extern consvar_t cv_usejoystick3;
extern consvar_t cv_usejoystick4;
extern consvar_t cv_usejoystick[4]; //MAXSPLITSCREENPLAYERS
#ifdef LJOYSTICK
extern consvar_t cv_joyport;
extern consvar_t cv_joyport2;
#endif
extern consvar_t cv_joyscale;
extern consvar_t cv_joyscale2;
extern consvar_t cv_joyscale3;
extern consvar_t cv_joyscale4;
extern consvar_t cv_joyscale[4]; //MAXSPLITSCREENPLAYERS
// splitscreen with second mouse
extern consvar_t cv_mouse2port;
+2 -1
View File
@@ -403,7 +403,6 @@ typedef struct player_s
angle_t old_frameangle, old_frameangle2;
// SRB2Kart CEP: Sliptide rolling
INT32 sliptidemem;
angle_t sliproll;
INT16 lturn_max[MAXPREDICTTICS]; // What's the expected turn value for full-left for a number of frames back (to account for netgame latency)?
@@ -413,6 +412,8 @@ typedef struct player_s
// See pflags_t, above.
pflags_t pflags;
UINT16 postimgflags;
// playing animation.
panim_t panim;
+1
View File
@@ -49,6 +49,7 @@ typedef struct thinker_s
// killough 11/98: count of how many other objects reference
// this one using pointers. Used for garbage collection.
INT32 references;
boolean cachable;
} thinker_t;
#endif
+27 -26
View File
@@ -14,7 +14,6 @@
#include "d_main.h" // for srb2home
#include "g_game.h"
#include "sounds.h"
#include "info.h"
#include "d_think.h"
#include "m_argv.h"
#include "z_zone.h"
@@ -33,12 +32,12 @@
#include "r_sky.h"
#include "r_draw.h" // translation colormap consts (for lua)
#include "fastcmp.h"
#include "lua_script.h"
#include "lua_glib.h"
#include "lua_hook.h"
#include "d_clisrv.h"
#include "v_video.h" // video flags (for lua)
#include "lua_glib.h"
#include "lua_hook.h"
#include "lua_script.h"
#include "lua_libs.h"
@@ -48,13 +47,14 @@
// Free slot names
// The crazy word-reading stuff uses these.
static char *FREE_STATES[NUMSTATEFREESLOTS];
static char *FREE_MOBJS[NUMMOBJFREESLOTS];
static UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1]; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway.
char *FREE_STATES[NUMSTATEFREESLOTS];
char *FREE_MOBJS[NUMMOBJFREESLOTS];
UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1]; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway.
#define initfreeslots() {\
memset(FREE_STATES,0,sizeof(char *) * NUMSTATEFREESLOTS);\
memset(FREE_MOBJS,0,sizeof(char *) * NUMMOBJFREESLOTS);\
memset(used_spr,0,sizeof(UINT8) * ((NUMSPRITEFREESLOTS / 8) + 1));\
memset(FREE_STATES,0,sizeof(char *) * NUMSTATEFREESLOTS);\
memset(FREE_MOBJS,0,sizeof(char *) * NUMMOBJFREESLOTS);\
memset(used_spr,0,sizeof(UINT8) * ((NUMSPRITEFREESLOTS / 8) + 1));\
}
// Crazy word-reading stuff
@@ -1493,9 +1493,6 @@ actionpointer_t actionpointers[] =
{{A_SpawnObjectRelative}, "A_SPAWNOBJECTRELATIVE"},
{{A_ChangeAngleRelative}, "A_CHANGEANGLERELATIVE"},
{{A_ChangeAngleAbsolute}, "A_CHANGEANGLEABSOLUTE"},
{{A_RollAngle}, "A_ROLLANGLE"},
{{A_ChangeRollAngleRelative},"A_CHANGEROLLANGLERELATIVE"},
{{A_ChangeRollAngleAbsolute},"A_CHANGEROLLANGLEABSOLUTE"},
{{A_PlaySound}, "A_PLAYSOUND"},
{{A_FindTarget}, "A_FINDTARGET"},
{{A_FindTracer}, "A_FINDTRACER"},
@@ -3150,7 +3147,7 @@ void DEH_LoadDehackedLump(lumpnum_t lumpnum)
// RegEx to generate this from info.h: ^\tS_([^,]+), --> \t"S_\1",
// I am leaving the prefixes solely for clarity to programmers,
// because sadly no one remembers this place while searching for full state names.
static const char *const STATE_LIST[] = { // array length left dynamic for sanity testing later.
const char *const STATE_LIST[] = { // array length left dynamic for sanity testing later.
"S_NULL",
"S_UNKNOWN",
"S_INVISIBLE", // state for invisible sprite
@@ -6364,7 +6361,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit
// RegEx to generate this from info.h: ^\tMT_([^,]+), --> \t"MT_\1",
// I am leaving the prefixes solely for clarity to programmers,
// because sadly no one remembers this place while searching for full state names.
static const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity testing later.
const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity testing later.
"MT_NULL",
"MT_UNKNOWN",
@@ -7155,7 +7152,7 @@ static const char *const MOBJTYPE_LIST[] = { // array length left dynamic for s
#endif
};
static const char *const MOBJFLAG_LIST[] = {
const char *const MOBJFLAG_LIST[] = {
"SPECIAL",
"SOLID",
"SHOOTABLE",
@@ -7191,7 +7188,7 @@ static const char *const MOBJFLAG_LIST[] = {
};
// \tMF2_(\S+).*// (.+) --> \t"\1", // \2
static const char *const MOBJFLAG2_LIST[] = {
const char *const MOBJFLAG2_LIST[] = {
"AXIS", // It's a NiGHTS axis! (For faster checking)
"TWOD", // Moves like it's in a 2D level
"DONTRESPAWN", // Don't respawn this object!
@@ -7224,7 +7221,7 @@ static const char *const MOBJFLAG2_LIST[] = {
NULL
};
static const char *const MOBJEFLAG_LIST[] = {
const char *const MOBJEFLAG_LIST[] = {
"ONGROUND", // The mobj stands on solid floor (not on another mobj or in air)
"JUSTHITFLOOR", // The mobj just hit the floor while falling, this is cleared on next frame
"TOUCHWATER", // The mobj stands in a sector with water, and touches the surface
@@ -7242,14 +7239,14 @@ static const char *const MOBJEFLAG_LIST[] = {
NULL
};
static const char *const MAPTHINGFLAG_LIST[4] = {
const char *const MAPTHINGFLAG_LIST[4] = {
NULL,
"OBJECTFLIP", // Reverse gravity flag for objects.
"OBJECTSPECIAL", // Special flag used with certain objects.
"AMBUSH" // Deaf monsters/do not react to sound.
};
static const char *const PLAYERFLAG_LIST[] = {
const char *const PLAYERFLAG_LIST[] = {
// Flip camera angle with gravity flip prefrence.
"FLIPCAM",
@@ -7321,7 +7318,7 @@ static const char *const PLAYERFLAG_LIST[] = {
};
// Linedef flags
static const char *const ML_LIST[16] = {
const char *const ML_LIST[16] = {
"IMPASSIBLE",
"BLOCKMONSTERS",
"TWOSIDED",
@@ -7342,7 +7339,7 @@ static const char *const ML_LIST[16] = {
// This DOES differ from r_draw's Color_Names, unfortunately.
// Also includes Super colors
static const char *COLOR_ENUMS[] = { // Rejigged for Kart.
const char *COLOR_ENUMS[] = { // Rejigged for Kart.
"NONE", // SKINCOLOR_NONE
"WHITE", // SKINCOLOR_WHITE
"SILVER", // SKINCOLOR_SILVER
@@ -7510,7 +7507,7 @@ static const char *COLOR_ENUMS[] = { // Rejigged for Kart.
"CSUPER5" // SKINCOLOR_CSUPER5,
};
static const char *const POWERS_LIST[] = {
const char *const POWERS_LIST[] = {
"INVULNERABILITY",
"SNEAKERS",
"FLASHING",
@@ -7545,7 +7542,7 @@ static const char *const POWERS_LIST[] = {
"INGOOP" // In goop
};
static const char *const KARTSTUFF_LIST[] = {
const char *const KARTSTUFF_LIST[] = {
"POSITION",
"OLDPOSITION",
"POSITIONDELAY",
@@ -7632,7 +7629,7 @@ static const char *const KARTSTUFF_LIST[] = {
"GROWCANCEL"
};
static const char *const HUDITEMS_LIST[] = {
const char *const HUDITEMS_LIST[] = {
"LIVESNAME",
"LIVESPIC",
"LIVESNUM",
@@ -9149,7 +9146,6 @@ int LUA_EnumLib(lua_State *L)
PUSHGETTER(globalweather, u8);
PUSHGETTER(levelskynum, i32);
PUSHGETTER(globallevelskynum, i32);
PUSHGETTER((*mapmusname), str);
PUSHGETTER(mapmusflags, u16);
PUSHGETTER(mapmusposition, u32);
PUSHGETTER(gravity, fxp);
@@ -9166,6 +9162,11 @@ int LUA_EnumLib(lua_State *L)
PUSHGETTER(racecountdown, u32);
PUSHGETTER(exitcountdown, u32);
lua_pushcfunction(L, lua_glib_new_getter);
lua_pushliteral(L, "mapmusname");
lua_glib_push_str_getter(L, mapmusname);
lua_call(L, 2, 0);
lua_pushcfunction(L, lua_glib_new_getter);
lua_pushliteral(L, "mariomode");
lua_pushcfunction(L, lua_enumlib_mariomode_get);
+20
View File
@@ -14,6 +14,26 @@
#define __DEHACKED_H__
#include "m_fixed.h" // for get_number
#include "info.h"
// Free slot names
// The crazy word-reading stuff uses these.
extern char *FREE_STATES[NUMSTATEFREESLOTS];
extern char *FREE_MOBJS[NUMMOBJFREESLOTS];
extern UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1]; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway.
extern const char *const STATE_LIST[];
extern const char *const MOBJTYPE_LIST[];
extern const char *const MOBJFLAG_LIST[];
extern const char *const MOBJFLAG2_LIST[]; // \tMF2_(\S+).*// (.+) --> \t"\1", // \2
extern const char *const MOBJEFLAG_LIST[];
extern const char *const MAPTHINGFLAG_LIST[4];
extern const char *const PLAYERFLAG_LIST[];
extern const char *const ML_LIST[]; // Linedef flags
extern const char *COLOR_ENUMS[];
extern const char *const POWERS_LIST[];
extern const char *const KARTSTUFF_LIST[];
extern const char *const HUDITEMS_LIST[];
void DEH_LoadDehackedLump(lumpnum_t lumpnum);
void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump);
+18 -2
View File
@@ -127,8 +127,8 @@ extern char logfilename[1024];
#else
#define VERSION 1 // Game version
#define SUBVERSION 6 // more precise version number
#define VERSIONSTRING "Saturn v7.1"
#define VERSIONSTRINGW L"Saturn v7.1"
#define VERSIONSTRING "Saturn v7.2"
#define VERSIONSTRINGW L"Saturn v7.2"
// Hey! If you change this, add 1 to the MODVERSION below! Otherwise we can't force updates!
// And change CMakeLists.txt (not src/, but in root), for CMake users!
// AND appveyor.yml, for the build bots!
@@ -522,6 +522,22 @@ extern boolean capslock;
// i_system.c, replace getchar() once the keyboard has been appropriated
INT32 I_GetKey(void);
/* http://www.cse.yorku.ca/~oz/hash.html */
static inline
UINT32 quickncasehash (const char *p, size_t n)
{
size_t i = 0;
UINT32 x = 5381;
while (i < n && p[i])
{
x = (x * 33) ^ tolower(p[i]);
i++;
}
return x;
}
#ifndef min // Double-Check with WATTCP-32's cdefs.h
#define min(x, y) (((x) < (y)) ? (x) : (y))
#endif
-1
View File
@@ -112,7 +112,6 @@ extern UINT8 window_notinfocus; // are we in focus? (backend independant -- hand
extern boolean nodrawers;
extern boolean noblit;
extern boolean lastdraw;
extern postimg_t postimgtype[MAXSPLITSCREENPLAYERS];
extern INT32 postimgparam[MAXSPLITSCREENPLAYERS];
extern INT32 viewwindowx, viewwindowy;
+30 -8
View File
@@ -344,14 +344,12 @@ typedef union FColorRGBA RGBA_t;
typedef enum
{
postimg_none,
postimg_water,
postimg_motion,
postimg_flip,
postimg_heat,
postimg_mirror,
postimg_mirrorflip
} postimg_t;
POSTIMG_WATER = 1, // Underwater screen effect.
POSTIMG_MOTION = 1<<1, // Unused motion blur effect.
POSTIMG_FLIP = 1<<2, // Flipcam screen effect.
POSTIMG_HEAT = 1<<3, // Heatwave screen effect.
POSTIMG_MIRROR = 1<<4, // encore screen effect.
} postimgflag_t;
typedef UINT32 lumpnum_t; // 16 : 16 unsigned long (wad num: lump num)
#define LUMPERROR UINT32_MAX
@@ -367,6 +365,30 @@ typedef UINT32 tic_t;
#define UINT2RGBA(a) (UINT32)((a&0xff)<<24)|((a&0xff00)<<8)|((a&0xff0000)>>8)|(((UINT32)a&0xff000000)>>24)
#endif
#define TOSTR(x) #x
typedef UINT8 bitarray_t;
#define BIT_ARRAY_SIZE(n) (((n) + 7) >> 3)
static inline int
in_bit_array (const bitarray_t * const array, const int value)
{
return (array[value >> 3] & (1<<(value & 7)));
}
static inline void
set_bit_array (bitarray_t * const array, const int value)
{
array[value >> 3] |= (1<<(value & 7));
}
static inline void
unset_bit_array (bitarray_t * const array, const int value)
{
array[value >> 3] &= ~(1<<(value & 7));
}
typedef UINT64 precise_t;
#endif //__DOOMTYPE__
+6 -5
View File
@@ -327,7 +327,8 @@ char menupath[1024];
size_t menupathindex[menudepth];
size_t menudepthleft = menudepth;
char menusearch[MAXSTRINGLENGTH+1];
char menusearchbuf[MAXSTRINGLENGTH+1];
textinput_t menusearch;
char **dirmenu, **coredirmenu; // core only local for this file
size_t sizedirmenu, sizecoredirmenu; // ditto
@@ -497,7 +498,7 @@ static boolean filemenucmp(char *haystack, char *needle)
strupr(localhaystack);
if (cv_addons_search_type.value)
return (strstr(localhaystack, needle) != 0);
return (!strncmp(localhaystack, needle, menusearch[0]));
return (!strncmp(localhaystack, needle, menusearch.length));
}
void closefilemenu(boolean validsize)
@@ -563,7 +564,7 @@ void searchfilemenu(char *tempname)
first = (((UINT8)(coredirmenu[0][DIR_TYPE]) == EXT_UP) ? 1 : 0); // skip UP...
if (!menusearch[0])
if (!menusearch.length)
{
if (dirmenu)
Z_Free(dirmenu);
@@ -590,7 +591,7 @@ void searchfilemenu(char *tempname)
return;
}
strcpy(localmenusearch, menusearch+1);
strcpy(localmenusearch, menusearch.buffer);
if (!cv_addons_search_case.value)
strupr(localmenusearch);
@@ -652,7 +653,7 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut)
tempname = Z_StrDup(dirmenu[dir_on[menudepthleft]]+DIR_STRING); // don't need to I_Error if can't make - not important, just QoL
}
else
menusearch[0] = menusearch[1] = 0; // clear search
M_TextInputInit(&menusearch, menusearchbuf, MAXSTRINGLENGTH+1);
if (!(dirhandle = opendir(menupath))) // get directory
{
+3 -1
View File
@@ -7,6 +7,7 @@
#include "doomdef.h"
#include "d_netfil.h"
#include "m_menu.h" // MAXSTRINGLENGTH
#include "m_textinput.h"
extern consvar_t cv_addons_option, cv_addons_folder, cv_addons_md5, cv_addons_showall, cv_addons_search_case, cv_addons_search_type;
@@ -34,7 +35,8 @@ extern char menupath[1024];
extern size_t menupathindex[menudepth];
extern size_t menudepthleft;
extern char menusearch[MAXSTRINGLENGTH+1];
extern char menusearchbuf[MAXSTRINGLENGTH+1];
extern textinput_t menusearch;
extern char **dirmenu;
extern size_t sizedirmenu;
+250 -583
View File
File diff suppressed because it is too large. Load diff
+16 -8
View File
@@ -121,12 +121,21 @@ extern consvar_t cv_pauseifunfocused;
//extern consvar_t cv_crosshair, cv_crosshair2, cv_crosshair3, cv_crosshair4;
extern consvar_t cv_invertmouse/*, cv_alwaysfreelook, cv_chasefreelook, cv_mousemove*/;
extern consvar_t cv_invertmouse2/*, cv_alwaysfreelook2, cv_chasefreelook2, cv_mousemove2*/;
extern consvar_t cv_useranalog, cv_useranalog2, cv_useranalog3, cv_useranalog4;
extern consvar_t cv_analog, cv_analog2, cv_analog3, cv_analog4;
extern consvar_t cv_turnaxis,cv_moveaxis,cv_brakeaxis,cv_aimaxis,cv_lookaxis,cv_fireaxis,cv_driftaxis,cv_lookbackaxis,cv_custom1axis,cv_custom2axis,cv_custom3axis,cv_xdeadzone,cv_ydeadzone;
extern consvar_t cv_turnaxis2,cv_moveaxis2,cv_brakeaxis2,cv_aimaxis2,cv_lookaxis2,cv_fireaxis2,cv_driftaxis2,cv_lookbackaxis2,cv_custom1axis2,cv_custom2axis2,cv_custom3axis2,cv_xdeadzone2,cv_ydeadzone2;
extern consvar_t cv_turnaxis3,cv_moveaxis3,cv_brakeaxis3,cv_aimaxis3,cv_lookaxis3,cv_fireaxis3,cv_driftaxis3,cv_lookbackaxis3,cv_custom1axis3,cv_custom2axis3,cv_custom3axis3,cv_xdeadzone3,cv_ydeadzone3;
extern consvar_t cv_turnaxis4,cv_moveaxis4,cv_brakeaxis4,cv_aimaxis4,cv_lookaxis4,cv_fireaxis4,cv_driftaxis4,cv_lookbackaxis4,cv_custom1axis4,cv_custom2axis4,cv_custom3axis4,cv_xdeadzone4,cv_ydeadzone4;
extern consvar_t cv_turnaxis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_moveaxis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_brakeaxis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_aimaxis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_lookaxis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_lookbackaxis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_fireaxis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_driftaxis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_custom1axis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_custom2axis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_custom3axis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_xdeadzone[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_ydeadzone[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_guest, cv_ghost_staff;
// Hud offsets
@@ -167,7 +176,6 @@ extern consvar_t cv_saltysquish;
extern consvar_t cv_driftsparkpulse;
extern consvar_t cv_gravstretch;
extern consvar_t cv_sloperoll;
extern consvar_t cv_spriteroll;
extern consvar_t cv_sliptideroll;
extern consvar_t cv_slamsound;
extern consvar_t cv_sloperolldist;
@@ -267,7 +275,6 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost);
// A normal game starts at map 1, but a warp test can start elsewhere
void G_DeferedInitNew(boolean pencoremode, const char *mapname, INT32 pickedchar,
UINT8 ssplayers, boolean FLS);
void G_DoLoadLevel(boolean resetplayer);
void G_LoadDemoInfo(menudemo_t *pdemo);
void G_LoadDemoTitle(menudemo_t *pdemo); // For use in replay search feature
@@ -357,6 +364,7 @@ extern demoghost *ghosts;
#define DFILE_ERROR_CANNOTLOAD 0x04 // Files are missing and cannot be loaded.
#define DFILE_ERROR_EXTRAFILES 0x05 // Extra files outside of the replay's file list are loaded.
void G_ResetDemoRecording(void);
void G_DoPlayDemo(char *defdemoname);
void G_TimeDemo(const char *name);
void G_AddGhost(char *defdemoname);
+5 -27
View File
@@ -908,28 +908,6 @@ static const char *gamecontrolname[num_gamecontrols] =
#include "k_kart.h"
INT32 G_GetDeviceForPlayer(INT32 player)
{
switch (player)
{
case 0:
return cv_usejoystick.value;
break;
case 1:
return cv_usejoystick2.value;
break;
case 2:
return cv_usejoystick3.value;
break;
case 3:
return cv_usejoystick4.value;
break;
default:
return 0;
break;
}
}
inline UINT16 G_GetSkinColor(INT32 player)
{
// make rgb rainbow vomit when invul or flash blue when grow
@@ -972,7 +950,7 @@ void G_SetPlayerGamepadIndicatorColor(INT32 player, UINT16 color)
if (cv_gamepadled[player].value == 0)
return;
device = G_GetDeviceForPlayer(player);
device = cv_usejoystick[player].value;
if (device <= 0)
{
@@ -989,7 +967,7 @@ static void G_ResetPlayerGamepadIndicatorColor(INT32 player)
{
if (cv_gamepadled[player].value == 0)
{
INT32 device = G_GetDeviceForPlayer(player);
INT32 device = cv_usejoystick[player].value;
if (device <= 0)
return;
@@ -1003,7 +981,7 @@ static void G_ResetPlayerDeviceRumble(INT32 player)
{
INT32 device_id;
device_id = G_GetDeviceForPlayer(player);
device_id = cv_usejoystick[player].value;
if (device_id < 1)
{
@@ -1022,7 +1000,7 @@ void G_ResetAllDeviceRumbles(void)
for (i = 0; i < devices; i++)
{
INT32 device_id = G_GetDeviceForPlayer(i);
INT32 device_id = cv_usejoystick[i].value;
I_GamepadRumble(device_id, 0, 0, 0);
}
@@ -1037,7 +1015,7 @@ void G_PlayerDeviceRumble(INT32 player, UINT16 low_strength, UINT16 high_strengt
return;
}
device_id = G_GetDeviceForPlayer(player);
device_id = cv_usejoystick[player].value;
if (device_id < 1)
{
+35 -32
View File
@@ -15,8 +15,9 @@
#include "hw_main.h"
#include "../i_system.h"
#include "../qs22j.h"
#include "../doomdef.h"
#include "../qs22j.h"
// The texture for the next polygon given to HWR_ProcessPolygon.
// Set with HWR_SetCurrentTexture.
@@ -46,12 +47,12 @@ int unsortedVertexArrayAllocSize = 65536;
// Call HWR_RenderBatches to render all the collected geometry.
void HWR_StartBatching(void)
{
if (currently_batching)
if (currently_batching)
{
I_Error("Repeat call to HWR_StartBatching without HWR_RenderBatches");
I_Error("Repeat call to HWR_StartBatching without HWR_RenderBatches");
}
// init arrays if that has not been done yet
// init arrays if that has not been done yet
if (!finalVertexArray)
{
finalVertexArray = malloc(finalVertexArrayAllocSize * sizeof(FOutVector));
@@ -61,22 +62,22 @@ void HWR_StartBatching(void)
unsortedVertexArray = malloc(unsortedVertexArrayAllocSize * sizeof(FOutVector));
}
currently_batching = true;
currently_batching = true;
}
// This replaces the direct calls to pfnSetTexture in cases where batching is available.
// This replaces the direct calls to GL_SetTexture in cases where batching is available.
// The texture selection is saved for the next HWR_ProcessPolygon call.
// Doing this was easier than getting a texture pointer to HWR_ProcessPolygon.
void HWR_SetCurrentTexture(GLMipmap_t *texture)
{
if (currently_batching)
{
current_texture = texture;
}
else
{
HWD.pfnSetTexture(texture);
}
if (currently_batching)
{
current_texture = texture;
}
else
{
GL_SetTexture(texture);
}
}
// If batching is enabled, this function collects the polygon data and the chosen texture
@@ -84,7 +85,7 @@ void HWR_SetCurrentTexture(GLMipmap_t *texture)
// render the polygon immediately.
void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, int shader_target, boolean horizonSpecial)
{
if (currently_batching)
if (currently_batching)
{
if (!pSurf)
I_Error("Got a null FSurfaceInfo in batching");// nulls should not come in the stuff that batching currently applies to
@@ -129,8 +130,8 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt
}
else
{
HWD.pfnSetShader((shader_target != SHADER_NONE) ? HWR_GetShaderFromTarget(shader_target) : shader_target);
HWD.pfnDrawPolygon(pSurf, pOutVerts, iNumPts, PolyFlags);
GL_SetShader((shader_target != SHADER_NONE) ? HWR_GetShaderFromTarget(shader_target) : shader_target);
GL_DrawPolygon(pSurf, pOutVerts, iNumPts, PolyFlags);
}
}
@@ -220,14 +221,14 @@ static int comparePolygonsNoShaders(const void *p1, const void *p2)
// the rendering backend to draw them.
void HWR_RenderBatches(void)
{
int finalVertexWritePos = 0;// position in finalVertexArray
int finalVertexWritePos = 0;// position in finalVertexArray
int finalIndexWritePos = 0;// position in finalVertexIndexArray
int polygonReadPos = 0;// position in polygonArraySorted
int currentShader;
int nextShader = 0;
GLMipmap_t *currentTexture;
GLMipmap_t *currentTexture = NULL;
GLMipmap_t *nextTexture = NULL;
FBITFIELD currentPolyFlags = 0;
FBITFIELD nextPolyFlags = 0;
@@ -236,7 +237,7 @@ void HWR_RenderBatches(void)
int i;
if (!currently_batching)
if (!currently_batching)
I_Error("HWR_RenderBatches called without starting batching");
nextSurfaceInfo.LightInfo.fade_end = 0;
@@ -256,6 +257,7 @@ void HWR_RenderBatches(void)
ps_hw_numcalls.value.i = ps_hw_numverts.value.i = 0;
ps_hw_numshaders.value.i = ps_hw_numtextures.value.i
= ps_hw_numpolyflags.value.i = ps_hw_numcolors.value.i = 1;
// init polygonArraySorted
for (i = 0; i < polygonArraySize; i++)
{
@@ -264,11 +266,12 @@ void HWR_RenderBatches(void)
// sort polygons
PS_START_TIMING(ps_hw_batchsorttime);
if (cv_grshaders.value && gr_shadersavailable)
if (cv_glshaders.value && gl_shadersavailable)
qs22j(polygonArraySorted, polygonArraySize, sizeof(PolygonArrayEntry *), comparePolygons);
else
qs22j(polygonArraySorted, polygonArraySize, sizeof(PolygonArrayEntry *), comparePolygonsNoShaders);
PS_STOP_TIMING(ps_hw_batchsorttime);
// sort order
// 1. shader
// 2. texture
@@ -287,15 +290,15 @@ void HWR_RenderBatches(void)
// set state for first batch
if (cv_grshaders.value && gr_shadersavailable)
if (cv_glshaders.value && gl_shadersavailable)
{
HWD.pfnSetShader(currentShader);
GL_SetShader(currentShader);
}
if (currentPolyFlags & PF_NoTexture)
currentTexture = NULL;
else
HWD.pfnSetTexture(currentTexture);
else
GL_SetTexture(currentTexture);
while (1)// note: remember handling notexture polyflag as having texture number 0 (also in comparePolygons)
{
@@ -369,7 +372,7 @@ void HWR_RenderBatches(void)
nextSurfaceInfo = nextEntry->surf;
if (nextPolyFlags & PF_NoTexture)
nextTexture = 0;
if (currentShader != nextShader && cv_grshaders.value && gr_shadersavailable)
if (currentShader != nextShader && cv_glshaders.value && gl_shadersavailable)
{
changeState = true;
changeShader = true;
@@ -384,7 +387,7 @@ void HWR_RenderBatches(void)
changeState = true;
changePolyFlags = true;
}
if (cv_grshaders.value && gr_shadersavailable)
if (cv_glshaders.value && gl_shadersavailable)
{
if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba ||
currentSurfaceInfo.TintColor.rgba != nextSurfaceInfo.TintColor.rgba ||
@@ -410,7 +413,7 @@ void HWR_RenderBatches(void)
if (changeState || stopFlag)
{
// execute draw call
HWD.pfnDrawIndexedTriangles(&currentSurfaceInfo, finalVertexArray, finalIndexWritePos, currentPolyFlags, finalVertexIndexArray);
GL_DrawIndexedTriangles(&currentSurfaceInfo, finalVertexArray, finalIndexWritePos, currentPolyFlags, finalVertexIndexArray);
// update stats
ps_hw_numcalls.value.i++;
ps_hw_numverts.value.i += finalIndexWritePos;
@@ -428,7 +431,7 @@ void HWR_RenderBatches(void)
{
if (changeShader)
{
HWD.pfnSetShader(nextShader);
GL_SetShader(nextShader);
currentShader = nextShader;
changeShader = false;
@@ -436,8 +439,8 @@ void HWR_RenderBatches(void)
}
if (changeTexture)
{
// texture should be already ready for use from calls to SetTexture during batch collection
HWD.pfnSetTexture(nextTexture);
// texture should be already ready for use from calls to GL_SetTexture during batch collection
GL_SetTexture(nextTexture);
currentTexture = nextTexture;
changeTexture = false;
@@ -457,6 +460,7 @@ void HWR_RenderBatches(void)
ps_hw_numcolors.value.i++;
}
// and that should be it?
}
}
// reset the arrays (set sizes to 0)
@@ -466,5 +470,4 @@ void HWR_RenderBatches(void)
PS_STOP_TIMING(ps_hw_batchdrawtime);
}
#endif // HWRENDER
+3 -1
View File
@@ -15,7 +15,9 @@
#include "hw_defs.h"
#include "hw_data.h"
#include "hw_drv.h"
#include "hw_gl.h"
extern boolean currently_batching;
typedef struct
{
+8 -8
View File
@@ -46,7 +46,7 @@ typedef struct
// when loading the map, this is set to true if portals are found.
// if no portals are found, the portal scanning phase can be skipped while rendering, saving a bit of time.
boolean gr_maphasportals = false;
boolean gl_maphasportals = false;
// ==========================================================================
// FLOOR & CEILING CONVEX POLYS GENERATION
@@ -371,14 +371,14 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 count, poly_t *poly)
line_t *line = lseg->linedef;
// portal check
if (!gr_maphasportals && line->special == 40 && lseg->side == 0)
if (!gl_maphasportals && line->special == 40 && lseg->side == 0)
{
// Find the other side!
INT32 line2 = P_FindSpecialLineFromTag(40, line->tag, -1);
if (line == &lines[line2])
line2 = P_FindSpecialLineFromTag(40, line->tag, line2);
if (line2 >= 0) // found it!
gr_maphasportals = 1;
gl_maphasportals = 1;
}
p1.x = FIXED_TO_FLOAT(lseg->side ? line->v2->x : line->v1->x);
@@ -768,7 +768,7 @@ static INT32 SolveTProblem(void)
INT32 i;
size_t l;
if (cv_grsolvetjoin.value == 0)
if (cv_glsolvetjoin.value == 0)
return 0;
CONS_Debug(DBG_RENDER, "Solving T-joins. This may take a while. Please wait...\n");
@@ -905,7 +905,7 @@ void HWR_CreatePlanePolygons(INT32 bspnum)
#endif
// reset the portal flag
gr_maphasportals = 0;
gl_maphasportals = 0;
// find min/max boundaries of map
//CONS_Debug(DBG_RENDER, "Looking for boundaries of map...\n");
@@ -923,9 +923,9 @@ void HWR_CreatePlanePolygons(INT32 bspnum)
I_Error("couldn't malloc extrasubsectors totsubsectors %s\n", sizeu1(totsubsectors));
// allocate table for back to front drawing of subsectors
/*gr_drawsubsectors = (INT16 *)malloc(sizeof (*gr_drawsubsectors) * totsubsectors);
if (!gr_drawsubsectors)
I_Error("couldn't malloc gr_drawsubsectors\n");*/
/*gl_drawsubsectors = (INT16 *)malloc(sizeof (*gl_drawsubsectors) * totsubsectors);
if (!gl_drawsubsectors)
I_Error("couldn't malloc gl_drawsubsectors\n");*/
// number of the first new subsector that might be added
addsubsector = numsubsectors;
+189 -184
View File
@@ -14,9 +14,10 @@
#include "../doomdef.h"
#ifdef HWRENDER
#include "hw_main.h"
#include "hw_glob.h"
#include "hw_drv.h"
#include "hw_gl.h"
#include "hw_batching.h"
#include "../doomstat.h" //gamemode
@@ -54,10 +55,10 @@ static INT32 format2bpp(GLTextureFormat_t format)
// It is now split from it for my sanity! (and the sanity of others)
// -- Monster Iestyn (13/02/19)
static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipmap_t *mipmap,
INT32 pblockheight, INT32 blockmodulo,
fixed_t yfracstep, fixed_t scale_y,
texpatch_t *originPatch, INT32 patchheight,
INT32 bpp, RGBA_t *palette)
INT32 pblockheight, INT32 blockmodulo,
fixed_t yfracstep, fixed_t scale_y,
texpatch_t *originPatch, INT32 patchheight,
INT32 bpp, RGBA_t *palette)
{
fixed_t yfrac, position, count;
UINT8 *dest;
@@ -73,6 +74,9 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm
(void)patchheight; // This parameter is unused
if (!mipmap)
return;
if (originPatch) // originPatch can be NULL here, unlike in the software version
originy = originPatch->originy;
@@ -108,14 +112,14 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm
count--;
texel = source[yfrac>>FRACBITS];
alpha = 0xff;
alpha = 0xFF;
//Hurdler: not perfect, but better than holes
if (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX && (mipmap->flags & TF_CHROMAKEYED))
// Make pixel transparent if chroma keyed
if ((mipmap && mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX))
alpha = 0x00;
//Hurdler: 25/04/2000: now support colormap in hardware mode
if (mipmap->colormap)
if (mipmap && mipmap->colormap)
texel = mipmap->colormap[texel];
// hope compiler will get this switch out of the loops (dreams...)
@@ -123,7 +127,8 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm
// Alam: SRB2 uses Mingw, HUGS
switch (bpp)
{
case 2 : texelu16 = (UINT16)((alpha<<8) | texel);
case 2 : // uhhhhhhhh..........
texelu16 = (UINT16)((alpha<<8) | texel);
memcpy(dest, &texelu16, sizeof(UINT16));
break;
case 3 : colortemp = palette[texel];
@@ -141,6 +146,7 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm
dest += blockmodulo;
yfrac += yfracstep;
}
patchcol = (const column_t *)((const UINT8 *)patchcol + patchcol->length + 4);
}
}
@@ -166,7 +172,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap,
if (pwidth <= 0 || pheight <= 0)
return;
palette = HWR_GetTexturePalette();
ncols = pwidth;
@@ -182,6 +188,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap,
if (bpp < 1 || bpp > 4)
I_Error("HWR_DrawPatchInCache: no drawer defined for this bpp (%d)\n",bpp);
// NOTE: should this actually be pblockwidth*bpp?
blockmodulo = pblockwidth*bpp;
// Draw each column to the block cache
@@ -216,7 +223,7 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
if (texture->width <= 0 || texture->height <= 0)
return;
palette = HWR_GetTexturePalette();
x1 = patch->originx;
@@ -260,6 +267,7 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
if (bpp < 1 || bpp > 4)
I_Error("HWR_DrawTexturePatchInCache: no drawer defined for this bpp (%d)\n",bpp);
// NOTE: should this actually be pblockwidth*bpp?
blockmodulo = pblockwidth*bpp;
// Draw each column to the block cache
@@ -275,15 +283,15 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
}
}
static UINT8 *MakeBlock(GLMipmap_t *grMipmap)
static UINT8 *MakeBlock(GLMipmap_t *glMipmap)
{
UINT8 *block;
INT32 bpp, i;
UINT16 bu16 = ((0x00 <<8) | HWR_PATCHES_CHROMAKEY_COLORINDEX);
INT32 blocksize = (grMipmap->width * grMipmap->height);
INT32 blocksize = (glMipmap->width * glMipmap->height);
bpp = format2bpp(grMipmap->format);
block = Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(grMipmap->data));
bpp = format2bpp(glMipmap->format);
block = Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(glMipmap->data));
switch (bpp)
{
@@ -303,7 +311,7 @@ static UINT8 *MakeBlock(GLMipmap_t *grMipmap)
// Create a composite texture from patches, adapt the texture size to a power of 2
// height and width for the hardware texture cache.
//
static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex, boolean noencore)
static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noencore)
{
UINT8 *block;
texture_t *texture;
@@ -313,7 +321,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex, boolean noe
INT32 i;
boolean skyspecial = false; //poor hack for Legacy large skies..
RGBA_t *palette;
palette = HWR_GetTexturePalette();
@@ -328,30 +336,30 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex, boolean noe
)
{
skyspecial = true;
grtex->mipmap.flags = TF_WRAPXY; // don't use the chromakey for sky
gltex->mipmap.flags = TF_WRAPXY; // don't use the chromakey for sky
}
else
grtex->mipmap.flags = TF_CHROMAKEYED | TF_WRAPXY;
gltex->mipmap.flags = TF_CHROMAKEYED | TF_WRAPXY;
grtex->mipmap.width = (UINT16)texture->width;
grtex->mipmap.height = (UINT16)texture->height;
gltex->mipmap.width = (UINT16)(texture->width);
gltex->mipmap.height = (UINT16)(texture->height);
if (skyspecial)
grtex->mipmap.format = GL_TEXFMT_RGBA; // that skyspecial code below assumes this format ...
gltex->mipmap.format = GL_TEXFMT_RGBA; // that skyspecial code below assumes this format ...
else
grtex->mipmap.format = textureformat;
gltex->mipmap.format = textureformat;
grtex->mipmap.colormap = colormaps;
gltex->mipmap.colormap = colormaps;
#ifdef GLENCORE
if (encoremap && !noencore)
grtex->mipmap.colormap += COLORMAP_REMAPOFFSET;
gltex->mipmap.colormap += COLORMAP_REMAPOFFSET;
#endif
blockwidth = texture->width;
blockheight = texture->height;
blocksize = (blockwidth * blockheight);
block = MakeBlock(&grtex->mipmap);
block = MakeBlock(&gltex->mipmap);
if (skyspecial) //Hurdler: not efficient, but better than holes in the sky (and it's done only at level loading)
{
@@ -359,14 +367,17 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex, boolean noe
RGBA_t col;
col = palette[HWR_CHROMAKEY_EQUIVALENTCOLORINDEX];
for (j = 0; j < blockheight; j++)
{
for (i = 0; i < blockwidth; i++)
{
block[4*(j*blockwidth+i)+0] = col.s.red;
block[4*(j*blockwidth+i)+1] = col.s.green;
block[4*(j*blockwidth+i)+2] = col.s.blue;
block[4*(j*blockwidth+i)+3] = 0xff;
int idx = (j*blockwidth+i);
block[4*idx+0] = col.s.red;
block[4*idx+1] = col.s.green;
block[4*idx+2] = col.s.blue;
block[4*idx+3] = 0xff;
}
}
}
@@ -375,86 +386,81 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex, boolean noe
for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++)
{
realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE);
HWR_DrawTexturePatchInCache(&grtex->mipmap,
blockwidth, blockheight,
texture, patch,
realpatch);
HWR_DrawTexturePatchInCache(&gltex->mipmap, blockwidth, blockheight, texture, patch, realpatch);
Z_ChangeTag(realpatch, PU_HWRCACHE_UNLOCKED);
}
//Hurdler: not efficient at all but I don't remember exactly how HWR_DrawPatchInCache works :(
if (format2bpp(grtex->mipmap.format)==4)
if (format2bpp(gltex->mipmap.format) == 4)
{
for (i = 3; i < blocksize*4; i += 4) // blocksize*4 because blocksize doesn't include the bpp
{
if (block[i] != 0)
continue;
grtex->mipmap.flags |= TF_TRANSPARENT;
gltex->mipmap.flags |= TF_TRANSPARENT;
break;
}
}
grtex->scaleX = 1.0f/(texture->width*FRACUNIT);
grtex->scaleY = 1.0f/(texture->height*FRACUNIT);
gltex->scaleX = 1.0f/(texture->width*FRACUNIT);
gltex->scaleY = 1.0f/(texture->height*FRACUNIT);
}
// patch may be NULL if grMipmap has been initialised already and makebitmap is false
void HWR_MakePatch (patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, boolean makebitmap)
// patch may be NULL if glMipmap has been initialised already and makebitmap is false
void HWR_MakePatch (patch_t *patch, GLPatch_t *glPatch, GLMipmap_t *glMipmap, boolean makebitmap)
{
// don't do it twice (like a cache)
if (grMipmap->width == 0)
if (glMipmap->width == 0)
{
// save the original patch header so that the GLPatch can be casted
// into a standard patch_t struct and the existing code can get the
// orginal patch dimensions and offsets.
grPatch->width = SHORT(patch->width);
grPatch->height = SHORT(patch->height);
grPatch->leftoffset = SHORT(patch->leftoffset);
grPatch->topoffset = SHORT(patch->topoffset);
glPatch->width = SHORT(patch->width);
glPatch->height = SHORT(patch->height);
glPatch->leftoffset = SHORT(patch->leftoffset);
glPatch->topoffset = SHORT(patch->topoffset);
//grMipmap->width = (UINT16)SHORT(patch->width);
//grMipmap->height = (UINT16)SHORT(patch->height);
grMipmap->width = grMipmap->height = 1;
while (grMipmap->width < grPatch->width) grMipmap->width <<= 1;
while (grMipmap->height < grPatch->height) grMipmap->height <<= 1;
glMipmap->width = glMipmap->height = 1;
while (glMipmap->width < glPatch->width) glMipmap->width <<= 1;
while (glMipmap->height < glPatch->height) glMipmap->height <<= 1;
// no wrap around, no chroma key
grMipmap->flags = 0;
glMipmap->flags = 0;
// setup the texture info
grMipmap->format = patchformat;
//grPatch->max_s = grPatch->max_t = 1.0f;
grPatch->max_s = (float)grPatch->width / (float)grMipmap->width;
grPatch->max_t = (float)grPatch->height / (float)grMipmap->height;
glMipmap->format = patchformat;
//glPatch->max_s = glPatch->max_t = 1.0f;
glPatch->max_s = (float)glPatch->width / (float)glMipmap->width;
glPatch->max_t = (float)glPatch->height / (float)glMipmap->height;
}
Z_Free(grMipmap->data);
grMipmap->data = NULL;
Z_Free(glMipmap->data);
glMipmap->data = NULL;
if (makebitmap)
{
MakeBlock(grMipmap);
HWR_DrawPatchInCache(grMipmap,
grMipmap->width, grMipmap->height,
grPatch->width, grPatch->height,
MakeBlock(glMipmap);
HWR_DrawPatchInCache(glMipmap,
glMipmap->width, glMipmap->height,
glPatch->width, glPatch->height,
patch);
}
//grPatch->max_s = grPatch->max_t = 1.0f;
}
// =================================================
// CACHING HANDLING
// =================================================
static size_t gr_numtextures;
static GLMapTexture_t *gr_textures; // For all textures
static size_t gl_numtextures;
static GLMapTexture_t *gl_textures; // For all textures
void HWR_InitTextureCache(void)
{
gr_numtextures = 0;
gr_textures = NULL;
gl_numtextures = 0;
gl_textures = NULL;
}
// Callback function for HWR_FreeTextureCache.
@@ -494,7 +500,7 @@ static void FreeMipmapColormap(INT32 patchnum, void *patch)
if (next->data)
Z_Free(next->data);
next->data = NULL;
HWD.pfnDeleteTexture(next);
GL_DeleteTexture(next);
// Free the old colormap mipmap from memory.
free(next);
@@ -505,7 +511,7 @@ void HWR_FreeMipmapCache(void)
{
INT32 i;
// free references to the textures
HWD.pfnClearMipMapCache();
GL_ClearMipMapCache();
// free all hardware-converted graphics cached in the heap
// our gool is only the textures since user of the texture is the texture cache
@@ -526,10 +532,10 @@ void HWR_FreeTextureCache(void)
// now the heap don't have any 'user' pointing to our
// texturecache info, we can free it
if (gr_textures)
free(gr_textures);
gr_textures = NULL;
gr_numtextures = 0;
if (gl_textures)
free(gl_textures);
gl_textures = NULL;
gl_numtextures = 0;
}
void HWR_LoadTextures(size_t pnumtextures)
@@ -537,13 +543,13 @@ void HWR_LoadTextures(size_t pnumtextures)
// we must free it since numtextures changed
HWR_FreeTextureCache();
gr_numtextures = pnumtextures;
gl_numtextures = pnumtextures;
#ifdef GLENCORE
gr_textures = calloc(pnumtextures, sizeof (*gr_textures)*2); // *2 - 1 for encore-remapped texture and another for noencore texture (unused when not in encore)
gl_textures = calloc(pnumtextures, sizeof (*gl_textures)*2); // *2 - 1 for encore-remapped texture and another for noencore texture (unused when not in encore)
#else
gr_textures = calloc(pnumtextures, sizeof (*gr_textures));
gl_textures = calloc(pnumtextures, sizeof (*gl_textures));
#endif
if (gr_textures == NULL)
if (gl_textures == NULL)
I_Error("HWR_LoadTextures: ran out of memory for OpenGL textures. Sad!");
}
@@ -552,9 +558,9 @@ void HWR_LoadTextures(size_t pnumtextures)
// --------------------------------------------------------------------------
GLMapTexture_t *HWR_GetTexture(INT32 tex, boolean noencore)
{
GLMapTexture_t *grtex;
GLMapTexture_t *gltex;
if (tex < 0 || tex >= (signed)gr_numtextures)
if (tex < 0 || tex >= (signed)gl_numtextures)
{
#ifdef PARANOIA
I_Error("HWR_GetTexture: Invalid texture ID %d", tex);
@@ -563,25 +569,25 @@ GLMapTexture_t *HWR_GetTexture(INT32 tex, boolean noencore)
#endif
}
#ifdef GLENCORE
grtex = &gr_textures[tex*2 + (encoremap && !noencore ? 0 : 1)];
gltex = &gl_textures[tex*2 + (encoremap && !noencore ? 0 : 1)];
#else
grtex = &gr_textures[tex];
gltex = &gl_textures[tex];
#endif
if (!grtex->mipmap.data && !grtex->mipmap.downloaded)
HWR_GenerateTexture(tex, grtex, noencore);
if (!gltex->mipmap.data && !gltex->mipmap.downloaded)
HWR_GenerateTexture(tex, gltex, noencore);
// If hardware does not have the texture, then call pfnSetTexture to upload it
if (!grtex->mipmap.downloaded)
HWD.pfnSetTexture(&grtex->mipmap);
HWR_SetCurrentTexture(&grtex->mipmap);
if (!gltex->mipmap.downloaded)
GL_SetTexture(&gltex->mipmap);
HWR_SetCurrentTexture(&gltex->mipmap);
// The system-memory data can be purged now.
Z_ChangeTag(grtex->mipmap.data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(gltex->mipmap.data, PU_HWRCACHE_UNLOCKED);
return grtex;
return gltex;
}
static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
static void HWR_CacheFlat(GLMipmap_t *glMipmap, lumpnum_t flatlumpnum)
{
#ifdef GLENCORE
UINT8 *flat;
@@ -590,8 +596,8 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
size_t size, pflatsize;
// setup the texture info
grMipmap->format = GL_TEXFMT_P_8;
grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED;
glMipmap->format = GL_TEXFMT_P_8;
glMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED;
size = W_LumpLength(flatlumpnum);
@@ -619,21 +625,21 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
pflatsize = 64;
break;
}
grMipmap->width = (UINT16)pflatsize;
grMipmap->height = (UINT16)pflatsize;
glMipmap->width = (UINT16)pflatsize;
glMipmap->height = (UINT16)pflatsize;
// the flat raw data needn't be converted with palettized textures
W_ReadLump(flatlumpnum, Z_Malloc(W_LumpLength(flatlumpnum),
PU_HWRCACHE, &grMipmap->data));
PU_HWRCACHE, &glMipmap->data));
#ifdef GLENCORE
flat = grMipmap->data;
flat = glMipmap->data;
for (steppy = 0; steppy < size; steppy++)
{
if (flat[steppy] == HWR_PATCHES_CHROMAKEY_COLORINDEX)
continue;
flat[steppy] = grMipmap->colormap[flat[steppy]];
flat[steppy] = glMipmap->colormap[flat[steppy]];
}
#endif
}
@@ -641,117 +647,117 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
// Download a Doom 'flat' to the hardware cache and make it ready for use
void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap)
{
GLMipmap_t *grmip;
GLMipmap_t *glMipmap;
if (flatlumpnum == LUMPERROR)
return;
grmip = HWR_GetCachedGLPatch(flatlumpnum)->mipmap;
glMipmap = HWR_GetCachedGLPatch(flatlumpnum)->mipmap;
grmip->colormap = colormaps;
glMipmap->colormap = colormaps;
#ifdef GLENCORE
if (!noencoremap && encoremap)
grmip->colormap += COLORMAP_REMAPOFFSET;
glMipmap->colormap += COLORMAP_REMAPOFFSET;
#endif
if (!grmip->downloaded && !grmip->data)
HWR_CacheFlat(grmip, flatlumpnum);
if (!glMipmap->downloaded && !glMipmap->data)
HWR_CacheFlat(glMipmap, flatlumpnum);
// If hardware does not have the texture, then call pfnSetTexture to upload it
if (!grmip->downloaded)
HWD.pfnSetTexture(grmip);
HWR_SetCurrentTexture(grmip);
if (!glMipmap->downloaded)
GL_SetTexture(glMipmap);
HWR_SetCurrentTexture(glMipmap);
// The system-memory data can be purged now.
Z_ChangeTag(grmip->data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(glMipmap->data, PU_HWRCACHE_UNLOCKED);
}
//
// HWR_LoadMappedPatch(): replace the skin color of the sprite in cache
// : load it first in doom cache if not already
//
static void HWR_LoadMappedPatch(GLMipmap_t *grmip, GLPatch_t *gpatch)
static void HWR_LoadMappedPatch(GLMipmap_t *glMipmap, GLPatch_t *glPatch)
{
if (!grmip->downloaded && !grmip->data)
if (!glMipmap->downloaded && !glMipmap->data)
{
patch_t *patch = gpatch->rawpatch;
patch_t *patch = glPatch->rawpatch;
if (!patch)
patch = W_CacheLumpNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC);
HWR_MakePatch(patch, gpatch, grmip, true);
patch = W_CacheLumpNumPwad(glPatch->wadnum, glPatch->lumpnum, PU_STATIC);
HWR_MakePatch(patch, glPatch, glMipmap, true);
// You can't free rawpatch for some reason?
// (Obviously I can't, sprite rotation needs that...)
if (!gpatch->rawpatch)
if (!glPatch->rawpatch)
Z_Free(patch);
}
// If hardware does not have the texture, then call pfnSetTexture to upload it
if (!grmip->downloaded)
HWD.pfnSetTexture(grmip);
HWR_SetCurrentTexture(grmip);
if (!glMipmap->downloaded)
GL_SetTexture(glMipmap);
HWR_SetCurrentTexture(glMipmap);
// The system-memory data can be purged now.
Z_ChangeTag(grmip->data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(glMipmap->data, PU_HWRCACHE_UNLOCKED);
}
// -----------------+
// HWR_GetPatch : Download a patch to the hardware cache and make it ready for use
// HWR_GetPatch : Downloads a patch to the hardware cache and make it ready for use
// -----------------+
void HWR_GetPatch(GLPatch_t *gpatch)
void HWR_GetPatch(GLPatch_t *glPatch)
{
// is it in hardware cache
if (!gpatch->mipmap->downloaded && !gpatch->mipmap->data)
if (!glPatch->mipmap->downloaded && !glPatch->mipmap->data)
{
// load the software patch, PU_STATIC or the Z_Malloc for hardware patch will
// flush the software patch before the conversion! oh yeah I suffered
patch_t *ptr = gpatch->rawpatch;
patch_t *ptr = glPatch->rawpatch;
if (!ptr)
ptr = W_CacheLumpNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC);
HWR_MakePatch(ptr, gpatch, gpatch->mipmap, true);
ptr = W_CacheLumpNumPwad(glPatch->wadnum, glPatch->lumpnum, PU_STATIC);
HWR_MakePatch(ptr, glPatch, glPatch->mipmap, true);
// this is inefficient.. but the hardware patch in heap is purgeable so it should
// not fragment memory, and besides the REAL cache here is the hardware memory
if (!gpatch->rawpatch)
if (!glPatch->rawpatch)
Z_Free(ptr);
}
// If hardware does not have the texture, then call pfnSetTexture to upload it
if (!gpatch->mipmap->downloaded)
HWD.pfnSetTexture(gpatch->mipmap);
HWR_SetCurrentTexture(gpatch->mipmap);
if (!glPatch->mipmap->downloaded)
GL_SetTexture(glPatch->mipmap);
HWR_SetCurrentTexture(glPatch->mipmap);
// The system-memory patch data can be purged now.
Z_ChangeTag(gpatch->mipmap->data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(glPatch->mipmap->data, PU_HWRCACHE_UNLOCKED);
}
// -------------------+
// HWR_GetMappedPatch : Same as HWR_GetPatch for sprite color
// -------------------+
void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap)
void HWR_GetMappedPatch(GLPatch_t *glPatch, const UINT8 *colormap)
{
GLMipmap_t *grmip, *newmip;
GLMipmap_t *glMipmap, *newMipmap;
// Blatant hack for encore colormapping aside...
if (colormap == colormaps || colormap == NULL || colormap == (const UINT8*)(COLORMAP_REMAPOFFSET))
{
// Load the default (green) color in doom cache (temporary?) AND hardware cache
HWR_GetPatch(gpatch);
HWR_GetPatch(glPatch);
return;
}
// search for the mimmap
// search for the mipmap
// skip the first (no colormap translated)
for (grmip = gpatch->mipmap; grmip->nextcolormap; )
for (glMipmap = glPatch->mipmap; glMipmap->nextcolormap; )
{
grmip = grmip->nextcolormap;
glMipmap = glMipmap->nextcolormap;
if (grmip->colormap != colormap)
if (glMipmap->colormap != colormap)
continue;
HWR_LoadMappedPatch(grmip, gpatch);
HWR_LoadMappedPatch(glMipmap, glPatch);
return;
}
// not found, create it!
@@ -761,38 +767,38 @@ void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap)
// (it have a liste of mipmap)
// this malloc is cleared in HWR_FreeTextureCache
// (...) unfortunately z_malloc fragment alot the memory :(so malloc is better
newmip = calloc(1, sizeof (*newmip));
if (newmip == NULL)
newMipmap = calloc(1, sizeof (*newMipmap));
if (newMipmap == NULL)
I_Error("%s: Out of memory", "HWR_GetMappedPatch");
grmip->nextcolormap = newmip;
glMipmap->nextcolormap = newMipmap;
newmip->colormap = colormap;
HWR_LoadMappedPatch(newmip, gpatch);
newMipmap->colormap = colormap;
HWR_LoadMappedPatch(newMipmap, glPatch);
}
void HWR_UnlockCachedPatch(GLPatch_t *gpatch)
void HWR_UnlockCachedPatch(GLPatch_t *glPatch)
{
if (!gpatch)
if (!glPatch)
return;
Z_ChangeTag(gpatch->mipmap->data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(glPatch->mipmap->data, PU_HWRCACHE_UNLOCKED);
}
GLPatch_t *HWR_GetCachedGLPatchPwad(UINT16 wadnum, UINT16 lumpnum)
{
aatree_t *hwrcache = wadfiles[wadnum]->hwrcache;
GLPatch_t *grpatch;
GLPatch_t *glPatch;
if (!(grpatch = M_AATreeGet(hwrcache, lumpnum)))
if (!(glPatch = M_AATreeGet(hwrcache, lumpnum)))
{
grpatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL);
grpatch->wadnum = wadnum;
grpatch->lumpnum = lumpnum;
grpatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL);
M_AATreeSet(hwrcache, lumpnum, grpatch);
glPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL);
glPatch->wadnum = wadnum;
glPatch->lumpnum = lumpnum;
glPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL);
M_AATreeSet(hwrcache, lumpnum, glPatch);
}
return grpatch;
return glPatch;
}
GLPatch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum)
@@ -840,14 +846,14 @@ static void HWR_DrawFadeMaskInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32
Z_Free(flat);
}
static void HWR_CacheFadeMask(GLMipmap_t *grMipmap, lumpnum_t fademasklumpnum)
static void HWR_CacheFadeMask(GLMipmap_t *glMipmap, lumpnum_t fademasklumpnum)
{
size_t size;
UINT16 fmheight = 0, fmwidth = 0;
// setup the texture info
grMipmap->format = GL_TEXFMT_ALPHA_8; // put the correct alpha levels straight in so I don't need to convert it later
grMipmap->flags = 0;
glMipmap->format = GL_TEXFMT_ALPHA_8; // put the correct alpha levels straight in so I don't need to convert it later
glMipmap->flags = 0;
size = W_LumpLength(fademasklumpnum);
@@ -876,28 +882,28 @@ static void HWR_CacheFadeMask(GLMipmap_t *grMipmap, lumpnum_t fademasklumpnum)
}
// Thankfully, this will still work for this scenario
grMipmap->width = fmwidth;
grMipmap->height = fmheight;
glMipmap->width = fmwidth;
glMipmap->height = fmheight;
MakeBlock(grMipmap);
MakeBlock(glMipmap);
HWR_DrawFadeMaskInCache(grMipmap, fmwidth, fmheight, fademasklumpnum, fmwidth, fmheight);
HWR_DrawFadeMaskInCache(glMipmap, fmwidth, fmheight, fademasklumpnum, fmwidth, fmheight);
// I DO need to convert this because it isn't power of 2 and we need the alpha
}
void HWR_GetFadeMask(lumpnum_t fademasklumpnum)
{
GLMipmap_t *grmip;
GLMipmap_t *glMipmap;
grmip = HWR_GetCachedGLPatch(fademasklumpnum)->mipmap;
glMipmap = HWR_GetCachedGLPatch(fademasklumpnum)->mipmap;
if (!grmip->downloaded && !grmip->data)
HWR_CacheFadeMask(grmip, fademasklumpnum);
if (!glMipmap->downloaded && !glMipmap->data)
HWR_CacheFadeMask(glMipmap, fademasklumpnum);
HWD.pfnSetTexture(grmip);
GL_SetTexture(glMipmap);
// The system-memory data can be purged now.
Z_ChangeTag(grmip->data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(glMipmap->data, PU_HWRCACHE_UNLOCKED);
}
// =================================================
@@ -909,15 +915,15 @@ void HWR_SetPalette(RGBA_t *palette)
if (HWR_ShouldUsePaletteRendering())
{
// set the palette for palette postprocessing
if (cv_grpalettedepth.value == 16)
if (cv_glpalettedepth.value == 16)
{
// crush to 16-bit rgb565, like software currently does in the standard configuration
// Note: Software's screenshots have the 24-bit palette, but the screen gets
// the 16-bit version! For making comparison screenshots either use an external screenshot
// tool or set the palette depth to 24 bits.
RGBA_t crushed_palette[256];
int i;
for (i = 0; i < 256; i++)
for (int i = 0; i < 256; i++)
{
float fred = (float)(palette[i].s.red >> 3);
float fgreen = (float)(palette[i].s.green >> 2);
@@ -927,21 +933,21 @@ void HWR_SetPalette(RGBA_t *palette)
crushed_palette[i].s.blue = (UINT8)(fblue / 31.0f * 255.0f);
crushed_palette[i].s.alpha = 255;
}
HWD.pfnSetScreenPalette(crushed_palette);
GL_SetScreenPalette(crushed_palette);
}
else
{
HWD.pfnSetScreenPalette(palette);
GL_SetScreenPalette(palette);
}
// this part is responsible for keeping track of the palette OUTSIDE of a level.
if ((!(gamestate == GS_LEVEL)) || (gamestate == GS_TITLESCREEN))
if (gamestate != GS_LEVEL || gamestate == GS_TITLESCREEN)
HWR_SetMapPalette();
}
else
{
// set the palette for the textures
HWD.pfnSetTexturePalette(palette);
GL_SetPalette(palette);
// reset mapPalette so next call to HWR_SetMapPalette will update everything correctly
memset(mapPalette, 0, sizeof(mapPalette));
// hardware driver will flush there own cache if cache is non paletized
@@ -974,7 +980,7 @@ static void HWR_SetPaletteLookup(RGBA_t *palette)
}
}
#undef STEP_SIZE
HWD.pfnSetPaletteLookup(lut);
GL_SetPaletteLookup(lut);
Z_Free(lut);
}
@@ -987,11 +993,9 @@ void HWR_SetMapPalette(void)
RGBA_t *palette;
int i;
if ((!(gamestate == GS_LEVEL)) || (gamestate == GS_TITLESCREEN))
if (gamestate != GS_LEVEL || gamestate == GS_TITLESCREEN)
{
// outside of a level, pMasterPalette should have PLAYPAL ready for us
//palette = pMasterPalette; // we dont have this in kart so just use pLocalPalette as before
// outside of a level, pLocalPalette should have PLAYPAL ready for us
palette = pLocalPalette;
}
else
@@ -1001,8 +1005,10 @@ void HWR_SetMapPalette(void)
lumpnum_t lumpnum = W_GetNumForName(GetPalette());
size_t palsize = W_LumpLength(lumpnum);
UINT8 *RGB_data;
if (palsize < 768) // 256 * 3
I_Error("HWR_SetMapPalette: A programmer assumed palette lumps are at least 768 bytes long, but apparently this was a wrong assumption!\n");
RGB_data = W_CacheLumpNum(lumpnum, PU_CACHE);
// we got the RGB palette now, but we need it in RGBA format.
for (i = 0; i < 256; i++)
@@ -1022,7 +1028,7 @@ void HWR_SetMapPalette(void)
// in palette rendering mode, this means that all rgba textures now have wrong colors
// and the lookup table is outdated
HWR_SetPaletteLookup(mapPalette);
HWD.pfnSetTexturePalette(mapPalette);
GL_SetPalette(mapPalette);
if (patchformat == GL_TEXFMT_RGBA || textureformat == GL_TEXFMT_RGBA)
{
@@ -1045,12 +1051,11 @@ UINT32 HWR_CreateLightTable(UINT8 *lighttable)
for (i = 0; i < 256 * 32; i++)
hw_lighttable[i] = palette[lighttable[i]];
id = HWD.pfnCreateLightTable(hw_lighttable);
id = GL_CreateLightTable(hw_lighttable);
Z_Free(hw_lighttable);
return id;
}
// get hwr lighttable id for colormap, create it if it doesn't already exist
UINT32 HWR_GetLightTableID(extracolormap_t *colormap)
{
@@ -1082,7 +1087,7 @@ UINT32 HWR_GetLightTableID(extracolormap_t *colormap)
void HWR_ClearLightTables(void)
{
if (vid.glstate == VID_GL_LIBRARY_LOADED)
HWD.pfnClearLightTables();
GL_ClearLightTables();
}
#endif //HWRENDER
+3 -3
View File
@@ -333,11 +333,11 @@ angle_t gld_FrustumAngle(angle_t tiltangle)
// ok, this is a gross hack that barely works...
// but at least it doesn't overestimate too much...
clipfov = atan(1 / projMatrix[0]) * 360 / M_PI;
clipfov = atan(1 / projMatrix[0]) * 360 / M_PIl;
floatangle = 2.0f + (45.0f + (tilt / 1.9f)) * clipfov / 90.0f;
if (floatangle >= 180.0)
return 0xffffffff;
a1 = (angle_t)(ANG1 * (int)floatangle);
a1 = (angle_t)xs_CRoundToInt(ANG1 * floatangle);
return a1;
}
@@ -458,4 +458,4 @@ boolean gld_SphereInFrustum(float x, float y, float z, float radius)
}
return true;
}
#endif
#endif
+7 -5
View File
@@ -33,16 +33,18 @@ typedef enum GLTextureFormat_e
GL_TEXFMT_ALPHA_INTENSITY_88 = 0x22,
} GLTextureFormat_t;
// data holds the address of the graphics data cached in heap memory
// NULL if the texture is not in Doom heap cache.
// Texture information (misleadingly named "mipmap" all over the code.)
// The *data pointer holds the address of the graphics data cached in heap memory.
// NULL if the texture is not in SRB2's heap cache.
struct GLMipmap_s
{
// for UpdateTexture
GLTextureFormat_t format;
void *data;
UINT32 flags;
UINT16 width, height;
UINT32 downloaded; // tex_downloaded
UINT32 downloaded; // The GPU has this texture.
struct GLMipmap_s *nextcolormap;
const UINT8 *colormap;
@@ -50,12 +52,12 @@ struct GLMipmap_s
typedef struct GLMipmap_s GLMipmap_t;
//
// Doom texture info, as cached for hardware rendering
// Level textures, as cached for hardware rendering.
//
struct GLMapTexture_s
{
GLMipmap_t mipmap;
float scaleX; //used for scaling textures on walls
float scaleX; //used for scaling textures on walls
float scaleY;
};
typedef struct GLMapTexture_s GLMapTexture_t;
+41 -12
View File
@@ -121,8 +121,6 @@ typedef struct
poly_t *planepoly; // the generated convex polygon
} extrasubsector_t;
//here lies gr_vissprite
// Kart features
#define USE_FTRANSFORM_ANGLEZ
#define USE_FTRANSFORM_MIRROR
@@ -134,14 +132,14 @@ typedef struct
{
FLOAT x,y,z; // position
#ifdef USE_FTRANSFORM_ANGLEZ
FLOAT anglex,angley,anglez; // aimingangle / viewangle
FLOAT anglex2,anglez2; // secondaries
FLOAT anglex, angley, anglez; // aimingangle / viewangle
FLOAT anglex2, anglez2; // secondaries
#else
FLOAT anglex,angley; // aimingangle / viewangle
FLOAT anglex, angley; // aimingangle / viewangle
FLOAT anglex2; // secondaries
#endif
FLOAT scalex,scaley,scalez;
FLOAT spritexscale,spriteyscale;
FLOAT scalex, scaley, scalez;
FLOAT spritexscale, spriteyscale;
FLOAT fovxangle, fovyangle;
UINT8 splitscreen;
boolean flip; // screenflip
@@ -166,6 +164,41 @@ typedef struct
FLOAT s,t;
} FOutVector;
typedef struct vbo_vertex_s
{
float x, y, z;
float u, v;
unsigned char r, g, b, a;
} gl_skyvertex_t;
typedef enum gl_skyloopmode_e
{
HWD_SKYLOOP_FAN,
HWD_SKYLOOP_STRIP
} gl_skyloopmode_t;
typedef struct
{
gl_skyloopmode_t mode;
int vertexcount;
int vertexindex;
boolean use_texture;
} gl_skyloopdef_t;
typedef struct
{
unsigned int vbo;
int rows, columns;
int loopcount;
int detail, vertex_count;
int texture, width, height;
boolean rebuild; // VBO needs to be rebuilt
gl_skyloopdef_t *loops;
gl_skyvertex_t *data;
} gl_sky_t;
// Shader targets used to render specific types of geometry.
// A shader target is resolved to an actual shader with HWR_GetShaderFromTarget.
// The shader returned may be a base shader or a custom shader.
@@ -173,7 +206,6 @@ enum
{
SHADER_NONE = -1,
SHADER_FLOOR = 0,
SHADER_SHADOW,
SHADER_WALL,
SHADER_SPRITE,
SHADER_MODEL,
@@ -204,7 +236,6 @@ enum hwdshaderstage
typedef enum hwdshaderstage hwdshaderstage_t;
// ==========================================================================
// RENDER MODES
// ==========================================================================
@@ -289,9 +320,6 @@ typedef struct FSurfaceInfo FSurfaceInfo;
enum hwdsetspecialstate
{
#ifdef USE_FBO_OGL
HWD_SET_FRAMEBUFFER,
#endif
HWD_SET_SHADERS,
HWD_SET_TEXTUREFILTERMODE,
@@ -346,6 +374,7 @@ enum hwdscreentexture
HWD_SCREENTEXTURE_WIPE_END, // destination image for the wipe/fade effect
HWD_SCREENTEXTURE_GENERIC1, // underwater/heat effect, intermission background
HWD_SCREENTEXTURE_GENERIC2, // palette-based colormap fade, final screen texture
HWD_SCREENTEXTURE_VHS,
NUMSCREENTEXTURES, // (generic3 is unused if palette rendering is disabled)
};
typedef enum hwdscreentexture hwdscreentexture_t;
+50 -49
View File
@@ -18,9 +18,10 @@
#include "../doomdef.h"
#ifdef HWRENDER
#include "hw_main.h"
#include "hw_glob.h"
#include "hw_drv.h"
#include "hw_gl.h"
#include "../m_misc.h" //FIL_WriteFile()
#include "../r_draw.h" //viewborderlump
@@ -122,7 +123,7 @@ void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option)
flags |= PF_ForceWrapY;
// clip it since it is used for bunny scroll in doom I
HWD.pfnDrawPolygon(NULL, v, 4, flags);
GL_DrawPolygon(NULL, v, 4, flags);
}
void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap)
@@ -303,10 +304,10 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t
else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[hudtrans];
else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel];
flags |= PF_Modulated;
HWD.pfnDrawPolygon(&Surf, v, 4, flags);
GL_DrawPolygon(&Surf, v, 4, flags);
}
else
HWD.pfnDrawPolygon(NULL, v, 4, flags);
GL_DrawPolygon(NULL, v, 4, flags);
}
void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h)
@@ -460,10 +461,10 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal
else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[cv_translucenthud.value];
else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel];
flags |= PF_Modulated;
HWD.pfnDrawPolygon(&Surf, v, 4, flags);
GL_DrawPolygon(&Surf, v, 4, flags);
}
else
HWD.pfnDrawPolygon(NULL, v, 4, flags);
GL_DrawPolygon(NULL, v, 4, flags);
}
// ==========================================================================
@@ -539,7 +540,7 @@ void HWR_DrawFlatFill (INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum
// BTW, I see we put 0 for PFs, and If I'm right, that
// means we take the previous PFs as default
// how can we be sure they are ok?
HWD.pfnDrawPolygon(NULL, v, 4, PF_NoDepthTest); //PF_Translucent);
GL_DrawPolygon(NULL, v, 4, PF_NoDepthTest); //PF_Translucent);
}
@@ -552,33 +553,33 @@ void HWR_DrawFlatFill (INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum
// 0--1
void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength)
{
FOutVector v[4];
FSurfaceInfo Surf;
FOutVector v[4];
FSurfaceInfo Surf;
FBITFIELD poly_flags = PF_NoTexture|PF_Modulated|PF_NoDepthTest;
v[0].x = v[3].x = -1.0f;
v[2].x = v[1].x = 1.0f;
v[0].y = v[1].y = -1.0f;
v[2].y = v[3].y = 1.0f;
v[0].z = v[1].z = v[2].z = v[3].z = 1.0f;
v[0].x = v[3].x = -1.0f;
v[2].x = v[1].x = 1.0f;
v[0].y = v[1].y = -1.0f;
v[2].y = v[3].y = 1.0f;
v[0].z = v[1].z = v[2].z = v[3].z = 1.0f;
v[0].s = v[3].s = 0.0f;
v[2].s = v[1].s = 1.0f;
v[0].t = v[1].t = 1.0f;
v[2].t = v[3].t = 0.0f;
v[0].s = v[3].s = 0.0f;
v[2].s = v[1].s = 1.0f;
v[0].t = v[1].t = 1.0f;
v[2].t = v[3].t = 0.0f;
if (color & 0xFF00) // Do COLORMAP fade.
{
if (HWR_ShouldUsePaletteRendering() && cv_grscreentextures.value)
if (color & 0xFF00) // Do COLORMAP fade.
{
if (HWR_ShouldUsePaletteRendering() && cv_glscreentextures.value)
{
const hwdscreentexture_t scr_tex = HWD_SCREENTEXTURE_GENERIC2;
Surf.LightTableId = HWR_GetLightTableID(NULL);
Surf.LightInfo.light_level = strength;
HWD.pfnMakeScreenTexture(scr_tex);
HWD.pfnSetShader(HWR_GetShaderFromTarget(SHADER_UI_COLORMAP_FADE));
HWD.pfnDrawScreenTexture(scr_tex, &Surf, PF_ColorMapped|PF_NoDepthTest);
HWD.pfnUnSetShader();
GL_MakeScreenTexture(scr_tex);
GL_SetShader(HWR_GetShaderFromTarget(SHADER_UI_COLORMAP_FADE));
GL_DrawScreenTexture(scr_tex, &Surf, PF_ColorMapped|PF_NoDepthTest);
GL_UnSetShader();
return;
}
@@ -588,21 +589,21 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength)
Surf.PolyColor.s.alpha = (strength*8);
poly_flags |= PF_Translucent;
}
}
else // Do TRANSMAP** fade.
{
}
else // Do TRANSMAP** fade.
{
RGBA_t *palette = HWR_GetTexturePalette();
Surf.PolyColor.rgba = palette[color&0xFF].rgba;
if (HWR_ShouldUsePaletteRendering())
Surf.PolyColor.s.alpha = softwaretranstogl[strength];
else
Surf.PolyColor.s.alpha = (UINT8)(strength*25.5f);
poly_flags |= PF_Translucent;
}
HWD.pfnDrawPolygon(&Surf, v, 4, poly_flags);
poly_flags |= PF_Translucent;
}
GL_DrawPolygon(&Surf, v, 4, poly_flags);
}
// Draw the console background with translucency support
@@ -629,7 +630,7 @@ void HWR_DrawConsoleBack(UINT32 color, INT32 height)
Surf.PolyColor.rgba = UINT2RGBA(color);
Surf.PolyColor.s.alpha = 0x80;
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
GL_DrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
}
@@ -652,17 +653,17 @@ void HWR_DrawViewBorder(INT32 clearlines)
INT32 basewindowx, basewindowy;
GLPatch_t *patch;
// if (gr_viewwidth == vid.width)
// if (gl_viewwidth == vid.width)
// return;
if (!clearlines)
clearlines = BASEVIDHEIGHT; // refresh all
// calc view size based on original game resolution
baseviewwidth = FixedInt(FixedDiv(FLOAT_TO_FIXED(gr_viewwidth), vid.fdupx)); //(cv_viewsize.value * BASEVIDWIDTH/10)&~7;
baseviewheight = FixedInt(FixedDiv(FLOAT_TO_FIXED(gr_viewheight), vid.fdupy));
top = FixedInt(FixedDiv(FLOAT_TO_FIXED(gr_baseviewwindowy), vid.fdupy));
side = FixedInt(FixedDiv(FLOAT_TO_FIXED(gr_baseviewwindowx), vid.fdupx));
baseviewwidth = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_viewwidth), vid.fdupx)); //(cv_viewsize.value * BASEVIDWIDTH/10)&~7;
baseviewheight = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_viewheight), vid.fdupy));
top = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_baseviewwindowy), vid.fdupy));
side = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_baseviewwindowx), vid.fdupx));
// top
HWR_DrawFlatFill(0, 0,
@@ -776,16 +777,16 @@ void HWR_drawAMline(const fline_t *fl, INT32 color)
F2DCoord v1, v2;
RGBA_t color_rgba;
RGBA_t *palette = HWR_GetTexturePalette();
color_rgba = palette[color&0xFF];
v1.x = ((float)fl->a.x-(vid.width/2.0f))*(2.0f/vid.width);
v1.y = ((float)fl->a.y-(vid.height/2.0f))*(2.0f/vid.height);
v2.x = ((float)fl->b.x-(vid.width/2.0f))*(2.0f/vid.width);
v2.y = ((float)fl->b.y-(vid.height/2.0f))*(2.0f/vid.height);
HWD.pfnDraw2DLine(&v1, &v2, color_rgba);
GL_Draw2DLine(&v1, &v2, color_rgba);
}
// -----------------+
@@ -879,7 +880,7 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color)
Surf.PolyColor = palette[color&0xFF];
HWD.pfnDrawPolygon(&Surf, v, 4,
GL_DrawPolygon(&Surf, v, 4,
PF_Modulated|PF_NoTexture|PF_NoDepthTest);
}
@@ -918,7 +919,7 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32
clearColour.green = (float)rgbaColour.s.green / 255;
clearColour.blue = (float)rgbaColour.s.blue / 255;
clearColour.alpha = 1;
HWD.pfnClearBuffer(true, false, false, &clearColour);
GL_ClearBuffer(true, false, false, &clearColour);
return;
}
@@ -989,7 +990,7 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32
Surf.PolyColor.rgba = UINT2RGBA(color);
Surf.PolyColor.s.alpha = 0x80;
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
GL_DrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
}
// -----------------+
@@ -1029,7 +1030,7 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
clearColour.green = (float)rgbaColour.s.green / 255;
clearColour.blue = (float)rgbaColour.s.blue / 255;
clearColour.alpha = 1;
HWD.pfnClearBuffer(true, false, false, &clearColour);
GL_ClearBuffer(true, false, false, &clearColour);
return;
}
@@ -1107,7 +1108,7 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel];
}
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
GL_DrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
}
#ifdef HAVE_PNG
@@ -1191,7 +1192,7 @@ UINT8 *HWR_GetScreenshot(void)
return NULL;
// returns 24bit 888 RGB
HWD.pfnReadScreenTexture(HWD_SCREENTEXTURE_GENERIC2, (void *)buf);
GL_ReadScreenTexture(HWD_SCREENTEXTURE_GENERIC2, (void *)buf);
return buf;
}
@@ -1207,7 +1208,7 @@ boolean HWR_Screenshot(const char *pathname)
}
// returns 24bit 888 RGB
HWD.pfnReadScreenTexture(HWD_SCREENTEXTURE_GENERIC2, (void *)buf);
GL_ReadScreenTexture(HWD_SCREENTEXTURE_GENERIC2, (void *)buf);
#ifdef USE_PNG
ret = M_SavePNG(pathname, buf, vid.width, vid.height, NULL);
-142
View File
@@ -1,142 +0,0 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2019 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file
/// \brief imports/exports for the GPU hardware low-level interface API
#ifndef __HWR_DRV_H__
#define __HWR_DRV_H__
// this must be here 19991024 by Kin
#include "../screen.h"
#include "hw_data.h"
#include "hw_defs.h"
#include "hw_md2.h"
#include "hw_dll.h"
#include "../doomdef.h"
// ==========================================================================
// STANDARD DLL EXPORTS
// ==========================================================================
EXPORT boolean HWRAPI(Init) (void);
EXPORT void HWRAPI(SetupGLInfo) (void);
EXPORT void HWRAPI(SetTexturePalette) (RGBA_t *ppal);
EXPORT void HWRAPI(FinishUpdate) (INT32 waitvbl);
EXPORT void HWRAPI(Draw2DLine) (F2DCoord *v1, F2DCoord *v2, RGBA_t Color);
EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags);
EXPORT void HWRAPI(DrawIndexedTriangles) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, unsigned int *IndexArray);
EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags);
EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, FBOOLEAN DepthMask, FBOOLEAN StencilMask, FRGBAFloat *ClearColor);
EXPORT void HWRAPI(SetTexture) (GLMipmap_t *TexInfo);
EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *TexInfo);
EXPORT void HWRAPI(DeleteTexture) (GLMipmap_t *TexInfo);
EXPORT void HWRAPI(ReadScreenTexture) (int tex, UINT16 *dst_data);
EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip, float farclip);
EXPORT void HWRAPI(ClearMipMapCache) (void);
//Hurdler: added for backward compatibility
EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value);
//Hurdler: added for new development
EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface);
EXPORT void HWRAPI(CreateModelVBOs) (model_t *model);
EXPORT void HWRAPI(SetTransform) (FTransform *stransform);
EXPORT INT32 HWRAPI(GetTextureUsed) (void);
EXPORT void HWRAPI(RenderSkyDome) (INT32 tex, INT32 texture_width, INT32 texture_height, FTransform transform);
EXPORT void HWRAPI(FlushScreenTextures) (void);
EXPORT void HWRAPI(DoScreenWipe) (int wipeStart, int wipeEnd);
EXPORT void HWRAPI(DrawScreenTexture) (int tex, FSurfaceInfo *surf, FBITFIELD polyflags);
EXPORT void HWRAPI(MakeScreenTexture) (int tex);
EXPORT void HWRAPI(DrawScreenFinalTexture) (int tex, INT32 width, INT32 height);
EXPORT void HWRAPI(RenderVhsEffect) (fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize);
#define SCREENVERTS 10
EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]);
// jimita
EXPORT boolean HWRAPI(InitShaders) (void);
EXPORT void HWRAPI(LoadShader) (int slot, char *code, hwdshaderstage_t stage);
EXPORT boolean HWRAPI(CompileShader) (int slot);
EXPORT void HWRAPI(SetShader) (int slot);
EXPORT void HWRAPI(UnSetShader) (void);
EXPORT void HWRAPI(SetShaderInfo) (hwdshaderinfo_t info, INT32 value);
EXPORT void HWRAPI(SetPaletteLookup)(UINT8 *lut);
EXPORT UINT32 HWRAPI(CreateLightTable)(RGBA_t *hw_lighttable);
EXPORT void HWRAPI(ClearLightTables)(void);
EXPORT void HWRAPI(SetScreenPalette)(RGBA_t *palette);
// ==========================================================================
// HWR DRIVER OBJECT, FOR CLIENT PROGRAM
// ==========================================================================
#if !defined (_CREATE_DLL_)
struct hwdriver_s
{
Init pfnInit;
SetupGLInfo pfnSetupGLInfo;
SetTexturePalette pfnSetTexturePalette;
FinishUpdate pfnFinishUpdate;
Draw2DLine pfnDraw2DLine;
DrawPolygon pfnDrawPolygon;
DrawIndexedTriangles pfnDrawIndexedTriangles;
SetBlend pfnSetBlend;
ClearBuffer pfnClearBuffer;
SetTexture pfnSetTexture;
UpdateTexture pfnUpdateTexture;
DeleteTexture pfnDeleteTexture;
ReadScreenTexture pfnReadScreenTexture;
GClipRect pfnGClipRect;
ClearMipMapCache pfnClearMipMapCache;
SetSpecialState pfnSetSpecialState;
DrawModel pfnDrawModel;
CreateModelVBOs pfnCreateModelVBOs;
SetTransform pfnSetTransform;
GetTextureUsed pfnGetTextureUsed;
PostImgRedraw pfnPostImgRedraw;
FlushScreenTextures pfnFlushScreenTextures;
DoScreenWipe pfnDoScreenWipe;
DrawScreenTexture pfnDrawScreenTexture;
MakeScreenTexture pfnMakeScreenTexture;
RenderVhsEffect pfnRenderVhsEffect;
DrawScreenFinalTexture pfnDrawScreenFinalTexture;
RenderSkyDome pfnRenderSkyDome;
InitShaders pfnInitShaders;
LoadShader pfnLoadShader;
CompileShader pfnCompileShader;
SetShader pfnSetShader;
UnSetShader pfnUnSetShader;
SetShaderInfo pfnSetShaderInfo;
SetPaletteLookup pfnSetPaletteLookup;
CreateLightTable pfnCreateLightTable;
ClearLightTables pfnClearLightTables;
SetScreenPalette pfnSetScreenPalette;
};
extern struct hwdriver_s hwdriver;
#define HWD hwdriver
#endif //not defined _CREATE_DLL_
#endif //__HWR_DRV_H__
+79
View File
@@ -0,0 +1,79 @@
// SONIC ROBO BLAST 2 Kart
//-----------------------------------------------------------------------------
// Copyright (C) 2020 by Jaime "Lactozilla" Passos.
// Copyright (C) 2020 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file hw_gl.h
/// \brief OpenGL low-level interface API
#ifndef __HWR_GL_H__
#define __HWR_GL_H__
#include "../screen.h"
#include "hw_data.h"
#include "hw_defs.h"
#include "hw_md2.h"
#define SCREENVERTS 10
boolean GL_Init(void);
void GL_FinishUpdate(INT32 waitvbl);
void SetupGLInfo(void);
void GL_SetSpecialState(hwdspecialstate_t IdState, INT32 Value);
void GL_SetTransform(FTransform *stransform);
void GL_SetBlend(FBITFIELD PolyFlags);
void GL_SetPalette(RGBA_t *palette);
void GL_ClearBuffer(FBOOLEAN ColorMask, FBOOLEAN DepthMask, FBOOLEAN StencilMask, FRGBAFloat * ClearColor);
void GL_DrawPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags);
void GL_DrawIndexedTriangles(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, unsigned int *IndexArray);
void GL_Draw2DLine(F2DCoord *v1, F2DCoord *v2, RGBA_t Color);
void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface);
#define GL_DrawModel(model, frameIndex, duration, tics, nextFrameIndex, pos, hscale, vscale, flipped, hflipped, Surface) GL_DrawModelEx(model, frameIndex, duration, tics, nextFrameIndex, pos, hscale, vscale, flipped, hflipped, Surface)
void GL_RenderSkyDome(gl_sky_t *sky);
void GL_SetTexture(GLMipmap_t *pTexInfo);
void GL_DeleteTexture(GLMipmap_t *pTexInfo);
void GL_Flush(void);
#define GL_ClearMipMapCache GL_Flush
INT32 GL_GetTextureUsed(void);
void GL_CreateModelVBOs(model_t *model);
void GL_ReadScreenTexture(int tex, UINT16 *dst_data);
void GL_GClipRect(INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip, float farclip);
void GL_MakeScreenTexture(int tex);
void GL_FlushScreenTextures(void);
void GL_DrawScreenTexture(int tex, FSurfaceInfo *surf, FBITFIELD polyflags);
void GL_DoScreenWipe(int wipeStart, int wipeEnd);
void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize);
void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean useshader);
void GL_PostImgRedraw(float points[SCREENVERTS][SCREENVERTS][2]);
boolean GL_InitShaders(void);
void GL_LoadShader(int slot, char *code, hwdshaderstage_t stage);
boolean GL_CompileShader(int slot);
void GL_SetShader(int slot);
void GL_UnSetShader(void);
void GL_SetShaderInfo(hwdshaderinfo_t info, INT32 value);
void GL_SetPaletteLookup(UINT8 *lut);
UINT32 GL_CreateLightTable(RGBA_t *hw_lighttable);
void GL_ClearLightTables(void);
void GL_SetScreenPalette(RGBA_t *palette);
#endif // __HWR_GL_H__
+3 -12
View File
@@ -23,7 +23,7 @@
// needed for sprite rendering
// equivalent of the software renderer's vissprites
typedef struct gr_vissprite_s
typedef struct gl_vissprite_s
{
float x1, x2;
float z1, z2;
@@ -32,7 +32,6 @@ typedef struct gr_vissprite_s
float scale;
float spritexscale, spriteyscale;
float spritexoffset, spriteyoffset;
UINT32 renderflags;
GLPatch_t *gpatch;
boolean flip;
UINT8 translucency; //alpha level 0-255
@@ -42,7 +41,7 @@ typedef struct gr_vissprite_s
//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;
} gl_vissprite_t;
// --------
// hw_bsp.c
@@ -64,7 +63,7 @@ void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap);
GLMapTexture_t *HWR_GetTexture(INT32 tex, boolean noencore);
void HWR_GetPatch(GLPatch_t *gpatch);
void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap);
void HWR_MakePatch(patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, boolean makebitmap);
void HWR_MakePatch(patch_t *patch, GLPatch_t *glPatch, GLMipmap_t *glMipmap, boolean makebitmap);
void HWR_UnlockCachedPatch(GLPatch_t *gpatch);
void HWR_SetPalette(RGBA_t *palette);
@@ -82,14 +81,6 @@ void HWR_GetFadeMask(lumpnum_t fademasklumpnum);
extern INT32 patchformat;
extern INT32 textureformat;
// --------
// hw_main.c // originally hw_drawnodes.c from HWPortal branch
// --------
void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 texnum, boolean noencore, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap);
void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap);
void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight,
INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap);
// --------
// hw_shaders.c
// --------
+1389 -1522
View File
File diff suppressed because it is too large. Load diff
+67 -61
View File
@@ -23,6 +23,7 @@
#include "hw_glob.h"
#include "hw_data.h"
#include "hw_defs.h"
#include "hw_portal.h"
#include "../am_map.h"
#include "../d_player.h"
@@ -35,15 +36,32 @@
void HWR_Startup(void);
void HWR_Shutdown(void);
extern float gr_viewwidth, gr_viewheight, gr_baseviewwindowx, gr_baseviewwindowy;
extern float gl_viewwidth, gl_viewheight, gl_baseviewwindowx, gl_baseviewwindowy;
extern float gr_basewindowcenterx, gr_basewindowcentery;
extern float gl_basewindowcenterx, gl_basewindowcentery;
extern unsigned msaa;
extern boolean a2c;
extern FTransform atransform;
extern float gr_viewsin, gr_viewcos;
extern float gl_viewsin, gl_viewcos;
extern boolean gl_drawing_stencil;
extern seg_t *gl_curline;
extern side_t *gl_sidedef;
extern line_t *gl_linedef;
extern sector_t *gl_frontsector;
extern sector_t *gl_backsector;
enum
{
HWR_STENCIL_NORMAL,
HWR_STENCIL_BEGIN,
HWR_STENCIL_REVERSE,
HWR_STENCIL_DEPTH,
HWR_STENCIL_SKY
};
// Performance stats
extern ps_metric_t ps_hw_nodesorttime;
@@ -62,7 +80,7 @@ extern ps_metric_t ps_hw_numcolors;
extern ps_metric_t ps_hw_batchsorttime;
extern ps_metric_t ps_hw_batchdrawtime;
extern boolean gr_shadersavailable;
extern boolean gl_shadersavailable;
// hw_draw.c
void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option);
@@ -81,24 +99,28 @@ UINT8 *HWR_GetScreenshot(void);
boolean HWR_Screenshot(const char *lbmname);
// hw_main.c
void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox);
void HWR_RenderPlayerView(INT32 viewnumber, player_t *player);
void HWR_SetViewSize(void);
void HWR_AddCommands(void);
void HWR_RenderPlayerView(INT32 viewnumber, player_t *player);
void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *player, int stencil_level, boolean allow_portals);
void HWR_ClearSkyDome(void);
void HWR_BuildSkyDome(void);
void HWR_SetTransform(float fpov, player_t *player);
void HWR_ClearClipper(void);
void HWR_SetStencilState(int state, int level);
boolean HWR_UseShader(void);
boolean HWR_ShouldUsePaletteRendering(void);
boolean HWR_PalRenderFlashpal(void);
void HWR_TogglePaletteRendering(void);
// My original intention was to split hw_main.c
// into files like hw_bsp.c, hw_sprites.c...
// hw_main.c: Lighting and fog
void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap);
UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap); // Let's see if this can work
FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf);
@@ -106,79 +128,63 @@ FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf);
INT32 HWR_GetTextureUsed(void);
// hw_main.c: Post-rendering
void HWR_DoPostProcessor(player_t *player);
void HWR_StartScreenWipe(void);
void HWR_EndScreenWipe(void);
void HWR_DrawIntermissionBG(void);
void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum);
void HWR_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize);
void HWR_MakeScreenFinalTexture(void);
void HWR_DrawScreenFinalTexture(INT32 width, INT32 height);
// hw_main.c: Planes
//void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap);
void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap);
void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, FBITFIELD blendmode, UINT8 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap);
void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap);
void HWR_DrawScreenFinalTexture(INT32 width, INT32 height, boolean useshader);
// hw_main.c: Segs
void HWR_ProcessSeg(void); // Sort of like GLWall::Process in GZDoom
void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap);
void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blendmode, INT32 lightlevel, extracolormap_t *wallcolormap);
void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo * pSurf, INT32 texnum, boolean noencore, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap);
// moved HWR_SplitWall to hw_main.c
void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf);
void HWR_DrawSkyBackground(float fpov);
// hw_main.c: Sprites
void HWR_AddSprites(sector_t *sec);
void HWR_ProjectSprite(mobj_t *thing);
//void HWR_ProjectPrecipitationSprite(precipmobj_t *thing);
void HWR_DrawSprites(void);
// hw_bsp.c
void HWR_CreatePlanePolygons(INT32 bspnum);
extern boolean gr_maphasportals;
extern boolean gl_maphasportals;
// hw_cache.c
void HWR_LoadTextures(size_t pnumtextures);
RGBA_t *HWR_GetTexturePalette(void);
void HWR_SetShaderState(void);
// Console variables
extern consvar_t cv_grshaders;
extern CV_PossibleValue_t glanisotropicmode_cons_t[];
extern consvar_t cv_glscreentextures;
#ifdef USE_FBO_OGL
extern consvar_t cv_grframebuffer;
extern consvar_t cv_glframebuffer;
#endif
extern consvar_t cv_splitwallfix;
extern consvar_t cv_grshearing;
extern consvar_t cv_grfov;
extern consvar_t cv_grmdls;
extern consvar_t cv_grfog;
extern consvar_t cv_grfogdensity;
extern consvar_t cv_grfiltermode;
extern consvar_t cv_granisotropicmode;
extern consvar_t cv_grcorrecttricks;
extern consvar_t cv_grfovchange;
extern consvar_t cv_grsolvetjoin;
extern consvar_t cv_grspritebillboarding;
extern consvar_t cv_grfakecontrast;
extern consvar_t cv_grslopecontrast;
extern consvar_t cv_grhorizonlines;
extern consvar_t cv_grfallbackplayermodel;
extern consvar_t cv_grbatching;
extern consvar_t cv_grrenderdistance;
extern consvar_t cv_grpaletterendering;
extern consvar_t cv_grpalettedepth;
extern consvar_t cv_grflashpal;
extern consvar_t cv_lightdither;
extern consvar_t cv_grscreentextures;
extern consvar_t cv_grportals;
extern consvar_t cv_nostencil;
extern consvar_t cv_secbright;
extern CV_PossibleValue_t granisotropicmode_cons_t[];
extern consvar_t cv_glmdls;
extern consvar_t cv_glfallbackplayermodel;
extern consvar_t cv_glspritebillboarding;
extern consvar_t cv_glshearing;
extern consvar_t cv_glfakecontrast;
extern consvar_t cv_glslopecontrast;
extern consvar_t cv_glshaders;
extern consvar_t cv_gllightdither;
extern consvar_t cv_glsecbright;
extern consvar_t cv_glfiltermode;
extern consvar_t cv_glanisotropicmode;
extern consvar_t cv_glsolvetjoin;
extern consvar_t cv_glbatching;
extern consvar_t cv_glrenderdistance;
extern consvar_t cv_glhorizonlines;
extern consvar_t cv_glportals;
extern consvar_t cv_glfovchange;
extern consvar_t cv_glpaletterendering;
extern consvar_t cv_glpalettedepth;
extern consvar_t cv_glflashpal;
#endif
+108 -110
View File
@@ -25,12 +25,14 @@
#include "../doomstat.h"
#ifdef HWRENDER
#include "hw_drv.h"
#include "hw_gl.h"
#include "hw_md2.h"
#include "../d_main.h"
#include "../r_bsp.h"
#include "../r_fps.h"
#include "../r_main.h"
#include "../p_setup.h"
#include "../m_misc.h"
#include "../w_wad.h"
#include "../z_zone.h"
@@ -43,8 +45,8 @@
#include "hw_main.h"
#include "../v_video.h"
#ifdef HAVE_PNG
#ifdef HAVE_PNG
#ifndef _MSC_VER
#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
@@ -147,7 +149,7 @@ static void PNG_warn(png_structp PNG, png_const_charp pngtext)
CONS_Debug(DBG_RENDER, "libpng warning at %p: %s", PNG, pngtext);
}
static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_t *grpatch)
static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_t *glpatch)
{
png_structp png_ptr;
png_infop png_info_ptr;
@@ -201,7 +203,7 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
//CONS_Debug(DBG_RENDER, "libpng load error on %s\n", filename);
png_destroy_read_struct(&png_ptr, &png_info_ptr, NULL);
fclose(png_FILE);
Z_Free(grpatch->mipmap->data);
Z_Free(glpatch->mipmap->data);
return 0;
}
#ifdef USE_FAR_KEYWORD
@@ -242,7 +244,7 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
{
png_uint_32 i, pitch = png_get_rowbytes(png_ptr, png_info_ptr);
png_bytep PNG_image = Z_Malloc(pitch*height, PU_HWRCACHE, &grpatch->mipmap->data);
png_bytep PNG_image = Z_Malloc(pitch*height, PU_HWRCACHE, &glpatch->mipmap->data);
png_bytepp row_pointers = png_malloc(png_ptr, height * sizeof (png_bytep));
for (i = 0; i < height; i++)
row_pointers[i] = PNG_image + i*pitch;
@@ -282,7 +284,7 @@ typedef struct
} PcxHeader;
static GLTextureFormat_t PCX_Load(const char *filename, int *w, int *h,
GLPatch_t *grpatch)
GLPatch_t *glpatch)
{
PcxHeader header;
#define PALSIZE 768
@@ -322,7 +324,7 @@ static GLTextureFormat_t PCX_Load(const char *filename, int *w, int *h,
pw = *w = header.xmax - header.xmin + 1;
ph = *h = header.ymax - header.ymin + 1;
image = Z_Malloc(pw*ph*4, PU_HWRCACHE, &grpatch->mipmap->data);
image = Z_Malloc(pw*ph*4, PU_HWRCACHE, &glpatch->mipmap->data);
if (fread(palette, sizeof (UINT8), PALSIZE, file) != PALSIZE)
{
@@ -364,43 +366,43 @@ static GLTextureFormat_t PCX_Load(const char *filename, int *w, int *h,
// -----------------+
static void md2_loadTexture(md2_t *model)
{
GLPatch_t *grpatch;
GLPatch_t *glpatch;
const char *filename = model->filename;
if (model->grpatch)
if (model->glpatch)
{
grpatch = model->grpatch;
Z_Free(grpatch->mipmap->data);
glpatch = model->glpatch;
Z_Free(glpatch->mipmap->data);
}
else
{
grpatch = Z_Calloc(sizeof *grpatch, PU_HWRPATCHINFO,
&(model->grpatch));
grpatch->mipmap = Z_Calloc(sizeof (GLMipmap_t), PU_HWRPATCHINFO, NULL);
glpatch = Z_Calloc(sizeof *glpatch, PU_HWRPATCHINFO,
&(model->glpatch));
glpatch->mipmap = Z_Calloc(sizeof (GLMipmap_t), PU_HWRPATCHINFO, NULL);
}
if (!grpatch->mipmap->downloaded && !grpatch->mipmap->data)
if (!glpatch->mipmap->downloaded && !glpatch->mipmap->data)
{
int w = 0, h = 0;
#ifdef HAVE_PNG
grpatch->mipmap->format = PNG_Load(filename, &w, &h, grpatch);
if (grpatch->mipmap->format == 0)
glpatch->mipmap->format = PNG_Load(filename, &w, &h, glpatch);
if (glpatch->mipmap->format == 0)
#endif
grpatch->mipmap->format = PCX_Load(filename, &w, &h, grpatch);
if (grpatch->mipmap->format == 0)
glpatch->mipmap->format = PCX_Load(filename, &w, &h, glpatch);
if (glpatch->mipmap->format == 0)
{
grpatch->notfound = true;// mark it so its not searched for again repeatedly
glpatch->notfound = true;// mark it so its not searched for again repeatedly
return;
}
grpatch->mipmap->downloaded = 0;
grpatch->mipmap->flags = 0;
glpatch->mipmap->downloaded = 0;
glpatch->mipmap->flags = 0;
grpatch->width = (INT16)w;
grpatch->height = (INT16)h;
grpatch->mipmap->width = (UINT16)w;
grpatch->mipmap->height = (UINT16)h;
glpatch->width = (INT16)w;
glpatch->height = (INT16)h;
glpatch->mipmap->width = (UINT16)w;
glpatch->mipmap->height = (UINT16)h;
// for palette rendering, color cube is applied in post-processing instead of here
if (!HWR_ShouldUsePaletteRendering())
@@ -408,7 +410,7 @@ static void md2_loadTexture(md2_t *model)
UINT32 size;
RGBA_t *image;
// Lactozilla: Apply colour cube
image = grpatch->mipmap->data;
image = glpatch->mipmap->data;
size = w*h;
while (size--)
{
@@ -417,8 +419,8 @@ static void md2_loadTexture(md2_t *model)
}
}
}
HWD.pfnSetTexture(grpatch->mipmap);
HWR_UnlockCachedPatch(grpatch);
GL_SetTexture(glpatch->mipmap);
HWR_UnlockCachedPatch(glpatch);
}
// -----------------+
@@ -426,49 +428,49 @@ static void md2_loadTexture(md2_t *model)
// -----------------+
static void md2_loadBlendTexture(md2_t *model)
{
GLPatch_t *grpatch;
GLPatch_t *glpatch;
char *filename = Z_Malloc(strlen(model->filename)+7, PU_STATIC, NULL);
strcpy(filename, model->filename);
FIL_ForceExtension(filename, "_blend.png");
if (model->blendgrpatch)
if (model->blendglpatch)
{
grpatch = model->blendgrpatch;
Z_Free(grpatch->mipmap->data);
glpatch = model->blendglpatch;
Z_Free(glpatch->mipmap->data);
}
else
{
grpatch = Z_Calloc(sizeof *grpatch, PU_HWRPATCHINFO,
&(model->blendgrpatch));
grpatch->mipmap = Z_Calloc(sizeof (GLMipmap_t), PU_HWRPATCHINFO, NULL);
glpatch = Z_Calloc(sizeof *glpatch, PU_HWRPATCHINFO,
&(model->blendglpatch));
glpatch->mipmap = Z_Calloc(sizeof (GLMipmap_t), PU_HWRPATCHINFO, NULL);
}
if (!grpatch->mipmap->downloaded && !grpatch->mipmap->data)
if (!glpatch->mipmap->downloaded && !glpatch->mipmap->data)
{
int w = 0, h = 0;
#ifdef HAVE_PNG
grpatch->mipmap->format = PNG_Load(filename, &w, &h, grpatch);
if (grpatch->mipmap->format == 0)
glpatch->mipmap->format = PNG_Load(filename, &w, &h, glpatch);
if (glpatch->mipmap->format == 0)
#endif
grpatch->mipmap->format = PCX_Load(filename, &w, &h, grpatch);
if (grpatch->mipmap->format == 0)
glpatch->mipmap->format = PCX_Load(filename, &w, &h, glpatch);
if (glpatch->mipmap->format == 0)
{
grpatch->notfound = true;// mark it so its not searched for again repeatedly
glpatch->notfound = true;// mark it so its not searched for again repeatedly
Z_Free(filename);
return;
}
grpatch->mipmap->downloaded = 0;
grpatch->mipmap->flags = 0;
glpatch->mipmap->downloaded = 0;
glpatch->mipmap->flags = 0;
grpatch->width = (INT16)w;
grpatch->height = (INT16)h;
grpatch->mipmap->width = (UINT16)w;
grpatch->mipmap->height = (UINT16)h;
glpatch->width = (INT16)w;
glpatch->height = (INT16)h;
glpatch->mipmap->width = (UINT16)w;
glpatch->mipmap->height = (UINT16)h;
}
HWD.pfnSetTexture(grpatch->mipmap); // We do need to do this so that it can be cleared and knows to recreate it when necessary
HWR_UnlockCachedPatch(grpatch);
GL_SetTexture(glpatch->mipmap); // We do need to do this so that it can be cleared and knows to recreate it when necessary
HWR_UnlockCachedPatch(glpatch);
Z_Free(filename);
}
@@ -489,7 +491,7 @@ void HWR_InitMD2(void)
{
md2_playermodels[s].scale = -1.0f;
md2_playermodels[s].model = NULL;
md2_playermodels[s].grpatch = NULL;
md2_playermodels[s].glpatch = NULL;
md2_playermodels[s].skin = -1;
md2_playermodels[s].notfound = true;
md2_playermodels[s].error = false;
@@ -498,7 +500,7 @@ void HWR_InitMD2(void)
{
md2_localplayermodels[s].scale = -1.0f;
md2_localplayermodels[s].model = NULL;
md2_localplayermodels[s].grpatch = NULL;
md2_localplayermodels[s].glpatch = NULL;
md2_localplayermodels[s].skin = -1;
md2_localplayermodels[s].notfound = true;
md2_localplayermodels[s].error = false;
@@ -507,7 +509,7 @@ void HWR_InitMD2(void)
{
md2_models[i].scale = -1.0f;
md2_models[i].model = NULL;
md2_models[i].grpatch = NULL;
md2_models[i].glpatch = NULL;
md2_models[i].skin = -1;
md2_models[i].notfound = true;
md2_models[i].error = false;
@@ -680,7 +682,7 @@ spritemd2found:
#define SETBRIGHTNESS(brightness,r,g,b) \
brightness = (UINT8)(((1063*(UINT32)(r))/5000) + ((3576*(UINT32)(g))/5000) + ((361*(UINT32)(b))/5000))
static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, GLMipmap_t *grmip, INT32 skinnum, skincolors_t color)
static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, GLMipmap_t *glMipmap, INT32 skinnum, skincolors_t color)
{
UINT16 w = gpatch->width, h = gpatch->height;
UINT32 size = w*h;
@@ -696,24 +698,24 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch,
memset(translation, 0, sizeof(translation));
memset(cutoff, 0, sizeof(cutoff));
if (grmip->width == 0)
if (glMipmap->width == 0)
{
grmip->width = gpatch->width;
grmip->height = gpatch->height;
glMipmap->width = gpatch->width;
glMipmap->height = gpatch->height;
// no wrap around, no chroma key
grmip->flags = 0;
glMipmap->flags = 0;
// setup the texture info
grmip->format = GL_TEXFMT_RGBA;
glMipmap->format = GL_TEXFMT_RGBA;
}
if (grmip->data)
if (glMipmap->data)
{
Z_Free(grmip->data);
grmip->data = NULL;
Z_Free(glMipmap->data);
glMipmap->data = NULL;
}
cur = Z_Malloc(size*4, PU_HWRCACHE, &grmip->data);
cur = Z_Malloc(size*4, PU_HWRCACHE, &glMipmap->data);
memset(cur, 0x00, size*4);
image = gpatch->mipmap->data;
@@ -794,10 +796,9 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch,
}
}
}
}
if (translen > 0)
colorbrightnesses[translen] = colorbrightnesses[translen-1];
}
while (size--)
{
@@ -1044,28 +1045,29 @@ skippixel:
static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT32 skinnum, const UINT8 *colormap, skincolors_t color)
{
// mostly copied from HWR_GetMappedPatch, hence the similarities and comment
GLMipmap_t *grmip, *newmip;
GLMipmap_t *glMipmap, *newMipmap;
if (colormap == colormaps || colormap == NULL)
{
// Don't do any blending
HWD.pfnSetTexture(gpatch->mipmap);
GL_SetTexture(gpatch->mipmap);
return;
}
// search for the mimmap
// search for the Mipmap
// skip the first (no colormap translated)
for (grmip = gpatch->mipmap; grmip->nextcolormap; )
for (glMipmap = gpatch->mipmap; glMipmap->nextcolormap; )
{
grmip = grmip->nextcolormap;
if (grmip->colormap == colormap)
glMipmap = glMipmap->nextcolormap;
if (glMipmap->colormap != colormap)
continue;
if (glMipmap->downloaded && glMipmap->data)
{
if (grmip->downloaded && grmip->data)
{
HWD.pfnSetTexture(grmip); // found the colormap, set it to the correct texture
Z_ChangeTag(grmip->data, PU_HWRCACHE_UNLOCKED);
return;
}
GL_SetTexture(glMipmap); // found the colormap, set it to the correct texture
Z_ChangeTag(glMipmap->data, PU_HWRCACHE_UNLOCKED);
return;
}
}
@@ -1076,26 +1078,25 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT
// (it have a liste of mipmap)
// this malloc is cleared in HWR_FreeTextureCache
// (...) unfortunately z_malloc fragment alot the memory :(so malloc is better
newmip = calloc(1, sizeof (*newmip));
if (newmip == NULL)
newMipmap = calloc(1, sizeof (*newMipmap));
if (newMipmap == NULL)
I_Error("%s: Out of memory", "HWR_GetMappedPatch");
grmip->nextcolormap = newmip;
newmip->colormap = colormap;
glMipmap->nextcolormap = newMipmap;
newMipmap->colormap = colormap;
HWR_CreateBlendedTexture(gpatch, blendgpatch, newmip, skinnum, color);
HWR_CreateBlendedTexture(gpatch, blendgpatch, newMipmap, skinnum, color);
HWD.pfnSetTexture(newmip);
Z_ChangeTag(newmip->data, PU_HWRCACHE_UNLOCKED);
GL_SetTexture(newMipmap);
Z_ChangeTag(newMipmap->data, PU_HWRCACHE_UNLOCKED);
}
// -----------------+
// HWR_DrawMD2 : Draw MD2
// :
// Returns :
// -----------------+
void HWR_DrawMD2(gr_vissprite_t *spr)
void HWR_DrawMD2(gl_vissprite_t *spr)
{
md2_t *md2;
@@ -1105,7 +1106,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
FTransform p;
FSurfaceInfo Surf;
if (!cv_grmdls.value)
if (!cv_glmdls.value)
return;
if (spr->precip)
@@ -1164,7 +1165,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
angle_t ang;
interpmobjstate_t interp;
if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || R_QuickCamDist(spr->mobj->x, spr->mobj->y) < cv_grmaxinterpdist.value))
if (R_UsingFrameInterpolation() && !paused && (!cv_maxinterpdist.value || R_QuickCamDist(spr->mobj->x, spr->mobj->y) < cv_maxinterpdist.value))
{
R_InterpolateMobjState(spr->mobj, rendertimefrac, &interp);
}
@@ -1234,7 +1235,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
if (md2->model)
{
md2_printModelInfo(md2->model);
HWD.pfnCreateModelVBOs(md2->model);
GL_CreateModelVBOs(md2->model);
}
else
{
@@ -1244,22 +1245,22 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
}
}
//Hurdler: arf, I don't like that implementation at all... too much crappy
gpatch = md2->grpatch;
gpatch = md2->glpatch;
if (!gpatch || ((!gpatch->mipmap->format || !gpatch->mipmap->downloaded) && !gpatch->notfound))
md2_loadTexture(md2);
gpatch = md2->grpatch; // Load it again, because it isn't being loaded into gpatch after md2_loadtexture...
gpatch = md2->glpatch; // Load it again, because it isn't being loaded into gpatch after md2_loadtexture...
if ((gpatch && gpatch->mipmap->format) // don't load the blend texture if the base texture isn't available
&& (!md2->blendgrpatch
|| ((!((GLPatch_t *)md2->blendgrpatch)->mipmap->format || !((GLPatch_t *)md2->blendgrpatch)->mipmap->downloaded)
&& !((GLPatch_t *)md2->blendgrpatch)->notfound)))
&& (!md2->blendglpatch
|| ((!((GLPatch_t *)md2->blendglpatch)->mipmap->format || !((GLPatch_t *)md2->blendglpatch)->mipmap->downloaded)
&& !((GLPatch_t *)md2->blendglpatch)->notfound)))
md2_loadBlendTexture(md2);
if (gpatch && gpatch->mipmap->format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture
{
if ((skincolors_t)spr->mobj->color != SKINCOLOR_NONE &&
md2->blendgrpatch && ((GLPatch_t *)md2->blendgrpatch)->mipmap->format
&& gpatch->width == ((GLPatch_t *)md2->blendgrpatch)->width && gpatch->height == ((GLPatch_t *)md2->blendgrpatch)->height)
md2->blendglpatch && ((GLPatch_t *)md2->blendglpatch)->mipmap->format
&& gpatch->width == ((GLPatch_t *)md2->blendglpatch)->width && gpatch->height == ((GLPatch_t *)md2->blendglpatch)->height)
{
INT32 tcskinnum = TC_DEFAULT;
if ((spr->mobj->flags & MF_BOSS) && (spr->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash"
@@ -1284,12 +1285,12 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
}
else tcskinnum = TC_DEFAULT;
}
HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendgrpatch, tcskinnum, spr->colormap, (skincolors_t)spr->mobj->color);
HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendglpatch, tcskinnum, spr->colormap, (skincolors_t)spr->mobj->color);
}
else
{
// This is safe, since we know the texture has been downloaded
HWD.pfnSetTexture(gpatch->mipmap);
GL_SetTexture(gpatch->mipmap);
}
}
else
@@ -1313,7 +1314,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
// Interpolate the model interpolation. (lol)
tics -= FixedToFloat(rendertimefrac);
if (cv_grmdls.value == 1 && tics <= durs)
if (cv_glmdls.value == 1 && tics <= durs)
{
// frames are handled differently for states with FF_ANIMATE, so get the next frame differently for the interpolation
if (spr->mobj->frame & FF_ANIMATE)
@@ -1370,19 +1371,16 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
p.spritexscale = FIXED_TO_FLOAT(spr->mobj->spritexscale);
p.spriteyscale = FIXED_TO_FLOAT(spr->mobj->spriteyscale);
angle_t sliptideroll = 0;
if (spr->mobj->player)
sliptideroll = ((cv_sloperoll.value && cv_sliptideroll.value) ? spr->mobj->player->sliproll : 0);
angle_t sliptideroll = ((cv_sloperoll.value && cv_sliptideroll.value && spr->mobj->player) ? spr->mobj->player->sliproll : 0);
if ((spr->mobj->rollangle)||(sliptideroll && cv_sliptideroll.value))
if (spr->mobj->rollangle || sliptideroll)
{
angle_t rollang = 0;
rollfactor = ((spr->mobj->rollmodel == true) ? 1 : 0);
rollang = (spr->mobj->player && sliptideroll && cv_sliptideroll.value)
? (spr->mobj->rollangle * rollfactor) + (sliptideroll * spr->mobj->player->sliptidemem)
rollang = sliptideroll
? (spr->mobj->rollangle * rollfactor) + (sliptideroll * spr->mobj->player->kartstuff[k_aizdriftstrat])
: (spr->mobj->rollangle * rollfactor);
fixed_t anglef = AngleFixed(rollang);
@@ -1465,7 +1463,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
p.mirror = atransform.mirror; // from Kart
#endif
HWD.pfnSetShader(SHADER_MODEL); // model shader
GL_SetShader(SHADER_MODEL); // model shader
{
SINT8 flipfactor = flip ? -1 : 1;
@@ -1478,11 +1476,11 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
float oy = ys * flipfactor*FIXED_TO_FLOAT(interp.spriteyoffset);
// offset perpendicular to the camera angle
p.x -= ox * gr_viewsin;
p.y += ox * gr_viewcos;
p.x -= ox * gl_viewsin;
p.y += ox * gl_viewcos;
p.z += oy;
HWD.pfnDrawModel(md2->model, frame, durs, tics, nextFrame, &p, md2->scale * xs, md2->scale * ys, flip, hflip, &Surf);
GL_DrawModel(md2->model, frame, durs, tics, nextFrame, &p, md2->scale * xs, md2->scale * ys, flip, hflip, &Surf);
}
}
}
+3 -3
View File
@@ -28,8 +28,8 @@ typedef struct
float scale;
float offset;
model_t *model;
void *grpatch;
void *blendgrpatch;
void *glpatch;
void *blendglpatch;
boolean notfound;
INT32 skin;
boolean error;
@@ -40,7 +40,7 @@ extern md2_t md2_playermodels[MAXSKINS];
extern md2_t md2_localplayermodels[MAXLOCALSKINS];
void HWR_InitMD2(void);
void HWR_DrawMD2(gr_vissprite_t *spr);
void HWR_DrawMD2(gl_vissprite_t *spr);
void HWR_AddPlayerMD2(INT32 skin, boolean local);
void HWR_AddSpriteMD2(size_t spritenum);
+231
View File
@@ -0,0 +1,231 @@
// SONIC ROBO BLAST 2 KART
//-----------------------------------------------------------------------------
// Copyright (C) 2024 by Kart Krew.
// Copyright (C) 2020 by Sonic Team Junior.
// Copyright (C) 2000 by DooM Legacy Team.
// Copyright (C) 1996 by id Software, Inc.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file hw_portal.c
/// \brief OpenGL renderer portals.
// ==========================================================================
// Visual portals (attr. Hannu Hanhi)
// ==========================================================================
#ifdef HWRENDER
#include "../r_portal.h"
#include "../z_zone.h"
#include "hw_clip.h"
#include "hw_gl.h"
#include "hw_defs.h"
#include "hw_main.h"
#include "hw_portal.h"
SINT8 gl_portal_state = GLPORTAL_OFF;
gl_portallist_t *currentportallist;
// clip the area outside the portal destination window
void HWR_PortalClipping(gl_portal_t *portal)
{
gld_clipper_SafeAddClipRange(portal->angle1, portal->angle2);
}
static gl_portal_t* HWR_Portal_Add (seg_t *seg)
{
gl_portal_t *portal = Z_Malloc(sizeof(gl_portal_t), PU_STATIC, NULL);
// Linked list.
if (!currentportallist->base)
{
currentportallist->base = portal;
currentportallist->cap = portal;
}
else
{
currentportallist->cap->next = portal;
currentportallist->cap = portal;
}
portal->next = NULL;
portal->seg = seg;
return portal;
}
void HWR_FreePortalList(gl_portallist_t freelist)
{
portalcullsector = NULL;
// free memory from portal list allocated by calls to Add2Lines
gl_portal_t *gl_portal_temp = freelist.base;
while (gl_portal_temp)
{
gl_portal_t *nextportal = gl_portal_temp->next;
Z_Free(gl_portal_temp);
gl_portal_temp = nextportal;
}
}
void HWR_Portal_Add2Lines(const INT32 line1, const INT32 line2, seg_t *seg)
{
gl_portal_t *portal = HWR_Portal_Add(seg);
// Offset the portal view by the linedef centers
line_t* start = &lines[line1];
line_t* dest = &lines[line2];
angle_t dangle = R_PointToAngle2(0, 0, dest->dx, dest->dy) - R_PointToAngle2(start->dx, start->dy, 0, 0);
fixed_t disttopoint;
angle_t angtopoint;
vertex_t dest_c, start_c;
// looking glass center
start_c.x = start->v1->x/2 + start->v2->x/2;
start_c.y = start->v1->y/2 + start->v2->y/2;
// other side center
dest_c.x = dest->v1->x/2 + dest->v2->x/2;
dest_c.y = dest->v1->y/2 + dest->v2->y/2;
disttopoint = R_PointToDist2(start_c.x, start_c.y, viewx, viewy);
angtopoint = R_PointToAngle2(start_c.x, start_c.y, viewx, viewy);
angtopoint += dangle;
portal->viewx = dest_c.x + FixedMul(FINECOSINE(angtopoint>>ANGLETOFINESHIFT), disttopoint);
portal->viewy = dest_c.y + FixedMul(FINESINE(angtopoint>>ANGLETOFINESHIFT), disttopoint);
portal->viewz = viewz + dest->frontsector->floorheight - start->frontsector->floorheight;
portal->viewangle = viewangle + dangle;
portal->angle1 = R_PointToAngle64(seg->v1->x, seg->v1->y) + dangle;
portal->angle2 = R_PointToAngle64(seg->v2->x, seg->v2->y) + dangle;
portal->clipline = line2;
}
void HWR_PortalFrame(gl_portal_t* portal)
{
viewx = portal->viewx;
viewy = portal->viewy;
viewz = portal->viewz;
viewangle = portal->viewangle;
//viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT);
//viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT);
if (portal->clipline != -1)
{
portalclipline = &lines[portal->clipline];
portalcullsector = portalclipline->frontsector;
viewsector = portalclipline->frontsector;
}
else
{
portalclipline = NULL;
portalcullsector = NULL;
viewsector = R_PointInSubsectorFast(viewx, viewy)->sector;
}
}
// Renders a portal segment.
static void HWR_RenderPortalSeg(gl_portal_t* portal, SINT8 state)
{
gl_drawing_stencil = true; // do not draw outside of the stencil buffer, idiot.
// set our portal state and prepare to render the seg
HWR_SetPortalState(state);
gl_curline = portal->seg;
gl_frontsector = portal->seg->frontsector;
gl_backsector = portal->seg->backsector;
HWR_ProcessSeg();
gl_drawing_stencil = false;
// need to work around the r_opengl PF_Invisible bug with this call
// similarly as in the linkdraw hack in HWR_DrawSprites
GL_SetBlend(PF_Translucent|PF_Occlude|PF_Masked);
}
// Renders a single portal from the current viewpoint.
void HWR_RenderPortal(gl_portal_t* portal, gl_portal_t* rootportal, const float fpov, player_t *player, int stencil_level)
{
// draw portal seg to stencil buffer with increment
HWR_SetTransform(fpov, player);
HWR_ClearClipper();
HWR_SetStencilState(HWR_STENCIL_BEGIN, stencil_level);
HWR_RenderPortalSeg(portal, GLPORTAL_STENCIL);
// go to portal frame lmao
HWR_PortalFrame(portal);
// call HWR_RenderViewpoint
HWR_RenderViewpoint(portal, fpov, player, stencil_level + 1, true);
// return to current frame
if (rootportal)
HWR_PortalFrame(rootportal);
else // current frame is not a portal frame but the main view!
{
R_SetupFrame(viewssnum, false);
portalclipline = NULL;
}
// remove portal seg from stencil buffer
HWR_SetTransform(fpov, player);
HWR_ClearClipper();
HWR_SetStencilState(HWR_STENCIL_REVERSE, stencil_level);
HWR_RenderPortalSeg(portal, GLPORTAL_STENCIL);
// draw portal seg to depth buffer
HWR_ClearClipper();
HWR_SetStencilState(HWR_STENCIL_DEPTH, stencil_level);
HWR_RenderPortalSeg(portal, GLPORTAL_DEPTH);
}
// returns true if the point is on the correct (viewable) side of the
// portal destination line
boolean HWR_PortalCheckPointSide(fixed_t x, fixed_t y)
{
// we are checking if the point is on the viewable side of the portal exit.
// being exactly on the portal exit line is not enough to pass the test.
// P_PointOnLineSide could behave differently from this expectation on this case,
// so first check if the point is precisely on the line, and then if not, check the side.
vertex_t closest_point;
P_ClosestPointOnLine(x, y, portalclipline, &closest_point);
if (closest_point.x != x || closest_point.y != y)
{
if (P_PointOnLineSide(x, y, portalclipline) != 1)
return true;
}
return false;
}
boolean HWR_PortalCheckBBox(const fixed_t *bspcoord)
{
if (!portalclipline)
return true;
if (HWR_PortalCheckPointSide(bspcoord[BOXLEFT], bspcoord[BOXTOP]) ||
HWR_PortalCheckPointSide(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM]) ||
HWR_PortalCheckPointSide(bspcoord[BOXRIGHT], bspcoord[BOXTOP]) ||
HWR_PortalCheckPointSide(bspcoord[BOXRIGHT], bspcoord[BOXBOTTOM]))
{
return true;
}
// we did not find any reason to pass the check, so return failure
return false;
}
#endif
+81
View File
@@ -0,0 +1,81 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2018 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file hw_portal.h
/// \brief OpenGL renderer portal struct, functions, linked list extern.
#ifndef __HW_PORTAL__
#define __HW_PORTAL__
#ifdef HWRENDER
#include "../doomstat.h"
#include "../r_data.h"
#include "../r_bsp.h"
/** Portal structure.
*/
enum
{
GLPORTAL_OFF,
GLPORTAL_SEARCH,
GLPORTAL_STENCIL,
GLPORTAL_DEPTH,
GLPORTAL_INSIDE,
};
typedef struct gl_portal_s
{
struct gl_portal_s *next;
// Viewport.
fixed_t viewx;
fixed_t viewy;
fixed_t viewz;
angle_t viewangle;
seg_t *seg; // seg that is used for drawing to the stencil buffer
INT32 clipline; // Optional clipline for line-based portals
// angles for the left and right edges of the portal
// relative to the viewpoint
angle_t angle1;
angle_t angle2;
} gl_portal_t;
typedef struct gl_portallist_s
{
gl_portal_t *base;
gl_portal_t *cap;
} gl_portallist_t;
extern SINT8 gl_portal_state;
// new thing
extern gl_portallist_t *currentportallist;
static inline void HWR_SetPortalState (SINT8 state)
{
gl_portal_state = state;
}
// Adds an entry to the clipper for portal rendering
void HWR_PortalClipping(gl_portal_t *portal);
void HWR_Portal_Add2Lines(const INT32 line1, const INT32 line2, seg_t *seg);
void HWR_PortalFrame(gl_portal_t* portal);
void HWR_RenderPortal(gl_portal_t* portal, gl_portal_t* rootportal, const float fpov, player_t *player, int stencil_level);
void HWR_FreePortalList(gl_portallist_t portallist);
boolean HWR_PortalCheckPointSide(fixed_t x, fixed_t y);
boolean HWR_PortalCheckBBox(const fixed_t *bspcoord);
#endif
#endif
+14 -18
View File
@@ -13,7 +13,7 @@
#include "hw_main.h"
#include "hw_glob.h"
#include "hw_drv.h"
#include "hw_gl.h"
#include "hw_shaders.h"
#include "../z_zone.h"
@@ -25,13 +25,10 @@ static struct {
const char *vertex;
const char *fragment;
} const gl_shadersources[] = {
// Floor shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_FLOOR_FRAGMENT_SHADER},
// Shadow shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_SHADOW_FRAGMENT_SHADER},
// Wall shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER},
@@ -52,7 +49,7 @@ static struct {
// Palette postprocess shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_PALETTE_POSTPROCESS_FRAGMENT_SHADER},
// UI colormap fade shader
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_UI_COLORMAP_FADE_FRAGMENT_SHADER},
@@ -90,7 +87,7 @@ boolean HWR_InitShaders(void)
{
int i;
if (!HWD.pfnInitShaders())
if (!GL_InitShaders())
return false;
for (i = 0; i < NUMSHADERTARGETS; i++)
@@ -279,11 +276,11 @@ static char *HWR_PreprocessShader(char *original)
// Calculate length of modified shader.
new_len = original_len;
if (cv_grpaletterendering.value)
if (cv_glpaletterendering.value)
ADD_TO_LEN(PALETTE_RENDERING_DEFINE)
if (cv_lightdither.value)
if (cv_gllightdither.value)
ADD_TO_LEN(LIGHT_DITHERING_DEFINE)
#undef ADD_TO_LEN
@@ -324,10 +321,10 @@ static char *HWR_PreprocessShader(char *original)
}
// Write the defines.
if (cv_grpaletterendering.value)
if (cv_glpaletterendering.value)
WRITE_DEFINE(PALETTE_RENDERING_DEFINE)
if (cv_lightdither.value)
if (cv_gllightdither.value)
WRITE_DEFINE(LIGHT_DITHERING_DEFINE)
#undef WRITE_DEFINE
@@ -369,16 +366,16 @@ static void HWR_CompileShader(int index)
{
char *preprocessed = HWR_PreprocessShader(vertex_source);
if (!preprocessed) return;
HWD.pfnLoadShader(index, preprocessed, HWD_SHADERSTAGE_VERTEX);
GL_LoadShader(index, preprocessed, HWD_SHADERSTAGE_VERTEX);
}
if (fragment_source)
{
char *preprocessed = HWR_PreprocessShader(fragment_source);
if (!preprocessed) return;
HWD.pfnLoadShader(index, preprocessed, HWD_SHADERSTAGE_FRAGMENT);
GL_LoadShader(index, preprocessed, HWD_SHADERSTAGE_FRAGMENT);
}
gl_shaders[index].compiled = HWD.pfnCompileShader(index);
gl_shaders[index].compiled = GL_CompileShader(index);
}
// compile or recompile shaders
@@ -410,7 +407,7 @@ int HWR_GetShaderFromTarget(int shader_target)
// - custom shaders are enabled
// - custom shaders are allowed by the server
if (custom_shader != -1 && gl_shaders[custom_shader].compiled &&
cv_grshaders.value == 1)
cv_glshaders.value == 1)
return custom_shader;
else
return gl_shadertargets[shader_target].base_shader;
@@ -432,7 +429,6 @@ static inline UINT16 HWR_FindShaderDefs(UINT16 wadnum)
customshaderxlat_t shaderxlat[] =
{
{"Flat", SHADER_FLOOR},
{"Shadow", SHADER_SHADOW},
{"WallTexture", SHADER_WALL},
{"Sprite", SHADER_SPRITE},
{"Model", SHADER_MODEL},
@@ -565,7 +561,7 @@ void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3)
int i;
boolean modified_shaders[NUMSHADERTARGETS] = {0};
if (!gr_shadersavailable)
if (!gl_shadersavailable)
return;
lump = HWR_FindShaderDefs(wadnum);
+2 -5
View File
@@ -99,6 +99,7 @@
GLSL_DOOM_COLORMAP_NODITHER \
"#endif\n" \
"}\n"
// lighting cap adjustment:
// first num (155.0), increase to make it start to go dark sooner
// second num (0.26), increase to make it go dark faster
@@ -171,7 +172,7 @@
"gl_FragColor = final_color;\n" \
"}\n" \
"#endif\0"
#define GLSL_SOFTWARE_FRAGMENT_SHADER_NOPAL \
"uniform sampler2D tex;\n" \
"uniform vec4 poly_color;\n" \
@@ -210,10 +211,6 @@
#define GLSL_WALL_FRAGMENT_SHADER \
GLSL_WALL_FUDGES \
GLSL_SOFTWARE_FRAGMENT_SHADER
#define GLSL_SHADOW_FRAGMENT_SHADER \
GLSL_FLOOR_FUDGES \
GLSL_SOFTWARE_FRAGMENT_SHADER_NOPAL
//
// Water surface shader
+3 -22
View File
@@ -358,8 +358,8 @@ static INT32 WINAPI SetRes(viddef_t *lvid, vmode_t *pcurrentmode)
else
textureformatGL = GL_RGB5_A1;
SetModelView(lvid->width, lvid->height);
SetStates();
GL_SetModelView(lvid->width, lvid->height);
GL_SetStates();
// we need to clear the depth buffer. Very important!!!
pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
@@ -526,7 +526,7 @@ EXPORT void HWRAPI(Shutdown) (void)
// -----------------+
// FinishUpdate : Swap front and back buffers
// -----------------+
EXPORT void HWRAPI(FinishUpdate) (INT32 waitvbl)
void GL_FinishUpdate (INT32 waitvbl)
{
#ifdef USE_WGL_SWAP
static INT32 oldwaitvbl = 0;
@@ -547,23 +547,4 @@ EXPORT void HWRAPI(FinishUpdate) (INT32 waitvbl)
SwapBuffers(hDC);
}
// -----------------+
// SetPalette : Set the color lookup table for paletted textures
// : in OpenGL, we store values for conversion of paletted graphics when
// : they are downloaded to the 3D card.
// -----------------+
EXPORT void HWRAPI(SetPalette) (RGBA_t *pal)
{
INT32 i;
for (i = 0; i < 256; i++)
{
myPaletteData[i].s.red = pal[i].s.red;
myPaletteData[i].s.green = pal[i].s.green;
myPaletteData[i].s.blue = pal[i].s.blue;
myPaletteData[i].s.alpha = pal[i].s.alpha;
}
}
#endif
File diff suppressed because it is too large. Load diff
+14 -14
View File
@@ -43,8 +43,9 @@
#endif
#define _CREATE_DLL_ // necessary for Unix AND Windows
#include "../../doomdef.h"
#include "../hw_drv.h"
#include "../hw_gl.h"
#include "../../z_zone.h"
// ==========================================================================
@@ -65,14 +66,15 @@ extern FILE *gllogstream;
// PROTOS
// ==========================================================================
boolean LoadGL(void);
FUNCPRINTF void GL_DBG_Printf(const char *format, ...);
void *GetGLFunc(const char *proc);
boolean SetupGLfunc(void);
void SetupGLFunc4(void);
void Flush(void);
INT32 isExtAvailable(const char *extension, const GLubyte *start);
void SetModelView(GLint w, GLint h);
void SetStates(void);
void GL_Flush(void);
INT32 GL_isExtAvailable(const char *extension, const GLubyte *start);
void GL_SetModelView(GLint w, GLint h);
void GL_SetStates(void);
#ifndef GL_EXT_texture_filter_anisotropic
#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
@@ -98,18 +100,14 @@ typedef void (APIENTRY * PFNglGetIntegerv) (GLenum pname, GLint *params);
extern PFNglGetIntegerv pglGetIntegerv;
typedef const GLubyte* (APIENTRY * PFNglGetString) (GLenum name);
extern PFNglGetString pglGetString;
#if 0
typedef void (APIENTRY * PFNglEnableClientState) (GLenum cap); // redefined in r_opengl.c
static PFNglEnableClientState pglEnableClientState;
#endif
#endif
#ifdef USE_FBO_OGL
void GLFramebuffer_DeleteAttachments(void);
void GL_Framebuffer_DeleteAttachments(void);
void GLFramebuffer_Unbind(void);
void GLFramebuffer_Enable(void);
void GLFramebuffer_Disable(void);
void GL_Framebuffer_Unbind(void);
void GL_Framebuffer_Enable(void);
void GL_Framebuffer_Disable(void);
extern GLuint FramebufferObject, FramebufferTexture, RenderbufferObject;
extern GLboolean FrameBufferEnabled, RenderToFramebuffer;
@@ -123,6 +121,8 @@ extern boolean supportFBO;
extern const GLubyte *gl_version;
extern const GLubyte *gl_renderer;
extern const GLubyte *gl_extensions;
extern const GLubyte *gl_vendor;
extern GLuint gl_num_extensions;
extern int majorGL, minorGL;
+18 -18
View File
@@ -289,7 +289,7 @@ int
HMS_register (void)
{
struct HMS_buffer *hms;
int ok;
int okay;
char post[256];
@@ -316,23 +316,23 @@ HMS_register (void)
curl_easy_setopt(hms->curl, CURLOPT_POSTFIELDS, post);
ok = HMS_do(hms);
okay = HMS_do(hms);
if (ok)
if (okay)
{
hms_server_token = strdup(strtok(hms->buffer, "\n"));
}
HMS_end(hms);
return ok;
return okay;
}
int
HMS_unlist (void)
{
struct HMS_buffer *hms;
int ok;
int okay;
hms = HMS_connect("servers/%s/unlist", hms_server_token);
@@ -342,19 +342,19 @@ HMS_unlist (void)
curl_easy_setopt(hms->curl, CURLOPT_POST, 1);
curl_easy_setopt(hms->curl, CURLOPT_POSTFIELDSIZE, 0);
ok = HMS_do(hms);
okay = HMS_do(hms);
HMS_end(hms);
free(hms_server_token);
return ok;
return okay;
}
int
HMS_update (void)
{
struct HMS_buffer *hms;
int ok;
int okay;
char post[256];
@@ -376,10 +376,10 @@ HMS_update (void)
curl_easy_setopt(hms->curl, CURLOPT_POSTFIELDS, post);
ok = HMS_do(hms);
okay = HMS_do(hms);
HMS_end(hms);
return ok;
return okay;
}
void
@@ -488,7 +488,7 @@ int
HMS_compare_mod_version (char *buffer, size_t buffer_size)
{
struct HMS_buffer *hms;
int ok;
int okay;
char *version;
char *version_name;
@@ -498,7 +498,7 @@ HMS_compare_mod_version (char *buffer, size_t buffer_size)
if (! hms)
return 0;
ok = 0;
okay = 0;
if (HMS_do(hms))
{
@@ -510,16 +510,16 @@ HMS_compare_mod_version (char *buffer, size_t buffer_size)
if (atoi(version) != MODVERSION)
{
strlcpy(buffer, version_name, buffer_size);
ok = 1;
okay = 1;
}
else
ok = -1;
okay = -1;
}
}
HMS_end(hms);
return ok;
return okay;
}
const char *
@@ -532,9 +532,9 @@ HMS_fetch_rules (char *buffer, size_t buffer_size)
if (! hms)
return NULL;
boolean ok = HMS_do(hms);
boolean okay = HMS_do(hms);
if (ok)
if (okay)
{
char *p = strstr(hms->buffer, "\n\n");
@@ -552,7 +552,7 @@ HMS_fetch_rules (char *buffer, size_t buffer_size)
HMS_end(hms);
if (!ok)
if (!okay)
return NULL;
return buffer;
+4 -3
View File
@@ -1003,7 +1003,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
// run the lua hook even if we were supposed to eat the msg, netgame consistency goes first.
if (LUAh_PlayerMsg(playernum, target, flags, msg, spam_eatmsg))
if (LUA_HookPlayerMsg(playernum, target, flags, msg, spam_eatmsg))
return;
if (spam_eatmsg)
@@ -2274,7 +2274,7 @@ void HU_Drawer(void)
if (renderisnewtic)
{
LUA_HUD_ClearDrawList(luahuddrawlist_scores);
LUAh_ScoresHUD(luahuddrawlist_scores);
LUA_HUDHOOK(scores, luahuddrawlist_scores);
}
LUA_HUD_DrawList(luahuddrawlist_scores);
@@ -2617,7 +2617,8 @@ static void HU_DrawRankings(void)
boolean completed[MAXPLAYERS];
UINT32 whiteplayer = MAXPLAYERS;
V_DrawFadeScreen(0xFF00, 16); // A little more readable, and prevents cheating the fades under other circumstances.
if (!automapactive)
V_DrawFadeScreen(0xFF00, 16); // A little more readable, and prevents cheating the fades under other circumstances.
if (cons_menuhighlight.value)
hilicol = cons_menuhighlight.value;
+1 -1
View File
@@ -53,6 +53,6 @@ typedef struct JoyType_s JoyType_t;
for palyer[sic] 1-4's joystick/gamepad
*/
extern JoyType_t Joystick, Joystick2, Joystick3, Joystick4;
extern JoyType_t Joystick[MAXSPLITSCREENPLAYERS];
#endif // __I_JOY_H__
-8
View File
@@ -82,18 +82,10 @@ extern holepunch_t *holepunchpacket;
*/
extern boolean (*I_NetGet)(void);
/** \brief ask to driver if there is data waiting
*/
extern boolean (*I_NetCanGet)(void);
/** \brief send packet within doomcom struct
*/
extern void (*I_NetSend)(void);
/** \brief ask to driver if all is ok to send data now
*/
extern boolean (*I_NetCanSend)(void);
/** \brief close a connection
\param nodenum node to be closed
+7 -15
View File
@@ -202,9 +202,13 @@ void I_JoyScale4(void);
// Called by D_SRB2Main.
/** \brief to startup joystick
*/
void I_InitJoystick(UINT8 index);
/** \brief to startup the first joystick
*/
void I_InitJoystick(void);
void I_InitJoystick1(void);
/** \brief to startup the second joystick
*/
@@ -307,21 +311,9 @@ INT32 I_mkdir(const char *dirname, INT32 unixright);
*/
const char *I_LocateWad(void);
/** \brief First Joystick's events
/** \brief Joystick events
*/
void I_GetJoystickEvents(void);
/** \brief Second Joystick's events
*/
void I_GetJoystick2Events(void);
/** \brief Third Joystick's events
*/
void I_GetJoystick3Events(void);
/** \brief Fourth Joystick's events
*/
void I_GetJoystick4Events(void);
void I_GetJoystickEvents(UINT8 index);
/** \brief Mouses events
*/
+6 -75
View File
@@ -168,7 +168,6 @@ static UINT8 UPNP_support = TRUE;
#endif
#include "i_addrinfo.h"
#define SELECTTEST
#define DEFAULTPORT "5029"
@@ -750,59 +749,6 @@ static boolean SOCK_Get(void)
}
#endif
// check if we can send (do not go over the buffer)
#ifndef NONET
static fd_set masterset;
#ifdef SELECTTEST
static boolean FD_CPY(fd_set *src, fd_set *dst, SOCKET_TYPE *fd, size_t len)
{
size_t i;
boolean testset = false;
FD_ZERO(dst);
for (i = 0; i < len;i++)
{
if(fd[i] != (SOCKET_TYPE)ERRSOCKET &&
FD_ISSET(fd[i], src) && !FD_ISSET(fd[i], dst)) // no checking for dups
{
FD_SET(fd[i], dst);
testset = true;
}
}
return testset;
}
static boolean SOCK_CanSend(void)
{
struct timeval timeval_for_select = {0, 0};
fd_set tset;
int wselect;
if(!FD_CPY(&masterset, &tset, mysockets, mysocketses))
return false;
wselect = select(255, NULL, &tset, NULL, &timeval_for_select);
if (wselect >= 1)
return true;
return false;
}
static boolean SOCK_CanGet(void)
{
struct timeval timeval_for_select = {0, 0};
fd_set tset;
int rselect;
if(!FD_CPY(&masterset, &tset, mysockets, mysocketses))
return false;
rselect = select(255, &tset, NULL, NULL, &timeval_for_select);
if (rselect >= 1)
return true;
return false;
}
#endif
#endif
#ifndef NONET
static inline ssize_t SOCK_SendToAddr(SOCKET_TYPE socket, mysockaddr_t *sockaddr)
{
@@ -877,7 +823,7 @@ static void SOCK_Send(void)
}
}
#undef ALLOWEDERROR
#endif
#endif //NONET
#ifndef NONET
static void SOCK_FreeNodenum(INT32 numnode)
@@ -1029,7 +975,6 @@ static boolean UDP_Socket(void)
mysockets[s] = ERRSOCKET;
for (s = 0; s < MAXNETNODES+1; s++)
nodesocket[s] = ERRSOCKET;
FD_ZERO(&masterset);
s = 0;
memset(&hints, 0x00, sizeof (hints));
@@ -1056,7 +1001,6 @@ static boolean UDP_Socket(void)
mysockets[s] = UDP_Bind(runp->ai_family, runp->ai_addr, (socklen_t)runp->ai_addrlen);
if (mysockets[s] != (SOCKET_TYPE)ERRSOCKET)
{
FD_SET(mysockets[s], &masterset);
myfamily[s] = hints.ai_family;
s++;
}
@@ -1077,7 +1021,6 @@ static boolean UDP_Socket(void)
mysockets[s] = UDP_Bind(runp->ai_family, runp->ai_addr, (socklen_t)runp->ai_addrlen);
if (mysockets[s] != (SOCKET_TYPE)ERRSOCKET)
{
FD_SET(mysockets[s], &masterset);
myfamily[s] = hints.ai_family;
s++;
#ifdef HAVE_MINIUPNPC
@@ -1110,7 +1053,6 @@ static boolean UDP_Socket(void)
mysockets[s] = UDP_Bind(runp->ai_family, runp->ai_addr, (socklen_t)runp->ai_addrlen);
if (mysockets[s] != (SOCKET_TYPE)ERRSOCKET)
{
FD_SET(mysockets[s], &masterset);
myfamily[s] = hints.ai_family;
s++;
}
@@ -1131,7 +1073,6 @@ static boolean UDP_Socket(void)
mysockets[s] = UDP_Bind(runp->ai_family, runp->ai_addr, (socklen_t)runp->ai_addrlen);
if (mysockets[s] != (SOCKET_TYPE)ERRSOCKET)
{
FD_SET(mysockets[s], &masterset);
myfamily[s] = hints.ai_family;
s++;
}
@@ -1298,16 +1239,15 @@ boolean I_InitTcpDriver(void)
static void SOCK_CloseSocket(void)
{
size_t i;
for (i=0; i < MAXNETNODES+1; i++)
for (i = 0; i < mysocketses; i++)
{
if (mysockets[i] != (SOCKET_TYPE)ERRSOCKET
&& FD_ISSET(mysockets[i], &masterset))
{
FD_CLR(mysockets[i], &masterset);
if (mysockets[i] != (SOCKET_TYPE)ERRSOCKET)
close(mysockets[i]);
}
mysockets[i] = ERRSOCKET;
}
mysocketses = 0;
}
#endif
@@ -1417,9 +1357,7 @@ static void rendezvous(int size)
if (tic == refreshtic)
{
#ifdef HOLEPUNCH
holepunchpacket->magic = hole_punch_magic;
#endif
sendto(mysockets[0], doomcom->data, size, 0, &rzv.any, sizeof rzv.ip4);
}
@@ -1444,7 +1382,6 @@ static void SOCK_RegisterHolePunch(void)
rendezvous(4);
}
#endif
#endif
static boolean SOCK_OpenSocket(void)
@@ -1464,13 +1401,7 @@ static boolean SOCK_OpenSocket(void)
I_NetFreeNodenum = SOCK_FreeNodenum;
I_NetMakeNodewPort = SOCK_NetMakeNodewPort;
#ifdef SELECTTEST
// seem like not work with libsocket : (
I_NetCanSend = SOCK_CanSend;
I_NetCanGet = SOCK_CanGet;
#endif
#ifdef HOLEPUNCH
I_NetRequestHolePunch = SOCK_RequestHolePunch;
I_NetRegisterHolePunch = SOCK_RegisterHolePunch;
#endif
+3 -3
View File
@@ -139,13 +139,13 @@ UINT32 I_GetRefreshRate(void);
boolean I_UseNativeKeyboard(void);
boolean I_CheckNativeRes(void);
#ifdef USE_FBO_OGL
#if defined (__unix__)
extern boolean xwaylandcrap;
#endif
void RefreshOGLSDLSurface(void);
void I_DownSample(void);
boolean UseScreenFBO(void);
extern boolean downsample;
#endif
-1
View File
@@ -21,7 +21,6 @@
#include "d_player.h"
#include "lzf.h"
// Hey, moron! If you change this table, don't forget about the sprite enum in info.h and the sprite lights in hw_light.c!
char sprnames[NUMSPRITES + 1][5] =
{
"NULL","UNKN","THOK","PLAY","POSS","SPOS","FISH","BUZZ","RBUZ","JETB",
-4
View File
@@ -159,9 +159,6 @@ enum actionnum
A_SPAWNOBJECTRELATIVE,
A_CHANGEANGLERELATIVE,
A_CHANGEANGLEABSOLUTE,
A_ROLLANGLE,
A_CHANGEROLLANGLERELATIVE,
A_CHANGEROLLANGLEABSOLUTE,
A_PLAYSOUND,
A_FINDTARGET,
A_FINDTRACER,
@@ -460,7 +457,6 @@ extern boolean actionsoverridden[NUMACTIONS];
#define NUMSPRITEFREESLOTS NUMMOBJFREESLOTS
#define NUMSTATEFREESLOTS (NUMMOBJFREESLOTS*8)
// Hey, moron! If you change this table, don't forget about sprnames in info.c and the sprite lights in hw_light.c!
typedef enum sprite
{
SPR_NULL, // invisible object
+1 -1
View File
@@ -69,7 +69,7 @@ static fixed_t ScaleFromMap(fixed_t n, fixed_t scale)
static boolean K_DirectorIsEnabled(void)
{
return cv_director.value && !splitscreen && (gamestate == GS_LEVEL && (((stplyr && !stplyr->spectator) && (!playeringame[consoleplayer] || players[consoleplayer].spectator)) || (demo.playback && !demo.freecam && (!demo.title || !modeattacking))) && !K_DirectorIsPlayerAlone());
return cv_director.value && !splitscreen && (gamestate == GS_LEVEL && (((!playeringame[consoleplayer] || players[consoleplayer].spectator)) || (demo.playback && !demo.freecam && (!demo.title || !modeattacking))) && !K_DirectorIsPlayerAlone());
}
void K_InitDirector(void)
+285 -310
View File
File diff suppressed because it is too large. Load diff
+13 -1
View File
@@ -1109,6 +1109,18 @@ static int lib_pCheckSight(lua_State *L)
return 1;
}
// DONT USE THIS FOR ANYTHING GAMEPLAY, THIS WILL DESYNCH!
static int lib_pCheckSightFast(lua_State *L)
{
mobj_t *t1 = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobj_t *t2 = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
//HUDSAFE?
if (!t1 || !t2)
return LUA_ErrInvalid(L, "mobj_t");
lua_pushboolean(L, P_CheckSightFast(t1, t2));
return 1;
}
static int lib_pCheckHoopPosition(lua_State *L)
{
mobj_t *hoopthing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
@@ -3154,7 +3166,6 @@ static luaL_Reg lib[] = {
{"P_LookForEnemies",lib_pLookForEnemies},
{"P_NukeEnemies",lib_pNukeEnemies},
{"P_HomingAttack",lib_pHomingAttack},
//{"P_SuperReady",lib_pSuperReady},
{"P_Telekinesis",lib_pTelekinesis},
// p_map
@@ -3167,6 +3178,7 @@ static luaL_Reg lib[] = {
{"P_SlideMove",lib_pSlideMove},
{"P_BounceMove",lib_pBounceMove},
{"P_CheckSight", lib_pCheckSight},
{"P_CheckSightFast", lib_pCheckSightFast},
{"P_CheckHoopPosition",lib_pCheckHoopPosition},
{"P_RadiusAttack",lib_pRadiusAttack},
{"P_FloorzAtPos",lib_pFloorzAtPos},
+1 -1
View File
@@ -169,7 +169,7 @@ void COM_Lua_f(void)
for (i = 0; i < argc; i++)
WRITESTRINGN(p, COM_Argv(i), 255);
if (flags & 2)
SendNetXCmd2(XD_LUACMD, buf, p-buf);
SendNetXCmdForPlayer(1, XD_LUACMD, buf, p-buf);
else
SendNetXCmd(XD_LUACMD, buf, p-buf);
free(buf);
+116 -92
View File
@@ -12,105 +12,129 @@
#include "r_defs.h"
#include "d_player.h"
#include "s_sound.h"
#include "lua_hudlib_drawlist.h"
enum hook {
hook_NetVars=0,
hook_MapChange,
hook_MapLoad,
hook_PlayerJoin,
hook_PreThinkFrame,
hook_ThinkFrame,
hook_PostThinkFrame,
hook_MobjSpawn,
hook_MobjCollide,
hook_MobjMoveCollide,
hook_TouchSpecial,
hook_MobjFuse,
hook_MobjThinker,
hook_BossThinker,
hook_ShouldDamage,
hook_MobjDamage,
hook_MobjDeath,
hook_BossDeath,
hook_MobjRemoved,
hook_JumpSpecial,
hook_AbilitySpecial,
hook_SpinSpecial,
hook_JumpSpinSpecial,
hook_BotTiccmd,
hook_BotAI,
hook_LinedefExecute,
hook_PlayerMsg,
hook_HurtMsg,
hook_PlayerSpawn,
hook_PlayerQuit,
hook_PlayerThink,
hook_MusicChange,
hook_ShouldSpin, //SRB2KART
hook_ShouldExplode, //SRB2KART
hook_ShouldSquish, //SRB2KART
hook_PlayerSpin, //SRB2KART
hook_PlayerExplode, //SRB2KART
hook_PlayerSquish, //SRB2KART
hook_PlayerCmd, //SRB2KART
hook_IntermissionThinker, //SRB2KART
hook_VoteThinker, //SRB2KART
hook_ServerJoin, // SRB2KART - Saturn 32p
/*
* Do you know what an 'X Macro' is? Such a macro is called over each element of
* a list and expands the input. I use it for the hook lists because both an enum
* and array of hook names need to be kept in order. The X Macro handles this
* automatically.
*/
hook_MAX // last hook
};
extern const char *const hookNames[];
#define MOBJ_HOOK_LIST(X) \
X (MobjSpawn),/* P_SpawnMobj */\
X (MobjCollide),/* PIT_CheckThing */\
X (MobjMoveCollide),/* tritto */\
X (TouchSpecial),/* P_TouchSpecialThing */\
X (MobjFuse),/* when mobj->fuse runs out */\
X (MobjThinker),/* P_MobjThinker, P_SceneryThinker */\
X (BossThinker),/* P_GenericBossThinker */\
X (ShouldDamage),/* P_DamageMobj (Should mobj take damage?) */\
X (MobjDamage),/* P_DamageMobj (Mobj actually takes damage!) */\
X (MobjDeath),/* P_KillMobj */\
X (BossDeath),/* A_BossDeath */\
X (MobjRemoved),/* P_RemoveMobj */\
X (HurtMsg),/* imhurttin */\
#define HOOK_LIST(X) \
X (NetVars),/* add to archive table (netsave) */\
X (MapChange),/* (before map load) */\
X (MapLoad),\
X (PlayerJoin),/* Got_AddPlayer */\
X (PreThinkFrame)/* frame (before mobj and player thinkers) */,\
X (ThinkFrame),/* frame (after mobj and player thinkers) */\
X (PostThinkFrame),/* frame (at end of tick, ie after overlays, precipitation, specials) */\
X (JumpSpecial),/* P_DoJumpStuff (Any-jumping) */\
X (AbilitySpecial),/* P_DoJumpStuff (Double-jumping) */\
X (SpinSpecial),/* P_DoSpinAbility (Spin button effect) */\
X (JumpSpinSpecial),/* P_DoJumpStuff (Spin button effect (mid-air)) */\
X (BotTiccmd),/* B_BuildTiccmd */\
X (PlayerMsg),/* chat messages */\
X (PlayerSpawn),/* G_SpawnPlayer */\
X (PlayerQuit),\
X (PlayerThink),/* P_PlayerThink */\
X (MusicChange),\
X (ShouldSpin),/*SRB2KART*/\
X (ShouldExplode),/*SRB2KART*/\
X (ShouldSquish),/*SRB2KART*/\
X (PlayerSpin),/*SRB2KART*/\
X (PlayerExplode),/*SRB2KART*/\
X (PlayerSquish),/*SRB2KART*/\
X (PlayerCmd),/* building the player's ticcmd struct (Ported from SRB2Kart) */\
X (IntermissionThinker),/* Y_Ticker */\
X (VoteThinker),/*SRB2KART*/\
X (ServerJoin),/* SRB2KART - Saturn 32p*/\
#define STRING_HOOK_LIST(X) \
X (BotAI),/* B_BuildTailsTiccmd by skin name */\
X (LinedefExecute),\
#define HUD_HOOK_LIST(X) \
X (game),\
X (scores),/* emblems/multiplayer list */\
X (intermission),\
X (vote),\
/*
* I chose to access the hook enums through a macro as well. This could provide
* a hint to lookup the macro's definition instead of the enum's definition.
* (Since each enumeration is not defined in the source code, but by the list
* macros above, it is not greppable.) The name passed to the macro can also be
* grepped and found in the lists above.
*/
#define MOBJ_HOOK(name) mobjhook_ ## name
#define HOOK(name) hook_ ## name
#define HUD_HOOK(name) hudhook_ ## name
#define STRING_HOOK(name) stringhook_ ## name
#define ENUM(X) enum { X ## _LIST (X) X(MAX) }
ENUM (MOBJ_HOOK);
ENUM (HOOK);
ENUM (HUD_HOOK);
ENUM (STRING_HOOK);
#undef ENUM
/* dead simple, LUA_HOOK(GameQuit) */
#define LUA_HOOK(type) LUA_HookVoid(HOOK(type))
#define LUA_HUDHOOK(type,drawlist) LUA_HookHUD(HUD_HOOK(type),(drawlist))
extern boolean hook_cmd_running; // This is used by PlayerCmd and lua_playerlib to prevent anything from being wirtten to player while we run PlayerCmd.
extern int hook_defrosting;
void LUAh_MapChange(INT16 mapnumber); // Hook for map change (before load)
void LUAh_MapLoad(void); // Hook for map load
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_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_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_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
boolean LUAh_MobjThinker(mobj_t *mo); // Hook for P_MobjThinker or P_SceneryThinker by mobj type
#define LUAh_BossThinker(mo) LUAh_MobjHook(mo, hook_BossThinker) // Hook for P_GenericBossThinker by mobj type
UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage); // Hook for P_DamageMobj by mobj type (Should mobj take damage?)
boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage); // Hook for P_DamageMobj by mobj type (Mobj actually takes damage!)
boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source); // Hook for P_KillMobj by mobj type
#define LUAh_BossDeath(mo) LUAh_MobjHook(mo, hook_BossDeath) // Hook for A_BossDeath by mobj type
#define LUAh_MobjRemoved(mo) LUAh_MobjHook(mo, hook_MobjRemoved) // Hook for P_RemoveMobj by mobj type
#define LUAh_JumpSpecial(player) LUAh_PlayerHook(player, hook_JumpSpecial) // Hook for P_DoJumpStuff (Any-jumping)
#define LUAh_AbilitySpecial(player) LUAh_PlayerHook(player, hook_AbilitySpecial) // Hook for P_DoJumpStuff (Double-jumping)
#define LUAh_SpinSpecial(player) LUAh_PlayerHook(player, hook_SpinSpecial) // Hook for P_DoSpinDash (Spin button effect)
#define LUAh_JumpSpinSpecial(player) LUAh_PlayerHook(player, hook_JumpSpinSpecial) // Hook for P_DoJumpStuff (Spin button effect (mid-air))
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, int mute); // Hook for chat messages
boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source); // Hook for hurt messages
#define LUAh_PlayerSpawn(player) LUAh_PlayerHook(player, hook_PlayerSpawn) // Hook for G_SpawnPlayer
void LUAh_PlayerQuit(player_t *plr, int reason); // Hook for player quitting
boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boolean *looping,
UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms); // Hook for music changes
void LUA_HookVoid(int hook);
void LUA_HookHUD(int hook, huddrawlist_h drawlist);
UINT8 LUAh_ShouldSpin(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Should player be spun out?
UINT8 LUAh_ShouldExplode(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Should player be exploded?
UINT8 LUAh_ShouldSquish(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Should player be squished?
int LUA_HookMobj(mobj_t *, int hook);
int LUA_Hook2Mobj(mobj_t *, mobj_t *, int hook);
void LUA_HookInt(INT32 integer, int hook);
//void LUA_HookBool(boolean value, int hook);
int LUA_HookPlayer(player_t *, int hook);
int LUA_HookTiccmd(player_t *, ticcmd_t *, int hook);
boolean LUAh_PlayerSpin(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_SpinPlayer. Allows Lua to execute code and/or overwrite its behavior.
boolean LUAh_PlayerExplode(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_ExplodePlayer. Allows Lua to execute code and/or overwrite its behavior.
boolean LUAh_PlayerSquish(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_SquishPlayer. Allows Lua to execute code and/or overwrite its behavior.
void LUA_HookPreThinkFrame(void);
void LUA_HookThinkFrame(void);
void LUA_HookPostThinkFrame(void);
int LUA_HookTouchSpecial(mobj_t *special, mobj_t *toucher);
int LUA_HookShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage);
int LUA_HookMobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage);
int LUA_HookMobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source);
int LUA_HookBotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd);
void LUA_HookLinedefExecute(line_t *, mobj_t *, sector_t *);
int LUA_HookPlayerMsg(int source, int target, int flags, char *msg, int mute);
int LUA_HookHurtMsg(player_t *, mobj_t *inflictor, mobj_t *source);
int LUA_HookPlayerCanDamage(player_t *, mobj_t *);
void LUA_HookPlayerQuit(player_t *, int);
int LUA_HookPlayerCmd(player_t *, ticcmd_t *);
int LUA_HookMusicChange(const char *oldname, struct MusicChange *);
void LUAh_ServerJoin(void); // SRB2KART - Saturn 32p: called by client when joining a server, allows lua to load any sort of config file
int LUA_HookShouldSpin(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Should player be spun out?
int LUA_HookShouldExplode(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Should player be exploded?
int LUA_HookShouldSquish(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Should player be squished?
boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd); // Allows to write to player cmd before the game does anything with them.
void LUAh_IntermissionThinker(void); // Hook for Y_Ticker
void LUAh_VoteThinker(void); // Hook for Y_VoteTicker
#define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink
boolean LUA_HookPlayerSpin(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_SpinPlayer. Allows Lua to execute code and/or overwrite its behavior.
boolean LUA_HookPlayerExplode(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_ExplodePlayer. Allows Lua to execute code and/or overwrite its behavior.
boolean LUA_HookPlayerSquish(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_SquishPlayer. Allows Lua to execute code and/or overwrite its behavior.
+974 -1828
View File
File diff suppressed because it is too large. Load diff
+1 -4
View File
@@ -50,9 +50,6 @@ extern boolean hud_interplatch; // string mode was toggled
boolean LUA_HudEnabled(enum hud option);
void LUAh_GameHUD(huddrawlist_h list);
void LUAh_ScoresHUD(huddrawlist_h list);
void LUAh_IntermissionHUD(huddrawlist_h list);
void LUAh_VoteHUD(huddrawlist_h list);
void LUA_SetHudHook(int hook, huddrawlist_h list);
#endif // __LUA_HUD_H__
+63 -281
View File
@@ -28,6 +28,7 @@
#include "lua_script.h"
#include "lua_libs.h"
#include "lua_hud.h"
#include "lua_hook.h"
#define HUDONLY if (!hud_running) return luaL_error(L, "HUD rendering code should not be called outside of rendering hooks!");
@@ -40,8 +41,6 @@ boolean hud_interpstring = false;
boolean hud_interplatch = false;
static UINT8 hud_enabled[(hud_MAX/8)+1];
static UINT8 hudAvailable; // hud hooks field
static UINT8 camnum = 1;
// must match enum hud in lua_hud.h
@@ -93,19 +92,6 @@ static const char *const patch_opt[] = {
"topoffset",
NULL};
enum hudhook {
hudhook_game = 0,
hudhook_scores = 1,
hudhook_intermission = 2,
hudhook_vote = 3,
};
static const char *const hudhook_opt[] = {
"game",
"scores",
"intermission",
"vote",
NULL};
static int patch_fields_ref = LUA_NOREF;
// alignment types for v.drawString
@@ -503,7 +489,7 @@ static int libd_getSpritePatch(lua_State *L)
angle = (angle & 7); // modulus angle by 8
// rotsprite?????
if (lua_isnumber(L, 4) && (cv_spriteroll.value))
if (lua_isnumber(L, 4) && cv_sloperoll.value)
{
angle_t rollangle = luaL_checkangle(L, 4);
INT32 rot = R_GetRollAngle(rollangle);
@@ -591,26 +577,16 @@ static int libd_drawOnMinimap(lua_State *L)
UINT8 *colormap = NULL; // do we want to colormap this patch?
boolean centered; // the patch is centered and doesn't need readjusting on x/y coordinates.
huddrawlist_h list;
// variables used to replicate k_kart's mmap drawer:
INT32 lumpnum;
patch_t *AutomapPic;
INT32 mx, my;
INT32 splitflags, minimaptrans;
patch_t *AutomapPic = NULL;
// base position of the minimap which also takes splits into account:
INT32 MM_X, MM_Y;
// variables used for actually drawing the icon:
INT32 splitflags, minimaptrans;
fixed_t amnumxpos, amnumypos;
INT32 amxpos, amypos;
node_t *bsp = &nodes[numnodes-1];
fixed_t maxx, minx, maxy, miny;
fixed_t mapwidth, mapheight;
fixed_t xoffset, yoffset;
fixed_t xscale, yscale, zoom;
fixed_t amxpos, amypos;
INT32 mm_x, mm_y;
fixed_t patchw, patchh;
HUDONLY // only run this function in hud hooks
@@ -622,8 +598,6 @@ static int libd_drawOnMinimap(lua_State *L)
colormap = *((UINT8 **)luaL_checkudata(L, 5, META_COLORMAP));
centered = lua_optboolean(L, 6);
// replicate exactly what source does for its minimap drawer; AKA hardcoded garbo.
// first, check what position the mmap is supposed to be in (pasted from k_kart.c):
MM_X = BASEVIDWIDTH - 50 + cv_mini_xoffset.value; // 270
MM_Y = (BASEVIDHEIGHT/2)-16 + cv_mini_yoffset.value; // 84
@@ -658,7 +632,6 @@ static int libd_drawOnMinimap(lua_State *L)
else
return 0;
minimaptrans = ((10-minimaptrans)<<FF_TRANSSHIFT);
splitflags |= minimaptrans;
@@ -679,97 +652,70 @@ static int libd_drawOnMinimap(lua_State *L)
if (stplyr != &players[displayplayers[0]])
return 0;
lumpnum = W_CheckNumForName(va("%sR", G_BuildMapName(gamemap)));
AutomapPic = minimapinfo.minimap_pic;
if (lumpnum != -1)
AutomapPic = W_CachePatchName(va("%sR", G_BuildMapName(gamemap)), PU_HUDGFX);
else
if (!AutomapPic)
{
return 0; // no pic, just get outta here
}
mx = MM_X - (AutomapPic->width/2);
my = MM_Y - (AutomapPic->height/2);
// Handle offsets and stuff.
mm_x = MM_X - (SHORT(AutomapPic->width)/2);
mm_y = MM_Y - (SHORT(AutomapPic->height)/2);
// let offsets transfer to the heads, too!
if (encoremode)
mx += SHORT(AutomapPic->leftoffset);
{
mm_x += SHORT(AutomapPic->leftoffset);
}
else
mx -= SHORT(AutomapPic->leftoffset);
my -= SHORT(AutomapPic->topoffset);
{
mm_x -= SHORT(AutomapPic->leftoffset);
}
// now that we have replicated this behavior, we can draw an icon from our supplied x, y coordinates by replicating k_kart.c's totally understandable uncommented code!!!
// get map boundaries using nodes
maxx = maxy = INT32_MAX;
minx = miny = INT32_MIN;
minx = bsp->bbox[0][BOXLEFT];
maxx = bsp->bbox[0][BOXRIGHT];
miny = bsp->bbox[0][BOXBOTTOM];
maxy = bsp->bbox[0][BOXTOP];
if (bsp->bbox[1][BOXLEFT] < minx)
minx = bsp->bbox[1][BOXLEFT];
if (bsp->bbox[1][BOXRIGHT] > maxx)
maxx = bsp->bbox[1][BOXRIGHT];
if (bsp->bbox[1][BOXBOTTOM] < miny)
miny = bsp->bbox[1][BOXBOTTOM];
if (bsp->bbox[1][BOXTOP] > maxy)
maxy = bsp->bbox[1][BOXTOP];
// You might be wondering why these are being bitshift here
// it's because mapwidth and height would otherwise overflow for maps larger than half the size possible...
// map boundaries and sizes will ALWAYS be whole numbers thankfully
// later calculations take into consideration that these are actually not in terms of FRACUNIT though
minx >>= FRACBITS;
maxx >>= FRACBITS;
miny >>= FRACBITS;
maxy >>= FRACBITS;
// these are our final map boundaries:
mapwidth = maxx - minx;
mapheight = maxy - miny;
// These should always be small enough to be bitshift back right now
xoffset = (minx + mapwidth/2)<<FRACBITS;
yoffset = (miny + mapheight/2)<<FRACBITS;
xscale = FixedDiv(AutomapPic->width, mapwidth);
yscale = FixedDiv(AutomapPic->height, mapheight);
zoom = FixedMul(min(xscale, yscale), FRACUNIT-FRACUNIT/20);
amnumxpos = (FixedMul(x, zoom) - FixedMul(xoffset, zoom));
amnumypos = -(FixedMul(y, zoom) - FixedMul(yoffset, zoom));
if (encoremode)
amnumxpos = -amnumxpos;
mm_y -= SHORT(AutomapPic->topoffset);
// scale patch coords
patchw = patch->width*scale /2;
patchh = patch->height*scale /2;
patchw = (SHORT(patch->width) * scale / 2);
patchh = (SHORT(patch->height) * scale / 2);
if (centered)
{
patchw = patchh = 0; // patch is supposedly already centered, don't butt in.
}
amxpos = amnumxpos + ((mx + AutomapPic->width/2)<<FRACBITS) - patchw;
amypos = amnumypos + ((my + AutomapPic->height/2)<<FRACBITS) - patchh;
amnumxpos = (FixedMul(x, minimapinfo.zoom) - minimapinfo.offs_x);
amnumypos = -(FixedMul(y, minimapinfo.zoom) - minimapinfo.offs_y);
if (encoremode)
{
amnumxpos = -amnumxpos;
}
amxpos = amnumxpos + ((mm_x + SHORT(AutomapPic->width) / 2)<<FRACBITS) - patchw;
amypos = amnumypos + ((mm_y + SHORT(AutomapPic->height) / 2)<<FRACBITS) - patchh;
// and NOW we can FINALLY DRAW OUR GOD DAMN PATCH :V
lua_getfield(L, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
list = (huddrawlist_h) lua_touserdata(L, -1);
lua_pop(L, 1);
if (LUA_HUD_IsDrawListValid(list)){
if (cv_minihead.value)
LUA_HUD_AddDrawScaled(list, amxpos, amypos, scale/2, patch, splitflags, colormap);
else
LUA_HUD_AddDrawScaled(list, amxpos, amypos, scale, patch, splitflags, colormap);
}else{
if (cv_minihead.value)
V_DrawFixedPatch(amxpos, amypos, scale/2, splitflags, patch, colormap);
else
V_DrawFixedPatch(amxpos, amypos, scale, splitflags, patch, colormap);
if (cv_minihead.value)
{
amxpos += patchw / 2;
amypos += patchh / 2;
scale /= 2;
}
if (LUA_HUD_IsDrawListValid(list))
{
LUA_HUD_AddDrawScaled(list, amxpos, amypos, scale, patch, splitflags, colormap);
}
else
{
V_DrawFixedPatch(amxpos, amypos, scale, splitflags, patch, colormap);
}
return 0;
}
@@ -1255,6 +1201,8 @@ static luaL_Reg lib_draw[] = {
{NULL, NULL}
};
static int lib_draw_ref;
//
// lib_hud
//
@@ -1288,25 +1236,7 @@ static int lib_hudenabled(lua_State *L)
}
// add a HUD element for rendering
static int lib_hudadd(lua_State *L)
{
enum hudhook field;
luaL_checktype(L, 1, LUA_TFUNCTION);
field = luaL_checkoption(L, 2, "game", hudhook_opt);
lua_getfield(L, LUA_REGISTRYINDEX, "HUD");
I_Assert(lua_istable(L, -1));
lua_rawgeti(L, -1, field+2); // HUD[2+]
I_Assert(lua_istable(L, -1));
lua_remove(L, -2);
lua_pushvalue(L, 1);
lua_rawseti(L, -2, (int)(lua_objlen(L, -2) + 1));
hudAvailable |= 1<<field;
return 0;
}
extern int lib_hudadd(lua_State *L);
static int lib_hudsetvotebackground(lua_State *L)
{
@@ -1391,23 +1321,9 @@ int LUA_HudLib(lua_State *L)
{
memset(hud_enabled, 0xff, (hud_MAX/8)+1);
lua_newtable(L); // HUD registry table
lua_newtable(L);
luaL_register(L, NULL, lib_draw);
lua_rawseti(L, -2, 1); // HUD[1] = lib_draw
lua_newtable(L);
lua_rawseti(L, -2, 2); // HUD[2] = game rendering functions array
lua_newtable(L);
lua_rawseti(L, -2, 3); // HUD[3] = scores rendering functions array
lua_newtable(L);
lua_rawseti(L, -2, 4); // HUD[4] = intermission rendering functions array
lua_newtable(L);
lua_rawseti(L, -2, 5); // HUD[5] = vote rendering functions array
lua_setfield(L, LUA_REGISTRYINDEX, "HUD");
lua_newtable(L);
luaL_register(L, NULL, lib_draw);
lib_draw_ref = luaL_ref(L, LUA_REGISTRYINDEX);
luaL_newmetatable(L, META_HUDINFO);
lua_pushcfunction(L, hudinfo_get);
@@ -1463,153 +1379,19 @@ boolean LUA_HudEnabled(enum hud option)
return false;
}
// Hook for HUD rendering
void LUAh_GameHUD(huddrawlist_h list)
void LUA_SetHudHook(int hook, huddrawlist_h list)
{
if (!gL || !(hudAvailable & (1<<hudhook_game)))
return;
lua_getref(gL, lib_draw_ref);
lua_pushlightuserdata(gL, list);
lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
hud_running = true;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
lua_getfield(gL, LUA_REGISTRYINDEX, "HUD");
I_Assert(lua_istable(gL, -1));
lua_rawgeti(gL, -1, hudhook_game+2); // HUD[2] = rendering funcs
I_Assert(lua_istable(gL, -1));
lua_rawgeti(gL, -2, 1); // HUD[1] = lib_draw
I_Assert(lua_istable(gL, -1));
lua_remove(gL, -3); // pop HUD
LUA_PushUserdata(gL, stplyr, META_PLAYER);
LUA_PushUserdata(gL, &camera[stplyrnum], META_CAMERA);
camnum = stplyrnum + 1;
hud_interpcounter = 0;
lua_pushnil(gL);
while (lua_next(gL, -5) != 0) {
hud_interpolate = hud_interpstring = hud_interplatch = false;
hud_interpcounter++;
lua_pushvalue(gL, -5); // graphics library (HUD[1])
lua_pushvalue(gL, -5); // stplyr
lua_pushvalue(gL, -5); // camera
LUA_Call(gL, 3, 0, 1);
// there used to be a switch statement here, its gone now.
if (hook == HUD_HOOK(game))
{
LUA_PushUserdata(gL, stplyr, META_PLAYER);
LUA_PushUserdata(gL, &camera[stplyrnum], META_CAMERA);
camnum = stplyrnum + 1; // for compatibility
}
lua_settop(gL, 0);
hud_running = false;
lua_pushlightuserdata(gL, NULL);
lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
}
void LUAh_ScoresHUD(huddrawlist_h list)
{
if (!gL || !(hudAvailable & (1<<hudhook_scores)))
return;
lua_pushlightuserdata(gL, list);
lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
hud_running = true;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
lua_getfield(gL, LUA_REGISTRYINDEX, "HUD");
I_Assert(lua_istable(gL, -1));
lua_rawgeti(gL, -1, hudhook_scores+2); // HUD[3] = rendering funcs
I_Assert(lua_istable(gL, -1));
lua_rawgeti(gL, -2, 1); // HUD[1] = lib_draw
I_Assert(lua_istable(gL, -1));
lua_remove(gL, -3); // pop HUD
lua_pushnil(gL);
hud_interpcounter = 0;
while (lua_next(gL, -3) != 0) {
hud_interpolate = hud_interpstring = hud_interplatch = false;
hud_interpcounter++;
lua_pushvalue(gL, -3); // graphics library (HUD[1])
LUA_Call(gL, 1, 0, 1);
}
lua_settop(gL, 0);
hud_running = false;
lua_pushlightuserdata(gL, NULL);
lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
}
void LUAh_IntermissionHUD(huddrawlist_h list)
{
if (!gL || !(hudAvailable & (1<<hudhook_intermission)))
return;
lua_pushlightuserdata(gL, list);
lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
hud_running = true;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
lua_getfield(gL, LUA_REGISTRYINDEX, "HUD");
I_Assert(lua_istable(gL, -1));
lua_rawgeti(gL, -1, hudhook_intermission+2); // HUD[4] = rendering funcs
I_Assert(lua_istable(gL, -1));
lua_rawgeti(gL, -2, 1); // HUD[1] = lib_draw
I_Assert(lua_istable(gL, -1));
lua_remove(gL, -3); // pop HUD
lua_pushnil(gL);
hud_interpcounter = 0;
while (lua_next(gL, -3) != 0) {
hud_interpolate = hud_interpstring = hud_interplatch = false;
hud_interpcounter++;
lua_pushvalue(gL, -3); // graphics library (HUD[1])
LUA_Call(gL, 1, 0, 1);
}
lua_settop(gL, 0);
hud_running = false;
lua_pushlightuserdata(gL, NULL);
lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
}
void LUAh_VoteHUD(huddrawlist_h list)
{
if (!gL || !(hudAvailable & (1<<hudhook_vote)))
return;
lua_pushlightuserdata(gL, list);
lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
hud_running = true;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
lua_getfield(gL, LUA_REGISTRYINDEX, "HUD");
I_Assert(lua_istable(gL, -1));
lua_rawgeti(gL, -1, hudhook_vote+2); // HUD[5] = rendering funcs
I_Assert(lua_istable(gL, -1));
lua_rawgeti(gL, -2, 1); // HUD[1] = lib_draw
I_Assert(lua_istable(gL, -1));
lua_remove(gL, -3); // pop HUD
lua_pushnil(gL);
hud_interpcounter = 0;
while (lua_next(gL, -3) != 0) {
hud_interpolate = hud_interpstring = hud_interplatch = false;
hud_interpcounter++;
lua_pushvalue(gL, -3); // graphics library (HUD[1])
LUA_Call(gL, 1, 0, 1);
}
lua_settop(gL, 0);
hud_running = false;
lua_pushlightuserdata(gL, NULL);
lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
}
+3 -1
View File
@@ -111,6 +111,8 @@ static void A_Lua(mobj_t *actor)
lua_pushinteger(gL, var2);
LUA_Call(gL, 3, 0, 1);
lua_pop(gL, 1); // pop error handler
if (found)
{
--superstack;
@@ -940,7 +942,7 @@ static int lib_setSfxInfo(lua_State *L)
if (lua_isnumber(L, 2))
{
int j = lua_tointeger(L, 2) - 1;
int j = lua_tointeger(L, 2);
// Read and Write enums were combined, need to do this switch now
switch (j)
+1 -1
View File
@@ -281,7 +281,7 @@ static int lib_iterateSectorThinglist(lua_State *L)
if (!lua_isnil(L, 1))
{
thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
if (P_MobjWasRemoved(thing))
if (!thing)
return luaL_error(L, "current entry in thinglist was removed; avoid calling P_RemoveMobj on entries!");
thing = thing->snext;
}
+2 -1
View File
@@ -1312,7 +1312,8 @@ void LUA_Archive(savebuffer_t *save, boolean network)
LUAh_NetArchiveHook(NetArchive, save); // call the NetArchive hook in archive mode
}
ArchiveTables(&save->p);
LUA_HookNetArchive(NetArchive); // call the NetArchive hook in archive mode
ArchiveTables();
if (gL)
lua_pop(gL, 1); // pop tables
+1 -1
View File
@@ -63,7 +63,7 @@ void Got_Luacmd(UINT8 **cp, INT32 playernum); // lua_consolelib.c
void LUA_CVarChanged(const char *name); // lua_consolelib.c
int Lua_optoption(lua_State *L, int narg, int def, int list_ref);
int Lua_CreateFieldTable(lua_State *L, const char *const lst[]);
void LUAh_NetArchiveHook(lua_CFunction archFunc, savebuffer_t *save);
void LUA_HookNetArchive(lua_CFunction archFunc);
// Console wrapper
void COM_Lua_f(void);
+189 -341
View File
@@ -37,8 +37,9 @@
/*
* Sacrifice very little compression quality in favour of compression speed.
* This gives almost the same compression as the default code, and is
* (very roughly) 15% faster. This is the preferred mode of operation.
* (very roughly) 15% faster. This is the preferable mode of operation.
*/
#ifndef VERY_FAST
# define VERY_FAST 1
#endif
@@ -47,7 +48,7 @@
* Sacrifice some more compression quality in favour of compression speed.
* (roughly 1-2% worse compression for large blocks and
* 9-10% for small, redundant, blocks and >>20% better speed in both cases)
* In short: when in need for speed, enable this for binary data,
* In INT16: when in need for speed, enable this for binary data,
* possibly disable this for text data.
*/
#ifndef ULTRA_FAST
@@ -65,10 +66,21 @@
#endif
#endif
/*
* Use string functions to copy memory.
* this is usually a loss, even with glibc's optimized memcpy
*/
#ifndef USE_MEMCPY
#ifdef _MSC_VER
# define USE_MEMCPY 0
#else
# define USE_MEMCPY 1
#endif
#endif
/*
* You may choose to pre-set the hash table (might be faster on some
* modern cpus and large (>>64k) blocks, and also makes compression
* deterministic/repeatable when the configuration otherwise is the same).
* modern cpus and large (>>64k) blocks)
*/
#ifndef INIT_HTAB
# define INIT_HTAB 1
@@ -76,15 +88,15 @@
/*
* Avoid assigning values to errno variable? for some embedding purposes
* (linux kernel for example), this is necessary. NOTE: this breaks
* the documentation in lzf.h. Avoiding errno has no speed impact.
* (linux kernel for example), this is neccessary. NOTE: this breaks
* the documentation in lzf.h.
*/
#ifndef AVOID_ERRNO
# define AVOID_ERRNO 0
#endif
/*
* Whether to pass the LZF_STATE variable as argument, or allocate it
* Wether to pass the LZF_STATE variable as argument, or allocate it
* on the stack. For small-stack environments, define this to 1.
* NOTE: this breaks the prototype in lzf.h.
*/
@@ -93,108 +105,50 @@
#endif
/*
* Whether to add extra checks for input validity in lzf_decompress
* Wether to add extra checks for input validity in lzf_decompress
* and return EINVAL if the input stream has been corrupted. This
* only shields against overflowing the input buffer and will not
* detect most corrupted streams.
* This check is not normally noticeable on modern hardware
* This check is not normally noticable on modern hardware
* (<1% slowdown), but might slow down older cpus considerably.
*/
#ifndef CHECK_INPUT
# define CHECK_INPUT 1
#endif
/*
* Whether the target CPU has a slow multiplication. This affects
* the default hash function for the compressor, and enables a slightly
* worse hash function that needs only shifts.
*/
#ifndef MULTIPLICATION_IS_SLOW
# define MULTIPLICATION_IS_SLOW 0
#endif
/*
* If defined, then this data type will be used for storing offsets.
* This can be useful if you want to use a huge hashtable, want to
* conserve memory, or both, and your data fits into e.g. 64kb.
* If instead you want to compress data > 4GB, then it's better to
* to "#define LZF_USE_OFFSETS 0" instead.
*/
/*#define LZF_HSLOT unsigned short*/
/*
* Whether to store pointers or offsets inside the hash table. On
* 64 bit architetcures, pointers take up twice as much space,
* and might also be slower. Default is to autodetect.
*/
/*#define LZF_USE_OFFSETS autodetect */
/*
* Whether to optimise code for size, at the expense of speed. Use
* this when you are extremely tight on memory, perhaps in combination
* with AVOID_ERRNO 1 and CHECK_INPUT 0.
*/
#ifndef OPTIMISE_SIZE
# ifdef __OPTIMIZE_SIZE__
# define OPTIMISE_SIZE 1
# else
# define OPTIMISE_SIZE 0
# endif
#endif
/*****************************************************************************/
/* nothing should be changed below */
# include <string.h>
# include <limits.h>
#if ULTRA_FAST
# undef VERY_FAST
#endif
#ifndef LZF_USE_OFFSETS
# ifdef _WIN32
# define LZF_USE_OFFSETS defined(_M_X64)
# else
# include <stdint.h>
# define LZF_USE_OFFSETS (UINTPTR_MAX > 0xffffffffU)
# endif
#endif
typedef unsigned char u8;
#ifdef LZF_HSLOT
# define LZF_HSLOT_BIAS ((const u8 *)in_data)
#else
# ifdef LZF_USE_OFFSETS
# define LZF_HSLOT_BIAS ((const u8 *)in_data)
typedef unsigned int LZF_HSLOT;
typedef const u8 *LZF_STATE[1 << (HLOG)];
#if !STRICT_ALIGN
/* for unaligned accesses we need a 16 bit datatype. */
# include <limits.h>
# if USHRT_MAX == 65535
typedef unsigned short u16;
# elif UINT_MAX == 65535
typedef unsigned int u16;
# else
# define LZF_HSLOT_BIAS 0
typedef const u8 *LZF_HSLOT;
# undef STRICT_ALIGN
# define STRICT_ALIGN 1
# endif
#endif
#if USHRT_MAX == 65535
typedef unsigned short u16;
#elif UINT_MAX == 65535
typedef unsigned int u16;
#else
# undef STRICT_ALIGN
# define STRICT_ALIGN 1
#if ULTRA_FAST
# if defined(VERY_FAST)
# undef VERY_FAST
# endif
#endif
#define LZF_MAX_LIT (1 << 5)
#define LZF_MAX_OFF (1 << 13)
#define LZF_MAX_REF ((1 << 8) + (1 << 3))
typedef LZF_HSLOT LZF_STATE[1 << (HLOG)];
typedef struct
{
const u8 *first [1 << (6+8)]; /* most recent occurance of a match */
u16 prev [LZF_MAX_OFF]; /* how many bytes to go backwards for the next match */
} LZF_STATE_BEST[1];
#if USE_MEMCPY || INIT_HTAB
# ifdef __cplusplus
# include <cstring>
# else
# include <string.h>
# endif
#endif
#endif
@@ -210,31 +164,14 @@ typedef struct
# define SET_ERRNO(n) errno = (n)
#endif
#ifndef USE_REP_MOVSB
#if (defined (__i386) || defined (__amd64)) && __GNUC__ >= 3
#define USE_REP_MOVSB 1
#else
#define USE_REP_MOVSB 0 // Default to 0 if not defined elsewhere
#endif
#endif
#if USE_REP_MOVSB /* small win on amd, big loss on intel */
#if (defined (__i386) || defined (__amd64)) && __GNUC__ >= 3
# define lzf_movsb(dst, src, len) \
asm ("rep movsb" \
: "=D" (dst), "=S" (src), "=c" (len) \
: "0" (dst), "1" (src), "2" (len));
#endif
#endif
size_t
lzf_decompress (const void *const in_data, size_t in_len,
void *out_data, size_t out_len)
void *out_data, size_t out_len)
{
u8 const *ip = (const u8 *)in_data;
u8 *op = (u8 *)out_data;
u8 *op = (u8 *)out_data;
u8 const *const in_end = ip + in_len;
u8 *const out_end = op + out_len;
u8 *const out_end = op + out_len;
do
{
@@ -258,23 +195,14 @@ lzf_decompress (const void *const in_data, size_t in_len,
}
#endif
#ifdef lzf_movsb
lzf_movsb (op, ip, ctrl);
#elif OPTIMISE_SIZE
while (ctrl--)
*op++ = *ip++;
#if USE_MEMCPY
M_Memcpy (op, ip, ctrl);
op += ctrl;
ip += ctrl;
#else
switch (ctrl)
{
case 32: *op++ = *ip++; case 31: *op++ = *ip++; case 30: *op++ = *ip++; case 29: *op++ = *ip++;
case 28: *op++ = *ip++; case 27: *op++ = *ip++; case 26: *op++ = *ip++; case 25: *op++ = *ip++;
case 24: *op++ = *ip++; case 23: *op++ = *ip++; case 22: *op++ = *ip++; case 21: *op++ = *ip++;
case 20: *op++ = *ip++; case 19: *op++ = *ip++; case 18: *op++ = *ip++; case 17: *op++ = *ip++;
case 16: *op++ = *ip++; case 15: *op++ = *ip++; case 14: *op++ = *ip++; case 13: *op++ = *ip++;
case 12: *op++ = *ip++; case 11: *op++ = *ip++; case 10: *op++ = *ip++; case 9: *op++ = *ip++;
case 8: *op++ = *ip++; case 7: *op++ = *ip++; case 6: *op++ = *ip++; case 5: *op++ = *ip++;
case 4: *op++ = *ip++; case 3: *op++ = *ip++; case 2: *op++ = *ip++; case 1: *op++ = *ip++;
}
do
*op++ = *ip++;
while (--ctrl);
#endif
}
else /* back reference */
@@ -316,49 +244,12 @@ lzf_decompress (const void *const in_data, size_t in_len,
return 0;
}
#ifdef lzf_movsb
len += 2;
lzf_movsb (op, ref, len);
#elif OPTIMISE_SIZE
len += 2;
*op++ = *ref++;
*op++ = *ref++;
do
*op++ = *ref++;
while (--len);
#else
switch (len)
{
default:
len += 2;
if (op >= ref + len)
{
/* disjunct areas */
memcpy (op, ref, len);
op += len;
}
else
{
/* overlapping, use octet by octet copying */
do
*op++ = *ref++;
while (--len);
}
break;
case 9: *op++ = *ref++;
case 8: *op++ = *ref++;
case 7: *op++ = *ref++;
case 6: *op++ = *ref++;
case 5: *op++ = *ref++;
case 4: *op++ = *ref++;
case 3: *op++ = *ref++;
case 2: *op++ = *ref++;
case 1: *op++ = *ref++;
case 0: *op++ = *ref++; /* two octets more */
*op++ = *ref++;
}
#endif
}
}
while (ip < in_end);
@@ -375,29 +266,23 @@ lzf_decompress (const void *const in_data, size_t in_len,
/*
* don't play with this unless you benchmark!
* the data format is not dependent on the hash function.
* the hash function might seem strange, just believe me,
* decompression is not dependent on the hash function
* the hashing function might seem strange, just believe me
* it works ;)
*/
#ifndef FRST
# define FRST(p) (((p[0]) << 8) | p[1])
# define NEXT(v,p) (((v) << 8) | p[2])
# if MULTIPLICATION_IS_SLOW
# if ULTRA_FAST
# define IDX(h) ((( h >> (3*8 - HLOG)) - h ) & (HSIZE - 1))
# elif VERY_FAST
# define IDX(h) ((( h >> (3*8 - HLOG)) - h*5) & (HSIZE - 1))
# else
# define IDX(h) ((((h ^ (h << 5)) >> (3*8 - HLOG)) - h*5) & (HSIZE - 1))
# endif
# else
/* this one was developed with sesse,
* and is very similar to the one in snappy.
* it does need a modern enough cpu with a fast multiplication.
*/
# define IDX(h) (((h * 0x1e35a7bdU) >> (32 - HLOG - 8)) & (HSIZE - 1))
# endif
# define IDX(h) ((((h ^ (h << 5)) >> (3*8 - HLOG)) - h*5) & (HSIZE - 1))
#endif
/*
* IDX works because it is very similar to a multiplicative hash, e.g.
* ((h * 57321 >> (3*8 - HLOG)) & (HSIZE - 1))
* the latter is also quite fast on newer CPUs, and sligthly better
*
* the next one is also quite good, albeit slow ;)
* (int)(cos(h & 0xffffff) * 1e6)
*/
#if 0
/* original lzv-like hash function, much worse and thus slower */
@@ -406,214 +291,177 @@ lzf_decompress (const void *const in_data, size_t in_len,
# define IDX(h) ((h) & (HSIZE - 1))
#endif
#if __GNUC__ >= 3
# define expect(expr,value) __builtin_expect ((expr),(value))
# define inline inline
#else
# define expect(expr,value) (expr)
# define inline static
#endif
#define expect_false(expr) expect ((expr) != 0, 0)
#define expect_true(expr) expect ((expr) != 0, 1)
#define MAX_LIT (1 << 5)
#define MAX_OFF (1 << 13)
#define MAX_REF ((1 << 8) + (1 << 3))
/*
* compressed format
*
* 000LLLLL <L+1> ; literal, L+1=1..33 octets
* LLLooooo oooooooo ; backref L+1=1..7 octets, o+1=1..4096 offset
* 111ooooo LLLLLLLL oooooooo ; backref L+8 octets, o+1=1..4096 offset
* 000LLLLL <L+1> ; literal
* LLLooooo oooooooo ; backref L
* 111ooooo LLLLLLLL oooooooo ; backref L+7
*
*/
size_t
lzf_compress (const void *const in_data, size_t in_len,
void *out_data, size_t out_len
lzf_compress (const void *const in_data,size_t in_len,
void *out_data, size_t out_len
#if LZF_STATE_ARG
, LZF_STATE htab
, LZF_STATE *htab
#endif
)
)
{
#if !LZF_STATE_ARG
LZF_STATE htab;
#endif
const u8 **hslot;
const u8 *ip = (const u8 *)in_data;
u8 *op = (u8 *)out_data;
u8 *op = (u8 *)out_data;
const u8 *in_end = ip + in_len;
u8 *out_end = op + out_len;
const u8 *ref;
/*
* off requires a type wide enough to hold a general pointer difference.
* ISO C doesn't have that (size_t might not be enough and ptrdiff_t only
* works for differences within a single object). We also assume that
* no bit pattern traps. Since the only platform that is both non-POSIX
* and fails to support both assumptions is windows 64 bit, we make a
* special workaround for it.
*/
u8 *out_end = op + out_len;
const u8 *ref = NULL;
unsigned int hval = FRST (ip);
size_t off;
unsigned int hval;
int lit;
if (!in_len || !out_len)
return 0;
int lit = 0;
#if INIT_HTAB
# if USE_MEMCPY
memset (htab, 0, sizeof (htab));
# else
for (hslot = htab; hslot < htab + HSIZE; hslot++)
*hslot++ = ip;
# endif
#endif
lit = 0; op++; /* start run */
hval = FRST (ip);
while (ip < in_end - 2)
for (;;)
{
LZF_HSLOT *hslot;
hval = NEXT (hval, ip);
hslot = htab + IDX (hval);
ref = *hslot + LZF_HSLOT_BIAS; *hslot = ip - LZF_HSLOT_BIAS;
if (1
#if INIT_HTAB
&& ref < ip /* the next test will actually take care of this, but this is faster */
#endif
&& (off = ip - ref - 1) < LZF_MAX_OFF
&& ref > (const u8 *)in_data
&& ref[2] == ip[2]
#if STRICT_ALIGN
&& ((ref[1] << 8) | ref[0]) == ((ip[1] << 8) | ip[0])
#else
&& *(const u16 *)ref == *(const u16 *)ip
#endif
)
if (ip < in_end - 2)
{
/* match found at *ref++ */
unsigned int len = 2;
size_t maxlen = in_end - ip - len;
maxlen = maxlen > LZF_MAX_REF ? LZF_MAX_REF : maxlen;
hval = NEXT (hval, ip);
hslot = htab + IDX (hval);
ref = *hslot; *hslot = ip;
if (expect_false (op + 3 + 1 >= out_end)) /* first a faster conservative test */
if (op - !lit + 3 + 1 >= out_end) /* second the exact but rare test */
return 0;
op [- lit - 1] = lit - 1; /* stop run */
op -= !lit; /* undo run if length is zero */
for (;;)
if (
#if INIT_HTAB && !USE_MEMCPY
ref < ip /* the next test will actually take care of this, but this is faster */
&&
#endif
(off = ip - ref - 1) < MAX_OFF
&& ip + 4 < in_end
&& ref > (const u8 *)in_data
#if STRICT_ALIGN
&& ref[0] == ip[0]
&& ref[1] == ip[1]
&& ref[2] == ip[2]
#else
&& *(const u16 *)ref == *(const u16 *)ip
&& ref[2] == ip[2]
#endif
)
{
if (expect_true (maxlen > 16))
{
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
/* match found at *ref++ */
unsigned int len = 2;
size_t maxlen = in_end - ip - len;
maxlen = maxlen > MAX_REF ? MAX_REF : maxlen;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
}
if (op + lit + 1 + 3 >= out_end)
return 0;
do
len++;
while (len < maxlen && ref[len] == ip[len]);
break;
}
if (lit)
{
*op++ = (u8)(lit - 1);
lit = -lit;
do
*op++ = ip[lit];
while (++lit);
}
len -= 2; /* len is now #octets - 1 */
ip++;
len -= 2;
ip++;
if (len < 7)
{
*op++ = (off >> 8) + (len << 5);
}
else
{
*op++ = (off >> 8) + ( 7 << 5);
*op++ = len - 7;
}
if (len < 7)
{
*op++ = (u8)((off >> 8) + (len << 5));
}
else
{
*op++ = (u8)((off >> 8) + ( 7 << 5));
*op++ = (u8)(len - 7);
}
*op++ = off;
lit = 0; op++; /* start run */
ip += len + 1;
if (expect_false (ip >= in_end - 2))
break;
*op++ = (u8)off;
#if ULTRA_FAST || VERY_FAST
--ip;
# if VERY_FAST && !ULTRA_FAST
--ip;
# endif
hval = FRST (ip);
hval = NEXT (hval, ip);
htab[IDX (hval)] = ip - LZF_HSLOT_BIAS;
ip++;
# if VERY_FAST && !ULTRA_FAST
hval = NEXT (hval, ip);
htab[IDX (hval)] = ip - LZF_HSLOT_BIAS;
ip++;
# endif
#else
ip -= len + 1;
do
{
hval = NEXT (hval, ip);
htab[IDX (hval)] = ip - LZF_HSLOT_BIAS;
ip++;
}
while (len--);
ip += len;
#if VERY_FAST && !ULTRA_FAST
--ip;
#endif
hval = FRST (ip);
hval = NEXT (hval, ip);
htab[IDX (hval)] = ip;
ip++;
#if VERY_FAST && !ULTRA_FAST
hval = NEXT (hval, ip);
htab[IDX (hval)] = ip;
ip++;
#endif
#else
do
{
hval = NEXT (hval, ip);
htab[IDX (hval)] = ip;
ip++;
}
while (len--);
#endif
continue;
}
}
else
else if (ip == in_end)
break;
/* one more literal byte we must copy */
lit++;
ip++;
if (lit == MAX_LIT)
{
/* one more literal byte we must copy */
if (expect_false (op >= out_end))
if (op + 1 + MAX_LIT >= out_end)
return 0;
lit++; *op++ = *ip++;
if (expect_false (lit == LZF_MAX_LIT))
{
op [- lit - 1] = lit - 1; /* stop run */
lit = 0; op++; /* start run */
}
*op++ = MAX_LIT - 1;
#if USE_MEMCPY
M_Memcpy (op, ip - MAX_LIT, MAX_LIT);
op += MAX_LIT;
lit = 0;
#else
lit = -lit;
do
*op++ = ip[lit];
while (++lit);
#endif
}
}
if (op + 3 > out_end) /* at most 3 bytes can be missing here */
return 0;
while (ip < in_end)
if (lit)
{
lit++; *op++ = *ip++;
if (op + lit + 1 >= out_end)
return 0;
if (expect_false (lit == LZF_MAX_LIT))
{
op [- lit - 1] = lit - 1; /* stop run */
lit = 0; op++; /* start run */
}
*op++ = (u8)(lit - 1);
lit = -lit;
do
*op++ = ip[lit];
while (++lit);
}
op [- lit - 1] = lit - 1; /* end run */
op -= !lit; /* undo run if length is zero */
return op - (u8 *)out_data;
return op - (u8 *) out_data;
}
+2 -2
View File
@@ -1,6 +1,6 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (c) 2000-2010 Marc Alexander Lehmann <schmorp@schmorp.de>
// Copyright (C) 2000-2005 by Marc Alexander Lehmann <schmorp@schmorp.de>
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
@@ -22,7 +22,7 @@
**
***********************************************************************/
#define LZF_VERSION 0x0106 /* 1.6 */
#define LZF_VERSION 0x0105 /* 1.5 */
/*
* Compress in_len bytes stored at the memory block starting at
+1 -1
View File
@@ -1091,7 +1091,7 @@ void OP_ObjectplaceMovement(player_t *player)
{
ticcmd_t *cmd = &player->cmd;
if (!player->climbing && (netgame || !cv_analog.value || (player->pflags & PF_SPINNING)))
if (!player->climbing && (netgame || (player->pflags & PF_SPINNING)))
player->mo->angle = (cmd->angleturn<<16 /* not FRACBITS */);
ticruned++;
+29
View File
@@ -247,6 +247,35 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedRound(fixed_t x)
return INT32_MAX;
}
/** \brief The xs_CRoundToInt function
\param val double number
\return Round toward nearest, but ties round toward even
*/
#if defined(SRB2_BIG_ENDIAN)
#define _xs_iexp_ 0
#define _xs_iman_ 1
#else
#define _xs_iexp_ 1 //intel is little endian
#define _xs_iman_ 0
#endif //BigEndian_
typedef double real64;
typedef union _xs_doubleints
{
real64 val;
unsigned ival[2];
} _xs_doubleints;
FUNCMATH FUNCINLINE static ATTRINLINE int xs_CRoundToInt(real64 val)
{
_xs_doubleints uval;
uval.val = val + 6755399441055744.0;
return uval.ival[_xs_iman_];
}
typedef struct
{
fixed_t x;
+404 -410
View File
File diff suppressed because it is too large. Load diff
+4
View File
@@ -299,6 +299,10 @@ void Bird_menu_Onchange(void);
// Saturn Hud menu updating
void SaturnHud_menu_Onchange(void);
#ifdef HWRENDER
void M_UpdateOGLMenu(void);
#endif
void M_ReplayHut(INT32 choice);
void M_SetPlaybackMenuPointer(void);
+80
View File
@@ -27,6 +27,8 @@
// Extended map support.
#include <ctype.h>
#include "am_map.h"
#include "doomdef.h"
#include "g_game.h"
#include "m_misc.h"
@@ -1573,6 +1575,84 @@ boolean M_ScreenshotResponder(event_t *ev)
return true;
}
void M_MinimapGenerate(void)
{
#ifdef USE_PNG
char *filepath;
boolean ret = false;
minigen_t *minigen = NULL;
size_t option_scale;
INT32 mul = 1;
if (gamestate != GS_LEVEL)
{
CONS_Alert(CONS_ERROR, "You must be in a level to generate a preliminary minimap!\n");
return;
}
if (automapactive)
{
CONS_Alert(CONS_ERROR, "The automap is active! Please deactivate it and try again.\n");
return;
}
option_scale = COM_CheckPartialParm("-m");
if (option_scale)
{
if (COM_Argc() < option_scale + 2)/* no argument after? */
{
CONS_Alert(CONS_ERROR,
"No multiplier follows parameter '%s'.\n",
COM_Argv(option_scale));
return;
}
mul = atoi(COM_Argv(option_scale + 1));
if (mul < 1 || mul > 10)
{
CONS_Alert(CONS_ERROR,
"Multiplier %d must be within range 1-10.\n",
mul);
return;
}
filepath = va("%s" PATHSEP "%s-MINIMAP-%d.png", srb2home, G_BuildMapName(gamemap), mul);
}
else
{
filepath = va("%s" PATHSEP "%s-MINIMAP.png", srb2home, G_BuildMapName(gamemap));
}
minigen = AM_MinimapGenerate(mul);
if (minigen == NULL || minigen->buf == NULL)
goto failure;
M_CreateScreenShotPalette();
ret = M_SavePNG(filepath, minigen->buf, minigen->w, minigen->h, screenshot_palette);
failure:
if (minigen->buf != NULL)
free(minigen->buf);
if (ret)
{
CONS_Printf(M_GetText("%s saved.\nRemember that this is not a complete minimap,\nand must be edited before putting in-game.\n"), filepath);
if (mul != 1)
{
CONS_Printf("You should divide its size by %d!\n", mul);
}
}
else
{
CONS_Alert(CONS_ERROR, M_GetText("Couldn't create %s\n"), filepath);
}
#endif //#ifdef USE_PNG
}
// ==========================================================================
// TRANSLATION FUNCTIONS
// ==========================================================================
+2
View File
@@ -69,6 +69,8 @@ void M_ScreenShot(void);
void M_DoScreenShot(void);
boolean M_ScreenshotResponder(event_t *ev);
void M_MinimapGenerate(void);
void Command_SaveConfig_f(void);
void Command_LoadConfig_f(void);
void Command_ChangeConfig_f(void);
+4 -4
View File
@@ -301,7 +301,7 @@ static boolean PS_IsRowValid(perfstatrow_t *row)
|| (row->flags & PS_SW && rendermode != render_soft)
|| (row->flags & PS_HW && rendermode != render_opengl)
#ifdef HWRENDER
|| (row->flags & PS_BATCHING && !cv_grbatching.value)
|| (row->flags & PS_BATCHING && !cv_glbatching.value)
#endif
);
}
@@ -518,7 +518,7 @@ static void PS_UpdateFrameStats(void)
ps_hw_spritesorttime.value.p +
ps_hw_spritedrawtime.value.p;
if (cv_grbatching.value)
if (cv_glbatching.value)
{
ps_otherrendertime.value.p -=
ps_hw_batchsorttime.value.p +
@@ -547,7 +547,7 @@ static void PS_UpdateFrameStats(void)
PS_UpdateRowHistories(interpolation_rows, true);*/
#ifdef HWRENDER
if (rendermode == render_opengl && cv_grbatching.value)
if (rendermode == render_opengl && cv_glbatching.value)
{
PS_UpdateRowHistories(batchcount_rows, true);
PS_UpdateRowHistories(batchcalls_rows, true);
@@ -760,7 +760,7 @@ static void PS_DrawRenderStats(void)
/*cy = */PS_DrawPerfRows(x, 10, V_BLUEMAP, commoncounter_rows);// + half_row;
#ifdef HWRENDER
if (rendermode == render_opengl && cv_grbatching.value)
if (rendermode == render_opengl && cv_glbatching.value)
{
x = hires ? 200 : 155;
y = PS_DrawPerfRows(x, 10, V_PURPLEMAP, batchcount_rows);
+18 -5
View File
@@ -118,6 +118,15 @@ static void M_TextInputToWordBegin(textinput_t *input, boolean move_sel)
if (move_sel) input->select = input->cursor;
}
static void M_TextInputPaste(textinput_t *input)
{
const char *paste = I_ClipboardPaste();
if (input->select != input->cursor)
M_TextInputDelSelection(input);
if (paste != NULL)
M_TextInputAddString(input, paste);
}
void M_TextInputInit(textinput_t *input, char *buffer, size_t buffer_size)
{
input->buffer = buffer;
@@ -131,6 +140,8 @@ void M_TextInputClear(textinput_t *input)
input->cursor = 0;
input->select = 0;
input->length = 0;
input->buffer[0] = 0;
}
void M_TextInputSetString(textinput_t *input, const char *c)
@@ -147,6 +158,12 @@ boolean M_TextInputHandle(textinput_t *input, INT32 key)
|| key == KEY_LALT || key == KEY_RALT)
return false;
if (shiftdown && key == KEY_INS)
{
M_TextInputPaste(input);
return true;
}
if ((cv_keyboardlayout.value != 3 && ctrldown) || (cv_keyboardlayout.value == 3 && ctrldown && !altdown))
{
if (key == 'x' || key == 'X')
@@ -168,11 +185,7 @@ boolean M_TextInputHandle(textinput_t *input, INT32 key)
}
else if (key == 'v' || key == 'V')
{
const char *paste = I_ClipboardPaste();
if (input->select != input->cursor)
M_TextInputDelSelection(input);
if (paste != NULL)
M_TextInputAddString(input, paste);
M_TextInputPaste(input);
return true;
}
else if (key == 'w' || key == 'W')
+1 -78
View File
@@ -165,9 +165,6 @@ void A_SpawnObjectAbsolute(mobj_t *actor);
void A_SpawnObjectRelative(mobj_t *actor);
void A_ChangeAngleRelative(mobj_t *actor);
void A_ChangeAngleAbsolute(mobj_t *actor);
void A_RollAngle(mobj_t *actor);
void A_ChangeRollAngleRelative(mobj_t *actor);
void A_ChangeRollAngleAbsolute(mobj_t *actor);
void A_PlaySound(mobj_t *actor);
void A_FindTarget(mobj_t *actor);
void A_FindTracer(mobj_t *actor);
@@ -2658,7 +2655,7 @@ void A_BossDeath(mobj_t *mo)
}
bossjustdie:
if (LUAh_BossDeath(mo))
if (LUA_HookMobj(mo, MOBJ_HOOK(BossDeath)))
return;
else if (P_MobjWasRemoved(mo))
return;
@@ -7183,80 +7180,6 @@ void A_ChangeAngleAbsolute(mobj_t *actor)
actor->angle = FixedAngle(P_RandomRange(amin, amax));
}
// Function: A_RollAngle
//
// Description: Changes the roll angle.
//
// var1 = angle
// var2 = relative? (default)
//
void A_RollAngle(mobj_t *actor)
{
INT32 locvar1 = var1;
INT32 locvar2 = var2;
const angle_t angle = FixedAngle(locvar1*FRACUNIT);
if (LUA_CallAction(A_ROLLANGLE, actor))
return;
// relative (default)
if (!locvar2)
actor->rollangle += angle;
// absolute
else
actor->rollangle = angle;
}
// Function: A_ChangeRollAngleRelative
//
// Description: Changes the roll angle to a random relative value between the min and max. Set min and max to the same value to eliminate randomness
//
// var1 = min
// var2 = max
//
void A_ChangeRollAngleRelative(mobj_t *actor)
{
INT32 locvar1 = var1;
INT32 locvar2 = var2;
const fixed_t amin = locvar1*FRACUNIT;
const fixed_t amax = locvar2*FRACUNIT;
if (LUA_CallAction(A_CHANGEROLLANGLERELATIVE, actor))
return;
#ifdef PARANOIA
if (amin > amax)
I_Error("A_ChangeRollAngleRelative: var1 is greater than var2");
#endif
actor->rollangle += FixedAngle(P_RandomRange(amin, amax));
}
// Function: A_ChangeRollAngleAbsolute
//
// Description: Changes the roll angle to a random absolute value between the min and max. Set min and max to the same value to eliminate randomness
//
// var1 = min
// var2 = max
//
void A_ChangeRollAngleAbsolute(mobj_t *actor)
{
INT32 locvar1 = var1;
INT32 locvar2 = var2;
const fixed_t amin = locvar1*FRACUNIT;
const fixed_t amax = locvar2*FRACUNIT;
if (LUA_CallAction(A_CHANGEROLLANGLEABSOLUTE, actor))
return;
#ifdef PARANOIA
if (amin > amax)
I_Error("A_ChangeRollAngleAbsolute: var1 is greater than var2");
#endif
actor->rollangle = FixedAngle(P_RandomRange(amin, amax));
}
// Function: A_PlaySound
//
// Description: Plays a sound
+36 -111
View File
@@ -2119,10 +2119,11 @@ void T_EachTimeThinker(levelspecthink_t *eachtime)
sec = &sectors[secnum];
FOFsector = false;
INT32 special = GETSECSPECIAL(sec->special, 2);
if (GETSECSPECIAL(sec->special, 2) == 3 || GETSECSPECIAL(sec->special, 2) == 5)
if (special == 3 || special == 5)
floortouch = true;
else if (GETSECSPECIAL(sec->special, 2) >= 1 && GETSECSPECIAL(sec->special, 2) <= 8)
else if (special >= 1 && special <= 8)
floortouch = false;
else
continue;
@@ -2254,7 +2255,7 @@ void T_EachTimeThinker(levelspecthink_t *eachtime)
continue;
if (!(players[i].mo->subsector->sector == sec
|| P_PlayerTouchingSectorSpecial(&players[i], 2, (GETSECSPECIAL(sec->special, 2))) == sec))
|| P_PlayerTouchingSectorSpecial(&players[i], 2, special) == sec))
continue;
if (floortouch == true && P_IsObjectOnRealGround(players[i].mo, sec))
@@ -2298,7 +2299,9 @@ void T_EachTimeThinker(levelspecthink_t *eachtime)
while ((affectPlayer = P_HavePlayersEnteredArea(playersArea, oldPlayersArea, inAndOut)) != -1)
{
if (GETSECSPECIAL(sec->special, 2) == 2 || GETSECSPECIAL(sec->special, 2) == 3)
INT32 special = GETSECSPECIAL(sec->special, 2);
if (special == 2 || special == 3)
{
for (i = 0; i < MAXPLAYERS; i++)
{
@@ -2507,123 +2510,44 @@ void T_CameraScanner(elevator_t *elevator)
{
// leveltime is compared to make multiple scanners in one map function correctly.
static tic_t lastleveltime = 32000; // any number other than 0 should do here
static boolean camerascanned, camerascanned2, camerascanned3, camerascanned4;
static boolean camerascanned[MAXSPLITSCREENPLAYERS];
static fixed_t t_cam_dist[MAXSPLITSCREENPLAYERS] = {-42, -42, -42, -42};
static fixed_t t_cam_height[MAXSPLITSCREENPLAYERS] = {-42, -42, -42, -42};
if (leveltime != lastleveltime) // Back on the first camera scanner
{
camerascanned = camerascanned2 = camerascanned3 = camerascanned4 = false;
memset(camerascanned, false, sizeof (camerascanned));
lastleveltime = leveltime;
}
if (players[displayplayers[0]].mo)
for (UINT8 i = 0; i <= splitscreen; i++)
{
if (players[displayplayers[0]].mo->subsector->sector == elevator->actionsector)
{
if (t_cam_dist == -42)
t_cam_dist = cv_cam_dist.value;
if (t_cam_height == -42)
t_cam_height = cv_cam_height.value;
if (t_cam_rotate == -42)
t_cam_rotate = cv_cam_rotate.value;
CV_SetValue(&cv_cam_height, FixedInt(elevator->sector->floorheight));
CV_SetValue(&cv_cam_dist, FixedInt(elevator->sector->ceilingheight));
CV_SetValue(&cv_cam_rotate, elevator->distance);
camerascanned = true;
}
else if (!camerascanned)
{
if (t_cam_height != -42 && cv_cam_height.value != t_cam_height)
CV_Set(&cv_cam_height, va("%f", (double)FIXED_TO_FLOAT(t_cam_height)));
if (t_cam_dist != -42 && cv_cam_dist.value != t_cam_dist)
CV_Set(&cv_cam_dist, va("%f", (double)FIXED_TO_FLOAT(t_cam_dist)));
if (t_cam_rotate != -42 && cv_cam_rotate.value != t_cam_rotate)
CV_Set(&cv_cam_rotate, va("%f", (double)t_cam_rotate));
if (!players[displayplayers[i]].mo || P_MobjWasRemoved(players[displayplayers[i]].mo))
continue;
t_cam_dist = t_cam_height = t_cam_rotate = -42;
}
}
if (splitscreen && players[displayplayers[1]].mo)
{
if (players[displayplayers[1]].mo->subsector->sector == elevator->actionsector)
if (players[displayplayers[i]].mo->subsector->sector == elevator->actionsector)
{
if (t_cam2_rotate == -42)
t_cam2_dist = cv_cam2_dist.value;
if (t_cam2_rotate == -42)
t_cam2_height = cv_cam2_height.value;
if (t_cam2_rotate == -42)
t_cam2_rotate = cv_cam2_rotate.value;
CV_SetValue(&cv_cam2_height, FixedInt(elevator->sector->floorheight));
CV_SetValue(&cv_cam2_dist, FixedInt(elevator->sector->ceilingheight));
CV_SetValue(&cv_cam2_rotate, elevator->distance);
camerascanned2 = true;
if (t_cam_dist[i] == -42)
t_cam_dist[i] = cv_cam_dist[i].value;
if (t_cam_height[i] == -42)
t_cam_height[i] = cv_cam_height[i].value;
if (t_cam_rotate[i] == -42)
t_cam_rotate[i] = cv_cam_rotate[i].value;
CV_SetValue(&cv_cam_height[i], FixedInt(elevator->sector->floorheight));
CV_SetValue(&cv_cam_dist[i], FixedInt(elevator->sector->ceilingheight));
CV_SetValue(&cv_cam_rotate[i], elevator->distance);
camerascanned[i] = true;
}
else if (!camerascanned2)
else if (!camerascanned[i])
{
if (t_cam2_height != -42 && cv_cam2_height.value != t_cam2_height)
CV_Set(&cv_cam2_height, va("%f", (double)FIXED_TO_FLOAT(t_cam2_height)));
if (t_cam2_dist != -42 && cv_cam2_dist.value != t_cam2_dist)
CV_Set(&cv_cam2_dist, va("%f", (double)FIXED_TO_FLOAT(t_cam2_dist)));
if (t_cam2_rotate != -42 && cv_cam2_rotate.value != t_cam2_rotate)
CV_Set(&cv_cam2_rotate, va("%f", (double)t_cam2_rotate));
if (t_cam_height[i] != -42 && cv_cam_height[i].value != t_cam_height[i])
CV_Set(&cv_cam_height[i], va("%f", (double)FIXED_TO_FLOAT(t_cam_height[i])));
if (t_cam_dist[i] != -42 && cv_cam_dist[i].value != t_cam_dist[i])
CV_Set(&cv_cam_dist[i], va("%f", (double)FIXED_TO_FLOAT(t_cam_dist[i])));
if (t_cam_rotate[i] != -42 && cv_cam_rotate[i].value != t_cam_rotate[i])
CV_Set(&cv_cam_rotate[i], va("%f", (double)t_cam_rotate[i]));
t_cam2_dist = t_cam2_height = t_cam2_rotate = -42;
}
}
if (splitscreen > 1 && players[displayplayers[2]].mo)
{
if (players[displayplayers[2]].mo->subsector->sector == elevator->actionsector)
{
if (t_cam3_rotate == -42)
t_cam3_dist = cv_cam3_dist.value;
if (t_cam3_rotate == -42)
t_cam3_height = cv_cam3_height.value;
if (t_cam3_rotate == -42)
t_cam3_rotate = cv_cam3_rotate.value;
CV_SetValue(&cv_cam3_height, FixedInt(elevator->sector->floorheight));
CV_SetValue(&cv_cam3_dist, FixedInt(elevator->sector->ceilingheight));
CV_SetValue(&cv_cam3_rotate, elevator->distance);
camerascanned3 = true;
}
else if (!camerascanned3)
{
if (t_cam3_height != -42 && cv_cam3_height.value != t_cam3_height)
CV_Set(&cv_cam3_height, va("%f", (double)FIXED_TO_FLOAT(t_cam3_height)));
if (t_cam3_dist != -42 && cv_cam3_dist.value != t_cam3_dist)
CV_Set(&cv_cam3_dist, va("%f", (double)FIXED_TO_FLOAT(t_cam3_dist)));
if (t_cam3_rotate != -42 && cv_cam3_rotate.value != t_cam3_rotate)
CV_Set(&cv_cam3_rotate, va("%f", (double)t_cam3_rotate));
t_cam3_dist = t_cam3_height = t_cam3_rotate = -42;
}
}
if (splitscreen > 2 && players[displayplayers[3]].mo)
{
if (players[displayplayers[3]].mo->subsector->sector == elevator->actionsector)
{
if (t_cam4_rotate == -42)
t_cam4_dist = cv_cam4_dist.value;
if (t_cam4_rotate == -42)
t_cam4_height = cv_cam4_height.value;
if (t_cam4_rotate == -42)
t_cam4_rotate = cv_cam4_rotate.value;
CV_SetValue(&cv_cam4_height, FixedInt(elevator->sector->floorheight));
CV_SetValue(&cv_cam4_dist, FixedInt(elevator->sector->ceilingheight));
CV_SetValue(&cv_cam4_rotate, elevator->distance);
camerascanned4 = true;
}
else if (!camerascanned4)
{
if (t_cam4_height != -42 && cv_cam4_height.value != t_cam4_height)
CV_Set(&cv_cam4_height, va("%f", (double)FIXED_TO_FLOAT(t_cam4_height)));
if (t_cam4_dist != -42 && cv_cam4_dist.value != t_cam4_dist)
CV_Set(&cv_cam4_dist, va("%f", (double)FIXED_TO_FLOAT(t_cam4_dist)));
if (t_cam4_rotate != -42 && cv_cam4_rotate.value != t_cam4_rotate)
CV_Set(&cv_cam4_rotate, va("%f", (double)t_cam4_rotate));
t_cam4_dist = t_cam4_height = t_cam4_rotate = -42;
t_cam_dist[i] = t_cam_height[i] = t_cam_rotate[i] = -42;
}
}
}
@@ -2996,11 +2920,12 @@ void EV_CrumbleChain(sector_t *sec, ffloor_t *rover)
fixed_t a, b, c;
mobjtype_t type = MT_ROCKCRUMBLE1;
const fixed_t spacing = 48*mapobjectscale;
INT32 special = GETSECSPECIAL(rover->master->frontsector->special, 3);
// If the control sector has a special
// of Section3:7-15, use the custom debris.
if (GETSECSPECIAL(rover->master->frontsector->special, 3) >= 8)
type = MT_ROCKCRUMBLE1+(GETSECSPECIAL(rover->master->frontsector->special, 3)-7);
if (special >= 8)
type = MT_ROCKCRUMBLE1+(special-7);
// soundorg z height never gets set normally, so MEH.
sec->soundorg.z = sec->floorheight;
+12 -16
View File
@@ -284,7 +284,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
if (special->flags & MF_BOSS && special->flags2 & MF2_FRET)
return;
if (LUAh_TouchSpecial(special, toucher) || P_MobjWasRemoved(special))
if (LUA_HookTouchSpecial(special, toucher) || P_MobjWasRemoved(special))
return;
if (special->flags & MF_BOSS)
@@ -976,11 +976,10 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
break;
case MT_HOOPCOLLIDE:
// This produces a kind of 'domino effect' with the hoop's pieces.
if (!midgamejoin)
for (; special->hprev != NULL; special = special->hprev); // Move to the first sprite in the hoop
for (; !P_MobjWasRemoved(special->hprev); special = special->hprev); // Move to the first sprite in the hoop
i = 0;
for (; special->type == MT_HOOP; special = special->hnext)
for (; !P_MobjWasRemoved(special->hnext) && special->type == MT_HOOP; special = special->hnext)
{
special->fuse = 11;
special->movedir = i;
@@ -1641,7 +1640,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source)
target->flags2 &= ~(MF2_SKULLFLY|MF2_NIGHTSPULL);
target->health = 0; // This makes it easy to check if something's dead elsewhere.
if (LUAh_MobjDeath(target, inflictor, source) || P_MobjWasRemoved(target))
if (LUA_HookMobjDeath(target, inflictor, source) || P_MobjWasRemoved(target))
return;
// SRB2kart
@@ -2397,11 +2396,9 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
// Everything above here can't be forced.
if (!metalrecording)
{
UINT8 shouldForce = LUAh_ShouldDamage(target, inflictor, source, damage);
UINT8 shouldForce = LUA_HookShouldDamage(target, inflictor, source, damage);
if (P_MobjWasRemoved(target))
return (shouldForce == 1); // mobj was removed
if (P_MobjWasRemoved(source))
source = NULL;
if (shouldForce == 1)
force = true;
else if (shouldForce == 2)
@@ -2440,7 +2437,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
if (!force && target->fuse) // Invincible
return false;
if (LUAh_MobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target))
if (LUA_HookMobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target))
return true;
if (target->health > 1)
@@ -2466,7 +2463,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
if (!force && target->flags2 & MF2_FRET) // Currently flashing from being hit
return false;
if (LUAh_MobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target))
if (LUA_HookMobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target))
return true;
if (target->health > 1)
@@ -2474,7 +2471,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
}
else if (target->flags & MF_ENEMY)
{
if (LUAh_MobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target))
if (LUA_HookMobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target))
return true;
}
@@ -2503,14 +2500,14 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
return false; // Don't run eachother over in special stages and team games and such
}
if (LUAh_MobjDamage(target, inflictor, source, damage))
if (LUA_HookMobjDamage(target, inflictor, source, damage))
return true;
P_NiGHTSDamage(target, source); // -5s :(
return true;
}
if (LUAh_MobjDamage(target, inflictor, source, damage))
if (LUA_HookMobjDamage(target, inflictor, source, damage))
return true;
if (!force && inflictor && (inflictor->flags & MF_FIRE))
@@ -2638,6 +2635,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
P_ResetPlayer(target->player);
}
else
{
switch (target->type)
{
case MT_EGGMOBILE2: // egg slimer
@@ -2651,9 +2649,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
P_SetMobjState(target, target->info->painstate);
break;
}
if (P_MobjWasRemoved(target))
return false;
}
if (!P_MobjWasRemoved(target))
{
+23 -20
View File
@@ -66,6 +66,7 @@
// both the head and tail of the thinker list
extern thinker_t thinkercap;
extern mobj_t *mobjcache;
void P_InitThinkers(void);
void P_AddThinker(thinker_t *thinker);
@@ -116,7 +117,7 @@ struct demofreecam_s {
camera_t *cam; // this is useful when the game is paused, notably
mobj_t *soundmobj; // mobj to play sound from, used in s_sound
angle_t localangle; // keeps track of the cam angle for cmds
angle_t localaiming; // ditto with aiming
boolean turnheld; // holding turn button for gradual turn speed
@@ -126,17 +127,12 @@ struct demofreecam_s {
extern struct demofreecam_s democam;
extern camera_t camera[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_cam_dist, cv_cam_still, cv_cam_height;
extern consvar_t cv_cam_speed, cv_cam_rotate, cv_cam_rotspeed;
extern consvar_t cv_cam2_dist, cv_cam2_still, cv_cam2_height;
extern consvar_t cv_cam2_speed, cv_cam2_rotate, cv_cam2_rotspeed;
extern consvar_t cv_cam3_dist, cv_cam3_still, cv_cam3_height;
extern consvar_t cv_cam3_speed, cv_cam3_rotate, cv_cam3_rotspeed;
extern consvar_t cv_cam4_dist, cv_cam4_still, cv_cam4_height;
extern consvar_t cv_cam4_speed, cv_cam4_rotate, cv_cam4_rotspeed;
extern consvar_t cv_cam_dist[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_cam_still[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_cam_height[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_cam_speed[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_cam_rotate[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_cam_rotspeed[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_tilting;
extern consvar_t cv_quaketilt;
@@ -146,10 +142,7 @@ extern consvar_t cv_actionmovie;
extern consvar_t cv_lookbackmom;
extern fixed_t t_cam_dist, t_cam_height, t_cam_rotate;
extern fixed_t t_cam2_dist, t_cam2_height, t_cam2_rotate;
extern fixed_t t_cam3_dist, t_cam3_height, t_cam3_rotate;
extern fixed_t t_cam4_dist, t_cam4_height, t_cam4_rotate;
extern fixed_t t_cam_rotate[MAXSPLITSCREENPLAYERS];
fixed_t P_GetPlayerHeight(player_t *player);
fixed_t P_GetPlayerSpinHeight(player_t *player);
@@ -265,7 +258,7 @@ void P_SceneryThinker(mobj_t *mobj);
// To test it in Lua, check mobj.valid
FUNCINLINE static ATTRINLINE boolean P_MobjWasRemoved(const mobj_t *mobj)
{
return !(mobj && mobj->thinker.function.acp1 == (actionf_p1)P_MobjThinker);
return (!mobj || mobj->thinker.function.acp1 != (actionf_p1)P_MobjThinker);
}
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);
@@ -298,7 +291,14 @@ mobj_t *P_SPMAngle(mobj_t *source, mobjtype_t type, angle_t angle, UINT8 aimtype
#define P_SpawnNameFinder(s,t) P_SPMAngle(s,t,s->angle,true,0)
#endif
void P_ColorTeamMissile(mobj_t *missile, player_t *source);
SINT8 P_MobjFlip(const mobj_t *mobj);
// P_MobjFlip
// Special utility to return +1 or -1 depending on mobj's gravity
FUNCINLINE static ATTRINLINE SINT8 P_MobjFlip(const mobj_t *mobj)
{
return (mobj && mobj->eflags & MFE_VERTICALFLIP) ? -1 : 1;
}
fixed_t P_GetMobjGravity(mobj_t *mo);
FUNCMATH boolean P_WeaponOrPanel(mobjtype_t type);
@@ -368,7 +368,11 @@ boolean P_MoveOrigin(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z);
void P_SlideMove(mobj_t *mo, boolean forceslide);
void P_BouncePlayerMove(mobj_t *mo);
void P_BounceMove(mobj_t *mo);
boolean P_CheckSight(mobj_t *t1, mobj_t *t2);
#define P_CheckSight(t1, t2) P_CheckSight2(t1, t2, false)
#define P_CheckSightFast(t1, t2) P_CheckSight2(t1, t2, true)
boolean P_CheckSight2(mobj_t *t1, mobj_t *t2, boolean fast);
void P_CheckHoopPosition(mobj_t *hoopthing, fixed_t x, fixed_t y, fixed_t z, fixed_t radius);
boolean P_CheckSector(sector_t *sector, boolean crunch);
@@ -441,7 +445,6 @@ 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);
boolean P_CanPickupItem(player_t *player, UINT8 weapon);
+9 -5
View File
@@ -449,7 +449,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
}
{
UINT8 shouldCollide = LUAh_MobjCollide(thing, tmthing); // checks hook for thing's type
UINT8 shouldCollide = LUA_Hook2Mobj(thing, tmthing, MOBJ_HOOK(MobjCollide)); // checks hook for thing's type
if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing))
return true; // one of them was removed???
if (shouldCollide == 1)
@@ -458,7 +458,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
return true; // force no collide
}
{
UINT8 shouldCollide = LUAh_MobjMoveCollide(tmthing, thing); // checks hook for tmthing's type
UINT8 shouldCollide = LUA_Hook2Mobj(tmthing, thing, MOBJ_HOOK(MobjMoveCollide)); // checks hook for tmthing's type
if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing))
return true; // one of them was removed???
if (shouldCollide == 1)
@@ -1727,6 +1727,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
tmbbox[BOXLEFT] = x - tmthing->radius;
newsubsec = R_PointInSubsector(x, y);
ceilingline = blockingline = NULL;
// The base floor / ceiling is from the subsector
@@ -2391,16 +2392,19 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
{
//All things are affected by their scale.
fixed_t maxstep = FixedMul(MAXSTEPMOVE, mapobjectscale);
INT32 special = 0;
if (thing->player)
{
special = GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1);
// If using type Section1:13, double the maxstep.
if (P_PlayerTouchingSectorSpecial(thing->player, 1, 13)
|| GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 13)
|| special == 13)
maxstep <<= 1;
// If using type Section1:12, no maxstep. For ledges you don't want the player to climb! (see: Egg Zeppelin & SMK port walls)
else if (P_PlayerTouchingSectorSpecial(thing->player, 1, 12)
|| GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 12)
|| special == 12)
maxstep = 0;
}
@@ -2446,7 +2450,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
else if (maxstep > 0 && !(
thing->player && (
P_PlayerTouchingSectorSpecial(thing->player, 1, 14)
|| GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 14)
|| special == 14)
)) // Step down
{
// If the floor difference is MAXSTEPMOVE or less, and the sector isn't Section1:14, ALWAYS
+65 -28
View File
@@ -35,23 +35,33 @@ void P_ClosestPointOnLine(fixed_t x, fixed_t y, line_t *line, vertex_t *result)
fixed_t dy = line->dy;
// Determine t (the length of the vector from �Line[0]� to �p�)
fixed_t cx, cy;
fixed_t vx, vy;
fixed_t magnitude;
fixed_t t;
//Sub (p, &Line[0], &c);
cx = x - startx;
cy = y - starty;
//Sub (&Line[1], &Line[0], &V);
vx = dx;
vy = dy;
//Normalize (&V, &V);
magnitude = R_PointToDist2(line->v2->x, line->v2->y, startx, starty);
dx = FixedDiv(dx, magnitude);
dy = FixedDiv(dy, magnitude);
vx = FixedDiv(vx, magnitude);
vy = FixedDiv(vy, magnitude);
t = (FixedMul(dx, (x - startx)) + FixedMul(dy, (y - starty)));
t = (FixedMul(vx, cx) + FixedMul(vy, cy));
// Return the point between �Line[0]� and �Line[1]�
dx = FixedMul(dx, t);
dy = FixedMul(dy, t);
vx = FixedMul(vx, t);
vy = FixedMul(vy, t);
//Add (&Line[0], &V, out);
result->x = startx + dx;
result->y = starty + dy;
result->x = startx + vx;
result->y = starty + vy;
return;
}
@@ -69,15 +79,28 @@ void P_ClosestPointOnLine3D(fixed_t x, fixed_t y, fixed_t z, line_t *line, verte
fixed_t dz = line->v2->z - line->v1->z;
// Determine t (the length of the vector from �Line[0]� to �p�)
fixed_t cx, cy, cz;
fixed_t vx, vy, vz;
fixed_t magnitude;
fixed_t t;
magnitude = R_PointToDist2(0, line->v2->z, R_PointToDist2(line->v2->x, line->v2->y, startx, starty), startz);
dx = FixedDiv(dx, magnitude);
dy = FixedDiv(dy, magnitude);
dz = FixedDiv(dz, magnitude);
//Sub (p, &Line[0], &c);
cx = x - startx;
cy = y - starty;
cz = z - startz;
t = (FixedMul(dx, (x - startx)) + FixedMul(dy, (y - starty)) + FixedMul(dz, (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
if (t <= 0)
@@ -96,14 +119,14 @@ void P_ClosestPointOnLine3D(fixed_t x, fixed_t y, fixed_t z, line_t *line, verte
}
// Return the point between �Line[0]� and �Line[1]�
dx = FixedMul(dx, t);
dy = FixedMul(dy, t);
dz = FixedMul(dz, t);
vx = FixedMul(vx, t);
vy = FixedMul(vy, t);
vz = FixedMul(vz, t);
//Add (&Line[0], &V, out);
result->x = startx + dx;
result->y = starty + dy;
result->z = startz + dz;
result->x = startx + vx;
result->y = starty + vy;
result->z = startz + vz;
return;
}
@@ -113,16 +136,21 @@ void P_ClosestPointOnLine3D(fixed_t x, fixed_t y, fixed_t z, line_t *line, verte
//
INT32 P_PointOnLineSide(fixed_t x, fixed_t y, const line_t *line)
{
fixed_t dx, dy, left, right;
if (!line->dx)
return x <= line->v1->x ? line->dy > 0 : line->dy < 0;
if (!line->dy)
return y <= line->v1->y ? line->dx < 0 : line->dx > 0;
x -= line->v1->x;
y -= line->v1->y;
dx = (x - line->v1->x);
dy = (y - line->v1->y);
return FixedMul(y, line->dx>>FRACBITS) < FixedMul(line->dy>>FRACBITS, x) ? 0 : 1;
left = FixedMul(line->dy>>FRACBITS, dx);
right = FixedMul(dy, line->dx>>FRACBITS);
return right < left ? 0 : 1;
}
//
@@ -182,22 +210,28 @@ INT32 P_BoxOnLineSide(fixed_t *tmbox, const line_t *ld)
//
static INT32 P_PointOnDivlineSide(fixed_t x, fixed_t y, divline_t *line)
{
fixed_t dx, dy, left, right;
if (!line->dx)
return x <= line->x ? line->dy > 0 : line->dy < 0;
if (!line->dy)
return y <= line->y ? line->dx < 0 : line->dx > 0;
x -= line->x;
y -= line->y;
dx = (x - line->x);
dy = (y - line->y);
// try to quickly decide by looking at sign bits
if ((line->dy ^ line->dx ^ x ^ y) & 0x80000000)
return ((line->dy ^ x) & 0x80000000) ? 1 : 0;
if ((line->dy ^ line->dx ^ dx ^ dy) & 0x80000000)
return ((line->dy ^ dx) & 0x80000000) ? 1 : 0;
return FixedMul(y>>8, line->dx>>8) < FixedMul(line->dy>>8, x>>8) ? 0 : 1;
left = FixedMul(line->dy>>8, dx>>8);
right = FixedMul(dy>>8, line->dx>>8);
return right < left ? 0 : 1;
}
//
// P_MakeDivline
//
@@ -216,14 +250,17 @@ void P_MakeDivline(line_t *li, divline_t *dl)
//
fixed_t P_InterceptVector(divline_t *v2, divline_t *v1)
{
fixed_t den;
fixed_t frac, num, den;
den = FixedMul(v1->dy>>8, v2->dx) - FixedMul(v1->dx>>8, v2->dy);
if (!den)
return 0;
return (FixedDiv(FixedMul((v1->x - v2->x)>>8, v1->dy) + FixedMul((v2->y - v1->y)>>8, v1->dx), den));
num = FixedMul((v1->x - v2->x)>>8, v1->dy) + FixedMul((v2->y - v1->y)>>8, v1->dx);
frac = FixedDiv(num, den);
return frac;
}
//
+205 -175
View File
@@ -48,6 +48,7 @@ actioncache_t actioncachehead;
static mobj_t *overlaycap = NULL;
static mobj_t *shadowcap = NULL;
mobj_t *waypointcap = NULL;
mobj_t *mobjcache = NULL;
void P_InitCachedActions(void)
{
@@ -91,6 +92,7 @@ FUNCINLINE static ATTRINLINE void P_CycleStateAnimation(mobj_t *mobj)
// var2 determines delay between animation frames
if (!(mobj->frame & FF_ANIMATE) || --mobj->anim_duration != 0)
return;
mobj->anim_duration = (UINT16)mobj->state->var2;
// compare the current sprite frame to the one we started from
@@ -351,18 +353,6 @@ static boolean P_SetPrecipMobjState(precipmobj_t *mobj, statenum_t state)
return true;
}
//
// P_MobjFlip
//
// Special utility to return +1 or -1 depending on mobj's gravity
//
SINT8 P_MobjFlip(const mobj_t *mobj)
{
if (mobj && mobj->eflags & MFE_VERTICALFLIP)
return -1;
return 1;
}
//
// P_WeaponOrPanel
//
@@ -408,7 +398,7 @@ void P_ExplodeMissile(mobj_t *mo)
P_RadiusAttack(mo, mo, 96*FRACUNIT);
explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE);
if (!P_MobjWasRemoved(explodemo))
if (explodemo)
{
P_SetScale(explodemo, mo->scale);
explodemo->destscale = mo->destscale;
@@ -417,7 +407,7 @@ void P_ExplodeMissile(mobj_t *mo)
S_StartSound(explodemo, sfx_pop);
}
explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE);
if (!P_MobjWasRemoved(explodemo))
if (explodemo)
{
P_SetScale(explodemo, mo->scale);
explodemo->destscale = mo->destscale;
@@ -426,7 +416,7 @@ void P_ExplodeMissile(mobj_t *mo)
S_StartSound(explodemo, sfx_dmpain);
}
explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE);
if (!P_MobjWasRemoved(explodemo))
if (explodemo)
{
P_SetScale(explodemo, mo->scale);
explodemo->destscale = mo->destscale;
@@ -435,7 +425,7 @@ void P_ExplodeMissile(mobj_t *mo)
S_StartSound(explodemo, sfx_pop);
}
explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE);
if (!P_MobjWasRemoved(explodemo))
if (explodemo)
{
P_SetScale(explodemo, mo->scale);
explodemo->destscale = mo->destscale;
@@ -1892,12 +1882,13 @@ boolean P_CheckDeathPitCollide(mobj_t *mo)
I_Assert(mo != NULL);
I_Assert(!P_MobjWasRemoved(mo));
INT32 special = GETSECSPECIAL(mo->subsector->sector->special, 1);
if (((mo->z <= mo->subsector->sector->floorheight
&& !(mo->eflags & MFE_VERTICALFLIP) && (mo->subsector->sector->flags & SF_FLIPSPECIAL_FLOOR))
|| (mo->z + mo->height >= mo->subsector->sector->ceilingheight
&& (mo->eflags & MFE_VERTICALFLIP) && (mo->subsector->sector->flags & SF_FLIPSPECIAL_CEILING)))
&& (GETSECSPECIAL(mo->subsector->sector->special, 1) == 6
|| GETSECSPECIAL(mo->subsector->sector->special, 1) == 7))
&& (special == 6 || special == 7))
return true;
return false;
@@ -1908,16 +1899,14 @@ boolean P_CheckSolidLava(mobj_t *mo, ffloor_t *rover)
I_Assert(mo != NULL);
I_Assert(!P_MobjWasRemoved(mo));
{
fixed_t topheight =
*rover->t_slope ? P_GetZAt(*rover->t_slope, mo->x, mo->y) :
*rover->topheight;
fixed_t topheight =
*rover->t_slope ? P_GetZAt(*rover->t_slope, mo->x, mo->y) :
*rover->topheight;
if (rover->flags & FF_SWIMMABLE && GETSECSPECIAL(rover->master->frontsector->special, 1) == 3
&& !(rover->master->flags & ML_BLOCKMONSTERS)
&& ((rover->master->flags & ML_EFFECT3) || mo->z-mo->momz > topheight - FixedMul(16*FRACUNIT, mo->scale)))
return true;
}
if (rover->flags & FF_SWIMMABLE && GETSECSPECIAL(rover->master->frontsector->special, 1) == 3
&& !(rover->master->flags & ML_BLOCKMONSTERS)
&& ((rover->master->flags & ML_EFFECT3) || mo->z-mo->momz > topheight - FixedMul(16*FRACUNIT, mo->scale)))
return true;
return false;
}
@@ -3242,20 +3231,68 @@ void P_DestroyRobots(void)
}
}
// the below is chasecam only, if you're curious. check out P_CalcPostImg in p_user.c for first person
static void P_CalcChasePostImg(player_t *player, camera_t *thiscam)
{
const boolean flipcam = (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP);
UINT16 postimgflags = 0;
UINT8 i;
if (encoremode)
postimgflags |= POSTIMG_MIRROR;
if (flipcam)
postimgflags |= POSTIMG_FLIP;
if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) // Camera must obviously exist
{
camera_t dummycam;
dummycam.subsector = player->awayviewmobj->subsector;
dummycam.x = player->awayviewmobj->x;
dummycam.y = player->awayviewmobj->y;
dummycam.z = player->awayviewmobj->z;
//dummycam.height = 40*FRACUNIT; // alt view height is 20*FRACUNIT
dummycam.height = 0; // Why? Remote viewpoint cameras have no height.
// Are we in water?
if (P_CameraCheckWater(&dummycam))
postimgflags |= POSTIMG_WATER;
if (P_CameraCheckHeat(&dummycam))
postimgflags |= POSTIMG_HEAT;
}
else
{
// Are we in water?
if (P_CameraCheckWater(thiscam))
postimgflags |= POSTIMG_WATER;
if (P_CameraCheckHeat(thiscam))
postimgflags |= POSTIMG_HEAT;
}
for (i = 0; i <= splitscreen; i++)
{
if (player != &players[displayplayers[i]])
continue;
players[displayplayers[i]].postimgflags = postimgflags;
break;
}
}
// P_CameraThinker
//
// Process the mobj-ish required functions of the camera
boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled)
{
boolean itsatwodlevel = false;
boolean flipcam = (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP);
postimg_t postimg = postimg_none;
UINT8 i;
// This can happen when joining
if (thiscam->subsector == NULL || thiscam->subsector->sector == NULL)
return true;
P_CalcChasePostImg(player, thiscam);
if (twodlevel)
itsatwodlevel = true;
else
@@ -3271,64 +3308,27 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled
}
}
if (encoremode && !flipcam)
postimg = postimg_mirror;
else if (!encoremode && flipcam)
postimg = postimg_flip;
else if (encoremode && flipcam)
postimg = postimg_mirrorflip;
else if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) // Camera must obviously exist
{
camera_t dummycam;
dummycam.subsector = player->awayviewmobj->subsector;
dummycam.x = player->awayviewmobj->x;
dummycam.y = player->awayviewmobj->y;
dummycam.z = player->awayviewmobj->z;
//dummycam.height = 40*FRACUNIT; // alt view height is 20*FRACUNIT
dummycam.height = 0; // Why? Remote viewpoint cameras have no height.
// Are we in water?
if (P_CameraCheckWater(&dummycam))
postimg = postimg_water;
else if (P_CameraCheckHeat(&dummycam))
postimg = postimg_heat;
}
else
{
// Are we in water?
if (P_CameraCheckWater(thiscam))
postimg = postimg_water;
else if (P_CameraCheckHeat(thiscam))
postimg = postimg_heat;
}
if (postimg != postimg_none)
{
for (i = 0; i <= splitscreen; i++)
{
if (player != &players[displayplayers[i]])
continue;
postimgtype[i] = postimg;
}
}
if (thiscam->momx || thiscam->momy)
{
if (!P_TryCameraMove(thiscam->x + thiscam->momx, thiscam->y + thiscam->momy, thiscam))
{ // Never fails for 2D mode.
if (!P_TryCameraMove(thiscam->x + thiscam->momx, thiscam->y + thiscam->momy, thiscam)) // Never fails for 2D mode.
{
mobj_t dummy;
dummy.thinker.function.acp1 = (actionf_p1)P_MobjThinker;
dummy.subsector = thiscam->subsector;
dummy.x = thiscam->x;
dummy.y = thiscam->y;
dummy.z = thiscam->z;
dummy.height = thiscam->height;
if (player->pflags & PF_TIMEOVER)
player->kartstuff[k_timeovercam] = (2*TICRATE)+1;
if (!resetcalled && !(player->pflags & PF_NOCLIP || leveltime < introtime) && !P_CheckSight(&dummy, player->mo)) // TODO: "P_CheckCameraSight" instead.
if (!resetcalled && !(player->pflags & PF_NOCLIP || leveltime < introtime) && !P_CheckSightFast(&dummy, player->mo)) // TODO: "P_CheckCameraSight" instead.
P_ResetCamera(player, thiscam);
else
P_SlideCameraMove(thiscam);
if (resetcalled) // Okay this means the camera is fully reset.
return true;
}
@@ -3337,7 +3337,7 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled
if (!itsatwodlevel)
P_CheckCameraPosition(thiscam->x, thiscam->y, thiscam);
thiscam->subsector = R_PointInSubsector(thiscam->x, thiscam->y);
thiscam->subsector = R_PointInSubsectorFast(thiscam->x, thiscam->y);
thiscam->floorz = tmfloorz;
thiscam->ceilingz = tmceilingz;
@@ -3410,8 +3410,8 @@ static void P_PlayerMobjThinker(mobj_t *mobj)
I_Assert(mobj != NULL);
I_Assert(mobj->player != NULL);
I_Assert(!P_MobjWasRemoved(mobj));
if (P_MobjWasRemoved(mobj))
if (!mobj)
return;
P_MobjCheckWater(mobj);
@@ -6030,41 +6030,38 @@ static void P_KoopaThinker(mobj_t *koopa)
//
void P_RollPitchMobj(mobj_t* mobj)
{
boolean usedist = false;
if (P_MobjWasRemoved(mobj))
return;
return;
if (cv_sloperolldist.value > 0)
usedist = true;
if (cv_sloperoll.value != 2)
{
mobj->sloperoll = FixedAngle(0);
mobj->slopepitch = FixedAngle(0);
return;
}
if (cv_spriteroll.value && cv_sloperoll.value == 2)
{
K_RollMobjBySlopes(mobj, usedist);
}
else
{
mobj->sloperoll = FixedAngle(0);
mobj->slopepitch = FixedAngle(0);
}
K_RollMobjBySlopes(mobj, cv_sloperolldist.value && !splitscreen);
}
angle_t P_MobjPitchAndRoll(mobj_t *mobj)
{
spritedef_t *sprdef;
spriteframe_t *sprframe;
angle_t ang = 0;
spritedef_t *sprdef;
spriteframe_t *sprframe;
angle_t ang = 0;
angle_t camang = 0;
angle_t return_angle = 0;
if (!cv_spriteroll.value)
if (!cv_sloperoll.value)
return 0;
if (P_MobjWasRemoved(mobj))
return 0;
if (P_MobjWasRemoved(mobj))
return 0;
size_t rot = mobj->frame & FF_FRAMEMASK;
boolean papersprite = (mobj->frame & FF_PAPERSPRITE);
// if mobj doesent have any of those, no need to do the rest
if (mobj->roll == 0 && mobj->pitch == 0 && mobj->sloperoll == 0 && mobj->slopepitch == 0)
return 0;
size_t rot = (mobj->frame & FF_FRAMEMASK);
if (mobj->skin && mobj->sprite == SPR_PLAY)
{
@@ -6081,7 +6078,7 @@ angle_t P_MobjPitchAndRoll(mobj_t *mobj)
if (rot >= sprdef->numframes)
{
sprdef = &sprites[states[S_UNKNOWN].sprite];
rot = states[S_UNKNOWN].frame&FF_FRAMEMASK;
rot = (states[S_UNKNOWN].frame & FF_FRAMEMASK);
}
sprframe = &sprdef->spriteframes[rot];
@@ -6089,20 +6086,16 @@ angle_t P_MobjPitchAndRoll(mobj_t *mobj)
// No sprite frame? I guess it is possible
if (!sprframe) return 0;
if (sprframe->rotate != SRF_SINGLE || papersprite)
if (sprframe->rotate != SRF_SINGLE || (mobj->frame & FF_PAPERSPRITE))
{
ang = R_PointToAngle(mobj->x, mobj->y) - mobj->angle;
camang = R_PointToAngle(mobj->x, mobj->y);
}
return_angle = FixedMul(FINECOSINE((ang) >> ANGLETOFINESHIFT), mobj->roll)
+ FixedMul(FINESINE((ang) >> ANGLETOFINESHIFT), mobj->pitch);
if (cv_sloperoll.value)
{
return_angle += FixedMul(FINECOSINE((camang) >> ANGLETOFINESHIFT), mobj->sloperoll)
+ FixedMul(FINESINE((camang) >> ANGLETOFINESHIFT), mobj->slopepitch);
}
return_angle = FixedMul(FINECOSINE((ang) >> ANGLETOFINESHIFT), mobj->roll)
+ FixedMul(FINESINE((ang) >> ANGLETOFINESHIFT), mobj->pitch)
+ FixedMul(FINECOSINE((camang) >> ANGLETOFINESHIFT), mobj->sloperoll)
+ FixedMul(FINESINE((camang) >> ANGLETOFINESHIFT), mobj->slopepitch);
return return_angle;
}
@@ -6189,7 +6182,7 @@ void P_MobjThinker(mobj_t *mobj)
// Special thinker for scenery objects
if (mobj->flags & MF_SCENERY)
{
if (LUAh_MobjThinker(mobj))
if (LUA_HookMobj(mobj, MOBJ_HOOK(MobjThinker)))
return;
if (P_MobjWasRemoved(mobj))
@@ -6263,7 +6256,7 @@ void P_MobjThinker(mobj_t *mobj)
P_RemoveMobj(mobj);
return;
}
if (cv_sloperoll.value == 2 && mobj->state == &states[S_SHADOW])
{
mobj->slopepitch = mobj->target->slopepitch;
@@ -6286,6 +6279,7 @@ void P_MobjThinker(mobj_t *mobj)
P_RemoveMobj(mobj);
return;
}
P_RollPitchMobj(mobj);
break;
case MT_SMOLDERING:
@@ -6886,7 +6880,7 @@ void P_MobjThinker(mobj_t *mobj)
mobj->fuse--;
if (!mobj->fuse)
{
if (!LUAh_MobjFuse(mobj))
if (!LUA_HookMobj(mobj, MOBJ_HOOK(MobjFuse)))
P_RemoveMobj(mobj);
return;
}
@@ -6901,13 +6895,13 @@ void P_MobjThinker(mobj_t *mobj)
// Check for a Lua thinker first
if (!mobj->player)
{
if (LUAh_MobjThinker(mobj) || P_MobjWasRemoved(mobj))
if (LUA_HookMobj(mobj, MOBJ_HOOK(MobjThinker)) || P_MobjWasRemoved(mobj))
return;
}
else if (!mobj->player->spectator)
{
// You cannot short-circuit the player thinker like you can other thinkers.
LUAh_MobjThinker(mobj);
LUA_HookMobj(mobj, MOBJ_HOOK(MobjThinker));
if (P_MobjWasRemoved(mobj))
return;
}
@@ -6916,7 +6910,7 @@ void P_MobjThinker(mobj_t *mobj)
// separate thinker
if (mobj->flags & MF_PUSHABLE || (mobj->info->flags & MF_PUSHABLE && mobj->fuse))
{
if (P_MobjWasRemoved(mobj))
if (!mobj)
return;
P_MobjCheckWater(mobj);
@@ -6932,7 +6926,7 @@ void P_MobjThinker(mobj_t *mobj)
}
else if (mobj->flags & MF_BOSS)
{
if (LUAh_BossThinker(mobj))
if (LUA_HookMobj(mobj, MOBJ_HOOK(BossThinker)))
{
if (P_MobjWasRemoved(mobj))
return;
@@ -8899,7 +8893,7 @@ void P_MobjThinker(mobj_t *mobj)
fixed_t x, y, z;
mobj_t *flagmo, *newmobj;
if (!LUAh_MobjFuse(mobj) && !P_MobjWasRemoved(mobj))
if (!LUA_HookMobj(mobj, MOBJ_HOOK(MobjFuse)) && !P_MobjWasRemoved(mobj))
{
switch (mobj->type)
{
@@ -9234,7 +9228,6 @@ void P_PushableThinker(mobj_t *mobj)
if (GETSECSPECIAL(sec->special, 2) == 1 && mobj->z == sec->floorheight)
P_LinedefExecute(sec->tag, mobj, sec);
// else if (GETSECSPECIAL(sec->special, 2) == 8)
{
sector_t *sec2;
@@ -9385,7 +9378,18 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
{
const mobjinfo_t *info = &mobjinfo[type];
state_t *st;
mobj_t *mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL);
mobj_t *mobj;
if (mobjcache != NULL)
{
mobj = mobjcache;
mobjcache = mobjcache->hnext;
memset(mobj, 0, sizeof(*mobj));
}
else
{
mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL);
}
// this is officially a mobj, declared as soon as possible.
mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker;
@@ -9434,11 +9438,11 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
mobj->destscale = mapobjectscale;
mobj->scalespeed = mapobjectscale/12;
}
// Sprite rendering
mobj->realxscale = mobj->realyscale = mobj->scale;
mobj->realxscale = mobj->realyscale = mobj->scale;
mobj->spritexscale = mobj->realxscale;
mobj->spriteyscale = mobj->realyscale;
mobj->spriteyscale = mobj->realyscale;
mobj->spritexoffset = mobj->spriteyoffset = 0;
// Funni slam sound when landing
@@ -9490,7 +9494,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
// DANGER! This can cause P_SpawnMobj to return NULL!
// Avoid using P_RemoveMobj on the newly created mobj in "MobjSpawn" Lua hooks!
if (LUAh_MobjSpawn(mobj))
if (LUA_HookMobj(mobj, MOBJ_HOOK(MobjSpawn)))
{
if (P_MobjWasRemoved(mobj))
return NULL;
@@ -9846,7 +9850,18 @@ mobj_t *P_SpawnShadowMobj(mobj_t * caster)
{
const mobjinfo_t *info = &mobjinfo[MT_SHADOW];
state_t *st;
mobj_t *mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL);
mobj_t *mobj;
if (mobjcache != NULL)
{
mobj = mobjcache;
mobjcache = mobjcache->hnext;
memset(mobj, 0, sizeof(*mobj));
}
else
{
mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL);
}
// this is officially a mobj, declared as soon as possible.
mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker;
@@ -9892,11 +9907,11 @@ mobj_t *P_SpawnShadowMobj(mobj_t * caster)
mobj->destscale = mapobjectscale;
mobj->scalespeed = mapobjectscale/12;
}
// Sprite rendering
mobj->spritexscale = mobj->spriteyscale = mobj->scale;
mobj->spritexscale = mobj->spriteyscale = mobj->scale;
mobj->spritexoffset = mobj->spriteyoffset = 0;
// set subsector and/or block links
P_SetThingPosition(mobj);
I_Assert(mobj->subsector != NULL);
@@ -9994,10 +10009,13 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype
if (mobj->floorz != starting_floorz)
mobj->precipflags |= PCF_FOF;
else if (GETSECSPECIAL(mobj->subsector->sector->special, 1) == 7
|| GETSECSPECIAL(mobj->subsector->sector->special, 1) == 6
|| mobj->subsector->sector->floorpic == skyflatnum)
mobj->precipflags |= PCF_PIT;
else
{
INT32 special = GETSECSPECIAL(mobj->subsector->sector->special, 1);
if (special == 7 || special == 6 || mobj->subsector->sector->floorpic == skyflatnum)
mobj->precipflags |= PCF_PIT;
}
R_ResetPrecipitationMobjInterpolationState(mobj);
@@ -10022,7 +10040,7 @@ void P_RemoveMobj(mobj_t *mobj)
return; // something already removing this mobj.
mobj->thinker.function.acp1 = (actionf_p1)P_RemoveThinkerDelayed; // shh. no recursing.
LUAh_MobjRemoved(mobj);
LUA_HookMobj(mobj, MOBJ_HOOK(MobjRemoved));
mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker; // needed for P_UnsetThingPosition, etc. to work.
// Rings only, please!
@@ -10100,7 +10118,7 @@ void P_RemoveMobj(mobj_t *mobj)
P_SetTarget(&mobj->hprev->hnext, cachenext);
P_SetTarget(&mobj->hprev, NULL);
}
// clear the reference from the mapthing
if (mobj->spawnpoint)
mobj->spawnpoint->mobj = NULL;
@@ -10117,7 +10135,9 @@ void P_RemoveMobj(mobj_t *mobj)
// Invalidate mobj_t data to cause crashes if accessed!
memset(mobj, 0xff, sizeof(mobj_t));
#endif
Z_Free(mobj); // No refrences? Can be removed immediately! :D
// no references, dump it directly in the mobj cache
mobj->hnext = mobjcache;
mobjcache = mobj;
}
else
{ // Add thinker just to delay removing it until refrences are gone.
@@ -10210,19 +10230,26 @@ void P_SpawnPrecipitation(void)
if (dedicated || !cv_drawdist_precip.value || curWeather == PRECIP_NONE) // SRB2Kart
return;
fixed_t density = (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT);
if (cv_lessprecip.value)
density *= 2; // just spawn half the precip
// Use the blockmap to narrow down our placing patterns
for (i = 0; i < bmapwidth*bmapheight; ++i)
{
basex = bmaporgx + (i % bmapwidth) * MAPBLOCKSIZE;
basey = bmaporgy + (i / bmapwidth) * MAPBLOCKSIZE;
for (j = 0; j < FRACUNIT; j += cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT)
// If mobjscale < FRACUNIT, each blockmap cell covers
// more area so spawn more precipitation in that area.
for (j = 0; j < FRACUNIT; j += density)
{
INT32 floorz;
INT32 ceilingz;
x = ((cv_lessprecip.value ? basex*1.5 : basex) + ((M_RandomKey(MAPBLOCKUNITS<<3)<<FRACBITS)>>3));
y = ((cv_lessprecip.value ? basey*1.5 : basey) + ((M_RandomKey(MAPBLOCKUNITS<<3)<<FRACBITS)>>3));
x = basex + ((M_RandomKey(MAPBLOCKUNITS << 3) << FRACBITS) >> 3);
y = basey + ((M_RandomKey(MAPBLOCKUNITS << 3) << FRACBITS) >> 3);
precipsector = R_IsPointInSubsector(x, y);
@@ -10291,7 +10318,7 @@ void P_PrecipitationEffects(void)
INT32 volume;
size_t i;
boolean sounds_rain = true;
boolean rainsfx = true;
boolean sounds_thunder = true;
boolean effects_lightning = true;
boolean lightningStrike = false;
@@ -10324,7 +10351,7 @@ void P_PrecipitationEffects(void)
effects_lightning = false;
break;
case PRECIP_STORM_NORAIN: // no rain, lightning and thunder allowed
sounds_rain = false;
rainsfx = false;
case PRECIP_STORM: // everything.
break;
default:
@@ -10332,6 +10359,8 @@ void P_PrecipitationEffects(void)
return;
}
boolean sounds_rain = ((cv_drawdist_precip.value != 0) && rainsfx && (!leveltime || leveltime % 80 == 1));
// Currently thunderstorming with lightning, and we're sounding the thunder...
// and where there's thunder, there's gotta be lightning!
if (effects_lightning && lightningStrike)
@@ -10351,38 +10380,57 @@ void P_PrecipitationEffects(void)
if (sound_disabled)
return; // Sound off? D'aw, no fun.
if (!sounds_rain && !sounds_thunder)
return; // no need to calculate volume at ALL
if (players[displayplayers[0]].mo->subsector->sector->ceilingpic == skyflatnum)
volume = 255; // Sky above? We get it full blast.
else
{
/* GCC is optimizing away y >= yl, FUCK YOU */
volatile fixed_t x, y, yl, yh, xl, xh;
INT64 x, y, yl, yh, xl, xh;
fixed_t closedist, newdist;
// Essentially check in a 1024 unit radius of the player for an outdoor area.
yl = players[displayplayers[0]].mo->y - 1024*FRACUNIT;
yh = players[displayplayers[0]].mo->y + 1024*FRACUNIT;
xl = players[displayplayers[0]].mo->x - 1024*FRACUNIT;
xh = players[displayplayers[0]].mo->x + 1024*FRACUNIT;
closedist = 2048*FRACUNIT;
#define RADIUSSTEP (64*FRACUNIT)
#define SEARCHRADIUS (16*RADIUSSTEP)
yl = yh = players[displayplayers[0]].mo->y;
yl -= SEARCHRADIUS;
while (yl < INT32_MIN)
yl += RADIUSSTEP;
yh += SEARCHRADIUS;
while (yh > INT32_MAX)
yh -= RADIUSSTEP;
for (y = yl; y >= yl && y <= yh; y += FRACUNIT*64)
for (x = xl; x >= xl && x <= xh; x += FRACUNIT*64)
xl = xh = players[displayplayers[0]].mo->x;
xl -= SEARCHRADIUS;
while (xl < INT32_MIN)
xl += RADIUSSTEP;
xh += SEARCHRADIUS;
while (xh > INT32_MAX)
xh -= RADIUSSTEP;
closedist = SEARCHRADIUS*2;
#undef SEARCHRADIUS
for (y = yl; y <= yh; y += RADIUSSTEP)
for (x = xl; x <= xh; x += RADIUSSTEP)
{
if (R_PointInSubsector(x, y)->sector->ceilingpic != skyflatnum) // Found the outdoors!
if (R_PointInSubsectorFast((fixed_t)x, (fixed_t)y)->sector->ceilingpic != skyflatnum) // Found the outdoors!
continue;
newdist = S_CalculateSoundDistance(players[displayplayers[0]].mo->x, players[displayplayers[0]].mo->y, 0, x, y, 0);
newdist = S_CalculateSoundDistance(players[displayplayers[0]].mo->x, players[displayplayers[0]].mo->y, 0, (fixed_t)x, (fixed_t)y, 0);
if (newdist < closedist)
closedist = newdist;
}
volume = 255 - (closedist>>(FRACBITS+2));
}
#undef RADIUSSTEP
volume = CLAMP(volume, 0, 255);
if (sounds_rain && (!leveltime || leveltime % 80 == 1))
if (sounds_rain)
S_StartSoundAtVolume(players[displayplayers[0]].mo, sfx_rainin, volume);
if (!sounds_thunder)
@@ -10567,7 +10615,8 @@ void P_SpawnPlayer(INT32 playernum)
}
// spawn as spectator determination
if (multiplayer && demo.playback); // Don't mess with spectator values since the demo setup handles them already.
if (multiplayer && demo.playback)
; // Don't mess with spectator values since the demo setup handles them already.
else if (!G_GametypeHasSpectators())
p->spectator = false;
else if (netgame && p->jointime <= 1 && pcount)
@@ -10634,15 +10683,8 @@ void P_SpawnPlayer(INT32 playernum)
// (usefulness: when body mobj is detached from player (who respawns),
// the dead body mobj retains the skin through the 'spritedef' override).
mobj->skin = &skins[p->skin];
if (p->localskin > 0)
{
if (p->skinlocal)
mobj->localskin = &localskins[p->localskin - 1];
else
mobj->localskin = & skins[p->localskin - 1];
}
else
mobj->localskin = 0;
mobj->localskin = ((p->localskin > 0) ? (p->skinlocal ? &localskins[p->localskin - 1] : &skins[p->localskin - 1]) : 0);
mobj->skinlocal = p->skinlocal;
mobj->health = p->health;
@@ -11250,7 +11292,8 @@ void P_SpawnMapThing(mapthing_t *mthing)
mobj = P_SpawnMobj(x, y, z, i);
if (!mobj || P_MobjWasRemoved(mobj)) {
if (!mobj || P_MobjWasRemoved(mobj))
{
CONS_Alert(CONS_ERROR, "Failed to spawn map thing #%d at %d, %d. This will crash vanilla clients!\n", mthing->type, x>>FRACBITS, y>>FRACBITS);
return;
}
@@ -11784,12 +11827,8 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing)
z = mthing->options << FRACBITS;
hoopcenter = P_SpawnMobj(x, y, z, MT_HOOPCENTER);
hoopcenter->spawnpoint = mthing;
// Screw these damn hoops, I need this thinker.
//hoopcenter->flags |= MF_NOTHINK;
z +=
sec->f_slope ? P_GetZAt(sec->f_slope, x, y) :
sec->floorheight;
@@ -11835,10 +11874,8 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing)
mobj = P_SpawnMobj(finalx, finaly, finalz, MT_HOOP);
//if (maptol & TOL_XMAS)
//P_SetMobjState(mobj, mobj->info->seestate + (i & 1));
mobj->z -= mobj->height/2;
P_SetTarget(&mobj->target, hoopcenter); // Link the sprite to the center.
mobj->fuse = 0;
@@ -11975,9 +12012,6 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing)
mobj = P_SpawnMobj(finalx, finaly, finalz, MT_HOOP);
//if (maptol & TOL_XMAS)
//P_SetMobjState(mobj, mobj->info->seestate + (i & 1));
mobj->z -= mobj->height/2;
P_SetTarget(&mobj->target, hoopcenter); // Link the sprite to the center.
mobj->fuse = 0;
@@ -12348,10 +12382,6 @@ void P_ColorTeamMissile(mobj_t *missile, player_t *source)
else if (source->ctfteam == 1)
missile->color = skincolor_redring;
}
/*
else
missile->color = player->mo->color; //copy color
*/
}
//
+4 -5
View File
@@ -261,6 +261,7 @@ typedef enum {
PCF_SPLASH = 1<<4, // Splashed on the ground, return to the ceiling after the animation's over
PCF_THUNK = 1<<5, // Ran the thinker this tic.
} precipflag_t;
// Map Object definition.
typedef struct mobj_s
{
@@ -287,8 +288,7 @@ typedef struct mobj_s
spritenum_t sprite; // used to find patch_t and flip value
UINT32 frame; // frame number, plus bits see p_pspr.h
UINT16 anim_duration; // for FF_ANIMATE states
UINT32 renderflags; // render flags
fixed_t spritexscale, spriteyscale;
fixed_t spritexoffset, spriteyoffset;
fixed_t old_spritexscale, old_spriteyscale;
@@ -440,8 +440,7 @@ typedef struct precipmobj_s
spritenum_t sprite; // used to find patch_t and flip value
UINT32 frame; // frame number, plus bits see p_pspr.h
UINT16 anim_duration; // for FF_ANIMATE states
UINT32 renderflags; // render flags
fixed_t spritexscale, spriteyscale;
fixed_t spritexoffset, spriteyoffset;
fixed_t old_spritexscale, old_spriteyscale;
@@ -450,7 +449,7 @@ typedef struct precipmobj_s
fixed_t realxscale, realyscale; // funn-E streeetch
fixed_t stretchslam; // "squish" effect when you land
//sloperollangle
angle_t sloperoll, slopepitch;
angle_t old_sloperoll, old_slopepitch;
+3
View File
@@ -153,6 +153,9 @@ FUNCINLINE static ATTRINLINE void PolyObj_AddThinker(thinker_t *th)
th->next = thinkercap.next;
th->prev = &thinkercap;
thinkercap.next = th;
th->references = 0;
th->cachable = false; // not initialising this made the mobjcache die thx!
}
static void FreeSideLists(void)
+6 -11
View File
@@ -296,7 +296,7 @@ static void P_NetArchivePlayers(savebuffer_t *save, boolean resending)
//
// P_NetUnArchivePlayers
//
static void P_NetUnArchivePlayers(savebuffer_t *save, boolean resending)
static void P_NetUnArchivePlayers(boolean reloading)
{
INT32 i, j;
UINT16 flags;
@@ -306,8 +306,8 @@ static void P_NetUnArchivePlayers(savebuffer_t *save, boolean resending)
for (i = 0; i < MAXPLAYERS; i++)
{
if (resending)
adminplayers[i] = (INT32)READSINT8(save->p);
if (reloading)
adminplayers[i] = (INT32)READSINT8(save_p);
// Do NOT memset player struct to 0
// other areas may initialize data elsewhere
@@ -317,8 +317,8 @@ static void P_NetUnArchivePlayers(savebuffer_t *save, boolean resending)
// NOTE: sending tics should (hopefully) no longer be necessary
if (resending)
READSTRINGN(save->p, player_names[i], MAXPLAYERNAME);
if (reloading)
READSTRINGN(save_p, player_names[i], MAXPLAYERNAME);
players[i].aiming = READANGLE(save->p);
players[i].awayviewaiming = READANGLE(save->p);
@@ -344,7 +344,7 @@ static void P_NetUnArchivePlayers(savebuffer_t *save, boolean resending)
players[i].flashpal = READUINT16(save->p);
players[i].flashcount = READUINT16(save->p);
if (resending)
if (reloading)
{
players[i].skincolor = READUINT8(save->p);
players[i].skin = READINT32(save->p);
@@ -2159,11 +2159,6 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker)
mobj->realyscale = FRACUNIT;
mobj->stretchslam = 0;
mobj->stretchslam = 0;
mobj->slamsoundtimer = 0;
mobj->mirrored = 0;
// Timer for slam sound effect
mobj->slamsoundtimer = 0;
+52 -51
View File
@@ -63,7 +63,7 @@
#include "md5.h" // map MD5
// for LUAh_MapLoad
// for MapLoad hook
#include "lua_script.h"
#include "lua_hook.h"
@@ -460,7 +460,11 @@ FUNCINLINE static ATTRINLINE void P_LoadRawVertexes(UINT8 *data)
* \param seg Seg to compute length for.
* \return Length in fracunits.
*/
#if defined (WALLSPLATS) || defined (FLOORSPLATS)
fixed_t P_SegLength(seg_t *seg)
#else
static inline fixed_t P_SegLength(seg_t *seg)
#endif
{
INT64 dx = (seg->v2->x - seg->v1->x)>>1;
INT64 dy = (seg->v2->y - seg->v1->y)>>1;
@@ -510,7 +514,7 @@ void P_UpdateSegLightOffset(seg_t *li)
// Loads the SEGS resource from a level.
static void P_LoadRawSegs(UINT8 *data)
{
INT32 linedef, side;
INT32 rawlinedef, rawside;
mapseg_t *ml = (mapseg_t*)data;
seg_t *li = segs;
line_t *ldef;
@@ -530,14 +534,14 @@ static void P_LoadRawSegs(UINT8 *data)
li->angle = (SHORT(ml->angle))<<FRACBITS;
li->offset = (SHORT(ml->offset))<<FRACBITS;
linedef = SHORT(ml->linedef);
ldef = &lines[linedef];
rawlinedef = SHORT(ml->linedef);
ldef = &lines[rawlinedef];
li->linedef = ldef;
li->side = side = SHORT(ml->side);
li->sidedef = &sides[ldef->sidenum[side]];
li->frontsector = sides[ldef->sidenum[side]].sector;
li->side = rawside = SHORT(ml->side);
li->sidedef = &sides[ldef->sidenum[rawside]];
li->frontsector = sides[ldef->sidenum[rawside]].sector;
if (ldef->flags & ML_TWOSIDED)
li->backsector = sides[ldef->sidenum[side^1]].sector;
li->backsector = sides[ldef->sidenum[rawside^1]].sector;
else
li->backsector = 0;
@@ -1542,16 +1546,23 @@ static void P_CreateBlockMap(void)
// First find limits of map
for (i = 0; i < numvertexes; i++)
{
if (vertexes[i].x>>FRACBITS < minx)
minx = vertexes[i].x>>FRACBITS;
else if (vertexes[i].x>>FRACBITS > maxx)
maxx = vertexes[i].x>>FRACBITS;
if (vertexes[i].y>>FRACBITS < miny)
miny = vertexes[i].y>>FRACBITS;
else if (vertexes[i].y>>FRACBITS > maxy)
maxy = vertexes[i].y>>FRACBITS;
fixed_t t;
if ((t = vertexes[i].x) < minx)
minx = t;
else if (t > maxx)
maxx = t;
if ((t = vertexes[i].y) < miny)
miny = t;
else if (t > maxy)
maxy = t;
}
minx >>= FRACBITS;
maxx >>= FRACBITS;
miny >>= FRACBITS;
maxy >>= FRACBITS;
// Save blockmap parameters
bmaporgx = minx << FRACBITS;
bmaporgy = miny << FRACBITS;
@@ -2426,7 +2437,7 @@ static void P_SetupCamera(UINT8 pnum, camera_t *cam)
cam->y = players[pnum].mo->y;
cam->z = players[pnum].mo->z;
cam->angle = players[pnum].mo->angle;
cam->subsector = R_PointInSubsector(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18)
cam->subsector = R_PointInSubsectorFast(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18)
}
else
{
@@ -2451,7 +2462,7 @@ static void P_SetupCamera(UINT8 pnum, camera_t *cam)
cam->y = thing->y;
cam->z = thing->z;
cam->angle = FixedAngle((fixed_t)thing->angle << FRACBITS);
cam->subsector = R_PointInSubsector(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18)
cam->subsector = R_PointInSubsectorFast(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18)
}
}
@@ -2466,17 +2477,11 @@ static void P_InitCamera(void)
P_SetupCamera(displayplayers[i], &camera[i]);
// Though, I don't think anyone would care about cam_rotate being reset back to the only value that makes sense :P
if (!cv_cam_rotate.changed)
CV_Set(&cv_cam_rotate, cv_cam_rotate.defaultvalue);
if (!cv_cam2_rotate.changed)
CV_Set(&cv_cam2_rotate, cv_cam2_rotate.defaultvalue);
if (!cv_cam3_rotate.changed)
CV_Set(&cv_cam3_rotate, cv_cam3_rotate.defaultvalue);
if (!cv_cam4_rotate.changed)
CV_Set(&cv_cam4_rotate, cv_cam4_rotate.defaultvalue);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
if (!cv_cam_rotate[i].changed)
CV_Set(&cv_cam_rotate[i], cv_cam_rotate[i].defaultvalue);
}
displayplayers[0] = consoleplayer; // Start with your OWN view, please!
}
@@ -2494,6 +2499,9 @@ static void P_InitMinimapInfo(void)
fixed_t a;
fixed_t b;
node_t *bsp = &nodes[numnodes-1];
minimapinfo.minimap_pic = NULL;
lumpnum = W_CheckNumForName(va("%sR", G_BuildMapName(gamemap)));
if (lumpnum != -1)
@@ -2505,6 +2513,7 @@ static void P_InitMinimapInfo(void)
minimapinfo.max_x = bsp->bbox[0][BOXRIGHT];
minimapinfo.min_y = bsp->bbox[0][BOXBOTTOM];
minimapinfo.max_y = bsp->bbox[0][BOXTOP];
if (bsp->bbox[1][BOXLEFT] < minimapinfo.min_x)
minimapinfo.min_x = bsp->bbox[1][BOXLEFT];
if (bsp->bbox[1][BOXRIGHT] > minimapinfo.max_x)
@@ -2513,15 +2522,19 @@ static void P_InitMinimapInfo(void)
minimapinfo.min_y = bsp->bbox[1][BOXBOTTOM];
if (bsp->bbox[1][BOXTOP] > minimapinfo.max_y)
minimapinfo.max_y = bsp->bbox[1][BOXTOP];
// You might be wondering why these are being bitshift here
// it's because mapwidth and height would otherwise overflow for maps larger than half the size possible...
// map boundaries and sizes will ALWAYS be whole numbers thankfully
// later calculations take into consideration that these are actually not in terms of FRACUNIT though
minimapinfo.map_w = (minimapinfo.max_x >>= FRACBITS) - (minimapinfo.min_x >>= FRACBITS);
minimapinfo.map_h = (minimapinfo.max_y >>= FRACBITS) - (minimapinfo.min_y >>= FRACBITS);
minimapinfo.minimap_w = minimapinfo.minimap_h = 100;
a = FixedDiv(minimapinfo.minimap_w<<FRACBITS, minimapinfo.map_w<<4);
b = FixedDiv(minimapinfo.minimap_h<<FRACBITS, minimapinfo.map_h<<4);
if (a < b)
{
minimapinfo.minimap_h = FixedMul(a, minimapinfo.map_h)>>(FRACBITS-4);
@@ -2535,8 +2548,10 @@ static void P_InitMinimapInfo(void)
}
minimapinfo.zoom = b;
}
minimapinfo.zoom >>= (FRACBITS-4);
minimapinfo.zoom -= (minimapinfo.zoom/20);
// These should always be small enough to be bitshift back right now
minimapinfo.offs_x = FixedMul((minimapinfo.min_x + minimapinfo.map_w/2) << FRACBITS, minimapinfo.zoom);
minimapinfo.offs_y = FixedMul((minimapinfo.min_y + minimapinfo.map_h/2) << FRACBITS, minimapinfo.zoom);
@@ -2587,9 +2602,6 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate)
P_LevelInitStuff(reloadinggamestate);
for (i = 0; i <= splitscreen; i++)
postimgtype[i] = postimg_none;
if (mapheaderinfo[gamemap-1]->forcecharacter[0] != '\0'
&& atoi(mapheaderinfo[gamemap-1]->forcecharacter) != 255)
P_ForceCharacter(mapheaderinfo[gamemap-1]->forcecharacter);
@@ -2600,18 +2612,11 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate)
if (!dedicated)
{
if (!cv_chasecam.changed)
CV_SetValue(&cv_chasecam, chase);
// same for second player
if (!cv_chasecam2.changed)
CV_SetValue(&cv_chasecam2, chase);
if (!cv_chasecam3.changed)
CV_SetValue(&cv_chasecam3, chase);
if (!cv_chasecam4.changed)
CV_SetValue(&cv_chasecam4, chase);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
if (!cv_chasecam[i].changed)
CV_SetValue(&cv_chasecam[i], chase);
}
}
// Initial height of PointOfView
@@ -2742,6 +2747,8 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate)
R_ClearLevelSplats();
#endif
mobjcache = NULL;
R_InitializeLevelInterpolators();
P_InitThinkers();
@@ -3006,12 +3013,11 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate)
}
P_PreTicker(2);
if (!reloadinggamestate)
LUAh_MapLoad();
LUA_HookInt(gamemap, HOOK(MapLoad));
}
if (rendermode != render_none && !reloadinggamestate)
{
R_ResetViewInterpolation(0);
R_ResetViewInterpolation(0);
R_UpdateMobjInterpolators();
}
@@ -3157,11 +3163,6 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local)
//
S_LoadMusicDefs(wadnum);
//
// edit music defs for stuff like musictest
//
S_LoadMTDefs(wadnum);
//
// search for maps
//
+5
View File
@@ -88,6 +88,11 @@ SINT8 P_PartialAddGetStage(void);
boolean P_RunSOC(const char *socfilename);
void P_WriteThings(lumpnum_t lump);
#if defined (WALLSPLATS) || defined (FLOORSPLATS)
fixed_t P_SegLength(seg_t *seg);
#endif
void P_UpdateSegLightOffset(seg_t *li);
size_t P_PrecacheLevelFlats(void);
void P_AllocMapHeader(INT16 i);
+40 -80
View File
@@ -38,66 +38,21 @@ static INT32 sightcounts[2];
//
// Returns side 0 (front), 1 (back), or 2 (on).
//
static INT32 P_DivlineSide(fixed_t x, fixed_t y, divline_t *node)
// killough 4/19/98: made static, cleaned up
static INT32 P_DivlineSide(fixed_t x, fixed_t y, const divline_t *node)
{
fixed_t dx, dy, left, right;
if (!node->dx)
{
if (x == node->x)
return 2;
if (x <= node->x)
return (node->dy > 0);
return (node->dy < 0);
}
if (!node->dy)
{
if (y == node->y)
return 2;
if (y <= node->y)
return (node->dx < 0);
return (node->dx > 0);
}
dx = x - node->x;
dy = y - node->y;
left = (node->dy>>FRACBITS) * (dx>>FRACBITS);
right = (dy>>FRACBITS) * (node->dx>>FRACBITS);
if (right < left)
return 0; // front side
if (left == right)
return 2;
return 1; // back side
fixed_t left, right;
return
!node->dx ? x == node->x ? 2 : x <= node->x ? node->dy > 0 : node->dy < 0 :
!node->dy ? y == node->y ? 2 : y <= node->y ? node->dx < 0 : node->dx > 0 :
(right = ((y - node->y) >> FRACBITS) * (node->dx >> FRACBITS)) <
(left = ((x - node->x) >> FRACBITS) * (node->dy >> FRACBITS)) ? 0 :
right == left ? 2 : 1;
}
//
// P_InterceptVector2
//
// Returns the fractional intercept point along the first divline.
// This is only called by the addthings and addlines traversers.
//
static fixed_t P_InterceptVector2(divline_t *v2, divline_t *v1)
static INT32 P_DivlineCrossed(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, const divline_t *node)
{
fixed_t frac, num, den;
den = FixedMul(v1->dy>>8, v2->dx) - FixedMul(v1->dx>>8, v2->dy);
if (!den)
return 0;
num = FixedMul((v1->x - v2->x)>>8, v1->dy) + FixedMul((v2->y - v1->y)>>8, v1->dx);
frac = FixedDiv(num, den);
return frac;
return (P_DivlineSide(x1, y1, node) == P_DivlineSide(x2, y2, node));
}
static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los)
@@ -135,23 +90,21 @@ static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los)
v2 = line->v2;
// line isn't crossed?
if (P_DivlineSide(v1->x, v1->y, &los->strace) ==
P_DivlineSide(v2->x, v2->y, &los->strace))
if (P_DivlineCrossed(v1->x, v1->y, v2->x, v2->y, &los->strace))
continue;
divl.dx = v2->x - (divl.x = v1->x);
divl.dy = v2->y - (divl.y = v1->y);
// line isn't crossed?
if (P_DivlineSide(los->strace.x, los->strace.y, &divl) ==
P_DivlineSide(los->t2x, los->t2y, &divl))
if (P_DivlineCrossed(los->strace.x, los->strace.y, los->t2x, los->t2y, &divl))
continue;
// stop because it is not two sided
//if (!(po->flags & POF_TESTHEIGHT))
//return false;
frac = P_InterceptVector2(&los->strace, &divl);
frac = P_InterceptVector(&los->strace, &divl);
// get slopes of top and bottom of this polyobject line
topslope = FixedDiv(polysec->ceilingheight - los->sightzstart , frac);
@@ -232,16 +185,14 @@ static boolean P_CrossSubsector(size_t num, register los_t *los)
v2 = line->v2;
// line isn't crossed?
if (P_DivlineSide(v1->x, v1->y, &los->strace) ==
P_DivlineSide(v2->x, v2->y, &los->strace))
if (P_DivlineCrossed(v1->x, v1->y, v2->x, v2->y, &los->strace))
continue;
divl.dx = v2->x - (divl.x = v1->x);
divl.dy = v2->y - (divl.y = v1->y);
// line isn't crossed?
if (P_DivlineSide(los->strace.x, los->strace.y, &divl) ==
P_DivlineSide(los->t2x, los->t2y, &divl))
if (P_DivlineCrossed(los->strace.x, los->strace.y, los->t2x, los->t2y, &divl))
continue;
// stop because it is not two sided anyway
@@ -249,7 +200,7 @@ static boolean P_CrossSubsector(size_t num, register los_t *los)
return false;
// calculate fractional intercept (how far along we are divided by how far we are from t2)
frac = P_InterceptVector2(&los->strace, &divl);
frac = P_InterceptVector(&los->strace, &divl);
front = seg->frontsector;
back = seg->backsector;
@@ -348,25 +299,34 @@ static boolean P_CrossSubsector(size_t num, register los_t *los)
// if strace crosses the given node successfully.
//
// killough 4/20/98: rewritten to remove tail recursion, clean up, and optimize
static boolean P_CrossBSPNode(INT32 bspnum, register los_t *los)
static boolean P_CrossBSPNode(INT32 bspnum, register los_t *los, boolean fast)
{
while (!(bspnum & NF_SUBSECTOR))
{
register node_t *bsp = nodes + bspnum;
INT32 side = P_DivlineSide(los->strace.x,los->strace.y,(divline_t *)bsp)&1;
if (side == P_DivlineSide(los->t2x, los->t2y, (divline_t *) bsp))
bspnum = bsp->children[side]; // doesn't touch the other side
else // the partition plane is crossed here
INT32 side = (fast ? R_PointOnSideFast(los->strace.x, los->strace.y, bsp) : (P_DivlineSide(los->strace.x,los->strace.y, (divline_t *)bsp) & 1));
INT32 side2 = (fast ? R_PointOnSideFast(los->t2x, los->t2y, bsp) : P_DivlineSide(los->t2x, los->t2y, (divline_t *) bsp));
if (side == side2)
{
if (!P_CrossBSPNode(bsp->children[side], los))
return 0; // cross the starting side
bspnum = bsp->children[side]; // doesn't touch the other side
}
else
{
// the partition plane is crossed here
if (!P_CrossBSPNode(bsp->children[side], los, fast))
{
return false; // cross the starting side
}
else
bspnum = bsp->children[side^1]; // cross the ending side
{
bspnum = bsp->children[side^1]; // cross the ending side
}
}
}
return
P_CrossSubsector((bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR), los);
return P_CrossSubsector((bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR), los);
}
//
@@ -375,7 +335,7 @@ static boolean P_CrossBSPNode(INT32 bspnum, register los_t *los)
// Returns true if a straight line between t1 and t2 is unobstructed.
// Uses REJECT.
//
boolean P_CheckSight(mobj_t *t1, mobj_t *t2)
boolean P_CheckSight2(mobj_t *t1, mobj_t *t2, boolean fast)
{
const sector_t *s1, *s2;
size_t pnum;
@@ -492,5 +452,5 @@ boolean P_CheckSight(mobj_t *t1, mobj_t *t2)
}
// the head node is the last node output
return P_CrossBSPNode((INT32)numnodes - 1, &los);
}
return (P_CrossBSPNode((INT32)numnodes - 1, &los, fast));
}
+34 -74
View File
@@ -364,11 +364,11 @@ void P_SpawnSlope_Line(int linenum)
// In P_SpawnSlopeLine the origin is the centerpoint of the sourcelinedef
fslope = line->frontsector->f_slope =
P_MakeSlope(&point, &direction, dz, flags);
P_MakeSlope(&point, &direction, dz, flags);
// Set up some shit
fslope->extent = extent;
fslope->refpos = 1;
// Set up some shit
fslope->extent = extent;
fslope->refpos = 1;
// Now remember that f_slope IS a vector
// fslope->o = origin 3D point 1 of the vector
@@ -425,11 +425,11 @@ void P_SpawnSlope_Line(int linenum)
dz = FixedDiv(origin.z - point.z, extent);
cslope = line->frontsector->c_slope =
P_MakeSlope(&point, &direction, dz, flags);
P_MakeSlope(&point, &direction, dz, flags);
// Set up some shit
cslope->extent = extent;
cslope->refpos = 2;
// Set up some shit
cslope->extent = extent;
cslope->refpos = 2;
// Sync the linedata of the line that started this slope
// TODO: Anything special for control sector based slopes later?
@@ -494,11 +494,11 @@ void P_SpawnSlope_Line(int linenum)
dz = FixedDiv(origin.z - point.z, extent);
fslope = line->backsector->f_slope =
P_MakeSlope(&point, &direction, dz, flags);
P_MakeSlope(&point, &direction, dz, flags);
// Set up some shit
fslope->extent = extent;
fslope->refpos = 3;
// Set up some shit
fslope->extent = extent;
fslope->refpos = 3;
// Sync the linedata of the line that started this slope
// TODO: Anything special for control sector based slopes later?
@@ -531,6 +531,7 @@ void P_SpawnSlope_Line(int linenum)
P_CalculateSlopeNormal(fslope);
}
if (backceil)
{
fixed_t highest, lowest;
@@ -540,11 +541,11 @@ void P_SpawnSlope_Line(int linenum)
dz = FixedDiv(origin.z - point.z, extent);
cslope = line->backsector->c_slope =
P_MakeSlope(&point, &direction, dz, flags);
P_MakeSlope(&point, &direction, dz, flags);
// Set up some shit
cslope->extent = extent;
cslope->refpos = 4;
// Set up some shit
cslope->extent = extent;
cslope->refpos = 4;
// Sync the linedata of the line that started this slope
// TODO: Anything special for control sector based slopes later?
@@ -604,7 +605,8 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag
memset(ret->vertices, 0, 3*sizeof(mapthing_t));
// And... look for the vertices in question.
for (i = 0; i < nummapthings; i++, mt++) {
for (i = 0; i < nummapthings; i++, mt++)
{
if (mt->type != 750) // Haha, I'm hijacking the old Chaos Spawn thingtype for something!
continue;
@@ -617,7 +619,8 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag
}
// Now set heights for each vertex, because they haven't been set yet
for (i = 0; i < 3; i++) {
for (i = 0; i < 3; i++)
{
mt = ret->vertices[i];
if (!mt) // If a vertex wasn't found, it's game over. There's nothing you can do to recover (except maybe try and kill the slope instead - TODO?)
I_Error("P_NewVertexSlope: Slope vertex %s (for linedef tag %d) not found!", sizeu1(i), tag1);
@@ -649,23 +652,23 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag
//
void P_CopySectorSlope(line_t *line)
{
sector_t *fsec = line->frontsector;
int i, special = line->special;
sector_t *fsec = line->frontsector;
int i, special = line->special;
// Check for copy linedefs
for(i = -1; (i = P_FindSectorFromLineTag(line, i)) >= 0;)
{
sector_t *srcsec = sectors + i;
// Check for copy linedefs
for(i = -1; (i = P_FindSectorFromLineTag(line, i)) >= 0;)
{
sector_t *srcsec = sectors + i;
if((special - 719) & 1 && !fsec->f_slope && srcsec->f_slope)
fsec->f_slope = srcsec->f_slope; //P_CopySlope(srcsec->f_slope);
if((special - 719) & 2 && !fsec->c_slope && srcsec->c_slope)
fsec->c_slope = srcsec->c_slope; //P_CopySlope(srcsec->c_slope);
}
if((special - 719) & 1 && !fsec->f_slope && srcsec->f_slope)
fsec->f_slope = srcsec->f_slope; //P_CopySlope(srcsec->f_slope);
if((special - 719) & 2 && !fsec->c_slope && srcsec->c_slope)
fsec->c_slope = srcsec->c_slope; //P_CopySlope(srcsec->c_slope);
}
fsec->hasslope = true;
fsec->hasslope = true;
line->special = 0; // Linedef was use to set slopes, it finished its job, so now make it a normal linedef
line->special = 0; // Linedef was use to set slopes, it finished its job, so now make it a normal linedef
}
//
@@ -790,49 +793,6 @@ void P_ResetDynamicSlopes(void)
// Various utilities related to slopes
//
//
// P_GetZAt
//
// 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)
{
fixed_t dist = FixedMul(x - slope->o.x, slope->d.x) +
FixedMul(y - slope->o.y, slope->d.y);
return slope->o.z + FixedMul(dist, slope->zdelta);
}
// Returns the height of the sector floor at (x, y)
fixed_t P_GetSectorFloorZAt(const sector_t *sector, fixed_t x, fixed_t y)
{
return sector->f_slope ? P_GetZAt(sector->f_slope, x, y) : sector->floorheight;
}
// Returns the height of the sector ceiling at (x, y)
fixed_t P_GetSectorCeilingZAt(const sector_t *sector, fixed_t x, fixed_t y)
{
return sector->c_slope ? P_GetZAt(sector->c_slope, x, y) : sector->ceilingheight;
}
// Returns the height of the FOF top at (x, y)
fixed_t P_GetFFloorTopZAt(const ffloor_t *ffloor, fixed_t x, fixed_t y)
{
return *ffloor->t_slope ? P_GetZAt(*ffloor->t_slope, x, y) : *ffloor->topheight;
}
// Returns the height of the FOF bottom at (x, y)
fixed_t P_GetFFloorBottomZAt(const ffloor_t *ffloor, fixed_t x, fixed_t y)
{
return *ffloor->b_slope ? P_GetZAt(*ffloor->b_slope, x, y) : *ffloor->bottomheight;
}
// Returns the height of the light list at (x, y)
fixed_t P_GetLightZAt(const lightlist_t *light, fixed_t x, fixed_t y)
{
return light->slope ? P_GetZAt(light->slope, x, y) : light->height;
}
//
// P_QuantizeMomentumToSlope
//
+37 -8
View File
@@ -13,9 +13,12 @@
#ifndef P_SLOPES_H__
#define P_SLOPES_H__
#include "doomtype.h"
void P_CalculateSlopeNormal(pslope_t *slope);
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.
@@ -30,19 +33,45 @@ void P_CopySectorSlope(line_t *line);
pslope_t *P_SlopeById(UINT16 id);
//
// P_GetZAt
//
// 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);
FUNCINLINE static ATTRINLINE fixed_t P_GetZAt(pslope_t *z_slope, fixed_t x, fixed_t y)
{
return z_slope->o.z + FixedMul((FixedMul(x - z_slope->o.x, z_slope->d.x) + FixedMul(y - z_slope->o.y, z_slope->d.y)), z_slope->zdelta);
}
// Returns the height of the sector at (x, y)
fixed_t P_GetSectorFloorZAt (const sector_t *sector, fixed_t x, fixed_t y);
fixed_t P_GetSectorCeilingZAt(const sector_t *sector, fixed_t x, fixed_t y);
// Returns the height of the sector floor at (x, y)
FUNCINLINE static ATTRINLINE fixed_t P_GetSectorFloorZAt(const sector_t *z_sector, fixed_t x, fixed_t y)
{
return z_sector->f_slope ? P_GetZAt(z_sector->f_slope, x, y) : z_sector->floorheight;
}
// Returns the height of the FOF at (x, y)
fixed_t P_GetFFloorTopZAt (const ffloor_t *ffloor, fixed_t x, fixed_t y);
fixed_t P_GetFFloorBottomZAt(const ffloor_t *ffloor, fixed_t x, fixed_t y);
// Returns the height of the sector ceiling at (x, y)
FUNCINLINE static ATTRINLINE fixed_t P_GetSectorCeilingZAt(const sector_t *z_sector, fixed_t x, fixed_t y)
{
return z_sector->c_slope ? P_GetZAt(z_sector->c_slope, x, y) : z_sector->ceilingheight;
}
// Returns the height of the FOF top at (x, y)
FUNCINLINE static ATTRINLINE fixed_t P_GetFFloorTopZAt(const ffloor_t *z_ffloor, fixed_t x, fixed_t y)
{
return *z_ffloor->t_slope ? P_GetZAt(*z_ffloor->t_slope, x, y) : *z_ffloor->topheight;
}
// Returns the height of the FOF bottom at (x, y)
FUNCINLINE static ATTRINLINE fixed_t P_GetFFloorBottomZAt(const ffloor_t *z_ffloor, fixed_t x, fixed_t y)
{
return *z_ffloor->b_slope ? P_GetZAt(*z_ffloor->b_slope, x, y) : *z_ffloor->bottomheight;
}
// Returns the height of the light list at (x, y)
fixed_t P_GetLightZAt(const lightlist_t *light, fixed_t x, fixed_t y);
FUNCINLINE static ATTRINLINE fixed_t P_GetLightZAt(const lightlist_t *z_light, fixed_t x, fixed_t y)
{
return z_light->slope ? P_GetZAt(z_light->slope, x, y) : z_light->height;
}
// Lots of physics-based bullshit
void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope);
+41 -65
View File
@@ -35,7 +35,7 @@
#include "hu_stuff.h"
#include "m_misc.h"
#include "m_cond.h" //unlock triggers
#include "lua_hook.h" // LUAh_LinedefExecute
#include "lua_hook.h" // LUA_HookLinedefExecute
#include "k_kart.h" // SRB2kart
#include "console.h" // CON_LogMessage
@@ -1431,12 +1431,14 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller
}
else if (caller)
{
if (GETSECSPECIAL(caller->special, 2) == 6)
INT32 special = GETSECSPECIAL(caller->special, 2);
if (special == 6)
{
if (!(ALL7EMERALDS(emeralds)))
return false;
}
else if (GETSECSPECIAL(caller->special, 2) == 7) // SRB2Kart: reusing for Race Lap executor
else if (special == 7) // SRB2Kart: reusing for Race Lap executor
{
UINT8 lap;
@@ -1470,7 +1472,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller
// If we were not triggered by a sector type especially for the purpose,
// a Linedef Executor linedef trigger is not handling sector triggers properly, return.
else if ((!GETSECSPECIAL(caller->special, 2) || GETSECSPECIAL(caller->special, 2) > 7) && (specialtype > 322))
else if ((!special || special > 7) && (specialtype > 322))
{
CONS_Alert(CONS_WARNING,
M_GetText("Linedef executor trigger isn't handling sector triggers properly!\nspecialtype = %d, if you are not a dev, report this warning instance\nalong with the wad that caused it!\n"),
@@ -1805,27 +1807,23 @@ void P_SwitchWeather(INT32 weathernum)
precipmobj = (precipmobj_t *)think;
mobjtype_t type = 0;
INT32 z = 0;
if (swap == PRECIP_BLANK || swap == PRECIP_STORM_NORAIN) // Remove precip, but keep it around for reuse.
{
precipmobj->precipflags |= PCF_INVISIBLE;
continue;
}
if (swap == PRECIP_RAIN) // Snow To Rain
{
precipmobj->type = MT_RAIN; // proper set the type
precipmobj->info = &mobjinfo[MT_RAIN];
precipmobj->flags = mobjinfo[MT_RAIN].flags;
st = &states[mobjinfo[MT_RAIN].spawnstate];
precipmobj->state = st;
precipmobj->tics = st->tics;
precipmobj->sprite = st->sprite;
precipmobj->frame = st->frame;
precipmobj->momz = cv_mobjscaleprecip.value ? FixedMul(mobjinfo[MT_RAIN].speed, mapobjectscale) : mobjinfo[MT_RAIN].speed;
precipmobj->precipflags &= ~(PCF_INVISIBLE|PCF_SPLASH); // P_PrecipThinker will add this again if it needs to
type = MT_RAIN;
}
else if (swap == PRECIP_SNOW) // Rain To Snow
{
INT32 z;
type = MT_SNOWFLAKE;
precipmobj->type = MT_SNOWFLAKE; // proper set the type
precipmobj->info = &mobjinfo[MT_SNOWFLAKE];
precipmobj->flags = mobjinfo[MT_SNOWFLAKE].flags;
z = M_RandomByte();
if (z < 64)
@@ -1834,92 +1832,69 @@ void P_SwitchWeather(INT32 weathernum)
z = 1;
else
z = 0;
st = &states[mobjinfo[MT_SNOWFLAKE].spawnstate+z];
precipmobj->state = st;
precipmobj->tics = st->tics;
precipmobj->sprite = st->sprite;
precipmobj->frame = st->frame;
precipmobj->momz = cv_mobjscaleprecip.value ? FixedMul(mobjinfo[MT_SNOWFLAKE].speed, mapobjectscale) : mobjinfo[MT_SNOWFLAKE].speed;
precipmobj->precipflags &= ~(PCF_INVISIBLE|PCF_SPLASH); // P_PrecipThinker will add this again if it needs to
}
else if (swap == PRECIP_BLANK || swap == PRECIP_STORM_NORAIN) // Remove precip, but keep it around for reuse.
{
precipmobj->precipflags |= PCF_INVISIBLE;
}
precipmobj->type = type; // proper set the type
precipmobj->info = &mobjinfo[type];
precipmobj->flags = mobjinfo[type].flags;
st = &states[mobjinfo[type].spawnstate+z];
precipmobj->state = st;
precipmobj->tics = st->tics;
precipmobj->sprite = st->sprite;
precipmobj->frame = st->frame;
precipmobj->momz = (cv_mobjscaleprecip.value ? FixedMul(mobjinfo[type].speed, mapobjectscale) : mobjinfo[type].speed);
precipmobj->precipflags &= ~(PCF_INVISIBLE|PCF_SPLASH); // P_PrecipThinker will add this again if it needs to
}
}
boolean dontspawn = false;
switch (weathernum)
{
case PRECIP_SNOW: // snow
curWeather = PRECIP_SNOW;
if (!swap)
P_SpawnPrecipitation();
break;
case PRECIP_RAIN: // rain
{
boolean dontspawn = false;
if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES)
dontspawn = true;
curWeather = PRECIP_RAIN;
if (!dontspawn && !swap)
P_SpawnPrecipitation();
break;
}
case PRECIP_STORM: // storm
{
boolean dontspawn = false;
if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES)
dontspawn = true;
curWeather = PRECIP_STORM;
if (!dontspawn && !swap)
P_SpawnPrecipitation();
break;
}
case PRECIP_STORM_NOSTRIKES: // storm w/o lightning
{
boolean dontspawn = false;
if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES)
dontspawn = true;
curWeather = PRECIP_STORM_NOSTRIKES;
if (!dontspawn && !swap)
P_SpawnPrecipitation();
break;
}
case PRECIP_STORM_NORAIN: // storm w/o rain
curWeather = PRECIP_STORM_NORAIN;
if (!swap)
P_SpawnPrecipitation();
break;
case PRECIP_BLANK:
curWeather = PRECIP_BLANK;
if (!swap)
P_SpawnPrecipitation();
break;
default:
dontspawn = true;
curWeather = PRECIP_NONE;
break;
}
if (!dontspawn && !swap)
P_SpawnPrecipitation();
}
/** Gets an object.
@@ -2084,6 +2059,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
mo->y += y;
mo->z += z;
P_SetThingPosition(mo);
mo->old_x = mo->x;
mo->old_y = mo->y;
mo->old_z = mo->z;
if (mo->player)
{
@@ -2102,7 +2080,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
camera[i].reset = true;
camera[i].subsector = R_PointInSubsector(camera[i].x, camera[i].y);
R_RelativeTeleportViewInterpolation(i, x, y, z, 0);
R_ResetViewInterpolation(i + 1); // reset view interp as well
break;
}
}
@@ -2520,7 +2497,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
if (displayplayers[i] == (mo->player - players))
{
R_ResetViewInterpolation(i + 1);
R_ResetViewInterpolation(i + 1);
}
}
}
@@ -2855,7 +2831,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
case 443: // Calls a named Lua function
if (line->text)
LUAh_LinedefExecute(line, mo, callsec);
LUA_HookLinedefExecute(line, mo, callsec);
else
CONS_Alert(CONS_WARNING, "Linedef %s is missing the hook name of the Lua function to call! (This should be given in the front texture fields)\n", sizeu1(line-lines));
break;
+63 -31
View File
@@ -196,6 +196,8 @@ void P_AddThinker(thinker_t *thinker)
thinkercap.prev = thinker;
thinker->references = 0; // killough 11/98: init reference counter to 0
thinker->cachable = (thinker->function.acp1 == (actionf_p1)P_MobjThinker);
}
//
@@ -235,7 +237,17 @@ void P_RemoveThinkerDelayed(thinker_t *thinker)
* thinker->prev->next = thinker->next */
(next->prev = currentthinker = thinker->prev)->next = next;
R_DestroyLevelInterpolators(thinker);
Z_Free(thinker);
if (thinker->cachable == true)
{
// put cachable thinkers in the mobj cache, so we can avoid allocations
((mobj_t *)thinker)->hnext = mobjcache;
mobjcache = (mobj_t *)thinker;
}
else
{
Z_Free(thinker);
}
}
//
@@ -250,9 +262,20 @@ void P_UnlinkThinker(thinker_t *thinker)
I_Assert(thinker->references == 0);
(next->prev = thinker->prev)->next = next;
Z_Free(thinker);
if (thinker->cachable == true)
{
// put cachable thinkers in the mobj cache, so we can avoid allocations
((mobj_t *)thinker)->hnext = mobjcache;
mobjcache = (mobj_t *)thinker;
}
else
{
Z_Free(thinker);
}
}
//
// P_RemoveThinker
//
@@ -327,7 +350,7 @@ static inline void P_RunThinkers(void)
}
}
static inline void P_DeviceRumbleTick(void)
static void P_DeviceRumbleTick(void)
{
UINT8 i;
@@ -345,7 +368,7 @@ static inline void P_DeviceRumbleTick(void)
if (!P_IsLocalPlayer(player))
continue;
if (G_GetDeviceForPlayer(i) == 0)
if (cv_usejoystick[i].value == 0)
continue;
if (!playeringame[displayplayers[i]] || player->spectator)
@@ -397,7 +420,7 @@ void P_RunChaseCameras(void)
}
}
static inline void P_RunQuakes(void)
static void P_RunQuakes(void)
{
fixed_t ir;
@@ -434,10 +457,21 @@ void P_Ticker(boolean run)
{
INT32 i;
//Increment jointime even if paused.
// Increment jointime even if paused
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i])
++players[i].jointime;
{
players[i].jointime++;
}
}
if (run)
{
// Update old view state BEFORE ticking so resetting
// the old interpolation state from game logic works.
R_UpdateViewInterpolation();
}
if (objectplacing)
{
@@ -469,9 +503,6 @@ void P_Ticker(boolean run)
return;
}
for (i = 0; i <= splitscreen; i++)
postimgtype[i] = postimg_none;
P_MapStart();
if (run)
@@ -520,7 +551,7 @@ void P_Ticker(boolean run)
ps_checkposition_calls.value.i = 0;
PS_START_TIMING(ps_lua_prethinkframe_time);
LUAh_PreThinkFrame();
LUA_HookPreThinkFrame();
PS_STOP_TIMING(ps_lua_prethinkframe_time);
PS_START_TIMING(ps_playerthink_time);
@@ -556,7 +587,7 @@ void P_Ticker(boolean run)
}
PS_START_TIMING(ps_lua_thinkframe_time);
LUAh_ThinkFrame();
LUA_HookThinkFrame();
PS_STOP_TIMING(ps_lua_thinkframe_time);
}
@@ -632,14 +663,17 @@ void P_Ticker(boolean run)
G_WriteAllGhostTics();
if (cv_recordmultiplayerdemos.value && (demo.savemode == DSM_NOTSAVING || demo.savemode == DSM_WILLAUTOSAVE))
if (demo.savebutton && demo.savebutton + 3*TICRATE < leveltime && (InputDown(gc_lookback, 1) || (cv_usejoystick.value && axis > 0)))
demo.savemode = DSM_TITLEENTRY;
if (cv_recordmultiplayerdemos.value)
{
if (demo.savemode == DSM_NOTSAVING || demo.savemode == DSM_WILLAUTOSAVE)
if (demo.savebutton && demo.savebutton + 3*TICRATE < leveltime && (InputDown(gc_lookback, 1) || (cv_usejoystick[0].value && axis > 0)))
demo.savemode = DSM_TITLEENTRY;
//if there are no players left at all, stop demo recording
//Demos that that dont have any players crash during playback, which can happen with dedicated servers
if (cv_recordmultiplayerdemos.value && demo.savemode == DSM_WILLAUTOSAVE && !D_NumPlayers())
G_SaveDemo();
// if there are no players left at all, stop demo recording
// Demos that that dont have any players crash during playback, which can happen with dedicated servers
if (demo.savemode == DSM_WILLAUTOSAVE && !D_NumPlayers())
G_ResetDemoRecording();
}
}
else if (demo.playback) // Use Ghost data for consistency checks.
{
@@ -660,7 +694,7 @@ void P_Ticker(boolean run)
D_MapChange(gamemap, gametype, encoremode, true, 0, false, false);
PS_START_TIMING(ps_lua_postthinkframe_time);
LUAh_PostThinkFrame();
LUA_HookPostThinkFrame();
PS_STOP_TIMING(ps_lua_postthinkframe_time);
}
@@ -672,7 +706,6 @@ void P_Ticker(boolean run)
if (run)
{
R_UpdateLevelInterpolators();
R_UpdateViewInterpolation();
// Hack: ensure newview is assigned every tic.
// Ensures view interpolation is T-1 to T in poor network conditions
@@ -682,16 +715,18 @@ void P_Ticker(boolean run)
for (i = 0; i <= splitscreen; i++)
{
player_t *player = &players[displayplayers[i]];
boolean isSkyVisibleForPlayer = skyVisiblePerPlayer[i];
if (!player->mo)
continue;
if (isSkyVisibleForPlayer && skyboxmo[0] && cv_skybox.value)
const boolean skybox = (skyboxmo[0] && cv_skybox.value);
if (skyVisiblePerPlayer[i] && skybox)
{
R_SkyboxFrame(player);
R_SkyboxFrame(i);
}
R_SetupFrame(player, (skyboxmo[0] && cv_skybox.value));
R_SetupFrame(i, skybox);
}
}
}
@@ -708,9 +743,6 @@ void P_PreTicker(INT32 frames)
INT32 i;
ticcmd_t temptic;
for (i = 0; i <= splitscreen; i++)
postimgtype[i] = postimg_none;
hook_defrosting = frames;
while (hook_defrosting)
@@ -719,7 +751,7 @@ void P_PreTicker(INT32 frames)
R_UpdateMobjInterpolators();
LUAh_PreThinkFrame();
LUA_HOOK(PreThinkFrame);
for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
@@ -748,7 +780,7 @@ void P_PreTicker(INT32 frames)
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
P_PlayerAfterThink(&players[i]);
LUAh_ThinkFrame();
LUA_HookThinkFrame();
P_RunOverlays();
P_RunShadows();
@@ -756,7 +788,7 @@ void P_PreTicker(INT32 frames)
P_UpdateSpecials();
P_RespawnSpecials();
LUAh_PostThinkFrame();
LUA_HOOK(PostThinkFrame);
R_UpdateLevelInterpolators();
R_UpdateViewInterpolation();
+155 -200
View File
@@ -427,8 +427,6 @@ void P_ResetPlayer(player_t *player)
player->powers[pw_tailsfly] = 0;
player->onconveyor = 0;
player->skidtime = 0;
/*if (player-players == consoleplayer && botingame)
CV_SetValue(&cv_analog2, true);*/
}
//
@@ -508,8 +506,6 @@ void P_DoSuperTransformation(player_t *player, boolean giverings)
// Adds to the player's score
void P_AddPlayerScore(player_t *player, UINT32 amount)
{
//UINT32 oldscore;
if (!(G_BattleGametype()))
return;
@@ -519,8 +515,6 @@ void P_AddPlayerScore(player_t *player, UINT32 amount)
if (player->exiting) // srb2kart
return;
//oldscore = player->score;
// Don't go above MAXSCORE.
if (player->marescore + amount < MAXSCORE)
player->marescore += amount;
@@ -743,7 +737,7 @@ void P_RestoreMusic(player_t *player)
return;
if (leveltime < MUSICSTARTTIME)
S_StartMapMusic(true);
S_StartMapMusic();
else // see also where time overs are handled - search for "lives = 2" in this file
{
INT32 wantedmus = 0; // 0 is level music, 1 is invincibility, 2 is grow
@@ -2341,8 +2335,6 @@ static void P_MovePlayer(player_t *player)
if (maptol & TOL_2D)
runspd = FixedMul(runspd, 2*FRACUNIT/3);
//P_SkidStuff(player);
/////////////////////////
// MOVEMENT ANIMATIONS //
/////////////////////////
@@ -2498,7 +2490,7 @@ static void P_MovePlayer(player_t *player)
}
#ifdef HWRENDER
if (rendermode != render_soft && rendermode != render_none && cv_grfovchange.value)
if (rendermode == render_opengl && cv_glfovchange.value)
{
fixed_t speed;
const fixed_t runnyspeed = 20*FRACUNIT;
@@ -2976,34 +2968,34 @@ camera_t camera[MAXSPLITSCREENPLAYERS]; // Four cameras, three for splitscreen
static void CV_CamRotate_OnChange(void)
{
if (cv_cam_rotate.value < 0)
CV_SetValue(&cv_cam_rotate, cv_cam_rotate.value + 360);
else if (cv_cam_rotate.value > 359)
CV_SetValue(&cv_cam_rotate, cv_cam_rotate.value % 360);
if (cv_cam_rotate[0].value < 0)
CV_SetValue(&cv_cam_rotate[0], cv_cam_rotate[0].value + 360);
else if (cv_cam_rotate[0].value > 359)
CV_SetValue(&cv_cam_rotate[0], cv_cam_rotate[0].value % 360);
}
static void CV_CamRotate2_OnChange(void)
{
if (cv_cam2_rotate.value < 0)
CV_SetValue(&cv_cam2_rotate, cv_cam2_rotate.value + 360);
else if (cv_cam2_rotate.value > 359)
CV_SetValue(&cv_cam2_rotate, cv_cam2_rotate.value % 360);
if (cv_cam_rotate[1].value < 0)
CV_SetValue(&cv_cam_rotate[1], cv_cam_rotate[1].value + 360);
else if (cv_cam_rotate[1].value > 359)
CV_SetValue(&cv_cam_rotate[1], cv_cam_rotate[1].value % 360);
}
static void CV_CamRotate3_OnChange(void)
{
if (cv_cam3_rotate.value < 0)
CV_SetValue(&cv_cam3_rotate, cv_cam3_rotate.value + 360);
else if (cv_cam3_rotate.value > 359)
CV_SetValue(&cv_cam3_rotate, cv_cam3_rotate.value % 360);
if (cv_cam_rotate[2].value < 0)
CV_SetValue(&cv_cam_rotate[2], cv_cam_rotate[2].value + 360);
else if (cv_cam_rotate[2].value > 359)
CV_SetValue(&cv_cam_rotate[2], cv_cam_rotate[2].value % 360);
}
static void CV_CamRotate4_OnChange(void)
{
if (cv_cam4_rotate.value < 0)
CV_SetValue(&cv_cam4_rotate, cv_cam4_rotate.value + 360);
else if (cv_cam4_rotate.value > 359)
CV_SetValue(&cv_cam4_rotate, cv_cam4_rotate.value % 360);
if (cv_cam_rotate[3].value < 0)
CV_SetValue(&cv_cam_rotate[3], cv_cam_rotate[3].value + 360);
else if (cv_cam_rotate[3].value > 359)
CV_SetValue(&cv_cam_rotate[3], cv_cam_rotate[3].value % 360);
}
static CV_PossibleValue_t CV_CamSpeed[] = {{0, "MIN"}, {1*FRACUNIT, "MAX"}, {0, NULL}};
@@ -3074,33 +3066,47 @@ static void CV_PlayerCam4_OnChange(void)
P_ResetCamera(&players[displayplayers[3]], &camera[3]);
}
consvar_t cv_cam_dist = {"cam_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam1_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam_height = {"cam_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam1_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam_still = {"cam_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam_speed = {"cam_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam_rotate = {"cam_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam_rotspeed = {"cam_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam_dist[MAXSPLITSCREENPLAYERS] = {
{"cam_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam1_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"cam2_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam2_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"cam3_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam3_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"cam4_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam4_OnChange, 0, NULL, NULL, 0, 0, NULL}
};
consvar_t cv_cam2_dist = {"cam2_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam2_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam2_height = {"cam2_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam2_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam2_still = {"cam2_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam2_speed = {"cam2_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam2_rotate = {"cam2_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate2_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam2_rotspeed = {"cam2_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam_height[MAXSPLITSCREENPLAYERS] = {
{"cam_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam1_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"cam2_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam2_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"cam3_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam3_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"cam4_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam4_OnChange, 0, NULL, NULL, 0, 0, NULL},
};
consvar_t cv_cam3_dist = {"cam3_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam3_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam3_height = {"cam3_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam3_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam3_still = {"cam3_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam3_speed = {"cam3_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam3_rotate = {"cam3_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate3_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam3_rotspeed = {"cam3_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam_still[MAXSPLITSCREENPLAYERS] = {
{"cam_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam2_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam3_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam4_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}
};
consvar_t cv_cam4_dist = {"cam4_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam4_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam4_height = {"cam4_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam4_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam4_still = {"cam4_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam4_speed = {"cam4_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam4_rotate = {"cam4_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate4_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam4_rotspeed = {"cam4_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cam_speed[MAXSPLITSCREENPLAYERS] = {
{"cam_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam2_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam3_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam4_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}
};
consvar_t cv_cam_rotate[MAXSPLITSCREENPLAYERS] = {
{"cam_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"cam2_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate2_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"cam3_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate3_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"cam4_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate4_OnChange, 0, NULL, NULL, 0, 0, NULL}
};
consvar_t cv_cam_rotspeed[MAXSPLITSCREENPLAYERS] = {
{"cam_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam2_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam3_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"cam4_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}
};
consvar_t cv_tilting = {"tilting", "Off", CV_SAVE|CV_CALL, CV_OnOff, Bird_menu_Onchange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_quaketilt = {"quaketilt", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -3111,18 +3117,7 @@ consvar_t cv_actionmovie = {"actionmovie", "Off", CV_SAVE, CV_OnOff, NULL, 0, NU
static CV_PossibleValue_t lookbackmom_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Double"}, {0, NULL}};
consvar_t cv_lookbackmom = {"cameralookbackmom", "Off", CV_SAVE, lookbackmom_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
fixed_t t_cam_dist = -42;
fixed_t t_cam_height = -42;
fixed_t t_cam_rotate = -42;
fixed_t t_cam2_dist = -42;
fixed_t t_cam2_height = -42;
fixed_t t_cam2_rotate = -42;
fixed_t t_cam3_dist = -42;
fixed_t t_cam3_height = -42;
fixed_t t_cam3_rotate = -42;
fixed_t t_cam4_dist = -42;
fixed_t t_cam4_height = -42;
fixed_t t_cam4_rotate = -42;
fixed_t t_cam_rotate[MAXSPLITSCREENPLAYERS] = {-42, -42, -42, -42};
#define MAXCAMERADIST 140*FRACUNIT // Max distance the camera can be in front of the player (2D mode)
@@ -3174,7 +3169,7 @@ static ticcmd_t *P_CameraCmd(camera_t *cam)
mouseaiming = true;
invertmouse = cv_invertmouse.value;
lookaxis = cv_lookaxis.value;
lookaxis = cv_lookaxis[0].value;
usejoystick = true;
turnright = InputDown(gc_turnright, 1);
@@ -3357,7 +3352,7 @@ void P_DemoCameraMovement(camera_t *cam)
democam.soundmobj = awayviewmobj_hack;
// update subsector to avoid crashes;
cam->subsector = R_PointInSubsector(cam->x, cam->y);
cam->subsector = R_PointInSubsectorFast(cam->x, cam->y);
}
void P_ResetCamera(player_t *player, camera_t *thiscam)
@@ -3388,17 +3383,18 @@ void P_ResetCamera(player_t *player, camera_t *thiscam)
thiscam->z = z;
thiscam->reset = true;
if (!(thiscam == &camera[0] && (cv_cam_still.value || cv_analog.value))
&& !(thiscam == &camera[1] && (cv_cam2_still.value || cv_analog2.value))
&& !(thiscam == &camera[2] && (cv_cam3_still.value || cv_analog3.value))
&& !(thiscam == &camera[3] && (cv_cam4_still.value || cv_analog4.value)))
if (!(thiscam == &camera[0] && (cv_cam_still[0].value))
&& !(thiscam == &camera[1] && (cv_cam_still[1].value))
&& !(thiscam == &camera[2] && (cv_cam_still[2].value))
&& !(thiscam == &camera[3] && (cv_cam_still[3].value)))
{
thiscam->angle = player->mo->angle;
thiscam->aiming = 0;
}
thiscam->relativex = 0;
thiscam->subsector = R_PointInSubsector(thiscam->x,thiscam->y);
thiscam->subsector = R_PointInSubsectorFast(thiscam->x,thiscam->y);
thiscam->radius = 20*FRACUNIT;
thiscam->height = 16*FRACUNIT;
@@ -3410,7 +3406,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
{
static boolean lookbackactive[MAXSPLITSCREENPLAYERS];
static UINT8 lookbackdelay[MAXSPLITSCREENPLAYERS];
UINT8 num;
UINT8 num, plyrnum;
angle_t angle = 0, focusangle = 0, focusaiming = 0;
fixed_t x, y, z, dist, viewpointx, viewpointy, camspeed, camdist, camheight, pviewheight;
fixed_t pan, xpan, ypan;
@@ -3440,6 +3436,44 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
return true;
}
if (thiscam == &camera[1]) // Camera 2
{
num = 1;
}
else if (thiscam == &camera[2]) // Camera 3
{
num = 2;
}
else if (thiscam == &camera[3]) // Camera 4
{
num = 3;
}
else // Camera 1
{
num = 0;
}
if (player == &players[consoleplayer])
{
plyrnum = 0;
}
else if (player == &players[displayplayers[1]])
{
plyrnum = 1;
}
else if (player == &players[displayplayers[2]])
{
plyrnum = 2;
}
else if (player == &players[displayplayers[3]])
{
plyrnum = 3;
}
else
{
plyrnum = 255;
}
mo = player->mo;
#ifndef NOCLIPCAM
@@ -3458,40 +3492,23 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
if (player->spectator) // force cam off for spectators
return true;
if (!cv_chasecam.value && thiscam == &camera[0])
return true;
if (!cv_chasecam2.value && thiscam == &camera[1])
return true;
if (!cv_chasecam3.value && thiscam == &camera[2])
return true;
if (!cv_chasecam4.value && thiscam == &camera[3])
if (!cv_chasecam[num].value && thiscam == &camera[num])
return true;
}
if (!thiscam->chase && !resetcalled)
{
if (player == &players[consoleplayer])
focusangle = localangle[0];
else if (player == &players[displayplayers[1]])
focusangle = localangle[1];
else if (player == &players[displayplayers[2]])
focusangle = localangle[2];
else if (player == &players[displayplayers[3]])
focusangle = localangle[3];
if (plyrnum != 255)
{
focusangle = localangle[plyrnum];
}
else
{
focusangle = mo->angle;
}
if (thiscam == &camera[0])
camrotate = cv_cam_rotate.value;
else if (thiscam == &camera[1])
camrotate = cv_cam2_rotate.value;
else if (thiscam == &camera[2])
camrotate = cv_cam3_rotate.value;
else if (thiscam == &camera[3])
camrotate = cv_cam4_rotate.value;
if (thiscam == &camera[num])
camrotate = cv_cam_rotate[num].value;
else
camrotate = 0;
@@ -3509,35 +3526,15 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
thiscam->radius = 20*mapobjectscale;
thiscam->height = 16*mapobjectscale;
// Don't run while respawning from a starpost
// Inu 4/8/13 Why not?!
// if (leveltime > 0 && timeinmap <= 0)
// return true;
if (demo.playback)
{
focusangle = mo->angle;
focusaiming = 0;
}
else if (player == &players[consoleplayer])
else if (plyrnum != 255)
{
focusangle = localangle[0];
focusaiming = localaiming[0];
}
else if (player == &players[displayplayers[1]])
{
focusangle = localangle[1];
focusaiming = localaiming[1];
}
else if (player == &players[displayplayers[2]])
{
focusangle = localangle[2];
focusaiming = localaiming[2];
}
else if (player == &players[displayplayers[3]])
{
focusangle = localangle[3];
focusaiming = localaiming[3];
focusangle = localangle[plyrnum];
focusaiming = localaiming[plyrnum];
}
else
{
@@ -3548,46 +3545,12 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
if (P_CameraThinker(player, thiscam, resetcalled))
return true;
if (thiscam == &camera[1]) // Camera 2
{
num = 1;
camspeed = cv_cam2_speed.value;
camstill = cv_cam2_still.value;
camrotate = cv_cam2_rotate.value;
camdist = FixedMul(cv_cam2_dist.value, mapobjectscale);
camheight = FixedMul(cv_cam2_height.value, mapobjectscale);
lookback = camspin[1];
}
else if (thiscam == &camera[2]) // Camera 3
{
num = 2;
camspeed = cv_cam3_speed.value;
camstill = cv_cam3_still.value;
camrotate = cv_cam3_rotate.value;
camdist = FixedMul(cv_cam3_dist.value, mapobjectscale);
camheight = FixedMul(cv_cam3_height.value, mapobjectscale);
lookback = camspin[2];
}
else if (thiscam == &camera[3]) // Camera 4
{
num = 3;
camspeed = cv_cam4_speed.value;
camstill = cv_cam4_still.value;
camrotate = cv_cam4_rotate.value;
camdist = FixedMul(cv_cam4_dist.value, mapobjectscale);
camheight = FixedMul(cv_cam4_height.value, mapobjectscale);
lookback = camspin[3];
}
else // Camera 1
{
num = 0;
camspeed = cv_cam_speed.value;
camstill = cv_cam_still.value;
camrotate = cv_cam_rotate.value;
camdist = FixedMul(cv_cam_dist.value, mapobjectscale);
camheight = FixedMul(cv_cam_height.value, mapobjectscale);
lookback = camspin[0];
}
camspeed = cv_cam_speed[num].value;
camstill = cv_cam_still[num].value;
camrotate = cv_cam_rotate[num].value;
camdist = FixedMul(cv_cam_dist[num].value, mapobjectscale);
camheight = FixedMul(cv_cam_height[num].value, mapobjectscale);
lookback = camspin[num];
if (timeover)
{
@@ -3651,10 +3614,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
}
if (!resetcalled && (leveltime > starttime && timeover != 2)
&& ((thiscam == &camera[0] && t_cam_rotate != -42)
|| (thiscam == &camera[1] && t_cam2_rotate != -42)
|| (thiscam == &camera[2] && t_cam3_rotate != -42)
|| (thiscam == &camera[3] && t_cam4_rotate != -42)))
&& (thiscam == &camera[num] && t_cam_rotate[num] != -42))
{
angle = FixedAngle(camrotate*FRACUNIT);
thiscam->angle = angle;
@@ -3995,7 +3955,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
{
P_MoveChaseCamera(player, thiscam, false);
R_ResetViewInterpolation(num + 1);
R_ResetViewInterpolation(num + 1);
}
return (x == thiscam->x && y == thiscam->y && z == thiscam->z && angle == thiscam->aiming);
@@ -4020,7 +3979,6 @@ boolean P_SpectatorJoinGame(player_t *player)
{
if (P_IsLocalPlayer(player))
CONS_Printf(M_GetText("Server does not allow team change.\n"));
//player->powers[pw_flashing] = TICRATE + 1; //to prevent message spam.
}
// Team changing in Team Match and CTF
// Pressing fire assigns you to a team that needs players if allowed.
@@ -4103,11 +4061,12 @@ boolean P_SpectatorJoinGame(player_t *player)
return false;
}
// the below is first person only, if you're curious. check out P_CalcChasePostImg in p_mobj.c for chasecam
static void P_CalcPostImg(player_t *player)
{
sector_t *sector = player->mo->subsector->sector;
postimg_t *type = NULL;
INT32 *param;
INT16 typeflag = 0;
//INT32 *param;
fixed_t pviewheight;
UINT8 i;
@@ -4122,20 +4081,19 @@ static void P_CalcPostImg(player_t *player)
pviewheight = player->awayviewmobj->z + 20*FRACUNIT;
}
for (i = 0; i <= splitscreen; i++)
/*for (i = 0; i <= splitscreen; i++)
{
if (player == &players[displayplayers[i]])
{
type = &postimgtype[i];
param = &postimgparam[i];
break;
}
}
}*/
// see if we are in heat (no, not THAT kind of heat...)
if (P_FindSpecialLineFromTag(13, sector->tag, -1) != -1)
*type = postimg_heat;
typeflag |= POSTIMG_HEAT;
else if (sector->ffloors)
{
ffloor_t *rover;
@@ -4154,7 +4112,7 @@ static void P_CalcPostImg(player_t *player)
continue;
if (P_FindSpecialLineFromTag(13, rover->master->frontsector->tag, -1) != -1)
*type = postimg_heat;
typeflag |= POSTIMG_HEAT;
}
}
@@ -4176,36 +4134,35 @@ static void P_CalcPostImg(player_t *player)
if (pviewheight >= topheight || pviewheight <= bottomheight)
continue;
*type = postimg_water;
typeflag |= POSTIMG_WATER;
}
}
if (!encoremode) // srb2kart
{
if (player->mo->eflags & MFE_VERTICALFLIP)
*type = postimg_flip;
}
else
{
if (player->mo->eflags & MFE_VERTICALFLIP)
*type = postimg_mirrorflip;
else
*type = postimg_mirror;
}
if (encoremode) // srb2kart
typeflag |= POSTIMG_MIRROR;
if (player->mo->eflags & MFE_VERTICALFLIP)
typeflag |= POSTIMG_FLIP;
#if 1
(void)param;
#else
// Motion blur
if (player->speed > (35<<FRACBITS))
// unused
/*if (player->speed > (35<<FRACBITS))
{
*type = postimg_motion;
typeflag |= POSTIMG_MOTION;
*param = (player->speed - 32)/4;
if (*param > 5)
*param = 5;
}*/
for (i = 0; i <= splitscreen; i++)
{
if (player != &players[displayplayers[i]])
continue;
players[displayplayers[i]].postimgflags = typeflag;
break;
}
#endif
}
void P_DoTimeOver(player_t *player)
@@ -4215,6 +4172,8 @@ void P_DoTimeOver(player_t *player)
player->pflags |= PF_TIMEOVER;
demo.savebutton = leveltime;
if (P_IsLocalPlayer(player) && !demo.playback)
legitimateexit = true; // SRB2kart: losing a race is still seeing it through to the end :p
@@ -4368,7 +4327,7 @@ void P_PlayerThink(player_t *player)
}
if (player->playerstate == PST_REBORN)
{
LUAh_PlayerThink(player);
LUA_HookPlayer(player, HOOK(PlayerThink));
return;
}
}
@@ -4475,7 +4434,7 @@ void P_PlayerThink(player_t *player)
if (player->playerstate == PST_DEAD)
{
LUAh_PlayerThink(player);
LUA_HookPlayer(player, HOOK(PlayerThink));
return;
}
}
@@ -4541,7 +4500,7 @@ void P_PlayerThink(player_t *player)
else
player->mo->flags2 &= ~MF2_SHADOW;
P_DeathThink(player);
LUAh_PlayerThink(player);
LUA_HookPlayer(player, HOOK(PlayerThink));
return;
}
@@ -4713,7 +4672,7 @@ void P_PlayerThink(player_t *player)
if (!player->mo)
{
LUAh_PlayerThink(player);
LUA_HookPlayer(player, HOOK(PlayerThink));
return; // P_MovePlayer removed player->mo.
}
@@ -4725,10 +4684,7 @@ void P_PlayerThink(player_t *player)
if (player->onconveyor == 1)
player->cmomy = player->cmomx = 0;
//P_DoSuperStuff(player);
//P_CheckSneakerAndLivesTimer(player);
P_DoBubbleBreath(player); // Spawn Sonic's bubbles
//P_CheckUnderwaterAndSpaceTimer(player); // Display the countdown drown numbers!
P_CheckInvincibilityTimer(player); // Spawn Invincibility Sparkles
P_DoPlayerHeadSigns(player); // Spawn Tag/CTF signs over player's head
@@ -4896,7 +4852,7 @@ void P_PlayerThink(player_t *player)
if (rendermode != render_none)
DoABarrelRoll(player);
LUAh_PlayerThink(player);
LUA_HookPlayer(player, HOOK(PlayerThink));
}
//
@@ -4947,7 +4903,6 @@ void P_PlayerAfterThink(player_t *player)
if (player->pflags & PF_NIGHTSMODE)
{
player->powers[pw_gravityboots] = 0;
//player->mo->eflags &= ~MFE_VERTICALFLIP;
}
if (player->pflags & PF_SLIDING)
+24 -7
View File
@@ -15,6 +15,8 @@
#include "g_game.h"
#include "r_local.h"
#include "r_state.h"
#include "r_portal.h" // Add seg portals
#include "r_splats.h"
#include "p_local.h" // camera
@@ -28,7 +30,6 @@ side_t *sidedef;
line_t *linedef;
sector_t *frontsector;
sector_t *backsector;
portal_pair *g_portal; // is curline a portal seg?
// very ugly realloc() of drawsegs at run-time, I upped it to 512
// instead of 256.. and someone managed to send me a level with
@@ -486,7 +487,7 @@ static void R_AddLine(seg_t *line)
line2 = P_FindSpecialLineFromTag(40, line->linedef->tag, line2);
if (line2 >= 0) // found it!
{
R_AddPortal(line->linedef-lines, line2, x1, x2); // Remember the lines for later rendering
Portal_Add2Lines(line->linedef-lines, line2, x1, x2); // Remember the lines for later rendering
//return; // Don't fill in that space now!
goto clipsolid;
}
@@ -582,10 +583,10 @@ static void R_AddLine(seg_t *line)
clippass:
g_walloffscreen = false;
R_ClipPassWallSegment(x1, x2 - 1, false);
if (g_walloffscreen)
R_ClipPassWallSegment(x1, x2 - 1, true);
else
R_ClipPassWallSegment(x1, x2 - 1, false);
return;
clipsolid:
@@ -626,7 +627,21 @@ static boolean R_CheckBBox(const fixed_t *bspcoord)
cliprange_t *start;
// Find the corners of the box that define the edges from current viewpoint.
if ((boxpos = (viewx <= bspcoord[BOXLEFT] ? 0 : viewx < bspcoord[BOXRIGHT] ? 1 : 2) + (viewy >= bspcoord[BOXTOP] ? 0 : viewy > bspcoord[BOXBOTTOM] ? 4 : 8)) == 5)
if (viewx <= bspcoord[BOXLEFT])
boxpos = 0;
else if (viewx < bspcoord[BOXRIGHT])
boxpos = 1;
else
boxpos = 2;
if (viewy >= bspcoord[BOXTOP])
boxpos |= 0;
else if (viewy > bspcoord[BOXBOTTOM])
boxpos |= 1<<2;
else
boxpos |= 2<<2;
if (boxpos == 5)
return true;
check = checkcoord[boxpos];
@@ -655,7 +670,8 @@ static boolean R_CheckBBox(const fixed_t *bspcoord)
sx2 = viewangletox[angle2];
// Does not cross a pixel.
if (sx1 >= sx2) return false;
if (sx1 >= sx2)
return false;
start = solidsegs;
while (start->last < sx2)
@@ -1319,7 +1335,8 @@ void R_RenderBSPNode(INT32 bspnum)
bsp = &nodes[bspnum];
// Decide which side the view point is on.
side = R_PointOnSide(viewx, viewy, bsp);
side = R_PointOnSideFast(viewx, viewy, bsp);
// Recursively divide front space.
R_RenderBSPNode(bsp->children[side]);
+2 -2
View File
@@ -25,7 +25,8 @@ extern side_t *sidedef;
extern line_t *linedef;
extern sector_t *frontsector;
extern sector_t *backsector;
extern portal_pair *g_portal; // is curline a portal seg?
typedef struct portal_s portal_t;
extern portal_t *g_portal; // is curline a portal seg?
// drawsegs are allocated on the fly... see r_segs.c
@@ -41,7 +42,6 @@ void R_ClearClipSegs(void);
void R_PortalClearClipSegs(INT32 start, INT32 end);
void R_ClearDrawSegs(void);
void R_RenderBSPNode(INT32 bspnum);
void R_AddPortal(INT32 line1, INT32 line2, INT32 x1, INT32 x2);
// determines when a given sector shouldn't abide by the encoremap's palette.
// no longer a static since this is used for encore in hw_main.c as well now:
Loaded 100 of 136 files, more files were not shown because too many files have changed in this diff. Show more