Jump to content

Erro de compilação


Metin2
 Share

Recommended Posts

Olá amigos eu estou colocando um item shop in game, precisa colocar uma função no arquivo questlua_global.cpp mas me da erro ao compilar alguém pode me disser a solução disso não tenho muito conhecimento em c++..

spacer.png

Código inserido em .cpp

	int _mysql_direct_query(lua_State* L)
	{
		if (!lua_isstring(L, 1))
			return 0;

		int i=0, m=1;
		MYSQL_ROW row;
		MYSQL_FIELD * field;
		MYSQL_RES * result;
		std::unique_ptr<SQLMsg> pMsg(DBManager::instance().DirectQuery(lua_tostring(L, 1)));
		if (pMsg.get())
		{
			lua_pushnumber(L, pMsg->Get()->uiAffectedRows);
			lua_newtable(L);
			if ((result = pMsg->Get()->pSQLResult) && !(pMsg->Get()->uiAffectedRows == 0 || pMsg->Get()->uiAffectedRows == (uint32_t)-1))
			{
				while((row = mysql_fetch_row(result)))
				{
					lua_pushnumber(L, m);
					lua_newtable(L);
					while((field = mysql_fetch_field(result)))
					{
						lua_pushstring(L, field->name);
						if (!(field->flags & NOT_NULL_FLAG) && (row[i]==NULL))
						{
							lua_pushnil(L);
						}
						else if (IS_NUM(field->type))
						{
							double val = NAN;
							lua_pushnumber(L, (sscanf(row[i],"%lf",&val)==1)?val:NAN);
						}
						else if (field->type == MYSQL_TYPE_BLOB)
						{
							lua_newtable(L);
							for (DWORD iBlob=0; iBlob < field->max_length; iBlob++)
							{
								lua_pushnumber(L, row[i][iBlob]);
								lua_rawseti(L, -2, iBlob+1);
							}
						}
						else
							lua_pushstring(L, row[i]);
						lua_rawset(L, -3);
						i++;
					}
					mysql_field_seek(result, 0);
					i=0;
					lua_rawset(L, -3);
					m++;
				}
			}
		}
		else {lua_pushnumber(L, 0); lua_newtable(L);}

		return 2;
	}

 

Link to comment
Share on other sites

Não tem referência à classe DBManager, por isso não consegue usar funções de lá.

Não estou no computador para ver, mas presumo que essa classe seja declarada no ficheiro db.h, por isso bastará incluir o seguinte debaixo dos outros includes no ficheiro onde estás a colocar esse função:

#include "db.h"

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...