Add abuse mode to mode plugin.

develop
Petr Mrázek 2012-02-22 22:46:12 +01:00
parent 58e3813d56
commit 252176d064
1 changed files with 77 additions and 49 deletions

@ -69,6 +69,9 @@ void printCurrentModes(t_gamemodes gm, Console & con)
case GAMETYPE_NONE: case GAMETYPE_NONE:
con << "NONE)" << endl; con << "NONE)" << endl;
break; break;
default:
con << "!!UNKNOWN!!)" << endl;
break;
} }
con << "Current game mode:\t" << gm.g_mode << " ("; con << "Current game mode:\t" << gm.g_mode << " (";
switch (gm.g_mode) switch (gm.g_mode)
@ -85,6 +88,9 @@ void printCurrentModes(t_gamemodes gm, Console & con)
case GAMEMODE_NONE: case GAMEMODE_NONE:
con << "NONE)" << endl; con << "NONE)" << endl;
break; break;
default:
con << "!!UNKNOWN!!)" << endl;
break;
} }
} }
@ -92,13 +98,18 @@ command_result mode (Core * c, vector <string> & parameters)
{ {
string command = ""; string command = "";
bool set = false; bool set = false;
bool abuse = false;
t_gamemodes gm; t_gamemodes gm;
if(parameters.size()) for(auto iter = parameters.begin(); iter != parameters.end(); iter++)
{ {
if(parameters[0] == "set") if((*iter) == "set")
{ {
set = true; set = true;
} }
else if((*iter) == "abuse")
{
set = abuse = true;
}
else else
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
} }
@ -109,6 +120,8 @@ command_result mode (Core * c, vector <string> & parameters)
c->Resume(); c->Resume();
printCurrentModes(gm, c->con); printCurrentModes(gm, c->con);
if(set) if(set)
{
if(!abuse)
{ {
if( gm.g_mode == GAMEMODE_NONE || gm.g_type == GAMETYPE_VIEW_LEGENDS) if( gm.g_mode == GAMEMODE_NONE || gm.g_type == GAMETYPE_VIEW_LEGENDS)
{ {
@ -138,7 +151,6 @@ command_result mode (Core * c, vector <string> & parameters)
c->con.printerr("This is not a valid selection.\n"); c->con.printerr("This is not a valid selection.\n");
goto input_again; goto input_again;
} }
switch(select) switch(select)
{ {
case 0: case 0:
@ -162,6 +174,22 @@ command_result mode (Core * c, vector <string> & parameters)
gm.g_type = GAMETYPE_DWARF_RECLAIM; gm.g_type = GAMETYPE_DWARF_RECLAIM;
break; break;
} }
}
else
{
CommandHistory hist;
string selected;
c->con.lineedit("Enter new game mode number (c for exit): ",selected, hist);
if(selected == "c")
return CR_OK;
const char * start = selected.c_str();
gm.g_mode = (GameMode) strtol(start, 0, 10);
c->con.lineedit("Enter new game type number (c for exit): ",selected, hist);
if(selected == "c")
return CR_OK;
start = selected.c_str();
gm.g_type = (GameType) strtol(start, 0, 10);
}
c->Suspend(); c->Suspend();
world->WriteGameMode(gm); world->WriteGameMode(gm);
c->Resume(); c->Resume();