Skip to content

Commit

Permalink
Fix creature owned items vector offset on Windows, added support for …
Browse files Browse the repository at this point in the history
…owned items to more versions.
  • Loading branch information
peterix committed May 28, 2011
1 parent 6e00dc4 commit da2fb1c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CMake/Modules/FindCurses.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ENDIF()
FIND_PATH(Curses_INCLUDE_PATH
NAMES ncurses.h curses.h
PATH_SUFFIXES ncurses
PATHS /usr/include /usr/local/include /usr/pkg/include
PATHS /usr/include/ncursesw /usr/include /usr/local/include /usr/pkg/include
)

FIND_LIBRARY(Curses_LIBRARY
Expand Down
12 changes: 8 additions & 4 deletions Memory.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2010,6 +2010,7 @@
<Offset name="birth_year" value="0x224" />
<Offset name="birth_time" value="0x228" />
<Offset name="inventory_vector" value="0x288" />
<Offset name="owned_items_vector" value="0x298"/>
<Offset name="current_job" value="0x2f4" />
<Offset name="current_job_skill" value="0x2f8" /> THIS IS TOTAL BS
<Offset name="physical" value="0x3cc" /> DT: 0x3C4, I don't believe that's OK'
Expand Down Expand Up @@ -2243,6 +2244,11 @@
<PETimeStamp value="0x4D90764F" />
<MD5 value="6ada05fc94785b53efe6aa5728b3756b" />
<Offsets>
<Group name="Creatures">
<Group name="creature">
<Offset name="flags3" value="0xE8"/>
</Group>
</Group>
<Group name="Items" valid="true">
<Address name="items_vector" value="0x16c4540"/>
<Offset name="id" value="0x14"/>
Expand Down Expand Up @@ -2880,6 +2886,7 @@
<Offset name="birth_year" value="0x1A0" />
<Offset name="birth_time" value="0x1A4" />
<Offset name="inventory_vector" value="0x204" />
<Offset name="owned_items_vector" value="0x210"/>
<Offset name="current_job" value="0x25C" />
<Offset name="current_job_skill" value="0x260" />
<Offset name="physical" value="0x310" />
Expand All @@ -2889,6 +2896,7 @@
<Offset name="current_soul" value="0x53C" />
<Offset name="labors" value="0x54C" />
<Offset name="happiness" value="0x05dc" />
<Offset name="hist_figure_id" value="0x640"/>
</Group>
</Group>
<Group name="job">
Expand Down Expand Up @@ -3021,10 +3029,6 @@
Address name="vector" value="0x0940b174"
<Group name="creature">
<Offset name="flags3" value="0x94"/>
<Group name="advanced">
<Offset name="owned_items_vector" value="0x210"/>
<Offset name="hist_figure_id" value="0x640"/>
</Group>
</Group>
</Group>
<Group name="Position" valid="true">
Expand Down
6 changes: 5 additions & 1 deletion library/modules/Creatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,11 @@ bool Creatures::ReadOwnedItemsPtr(const uint32_t temp, std::vector<int32_t> & it

bool Creatures::RemoveOwnedItemIdx(const uint32_t index, int32_t id)
{
if(!d->Started || !d->Ft_owned_items) return false;
if(!d->Started || !d->Ft_owned_items)
{
cerr << "!d->Started || !d->Ft_owned_items FAIL" << endl;
return false;
}
uint32_t temp = d->p_cre->at (index);
return this->RemoveOwnedItemPtr(temp, id);
}
Expand Down
6 changes: 6 additions & 0 deletions library/modules/Items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,10 +592,16 @@ bool Items::removeItemOwner(dfh_item &item, Creatures *creatures)
int32_t ix = creatures->FindIndexById(oid);

if (ix < 0 || !creatures->RemoveOwnedItemIdx(ix, item.id))
{
cerr << "RemoveOwnedItemIdx: CREATURE " << ix << " ID " << item.id << " FAILED!" << endl;
return false;
}

if (!p_refs.remove(i--))
{
cerr << "p_refs.remove FAILED!" << endl;
return false;
}
}

item.base.flags.owned = 0;
Expand Down

0 comments on commit da2fb1c

Please sign in to comment.