--
[ Picked text/plain from multipart/alternative ]
Don't quote the whole thing :)
Hello, I have a Server side Logical Entity that uses a Think func:
CWeaponSetEnt::SpawnNewItem, I also have a ConCommand that eventually
triggers a SetThink(&CWeaponSetEnt::SpawnNewItem).
After loading the mod, and starting a map I can call this command whithout
problems, and the Think and everything works like a charm. The problem is
after disconnecting and loading a second (or third, etc) -different- map, on
Release it crashes, and on Debug I get the following:
X 00000043() -> GetDataDescMap()
> server.dll!CBaseEntity::FunctionCheck(void * pFunction=0x222eda77, char
* name=0x228beb18) Línea 2699 + 0x19
>>>> pFunction 0x222eda77 CWeaponSetEnt::SpawnNewItem(void) void *
>>>> name 0x228beb18 "BaseThinkFunc" char *
> server.dll!CBaseEntity::ThinkSet(void (void)* func=0x222eda77, float
thinkTime=0.00000000, const char * szContext=0x00000000) Línea 593
> server.dll!CWeaponSetEnt::InitSpawnNewItem(bool delayed=false) Línea
440
> (...)
> server.dll!CWeaponSetManager::ModifySlotOfWeaponSet(int weaponset=0,
int slot=1, Item_t * item=0x22a0b998) Línea 190 //concommand
I thought I was declaring a datadesc so I don't get it, am I missing some
macro? What is a think context?
I include the code, I left one member variable and other Macro-using lines.
Also included the code for the functions called so you don't have to search
for them :)
Not Linux or dedicated server, it is a listen server no-lan under W2K.
Thanks.
//Code
class CWeaponSetEnt : public CLogicalEntity
{
public:
DECLARE_CLASS( CWeaponSetEnt, CLogicalEntity );
DECLARE_DATADESC();
int m_iWeaponSlot;
void Spawn( void );
void InitSpawnNewItem( bool delayed );
void SpawnNewItem( void );
void InputPickedUp( inputdata_t &inputData );
private:
COutputEvent m_OnPlayerPickUp;
COutputEvent m_OnNPCPickUp;
COutputEvent m_OnPlayerUse;
};
LINK_ENTITY_TO_CLASS( item_weaponset, CWeaponSetEnt );
BEGIN_DATADESC( CWeaponSetEnt )
DEFINE_KEYFIELD( m_iWeaponSlot, FIELD_INTEGER, "weaponsetslot" ),
DEFINE_THINKFUNC( SpawnNewItem ),
// Links our input name from Hammer to our input member function
DEFINE_INPUTFUNC(FIELD_STRING, "PickedUp", InputPickedUp ),
// Links our output member to the output name used by Hammer
DEFINE_OUTPUT( m_OnPlayerPickUp, "OnPlayerPickUp" ),
DEFINE_OUTPUT( m_OnNPCPickUp, "OnNPCPickUp" ),
DEFINE_OUTPUT( m_OnPlayerUse, "OnPlayerUse" ),
END_DATADESC()
void CWeaponSetEnt::InitSpawnNewItem( bool delayed )
{
float f = 0.1f;
(...)
SetThink( &CWeaponSetEnt::SpawnNewItem ); //Crash
SetNextThink( gpGlobals->curtime + f );
}
BASEPTR CBaseEntity::ThinkSet( BASEPTR func, float thinkTime, const char
*szContext )
{
#if !defined( CLIENT_DLL )
#ifdef _DEBUG
COMPILE_TIME_ASSERT( sizeof(func) == 4 );
#endif
#endif
// Old system?
if ( !szContext )
{
m_pfnThink = func;
#if !defined( CLIENT_DLL )
#ifdef _DEBUG
FunctionCheck( (void *)*((int *)((char *)this + (
offsetof(CBaseEntity,m_pfnThink)))), "BaseThinkFunc" ); //Crash
#endif
#endif
return m_pfnThink;
}
(...)
}
#ifdef _DEBUG
void CBaseEntity::FunctionCheck( void *pFunction, char *name )
{
#ifdef USES_SAVERESTORE
// Note, if you crash here and your class is using multiple inheritance,
it is
// probably the case that CBaseEntity (or a descendant) is not the first
// class in your list of ancestors, which it must be.
if (pFunction && !UTIL_FunctionToName( GetDataDescMap(), pFunction ) )
//Crash on GetDataDescMap()
{
Warning( "FUNCTION NOT IN TABLE!: %s:%s (%08lx)\n",
STRING(m_iClassname), name, (unsigned long)pFunction );
Assert(0);
}
#endif
}
#endif
--
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders