Sync to the change in gamemode/gametype globals.

develop
Alexander Gavrilov 2012-06-16 14:42:56 +04:00
parent dc5bef2cb8
commit db91850464
8 changed files with 54 additions and 71 deletions

@ -379,19 +379,19 @@ static command_result GetWorldInfo(color_ostream &stream,
if (!ui || !world || !Core::getInstance().isWorldLoaded())
return CR_NOT_FOUND;
t_gamemodes mode;
if (!Core::getInstance().getWorld()->ReadGameMode(mode))
mode.g_type = GAMETYPE_DWARF_MAIN;
df::game_type gt = game_type::DWARF_MAIN;
if (df::global::gametype)
gt = *df::global::gametype;
out->set_save_dir(world->cur_savegame.save_dir);
if (world->world_data->name.has_name)
describeName(out->mutable_world_name(), &world->world_data->name);
switch (mode.g_type)
switch (gt)
{
case GAMETYPE_DWARF_MAIN:
case GAMETYPE_DWARF_RECLAIM:
case game_type::DWARF_MAIN:
case game_type::DWARF_RECLAIM:
out->set_mode(GetWorldInfoOut::MODE_DWARF);
out->set_civ_id(ui->civ_id);
out->set_site_id(ui->site_id);
@ -399,7 +399,7 @@ static command_result GetWorldInfo(color_ostream &stream,
out->set_race_id(ui->race_id);
break;
case GAMETYPE_ADVENTURE_MAIN:
case game_type::ADVENTURE_MAIN:
out->set_mode(GetWorldInfoOut::MODE_ADVENTURE);
if (auto unit = vector_get(world->units.active, 0))
@ -423,7 +423,7 @@ static command_result GetWorldInfo(color_ostream &stream,
}
break;
case GAMETYPE_VIEW_LEGENDS:
case game_type::VIEW_LEGENDS:
out->set_mode(GetWorldInfoOut::MODE_LEGENDS);
break;

@ -35,32 +35,15 @@ distribution.
#include "Module.h"
#include <ostream>
#include "DataDefs.h"
namespace DFHack
{
/**
* \ingroup grp_world
*/
enum GameMode
{
GAMEMODE_DWARF,
GAMEMODE_ADVENTURE,
GAMEMODENUM,
GAMEMODE_NONE
};
/**
* \ingroup grp_world
*/
enum GameType
{
GAMETYPE_DWARF_MAIN,
GAMETYPE_ADVENTURE_MAIN,
GAMETYPE_VIEW_LEGENDS,
GAMETYPE_DWARF_RECLAIM,
GAMETYPE_DWARF_ARENA,
GAMETYPE_ADVENTURE_ARENA,
GAMETYPENUM,
GAMETYPE_NONE
};
typedef df::game_mode GameMode;
typedef df::game_type GameType;
#define GAMEMODE_ADVENTURE df::enums::game_mode::ADVENTURE
/**
* \ingroup grp_world
*/

@ -85,7 +85,7 @@ World::World()
if(df::global::current_weather)
d->StartedWeather = true;
if (df::global::game_mode && df::global::control_mode)
if (df::global::gamemode && df::global::gametype)
d->StartedMode = true;
d->Inited = true;
@ -132,8 +132,8 @@ bool World::ReadGameMode(t_gamemodes& rd)
{
if(d->Inited && d->StartedMode)
{
rd.g_mode = (DFHack::GameMode)*df::global::control_mode;
rd.g_type = (DFHack::GameType)*df::global::game_mode;
rd.g_mode = (DFHack::GameMode)*df::global::gamemode;
rd.g_type = (DFHack::GameType)*df::global::gametype;
return true;
}
return false;
@ -142,8 +142,8 @@ bool World::WriteGameMode(const t_gamemodes & wr)
{
if(d->Inited && d->StartedMode)
{
*df::global::control_mode = wr.g_mode;
*df::global::game_mode = wr.g_type;
*df::global::gamemode = wr.g_mode;
*df::global::gametype = wr.g_type;
return true;
}
return false;

@ -1 +1 @@
Subproject commit c381884664c71adefbec44258a734def2c88dacc
Subproject commit bc757db69514b54eb66d4d38e9cc1354d3761907

@ -101,8 +101,8 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan
switch (event) {
case SC_MAP_LOADED:
deinit_map(out);
if (df::global::game_mode &&
*df::global::game_mode == GAMEMODE_DWARF)
if (df::global::gamemode &&
*df::global::gamemode == game_mode::DWARF)
init_map(out);
break;
case SC_MAP_UNLOADED:

@ -10,7 +10,7 @@ using namespace std;
#include "modules/World.h"
#include <stdlib.h>
using namespace DFHack;
using namespace df::enums;
command_result mode (color_ostream &out, vector <string> & parameters);
@ -44,28 +44,28 @@ void printCurrentModes(t_gamemodes gm, Console & con)
con << "Current game type:\t" << gm.g_type << " (";
switch(gm.g_type)
{
case GAMETYPE_DWARF_MAIN:
case game_type::DWARF_MAIN:
con << "Fortress)" << endl;
break;
case GAMETYPE_ADVENTURE_MAIN:
case game_type::ADVENTURE_MAIN:
con << "Adventurer)" << endl;
break;
case GAMETYPE_VIEW_LEGENDS:
case game_type::VIEW_LEGENDS:
con << "Legends)" << endl;
break;
case GAMETYPE_DWARF_RECLAIM:
case game_type::DWARF_RECLAIM:
con << "Reclaim)" << endl;
break;
case GAMETYPE_DWARF_ARENA:
case game_type::DWARF_ARENA:
con << "Arena)" << endl;
break;
case GAMETYPE_ADVENTURE_ARENA:
case game_type::ADVENTURE_ARENA:
con << "Arena - control creature)" << endl;
break;
case GAMETYPENUM:
case game_type::num:
con << "INVALID)" << endl;
break;
case GAMETYPE_NONE:
case game_type::NONE:
con << "NONE)" << endl;
break;
default:
@ -75,16 +75,16 @@ void printCurrentModes(t_gamemodes gm, Console & con)
con << "Current game mode:\t" << gm.g_mode << " (";
switch (gm.g_mode)
{
case GAMEMODE_DWARF:
case game_mode::DWARF:
con << "Dwarf)" << endl;
break;
case GAMEMODE_ADVENTURE:
case game_mode::ADVENTURE:
con << "Adventure)" << endl;
break;
case GAMEMODENUM:
case game_mode::num:
con << "INVALID)" << endl;
break;
case GAMEMODE_NONE:
case game_mode::NONE:
con << "NONE)" << endl;
break;
default:
@ -132,7 +132,7 @@ command_result mode (color_ostream &out_, vector <string> & parameters)
{
if(!abuse)
{
if( gm.g_mode == GAMEMODE_NONE || gm.g_type == GAMETYPE_VIEW_LEGENDS)
if( gm.g_mode == game_mode::NONE || gm.g_type == game_type::VIEW_LEGENDS)
{
out.printerr("It is not safe to set modes in menus.\n");
return CR_FAILURE;
@ -163,24 +163,24 @@ command_result mode (color_ostream &out_, vector <string> & parameters)
switch(select)
{
case 0:
gm.g_mode = GAMEMODE_DWARF;
gm.g_type = GAMETYPE_DWARF_MAIN;
gm.g_mode = game_mode::DWARF;
gm.g_type = game_type::DWARF_MAIN;
break;
case 1:
gm.g_mode = GAMEMODE_ADVENTURE;
gm.g_type = GAMETYPE_ADVENTURE_MAIN;
gm.g_mode = game_mode::ADVENTURE;
gm.g_type = game_type::ADVENTURE_MAIN;
break;
case 2:
gm.g_mode = GAMEMODE_DWARF;
gm.g_type = GAMETYPE_DWARF_ARENA;
gm.g_mode = game_mode::DWARF;
gm.g_type = game_type::DWARF_ARENA;
break;
case 3:
gm.g_mode = GAMEMODE_ADVENTURE;
gm.g_type = GAMETYPE_ADVENTURE_ARENA;
gm.g_mode = game_mode::ADVENTURE;
gm.g_type = game_type::ADVENTURE_ARENA;
break;
case 4:
gm.g_mode = GAMEMODE_DWARF;
gm.g_type = GAMETYPE_DWARF_RECLAIM;
gm.g_mode = game_mode::DWARF;
gm.g_type = game_type::DWARF_RECLAIM;
break;
}
}

@ -90,7 +90,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
World *World = Core::getInstance().getWorld();
t_gamemodes gm;
World->ReadGameMode(gm);
if(gm.g_mode == GAMEMODE_DWARF)
if(gm.g_mode == game_mode::DWARF)
{
// if the map is revealed and we're in fortress mode, force the game to pause.
if(revealed == REVEALED)
@ -193,12 +193,12 @@ command_result reveal(color_ostream &out, vector<string> & params)
}
t_gamemodes gm;
World->ReadGameMode(gm);
if(gm.g_mode == GAMEMODE_ADVENTURE)
if(gm.g_mode == game_mode::ADVENTURE)
{
revealAdventure(out);
return CR_OK;
}
if(gm.g_mode != GAMEMODE_DWARF)
if(gm.g_mode != game_mode::DWARF)
{
con.printerr("Only in fortress mode.\n");
return CR_FAILURE;
@ -272,7 +272,7 @@ command_result unreveal(color_ostream &out, vector<string> & params)
}
t_gamemodes gm;
World->ReadGameMode(gm);
if(gm.g_mode != GAMEMODE_DWARF)
if(gm.g_mode != game_mode::DWARF)
{
con.printerr("Only in fortress mode.\n");
return CR_FAILURE;
@ -350,7 +350,7 @@ command_result revflood(color_ostream &out, vector<string> & params)
}
t_gamemodes gm;
World->ReadGameMode(gm);
if(gm.g_type != GAMETYPE_DWARF_MAIN && gm.g_mode != GAMEMODE_DWARF )
if(gm.g_type != game_type::DWARF_MAIN && gm.g_mode != game_mode::DWARF )
{
out.printerr("Only in proper dwarf mode.\n");
return CR_FAILURE;

@ -111,7 +111,7 @@ command_result df_seedwatch(color_ostream &out, vector<string>& parameters)
w->ReadGameMode(gm);// FIXME: check return value
// if game mode isn't fortress mode
if(gm.g_mode != GAMEMODE_DWARF || gm.g_type != GAMETYPE_DWARF_MAIN)
if(gm.g_mode != game_mode::DWARF || gm.g_type != game_type::DWARF_MAIN)
{
// just print the help
printHelp(out);
@ -299,7 +299,7 @@ DFhackCExport command_result plugin_onupdate(color_ostream &out)
t_gamemodes gm;
w->ReadGameMode(gm);// FIXME: check return value
// if game mode isn't fortress mode
if(gm.g_mode != GAMEMODE_DWARF || gm.g_type != GAMETYPE_DWARF_MAIN)
if(gm.g_mode != game_mode::DWARF || gm.g_type != game_type::DWARF_MAIN)
{
// stop running.
running = false;