Merge branch 'Saturn-Next' into optimizeluaactions
This commit is contained in:
commit
59a50994b8
64 files changed
+2571
-1389
No files matched your search
+64
@@ -52,6 +52,70 @@ Returns the displayplayer's HUD color.
|
||||
|
||||
Returns true if colorization is enabled, false otherwise.
|
||||
|
||||
## v.interpolate(true)
|
||||
|
||||
Enables HUD interpolation. Each call to a drawing function will have its coordinates interpolated
|
||||
by assigning an unique ID to every call.
|
||||
For example, three successive calls to `v.draw` will each have their own ID and interpolation offsets.
|
||||
Pass `true` to enable interpolation, `false` to disable.
|
||||
|
||||
Alternatively, pass a number to enable interpolation with the specified tag.
|
||||
Tags allow HUD items drawn by the same call to a drawing function to be differentiated.
|
||||
Valid tags range from 0-255.
|
||||
For example, when iterating players, use a unique tag for each player to avoid artifacting:
|
||||
```lua
|
||||
for p in players.iterate do
|
||||
-- enable interpolation, using player numbers as the tag
|
||||
-- every draw will have different interp offsets per player
|
||||
v.interpolate(#p)
|
||||
|
||||
-- doesn't matter for unconditional draws like this one...
|
||||
v.draw(...)
|
||||
|
||||
-- but it does matter if there's a condition!
|
||||
-- without tags, this patch would warp between players
|
||||
-- whenever their `someVar` changes
|
||||
if p.someVar then v.draw(...) end
|
||||
end
|
||||
|
||||
-- don't want interpolation anymore? then disable it
|
||||
v.interpolate(false)
|
||||
```
|
||||
NOTE: The default tag for `true` is 0.
|
||||
|
||||
## v.interpLatch(true)
|
||||
|
||||
Enables interpolation offset latching. The next call to a drawing function will have its lerp offsets
|
||||
saved and reused for all following draw calls. Disable with `false` when done.
|
||||
Interpolation cannot easily "snap" between two points; latching can help overcome this by manually
|
||||
setting the lerp offsets.
|
||||
```lua
|
||||
v.interpolate(true)
|
||||
|
||||
-- X coordinate for the HUD item
|
||||
-- every so often, this will wrap around to zero
|
||||
local x = (leveltime*4) % 256
|
||||
|
||||
-- draw an interpolated patch, but... when X rolls back to zero,
|
||||
-- the patch will slide all the way across the screen!
|
||||
v.draw(x, 100, ...)
|
||||
|
||||
-- this is where interpLatch comes into play
|
||||
-- enable latching, then draw an invisible patch,
|
||||
-- moving at the same speed as the visible patch
|
||||
-- the exact coordinates don't matter, it just has to move at the right speed
|
||||
v.interpLatch(true)
|
||||
v.draw(leveltime*4, 0, v.cachePatch("K_TRNULL"))
|
||||
|
||||
-- now we can draw the patch again, and when X becomes zero,
|
||||
-- it'll snap right back without sliding across the screen
|
||||
v.draw(x, 150, ...)
|
||||
|
||||
-- don't forget to turn off latching!
|
||||
v.interpLatch(false)
|
||||
```
|
||||
When using a custom string drawer, enable this mode to avoid interpolation artifacting when the string changes.
|
||||
|
||||
## mobj.spritexscale, mobj.spriteyscale, mobj.spritexoffset, mobj.spriteyoffset, mobj.rollangle, mobj.sloperoll, mobj.rollmodel fields
|
||||
|
||||
Same fields as in SRB2 2.2
|
||||
|
||||
@@ -106,6 +106,8 @@ ifeq ($(OS),Windows_NT) # all windows are Windows_NT...
|
||||
|
||||
else # if you on the *nix
|
||||
|
||||
NOUPX=1
|
||||
|
||||
system:=$(shell uname -s)
|
||||
|
||||
ifeq ($(system),Linux)
|
||||
|
||||
@@ -1015,6 +1015,9 @@ static inline void AM_drawPlayers(void)
|
||||
{
|
||||
if (!playeringame[i] || players[i].spectator)
|
||||
continue;
|
||||
|
||||
if (!players[i].mo)
|
||||
continue;
|
||||
|
||||
p = &players[i];
|
||||
if (p->skincolor > 0)
|
||||
|
||||
@@ -11,17 +11,12 @@
|
||||
/// \brief Macros to read/write from/to a UINT8 *,
|
||||
/// used for packet creation and such
|
||||
|
||||
#if defined (__alpha__) || defined (__arm__) || defined (__mips__) || defined (__ia64__) || defined (__clang__)
|
||||
#define DEALIGNED
|
||||
#endif
|
||||
|
||||
#include "endian.h"
|
||||
|
||||
#ifndef SRB2_BIG_ENDIAN
|
||||
//
|
||||
// Little-endian machines
|
||||
//
|
||||
#ifdef DEALIGNED
|
||||
#define WRITEUINT8(p,b) do { UINT8 *p_tmp = (void *)p; const UINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||
#define WRITESINT8(p,b) do { SINT8 *p_tmp = (void *)p; const SINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||
#define WRITEINT16(p,b) do { INT16 *p_tmp = (void *)p; const INT16 tv = ( INT16)(b); memcpy(p, &tv, sizeof( INT16)); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||
@@ -31,20 +26,8 @@
|
||||
#define WRITECHAR(p,b) do { char *p_tmp = (void *)p; const char tv = ( char)(b); memcpy(p, &tv, sizeof( char)); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||
#define WRITEFIXED(p,b) do { fixed_t *p_tmp = (void *)p; const fixed_t tv = (fixed_t)(b); memcpy(p, &tv, sizeof(fixed_t)); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||
#define WRITEANGLE(p,b) do { angle_t *p_tmp = (void *)p; const angle_t tv = (angle_t)(b); memcpy(p, &tv, sizeof(angle_t)); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||
#else
|
||||
#define WRITEUINT8(p,b) do { UINT8 *p_tmp = ( UINT8 *)p; *p_tmp = ( UINT8)(b); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||
#define WRITESINT8(p,b) do { SINT8 *p_tmp = ( SINT8 *)p; *p_tmp = ( SINT8)(b); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||
#define WRITEINT16(p,b) do { INT16 *p_tmp = ( INT16 *)p; *p_tmp = ( INT16)(b); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||
#define WRITEUINT16(p,b) do { UINT16 *p_tmp = ( UINT16 *)p; *p_tmp = ( UINT16)(b); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||
#define WRITEINT32(p,b) do { INT32 *p_tmp = ( INT32 *)p; *p_tmp = ( INT32)(b); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||
#define WRITEUINT32(p,b) do { UINT32 *p_tmp = ( UINT32 *)p; *p_tmp = ( UINT32)(b); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||
#define WRITECHAR(p,b) do { char *p_tmp = ( char *)p; *p_tmp = ( char)(b); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||
#define WRITEFIXED(p,b) do { fixed_t *p_tmp = (fixed_t *)p; *p_tmp = (fixed_t)(b); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||
#define WRITEANGLE(p,b) do { angle_t *p_tmp = (angle_t *)p; *p_tmp = (angle_t)(b); p_tmp++; p = (void *)p_tmp; } while (0)
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#ifdef DEALIGNED
|
||||
#define READUINT8(p) ({ UINT8 *p_tmp = (void *)p; UINT8 b; memcpy(&b, p, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; b; })
|
||||
#define READSINT8(p) ({ SINT8 *p_tmp = (void *)p; SINT8 b; memcpy(&b, p, sizeof( SINT8)); p_tmp++; p = (void *)p_tmp; b; })
|
||||
#define READINT16(p) ({ INT16 *p_tmp = (void *)p; INT16 b; memcpy(&b, p, sizeof( INT16)); p_tmp++; p = (void *)p_tmp; b; })
|
||||
@@ -55,17 +38,6 @@
|
||||
#define READFIXED(p) ({ fixed_t *p_tmp = (void *)p; fixed_t b; memcpy(&b, p, sizeof(fixed_t)); p_tmp++; p = (void *)p_tmp; b; })
|
||||
#define READANGLE(p) ({ angle_t *p_tmp = (void *)p; angle_t b; memcpy(&b, p, sizeof(angle_t)); p_tmp++; p = (void *)p_tmp; b; })
|
||||
#else
|
||||
#define READUINT8(p) ({ UINT8 *p_tmp = ( UINT8 *)p; UINT8 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; })
|
||||
#define READSINT8(p) ({ SINT8 *p_tmp = ( SINT8 *)p; SINT8 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; })
|
||||
#define READINT16(p) ({ INT16 *p_tmp = ( INT16 *)p; INT16 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; })
|
||||
#define READUINT16(p) ({ UINT16 *p_tmp = ( UINT16 *)p; UINT16 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; })
|
||||
#define READINT32(p) ({ INT32 *p_tmp = ( INT32 *)p; INT32 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; })
|
||||
#define READUINT32(p) ({ UINT32 *p_tmp = ( UINT32 *)p; UINT32 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; })
|
||||
#define READCHAR(p) ({ char *p_tmp = ( char *)p; char b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; })
|
||||
#define READFIXED(p) ({ fixed_t *p_tmp = (fixed_t *)p; fixed_t b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; })
|
||||
#define READANGLE(p) ({ angle_t *p_tmp = (angle_t *)p; angle_t b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; })
|
||||
#endif
|
||||
#else
|
||||
#define READUINT8(p) *(( UINT8 *)p)++
|
||||
#define READSINT8(p) *(( SINT8 *)p)++
|
||||
#define READINT16(p) *(( INT16 *)p)++
|
||||
@@ -148,8 +120,6 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr)
|
||||
#define READANGLE(p) ({ angle_t *p_tmp = (angle_t *)p; angle_t b = readulong(p); p_tmp++; p = (void *)p_tmp; b; })
|
||||
#endif //SRB2_BIG_ENDIAN
|
||||
|
||||
#undef DEALIGNED
|
||||
|
||||
#define WRITESTRINGN(p, s, n) ({ \
|
||||
size_t tmp_i; \
|
||||
\
|
||||
|
||||
+19
-3
@@ -23,6 +23,7 @@
|
||||
#include "d_netfil.h" // fileneedednum
|
||||
#include "d_main.h"
|
||||
#include "g_game.h"
|
||||
#include "m_menu.h" // M_ClearMenus
|
||||
#include "hu_stuff.h"
|
||||
#include "keys.h"
|
||||
#include "g_input.h" // JOY1
|
||||
@@ -1333,9 +1334,13 @@ static inline void CL_DrawConnectionStatus(void)
|
||||
{
|
||||
strncpy(tempname, filename, sizeof(tempname)-1);
|
||||
}
|
||||
|
||||
#ifdef HAVE_CURL
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-30, 0,
|
||||
va(M_GetText("%s downloading"), ((cl_mode == CL_DOWNLOADHTTPFILES) ? "\x82""HTTP" : "\x85""Direct")));
|
||||
#else
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-30, 0,
|
||||
va(M_GetText("%s downloading"),("\x85""Direct")));
|
||||
#endif
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-22, V_YELLOWMAP,
|
||||
va(M_GetText("\"%s\""), tempname));
|
||||
V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, V_20TRANS|V_MONOSPACE,
|
||||
@@ -2170,7 +2175,9 @@ static void M_ConfirmConnect(event_t *ev)
|
||||
|
||||
static void AbortConnection(void)
|
||||
{
|
||||
#ifdef HAVE_CURL
|
||||
CURLAbortFile();
|
||||
#endif
|
||||
D_QuitNetGame();
|
||||
CL_Reset();
|
||||
D_StartTitle();
|
||||
@@ -3040,8 +3047,17 @@ static void Command_connect(void)
|
||||
|
||||
if (Playing() || demo.title)
|
||||
{
|
||||
CONS_Printf(M_GetText("You cannot connect while in a game. End this game first.\n"));
|
||||
return;
|
||||
M_ClearMenus(true);
|
||||
if (demo.title)
|
||||
G_CheckDemoStatus();
|
||||
|
||||
if (netgame)
|
||||
{
|
||||
D_QuitNetGame();
|
||||
CL_Reset();
|
||||
}
|
||||
|
||||
D_StartTitle();
|
||||
}
|
||||
|
||||
// modified game check: no longer handled
|
||||
|
||||
@@ -577,6 +577,8 @@ static CV_PossibleValue_t skinselectgridsort_t[] ={
|
||||
};
|
||||
consvar_t cv_skinselectgridsort ={ "skinselectgridsort", "Real name", CV_SAVE|CV_CALL|CV_NOINIT, skinselectgridsort_t, sortSkinGrid, 0, NULL, NULL, 0, 0, NULL };
|
||||
|
||||
consvar_t cv_betainterscreen = {"betaintermissionscreen", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
INT16 gametype = GT_RACE; // SRB2kart
|
||||
boolean forceresetplayers = false;
|
||||
boolean deferencoremode = false;
|
||||
@@ -822,6 +824,8 @@ void D_RegisterServerCommands(void)
|
||||
CV_RegisterVar(&cv_netdemosyncquality);
|
||||
CV_RegisterVar(&cv_maxdemosize);
|
||||
CV_RegisterVar(&cv_keyboardlayout);
|
||||
|
||||
CV_RegisterVar(&cv_betainterscreen);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
|
||||
@@ -205,6 +205,8 @@ extern consvar_t cv_showtrackaddon;
|
||||
|
||||
extern consvar_t cv_showspecstuff;
|
||||
|
||||
extern consvar_t cv_betainterscreen;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SKINMENUTYPE_SCROLL = 0,
|
||||
|
||||
+2
-1
@@ -1300,8 +1300,9 @@ void CURLPrepareFile(const char* url, int dfilenum)
|
||||
curl_starttime = time(NULL);
|
||||
|
||||
curl_running = true;
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
I_spawn_thread("http-download", (I_thread_fn)CURLGetFile, NULL);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-6
@@ -9116,12 +9116,15 @@ int LUA_EnumLib(lua_State *L)
|
||||
char *str = NULL;
|
||||
int size = 0;
|
||||
|
||||
// Sound enum tables preallocated for sfx_freeslot0 elements because using NUMSFX may be too
|
||||
// much if number of skins increased a lot (because of skinsound freeslots)
|
||||
|
||||
/* SFX (SFX_) */
|
||||
lua_pushcfunction(L, lua_glib_new_enum);
|
||||
lua_createtable(L, 0, NUMSFX);
|
||||
lua_createtable(L, 0, sfx_freeslot0);
|
||||
for (int i = 0; i < NUMSFX; i++)
|
||||
{
|
||||
if (!S_sfx[i].name) continue;
|
||||
if (!S_sfx[i].name || !S_sfx[i].priority) continue;
|
||||
|
||||
if (lua_enumlib_sprintf_upper(&str, &size, "SFX_%s", S_sfx[i].name) == NULL)
|
||||
return luaL_error(L, "Ran out of memory.");
|
||||
@@ -9136,10 +9139,10 @@ int LUA_EnumLib(lua_State *L)
|
||||
|
||||
/* SFX (DS) */
|
||||
lua_pushcfunction(L, lua_glib_new_enum);
|
||||
lua_createtable(L, 0, NUMSFX);
|
||||
lua_createtable(L, 0, sfx_freeslot0);
|
||||
for (int i = 0; i < NUMSFX; i++)
|
||||
{
|
||||
if (!S_sfx[i].name) continue;
|
||||
if (!S_sfx[i].name || !S_sfx[i].priority) continue;
|
||||
|
||||
if (lua_enumlib_sprintf_upper(&str, &size, "DS%s", S_sfx[i].name) == NULL)
|
||||
return luaL_error(L, "Ran out of memory.");
|
||||
@@ -9174,10 +9177,10 @@ int LUA_EnumLib(lua_State *L)
|
||||
{
|
||||
/* SFX (sfx_) */
|
||||
lua_pushcfunction(L, lua_glib_new_enum);
|
||||
lua_createtable(L, 0, NUMSFX);
|
||||
lua_createtable(L, 0, sfx_freeslot0);
|
||||
for (int i = 0; i < NUMSFX; i++)
|
||||
{
|
||||
if (!S_sfx[i].name) continue;
|
||||
if (!S_sfx[i].name || !S_sfx[i].priority) continue;
|
||||
|
||||
lua_pushfstring(L, "sfx_%s", S_sfx[i].name);
|
||||
lua_pushinteger(L, i);
|
||||
|
||||
@@ -211,6 +211,7 @@ extern char logfilename[1024];
|
||||
|
||||
#define MAXPLAYERS 16
|
||||
#define MAXSKINS 255
|
||||
#define MAXLOCALSKINS 32
|
||||
#define PLAYERSMASK (MAXPLAYERS-1)
|
||||
#define MAXPLAYERNAME 21
|
||||
|
||||
|
||||
+14
-6
@@ -2108,7 +2108,7 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive)
|
||||
olddisplayplayer = (*displayplayerp);
|
||||
|
||||
/* Check if anyone is available to view. */
|
||||
if (( playernum = G_FindView(playernum, viewnum, onlyactive, playernum < olddisplayplayer) ) == -1)
|
||||
if ((playernum = G_FindView(playernum, viewnum, onlyactive, playernum < olddisplayplayer)) == -1)
|
||||
return;
|
||||
|
||||
/* Focus our target view first so that we don't take its player. */
|
||||
@@ -2118,6 +2118,8 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive)
|
||||
camerap = &camera[viewnum-1];
|
||||
P_ResetCamera(&players[(*displayplayerp)], camerap);
|
||||
|
||||
// Make sure the viewport doesn't interpolate at all into
|
||||
// its new position -- just snap instantly into place.
|
||||
R_ResetViewInterpolation(viewnum);
|
||||
}
|
||||
|
||||
@@ -2131,6 +2133,11 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive)
|
||||
(*displayplayerp) = G_FindView(0, viewd, onlyactive, false);
|
||||
|
||||
P_ResetCamera(&players[(*displayplayerp)], camerap);
|
||||
|
||||
|
||||
// Make sure the viewport doesn't interpolate at all into
|
||||
// its new position -- just snap instantly into place.
|
||||
R_ResetViewInterpolation(viewd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2244,13 +2251,14 @@ void G_Ticker(boolean run)
|
||||
buf = gametic % TICQUEUE;
|
||||
|
||||
if (!demo.playback)
|
||||
// read/write demo and check turbo cheat
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
cmd = &players[i].cmd;
|
||||
|
||||
if (playeringame[i])
|
||||
for (i = 0; i < MAXPLAYERS; i++) // read/write demo and check turbo cheat
|
||||
{
|
||||
cmd = &players[i].cmd;
|
||||
|
||||
if (!playeringame[i])
|
||||
continue;
|
||||
|
||||
//@TODO all this throwdir stuff shouldn't be here! But it stays for now to maintain 1.0.4 compat...
|
||||
// Remove for 1.1!
|
||||
|
||||
|
||||
+27
-31
@@ -35,7 +35,7 @@ int finalVertexArrayAllocSize = 65536;
|
||||
|
||||
PolygonArrayEntry* polygonArray = NULL;// contains the polygon data from DrawPolygon, waiting to be processed
|
||||
int polygonArraySize = 0;
|
||||
UINT32* polygonIndexArray = NULL;// contains sorting pointers for polygonArray
|
||||
PolygonArrayEntry **polygonArraySorted = NULL;// contains sorted pointers to polygonArray
|
||||
int polygonArrayAllocSize = 65536;
|
||||
|
||||
FOutVector* unsortedVertexArray = NULL;// contains unsorted vertices and texture coordinates from DrawPolygon
|
||||
@@ -55,7 +55,7 @@ void HWR_StartBatching(void)
|
||||
finalVertexArray = malloc(finalVertexArrayAllocSize * sizeof(FOutVector));
|
||||
finalVertexIndexArray = malloc(finalVertexArrayAllocSize * 3 * sizeof(UINT32));
|
||||
polygonArray = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry));
|
||||
polygonIndexArray = malloc(polygonArrayAllocSize * sizeof(UINT32));
|
||||
polygonArraySorted = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry *));
|
||||
unsortedVertexArray = malloc(unsortedVertexArrayAllocSize * sizeof(FOutVector));
|
||||
}
|
||||
|
||||
@@ -96,8 +96,8 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt
|
||||
free(polygonArray);
|
||||
polygonArray = new_array;
|
||||
// also need to redo the index array, dont need to copy it though
|
||||
free(polygonIndexArray);
|
||||
polygonIndexArray = malloc(polygonArrayAllocSize * sizeof(UINT32));
|
||||
free(polygonArraySorted);
|
||||
polygonArraySorted = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry *));
|
||||
}
|
||||
|
||||
while (unsortedVertexArraySize + (int)iNumPts > unsortedVertexArrayAllocSize)
|
||||
@@ -134,10 +134,8 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt
|
||||
|
||||
static int comparePolygons(const void *p1, const void *p2)
|
||||
{
|
||||
unsigned int index1 = *(const unsigned int*)p1;
|
||||
unsigned int index2 = *(const unsigned int*)p2;
|
||||
PolygonArrayEntry* poly1 = &polygonArray[index1];
|
||||
PolygonArrayEntry* poly2 = &polygonArray[index2];
|
||||
PolygonArrayEntry *poly1 = *(PolygonArrayEntry *const *)p1;
|
||||
PolygonArrayEntry *poly2 = *(PolygonArrayEntry *const *)p2;
|
||||
int diff;
|
||||
INT64 diff64;
|
||||
UINT32 downloaded1 = 0;
|
||||
@@ -155,7 +153,7 @@ static int comparePolygons(const void *p1, const void *p2)
|
||||
|
||||
// skywalls and horizon lines must retain their order for horizon lines to work
|
||||
if (shader1 == -1 && shader2 == -1)
|
||||
return index1 - index2;
|
||||
return poly1 - poly2;
|
||||
|
||||
if (poly1->texture)
|
||||
downloaded1 = poly1->texture->downloaded; // there should be a opengl texture name here, usable for comparisons
|
||||
@@ -184,10 +182,8 @@ static int comparePolygons(const void *p1, const void *p2)
|
||||
|
||||
static int comparePolygonsNoShaders(const void *p1, const void *p2)
|
||||
{
|
||||
unsigned int index1 = *(const unsigned int*)p1;
|
||||
unsigned int index2 = *(const unsigned int*)p2;
|
||||
PolygonArrayEntry* poly1 = &polygonArray[index1];
|
||||
PolygonArrayEntry* poly2 = &polygonArray[index2];
|
||||
PolygonArrayEntry *poly1 = *(PolygonArrayEntry *const *)p1;
|
||||
PolygonArrayEntry *poly2 = *(PolygonArrayEntry *const *)p2;
|
||||
int diff;
|
||||
INT64 diff64;
|
||||
|
||||
@@ -205,7 +201,7 @@ static int comparePolygonsNoShaders(const void *p1, const void *p2)
|
||||
downloaded2 = texture2->downloaded;
|
||||
// skywalls and horizon lines must retain their order for horizon lines to work
|
||||
if (!texture1 && !texture2)
|
||||
return index1 - index2;
|
||||
return poly1 - poly2;
|
||||
diff64 = downloaded1 - downloaded2;
|
||||
if (diff64 != 0) return diff64;
|
||||
|
||||
@@ -225,7 +221,7 @@ void HWR_RenderBatches(void)
|
||||
int finalVertexWritePos = 0;// position in finalVertexArray
|
||||
int finalIndexWritePos = 0;// position in finalVertexIndexArray
|
||||
|
||||
int polygonReadPos = 0;// position in polygonIndexArray
|
||||
int polygonReadPos = 0;// position in polygonArraySorted
|
||||
|
||||
int currentShader;
|
||||
int nextShader = 0;
|
||||
@@ -258,18 +254,18 @@ 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 polygonIndexArray
|
||||
// init polygonArraySorted
|
||||
for (i = 0; i < polygonArraySize; i++)
|
||||
{
|
||||
polygonIndexArray[i] = i;
|
||||
polygonArraySorted[i] = &polygonArray[i];
|
||||
}
|
||||
|
||||
// sort polygons
|
||||
PS_START_TIMING(ps_hw_batchsorttime);
|
||||
if (cv_grshaders.value && gr_shadersavailable)
|
||||
qs22j(polygonIndexArray, polygonArraySize, sizeof(unsigned int), comparePolygons);
|
||||
qs22j(polygonArraySorted, polygonArraySize, sizeof(PolygonArrayEntry *), comparePolygons);
|
||||
else
|
||||
qs22j(polygonIndexArray, polygonArraySize, sizeof(unsigned int), comparePolygonsNoShaders);
|
||||
qs22j(polygonArraySorted, polygonArraySize, sizeof(PolygonArrayEntry *), comparePolygonsNoShaders);
|
||||
PS_STOP_TIMING(ps_hw_batchsorttime);
|
||||
// sort order
|
||||
// 1. shader
|
||||
@@ -280,10 +276,10 @@ void HWR_RenderBatches(void)
|
||||
|
||||
PS_START_TIMING(ps_hw_batchdrawtime);
|
||||
|
||||
currentShader = polygonArray[polygonIndexArray[0]].shader;
|
||||
currentTexture = polygonArray[polygonIndexArray[0]].texture;
|
||||
currentPolyFlags = polygonArray[polygonIndexArray[0]].polyFlags;
|
||||
currentSurfaceInfo = polygonArray[polygonIndexArray[0]].surf;
|
||||
currentShader = polygonArraySorted[0]->shader;
|
||||
currentTexture = polygonArraySorted[0]->texture;
|
||||
currentPolyFlags = polygonArraySorted[0]->polyFlags;
|
||||
currentSurfaceInfo = polygonArraySorted[0]->surf;
|
||||
// For now, will sort and track the colors. Vertex attributes could be used instead of uniforms
|
||||
// and a color array could replace the color calls.
|
||||
|
||||
@@ -322,8 +318,8 @@ void HWR_RenderBatches(void)
|
||||
// reset write pos
|
||||
// repeat loop
|
||||
|
||||
int index = polygonIndexArray[polygonReadPos++];
|
||||
int numVerts = polygonArray[index].numVerts;
|
||||
PolygonArrayEntry *entry = polygonArraySorted[polygonReadPos++];
|
||||
int numVerts = entry->numVerts;
|
||||
// before writing, check if there is enough room
|
||||
// using 'while' instead of 'if' here makes sure that there will *always* be enough room.
|
||||
// probably never will this loop run more than once though
|
||||
@@ -344,7 +340,7 @@ void HWR_RenderBatches(void)
|
||||
finalVertexIndexArray = new_index_array;
|
||||
}
|
||||
// write the vertices of the polygon
|
||||
memcpy(&finalVertexArray[finalVertexWritePos], &unsortedVertexArray[polygonArray[index].vertsIndex],
|
||||
memcpy(&finalVertexArray[finalVertexWritePos], &unsortedVertexArray[entry->vertsIndex],
|
||||
numVerts * sizeof(FOutVector));
|
||||
// write the indexes, pointing to the fan vertexes but in triangles format
|
||||
firstIndex = finalVertexWritePos;
|
||||
@@ -364,11 +360,11 @@ void HWR_RenderBatches(void)
|
||||
else
|
||||
{
|
||||
// check if a state change is required, set the change bools and next vars
|
||||
int nextIndex = polygonIndexArray[polygonReadPos];
|
||||
nextShader = polygonArray[nextIndex].shader;
|
||||
nextTexture = polygonArray[nextIndex].texture;
|
||||
nextPolyFlags = polygonArray[nextIndex].polyFlags;
|
||||
nextSurfaceInfo = polygonArray[nextIndex].surf;
|
||||
PolygonArrayEntry *nextEntry = polygonArraySorted[polygonReadPos];
|
||||
nextShader = nextEntry->shader;
|
||||
nextTexture = nextEntry->texture;
|
||||
nextPolyFlags = nextEntry->polyFlags;
|
||||
nextSurfaceInfo = nextEntry->surf;
|
||||
if (nextPolyFlags & PF_NoTexture)
|
||||
nextTexture = 0;
|
||||
if (currentShader != nextShader && cv_grshaders.value && gr_shadersavailable)
|
||||
|
||||
+18
-8
@@ -667,9 +667,15 @@ static boolean PointInSeg(polyvertex_t *a,polyvertex_t *v1,polyvertex_t *v2)
|
||||
// v1 = origine
|
||||
ax= v2->x-v1->x;
|
||||
ay= v2->y-v1->y;
|
||||
norm = (float)hypot(ax, ay);
|
||||
ax /= norm;
|
||||
ay /= norm;
|
||||
norm = hypotf(ax, ay);
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
if (norm != 0) // yes, this can be exactly 0
|
||||
#pragma GCC diagnostic pop
|
||||
{
|
||||
ax /= norm;
|
||||
ay /= norm;
|
||||
}
|
||||
bx = a->x-v1->x;
|
||||
by = a->y-v1->y;
|
||||
//d = a.b
|
||||
@@ -772,9 +778,11 @@ static INT32 SolveTProblem(void)
|
||||
for (l = 0; l < addsubsector; l++)
|
||||
{
|
||||
p = extrasubsectors[l].planepoly;
|
||||
if (p)
|
||||
for (i = 0; i < p->numpts; i++)
|
||||
SearchSegInBSP((INT32)numnodes-1, &p->pts[i], p);
|
||||
if (!p)
|
||||
continue;
|
||||
|
||||
for (i = 0; i < p->numpts; i++)
|
||||
SearchSegInBSP((INT32)numnodes-1, &p->pts[i], p);
|
||||
}
|
||||
//CONS_Debug(DBG_RENDER, "numsplitpoly %d\n", numsplitpoly);
|
||||
return numsplitpoly;
|
||||
@@ -802,8 +810,10 @@ static void AdjustSegs(void)
|
||||
count = subsectors[i].numlines;
|
||||
lseg = &segs[subsectors[i].firstline];
|
||||
p = extrasubsectors[i].planepoly;
|
||||
//if (!p)
|
||||
//continue;
|
||||
|
||||
if (!p)
|
||||
continue;
|
||||
|
||||
for (; count--; lseg++)
|
||||
{
|
||||
float distv1,distv2,tmp;
|
||||
|
||||
+23
-15
@@ -26,6 +26,7 @@
|
||||
#include "../z_zone.h"
|
||||
#include "../v_video.h"
|
||||
#include "../r_draw.h"
|
||||
#include "../r_main.h"
|
||||
#include "../r_patch.h" // patch rotation
|
||||
|
||||
INT32 patchformat = GL_TEXFMT_AP_88; // use alpha for holes
|
||||
@@ -344,7 +345,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex, boolean noe
|
||||
|
||||
#ifdef GLENCORE
|
||||
if (encoremap && !noencore)
|
||||
grtex->mipmap.colormap += (256*32);
|
||||
grtex->mipmap.colormap += COLORMAP_REMAPOFFSET;
|
||||
#endif
|
||||
|
||||
blockwidth = texture->width;
|
||||
@@ -380,16 +381,17 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex, boolean noe
|
||||
realpatch);
|
||||
Z_Unlock(realpatch);
|
||||
}
|
||||
|
||||
//Hurdler: not efficient at all but I don't remember exactly how HWR_DrawPatchInCache works :(
|
||||
if (format2bpp(grtex->mipmap.format)==4)
|
||||
{
|
||||
for (i = 3; i < blocksize*4; i += 4) // blocksize*4 because blocksize doesn't include the bpp
|
||||
{
|
||||
if (block[i] == 0)
|
||||
{
|
||||
grtex->mipmap.flags |= TF_TRANSPARENT;
|
||||
break;
|
||||
}
|
||||
if (block[i] != 0)
|
||||
continue;
|
||||
|
||||
grtex->mipmap.flags |= TF_TRANSPARENT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -628,8 +630,12 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
|
||||
#ifdef GLENCORE
|
||||
flat = grMipmap->data;
|
||||
for (steppy = 0; steppy < size; steppy++)
|
||||
if (flat[steppy] != HWR_PATCHES_CHROMAKEY_COLORINDEX)
|
||||
flat[steppy] = grMipmap->colormap[flat[steppy]];
|
||||
{
|
||||
if (flat[steppy] == HWR_PATCHES_CHROMAKEY_COLORINDEX)
|
||||
continue;
|
||||
|
||||
flat[steppy] = grMipmap->colormap[flat[steppy]];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -647,7 +653,7 @@ void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap)
|
||||
|
||||
#ifdef GLENCORE
|
||||
if (!noencoremap && encoremap)
|
||||
grmip->colormap += (256*32);
|
||||
grmip->colormap += COLORMAP_REMAPOFFSET;
|
||||
#endif
|
||||
|
||||
if (!grmip->downloaded && !grmip->data)
|
||||
@@ -729,7 +735,8 @@ void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap)
|
||||
{
|
||||
GLMipmap_t *grmip, *newmip;
|
||||
|
||||
if (colormap == colormaps || colormap == NULL)
|
||||
// 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);
|
||||
@@ -741,11 +748,12 @@ void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap)
|
||||
for (grmip = gpatch->mipmap; grmip->nextcolormap; )
|
||||
{
|
||||
grmip = grmip->nextcolormap;
|
||||
if (grmip->colormap == colormap)
|
||||
{
|
||||
HWR_LoadMappedPatch(grmip, gpatch);
|
||||
return;
|
||||
}
|
||||
|
||||
if (grmip->colormap != colormap)
|
||||
continue;
|
||||
|
||||
HWR_LoadMappedPatch(grmip, gpatch);
|
||||
return;
|
||||
}
|
||||
// not found, create it!
|
||||
// If we are here, the sprite with the current colormap is not already in hardware memory
|
||||
|
||||
@@ -173,6 +173,7 @@ enum
|
||||
{
|
||||
SHADER_NONE = -1,
|
||||
SHADER_FLOOR = 0,
|
||||
SHADER_SHADOW,
|
||||
SHADER_WALL,
|
||||
SHADER_MODEL,
|
||||
SHADER_SPRITE,
|
||||
|
||||
@@ -30,11 +30,9 @@ typedef struct gr_vissprite_s
|
||||
float gz, gzt;
|
||||
float tz, ty;
|
||||
float scale;
|
||||
//lumpnum_t patchlumpnum;
|
||||
float spritexscale, spriteyscale;
|
||||
float spritexoffset, spriteyoffset;
|
||||
UINT32 renderflags;
|
||||
UINT8 rotateflags;
|
||||
GLPatch_t *gpatch;
|
||||
boolean flip;
|
||||
UINT8 translucency; //alpha level 0-255
|
||||
|
||||
+270
-280
@@ -54,6 +54,8 @@
|
||||
|
||||
#define SOFTLIGHT(llevel) HWR_ShouldUsePaletteRendering() ? ((llevel) >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : (llevel)
|
||||
|
||||
#define CLAMP(x, min_val, max_val) ((x) < (min_val) ? (min_val) : ((x) > (max_val) ? (max_val) : (x)))
|
||||
|
||||
// ==========================================================================
|
||||
// the hardware driver object
|
||||
// ==========================================================================
|
||||
@@ -79,6 +81,8 @@ static void CV_grshaders_OnChange(void);
|
||||
static void CV_grpaletterendering_OnChange(void);
|
||||
static void CV_grpalettedepth_OnChange(void);
|
||||
|
||||
static void CV_grlightdithering_OnChange(void);
|
||||
|
||||
static CV_PossibleValue_t grfakecontrast_cons_t[] = {{0, "Off"}, {1, "Standard"}, {2, "Smooth"}, {0, NULL}};
|
||||
|
||||
static CV_PossibleValue_t grfiltermode_cons_t[]= {{HWD_SET_TEXTUREFILTER_POINTSAMPLED, "Nearest"},
|
||||
@@ -155,6 +159,8 @@ consvar_t cv_grpaletterendering = {"gr_paletteshader", "Off", CV_CALL|CV_SAVE, C
|
||||
static CV_PossibleValue_t glpalettedepth_cons_t[] = {{16, "16 bits"}, {24, "24 bits"}, {0, NULL}};
|
||||
consvar_t cv_grpalettedepth = {"gr_palettedepth", "16 bits", CV_SAVE|CV_CALL, glpalettedepth_cons_t, CV_grpalettedepth_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
consvar_t cv_lightdither = {"gr_lightdithering", "Off", CV_CALL|CV_SAVE, CV_OnOff, CV_grlightdithering_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
consvar_t cv_grflashpal = {"gr_flashpal", "On", CV_CALL|CV_SAVE, CV_OnOff, CV_grpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
consvar_t cv_grmdls = {"gr_mdls", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
@@ -184,7 +190,7 @@ static void CV_anisotropic_ONChange(void)
|
||||
static void CV_screentextures_ONChange(void)
|
||||
{
|
||||
ONLY_IF_GL_LOADED
|
||||
if (cv_grscreentextures.value != 3)
|
||||
if (cv_grscreentextures.value != 2)
|
||||
{
|
||||
#ifdef USE_FBO_OGL
|
||||
CV_Set(&cv_grframebuffer, "Off");
|
||||
@@ -215,6 +221,15 @@ static void CV_grpaletterendering_OnChange(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void CV_grlightdithering_OnChange(void)
|
||||
{
|
||||
ONLY_IF_GL_LOADED
|
||||
if (gr_shadersavailable)
|
||||
{
|
||||
HWR_CompileShaders();
|
||||
}
|
||||
}
|
||||
|
||||
static void CV_grpalettedepth_OnChange(void)
|
||||
{
|
||||
ONLY_IF_GL_LOADED
|
||||
@@ -558,12 +573,8 @@ UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap) // Let's see if
|
||||
else
|
||||
{
|
||||
light = light - (255 - light);
|
||||
|
||||
// Don't go out of bounds
|
||||
if (light < 0)
|
||||
light = 0;
|
||||
else if (light > 255)
|
||||
light = 255;
|
||||
light = CLAMP(light, 0, 255);
|
||||
|
||||
alpha = (realcolor.s.alpha*255)/25;
|
||||
|
||||
@@ -602,11 +613,7 @@ static FUINT HWR_CalcWallLight(FUINT lightnum, fixed_t v1x, fixed_t v1y, fixed_t
|
||||
if (extralight != 0)
|
||||
{
|
||||
finallight += extralight;
|
||||
|
||||
if (finallight < 0)
|
||||
finallight = 0;
|
||||
if (finallight > 255)
|
||||
finallight = 255;
|
||||
finallight = CLAMP(finallight, 0 , 255);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -646,11 +653,7 @@ static FUINT HWR_CalcSlopeLight(FUINT lightnum, angle_t dir, fixed_t delta)
|
||||
if (extralight != 0)
|
||||
{
|
||||
finallight += extralight;
|
||||
|
||||
if (finallight < 0)
|
||||
finallight = 0;
|
||||
if (finallight > 255)
|
||||
finallight = 255;
|
||||
finallight = CLAMP(finallight, 0 , 255);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -882,75 +885,75 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc
|
||||
|
||||
for (i = 0; i < subsector->numlines; i++, line++)
|
||||
{
|
||||
if (line->linedef->special == HORIZONSPECIAL && R_PointOnSegSide(viewx, viewy, line) == 0)
|
||||
if (!(line->linedef->special == HORIZONSPECIAL && R_PointOnSegSide(viewx, viewy, line) == 0))
|
||||
continue;
|
||||
|
||||
P_ClosestPointOnLine(viewx, viewy, line->linedef, &v);
|
||||
dist = FIXED_TO_FLOAT(R_PointToDist(v.x, v.y));
|
||||
|
||||
if (line->pv1)
|
||||
{
|
||||
P_ClosestPointOnLine(viewx, viewy, line->linedef, &v);
|
||||
dist = FIXED_TO_FLOAT(R_PointToDist(v.x, v.y));
|
||||
|
||||
if (line->pv1)
|
||||
{
|
||||
x1 = ((polyvertex_t *)line->pv1)->x;
|
||||
y1 = ((polyvertex_t *)line->pv1)->y;
|
||||
}
|
||||
else
|
||||
{
|
||||
x1 = FIXED_TO_FLOAT(line->v1->x);
|
||||
y1 = FIXED_TO_FLOAT(line->v1->x);
|
||||
}
|
||||
if (line->pv2)
|
||||
{
|
||||
xd = ((polyvertex_t *)line->pv2)->x - x1;
|
||||
yd = ((polyvertex_t *)line->pv2)->y - y1;
|
||||
}
|
||||
else
|
||||
{
|
||||
xd = FIXED_TO_FLOAT(line->v2->x) - x1;
|
||||
yd = FIXED_TO_FLOAT(line->v2->y) - y1;
|
||||
}
|
||||
x1 = ((polyvertex_t *)line->pv1)->x;
|
||||
y1 = ((polyvertex_t *)line->pv1)->y;
|
||||
}
|
||||
else
|
||||
{
|
||||
x1 = FIXED_TO_FLOAT(line->v1->x);
|
||||
y1 = FIXED_TO_FLOAT(line->v1->x);
|
||||
}
|
||||
if (line->pv2)
|
||||
{
|
||||
xd = ((polyvertex_t *)line->pv2)->x - x1;
|
||||
yd = ((polyvertex_t *)line->pv2)->y - y1;
|
||||
}
|
||||
else
|
||||
{
|
||||
xd = FIXED_TO_FLOAT(line->v2->x) - x1;
|
||||
yd = FIXED_TO_FLOAT(line->v2->y) - y1;
|
||||
}
|
||||
|
||||
// Based on the seg length and the distance from the line, split horizon into multiple poly sets to reduce distortion
|
||||
dist = sqrtf((xd*xd) + (yd*yd)) / dist / 16.0f;
|
||||
if (dist > 100.0f)
|
||||
numplanes = 100;
|
||||
else
|
||||
numplanes = (UINT8)dist + 1;
|
||||
// Based on the seg length and the distance from the line, split horizon into multiple poly sets to reduce distortion
|
||||
dist = sqrtf((xd*xd) + (yd*yd)) / dist / 16.0f;
|
||||
if (dist > 100.0f)
|
||||
numplanes = 100;
|
||||
else
|
||||
numplanes = (UINT8)dist + 1;
|
||||
|
||||
for (j = 0; j < numplanes; j++)
|
||||
{
|
||||
// Left side
|
||||
vx = x1 + xd * j / numplanes;
|
||||
vy = y1 + yd * j / numplanes;
|
||||
SETUP3DVERT((&horizonpts[1]), vx, vy);
|
||||
for (j = 0; j < numplanes; j++)
|
||||
{
|
||||
// Left side
|
||||
vx = x1 + xd * j / numplanes;
|
||||
vy = y1 + yd * j / numplanes;
|
||||
SETUP3DVERT((&horizonpts[1]), vx, vy);
|
||||
|
||||
dist = sqrtf(powf(vx - gr_viewx, 2) + powf(vy - gr_viewy, 2));
|
||||
vx = (vx - gr_viewx) * renderdist / dist + gr_viewx;
|
||||
vy = (vy - gr_viewy) * renderdist / dist + gr_viewy;
|
||||
SETUP3DVERT((&horizonpts[0]), vx, vy);
|
||||
dist = sqrtf(powf(vx - gr_viewx, 2) + powf(vy - gr_viewy, 2));
|
||||
vx = (vx - gr_viewx) * renderdist / dist + gr_viewx;
|
||||
vy = (vy - gr_viewy) * renderdist / dist + gr_viewy;
|
||||
SETUP3DVERT((&horizonpts[0]), vx, vy);
|
||||
|
||||
// Right side
|
||||
vx = x1 + xd * (j+1) / numplanes;
|
||||
vy = y1 + yd * (j+1) / numplanes;
|
||||
SETUP3DVERT((&horizonpts[2]), vx, vy);
|
||||
// Right side
|
||||
vx = x1 + xd * (j+1) / numplanes;
|
||||
vy = y1 + yd * (j+1) / numplanes;
|
||||
SETUP3DVERT((&horizonpts[2]), vx, vy);
|
||||
|
||||
dist = sqrtf(powf(vx - gr_viewx, 2) + powf(vy - gr_viewy, 2));
|
||||
vx = (vx - gr_viewx) * renderdist / dist + gr_viewx;
|
||||
vy = (vy - gr_viewy) * renderdist / dist + gr_viewy;
|
||||
SETUP3DVERT((&horizonpts[3]), vx, vy);
|
||||
dist = sqrtf(powf(vx - gr_viewx, 2) + powf(vy - gr_viewy, 2));
|
||||
vx = (vx - gr_viewx) * renderdist / dist + gr_viewx;
|
||||
vy = (vy - gr_viewy) * renderdist / dist + gr_viewy;
|
||||
SETUP3DVERT((&horizonpts[3]), vx, vy);
|
||||
|
||||
// Horizon fills
|
||||
vx = (horizonpts[0].x - gr_viewx) * farrenderdist / renderdist + gr_viewx;
|
||||
vy = (horizonpts[0].z - gr_viewy) * farrenderdist / renderdist + gr_viewy;
|
||||
SETUP3DVERT((&horizonpts[5]), vx, vy);
|
||||
horizonpts[5].y = gr_viewz;
|
||||
// Horizon fills
|
||||
vx = (horizonpts[0].x - gr_viewx) * farrenderdist / renderdist + gr_viewx;
|
||||
vy = (horizonpts[0].z - gr_viewy) * farrenderdist / renderdist + gr_viewy;
|
||||
SETUP3DVERT((&horizonpts[5]), vx, vy);
|
||||
horizonpts[5].y = gr_viewz;
|
||||
|
||||
vx = (horizonpts[3].x - gr_viewx) * farrenderdist / renderdist + gr_viewx;
|
||||
vy = (horizonpts[3].z - gr_viewy) * farrenderdist / renderdist + gr_viewy;
|
||||
SETUP3DVERT((&horizonpts[4]), vx, vy);
|
||||
vx = (horizonpts[3].x - gr_viewx) * farrenderdist / renderdist + gr_viewx;
|
||||
vy = (horizonpts[3].z - gr_viewy) * farrenderdist / renderdist + gr_viewy;
|
||||
SETUP3DVERT((&horizonpts[4]), vx, vy);
|
||||
horizonpts[4].y = gr_viewz;
|
||||
|
||||
// Draw
|
||||
HWR_ProcessPolygon(&Surf, horizonpts, 6, PolyFlags, shader, true);
|
||||
}
|
||||
// Draw
|
||||
HWR_ProcessPolygon(&Surf, horizonpts, 6, PolyFlags, shader, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1135,27 +1138,15 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum,
|
||||
{
|
||||
if (pfloor && (pfloor->flags & FF_FOG))
|
||||
{
|
||||
if (HWR_ShouldUsePaletteRendering())
|
||||
{
|
||||
lightnum = pfloor->master->frontsector->lightlevel;
|
||||
colormap = pfloor->master->frontsector->extra_colormap;
|
||||
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, v1x, v1y, v2x, v2y);
|
||||
}else{
|
||||
lightnum = HWR_CalcWallLight(pfloor->master->frontsector->lightlevel, v1x, v1y, v2x, v2y);
|
||||
colormap = pfloor->master->frontsector->extra_colormap;
|
||||
}
|
||||
lightnum = pfloor->master->frontsector->lightlevel;
|
||||
colormap = pfloor->master->frontsector->extra_colormap;
|
||||
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, v1x, v1y, v2x, v2y);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (HWR_ShouldUsePaletteRendering())
|
||||
{
|
||||
lightnum = *list[i].lightlevel;
|
||||
colormap = list[i].extra_colormap;
|
||||
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, v1x, v1y, v2x, v2y);
|
||||
}else{
|
||||
lightnum = HWR_CalcWallLight(*list[i].lightlevel, v1x, v1y, v2x, v2y);
|
||||
colormap = list[i].extra_colormap;
|
||||
}
|
||||
lightnum = *list[i].lightlevel;
|
||||
colormap = list[i].extra_colormap;
|
||||
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, v1x, v1y, v2x, v2y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1522,17 +1513,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
cliplow = (float)texturehpeg;
|
||||
cliphigh = (float)(texturehpeg + (gr_curline->flength*FRACUNIT));
|
||||
|
||||
if (HWR_ShouldUsePaletteRendering())
|
||||
{
|
||||
lightnum = gr_frontsector->lightlevel;
|
||||
colormap = gr_frontsector->extra_colormap;
|
||||
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
lightnum = HWR_CalcWallLight(gr_frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y);
|
||||
colormap = gr_frontsector->extra_colormap;
|
||||
}
|
||||
lightnum = gr_frontsector->lightlevel;
|
||||
colormap = gr_frontsector->extra_colormap;
|
||||
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y);
|
||||
|
||||
if (gr_linedef->flags & ML_TFERLINE)
|
||||
noencore = true;
|
||||
@@ -2107,20 +2090,20 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
INT32 texnum;
|
||||
line_t * newline = NULL; // Multi-Property FOF
|
||||
|
||||
if (!cv_grfofcut.value)
|
||||
{
|
||||
///TODO add slope support (fixing cutoffs, proper wall clipping) - maybe just disable highcut/lowcut if either sector or FOF has a slope
|
||||
/// to allow fun plane intersecting in OGL? But then people would abuse that and make software look bad. :C
|
||||
highcut = gr_frontsector->ceilingheight < gr_backsector->ceilingheight ? gr_frontsector->ceilingheight : gr_backsector->ceilingheight;
|
||||
lowcut = gr_frontsector->floorheight > gr_backsector->floorheight ? gr_frontsector->floorheight : gr_backsector->floorheight;
|
||||
}
|
||||
else
|
||||
if (cv_grfofcut.value)
|
||||
{
|
||||
lowcut = max(worldbottom, worldlow);
|
||||
highcut = min(worldtop, worldhigh);
|
||||
lowcutslope = max(worldbottomslope, worldlowslope);
|
||||
highcutslope = min(worldtopslope, worldhighslope);
|
||||
}
|
||||
else
|
||||
{
|
||||
///TODO add slope support (fixing cutoffs, proper wall clipping) - maybe just disable highcut/lowcut if either sector or FOF has a slope
|
||||
/// to allow fun plane intersecting in OGL? But then people would abuse that and make software look bad. :C
|
||||
highcut = gr_frontsector->ceilingheight < gr_backsector->ceilingheight ? gr_frontsector->ceilingheight : gr_backsector->ceilingheight;
|
||||
lowcut = gr_frontsector->floorheight > gr_backsector->floorheight ? gr_frontsector->floorheight : gr_backsector->floorheight;
|
||||
}
|
||||
|
||||
if (gr_backsector->ffloors)
|
||||
{
|
||||
@@ -2129,12 +2112,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERSIDES) || (rover->flags & FF_INVERTSIDES))
|
||||
continue;
|
||||
|
||||
if (!cv_grfofcut.value)
|
||||
{
|
||||
if (*rover->topheight < lowcut || *rover->bottomheight > highcut)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
if (cv_grfofcut.value)
|
||||
{
|
||||
SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight)
|
||||
SLOPEPARAMS(*rover->b_slope, low1, lowslope1, *rover->bottomheight)
|
||||
@@ -2142,6 +2120,11 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope))
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*rover->topheight < lowcut || *rover->bottomheight > highcut)
|
||||
continue;
|
||||
}
|
||||
|
||||
texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture);
|
||||
|
||||
@@ -2157,14 +2140,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
l = P_GetFFloorBottomZAt(rover, v1x, v1y);
|
||||
lS = P_GetFFloorBottomZAt(rover, v2x, v2y);
|
||||
|
||||
if (!cv_grfofcut.value)
|
||||
{
|
||||
if (!(*rover->t_slope) && !gr_frontsector->c_slope && !gr_backsector->c_slope && h > highcut)
|
||||
h = hS = highcut;
|
||||
if (!(*rover->b_slope) && !gr_frontsector->f_slope && !gr_backsector->f_slope && l < lowcut)
|
||||
l = lS = lowcut;
|
||||
}
|
||||
else
|
||||
if (cv_grfofcut.value)
|
||||
{
|
||||
// Adjust the heights so the FOF does not overlap with top and bottom textures.
|
||||
if (h >= highcut && hS >= highcutslope)
|
||||
@@ -2178,6 +2154,13 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
lS = lowcutslope;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(*rover->t_slope) && !gr_frontsector->c_slope && !gr_backsector->c_slope && h > highcut)
|
||||
h = hS = highcut;
|
||||
if (!(*rover->b_slope) && !gr_frontsector->f_slope && !gr_backsector->f_slope && l < lowcut)
|
||||
l = lS = lowcut;
|
||||
}
|
||||
|
||||
//Hurdler: HW code starts here
|
||||
//FIXME: check if peging is correct
|
||||
@@ -2253,16 +2236,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
|
||||
blendmode = PF_Fog|PF_NoTexture;
|
||||
|
||||
if (HWR_ShouldUsePaletteRendering())
|
||||
{
|
||||
lightnum = rover->master->frontsector->lightlevel;
|
||||
colormap = rover->master->frontsector->extra_colormap;
|
||||
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y);
|
||||
}else{
|
||||
lightnum = HWR_CalcWallLight(rover->master->frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y);
|
||||
colormap = rover->master->frontsector->extra_colormap;
|
||||
}
|
||||
|
||||
lightnum = rover->master->frontsector->lightlevel;
|
||||
colormap = rover->master->frontsector->extra_colormap;
|
||||
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y);
|
||||
|
||||
Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap);
|
||||
|
||||
if (gr_frontsector->numlights)
|
||||
@@ -2300,12 +2277,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERSIDES) || !(rover->flags & FF_ALLSIDES))
|
||||
continue;
|
||||
|
||||
if (!cv_grfofcut.value)
|
||||
{
|
||||
if (*rover->topheight < lowcut || *rover->bottomheight > highcut)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
if (cv_grfofcut.value)
|
||||
{
|
||||
SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight)
|
||||
SLOPEPARAMS(*rover->b_slope, low1, lowslope1, *rover->bottomheight)
|
||||
@@ -2313,7 +2285,11 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope))
|
||||
continue;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (*rover->topheight < lowcut || *rover->bottomheight > highcut)
|
||||
continue;
|
||||
}
|
||||
|
||||
texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture);
|
||||
|
||||
@@ -2329,14 +2305,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
l = P_GetFFloorBottomZAt(rover, v1x, v1y);
|
||||
lS = P_GetFFloorBottomZAt(rover, v2x, v2y);
|
||||
|
||||
if (!cv_grfofcut.value)
|
||||
{
|
||||
if (!(*rover->t_slope) && !gr_frontsector->c_slope && !gr_backsector->c_slope && h > highcut)
|
||||
h = hS = highcut;
|
||||
if (!(*rover->b_slope) && !gr_frontsector->f_slope && !gr_backsector->f_slope && l < lowcut)
|
||||
l = lS = lowcut;
|
||||
}
|
||||
else
|
||||
if (cv_grfofcut.value)
|
||||
{
|
||||
// Adjust the heights so the FOF does not overlap with top and bottom textures.
|
||||
if (h >= highcut && hS >= highcutslope)
|
||||
@@ -2350,6 +2319,13 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
lS = lowcutslope;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(*rover->t_slope) && !gr_frontsector->c_slope && !gr_backsector->c_slope && h > highcut)
|
||||
h = hS = highcut;
|
||||
if (!(*rover->b_slope) && !gr_frontsector->f_slope && !gr_backsector->f_slope && l < lowcut)
|
||||
l = lS = lowcut;
|
||||
}
|
||||
|
||||
//Hurdler: HW code starts here
|
||||
//FIXME: check if peging is correct
|
||||
@@ -2392,15 +2368,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
|
||||
blendmode = PF_Fog|PF_NoTexture;
|
||||
|
||||
if (HWR_ShouldUsePaletteRendering())
|
||||
{
|
||||
lightnum = rover->master->frontsector->lightlevel;
|
||||
colormap = rover->master->frontsector->extra_colormap;
|
||||
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y);
|
||||
}else{
|
||||
lightnum = HWR_CalcWallLight(rover->master->frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y);
|
||||
colormap = rover->master->frontsector->extra_colormap;
|
||||
}
|
||||
lightnum = rover->master->frontsector->lightlevel;
|
||||
colormap = rover->master->frontsector->extra_colormap;
|
||||
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y);
|
||||
|
||||
Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap);
|
||||
|
||||
@@ -2854,9 +2824,6 @@ static boolean HWR_CheckBBox(const fixed_t *bspcoord)
|
||||
void HWR_AddPolyObjectSegs(void)
|
||||
{
|
||||
size_t i, j;
|
||||
seg_t gr_fakeline;
|
||||
polyvertex_t pv1;
|
||||
polyvertex_t pv2;
|
||||
|
||||
// Sort through all the polyobjects
|
||||
for (i = 0; i < numpolys; ++i)
|
||||
@@ -2864,19 +2831,7 @@ void HWR_AddPolyObjectSegs(void)
|
||||
// Render the polyobject's lines
|
||||
for (j = 0; j < po_ptrs[i]->segCount; ++j)
|
||||
{
|
||||
// Copy the info of a polyobject's seg, then convert it to OpenGL floating point
|
||||
M_Memcpy(&gr_fakeline, po_ptrs[i]->segs[j], sizeof(seg_t));
|
||||
|
||||
// Now convert the line to float and add it to be rendered
|
||||
pv1.x = FIXED_TO_FLOAT(gr_fakeline.v1->x);
|
||||
pv1.y = FIXED_TO_FLOAT(gr_fakeline.v1->y);
|
||||
pv2.x = FIXED_TO_FLOAT(gr_fakeline.v2->x);
|
||||
pv2.y = FIXED_TO_FLOAT(gr_fakeline.v2->y);
|
||||
|
||||
gr_fakeline.pv1 = &pv1;
|
||||
gr_fakeline.pv2 = &pv2;
|
||||
|
||||
HWR_AddLine(&gr_fakeline);
|
||||
HWR_AddLine(po_ptrs[i]->segs[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3062,13 +3017,13 @@ void HWR_AddPolyObjectPlanes(void)
|
||||
|
||||
for (i = 0; i < numpolys; i++)
|
||||
{
|
||||
polyobjsector = po_ptrs[i]->lines[0]->backsector; // the in-level polyobject sector
|
||||
|
||||
if (!(po_ptrs[i]->flags & POF_RENDERPLANES)) // Only render planes when you should
|
||||
continue;
|
||||
|
||||
if (po_ptrs[i]->translucency >= NUMTRANSMAPS)
|
||||
continue;
|
||||
|
||||
polyobjsector = po_ptrs[i]->lines[0]->backsector; // the in-level polyobject sector
|
||||
|
||||
if (polyobjsector->floorheight <= gr_frontsector->ceilingheight
|
||||
&& polyobjsector->floorheight >= gr_frontsector->floorheight
|
||||
@@ -3230,11 +3185,11 @@ static void HWR_Subsector(size_t num)
|
||||
{
|
||||
sector_t *controlSec = §ors[rover->secnum];
|
||||
|
||||
if (controlSec->moved == true)
|
||||
{
|
||||
anyMoved = true;
|
||||
break;
|
||||
}
|
||||
if (controlSec->moved != true)
|
||||
continue;
|
||||
|
||||
anyMoved = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3635,8 +3590,11 @@ static fixed_t HWR_OpaqueFloorAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t hei
|
||||
|
||||
delta1 = z - (*rover->bottomheight + ((*rover->topheight - *rover->bottomheight)/2));
|
||||
delta2 = thingtop - (*rover->bottomheight + ((*rover->topheight - *rover->bottomheight)/2));
|
||||
if (*rover->topheight > floorz && abs(delta1) < abs(delta2))
|
||||
floorz = *rover->topheight;
|
||||
|
||||
if (!(*rover->topheight > floorz && abs(delta1) < abs(delta2)))
|
||||
continue;
|
||||
|
||||
floorz = *rover->topheight;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3647,6 +3605,7 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t
|
||||
{
|
||||
FOutVector swallVerts[4];
|
||||
FSurfaceInfo sSurf;
|
||||
FBITFIELD blendmode = 0;
|
||||
fixed_t floorheight, mobjfloor;
|
||||
pslope_t *floorslope;
|
||||
fixed_t slopez;
|
||||
@@ -3802,13 +3761,14 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t
|
||||
if (sSurf.PolyColor.s.alpha > floorheight/4)
|
||||
{
|
||||
sSurf.PolyColor.s.alpha = (UINT8)(sSurf.PolyColor.s.alpha - floorheight/4);
|
||||
|
||||
|
||||
if (HWR_UseShader())
|
||||
{
|
||||
shader = SHADER_FLOOR; // floor shader
|
||||
shader = SHADER_SHADOW;
|
||||
blendmode |= PF_ColorMapped;
|
||||
}
|
||||
|
||||
HWR_ProcessPolygon(&sSurf, swallVerts, 4, PF_Translucent|PF_Modulated, shader, false);
|
||||
HWR_ProcessPolygon(&sSurf, swallVerts, 4, blendmode|PF_Translucent|PF_Modulated, shader, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4039,13 +3999,13 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
|
||||
for (i = 1; i < sector->numlights; i++)
|
||||
{
|
||||
fixed_t h = P_GetLightZAt(§or->lightlist[i], spr->mobj->x, spr->mobj->y);
|
||||
if (h <= temp)
|
||||
{
|
||||
if (!(spr->mobj->frame & FF_FULLBRIGHT))
|
||||
lightlevel = *list[i-1].lightlevel > 255 ? 255 : *list[i-1].lightlevel;
|
||||
colormap = list[i-1].extra_colormap;
|
||||
break;
|
||||
}
|
||||
if (!(h <= temp))
|
||||
continue;
|
||||
|
||||
if (!(spr->mobj->frame & FF_FULLBRIGHT))
|
||||
lightlevel = *list[i-1].lightlevel > 255 ? 255 : *list[i-1].lightlevel;
|
||||
colormap = list[i-1].extra_colormap;
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < sector->numlights; i++)
|
||||
@@ -4575,10 +4535,7 @@ void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean
|
||||
planeinfo->isceiling = isceiling;
|
||||
planeinfo->fixedheight = fixedheight;
|
||||
|
||||
if (HWR_ShouldUsePaletteRendering())
|
||||
planeinfo->lightlevel = (planecolormap && (planecolormap->fog & 1)) ? 255 : lightlevel;
|
||||
else
|
||||
planeinfo->lightlevel = lightlevel;
|
||||
planeinfo->lightlevel = (planecolormap && (planecolormap->fog & 1)) ? 255 : lightlevel;
|
||||
|
||||
planeinfo->lumpnum = lumpnum;
|
||||
planeinfo->xsub = xsub;
|
||||
@@ -4598,10 +4555,7 @@ void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector,
|
||||
polyplaneinfo->isceiling = isceiling;
|
||||
polyplaneinfo->fixedheight = fixedheight;
|
||||
|
||||
if (HWR_ShouldUsePaletteRendering())
|
||||
polyplaneinfo->lightlevel = (planecolormap && (planecolormap->fog & 1)) ? 255 : lightlevel;
|
||||
else
|
||||
polyplaneinfo->lightlevel = lightlevel;
|
||||
polyplaneinfo->lightlevel = (planecolormap && (planecolormap->fog & 1)) ? 255 : lightlevel;
|
||||
|
||||
polyplaneinfo->lumpnum = lumpnum;
|
||||
polyplaneinfo->polysector = polysector;
|
||||
@@ -4737,35 +4691,39 @@ void HWR_DrawSprites(void)
|
||||
for (i = 0; i < gr_visspritecount; i++)
|
||||
{
|
||||
gr_vissprite_t *spr = gr_vsprorder[i];
|
||||
if (spr->precip)
|
||||
HWR_DrawPrecipitationSprite(spr);
|
||||
else
|
||||
if (spr->mobj && spr->mobj->skin && spr->mobj->sprite == SPR_PLAY)
|
||||
{
|
||||
md2_t *md2;
|
||||
if (spr->mobj->localskin)
|
||||
{
|
||||
if (spr->mobj->skinlocal)
|
||||
md2 = &md2_localplayermodels[(skin_t *)spr->mobj->localskin - localskins];
|
||||
else
|
||||
md2 = &md2_playermodels [(skin_t *)spr->mobj->localskin - skins];
|
||||
}
|
||||
else
|
||||
md2 = &md2_playermodels[(skin_t *)spr->mobj->skin - skins];
|
||||
|
||||
// 8/1/19: Only don't display player models if no default SPR_PLAY is found.
|
||||
if (!cv_grmdls.value || ((md2->notfound || md2->scale < 0.0f) && ((!cv_grfallbackplayermodel.value) || md2_models[SPR_PLAY].notfound || md2_models[SPR_PLAY].scale < 0.0f)) || spr->mobj->state == &states[S_PLAY_SIGN])
|
||||
HWR_DrawSprite(spr);
|
||||
if (spr->precip)
|
||||
{
|
||||
HWR_DrawPrecipitationSprite(spr);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (spr->mobj && spr->mobj->skin && spr->mobj->sprite == SPR_PLAY)
|
||||
{
|
||||
md2_t *md2;
|
||||
if (spr->mobj->localskin)
|
||||
{
|
||||
if (spr->mobj->skinlocal)
|
||||
md2 = &md2_localplayermodels[(skin_t *)spr->mobj->localskin - localskins];
|
||||
else
|
||||
HWR_DrawMD2(spr);
|
||||
md2 = &md2_playermodels [(skin_t *)spr->mobj->localskin - skins];
|
||||
}
|
||||
else
|
||||
md2 = &md2_playermodels[(skin_t *)spr->mobj->skin - skins];
|
||||
|
||||
// 8/1/19: Only don't display player models if no default SPR_PLAY is found.
|
||||
if (!cv_grmdls.value || ((md2->notfound || md2->scale < 0.0f) && ((!cv_grfallbackplayermodel.value) || md2_models[SPR_PLAY].notfound || md2_models[SPR_PLAY].scale < 0.0f)) || spr->mobj->state == &states[S_PLAY_SIGN])
|
||||
HWR_DrawSprite(spr);
|
||||
else
|
||||
HWR_DrawMD2(spr);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!cv_grmdls.value || md2_models[spr->mobj->sprite].notfound || md2_models[spr->mobj->sprite].scale < 0.0f)
|
||||
HWR_DrawSprite(spr);
|
||||
else
|
||||
HWR_DrawMD2(spr);
|
||||
}
|
||||
if (!cv_grmdls.value || md2_models[spr->mobj->sprite].notfound || md2_models[spr->mobj->sprite].scale < 0.0f)
|
||||
HWR_DrawSprite(spr);
|
||||
else
|
||||
HWR_DrawMD2(spr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4795,16 +4753,55 @@ void HWR_AddSprites(sector_t *sec)
|
||||
{
|
||||
// Use the smaller setting
|
||||
if (cv_drawdist.value)
|
||||
limit_dist = min(current_bsp_culling_distance, cv_drawdist.value << FRACBITS);
|
||||
limit_dist = min(current_bsp_culling_distance, (fixed_t)(cv_drawdist.value) * mapobjectscale);
|
||||
else
|
||||
limit_dist = current_bsp_culling_distance;
|
||||
}
|
||||
else
|
||||
limit_dist = cv_drawdist.value << FRACBITS;
|
||||
limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale;
|
||||
|
||||
// Handle all things in sector.
|
||||
// If a limit exists, handle things a tiny bit different.
|
||||
if (limit_dist)
|
||||
if (limit_dist == 0)
|
||||
{
|
||||
// Draw everything in sector, no checks
|
||||
for (thing = sec->thinglist; thing; thing = thing->snext)
|
||||
{
|
||||
split_drawsprite = false;
|
||||
|
||||
if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW)
|
||||
continue;
|
||||
|
||||
splitflags = thing->eflags & (MFE_DRAWONLYFORP1|MFE_DRAWONLYFORP2|MFE_DRAWONLYFORP3|MFE_DRAWONLYFORP4);
|
||||
|
||||
if (splitscreen && splitflags)
|
||||
{
|
||||
if (thing->eflags & MFE_DRAWONLYFORP1)
|
||||
if (viewssnum == 0)
|
||||
split_drawsprite = true;
|
||||
|
||||
if (thing->eflags & MFE_DRAWONLYFORP2)
|
||||
if (viewssnum == 1)
|
||||
split_drawsprite = true;
|
||||
|
||||
if (thing->eflags & MFE_DRAWONLYFORP3 && splitscreen > 1)
|
||||
if (viewssnum == 2)
|
||||
split_drawsprite = true;
|
||||
|
||||
if (thing->eflags & MFE_DRAWONLYFORP4 && splitscreen > 2)
|
||||
if (viewssnum == 3)
|
||||
split_drawsprite = true;
|
||||
}
|
||||
else
|
||||
split_drawsprite = true;
|
||||
|
||||
if (!split_drawsprite)
|
||||
continue;
|
||||
|
||||
HWR_ProjectSprite(thing);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (thing = sec->thinglist; thing; thing = thing->snext)
|
||||
{
|
||||
@@ -4847,45 +4844,6 @@ void HWR_AddSprites(sector_t *sec)
|
||||
HWR_ProjectSprite(thing);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Draw everything in sector, no checks
|
||||
for (thing = sec->thinglist; thing; thing = thing->snext)
|
||||
{
|
||||
split_drawsprite = false;
|
||||
|
||||
if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW)
|
||||
continue;
|
||||
|
||||
splitflags = thing->eflags & (MFE_DRAWONLYFORP1|MFE_DRAWONLYFORP2|MFE_DRAWONLYFORP3|MFE_DRAWONLYFORP4);
|
||||
|
||||
if (splitscreen && splitflags)
|
||||
{
|
||||
if (thing->eflags & MFE_DRAWONLYFORP1)
|
||||
if (viewssnum == 0)
|
||||
split_drawsprite = true;
|
||||
|
||||
if (thing->eflags & MFE_DRAWONLYFORP2)
|
||||
if (viewssnum == 1)
|
||||
split_drawsprite = true;
|
||||
|
||||
if (thing->eflags & MFE_DRAWONLYFORP3 && splitscreen > 1)
|
||||
if (viewssnum == 2)
|
||||
split_drawsprite = true;
|
||||
|
||||
if (thing->eflags & MFE_DRAWONLYFORP4 && splitscreen > 2)
|
||||
if (viewssnum == 3)
|
||||
split_drawsprite = true;
|
||||
}
|
||||
else
|
||||
split_drawsprite = true;
|
||||
|
||||
if (!split_drawsprite)
|
||||
continue;
|
||||
|
||||
HWR_ProjectSprite(thing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -4903,9 +4861,9 @@ static void HWR_AddPrecipitationSprites(void)
|
||||
precipmobj_t *th;
|
||||
|
||||
if (current_bsp_culling_distance)
|
||||
drawdist = min(current_bsp_culling_distance, cv_drawdist_precip.value * mapobjectscale);
|
||||
drawdist = min(current_bsp_culling_distance, (fixed_t)(cv_drawdist_precip.value) * mapobjectscale);
|
||||
else
|
||||
drawdist = cv_drawdist_precip.value * mapobjectscale;
|
||||
drawdist = (fixed_t)(cv_drawdist_precip.value) * mapobjectscale;
|
||||
|
||||
// No to infinite precipitation draw distance.
|
||||
if (drawdist == 0)
|
||||
@@ -5285,7 +5243,7 @@ void HWR_ProjectSprite(mobj_t *thing)
|
||||
vis->colormap = colormaps;
|
||||
#ifdef GLENCORE
|
||||
if (encoremap && !(thing->flags & MF_DONTENCOREMAP))
|
||||
vis->colormap += (256*32);
|
||||
vis->colormap += COLORMAP_REMAPOFFSET;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -5416,7 +5374,7 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
|
||||
|
||||
#ifdef GLENCORE
|
||||
if (encoremap && !(thing->flags & MF_DONTENCOREMAP))
|
||||
vis->colormap += (256*32);
|
||||
vis->colormap += COLORMAP_REMAPOFFSET;
|
||||
#endif
|
||||
|
||||
// set top/bottom coords
|
||||
@@ -5572,8 +5530,10 @@ void HWR_SetTransform(float fpov, player_t *player)
|
||||
|
||||
for (i = 0; i <= splitscreen; i++)
|
||||
{
|
||||
if (player == &players[displayplayers[i]])
|
||||
postprocessor = &postimgtype[i];
|
||||
if (player != &players[displayplayers[i]])
|
||||
continue;
|
||||
|
||||
postprocessor = &postimgtype[i];
|
||||
}
|
||||
|
||||
atransform.flip = false;
|
||||
@@ -5949,6 +5909,25 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
|
||||
HWR_RenderFrame(viewnumber, player, false);
|
||||
}
|
||||
|
||||
void HWR_LoadLevel(void)
|
||||
{
|
||||
// Lactozilla (December 8, 2019)
|
||||
// Level setup used to free EVERY mipmap from memory.
|
||||
// Even mipmaps that aren't related to level textures.
|
||||
// Presumably, the hardware render code used to store textures as level data.
|
||||
// Meaning, they had memory allocated and marked with the PU_LEVEL tag.
|
||||
// Level textures are only reloaded after R_LoadTextures, which is
|
||||
// when the texture list is loaded.
|
||||
|
||||
// Sal: Unfortunately, NOT freeing them causes the dreaded Color Bug.
|
||||
HWR_FreeMipmapCache();
|
||||
|
||||
HWR_CreatePlanePolygons((INT32)numnodes - 1);
|
||||
|
||||
if (HWR_ShouldUsePaletteRendering())
|
||||
HWR_SetMapPalette();
|
||||
}
|
||||
|
||||
// enable or disable palette rendering state depending on settings and availability
|
||||
// called when relevant settings change
|
||||
// shader recompilation is done in the cvar callback
|
||||
@@ -6033,6 +6012,8 @@ void HWR_AddCommands(void)
|
||||
CV_RegisterVar(&cv_grpalettedepth);
|
||||
CV_RegisterVar(&cv_grflashpal);
|
||||
|
||||
CV_RegisterVar(&cv_lightdither);
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
CV_RegisterVar(&cv_grframebuffer);
|
||||
#endif
|
||||
@@ -6140,11 +6121,11 @@ void HWR_DoPostProcessor(player_t *player)
|
||||
|
||||
for (i = splitscreen; i > 0; i--)
|
||||
{
|
||||
if (player == &players[displayplayers[i]])
|
||||
{
|
||||
type = &postimgtype[i];
|
||||
break;
|
||||
}
|
||||
if (player != &players[displayplayers[i]])
|
||||
continue;
|
||||
|
||||
type = &postimgtype[i];
|
||||
break;
|
||||
}
|
||||
|
||||
// Armageddon Blast Flash!
|
||||
@@ -6247,6 +6228,12 @@ void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum)
|
||||
lumpnum_t lumpnum;
|
||||
size_t lsize;
|
||||
|
||||
if (cv_grscreentextures.value == 0)
|
||||
{
|
||||
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); // just draw a black screen instead of flashing and crap
|
||||
return;
|
||||
}
|
||||
|
||||
if (wipenum > 99 || scrnnum > 99) // not a valid wipe number
|
||||
return; // shouldn't end up here really, the loop should've stopped running beforehand
|
||||
|
||||
@@ -6283,4 +6270,7 @@ void HWR_DrawScreenFinalTexture(INT32 width, INT32 height)
|
||||
{
|
||||
HWD.pfnDrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, width, height);
|
||||
}
|
||||
|
||||
#undef CLAMP
|
||||
|
||||
#endif // HWRENDER
|
||||
@@ -179,6 +179,7 @@ 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;
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
|
||||
md2_t md2_models[NUMSPRITES];
|
||||
md2_t md2_playermodels[MAXSKINS];
|
||||
md2_t md2_localplayermodels[MAXSKINS];
|
||||
md2_t md2_localplayermodels[MAXLOCALSKINS];
|
||||
|
||||
|
||||
/*
|
||||
@@ -494,7 +494,9 @@ void HWR_InitMD2(void)
|
||||
md2_playermodels[s].skin = -1;
|
||||
md2_playermodels[s].notfound = true;
|
||||
md2_playermodels[s].error = false;
|
||||
|
||||
}
|
||||
for (s = 0; s < MAXLOCALSKINS; s++)
|
||||
{
|
||||
md2_localplayermodels[s].scale = -1.0f;
|
||||
md2_localplayermodels[s].model = NULL;
|
||||
md2_localplayermodels[s].grpatch = NULL;
|
||||
|
||||
@@ -37,7 +37,7 @@ typedef struct
|
||||
|
||||
extern md2_t md2_models[NUMSPRITES];
|
||||
extern md2_t md2_playermodels[MAXSKINS];
|
||||
extern md2_t md2_localplayermodels[MAXSKINS];
|
||||
extern md2_t md2_localplayermodels[MAXLOCALSKINS];
|
||||
|
||||
void HWR_InitMD2(void);
|
||||
void HWR_DrawMD2(gr_vissprite_t *spr);
|
||||
|
||||
+111
-1
@@ -29,6 +29,9 @@ static struct {
|
||||
// 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},
|
||||
|
||||
@@ -79,6 +82,7 @@ static shadertarget_t gl_shadertargets[NUMSHADERTARGETS];
|
||||
#define WHITESPACE_CHARS " \t"
|
||||
|
||||
#define PALETTE_RENDERING_DEFINE "#define SRB2_PALETTE_RENDERING"
|
||||
#define LIGHT_DITHERING_DEFINE "#define SRB2_LIGHT_DITHER"
|
||||
|
||||
// Initialize shader variables and the backend's shader system. Load the base shaders.
|
||||
// Returns false if shaders cannot be used.
|
||||
@@ -279,6 +283,9 @@ static char *HWR_PreprocessShader(char *original)
|
||||
if (cv_grpaletterendering.value)
|
||||
ADD_TO_LEN(PALETTE_RENDERING_DEFINE)
|
||||
|
||||
if (cv_lightdither.value)
|
||||
ADD_TO_LEN(LIGHT_DITHERING_DEFINE)
|
||||
|
||||
#undef ADD_TO_LEN
|
||||
|
||||
#define VERSION_PART "#version "
|
||||
@@ -320,6 +327,9 @@ static char *HWR_PreprocessShader(char *original)
|
||||
if (cv_grpaletterendering.value)
|
||||
WRITE_DEFINE(PALETTE_RENDERING_DEFINE)
|
||||
|
||||
if (cv_lightdither.value)
|
||||
WRITE_DEFINE(LIGHT_DITHERING_DEFINE)
|
||||
|
||||
#undef WRITE_DEFINE
|
||||
|
||||
// Write a #line directive, so compiler errors will report line numbers from the
|
||||
@@ -422,6 +432,7 @@ 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},
|
||||
@@ -442,6 +453,101 @@ void HWR_LoadAllCustomShaders(void)
|
||||
HWR_LoadCustomShadersFromFile(i, W_FileHasFolders(wadfiles[i]));
|
||||
}
|
||||
|
||||
static const char version_directives[][14] = {
|
||||
"#version 330\n",
|
||||
"#version 150\n",
|
||||
"#version 140\n",
|
||||
"#version 130\n",
|
||||
"#version 120\n",
|
||||
"#version 110\n",
|
||||
};
|
||||
|
||||
static boolean HWR_VersionDirectiveExists(const char* source)
|
||||
{
|
||||
return strncmp(source, "#version", 8) == 0;
|
||||
}
|
||||
|
||||
static char* HWR_PrependVersionDirective(const char* source, UINT32 version_index)
|
||||
{
|
||||
const UINT32 version_len = sizeof(version_directives[version_index]) - 1;
|
||||
const UINT32 source_len = strlen(source);
|
||||
|
||||
char* result = Z_Malloc(source_len + version_len + 1, PU_STATIC, NULL);
|
||||
strcpy(result, version_directives[version_index]);
|
||||
strcpy(result + version_len, source);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void HWR_ReplaceVersionInplace(char* shader, UINT32 version_index)
|
||||
{
|
||||
shader[9] = version_directives[version_index][9];
|
||||
shader[10] = version_directives[version_index][10];
|
||||
shader[11] = version_directives[version_index][11];
|
||||
}
|
||||
|
||||
static boolean HWR_CheckVersionDirectives(const char* vert, const char* frag)
|
||||
{
|
||||
return HWR_VersionDirectiveExists(vert) && HWR_VersionDirectiveExists(frag);
|
||||
}
|
||||
|
||||
static void HWR_TryToCompileShaderWithImplicitVersion(INT32 shader_index, INT32 shaderxlat_id)
|
||||
{
|
||||
char* vert_shader = gl_shaders[shader_index].vertex;
|
||||
char* frag_shader = gl_shaders[shader_index].fragment;
|
||||
|
||||
boolean vert_shader_version_exists = HWR_VersionDirectiveExists(vert_shader);
|
||||
boolean frag_shader_version_exists = HWR_VersionDirectiveExists(frag_shader);
|
||||
|
||||
if(!vert_shader_version_exists) {
|
||||
CONS_Alert(CONS_WARNING, "HWR_LoadCustomShadersFromFile: vertex shader '%s' is missing a #version directive\n", HWR_GetShaderName(shaderxlat_id));
|
||||
}
|
||||
|
||||
if(!frag_shader_version_exists) {
|
||||
CONS_Alert(CONS_WARNING, "HWR_LoadCustomShadersFromFile: fragment shader '%s' is missing a #version directive\n", HWR_GetShaderName(shaderxlat_id));
|
||||
}
|
||||
|
||||
// try to compile as is
|
||||
HWR_CompileShader(shader_index);
|
||||
if (gl_shaders[shader_index].compiled)
|
||||
return;
|
||||
|
||||
// try each version directive
|
||||
for(UINT32 i = 0; i < sizeof(version_directives) / sizeof(version_directives[0]); ++i) {
|
||||
CONS_Alert(CONS_NOTICE, "HWR_TryToCompileShaderWithImplicitVersion: Trying %s\n", version_directives[i]);
|
||||
|
||||
if(!vert_shader_version_exists) {
|
||||
// first time reallocation would have to be made
|
||||
|
||||
if(i == 0) {
|
||||
void* old = (void*)gl_shaders[shader_index].vertex;
|
||||
vert_shader = gl_shaders[shader_index].vertex = HWR_PrependVersionDirective(vert_shader, i);
|
||||
Z_Free(old);
|
||||
} else {
|
||||
HWR_ReplaceVersionInplace(vert_shader, i);
|
||||
}
|
||||
}
|
||||
|
||||
if(!frag_shader_version_exists) {
|
||||
if(i == 0) {
|
||||
void* old = (void*)gl_shaders[shader_index].fragment;
|
||||
frag_shader = gl_shaders[shader_index].fragment = HWR_PrependVersionDirective(frag_shader, i);
|
||||
Z_Free(old);
|
||||
} else {
|
||||
HWR_ReplaceVersionInplace(frag_shader, i);
|
||||
}
|
||||
}
|
||||
|
||||
HWR_CompileShader(shader_index);
|
||||
if (gl_shaders[shader_index].compiled) {
|
||||
CONS_Alert(CONS_NOTICE, "HWR_TryToCompileShaderWithImplicitVersion: Compiled with %s\n",
|
||||
version_directives[i]);
|
||||
CONS_Alert(CONS_WARNING, "Implicit GLSL version is used. Correct behavior is not guaranteed\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3)
|
||||
{
|
||||
UINT16 lump;
|
||||
@@ -604,7 +710,11 @@ skip_field:
|
||||
gl_shaders[shader_index].fragment = Z_StrDup(gl_shadersources[i].fragment);
|
||||
if (!gl_shaders[shader_index].vertex)
|
||||
gl_shaders[shader_index].vertex = Z_StrDup(gl_shadersources[i].vertex);
|
||||
HWR_CompileShader(shader_index);
|
||||
if(!HWR_CheckVersionDirectives(gl_shaders[shader_index].vertex, gl_shaders[shader_index].fragment)) {
|
||||
HWR_TryToCompileShaderWithImplicitVersion(shader_index, i);
|
||||
} else {
|
||||
HWR_CompileShader(shader_index);
|
||||
}
|
||||
if (!gl_shaders[shader_index].compiled)
|
||||
CONS_Alert(CONS_ERROR, "HWR_LoadCustomShadersFromFile: A compilation error occured for the %s shader in file %s. See the console messages above for more information.\n", shaderxlat[i].type, wadfiles[wadnum]->filename);
|
||||
}
|
||||
|
||||
@@ -51,15 +51,49 @@
|
||||
//
|
||||
|
||||
// Include GLSL_FLOOR_FUDGES or GLSL_WALL_FUDGES or define the fudges in shaders that use this macro.
|
||||
#define GLSL_DOOM_COLORMAP_DITHER \
|
||||
"float baseValue = max(startmap * STARTMAP_FUDGE - scale * 0.5 * SCALE_FUDGE, cap);\n" \
|
||||
"float halfResolutionx = scr_resolution.x;\n" \
|
||||
"float halfResolutiony = scr_resolution.y;\n" \
|
||||
"if (scr_resolution.x > 1280.0) {\n" \
|
||||
"halfResolutionx = scr_resolution.x * 0.5;\n" \
|
||||
"}\n" \
|
||||
"if (scr_resolution.y > 720.0) {\n" \
|
||||
"halfResolutiony = scr_resolution.y * 0.5;\n" \
|
||||
"}\n" \
|
||||
"vec2 normalizedPosition = position * vec2(halfResolutionx / scr_resolution.x, halfResolutiony / scr_resolution.y);\n" \
|
||||
"int x = int(mod(normalizedPosition.x, 4.0));\n" \
|
||||
"int y = int(mod(normalizedPosition.y, 4.0));\n" \
|
||||
"float bayerMatrix[4*4] = float[4*4](\n" \
|
||||
"0.0, 8.0, 2.0, 10.0,\n" \
|
||||
"12.0, 4.0, 14.0, 6.0,\n" \
|
||||
"3.0, 11.0, 1.0, 9.0,\n" \
|
||||
"15.0, 7.0, 13.0, 5.0\n" \
|
||||
");\n" \
|
||||
"#ifdef SRB2_PALETTE_RENDERING\n" \
|
||||
"float threshold = bayerMatrix[y*4 + x] / 12.0;\n" \
|
||||
"#else\n" \
|
||||
"float threshold = bayerMatrix[y*4 + x] / 16.0;\n" \
|
||||
"#endif\n" \
|
||||
"return baseValue + threshold - 0.5 / 16.0;\n" \
|
||||
|
||||
#define GLSL_DOOM_COLORMAP_NODITHER \
|
||||
"return max(startmap * STARTMAP_FUDGE - scale * 0.5 * SCALE_FUDGE, cap);\n" \
|
||||
|
||||
#define GLSL_DOOM_COLORMAP \
|
||||
"float R_DoomColormap(float light, float z)\n" \
|
||||
"uniform vec2 scr_resolution;\n" \
|
||||
"float R_DoomColormap(float light, float z, vec2 position)\n" \
|
||||
"{\n" \
|
||||
"float lightnum = clamp(light / 17.0, 0.0, 15.0);\n" \
|
||||
"float lightz = clamp(z / 16.0, 0.0, 127.0);\n" \
|
||||
"float startmap = (15.0 - lightnum) * 4.0;\n" \
|
||||
"float scale = 160.0 / (lightz + 1.0);\n" \
|
||||
"float cap = (155.0 - light) * 0.26;\n" \
|
||||
"return max(startmap * STARTMAP_FUDGE - scale * 0.5 * SCALE_FUDGE, cap);\n" \
|
||||
"#ifdef SRB2_LIGHT_DITHER\n" \
|
||||
GLSL_DOOM_COLORMAP_DITHER \
|
||||
"#else\n" \
|
||||
GLSL_DOOM_COLORMAP_NODITHER \
|
||||
"#endif\n" \
|
||||
"}\n"
|
||||
// lighting cap adjustment:
|
||||
// first num (155.0), increase to make it start to go dark sooner
|
||||
@@ -69,7 +103,7 @@
|
||||
"float R_DoomLightingEquation(float light)\n" \
|
||||
"{\n" \
|
||||
"float z = gl_FragCoord.z / gl_FragCoord.w;\n" \
|
||||
"float colormap = floor(R_DoomColormap(light, z)) + 0.5;\n" \
|
||||
"float colormap = floor(R_DoomColormap(light, z, gl_FragCoord.xy)) + 0.5;\n" \
|
||||
"return clamp(colormap, 0.0, 31.0) / 32.0;\n" \
|
||||
"}\n"
|
||||
|
||||
@@ -95,7 +129,7 @@
|
||||
#define GLSL_PALETTE_RENDERING \
|
||||
"float tex_pal_idx = texture3D(palette_lookup_tex, vec3((texel * 63.0 + 0.5) / 64.0))[0] * 255.0;\n" \
|
||||
"float z = gl_FragCoord.z / gl_FragCoord.w;\n" \
|
||||
"float light_y = clamp(floor(R_DoomColormap(lighting, z)), 0.0, 31.0);\n" \
|
||||
"float light_y = clamp(floor(R_DoomColormap(lighting, z, gl_FragCoord.xy)), 0.0, 31.0);\n" \
|
||||
"vec2 lighttable_coord = vec2((tex_pal_idx + 0.5) / 256.0, (light_y + 0.5) / 32.0);\n" \
|
||||
"vec4 final_color = texture2D(lighttable_tex, lighttable_coord);\n" \
|
||||
"final_color.a = texel.a * poly_color.a;\n" \
|
||||
@@ -133,13 +167,35 @@
|
||||
"gl_FragColor = final_color;\n" \
|
||||
"}\n" \
|
||||
"#endif\0"
|
||||
|
||||
#define GLSL_SOFTWARE_FRAGMENT_SHADER_NOPAL \
|
||||
"uniform sampler2D tex;\n" \
|
||||
"uniform vec4 poly_color;\n" \
|
||||
"uniform vec4 tint_color;\n" \
|
||||
"uniform vec4 fade_color;\n" \
|
||||
"uniform float lighting;\n" \
|
||||
"uniform float fade_start;\n" \
|
||||
"uniform float fade_end;\n" \
|
||||
GLSL_DOOM_COLORMAP \
|
||||
GLSL_DOOM_LIGHT_EQUATION \
|
||||
"void main(void) {\n" \
|
||||
"vec4 texel = texture2D(tex, gl_TexCoord[0].st);\n" \
|
||||
"vec4 base_color = texel * poly_color;\n" \
|
||||
"vec4 final_color = base_color;\n" \
|
||||
GLSL_SOFTWARE_TINT_EQUATION \
|
||||
GLSL_SOFTWARE_FADE_EQUATION \
|
||||
"final_color.a = texel.a * poly_color.a;\n" \
|
||||
"gl_FragColor = final_color;\n" \
|
||||
"}\n" \
|
||||
|
||||
// hand tuned adjustments for light level calculation
|
||||
#define GLSL_FLOOR_FUDGES \
|
||||
"#version 120\n" \
|
||||
"#define STARTMAP_FUDGE 1.06\n" \
|
||||
"#define SCALE_FUDGE 1.15\n"
|
||||
|
||||
#define GLSL_WALL_FUDGES \
|
||||
"#version 120\n" \
|
||||
"#define STARTMAP_FUDGE 1.05\n" \
|
||||
"#define SCALE_FUDGE 2.2\n"
|
||||
|
||||
@@ -150,6 +206,10 @@
|
||||
#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
|
||||
|
||||
@@ -608,6 +608,7 @@ typedef void (APIENTRY *PFNglDeleteProgram) (GLuint);
|
||||
typedef void (APIENTRY *PFNglAttachShader) (GLuint, GLuint);
|
||||
typedef void (APIENTRY *PFNglLinkProgram) (GLuint);
|
||||
typedef void (APIENTRY *PFNglGetProgramiv) (GLuint, GLenum, GLint*);
|
||||
typedef void (APIENTRY *PFNglGetProgramInfoLog) (GLuint, GLsizei, GLsizei*, GLchar*);
|
||||
typedef void (APIENTRY *PFNglUseProgram) (GLuint);
|
||||
typedef void (APIENTRY *PFNglUniform1i) (GLint, GLint);
|
||||
typedef void (APIENTRY *PFNglUniform1f) (GLint, GLfloat);
|
||||
@@ -630,6 +631,7 @@ static PFNglDeleteProgram pglDeleteProgram;
|
||||
static PFNglAttachShader pglAttachShader;
|
||||
static PFNglLinkProgram pglLinkProgram;
|
||||
static PFNglGetProgramiv pglGetProgramiv;
|
||||
static PFNglGetProgramInfoLog pglGetProgramInfoLog;
|
||||
static PFNglUseProgram pglUseProgram;
|
||||
static PFNglUniform1i pglUniform1i;
|
||||
static PFNglUniform1f pglUniform1f;
|
||||
@@ -669,6 +671,8 @@ typedef enum
|
||||
|
||||
// misc.
|
||||
gluniform_leveltime,
|
||||
|
||||
gluniform_scr_resolution,
|
||||
|
||||
gluniform_max,
|
||||
} gluniform_t;
|
||||
@@ -735,6 +739,7 @@ void SetupGLFunc4(void)
|
||||
pglAttachShader = GetGLFunc("glAttachShader");
|
||||
pglLinkProgram = GetGLFunc("glLinkProgram");
|
||||
pglGetProgramiv = GetGLFunc("glGetProgramiv");
|
||||
pglGetProgramInfoLog = GetGLFunc("glGetProgramInfoLog");
|
||||
pglUseProgram = GetGLFunc("glUseProgram");
|
||||
pglUniform1i = GetGLFunc("glUniform1i");
|
||||
pglUniform1f = GetGLFunc("glUniform1f");
|
||||
@@ -1836,6 +1841,8 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF
|
||||
|
||||
UNIFORM_1(shader->uniforms[gluniform_leveltime], ((float)shader_leveltime) / TICRATE, pglUniform1f);
|
||||
|
||||
UNIFORM_2(shader->uniforms[gluniform_scr_resolution], vid.width, vid.height, pglUniform2f);
|
||||
|
||||
#undef UNIFORM_1
|
||||
#undef UNIFORM_2
|
||||
#undef UNIFORM_3
|
||||
@@ -1850,6 +1857,7 @@ static boolean Shader_CompileProgram(gl_shader_t *shader, GLint i)
|
||||
GLint result;
|
||||
const GLchar *vert_shader = shader->vertex_shader;
|
||||
const GLchar *frag_shader = shader->fragment_shader;
|
||||
GLchar info_log[512];
|
||||
|
||||
if (shader->program)
|
||||
pglDeleteProgram(shader->program);
|
||||
@@ -1879,7 +1887,10 @@ static boolean Shader_CompileProgram(gl_shader_t *shader, GLint i)
|
||||
pglGetShaderiv(gl_vertShader, GL_COMPILE_STATUS, &result);
|
||||
if (result == GL_FALSE)
|
||||
{
|
||||
GL_MSG_Error("Error compiling vertex shader", gl_vertShader, i);
|
||||
pglGetShaderInfoLog(gl_vertShader, 512, NULL, info_log);
|
||||
|
||||
GL_MSG_Error("Error compiling vertex shader: %s\n", info_log);
|
||||
|
||||
pglDeleteShader(gl_vertShader);
|
||||
return false;
|
||||
}
|
||||
@@ -1906,7 +1917,9 @@ static boolean Shader_CompileProgram(gl_shader_t *shader, GLint i)
|
||||
pglGetShaderiv(gl_fragShader, GL_COMPILE_STATUS, &result);
|
||||
if (result == GL_FALSE)
|
||||
{
|
||||
GL_MSG_Error("Error compiling fragment shader", gl_fragShader, i);
|
||||
pglGetShaderInfoLog(gl_fragShader, 512, NULL, info_log);
|
||||
|
||||
GL_MSG_Error("Error compiling fragment shader: %s\n", info_log);
|
||||
pglDeleteShader(gl_vertShader);
|
||||
pglDeleteShader(gl_fragShader);
|
||||
return false;
|
||||
@@ -1932,7 +1945,8 @@ static boolean Shader_CompileProgram(gl_shader_t *shader, GLint i)
|
||||
// couldn't link?
|
||||
if (result != GL_TRUE)
|
||||
{
|
||||
GL_MSG_Error("Shader_CompileProgram: Error linking shader program %s\n", HWR_GetShaderName(i));
|
||||
pglGetProgramInfoLog(shader->program, 512, NULL, info_log);
|
||||
GL_MSG_Error("Shader_CompileProgram: Error linking shader program %s: %s\n", HWR_GetShaderName(i), info_log);
|
||||
pglDeleteProgram(shader->program);
|
||||
return false;
|
||||
}
|
||||
@@ -1953,6 +1967,8 @@ static boolean Shader_CompileProgram(gl_shader_t *shader, GLint i)
|
||||
shader->uniforms[gluniform_palette_lookup_tex] = GETUNI("palette_lookup_tex");
|
||||
shader->uniforms[gluniform_lighttable_tex] = GETUNI("lighttable_tex");
|
||||
|
||||
shader->uniforms[gluniform_scr_resolution] = GETUNI("scr_resolution");
|
||||
|
||||
// misc.
|
||||
shader->uniforms[gluniform_leveltime] = GETUNI("leveltime");
|
||||
#undef GETUNI
|
||||
@@ -2960,7 +2976,7 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform)
|
||||
if (shearing)
|
||||
{
|
||||
float dy = FIXED_TO_FLOAT(AIMINGTODY((stransform->viewaiming)) * 2)* ((float)vid.width / vid.height) / ((float)BASEVIDWIDTH / BASEVIDHEIGHT); //screen_width/BASEVIDWIDTH;
|
||||
if (stransform->flip)
|
||||
if (stransform->flip || stransform->mirrorflip)
|
||||
dy *= -1.0f;
|
||||
pglTranslatef(0.0f, -dy/BASEVIDHEIGHT, 0.0f);
|
||||
}
|
||||
|
||||
+45
-11
@@ -580,27 +580,59 @@ static luaL_Reg lib[] = {
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
enum cvar_e
|
||||
{
|
||||
cvar_name,
|
||||
cvar_defaultvalue,
|
||||
cvar_flags,
|
||||
cvar_value,
|
||||
cvar_string,
|
||||
cvar_changed,
|
||||
};
|
||||
|
||||
static const char *const cvar_opt[] = {
|
||||
"name",
|
||||
"defaultvalue",
|
||||
"flags",
|
||||
"value",
|
||||
"string",
|
||||
"changed",
|
||||
NULL,
|
||||
};
|
||||
|
||||
static int cvar_fields_ref = LUA_NOREF;
|
||||
|
||||
static int cvar_get(lua_State *L)
|
||||
{
|
||||
consvar_t *cvar = (consvar_t *)luaL_checkudata(L, 1, META_CVAR);
|
||||
const char *field = luaL_checkstring(L, 2);
|
||||
enum cvar_e field = Lua_optoption(L, 2, -1, cvar_fields_ref);
|
||||
|
||||
if(fastcmp(field,"name"))
|
||||
switch (field)
|
||||
{
|
||||
case cvar_name:
|
||||
lua_pushstring(L, cvar->name);
|
||||
else if(fastcmp(field,"defaultvalue"))
|
||||
break;
|
||||
case cvar_defaultvalue:
|
||||
lua_pushstring(L, cvar->defaultvalue);
|
||||
else if(fastcmp(field,"flags"))
|
||||
break;
|
||||
case cvar_flags:
|
||||
lua_pushinteger(L, cvar->flags);
|
||||
else if(fastcmp(field,"value"))
|
||||
break;
|
||||
case cvar_value:
|
||||
lua_pushinteger(L, cvar->value);
|
||||
else if(fastcmp(field,"string"))
|
||||
break;
|
||||
case cvar_string:
|
||||
lua_pushstring(L, cvar->string);
|
||||
else if(fastcmp(field,"changed"))
|
||||
break;
|
||||
case cvar_changed:
|
||||
lua_pushboolean(L, cvar->changed);
|
||||
else if (devparm)
|
||||
return luaL_error(L, LUA_QL("consvar_t") " has no field named " LUA_QS, field);
|
||||
else
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
if (devparm)
|
||||
return luaL_error(L, LUA_QL("consvar_t") " has no field named " LUA_QS, field);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -612,6 +644,8 @@ int LUA_ConsoleLib(lua_State *L)
|
||||
lua_setfield(L, -2, "__index");
|
||||
lua_pop(L,1);
|
||||
|
||||
cvar_fields_ref = Lua_CreateFieldTable(L, cvar_opt);
|
||||
|
||||
// Set empty registry tables
|
||||
lua_newtable(L);
|
||||
lua_setfield(L, LUA_REGISTRYINDEX, "COM_Command");
|
||||
|
||||
+271
-152
File diff suppressed because it is too large.
Load diff
+7
-1
@@ -42,9 +42,15 @@ enum hud {
|
||||
|
||||
extern boolean hud_running;
|
||||
|
||||
extern boolean hud_interpolate; // interpolation enabled
|
||||
extern UINT8 hud_interptag; // current tag
|
||||
extern UINT32 hud_interpcounter; // number of HUD hooks ran
|
||||
extern boolean hud_interpstring; // string mode
|
||||
extern boolean hud_interplatch; // string mode was toggled
|
||||
|
||||
boolean LUA_HudEnabled(enum hud option);
|
||||
|
||||
void LUAh_GameHUD(player_t *stplyr, huddrawlist_h list);
|
||||
void LUAh_GameHUD(huddrawlist_h list);
|
||||
void LUAh_ScoresHUD(huddrawlist_h list);
|
||||
void LUAh_IntermissionHUD(huddrawlist_h list);
|
||||
void LUAh_VoteHUD(huddrawlist_h list);
|
||||
|
||||
+70
-26
@@ -32,6 +32,12 @@
|
||||
#define HUDONLY if (!hud_running) return luaL_error(L, "HUD rendering code should not be called outside of rendering hooks!");
|
||||
|
||||
boolean hud_running = false;
|
||||
|
||||
boolean hud_interpolate = false;
|
||||
UINT8 hud_interptag = 0;
|
||||
UINT32 hud_interpcounter = 0;
|
||||
boolean hud_interpstring = false;
|
||||
boolean hud_interplatch = false;
|
||||
static UINT8 hud_enabled[(hud_MAX/8)+1];
|
||||
|
||||
static UINT8 hudAvailable; // hud hooks field
|
||||
@@ -100,6 +106,8 @@ static const char *const hudhook_opt[] = {
|
||||
"vote",
|
||||
NULL};
|
||||
|
||||
static int patch_fields_ref = LUA_NOREF;
|
||||
|
||||
// alignment types for v.drawString
|
||||
enum align {
|
||||
align_left = 0,
|
||||
@@ -223,6 +231,8 @@ static const char *const hud_drawinfo_options[] = {
|
||||
"minimap",
|
||||
NULL};
|
||||
|
||||
static int camera_fields_ref = LUA_NOREF;
|
||||
|
||||
static int lib_getHudInfo(lua_State *L)
|
||||
{
|
||||
UINT32 i;
|
||||
@@ -292,7 +302,7 @@ static int colormap_get(lua_State *L)
|
||||
static int patch_get(lua_State *L)
|
||||
{
|
||||
patch_t *patch = *((patch_t **)luaL_checkudata(L, 1, META_PATCH));
|
||||
enum patch field = luaL_checkoption(L, 2, NULL, patch_opt);
|
||||
enum patch field = Lua_optoption(L, 2, -1, patch_fields_ref);
|
||||
|
||||
// patches are CURRENTLY always valid, expected to be cached with PU_STATIC
|
||||
// this may change in the future, so patch.valid still exists
|
||||
@@ -327,7 +337,7 @@ static int patch_set(lua_State *L)
|
||||
static int camera_get(lua_State *L)
|
||||
{
|
||||
camera_t *cam = *((camera_t **)luaL_checkudata(L, 1, META_CAMERA));
|
||||
enum cameraf field = luaL_checkoption(L, 2, NULL, camera_opt);
|
||||
enum cameraf field = Lua_optoption(L, 2, -1, camera_fields_ref);
|
||||
|
||||
// cameras should always be valid unless I'm a nutter
|
||||
I_Assert(cam != NULL);
|
||||
@@ -1178,6 +1188,41 @@ static int libd_getDrawInfo(lua_State *L)
|
||||
return 3;
|
||||
}
|
||||
|
||||
static int libd_interpolate(lua_State *L)
|
||||
{
|
||||
HUDONLY
|
||||
|
||||
// do type checking even if interpolation is disabled
|
||||
boolean newinterpolate;
|
||||
UINT8 newtag;
|
||||
|
||||
if (lua_isnumber(L, 1))
|
||||
{
|
||||
newinterpolate = true;
|
||||
newtag = luaL_checkinteger(L, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
newinterpolate = luaL_checkboolean(L, 1);
|
||||
newtag = 0;
|
||||
}
|
||||
|
||||
if (!cv_uncappedhud.value)
|
||||
return 0;
|
||||
|
||||
hud_interpolate = newinterpolate;
|
||||
hud_interptag = newtag;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int libd_interpLatch(lua_State *L)
|
||||
{
|
||||
HUDONLY
|
||||
hud_interpstring = hud_interplatch = luaL_checkboolean(L, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static luaL_Reg lib_draw[] = {
|
||||
{"patchExists", libd_patchExists},
|
||||
{"cachePatch", libd_cachePatch},
|
||||
@@ -1205,6 +1250,8 @@ static luaL_Reg lib_draw[] = {
|
||||
{"getDrawInfo", libd_getDrawInfo},
|
||||
{"getHudColor", libd_getHudColor},
|
||||
{"useColorHud", libd_useColorHud},
|
||||
{"interpolate", libd_interpolate},
|
||||
{"interpLatch", libd_interpLatch},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
@@ -1396,11 +1443,15 @@ int LUA_HudLib(lua_State *L)
|
||||
lua_setfield(L, -2, "__newindex");
|
||||
lua_pop(L,1);
|
||||
|
||||
patch_fields_ref = Lua_CreateFieldTable(L, patch_opt);
|
||||
|
||||
luaL_newmetatable(L, META_CAMERA);
|
||||
lua_pushcfunction(L, camera_get);
|
||||
lua_setfield(L, -2, "__index");
|
||||
lua_pop(L,1);
|
||||
|
||||
camera_fields_ref = Lua_CreateFieldTable(L, camera_opt);
|
||||
|
||||
luaL_register(L, "hud", lib_hud);
|
||||
return 0;
|
||||
}
|
||||
@@ -1413,7 +1464,7 @@ boolean LUA_HudEnabled(enum hud option)
|
||||
}
|
||||
|
||||
// Hook for HUD rendering
|
||||
void LUAh_GameHUD(player_t *stplayr, huddrawlist_h list)
|
||||
void LUAh_GameHUD(huddrawlist_h list)
|
||||
{
|
||||
if (!gL || !(hudAvailable & (1<<hudhook_game)))
|
||||
return;
|
||||
@@ -1434,33 +1485,17 @@ void LUAh_GameHUD(player_t *stplayr, huddrawlist_h list)
|
||||
lua_rawgeti(gL, -2, 1); // HUD[1] = lib_draw
|
||||
I_Assert(lua_istable(gL, -1));
|
||||
lua_remove(gL, -3); // pop HUD
|
||||
LUA_PushUserdata(gL, stplayr, META_PLAYER);
|
||||
|
||||
if (splitscreen > 2 && stplayr == &players[displayplayers[3]])
|
||||
{
|
||||
LUA_PushUserdata(gL, &camera[3], META_CAMERA);
|
||||
camnum = 4;
|
||||
}
|
||||
else if (splitscreen > 1 && stplayr == &players[displayplayers[2]])
|
||||
{
|
||||
LUA_PushUserdata(gL, &camera[2], META_CAMERA);
|
||||
camnum = 3;
|
||||
}
|
||||
else if (splitscreen && stplayr == &players[displayplayers[1]])
|
||||
{
|
||||
LUA_PushUserdata(gL, &camera[1], META_CAMERA);
|
||||
camnum = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
LUA_PushUserdata(gL, &camera[0], META_CAMERA);
|
||||
camnum = 1;
|
||||
}
|
||||
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); // stplayr
|
||||
lua_pushvalue(gL, -5); // stplyr
|
||||
lua_pushvalue(gL, -5); // camera
|
||||
LUA_Call(gL, 3, 0, 1);
|
||||
}
|
||||
@@ -1493,7 +1528,10 @@ void LUAh_ScoresHUD(huddrawlist_h list)
|
||||
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);
|
||||
}
|
||||
@@ -1526,7 +1564,10 @@ void LUAh_IntermissionHUD(huddrawlist_h list)
|
||||
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);
|
||||
}
|
||||
@@ -1559,7 +1600,10 @@ void LUAh_VoteHUD(huddrawlist_h list)
|
||||
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);
|
||||
}
|
||||
|
||||
+287
-52
@@ -11,11 +11,16 @@
|
||||
/// \brief a data structure for managing cached drawlists for the Lua hud lib
|
||||
|
||||
#include "lua_hudlib_drawlist.h"
|
||||
#include "lua_hud.h"
|
||||
#include "blua/lstate.h" // shhhhhh
|
||||
#include "lua_libs.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "v_video.h"
|
||||
#include "z_zone.h"
|
||||
#include "r_main.h"
|
||||
#include "r_fps.h"
|
||||
|
||||
enum drawitem_e {
|
||||
DI_Draw = 0,
|
||||
@@ -34,37 +39,45 @@ enum drawitem_e {
|
||||
|
||||
// A single draw item with all possible arguments needed for a draw call.
|
||||
typedef struct drawitem_s {
|
||||
UINT64 id;
|
||||
enum drawitem_e type;
|
||||
fixed_t x;
|
||||
fixed_t y;
|
||||
fixed_t w;
|
||||
fixed_t h;
|
||||
INT32 c;
|
||||
fixed_t scale;
|
||||
fixed_t hscale;
|
||||
fixed_t vscale;
|
||||
patch_t *patch;
|
||||
INT32 flags;
|
||||
UINT16 basecolor;
|
||||
UINT16 outlinecolor;
|
||||
union {
|
||||
INT32 flags;
|
||||
INT32 c;
|
||||
};
|
||||
|
||||
union {
|
||||
fixed_t scale; // drawScaled
|
||||
fixed_t hscale; // drawStretched
|
||||
fixed_t w; // drawFill
|
||||
INT32 align; // drawString
|
||||
INT32 num; // drawNum, drawPaddedNum, drawPingNum
|
||||
UINT16 color; // fadeScreen
|
||||
};
|
||||
union {
|
||||
fixed_t vscale; // drawStretched
|
||||
fixed_t h; // drawFill
|
||||
INT32 digits; // drawPaddedNum
|
||||
UINT8 strength; // fadeScreen
|
||||
};
|
||||
|
||||
// pointers (and size_t's) last, for potentially better packing
|
||||
union {
|
||||
patch_t *patch;
|
||||
size_t stroffset; // offset into strbuf to get str
|
||||
};
|
||||
const UINT8 *colormap;
|
||||
UINT8 *basecolormap;
|
||||
UINT8 *outlinecolormap;
|
||||
fixed_t sx;
|
||||
fixed_t sy;
|
||||
INT32 num;
|
||||
INT32 digits;
|
||||
size_t stroffset; // offset into strbuf to get str
|
||||
UINT16 color;
|
||||
UINT8 strength;
|
||||
INT32 align;
|
||||
} drawitem_t;
|
||||
|
||||
// The internal structure of a drawlist.
|
||||
struct huddrawlist_s {
|
||||
drawitem_t *items;
|
||||
size_t items_capacity;
|
||||
size_t items_len;
|
||||
drawitem_t *olditems;
|
||||
size_t olditems_len;
|
||||
size_t capacity;
|
||||
char *strbuf;
|
||||
size_t strbuf_capacity;
|
||||
size_t strbuf_len;
|
||||
@@ -88,8 +101,10 @@ huddrawlist_h LUA_HUD_CreateDrawList(void)
|
||||
|
||||
drawlist = (huddrawlist_h) Z_Calloc(sizeof(struct huddrawlist_s), PU_STATIC, NULL);
|
||||
drawlist->items = NULL;
|
||||
drawlist->items_capacity = 0;
|
||||
drawlist->items_len = 0;
|
||||
drawlist->olditems = NULL;
|
||||
drawlist->olditems_len = 0;
|
||||
drawlist->capacity = 0;
|
||||
drawlist->strbuf = NULL;
|
||||
drawlist->strbuf_capacity = 0;
|
||||
drawlist->strbuf_len = 0;
|
||||
@@ -99,15 +114,14 @@ huddrawlist_h LUA_HUD_CreateDrawList(void)
|
||||
|
||||
void LUA_HUD_ClearDrawList(huddrawlist_h list)
|
||||
{
|
||||
// swap the old and new lists
|
||||
void *tmp = list->olditems;
|
||||
list->olditems = list->items;
|
||||
list->items = tmp;
|
||||
|
||||
// rather than deallocate, we'll just save the existing allocation and empty
|
||||
// it out for reuse
|
||||
|
||||
// this memset probably isn't necessary
|
||||
if (list->items)
|
||||
{
|
||||
memset(list->items, 0, sizeof(drawitem_t) * list->items_capacity);
|
||||
}
|
||||
|
||||
list->olditems_len = list->items_len;
|
||||
list->items_len = 0;
|
||||
|
||||
if (list->strbuf)
|
||||
@@ -125,6 +139,10 @@ void LUA_HUD_DestroyDrawList(huddrawlist_h list)
|
||||
{
|
||||
Z_Free(list->items);
|
||||
}
|
||||
if (list->olditems)
|
||||
{
|
||||
Z_Free(list->olditems);
|
||||
}
|
||||
if (list->strbuf)
|
||||
{
|
||||
Z_Free(list->strbuf);
|
||||
@@ -143,11 +161,11 @@ boolean LUA_HUD_IsDrawListValid(huddrawlist_h list)
|
||||
static size_t AllocateDrawItem(huddrawlist_h list)
|
||||
{
|
||||
if (!list) I_Error("can't allocate draw item: invalid list");
|
||||
if (list->items_capacity <= list->items_len + 1)
|
||||
if (list->capacity <= list->items_len)
|
||||
{
|
||||
if (list->items_capacity == 0) list->items_capacity = 128;
|
||||
else list->items_capacity *= 2;
|
||||
list->items = (drawitem_t *) Z_Realloc(list->items, sizeof(struct drawitem_s) * list->items_capacity, PU_STATIC, NULL);
|
||||
list->capacity = list->capacity == 0 ? 128 : list->capacity * 2;
|
||||
list->items = Z_Realloc(list->items, sizeof(struct drawitem_s) * list->capacity, PU_STATIC, NULL);
|
||||
list->olditems = Z_Realloc(list->olditems, sizeof(struct drawitem_s) * list->capacity, PU_STATIC, NULL);
|
||||
}
|
||||
|
||||
return list->items_len++;
|
||||
@@ -178,6 +196,149 @@ static size_t CopyString(huddrawlist_h list, const char* str)
|
||||
}
|
||||
}
|
||||
|
||||
static void CalcStringCoords(drawitem_t *item, const char *string)
|
||||
{
|
||||
if (!(item->flags & V_NOSCALESTART) && cv_uncappedhud.value)
|
||||
{
|
||||
INT32 dupx = vid.dupx;
|
||||
INT32 dupy = vid.dupy;
|
||||
|
||||
item->flags |= V_NOSCALESTART;
|
||||
|
||||
if (item->flags & V_SCALEPATCHMASK) switch ((item->flags & V_SCALEPATCHMASK) >> V_SCALEPATCHSHIFT)
|
||||
{
|
||||
case 1: // V_NOSCALEPATCH
|
||||
dupx = dupy = 1;
|
||||
break;
|
||||
case 2: // V_SMALLSCALEPATCH
|
||||
dupx = vid.smalldupx;
|
||||
dupy = vid.smalldupy;
|
||||
break;
|
||||
case 3: // V_MEDSCALEPATCH
|
||||
dupx = vid.meddupx;
|
||||
dupy = vid.meddupy;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// only use one dup, to avoid stretching (har har)
|
||||
dupx = dupy = (dupx < dupy ? dupx : dupy);
|
||||
|
||||
INT32 x = item->x * dupx;
|
||||
INT32 y = item->y * dupy;
|
||||
|
||||
if (item->flags & V_SPLITSCREEN)
|
||||
y += (BASEVIDHEIGHT * (dupy - 1))/2;
|
||||
|
||||
if (item->flags & V_HORZSCREEN)
|
||||
x += (BASEVIDWIDTH * (dupx - 1))/2;
|
||||
|
||||
if (vid.width != BASEVIDWIDTH * dupx)
|
||||
{
|
||||
// dupx adjustments pretend that screen width is BASEVIDWIDTH * dupx,
|
||||
// so center this imaginary screen
|
||||
if ((item->flags & (V_HORZSCREEN|V_SNAPTOLEFT)) == (V_HORZSCREEN|V_SNAPTOLEFT))
|
||||
x += (vid.width/2 - (BASEVIDWIDTH/2 * dupx));
|
||||
else if (item->flags & V_SNAPTORIGHT)
|
||||
x += (vid.width - (BASEVIDWIDTH * dupx));
|
||||
else if (!(item->flags & V_SNAPTOLEFT))
|
||||
x += (vid.width - (BASEVIDWIDTH * dupx)) / 2;
|
||||
}
|
||||
if (vid.height != BASEVIDHEIGHT * dupy)
|
||||
{
|
||||
// same thing here
|
||||
if ((item->flags & (V_SPLITSCREEN|V_SNAPTOTOP)) == (V_SPLITSCREEN|V_SNAPTOTOP))
|
||||
y += (vid.height/2 - (BASEVIDHEIGHT/2 * dupy));
|
||||
else if (item->flags & V_SNAPTOBOTTOM)
|
||||
y += (vid.height - (BASEVIDHEIGHT * dupy));
|
||||
else if (!(item->flags & V_SNAPTOTOP))
|
||||
y += (vid.height - (BASEVIDHEIGHT * dupy)) / 2;
|
||||
}
|
||||
|
||||
// need to compensate for dup here
|
||||
if (item->type == DI_DrawString)
|
||||
{
|
||||
if (item->align == align_center)
|
||||
x -= (V_StringWidth(string, item->flags) * (dupx - 1))/2;
|
||||
if (item->align == align_right)
|
||||
x -= V_StringWidth(string, item->flags) * (dupx - 1);
|
||||
if (item->align == align_smallright)
|
||||
x -= V_SmallStringWidth(string, item->flags) * (dupx - 1);
|
||||
if (item->align == align_thinright)
|
||||
x -= V_ThinStringWidth(string, item->flags) * (dupx - 1);
|
||||
}
|
||||
|
||||
item->x = x;
|
||||
item->y = y;
|
||||
}
|
||||
}
|
||||
|
||||
static void CalcFillCoords(drawitem_t *item)
|
||||
{
|
||||
if (!(item->flags & V_NOSCALESTART) && cv_uncappedhud.value)
|
||||
{
|
||||
INT32 dupx = vid.dupx;
|
||||
INT32 dupy = vid.dupy;
|
||||
INT32 x = item->x * dupx;
|
||||
INT32 y = item->y * dupy;
|
||||
INT32 c = item->c;
|
||||
|
||||
item->flags |= V_NOSCALESTART;
|
||||
item->w *= dupx;
|
||||
item->h *= dupy;
|
||||
|
||||
// Center it if necessary
|
||||
if (vid.width != BASEVIDWIDTH * dupx)
|
||||
{
|
||||
// dupx adjustments pretend that screen width is BASEVIDWIDTH * dupx,
|
||||
// so center this imaginary screen
|
||||
if (c & V_SNAPTORIGHT)
|
||||
x += (vid.width - (BASEVIDWIDTH * dupx));
|
||||
else if (!(c & V_SNAPTOLEFT))
|
||||
x += (vid.width - (BASEVIDWIDTH * dupx)) / 2;
|
||||
}
|
||||
if (vid.height != BASEVIDHEIGHT * dupy)
|
||||
{
|
||||
// same thing here
|
||||
if (c & V_SNAPTOBOTTOM)
|
||||
y += (vid.height - (BASEVIDHEIGHT * dupy));
|
||||
else if (!(c & V_SNAPTOTOP))
|
||||
y += (vid.height - (BASEVIDHEIGHT * dupy)) / 2;
|
||||
}
|
||||
if (c & V_SPLITSCREEN)
|
||||
y += (BASEVIDHEIGHT * dupy)/2;
|
||||
if (c & V_HORZSCREEN)
|
||||
x += (BASEVIDWIDTH * dupx)/2;
|
||||
|
||||
item->x = x;
|
||||
item->y = y;
|
||||
}
|
||||
}
|
||||
|
||||
#define INTERP_LATCH 1
|
||||
#define INTERP_STRING 2
|
||||
#define INTERP_FLAGMASK 0x3
|
||||
|
||||
static UINT64 GetItemId(void)
|
||||
{
|
||||
if (!hud_interpolate)
|
||||
return 0;
|
||||
|
||||
// leave bits 0 and 1 free for the string mode
|
||||
UINT64 id = ((uintptr_t)gL->savedpc << 32) | (hud_interpcounter << 10) | (hud_interptag << 2);
|
||||
|
||||
if (hud_interplatch)
|
||||
{
|
||||
id |= INTERP_LATCH;
|
||||
hud_interplatch = false;
|
||||
}
|
||||
if (hud_interpstring)
|
||||
id |= INTERP_STRING;
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
void LUA_HUD_AddDraw(
|
||||
huddrawlist_h list,
|
||||
INT32 x,
|
||||
@@ -189,9 +350,10 @@ void LUA_HUD_AddDraw(
|
||||
{
|
||||
size_t i = AllocateDrawItem(list);
|
||||
drawitem_t *item = &list->items[i];
|
||||
item->id = GetItemId();
|
||||
item->type = DI_Draw;
|
||||
item->x = x;
|
||||
item->y = y;
|
||||
item->x = x << FRACBITS;
|
||||
item->y = y << FRACBITS;
|
||||
item->patch = patch;
|
||||
item->flags = flags;
|
||||
item->colormap = colormap;
|
||||
@@ -209,6 +371,7 @@ void LUA_HUD_AddDrawScaled(
|
||||
{
|
||||
size_t i = AllocateDrawItem(list);
|
||||
drawitem_t *item = &list->items[i];
|
||||
item->id = GetItemId();
|
||||
item->type = DI_DrawScaled;
|
||||
item->x = x;
|
||||
item->y = y;
|
||||
@@ -231,6 +394,7 @@ void LUA_HUD_AddDrawStretched(
|
||||
{
|
||||
size_t i = AllocateDrawItem(list);
|
||||
drawitem_t *item = &list->items[i];
|
||||
item->id = GetItemId();
|
||||
item->type = DI_DrawStretched;
|
||||
item->x = x;
|
||||
item->y = y;
|
||||
@@ -251,11 +415,13 @@ void LUA_HUD_AddDrawNum(
|
||||
{
|
||||
size_t i = AllocateDrawItem(list);
|
||||
drawitem_t *item = &list->items[i];
|
||||
item->id = GetItemId();
|
||||
item->type = DI_DrawNum;
|
||||
item->x = x;
|
||||
item->y = y;
|
||||
item->num = num;
|
||||
item->flags = flags;
|
||||
CalcStringCoords(item, NULL);
|
||||
}
|
||||
|
||||
void LUA_HUD_AddDrawPaddedNum(
|
||||
@@ -269,12 +435,14 @@ void LUA_HUD_AddDrawPaddedNum(
|
||||
{
|
||||
size_t i = AllocateDrawItem(list);
|
||||
drawitem_t *item = &list->items[i];
|
||||
item->id = GetItemId();
|
||||
item->type = DI_DrawPaddedNum;
|
||||
item->x = x;
|
||||
item->y = y;
|
||||
item->num = num;
|
||||
item->digits = digits;
|
||||
item->flags = flags;
|
||||
CalcStringCoords(item, NULL);
|
||||
}
|
||||
|
||||
void LUA_HUD_AddDrawPingNum(
|
||||
@@ -288,12 +456,14 @@ void LUA_HUD_AddDrawPingNum(
|
||||
{
|
||||
size_t i = AllocateDrawItem(list);
|
||||
drawitem_t *item = &list->items[i];
|
||||
item->id = GetItemId();
|
||||
item->type = DI_DrawPingNum;
|
||||
item->x = x;
|
||||
item->y = y;
|
||||
item->num = num;
|
||||
item->flags = flags;
|
||||
item->colormap = colormap;
|
||||
CalcStringCoords(item, NULL);
|
||||
}
|
||||
|
||||
void LUA_HUD_AddDrawFill(
|
||||
@@ -307,12 +477,14 @@ void LUA_HUD_AddDrawFill(
|
||||
{
|
||||
size_t i = AllocateDrawItem(list);
|
||||
drawitem_t *item = &list->items[i];
|
||||
item->id = GetItemId();
|
||||
item->type = DI_DrawFill;
|
||||
item->x = x;
|
||||
item->y = y;
|
||||
item->w = w;
|
||||
item->h = h;
|
||||
item->c = c;
|
||||
CalcFillCoords(item);
|
||||
}
|
||||
|
||||
void LUA_HUD_AddDrawString(
|
||||
@@ -326,12 +498,15 @@ void LUA_HUD_AddDrawString(
|
||||
{
|
||||
size_t i = AllocateDrawItem(list);
|
||||
drawitem_t *item = &list->items[i];
|
||||
item->id = GetItemId();
|
||||
item->type = DI_DrawString;
|
||||
item->x = x;
|
||||
item->y = y;
|
||||
item->stroffset = CopyString(list, str);
|
||||
item->flags = flags;
|
||||
item->align = align;
|
||||
if (item->align != align_fixed)
|
||||
CalcStringCoords(item, str);
|
||||
}
|
||||
|
||||
void LUA_HUD_AddDrawKartString(
|
||||
@@ -344,11 +519,13 @@ void LUA_HUD_AddDrawKartString(
|
||||
{
|
||||
size_t i = AllocateDrawItem(list);
|
||||
drawitem_t *item = &list->items[i];
|
||||
item->id = GetItemId();
|
||||
item->type = DI_DrawKartString;
|
||||
item->x = x;
|
||||
item->y = y;
|
||||
item->stroffset = CopyString(list, str);
|
||||
item->flags = flags;
|
||||
CalcStringCoords(item, str);
|
||||
}
|
||||
|
||||
void LUA_HUD_AddDrawLevelTitle(
|
||||
@@ -361,11 +538,13 @@ void LUA_HUD_AddDrawLevelTitle(
|
||||
{
|
||||
size_t i = AllocateDrawItem(list);
|
||||
drawitem_t *item = &list->items[i];
|
||||
item->id = GetItemId();
|
||||
item->type = DI_DrawLevelTitle;
|
||||
item->x = x;
|
||||
item->y = y;
|
||||
item->stroffset = CopyString(list, str);
|
||||
item->flags = flags;
|
||||
CalcStringCoords(item, str);
|
||||
}
|
||||
|
||||
void LUA_HUD_AddFadeScreen(
|
||||
@@ -376,6 +555,8 @@ void LUA_HUD_AddFadeScreen(
|
||||
{
|
||||
size_t i = AllocateDrawItem(list);
|
||||
drawitem_t *item = &list->items[i];
|
||||
// nothing to interpolate here
|
||||
item->id = 0;
|
||||
item->type = DI_FadeScreen;
|
||||
item->color = color;
|
||||
item->strength = strength;
|
||||
@@ -384,6 +565,11 @@ void LUA_HUD_AddFadeScreen(
|
||||
void LUA_HUD_DrawList(huddrawlist_h list)
|
||||
{
|
||||
size_t i;
|
||||
size_t j = 0;
|
||||
fixed_t frac = R_UsingFrameInterpolation() ? rendertimefrac : FRACUNIT;
|
||||
fixed_t lerpx = 0, lerpy = 0;
|
||||
drawitem_t *latchitem = NULL;
|
||||
drawitem_t *oldlatchitem = NULL;
|
||||
|
||||
if (!list) I_Error("HUD drawlist invalid");
|
||||
if (list->items_len <= 0) return;
|
||||
@@ -392,68 +578,117 @@ void LUA_HUD_DrawList(huddrawlist_h list)
|
||||
for (i = 0; i < list->items_len; i++)
|
||||
{
|
||||
drawitem_t *item = &list->items[i];
|
||||
drawitem_t *olditem = NULL;
|
||||
const char *itemstr = &list->strbuf[item->stroffset];
|
||||
|
||||
if (item->id)
|
||||
{
|
||||
// find the old one too
|
||||
// this is kinda cursed... we need to check every item
|
||||
// but stop when the first-checked item is reached again
|
||||
size_t stop = j;
|
||||
do
|
||||
{
|
||||
if (j == list->olditems_len)
|
||||
{
|
||||
j = 0;
|
||||
continue;
|
||||
}
|
||||
drawitem_t *old = &list->olditems[j++];
|
||||
if ((old->id & ~INTERP_FLAGMASK) == (item->id & ~INTERP_FLAGMASK))
|
||||
{
|
||||
// gotcha!
|
||||
olditem = old;
|
||||
if (item->id & INTERP_LATCH)
|
||||
{
|
||||
lerpx = FixedMul(frac, item->x - olditem->x);
|
||||
lerpy = FixedMul(frac, item->y - olditem->y);
|
||||
latchitem = item;
|
||||
oldlatchitem = olditem;
|
||||
}
|
||||
else if (!(item->id & INTERP_STRING))
|
||||
{
|
||||
lerpx = FixedMul(frac, item->x - olditem->x);
|
||||
lerpy = FixedMul(frac, item->y - olditem->y);
|
||||
latchitem = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (j != stop);
|
||||
}
|
||||
else
|
||||
{
|
||||
lerpx = lerpy = 0;
|
||||
latchitem = NULL;
|
||||
}
|
||||
|
||||
#define LERP(it) (olditem ? olditem->it + FixedMul(frac, item->it - olditem->it) : item->it)
|
||||
|
||||
// half of this could be done when the coordinates are latched... zzzzzz
|
||||
#define LERPS(it) (latchitem ? ((latchitem->it + (item->it - latchitem->it)) - (latchitem->it - oldlatchitem->it)) + lerp##it : (olditem ? olditem->it + lerp##it : item->it))
|
||||
//define LERPS(it) (olditem ? (latchitem ? (latchitem->it + (item->it - latchitem->it)) - (latchitem->it - oldlatchitem->it) : olditem->it) + lerp##it : item->it)
|
||||
|
||||
switch (item->type)
|
||||
{
|
||||
case DI_Draw:
|
||||
V_DrawFixedPatch(item->x<<FRACBITS, item->y<<FRACBITS, FRACUNIT, item->flags, item->patch, item->colormap);
|
||||
V_DrawFixedPatch(LERPS(x), LERPS(y), FRACUNIT, item->flags, item->patch, item->colormap);
|
||||
break;
|
||||
case DI_DrawScaled:
|
||||
V_DrawFixedPatch(item->x, item->y, item->scale, item->flags, item->patch, item->colormap);
|
||||
V_DrawFixedPatch(LERPS(x), LERPS(y), LERP(scale), item->flags, item->patch, item->colormap);
|
||||
break;
|
||||
case DI_DrawStretched:
|
||||
V_DrawStretchyFixedPatch(item->x, item->y, item->hscale, item->vscale, item->flags, item->patch, item->colormap);
|
||||
V_DrawStretchyFixedPatch(LERPS(x), LERPS(y), LERP(hscale), LERP(vscale), item->flags, item->patch, item->colormap);
|
||||
break;
|
||||
case DI_DrawNum:
|
||||
V_DrawTallNum(item->x, item->y, item->flags, item->num);
|
||||
V_DrawTallNum(LERPS(x), LERPS(y), item->flags, item->num);
|
||||
break;
|
||||
case DI_DrawPaddedNum:
|
||||
V_DrawPaddedTallNum(item->x, item->y, item->flags, item->num, item->digits);
|
||||
V_DrawPaddedTallNum(LERPS(x), LERPS(y), item->flags, item->num, item->digits);
|
||||
break;
|
||||
case DI_DrawPingNum:
|
||||
V_DrawPingNum(item->x, item->y, item->flags, item->num, item->colormap);
|
||||
V_DrawPingNum(LERPS(x), LERPS(y), item->flags, item->num, item->colormap);
|
||||
break;
|
||||
case DI_DrawFill:
|
||||
V_DrawFill(item->x, item->y, item->w, item->h, item->c);
|
||||
V_DrawFill(LERPS(x), LERPS(y), LERP(w), LERP(h), item->c);
|
||||
break;
|
||||
case DI_DrawString:
|
||||
switch(item->align)
|
||||
{
|
||||
// hu_font
|
||||
case align_left:
|
||||
V_DrawString(item->x, item->y, item->flags, itemstr);
|
||||
V_DrawString(LERPS(x), LERPS(y), item->flags, itemstr);
|
||||
break;
|
||||
case align_center:
|
||||
V_DrawCenteredString(item->x, item->y, item->flags, itemstr);
|
||||
V_DrawCenteredString(LERPS(x), LERPS(y), item->flags, itemstr);
|
||||
break;
|
||||
case align_right:
|
||||
V_DrawRightAlignedString(item->x, item->y, item->flags, itemstr);
|
||||
V_DrawRightAlignedString(LERPS(x), LERPS(y), item->flags, itemstr);
|
||||
break;
|
||||
case align_fixed:
|
||||
V_DrawStringAtFixed(item->x, item->y, item->flags, itemstr);
|
||||
V_DrawStringAtFixed(LERPS(x), LERPS(y), item->flags, itemstr);
|
||||
break;
|
||||
// hu_font, 0.5x scale
|
||||
case align_small:
|
||||
V_DrawSmallString(item->x, item->y, item->flags, itemstr);
|
||||
V_DrawSmallString(LERPS(x), LERPS(y), item->flags, itemstr);
|
||||
break;
|
||||
case align_smallright:
|
||||
V_DrawRightAlignedSmallString(item->x, item->y, item->flags, itemstr);
|
||||
V_DrawRightAlignedSmallString(LERPS(x), LERPS(y), item->flags, itemstr);
|
||||
break;
|
||||
// tny_font
|
||||
case align_thin:
|
||||
V_DrawThinString(item->x, item->y, item->flags, itemstr);
|
||||
V_DrawThinString(LERPS(x), LERPS(y), item->flags, itemstr);
|
||||
break;
|
||||
case align_thinright:
|
||||
V_DrawRightAlignedThinString(item->x, item->y, item->flags, itemstr);
|
||||
V_DrawRightAlignedThinString(LERPS(x), LERPS(y), item->flags, itemstr);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case DI_DrawKartString:
|
||||
V_DrawKartString(item->x, item->y, item->flags, itemstr);
|
||||
V_DrawKartString(LERPS(x), LERPS(y), item->flags, itemstr);
|
||||
break;
|
||||
case DI_DrawLevelTitle:
|
||||
V_DrawLevelTitle(item->x, item->y, item->flags, itemstr);
|
||||
V_DrawLevelTitle(LERPS(x), LERPS(y), item->flags, itemstr);
|
||||
break;
|
||||
case DI_FadeScreen:
|
||||
V_DrawFadeScreen(item->color, item->strength);
|
||||
|
||||
+346
-150
@@ -26,32 +26,6 @@
|
||||
boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor);
|
||||
state_t *astate;
|
||||
|
||||
enum sfxinfo_read {
|
||||
sfxinfor_name = 0,
|
||||
sfxinfor_singular,
|
||||
sfxinfor_priority,
|
||||
sfxinfor_flags, // "pitch"
|
||||
sfxinfor_skinsound
|
||||
};
|
||||
const char *const sfxinfo_ropt[] = {
|
||||
"name",
|
||||
"singular",
|
||||
"priority",
|
||||
"flags",
|
||||
"skinsound",
|
||||
NULL};
|
||||
|
||||
enum sfxinfo_write {
|
||||
sfxinfow_singular = 0,
|
||||
sfxinfow_priority,
|
||||
sfxinfow_flags // "pitch"
|
||||
};
|
||||
const char *const sfxinfo_wopt[] = {
|
||||
"singular",
|
||||
"priority",
|
||||
"flags",
|
||||
NULL};
|
||||
|
||||
boolean actionsoverridden[NUMACTIONS] = {false};
|
||||
|
||||
//
|
||||
@@ -103,7 +77,7 @@ static void A_Lua(mobj_t *actor)
|
||||
{
|
||||
boolean found = false;
|
||||
I_Assert(actor != NULL);
|
||||
|
||||
|
||||
lua_settop(gL, 0); // Just in case...
|
||||
lua_pushcfunction(gL, LUA_GetErrorMessage);
|
||||
|
||||
@@ -326,49 +300,93 @@ boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor)
|
||||
return true; // action successfully called.
|
||||
}
|
||||
|
||||
enum state_e {
|
||||
state_sprite = 0,
|
||||
state_frame,
|
||||
state_tics,
|
||||
state_action,
|
||||
state_var1,
|
||||
state_var2,
|
||||
state_nextstate,
|
||||
};
|
||||
|
||||
const char *const state_opt[] = {
|
||||
"sprite",
|
||||
"frame",
|
||||
"tics",
|
||||
"action",
|
||||
"var1",
|
||||
"var2",
|
||||
"nextstate",
|
||||
NULL
|
||||
};
|
||||
|
||||
static int state_fields_ref = LUA_NOREF;
|
||||
|
||||
// state_t *, field -> number
|
||||
static int state_get(lua_State *L)
|
||||
{
|
||||
state_t *st = *((state_t **)luaL_checkudata(L, 1, META_STATE));
|
||||
const char *field = luaL_checkstring(L, 2);
|
||||
enum state_e field = Lua_optoption(L, 2, -1, state_fields_ref);
|
||||
lua_Integer number;
|
||||
|
||||
if (fastcmp(field,"sprite"))
|
||||
number = st->sprite;
|
||||
else if (fastcmp(field,"frame"))
|
||||
number = st->frame;
|
||||
else if (fastcmp(field,"tics"))
|
||||
number = st->tics;
|
||||
else if (fastcmp(field,"action")) {
|
||||
const char *name;
|
||||
if (!st->action.acp1) // Action is NULL.
|
||||
return 0; // return nil.
|
||||
if (st->action.acp1 == (actionf_p1)A_Lua) { // This is a Lua function?
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, LREG_STATEACTION);
|
||||
I_Assert(lua_istable(L, -1));
|
||||
lua_pushlightuserdata(L, st); // Push the state pointer and
|
||||
lua_rawget(L, -2); // use it to get the actual Lua function.
|
||||
lua_remove(L, -2); // pop LREG_STATEACTION
|
||||
return 1; // Return the Lua function.
|
||||
switch (field)
|
||||
{
|
||||
case state_sprite:
|
||||
number = st->sprite;
|
||||
break;
|
||||
|
||||
case state_frame:
|
||||
number = st->frame;
|
||||
break;
|
||||
|
||||
case state_tics:
|
||||
number = st->tics;
|
||||
break;
|
||||
|
||||
case state_action:
|
||||
{
|
||||
const char *name;
|
||||
if (!st->action.acp1) // Action is NULL.
|
||||
return 0; // return nil.
|
||||
if (st->action.acp1 == (actionf_p1)A_Lua) { // This is a Lua function?
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, LREG_STATEACTION);
|
||||
I_Assert(lua_istable(L, -1));
|
||||
lua_pushlightuserdata(L, st); // Push the state pointer and
|
||||
lua_rawget(L, -2); // use it to get the actual Lua function.
|
||||
lua_remove(L, -2); // pop LREG_STATEACTION
|
||||
return 1; // Return the Lua function.
|
||||
}
|
||||
name = LUA_GetActionName(&st->action); // find a hardcoded function name
|
||||
if (!name) // If it's not a hardcoded function and it's not a Lua function...
|
||||
return 0; // Just what is this??
|
||||
// get the function from the global
|
||||
// because the metatable will trigger.
|
||||
lua_getglobal(L, name); // actually gets from LREG_ACTIONS if applicable, and pushes a new C closure if not.
|
||||
lua_pushstring(L, name); // push the name we found.
|
||||
return 2; // return both the function and its name, in case somebody wanted to do a comparison by name or something?
|
||||
}
|
||||
name = LUA_GetActionName(&st->action); // find a hardcoded function name
|
||||
if (!name) // If it's not a hardcoded function and it's not a Lua function...
|
||||
return 0; // Just what is this??
|
||||
// get the function from the global
|
||||
// because the metatable will trigger.
|
||||
lua_getglobal(L, name); // actually gets from LREG_ACTIONS if applicable, and pushes a new C closure if not.
|
||||
lua_pushstring(L, name); // push the name we found.
|
||||
return 2; // return both the function and its name, in case somebody wanted to do a comparison by name or something?
|
||||
} else if (fastcmp(field,"var1"))
|
||||
number = st->var1;
|
||||
else if (fastcmp(field,"var2"))
|
||||
number = st->var2;
|
||||
else if (fastcmp(field,"nextstate"))
|
||||
number = st->nextstate;
|
||||
else if (devparm)
|
||||
return luaL_error(L, LUA_QL("state_t") " has no field named " LUA_QS, field);
|
||||
else
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case state_var1:
|
||||
number = st->var1;
|
||||
break;
|
||||
|
||||
case state_var2:
|
||||
number = st->var2;
|
||||
break;
|
||||
|
||||
case state_nextstate:
|
||||
number = st->nextstate;
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
if (devparm)
|
||||
return luaL_error(L, LUA_QL("state_t") " has no field named " LUA_QS, field);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
lua_pushinteger(L, number);
|
||||
return 1;
|
||||
@@ -378,7 +396,7 @@ static int state_get(lua_State *L)
|
||||
static int state_set(lua_State *L)
|
||||
{
|
||||
state_t *st = *((state_t **)luaL_checkudata(L, 1, META_STATE));
|
||||
const char *field = luaL_checkstring(L, 2);
|
||||
enum state_e field = Lua_optoption(L, 2, -1, state_fields_ref);
|
||||
lua_Integer value;
|
||||
|
||||
if (hud_running)
|
||||
@@ -386,16 +404,24 @@ static int state_set(lua_State *L)
|
||||
if (hook_cmd_running)
|
||||
return luaL_error(L, "Do not alter states in BuildCMD code!");
|
||||
|
||||
if (fastcmp(field,"sprite")) {
|
||||
switch (field)
|
||||
{
|
||||
case state_sprite:
|
||||
value = luaL_checknumber(L, 3);
|
||||
if (value < SPR_NULL || value >= NUMSPRITES)
|
||||
return luaL_error(L, "sprite number %d is invalid.", value);
|
||||
st->sprite = (spritenum_t)value;
|
||||
} else if (fastcmp(field,"frame"))
|
||||
break;
|
||||
|
||||
case state_frame:
|
||||
st->frame = (UINT32)luaL_checknumber(L, 3);
|
||||
else if (fastcmp(field,"tics"))
|
||||
break;
|
||||
|
||||
case state_tics:
|
||||
st->tics = (INT32)luaL_checknumber(L, 3);
|
||||
else if (fastcmp(field,"action")) {
|
||||
break;
|
||||
|
||||
case state_action:
|
||||
switch(lua_type(L, 3))
|
||||
{
|
||||
case LUA_TNIL: // Null? Set the action to nothing, then.
|
||||
@@ -416,17 +442,26 @@ static int state_set(lua_State *L)
|
||||
default: // ?!
|
||||
return luaL_typerror(L, 3, "function");
|
||||
}
|
||||
} else if (fastcmp(field,"var1"))
|
||||
break;
|
||||
|
||||
case state_var1:
|
||||
st->var1 = (INT32)luaL_checknumber(L, 3);
|
||||
else if (fastcmp(field,"var2"))
|
||||
break;
|
||||
|
||||
case state_var2:
|
||||
st->var2 = (INT32)luaL_checknumber(L, 3);
|
||||
else if (fastcmp(field,"nextstate")) {
|
||||
break;
|
||||
|
||||
case state_nextstate:
|
||||
value = luaL_checkinteger(L, 3);
|
||||
if (value < S_NULL || value >= NUMSTATES)
|
||||
return luaL_error(L, "nextstate number %d is invalid.", value);
|
||||
st->nextstate = (statenum_t)value;
|
||||
} else
|
||||
break;
|
||||
|
||||
default:
|
||||
return luaL_error(L, LUA_QL("state_t") " has no field named " LUA_QS, field);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -561,75 +596,161 @@ static int lib_mobjinfolen(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
enum mobjinfo_e
|
||||
{
|
||||
mobjinfo_doomednum,
|
||||
mobjinfo_spawnstate,
|
||||
mobjinfo_spawnhealth,
|
||||
mobjinfo_seestate,
|
||||
mobjinfo_seesound,
|
||||
mobjinfo_reactiontime,
|
||||
mobjinfo_attacksound,
|
||||
mobjinfo_painstate,
|
||||
mobjinfo_painchance,
|
||||
mobjinfo_painsound,
|
||||
mobjinfo_meleestate,
|
||||
mobjinfo_missilestate,
|
||||
mobjinfo_deathstate,
|
||||
mobjinfo_xdeathstate,
|
||||
mobjinfo_deathsound,
|
||||
mobjinfo_speed,
|
||||
mobjinfo_radius,
|
||||
mobjinfo_height,
|
||||
mobjinfo_dispoffset,
|
||||
mobjinfo_mass,
|
||||
mobjinfo_damage,
|
||||
mobjinfo_activesound,
|
||||
mobjinfo_flags,
|
||||
mobjinfo_raisestate,
|
||||
};
|
||||
|
||||
const char *const mobjinfo_opt[] = {
|
||||
"doomednum",
|
||||
"spawnstate",
|
||||
"spawnhealth",
|
||||
"seestate",
|
||||
"seesound",
|
||||
"reactiontime",
|
||||
"attacksound",
|
||||
"painstate",
|
||||
"painchance",
|
||||
"painsound",
|
||||
"meleestate",
|
||||
"missilestate",
|
||||
"deathstate",
|
||||
"xdeathstate",
|
||||
"deathsound",
|
||||
"speed",
|
||||
"radius",
|
||||
"height",
|
||||
"dispoffset",
|
||||
"mass",
|
||||
"damage",
|
||||
"activesound",
|
||||
"flags",
|
||||
"raisestate",
|
||||
NULL,
|
||||
};
|
||||
|
||||
static int mobjinfo_fields_ref = LUA_NOREF;
|
||||
|
||||
// mobjinfo_t *, field -> number
|
||||
static int mobjinfo_get(lua_State *L)
|
||||
{
|
||||
mobjinfo_t *info = *((mobjinfo_t **)luaL_checkudata(L, 1, META_MOBJINFO));
|
||||
const char *field = luaL_checkstring(L, 2);
|
||||
enum mobjinfo_e field = Lua_optoption(L, 2, -1, mobjinfo_fields_ref);
|
||||
|
||||
I_Assert(info != NULL);
|
||||
I_Assert(info >= mobjinfo);
|
||||
|
||||
if (fastcmp(field,"doomednum"))
|
||||
switch (field)
|
||||
{
|
||||
case mobjinfo_doomednum:
|
||||
lua_pushinteger(L, info->doomednum);
|
||||
else if (fastcmp(field,"spawnstate"))
|
||||
break;
|
||||
case mobjinfo_spawnstate:
|
||||
lua_pushinteger(L, info->spawnstate);
|
||||
else if (fastcmp(field,"spawnhealth"))
|
||||
break;
|
||||
case mobjinfo_spawnhealth:
|
||||
lua_pushinteger(L, info->spawnhealth);
|
||||
else if (fastcmp(field,"seestate"))
|
||||
break;
|
||||
case mobjinfo_seestate:
|
||||
lua_pushinteger(L, info->seestate);
|
||||
else if (fastcmp(field,"seesound"))
|
||||
break;
|
||||
case mobjinfo_seesound:
|
||||
lua_pushinteger(L, info->seesound);
|
||||
else if (fastcmp(field,"reactiontime"))
|
||||
break;
|
||||
case mobjinfo_reactiontime:
|
||||
lua_pushinteger(L, info->reactiontime);
|
||||
else if (fastcmp(field,"attacksound"))
|
||||
break;
|
||||
case mobjinfo_attacksound:
|
||||
lua_pushinteger(L, info->attacksound);
|
||||
else if (fastcmp(field,"painstate"))
|
||||
break;
|
||||
case mobjinfo_painstate:
|
||||
lua_pushinteger(L, info->painstate);
|
||||
else if (fastcmp(field,"painchance"))
|
||||
break;
|
||||
case mobjinfo_painchance:
|
||||
lua_pushinteger(L, info->painchance);
|
||||
else if (fastcmp(field,"painsound"))
|
||||
break;
|
||||
case mobjinfo_painsound:
|
||||
lua_pushinteger(L, info->painsound);
|
||||
else if (fastcmp(field,"meleestate"))
|
||||
break;
|
||||
case mobjinfo_meleestate:
|
||||
lua_pushinteger(L, info->meleestate);
|
||||
else if (fastcmp(field,"missilestate"))
|
||||
break;
|
||||
case mobjinfo_missilestate:
|
||||
lua_pushinteger(L, info->missilestate);
|
||||
else if (fastcmp(field,"deathstate"))
|
||||
break;
|
||||
case mobjinfo_deathstate:
|
||||
lua_pushinteger(L, info->deathstate);
|
||||
else if (fastcmp(field,"xdeathstate"))
|
||||
break;
|
||||
case mobjinfo_xdeathstate:
|
||||
lua_pushinteger(L, info->xdeathstate);
|
||||
else if (fastcmp(field,"deathsound"))
|
||||
break;
|
||||
case mobjinfo_deathsound:
|
||||
lua_pushinteger(L, info->deathsound);
|
||||
else if (fastcmp(field,"speed"))
|
||||
break;
|
||||
case mobjinfo_speed:
|
||||
lua_pushinteger(L, info->speed); // sometimes it's fixed_t, sometimes it's not...
|
||||
else if (fastcmp(field,"radius"))
|
||||
break;
|
||||
case mobjinfo_radius:
|
||||
lua_pushfixed(L, info->radius);
|
||||
else if (fastcmp(field,"height"))
|
||||
break;
|
||||
case mobjinfo_height:
|
||||
lua_pushfixed(L, info->height);
|
||||
else if (fastcmp(field,"dispoffset"))
|
||||
break;
|
||||
case mobjinfo_dispoffset:
|
||||
lua_pushinteger(L, info->dispoffset);
|
||||
else if (fastcmp(field,"mass"))
|
||||
break;
|
||||
case mobjinfo_mass:
|
||||
lua_pushinteger(L, info->mass);
|
||||
else if (fastcmp(field,"damage"))
|
||||
break;
|
||||
case mobjinfo_damage:
|
||||
lua_pushinteger(L, info->damage);
|
||||
else if (fastcmp(field,"activesound"))
|
||||
break;
|
||||
case mobjinfo_activesound:
|
||||
lua_pushinteger(L, info->activesound);
|
||||
else if (fastcmp(field,"flags"))
|
||||
break;
|
||||
case mobjinfo_flags:
|
||||
lua_pushinteger(L, info->flags);
|
||||
else if (fastcmp(field,"raisestate"))
|
||||
break;
|
||||
case mobjinfo_raisestate:
|
||||
lua_pushinteger(L, info->raisestate);
|
||||
else {
|
||||
break;
|
||||
default:
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS);
|
||||
I_Assert(lua_istable(L, -1));
|
||||
lua_pushlightuserdata(L, info);
|
||||
lua_rawget(L, -2);
|
||||
if (!lua_istable(L, -1)) { // no extra values table
|
||||
CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; returning nil.\n"), "mobjinfo_t", field);
|
||||
CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; returning nil.\n"), "mobjinfo_t", lua_tostring(L, 2));
|
||||
return 0;
|
||||
}
|
||||
lua_getfield(L, -1, field);
|
||||
lua_pushvalue(L, 2); // field name
|
||||
lua_gettable(L, -2);
|
||||
if (lua_isnil(L, -1)) // no value for this field
|
||||
CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; returning nil.\n"), "mobjinfo_t", field);
|
||||
CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; returning nil.\n"), "mobjinfo_t", lua_tostring(L, 2));
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -638,7 +759,7 @@ static int mobjinfo_get(lua_State *L)
|
||||
static int mobjinfo_set(lua_State *L)
|
||||
{
|
||||
mobjinfo_t *info = *((mobjinfo_t **)luaL_checkudata(L, 1, META_MOBJINFO));
|
||||
const char *field = luaL_checkstring(L, 2);
|
||||
enum mobjinfo_e field = Lua_optoption(L, 2, -1, mobjinfo_fields_ref);
|
||||
|
||||
if (hud_running)
|
||||
return luaL_error(L, "Do not alter mobjinfo in HUD rendering code!");
|
||||
@@ -648,55 +769,81 @@ static int mobjinfo_set(lua_State *L)
|
||||
I_Assert(info != NULL);
|
||||
I_Assert(info >= mobjinfo);
|
||||
|
||||
if (fastcmp(field,"doomednum"))
|
||||
switch (field)
|
||||
{
|
||||
case mobjinfo_doomednum:
|
||||
info->doomednum = (INT32)luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"spawnstate"))
|
||||
break;
|
||||
case mobjinfo_spawnstate:
|
||||
info->spawnstate = luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"spawnhealth"))
|
||||
break;
|
||||
case mobjinfo_spawnhealth:
|
||||
info->spawnhealth = (INT32)luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"seestate"))
|
||||
break;
|
||||
case mobjinfo_seestate:
|
||||
info->seestate = luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"seesound"))
|
||||
break;
|
||||
case mobjinfo_seesound:
|
||||
info->seesound = luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"reactiontime"))
|
||||
break;
|
||||
case mobjinfo_reactiontime:
|
||||
info->reactiontime = (INT32)luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"attacksound"))
|
||||
break;
|
||||
case mobjinfo_attacksound:
|
||||
info->attacksound = luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"painstate"))
|
||||
break;
|
||||
case mobjinfo_painstate:
|
||||
info->painstate = luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"painchance"))
|
||||
break;
|
||||
case mobjinfo_painchance:
|
||||
info->painchance = (INT32)luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"painsound"))
|
||||
break;
|
||||
case mobjinfo_painsound:
|
||||
info->painsound = luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"meleestate"))
|
||||
break;
|
||||
case mobjinfo_meleestate:
|
||||
info->meleestate = luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"missilestate"))
|
||||
break;
|
||||
case mobjinfo_missilestate:
|
||||
info->missilestate = luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"deathstate"))
|
||||
break;
|
||||
case mobjinfo_deathstate:
|
||||
info->deathstate = luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"xdeathstate"))
|
||||
break;
|
||||
case mobjinfo_xdeathstate:
|
||||
info->xdeathstate = luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"deathsound"))
|
||||
break;
|
||||
case mobjinfo_deathsound:
|
||||
info->deathsound = luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"speed"))
|
||||
break;
|
||||
case mobjinfo_speed:
|
||||
info->speed = luaL_checkfixed(L, 3);
|
||||
else if (fastcmp(field,"radius"))
|
||||
break;
|
||||
case mobjinfo_radius:
|
||||
info->radius = luaL_checkfixed(L, 3);
|
||||
else if (fastcmp(field,"height"))
|
||||
break;
|
||||
case mobjinfo_height:
|
||||
info->height = luaL_checkfixed(L, 3);
|
||||
else if (fastcmp(field,"dispoffset"))
|
||||
break;
|
||||
case mobjinfo_dispoffset:
|
||||
info->dispoffset = (INT32)luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"mass"))
|
||||
break;
|
||||
case mobjinfo_mass:
|
||||
info->mass = (INT32)luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"damage"))
|
||||
break;
|
||||
case mobjinfo_damage:
|
||||
info->damage = (INT32)luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"activesound"))
|
||||
break;
|
||||
case mobjinfo_activesound:
|
||||
info->activesound = luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"flags"))
|
||||
break;
|
||||
case mobjinfo_flags:
|
||||
info->flags = (INT32)luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"raisestate"))
|
||||
break;
|
||||
case mobjinfo_raisestate:
|
||||
info->raisestate = luaL_checkinteger(L, 3);
|
||||
else {
|
||||
break;
|
||||
default:
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS);
|
||||
I_Assert(lua_istable(L, -1));
|
||||
lua_pushlightuserdata(L, info);
|
||||
@@ -704,18 +851,17 @@ static int mobjinfo_set(lua_State *L)
|
||||
if (lua_isnil(L, -1)) {
|
||||
// This index doesn't have a table for extra values yet, let's make one.
|
||||
lua_pop(L, 1);
|
||||
CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; adding it as Lua data.\n"), "mobjinfo_t", field);
|
||||
CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; adding it as Lua data.\n"), "mobjinfo_t", lua_tostring(L, 2));
|
||||
lua_newtable(L);
|
||||
lua_pushlightuserdata(L, info);
|
||||
lua_pushvalue(L, -2); // ext value table
|
||||
lua_rawset(L, -4); // LREG_EXTVARS table
|
||||
}
|
||||
lua_pushvalue(L, 2); // key
|
||||
lua_pushvalue(L, 3); // value to store
|
||||
lua_setfield(L, -2, field);
|
||||
lua_settable(L, -3);
|
||||
lua_pop(L, 2);
|
||||
}
|
||||
//else
|
||||
//return luaL_error(L, LUA_QL("mobjinfo_t") " has no field named " LUA_QS, field);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -748,6 +894,25 @@ static int lib_getSfxInfo(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
enum sfxinfo_e {
|
||||
sfxinfo_name = 0,
|
||||
sfxinfo_singular,
|
||||
sfxinfo_priority,
|
||||
sfxinfo_flags, // "pitch"
|
||||
sfxinfo_skinsound
|
||||
};
|
||||
|
||||
const char *const sfxinfo_opt[] = {
|
||||
"name",
|
||||
"singular",
|
||||
"priority",
|
||||
"flags",
|
||||
"skinsound",
|
||||
NULL
|
||||
};
|
||||
|
||||
static int sfxinfo_fields_ref = LUA_NOREF;
|
||||
|
||||
// stack: dummy, S_sfx[] table index, table of values to set.
|
||||
static int lib_setSfxInfo(lua_State *L)
|
||||
{
|
||||
@@ -771,22 +936,44 @@ static int lib_setSfxInfo(lua_State *L)
|
||||
|
||||
lua_pushnil(L);
|
||||
while (lua_next(L, 1)) {
|
||||
enum sfxinfo_write i;
|
||||
enum sfxinfo_e i;
|
||||
|
||||
if (lua_isnumber(L, 2))
|
||||
i = lua_tointeger(L, 2) - 1; // lua is one based, this enum is zero based.
|
||||
{
|
||||
int j = lua_tointeger(L, 2) - 1;
|
||||
|
||||
// Read and Write enums were combined, need to do this switch now
|
||||
switch (j)
|
||||
{
|
||||
case 1:
|
||||
i = sfxinfo_singular;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
i = sfxinfo_priority;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
i = sfxinfo_flags;
|
||||
break;
|
||||
|
||||
default:
|
||||
i = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
i = luaL_checkoption(L, 2, NULL, sfxinfo_wopt);
|
||||
i = Lua_optoption(L, 2, -1, sfxinfo_fields_ref);
|
||||
|
||||
switch(i)
|
||||
{
|
||||
case sfxinfow_singular:
|
||||
case sfxinfo_singular:
|
||||
info->singularity = luaL_checkboolean(L, 3);
|
||||
break;
|
||||
case sfxinfow_priority:
|
||||
case sfxinfo_priority:
|
||||
info->priority = (INT32)luaL_checkinteger(L, 3);
|
||||
break;
|
||||
case sfxinfow_flags:
|
||||
case sfxinfo_flags:
|
||||
info->pitch = (INT32)luaL_checkinteger(L, 3);
|
||||
break;
|
||||
default:
|
||||
@@ -808,29 +995,29 @@ static int lib_sfxlen(lua_State *L)
|
||||
static int sfxinfo_get(lua_State *L)
|
||||
{
|
||||
sfxinfo_t *sfx = *((sfxinfo_t **)luaL_checkudata(L, 1, META_SFXINFO));
|
||||
enum sfxinfo_read field = luaL_checkoption(L, 2, NULL, sfxinfo_ropt);
|
||||
enum sfxinfo_e field = Lua_optoption(L, 2, -1, sfxinfo_fields_ref);
|
||||
|
||||
I_Assert(sfx != NULL);
|
||||
|
||||
switch (field)
|
||||
{
|
||||
case sfxinfor_name:
|
||||
case sfxinfo_name:
|
||||
lua_pushstring(L, sfx->name);
|
||||
return 1;
|
||||
case sfxinfor_singular:
|
||||
case sfxinfo_singular:
|
||||
lua_pushboolean(L, sfx->singularity);
|
||||
return 1;
|
||||
case sfxinfor_priority:
|
||||
case sfxinfo_priority:
|
||||
lua_pushinteger(L, sfx->priority);
|
||||
return 1;
|
||||
case sfxinfor_flags:
|
||||
case sfxinfo_flags:
|
||||
lua_pushinteger(L, sfx->pitch);
|
||||
return 1;
|
||||
case sfxinfor_skinsound:
|
||||
case sfxinfo_skinsound:
|
||||
lua_pushinteger(L, sfx->skinsound);
|
||||
return 1;
|
||||
default:
|
||||
return luaL_error(L, "impossible error");
|
||||
return luaL_error(L, LUA_QL("sfxinfo_t") " has no field named " LUA_QS, lua_tostring(L, 2));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -839,7 +1026,7 @@ static int sfxinfo_get(lua_State *L)
|
||||
static int sfxinfo_set(lua_State *L)
|
||||
{
|
||||
sfxinfo_t *sfx = *((sfxinfo_t **)luaL_checkudata(L, 1, META_SFXINFO));
|
||||
enum sfxinfo_write field = luaL_checkoption(L, 2, NULL, sfxinfo_wopt);
|
||||
int field = Lua_optoption(L, 2, -1, sfxinfo_fields_ref);
|
||||
|
||||
if (hud_running)
|
||||
return luaL_error(L, "Do not alter S_sfx in HUD rendering code!");
|
||||
@@ -854,17 +1041,20 @@ static int sfxinfo_set(lua_State *L)
|
||||
|
||||
switch (field)
|
||||
{
|
||||
case sfxinfow_singular:
|
||||
case sfxinfo_singular:
|
||||
sfx->singularity = luaL_checkboolean(L, 1);
|
||||
break;
|
||||
case sfxinfow_priority:
|
||||
case sfxinfo_priority:
|
||||
sfx->priority = luaL_checkinteger(L, 1);
|
||||
break;
|
||||
case sfxinfow_flags:
|
||||
case sfxinfo_flags:
|
||||
sfx->pitch = luaL_checkinteger(L, 1);
|
||||
break;
|
||||
default:
|
||||
return luaL_error(L, "impossible error");
|
||||
if (field == -1)
|
||||
return luaL_error(L, LUA_QL("sfxinfo_t") " has no field named " LUA_QS, lua_tostring(L, 2));
|
||||
else
|
||||
return luaL_error(L, LUA_QL("sfxinfo_t") " field " LUA_QS " is read-only", lua_tostring(L, 2));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -906,6 +1096,8 @@ int LUA_InfoLib(lua_State *L)
|
||||
lua_setfield(L, -2, "__len");
|
||||
lua_pop(L, 1);
|
||||
|
||||
state_fields_ref = Lua_CreateFieldTable(L, state_opt);
|
||||
|
||||
luaL_newmetatable(L, META_MOBJINFO);
|
||||
lua_pushcfunction(L, mobjinfo_get);
|
||||
lua_setfield(L, -2, "__index");
|
||||
@@ -917,6 +1109,8 @@ int LUA_InfoLib(lua_State *L)
|
||||
lua_setfield(L, -2, "__len");
|
||||
lua_pop(L, 1);
|
||||
|
||||
mobjinfo_fields_ref = Lua_CreateFieldTable(L, mobjinfo_opt);
|
||||
|
||||
luaL_newmetatable(L, META_SFXINFO);
|
||||
lua_pushcfunction(L, sfxinfo_get);
|
||||
lua_setfield(L, -2, "__index");
|
||||
@@ -928,6 +1122,8 @@ int LUA_InfoLib(lua_State *L)
|
||||
lua_setfield(L, -2, "__len");
|
||||
lua_pop(L, 1);
|
||||
|
||||
sfxinfo_fields_ref = Lua_CreateFieldTable(L, sfxinfo_opt);
|
||||
|
||||
lua_newuserdata(L, 0);
|
||||
lua_createtable(L, 0, 2);
|
||||
lua_pushcfunction(L, lib_getSprname);
|
||||
@@ -979,4 +1175,4 @@ int LUA_InfoLib(lua_State *L)
|
||||
lua_setglobal(L, "S_sfx");
|
||||
lua_setglobal(L, "sfxinfo");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
+193
-49
@@ -71,6 +71,8 @@ enum subsector_e {
|
||||
subsector_firstline,
|
||||
};
|
||||
|
||||
static int sector_fields_ref = LUA_NOREF;
|
||||
|
||||
static const char *const subsector_opt[] = {
|
||||
"valid",
|
||||
"sector",
|
||||
@@ -78,6 +80,8 @@ static const char *const subsector_opt[] = {
|
||||
"firstline",
|
||||
NULL};
|
||||
|
||||
static int subsector_fields_ref = LUA_NOREF;
|
||||
|
||||
enum line_e {
|
||||
line_valid = 0,
|
||||
line_v1,
|
||||
@@ -120,6 +124,8 @@ static const char *const line_opt[] = {
|
||||
"callcount",
|
||||
NULL};
|
||||
|
||||
static int line_fields_ref = LUA_NOREF;
|
||||
|
||||
enum side_e {
|
||||
side_valid = 0,
|
||||
side_textureoffset,
|
||||
@@ -146,6 +152,8 @@ static const char *const side_opt[] = {
|
||||
"text",
|
||||
NULL};
|
||||
|
||||
static int side_fields_ref = LUA_NOREF;
|
||||
|
||||
enum vertex_e {
|
||||
vertex_valid = 0,
|
||||
vertex_x,
|
||||
@@ -160,6 +168,8 @@ static const char *const vertex_opt[] = {
|
||||
"z",
|
||||
NULL};
|
||||
|
||||
static int vertex_fields_ref = LUA_NOREF;
|
||||
|
||||
enum ffloor_e {
|
||||
ffloor_valid = 0,
|
||||
ffloor_topheight,
|
||||
@@ -196,6 +206,8 @@ static const char *const ffloor_opt[] = {
|
||||
"alpha",
|
||||
NULL};
|
||||
|
||||
static int ffloor_fields_ref = LUA_NOREF;
|
||||
|
||||
enum slope_e {
|
||||
slope_valid = 0,
|
||||
slope_o,
|
||||
@@ -222,6 +234,8 @@ static const char *const slope_opt[] = {
|
||||
"flags",
|
||||
NULL};
|
||||
|
||||
static int slope_fields_ref = LUA_NOREF;
|
||||
|
||||
// shared by both vector2_t and vector3_t
|
||||
enum vector_e {
|
||||
vector_x = 0,
|
||||
@@ -387,7 +401,7 @@ static int sectorlines_num(lua_State *L)
|
||||
static int sector_get(lua_State *L)
|
||||
{
|
||||
sector_t *sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR));
|
||||
enum sector_e field = luaL_checkoption(L, 2, sector_opt[0], sector_opt);
|
||||
enum sector_e field = Lua_optoption(L, 2, sector_valid, sector_fields_ref);
|
||||
INT16 i;
|
||||
|
||||
if (!sector)
|
||||
@@ -473,7 +487,7 @@ static int sector_get(lua_State *L)
|
||||
static int sector_set(lua_State *L)
|
||||
{
|
||||
sector_t *sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR));
|
||||
enum sector_e field = luaL_checkoption(L, 2, sector_opt[0], sector_opt);
|
||||
enum sector_e field = Lua_optoption(L, 2, sector_valid, sector_fields_ref);
|
||||
|
||||
if (!sector)
|
||||
return luaL_error(L, "accessed sector_t doesn't exist anymore.");
|
||||
@@ -551,7 +565,7 @@ static int sector_num(lua_State *L)
|
||||
static int subsector_get(lua_State *L)
|
||||
{
|
||||
subsector_t *subsector = *((subsector_t **)luaL_checkudata(L, 1, META_SUBSECTOR));
|
||||
enum subsector_e field = luaL_checkoption(L, 2, subsector_opt[0], subsector_opt);
|
||||
enum subsector_e field = Lua_optoption(L, 2, subsector_valid, subsector_fields_ref);
|
||||
|
||||
if (!subsector)
|
||||
{
|
||||
@@ -590,7 +604,7 @@ static int subsector_num(lua_State *L)
|
||||
static int line_get(lua_State *L)
|
||||
{
|
||||
line_t *line = *((line_t **)luaL_checkudata(L, 1, META_LINE));
|
||||
enum line_e field = luaL_checkoption(L, 2, line_opt[0], line_opt);
|
||||
enum line_e field = Lua_optoption(L, 2, line_valid, line_fields_ref);
|
||||
|
||||
if (!line)
|
||||
{
|
||||
@@ -715,7 +729,7 @@ static int sidenum_get(lua_State *L)
|
||||
static int side_get(lua_State *L)
|
||||
{
|
||||
side_t *side = *((side_t **)luaL_checkudata(L, 1, META_SIDE));
|
||||
enum side_e field = luaL_checkoption(L, 2, side_opt[0], side_opt);
|
||||
enum side_e field = Lua_optoption(L, 2, side_valid, side_fields_ref);
|
||||
|
||||
if (!side)
|
||||
{
|
||||
@@ -765,7 +779,7 @@ static int side_get(lua_State *L)
|
||||
static int side_set(lua_State *L)
|
||||
{
|
||||
side_t *side = *((side_t **)luaL_checkudata(L, 1, META_SIDE));
|
||||
enum side_e field = luaL_checkoption(L, 2, side_opt[0], side_opt);
|
||||
enum side_e field = Lua_optoption(L, 2, side_valid, side_fields_ref);
|
||||
|
||||
if (!side)
|
||||
{
|
||||
@@ -816,7 +830,7 @@ static int side_num(lua_State *L)
|
||||
static int vertex_get(lua_State *L)
|
||||
{
|
||||
vertex_t *vertex = *((vertex_t **)luaL_checkudata(L, 1, META_VERTEX));
|
||||
enum vertex_e field = luaL_checkoption(L, 2, vertex_opt[0], vertex_opt);
|
||||
enum vertex_e field = Lua_optoption(L, 2, vertex_valid, vertex_fields_ref);
|
||||
|
||||
if (!vertex)
|
||||
{
|
||||
@@ -1085,7 +1099,7 @@ static int lib_numvertexes(lua_State *L)
|
||||
static int ffloor_get(lua_State *L)
|
||||
{
|
||||
ffloor_t *ffloor = *((ffloor_t **)luaL_checkudata(L, 1, META_FFLOOR));
|
||||
enum ffloor_e field = luaL_checkoption(L, 2, ffloor_opt[0], ffloor_opt);
|
||||
enum ffloor_e field = Lua_optoption(L, 2, ffloor_valid, ffloor_fields_ref);
|
||||
INT16 i;
|
||||
|
||||
if (!ffloor)
|
||||
@@ -1161,7 +1175,7 @@ static int ffloor_get(lua_State *L)
|
||||
static int ffloor_set(lua_State *L)
|
||||
{
|
||||
ffloor_t *ffloor = *((ffloor_t **)luaL_checkudata(L, 1, META_FFLOOR));
|
||||
enum ffloor_e field = luaL_checkoption(L, 2, ffloor_opt[0], ffloor_opt);
|
||||
enum ffloor_e field = Lua_optoption(L, 2, ffloor_valid, ffloor_fields_ref);
|
||||
|
||||
if (!ffloor)
|
||||
return luaL_error(L, "accessed ffloor_t doesn't exist anymore.");
|
||||
@@ -1239,7 +1253,7 @@ static int ffloor_set(lua_State *L)
|
||||
static int slope_get(lua_State *L)
|
||||
{
|
||||
pslope_t *slope = *((pslope_t **)luaL_checkudata(L, 1, META_SLOPE));
|
||||
enum slope_e field = luaL_checkoption(L, 2, slope_opt[0], slope_opt);
|
||||
enum slope_e field = Lua_optoption(L, 2, slope_valid, slope_fields_ref);
|
||||
|
||||
if (!slope)
|
||||
{
|
||||
@@ -1289,7 +1303,7 @@ static int slope_get(lua_State *L)
|
||||
static int slope_set(lua_State *L)
|
||||
{
|
||||
pslope_t *slope = *((pslope_t **)luaL_checkudata(L, 1, META_SLOPE));
|
||||
enum slope_e field = luaL_checkoption(L, 2, slope_opt[0], slope_opt);
|
||||
enum slope_e field = Lua_optoption(L, 2, slope_valid, slope_fields_ref);
|
||||
|
||||
if (!slope)
|
||||
return luaL_error(L, "accessed pslope_t doesn't exist anymore.");
|
||||
@@ -1446,93 +1460,207 @@ static int lib_nummapheaders(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
enum mapheaderinfo_e
|
||||
{
|
||||
mapheaderinfo_lvlttl,
|
||||
mapheaderinfo_subttl,
|
||||
mapheaderinfo_zonttl,
|
||||
mapheaderinfo_actnum,
|
||||
mapheaderinfo_typeoflevel,
|
||||
mapheaderinfo_nextlevel,
|
||||
mapheaderinfo_musname,
|
||||
mapheaderinfo_mustrack,
|
||||
mapheaderinfo_muspos,
|
||||
mapheaderinfo_musinterfadeout,
|
||||
mapheaderinfo_musintername,
|
||||
mapheaderinfo_forcecharacter,
|
||||
mapheaderinfo_weather,
|
||||
mapheaderinfo_skynum,
|
||||
mapheaderinfo_skybox_scalex,
|
||||
mapheaderinfo_skybox_scaley,
|
||||
mapheaderinfo_skybox_scalez,
|
||||
mapheaderinfo_interscreen,
|
||||
mapheaderinfo_runsoc,
|
||||
mapheaderinfo_scriptname,
|
||||
mapheaderinfo_precutscenenum,
|
||||
mapheaderinfo_cutscenenum,
|
||||
mapheaderinfo_countdown,
|
||||
mapheaderinfo_palette,
|
||||
mapheaderinfo_numlaps,
|
||||
mapheaderinfo_unlockrequired,
|
||||
mapheaderinfo_levelselect,
|
||||
mapheaderinfo_bonustype,
|
||||
mapheaderinfo_saveoverride,
|
||||
mapheaderinfo_levelflags,
|
||||
mapheaderinfo_menuflags,
|
||||
//mapheaderinfo_automap,
|
||||
mapheaderinfo_mobj_scale,
|
||||
};
|
||||
|
||||
static const char *const mapheaderinfo_opt[] = {
|
||||
"lvlttl",
|
||||
"subttl",
|
||||
"zonttl",
|
||||
"actnum",
|
||||
"typeoflevel",
|
||||
"nextlevel",
|
||||
"musname",
|
||||
"mustrack",
|
||||
"muspos",
|
||||
"musinterfadeout",
|
||||
"musintername",
|
||||
"forcecharacter",
|
||||
"weather",
|
||||
"skynum",
|
||||
"skybox_scalex",
|
||||
"skybox_scaley",
|
||||
"skybox_scalez",
|
||||
"interscreen",
|
||||
"runsoc",
|
||||
"scriptname",
|
||||
"precutscenenum",
|
||||
"cutscenenum",
|
||||
"countdown",
|
||||
"palette",
|
||||
"numlaps",
|
||||
"unlockrequired",
|
||||
"levelselect",
|
||||
"bonustype",
|
||||
"saveoverride",
|
||||
"levelflags",
|
||||
"menuflags",
|
||||
//"automap",
|
||||
"mobj_scale",
|
||||
NULL,
|
||||
};
|
||||
|
||||
static int mapheaderinfo_fields_ref = LUA_NOREF;
|
||||
|
||||
static int mapheaderinfo_get(lua_State *L)
|
||||
{
|
||||
mapheader_t *header = *((mapheader_t **)luaL_checkudata(L, 1, META_MAPHEADER));
|
||||
const char *field = luaL_checkstring(L, 2);
|
||||
enum mapheaderinfo_e field = Lua_optoption(L, 2, -1, mapheaderinfo_fields_ref);
|
||||
INT16 i;
|
||||
if (fastcmp(field,"lvlttl"))
|
||||
switch (field)
|
||||
{
|
||||
case mapheaderinfo_lvlttl:
|
||||
lua_pushstring(L, header->lvlttl);
|
||||
else if (fastcmp(field,"subttl"))
|
||||
break;
|
||||
case mapheaderinfo_subttl:
|
||||
lua_pushstring(L, header->subttl);
|
||||
else if (fastcmp(field,"zonttl"))
|
||||
break;
|
||||
case mapheaderinfo_zonttl:
|
||||
lua_pushstring(L, header->zonttl);
|
||||
else if (fastcmp(field,"actnum"))
|
||||
break;
|
||||
case mapheaderinfo_actnum:
|
||||
lua_pushstring(L, header->actnum);
|
||||
else if (fastcmp(field,"typeoflevel"))
|
||||
break;
|
||||
case mapheaderinfo_typeoflevel:
|
||||
lua_pushinteger(L, header->typeoflevel);
|
||||
else if (fastcmp(field,"nextlevel"))
|
||||
break;
|
||||
case mapheaderinfo_nextlevel:
|
||||
lua_pushinteger(L, header->nextlevel);
|
||||
else if (fastcmp(field,"musname"))
|
||||
break;
|
||||
case mapheaderinfo_musname:
|
||||
lua_pushstring(L, header->musname);
|
||||
else if (fastcmp(field,"mustrack"))
|
||||
break;
|
||||
case mapheaderinfo_mustrack:
|
||||
lua_pushinteger(L, header->mustrack);
|
||||
else if (fastcmp(field,"muspos"))
|
||||
break;
|
||||
case mapheaderinfo_muspos:
|
||||
lua_pushinteger(L, header->muspos);
|
||||
else if (fastcmp(field,"musinterfadeout"))
|
||||
break;
|
||||
case mapheaderinfo_musinterfadeout:
|
||||
lua_pushinteger(L, header->musinterfadeout);
|
||||
else if (fastcmp(field,"musintername"))
|
||||
break;
|
||||
case mapheaderinfo_musintername:
|
||||
lua_pushstring(L, header->musintername);
|
||||
else if (fastcmp(field,"forcecharacter"))
|
||||
break;
|
||||
case mapheaderinfo_forcecharacter:
|
||||
lua_pushstring(L, header->forcecharacter);
|
||||
else if (fastcmp(field,"weather"))
|
||||
break;
|
||||
case mapheaderinfo_weather:
|
||||
lua_pushinteger(L, header->weather);
|
||||
else if (fastcmp(field,"skynum"))
|
||||
break;
|
||||
case mapheaderinfo_skynum:
|
||||
lua_pushinteger(L, header->skynum);
|
||||
else if (fastcmp(field,"skybox_scalex"))
|
||||
break;
|
||||
case mapheaderinfo_skybox_scalex:
|
||||
lua_pushinteger(L, header->skybox_scalex);
|
||||
else if (fastcmp(field,"skybox_scaley"))
|
||||
break;
|
||||
case mapheaderinfo_skybox_scaley:
|
||||
lua_pushinteger(L, header->skybox_scaley);
|
||||
else if (fastcmp(field,"skybox_scalez"))
|
||||
break;
|
||||
case mapheaderinfo_skybox_scalez:
|
||||
lua_pushinteger(L, header->skybox_scalez);
|
||||
else if (fastcmp(field,"interscreen")) {
|
||||
break;
|
||||
case mapheaderinfo_interscreen:
|
||||
for (i = 0; i < 8; i++)
|
||||
if (!header->interscreen[i])
|
||||
break;
|
||||
lua_pushlstring(L, header->interscreen, i);
|
||||
} else if (fastcmp(field,"runsoc"))
|
||||
break;
|
||||
case mapheaderinfo_runsoc:
|
||||
lua_pushstring(L, header->runsoc);
|
||||
else if (fastcmp(field,"scriptname"))
|
||||
break;
|
||||
case mapheaderinfo_scriptname:
|
||||
lua_pushstring(L, header->scriptname);
|
||||
else if (fastcmp(field,"precutscenenum"))
|
||||
break;
|
||||
case mapheaderinfo_precutscenenum:
|
||||
lua_pushinteger(L, header->precutscenenum);
|
||||
else if (fastcmp(field,"cutscenenum"))
|
||||
break;
|
||||
case mapheaderinfo_cutscenenum:
|
||||
lua_pushinteger(L, header->cutscenenum);
|
||||
else if (fastcmp(field,"countdown"))
|
||||
break;
|
||||
case mapheaderinfo_countdown:
|
||||
lua_pushinteger(L, header->countdown);
|
||||
else if (fastcmp(field,"palette"))
|
||||
break;
|
||||
case mapheaderinfo_palette:
|
||||
lua_pushinteger(L, header->palette);
|
||||
else if (fastcmp(field,"numlaps"))
|
||||
break;
|
||||
case mapheaderinfo_numlaps:
|
||||
lua_pushinteger(L, header->numlaps);
|
||||
else if (fastcmp(field,"unlockrequired"))
|
||||
break;
|
||||
case mapheaderinfo_unlockrequired:
|
||||
lua_pushinteger(L, header->unlockrequired);
|
||||
else if (fastcmp(field,"levelselect"))
|
||||
break;
|
||||
case mapheaderinfo_levelselect:
|
||||
lua_pushinteger(L, header->levelselect);
|
||||
else if (fastcmp(field,"bonustype"))
|
||||
break;
|
||||
case mapheaderinfo_bonustype:
|
||||
lua_pushinteger(L, header->bonustype);
|
||||
else if (fastcmp(field,"saveoverride"))
|
||||
break;
|
||||
case mapheaderinfo_saveoverride:
|
||||
lua_pushinteger(L, header->saveoverride);
|
||||
else if (fastcmp(field,"levelflags"))
|
||||
break;
|
||||
case mapheaderinfo_levelflags:
|
||||
lua_pushinteger(L, header->levelflags);
|
||||
else if (fastcmp(field,"menuflags"))
|
||||
break;
|
||||
case mapheaderinfo_menuflags:
|
||||
lua_pushinteger(L, header->menuflags);
|
||||
/*else if (fastcmp(field,"automap"))
|
||||
lua_pushboolean(L, header->automap);*/
|
||||
else if (fastcmp(field,"mobj_scale"))
|
||||
break;
|
||||
/*case mapheaderinfo_automap:
|
||||
lua_pushstring(L, header->selectheading);
|
||||
break;*/
|
||||
case mapheaderinfo_mobj_scale:
|
||||
lua_pushfixed(L, header->mobj_scale);
|
||||
break;
|
||||
// TODO add support for reading numGradedMares and grades
|
||||
else {
|
||||
default:
|
||||
{
|
||||
// Read custom vars now
|
||||
// (note: don't include the "LUA." in your lua scripts!)
|
||||
UINT8 j = 0;
|
||||
for (;j < header->numCustomOptions && !fastcmp(field, header->customopts[j].option); ++j);
|
||||
for (;j < header->numCustomOptions && !fastcmp(lua_tostring(L, 2), header->customopts[j].option); ++j);
|
||||
|
||||
if(j < header->numCustomOptions)
|
||||
lua_pushstring(L, header->customopts[j].value);
|
||||
else
|
||||
lua_pushnil(L);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
int LUA_MapLib(lua_State *L)
|
||||
@@ -1556,6 +1684,8 @@ int LUA_MapLib(lua_State *L)
|
||||
lua_setfield(L, -2, "__len");
|
||||
lua_pop(L, 1);
|
||||
|
||||
sector_fields_ref = Lua_CreateFieldTable(L, sector_opt);
|
||||
|
||||
luaL_newmetatable(L, META_SUBSECTOR);
|
||||
lua_pushcfunction(L, subsector_get);
|
||||
lua_setfield(L, -2, "__index");
|
||||
@@ -1564,6 +1694,8 @@ int LUA_MapLib(lua_State *L)
|
||||
lua_setfield(L, -2, "__len");
|
||||
lua_pop(L, 1);
|
||||
|
||||
subsector_fields_ref = Lua_CreateFieldTable(L, subsector_opt);
|
||||
|
||||
luaL_newmetatable(L, META_LINE);
|
||||
lua_pushcfunction(L, line_get);
|
||||
lua_setfield(L, -2, "__index");
|
||||
@@ -1572,6 +1704,8 @@ int LUA_MapLib(lua_State *L)
|
||||
lua_setfield(L, -2, "__len");
|
||||
lua_pop(L, 1);
|
||||
|
||||
line_fields_ref = Lua_CreateFieldTable(L, line_opt);
|
||||
|
||||
luaL_newmetatable(L, META_SIDENUM);
|
||||
lua_pushcfunction(L, sidenum_get);
|
||||
lua_setfield(L, -2, "__index");
|
||||
@@ -1588,6 +1722,8 @@ int LUA_MapLib(lua_State *L)
|
||||
lua_setfield(L, -2, "__len");
|
||||
lua_pop(L, 1);
|
||||
|
||||
side_fields_ref = Lua_CreateFieldTable(L, side_opt);
|
||||
|
||||
luaL_newmetatable(L, META_VERTEX);
|
||||
lua_pushcfunction(L, vertex_get);
|
||||
lua_setfield(L, -2, "__index");
|
||||
@@ -1596,6 +1732,8 @@ int LUA_MapLib(lua_State *L)
|
||||
lua_setfield(L, -2, "__len");
|
||||
lua_pop(L, 1);
|
||||
|
||||
vertex_fields_ref = Lua_CreateFieldTable(L, vertex_opt);
|
||||
|
||||
luaL_newmetatable(L, META_FFLOOR);
|
||||
lua_pushcfunction(L, ffloor_get);
|
||||
lua_setfield(L, -2, "__index");
|
||||
@@ -1604,6 +1742,8 @@ int LUA_MapLib(lua_State *L)
|
||||
lua_setfield(L, -2, "__newindex");
|
||||
lua_pop(L, 1);
|
||||
|
||||
ffloor_fields_ref = Lua_CreateFieldTable(L, ffloor_opt);
|
||||
|
||||
luaL_newmetatable(L, META_SLOPE);
|
||||
lua_pushcfunction(L, slope_get);
|
||||
lua_setfield(L, -2, "__index");
|
||||
@@ -1612,6 +1752,8 @@ int LUA_MapLib(lua_State *L)
|
||||
lua_setfield(L, -2, "__newindex");
|
||||
lua_pop(L, 1);
|
||||
|
||||
slope_fields_ref = Lua_CreateFieldTable(L, slope_opt);
|
||||
|
||||
luaL_newmetatable(L, META_VECTOR2);
|
||||
lua_pushcfunction(L, vector2_get);
|
||||
lua_setfield(L, -2, "__index");
|
||||
@@ -1630,6 +1772,8 @@ int LUA_MapLib(lua_State *L)
|
||||
//lua_setfield(L, -2, "__len");
|
||||
lua_pop(L, 1);
|
||||
|
||||
mapheaderinfo_fields_ref = Lua_CreateFieldTable(L, mapheaderinfo_opt);
|
||||
|
||||
lua_newuserdata(L, 0);
|
||||
lua_createtable(L, 0, 2);
|
||||
lua_pushcfunction(L, lib_getSector);
|
||||
@@ -1690,4 +1834,4 @@ int LUA_MapLib(lua_State *L)
|
||||
lua_setmetatable(L, -2);
|
||||
lua_setglobal(L, "mapheaderinfo");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
+104
-48
@@ -769,14 +769,41 @@ static int mobj_set(lua_State *L)
|
||||
#undef NOSETPOS
|
||||
#undef NOFIELD
|
||||
|
||||
enum mapthing_e {
|
||||
mapthing_valid = 0,
|
||||
mapthing_x,
|
||||
mapthing_y,
|
||||
mapthing_angle,
|
||||
mapthing_type,
|
||||
mapthing_options,
|
||||
mapthing_z,
|
||||
mapthing_extrainfo,
|
||||
mapthing_mobj,
|
||||
};
|
||||
|
||||
const char *const mapthing_opt[] = {
|
||||
"valid",
|
||||
"x",
|
||||
"y",
|
||||
"angle",
|
||||
"type",
|
||||
"options",
|
||||
"z",
|
||||
"extrainfo",
|
||||
"mobj",
|
||||
NULL,
|
||||
};
|
||||
|
||||
static int mapthing_fields_ref = LUA_NOREF;
|
||||
|
||||
static int mapthing_get(lua_State *L)
|
||||
{
|
||||
mapthing_t *mt = *((mapthing_t **)luaL_checkudata(L, 1, META_MAPTHING));
|
||||
const char *field = luaL_checkstring(L, 2);
|
||||
lua_Integer number;
|
||||
enum mapthing_e field = Lua_optoption(L, 2, -1, mapthing_fields_ref);
|
||||
lua_settop(L, 2);
|
||||
|
||||
if (!mt) {
|
||||
if (fastcmp(field,"valid")) {
|
||||
if (field == mapthing_valid) {
|
||||
lua_pushboolean(L, false);
|
||||
return 1;
|
||||
}
|
||||
@@ -785,39 +812,50 @@ static int mapthing_get(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (fastcmp(field,"valid")) {
|
||||
lua_pushboolean(L, true);
|
||||
return 1;
|
||||
} else if(fastcmp(field,"x"))
|
||||
number = mt->x;
|
||||
else if(fastcmp(field,"y"))
|
||||
number = mt->y;
|
||||
else if(fastcmp(field,"angle"))
|
||||
number = mt->angle;
|
||||
else if(fastcmp(field,"type"))
|
||||
number = mt->type;
|
||||
else if(fastcmp(field,"options"))
|
||||
number = mt->options;
|
||||
else if(fastcmp(field,"z"))
|
||||
number = mt->z;
|
||||
else if(fastcmp(field,"extrainfo"))
|
||||
number = mt->extrainfo;
|
||||
else if(fastcmp(field,"mobj")) {
|
||||
LUA_PushUserdata(L, mt->mobj, META_MOBJ);
|
||||
return 1;
|
||||
} else if (devparm)
|
||||
return luaL_error(L, LUA_QL("mapthing_t") " has no field named " LUA_QS, field);
|
||||
else
|
||||
return 0;
|
||||
switch (field)
|
||||
{
|
||||
case mapthing_valid:
|
||||
lua_pushboolean(L, true);
|
||||
break;
|
||||
case mapthing_x:
|
||||
lua_pushinteger(L, mt->x);
|
||||
break;
|
||||
case mapthing_y:
|
||||
lua_pushinteger(L, mt->y);
|
||||
break;
|
||||
case mapthing_angle:
|
||||
lua_pushinteger(L, mt->angle);
|
||||
break;
|
||||
case mapthing_type:
|
||||
lua_pushinteger(L, mt->type);
|
||||
break;
|
||||
case mapthing_options:
|
||||
lua_pushinteger(L, mt->options);
|
||||
break;
|
||||
case mapthing_z:
|
||||
lua_pushinteger(L, mt->z);
|
||||
break;
|
||||
case mapthing_extrainfo:
|
||||
lua_pushinteger(L, mt->extrainfo);
|
||||
break;
|
||||
case mapthing_mobj:
|
||||
LUA_PushUserdata(L, mt->mobj, META_MOBJ);
|
||||
break;
|
||||
default:
|
||||
if (devparm)
|
||||
return luaL_error(L, LUA_QL("mapthing_t") " has no field named " LUA_QS, field);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
lua_pushinteger(L, number);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int mapthing_set(lua_State *L)
|
||||
{
|
||||
mapthing_t *mt = *((mapthing_t **)luaL_checkudata(L, 1, META_MAPTHING));
|
||||
const char *field = luaL_checkstring(L, 2);
|
||||
enum mapthing_e field = Lua_optoption(L, 2, -1, mapthing_fields_ref);
|
||||
lua_settop(L, 3);
|
||||
|
||||
if (!mt)
|
||||
return luaL_error(L, "accessed mapthing_t doesn't exist anymore.");
|
||||
@@ -827,24 +865,40 @@ static int mapthing_set(lua_State *L)
|
||||
if (hook_cmd_running)
|
||||
return luaL_error(L, "Do not alter mapthing_t in BuildCMD code!");
|
||||
|
||||
if(fastcmp(field,"x"))
|
||||
mt->x = (INT16)luaL_checkinteger(L, 3);
|
||||
else if(fastcmp(field,"y"))
|
||||
mt->y = (INT16)luaL_checkinteger(L, 3);
|
||||
else if(fastcmp(field,"angle"))
|
||||
mt->angle = (INT16)luaL_checkinteger(L, 3);
|
||||
else if(fastcmp(field,"type"))
|
||||
mt->type = (UINT16)luaL_checkinteger(L, 3);
|
||||
else if(fastcmp(field,"options"))
|
||||
mt->options = (UINT16)luaL_checkinteger(L, 3);
|
||||
else if(fastcmp(field,"z"))
|
||||
mt->z = (INT16)luaL_checkinteger(L, 3);
|
||||
else if(fastcmp(field,"extrainfo"))
|
||||
mt->extrainfo = (UINT8)luaL_checkinteger(L, 3);
|
||||
else if(fastcmp(field,"mobj"))
|
||||
mt->mobj = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ));
|
||||
else
|
||||
return luaL_error(L, LUA_QL("mapthing_t") " has no field named " LUA_QS, field);
|
||||
switch (field)
|
||||
{
|
||||
case mapthing_x:
|
||||
mt->x = (INT16)luaL_checkinteger(L, 3);
|
||||
break;
|
||||
case mapthing_y:
|
||||
mt->y = (INT16)luaL_checkinteger(L, 3);
|
||||
break;
|
||||
case mapthing_angle:
|
||||
mt->angle = (INT16)luaL_checkinteger(L, 3);
|
||||
break;
|
||||
case mapthing_type:
|
||||
mt->type = (UINT16)luaL_checkinteger(L, 3);
|
||||
break;
|
||||
case mapthing_options:
|
||||
mt->options = (UINT16)luaL_checkinteger(L, 3);
|
||||
break;
|
||||
case mapthing_z:
|
||||
mt->z = (INT16)luaL_checkinteger(L, 3);
|
||||
break;
|
||||
case mapthing_extrainfo:
|
||||
{
|
||||
INT32 extrainfo = luaL_checkinteger(L, 3);
|
||||
if (extrainfo & ~15)
|
||||
return luaL_error(L, "mapthing_t extrainfo set %d out of range (%d - %d)", extrainfo, 0, 15);
|
||||
mt->extrainfo = (UINT8)extrainfo;
|
||||
break;
|
||||
}
|
||||
case mapthing_mobj:
|
||||
mt->mobj = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ));
|
||||
break;
|
||||
default:
|
||||
return luaL_error(L, LUA_QL("mapthing_t") " has no field named " LUA_QS, field);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -915,6 +969,8 @@ int LUA_MobjLib(lua_State *L)
|
||||
lua_setfield(L, -2, "__newindex");
|
||||
lua_pop(L,1);
|
||||
|
||||
mapthing_fields_ref = Lua_CreateFieldTable(L, mapthing_opt);
|
||||
|
||||
lua_newuserdata(L, 0);
|
||||
lua_createtable(L, 0, 2);
|
||||
lua_pushcfunction(L, lib_getMapthing);
|
||||
@@ -925,4 +981,4 @@ int LUA_MobjLib(lua_State *L)
|
||||
lua_setmetatable(L, -2);
|
||||
lua_setglobal(L, "mapthings");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
+66
-17
@@ -694,30 +694,65 @@ static int kartstuff_len(lua_State *L)
|
||||
}
|
||||
|
||||
#define NOFIELD luaL_error(L, LUA_QL("ticcmd_t") " has no field named " LUA_QS, field)
|
||||
#define NOSET luaL_error(L, LUA_QL("ticcmd_t") " field " LUA_QS " should not be set directly.", field)
|
||||
|
||||
enum ticcmd_e
|
||||
{
|
||||
ticcmd_forwardmove,
|
||||
ticcmd_sidemove,
|
||||
ticcmd_angleturn,
|
||||
ticcmd_aiming,
|
||||
ticcmd_buttons,
|
||||
ticcmd_driftturn,
|
||||
ticcmd_latency,
|
||||
};
|
||||
|
||||
static const char *const ticcmd_opt[] = {
|
||||
"forwardmove",
|
||||
"sidemove",
|
||||
"angleturn",
|
||||
"aiming",
|
||||
"buttons",
|
||||
"driftturn",
|
||||
"latency",
|
||||
NULL,
|
||||
};
|
||||
|
||||
static int ticcmd_fields_ref = LUA_NOREF;
|
||||
|
||||
static int ticcmd_get(lua_State *L)
|
||||
{
|
||||
ticcmd_t *cmd = *((ticcmd_t **)luaL_checkudata(L, 1, META_TICCMD));
|
||||
const char *field = luaL_checkstring(L, 2);
|
||||
enum ticcmd_e field = Lua_optoption(L, 2, -1, ticcmd_fields_ref);
|
||||
if (!cmd)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
|
||||
if (fastcmp(field,"forwardmove"))
|
||||
switch (field)
|
||||
{
|
||||
case ticcmd_forwardmove:
|
||||
lua_pushinteger(L, cmd->forwardmove);
|
||||
else if (fastcmp(field,"sidemove"))
|
||||
break;
|
||||
case ticcmd_sidemove:
|
||||
lua_pushinteger(L, cmd->sidemove);
|
||||
else if (fastcmp(field,"angleturn"))
|
||||
break;
|
||||
case ticcmd_angleturn:
|
||||
lua_pushinteger(L, cmd->angleturn);
|
||||
else if (fastcmp(field,"aiming"))
|
||||
break;
|
||||
case ticcmd_aiming:
|
||||
lua_pushinteger(L, cmd->aiming);
|
||||
else if (fastcmp(field,"buttons"))
|
||||
break;
|
||||
case ticcmd_buttons:
|
||||
lua_pushinteger(L, cmd->buttons);
|
||||
else if (fastcmp(field,"driftturn"))
|
||||
break;
|
||||
case ticcmd_driftturn:
|
||||
lua_pushinteger(L, cmd->driftturn);
|
||||
else if (fastcmp(field,"latency"))
|
||||
break;
|
||||
case ticcmd_latency:
|
||||
lua_pushinteger(L, cmd->latency);
|
||||
else
|
||||
break;
|
||||
default:
|
||||
return NOFIELD;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -725,32 +760,44 @@ static int ticcmd_get(lua_State *L)
|
||||
static int ticcmd_set(lua_State *L)
|
||||
{
|
||||
ticcmd_t *cmd = *((ticcmd_t **)luaL_checkudata(L, 1, META_TICCMD));
|
||||
const char *field = luaL_checkstring(L, 2);
|
||||
enum ticcmd_e field = Lua_optoption(L, 2, -1, ticcmd_fields_ref);
|
||||
if (!cmd)
|
||||
return LUA_ErrInvalid(L, "ticcmd_t");
|
||||
|
||||
if (hud_running)
|
||||
return luaL_error(L, "Do not alter player_t in HUD rendering code!");
|
||||
|
||||
if (fastcmp(field,"forwardmove"))
|
||||
switch (field)
|
||||
{
|
||||
case ticcmd_forwardmove:
|
||||
cmd->forwardmove = (SINT8)luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"sidemove"))
|
||||
break;
|
||||
case ticcmd_sidemove:
|
||||
cmd->sidemove = (SINT8)luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"angleturn"))
|
||||
break;
|
||||
case ticcmd_angleturn:
|
||||
cmd->angleturn = (INT16)luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"aiming"))
|
||||
break;
|
||||
case ticcmd_aiming:
|
||||
cmd->aiming = (INT16)luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"buttons"))
|
||||
break;
|
||||
case ticcmd_buttons:
|
||||
cmd->buttons = (UINT16)luaL_checkinteger(L, 3);
|
||||
else if (fastcmp(field,"driftturn"))
|
||||
break;
|
||||
case ticcmd_driftturn:
|
||||
cmd->driftturn = (INT16)luaL_checkinteger(L, 3);
|
||||
else
|
||||
break;
|
||||
case ticcmd_latency:
|
||||
return NOSET;
|
||||
default:
|
||||
return NOFIELD;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#undef NOFIELD
|
||||
#undef NOSET
|
||||
|
||||
int LUA_PlayerLib(lua_State *L)
|
||||
{
|
||||
@@ -797,6 +844,8 @@ int LUA_PlayerLib(lua_State *L)
|
||||
lua_setfield(L, -2, "__newindex");
|
||||
lua_pop(L,1);
|
||||
|
||||
ticcmd_fields_ref = Lua_CreateFieldTable(L, ticcmd_opt);
|
||||
|
||||
lua_newuserdata(L, 0);
|
||||
lua_createtable(L, 0, 2);
|
||||
lua_pushcfunction(L, lib_getPlayer);
|
||||
|
||||
+36
-8
@@ -1683,13 +1683,41 @@ void LUA_UnArchiveDemo(void)
|
||||
}
|
||||
|
||||
// For mobj_t, player_t, etc. to take custom variables.
|
||||
int Lua_optoption(lua_State *L, int narg,
|
||||
const char *def, const char *const lst[])
|
||||
int Lua_optoption(lua_State *L, int narg, int def, int list_ref)
|
||||
{
|
||||
int result = -1;
|
||||
|
||||
if (lua_isnoneornil(L, narg))
|
||||
return def;
|
||||
|
||||
I_Assert(lua_checkstack(L, 2));
|
||||
luaL_checkstring(L, narg);
|
||||
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, list_ref);
|
||||
I_Assert(lua_istable(L, -1));
|
||||
lua_pushvalue(L, narg);
|
||||
lua_rawget(L, -2);
|
||||
|
||||
if (lua_isnumber(L, -1))
|
||||
result = lua_tointeger(L, -1);
|
||||
|
||||
lua_pop(L, 2); // Pop result and fields table
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int Lua_CreateFieldTable(lua_State *L, const char *const lst[])
|
||||
{
|
||||
const char *name = (def) ? luaL_optstring(L, narg, def) : luaL_checkstring(L, narg);
|
||||
int i;
|
||||
for (i=0; lst[i]; i++)
|
||||
if (fastcmp(lst[i], name))
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
lua_newtable(L);
|
||||
for (i = 0; lst[i] != NULL; i++)
|
||||
{
|
||||
lua_pushstring(L, lst[i]);
|
||||
lua_pushinteger(L, i);
|
||||
lua_settable(L, -3);
|
||||
}
|
||||
|
||||
return luaL_ref(L, LUA_REGISTRYINDEX);
|
||||
}
|
||||
+2
-2
@@ -63,8 +63,8 @@ void LUA_UnArchiveDemo(void);
|
||||
|
||||
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,
|
||||
const char *def, const char *const lst[]);
|
||||
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);
|
||||
|
||||
// Console wrapper
|
||||
|
||||
+6
-1
@@ -38,6 +38,7 @@ enum skin {
|
||||
skin_highresscale,
|
||||
skin_soundsid
|
||||
};
|
||||
|
||||
static const char *const skin_opt[] = {
|
||||
"valid",
|
||||
"name",
|
||||
@@ -61,10 +62,12 @@ static const char *const skin_opt[] = {
|
||||
|
||||
#define UNIMPLEMENTED luaL_error(L, LUA_QL("skin_t") " field " LUA_QS " is not implemented for Lua and cannot be accessed.", skin_opt[field])
|
||||
|
||||
static int skin_fields_ref = LUA_NOREF;
|
||||
|
||||
static int skin_get(lua_State *L)
|
||||
{
|
||||
skin_t *skin = *((skin_t **)luaL_checkudata(L, 1, META_SKIN));
|
||||
enum skin field = luaL_checkoption(L, 2, NULL, skin_opt);
|
||||
enum skin field = Lua_optoption(L, 2, -1, skin_fields_ref);
|
||||
INT32 i;
|
||||
|
||||
// skins are always valid, only added, never removed
|
||||
@@ -253,6 +256,8 @@ int LUA_SkinLib(lua_State *L)
|
||||
lua_setfield(L, -2, "__len");
|
||||
lua_pop(L,1);
|
||||
|
||||
skin_fields_ref = Lua_CreateFieldTable(L, skin_opt);
|
||||
|
||||
luaL_newmetatable(L, META_SOUNDSID);
|
||||
lua_pushcfunction(L, soundsid_get);
|
||||
lua_setfield(L, -2, "__index");
|
||||
|
||||
@@ -4160,6 +4160,11 @@ void M_StartControlPanel(void)
|
||||
|
||||
menuactive = true;
|
||||
|
||||
DPADUPSCROLL = false;
|
||||
DPADDOWNSCROLL = false;
|
||||
DPADLEFTSCROLL = false;
|
||||
DPADRIGHTSCROLL = false;
|
||||
|
||||
if (demo.playback)
|
||||
{
|
||||
currentMenu = &PlaybackMenuDef;
|
||||
|
||||
+3
-1
@@ -90,9 +90,11 @@ char *GetMODVersion(int id);
|
||||
#endif
|
||||
|
||||
char *GetMasterServerRules(void);
|
||||
#endif
|
||||
|
||||
void AddMServCommands(void);
|
||||
|
||||
#ifdef MASTERSERVER
|
||||
/* HTTP */
|
||||
void HMS_set_api (char *api);
|
||||
int HMS_register (void);
|
||||
@@ -105,4 +107,4 @@ const char * HMS_fetch_rules (char *buffer, size_t size_of_buffer);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
+3
-3
@@ -1908,8 +1908,8 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source)
|
||||
mobj_t *mo;
|
||||
int ms;
|
||||
|
||||
//if (inflictor && (inflictor->type == MT_SHELL || inflictor->type == MT_FIREBALL))
|
||||
// P_SetTarget(&target->tracer, inflictor);
|
||||
if (!target || P_MobjWasRemoved(target))
|
||||
return;
|
||||
|
||||
if (!useNightsSS && G_IsSpecialStage(gamemap) && target->player && sstimer > 6)
|
||||
sstimer = 6; // Just let P_Ticker take care of the rest.
|
||||
@@ -1955,7 +1955,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source)
|
||||
{
|
||||
if (target->movedir != 0 && target->movedir < (UINT16)target->target->player->kartstuff[k_itemamount])
|
||||
{
|
||||
if (target->target->hnext)
|
||||
if (target->target->hnext && !P_MobjWasRemoved(target->target->hnext))
|
||||
K_KillBananaChain(target->target->hnext, inflictor, source);
|
||||
target->target->player->kartstuff[k_itemamount] = 0;
|
||||
}
|
||||
|
||||
+5
-11
@@ -3034,7 +3034,12 @@ boolean P_SetupLevel(boolean skipprecip)
|
||||
|
||||
#ifdef HWRENDER // not win32 only 19990829 by Kin
|
||||
if (rendermode == render_opengl)
|
||||
{
|
||||
HWR_FreeExtraSubsectors();
|
||||
|
||||
// stuff like HWR_CreatePlanePolygons is called there
|
||||
HWR_LoadLevel();
|
||||
}
|
||||
#endif
|
||||
|
||||
// oh god I hope this helps
|
||||
@@ -3303,17 +3308,6 @@ boolean P_SetupLevel(boolean skipprecip)
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef HWRENDER
|
||||
void HWR_LoadLevel(void)
|
||||
{
|
||||
HWR_FreeMipmapCache();
|
||||
HWR_CreatePlanePolygons((INT32)numnodes - 1);
|
||||
|
||||
if (HWR_ShouldUsePaletteRendering())
|
||||
HWR_SetMapPalette();
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// P_RunSOC
|
||||
//
|
||||
|
||||
+1
-5
@@ -2371,11 +2371,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
|
||||
y = sides[line->sidenum[0]].rowoffset;
|
||||
z = line->frontsector->ceilingheight;
|
||||
|
||||
P_UnsetThingPosition(mo);
|
||||
mo->x += x;
|
||||
mo->y += y;
|
||||
mo->z += z;
|
||||
P_SetThingPosition(mo);
|
||||
P_SetOrigin(mo, mo->x + x, mo->y + y, mo->z + z);
|
||||
|
||||
if (mo->player)
|
||||
{
|
||||
|
||||
+10
-9
@@ -84,10 +84,11 @@ void P_MixUp(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle,
|
||||
{
|
||||
if (thing->player != &players[displayplayers[i]])
|
||||
continue;
|
||||
|
||||
if (camera[i].chase)
|
||||
P_ResetCamera(thing->player, &camera[i]);
|
||||
|
||||
R_ResetViewInterpolation(i + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
// don't run in place after a teleport
|
||||
@@ -157,14 +158,14 @@ boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle
|
||||
// move chasecam at new player location
|
||||
for (i = 0; i <= splitscreen; i++)
|
||||
{
|
||||
if (thing->player == &players[displayplayers[i]])
|
||||
{
|
||||
localangle[i] = angle;
|
||||
if (camera[i].chase)
|
||||
P_ResetCamera(thing->player, &camera[i]);
|
||||
R_ResetViewInterpolation(i + 1);
|
||||
break;
|
||||
}
|
||||
if (thing->player != &players[displayplayers[i]])
|
||||
continue;
|
||||
|
||||
localangle[i] = angle;
|
||||
if (camera[i].chase)
|
||||
P_ResetCamera(thing->player, &camera[i]);
|
||||
|
||||
R_ResetViewInterpolation(i + 1);
|
||||
}
|
||||
|
||||
// don't run in place after a teleport
|
||||
|
||||
+1
-7
@@ -581,13 +581,6 @@ void P_Ticker(boolean run)
|
||||
if (playeringame[i])
|
||||
++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)
|
||||
{
|
||||
if (OP_FreezeObjectplace())
|
||||
@@ -834,6 +827,7 @@ 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
|
||||
|
||||
@@ -3959,6 +3959,7 @@ 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);
|
||||
|
||||
+16
-16
@@ -266,11 +266,11 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel,
|
||||
|
||||
for (i = 0; i <= splitscreen; i++)
|
||||
{
|
||||
if (viewplayer == &players[displayplayers[i]] && camera[i].chase)
|
||||
{
|
||||
heightsec = R_PointInSubsector(camera[i].x, camera[i].y)->sector->heightsec;
|
||||
break;
|
||||
}
|
||||
if (!(viewplayer == &players[displayplayers[i]] && camera[i].chase))
|
||||
continue;
|
||||
|
||||
heightsec = R_PointInSubsector(camera[i].x, camera[i].y)->sector->heightsec;
|
||||
break;
|
||||
}
|
||||
|
||||
if (i > splitscreen && viewmobj)
|
||||
@@ -907,11 +907,11 @@ static void R_Subsector(size_t num)
|
||||
{
|
||||
sector_t *controlSec = §ors[rover->secnum];
|
||||
|
||||
if (controlSec->moved == true)
|
||||
{
|
||||
anyMoved = true;
|
||||
break;
|
||||
}
|
||||
if (controlSec->moved != true)
|
||||
continue;
|
||||
|
||||
anyMoved = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1185,13 +1185,13 @@ void R_Prep3DFloors(sector_t *sector)
|
||||
count = 1;
|
||||
for (rover = sector->ffloors; rover; rover = rover->next)
|
||||
{
|
||||
if ((rover->flags & FF_EXISTS) && (!(rover->flags & FF_NOSHADE)
|
||||
|| (rover->flags & FF_CUTLEVEL) || (rover->flags & FF_CUTSPRITES)))
|
||||
{
|
||||
if (!((rover->flags & FF_EXISTS) && (!(rover->flags & FF_NOSHADE)
|
||||
|| (rover->flags & FF_CUTLEVEL) || (rover->flags & FF_CUTSPRITES))))
|
||||
continue;
|
||||
|
||||
count++;
|
||||
if (rover->flags & FF_DOUBLESHADOW)
|
||||
count++;
|
||||
if (rover->flags & FF_DOUBLESHADOW)
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count != sector->numlights)
|
||||
|
||||
+32
-29
@@ -429,22 +429,24 @@ void R_LoadTextures(void)
|
||||
}
|
||||
|
||||
// Add all the textures between TX_START and TX_END
|
||||
if (texstart != INT16_MAX && texend != INT16_MAX)
|
||||
if (!(texstart != INT16_MAX && texend != INT16_MAX))
|
||||
continue;
|
||||
|
||||
// PK3s have subfolders, so we can't just make a simple sum
|
||||
if (W_FileHasFolders(wadfiles[w]))
|
||||
{
|
||||
// PK3s have subfolders, so we can't just make a simple sum
|
||||
if (W_FileHasFolders(wadfiles[w]))
|
||||
for (j = texstart; j < texend; j++)
|
||||
{
|
||||
for (j = texstart; j < texend; j++)
|
||||
{
|
||||
if (!W_IsLumpFolder((UINT16)w, j)) // Check if lump is a folder; if not, then count it
|
||||
numtextures++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
numtextures += (UINT32)(texend - texstart);
|
||||
if (W_IsLumpFolder((UINT16)w, j)) // Check if lump is a folder; if not, then count it
|
||||
continue;
|
||||
|
||||
numtextures++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
numtextures += (UINT32)(texend - texstart);
|
||||
}
|
||||
}
|
||||
|
||||
// If no textures found by this point, bomb out
|
||||
@@ -1003,26 +1005,26 @@ lumpnum_t R_GetFlatNumForName(const char *name)
|
||||
{
|
||||
switch (wadfiles[i]->type)
|
||||
{
|
||||
case RET_WAD:
|
||||
if ((start = W_CheckNumForNamePwad("F_START", (UINT16)i, 0)) == INT16_MAX)
|
||||
{
|
||||
if ((start = W_CheckNumForNamePwad("FF_START", (UINT16)i, 0)) == INT16_MAX)
|
||||
case RET_WAD:
|
||||
if ((start = W_CheckNumForNamePwad("F_START", (UINT16)i, 0)) == INT16_MAX)
|
||||
{
|
||||
if ((start = W_CheckNumForNamePwad("FF_START", (UINT16)i, 0)) == INT16_MAX)
|
||||
continue;
|
||||
else if ((end = W_CheckNumForNamePwad("FF_END", (UINT16)i, start)) == INT16_MAX)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
if ((end = W_CheckNumForNamePwad("F_END", (UINT16)i, start)) == INT16_MAX)
|
||||
continue;
|
||||
break;
|
||||
case RET_PK3:
|
||||
if ((start = W_CheckNumForFolderStartPK3("Flats/", i, 0)) == INT16_MAX)
|
||||
continue;
|
||||
else if ((end = W_CheckNumForNamePwad("FF_END", (UINT16)i, start)) == INT16_MAX)
|
||||
if ((end = W_CheckNumForFolderEndPK3("Flats/", i, start)) == INT16_MAX)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
if ((end = W_CheckNumForNamePwad("F_END", (UINT16)i, start)) == INT16_MAX)
|
||||
continue;
|
||||
break;
|
||||
case RET_PK3:
|
||||
if ((start = W_CheckNumForFolderStartPK3("Flats/", i, 0)) == INT16_MAX)
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
if ((end = W_CheckNumForFolderEndPK3("Flats/", i, start)) == INT16_MAX)
|
||||
continue;
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
// Now find lump with specified name in that range.
|
||||
@@ -1310,6 +1312,7 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3)
|
||||
{
|
||||
if (foundcolormaps[i] != LUMPERROR)
|
||||
continue;
|
||||
|
||||
if (maskcolor == extra_colormaps[i].maskcolor
|
||||
&& fadecolor == extra_colormaps[i].fadecolor
|
||||
&& fabs(maskamt - extra_colormaps[i].maskamt) < DBL_EPSILON
|
||||
|
||||
+2
-9
@@ -648,16 +648,9 @@ typedef struct
|
||||
INT16 height;
|
||||
INT16 leftoffset; // pixels to the left of origin
|
||||
INT16 topoffset; // pixels below the origin
|
||||
INT32 columnofs[8]; // only [width] used
|
||||
UINT8 *columns; // Software column data
|
||||
INT32 columnofs[]; // only [width] used
|
||||
// the [0] is &columnofs[width]
|
||||
|
||||
void *hardware; // OpenGL patch, allocated whenever necessary
|
||||
|
||||
#ifdef ROTSPRITE
|
||||
rotsprite_t *rotated; // Rotated patches
|
||||
#endif
|
||||
} patch_t;
|
||||
}ATTRPACK patch_t;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4200)
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@ UINT32 nflatxshift, nflatyshift, nflatshiftup, nflatmask;
|
||||
#define NUM_PALETTE_ENTRIES 256
|
||||
|
||||
static UINT8** translationtablecache[TT_CACHE_SIZE] = {NULL};
|
||||
static UINT8** localtranslationtablecache[MAXSKINS] = {NULL};
|
||||
static UINT8** localtranslationtablecache[MAXLOCALSKINS] = {NULL};
|
||||
|
||||
|
||||
// See also the enum skincolors_t
|
||||
|
||||
+3
-3
@@ -943,7 +943,7 @@ void R_DrawTiltedTranslucentWaterSpan_8(void)
|
||||
|
||||
// Lighting is simple. It's just linear interpolation from start to end
|
||||
{
|
||||
float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f;
|
||||
float planelightfloat = PLANELIGHTFLOAT;
|
||||
float lightstart, lightend;
|
||||
|
||||
lightend = (iz + ds_szp->x*width) * planelightfloat;
|
||||
@@ -1696,7 +1696,7 @@ void R_DrawColumnShadowed_8(void)
|
||||
{
|
||||
dc_colormap = dc_lightlist[i].rcolormap;
|
||||
if (encoremap)
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
if (solid && dc_yl < bheight)
|
||||
dc_yl = bheight;
|
||||
continue;
|
||||
@@ -1714,7 +1714,7 @@ void R_DrawColumnShadowed_8(void)
|
||||
|
||||
dc_colormap = dc_lightlist[i].rcolormap;
|
||||
if (encoremap)
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
}
|
||||
dc_yh = realyh;
|
||||
if (dc_yl <= realyh)
|
||||
|
||||
+24
-56
@@ -23,8 +23,6 @@
|
||||
#include "r_state.h"
|
||||
#include "z_zone.h"
|
||||
#include "console.h" // con_startup_loadprogress
|
||||
#include "i_time.h"
|
||||
|
||||
#ifdef HWRENDER
|
||||
#include "hardware/hw_main.h" // for cv_grshearing
|
||||
#endif
|
||||
@@ -82,7 +80,6 @@ static viewvars_t skyview_old[MAXSPLITSCREENPLAYERS];
|
||||
static viewvars_t skyview_new[MAXSPLITSCREENPLAYERS];
|
||||
|
||||
static viewvars_t *oldview = &pview_old[0];
|
||||
static tic_t last_view_update;
|
||||
static int oldview_invalid[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0};
|
||||
viewvars_t *newview = &pview_new[0];
|
||||
|
||||
@@ -203,27 +200,21 @@ void R_UpdateViewInterpolation(void)
|
||||
|
||||
if (oldview_invalid[i]) oldview_invalid[i]--;
|
||||
}
|
||||
|
||||
last_view_update = I_GetTime();
|
||||
}
|
||||
|
||||
void R_ResetViewInterpolation(UINT8 p)
|
||||
{
|
||||
// Wait an extra tic if the interpolation state hasn't
|
||||
// updated yet.
|
||||
int t = last_view_update == I_GetTime() ? 1 : 2;
|
||||
|
||||
if (p == 0)
|
||||
{
|
||||
UINT8 i;
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
{
|
||||
oldview_invalid[i] = t;
|
||||
oldview_invalid[i]++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
oldview_invalid[p - 1] = t;
|
||||
oldview_invalid[p - 1]++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,6 +278,11 @@ angle_t R_InterpolateAngle(angle_t from, angle_t to)
|
||||
return (R_LerpAngle(from, to, rendertimefrac));
|
||||
}*/
|
||||
|
||||
#define IFCHANGED(a, b)\
|
||||
if (mobj->a == mobj->b)\
|
||||
(out->a = mobj->b);\
|
||||
else
|
||||
|
||||
void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out)
|
||||
{
|
||||
if (frac == FRACUNIT)
|
||||
@@ -308,44 +304,28 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out)
|
||||
return;
|
||||
}
|
||||
|
||||
if (mobj->x == mobj->old_x)
|
||||
out->x = mobj->x;
|
||||
else
|
||||
IFCHANGED(x, old_x)
|
||||
out->x = R_LerpFixed(mobj->old_x, mobj->x, frac);
|
||||
|
||||
if (mobj->y == mobj->old_y)
|
||||
out->y = mobj->y;
|
||||
else
|
||||
IFCHANGED(y, old_y)
|
||||
out->y = R_LerpFixed(mobj->old_y, mobj->y, frac);
|
||||
|
||||
if (mobj->z == mobj->old_z)
|
||||
out->z = mobj->z;
|
||||
else
|
||||
IFCHANGED(z, old_z)
|
||||
out->z = R_LerpFixed(mobj->old_z, mobj->z, frac);
|
||||
|
||||
if (mobj->spritexscale == mobj->old_spritexscale)
|
||||
out->spritexscale = mobj->spritexscale;
|
||||
else
|
||||
IFCHANGED(spritexscale, old_spritexscale)
|
||||
out->spritexscale = mobj->resetinterp ? mobj->spritexscale : R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac);
|
||||
|
||||
if (mobj->spriteyscale == mobj->old_spriteyscale)
|
||||
out->spriteyscale = mobj->spriteyscale;
|
||||
else
|
||||
IFCHANGED(spriteyscale, old_spriteyscale)
|
||||
out->spriteyscale = mobj->resetinterp ? mobj->spriteyscale : R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac);
|
||||
|
||||
if (mobj->spritexoffset == mobj->old_spritexoffset)
|
||||
out->spritexoffset = mobj->spritexoffset;
|
||||
else
|
||||
IFCHANGED(spritexoffset, old_spritexoffset)
|
||||
out->spritexoffset = mobj->resetinterp ? mobj->spritexoffset : R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac);
|
||||
|
||||
if (mobj->spriteyoffset == mobj->old_spriteyoffset)
|
||||
out->spriteyoffset = mobj->spriteyoffset;
|
||||
else
|
||||
IFCHANGED(spriteyoffset, old_spriteyoffset)
|
||||
out->spriteyoffset = mobj->resetinterp ? mobj->spriteyoffset : R_LerpFixed(mobj->old_spriteyoffset, mobj->spriteyoffset, frac);
|
||||
|
||||
if (mobj->scale == mobj->old_scale) // Tiny optimisation - scale is usually unchanging, so let's skip a lerp, two FixedMuls, and two FixedDivs
|
||||
out->scale = mobj->scale;
|
||||
else
|
||||
IFCHANGED(scale, old_scale)
|
||||
out->scale = mobj->resetinterp ? mobj->scale : R_LerpFixed(mobj->old_scale, mobj->scale, frac);
|
||||
|
||||
if (cv_mobjssector.value)
|
||||
@@ -355,39 +335,27 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out)
|
||||
|
||||
if (mobj->player)
|
||||
{
|
||||
if (mobj->angle == mobj->player->old_frameangle)
|
||||
out->angle = mobj->player->frameangle;
|
||||
else
|
||||
IFCHANGED(angle, player->old_frameangle)
|
||||
out->angle = mobj->resetinterp ? mobj->player->frameangle : R_LerpAngle(mobj->player->old_frameangle, mobj->player->frameangle, frac);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mobj->angle == mobj->old_angle)
|
||||
out->angle = mobj->angle;
|
||||
else
|
||||
IFCHANGED(angle, old_angle)
|
||||
out->angle = mobj->resetinterp ? mobj->angle : R_LerpAngle(mobj->old_angle, mobj->angle, frac);
|
||||
}
|
||||
|
||||
// pitch roll stuff
|
||||
if (mobj->pitch == mobj->old_pitch)
|
||||
out->pitch = mobj->pitch;
|
||||
else
|
||||
IFCHANGED(pitch, old_pitch)
|
||||
out->pitch = mobj->resetinterp ? mobj->pitch : R_LerpAngle(mobj->old_pitch, mobj->pitch, frac);
|
||||
|
||||
if (mobj->roll == mobj->old_roll)
|
||||
out->roll = mobj->roll;
|
||||
else
|
||||
IFCHANGED(roll, old_roll)
|
||||
out->roll = mobj->resetinterp ? mobj->roll : R_LerpAngle(mobj->old_roll, mobj->roll, frac);
|
||||
|
||||
// and the slope stuff
|
||||
if (mobj->slopepitch == mobj->old_slopepitch)
|
||||
out->slopepitch = mobj->slopepitch;
|
||||
else
|
||||
IFCHANGED(slopepitch, old_slopepitch)
|
||||
out->slopepitch = mobj->resetinterp ? mobj->slopepitch : R_LerpAngle(mobj->old_slopepitch, mobj->slopepitch, frac);
|
||||
|
||||
if (mobj->sloperoll == mobj->old_sloperoll)
|
||||
out->sloperoll = mobj->sloperoll;
|
||||
else
|
||||
IFCHANGED(sloperoll, old_sloperoll)
|
||||
out->sloperoll = mobj->resetinterp ? mobj->sloperoll : R_LerpAngle(mobj->old_sloperoll, mobj->sloperoll, frac);
|
||||
}
|
||||
|
||||
@@ -422,12 +390,12 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst
|
||||
else
|
||||
out->subsector = mobj->subsector;
|
||||
|
||||
if (mobj->angle == mobj->old_angle)
|
||||
out->angle = mobj->angle;
|
||||
else
|
||||
IFCHANGED(angle, old_angle)
|
||||
out->angle = R_LerpAngle(mobj->old_angle, mobj->angle, frac);
|
||||
}
|
||||
|
||||
#undef IFCHANGED
|
||||
|
||||
static void AddInterpolator(levelinterpolator_t* interpolator)
|
||||
{
|
||||
if (levelinterpolators_len >= levelinterpolators_size)
|
||||
|
||||
+10
-10
@@ -1687,11 +1687,11 @@ void R_RenderPlayerView(player_t *player)
|
||||
// load previous saved value of skyVisible for the player
|
||||
for (i = 0; i <= splitscreen; i++)
|
||||
{
|
||||
if (player == &players[displayplayers[i]])
|
||||
{
|
||||
skyVisible = skyVisiblePerPlayer[i];
|
||||
break;
|
||||
}
|
||||
if (player != &players[displayplayers[i]])
|
||||
continue;
|
||||
|
||||
skyVisible = skyVisiblePerPlayer[i];
|
||||
break;
|
||||
}
|
||||
|
||||
portalrender = 0;
|
||||
@@ -1814,11 +1814,11 @@ void R_RenderPlayerView(player_t *player)
|
||||
// this is so that P1 can't affect whether P2 can see a skybox or not, or vice versa
|
||||
for (i = 0; i <= splitscreen; i++)
|
||||
{
|
||||
if (player == &players[displayplayers[i]])
|
||||
{
|
||||
skyVisiblePerPlayer[i] = skyVisible;
|
||||
break;
|
||||
}
|
||||
if (player != &players[displayplayers[i]])
|
||||
continue;
|
||||
|
||||
skyVisiblePerPlayer[i] = skyVisible;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,9 @@ extern lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ];
|
||||
// There a 0-31, i.e. 32 LUT in the COLORMAP lump.
|
||||
#define NUMCOLORMAPS 32
|
||||
|
||||
#define COLORMAP_SIZE (256*LIGHTLEVELS)
|
||||
#define COLORMAP_REMAPOFFSET COLORMAP_SIZE
|
||||
|
||||
// Utility functions.
|
||||
INT32 R_PointOnSide(fixed_t x, fixed_t y, const node_t *node);
|
||||
INT32 R_PointOnSegSide(fixed_t x, fixed_t y, const seg_t *line);
|
||||
|
||||
+14
-18
@@ -48,8 +48,8 @@ boolean R_CheckIfPatch(lumpnum_t lump)
|
||||
|
||||
patch = (patch_t *)W_CacheLumpNum(lump, PU_STATIC);
|
||||
|
||||
width = patch->width;
|
||||
height = patch->height;
|
||||
width = SHORT(patch->width);
|
||||
height = SHORT(patch->height);
|
||||
|
||||
result = (height > 0 && height <= 16384 && width > 0 && width <= 16384 && width < (INT16)(size / 4));
|
||||
|
||||
@@ -772,6 +772,17 @@ static UINT16 GetPatchPixel(patch_t *patch, INT32 x, INT32 y, boolean flip)
|
||||
return 0xFF00;
|
||||
}
|
||||
|
||||
#ifdef HWRENDER
|
||||
static patch_t *R_CreateHardwarePatch(patch_t *patch)
|
||||
{
|
||||
GLPatch_t *grPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL);
|
||||
grPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL);
|
||||
grPatch->rawpatch = patch;
|
||||
HWR_MakePatch(patch, grPatch, grPatch->mipmap, false);
|
||||
return (patch_t *)grPatch;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ROTSPRITE
|
||||
//
|
||||
// R_GetRollAngle
|
||||
@@ -792,11 +803,7 @@ INT32 R_GetRollAngle(angle_t rollangle)
|
||||
return ra;
|
||||
}
|
||||
|
||||
patch_t *Patch_GetRotatedSprite(
|
||||
spriteframe_t *sprite,
|
||||
size_t frame, size_t spriteangle,
|
||||
boolean flip, boolean adjustfeet,
|
||||
void *info, INT32 rotationangle)
|
||||
patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spriteangle, boolean flip, boolean adjustfeet, void *info, INT32 rotationangle)
|
||||
{
|
||||
rotsprite_t *rotsprite;
|
||||
spriteinfo_t *sprinfo = (spriteinfo_t *)info;
|
||||
@@ -882,17 +889,6 @@ static void RotatedPatch_CalculateDimensions(
|
||||
*newheight = max(height, max(h1, h2));
|
||||
}
|
||||
|
||||
#ifdef HWRENDER
|
||||
static patch_t *R_CreateHardwarePatch(patch_t *patch)
|
||||
{
|
||||
GLPatch_t *grPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL);
|
||||
grPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL);
|
||||
grPatch->rawpatch = patch;
|
||||
HWR_MakePatch(patch, grPatch, grPatch->mipmap, false);
|
||||
return (patch_t *)grPatch;
|
||||
}
|
||||
#endif
|
||||
|
||||
void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip)
|
||||
{
|
||||
UINT32 i;
|
||||
|
||||
+24
-26
@@ -295,7 +295,7 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2)
|
||||
ds_colormap = planezlight[pindex];
|
||||
}
|
||||
if (encoremap && !currentplane->noencore)
|
||||
ds_colormap += (256*32);
|
||||
ds_colormap += COLORMAP_REMAPOFFSET;
|
||||
|
||||
if (currentplane->extra_colormap)
|
||||
ds_colormap = currentplane->extra_colormap->colormap + (ds_colormap - colormaps);
|
||||
@@ -674,25 +674,26 @@ static void R_DrawSkyPlane(visplane_t *pl)
|
||||
// Because of this hack, sky is not affected
|
||||
// by INVUL inverse mapping.
|
||||
dc_colormap = colormaps;
|
||||
|
||||
if (encoremap)
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
|
||||
dc_texturemid = skytexturemid;
|
||||
dc_texheight = textureheight[skytexture]
|
||||
>>FRACBITS;
|
||||
dc_texheight = textureheight[skytexture] >>FRACBITS;
|
||||
|
||||
for (x = pl->minx; x <= pl->maxx; x++)
|
||||
{
|
||||
dc_yl = pl->top[x];
|
||||
dc_yh = pl->bottom[x];
|
||||
if (dc_yl <= dc_yh)
|
||||
{
|
||||
angle = (pl->viewangle + xtoviewangle[x])>>ANGLETOSKYSHIFT;
|
||||
dc_iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x]>>ANGLETOFINESHIFT));
|
||||
dc_x = x;
|
||||
dc_source =
|
||||
R_GetColumn(texturetranslation[skytexture],
|
||||
angle);
|
||||
wallcolfunc();
|
||||
}
|
||||
|
||||
if (!(dc_yl <= dc_yh))
|
||||
continue;
|
||||
|
||||
angle = (pl->viewangle + xtoviewangle[x])>>ANGLETOSKYSHIFT;
|
||||
dc_iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x]>>ANGLETOFINESHIFT));
|
||||
dc_x = x;
|
||||
dc_source = R_GetColumn(texturetranslation[skytexture], angle);
|
||||
wallcolfunc();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -839,18 +840,15 @@ void R_DrawSinglePlane(visplane_t *pl)
|
||||
// Don't draw planes that shouldn't be drawn.
|
||||
for (rover = pl->ffloor->target->ffloors; rover; rover = rover->next)
|
||||
{
|
||||
if ((pl->ffloor->flags & FF_CUTEXTRA) && (rover->flags & FF_EXTRA))
|
||||
{
|
||||
if (pl->ffloor->flags & FF_EXTRA)
|
||||
{
|
||||
// The plane is from an extra 3D floor... Check the flags so
|
||||
// there are no undesired cuts.
|
||||
if (((pl->ffloor->flags & (FF_FOG|FF_SWIMMABLE)) == (rover->flags & (FF_FOG|FF_SWIMMABLE)))
|
||||
&& pl->height < *rover->topheight
|
||||
&& pl->height > *rover->bottomheight)
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!((pl->ffloor->flags & FF_CUTEXTRA) && (rover->flags & FF_EXTRA)))
|
||||
continue;
|
||||
|
||||
// The plane is from an extra 3D floor... Check the flags so
|
||||
// there are no undesired cuts.
|
||||
if (((pl->ffloor->flags & (FF_FOG|FF_SWIMMABLE)) == (rover->flags & (FF_FOG|FF_SWIMMABLE)))
|
||||
&& pl->height < *rover->topheight
|
||||
&& pl->height > *rover->bottomheight)
|
||||
return;
|
||||
}
|
||||
|
||||
if (pl->ffloor->flags & FF_TRANSLUCENT)
|
||||
|
||||
+11
-10
@@ -208,7 +208,7 @@ static void R_DrawWallSplats(void)
|
||||
pindex = MAXLIGHTSCALE - 1;
|
||||
dc_colormap = walllights[pindex];
|
||||
if (encoremap && !(seg->linedef->flags & ML_TFERLINE))
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
|
||||
if (frontsector->extra_colormap)
|
||||
dc_colormap = frontsector->extra_colormap->colormap + (dc_colormap - colormaps);
|
||||
@@ -496,7 +496,6 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dc_texheight = textureheight[texnum]>>FRACBITS;
|
||||
|
||||
// draw the columns
|
||||
@@ -573,7 +572,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
|
||||
{
|
||||
dc_colormap = rlight->rcolormap;
|
||||
if (encoremap && !(ldef->flags & ML_TFERLINE))
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -594,7 +593,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
|
||||
windowtop = windowbottom + 1;
|
||||
dc_colormap = rlight->rcolormap;
|
||||
if (encoremap && !(ldef->flags & ML_TFERLINE))
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
}
|
||||
windowbottom = realbot;
|
||||
if (windowtop < windowbottom)
|
||||
@@ -612,7 +611,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
|
||||
|
||||
dc_colormap = walllights[pindex];
|
||||
if (encoremap && !(ldef->flags & ML_TFERLINE))
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
|
||||
if (frontsector->extra_colormap)
|
||||
dc_colormap = frontsector->extra_colormap->colormap + (dc_colormap - colormaps);
|
||||
@@ -983,7 +982,9 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
|
||||
// draw the columns
|
||||
for (dc_x = x1; dc_x <= x2; dc_x++)
|
||||
{
|
||||
if (maskedtexturecol[dc_x] != INT16_MAX)
|
||||
if (maskedtexturecol[dc_x] == INT16_MAX)
|
||||
continue;
|
||||
|
||||
{
|
||||
if (ffloortextureslide) { // skew FOF walls
|
||||
if (oldx != -1)
|
||||
@@ -1107,7 +1108,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
|
||||
{
|
||||
dc_colormap = rlight->rcolormap;
|
||||
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
}
|
||||
if (solid && windowtop < bheight)
|
||||
windowtop = bheight;
|
||||
@@ -1139,7 +1140,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
|
||||
{
|
||||
dc_colormap = rlight->rcolormap;
|
||||
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
}
|
||||
}
|
||||
windowbottom = sprbotscreen;
|
||||
@@ -1160,7 +1161,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
|
||||
dc_colormap = walllights[pindex];
|
||||
|
||||
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
|
||||
if (pfloor->flags & FF_FOG && pfloor->master->frontsector->extra_colormap)
|
||||
dc_colormap = pfloor->master->frontsector->extra_colormap->colormap + (dc_colormap - colormaps);
|
||||
@@ -1396,7 +1397,7 @@ static void R_RenderSegLoop (void)
|
||||
|
||||
dc_colormap = walllights[pindex];
|
||||
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
dc_x = rw_x;
|
||||
dc_iscale = 0xffffffffu / (unsigned)rw_scale;
|
||||
|
||||
|
||||
+234
-171
@@ -152,7 +152,6 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch
|
||||
}
|
||||
#endif/*ROTSPRITE*/
|
||||
|
||||
|
||||
if (rotation == 0)
|
||||
{
|
||||
// the lump should be used for all rotations
|
||||
@@ -276,58 +275,50 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef,
|
||||
|
||||
for (l = startlump; l < endlump; l++)
|
||||
{
|
||||
if (memcmp(lumpinfo[l].name,sprname,4)==0)
|
||||
if (memcmp(lumpinfo[l].name,sprname,4))
|
||||
continue;
|
||||
|
||||
frame = R_Char2Frame(lumpinfo[l].name[4]);
|
||||
rotation = (UINT8)(lumpinfo[l].name[5] - '0');
|
||||
|
||||
if (frame >= 64 || !(R_ValidSpriteAngle(rotation))) // Give an actual NAME error -_-...
|
||||
{
|
||||
frame = R_Char2Frame(lumpinfo[l].name[4]);
|
||||
rotation = (UINT8)(lumpinfo[l].name[5] - '0');
|
||||
|
||||
if (frame >= 64 || !(R_ValidSpriteAngle(rotation))) // Give an actual NAME error -_-...
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Bad sprite name: %s\n"), W_CheckNameForNumPwad(wadnum,l));
|
||||
continue;
|
||||
}
|
||||
|
||||
// skip NULL sprites from very old dmadds pwads
|
||||
if (W_LumpLengthPwad(wadnum,l)<=8)
|
||||
continue;
|
||||
|
||||
// store sprite info in lookup tables
|
||||
//FIXME : numspritelumps do not duplicate sprite replacements
|
||||
W_ReadLumpHeaderPwad(wadnum, l, &patch, sizeof (patch_t), 0);
|
||||
spritecachedinfo[numspritelumps].width = SHORT(patch.width)<<FRACBITS;
|
||||
spritecachedinfo[numspritelumps].offset = SHORT(patch.leftoffset)<<FRACBITS;
|
||||
spritecachedinfo[numspritelumps].topoffset = SHORT(patch.topoffset)<<FRACBITS;
|
||||
spritecachedinfo[numspritelumps].height = SHORT(patch.height)<<FRACBITS;
|
||||
|
||||
//BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer
|
||||
if (rendermode != render_none) // not for psprite
|
||||
spritecachedinfo[numspritelumps].topoffset += 4<<FRACBITS;
|
||||
|
||||
// Being selective with this causes bad things. :( Like the special stage tokens breaking apart.
|
||||
/*if (rendermode != render_none // not for psprite
|
||||
&& SHORT(patch.topoffset)>0 && SHORT(patch.topoffset)<SHORT(patch.height))
|
||||
// perfect is patch.height but sometime it is too high
|
||||
spritecachedinfo[numspritelumps].topoffset = min(SHORT(patch.topoffset)+4,SHORT(patch.height))<<FRACBITS;*/
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
R_InstallSpriteLump(wadnum, l, numspritelumps, frame, rotation, 0);
|
||||
|
||||
if (lumpinfo[l].name[6])
|
||||
{
|
||||
frame = R_Char2Frame(lumpinfo[l].name[6]);
|
||||
rotation = (UINT8)(lumpinfo[l].name[7] - '0');
|
||||
R_InstallSpriteLump(wadnum, l, numspritelumps, frame, rotation, 1);
|
||||
}
|
||||
|
||||
if (++numspritelumps >= max_spritelumps)
|
||||
{
|
||||
max_spritelumps *= 2;
|
||||
Z_Realloc(spritecachedinfo, max_spritelumps*sizeof(*spritecachedinfo), PU_STATIC, &spritecachedinfo);
|
||||
}
|
||||
|
||||
++numadded;
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Bad sprite name: %s\n"), W_CheckNameForNumPwad(wadnum,l));
|
||||
continue;
|
||||
}
|
||||
|
||||
// skip NULL sprites from very old dmadds pwads
|
||||
if (W_LumpLengthPwad(wadnum,l)<=8)
|
||||
continue;
|
||||
|
||||
// store sprite info in lookup tables
|
||||
//FIXME : numspritelumps do not duplicate sprite replacements
|
||||
W_ReadLumpHeaderPwad(wadnum, l, &patch, sizeof (patch_t), 0);
|
||||
spritecachedinfo[numspritelumps].width = SHORT(patch.width)<<FRACBITS;
|
||||
spritecachedinfo[numspritelumps].offset = SHORT(patch.leftoffset)<<FRACBITS;
|
||||
spritecachedinfo[numspritelumps].topoffset = SHORT(patch.topoffset)<<FRACBITS;
|
||||
spritecachedinfo[numspritelumps].height = SHORT(patch.height)<<FRACBITS;
|
||||
|
||||
//BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer
|
||||
if (rendermode != render_none) // not for psprite
|
||||
spritecachedinfo[numspritelumps].topoffset += FEETADJUST;
|
||||
|
||||
R_InstallSpriteLump(wadnum, l, numspritelumps, frame, rotation, 0);
|
||||
|
||||
if (lumpinfo[l].name[6])
|
||||
{
|
||||
frame = R_Char2Frame(lumpinfo[l].name[6]);
|
||||
rotation = (UINT8)(lumpinfo[l].name[7] - '0');
|
||||
R_InstallSpriteLump(wadnum, l, numspritelumps, frame, rotation, 1);
|
||||
}
|
||||
|
||||
if (++numspritelumps >= max_spritelumps)
|
||||
{
|
||||
max_spritelumps *= 2;
|
||||
Z_Realloc(spritecachedinfo, max_spritelumps*sizeof(*spritecachedinfo), PU_STATIC, &spritecachedinfo);
|
||||
}
|
||||
|
||||
++numadded;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -456,6 +447,7 @@ void R_AddSpriteDefs(UINT16 wadnum)
|
||||
for (i = 0; i < numsprites; i++)
|
||||
{
|
||||
spritename = sprnames[i];
|
||||
|
||||
if (spritename[4] && wadnum >= (UINT16)spritename[4])
|
||||
continue;
|
||||
|
||||
@@ -578,10 +570,8 @@ static vissprite_t *R_GetVisSprite(UINT32 num)
|
||||
|
||||
static vissprite_t *R_NewVisSprite(void)
|
||||
{
|
||||
if (visspritecount == MAXVISSPRITES) {
|
||||
//CONS_Alert(CONS_ERROR, M_GetText("R_NewVisSprite: too many vissprites requested (maximum is %i)\n"), MAXVISSPRITES);
|
||||
if (visspritecount == MAXVISSPRITES)
|
||||
return &overflowsprite;
|
||||
}
|
||||
|
||||
return R_GetVisSprite(visspritecount++);
|
||||
}
|
||||
@@ -638,7 +628,7 @@ void R_DrawMaskedColumn(column_t *column)
|
||||
if (dc_yh >= vid.height)
|
||||
dc_yh = vid.height - 1;
|
||||
|
||||
if (dc_yl <= dc_yh && dc_yl < vid.height && dc_yh > 0)
|
||||
if (dc_yl <= dc_yh && dc_yh > 0)
|
||||
{
|
||||
dc_source = (UINT8 *)column + 3;
|
||||
dc_texturemid = basetexturemid - (topdelta<<FRACBITS);
|
||||
@@ -658,7 +648,7 @@ void R_DrawMaskedColumn(column_t *column)
|
||||
|
||||
INT32 lengthcol; // column->length : for flipped column function pointers and multi-patch on 2sided wall = texture->height
|
||||
|
||||
static void R_DrawFlippedMaskedColumn(column_t *column, INT32 texheight)
|
||||
static void R_DrawFlippedMaskedColumn(column_t *column)
|
||||
{
|
||||
INT32 topscreen;
|
||||
INT32 bottomscreen;
|
||||
@@ -674,11 +664,10 @@ static void R_DrawFlippedMaskedColumn(column_t *column, INT32 texheight)
|
||||
if (topdelta <= prevdelta)
|
||||
topdelta += prevdelta;
|
||||
prevdelta = topdelta;
|
||||
topdelta = texheight-column->length-topdelta;
|
||||
topdelta = lengthcol-column->length-topdelta;
|
||||
topscreen = sprtopscreen + spryscale*topdelta;
|
||||
bottomscreen = sprbotscreen == INT32_MAX ? topscreen + spryscale*column->length
|
||||
: sprbotscreen + spryscale*column->length;
|
||||
|
||||
dc_yl = (topscreen+FRACUNIT-1)>>FRACBITS;
|
||||
dc_yh = (bottomscreen-1)>>FRACBITS;
|
||||
|
||||
@@ -699,7 +688,7 @@ static void R_DrawFlippedMaskedColumn(column_t *column, INT32 texheight)
|
||||
if (dc_yh >= vid.height)
|
||||
dc_yh = vid.height - 1;
|
||||
|
||||
if (dc_yl <= dc_yh && dc_yl < vid.height && dc_yh > 0)
|
||||
if (dc_yl <= dc_yh && dc_yh > 0)
|
||||
{
|
||||
dc_source = ZZ_Alloc(column->length);
|
||||
for (s = (UINT8 *)column+2+column->length, d = dc_source; d < dc_source+column->length; --s)
|
||||
@@ -724,9 +713,9 @@ static void R_DrawFlippedMaskedColumn(column_t *column, INT32 texheight)
|
||||
static void R_DrawVisSprite(vissprite_t *vis)
|
||||
{
|
||||
column_t *column;
|
||||
#ifdef RANGECHECK
|
||||
void (*localcolfunc)(column_t *);
|
||||
INT32 texturecolumn;
|
||||
#endif
|
||||
INT32 pwidth;
|
||||
fixed_t frac;
|
||||
patch_t *patch = vis->patch;
|
||||
fixed_t this_scale = vis->thingscale;
|
||||
@@ -751,7 +740,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
|
||||
// TODO This check should not be necessary. But Papersprites near to the camera will sometimes create invalid values
|
||||
// for the vissprite's startfrac. This happens because they are not depth culled like other sprites.
|
||||
// Someone who is more familiar with papersprites pls check and try to fix <3
|
||||
if (vis->startfrac < 0 || vis->startfrac > (patch->width << FRACBITS))
|
||||
if (vis->startfrac < 0 || vis->startfrac > (SHORT(patch->width) << FRACBITS))
|
||||
{
|
||||
// never draw vissprites with startfrac out of patch range
|
||||
return;
|
||||
@@ -816,7 +805,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
|
||||
dc_colormap = colormaps;
|
||||
|
||||
if (encoremap && !vis->mobj->color && !(vis->mobj->flags & MF_DONTENCOREMAP))
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
|
||||
dc_texturemid = vis->texturemid;
|
||||
dc_texheight = 0;
|
||||
@@ -862,9 +851,6 @@ static void R_DrawVisSprite(vissprite_t *vis)
|
||||
if (vis->x2 >= vid.width)
|
||||
vis->x2 = vid.width-1;
|
||||
|
||||
lengthcol = SHORT(patch->height);
|
||||
|
||||
#if 1
|
||||
// Something is occasionally setting 1px-wide sprites whose frac is exactly the width of the sprite, causing crashes due to
|
||||
// accessing invalid column info. Until the cause is found, let's try to correct those manually...
|
||||
{
|
||||
@@ -872,35 +858,49 @@ static void R_DrawVisSprite(vissprite_t *vis)
|
||||
if (temp > 0)
|
||||
vis->x2 -= temp;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale)
|
||||
localcolfunc = (vis->vflip) ? R_DrawFlippedMaskedColumn : R_DrawMaskedColumn;
|
||||
lengthcol = patch->height;
|
||||
|
||||
// Split drawing loops for paper and non-paper to reduce conditional checks per sprite
|
||||
if (vis->scalestep)
|
||||
{
|
||||
fixed_t horzscale = FixedMul(vis->spritexscale, this_scale);
|
||||
fixed_t scalestep = FixedMul(vis->scalestep, vis->spriteyscale);
|
||||
if (vis->scalestep) // currently papersprites only
|
||||
pwidth = SHORT(patch->width);
|
||||
|
||||
// Papersprite drawing loop
|
||||
for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, spryscale += scalestep)
|
||||
{
|
||||
angle_t angle = ((vis->centerangle + xtoviewangle[dc_x]) >> ANGLETOFINESHIFT) & 0xFFF;
|
||||
texturecolumn = (vis->paperoffset - FixedMul(FINETANGENT(angle), vis->paperdistance)) / horzscale;
|
||||
|
||||
if (texturecolumn < 0 || texturecolumn >= pwidth)
|
||||
continue;
|
||||
|
||||
if (vis->xiscale < 0) // Flipped sprite
|
||||
texturecolumn = pwidth - 1 - texturecolumn;
|
||||
|
||||
#ifndef RANGECHECK
|
||||
if ((frac>>FRACBITS) < 0 || (frac>>FRACBITS) >= SHORT(patch->width)) // if this doesn't work i'm removing papersprites
|
||||
break;
|
||||
#endif
|
||||
sprtopscreen = (centeryfrac - FixedMul(dc_texturemid, spryscale));
|
||||
dc_iscale = (0xffffffffu / (unsigned)spryscale);
|
||||
spryscale += scalestep;
|
||||
}
|
||||
#ifdef RANGECHECK
|
||||
texturecolumn = frac>>FRACBITS;
|
||||
|
||||
if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width))
|
||||
I_Error("R_DrawSpriteRange: bad texturecolumn");
|
||||
column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn]));
|
||||
#else
|
||||
column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[frac>>FRACBITS]));
|
||||
#endif
|
||||
if (vis->vflip)
|
||||
R_DrawFlippedMaskedColumn(column, patch->height);
|
||||
else
|
||||
R_DrawMaskedColumn(column);
|
||||
column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn]));
|
||||
|
||||
localcolfunc (column);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pwidth = SHORT(patch->width);
|
||||
|
||||
// Non-paper drawing loop
|
||||
for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale)
|
||||
{
|
||||
texturecolumn = CLAMP(frac >> FRACBITS, 0, pwidth - 1);
|
||||
column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn]));
|
||||
|
||||
localcolfunc (column);
|
||||
}
|
||||
}
|
||||
|
||||
colfunc = basecolfunc;
|
||||
@@ -914,9 +914,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
|
||||
static void R_DrawPrecipitationVisSprite(vissprite_t *vis)
|
||||
{
|
||||
column_t *column;
|
||||
#ifdef RANGECHECK
|
||||
INT32 texturecolumn;
|
||||
#endif
|
||||
fixed_t frac;
|
||||
patch_t *patch;
|
||||
INT64 overflow_test;
|
||||
@@ -939,7 +937,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis)
|
||||
|
||||
dc_colormap = colormaps;
|
||||
if (encoremap)
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
|
||||
dc_iscale = FixedDiv(FRACUNIT, vis->scale);
|
||||
dc_texturemid = vis->texturemid;
|
||||
@@ -958,16 +956,9 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis)
|
||||
|
||||
for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale)
|
||||
{
|
||||
#ifdef RANGECHECK
|
||||
texturecolumn = frac>>FRACBITS;
|
||||
|
||||
if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width))
|
||||
I_Error("R_DrawPrecipitationSpriteRange: bad texturecolumn");
|
||||
|
||||
texturecolumn = CLAMP(frac >> FRACBITS, 0, SHORT(patch->width) - 1);
|
||||
column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn]));
|
||||
#else
|
||||
column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[frac>>FRACBITS]));
|
||||
#endif
|
||||
|
||||
R_DrawMaskedColumn(column);
|
||||
}
|
||||
|
||||
@@ -1055,8 +1046,9 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing)
|
||||
{
|
||||
lindex = FixedMul(sprite->xscale, LIGHTRESOLUTIONFIX)>>(LIGHTSCALESHIFT);
|
||||
|
||||
if (lindex >= MAXLIGHTSCALE)
|
||||
lindex = MAXLIGHTSCALE-1;
|
||||
// Mitigate against negative xscale and arithmetic overflow
|
||||
lindex = CLAMP(lindex, 0, MAXLIGHTSCALE - 1);
|
||||
|
||||
newsprite->colormap = spritelights[lindex];
|
||||
}
|
||||
}
|
||||
@@ -1132,6 +1124,7 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope)
|
||||
static void R_ProjectSprite(mobj_t *thing)
|
||||
{
|
||||
mobj_t *oldthing = thing;
|
||||
|
||||
fixed_t tr_x, tr_y;
|
||||
fixed_t gxt, gyt;
|
||||
fixed_t tx, tz;
|
||||
@@ -1148,7 +1141,6 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||
|
||||
size_t rot;
|
||||
UINT8 flip;
|
||||
/*boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !R_ThingVerticallyFlipped(thing));*/
|
||||
|
||||
boolean mirrored = thing->mirrored;
|
||||
boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored);
|
||||
@@ -1163,6 +1155,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||
fixed_t scalestep; // toast '16
|
||||
fixed_t offset, offset2;
|
||||
boolean papersprite = (thing->frame & FF_PAPERSPRITE);
|
||||
fixed_t paperoffset = 0, paperdistance = 0; angle_t centerangle = 0;
|
||||
|
||||
//SoM: 3/17/2000
|
||||
fixed_t gz, gzt;
|
||||
@@ -1174,6 +1167,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||
// rotsprite
|
||||
fixed_t spr_width, spr_height;
|
||||
fixed_t spr_offset, spr_topoffset;
|
||||
|
||||
#ifdef ROTSPRITE
|
||||
patch_t *rotsprite = NULL;
|
||||
INT32 rollangle = 0;
|
||||
@@ -1181,8 +1175,6 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||
angle_t pitchnroll = 0;
|
||||
angle_t sliptiderollangle = 0;
|
||||
#endif
|
||||
|
||||
fixed_t ang_scale = FRACUNIT;
|
||||
|
||||
INT32 dist = -1;
|
||||
|
||||
@@ -1214,7 +1206,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||
tz = gxt-gyt;
|
||||
|
||||
// thing is behind view plane?
|
||||
if (!(papersprite) && (tz < FixedMul(MINZ, this_scale))) // papersprite clipping is handled later
|
||||
if (!papersprite && (tz < FixedMul(MINZ, this_scale))) // papersprite clipping is handled later
|
||||
return;
|
||||
|
||||
gxt = -FixedMul(tr_x, viewsin);
|
||||
@@ -1285,14 +1277,9 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||
{
|
||||
ang = R_PointToAngle (interp.x, interp.y) - interp.angle;
|
||||
camang = R_PointToAngle (interp.x, interp.y);
|
||||
}
|
||||
|
||||
if (sprframe->rotate != SRF_SINGLE || papersprite)
|
||||
{
|
||||
|
||||
if (mirrored)
|
||||
ang = InvAngle(ang);
|
||||
if (papersprite)
|
||||
ang_scale = abs(FINESINE(ang>>ANGLETOFINESHIFT));
|
||||
}
|
||||
|
||||
if (sprframe->rotate == SRF_SINGLE)
|
||||
@@ -1375,8 +1362,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||
rollsum += thing->rollangle;
|
||||
|
||||
rollangle = R_GetRollAngle(rollsum);
|
||||
rotsprite = Patch_GetRotatedSprite(
|
||||
sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle);
|
||||
rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle);
|
||||
|
||||
if (rotsprite != NULL)
|
||||
{
|
||||
@@ -1393,10 +1379,11 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||
}
|
||||
#endif
|
||||
|
||||
flip = !flip != !hflip;
|
||||
|
||||
// calculate edges of the shape
|
||||
spritexscale = interp.spritexscale;
|
||||
spriteyscale = interp.spriteyscale;
|
||||
|
||||
if (spritexscale < 1 || spriteyscale < 1)
|
||||
return;
|
||||
|
||||
@@ -1415,39 +1402,19 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||
spr_offset += interp.spritexoffset * flipoffset;
|
||||
spr_topoffset += interp.spriteyoffset * flipoffset;
|
||||
}
|
||||
|
||||
flip = !flip != !hflip;
|
||||
|
||||
if (flip)
|
||||
offset = spr_offset - spr_width;
|
||||
else
|
||||
offset = -spr_offset;
|
||||
|
||||
//offset = FixedMul(offset, FixedMul(spritexscale, this_scale));
|
||||
//offset2 = FixedMul(spr_width, FixedMul(spritexscale, this_scale)); // OH GOD I'M REVOOOOORTINGGGG AHHHHHHH
|
||||
|
||||
offset = FixedMul(offset, FixedMul(spritexscale, this_scale));
|
||||
tx += FixedMul(offset, ang_scale);
|
||||
x1 = (centerxfrac + FixedMul (tx,xscale)) >>FRACBITS;
|
||||
|
||||
// off the right side?
|
||||
if (x1 > viewwidth)
|
||||
return;
|
||||
|
||||
offset2 = FixedMul(spr_width, FixedMul(spritexscale, this_scale));
|
||||
tx += FixedMul(offset2, ang_scale);
|
||||
x2 = ((centerxfrac + FixedMul (tx,xscale)) >> FRACBITS) - 1;
|
||||
|
||||
// off the left side
|
||||
if (x2 < 0)
|
||||
return;
|
||||
|
||||
if (papersprite)
|
||||
{
|
||||
fixed_t yscale2, cosmul, sinmul, tz2;
|
||||
|
||||
if (x2 <= x1)
|
||||
return;
|
||||
fixed_t xscale2, yscale2, cosmul, sinmul, tx2, tz2;
|
||||
INT32 range;
|
||||
|
||||
if (ang >= ANGLE_180)
|
||||
{
|
||||
@@ -1464,7 +1431,22 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||
gyt = -FixedMul(tr_y, viewsin);
|
||||
tz = gxt-gyt;
|
||||
yscale = FixedDiv(projectiony, tz);
|
||||
if (yscale < 64) return; // Fix some funky visuals
|
||||
|
||||
gxt = -FixedMul(tr_x, viewsin);
|
||||
gyt = FixedMul(tr_y, viewcos);
|
||||
tx = -(gyt + gxt);
|
||||
xscale = FixedDiv(projection, tz);
|
||||
x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS;
|
||||
|
||||
// Get paperoffset (offset) and paperoffset (distance)
|
||||
paperoffset = -FixedMul(tr_x, cosmul) - FixedMul(tr_y, sinmul);
|
||||
paperdistance = -FixedMul(tr_x, sinmul) + FixedMul(tr_y, cosmul);
|
||||
if (paperdistance < 0)
|
||||
{
|
||||
paperoffset = -paperoffset;
|
||||
paperdistance = -paperdistance;
|
||||
}
|
||||
centerangle = viewangle - interp.angle;
|
||||
|
||||
tr_x += FixedMul(offset2, cosmul);
|
||||
tr_y += FixedMul(offset2, sinmul);
|
||||
@@ -1472,14 +1454,72 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||
gyt = -FixedMul(tr_y, viewsin);
|
||||
tz2 = gxt-gyt;
|
||||
yscale2 = FixedDiv(projectiony, tz2);
|
||||
if (yscale2 < 64) return; // ditto
|
||||
//if (yscale2 < 64) return; // ditto
|
||||
|
||||
gxt = -FixedMul(tr_x, viewsin);
|
||||
gyt = FixedMul(tr_y, viewcos);
|
||||
tx2 = -(gyt + gxt);
|
||||
xscale2 = FixedDiv(projection, tz2);
|
||||
x2 = ((centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS);
|
||||
|
||||
if (max(tz, tz2) < FixedMul(MINZ, this_scale)) // non-papersprite clipping is handled earlier
|
||||
return;
|
||||
|
||||
scalestep = (yscale2 - yscale)/(x2 - x1);
|
||||
scalestep = scalestep ? scalestep : 1;
|
||||
// Needs partially clipped
|
||||
if (tz < FixedMul(MINZ, this_scale))
|
||||
{
|
||||
fixed_t div = FixedDiv(tz2-tz, FixedMul(MINZ, this_scale)-tz);
|
||||
tx += FixedDiv(tx2-tx, div);
|
||||
tz = FixedMul(MINZ, this_scale);
|
||||
}
|
||||
else if (tz2 < FixedMul(MINZ, this_scale))
|
||||
{
|
||||
fixed_t div = FixedDiv(tz-tz2, FixedMul(MINZ, this_scale)-tz2);
|
||||
tx2 += FixedDiv(tx-tx2, div);
|
||||
tz2 = FixedMul(MINZ, this_scale);
|
||||
}
|
||||
|
||||
if ((tx2 / 4) < -(FixedMul(tz2, fovtan)) || (tx / 4) > FixedMul(tz, fovtan)) // too far off the side?
|
||||
return;
|
||||
|
||||
yscale = FixedDiv(projectiony, tz);
|
||||
xscale = FixedDiv(projection, tz);
|
||||
|
||||
x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS;
|
||||
|
||||
// off the right side?
|
||||
if (x1 > viewwidth)
|
||||
return;
|
||||
|
||||
yscale2 = FixedDiv(projectiony, tz2);
|
||||
xscale2 = FixedDiv(projection, tz2);
|
||||
|
||||
x2 = (centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS;
|
||||
|
||||
// off the left side
|
||||
if (x2 < 0)
|
||||
return;
|
||||
|
||||
range = x2 - x1;
|
||||
|
||||
if (range < 0)
|
||||
return;
|
||||
|
||||
range++; // fencepost problem
|
||||
|
||||
if (range > 32767)
|
||||
{
|
||||
// If the range happens to be too large for fixed_t,
|
||||
// abort the draw to avoid xscale becoming negative due to arithmetic overflow.
|
||||
return;
|
||||
}
|
||||
|
||||
scalestep = ((yscale2 - yscale)/range) ?: 1;
|
||||
|
||||
if (scalestep == 0)
|
||||
scalestep = 1;
|
||||
|
||||
xscale = FixedDiv(range<<FRACBITS, abs(offset2));
|
||||
|
||||
// The following two are alternate sorting methods which might be more applicable in some circumstances. TODO - maybe enable via MF2?
|
||||
// sortscale = max(yscale, yscale2);
|
||||
@@ -1489,12 +1529,25 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||
{
|
||||
scalestep = 0;
|
||||
yscale = sortscale;
|
||||
tx += offset;
|
||||
//x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS;
|
||||
x1 = centerx + (FixedMul(tx,xscale) / FRACUNIT);
|
||||
|
||||
// off the right side?
|
||||
if (x1 > viewwidth)
|
||||
return;
|
||||
|
||||
tx += offset2;
|
||||
//x2 = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS); x2--;
|
||||
x2 = (centerx + (FixedMul(tx,xscale) / FRACUNIT)) - 1;
|
||||
|
||||
// off the left side
|
||||
if (x2 < 0)
|
||||
return;
|
||||
}
|
||||
|
||||
xscale = FixedMul(xscale, ang_scale);
|
||||
|
||||
// PORTAL SPRITE CLIPPING
|
||||
if (portalrender)
|
||||
if (portalrender && portalclipline)
|
||||
{
|
||||
if (x2 < portalclipstart || x1 > portalclipend)
|
||||
return;
|
||||
@@ -1555,16 +1608,13 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||
|
||||
if (heightsec != -1 && phs != -1) // only clip things which are in special sectors
|
||||
{
|
||||
fixed_t top = gzt;
|
||||
fixed_t bottom = interp.z;
|
||||
|
||||
if (viewz < sectors[phs].floorheight ?
|
||||
bottom >= sectors[heightsec].floorheight :
|
||||
top < sectors[heightsec].floorheight)
|
||||
interp.z >= sectors[heightsec].floorheight :
|
||||
gzt < sectors[heightsec].floorheight)
|
||||
return;
|
||||
if (viewz > sectors[phs].ceilingheight ?
|
||||
top < sectors[heightsec].ceilingheight && viewz >= sectors[heightsec].ceilingheight :
|
||||
bottom >= sectors[heightsec].ceilingheight)
|
||||
gzt < sectors[heightsec].ceilingheight && viewz >= sectors[heightsec].ceilingheight :
|
||||
interp.z >= sectors[heightsec].ceilingheight)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1585,12 +1635,24 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||
vis->pzt = vis->pz + vis->thingheight;
|
||||
vis->texturemid = FixedDiv(gzt - viewz, spriteyscale);
|
||||
vis->scalestep = scalestep;
|
||||
vis->paperoffset = paperoffset;
|
||||
vis->paperdistance = paperdistance;
|
||||
vis->centerangle = centerangle;
|
||||
|
||||
vis->mobj = thing; // Easy access! Tails 06-07-2002
|
||||
|
||||
vis->x1 = x1 < 0 ? 0 : x1;
|
||||
vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2;
|
||||
|
||||
// PORTAL SEMI-CLIPPING
|
||||
if (portalrender && portalclipline)
|
||||
{
|
||||
if (vis->x1 < portalclipstart)
|
||||
vis->x1 = portalclipstart;
|
||||
if (vis->x2 > portalclipend)
|
||||
vis->x2 = portalclipend;
|
||||
}
|
||||
|
||||
vis->sector = thing->subsector->sector;
|
||||
vis->szt = (INT16)((centeryfrac - FixedMul(vis->gzt - viewz, sortscale))>>FRACBITS);
|
||||
vis->sz = (INT16)((centeryfrac - FixedMul(vis->gz - viewz, sortscale))>>FRACBITS);
|
||||
@@ -1601,15 +1663,6 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||
else
|
||||
vis->extra_colormap = thing->subsector->sector->extra_colormap;
|
||||
|
||||
// PORTAL SEMI-CLIPPING
|
||||
if (portalrender)
|
||||
{
|
||||
if (vis->x1 < portalclipstart)
|
||||
vis->x1 = portalclipstart;
|
||||
if (vis->x2 > portalclipend)
|
||||
vis->x2 = portalclipend;
|
||||
}
|
||||
|
||||
vis->xscale = FixedMul(spritexscale, xscale); //SoM: 4/17/2000
|
||||
vis->scale = FixedMul(spriteyscale, yscale); //<<detailshift;
|
||||
vis->thingscale = interp.scale;
|
||||
@@ -1671,8 +1724,8 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||
// diminished light
|
||||
lindex = FixedMul(xscale, LIGHTRESOLUTIONFIX)>>(LIGHTSCALESHIFT);
|
||||
|
||||
if (lindex >= MAXLIGHTSCALE)
|
||||
lindex = MAXLIGHTSCALE-1;
|
||||
// Mitigate against negative xscale and arithmetic overflow
|
||||
lindex = CLAMP(lindex, 0, MAXLIGHTSCALE - 1);
|
||||
|
||||
vis->colormap = spritelights[lindex];
|
||||
}
|
||||
@@ -1749,7 +1802,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
|
||||
tx = -(gyt + gxt);
|
||||
|
||||
// too far off the side?
|
||||
if (abs(tx) > tz<<2)
|
||||
if (abs(tx) > FixedMul(tz, fovtan)<<2)
|
||||
return;
|
||||
|
||||
// aspect ratio stuff :
|
||||
@@ -1797,7 +1850,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
|
||||
return;
|
||||
|
||||
// PORTAL SPRITE CLIPPING
|
||||
if (portalrender)
|
||||
if (portalrender && portalclipline)
|
||||
{
|
||||
if (x2 < portalclipstart || x1 > portalclipend)
|
||||
return;
|
||||
@@ -1829,12 +1882,13 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
|
||||
vis->pzt = vis->pz + vis->thingheight;
|
||||
vis->texturemid = vis->gzt - viewz;
|
||||
vis->scalestep = 0;
|
||||
vis->paperdistance = 0;
|
||||
|
||||
vis->x1 = x1 < 0 ? 0 : x1;
|
||||
vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2;
|
||||
|
||||
// PORTAL SEMI-CLIPPING
|
||||
if (portalrender)
|
||||
if (portalrender && portalclipline)
|
||||
{
|
||||
if (vis->x1 < portalclipstart)
|
||||
vis->x1 = portalclipstart;
|
||||
@@ -1932,7 +1986,7 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel)
|
||||
|
||||
// Handle all things in sector.
|
||||
// If a limit exists, handle things a tiny bit different.
|
||||
if ((limit_dist = (fixed_t)(/*(maptol & TOL_NIGHTS) ? cv_drawdist_nights.value : */cv_drawdist.value) << FRACBITS))
|
||||
if ((limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale))
|
||||
{
|
||||
for (thing = sec->thinglist; thing; thing = thing->snext)
|
||||
{
|
||||
@@ -2024,11 +2078,12 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel)
|
||||
//
|
||||
void R_AddPrecipitationSprites(void)
|
||||
{
|
||||
const fixed_t drawdist = cv_drawdist_precip.value * mapobjectscale;
|
||||
const fixed_t drawdist = (fixed_t)(cv_drawdist_precip.value) * mapobjectscale;
|
||||
|
||||
INT32 xl, xh, yl, yh, bx, by;
|
||||
precipmobj_t *th, *next;
|
||||
|
||||
// no, no infinite draw distance for precipitation. this option at zero is supposed to turn it off
|
||||
if (drawdist == 0)
|
||||
{
|
||||
return;
|
||||
@@ -2036,7 +2091,6 @@ void R_AddPrecipitationSprites(void)
|
||||
|
||||
R_GetRenderBlockMapDimensions(drawdist, &xl, &xh, &yl, &yh);
|
||||
|
||||
// no, no infinite draw distance for precipitation. this option at zero is supposed to turn it off
|
||||
for (bx = xl; bx <= xh; bx++)
|
||||
{
|
||||
for (by = yl; by <= yh; by++)
|
||||
@@ -2882,14 +2936,14 @@ UINT8 skinstatscount[9][9] = {
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
UINT8 skinsorted[MAXSKINS];
|
||||
skin_t localskins[MAXSKINS];
|
||||
skin_t allskins[MAXSKINS*2];
|
||||
skin_t localskins[MAXLOCALSKINS];
|
||||
skin_t allskins[MAXSKINS+MAXLOCALSKINS];
|
||||
|
||||
// FIXTHIS: don't work because it must be inistilised before the config load
|
||||
//#define SKINVALUES
|
||||
#ifdef SKINVALUES
|
||||
CV_PossibleValue_t skin_cons_t[MAXSKINS+1];
|
||||
CV_PossibleValue_t localskin_cons_t[MAXSKINS+1];
|
||||
CV_PossibleValue_t localskin_cons_t[MAXLOCALSKINS+1];
|
||||
#endif
|
||||
|
||||
static void Sk_SetDefaultValue(skin_t *skin, boolean local)
|
||||
@@ -2941,6 +2995,9 @@ void R_InitSkins(void)
|
||||
{
|
||||
skin_cons_t[i].value = 0;
|
||||
skin_cons_t[i].strvalue = NULL;
|
||||
}
|
||||
for (i = 0; i <= MAXLOCALSKINS; i++)
|
||||
{
|
||||
localskin_cons_t[i].value = 0;
|
||||
localskin_cons_t[i].strvalue = NULL;
|
||||
}
|
||||
@@ -3329,11 +3386,17 @@ void R_AddSkins(UINT16 wadnum, boolean local)
|
||||
// advance by default
|
||||
lastlump = lump + 1;
|
||||
|
||||
if (( (local) ? numlocalskins : numskins ) >= MAXSKINS)
|
||||
if (numskins >= MAXSKINS)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Unable to add skin, too many characters are loaded (%d maximum)\n"), MAXSKINS);
|
||||
continue; // so we know how many skins couldn't be added
|
||||
}
|
||||
if (numlocalskins >= MAXLOCALSKINS)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Unable to add localskin, too many localskins are loaded (%d maximum)\n"), MAXLOCALSKINS);
|
||||
continue; // so we know how many skins couldn't be added
|
||||
}
|
||||
|
||||
buf = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE);
|
||||
size = W_LumpLengthPwad(wadnum, lump);
|
||||
|
||||
|
||||
+5
-4
@@ -149,8 +149,11 @@ typedef struct vissprite_s
|
||||
fixed_t thingscale; // the object's scale
|
||||
fixed_t sortscale; // sortscale only differs from scale for flat sprites
|
||||
fixed_t scalestep; // only for flat sprites, 0 otherwise
|
||||
fixed_t paperoffset, paperdistance; // for paper sprites, offset/dist relative to the angle
|
||||
fixed_t xiscale; // negative if flipped
|
||||
|
||||
angle_t centerangle; // for paper sprites
|
||||
|
||||
fixed_t texturemid;
|
||||
patch_t *patch;
|
||||
|
||||
@@ -172,12 +175,10 @@ typedef struct vissprite_s
|
||||
|
||||
spritecut_e cut;
|
||||
UINT32 renderflags;
|
||||
UINT8 rotateflags;
|
||||
|
||||
fixed_t spritexscale, spriteyscale;
|
||||
fixed_t spritexoffset, spriteyoffset;
|
||||
|
||||
|
||||
INT16 clipbot[MAXVIDWIDTH], cliptop[MAXVIDWIDTH];
|
||||
|
||||
boolean precip;
|
||||
@@ -219,8 +220,8 @@ extern UINT8 skinstatscount[9][9];
|
||||
extern UINT8 skinsorted[MAXSKINS];
|
||||
|
||||
void sortSkinGrid(void);
|
||||
extern skin_t localskins[MAXSKINS];
|
||||
extern skin_t allskins[MAXSKINS*2];
|
||||
extern skin_t localskins[MAXLOCALSKINS];
|
||||
extern skin_t allskins[MAXSKINS+MAXLOCALSKINS];
|
||||
|
||||
boolean SetPlayerSkin(INT32 playernum,const char *skinname);
|
||||
void SetPlayerSkinByNum(INT32 playernum,INT32 skinnum); // Tails 03-16-2002
|
||||
|
||||
+2
-2
@@ -65,7 +65,7 @@ static void AmigaType_OnChange(void);
|
||||
|
||||
consvar_t cv_samplerate = {"samplerate", "44100", 0, CV_Unsigned, NULL, 22050, NULL, NULL, 0, 0, NULL}; //Alam: For easy hacking?
|
||||
|
||||
static CV_PossibleValue_t audbuffersize_cons_t[] = {{512, "512"}, {1024, "1024"}, {2048, "2048"}, {4096, "4096"}, {0, NULL}};
|
||||
static CV_PossibleValue_t audbuffersize_cons_t[] = {{256, "256"}, {512, "512"}, {1024, "1024"}, {2048, "2048"}, {4096, "4096"}, {0, NULL}};
|
||||
consvar_t cv_audbuffersize = {"buffersize", "2048", CV_SAVE, audbuffersize_cons_t, BufferSize_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
// stereo reverse
|
||||
@@ -1996,7 +1996,7 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32
|
||||
|
||||
strncpy(newmusic, mmusic, 6);
|
||||
|
||||
if(LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms))
|
||||
if (LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms))
|
||||
return;
|
||||
|
||||
// No Music (empty string)
|
||||
|
||||
@@ -1198,6 +1198,8 @@ SDL_Surface *IMG_ReadXPMFromArray(const char **xpm)
|
||||
return load_xpm(xpm, NULL);
|
||||
}
|
||||
|
||||
#undef MAX
|
||||
|
||||
#else /* not LOAD_XPM */
|
||||
|
||||
/* See if an image is contained in a data source */
|
||||
|
||||
+16
-45
@@ -3189,28 +3189,21 @@ ticcmd_t *I_BaseTiccmd4(void)
|
||||
return &emptycmd4;
|
||||
}
|
||||
|
||||
//
|
||||
// I_GetTime
|
||||
// returns time in 1/TICRATE second tics
|
||||
//
|
||||
|
||||
static Uint64 timer_frequency;
|
||||
|
||||
precise_t I_GetPreciseTime(void)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
LARGE_INTEGER counter;
|
||||
QueryPerformanceCounter(&counter);
|
||||
return counter.QuadPart;
|
||||
#else
|
||||
return SDL_GetPerformanceCounter();
|
||||
#endif
|
||||
}
|
||||
|
||||
UINT64 I_GetPrecisePrecision(void)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
LARGE_INTEGER frequency;
|
||||
QueryPerformanceFrequency(&frequency);
|
||||
return frequency.QuadPart;
|
||||
#else
|
||||
return SDL_GetPerformanceFrequency();
|
||||
#endif
|
||||
}
|
||||
|
||||
static UINT32 frame_rate;
|
||||
@@ -3237,24 +3230,14 @@ static void I_InitFrameTime(const UINT64 now, const UINT32 cap)
|
||||
}
|
||||
|
||||
double I_GetFrameTime(void)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
LARGE_INTEGER now;
|
||||
QueryPerformanceCounter(&now);
|
||||
const UINT64 nowValue = now.QuadPart;
|
||||
#else
|
||||
{
|
||||
const UINT64 now = SDL_GetPerformanceCounter();
|
||||
#endif
|
||||
const UINT32 cap = R_GetFramerateCap();
|
||||
|
||||
if (cap != frame_rate)
|
||||
{
|
||||
// Maybe do this in a OnChange function for cv_fpscap?
|
||||
#if defined(_WIN32)
|
||||
I_InitFrameTime(nowValue, cap);
|
||||
#else
|
||||
I_InitFrameTime(now, cap);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (frame_rate == 0)
|
||||
@@ -3264,17 +3247,10 @@ double I_GetFrameTime(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
elapsed_frames += (nowValue - frame_epoch) / frame_frequency;
|
||||
#else
|
||||
elapsed_frames += (now - frame_epoch) / frame_frequency;
|
||||
#endif
|
||||
}
|
||||
#if defined(_WIN32)
|
||||
frame_epoch = nowValue; // moving epoch
|
||||
#else
|
||||
frame_epoch = now; // moving epoch
|
||||
#endif
|
||||
|
||||
frame_epoch = now; // moving epoch
|
||||
return elapsed_frames;
|
||||
}
|
||||
|
||||
@@ -3283,13 +3259,8 @@ double I_GetFrameTime(void)
|
||||
//
|
||||
void I_StartupTimer(void)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
LARGE_INTEGER frequency;
|
||||
QueryPerformanceFrequency(&frequency);
|
||||
timer_frequency = frequency.QuadPart;
|
||||
#else
|
||||
timer_frequency = SDL_GetPerformanceFrequency();
|
||||
#endif
|
||||
|
||||
I_InitFrameTime(0, R_GetFramerateCap());
|
||||
elapsed_frames = 0.0;
|
||||
}
|
||||
@@ -3335,12 +3306,7 @@ void I_SleepDuration(precise_t duration)
|
||||
// hard sleep function.
|
||||
if (sleepvalue > 0 && (dest - cur) > delaygranularity)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
DWORD sleepDuration = (DWORD)min((INT64)(dest - cur), sleepvalue);
|
||||
SleepEx(sleepDuration, TRUE);
|
||||
#else
|
||||
I_Sleep(sleepvalue);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Otherwise, this is a spinloop.
|
||||
@@ -4039,10 +4005,15 @@ static const char *locateWad(void)
|
||||
#endif
|
||||
#ifndef NOHOME
|
||||
// find in $HOME
|
||||
I_OutputMsg(",HOME");
|
||||
I_OutputMsg(",HOME/" DEFAULTDIR);
|
||||
if ((envstr = I_GetEnv("HOME")) != NULL)
|
||||
{
|
||||
WadPath = searchWad(envstr);
|
||||
char *tmp = malloc(strlen(envstr) + sizeof(PATHSEP) + sizeof(DEFAULTDIR));
|
||||
strcpy(tmp, envstr);
|
||||
strcat(tmp, PATHSEP);
|
||||
strcat(tmp, DEFAULTDIR);
|
||||
WadPath = searchWad(tmp);
|
||||
free(tmp);
|
||||
if (WadPath)
|
||||
return WadPath;
|
||||
}
|
||||
|
||||
+4
-5
@@ -2023,12 +2023,11 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen)
|
||||
else if (cv_vidwait.value)
|
||||
flags |= SDL_RENDERER_PRESENTVSYNC;
|
||||
|
||||
// 3 August 2022
|
||||
// Possibly a Windows 11 issue; the default
|
||||
// "direct3d" driver (D3D9) causes Drmingw exchndl
|
||||
// to not write RPT files. Every other driver
|
||||
// seems fine.
|
||||
#ifdef _WIN32
|
||||
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "direct3d11");
|
||||
#else
|
||||
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
|
||||
#endif
|
||||
|
||||
renderer = SDL_CreateRenderer(window, -1, flags);
|
||||
if (renderer == NULL)
|
||||
|
||||
+19
-16
@@ -56,17 +56,17 @@ patch_t *facerankprefix[MAXSKINS]; // ranking
|
||||
patch_t *facewantprefix[MAXSKINS]; // wanted
|
||||
patch_t *facemmapprefix[MAXSKINS]; // minimap
|
||||
|
||||
patch_t *localfacerankprefix[MAXSKINS]; // ranking
|
||||
patch_t *localfacewantprefix[MAXSKINS]; // wanted
|
||||
patch_t *localfacemmapprefix[MAXSKINS]; // minimap
|
||||
patch_t *localfacerankprefix[MAXLOCALSKINS]; // ranking
|
||||
patch_t *localfacewantprefix[MAXLOCALSKINS]; // wanted
|
||||
patch_t *localfacemmapprefix[MAXLOCALSKINS]; // minimap
|
||||
|
||||
char *facerankprefix_name[MAXSKINS]; // ranking
|
||||
/*char *facerankprefix_name[MAXSKINS]; // ranking
|
||||
char *facewantprefix_name[MAXSKINS]; // wanted
|
||||
char *facemmapprefix_name[MAXSKINS]; // minimap
|
||||
|
||||
char *localfacerankprefix_name[MAXSKINS]; // ranking
|
||||
char *localfacewantprefix_name[MAXSKINS]; // wanted
|
||||
char *localfacemmapprefix_name[MAXSKINS]; // minimap
|
||||
char *localfacerankprefix_name[MAXLOCALSKINS]; // ranking
|
||||
char *localfacewantprefix_name[MAXLOCALSKINS]; // wanted
|
||||
char *localfacemmapprefix_name[MAXLOCALSKINS]; // minimap*/
|
||||
|
||||
// ------------------------------------------
|
||||
// status bar overlay
|
||||
@@ -193,7 +193,7 @@ hudinfo_t hudinfo[NUMHUDITEMS] =
|
||||
{ 240, 160}, // HUD_LAP
|
||||
};
|
||||
|
||||
static huddrawlist_h luahuddrawlist_game;
|
||||
static huddrawlist_h luahuddrawlist_game[MAXSPLITSCREENPLAYERS];
|
||||
|
||||
// variable to stop mayonaka static from flickering
|
||||
consvar_t cv_lessflicker = {"lessflicker", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
@@ -395,9 +395,9 @@ void ST_LoadFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32 skin
|
||||
facewantprefix[skinnum] = W_CachePatchName(wantstr, PU_HUDGFX);
|
||||
facemmapprefix[skinnum] = W_CachePatchName(mmapstr, PU_HUDGFX);
|
||||
|
||||
facerankprefix_name[skinnum] = rankstr;
|
||||
/*facerankprefix_name[skinnum] = rankstr;
|
||||
facewantprefix_name[skinnum] = wantstr;
|
||||
facemmapprefix_name[skinnum] = mmapstr;
|
||||
facemmapprefix_name[skinnum] = mmapstr;*/
|
||||
}
|
||||
|
||||
void ST_LoadLocalFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32 skinnum)
|
||||
@@ -406,9 +406,9 @@ void ST_LoadLocalFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32
|
||||
localfacewantprefix[skinnum] = W_CachePatchName(wantstr, PU_HUDGFX);
|
||||
localfacemmapprefix[skinnum] = W_CachePatchName(mmapstr, PU_HUDGFX);
|
||||
|
||||
localfacerankprefix_name[skinnum] = rankstr;
|
||||
/*localfacerankprefix_name[skinnum] = rankstr;
|
||||
localfacewantprefix_name[skinnum] = wantstr;
|
||||
localfacemmapprefix_name[skinnum] = mmapstr;
|
||||
localfacemmapprefix_name[skinnum] = mmapstr;*/
|
||||
|
||||
//CONS_Printf("Added rank prefix %s\n", rankstr);
|
||||
//CONS_Printf("Added want prefix %s\n", wantstr);
|
||||
@@ -473,7 +473,8 @@ void ST_Init(void)
|
||||
|
||||
ST_LoadGraphics();
|
||||
|
||||
luahuddrawlist_game = LUA_HUD_CreateDrawList();
|
||||
for (int i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
luahuddrawlist_game[i] = LUA_HUD_CreateDrawList();
|
||||
}
|
||||
|
||||
// change the status bar too, when pressing F12 while viewing a demo.
|
||||
@@ -846,7 +847,7 @@ static void ST_overlayDrawer(void)
|
||||
{
|
||||
if (renderisnewtic)
|
||||
{
|
||||
LUAh_GameHUD(stplyr, luahuddrawlist_game);
|
||||
LUAh_GameHUD(luahuddrawlist_game[stplyrnum]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1024,7 +1025,8 @@ void ST_Drawer(void)
|
||||
{
|
||||
if (renderisnewtic)
|
||||
{
|
||||
LUA_HUD_ClearDrawList(luahuddrawlist_game);
|
||||
for (i = 0; i <= splitscreen; i++)
|
||||
LUA_HUD_ClearDrawList(luahuddrawlist_game[i]);
|
||||
}
|
||||
|
||||
// No deadview!
|
||||
@@ -1035,7 +1037,8 @@ void ST_Drawer(void)
|
||||
ST_overlayDrawer();
|
||||
}
|
||||
|
||||
LUA_HUD_DrawList(luahuddrawlist_game);
|
||||
for (i = 0; i <= splitscreen; i++)
|
||||
LUA_HUD_DrawList(luahuddrawlist_game[i]);
|
||||
|
||||
// draw Midnight Channel's overlay ontop
|
||||
if (mapheaderinfo[gamemap-1]->typeoflevel & TOL_TV) // Very specific Midnight Channel stuff.
|
||||
|
||||
+7
-7
@@ -78,15 +78,15 @@ extern patch_t *sboperiod;
|
||||
extern patch_t *facerankprefix[MAXSKINS]; // ranking
|
||||
extern patch_t *facewantprefix[MAXSKINS]; // wanted
|
||||
extern patch_t *facemmapprefix[MAXSKINS]; // minimap
|
||||
extern patch_t *localfacerankprefix[MAXSKINS]; // ranking
|
||||
extern patch_t *localfacewantprefix[MAXSKINS]; // wanted
|
||||
extern patch_t *localfacemmapprefix[MAXSKINS]; // minimap
|
||||
extern char *facerankprefix_name[MAXSKINS]; // ranking
|
||||
extern patch_t *localfacerankprefix[MAXLOCALSKINS]; // ranking
|
||||
extern patch_t *localfacewantprefix[MAXLOCALSKINS]; // wanted
|
||||
extern patch_t *localfacemmapprefix[MAXLOCALSKINS]; // minimap
|
||||
/*extern char *facerankprefix_name[MAXSKINS]; // ranking
|
||||
extern char *facewantprefix_name[MAXSKINS]; // wanted
|
||||
extern char *facemmapprefix_name[MAXSKINS]; // minimap
|
||||
extern char *localfacerankprefix_name[MAXSKINS]; // ranking
|
||||
extern char *localfacewantprefix_name[MAXSKINS]; // wanted
|
||||
extern char *localfacemmapprefix_name[MAXSKINS]; // minimap
|
||||
extern char *localfacerankprefix_name[MAXLOCALSKINS]; // ranking
|
||||
extern char *localfacewantprefix_name[MAXLOCALSKINS]; // wanted
|
||||
extern char *localfacemmapprefix_name[MAXLOCALSKINS]; // minimap*/
|
||||
extern patch_t *livesback;
|
||||
extern patch_t *ngradeletters[7];
|
||||
|
||||
|
||||
+1
-2
@@ -789,7 +789,7 @@ UINT16 W_InitFile(const char *filename, boolean local)
|
||||
//
|
||||
// link wad file to search files
|
||||
//
|
||||
wadfile = Z_Malloc(sizeof (*wadfile), PU_STATIC, NULL);
|
||||
wadfile = Z_Calloc(sizeof (*wadfile), PU_STATIC, NULL);
|
||||
wadfile->filename = Z_StrDup(filename);
|
||||
wadfile->handle = handle;
|
||||
wadfile->numlumps = (UINT16)numlumps;
|
||||
@@ -798,7 +798,6 @@ UINT16 W_InitFile(const char *filename, boolean local)
|
||||
fseek(handle, 0, SEEK_END);
|
||||
wadfile->filesize = (unsigned)ftell(handle);
|
||||
wadfile->type = type;
|
||||
wadfile->majormod = false;
|
||||
|
||||
// already generated, just copy it over
|
||||
M_Memcpy(&wadfile->md5sum, &md5sum, 16);
|
||||
|
||||
+19
-12
@@ -100,10 +100,10 @@ static y_data data;
|
||||
static patch_t *bgpatch = NULL; // INTERSCR
|
||||
static patch_t *widebgpatch = NULL; // INTERSCW
|
||||
static patch_t *bgtile = NULL; // SPECTILE/SRB2BACK
|
||||
static patch_t *interpic = NULL; // custom picture defined in map header
|
||||
static boolean usetile;
|
||||
//static patch_t *interpic = NULL; // custom picture defined in map header
|
||||
//static boolean usetile;
|
||||
boolean usebuffer = false;
|
||||
static boolean useinterpic;
|
||||
//static boolean useinterpic;
|
||||
static INT32 timer;
|
||||
|
||||
static INT32 intertic;
|
||||
@@ -392,9 +392,16 @@ void Y_IntermissionDrawer(void)
|
||||
if (!usebuffer)
|
||||
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
|
||||
|
||||
if (useinterpic)
|
||||
V_DrawScaledPatch(0, 0, 0, interpic);
|
||||
else if (!usetile)
|
||||
if (cv_betainterscreen.value
|
||||
#ifdef HWRENDER
|
||||
|| (rendermode == render_opengl && cv_grscreentextures.value != 2) // use the neato kart bg for intermission on disabled screen textures
|
||||
#endif
|
||||
)
|
||||
V_DrawPatchFill(bgtile); // use the neato kart bg for intermission on disabled screen textures
|
||||
//else if (useinterpic)
|
||||
//V_DrawScaledPatch(0, 0, 0, interpic);
|
||||
//else if (!usetile)
|
||||
else
|
||||
{
|
||||
if (rendermode == render_soft && usebuffer)
|
||||
VID_BlitLinearScreen(screens[1], screens[0], vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.rowbytes);
|
||||
@@ -412,8 +419,8 @@ void Y_IntermissionDrawer(void)
|
||||
V_DrawScaledPatch(0, 0, 0, bgpatch);
|
||||
}
|
||||
}
|
||||
else if (bgtile)
|
||||
V_DrawPatchFill(bgtile);
|
||||
//else if (bgtile)
|
||||
//V_DrawPatchFill(bgtile);
|
||||
|
||||
if (usebuffer) // Fade everything out
|
||||
V_DrawFadeScreen(0xFF00, 22);
|
||||
@@ -430,7 +437,7 @@ void Y_IntermissionDrawer(void)
|
||||
|
||||
if (sorttic != -1 && intertic >= sorttic && !demo.playback)
|
||||
{
|
||||
INT32 count = (intertic - sorttic);
|
||||
INT64 count = (intertic - sorttic);
|
||||
|
||||
if (count < 8)
|
||||
x -= ((((count<<FRACBITS) + R_GetHudUncap()) * vid.width)>>FRACBITS) / (8 * vid.dupx);
|
||||
@@ -937,8 +944,8 @@ void Y_StartIntermission(void)
|
||||
|
||||
//if (intertype == int_race || intertype == int_match)
|
||||
{
|
||||
//bgtile = W_CachePatchName("SRB2BACK", PU_STATIC);
|
||||
usetile = useinterpic = false;
|
||||
bgtile = W_CachePatchName("SRB2BACK", PU_STATIC);
|
||||
//usetile = useinterpic = false;
|
||||
usebuffer = true;
|
||||
}
|
||||
|
||||
@@ -988,7 +995,7 @@ static void Y_UnloadData(void)
|
||||
UNLOAD(bgpatch);
|
||||
UNLOAD(widebgpatch);
|
||||
UNLOAD(bgtile);
|
||||
UNLOAD(interpic);
|
||||
//UNLOAD(interpic);
|
||||
}
|
||||
|
||||
// SRB2Kart: Voting!
|
||||
|
||||
Reference in new issue
Block a user