parent
92f97c13bd
commit
f3e96a64c1
|
@ -113,6 +113,7 @@ Config::Config() {
|
|||
fileNameParameter.first = "";
|
||||
fileNameParameter.second = "";
|
||||
custom_path_parameter = "";
|
||||
serverTitle = "";
|
||||
}
|
||||
|
||||
bool Config::tryCustomPath(std::pair<ConfigType,ConfigType> &type, std::pair<string,string> &file, string custom_path) {
|
||||
|
|
|
@ -52,6 +52,7 @@ private:
|
|||
std::pair<string,string> fileName;
|
||||
std::pair<bool,bool> fileLoaded;
|
||||
string custom_path_parameter;
|
||||
string serverTitle;
|
||||
|
||||
static map<ConfigType,Config> configList;
|
||||
|
||||
|
@ -118,6 +119,9 @@ public:
|
|||
|
||||
string toString();
|
||||
|
||||
string getServerTitle() {return serverTitle;}
|
||||
void setServerTitle(string name) {serverTitle=name;}
|
||||
|
||||
static string getCustomRuntimeProperty(string key) { return customRuntimeProperties[key]; }
|
||||
static void setCustomRuntimeProperty(string key, string value) { customRuntimeProperties[key] = value; }
|
||||
|
||||
|
|
|
@ -4107,6 +4107,29 @@ int glestMain(int argc, char** argv) {
|
|||
}
|
||||
}
|
||||
|
||||
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SERVER_TITLE]) == true) {
|
||||
int foundParamIndIndex = -1;
|
||||
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_SERVER_TITLE]) + string("="),&foundParamIndIndex);
|
||||
if(foundParamIndIndex < 0) {
|
||||
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_SERVER_TITLE]),&foundParamIndIndex);
|
||||
}
|
||||
string paramValue = argv[foundParamIndIndex];
|
||||
vector<string> paramPartTokens;
|
||||
Tokenize(paramValue,paramPartTokens,"=");
|
||||
if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) {
|
||||
Config &config = Config::getInstance();
|
||||
string serverTitle = paramPartTokens[1];
|
||||
printf("Forcing serverTitle[%s]\n",serverTitle.c_str());
|
||||
|
||||
config.setServerTitle(serverTitle);
|
||||
}
|
||||
else {
|
||||
printf("\nInvalid missing server title specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL));
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
PlatformExceptionHandler::application_binary= executable_path(argv[0],true);
|
||||
mg_app_name = GameConstants::application_name;
|
||||
mailStringSupport = mailString;
|
||||
|
|
|
@ -461,12 +461,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
|
|||
labelGameName.init(20+checkBoxPublishServer.getW()+5, networkPos,200);
|
||||
labelGameName.setFont(CoreData::getInstance().getMenuFontBig());
|
||||
labelGameName.setFont3D(CoreData::getInstance().getMenuFontBig3D());
|
||||
if(this->headlessServerMode == false) {
|
||||
labelGameName.setText(defaultPlayerName+"'s game");
|
||||
}
|
||||
else {
|
||||
labelGameName.setText("headless ("+defaultPlayerName+")");
|
||||
}
|
||||
labelGameName.setText(createGameName());
|
||||
labelGameName.setEditable(true);
|
||||
labelGameName.setMaxEditWidth(20);
|
||||
labelGameName.setMaxEditRenderWidth(200);
|
||||
|
@ -735,6 +730,22 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
|
|||
}
|
||||
}
|
||||
|
||||
string MenuStateCustomGame::createGameName(string controllingPlayer){
|
||||
Config &config = Config::getInstance();
|
||||
if(config.getServerTitle()!="" && controllingPlayer == ""){
|
||||
return config.getServerTitle();
|
||||
}
|
||||
else if (this->headlessServerMode == true) {
|
||||
if (controllingPlayer != "") {
|
||||
return controllingPlayer + " controls";
|
||||
} else {
|
||||
return "Headless (" + defaultPlayerName + ")";
|
||||
}
|
||||
} else {
|
||||
return defaultPlayerName+"'s game";
|
||||
}
|
||||
}
|
||||
|
||||
void MenuStateCustomGame::reloadUI() {
|
||||
Lang &lang= Lang::getInstance();
|
||||
Config &config = Config::getInstance();
|
||||
|
@ -809,12 +820,8 @@ void MenuStateCustomGame::reloadUI() {
|
|||
|
||||
labelGameName.setFont(CoreData::getInstance().getMenuFontBig());
|
||||
labelGameName.setFont3D(CoreData::getInstance().getMenuFontBig3D());
|
||||
if(this->headlessServerMode == false) {
|
||||
labelGameName.setText(defaultPlayerName+"'s game");
|
||||
}
|
||||
else {
|
||||
labelGameName.setText("headless ("+defaultPlayerName+")");
|
||||
}
|
||||
|
||||
labelGameName.setText(createGameName());
|
||||
|
||||
labelNetworkPauseGameForLaggedClients.setText(lang.getString("NetworkPauseGameForLaggedClients"));
|
||||
|
||||
|
@ -3854,7 +3861,7 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force
|
|||
clientConnectedTime = serverInterface->getSlot(i,true)->getConnectedTime();
|
||||
gameSettings->setMasterserver_admin(serverInterface->getSlot(i,true)->getSessionKey());
|
||||
gameSettings->setMasterserver_admin_faction_index(serverInterface->getSlot(i,true)->getPlayerIndex());
|
||||
labelGameName.setText(serverInterface->getSlot(i,true)->getName()+" controls");
|
||||
labelGameName.setText(createGameName(serverInterface->getSlot(i,true)->getName()));
|
||||
//printf("slot = %d, admin key [%d] slot connected time[" MG_SIZE_T_SPECIFIER "] clientConnectedTime [" MG_SIZE_T_SPECIFIER "]\n",i,gameSettings->getMasterserver_admin(),serverInterface->getSlot(i)->getConnectedTime(),clientConnectedTime);
|
||||
}
|
||||
if(serverInterface->getSlot(i,true)->getSessionKey() == gameSettings->getMasterserver_admin()){
|
||||
|
@ -3878,7 +3885,7 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force
|
|||
clientConnectedTime = serverInterface->getSlot(i,true)->getConnectedTime();
|
||||
gameSettings->setMasterserver_admin(serverInterface->getSlot(i,true)->getSessionKey());
|
||||
gameSettings->setMasterserver_admin_faction_index(serverInterface->getSlot(i,true)->getPlayerIndex());
|
||||
labelGameName.setText(serverInterface->getSlot(i,true)->getName()+" controls");
|
||||
labelGameName.setText(createGameName(serverInterface->getSlot(i,true)->getName()));
|
||||
//printf("slot = %d, admin key [%d] slot connected time[" MG_SIZE_T_SPECIFIER "] clientConnectedTime [" MG_SIZE_T_SPECIFIER "]\n",i,gameSettings->getMasterserver_admin(),serverInterface->getSlot(i)->getConnectedTime(),clientConnectedTime);
|
||||
}
|
||||
if(serverInterface->getSlot(i,true)->getSessionKey() == gameSettings->getMasterserver_admin()){
|
||||
|
@ -3890,7 +3897,7 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force
|
|||
|
||||
if(masterserver_admin_found == false)
|
||||
{
|
||||
labelGameName.setText("Headless: "+defaultPlayerName);
|
||||
labelGameName.setText(createGameName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -292,6 +292,7 @@ private:
|
|||
ServerInterface *& serverInterface, int startIndex, int endIndex,
|
||||
bool onlyNetworkUnassigned);
|
||||
|
||||
string createGameName(string controllingPlayer="");
|
||||
void reloadUI();
|
||||
void loadScenarioInfo(string file, ScenarioInfo *scenarioInfo);
|
||||
void processScenario();
|
||||
|
|
|
@ -33,6 +33,7 @@ const char *GAME_ARGS[] = {
|
|||
"--starthost",
|
||||
"--headless-server-mode",
|
||||
"--headless-server-status",
|
||||
"--server-title",
|
||||
"--use-ports",
|
||||
|
||||
"--load-scenario",
|
||||
|
@ -113,6 +114,7 @@ enum GAME_ARG_TYPE {
|
|||
GAME_ARG_SERVER,
|
||||
GAME_ARG_MASTERSERVER_MODE,
|
||||
GAME_ARG_MASTERSERVER_STATUS,
|
||||
GAME_ARG_SERVER_TITLE,
|
||||
GAME_ARG_USE_PORTS,
|
||||
|
||||
GAME_ARG_LOADSCENARIO,
|
||||
|
@ -235,7 +237,7 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) {
|
|||
|
||||
printf("\n%s\tCheck the current status of a headless server.",GAME_ARGS[GAME_ARG_MASTERSERVER_STATUS]);
|
||||
|
||||
printf("\n%s=x,y,z\t\t\tForce hosted games to listen internally on port",GAME_ARGS[GAME_ARG_USE_PORTS]);
|
||||
printf("\n%s=x,y,z\t\tForce hosted games to listen internally on port",GAME_ARGS[GAME_ARG_USE_PORTS]);
|
||||
printf("\n\t\t\t\tx, externally on port y and game status on port z.");
|
||||
printf("\n \t\tWhere x is the internal port # on the local");
|
||||
printf("\n \t\t machine to listen for connects");
|
||||
|
@ -247,6 +249,8 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) {
|
|||
printf("\n \t\t*NOTE: If enabled the FTP Server port #'s will");
|
||||
printf("\n \t\t be set to x+1 to x+9");
|
||||
|
||||
printf("\n%s=x\t\tSet server title.",GAME_ARGS[GAME_ARG_SERVER_TITLE]);
|
||||
|
||||
printf("\n%s=x\t\tAuto load a scenario by scenario name.",GAME_ARGS[GAME_ARG_LOADSCENARIO]);
|
||||
printf("\n%s=x\t\t\tAuto load a mod by mod pathname.",GAME_ARGS[GAME_ARG_MOD]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue