예제 #1
0
// initialize
int inter_init_sql(const char *file)
{
	//int i;

	ShowInfo ("interserver initialize...\n");
	inter_config_read(file);

	//DB connection initialized
	sql_handle = Sql_Malloc();
	ShowInfo("Connect Character DB server.... (Character Server)\n");
	if( SQL_ERROR == Sql_Connect(sql_handle, char_server_id, char_server_pw, char_server_ip, (uint16)char_server_port, char_server_db) )
	{
		Sql_ShowDebug(sql_handle);
		Sql_Free(sql_handle);
		exit(EXIT_FAILURE);
	}

	if( *default_codepage ) {
		if( SQL_ERROR == Sql_SetEncoding(sql_handle, default_codepage) )
			Sql_ShowDebug(sql_handle);
	}

	wis_db = idb_alloc(DB_OPT_RELEASE_DATA);
	inter_guild_sql_init();
	inter_storage_sql_init();
	inter_party_sql_init();
	inter_pet_sql_init();
	inter_homunculus_sql_init();
	inter_mercenary_sql_init();
	inter_accreg_sql_init();
	inter_mail_sql_init();
	inter_auction_sql_init();

	return 0;
}
예제 #2
0
// initialize
int inter_init_sql(const char *file)
{
	//int i;

	inter_config_read(file);

	//DB connection initialized
	sql_handle = Sql_Malloc();
	ShowInfo(read_message("Source.char.inter_init_sql"));
	if(SQL_ERROR == Sql_Connect(sql_handle, char_server_id, char_server_pw, char_server_ip, (uint16)char_server_port, char_server_db)) {
		Sql_ShowDebug(sql_handle);
		Sql_Free(sql_handle);
		exit(EXIT_FAILURE);
	}

	if(*default_codepage) {
		if(SQL_ERROR == Sql_SetEncoding(sql_handle, default_codepage))
			Sql_ShowDebug(sql_handle);
	}

	wis_db = idb_alloc(DB_OPT_RELEASE_DATA);
	inter_guild_sql_init();
	inter_storage_sql_init();
	inter_party_sql_init();
	inter_pet_sql_init();
	inter_homunculus_sql_init();
	inter_mercenary_sql_init();
	inter_elemental_sql_init();
	inter_mail_sql_init();
	inter_auction_sql_init();

	geoip_readdb();
	msg_config_read("conf/messages.conf", false);
	return 0;
}
예제 #3
0
파일: inter.c 프로젝트: Celso1415/Fusion
// initialize
int inter_init_sql (const char *file)
{
	inter_config_read (file);
	//DB connection initialized
	sql_handle = Sql_Malloc();
	ShowInfo ("Conectando à DB de chars.... (Character Server)\n");

	if (SQL_ERROR == Sql_Connect (sql_handle, char_server_id, char_server_pw, char_server_ip, (uint16) char_server_port, char_server_db)) {
		Sql_ShowDebug (sql_handle);
		Sql_Free (sql_handle);
		exit (EXIT_FAILURE);
	}

	if (*default_codepage) {
		if (SQL_ERROR == Sql_SetEncoding (sql_handle, default_codepage))
			Sql_ShowDebug (sql_handle);
	}

	ShowStatus ("Conectado ao banco de dados principal '"CL_WHITE"%s"CL_RESET"'.\n", char_server_db);
	Sql_PrintExtendedInfo (sql_handle);
	wis_db = idb_alloc (DB_OPT_RELEASE_DATA);
	inter_guild_sql_init();
	inter_storage_sql_init();
	inter_party_sql_init();
	inter_pet_sql_init();
	inter_homunculus_sql_init();
	inter_mercenary_sql_init();
	inter_elemental_sql_init();
	inter_accreg_sql_init();
	inter_mail_sql_init();
	inter_auction_sql_init();
	geoip_readdb();
	msg_config_read ("conf/msg_athena.conf");
	return 0;
}
예제 #4
0
파일: login.c 프로젝트: benedicktj/mYnexia
int do_init(int argc, char **argv) {
	int i;
	char *CONF_FILE = "conf/login.conf";
	char *LANG_FILE = "conf/lang.conf";
	char *INTER_FILE = "conf/inter.conf";

	srand(gettick());
	set_logfile("log/login.log");
	set_dmpfile("log/login_dump.log");

	for (i = 1; i < argc ; i++) {
		if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "--h") == 0 || strcmp(argv[i], "--?") == 0 || strcmp(argv[i], "/?") == 0)
			help_screen();
		else if (strcmp(argv[i], "--conf") == 0)
			CONF_FILE=argv[i+1];
		else if (strcmp(argv[i],"--inter") == 0)
			INTER_FILE = argv[i+1];
		else if (strcmp(argv[i],"--lang") == 0)
			LANG_FILE = argv[i+1];
	}

	config_read(CONF_FILE);
	config_read(INTER_FILE);
	config_read("conf/char.conf");
	sql_handle = Sql_Malloc();
	if(sql_handle==NULL)
	{
		Sql_ShowDebug(sql_handle);
		exit(EXIT_FAILURE);
	}
	if( SQL_ERROR == Sql_Connect(sql_handle, sql_id, sql_pw, sql_ip, (uint16)sql_port, sql_db) )
	{
		printf("id: %s pass: %s Port: %d\n",sql_id, sql_pw,sql_port);
		Sql_ShowDebug(sql_handle);
		Sql_Free(sql_handle);
		exit(EXIT_FAILURE);
	}
	
	//sql_init();
	lang_read(LANG_FILE);
	set_termfunc(do_term);
	//zlib_init();
	add_log("");
	add_log("mYnexia Login Server Started.\n");

	set_defaultaccept(clif_accept);
	set_defaultparse(clif_parse);
	login_fd = make_listen_port(login_port);
	timer_insert(10 * 60 * 1000, 10 * 60 * 1000, Remove_Throttle, 0, 0);
	//Lockout DB
	bf_lockout=uidb_alloc(DB_OPT_BASE);
	
	printf("mYnexia Login Server is \033[1;32mready\033[0m! Listening at %d.\n", login_port);
	add_log("Server Ready! Listening at %d.\n", login_port);
	return 0;
}
예제 #5
0
// initialize
void ipban_init(void)
{
	const char* username;
	const char* password;
	const char* hostname;
	uint16      port;
	const char* database;
	const char* codepage;

	ipban_inited = true;

	if( !login_config.ipban )
		return;// ipban disabled

	if( ipban_db_hostname[0] != '\0' )
	{// local settings
		username = ipban_db_username;
		password = ipban_db_password;
		hostname = ipban_db_hostname;
		port     = ipban_db_port;
		database = ipban_db_database;
		codepage = ipban_codepage;
	}
	else
	{// global settings
		username = global_db_username;
		password = global_db_password;
		hostname = global_db_hostname;
		port     = global_db_port;
		database = global_db_database;
		codepage = global_codepage;
	}

	// establish connections
	sql_handle = Sql_Malloc();
	if( SQL_ERROR == Sql_Connect(sql_handle, username, password, hostname, port, database) )
	{
		Sql_ShowDebug(sql_handle);
		Sql_Free(sql_handle);
		exit(EXIT_FAILURE);
	}
	if( codepage[0] != '\0' && SQL_ERROR == Sql_SetEncoding(sql_handle, codepage) )
		Sql_ShowDebug(sql_handle);
		
	ShowStatus("Conectado ao banco de dados ipban '%s'.\n", database);
	Sql_PrintExtendedInfo(sql_handle);

	if( login_config.ipban_cleanup_interval > 0 )
	{ // set up periodic cleanup of connection history and active bans
		add_timer_func_list(ipban_cleanup, "ipban_cleanup");
		cleanup_timer_id = add_timer_interval(gettick()+10, ipban_cleanup, 0, 0, login_config.ipban_cleanup_interval*1000);
	} else // make sure it gets cleaned up on login-server start regardless of interval-based cleanups
		ipban_cleanup(0,0,0,0);
}
예제 #6
0
파일: log.c 프로젝트: Mateuus/brathena-1
void log_sql_init(void) {
	// log db connection
	logs->mysql_handle = Sql_Malloc();

	ShowInfo("Conectando com o banco de dados de logs "CL_WHITE"%s"CL_RESET" em "CL_WHITE"%s"CL_RESET"...\n",logs->db_name,logs->db_ip);
	if(SQL_ERROR == Sql_Connect(logs->mysql_handle, logs->db_id, logs->db_pw, logs->db_ip, logs->db_port, logs->db_name) )
		exit(EXIT_FAILURE);
	ShowStatus("Conex%co efetuada com sucesso no banco de dados '"CL_WHITE"%s"CL_RESET"'.\n", 198, logs->db_name);

	if(strlen(map->default_codepage) > 0)
	if(SQL_ERROR == Sql_SetEncoding(logs->mysql_handle, map->default_codepage))
			Sql_ShowDebug(logs->mysql_handle);
}
예제 #7
0
CDataLoader::CDataLoader()
{
    SqlHandle = Sql_Malloc();

    //	ShowStatus("sqlhandle is allocating\n");
    if (Sql_Connect(SqlHandle, search_config.mysql_login.c_str(),
        search_config.mysql_password.c_str(),
        search_config.mysql_host.c_str(),
        search_config.mysql_port,
        search_config.mysql_database.c_str()) == SQL_ERROR)
    {
        ShowError("cant connect\n");
    }
}
예제 #8
0
/// establishes database connection
static bool account_db_sql_init(AccountDB* self)
{
	AccountDB_SQL* db = (AccountDB_SQL*)self;
	Sql* sql_handle;
	const char* username;
	const char* password;
	const char* hostname;
	uint16      port;
	const char* database;
	const char* codepage;

	db->accounts = Sql_Malloc();
	sql_handle = db->accounts;

	if( db->db_hostname[0] != '\0' )
	{// local settings
		username = db->db_username;
		password = db->db_password;
		hostname = db->db_hostname;
		port     = db->db_port;
		database = db->db_database;
		codepage = db->codepage;
	}
	else
	{// global settings
		username = db->global_db_username;
		password = db->global_db_password;
		hostname = db->global_db_hostname;
		port     = db->global_db_port;
		database = db->global_db_database;
		codepage = db->global_codepage;
	}

	if( SQL_ERROR == Sql_Connect(sql_handle, username, password, hostname, port, database) )
	{
		Sql_ShowDebug(sql_handle);
		Sql_Free(db->accounts);
		db->accounts = NULL;
		return false;
	}

	if( codepage[0] != '\0' && SQL_ERROR == Sql_SetEncoding(sql_handle, codepage) )
		Sql_ShowDebug(sql_handle);

	ShowStatus("Connected to main database '%s'.\n", database);
	Sql_PrintExtendedInfo(sql_handle);

	return true;
}	
예제 #9
0
// initialize
void ipban_init(void)
{
	const char* username;
	const char* password;
	const char* hostname;
	uint16      port;
	const char* database;
	const char* codepage;

	ipban_inited = true;

	if( !login_config.ipban )
		return;// ipban disabled

	if( ipban_db_hostname[0] != '\0' )
	{// local settings
		username = ipban_db_username;
		password = ipban_db_password;
		hostname = ipban_db_hostname;
		port     = ipban_db_port;
		database = ipban_db_database;
		codepage = ipban_codepage;
	}
	else
	{// global settings
		username = global_db_username;
		password = global_db_password;
		hostname = global_db_hostname;
		port     = global_db_port;
		database = global_db_database;
		codepage = global_codepage;
	}

	// establish connections
	sql_handle = Sql_Malloc();
	if( SQL_ERROR == Sql_Connect(sql_handle, username, password, hostname, port, database) )
	{
		Sql_ShowDebug(sql_handle);
		Sql_Free(sql_handle);
		exit(EXIT_FAILURE);
	}
	if( codepage[0] != '\0' && SQL_ERROR == Sql_SetEncoding(sql_handle, codepage) )
		Sql_ShowDebug(sql_handle);

	// set up periodic cleanup of connection history and active bans
	add_timer_func_list(ipban_cleanup, "ipban_cleanup");
	cleanup_timer_id = add_timer_interval(gettick()+10, ipban_cleanup, 0, 0, 60*1000);
}
예제 #10
0
파일: loginlog.cpp 프로젝트: AlmasB/rathena
/**
 * Initialize the module.
 * Launched at login-serv start, create db or other long scope variable here.
 * @return true if success else exit execution
 */
bool loginlog_init(void) {
	const char* username;
	const char* password;
	const char* hostname;
	uint16      port;
	const char* database;
	const char* codepage;

	if( log_db_hostname[0] != '\0' )
	{// local settings
		username = log_db_username;
		password = log_db_password;
		hostname = log_db_hostname;
		port     = log_db_port;
		database = log_db_database;
		codepage = log_codepage;
	}
	else
	{// global settings
		username = global_db_username;
		password = global_db_password;
		hostname = global_db_hostname;
		port     = global_db_port;
		database = global_db_database;
		codepage = global_codepage;
	}

	sql_handle = Sql_Malloc();

	if( SQL_ERROR == Sql_Connect(sql_handle, username, password, hostname, port, database) )
	{
        ShowError("Couldn't connect with uname='%s',passwd='%s',host='%s',port='%d',database='%s'\n",
                        username, password, hostname, port, database);
		Sql_ShowDebug(sql_handle);
		Sql_Free(sql_handle);
		exit(EXIT_FAILURE);
	}

	if( codepage[0] != '\0' && SQL_ERROR == Sql_SetEncoding(sql_handle, codepage) )
		Sql_ShowDebug(sql_handle);

	enabled = true;

	return true;
}
예제 #11
0
void CDataLoader::ExpireAHItems()
{
	Sql_t* sqlH2 = Sql_Malloc();
	Sql_Connect(sqlH2, search_config.mysql_login.c_str(),
		search_config.mysql_password.c_str(),
		search_config.mysql_host.c_str(),
		search_config.mysql_port,
		search_config.mysql_database.c_str());

	std::string qStr = "SELECT T0.id,T0.itemid,T1.stacksize, T0.stack, T0.seller FROM auction_house T0 INNER JOIN item_basic T1 ON \
					   		T0.itemid = T1.itemid WHERE datediff(now(),from_unixtime(date)) >=%u AND buyer_name IS NULL;";
	int32 ret = Sql_Query(SqlHandle, qStr.c_str(), search_config.expire_days);
	int64 expiredAuctions = Sql_NumRows(SqlHandle);
	if (ret != SQL_ERROR &&	Sql_NumRows(SqlHandle) != 0)
	{
		while (Sql_NextRow(SqlHandle) == SQL_SUCCESS)
		{
			std::string qStr2;
			// iterate through the expired auctions and return them to the seller
			uint32 saleID = (uint32)Sql_GetUIntData(SqlHandle, 0);
			uint32 itemID = (uint32)Sql_GetUIntData(SqlHandle, 1);
			uint8  itemStack = (uint8)Sql_GetUIntData(SqlHandle, 2);
			uint8 ahStack = (uint8)Sql_GetUIntData(SqlHandle, 3);
			uint32 seller = (uint32)Sql_GetUIntData(SqlHandle, 4);
			ret = Sql_Query(sqlH2, "INSERT INTO delivery_box (charid, charname, box, itemid, itemsubid, quantity, senderid, sender) VALUES "
				"(%u, (select charname from chars where charid=%u), 1, %u, 0, %u, 0, 'AH-Jeuno');", seller, seller, itemID, ahStack == 1 ? itemStack : 1 );
			//		ShowMessage(cC2, seller, seller, itemID);
			if (ret != SQL_ERROR &&	Sql_NumRows(SqlHandle) != 0)
			{
				// delete the item from the auction house
				Sql_Query(sqlH2, "DELETE FROM auction_house WHERE id= %u", saleID);
			}
		}
	}
	else if (ret == SQL_ERROR)
	{
		//	ShowMessage(CL_RED"SQL ERROR: %s\n\n" CL_RESET, SQL_ERROR);
	}
	ShowMessage("Sent %u expired auction house items back to sellers\n", expiredAuctions);
	Sql_Free(sqlH2);
}
예제 #12
0
CInstanceLoader::CInstanceLoader(uint8 instanceid, CZone* PZone, CCharEntity* PRequester)
{
    DSP_DEBUG_BREAK_IF(PZone->GetType() != ZONETYPE_DUNGEON_INSTANCED);

	requester = PRequester;
    zone = PZone;
    CInstance* instance = ((CZoneInstance*)PZone)->CreateInstance(instanceid);

	SqlInstanceHandle = Sql_Malloc();

	if (Sql_Connect(SqlInstanceHandle, map_config.mysql_login,
		map_config.mysql_password,
		map_config.mysql_host,
		map_config.mysql_port,
		map_config.mysql_database) == SQL_ERROR)
	{
		do_final(EXIT_FAILURE);
	}
	Sql_Keepalive(SqlInstanceHandle);

	task = std::async(std::launch::async, &CInstanceLoader::LoadInstance, this, instance);
}
예제 #13
0
파일: account.c 프로젝트: Akheon23/rathena
/**
 * Establish the database connection.
 * @param self: pointer to db
 */
static bool account_db_sql_init(AccountDB* self) {
	AccountDB_SQL* db = (AccountDB_SQL*)self;
	Sql* sql_handle;
	const char* username = "******";
	const char* password = "";
	const char* hostname = "127.0.0.1";
	uint16      port     = 3306;
	const char* database = "ragnarok";
	const char* codepage = "";

	db->accounts = Sql_Malloc();
	sql_handle = db->accounts;

	if( db->db_hostname[0] != '\0' )
	{// local settings
		username = db->db_username;
		password = db->db_password;
		hostname = db->db_hostname;
		port     = db->db_port;
		database = db->db_database;
		codepage = db->codepage;
	}

	if( SQL_ERROR == Sql_Connect(sql_handle, username, password, hostname, port, database) )
	{
                ShowError("Couldn't connect with uname='%s',passwd='%s',host='%s',port='%d',database='%s'\n",
                        username, password, hostname, port, database);
		Sql_ShowDebug(sql_handle);
		Sql_Free(db->accounts);
		db->accounts = NULL;
		return false;
	}

	if( codepage[0] != '\0' && SQL_ERROR == Sql_SetEncoding(sql_handle, codepage) )
		Sql_ShowDebug(sql_handle);

	return true;
}
예제 #14
0
// initialize
int inter_init_sql(const char *file)
{
	inter_config_defaults();
	inter_config_read(file);

	//DB connection initialized
	sql_handle = Sql_Malloc();
	ShowInfo("Connect Character DB server.... (Character Server)\n");
	if( SQL_ERROR == Sql_Connect(sql_handle, char_server_id, char_server_pw, char_server_ip, (uint16)char_server_port, char_server_db) )
	{
		ShowError("Couldn't connect with username = '******', password = '******', host = '%s', port = '%d', database = '%s'\n",
			char_server_id, char_server_pw, char_server_ip, char_server_port, char_server_db);
		Sql_ShowDebug(sql_handle);
		Sql_Free(sql_handle);
		exit(EXIT_FAILURE);
	}

	if( *default_codepage ) {
		if( SQL_ERROR == Sql_SetEncoding(sql_handle, default_codepage) )
			Sql_ShowDebug(sql_handle);
	}

	wis_db = idb_alloc(DB_OPT_RELEASE_DATA);
	inter_config_readConf();
	inter_guild_sql_init();
	inter_storage_sql_init();
	inter_party_sql_init();
	inter_pet_sql_init();
	inter_homunculus_sql_init();
	inter_mercenary_sql_init();
	inter_elemental_sql_init();
	inter_mail_sql_init();
	inter_auction_sql_init();
	inter_clan_init();

	geoip_readdb();
	return 0;
}
예제 #15
0
int32 do_init(int32 argc, int8** argv)
{
    ShowStatus("do_init: begin server initialization...\n");

    MAP_CONF_FILENAME = "./conf/map_darkstar.conf";

    srand((uint32)time(NULL));

    map_config_default();
    map_config_read(MAP_CONF_FILENAME);
    ShowMessage("\t\t\t - "CL_GREEN"[OK]"CL_RESET"\n");
    ShowStatus("do_init: map_config is reading");
    ShowMessage("\t\t - "CL_GREEN"[OK]"CL_RESET"\n");

    luautils::init();
    CmdHandler.init("conf/commands.conf",luautils::LuaHandle);
    PacketParderInitialize();
    SqlHandle = Sql_Malloc();

    ShowStatus("do_init: sqlhandle is allocating");
    if( Sql_Connect(SqlHandle,map_config.mysql_login,
                    map_config.mysql_password,
                    map_config.mysql_host,
                    map_config.mysql_port,
                    map_config.mysql_database) == SQL_ERROR )
    {
        exit(EXIT_FAILURE);
    }
    Sql_Keepalive(SqlHandle);

    ShowMessage("\t\t - "CL_GREEN"[OK]"CL_RESET"\n");
    ShowStatus("do_init: zlib is reading");
    zlib_init();
    ShowMessage("\t\t\t - "CL_GREEN"[OK]"CL_RESET"\n");

    ShowStatus("do_init: loading items");
    itemutils::LoadItemList();
    ShowMessage("\t\t\t - "CL_GREEN"[OK]"CL_RESET"\n");

    // нужно будет написать один метод для инициализации всех данных в battleutils
    // и один метод для освобождения этих данных

    ShowStatus("do_init: loading spells");
    battleutils::LoadSpellList();
    ShowMessage("\t\t\t - "CL_GREEN"[OK]"CL_RESET"\n");

    guildutils::Initialize();
    charutils::LoadExpTable();
    battleutils::LoadSkillTable();
    battleutils::LoadAbilitiesList();
    battleutils::LoadWeaponSkillsList();
    battleutils::LoadTraitsList();
    battleutils::LoadMobSkillsList();
    battleutils::LoadEnmityTable();
    petutils::LoadPetList();

    ShowStatus("do_init: loading zones");
    zoneutils::LoadZoneList();
    ShowMessage("\t\t\t - "CL_GREEN"[OK]"CL_RESET"\n");

    luautils::OnServerStart();

    ShowStatus("do_init: server is binding with port %u",map_config.usMapPort);
    map_fd = makeBind_udp(map_config.uiMapIp,map_config.usMapPort);
    ShowMessage("\t - "CL_GREEN"[OK]"CL_RESET"\n");

    CVanaTime::getInstance()->setCustomOffset(map_config.vanadiel_time_offset);

    CTaskMgr::getInstance()->AddTask("time_server", gettick()+1000, NULL, CTaskMgr::TASK_INTERVAL, time_server, 2400);
    CTaskMgr::getInstance()->AddTask("map_cleanup", gettick()+5000, NULL, CTaskMgr::TASK_INTERVAL, map_cleanup, map_config.max_time_lastupdate);

    CREATE(g_PBuff,   int8, map_config.buffer_size + 20);
    CREATE(PTempBuff, int8, map_config.buffer_size + 20);
    ShowStatus("The map-server is "CL_GREEN"ready"CL_RESET" to work...\n");
    ShowMessage("=======================================================================\n");
    return 0;
}
예제 #16
0
파일: login.cpp 프로젝트: jono659/enko
int32 do_init(int32 argc, char** argv)
{
    int32 i;
    LOGIN_CONF_FILENAME = "conf/login_darkstar.conf";
    VERSION_INFO_FILENAME = "version.info";

    const char *lan_cfgName = LAN_CONFIG_NAME;
    //srand(gettick());

    for (i = 1; i < argc; i++) {
        if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "--h") == 0 || strcmp(argv[i], "--?") == 0 || strcmp(argv[i], "/?") == 0)
            login_helpscreen(1);
        else if (strcmp(argv[i], "--version") == 0 || strcmp(argv[i], "--v") == 0 || strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "/v") == 0)
            login_versionscreen(1);
        else if (strcmp(argv[i], "--login_config") == 0 || strcmp(argv[i], "--login-config") == 0)
            LOGIN_CONF_FILENAME = argv[i + 1];
        else if (strcmp(argv[i], "--lan_config") == 0 || strcmp(argv[i], "--lan-config") == 0)
            lan_cfgName = argv[i + 1];
        else if (strcmp(argv[i], "--run_once") == 0)	// close the map-server as soon as its done.. for testing [Celest]
            runflag = 0;
    }

    //lan_config_default(&lan_config);
    //lan_config_read(lan_cfgName,&lan_config);

    login_config_default();
    login_config_read(LOGIN_CONF_FILENAME);

    version_info_default();
    version_info_read(VERSION_INFO_FILENAME);


    login_fd = makeListenBind_tcp(login_config.uiLoginAuthIp, login_config.usLoginAuthPort, connect_client_login);
    ShowStatus("The login-server-auth is " CL_GREEN"ready" CL_RESET" (Server is listening on the port %u).\n\n", login_config.usLoginAuthPort);

    login_lobbydata_fd = makeListenBind_tcp(login_config.uiLobbyDataIp, login_config.usLobbyDataPort, connect_client_lobbydata);
    ShowStatus("The login-server-lobbydata is " CL_GREEN"ready" CL_RESET" (Server is listening on the port %u).\n\n", login_config.usLobbyDataPort);

    login_lobbyview_fd = makeListenBind_tcp(login_config.uiLobbyViewIp, login_config.usLobbyViewPort, connect_client_lobbyview);
    ShowStatus("The login-server-lobbyview is " CL_GREEN"ready" CL_RESET" (Server is listening on the port %u).\n\n", login_config.usLobbyViewPort);

    SqlHandle = Sql_Malloc();
    if (Sql_Connect(SqlHandle, login_config.mysql_login,
                    login_config.mysql_password,
                    login_config.mysql_host,
                    login_config.mysql_port,
                    login_config.mysql_database) == SQL_ERROR)
    {
        exit(EXIT_FAILURE);
    }
    Sql_Keepalive(SqlHandle);

    const char *fmtQuery = "OPTIMIZE TABLE `accounts`,`accounts_banned`, `accounts_sessions`, `chars`,`char_equip`, \
						   `char_inventory`, `char_jobs`,`char_look`,`char_stats`, `char_vars`, `char_bazaar_msg`, \
						   `char_skills`, `char_titles`, `char_effects`, `char_exp`;";

    if (Sql_Query(SqlHandle, fmtQuery) == SQL_ERROR)
    {
        ShowError("do_init: Impossible to optimise tables\n");
    }

    messageThread = std::thread(message_server_init);

    ShowStatus("The login-server is " CL_GREEN"ready" CL_RESET" to work...\n");
    return 0;
}
예제 #17
0
파일: map.cpp 프로젝트: Elkazan/darkstar
int32 do_init(int32 argc, int8** argv)
{
    ShowStatus("do_init: begin server initialization...\n");
    map_ip.s_addr = 0;

    for (int i = 1; i < argc; i++)
    {
        if (strcmp(argv[i], "--ip") == 0)
            map_ip.s_addr = inet_addr(argv[i + 1]);
        else if (strcmp(argv[i], "--port") == 0)
            map_port = std::stoi(argv[i + 1]);
    }

    MAP_CONF_FILENAME = "./conf/map_darkstar.conf";

    srand((uint32)time(nullptr));
    dsprand::seed();

    map_config_default();
    map_config_read(MAP_CONF_FILENAME);
    ShowMessage("\t\t\t - " CL_GREEN"[OK]" CL_RESET"\n");
    ShowStatus("do_init: map_config is reading");
    ShowMessage("\t\t - " CL_GREEN"[OK]" CL_RESET"\n");

    luautils::init();
    CmdHandler.init(luautils::LuaHandle);
    PacketParserInitialize();
    SqlHandle = Sql_Malloc();

    ShowStatus("do_init: sqlhandle is allocating");
    if (Sql_Connect(SqlHandle, map_config.mysql_login,
        map_config.mysql_password,
        map_config.mysql_host,
        map_config.mysql_port,
        map_config.mysql_database) == SQL_ERROR)
    {
        do_final(EXIT_FAILURE);
    }
    Sql_Keepalive(SqlHandle);

    // отчищаем таблицу сессий при старте сервера (временное решение, т.к. в кластере это не будет работать)
    Sql_Query(SqlHandle, "DELETE FROM accounts_sessions WHERE IF(%u = 0 AND %u = 0, true, server_addr = %u AND server_port = %u);",
        map_ip, map_port, map_ip, map_port);

    ShowMessage("\t\t - " CL_GREEN"[OK]" CL_RESET"\n");
    ShowStatus("do_init: zlib is reading");
    zlib_init();
    ShowMessage("\t\t\t - " CL_GREEN"[OK]" CL_RESET"\n");

    messageThread = std::thread(message::init, map_config.msg_server_ip, map_config.msg_server_port);

    ShowStatus("do_init: loading items");
    itemutils::Initialize();
    ShowMessage("\t\t\t - " CL_GREEN"[OK]" CL_RESET"\n");

    // нужно будет написать один метод для инициализации всех данных в battleutils
    // и один метод для освобождения этих данных

    ShowStatus("do_init: loading spells");
    spell::LoadSpellList();
    mobSpellList::LoadMobSpellList();
    ShowMessage("\t\t\t - " CL_GREEN"[OK]" CL_RESET"\n");

    guildutils::Initialize();
    charutils::LoadExpTable();
    linkshell::LoadLinkshellList();
    traits::LoadTraitsList();
    effects::LoadEffectsParameters();
    battleutils::LoadSkillTable();
    meritNameSpace::LoadMeritsList();
    ability::LoadAbilitiesList();
    battleutils::LoadWeaponSkillsList();
    battleutils::LoadMobSkillsList();
    battleutils::LoadSkillChainDamageModifiers();
    petutils::LoadPetList();
    mobutils::LoadCustomMods();

    ShowStatus("do_init: loading zones\n");
    zoneutils::LoadZoneList();
    ShowMessage("\t\t\t - " CL_GREEN"[OK]" CL_RESET"\n");

    fishingutils::LoadFishingMessages();

    ShowStatus("do_init: server is binding with port %u", map_port == 0 ? map_config.usMapPort : map_port);
    map_fd = makeBind_udp(map_config.uiMapIp, map_port == 0 ? map_config.usMapPort : map_port);
    ShowMessage("\t - " CL_GREEN"[OK]" CL_RESET"\n");

    CVanaTime::getInstance()->setCustomOffset(map_config.vanadiel_time_offset);

    zoneutils::InitializeWeather(); // Need VanaTime initialized

    CTransportHandler::getInstance()->InitializeTransport();

    CTaskMgr::getInstance()->AddTask("time_server", gettick(), nullptr, CTaskMgr::TASK_INTERVAL, time_server, 2400);
    CTaskMgr::getInstance()->AddTask("map_cleanup", gettick(), nullptr, CTaskMgr::TASK_INTERVAL, map_cleanup, 5000);
    CTaskMgr::getInstance()->AddTask("garbage_collect", gettick(), nullptr, CTaskMgr::TASK_INTERVAL, map_garbage_collect, 15 * 60 * 1000);

    CREATE(g_PBuff, int8, map_config.buffer_size + 20);
    CREATE(PTempBuff, int8, map_config.buffer_size + 20);

    ShowStatus("The map-server is " CL_GREEN"ready" CL_RESET" to work...\n");
    ShowMessage("=======================================================================\n");
    return 0;
}
예제 #18
0
파일: map.cpp 프로젝트: Gwynthell/FFDB
int32 do_init(int32 argc, int8** argv)
{
	ShowStatus("do_init: begin server initialization...\n");

	MAP_CONF_FILENAME = "./conf/map_darkstar.conf";

	srand((uint32)time(NULL));
	WELL512::seed((uint32)time(NULL));

	map_config_default();
	map_config_read(MAP_CONF_FILENAME);
	ShowMessage("\t\t\t - " CL_GREEN"[OK]" CL_RESET"\n");
 	ShowStatus("do_init: map_config is reading");
	ShowMessage("\t\t - " CL_GREEN"[OK]" CL_RESET"\n");

	luautils::init();
    CmdHandler.init(luautils::LuaHandle);
    PacketParserInitialize();
	SqlHandle = Sql_Malloc();

	ShowStatus("do_init: sqlhandle is allocating");
	if( Sql_Connect(SqlHandle,map_config.mysql_login,
							  map_config.mysql_password,
							  map_config.mysql_host,
							  map_config.mysql_port,
							  map_config.mysql_database) == SQL_ERROR )
	{
		exit(EXIT_FAILURE);
	}
    Sql_Keepalive(SqlHandle);

    // отчищаем таблицу сессий при старте сервера (временное решение, т.к. в кластере это не будет работать)
    Sql_Query(SqlHandle, "TRUNCATE TABLE accounts_sessions");

	ShowMessage("\t\t - " CL_GREEN"[OK]" CL_RESET"\n");
	ShowStatus("do_init: zlib is reading");
	zlib_init();
	ShowMessage("\t\t\t - " CL_GREEN"[OK]" CL_RESET"\n");

	ShowStatus("do_init: loading items");
    itemutils::Initialize();
	ShowMessage("\t\t\t - " CL_GREEN"[OK]" CL_RESET"\n");

	// нужно будет написать один метод для инициализации всех данных в battleutils
	// и один метод для освобождения этих данных

	ShowStatus("do_init: loading spells");
	spell::LoadSpellList();
	mobSpellList::LoadMobSpellList();
	ShowMessage("\t\t\t - " CL_GREEN"[OK]" CL_RESET"\n");

    charutils::ResetAllTwoHours();
	guildutils::Initialize();
	charutils::LoadExpTable();
    linkshell::LoadLinkshellList();
    traits::LoadTraitsList();
    effects::LoadEffectsParameters();
	battleutils::LoadSkillTable();
	meritNameSpace::LoadMeritsList();
	nameSpaceUnlockableWeapons::LoadUnlockableWeaponList();
	ability::LoadAbilitiesList();
	battleutils::LoadWeaponSkillsList();
	battleutils::LoadMobSkillsList();
	battleutils::LoadEnmityTable();
    battleutils::LoadSkillChainDamageModifiers();
	petutils::LoadPetList();
	conquest::LoadConquestSystem();
	mobutils::LoadCustomMods();

	ShowStatus("do_init: loading zones");
	zoneutils::LoadZoneList();
	ShowMessage("\t\t\t - " CL_GREEN"[OK]" CL_RESET"\n");

	luautils::OnServerStart();
    fishingutils::LoadFishingMessages();

	ShowStatus("do_init: server is binding with port %u",map_config.usMapPort);
	map_fd = makeBind_udp(map_config.uiMapIp,map_config.usMapPort);
	ShowMessage("\t - " CL_GREEN"[OK]" CL_RESET"\n");

    CVanaTime::getInstance()->setCustomOffset(map_config.vanadiel_time_offset);

	CTaskMgr::getInstance()->AddTask("time_server", gettick(), NULL, CTaskMgr::TASK_INTERVAL, time_server, 2400);
	CTaskMgr::getInstance()->AddTask("map_cleanup", gettick(), NULL, CTaskMgr::TASK_INTERVAL, map_cleanup, 5000);
	CTaskMgr::getInstance()->AddTask("garbage_collect", gettick(), NULL, CTaskMgr::TASK_INTERVAL, map_garbage_collect, 15 * 60 * 1000);

	CREATE(g_PBuff,   int8, map_config.buffer_size + 20);
    CREATE(PTempBuff, int8, map_config.buffer_size + 20);
	aFree((void*)map_config.mysql_login);
	aFree((void*)map_config.mysql_password);
	ShowStatus("The map-server is " CL_GREEN"ready" CL_RESET" to work...\n");
    ShowMessage("=======================================================================\n");
	return 0;
}
예제 #19
0
int convert_login(void)
{
	Sql* mysql_handle;
	SqlStmt* stmt;
	int line_counter = 0;
	FILE *fp;
	int account_id, logincount, user_level, state, n, i;
	char line[2048], userid[2048], pass[2048], lastlogin[2048], sex, email[2048], error_message[2048], last_ip[2048], memo[2048];
	int ban_until_time, connect_until_time;
	char dummy[2048];

	mysql_handle = Sql_Malloc();
	if ( SQL_ERROR == Sql_Connect(mysql_handle, db_server_id, db_server_pw, db_server_ip, db_server_port, db_server_logindb) )
	{
		Sql_ShowDebug(mysql_handle);
		Sql_Free(mysql_handle);
		exit(EXIT_FAILURE);
	}
	ShowStatus("Connect: Success!\n");
	
	ShowStatus("Convert start...\n");
	fp = fopen(ACCOUNT_TXT_NAME,"r");
	if(fp == NULL)
		return 0;

	while(fgets(line,sizeof(line),fp) != NULL)
	{
		line_counter++;
		if(line[0]=='/' && line[1]=='/')
			continue;

		i = sscanf(line, "%d\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%d\t%[^\t]\t%[^\t]\t%d\t%[^\t]\t%[^\t]\t%d\t%[^\r\n]%n",
			&account_id, userid, pass, lastlogin, &sex, &logincount, &state,
			email, error_message, &connect_until_time, last_ip, memo, &ban_until_time, dummy, &n);

		if (i < 13) {
			ShowWarning("Skipping incompatible data on line %d\n", line_counter);
			continue;
 		}

		if (i > 13)
			ShowWarning("Reading login account variables is not implemented, data will be lost! (line %d)\n", line_counter);

		user_level = isGM(account_id);
		ShowInfo("Converting user (id: %d, name: %s, gm level: %d)\n", account_id, userid, user_level);
		
		stmt = SqlStmt_Malloc(mysql_handle);
		if( SQL_ERROR == SqlStmt_Prepare(stmt, 
			"REPLACE INTO `login` "
			"(`account_id`, `userid`, `user_pass`, `lastlogin`, `sex`, `logincount`, `email`, `level`, `error_message`, `connect_until`, `last_ip`, `memo`, `ban_until`, `state`) "
			"VALUES "
			"(%d, ?, ?, '%s', '%c', %d, '%s', %d, '%s', %d, '%s', '%s', %d, %d)",
			account_id, lastlogin, sex, logincount, email, user_level, error_message, connect_until_time, last_ip, memo, ban_until_time, state)
		||	SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_STRING, userid, strnlen(userid, 255))
		||	SQL_ERROR == SqlStmt_BindParam(stmt, 1, SQLDT_STRING, pass, strnlen(pass, 32))
		||	SQL_ERROR == SqlStmt_Execute(stmt) )
		{
			SqlStmt_ShowDebug(stmt);
		}
		SqlStmt_Free(stmt);
	
		//TODO: parse the rest of the line to read the login-stored account variables, and import them to `global_reg_value`
		//      then remove the 'dummy' buffer
	}
	fclose(fp);
	Sql_Free(mysql_handle);

	ShowStatus("Convert end...\n");

	return 0;
}