Exemplo n.º 1
0
// Start gui handler
void kaillera_GUI(){
	char kaillera_server[128];

	nSettings::get_str("kaillera_server", kaillera_server, 128);
	ParseServerAddress(kaillera_server);

	KAILLERA_CORE_INITIALIZED = true;
	strcpy(kaillera_sdlg_NAME, KLSNST_temp.hostname);

	char un[32];
	nSettings::get_str("username", un, 32);

	char conset = nSettings::get_int("kaillera_cns") + 1;

	if (kaillera_core_initialize(0, APP, un, conset)) {
		Sleep(150);
	        
		kaillera_core_connect(KLSNST_temp.hostname, KLSNST_temp.port);

		while (1) {
			Sleep(100);
			if (kaillera_is_connected()) {
				//kaillera_game_debug("Connected to %s (%i users & %i games)", );
				kaillera_game_debug("Connected to ...");
				break;
			}
		}

		// Emulate activity
		Sleep(3000);
		if (CURRENT_ID != -1) {
			kaillera_join_game(CURRENT_ID);
		}
		else {
			strcpy(GAME, gamelist);
			kaillera_create_game(GAME);
		}


		while (!PDROPPED) Sleep(100);
		
		//disconnect
		char quitmsg[128];
		//GetWindowText(GetDlgItem(kaillera_ssdlg, IDC_QUITMSG), quitmsg, 128);
		kaillera_disconnect(quitmsg);
		kaillera_core_cleanup();
		
		KSSDFA.state = 0;
		KSSDFA.input = KSSDFA_END_GAME;

		PDROPPED = false;
		CURRENT_ID = -1;
		GAME[0] = 0;
	} else {
		//MessageBox(pDlg, "Core Initialization Failed", 0, 0);
	}
}
Exemplo n.º 2
0
bool kaillera_core_initialize(int port, char * appname, char * username, char connection_setting){
	p2p_InitializeTime();
	
	if (kaillera_core_initialized) kaillera_core_cleanup();
	
	KAILLERAC.PORT = port;
	KAILLERAC.conset = connection_setting;
	
	strncpy(KAILLERAC.APP, appname, 128);
	strncpy(KAILLERAC.USERNAME, username, 32);
	
	KAILLERAC.connection = new k_message;
	if (!KAILLERAC.connection->initialize(KAILLERAC.PORT)){
		return false;
	}
	KAILLERAC.PORT = KAILLERAC.connection->get_port();
	
	kaillera_core_initialized = true;
	
	return true;
}