mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 06:41:41 +00:00
- Yay! We now seem to be free of memory leaks! The next step will be to
merge a lot of these static destructor-only structs into regular functions added to the exit chain with atterm so that they can be called in a deterministic order and not whatever order the linker decides to put them in. (Interestingly, the amount of memory used when repeatedly executing the same map command at the console varies up and down, but it now stays relatively stable rather than increasing unbounded.) - Fixed: The list of resolutions in the video modes menu was not freed at exit. - Fixed: mus_playing.name was not freed at exit. - Fixed: SN_StopAllSequences() should be called at the start of P_FreeLevelData(), not just before the call to P_SetupLevel() in G_DoLoadLevel(), so it can run even at exit. And C_FullConsole() can call P_FreeLevelData() to free more memory too. - Fixed: StatusBar was not freed at exit. - Fixed: spritesorter was not freed at exit. - Fixed: Bad things happened if FString's data pool was destroyed before all C_RemoveTabCommand() calls were made. - Added an overload for FArchive << FString. - Fixed: The players' log text was not freed at exit. - Fixed: Bot information was not freed at exit. - Fixed: doomcom was not freed at exit. But since it's always created, there's no reason why it needs to be allocated from the heap. My guess is that in the DOS days, the external packet driver was responsible for allocating doomcom and passed its location with the -net parameter. - Fixed: FBlockNodes were not freed at exit. - Fixed: Openings were not freed at exit. - Fixed: Drawsegs were not freed at exit. - Fixed: Vissprites were not freed at exit. - Fixed: Console command history was not freed at exit. - Fixed: Visplanes were not freed at exit. - Fixed: Call P_FreeLevelData() at exit. - Fixed: Channel, SoundCurve, and PlayList in s_sound.cpp were not freed at exit. - Fixed: Sound sequences were not freed at exit. - Fixed: DSeqNode::Serialize() did not resize the m_SequenceChoices array when loading. SVN r106 (trunk)
This commit is contained in:
parent
0069ca4072
commit
a0c88a9b31
22 changed files with 432 additions and 199 deletions
|
@ -1,4 +1,41 @@
|
|||
May 10, 2006
|
||||
- Yay! We now seem to be free of memory leaks! The next step will be to
|
||||
merge a lot of these static destructor-only structs into regular
|
||||
functions added to the exit chain with atterm so that they can be called
|
||||
in a deterministic order and not whatever order the linker decides to put
|
||||
them in. (Interestingly, the amount of memory used when repeatedly
|
||||
executing the same map command at the console varies up and down, but it
|
||||
now stays relatively stable rather than increasing unbounded.)
|
||||
- Fixed: The list of resolutions in the video modes menu was not freed
|
||||
at exit.
|
||||
- Fixed: mus_playing.name was not freed at exit.
|
||||
- Fixed: SN_StopAllSequences() should be called at the start of
|
||||
P_FreeLevelData(), not just before the call to P_SetupLevel() in
|
||||
G_DoLoadLevel(), so it can run even at exit. And C_FullConsole() can
|
||||
call P_FreeLevelData() to free more memory too.
|
||||
- Fixed: StatusBar was not freed at exit.
|
||||
- Fixed: spritesorter was not freed at exit.
|
||||
- Fixed: Bad things happened if FString's data pool was destroyed before
|
||||
all C_RemoveTabCommand() calls were made.
|
||||
- Added an overload for FArchive << FString.
|
||||
- Fixed: The players' log text was not freed at exit.
|
||||
- Fixed: Bot information was not freed at exit.
|
||||
- Fixed: doomcom was not freed at exit. But since it's always created,
|
||||
there's no reason why it needs to be allocated from the heap. My guess
|
||||
is that in the DOS days, the external packet driver was responsible for
|
||||
allocating doomcom and passed its location with the -net parameter.
|
||||
- Fixed: FBlockNodes were not freed at exit.
|
||||
- Fixed: Openings were not freed at exit.
|
||||
- Fixed: Drawsegs were not freed at exit.
|
||||
- Fixed: Vissprites were not freed at exit.
|
||||
- Fixed: Console command history was not freed at exit.
|
||||
- Fixed: Visplanes were not freed at exit.
|
||||
- Fixed: Call P_FreeLevelData() at exit.
|
||||
- Fixed: Channel, SoundCurve, and PlayList in s_sound.cpp were not freed at
|
||||
exit.
|
||||
- Fixed: Sound sequences were not freed at exit.
|
||||
- Fixed: DSeqNode::Serialize() did not resize the m_SequenceChoices array
|
||||
when loading.
|
||||
- Fixed mvlineasm1 and mvlineasm4 so that they can be used with textures
|
||||
taller than 256 pixels. There was a very slight performance hit for this,
|
||||
but I was able to tweak mvlineasm4 to make it approximately as fast as
|
||||
|
|
|
@ -78,6 +78,8 @@ class DCajunMaster : public DObject
|
|||
DECLARE_CLASS (DCajunMaster, DObject)
|
||||
HAS_OBJECT_POINTERS
|
||||
public:
|
||||
~DCajunMaster();
|
||||
|
||||
void ClearPlayer (int playernum, bool keepTeam);
|
||||
|
||||
//(B_Game.c)
|
||||
|
|
|
@ -90,6 +90,10 @@ static bool waitingforspawn[MAXPLAYERS];
|
|||
|
||||
void G_DoReborn (int playernum, bool freshbot);
|
||||
|
||||
DCajunMaster::~DCajunMaster()
|
||||
{
|
||||
ForgetBots();
|
||||
}
|
||||
|
||||
//This function is called every tick (from g_game.c),
|
||||
//send bots into thinking (+more).
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "m_alloc.h"
|
||||
#include "templates.h"
|
||||
#include "p_setup.h"
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
@ -132,6 +133,21 @@ static byte CmdLine[260];
|
|||
static struct History *HistHead = NULL, *HistTail = NULL, *HistPos = NULL;
|
||||
static int HistSize;
|
||||
|
||||
static struct HistoryFree
|
||||
{
|
||||
~HistoryFree()
|
||||
{
|
||||
History *hist = HistTail;
|
||||
|
||||
while (hist != NULL)
|
||||
{
|
||||
History *next = hist->Newer;
|
||||
free (hist);
|
||||
hist = next;
|
||||
}
|
||||
}
|
||||
} HistoryFree_er;
|
||||
|
||||
|
||||
CVAR (Float, con_notifytime, 3.f, CVAR_ARCHIVE)
|
||||
CVAR (Bool, con_centernotify, false, CVAR_ARCHIVE)
|
||||
|
@ -1151,7 +1167,7 @@ void C_FullConsole ()
|
|||
gamestate = GS_FULLCONSOLE;
|
||||
level.music = NULL;
|
||||
S_Start ();
|
||||
SN_StopAllSequences ();
|
||||
P_FreeLevelData ();
|
||||
V_SetBlend (0,0,0,0);
|
||||
}
|
||||
else
|
||||
|
@ -1716,7 +1732,7 @@ void C_MidPrintBold (const char *msg)
|
|||
struct TabData
|
||||
{
|
||||
int UseCount;
|
||||
FString Name;
|
||||
FName TabName;
|
||||
|
||||
TabData()
|
||||
: UseCount(0)
|
||||
|
@ -1724,12 +1740,12 @@ struct TabData
|
|||
}
|
||||
|
||||
TabData(const char *name)
|
||||
: UseCount(1), Name(name)
|
||||
: UseCount(1), TabName(name)
|
||||
{
|
||||
}
|
||||
|
||||
TabData(const TabData &other)
|
||||
: UseCount(other.UseCount), Name(other.Name)
|
||||
: UseCount(other.UseCount), TabName(other.TabName)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
@ -1741,11 +1757,18 @@ static int TabSize; // Size of tab string
|
|||
|
||||
static BOOL FindTabCommand (const char *name, int *stoppos, int len)
|
||||
{
|
||||
int i, cval = 1;
|
||||
FName aname(name);
|
||||
unsigned int i;
|
||||
int cval = 1;
|
||||
|
||||
for (i = 0; i < TabCommands.Size(); i++)
|
||||
{
|
||||
cval = strnicmp (TabCommands[i].Name, name, len);
|
||||
if (TabCommands[i].TabName == aname)
|
||||
{
|
||||
*stoppos = i;
|
||||
return true;
|
||||
}
|
||||
cval = strnicmp (TabCommands[i].TabName.GetChars(), name, len);
|
||||
if (cval >= 0)
|
||||
break;
|
||||
}
|
||||
|
@ -1772,19 +1795,28 @@ void C_AddTabCommand (const char *name)
|
|||
|
||||
void C_RemoveTabCommand (const char *name)
|
||||
{
|
||||
int pos;
|
||||
FName aname(name, true);
|
||||
|
||||
if (FindTabCommand (name, &pos, INT_MAX))
|
||||
if (aname == NAME_None)
|
||||
{
|
||||
if (--TabCommands[pos].UseCount == 0)
|
||||
return;
|
||||
}
|
||||
for (unsigned int i = 0; i < TabCommands.Size(); ++i)
|
||||
{
|
||||
if (TabCommands[i].TabName == aname)
|
||||
{
|
||||
TabCommands.Delete(pos);
|
||||
if (--TabCommands[i].UseCount == 0)
|
||||
{
|
||||
TabCommands.Delete(i);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int FindDiffPoint (const char *str1, const char *str2)
|
||||
static int FindDiffPoint (FName name1, const char *str2)
|
||||
{
|
||||
const char *str1 = name1.GetChars();
|
||||
int i;
|
||||
|
||||
for (i = 0; tolower(str1[i]) == tolower(str2[i]); i++)
|
||||
|
@ -1845,7 +1877,7 @@ static void C_TabComplete (bool goForward)
|
|||
{ // Find the last matching tab, then go one past it.
|
||||
while (++TabPos < TabCommands.Size())
|
||||
{
|
||||
if (FindDiffPoint (TabCommands[TabPos].Name, (char *)(CmdLine + TabStart)) < TabSize)
|
||||
if (FindDiffPoint (TabCommands[TabPos].TabName, (char *)(CmdLine + TabStart)) < TabSize)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -1866,7 +1898,7 @@ static void C_TabComplete (bool goForward)
|
|||
}
|
||||
else
|
||||
{
|
||||
diffpoint = FindDiffPoint (TabCommands[TabPos].Name, (char *)(CmdLine + TabStart));
|
||||
diffpoint = FindDiffPoint (TabCommands[TabPos].TabName, (char *)(CmdLine + TabStart));
|
||||
|
||||
if (diffpoint < TabSize)
|
||||
{
|
||||
|
@ -1876,7 +1908,7 @@ static void C_TabComplete (bool goForward)
|
|||
}
|
||||
else
|
||||
{
|
||||
strcpy ((char *)(CmdLine + TabStart), TabCommands[TabPos].Name);
|
||||
strcpy ((char *)(CmdLine + TabStart), TabCommands[TabPos].TabName.GetChars());
|
||||
CmdLine[0] = CmdLine[1] = (BYTE)strlen ((char *)(CmdLine + 2)) + 1;
|
||||
CmdLine[CmdLine[0] + 1] = ' ';
|
||||
}
|
||||
|
@ -1896,7 +1928,7 @@ static bool C_TabCompleteList ()
|
|||
|
||||
for (i = TabPos; i < TabCommands.Size(); ++i)
|
||||
{
|
||||
if (FindDiffPoint (TabCommands[i].Name, (char *)(CmdLine + TabStart)) < TabSize)
|
||||
if (FindDiffPoint (TabCommands[i].TabName, (char *)(CmdLine + TabStart)) < TabSize)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -1907,14 +1939,14 @@ static bool C_TabCompleteList ()
|
|||
// This keeps track of the longest common prefix for all the possible
|
||||
// completions, so we can fill in part of the command for the user if
|
||||
// the longest common prefix is longer than what the user already typed.
|
||||
int diffpt = FindDiffPoint (TabCommands[i-1].Name, TabCommands[i].Name);
|
||||
int diffpt = FindDiffPoint (TabCommands[i-1].TabName, TabCommands[i].TabName.GetChars());
|
||||
if (diffpt < commonsize)
|
||||
{
|
||||
commonsize = diffpt;
|
||||
}
|
||||
}
|
||||
nummatches++;
|
||||
maxwidth = MAX (maxwidth, strlen (TabCommands[i].Name));
|
||||
maxwidth = MAX (maxwidth, strlen (TabCommands[i].TabName.GetChars()));
|
||||
}
|
||||
}
|
||||
if (nummatches > 1)
|
||||
|
@ -1924,7 +1956,7 @@ static bool C_TabCompleteList ()
|
|||
Printf (TEXTCOLOR_BLUE "Completions for %s:\n", CmdLine+2);
|
||||
for (i = TabPos; nummatches > 0; ++i, --nummatches)
|
||||
{
|
||||
Printf ("%-*s", int(maxwidth), TabCommands[i].Name.GetChars());
|
||||
Printf ("%-*s", int(maxwidth), TabCommands[i].TabName.GetChars());
|
||||
x += maxwidth;
|
||||
if (x > ConCols - maxwidth)
|
||||
{
|
||||
|
@ -1940,7 +1972,7 @@ static bool C_TabCompleteList ()
|
|||
if (TabSize != commonsize)
|
||||
{
|
||||
TabSize = commonsize;
|
||||
strncpy ((char *)CmdLine + TabStart, TabCommands[TabPos].Name, commonsize);
|
||||
strncpy ((char *)CmdLine + TabStart, TabCommands[TabPos].TabName.GetChars(), commonsize);
|
||||
CmdLine[0] = TabStart + commonsize - 2;
|
||||
CmdLine[1] = CmdLine[0];
|
||||
}
|
||||
|
|
116
src/d_net.cpp
116
src/d_net.cpp
|
@ -93,8 +93,8 @@ extern FString savegamefile;
|
|||
|
||||
extern short consistancy[MAXPLAYERS][BACKUPTICS];
|
||||
|
||||
doomcom_t* doomcom;
|
||||
#define netbuffer (doomcom->data)
|
||||
doomcom_t doomcom;
|
||||
#define netbuffer (doomcom.data)
|
||||
|
||||
enum { NET_PeerToPeer, NET_PacketServer };
|
||||
BYTE NetMode = NET_PeerToPeer;
|
||||
|
@ -327,7 +327,7 @@ int NetbufferSize ()
|
|||
{
|
||||
if (netbuffer[0] & (NCMD_EXIT | NCMD_SETUP))
|
||||
{
|
||||
return doomcom->datalength;
|
||||
return doomcom.datalength;
|
||||
}
|
||||
|
||||
int k = 2, count, numtics;
|
||||
|
@ -335,7 +335,7 @@ int NetbufferSize ()
|
|||
if (netbuffer[0] & NCMD_RETRANSMIT)
|
||||
k++;
|
||||
|
||||
if (NetMode == NET_PacketServer && doomcom->remotenode == nodeforplayer[Net_Arbitrator])
|
||||
if (NetMode == NET_PacketServer && doomcom.remotenode == nodeforplayer[Net_Arbitrator])
|
||||
k++;
|
||||
|
||||
numtics = netbuffer[0] & NCMD_XTICS;
|
||||
|
@ -360,7 +360,7 @@ int NetbufferSize ()
|
|||
}
|
||||
|
||||
// Need at least 3 bytes per tic per player
|
||||
if (doomcom->datalength < k + 3 * count * numtics)
|
||||
if (doomcom.datalength < k + 3 * count * numtics)
|
||||
{
|
||||
return k + 3 * count * numtics;
|
||||
}
|
||||
|
@ -449,7 +449,7 @@ void HSendPacket (int node, int len)
|
|||
fprintf (debugfile, "%c%2x", i==k?'|':' ', ((byte *)netbuffer)[i]);
|
||||
}
|
||||
fprintf (debugfile, " [[ ");
|
||||
for (i = 0; i < doomcom->numnodes; ++i)
|
||||
for (i = 0; i < doomcom.numnodes; ++i)
|
||||
{
|
||||
if (nodeingame[i])
|
||||
{
|
||||
|
@ -485,9 +485,9 @@ void HSendPacket (int node, int len)
|
|||
}
|
||||
#endif
|
||||
|
||||
doomcom->command = CMD_SEND;
|
||||
doomcom->remotenode = node;
|
||||
doomcom->datalength = len;
|
||||
doomcom.command = CMD_SEND;
|
||||
doomcom.remotenode = node;
|
||||
doomcom.datalength = len;
|
||||
|
||||
I_NetCmd ();
|
||||
}
|
||||
|
@ -501,7 +501,7 @@ BOOL HGetPacket (void)
|
|||
if (reboundpacket)
|
||||
{
|
||||
memcpy (netbuffer, reboundstore, reboundpacket);
|
||||
doomcom->remotenode = 0;
|
||||
doomcom.remotenode = 0;
|
||||
reboundpacket = 0;
|
||||
return true;
|
||||
}
|
||||
|
@ -512,10 +512,10 @@ BOOL HGetPacket (void)
|
|||
if (demoplayback)
|
||||
return false;
|
||||
|
||||
doomcom->command = CMD_GET;
|
||||
doomcom.command = CMD_GET;
|
||||
I_NetCmd ();
|
||||
|
||||
if (doomcom->remotenode == -1)
|
||||
if (doomcom.remotenode == -1)
|
||||
return false;
|
||||
|
||||
if (debugfile)
|
||||
|
@ -524,15 +524,15 @@ BOOL HGetPacket (void)
|
|||
|
||||
if (netbuffer[0] & NCMD_SETUP)
|
||||
{
|
||||
fprintf (debugfile,"%i/%i get %i = SETUP [%3i]", gametic, maketic, doomcom->remotenode, doomcom->datalength);
|
||||
for (i = 0; i < doomcom->datalength; i++)
|
||||
fprintf (debugfile,"%i/%i get %i = SETUP [%3i]", gametic, maketic, doomcom.remotenode, doomcom.datalength);
|
||||
for (i = 0; i < doomcom.datalength; i++)
|
||||
fprintf (debugfile, " %2x", ((byte *)netbuffer)[i]);
|
||||
fprintf (debugfile, "\n");
|
||||
}
|
||||
else if (netbuffer[0] & NCMD_EXIT)
|
||||
{
|
||||
fprintf (debugfile,"%i/%i get %i = EXIT [%3i]", gametic, maketic, doomcom->remotenode, doomcom->datalength);
|
||||
for (i = 0; i < doomcom->datalength; i++)
|
||||
fprintf (debugfile,"%i/%i get %i = EXIT [%3i]", gametic, maketic, doomcom.remotenode, doomcom.datalength);
|
||||
for (i = 0; i < doomcom.datalength; i++)
|
||||
fprintf (debugfile, " %2x", ((byte *)netbuffer)[i]);
|
||||
fprintf (debugfile, "\n");
|
||||
}
|
||||
|
@ -540,7 +540,7 @@ BOOL HGetPacket (void)
|
|||
k = 2;
|
||||
|
||||
if (NetMode == NET_PacketServer &&
|
||||
doomcom->remotenode == nodeforplayer[Net_Arbitrator])
|
||||
doomcom.remotenode == nodeforplayer[Net_Arbitrator])
|
||||
{
|
||||
k++;
|
||||
}
|
||||
|
@ -556,25 +556,25 @@ BOOL HGetPacket (void)
|
|||
|
||||
fprintf (debugfile,"%i/%i get %i = (%i + %i, R %i) [%3i]",
|
||||
gametic, maketic,
|
||||
doomcom->remotenode,
|
||||
doomcom.remotenode,
|
||||
ExpandTics(netbuffer[1]),
|
||||
numtics, realretrans, doomcom->datalength);
|
||||
numtics, realretrans, doomcom.datalength);
|
||||
|
||||
for (i = 0; i < doomcom->datalength; i++)
|
||||
for (i = 0; i < doomcom.datalength; i++)
|
||||
fprintf (debugfile, "%c%2x", i==k?'|':' ', ((byte *)netbuffer)[i]);
|
||||
if (numtics)
|
||||
fprintf (debugfile, " <<%4x>>\n",
|
||||
consistancy[playerfornode[doomcom->remotenode]][nettics[doomcom->remotenode]%BACKUPTICS] & 0xFFFF);
|
||||
consistancy[playerfornode[doomcom.remotenode]][nettics[doomcom.remotenode]%BACKUPTICS] & 0xFFFF);
|
||||
else
|
||||
fprintf (debugfile, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (doomcom->datalength != NetbufferSize ())
|
||||
if (doomcom.datalength != NetbufferSize ())
|
||||
{
|
||||
if (debugfile)
|
||||
fprintf (debugfile,"---bad packet length %i (calculated %i)\n",
|
||||
doomcom->datalength, NetbufferSize());
|
||||
doomcom.datalength, NetbufferSize());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -585,14 +585,14 @@ void PlayerIsGone (int netnode, int netconsole)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = netnode + 1; i < doomcom->numnodes; ++i)
|
||||
for (i = netnode + 1; i < doomcom.numnodes; ++i)
|
||||
{
|
||||
if (nodeingame[i])
|
||||
break;
|
||||
}
|
||||
if (i == doomcom->numnodes)
|
||||
if (i == doomcom.numnodes)
|
||||
{
|
||||
doomcom->numnodes = netnode;
|
||||
doomcom.numnodes = netnode;
|
||||
}
|
||||
|
||||
nodeingame[netnode] = false;
|
||||
|
@ -690,12 +690,12 @@ void GetPackets (void)
|
|||
{
|
||||
// This player apparantly doesn't realise the game has started
|
||||
netbuffer[0] = NCMD_SETUP+3;
|
||||
HSendPacket (doomcom->remotenode, 1);
|
||||
HSendPacket (doomcom.remotenode, 1);
|
||||
}
|
||||
continue; // extra setup packet
|
||||
}
|
||||
|
||||
netnode = doomcom->remotenode;
|
||||
netnode = doomcom.remotenode;
|
||||
netconsole = playerfornode[netnode] & ~PL_DRONE;
|
||||
|
||||
// [RH] Get "ping" times
|
||||
|
@ -1065,7 +1065,7 @@ void NetUpdate (void)
|
|||
// and it also added the player being sent the packet to the count.
|
||||
count -= 2;
|
||||
|
||||
for (j = 0; j < doomcom->numnodes; ++j)
|
||||
for (j = 0; j < doomcom.numnodes; ++j)
|
||||
{
|
||||
if (nodejustleft[j])
|
||||
{
|
||||
|
@ -1087,7 +1087,7 @@ void NetUpdate (void)
|
|||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < doomcom->numnodes; i++)
|
||||
for (i = 0; i < doomcom.numnodes; i++)
|
||||
{
|
||||
BYTE playerbytes[MAXPLAYERS];
|
||||
|
||||
|
@ -1120,7 +1120,7 @@ void NetUpdate (void)
|
|||
consoleplayer == Net_Arbitrator &&
|
||||
i != 0)
|
||||
{
|
||||
for (j = 1; j < doomcom->numnodes; ++j)
|
||||
for (j = 1; j < doomcom.numnodes; ++j)
|
||||
{
|
||||
if (nodeingame[j] && nettics[j] < lowtic && j != i)
|
||||
{
|
||||
|
@ -1134,7 +1134,7 @@ void NetUpdate (void)
|
|||
if (numtics > BACKUPTICS)
|
||||
I_Error ("NetUpdate: Node %d missed too many tics", i);
|
||||
|
||||
resendto[i] = MAX (0, lowtic - doomcom->extratics);
|
||||
resendto[i] = MAX (0, lowtic - doomcom.extratics);
|
||||
|
||||
if (numtics == 0 && resendOnly && !remoteresend[i] && nettics[i])
|
||||
{
|
||||
|
@ -1161,7 +1161,7 @@ void NetUpdate (void)
|
|||
{
|
||||
netbuffer[0] |= NCMD_QUITTERS;
|
||||
netbuffer[k++] = quitcount;
|
||||
for (int l = 0; l < doomcom->numnodes; ++l)
|
||||
for (int l = 0; l < doomcom.numnodes; ++l)
|
||||
{
|
||||
if (nodejustleft[l])
|
||||
{
|
||||
|
@ -1339,7 +1339,7 @@ void D_ArbitrateNetStart (void)
|
|||
bool allset = false;
|
||||
|
||||
// Return right away if we're just playing with ourselves.
|
||||
if (doomcom->numnodes == 1)
|
||||
if (doomcom.numnodes == 1)
|
||||
return;
|
||||
|
||||
autostart = true;
|
||||
|
@ -1355,7 +1355,7 @@ void D_ArbitrateNetStart (void)
|
|||
nodeforplayer[consoleplayer] = 0;
|
||||
if (consoleplayer == Net_Arbitrator)
|
||||
{
|
||||
for (i = 1; i < doomcom->numnodes; ++i)
|
||||
for (i = 1; i < doomcom.numnodes; ++i)
|
||||
{
|
||||
playerfornode[i] = i;
|
||||
nodeforplayer[i] = i;
|
||||
|
@ -1365,7 +1365,7 @@ void D_ArbitrateNetStart (void)
|
|||
{
|
||||
playerfornode[1] = 0;
|
||||
nodeforplayer[0] = 1;
|
||||
for (i = 1; i < doomcom->numnodes; ++i)
|
||||
for (i = 1; i < doomcom.numnodes; ++i)
|
||||
{
|
||||
if (i < consoleplayer)
|
||||
{
|
||||
|
@ -1399,14 +1399,14 @@ void D_ArbitrateNetStart (void)
|
|||
I_FatalError ("The game was aborted\n");
|
||||
}
|
||||
|
||||
if (doomcom->remotenode == 0)
|
||||
if (doomcom.remotenode == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (netbuffer[0] == NCMD_SETUP || netbuffer[0] == NCMD_SETUP+1) // got user info
|
||||
{
|
||||
node = (netbuffer[0] == NCMD_SETUP) ? doomcom->remotenode
|
||||
node = (netbuffer[0] == NCMD_SETUP) ? doomcom.remotenode
|
||||
: nodeforplayer[netbuffer[1]];
|
||||
|
||||
playersdetected[node] =
|
||||
|
@ -1442,8 +1442,8 @@ void D_ArbitrateNetStart (void)
|
|||
{
|
||||
gotsetup[0] = 0x80;
|
||||
|
||||
ticdup = doomcom->ticdup = netbuffer[1];
|
||||
doomcom->extratics = netbuffer[2];
|
||||
ticdup = doomcom.ticdup = netbuffer[1];
|
||||
doomcom.extratics = netbuffer[2];
|
||||
NetMode = netbuffer[3];
|
||||
|
||||
stream = &netbuffer[4];
|
||||
|
@ -1462,11 +1462,11 @@ void D_ArbitrateNetStart (void)
|
|||
// If everybody already knows everything, it's time to go
|
||||
if (consoleplayer == Net_Arbitrator)
|
||||
{
|
||||
for (i = 0; i < doomcom->numnodes; ++i)
|
||||
if (playersdetected[i] != DWORD(1 << doomcom->numnodes) - 1 || !gotsetup[i])
|
||||
for (i = 0; i < doomcom.numnodes; ++i)
|
||||
if (playersdetected[i] != DWORD(1 << doomcom.numnodes) - 1 || !gotsetup[i])
|
||||
break;
|
||||
|
||||
if (i == doomcom->numnodes)
|
||||
if (i == doomcom.numnodes)
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1489,9 +1489,9 @@ void D_ArbitrateNetStart (void)
|
|||
{ // Send user info for all nodes
|
||||
netbuffer[0] = NCMD_SETUP+1;
|
||||
netbuffer[2] = NETGAMEVERSION;
|
||||
for (i = 1; i < doomcom->numnodes; ++i)
|
||||
for (i = 1; i < doomcom.numnodes; ++i)
|
||||
{
|
||||
for (j = 0; j < doomcom->numnodes; ++j)
|
||||
for (j = 0; j < doomcom.numnodes; ++j)
|
||||
{
|
||||
// Send info about player j to player i?
|
||||
if (i != j && (playersdetected[0] & (1<<j)) &&
|
||||
|
@ -1510,8 +1510,8 @@ void D_ArbitrateNetStart (void)
|
|||
if (consoleplayer == Net_Arbitrator)
|
||||
{
|
||||
netbuffer[0] = NCMD_SETUP+2;
|
||||
netbuffer[1] = doomcom->ticdup;
|
||||
netbuffer[2] = doomcom->extratics;
|
||||
netbuffer[1] = doomcom.ticdup;
|
||||
netbuffer[2] = doomcom.extratics;
|
||||
netbuffer[3] = NetMode;
|
||||
stream = &netbuffer[4];
|
||||
WriteString (startmap, &stream);
|
||||
|
@ -1530,7 +1530,7 @@ void D_ArbitrateNetStart (void)
|
|||
|
||||
if (debugfile)
|
||||
{
|
||||
for (i = 0; i < doomcom->numnodes; ++i)
|
||||
for (i = 0; i < doomcom.numnodes; ++i)
|
||||
{
|
||||
fprintf (debugfile, "player %d is on node %d\n", i, nodeforplayer[i]);
|
||||
}
|
||||
|
@ -1552,7 +1552,7 @@ static void SendSetup (DWORD playersdetected[MAXNETNODES], BYTE gotsetup[MAXNETN
|
|||
}
|
||||
else
|
||||
{
|
||||
for (int i = 1; i < doomcom->numnodes; ++i)
|
||||
for (int i = 1; i < doomcom.numnodes; ++i)
|
||||
{
|
||||
if (!gotsetup[i] || netbuffer[0] == NCMD_SETUP+3)
|
||||
{
|
||||
|
@ -1583,10 +1583,10 @@ void D_CheckNetGame (void)
|
|||
|
||||
// I_InitNetwork sets doomcom and netgame
|
||||
I_InitNetwork ();
|
||||
if (doomcom->id != DOOMCOM_ID)
|
||||
if (doomcom.id != DOOMCOM_ID)
|
||||
I_FatalError ("Doomcom buffer invalid!");
|
||||
|
||||
consoleplayer = doomcom->consoleplayer;
|
||||
consoleplayer = doomcom.consoleplayer;
|
||||
|
||||
v = Args.CheckValue ("-netmode");
|
||||
if (v != NULL)
|
||||
|
@ -1612,15 +1612,15 @@ void D_CheckNetGame (void)
|
|||
}
|
||||
|
||||
// read values out of doomcom
|
||||
ticdup = doomcom->ticdup;
|
||||
ticdup = doomcom.ticdup;
|
||||
|
||||
for (i = 0; i < doomcom->numplayers; i++)
|
||||
for (i = 0; i < doomcom.numplayers; i++)
|
||||
playeringame[i] = true;
|
||||
for (i = 0; i < doomcom->numnodes; i++)
|
||||
for (i = 0; i < doomcom.numnodes; i++)
|
||||
nodeingame[i] = true;
|
||||
|
||||
Printf ("player %i of %i (%i nodes)\n",
|
||||
consoleplayer+1, doomcom->numplayers, doomcom->numnodes);
|
||||
consoleplayer+1, doomcom.numplayers, doomcom.numnodes);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1663,7 +1663,7 @@ void STACK_ARGS D_QuitNetGame (void)
|
|||
}
|
||||
else
|
||||
{
|
||||
for (j = 1; j < doomcom->numnodes; j++)
|
||||
for (j = 1; j < doomcom.numnodes; j++)
|
||||
if (nodeingame[j])
|
||||
HSendPacket (j, k);
|
||||
}
|
||||
|
@ -1709,7 +1709,7 @@ void TryRunTics (void)
|
|||
|
||||
lowtic = INT_MAX;
|
||||
numplaying = 0;
|
||||
for (i = 0; i < doomcom->numnodes; i++)
|
||||
for (i = 0; i < doomcom.numnodes; i++)
|
||||
{
|
||||
if (nodeingame[i])
|
||||
{
|
||||
|
@ -1806,7 +1806,7 @@ void TryRunTics (void)
|
|||
NetUpdate ();
|
||||
lowtic = INT_MAX;
|
||||
|
||||
for (i = 0; i < doomcom->numnodes; i++)
|
||||
for (i = 0; i < doomcom.numnodes; i++)
|
||||
if (nodeingame[i] && nettics[i] < lowtic)
|
||||
lowtic = nettics[i];
|
||||
|
||||
|
|
|
@ -276,7 +276,7 @@ public:
|
|||
float BlendB;
|
||||
float BlendA;
|
||||
|
||||
char *LogText; // [RH] Log for Strife
|
||||
FString LogText; // [RH] Log for Strife
|
||||
|
||||
|
||||
fixed_t GetDeltaViewHeight() const
|
||||
|
|
|
@ -254,7 +254,7 @@ extern int skyflatnum;
|
|||
|
||||
// This is the interface to the packet driver, a separate program
|
||||
// in DOS, but just an abstraction here.
|
||||
extern doomcom_t* doomcom;
|
||||
extern doomcom_t doomcom;
|
||||
|
||||
extern struct ticcmd_t localcmds[LOCALCMDTICS];
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <zlib.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "doomtype.h"
|
||||
#include "farchive.h"
|
||||
|
@ -830,6 +831,32 @@ FArchive &FArchive::operator<< (char *&str)
|
|||
return *this;
|
||||
}
|
||||
|
||||
FArchive &FArchive::operator<< (FString &str)
|
||||
{
|
||||
if (m_Storing)
|
||||
{
|
||||
WriteString (str.GetChars());
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD size = ReadCount();
|
||||
|
||||
if (size == 0)
|
||||
{
|
||||
str = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
char *str2 = (char *)alloca(size*sizeof(char));
|
||||
size--;
|
||||
Read (str2, size);
|
||||
str2[size] = 0;
|
||||
str = str2;
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
FArchive &FArchive::operator<< (BYTE &c)
|
||||
{
|
||||
if (m_Storing)
|
||||
|
|
|
@ -179,6 +179,7 @@ virtual void Read (void *mem, unsigned int len);
|
|||
FArchive& operator<< (double &d);
|
||||
FArchive& operator<< (char *&str);
|
||||
FArchive& operator<< (FName &n);
|
||||
FArchive& operator<< (FString &str);
|
||||
FArchive& SerializePointer (void *ptrbase, BYTE **ptr, DWORD elemSize);
|
||||
FArchive& SerializeObject (DObject *&object, PClass *type);
|
||||
FArchive& WriteObject (DObject *obj);
|
||||
|
|
|
@ -1769,7 +1769,6 @@ void G_DoLoadLevel (int position, bool autosave)
|
|||
players[i].fragcount = 0;
|
||||
}
|
||||
|
||||
SN_StopAllSequences ();
|
||||
P_SetupLevel (level.mapname, position);
|
||||
|
||||
// [RH] Start lightning, if MAPINFO tells us to
|
||||
|
|
|
@ -797,6 +797,7 @@ extern int DisplayBits;
|
|||
int testingmode; // Holds time to revert to old mode
|
||||
int OldWidth, OldHeight, OldBits;
|
||||
|
||||
void M_FreeModesList ();
|
||||
static void BuildModesList (int hiwidth, int hiheight, int hi_id);
|
||||
static BOOL GetSelectedSize (int line, int *width, int *height);
|
||||
static void SetModesMenu (int w, int h, int bits);
|
||||
|
@ -823,6 +824,7 @@ static struct DepthNameKiller
|
|||
Depths[i].name = NULL;
|
||||
}
|
||||
}
|
||||
M_FreeModesList();
|
||||
}
|
||||
} KillTheDepthValues;
|
||||
|
||||
|
@ -2743,7 +2745,7 @@ static void BuildModesList (int hiwidth, int hiheight, int hi_bits)
|
|||
{
|
||||
if (*str)
|
||||
{
|
||||
free (*str);
|
||||
delete[] *str;
|
||||
*str = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -2756,6 +2758,29 @@ void M_RefreshModesList ()
|
|||
BuildModesList (SCREENWIDTH, SCREENHEIGHT, DisplayBits);
|
||||
}
|
||||
|
||||
void M_FreeModesList ()
|
||||
{
|
||||
for (int i = VM_RESSTART; ModesItems[i].type == screenres; ++i)
|
||||
{
|
||||
for (int c = 0; c < 3; ++c)
|
||||
{
|
||||
char **str;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
default: str = &ModesItems[i].b.res1; break;
|
||||
case 1: str = &ModesItems[i].c.res2; break;
|
||||
case 2: str = &ModesItems[i].d.res3; break;
|
||||
}
|
||||
if (str != NULL)
|
||||
{
|
||||
delete[] *str;
|
||||
*str = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL GetSelectedSize (int line, int *width, int *height)
|
||||
{
|
||||
if (ModesItems[line].type != screenres)
|
||||
|
|
|
@ -4240,22 +4240,6 @@ bool P_ChangeSector (sector_t *sector, int crunch, int amt, int floorOrCeil)
|
|||
|
||||
msecnode_t *headsecnode = NULL;
|
||||
|
||||
struct SecnodeKiller
|
||||
{
|
||||
~SecnodeKiller()
|
||||
{
|
||||
msecnode_t *node = headsecnode;
|
||||
|
||||
while (node != NULL)
|
||||
{
|
||||
msecnode_t *next = node->m_snext;
|
||||
free (node);
|
||||
node = next;
|
||||
}
|
||||
headsecnode = NULL;
|
||||
}
|
||||
} KillTheSecnodes;
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// P_GetSecnode
|
||||
|
|
|
@ -55,6 +55,8 @@
|
|||
#include "gi.h"
|
||||
#include "p_conversation.h"
|
||||
#include "a_keys.h"
|
||||
#include "s_sndseq.h"
|
||||
#include "sbar.h"
|
||||
|
||||
extern void P_SpawnMapThing (mapthing2_t *mthing, int position);
|
||||
extern bool P_LoadBuildMap (BYTE *mapdata, size_t len, mapthing2_t **things, int *numthings);
|
||||
|
@ -2790,6 +2792,7 @@ extern polyblock_t **PolyBlockMap;
|
|||
|
||||
void P_FreeLevelData ()
|
||||
{
|
||||
SN_StopAllSequences ();
|
||||
DThinker::DestroyAllThinkers ();
|
||||
level.total_monsters = level.total_items = level.total_secrets =
|
||||
level.killed_monsters = level.found_items = level.found_secrets =
|
||||
|
@ -2904,10 +2907,50 @@ void P_FreeLevelData ()
|
|||
if (zones != NULL)
|
||||
{
|
||||
delete[] zones;
|
||||
zones = NULL;
|
||||
}
|
||||
P_FreeStrifeConversations ();
|
||||
}
|
||||
|
||||
extern msecnode_t *headsecnode;
|
||||
|
||||
static struct AutoFreeLevelData
|
||||
{
|
||||
~AutoFreeLevelData()
|
||||
{
|
||||
P_FreeLevelData();
|
||||
|
||||
// Blocknodes and msecnodes should be freed now, when we
|
||||
// can be sure they are all easily located in their
|
||||
// free lists.
|
||||
{
|
||||
FBlockNode *node = FBlockNode::FreeBlocks;
|
||||
while (node != NULL)
|
||||
{
|
||||
FBlockNode *next = node->NextBlock;
|
||||
delete node;
|
||||
node = next;
|
||||
}
|
||||
}
|
||||
{
|
||||
msecnode_t *node = headsecnode;
|
||||
|
||||
while (node != NULL)
|
||||
{
|
||||
msecnode_t *next = node->m_snext;
|
||||
free (node);
|
||||
node = next;
|
||||
}
|
||||
headsecnode = NULL;
|
||||
}
|
||||
if (StatusBar != NULL)
|
||||
{
|
||||
delete StatusBar;
|
||||
StatusBar = NULL;
|
||||
}
|
||||
}
|
||||
} LevelDataFree_er;
|
||||
|
||||
//
|
||||
// P_SetupLevel
|
||||
//
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
// of single-player start spots should be spawned in the level.
|
||||
void P_SetupLevel (char *mapname, int position);
|
||||
|
||||
void P_FreeLevelData();
|
||||
|
||||
// Called by startup code.
|
||||
void P_Init (void);
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ void player_s::SetLogNumber (int num)
|
|||
|
||||
void player_s::SetLogText (const char *text)
|
||||
{
|
||||
ReplaceString (&LogText, text);
|
||||
LogText = text;
|
||||
}
|
||||
|
||||
IMPLEMENT_ABSTRACT_ACTOR (APlayerPawn)
|
||||
|
|
|
@ -83,6 +83,18 @@ drawseg_t *drawsegs;
|
|||
drawseg_t* firstdrawseg;
|
||||
drawseg_t* ds_p;
|
||||
|
||||
static struct DrawSegFree
|
||||
{
|
||||
~DrawSegFree()
|
||||
{
|
||||
if (drawsegs != NULL)
|
||||
{
|
||||
free (drawsegs);
|
||||
drawsegs = NULL;
|
||||
}
|
||||
}
|
||||
} FreeDrawSegs;
|
||||
|
||||
size_t FirstInterestingDrawseg;
|
||||
TArray<size_t> InterestingDrawsegs;
|
||||
|
||||
|
|
|
@ -72,6 +72,20 @@ static visplane_t *visplanes[MAXVISPLANES+1]; // killough
|
|||
static visplane_t *freetail; // killough
|
||||
static visplane_t **freehead = &freetail; // killough
|
||||
|
||||
static struct VisPlaneFree
|
||||
{
|
||||
~VisPlaneFree()
|
||||
{
|
||||
R_ClearPlanes(false);
|
||||
for (visplane_t *pl = freetail; pl != NULL; )
|
||||
{
|
||||
visplane_t *next = pl->next;
|
||||
free (pl);
|
||||
pl = next;
|
||||
}
|
||||
}
|
||||
} VisPlaneFree_er;
|
||||
|
||||
visplane_t *floorplane;
|
||||
visplane_t *ceilingplane;
|
||||
|
||||
|
@ -99,6 +113,17 @@ size_t maxopenings;
|
|||
short *openings;
|
||||
ptrdiff_t lastopening;
|
||||
|
||||
static struct OpeningsFree
|
||||
{
|
||||
~OpeningsFree()
|
||||
{
|
||||
if (openings != NULL)
|
||||
{
|
||||
free (openings);
|
||||
openings = NULL;
|
||||
}
|
||||
}
|
||||
} FreeOpenings;
|
||||
|
||||
//
|
||||
// Clip values are the solid pixel bounding the range.
|
||||
|
|
|
@ -678,6 +678,18 @@ vissprite_t **vissprite_p;
|
|||
vissprite_t **lastvissprite;
|
||||
int newvissprite;
|
||||
|
||||
static struct VisSpriteDeleter
|
||||
{
|
||||
~VisSpriteDeleter()
|
||||
{
|
||||
for (int i = 0; i < MaxVisSprites; ++i)
|
||||
{
|
||||
delete vissprites[i];
|
||||
}
|
||||
free (vissprites);
|
||||
}
|
||||
} DeleteTheVisSprites;
|
||||
|
||||
static void R_CreateSkinTranslation (const char *palname)
|
||||
{
|
||||
FMemLump lump = Wads.ReadLump (palname);
|
||||
|
@ -832,7 +844,6 @@ vissprite_t *R_NewVisSprite (void)
|
|||
return *(vissprite_p-1);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// R_DrawMaskedColumn
|
||||
// Used for sprites and masked mid textures.
|
||||
|
@ -1555,8 +1566,18 @@ static vissprite_t **spritesorter;
|
|||
static int spritesortersize = 0;
|
||||
static int vsprcount;
|
||||
|
||||
static drawseg_t **drawsegsorter;
|
||||
static int drawsegsortersize = 0;
|
||||
static struct SpriteSorterFree
|
||||
{
|
||||
~SpriteSorterFree()
|
||||
{
|
||||
if (spritesorter != NULL)
|
||||
{
|
||||
delete[] spritesorter;
|
||||
spritesortersize = 0;
|
||||
spritesorter = NULL;
|
||||
}
|
||||
}
|
||||
} SpriteSorterFree_er;
|
||||
|
||||
// Sort vissprites by depth, far to near
|
||||
static int STACK_ARGS sv_compare (const void *arg1, const void *arg2)
|
||||
|
@ -1569,6 +1590,9 @@ static int STACK_ARGS sv_compare (const void *arg1, const void *arg2)
|
|||
}
|
||||
|
||||
#if 0
|
||||
static drawseg_t **drawsegsorter;
|
||||
static int drawsegsortersize = 0;
|
||||
|
||||
// Sort vissprites by leftmost column, left to right
|
||||
static int STACK_ARGS sv_comparex (const void *arg1, const void *arg2)
|
||||
{
|
||||
|
|
|
@ -146,6 +146,18 @@ private:
|
|||
sector_t *m_Sector;
|
||||
};
|
||||
|
||||
// When destroyed, destroy the sound sequences too.
|
||||
struct FSoundSequencePtrArray : public TArray<FSoundSequence *>
|
||||
{
|
||||
~FSoundSequencePtrArray()
|
||||
{
|
||||
for (unsigned int i = 0; i < Size(); ++i)
|
||||
{
|
||||
free ((*this)[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
|
||||
|
||||
static void AssignTranslations (int seq, seqtype_t type);
|
||||
|
@ -157,7 +169,7 @@ static bool TwiddleSeqNum (int &sequence, seqtype_t type);
|
|||
|
||||
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
||||
|
||||
TArray<FSoundSequence *> Sequences;
|
||||
FSoundSequencePtrArray Sequences;
|
||||
int ActiveSequences;
|
||||
DSeqNode *DSeqNode::SequenceListHead;
|
||||
|
||||
|
@ -298,6 +310,7 @@ void DSeqNode::Serialize (FArchive &arc)
|
|||
ChangeData (seqOffset, delayTics - TIME_REFERENCE, volume, id);
|
||||
|
||||
numchoices = arc.ReadCount();
|
||||
m_SequenceChoices.Resize(numchoices);
|
||||
for (i = 0; i < numchoices; ++i)
|
||||
{
|
||||
arc << seqName;
|
||||
|
|
|
@ -116,7 +116,7 @@ typedef struct
|
|||
|
||||
struct MusPlayingInfo
|
||||
{
|
||||
char *name;
|
||||
FString name;
|
||||
void *handle;
|
||||
int baseorder;
|
||||
bool loop;
|
||||
|
@ -144,7 +144,7 @@ int MAX_SND_DIST;
|
|||
static channel_t *Channel; // the set of channels available
|
||||
static BOOL mus_paused; // whether songs are paused
|
||||
static MusPlayingInfo mus_playing; // music currently being played
|
||||
static char *LastSong; // last music that was played
|
||||
static FString LastSong; // last music that was played
|
||||
static byte *SoundCurve;
|
||||
static int nextcleanup;
|
||||
static FPlayList *PlayList;
|
||||
|
@ -167,6 +167,29 @@ CVAR (Bool, snd_flipstereo, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|||
|
||||
// CODE --------------------------------------------------------------------
|
||||
|
||||
static struct FreeSoundData
|
||||
{
|
||||
~FreeSoundData()
|
||||
{
|
||||
if (Channel != NULL)
|
||||
{
|
||||
delete[] Channel;
|
||||
Channel = NULL;
|
||||
numChannels = 0;
|
||||
}
|
||||
if (SoundCurve != NULL)
|
||||
{
|
||||
delete[] SoundCurve;
|
||||
SoundCurve = NULL;
|
||||
}
|
||||
if (PlayList != NULL)
|
||||
{
|
||||
delete PlayList;
|
||||
PlayList = NULL;
|
||||
}
|
||||
}
|
||||
} SoundDataFree_er;
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// P_AproxDistance2
|
||||
|
@ -1430,7 +1453,7 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (mus_playing.name && stricmp (mus_playing.name, musicname) == 0)
|
||||
if (!mus_playing.name.IsEmpty() && stricmp (mus_playing.name, musicname) == 0)
|
||||
{
|
||||
if (order != mus_playing.baseorder)
|
||||
{
|
||||
|
@ -1451,10 +1474,6 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force)
|
|||
id = strtoul (more+1, NULL, 16);
|
||||
}
|
||||
S_StopMusic (true);
|
||||
if (mus_playing.name)
|
||||
{
|
||||
delete[] mus_playing.name;
|
||||
}
|
||||
mus_playing.handle = I_RegisterCDSong (track, id);
|
||||
}
|
||||
else
|
||||
|
@ -1498,15 +1517,6 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force)
|
|||
S_StopMusic (true);
|
||||
|
||||
// load & register it
|
||||
|
||||
// Note by Graf Zahl: S_StopMusic NULLs this variable so there's nothing to delete anymore!
|
||||
/*
|
||||
if (mus_playing.name)
|
||||
{
|
||||
delete[] mus_playing.name;
|
||||
}
|
||||
*/
|
||||
|
||||
if (offset!=-1)
|
||||
{
|
||||
mus_playing.handle = I_RegisterSong (lumpnum != -1 ?
|
||||
|
@ -1525,7 +1535,7 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force)
|
|||
|
||||
if (mus_playing.handle != 0)
|
||||
{ // play it
|
||||
mus_playing.name = copystring (musicname);
|
||||
mus_playing.name = musicname;
|
||||
I_PlaySong (mus_playing.handle, looping, S_GetMusicVolume (musicname));
|
||||
mus_playing.baseorder =
|
||||
(I_SetSongPosition (mus_playing.handle, order) ? order : 0);
|
||||
|
@ -1543,11 +1553,10 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force)
|
|||
|
||||
void S_RestartMusic ()
|
||||
{
|
||||
if (LastSong != NULL)
|
||||
if (!LastSong.IsEmpty())
|
||||
{
|
||||
S_ChangeMusic (LastSong, mus_playing.baseorder, mus_playing.loop, true);
|
||||
delete[] LastSong;
|
||||
LastSong = NULL;
|
||||
LastSong = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1583,7 +1592,7 @@ int S_GetMusic (char **name)
|
|||
void S_StopMusic (bool force)
|
||||
{
|
||||
// [RH] Don't stop if a playlist is active.
|
||||
if ((force || PlayList == NULL) && mus_playing.name)
|
||||
if ((force || PlayList == NULL) && !mus_playing.name.IsEmpty())
|
||||
{
|
||||
if (mus_paused)
|
||||
I_ResumeSong(mus_playing.handle);
|
||||
|
@ -1591,13 +1600,8 @@ void S_StopMusic (bool force)
|
|||
I_StopSong(mus_playing.handle);
|
||||
I_UnRegisterSong(mus_playing.handle);
|
||||
|
||||
if (LastSong)
|
||||
{
|
||||
delete[] LastSong;
|
||||
}
|
||||
|
||||
LastSong = mus_playing.name;
|
||||
mus_playing.name = NULL;
|
||||
mus_playing.name = "";
|
||||
mus_playing.handle = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -170,12 +170,12 @@ int FindNode (sockaddr_in *address)
|
|||
int i;
|
||||
|
||||
// find remote node number
|
||||
for (i = 0; i<doomcom->numnodes; i++)
|
||||
for (i = 0; i<doomcom.numnodes; i++)
|
||||
if (address->sin_addr.s_addr == sendaddress[i].sin_addr.s_addr
|
||||
&& address->sin_port == sendaddress[i].sin_port)
|
||||
break;
|
||||
|
||||
if (i == doomcom->numnodes)
|
||||
if (i == doomcom.numnodes)
|
||||
{
|
||||
// packet is not from one of the players (new game broadcast?)
|
||||
i = -1;
|
||||
|
@ -191,9 +191,9 @@ void PacketSend (void)
|
|||
int c;
|
||||
|
||||
//printf ("sending %i\n",gametic);
|
||||
c = sendto (mysocket , (const char*)doomcom->data, doomcom->datalength
|
||||
,0,(sockaddr *)&sendaddress[doomcom->remotenode]
|
||||
,sizeof(sendaddress[doomcom->remotenode]));
|
||||
c = sendto (mysocket , (const char*)doomcom.data, doomcom.datalength
|
||||
,0,(sockaddr *)&sendaddress[doomcom.remotenode]
|
||||
,sizeof(sendaddress[doomcom.remotenode]));
|
||||
|
||||
// if (c == -1)
|
||||
// I_Error ("SendPacket error: %s",strerror(errno));
|
||||
|
@ -211,7 +211,7 @@ void PacketGet (void)
|
|||
int node;
|
||||
|
||||
fromlen = sizeof(fromaddress);
|
||||
c = recvfrom (mysocket, (char*)doomcom->data, MAX_MSGLEN, 0
|
||||
c = recvfrom (mysocket, (char*)doomcom.data, MAX_MSGLEN, 0
|
||||
, (sockaddr *)&fromaddress, &fromlen);
|
||||
node = FindNode (&fromaddress);
|
||||
|
||||
|
@ -225,7 +225,7 @@ void PacketGet (void)
|
|||
Printf (PRINT_BOLD, "The connection from %s was dropped\n",
|
||||
players[sendplayer[node]].userinfo.netname);
|
||||
|
||||
doomcom->data[0] = 0x80; // NCMD_EXIT
|
||||
doomcom.data[0] = 0x80; // NCMD_EXIT
|
||||
c = 1;
|
||||
}
|
||||
else if (err != WSAEWOULDBLOCK)
|
||||
|
@ -234,13 +234,13 @@ void PacketGet (void)
|
|||
}
|
||||
else
|
||||
{
|
||||
doomcom->remotenode = -1; // no packet
|
||||
doomcom.remotenode = -1; // no packet
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
doomcom->remotenode = node;
|
||||
doomcom->datalength = (short)c;
|
||||
doomcom.remotenode = node;
|
||||
doomcom.datalength = (short)c;
|
||||
}
|
||||
|
||||
sockaddr_in *PreGet (void *buffer, int bufferlen, bool noabort)
|
||||
|
@ -307,7 +307,7 @@ void BuildAddress (sockaddr_in *address, char *name)
|
|||
if (!isnamed)
|
||||
{
|
||||
address->sin_addr.s_addr = inet_addr (name);
|
||||
Printf ("Node number %d address %s\n", doomcom->numnodes, name);
|
||||
Printf ("Node number %d address %s\n", doomcom.numnodes, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -316,7 +316,7 @@ void BuildAddress (sockaddr_in *address, char *name)
|
|||
I_FatalError ("gethostbyname: couldn't find %s\n%s", name, neterror());
|
||||
address->sin_addr.s_addr = *(int *)hostentry->h_addr_list[0];
|
||||
Printf ("Node number %d hostname %s\n",
|
||||
doomcom->numnodes, hostentry->h_name);
|
||||
doomcom.numnodes, hostentry->h_name);
|
||||
}
|
||||
|
||||
if (portpart)
|
||||
|
@ -368,34 +368,34 @@ void WaitForPlayers (int i)
|
|||
StartNetwork (false);
|
||||
|
||||
// parse player number and host list
|
||||
doomcom->consoleplayer = (short)(Args.GetArg (i+1)[0]-'1');
|
||||
Printf ("Console player number: %d\n", doomcom->consoleplayer);
|
||||
doomcom.consoleplayer = (short)(Args.GetArg (i+1)[0]-'1');
|
||||
Printf ("Console player number: %d\n", doomcom.consoleplayer);
|
||||
|
||||
doomcom->numnodes = 1; // this node for sure
|
||||
doomcom.numnodes = 1; // this node for sure
|
||||
|
||||
i++;
|
||||
while (++i < Args.NumArgs() && Args.GetArg (i)[0] != '-' && Args.GetArg (i)[0] != '+')
|
||||
{
|
||||
BuildAddress (&sendaddress[doomcom->numnodes], Args.GetArg (i));
|
||||
doomcom->numnodes++;
|
||||
BuildAddress (&sendaddress[doomcom.numnodes], Args.GetArg (i));
|
||||
doomcom.numnodes++;
|
||||
}
|
||||
|
||||
Printf ("Total players: %d\n", doomcom->numnodes);
|
||||
Printf ("Total players: %d\n", doomcom.numnodes);
|
||||
|
||||
doomcom->id = DOOMCOM_ID;
|
||||
doomcom->numplayers = doomcom->numnodes;
|
||||
doomcom.id = DOOMCOM_ID;
|
||||
doomcom.numplayers = doomcom.numnodes;
|
||||
}
|
||||
|
||||
void STACK_ARGS SendAbort (void)
|
||||
{
|
||||
BYTE dis[2] = { PRE_FAKE, PRE_DISCONNECT };
|
||||
|
||||
while (--doomcom->numnodes > 0)
|
||||
while (--doomcom.numnodes > 0)
|
||||
{
|
||||
PreSend (dis, 2, &sendaddress[doomcom->numnodes]);
|
||||
PreSend (dis, 2, &sendaddress[doomcom->numnodes]);
|
||||
PreSend (dis, 2, &sendaddress[doomcom->numnodes]);
|
||||
PreSend (dis, 2, &sendaddress[doomcom->numnodes]);
|
||||
PreSend (dis, 2, &sendaddress[doomcom.numnodes]);
|
||||
PreSend (dis, 2, &sendaddress[doomcom.numnodes]);
|
||||
PreSend (dis, 2, &sendaddress[doomcom.numnodes]);
|
||||
PreSend (dis, 2, &sendaddress[doomcom.numnodes]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -417,9 +417,9 @@ void HostGame (int i)
|
|||
{ // Special case: Only 1 player, so don't bother starting the network
|
||||
netgame = false;
|
||||
multiplayer = true;
|
||||
doomcom->id = DOOMCOM_ID;
|
||||
doomcom->numplayers = doomcom->numnodes = 1;
|
||||
doomcom->consoleplayer = 0;
|
||||
doomcom.id = DOOMCOM_ID;
|
||||
doomcom.numplayers = doomcom.numnodes = 1;
|
||||
doomcom.consoleplayer = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -427,18 +427,18 @@ void HostGame (int i)
|
|||
|
||||
// [JC] - this computer is starting the game, therefore it should
|
||||
// be the Net Arbitrator.
|
||||
doomcom->consoleplayer = 0;
|
||||
Printf ("Console player number: %d\n", doomcom->consoleplayer);
|
||||
doomcom.consoleplayer = 0;
|
||||
Printf ("Console player number: %d\n", doomcom.consoleplayer);
|
||||
|
||||
doomcom->numnodes = 1;
|
||||
doomcom.numnodes = 1;
|
||||
Printf ("Waiting for players...\n");
|
||||
|
||||
atterm (SendAbort);
|
||||
|
||||
// Wait for numplayers-1 different connections
|
||||
while (doomcom->numnodes < numplayers)
|
||||
while (doomcom.numnodes < numplayers)
|
||||
{
|
||||
while (doomcom->numnodes < numplayers)
|
||||
while (doomcom.numnodes < numplayers)
|
||||
{
|
||||
if (CheckAbort ())
|
||||
{
|
||||
|
@ -458,7 +458,7 @@ void HostGame (int i)
|
|||
node = FindNode (from);
|
||||
if (node == -1)
|
||||
{
|
||||
node = doomcom->numnodes++;
|
||||
node = doomcom.numnodes++;
|
||||
sendaddress[node] = *from;
|
||||
}
|
||||
Printf ("Got connect from node %d\n", node);
|
||||
|
@ -472,8 +472,8 @@ void HostGame (int i)
|
|||
if (node >= 0)
|
||||
{
|
||||
Printf ("Got disconnect from node %d\n", node);
|
||||
doomcom->numnodes--;
|
||||
while (node < doomcom->numnodes)
|
||||
doomcom.numnodes--;
|
||||
while (node < doomcom.numnodes)
|
||||
{
|
||||
sendaddress[node] = sendaddress[node+1];
|
||||
node++;
|
||||
|
@ -494,8 +494,8 @@ void HostGame (int i)
|
|||
node = FindNode (from);
|
||||
if (node >= 0)
|
||||
{
|
||||
doomcom->numnodes--;
|
||||
while (node < doomcom->numnodes)
|
||||
doomcom.numnodes--;
|
||||
while (node < doomcom.numnodes)
|
||||
{
|
||||
sendaddress[node] = sendaddress[node+1];
|
||||
node++;
|
||||
|
@ -510,18 +510,18 @@ void HostGame (int i)
|
|||
ackcount = 0;
|
||||
memset (gotack, 0, sizeof(gotack));
|
||||
Printf ("Sending all here\n");
|
||||
while (ackcount < doomcom->numnodes - 1)
|
||||
while (ackcount < doomcom.numnodes - 1)
|
||||
{
|
||||
packet.fake = PRE_FAKE;
|
||||
packet.message = PRE_ALLHERE;
|
||||
packet.numnodes = doomcom->numnodes - 2;
|
||||
for (node = 1; node < doomcom->numnodes; node++)
|
||||
packet.numnodes = doomcom.numnodes - 2;
|
||||
for (node = 1; node < doomcom.numnodes; node++)
|
||||
{
|
||||
int machine, spot = 0;
|
||||
|
||||
if (!gotack[node])
|
||||
{
|
||||
for (spot = 0, machine = 1; machine < doomcom->numnodes; machine++)
|
||||
for (spot = 0, machine = 1; machine < doomcom.numnodes; machine++)
|
||||
{
|
||||
if (node != machine)
|
||||
{
|
||||
|
@ -567,7 +567,7 @@ void HostGame (int i)
|
|||
Printf ("Go\n");
|
||||
packet.fake = PRE_FAKE;
|
||||
packet.message = PRE_GO;
|
||||
for (node = 1; node < doomcom->numnodes; node++)
|
||||
for (node = 1; node < doomcom.numnodes; node++)
|
||||
{
|
||||
for (int i = 8; i != 0; --i)
|
||||
{
|
||||
|
@ -575,13 +575,13 @@ void HostGame (int i)
|
|||
}
|
||||
}
|
||||
|
||||
Printf ("Total players: %d\n", doomcom->numnodes);
|
||||
Printf ("Total players: %d\n", doomcom.numnodes);
|
||||
|
||||
doomcom->id = DOOMCOM_ID;
|
||||
doomcom->numplayers = doomcom->numnodes;
|
||||
doomcom.id = DOOMCOM_ID;
|
||||
doomcom.numplayers = doomcom.numnodes;
|
||||
|
||||
// On the host, each player's number is the same as its node number
|
||||
for (i = 0; i < doomcom->numnodes; ++i)
|
||||
for (i = 0; i < doomcom.numnodes; ++i)
|
||||
{
|
||||
sendplayer[i] = i;
|
||||
}
|
||||
|
@ -614,9 +614,9 @@ void SendToHost (BYTE message, BYTE ackmess, bool abortable)
|
|||
{
|
||||
waiting = false;
|
||||
|
||||
doomcom->consoleplayer = packet.consolenum;
|
||||
doomcom.consoleplayer = packet.consolenum;
|
||||
sendplayer[0] = packet.consolenum;
|
||||
Printf ("Console player number: %d\n", doomcom->consoleplayer);
|
||||
Printf ("Console player number: %d\n", doomcom.consoleplayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -644,7 +644,7 @@ void JoinGame (int i)
|
|||
|
||||
// Wait for everyone else to connect
|
||||
waiting = true;
|
||||
//doomcom->numnodes = 2;
|
||||
//doomcom.numnodes = 2;
|
||||
atterm (SendAbort);
|
||||
|
||||
while (waiting)
|
||||
|
@ -665,12 +665,12 @@ void JoinGame (int i)
|
|||
switch (packet.message)
|
||||
{
|
||||
case PRE_ALLHERE:
|
||||
if (doomcom->numnodes == 0)
|
||||
if (doomcom.numnodes == 0)
|
||||
{
|
||||
int node;
|
||||
|
||||
packet.numnodes = packet.numnodes;
|
||||
doomcom->numnodes = packet.numnodes + 2;
|
||||
doomcom.numnodes = packet.numnodes + 2;
|
||||
for (node = 0; node < packet.numnodes; node++)
|
||||
{
|
||||
sendaddress[node+2].sin_addr.s_addr = packet.machines[node].address;
|
||||
|
@ -702,10 +702,10 @@ void JoinGame (int i)
|
|||
|
||||
popterm ();
|
||||
|
||||
Printf ("Total players: %d\n", doomcom->numnodes);
|
||||
Printf ("Total players: %d\n", doomcom.numnodes);
|
||||
|
||||
doomcom->id = DOOMCOM_ID;
|
||||
doomcom->numplayers = doomcom->numnodes;
|
||||
doomcom.id = DOOMCOM_ID;
|
||||
doomcom.numplayers = doomcom.numnodes;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -716,24 +716,23 @@ void I_InitNetwork (void)
|
|||
int i;
|
||||
char *v;
|
||||
|
||||
doomcom = new doomcom_t;
|
||||
memset (doomcom, 0, sizeof(*doomcom));
|
||||
memset (&doomcom, 0, sizeof(doomcom));
|
||||
|
||||
// set up for network
|
||||
v = Args.CheckValue ("-dup");
|
||||
if (v)
|
||||
{
|
||||
doomcom->ticdup = clamp (atoi (v), 1, MAXTICDUP);
|
||||
doomcom.ticdup = clamp (atoi (v), 1, MAXTICDUP);
|
||||
}
|
||||
else
|
||||
{
|
||||
doomcom->ticdup = 1;
|
||||
doomcom.ticdup = 1;
|
||||
}
|
||||
|
||||
if (Args.CheckParm ("-extratic"))
|
||||
doomcom->extratics = 1;
|
||||
doomcom.extratics = 1;
|
||||
else
|
||||
doomcom->extratics = 0;
|
||||
doomcom.extratics = 0;
|
||||
|
||||
v = Args.CheckValue ("-port");
|
||||
if (v)
|
||||
|
@ -758,9 +757,9 @@ void I_InitNetwork (void)
|
|||
// single player game
|
||||
netgame = false;
|
||||
multiplayer = false;
|
||||
doomcom->id = DOOMCOM_ID;
|
||||
doomcom->numplayers = doomcom->numnodes = 1;
|
||||
doomcom->consoleplayer = 0;
|
||||
doomcom.id = DOOMCOM_ID;
|
||||
doomcom.numplayers = doomcom.numnodes = 1;
|
||||
doomcom.consoleplayer = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -768,16 +767,16 @@ void I_InitNetwork (void)
|
|||
|
||||
void I_NetCmd (void)
|
||||
{
|
||||
if (doomcom->command == CMD_SEND)
|
||||
if (doomcom.command == CMD_SEND)
|
||||
{
|
||||
netsend ();
|
||||
}
|
||||
else if (doomcom->command == CMD_GET)
|
||||
else if (doomcom.command == CMD_GET)
|
||||
{
|
||||
netget ();
|
||||
}
|
||||
else
|
||||
I_Error ("Bad net cmd: %i\n",doomcom->command);
|
||||
I_Error ("Bad net cmd: %i\n",doomcom.command);
|
||||
}
|
||||
|
||||
#ifdef __WIN32__
|
||||
|
|
|
@ -200,7 +200,7 @@ FString::Pool::~Pool ()
|
|||
if (str->Owner != NULL)
|
||||
{
|
||||
FString *owner = str->Owner;
|
||||
assert (owner->Chars == (char *)str + sizeof(StringHeader));
|
||||
// assert (owner->Chars == (char *)str + sizeof(StringHeader));
|
||||
Free ((char *)str + sizeof(StringHeader));
|
||||
owner->Chars = "";
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ void FString::Pool::Free (char *chars)
|
|||
{
|
||||
if (str->Owner != NULL)
|
||||
{
|
||||
assert (str->Owner->Chars == (char *)str + sizeof(StringHeader));
|
||||
// assert (str->Owner->Chars == (char *)str + sizeof(StringHeader));
|
||||
str = (StringHeader *)((char *)str + RoundLen(str->Len));
|
||||
}
|
||||
else
|
||||
|
@ -335,7 +335,7 @@ void FString::Pool::Free (char *chars)
|
|||
{
|
||||
if (str->Owner != NULL)
|
||||
{
|
||||
assert (str->Owner->Chars == (char *)str + sizeof(StringHeader));
|
||||
// assert (str->Owner->Chars == (char *)str + sizeof(StringHeader));
|
||||
str = (StringHeader *)((char *)str + RoundLen(str->Len));
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue