Jump to content

Select character on 40k for Local Server and VPS


Karbust

Recommended Posts

  • Web Developer

Sup bois and grils

I still see a lot of people not being able to select the character when using a local server for friends or VPS behind a internal router or firewall.

Disclaimer: This code wasn't made by me, it was originally posted on the metin2dev's French brother Funky-Emu by @Veltor88.

 

On service.h add this:

#define ENABLE_PROXY_IP

 

On char.cpp:
After:

	p.lAddr	= lAddr;

Add:

	#ifdef ENABLE_PROXY_IP
	if (!g_stProxyIP.empty())
		p.lAddr = inet_addr(g_stProxyIP.c_str());
	#endif

Like this:

1406391.png

 

On config.cpp:
After (or anywhere within the global variables definition): 

char		g_szInternalIP[16]

Add:

#ifdef ENABLE_PROXY_IP
std::string	g_stProxyIP = "";
#endif

Like this:
1406392.png

 

Still on config.cpp:
After: the last TOKEN
Add:

		#ifdef ENABLE_PROXY_IP
		TOKEN("proxy_ip")
		{
			g_stProxyIP = value_string;
		}
		#endif

Like this:
1406393.png

 

On config.h:
After (or anywhere in the file):

extern char		g_szInternalIP[16];

Add:

#ifdef ENABLE_PROXY_IP
extern std::string	g_stProxyIP;
#endif

Like this:
1406394.png

 

On desc.cpp:
Within the function:

void DESC::SendLoginSuccessPacket()

Inside: 

for (int i = 0; i < PLAYER_PER_ACCOUNT; ++i)


Add in the beginning:

		#ifdef ENABLE_PROXY_IP
		if (!g_stProxyIP.empty())
			rTable.players[i].lAddr=inet_addr(g_stProxyIP.c_str());
		#endif

Like this:
1406395.png

 

On input_db.cpp:
Withing the function:

bool GetServerLocation(TAccountTable & rTab, BYTE bEmpire)

After:

						rTab.players[i].szName);

Add:

				#ifdef ENABLE_PROXY_IP
				if (!g_stProxyIP.empty())
					rTab.players[i].lAddr=inet_addr(g_stProxyIP.c_str());
				#endif


                
Still on input_db.cpp and within the same function:
After:

struct in_addr in;

Add:

		#ifdef ENABLE_PROXY_IP
		if (!g_stProxyIP.empty())
			rTab.players[i].lAddr=inet_addr(g_stProxyIP.c_str());
		#endif

Like this:
1406396.png

 

Still on the same file:
Within the function:

void CInputDB::PlayerCreateSuccess(LPDESC d, const char * data)

After:

	pack.player = pPacketDB->player;

Add:

	#ifdef ENABLE_PROXY_IP
	if (!g_stProxyIP.empty())
		pack.player.lAddr=inet_addr(g_stProxyIP.c_str());
	#endif

Like this:
1406397.png

 

Done on the source, you can compile.


On every channel config, add this:

BIND_IP: <Private IPv4 IP> (it will be something within a private IP class. Check the IP of the machine using the "ifconfig" command)
PROXY_IP: <Public IPv4 IP> (check out something like https://www.whatismyip.com)

Private IPv4 classes:

1406398.png

On some sources (like the one from vanilla, BIND_IP was renamed to PUBLIC_IP, just check which TOKEN is responsible to set the value on the variable g_szPublicIP.

You will need to open the ports on your router, even for yourself on localhost with the virtual machine because the game server will try to "proxy" you through the public IP you defined.

This wasn't tested using a VPN, like Hamachi or ZeroTier.

  • Metin2 Dev 1
  • Love 4
  • Love 1

QJ0orbR.png

Metin2 Icon Database

Link to comment
Share on other sites

  • 1 year later...


!-->
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.