Compare commits

...
58 Commits
Author SHA1 Message Date
Alug 0ac0f2bae2 forgor to remove this 2024-10-26 00:51:24 +02:00
Alug cee28c6166 refactor a bunch of crap and fix skyportals 2024-10-25 22:58:10 +02:00
Alug a6be267325 Add visplane portal creation functionality and use it to replace the skybox rendering.
https://git.do.srb2.org/STJr/SRB2/-/commit/264386f84257a47fe5480bb6300df02d039a2491
2024-10-25 22:58:05 +02:00
Alug 426740e0ac port srb2 software portal refactor 2024-10-25 22:57:43 +02:00
Alug 78c0f64135 dont pass skybox to r_setupframe
why was this even done?
neither srb2 nor v2/rr ever did this?
2024-10-25 22:57:38 +02:00
indev b6e766ee44 Fix A_Lua not removing error handler from lua stack 2024-10-25 23:15:52 +03:00
Alug 5437040b78 move the return ealier in V_DoPostProcessor 2024-10-25 20:21:10 +02:00
Alug c786569981 Merge branch 'refactorpostimg' into Saturn-Next 2024-10-25 20:12:56 +02:00
Alug 7064b14539 Merge branch 'autoloadagain' into Saturn-Next 2024-10-25 20:12:53 +02:00
Alug f275ae98f5 this is needed for postimg stuff in first person
lol
also adds break in splitscreen lööp
2024-10-25 20:12:14 +02:00
Alug ef07d89e29 Revert "update lzf compression to 1.6"
This reverts commit 48e71afec1.
2024-10-25 19:50:16 +02:00
Alug b9bbd45e15 Revert "shut up mingw"
This reverts commit 75637e361c.
2024-10-25 19:50:10 +02:00
Alug 2bda27b80d Revert "those should be size_t"
This reverts commit b357c09171.
2024-10-25 19:49:26 +02:00
Alug 6ebf90cc50 Merge branch 'Saturn-Next' into autoloadagain 2024-10-25 03:28:43 +02:00
Alug ea00bebb04 Merge branch 'Saturn-Next' into refactorpostimg 2024-10-25 03:28:20 +02:00
Alug b862d835a5 save one calc lol 2024-10-25 03:27:51 +02:00
Alug d6602747ae oops forgor lol 2024-10-25 03:26:22 +02:00
Alug 9f79429d03 slight cleanup + make static + smol optimize ogl sprite drawers 2024-10-25 03:26:19 +02:00
Alug 5ff0c09868 just check for noencore bool in hwr_processseg instead of checked line flags everytime 2024-10-23 21:33:31 +02:00
Alug ad1c3e63a4 why not reuse those? 2024-10-23 21:33:28 +02:00
Alug 24dd6ba675 cleanup HWR_ProcessSeg
stuff was quite the mess
2024-10-23 21:33:21 +02:00
Alug 85f036a45b dont always calc this twice 2024-10-23 21:33:14 +02:00
Alug 6f8342b9a8 remove cv_splitwallfix
tbh i dont think anyone even knows about this, never heard any complains, never had any issues, neither visually or performancewise.
its just clutter at this point
2024-10-23 21:33:04 +02:00
Alug c5c6f6b820 this does nothing 2024-10-23 21:30:21 +02:00
Alug 3d472c34a1 no need to check stuff in already postload marked addons 2024-10-23 15:48:44 +02:00
Alug 63ca366bd8 dont play rain sounds when weather is disabled 2024-10-23 13:00:36 +02:00
Alug e9e888ab7f remove debug print 2024-10-23 02:41:28 +02:00
indev 5ea55b3e3a Add W_CheckFileContains for W_CheckPostLoadList 2024-10-23 02:41:25 +02:00
Alug 8b1797927a attempt to check for things in file for postload detection 2024-10-23 02:41:23 +02:00
Alug 05a98964fb split auto and postload, let autoload run on gamestart again
prep for smth
2024-10-23 02:41:20 +02:00
Alug 8cbf798de8 redo rain sound overflow fix
https://git.do.srb2.org/KartKrew/RingRacers/-/commit/3eac1fed0f44a8285a9f6b82a12e86997bbb0d34
2024-10-23 02:37:32 +02:00
Alug 9314a24cb2 use highly optmized (but slightly inaccurate) version of R_PointOnSide for rendering 2024-10-23 02:37:08 +02:00
Alug 19b1683e61 make those not look terrible thx 2024-10-22 01:18:13 +02:00
Alug d029107e75 refactor postimg stuff so it can be combined with each other better
thx much indev! <3
everything now works with encore!
software now also supports screen effects in splitscreen!
2024-10-22 01:17:57 +02:00
Alug bc97e0b703 actually remove "renderflags" lol 2024-10-21 22:53:44 +02:00
Alug f47c663f79 remove renderflags
those literally did nothing
2024-10-21 22:47:32 +02:00
Alug 6f9d41eadb fix R_ThingVisible
those are "eflags" in kart smh
2024-10-21 22:46:59 +02:00
Alug 1b512edc56 add proper null check here too 2024-10-21 21:28:08 +02:00
Alug 884a6da2bd dont use cv_sloperolldist in splitscreen + save some assignments and one fixedhypot call
also use tabs lul
2024-10-21 21:07:32 +02:00
Alug 7a3d958fc1 tab pls 2024-10-21 18:43:08 +02:00
Alug 7223581539 Clarify we're calculating a cross product 2024-10-21 18:10:29 +02:00
Alug 664bd2de3f dont draw fadescreen when minimap iss active 2024-10-21 17:47:44 +02:00
indev 63568e3861 Fix off-by-one error for using '?' as map name 2024-10-21 18:43:37 +03:00
indev f149d058a1 Fix off-by-one error in lib_setSfxInfo 2024-10-21 18:06:35 +03:00
Alug 970251ced3 also check here ig? 2024-10-21 17:01:27 +02:00
Alug dba7a7dc3c prevent map command crash from maps with invalid or non existing mapinfo 2024-10-21 15:37:44 +02:00
Alug 393c0be407 Revert "attempt to optimize some p_maputl stuff"
This reverts commit 81d415c5ba.
2024-10-21 14:19:35 +02:00
Alug 5e9ea2429b replace those two P_MobjWasRemoved with simple null check insteead
since those may actually segfault if null anyways
2024-10-21 06:23:14 +02:00
Alug 81a14995da trailing space hell 2024-10-21 06:14:24 +02:00
Alug 4267ac9a8d remove more P_MobjWasRemoved checks
same as before, those may be not synchsafe
2024-10-21 06:04:47 +02:00
Alug bcf72cc0e8 revert some P_MobjWasRemoved checks i forgor about
those may NOT be vanilla netsafe
2024-10-21 06:04:17 +02:00
Alug 54d9a98090 rotsprite stuff also should be SHORT 2024-10-20 19:11:54 +02:00
Alug 81d415c5ba attempt to optimize some p_maputl stuff 2024-10-20 16:25:12 +02:00
Alug de1b801bda try to take some registers for span drawers too 2024-10-20 16:24:02 +02:00
Alug 2c665fef6f remove this again 2024-10-20 15:21:42 +02:00
Alug c6fbf405bf optimize R_PointOnSegSide
its only used for 2 rendering functions, so being potentially inaccurate is not that dangerous and the speedup in some instances might be worth the tradeoff
2024-10-20 15:16:37 +02:00
Alug 7076c35521 HWR_RenderPlane can be static 2024-10-20 14:57:28 +02:00
Alug 86ed1b709e fix some rendering issues and crashes in software renderer
- Increase MINZ from 4 fracunits to 16
- R_StoreWallRange: do not render textures with holes
- fix off-by-one error in R_ProjectSprite
- Avoid rendering unused left/right edges of screen while rolling
- Clamp patch column post drawing bounds
- Vissprites: set dc.texheight
- Add null check for column in R_DrawMaskedColumn
2024-10-20 14:57:22 +02:00
45 changed files with 1721 additions and 1330 deletions

No files matched your search

+1
View File
@@ -563,6 +563,7 @@ OBJS:=$(i_main_o) \
$(OBJDIR)/r_splats.o \ $(OBJDIR)/r_splats.o \
$(OBJDIR)/r_patch.o \ $(OBJDIR)/r_patch.o \
$(OBJDIR)/r_things.o \ $(OBJDIR)/r_things.o \
$(OBJDIR)/r_portal.o \
$(OBJDIR)/screen.o \ $(OBJDIR)/screen.o \
$(OBJDIR)/v_video.o \ $(OBJDIR)/v_video.o \
$(OBJDIR)/s_sound.o \ $(OBJDIR)/s_sound.o \
+1 -1
View File
@@ -4464,7 +4464,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
if (server && multiplayer && motd[0] != '\0') if (server && multiplayer && motd[0] != '\0')
COM_BufAddText(va("sayto %d %s\n", newplayernum, motd)); COM_BufAddText(va("sayto %d %s\n", newplayernum, motd));
D_AddAutoloadFiles(); D_AddPostloadFiles();
LUAh_PlayerJoin(newplayernum); LUAh_PlayerJoin(newplayernum);
+29 -57
View File
@@ -99,7 +99,6 @@ UINT8 window_notinfocus = false;
// DEMO LOOP // DEMO LOOP
// //
//static INT32 demosequence; //static INT32 demosequence;
static const char *pagename = "MAP1PIC";
static char *startupwadfiles[MAX_WADFILES]; static char *startupwadfiles[MAX_WADFILES];
static char *startuppwads[MAX_WADFILES]; static char *startuppwads[MAX_WADFILES];
@@ -116,7 +115,6 @@ boolean devparm = false; // started game with -devparm
boolean singletics = false; // timedemo boolean singletics = false; // timedemo
boolean lastdraw = false; boolean lastdraw = false;
postimg_t postimgtype[MAXSPLITSCREENPLAYERS];
INT32 postimgparam[MAXSPLITSCREENPLAYERS]; INT32 postimgparam[MAXSPLITSCREENPLAYERS];
// These variables are only true if // These variables are only true if
@@ -513,15 +511,12 @@ static boolean D_Display(void)
if (rendermode == render_soft) if (rendermode == render_soft)
{ {
if (!splitscreen) if (!splitscreen)
R_ApplyViewMorph(); R_ApplyViewMorph();
for (i = 0; i <= splitscreen; i++) for (i = 0; i <= splitscreen; i++)
{ {
if (!postimgtype[i]) V_DoPostProcessor(i, &players[displayplayers[i]], postimgparam[i]);
continue;
V_DoPostProcessor(i, postimgtype[i], postimgparam[i]);
} }
} }
@@ -1072,8 +1067,7 @@ static void D_FindAddonsToAutoload(void)
const char *autoloadpath; const char *autoloadpath;
boolean postload; boolean postload;
INT32 i, len; INT32 i;
boolean hasprefix = false;
char wadsToAutoload[256] = ""; char wadsToAutoload[256] = "";
// does it exist tho // does it exist tho
@@ -1095,7 +1089,8 @@ static void D_FindAddonsToAutoload(void)
|| (wadsToAutoload[0] == '#')) || (wadsToAutoload[0] == '#'))
continue; continue;
// this marks it so that it loads after loading server addons // this marks it so that it loads after loading server addons
else if (fastncmp(wadsToAutoload, "postload ", 9)) { else if (fastncmp(wadsToAutoload, "postload ", 9))
{
strremove(wadsToAutoload, "postload "); strremove(wadsToAutoload, "postload ");
postload = true; postload = true;
} }
@@ -1107,34 +1102,10 @@ static void D_FindAddonsToAutoload(void)
wadsToAutoload[i] = '\0'; wadsToAutoload[i] = '\0';
} }
len = strlen(wadsToAutoload); if (!postload && W_CheckPostLoadList(wadsToAutoload))
hasprefix = false;
for (i = 0; i < len; ++i)
{ {
if (wadsToAutoload[i] == '_') CONS_Printf("forcing postload for file %s\n", wadsToAutoload);
{ postload = true;
hasprefix = true;
break;
}
}
// Lets just hope no one adds bonuschars in autoload
if (hasprefix)
{
// We searching for c in prefix, which stands for "character" and doesn't work well with
// autoload atm, only fine for postload
for (i = 0; i < len; ++i)
{
if (wadsToAutoload[i] == '_') break; // Prefix end
if (wadsToAutoload[i] == 'c' || wadsToAutoload[i] == 'C')
{
CONS_Alert(CONS_WARNING, "forcing postload for %s as local skin\n", wadsToAutoload);
postload = true;
break; // Found it
}
}
} }
// LOAD IT // LOAD IT
@@ -1152,30 +1123,30 @@ static void D_FindAddonsToAutoload(void)
fclose(autoloadconfigfile); fclose(autoloadconfigfile);
} }
void D_AddAutoloadFiles(void) static void D_AddAutoloadFiles(void)
{ {
if (wasautoloaded && postautoloaded) if (wasautoloaded)
return; return;
if (!wasautoloaded && !modeattacking) CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n");
{ if (W_AddAutoloadedLocalFiles(autoloadwadfiles) == 0)
CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n"); CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n");
if (W_AddAutoloadedLocalFiles(autoloadwadfiles) == 0) D_CleanFile(autoloadwadfiles);
CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n");
D_CleanFile(autoloadwadfiles);
wasautoloaded = true; wasautoloaded = true;
} }
if ((!postautoloaded) && netgame) void D_AddPostloadFiles(void)
{ {
CONS_Printf("D_AutoloadFile(): Loading postloaded addons...\n"); if (postautoloaded || !netgame)
if (W_AddAutoloadedLocalFiles(autoloadwadfilespost) == 0) return;
CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n");
D_CleanFile(autoloadwadfilespost);
postautoloaded = true; CONS_Printf("D_AddPostloadFiles(): Loading postloaded addons...\n");
} if (W_AddAutoloadedLocalFiles(autoloadwadfilespost) == 0)
CONS_Printf("D_AddPostloadFiles(): Are you sure you put in valid files or what?\n");
D_CleanFile(autoloadwadfilespost);
postautoloaded = true;
} }
void D_CleanFile(char **filearray) void D_CleanFile(char **filearray)
@@ -1870,6 +1841,8 @@ void D_SRB2Main(void)
CONS_Printf("ST_Init(): Init status bar.\n"); CONS_Printf("ST_Init(): Init status bar.\n");
ST_Init(); ST_Init();
D_AddAutoloadFiles();
// Set up splitscreen players before joining! // Set up splitscreen players before joining!
if (!dedicated && (M_CheckParm("-splitscreen") && M_IsNextParm())) if (!dedicated && (M_CheckParm("-splitscreen") && M_IsNextParm()))
{ {
@@ -2071,7 +2044,6 @@ void D_SRB2Main(void)
if (dedicated && server) if (dedicated && server)
{ {
pagename = "TITLESKY";
levelstarttic = gametic; levelstarttic = gametic;
G_SetGamestate(GS_LEVEL); G_SetGamestate(GS_LEVEL);
if (!P_SetupLevel(false, false)) if (!P_SetupLevel(false, false))
+3 -3
View File
@@ -45,12 +45,12 @@ extern boolean statdp; // stat display for extended player setup
extern boolean nametaggfx; // Nametag stuffs extern boolean nametaggfx; // Nametag stuffs
extern boolean driftgaugegfx; extern boolean driftgaugegfx;
void D_AddAutoloadFiles(void); // autoload stuff
extern boolean autoloading; extern boolean autoloading;
extern boolean autoloaded; extern boolean autoloaded;
extern boolean postautoloaded; extern boolean postautoloaded;
extern boolean wasautoloaded;
void D_AddPostloadFiles(void);
extern char *autoloadwadfilespost[MAX_WADFILES]; extern char *autoloadwadfilespost[MAX_WADFILES];
extern char *autoloadwadfiles[MAX_WADFILES]; extern char *autoloadwadfiles[MAX_WADFILES];
+8
View File
@@ -2983,6 +2983,14 @@ static void Command_Map_f(void)
// G_TOLFlag handles both multiplayer gametype and ignores it for !multiplayer // G_TOLFlag handles both multiplayer gametype and ignores it for !multiplayer
else else
{ {
if (!mapheaderinfo[newmapnum-1] || mapheaderinfo[newmapnum-1] == NULL)
{
CONS_Alert(CONS_WARNING, M_GetText("Invalid mapheaderinfo for Course %s (%s)\n"), realmapname, G_BuildMapName(newmapnum));
Z_Free(realmapname);
Z_Free(mapname);
return;
}
if (!(mapheaderinfo[newmapnum-1]->typeoflevel & G_TOLFlag(newgametype))) if (!(mapheaderinfo[newmapnum-1]->typeoflevel & G_TOLFlag(newgametype)))
{ {
CONS_Alert(CONS_WARNING, M_GetText("Course %s (%s) doesn't support %s mode!\n(Use -force to override)\n"), realmapname, G_BuildMapName(newmapnum), CONS_Alert(CONS_WARNING, M_GetText("Course %s (%s) doesn't support %s mode!\n(Use -force to override)\n"), realmapname, G_BuildMapName(newmapnum),
+2
View File
@@ -413,6 +413,8 @@ typedef struct player_s
// See pflags_t, above. // See pflags_t, above.
pflags_t pflags; pflags_t pflags;
UINT16 postimgflags;
// playing animation. // playing animation.
panim_t panim; panim_t panim;
-1
View File
@@ -112,7 +112,6 @@ extern UINT8 window_notinfocus; // are we in focus? (backend independant -- hand
extern boolean nodrawers; extern boolean nodrawers;
extern boolean noblit; extern boolean noblit;
extern boolean lastdraw; extern boolean lastdraw;
extern postimg_t postimgtype[MAXSPLITSCREENPLAYERS];
extern INT32 postimgparam[MAXSPLITSCREENPLAYERS]; extern INT32 postimgparam[MAXSPLITSCREENPLAYERS];
extern INT32 viewwindowx, viewwindowy; extern INT32 viewwindowx, viewwindowy;
+6 -8
View File
@@ -344,14 +344,12 @@ typedef union FColorRGBA RGBA_t;
typedef enum typedef enum
{ {
postimg_none, POSTIMG_WATER = 1, // Underwater screen effect.
postimg_water, POSTIMG_MOTION = 1<<1, // Unused motion blur effect.
postimg_motion, POSTIMG_FLIP = 1<<2, // Flipcam screen effect.
postimg_flip, POSTIMG_HEAT = 1<<3, // Heatwave screen effect.
postimg_heat, POSTIMG_MIRROR = 1<<4, // encore screen effect.
postimg_mirror, } postimgflag_t;
postimg_mirrorflip
} postimg_t;
typedef UINT32 lumpnum_t; // 16 : 16 unsigned long (wad num: lump num) typedef UINT32 lumpnum_t; // 16 : 16 unsigned long (wad num: lump num)
#define LUMPERROR UINT32_MAX #define LUMPERROR UINT32_MAX
+3 -4
View File
@@ -4542,8 +4542,7 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep,
break; break;
} }
} }
else else if (apromapnum == 0 || wanttable)
if (apromapnum == 0 || wanttable)
{ {
/* LEVEL 1--match keywords verbatim */ /* LEVEL 1--match keywords verbatim */
if (( aprop = strcasestr(realmapname, mapname) )) if (( aprop = strcasestr(realmapname, mapname) ))
@@ -4634,8 +4633,8 @@ INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep)
{ {
if (mapname[0] == '*') // current map if (mapname[0] == '*') // current map
return gamemap; return gamemap;
else if (mapname[0] == '?') else if (mapname[0] == '?' && mapheaderinfo[gamemap-1])
return G_RandMap(G_TOLFlag(gametype), prevmap, false, 0, false, NULL); return G_RandMap(G_TOLFlag(gametype), gamemap-1, false, 0, false, NULL)+1;
else if (mapname[0] == '+' && mapheaderinfo[gamemap-1]) // next map else if (mapname[0] == '+' && mapheaderinfo[gamemap-1]) // next map
{ {
newmapnum = mapheaderinfo[gamemap-1]->nextlevel; newmapnum = mapheaderinfo[gamemap-1]->nextlevel;
-1
View File
@@ -32,7 +32,6 @@ typedef struct gr_vissprite_s
float scale; float scale;
float spritexscale, spriteyscale; float spritexscale, spriteyscale;
float spritexoffset, spriteyoffset; float spritexoffset, spriteyoffset;
UINT32 renderflags;
GLPatch_t *gpatch; GLPatch_t *gpatch;
boolean flip; boolean flip;
UINT8 translucency; //alpha level 0-255 UINT8 translucency; //alpha level 0-255
+152 -202
View File
@@ -106,8 +106,6 @@ consvar_t cv_grbatching = {"gr_batching", "On", 0, CV_OnOff, NULL, 0, NULL, NULL
consvar_t cv_grframebuffer = {"gr_framebuffer", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, CV_grframebuffer_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grframebuffer = {"gr_framebuffer", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, CV_grframebuffer_OnChange, 0, NULL, NULL, 0, 0, NULL};
#endif #endif
consvar_t cv_splitwallfix = {"splitwallfix", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t grrenderdistance_cons_t[] = { static CV_PossibleValue_t grrenderdistance_cons_t[] = {
{0, "Max"}, {1, "1024"}, {2, "2048"}, {3, "4096"}, {4, "6144"}, {5, "8192"}, {0, "Max"}, {1, "1024"}, {2, "2048"}, {3, "4096"}, {4, "6144"}, {5, "8192"},
{6, "12288"}, {7, "16384"}, {0, NULL}}; {6, "12288"}, {7, "16384"}, {0, NULL}};
@@ -297,6 +295,8 @@ ps_metric_t ps_hw_numcolors = {0};
ps_metric_t ps_hw_batchsorttime = {0}; ps_metric_t ps_hw_batchsorttime = {0};
ps_metric_t ps_hw_batchdrawtime = {0}; ps_metric_t ps_hw_batchdrawtime = {0};
static void HWR_AddSprites(sector_t *sec);
static void HWR_ProjectSprite(mobj_t *thing);
static void HWR_AddPrecipitationSprites(void); static void HWR_AddPrecipitationSprites(void);
static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing); static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing);
@@ -652,7 +652,7 @@ static FUINT HWR_CalcSlopeLight(FUINT lightnum, pslope_t *slope)
// HWR_RenderPlane // HWR_RenderPlane
// Render a floor or ceiling convex polygon // Render a floor or ceiling convex polygon
void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap) static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap)
{ {
FSurfaceInfo Surf; FSurfaceInfo Surf;
FOutVector *v3d; FOutVector *v3d;
@@ -1077,6 +1077,8 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum,
float endpegt, endpegb, endpegmul; float endpegt, endpegb, endpegmul;
float endheight = 0.0f, endbheight = 0.0f; float endheight = 0.0f, endbheight = 0.0f;
float diff;
fixed_t v1x = FloatToFixed(wallVerts[0].x); fixed_t v1x = FloatToFixed(wallVerts[0].x);
fixed_t v1y = FloatToFixed(wallVerts[0].z); fixed_t v1y = FloatToFixed(wallVerts[0].z);
fixed_t v2x = FloatToFixed(wallVerts[1].x); fixed_t v2x = FloatToFixed(wallVerts[1].x);
@@ -1088,26 +1090,30 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum,
realtop = top = wallVerts[3].y; realtop = top = wallVerts[3].y;
realbot = bot = wallVerts[0].y; realbot = bot = wallVerts[0].y;
diff = top - bot;
pegt = wallVerts[3].t; pegt = wallVerts[3].t;
pegb = wallVerts[0].t; pegb = wallVerts[0].t;
// Lactozilla: If both heights of a side lay on the same position, then this wall is a triangle. // Lactozilla: If both heights of a side lay on the same position, then this wall is a triangle.
// To avoid division by zero, which would result in a NaN, we check if the vertical difference // To avoid division by zero, which would result in a NaN, we check if the vertical difference
// between the two vertices is not zero. // between the two vertices is not zero.
if (fpclassify(top - bot) == FP_ZERO && cv_splitwallfix.value) if (fpclassify(diff) == FP_ZERO)
pegmul = 0.0; pegmul = 0.0;
else else
pegmul = (pegb - pegt) / (top - bot); pegmul = (pegb - pegt) / diff;
endrealtop = endtop = wallVerts[2].y; endrealtop = endtop = wallVerts[2].y;
endrealbot = endbot = wallVerts[1].y; endrealbot = endbot = wallVerts[1].y;
diff = endtop - endbot;
endpegt = wallVerts[2].t; endpegt = wallVerts[2].t;
endpegb = wallVerts[1].t; endpegb = wallVerts[1].t;
if (fpclassify(endtop - endbot) == FP_ZERO && cv_splitwallfix.value) if (fpclassify(diff) == FP_ZERO)
endpegmul = 0.0; endpegmul = 0.0;
else else
endpegmul = (endpegb - endpegt) / (endtop - endbot); endpegmul = (endpegb - endpegt) / diff;
for (INT32 i = 0; i < sector->numlights; i++) for (INT32 i = 0; i < sector->numlights; i++)
{ {
@@ -1177,13 +1183,10 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum,
endbheight = endrealbot; endbheight = endrealbot;
} }
if (cv_splitwallfix.value) if (endbheight > endtop)
{ endbot = endtop;
if (endbheight > endtop)
endbot = endtop;
}
if ((endbheight >= endtop && bheight >= top && !cv_splitwallfix.value) || (bheight >= top && cv_splitwallfix.value)) if (bheight >= top)
continue; continue;
// Found a break // Found a break
@@ -1193,15 +1196,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum,
if (bot < realbot) if (bot < realbot)
bot = realbot; bot = realbot;
if (cv_splitwallfix.value) endbot = min(max(endbheight, endrealbot), endtop);
endbot = min(max(endbheight, endrealbot), endtop);
else
{
endbot = endbheight;
if (endbot < endrealbot)
endbot = endrealbot;
}
Surf->PolyColor.s.alpha = alpha; Surf->PolyColor.s.alpha = alpha;
@@ -1429,19 +1424,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
fixed_t worldhighslope = 0, worldlowslope = 0; fixed_t worldhighslope = 0, worldlowslope = 0;
fixed_t v1x, v1y, v2x, v2y; fixed_t v1x, v1y, v2x, v2y;
float cliplow = 0.0f, cliphigh = 0.0f;
fixed_t h, l; // 3D sides and 2s middle textures fixed_t h, l; // 3D sides and 2s middle textures
fixed_t hS, lS; fixed_t hS, lS;
FUINT lightnum = 0; // shut up compiler
extracolormap_t *colormap;
FSurfaceInfo Surf;
boolean noencore = false;
gr_sidedef = gr_curline->sidedef; gr_sidedef = gr_curline->sidedef;
gr_linedef = gr_curline->linedef; gr_linedef = gr_curline->linedef;
const boolean noencore = (gr_linedef->flags & ML_TFERLINE);
if (gr_curline->pv1) if (gr_curline->pv1)
{ {
vs.x = ((polyvertex_t *)gr_curline->pv1)->x; vs.x = ((polyvertex_t *)gr_curline->pv1)->x;
@@ -1492,16 +1482,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
// x offset the texture // x offset the texture
fixed_t texturehpeg = gr_sidedef->textureoffset + gr_curline->offset; fixed_t texturehpeg = gr_sidedef->textureoffset + gr_curline->offset;
cliplow = (float)texturehpeg; float cliplow = (float)texturehpeg;
cliphigh = (float)(texturehpeg + (gr_curline->flength*FRACUNIT)); float cliphigh = (float)(texturehpeg + (gr_curline->flength*FRACUNIT));
lightnum = gr_frontsector->lightlevel; FUINT lightnum = gr_frontsector->lightlevel;
colormap = gr_frontsector->extra_colormap; extracolormap_t *colormap = gr_frontsector->extra_colormap;
lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gr_curline); lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gr_curline);
if (gr_linedef->flags & ML_TFERLINE) FSurfaceInfo Surf;
noencore = true;
Surf.PolyColor.s.alpha = 255; Surf.PolyColor.s.alpha = 255;
INT32 gr_midtexture = R_GetTextureNum(gr_sidedef->midtexture); INT32 gr_midtexture = R_GetTextureNum(gr_sidedef->midtexture);
@@ -1512,6 +1500,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
{ {
INT32 gr_toptexture = 0, gr_bottomtexture = 0; INT32 gr_toptexture = 0, gr_bottomtexture = 0;
fixed_t texturevpeg;
SLOPEPARAMS(gr_backsector->c_slope, worldhigh, worldhighslope, gr_backsector->ceilingheight) SLOPEPARAMS(gr_backsector->c_slope, worldhigh, worldhighslope, gr_backsector->ceilingheight)
SLOPEPARAMS(gr_backsector->f_slope, worldlow, worldlowslope, gr_backsector->floorheight) SLOPEPARAMS(gr_backsector->f_slope, worldlow, worldlowslope, gr_backsector->floorheight)
@@ -1527,8 +1517,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
{ {
// Both front and back sectors are sky, needs skywall from the frontsector's ceiling, but only if the // Both front and back sectors are sky, needs skywall from the frontsector's ceiling, but only if the
// backsector is lower // backsector is lower
if ((worldhigh <= worldtop && worldhighslope <= worldtopslope)// Assuming ESLOPE is always on with my changes if ((worldhigh <= worldtop && worldhighslope <= worldtopslope) // Assuming ESLOPE is always on with my changes
&& (worldhigh != worldtop || worldhighslope != worldtopslope)) && (worldhigh != worldtop || worldhighslope != worldtopslope))
// Removing the second line above will render more rarely visible skywalls. Example: Cave garden ceiling in Dark race // Removing the second line above will render more rarely visible skywalls. Example: Cave garden ceiling in Dark race
{ {
wallVerts[0].y = FIXED_TO_FLOAT(worldhigh); wallVerts[0].y = FIXED_TO_FLOAT(worldhigh);
@@ -1604,51 +1594,47 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
// check TOP TEXTURE // check TOP TEXTURE
if ((worldhighslope < worldtopslope || worldhigh < worldtop) && gr_toptexture) if ((worldhighslope < worldtopslope || worldhigh < worldtop) && gr_toptexture)
{ {
// PEGGING
if (gr_linedef->flags & ML_DONTPEGTOP)
texturevpeg = 0;
else if (gr_linedef->flags & ML_EFFECT1)
texturevpeg = worldhigh + textureheight[gr_toptexture] - worldtop;
else
texturevpeg = gr_backsector->ceilingheight + textureheight[gr_toptexture] - gr_frontsector->ceilingheight;
texturevpeg += gr_sidedef->rowoffset;
// This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway
texturevpeg %= textureheight[gr_toptexture];
grTex = HWR_GetTexture(gr_toptexture, noencore);
wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY;
wallVerts[0].t = wallVerts[1].t = (texturevpeg + gr_frontsector->ceilingheight - gr_backsector->ceilingheight) * grTex->scaleY;
wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX;
// Adjust t value for sloped walls
if (!(gr_linedef->flags & ML_EFFECT1))
{ {
fixed_t texturevpegtop; // top // Unskewed
wallVerts[3].t -= (worldtop - gr_frontsector->ceilingheight) * grTex->scaleY;
grTex = HWR_GetTexture(gr_toptexture, gr_linedef->flags & ML_TFERLINE); wallVerts[2].t -= (worldtopslope - gr_frontsector->ceilingheight) * grTex->scaleY;
wallVerts[0].t -= (worldhigh - gr_backsector->ceilingheight) * grTex->scaleY;
// PEGGING wallVerts[1].t -= (worldhighslope - gr_backsector->ceilingheight) * grTex->scaleY;
if (gr_linedef->flags & ML_DONTPEGTOP) }
texturevpegtop = 0; else if (gr_linedef->flags & ML_DONTPEGTOP)
else if (gr_linedef->flags & ML_EFFECT1) {
texturevpegtop = worldhigh + textureheight[gr_sidedef->toptexture] - worldtop; // Skewed by top
else wallVerts[0].t = (texturevpeg + worldtop - worldhigh) * grTex->scaleY;
texturevpegtop = gr_backsector->ceilingheight + textureheight[gr_sidedef->toptexture] - gr_frontsector->ceilingheight; wallVerts[1].t = (texturevpeg + worldtopslope - worldhighslope) * grTex->scaleY;
}
texturevpegtop += gr_sidedef->rowoffset; else
{
// This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway // Skewed by bottom
texturevpegtop %= SHORT(textures[gr_toptexture]->height)<<FRACBITS; wallVerts[0].t = wallVerts[1].t = (texturevpeg + worldtop - worldhigh) * grTex->scaleY;
wallVerts[3].t = wallVerts[0].t - (worldtop - worldhigh) * grTex->scaleY;
wallVerts[3].t = wallVerts[2].t = texturevpegtop * grTex->scaleY; wallVerts[2].t = wallVerts[1].t - (worldtopslope - worldhighslope) * grTex->scaleY;
wallVerts[0].t = wallVerts[1].t = (texturevpegtop + gr_frontsector->ceilingheight - gr_backsector->ceilingheight) * grTex->scaleY;
wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX;
// Adjust t value for sloped walls
if (!(gr_linedef->flags & ML_EFFECT1))
{
// Unskewed
wallVerts[3].t -= (worldtop - gr_frontsector->ceilingheight) * grTex->scaleY;
wallVerts[2].t -= (worldtopslope - gr_frontsector->ceilingheight) * grTex->scaleY;
wallVerts[0].t -= (worldhigh - gr_backsector->ceilingheight) * grTex->scaleY;
wallVerts[1].t -= (worldhighslope - gr_backsector->ceilingheight) * grTex->scaleY;
}
else if (gr_linedef->flags & ML_DONTPEGTOP)
{
// Skewed by top
wallVerts[0].t = (texturevpegtop + worldtop - worldhigh) * grTex->scaleY;
wallVerts[1].t = (texturevpegtop + worldtopslope - worldhighslope) * grTex->scaleY;
}
else
{
// Skewed by bottom
wallVerts[0].t = wallVerts[1].t = (texturevpegtop + worldtop - worldhigh) * grTex->scaleY;
wallVerts[3].t = wallVerts[0].t - (worldtop - worldhigh) * grTex->scaleY;
wallVerts[2].t = wallVerts[1].t - (worldtopslope - worldhighslope) * grTex->scaleY;
}
} }
// set top/bottom coords // set top/bottom coords
@@ -1658,35 +1644,33 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
wallVerts[1].y = FIXED_TO_FLOAT(worldhighslope); wallVerts[1].y = FIXED_TO_FLOAT(worldhighslope);
if (!gl_drawing_stencil && gr_frontsector->numlights) if (!gl_drawing_stencil && gr_frontsector->numlights)
HWR_SplitWall(gr_frontsector, wallVerts, gr_toptexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); HWR_SplitWall(gr_frontsector, wallVerts, gr_toptexture, noencore, &Surf, FF_CUTLEVEL, NULL, 0);
else if (!gl_drawing_stencil && grTex->mipmap.flags & TF_TRANSPARENT) else if (!gl_drawing_stencil && grTex->mipmap.flags & TF_TRANSPARENT)
HWR_AddTransparentWall(wallVerts, &Surf, gr_toptexture, gr_linedef->flags & ML_TFERLINE, PF_Environment, false, lightnum, colormap); HWR_AddTransparentWall(wallVerts, &Surf, gr_toptexture, noencore, PF_Environment, false, lightnum, colormap);
else else
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap);
} }
// check BOTTOM TEXTURE // check BOTTOM TEXTURE
if ((worldlowslope > worldbottomslope || worldlow > worldbottom) && gr_bottomtexture) //only if VISIBLE!!! if ((worldlowslope > worldbottomslope || worldlow > worldbottom) && gr_bottomtexture)
{ {
fixed_t texturevpegbottom = 0; // bottom
grTex = HWR_GetTexture(gr_bottomtexture, gr_linedef->flags & ML_TFERLINE);
// PEGGING // PEGGING
if (!(gr_linedef->flags & ML_DONTPEGBOTTOM)) if (!(gr_linedef->flags & ML_DONTPEGBOTTOM))
texturevpegbottom = 0; texturevpeg = 0;
else if (gr_linedef->flags & ML_EFFECT1) else if (gr_linedef->flags & ML_EFFECT1)
texturevpegbottom = worldbottom - worldlow; texturevpeg = worldbottom - worldlow;
else else
texturevpegbottom = gr_frontsector->floorheight - gr_backsector->floorheight; texturevpeg = gr_frontsector->floorheight - gr_backsector->floorheight;
texturevpegbottom += gr_sidedef->rowoffset; texturevpeg += gr_sidedef->rowoffset;
// This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway // This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway
texturevpegbottom %= SHORT(textures[gr_bottomtexture]->height)<<FRACBITS; texturevpeg %= textureheight[gr_bottomtexture];
wallVerts[3].t = wallVerts[2].t = texturevpegbottom * grTex->scaleY; grTex = HWR_GetTexture(gr_bottomtexture, noencore);
wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + gr_backsector->floorheight - gr_frontsector->floorheight) * grTex->scaleY;
wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY;
wallVerts[0].t = wallVerts[1].t = (texturevpeg + gr_backsector->floorheight - gr_frontsector->floorheight) * grTex->scaleY;
wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX;
@@ -1702,15 +1686,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
else if (gr_linedef->flags & ML_DONTPEGBOTTOM) else if (gr_linedef->flags & ML_DONTPEGBOTTOM)
{ {
// Skewed by bottom // Skewed by bottom
wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; wallVerts[0].t = wallVerts[1].t = (texturevpeg + worldlow - worldbottom) * grTex->scaleY;
//wallVerts[3].t = wallVerts[0].t - (worldlow - worldbottom) * grTex->scaleY; // no need, [3] is already this
wallVerts[2].t = wallVerts[1].t - (worldlowslope - worldbottomslope) * grTex->scaleY; wallVerts[2].t = wallVerts[1].t - (worldlowslope - worldbottomslope) * grTex->scaleY;
} }
else else
{ {
// Skewed by top // Skewed by top
wallVerts[0].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; wallVerts[0].t = (texturevpeg + worldlow - worldbottom) * grTex->scaleY;
wallVerts[1].t = (texturevpegbottom + worldlowslope - worldbottomslope) * grTex->scaleY; wallVerts[1].t = (texturevpeg + worldlowslope - worldbottomslope) * grTex->scaleY;
} }
// set top/bottom coords // set top/bottom coords
@@ -1720,9 +1703,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope); wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope);
if (!gl_drawing_stencil && gr_frontsector->numlights) if (!gl_drawing_stencil && gr_frontsector->numlights)
HWR_SplitWall(gr_frontsector, wallVerts, gr_bottomtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); HWR_SplitWall(gr_frontsector, wallVerts, gr_bottomtexture, noencore, &Surf, FF_CUTLEVEL, NULL, 0);
else if (!gl_drawing_stencil && grTex->mipmap.flags & TF_TRANSPARENT) else if (!gl_drawing_stencil && grTex->mipmap.flags & TF_TRANSPARENT)
HWR_AddTransparentWall(wallVerts, &Surf, gr_bottomtexture, gr_linedef->flags & ML_TFERLINE, PF_Environment, false, lightnum, colormap); HWR_AddTransparentWall(wallVerts, &Surf, gr_bottomtexture, noencore, PF_Environment, false, lightnum, colormap);
else else
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap);
} }
@@ -1758,23 +1741,21 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
else else
low = back->floorheight; low = back->floorheight;
repeats = (high - low)/textureheight[gr_sidedef->midtexture]; repeats = (high - low) / textureheight[gr_midtexture];
if ((high-low)%textureheight[gr_sidedef->midtexture]) if ((high - low) % textureheight[gr_midtexture])
repeats++; // tile an extra time to fill the gap -- Monster Iestyn repeats++; // tile an extra time to fill the gap -- Monster Iestyn
} }
else else
repeats = 1; repeats = 1;
fixed_t midtexheight = textureheight[gr_midtexture] * repeats;
fixed_t popentop, popenbottom, polytop, polybottom, lowcut, highcut;
fixed_t popentopslope, popenbottomslope, polytopslope, polybottomslope, lowcutslope, highcutslope;
// SoM: a little note: This code re-arranging will // SoM: a little note: This code re-arranging will
// fix the bug in Nimrod map02. popentop and popenbottom // fix the bug in Nimrod map02. popentop and popenbottom
// record the limits the texture can be displayed in. // record the limits the texture can be displayed in.
// polytop and polybottom, are the ideal (i.e. unclipped) // polytop and polybottom, are the ideal (i.e. unclipped)
// heights of the polygon, and h & l, are the final (clipped) // heights of the polygon, and h & l, are the final (clipped)
// poly coords. // poly coords.
fixed_t popentop, popenbottom, polytop, polybottom, lowcut, highcut;
fixed_t popentopslope, popenbottomslope, polytopslope, polybottomslope, lowcutslope, highcutslope;
// NOTE: With polyobjects, whenever you need to check the properties of the polyobject sector it belongs to, // NOTE: With polyobjects, whenever you need to check the properties of the polyobject sector it belongs to,
// you must use the linedef's backsector to be correct // you must use the linedef's backsector to be correct
@@ -1788,39 +1769,40 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
{ {
popentop = min(worldtop, worldhigh); popentop = min(worldtop, worldhigh);
popenbottom = max(worldbottom, worldlow); popenbottom = max(worldbottom, worldlow);
popentopslope = min(worldtopslope, worldhighslope); popentopslope = min(worldtopslope, worldhighslope);
popenbottomslope = max(worldbottomslope, worldlowslope); popenbottomslope = max(worldbottomslope, worldlowslope);
} }
// Find the wall's coordinates
fixed_t midtexheight = textureheight[gr_midtexture] * repeats;
if (gr_linedef->flags & ML_EFFECT2) if (gr_linedef->flags & ML_EFFECT2)
{ {
if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) // Peg it to the floor
{ {
polybottom = max(front->floorheight, back->floorheight) + gr_sidedef->rowoffset; polybottom = max(front->floorheight, back->floorheight) + gr_sidedef->rowoffset;
polybottomslope = polybottom;
polytop = polybottom + midtexheight; polytop = polybottom + midtexheight;
polytopslope = polytop;
} }
else else // Peg it to the ceiling
{ {
polytop = min(front->ceilingheight, back->ceilingheight) + gr_sidedef->rowoffset; polytop = min(front->ceilingheight, back->ceilingheight) + gr_sidedef->rowoffset;
polytopslope = polytop;
polybottom = polytop - midtexheight; polybottom = polytop - midtexheight;
polybottomslope = polybottom;
} }
// The right side's coordinates are the the same as the left side
polytopslope = polytop;
polybottomslope = polybottom;
} }
else if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) else if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) // Skew the texture, but peg it to the floor
{ {
polybottom = popenbottom + gr_sidedef->rowoffset; polybottom = popenbottom + gr_sidedef->rowoffset;
polytop = polybottom + midtexheight; polytop = polybottom + midtexheight;
polybottomslope = popenbottomslope + gr_sidedef->rowoffset; polybottomslope = popenbottomslope + gr_sidedef->rowoffset;
polytopslope = polybottomslope + midtexheight; polytopslope = polybottomslope + midtexheight;
} }
else else // Skew it according to the ceiling's slope
{ {
polytop = popentop + gr_sidedef->rowoffset; polytop = popentop + gr_sidedef->rowoffset;
polybottom = polytop - textureheight[gr_midtexture]*repeats;
polybottom = polytop - midtexheight; polybottom = polytop - midtexheight;
polytopslope = popentopslope + gr_sidedef->rowoffset; polytopslope = popentopslope + gr_sidedef->rowoffset;
polybottomslope = polytopslope - midtexheight; polybottomslope = polytopslope - midtexheight;
@@ -1851,9 +1833,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
lS = max(polybottomslope, lowcutslope); lS = max(polybottomslope, lowcutslope);
// PEGGING // PEGGING
fixed_t texturevpeg, texturevpegslope; fixed_t texturevpegslope;
grTex = HWR_GetTexture(gr_midtexture, gr_linedef->flags & ML_TFERLINE);
if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3))
{ {
@@ -1866,11 +1846,16 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
texturevpegslope = polytopslope - hS; texturevpegslope = polytopslope - hS;
} }
grTex = HWR_GetTexture(gr_midtexture, noencore);
// Left side
wallVerts[3].t = texturevpeg * grTex->scaleY; wallVerts[3].t = texturevpeg * grTex->scaleY;
wallVerts[0].t = (h - l + texturevpeg) * grTex->scaleY; wallVerts[0].t = (h - l + texturevpeg) * grTex->scaleY;
wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX;
// Right side
wallVerts[2].t = texturevpegslope * grTex->scaleY; wallVerts[2].t = texturevpegslope * grTex->scaleY;
wallVerts[1].t = (hS - lS + texturevpegslope) * grTex->scaleY; wallVerts[1].t = (hS - lS + texturevpegslope) * grTex->scaleY;
wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX;
// set top/bottom coords // set top/bottom coords
@@ -1889,9 +1874,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
blendmode |= PF_Decal; blendmode |= PF_Decal;
if (!gl_drawing_stencil && gr_frontsector->numlights) if (!gl_drawing_stencil && gr_frontsector->numlights)
HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, (!(blendmode & PF_Masked)) ? FF_TRANSLUCENT : FF_CUTLEVEL, NULL, PF_Decal); HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, noencore, &Surf, (!(blendmode & PF_Masked)) ? FF_TRANSLUCENT : FF_CUTLEVEL, NULL, PF_Decal);
else if (!gl_drawing_stencil && !(blendmode & PF_Masked)) else if (!gl_drawing_stencil && !(blendmode & PF_Masked))
HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, gr_linedef->flags & ML_TFERLINE, blendmode, false, lightnum, colormap); HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, noencore, blendmode, false, lightnum, colormap);
else else
HWR_ProjectWall(wallVerts, &Surf, blendmode, lightnum, colormap); HWR_ProjectWall(wallVerts, &Surf, blendmode, lightnum, colormap);
} }
@@ -1911,7 +1896,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
else else
texturevpeg = gr_sidedef->rowoffset; // top of texture at top texturevpeg = gr_sidedef->rowoffset; // top of texture at top
grTex = HWR_GetTexture(gr_midtexture, gr_linedef->flags & ML_TFERLINE); grTex = HWR_GetTexture(gr_midtexture, noencore);
wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY;
wallVerts[0].t = wallVerts[1].t = (texturevpeg + gr_frontsector->ceilingheight - gr_frontsector->floorheight) * grTex->scaleY; wallVerts[0].t = wallVerts[1].t = (texturevpeg + gr_frontsector->ceilingheight - gr_frontsector->floorheight) * grTex->scaleY;
@@ -1944,11 +1929,11 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope); wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope);
if (gr_frontsector->numlights) if (gr_frontsector->numlights)
HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, noencore, &Surf, FF_CUTLEVEL, NULL, 0);
else // I don't think that solid walls can use translucent linedef types... else // I don't think that solid walls can use translucent linedef types...
{ {
if (grTex->mipmap.flags & TF_TRANSPARENT) if (grTex->mipmap.flags & TF_TRANSPARENT)
HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, gr_linedef->flags & ML_TFERLINE, PF_Environment, false, lightnum, colormap); HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, noencore, PF_Environment, false, lightnum, colormap);
else else
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap);
} }
@@ -1965,22 +1950,21 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
HWR_DrawSkyWall(wallVerts, &Surf); HWR_DrawSkyWall(wallVerts, &Surf);
} }
// Single sided lines are simple for skywalls, just need to draw from the top or bottom of the sector if there's
// a sky flat
if (!gr_curline->polyseg) if (!gr_curline->polyseg)
{ {
if (gr_frontsector->ceilingpic == skyflatnum) // It's a single-sided line with sky for its sector if (gr_frontsector->ceilingpic == skyflatnum) // It's a single-sided line with sky for its sector
{ {
wallVerts[3].y = wallVerts[2].y = FIXED_TO_FLOAT(INT32_MAX); wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(INT32_MAX); // draw to top of map space
wallVerts[0].y = FIXED_TO_FLOAT(worldtop); wallVerts[0].y = FIXED_TO_FLOAT(worldtop);
wallVerts[1].y = FIXED_TO_FLOAT(worldtopslope); wallVerts[1].y = FIXED_TO_FLOAT(worldtopslope);
HWR_DrawSkyWall(wallVerts, &Surf); HWR_DrawSkyWall(wallVerts, &Surf);
} }
if (gr_frontsector->floorpic == skyflatnum) if (gr_frontsector->floorpic == skyflatnum)
{ {
wallVerts[3].y = FIXED_TO_FLOAT(worldbottom); wallVerts[3].y = FIXED_TO_FLOAT(worldbottom);
wallVerts[2].y = FIXED_TO_FLOAT(worldbottomslope); wallVerts[2].y = FIXED_TO_FLOAT(worldbottomslope);
wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(INT32_MIN); wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(INT32_MIN); // draw to bottom of map space
HWR_DrawSkyWall(wallVerts, &Surf); HWR_DrawSkyWall(wallVerts, &Surf);
} }
@@ -1988,7 +1972,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
} }
//Hurdler: 3d-floors test //Hurdler: 3d-floors test
if (!gl_drawing_stencil && gr_frontsector && gr_backsector && gr_frontsector->tag != gr_backsector->tag && (gr_backsector->ffloors || gr_frontsector->ffloors)) if (!gl_drawing_stencil && gr_backsector && gr_frontsector->tag != gr_backsector->tag && (gr_backsector->ffloors || gr_frontsector->ffloors))
{ {
ffloor_t * rover; ffloor_t * rover;
fixed_t highcut = 0, lowcut = 0; fixed_t highcut = 0, lowcut = 0;
@@ -2120,9 +2104,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
lightnum = rover->master->frontsector->lightlevel; lightnum = rover->master->frontsector->lightlevel;
colormap = rover->master->frontsector->extra_colormap; colormap = rover->master->frontsector->extra_colormap;
lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gr_curline);
Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(lightnum, colormap);
lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gr_curline);
if (gr_frontsector->numlights) if (gr_frontsector->numlights)
HWR_SplitWall(gr_frontsector, wallVerts, 0, false, &Surf, rover->flags, rover, 0); HWR_SplitWall(gr_frontsector, wallVerts, 0, false, &Surf, rover->flags, rover, 0);
@@ -2144,7 +2129,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
else else
{ {
if (blendmode != PF_Masked) if (blendmode != PF_Masked)
HWR_AddTransparentWall(wallVerts, &Surf, texnum, gr_linedef->flags & ML_TFERLINE, blendmode, false, lightnum, colormap); HWR_AddTransparentWall(wallVerts, &Surf, texnum, noencore, blendmode, false, lightnum, colormap);
else else
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap);
} }
@@ -2234,9 +2219,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
lightnum = rover->master->frontsector->lightlevel; lightnum = rover->master->frontsector->lightlevel;
colormap = rover->master->frontsector->extra_colormap; colormap = rover->master->frontsector->extra_colormap;
lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gr_curline);
Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(lightnum, colormap);
lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gr_curline);
if (gr_backsector->numlights) if (gr_backsector->numlights)
HWR_SplitWall(gr_backsector, wallVerts, 0, false, &Surf, rover->flags, rover, 0); HWR_SplitWall(gr_backsector, wallVerts, 0, false, &Surf, rover->flags, rover, 0);
@@ -3325,7 +3311,7 @@ static void HWR_RenderBSPNode(INT32 bspnum)
bsp = &nodes[bspnum]; bsp = &nodes[bspnum];
// Decide which side the view point is on. // Decide which side the view point is on.
side = R_PointOnSide(viewx, viewy, bsp); side = R_PointOnSideRender(viewx, viewy, bsp);
// Recursively divide front space. // Recursively divide front space.
if (HWR_PortalCheckBBox(bsp->bbox[side])) if (HWR_PortalCheckBBox(bsp->bbox[side]))
@@ -4496,9 +4482,10 @@ static void HWR_RenderDrawNodes(void)
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Draw all vissprites // Draw all vissprites
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
void HWR_DrawSprites(void) static void HWR_DrawSprites(void)
{ {
UINT32 i; UINT32 i;
for (i = 0; i < gr_visspritecount; i++) for (i = 0; i < gr_visspritecount; i++)
{ {
gr_vissprite_t *spr = gr_vsprorder[i]; gr_vissprite_t *spr = gr_vsprorder[i];
@@ -4542,7 +4529,7 @@ void HWR_DrawSprites(void)
// HWR_AddSprites // HWR_AddSprites
// During BSP traversal, this adds sprites by sector. // During BSP traversal, this adds sprites by sector.
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
void HWR_AddSprites(sector_t *sec) static void HWR_AddSprites(sector_t *sec)
{ {
mobj_t *thing; mobj_t *thing;
fixed_t limit_dist; fixed_t limit_dist;
@@ -4629,7 +4616,7 @@ static void HWR_AddPrecipitationSprites(void)
// Generates a vissprite for a thing if it might be visible. // Generates a vissprite for a thing if it might be visible.
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// BP why not use xtoviexangle/viewangletox like in bsp ?.... // BP why not use xtoviexangle/viewangletox like in bsp ?....
void HWR_ProjectSprite(mobj_t *thing) static void HWR_ProjectSprite(mobj_t *thing)
{ {
gr_vissprite_t *vis; gr_vissprite_t *vis;
float tr_x, tr_y; float tr_x, tr_y;
@@ -4666,12 +4653,12 @@ void HWR_ProjectSprite(mobj_t *thing)
angle_t sliptiderollangle = 0; angle_t sliptiderollangle = 0;
#endif #endif
// uncapped/interpolation
interpmobjstate_t interp = {0};
if (!thing) if (!thing)
return; return;
// uncapped/interpolation
interpmobjstate_t interp = {0};
vflip = (thing->eflags & MFE_VERTICALFLIP); vflip = (thing->eflags & MFE_VERTICALFLIP);
mirrored = thing->mirrored; mirrored = thing->mirrored;
hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored);
@@ -4776,9 +4763,9 @@ void HWR_ProjectSprite(mobj_t *thing)
else else
{ {
// choose a different rotation based on player view // choose a different rotation based on player view
if ((ang < ANGLE_180) && (sprframe->rotate & SRF_RIGHT)) // See from right if ((sprframe->rotate & SRF_RIGHT) && (ang < ANGLE_180)) // See from right
rot = 6; // F7 slot rot = 6; // F7 slot
else if ((ang >= ANGLE_180) && (sprframe->rotate & SRF_LEFT)) // See from left else if ((sprframe->rotate & SRF_LEFT) && (ang >= ANGLE_180)) // See from left
rot = 2; // F3 slot rot = 2; // F3 slot
else // Normal behaviour else // Normal behaviour
rot = (ang+ANGLE_202h)>>29; rot = (ang+ANGLE_202h)>>29;
@@ -4823,10 +4810,10 @@ void HWR_ProjectSprite(mobj_t *thing)
if (rotsprite != NULL) if (rotsprite != NULL)
{ {
spr_width = rotsprite->width << FRACBITS; spr_width = SHORT(rotsprite->width) << FRACBITS;
spr_height = rotsprite->height << FRACBITS; spr_height = SHORT(rotsprite->height) << FRACBITS;
spr_offset = rotsprite->leftoffset << FRACBITS; spr_offset = SHORT(rotsprite->leftoffset) << FRACBITS;
spr_topoffset = rotsprite->topoffset << FRACBITS; spr_topoffset = SHORT(rotsprite->topoffset) << FRACBITS;
spr_topoffset += FEETADJUST; spr_topoffset += FEETADJUST;
// flip -> rotate, not rotate -> flip // flip -> rotate, not rotate -> flip
@@ -4836,21 +4823,8 @@ void HWR_ProjectSprite(mobj_t *thing)
} }
#endif #endif
if (thing->renderflags & RF_ABSOLUTEOFFSETS) spr_offset += interp.spritexoffset;
{ spr_topoffset += interp.spriteyoffset;
spr_offset = interp.spritexoffset;
spr_topoffset = interp.spriteyoffset;
}
else
{
SINT8 flipoffset = 1;
if ((thing->renderflags & RF_FLIPOFFSETS) && flip)
flipoffset = -1;
spr_offset += interp.spritexoffset * flipoffset;
spr_topoffset += interp.spriteyoffset * flipoffset;
}
if (papersprite) if (papersprite)
{ {
@@ -4910,13 +4884,12 @@ void HWR_ProjectSprite(mobj_t *thing)
if (heightsec != -1 && phs != -1) // only clip things which are in special sectors if (heightsec != -1 && phs != -1) // only clip things which are in special sectors
{ {
if (gr_viewz < FIXED_TO_FLOAT(sectors[phs].floorheight) ? if (gr_viewz < FIXED_TO_FLOAT(sectors[phs].floorheight) ?
FIXED_TO_FLOAT(interp.z) >= FIXED_TO_FLOAT(sectors[heightsec].floorheight) : FIXED_TO_FLOAT(interp.z) >= FIXED_TO_FLOAT(sectors[heightsec].floorheight) :
gzt < FIXED_TO_FLOAT(sectors[heightsec].floorheight)) gzt < FIXED_TO_FLOAT(sectors[heightsec].floorheight))
return; return;
if (gr_viewz > FIXED_TO_FLOAT(sectors[phs].ceilingheight) ? if (gr_viewz > FIXED_TO_FLOAT(sectors[phs].ceilingheight) ?
gzt < FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) && gr_viewz >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) : gzt < FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) && gr_viewz >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) :
FIXED_TO_FLOAT(interp.z) >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight)) FIXED_TO_FLOAT(interp.z) >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight))
return; return;
} }
@@ -4926,7 +4899,9 @@ void HWR_ProjectSprite(mobj_t *thing)
vis->x2 = x2; vis->x2 = x2;
vis->z1 = z1; vis->z1 = z1;
vis->z2 = z2; vis->z2 = z2;
vis->tz = tz; // Keep tz for the simple sprite sorting that happens vis->tz = tz; // Keep tz for the simple sprite sorting that happens
vis->dispoffset = thing->info->dispoffset; // Monster Iestyn: 23/11/15: HARDWARE SUPPORT AT LAST vis->dispoffset = thing->info->dispoffset; // Monster Iestyn: 23/11/15: HARDWARE SUPPORT AT LAST
vis->flip = flip; vis->flip = flip;
@@ -5218,9 +5193,6 @@ static void HWR_SetTransformAiming(FTransform *trans)
void HWR_SetTransform(float fpov, player_t *player) void HWR_SetTransform(float fpov, player_t *player)
{ {
postimg_t *postprocessor = &postimgtype[0];
INT32 i;
gr_viewx = FIXED_TO_FLOAT(viewx); gr_viewx = FIXED_TO_FLOAT(viewx);
gr_viewy = FIXED_TO_FLOAT(viewy); gr_viewy = FIXED_TO_FLOAT(viewy);
gr_viewz = FIXED_TO_FLOAT(viewz); gr_viewz = FIXED_TO_FLOAT(viewz);
@@ -5249,24 +5221,16 @@ void HWR_SetTransform(float fpov, player_t *player)
HWR_RollTransform(&atransform, viewroll); HWR_RollTransform(&atransform, viewroll);
atransform.splitscreen = splitscreen; atransform.splitscreen = splitscreen;
for (i = 0; i <= splitscreen; i++)
{
if (player != &players[displayplayers[i]])
continue;
postprocessor = &postimgtype[i];
}
atransform.flip = false; atransform.flip = false;
if (*postprocessor == postimg_flip) if ((player->postimgflags & POSTIMG_FLIP) && !(player->postimgflags & POSTIMG_MIRROR))
atransform.flip = true; atransform.flip = true;
atransform.mirror = false; atransform.mirror = false;
if (*postprocessor == postimg_mirror) if ((player->postimgflags & POSTIMG_MIRROR) && !(player->postimgflags & POSTIMG_FLIP))
atransform.mirror = true; atransform.mirror = true;
atransform.mirrorflip = false; atransform.mirrorflip = false;
if (*postprocessor == postimg_mirrorflip) if ((player->postimgflags & POSTIMG_FLIP) && (player->postimgflags & POSTIMG_MIRROR))
atransform.mirrorflip = true; atransform.mirrorflip = true;
// Set transform. // Set transform.
@@ -5352,7 +5316,7 @@ static void HWR_RenderPortal(gl_portal_t* portal, gl_portal_t* rootportal, const
HWR_PortalFrame(rootportal); HWR_PortalFrame(rootportal);
else // current frame is not a portal frame but the main view! else // current frame is not a portal frame but the main view!
{ {
R_SetupFrame(player, false); R_SetupFrame(player);
portalclipline = NULL; portalclipline = NULL;
} }
@@ -5626,7 +5590,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
} }
PS_STOP_TIMING(ps_skyboxtime); PS_STOP_TIMING(ps_skyboxtime);
R_SetupFrame(player, false); // This can stay false because it is only used to set viewsky in r_main.c, which isn't used here R_SetupFrame(player); // This can stay false because it is only used to set viewsky in r_main.c, which isn't used here
framecount++; // for timedemo framecount++; // for timedemo
HWR_RenderFrame(viewnumber, player, false); HWR_RenderFrame(viewnumber, player, false);
} }
@@ -5702,8 +5666,6 @@ void HWR_AddCommands(void)
CV_RegisterVar(&cv_grbatching); CV_RegisterVar(&cv_grbatching);
CV_RegisterVar(&cv_splitwallfix);
CV_RegisterVar(&cv_grrenderdistance); CV_RegisterVar(&cv_grrenderdistance);
CV_RegisterVar(&cv_grfakecontrast); CV_RegisterVar(&cv_grfakecontrast);
@@ -5829,20 +5791,8 @@ INT32 HWR_GetTextureUsed(void)
void HWR_DoPostProcessor(player_t *player) void HWR_DoPostProcessor(player_t *player)
{ {
postimg_t *type = &postimgtype[0];
UINT8 i;
HWD.pfnUnSetShader(); HWD.pfnUnSetShader();
for (i = splitscreen; i > 0; i--)
{
if (player != &players[displayplayers[i]])
continue;
type = &postimgtype[i];
break;
}
// Armageddon Blast Flash! // Armageddon Blast Flash!
// Could this even be considered postprocessor? // Could this even be considered postprocessor?
if (!HWR_PalRenderFlashpal() && player->flashcount) if (!HWR_PalRenderFlashpal() && player->flashcount)
@@ -5879,7 +5829,7 @@ void HWR_DoPostProcessor(player_t *player)
return; return;
// Drunken vision! WooOOooo~ // Drunken vision! WooOOooo~
if (*type == postimg_water || *type == postimg_heat) if (player->postimgflags & POSTIMG_WATER || player->postimgflags & POSTIMG_HEAT)
{ {
// 10 by 10 grid. 2 coordinates (xy) // 10 by 10 grid. 2 coordinates (xy)
float v[SCREENVERTS][SCREENVERTS][2]; float v[SCREENVERTS][SCREENVERTS][2];
@@ -5891,7 +5841,7 @@ void HWR_DoPostProcessor(player_t *player)
INT32 FREQUENCY; INT32 FREQUENCY;
// Modifies the wave. // Modifies the wave.
if (*type == postimg_water) if (player->postimgflags & POSTIMG_WATER)
{ {
WAVELENGTH = 5; WAVELENGTH = 5;
AMPLITUDE = 20; AMPLITUDE = 20;
+1 -8
View File
@@ -116,7 +116,7 @@ void HWR_MakeScreenFinalTexture(void);
void HWR_DrawScreenFinalTexture(INT32 width, INT32 height); void HWR_DrawScreenFinalTexture(INT32 width, INT32 height);
// hw_main.c: Planes // hw_main.c: Planes
void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap); //void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap);
void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap); void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap);
void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, FBITFIELD blendmode, UINT8 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap); void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, FBITFIELD blendmode, UINT8 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap);
@@ -131,12 +131,6 @@ void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo * pSurf, INT32 t
void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf); void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf);
void HWR_DrawSkyBackground(float fpov); void HWR_DrawSkyBackground(float fpov);
// hw_main.c: Sprites
void HWR_AddSprites(sector_t *sec);
void HWR_ProjectSprite(mobj_t *thing);
//void HWR_ProjectPrecipitationSprite(precipmobj_t *thing);
void HWR_DrawSprites(void);
// hw_bsp.c // hw_bsp.c
void HWR_CreatePlanePolygons(INT32 bspnum); void HWR_CreatePlanePolygons(INT32 bspnum);
extern boolean gr_maphasportals; extern boolean gr_maphasportals;
@@ -152,7 +146,6 @@ extern consvar_t cv_grshaders;
#ifdef USE_FBO_OGL #ifdef USE_FBO_OGL
extern consvar_t cv_grframebuffer; extern consvar_t cv_grframebuffer;
#endif #endif
extern consvar_t cv_splitwallfix;
extern consvar_t cv_grshearing; extern consvar_t cv_grshearing;
extern consvar_t cv_grfov; extern consvar_t cv_grfov;
extern consvar_t cv_grmdls; extern consvar_t cv_grmdls;
+2 -1
View File
@@ -2617,7 +2617,8 @@ static void HU_DrawRankings(void)
boolean completed[MAXPLAYERS]; boolean completed[MAXPLAYERS];
UINT32 whiteplayer = MAXPLAYERS; UINT32 whiteplayer = MAXPLAYERS;
V_DrawFadeScreen(0xFF00, 16); // A little more readable, and prevents cheating the fades under other circumstances. if (!automapactive)
V_DrawFadeScreen(0xFF00, 16); // A little more readable, and prevents cheating the fades under other circumstances.
if (cons_menuhighlight.value) if (cons_menuhighlight.value)
hilicol = cons_menuhighlight.value; hilicol = cons_menuhighlight.value;
+41 -47
View File
@@ -3308,56 +3308,55 @@ static void K_QuiteSaltyHop(player_t *p)
void K_RollMobjBySlopes(mobj_t* mo, boolean usedistance) void K_RollMobjBySlopes(mobj_t* mo, boolean usedistance)
{ {
I_Assert(mo->subsector != NULL); I_Assert(mo->subsector != NULL);
I_Assert(mo->subsector->sector != NULL); I_Assert(mo->subsector->sector != NULL);
angle_t an; angle_t an;
boolean flip = mo->eflags & MFE_VERTICALFLIP; const boolean flip = mo->eflags & MFE_VERTICALFLIP;
fixed_t m_dist = R_PointToDist(mo->x, mo->y); const fixed_t m_dist = usedistance ? R_PointToDist(mo->x, mo->y) : 0;
fixed_t rolldist = cv_sloperolldist.value * mapobjectscale; const fixed_t rolldist = cv_sloperolldist.value * mapobjectscale;
// lifted from hw_md2 // lifted from hw_md2
if (mo->standingslope) if (mo->standingslope)
{ {
fixed_t tempz = mo->standingslope->normal.z; fixed_t tempz = mo->standingslope->normal.z;
fixed_t tempy = mo->standingslope->normal.y; fixed_t tempy = mo->standingslope->normal.y;
fixed_t tempx = mo->standingslope->normal.x; fixed_t tempx = mo->standingslope->normal.x;
fixed_t tempangle = -(R_PointToAngle2( fixed_t tempangle = -(R_PointToAngle2(0, 0, FixedSqrt(FixedMul(tempy, tempy) + FixedMul(tempz, tempz)), tempx));
0, 0, FixedSqrt(FixedMul(tempy, tempy) + FixedMul(tempz, tempz)), tempx));
// admittedly this is a very hacky way to do the pitch and roll easing // admittedly this is a very hacky way to do the pitch and roll easing
// pitch // pitch
if ((!usedistance) || (m_dist <= (rolldist))) if ((!usedistance) || (m_dist <= (rolldist)))
{ {
an = (INT32)((angle_t)tempangle - mo->pitch_sprite) / SLOPEROLL_DIV; an = (INT32)((angle_t)tempangle - mo->pitch_sprite) / SLOPEROLL_DIV;
mo->pitch_sprite = an ? mo->pitch_sprite + an : (angle_t)tempangle; mo->pitch_sprite = an ? mo->pitch_sprite + an : (angle_t)tempangle;
} }
else else
mo->pitch_sprite = FixedAngle(0); mo->pitch_sprite = FixedAngle(0);
mo->slopepitch = flip ? InvAngle(mo->pitch_sprite) : mo->pitch_sprite; mo->slopepitch = flip ? InvAngle(mo->pitch_sprite) : mo->pitch_sprite;
// roll // roll
tempangle = (R_PointToAngle2(0, 0, tempz, tempy)); tempangle = (R_PointToAngle2(0, 0, tempz, tempy));
if ((!usedistance) || (m_dist <= (rolldist))) if (!usedistance || (m_dist <= (rolldist)))
{ {
an = (INT32)((angle_t)tempangle - mo->roll_sprite) / SLOPEROLL_DIV; an = (INT32)((angle_t)tempangle - mo->roll_sprite) / SLOPEROLL_DIV;
mo->roll_sprite = an ? mo->roll_sprite + an : (angle_t)tempangle; mo->roll_sprite = an ? mo->roll_sprite + an : (angle_t)tempangle;
} }
else else
mo->roll_sprite = FixedAngle(0); mo->roll_sprite = FixedAngle(0);
mo->sloperoll = flip ? InvAngle(mo->roll_sprite) : mo->roll_sprite; mo->sloperoll = flip ? InvAngle(mo->roll_sprite) : mo->roll_sprite;
} }
else if (P_IsObjectOnGround(mo)) else if (P_IsObjectOnGround(mo))
{ {
mo->sloperoll = FixedAngle(0); mo->sloperoll = FixedAngle(0);
mo->slopepitch = FixedAngle(0); mo->slopepitch = FixedAngle(0);
} }
} }
void K_SpawnBoostTrail(player_t *player) void K_SpawnBoostTrail(player_t *player)
@@ -4460,7 +4459,6 @@ void K_RepairOrbitChain(mobj_t *orbit)
if (orbit->target && orbit->target->player) if (orbit->target && orbit->target->player)
{ {
player_t *player = orbit->target->player; player_t *player = orbit->target->player;
INT32 num = 0; INT32 num = 0;
mobj_t *cur = orbit->target->hnext; mobj_t *cur = orbit->target->hnext;
@@ -6504,14 +6502,10 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
player->mo->spriteyscale = player->mo->realyscale; player->mo->spriteyscale = player->mo->realyscale;
} }
boolean usedist = false; if (cv_spriteroll.value && cv_sloperoll.value)
if (cv_sloperolldist.value > 0)
usedist = true;
if ((cv_spriteroll.value) && (cv_sloperoll.value))
{ {
if ((!player->mo->salty_jump)) // seeing a character rotate mid-hop looks really janky if ((!player->mo->salty_jump)) // seeing a character rotate mid-hop looks really janky
K_RollMobjBySlopes(player->mo, usedist); K_RollMobjBySlopes(player->mo, (cv_sloperolldist.value && !splitscreen));
} }
else else
{ {
+3 -1
View File
@@ -111,6 +111,8 @@ static void A_Lua(mobj_t *actor)
lua_pushinteger(gL, var2); lua_pushinteger(gL, var2);
LUA_Call(gL, 3, 0, 1); LUA_Call(gL, 3, 0, 1);
lua_pop(gL, 1); // pop error handler
if (found) if (found)
{ {
--superstack; --superstack;
@@ -940,7 +942,7 @@ static int lib_setSfxInfo(lua_State *L)
if (lua_isnumber(L, 2)) if (lua_isnumber(L, 2))
{ {
int j = lua_tointeger(L, 2) - 1; int j = lua_tointeger(L, 2);
// Read and Write enums were combined, need to do this switch now // Read and Write enums were combined, need to do this switch now
switch (j) switch (j)
+1 -1
View File
@@ -281,7 +281,7 @@ static int lib_iterateSectorThinglist(lua_State *L)
if (!lua_isnil(L, 1)) if (!lua_isnil(L, 1))
{ {
thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
if (P_MobjWasRemoved(thing)) if (!thing)
return luaL_error(L, "current entry in thinglist was removed; avoid calling P_RemoveMobj on entries!"); return luaL_error(L, "current entry in thinglist was removed; avoid calling P_RemoveMobj on entries!");
thing = thing->snext; thing = thing->snext;
} }
+189 -341
View File
@@ -37,8 +37,9 @@
/* /*
* Sacrifice very little compression quality in favour of compression speed. * Sacrifice very little compression quality in favour of compression speed.
* This gives almost the same compression as the default code, and is * This gives almost the same compression as the default code, and is
* (very roughly) 15% faster. This is the preferred mode of operation. * (very roughly) 15% faster. This is the preferable mode of operation.
*/ */
#ifndef VERY_FAST #ifndef VERY_FAST
# define VERY_FAST 1 # define VERY_FAST 1
#endif #endif
@@ -47,7 +48,7 @@
* Sacrifice some more compression quality in favour of compression speed. * Sacrifice some more compression quality in favour of compression speed.
* (roughly 1-2% worse compression for large blocks and * (roughly 1-2% worse compression for large blocks and
* 9-10% for small, redundant, blocks and >>20% better speed in both cases) * 9-10% for small, redundant, blocks and >>20% better speed in both cases)
* In short: when in need for speed, enable this for binary data, * In INT16: when in need for speed, enable this for binary data,
* possibly disable this for text data. * possibly disable this for text data.
*/ */
#ifndef ULTRA_FAST #ifndef ULTRA_FAST
@@ -65,10 +66,21 @@
#endif #endif
#endif #endif
/*
* Use string functions to copy memory.
* this is usually a loss, even with glibc's optimized memcpy
*/
#ifndef USE_MEMCPY
#ifdef _MSC_VER
# define USE_MEMCPY 0
#else
# define USE_MEMCPY 1
#endif
#endif
/* /*
* You may choose to pre-set the hash table (might be faster on some * You may choose to pre-set the hash table (might be faster on some
* modern cpus and large (>>64k) blocks, and also makes compression * modern cpus and large (>>64k) blocks)
* deterministic/repeatable when the configuration otherwise is the same).
*/ */
#ifndef INIT_HTAB #ifndef INIT_HTAB
# define INIT_HTAB 1 # define INIT_HTAB 1
@@ -76,15 +88,15 @@
/* /*
* Avoid assigning values to errno variable? for some embedding purposes * Avoid assigning values to errno variable? for some embedding purposes
* (linux kernel for example), this is necessary. NOTE: this breaks * (linux kernel for example), this is neccessary. NOTE: this breaks
* the documentation in lzf.h. Avoiding errno has no speed impact. * the documentation in lzf.h.
*/ */
#ifndef AVOID_ERRNO #ifndef AVOID_ERRNO
# define AVOID_ERRNO 0 # define AVOID_ERRNO 0
#endif #endif
/* /*
* Whether to pass the LZF_STATE variable as argument, or allocate it * Wether to pass the LZF_STATE variable as argument, or allocate it
* on the stack. For small-stack environments, define this to 1. * on the stack. For small-stack environments, define this to 1.
* NOTE: this breaks the prototype in lzf.h. * NOTE: this breaks the prototype in lzf.h.
*/ */
@@ -93,108 +105,50 @@
#endif #endif
/* /*
* Whether to add extra checks for input validity in lzf_decompress * Wether to add extra checks for input validity in lzf_decompress
* and return EINVAL if the input stream has been corrupted. This * and return EINVAL if the input stream has been corrupted. This
* only shields against overflowing the input buffer and will not * only shields against overflowing the input buffer and will not
* detect most corrupted streams. * detect most corrupted streams.
* This check is not normally noticeable on modern hardware * This check is not normally noticable on modern hardware
* (<1% slowdown), but might slow down older cpus considerably. * (<1% slowdown), but might slow down older cpus considerably.
*/ */
#ifndef CHECK_INPUT #ifndef CHECK_INPUT
# define CHECK_INPUT 1 # define CHECK_INPUT 1
#endif #endif
/*
* Whether the target CPU has a slow multiplication. This affects
* the default hash function for the compressor, and enables a slightly
* worse hash function that needs only shifts.
*/
#ifndef MULTIPLICATION_IS_SLOW
# define MULTIPLICATION_IS_SLOW 0
#endif
/*
* If defined, then this data type will be used for storing offsets.
* This can be useful if you want to use a huge hashtable, want to
* conserve memory, or both, and your data fits into e.g. 64kb.
* If instead you want to compress data > 4GB, then it's better to
* to "#define LZF_USE_OFFSETS 0" instead.
*/
/*#define LZF_HSLOT unsigned short*/
/*
* Whether to store pointers or offsets inside the hash table. On
* 64 bit architetcures, pointers take up twice as much space,
* and might also be slower. Default is to autodetect.
*/
/*#define LZF_USE_OFFSETS autodetect */
/*
* Whether to optimise code for size, at the expense of speed. Use
* this when you are extremely tight on memory, perhaps in combination
* with AVOID_ERRNO 1 and CHECK_INPUT 0.
*/
#ifndef OPTIMISE_SIZE
# ifdef __OPTIMIZE_SIZE__
# define OPTIMISE_SIZE 1
# else
# define OPTIMISE_SIZE 0
# endif
#endif
/*****************************************************************************/ /*****************************************************************************/
/* nothing should be changed below */ /* nothing should be changed below */
# include <string.h>
# include <limits.h>
#if ULTRA_FAST
# undef VERY_FAST
#endif
#ifndef LZF_USE_OFFSETS
# ifdef _WIN32
# define LZF_USE_OFFSETS defined(_M_X64)
# else
# include <stdint.h>
# define LZF_USE_OFFSETS (UINTPTR_MAX > 0xffffffffU)
# endif
#endif
typedef unsigned char u8; typedef unsigned char u8;
#ifdef LZF_HSLOT typedef const u8 *LZF_STATE[1 << (HLOG)];
# define LZF_HSLOT_BIAS ((const u8 *)in_data)
#else #if !STRICT_ALIGN
# ifdef LZF_USE_OFFSETS /* for unaligned accesses we need a 16 bit datatype. */
# define LZF_HSLOT_BIAS ((const u8 *)in_data) # include <limits.h>
typedef unsigned int LZF_HSLOT; # if USHRT_MAX == 65535
typedef unsigned short u16;
# elif UINT_MAX == 65535
typedef unsigned int u16;
# else # else
# define LZF_HSLOT_BIAS 0 # undef STRICT_ALIGN
typedef const u8 *LZF_HSLOT; # define STRICT_ALIGN 1
# endif # endif
#endif #endif
#if USHRT_MAX == 65535 #if ULTRA_FAST
typedef unsigned short u16; # if defined(VERY_FAST)
#elif UINT_MAX == 65535 # undef VERY_FAST
typedef unsigned int u16; # endif
#else
# undef STRICT_ALIGN
# define STRICT_ALIGN 1
#endif #endif
#define LZF_MAX_LIT (1 << 5) #if USE_MEMCPY || INIT_HTAB
#define LZF_MAX_OFF (1 << 13) # ifdef __cplusplus
#define LZF_MAX_REF ((1 << 8) + (1 << 3)) # include <cstring>
# else
typedef LZF_HSLOT LZF_STATE[1 << (HLOG)]; # include <string.h>
# endif
typedef struct #endif
{
const u8 *first [1 << (6+8)]; /* most recent occurance of a match */
u16 prev [LZF_MAX_OFF]; /* how many bytes to go backwards for the next match */
} LZF_STATE_BEST[1];
#endif #endif
@@ -210,31 +164,14 @@ typedef struct
# define SET_ERRNO(n) errno = (n) # define SET_ERRNO(n) errno = (n)
#endif #endif
#ifndef USE_REP_MOVSB
#if (defined (__i386) || defined (__amd64)) && __GNUC__ >= 3
#define USE_REP_MOVSB 1
#else
#define USE_REP_MOVSB 0 // Default to 0 if not defined elsewhere
#endif
#endif
#if USE_REP_MOVSB /* small win on amd, big loss on intel */
#if (defined (__i386) || defined (__amd64)) && __GNUC__ >= 3
# define lzf_movsb(dst, src, len) \
asm ("rep movsb" \
: "=D" (dst), "=S" (src), "=c" (len) \
: "0" (dst), "1" (src), "2" (len));
#endif
#endif
size_t size_t
lzf_decompress (const void *const in_data, size_t in_len, lzf_decompress (const void *const in_data, size_t in_len,
void *out_data, size_t out_len) void *out_data, size_t out_len)
{ {
u8 const *ip = (const u8 *)in_data; u8 const *ip = (const u8 *)in_data;
u8 *op = (u8 *)out_data; u8 *op = (u8 *)out_data;
u8 const *const in_end = ip + in_len; u8 const *const in_end = ip + in_len;
u8 *const out_end = op + out_len; u8 *const out_end = op + out_len;
do do
{ {
@@ -258,23 +195,14 @@ lzf_decompress (const void *const in_data, size_t in_len,
} }
#endif #endif
#ifdef lzf_movsb #if USE_MEMCPY
lzf_movsb (op, ip, ctrl); M_Memcpy (op, ip, ctrl);
#elif OPTIMISE_SIZE op += ctrl;
while (ctrl--) ip += ctrl;
*op++ = *ip++;
#else #else
switch (ctrl) do
{ *op++ = *ip++;
case 32: *op++ = *ip++; case 31: *op++ = *ip++; case 30: *op++ = *ip++; case 29: *op++ = *ip++; while (--ctrl);
case 28: *op++ = *ip++; case 27: *op++ = *ip++; case 26: *op++ = *ip++; case 25: *op++ = *ip++;
case 24: *op++ = *ip++; case 23: *op++ = *ip++; case 22: *op++ = *ip++; case 21: *op++ = *ip++;
case 20: *op++ = *ip++; case 19: *op++ = *ip++; case 18: *op++ = *ip++; case 17: *op++ = *ip++;
case 16: *op++ = *ip++; case 15: *op++ = *ip++; case 14: *op++ = *ip++; case 13: *op++ = *ip++;
case 12: *op++ = *ip++; case 11: *op++ = *ip++; case 10: *op++ = *ip++; case 9: *op++ = *ip++;
case 8: *op++ = *ip++; case 7: *op++ = *ip++; case 6: *op++ = *ip++; case 5: *op++ = *ip++;
case 4: *op++ = *ip++; case 3: *op++ = *ip++; case 2: *op++ = *ip++; case 1: *op++ = *ip++;
}
#endif #endif
} }
else /* back reference */ else /* back reference */
@@ -316,49 +244,12 @@ lzf_decompress (const void *const in_data, size_t in_len,
return 0; return 0;
} }
#ifdef lzf_movsb *op++ = *ref++;
len += 2; *op++ = *ref++;
lzf_movsb (op, ref, len);
#elif OPTIMISE_SIZE
len += 2;
do do
*op++ = *ref++; *op++ = *ref++;
while (--len); while (--len);
#else
switch (len)
{
default:
len += 2;
if (op >= ref + len)
{
/* disjunct areas */
memcpy (op, ref, len);
op += len;
}
else
{
/* overlapping, use octet by octet copying */
do
*op++ = *ref++;
while (--len);
}
break;
case 9: *op++ = *ref++;
case 8: *op++ = *ref++;
case 7: *op++ = *ref++;
case 6: *op++ = *ref++;
case 5: *op++ = *ref++;
case 4: *op++ = *ref++;
case 3: *op++ = *ref++;
case 2: *op++ = *ref++;
case 1: *op++ = *ref++;
case 0: *op++ = *ref++; /* two octets more */
*op++ = *ref++;
}
#endif
} }
} }
while (ip < in_end); while (ip < in_end);
@@ -375,29 +266,23 @@ lzf_decompress (const void *const in_data, size_t in_len,
/* /*
* don't play with this unless you benchmark! * don't play with this unless you benchmark!
* the data format is not dependent on the hash function. * decompression is not dependent on the hash function
* the hash function might seem strange, just believe me, * the hashing function might seem strange, just believe me
* it works ;) * it works ;)
*/ */
#ifndef FRST #ifndef FRST
# define FRST(p) (((p[0]) << 8) | p[1]) # define FRST(p) (((p[0]) << 8) | p[1])
# define NEXT(v,p) (((v) << 8) | p[2]) # define NEXT(v,p) (((v) << 8) | p[2])
# if MULTIPLICATION_IS_SLOW # define IDX(h) ((((h ^ (h << 5)) >> (3*8 - HLOG)) - h*5) & (HSIZE - 1))
# if ULTRA_FAST
# define IDX(h) ((( h >> (3*8 - HLOG)) - h ) & (HSIZE - 1))
# elif VERY_FAST
# define IDX(h) ((( h >> (3*8 - HLOG)) - h*5) & (HSIZE - 1))
# else
# define IDX(h) ((((h ^ (h << 5)) >> (3*8 - HLOG)) - h*5) & (HSIZE - 1))
# endif
# else
/* this one was developed with sesse,
* and is very similar to the one in snappy.
* it does need a modern enough cpu with a fast multiplication.
*/
# define IDX(h) (((h * 0x1e35a7bdU) >> (32 - HLOG - 8)) & (HSIZE - 1))
# endif
#endif #endif
/*
* IDX works because it is very similar to a multiplicative hash, e.g.
* ((h * 57321 >> (3*8 - HLOG)) & (HSIZE - 1))
* the latter is also quite fast on newer CPUs, and sligthly better
*
* the next one is also quite good, albeit slow ;)
* (int)(cos(h & 0xffffff) * 1e6)
*/
#if 0 #if 0
/* original lzv-like hash function, much worse and thus slower */ /* original lzv-like hash function, much worse and thus slower */
@@ -406,214 +291,177 @@ lzf_decompress (const void *const in_data, size_t in_len,
# define IDX(h) ((h) & (HSIZE - 1)) # define IDX(h) ((h) & (HSIZE - 1))
#endif #endif
#if __GNUC__ >= 3 #define MAX_LIT (1 << 5)
# define expect(expr,value) __builtin_expect ((expr),(value)) #define MAX_OFF (1 << 13)
# define inline inline #define MAX_REF ((1 << 8) + (1 << 3))
#else
# define expect(expr,value) (expr)
# define inline static
#endif
#define expect_false(expr) expect ((expr) != 0, 0)
#define expect_true(expr) expect ((expr) != 0, 1)
/* /*
* compressed format * compressed format
* *
* 000LLLLL <L+1> ; literal, L+1=1..33 octets * 000LLLLL <L+1> ; literal
* LLLooooo oooooooo ; backref L+1=1..7 octets, o+1=1..4096 offset * LLLooooo oooooooo ; backref L
* 111ooooo LLLLLLLL oooooooo ; backref L+8 octets, o+1=1..4096 offset * 111ooooo LLLLLLLL oooooooo ; backref L+7
* *
*/ */
size_t size_t
lzf_compress (const void *const in_data, size_t in_len, lzf_compress (const void *const in_data,size_t in_len,
void *out_data, size_t out_len void *out_data, size_t out_len
#if LZF_STATE_ARG #if LZF_STATE_ARG
, LZF_STATE htab , LZF_STATE *htab
#endif #endif
) )
{ {
#if !LZF_STATE_ARG #if !LZF_STATE_ARG
LZF_STATE htab; LZF_STATE htab;
#endif #endif
const u8 **hslot;
const u8 *ip = (const u8 *)in_data; const u8 *ip = (const u8 *)in_data;
u8 *op = (u8 *)out_data; u8 *op = (u8 *)out_data;
const u8 *in_end = ip + in_len; const u8 *in_end = ip + in_len;
u8 *out_end = op + out_len; u8 *out_end = op + out_len;
const u8 *ref; const u8 *ref = NULL;
/*
* off requires a type wide enough to hold a general pointer difference.
* ISO C doesn't have that (size_t might not be enough and ptrdiff_t only
* works for differences within a single object). We also assume that
* no bit pattern traps. Since the only platform that is both non-POSIX
* and fails to support both assumptions is windows 64 bit, we make a
* special workaround for it.
*/
unsigned int hval = FRST (ip);
size_t off; size_t off;
unsigned int hval; int lit = 0;
int lit;
if (!in_len || !out_len)
return 0;
#if INIT_HTAB #if INIT_HTAB
# if USE_MEMCPY
memset (htab, 0, sizeof (htab)); memset (htab, 0, sizeof (htab));
# else
for (hslot = htab; hslot < htab + HSIZE; hslot++)
*hslot++ = ip;
# endif
#endif #endif
lit = 0; op++; /* start run */ for (;;)
hval = FRST (ip);
while (ip < in_end - 2)
{ {
LZF_HSLOT *hslot; if (ip < in_end - 2)
hval = NEXT (hval, ip);
hslot = htab + IDX (hval);
ref = *hslot + LZF_HSLOT_BIAS; *hslot = ip - LZF_HSLOT_BIAS;
if (1
#if INIT_HTAB
&& ref < ip /* the next test will actually take care of this, but this is faster */
#endif
&& (off = ip - ref - 1) < LZF_MAX_OFF
&& ref > (const u8 *)in_data
&& ref[2] == ip[2]
#if STRICT_ALIGN
&& ((ref[1] << 8) | ref[0]) == ((ip[1] << 8) | ip[0])
#else
&& *(const u16 *)ref == *(const u16 *)ip
#endif
)
{ {
/* match found at *ref++ */ hval = NEXT (hval, ip);
unsigned int len = 2; hslot = htab + IDX (hval);
size_t maxlen = in_end - ip - len; ref = *hslot; *hslot = ip;
maxlen = maxlen > LZF_MAX_REF ? LZF_MAX_REF : maxlen;
if (expect_false (op + 3 + 1 >= out_end)) /* first a faster conservative test */ if (
if (op - !lit + 3 + 1 >= out_end) /* second the exact but rare test */ #if INIT_HTAB && !USE_MEMCPY
return 0; ref < ip /* the next test will actually take care of this, but this is faster */
&&
op [- lit - 1] = lit - 1; /* stop run */ #endif
op -= !lit; /* undo run if length is zero */ (off = ip - ref - 1) < MAX_OFF
&& ip + 4 < in_end
for (;;) && ref > (const u8 *)in_data
#if STRICT_ALIGN
&& ref[0] == ip[0]
&& ref[1] == ip[1]
&& ref[2] == ip[2]
#else
&& *(const u16 *)ref == *(const u16 *)ip
&& ref[2] == ip[2]
#endif
)
{ {
if (expect_true (maxlen > 16)) /* match found at *ref++ */
{ unsigned int len = 2;
len++; if (ref [len] != ip [len]) break; size_t maxlen = in_end - ip - len;
len++; if (ref [len] != ip [len]) break; maxlen = maxlen > MAX_REF ? MAX_REF : maxlen;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break; if (op + lit + 1 + 3 >= out_end)
len++; if (ref [len] != ip [len]) break; return 0;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
len++; if (ref [len] != ip [len]) break;
}
do do
len++; len++;
while (len < maxlen && ref[len] == ip[len]); while (len < maxlen && ref[len] == ip[len]);
break; if (lit)
} {
*op++ = (u8)(lit - 1);
lit = -lit;
do
*op++ = ip[lit];
while (++lit);
}
len -= 2; /* len is now #octets - 1 */ len -= 2;
ip++; ip++;
if (len < 7) if (len < 7)
{ {
*op++ = (off >> 8) + (len << 5); *op++ = (u8)((off >> 8) + (len << 5));
} }
else else
{ {
*op++ = (off >> 8) + ( 7 << 5); *op++ = (u8)((off >> 8) + ( 7 << 5));
*op++ = len - 7; *op++ = (u8)(len - 7);
} }
*op++ = off; *op++ = (u8)off;
lit = 0; op++; /* start run */
ip += len + 1;
if (expect_false (ip >= in_end - 2))
break;
#if ULTRA_FAST || VERY_FAST #if ULTRA_FAST || VERY_FAST
--ip; ip += len;
# if VERY_FAST && !ULTRA_FAST #if VERY_FAST && !ULTRA_FAST
--ip; --ip;
# endif
hval = FRST (ip);
hval = NEXT (hval, ip);
htab[IDX (hval)] = ip - LZF_HSLOT_BIAS;
ip++;
# if VERY_FAST && !ULTRA_FAST
hval = NEXT (hval, ip);
htab[IDX (hval)] = ip - LZF_HSLOT_BIAS;
ip++;
# endif
#else
ip -= len + 1;
do
{
hval = NEXT (hval, ip);
htab[IDX (hval)] = ip - LZF_HSLOT_BIAS;
ip++;
}
while (len--);
#endif #endif
hval = FRST (ip);
hval = NEXT (hval, ip);
htab[IDX (hval)] = ip;
ip++;
#if VERY_FAST && !ULTRA_FAST
hval = NEXT (hval, ip);
htab[IDX (hval)] = ip;
ip++;
#endif
#else
do
{
hval = NEXT (hval, ip);
htab[IDX (hval)] = ip;
ip++;
}
while (len--);
#endif
continue;
}
} }
else else if (ip == in_end)
break;
/* one more literal byte we must copy */
lit++;
ip++;
if (lit == MAX_LIT)
{ {
/* one more literal byte we must copy */ if (op + 1 + MAX_LIT >= out_end)
if (expect_false (op >= out_end))
return 0; return 0;
lit++; *op++ = *ip++; *op++ = MAX_LIT - 1;
#if USE_MEMCPY
if (expect_false (lit == LZF_MAX_LIT)) M_Memcpy (op, ip - MAX_LIT, MAX_LIT);
{ op += MAX_LIT;
op [- lit - 1] = lit - 1; /* stop run */ lit = 0;
lit = 0; op++; /* start run */ #else
} lit = -lit;
do
*op++ = ip[lit];
while (++lit);
#endif
} }
} }
if (op + 3 > out_end) /* at most 3 bytes can be missing here */ if (lit)
return 0;
while (ip < in_end)
{ {
lit++; *op++ = *ip++; if (op + lit + 1 >= out_end)
return 0;
if (expect_false (lit == LZF_MAX_LIT)) *op++ = (u8)(lit - 1);
{ lit = -lit;
op [- lit - 1] = lit - 1; /* stop run */ do
lit = 0; op++; /* start run */ *op++ = ip[lit];
} while (++lit);
} }
op [- lit - 1] = lit - 1; /* end run */ return op - (u8 *) out_data;
op -= !lit; /* undo run if length is zero */
return op - (u8 *)out_data;
} }
+2 -2
View File
@@ -1,6 +1,6 @@
// SONIC ROBO BLAST 2 // SONIC ROBO BLAST 2
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Copyright (c) 2000-2010 Marc Alexander Lehmann <schmorp@schmorp.de> // Copyright (C) 2000-2005 by Marc Alexander Lehmann <schmorp@schmorp.de>
// //
// This program is free software distributed under the // This program is free software distributed under the
// terms of the GNU General Public License, version 2. // terms of the GNU General Public License, version 2.
@@ -22,7 +22,7 @@
** **
***********************************************************************/ ***********************************************************************/
#define LZF_VERSION 0x0106 /* 1.6 */ #define LZF_VERSION 0x0105 /* 1.5 */
/* /*
* Compress in_len bytes stored at the memory block starting at * Compress in_len bytes stored at the memory block starting at
-5
View File
@@ -1498,8 +1498,6 @@ static menuitem_t OP_ExpOptionsMenu[] =
{IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_grframebuffer, 110}, {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_grframebuffer, 110},
#endif #endif
{IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_grpalettedepth, 130}, {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_grpalettedepth, 130},
{IT_STRING | IT_CVAR, NULL, "Splitwall/Slope texture fix", &cv_splitwallfix, 150},
#endif #endif
}; };
@@ -1517,7 +1515,6 @@ static const char* OP_ExpTooltips[] =
"Allows the game to downsample from a higher resolution than your display\nin OpenGL renderer mode. Requires a GPU with atleast OpenGL 3.0 support.", "Allows the game to downsample from a higher resolution than your display\nin OpenGL renderer mode. Requires a GPU with atleast OpenGL 3.0 support.",
#endif #endif
"Change the depth of the Palette in Palette rendering mode\n 16 bits is like software looks ingame\nwhile 24 bits is how software looks in screenshots.", "Change the depth of the Palette in Palette rendering mode\n 16 bits is like software looks ingame\nwhile 24 bits is how software looks in screenshots.",
"Fixes issues that resulted in Textures sticking from the ground sometimes.\n This may be CPU heavy and result in worse performance in some cases.",
#endif #endif
}; };
@@ -1535,7 +1532,6 @@ enum
op_exp_fbo, op_exp_fbo,
#endif #endif
op_exp_paldepth, op_exp_paldepth,
op_exp_spltwal,
#endif #endif
}; };
@@ -4724,7 +4720,6 @@ void M_Init(void)
#ifdef USE_FBO_OGL #ifdef USE_FBO_OGL
OP_ExpOptionsMenu[op_exp_fbo].status = IT_DISABLED; OP_ExpOptionsMenu[op_exp_fbo].status = IT_DISABLED;
#endif #endif
OP_ExpOptionsMenu[op_exp_spltwal].status = IT_DISABLED;
} }
if (rendermode == render_opengl) if (rendermode == render_opengl)
+2 -5
View File
@@ -2400,8 +2400,6 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
UINT8 shouldForce = LUAh_ShouldDamage(target, inflictor, source, damage); UINT8 shouldForce = LUAh_ShouldDamage(target, inflictor, source, damage);
if (P_MobjWasRemoved(target)) if (P_MobjWasRemoved(target))
return (shouldForce == 1); // mobj was removed return (shouldForce == 1); // mobj was removed
if (P_MobjWasRemoved(source))
source = NULL;
if (shouldForce == 1) if (shouldForce == 1)
force = true; force = true;
else if (shouldForce == 2) else if (shouldForce == 2)
@@ -2638,6 +2636,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
P_ResetPlayer(target->player); P_ResetPlayer(target->player);
} }
else else
{
switch (target->type) switch (target->type)
{ {
case MT_EGGMOBILE2: // egg slimer case MT_EGGMOBILE2: // egg slimer
@@ -2651,9 +2650,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
P_SetMobjState(target, target->info->painstate); P_SetMobjState(target, target->info->painstate);
break; break;
} }
}
if (P_MobjWasRemoved(target))
return false;
if (!P_MobjWasRemoved(target)) if (!P_MobjWasRemoved(target))
{ {
+93 -72
View File
@@ -408,7 +408,7 @@ void P_ExplodeMissile(mobj_t *mo)
P_RadiusAttack(mo, mo, 96*FRACUNIT); P_RadiusAttack(mo, mo, 96*FRACUNIT);
explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE);
if (!P_MobjWasRemoved(explodemo)) if (explodemo)
{ {
P_SetScale(explodemo, mo->scale); P_SetScale(explodemo, mo->scale);
explodemo->destscale = mo->destscale; explodemo->destscale = mo->destscale;
@@ -417,7 +417,7 @@ void P_ExplodeMissile(mobj_t *mo)
S_StartSound(explodemo, sfx_pop); S_StartSound(explodemo, sfx_pop);
} }
explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE);
if (!P_MobjWasRemoved(explodemo)) if (explodemo)
{ {
P_SetScale(explodemo, mo->scale); P_SetScale(explodemo, mo->scale);
explodemo->destscale = mo->destscale; explodemo->destscale = mo->destscale;
@@ -426,7 +426,7 @@ void P_ExplodeMissile(mobj_t *mo)
S_StartSound(explodemo, sfx_dmpain); S_StartSound(explodemo, sfx_dmpain);
} }
explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE);
if (!P_MobjWasRemoved(explodemo)) if (explodemo)
{ {
P_SetScale(explodemo, mo->scale); P_SetScale(explodemo, mo->scale);
explodemo->destscale = mo->destscale; explodemo->destscale = mo->destscale;
@@ -435,7 +435,7 @@ void P_ExplodeMissile(mobj_t *mo)
S_StartSound(explodemo, sfx_pop); S_StartSound(explodemo, sfx_pop);
} }
explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE);
if (!P_MobjWasRemoved(explodemo)) if (explodemo)
{ {
P_SetScale(explodemo, mo->scale); P_SetScale(explodemo, mo->scale);
explodemo->destscale = mo->destscale; explodemo->destscale = mo->destscale;
@@ -3249,7 +3249,7 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled
{ {
boolean itsatwodlevel = false; boolean itsatwodlevel = false;
boolean flipcam = (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP); boolean flipcam = (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP);
postimg_t postimg = postimg_none; UINT16 postimgflags = 0;
UINT8 i; UINT8 i;
// This can happen when joining // This can happen when joining
@@ -3271,64 +3271,67 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled
} }
} }
if (encoremode && !flipcam) if (encoremode)
postimg = postimg_mirror; postimgflags |= POSTIMG_MIRROR;
else if (!encoremode && flipcam) if (flipcam)
postimg = postimg_flip; postimgflags |= POSTIMG_FLIP;
else if (encoremode && flipcam)
postimg = postimg_mirrorflip; if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) // Camera must obviously exist
else if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) // Camera must obviously exist
{ {
camera_t dummycam; camera_t dummycam;
dummycam.subsector = player->awayviewmobj->subsector; dummycam.subsector = player->awayviewmobj->subsector;
dummycam.x = player->awayviewmobj->x; dummycam.x = player->awayviewmobj->x;
dummycam.y = player->awayviewmobj->y; dummycam.y = player->awayviewmobj->y;
dummycam.z = player->awayviewmobj->z; dummycam.z = player->awayviewmobj->z;
//dummycam.height = 40*FRACUNIT; // alt view height is 20*FRACUNIT //dummycam.height = 40*FRACUNIT; // alt view height is 20*FRACUNIT
dummycam.height = 0; // Why? Remote viewpoint cameras have no height. dummycam.height = 0; // Why? Remote viewpoint cameras have no height.
// Are we in water? // Are we in water?
if (P_CameraCheckWater(&dummycam)) if (P_CameraCheckWater(&dummycam))
postimg = postimg_water; postimgflags |= POSTIMG_WATER;
else if (P_CameraCheckHeat(&dummycam)) if (P_CameraCheckHeat(&dummycam))
postimg = postimg_heat; postimgflags |= POSTIMG_HEAT;
} }
else else
{ {
// Are we in water? // Are we in water?
if (P_CameraCheckWater(thiscam)) if (P_CameraCheckWater(thiscam))
postimg = postimg_water; postimgflags |= POSTIMG_WATER;
else if (P_CameraCheckHeat(thiscam)) if (P_CameraCheckHeat(thiscam))
postimg = postimg_heat; postimgflags |= POSTIMG_HEAT;
} }
if (postimg != postimg_none) for (i = 0; i <= splitscreen; i++)
{ {
for (i = 0; i <= splitscreen; i++) if (player != &players[displayplayers[i]])
{ continue;
if (player != &players[displayplayers[i]])
continue;
postimgtype[i] = postimg; players[displayplayers[i]].postimgflags = postimgflags;
} break;
} }
if (thiscam->momx || thiscam->momy) if (thiscam->momx || thiscam->momy)
{ {
if (!P_TryCameraMove(thiscam->x + thiscam->momx, thiscam->y + thiscam->momy, thiscam)) if (!P_TryCameraMove(thiscam->x + thiscam->momx, thiscam->y + thiscam->momy, thiscam)) // Never fails for 2D mode.
{ // Never fails for 2D mode. {
mobj_t dummy; mobj_t dummy;
dummy.thinker.function.acp1 = (actionf_p1)P_MobjThinker; dummy.thinker.function.acp1 = (actionf_p1)P_MobjThinker;
dummy.subsector = thiscam->subsector; dummy.subsector = thiscam->subsector;
dummy.x = thiscam->x; dummy.x = thiscam->x;
dummy.y = thiscam->y; dummy.y = thiscam->y;
dummy.z = thiscam->z; dummy.z = thiscam->z;
dummy.height = thiscam->height; dummy.height = thiscam->height;
if (player->pflags & PF_TIMEOVER) if (player->pflags & PF_TIMEOVER)
player->kartstuff[k_timeovercam] = (2*TICRATE)+1; player->kartstuff[k_timeovercam] = (2*TICRATE)+1;
if (!resetcalled && !(player->pflags & PF_NOCLIP || leveltime < introtime) && !P_CheckSight(&dummy, player->mo)) // TODO: "P_CheckCameraSight" instead. if (!resetcalled && !(player->pflags & PF_NOCLIP || leveltime < introtime) && !P_CheckSight(&dummy, player->mo)) // TODO: "P_CheckCameraSight" instead.
P_ResetCamera(player, thiscam); P_ResetCamera(player, thiscam);
else else
P_SlideCameraMove(thiscam); P_SlideCameraMove(thiscam);
if (resetcalled) // Okay this means the camera is fully reset. if (resetcalled) // Okay this means the camera is fully reset.
return true; return true;
} }
@@ -3411,7 +3414,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj)
I_Assert(mobj->player != NULL); I_Assert(mobj->player != NULL);
I_Assert(!P_MobjWasRemoved(mobj)); I_Assert(!P_MobjWasRemoved(mobj));
if (P_MobjWasRemoved(mobj)) if (!mobj)
return; return;
P_MobjCheckWater(mobj); P_MobjCheckWater(mobj);
@@ -6030,41 +6033,36 @@ static void P_KoopaThinker(mobj_t *koopa)
// //
void P_RollPitchMobj(mobj_t* mobj) void P_RollPitchMobj(mobj_t* mobj)
{ {
boolean usedist = false; if (!mobj || P_MobjWasRemoved(mobj))
return;
if (P_MobjWasRemoved(mobj)) if (cv_spriteroll.value && cv_sloperoll.value == 2)
return; {
K_RollMobjBySlopes(mobj, cv_sloperolldist.value && !splitscreen);
if (cv_sloperolldist.value > 0) }
usedist = true; else
{
if (cv_spriteroll.value && cv_sloperoll.value == 2) mobj->sloperoll = FixedAngle(0);
{ mobj->slopepitch = FixedAngle(0);
K_RollMobjBySlopes(mobj, usedist); }
}
else
{
mobj->sloperoll = FixedAngle(0);
mobj->slopepitch = FixedAngle(0);
}
} }
angle_t P_MobjPitchAndRoll(mobj_t *mobj) angle_t P_MobjPitchAndRoll(mobj_t *mobj)
{ {
spritedef_t *sprdef; spritedef_t *sprdef;
spriteframe_t *sprframe; spriteframe_t *sprframe;
angle_t ang = 0; angle_t ang = 0;
angle_t camang = 0; angle_t camang = 0;
angle_t return_angle = 0; angle_t return_angle = 0;
if (!cv_spriteroll.value) if (!cv_spriteroll.value)
return 0; return 0;
if (P_MobjWasRemoved(mobj)) if (P_MobjWasRemoved(mobj))
return 0; return 0;
size_t rot = mobj->frame & FF_FRAMEMASK; size_t rot = mobj->frame & FF_FRAMEMASK;
boolean papersprite = (mobj->frame & FF_PAPERSPRITE); boolean papersprite = (mobj->frame & FF_PAPERSPRITE);
if (mobj->skin && mobj->sprite == SPR_PLAY) if (mobj->skin && mobj->sprite == SPR_PLAY)
{ {
@@ -6286,6 +6284,7 @@ void P_MobjThinker(mobj_t *mobj)
P_RemoveMobj(mobj); P_RemoveMobj(mobj);
return; return;
} }
P_RollPitchMobj(mobj); P_RollPitchMobj(mobj);
break; break;
case MT_SMOLDERING: case MT_SMOLDERING:
@@ -6916,9 +6915,6 @@ void P_MobjThinker(mobj_t *mobj)
// separate thinker // separate thinker
if (mobj->flags & MF_PUSHABLE || (mobj->info->flags & MF_PUSHABLE && mobj->fuse)) if (mobj->flags & MF_PUSHABLE || (mobj->info->flags & MF_PUSHABLE && mobj->fuse))
{ {
if (P_MobjWasRemoved(mobj))
return;
P_MobjCheckWater(mobj); P_MobjCheckWater(mobj);
P_PushableThinker(mobj); P_PushableThinker(mobj);
@@ -9994,10 +9990,13 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype
if (mobj->floorz != starting_floorz) if (mobj->floorz != starting_floorz)
mobj->precipflags |= PCF_FOF; mobj->precipflags |= PCF_FOF;
else if (GETSECSPECIAL(mobj->subsector->sector->special, 1) == 7 else
|| GETSECSPECIAL(mobj->subsector->sector->special, 1) == 6 {
|| mobj->subsector->sector->floorpic == skyflatnum) INT32 special = GETSECSPECIAL(mobj->subsector->sector->special, 1);
mobj->precipflags |= PCF_PIT;
if (special == 7 || special == 6 || mobj->subsector->sector->floorpic == skyflatnum)
mobj->precipflags |= PCF_PIT;
}
R_ResetPrecipitationMobjInterpolationState(mobj); R_ResetPrecipitationMobjInterpolationState(mobj);
@@ -10291,7 +10290,7 @@ void P_PrecipitationEffects(void)
INT32 volume; INT32 volume;
size_t i; size_t i;
boolean sounds_rain = true; boolean rainsfx = true;
boolean sounds_thunder = true; boolean sounds_thunder = true;
boolean effects_lightning = true; boolean effects_lightning = true;
boolean lightningStrike = false; boolean lightningStrike = false;
@@ -10324,7 +10323,7 @@ void P_PrecipitationEffects(void)
effects_lightning = false; effects_lightning = false;
break; break;
case PRECIP_STORM_NORAIN: // no rain, lightning and thunder allowed case PRECIP_STORM_NORAIN: // no rain, lightning and thunder allowed
sounds_rain = false; rainsfx = false;
case PRECIP_STORM: // everything. case PRECIP_STORM: // everything.
break; break;
default: default:
@@ -10332,6 +10331,8 @@ void P_PrecipitationEffects(void)
return; return;
} }
boolean sounds_rain = ((cv_drawdist_precip.value != 0) && rainsfx && (!leveltime || leveltime % 80 == 1));
// Currently thunderstorming with lightning, and we're sounding the thunder... // Currently thunderstorming with lightning, and we're sounding the thunder...
// and where there's thunder, there's gotta be lightning! // and where there's thunder, there's gotta be lightning!
if (effects_lightning && lightningStrike) if (effects_lightning && lightningStrike)
@@ -10351,38 +10352,57 @@ void P_PrecipitationEffects(void)
if (sound_disabled) if (sound_disabled)
return; // Sound off? D'aw, no fun. return; // Sound off? D'aw, no fun.
if (!sounds_rain && !sounds_thunder)
return; // no need to calculate volume at ALL
if (players[displayplayers[0]].mo->subsector->sector->ceilingpic == skyflatnum) if (players[displayplayers[0]].mo->subsector->sector->ceilingpic == skyflatnum)
volume = 255; // Sky above? We get it full blast. volume = 255; // Sky above? We get it full blast.
else else
{ {
/* GCC is optimizing away y >= yl, FUCK YOU */ /* GCC is optimizing away y >= yl, FUCK YOU */
volatile fixed_t x, y, yl, yh, xl, xh; INT64 x, y, yl, yh, xl, xh;
fixed_t closedist, newdist; fixed_t closedist, newdist;
// Essentially check in a 1024 unit radius of the player for an outdoor area. // Essentially check in a 1024 unit radius of the player for an outdoor area.
yl = players[displayplayers[0]].mo->y - 1024*FRACUNIT; #define RADIUSSTEP (64*FRACUNIT)
yh = players[displayplayers[0]].mo->y + 1024*FRACUNIT; #define SEARCHRADIUS (16*RADIUSSTEP)
xl = players[displayplayers[0]].mo->x - 1024*FRACUNIT; yl = yh = players[displayplayers[0]].mo->y;
xh = players[displayplayers[0]].mo->x + 1024*FRACUNIT; yl -= SEARCHRADIUS;
closedist = 2048*FRACUNIT; while (yl < INT32_MIN)
yl += RADIUSSTEP;
yh += SEARCHRADIUS;
while (yh > INT32_MAX)
yh -= RADIUSSTEP;
for (y = yl; y >= yl && y <= yh; y += FRACUNIT*64) xl = xh = players[displayplayers[0]].mo->x;
for (x = xl; x >= xl && x <= xh; x += FRACUNIT*64) xl -= SEARCHRADIUS;
while (xl < INT32_MIN)
xl += RADIUSSTEP;
xh += SEARCHRADIUS;
while (xh > INT32_MAX)
xh -= RADIUSSTEP;
closedist = SEARCHRADIUS*2;
#undef SEARCHRADIUS
for (y = yl; y <= yh; y += RADIUSSTEP)
for (x = xl; x <= xh; x += RADIUSSTEP)
{ {
if (R_PointInSubsector(x, y)->sector->ceilingpic != skyflatnum) // Found the outdoors! if (R_PointInSubsector((fixed_t)x, (fixed_t)y)->sector->ceilingpic != skyflatnum) // Found the outdoors!
continue; continue;
newdist = S_CalculateSoundDistance(players[displayplayers[0]].mo->x, players[displayplayers[0]].mo->y, 0, x, y, 0); newdist = S_CalculateSoundDistance(players[displayplayers[0]].mo->x, players[displayplayers[0]].mo->y, 0, (fixed_t)x, (fixed_t)y, 0);
if (newdist < closedist) if (newdist < closedist)
closedist = newdist; closedist = newdist;
} }
volume = 255 - (closedist>>(FRACBITS+2)); volume = 255 - (closedist>>(FRACBITS+2));
} }
#undef RADIUSSTEP
volume = CLAMP(volume, 0, 255); volume = CLAMP(volume, 0, 255);
if (sounds_rain && (!leveltime || leveltime % 80 == 1)) if (sounds_rain)
S_StartSoundAtVolume(players[displayplayers[0]].mo, sfx_rainin, volume); S_StartSoundAtVolume(players[displayplayers[0]].mo, sfx_rainin, volume);
if (!sounds_thunder) if (!sounds_thunder)
@@ -11250,7 +11270,8 @@ void P_SpawnMapThing(mapthing_t *mthing)
mobj = P_SpawnMobj(x, y, z, i); mobj = P_SpawnMobj(x, y, z, i);
if (!mobj || P_MobjWasRemoved(mobj)) { if (!mobj || P_MobjWasRemoved(mobj))
{
CONS_Alert(CONS_ERROR, "Failed to spawn map thing #%d at %d, %d. This will crash vanilla clients!\n", mthing->type, x>>FRACBITS, y>>FRACBITS); CONS_Alert(CONS_ERROR, "Failed to spawn map thing #%d at %d, %d. This will crash vanilla clients!\n", mthing->type, x>>FRACBITS, y>>FRACBITS);
return; return;
} }
+1 -2
View File
@@ -261,6 +261,7 @@ typedef enum {
PCF_SPLASH = 1<<4, // Splashed on the ground, return to the ceiling after the animation's over PCF_SPLASH = 1<<4, // Splashed on the ground, return to the ceiling after the animation's over
PCF_THUNK = 1<<5, // Ran the thinker this tic. PCF_THUNK = 1<<5, // Ran the thinker this tic.
} precipflag_t; } precipflag_t;
// Map Object definition. // Map Object definition.
typedef struct mobj_s typedef struct mobj_s
{ {
@@ -288,7 +289,6 @@ typedef struct mobj_s
UINT32 frame; // frame number, plus bits see p_pspr.h UINT32 frame; // frame number, plus bits see p_pspr.h
UINT16 anim_duration; // for FF_ANIMATE states UINT16 anim_duration; // for FF_ANIMATE states
UINT32 renderflags; // render flags
fixed_t spritexscale, spriteyscale; fixed_t spritexscale, spriteyscale;
fixed_t spritexoffset, spriteyoffset; fixed_t spritexoffset, spriteyoffset;
fixed_t old_spritexscale, old_spriteyscale; fixed_t old_spritexscale, old_spriteyscale;
@@ -441,7 +441,6 @@ typedef struct precipmobj_s
UINT32 frame; // frame number, plus bits see p_pspr.h UINT32 frame; // frame number, plus bits see p_pspr.h
UINT16 anim_duration; // for FF_ANIMATE states UINT16 anim_duration; // for FF_ANIMATE states
UINT32 renderflags; // render flags
fixed_t spritexscale, spriteyscale; fixed_t spritexscale, spriteyscale;
fixed_t spritexoffset, spriteyoffset; fixed_t spritexoffset, spriteyoffset;
fixed_t old_spritexscale, old_spriteyscale; fixed_t old_spritexscale, old_spriteyscale;
+2 -9
View File
@@ -2587,9 +2587,6 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate)
P_LevelInitStuff(reloadinggamestate); P_LevelInitStuff(reloadinggamestate);
for (i = 0; i <= splitscreen; i++)
postimgtype[i] = postimg_none;
if (mapheaderinfo[gamemap-1]->forcecharacter[0] != '\0' if (mapheaderinfo[gamemap-1]->forcecharacter[0] != '\0'
&& atoi(mapheaderinfo[gamemap-1]->forcecharacter) != 255) && atoi(mapheaderinfo[gamemap-1]->forcecharacter) != 255)
P_ForceCharacter(mapheaderinfo[gamemap-1]->forcecharacter); P_ForceCharacter(mapheaderinfo[gamemap-1]->forcecharacter);
@@ -2992,13 +2989,9 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate)
savedata.lives = 0; savedata.lives = 0;
} }
// assume the skybox is visible on level load.
skyVisible = true;
memset(skyVisiblePerPlayer, true, sizeof(skyVisiblePerPlayer));
if (loadprecip) // uglier hack if (loadprecip) // uglier hack
{ // to make a newly loaded level start on the second frame. {
INT32 buf = gametic % TICQUEUE; INT32 buf = gametic % TICQUEUE; // to make a newly loaded level start on the second frame.
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
if (playeringame[i]) if (playeringame[i])
+4 -9
View File
@@ -469,9 +469,6 @@ void P_Ticker(boolean run)
return; return;
} }
for (i = 0; i <= splitscreen; i++)
postimgtype[i] = postimg_none;
P_MapStart(); P_MapStart();
if (run) if (run)
@@ -682,16 +679,17 @@ void P_Ticker(boolean run)
for (i = 0; i <= splitscreen; i++) for (i = 0; i <= splitscreen; i++)
{ {
player_t *player = &players[displayplayers[i]]; player_t *player = &players[displayplayers[i]];
boolean isSkyVisibleForPlayer = skyVisiblePerPlayer[i];
if (!player->mo) if (!player->mo)
continue; continue;
if (isSkyVisibleForPlayer && skyboxmo[0] && cv_skybox.value) const boolean skybox = (skyboxmo[0] && cv_skybox.value);
if (skybox)
{ {
R_SkyboxFrame(player); R_SkyboxFrame(player);
} }
R_SetupFrame(player, (skyboxmo[0] && cv_skybox.value)); R_SetupFrame(player);
} }
} }
} }
@@ -708,9 +706,6 @@ void P_PreTicker(INT32 frames)
INT32 i; INT32 i;
ticcmd_t temptic; ticcmd_t temptic;
for (i = 0; i <= splitscreen; i++)
postimgtype[i] = postimg_none;
hook_defrosting = frames; hook_defrosting = frames;
while (hook_defrosting) while (hook_defrosting)
+24 -26
View File
@@ -4106,8 +4106,8 @@ boolean P_SpectatorJoinGame(player_t *player)
static void P_CalcPostImg(player_t *player) static void P_CalcPostImg(player_t *player)
{ {
sector_t *sector = player->mo->subsector->sector; sector_t *sector = player->mo->subsector->sector;
postimg_t *type = NULL; INT16 typeflag = 0;
INT32 *param; //INT32 *param;
fixed_t pviewheight; fixed_t pviewheight;
UINT8 i; UINT8 i;
@@ -4122,20 +4122,19 @@ static void P_CalcPostImg(player_t *player)
pviewheight = player->awayviewmobj->z + 20*FRACUNIT; pviewheight = player->awayviewmobj->z + 20*FRACUNIT;
} }
for (i = 0; i <= splitscreen; i++) /*for (i = 0; i <= splitscreen; i++)
{ {
if (player == &players[displayplayers[i]]) if (player == &players[displayplayers[i]])
{ {
type = &postimgtype[i];
param = &postimgparam[i]; param = &postimgparam[i];
break; break;
} }
} }*/
// see if we are in heat (no, not THAT kind of heat...) // see if we are in heat (no, not THAT kind of heat...)
if (P_FindSpecialLineFromTag(13, sector->tag, -1) != -1) if (P_FindSpecialLineFromTag(13, sector->tag, -1) != -1)
*type = postimg_heat; typeflag |= POSTIMG_HEAT;
else if (sector->ffloors) else if (sector->ffloors)
{ {
ffloor_t *rover; ffloor_t *rover;
@@ -4154,7 +4153,7 @@ static void P_CalcPostImg(player_t *player)
continue; continue;
if (P_FindSpecialLineFromTag(13, rover->master->frontsector->tag, -1) != -1) if (P_FindSpecialLineFromTag(13, rover->master->frontsector->tag, -1) != -1)
*type = postimg_heat; typeflag |= POSTIMG_HEAT;
} }
} }
@@ -4176,36 +4175,35 @@ static void P_CalcPostImg(player_t *player)
if (pviewheight >= topheight || pviewheight <= bottomheight) if (pviewheight >= topheight || pviewheight <= bottomheight)
continue; continue;
*type = postimg_water; typeflag |= POSTIMG_WATER;
} }
} }
if (!encoremode) // srb2kart if (encoremode) // srb2kart
{ typeflag |= POSTIMG_MIRROR;
if (player->mo->eflags & MFE_VERTICALFLIP)
*type = postimg_flip; if (player->mo->eflags & MFE_VERTICALFLIP)
} typeflag |= POSTIMG_FLIP;
else
{
if (player->mo->eflags & MFE_VERTICALFLIP)
*type = postimg_mirrorflip;
else
*type = postimg_mirror;
}
#if 1
(void)param;
#else
// Motion blur // Motion blur
if (player->speed > (35<<FRACBITS)) // unused
/*if (player->speed > (35<<FRACBITS))
{ {
*type = postimg_motion; typeflag |= POSTIMG_MOTION;
*param = (player->speed - 32)/4; *param = (player->speed - 32)/4;
if (*param > 5) if (*param > 5)
*param = 5; *param = 5;
}*/
for (i = 0; i <= splitscreen; i++)
{
if (player != &players[displayplayers[i]])
continue;
players[displayplayers[i]].postimgflags = typeflag;
break;
} }
#endif
} }
void P_DoTimeOver(player_t *player) void P_DoTimeOver(player_t *player)
+5 -3
View File
@@ -15,6 +15,7 @@
#include "g_game.h" #include "g_game.h"
#include "r_local.h" #include "r_local.h"
#include "r_state.h" #include "r_state.h"
#include "r_portal.h" // Add seg portals
#include "r_splats.h" #include "r_splats.h"
#include "p_local.h" // camera #include "p_local.h" // camera
@@ -28,11 +29,11 @@ side_t *sidedef;
line_t *linedef; line_t *linedef;
sector_t *frontsector; sector_t *frontsector;
sector_t *backsector; sector_t *backsector;
portal_pair *g_portal; // is curline a portal seg?
// very ugly realloc() of drawsegs at run-time, I upped it to 512 // very ugly realloc() of drawsegs at run-time, I upped it to 512
// instead of 256.. and someone managed to send me a level with // instead of 256.. and someone managed to send me a level with
// 896 drawsegs! So too bad here's a limit removal a-la-Boom // 896 drawsegs! So too bad here's a limit removal a-la-Boom
drawseg_t *curdrawsegs = NULL; /**< This is used to handle multiple lists for masked drawsegs. */
drawseg_t *drawsegs = NULL; drawseg_t *drawsegs = NULL;
drawseg_t *ds_p = NULL; drawseg_t *ds_p = NULL;
@@ -486,7 +487,7 @@ static void R_AddLine(seg_t *line)
line2 = P_FindSpecialLineFromTag(40, line->linedef->tag, line2); line2 = P_FindSpecialLineFromTag(40, line->linedef->tag, line2);
if (line2 >= 0) // found it! if (line2 >= 0) // found it!
{ {
R_AddPortal(line->linedef-lines, line2, x1, x2); // Remember the lines for later rendering Portal_Add2Lines(line->linedef-lines, line2, x1, x2); // Remember the lines for later rendering
//return; // Don't fill in that space now! //return; // Don't fill in that space now!
goto clipsolid; goto clipsolid;
} }
@@ -1319,7 +1320,8 @@ void R_RenderBSPNode(INT32 bspnum)
bsp = &nodes[bspnum]; bsp = &nodes[bspnum];
// Decide which side the view point is on. // Decide which side the view point is on.
side = R_PointOnSide(viewx, viewy, bsp); side = R_PointOnSideRender(viewx, viewy, bsp);
// Recursively divide front space. // Recursively divide front space.
R_RenderBSPNode(bsp->children[side]); R_RenderBSPNode(bsp->children[side]);
+3 -2
View File
@@ -25,12 +25,14 @@ extern side_t *sidedef;
extern line_t *linedef; extern line_t *linedef;
extern sector_t *frontsector; extern sector_t *frontsector;
extern sector_t *backsector; extern sector_t *backsector;
extern portal_pair *g_portal; // is curline a portal seg? typedef struct portal_s portal_t;
extern portal_t *g_portal; // is curline a portal seg?
// drawsegs are allocated on the fly... see r_segs.c // drawsegs are allocated on the fly... see r_segs.c
extern INT32 checkcoord[12][4]; extern INT32 checkcoord[12][4];
extern drawseg_t *curdrawsegs;
extern drawseg_t *drawsegs; extern drawseg_t *drawsegs;
extern drawseg_t *ds_p; extern drawseg_t *ds_p;
extern INT32 doorclosed; extern INT32 doorclosed;
@@ -41,7 +43,6 @@ void R_ClearClipSegs(void);
void R_PortalClearClipSegs(INT32 start, INT32 end); void R_PortalClearClipSegs(INT32 start, INT32 end);
void R_ClearDrawSegs(void); void R_ClearDrawSegs(void);
void R_RenderBSPNode(INT32 bspnum); void R_RenderBSPNode(INT32 bspnum);
void R_AddPortal(INT32 line1, INT32 line2, INT32 x1, INT32 x2);
// determines when a given sector shouldn't abide by the encoremap's palette. // determines when a given sector shouldn't abide by the encoremap's palette.
// no longer a static since this is used for encore in hw_main.c as well now: // no longer a static since this is used for encore in hw_main.c as well now:
-8
View File
@@ -687,14 +687,6 @@ typedef struct
#pragma pack() #pragma pack()
#endif #endif
typedef enum // trimmed since its only real use here is for xscale/yscale
{
RF_HORIZONTALFLIP = 0x0001, // Flip sprite horizontally
RF_VERTICALFLIP = 0x0002, // Flip sprite vertically
RF_ABSOLUTEOFFSETS = 0x0004, // Sprite uses the object's offsets absolutely, instead of relatively
RF_FLIPOFFSETS = 0x0008, // Relative object offsets are flipped with the sprite
} renderflags_t;
typedef enum typedef enum
{ {
SRF_SINGLE = 0, // 0-angle for all rotations SRF_SINGLE = 0, // 0-angle for all rotations
+1
View File
@@ -78,6 +78,7 @@ fixed_t dc_iscale, dc_texturemid;
UINT8 dc_hires; // under MSVC boolean is a byte, while on other systems, it a bit, UINT8 dc_hires; // under MSVC boolean is a byte, while on other systems, it a bit,
// soo lets make it a byte on all system for the ASM code // soo lets make it a byte on all system for the ASM code
UINT8 *dc_source; UINT8 *dc_source;
INT32 dc_sourcelength;
// ----------------------- // -----------------------
// translucency stuff here // translucency stuff here
+1
View File
@@ -62,6 +62,7 @@ extern lighttable_t *ds_colormap;
extern fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep; extern fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep;
extern INT32 ds_waterofs, ds_bgofs; extern INT32 ds_waterofs, ds_bgofs;
extern UINT8 *ds_source; // start of a 64*64 tile image extern UINT8 *ds_source; // start of a 64*64 tile image
extern INT32 dc_sourcelength;
extern UINT8 *ds_transmap; extern UINT8 *ds_transmap;
extern INT32 ds_bgofs; extern INT32 ds_bgofs;
+130 -34
View File
@@ -28,6 +28,8 @@ void R_DrawColumn_8(void)
register UINT8 *dest; register UINT8 *dest;
register fixed_t frac; register fixed_t frac;
fixed_t fracstep; fixed_t fracstep;
INT32 npow2min;
INT32 npow2max;
count = dc_yh - dc_yl; count = dc_yh - dc_yl;
@@ -51,13 +53,26 @@ void R_DrawColumn_8(void)
fracstep = dc_iscale; fracstep = dc_iscale;
frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires);
// Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling.
// This is as fast as it gets. // This is as fast as it gets.
{ {
register const UINT8 *source = dc_source; register const UINT8 *source = dc_source;
register const lighttable_t *colormap = dc_colormap; register const lighttable_t *colormap = dc_colormap;
register INT32 heightmask = dc_texheight-1; register INT32 heightmask = dc_texheight-1;
if (dc_sourcelength <= 0)
{
// Note: we need to unconditionally clamp in npow2 draw loop to avoid a CPU branch
// This is to just render it effectively the identity function.
npow2min = INT32_MIN;
npow2max = INT32_MAX;
}
else
{
npow2min = -1;
npow2max = dc_sourcelength;
}
if (dc_texheight & heightmask) // not a power of 2 -- killough if (dc_texheight & heightmask) // not a power of 2 -- killough
{ {
heightmask++; heightmask++;
@@ -74,7 +89,10 @@ void R_DrawColumn_8(void)
// Re-map color indices from wall texture column // Re-map color indices from wall texture column
// using a lighting/special effects LUT. // using a lighting/special effects LUT.
// heightmask is the Tutti-Frutti fix // heightmask is the Tutti-Frutti fix
*dest = colormap[source[frac>>FRACBITS]];
// -1 is the lower clamp bound because column posts have a "safe" byte before the real data
// and a few bytes after as well
*dest = colormap[source[CLAMP(frac>>FRACBITS, npow2min, npow2max)]];
dest += vid.width; dest += vid.width;
// Avoid overflow. // Avoid overflow.
@@ -115,6 +133,8 @@ void R_Draw2sMultiPatchColumn_8(void)
register UINT8 *dest; register UINT8 *dest;
register fixed_t frac; register fixed_t frac;
fixed_t fracstep; fixed_t fracstep;
INT32 npow2min;
INT32 npow2max;
count = dc_yh - dc_yl; count = dc_yh - dc_yl;
@@ -147,6 +167,20 @@ void R_Draw2sMultiPatchColumn_8(void)
register const lighttable_t *colormap = dc_colormap; register const lighttable_t *colormap = dc_colormap;
register INT32 heightmask = dc_texheight-1; register INT32 heightmask = dc_texheight-1;
register UINT8 val; register UINT8 val;
if (dc_sourcelength <= 0)
{
// Note: we need to unconditionally clamp in npow2 draw loop to avoid a CPU branch
// This is to just render it effectively the identity function.
npow2min = INT32_MIN;
npow2max = INT32_MAX;
}
else
{
npow2min = -1;
npow2max = dc_sourcelength;
}
if (dc_texheight & heightmask) // not a power of 2 -- killough if (dc_texheight & heightmask) // not a power of 2 -- killough
{ {
heightmask++; heightmask++;
@@ -163,7 +197,10 @@ void R_Draw2sMultiPatchColumn_8(void)
// Re-map color indices from wall texture column // Re-map color indices from wall texture column
// using a lighting/special effects LUT. // using a lighting/special effects LUT.
// heightmask is the Tutti-Frutti fix // heightmask is the Tutti-Frutti fix
val = source[frac>>FRACBITS];
// -1 is the lower clamp bound because column posts have a "safe" byte before the real data
// and a few bytes after as well
val = source[CLAMP(frac>>FRACBITS, npow2min, npow2max)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
{ {
@@ -223,6 +260,8 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void)
register UINT8 *dest; register UINT8 *dest;
register fixed_t frac; register fixed_t frac;
fixed_t fracstep; fixed_t fracstep;
INT32 npow2min;
INT32 npow2max;
count = dc_yh - dc_yl; count = dc_yh - dc_yl;
@@ -256,6 +295,20 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void)
register const lighttable_t *colormap = dc_colormap; register const lighttable_t *colormap = dc_colormap;
register INT32 heightmask = dc_texheight-1; register INT32 heightmask = dc_texheight-1;
register UINT8 val; register UINT8 val;
if (dc_sourcelength <= 0)
{
// Note: we need to unconditionally clamp in npow2 draw loop to avoid a CPU branch
// This is to just render it effectively the identity function.
npow2min = INT32_MIN;
npow2max = INT32_MAX;
}
else
{
npow2min = -1;
npow2max = dc_sourcelength;
}
if (dc_texheight & heightmask) // not a power of 2 -- killough if (dc_texheight & heightmask) // not a power of 2 -- killough
{ {
heightmask++; heightmask++;
@@ -272,7 +325,10 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void)
// Re-map color indices from wall texture column // Re-map color indices from wall texture column
// using a lighting/special effects LUT. // using a lighting/special effects LUT.
// heightmask is the Tutti-Frutti fix // heightmask is the Tutti-Frutti fix
val = source[frac>>FRACBITS];
// -1 is the lower clamp bound because column posts have a "safe" byte before the real data
// and a few bytes after as well
val = source[CLAMP(frac>>FRACBITS, npow2min, npow2max)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
{ {
@@ -376,6 +432,8 @@ void R_DrawTranslucentColumn_8(void)
register INT32 count; register INT32 count;
register UINT8 *dest; register UINT8 *dest;
register fixed_t frac, fracstep; register fixed_t frac, fracstep;
INT32 npow2min;
INT32 npow2max;
count = dc_yh - dc_yl + 1; count = dc_yh - dc_yl + 1;
@@ -403,6 +461,20 @@ void R_DrawTranslucentColumn_8(void)
register const UINT8 *transmap = dc_transmap; register const UINT8 *transmap = dc_transmap;
register const lighttable_t *colormap = dc_colormap; register const lighttable_t *colormap = dc_colormap;
register INT32 heightmask = dc_texheight - 1; register INT32 heightmask = dc_texheight - 1;
if (dc_sourcelength <= 0)
{
// Note: we need to unconditionally clamp in npow2 draw loop to avoid a CPU branch
// This is to just render it effectively the identity function.
npow2min = INT32_MIN;
npow2max = INT32_MAX;
}
else
{
npow2min = -1;
npow2max = dc_sourcelength;
}
if (dc_texheight & heightmask) if (dc_texheight & heightmask)
{ {
heightmask++; heightmask++;
@@ -420,7 +492,11 @@ void R_DrawTranslucentColumn_8(void)
// Re-map color indices from wall texture column // Re-map color indices from wall texture column
// using a lighting/special effects LUT. // using a lighting/special effects LUT.
// heightmask is the Tutti-Frutti fix // heightmask is the Tutti-Frutti fix
*dest = *(transmap + (colormap[source[frac>>FRACBITS]]<<8) + (*dest));
// -1 is the lower clamp bound because column posts have a "safe" byte before the real data
// and a few bytes after as well
*dest = *(transmap + (colormap[source[CLAMP(frac>>FRACBITS, npow2min, npow2max)]]<<8) + (*dest));
dest += vid.width; dest += vid.width;
if ((frac += fracstep) >= heightmask) if ((frac += fracstep) >= heightmask)
@@ -458,6 +534,8 @@ void R_DrawTranslatedTranslucentColumn_8(void)
register INT32 count; register INT32 count;
register UINT8 *dest; register UINT8 *dest;
register fixed_t frac, fracstep; register fixed_t frac, fracstep;
INT32 npow2min;
INT32 npow2max;
count = dc_yh - dc_yl + 1; count = dc_yh - dc_yl + 1;
@@ -477,6 +555,20 @@ void R_DrawTranslatedTranslucentColumn_8(void)
// This is as fast as it gets. // This is as fast as it gets.
{ {
register INT32 heightmask = dc_texheight - 1; register INT32 heightmask = dc_texheight - 1;
if (dc_sourcelength <= 0)
{
// Note: we need to unconditionally clamp in npow2 draw loop to avoid a CPU branch
// This is to just render it effectively the identity function.
npow2min = INT32_MIN;
npow2max = INT32_MAX;
}
else
{
npow2min = -1;
npow2max = dc_sourcelength;
}
if (dc_texheight & heightmask) if (dc_texheight & heightmask)
{ {
heightmask++; heightmask++;
@@ -494,7 +586,10 @@ void R_DrawTranslatedTranslucentColumn_8(void)
// Re-map color indices from wall texture column // Re-map color indices from wall texture column
// using a lighting/special effects LUT. // using a lighting/special effects LUT.
// heightmask is the Tutti-Frutti fix // heightmask is the Tutti-Frutti fix
*dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[frac>>FRACBITS]]]<<8) + (*dest));
// -1 is the lower clamp bound because column posts have a "safe" byte before the real data
// and a few bytes after as well
*dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[CLAMP(frac>>FRACBITS, npow2min, npow2max)]]]<<8) + (*dest));
dest += vid.width; dest += vid.width;
if ((frac += fracstep) >= heightmask) if ((frac += fracstep) >= heightmask)
@@ -586,14 +681,14 @@ void R_DrawSpan_8 (void)
fixed_t xposition; fixed_t xposition;
fixed_t yposition; fixed_t yposition;
fixed_t xstep, ystep; fixed_t xstep, ystep;
UINT32 bit; register UINT32 bit;
UINT8 *source; UINT8 *source;
UINT8 *colormap; UINT8 *colormap;
UINT8 *dest; register UINT8 *dest;
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
size_t count = (ds_x2 - ds_x1 + 1); register size_t count = (ds_x2 - ds_x1 + 1);
size_t i; size_t i;
xposition = ds_xfrac; yposition = ds_yfrac; xposition = ds_xfrac; yposition = ds_yfrac;
@@ -681,13 +776,13 @@ void R_DrawTiltedSpan_8(void)
UINT8 *source; UINT8 *source;
UINT8 *colormap; UINT8 *colormap;
UINT8 *dest; register UINT8 *dest;
double startz, startu, startv; double startz, startu, startv;
double izstep, uzstep, vzstep; double izstep, uzstep, vzstep;
double endz, endu, endv; double endz, endu, endv;
UINT32 stepu, stepv; UINT32 stepu, stepv;
UINT32 bit; register UINT32 bit;
iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
@@ -822,13 +917,13 @@ void R_DrawTiltedTranslucentSpan_8(void)
UINT8 *source; UINT8 *source;
UINT8 *colormap; UINT8 *colormap;
UINT8 *dest; register UINT8 *dest;
double startz, startu, startv; double startz, startu, startv;
double izstep, uzstep, vzstep; double izstep, uzstep, vzstep;
double endz, endu, endv; double endz, endu, endv;
UINT32 stepu, stepv; UINT32 stepu, stepv;
UINT32 bit; register UINT32 bit;
iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
@@ -964,14 +1059,14 @@ void R_DrawTiltedTranslucentWaterSpan_8(void)
UINT8 *source; UINT8 *source;
UINT8 *colormap; UINT8 *colormap;
UINT8 *dest; register UINT8 *dest;
UINT8 *dsrc; UINT8 *dsrc;
double startz, startu, startv; double startz, startu, startv;
double izstep, uzstep, vzstep; double izstep, uzstep, vzstep;
double endz, endu, endv; double endz, endu, endv;
UINT32 stepu, stepv; UINT32 stepu, stepv;
UINT32 bit; register UINT32 bit;
iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
@@ -1105,7 +1200,7 @@ void R_DrawTiltedSplat_8(void)
UINT8 *source; UINT8 *source;
UINT8 *colormap; UINT8 *colormap;
UINT8 *dest; register UINT8 *dest;
UINT8 val; UINT8 val;
@@ -1113,7 +1208,7 @@ void R_DrawTiltedSplat_8(void)
double izstep, uzstep, vzstep; double izstep, uzstep, vzstep;
double endz, endu, endv; double endz, endu, endv;
UINT32 stepu, stepv; UINT32 stepu, stepv;
UINT32 bit; register UINT32 bit;
iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
@@ -1257,13 +1352,13 @@ void R_DrawSplat_8 (void)
UINT32 xposition; UINT32 xposition;
UINT32 yposition; UINT32 yposition;
UINT32 xstep, ystep; UINT32 xstep, ystep;
UINT32 bit; register UINT32 bit;
UINT8 *source; UINT8 *source;
UINT8 *colormap; UINT8 *colormap;
UINT8 *dest; register UINT8 *dest;
size_t count; register size_t count;
size_t i; size_t i;
UINT32 val; UINT32 val;
@@ -1327,13 +1422,13 @@ void R_DrawTranslucentSplat_8 (void)
UINT32 xposition; UINT32 xposition;
UINT32 yposition; UINT32 yposition;
UINT32 xstep, ystep; UINT32 xstep, ystep;
UINT32 bit; register UINT32 bit;
UINT8 *source; UINT8 *source;
UINT8 *colormap; UINT8 *colormap;
UINT8 *dest; register UINT8 *dest;
size_t count; register size_t count;
size_t i; size_t i;
UINT8 val; UINT8 val;
@@ -1392,14 +1487,14 @@ void R_DrawTranslucentSpan_8 (void)
fixed_t xposition; fixed_t xposition;
fixed_t yposition; fixed_t yposition;
fixed_t xstep, ystep; fixed_t xstep, ystep;
UINT32 bit; register UINT32 bit;
UINT8 *source; UINT8 *source;
UINT8 *colormap; UINT8 *colormap;
UINT8 *dest; register UINT8 *dest;
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
size_t count = (ds_x2 - ds_x1 + 1); register size_t count = (ds_x2 - ds_x1 + 1);
size_t i; size_t i;
xposition = ds_xfrac; yposition = ds_yfrac; xposition = ds_xfrac; yposition = ds_yfrac;
@@ -1451,14 +1546,14 @@ void R_DrawTranslucentWaterSpan_8(void)
UINT32 xposition; UINT32 xposition;
UINT32 yposition; UINT32 yposition;
UINT32 xstep, ystep; UINT32 xstep, ystep;
UINT32 bit; register UINT32 bit;
UINT8 *source; UINT8 *source;
UINT8 *colormap; UINT8 *colormap;
UINT8 *dest; register UINT8 *dest;
UINT8 *dsrc; UINT8 *dsrc;
size_t count; register size_t count;
size_t i; size_t i;
// SoM: we only need 6 bits for the integer part (0 thru 63) so the rest // SoM: we only need 6 bits for the integer part (0 thru 63) so the rest
@@ -1510,9 +1605,9 @@ void R_DrawTranslucentWaterSpan_8(void)
void R_DrawFogSpan_8(void) void R_DrawFogSpan_8(void)
{ {
UINT8 *colormap; UINT8 *colormap;
UINT8 *dest; register UINT8 *dest;
size_t count; register size_t count;
colormap = ds_colormap; colormap = ds_colormap;
//dest = ylookup[ds_y] + columnofs[ds_x1]; //dest = ylookup[ds_y] + columnofs[ds_x1];
@@ -1543,8 +1638,8 @@ void R_DrawFogSpan_8(void)
*/ */
void R_DrawFogColumn_8(void) void R_DrawFogColumn_8(void)
{ {
INT32 count; register INT32 count;
UINT8 *dest; register UINT8 *dest;
count = dc_yh - dc_yl; count = dc_yh - dc_yl;
@@ -1579,7 +1674,8 @@ void R_DrawFogColumn_8(void)
*/ */
void R_DrawColumnShadowed_8(void) void R_DrawColumnShadowed_8(void)
{ {
INT32 count, realyh, i, height, bheight = 0, solid = 0; register INT32 count;
INT32 realyh, i, height, bheight = 0, solid = 0;
realyh = dc_yh; realyh = dc_yh;
+83 -203
View File
@@ -31,6 +31,7 @@
#include "p_spec.h" // skyboxmo #include "p_spec.h" // skyboxmo
#include "z_zone.h" #include "z_zone.h"
#include "m_random.h" // quake camera shake #include "m_random.h" // quake camera shake
#include "r_portal.h"
#include "doomstat.h" // MAXSPLITSCREENPLAYERS #include "doomstat.h" // MAXSPLITSCREENPLAYERS
#include "r_fps.h" // Frame interpolation/uncapped #include "r_fps.h" // Frame interpolation/uncapped
#include "tables.h" #include "tables.h"
@@ -61,19 +62,9 @@ fixed_t viewx, viewy, viewz;
angle_t viewangle, aimingangle, viewroll; angle_t viewangle, aimingangle, viewroll;
UINT8 viewssnum; UINT8 viewssnum;
fixed_t viewcos, viewsin; fixed_t viewcos, viewsin;
boolean skyVisible;
boolean skyVisiblePerPlayer[MAXSPLITSCREENPLAYERS]; // saved values of skyVisible for each splitscreen player
sector_t *viewsector; sector_t *viewsector;
player_t *viewplayer; player_t *viewplayer;
// PORTALS!
// You can thank and/or curse JTE for these.
UINT8 portalrender;
sector_t *portalcullsector;
portal_pair *portal_base, *portal_cap;
line_t *portalclipline;
INT32 portalclipstart, portalclipend;
fixed_t rendertimefrac; fixed_t rendertimefrac;
fixed_t rendertimefrac_unpaused; fixed_t rendertimefrac_unpaused;
fixed_t renderdeltatics; fixed_t renderdeltatics;
@@ -325,29 +316,6 @@ PUREFUNC INT32 R_PointOnSide(fixed_t x, fixed_t y, const node_t *restrict node)
(~mask & (FixedMul(y, node->dx>>FRACBITS) >= FixedMul(node->dy>>FRACBITS, x))); (~mask & (FixedMul(y, node->dx>>FRACBITS) >= FixedMul(node->dy>>FRACBITS, x)));
} }
// killough 5/2/98: reformatted
PUREFUNC INT32 R_PointOnSegSide(fixed_t x, fixed_t y, const seg_t *line)
{
fixed_t lx = line->v1->x;
fixed_t ly = line->v1->y;
fixed_t ldx = line->v2->x - lx;
fixed_t ldy = line->v2->y - ly;
if (!ldx)
return x <= lx ? ldy > 0 : ldy < 0;
if (!ldy)
return y <= ly ? ldx < 0 : ldx > 0;
x -= lx;
y -= ly;
// Try to quickly decide by looking at sign bits.
if ((ldy ^ ldx ^ x ^ y) < 0)
return (ldy ^ x) < 0; // (left is negative)
return FixedMul(y, ldx>>FRACBITS) >= FixedMul(ldy>>FRACBITS, x);
}
// //
// R_PointToAngle // R_PointToAngle
// To get a global angle from cartesian coordinates, // To get a global angle from cartesian coordinates,
@@ -1359,7 +1327,7 @@ void R_SkyboxFrame(player_t *player)
R_InterpolateView(R_UsingFrameInterpolation() ? (demo.playback && demo.freecam) ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false); R_InterpolateView(R_UsingFrameInterpolation() ? (demo.playback && demo.freecam) ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false);
} }
void R_SetupFrame(player_t *player, boolean skybox) void R_SetupFrame(player_t *player)
{ {
camera_t *thiscam; camera_t *thiscam;
boolean chasecam = false; boolean chasecam = false;
@@ -1422,7 +1390,7 @@ void R_SetupFrame(player_t *player, boolean skybox)
else if (thiscam && !chasecam) else if (thiscam && !chasecam)
thiscam->chase = false; thiscam->chase = false;
newview->sky = !skybox; newview->sky = false;
if (player->awayviewtics) // cut-away view stuff if (player->awayviewtics) // cut-away view stuff
{ {
@@ -1504,115 +1472,49 @@ void R_SetupFrame(player_t *player, boolean skybox)
R_InterpolateView(R_UsingFrameInterpolation() ? (demo.playback && demo.freecam) ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false); R_InterpolateView(R_UsingFrameInterpolation() ? (demo.playback && demo.freecam) ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false);
} }
#define ANGLED_PORTALS static void R_PortalFrame(portal_t *portal)
static void R_PortalFrame(line_t *start, line_t *dest, portal_pair *portal)
{ {
vertex_t dest_c, start_c;
#ifdef ANGLED_PORTALS
// delta angle
angle_t dangle = R_PointToAngle2(0,0,dest->dx,dest->dy) - R_PointToAngle2(start->dx,start->dy,0,0);
#endif
//R_SetupFrame(player, false);
viewx = portal->viewx; viewx = portal->viewx;
viewy = portal->viewy; viewy = portal->viewy;
viewz = portal->viewz; viewz = portal->viewz;
viewangle = portal->viewangle; viewangle = portal->viewangle;
// newview->sin = FINESINE(newview->angle>>ANGLETOFINESHIFT); viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT);
// newview->cos = FINECOSINE(newview->angle>>ANGLETOFINESHIFT); viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT);
portalcullsector = dest->frontsector;
viewsector = dest->frontsector;
portalclipline = dest;
portalclipstart = portal->start; portalclipstart = portal->start;
portalclipend = portal->end; portalclipend = portal->end;
// Offset the portal view by the linedef centers if (portal->clipline != -1)
// looking glass center
start_c.x = (start->v1->x + start->v2->x) / 2;
start_c.y = (start->v1->y + start->v2->y) / 2;
// other side center
dest_c.x = (dest->v1->x + dest->v2->x) / 2;
dest_c.y = (dest->v1->y + dest->v2->y) / 2;
// Heights!
viewz += dest->frontsector->floorheight - start->frontsector->floorheight;
// calculate the difference in position and rotation!
#ifdef ANGLED_PORTALS
if (dangle == 0)
#endif
{ // the entrance goes straight opposite the exit, so we just need to mess with the offset.
viewx += dest_c.x - start_c.x;
viewy += dest_c.y - start_c.y;
return;
}
#ifdef ANGLED_PORTALS
viewangle += dangle;
// newview->sin = FINESINE(newview->angle>>ANGLETOFINESHIFT);
// newview->cos = FINECOSINE(newview->angle>>ANGLETOFINESHIFT);
//CONS_Printf("dangle == %u\n", AngleFixed(dangle)>>FRACBITS);
// ????
{ {
fixed_t disttopoint; portalclipline = &lines[portal->clipline];
angle_t angtopoint; portalcullsector = portalclipline->frontsector;
viewsector = portalclipline->frontsector;
disttopoint = R_PointToDist2(start_c.x, start_c.y, newview->x, newview->y);
angtopoint = R_PointToAngle2(start_c.x, start_c.y, newview->x, newview->y);
angtopoint += dangle;
viewx = dest_c.x+FixedMul(FINECOSINE(angtopoint>>ANGLETOFINESHIFT), disttopoint);
viewy = dest_c.y+FixedMul(FINESINE(angtopoint>>ANGLETOFINESHIFT), disttopoint);
}
#endif
}
void R_AddPortal(INT32 line1, INT32 line2, INT32 x1, INT32 x2)
{
portal_pair *portal = Z_Malloc(sizeof(portal_pair), PU_LEVEL, NULL);
INT16 *ceilingclipsave = Z_Malloc(sizeof(INT16)*(x2-x1), PU_LEVEL, NULL);
INT16 *floorclipsave = Z_Malloc(sizeof(INT16)*(x2-x1), PU_LEVEL, NULL);
fixed_t *frontscalesave = Z_Malloc(sizeof(fixed_t)*(x2-x1), PU_LEVEL, NULL);
portal->line1 = line1;
portal->line2 = line2;
portal->pass = portalrender+1;
portal->next = NULL;
R_PortalStoreClipValues(x1, x2, ceilingclipsave, floorclipsave, frontscalesave);
portal->ceilingclip = ceilingclipsave;
portal->floorclip = floorclipsave;
portal->frontscale = frontscalesave;
portal->start = x1;
portal->end = x2;
g_portal = portal; // this tells R_StoreWallRange that curline is a portal seg
portal->viewx = viewx;
portal->viewy = viewy;
portal->viewz = viewz;
portal->viewangle = viewangle;
if (!portal_base)
{
portal_base = portal;
portal_cap = portal;
} }
else else
{ {
portal_cap->next = portal; portalclipline = NULL;
portal_cap = portal; portalcullsector = NULL;
viewsector = R_PointInSubsector(viewx, viewy)->sector;
} }
} }
static void Mask_Pre (maskcount_t* m)
{
m->drawsegs[0] = ds_p - drawsegs;
m->vissprites[0] = visspritecount;
m->viewx = viewx;
m->viewy = viewy;
m->viewz = viewz;
m->viewsector = viewsector;
}
static void Mask_Post (maskcount_t* m)
{
m->drawsegs[1] = ds_p - drawsegs;
m->vissprites[1] = visspritecount;
}
// ================ // ================
// R_RenderView // R_RenderView
// ================ // ================
@@ -1625,9 +1527,8 @@ void R_AddPortal(INT32 line1, INT32 line2, INT32 x1, INT32 x2)
void R_RenderPlayerView(player_t *player) void R_RenderPlayerView(player_t *player)
{ {
portal_pair *portal; INT32 nummasks = 1;
const boolean skybox = (skyboxmo[0] && cv_skybox.value); maskcount_t* masks = malloc(sizeof(maskcount_t));
UINT8 i;
// if this is display player 1 // if this is display player 1
if (cv_homremoval.value && player == &players[displayplayers[0]]) if (cv_homremoval.value && player == &players[displayplayers[0]])
@@ -1652,44 +1553,7 @@ void R_RenderPlayerView(player_t *player)
} }
} }
// load previous saved value of skyVisible for the player R_SetupFrame(player);
for (i = 0; i <= splitscreen; i++)
{
if (player != &players[displayplayers[i]])
continue;
skyVisible = skyVisiblePerPlayer[i];
break;
}
portalrender = 0;
portal_base = portal_cap = NULL;
PS_START_TIMING(ps_skyboxtime);
if (skybox && skyVisible)
{
R_SkyboxFrame(player);
R_ClearClipSegs();
R_ClearDrawSegs();
R_ClearPlanes();
R_ClearSprites();
#ifdef FLOORSPLATS
R_ClearVisibleFloorSplats();
#endif
R_RenderBSPNode((INT32)numnodes - 1);
R_ClipSprites();
R_DrawPlanes();
#ifdef FLOORSPLATS
R_DrawVisibleFloorSplats();
#endif
R_DrawMasked();
}
PS_STOP_TIMING(ps_skyboxtime);
R_SetupFrame(player, skybox);
skyVisible = false;
framecount++; framecount++;
validcount++; validcount++;
@@ -1706,7 +1570,7 @@ void R_RenderPlayerView(player_t *player)
else else
{ {
portalclipstart = 0; portalclipstart = 0;
portalclipend = viewwidth-1; portalclipend = viewwidth;
R_ClearClipSegs(); R_ClearClipSegs();
} }
R_ClearDrawSegs(); R_ClearDrawSegs();
@@ -1715,50 +1579,75 @@ void R_RenderPlayerView(player_t *player)
R_ClearVisibleFloorSplats(); R_ClearVisibleFloorSplats();
#endif #endif
// The head node is the last node output. Portal_InitList();
// The head node is the last node output.
Mask_Pre(&masks[nummasks - 1]);
curdrawsegs = ds_p;
ps_numbspcalls.value.i = ps_numpolyobjects.value.i = ps_numdrawnodes.value.i = 0; ps_numbspcalls.value.i = ps_numpolyobjects.value.i = ps_numdrawnodes.value.i = 0;
PS_START_TIMING(ps_bsptime); PS_START_TIMING(ps_bsptime);
R_RenderBSPNode((INT32)numnodes - 1); R_RenderBSPNode((INT32)numnodes - 1);
PS_STOP_TIMING(ps_bsptime); PS_STOP_TIMING(ps_bsptime);
Mask_Post(&masks[nummasks - 1]);
R_AddPrecipitationSprites(); R_AddPrecipitationSprites();
PS_START_TIMING(ps_sw_spritecliptime); PS_START_TIMING(ps_sw_spritecliptime);
R_ClipSprites(); R_ClipSprites(drawsegs, NULL);
PS_STOP_TIMING(ps_sw_spritecliptime); PS_STOP_TIMING(ps_sw_spritecliptime);
ps_numsprites.value.i = numvisiblesprites; ps_numsprites.value.i = numvisiblesprites;
// PORTAL RENDERING // Add skybox portals caused by sky visplanes.
if (skyboxmo[0] && cv_skybox.value)
Portal_AddSkyboxPortals();
PS_START_TIMING(ps_sw_portaltime); PS_START_TIMING(ps_sw_portaltime);
for(portal = portal_base; portal; portal = portal_base) // Portal rendering. Hijacks the BSP traversal.
if (portal_base)
{ {
// render the portal portal_t *portal;
CONS_Debug(DBG_RENDER, "Rendering portal from line %d to %d\n", portal->line1, portal->line2);
portalrender = portal->pass;
R_PortalFrame(&lines[portal->line1], &lines[portal->line2], portal); for (portal = portal_base; portal; portal = portal_base)
{
portalrender = portal->pass; // Recursiveness depth.
R_PortalClearClipSegs(portal->start, portal->end); R_ClearFFloorClips();
R_PortalRestoreClipValues(portal->start, portal->end, portal->ceilingclip, portal->floorclip, portal->frontscale); // Apply the viewpoint stored for the portal.
R_PortalFrame(portal);
validcount++; // Hack in the clipsegs to delimit the starting
// clipping for sprites and possibly other similar
// future items.
R_PortalClearClipSegs(portal->start, portal->end);
R_RenderBSPNode((INT32)numnodes - 1); // Hack in the top/bottom clip values for the window
R_ClipSprites(); // that were previously stored.
//R_DrawPlanes(); Portal_ClipApply(portal);
//R_DrawMasked();
// okay done. free it. validcount++;
portalcullsector = NULL; // Just in case...
portal_base = portal->next; masks = realloc(masks, (++nummasks)*sizeof(maskcount_t));
Z_Free(portal->ceilingclip);
Z_Free(portal->floorclip); Mask_Pre(&masks[nummasks - 1]);
Z_Free(portal->frontscale); curdrawsegs = ds_p;
Z_Free(portal);
portalskipprecipmobjs = portal->isskybox;
// Render the BSP from the new viewpoint, and clip
// any sprites with the new clipsegs and window.
R_RenderBSPNode((INT32)numnodes - 1);
Mask_Post(&masks[nummasks - 1]);
portalskipprecipmobjs = false;
R_ClipSprites(ds_p - (masks[nummasks - 1].drawsegs[1] - masks[nummasks - 1].drawsegs[0]), portal);
Portal_Remove(portal);
}
} }
PS_STOP_TIMING(ps_sw_portaltime); PS_STOP_TIMING(ps_sw_portaltime);
// END PORTAL RENDERING
PS_START_TIMING(ps_sw_planetime); PS_START_TIMING(ps_sw_planetime);
R_DrawPlanes(); R_DrawPlanes();
@@ -1769,19 +1658,10 @@ void R_RenderPlayerView(player_t *player)
// draw mid texture and sprite // draw mid texture and sprite
// And now 3D floors/sides! // And now 3D floors/sides!
PS_START_TIMING(ps_sw_maskedtime); PS_START_TIMING(ps_sw_maskedtime);
R_DrawMasked(); R_DrawMasked(masks, nummasks);
PS_STOP_TIMING(ps_sw_maskedtime); PS_STOP_TIMING(ps_sw_maskedtime);
// save value to skyVisiblePerPlayer free(masks);
// 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]])
continue;
skyVisiblePerPlayer[i] = skyVisible;
break;
}
} }
// ========================================================================= // =========================================================================
+19 -23
View File
@@ -73,7 +73,24 @@ extern lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ];
// Utility functions. // Utility functions.
INT32 R_PointOnSide(fixed_t x, fixed_t y, const node_t *node); 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);
FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSideRender(fixed_t x, fixed_t y, const node_t *node)
{
// use cross product to determine side quickly
return (INT64)(y - node->y) * node->dx - (INT64)(x - node->x) * node->dy > 0;
}
FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSegSide(fixed_t x, fixed_t y, const seg_t *line)
{
fixed_t lx = line->v1->x;
fixed_t ly = line->v1->y;
fixed_t ldx = line->v2->x - lx;
fixed_t ldy = line->v2->y - ly;
// use cross product to determine side quickly
return (INT64)(y - ly) * ldx - (INT64)(x - lx) * ldy > 0;
}
angle_t R_PointToAngle(fixed_t x, fixed_t y); angle_t R_PointToAngle(fixed_t x, fixed_t y);
angle_t R_PointToAngle64(INT64 x, INT64 y); angle_t R_PointToAngle64(INT64 x, INT64 y);
angle_t R_PointToAngle2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1); angle_t R_PointToAngle2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1);
@@ -90,27 +107,6 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y);
boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixed_t bottomh, fixed_t toph); boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixed_t bottomh, fixed_t toph);
void R_GetRenderBlockMapDimensions(fixed_t drawdist, INT32 *xl, INT32 *xh, INT32 *yl, INT32 *yh); void R_GetRenderBlockMapDimensions(fixed_t drawdist, INT32 *xl, INT32 *xh, INT32 *yl, INT32 *yh);
typedef struct portal_pair
{
INT32 line1;
INT32 line2;
UINT8 pass;
struct portal_pair *next;
fixed_t viewx;
fixed_t viewy;
fixed_t viewz;
angle_t viewangle;
INT32 start;
INT32 end;
INT16 *ceilingclip;
INT16 *floorclip;
fixed_t *frontscale;
} portal_pair;
// Performance stats // Performance stats
extern precise_t ps_prevframetime;// time when previous frame was rendered extern precise_t ps_prevframetime;// time when previous frame was rendered
extern ps_metric_t ps_rendercalltime; extern ps_metric_t ps_rendercalltime;
@@ -164,8 +160,8 @@ void R_SetViewSize(void);
void R_ExecuteSetViewSize(void); void R_ExecuteSetViewSize(void);
void R_SkyboxFrame(player_t *player); void R_SkyboxFrame(player_t *player);
void R_SetupFrame(player_t *player);
void R_SetupFrame(player_t *player, boolean skybox);
// Called by G_Drawer. // Called by G_Drawer.
void R_RenderPlayerView(player_t *player); void R_RenderPlayerView(player_t *player);
+21 -59
View File
@@ -23,6 +23,8 @@
#include "r_state.h" #include "r_state.h"
#include "r_splats.h" // faB(21jan):testing #include "r_splats.h" // faB(21jan):testing
#include "r_sky.h" #include "r_sky.h"
#include "r_portal.h"
#include "v_video.h" #include "v_video.h"
#include "w_wad.h" #include "w_wad.h"
#include "z_zone.h" #include "z_zone.h"
@@ -39,13 +41,7 @@
// good night sweet prince // good night sweet prince
//#define SHITPLANESPARENCY //#define SHITPLANESPARENCY
//SoM: 3/23/2000: Use Boom visplane hashing. visplane_t *visplanes[MAXVISPLANES];
#define VISPLANEHASHBITS 9
#define VISPLANEHASHMASK ((1<<VISPLANEHASHBITS)-1)
// the last visplane list is outside of the hash table and is used for fof planes
#define MAXVISPLANES ((1<<VISPLANEHASHBITS)+1)
static visplane_t *visplanes[MAXVISPLANES];
static visplane_t *freetail; static visplane_t *freetail;
static visplane_t **freehead = &freetail; static visplane_t **freehead = &freetail;
@@ -112,50 +108,6 @@ void R_InitPlanes(void)
// FIXME: unused // FIXME: unused
} }
// R_PortalStoreClipValues
// Saves clipping values for later. -Red
void R_PortalStoreClipValues(INT32 start, INT32 end, INT16 *ceil, INT16 *floor, fixed_t *scale)
{
INT32 i;
for (i = 0; i < end-start; i++)
{
*ceil = ceilingclip[start+i];
ceil++;
*floor = floorclip[start+i];
floor++;
*scale = frontscale[start+i];
scale++;
}
}
// R_PortalRestoreClipValues
// Inverse of the above. Restores the old value!
void R_PortalRestoreClipValues(INT32 start, INT32 end, INT16 *ceil, INT16 *floor, fixed_t *scale)
{
INT32 i;
for (i = 0; i < end-start; i++)
{
ceilingclip[start+i] = *ceil;
ceil++;
floorclip[start+i] = *floor;
floor++;
frontscale[start+i] = *scale;
scale++;
}
// HACKS FOLLOW
for (i = 0; i < start; i++)
{
floorclip[i] = -1;
ceilingclip[i] = (INT16)viewheight;
}
for (i = end; i < vid.width; i++)
{
floorclip[i] = -1;
ceilingclip[i] = (INT16)viewheight;
}
}
// //
// Water ripple effect!! // Water ripple effect!!
// Needs the height of the plane, and the vertical position of the span. // Needs the height of the plane, and the vertical position of the span.
@@ -307,6 +259,24 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2)
spanfunc(); spanfunc();
} }
void R_ClearFFloorClips (void)
{
INT32 i, p;
// opening / clipping determination
for (i = 0; i < viewwidth; i++)
{
for (p = 0; p < MAXFFLOORS; p++)
{
ffloor[p].f_clip[i] = (INT16)viewheight;
ffloor[p].c_clip[i] = -1;
}
}
numffloors = 0;
}
// //
// R_ClearPlanes // R_ClearPlanes
// At begining of frame. // At begining of frame.
@@ -329,8 +299,6 @@ void R_ClearPlanes(void)
} }
} }
numffloors = 0;
for (i = 0; i < MAXVISPLANES; i++) for (i = 0; i < MAXVISPLANES; i++)
{ {
for (*freehead = visplanes[i], visplanes[i] = NULL; for (*freehead = visplanes[i], visplanes[i] = NULL;
@@ -665,12 +633,6 @@ static void R_DrawSkyPlane(visplane_t *pl)
INT32 x; INT32 x;
INT32 angle; INT32 angle;
if (!newview->sky)
{
skyVisible = true;
return;
}
wallcolfunc = walldrawerfunc; wallcolfunc = walldrawerfunc;
// use correct aspect ratio scale // use correct aspect ratio scale
+3 -2
View File
@@ -18,6 +18,7 @@
#include "r_data.h" #include "r_data.h"
#include "p_polyobj.h" #include "p_polyobj.h"
//SoM: 3/23/2000: Use Boom visplane hashing.
#define VISPLANEHASHBITS 9 #define VISPLANEHASHBITS 9
#define VISPLANEHASHMASK ((1<<VISPLANEHASHBITS)-1) #define VISPLANEHASHMASK ((1<<VISPLANEHASHBITS)-1)
// the last visplane list is outside of the hash table and is used for fof planes // the last visplane list is outside of the hash table and is used for fof planes
@@ -56,6 +57,7 @@ typedef struct visplane_s
boolean noencore; boolean noencore;
} visplane_t; } visplane_t;
extern visplane_t *visplanes[MAXVISPLANES];
extern visplane_t *floorplane; extern visplane_t *floorplane;
extern visplane_t *ceilingplane; extern visplane_t *ceilingplane;
@@ -75,9 +77,8 @@ extern fixed_t *yslope;
extern lighttable_t **planezlight; extern lighttable_t **planezlight;
void R_InitPlanes(void); void R_InitPlanes(void);
void R_PortalStoreClipValues(INT32 start, INT32 end, INT16 *ceil, INT16 *floor, fixed_t *scale);
void R_PortalRestoreClipValues(INT32 start, INT32 end, INT16 *ceil, INT16 *floor, fixed_t *scale);
void R_ClearPlanes(void); void R_ClearPlanes(void);
void R_ClearFFloorClips (void);
void R_MapPlane(INT32 y, INT32 x1, INT32 x2); void R_MapPlane(INT32 y, INT32 x1, INT32 x2);
void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2); void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2);
+317
View File
@@ -0,0 +1,317 @@
// SONIC ROBO BLAST 2 KART
//-----------------------------------------------------------------------------
// Copyright (C) 2024 by Kart Krew.
// Copyright (C) 2020 by Sonic Team Junior.
// Copyright (C) 2000 by DooM Legacy Team.
// Copyright (C) 1996 by id Software, Inc.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file r_portal.c
/// \brief Software renderer portals.
#include "r_portal.h"
#include "r_plane.h"
#include "r_main.h"
#include "doomstat.h"
#include "p_spec.h" // Skybox viewpoints
#include "z_zone.h"
#include "r_things.h"
#include "r_sky.h"
UINT8 portalrender; /**< When rendering a portal, it establishes the depth of the current BSP traversal. */
boolean portalskipprecipmobjs = false;
// Linked list for portals.
portal_t *portal_base, *portal_cap;
line_t *portalclipline;
sector_t *portalcullsector;
INT32 portalclipstart, portalclipend;
portal_t *g_portal; // is curline a portal seg?
void Portal_InitList (void)
{
portalrender = 0;
portal_base = portal_cap = NULL;
}
/** Apply the clipping window from a portal.
*/
void Portal_ClipApply (const portal_t* portal)
{
INT32 i;
INT32 start = portal->start;
INT32 end = portal->end;
INT16 *ceil = portal->ceilingclip;
INT16 *floor = portal->floorclip;
fixed_t *scale = portal->frontscale;
for (i = 0; i < end-start; i++)
{
ceilingclip[start+i] = *ceil;
ceil++;
floorclip[start+i] = *floor;
floor++;
frontscale[start+i] = *scale;
scale++;
}
// HACKS FOLLOW
for (i = 0; i < start; i++)
{
floorclip[i] = -1;
ceilingclip[i] = (INT16)viewheight;
}
for (i = end; i < vid.width; i++)
{
floorclip[i] = -1;
ceilingclip[i] = (INT16)viewheight;
}
}
static portal_t* Portal_Add (const INT16 x1, const INT16 x2)
{
portal_t *portal = Z_Malloc(sizeof(portal_t), PU_LEVEL, NULL);
INT16 *ceilingclipsave = Z_Malloc(sizeof(INT16)*(x2-x1 + 1), PU_LEVEL, NULL);
INT16 *floorclipsave = Z_Malloc(sizeof(INT16)*(x2-x1 + 1), PU_LEVEL, NULL);
fixed_t *frontscalesave = Z_Malloc(sizeof(fixed_t)*(x2-x1 + 1), PU_LEVEL, NULL);
// Linked list.
if (!portal_base)
{
portal_base = portal;
portal_cap = portal;
}
else
{
portal_cap->next = portal;
portal_cap = portal;
}
portal->next = NULL;
// Store clipping values so they can be restored once the portal is rendered.
portal->ceilingclip = ceilingclipsave;
portal->floorclip = floorclipsave;
portal->frontscale = frontscalesave;
portal->start = x1;
portal->end = x2;
// Increase recursion level.
portal->pass = portalrender+1;
portal->isskybox = false;
return portal;
}
void Portal_Remove (portal_t* portal)
{
portalcullsector = NULL;
portal_base = portal->next;
Z_Free(portal->ceilingclip);
Z_Free(portal->floorclip);
Z_Free(portal->frontscale);
Z_Free(portal);
}
/** Creates a portal out of two lines and a determined screen range.
*
* line1 determines the entrance, and line2 the exit.
* x1 and x2 determine the screen's column bounds.
* The view's offset from the entry line center is obtained,
* and then rotated&translated to the exit line's center.
* When the portal renders, it will create the illusion of
* the two lines being seamed together.
*/
void Portal_Add2Lines (const INT32 line1, const INT32 line2, const INT32 x1, const INT32 x2)
{
portal_t* portal = Portal_Add(x1, x2);
// Offset the portal view by the linedef centers
line_t* start = &lines[line1];
line_t* dest = &lines[line2];
angle_t dangle = R_PointToAngle2(0,0,dest->dx,dest->dy) - R_PointToAngle2(start->dx,start->dy,0,0);
fixed_t disttopoint;
angle_t angtopoint;
vertex_t dest_c, start_c;
// looking glass center
start_c.x = (start->v1->x + start->v2->x) / 2;
start_c.y = (start->v1->y + start->v2->y) / 2;
// other side center
dest_c.x = (dest->v1->x + dest->v2->x) / 2;
dest_c.y = (dest->v1->y + dest->v2->y) / 2;
disttopoint = R_PointToDist2(start_c.x, start_c.y, viewx, viewy);
angtopoint = R_PointToAngle2(start_c.x, start_c.y, viewx, viewy);
angtopoint += dangle;
portal->viewx = dest_c.x + FixedMul(FINECOSINE(angtopoint>>ANGLETOFINESHIFT), disttopoint);
portal->viewy = dest_c.y + FixedMul(FINESINE(angtopoint>>ANGLETOFINESHIFT), disttopoint);
portal->viewz = viewz + dest->frontsector->floorheight - start->frontsector->floorheight;
portal->viewangle = viewangle + dangle;
portal->clipline = line2;
g_portal = portal; // this tells R_StoreWallRange that curline is a portal seg
}
/** Store the clipping window for a portal using a visplane.
*
* Since visplanes top/bottom windows work in an identical way,
* it can just be copied almost directly.
*/
static void Portal_ClipVisplane (const visplane_t* plane, portal_t* portal)
{
INT16 start = portal->start;
INT16 end = portal->end;
INT32 i;
for (i = 0; i < end - start; i++)
{
// Invalid column.
if (plane->top[i + start] == 65535)
{
portal->ceilingclip[i] = -1;
portal->floorclip[i] = -1;
continue;
}
portal->ceilingclip[i] = plane->top[i + start] - 1;
portal->floorclip[i] = plane->bottom[i + start] + 1;
portal->frontscale[i] = INT32_MAX;
}
}
extern INT32 viewwidth;
static boolean TrimVisplaneBounds (const visplane_t* plane, INT16* start, INT16* end)
{
*start = plane->minx;
*end = plane->maxx + 1;
// Visplanes have 1-px pads on their sides (extra columns).
// Trim them, else it may render out of bounds.
if (*end > viewwidth)
*end = viewwidth;
if (!(*start < *end))
return true;
/** Trims a visplane's horizontal gap to match its render area.
*
* Visplanes' minx/maxx may sometimes exceed the area they're
* covering. This merely adjusts the boundaries to the next
* valid area.
*/
while (plane->bottom[*start] == 0 && plane->top[*start] == 65535 && *start < *end)
{
(*start)++;
}
while (plane->bottom[*end - 1] == 0 && plane->top[*start] == 65535 && *end > *start)
{
(*end)--;
}
return false;
}
/** Creates a skybox portal out of a visplane.
*
* Applies the necessary offsets and rotation to give
* a depth illusion to the skybox.
*/
static void Portal_AddSkybox (const visplane_t* plane)
{
INT16 start, end;
mapheader_t *mh;
portal_t* portal;
if (TrimVisplaneBounds(plane, &start, &end))
return;
portal = Portal_Add(start, end);
Portal_ClipVisplane(plane, portal);
portal->viewx = skyboxmo[0]->x;
portal->viewy = skyboxmo[0]->y;
portal->viewz = 0;
if (skyboxmo[0]->spawnpoint)
portal->viewz = ((fixed_t)skyboxmo[0]->spawnpoint->angle)<<FRACBITS;
portal->viewangle = viewangle + skyboxmo[0]->angle;
mh = mapheaderinfo[gamemap-1];
// If a relative viewpoint exists, offset the viewpoint.
if (skyboxmo[1])
{
fixed_t x = 0, y = 0;
angle_t ang = skyboxmo[0]->angle>>ANGLETOFINESHIFT;
if (mh->skybox_scalex > 0)
x = (viewx - skyboxmo[1]->x) / mh->skybox_scalex;
else if (mh->skybox_scalex < 0)
x = (viewx - skyboxmo[1]->x) * -mh->skybox_scalex;
if (mh->skybox_scaley > 0)
y = (viewy - skyboxmo[1]->y) / mh->skybox_scaley;
else if (mh->skybox_scaley < 0)
y = (viewy - skyboxmo[1]->y) * -mh->skybox_scaley;
// Apply transform to account for the skybox viewport angle.
portal->viewx += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang));
portal->viewy += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang));
}
if (mh->skybox_scalez > 0)
portal->viewz += viewz / mh->skybox_scalez;
else if (mh->skybox_scalez < 0)
portal->viewz += viewz * -mh->skybox_scalez;
portal->clipline = -1;
portal->isskybox = true;
}
/** Creates portals for the currently existing sky visplanes.
* The visplanes are also removed and cleared from the list.
*/
void Portal_AddSkyboxPortals (void)
{
visplane_t *pl;
INT32 i;
UINT16 count = 0;
for (i = 0; i < MAXVISPLANES; i++, pl++)
{
for (pl = visplanes[i]; pl; pl = pl->next)
{
//if (pl->minx >= pl->maxx)
//continue;
if (pl->picnum == skyflatnum)
{
Portal_AddSkybox(pl);
pl->minx = 0;
pl->maxx = -1;
count++;
}
}
}
//CONS_Debug(DBG_RENDER, "Skybox portals: %d\n", count);
}
+63
View File
@@ -0,0 +1,63 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2018 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file r_portal.h
/// \brief Software renderer portal struct, functions, linked list extern.
#ifndef __R_PORTAL__
#define __R_PORTAL__
#include "r_data.h"
#include "r_plane.h" // visplanes
/*
* Portal structure for the software renderer.
*/
typedef struct portal_s
{
struct portal_s *next;
// Viewport.
fixed_t viewx;
fixed_t viewy;
fixed_t viewz;
angle_t viewangle;
UINT8 pass; /**< Keeps track of the portal's recursion depth. */
boolean isskybox;
INT32 clipline; /**< Optional clipline for line-based portals. */
// Clipping information.
INT32 start; /**< First horizontal pixel coordinate to draw at. */
INT32 end; /**< Last horizontal pixel coordinate to draw at. */
INT16 *ceilingclip; /**< Temporary screen top clipping array. */
INT16 *floorclip; /**< Temporary screen bottom clipping array. */
fixed_t *frontscale;/**< Temporary screen bottom clipping array. */
} portal_t;
extern portal_t* portal_base;
extern portal_t* portal_cap;
extern UINT8 portalrender;
extern boolean portalskipprecipmobjs;
extern line_t *portalclipline;
extern sector_t *portalcullsector;
extern INT32 portalclipstart, portalclipend;
void Portal_InitList (void);
void Portal_Remove (portal_t* portal);
void Portal_Add2Lines (const INT32 line1, const INT32 line2, const INT32 x1, const INT32 x2);
void Portal_ClipRange (portal_t* portal);
void Portal_ClipApply (const portal_t* portal);
void Portal_AddSkyboxPortals (void);
#endif
+19 -5
View File
@@ -15,6 +15,7 @@
#include "r_local.h" #include "r_local.h"
#include "r_sky.h" #include "r_sky.h"
#include "r_portal.h"
#include "r_splats.h" #include "r_splats.h"
#include "w_wad.h" #include "w_wad.h"
@@ -275,6 +276,7 @@ static void R_Render2sidedMultiPatchColumn(column_t *column)
if (dc_yl <= dc_yh && dc_yh < vid.height && dc_yh > 0) if (dc_yl <= dc_yh && dc_yh < vid.height && dc_yh > 0)
{ {
dc_source = (UINT8 *)column + 3; dc_source = (UINT8 *)column + 3;
dc_sourcelength = 0;
if (colfunc == wallcolfunc) if (colfunc == wallcolfunc)
twosmultipatchfunc(); twosmultipatchfunc();
@@ -1446,6 +1448,7 @@ static void R_RenderSegLoop (void)
dc_texturemid = rw_midtexturemid; dc_texturemid = rw_midtexturemid;
dc_source = R_GetColumn(midtexture,texturecolumn); dc_source = R_GetColumn(midtexture,texturecolumn);
dc_texheight = textureheight[midtexture]>>FRACBITS; dc_texheight = textureheight[midtexture]>>FRACBITS;
dc_sourcelength = 0;
colfunc(); colfunc();
// dont draw anything more for this column, since // dont draw anything more for this column, since
@@ -1493,6 +1496,7 @@ static void R_RenderSegLoop (void)
dc_texturemid = rw_toptexturemid; dc_texturemid = rw_toptexturemid;
dc_source = R_GetColumn(toptexture,texturecolumn); dc_source = R_GetColumn(toptexture,texturecolumn);
dc_texheight = textureheight[toptexture]>>FRACBITS; dc_texheight = textureheight[toptexture]>>FRACBITS;
dc_sourcelength = 0;
colfunc(); colfunc();
ceilingclip[rw_x] = (INT16)mid; ceilingclip[rw_x] = (INT16)mid;
} }
@@ -1530,6 +1534,7 @@ static void R_RenderSegLoop (void)
dc_source = R_GetColumn(bottomtexture, dc_source = R_GetColumn(bottomtexture,
texturecolumn); texturecolumn);
dc_texheight = textureheight[bottomtexture]>>FRACBITS; dc_texheight = textureheight[bottomtexture]>>FRACBITS;
dc_sourcelength = 0;
colfunc(); colfunc();
floorclip[rw_x] = (INT16)mid; floorclip[rw_x] = (INT16)mid;
} }
@@ -1605,6 +1610,12 @@ static INT64 R_CalcSegDist(seg_t* seg, INT64 x2, INT64 y2)
} }
} }
static inline INT32 get_flat_tex (INT32 texnum)
{
texnum = R_GetTextureNum(texnum);
return textures[texnum]->holes ? 0 : texnum; // R_DrawWallColumn cannot render holey textures
}
// //
// R_StoreWallRange // R_StoreWallRange
// A wall segment will be drawn // A wall segment will be drawn
@@ -1632,6 +1643,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
if (ds_p == drawsegs+maxdrawsegs) if (ds_p == drawsegs+maxdrawsegs)
{ {
size_t curpos = curdrawsegs - drawsegs;
size_t pos = ds_p - drawsegs; size_t pos = ds_p - drawsegs;
size_t newmax = maxdrawsegs ? maxdrawsegs*2 : 128; size_t newmax = maxdrawsegs ? maxdrawsegs*2 : 128;
if (firstseg) if (firstseg)
@@ -1639,6 +1651,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
drawsegs = Z_Realloc(drawsegs, newmax*sizeof (*drawsegs), PU_STATIC, NULL); drawsegs = Z_Realloc(drawsegs, newmax*sizeof (*drawsegs), PU_STATIC, NULL);
ds_p = drawsegs + pos; ds_p = drawsegs + pos;
maxdrawsegs = newmax; maxdrawsegs = newmax;
curdrawsegs = drawsegs + curpos;
if (firstseg) if (firstseg)
firstseg = drawsegs + (size_t)firstseg; firstseg = drawsegs + (size_t)firstseg;
} }
@@ -1691,6 +1704,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
// borrowed fix from *cough* zdoom *cough* // borrowed fix from *cough* zdoom *cough*
// [RH] We also need to adjust the openings pointers that // [RH] We also need to adjust the openings pointers that
// were already stored in drawsegs. // were already stored in drawsegs.
//for (ds = curdrawsegs; ds < ds_p; ds++)
for (ds = drawsegs; ds < ds_p; ds++) for (ds = drawsegs; ds < ds_p; ds++)
{ {
#define ADJUST(p) if (ds->p + ds->x1 >= oldopenings && ds->p + ds->x1 <= oldlast) ds->p = ds->p - oldopenings + openings; #define ADJUST(p) if (ds->p + ds->x1 >= oldopenings && ds->p + ds->x1 <= oldlast) ds->p = ds->p - oldopenings + openings;
@@ -1862,7 +1876,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
{ {
fixed_t texheight; fixed_t texheight;
// single sided line // single sided line
midtexture = R_GetTextureNum(sidedef->midtexture); midtexture = get_flat_tex(sidedef->midtexture);
texheight = textureheight[midtexture]; texheight = textureheight[midtexture];
// a single sided line is terminal, so it must mark ends // a single sided line is terminal, so it must mark ends
markfloor = markceiling = true; markfloor = markceiling = true;
@@ -2045,15 +2059,15 @@ void R_StoreWallRange(INT32 start, INT32 stop)
{ {
// Special case... use offsets from 2nd side but only if it has a texture. // Special case... use offsets from 2nd side but only if it has a texture.
side_t *def = &sides[linedef->sidenum[1]]; side_t *def = &sides[linedef->sidenum[1]];
toptexture = R_GetTextureNum(def->toptexture); toptexture = get_flat_tex(def->toptexture);
if (!toptexture) //Second side has no texture, use the first side's instead. if (!toptexture) //Second side has no texture, use the first side's instead.
toptexture = R_GetTextureNum(sidedef->toptexture); toptexture = get_flat_tex(sidedef->toptexture);
texheight = textureheight[toptexture]; texheight = textureheight[toptexture];
} }
else else
{ {
toptexture = R_GetTextureNum(sidedef->toptexture); toptexture = get_flat_tex(sidedef->toptexture);
texheight = textureheight[toptexture]; texheight = textureheight[toptexture];
} }
if (!(linedef->flags & ML_EFFECT1)) { // Ignore slopes for lower/upper textures unless flag is checked if (!(linedef->flags & ML_EFFECT1)) { // Ignore slopes for lower/upper textures unless flag is checked
@@ -2078,7 +2092,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
if (worldlow > worldbottom || worldlowslope > worldbottomslope) // Only if VISIBLE!!! if (worldlow > worldbottom || worldlowslope > worldbottomslope) // Only if VISIBLE!!!
{ {
// bottom texture // bottom texture
bottomtexture = R_GetTextureNum(sidedef->bottomtexture); bottomtexture = get_flat_tex(sidedef->bottomtexture);
if (!(linedef->flags & ML_EFFECT1)) { // Ignore slopes for lower/upper textures unless flag is checked if (!(linedef->flags & ML_EFFECT1)) { // Ignore slopes for lower/upper textures unless flag is checked
if (linedef->flags & ML_DONTPEGBOTTOM) if (linedef->flags & ML_DONTPEGBOTTOM)
-6
View File
@@ -90,14 +90,8 @@ extern side_t *sides;
extern fixed_t viewx, viewy, viewz; extern fixed_t viewx, viewy, viewz;
extern angle_t viewangle, aimingangle, viewroll; extern angle_t viewangle, aimingangle, viewroll;
extern UINT8 viewssnum; // splitscreen view number extern UINT8 viewssnum; // splitscreen view number
extern boolean viewsky, skyVisible;
extern boolean skyVisiblePerPlayer[MAXSPLITSCREENPLAYERS]; // saved values of skyVisible of each splitscreen player
extern sector_t *viewsector; extern sector_t *viewsector;
extern player_t *viewplayer; extern player_t *viewplayer;
extern UINT8 portalrender;
extern sector_t *portalcullsector;
extern line_t *portalclipline;
extern INT32 portalclipstart, portalclipend;
extern consvar_t cv_allowmlook; extern consvar_t cv_allowmlook;
extern consvar_t cv_maxportals; extern consvar_t cv_maxportals;
+190 -120
View File
@@ -25,6 +25,7 @@
#include "r_things.h" #include "r_things.h"
#include "r_patch.h" #include "r_patch.h"
#include "r_plane.h" #include "r_plane.h"
#include "r_portal.h"
#include "p_tick.h" #include "p_tick.h"
#include "p_local.h" #include "p_local.h"
#include "p_slopes.h" #include "p_slopes.h"
@@ -43,7 +44,7 @@ CV_PossibleValue_t Forceskin_cons_t[MAXSKINS+2];
static void R_InitSkins(void); static void R_InitSkins(void);
#define MINZ (FRACUNIT*4) #define MINZ (FRACUNIT*16)
#define BASEYCENTER (BASEVIDHEIGHT/2) #define BASEYCENTER (BASEVIDHEIGHT/2)
typedef struct typedef struct
@@ -583,6 +584,9 @@ void R_DrawMaskedColumn(column_t *column)
basetexturemid = dc_texturemid; basetexturemid = dc_texturemid;
if (!column || column == 0)
return;
for (; column->topdelta != 0xff ;) for (; column->topdelta != 0xff ;)
{ {
// calculate unclipped screen coordinates // calculate unclipped screen coordinates
@@ -618,6 +622,7 @@ void R_DrawMaskedColumn(column_t *column)
if (dc_yl <= dc_yh && dc_yh > 0 && column->length != 0) if (dc_yl <= dc_yh && dc_yh > 0 && column->length != 0)
{ {
dc_source = (UINT8 *)column + 3; dc_source = (UINT8 *)column + 3;
dc_sourcelength = column->length;
dc_texturemid = basetexturemid - (topdelta<<FRACBITS); dc_texturemid = basetexturemid - (topdelta<<FRACBITS);
// Drawn by R_DrawColumn. // Drawn by R_DrawColumn.
@@ -682,6 +687,7 @@ static void R_DrawFlippedMaskedColumn(column_t *column)
if (dc_yl <= dc_yh && dc_yh > 0 && column->length != 0) if (dc_yl <= dc_yh && dc_yh > 0 && column->length != 0)
{ {
dc_source = ZZ_Alloc(column->length); dc_source = ZZ_Alloc(column->length);
dc_sourcelength = column->length;
for (s = (UINT8 *)column+2+column->length, d = dc_source; d < dc_source+column->length; --s) for (s = (UINT8 *)column+2+column->length, d = dc_source; d < dc_source+column->length; --s)
*d++ = *s; *d++ = *s;
dc_texturemid = basetexturemid - (topdelta<<FRACBITS); dc_texturemid = basetexturemid - (topdelta<<FRACBITS);
@@ -799,7 +805,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
dc_colormap += COLORMAP_REMAPOFFSET; dc_colormap += COLORMAP_REMAPOFFSET;
dc_texturemid = vis->texturemid; dc_texturemid = vis->texturemid;
dc_texheight = 0; dc_texheight = SHORT(patch->height);
frac = vis->startfrac; frac = vis->startfrac;
windowtop = windowbottom = sprbotscreen = INT32_MAX; windowtop = windowbottom = sprbotscreen = INT32_MAX;
@@ -808,8 +814,10 @@ static void R_DrawVisSprite(vissprite_t *vis)
this_scale = FixedMul(this_scale, ((skin_t *)vis->mobj->localskin)->highresscale); this_scale = FixedMul(this_scale, ((skin_t *)vis->mobj->localskin)->highresscale);
else if (vis->mobj->skin && ((skin_t *)vis->mobj->skin)->flags & SF_HIRES) else if (vis->mobj->skin && ((skin_t *)vis->mobj->skin)->flags & SF_HIRES)
this_scale = FixedMul(this_scale, ((skin_t *)vis->mobj->skin)->highresscale); this_scale = FixedMul(this_scale, ((skin_t *)vis->mobj->skin)->highresscale);
if (this_scale <= 0) if (this_scale <= 0)
this_scale = 1; this_scale = 1;
if (this_scale != FRACUNIT) if (this_scale != FRACUNIT)
{ {
if (!vis->isScaled) if (!vis->isScaled)
@@ -875,12 +883,10 @@ static void R_DrawVisSprite(vissprite_t *vis)
} }
else else
{ {
pwidth = SHORT(patch->width);
// Non-paper drawing loop // Non-paper drawing loop
for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale) for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale)
{ {
texturecolumn = CLAMP(frac >> FRACBITS, 0, pwidth - 1); texturecolumn = CLAMP(frac >> FRACBITS, 0, SHORT(patch->width) - 1);
column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn]));
localcolfunc (column); localcolfunc (column);
@@ -926,7 +932,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis)
dc_iscale = FixedDiv(FRACUNIT, vis->scale); dc_iscale = FixedDiv(FRACUNIT, vis->scale);
dc_texturemid = FixedDiv(vis->texturemid, this_scale); dc_texturemid = FixedDiv(vis->texturemid, this_scale);
dc_texheight = 0; dc_texheight = SHORT(patch->height);
frac = vis->startfrac; frac = vis->startfrac;
spryscale = vis->scale; spryscale = vis->scale;
@@ -941,7 +947,14 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis)
for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale) for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale)
{ {
texturecolumn = CLAMP(frac >> FRACBITS, 0, SHORT(patch->width) - 1); texturecolumn = frac>>FRACBITS;
if (texturecolumn < 0 || texturecolumn >= patch->width)
{
CONS_Debug(DBG_RENDER, "R_DrawPrecipitationSpriteRange: bad texturecolumn\n");
break;
}
column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn]));
R_DrawMaskedColumn(column); R_DrawMaskedColumn(column);
@@ -1273,9 +1286,9 @@ static void R_ProjectSprite(mobj_t *thing)
// choose a different rotation based on player view // choose a different rotation based on player view
//ang = R_PointToAngle (interp.x, interp.y) - interpangle; //ang = R_PointToAngle (interp.x, interp.y) - interpangle;
if ((ang < ANGLE_180) && (sprframe->rotate & SRF_RIGHT)) // See from right if ((sprframe->rotate & SRF_RIGHT) && (ang < ANGLE_180)) // See from right
rot = 6; // F7 slot rot = 6; // F7 slot
else if ((ang >= ANGLE_180) && (sprframe->rotate & SRF_LEFT)) // See from left else if ((sprframe->rotate & SRF_LEFT) && (ang >= ANGLE_180)) // See from left
rot = 2; // F3 slot rot = 2; // F3 slot
else // Normal behaviour else // Normal behaviour
rot = (ang+ANGLE_202h)>>29; rot = (ang+ANGLE_202h)>>29;
@@ -1345,10 +1358,10 @@ static void R_ProjectSprite(mobj_t *thing)
if (rotsprite != NULL) if (rotsprite != NULL)
{ {
spr_width = rotsprite->width << FRACBITS; spr_width = SHORT(rotsprite->width) << FRACBITS;
spr_height = rotsprite->height << FRACBITS; spr_height = SHORT(rotsprite->height) << FRACBITS;
spr_offset = rotsprite->leftoffset << FRACBITS; spr_offset = SHORT(rotsprite->leftoffset) << FRACBITS;
spr_topoffset = rotsprite->topoffset << FRACBITS; spr_topoffset = SHORT(rotsprite->topoffset) << FRACBITS;
spr_topoffset += FEETADJUST; spr_topoffset += FEETADJUST;
// flip -> rotate, not rotate -> flip // flip -> rotate, not rotate -> flip
@@ -1366,21 +1379,8 @@ static void R_ProjectSprite(mobj_t *thing)
if (spritexscale < 1 || spriteyscale < 1) if (spritexscale < 1 || spriteyscale < 1)
return; return;
if (thing->renderflags & RF_ABSOLUTEOFFSETS) spr_offset += interp.spritexoffset;
{ spr_topoffset += interp.spriteyoffset;
spr_offset = interp.spritexoffset;
spr_topoffset = interp.spriteyoffset;
}
else
{
SINT8 flipoffset = 1;
if ((thing->renderflags & RF_FLIPOFFSETS) && flip)
flipoffset = -1;
spr_offset += interp.spritexoffset * flipoffset;
spr_topoffset += interp.spriteyoffset * flipoffset;
}
if (flip) if (flip)
offset = spr_offset - spr_width; offset = spr_offset - spr_width;
@@ -1528,7 +1528,7 @@ static void R_ProjectSprite(mobj_t *thing)
// PORTAL SPRITE CLIPPING // PORTAL SPRITE CLIPPING
if (portalrender && portalclipline) if (portalrender && portalclipline)
{ {
if (x2 < portalclipstart || x1 > portalclipend) if (x2 < portalclipstart || x1 >= portalclipend)
return; return;
if (P_PointOnLineSide(interp.x, interp.y, portalclipline) != 0) if (P_PointOnLineSide(interp.x, interp.y, portalclipline) != 0)
@@ -1600,7 +1600,6 @@ static void R_ProjectSprite(mobj_t *thing)
// store information in a vissprite // store information in a vissprite
vis = R_NewVisSprite(); vis = R_NewVisSprite();
vis->renderflags = thing->renderflags;
vis->heightsec = heightsec; //SoM: 3/17/2000 vis->heightsec = heightsec; //SoM: 3/17/2000
vis->mobjflags = thing->flags; vis->mobjflags = thing->flags;
vis->scale = yscale; //<<detailshift; vis->scale = yscale; //<<detailshift;
@@ -1621,17 +1620,8 @@ static void R_ProjectSprite(mobj_t *thing)
vis->mobj = thing; // Easy access! Tails 06-07-2002 vis->mobj = thing; // Easy access! Tails 06-07-2002
vis->x1 = x1 < 0 ? 0 : x1; vis->x1 = x1 < portalclipstart ? portalclipstart : x1;
vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; vis->x2 = x2 >= portalclipend ? portalclipend-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->sector = thing->subsector->sector;
vis->szt = (INT16)((centeryfrac - FixedMul(vis->gzt - viewz, sortscale))>>FRACBITS); vis->szt = (INT16)((centeryfrac - FixedMul(vis->gzt - viewz, sortscale))>>FRACBITS);
@@ -1841,7 +1831,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
// PORTAL SPRITE CLIPPING // PORTAL SPRITE CLIPPING
if (portalrender && portalclipline) if (portalrender && portalclipline)
{ {
if (x2 < portalclipstart || x1 > portalclipend) if (x2 < portalclipstart || x1 >= portalclipend)
return; return;
if (P_PointOnLineSide(interp.x, interp.y, portalclipline) != 0) if (P_PointOnLineSide(interp.x, interp.y, portalclipline) != 0)
@@ -1875,17 +1865,8 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
vis->scalestep = 0; vis->scalestep = 0;
vis->paperdistance = 0; vis->paperdistance = 0;
vis->x1 = x1 < 0 ? 0 : x1; vis->x1 = x1 < portalclipstart ? portalclipstart : x1;
vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; vis->x2 = x2 >= portalclipend ? portalclipend-1 : x2;
// PORTAL SEMI-CLIPPING
if (portalrender && portalclipline)
{
if (vis->x1 < portalclipstart)
vis->x1 = portalclipstart;
if (vis->x2 > portalclipend)
vis->x2 = portalclipend;
}
vis->xscale = xscale; //SoM: 4/17/2000 vis->xscale = xscale; //SoM: 4/17/2000
vis->sector = thing->subsector->sector; vis->sector = thing->subsector->sector;
@@ -1990,6 +1971,12 @@ void R_AddPrecipitationSprites(void)
return; return;
} }
// do not render in skybox
if (portalskipprecipmobjs)
{
return;
}
R_GetRenderBlockMapDimensions(drawdist, &xl, &xh, &yl, &yh); R_GetRenderBlockMapDimensions(drawdist, &xl, &xh, &yl, &yh);
for (bx = xl; bx <= xh; bx++) for (bx = xl; bx <= xh; bx++)
@@ -2013,46 +2000,47 @@ void R_AddPrecipitationSprites(void)
// //
// R_SortVisSprites // R_SortVisSprites
// //
static vissprite_t vsprsortedhead;
void R_SortVisSprites(void) static void R_SortVisSprites(vissprite_t* vsprsortedhead, UINT32 start, UINT32 end)
{ {
UINT32 i; UINT32 i, count = 0;
vissprite_t *ds, *dsprev, *dsnext, *dsfirst; vissprite_t *ds, *dsprev, *dsnext, *dsfirst;
vissprite_t *best = NULL; vissprite_t *best = NULL;
vissprite_t unsorted; vissprite_t unsorted;
fixed_t bestscale; fixed_t bestscale;
INT32 bestdispoffset; INT32 bestdispoffset;
if (!visspritecount) dsfirst = &unsorted;
return; dsprev = dsfirst;
dsnext = dsfirst;
unsorted.next = unsorted.prev = &unsorted; I_Assert(start <= end);
dsfirst = R_GetVisSprite(0); for (i = start; i < end; ++i)
// The first's prev and last's next will be set to
// nonsense, but are fixed in a moment
for (i = 0, dsnext = dsfirst, ds = NULL; i < visspritecount; i++)
{ {
dsprev = ds; ds = R_GetVisSprite(i);
ds = dsnext;
if (i < visspritecount - 1) dsnext = R_GetVisSprite(i + 1);
ds->next = dsnext; // Do not include this sprite, since it is completely obscured
ds->prev = dsprev; if (ds->cut & SC_NOTVISIBLE)
{
continue;
}
dsnext = ds;
dsprev->next = dsnext;
dsnext->prev = dsprev;
dsprev = dsnext;
count++;
} }
// Fix first and last. ds still points to the last one after the loop dsnext->next = dsfirst;
dsfirst->prev = &unsorted; dsfirst->prev = dsnext;
unsorted.next = dsfirst;
if (ds)
ds->next = &unsorted;
unsorted.prev = ds;
// pull the vissprites out by scale // pull the vissprites out by scale
vsprsortedhead.next = vsprsortedhead.prev = &vsprsortedhead; vsprsortedhead->next = vsprsortedhead->prev = vsprsortedhead;
for (i = 0; i < visspritecount; i++) for (i = 0; i < count; i++)
{ {
bestscale = bestdispoffset = INT32_MAX; bestscale = bestdispoffset = INT32_MAX;
for (ds = unsorted.next; ds != &unsorted; ds = ds->next) for (ds = unsorted.next; ds != &unsorted; ds = ds->next)
@@ -2078,15 +2066,12 @@ void R_SortVisSprites(void)
best = ds; best = ds;
} }
} }
if (best) best->next->prev = best->prev;
{ best->prev->next = best->next;
best->next->prev = best->prev; best->next = vsprsortedhead;
best->prev->next = best->next; best->prev = vsprsortedhead->prev;
best->next = &vsprsortedhead; vsprsortedhead->prev->next = best;
best->prev = vsprsortedhead.prev; vsprsortedhead->prev = best;
vsprsortedhead.prev->next = best;
vsprsortedhead.prev = best;
}
} }
} }
@@ -2096,28 +2081,28 @@ void R_SortVisSprites(void)
static drawnode_t *R_CreateDrawNode(drawnode_t *link); static drawnode_t *R_CreateDrawNode(drawnode_t *link);
static drawnode_t nodebankhead; static drawnode_t nodebankhead;
static drawnode_t nodehead;
static void R_CreateDrawNodes(void) static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean tempskip)
{ {
drawnode_t *entry; drawnode_t *entry;
drawseg_t *ds; drawseg_t *ds;
INT32 i, p, best, x1, x2; INT32 i, p, best, x1, x2;
fixed_t bestdelta, delta; fixed_t bestdelta, delta;
vissprite_t *rover; vissprite_t *rover;
static vissprite_t vsprsortedhead;
drawnode_t *r2; drawnode_t *r2;
visplane_t *plane; visplane_t *plane;
INT32 sintersect; INT32 sintersect;
fixed_t scale = 0; fixed_t scale = 0;
// Add the 3D floors, thicksides, and masked textures... // Add the 3D floors, thicksides, and masked textures...
for (ds = ds_p; ds-- > drawsegs ;) for (ds = drawsegs + mask->drawsegs[1]; ds-- > drawsegs + mask->drawsegs[0];)
{ {
if (ds->numthicksides) if (ds->numthicksides)
{ {
for (i = 0; i < ds->numthicksides; i++) for (i = 0; i < ds->numthicksides; i++)
{ {
entry = R_CreateDrawNode(&nodehead); entry = R_CreateDrawNode(head);
entry->thickseg = ds; entry->thickseg = ds;
entry->ffloor = ds->thicksides[i]; entry->ffloor = ds->thicksides[i];
} }
@@ -2133,7 +2118,7 @@ static void R_CreateDrawNodes(void)
else else
{ {
// Put it in! // Put it in!
entry = R_CreateDrawNode(&nodehead); entry = R_CreateDrawNode(head);
entry->plane = plane; entry->plane = plane;
entry->seg = ds; entry->seg = ds;
} }
@@ -2141,7 +2126,7 @@ static void R_CreateDrawNodes(void)
} }
if (ds->maskedtexturecol) if (ds->maskedtexturecol)
{ {
entry = R_CreateDrawNode(&nodehead); entry = R_CreateDrawNode(head);
entry->seg = ds; entry->seg = ds;
} }
if (ds->numffloorplanes) if (ds->numffloorplanes)
@@ -2173,7 +2158,7 @@ static void R_CreateDrawNodes(void)
} }
if (best != -1) if (best != -1)
{ {
entry = R_CreateDrawNode(&nodehead); entry = R_CreateDrawNode(head);
entry->plane = ds->ffloorplanes[best]; entry->plane = ds->ffloorplanes[best];
entry->seg = ds; entry->seg = ds;
ds->ffloorplanes[best] = NULL; ds->ffloorplanes[best] = NULL;
@@ -2184,6 +2169,9 @@ static void R_CreateDrawNodes(void)
} }
} }
if (tempskip)
return;
// find all the remaining polyobject planes and add them on the end of the list // find all the remaining polyobject planes and add them on the end of the list
// probably this is a terrible idea if we wanted them to be sorted properly // probably this is a terrible idea if we wanted them to be sorted properly
// but it works getting them in for now // but it works getting them in for now
@@ -2199,16 +2187,18 @@ static void R_CreateDrawNodes(void)
PolyObjects[i].visplane = NULL; PolyObjects[i].visplane = NULL;
continue; continue;
} }
entry = R_CreateDrawNode(&nodehead); entry = R_CreateDrawNode(head);
entry->plane = plane; entry->plane = plane;
// note: no seg is set, for what should be obvious reasons // note: no seg is set, for what should be obvious reasons
PolyObjects[i].visplane = NULL; PolyObjects[i].visplane = NULL;
} }
if (visspritecount == 0) // No vissprites in this mask?
if (mask->vissprites[1] - mask->vissprites[0] == 0)
return; return;
R_SortVisSprites(); R_SortVisSprites(&vsprsortedhead, mask->vissprites[0], mask->vissprites[1]);
for (rover = vsprsortedhead.prev; rover != &vsprsortedhead; rover = rover->prev) for (rover = vsprsortedhead.prev; rover != &vsprsortedhead; rover = rover->prev)
{ {
if (rover->szt > vid.height || rover->sz < 0) if (rover->szt > vid.height || rover->sz < 0)
@@ -2216,7 +2206,7 @@ static void R_CreateDrawNodes(void)
sintersect = (rover->x1 + rover->x2) / 2; sintersect = (rover->x1 + rover->x2) / 2;
for (r2 = nodehead.next; r2 != &nodehead; r2 = r2->next) for (r2 = head->next; r2 != head; r2 = r2->next)
{ {
if (r2->plane) if (r2->plane)
{ {
@@ -2355,9 +2345,9 @@ static void R_CreateDrawNodes(void)
} }
} }
} }
if (r2 == &nodehead) if (r2 == head)
{ {
entry = R_CreateDrawNode(&nodehead); entry = R_CreateDrawNode(head);
entry->sprite = rover; entry->sprite = rover;
} }
} }
@@ -2401,25 +2391,24 @@ static void R_DoneWithNode(drawnode_t *node)
(node->prev = &nodebankhead)->next = node; (node->prev = &nodebankhead)->next = node;
} }
static void R_ClearDrawNodes(void) static void R_ClearDrawNodes(drawnode_t* head)
{ {
drawnode_t *rover; drawnode_t *rover;
drawnode_t *next; drawnode_t *next;
for (rover = nodehead.next; rover != &nodehead ;) for (rover = head->next; rover != head;)
{ {
next = rover->next; next = rover->next;
R_DoneWithNode(rover); R_DoneWithNode(rover);
rover = next; rover = next;
} }
nodehead.next = nodehead.prev = &nodehead; head->next = head->prev = head;
} }
void R_InitDrawNodes(void) void R_InitDrawNodes(void)
{ {
nodebankhead.next = nodebankhead.prev = &nodebankhead; nodebankhead.next = nodebankhead.prev = &nodebankhead;
nodehead.next = nodehead.prev = &nodehead;
} }
// //
@@ -2483,7 +2472,7 @@ static boolean R_CheckSpriteVisible(vissprite_t *spr, INT32 x1, INT32 x2)
// R_ClipVisSprite // R_ClipVisSprite
// Clips vissprites without drawing, so that portals can work. -Red // Clips vissprites without drawing, so that portals can work. -Red
static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2) static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, portal_t* portal)
{ {
drawseg_t *ds; drawseg_t *ds;
INT32 x; INT32 x;
@@ -2522,8 +2511,36 @@ static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2)
ds = curr->user; ds = curr->user;
if (ds->portalpass > 0 && ds->portalpass <= portalrender) if (ds->portalpass != 66) // unused?
continue; // is a portal {
if (ds->portalpass > 0 && ds->portalpass <= portalrender)
continue; // is a portal
if (ds->scale1 > ds->scale2)
{
lowscale = ds->scale2;
scale = ds->scale1;
}
else
{
lowscale = ds->scale1;
scale = ds->scale2;
}
if (scale < spr->sortscale ||
(lowscale < spr->sortscale &&
!R_PointOnSegSide (spr->gx, spr->gy, ds->curline)))
{
// masked mid texture?
/*
if (ds->maskedtexturecol)
R_RenderMaskedSegRange (ds, r1, r2);
*/
// seg is behind sprite
continue;
}
}
r1 = ds->x1 < spr->x1 ? spr->x1 : ds->x1; r1 = ds->x1 < spr->x1 ? spr->x1 : ds->x1;
r2 = ds->x2 > spr->x2 ? spr->x2 : ds->x2; r2 = ds->x2 > spr->x2 ? spr->x2 : ds->x2;
@@ -2674,11 +2691,34 @@ static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2)
if (!R_CheckSpriteVisible(spr, x1, x2)) if (!R_CheckSpriteVisible(spr, x1, x2))
spr->cut |= SC_NOTVISIBLE; spr->cut |= SC_NOTVISIBLE;
} }
if (portal)
{
INT32 start_index = max(portal->start, x1);
INT32 end_index = min(portal->start + portal->end - portal->start, x2);
for (x = x1; x < start_index; x++)
{
spr->clipbot[x] = -1;
spr->cliptop[x] = -1;
}
for (x = start_index; x <= end_index; x++)
{
if (spr->clipbot[x] > portal->floorclip[x - portal->start])
spr->clipbot[x] = portal->floorclip[x - portal->start];
if (spr->cliptop[x] < portal->ceilingclip[x - portal->start])
spr->cliptop[x] = portal->ceilingclip[x - portal->start];
}
for (x = end_index + 1; x <= x2; x++)
{
spr->clipbot[x] = -1;
spr->cliptop[x] = -1;
}
}
} }
void R_ClipSprites(void) void R_ClipSprites(drawseg_t* dsstart, portal_t* portal)
{ {
const size_t maxdrawsegs = ds_p - drawsegs; const size_t maxdrawsegs = ds_p - dsstart;
const INT32 cx = viewwidth / 2; const INT32 cx = viewwidth / 2;
drawseg_t* ds; drawseg_t* ds;
INT32 i; INT32 i;
@@ -2711,7 +2751,7 @@ void R_ClipSprites(void)
} }
} }
for (ds = ds_p; ds-- > drawsegs;) for (ds = ds_p; ds-- > dsstart;)
{ {
if (ds->silhouette || ds->maskedtexturecol) if (ds->silhouette || ds->maskedtexturecol)
{ {
@@ -2765,7 +2805,7 @@ void R_ClipSprites(void)
drawsegs_xrange_count = drawsegs_xranges[0].count; drawsegs_xrange_count = drawsegs_xranges[0].count;
} }
R_ClipVisSprite(spr, spr->x1, spr->x2); R_ClipVisSprite(spr, spr->x1, spr->x2, portal);
if ((spr->cut & SC_NOTVISIBLE) == 0) if ((spr->cut & SC_NOTVISIBLE) == 0)
numvisiblesprites++; numvisiblesprites++;
@@ -2783,10 +2823,10 @@ boolean R_ThingVisible (mobj_t *thing)
if (splitscreen) if (splitscreen)
{ {
if ((viewssnum == 0 && (thing->renderflags & MFE_DRAWONLYFORP1)) if ((viewssnum == 0 && (thing->eflags & MFE_DRAWONLYFORP1))
|| (viewssnum == 1 && (thing->renderflags & MFE_DRAWONLYFORP2)) || (viewssnum == 1 && (thing->eflags & MFE_DRAWONLYFORP2))
|| (viewssnum == 2 && (thing->renderflags & MFE_DRAWONLYFORP2)) || (viewssnum == 2 && (thing->eflags & MFE_DRAWONLYFORP2))
|| (viewssnum == 3 && (thing->renderflags & MFE_DRAWONLYFORP4))) || (viewssnum == 3 && (thing->eflags & MFE_DRAWONLYFORP4)))
return true; return true;
} }
@@ -2810,14 +2850,12 @@ boolean R_ThingWithinDist (mobj_t *thing, fixed_t limit_dist)
// //
// R_DrawMasked // R_DrawMasked
// //
void R_DrawMasked(void) static void R_DrawMaskedList (drawnode_t* head)
{ {
drawnode_t *r2; drawnode_t *r2;
drawnode_t *next; drawnode_t *next;
R_CreateDrawNodes(); for (r2 = head->next; r2 != head; r2 = r2->next)
for (r2 = nodehead.next; r2 != &nodehead; r2 = r2->next)
{ {
if (r2->plane) if (r2->plane)
{ {
@@ -2855,7 +2893,39 @@ void R_DrawMasked(void)
r2 = next; r2 = next;
} }
} }
R_ClearDrawNodes(); }
void R_DrawMasked(maskcount_t* masks, INT32 nummasks)
{
drawnode_t *heads; /**< Drawnode lists; as many as number of views/portals. */
INT32 i;
heads = calloc(nummasks, sizeof(drawnode_t));
for (i = 0; i < nummasks; i++)
{
heads[i].next = heads[i].prev = &heads[i];
viewx = masks[i].viewx;
viewy = masks[i].viewy;
viewz = masks[i].viewz;
viewsector = masks[i].viewsector;
R_CreateDrawNodes(&masks[i], &heads[i], false);
}
for (; nummasks > 0; nummasks--)
{
viewx = masks[nummasks - 1].viewx;
viewy = masks[nummasks - 1].viewy;
viewz = masks[nummasks - 1].viewz;
viewsector = masks[nummasks - 1].viewsector;
R_DrawMaskedList(&heads[nummasks - 1]);
R_ClearDrawNodes(&heads[nummasks - 1]);
}
free(heads);
} }
// ========================================================================== // ==========================================================================
@@ -3293,7 +3363,7 @@ static int skinSortFunc(const void *a, const void *b) //tbh i have no clue what
void sortSkinGrid(void) void sortSkinGrid(void)
{ {
//CONS_Printf("Sorting skin list (%d)...\n", cv_skinselectgridsort.value); //CONS_Printf("Sorting skin list (%d)...\n", cv_skinselectgridsort.value);
qs22j(skinsorted, numskins, sizeof(UINT8), skinSortFunc); qs22j(skinsorted, numskins, sizeof(UINT8), skinSortFunc);
} }
// //
+16 -3
View File
@@ -16,6 +16,7 @@
#include "sounds.h" #include "sounds.h"
#include "r_plane.h" #include "r_plane.h"
#include "r_portal.h"
#include "r_patch.h" #include "r_patch.h"
// "Left" and "Right" character symbols for additional rotation functionality // "Left" and "Right" character symbols for additional rotation functionality
@@ -55,11 +56,11 @@ extern fixed_t sprtopscreen;
extern fixed_t sprbotscreen; extern fixed_t sprbotscreen;
extern fixed_t windowtop; extern fixed_t windowtop;
extern fixed_t windowbottom; extern fixed_t windowbottom;
extern INT32 lengthcol;
fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope); fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope);
void R_DrawMaskedColumn(column_t *column); void R_DrawMaskedColumn(column_t *column);
void R_SortVisSprites(void);
//faB: find sprites in wadfile, replace existing, add new ones //faB: find sprites in wadfile, replace existing, add new ones
// (only sprites from namelist are added or replaced) // (only sprites from namelist are added or replaced)
@@ -70,7 +71,19 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel);
void R_AddPrecipitationSprites(void); void R_AddPrecipitationSprites(void);
void R_InitSprites(void); void R_InitSprites(void);
void R_ClearSprites(void); void R_ClearSprites(void);
void R_DrawMasked(void);
/** Used to count the amount of masked elements
* per portal to later group them in separate
* drawnode lists.
*/
typedef struct
{
size_t drawsegs[2];
size_t vissprites[2];
fixed_t viewx, viewy, viewz; /**< View z stored at the time of the BSP traversal for the view/portal. Masked sorting/drawing needs it. */
sector_t* viewsector;
} maskcount_t;
void R_DrawMasked(maskcount_t* masks, INT32 nummasks);
boolean R_ThingVisible (mobj_t *thing); boolean R_ThingVisible (mobj_t *thing);
boolean R_ThingWithinDist (mobj_t *thing, fixed_t limit_dist); boolean R_ThingWithinDist (mobj_t *thing, fixed_t limit_dist);
@@ -192,7 +205,7 @@ typedef struct vissprite_s
extern UINT32 visspritecount, numvisiblesprites; extern UINT32 visspritecount, numvisiblesprites;
void R_ClipSprites(void); void R_ClipSprites(drawseg_t* dsstart, portal_t* portal);
UINT8 *R_GetSpriteTranslation(vissprite_t *vis); UINT8 *R_GetSpriteTranslation(vissprite_t *vis);
+56 -55
View File
@@ -3189,7 +3189,7 @@ INT32 heatindex[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0};
// Perform a particular image postprocessing function. // Perform a particular image postprocessing function.
// //
void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param) void V_DoPostProcessor(INT32 view, player_t *player, INT32 param)
{ {
#if NUMSCREENS < 5 #if NUMSCREENS < 5
// do not enable image post processing for ARM, SH and MIPS CPUs // do not enable image post processing for ARM, SH and MIPS CPUs
@@ -3197,6 +3197,7 @@ void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param)
(void)type; (void)type;
(void)param; (void)param;
#else #else
(void)param; // unused motion blur stuff
INT32 yoffset, xoffset; INT32 yoffset, xoffset;
#ifdef HWRENDER #ifdef HWRENDER
@@ -3207,6 +3208,9 @@ void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param)
if (view < 0 || view > 3 || view > splitscreen) if (view < 0 || view > 3 || view > splitscreen)
return; return;
if (!player->postimgflags)
return;
if ((view == 1 && splitscreen == 1) || view >= 2) if ((view == 1 && splitscreen == 1) || view >= 2)
yoffset = viewheight; yoffset = viewheight;
else else
@@ -3217,10 +3221,11 @@ void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param)
else else
xoffset = 0; xoffset = 0;
if (type == postimg_water) UINT8 *tmpscr = screens[4];
UINT8 *srcscr = screens[0];
if (player->postimgflags & POSTIMG_WATER)
{ {
UINT8 *tmpscr = screens[4];
UINT8 *srcscr = screens[0];
INT32 y; INT32 y;
// Set disStart to a range from 0 to FINEANGLE, incrementing by 128 per tic // Set disStart to a range from 0 to FINEANGLE, incrementing by 128 per tic
angle_t disStart = (((leveltime-1)*128) + (rendertimefrac / (FRACUNIT/128))) & FINEMASK; angle_t disStart = (((leveltime-1)*128) + (rendertimefrac / (FRACUNIT/128))) & FINEMASK;
@@ -3257,29 +3262,30 @@ void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param)
} }
/* /*
Unoptimized version Unoptimized version
for (x = 0; x < vid.width*vid.bpp; x++) for (x = 0; x < vid.width*vid.bpp; x++)
{ {
newpix = (x + sine); newpix = (x + sine);
if (newpix < 0) if (newpix < 0)
newpix = 0; newpix = 0;
else if (newpix >= vid.width) else if (newpix >= vid.width)
newpix = vid.width-1; newpix = vid.width-1;
tmpscr[y*vid.width + x] = srcscr[y*vid.width+newpix]; // *(transme + (srcscr[y*vid.width+x]<<8) + srcscr[y*vid.width+newpix]);
}*/
tmpscr[y*vid.width + x] = srcscr[y*vid.width+newpix]; // *(transme + (srcscr[y*vid.width+x]<<8) + srcscr[y*vid.width+newpix]);
}*/
disStart += 22;//the offset into the displacement map, increment each game loop disStart += 22;//the offset into the displacement map, increment each game loop
disStart &= FINEMASK; //clip it to FINEMASK disStart &= FINEMASK; //clip it to FINEMASK
} }
VID_BlitLinearScreen(tmpscr+vid.width*vid.bpp*yoffset+xoffset, screens[0]+vid.width*vid.bpp*yoffset+xoffset, UINT8 *tmp = tmpscr;
viewwidth*vid.bpp, viewheight, vid.width*vid.bpp, vid.width); tmpscr = srcscr;
srcscr = tmp;
} }
else if (type == postimg_motion) // Motion Blur!
{ /*if (player->postimgflags & POSTIMG_MOTION) // Motion Blur!
UINT8 *tmpscr = screens[4]; {
UINT8 *srcscr = screens[0];
INT32 x, y; INT32 x, y;
// TODO: Add a postimg_param so that we can pick the translucency level... // TODO: Add a postimg_param so that we can pick the translucency level...
@@ -3288,30 +3294,12 @@ void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param)
for (y = yoffset; y < yoffset+viewheight; y++) for (y = yoffset; y < yoffset+viewheight; y++)
{ {
for (x = xoffset; x < xoffset+viewwidth; x++) for (x = xoffset; x < xoffset+viewwidth; x++)
{ tmpscr[y*vid.width + x] = colormaps[*(transme + (srcscr [(y*vid.width)+x ] <<8) + (tmpscr[(y*vid.width)+x]))];
tmpscr[y*vid.width + x]
= colormaps[*(transme + (srcscr [(y*vid.width)+x ] <<8) + (tmpscr[(y*vid.width)+x]))];
}
} }
VID_BlitLinearScreen(tmpscr+vid.width*vid.bpp*yoffset+xoffset, screens[0]+vid.width*vid.bpp*yoffset+xoffset, }*/
viewwidth*vid.bpp, viewheight, vid.width*vid.bpp, vid.width);
}
else if (type == postimg_flip) // Flip the screen upside-down
{
UINT8 *tmpscr = screens[4];
UINT8 *srcscr = screens[0];
INT32 y, y2;
for (y = yoffset, y2 = yoffset+viewheight - 1; y < yoffset+viewheight; y++, y2--) if (player->postimgflags & POSTIMG_HEAT) // Heat wave
M_Memcpy(&tmpscr[(y2*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth);
VID_BlitLinearScreen(tmpscr+vid.width*vid.bpp*yoffset+xoffset, screens[0]+vid.width*vid.bpp*yoffset+xoffset,
viewwidth*vid.bpp, viewheight, vid.width*vid.bpp, vid.width);
}
else if (type == postimg_heat) // Heat wave
{ {
UINT8 *tmpscr = screens[4];
UINT8 *srcscr = screens[0];
INT32 y; INT32 y;
// Make sure table is built // Make sure table is built
@@ -3352,40 +3340,53 @@ void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param)
heatindex[view] %= vid.height; heatindex[view] %= vid.height;
} }
VID_BlitLinearScreen(tmpscr+vid.width*vid.bpp*yoffset+xoffset, screens[0]+vid.width*vid.bpp*yoffset+xoffset, UINT8 *tmp = tmpscr;
viewwidth*vid.bpp, viewheight, vid.width*vid.bpp, vid.width); tmpscr = srcscr;
srcscr = tmp;
} }
else if (type == postimg_mirror) // Flip the screen on the x axis
if ((player->postimgflags & POSTIMG_FLIP) && !(player->postimgflags & POSTIMG_MIRROR)) // Flip the screen upside-down
{
INT32 y, y2;
for (y = yoffset, y2 = yoffset+viewheight - 1; y < yoffset+viewheight; y++, y2--)
M_Memcpy(&tmpscr[(y2*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth);
UINT8 *tmp = tmpscr;
tmpscr = srcscr;
srcscr = tmp;
}
else if ((player->postimgflags & POSTIMG_MIRROR) && !(player->postimgflags & POSTIMG_FLIP)) // Flip the screen on the x axis
{ {
UINT8 *tmpscr = screens[4];
UINT8 *srcscr = screens[0];
INT32 y, x, x2; INT32 y, x, x2;
for (y = yoffset; y < yoffset+viewheight; y++) for (y = yoffset; y < yoffset+viewheight; y++)
{
for (x = xoffset, x2 = xoffset+((viewwidth*vid.bpp)-1); x < xoffset+(viewwidth*vid.bpp); x++, x2--) for (x = xoffset, x2 = xoffset+((viewwidth*vid.bpp)-1); x < xoffset+(viewwidth*vid.bpp); x++, x2--)
tmpscr[y*vid.width + x2] = srcscr[y*vid.width + x]; tmpscr[y*vid.width + x2] = srcscr[y*vid.width + x];
}
VID_BlitLinearScreen(tmpscr+vid.width*vid.bpp*yoffset+xoffset, screens[0]+vid.width*vid.bpp*yoffset+xoffset, UINT8 *tmp = tmpscr;
viewwidth*vid.bpp, viewheight, vid.width*vid.bpp, vid.width); tmpscr = srcscr;
srcscr = tmp;
} }
else if (type == postimg_mirrorflip) // Flip the screen upside-down and on the x axis else if ((player->postimgflags & POSTIMG_MIRROR) && (player->postimgflags & POSTIMG_FLIP)) // Flip the screen upside-down and on the x axis
{ {
UINT8 *tmpscr = screens[4];
UINT8 *srcscr = screens[0];
INT32 y, x; INT32 y, x;
for (y = yoffset; y < yoffset + viewheight; y++) for (y = yoffset; y < yoffset + viewheight; y++)
for (x = xoffset; x < xoffset + viewwidth; x++) for (x = xoffset; x < xoffset + viewwidth; x++)
tmpscr[((yoffset + viewheight - 1 - y) * vid.width) + xoffset + viewwidth - (x - xoffset) - 1] = srcscr[(y * vid.width) + x]; tmpscr[((yoffset + viewheight - 1 - y) * vid.width) + xoffset + viewwidth - (x - xoffset) - 1] = srcscr[(y * vid.width) + x];
VID_BlitLinearScreen(tmpscr+vid.width*vid.bpp*yoffset+xoffset, screens[0]+vid.width*vid.bpp*yoffset+xoffset, UINT8 *tmp = tmpscr;
viewwidth*vid.bpp, viewheight, vid.width*vid.bpp, vid.width); tmpscr = srcscr;
srcscr = tmp;
} }
VID_BlitLinearScreen(srcscr+vid.width*vid.bpp*yoffset+xoffset, tmpscr+vid.width*vid.bpp*yoffset+xoffset,
viewwidth*vid.bpp, viewheight, vid.width*vid.bpp, vid.width);
#endif #endif
} }
// Taken from my videos-in-SRB2 project // Taken from my videos-in-SRB2 project
// Generates a color look-up table // Generates a color look-up table
// which has up to 64 colors at each channel // which has up to 64 colors at each channel
+3 -1
View File
@@ -251,7 +251,9 @@ INT32 V_SubStringLengthToFit(const char *string, INT32 width, INT32 option);
char V_GetSkincolorChar(INT32 color); char V_GetSkincolorChar(INT32 color);
void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param); typedef struct player_s player_t;
void V_DoPostProcessor(INT32 view, player_t *player, INT32 param);
void V_DrawPatchFill(patch_t *pat); void V_DrawPatchFill(patch_t *pat);
+219
View File
@@ -2120,6 +2120,225 @@ int W_VerifyNMUSlumps(const char *filename)
return W_VerifyFile(filename, NMUSlist, false); return W_VerifyFile(filename, NMUSlist, false);
} }
static int W_NameStartsWith(const char *name, lumpchecklist_t *checklist)
{
size_t j;
for (j = 0; checklist[j].len && checklist[j].name; ++j)
{
if (strncasecmp(name, checklist[j].name, checklist[j].len) == 0)
return true;
}
return false;
}
// Checks if file contains at least one lump which name starts with one of strings in checklist
static int W_CheckWADContains(FILE *fp, lumpchecklist_t *checklist)
{
size_t i, j;
// if we're here it's a WAD file
wadinfo_t header;
filelump_t lumpinfo;
// read the header
if (fread(&header, 1, sizeof header, fp) == sizeof header
&& header.numlumps < INT16_MAX
&& strncmp(header.identification, "ZWAD", 4)
&& strncmp(header.identification, "IWAD", 4)
&& strncmp(header.identification, "PWAD", 4)
&& strncmp(header.identification, "SDLL", 4))
{
return true;
}
header.numlumps = LONG(header.numlumps);
header.infotableofs = LONG(header.infotableofs);
// let seek to the lumpinfo list
if (fseek(fp, header.infotableofs, SEEK_SET) == -1)
return true;
for (i = 0; i < header.numlumps; i++)
{
// fill in lumpinfo for this wad file directory
if (fread(&lumpinfo, sizeof (lumpinfo), 1 , fp) != 1)
return -1;
lumpinfo.filepos = LONG(lumpinfo.filepos);
lumpinfo.size = LONG(lumpinfo.size);
if (lumpinfo.size == 0)
continue;
for (j = 0; j < NUMSPRITES; j++)
if (!strncmp(lumpinfo.name, sprnames[j], 4)) // Sprites
continue;
if (W_NameStartsWith(lumpinfo.name, checklist))
return true;
}
return false;
}
static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist)
{
zend_t zend;
zlentry_t zlentry;
long file_size;/* size of zip file */
long data_size;/* size of data inside zip file */
UINT16 numlumps;
size_t i;
char pat_central[] = {0x50, 0x4b, 0x01, 0x02, 0x00};
char pat_end[] = {0x50, 0x4b, 0x05, 0x06, 0x00};
char lumpname[9];
// Haha the ResGetLumpsZip function doesn't
// check for file errors, so neither will I.
// Central directory bullshit
fseek(fp, 0, SEEK_END);
file_size = ftell(fp);
if (!ResFindSignature(fp, pat_end, max(0, ftell(fp) - (22 + 65536))))
return true;
fseek(fp, -4, SEEK_CUR);
if (fread(&zend, 1, sizeof zend, fp) < sizeof zend)
return true;
data_size = sizeof zend;
numlumps = SHORT(zend.entries);
fseek(fp, LONG(zend.cdiroffset), SEEK_SET);
char *cdir = (char*)(malloc(LONG(zend.cdirsize)));
if (fread(cdir, 1, LONG(zend.cdirsize), fp) < (UINT32)(LONG(zend.cdirsize)))
return true;
size_t offset = 0;
for (i = 0; i < numlumps; i++)
{
zentry_t *zentry = (zentry_t*)(cdir + offset);
char* fullname;
char* trimname;
char* dotpos;
if (memcmp(zentry->signature, pat_central, 4) != 0)
return false;
fullname = (char*)(malloc(SHORT(zentry->namelen) + 1));
strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1);
// Strip away file address and extension for the 8char name.
if ((trimname = strrchr(fullname, '/')) != 0)
trimname++;
else
trimname = fullname; // Care taken for root files.
if (*trimname) // Ignore directories, well kinda
{
if ((dotpos = strrchr(trimname, '.')) == 0)
dotpos = fullname + strlen(fullname); // Watch for files without extension.
memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary?
strncpy(lumpname, trimname, min(8, dotpos - trimname));
if (W_NameStartsWith(lumpname, checklist))
return true;
}
if (W_NameStartsWith(fullname, checklist))
return true;
free(fullname);
offset += sizeof *zentry + SHORT(zentry->namelen) + SHORT(zentry->xtralen) + SHORT(zentry->commlen);
data_size +=
sizeof *zentry + SHORT(zentry->namelen) + SHORT(zentry->xtralen) + SHORT(zentry->commlen);
if (fseek(fp, LONG(zentry->offset), SEEK_SET) != 0)
return false;
if (fread(&zlentry, 1, sizeof(zlentry_t), fp) < sizeof (zlentry_t))
return false;
data_size +=
sizeof zlentry + SHORT(zlentry.namelen) + SHORT(zlentry.xtralen) + LONG(zlentry.compsize);
}
free(cdir);
if (data_size < file_size)
{
const char * error = "ZIP file has holes (%ld extra bytes)\n";
CONS_Alert(CONS_ERROR, error, (file_size - data_size));
return -1;
}
else if (data_size > file_size)
{
const char * error = "Reported size of ZIP file contents exceeds file size (%ld extra bytes)\n";
CONS_Alert(CONS_ERROR, error, (data_size - file_size));
return -1;
}
else
{
return false;
}
}
static int W_CheckFileContains(const char *filename, lumpchecklist_t *checklist)
{
FILE *handle;
int contains = false;
if (!checklist)
I_Error("No checklist for %s\n", filename);
// open wad file
if ((handle = W_OpenWadFile(&filename, false)) == NULL)
return -1;
if (stricmp(&filename[strlen(filename) - 4], ".pk3") == 0)
contains = W_CheckPK3Contains(handle, checklist);
else
{
// detect wad file by the absence of the other supported extensions
if (stricmp(&filename[strlen(filename) - 4], ".soc")
&& stricmp(&filename[strlen(filename) - 4], ".lua"))
{
contains = W_CheckWADContains(handle, checklist);
}
}
fclose(handle);
return contains;
}
int W_CheckPostLoadList(const char *filename)
{
static lumpchecklist_t postloadlist[] =
{
{"Lua/", 4},
{"SOC/", 4},
{"Skins/", 6},
{"S_SKIN", 6},
{"LUA_", 4},
{"SOC_", 4},
{"MAINCFG", 7},
{"OBJCTCFG", 8},
{"MAP", 3},
{NULL, 0},
};
return W_CheckFileContains(filename, postloadlist);
}
/** \brief Generates a virtual resource used for level data loading. /** \brief Generates a virtual resource used for level data loading.
* *
* \param lumpnum_t reference * \param lumpnum_t reference
+2
View File
@@ -226,4 +226,6 @@ void W_VerifyFileMD5(UINT16 wadfilenum, const char *matchmd5);
int W_VerifyNMUSlumps(const char *filename); int W_VerifyNMUSlumps(const char *filename);
int W_CheckPostLoadList(const char *filename);
#endif // __W_WAD__ #endif // __W_WAD__