コード例 #1
0
void kaillera_user_kicked_callback(){
	kaillera_ui_trace("kaillera_user_kicked_callback()");
	kaillera_error_callback("* You have been kicked out of the game");
	KSSDFA.input = KSSDFA_END_GAME;
	KSSDFA.state = 0;
	PDROPPED = true;
//	kaillera_sdlgNormalMode();
}
コード例 #2
0
ファイル: kaillera_core.cpp プロジェクト: RDCH106/p2pkaillera
bool kaillera_core_connect(char * ip, int port){
	
	kaillera_core_debug("Connecting to %s:%i", ip, port);
	
	strncpy(KAILLERAC.IP, ip, 128);
	
	k_socket ksock;
	ksock.initialize(0, 2048);
	
	if (ksock.set_address(ip, port)){
		ksock.send("HELLO0.83", 10); // Client's hello message
		
		DWORD tout = p2p_GetTime();
		
		while ((!k_socket::check_sockets(0, 100) || !ksock.has_data()) && p2p_GetTime() - tout < KAILLERA_CONNECTION_RESP_MAX_DELAY);
		
		if (ksock.has_data()) {

			char srsp[256];
			int srspl = 256;
			sockaddr_in addr;
			
			kaillera_core_debug("server replied");
			
			if (ksock.check_recv(srsp, &srspl, false, &addr)) {
				if (strncmp("HELLOD00D", srsp, 9) == 0) { // Server's hello reply
					
					kaillera_core_debug("logging in");
					
					addr.sin_port = htons(atoi(srsp+9));
					KAILLERAC.connection->set_addr(&addr);
					KAILLERAC.USERSTAT = 1;
					KAILLERAC.PLAYERSTAT = -1;
					
					k_instruction ki;
					ki.type = USERLOGN;
					ki.store_string(KAILLERAC.APP);
					ki.store_char(KAILLERAC.conset);
					/* Old code to append "--FakePing" to the username
					if(spoofing)
					{
						//char tempbuff[32];
						//strcpy(tempbuff,KAILLERAC.USERNAME);
						//snprintf(KAILLERAC.USERNAME,32,"%s--FakePing",tempbuff);
					}*/
					ki.set_username(KAILLERAC.USERNAME);
					
					KAILLERAC.connection->send_instruction(&ki);

					// Credits to Fireblaster for showing me the code that taught me
					// I needed to pong 4 times.
					// If you take a minute to think about it, this ping spoofing code
					// is simple and makes perfect sense.
					if(spoofing)
					{
						Sleep(spoofPing);
						SendPong();
						Sleep(spoofPing);
						SendPong();
						Sleep(spoofPing);
						SendPong();
						Sleep(spoofPing);
						SendPong();
					}

					return true;
				}
			} else {
				if (strcmp("TOO", srsp)==0) { // Too many users
					kaillera_error_callback("Server is full");
				} else {
					kaillera_core_debug("server protocol mismatch or other error");
					//protocol different or unrecognized protocol
				}
			}

		}
		
		return false;
	}
	return false;
}