/* * * * * * * * * * * * * * * * 
 * 	 ______     __  __     ______     __  __     ______     ______     __  __    
 *	/\  __ \   /\ \/\ \   /\  == \   /\ \_\ \   /\  __ \   /\  ___\   /\ \/ /    
 *	\ \ \/\ \  \ \ \_\ \  \ \  __<   \ \  __ \  \ \  __ \  \ \ \____  \ \  _"-.  
 *	 \ \_____\  \ \_____\  \ \_____\  \ \_\ \_\  \ \_\ \_\  \ \_____\  \ \_\ \_\ 
 *	  \/_____/   \/_____/   \/_____/   \/_/\/_/   \/_/\/_/   \/_____/   \/_/\/_/ 
 *
 *  - Version : 3L
 *  - By Oubliette
 * * * * * * * * * * * * * * * */

#include "main.h"
#include "oubhack.h"
#include "oubhack_cvar.h"

ICvar* _g_pCVar;

ICvarInterface::ICvarInterface(){

	CreateInterfaceFn VSTDLibFac = (CreateInterfaceFn)GetProcAddress( GetModuleHandle("vstdlib.dll"), "CreateInterface" );
	_g_pCVar = (ICvar*)VSTDLibFac( CVAR_INTERFACE_VERSION, NULL );

}


void ICvarInterface::Close(){

	_g_pCVar->Shutdown();

}

ConVar* ICvarInterface::GetCVar( const char* name ){

	return _g_pCVar->FindVar( name );

}

void ICvarInterface::SetCVarName( const char* name, const char* newName ){

	ConVar* cv_Var = this->GetCVar( name );

	if ( cv_Var != NULL ){

		cv_Var->m_nFlags = FCVAR_NONE;
		cv_Var->m_pszName = newName;

	}

}

void ICvarInterface::SetCVarValue( const char* name, float value ){

	ConVar* cv_Var = this->GetCVar( name );

	if ( cv_Var != NULL ){

		cv_Var->m_nFlags = FCVAR_NONE;
		cv_Var->SetValue( value );

	}

}

void ICvarInterface::SetCVarValue( const char* name, const char* value ){

	ConVar* cv_Var = this->GetCVar( name );

	if ( cv_Var != NULL ){

		cv_Var->m_nFlags = FCVAR_NONE;
		cv_Var->SetValue( value );

	}

}

void ICvarInterface::SetCVarValue( const char* name, int value ){

	ConVar* cv_Var = this->GetCVar( name );

	if ( cv_Var != NULL ){

		cv_Var->m_nFlags = FCVAR_NONE;
		cv_Var->SetValue( value );

	}

}

void ICvarInterface::NullCallback( const char* name ){

	ConVar* cv_Var = this->GetCVar( name );

	if ( cv_Var != NULL ){

		cv_Var->m_fnChangeCallback = NULL;

	}

}