Need some help with a keyvalue Created 3 years ago2021-05-09 17:48:02 UTC by Petko Petko

Created 3 years ago2021-05-09 17:48:02 UTC by Petko Petko

Posted 3 years ago2021-05-09 17:48:02 UTC Post #345595
So, Ive been working on a Half-Life: Decay port (Based on Yet another PS2 Half-Life PC port) and have somewhat recently (8 months ago)
ran into an issue when porting the mission lasers (ht11lasers). So here is the situation:

Whenever I press the buttons in the laser control room, the laser doesnt change color or become visible after being
completely turned off. First I thought that trigger_bit & trigger_bit_counter had some problems, but
I found out later that it was all caused beacuse env_render had a new keyvalue in PS2 Half-Life called
netname, it basically works somewhat like a multi manager, it finds all other entities on the map with the same netname (not targetname!)
and then applies the new rendermode, renderfx, color, etc...

I tried to make it work but all of my attempts have failed so far, so I came here to ask for help.

Here is the code:
//
// PS2DECAY
//

    if (!FStringNull(pev->netname))
    {
        edict_t* pentTarget    = NULL;
        //pentTarget = FIND_ENTITY_BY_STRING(pentTarget, "netname", STRING( pev->netname ));
        pentTarget = FIND_ENTITY_BY_STRING(NULL, "netname", STRING(pev->netname));
        while ( pentTarget )
        {
            //if (FNullEnt(pentTarget))
                //break;

            entvars_t *pevNetname = VARS( pentTarget );
            if ( !FBitSet( pev->spawnflags, SF_RENDER_MASKFX ) )
                pevNetname->renderfx = pev->renderfx;
            if ( !FBitSet( pev->spawnflags, SF_RENDER_MASKAMT ) )
                pevNetname->renderamt = pev->renderamt;
            if ( !FBitSet( pev->spawnflags, SF_RENDER_MASKMODE ) )
                pevNetname->rendermode = pev->rendermode;
            if ( !FBitSet( pev->spawnflags, SF_RENDER_MASKCOLOR ) )
                pevNetname->rendercolor = pev->rendercolor;

            pentTarget = FIND_ENTITY_BY_STRING(pentTarget, "netname", STRING( pev->netname ));
        }
    }
This is all located at the bottom of CRenderFxManager :: Use ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )

Can someone please help me with this?
Posted 3 years ago2021-05-10 09:10:41 UTC Post #345596
Are you sure it's supposed to check the other entities' netname and not their targetname? What's the entity setup in this map like? Can you show the original entity data for those?

Also you should prefer the use of UTIL_FindEntityByString since that does the work of testing for valid entities for you. FIND_ENTITY_BY_STRING can return the world which without the FNullEnt checks can result in an infinite loop.
Posted 3 years ago2021-05-11 17:44:36 UTC Post #345598
@Solokiller

yea, its supposed to check their netname, not their targetname. (checked the mapfile again to make sure)
Also thanks for mentioning that check, for some reason I had commented it out, so I fixed that (It was actually causing a crash)

Ive got the whole thing working now, and I will try using UTIL_FindEntityByString.

But now that that works (tested on a test map not ht11lasers) I have realised that multisource's are likely the main cause of the issue beacuse they have a custom spawnflag set, I'll have to look into that further. (the issue is on map ht11lasers that lasers dont register correctly, like Incorrect colors,
no sync-ing)

Thanks for the help! :biggrin:
You must be logged in to post a response.