added new commandline to specify internal/external port #'s to use when hosting:
--use-ports=61390,61390
This commit is contained in:
parent
53ad9d77c2
commit
1935f9314b
|
@ -2652,61 +2652,6 @@ int glestMain(int argc, char** argv) {
|
|||
Renderer::renderText3DEnabled = config.getBool("Enable3DFontRendering",intToStr(Renderer::renderText3DEnabled).c_str());
|
||||
}
|
||||
|
||||
// if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_USE_VIDEO_SETTINGS]) == true) {
|
||||
// int foundParamIndIndex = -1;
|
||||
// hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_USE_VIDEO_SETTINGS]) + string("="),&foundParamIndIndex);
|
||||
// if(foundParamIndIndex < 0) {
|
||||
// hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_USE_VIDEO_SETTINGS]),&foundParamIndIndex);
|
||||
// }
|
||||
// string paramValue = argv[foundParamIndIndex];
|
||||
// vector<string> paramPartTokens;
|
||||
// Tokenize(paramValue,paramPartTokens,"=");
|
||||
// if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) {
|
||||
// string settings = paramPartTokens[1];
|
||||
// printf("Forcing video settings [%s]\n",settings.c_str());
|
||||
//
|
||||
// paramPartTokens.clear();
|
||||
// Tokenize(settings,paramPartTokens,"x");
|
||||
// if(paramPartTokens.size() >= 2) {
|
||||
// int newScreenWidth = strToInt(paramPartTokens[0]);
|
||||
// config.setInt("ScreenWidth",newScreenWidth);
|
||||
//
|
||||
// int newScreenHeight = strToInt(paramPartTokens[1]);
|
||||
// config.setInt("ScreenHeight",newScreenHeight);
|
||||
//
|
||||
// if(paramPartTokens.size() >= 3) {
|
||||
// if(paramPartTokens[2] != "*") {
|
||||
// int newColorBits = strToInt(paramPartTokens[2]);
|
||||
// config.setInt("ColorBits",newColorBits);
|
||||
// }
|
||||
// }
|
||||
// if(paramPartTokens.size() >= 4) {
|
||||
// if(paramPartTokens[3] != "*") {
|
||||
// int newDepthBits = strToInt(paramPartTokens[3]);
|
||||
// config.setInt("DepthBits",newDepthBits);
|
||||
// }
|
||||
// }
|
||||
// if(paramPartTokens.size() >= 5) {
|
||||
// if(paramPartTokens[4] != "*") {
|
||||
// bool newFullScreenMode = strToBool(paramPartTokens[4]);
|
||||
// config.setBool("Windowed",!newFullScreenMode);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// printf("\nInvalid missing video settings specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL));
|
||||
// //printParameterHelp(argv[0],false);
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// printf("\nInvalid missing video settings specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL));
|
||||
// //printParameterHelp(argv[0],false);
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_USE_RESOLUTION]) == true) {
|
||||
int foundParamIndIndex = -1;
|
||||
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_USE_RESOLUTION]) + string("="),&foundParamIndIndex);
|
||||
|
@ -2893,6 +2838,43 @@ int glestMain(int argc, char** argv) {
|
|||
Renderer &renderer= Renderer::getInstance(true);
|
||||
}
|
||||
|
||||
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_USE_PORTS]) == true) {
|
||||
int foundParamIndIndex = -1;
|
||||
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_USE_PORTS]) + string("="),&foundParamIndIndex);
|
||||
if(foundParamIndIndex < 0) {
|
||||
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_USE_PORTS]),&foundParamIndIndex);
|
||||
}
|
||||
string paramValue = argv[foundParamIndIndex];
|
||||
vector<string> paramPartTokens;
|
||||
Tokenize(paramValue,paramPartTokens,"=");
|
||||
if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) {
|
||||
string portsToUse = paramPartTokens[1];
|
||||
|
||||
vector<string> paramPartPortsTokens;
|
||||
Tokenize(portsToUse,paramPartPortsTokens,",");
|
||||
if(paramPartPortsTokens.size() >= 2 && paramPartPortsTokens[1].length() > 0) {
|
||||
int internalPort = strToInt(paramPartPortsTokens[0]);
|
||||
int externalPort = strToInt(paramPartPortsTokens[1]);
|
||||
|
||||
printf("Forcing internal port# %d, external port# %d\n",internalPort,externalPort);
|
||||
|
||||
config.setInt("ServerPort",internalPort);
|
||||
config.setInt("MasterServerExternalPort",externalPort);
|
||||
config.setInt("FTPServerPort",internalPort+1);
|
||||
}
|
||||
else {
|
||||
printf("\nInvalid ports specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL));
|
||||
//printParameterHelp(argv[0],false);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("\nInvalid missing ports specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL));
|
||||
//printParameterHelp(argv[0],false);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
//float pingTime = Socket::getAveragePingMS("soft-haus.com");
|
||||
//printf("Ping time = %f\n",pingTime);
|
||||
|
||||
|
|
|
@ -210,8 +210,8 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
|
|||
ipText += ip;
|
||||
}
|
||||
}
|
||||
string externalPort=config.getString("MasterServerExternalPort", "61357");
|
||||
string serverPort=config.getString("ServerPort", "61357");
|
||||
string externalPort=config.getString("MasterServerExternalPort", intToStr(GameConstants::serverPort).c_str());
|
||||
string serverPort=config.getString("ServerPort", intToStr(GameConstants::serverPort).c_str());
|
||||
labelLocalIP.setText(lang.get("LanIP") + ipText + " ( "+serverPort+" / "+externalPort+" )");
|
||||
ServerSocket::setExternalPort(strToInt(externalPort));
|
||||
|
||||
|
@ -656,8 +656,8 @@ void MenuStateCustomGame::reloadUI() {
|
|||
ipText += ip;
|
||||
}
|
||||
}
|
||||
string externalPort=config.getString("MasterServerExternalPort", "61357");
|
||||
string serverPort=config.getString("ServerPort", "61357");
|
||||
string externalPort=config.getString("MasterServerExternalPort", intToStr(GameConstants::serverPort).c_str());
|
||||
string serverPort=config.getString("ServerPort", intToStr(GameConstants::serverPort).c_str());
|
||||
labelLocalIP.setText(lang.get("LanIP") + ipText + " ( "+serverPort+" / "+externalPort+" )");
|
||||
|
||||
labelMap.setText(lang.get("Map")+":");
|
||||
|
@ -2558,7 +2558,7 @@ void MenuStateCustomGame::publishToMasterserver() {
|
|||
publishToServerInfo["networkSlots"] = intToStr(slotCountHumans);
|
||||
publishToServerInfo["connectedClients"] = intToStr(slotCountConnectedPlayers);
|
||||
|
||||
string externalport = config.getString("MasterServerExternalPort", "61357");
|
||||
string externalport = config.getString("MasterServerExternalPort", intToStr(GameConstants::serverPort).c_str());
|
||||
publishToServerInfo["externalconnectport"] = externalport;
|
||||
publishToServerInfo["privacyPlease"] = intToStr(config.getBool("PrivacyPlease","false"));
|
||||
|
||||
|
|
|
@ -124,10 +124,10 @@ MenuStateJoinGame::MenuStateJoinGame(Program *program, MainMenu *mainMenu, bool
|
|||
labelServerPort.registerGraphicComponent(containerName,"labelServerPort");
|
||||
labelServerPort.init(465,430);
|
||||
string port=intToStr(config.getInt("ServerPort"));
|
||||
if(port!="61357"){
|
||||
if(port != intToStr(GameConstants::serverPort)){
|
||||
port=port +" ("+lang.get("NonStandardPort")+")";
|
||||
}
|
||||
else{
|
||||
else {
|
||||
port=port +" ("+lang.get("StandardPort")+")";
|
||||
}
|
||||
labelServerPort.setText(port);
|
||||
|
@ -183,7 +183,7 @@ void MenuStateJoinGame::reloadUI() {
|
|||
labelServerPortLabel.setText(lang.get("ServerPort"));
|
||||
|
||||
string port=intToStr(config.getInt("ServerPort"));
|
||||
if(port != "61357") {
|
||||
if(port != intToStr(GameConstants::serverPort)) {
|
||||
port = port +" ("+lang.get("NonStandardPort")+")";
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -387,7 +387,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
|||
labelServerPortLabel.setText(lang.get("ServerPort"));
|
||||
labelServerPort.init(currentColumnStart,currentLine);
|
||||
string port=intToStr(config.getInt("ServerPort"));
|
||||
if(port!="61357"){
|
||||
if(port != intToStr(GameConstants::serverPort)){
|
||||
port=port +" ("+lang.get("NonStandardPort")+"!!)";
|
||||
}
|
||||
else{
|
||||
|
@ -410,7 +410,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
|||
std::vector<std::string> externalPortList;
|
||||
Tokenize(supportExternalPortList,externalPortList,",");
|
||||
|
||||
string currentPort=config.getString("MasterServerExternalPort", "61357");
|
||||
string currentPort=config.getString("MasterServerExternalPort", intToStr(GameConstants::serverPort).c_str());
|
||||
int masterServerExternalPortSelectionIndex=0;
|
||||
for(int idx = 0; idx < externalPortList.size(); idx++) {
|
||||
if(externalPortList[idx] != "" && IsNumeric(externalPortList[idx].c_str(),false)) {
|
||||
|
@ -610,7 +610,7 @@ void MenuStateOptions::reloadUI() {
|
|||
labelServerPortLabel.setText(lang.get("ServerPort"));
|
||||
Config &config= Config::getInstance();
|
||||
string port = intToStr(config.getInt("ServerPort"));
|
||||
if(port != "61357") {
|
||||
if(port != intToStr(GameConstants::serverPort).c_str()) {
|
||||
port = port +" ("+lang.get("NonStandardPort")+"!!)";
|
||||
}
|
||||
else{
|
||||
|
|
|
@ -1866,7 +1866,7 @@ std::map<string,string> ServerInterface::publishToMasterserver() {
|
|||
publishToServerInfo["activeSlots"] = intToStr(slotCountUsed);
|
||||
publishToServerInfo["networkSlots"] = intToStr(slotCountHumans);
|
||||
publishToServerInfo["connectedClients"] = intToStr(slotCountConnectedPlayers);
|
||||
string externalport = config.getString("MasterServerExternalPort", "61357");
|
||||
string externalport = config.getString("MasterServerExternalPort", intToStr(GameConstants::serverPort).c_str());
|
||||
publishToServerInfo["externalconnectport"] = externalport;
|
||||
publishToServerInfo["privacyPlease"] = intToStr(config.getBool("PrivacyPlease","false"));
|
||||
publishToServerInfo["gameStatus"] = intToStr(game_status_in_progress);
|
||||
|
|
|
@ -24,10 +24,13 @@
|
|||
|
||||
const char *GAME_ARGS[] = {
|
||||
"--help",
|
||||
|
||||
"--autostart-lastgame",
|
||||
"--connecthost",
|
||||
"--starthost",
|
||||
"--headless-server-mode",
|
||||
"--use-ports",
|
||||
|
||||
"--load-scenario",
|
||||
"--load-mod",
|
||||
"--preview-map",
|
||||
|
@ -70,10 +73,13 @@ const char *GAME_ARGS[] = {
|
|||
|
||||
enum GAME_ARG_TYPE {
|
||||
GAME_ARG_HELP = 0,
|
||||
|
||||
GAME_ARG_AUTOSTART_LASTGAME,
|
||||
GAME_ARG_CLIENT,
|
||||
GAME_ARG_SERVER,
|
||||
GAME_ARG_MASTERSERVER_MODE,
|
||||
GAME_ARG_USE_PORTS,
|
||||
|
||||
GAME_ARG_LOADSCENARIO,
|
||||
GAME_ARG_MOD,
|
||||
GAME_ARG_PREVIEW_MAP,
|
||||
|
@ -132,6 +138,11 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) {
|
|||
printf("\n \t\texit - which quits the application after a game has no more connected players.");
|
||||
printf("\n \t\tvps - which does NOT read commands from the local console (required for some vps's).");
|
||||
|
||||
printf("\n%s=x,y\tForce hosted games to listen internally on port x, externally on port y.",GAME_ARGS[GAME_ARG_USE_PORTS]);
|
||||
printf("\n \t\tWhere x is the internal port # on the local machine to listen for connects");
|
||||
printf("\n \t\t y is the external port # on the router/proxy to forward connection from to the internal port #");
|
||||
printf("\n \t\t*NOTE: If enabled the FTP Server port #'s will be set to x+1 to x+9");
|
||||
|
||||
printf("\n%s=x\t\tAuto loads the specified scenario by scenario name.",GAME_ARGS[GAME_ARG_LOADSCENARIO]);
|
||||
printf("\n%s=x\t\tAuto loads the specified mod by mod pathname.",GAME_ARGS[GAME_ARG_MOD]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user