From db91850464a98e785ff53cfdc5df46b10229cfdb Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Sat, 16 Jun 2012 14:42:56 +0400 Subject: [PATCH] Sync to the change in gamemode/gametype globals. --- library/RemoteTools.cpp | 16 +++++------ library/include/modules/World.h | 31 +++++---------------- library/modules/World.cpp | 10 +++---- library/xml | 2 +- plugins/burrows.cpp | 4 +-- plugins/mode.cpp | 48 ++++++++++++++++----------------- plugins/reveal.cpp | 10 +++---- plugins/seedwatch.cpp | 4 +-- 8 files changed, 54 insertions(+), 71 deletions(-) diff --git a/library/RemoteTools.cpp b/library/RemoteTools.cpp index 689c783a8..95c495e93 100644 --- a/library/RemoteTools.cpp +++ b/library/RemoteTools.cpp @@ -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; diff --git a/library/include/modules/World.h b/library/include/modules/World.h index 81ebfbd60..8b0fe3f59 100644 --- a/library/include/modules/World.h +++ b/library/include/modules/World.h @@ -35,32 +35,15 @@ distribution. #include "Module.h" #include +#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 */ diff --git a/library/modules/World.cpp b/library/modules/World.cpp index 4b50b44ca..393e7cbfe 100644 --- a/library/modules/World.cpp +++ b/library/modules/World.cpp @@ -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; diff --git a/library/xml b/library/xml index c38188466..bc757db69 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit c381884664c71adefbec44258a734def2c88dacc +Subproject commit bc757db69514b54eb66d4d38e9cc1354d3761907 diff --git a/plugins/burrows.cpp b/plugins/burrows.cpp index 9ff902c3d..0b66a7b9a 100644 --- a/plugins/burrows.cpp +++ b/plugins/burrows.cpp @@ -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: diff --git a/plugins/mode.cpp b/plugins/mode.cpp index 33dd5875f..f9e6cd10c 100644 --- a/plugins/mode.cpp +++ b/plugins/mode.cpp @@ -10,7 +10,7 @@ using namespace std; #include "modules/World.h" #include using namespace DFHack; - +using namespace df::enums; command_result mode (color_ostream &out, vector & 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 & 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 & 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; } } diff --git a/plugins/reveal.cpp b/plugins/reveal.cpp index 513eededb..f35424309 100644 --- a/plugins/reveal.cpp +++ b/plugins/reveal.cpp @@ -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 & 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 & 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 & 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; diff --git a/plugins/seedwatch.cpp b/plugins/seedwatch.cpp index b6097f628..ae9ff0e14 100755 --- a/plugins/seedwatch.cpp +++ b/plugins/seedwatch.cpp @@ -111,7 +111,7 @@ command_result df_seedwatch(color_ostream &out, vector& 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;