View Single Post
voogru
Inspector Javert
Join Date: Oct 2004
Old 03-15-2009 , 15:02   Re: [FRAMEWORK] CEntity
Reply With Quote #5

OMG COPYCAT, first homing sentry rockets, and now this!

When does it stop?!

:p

It's surprising how much of it actually looks like copy and paste from my interface.

I'm implementing the VP hooks, and after looking at your code there is a flaw that I've discovered:

Code:
if (pNetworkable != NULL)
	{
		const char *serverName = pNetworkable->GetServerClass()->GetName();
		edict_t *pEdict = pNetworkable->GetEdict();
		CBaseEntity *pEnt = pNetworkable->GetBaseEntity();

		if (!pEdict || !pEnt)
		{
			return NULL;
		}

		if (pHookedTrie.retrieve(serverName))
		{
			pFactory->Create(pEdict, pEnt, false);
		}
		else
		{
			pFactory->Create(pEdict, pEnt, true);
			pHookedTrie.insert(serverName, true);
		}
	}

You are assuming that GetServerClass()->GetName() is going to be unique for every vtable, this isn't the case. There are several
entities where this will show up as "CBaseEntity", but they are seperate vtables.

For example, look at "info_target" and "soundent", completely different vtables, but same ServerClass "CBaseEntity".

I'd suggest using the classname of the entity instead, or some alternative method of detecting unique vtables because classname isn't perfect either.
voogru is offline