@@ -189,9 +189,28 @@ void export_concommandbase()
189189class ConVarExt
190190{
191191public:
192- static ConVar* CreateConVar ( const char *pName )
192+ static ConVar* Get1 ( const char * szName )
193193 {
194- return new ConVar (pName, " " );
194+ return Get2 (szName, NULL , 0 );
195+ }
196+
197+ static ConVar* Get2 (const char * szName, const char * szDefaultValue, int flags)
198+ {
199+ return Get3 (szName, szDefaultValue, flags, NULL );
200+ }
201+
202+ static ConVar* Get3 (const char * szName, const char * szDefaultValue, int flags,
203+ const char * szHelpString)
204+ {
205+ return Get4 (szName, szDefaultValue, flags, szHelpString, false , 0 , false , 0 );
206+ }
207+
208+ static ConVar* Get4 (const char * szName, const char * szDefaultValue, int flags,
209+ const char * szHelpString, bool bMin, float fMin , bool bMax, float fMax )
210+ {
211+ ConVar* pConVar = g_pCVar->FindVar (szName);
212+ return pConVar ? pConVar : new ConVar (szName, szDefaultValue, flags,
213+ strdup (szHelpString), bMin, fMin , bMax, fMax );
195214 }
196215
197216 static bool HasMin (ConVar* pConVar)
@@ -229,10 +248,31 @@ class ConVarExt
229248void export_convar ()
230249{
231250 // TODO: Rename it?
232- class_<ConVar, bases<ConCommandBase, IConVar>, boost::noncopyable >(" CConVar" , init<const char *, const char *, optional< int > >())
233- .def (init<const char *, const char *, int , const char *>())
234- .def (init<const char *, const char *, int , const char *, bool , float , bool , float >())
235- .def (" __init__" , make_constructor (&ConVarExt::CreateConVar))
251+ class_<ConVar, bases<ConCommandBase, IConVar>, boost::noncopyable >(" CConVar" , no_init)
252+ .def (" get" ,
253+ &ConVarExt::Get1,
254+ " Creates a new server variable. If it already exists, the existing one will be returned." ,
255+ reference_existing_object_policy ()
256+ )
257+
258+ .def (" get" ,
259+ &ConVarExt::Get2,
260+ " Creates a new server variable. If it already exists, the existing one will be returned." ,
261+ reference_existing_object_policy ()
262+ )
263+
264+ .def (" get" ,
265+ &ConVarExt::Get3,
266+ " Creates a new server variable. If it already exists, the existing one will be returned." ,
267+ reference_existing_object_policy ()
268+ )
269+
270+ .def (" get" ,
271+ &ConVarExt::Get4,
272+ " Creates a new server variable. If it already exists, the existing one will be returned." ,
273+ reference_existing_object_policy ()
274+ )
275+ .staticmethod (" get" )
236276
237277 .def (" get_float" ,
238278 &ConVar::GetFloat,
0 commit comments