diff options
author | proller <proller@github.com> | 2013-06-23 11:31:22 +0400 |
---|---|---|
committer | proller <proller@github.com> | 2013-06-23 11:31:22 +0400 |
commit | f960c3be313c761fe02f9167dc1fe3fca5dc4ada (patch) | |
tree | 54543a7e61e6ed273840d9bcba6bc9655add5243 /src/game.cpp | |
parent | 309c5f3641dccaf1260953f098ccd593396dee64 (diff) | |
download | minetest-f960c3be313c761fe02f9167dc1fe3fca5dc4ada.tar.gz minetest-f960c3be313c761fe02f9167dc1fe3fca5dc4ada.tar.bz2 minetest-f960c3be313c761fe02f9167dc1fe3fca5dc4ada.zip |
Add support for IPv6
Two new configuration options are added:
- "enable_ipv6" to enable/disable the overall use of IPv6
- "ipv6_server" to enable/disable the use of IPv6 sockets when running
a server (when "enable_ipv6" is enabled)
Diffstat (limited to 'src/game.cpp')
-rw-r--r-- | src/game.cpp | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/game.cpp b/src/game.cpp index 833117959..e4019e472 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1039,12 +1039,6 @@ void the_game( infostream<<"Creating client"<<std::endl; MapDrawControl draw_control; - - Client client(device, playername.c_str(), password, draw_control, - tsrc, shsrc, itemdef, nodedef, sound, &eventmgr); - - // Client acts as our GameDef - IGameDef *gamedef = &client; { wchar_t* text = wgettext("Resolving address..."); @@ -1054,18 +1048,39 @@ void the_game( Address connect_address(0,0,0,0, port); try{ if(address == "") + { //connect_address.Resolve("localhost"); - connect_address.setAddress(127,0,0,1); + if(g_settings->getBool("enable_ipv6") && g_settings->getBool("ipv6_server")) + { + IPv6AddressBytes addr_bytes; + addr_bytes.bytes[15] = 1; + connect_address.setAddress(&addr_bytes); + } + else + { + connect_address.setAddress(127,0,0,1); + } + } else connect_address.Resolve(address.c_str()); } catch(ResolveError &e) { - error_message = L"Couldn't resolve address"; + error_message = L"Couldn't resolve address: " + narrow_to_wide(e.what()); errorstream<<wide_to_narrow(error_message)<<std::endl; // Break out of client scope break; } + + /* + Create client + */ + Client client(device, playername.c_str(), password, draw_control, + tsrc, shsrc, itemdef, nodedef, sound, &eventmgr, + connect_address.isIPv6()); + + // Client acts as our GameDef + IGameDef *gamedef = &client; /* Attempt to connect to the server |