Here is a trick around it:
-First of all, create an accound at <a href='http://www.no-ip.com' target='_blank'>No-IP.com</a>, add a new host and update your ip, let's use test.servegame.com to show how it works.
-download the IP update program from no-ip.com, make it execute as a service at windows, it will update the DNs with your ip every time it changes.
-open game.h and add the following lines:
Code: Select all
void GetIPByDNS();
char m_cLogServerAddrBuffer[100];
where is
strcpy(m_cLogServerAddr, xxx.xxx.xxx.xxx <- some IP);
replace with
Code: Select all
strcpy(m_cLogServerAddrBuffer, "test.servegame.com");
Code: Select all
void CGame::GetIPByDNS()
{
ZeroMemory(m_cLogServerAddr, sizeof(m_cLogServerAddr));
if (m_cLogServerAddrBuffer[0] >= 65 && m_cLogServerAddrBuffer[0] <= 122) {
char cDnsResult[40];
struct hostent *host_entry;
host_entry = gethostbyname(m_cLogServerAddrBuffer);
if (host_entry == NULL){
MessageBox(m_hWnd, "Failed to get DNS entry for the logserver!", "ERROR1", MB_ICONEXCLAMATION | MB_OK);
_exit(0);
}
ZeroMemory(cDnsResult, sizeof(cDnsResult));
wsprintf(cDnsResult, "%d.%d.%d.%d",
( host_entry->h_addr_list[0][0] & 0x00ff ),
( host_entry->h_addr_list[0][1] & 0x00ff ),
( host_entry->h_addr_list[0][2] & 0x00ff ),
( host_entry->h_addr_list[0][3] & 0x00ff ));
strcpy(m_cLogServerAddr, cDnsResult);
}
else strcpy(m_cLogServerAddr, m_cLogServerAddrBuffer);
}
m_pLSock = new class XSocket(m_hWnd, DEF_SOCKETBLOCKLIMIT);
add:
Code: Select all
GetIPByDNS();
Thats it.