Skip to content

Commit

Permalink
Merge ccf053c into a85131f
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinEady committed Mar 7, 2023
2 parents a85131f + ccf053c commit c90e564
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 10 deletions.
7 changes: 6 additions & 1 deletion docs/docs.polserver.com/pol100/corechanges.xml
Expand Up @@ -2,9 +2,14 @@
<ESCRIPT>
<header>
<topic>Latest Core Changes</topic>
<datemodified>02-27-2023</datemodified>
<datemodified>02-28-2023</datemodified>
</header>
<version name="POL100.1.0">
<entry>
<date>02-28-2023</date>
<author>Kevin:</author>
<change type="Fixed">MultiRef.items now correctly includes items on the exterior stairs of custom houses.</change>
</entry>
<entry>
<date>02-27-2023</date>
<author>Kevin:</author>
Expand Down
2 changes: 2 additions & 0 deletions pol-core/doc/core-changes.txt
@@ -1,4 +1,6 @@
-- POL100.1.0 --
02-28-2023 Kevin:
Fixed: MultiRef.items now correctly includes items on the exterior stairs of custom houses.
02-27-2023 Kevin:
Fixed: DestroyItem(item) will now throw an error if item is a multi.
02-06-2023 Kevin:
Expand Down
10 changes: 5 additions & 5 deletions pol-core/pol/multi/customhouses.cpp
Expand Up @@ -685,7 +685,8 @@ Bscript::ObjArray* CustomHouseDesign::list_parts() const
return arr.release();
}

void CustomHouseStopEditing( Mobile::Character* chr, UHouse* house, bool send_pkts )
void CustomHouseStopEditing( Mobile::Character* chr, UHouse* house, ItemList& itemlist,
bool send_pkts )
{
if ( send_pkts && chr->client )
{
Expand All @@ -710,9 +711,6 @@ void CustomHouseStopEditing( Mobile::Character* chr, UHouse* house, bool send_pk
house->editing = false;
if ( send_pkts && chr->client )
{
ItemList itemlist;
MobileList moblist;
UHouse::list_contents( house, itemlist, moblist );
while ( !itemlist.empty() )
{
Items::Item* item = itemlist.front();
Expand Down Expand Up @@ -1167,6 +1165,8 @@ void UHouse::CustomHouseSetInitialState()

void UHouse::CustomHousesQuit( Mobile::Character* chr, bool drop_changes, bool send_pkts )
{
ItemList itemlist = get_working_design_items( this );

if ( drop_changes )
WorkingDesign = CurrentDesign;
else
Expand All @@ -1182,7 +1182,7 @@ void UHouse::CustomHousesQuit( Mobile::Character* chr, bool drop_changes, bool s
CurrentCompressed.swap( newvec2 );
if ( chr )
{
CustomHouseStopEditing( chr, this, send_pkts );
CustomHouseStopEditing( chr, this, itemlist, send_pkts );
if ( chr->client && send_pkts )
CustomHousesSendFull( this, chr->client, HOUSE_DESIGN_CURRENT );
if ( Core::gamestate.system_hooks.close_customhouse_hook )
Expand Down
4 changes: 3 additions & 1 deletion pol-core/pol/multi/customhouses.h
Expand Up @@ -80,6 +80,7 @@ typedef std::list<CUSTOM_HOUSE_ELEMENT> HouseFloorZColumn;
// v v v v v v
// [][][][][][] - lists of zoffsets
// [][][][][][]
typedef std::list<Items::Item*> ItemList;

class CustomHouseElements
{
Expand Down Expand Up @@ -174,7 +175,8 @@ void CustomHousesSendFull( UHouse* house, Network::Client* client,
int design = HOUSE_DESIGN_CURRENT );
void CustomHousesSendFullToInRange( UHouse* house, int design, int range );
void CustomHousesSendShort( UHouse* house, Network::Client* client );
void CustomHouseStopEditing( Mobile::Character* chr, UHouse* house, bool send_pkts = true );
void CustomHouseStopEditing( Mobile::Character* chr, UHouse* house, ItemList& itemlist,
bool send_pkts = true );
} // namespace Multi
} // namespace Pol
#endif
26 changes: 25 additions & 1 deletion pol-core/pol/multi/house.cpp
Expand Up @@ -61,6 +61,28 @@ namespace Pol
{
namespace Multi
{
Core::Range3d UHouse::current_box() const
{
if ( IsCustom() )
{
const MultiDef& md = multidef();
return Core::Range3d( pos() + md.minrxyz, pos() + md.maxrxyz + Core::Vec2d( 0, 1 ) );
}

return base::current_box();
}

ItemList UHouse::get_working_design_items( UHouse* house )
{
ItemList itemlist;
MobileList moblist;
bool was_editing = house->editing;
house->editing = false;
UHouse::list_contents( house, itemlist, moblist );
house->editing = was_editing;
return itemlist;
}

void UHouse::list_contents( const UHouse* house, ItemList& items_in, MobileList& chrs_in )
{
auto box = house->current_box();
Expand Down Expand Up @@ -977,6 +999,8 @@ void UHouse::AcceptHouseCommit( Mobile::Character* chr, bool accept )
waiting_for_accept = false;
if ( accept )
{
auto itemlist = get_working_design_items( this );

revision++;

// commit working design to current design
Expand All @@ -986,7 +1010,7 @@ void UHouse::AcceptHouseCommit( Mobile::Character* chr, bool accept )
std::vector<u8> newvec;
CurrentCompressed.swap( newvec );

CustomHouseStopEditing( chr, this );
CustomHouseStopEditing( chr, this, itemlist );

// send full house
CustomHousesSendFullToInRange( this, HOUSE_DESIGN_CURRENT, RANGE_VISUAL_LARGE_BUILDINGS );
Expand Down
3 changes: 3 additions & 0 deletions pol-core/pol/multi/house.h
Expand Up @@ -98,10 +98,13 @@ class UHouse final : public UMulti

virtual void walk_on( Mobile::Character* chr ) override;

virtual Core::Range3d current_box() const override;

void ClearSquatters();
bool add_component( Items::Item* item, s32 xoff, s32 yoff, s16 zoff );
bool add_component( Component component );
static void list_contents( const UHouse* house, ItemList& items_in, MobileList& chrs_in );
static ItemList get_working_design_items( UHouse* house );
void AcceptHouseCommit( Mobile::Character* chr, bool accept );
void CustomHousesQuit( Mobile::Character* chr, bool drop_changes, bool send_pkts = true );

Expand Down
2 changes: 1 addition & 1 deletion pol-core/pol/multi/multi.h
Expand Up @@ -88,7 +88,7 @@ class UMulti : public Items::Item
Bscript::BStruct* footprint() const;
virtual bool readshapes( Plib::MapShapeList& vec, s16 rx, s16 ry, s16 zbase );
virtual bool readobjects( Plib::StaticList& vec, s16 rx, s16 ry, s16 zbase );
Core::Range3d current_box() const;
virtual Core::Range3d current_box() const;

virtual ~UMulti();
virtual size_t estimatedSize() const override;
Expand Down
3 changes: 2 additions & 1 deletion pol-core/pol/realms/realmfunc.cpp
Expand Up @@ -434,7 +434,8 @@ bool Realm::walkheight( const Mobile::Character* chr, const Core::Pos2d& pos, sh
Multi::UHouse* house = multi->as_house();
if ( house != nullptr )
{
Multi::CustomHouseStopEditing( const_cast<Mobile::Character*>( chr ), house );
Multi::ItemList itemlist = Multi::UHouse::get_working_design_items( house );
Multi::CustomHouseStopEditing( const_cast<Mobile::Character*>( chr ), house, itemlist );
Multi::CustomHousesSendFull( house, chr->client, Multi::HOUSE_DESIGN_CURRENT );
}
}
Expand Down

0 comments on commit c90e564

Please sign in to comment.