Except he said that "cvar->FindVar("r_decals")->GetString()" is working. Perhaps you're changing the value too early and then what you have in config.cfg overrides it? After setting it, check that it has been set by printing the value and then maybe place a data breakpoint to see when the value changes again.
-----Original Message----- From: hlcoders-boun...@list.valvesoftware.com [mailto:hlcoders-boun...@list.valvesoftware.com] On Behalf Of Spencer 'voogru' MacDonald Sent: Wednesday, May 19, 2010 9:16 AM To: 'Discussion of Half-Life Programming' Subject: Re: [hlcoders] ConVar assignment breaks game "I made the assignment to a global variable" cvar is NULL when the dll loads. -----Original Message----- From: hlcoders-boun...@list.valvesoftware.com [mailto:hlcoders-boun...@list.valvesoftware.com] On Behalf Of Klaus Müller Sent: Wednesday, May 19, 2010 10:43 AM To: Discussion of Half-Life Programming Subject: Re: [hlcoders] ConVar assignment breaks game Okay, seems like it broke the game because I made the assignment to a global variable, although I still don't understand what the problem with that is. So if I assign it to a member variable of my panel resp. my property sheet class, at least the game remains functional. The problem still remains though that I can't change the value of the variable. Klaus Müller wrote: > I'm currently rewriting the entire options dialogue of Ep2 in order to > be able to add my own options. One of the fields I want to add is the > number of decals. So I made a call to cvar->FindVar("r_decals") in my > optionspanel.cpp. Since I'll be needing the ConVar multiple times, I > assigned it to a ConVar pointer via > > ConVar *cvDecals = (ConVar*) cvar->FindVar("r_decals"); > > The same is done in c_baseplayer.cpp for example, i.e. ConVar *pVar = > (ConVar *)cvar->FindVar( "snd_soundmixer" ). The code compiles > absolutely fine. However, if I start the mod and go to the console, it > says "ConVarRef cl_forwardspeed doesn't point to an existing ConVar". > Trying to open my panel I get a "unknown command modoptions". When I > want to start a singleplayer game I get the DT_Basegrenade error > discussed here multiple times, complaining about missing decoders. > And, to top it all off, when I close the game via exit or quit through > the console or the quit dialogue, the game crashes with this listed as > faulty module: Fault Module Name: client.dll_unloaded. > > The strange thing is though that if I don't assign the return value of > FindVar() and simply do a > > Q_strcpy( m_cDecals, cvar->FindVar("r_decals")->GetString() ); > m_pDecals->SetText( m_cDecals ); > > everything works fine and the value of r_decals gets printed to the > appropriate text field. However, it's not possible to change the value > of the ConVar. For example, if I do a > cvar->FindVar("r_decals")->SetValue(1024) before I copy the string to > m_cDecals, the value will still be 2048 as defined in my config.cf. > > This is all very confusing since I can't find the striking difference > between the example in c_baseplayer I mentioned and my panel. _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders