houndeyes killing each other Created 5 years ago2019-02-02 06:11:07 UTC by tschumann tschumann

Created 5 years ago2019-02-02 06:11:07 UTC by tschumann tschumann

Posted 5 years ago2019-02-02 06:11:07 UTC Post #341920
Okay this is a bit of strange one. I'm programmatically creating monster_houndeye entities with CBaseEntity::Create
After they are created I ALERT their pev->classname values and can see monster_houndeye
In the houndeye's SonicAttack method, all entities in a sphere around the houndeye are looped over. In this loop the pev->classname of neighbouring houndeyes is garbage so the houndeyes end up killing each other and themselves.

Somewhere the pev->classname is getting messed up. Any ideas?
If the houndeye is just in the map it doesn't seem to have this problem.
Posted 5 years ago2019-02-02 11:10:22 UTC Post #341921
How are you setting the classname?
Posted 5 years ago2019-02-02 23:07:33 UTC Post #341934
I'm not setting it at all - something in CBaseEntity seems to do that and it looks okay when it is spawned, and I think I tried setting it with MAKE_STRING but that didn't work either.

I see that some entities have it set manually with MAKE_STRING though.
Posted 5 years ago2019-02-02 23:38:55 UTC Post #341935
Then how are you creating the houndeyes? The string passed to Create will be used, but if the string is not allocated or a string literal it'll end up becoming garbage.
You can use MAKE_STRING( ALLOC_STRING( pszName ) ) to make sure it'll work, but if this code runs often you'll end up running out of memory in the engine since each ALLOC_STRING call allocates more memory.
Posted 5 years ago2019-02-03 08:20:55 UTC Post #341941
Ah, that'd be it - I use a value from CMD_ARGV which will get tidied up.
I guess I can cache the strings to stop running out of memory.
You must be logged in to post a response.