Hi, all. I've been lurking here for a while, but something's recently  
come up in my code that prompted me to post. I've looked through my entire  
backlog of hlcoders messages (almost 3000 at this point), searched the SDK  
wiki and the Steam Forums, and even did a brief google for this, and still  
I haven't found anything close to an answer.

        In my mod, I've got a base class, something like:

// --- server ---

class CBaseClass : public CBaseEntity
{
public:
        DECLARE_CLASS( CBaseClass, CBaseEntity );
        DECLARE_SERVERCLASS();

private:
        CNetworkVar( int, m_index );
};

IMPLEMENT_SERVERCLASS_ST( CBaseClass, DT_BaseClass )
        SendPropInt( SENDINFO( m_index ), 10, SPROP_UNSIGNED ),
END_SEND_TABLE()

// --- client ---

class C_BaseClass : public C_BaseEntity
{
public:
        DECLARE_CLASS( C_BaseClass, C_BaseEntity );
        DECLARE_CLIENTCLASS();

        int m_index;  // couldn't get this to work under private:
};

IMPLEMENT_CLIENTCLASS_DT( C_BaseClass, DT_BaseClass, CBaseClass )
        RecvPropInt( RECVINFO( m_index ) ),
END_RECV_TABLE()

        So far, so good, right? Follows the wiki, Valve's code, etc. Compiles  
with no errors. Load up the mod, and it works as expected.

        Now, here's the fun part. If I derive a class from my base class, like 
so:

// --- server ---

class CDerivedClass : public CBaseClass
{
public:
        DECLARE_CLASS( CDerivedClass, CBaseClass );
        DECLARE_SERVERCLASS();

private:
        CNetworkVar( int, m_something );
};

IMPLEMENT_SERVERCLASS_ST( CDerivedClass, DT_DerivedClass )
        SendPropInt( SENDINFO( m_something ), 10, SPROP_UNSIGNED ),
END_SEND_TABLE()

// --- client ---

class C_DerivedClass : public C_BaseClass
{
public:
        DECLARE_CLASS( C_DerivedClass, C_BaseClass );
        DECLARE_CLIENTCLASS();

        int m_something;
};

IMPLEMENT_CLIENTCLASS_DT( C_DerivedClass, DT_DerivedClass, CDerivedClass )
        RecvPropInt( RECVINFO( m_something ) ),
END_RECV_TABLE()

        ...the code compiles and runs just fine, but the client side of the  
derived class *never* gets any updates when m_something is set. What blows  
my mind is that I can cut and paste the code into the base class, and it  
will behave exactly as it should. What the heck is going on here? There's  
no indication that I can find in Valve's code or the wiki that I'm doing  
anything wrong, or that more/different code is needed. Someone mentioned  
CNetworkVarForDerived, but that doesn't seem to be the ideal solution,  
since you're still declaring a variable in the base class, and I want  
completely unique variables in some of the derived classes.

        Any thoughts/suggestions? I'm at my wits' end here...


_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to