Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > General Coding
You last visited: Today at 21:43

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[PROBLEM] Metin2 Server State

Discussion on [PROBLEM] Metin2 Server State within the General Coding forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 577
Join Date: Oct 2009
Posts: 665
Received Thanks: 3,502
[PROBLEM] Metin2 Server State

Hallo,

Mein Clientless-Bot soll beim Serverselect auch die jeweiligen Channels und ihre States anzeigen. (STATES=...,NORM,BUSY,FULL).
Wenn ich den folgenden Code benutze, bekomme ich bei allen Channels STATE_NORM zurück, obwohl dieselben im Metin2-Client als BUSY angezeigt werden. Ich hoffe jemand kann mir helfen.

MfG tim.

EDIT: Problem gefunden & gelöst!.

Code:
/* ServerStateChecker implementation */

void NetworkStream::ServerStateChecker::Create(uint16_t port)
{
	m_socket = socket(AF_INET, SOCK_DGRAM, 0);
	m_sig = 0;

	if(m_socket != -1) {
		u_long argp = 1;

		m_addr.sin_family = AF_INET;
		m_addr.sin_addr.s_addr = 0;
		m_addr.sin_port = htons((u_short)port);

		ioctlsocket(m_socket, FIONBIO, &argp);

		if(bind(m_socket, (sockaddr*)&m_addr, sizeof(sockaddr_in)) == -1)
			throw _("NetworkStream::ServerStateChecker::Create(): Unable to bind sockaddr_in to socket.");
	}else
		throw _("NetworkStream::ServerStateChecker::Create(): Unable to create socket.");
}

void NetworkStream::ServerStateChecker::Destroy()
{
	if(m_socket != -1)
		closesocket(m_socket);

	m_addr.sin_addr.s_addr = 0;
}

int NetworkStream::ServerStateChecker::Update()
{
	if(m_socket == -1)
		throw _("NetworkStream::ServerStateChecker::Update(): Not initialized.");

	char buf[10];
	bool isRetry = false;
	int len, size = sizeof(sockaddr_in);

check_for_state:
	if((len = recvfrom(m_socket, buf, 10, 0, (sockaddr*)&m_addr, &size)) == 10) {
		if(buf[0] > 3 || buf[1] != m_sig)
			throw _("NetworkStream::ServerStateChecker::Update(): invalid server state.");

		return buf[0];
	}else{
		if(WSAGetLastError() == WSAEWOULDBLOCK) {
			if(isRetry == false) {
				Sleep(250);
				isRetry = true;
				goto check_for_state;
			}

			// Unable to get server state.
			return 0;
		}

		throw _("NetworkStream::ServerStateChecker::Update(): packet size is wrong.");
	}
}

void NetworkStream::ServerStateChecker::Request(int key, const char* ip, uint16_t port)
{
	if(m_socket == -1)
		throw _("NetworkStream::ServerStateChecker::Request(): Not initialized.");

	m_addr.sin_addr = GetInetAddress(ip);
	m_addr.sin_port = htons((u_short)port);

	char buf[9];

	buf[0] = 1; // Packet Type: kGetServerState
	buf[1] = m_sig;
	buf[2] = m_sig >> 8;
	buf[3] = m_sig >> 16;
	buf[4] = m_sig >> 24;
	buf[5] = key;
	buf[6] = key >> 8;
	buf[7] = key >> 16;
	buf[8] = key >> 24;

	sendto(m_socket, buf, 9, 0, (sockaddr*)&m_addr, sizeof(sockaddr_in));
}
tim66613 is offline  
Thanks
5 Users
Old 12/13/2010, 18:36   #2
 
elite*gold: 0
Join Date: Nov 2010
Posts: 15
Received Thanks: 1
Danke, jetzt komm ich weiter ^^
Checka96 is offline  
Old 04/14/2011, 15:26   #3
 
elite*gold: 0
Join Date: Jun 2009
Posts: 52
Received Thanks: 6
where to put this text?
useluker is offline  
Old 11/21/2011, 19:43   #4
 
elite*gold: 3
Join Date: May 2009
Posts: 772
Received Thanks: 109
Könntest du den mal bitte uploaden oder nur einen clientless einlogger
Orban is offline  
Reply

Tags
winsock


Similar Threads Similar Threads
State of Hacking in Aion
11/09/2010 - Aion - 9 Replies
Hi everybody.. i want to start a little discussion on Aion and hacking. First of all, i'm not actualy a big fan of hacking, but I always try to do as much as I can to stay at the top when playing a game.. So when there are safe to use hacks out there I use them. As far as I know there are bots out there, I think that is something that we will never get rid of. Then there is some Memory hacking like jump hacks/speed hacks and so on.. so what do you think, will Aion be a hacker paradise or...
State of CO/Botting:
05/07/2008 - Conquer Online 2 - 9 Replies
*Note I will be posting this on 2 forums, so if you see it at another gaming forum don't worry* State of CO: Alot has changed in the past year in CO, because of some patches that have been introduced. Many servers have had their top players move onto other games or quit playing entirely and many servers economies were messed up when nobility was introduced (a few still haven't recovered), "potency-locked" items, merchant accounts are just a few more that had contributed to more than one...



All times are GMT +1. The time now is 21:43.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.