2008-03-19 09:53:23 +00:00
|
|
|
/*
|
|
|
|
** dobjtype.cpp
|
|
|
|
** Implements the type information class
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
** Copyright 1998-2008 Randy Heit
|
|
|
|
** 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.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
2006-05-10 02:40:43 +00:00
|
|
|
#include "dobject.h"
|
|
|
|
#include "i_system.h"
|
|
|
|
#include "actor.h"
|
2006-09-27 04:56:18 +00:00
|
|
|
#include "templates.h"
|
2008-09-14 23:54:38 +00:00
|
|
|
#include "autosegs.h"
|
2006-05-10 02:40:43 +00:00
|
|
|
|
|
|
|
TArray<PClass *> PClass::m_RuntimeActors;
|
|
|
|
TArray<PClass *> PClass::m_Types;
|
|
|
|
PClass *PClass::TypeHash[PClass::HASH_SIZE];
|
- 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
|
|
|
bool PClass::bShutdown;
|
2006-05-10 02:40:43 +00:00
|
|
|
|
2008-04-29 02:43:42 +00:00
|
|
|
// A harmless non-NULL FlatPointer for classes without pointers.
|
|
|
|
static const size_t TheEnd = ~(size_t)0;
|
2006-05-10 02:40:43 +00:00
|
|
|
|
2006-09-27 04:56:18 +00:00
|
|
|
static int STACK_ARGS cregcmp (const void *a, const void *b)
|
|
|
|
{
|
|
|
|
// VC++ introduces NULLs in the sequence. GCC seems to work as expected and not do it.
|
|
|
|
const ClassReg *class1 = *(const ClassReg **)a;
|
|
|
|
const ClassReg *class2 = *(const ClassReg **)b;
|
|
|
|
if (class1 == NULL) return 1;
|
|
|
|
if (class2 == NULL) return -1;
|
|
|
|
return strcmp (class1->Name, class2->Name);
|
|
|
|
}
|
|
|
|
|
2006-05-12 03:14:40 +00:00
|
|
|
void PClass::StaticInit ()
|
2006-05-10 02:40:43 +00:00
|
|
|
{
|
2006-05-12 03:14:40 +00:00
|
|
|
atterm (StaticShutdown);
|
|
|
|
|
2006-09-27 04:56:18 +00:00
|
|
|
// Sort classes by name to remove dependance on how the compiler ordered them.
|
|
|
|
REGINFO *head = &CRegHead;
|
|
|
|
REGINFO *tail = &CRegTail;
|
|
|
|
|
|
|
|
// MinGW's linker is linking the object files backwards for me now...
|
|
|
|
if (head > tail)
|
|
|
|
{
|
|
|
|
swap (head, tail);
|
|
|
|
}
|
|
|
|
qsort (head + 1, tail - head - 1, sizeof(REGINFO), cregcmp);
|
|
|
|
|
2009-08-02 03:38:57 +00:00
|
|
|
FAutoSegIterator probe(CRegHead, CRegTail);
|
2006-05-12 03:14:40 +00:00
|
|
|
|
2009-08-02 03:38:57 +00:00
|
|
|
while (*++probe != NULL)
|
2006-05-10 02:40:43 +00:00
|
|
|
{
|
2009-08-02 03:38:57 +00:00
|
|
|
((ClassReg *)*probe)->RegisterClass ();
|
2006-05-12 03:14:40 +00:00
|
|
|
}
|
|
|
|
}
|
2006-05-10 02:40:43 +00:00
|
|
|
|
2006-05-12 03:14:40 +00:00
|
|
|
void PClass::StaticShutdown ()
|
|
|
|
{
|
|
|
|
TArray<size_t *> uniqueFPs(64);
|
|
|
|
unsigned int i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < PClass::m_Types.Size(); ++i)
|
|
|
|
{
|
|
|
|
PClass *type = PClass::m_Types[i];
|
|
|
|
PClass::m_Types[i] = NULL;
|
|
|
|
if (type->FlatPointers != &TheEnd && type->FlatPointers != type->Pointers)
|
2006-05-10 02:40:43 +00:00
|
|
|
{
|
2006-05-12 03:14:40 +00:00
|
|
|
// FlatPointers are shared by many classes, so we must check for
|
|
|
|
// duplicates and only delete those that are unique.
|
|
|
|
for (j = 0; j < uniqueFPs.Size(); ++j)
|
2006-05-10 02:40:43 +00:00
|
|
|
{
|
2006-05-12 03:14:40 +00:00
|
|
|
if (type->FlatPointers == uniqueFPs[j])
|
2006-05-10 02:40:43 +00:00
|
|
|
{
|
2006-05-12 03:14:40 +00:00
|
|
|
break;
|
2006-05-10 02:40:43 +00:00
|
|
|
}
|
|
|
|
}
|
2006-05-12 03:14:40 +00:00
|
|
|
if (j == uniqueFPs.Size())
|
|
|
|
{
|
|
|
|
uniqueFPs.Push(const_cast<size_t *>(type->FlatPointers));
|
|
|
|
}
|
2006-05-10 02:40:43 +00:00
|
|
|
}
|
2006-05-12 03:14:40 +00:00
|
|
|
// For runtime classes, this call will also delete the PClass.
|
|
|
|
PClass::StaticFreeData (type);
|
|
|
|
}
|
|
|
|
for (i = 0; i < uniqueFPs.Size(); ++i)
|
|
|
|
{
|
|
|
|
delete[] uniqueFPs[i];
|
2006-05-10 02:40:43 +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
|
|
|
bShutdown = true;
|
2006-05-12 03:14:40 +00:00
|
|
|
}
|
2006-05-10 02:40:43 +00:00
|
|
|
|
|
|
|
void PClass::StaticFreeData (PClass *type)
|
|
|
|
{
|
|
|
|
if (type->Defaults != NULL)
|
|
|
|
{
|
|
|
|
delete[] type->Defaults;
|
|
|
|
type->Defaults = NULL;
|
|
|
|
}
|
2006-10-31 14:53:21 +00:00
|
|
|
type->FreeStateList ();
|
|
|
|
|
2008-08-12 09:57:59 +00:00
|
|
|
if (type->ActorInfo != NULL)
|
2006-05-10 02:40:43 +00:00
|
|
|
{
|
2008-08-12 09:57:59 +00:00
|
|
|
if (type->ActorInfo->OwnedStates != NULL)
|
2006-05-10 02:40:43 +00:00
|
|
|
{
|
2008-08-12 09:57:59 +00:00
|
|
|
delete[] type->ActorInfo->OwnedStates;
|
|
|
|
type->ActorInfo->OwnedStates = NULL;
|
2006-05-10 02:40:43 +00:00
|
|
|
}
|
2008-08-12 09:57:59 +00:00
|
|
|
if (type->ActorInfo->DamageFactors != NULL)
|
2008-07-21 17:03:30 +00:00
|
|
|
{
|
2008-08-12 09:57:59 +00:00
|
|
|
delete type->ActorInfo->DamageFactors;
|
|
|
|
type->ActorInfo->DamageFactors = NULL;
|
2008-07-21 17:03:30 +00:00
|
|
|
}
|
2008-08-12 09:57:59 +00:00
|
|
|
if (type->ActorInfo->PainChances != NULL)
|
2008-07-21 17:03:30 +00:00
|
|
|
{
|
2008-08-12 09:57:59 +00:00
|
|
|
delete type->ActorInfo->PainChances;
|
|
|
|
type->ActorInfo->PainChances = NULL;
|
2008-07-21 17:03:30 +00:00
|
|
|
}
|
2008-08-12 09:57:59 +00:00
|
|
|
delete type->ActorInfo;
|
|
|
|
type->ActorInfo = NULL;
|
|
|
|
}
|
|
|
|
if (type->bRuntimeClass)
|
|
|
|
{
|
|
|
|
delete type;
|
2006-05-10 02:40:43 +00:00
|
|
|
}
|
2008-06-06 02:17:28 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
type->Symbols.ReleaseSymbols();
|
|
|
|
}
|
2006-05-10 02:40:43 +00:00
|
|
|
}
|
|
|
|
|
2009-08-02 03:38:57 +00:00
|
|
|
void ClassReg::RegisterClass () const
|
2006-05-10 02:40:43 +00:00
|
|
|
{
|
|
|
|
assert (MyClass != NULL);
|
|
|
|
|
|
|
|
// Add type to list
|
|
|
|
MyClass->ClassIndex = PClass::m_Types.Push (MyClass);
|
|
|
|
|
|
|
|
MyClass->TypeName = FName(Name+1);
|
|
|
|
MyClass->ParentClass = ParentType;
|
|
|
|
MyClass->Size = SizeOf;
|
|
|
|
MyClass->Pointers = Pointers;
|
|
|
|
MyClass->ConstructNative = ConstructNative;
|
|
|
|
MyClass->InsertIntoHash ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PClass::InsertIntoHash ()
|
|
|
|
{
|
|
|
|
// Add class to hash table. Classes are inserted into each bucket
|
|
|
|
// in ascending order by name index.
|
|
|
|
unsigned int bucket = TypeName % HASH_SIZE;
|
|
|
|
PClass **hashpos = &TypeHash[bucket];
|
|
|
|
while (*hashpos != NULL)
|
|
|
|
{
|
|
|
|
int lexx = int(TypeName) - int((*hashpos)->TypeName);
|
|
|
|
|
|
|
|
if (lexx > 0)
|
|
|
|
{ // This type should come later in the chain
|
|
|
|
hashpos = &((*hashpos)->HashNext);
|
|
|
|
}
|
|
|
|
else if (lexx == 0)
|
|
|
|
{ // This type has already been inserted
|
2008-04-12 15:31:18 +00:00
|
|
|
// ... but there is no need whatsoever to make it a fatal error!
|
|
|
|
Printf ("Tried to register class '%s' more than once.\n", TypeName.GetChars());
|
|
|
|
break;
|
2006-05-10 02:40:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // Type comes right here
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
HashNext = *hashpos;
|
|
|
|
*hashpos = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find a type, passed the name as a name
|
|
|
|
const PClass *PClass::FindClass (FName zaname)
|
|
|
|
{
|
- Added the ACS commands
ReplaceTextures (str old_texture, str new_texture, optional bool not_lower,
optional bool not_mid, optional bool not_upper, optional bool not_floor,
optional bool not_ceiling); and
SectorDamage (int tag, int amount, str type, bool players_only, bool in_air,
str protection_item, bool subclasses_okay);
- Added the vid_nowidescreen cvar to disable widescreen aspect ratio
correction. When this is enabled, the only display ratio available is 4:3
(and 5:4 if vid_tft is set).
- Added support for setting an actor's damage property to an expression
through decorate. Just enclose it within parentheses, and the expression
will be evaluated exactly as-is without the normal Doom damage calculation.
So if you want something that does exactly 6 damage, use a "Damage (6)"
property. To deal normal Doom missile damage, you can use
"Damage (random(1,8)*6)" instead of "Damage 6".
- Moved InvFirst and InvSel into APlayerPawn so that they can be consistantly
maintained by ObtainInventory.
SVN r288 (trunk)
2006-08-12 02:30:57 +00:00
|
|
|
if (zaname == NAME_None)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-05-10 02:40:43 +00:00
|
|
|
PClass *cls = TypeHash[zaname % HASH_SIZE];
|
|
|
|
|
|
|
|
while (cls != 0)
|
|
|
|
{
|
|
|
|
int lexx = int(zaname) - int(cls->TypeName);
|
|
|
|
if (lexx > 0)
|
|
|
|
{
|
|
|
|
cls = cls->HashNext;
|
|
|
|
}
|
|
|
|
else if (lexx == 0)
|
|
|
|
{
|
2008-12-29 23:03:38 +00:00
|
|
|
return cls->Size<0? NULL : cls;
|
2006-05-10 02:40:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new object that this class represents
|
|
|
|
DObject *PClass::CreateNew () const
|
|
|
|
{
|
|
|
|
BYTE *mem = (BYTE *)M_Malloc (Size);
|
2006-07-11 04:48:10 +00:00
|
|
|
assert (mem != NULL);
|
2006-05-10 02:40:43 +00:00
|
|
|
|
|
|
|
// Set this object's defaults before constructing it.
|
2009-05-11 15:15:06 +00:00
|
|
|
if (Defaults != NULL)
|
2006-05-10 16:43:46 +00:00
|
|
|
memcpy (mem, Defaults, Size);
|
|
|
|
else
|
|
|
|
memset (mem, 0, Size);
|
2006-05-10 02:40:43 +00:00
|
|
|
|
|
|
|
ConstructNative (mem);
|
|
|
|
((DObject *)mem)->SetClass (const_cast<PClass *>(this));
|
|
|
|
return (DObject *)mem;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a new class based on an existing class
|
|
|
|
PClass *PClass::CreateDerivedClass (FName name, unsigned int size)
|
|
|
|
{
|
|
|
|
assert (size >= Size);
|
2008-12-29 23:03:38 +00:00
|
|
|
PClass *type;
|
|
|
|
bool notnew;
|
2006-05-10 02:40:43 +00:00
|
|
|
|
2008-12-29 23:03:38 +00:00
|
|
|
const PClass *existclass = FindClass(name);
|
|
|
|
|
|
|
|
// This is a placeholder so fill it in
|
2009-01-28 05:29:41 +00:00
|
|
|
if (existclass != NULL && existclass->Size == (unsigned)-1)
|
2008-12-29 23:03:38 +00:00
|
|
|
{
|
|
|
|
type = const_cast<PClass*>(existclass);
|
|
|
|
if (!IsDescendantOf(type->ParentClass))
|
|
|
|
{
|
|
|
|
I_Error("%s must inherit from %s but doesn't.", name.GetChars(), type->ParentClass->TypeName.GetChars());
|
|
|
|
}
|
2008-12-30 14:24:55 +00:00
|
|
|
DPrintf("Defining placeholder class %s\n", name.GetChars());
|
2008-12-29 23:03:38 +00:00
|
|
|
notnew = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
type = new PClass;
|
|
|
|
notnew = false;
|
|
|
|
}
|
2006-05-10 02:40:43 +00:00
|
|
|
|
|
|
|
type->TypeName = name;
|
|
|
|
type->ParentClass = this;
|
|
|
|
type->Size = size;
|
|
|
|
type->Pointers = NULL;
|
|
|
|
type->ConstructNative = ConstructNative;
|
2009-05-11 15:15:06 +00:00
|
|
|
if (!notnew)
|
|
|
|
{
|
|
|
|
type->ClassIndex = m_Types.Push (type);
|
|
|
|
}
|
2006-05-10 02:40:43 +00:00
|
|
|
type->Meta = Meta;
|
2009-05-11 15:15:06 +00:00
|
|
|
|
|
|
|
// Set up default instance of the new class.
|
2006-05-10 02:40:43 +00:00
|
|
|
type->Defaults = new BYTE[size];
|
|
|
|
memcpy (type->Defaults, Defaults, Size);
|
|
|
|
if (size > Size)
|
|
|
|
{
|
|
|
|
memset (type->Defaults + Size, 0, size - Size);
|
|
|
|
}
|
2009-05-11 15:15:06 +00:00
|
|
|
|
2006-05-10 02:40:43 +00:00
|
|
|
type->FlatPointers = NULL;
|
|
|
|
type->bRuntimeClass = true;
|
2006-07-13 02:08:39 +00:00
|
|
|
type->ActorInfo = NULL;
|
2006-11-29 04:51:16 +00:00
|
|
|
type->Symbols.SetParentTable (&this->Symbols);
|
2008-12-29 23:03:38 +00:00
|
|
|
if (!notnew) type->InsertIntoHash();
|
2006-05-10 02:40:43 +00:00
|
|
|
|
|
|
|
// If this class has an actor info, then any classes derived from it
|
|
|
|
// also need an actor info.
|
|
|
|
if (this->ActorInfo != NULL)
|
|
|
|
{
|
|
|
|
FActorInfo *info = type->ActorInfo = new FActorInfo;
|
|
|
|
info->Class = type;
|
|
|
|
info->GameFilter = GAME_Any;
|
|
|
|
info->SpawnID = 0;
|
|
|
|
info->DoomEdNum = -1;
|
|
|
|
info->OwnedStates = NULL;
|
|
|
|
info->NumOwnedStates = 0;
|
2006-07-08 02:17:35 +00:00
|
|
|
info->Replacement = NULL;
|
2006-07-18 23:09:11 +00:00
|
|
|
info->Replacee = NULL;
|
Note: I have not tried compiling these recent changes under Linux. I wouldn't
be surprised if it doesn't work.
- Reorganized the network startup loops so now they are event driven. There is
a single function that gets called to drive it, and it uses callbacks to
perform the different stages of the synchronization. This lets me have a nice,
responsive abort button instead of the previous unannounced hit-escape-to-
abort behavior, and I think the rearranged code is slightly easier to
understand too.
- Increased the number of bytes for version info during D_ArbitrateNetStart(),
in preparation for the day when NETGAMEVERSION requires more than one byte.
- I noticed an issue with Vista RC1 and the new fatal error setup. Even after
releasing a DirectDraw or Direct3D interface, the DWM can still use the
last image drawn using them when it composites the window. It doesn't always
do it but it does often enough that it is a real problem. At this point, I
don't know if it's a problem with the release version of Vista or not.
After messing around, I discovered the problem was caused by ~Win32Video()
hiding the window and then having it immediately shown soon after. The DWM
kept an image of the window to do the transition effect with, and then when
it didn't get a chance to do the transition, it didn't properly forget about
its saved image and kept plastering it on top of everything else
underneath.
- Added a network synchronization panel to the window during netgame startup.
- Fixed: PClass::CreateDerivedClass() must initialize StateList to NULL.
Otherwise, classic DECORATE definitions generate a big, fat crash.
- Resurrected the R_Init progress bar, now as a standard Windows control.
- Removed the sound failure dialog. The FMOD setup already defaulted to no
sound if initialization failed, so this only applies when snd_output is set
to "alternate" which now also falls back to no sound. In addition, it wasn't
working right, and I didn't feel like fixing it for the probably 0% of users
it affected.
- Fixed: The edit control used for logging output added text in reverse order
on Win9x.
- Went back to the roots and made graphics initialization one of the last
things to happen during setup. Now the startup text is visible again. More
importantly, the main window is no longer created invisible, which seems
to cause trouble with it not always appearing in the taskbar. The fatal
error dialog is now also embedded in the main window instead of being a
separate modal dialog, so you can play with the log window to see any
problems that might be reported there.
Rather than completely restoring the original startup order, I tried to
keep things as close to the way they were with early graphics startup. In
particular, V_Init() now creates a dummy screen so that things that need
screen dimensions can get them. It gets replaced by the real screen later
in I_InitGraphics(). Will need to check this under Linux to make sure it
didn't cause any problems there.
- Removed the following stubs that just called functions in Video:
- I_StartModeIterator()
- I_NextMode()
- I_DisplayType()
I_FullscreenChanged() was also removed, and a new fullscreen parameter
was added to IVideo::StartModeIterator(), since that's all it controlled.
- Renamed I_InitHardware() back to I_InitGraphics(), since that's all it's
initialized post-1.22.
SVN r416 (trunk)
2006-12-19 04:09:10 +00:00
|
|
|
info->StateList = NULL;
|
2007-04-28 22:03:18 +00:00
|
|
|
info->DamageFactors = NULL;
|
2007-05-26 10:50:32 +00:00
|
|
|
info->PainChances = NULL;
|
2006-05-10 02:40:43 +00:00
|
|
|
m_RuntimeActors.Push (type);
|
|
|
|
}
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2008-12-29 23:03:38 +00:00
|
|
|
// Like FindClass but creates a placeholder if no class
|
|
|
|
// is found. CreateDerivedClass will automatcally fill in
|
|
|
|
// the placeholder when the actual class is defined.
|
|
|
|
const PClass *PClass::FindClassTentative (FName name)
|
|
|
|
{
|
|
|
|
if (name == NAME_None)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
PClass *cls = TypeHash[name % HASH_SIZE];
|
|
|
|
|
|
|
|
while (cls != 0)
|
|
|
|
{
|
|
|
|
int lexx = int(name) - int(cls->TypeName);
|
|
|
|
if (lexx > 0)
|
|
|
|
{
|
|
|
|
cls = cls->HashNext;
|
|
|
|
}
|
|
|
|
else if (lexx == 0)
|
|
|
|
{
|
|
|
|
return cls;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PClass *type = new PClass;
|
2008-12-30 14:24:55 +00:00
|
|
|
DPrintf("Creating placeholder class %s : %s\n", name.GetChars(), TypeName.GetChars());
|
2008-12-29 23:03:38 +00:00
|
|
|
|
|
|
|
type->TypeName = name;
|
|
|
|
type->ParentClass = this;
|
|
|
|
type->Size = -1;
|
|
|
|
type->Pointers = NULL;
|
|
|
|
type->ConstructNative = NULL;
|
|
|
|
type->ClassIndex = m_Types.Push (type);
|
|
|
|
type->Defaults = NULL;
|
|
|
|
type->FlatPointers = NULL;
|
|
|
|
type->bRuntimeClass = true;
|
|
|
|
type->ActorInfo = NULL;
|
|
|
|
type->InsertIntoHash();
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2008-07-21 17:03:30 +00:00
|
|
|
// This is used by DECORATE to assign ActorInfos to internal classes
|
|
|
|
void PClass::InitializeActorInfo ()
|
|
|
|
{
|
|
|
|
Symbols.SetParentTable (&ParentClass->Symbols);
|
|
|
|
Defaults = new BYTE[Size];
|
|
|
|
if (ParentClass->Defaults != NULL)
|
|
|
|
{
|
2008-09-21 18:02:38 +00:00
|
|
|
memcpy (Defaults, ParentClass->Defaults, ParentClass->Size);
|
2008-07-21 17:03:30 +00:00
|
|
|
if (Size > ParentClass->Size)
|
|
|
|
{
|
|
|
|
memset (Defaults + ParentClass->Size, 0, Size - ParentClass->Size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
memset (Defaults, 0, Size);
|
|
|
|
}
|
|
|
|
|
|
|
|
FActorInfo *info = ActorInfo = new FActorInfo;
|
|
|
|
info->Class = this;
|
|
|
|
info->GameFilter = GAME_Any;
|
|
|
|
info->SpawnID = 0;
|
|
|
|
info->DoomEdNum = -1;
|
|
|
|
info->OwnedStates = NULL;
|
|
|
|
info->NumOwnedStates = 0;
|
|
|
|
info->Replacement = NULL;
|
|
|
|
info->Replacee = NULL;
|
|
|
|
info->StateList = NULL;
|
|
|
|
info->DamageFactors = NULL;
|
|
|
|
info->PainChances = NULL;
|
|
|
|
m_RuntimeActors.Push (this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-10 02:40:43 +00:00
|
|
|
// Create the FlatPointers array, if it doesn't exist already.
|
|
|
|
// It comprises all the Pointers from superclasses plus this class's own Pointers.
|
|
|
|
// If this class does not define any new Pointers, then FlatPointers will be set
|
|
|
|
// to the same array as the super class's.
|
|
|
|
void PClass::BuildFlatPointers ()
|
|
|
|
{
|
|
|
|
if (FlatPointers != NULL)
|
|
|
|
{ // Already built: Do nothing.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (ParentClass == NULL)
|
|
|
|
{ // No parent: FlatPointers is the same as Pointers.
|
|
|
|
if (Pointers == NULL)
|
|
|
|
{ // No pointers: Make FlatPointers a harmless non-NULL.
|
|
|
|
FlatPointers = &TheEnd;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FlatPointers = Pointers;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ParentClass->BuildFlatPointers ();
|
|
|
|
if (Pointers == NULL)
|
|
|
|
{ // No new pointers: Just use the same FlatPointers as the parent.
|
|
|
|
FlatPointers = ParentClass->FlatPointers;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // New pointers: Create a new FlatPointers array and add them.
|
|
|
|
int numPointers, numSuperPointers;
|
|
|
|
|
|
|
|
// Count pointers defined by this class.
|
|
|
|
for (numPointers = 0; Pointers[numPointers] != ~(size_t)0; numPointers++)
|
|
|
|
{ }
|
|
|
|
// Count pointers defined by superclasses.
|
|
|
|
for (numSuperPointers = 0; ParentClass->FlatPointers[numSuperPointers] != ~(size_t)0; numSuperPointers++)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
// Concatenate them into a new array
|
|
|
|
size_t *flat = new size_t[numPointers + numSuperPointers + 1];
|
|
|
|
if (numSuperPointers > 0)
|
|
|
|
{
|
|
|
|
memcpy (flat, ParentClass->FlatPointers, sizeof(size_t)*numSuperPointers);
|
|
|
|
}
|
|
|
|
memcpy (flat + numSuperPointers, Pointers, sizeof(size_t)*(numPointers+1));
|
|
|
|
FlatPointers = flat;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-10-31 14:53:21 +00:00
|
|
|
|
|
|
|
void PClass::FreeStateList ()
|
|
|
|
{
|
|
|
|
if (ActorInfo != NULL && ActorInfo->StateList != NULL)
|
|
|
|
{
|
|
|
|
ActorInfo->StateList->Destroy();
|
2008-02-17 02:40:03 +00:00
|
|
|
M_Free (ActorInfo->StateList);
|
2006-10-31 14:53:21 +00:00
|
|
|
ActorInfo->StateList = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-06 22:59:24 +00:00
|
|
|
const PClass *PClass::NativeClass() const
|
|
|
|
{
|
|
|
|
const PClass *cls = this;
|
|
|
|
|
2008-08-12 09:57:59 +00:00
|
|
|
while (cls && cls->bRuntimeClass)
|
2008-08-06 22:59:24 +00:00
|
|
|
cls = cls->ParentClass;
|
|
|
|
|
|
|
|
return cls;
|
|
|
|
}
|
|
|
|
|
2006-11-29 04:51:16 +00:00
|
|
|
// Symbol tables ------------------------------------------------------------
|
|
|
|
|
2008-06-06 02:17:28 +00:00
|
|
|
PSymbol::~PSymbol()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-11-29 04:51:16 +00:00
|
|
|
PSymbolTable::~PSymbolTable ()
|
2008-06-06 02:17:28 +00:00
|
|
|
{
|
|
|
|
ReleaseSymbols();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PSymbolTable::ReleaseSymbols()
|
2006-11-29 04:51:16 +00:00
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < Symbols.Size(); ++i)
|
|
|
|
{
|
|
|
|
delete Symbols[i];
|
|
|
|
}
|
2008-06-06 02:17:28 +00:00
|
|
|
Symbols.Clear();
|
2006-11-29 04:51:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PSymbolTable::SetParentTable (PSymbolTable *parent)
|
|
|
|
{
|
|
|
|
ParentSymbolTable = parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
PSymbol *PSymbolTable::FindSymbol (FName symname, bool searchparents) const
|
|
|
|
{
|
|
|
|
int min, max;
|
|
|
|
|
|
|
|
min = 0;
|
|
|
|
max = (int)Symbols.Size() - 1;
|
|
|
|
|
|
|
|
while (min <= max)
|
|
|
|
{
|
|
|
|
unsigned int mid = (min + max) / 2;
|
|
|
|
PSymbol *sym = Symbols[mid];
|
|
|
|
|
|
|
|
if (sym->SymbolName == symname)
|
|
|
|
{
|
|
|
|
return sym;
|
|
|
|
}
|
|
|
|
else if (sym->SymbolName < symname)
|
|
|
|
{
|
|
|
|
min = mid + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
max = mid - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (searchparents && ParentSymbolTable != NULL)
|
|
|
|
{
|
|
|
|
return ParentSymbolTable->FindSymbol (symname, true);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
PSymbol *PSymbolTable::AddSymbol (PSymbol *sym)
|
|
|
|
{
|
|
|
|
// Insert it in sorted order.
|
|
|
|
int min, max, mid;
|
|
|
|
|
|
|
|
min = 0;
|
|
|
|
max = (int)Symbols.Size() - 1;
|
|
|
|
|
|
|
|
while (min <= max)
|
|
|
|
{
|
|
|
|
mid = (min + max) / 2;
|
|
|
|
PSymbol *tsym = Symbols[mid];
|
|
|
|
|
|
|
|
if (tsym->SymbolName == sym->SymbolName)
|
|
|
|
{ // A symbol with this name already exists in the table
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else if (tsym->SymbolName < sym->SymbolName)
|
|
|
|
{
|
|
|
|
min = mid + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
max = mid - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Good. The symbol is not in the table yet.
|
|
|
|
Symbols.Insert (MAX(min, max), sym);
|
|
|
|
return sym;
|
2006-12-09 00:16:10 +00:00
|
|
|
}
|