[SAMMELTHREAD] Game Source Changes

01/05/2014 12:51 JachuPL#211
Fix for "can not get public ip address" message on startup
File: config.cpp
Change this function
Code:
bool GetIPInfo()
{
#ifndef __WIN32__
	struct ifaddrs* ifaddrp = NULL;

	if (0 != getifaddrs(&ifaddrp))
		return false;

	for( struct ifaddrs* ifap=ifaddrp ; NULL != ifap ; ifap = ifap->ifa_next )
	{
		struct sockaddr_in * sai = (struct sockaddr_in *) ifap->ifa_addr;

		if (!ifap->ifa_netmask ||  // ignore if no netmask
				sai->sin_addr.s_addr == 0 || // ignore if address is 0.0.0.0
				sai->sin_addr.s_addr == 16777343) // ignore if address is 127.0.0.1
			continue;
#else
	WSADATA wsa_data;
	char host_name[100];
	HOSTENT* host_ent;
	int n = 0;

	if (WSAStartup(0x0101, &wsa_data)) {
		return false;
	}

	gethostname(host_name, sizeof(host_name));
	host_ent = gethostbyname(host_name);
	if (host_ent == NULL) {
		return false;
	}
	for ( ; host_ent->h_addr_list[n] != NULL; ++n) {
		struct sockaddr_in addr;
		struct sockaddr_in* sai = &addr;
		memcpy(&sai->sin_addr.s_addr, host_ent->h_addr_list[n], host_ent->h_length);
#endif

		char * netip = inet_ntoa(sai->sin_addr);

		if (!strncmp(netip, "192.168", 7)) // ignore if address is starting with 192
		{
			strlcpy(g_szInternalIP, netip, sizeof(g_szInternalIP));
#ifndef __WIN32__
			fprintf(stderr, "INTERNAL_IP: %s interface %s\n", netip, ifap->ifa_name);
#else
			fprintf(stderr, "INTERNAL_IP: %s\n", netip);
#endif
		}
		else if (!strncmp(netip, "10.", 3))
		{
			strlcpy(g_szInternalIP, netip, sizeof(g_szInternalIP));
#ifndef __WIN32__
			fprintf(stderr, "INTERNAL_IP: %s interface %s\n", netip, ifap->ifa_name);
#else
			fprintf(stderr, "INTERNAL_IP: %s\n", netip);
#endif
		}
		else if (g_szPublicIP[0] == '0')
		{
			strlcpy(g_szPublicIP, netip, sizeof(g_szPublicIP));
#ifndef __WIN32__
			fprintf(stderr, "PUBLIC_IP: %s interface %s\n", netip, ifap->ifa_name);
#else
			fprintf(stderr, "PUBLIC_IP: %s\n", netip);
#endif
		}
	}

#ifndef __WIN32__
	freeifaddrs( ifaddrp );
#else
	WSACleanup();
#endif

	if (g_szPublicIP[0] != '0')
		return true;
	else
		return false;
}
To this
Code:
bool GetIPInfo()
{
#ifndef __WIN32__
	struct ifaddrs* ifaddrp = NULL;

	if (0 != getifaddrs(&ifaddrp))
		return false;

	for( struct ifaddrs* ifap=ifaddrp ; NULL != ifap ; ifap = ifap->ifa_next )
	{
		struct sockaddr_in * sai = (struct sockaddr_in *) ifap->ifa_addr;

		if (!ifap->ifa_netmask ||  // ignore if no netmask
				sai->sin_addr.s_addr == 0 || // ignore if address is 0.0.0.0
				sai->sin_addr.s_addr == 16777343) // ignore if address is 127.0.0.1
			continue;
#else
	WSADATA wsa_data;
	char host_name[100];
	HOSTENT* host_ent;
	int n = 0;

	if (WSAStartup(0x0101, &wsa_data)) {
		return false;
	}

	gethostname(host_name, sizeof(host_name));
	host_ent = gethostbyname(host_name);
	if (host_ent == NULL) {
		return false;
	}
	for ( ; host_ent->h_addr_list[n] != NULL; ++n) {
		struct sockaddr_in addr;
		struct sockaddr_in* sai = &addr;
		memcpy(&sai->sin_addr.s_addr, host_ent->h_addr_list[n], host_ent->h_length);
#endif

		char * netip = inet_ntoa(sai->sin_addr);

		if (!strncmp(netip, "111.111", 7)) // ignore if address is starting with 192
		{
			strlcpy(g_szInternalIP, netip, sizeof(g_szInternalIP));
#ifndef __WIN32__
			fprintf(stderr, "INTERNAL_IP: %s interface %s\n", netip, ifap->ifa_name);
#else
			fprintf(stderr, "INTERNAL_IP: %s\n", netip);
#endif
		}
		else if (!strncmp(netip, "10.", 3))
		{
			strlcpy(g_szInternalIP, netip, sizeof(g_szInternalIP));
#ifndef __WIN32__
			fprintf(stderr, "INTERNAL_IP: %s interface %s\n", netip, ifap->ifa_name);
#else
			fprintf(stderr, "INTERNAL_IP: %s\n", netip);
#endif
		}
		else if (g_szPublicIP[0] == '0')
		{
			strlcpy(g_szPublicIP, netip, sizeof(g_szPublicIP));
#ifndef __WIN32__
			fprintf(stderr, "PUBLIC_IP: %s interface %s\n", netip, ifap->ifa_name);
#else
			fprintf(stderr, "PUBLIC_IP: %s\n", netip);
#endif
		}
	}

#ifndef __WIN32__
	freeifaddrs( ifaddrp );
#else
	WSACleanup();
#endif

	if (g_szPublicIP[0] != '0')
		return true;
	else
		return false;
}
01/08/2014 13:03 MrFrancisc#212
I have new errors: :(

[Only registered and activated users can see links. Click Here To Register...]

Thank.
01/08/2014 14:06 Sphinx²#213
Quote:
Originally Posted by MrFrancisc View Post
I have new errors: :(

[Only registered and activated users can see links. Click Here To Register...]

Thank.
Du machst alles kaputt....
01/08/2014 14:23 Sujino#214
Some one get fixxed the unknown packet header errors?
01/08/2014 16:00 WildGamers-Metin2#215
Quote:
Originally Posted by Sujino View Post
Some one get fixxed the unknown packet header errors?
Yes i did :D
01/08/2014 18:04 Evor™#216
@up
Can u share ur work?
Anyone have fix for DB which can read from mysql instead of reading from .txt?
01/08/2014 18:54 IchVerabschiedeMich#217
Quote:
Originally Posted by Evor™ View Post
Anyone have fix for DB which can read from mysql instead of reading from .txt?
Dissable Textfile Protos

File: ClientManagerBoot.cpp
Comment out (CTRL + K + C) lines 23 - 26 and 35 - 39.

Should look like this:
[Only registered and activated users can see links. Click Here To Register...]
01/08/2014 19:11 MrFrancisc#218
Quote:
Originally Posted by Sphinx² View Post
Du machst alles kaputt....
Well as you know all
01/08/2014 19:12 RageAtMeBros#219
Quote:
Originally Posted by Padrio View Post
Dissable Textfile Protos

File: ClientManagerBoot.cpp
Comment out (CTRL + K + C) lines 23 - 26 and 35 - 39.

Should look like this:
[Only registered and activated users can see links. Click Here To Register...]
I didn't checked it really that much but I think that it reads from the .TXT tables and mysql is worthless.

Correct me if wrong please, I already had bypassed the Mirror Functions and I think it uses the data from txt instead of mysql, if not cool.
01/08/2014 19:52 Sujino#220
Quote:
Originally Posted by WildGamers-Metin2 View Post
Yes i did :D
Can u told us how u did it? Because i dont know how i can find the packet
which is wrong.... My Packet Error:

Code:
0108 14:26:53983 :: Unknown packet header: 160, last: 3 81
I can login and "play" for hmm maybe 5 Min. and then i get kicked and cant login even if i see the ground i got kicked again...
01/08/2014 20:42 miszczuuuuu#221
Quote:
Originally Posted by Sujino View Post
Can u told us how u did it? Because i dont know how i can find the packet
which is wrong.... My Packet Error:

Code:
0108 14:26:53983 :: Unknown packet header: 160, last: 3 81
I can login and "play" for hmm maybe 5 Min. and then i get kicked and cant login even if i see the ground i got kicked again...
Create a new char in game
01/08/2014 20:48 Evor™#222
So, I came up with good idea.
What about auto-striping game file?
We have the whole source so te debug symbols are just useless.
Manual way:
Simply write in the command line:
strip name_of_the_game_file
for example)
strip game_r32
Automatical way:
go to path_to_the_source/Server/game/src and open the Makefile, next find the string:
Quote:
default: $(TARGET) $(TEST_TARGET)
and change it to:
Quote:
default: $(TARGET) // I've delete TEST_TARGET becouse it's useless too.
[TAB]@strip $(TARGET)
That's all.
Greetings from Poland :)
PS. If sb want's the version with dbg symbols generate automatically simply change first quote into:
Quote:
default: $(TARGET) // I've delete TEST_TARGET becouse it's useless too.
[TAB] @objcopy --only-keep-debug $(TARGET) $(TARGET).dbg // it'll generate the .dbg file next to the game file
[TAB]@strip $(TARGET)
PS2.
Remember replacing [TAB] with real Tab-key :)
01/08/2014 20:53 Nell™#223
hat jemand eine passende exe auf den gamecore ?
01/08/2014 21:21 .Captor#224
Hier mal ein Change von mir:


Bewirkt?: Man muss wenn man z.B. die Game usw auf Windows laufen lässt nicht in das GameCore verzeichnis die "locale" und "data" Ordner packen, sondern einfach wie gewoht "/share/". :)

PS: Funktioniert nur für "germany"!

Viel Spaß!
01/08/2014 22:11 GunnerMBT#225
Quote:
Originally Posted by Evor™ View Post
So, I came up with good idea.
What about auto-striping game file?
We have the whole source so te debug symbols are just useless.
Manual way:
Simply write in the command line:
strip name_of_the_game_file
for example)
strip game_r32
Automatical way:
go to path_to_the_source/Server/game/src and open the Makefile, next find the string:
and change it to:

That's all.
Greetings from Poland :)
PS. If sb want's the version with dbg symbols generate automatically simply change first quote into:

PS2.
Remember replacing [TAB] with real Tab-key :)
Well, the debug symbols may be handy when you're actually debugging the file... So, stripping it would only be wise if you're sure it's a stable and decently tested release imo.