Compare commits
24
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3204b5c3b4 | ||
|
|
cd02242a01 | ||
|
|
6cbb8a36cf | ||
|
|
bf1aa47854 | ||
|
|
be423b2910 | ||
|
|
3bf3bdf641 | ||
|
|
e923777eb6 | ||
|
|
cf6eb0010e | ||
|
|
5184115216 | ||
|
|
39a46e8f79 | ||
|
|
d9712cf85e | ||
|
|
0691e2d9e2 | ||
|
|
08864e27b2 | ||
|
|
4a3c9ccfbb | ||
|
|
cedd789a27 | ||
|
|
8f91707164 | ||
|
|
37eba186f5 | ||
|
|
7eb2ad1e35 | ||
|
|
f49e57a38c | ||
|
|
265f4a50ef | ||
|
|
e83e2659a7 | ||
|
|
c680dd3222 | ||
|
|
96aaaf5261 | ||
|
|
efb29e6be5 |
No files matched your search
+1
-1
@@ -54,7 +54,7 @@ set(SRB2_CORE_SOURCES
|
||||
string.c
|
||||
tables.c
|
||||
v_video.c
|
||||
w_wad.cpp
|
||||
w_wad.c
|
||||
y_inter.c
|
||||
z_zone.cpp
|
||||
)
|
||||
|
||||
@@ -295,7 +295,6 @@ opts+=$(debug_opts)
|
||||
|
||||
opts+=$(foreach v,$(passthru_opts),$(if $($(v)),-D$(v)))
|
||||
|
||||
CWFLAGS+=-std=gnu17
|
||||
CXXFLAGS+=-std=c++17 # force c17 for c++ since most vpss run older ubuntu versions with old compilers
|
||||
|
||||
opts+=$(WFLAGS) $(CFLAGS)
|
||||
|
||||
+2
-2
@@ -50,8 +50,8 @@ I_mutex con_mutex;
|
||||
// to avoid infinite SIGABRT recursion in the signal handler
|
||||
// due to poisoned locks or mach-o kernel not supporting locks in signals
|
||||
// or something like that. idk
|
||||
# define Lock_state() if (!I_In_Exiting_Signal_Handler()) { I_lock_mutex(&con_mutex); }
|
||||
# define Unlock_state() if (!I_In_Exiting_Signal_Handler()) { I_unlock_mutex(con_mutex); }
|
||||
# define Lock_state() if (!I_In_Exiting_Signal_Handler()) { I_LockMutex(&con_mutex); }
|
||||
# define Unlock_state() if (!I_In_Exiting_Signal_Handler()) { I_UnlockMutex(con_mutex); }
|
||||
#else /*HAVE_THREADS*/
|
||||
# define Lock_state()
|
||||
# define Unlock_state()
|
||||
|
||||
@@ -13,10 +13,6 @@
|
||||
#ifndef __CONSOLE__
|
||||
#define __CONSOLE__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "d_event.h"
|
||||
#include "command.h"
|
||||
#include "i_threads.h"
|
||||
@@ -67,8 +63,4 @@ boolean CON_Ready(void);
|
||||
|
||||
void CON_LogMessage(const char *msg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+343
-320
File diff suppressed because it is too large.
Load diff
+3
-1
@@ -660,9 +660,11 @@ extern UINT8 hu_redownloadinggamestate;
|
||||
#endif
|
||||
extern boolean hu_stopped; // kart, true when the game is stopped for players due to a disconnecting or connecting player
|
||||
|
||||
#define SAVEGAMESIZE (768*1024)
|
||||
|
||||
typedef struct rewind_s
|
||||
{
|
||||
UINT8 savebuffer[(768*1024)];
|
||||
UINT8 savebuffer[SAVEGAMESIZE];
|
||||
tic_t leveltime;
|
||||
size_t demopos;
|
||||
|
||||
|
||||
+1
-1
@@ -2023,7 +2023,7 @@ void D_SRB2Main(void)
|
||||
if (M_CheckProtoParam("replay"))
|
||||
{
|
||||
const char *replayurl = M_GetProtoParam();
|
||||
gconst char *replayname = strrchr(replayurl, '/');
|
||||
char *replayname = strrchr(replayurl, '/');
|
||||
|
||||
if (!replayname || !replayurl)
|
||||
I_Error("REPLAY: Invalid URL.");
|
||||
|
||||
+1
-5
@@ -612,12 +612,8 @@ void Net_WaitAllAckReceived(UINT32 timeout)
|
||||
|
||||
static void InitNode(node_t *node)
|
||||
{
|
||||
node->acktosend_head = node->acktosend_tail = 0;
|
||||
memset(node->acktosend, 0, sizeof(node->acktosend));
|
||||
node->firstacktosend = 0;
|
||||
memset(node, 0, sizeof(node_t));
|
||||
node->nextacknum = 1;
|
||||
node->remotefirstack = 0;
|
||||
node->flags = 0;
|
||||
}
|
||||
|
||||
static void InitAck(void)
|
||||
|
||||
+144
-482
@@ -1208,11 +1208,11 @@ static boolean AllowedPlayerNameChar(char ch)
|
||||
|
||||
static boolean EnsurePlayerNameIsGood(char *name, INT32 playernum)
|
||||
{
|
||||
INT32 ix;
|
||||
size_t ix, len = strlen(name);
|
||||
|
||||
if (strlen(name) == 0 || strlen(name) > MAXPLAYERNAME)
|
||||
if (len == 0 || len > MAXPLAYERNAME)
|
||||
return false; // Empty or too long.
|
||||
if (name[0] == ' ' || name[strlen(name)-1] == ' ')
|
||||
if (name[0] == ' ' || name[len-1] == ' ')
|
||||
return false; // Starts or ends with a space.
|
||||
if (isdigit(name[0]))
|
||||
return false; // Starts with a digit.
|
||||
@@ -1226,20 +1226,19 @@ static boolean EnsurePlayerNameIsGood(char *name, INT32 playernum)
|
||||
|
||||
// Also, anything over 0x80 is disallowed too, since compilers love to
|
||||
// differ on whether they're printable characters or not.
|
||||
for (ix = 0; name[ix] != '\0'; ix++)
|
||||
for (ix = 0; ix < len; ix++)
|
||||
if (!AllowedPlayerNameChar(name[ix]))
|
||||
return false;
|
||||
|
||||
// Check if a player is currently using the name, case-insensitively.
|
||||
for (ix = 0; ix < MAXPLAYERS; ix++)
|
||||
{
|
||||
if (ix != playernum && playeringame[ix]
|
||||
if (ix != (size_t)playernum && playeringame[ix]
|
||||
&& fasticmp(name, player_names[ix]))
|
||||
{
|
||||
// We shouldn't kick people out just because
|
||||
// they joined the game with the same name
|
||||
// as someone else -- modify the name instead.
|
||||
size_t len = strlen(name);
|
||||
|
||||
// Recursion!
|
||||
// Slowly strip characters off the end of the
|
||||
@@ -1458,7 +1457,9 @@ UINT8 CanChangeSkin(INT32 playernum)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (players[playernum].spectator || players[playernum].playerstate == PST_DEAD || players[playernum].playerstate == PST_REBORN)
|
||||
if (players[playernum].spectator ||
|
||||
players[playernum].playerstate == PST_DEAD ||
|
||||
players[playernum].playerstate == PST_REBORN)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -1492,445 +1493,144 @@ static void ForceAllSkins(INT32 forcedskin)
|
||||
}
|
||||
}
|
||||
|
||||
static INT32 snacpending = 0, snac2pending = 0, snac3pending = 0, snac4pending = 0, chmappending = 0;
|
||||
static INT32 chmappending;
|
||||
static INT32 snacpending[MAXSPLITSCREENPLAYERS];
|
||||
|
||||
// wonky compat, idk if anything uses this....
|
||||
#define playerisbot (splitplayer == 1 && botingame)
|
||||
|
||||
// name, color, or skin has changed
|
||||
//
|
||||
static void SendNameAndColor(void)
|
||||
static void SendNameAndColor(UINT8 splitplayer)
|
||||
{
|
||||
char buf[MAXPLAYERNAME+2];
|
||||
char *p;
|
||||
|
||||
p = buf;
|
||||
|
||||
// splitscreen
|
||||
if (splitscreen < splitplayer && !playerisbot)
|
||||
return;
|
||||
|
||||
const INT32 pnum = P_GetLocalPlayerNumForNum(splitplayer);
|
||||
|
||||
player_t *player = &players[pnum];
|
||||
|
||||
// TODO: make those cvars arrays
|
||||
consvar_t *playercolor, *playername, *playerskin;
|
||||
consvar_t *colorvars[] = {&cv_playercolor, &cv_playercolor2, &cv_playercolor3, &cv_playercolor4};
|
||||
consvar_t *namevars[] = {&cv_playername, &cv_playername2, &cv_playername3, &cv_playername4};
|
||||
consvar_t *skinvars[] = {&cv_skin, &cv_skin2, &cv_skin3, &cv_skin4};
|
||||
|
||||
playercolor = colorvars[splitplayer];
|
||||
playername = namevars[splitplayer];
|
||||
playerskin = skinvars[splitplayer];
|
||||
|
||||
// normal player colors
|
||||
if (G_GametypeHasTeams())
|
||||
{
|
||||
if (players[consoleplayer].ctfteam == 1 && cv_playercolor.value != skincolor_redteam)
|
||||
CV_StealthSetValue(&cv_playercolor, skincolor_redteam);
|
||||
else if (players[consoleplayer].ctfteam == 2 && cv_playercolor.value != skincolor_blueteam)
|
||||
CV_StealthSetValue(&cv_playercolor, skincolor_blueteam);
|
||||
if (player->ctfteam == 1 && playercolor->value != skincolor_redteam)
|
||||
CV_StealthSetValue(playercolor, skincolor_redteam);
|
||||
else if (player->ctfteam == 2 && playercolor->value != skincolor_blueteam)
|
||||
CV_StealthSetValue(playercolor, skincolor_blueteam);
|
||||
}
|
||||
|
||||
// never allow the color "none"
|
||||
if (!cv_playercolor.value)
|
||||
if (!playercolor->value)
|
||||
{
|
||||
if (players[consoleplayer].skincolor)
|
||||
CV_StealthSetValue(&cv_playercolor, players[consoleplayer].skincolor);
|
||||
else if (skins[players[consoleplayer].skin].prefcolor)
|
||||
CV_StealthSetValue(&cv_playercolor, skins[players[consoleplayer].skin].prefcolor);
|
||||
if (player->skincolor)
|
||||
CV_StealthSetValue(playercolor, player->skincolor);
|
||||
else if (skins[player->skin].prefcolor)
|
||||
CV_StealthSetValue(playercolor, skins[player->skin].prefcolor);
|
||||
else
|
||||
CV_StealthSet(&cv_playercolor, cv_playercolor.defaultvalue);
|
||||
CV_StealthSet(playercolor, playercolor->defaultvalue);
|
||||
}
|
||||
|
||||
if (fastcmp(cv_playername.string, player_names[consoleplayer])
|
||||
&& cv_playercolor.value == players[consoleplayer].skincolor
|
||||
&& fastcmp(cv_skin.string, skins[players[consoleplayer].skin].name))
|
||||
return;
|
||||
|
||||
// We'll handle it later if we're not playing.
|
||||
if (!Playing())
|
||||
return;
|
||||
|
||||
if (fastcmp(playername->string, player_names[pnum])
|
||||
&& playercolor->value == player->skincolor
|
||||
&& fastcmp(playerskin->string, skins[player->skin].name))
|
||||
return;
|
||||
|
||||
if (playerisbot)
|
||||
{
|
||||
players[pnum].skincolor = botcolor;
|
||||
if (players[pnum].mo)
|
||||
players[pnum].mo->color = players[pnum].skincolor;
|
||||
SetPlayerSkinByNum(pnum, botskin-1);
|
||||
return;
|
||||
}
|
||||
|
||||
// If you're not in a netgame, merely update the skin, color, and name.
|
||||
if (!netgame)
|
||||
{
|
||||
INT32 foundskin;
|
||||
|
||||
CleanupPlayerName(consoleplayer, cv_playername.zstring);
|
||||
strcpy(player_names[consoleplayer], cv_playername.zstring);
|
||||
CleanupPlayerName(pnum, playername->zstring);
|
||||
strcpy(player_names[pnum], playername->zstring);
|
||||
|
||||
players[consoleplayer].skincolor = cv_playercolor.value;
|
||||
player->skincolor = playercolor->value;
|
||||
|
||||
if (players[consoleplayer].mo)
|
||||
players[consoleplayer].mo->color = players[consoleplayer].skincolor;
|
||||
if (player->mo)
|
||||
player->mo->color = player->skincolor;
|
||||
|
||||
if ((foundskin = R_SkinAvailable(cv_skin.string)) != -1)
|
||||
if ((foundskin = R_SkinAvailable(playerskin->string)) != -1)
|
||||
{
|
||||
cv_skin.value = foundskin;
|
||||
SetPlayerSkin(consoleplayer, cv_skin.string);
|
||||
CV_StealthSet(&cv_skin, skins[cv_skin.value].name);
|
||||
playerskin->value = foundskin;
|
||||
SetPlayerSkin(pnum, playerskin->string);
|
||||
CV_StealthSet(playerskin, skins[playerskin->value].name);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv_skin.value = players[consoleplayer].skin;
|
||||
CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name);
|
||||
playerskin->value = player->skin;
|
||||
CV_StealthSet(playerskin, skins[player->skin].name);
|
||||
// will always be same as current
|
||||
SetPlayerSkin(consoleplayer, cv_skin.string);
|
||||
SetPlayerSkin(pnum, playerskin->string);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
snacpending++;
|
||||
snacpending[splitplayer]++;
|
||||
|
||||
// Don't change name if muted
|
||||
if (player_name_changes[consoleplayer] >= MAXNAMECHANGES)
|
||||
if (player_name_changes[pnum] >= MAXNAMECHANGES)
|
||||
{
|
||||
CV_StealthSet(&cv_playername, player_names[consoleplayer]);
|
||||
CV_StealthSet(playername, player_names[pnum]);
|
||||
HU_AddChatText("\x85*You must wait to change your name again", false);
|
||||
}
|
||||
else if (cv_mute.value && !(server || IsPlayerAdmin(consoleplayer)))
|
||||
CV_StealthSet(&cv_playername, player_names[consoleplayer]);
|
||||
else if (cv_mute.value && !(server || IsPlayerAdmin(pnum)))
|
||||
CV_StealthSet(playername, player_names[pnum]);
|
||||
else // Cleanup name if changing it
|
||||
CleanupPlayerName(consoleplayer, cv_playername.zstring);
|
||||
CleanupPlayerName(pnum, playername->zstring);
|
||||
|
||||
// Don't change skin if the server doesn't want you to.
|
||||
if (!CanChangeSkin(consoleplayer))
|
||||
CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name);
|
||||
if (!CanChangeSkin(pnum))
|
||||
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)
|
||||
cv_skin.value = R_SkinAvailable(cv_skin.string);
|
||||
if (cv_skin.value < 0)
|
||||
playerskin->value = R_SkinAvailable(playerskin->string);
|
||||
if (playerskin->value < 0)
|
||||
{
|
||||
INT32 skinnum = players[consoleplayer].skin;
|
||||
CV_StealthSet(&cv_skin, skins[skinnum].name);
|
||||
cv_skin.value = skinnum;
|
||||
INT32 skinnum = player->skin;
|
||||
CV_StealthSet(playerskin, skins[skinnum].name);
|
||||
playerskin->value = skinnum;
|
||||
}
|
||||
|
||||
// Finally write out the complete packet and send it off.
|
||||
WRITESTRINGN(p, cv_playername.zstring, MAXPLAYERNAME);
|
||||
WRITEUINT8(p, (UINT8)cv_playercolor.value);
|
||||
WRITEUINT8(p, (UINT8)cv_skin.value);
|
||||
SendNetXCmdForPlayer(0, XD_NAMEANDCOLOR, buf, p - buf);
|
||||
}
|
||||
|
||||
// splitscreen
|
||||
static void SendNameAndColor2(void)
|
||||
{
|
||||
INT32 secondplaya = -1;
|
||||
char buf[MAXPLAYERNAME+2];
|
||||
char *p;
|
||||
|
||||
if (splitscreen < 1 && !botingame)
|
||||
return; // can happen if skin2/color2/name2 changed
|
||||
|
||||
if (displayplayers[1] != consoleplayer)
|
||||
secondplaya = displayplayers[1];
|
||||
else if (!netgame) // HACK
|
||||
secondplaya = 1;
|
||||
|
||||
if (secondplaya == -1)
|
||||
return;
|
||||
|
||||
p = buf;
|
||||
|
||||
// normal player colors
|
||||
if (G_GametypeHasTeams())
|
||||
{
|
||||
if (players[secondplaya].ctfteam == 1 && cv_playercolor2.value != skincolor_redteam)
|
||||
CV_StealthSetValue(&cv_playercolor2, skincolor_redteam);
|
||||
else if (players[secondplaya].ctfteam == 2 && cv_playercolor2.value != skincolor_blueteam)
|
||||
CV_StealthSetValue(&cv_playercolor2, skincolor_blueteam);
|
||||
}
|
||||
|
||||
// never allow the color "none"
|
||||
if (!cv_playercolor2.value)
|
||||
{
|
||||
if (players[secondplaya].skincolor)
|
||||
CV_StealthSetValue(&cv_playercolor2, players[secondplaya].skincolor);
|
||||
else if (skins[players[secondplaya].skin].prefcolor)
|
||||
CV_StealthSetValue(&cv_playercolor2, skins[players[secondplaya].skin].prefcolor);
|
||||
else
|
||||
CV_StealthSet(&cv_playercolor2, cv_playercolor2.defaultvalue);
|
||||
}
|
||||
|
||||
// We'll handle it later if we're not playing.
|
||||
if (!Playing())
|
||||
return;
|
||||
|
||||
// If you're not in a netgame, merely update the skin, color, and name.
|
||||
if (botingame)
|
||||
{
|
||||
players[secondplaya].skincolor = botcolor;
|
||||
if (players[secondplaya].mo)
|
||||
players[secondplaya].mo->color = players[secondplaya].skincolor;
|
||||
SetPlayerSkinByNum(secondplaya, botskin-1);
|
||||
return;
|
||||
}
|
||||
else if (!netgame)
|
||||
{
|
||||
INT32 foundskin;
|
||||
|
||||
CleanupPlayerName(secondplaya, cv_playername2.zstring);
|
||||
strcpy(player_names[secondplaya], cv_playername2.zstring);
|
||||
|
||||
// don't use displayplayers[1]: the second player must be 1
|
||||
players[secondplaya].skincolor = cv_playercolor2.value;
|
||||
if (players[secondplaya].mo)
|
||||
players[secondplaya].mo->color = players[secondplaya].skincolor;
|
||||
|
||||
if ((foundskin = R_SkinAvailable(cv_skin2.string)) != -1)
|
||||
{
|
||||
cv_skin2.value = foundskin;
|
||||
SetPlayerSkin(secondplaya, cv_skin2.string);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv_skin2.value = players[secondplaya].skin;
|
||||
CV_StealthSet(&cv_skin2, skins[players[secondplaya].skin].name);
|
||||
// will always be same as current
|
||||
SetPlayerSkin(secondplaya, cv_skin2.string);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
snac2pending++;
|
||||
|
||||
// Don't change name if muted
|
||||
if (player_name_changes[displayplayers[1]] >= MAXNAMECHANGES)
|
||||
{
|
||||
CV_StealthSet(&cv_playername2, player_names[displayplayers[1]]);
|
||||
HU_AddChatText("\x85*You must wait to change your name again", false);
|
||||
}
|
||||
else if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[1])))
|
||||
CV_StealthSet(&cv_playername2, player_names[displayplayers[1]]);
|
||||
else // Cleanup name if changing it
|
||||
CleanupPlayerName(displayplayers[1], cv_playername2.zstring);
|
||||
|
||||
// Don't change skin if the server doesn't want you to.
|
||||
if (!CanChangeSkin(displayplayers[1]))
|
||||
CV_StealthSet(&cv_skin2, skins[players[displayplayers[1]].skin].name);
|
||||
|
||||
// check if player has the skin loaded (cv_skin2 may have
|
||||
// the name of a skin that was available in the previous game)
|
||||
cv_skin2.value = R_SkinAvailable(cv_skin2.string);
|
||||
if (cv_skin2.value < 0)
|
||||
{
|
||||
INT32 skinnum = players[displayplayers[1]].skin;
|
||||
CV_StealthSet(&cv_skin2, skins[skinnum].name);
|
||||
cv_skin2.value = skinnum;
|
||||
}
|
||||
|
||||
// Finally write out the complete packet and send it off.
|
||||
WRITESTRINGN(p, cv_playername2.zstring, MAXPLAYERNAME);
|
||||
WRITEUINT8(p, (UINT8)cv_playercolor2.value);
|
||||
WRITEUINT8(p, (UINT8)cv_skin2.value);
|
||||
SendNetXCmdForPlayer(1, XD_NAMEANDCOLOR, buf, p - buf);
|
||||
}
|
||||
|
||||
static void SendNameAndColor3(void)
|
||||
{
|
||||
INT32 thirdplaya = -1;
|
||||
char buf[MAXPLAYERNAME+2];
|
||||
char *p;
|
||||
|
||||
if (splitscreen < 2)
|
||||
return; // can happen if skin3/color3/name3 changed
|
||||
|
||||
if (displayplayers[2] != consoleplayer)
|
||||
thirdplaya = displayplayers[2];
|
||||
else if (!netgame) // HACK
|
||||
thirdplaya = 2;
|
||||
|
||||
if (thirdplaya == -1)
|
||||
return;
|
||||
|
||||
p = buf;
|
||||
|
||||
// normal player colors
|
||||
if (G_GametypeHasTeams())
|
||||
{
|
||||
if (players[thirdplaya].ctfteam == 1 && cv_playercolor3.value != skincolor_redteam)
|
||||
CV_StealthSetValue(&cv_playercolor3, skincolor_redteam);
|
||||
else if (players[thirdplaya].ctfteam == 2 && cv_playercolor3.value != skincolor_blueteam)
|
||||
CV_StealthSetValue(&cv_playercolor3, skincolor_blueteam);
|
||||
}
|
||||
|
||||
// never allow the color "none"
|
||||
if (!cv_playercolor3.value)
|
||||
{
|
||||
if (players[thirdplaya].skincolor)
|
||||
CV_StealthSetValue(&cv_playercolor3, players[thirdplaya].skincolor);
|
||||
else if (skins[players[thirdplaya].skin].prefcolor)
|
||||
CV_StealthSetValue(&cv_playercolor3, skins[players[thirdplaya].skin].prefcolor);
|
||||
else
|
||||
CV_StealthSet(&cv_playercolor3, cv_playercolor3.defaultvalue);
|
||||
}
|
||||
|
||||
// We'll handle it later if we're not playing.
|
||||
if (!Playing())
|
||||
return;
|
||||
|
||||
// If you're not in a netgame, merely update the skin, color, and name.
|
||||
if (!netgame)
|
||||
{
|
||||
INT32 foundskin;
|
||||
|
||||
CleanupPlayerName(thirdplaya, cv_playername3.zstring);
|
||||
strcpy(player_names[thirdplaya], cv_playername3.zstring);
|
||||
|
||||
// don't use displayplayers[2]: the third player must be 2
|
||||
players[thirdplaya].skincolor = cv_playercolor3.value;
|
||||
if (players[thirdplaya].mo)
|
||||
players[thirdplaya].mo->color = players[thirdplaya].skincolor;
|
||||
|
||||
if ((foundskin = R_SkinAvailable(cv_skin3.string)) != -1)
|
||||
{
|
||||
cv_skin3.value = foundskin;
|
||||
SetPlayerSkin(thirdplaya, cv_skin3.string);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv_skin3.value = players[thirdplaya].skin;
|
||||
CV_StealthSet(&cv_skin3, skins[players[thirdplaya].skin].name);
|
||||
// will always be same as current
|
||||
SetPlayerSkin(thirdplaya, cv_skin3.string);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
snac3pending++;
|
||||
|
||||
// Don't change name if muted
|
||||
if (player_name_changes[displayplayers[2]] >= MAXNAMECHANGES)
|
||||
{
|
||||
CV_StealthSet(&cv_playername3, player_names[displayplayers[2]]);
|
||||
HU_AddChatText("\x85*You must wait to change your name again", false);
|
||||
}
|
||||
else if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[2])))
|
||||
CV_StealthSet(&cv_playername3, player_names[displayplayers[2]]);
|
||||
else // Cleanup name if changing it
|
||||
CleanupPlayerName(displayplayers[2], cv_playername3.zstring);
|
||||
|
||||
// Don't change skin if the server doesn't want you to.
|
||||
if (!CanChangeSkin(displayplayers[2]))
|
||||
CV_StealthSet(&cv_skin3, skins[players[displayplayers[2]].skin].name);
|
||||
|
||||
// check if player has the skin loaded (cv_skin3 may have
|
||||
// the name of a skin that was available in the previous game)
|
||||
cv_skin3.value = R_SkinAvailable(cv_skin3.string);
|
||||
if (cv_skin3.value < 0)
|
||||
{
|
||||
INT32 skinnum = players[displayplayers[2]].skin;
|
||||
CV_StealthSet(&cv_skin3, skins[skinnum].name);
|
||||
cv_skin3.value = skinnum;
|
||||
}
|
||||
|
||||
// Finally write out the complete packet and send it off.
|
||||
WRITESTRINGN(p, cv_playername3.zstring, MAXPLAYERNAME);
|
||||
WRITEUINT8(p, (UINT8)cv_playercolor3.value);
|
||||
WRITEUINT8(p, (UINT8)cv_skin3.value);
|
||||
SendNetXCmdForPlayer(2, XD_NAMEANDCOLOR, buf, p - buf);
|
||||
}
|
||||
|
||||
static void SendNameAndColor4(void)
|
||||
{
|
||||
INT32 fourthplaya = -1;
|
||||
char buf[MAXPLAYERNAME+2];
|
||||
char *p;
|
||||
|
||||
if (splitscreen < 3)
|
||||
return; // can happen if skin4/color4/name4 changed
|
||||
|
||||
if (displayplayers[3] != consoleplayer)
|
||||
fourthplaya = displayplayers[3];
|
||||
else if (!netgame) // HACK
|
||||
fourthplaya = 3;
|
||||
|
||||
if (fourthplaya == -1)
|
||||
return;
|
||||
|
||||
p = buf;
|
||||
|
||||
// normal player colors
|
||||
if (G_GametypeHasTeams())
|
||||
{
|
||||
if (players[fourthplaya].ctfteam == 1 && cv_playercolor4.value != skincolor_redteam)
|
||||
CV_StealthSetValue(&cv_playercolor4, skincolor_redteam);
|
||||
else if (players[fourthplaya].ctfteam == 2 && cv_playercolor4.value != skincolor_blueteam)
|
||||
CV_StealthSetValue(&cv_playercolor4, skincolor_blueteam);
|
||||
}
|
||||
|
||||
// never allow the color "none"
|
||||
if (!cv_playercolor4.value)
|
||||
{
|
||||
if (players[fourthplaya].skincolor)
|
||||
CV_StealthSetValue(&cv_playercolor4, players[fourthplaya].skincolor);
|
||||
else if (skins[players[fourthplaya].skin].prefcolor)
|
||||
CV_StealthSetValue(&cv_playercolor4, skins[players[fourthplaya].skin].prefcolor);
|
||||
else
|
||||
CV_StealthSet(&cv_playercolor4, cv_playercolor4.defaultvalue);
|
||||
}
|
||||
|
||||
// We'll handle it later if we're not playing.
|
||||
if (!Playing())
|
||||
return;
|
||||
|
||||
// If you're not in a netgame, merely update the skin, color, and name.
|
||||
if (botingame)
|
||||
{
|
||||
players[fourthplaya].skincolor = botcolor;
|
||||
if (players[fourthplaya].mo)
|
||||
players[fourthplaya].mo->color = players[fourthplaya].skincolor;
|
||||
SetPlayerSkinByNum(fourthplaya, botskin-1);
|
||||
return;
|
||||
}
|
||||
else if (!netgame)
|
||||
{
|
||||
INT32 foundskin;
|
||||
|
||||
CleanupPlayerName(fourthplaya, cv_playername4.zstring);
|
||||
strcpy(player_names[fourthplaya], cv_playername4.zstring);
|
||||
|
||||
// don't use displayplayers[3]: the second player must be 4
|
||||
players[fourthplaya].skincolor = cv_playercolor4.value;
|
||||
if (players[fourthplaya].mo)
|
||||
players[fourthplaya].mo->color = players[fourthplaya].skincolor;
|
||||
|
||||
if ((foundskin = R_SkinAvailable(cv_skin4.string)) != -1)
|
||||
{
|
||||
cv_skin4.value = foundskin;
|
||||
SetPlayerSkin(fourthplaya, cv_skin4.string);
|
||||
}
|
||||
else
|
||||
{
|
||||
cv_skin4.value = players[fourthplaya].skin;
|
||||
CV_StealthSet(&cv_skin4, skins[players[fourthplaya].skin].name);
|
||||
// will always be same as current
|
||||
SetPlayerSkin(fourthplaya, cv_skin4.string);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
snac4pending++;
|
||||
|
||||
// Don't change name if muted
|
||||
if (player_name_changes[displayplayers[3]] >= MAXNAMECHANGES)
|
||||
{
|
||||
CV_StealthSet(&cv_playername4, player_names[displayplayers[3]]);
|
||||
HU_AddChatText("\x85*You must wait to change your name again", false);
|
||||
}
|
||||
else if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[3])))
|
||||
CV_StealthSet(&cv_playername4, player_names[displayplayers[3]]);
|
||||
else // Cleanup name if changing it
|
||||
CleanupPlayerName(displayplayers[3], cv_playername4.zstring);
|
||||
|
||||
// Don't change skin if the server doesn't want you to.
|
||||
if (!CanChangeSkin(displayplayers[3]))
|
||||
CV_StealthSet(&cv_skin4, skins[players[displayplayers[3]].skin].name);
|
||||
|
||||
// check if player has the skin loaded (cv_skin4 may have
|
||||
// the name of a skin that was available in the previous game)
|
||||
cv_skin4.value = R_SkinAvailable(cv_skin4.string);
|
||||
if (cv_skin4.value < 0)
|
||||
{
|
||||
INT32 skinnum = players[displayplayers[3]].skin;
|
||||
CV_StealthSet(&cv_skin4, skins[skinnum].name);
|
||||
cv_skin4.value = skinnum;
|
||||
}
|
||||
|
||||
// Finally write out the complete packet and send it off.
|
||||
WRITESTRINGN(p, cv_playername4.zstring, MAXPLAYERNAME);
|
||||
WRITEUINT8(p, (UINT8)cv_playercolor4.value);
|
||||
WRITEUINT8(p, (UINT8)cv_skin4.value);
|
||||
SendNetXCmdForPlayer(3, XD_NAMEANDCOLOR, buf, p - buf);
|
||||
WRITESTRINGN(p, playername->zstring, MAXPLAYERNAME);
|
||||
WRITEUINT8(p, (UINT8)playercolor->value);
|
||||
WRITEUINT8(p, (UINT8)playerskin->value);
|
||||
SendNetXCmdForPlayer(splitplayer, XD_NAMEANDCOLOR, buf, p - buf);
|
||||
}
|
||||
|
||||
static void Got_NameAndColor(const UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
player_t *p = &players[playernum];
|
||||
player_t *player = &players[playernum];
|
||||
char name[MAXPLAYERNAME+1];
|
||||
UINT8 color, skin;
|
||||
|
||||
@@ -1939,19 +1639,14 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum)
|
||||
I_Error("There is no player %d!", playernum);
|
||||
#endif
|
||||
|
||||
if (playernum == consoleplayer)
|
||||
snacpending--; // TODO: make snacpending an array instead of 4 separate vars?
|
||||
else if (playernum == displayplayers[1])
|
||||
snac2pending--;
|
||||
else if (playernum == displayplayers[2])
|
||||
snac3pending--;
|
||||
else if (playernum == displayplayers[3])
|
||||
snac4pending--;
|
||||
|
||||
if (P_IsLocalPlayer(player))
|
||||
{
|
||||
snacpending[playernum]--;
|
||||
#ifdef PARANOIA
|
||||
if (snacpending < 0 || snac2pending < 0 || snac3pending < 0 || snac4pending < 0)
|
||||
I_Error("snacpending negative!");
|
||||
if (snacpending[playernum] < 0)
|
||||
I_Error("snacpending negative!");
|
||||
#endif
|
||||
}
|
||||
|
||||
READSTRINGN(*cp, name, MAXPLAYERNAME);
|
||||
color = READUINT8(*cp);
|
||||
@@ -1965,33 +1660,32 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum)
|
||||
}
|
||||
|
||||
// set color
|
||||
p->skincolor = color % MAXSKINCOLORS;
|
||||
if (p->mo)
|
||||
p->mo->color = (UINT8)p->skincolor;
|
||||
player->skincolor = color % MAXSKINCOLORS;
|
||||
if (player->mo)
|
||||
player->mo->color = (UINT8)player->skincolor;
|
||||
demo_extradata[playernum] |= DXD_COLOR;
|
||||
|
||||
// normal player colors
|
||||
if (server && (p != &players[consoleplayer] && p != &players[displayplayers[1]]
|
||||
&& p != &players[displayplayers[2]] && p != &players[displayplayers[3]]))
|
||||
if (server && !P_IsLocalPlayer(player))
|
||||
{
|
||||
boolean kick = false;
|
||||
|
||||
// team colors
|
||||
if (G_GametypeHasTeams())
|
||||
{
|
||||
if (p->ctfteam == 1 && p->skincolor != skincolor_redteam)
|
||||
if (player->ctfteam == 1 && player->skincolor != skincolor_redteam)
|
||||
kick = true;
|
||||
else if (p->ctfteam == 2 && p->skincolor != skincolor_blueteam)
|
||||
else if (player->ctfteam == 2 && player->skincolor != skincolor_blueteam)
|
||||
kick = true;
|
||||
}
|
||||
|
||||
// don't allow color "none"
|
||||
if (!p->skincolor)
|
||||
if (!player->skincolor)
|
||||
kick = true;
|
||||
|
||||
if (kick)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Illegal color change received from %s (team: %d), color: %d)\n"), player_names[playernum], p->ctfteam, p->skincolor);
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Illegal color change received from %s (team: %d), color: %d)\n"), player_names[playernum], player->ctfteam, player->skincolor);
|
||||
SendKick(playernum, KICK_MSG_CON_FAIL);
|
||||
return;
|
||||
}
|
||||
@@ -2003,6 +1697,7 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum)
|
||||
const INT32 forcedskin = cv_forceskin.value;
|
||||
SetPlayerSkinByNum(playernum, forcedskin);
|
||||
|
||||
// TODO: make cv_skin an array
|
||||
if (playernum == consoleplayer)
|
||||
CV_StealthSet(&cv_skin, skins[forcedskin].name);
|
||||
else if (playernum == displayplayers[1])
|
||||
@@ -2016,44 +1711,16 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum)
|
||||
SetPlayerSkinByNum(playernum, skin);
|
||||
}
|
||||
|
||||
void SendWeaponPref(void)
|
||||
void SendWeaponPref(UINT8 splitplayer)
|
||||
{
|
||||
UINT8 buf[1];
|
||||
|
||||
buf[0] = 0;
|
||||
if (cv_flipcam[0].value)
|
||||
|
||||
if (cv_flipcam[splitplayer].value)
|
||||
buf[0] |= 1;
|
||||
SendNetXCmdForPlayer(0, XD_WEAPONPREF, buf, 1);
|
||||
}
|
||||
|
||||
void SendWeaponPref2(void)
|
||||
{
|
||||
UINT8 buf[1];
|
||||
|
||||
buf[0] = 0;
|
||||
if (cv_flipcam[1].value)
|
||||
buf[0] |= 1;
|
||||
SendNetXCmdForPlayer(1, XD_WEAPONPREF, buf, 1);
|
||||
}
|
||||
|
||||
void SendWeaponPref3(void)
|
||||
{
|
||||
UINT8 buf[1];
|
||||
|
||||
buf[0] = 0;
|
||||
if (cv_flipcam[2].value)
|
||||
buf[0] |= 1;
|
||||
SendNetXCmdForPlayer(2, XD_WEAPONPREF, buf, 1);
|
||||
}
|
||||
|
||||
void SendWeaponPref4(void)
|
||||
{
|
||||
UINT8 buf[1];
|
||||
|
||||
buf[0] = 0;
|
||||
if (cv_flipcam[3].value)
|
||||
buf[0] |= 1;
|
||||
SendNetXCmdForPlayer(3, XD_WEAPONPREF, buf, 1);
|
||||
SendNetXCmdForPlayer(splitplayer, XD_WEAPONPREF, buf, 1);
|
||||
}
|
||||
|
||||
static void Got_WeaponPref(const UINT8 **cp, INT32 playernum)
|
||||
@@ -2069,23 +1736,10 @@ static void Got_WeaponPref(const UINT8 **cp, INT32 playernum)
|
||||
player->pflags |= PF_ANALOGMODE;
|
||||
}
|
||||
|
||||
void D_SendPlayerConfig(void)
|
||||
void D_SendPlayerConfig(UINT8 splitplayer)
|
||||
{
|
||||
SendNameAndColor();
|
||||
if (splitscreen || botingame)
|
||||
SendNameAndColor2();
|
||||
if (splitscreen > 1)
|
||||
SendNameAndColor3();
|
||||
if (splitscreen > 2)
|
||||
SendNameAndColor4();
|
||||
|
||||
SendWeaponPref();
|
||||
if (splitscreen)
|
||||
SendWeaponPref2();
|
||||
if (splitscreen > 1)
|
||||
SendWeaponPref3();
|
||||
if (splitscreen > 2)
|
||||
SendWeaponPref4();
|
||||
SendNameAndColor(splitplayer);
|
||||
SendWeaponPref(splitplayer);
|
||||
}
|
||||
|
||||
// Only works for displayplayer, sorry!
|
||||
@@ -2108,10 +1762,12 @@ INT32 D_LookupPlayer(const char *s)
|
||||
return playernum;
|
||||
}
|
||||
|
||||
const size_t len = strlen(s);
|
||||
|
||||
for (playernum = 0; playernum < MAXPLAYERS; ++playernum)
|
||||
{
|
||||
/* Match name case-insensitively: fully, or partially the start. */
|
||||
if (playeringame[playernum] && (strnicmp(player_names[playernum], s, strlen(s)) == 0))
|
||||
if (playeringame[playernum] && (strnicmp(player_names[playernum], s, len) == 0))
|
||||
{
|
||||
return playernum;
|
||||
}
|
||||
@@ -2151,13 +1807,15 @@ static void GetViewablePlayerPlaceRange(INT32 *first, INT32 *last)
|
||||
(*last) = 0;
|
||||
|
||||
for (i = 0; i < MAXPLAYERS; ++i)
|
||||
if (G_CouldView(i))
|
||||
{
|
||||
place = players[i].kartstuff[k_position];
|
||||
if (place < (*first))
|
||||
(*first) = place;
|
||||
if (place > (*last))
|
||||
(*last) = place;
|
||||
if (G_CouldView(i))
|
||||
{
|
||||
place = players[i].kartstuff[k_position];
|
||||
if (place < (*first))
|
||||
(*first) = place;
|
||||
if (place > (*last))
|
||||
(*last) = place;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2491,7 +2149,7 @@ void D_MapChange(INT32 mapnum, INT32 newgametype, boolean pencoremode, boolean r
|
||||
displayplayers[1] = 1;
|
||||
playeringame[1] = true;
|
||||
players[1].bot = 1;
|
||||
SendNameAndColor2();
|
||||
SendNameAndColor(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5768,50 +5426,54 @@ static void ForceSkin_OnChange(void)
|
||||
}
|
||||
}
|
||||
|
||||
//Allows the player's name to be changed if cv_mute is off.
|
||||
// Allows the player's name to be changed if cv_mute is off.
|
||||
static void Name_OnChange(void)
|
||||
{
|
||||
if (cv_mute.value && !(server || IsPlayerAdmin(consoleplayer)))
|
||||
{
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n"));
|
||||
CV_StealthSet(&cv_playername, player_names[consoleplayer]);
|
||||
return;
|
||||
}
|
||||
else
|
||||
SendNameAndColor();
|
||||
|
||||
SendNameAndColor(0);
|
||||
|
||||
}
|
||||
|
||||
static void Name2_OnChange(void)
|
||||
{
|
||||
if (cv_mute.value) //Secondary player can't be admin.
|
||||
if (cv_mute.value) // Secondary player can't be admin.
|
||||
{
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n"));
|
||||
CV_StealthSet(&cv_playername2, player_names[displayplayers[1]]);
|
||||
return;
|
||||
}
|
||||
else
|
||||
SendNameAndColor2();
|
||||
|
||||
SendNameAndColor(1);
|
||||
}
|
||||
|
||||
static void Name3_OnChange(void)
|
||||
{
|
||||
if (cv_mute.value) //Third player can't be admin.
|
||||
if (cv_mute.value) // Third player can't be admin.
|
||||
{
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n"));
|
||||
CV_StealthSet(&cv_playername3, player_names[displayplayers[2]]);
|
||||
return;
|
||||
}
|
||||
else
|
||||
SendNameAndColor3();
|
||||
|
||||
SendNameAndColor(2);
|
||||
}
|
||||
|
||||
static void Name4_OnChange(void)
|
||||
{
|
||||
if (cv_mute.value) //Secondary player can't be admin.
|
||||
if (cv_mute.value) // Secondary player can't be admin.
|
||||
{
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n"));
|
||||
CV_StealthSet(&cv_playername4, player_names[displayplayers[3]]);
|
||||
return;
|
||||
}
|
||||
else
|
||||
SendNameAndColor4();
|
||||
|
||||
SendNameAndColor(3);
|
||||
}
|
||||
|
||||
/** Sends a skin change for the console player, unless that player is moving.
|
||||
@@ -5833,7 +5495,7 @@ static void Skin_OnChange(void)
|
||||
}
|
||||
|
||||
if (CanChangeSkin(consoleplayer) && !P_PlayerMoving(consoleplayer))
|
||||
SendNameAndColor();
|
||||
SendNameAndColor(0);
|
||||
else
|
||||
{
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
|
||||
@@ -5854,7 +5516,7 @@ static void Skin2_OnChange(void)
|
||||
return; // do whatever you want
|
||||
|
||||
if (CanChangeSkin(displayplayers[1]) && !P_PlayerMoving(displayplayers[1]))
|
||||
SendNameAndColor2();
|
||||
SendNameAndColor(1);
|
||||
else
|
||||
{
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
|
||||
@@ -5870,7 +5532,7 @@ static void Skin3_OnChange(void)
|
||||
return; // do whatever you want
|
||||
|
||||
if (CanChangeSkin(displayplayers[2]) && !P_PlayerMoving(displayplayers[2]))
|
||||
SendNameAndColor3();
|
||||
SendNameAndColor(2);
|
||||
else
|
||||
{
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
|
||||
@@ -5886,7 +5548,7 @@ static void Skin4_OnChange(void)
|
||||
return; // do whatever you want
|
||||
|
||||
if (CanChangeSkin(displayplayers[3]) && !P_PlayerMoving(displayplayers[3]))
|
||||
SendNameAndColor4();
|
||||
SendNameAndColor(3);
|
||||
else
|
||||
{
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
|
||||
@@ -5999,7 +5661,7 @@ static void Color_OnChange(void)
|
||||
if (!P_PlayerMoving(consoleplayer))
|
||||
{
|
||||
// Color change menu scrolling fix is no longer necessary
|
||||
SendNameAndColor();
|
||||
SendNameAndColor(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -6021,7 +5683,7 @@ static void Color2_OnChange(void)
|
||||
if (!P_PlayerMoving(displayplayers[1]))
|
||||
{
|
||||
// Color change menu scrolling fix is no longer necessary
|
||||
SendNameAndColor2();
|
||||
SendNameAndColor(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -6038,7 +5700,7 @@ static void Color3_OnChange(void)
|
||||
if (!P_PlayerMoving(displayplayers[2]))
|
||||
{
|
||||
// Color change menu scrolling fix is no longer necessary
|
||||
SendNameAndColor3();
|
||||
SendNameAndColor(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -6055,7 +5717,7 @@ static void Color4_OnChange(void)
|
||||
if (!P_PlayerMoving(displayplayers[3]))
|
||||
{
|
||||
// Color change menu scrolling fix is no longer necessary
|
||||
SendNameAndColor4();
|
||||
SendNameAndColor(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+2
-5
@@ -21,10 +21,7 @@ extern "C" {
|
||||
|
||||
#include "command.h"
|
||||
|
||||
void SendWeaponPref(void);
|
||||
void SendWeaponPref2(void);
|
||||
void SendWeaponPref3(void);
|
||||
void SendWeaponPref4(void);
|
||||
void SendWeaponPref(UINT8 splitplayer);
|
||||
|
||||
// console vars
|
||||
extern consvar_t cv_playername;
|
||||
@@ -295,7 +292,7 @@ typedef union {
|
||||
// add game commands, needs cleanup
|
||||
void D_RegisterServerCommands(void);
|
||||
void D_RegisterClientCommands(void);
|
||||
void D_SendPlayerConfig(void);
|
||||
void D_SendPlayerConfig(UINT8 splitplayer);
|
||||
void Command_ExitGame_f(void);
|
||||
void Command_Retry_f(void);
|
||||
void D_GameTypeChanged(INT32 lastgametype); // not a real _OnChange function anymore
|
||||
|
||||
+16
-16
@@ -960,7 +960,7 @@ void Got_Filetxpak(void)
|
||||
|| fastcmp(filename, "music.kart")
|
||||
|| fastcmp(filename, "patch.kart")
|
||||
))
|
||||
I_Error("Tried to download \"%s\"", filename);
|
||||
I_Error("Tried to download base-game file: \"%s\"", filename);
|
||||
|
||||
if (filenum >= fileneedednum)
|
||||
{
|
||||
@@ -1019,21 +1019,21 @@ void Got_Filetxpak(void)
|
||||
|
||||
switch(file->status)
|
||||
{
|
||||
case FS_NOTFOUND:
|
||||
s = "FS_NOTFOUND";
|
||||
break;
|
||||
case FS_FOUND:
|
||||
s = "FS_FOUND";
|
||||
break;
|
||||
case FS_OPEN:
|
||||
s = "FS_OPEN";
|
||||
break;
|
||||
case FS_MD5SUMBAD:
|
||||
s = "FS_MD5SUMBAD";
|
||||
break;
|
||||
default:
|
||||
s = "unknown";
|
||||
break;
|
||||
case FS_NOTFOUND:
|
||||
s = "FS_NOTFOUND";
|
||||
break;
|
||||
case FS_FOUND:
|
||||
s = "FS_FOUND";
|
||||
break;
|
||||
case FS_OPEN:
|
||||
s = "FS_OPEN";
|
||||
break;
|
||||
case FS_MD5SUMBAD:
|
||||
s = "FS_MD5SUMBAD";
|
||||
break;
|
||||
default:
|
||||
s = "unknown";
|
||||
break;
|
||||
}
|
||||
|
||||
I_Error("Received a file not requested (file id: %d, file status: %s)\n", filenum, s);
|
||||
|
||||
@@ -1384,7 +1384,6 @@ static void I_Fork(void)
|
||||
|
||||
INT32 I_StartupSystem(void)
|
||||
{
|
||||
W_Startup();
|
||||
I_StartupConsole();
|
||||
#ifdef NEWSIGNALHANDLER
|
||||
// This is useful when debugging. It lets GDB attach to
|
||||
|
||||
@@ -13,10 +13,6 @@
|
||||
#ifndef __DEHACKED_H__
|
||||
#define __DEHACKED_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "m_fixed.h" // for get_number
|
||||
#include "info.h"
|
||||
|
||||
@@ -75,9 +71,4 @@ typedef struct
|
||||
} MYFILE;
|
||||
#define myfeof(a) (a->data + a->size <= a->curpos)
|
||||
char *myfgets(char *buf, size_t bufsize, MYFILE *f);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -516,6 +516,22 @@ extern boolean capslock;
|
||||
// i_system.c, replace getchar() once the keyboard has been appropriated
|
||||
INT32 I_GetKey(void);
|
||||
|
||||
/* http://www.cse.yorku.ca/~oz/hash.html */
|
||||
static inline
|
||||
UINT32 quickncasehash (const char *p, size_t n)
|
||||
{
|
||||
size_t i = 0;
|
||||
UINT32 x = 5381;
|
||||
|
||||
while (i < n && p[i])
|
||||
{
|
||||
x = (x * 33) ^ tolower(p[i]);
|
||||
i++;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
#ifndef __cplusplus
|
||||
#ifndef min // Double-Check with WATTCP-32's cdefs.h
|
||||
#define min(x, y) (((x) < (y)) ? (x) : (y))
|
||||
|
||||
+5
-16
@@ -68,21 +68,8 @@ extern "C" {
|
||||
#define strnicmp(x,y,n) strncasecmp(x,y,n)
|
||||
#endif
|
||||
|
||||
// glibc 2.43 made alot of standard lib functions propagate the constness of its input pointers
|
||||
// to not cause warnings or compile issues on older glibc versions we do this silly thing
|
||||
// to not have a gazillion glibc version checks
|
||||
#if defined(__GLIBC_PREREQ)
|
||||
#if __GLIBC_PREREQ(2, 43)
|
||||
#define gconst const
|
||||
#else
|
||||
#define gconst
|
||||
#endif
|
||||
#else
|
||||
#define gconst
|
||||
#endif
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
char *nongnu_strcasestr(const char *in, const char *what);
|
||||
#ifndef _GNU_SOURCE
|
||||
#define strcasestr nongnu_strcasestr
|
||||
#endif
|
||||
|
||||
@@ -140,9 +127,9 @@ size_t strlcpy(char *dst, const char *src, size_t dsize);
|
||||
#define STRBUFCPY(dst,src) strlcpy(dst, src, sizeof dst)
|
||||
|
||||
/* Boolean type definition */
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <stdbool.h>
|
||||
// dont use stdbools _BOOL type
|
||||
// its smaller (1 byte) than the old interger bool (4 bytes)
|
||||
// which results in packed struct sizes being mismatched between vanilla and this
|
||||
@@ -150,7 +137,9 @@ size_t strlcpy(char *dst, const char *src, size_t dsize);
|
||||
// which we cant use as enumeration constants
|
||||
typedef int32_t boolean;
|
||||
#else
|
||||
#define boolean int32_t
|
||||
#define false FALSE
|
||||
#define true TRUE
|
||||
#define boolean BOOL
|
||||
#endif
|
||||
|
||||
/* 7.18.2.1 Limits of exact-width integer types */
|
||||
|
||||
@@ -361,11 +361,6 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu)
|
||||
// on for fade-to-black
|
||||
for (;;)
|
||||
{
|
||||
if (I_Interrupted())
|
||||
{
|
||||
I_Quit();
|
||||
}
|
||||
|
||||
// get fademask first so we can tell if it exists or not
|
||||
fmask = F_GetFadeMask(wipetype, wipeframe++);
|
||||
|
||||
|
||||
+1
-7
@@ -69,9 +69,6 @@ UINT8 botcolor = 0;
|
||||
|
||||
JoyType_t Joystick[MAXSPLITSCREENPLAYERS] = {};
|
||||
|
||||
// 1024 bytes is plenty for a savegame
|
||||
#define SAVEGAMESIZE (1024)
|
||||
|
||||
// SRB2kart
|
||||
char gamedatafilename[64] = "kartdata.dat";
|
||||
char timeattackfolder[64] = "kart";
|
||||
@@ -3902,7 +3899,7 @@ void G_SaveGame(UINT32 savegameslot)
|
||||
char name[VERSIONSIZE];
|
||||
size_t length;
|
||||
|
||||
save.p = save.buffer = (UINT8 *)Z_Malloc(SAVEGAMESIZE, PU_STATIC, NULL);
|
||||
save.p = save.buffer = (UINT8 *)Z_Malloc(1024, PU_STATIC, NULL); // 1024 bytes is plenty for a savegame
|
||||
if (!save.p)
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, M_GetText("No more free memory for saving game data\n"));
|
||||
@@ -4153,7 +4150,6 @@ static void measurekeywords(mapsearchfreq_t *fr,
|
||||
{
|
||||
char *qp;
|
||||
char *sp;
|
||||
|
||||
if (wanttable)
|
||||
(*dimp) = Z_Realloc((*dimp), 255 * sizeof (struct searchdim),
|
||||
PU_STATIC, NULL);
|
||||
@@ -4168,12 +4164,10 @@ static void measurekeywords(mapsearchfreq_t *fr,
|
||||
(*dimp)[(*cuntp)].pos = sp - s;
|
||||
(*dimp)[(*cuntp)].siz = strlen(qp);
|
||||
}
|
||||
|
||||
(*cuntp)++;
|
||||
fr->total++;
|
||||
}
|
||||
}
|
||||
|
||||
if (wanttable)
|
||||
(*dimp) = Z_Realloc((*dimp), (*cuntp) * sizeof (struct searchdim),
|
||||
PU_STATIC, NULL);
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
#ifdef HWRENDER
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
#include "hw_main.h"
|
||||
#include "hw_glob.h"
|
||||
#include "hw_gl.h"
|
||||
@@ -98,7 +100,7 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm
|
||||
position = 0;
|
||||
}
|
||||
|
||||
position = max(((position * scale_y) + (FRACUNIT/2)) >> FRACBITS, 0);
|
||||
position = std::max(((position * scale_y) + (FRACUNIT/2)) >> FRACBITS, 0);
|
||||
|
||||
if (position + count >= pblockheight)
|
||||
count = pblockheight - position;
|
||||
@@ -162,7 +164,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap,
|
||||
fixed_t xfrac, xfracstep;
|
||||
fixed_t yfracstep, scale_y;
|
||||
const column_t *patchcol;
|
||||
UINT8 *block = (UINT8 *)(mipmap->data);
|
||||
UINT8 *block = static_cast<UINT8 *>(mipmap->data);
|
||||
INT32 bpp;
|
||||
INT32 blockmodulo;
|
||||
RGBA_t *palette;
|
||||
@@ -212,7 +214,7 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
|
||||
fixed_t xfrac, xfracstep;
|
||||
fixed_t yfracstep, scale_y;
|
||||
const column_t *patchcol;
|
||||
UINT8 *block = (UINT8 *)(mipmap->data);
|
||||
UINT8 *block = static_cast<UINT8 *>(mipmap->data);
|
||||
INT32 bpp;
|
||||
INT32 blockmodulo;
|
||||
INT32 width, height;
|
||||
@@ -288,7 +290,7 @@ static UINT8 *MakeBlock(GLMipmap_t *glMipmap)
|
||||
INT32 blocksize = (glMipmap->width * glMipmap->height);
|
||||
|
||||
bpp = format2bpp(glMipmap->format);
|
||||
block = (UINT8 *)(Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(glMipmap->data)));
|
||||
block = static_cast<UINT8 *>(Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(glMipmap->data)));
|
||||
|
||||
switch (bpp)
|
||||
{
|
||||
@@ -325,7 +327,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe
|
||||
texture = textures[texnum];
|
||||
|
||||
gltex->mipmap.flags = TF_CHROMAKEYED | TF_WRAPXY;
|
||||
gltex->mipmap.format = (GLTextureFormat_t)(textureformat);
|
||||
gltex->mipmap.format = static_cast<GLTextureFormat_t>(textureformat);
|
||||
|
||||
// hack the Legacy skies..
|
||||
if (UNLIKELY(memcmp(texture->name, "SKY", 3) == 0 &&
|
||||
@@ -344,7 +346,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe
|
||||
colormap += COLORMAP_REMAPOFFSET;
|
||||
#endif
|
||||
|
||||
gltex->mipmap.colormap = (GLColormap_t *)(Z_Calloc(sizeof(*gltex->mipmap.colormap), PU_HWRPATCHCOLMIPMAP, NULL));
|
||||
gltex->mipmap.colormap = static_cast<GLColormap_t *>(Z_Calloc(sizeof(*gltex->mipmap.colormap), PU_HWRPATCHCOLMIPMAP, NULL));
|
||||
gltex->mipmap.colormap->source = colormap;
|
||||
memcpy(gltex->mipmap.colormap->data, colormap, 256 * sizeof(UINT8));
|
||||
|
||||
@@ -377,7 +379,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe
|
||||
// Composite the columns together.
|
||||
for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++)
|
||||
{
|
||||
pdata = (UINT8 *)(W_CacheLumpNumPwad(patch->wad, patch->lump, PU_LEVEL));
|
||||
pdata = static_cast<UINT8 *>(W_CacheLumpNumPwad(patch->wad, patch->lump, PU_LEVEL));
|
||||
realpatch = (softwarepatch_t *)pdata;
|
||||
|
||||
HWR_DrawTexturePatchInCache(&gltex->mipmap, blockwidth, blockheight, texture, patch, realpatch);
|
||||
@@ -413,7 +415,7 @@ void HWR_MakePatch(const patch_t *patch, GLPatch_t *glPatch, GLMipmap_t *glMipma
|
||||
glMipmap->flags = 0;
|
||||
|
||||
// setup the texture info
|
||||
glMipmap->format = (GLTextureFormat_t)(patchformat);
|
||||
glMipmap->format = static_cast<GLTextureFormat_t>(patchformat);
|
||||
|
||||
glPatch->max_s = (float)patch->width / (float)glMipmap->width;
|
||||
glPatch->max_t = (float)patch->height / (float)glMipmap->height;
|
||||
@@ -455,7 +457,7 @@ static void HWR_FreeTextureData(patch_t *patch)
|
||||
if (!patch || !patch->hardware)
|
||||
return;
|
||||
|
||||
glPatch = (GLPatch_t *)(patch->hardware);
|
||||
glPatch = static_cast<GLPatch_t *>(patch->hardware);
|
||||
|
||||
if (vid.glstate == VID_GL_LIBRARY_LOADED)
|
||||
GL_DeleteTexture(glPatch->mipmap);
|
||||
@@ -471,7 +473,7 @@ void HWR_FreeTexture(patch_t *patch)
|
||||
|
||||
if (patch->hardware)
|
||||
{
|
||||
GLPatch_t *glPatch = (GLPatch_t *)(patch->hardware);
|
||||
GLPatch_t *glPatch = static_cast<GLPatch_t *>(patch->hardware);
|
||||
|
||||
HWR_FreeTextureColormaps(patch);
|
||||
|
||||
@@ -497,7 +499,7 @@ static void HWR_FreeTextureColormaps(patch_t *patch)
|
||||
if (!patch)
|
||||
return;
|
||||
|
||||
pat = (GLPatch_t *)(patch->hardware);
|
||||
pat = static_cast<GLPatch_t *>(patch->hardware);
|
||||
if (!pat)
|
||||
return;
|
||||
|
||||
@@ -612,20 +614,24 @@ void HWR_FreeMapTextures(void)
|
||||
gl_numtextures = 0;
|
||||
}
|
||||
|
||||
#define NAME flatcheck
|
||||
#define KEY_TY UINT32
|
||||
#define HASH_FN vt_hash_integer
|
||||
#define CMPR_FN vt_cmpr_integer
|
||||
#include "../verstable.h"
|
||||
|
||||
static void HWR_PrecacheLevelFlats(void)
|
||||
{
|
||||
// lookup for flats that may´ve been already loaded
|
||||
flatcheck flatpresent;
|
||||
flatcheck_init(&flatpresent);
|
||||
// too lazy to make a hashtable or smth so unordered set will do :carbuncle:
|
||||
std::unordered_set<UINT32> flatpresent;
|
||||
size_t i, j;
|
||||
INT32 k;
|
||||
|
||||
auto load_flat = [&](lumpnum_t lump, boolean noencoremap)
|
||||
{
|
||||
// flat already loaded?
|
||||
if (flatpresent.count(lump) == 0)
|
||||
{
|
||||
HWR_GetFlat(lump, noencoremap);
|
||||
flatpresent.insert(lump);
|
||||
}
|
||||
};
|
||||
|
||||
// special case for encore
|
||||
#ifdef GLENCORE
|
||||
if (encoremap)
|
||||
@@ -643,23 +649,14 @@ static void HWR_PrecacheLevelFlats(void)
|
||||
|
||||
const levelflat_t *levelflat = &levelflats[pic];
|
||||
|
||||
if (flatcheck_is_end(flatcheck_get(&flatpresent, levelflat->lumpnum)))
|
||||
{
|
||||
HWR_GetFlat(levelflat->lumpnum, R_NoEncore(sec, ceiling));
|
||||
flatcheck_insert(&flatpresent, levelflat->lumpnum);
|
||||
}
|
||||
load_flat(levelflat->lumpnum, R_NoEncore(sec, ceiling));
|
||||
|
||||
if (levelflat->speed) // is it an animated flat ?
|
||||
{
|
||||
// start from 0, occasionally basenumlump != flat->lumpnum
|
||||
for (k = 0; k < levelflat->numpics; k++)
|
||||
{
|
||||
lumpnum_t lump = levelflat->baselumpnum + k;
|
||||
if (flatcheck_is_end(flatcheck_get(&flatpresent, lump)))
|
||||
{
|
||||
HWR_GetFlat(lump, R_NoEncore(sec, ceiling));
|
||||
flatcheck_insert(&flatpresent, lump);
|
||||
}
|
||||
load_flat(levelflat->baselumpnum + k, R_NoEncore(sec, ceiling));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -674,29 +671,18 @@ static void HWR_PrecacheLevelFlats(void)
|
||||
{
|
||||
const levelflat_t *levelflat = &levelflats[i];
|
||||
|
||||
if (flatcheck_is_end(flatcheck_get(&flatpresent, levelflat->lumpnum)))
|
||||
{
|
||||
HWR_GetFlat(levelflat->lumpnum, false);
|
||||
flatcheck_insert(&flatpresent, levelflat->lumpnum);
|
||||
}
|
||||
load_flat(levelflat->lumpnum, false);
|
||||
|
||||
if (levelflat->speed) // is it an animated flat ?
|
||||
{
|
||||
// start from 0, occasionally basenumlump != flat->lumpnum
|
||||
for (k = 0; k < levelflat->numpics; k++)
|
||||
{
|
||||
lumpnum_t lump = levelflat->baselumpnum + k;
|
||||
if (flatcheck_is_end(flatcheck_get(&flatpresent, lump)))
|
||||
{
|
||||
HWR_GetFlat(lump, false);
|
||||
flatcheck_insert(&flatpresent, lump);
|
||||
}
|
||||
load_flat(levelflat->baselumpnum + k, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flatcheck_cleanup(&flatpresent);
|
||||
}
|
||||
|
||||
static void HWR_PrecacheLevelTextures(void)
|
||||
@@ -706,7 +692,7 @@ static void HWR_PrecacheLevelTextures(void)
|
||||
size_t i, j, f;
|
||||
INT32 h;
|
||||
|
||||
texturepresent = (char *)(calloc(gl_numtextures, sizeof(*texturepresent)));
|
||||
texturepresent = static_cast<char *>(calloc(gl_numtextures, sizeof(*texturepresent)));
|
||||
if (texturepresent == NULL)
|
||||
I_Error("%s: Out of memory looking up textures", "HWR_PrecacheLevel");
|
||||
|
||||
@@ -881,7 +867,7 @@ void HWR_LoadMapTextures(size_t pnumtextures)
|
||||
HWR_FreeMapTextures();
|
||||
|
||||
gl_numtextures = pnumtextures;
|
||||
gl_textures = (GLMapTextureSet_t *)(calloc(gl_numtextures, sizeof(*gl_textures))); // *2 - 1 for encore-remapped texture and another for noencore texture (unused when not in encore), see: GLMapTextureSet_t
|
||||
gl_textures = static_cast<GLMapTextureSet_t *>(calloc(gl_numtextures, sizeof(*gl_textures))); // *2 - 1 for encore-remapped texture and another for noencore texture (unused when not in encore), see: GLMapTextureSet_t
|
||||
|
||||
if (gl_textures == NULL)
|
||||
I_Error("HWR_LoadMapTextures: ran out of memory for OpenGL textures. Sad!");
|
||||
@@ -978,7 +964,7 @@ static void HWR_CacheFlat(GLMipmap_t *glMipmap, lumpnum_t flatlumpnum)
|
||||
W_ReadLump(flatlumpnum, Z_Malloc(size, PU_HWRCACHE, &glMipmap->data));
|
||||
|
||||
#ifdef GLENCORE
|
||||
flat = (UINT8 *)(glMipmap->data);
|
||||
flat = static_cast<UINT8 *>(glMipmap->data);
|
||||
for (steppy = 0; steppy < size; steppy++)
|
||||
{
|
||||
if (flat[steppy] == HWR_PATCHES_CHROMAKEY_COLORINDEX)
|
||||
@@ -1022,7 +1008,7 @@ void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap)
|
||||
if (!noencoremap && encoremap)
|
||||
colormap += COLORMAP_REMAPOFFSET;
|
||||
#endif
|
||||
glMipmap->colormap = (GLColormap_t *)(Z_Calloc(sizeof(*glMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL));
|
||||
glMipmap->colormap = static_cast<GLColormap_t *>(Z_Calloc(sizeof(*glMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL));
|
||||
glMipmap->colormap->source = colormap;
|
||||
memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8));
|
||||
}
|
||||
@@ -1046,7 +1032,7 @@ void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap)
|
||||
// --------------------+
|
||||
static void HWR_LoadPatchMipmap(patch_t *patch, GLMipmap_t *glMipmap)
|
||||
{
|
||||
GLPatch_t *glPatch = (GLPatch_t *)(patch->hardware);
|
||||
GLPatch_t *glPatch = static_cast<GLPatch_t *>(patch->hardware);
|
||||
|
||||
if (!glMipmap->downloaded)
|
||||
{
|
||||
@@ -1067,7 +1053,7 @@ static void HWR_LoadPatchMipmap(patch_t *patch, GLMipmap_t *glMipmap)
|
||||
// ----------------------+
|
||||
static void HWR_UpdatePatchMipmap(patch_t *patch, GLMipmap_t *glMipmap)
|
||||
{
|
||||
GLPatch_t *glPatch = (GLPatch_t *)(patch->hardware);
|
||||
GLPatch_t *glPatch = static_cast<GLPatch_t *>(patch->hardware);
|
||||
HWR_MakePatch(patch, glPatch, glMipmap, true);
|
||||
|
||||
// If hardware does not have the texture, then call GL_SetTexture to upload it
|
||||
@@ -1103,7 +1089,7 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap)
|
||||
|
||||
if (!patch->hardware)
|
||||
Patch_CreateGL(patch);
|
||||
glPatch = (GLPatch_t *)(patch->hardware);
|
||||
glPatch = static_cast<GLPatch_t *>(patch->hardware);
|
||||
|
||||
// Blatant hack for encore colormapping aside...
|
||||
if (colormap == colormaps || colormap == NULL || colormap == (const UINT8*)(COLORMAP_REMAPOFFSET))
|
||||
@@ -1139,12 +1125,12 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap)
|
||||
// (it have a liste of mipmap)
|
||||
// this malloc is cleared in HWR_FreeColormapCache
|
||||
// (...) unfortunately z_malloc fragment alot the memory :(so malloc is better
|
||||
newMipmap = (GLMipmap_t *)(calloc(1, sizeof (*newMipmap)));
|
||||
newMipmap = static_cast<GLMipmap_t *>(calloc(1, sizeof (*newMipmap)));
|
||||
if (newMipmap == NULL)
|
||||
I_Error("%s: Out of memory", "HWR_GetMappedPatch");
|
||||
glMipmap->nextcolormap = newMipmap;
|
||||
|
||||
newMipmap->colormap = (GLColormap_t *)(Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL));
|
||||
newMipmap->colormap = static_cast<GLColormap_t *>(Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL));
|
||||
newMipmap->colormap->source = colormap;
|
||||
memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8));
|
||||
|
||||
@@ -1167,7 +1153,7 @@ patch_t *HWR_GetCachedGLPatchPwad(UINT16 wadnum, UINT16 lumpnum)
|
||||
{
|
||||
void *ptr = Z_Calloc(sizeof(patch_t), PU_PATCH, &lumpcache[lumpnum]);
|
||||
Patch_Create(NULL, 0, ptr);
|
||||
Patch_AllocateHardwarePatch((patch_t *)(ptr));
|
||||
Patch_AllocateHardwarePatch(static_cast<patch_t *>(ptr));
|
||||
}
|
||||
|
||||
return (patch_t *)(lumpcache[lumpnum]);
|
||||
@@ -1184,7 +1170,7 @@ static void HWR_DrawFadeMaskInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32
|
||||
{
|
||||
INT32 i,j;
|
||||
fixed_t posx, posy, stepx, stepy;
|
||||
UINT8 *block = (UINT8 *)(mipmap->data); // places the data directly into here
|
||||
UINT8 *block = static_cast<UINT8 *>(mipmap->data); // places the data directly into here
|
||||
UINT8 *flat;
|
||||
UINT8 *dest, *src, texel;
|
||||
RGBA_t col;
|
||||
@@ -1340,7 +1326,7 @@ void HWR_SetPalette(RGBA_t *palette)
|
||||
static void HWR_SetPaletteLookup(RGBA_t *palette)
|
||||
{
|
||||
int r, g, b;
|
||||
UINT8 *lut = (UINT8 *)(Z_Malloc(
|
||||
UINT8 *lut = static_cast<UINT8 *>(Z_Malloc(
|
||||
HWR_PALETTE_LUT_SIZE*HWR_PALETTE_LUT_SIZE*HWR_PALETTE_LUT_SIZE*sizeof(UINT8),
|
||||
PU_STATIC, NULL));
|
||||
#define STEP_SIZE (256/HWR_PALETTE_LUT_SIZE)
|
||||
@@ -1385,7 +1371,7 @@ void HWR_SetMapPalette(void)
|
||||
if (palsize < 768) // 256 * 3
|
||||
I_Error("HWR_SetMapPalette: A programmer assumed palette lumps are at least 768 bytes long, but apparently this was a wrong assumption!\n");
|
||||
|
||||
RGB_data = (UINT8 *)(W_CacheLumpNum(lumpnum, PU_CACHE));
|
||||
RGB_data = static_cast<UINT8 *>(W_CacheLumpNum(lumpnum, PU_CACHE));
|
||||
// we got the RGB palette now, but we need it in RGBA format.
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
@@ -1420,7 +1406,7 @@ static UINT32 HWR_CreateLightTable(UINT8 *lighttable)
|
||||
{
|
||||
UINT32 i, id;
|
||||
RGBA_t *palette = HWR_GetTexturePalette();
|
||||
RGBA_t *hw_lighttable = (RGBA_t *)(Z_Malloc(256 * 32 * sizeof(RGBA_t), PU_STATIC, NULL));
|
||||
RGBA_t *hw_lighttable = static_cast<RGBA_t *>(Z_Malloc(256 * 32 * sizeof(RGBA_t), PU_STATIC, NULL));
|
||||
|
||||
// To make the palette index -> RGBA mapping easier for the shader,
|
||||
// the hardware lighttable is composed of RGBA colors instead of palette indices.
|
||||
@@ -54,7 +54,7 @@ struct GLMipmap_s
|
||||
UINT16 width, height;
|
||||
UINT32 downloaded; // The GPU has this texture.
|
||||
|
||||
struct GLMipmap_s *nextcolormap;
|
||||
struct GLMipmap_s *nextcolormap;
|
||||
struct GLColormap_s *colormap;
|
||||
};
|
||||
typedef struct GLMipmap_s GLMipmap_t;
|
||||
|
||||
@@ -109,7 +109,7 @@ boolean HWR_InitShaders(void)
|
||||
// returns INT32_MAX if not found
|
||||
static INT32 strstr_int(const char *str1, const char *str2)
|
||||
{
|
||||
gconst char *location = strstr(str1, str2);
|
||||
char *location = strstr(str1, str2);
|
||||
if (location)
|
||||
return location - str1;
|
||||
else
|
||||
|
||||
@@ -1383,19 +1383,19 @@ void GL_Flush(void)
|
||||
// -----------------+
|
||||
INT32 GL_isExtAvailable(const char *extension, const GLubyte *start)
|
||||
{
|
||||
gconst GLubyte *where, *terminator;
|
||||
GLubyte *where, *terminator;
|
||||
|
||||
if (!extension || !start)
|
||||
return 0;
|
||||
|
||||
where = (gconst GLubyte *)strchr(extension, ' ');
|
||||
where = (GLubyte *) strchr(extension, ' ');
|
||||
|
||||
if (where || *extension == '\0')
|
||||
return 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
where = (gconst GLubyte *)strstr((const char *)start, extension);
|
||||
where = (GLubyte *) strstr((const char *) start, extension);
|
||||
|
||||
if (!where)
|
||||
break;
|
||||
|
||||
+9
-7
@@ -496,8 +496,10 @@ static void cleanupnodes(void)
|
||||
|
||||
// Why can't I start at zero?
|
||||
for (j = 1; j < MAXNETNODES; j++)
|
||||
{
|
||||
if (!(nodeingame[j] || SV_SendingFile(j)))
|
||||
nodeconnected[j] = false;
|
||||
}
|
||||
}
|
||||
|
||||
static SINT8 getfreenode(void)
|
||||
@@ -507,11 +509,13 @@ static SINT8 getfreenode(void)
|
||||
cleanupnodes();
|
||||
|
||||
for (j = 0; j < MAXNETNODES; j++)
|
||||
{
|
||||
if (!nodeconnected[j])
|
||||
{
|
||||
nodeconnected[j] = true;
|
||||
return j;
|
||||
}
|
||||
}
|
||||
|
||||
/** \warning No free node? Just in case a node might not have been freed properly,
|
||||
* look if there are connected nodes that aren't in game, and forget them.
|
||||
@@ -812,7 +816,7 @@ static void SOCK_Send(void)
|
||||
static void SOCK_FreeNodenum(INT32 numnode)
|
||||
{
|
||||
// can't disconnect from self :)
|
||||
if (!numnode || numnode > MAXNETNODES)
|
||||
if (numnode <= 0 || numnode > MAXNETNODES)
|
||||
return;
|
||||
|
||||
DEBFILE(va("Free node %d (%s)\n", numnode, SOCK_GetNodeAddress(numnode)));
|
||||
@@ -1432,14 +1436,12 @@ static void SOCK_RegisterHolePunch(void)
|
||||
|
||||
static boolean SOCK_OpenSocket(void)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
memset(clientaddress, 0, sizeof (clientaddress));
|
||||
memset(clientaddress, 0, sizeof(clientaddress));
|
||||
|
||||
memset(nodeconnected, false, sizeof(nodeconnected));
|
||||
nodeconnected[0] = true; // always connected to self
|
||||
for (i = 1; i < MAXNETNODES; i++)
|
||||
nodeconnected[i] = false;
|
||||
nodeconnected[BROADCASTADDR] = true;
|
||||
|
||||
I_NetSend = SOCK_Send;
|
||||
I_NetGet = SOCK_Get;
|
||||
I_NetCloseSocket = SOCK_CloseSocket;
|
||||
@@ -1479,7 +1481,7 @@ static boolean SOCK_Ban(INT32 node)
|
||||
{
|
||||
INT32 ban;
|
||||
|
||||
if (node > MAXNETNODES)
|
||||
if (node < 0 || node > MAXNETNODES)
|
||||
return false;
|
||||
|
||||
ban = numbans;
|
||||
|
||||
@@ -13,10 +13,6 @@
|
||||
#define LZF_H
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***********************************************************************
|
||||
**
|
||||
** lzf -- an extremely fast/free compression/decompression-method
|
||||
@@ -75,9 +71,5 @@ size_t
|
||||
lzf_decompress (const void *const in_data, size_t in_len,
|
||||
void *out_data, size_t out_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -4020,8 +4020,8 @@ I_mutex replayquerymutex;
|
||||
// to avoid infinite SIGABRT recursion in the signal handler
|
||||
// due to poisoned locks or mach-o kernel not supporting locks in signals
|
||||
// or something like that. idk
|
||||
# define Lock_search_state() if (!I_In_Exiting_Signal_Handler()) { I_lock_mutex(&replayquerymutex); }
|
||||
# define Unlock_search_state() if (!I_In_Exiting_Signal_Handler()) { I_unlock_mutex(replayquerymutex); }
|
||||
# define Lock_search_state() if (!I_In_Exiting_Signal_Handler()) { I_LockMutex(&replayquerymutex); }
|
||||
# define Unlock_search_state() if (!I_In_Exiting_Signal_Handler()) { I_UnlockMutex(replayquerymutex); }
|
||||
#else /*HAVE_THREADS*/
|
||||
# define Lock_search_state()
|
||||
# define Unlock_search_state()
|
||||
|
||||
+3
-19
@@ -1454,9 +1454,9 @@ INT32 axtoi(const char *hexStg)
|
||||
|
||||
void CopyCaretColors(char *p, const char *s, int n)
|
||||
{
|
||||
gconst char *t;
|
||||
int m;
|
||||
int c;
|
||||
char *t;
|
||||
int m;
|
||||
int c;
|
||||
|
||||
if (!n)
|
||||
return;
|
||||
@@ -1956,22 +1956,6 @@ UINT32 FNV1a_Hash(const char *message, size_t size)
|
||||
return hash;
|
||||
}
|
||||
|
||||
// Behaves like the old quickncasehash
|
||||
// Stops either if it encounters null terminator
|
||||
// or reaches size
|
||||
UINT32 FNV1a_QuickCaseHash(const char *message, size_t size)
|
||||
{
|
||||
UINT32 hash = FNV1A_OFFSET_BASIS;
|
||||
|
||||
for (size_t i = 0; i < size && message[i]; i++)
|
||||
{
|
||||
hash ^= tolower(message[i]);
|
||||
hash *= FNV1A_PRIME;
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
UINT32 FNV1a_HashString(const char *message)
|
||||
{
|
||||
UINT32 hash = FNV1A_OFFSET_BASIS;
|
||||
|
||||
@@ -123,7 +123,6 @@ FUNCMATH UINT8 M_CountBits(UINT32 num, UINT8 size);
|
||||
|
||||
// Hashes some message using FNV-1a
|
||||
UINT32 FNV1a_Hash(const char *message, size_t size);
|
||||
UINT32 FNV1a_QuickCaseHash(const char *message, size_t size);
|
||||
UINT32 FNV1a_HashString(const char *message);
|
||||
UINT32 FNV1a_HashLowercaseString(const char *message);
|
||||
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
#ifndef _MD5_H
|
||||
#define _MD5_H 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined (HAVE_LIMITS_H) || (defined (_LIBC) && _LIBC) || defined (_WIN32)
|
||||
@@ -56,8 +52,4 @@ int md5_stream(FILE *stream, void *resblock) THROWFUNC;
|
||||
digest. */
|
||||
extern void *md5_buffer(const char *buffer, size_t len, void *resblock) THROWFUNC;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif /* md5.h */
|
||||
+3
-3
@@ -622,7 +622,7 @@ Rloadtextures (INT32 i, INT32 w)
|
||||
|
||||
// Set texture properties.
|
||||
memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name));
|
||||
texture->hash = FNV1a_QuickCaseHash(texture->name, 8);
|
||||
texture->hash = quickncasehash(texture->name, 8);
|
||||
|
||||
texture->width = SHORT(patchlump.width);
|
||||
texture->height = SHORT(patchlump.height);
|
||||
@@ -1066,7 +1066,7 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
|
||||
// Allocate memory for a zero-patch texture. Obviously, we'll be adding patches momentarily.
|
||||
resultTexture = (texture_t *)Z_Calloc(sizeof(texture_t), PU_STATIC, NULL);
|
||||
memcpy(resultTexture->name, newTextureName, 8);
|
||||
resultTexture->hash = FNV1a_QuickCaseHash(newTextureName, 8);
|
||||
resultTexture->hash = quickncasehash(newTextureName, 8);
|
||||
resultTexture->width = newTextureWidth;
|
||||
resultTexture->height = newTextureHeight;
|
||||
resultTexture->type = TEXTURETYPE_COMPOSITE;
|
||||
@@ -1755,7 +1755,7 @@ INT32 R_CheckTextureNumForName(const char *name)
|
||||
if (name[0] == '-')
|
||||
return 0;
|
||||
|
||||
hash = FNV1a_QuickCaseHash(name, 8);
|
||||
hash = quickncasehash(name, 8);
|
||||
|
||||
for (i = 0; i < tidcachelen; i++)
|
||||
if (tidcache[i].hash == hash && !strncasecmp(tidcache[i].name, name, 8))
|
||||
|
||||
+4
-4
@@ -280,22 +280,22 @@ static void Fov_OnChange(void)
|
||||
|
||||
static void FlipCam_OnChange(void)
|
||||
{
|
||||
SendWeaponPref();
|
||||
SendWeaponPref(0);
|
||||
}
|
||||
|
||||
static void FlipCam2_OnChange(void)
|
||||
{
|
||||
SendWeaponPref2();
|
||||
SendWeaponPref(1);
|
||||
}
|
||||
|
||||
static void FlipCam3_OnChange(void)
|
||||
{
|
||||
SendWeaponPref3();
|
||||
SendWeaponPref(2);
|
||||
}
|
||||
|
||||
static void FlipCam4_OnChange(void)
|
||||
{
|
||||
SendWeaponPref4();
|
||||
SendWeaponPref(3);
|
||||
}
|
||||
|
||||
static void Precipstuff_OnChange(void)
|
||||
|
||||
+1
-1
@@ -2960,7 +2960,7 @@ fixed_t R_DoPlayerFade(mobj_t *thing)
|
||||
fixed_t fadealpha = FRACUNIT;
|
||||
static constexpr tic_t countdownstarttime = (15 * TICRATE) / 4; // starttime - (3*TICRATE)
|
||||
|
||||
if (thing->player == viewplayer || viewplayer->exiting || viewplayer->spectator || camera[R_GetViewNumber()].freecam || leveltime < countdownstarttime)
|
||||
if (thing->player == viewplayer || viewplayer->exiting || camera[R_GetViewNumber()].freecam || leveltime < countdownstarttime)
|
||||
return fadealpha;
|
||||
|
||||
const INT32 playerdist = (FixedMul((thing->x - viewx), viewcos) + FixedMul((thing->y - viewy), viewsin)) >> FRACBITS;
|
||||
|
||||
+2
-2
@@ -1301,7 +1301,7 @@ static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicde
|
||||
|
||||
STRBUFCPY(def->name, value);
|
||||
strlwr(def->name);
|
||||
def->hash = FNV1a_QuickCaseHash(def->name, 6);
|
||||
def->hash = quickncasehash (def->name, 6);
|
||||
}
|
||||
|
||||
(*defp) = def;
|
||||
@@ -1483,7 +1483,7 @@ void S_InitMusicDefs(void)
|
||||
//
|
||||
musicdef_t *S_FindMusicCredit(const char *musname)
|
||||
{
|
||||
UINT32 hash = FNV1a_QuickCaseHash(musname, 6);
|
||||
UINT32 hash = quickncasehash(musname, 6);
|
||||
musicdef_t *def;
|
||||
|
||||
for (INT32 i = 0; i < nummusicdefs; ++i)
|
||||
|
||||
@@ -1886,9 +1886,6 @@ INT32 I_StartupSystem(void)
|
||||
SDL_version SDLlinked;
|
||||
SDL_VERSION(&SDLcompiled)
|
||||
SDL_GetVersion(&SDLlinked);
|
||||
|
||||
W_Startup();
|
||||
|
||||
I_StartupConsole();
|
||||
#ifdef NEWSIGNALHANDLER
|
||||
// This is useful when debugging. It lets GDB attach to
|
||||
|
||||
+7
-10
@@ -23,26 +23,24 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stddef.h>
|
||||
|
||||
static inline int trycmp(char **pp, char *cp, const char *q, size_t qn)
|
||||
static inline int
|
||||
trycmp (char **pp, char *cp,
|
||||
const char *q, size_t qn)
|
||||
{
|
||||
char *p;
|
||||
p = (*pp);
|
||||
|
||||
if (strncasecmp(p, q, qn) == 0)
|
||||
return 0;
|
||||
|
||||
(*pp) = strchr(&p[1], (*cp));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline void swapp(char ***ppap, char ***ppbp, char **cpap, char **cpbp)
|
||||
static inline void
|
||||
swapp (char ***ppap, char ***ppbp, char **cpap, char **cpbp)
|
||||
{
|
||||
char **pp;
|
||||
char *p;
|
||||
@@ -56,7 +54,8 @@ static inline void swapp(char ***ppap, char ***ppbp, char **cpap, char **cpbp)
|
||||
*cpbp = p;
|
||||
}
|
||||
|
||||
char *nongnu_strcasestr(const char *s, const char *q)
|
||||
char *
|
||||
nongnu_strcasestr (const char *s, const char *q)
|
||||
{
|
||||
size_t qn;
|
||||
|
||||
@@ -114,5 +113,3 @@ char *nongnu_strcasestr(const char *s, const char *q)
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
-2119
File diff suppressed because it is too large.
Load diff
+178
-194
@@ -87,32 +87,18 @@ typedef struct
|
||||
} lumpchecklist_t;
|
||||
|
||||
// Must be a power of two
|
||||
#define LUMPNUMCACHESIZE 2048 // should be reasonable ig
|
||||
#define LUMPNUMCACHESIZE 64
|
||||
#define LUMPNUMCACHENAME 32
|
||||
|
||||
#define NAME lumpnum_map
|
||||
#define KEY_TY char *
|
||||
#define KEY_GET_CONST
|
||||
#define VAL_TY lumpnum_t
|
||||
#define HASH_FN vt_hash_string
|
||||
#define CMPR_FN vt_cmpr_string
|
||||
#define KEY_DTOR_FN free
|
||||
#include "verstable.h"
|
||||
typedef struct lumpnum_cache_s
|
||||
{
|
||||
char lumpname[LUMPNUMCACHENAME];
|
||||
lumpnum_t lumpnum;
|
||||
UINT32 hash;
|
||||
} lumpnum_cache_t;
|
||||
|
||||
#define NAME folder_map
|
||||
#define KEY_TY char *
|
||||
#define KEY_GET_CONST
|
||||
#define VAL_TY UINT16
|
||||
#define HASH_FN vt_hash_string
|
||||
#define CMPR_FN vt_cmpr_string
|
||||
#define KEY_DTOR_FN free
|
||||
#include "verstable.h"
|
||||
|
||||
static lumpnum_map lumpnumcache;
|
||||
|
||||
typedef struct FolderCache {
|
||||
folder_map map;
|
||||
} FolderCache;
|
||||
static lumpnum_cache_t lumpnumcache[LUMPNUMCACHESIZE];
|
||||
static UINT16 lumpnumcacheindex = 0;
|
||||
|
||||
static const char pat_central[] = {0x50, 0x4b, 0x01, 0x02, 0x00};
|
||||
static const char pat_end[] = {0x50, 0x4b, 0x05, 0x06, 0x00};
|
||||
@@ -130,8 +116,6 @@ wadfile_t *wadfiles[MAX_WADFILES] = {}; // 0 to numwadfiles-1 are valid
|
||||
// being ejected
|
||||
void W_Shutdown(void)
|
||||
{
|
||||
lumpnum_map_cleanup(&lumpnumcache);
|
||||
|
||||
while (numwadfiles--)
|
||||
{
|
||||
wadfile_t *wad = wadfiles[numwadfiles];
|
||||
@@ -143,28 +127,18 @@ void W_Shutdown(void)
|
||||
|
||||
while (wad->numlumps--)
|
||||
{
|
||||
//Z_Free(wad->lumpinfo[wad->numlumps].longname);
|
||||
Z_Free(wad->lumpinfo[wad->numlumps].longname);
|
||||
Z_Free(wad->lumpinfo[wad->numlumps].fullname);
|
||||
}
|
||||
|
||||
folder_map_cleanup(&wad->startfolders->map);
|
||||
free(wad->startfolders);
|
||||
folder_map_cleanup(&wad->endfolders->map);
|
||||
free(wad->endfolders);
|
||||
M_AATreeFree(wad->startfolders);
|
||||
M_AATreeFree(wad->endfolders);
|
||||
|
||||
Z_Free(wad->lumpinfo);
|
||||
Z_Free(wad);
|
||||
}
|
||||
}
|
||||
|
||||
// the lumpnum cache needs to be initialized before use
|
||||
// call this as early as possible!
|
||||
void W_Startup(void)
|
||||
{
|
||||
lumpnum_map_init(&lumpnumcache);
|
||||
lumpnum_map_reserve(&lumpnumcache, LUMPNUMCACHESIZE);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// LUMP BASED ROUTINES
|
||||
//===========================================================================
|
||||
@@ -285,7 +259,7 @@ static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum)
|
||||
lumpinfo_t *lump_p = &wadfiles[wadnum]->lumpinfo[posStart];
|
||||
|
||||
size_t length = len + 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name
|
||||
char *name = (char *)(malloc(length + 1));
|
||||
char *name = malloc(length + 1);
|
||||
|
||||
if (!name)
|
||||
I_Error("W_LoadDehackedLumpsPK3: Out of memory!\n");
|
||||
@@ -321,7 +295,7 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum)
|
||||
if (memcmp(lump_p->name, "SOC_", 4) == 0) // Check for generic SOC lump
|
||||
{ // shameless copy+paste of code from LUA_LoadLump
|
||||
size_t length = len + 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name
|
||||
char *name = (char *)(malloc(length + 1));
|
||||
char *name = malloc(length + 1);
|
||||
|
||||
if (!name)
|
||||
I_Error("W_LoadDehackedLumps: Out of memory!\n");
|
||||
@@ -386,12 +360,12 @@ static inline INT32 W_MakeFileMD5(const char *filename, void *resblock)
|
||||
}
|
||||
|
||||
// Invalidates the cache of lump numbers. Call this whenever a wad is added.
|
||||
FUNCINLINE static ATTRINLINE void W_InvalidateLumpnumCache(void)
|
||||
static void W_InvalidateLumpnumCache(void)
|
||||
{
|
||||
lumpnum_map_clear(&lumpnumcache);
|
||||
memset(lumpnumcache, 0, sizeof(lumpnumcache));
|
||||
}
|
||||
|
||||
FUNCINLINE static ATTRINLINE UINT32 W_HashLumpName(const char *name)
|
||||
UINT32 W_HashLumpName(const char *name)
|
||||
{
|
||||
return FNV1a_HashLowercaseString(name);
|
||||
}
|
||||
@@ -417,28 +391,28 @@ static restype_t ResourceFileDetect(const char* filename)
|
||||
*/
|
||||
static lumpinfo_t* ResGetLumpsStandalone(FILE* handle, UINT16* numlumps, const char* lumpname)
|
||||
{
|
||||
lumpinfo_t* lumpinfo = (lumpinfo_t *)(Z_Calloc(sizeof (*lumpinfo), PU_STATIC, NULL));
|
||||
lumpinfo_t* lumpinfo = Z_Calloc(sizeof (*lumpinfo), PU_STATIC, NULL);
|
||||
lumpinfo->position = 0;
|
||||
fseek(handle, 0, SEEK_END);
|
||||
lumpinfo->size = (size_t)(ftell(handle));
|
||||
lumpinfo->size = ftell(handle);
|
||||
fseek(handle, 0, SEEK_SET);
|
||||
strlcpy(lumpinfo->name, lumpname, sizeof(lumpinfo->name));
|
||||
lumpinfo->namelength = strlen(lumpinfo->name);
|
||||
lumpinfo->hash.name = W_HashLumpName(lumpname);
|
||||
|
||||
// Allocate the lump's long name.
|
||||
/*lumpinfo->longname = (char *)(Z_Malloc((lumpinfo->namelength + 1) * sizeof(char), PU_STATIC, NULL));
|
||||
lumpinfo->longname = Z_Malloc((lumpinfo->namelength + 1) * sizeof(char), PU_STATIC, NULL);
|
||||
strcpy(lumpinfo->longname, lumpname);
|
||||
lumpinfo->longname[lumpinfo->namelength] = '\0';
|
||||
lumpinfo->longnamelength = lumpinfo->namelength;
|
||||
lumpinfo->hash.longname = lumpinfo->hash.name;*/
|
||||
lumpinfo->hash.longname = lumpinfo->hash.name;
|
||||
|
||||
// Allocate the lump's full name.
|
||||
lumpinfo->fullname = (char *)(Z_Malloc((lumpinfo->namelength + 1) * sizeof(char), PU_STATIC, NULL));
|
||||
lumpinfo->fullname = Z_Malloc((lumpinfo->namelength + 1) * sizeof(char), PU_STATIC, NULL);
|
||||
strcpy(lumpinfo->fullname, lumpname);
|
||||
lumpinfo->fullname[lumpinfo->namelength] = '\0';
|
||||
lumpinfo->fullnamelength = lumpinfo->namelength;
|
||||
//lumpinfo->hash.fullname = lumpinfo->hash.name;
|
||||
lumpinfo->hash.fullname = lumpinfo->hash.name;
|
||||
|
||||
*numlumps = 1;
|
||||
return lumpinfo;
|
||||
@@ -482,7 +456,7 @@ static lumpinfo_t* ResGetLumpsWad(FILE* handle, UINT16* nlmp, const char* filena
|
||||
|
||||
// read wad file directory
|
||||
i = header.numlumps * sizeof(*fileinfo);
|
||||
fileinfov = fileinfo = (filelump_t *)(malloc(i));
|
||||
fileinfov = fileinfo = malloc(i);
|
||||
|
||||
if (fseek(handle, header.infotableofs, SEEK_SET) == -1
|
||||
|| fread(fileinfo, 1, i, handle) < i)
|
||||
@@ -494,7 +468,7 @@ static lumpinfo_t* ResGetLumpsWad(FILE* handle, UINT16* nlmp, const char* filena
|
||||
numlumps = header.numlumps;
|
||||
|
||||
// fill in lumpinfo for this wad
|
||||
lump_p = lumpinfo = (lumpinfo_t *)(Z_Malloc(numlumps * sizeof (*lumpinfo), PU_STATIC, NULL));
|
||||
lump_p = lumpinfo = Z_Malloc(numlumps * sizeof (*lumpinfo), PU_STATIC, NULL);
|
||||
|
||||
for (i = 0; i < numlumps; i++, lump_p++, fileinfo++)
|
||||
{
|
||||
@@ -538,18 +512,18 @@ static lumpinfo_t* ResGetLumpsWad(FILE* handle, UINT16* nlmp, const char* filena
|
||||
lump_p->hash.name = W_HashLumpName(lump_p->name);
|
||||
|
||||
// Allocate the lump's long name.
|
||||
/*lump_p->longname = (char *)(Z_Malloc(9 * sizeof(char), PU_STATIC, NULL));
|
||||
lump_p->longname = Z_Malloc(9 * sizeof(char), PU_STATIC, NULL);
|
||||
strncpy(lump_p->longname, fileinfo->name, 8);
|
||||
lump_p->longname[8] = '\0';
|
||||
lump_p->longnamelength = lump_p->namelength;
|
||||
lump_p->hash.longname = lump_p->hash.name;*/
|
||||
lump_p->hash.longname = lump_p->hash.name;
|
||||
|
||||
// Allocate the lump's full name.
|
||||
lump_p->fullname = (char *)(Z_Malloc(9 * sizeof(char), PU_STATIC, NULL));
|
||||
lump_p->fullname = Z_Malloc(9 * sizeof(char), PU_STATIC, NULL);
|
||||
strncpy(lump_p->fullname, fileinfo->name, 8);
|
||||
lump_p->fullname[8] = '\0';
|
||||
lump_p->fullnamelength = lump_p->namelength;
|
||||
//lump_p->hash.fullname = lump_p->hash.name;
|
||||
lump_p->hash.fullname = lump_p->hash.name;
|
||||
}
|
||||
|
||||
*nlmp = numlumps;
|
||||
@@ -566,24 +540,24 @@ static boolean ResFindSignature(FILE* handle, const char endPat[], UINT32 startp
|
||||
int c;
|
||||
|
||||
fseek(handle, 0, SEEK_END);
|
||||
size_t len = (size_t)(ftell(handle));
|
||||
size_t len = ftell(handle);
|
||||
|
||||
fseek(handle, startpos, SEEK_SET);
|
||||
size_t remaining = (size_t)(len - startpos);
|
||||
size_t chunkpos = (size_t)(startpos);
|
||||
size_t remaining = len - startpos;
|
||||
size_t chunkpos = startpos;
|
||||
|
||||
s = endPat;
|
||||
|
||||
//128k buffers
|
||||
size_t buffer_size = min(128 * 1024 * sizeof(char), remaining);
|
||||
CLEANUP(pfree) char* buffer = (char *)(malloc(buffer_size));
|
||||
CLEANUP(pfree) char* buffer = (char*)(malloc(buffer_size));
|
||||
|
||||
size_t bytes_read = 0;
|
||||
while ((bytes_read = fread(buffer, 1, buffer_size, handle)) > 0)
|
||||
{
|
||||
for (size_t i = 0; i < bytes_read; i++)
|
||||
{
|
||||
c = (int)(buffer[i]);
|
||||
c = (int)buffer[i];
|
||||
|
||||
if (*s != c && s > endPat) // No match?
|
||||
s = endPat; // We "reset" the counter by sending the s pointer back to the start of the array.
|
||||
@@ -595,7 +569,7 @@ static boolean ResFindSignature(FILE* handle, const char endPat[], UINT32 startp
|
||||
if (*s == 0x00) // The array pointer has reached the key char which marks the end. It means we have matched the signature.
|
||||
{
|
||||
//the original function would leave the FILE* seeked to the end of the match
|
||||
size_t foundpos = (size_t)(chunkpos + i + 1);
|
||||
size_t foundpos = chunkpos + i + 1;
|
||||
fseek(handle, foundpos, SEEK_SET);
|
||||
return true;
|
||||
}
|
||||
@@ -672,7 +646,7 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp)
|
||||
// Contains entry number (number of lumps), and central directory start offset.
|
||||
fseek(handle, 0, SEEK_END);
|
||||
|
||||
const long startpos = ftell(handle) - (22 + 65536);
|
||||
const long startpos = (ftell(handle) - (22 + 65536));
|
||||
if (!ResFindSignature(handle, pat_end, max(0l, startpos)))
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "Missing central directory\n");
|
||||
@@ -688,11 +662,11 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp)
|
||||
|
||||
numlumps = SHORT(zend.entries);
|
||||
|
||||
lump_p = lumpinfo = (lumpinfo_t *)(Z_Malloc(numlumps * sizeof (*lumpinfo), PU_STATIC, NULL));
|
||||
lump_p = lumpinfo = Z_Malloc(numlumps * sizeof (*lumpinfo), PU_STATIC, NULL);
|
||||
|
||||
fseek(handle, LONG(zend.cdiroffset), SEEK_SET);
|
||||
|
||||
CLEANUP(Z_Pfree) char *cdir = (char *)(Z_Malloc(LONG(zend.cdirsize), PU_STATIC, &cdir));
|
||||
CLEANUP(Z_Pfree) char *cdir = Z_Malloc(LONG(zend.cdirsize), PU_STATIC, &cdir);
|
||||
|
||||
if (fread(cdir, 1, LONG(zend.cdirsize), handle) < (UINT32)(LONG(zend.cdirsize)))
|
||||
{
|
||||
@@ -705,7 +679,7 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp)
|
||||
|
||||
for (i = 0; i < numlumps; i++, lump_p++)
|
||||
{
|
||||
zentry_t *zentry = (zentry_t *)(cdir + offset);
|
||||
zentry_t *zentry = (zentry_t*)(cdir + offset);
|
||||
char* fullname;
|
||||
char* trimname;
|
||||
char* dotpos;
|
||||
@@ -721,9 +695,8 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp)
|
||||
lump_p->disksize = LONG(zentry->compsize);
|
||||
lump_p->size = LONG(zentry->size);
|
||||
|
||||
fullname = (char *)(malloc(SHORT(zentry->namelen) + 1));
|
||||
strncpy(fullname, (char *)(zentry + 1), SHORT(zentry->namelen));
|
||||
fullname[zentry->namelen] = 0;
|
||||
fullname = (char*)(malloc(SHORT(zentry->namelen) + 1));
|
||||
strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1);
|
||||
|
||||
// Strip away file address and extension for the 8char name.
|
||||
if ((trimname = strrchr(fullname, '/')) != NULL)
|
||||
@@ -739,15 +712,15 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp)
|
||||
lump_p->namelength = strlen(lump_p->name);
|
||||
lump_p->hash.name = W_HashLumpName(lump_p->name);
|
||||
|
||||
/*lump_p->longname = (char *)(Z_Calloc(dotpos - trimname + 1, PU_STATIC, NULL));
|
||||
lump_p->longname = Z_Calloc(dotpos - trimname + 1, PU_STATIC, NULL);
|
||||
strlcpy(lump_p->longname, trimname, dotpos - trimname + 1);
|
||||
lump_p->longnamelength = strlen(lump_p->longname);
|
||||
lump_p->hash.longname = W_HashLumpName(lump_p->longname);*/
|
||||
lump_p->hash.longname = W_HashLumpName(lump_p->longname);
|
||||
|
||||
lump_p->fullname = (char *)(Z_Calloc(SHORT(zentry->namelen) + 1, PU_STATIC, NULL));
|
||||
lump_p->fullname = (char*)(Z_Calloc(SHORT(zentry->namelen) + 1, PU_STATIC, NULL));
|
||||
strncpy(lump_p->fullname, fullname, SHORT(zentry->namelen));
|
||||
lump_p->fullnamelength = zentry->namelen;
|
||||
//lump_p->hash.fullname = W_HashLumpName(lump_p->fullname);
|
||||
lump_p->hash.fullname = W_HashLumpName(lump_p->fullname);
|
||||
|
||||
switch(SHORT(zentry->compression))
|
||||
{
|
||||
@@ -922,19 +895,17 @@ UINT16 W_InitFile(const char *filename, boolean local, boolean startup)
|
||||
//
|
||||
// link wad file to search files
|
||||
//
|
||||
wadfile = (wadfile_t *)(Z_Calloc(sizeof (*wadfile), PU_STATIC, NULL));
|
||||
wadfile = Z_Calloc(sizeof (*wadfile), PU_STATIC, NULL);
|
||||
wadfile->filename = Z_StrDup(filename);
|
||||
wadfile->handle = handle;
|
||||
wadfile->numlumps = (UINT16)(numlumps);
|
||||
wadfile->numlumps = (UINT16)numlumps;
|
||||
wadfile->lumpinfo = lumpinfo;
|
||||
wadfile->important = important;
|
||||
fseek(handle, 0, SEEK_END);
|
||||
wadfile->filesize = (unsigned)(ftell(handle));
|
||||
wadfile->filesize = (unsigned)ftell(handle);
|
||||
wadfile->type = type;
|
||||
wadfile->startfolders = (FolderCache *)malloc(sizeof(FolderCache));
|
||||
folder_map_init(&wadfile->startfolders->map);
|
||||
wadfile->endfolders = (FolderCache *)malloc(sizeof(FolderCache));
|
||||
folder_map_init(&wadfile->endfolders->map);
|
||||
wadfile->startfolders = M_AATreeAlloc(AATREE_STRING);
|
||||
wadfile->endfolders = M_AATreeAlloc(AATREE_STRING);
|
||||
|
||||
// already generated, just copy it over
|
||||
memcpy(&wadfile->md5sum, &md5sum, 16);
|
||||
@@ -959,7 +930,7 @@ UINT16 W_InitFile(const char *filename, boolean local, boolean startup)
|
||||
#ifdef HWRENDER
|
||||
// Read shaders from file
|
||||
if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED))
|
||||
HWR_LoadCustomShadersFromFile(numwadfiles - 1, (boolean)(type == RET_PK3));
|
||||
HWR_LoadCustomShadersFromFile(numwadfiles - 1, (type == RET_PK3));
|
||||
#endif
|
||||
|
||||
// TODO: HACK ALERT - Load Lua & SOC stuff right here. I feel like this should be out of this place, but... Let's stick with this for now.
|
||||
@@ -1059,7 +1030,7 @@ INT32 W_AddAutoloadedLocalFiles(char **filenames)
|
||||
/** Make sure a lump number is valid.
|
||||
* Compiles away to nothing if PARANOIA is not defined.
|
||||
*/
|
||||
static inline boolean TestValidLump(UINT16 wad, UINT16 lump)
|
||||
static boolean TestValidLump(UINT16 wad, UINT16 lump)
|
||||
{
|
||||
I_Assert(wad < MAX_WADFILES);
|
||||
if (!wadfiles[wad]) // make sure the wad file exists
|
||||
@@ -1082,7 +1053,7 @@ const char *W_CheckNameForNumPwad(UINT16 wad, UINT16 lump)
|
||||
|
||||
const char *W_CheckNameForNum(lumpnum_t lumpnum)
|
||||
{
|
||||
return W_CheckNameForNumPwad(WADFILENUM(lumpnum), LUMPNUM(lumpnum));
|
||||
return W_CheckNameForNumPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum));
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1136,7 +1107,7 @@ UINT16 W_CheckNumForNamePwad(const char *name, UINT16 wad, UINT16 startlump)
|
||||
// Should be the only version, but that's not possible until we fix
|
||||
// all the instances of non null-terminated strings in the codebase...
|
||||
//
|
||||
/*UINT16 W_CheckNumForLongNamePwad(const char *name, UINT16 wad, UINT16 startlump)
|
||||
UINT16 W_CheckNumForLongNamePwad(const char *name, UINT16 wad, UINT16 startlump)
|
||||
{
|
||||
UINT16 i;
|
||||
UINT32 hash;
|
||||
@@ -1168,46 +1139,43 @@ UINT16 W_CheckNumForNamePwad(const char *name, UINT16 wad, UINT16 startlump)
|
||||
|
||||
// not found.
|
||||
return INT16_MAX;
|
||||
}*/
|
||||
}
|
||||
|
||||
UINT16 W_CheckNumForMarkerStartPwad(const char *name, UINT16 wad, UINT16 startlump)
|
||||
{
|
||||
UINT16 marker;
|
||||
|
||||
marker = W_CheckNumForNamePwad(name, wad, startlump);
|
||||
if (marker != INT16_MAX)
|
||||
marker++; // Do not count the first marker
|
||||
|
||||
return marker;
|
||||
}
|
||||
|
||||
// Look for the first lump from a folder.
|
||||
UINT16 W_CheckNumForFolderStartPK3(const char *name, UINT16 wad, UINT16 startlump)
|
||||
{
|
||||
UINT16 i;
|
||||
size_t namelen;
|
||||
size_t name_length;
|
||||
INT32 i;
|
||||
lumpinfo_t *lump_p = wadfiles[wad]->lumpinfo + startlump;
|
||||
name_length = strlen(name);
|
||||
|
||||
folder_map_itr it = folder_map_get(&wadfiles[wad]->startfolders->map, name);
|
||||
if (!folder_map_is_end(it))
|
||||
return it.data->val;
|
||||
|
||||
namelen = strlen(name);
|
||||
void *val = M_AATreeGetString(wadfiles[wad]->startfolders, name);
|
||||
if (val != NULL)
|
||||
return (uintptr_t)val;
|
||||
|
||||
for (i = startlump; i < wadfiles[wad]->numlumps; i++, lump_p++)
|
||||
{
|
||||
if (strnicmp(name, lump_p->fullname, namelen) == 0)
|
||||
if (strnicmp(name, lump_p->fullname, name_length) == 0)
|
||||
{
|
||||
/* SLADE is special and puts a single directory entry. Skip that. */
|
||||
if (lump_p->fullnamelength == namelen)
|
||||
if (strlen(lump_p->fullname) == name_length)
|
||||
i++;
|
||||
|
||||
folder_map_insert(&wadfiles[wad]->startfolders->map, strdup(name), i);
|
||||
M_AATreeSetString(wadfiles[wad]->startfolders, name, (void *)(uintptr_t)i);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
folder_map_insert(&wadfiles[wad]->startfolders->map, strdup(name), INT16_MAX);
|
||||
M_AATreeSetString(wadfiles[wad]->startfolders, name, (void *)INT16_MAX);
|
||||
return INT16_MAX;
|
||||
}
|
||||
|
||||
@@ -1216,23 +1184,21 @@ UINT16 W_CheckNumForFolderStartPK3(const char *name, UINT16 wad, UINT16 startlum
|
||||
// Returns the position of the lumpinfo entry.
|
||||
UINT16 W_CheckNumForFolderEndPK3(const char *name, UINT16 wad, UINT16 startlump)
|
||||
{
|
||||
UINT16 i;
|
||||
size_t namelen;
|
||||
INT32 i;
|
||||
lumpinfo_t *lump_p = wadfiles[wad]->lumpinfo + startlump;
|
||||
size_t name_length = strlen(name);
|
||||
|
||||
folder_map_itr it = folder_map_get(&wadfiles[wad]->endfolders->map, name);
|
||||
if (!folder_map_is_end(it))
|
||||
return it.data->val;
|
||||
|
||||
namelen = strlen(name);
|
||||
void *val = M_AATreeGetString(wadfiles[wad]->endfolders, name);
|
||||
if (val != NULL)
|
||||
return (uintptr_t)val;
|
||||
|
||||
for (i = startlump; i < wadfiles[wad]->numlumps; i++, lump_p++)
|
||||
{
|
||||
if (strnicmp(name, lump_p->fullname, namelen))
|
||||
if (strnicmp(name, lump_p->fullname, name_length))
|
||||
break;
|
||||
}
|
||||
|
||||
folder_map_insert(&wadfiles[wad]->endfolders->map, strdup(name), i);
|
||||
M_AATreeSetString(wadfiles[wad]->endfolders, name, (void *)(uintptr_t)i);
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -1240,15 +1206,13 @@ UINT16 W_CheckNumForFolderEndPK3(const char *name, UINT16 wad, UINT16 startlump)
|
||||
// Returns lump position in PK3's lumpinfo, or INT16_MAX if not found.
|
||||
UINT16 W_CheckNumForFullNamePK3(const char *name, UINT16 wad, UINT16 startlump)
|
||||
{
|
||||
UINT16 i;
|
||||
size_t namelen;
|
||||
INT32 i;
|
||||
lumpinfo_t *lump_p = wadfiles[wad]->lumpinfo + startlump;
|
||||
|
||||
namelen = strlen(name);
|
||||
size_t name_length = strlen(name);
|
||||
|
||||
for (i = startlump; i < wadfiles[wad]->numlumps; i++, lump_p++)
|
||||
{
|
||||
if (!strnicmp(name, lump_p->fullname, namelen))
|
||||
if (!strnicmp(name, lump_p->fullname, name_length))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
@@ -1258,19 +1222,61 @@ UINT16 W_CheckNumForFullNamePK3(const char *name, UINT16 wad, UINT16 startlump)
|
||||
return INT16_MAX;
|
||||
}
|
||||
|
||||
FUNCINLINE static ATTRINLINE lumpnum_t CheckLumpInCache(const char *name)
|
||||
static lumpnum_t CheckLumpInCache(const char *name, boolean longname)
|
||||
{
|
||||
lumpnum_map_itr it = lumpnum_map_get(&lumpnumcache, name);
|
||||
if (!lumpnum_map_is_end(it))
|
||||
return it.data->val;
|
||||
if (longname)
|
||||
{
|
||||
UINT32 hash = quickncasehash(name, 32);
|
||||
|
||||
// Loop backwards so that we check most recent entries first
|
||||
for (INT32 i = lumpnumcacheindex + LUMPNUMCACHESIZE; i > lumpnumcacheindex; i--)
|
||||
{
|
||||
if (lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].hash == hash
|
||||
&& fasticmp(lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].lumpname, name))
|
||||
{
|
||||
lumpnumcacheindex = i & (LUMPNUMCACHESIZE - 1);
|
||||
return lumpnumcache[lumpnumcacheindex].lumpnum;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UINT32 hash = quickncasehash(name, 8);
|
||||
|
||||
// Loop backwards so that we check most recent entries first
|
||||
for (INT32 i = lumpnumcacheindex + LUMPNUMCACHESIZE; i > lumpnumcacheindex; i--)
|
||||
{
|
||||
if (lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].hash == hash
|
||||
&& lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].lumpname[8] == '\0'
|
||||
&& strnicmp(lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].lumpname, name, 8) == 0)
|
||||
{
|
||||
lumpnumcacheindex = i & (LUMPNUMCACHESIZE - 1);
|
||||
return lumpnumcache[lumpnumcacheindex].lumpnum;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return LUMPERROR;
|
||||
}
|
||||
|
||||
FUNCINLINE static ATTRINLINE void AddLumpToCache(lumpnum_t lumpnum, const char *name)
|
||||
static void AddLumpToCache(lumpnum_t lumpnum, const char *name, boolean longname)
|
||||
{
|
||||
I_Assert(strlen(name) <= 8); // we dont have longnames, so assume this is a non terminated string
|
||||
lumpnum_map_insert(&lumpnumcache, strdup(name), lumpnum);
|
||||
if (longname && strlen(name) >= LUMPNUMCACHENAME)
|
||||
return;
|
||||
|
||||
lumpnumcacheindex = (lumpnumcacheindex + 1) & (LUMPNUMCACHESIZE - 1);
|
||||
memset(lumpnumcache[lumpnumcacheindex].lumpname, '\0', LUMPNUMCACHENAME);
|
||||
if (longname)
|
||||
{
|
||||
strlcpy(lumpnumcache[lumpnumcacheindex].lumpname, name, LUMPNUMCACHENAME);
|
||||
lumpnumcache[lumpnumcacheindex].hash = quickncasehash(name, LUMPNUMCACHENAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(lumpnumcache[lumpnumcacheindex].lumpname, name, 8);
|
||||
lumpnumcache[lumpnumcacheindex].hash = quickncasehash(name, 8);
|
||||
}
|
||||
lumpnumcache[lumpnumcacheindex].lumpnum = lumpnum;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1286,14 +1292,14 @@ lumpnum_t W_CheckNumForName(const char *name)
|
||||
return LUMPERROR;
|
||||
|
||||
// Check the lumpnumcache first.
|
||||
lumpnum_t cachenum = CheckLumpInCache(name);
|
||||
lumpnum_t cachenum = CheckLumpInCache(name, false);
|
||||
if (cachenum != LUMPERROR)
|
||||
return cachenum;
|
||||
|
||||
// scan wad files backwards so patch lump files take precedence
|
||||
for (i = numwadfiles - 1; i >= 0; i--)
|
||||
{
|
||||
check = W_CheckNumForNamePwad(name, (UINT16)(i), 0);
|
||||
check = W_CheckNumForNamePwad(name, (UINT16)i, 0);
|
||||
|
||||
if (check != INT16_MAX)
|
||||
break; //found it
|
||||
@@ -1307,7 +1313,7 @@ lumpnum_t W_CheckNumForName(const char *name)
|
||||
{
|
||||
// Update the cache.
|
||||
lumpnum_t lumpnum = (i << 16) | check;
|
||||
AddLumpToCache(lumpnum, name);
|
||||
AddLumpToCache(lumpnum, name, false);
|
||||
|
||||
return lumpnum;
|
||||
}
|
||||
@@ -1319,7 +1325,7 @@ lumpnum_t W_CheckNumForName(const char *name)
|
||||
// Should be the only version, but that's not possible until we fix
|
||||
// all the instances of non null-terminated strings in the codebase...
|
||||
//
|
||||
/*lumpnum_t W_CheckNumForLongName(const char *name)
|
||||
lumpnum_t W_CheckNumForLongName(const char *name)
|
||||
{
|
||||
INT32 i;
|
||||
lumpnum_t check = INT16_MAX;
|
||||
@@ -1328,14 +1334,14 @@ lumpnum_t W_CheckNumForName(const char *name)
|
||||
return LUMPERROR;
|
||||
|
||||
// Check the lumpnumcache first.
|
||||
lumpnum_t cachenum = CheckLumpInCache(name);
|
||||
lumpnum_t cachenum = CheckLumpInCache(name, true);
|
||||
if (cachenum != LUMPERROR)
|
||||
return cachenum;
|
||||
|
||||
// scan wad files backwards so patch lump files take precedence
|
||||
for (i = numwadfiles - 1; i >= 0; i--)
|
||||
{
|
||||
check = W_CheckNumForLongNamePwad(name, (UINT16)(i), 0);
|
||||
check = W_CheckNumForLongNamePwad(name, (UINT16)i, 0);
|
||||
|
||||
if (check != INT16_MAX)
|
||||
break; //found it
|
||||
@@ -1349,11 +1355,11 @@ lumpnum_t W_CheckNumForName(const char *name)
|
||||
{
|
||||
// Update the cache.
|
||||
lumpnum_t lumpnum = (i << 16) | check;
|
||||
AddLumpToCache(lumpnum, name);
|
||||
AddLumpToCache(lumpnum, name, true);
|
||||
|
||||
return lumpnum;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
//
|
||||
// W_GetNumForName
|
||||
@@ -1378,7 +1384,7 @@ lumpnum_t W_GetNumForName(const char *name)
|
||||
// Should be the only version, but that's not possible until we fix
|
||||
// all the instances of non null-terminated strings in the codebase...
|
||||
//
|
||||
/*lumpnum_t W_GetNumForLongName(const char *name)
|
||||
lumpnum_t W_GetNumForLongName(const char *name)
|
||||
{
|
||||
lumpnum_t i;
|
||||
|
||||
@@ -1388,7 +1394,7 @@ lumpnum_t W_GetNumForName(const char *name)
|
||||
I_Error("W_GetNumForLongName: %s not found!\n", name);
|
||||
|
||||
return i;
|
||||
}*/
|
||||
}
|
||||
|
||||
//
|
||||
// W_CheckNumForNameInBlock
|
||||
@@ -1405,49 +1411,32 @@ lumpnum_t W_CheckNumForNameInBlock(const char *name, const char *blockstart, con
|
||||
{
|
||||
if (wadfiles[i]->type == RET_WAD)
|
||||
{
|
||||
bsid = W_CheckNumForNamePwad(blockstart, (UINT16)(i), 0);
|
||||
bsid = W_CheckNumForNamePwad(blockstart, (UINT16)i, 0);
|
||||
if (bsid == INT16_MAX)
|
||||
continue; // Start block doesn't exist?
|
||||
beid = W_CheckNumForNamePwad(blockend, (UINT16)(i), 0);
|
||||
beid = W_CheckNumForNamePwad(blockend, (UINT16)i, 0);
|
||||
if (beid == INT16_MAX)
|
||||
continue; // End block doesn't exist?
|
||||
|
||||
check = W_CheckNumForNamePwad(name, (UINT16)(i), bsid);
|
||||
check = W_CheckNumForNamePwad(name, (UINT16)i, bsid);
|
||||
if (check < beid)
|
||||
return (i << 16)+check; // found it, in our constraints
|
||||
return (i<<16)+check; // found it, in our constraints
|
||||
}
|
||||
}
|
||||
|
||||
return LUMPERROR;
|
||||
}
|
||||
|
||||
// Used by Lua. Case sensitive lump checking, quickly...
|
||||
UINT8 W_LumpExists(const char *name)
|
||||
{
|
||||
INT32 i, j;
|
||||
UINT32 hash;
|
||||
size_t namelen;
|
||||
|
||||
// Check the lumpnumcache first.
|
||||
lumpnum_t cachenum = CheckLumpInCache(name);
|
||||
if (cachenum != LUMPERROR)
|
||||
return true;
|
||||
|
||||
namelen = strlen(name);
|
||||
hash = W_HashLumpName(name);
|
||||
|
||||
INT32 i,j;
|
||||
for (i = numwadfiles - 1; i >= 0; i--)
|
||||
{
|
||||
lumpinfo_t *lump_p = wadfiles[i]->lumpinfo;
|
||||
for (j = 0; j < wadfiles[i]->numlumps; ++j, ++lump_p)
|
||||
{
|
||||
if (lump_p->namelength == namelen
|
||||
&& lump_p->hash.name == hash
|
||||
&& fastcmp(lump_p->name, name))
|
||||
if (fastcmp(lump_p->name, name))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1607,13 +1596,13 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si
|
||||
fseek(handle, (long)(l->position + offset), SEEK_SET);
|
||||
|
||||
// But let's not copy it yet. We support different compression formats on lumps, so we need to take that into account.
|
||||
switch (wadfiles[wad]->lumpinfo[lump].compression)
|
||||
switch(wadfiles[wad]->lumpinfo[lump].compression)
|
||||
{
|
||||
case CM_NOCOMPRESSION: // If it's uncompressed, we directly write the data into our destination, and return the bytes read.
|
||||
#ifdef NO_PNG_LUMPS
|
||||
{
|
||||
size_t bytesread = fread(dest, 1, size, handle);
|
||||
ErrorIfPNG((UINT8 *)(dest), bytesread, wadfiles[wad]->filename, l->fullname);
|
||||
ErrorIfPNG((UINT8 *)dest, bytesread, wadfiles[wad]->filename, l->fullname);
|
||||
return bytesread;
|
||||
}
|
||||
#else
|
||||
@@ -1626,8 +1615,8 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si
|
||||
char *decData; // Lump's decompressed real data.
|
||||
size_t retval; // Helper var, lzf_decompress returns 0 when an error occurs.
|
||||
|
||||
rawData = (char *)(Z_Malloc(l->disksize, PU_STATIC, NULL));
|
||||
decData = (char *)(Z_Malloc(l->size, PU_STATIC, NULL));
|
||||
rawData = Z_Malloc(l->disksize, PU_STATIC, NULL);
|
||||
decData = Z_Malloc(l->size, PU_STATIC, NULL);
|
||||
|
||||
if (fread(rawData, 1, l->disksize, handle) < l->disksize)
|
||||
I_Error("wad %d, lump %d: cannot read compressed data", wad, lump);
|
||||
@@ -1654,7 +1643,7 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si
|
||||
Z_Free(rawData);
|
||||
Z_Free(decData);
|
||||
#ifdef NO_PNG_LUMPS
|
||||
ErrorIfPNG((UINT8 *)(dest), size, wadfiles[wad]->filename, l->fullname);
|
||||
ErrorIfPNG((UINT8 *)dest, size, wadfiles[wad]->filename, l->fullname);
|
||||
#endif
|
||||
return size;
|
||||
#else
|
||||
@@ -1674,8 +1663,8 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si
|
||||
unsigned long rawSize = l->disksize;
|
||||
unsigned long decSize = size;
|
||||
|
||||
rawData = (UINT8 *)(Z_Malloc(rawSize, PU_STATIC, NULL));
|
||||
decData = (UINT8 *)(dest);
|
||||
rawData = Z_Malloc(rawSize, PU_STATIC, NULL);
|
||||
decData = dest;
|
||||
|
||||
if (fread(rawData, 1, rawSize, handle) < rawSize)
|
||||
I_Error("wad %d, lump %d: cannot read compressed data", wad, lump);
|
||||
@@ -1711,7 +1700,7 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si
|
||||
Z_Free(rawData);
|
||||
|
||||
#ifdef NO_PNG_LUMPS
|
||||
ErrorIfPNG((UINT8 *)(dest), size, wadfiles[wad]->filename, l->fullname);
|
||||
ErrorIfPNG((UINT8 *)dest, size, wadfiles[wad]->filename, l->fullname);
|
||||
#endif
|
||||
return size;
|
||||
}
|
||||
@@ -1899,7 +1888,7 @@ void *W_CacheSoftwarePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag)
|
||||
W_ReadLumpHeaderPwad(wad, lump, lumpdata, 0, 0);
|
||||
|
||||
dest = Z_Calloc(sizeof(patch_t), tag, &lumpcache[lump]);
|
||||
Patch_Create((softwarepatch_t *)(lumpdata), len, dest);
|
||||
Patch_Create((softwarepatch_t*)lumpdata, len, dest);
|
||||
|
||||
Z_Free(lumpdata);
|
||||
}
|
||||
@@ -1921,7 +1910,7 @@ void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag)
|
||||
if (!TestValidLump(wad, lump))
|
||||
return NULL;
|
||||
|
||||
patch = (patch_t *)(W_CacheSoftwarePatchNumPwad(wad, lump, tag));
|
||||
patch = (patch_t *)W_CacheSoftwarePatchNumPwad(wad, lump, tag);
|
||||
|
||||
if (patch == NULL)
|
||||
return NULL;
|
||||
@@ -1932,7 +1921,7 @@ void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag)
|
||||
Patch_CreateGL(patch);
|
||||
#endif
|
||||
|
||||
return (void*)(patch);
|
||||
return (void *)patch;
|
||||
}
|
||||
|
||||
void *W_CachePatchNum(lumpnum_t lumpnum, INT32 tag)
|
||||
@@ -1950,20 +1939,17 @@ void *W_GetCachedPatchNumPwad(UINT16 wad, UINT16 lump)
|
||||
|
||||
#ifdef ROTSPRITE
|
||||
// Caches a rotsprite for patch rotation.
|
||||
void *W_GetCachedRotPatchPwad(UINT16 wad, UINT16 lump)
|
||||
void *W_GetCachedRotPatchPwad(UINT16 wadnum, UINT16 lumpnum)
|
||||
{
|
||||
if (!TestValidLump(wad, lump))
|
||||
return NULL;
|
||||
lumpcache_t *rotcache = wadfiles[wadnum]->rotcache;
|
||||
|
||||
lumpcache_t *rotcache = wadfiles[wad]->rotcache;
|
||||
|
||||
if (!rotcache[lump])
|
||||
if (!rotcache[lumpnum])
|
||||
{
|
||||
rotsprite_t *rspr = RotatedPatch_Create(ROTANGLES);
|
||||
Z_SetUser(rspr, (void**)(&rotcache[lump]));
|
||||
Z_SetUser(rspr, (void **)(&rotcache[lumpnum]));
|
||||
}
|
||||
|
||||
return (void*)(rotcache[lump]);
|
||||
return (void *)(rotcache[lumpnum]);
|
||||
}
|
||||
#endif // ROTSPRITE
|
||||
|
||||
@@ -1976,7 +1962,7 @@ void W_UnlockCachedPatch(void *patch)
|
||||
// have different lifetimes from software's.
|
||||
#ifdef HWRENDER
|
||||
if (rendermode == render_opengl)
|
||||
HWR_UnlockCachedPatch((GLPatch_t *)(((patch_t *)(patch))->hardware));
|
||||
HWR_UnlockCachedPatch((GLPatch_t *)((patch_t *)patch)->hardware);
|
||||
else
|
||||
#endif
|
||||
Z_ChangeTag(patch, PU_PATCH);
|
||||
@@ -2011,7 +1997,7 @@ void *W_CachePatchNameRotated(const char *name, INT32 rotationangle, INT32 tag)
|
||||
if (rotationangle < 1 || rotationangle >= ROTANGLES)
|
||||
return W_CachePatchNum(num, tag);
|
||||
|
||||
rspr = (rotsprite_t *)(W_GetCachedRotPatchPwad(WADFILENUM(num), LUMPNUM(num)));
|
||||
rspr = (rotsprite_t *)W_GetCachedRotPatchPwad(WADFILENUM(num),LUMPNUM(num));
|
||||
|
||||
if (rspr == NULL)
|
||||
return W_CachePatchNum(W_GetNumForName("MISSING"), tag);
|
||||
@@ -2020,7 +2006,7 @@ void *W_CachePatchNameRotated(const char *name, INT32 rotationangle, INT32 tag)
|
||||
{
|
||||
INT32 xpivot = 0, ypivot = 0;
|
||||
|
||||
ptr = (patch_t *)(W_CachePatchNum(num, PU_PATCH));
|
||||
ptr = (patch_t *)W_CachePatchNum(num, PU_PATCH);
|
||||
if (ptr == NULL)
|
||||
return W_CachePatchNum(W_GetNumForName("MISSING"), tag);
|
||||
|
||||
@@ -2213,7 +2199,7 @@ static int W_VerifyPK3(FILE *fp, lumpchecklist_t *checklist, boolean status)
|
||||
fseek(fp, 0, SEEK_END);
|
||||
file_size = ftell(fp);
|
||||
|
||||
const long startpos = file_size - (22 + 65536);
|
||||
const long startpos = (file_size - (22 + 65536));
|
||||
if (!ResFindSignature(fp, pat_end, max(0l, startpos)))
|
||||
return true;
|
||||
|
||||
@@ -2227,7 +2213,7 @@ static int W_VerifyPK3(FILE *fp, lumpchecklist_t *checklist, boolean status)
|
||||
|
||||
fseek(fp, LONG(zend.cdiroffset), SEEK_SET);
|
||||
|
||||
CLEANUP(pfree) char *cdir = (char *)(malloc(LONG(zend.cdirsize)));
|
||||
CLEANUP(pfree) char *cdir = (char*)(malloc(LONG(zend.cdirsize)));
|
||||
|
||||
if (fread(cdir, 1, LONG(zend.cdirsize), fp) < (UINT32)(LONG(zend.cdirsize)))
|
||||
{
|
||||
@@ -2238,7 +2224,7 @@ static int W_VerifyPK3(FILE *fp, lumpchecklist_t *checklist, boolean status)
|
||||
|
||||
for (i = 0; i < numlumps; i++)
|
||||
{
|
||||
zentry_t *zentry = (zentry_t *)(cdir + offset);
|
||||
zentry_t *zentry = (zentry_t*)(cdir + offset);
|
||||
char* fullname;
|
||||
char* trimname;
|
||||
char* dotpos;
|
||||
@@ -2250,9 +2236,8 @@ static int W_VerifyPK3(FILE *fp, lumpchecklist_t *checklist, boolean status)
|
||||
|
||||
if (verified == true)
|
||||
{
|
||||
fullname = (char *)(malloc(SHORT(zentry->namelen) + 1));
|
||||
strncpy(fullname, (char *)(zentry + 1), SHORT(zentry->namelen));
|
||||
fullname[zentry->namelen] = 0;
|
||||
fullname = (char*)(malloc(SHORT(zentry->namelen) + 1));
|
||||
strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1);
|
||||
|
||||
// Strip away file address and extension for the 8char name.
|
||||
if ((trimname = strrchr(fullname, '/')) != NULL)
|
||||
@@ -2461,7 +2446,7 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist)
|
||||
fseek(fp, 0, SEEK_END);
|
||||
file_size = ftell(fp);
|
||||
|
||||
const long startpos = file_size - (22 + 65536);
|
||||
const long startpos = (file_size - (22 + 65536));
|
||||
if (!ResFindSignature(fp, pat_end, max(0l, startpos)))
|
||||
return true;
|
||||
|
||||
@@ -2475,7 +2460,7 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist)
|
||||
|
||||
fseek(fp, LONG(zend.cdiroffset), SEEK_SET);
|
||||
|
||||
CLEANUP(pfree) char *cdir = (char *)(malloc(LONG(zend.cdirsize)));
|
||||
CLEANUP(pfree) char *cdir = (char*)(malloc(LONG(zend.cdirsize)));
|
||||
|
||||
if (fread(cdir, 1, LONG(zend.cdirsize), fp) < (UINT32)(LONG(zend.cdirsize)))
|
||||
{
|
||||
@@ -2486,7 +2471,7 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist)
|
||||
|
||||
for (i = 0; i < numlumps; i++)
|
||||
{
|
||||
zentry_t *zentry = (zentry_t *)(cdir + offset);
|
||||
zentry_t *zentry = (zentry_t*)(cdir + offset);
|
||||
CLEANUP(pfree) char* fullname = NULL;
|
||||
char* trimname;
|
||||
char* dotpos;
|
||||
@@ -2496,9 +2481,8 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist)
|
||||
return false;
|
||||
}
|
||||
|
||||
fullname = (char *)(malloc(SHORT(zentry->namelen) + 1));
|
||||
strncpy(fullname, (char *)(zentry + 1), SHORT(zentry->namelen));
|
||||
fullname[zentry->namelen] = 0;
|
||||
fullname = (char*)(malloc(SHORT(zentry->namelen) + 1));
|
||||
strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1);
|
||||
|
||||
// Strip away file address and extension for the 8char name.
|
||||
if ((trimname = strrchr(fullname, '/')) != NULL)
|
||||
@@ -2634,14 +2618,14 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
||||
size_t *vsizecache;
|
||||
|
||||
// Remember that we're assuming that the WAD will have a specific set of lumps in a specific order.
|
||||
UINT8 *wadData = (UINT8 *)(W_CacheLumpNum(lumpnum, PU_LEVEL));
|
||||
UINT8 *wadData = (UINT8*)(W_CacheLumpNum(lumpnum, PU_LEVEL));
|
||||
if (wadData == NULL)
|
||||
I_Error("vres_GetMap: Invalid WadData!\n");
|
||||
|
||||
filelump_t *fileinfo = (filelump_t *)(wadData + LONG(((wadinfo_t *)(wadData))->infotableofs));
|
||||
filelump_t *fileinfo = (filelump_t *)(wadData + LONG(((wadinfo_t *)wadData)->infotableofs));
|
||||
|
||||
i = LONG(((wadinfo_t *)(wadData))->numlumps);
|
||||
vsizecache = (size_t *)(Z_Malloc(sizeof(size_t)*i, PU_LEVEL, NULL));
|
||||
i = LONG(((wadinfo_t *)wadData)->numlumps);
|
||||
vsizecache = (size_t*)(Z_Malloc(sizeof(size_t)*i, PU_LEVEL, NULL));
|
||||
|
||||
for (realentry = 0; realentry < i; realentry++)
|
||||
{
|
||||
@@ -2653,7 +2637,7 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
||||
numlumps++;
|
||||
}
|
||||
|
||||
vlumps = (virtlump_t *)(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL));
|
||||
vlumps = (virtlump_t*)(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL));
|
||||
if (vlumps == NULL)
|
||||
I_Error("vres_GetMap: Out of memory!\n");
|
||||
|
||||
@@ -2675,7 +2659,7 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
||||
// Play it safe with the name in this case.
|
||||
memcpy(vlumps[i].name, name, 8);
|
||||
vlumps[i].name[8] = '\0';
|
||||
vlumps[i].data = (UINT8 *)(
|
||||
vlumps[i].data = (UINT8*)(
|
||||
Z_Malloc(vlumps[i].size, PU_LEVEL, NULL) // This is memory inefficient, sorry about that.
|
||||
);
|
||||
memcpy(vlumps[i].data, wadData + LONG((fileinfo + realentry)->filepos), vlumps[i].size);
|
||||
@@ -2702,7 +2686,7 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
||||
}
|
||||
numlumps++;
|
||||
|
||||
vlumps = (virtlump_t *)(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL));
|
||||
vlumps = (virtlump_t*)(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL));
|
||||
if (vlumps == NULL)
|
||||
I_Error("vres_GetMap: Out of memory!\n");
|
||||
|
||||
@@ -2723,11 +2707,11 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
||||
vlumps[i].size = W_LumpLength(lumpnum);
|
||||
memcpy(vlumps[i].name, name, 8);
|
||||
vlumps[i].name[8] = '\0';
|
||||
vlumps[i].data = (UINT8 *)(W_CacheLumpNum(lumpnum, PU_LEVEL));
|
||||
vlumps[i].data = (UINT8*)(W_CacheLumpNum(lumpnum, PU_LEVEL));
|
||||
}
|
||||
}
|
||||
|
||||
vres = (virtres_t *)(Z_Malloc(sizeof(virtres_t), PU_LEVEL, NULL));
|
||||
vres = (virtres_t*)(Z_Malloc(sizeof(virtres_t), PU_LEVEL, NULL));
|
||||
vres->vlumps = vlumps;
|
||||
vres->numlumps = numlumps;
|
||||
|
||||
|
||||
+13
-11
@@ -68,11 +68,11 @@ typedef struct
|
||||
unsigned long position; // filelump_t filepos
|
||||
unsigned long disksize; // filelump_t size
|
||||
char name[9]; // filelump_t name[] e.g. "LongEntr"
|
||||
//char *longname; // e.g. "LongEntryName"
|
||||
char *longname; // e.g. "LongEntryName"
|
||||
char *fullname; // e.g. "Folder/Subfolder/LongEntryName.extension"
|
||||
|
||||
size_t namelength; // length of name
|
||||
//size_t longnamelength; // length of longname
|
||||
size_t longnamelength; // length of longname
|
||||
size_t fullnamelength; // length of fullname
|
||||
|
||||
size_t size; // real (uncompressed) size
|
||||
@@ -80,8 +80,8 @@ typedef struct
|
||||
|
||||
struct {
|
||||
UINT32 name; // hash of name
|
||||
//UINT32 longname; // hash of longname
|
||||
//UINT32 fullname; // hash of fullname
|
||||
UINT32 longname; // hash of longname
|
||||
UINT32 fullname; // hash of fullname
|
||||
} hash;
|
||||
} lumpinfo_t;
|
||||
|
||||
@@ -126,6 +126,7 @@ typedef enum restype
|
||||
RET_UNKNOWN,
|
||||
} restype_t;
|
||||
|
||||
|
||||
typedef struct wadfile_s
|
||||
{
|
||||
char *filename;
|
||||
@@ -136,8 +137,8 @@ typedef struct wadfile_s
|
||||
#ifdef ROTSPRITE
|
||||
lumpcache_t *rotcache; // Cache rotsprites for rotating patches.
|
||||
#endif
|
||||
struct FolderCache *startfolders;
|
||||
struct FolderCache *endfolders;
|
||||
aatree_t *startfolders;
|
||||
aatree_t *endfolders;
|
||||
UINT16 numlumps; // this wad's number of resources
|
||||
FILE *handle;
|
||||
UINT32 filesize; // for network
|
||||
@@ -154,7 +155,6 @@ extern wadfile_t *wadfiles[MAX_WADFILES];
|
||||
|
||||
// =========================================================================
|
||||
|
||||
void W_Startup(void);
|
||||
void W_Shutdown(void);
|
||||
|
||||
// Opens a WAD file. Returns the FILE * handle for the file, or NULL if not found or could not be opened
|
||||
@@ -174,11 +174,13 @@ INT32 W_AddAutoloadedLocalFiles(char **filenames);
|
||||
|
||||
#define W_FileHasFolders(wadfile) ((wadfile)->type == RET_PK3)
|
||||
|
||||
UINT32 W_HashLumpName(const char *name);
|
||||
|
||||
const char *W_CheckNameForNumPwad(UINT16 wad, UINT16 lump);
|
||||
const char *W_CheckNameForNum(lumpnum_t lumpnum);
|
||||
|
||||
UINT16 W_CheckNumForNamePwad(const char *name, UINT16 wad, UINT16 startlump); // checks only in one pwad
|
||||
//UINT16 W_CheckNumForLongNamePwad(const char *name, UINT16 wad, UINT16 startlump);
|
||||
UINT16 W_CheckNumForLongNamePwad(const char *name, UINT16 wad, UINT16 startlump);
|
||||
|
||||
/* Find the first lump after F_START for instance. */
|
||||
UINT16 W_CheckNumForMarkerStartPwad(const char *name, UINT16 wad, UINT16 startlump);
|
||||
@@ -188,9 +190,9 @@ UINT16 W_CheckNumForFolderStartPK3(const char *name, UINT16 wad, UINT16 startlum
|
||||
UINT16 W_CheckNumForFolderEndPK3(const char *name, UINT16 wad, UINT16 startlump);
|
||||
|
||||
lumpnum_t W_CheckNumForName(const char *name);
|
||||
//lumpnum_t W_CheckNumForLongName(const char *name);
|
||||
lumpnum_t W_CheckNumForLongName(const char *name);
|
||||
lumpnum_t W_GetNumForName(const char *name); // like W_CheckNumForName but I_Error on LUMPERROR
|
||||
//lumpnum_t W_GetNumForLongName(const char *name);
|
||||
lumpnum_t W_GetNumForLongName(const char *name);
|
||||
lumpnum_t W_CheckNumForNameInBlock(const char *name, const char *blockstart, const char *blockend);
|
||||
UINT8 W_LumpExists(const char *name); // Lua uses this.
|
||||
UINT8 W_CheckMultipleLumps(const char* lump, ...); // variadic version of above lmao
|
||||
@@ -231,7 +233,7 @@ void *W_CacheSoftwarePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag);
|
||||
void *W_CacheSoftwarePatchNum(lumpnum_t lumpnum, INT32 tag);
|
||||
|
||||
#ifdef ROTSPRITE
|
||||
void *W_GetCachedRotPatchPwad(UINT16 wad, UINT16 lump); // Get patch-based rotsprites from the cache.
|
||||
void *W_GetCachedRotPatchPwad(UINT16 wadnum, UINT16 lumpnum); // Get patch-based rotsprites from the cache.
|
||||
void *W_CachePatchNameRotated(const char *name, INT32 rotationangle, INT32 tag);
|
||||
#endif
|
||||
|
||||
|
||||
Reference in new issue
Block a user