Esempio n. 1
0
int main()
{
	Log.Init(3);
	Log.Color(TBLUE);
	printf("Schumix Verzio: %s\n", revision);
	printf("A program leallitasahoz hasznald a <Ctrl+C> parancsot vagy <kikapcs>\n\n");
	Log.Color(TNORMAL);
	printf("Keszulesi ido: %s %s\n", BUILD_DATE, BUILD_TIME);
	printf("Keszitette Megax, Twl, Valroft es Scymex http://megaxx.info\n");
	printf("==============================================================================\n");
	printf("\n");
	Log.Notice("Schumix", "Rendszer indul...\n");

#if PLATFORM == PLATFORM_WINDOWS
	// WSA Setup
	WSADATA info;
	int error;

	if((err = WSAStartup(MAKEWORD(2, 2), &info)) != 0)
	{
		Log.Error("WSA", "Hiba tortent a WSA inicializalasanal. Hibakod: %i", error);
		return -1;
	}
#endif

	Log.Notice("Config", "Config fajl betoltese...");

	string config = string(Elnevezes) + ".conf";

	// Config fájl
	if(!Config.MainConfig.SetSource(format("./%s", config.c_str()).c_str()))
	{
		Log.Error("Config", ">> %s", config.c_str());
		new DefaultConfig(config);

		if(Config.MainConfig.SetSource(format("./%s", config.c_str()).c_str()))
			Log.Success("Config", ">> Config adatbazis sikeresen betoltve.");
		else
		{
			Log.Error("Config", ">> Ujabb sikertelen betoltes. Ellenorizze le kezileg.");
			return 0;
		}
	}
	else
		Log.Success("Config", ">> %s", config.c_str());

	printf("\n");

	Log.Init(cast_uint8(Config.MainConfig.GetIntDefault("Log", "Loglevel", 3)));
	new Vezerlo();

#if PLATFORM == PLATFORM_WINDOWS
	WSACleanup();
#endif

	Log.Notice("Schumix", "Program leallt.");
	return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
	Log.loglevel = 999;
	const char * username = "";
	const char * password = "";
	const char * dbname = "";
	if(!sDatabase.Initialize("localhost", 3306, username, password, dbname, 1, 65536))
	{
		Log.Error("SQL", "could not connect");
		return 1;
	}
	QueryResult * result = sDatabase.Query("SELECT guid, skills FROM characters");
	do 
	{
		char * skills = strdup(result->Fetch()[1].GetString());
		if(strchr(skills, ',') != 0)
		{
			// need to convert
			uint32 i = 0;
			stringstream ss;
			char * start = skills;
			char * end;
			for(;;)
			{
				// skill, skill+1, <add>0
				end = strchr(start, ',');
				if(!end)
					break;
				*end = '\0';
				uint32 val = atoi(start);
				start = end + 1;
				ss << val << " ";
				++i;
				if(!(i % 2))
					ss << "0 ";
			}

			sDatabase.Execute("UPDATE characters SET skills = '%s' WHERE guid = %u", ss.str().c_str(), result->Fetch()[0].GetUInt32());
			Log.Debug("SQL", "UPDATE characters SET skills = '%s' WHERE guid = %u", ss.str().c_str(), result->Fetch()[0].GetUInt32());
		}
	} while(result->NextRow());
	delete result;
	sDatabase.Shutdown();
	Log.Success("Program", "Exit normally");
	return 0;
}