[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[netPanzer-CVS] netpanzer docs/netpanzer.6 src/Lib/Interfaces/U...
From: |
Hankin Chick |
Subject: |
[netPanzer-CVS] netpanzer docs/netpanzer.6 src/Lib/Interfaces/U... |
Date: |
Thu, 13 Nov 2003 08:12:22 -0500 |
CVSROOT: /cvsroot/netpanzer
Module name: netpanzer
Branch:
Changes by: Hankin Chick <address@hidden> 03/11/13 08:12:20
Modified files:
docs : netpanzer.6
src/Lib/Interfaces: UtilInterface.cpp UtilInterface.hpp
src/NetPanzer/Core: main.cpp
src/NetPanzer/Interfaces: GameConfig.cpp GameConfig.hpp
src/NetPanzer/Interfaces/unix: NetworkClientUnix.cpp
NetworkServerUnix.cpp
src/NetPanzer/Views/MainMenu/Multi: HostJoinTemplateView.cpp
IRCLobby.cpp IRCLobby.hpp
IRCLobbyView.cpp
IRCLobbyView.hpp
src/UILib/Network: ClientSocket.cpp ClientSocket.hpp
Log message:
* Added proxyserver, proxyserveruser,proxyserverpass options,
have to edit xml to use them for now,
so you can play from behind a firewall if you run the server
on port 443, most proxys allow port 443(https).
* reenabled -p port option, should work now.
* fixed not joining lobby if you host a game
* changed no lobby option to lobby_server=none because the option
class couldn't tell the difference between
an empty string from no option at all.
Patches:
Index: netpanzer/docs/netpanzer.6
diff -u netpanzer/docs/netpanzer.6:1.3 netpanzer/docs/netpanzer.6:1.4
--- netpanzer/docs/netpanzer.6:1.3 Tue Nov 11 06:56:42 2003
+++ netpanzer/docs/netpanzer.6 Thu Nov 13 08:12:17 2003
@@ -41,7 +41,7 @@
.B -g, --debug
enable debug output.
.B --lobby-server=VALUE
-Use the specified irc server as lobby server. You can use an empty value to
+Use the specified irc server as lobby server. You can use 'none' to
disable lobby announcement.
.PD
Index: netpanzer/src/Lib/Interfaces/UtilInterface.cpp
diff -u netpanzer/src/Lib/Interfaces/UtilInterface.cpp:1.11
netpanzer/src/Lib/Interfaces/UtilInterface.cpp:1.12
--- netpanzer/src/Lib/Interfaces/UtilInterface.cpp:1.11 Wed Sep 24 13:43:21 2003
+++ netpanzer/src/Lib/Interfaces/UtilInterface.cpp Thu Nov 13 08:12:18 2003
@@ -16,13 +16,16 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <config.h>
+#include <sstream>
#include <sys/stat.h>
#include <string.h>
#include "SplitPath.hpp"
#include "Exception.hpp"
#include "FileSystem.hpp"
+#include "GameConfig.hpp"
#include "UtilInterface.hpp"
+#include "Log.hpp"
bool gSpanBlittingFlag = false;
@@ -138,3 +141,81 @@
srand((unsigned)time(0));
#endif
} // end UtilInterface::startRandomNumberGenerator
+
+
+
+// split server:port string, doesn't always set the port
+void UtilInterface::splitServerPort(const std::string& server,std::string&
address,int *port)
+{
+ unsigned int colon=server.find(':',0);
+ if(colon==std::string::npos) {
+ address=server;
+ }
+ else {
+ address=server.substr(0,colon);
+ colon++;
+ std::string port_str(server.substr(colon,server.length()-colon));
+ port[0]=atoi(port_str.c_str());
+ }
+}
+
+
+void UtilInterface::makeBase64(std::string &base64,std::string &str)
+{
+ static const char
base64_chars[65]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ const char *auth_ptr;
+ char auth_ptr_dest[5];
+
+ auth_ptr_dest[4]=0;
+ base64="";
+ for(auth_ptr=str.c_str(); *auth_ptr; auth_ptr+=3) {
+ auth_ptr_dest[0]='=';
+ auth_ptr_dest[1]='=';
+ auth_ptr_dest[2]='=';
+ auth_ptr_dest[3]='=';
+
+ auth_ptr_dest[0]=base64_chars[(auth_ptr[0]&0xfc) >>2];
+ auth_ptr_dest[1]=base64_chars[((auth_ptr[0]&0x3)
<<4)|((auth_ptr[1]&0xf0)>>4)];
+ if(auth_ptr[1]==0) { base64+=auth_ptr_dest; break; }
+ auth_ptr_dest[2]=base64_chars[((auth_ptr[1]&0xf)
<<2)|((auth_ptr[2]&0xc0)>>6)];
+ if(auth_ptr[2]==0) { base64+=auth_ptr_dest; break; }
+ auth_ptr_dest[3]=base64_chars[((auth_ptr[2]&0x3f))];
+ base64+=auth_ptr_dest;
+ }
+}
+
+
+void UtilInterface::getProxyConnect(std::stringstream &buffer,const
std::string &serveraddress) {
+ if(((const std::string &)gameconfig->proxyserver).size()>0) {
+ buffer << "CONNECT " << serveraddress << " HTTP/1.0\r\n";
+ if(((const std::string &)gameconfig->proxyserveruser).size()>0) {
+ std::string base64;
+ std::string userpass( ((const std::string
&)gameconfig->proxyserveruser) +":"+((const std::string
&)gameconfig->proxyserverpass) );
+ UtilInterface::makeBase64(base64, userpass);
+ buffer << "Authorization: Basic " << base64 << "\r\n";
+ }
+ buffer << "\r\n";
+ }
+}
+
+
+void UtilInterface::sendProxyConnect(TCPsocket socket,const std::string
&serveraddress)
+{
+ std::stringstream buffer;
+
+ getProxyConnect(buffer,serveraddress);
+
+ SDLNet_TCP_Send(socket,const_cast<char*>
(buffer.str().c_str()),buffer.str().size());
+ int lfs=0;
+// XXX grab any http error messages
+ while(1) {
+ char ch;
+ if(SDLNet_TCP_Recv(socket,&ch,1)!=1) { break; }
+ if(ch=='\r') { continue; }
+ if(ch=='\n') { lfs++; }
+ else { lfs=0; }
+ if(lfs>=2) { break; }
+ }
+}
+
+
Index: netpanzer/src/Lib/Interfaces/UtilInterface.hpp
diff -u netpanzer/src/Lib/Interfaces/UtilInterface.hpp:1.6
netpanzer/src/Lib/Interfaces/UtilInterface.hpp:1.7
--- netpanzer/src/Lib/Interfaces/UtilInterface.hpp:1.6 Fri Sep 19 11:22:30 2003
+++ netpanzer/src/Lib/Interfaces/UtilInterface.hpp Thu Nov 13 08:12:18 2003
@@ -19,6 +19,8 @@
#ifndef __UtilInterface_hpp__
#define __UtilInterface_hpp__
+#include <SDL_net.h>
+
#include "String.hpp"
class Filename
@@ -57,6 +59,14 @@
static int getNumFilesInDirectory(String path);
static void checkError(FILE *fp);
static void startRandomNumberGenerator();
+
+ // get servername/port from a string, doesn't always set the port
+ static void splitServerPort(const std::string &server,std::string
&address,int *port);
+ static void makeBase64(std::string &base64,std::string &str);
+ static void getProxyConnect(std::stringstream &buf,const std::string
&serveraddress);
+ static void sendProxyConnect(TCPsocket socket,const std::string
&serveraddress);
+
+
}; // end UtilInterface
#endif // __UtilInterface_hpp__
Index: netpanzer/src/NetPanzer/Core/main.cpp
diff -u netpanzer/src/NetPanzer/Core/main.cpp:1.21
netpanzer/src/NetPanzer/Core/main.cpp:1.22
--- netpanzer/src/NetPanzer/Core/main.cpp:1.21 Tue Nov 11 08:42:04 2003
+++ netpanzer/src/NetPanzer/Core/main.cpp Thu Nov 13 08:12:18 2003
@@ -174,15 +174,13 @@
option<std::string, true, false> bot_option('b', "bot",
"connect as bot to specific server", "");
commandline.add(&bot_option);
-#if 0
option<int> port_option('p', "port", "run server on specific port", 0);
commandline.add(&port_option);
-#endif
bool_option debug_option('g', "debug",
"enable debug output", false);
commandline.add(&debug_option);
- option<char *> lobby_server_option('\0', "lobby_server",
- "Use an empty lobby server if you dont want to use the lobby", false);
+ option<std::string, true, false> lobby_server_option('\0', "lobby_server",
+ "Use 'none' if you dont want to use the lobby", "");
commandline.add(&lobby_server_option);
if(!commandline.process() || commandline.help() || commandline.version())
@@ -192,8 +190,6 @@
LOGGER.setLogLevel(Logger::LEVEL_DEBUG);
LOGGER.debug("debug option enabled");
}
- if (lobby_server_option.value())
- gameconfig->lobbyserver = lobby_server_option.value();
// Initialize SDL
SDL_Init(SDL_INIT_NOPARACHUTE | SDL_INIT_TIMER);
@@ -242,7 +238,18 @@
}
}
+
manager->initialize();
+
+ // gameconfig exists now...
+ if (lobby_server_option.value().size() > 0) {
+ if (lobby_server_option.value() == "none") {
+ gameconfig->lobbyserver = "";
+ }
+ else { gameconfig->lobbyserver = lobby_server_option.value(); }
+ }
+ gameconfig->serverport=port_option.value();
+
return manager;
} catch(Exception e) {
LOGGER.warning("Couldn't initialize the game: %s", e.what());
Index: netpanzer/src/NetPanzer/Interfaces/GameConfig.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/GameConfig.cpp:1.17
netpanzer/src/NetPanzer/Interfaces/GameConfig.cpp:1.18
--- netpanzer/src/NetPanzer/Interfaces/GameConfig.cpp:1.17 Wed Nov 12
06:26:00 2003
+++ netpanzer/src/NetPanzer/Interfaces/GameConfig.cpp Thu Nov 13 08:12:18 2003
@@ -22,6 +22,7 @@
#include "Log.hpp"
#include "Exception.hpp"
#include "GameConfig.hpp"
+#include "NetworkGlobals.hpp"
#include "XmlConfig.hpp"
#include "XmlStore.hpp"
@@ -30,7 +31,10 @@
: hostorjoin("hostorjoin", _game_session_join, 0, _game_session_last-1),
playername("name", "Player"),
lobbyserver("lobbyserver", "irc.freenode.net:6667"),
-
+ serverport("serverport",_NETPANZER_DEFAULT_PORT_TCP,0,65535),
+ proxyserver("proxyserver",""),
+ proxyserveruser("proxyserveruser",""),
+ proxyserverpass("proxyserverpass",""),
gametype("gametype", _gametype_objective, 0, _gametype_last-1),
maxplayers("maxplayers", 8, 1, 25),
maxunits("maxunits", 500, 25, 10000),
@@ -87,7 +91,11 @@
playername=default_player.str();
playersettings.push_back(&playername);
playersettings.push_back(&lobbyserver);
+ playersettings.push_back(&proxyserver);
+ playersettings.push_back(&proxyserveruser);
+ playersettings.push_back(&proxyserverpass);
+ serversettings.push_back(&serverport);
serversettings.push_back(&gametype);
serversettings.push_back(&maxplayers);
serversettings.push_back(&maxunits);
Index: netpanzer/src/NetPanzer/Interfaces/GameConfig.hpp
diff -u netpanzer/src/NetPanzer/Interfaces/GameConfig.hpp:1.14
netpanzer/src/NetPanzer/Interfaces/GameConfig.hpp:1.15
--- netpanzer/src/NetPanzer/Interfaces/GameConfig.hpp:1.14 Tue Nov 11
08:42:05 2003
+++ netpanzer/src/NetPanzer/Interfaces/GameConfig.hpp Thu Nov 13 08:12:19 2003
@@ -115,6 +115,10 @@
ConfigString lobbyserver;
// server settings
+ ConfigInt serverport;
+ ConfigString proxyserver;
+ ConfigString proxyserveruser;
+ ConfigString proxyserverpass;
ConfigInt gametype; //Objectives, FragLimit, TimeLimit
ConfigInt maxplayers;
ConfigInt maxunits;
Index: netpanzer/src/NetPanzer/Interfaces/unix/NetworkClientUnix.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/unix/NetworkClientUnix.cpp:1.11
netpanzer/src/NetPanzer/Interfaces/unix/NetworkClientUnix.cpp:1.12
--- netpanzer/src/NetPanzer/Interfaces/unix/NetworkClientUnix.cpp:1.11 Wed Oct
22 19:05:40 2003
+++ netpanzer/src/NetPanzer/Interfaces/unix/NetworkClientUnix.cpp Thu Nov
13 08:12:19 2003
@@ -84,7 +84,7 @@
clientsocket = 0;
LOG( ("Trying to join server '%s'.\n", session_name) );
try {
- clientsocket = new ClientSocket(session_name,
_NETPANZER_DEFAULT_PORT_TCP);
+ clientsocket = new ClientSocket(session_name);
} catch(Exception e) {
LOG( ( "Couldn't connect to server:\n%s.", e.what()) );
char text[128];
Index: netpanzer/src/NetPanzer/Interfaces/unix/NetworkServerUnix.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/unix/NetworkServerUnix.cpp:1.7
netpanzer/src/NetPanzer/Interfaces/unix/NetworkServerUnix.cpp:1.8
--- netpanzer/src/NetPanzer/Interfaces/unix/NetworkServerUnix.cpp:1.7 Wed Oct
22 11:53:03 2003
+++ netpanzer/src/NetPanzer/Interfaces/unix/NetworkServerUnix.cpp Thu Nov
13 08:12:19 2003
@@ -20,6 +20,7 @@
#include <assert.h>
#include "Log.hpp"
#include "NetworkGlobals.hpp"
+#include "GameConfig.hpp"
#include "NetworkState.hpp"
#include "Exception.hpp"
#include "NetworkServerUnix.hpp"
@@ -47,7 +48,7 @@
void NetworkServerUnix::hostSession()
{
delete serversocket;
- serversocket = new ServerSocket(_NETPANZER_DEFAULT_PORT_TCP);
+ serversocket = new ServerSocket(gameconfig->serverport);
}
void NetworkServerUnix::closeSession()
Index: netpanzer/src/NetPanzer/Views/MainMenu/Multi/HostJoinTemplateView.cpp
diff -u
netpanzer/src/NetPanzer/Views/MainMenu/Multi/HostJoinTemplateView.cpp:1.22
netpanzer/src/NetPanzer/Views/MainMenu/Multi/HostJoinTemplateView.cpp:1.23
--- netpanzer/src/NetPanzer/Views/MainMenu/Multi/HostJoinTemplateView.cpp:1.22
Tue Nov 11 10:01:32 2003
+++ netpanzer/src/NetPanzer/Views/MainMenu/Multi/HostJoinTemplateView.cpp
Thu Nov 13 08:12:19 2003
@@ -92,6 +92,7 @@
Desktop::setVisibilityAllWindows(false);
Desktop::setVisibility("LobbyView", true);
+ lobby_view->stopIRC();
//this call should be redundant -- enumeration ceases
//when a session is opened in any case:
@@ -100,6 +101,7 @@
} else {
// Close all menu views.
Desktop::setVisibilityAllWindows(false);
+ lobby_view->startIRC();
}
// Free the menu pictures.
@@ -107,7 +109,6 @@
MenuTemplateView::backgroundSurface.free();
//MenuTemplateView::titleSurface.free();
- lobby_view->stopIRC();
//TODO: I don't like static methods
PlayerGameManager::launchMultiPlayerGame();
}
Index: netpanzer/src/NetPanzer/Views/MainMenu/Multi/IRCLobby.cpp
diff -u netpanzer/src/NetPanzer/Views/MainMenu/Multi/IRCLobby.cpp:1.7
netpanzer/src/NetPanzer/Views/MainMenu/Multi/IRCLobby.cpp:1.8
--- netpanzer/src/NetPanzer/Views/MainMenu/Multi/IRCLobby.cpp:1.7 Wed Nov
12 12:03:38 2003
+++ netpanzer/src/NetPanzer/Views/MainMenu/Multi/IRCLobby.cpp Thu Nov 13
08:12:20 2003
@@ -17,6 +17,7 @@
*/
#include <config.h>
+#include <SDLNet.hpp>
#include <sstream>
#include "Log.hpp"
@@ -25,6 +26,7 @@
#include "GameConfig.hpp"
#include "NetworkGlobals.hpp"
#include "Exception.hpp"
+#include "UtilInterface.hpp"
static const char* ask_server_running_mess = "Who's running a server?";
static const char* server_running_mess = "I'm running";
@@ -35,21 +37,10 @@
: irc_server_socket(0), channel_name(newchannelname), nickname(nick),
game_servers(0), running_thread(0)
{
- unsigned int colon=server.find(':',0);
- if(colon==std::string::npos) {
- serveraddress=server;
- serverport=6667;
- }
- else {
- serveraddress=server.substr(0,colon);
- colon++;
- std::string port_str(server.substr(colon,server.length()-colon));
- serverport=atoi(port_str.c_str());
- }
+ serveraddress=server;
game_servers=new GameServerList();
game_servers_mutex=SDL_CreateMutex();
- connectToServer();
startMessagesThread();
}
@@ -86,6 +77,7 @@
buffer << "-" << server_running_mess << " "
<< PlayerInterface::countPlayers()
<< "/" << PlayerInterface::getMaxPlayers()
+ << " port:" << gameconfig->serverport
<< " map:" << gameconfig->map;
return sendIRCMessageLine(buffer.str(), dest);
@@ -94,16 +86,22 @@
void IRCLobby::connectToServer()
{
IPaddress addr;
+
+ const std::string &server=((const std::string
&)gameconfig->proxyserver).size()>0 ? ((const std::string
&)gameconfig->proxyserver): serveraddress;
+
+ int sport=6667;
+ std::string saddress;
+ UtilInterface::splitServerPort(server,saddress,&sport);
+
// some old versions of SDL_net take a char* instead of const char*
- if(SDLNet_ResolveHost(&addr, const_cast<char*>(serveraddress.c_str()),
- serverport) < 0)
- throw Exception("Couldn't resolve server address '%s:%d'",
- serveraddress.c_str(), serverport);
+ if(SDLNet_ResolveHost(&addr, const_cast<char*>(saddress.c_str()), sport) <
0)
+ throw Exception("Couldn't resolve server address '%s'",
+ saddress.c_str());
irc_server_socket = SDLNet_TCP_Open(&addr);
if(!irc_server_socket)
- throw Exception("Couldn't connect to irc server '%s:%d': %s",
- serveraddress.c_str(), serverport, SDLNet_GetError());
+ throw Exception("Couldn't connect to irc server '%s': %s",
+ saddress.c_str(), SDLNet_GetError());
// login
const char *playername = nickname.c_str();
@@ -123,8 +121,15 @@
}
}
ircname[i] = 0;
+
std::stringstream buffer;
+
+ if(((const std::string &)gameconfig->proxyserver).size()>0) {
+ UtilInterface::sendProxyConnect(irc_server_socket,serveraddress);
+ }
+
+ buffer.str("");
buffer << "NICK " << ircname;
sendIRCLine(buffer.str());
@@ -164,6 +169,10 @@
int IRCLobby::messagesThreadEntry(void* data)
{
IRCLobby* t = (IRCLobby*) data;
+ // this is here so that the thread is started before we connect
+ // to the irc server otherwise the main thread will halt
+ // if we don't have access to the irc server.
+ t->connectToServer();
t->processMessages();
return 0;
}
@@ -320,6 +329,11 @@
return;
}
int max_players=atoi(++p);
+ int port=_NETPANZER_DEFAULT_PORT_TCP;
+ char *port_str;
+ if((port_str=strstr(p,"port:"))!=0) {
+ port=atoi(port_str+5);
+ }
if((map=strstr(p,"map:"))==0) {
LOG(("no map name: %s\n",mess));
return;
@@ -327,11 +341,11 @@
map+=4;
GameServer *server
- = game_servers->find(host, _NETPANZER_DEFAULT_PORT_TCP);
+ = game_servers->find(host, port);
if(server==0) {
SDL_mutexP(game_servers_mutex);
game_servers->push_back(
- GameServer(host, _NETPANZER_DEFAULT_PORT_TCP,
+ GameServer(host, port,
buf+1, map, players, max_players));
SDL_mutexV(game_servers_mutex);
}
Index: netpanzer/src/NetPanzer/Views/MainMenu/Multi/IRCLobby.hpp
diff -u netpanzer/src/NetPanzer/Views/MainMenu/Multi/IRCLobby.hpp:1.4
netpanzer/src/NetPanzer/Views/MainMenu/Multi/IRCLobby.hpp:1.5
--- netpanzer/src/NetPanzer/Views/MainMenu/Multi/IRCLobby.hpp:1.4 Tue Nov
11 08:42:06 2003
+++ netpanzer/src/NetPanzer/Views/MainMenu/Multi/IRCLobby.hpp Thu Nov 13
08:12:20 2003
@@ -73,7 +73,6 @@
std::string channel_name;
std::string nickname;
std::string serveraddress;
- int serverport;
std::list<IRCChatMessage> chat_messages;
GameServerList* game_servers;
Index: netpanzer/src/NetPanzer/Views/MainMenu/Multi/IRCLobbyView.cpp
diff -u netpanzer/src/NetPanzer/Views/MainMenu/Multi/IRCLobbyView.cpp:1.5
netpanzer/src/NetPanzer/Views/MainMenu/Multi/IRCLobbyView.cpp:1.6
--- netpanzer/src/NetPanzer/Views/MainMenu/Multi/IRCLobbyView.cpp:1.5 Tue Nov
11 08:42:06 2003
+++ netpanzer/src/NetPanzer/Views/MainMenu/Multi/IRCLobbyView.cpp Thu Nov
13 08:12:20 2003
@@ -34,7 +34,6 @@
{
lobby_connection=0;
lobby_view_height=160;
- mouse_down_server=0;
total_displayed_servers=0;
setSearchName("IRCLobbyView");
setTitle("Lobby");
@@ -81,7 +80,7 @@
return;
}
-//~~~ todo: scrollbar for large list of servers
+// XXX todo: scrollbar for large list of servers
if(!lobby_connection->isConnected()) {
clientArea.bltString(iXY(0,0),"Not connected to lobby", Color::white);
}
@@ -137,7 +136,9 @@
assert(server!=0);
// connect to this game
- IPAddressView::szServer.setString(server->host.c_str());
+ std::stringstream server_host;
+ server_host << server->host.c_str() <<":"<<server->port;
+ IPAddressView::szServer.setString(server_host.str().c_str());
}
return View::lMouseUp(down_pos,up_pos);
}
Index: netpanzer/src/NetPanzer/Views/MainMenu/Multi/IRCLobbyView.hpp
diff -u netpanzer/src/NetPanzer/Views/MainMenu/Multi/IRCLobbyView.hpp:1.4
netpanzer/src/NetPanzer/Views/MainMenu/Multi/IRCLobbyView.hpp:1.5
--- netpanzer/src/NetPanzer/Views/MainMenu/Multi/IRCLobbyView.hpp:1.4 Tue Nov
11 08:42:06 2003
+++ netpanzer/src/NetPanzer/Views/MainMenu/Multi/IRCLobbyView.hpp Thu Nov
13 08:12:20 2003
@@ -42,7 +42,6 @@
static void chatReturnPressed(cInputField* input);
int lobby_view_height;
- const GameServer *mouse_down_server;
const GameServer *displayed_servers[64];
int total_displayed_servers;
Index: netpanzer/src/UILib/Network/ClientSocket.cpp
diff -u netpanzer/src/UILib/Network/ClientSocket.cpp:1.6
netpanzer/src/UILib/Network/ClientSocket.cpp:1.7
--- netpanzer/src/UILib/Network/ClientSocket.cpp:1.6 Fri Nov 7 04:38:41 2003
+++ netpanzer/src/UILib/Network/ClientSocket.cpp Thu Nov 13 08:12:20 2003
@@ -17,29 +17,44 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <config.h>
+#include <string>
+#include <sstream>
#include "Log.hpp"
#include "Exception.hpp"
#include "SDLNet.hpp"
#include "NetworkInterface.hpp"
+#include "NetworkGlobals.hpp"
#include "ClientSocket.hpp"
+#include "UtilInterface.hpp"
+#include "GameConfig.hpp"
-ClientSocket::ClientSocket(const char* servername, Uint16 port)
+ClientSocket::ClientSocket(const char* whole_servername)
{
SDLNet::initialise();
+ int port=_NETPANZER_DEFAULT_PORT_TCP;
+ std::string servername;
// resolve server name
IPaddress serverip;
+ const char *server=(((const std::string
&)gameconfig->proxyserver).size()>0?gameconfig->proxyserver.c_str():whole_servername);
+ UtilInterface::splitServerPort(server,servername,&port);
// some old version of SDL_net take a char* instead of a const char*
- if(SDLNet_ResolveHost(&serverip, const_cast<char*>(servername),
+
+ if(SDLNet_ResolveHost(&serverip, const_cast<char *>(servername.c_str()),
port) < 0) {
- throw Exception("couldn't resolve name '%s'.", servername);
+ throw Exception("couldn't resolve name '%s'.", servername.c_str());
}
tcpsocket = SDLNet_TCP_Open(&serverip);
if(!tcpsocket) {
throw Exception("couldn't open tcp connection to server '%s:%u'.",
- servername, port);
+ servername.c_str(), port);
+ }
+
+ if( ((const std::string &)gameconfig->proxyserver).size()>0) {
+ UtilInterface::sendProxyConnect(tcpsocket,whole_servername);
+ LOGGER.info("%s connected via proxy
%s",whole_servername,gameconfig->proxyserver.c_str());
}
socketset = SDLNet_AllocSocketSet(1);
Index: netpanzer/src/UILib/Network/ClientSocket.hpp
diff -u netpanzer/src/UILib/Network/ClientSocket.hpp:1.3
netpanzer/src/UILib/Network/ClientSocket.hpp:1.4
--- netpanzer/src/UILib/Network/ClientSocket.hpp:1.3 Tue Sep 16 16:16:13 2003
+++ netpanzer/src/UILib/Network/ClientSocket.hpp Thu Nov 13 08:12:20 2003
@@ -23,7 +23,7 @@
class ClientSocket
{
public:
- ClientSocket(const char* serveraddress, Uint16 port);
+ ClientSocket(const char* serveraddress);
~ClientSocket();
void read();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [netPanzer-CVS] netpanzer docs/netpanzer.6 src/Lib/Interfaces/U...,
Hankin Chick <=