• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Tutorial Auto IP & Resolve IP by DNS

Kyron

walking
Joined
Jun 1, 2007
Messages
25
Reaction score
0
Location
algum lugar no MS
Desenvolvido por Raphael Carnaúba.

Code:
Fiz esse code a 2 dias atrás, mais não quiz liberar...depois de meus amigos pedirem descidi liberar pro OTplanet

(SVN)
Vá em otserv.cpp e procure por :

[code] if(argc > 1)
   ip = argv[1];
  else
   ip = g_config.getString(ConfigManager::IP);


Substitua por:
Code:
     if( g_config.getString(ConfigManager::IP) == "auto" )
     {
         if( gethostname( szHostName , 128) == 0 )
         {
              struct hostent* he = gethostbyname( szHostName );
            
              if( he != NULL )
              {
                  ip = inet_ntoa( * ( reinterpret_cast< in_addr* >( he->h_addr )));
              }
         }
     }  
    
     else{
  if(argc > 1)
   ip = argv[1];
  else
   ip = g_config.getString(ConfigManager::IP);
     }

Se você usa Forgotten Server ou Evolutions:

Procure por:


Code:
  ip = g_config.getString(ConfigManager::IP);

Substitua por:

Code:
    if( g_config.getString(ConfigManager::IP) == "auto" )
     {
         if( gethostname( szHostName , 128) == 0 )
         {
              struct hostent* he = gethostbyname( szHostName );
            
              if( he != NULL )
              {
                  ip = inet_ntoa( * ( reinterpret_cast< in_addr* >( he->h_addr )));
              }
         }
     }  
    
     else{
   ip = g_config.getString(ConfigManager::IP);
     }



Auto IP Terminado


Agora se você quer algo diferente como por exemplo você colocar
no seu ip no config.lua seuserver.servegame.com

Use esse codigo:

(SVN)
Procure por:

Code:
     if(argc > 1)
   ip = argv[1];
  else
   ip = g_config.getString(ConfigManager::IP);

E substitua por :

Code:
   struct hostent* he = gethostbyname(g_config.getString(ConfigManager::IP));
   if( he != NULL )
   {
       ip = inet_ntoa( * ( reinterpret_cast< in_addr* >( he->h_addr )));
   }
   else{
       std::cout << "Could not resolve host address " << ip << std::endl;
       std::cout << "IP now is 127.0.0.1" << std::endl;
       ip = "127.0.0.1";
   }


Se você usa Evolutions ou Forgotten Server:

Troque:
Code:
     ip = g_config.getString(ConfigManager::IP);
por:

Code:
   struct hostent* he = gethostbyname(g_config.getString(ConfigManager::IP));
   if( he != NULL )
   {
       ip = inet_ntoa( * ( reinterpret_cast< in_addr* >( he->h_addr )));
   }
   else{
       std::cout << "Could not resolve host address " << ip << std::endl;
       std::cout << "IP now is 127.0.0.1" << std::endl;
       ip = "127.0.0.1";
   }

Creditos:

Raphael Carnaúba
[/code]
 
Back
Top