Compare commits

..
37 Commits
Author SHA1 Message Date
alufolie91 8f6178fc0e Merge branch 'Saturn-Next' into dynskins 2026-11-12 20:52:30 +01:00
alufolie91 32bd5a02ec fix some smol style gripes in lua mobj and player lib 2026-11-12 20:46:01 +01:00
indev 546fae5110 Merge branch 'remove-lua-udata-lib' into Saturn-Next 2026-11-12 22:43:23 +03:00
alufolie91 ee4c060cc8 add rumble type for wallbonks
yoinked from blan
will also look into drift release rumble, but we have that per lua in sg anyways
2026-11-12 20:31:27 +01:00
alufolie91 ebd5b86e87 use screen_width/height for scr_resolution uniform
those are meant for this kinda crap
2026-11-12 19:39:50 +01:00
alufolie91 9321036049 further simplify downsample stuff
man idk why i even did the whole desktop res shit
somehow kept forgetting we should just check against the drawable/window size as it determines the main framebuffer size
so we just can use SDL_GetWindowSize and get rid of all the other crap
2026-11-11 12:26:53 +01:00
alufolie91 12f43ae504 move horizonline stuff back to plane preprocessor
well "back" we still had it there, but the subsector marking logic can just be there
was kinda too lazy before to do this lul
saves some time as we dont need to go thru all subsectors again at mapload, which there can be many of
2026-11-11 12:25:20 +01:00
alufolie91 cfc94c0f9e fix horizonlines on fofs in opengl
not super cool but seems to work just fine
the new subsector flag may even improve performance in some cases since the horizonspecial check seems to mess up the branch predictor often lol
2026-11-11 00:55:41 +01:00
indev 148bd1ab4d Remove lua_udatalib, and use Lua_CreateFieldTable for mobj and player instead
Need to test this a little but in theory, udatalib doesn't really give
much benefits, and using fields table and enum is safer than messing
with offsetof
2026-11-10 21:53:23 +03:00
alufolie91 3385df4c7e allow gl fbo to be enabled at all times
not just when downsampling
as this may improve performance in some cases
2026-11-10 17:48:30 +01:00
alufolie91 561f871e61 fix downsample state not refreshing in the right place
needs to be done before refreshing the surface, as OglSdlSurface needs to determine the state to toggle the fbo
2026-11-10 17:48:27 +01:00
alufolie91 bffafa0540 make screen fbo msaa compatible
quite a mess but "works"
the reason this didnt work before was
i mostly tried doing this per multisample textures which you cant really copy from
now we do it per color rbo which you also cant really copy from, but is the recommended way
so now each time we try to copy from the screen (screentextures, screenshots, etc.) we blit the msaa fbo into the normal fbo so we can copy from that
its probably a little slow, but cant really do much about it besides getting rid of screen textures and replacing them with more fbo logic.....
2026-11-10 17:27:11 +01:00
alufolie91 473619ab66 add I_CheckAboveDesktopRes
forgor i added this originally for the resolution list rework stuff so was missing here lul
2026-11-09 20:51:02 +01:00
alufolie91 d75638cbfc remove alpha to coverage (a2c) support
while this can look nice in some cases with msaa, it has the effect that everything transclucent is twice as translucent as it should be besides just being a kinda confusing option for almost everyone
so just delet it and simplify code
2026-11-09 20:26:50 +01:00
alufolie91 f09b591989 set screentexture filtermode to linear when downsampling
nearest-neighbour filtering is good from upscaling from a lower resolution, but will produce super ugly mixels and shimmering when downsampling from a higher resolution
2026-11-09 20:19:14 +01:00
alufolie91 79d75aa08d simplify gl "downsampling" stuff
still kinda meh but whatever, shit works
2026-11-09 20:19:08 +01:00
alufolie91 486560d79e fix typo
:blobcatpats:
2026-11-09 20:18:03 +01:00
alufolie91 953b0c8f94 opengl: make stencil attachment for fbo with EXT a requierement
while not compeletely needed, we use the stencil buffer for some stuff, so dont really feel like having to deal with potential issues here
besides, probably any gpu in almost the last 2 decades should support this and even gl3.0 anyways, so this is just bloat we do not need
2026-11-09 20:17:59 +01:00
alufolie91 5639e872f1 delet this
cant remember what this was used for lul
2026-11-09 20:17:51 +01:00
alufolie91 80da0fc538 fix G_GetDemoDate
forgor to change this back oopsie
2026-11-07 13:52:29 +01:00
alufolie91 014126b57d Merge branch 'origin/polyholes' into Saturn-Next 2026-11-06 17:21:19 +01:00
alufolie91 d7b150a04f (hopefully) make replay date stuff more thread safe
dont do locale stuff from thread, use localtime_r && localtime_r as localtime is not threadsafe either
G_GetDemoDate returns malloc´d buffer again, tho not strictly necessary
also, fix dates not always being initialized in all cases and type issue with G_GetCreationTime
2026-11-06 16:14:39 +01:00
alufolie91 5751f9b29b fix windoze compile
windoze does not have threads.h and thread_local is only a keyword per c23....
thanks michealslop....
2026-11-05 15:55:22 +01:00
alufolie91 1f04d07a32 ensure skin models are ALWAYS initialized
if smth sets nomd2s those werent set up correctly and enabling models just ended up drawing nothing instead

ideally nomd2s == false should just completely disable the model system but im too lazy for that currently
2026-10-17 16:06:20 +02:00
alufolie91 f0e0cd4f65 fix compile with discordrpc 2026-10-16 15:27:57 +02:00
alufolie91 3fb6f4a725 Merge branch 'Saturn-Next' into dynskins 2026-10-16 15:23:26 +02:00
alufolie91 8578697e53 fix buffer overflow with skinnumbers in R_ParseSpriteInfo
this was always too small and would just cause a buffer overflow if youd reached the skinlimit and then attempt to load localskins
2026-10-16 15:20:39 +02:00
alufolie91 102f9ec280 remove localskin limit 2026-10-16 15:20:36 +02:00
alufolie91 0e5fd84dbd move translationtablecache to skin_t
last remaining static buffer for localskins
now we can remove the limit completely
there are still some static arrays for normal skins remaining, removing those will take a bit more work im currently waaaaay too lazy for
2026-10-16 15:20:34 +02:00
alufolie91 971eb871da fix some skinnumber bound checks
gotta stay within "numskins" now instead of maxskins
2026-10-16 15:20:31 +02:00
alufolie91 e8513333cd fixup localskin lua stuff
i hope and pray this does not explode
localskin lookup per skinnumber straight up did not work and also technically could cause issues if someone would load localskins before other skins
and generally localskins are now ONLY exposed if luaimmersion is enabled
2026-10-12 17:43:22 +02:00
alufolie91 5cc66172a4 cleanup localskin md2 handling 2026-10-12 16:23:26 +02:00
alufolie91 31d8ad1d1a remove now unnecessary mobj skin_t casts
no more void pointers for this stuff!
2026-10-12 16:23:23 +02:00
alufolie91 2d926689d9 simpler fix for localskin minimap angle display crash 2026-10-12 15:13:53 +02:00
alufolie91 58db9365bf simplify skin helper functions a bit 2026-10-12 15:13:50 +02:00
alufolie91 e81547f637 fix crash when applying localskin midgame 2026-10-08 09:21:50 +02:00
alufolie91 6e1877f6ab dynamically allocate skin/localskins
based on https://gitlab.com/kart-krew-dev/ring-racers/-/commit/255570cfca8ac6a2700098036085a48a10a3a84b

this also extends to localskins and some other things that were static arrays before, like the faceprefixes and md2 models
those are now part of the skin_t structs aswell

TODO: dynamic allocate the translationtablecaches so we can completely remove the localskin limits and maybe further cleanup localskin handling

also cleans up a few parts of the localskin handling
and might reduce general memory usage slightly in some cases

this gave me an intense headache ngl
2026-10-08 09:07:27 +02:00
57 changed files with 2862 additions and 2357 deletions

No files matched your search

-2
View File
@@ -292,7 +292,6 @@ if(${SRB2_CONFIG_HAVE_BLUA})
lua_script.c
lua_skinlib.c
lua_thinkerlib.c
lua_udatalib.c
lua_glib.c
)
set(SRB2_LUA_HEADERS
@@ -302,7 +301,6 @@ if(${SRB2_CONFIG_HAVE_BLUA})
lua_profile.h
lua_libs.h
lua_script.h
lua_udatalib.h
lua_glib.h
)
-1
View File
@@ -97,6 +97,5 @@ lua_playerlib.c
lua_script.c
lua_skinlib.c
lua_thinkerlib.c
lua_udatalib.c
lua_glib.c
lua_profile.cpp
+2 -2
View File
@@ -811,7 +811,7 @@ static void resynch_read_player(resynch_pak *rsp)
players[i].mo->scalespeed = (fixed_t)LONG(rsp->scalespeed);
// And finally, SET THE MOBJ SKIN damn it.
players[i].mo->skin = &skins[players[i].skin];
players[i].mo->skin = skins[players[i].skin];
players[i].mo->color = players[i].skincolor;
P_SetThingPosition(players[i].mo);
@@ -4128,7 +4128,7 @@ static void Got_KickCmd(const UINT8 **p, INT32 playernum)
if (!players[i].mo->skin)
CONS_Printf("Mobj skin: NULL!\n");
else
CONS_Printf("Mobj skin: %s\n", ((skin_t *)players[i].mo->skin)->name);
CONS_Printf("Mobj skin: %s\n", players[i].mo->skin->name);
CONS_Printf("Position: %d, %d, %d\n", players[i].mo->x, players[i].mo->y, players[i].mo->z);
if (!players[i].mo->state)
CONS_Printf("State: S_NULL\n");
+35 -33
View File
@@ -1043,6 +1043,8 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_rumble[i]);
CV_RegisterVar(&cv_rumble_strength[i]);
CV_RegisterVar(&cv_rumble_wallbonk[i]);
CV_RegisterVar(&cv_rumble_spinout[i]);
CV_RegisterVar(&cv_rumble_sneakerboost[i]);
CV_RegisterVar(&cv_rumble_offroad[i]);
@@ -1174,14 +1176,14 @@ static void Skin_FindRealNameSkin(consvar_t *cvar)
for (i = 0; i < numskins; i++)
{
// Perfect match with some skin name, no need to find matching realname
if (strncasecmp(value, skins[i].name, sizeof skins[i].name) == 0)
if (strncasecmp(value, skins[i]->name, sizeof skins[i]->name) == 0)
return;
const char *match = strcasestr(skins[i].realname, value);
const char *match = strcasestr(skins[i]->realname, value);
if (match != NULL)
{
matches[nummatches] = i;
matches_pos[nummatches] = match - skins[i].realname;
matches_pos[nummatches] = match - skins[i]->realname;
++nummatches;
}
}
@@ -1189,7 +1191,7 @@ static void Skin_FindRealNameSkin(consvar_t *cvar)
if (nummatches == 1)
{
// Change the cvar to be the value of the name.
CV_StealthSet(cvar, skins[matches[0]].name);
CV_StealthSet(cvar, skins[matches[0]]->name);
}
else if (nummatches > 1)
{
@@ -1203,7 +1205,7 @@ static void Skin_FindRealNameSkin(consvar_t *cvar)
for (i = 0; i < nummatches; ++i)
{
const char *realname = skins[matches[i]].realname;
const char *realname = skins[matches[i]]->realname;
if (matches_pos[i] == 0)
start[0] = 0;
@@ -1218,7 +1220,7 @@ static void Skin_FindRealNameSkin(consvar_t *cvar)
end = realname + matches_pos[i] + query_length;
CONS_Printf("%s\x85%s\x80%s (%s)\n", start, match, end, skins[matches[i]].name);
CONS_Printf("%s\x85%s\x80%s (%s)\n", start, match, end, skins[matches[i]]->name);
}
CONS_Printf("\x86Try be more specific\n");
@@ -1553,13 +1555,13 @@ static void ForceAllSkins(INT32 forcedskin)
if (!dedicated) // But don't do this for dedicated servers, of course.
{
if (i == consoleplayer)
CV_StealthSet(&cv_skin, skins[forcedskin].name);
CV_StealthSet(&cv_skin, skins[forcedskin]->name);
else if (i == displayplayers[1])
CV_StealthSet(&cv_skin2, skins[forcedskin].name);
CV_StealthSet(&cv_skin2, skins[forcedskin]->name);
else if (i == displayplayers[2])
CV_StealthSet(&cv_skin3, skins[forcedskin].name);
CV_StealthSet(&cv_skin3, skins[forcedskin]->name);
else if (i == displayplayers[3])
CV_StealthSet(&cv_skin4, skins[forcedskin].name);
CV_StealthSet(&cv_skin4, skins[forcedskin]->name);
}
}
}
@@ -1613,8 +1615,8 @@ static void SendNameAndColor(UINT8 splitplayer)
{
if (player->skincolor)
CV_StealthSetValue(playercolor, player->skincolor);
else if (skins[player->skin].prefcolor)
CV_StealthSetValue(playercolor, skins[player->skin].prefcolor);
else if (skins[player->skin]->prefcolor)
CV_StealthSetValue(playercolor, skins[player->skin]->prefcolor);
else
CV_StealthSet(playercolor, playercolor->defaultvalue);
}
@@ -1625,7 +1627,7 @@ static void SendNameAndColor(UINT8 splitplayer)
if (fastcmp(playername->string, player_names[pnum])
&& playercolor->value == player->skincolor
&& fastcmp(playerskin->string, skins[player->skin].name))
&& fastcmp(playerskin->string, skins[player->skin]->name))
return;
if (playerisbot)
@@ -1654,12 +1656,12 @@ static void SendNameAndColor(UINT8 splitplayer)
{
playerskin->value = foundskin;
SetPlayerSkin(pnum, playerskin->string);
CV_StealthSet(playerskin, skins[playerskin->value].name);
CV_StealthSet(playerskin, skins[playerskin->value]->name);
}
else
{
playerskin->value = player->skin;
CV_StealthSet(playerskin, skins[player->skin].name);
CV_StealthSet(playerskin, skins[player->skin]->name);
// will always be same as current
SetPlayerSkin(pnum, playerskin->string);
}
@@ -1684,7 +1686,7 @@ static void SendNameAndColor(UINT8 splitplayer)
// Don't change skin if the server doesn't want you to.
if (!CanChangeSkin(pnum))
CV_StealthSet(playerskin, skins[player->skin].name);
CV_StealthSet(playerskin, skins[player->skin]->name);
// check if player has the skin loaded (cv_skin may have
// the name of a skin that was available in the previous game)
@@ -1692,7 +1694,7 @@ static void SendNameAndColor(UINT8 splitplayer)
if (playerskin->value < 0)
{
INT32 skinnum = player->skin;
CV_StealthSet(playerskin, skins[skinnum].name);
CV_StealthSet(playerskin, skins[skinnum]->name);
playerskin->value = skinnum;
}
@@ -1780,13 +1782,13 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum)
// TODO: make cv_skin an array
if (playernum == consoleplayer)
CV_StealthSet(&cv_skin, skins[forcedskin].name);
CV_StealthSet(&cv_skin, skins[forcedskin]->name);
else if (playernum == displayplayers[1])
CV_StealthSet(&cv_skin2, skins[forcedskin].name);
CV_StealthSet(&cv_skin2, skins[forcedskin]->name);
else if (playernum == displayplayers[2])
CV_StealthSet(&cv_skin3, skins[forcedskin].name);
CV_StealthSet(&cv_skin3, skins[forcedskin]->name);
else if (playernum == displayplayers[3])
CV_StealthSet(&cv_skin4, skins[forcedskin].name);
CV_StealthSet(&cv_skin4, skins[forcedskin]->name);
}
else
SetPlayerSkinByNum(playernum, skin);
@@ -4356,10 +4358,10 @@ static void SetPrefcolor(int splitplayer)
consvar_t *colorvars[] = {&cv_playercolor, &cv_playercolor2, &cv_playercolor3, &cv_playercolor4};
consvar_t *playercolor = colorvars[splitplayer];
if (skins[player->skin].prefcolor)
if (skins[player->skin]->prefcolor)
{
CV_SetValue(playercolor, skins[player->skin].prefcolor);
CONS_Printf("Set color to %s%s\n", HU_SkinColorToConsoleColor(skins[player->skin].prefcolor), KartColor_Names[skins[player->skin].prefcolor]);
CV_SetValue(playercolor, skins[player->skin]->prefcolor);
CONS_Printf("Set color to %s%s\n", HU_SkinColorToConsoleColor(skins[player->skin]->prefcolor), KartColor_Names[skins[player->skin]->prefcolor]);
}
else
{
@@ -5632,7 +5634,7 @@ static void Skin_OnChange(void)
if (!(cv_debug || devparm) && !(multiplayer || netgame) // In single player.
&& (gamestate != GS_WAITINGPLAYERS)) // allows command line -warp x +skin y
{
CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name);
CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin]->name);
return;
}
@@ -5641,7 +5643,7 @@ static void Skin_OnChange(void)
else
{
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name);
CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin]->name);
}
}
@@ -5662,7 +5664,7 @@ static void Skin2_OnChange(void)
else
{
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
CV_StealthSet(&cv_skin2, skins[players[displayplayers[1]].skin].name);
CV_StealthSet(&cv_skin2, skins[players[displayplayers[1]].skin]->name);
}
}
@@ -5678,7 +5680,7 @@ static void Skin3_OnChange(void)
else
{
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
CV_StealthSet(&cv_skin3, skins[players[displayplayers[2]].skin].name);
CV_StealthSet(&cv_skin3, skins[players[displayplayers[2]].skin]->name);
}
}
@@ -5694,7 +5696,7 @@ static void Skin4_OnChange(void)
else
{
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
CV_StealthSet(&cv_skin4, skins[players[displayplayers[3]].skin].name);
CV_StealthSet(&cv_skin4, skins[players[displayplayers[3]].skin]->name);
}
}
@@ -5737,7 +5739,7 @@ static void Command_ListSkins(void)
for (i = page * 10; i < numskins && i < (page + 1) * 10; i++)
{
int length;
skin_t *skin = &skins[i];
skin_t *skin = skins[i];
if ((length = strlen(skin->name)) > longest_name)
longest_name = length;
@@ -5745,7 +5747,7 @@ static void Command_ListSkins(void)
for (i = page * 10; i < numskins && i < (page + 1) * 10; i++)
{
skin_t *skin = &skins[i];
skin_t *skin = skins[i];
CONS_Printf(
"%s[%-*s]\x80 %s\n",
@@ -5775,7 +5777,7 @@ static void Command_SkinSearch(void)
{
for (s = 0; s < numskins; s++)
{
skin_t *skininput = &skins[s];
skin_t *skininput = skins[s];
if (strcasestr(skininput->realname, COM_Argv(i)))
{
@@ -5799,7 +5801,7 @@ static void Color_OnChange(void)
if (!(cv_debug || devparm) && !(multiplayer || netgame || modeattacking)) // In single player.
{
CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name);
CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin]->name);
return;
}
+2 -2
View File
@@ -686,7 +686,7 @@ void DRPC_UpdatePresence(void)
// Character image
while (supportedSkins[checkSkin] != NULL)
{
if (fastcmp(skins[players[consoleplayer].skin].name, supportedSkins[checkSkin]))
if (fastcmp(skins[players[consoleplayer].skin]->name, supportedSkins[checkSkin]))
{
snprintf(charimg, 21, "char%s", supportedSkins[checkSkin]);
discordPresence.smallImageKey = charimg;
@@ -703,7 +703,7 @@ void DRPC_UpdatePresence(void)
discordPresence.smallImageKey = "charcustom";
}
snprintf(charname, 28, "Character: %s", skins[players[consoleplayer].skin].realname);
snprintf(charname, 28, "Character: %s", skins[players[consoleplayer].skin]->realname);
discordPresence.smallImageText = charname; // Character name
}
+5 -5
View File
@@ -324,7 +324,7 @@ void F_IntroTicker(void)
// Need to use M_Random otherwise it always uses the same sound
INT32 rskin = M_RandomKey(numskins);
UINT8 rtaunt = M_RandomKey(2);
sfxenum_t rsound = skins[rskin].soundsid[SKSKBST1+rtaunt];
sfxenum_t rsound = skins[rskin]->soundsid[SKSKBST1+rtaunt];
S_StartSound(NULL, rsound);
}
}
@@ -1162,17 +1162,17 @@ void F_StartWaitingPlayers(void)
finalecount = 0;
randskin = M_RandomKey(numskins);
boolean waithires = skins[randskin].flags && SF_HIRES;
boolean waithires = skins[randskin]->flags && SF_HIRES;
Z_Free(waitcolormap);
waitcolormap = R_GetTranslationColormap(randskin, skins[randskin].prefcolor, 0);
waitcolormap = R_GetTranslationColormap(randskin, skins[randskin]->prefcolor, 0);
if (waithires)
waitscale = waitscale * FIXED_TO_FLOAT(skins[randskin].highresscale); // need to set scale here cause im lazy
waitscale = waitscale * FIXED_TO_FLOAT(skins[randskin]->highresscale); // need to set scale here cause im lazy
for (i = 0; i < 2; i++)
{
sprframe = &skins[randskin].spritedef.spriteframes[(6+(i*3)) & FF_FRAMEMASK];
sprframe = &skins[randskin]->spritedef.spriteframes[(6+(i*3)) & FF_FRAMEMASK];
driver[i] = W_CachePatchNum(sprframe->lumppat[1], PU_CACHE);
}
}
+42 -73
View File
@@ -63,7 +63,6 @@
// for replay dates
#include <time.h>
#include <locale.h>
// menu demo things
UINT32 demoDelayTime = 15*TICRATE;
@@ -203,7 +202,7 @@ static INT32 GetSkinNumClosestToStats(UINT8 kartspeed, UINT8 kartweight)
for (i = 0; i < numskins; i++)
{
stat_diff = abs(skins[i].kartspeed - kartspeed) + abs(skins[i].kartweight - kartweight);
stat_diff = abs(skins[i]->kartspeed - kartspeed) + abs(skins[i]->kartweight - kartweight);
if (stat_diff < closest_stats)
{
@@ -266,7 +265,7 @@ void G_ReadDemoExtraData(void)
kartspeed = READUINT8(demobuf.p);
kartweight = READUINT8(demobuf.p);
if (!fasticmp(skins[player->skin].name, name))
if (!fasticmp(skins[player->skin]->name, name))
FindClosestSkinForStats(p, kartspeed, kartweight);
player->kartspeed = kartspeed;
@@ -396,12 +395,12 @@ void G_WriteDemoExtraData(void)
{
// Skin
memset(name, 0, 16);
strncpy(name, skins[players[i].skin].name, 16);
strncpy(name, skins[players[i].skin]->name, 16);
memcpy(demobuf.p, name, 16);
demobuf.p += 16;
WRITEUINT8(demobuf.p, skins[players[i].skin].kartspeed);
WRITEUINT8(demobuf.p, skins[players[i].skin].kartweight);
WRITEUINT8(demobuf.p, skins[players[i].skin]->kartspeed);
WRITEUINT8(demobuf.p, skins[players[i].skin]->kartweight);
}
if (demo_extradata[i] & DXD_COLOR)
@@ -1807,7 +1806,7 @@ void G_BeginRecording(void)
// Skin
memset(name, 0, 16);
strncpy(name, skins[player->skin].name, 16);
strncpy(name, skins[player->skin]->name, 16);
memcpy(demobuf.p, name, 16);
demobuf.p += 16;
@@ -1821,8 +1820,8 @@ void G_BeginRecording(void)
WRITEUINT32(demobuf.p, player->score);
// Kart speed and weight
WRITEUINT8(demobuf.p, skins[player->skin].kartspeed);
WRITEUINT8(demobuf.p, skins[player->skin].kartweight);
WRITEUINT8(demobuf.p, skins[player->skin]->kartspeed);
WRITEUINT8(demobuf.p, skins[player->skin]->kartweight);
}
WRITEUINT8(demobuf.p, 0xFF); // Denote the end of the player listing
@@ -1878,7 +1877,7 @@ void G_WriteStanding(UINT8 ranking, char *name, INT32 skinnum, UINT8 color, UINT
// Skin
memset(temp, 0, 16);
strncpy(temp, skins[skinnum].name, 16);
strncpy(temp, skins[skinnum]->name, 16);
memcpy(demobuf.p, temp, 16);
demobuf.p += 16;
@@ -2351,7 +2350,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
for (i = 0; i < numskins; i++)
{
if (fasticmp(skins[i].name, temp))
if (fasticmp(skins[i]->name, temp))
{
pdemo->standings[count].skin = i;
break;
@@ -2387,7 +2386,9 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
#if defined (_WIN32)
// return the file creation time
// useful for demos that were renamed
static long G_GetCreationTime(char *filepath)
// windows only, as file creation times are
// very unreliable (or non existant depending on fs) on linux
static time_t G_GetCreationTime(char *filepath)
{
struct stat fileinfo;
@@ -2398,35 +2399,24 @@ static long G_GetCreationTime(char *filepath)
}
#endif
static char *G_GetDemoDate(menudemo_t *pdemo)
static char *G_GetDemoDate(menudemo_t *pdemo, const char *dateformat)
{
char *endPos = NULL;
static char datetime[11];
char *datetime;
time_t file_time = 0;
const char *format = NULL;
struct tm *tm_buf = NULL;
struct tm tm_buf;
CLEANUP(pfree) char *filename = NULL;
// get le filepath
filename = strdup(pdemo->filepath);
if (!filename)
{
#if defined (_WIN32)
// if we cant get a filename try just getting the file creation time
file_time = G_GetCreationTime(pdemo->filepath);
goto skipfilenametime;
#else
return NULL;
#endif
}
// get the actual filename Zzz...
nameonly(filename);
// the first 10 characters of a replay name usually is a unix timestamp
// not long enough to contain a valid timestamp
// the first 10 characters of a replay name is a unix timestamp
if (strlen(filename) < 10)
{
#if defined (_WIN32)
@@ -2458,67 +2448,49 @@ static char *G_GetDemoDate(menudemo_t *pdemo)
#endif
}
#if defined (_WIN32)
skipfilenametime:
#endif
// then throw it into localtime to get an actual human readable format lmao
tm_buf = localtime(&file_time);
// cant believe we ended up in 1970
if (tm_buf == NULL || tm_buf->tm_year <= 110)
#if defined(_WIN32)
skipfilenametime:
if ((localtime_s(&tm_buf, &file_time) != 0) ||
(tm_buf.tm_year <= 110)) // cant believe we ended up in 1970
{
#if defined (_WIN32)
// uh ohh, we got an invalid time
// try one more time getting the creation time
file_time = G_GetCreationTime(pdemo->filepath);
tm_buf = localtime(&file_time);
if (tm_buf == NULL || tm_buf->tm_year <= 110)
if ((localtime_s(&tm_buf, &file_time) != 0) ||
(tm_buf.tm_year <= 110))
return NULL;
goto gotcreationtime;
}
#else
if ((localtime_r(&file_time, &tm_buf) == NULL) ||
(tm_buf.tm_year <= 110)) // cant believe we ended up in 1970
return NULL;
#endif
}
#if defined (_WIN32)
gotcreationtime:
#endif
datetime = malloc(sizeof(pdemo->date)); // mallocma balls
// US ppl are special (:
if (cv_demodateformat.value == 2)
format = "%m.%d.%Y";
else if (cv_demodateformat.value == 1)
format = "%d.%m.%Y";
else
{
const char *locale = setlocale(LC_TIME, NULL);
// no mallocma balls... :c
if (!datetime)
return NULL;
if (locale == NULL)
format = "%d.%m.%Y"; // fallback to non US format
else if (strstr(locale, "en_US"))
format = "%m.%d.%Y";
else
format = "%d.%m.%Y";
}
if (strftime(datetime, sizeof(datetime), format, tm_buf) == 0)
if (strftime(datetime, sizeof(pdemo->date), dateformat, &tm_buf) == 0)
{
free(datetime);
return NULL;
}
return datetime;
}
void G_LoadDemoTitle(menudemo_t *pdemo)
void G_LoadDemoTitle(menudemo_t *pdemo, const char *dateformat)
{
UINT8 infobuffer[96], *info_p;
UINT16 pdemoversion;
char *demodate = NULL;
size_t count;
memset(pdemo->date, 0, sizeof(pdemo->date));
FILE *handle = fopen(pdemo->filepath, "rb");
if (!handle)
@@ -2546,8 +2518,6 @@ void G_LoadDemoTitle(menudemo_t *pdemo)
pdemoversion = READUINT16(info_p);
memset(pdemo->date, 0, sizeof(pdemo->date));
switch (pdemoversion)
{
case DEMOVERSION: // latest always supported
@@ -2555,13 +2525,12 @@ void G_LoadDemoTitle(menudemo_t *pdemo)
memcpy(pdemo->title, info_p, 64);
// demo date
demodate = G_GetDemoDate(pdemo);
char *demodate = G_GetDemoDate(pdemo, dateformat);
if (demodate)
{
strlcpy(pdemo->date, demodate, sizeof(pdemo->date));
free(demodate);
}
break;
#ifdef DEMO_COMPAT_100
case 0x0001:
@@ -3029,7 +2998,7 @@ void G_DoPlayDemo(char *defdemoname)
kartspeed[p] = READUINT8(demobuf.p);
kartweight[p] = READUINT8(demobuf.p);
if (!fasticmp(skins[players[p].skin].name, skin))
if (!fasticmp(skins[players[p].skin]->name, skin))
FindClosestSkinForStats(p, kartspeed[p], kartweight[p]);
// Look for the next player
@@ -3106,7 +3075,7 @@ void G_AddGhost(char *defdemoname)
CLEANUP(Z_Pfree) UINT8 *buffer = NULL;
mapthing_t *mthing;
UINT16 count, ghostversion;
skin_t *ghskin = &skins[0];
skin_t *ghskin = skins[0];
UINT8 kartspeed = UINT8_MAX, kartweight = UINT8_MAX;
name[16] = '\0';
@@ -3313,9 +3282,9 @@ void G_AddGhost(char *defdemoname)
for (i = 0; i < numskins; i++)
{
if (fasticmp(skins[i].name, skin))
if (fasticmp(skins[i]->name, skin))
{
ghskin = &skins[i];
ghskin = skins[i];
break;
}
}
@@ -3323,7 +3292,7 @@ void G_AddGhost(char *defdemoname)
if (i == numskins)
{
if (kartspeed != UINT8_MAX && kartweight != UINT8_MAX)
ghskin = &skins[GetSkinNumClosestToStats(kartspeed, kartweight)];
ghskin = skins[GetSkinNumClosestToStats(kartspeed, kartweight)];
CONS_Alert(CONS_NOTICE, M_GetText("Ghost %s: Invalid character. Falling back to %s.\n"), pdemoname, ghskin->name);
}
+1 -1
View File
@@ -98,7 +98,7 @@ void G_SetDemoTime(UINT32 ptime, UINT32 plap);
UINT8 G_CmpDemoTime(char *oldname, char *newname);
void G_LoadDemoInfo(menudemo_t *pdemo);
void G_LoadDemoTitle(menudemo_t *pdemo); // For use in replay search feature
void G_LoadDemoTitle(menudemo_t *pdemo, const char *dateformat); // For use in replay search feature
void G_DeferedPlayDemo(const char *demo);
typedef enum
+2 -2
View File
@@ -3935,9 +3935,9 @@ void G_DeferedInitNew(boolean pencoremode, const char *mapname, INT32 pickedchar
}
if (!color && !modeattacking)
color = skins[pickedchar].prefcolor;
color = skins[pickedchar]->prefcolor;
SetPlayerSkinByNum(consoleplayer, pickedchar);
CV_StealthSet(&cv_skin, skins[pickedchar].name);
CV_StealthSet(&cv_skin, skins[pickedchar]->name);
if (color)
CV_StealthSetValue(&cv_playercolor, color);
+39 -62
View File
@@ -17,14 +17,9 @@
#include "g_game.h"
#include "keys.h"
#include "hu_stuff.h" // need HUFONT start & end
#include "d_net.h"
#include "console.h"
#include "m_menu.h"
#include "i_system.h"
#include "i_video.h"
#include "r_draw.h"
#include "v_video.h"
#define MAXMOUSESENSITIVITY 100 // sensitivity steps
@@ -36,10 +31,11 @@ static CV_PossibleValue_t turnsmooth_cons_t[] = {{2, "Slow"}, {1, "Fast"}, {0, "
// mouse values are used once
consvar_t cv_mousexsens = {"mousexsens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_mouseysens = {"mouseysens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_controlperkey = {"controlperkey", "One", CV_SAVE, onecontrolperkey_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_turnsmooth[MAXSPLITSCREENPLAYERS] = {
{"turnsmoothing", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"turnsmoothing", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"turnsmoothing2", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"turnsmoothing3", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"turnsmoothing4", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}
@@ -81,6 +77,7 @@ consvar_t cv_rumble_##type [MAXSPLITSCREENPLAYERS] = {\
{"rumble4_" #type, "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}\
};
IMPL_RUMBLE_TYPE(wallbonk);
IMPL_RUMBLE_TYPE(spinout);
IMPL_RUMBLE_TYPE(sneakerboost);
IMPL_RUMBLE_TYPE(offroad);
@@ -89,7 +86,6 @@ IMPL_RUMBLE_TYPE(stairjank);
IMPL_RUMBLE_TYPE(brakedrift);
IMPL_RUMBLE_TYPE(driftcharge);
static CV_PossibleValue_t gamepadled_cons_t[] = {{0, "Off"}, {1, "Skincolor"}, {2, "Mobjcolor"}, {0, NULL}};
consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS] = {
{"gamepadled", "Skincolor", CV_SAVE|CV_CALL|CV_NOINIT, gamepadled_cons_t, led_off_handle, 0, NULL, NULL, 0, 0, NULL},
@@ -195,7 +191,6 @@ void G_MapEventsToControls(event_t *ev)
{
CONS_Debug(DBG_GAMELOGIC, "Bad downkey input %d\n",ev->data1);
}
#endif
break;
@@ -951,16 +946,15 @@ void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT8 color)
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
if (cv_gamepadled[playernum].value == 0 || (window_notinfocus && cv_gamepadledifunfocused.value == 0)
|| color >= MAXTRANSLATIONS)
if (cv_gamepadled[playernum].value == 0 ||
(window_notinfocus && cv_gamepadledifunfocused.value == 0) ||
color >= MAXTRANSLATIONS)
{
return;
}
if (!I_GamepadHasLED(playernum))
{
return;
}
// so we can override this
skincolor = color ? color : G_GetSkinColorForGamepad(playernum);
@@ -990,29 +984,21 @@ void G_DeviceLEDTick(void)
UINT8 i, newcolor;
if (numcontrollers == 0)
{
return;
}
for (i = 0; i <= splitscreen; i++)
{
if (!cv_usejoystick[i].value || !cv_gamepadled[i].value)
{
continue;
}
// does not have a configurable led! :c
if (!I_GamepadHasLED(i))
{
continue;
}
newcolor = G_GetSkinColorForGamepad(i);
if (curcolor[i] == newcolor) // dont update if same colour
{
continue;
}
G_SetPlayerGamepadIndicatorColor(i, newcolor);
curcolor[i] = newcolor;
@@ -1046,9 +1032,7 @@ void G_PlayerDeviceRumble(INT32 playernum, UINT16 low_strength, UINT16 high_stre
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
if (cv_rumble[playernum].value == 0 || (window_notinfocus && cv_rumbleifunfocused.value == 0))
{
return;
}
// doesent need to be super precise
// but ensure this is within range (0-65535)
@@ -1077,46 +1061,34 @@ void G_DeviceRumbleTick(void)
UINT8 i;
if (dedicated || numcontrollers == 0 || gamestate != GS_LEVEL || demo.playback)
{
return;
}
for (i = 0; i <= splitscreen; i++)
{
if (!cv_usejoystick[i].value || !cv_rumble[i].value)
{
continue;
}
// does not support rumble! :c
if (!I_GamepadHasRumble(i))
{
continue;
}
if (camera[i].freecam)
{
continue;
}
// SDL rumble strength goes from a range or 0-65535 respectively
// the higher, the stronger it is
UINT16 low = 0, high = 0;
// for how long the action should rumble, in ms
UINT16 lenght = 57; // 57ms is a short pulse, matches super well with this updating once per tic
UINT16 length = 57; // 57ms is a short pulse, matches super well with this updating once per tic
const player_t *player = P_GetLocalPlayerForNum(i);
if (!player)
{
continue;
}
// allow lua to do some crap for spectators
if (player->spectator || !player->mo)
{
continue;
}
// reset the rumble if you exit or are ded lel
if (player->exiting ||
@@ -1127,21 +1099,28 @@ void G_DeviceRumbleTick(void)
continue;
}
if (cv_rumble_spinout[i].value
&& player->kartstuff[k_spinouttimer])
if (cv_rumble_wallbonk[i].value &&
(player->mo->eflags & MFE_JUSTBOUNCEDWALL))
{
high = RUMBLE_STRONG;
low = RUMBLE_MODERATE;
}
else if (cv_rumble_spinout[i].value &&
player->kartstuff[k_spinouttimer])
{
//low = high = FRACUNIT / 6;
low = high = FixedMul((RUMBLE_VERYSTRONG), (FixedDiv(player->kartstuff[k_spinouttimer], (3*TICRATE / 2)))); // try do some some kinda fadeout, 3*TICRATE / 2 is the "default" spinout time
// try do some some kinda fadeout, 3*TICRATE / 2 is the "default" spinout time
low = high = FixedMul(RUMBLE_VERYSTRONG, FixedDiv(player->kartstuff[k_spinouttimer], (3*TICRATE / 2)));
}
else if (cv_rumble_sneakerboost[i].value
&& (player->kartstuff[k_sneakertimer] > (sneakertime-(TICRATE/2))))
else if (cv_rumble_sneakerboost[i].value &&
(player->kartstuff[k_sneakertimer] > (sneakertime-(TICRATE/2))))
{
low = high = RUMBLE_STRONG;
}
else if (cv_rumble_offroad[i].value
&& (player->kartstuff[k_offroad])
&& (player->speed != 0)
&& P_IsObjectOnGround(player->mo))
else if (cv_rumble_offroad[i].value &&
(player->kartstuff[k_offroad]) &&
(player->speed != 0) &&
P_IsObjectOnGround(player->mo))
{
// weaken this depending on if you got hyu or invinc
if (player->kartstuff[k_hyudorotimer])
@@ -1157,50 +1136,48 @@ void G_DeviceRumbleTick(void)
low = high = RUMBLE_MODERATE;
}
}
else if (cv_rumble_bananadrag[i].value
&& (player->kartstuff[k_bananadrag] > TICRATE)
&& (player->speed != 0)
&& P_IsObjectOnGround(player->mo))
else if (cv_rumble_bananadrag[i].value &&
(player->kartstuff[k_bananadrag] > TICRATE) &&
(player->speed != 0) &&
P_IsObjectOnGround(player->mo))
{
if (leveltime & 1) // this is actually funny lel
high = RUMBLE_MODERATE;
}
else if (cv_rumble_stairjank[i].value
&& (player->stairjank > 8)
&& (player->speed != 0)
&& P_IsObjectOnGround(player->mo))
else if (cv_rumble_stairjank[i].value &&
(player->stairjank > 8) &&
(player->speed != 0) &&
P_IsObjectOnGround(player->mo))
{
low = high = RUMBLE_VERYWEAK;
}
if (cv_rumble_brakedrift[i].value
&& player->kartstuff[k_brakedrift])
if (cv_rumble_brakedrift[i].value &&
player->kartstuff[k_brakedrift])
{
high = CLAMP((high + RUMBLE_VERYWEAK), 0, UINT16_MAX);
}
// pulse when gettin new driftlevel
// let this come last
if (cv_rumble_driftcharge[i].value
&& player->kartstuff[k_driftcharge]
&& player->driftlevel)
if (cv_rumble_driftcharge[i].value &&
player->kartstuff[k_driftcharge] &&
player->driftlevel)
{
high = CLAMP((high + RUMBLE_VERYWEAK), 0, UINT16_MAX);
// make it rumble slightly longer the higher your driftlevel!
if (player->driftlevel == 2)
lenght = 114;
length = 114;
else if (player->driftlevel == 3)
lenght = 174;
length = 174;
}
// hack alert! i just dont want this thing constantly resetting the rumble lol
if (low == 0 && high == 0)
{
continue;
}
G_PlayerDeviceRumble(i, low, high, lenght);
G_PlayerDeviceRumble(i, low, high, length);
}
}
+2
View File
@@ -118,6 +118,8 @@ extern consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_rumble_strength[MAXSPLITSCREENPLAYERS];
// rumble types
extern consvar_t cv_rumble_wallbonk[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_rumble_spinout[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_rumble_sneakerboost[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_rumble_offroad[MAXSPLITSCREENPLAYERS];
+15 -18
View File
@@ -54,10 +54,6 @@ typedef struct {
// if no portals are found, the portal scanning phase can be skipped while rendering, saving a bit of time.
boolean gl_maphasportals = false;
// Determine on mapload if current map has any Horizonlines present
// avoids doing a bunch of work during rendering
boolean gl_maphashorizonlines = false;
// ==========================================================================
// FLOOR & CEILING CONVEX POLYS GENERATION
// ==========================================================================
@@ -405,7 +401,7 @@ static void SplitPoly (fdivline_t *dlnp, // splitting parametric line
}
// checks if any line is a portal or horizonline, for optimization
static inline void CheckForPortalsAndHorizonLines(boolean firstside, const line_t *line)
static inline void CheckForPortalsAndHorizonLines(boolean firstside, const line_t *line, subsector_t *sub)
{
// portal check
if (!gl_maphasportals && firstside && line->special == PORTALSPECIAL)
@@ -421,8 +417,8 @@ static inline void CheckForPortalsAndHorizonLines(boolean firstside, const line_
}
// horizonline check
if (!gl_maphashorizonlines && line->special == HORIZONSPECIAL)
gl_maphashorizonlines = true;
if (line->special == HORIZONSPECIAL)
sub->hashorizon = true;
}
// Use each seg of the poly as a partition line, keep only the
@@ -435,7 +431,7 @@ static inline void CheckForPortalsAndHorizonLines(boolean firstside, const line_
// segcount : number of seg in the array
// Return frontpoly, which may be new or ptr to poly.
// Called from: HWR_SubsecPoly
static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 segcount, poly_t *poly)
static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 segcount, poly_t *poly, subsector_t *sub)
{
INT32 i, j;
poly_t* frontpoly = poly; // default, return same poly
@@ -447,10 +443,6 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 segcount, poly_t *poly)
vertex_t *v1, *v2;
fdivline_t cutseg; // x, y, dx, dy as start of node_t struct
// empty poly? just save us some time then
if (poly->numpts <= 0)
return frontpoly;
// for each seg of the subsector
for (; segcount--; lseg++)
{
@@ -460,7 +452,7 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 segcount, poly_t *poly)
if (!line)
continue;
CheckForPortalsAndHorizonLines(lseg->side == 0, line);
CheckForPortalsAndHorizonLines(lseg->side == 0, line, sub);
if (line->sidenum[1] != NO_INDEX)
{
@@ -623,7 +615,7 @@ static inline void HWR_SubsecPoly(INT32 ssindex, poly_t *poly)
if (poly)
{
poly = CutOutSubsecPoly(lseg, segcount, poly);
poly = CutOutSubsecPoly(lseg, segcount, poly, sub);
#ifdef DEBUG_HWBSP
totalsubsecpolys++;
#endif
@@ -752,7 +744,7 @@ static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *b
#endif
// Recursively divide front space.
if (LIKELY(frontpoly))
if (frontpoly)
{
WalkBSPNode(bsp->children[0], frontpoly, &bsp->children[0],bsp->bbox[0]);
@@ -879,7 +871,9 @@ static boolean PointInSeg(polyvertex_t *va, polyvertex_t *v1, polyvertex_t *v2)
#endif
}
#ifdef DEBUG_HWBSP
static INT32 numsplitpoly;
#endif
static void SearchSegInBSP(INT32 bspnum, polyvertex_t *p, poly_t *poly)
{
@@ -918,8 +912,9 @@ static void SearchSegInBSP(INT32 bspnum, polyvertex_t *p, poly_t *poly)
for (n = k+1; n < newpoly->numpts; n++)
newpoly->pts[n] = q->pts[n-1];
#ifdef DEBUG_HWBSP
numsplitpoly++;
#endif
extrasubsectors[bspnum].planepoly = newpoly;
HWR_FreePoly(q);
return;
@@ -965,7 +960,9 @@ static void SolveTProblem(void)
I_FinishUpdate(); // page flip or blit buffer
#endif
#ifdef DEBUG_HWBSP
numsplitpoly = 0;
#endif
for (ssnum = 0; ssnum < num_extra_subsector; ssnum++)
{
@@ -1002,8 +999,8 @@ void HWR_CreatePlanePolygons(INT32 bspnum)
I_FinishUpdate(); // page flip or blit buffer
#endif
// reset the portal and horizonline flag
gl_maphasportals = gl_maphashorizonlines = false;
// reset the portal flag
gl_maphasportals = false;
// find min/max boundaries of map
#ifdef DEBUG_HWBSP
+285 -30
View File
@@ -16,6 +16,7 @@
#include <algorithm>
#include <vector>
#include "../d_main.h"
#include "../doomstat.h"
#include "../doomdef.h"
@@ -120,7 +121,7 @@ ps_metric_t ps_hw_batchdrawtime = {};
static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, boolean noencore, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor, FBITFIELD polyflags);
static void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap);
static 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);
static 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, subsector_t *subsector);
static void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 texnum, boolean noencore, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap);
static void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap);
@@ -204,7 +205,8 @@ static CV_PossibleValue_t glpalettedepth_cons_t[] = {{16, "16 bits"}, {24, "24 b
consvar_t cv_glscreentextures = {"gr_screentextures", "All", CV_CALL|CV_SAVE, glscreentextures_cons_t, CV_screentextures_OnChange, 0, NULL, NULL, 0, 0, NULL};
#ifdef USE_FBO_OGL
consvar_t cv_glframebuffer = {"gr_framebuffer", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, CV_glframebuffer_OnChange, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t glframebuffer_cons_t[] = {{0, "Off"}, {1, "Downsample"}, {2, "Always"}, {0, NULL}};
consvar_t cv_glframebuffer = {"gr_framebuffer", "Off", CV_SAVE|CV_CALL, glframebuffer_cons_t, CV_glframebuffer_OnChange, 0, NULL, NULL, 0, 0, NULL};
#endif
consvar_t cv_glmdls = {"gr_mdls", "Off", CV_SAVE|CV_CALL, CV_OnOff, M_UpdateOGLMenu, 0, NULL, NULL, 0, 0, NULL};
@@ -255,6 +257,7 @@ static void CV_screentextures_OnChange(void)
#endif
intermissionbginit = false;
}
GL_SetSpecialState(HWD_SET_SCREEN_TEXTURES, cv_glscreentextures.value);
M_UpdateOGLMenu();
}
@@ -263,12 +266,11 @@ static void CV_screentextures_OnChange(void)
static void CV_glframebuffer_OnChange(void)
{
ONLY_IF_GL_LOADED
if ((cv_glframebuffer.value != 0 && cv_glscreentextures.value != 2)
|| (!supportFBO && cv_glframebuffer.value != 0)) // screen FBO needs screen textures
CV_SetValue(&cv_glframebuffer, 0);
I_DownSample();
RefreshOGLSDLSurface();
// screen FBO needs screen textures currently
if (cv_glframebuffer.value != 0 && ((cv_glscreentextures.value != 2) || !supportFBO))
CV_StealthSetValue(&cv_glframebuffer, 0); // dont recursively call this lul
if (loaded_config) // dont do this crap on startup, this is handled elsewhere
I_CheckDownSampleState(true);
M_UpdateOGLMenu();
intermissionbginit = false;
}
@@ -721,7 +723,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, PolyFlags, shader, false);
if (gl_maphashorizonlines && subsector && !FOFsector && cv_glhorizonlines.value)
if (subsector && subsector->hashorizon && cv_glhorizonlines.value)
{
// Horizon lines
FOutVector horizonpts[6];
@@ -806,6 +808,268 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
#undef SETUP3DVERT
}
static void HWR_RenderFOFHorizonPlane(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 = {};
polyvertex_t *pv;
pslope_t *slope = NULL;
INT32 shader = SHADER_NONE;
size_t nrPlaneVerts;
INT32 i;
float height; // constant y for all points on the convex flat polygon
static float flatxref = 0.0f, flatyref = 0.0f;
static float fflatsize = 64.0f;
static INT32 flatflag = 63;
size_t len;
float tempxsow, tempytow;
float scrollx = 0.0f, scrolly = 0.0f;
float anglef = 0.0f, cosangf = 0.0f, sinangf = 0.0f;
angle_t angle = 0;
static FOutVector *planeVerts = NULL;
static UINT16 numAllocedPlaneVerts = 0;
poly_t *planepoly = xsub->planepoly;
if (!cv_glhorizonlines.value)
return;
if (!subsector || !subsector->hashorizon)
return;
// no convex poly were generated for this subsector
if (!planepoly)
return;
nrPlaneVerts = planepoly->numpts;
if (nrPlaneVerts < 3) // not even a triangle ?
return;
const sector_t *sec = FOFsector;
if (!(PolyFlags & PF_NoTexture))
{
HWR_GetFlat(lumpnum, R_NoEncore(FOFsector, !isceiling));
}
// Get the slope pointer to simplify future code
if (!isceiling && sec->f_slope)
slope = sec->f_slope;
else if (isceiling && sec->c_slope)
slope = sec->c_slope;
height = FixedToFloat(fixedheight);
// Allocate plane-vertex buffer if we need to
if (!planeVerts || nrPlaneVerts > numAllocedPlaneVerts)
{
numAllocedPlaneVerts = (UINT16)nrPlaneVerts;
Z_Free(planeVerts);
Z_Malloc(numAllocedPlaneVerts * sizeof (FOutVector), PU_LEVEL, &planeVerts);
}
len = W_LumpLength(lumpnum);
switch (len)
{
case 4194304: // 2048x2048 lump
fflatsize = 2048.0f;
flatflag = 2047;
break;
case 1048576: // 1024x1024 lump
fflatsize = 1024.0f;
flatflag = 1023;
break;
case 262144: // 512x512 lump
fflatsize = 512.0f;
flatflag = 511;
break;
case 65536: // 256x256 lump
fflatsize = 256.0f;
flatflag = 255;
break;
case 16384: // 128x128 lump
fflatsize = 128.0f;
flatflag = 127;
break;
case 1024: // 32x32 lump
fflatsize = 32.0f;
flatflag = 31;
break;
default: // 64x64 lump
fflatsize = 64.0f;
flatflag = 63;
break;
}
pv = planepoly->pts;
// reference point for flat texture coord for each vertex around the polygon
flatxref = static_cast<float>(static_cast<fixed_t>(pv->x) & (~flatflag)) / fflatsize;
flatyref = static_cast<float>(static_cast<fixed_t>(pv->y) & (~flatflag)) / fflatsize;
if (!isceiling) // it's a floor
{
scrollx = FixedToFloat(sec->floor_xoffs)/fflatsize;
scrolly = FixedToFloat(sec->floor_yoffs)/fflatsize;
angle = sec->floorpic_angle;
}
else // it's a ceiling
{
scrollx = FixedToFloat(sec->ceiling_xoffs)/fflatsize;
scrolly = FixedToFloat(sec->ceiling_yoffs)/fflatsize;
angle = sec->ceilingpic_angle;
}
if (angle) // Only needs to be done if there's an altered angle
{
// This needs to be done so that it scrolls in a different direction after rotation like software
tempxsow = flatxref;
tempytow = flatyref;
anglef = ANG2RAD(InvAngle(angle));
// This needs to be done so everything aligns after rotation
// It would be done so that rotation is done, THEN the translation, but I couldn't get it to rotate AND scroll like software does
cosangf = cosf(anglef);
sinangf = sinf(anglef);
flatxref = (tempxsow * cosangf) - (tempytow * sinangf);
flatyref = (tempxsow * sinangf) + (tempytow * cosangf);
}
#define SETUP3DVERT(vert, vx, vy) {\
/* Hurdler: add scrolling texture on floor/ceiling */\
vert->s = (float)(((vx) / fflatsize) - flatxref + scrollx);\
vert->t = (float)(flatyref - ((vy) / fflatsize) + scrolly);\
\
/* Need to rotate before translate */\
if (angle) /* Only needs to be done if there's an altered angle */\
{\
tempxsow = vert->s;\
tempytow = vert->t;\
vert->s = (tempxsow * cosangf) - (tempytow * sinangf);\
vert->t = (tempxsow * sinangf) + (tempytow * cosangf);\
}\
\
if (slope)\
{\
fixedheight = P_GetSlopeZAt(slope, FloatToFixed((vx)), FloatToFixed((vy)));\
height = FixedToFloat(fixedheight);\
}\
\
vert->x = (vx);\
vert->y = height;\
vert->z = (vy);\
\
}
HWR_Lighting(&Surf, lightlevel, planecolormap, false);
if (PolyFlags & (PF_Translucent|PF_Fog|PF_Additive|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative|PF_Environment))
{
Surf.PolyColor.s.alpha = (UINT8)alpha;
PolyFlags |= PF_Modulated;
}
else
PolyFlags |= PF_Masked|PF_Modulated;
if (HWR_UseShader())
{
if (PolyFlags & PF_Fog)
shader = SHADER_FOG;
else if (cv_ripplewater.value && (PolyFlags & PF_Ripple))
shader = SHADER_WATER;
else
shader = SHADER_FLOOR;
PolyFlags |= PF_ColorMapped;
}
// Horizon lines
FOutVector horizonpts[6];
float dist, vx, vy;
float x1, y1, xd, yd;
UINT8 numplanes, j;
vertex_t v; // For determining the closest distance from the line to the camera, to split render planes for minimum distortion;
static constexpr float renderdist = 27000.0f; // How far out to properly render the plane
static constexpr float farrenderdist = 32768.0f; // From here, raise plane to horizon level to fill in the line with some texture distortion
const seg_t *line = &segs[subsector->firstline];
for (i = 0; i < subsector->numlines; i++, line++)
{
if (line->polyseg)
continue;
line_t* ld = line->linedef;
if (LIKELY(ld->special != HORIZONSPECIAL))
continue;
if (R_PointOnSegSide(viewx, viewy, line) != 0)
continue;
P_ClosestPointOnLine(viewx, viewy, ld, &v);
dist = FixedToFloat(R_PointToDist(v.x, v.y));
x1 = (line->fv1.x);
y1 = (line->fv1.y);
xd = (line->fv2.x) - x1;
yd = (line->fv2.y) - y1;
// Based on the seg length and the distance from the line, split horizon into multiple poly sets to reduce distortion
dist = sqrtf((xd*xd) + (yd*yd)) / dist / 16.0f;
if (dist > 100.0f)
numplanes = 100;
else
numplanes = (UINT8)dist + 1;
for (j = 0; j < numplanes; j++)
{
// Left side
vx = x1 + xd * j / numplanes;
vy = y1 + yd * j / numplanes;
SETUP3DVERT((&horizonpts[1]), vx, vy);
dist = sqrtf(powf(vx - gl_viewx, 2) + powf(vy - gl_viewy, 2));
vx = (vx - gl_viewx) * renderdist / dist + gl_viewx;
vy = (vy - gl_viewy) * renderdist / dist + gl_viewy;
SETUP3DVERT((&horizonpts[0]), vx, vy);
// Right side
vx = x1 + xd * (j+1) / numplanes;
vy = y1 + yd * (j+1) / numplanes;
SETUP3DVERT((&horizonpts[2]), vx, vy);
dist = sqrtf(powf(vx - gl_viewx, 2) + powf(vy - gl_viewy, 2));
vx = (vx - gl_viewx) * renderdist / dist + gl_viewx;
vy = (vy - gl_viewy) * renderdist / dist + gl_viewy;
SETUP3DVERT((&horizonpts[3]), vx, vy);
// Horizon fills
vx = (horizonpts[0].x - gl_viewx) * farrenderdist / renderdist + gl_viewx;
vy = (horizonpts[0].z - gl_viewy) * farrenderdist / renderdist + gl_viewy;
SETUP3DVERT((&horizonpts[5]), vx, vy);
horizonpts[5].y = gl_viewz;
vx = (horizonpts[3].x - gl_viewx) * farrenderdist / renderdist + gl_viewx;
vy = (horizonpts[3].z - gl_viewy) * farrenderdist / renderdist + gl_viewy;
SETUP3DVERT((&horizonpts[4]), vx, vy);
horizonpts[4].y = gl_viewz;
// Draw
HWR_ProcessPolygon(&Surf, horizonpts, 6, PolyFlags, shader, true);
}
}
#undef SETUP3DVERT
}
#ifdef WALLSPLATS
static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf)
{
@@ -2960,16 +3224,14 @@ static void HWR_Subsector(size_t num)
UINT8 alpha;
light = R_GetPlaneLight(gl_frontsector, centerHeight, underside);
alpha = HWR_FogBlockAlpha(*gl_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap);
HWR_AddTransparentFloor(0,
&extrasubsectors[num],
!bottom,
roverheight,
*gl_frontsector->lightlist[light].lightlevel,
alpha, rover->master->frontsector, PF_Fog|PF_NoTexture,
true, rover->master->frontsector->extra_colormap);
true, rover->master->frontsector->extra_colormap, sub);
}
else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) // SoM: Flags are more efficient
{
@@ -2981,13 +3243,12 @@ static void HWR_Subsector(size_t num)
roverheight,
*gl_frontsector->lightlist[light].lightlevel,
CLAMP(rover->alpha, 0, 255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : static_cast<FBITFIELD>(PF_Translucent)),
false, gl_frontsector->lightlist[light].extra_colormap);
false, gl_frontsector->lightlist[light].extra_colormap, sub);
}
else
{
HWR_GetFlat(flatlump, R_NoEncore(rover->master->frontsector, bottom));
light = R_GetPlaneLight(gl_frontsector, centerHeight, underside);
HWR_RenderPlane(sub, &extrasubsectors[num], !bottom, roverheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, flatlump,
rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap);
}
@@ -3319,7 +3580,7 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t
// technically this_scale gets multiplied and added to sprite y/x scale, but this thing needs it for some crap so ill just throw it in here again
this_scale = FixedToFloat(spr->mobj->scale);
const skin_t *moskin = K_GetMobjSkin(spr->mobj);
const skin_t *moskin = R_GetMobjSkin(spr->mobj);
if (moskin && moskin->flags & SF_HIRES)
this_scale *= FixedToFloat(moskin->highresscale);
@@ -4191,7 +4452,7 @@ static void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, I
wallinfo->wallcolormap = wallcolormap;
}
static 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)
static 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, subsector_t *subsector)
{
planeinfo_t *planeinfo = static_cast<planeinfo_t*>(HWR_CreateDrawNode(DRAWNODE_PLANE));
@@ -4205,6 +4466,9 @@ static void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, b
planeinfo->blend = blend;
planeinfo->fogplane = fogplane;
planeinfo->planecolormap = planecolormap;
// horizonplanes need to be drawn BEFORE skywalls, so lets hope this works without too many issues....
HWR_RenderFOFHorizonPlane(subsector, planeinfo->xsub, planeinfo->isceiling, planeinfo->fixedheight, planeinfo->blend, planeinfo->lightlevel, planeinfo->lumpnum, planeinfo->FOFSector, (UINT8)planeinfo->alpha, planeinfo->planecolormap);
}
// Adding this for now until I can create extrasubsector info for polyobjects
@@ -4391,17 +4655,8 @@ static void HWR_DrawSprites(void)
{
if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY)
{
md2_t *md2;
if (spr->mobj->localskin)
{
if (spr->mobj->skinlocal)
md2 = &md2_localplayermodels[(skin_t *)spr->mobj->localskin - localskins];
else
md2 = &md2_playermodels [(skin_t *)spr->mobj->localskin - skins];
}
else
md2 = &md2_playermodels[(skin_t *)spr->mobj->skin - skins];
/* fuck you */
md2_t *md2 = &R_GetMobjSkin(spr->mobj)->playermodel;
// 8/1/19: Only don't display player models if no default SPR_PLAY is found.
if (((md2->notfound || md2->scale < 0.0f) && ((!cv_glfallbackplayermodel.value) || md2_models[SPR_PLAY].notfound || md2_models[SPR_PLAY].scale < 0.0f)) || spr->mobj->state == &states[S_PLAY_SIGN])
@@ -4623,7 +4878,7 @@ static void HWR_ProjectSprite(mobj_t *thing)
rot = (thing->frame & FF_FRAMEMASK);
sprskin = K_GetMobjSkin(thing);
sprskin = R_GetMobjSkin(thing);
//Fab : 02-08-98: 'skin' override spritedef currently used for skin
if (sprskin && thing->sprite == SPR_PLAY)
@@ -5899,7 +6154,7 @@ void HWR_Startup(void)
HWR_TogglePaletteRendering();
if (msaa)
GL_SetSpecialState(HWD_SET_MSAA, a2c ? 2 : 1);
GL_SetSpecialState(HWD_SET_MSAA, 1);
HWR_RegisterCommands();
}
@@ -5987,7 +6242,7 @@ void HWR_Shutdown(void)
GL_FlushScreenTextures();
HWR_ClearAllTextures();
#ifdef USE_FBO_OGL
GL_Framebuffer_Disable();
GL_FBO_Disable();
#endif
}
-2
View File
@@ -43,7 +43,6 @@ void HWR_Startup(void);
void HWR_Shutdown(void);
extern unsigned msaa;
extern boolean a2c;
extern FTransform atransform;
extern float gl_viewsin, gl_viewcos;
@@ -172,7 +171,6 @@ void HWR_ProcessSeg(void); // Sort of like GLWall::Process in GZDoom
// hw_bsp.c
void HWR_CreatePlanePolygons(INT32 bspnum);
extern boolean gl_maphasportals;
extern boolean gl_maphashorizonlines;
// Console variables
extern CV_PossibleValue_t glanisotropicmode_cons_t[];
+79 -77
View File
@@ -73,8 +73,6 @@
#endif
md2_t md2_models[NUMSPRITES] = {};
md2_t md2_playermodels[MAXSKINS] = {};
md2_t md2_localplayermodels[MAXLOCALSKINS] = {};
/*
* free model
@@ -421,6 +419,7 @@ static void md2_loadTexture(md2_t *model)
}
}
}
GL_SetTexture(glPatch->mipmap);
HWR_UnlockCachedPatch(glPatch);
}
@@ -478,6 +477,7 @@ static void md2_loadBlendTexture(md2_t *model)
glPatch->mipmap->width = (UINT16)w;
glPatch->mipmap->height = (UINT16)h;
}
GL_SetTexture(glPatch->mipmap); // We do need to do this so that it can be cleared and knows to recreate it when necessary
HWR_UnlockCachedPatch(glPatch);
@@ -487,6 +487,19 @@ static void md2_loadBlendTexture(md2_t *model)
// Don't spam the console, or the OS with fopen requests!
static boolean nomd2s = false;
// initializes an md2 model
static void HWR_InitModel(md2_t *md2)
{
md2->scale = -1.0f;
md2->model = NULL;
md2->glpatch = NULL;
md2->skinnum = -1;
md2->notexturefile = false;
md2->noblendfile = false;
md2->notfound = true;
md2->error = false;
}
void HWR_InitMD2(void)
{
size_t i;
@@ -496,38 +509,22 @@ void HWR_InitMD2(void)
float scale, offset;
CONS_Printf("InitMD2()...\n");
for (s = 0; s < MAXSKINS; s++)
for (s = 0; s < numskins; s++)
{
md2_playermodels[s].scale = -1.0f;
md2_playermodels[s].model = NULL;
md2_playermodels[s].glpatch = NULL;
md2_playermodels[s].skin = -1;
md2_playermodels[s].notexturefile = false;
md2_playermodels[s].noblendfile = false;
md2_playermodels[s].notfound = true;
md2_playermodels[s].error = false;
skin_t *skin = skins[s];
HWR_InitModel(&skin->playermodel);
}
for (s = 0; s < MAXLOCALSKINS; s++)
for (s = 0; s < numlocalskins; s++)
{
md2_localplayermodels[s].scale = -1.0f;
md2_localplayermodels[s].model = NULL;
md2_localplayermodels[s].glpatch = NULL;
md2_localplayermodels[s].skin = -1;
md2_localplayermodels[s].notexturefile = false;
md2_localplayermodels[s].noblendfile = false;
md2_localplayermodels[s].notfound = true;
md2_localplayermodels[s].error = false;
skin_t *skin = localskins[s];
HWR_InitModel(&skin->playermodel);
}
for (i = 0; i < NUMSPRITES; i++)
{
md2_models[i].scale = -1.0f;
md2_models[i].model = NULL;
md2_models[i].glpatch = NULL;
md2_models[i].skin = -1;
md2_models[s].notexturefile = false;
md2_models[s].noblendfile = false;
md2_models[i].notfound = true;
md2_models[i].error = false;
HWR_InitModel(&md2_models[i]);
}
// read the mdls.dat file
@@ -544,6 +541,7 @@ void HWR_InitMD2(void)
return;
}
}
while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4)
{
for (i = 0; i < NUMSPRITES; i++)
@@ -558,18 +556,21 @@ void HWR_InitMD2(void)
}
}
for (s = 0; s < MAXSKINS; s++)
for (s = 0; s < numskins; s++)
{
if (fasticmp(name, skins[s].name))
skin_t *skin = skins[s];
if (fasticmp(name, skin->name))
{
md2_playermodels[s].skin = s;
md2_playermodels[s].scale = scale;
md2_playermodels[s].offset = offset;
md2_playermodels[s].notfound = false;
strcpy(md2_playermodels[s].filename, filename);
skin->playermodel.skinnum = s;
skin->playermodel.scale = scale;
skin->playermodel.offset = offset;
skin->playermodel.notfound = false;
strcpy(skin->playermodel.filename, filename);
goto md2found;
}
}
// no sprite/player skin name found?!?D
CONS_Printf("Unknown sprite/player skin %s detected in mdls.dat\n", name);
md2found:
@@ -579,12 +580,16 @@ md2found:
fclose(f);
}
void HWR_AddPlayerMD2(INT32 skin, boolean local) // For MD2's that were added after startup
void HWR_AddPlayerMD2(INT32 skinnum, boolean local) // For MD2's that were added after startup
{
FILE *f;
char name[20], filename[32];
float scale, offset;
md2_t *md2s;
skin_t *skin = R_GetSkinArray(local)[skinnum];
// ensure we ALWAYS initialize the model even if no mdls.dat was found!
HWR_InitModel(&skin->playermodel);
if (nomd2s)
return;
@@ -598,6 +603,7 @@ void HWR_AddPlayerMD2(INT32 skin, boolean local) // For MD2's that were added af
if (!f)
{
f = fopen(va("%s"PATHSEP"%s", srb2path, "mdls.dat"), "rt");
if (!f)
{
CONS_Printf("%s %s\n", M_GetText("Error while loading mdls.dat:"), strerror(errno));
@@ -606,25 +612,25 @@ void HWR_AddPlayerMD2(INT32 skin, boolean local) // For MD2's that were added af
}
}
md2s = (local ? md2_localplayermodels : md2_playermodels);
// Check for any MD2s that match the names of player skins!
while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4)
{
if (fasticmp(name, K_GetSkinArray(local)[skin].name))
if (fasticmp(name, skin->name))
{
md2s[skin].skin = skin;
md2s[skin].scale = scale;
md2s[skin].offset = offset;
md2s[skin].notfound = false;
strcpy(md2s[skin].filename, filename);
skin->playermodel.skinnum = skinnum;
skin->playermodel.scale = scale;
skin->playermodel.offset = offset;
skin->playermodel.notfound = false;
strcpy(skin->playermodel.filename, filename);
goto playermd2found;
}
}
//CONS_Printf("MD2 for player skin %s not found\n", skins[skin].name);
md2s[skin].notfound = true;
//CONS_Printf("MD2 for player skin %s not found\n", skins[skinnum].name);
skin->playermodel.notfound = true;
playermd2found:
fclose(f);
}
@@ -674,6 +680,7 @@ void HWR_AddSpriteMD2(size_t spritenum) // For MD2s that were added after startu
//CONS_Printf("MD2 for sprite %s not found\n", sprnames[spritenum]);
md2_models[spritenum].notfound = true;
spritemd2found:
fclose(f);
}
@@ -1146,8 +1153,6 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
// Look at HWR_ProjectSprite for more
{
md2_t *md2s = NULL;
int skinnum = 0;
patch_t *gpatch, *blendgpatch;
GLPatch_t *hwrPatch = NULL, *hwrBlendPatch = NULL;
INT32 durs = spr->mobj->state->tics;
@@ -1207,36 +1212,29 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
// dont forget to enabled the depth test because we can't do this like
// before: polygons models are not sorted
/* fuck you */
if (spr->mobj->localskin)
{
if (spr->mobj->skinlocal)
{
md2s = md2_localplayermodels;
skinnum = (skin_t *)spr->mobj->localskin - localskins;
}
else
{
md2s = md2_playermodels;
skinnum = (skin_t *)spr->mobj->localskin - skins;
}
}
else if (spr->mobj->skin)
{
md2s = md2_playermodels;
skinnum = (skin_t *)spr->mobj->skin - skins;
}
// 1. load model+texture if not already loaded
// 2. draw model with correct position, rotation,...
if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY && !md2s[skinnum].notfound) // Use the player MD2 list if the mobj has a skin and is using the player sprites
// Use the player MD2 list if the mobj has a skin and is using the player sprites
if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY)
{
md2 = &md2s[skinnum];
md2->skin = skinnum;
sprinfo = &spriteinfo[spr->mobj->sprite];
/* fuck you */
md2_t *md2s = &R_GetMobjSkin(spr->mobj)->playermodel;
if (!md2s->notfound)
{
md2 = md2s;
md2->skinnum = R_GetMobjSkinNum(spr->mobj);
sprinfo = &spriteinfo[spr->mobj->sprite];
}
else // if we can't find the player md2, use SPR_PLAY's MD2.
{
md2 = &md2_models[spr->mobj->sprite];
sprinfo = &spriteinfo[spr->mobj->sprite];
}
}
else
{ // if we can't find the player md2, use SPR_PLAY's MD2.
{
md2 = &md2_models[spr->mobj->sprite];
sprinfo = &spriteinfo[spr->mobj->sprite];
}
@@ -1299,6 +1297,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
&& gpatch->width == blendgpatch->width && gpatch->height == blendgpatch->height)
{
INT32 tcskinnum = TC_DEFAULT;
if ((spr->mobj->flags & MF_BOSS) && (spr->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash"
{
if (spr->mobj->type == MT_CYBRAKDEMON)
@@ -1313,13 +1312,16 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY)
{
if (spr->mobj->colorized)
{
tcskinnum = TC_RAINBOW;
}
else
{
tcskinnum = (INT32)(K_GetMobjSkinNum(K_GetMobjSkin(spr->mobj), spr->mobj->skinlocal));
tcskinnum = (INT32)R_GetMobjSkinNum(spr->mobj);
}
}
else tcskinnum = TC_DEFAULT;
else
tcskinnum = TC_DEFAULT;
}
HWR_GetBlendedTexture(gpatch, blendgpatch, tcskinnum, spr->colormap, (skincolors_t)spr->mobj->color);
@@ -1383,7 +1385,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
p.z = FIXED_TO_FLOAT(interp.z);
if ((spr->mobj->skin || spr->mobj->localskin) && spr->mobj->sprite == SPR_PLAY)
sprdef = &K_GetMobjSkin(spr->mobj)->spritedef;
sprdef = &R_GetMobjSkin(spr->mobj)->spritedef;
else
sprdef = &sprites[spr->mobj->sprite];
+1 -3
View File
@@ -33,13 +33,11 @@ typedef struct
void *blendglpatch;
boolean noblendfile; // true if blend texture file was not found
boolean notfound;
INT32 skin;
INT32 skinnum;
boolean error;
} md2_t;
extern md2_t md2_models[NUMSPRITES];
extern md2_t md2_playermodels[MAXSKINS];
extern md2_t md2_localplayermodels[MAXLOCALSKINS];
void HWR_InitMD2(void);
void HWR_DrawMD2(gl_vissprite_t *spr);
-20
View File
@@ -193,26 +193,6 @@
"}\n" \
"#endif\0"
#define GLSL_SOFTWARE_FRAGMENT_SHADER_NOPAL \
"uniform sampler2D tex;\n" \
"uniform vec4 poly_color;\n" \
"uniform vec4 tint_color;\n" \
"uniform vec4 fade_color;\n" \
"uniform float lighting;\n" \
"uniform float fade_start;\n" \
"uniform float fade_end;\n" \
GLSL_DOOM_COLORMAP \
GLSL_DOOM_LIGHT_EQUATION \
"void main(void) {\n" \
"vec4 texel = texture2D(tex, gl_TexCoord[0].st);\n" \
"vec4 base_color = texel * poly_color;\n" \
"vec4 final_color = base_color;\n" \
GLSL_SOFTWARE_TINT_EQUATION \
GLSL_SOFTWARE_FADE_EQUATION \
"final_color.a = texel.a * poly_color.a;\n" \
"gl_FragColor = final_color;\n" \
"}\n" \
// hand tuned adjustments for light level calculation
#define GLSL_FLOOR_FUDGES \
"#define STARTMAP_FUDGE 1.06\n" \
+282 -75
View File
@@ -136,32 +136,61 @@ enum
{
FBO_NONE,
FBO_ARB,
FBO_EXT,
FBO_EXT_STENCIL // supports stencil attachment
FBO_EXT
};
typedef struct
{
GLuint fboobj; // actual Framebuffer Object
GLuint rboobj; // Renderbuffer Object
GLuint tex; // Framebuffer texture
GLuint fboobj; // normal single sample fbo
GLuint rboobj; // normal single sample rbo for depth and stencil stuff
GLuint tex; // fbo texture for color
GLuint msaa_fboobj; // msaa fbo
GLuint msaa_rboobj; // msaa rbo for color this time
GLuint msaa_depthrboobj; // msaa rbo for depth and stencil stuff
boolean init;
boolean msaa; // true if the msaa fbo is the render target ugh
boolean bound; // true if the fbo is currently bound as the framebuffer
} fboobj_t;
// this is a little messy but less messy than having two of those tbh
static fboobj_t framebufferobject = {};
int supportFBO = FBO_NONE;
// older gl versions might not have these, so prevent compile errors
// this should still give a simple depth only rbo
#ifndef GL_DEPTH_COMPONENT
#define GL_DEPTH_COMPONENT 0x1902
#endif
#ifndef GL_DEPTH_ATTACHMENT_EXT
#define GL_DEPTH_ATTACHMENT_EXT 0x8D00
#endif
#ifndef GL_DEPTH24_STENCIL8
GL_DEPTH24_STENCIL8 GL_DEPTH_COMPONENT_EXT
#define GL_DEPTH24_STENCIL8 0x88F0
#endif
#ifndef GL_DEPTH_STENCIL_ATTACHMENT
GL_DEPTH_STENCIL_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT
#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
#endif
#ifndef GL_COLOR_ATTACHMENT0_EXT
#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
#endif
#ifndef GL_READ_FRAMEBUFFER_EXT
#define GL_READ_FRAMEBUFFER_EXT 0x8CA8
#endif
#ifndef GL_DRAW_FRAMEBUFFER_EXT
#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9
#endif
#ifndef GL_FRAMEBUFFER_EXT
#define GL_FRAMEBUFFER_EXT 0x8D40
#endif
#ifndef GL_RENDERBUFFER_EXT
#define GL_RENDERBUFFER_EXT 0x8D41
#endif
#ifndef GL_FRAMEBUFFER_COMPLETE_EXT
#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5
#endif
static void GL_Framebuffer_DeleteAttachments(void);
static void GL_FBO_DeleteAttachments(void);
static void GL_FBO_Resolve(GLbitfield mask);
#endif
// needed for glportals
@@ -479,6 +508,10 @@ typedef void (APIENTRY * PFNglRenderbufferStorage) (GLenum target, GLenum intern
static PFNglRenderbufferStorage pglRenderbufferStorage;
typedef void (APIENTRY * PFNglFramebufferRenderbuffer) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLenum renderbuffer);
static PFNglFramebufferRenderbuffer pglFramebufferRenderbuffer;
typedef void (APIENTRY * PFNglRenderbufferStorageMultisample) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
static PFNglRenderbufferStorageMultisample pglRenderbufferStorageMultisample;
typedef void (APIENTRY * PFNglBlitFramebuffer) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
static PFNglBlitFramebuffer pglBlitFramebuffer;
/* 2.1 extension functions for framebuffers and renderbuffers */
typedef void (APIENTRY * PFNglGenFramebuffersEXT) (GLsizei n, GLuint *ids);
@@ -769,28 +802,22 @@ static GLRGBAFloat shader_defaultcolor = {1.0f, 1.0f, 1.0f, 1.0f};
#ifdef USE_FBO_OGL
static int GLFramebuffer_CheckExt(void)
{
// in opengl 3.0 and up fbos are standart and always supported
if (majorGL >= 3)
return FBO_ARB;
// gl versions from 2.1 may still support framebuffer objects
// maybe, just maybe, we support the standart extensions
// check for the standard arb extensions
// these should be there from version 3.0 onwards
if (GL_isExtAvailable("GL_ARB_framebuffer_no_attachments", gl_extensions) &&
GL_isExtAvailable("GL_ARB_framebuffer_object", gl_extensions) &&
GL_isExtAvailable("GL_ARB_framebuffer_sRGB", gl_extensions))
{
return FBO_ARB;
}
// nope, try the older 2.1 extensions
// gl versions from 2.1 and older may still support framebuffer objects
// depending on vendor and driver support
if (GL_isExtAvailable("GL_EXT_framebuffer_no_attachments", gl_extensions) &&
GL_isExtAvailable("GL_EXT_framebuffer_object", gl_extensions) &&
GL_isExtAvailable("GL_EXT_framebuffer_sRGB", gl_extensions))
GL_isExtAvailable("GL_EXT_framebuffer_sRGB", gl_extensions) &&
GL_isExtAvailable("GL_EXT_packed_depth_stencil", gl_extensions)) // we use the stencil buffer for stuff like portals, so its better to make stencil extension a requirement
{
// perhaps we may even support a stencil attachment
if (GL_isExtAvailable("GL_EXT_packed_depth_stencil", gl_extensions))
return FBO_EXT_STENCIL;
// no stencil support, sad
return FBO_EXT;
}
@@ -906,38 +933,69 @@ void SetupGLFunc4(void)
GetGLfunc(glRenderbufferStorage);
GetGLfunc(glFramebufferRenderbuffer);
// multisample support, this should be in core per gl 3.0 and newer
pglRenderbufferStorageMultisample = GetGLFunc("glRenderbufferStorageMultisample");
pglBlitFramebuffer = GetGLFunc("glBlitFramebuffer");
if (!pglRenderbufferStorageMultisample || !pglBlitFramebuffer)
{
pglRenderbufferStorageMultisample = NULL;
pglBlitFramebuffer = NULL;
GL_DBG_Printf("\nFBO: No multisample support\n");
}
GL_DBG_Printf("\nFBO: ARB extensions found\n");
}
else if (fbocheck == FBO_EXT || fbocheck == FBO_EXT_STENCIL) // uh oh only support for EXT prefix fbos...
else if (fbocheck == FBO_EXT) // uh oh only support old fbo extensions...
{
GetGLfunc(glGenFramebuffersEXT);
GetGLfunc(glBindFramebufferEXT);
GetGLfunc(glDeleteFramebuffersEXT);
GetGLfunc(glFramebufferTexture2DEXT);
GetGLfunc(glCheckFramebufferStatusEXT);
GetGLfunc(glGenRenderbuffersEXT);
GetGLfunc(glBindRenderbufferEXT);
GetGLfunc(glDeleteRenderbuffersEXT);
GetGLfunc(glRenderbufferStorageEXT);
GetGLfunc(glFramebufferRenderbufferEXT);
// remapping galore huehue
// do this so we dont have to dupe half our code
GetGLfunc(glGenFramebuffersEXT);
pglGenFramebuffers = pglGenFramebuffersEXT;
GetGLfunc(glBindFramebufferEXT);
pglBindFramebuffer = pglBindFramebufferEXT;
GetGLfunc(glDeleteFramebuffersEXT);
pglDeleteFramebuffers = pglDeleteFramebuffersEXT;
GetGLfunc(glFramebufferTexture2DEXT);
pglFramebufferTexture2D = pglFramebufferTexture2DEXT;
GetGLfunc(glCheckFramebufferStatusEXT);
pglCheckFramebufferStatus = pglCheckFramebufferStatusEXT;
GetGLfunc(glGenRenderbuffersEXT);
pglGenRenderbuffers = pglGenRenderbuffersEXT;
GetGLfunc(glBindRenderbufferEXT);
pglBindRenderbuffer = pglBindRenderbufferEXT;
GetGLfunc(glDeleteRenderbuffersEXT);
pglDeleteRenderbuffers = pglDeleteRenderbuffersEXT;
GetGLfunc(glRenderbufferStorageEXT);
pglRenderbufferStorage = pglRenderbufferStorageEXT;
GetGLfunc(glFramebufferRenderbufferEXT);
pglFramebufferRenderbuffer = pglFramebufferRenderbufferEXT;
if (fbocheck == FBO_EXT)
GL_DBG_Printf("\nFBO: EXT extensions found, no stencil\n");
else if (fbocheck == FBO_EXT_STENCIL)
GL_DBG_Printf("\nFBO: EXT extensions with packed depth-stencil\n");
// multisample support needs the EXT multisample and blit extensions
if (GL_isExtAvailable("GL_EXT_framebuffer_multisample", gl_extensions) &&
GL_isExtAvailable("GL_EXT_framebuffer_blit", gl_extensions))
{
pglRenderbufferStorageMultisample = GetGLFunc("glRenderbufferStorageMultisampleEXT");
pglBlitFramebuffer = GetGLFunc("glBlitFramebufferEXT");
}
if (!pglRenderbufferStorageMultisample || !pglBlitFramebuffer)
{
pglRenderbufferStorageMultisample = NULL;
pglBlitFramebuffer = NULL;
GL_DBG_Printf("\nFBO: No multisample support\n");
}
GL_DBG_Printf("\nFBO: EXT extensions with packed depth-stencil\n");
}
supportFBO = fbocheck;
@@ -1151,7 +1209,7 @@ void GL_SetModelView(GLint w, GLint h)
GL_FlushScreenTextures();
#ifdef USE_FBO_OGL
GL_Framebuffer_DeleteAttachments();
GL_FBO_DeleteAttachments();
#endif
}
@@ -1457,6 +1515,15 @@ void GL_ReadScreenTexture(int tex, UINT8 *restrict dest, INT32 scale)
const INT32 stride = (screen_width/scale)*3;
INT32 scanlines = screen_height;
GLubyte * restrict image;
#ifdef USE_FBO_OGL
const boolean msaa_fbo = (framebufferobject.bound && framebufferobject.msaa);
#endif
#ifdef USE_FBO_OGL
// cant read from the msaa fbo, so gotta blit it first into either the single sample fbo or the screen framebuffer....
if (msaa_fbo)
GL_FBO_Resolve(GL_COLOR_BUFFER_BIT);
#endif
// at the time this function is called, generic2 can be found drawn on the framebuffer
// if some other screen texture is needed, draw it to the framebuffer
@@ -1498,9 +1565,16 @@ void GL_ReadScreenTexture(int tex, UINT8 *restrict dest, INT32 scale)
memcpy(dest + i, image + i*scale, 3);
dest += stride;
}
// this probably could be done with fbos, might mess around with that some time :3
// ...yet still, restrict doesn't make the inner loop any faster
free(image - ((screen_height % scale) * screen_width*3));
#ifdef USE_FBO_OGL
// this´ll reenable the msaa fbo....
if (msaa_fbo)
GL_FBO_Enable();
#endif
}
// -----------------+
@@ -2254,7 +2328,7 @@ static void GL_Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRG
UNIFORM_1(shader->uniforms[gluniform_leveltime], shader_leveltime, pglUniform1f);
UNIFORM_2(shader->uniforms[gluniform_scr_resolution], (GLfloat)vid.width, (GLfloat)vid.height, pglUniform2f);
UNIFORM_2(shader->uniforms[gluniform_scr_resolution], (GLfloat)screen_width, (GLfloat)screen_height, pglUniform2f);
#undef UNIFORM_1
#undef UNIFORM_2
@@ -2641,11 +2715,7 @@ void GL_SetSpecialState(hwdspecialstate_t IdState, INT32 Value)
case HWD_SET_MSAA:
if (Value)
{
pglEnable(GL_MULTISAMPLE);
if (Value == 2)
pglEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
}
break;
case HWD_SET_TEXTUREANISOTROPICMODE:
@@ -3246,9 +3316,9 @@ void GL_SetTransform(FTransform *stransform)
}
#ifdef USE_FBO_OGL
static void GL_Framebuffer_DeleteAttachments(void)
static void GL_FBO_DeleteAttachments(void)
{
if (supportFBO == FBO_NONE || !framebufferobject.init)
if (supportFBO == FBO_NONE)
return;
// Unbind the framebuffer
@@ -3261,14 +3331,45 @@ static void GL_Framebuffer_DeleteAttachments(void)
if (framebufferobject.rboobj)
pglDeleteRenderbuffers(1, &framebufferobject.rboobj);
if (framebufferobject.msaa_rboobj)
pglDeleteRenderbuffers(1, &framebufferobject.msaa_rboobj);
if (framebufferobject.msaa_depthrboobj)
pglDeleteRenderbuffers(1, &framebufferobject.msaa_depthrboobj);
framebufferobject.tex = 0;
framebufferobject.rboobj = 0;
framebufferobject.msaa_rboobj = 0;
framebufferobject.msaa_depthrboobj = 0;
framebufferobject.init = false;
framebufferobject.bound = false;
}
static void GL_Framebuffer_Generate(void)
// blit the msaa fbo into the normal single sample fbo
// so we can use it to copy from and stuff
static void GL_FBO_Resolve(GLbitfield mask)
{
if (supportFBO == FBO_NONE || framebufferobject.init || !UseScreenFBO())
if (supportFBO == FBO_NONE || !framebufferobject.init || !framebufferobject.msaa)
return;
if (!pglBlitFramebuffer)
return;
pglBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, framebufferobject.msaa_fboobj);
pglBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, framebufferobject.fboobj);
pglBlitFramebuffer(0, 0, screen_width, screen_height,
0, 0, screen_width, screen_height,
mask, GL_NEAREST);
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, framebufferobject.fboobj);
}
static void GL_FBO_Generate(void)
{
GLint msaasamples;
if (supportFBO == FBO_NONE || framebufferobject.init)
return;
// Generate the framebuffer
@@ -3283,7 +3384,7 @@ static void GL_Framebuffer_Generate(void)
{
pglGenTextures(1, &framebufferobject.tex);
pglBindTexture(GL_TEXTURE_2D, framebufferobject.tex);
pglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, screen_width, screen_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
pglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, screen_width, screen_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
Clamp2D(GL_TEXTURE_WRAP_S);
@@ -3306,18 +3407,13 @@ static void GL_Framebuffer_Generate(void)
pglRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8, screen_width, screen_height);
pglFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER_EXT, framebufferobject.rboobj);
}
else if (supportFBO == FBO_EXT || supportFBO == FBO_EXT_STENCIL)
else if (supportFBO == FBO_EXT)
{
pglRenderbufferStorage(GL_RENDERBUFFER_EXT, (supportFBO == FBO_EXT_STENCIL) ? GL_DEPTH_STENCIL_EXT : GL_DEPTH_COMPONENT, screen_width, screen_height);
// attach a renderbuffer to depth attachment point
pglRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_DEPTH_STENCIL_EXT, screen_width, screen_height);
// attach the renderbuffer to depth attachment point
pglFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, framebufferobject.rboobj);
if (supportFBO == FBO_EXT_STENCIL)
{
// attach a renderbuffer to stencil attachment point
pglFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, framebufferobject.rboobj);
}
// attach the renderbuffer to stencil attachment point
pglFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, framebufferobject.rboobj);
}
// Clear the renderbuffer
@@ -3329,48 +3425,124 @@ static void GL_Framebuffer_Generate(void)
if (pglCheckFramebufferStatus(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT)
{
//pglGetError(); TODO:implement this or smth
GL_MSG_Error("GL_Framebuffer_Generate: Failed to create Framebuffer Object");
GL_MSG_Error("GL_FBO_Generate: Failed to create Framebuffer Object");
// if this fails, dont retry it a gazillion times
// this wouldnt recover
// this probably wouldnt recover and we dont want any more black screens...
supportFBO = FBO_NONE;
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
return;
}
// Try to set up a multisampled render target for MSAA
framebufferobject.msaa = false;
msaasamples = (GLint)msaa;
// maybe should just make more "supportFBO" cases or smth but :chaosleep:
if (msaasamples > 1 && pglRenderbufferStorageMultisample && pglBlitFramebuffer)
{
if (!framebufferobject.msaa_fboobj)
pglGenFramebuffers(1, &framebufferobject.msaa_fboobj);
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, framebufferobject.msaa_fboobj);
// Generate the multisampled color renderbuffer
if (!framebufferobject.msaa_rboobj)
{
pglGenRenderbuffers(1, &framebufferobject.msaa_rboobj);
pglBindRenderbuffer(GL_RENDERBUFFER_EXT, framebufferobject.msaa_rboobj);
pglRenderbufferStorageMultisample(GL_RENDERBUFFER_EXT, msaasamples, GL_RGBA8, screen_width, screen_height);
pglFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, framebufferobject.msaa_rboobj);
}
// Generate the multisampled depth/stencil renderbuffer
if (!framebufferobject.msaa_depthrboobj)
{
pglGenRenderbuffers(1, &framebufferobject.msaa_depthrboobj);
pglBindRenderbuffer(GL_RENDERBUFFER_EXT, framebufferobject.msaa_depthrboobj);
if (supportFBO == FBO_ARB)
{
pglRenderbufferStorageMultisample(GL_RENDERBUFFER_EXT, msaasamples, GL_DEPTH24_STENCIL8, screen_width, screen_height);
pglFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER_EXT, framebufferobject.msaa_depthrboobj);
}
else if (supportFBO == FBO_EXT)
{
pglRenderbufferStorageMultisample(GL_RENDERBUFFER_EXT, msaasamples, GL_DEPTH_STENCIL_EXT, screen_width, screen_height);
// attach a renderbuffer to depth attachment point
pglFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, framebufferobject.msaa_depthrboobj);
// attach a renderbuffer to stencil attachment point
pglFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, framebufferobject.msaa_depthrboobj);
}
}
pglBindRenderbuffer(GL_RENDERBUFFER_EXT, 0);
if (pglCheckFramebufferStatus(GL_FRAMEBUFFER_EXT) == GL_FRAMEBUFFER_COMPLETE_EXT)
{
framebufferobject.msaa = true;
GL_ClearBuffer(true, true, true, NULL);
GL_DBG_Printf("\nGL_FBO_Generate: Multisampled framebuffer created with %d samples\n", msaasamples);
}
else
{
GL_MSG_Warning("GL_FBO_Generate: Failed to create multisampled Framebuffer Object, falling back to no MSAA");
if (framebufferobject.msaa_rboobj)
pglDeleteRenderbuffers(1, &framebufferobject.msaa_rboobj);
if (framebufferobject.msaa_depthrboobj)
pglDeleteRenderbuffers(1, &framebufferobject.msaa_depthrboobj);
framebufferobject.msaa_rboobj = 0;
framebufferobject.msaa_depthrboobj = 0;
}
}
// Unbind the framebuffer
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
framebufferobject.init = true;
}
void GL_Framebuffer_Unbind(void)
void GL_FBO_BindMainFrameBuffer(void)
{
if (supportFBO == FBO_NONE || !framebufferobject.init)
if (supportFBO == FBO_NONE)
return;
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
pglBindRenderbuffer(GL_RENDERBUFFER_EXT, 0);
framebufferobject.bound = false;
}
void GL_Framebuffer_Enable(void)
void GL_FBO_Enable(void)
{
if (supportFBO == FBO_NONE || !UseScreenFBO())
if (supportFBO == FBO_NONE)
return;
GL_Framebuffer_Generate();
GL_FBO_Generate();
// failed
if (supportFBO == FBO_NONE || !framebufferobject.init)
if (!framebufferobject.init)
return;
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, framebufferobject.fboobj);
pglBindRenderbuffer(GL_RENDERBUFFER_EXT, framebufferobject.rboobj);
if (framebufferobject.msaa)
{
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, framebufferobject.msaa_fboobj);
pglBindRenderbuffer(GL_RENDERBUFFER_EXT, framebufferobject.msaa_rboobj);
}
else
{
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, framebufferobject.fboobj);
pglBindRenderbuffer(GL_RENDERBUFFER_EXT, framebufferobject.rboobj);
}
framebufferobject.bound = true;
}
void GL_Framebuffer_Disable(void)
void GL_FBO_Disable(void)
{
if (supportFBO == FBO_NONE || !framebufferobject.init)
if (supportFBO == FBO_NONE)
return;
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
@@ -3381,7 +3553,14 @@ void GL_Framebuffer_Disable(void)
pglDeleteFramebuffers(1, &framebufferobject.fboobj);
framebufferobject.fboobj = 0;
GL_Framebuffer_DeleteAttachments();
if (framebufferobject.msaa_fboobj)
pglDeleteFramebuffers(1, &framebufferobject.msaa_fboobj);
framebufferobject.msaa_fboobj = 0;
GL_FBO_DeleteAttachments();
framebufferobject.msaa = false;
framebufferobject.bound = false;
}
#endif
@@ -3732,10 +3911,20 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8
void GL_MakeScreenTexture(int tex)
{
boolean firstTime;
static GLint lastfiltermode[NUMSCREENTEXTURES] = {-1, -1, -1, -1, -1};
#ifdef USE_FBO_OGL
const boolean msaa_fbo = (framebufferobject.bound && framebufferobject.msaa);
#endif
if (!gl_enable_screen_textures)
return;
#ifdef USE_FBO_OGL
// cant read from the msaa fbo, so gotta blit it first into either the single sample fbo or the screen framebuffer....
if (msaa_fbo)
GL_FBO_Resolve(GL_COLOR_BUFFER_BIT);
#endif
firstTime = (screenTextures[tex] == 0);
// Create screen texture
@@ -3744,18 +3933,36 @@ void GL_MakeScreenTexture(int tex)
pglBindTexture(GL_TEXTURE_2D, screenTextures[tex]);
// if were downsampling, choose to do that with linear filter instead of nearest neighbor
// otherwise well get ugly mixels
GLint filtermode = I_IsDownsampling() ? GL_LINEAR : GL_NEAREST;
// avoid redundant calls to this, prob doesent really matter tbh
if (filtermode != lastfiltermode[tex] || firstTime)
{
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtermode);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtermode);
lastfiltermode[tex] = filtermode;
}
if (firstTime)
{
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
Clamp2D(GL_TEXTURE_WRAP_S);
Clamp2D(GL_TEXTURE_WRAP_T);
pglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, screen_texsizew, screen_texsizeh, 0);
}
else
{
pglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, screen_texsizew, screen_texsizeh);
}
tex_downloaded = screenTextures[tex];
#ifdef USE_FBO_OGL
if (msaa_fbo)
GL_FBO_Enable();
#endif
}
void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height)
+3 -3
View File
@@ -98,9 +98,9 @@ extern PFNglGetString pglGetString;
#endif
#ifdef USE_FBO_OGL
void GL_Framebuffer_Unbind(void);
void GL_Framebuffer_Enable(void);
void GL_Framebuffer_Disable(void);
void GL_FBO_BindMainFrameBuffer(void);
void GL_FBO_Enable(void);
void GL_FBO_Disable(void);
extern int supportFBO;
#endif
+4 -1
View File
@@ -2654,9 +2654,12 @@ static inline void HU_DrawSpectatorTicker(void)
if (player->mo && player->mo->color)
{
const UINT8 *colormap = R_GetTranslationColormap(player->skin, player->mo->color, GTC_CACHE);
const UINT8 *colormap = NULL;
if (player->mo->colorized)
colormap = R_GetTranslationColormap(TC_RAINBOW, player->mo->color, GTC_CACHE);
else
colormap = R_GetTranslationColormap(player->skin, player->mo->color, GTC_CACHE);
if (K_UseHighResPortraits())
V_DrawSmallMappedPatch((templength - duptweak), height+10, V_TRANSLUCENT, R_GetSkinFaceWant(player), colormap);
+2 -7
View File
@@ -118,19 +118,14 @@ void I_UpdateNoVsync(void);
*/
void I_ReadScreen(UINT8 * restrict scr, INT32 scale);
UINT32 I_GetRefreshRate(void);
boolean I_CheckNativeRes(void);
void I_SetBorderlessWindow(void);
#ifdef USE_FBO_OGL
void RefreshOGLSDLSurface(void);
void I_DownSample(void);
void I_CheckDownSampleState(boolean forcerefresh);
boolean I_IsDownsampling(void);
boolean UseScreenFBO(void);
extern boolean downsample;
#endif
// So we can call this from i_video event loop
+8 -10
View File
@@ -1221,10 +1221,8 @@ boolean K_UseHighResPortraits(void)
// accounts for localskins
patch_t *K_GetFacePrefix(player_t *player, INT32 skinnum)
{
if (!player->skinlocal)
return (K_UseHighResPortraits() ? facewantprefix[skinnum] : facerankprefix[skinnum]);
else
return (K_UseHighResPortraits() ? localfacewantprefix[skinnum] : localfacerankprefix[skinnum]);
const skin_t *skin = R_GetSkinArray(player->skinlocal)[skinnum];
return (K_UseHighResPortraits() ? skin->facewantprefix : skin->facerankprefix);
}
INT32 K_calcSplitFlags(INT32 snapflags)
@@ -1426,7 +1424,7 @@ static void K_drawKartStats(void)
flags |= V_HUDTRANS;
flags2 = flags|V_ALLOWLOWERCASE|V_SkinColorToHighlightcolor(stplyr->skincolor);
fakeskin = K_GetPlayerSkin(stplyr);
fakeskin = R_GetPlayerSkin(stplyr);
// Skin name
if (cv_showstats_skinname.value)
@@ -3109,7 +3107,7 @@ static void K_drawNameTags(void)
cm = R_GetTranslationColormap(players[i].skin, players[i].mo->color, GTC_CACHE);
tagcolor = colortranslations[players[i].mo->color][7];
vflags = trans | V_NOSCALESTART;
usenametagrestat = ((cv_nametagrestat.value == 1 && (players[i].kartspeed != skins[players[i].skin].kartspeed || players[i].kartweight != skins[players[i].skin].kartweight)) || cv_nametagrestat.value == 2);
usenametagrestat = ((cv_nametagrestat.value == 1 && (players[i].kartspeed != skins[players[i].skin]->kartspeed || players[i].kartweight != skins[players[i].skin]->kartweight)) || cv_nametagrestat.value == 2);
tagwidthsmall = cv_smallnametags.value ? V_SmallStringWidth(player_names[i], V_ALLOWLOWERCASE) : V_ThinStringWidth(player_names[i], V_ALLOWLOWERCASE);
tagwidth = vid.dup*tagwidthsmall;
@@ -3594,12 +3592,12 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags)
INT32 rot = 0;
#endif
skin = K_GetMobjSkin(mo);
skin = R_GetMobjSkin(mo);
if (!skin)
return;
minimaphead = (skinlocal ? localfacemmapprefix : facemmapprefix)[K_GetMobjSkinNum(skin, skinlocal)];
minimaphead = skin->facemmapprefix;
if (minimaphead == NULL)
return;
@@ -3830,7 +3828,7 @@ static void K_drawKartMinimap(void)
else
{
// special case if startcolor is not the default (160 / Green)
if (K_GetMobjSkin(mobj)->starttranscolor != skins[0].starttranscolor)
if (R_GetMobjSkin(mobj)->starttranscolor != skins[0]->starttranscolor)
{
colormap = R_GetTranslationColormap(TC_DEFAULT, mobj->color, GTC_CACHE);
}
@@ -4905,7 +4903,7 @@ void K_drawKartHUD(void)
for (c = 1; c < MAXSKINCOLORS; c++)
{
UINT8 *cm = R_GetTranslationColormap(TC_RAINBOW, c, GTC_CACHE);
V_DrawFixedPatch(x<<FRACBITS, y<<FRACBITS, FRACUNIT>>1, 0, facewantprefix[stplyr->skin], cm);
V_DrawFixedPatch(x<<FRACBITS, y<<FRACBITS, FRACUNIT>>1, 0, skins[stplyr->skin]->facewantprefix, cm);
x += 16;
if (x > BASEVIDWIDTH-16)
+2
View File
@@ -78,6 +78,8 @@ INT32 K_getMinimapTrans(void);
void K_getLapsDrawinfo(drawinfo_t *out);
void K_getMinimapDrawinfo(drawinfo_t *out);
patch_t *K_GetFacePrefix(player_t *player, INT32 skinnum);
#ifdef __cplusplus
} // extern "C"
#endif
+2 -56
View File
@@ -592,7 +592,7 @@ void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color, bo
if (color >= MAXTRANSLATIONS)
I_Error("Invalid skin color #%hu.", (UINT16)color);
starttranscolor = (skinnum != TC_DEFAULT) ? K_GetSkinArray(local)[skinnum].starttranscolor : DEFAULT_STARTTRANSCOLOR;
starttranscolor = (skinnum != TC_DEFAULT) ? R_GetSkinArray(local)[skinnum]->starttranscolor : DEFAULT_STARTTRANSCOLOR;
if (starttranscolor >= NUM_PALETTE_ENTRIES)
I_Error("Invalid startcolor #%d.", starttranscolor);
@@ -632,60 +632,6 @@ UINT8 K_GetKartColorByName(const char *name)
return 0;
}
//
// returns the players skinnumber
// accounts for localskins
//
INT32 K_GetSkinNum(player_t *player)
{
return player->localskin ? (player->localskin - 1) : player->skin;
}
//
// returns the mobj skinnumber
// accounts for localskins ?
//
INT32 K_GetMobjSkinNum(const skin_t *skin, boolean local)
{
return skin - K_GetSkinArray(local);
}
//
// returns the mobj skinnumber
// accounts for localskins
//
INT32 K_GetMobjLocalSkinNum(const skin_t *skin, const skin_t *localskin, boolean local)
{
return localskin ? (localskin - K_GetSkinArray(local)) : (skin - skins);
}
//
// returns the players skinnumber
// accounts for localskins
//
skin_t *K_GetMobjSkin(const mobj_t *mobj)
{
return mobj->localskin ? mobj->localskin : mobj->skin;
}
//
// returns the skin array to use
// accounts for localskins
//
skin_t *K_GetSkinArray(boolean local)
{
return local ? localskins : skins;
}
//
// returns the players skin
// accounts for localskins
//
skin_t *K_GetPlayerSkin(player_t *player)
{
return &K_GetSkinArray(player->skinlocal)[K_GetSkinNum(player)];
}
//}
//{ SRB2kart Net Variables
@@ -1989,7 +1935,7 @@ static void K_PlayGenericCombatSound(mobj_t *source, mobj_t *other, sfxenum_t sf
// I HATE LOCALSKINS! I HATE LOCALSKINS! :AAAAAAAAAA:
if (source->player)
{
skin = K_GetPlayerSkin(source->player);
skin = R_GetPlayerSkin(source->player);
}
if (!skin)
+3 -1
View File
@@ -1766,6 +1766,8 @@ static int lib_rSetPlayerSkin(lua_State *L)
INT32 i = luaL_checkinteger(L, 2);
if (i < 0 || i >= MAXSKINS)
return luaL_error(L, "skin number (argument #2) %d out of range (0 - %d)", i, MAXSKINS-1);
if (i >= numskins)
return 0;
SetPlayerSkinByNum(player-players, i);
}
else // skin name
@@ -2631,7 +2633,7 @@ static int lib_kLossSound(lua_State *L)
if (!mobj->player)
return luaL_error(L, "K_PlayLossSound: mobj_t isn't a player object.");
sfx_id = ((skin_t *)mobj->skin)->soundsid[S_sfx[sfx_klose].skinsound];
sfx_id = R_GetMobjSkin(mobj)->soundsid[S_sfx[sfx_klose].skinsound];
S_StartSound(mobj, sfx_id);
return 0;
}
+1 -1
View File
@@ -962,7 +962,7 @@ static void res_botai(Hook_State *hook)
int LUA_HookBotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
{
const char *skin = ((skin_t *)tails->skin)->name;
const char *skin = tails->skin->name;
Hook_State hook = {};
BotAI_State botai = {};
+2
View File
@@ -53,4 +53,6 @@ boolean LUA_HudEnabled(enum hud option);
void LUA_SetHudHook(int hook, huddrawlist_h list);
#define LOCALSKINIMMERSION (hud_running && cv_luaimmersion.value)
#endif // __LUA_HUD_H__
+5 -3
View File
@@ -487,7 +487,7 @@ static int libd_getSpritePatch(lua_State *L)
{
const char *name = luaL_checkstring(L, 1);
for (skn = 0; skn < numskins; skn++)
if (fastcmp(skins[skn].name, name))
if (fastcmp(skins[skn]->name, name))
break;
if (skn >= numskins)
return 0;
@@ -527,9 +527,9 @@ static int libd_getSpritePatch(lua_State *L)
}
else // player skin
{
sprdef = &skins[skn].spritedef;
sprdef = &skins[skn]->spritedef;
#ifdef ROTSPRITE
sprinfo = &skins[skn].sprinfo;
sprinfo = &skins[skn]->sprinfo;
#endif
}
@@ -1056,6 +1056,8 @@ static int libd_getColormap(lua_State *L)
skinnum = (INT32)luaL_checkinteger(L, 1);
if (skinnum < TC_BLINK || skinnum >= MAXSKINS)
return luaL_error(L, "skin number %d is out of range (%d - %d)", skinnum, TC_BLINK, MAXSKINS-1);
if (skinnum >= numskins)
return 0;
}
else // skin name
{
-10
View File
@@ -18,7 +18,6 @@
#include "p_slopes.h"
#include "r_main.h"
#include "lua_udatalib.h"
#include "lua_script.h"
#include "lua_libs.h"
#include "lua_hud.h" // hud_running errors
@@ -256,15 +255,6 @@ static const char *const vector_opt[] = {
static const char *const array_opt[] ={"iterate",NULL};
static const char *const valid_opt[] ={"valid",NULL};
#define pushsubsector(L, subsector) LUA_PushUserdata(L, subsector, META_SUBSECTOR)
int udatalib_getter_subsector(lua_State *L)
UDATALIB_SIMPLE_GETTER(subsector_t*, pushsubsector)
#undef pushsubsector
#define pushslope(L, slope) LUA_PushUserdata(L, slope, META_SLOPE)
int udatalib_getter_slope(lua_State *L)
UDATALIB_SIMPLE_GETTER(pslope_t*, pushslope)
#undef pushslope
// iterates through a sector's thinglist!
static int lib_iterateSectorThinglist(lua_State *L)
{
+777 -743
View File
File diff suppressed because it is too large. Load diff
+847 -422
View File
File diff suppressed because it is too large. Load diff
+30 -13
View File
@@ -18,6 +18,10 @@
#include "lua_script.h"
#include "lua_libs.h"
#include "lua_hud.h" // hud_running errors
#define SKINARR (LOCALSKINIMMERSION ? allskins : skins)
#define NSKINS (LOCALSKINIMMERSION ? numallskins : numskins)
enum skin {
skin_valid = 0,
@@ -150,13 +154,15 @@ static int skin_num(lua_State *L)
// skins are always valid, only added, never removed
I_Assert(skin != NULL);
lua_pushinteger(L, skin-skins);
lua_pushinteger(L, LOCALSKINIMMERSION ? skin->allskinnum : skin->skinnum);
return 1;
}
static int lib_iterateSkins(lua_State *L)
{
INT32 i;
skin_t **skinar = SKINARR;
const INT32 nskins = NSKINS;
if (lua_gettop(L) < 2)
{
@@ -169,14 +175,17 @@ static int lib_iterateSkins(lua_State *L)
lua_remove(L, 1); // state is unused.
if (!lua_isnil(L, 1))
i = (INT32)(*((skin_t **)luaL_checkudata(L, 1, META_SKIN)) - allskins) + 1;
{
skin_t *skin = (*((skin_t **)luaL_checkudata(L, 1, META_SKIN)));
i = (INT32)(LOCALSKINIMMERSION ? skin->allskinnum : skin->skinnum) + 1;
}
else
i = 0;
// skins are always valid, only added, never removed
if (i < numallskins)
if (i < nskins)
{
LUA_PushUserdata(L, &allskins[i], META_SKIN);
LUA_PushUserdata(L, skinar[i], META_SKIN);
return 1;
}
@@ -188,32 +197,40 @@ static int lib_getSkin(lua_State *L)
const char *field;
INT32 i;
skin_t **skinar = SKINARR;
const INT32 nskins = NSKINS;
// find skin by number
if (lua_type(L, 2) == LUA_TNUMBER)
{
const INT32 skinmax = LOCALSKINIMMERSION ? numallskins : MAXSKINS;
i = luaL_checkinteger(L, 2);
if (i < 0 || i >= MAXSKINS)
return luaL_error(L, "skins[] index %d out of range (0 - %d)", i, MAXSKINS-1);
if (i >= numallskins)
if (i < 0 || i >= skinmax)
return luaL_error(L, "skins[] index %d out of range (0 - %d)", i, skinmax-1);
if (i >= nskins)
return 0;
LUA_PushUserdata(L, &allskins[i], META_SKIN);
LUA_PushUserdata(L, skinar[i], META_SKIN);
return 1;
}
field = luaL_checkstring(L, 2);
// special function iterate
if (fastcmp(field,"iterate"))
if (fastcmp(field, "iterate"))
{
lua_pushcfunction(L, lib_iterateSkins);
return 1;
}
// find skin by name
for (i = 0; i < numallskins; i++)
if (fastcmp(allskins[i].name, field))
for (i = 0; i < nskins; i++)
if (fastcmp(skinar[i]->name, field))
{
LUA_PushUserdata(L, &allskins[i], META_SKIN);
LUA_PushUserdata(L, skinar[i], META_SKIN);
return 1;
}
@@ -222,7 +239,7 @@ static int lib_getSkin(lua_State *L)
static int lib_numSkins(lua_State *L)
{
lua_pushinteger(L, numallskins);
lua_pushinteger(L, NSKINS);
return 1;
}
-137
View File
@@ -1,137 +0,0 @@
// SONIC ROBO BLAST 2 KART SATURN
//-----------------------------------------------------------------------------
// Copyright (C) 2025 by Indev.
//
// 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 lua_udatalib.c
/// \brief Implementation of lua userdata object metatables based on getter/setter functions
#include "doomtype.h"
#include "m_fixed.h"
#include "lua_udatalib.h"
// Getters
int udatalib_getter_fixed(lua_State *L)
UDATALIB_SIMPLE_GETTER(fixed_t, lua_pushinteger)
int udatalib_getter_angle(lua_State *L)
UDATALIB_SIMPLE_GETTER(angle_t, lua_pushangle)
int udatalib_getter_uint8(lua_State *L)
UDATALIB_SIMPLE_GETTER(UINT8, lua_pushinteger)
int udatalib_getter_sint8(lua_State *L)
UDATALIB_SIMPLE_GETTER(SINT8, lua_pushinteger)
int udatalib_getter_uint16(lua_State *L)
UDATALIB_SIMPLE_GETTER(UINT16, lua_pushinteger)
int udatalib_getter_int16(lua_State *L)
UDATALIB_SIMPLE_GETTER(INT16, lua_pushinteger)
int udatalib_getter_uint32(lua_State *L)
UDATALIB_SIMPLE_GETTER(UINT32, lua_pushinteger)
int udatalib_getter_int32(lua_State *L)
UDATALIB_SIMPLE_GETTER(INT32, lua_pushinteger)
int udatalib_getter_uint64(lua_State *L)
UDATALIB_SIMPLE_GETTER(UINT64, lua_pushinteger)
int udatalib_getter_int64(lua_State *L)
UDATALIB_SIMPLE_GETTER(INT64, lua_pushinteger)
int udatalib_getter_string(lua_State *L)
UDATALIB_SIMPLE_GETTER(const char*, lua_pushstring)
int udatalib_getter_boolean(lua_State *L)
UDATALIB_SIMPLE_GETTER(boolean, lua_pushboolean)
int udatalib_getter_spritenum(lua_State *L)
UDATALIB_SIMPLE_GETTER(spritenum_t, lua_pushinteger)
int udatalib_getter_tic(lua_State *L)
UDATALIB_SIMPLE_GETTER(tic_t, lua_pushinteger)
// Setters
int udatalib_setter_fixed(lua_State *L)
UDATALIB_SIMPLE_SETTER(fixed_t, luaL_checkfixed)
int udatalib_setter_angle(lua_State *L)
UDATALIB_SIMPLE_SETTER(angle_t, luaL_checkangle)
int udatalib_setter_uint8(lua_State *L)
UDATALIB_SIMPLE_SETTER(UINT8, (UINT8)luaL_checkinteger)
int udatalib_setter_sint8(lua_State *L)
UDATALIB_SIMPLE_SETTER(SINT8, luaL_checkinteger)
int udatalib_setter_uint16(lua_State *L)
UDATALIB_SIMPLE_SETTER(UINT16, (UINT16)luaL_checkinteger)
int udatalib_setter_int16(lua_State *L)
UDATALIB_SIMPLE_SETTER(INT16, luaL_checkinteger)
int udatalib_setter_uint32(lua_State *L)
UDATALIB_SIMPLE_SETTER(UINT32, (UINT32)luaL_checkinteger)
int udatalib_setter_int32(lua_State *L)
UDATALIB_SIMPLE_SETTER(INT32, luaL_checkinteger)
int udatalib_setter_uint64(lua_State *L)
UDATALIB_SIMPLE_SETTER(UINT64, (UINT64)luaL_checkinteger)
int udatalib_setter_int64(lua_State *L)
UDATALIB_SIMPLE_SETTER(INT64, luaL_checkinteger)
int udatalib_setter_string(lua_State *L)
UDATALIB_SIMPLE_SETTER(const char*, luaL_checkstring)
int udatalib_setter_boolean(lua_State *L)
UDATALIB_SIMPLE_SETTER(boolean, luaL_checkboolean)
// ffs
int udatalib_setter_boolean_nocheck(lua_State *L)
UDATALIB_SIMPLE_SETTER(boolean, lua_toboolean)
int udatalib_setter_spritenum(lua_State *L)
UDATALIB_SIMPLE_SETTER(spritenum_t, luaL_checkinteger)
int udatalib_setter_tic(lua_State *L)
UDATALIB_SIMPLE_SETTER(tic_t, (tic_t)luaL_checkinteger)
void udatalib_addfield(lua_State *L, int mt, udata_field_t field)
{
int idx = abs_index(L, mt);
lua_createtable(L, 2, 0); // Push table
lua_pushinteger(L, field.offset); // Push offset
lua_pushcclosure(L, field.getter, 1); // Pop offset, push closure
lua_rawseti(L, -2, UDATALIB_GETTER); // Pop closure, add to table
lua_pushinteger(L, field.offset); // Push offset
lua_pushcclosure(L, field.setter, 1); // Pop offset, push closure
lua_rawseti(L, -2, UDATALIB_SETTER); // Pop closure, add to table
lua_pushstring(L, field.name); // Push field name
lua_pushvalue(L, -2); // Copy table
lua_rawset(L, idx); // Pop field name and table, add to metatable
lua_pop(L, 1); // Pop field table
}
void udatalib_addfields(lua_State *L, int mt, const udata_field_t fields[])
{
for (unsigned i = 0; fields[i].name != NULL; ++i)
{
udatalib_addfield(L, mt, fields[i]);
//CONS_Printf("Add field name=%s, offset=%d, getter=%p, setter=%p\n", fields[i].name, fields[i].offset, fields[i].getter, fields[i].setter);
}
}
-114
View File
@@ -1,114 +0,0 @@
// SONIC ROBO BLAST 2 KART SATURN
//-----------------------------------------------------------------------------
// Copyright (C) 2025 by Indev.
//
// 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 lua_udatalib.h
/// \brief Implementation of lua userdata object metatables based on getter/setter functions
#ifndef __LUA_UDATALIB_H__
#define __LUA_UDATALIB_H__
#include "doomdef.h"
#include "lua_script.h"
#include "lua_libs.h"
#include "fastcmp.h"
// Indices in getter/setter tables for fields
#define UDATALIB_GETTER 1
#define UDATALIB_SETTER 2
typedef struct udata_field_s {
const char *name;
size_t offset;
lua_CFunction getter;
lua_CFunction setter;
} udata_field_t;
// Simple setters and getters, for situations where getter is simply
// "return obj.field" and setter is "obj.field = value"
int udatalib_getter_fixed(lua_State *L);
int udatalib_getter_angle(lua_State *L);
int udatalib_getter_uint8(lua_State *L);
int udatalib_getter_sint8(lua_State *L);
int udatalib_getter_uint16(lua_State *L);
int udatalib_getter_int16(lua_State *L);
int udatalib_getter_uint32(lua_State *L);
int udatalib_getter_int32(lua_State *L);
int udatalib_getter_uint64(lua_State *L);
int udatalib_getter_int64(lua_State *L);
int udatalib_getter_string(lua_State *L);
int udatalib_getter_boolean(lua_State *L);
int udatalib_getter_spritenum(lua_State *L);
int udatalib_getter_mobj(lua_State *L);
int udatalib_getter_subsector(lua_State *L);
int udatalib_getter_mobjtype(lua_State *L);
int udatalib_getter_player(lua_State *L);
int udatalib_getter_mapthing(lua_State *L);
int udatalib_getter_slope(lua_State *L);
int udatalib_getter_cmd(lua_State *L);
int udatalib_getter_playerstate(lua_State *L);
int udatalib_getter_powers(lua_State *L);
int udatalib_getter_kartstuff(lua_State *L);
int udatalib_getter_pflags(lua_State *L);
int udatalib_getter_panim(lua_State *L);
int udatalib_getter_tic(lua_State *L);
int udatalib_setter_fixed(lua_State *L);
int udatalib_setter_angle(lua_State *L);
int udatalib_setter_uint8(lua_State *L);
int udatalib_setter_sint8(lua_State *L);
int udatalib_setter_uint16(lua_State *L);
int udatalib_setter_int16(lua_State *L);
int udatalib_setter_uint32(lua_State *L);
int udatalib_setter_int32(lua_State *L);
int udatalib_setter_uint64(lua_State *L);
int udatalib_setter_int64(lua_State *L);
int udatalib_setter_string(lua_State *L);
int udatalib_setter_boolean(lua_State *L);
int udatalib_setter_boolean_nocheck(lua_State *L);
int udatalib_setter_spritenum(lua_State *L);
int udatalib_setter_mobj(lua_State *L);
int udatalib_setter_playerstate(lua_State *L);
int udatalib_setter_pflags(lua_State *L);
int udatalib_setter_panim(lua_State *L);
int udatalib_setter_tic(lua_State *L);
// Adds setter and getter for field and stores it as field.name..".get" and
// field.name..".set" in table at index mt. (metatable, usually)
void udatalib_addfield(lua_State *L, int mt, udata_field_t field);
// Convinience function to add array of fields at once.
void udatalib_addfields(lua_State *L, int mt, const udata_field_t fields[]);
// I miss C++ template functons :(
// Get pointer to field value within getter or setter
#define UDATALIB_GETFIELD(type, field) \
{ \
size_t offset = lua_tointeger(L, lua_upvalueindex(1)); \
field = (type*)((uint8_t*)lua_touserdata(L, 1) + offset); \
}
// Creates implementation for simple getter and setter. Super lazy, yes.
// Assumes userdata is a pointer to actual data. Maybe not really safe.
#define UDATALIB_SIMPLE_GETTER(type, pushf) \
{ \
type *field; \
UDATALIB_GETFIELD(type, field) \
pushf(L, *field); \
return 1; \
}
#define UDATALIB_SIMPLE_SETTER(type, checkf) \
{ \
type *field; \
UDATALIB_GETFIELD(type, field) \
*field = checkf(L, 2); \
return 0; \
}
#endif
+1 -2
View File
@@ -14,8 +14,7 @@
#include <string.h>
#ifdef HAVE_THREADS
#include <threads.h>
#define local_for_thread thread_local
#define local_for_thread _Thread_local
#else
#define local_for_thread
#endif
+83 -70
View File
@@ -809,7 +809,7 @@ static void M_ChangeCvar(INT32 choice)
{
INT32 skinno = R_SkinAvailable(cv_chooseskin.string);
if (skinno != -1)
CV_SetValue(cv,skins[skinno].prefcolor);
CV_SetValue(cv,skins[skinno]->prefcolor);
return;
}
@@ -2851,11 +2851,11 @@ static void M_PatchSkinNameTable(void)
memset(skins_cons_t, 0, sizeof (skins_cons_t));
for (j = 0; j < MAXSKINS; j++)
for (j = 0; j < numskins; j++)
{
if (skins[j].name[0] != '\0')
if (skins[j]->name[0] != '\0')
{
skins_cons_t[j].strvalue = skins[j].name;
skins_cons_t[j].strvalue = skins[j]->name;
skins_cons_t[j].value = j+1;
}
else
@@ -3989,6 +3989,10 @@ boolean replaynamesloaded = false;
// If it's not equal, that means we started more than one thread (left and re-entered menu for example)
size_t replaythreadnum = 0;
// for replay dates
#include <locale.h>
const char *demodateformat = "%d.%m.%Y";
#ifdef HAVE_THREADS
I_mutex replayquerymutex;
@@ -4025,6 +4029,7 @@ static void ReplayNamesLoadThread(void* userdata)
menudemo_t *demolist_all_local = (menudemo_t*)malloc(sizeof(menudemo_t)*demolist_all_size_local);
memcpy(demolist_all_local, demolist_all, sizeof(menudemo_t)*demolist_all_size_local);
size_t localreplaythreadnum = replaythreadnum;
const char *localdemodateformat = demodateformat;
Unlock_search_state();
@@ -4032,13 +4037,7 @@ static void ReplayNamesLoadThread(void* userdata)
{
if (demolist_all_local[i].type != MD_SUBDIR)
{
G_LoadDemoTitle(&demolist_all_local[i]);
// this is fucking horrid, but i wanna be able to search for dates
/*if (demolist_all_local[i].date[0] != '\0')
{
snprintf(demolist_all_local[i].title, sizeof(demolist_all_local[i].title), "%s %s", demolist_all_local[i].title, demolist_all_local[i].date);
}*/
G_LoadDemoTitle(&demolist_all_local[i], localdemodateformat);
}
}
@@ -4061,6 +4060,18 @@ static void LoadReplayNames(void)
Lock_search_state();
replaythreadnum++;
replaynamesloaded = false;
if (cv_demodateformat.value == 2)
demodateformat = "%m.%d.%Y";
else if (cv_demodateformat.value == 1)
demodateformat = "%d.%m.%Y";
else
{
// get the date format here
// setlocale reads/writes global state
const char *locale = setlocale(LC_TIME, NULL);
// US ppl are special (:
demodateformat = (locale && strstr(locale, "en_US")) ? "%m.%d.%Y" : "%d.%m.%Y";
}
Unlock_search_state();
#ifdef HAVE_THREADS
@@ -4553,9 +4564,9 @@ static void DrawReplayHutReplayInfo(void)
}
// Character face!
if (replaydemolist->standings[0].skin < numskins && W_CheckNumForName(skins[replaydemolist->standings[0].skin].facewant) != LUMPERROR)
if (replaydemolist->standings[0].skin < numskins && W_CheckNumForName(skins[replaydemolist->standings[0].skin]->facewant) != LUMPERROR)
{
patch = facewantprefix[replaydemolist->standings[0].skin];
patch = skins[replaydemolist->standings[0].skin]->facewantprefix;
colormap = R_GetTranslationColormap(
replaydemolist->standings[0].skin,
replaydemolist->standings[0].color,
@@ -4776,9 +4787,9 @@ static void M_DrawReplayStartMenu(void)
V_DrawString(BASEVIDWIDTH-92, STARTY + i*20 + 9, V_SNAPTOTOP, va("%d", timeorscore));
// Character face!
if (replaydemolist->standings[i].skin < numskins && W_CheckNumForName(skins[replaydemolist->standings[i].skin].facerank) != LUMPERROR)
if (replaydemolist->standings[i].skin < numskins && W_CheckNumForName(skins[replaydemolist->standings[i].skin]->facerank) != LUMPERROR)
{
patch = facerankprefix[replaydemolist->standings[i].skin];
patch = skins[replaydemolist->standings[i].skin]->facerankprefix;
colormap = R_GetTranslationColormap(
replaydemolist->standings[i].skin,
replaydemolist->standings[i].color,
@@ -4967,13 +4978,15 @@ static void M_DrawPlaybackMenu(void)
if (i >= playback_view1 && i <= playback_view4)
{
if (modeattacking) continue;
if (modeattacking)
continue;
if (splitscreen >= i - playback_view1)
{
INT32 ply = displayplayers[i - playback_view1];
icon = facerankprefix[players[ply].skin];
icon = skins[players[ply].skin]->facerankprefix;
if (i != itemOn)
inactivemap = R_GetTranslationColormap(players[ply].skin, players[ply].skincolor, GTC_MENUCACHE);
}
@@ -6259,17 +6272,17 @@ void M_DrawTimeAttackMenu(void)
SHOWMODDEDGAME
const INT32 skinnum = max(cv_chooseskin.value-1, 0); // dont think its needed but better safe than sorry!
const skin_t *skin = &skins[skinnum];
const skin_t *skin = skins[skinnum];
// Character face!
if (W_CheckNumForName(skin->facewant) != LUMPERROR)
{
const INT32 charx = (BASEVIDWIDTH-x - facewantprefix[skinnum]->width);
const INT32 charx = (BASEVIDWIDTH-x - skins[skinnum]->facewantprefix->width);
UINT8 *colormap = NULL;
colormap = R_GetTranslationColormap(skinnum, cv_playercolor.value, GTC_MENUCACHE);
V_DrawMappedPatch(charx, y, 0, facewantprefix[skinnum], colormap);
V_DrawMappedPatch(charx, y, 0, skins[skinnum]->facewantprefix, colormap);
// draw stats
// speed
@@ -7717,7 +7730,7 @@ static void M_DrawMPMainMenu(void)
break;
}
if (pskin >= MAXSKINS)
if (pskin >= numskins)
pskin = 0;
if (!trans && i > cv_splitplayers.value)
@@ -7725,7 +7738,7 @@ static void M_DrawMPMainMenu(void)
colmap = R_GetTranslationColormap(pskin, pcol, GTC_MENUCACHE);
V_DrawFixedPatch(x<<FRACBITS, y<<FRACBITS, FRACUNIT, trans, facewantprefix[pskin], colmap);
V_DrawFixedPatch(x<<FRACBITS, y<<FRACBITS, FRACUNIT, trans, skins[pskin]->facewantprefix, colmap);
if (itemOn == 2 && i == setupm_pselect)
{
@@ -7986,12 +7999,12 @@ static void M_DrawSetupMultiPlayerMenu(void)
else
M_DrawTextInput(mx + 40, my + nameboxaddy, &setupm_input, 0);
#define GETSELECTEDSKINNAME (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]].realname : skins[setupm_fakeskin].realname)
#define GETSELECTEDSPEED (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]].kartspeed : skins[setupm_fakeskin].kartspeed)
#define GETSELECTEDWEIGHT (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]].kartweight : skins[setupm_fakeskin].kartweight)
#define GETSELECTEDSKINNAME (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]]->realname : skins[setupm_fakeskin]->realname)
#define GETSELECTEDSPEED (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]]->kartspeed : skins[setupm_fakeskin]->kartspeed)
#define GETSELECTEDWEIGHT (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]]->kartweight : skins[setupm_fakeskin]->kartweight)
// draw skin string
st = V_StringWidth(skins[setupm_fakeskin].realname, 0);
st = V_StringWidth(skins[setupm_fakeskin]->realname, 0);
switch (cv_skinselectmenu.value)
{
case SKINMENUTYPE_EXTENDED:
@@ -8013,10 +8026,10 @@ static void M_DrawSetupMultiPlayerMenu(void)
skintodisplay = skinstats[setupm_skinxpos][setupm_skinypos][(I_GetTime()/TICRATE)%SELECTEDSTATSCOUNT];
tw = V_StringWidth("Character", 0);
st = V_StringWidth(skins[skintodisplay].realname, 0);
st = V_StringWidth(skins[skintodisplay]->realname, 0);
V_DrawString((mx+(tw/2)) - (st/2), my + 37,
((MP_PlayerSetupMenu[2].status & IT_TYPE) == IT_SPACE ? V_TRANSLUCENT : 0) | highlightflags | V_ALLOWLOWERCASE,
skins[skintodisplay].realname);
skins[skintodisplay]->realname);
// the menu is now 2d, no need for scroll arrows...
if (itemOn == 1 && setupm_skinlockedselect)
{
@@ -8030,7 +8043,7 @@ static void M_DrawSetupMultiPlayerMenu(void)
default:
V_DrawString(BASEVIDWIDTH - mx - st, my + 16,
((MP_PlayerSetupMenu[2].status & IT_TYPE) == IT_SPACE ? V_TRANSLUCENT : 0)|highlightflags|V_ALLOWLOWERCASE,
skins[setupm_fakeskin].realname);
skins[setupm_fakeskin]->realname);
if (itemOn == 1)
{
V_DrawCharacter(BASEVIDWIDTH - mx - 10 - st - (skullAnimCounter/5), my + 16,
@@ -8136,10 +8149,10 @@ static void M_DrawSetupMultiPlayerMenu(void)
for (i = 0; i < numskins; i++) // draw the stat dots
{
if (i != setupm_fakeskin && R_SkinAvailable(skins[i].name) != -1)
if (i != setupm_fakeskin && R_SkinAvailable(skins[i]->name) != -1)
{
speed = skins[i].kartspeed;
weight = skins[i].kartweight;
speed = skins[i]->kartspeed;
weight = skins[i]->kartweight;
V_DrawFixedPatch((((statx+46) + (speed*4))<<FRACBITS) + (FRACUNIT>>1), (((staty+71) + (weight*4))<<FRACBITS), FRACUNIT>>1, 0, statdot, NULL);
}
}
@@ -8195,10 +8208,10 @@ static void M_DrawSetupMultiPlayerMenu(void)
for (i = 0; i < numskins; i++) // draw the stat dots
{
if (i != setupm_fakeskin && R_SkinAvailable(skins[i].name) != -1)
if (i != setupm_fakeskin && R_SkinAvailable(skins[i]->name) != -1)
{
speed = skins[i].kartspeed;
weight = skins[i].kartweight;
speed = skins[i]->kartspeed;
weight = skins[i]->kartweight;
V_DrawFixedPatch(((BASEVIDWIDTH - mx - 80) + ((speed-1)*8))<<FRACBITS, ((my+76) + ((weight-1)*8))<<FRACBITS, FRACUNIT, 0, statdot, NULL);
}
}
@@ -8232,8 +8245,8 @@ static void M_DrawSetupMultiPlayerMenu(void)
continue;
}
face = facerankprefix[skinn];
cmap = R_GetTranslationColormap(skinn, skins[skinn].prefcolor, GTC_MENUCACHE);
face = skins[skinn]->facerankprefix;
cmap = R_GetTranslationColormap(skinn, skins[skinn]->prefcolor, GTC_MENUCACHE);
V_DrawFixedPatch(x << FRACBITS, y << FRACBITS, FRACUNIT, 0, face, cmap);
}
@@ -8270,8 +8283,8 @@ static void M_DrawSetupMultiPlayerMenu(void)
continue;
}
face = facerankprefix[skinn];
cmap = R_GetTranslationColormap(skinn, skins[skinn].prefcolor, GTC_MENUCACHE);
face = skins[skinn]->facerankprefix;
cmap = R_GetTranslationColormap(skinn, skins[skinn]->prefcolor, GTC_MENUCACHE);
V_DrawFixedPatch(x << FRACBITS, y << FRACBITS, FRACUNIT, 0, face, cmap);
}
@@ -8285,7 +8298,7 @@ static void M_DrawSetupMultiPlayerMenu(void)
if (setupm_skinselect < numskins)
{
const UINT8 *cmap = R_GetTranslationColormap(setupm_skinselect, setupm_fakecolor, GTC_MENUCACHE);
cursor = facewantprefix[skinsorted[setupm_skinselect]];
cursor = skins[skinsorted[setupm_skinselect]]->facewantprefix;
V_DrawFixedPatch(((curx-8) << FRACBITS), ((cury-8) << FRACBITS), FRACUNIT, 0, cursor, cmap);
}
else
@@ -8299,8 +8312,8 @@ static void M_DrawSetupMultiPlayerMenu(void)
{ // stat dot
const INT32 selectedskin = (itemOn == 1 && setupm_skinselect < numskins ? skinsorted[setupm_skinselect] : setupm_fakeskin);
speed = skins[selectedskin].kartspeed;
weight = skins[selectedskin].kartweight;
speed = skins[selectedskin]->kartspeed;
weight = skins[selectedskin]->kartweight;
const INT32 x = (((statx+46) + (speed*4))<<FRACBITS) + (FRACUNIT>>1);
const INT32 y = (((staty+71) + (weight*4))<<FRACBITS);
@@ -8339,8 +8352,8 @@ static void M_DrawSetupMultiPlayerMenu(void)
}
skinn = skinstats[s][w][(I_GetTime() / TICRATE) % skinstatscount[s][w]];
face = facerankprefix[skinn];
cmap = R_GetTranslationColormap(skinn, skins[skinn].prefcolor, GTC_MENUCACHE);
face = skins[skinn]->facerankprefix;
cmap = R_GetTranslationColormap(skinn, skins[skinn]->prefcolor, GTC_MENUCACHE);
V_DrawFixedPatch(x << FRACBITS, y << FRACBITS, FRACUNIT, 0, face, cmap);
}
@@ -8357,7 +8370,7 @@ static void M_DrawSetupMultiPlayerMenu(void)
const UINT8 *cmap = R_GetTranslationColormap(setupm_skinselect, setupm_fakecolor, GTC_MENUCACHE);
const INT32 skinn = skinstats[setupm_skinxpos][setupm_skinypos][(I_GetTime() / TICRATE) % skinstatscount[setupm_skinxpos][setupm_skinypos]];
cursor = facewantprefix[skinn];
cursor = skins[skinn]->facewantprefix;
V_DrawFixedPatch(((curx-8) << FRACBITS), ((cury-8) << FRACBITS), FRACUNIT, 0, cursor, cmap);
}
else
@@ -8371,8 +8384,8 @@ static void M_DrawSetupMultiPlayerMenu(void)
#undef SKINXSHIFT
default:
{
speed = skins[setupm_fakeskin].kartspeed;
weight = skins[setupm_fakeskin].kartweight;
speed = skins[setupm_fakeskin]->kartspeed;
weight = skins[setupm_fakeskin]->kartweight;
const INT32 x = ((BASEVIDWIDTH - mx - 80) + ((speed-1)*8))<<FRACBITS;
const INT32 y = ((my+76) + ((weight-1)*8))<<FRACBITS;
@@ -8456,14 +8469,14 @@ static void M_DrawSetupMultiPlayerMenu(void)
if (!(k++))
{
scale = FRACUNIT;
face = facewantprefix[col];
face = skins[col]->facewantprefix;
offx = 12;
offy = 0;
}
else
{
scale = FRACUNIT/2;
face = facerankprefix[col];
face = skins[col]->facerankprefix;
offx = 8;
offy = 8;
}
@@ -8517,15 +8530,15 @@ static void M_DrawSetupMultiPlayerMenu(void)
break;
}
if (skintodisplay >= MAXSKINS)
if (skintodisplay >= numskins)
skintodisplay = 0;
skinnum = R_SkinAvailable(skins[skintodisplay].name);
skinnum = R_SkinAvailable(skins[skintodisplay]->name);
if (skinnum < 0 || skinnum >= MAXSKINS)
if (skinnum < 0 || skinnum >= numskins)
skinnum = 0;
sprdef = &skins[skinnum].spritedef;
sprdef = &skins[skinnum]->spritedef;
if (!sprdef->numframes) // No frames ??
return; // Can't render!
@@ -8543,7 +8556,7 @@ static void M_DrawSetupMultiPlayerMenu(void)
{
UINT8 *colormap = R_GetTranslationColormap(skintodisplay, setupm_fakecolor, GTC_MENUCACHE);
#ifdef HWRENDER
md2_t *md2 = &md2_playermodels[skinnum];
md2_t *md2 = &skins[skinnum]->playermodel;
#endif
mx += 36;
my += 131;
@@ -8574,11 +8587,11 @@ static void M_DrawSetupMultiPlayerMenu(void)
patch = (patch_t *)W_CachePatchNum(sprframe->lumppat[speenframe], PU_PATCH);
if (skins[skintodisplay].flags & SF_HIRES)
if (skins[skintodisplay]->flags & SF_HIRES)
{
V_DrawFixedPatch(mx<<FRACBITS,
my<<FRACBITS,
skins[skintodisplay].highresscale,
skins[skintodisplay]->highresscale,
flags, patch, colormap);
}
else
@@ -8885,7 +8898,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
}
else if (itemOn == 2)
{
UINT8 col = skins[setupm_fakeskin].prefcolor;
UINT8 col = skins[setupm_fakeskin]->prefcolor;
if (setupm_fakecolor != col)
{
S_StartSound(NULL, sfx_menu1); // Tails
@@ -9108,7 +9121,7 @@ static boolean M_QuitMultiPlayerMenu(void)
}
// you know what? always putting these in the buffer won't hurt anything.
COM_BufAddText(va("%s \"%s\"\n", setupm_cvskin->name, skins[setupm_fakeskin].name));
COM_BufAddText(va("%s \"%s\"\n", setupm_cvskin->name, skins[setupm_fakeskin]->name));
COM_BufAddText(va("%s %d\n", setupm_cvcolor->name, setupm_fakecolor));
return true;
@@ -9884,7 +9897,7 @@ static void M_DrawLocalSkinMenu(void)
UINT8 frame;
INT32 skintodisplay = 0;
UINT32 speenframe;
skin_t displayskin;
skin_t *displayskin;
mx = OP_ForkedBirdDef.x;
my = OP_ForkedBirdDef.y;
@@ -9926,7 +9939,7 @@ static void M_DrawLocalSkinMenu(void)
displayskin = allskins[skintodisplay];
sprdef = &displayskin.spritedef;
sprdef = &displayskin->spritedef;
if (!sprdef->numframes) // No frames ??
return; // Can't render!
@@ -9939,25 +9952,25 @@ static void M_DrawLocalSkinMenu(void)
V_DrawFill(mx + 220 - (charw/2), my+54, charw, 84, 239);
#undef charw
// FIXME: is skins[displayskin.localnum] even correct?
UINT8 *colormap = R_GetLocalTranslationColormap(&skins[displayskin.localnum], (displayskin.localskin ? &localskins[displayskin.localnum] : NULL), cv_playercolor.value, GTC_MENUCACHE, displayskin.localskin);
// FIXME: is using just "skins" array even correct?
UINT8 *colormap = R_GetLocalTranslationColormap(skins[displayskin->skinnum], (displayskin->localskin ? localskins[displayskin->skinnum] : NULL), cv_playercolor.value, GTC_MENUCACHE, displayskin->localskin);
V_DrawMappedPatch(mx, my+50, 0, (patch_t *)W_CachePatchName(displayskin.facewant, PU_PATCH), colormap);
V_DrawMappedPatch(mx+8, my+85, 0, (patch_t *)W_CachePatchName(displayskin.facerank, PU_PATCH), colormap);
V_DrawMappedPatch(mx, my+50, 0, (patch_t *)W_CachePatchName(displayskin->facewant, PU_PATCH), colormap);
V_DrawMappedPatch(mx+8, my+85, 0, (patch_t *)W_CachePatchName(displayskin->facerank, PU_PATCH), colormap);
V_DrawString(mx, my+108, V_ALLOWLOWERCASE, "Character");
if (strlen(displayskin.realname) > 10)
V_DrawThinString(mx+20, my+118, V_ALLOWLOWERCASE|highlightflags, displayskin.realname);
if (strlen(displayskin->realname) > 10)
V_DrawThinString(mx+20, my+118, V_ALLOWLOWERCASE|highlightflags, displayskin->realname);
else
V_DrawString(mx+20, my+118, V_ALLOWLOWERCASE|highlightflags, displayskin.realname);
V_DrawString(mx+20, my+118, V_ALLOWLOWERCASE|highlightflags, displayskin->realname);
// draw player sprite
mx += 220;
my += 120;
#ifdef HWRENDER
md2_t *md2 = (displayskin.localskin ? &md2_localplayermodels[displayskin.localnum] : &md2_playermodels[skintodisplay]);
md2_t *md2 = &displayskin->playermodel;
// if we have 3d models enabled and a model exists
// try to show it instead of the sprite
@@ -9985,9 +9998,9 @@ static void M_DrawLocalSkinMenu(void)
patch = (patch_t *)W_CachePatchNum(sprframe->lumppat[speenframe], PU_PATCH);
if (displayskin.flags & SF_HIRES)
if (displayskin->flags & SF_HIRES)
{
V_DrawFixedPatch(mx<<FRACBITS, my<<FRACBITS, displayskin.highresscale, flags, patch, colormap);
V_DrawFixedPatch(mx<<FRACBITS, my<<FRACBITS, displayskin->highresscale, flags, patch, colormap);
}
else
{
+2 -2
View File
@@ -1004,7 +1004,7 @@ static menuitem_t OP_ExpOptionsMenu[] =
#ifdef HWRENDER
{IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 95},
#ifdef USE_FBO_OGL
{IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_glframebuffer, 100},
{IT_STRING | IT_CVAR, NULL, "FBO support", &cv_glframebuffer, 100},
{IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 110},
{IT_DISABLED, NULL, "", NULL, 120}, // dummy text
#else
@@ -1030,7 +1030,7 @@ static const char* OP_ExpTooltips[] =
#ifdef HWRENDER
"Disabling Screen Textures may result in a performance boost\nbut will break certain effects.\nScreen textures are required at resolutions lower than your desktop resolution!",
#ifdef USE_FBO_OGL
"Allows the game to downsample from a higher resolution\nthan your display in OpenGL renderer mode.\nRequires a GPU with atleast OpenGL 2.1 support.",
"Allows the game to downsample from a higher resolution\nthan your display in OpenGL renderer mode.\nThis can be set to automatically enable if the game resolution\nis higher than the current Display Resolution\nor enabled at all times.\nThis may improve performance in some cases.\nRequires a GPU with atleast OpenGL 2.1 support.",
#endif
"Change the bit depth of the Lookup Palette in Palette rendering mode\n 16 bits is like software looks ingame\nwhile 24 bits is how software looks in screenshots.",
#endif
+7 -7
View File
@@ -2312,7 +2312,7 @@ void A_1upThinker(void *thing)
}
}
if (closestplayer == -1 || skins[players[closestplayer].skin].spritedef.numframes <= states[S_PLAY_BOX1].frame)
if (closestplayer == -1 || skins[players[closestplayer].skin]->spritedef.numframes <= states[S_PLAY_BOX1].frame)
{ // Closest player not found (no players in game?? may be empty dedicated server!), or does not have correct sprite.
actor->frame = 0;
@@ -2337,7 +2337,7 @@ void A_1upThinker(void *thing)
}
actor->tracer->color = players[closestplayer].mo->color;
actor->tracer->skin = &skins[players[closestplayer].skin];
actor->tracer->skin = skins[players[closestplayer].skin];
}
// Function: A_MonitorPop
@@ -2436,7 +2436,7 @@ void A_MonitorPop(void *thing)
if (actor->tracer) // Remove the old lives icon.
P_RemoveMobj(actor->tracer);
if (!newmobj->target->skin || ((skin_t *)newmobj->target->skin)->spritedef.numframes <= states[S_PLAY_BOX1].frame)
if (!newmobj->target->skin || newmobj->target->skin->spritedef.numframes <= states[S_PLAY_BOX1].frame)
newmobj->frame -= 2; // No lives icon for this player, use the default.
else
{ // Spawn the lives icon.
@@ -2448,7 +2448,7 @@ void A_MonitorPop(void *thing)
P_SetTarget(&newmobj->tracer, remains);
remains->color = newmobj->target->player->mo->color;
remains->skin = &skins[newmobj->target->player->skin];
remains->skin = skins[newmobj->target->player->skin];
P_SetMobjState(remains, newmobj->info->seestate);
}
}
@@ -3995,14 +3995,14 @@ void A_SignPlayer(void *thing)
P_SetTarget(&ov->target, actor);
ov->color = actor->target->player->skincolor;
ov->skin = &skins[actor->target->player->skin];
ov->skin = skins[actor->target->player->skin];
// needs - 1 or else it pukes an error out
// same thing happens on p_mobj.c
if (actor->target->skinlocal)
ov->localskin = &localskins[actor->target->player->localskin - 1];
ov->localskin = localskins[actor->target->player->localskin - 1];
else if (actor->target->player->localskin)
ov->localskin = &skins[actor->target->player->localskin - 1];
ov->localskin = skins[actor->target->player->localskin - 1];
ov->skinlocal = actor->target->skinlocal;
P_SetMobjState(ov, actor->info->seestate); // S_PLAY_SIGN
+3 -3
View File
@@ -6154,7 +6154,7 @@ angle_t P_MobjPitchAndRoll(mobj_t *mobj)
if (mobj->skin && mobj->sprite == SPR_PLAY)
{
sprdef = &((skin_t *)mobj->skin)->spritedef;
sprdef = &mobj->skin->spritedef;
if (rot >= sprdef->numframes)
sprdef = &sprites[mobj->sprite];
@@ -10958,9 +10958,9 @@ void P_SpawnPlayer(INT32 playernum)
// set 'spritedef' override in mobj for player skins.. (see ProjectSprite)
// (usefulness: when body mobj is detached from player (who respawns),
// the dead body mobj retains the skin through the 'spritedef' override).
mobj->skin = &skins[p->skin];
mobj->skin = skins[p->skin];
mobj->localskin = (p->localskin ? K_GetPlayerSkin(p) : NULL);
mobj->localskin = (p->localskin ? R_GetPlayerSkin(p) : NULL);
mobj->skinlocal = p->skinlocal;
mobj->health = p->health;
+5 -3
View File
@@ -265,6 +265,8 @@ typedef enum {
} precipflag_t;
typedef struct skin_s skin_t;
// Map Object definition.
typedef struct mobj_s
{
@@ -340,9 +342,9 @@ typedef struct mobj_s
struct mobj_s *hnext;
struct mobj_s *hprev;
void *skin; // overrides 'sprite' when non-NULL (for player bodies to 'remember' the skin)
void *localskin;
boolean skinlocal;
skin_t *skin; // overrides 'sprite' when non-NULL (for player bodies to 'remember' the skin)
skin_t *localskin;
boolean skinlocal; // if the skin is from a LOCALLY loaded skin
// Player and mobj sprites in multiplayer modes are modified
// using an internal color lookup table for re-indexing.
+2 -2
View File
@@ -1344,7 +1344,7 @@ static void SaveMobjThinker(savebuffer_t *save, const thinker_t *th, const UINT8
if (diff2 & MD2_CVMEM)
WRITEINT32(save->p, mobj->cvmem);
if (diff2 & MD2_SKIN)
WRITESKIN(save->p, (skinnum_t)((skin_t *)mobj->skin - skins));
WRITESKIN(save->p, (skinnum_t)mobj->skin->skinnum);
if (diff2 & MD2_COLOR)
WRITEUINT8(save->p, mobj->color);
if (diff2 & MD2_EXTVAL1)
@@ -2221,7 +2221,7 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker)
if (diff2 & MD2_CVMEM)
mobj->cvmem = READINT32(save->p);
if (diff2 & MD2_SKIN)
mobj->skin = &skins[READSKIN(save->p)];
mobj->skin = skins[READSKIN(save->p)];
if (diff2 & MD2_COLOR)
mobj->color = READUINT8(save->p);
if (diff2 & MD2_EXTVAL1)
+18 -18
View File
@@ -2483,28 +2483,28 @@ static void P_ForceCharacter(const char *forcecharskin)
if (splitscreen)
{
SetPlayerSkin(displayplayers[1], forcecharskin);
if ((unsigned)cv_playercolor2.value != skins[players[displayplayers[1]].skin].prefcolor && !modeattacking)
if ((unsigned)cv_playercolor2.value != skins[players[displayplayers[1]].skin]->prefcolor && !modeattacking)
{
CV_StealthSetValue(&cv_playercolor2, skins[players[displayplayers[1]].skin].prefcolor);
players[displayplayers[1]].skincolor = skins[players[displayplayers[1]].skin].prefcolor;
CV_StealthSetValue(&cv_playercolor2, skins[players[displayplayers[1]].skin]->prefcolor);
players[displayplayers[1]].skincolor = skins[players[displayplayers[1]].skin]->prefcolor;
}
if (splitscreen > 1)
{
SetPlayerSkin(displayplayers[2], forcecharskin);
if ((unsigned)cv_playercolor3.value != skins[players[displayplayers[2]].skin].prefcolor && !modeattacking)
if ((unsigned)cv_playercolor3.value != skins[players[displayplayers[2]].skin]->prefcolor && !modeattacking)
{
CV_StealthSetValue(&cv_playercolor3, skins[players[displayplayers[2]].skin].prefcolor);
players[displayplayers[2]].skincolor = skins[players[displayplayers[2]].skin].prefcolor;
CV_StealthSetValue(&cv_playercolor3, skins[players[displayplayers[2]].skin]->prefcolor);
players[displayplayers[2]].skincolor = skins[players[displayplayers[2]].skin]->prefcolor;
}
if (splitscreen > 2)
{
SetPlayerSkin(displayplayers[3], forcecharskin);
if ((unsigned)cv_playercolor4.value != skins[players[displayplayers[3]].skin].prefcolor && !modeattacking)
if ((unsigned)cv_playercolor4.value != skins[players[displayplayers[3]].skin]->prefcolor && !modeattacking)
{
CV_StealthSetValue(&cv_playercolor4, skins[players[displayplayers[3]].skin].prefcolor);
players[displayplayers[3]].skincolor = skins[players[displayplayers[3]].skin].prefcolor;
CV_StealthSetValue(&cv_playercolor4, skins[players[displayplayers[3]].skin]->prefcolor);
players[displayplayers[3]].skincolor = skins[players[displayplayers[3]].skin]->prefcolor;
}
}
}
@@ -2512,10 +2512,10 @@ static void P_ForceCharacter(const char *forcecharskin)
SetPlayerSkin(consoleplayer, forcecharskin);
// normal player colors in single player
if ((unsigned)cv_playercolor.value != skins[players[consoleplayer].skin].prefcolor && !modeattacking)
if ((unsigned)cv_playercolor.value != skins[players[consoleplayer].skin]->prefcolor && !modeattacking)
{
CV_StealthSetValue(&cv_playercolor, skins[players[consoleplayer].skin].prefcolor);
players[consoleplayer].skincolor = skins[players[consoleplayer].skin].prefcolor;
CV_StealthSetValue(&cv_playercolor, skins[players[consoleplayer].skin]->prefcolor);
players[consoleplayer].skincolor = skins[players[consoleplayer].skin]->prefcolor;
}
}
}
@@ -2542,8 +2542,8 @@ static void P_LoadRecordGhosts(void)
if (cv_ghost_besttime.value == 1 && players[consoleplayer].skin != i)
continue;
if (FIL_FileExists(va("%s-%s-time-best.lmp", gpath, skins[i].name)))
G_AddGhost(va("%s-%s-time-best.lmp", gpath, skins[i].name));
if (FIL_FileExists(va("%s-%s-time-best.lmp", gpath, skins[i]->name)))
G_AddGhost(va("%s-%s-time-best.lmp", gpath, skins[i]->name));
}
}
@@ -2555,8 +2555,8 @@ static void P_LoadRecordGhosts(void)
if (cv_ghost_bestlap.value == 1 && players[consoleplayer].skin != i)
continue;
if (FIL_FileExists(va("%s-%s-lap-best.lmp", gpath, skins[i].name)))
G_AddGhost(va("%s-%s-lap-best.lmp", gpath, skins[i].name));
if (FIL_FileExists(va("%s-%s-lap-best.lmp", gpath, skins[i]->name)))
G_AddGhost(va("%s-%s-lap-best.lmp", gpath, skins[i]->name));
}
}
@@ -2568,8 +2568,8 @@ static void P_LoadRecordGhosts(void)
if (cv_ghost_last.value == 1 && players[consoleplayer].skin != i)
continue;
if (FIL_FileExists(va("%s-%s-last.lmp", gpath, skins[i].name)))
G_AddGhost(va("%s-%s-last.lmp", gpath, skins[i].name));
if (FIL_FileExists(va("%s-%s-last.lmp", gpath, skins[i]->name)))
G_AddGhost(va("%s-%s-last.lmp", gpath, skins[i]->name));
}
}
+2 -2
View File
@@ -498,7 +498,7 @@ void P_PlayRinglossSound(mobj_t *source, mobj_t *damager)
// I HATE LOCALSKINS! I HATE LOCALSKINS! :AAAAAAAAAA:
if (source->player)
sfx = K_GetPlayerSkin(source->player)->soundsid[SKSKPAN1 + key];
sfx = R_GetPlayerSkin(source->player)->soundsid[SKSKPAN1 + key];
S_StartSound(NULL, sfx);
}
@@ -1271,7 +1271,7 @@ void P_DoPlayerExit(player_t *player)
if (islocalplayer)
{
sfxenum_t sfx_id = K_GetMobjSkin(player->mo)->soundsid[S_sfx[soundid].skinsound];
sfxenum_t sfx_id = R_GetMobjSkin(player->mo)->soundsid[S_sfx[soundid].skinsound];
S_StartSound(NULL, sfx_id);
}
else
+3
View File
@@ -504,6 +504,9 @@ typedef struct subsector_s
void *splats; // floorsplat_t list
#endif
size_t validcount;
#ifdef HWRENDER
boolean hashorizon; // not really needed for software, this stuff works differently there
#endif
} subsector_t;
// Sector list node showing all sectors an object appears in.
+72 -64
View File
@@ -94,19 +94,18 @@ spandrawfunc_t *spanfuncs[SPANDRAWFUNC_MAX] = {};
// TRANSLATION COLORMAP CODE
// =========================================================================
#define DEFAULT_TT_CACHE_INDEX MAXSKINS
#define BOSS_TT_CACHE_INDEX (MAXSKINS + 1)
#define METALSONIC_TT_CACHE_INDEX (MAXSKINS + 2)
#define ALLWHITE_TT_CACHE_INDEX (MAXSKINS + 3)
#define RAINBOW_TT_CACHE_INDEX (MAXSKINS + 4)
#define BLINK_TT_CACHE_INDEX (MAXSKINS + 5)
#define TT_CACHE_SIZE (MAXSKINS + 6)
#define DEFAULT_TT_CACHE_INDEX 0
#define BOSS_TT_CACHE_INDEX 1
#define METALSONIC_TT_CACHE_INDEX 2
#define ALLWHITE_TT_CACHE_INDEX 3
#define RAINBOW_TT_CACHE_INDEX 4
#define BLINK_TT_CACHE_INDEX 5
#define TT_CACHE_SIZE 6
#define SKIN_RAMP_LENGTH 16
#define DEFAULT_STARTTRANSCOLOR 160
#define NUM_PALETTE_ENTRIES 256
static UINT8 **translationtablecache[TT_CACHE_SIZE] = {};
static UINT8 **localtranslationtablecache[MAXLOCALSKINS] = {};
static UINT8 **specialtranslationtablecache[TT_CACHE_SIZE] = {};
CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1] = {};
@@ -378,38 +377,60 @@ static UINT8* RGetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 f
{
UINT8 ***tt;
UINT8* ret;
INT32 skintableindex;
if (local)
{
tt = localtranslationtablecache;
skintableindex = skinnum;
I_Assert(skinnum >= 0 && skinnum < numlocalskins);
tt = &localskins[skinnum]->translationtablecache;
}
else
{
tt = translationtablecache;
// Adjust if we want the default colormap
switch (skinnum)
if (skinnum < 0)
{
case TC_DEFAULT: skintableindex = DEFAULT_TT_CACHE_INDEX; break;
case TC_BOSS: skintableindex = BOSS_TT_CACHE_INDEX; break;
case TC_METALSONIC: skintableindex = METALSONIC_TT_CACHE_INDEX; break;
case TC_ALLWHITE: skintableindex = ALLWHITE_TT_CACHE_INDEX; break;
case TC_RAINBOW: skintableindex = RAINBOW_TT_CACHE_INDEX; break;
case TC_BLINK: skintableindex = BLINK_TT_CACHE_INDEX; break;
default: skintableindex = skinnum; break;
INT32 skintableindex;
switch (skinnum)
{
case TC_DEFAULT:
skintableindex = DEFAULT_TT_CACHE_INDEX;
break;
case TC_BOSS:
skintableindex = BOSS_TT_CACHE_INDEX;
break;
case TC_METALSONIC:
skintableindex = METALSONIC_TT_CACHE_INDEX;
break;
case TC_ALLWHITE:
skintableindex = ALLWHITE_TT_CACHE_INDEX;
break;
case TC_RAINBOW:
skintableindex = RAINBOW_TT_CACHE_INDEX;
break;
case TC_BLINK:
skintableindex = BLINK_TT_CACHE_INDEX;
break;
default:
return NULL;
}
tt = &specialtranslationtablecache[skintableindex];
}
else
{
I_Assert(skinnum >= 0 && skinnum < numskins);
tt = &skins[skinnum]->translationtablecache;
}
}
if (flags & GTC_CACHE)
{
// Allocate table for skin if necessary
if (!tt[skintableindex])
tt[skintableindex] = static_cast<UINT8**>(Z_Calloc(MAXTRANSLATIONS * sizeof(UINT8**), PU_STATIC, NULL));
if (!*tt)
*tt = static_cast<UINT8**>(Z_Calloc(MAXTRANSLATIONS * sizeof(UINT8**), PU_STATIC, NULL));
// Get colormap
ret = tt[skintableindex][color];
ret = (*tt)[color];
}
else
ret = NULL;
@@ -418,11 +439,11 @@ static UINT8* RGetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 f
if (!ret)
{
ret = static_cast<UINT8*>(Z_Malloc(NUM_PALETTE_ENTRIES, PU_STATIC, NULL));
K_GenerateKartColormap(ret, skinnum, color, local); //R_GenerateTranslationColormap(ret, skinnum, color); // SRB2kart
K_GenerateKartColormap(ret, skinnum, color, local); // R_GenerateTranslationColormap(ret, skinnum, color); // SRB2kart
// Cache the colormap if desired
if (flags & GTC_CACHE)
tt[skintableindex][color] = ret;
(*tt)[color] = ret;
}
return ret;
@@ -435,46 +456,26 @@ UINT8* R_GetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 flags)
UINT8* R_GetLocalTranslationColormap(skin_t *skin, skin_t *localskin, skincolors_t color, UINT8 flags, boolean local)
{
return RGetTranslationColormap(K_GetMobjLocalSkinNum(skin, localskin, local), color, flags, (localskin && local));
const INT32 skinnum = (INT32)((localskin && local) ? localskin->skinnum : (skin != NULL ? skin->skinnum : 0));
return RGetTranslationColormap(skinnum, color, flags, (localskin && local));
}
patch_t* R_GetSkinFaceRank(player_t* ply)
patch_t* R_GetSkinFaceRank(player_t* player)
{
if (ply->localskin)
{
if (ply->skinlocal)
return localfacerankprefix[ply->localskin - 1];
return facerankprefix[ply->localskin - 1];
}
return facerankprefix[ply->skin];
const skin_t *skin = R_GetPlayerSkin(player);
return skin->facerankprefix;
}
patch_t* R_GetSkinFaceWant(player_t* ply)
patch_t* R_GetSkinFaceWant(player_t* player)
{
if (ply->localskin)
{
if (ply->skinlocal)
return localfacewantprefix[ply->localskin - 1];
return facewantprefix[ply->localskin - 1];
}
return facewantprefix[ply->skin];
const skin_t *skin = R_GetPlayerSkin(player);
return skin->facewantprefix;
}
patch_t* R_GetSkinFaceMini(player_t* ply)
patch_t* R_GetSkinFaceMini(player_t* player)
{
if (ply->localskin)
{
if (ply->skinlocal)
return localfacemmapprefix[ply->localskin - 1];
return facemmapprefix[ply->localskin - 1];
}
return facemmapprefix[ply->skin];
const skin_t *skin = R_GetPlayerSkin(player);
return skin->facemmapprefix;
}
/** \brief Flushes cache of translation colormaps.
@@ -493,13 +494,20 @@ void R_FlushTranslationColormapCache(void)
{
INT32 i;
for (i = 0; i < (INT32)(sizeof(translationtablecache) / sizeof(translationtablecache[0])); i++)
if (translationtablecache[i])
memset(translationtablecache[i], 0, MAXTRANSLATIONS * sizeof(UINT8**));
// skin cache
for (i = 0; i < (INT32)numskins; i++)
if (skins[i]->translationtablecache)
memset(skins[i]->translationtablecache, 0, MAXTRANSLATIONS * sizeof(UINT8**));
for (i = 0; i < (INT32)(sizeof(localtranslationtablecache) / sizeof(localtranslationtablecache[0])); i++)
if (localtranslationtablecache[i])
memset(localtranslationtablecache[i], 0, MAXTRANSLATIONS * sizeof(UINT8**));
// localskin cache
for (i = 0; i < (INT32)numlocalskins; i++)
if (localskins[i]->translationtablecache)
memset(localskins[i]->translationtablecache, 0, MAXTRANSLATIONS * sizeof(UINT8**));
// special cache
for (i = 0; i < (INT32)(sizeof(specialtranslationtablecache) / sizeof(specialtranslationtablecache[0])); i++)
if (specialtranslationtablecache[i])
memset(specialtranslationtablecache[i], 0, MAXTRANSLATIONS * sizeof(UINT8**));
}
*/
+1 -1
View File
@@ -389,7 +389,7 @@ angle_t R_PlayerSliptideAngle(player_t *player)
if (mo->skin && mo->sprite == SPR_PLAY)
{
sprdef = &((skin_t *)mo->skin)->spritedef;
sprdef = &mo->skin->spritedef;
if (rot >= sprdef->numframes)
sprdef = &sprites[mo->sprite];
+4 -4
View File
@@ -129,8 +129,8 @@ static void R_ParseSpriteInfo(boolean spr2)
spritenum_t sprnum = NUMSPRITES;
//playersprite_t spr2num = NUMPLAYERSPRITES;
INT32 i;
INT32 skinnumbers[MAXSKINS]; // >variable 'skinnumbers' set but not used >compile error when commented out
INT32 foundskins = 0;
CLEANUP(pfree) INT32 *skinnumbers = (INT32 *)calloc(1, numallskins); // could realloc this for foundskins but this is simpler
// Sprite name
sprinfoToken = M_GetToken(NULL);
@@ -236,10 +236,10 @@ static void R_ParseSpriteInfo(boolean spr2)
{
size_t skinnum = skinnumbers[i];
skin_t *skin;
if (allskins[skinnum].localskin)
skin = &localskins[allskins[skinnum].localnum];
if (allskins[skinnum]->localskin)
skin = localskins[allskins[skinnum]->skinnum];
else
skin = &skins[allskins[skinnum].localnum];
skin = skins[allskins[skinnum]->skinnum];
memcpy(&skin->sprinfo, info, sizeof(spriteinfo_t));
}
}
+102 -63
View File
@@ -40,7 +40,9 @@ CV_PossibleValue_t Forceskin_cons_t[MAXSKINS+2] = {}; // huehuehuehuehue
INT32 numskins = 0;
INT32 numallskins = 0;
INT32 numlocalskins = 0;
skin_t skins[MAXSKINS];
skin_t **skins = NULL;
skin_t **localskins = NULL;
skin_t **allskins = NULL;
skinnum_t skinstats[9][9][MAXSKINS];
skinnum_t skinstatscount[9][9] = {
@@ -56,17 +58,8 @@ skinnum_t skinstatscount[9][9] = {
};
skinnum_t skinsorted[MAXSKINS] = {};
skin_t localskins[MAXLOCALSKINS] = {};
skin_t allskins[MAXSKINS+MAXLOCALSKINS] = {};
// FIXTHIS: don't work because it must be inistilised before the config load
//#define SKINVALUES
#ifdef SKINVALUES
CV_PossibleValue_t skin_cons_t[MAXSKINS+1] = {};
CV_PossibleValue_t localskin_cons_t[MAXLOCALSKINS+1] = {};
#endif
static void Sk_SetDefaultValue(skin_t *skin, boolean local)
static void Sk_SetDefaultValue(skin_t *skin)
{
INT32 i;
//
@@ -74,7 +67,7 @@ static void Sk_SetDefaultValue(skin_t *skin, boolean local)
//
memset(skin, 0, sizeof(skin_t));
snprintf(skin->name, sizeof skin->name, "skin %u", K_GetMobjSkinNum(skin, local));
snprintf(skin->name, sizeof skin->name, "skin %u", skin->skinnum); // this will always be "skin 0" cause of the memset above lmao
skin->name[sizeof skin->name - 1] = '\0';
skin->wadnum = INT16_MAX;
@@ -112,35 +105,22 @@ static void Sk_SetDefaultValue(skin_t *skin, boolean local)
void R_InitSkins(void)
{
skin_t *skin;
#ifdef SKINVALUES
INT32 i;
for (i = 0; i <= MAXSKINS; i++)
{
skin_cons_t[i].value = 0;
skin_cons_t[i].strvalue = NULL;
}
for (i = 0; i <= MAXLOCALSKINS; i++)
{
localskin_cons_t[i].value = 0;
localskin_cons_t[i].strvalue = NULL;
}
#endif
skins = Z_Calloc(sizeof(skin_t *), PU_STATIC, NULL);
//localskins = Z_Calloc(sizeof(skin_t *), PU_STATIC, NULL);
allskins = Z_Calloc(sizeof(skin_t *), PU_STATIC, NULL);
// skin[0] = Sonic skin
skin = &skins[0];
numskins = 1;
Sk_SetDefaultValue(skin, false);
skin = skins[0] = Z_Calloc(sizeof(skin_t), PU_STATIC, NULL);
Sk_SetDefaultValue(skin);
skin->skinnum = 0;
memset(skinstats, 0, sizeof(skinstats));
memset(skinsorted, 0, sizeof(skinsorted));
// Hardcoded S_SKIN customizations for Sonic.
strcpy(skin->name, DEFAULTSKIN);
#ifdef SKINVALUES
skin_cons_t[0].strvalue = skins[0].name;
#endif
strcpy(skin->realname, "Sonic");
strcpy(skin->hudname, "SONIC");
@@ -153,7 +133,6 @@ void R_InitSkins(void)
skin->wadnum = 0; // god what have you brought to this world
skin->prefcolor = SKINCOLOR_BLUE;
skin->localskin = false;
skin->localnum = 0;
// SRB2kart
skin->kartspeed = 8;
@@ -163,7 +142,7 @@ void R_InitSkins(void)
skin->spritedef.numframes = sprites[SPR_PLAY].numframes;
skin->spritedef.spriteframes = sprites[SPR_PLAY].spriteframes;
skin->sprinfo = spriteinfo[SPR_PLAY];
ST_LoadFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, 0);
ST_LoadFaceGraphics(skin);
// Set values for Sonic skin
Forceskin_cons_t[1].value = 0;
@@ -177,6 +156,8 @@ void R_InitSkins(void)
// lets set it
allskins[0] = skins[0];
numskins = 1;
numallskins = 1;
}
@@ -188,7 +169,7 @@ INT32 R_SkinAvailable(const char *name)
for (i = 0; i < numskins; i++)
{
if (fasticmp(skins[i].name, name))
if (fasticmp(skins[i]->name, name))
return i;
}
@@ -203,7 +184,7 @@ INT32 R_AnySkinAvailable(const char *name)
for (i = 0; i < numallskins; i++)
{
if (fasticmp(allskins[i].name, name))
if (fasticmp(allskins[i]->name, name))
return i;
}
@@ -218,7 +199,7 @@ INT32 R_LocalSkinAvailable(const char *name, boolean local)
{
for (i = 0; i < numlocalskins; i++)
{
if (fasticmp(localskins[i].name, name))
if (fasticmp(localskins[i]->name, name))
return i;
}
@@ -236,7 +217,7 @@ boolean SetPlayerSkin(INT32 playernum, const char *skinname)
for (i = 0; i < numskins; i++)
{
// search in the skin list
if (fasticmp(skins[i].name, skinname))
if (fasticmp(skins[i]->name, skinname))
{
SetPlayerSkinByNum(playernum, i);
return true;
@@ -262,14 +243,14 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar)
for (i = 0; i < numlocalskins; i++)
{
// search in the localskin list
if (fasticmp(localskins[i].name, skinname))
if (fasticmp(localskins[i]->name, skinname))
{
player->localskin = 1 + i;
player->skinlocal = true;
if (player->mo)
{
player->mo->localskin = &localskins[i];
player->mo->localskin = localskins[i];
player->mo->skinlocal = true;
}
@@ -280,14 +261,14 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar)
for (i = 0; i < numskins; i++)
{
// search in the skin list
if (fasticmp(skins[i].name, skinname))
if (fasticmp(skins[i]->name, skinname))
{
player->localskin = 1 + i;
player->skinlocal = false;
if (player->mo)
{
player->mo->localskin = &skins[i];
player->mo->localskin = skins[i];
player->mo->skinlocal = false;
}
@@ -312,9 +293,9 @@ setcvar:
{
if (player->localskin > 0)
{
CV_StealthSet(&cv_fakelocalskin, K_GetSkinArray(player->skinlocal)[player->localskin-1].name);
CV_StealthSet(cvar, K_GetSkinArray(player->skinlocal)[player->localskin-1].name);
skin_t *lskin = R_GetSkinArray(player->skinlocal)[player->localskin-1];
CV_StealthSet(&cv_fakelocalskin, lskin->name);
CV_StealthSet(cvar, lskin->name);
}
else
{
@@ -329,10 +310,12 @@ setcvar:
void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum)
{
player_t *player = &players[playernum];
skin_t *skin = &skins[skinnum];
skin_t *skin;
if (skinnum >= 0 && skinnum < numskins) // Make sure it exists!
{
skin = skins[skinnum];
player->skin = skinnum;
if (player->mo)
@@ -400,8 +383,8 @@ static int skinSortFunc(const void *a, const void *b) // tbh i have no clue what
int diff = 0;
const skinnum_t val_a = *(const skinnum_t *)a;
const skinnum_t val_b = *(const skinnum_t *)b;
const skin_t *in1 = &skins[val_a];
const skin_t *in2 = &skins[val_b];
const skin_t *in1 = skins[val_a];
const skin_t *in2 = skins[val_b];
// return (strcmp(in1->realname, in2->realname) < 0) || (strcmp(in1->realname, in2->realname) ==);
@@ -488,7 +471,7 @@ void R_AddSkins(UINT16 wadnum, boolean local)
char *stoken;
char *value;
size_t size;
skin_t *skin;
skin_t *skin = NULL;
boolean hudname, realname;
#define lnumskins (local ? numlocalskins : numskins)
@@ -502,16 +485,18 @@ void R_AddSkins(UINT16 wadnum, boolean local)
// advance by default
lastlump = lump + 1;
// gotta keep this for vanilla compat reasons
if (!local && numskins >= MAXSKINS)
{
CONS_Alert(CONS_WARNING, M_GetText("Unable to add skin, too many characters are loaded (%d maximum)\n"), MAXSKINS);
continue; // so we know how many skins couldn't be added
}
if (local && numlocalskins >= MAXLOCALSKINS)
/* if (local && numlocalskins >= MAXLOCALSKINS)
{
CONS_Alert(CONS_WARNING, M_GetText("Unable to add localskin, too many localskins are loaded (%d maximum)\n"), MAXLOCALSKINS);
continue; // so we know how many skins couldn't be added
}
} */
buf = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE);
size = W_LumpLengthPwad(wadnum, lump);
@@ -524,8 +509,19 @@ void R_AddSkins(UINT16 wadnum, boolean local)
buf2[size] = '\0';
// set defaults
skin = &K_GetSkinArray(local)[lnumskins];
Sk_SetDefaultValue(skin, local);
if (!local)
{
skins = Z_Realloc(skins, sizeof(skin_t *) * (numskins + 1), PU_STATIC, NULL);
}
else
{
localskins = Z_Realloc(localskins, sizeof(skin_t *) * (numlocalskins + 1), PU_STATIC, NULL);
}
skin = R_GetSkinArray(local)[lnumskins] = Z_Calloc(sizeof(skin_t), PU_STATIC, NULL);
Sk_SetDefaultValue(skin);
skin->skinnum = lnumskins;
skin->allskinnum = numallskins;
skin->wadnum = wadnum;
hudname = realname = false;
@@ -777,24 +773,19 @@ void R_AddSkins(UINT16 wadnum, boolean local)
//R_FlushTranslationColormapCache();
CONS_Printf(M_GetText("Added skin '%s'\n"), skin->name);
#ifdef SKINVALUES
(local ? localskin_cons_t : skin_cons_t)[lnumskins].value = lnumskins;
(local ? localskin_cons_t : skin_cons_t)[lnumskins].strvalue = skin->name;
#endif
if (!local)
{
// Update the forceskin possiblevalues
Forceskin_cons_t[numskins+1].value = numskins;
Forceskin_cons_t[numskins+1].strvalue = skins[numskins].name;
Forceskin_cons_t[numskins+1].strvalue = skins[numskins]->name;
skin->localskin = false;
skin->localnum = numskins;
ST_LoadFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, numskins);
ST_LoadFaceGraphics(skin);
}
else
{
skin->localskin = true;
skin->localnum = numlocalskins;
ST_LoadLocalFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, numlocalskins);
ST_LoadFaceGraphics(skin);
}
#ifdef HWRENDER
@@ -810,7 +801,8 @@ void R_AddSkins(UINT16 wadnum, boolean local)
skinsorted[numskins] = numskins;
}
allskins[numallskins] = K_GetSkinArray(local)[lnumskins];
allskins = Z_Realloc(allskins, sizeof(skin_t*) * (numallskins + 1), PU_STATIC, NULL);
allskins[numallskins] = R_GetSkinArray(local)[lnumskins];
local ? numlocalskins++ : numskins++;
numallskins++;
@@ -820,3 +812,50 @@ void R_AddSkins(UINT16 wadnum, boolean local)
return;
}
// Helper functions for skin stuff
//
// returns the skin array to use
// accounts for localskins
//
skin_t **R_GetSkinArray(boolean local)
{
return local ? localskins : skins;
}
//
// returns the players skinnumber
// accounts for localskins
//
INT32 R_GetPlayerSkinNum(player_t *player)
{
return player->localskin ? (player->localskin - 1) : player->skin;
}
//
// returns the players skin
// accounts for localskins
//
skin_t *R_GetPlayerSkin(player_t *player)
{
return R_GetSkinArray(player->skinlocal)[R_GetPlayerSkinNum(player)];
}
//
// returns the mobj skinnumber
// accounts for localskins
//
INT32 R_GetMobjSkinNum(const mobj_t *mobj)
{
return mobj->localskin ? mobj->localskin->skinnum : mobj->skin->skinnum;
}
//
// returns the mobjs skin
// accounts for localskins
//
skin_t *R_GetMobjSkin(const mobj_t *mobj)
{
return mobj->localskin ? mobj->localskin : mobj->skin;
}
+26 -13
View File
@@ -16,6 +16,7 @@
#ifndef __R_SKINS__
#define __R_SKINS__
#include "doomtype.h"
#ifdef __cplusplus
extern "C" {
#endif
@@ -24,6 +25,10 @@ extern "C" {
#include "sounds.h"
#include "r_patch.h"
#ifdef HWRENDER
#include "hardware/hw_md2.h"
#endif
// "Left" and "Right" character symbols for additional rotation functionality
#define ROT_L ('L' - '0')
#define ROT_R ('R' - '0')
@@ -35,7 +40,7 @@ extern "C" {
#define DEFAULTSKIN3 "knuckles" // third player
#define DEFAULTSKIN4 "eggman" // fourth player
typedef struct
typedef struct skin_s
{
char name[SKINNAMESIZE+1]; // INT16 descriptive name of the skin
spritedef_t spritedef;
@@ -48,12 +53,17 @@ typedef struct
char hudname[SKINNAMESIZE+1]; // HUD name to display (officially exactly 5 characters long)
char facerank[9], facewant[9], facemmap[9]; // Arbitrarily named patch lumps
patch_t *facerankprefix; // ranking
patch_t *facewantprefix; // wanted
patch_t *facemmapprefix; // minimap
// SRB2kart
UINT8 kartspeed;
UINT8 kartweight;
//
// Definable color translation table
UINT8 **translationtablecache;
UINT8 starttranscolor;
UINT8 prefcolor;
fixed_t highresscale; // scale of highres, default is 0.5
@@ -61,8 +71,13 @@ typedef struct
// specific sounds per skin
sfxenum_t soundsid[NUMSKINSOUNDS]; // sound # in S_sfx table
#ifdef HWRENDER
md2_t playermodel;
#endif
boolean localskin;
INT32 localnum;
skinnum_t skinnum;
UINT16 allskinnum;
} skin_t;
extern CV_PossibleValue_t Forceskin_cons_t[];
@@ -70,14 +85,14 @@ extern CV_PossibleValue_t Forceskin_cons_t[];
extern INT32 numskins;
extern INT32 numlocalskins;
extern INT32 numallskins;
extern skin_t skins[MAXSKINS];
extern skin_t **skins;
extern skin_t **localskins;
extern skin_t **allskins;
extern skinnum_t skinstats[9][9][MAXSKINS];
extern skinnum_t skinstatscount[9][9];
extern skinnum_t skinsorted[MAXSKINS];
extern skin_t localskins[MAXLOCALSKINS];
extern skin_t allskins[MAXSKINS+MAXLOCALSKINS];
//faB: find sprites in wadfile, replace existing, add new ones
// (only sprites from namelist are added or replaced)
void R_AddSpriteDefs(UINT16 wadnum);
@@ -90,13 +105,11 @@ INT32 R_AnySkinAvailable(const char *name);
INT32 R_LocalSkinAvailable(const char *name, boolean local);
// had to move those here Zzz...
INT32 K_GetSkinNum(player_t *player);
INT32 K_GetMobjSkinNum(const skin_t *skin, boolean local);
INT32 K_GetMobjLocalSkinNum(const skin_t *skin, const skin_t *localskin, boolean local);
skin_t *K_GetPlayerSkin(player_t *player);
skin_t *K_GetMobjSkin(const mobj_t *mobj);
patch_t *K_GetFacePrefix(player_t *player, INT32 skinnum);
skin_t *K_GetSkinArray(boolean local);
skin_t **R_GetSkinArray(boolean local);
skin_t *R_GetPlayerSkin(player_t *player);
INT32 R_GetPlayerSkinNum(player_t *player);
INT32 R_GetMobjSkinNum(const mobj_t *mobj);
skin_t *R_GetMobjSkin(const mobj_t *mobj);
void sortSkinGrid(void);
+1 -1
View File
@@ -1276,7 +1276,7 @@ static void R_ProjectSprite(mobj_t *thing)
const boolean shouldrotate = (interp.sloperoll || interp.slopepitch || interp.roll || interp.pitch || thing->rollangle || thing->temprollangle || sliprollrotate);
#endif
sprskin = K_GetMobjSkin(thing);
sprskin = R_GetMobjSkin(thing);
//Fab : 02-08-98: 'skin' override spritedef currently used for skin
if (sprskin && thing->sprite == SPR_PLAY)
+1 -1
View File
@@ -529,7 +529,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume)
if (sfx->skinsound != -1 && origin && origin->skin)
{
// redirect player sound to the sound in the skin table
sfx_id = K_GetMobjSkin(origin)->soundsid[sfx->skinsound];
sfx_id = R_GetMobjSkin(origin)->soundsid[sfx->skinsound];
sfx = &S_sfx[sfx_id];
}
+34 -104
View File
@@ -97,11 +97,9 @@ static char vidModeName[33][32]; // allow 33 different modes
rendermode_t rendermode = render_none;
#ifdef HWRENDER
unsigned msaa = 0;
// Eee probably the way i organize it isn't best ><
// Just don't know where do i put declaration and "implementation"
boolean a2c = false;
unsigned msaa = 0;
#endif
static void KeyboardLayout_OnChange(void)
@@ -115,10 +113,6 @@ consvar_t cv_keyboardlayout = {"keyboardlayout", "Default US", CV_SAVE|CV_CALL,
static void Impl_SetVsync(void);
static INT32 desktopwidth = 0, desktopheight = 0;
static void I_CheckDesktopRes(void);
// synchronize page flipping with screen refresh
consvar_t cv_vidwait = {"vid_wait", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Impl_SetVsync, 0, NULL, NULL, 0, 0, NULL};
static consvar_t cv_stretch = {"stretch", "Off", CV_SAVE|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -197,10 +191,6 @@ static INT32 custom_height = 0;
static SDL_bool Impl_CreateWindow(SDL_bool fullscreen);
static void Impl_SetWindowIcon(void);
#ifdef USE_FBO_OGL
boolean downsample = false;
#endif
static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code)
{
if (code >= SDL_SCANCODE_A && code <= SDL_SCANCODE_Z)
@@ -518,11 +508,11 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
return;
}
if (windowmoved && rendermode == render_opengl)
if (windowmoved)
{
I_CheckDesktopRes();
#ifdef USE_FBO_OGL
I_DownSample();
if (rendermode == render_opengl)
I_CheckDownSampleState(false);
#endif
windowmoved = SDL_FALSE;
}
@@ -1229,9 +1219,7 @@ static void VID_Command_ModeList_f(void)
// List windowed modes
INT32 i = 0;
CONS_Printf("NOTE: Under SDL2, all modes are supported on all platforms.\n"
"Under opengl, fullscreen only supports native desktop resolution.\n"
"Under software, the mode is stretched up to desktop resolution.\n");
CONS_Printf("NOTE: Under SDL2, all modes are supported on all platforms.\n");
for (i = 0; i < MAXWINMODES; i++)
{
@@ -1257,78 +1245,41 @@ static void VID_Command_Mode_f (void)
setmodeneeded = modenum+1; // request vid mode change
}
// Get the desktop resolution from the current display the gamewindow resides on
static void I_CheckDesktopRes(void)
{
int currentDisplayIndex = -1;
SDL_DisplayMode curmode;
desktopwidth = 0;
desktopheight = 0;
currentDisplayIndex = SDL_GetWindowDisplayIndex(window);
// No valid index
if (currentDisplayIndex < 0)
{
return;
}
if (SDL_GetDesktopDisplayMode(currentDisplayIndex, &curmode) != 0)
{
return;
}
desktopwidth = curmode.w;
desktopheight = curmode.h;
}
// Check if the game resolution matches the desktop resolution
boolean I_CheckNativeRes(void)
{
return (vid.width == desktopwidth && vid.height == desktopheight);
}
#ifdef USE_FBO_OGL
static boolean vid_downsampling = false;
void RefreshOGLSDLSurface(void)
boolean I_IsDownsampling(void)
{
if (rendermode == render_opengl)
OglSdlSurface(vid.width, vid.height);
return vid_downsampling;
}
void I_DownSample(void)
void I_CheckDownSampleState(boolean forcerefresh)
{
boolean needrefresh = false;
if (!cv_glframebuffer.value || !supportFBO || (cv_glscreentextures.value == 0)) // no sense to do this crap if we cant benefit from it
// no fbo support so we dont care
if (!supportFBO)
{
downsample = false;
vid_downsampling = false;
return;
}
if (I_CheckNativeRes() && (downsample == true))
// no sense to do this crap if we cant benefit from it
boolean newdownsamplestate = false;
if (cv_glframebuffer.value && (cv_glscreentextures.value == 2))
{
downsample = false;
RefreshOGLSDLSurface();
return;
int sdlw, sdlh;
SDL_GetWindowSize(window, &sdlw, &sdlh);
if (vid.width > sdlw || vid.height > sdlh)
newdownsamplestate = true;
}
if ((vid.width > desktopwidth) || (vid.height > desktopheight)) //check if current resolution is higher than current display resolution
// state changed or fbo was toggled
if (vid_downsampling != newdownsamplestate || forcerefresh)
{
downsample = true;
needrefresh = true;
}
else if (downsample == true)
{
downsample = false;
needrefresh = true;
}
if (needrefresh)
{
RefreshOGLSDLSurface();
needrefresh = false;
//printf("downsample changed from %d to %d\n", vid_downsampling, newdownsamplestate);
// needs to be reset before refreshing the gl surface!
vid_downsampling = newdownsamplestate;
OglSdlSurface(vid.width, vid.height);
}
}
#endif
@@ -1360,9 +1311,10 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
// Reposition window only in windowed mode
SDL_SetWindowSize(window, width, height);
const int windowpos = SDL_GetWindowDisplayIndex(window);
SDL_SetWindowPosition(window,
SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)),
SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window))
SDL_WINDOWPOS_CENTERED_DISPLAY(windowpos),
SDL_WINDOWPOS_CENTERED_DISPLAY(windowpos)
);
}
}
@@ -1382,9 +1334,8 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
#ifdef HWRENDER
if (rendermode == render_opengl)
{
I_CheckDesktopRes();
#ifdef USE_FBO_OGL
I_DownSample();
I_CheckDownSampleState(false);
#endif
OglSdlSurface(vid.width, vid.height);
}
@@ -1580,7 +1531,7 @@ void VID_PrepareModeList(void)
static UINT32 refresh_rate;
static UINT32 VID_GetRefreshRate(void)
{
int index = SDL_GetWindowDisplayIndex(window);
int index;
SDL_DisplayMode m;
if (SDL_WasInit(SDL_INIT_VIDEO) == 0)
@@ -1589,6 +1540,8 @@ static UINT32 VID_GetRefreshRate(void)
return 0;
}
index = SDL_GetWindowDisplayIndex(window);
if (SDL_GetDesktopDisplayMode(index, &m) != 0)
{
// Error has occurred.
@@ -1825,7 +1778,6 @@ void I_StartupGraphics(void)
rendermode = render_opengl;
msaa = 0; boolean msaa_set = false;
a2c = false; boolean a2c_set = false;
// MSAA antialiasing
if (M_CheckParm("-msaa") && M_IsNextParm())
@@ -1837,16 +1789,6 @@ void I_StartupGraphics(void)
}
}
if (M_CheckParm("-a2c"))
{
a2c = true;
a2c_set = true;
}
else if (M_CheckParm("-noa2c"))
{
a2c_set = true;
}
{
char line[16];
char * word;
@@ -1890,19 +1832,10 @@ void I_StartupGraphics(void)
}
else
{
CONS_Printf("Using last know MSAA value: %u\n", msaa);
CONS_Printf("Using last known MSAA value: %u\n", msaa);
}
}
}
if (!a2c_set)
{
if (fasticmp(word, "a2c"))
{
a2c = true;
CONS_Printf("Using a2c because it was specified to be used earlier\n");
}
}
}
fclose(file);
@@ -1937,9 +1870,6 @@ void I_StartupGraphics(void)
#ifdef HWRENDER
fprintf(file, "msaa %u\n", msaa);
if (a2c)
fputs("a2c\n", file);
#endif
fclose(file);
}
+7 -13
View File
@@ -65,7 +65,7 @@ PFNglGetString pglGetString;
#ifdef USE_FBO_OGL
boolean UseScreenFBO(void)
{
return (supportFBO && cv_glframebuffer.value && downsample);
return (supportFBO && cv_glframebuffer.value && (cv_glscreentextures.value == 2) && (cv_glframebuffer.value == 2 || I_IsDownsampling()));
}
#endif
@@ -203,9 +203,9 @@ boolean OglSdlSurface(INT32 w, INT32 h)
#ifdef USE_FBO_OGL
if (UseScreenFBO())
GL_Framebuffer_Enable();
GL_FBO_Enable();
else
GL_Framebuffer_Disable();
GL_FBO_Disable();
#endif
if (!first_init)
@@ -225,7 +225,6 @@ boolean OglSdlSurface(INT32 w, INT32 h)
void OglSdlFinishUpdate(SDL_Window *window)
{
int sdlw, sdlh;
#ifdef USE_FBO_OGL
const boolean usefbo = UseScreenFBO();
#endif
@@ -235,9 +234,7 @@ void OglSdlFinishUpdate(SDL_Window *window)
#ifdef USE_FBO_OGL
if (usefbo)
{
GL_Framebuffer_Unbind();
}
GL_FBO_BindMainFrameBuffer();
#endif
if (HWR_ShouldUsePaletteRendering())
@@ -255,9 +252,7 @@ void OglSdlFinishUpdate(SDL_Window *window)
#ifdef USE_FBO_OGL
if (usefbo)
{
GL_Framebuffer_Enable();
}
GL_FBO_Enable();
#endif
SDL_GL_SwapWindow(window);
@@ -266,11 +261,10 @@ void OglSdlFinishUpdate(SDL_Window *window)
// Sryder: We need to draw the final screen texture again into the other buffer in the original position so that
// effects that want to take the old screen can do so after this
// well we dont need it on native res it seems
#ifdef USE_FBO_OGL
if ((!I_CheckNativeRes() && !usefbo) || WipeInAction)
if (!usefbo && (realwidth != sdlw || realheight != sdlh)) // not needed if fbo is in use
#else
if (!I_CheckNativeRes() || WipeInAction)
if (realwidth != sdlw || realheight != sdlh) // this is not needed if the render size matches window size
#endif
HWR_DrawScreenFinalTexture(realwidth, realheight);
}
+6 -41
View File
@@ -60,22 +60,6 @@ tic_t directortoggletimer = 0;
// STATUS BAR DATA
//
patch_t *facerankprefix[MAXSKINS] = {}; // ranking
patch_t *facewantprefix[MAXSKINS] = {}; // wanted
patch_t *facemmapprefix[MAXSKINS] = {}; // minimap
patch_t *localfacerankprefix[MAXLOCALSKINS] = {}; // ranking
patch_t *localfacewantprefix[MAXLOCALSKINS] = {}; // wanted
patch_t *localfacemmapprefix[MAXLOCALSKINS] = {}; // minimap
/*char *facerankprefix_name[MAXSKINS]; // ranking
char *facewantprefix_name[MAXSKINS]; // wanted
char *facemmapprefix_name[MAXSKINS]; // minimap
char *localfacerankprefix_name[MAXLOCALSKINS]; // ranking
char *localfacewantprefix_name[MAXLOCALSKINS]; // wanted
char *localfacemmapprefix_name[MAXLOCALSKINS]; // minimap*/
// ------------------------------------------
// status bar overlay
// ------------------------------------------
@@ -243,30 +227,11 @@ void ST_LoadGraphics(void)
}
// made separate so that skins code can reload custom face graphics
void ST_LoadFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32 skinnum)
void ST_LoadFaceGraphics(skin_t *skin)
{
facerankprefix[skinnum] = W_CachePatchName(rankstr, PU_HUDGFX);
facewantprefix[skinnum] = W_CachePatchName(wantstr, PU_HUDGFX);
facemmapprefix[skinnum] = W_CachePatchName(mmapstr, PU_HUDGFX);
/*facerankprefix_name[skinnum] = rankstr;
facewantprefix_name[skinnum] = wantstr;
facemmapprefix_name[skinnum] = mmapstr;*/
}
void ST_LoadLocalFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32 skinnum)
{
localfacerankprefix[skinnum] = W_CachePatchName(rankstr, PU_HUDGFX);
localfacewantprefix[skinnum] = W_CachePatchName(wantstr, PU_HUDGFX);
localfacemmapprefix[skinnum] = W_CachePatchName(mmapstr, PU_HUDGFX);
/*localfacerankprefix_name[skinnum] = rankstr;
localfacewantprefix_name[skinnum] = wantstr;
localfacemmapprefix_name[skinnum] = mmapstr;*/
//CONS_Printf("Added rank prefix %s\n", rankstr);
//CONS_Printf("Added want prefix %s\n", wantstr);
//CONS_Printf("Added mmap prefix %s\n", mmapstr);
skin->facerankprefix = W_CachePatchName(skin->facerank, PU_HUDGFX);
skin->facewantprefix = W_CachePatchName(skin->facewant, PU_HUDGFX);
skin->facemmapprefix = W_CachePatchName(skin->facemmap, PU_HUDGFX);
}
void ST_ReloadSkinFaceGraphics(void)
@@ -274,10 +239,10 @@ void ST_ReloadSkinFaceGraphics(void)
INT32 i;
for (i = 0; i < numskins; i++)
ST_LoadFaceGraphics(skins[i].facerank, skins[i].facewant, skins[i].facemmap, i);
ST_LoadFaceGraphics(skins[i]);
for (i = 0; i < numlocalskins; i++)
ST_LoadLocalFaceGraphics(localskins[i].facerank, localskins[i].facewant, localskins[i].facemmap, i);
ST_LoadFaceGraphics(localskins[i]);
}
static inline void ST_InitData(void)
+1 -10
View File
@@ -58,8 +58,7 @@ void ST_UnloadGraphics(void);
void ST_LoadGraphics(void);
// face load graphics, called when skin changes
void ST_LoadFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32 playernum);
void ST_LoadLocalFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32 playernum);
void ST_LoadFaceGraphics(skin_t *skin);
void ST_ReloadSkinFaceGraphics(void);
// return if player a is in the same team as player b
@@ -76,14 +75,6 @@ extern UINT8 stplyrnum;
extern lumpnum_t st_borderpatchnum;
// patches, also used in intermission
extern patch_t *facerankprefix[MAXSKINS]; // ranking
extern patch_t *facewantprefix[MAXSKINS]; // wanted
extern patch_t *facemmapprefix[MAXSKINS]; // minimap
extern patch_t *localfacerankprefix[MAXLOCALSKINS]; // ranking
extern patch_t *localfacewantprefix[MAXLOCALSKINS]; // wanted
extern patch_t *localfacemmapprefix[MAXLOCALSKINS]; // minimap
/** HUD location information (don't move this comment)
*/
typedef struct
+2 -2
View File
@@ -1261,11 +1261,11 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_
//
void V_DrawContinueIcon(INT32 x, INT32 y, INT32 flags, INT32 skinnum, UINT8 skincolor)
{
if (skinnum < 0 || skinnum >= numskins || (skins[skinnum].flags & SF_HIRES))
if (skinnum < 0 || skinnum >= numskins || (skins[skinnum]->flags & SF_HIRES))
V_DrawScaledPatch(x - 10, y - 14, flags, W_CachePatchName("CONTINS", PU_PATCH)); // Draw a star
else
{ // Find front angle of the first waiting frame of the character's actual sprites
spriteframe_t *sprframe = &skins[skinnum].spritedef.spriteframes[2 & FF_FRAMEMASK];
spriteframe_t *sprframe = &skins[skinnum]->spritedef.spriteframes[2 & FF_FRAMEMASK];
patch_t *patch = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH);
const UINT8 *colormap = R_GetTranslationColormap(skinnum, skincolor, GTC_CACHE);
+1 -2
View File
@@ -1190,8 +1190,7 @@ void Y_VoteDrawer(void)
if (player->skincolor)
{
UINT8 *colormap = R_GetTranslationColormap(player->skin, player->skincolor, GTC_CACHE);
patch_t *faceprefix = K_GetFacePrefix(player, K_GetSkinNum(player));
patch_t *faceprefix = K_GetFacePrefix(player, R_GetPlayerSkinNum(player));
if (K_UseHighResPortraits())
V_DrawSmallMappedPatch(x+24, y+9, V_SNAPTOLEFT, faceprefix, colormap);