summaryrefslogtreecommitdiff
path: root/plugins/advtools.cpp
diff options
context:
space:
mode:
authorAlexander Gavrilov2012-02-29 17:06:05 +0400
committerAlexander Gavrilov2012-02-29 17:06:05 +0400
commitdf6bd590068eb060f1e4e04e09506cfbeacd3258 (patch)
treef33e5b0b5709c5d90d24425eab03cfe5867520b6 /plugins/advtools.cpp
parent26c15a1d5177ddc3592a6625118104ea1fd8fd0d (diff)
downloaddfhack-df6bd590068eb060f1e4e04e09506cfbeacd3258.tar.gz
dfhack-df6bd590068eb060f1e4e04e09506cfbeacd3258.tar.bz2
dfhack-df6bd590068eb060f1e4e04e09506cfbeacd3258.tar.xz
Fix advtools: player_id is an array index, not nemesis id.
In most worlds they happen to be the same, but not always.
Diffstat (limited to 'plugins/advtools.cpp')
-rw-r--r--plugins/advtools.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/plugins/advtools.cpp b/plugins/advtools.cpp
index 6b2787ea..7ccb4302 100644
--- a/plugins/advtools.cpp
+++ b/plugins/advtools.cpp
@@ -201,7 +201,7 @@ bool bodySwap(Core *c, df::unit *player)
df::nemesis_record *getPlayerNemesis(Core *c, bool restore_swap)
{
- auto real_nemesis = df::nemesis_record::find(ui_advmode->player_id);
+ auto real_nemesis = vector_get(world->nemesis.all, ui_advmode->player_id);
if (!real_nemesis || !real_nemesis->unit)
{
c->con.printerr("Invalid player nemesis id: %d\n", ui_advmode->player_id);
@@ -274,7 +274,11 @@ void sortCompanionNemesis(std::vector<nemesis_record*> *list, int player_id = -1
output.reserve(list->size());
if (player_id < 0)
- player_id = ui_advmode->player_id;
+ {
+ auto real_nemesis = vector_get(world->nemesis.all, ui_advmode->player_id);
+ if (real_nemesis)
+ player_id = real_nemesis->id;
+ }
// Index records; find the player
for (size_t i = 0; i < list->size(); i++)
@@ -570,7 +574,7 @@ command_result adv_bodyswap (Core * c, std::vector <std::string> & parameters)
// Permanently re-link everything
if (permanent)
{
- ui_advmode->player_id = new_nemesis->id;
+ ui_advmode->player_id = linear_index(world->nemesis.all, new_nemesis);
// Flag 0 appears to be the 'active adventurer' flag, and
// the player_id field above seems to be computed using it