Raised This Month: $51 Target: $400
 12% 

cvar flags


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Old and Slow
Senior Member
Join Date: May 2005
Location: Arlington, Texas
Old 03-18-2012 , 22:13   cvar flags
Reply With Quote #1

I want to disable the announcement to players of certain cvar changes, like bot_quota.

It looks like the available control of cvar flags is limited. I do a ConCommandBase scan and find the cvar so I can later change the value. That is working.

At the same time I can query for various flags with:

bool notify = pCmd->IsFlagSet(FCVAR_NOTIFY);

However, I would like to get the whole flag word in order to see what other flags are set but m_nFlags is not public. I could do a 32-bit loop and check them all but what seems wasteful (this is only done once tho).

It looks like there may be another way but it may not be public either - this comment appears in the iconvar.h file:

PHP Code:
    // Accessors.. not as efficient as using GetState()/GetInfo()
    // if you call these methods multiple times on the same IConVar
    
virtual bool IsFlagSetint nFlag ) const = 0
Also, I notice that there is an "AddFlags()" method but nothing mentioned to delete or replace flags.

So, any ideas on the best way to do this? Will I need to run an "Init()" to clear the flags and then manually reset the flags and the value?

Any help appreciated.
__________________
.......Chuck |TxA| Old and Slow [AARP]
Old and Slow is offline
Old and Slow
Senior Member
Join Date: May 2005
Location: Arlington, Texas
Old 03-27-2012 , 21:06   Re: cvar flags
Reply With Quote #2

Well, I cheated and made m_nFlags protected in convar.h so I can access it from a derived class. That works but I would like to leave the SDK untouched, if possible.
__________________
.......Chuck |TxA| Old and Slow [AARP]
Old and Slow is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 03-28-2012 , 04:58   Re: cvar flags
Reply With Quote #3

Quote:
Originally Posted by Old and Slow View Post
Well, I cheated and made m_nFlags protected in convar.h so I can access it from a derived class. That works but I would like to leave the SDK untouched, if possible.
http://mxr.alliedmods.net/sourcemod-...ar_sm_ob.h#180
__________________
asherkin is offline
Old and Slow
Senior Member
Join Date: May 2005
Location: Arlington, Texas
Old 03-28-2012 , 23:02   Re: cvar flags
Reply With Quote #4

I don't have sourcemod in this - it is a pure MetaMod:Source plug-in, so I was just linking to the HL2 SDK.

That link is interesting tho, I need to look closer at how SM does some things.
__________________
.......Chuck |TxA| Old and Slow [AARP]
Old and Slow is offline
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 03-30-2012 , 14:17   Re: cvar flags
Reply With Quote #5

The most dirties way:
PHP Code:
#define GET_CVAR_FLAGS(cvar_addr) *(int *)((char *)cvar_addr + 20)
#define ADD_CVAR_FLAG(cvar_addr, flag) *(int *)((char *)cvar_addr + 20) |= flag
#define REMOVE_CVAR_FLAG(cvar_addr, flag) *(int *)((char *)cvar_addr + 20) &= ~flag 
But if ConCommandBase was to change we would be fucked anyway.
Wazz is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:43.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode