Jump to content

Quitar quest_fuctions


Jfirewall

Mensajes recomendados

Hola, andaba creando funciones y me daba pereza agregar siempre en el quest_fuctions entonces decidí quitarlo desde mi qc

Primero vamos a qc.cc y buscamos:

enum parse_state dentro de esto eliminamos esto
  ST_FUNCTION_NAME,

luego buscamos y eliminamos esto :
  int none_c_function(lua_State* L)
{
	return 0;
}

set<string> function_defs;
set<string> function_calls;

void RegisterDefFunction(const string& fname)
{
	function_defs.insert(fname);
}

void RegisterUsedFunction(const string& fname)
{
	function_calls.insert(fname);
}

void CheckUsedFunction()
{
	bool hasError = false;
	set<string> error_func;

	for (typeof(function_calls.begin()) it = function_calls.begin(); it != function_calls.end(); ++it)
	{
		if (function_defs.find(*it) == function_defs.end())
		{
			hasError = true;
			error_func.insert(*it);
		}
		cout << "Used : " << *it <<  endl;
	}

	if (hasError)
	{
		cout << "Calls undeclared function! : " << endl;
		for (typeof(error_func.begin()) it = error_func.begin(); it != error_func.end(); ++it)
		{
			cout << *it << endl;
		}
		abort();
	}
}

void load_quest_function_list(const char* filename)
{
	ifstream inf(filename);
	string s;

	while (!inf.eof())
	{
		inf >> s;
		if (inf.fail())
			break;

		RegisterDefFunction(s);
	}
}

luego buscamos esto y lo eliminamos:

load_quest_function_list("quest_functions");

luego buscamos esto y lo eliminamos:

else if (t.token == TK_FUNCTION)
					 {
						 ps = ST_FUNCTION_NAME;
  
 luego buscamos esto y lo eliminamos  OJO EXISTEN DOS ELIMINAR LOS DOS:
  
  if (!callname.empty())
						{
							lookahead(&lexstate);
							if (lexstate.lookahead.token == '(')
							{
								RegisterUsedFunction(callname);
								registered = true;
							}
							callname.clear();
						}
						else if (lexstate.t.token == '(')
						{ 
							if (!registered && prev.t.token == TK_NAME)
								RegisterUsedFunction(getstr(prev.t.seminfo.ts));
							registered = false;
						}
 luego buscamos esto y lo eliminamos:
  case ST_FUNCTION_NAME:
				if (t.token == TK_NAME)
				{
					current_function_name = getstr(t.seminfo.ts);
					RegisterDefFunction(quest_name+"."+current_function_name);
					ps = ST_FUNCTION_ARG;
				}
				break;
  
 luego buscamos esto y lo eliminamos:
  
  CheckUsedFunction();  
  
 Compilamos nuestro qc, y listo ya no tendran que declarar mas funciones nuevas en el quest_fuctions

 

Enlace para comentar
Compartir en otros sitios

hace 20 minutos, KnightFall dijo:

que sepa las funciones pueden estar dentro de la misma quest que implementes, pero por arranque de sistema para compilar si no equivoco siempre debe agregarse si no no te compila por la función faltante :down_2:

tu puedes crear tus funciones dentro de una misma quest la funcionalidad de esto es para esto por ejm, tu creas una nueva funcion en tu source ejm

questlua_pc
int pc_zone(lua_State* L)
	{	
		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();	
		ch->ChatPacket(CHAT_TYPE_INFO, "hola zone");
	}
quet zone begin
  state start begin
  	when login begin
  		pc.zone()
  end
 end
end

cuando tu compilas  te generaria un error el cual seria que debes declarar esta funcion pc.zone, lo que hace lo que publico es quitar que te genere el error y solo compiles y ya, aclaro esto es para los que nos da pereza cada rato estar agregando y agregando funciones 

Enlace para comentar
Compartir en otros sitios

hace 9 horas, Jfirewall dijo:

Hola, andaba creando funciones y me daba pereza agregar siempre en el quest_fuctions entonces decidí quitarlo desde mi qc


Primero vamos a qc.cc y buscamos:

enum parse_state dentro de esto eliminamos esto
  ST_FUNCTION_NAME,

luego buscamos y eliminamos esto :
  int none_c_function(lua_State* L)
{
	return 0;
}

set<string> function_defs;
set<string> function_calls;

void RegisterDefFunction(const string& fname)
{
	function_defs.insert(fname);
}

void RegisterUsedFunction(const string& fname)
{
	function_calls.insert(fname);
}

void CheckUsedFunction()
{
	bool hasError = false;
	set<string> error_func;

	for (typeof(function_calls.begin()) it = function_calls.begin(); it != function_calls.end(); ++it)
	{
		if (function_defs.find(*it) == function_defs.end())
		{
			hasError = true;
			error_func.insert(*it);
		}
		cout << "Used : " << *it <<  endl;
	}

	if (hasError)
	{
		cout << "Calls undeclared function! : " << endl;
		for (typeof(error_func.begin()) it = error_func.begin(); it != error_func.end(); ++it)
		{
			cout << *it << endl;
		}
		abort();
	}
}

void load_quest_function_list(const char* filename)
{
	ifstream inf(filename);
	string s;

	while (!inf.eof())
	{
		inf >> s;
		if (inf.fail())
			break;

		RegisterDefFunction(s);
	}
}

luego buscamos esto y lo eliminamos:

load_quest_function_list("quest_functions");

luego buscamos esto y lo eliminamos:

else if (t.token == TK_FUNCTION)
					 {
						 ps = ST_FUNCTION_NAME;
  
 luego buscamos esto y lo eliminamos  OJO EXISTEN DOS ELIMINAR LOS DOS:
  
  if (!callname.empty())
						{
							lookahead(&lexstate);
							if (lexstate.lookahead.token == '(')
							{
								RegisterUsedFunction(callname);
								registered = true;
							}
							callname.clear();
						}
						else if (lexstate.t.token == '(')
						{ 
							if (!registered && prev.t.token == TK_NAME)
								RegisterUsedFunction(getstr(prev.t.seminfo.ts));
							registered = false;
						}
 luego buscamos esto y lo eliminamos:
  case ST_FUNCTION_NAME:
				if (t.token == TK_NAME)
				{
					current_function_name = getstr(t.seminfo.ts);
					RegisterDefFunction(quest_name+"."+current_function_name);
					ps = ST_FUNCTION_ARG;
				}
				break;
  
 luego buscamos esto y lo eliminamos:
  
  CheckUsedFunction();  
  
 Compilamos nuestro qc, y listo ya no tendran que declarar mas funciones nuevas en el quest_fuctions

 

#define DISABLE_QUEST_FUNCTIONS

#ifndef DISABLE_QUEST_FUNCTIONS
	CheckUsedFunction();
#endif

Qué mierda?

Enlace para comentar
Compartir en otros sitios

Unirse a la conversación

Puedes publicar ahora y registrarte más tarde. Si tienes una cuenta, regístrate para publicar con su cuenta.

Guest
Responder a este tema...

×   Has pegado contenido con formato .   Eliminar formato

  Only 75 emoji are allowed.

×   Tu enlace se ha incorporado automáticamente.   Mostrar un enlace en su lugar

×   Se ha restaurado el contenido anterior. .   Borrar editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recientemente navegando por este tema   0 miembros

    • No hay usuarios registrados visitando esta página.
×
×
  • Crear nuevo...