diff options
| author | Alexander Gavrilov | 2012-04-07 19:08:30 +0400 |
|---|---|---|
| committer | Alexander Gavrilov | 2012-04-07 19:08:30 +0400 |
| commit | 45ae2ed67f9aba4d635a7565253bd9098a87bbde (patch) | |
| tree | 5cf1e6c898d4ab96bcba52f520aa8404f65b7ce4 /plugins/advtools.cpp | |
| parent | e74788cb26edd41e484071ac3a371422c6be8773 (diff) | |
| download | dfhack-45ae2ed67f9aba4d635a7565253bd9098a87bbde.tar.gz dfhack-45ae2ed67f9aba4d635a7565253bd9098a87bbde.tar.bz2 dfhack-45ae2ed67f9aba4d635a7565253bd9098a87bbde.tar.xz | |
Pull a few utility functions into the core and publish to lua.
Diffstat (limited to 'plugins/advtools.cpp')
| -rw-r--r-- | plugins/advtools.cpp | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/plugins/advtools.cpp b/plugins/advtools.cpp index 4fc1b4e5..ffb428fd 100644 --- a/plugins/advtools.cpp +++ b/plugins/advtools.cpp @@ -8,6 +8,8 @@ #include "modules/Materials.h" #include "modules/Maps.h" #include "modules/Items.h" +#include "modules/Gui.h" +#include "modules/Units.h" #include "DataDefs.h" #include "df/world.h" @@ -159,31 +161,6 @@ static bool bodyswap_hotkey(df::viewscreen *top) !!virtual_cast<df::viewscreen_dungeon_monsterstatusst>(top); } -df::unit *getCurUnit() -{ - auto top = Core::getTopViewscreen(); - - if (VIRTUAL_CAST_VAR(ms, df::viewscreen_dungeon_monsterstatusst, top)) - return ms->unit; - - return NULL; -} - -df::nemesis_record *getNemesis(df::unit *unit) -{ - if (!unit) - return NULL; - - for (unsigned i = 0; i < unit->refs.size(); i++) - { - df::nemesis_record *rv = unit->refs[i]->getNemesis(); - if (rv && rv->unit == unit) - return rv; - } - - return NULL; -} - bool bodySwap(color_ostream &out, df::unit *player) { if (!player) @@ -219,7 +196,7 @@ df::nemesis_record *getPlayerNemesis(color_ostream &out, bool restore_swap) if (restore_swap) { df::unit *ctl = world->units.other[0][0]; - auto ctl_nemesis = getNemesis(ctl); + auto ctl_nemesis = Units::getNemesis(ctl); if (ctl_nemesis != real_nemesis) { @@ -672,8 +649,8 @@ command_result adv_bodyswap (color_ostream &out, std::vector <std::string> & par return CR_FAILURE; // Get the unit to swap to - auto new_unit = getCurUnit(); - auto new_nemesis = getNemesis(new_unit); + auto new_unit = Gui::getSelectedUnit(out, true); + auto new_nemesis = Units::getNemesis(new_unit); if (!new_nemesis) { |
