MCPcopy Create free account
hub / github.com/JACoders/OpenJK / GetString

Method GetString

code/game/Q3_Interface.cpp:10563–10854  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10561}
10562
10563int CQuake3GameInterface::GetString( int entID, const char *name, char **value )
10564{
10565 gentity_t *ent = &g_entities[entID];
10566 if ( !ent )
10567 {
10568 return false;
10569 }
10570
10571 if( strlen(name) > 5 && !Q_stricmpn(name, "cvar_", 5) )
10572 {
10573 const char* cvar_name = name + 5;
10574 // by allocating and then re-using the same sufficiently large buffer,
10575 // we ensure that pointers to it never become invalid,
10576 // so we can support expressions using the same cvar twice,
10577 // e.g. if(get(cvar_x) == get(cvar_x))
10578 std::array<char, MAX_STRING_CHARS>& buf = m_cvars[cvar_name];
10579 gi.Cvar_VariableStringBuffer(cvar_name, buf.data(), buf.size());
10580 *value = buf.data();
10581 return true;
10582 }
10583
10584 int toGet = GetIDForString( setTable, name ); //FIXME: May want to make a "getTable" as well
10585
10586 switch ( toGet )
10587 {
10588 case SET_ANIM_BOTH:
10589 *value = (char *) Q3_GetAnimBoth( ent );
10590
10591 if ( VALIDSTRING( *value ) == false )
10592 return false;
10593
10594 break;
10595
10596 case SET_PARM1:
10597 case SET_PARM2:
10598 case SET_PARM3:
10599 case SET_PARM4:
10600 case SET_PARM5:
10601 case SET_PARM6:
10602 case SET_PARM7:
10603 case SET_PARM8:
10604 case SET_PARM9:
10605 case SET_PARM10:
10606 case SET_PARM11:
10607 case SET_PARM12:
10608 case SET_PARM13:
10609 case SET_PARM14:
10610 case SET_PARM15:
10611 case SET_PARM16:
10612 if ( ent->parms )
10613 {
10614 *value = (char *) ent->parms->parm[toGet - SET_PARM1];
10615 }
10616 else
10617 {
10618 DebugPrint( WL_WARNING, "GetString: invalid ent %s has no parms!\n", ent->targetname );
10619 return false;
10620 }

Callers 4

GetMethod · 0.45
ParseAffectMethod · 0.45
EvaluateConditionalMethod · 0.45
CheckAffectMethod · 0.45

Calls 7

Q_stricmpnFunction · 0.85
VALIDSTRINGFunction · 0.85
Q3_GetAnimBothFunction · 0.70
G_GetLocationForEntFunction · 0.70
GetIDForStringFunction · 0.50
GetStringForIDFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected