2006-02-24 04:48:15 +00:00
|
|
|
/*
|
|
|
|
** dobject.cpp
|
|
|
|
** Implements the base class DObject, which most other classes derive from
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
2006-06-11 01:37:00 +00:00
|
|
|
** Copyright 1998-2006 Randy Heit
|
2006-02-24 04:48:15 +00:00
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "cmdlib.h"
|
|
|
|
#include "actor.h"
|
|
|
|
#include "dobject.h"
|
|
|
|
#include "doomstat.h" // Ideally, DObjects can be used independant of Doom.
|
|
|
|
#include "d_player.h" // See p_user.cpp to find out why this doesn't work.
|
|
|
|
#include "g_game.h" // Needed for bodyque.
|
|
|
|
#include "c_dispatch.h"
|
|
|
|
#include "i_system.h"
|
|
|
|
#include "r_state.h"
|
|
|
|
#include "stats.h"
|
2007-10-29 20:27:40 +00:00
|
|
|
#include "a_sharedglobal.h"
|
2008-03-12 02:56:11 +00:00
|
|
|
#include "dsectoreffect.h"
|
2011-07-06 14:20:54 +00:00
|
|
|
#include "farchive.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-05-10 02:40:43 +00:00
|
|
|
ClassReg DObject::RegistrationInfo =
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-09-17 01:36:14 +00:00
|
|
|
NULL, // MyClass
|
2006-05-10 02:40:43 +00:00
|
|
|
"DObject", // Name
|
|
|
|
NULL, // ParentType
|
|
|
|
NULL, // Pointers
|
2010-03-24 02:49:37 +00:00
|
|
|
&DObject::InPlaceConstructor, // ConstructNative
|
|
|
|
sizeof(DObject), // SizeOf
|
|
|
|
CLASSREG_PClass, // MetaClassNum
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
2006-05-10 02:40:43 +00:00
|
|
|
_DECLARE_TI(DObject)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-07-26 17:10:43 +00:00
|
|
|
CCMD (dumpactors)
|
|
|
|
{
|
2010-08-11 03:56:31 +00:00
|
|
|
const char *const filters[32] =
|
2010-07-26 17:10:43 +00:00
|
|
|
{
|
|
|
|
"0:All", "1:Doom", "2:Heretic", "3:DoomHeretic", "4:Hexen", "5:DoomHexen", "6:Raven", "7:IdRaven",
|
|
|
|
"8:Strife", "9:DoomStrife", "10:HereticStrife", "11:DoomHereticStrife", "12:HexenStrife",
|
|
|
|
"13:DoomHexenStrife", "14:RavenStrife", "15:NotChex", "16:Chex", "17:DoomChex", "18:HereticChex",
|
|
|
|
"19:DoomHereticChex", "20:HexenChex", "21:DoomHexenChex", "22:RavenChex", "23:NotStrife", "24:StrifeChex",
|
|
|
|
"25:DoomStrifeChex", "26:HereticStrifeChex", "27:NotHexen", "28:HexenStrifeChex", "29:NotHeretic",
|
|
|
|
"30:NotDoom", "31:All",
|
|
|
|
};
|
2010-09-16 03:14:32 +00:00
|
|
|
Printf("%i object class types total\nActor\tEd Num\tSpawnID\tFilter\tSource\n", PClass::AllClasses.Size());
|
|
|
|
for (unsigned int i = 0; i < PClass::AllClasses.Size(); i++)
|
2010-07-26 17:10:43 +00:00
|
|
|
{
|
2010-09-16 03:14:32 +00:00
|
|
|
PClass *cls = PClass::AllClasses[i];
|
|
|
|
PClassActor *acls = dyn_cast<PClassActor>(cls);
|
|
|
|
if (acls != NULL)
|
|
|
|
{
|
2010-07-26 17:10:43 +00:00
|
|
|
Printf("%s\t%i\t%i\t%s\t%s\n",
|
2010-09-16 03:14:32 +00:00
|
|
|
acls->TypeName.GetChars(), acls->DoomEdNum,
|
|
|
|
acls->SpawnID, filters[acls->GameFilter & 31],
|
|
|
|
acls->SourceLumpName.GetChars());
|
|
|
|
}
|
2010-07-26 17:10:43 +00:00
|
|
|
else if (cls != NULL)
|
2010-09-16 03:14:32 +00:00
|
|
|
{
|
2010-07-26 17:10:43 +00:00
|
|
|
Printf("%s\tn/a\tn/a\tn/a\tEngine (not an actor type)\n", cls->TypeName.GetChars());
|
2010-09-16 03:14:32 +00:00
|
|
|
}
|
2010-07-26 17:10:43 +00:00
|
|
|
else
|
2010-09-16 03:14:32 +00:00
|
|
|
{
|
2010-07-26 17:10:43 +00:00
|
|
|
Printf("Type %i is not an object class\n", i);
|
2010-09-16 03:14:32 +00:00
|
|
|
}
|
2010-07-26 17:10:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
CCMD (dumpclasses)
|
|
|
|
{
|
2006-05-10 02:40:43 +00:00
|
|
|
// This is by no means speed-optimized. But it's an informational console
|
|
|
|
// command that will be executed infrequently, so I don't mind.
|
|
|
|
struct DumpInfo
|
|
|
|
{
|
|
|
|
const PClass *Type;
|
|
|
|
DumpInfo *Next;
|
|
|
|
DumpInfo *Children;
|
|
|
|
|
|
|
|
static DumpInfo *FindType (DumpInfo *root, const PClass *type)
|
|
|
|
{
|
|
|
|
if (root == NULL)
|
|
|
|
{
|
|
|
|
return root;
|
|
|
|
}
|
|
|
|
if (root->Type == type)
|
|
|
|
{
|
|
|
|
return root;
|
|
|
|
}
|
|
|
|
if (root->Next != NULL)
|
|
|
|
{
|
|
|
|
return FindType (root->Next, type);
|
|
|
|
}
|
|
|
|
if (root->Children != NULL)
|
|
|
|
{
|
|
|
|
return FindType (root->Children, type);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DumpInfo *AddType (DumpInfo **root, const PClass *type)
|
|
|
|
{
|
|
|
|
DumpInfo *info, *parentInfo;
|
|
|
|
|
|
|
|
if (*root == NULL)
|
|
|
|
{
|
|
|
|
info = new DumpInfo;
|
|
|
|
info->Type = type;
|
|
|
|
info->Next = NULL;
|
|
|
|
info->Children = *root;
|
|
|
|
*root = info;
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
if (type->ParentClass == (*root)->Type)
|
|
|
|
{
|
|
|
|
parentInfo = *root;
|
|
|
|
}
|
|
|
|
else if (type == (*root)->Type)
|
|
|
|
{
|
|
|
|
return *root;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
parentInfo = FindType (*root, type->ParentClass);
|
|
|
|
if (parentInfo == NULL)
|
|
|
|
{
|
|
|
|
parentInfo = AddType (root, type->ParentClass);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Has this type already been added?
|
|
|
|
for (info = parentInfo->Children; info != NULL; info = info->Next)
|
|
|
|
{
|
|
|
|
if (info->Type == type)
|
|
|
|
{
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
info = new DumpInfo;
|
|
|
|
info->Type = type;
|
|
|
|
info->Next = parentInfo->Children;
|
|
|
|
info->Children = NULL;
|
|
|
|
parentInfo->Children = info;
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PrintTree (DumpInfo *root, int level)
|
|
|
|
{
|
|
|
|
Printf ("%*c%s\n", level, ' ', root->Type->TypeName.GetChars());
|
|
|
|
if (root->Children != NULL)
|
|
|
|
{
|
|
|
|
PrintTree (root->Children, level + 2);
|
|
|
|
}
|
|
|
|
if (root->Next != NULL)
|
|
|
|
{
|
|
|
|
PrintTree (root->Next, level);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void FreeTree (DumpInfo *root)
|
|
|
|
{
|
|
|
|
if (root->Children != NULL)
|
|
|
|
{
|
|
|
|
FreeTree (root->Children);
|
|
|
|
}
|
|
|
|
if (root->Next != NULL)
|
|
|
|
{
|
|
|
|
FreeTree (root->Next);
|
|
|
|
}
|
|
|
|
delete root;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2006-05-16 04:19:20 +00:00
|
|
|
unsigned int i;
|
2006-02-24 04:48:15 +00:00
|
|
|
int shown, omitted;
|
2006-05-10 02:40:43 +00:00
|
|
|
DumpInfo *tree = NULL;
|
|
|
|
const PClass *root = NULL;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (argv.argc() > 1)
|
|
|
|
{
|
2006-05-10 02:40:43 +00:00
|
|
|
root = PClass::FindClass (argv[1]);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (root == NULL)
|
|
|
|
{
|
|
|
|
Printf ("Class '%s' not found\n", argv[1]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
shown = omitted = 0;
|
2006-05-10 02:40:43 +00:00
|
|
|
DumpInfo::AddType (&tree, root != NULL ? root : RUNTIME_CLASS(DObject));
|
2010-04-16 02:57:51 +00:00
|
|
|
for (i = 0; i < PClass::AllClasses.Size(); i++)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-04-16 02:57:51 +00:00
|
|
|
PClass *cls = PClass::AllClasses[i];
|
2010-03-24 02:49:37 +00:00
|
|
|
if (root == NULL || cls == root || cls->IsDescendantOf(root))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-05-10 02:40:43 +00:00
|
|
|
DumpInfo::AddType (&tree, cls);
|
|
|
|
// Printf (" %s\n", PClass::m_Types[i]->Name + 1);
|
2006-02-24 04:48:15 +00:00
|
|
|
shown++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
omitted++;
|
|
|
|
}
|
|
|
|
}
|
2006-05-10 02:40:43 +00:00
|
|
|
DumpInfo::PrintTree (tree, 2);
|
|
|
|
DumpInfo::FreeTree (tree);
|
2006-02-24 04:48:15 +00:00
|
|
|
Printf ("%d classes shown, %d omitted\n", shown, omitted);
|
|
|
|
}
|
|
|
|
|
2006-05-10 02:40:43 +00:00
|
|
|
void DObject::InPlaceConstructor (void *mem)
|
|
|
|
{
|
|
|
|
new ((EInPlace *)mem) DObject;
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
DObject::DObject ()
|
2008-03-12 02:56:11 +00:00
|
|
|
: Class(0), ObjectFlags(0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-12 02:56:11 +00:00
|
|
|
ObjectFlags = GC::CurrentWhite & OF_WhiteBits;
|
|
|
|
ObjNext = GC::Root;
|
|
|
|
GC::Root = this;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-05-10 02:40:43 +00:00
|
|
|
DObject::DObject (PClass *inClass)
|
2008-03-12 02:56:11 +00:00
|
|
|
: Class(inClass), ObjectFlags(0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-12 02:56:11 +00:00
|
|
|
ObjectFlags = GC::CurrentWhite & OF_WhiteBits;
|
|
|
|
ObjNext = GC::Root;
|
|
|
|
GC::Root = this;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DObject::~DObject ()
|
|
|
|
{
|
2012-07-14 03:56:56 +00:00
|
|
|
if (!(ObjectFlags & OF_Cleanup) && !PClass::bShutdown)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-12 02:56:11 +00:00
|
|
|
DObject **probe;
|
|
|
|
PClass *type = GetClass();
|
|
|
|
|
|
|
|
if (!(ObjectFlags & OF_YesReallyDelete))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-12 02:56:11 +00:00
|
|
|
Printf ("Warning: '%s' is freed outside the GC process.\n",
|
|
|
|
type != NULL ? type->TypeName.GetChars() : "==some object==");
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-03-12 02:56:11 +00:00
|
|
|
// Find all pointers that reference this object and NULL them.
|
2008-03-12 16:27:47 +00:00
|
|
|
StaticPointerSubstitution(this, NULL);
|
2008-03-12 02:56:11 +00:00
|
|
|
|
|
|
|
// Now unlink this object from the GC list.
|
|
|
|
for (probe = &GC::Root; *probe != NULL; probe = &((*probe)->ObjNext))
|
|
|
|
{
|
|
|
|
if (*probe == this)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-12 02:56:11 +00:00
|
|
|
*probe = ObjNext;
|
|
|
|
if (&ObjNext == GC::SweepPos)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-12 02:56:11 +00:00
|
|
|
GC::SweepPos = probe;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-03-12 02:56:11 +00:00
|
|
|
break;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-12 02:56:11 +00:00
|
|
|
// If it's gray, also unlink it from the gray list.
|
|
|
|
if (this->IsGray())
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-12 02:56:11 +00:00
|
|
|
for (probe = &GC::Gray; *probe != NULL; probe = &((*probe)->GCNext))
|
|
|
|
{
|
|
|
|
if (*probe == this)
|
|
|
|
{
|
|
|
|
*probe = GCNext;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-12 02:56:11 +00:00
|
|
|
void DObject::Destroy ()
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-13 00:41:16 +00:00
|
|
|
ObjectFlags = (ObjectFlags & ~OF_Fixed) | OF_EuthanizeMe;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-03-12 02:56:11 +00:00
|
|
|
size_t DObject::PropagateMark()
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-12 02:56:11 +00:00
|
|
|
const PClass *info = GetClass();
|
- The garbage collector is now run one last time just before exiting the game.
- Removed movie volume from the sound menu and renamed some of the other
options to give the MIDI device name more room to display itself.
- Moved the midi device selection into the main sound menu.
- Added FMOD as MIDI device -1, to replace the MIDI mapper. This is still the
default device. By default, it uses exactly the same DLS instruments as the
Microsoft GS Wavetable Synth. If you have another set DLS level 1 patch set
you want to use, set the snd_midipatchfile cvar to specify where it should
load the instruments from.
- Changed the ProduceMIDI function to store its output into a TArray<BYTE>.
An overloaded version wraps around it to continue to supply file-writing
support for external Timidity++ usage.
- Added an FMOD credits banner to comply with their non-commercial license.
- Reimplemented the snd_buffersize cvar for the FMOD Ex sound system. Rather
than a time in ms, this is now the length in samples of the DSP buffer.
Also added the snd_buffercount cvar to offer complete control over the
call to FMOD::System::setDSPBufferSize(). Note that with any snd_samplerate
below about 44kHz, you will need to set snd_buffersize to avoid long
latencies.
- Reimplemented the snd_output cvar for the FMOD Ex sound system.
- Changed snd_samplerate default to 0. This now means to use the default
sample rate.
- Made snd_output, snd_output_format, snd_speakermode, snd_resampler, and
snd_hrtf available through the menu.
- Split the HRTF effect selection into its own cvar: snd_hrtf.
- Removed 96000 Hz option from the menu. It's still available through the
cvar, if desired.
- Fixed: If Windows sound init failed, retry with DirectSound. (Apparently,
WASAPI doesn't work with more than two speakers and PCM-Float output at the
same time.)
- Fixed: Area sounds only played from the front speakers once you got within
the 2D panning area.
SVN r854 (trunk)
2008-03-26 04:27:07 +00:00
|
|
|
if (!PClass::bShutdown)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
- The garbage collector is now run one last time just before exiting the game.
- Removed movie volume from the sound menu and renamed some of the other
options to give the MIDI device name more room to display itself.
- Moved the midi device selection into the main sound menu.
- Added FMOD as MIDI device -1, to replace the MIDI mapper. This is still the
default device. By default, it uses exactly the same DLS instruments as the
Microsoft GS Wavetable Synth. If you have another set DLS level 1 patch set
you want to use, set the snd_midipatchfile cvar to specify where it should
load the instruments from.
- Changed the ProduceMIDI function to store its output into a TArray<BYTE>.
An overloaded version wraps around it to continue to supply file-writing
support for external Timidity++ usage.
- Added an FMOD credits banner to comply with their non-commercial license.
- Reimplemented the snd_buffersize cvar for the FMOD Ex sound system. Rather
than a time in ms, this is now the length in samples of the DSP buffer.
Also added the snd_buffercount cvar to offer complete control over the
call to FMOD::System::setDSPBufferSize(). Note that with any snd_samplerate
below about 44kHz, you will need to set snd_buffersize to avoid long
latencies.
- Reimplemented the snd_output cvar for the FMOD Ex sound system.
- Changed snd_samplerate default to 0. This now means to use the default
sample rate.
- Made snd_output, snd_output_format, snd_speakermode, snd_resampler, and
snd_hrtf available through the menu.
- Split the HRTF effect selection into its own cvar: snd_hrtf.
- Removed 96000 Hz option from the menu. It's still available through the
cvar, if desired.
- Fixed: If Windows sound init failed, retry with DirectSound. (Apparently,
WASAPI doesn't work with more than two speakers and PCM-Float output at the
same time.)
- Fixed: Area sounds only played from the front speakers once you got within
the 2D panning area.
SVN r854 (trunk)
2008-03-26 04:27:07 +00:00
|
|
|
const size_t *offsets = info->FlatPointers;
|
|
|
|
if (offsets == NULL)
|
|
|
|
{
|
|
|
|
const_cast<PClass *>(info)->BuildFlatPointers();
|
|
|
|
offsets = info->FlatPointers;
|
|
|
|
}
|
|
|
|
while (*offsets != ~(size_t)0)
|
|
|
|
{
|
|
|
|
GC::Mark((DObject **)((BYTE *)this + *offsets));
|
|
|
|
offsets++;
|
|
|
|
}
|
2012-06-16 03:10:38 +00:00
|
|
|
return info->Size;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2012-06-16 03:10:38 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-03-13 23:00:33 +00:00
|
|
|
size_t DObject::PointerSubstitution (DObject *old, DObject *notOld)
|
2008-03-12 16:27:47 +00:00
|
|
|
{
|
|
|
|
const PClass *info = GetClass();
|
|
|
|
const size_t *offsets = info->FlatPointers;
|
2008-03-13 23:00:33 +00:00
|
|
|
size_t changed = 0;
|
2008-03-12 16:27:47 +00:00
|
|
|
if (offsets == NULL)
|
|
|
|
{
|
|
|
|
const_cast<PClass *>(info)->BuildFlatPointers();
|
|
|
|
offsets = info->FlatPointers;
|
|
|
|
}
|
|
|
|
while (*offsets != ~(size_t)0)
|
|
|
|
{
|
|
|
|
if (*(DObject **)((BYTE *)this + *offsets) == old)
|
|
|
|
{
|
|
|
|
*(DObject **)((BYTE *)this + *offsets) = notOld;
|
2008-03-13 23:00:33 +00:00
|
|
|
changed++;
|
2008-03-12 16:27:47 +00:00
|
|
|
}
|
|
|
|
offsets++;
|
|
|
|
}
|
2008-03-13 23:00:33 +00:00
|
|
|
return changed;
|
2008-03-12 16:27:47 +00:00
|
|
|
}
|
|
|
|
|
2008-03-13 23:00:33 +00:00
|
|
|
size_t DObject::StaticPointerSubstitution (DObject *old, DObject *notOld)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-12 02:56:11 +00:00
|
|
|
DObject *probe;
|
2008-03-13 23:00:33 +00:00
|
|
|
size_t changed = 0;
|
2008-03-12 02:56:11 +00:00
|
|
|
int i;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-03-12 02:56:11 +00:00
|
|
|
// Go through all objects.
|
2009-09-17 01:36:14 +00:00
|
|
|
i = 0;DObject *last=0;
|
2008-03-12 02:56:11 +00:00
|
|
|
for (probe = GC::Root; probe != NULL; probe = probe->ObjNext)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-09-17 01:36:14 +00:00
|
|
|
i++;
|
2008-03-13 23:00:33 +00:00
|
|
|
changed += probe->PointerSubstitution(old, notOld);
|
2009-09-17 01:36:14 +00:00
|
|
|
last = probe;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-03-12 02:56:11 +00:00
|
|
|
// Go through the bodyque.
|
2006-02-24 04:48:15 +00:00
|
|
|
for (i = 0; i < BODYQUESIZE; ++i)
|
|
|
|
{
|
|
|
|
if (bodyque[i] == old)
|
|
|
|
{
|
|
|
|
bodyque[i] = static_cast<AActor *>(notOld);
|
2008-03-13 23:00:33 +00:00
|
|
|
changed++;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-12 02:56:11 +00:00
|
|
|
// Go through players.
|
2006-02-24 04:48:15 +00:00
|
|
|
for (i = 0; i < MAXPLAYERS; i++)
|
|
|
|
{
|
|
|
|
if (playeringame[i])
|
2008-03-13 23:00:33 +00:00
|
|
|
changed += players[i].FixPointers (old, notOld);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
- Fixed compilation with mingw again.
- Added multiple-choice sound sequences. These overcome one of the major
deficiences of the Hexen-inherited SNDSEQ system while still being Hexen
compatible: Custom door sounds can now use different opening and closing
sequences, for both normal and blazing speeds.
- Added a serializer for TArray.
- Added a countof macro to doomtype.h. See the1's blog to find out why
it's implemented the way it is.
<http://blogs.msdn.com/the1/articles/210011.aspx>
- Added a new method to FRandom for getting random numbers larger than 255,
which lets me:
- Fixed: SNDSEQ delayrand commands could delay for no more than 255 tics.
- Fixed: If you're going to have sector_t.SoundTarget, then they need to
be included in the pointer cleanup scans.
- Ported back newer name code from 2.1.
- Fixed: Using -warp with only one parameter in Doom and Heretic to
select a map on episode 1 no longer worked.
- New: Loading a multiplayer save now restores the players based on
their names rather than on their connection order. Using connection
order was sensible when -net was the only way to start a network game,
but with -host/-join, it's not so nice. Also, if there aren't enough
players in the save, then the extra players will be spawned normally,
so you can continue a saved game with more players than you started it
with.
- Added some new SNDSEQ commands to make it possible to define Heretic's
ambient sounds in SNDSEQ: volumerel, volumerand, slot, randomsequence,
delayonce, and restart. With these, it is basically possible to obsolete
all of the $ambient SNDINFO commands.
- Fixed: Sound sequences would only execute one command each time they were
ticked.
- Fixed: No bounds checking was done on the volume sound sequences played at.
- Fixed: The tic parameter to playloop was useless and caused it to
act like a redundant playrepeat. I have removed all the logic that
caused playloop to play repeating sounds, and now it acts like an
infinite sequence of play/delay commands until the sequence is
stopped.
- Fixed: Sound sequences were ticked every frame, not every tic, so all
the delay commands were timed incorrectly and varied depending on your
framerate. Since this is useful for restarting looping sounds that got
cut off, I have not changed this. Instead, the delay commands now
record the tic when execution should resume, not the number of tics
left to delay.
SVN r57 (trunk)
2006-04-21 01:22:55 +00:00
|
|
|
|
2008-03-12 02:56:11 +00:00
|
|
|
// Go through sectors.
|
2006-06-15 03:31:19 +00:00
|
|
|
if (sectors != NULL)
|
- Fixed compilation with mingw again.
- Added multiple-choice sound sequences. These overcome one of the major
deficiences of the Hexen-inherited SNDSEQ system while still being Hexen
compatible: Custom door sounds can now use different opening and closing
sequences, for both normal and blazing speeds.
- Added a serializer for TArray.
- Added a countof macro to doomtype.h. See the1's blog to find out why
it's implemented the way it is.
<http://blogs.msdn.com/the1/articles/210011.aspx>
- Added a new method to FRandom for getting random numbers larger than 255,
which lets me:
- Fixed: SNDSEQ delayrand commands could delay for no more than 255 tics.
- Fixed: If you're going to have sector_t.SoundTarget, then they need to
be included in the pointer cleanup scans.
- Ported back newer name code from 2.1.
- Fixed: Using -warp with only one parameter in Doom and Heretic to
select a map on episode 1 no longer worked.
- New: Loading a multiplayer save now restores the players based on
their names rather than on their connection order. Using connection
order was sensible when -net was the only way to start a network game,
but with -host/-join, it's not so nice. Also, if there aren't enough
players in the save, then the extra players will be spawned normally,
so you can continue a saved game with more players than you started it
with.
- Added some new SNDSEQ commands to make it possible to define Heretic's
ambient sounds in SNDSEQ: volumerel, volumerand, slot, randomsequence,
delayonce, and restart. With these, it is basically possible to obsolete
all of the $ambient SNDINFO commands.
- Fixed: Sound sequences would only execute one command each time they were
ticked.
- Fixed: No bounds checking was done on the volume sound sequences played at.
- Fixed: The tic parameter to playloop was useless and caused it to
act like a redundant playrepeat. I have removed all the logic that
caused playloop to play repeating sounds, and now it acts like an
infinite sequence of play/delay commands until the sequence is
stopped.
- Fixed: Sound sequences were ticked every frame, not every tic, so all
the delay commands were timed incorrectly and varied depending on your
framerate. Since this is useful for restarting looping sounds that got
cut off, I have not changed this. Instead, the delay commands now
record the tic when execution should resume, not the number of tics
left to delay.
SVN r57 (trunk)
2006-04-21 01:22:55 +00:00
|
|
|
{
|
2008-03-12 02:56:11 +00:00
|
|
|
for (i = 0; i < numsectors; ++i)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-12 02:56:11 +00:00
|
|
|
#define SECTOR_CHECK(f,t) \
|
2008-03-28 00:38:17 +00:00
|
|
|
if (sectors[i].f.p == static_cast<t *>(old)) { sectors[i].f = static_cast<t *>(notOld); changed++; }
|
2008-03-12 02:56:11 +00:00
|
|
|
SECTOR_CHECK( SoundTarget, AActor );
|
2016-01-12 20:34:41 +00:00
|
|
|
SECTOR_CHECK( SkyBoxes[sector_t::ceiling], ASkyViewpoint );
|
|
|
|
SECTOR_CHECK( SkyBoxes[sector_t::floor], ASkyViewpoint );
|
2008-03-12 02:56:11 +00:00
|
|
|
SECTOR_CHECK( SecActTarget, ASectorAction );
|
|
|
|
SECTOR_CHECK( floordata, DSectorEffect );
|
|
|
|
SECTOR_CHECK( ceilingdata, DSectorEffect );
|
|
|
|
SECTOR_CHECK( lightingdata, DSectorEffect );
|
|
|
|
#undef SECTOR_CHECK
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2008-03-28 00:38:17 +00:00
|
|
|
|
|
|
|
// Go through bot stuff.
|
|
|
|
if (bglobal.firstthing.p == (AActor *)old) bglobal.firstthing = (AActor *)notOld, ++changed;
|
|
|
|
if (bglobal.body1.p == (AActor *)old) bglobal.body1 = (AActor *)notOld, ++changed;
|
|
|
|
if (bglobal.body2.p == (AActor *)old) bglobal.body2 = (AActor *)notOld, ++changed;
|
|
|
|
|
2008-03-13 23:00:33 +00:00
|
|
|
return changed;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2009-10-25 02:19:51 +00:00
|
|
|
void DObject::SerializeUserVars(FArchive &arc)
|
|
|
|
{
|
|
|
|
PSymbolTable *symt;
|
|
|
|
FName varname;
|
|
|
|
DWORD count, j;
|
2011-03-29 05:20:33 +00:00
|
|
|
int *varloc = NULL;
|
2009-10-25 02:19:51 +00:00
|
|
|
|
|
|
|
symt = &GetClass()->Symbols;
|
|
|
|
|
|
|
|
if (arc.IsStoring())
|
|
|
|
{
|
|
|
|
// Write all user variables.
|
|
|
|
for (; symt != NULL; symt = symt->ParentSymbolTable)
|
|
|
|
{
|
2010-03-30 04:11:16 +00:00
|
|
|
PSymbolTable::MapType::Iterator it(symt->Symbols);
|
|
|
|
PSymbolTable::MapType::Pair *pair;
|
|
|
|
|
|
|
|
while (it.NextPair(pair))
|
2009-10-25 02:19:51 +00:00
|
|
|
{
|
2013-08-24 03:02:51 +00:00
|
|
|
PField *var = dyn_cast<PField>(pair->Value);
|
|
|
|
if (var != NULL && !(var->Flags & VARF_Native))
|
2009-10-25 02:19:51 +00:00
|
|
|
{
|
2013-08-24 03:02:51 +00:00
|
|
|
PType *type = var->Type;
|
|
|
|
PArray *arraytype = dyn_cast<PArray>(type);
|
|
|
|
if (arraytype == NULL)
|
|
|
|
{
|
|
|
|
count = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
count = arraytype->ElementCount;
|
|
|
|
type = arraytype->ElementType;
|
|
|
|
}
|
|
|
|
assert(type == TypeSInt32);
|
|
|
|
varloc = (int *)(reinterpret_cast<BYTE *>(this) + var->Offset);
|
2010-04-03 02:06:51 +00:00
|
|
|
|
|
|
|
arc << var->SymbolName;
|
|
|
|
arc.WriteCount(count);
|
|
|
|
for (j = 0; j < count; ++j)
|
2009-10-25 02:19:51 +00:00
|
|
|
{
|
2010-04-03 02:06:51 +00:00
|
|
|
arc << varloc[j];
|
2009-10-25 02:19:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Write terminator.
|
|
|
|
varname = NAME_None;
|
|
|
|
arc << varname;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Read user variables until 'None' is encountered.
|
|
|
|
arc << varname;
|
|
|
|
while (varname != NAME_None)
|
|
|
|
{
|
2013-08-24 03:02:51 +00:00
|
|
|
PField *var = dyn_cast<PField>(symt->FindSymbol(varname, true));
|
2009-10-25 02:19:51 +00:00
|
|
|
DWORD wanted = 0;
|
|
|
|
|
2013-08-24 03:02:51 +00:00
|
|
|
if (var != NULL && !(var->Flags & VARF_Native))
|
2009-10-25 02:19:51 +00:00
|
|
|
{
|
2013-08-24 03:02:51 +00:00
|
|
|
PType *type = var->Type;
|
|
|
|
PArray *arraytype = dyn_cast<PArray>(type);
|
|
|
|
if (arraytype != NULL)
|
|
|
|
{
|
|
|
|
wanted = arraytype->ElementCount;
|
|
|
|
type = arraytype->ElementType;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wanted = 1;
|
|
|
|
}
|
|
|
|
assert(type == TypeSInt32);
|
|
|
|
varloc = (int *)(reinterpret_cast<BYTE *>(this) + var->Offset);
|
2009-10-25 02:19:51 +00:00
|
|
|
}
|
|
|
|
count = arc.ReadCount();
|
|
|
|
for (j = 0; j < MIN(wanted, count); ++j)
|
|
|
|
{
|
|
|
|
arc << varloc[j];
|
|
|
|
}
|
|
|
|
if (wanted < count)
|
|
|
|
{
|
|
|
|
// Ignore remaining values from archive.
|
|
|
|
for (; j < count; ++j)
|
|
|
|
{
|
|
|
|
int foo;
|
|
|
|
arc << foo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
arc << varname;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
void DObject::Serialize (FArchive &arc)
|
|
|
|
{
|
|
|
|
ObjectFlags |= OF_SerialSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DObject::CheckIfSerialized () const
|
|
|
|
{
|
|
|
|
if (!(ObjectFlags & OF_SerialSuccess))
|
|
|
|
{
|
|
|
|
I_Error (
|
|
|
|
"BUG: %s::Serialize\n"
|
|
|
|
"(or one of its superclasses) needs to call\n"
|
|
|
|
"Super::Serialize\n",
|
2006-05-10 02:40:43 +00:00
|
|
|
StaticType()->TypeName.GetChars());
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2008-08-10 03:56:53 +00:00
|
|
|
|