2016-01-28 14:52:40 +01:00
|
|
|
/** @file
|
|
|
|
|
*
|
|
|
|
|
* @par History
|
|
|
|
|
* - 2009/09/03 MuadDib: Relocation of multi related cpp/h
|
|
|
|
|
* - 2009/09/15 MuadDib: Multi registration/unregistration support added.
|
|
|
|
|
*/
|
2016-02-11 22:54:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "core.h"
|
|
|
|
|
|
2018-01-29 21:55:48 +01:00
|
|
|
#include <stddef.h>
|
2016-02-11 22:54:43 +01:00
|
|
|
|
2018-11-03 13:14:53 +01:00
|
|
|
#include "../clib/compilerspecifics.h"
|
2018-01-29 21:55:48 +01:00
|
|
|
#include "../clib/rawtypes.h"
|
|
|
|
|
#include "fnsearch.h"
|
2016-02-11 22:54:43 +01:00
|
|
|
#include "globals/uvars.h"
|
2018-01-29 21:55:48 +01:00
|
|
|
#include "item/item.h"
|
|
|
|
|
#include "item/itemdesc.h"
|
2016-02-11 22:54:43 +01:00
|
|
|
#include "mobile/charactr.h"
|
2018-01-29 21:55:48 +01:00
|
|
|
#include "multi/house.h"
|
|
|
|
|
#include "multi/multi.h"
|
2016-02-11 22:54:43 +01:00
|
|
|
#include "network/cgdata.h"
|
|
|
|
|
#include "network/client.h"
|
2018-01-29 21:55:48 +01:00
|
|
|
#include "realms/realm.h"
|
2016-02-11 22:54:43 +01:00
|
|
|
#include "ufunc.h"
|
|
|
|
|
#include "uworld.h"
|
|
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
namespace Pol
|
|
|
|
|
{
|
|
|
|
|
namespace Core
|
|
|
|
|
{
|
|
|
|
|
void SetSysTrayPopupText( const char* text );
|
2016-02-11 22:54:43 +01:00
|
|
|
#ifdef _WIN32
|
2016-02-19 19:26:35 +01:00
|
|
|
static Priority tipPriority = ToolTipPriorityNone;
|
2016-02-11 22:54:43 +01:00
|
|
|
#endif
|
2016-02-19 19:26:35 +01:00
|
|
|
void CoreSetSysTrayToolTip( const std::string& text, Priority priority )
|
|
|
|
|
{
|
2016-02-11 22:54:43 +01:00
|
|
|
#ifdef _WIN32
|
2016-02-19 19:26:35 +01:00
|
|
|
if ( priority >= tipPriority )
|
|
|
|
|
{
|
|
|
|
|
tipPriority = priority;
|
|
|
|
|
SetSysTrayPopupText( text.c_str() );
|
|
|
|
|
}
|
2016-02-11 22:54:43 +01:00
|
|
|
#else
|
2016-02-19 19:26:35 +01:00
|
|
|
(void)text;
|
|
|
|
|
(void)priority;
|
2016-02-11 22:54:43 +01:00
|
|
|
#endif
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
|
|
|
|
|
2020-04-04 17:22:24 +02:00
|
|
|
bool move_character_to( Mobile::Character* chr, Pos4d newpos, int flags )
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
|
|
|
|
// FIXME consider consolidating with similar code in CHARACTER.CPP
|
2020-04-19 12:46:57 +02:00
|
|
|
s8 newz;
|
2018-07-31 14:30:29 +02:00
|
|
|
Multi::UMulti* supporting_multi = nullptr;
|
|
|
|
|
Items::Item* walkon_item = nullptr;
|
2016-02-19 19:26:35 +01:00
|
|
|
short new_boost = 0;
|
2020-04-04 17:22:24 +02:00
|
|
|
Pos4d oldpos = chr->pos();
|
2016-02-19 19:26:35 +01:00
|
|
|
|
|
|
|
|
if ( flags & MOVEITEM_FORCELOCATION )
|
|
|
|
|
{
|
2020-04-05 21:41:56 +02:00
|
|
|
newpos.realm()->walkheight( newpos.xy(), newpos.z(), &newz, &supporting_multi, &walkon_item,
|
|
|
|
|
true, chr->movemode, &new_boost );
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-04-05 21:41:56 +02:00
|
|
|
if ( !newpos.realm()->walkheight( chr, newpos.xy(), newpos.z(), &newz, &supporting_multi,
|
|
|
|
|
&walkon_item, &new_boost ) )
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2020-04-19 12:46:57 +02:00
|
|
|
newpos.z( newz );
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
|
|
|
|
chr->set_dirty();
|
|
|
|
|
|
2020-04-04 17:22:24 +02:00
|
|
|
if ( ( oldpos.realm() != nullptr ) && ( oldpos.realm() != newpos.realm() ) )
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
2020-04-04 17:22:24 +02:00
|
|
|
// Notify NPCs in the old realm that the player left the realm.
|
|
|
|
|
oldpos.realm()->notify_left( *chr );
|
|
|
|
|
|
|
|
|
|
send_remove_character_to_nearby( chr );
|
|
|
|
|
if ( chr->client != nullptr )
|
|
|
|
|
remove_objects_inrange( chr->client );
|
|
|
|
|
chr->setposition( newpos );
|
|
|
|
|
chr->realm_changed();
|
|
|
|
|
chr->lastxyz = Pos3d( 0, 0, 0 );
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-04-04 17:22:24 +02:00
|
|
|
chr->setposition( newpos );
|
|
|
|
|
chr->lastxyz = oldpos.xyz();
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
2020-04-04 17:22:24 +02:00
|
|
|
MoveCharacterWorldPosition( oldpos, chr );
|
2016-02-19 19:26:35 +01:00
|
|
|
|
|
|
|
|
chr->gradual_boost = new_boost;
|
|
|
|
|
chr->position_changed();
|
|
|
|
|
// FIXME: Need to add Walkon checks for multi right here if type is house.
|
2018-07-31 14:30:29 +02:00
|
|
|
if ( supporting_multi != nullptr )
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
|
|
|
|
supporting_multi->register_object( chr );
|
|
|
|
|
Multi::UHouse* this_house = supporting_multi->as_house();
|
|
|
|
|
if ( chr->registered_house == 0 )
|
|
|
|
|
{
|
|
|
|
|
chr->registered_house = supporting_multi->serial;
|
|
|
|
|
|
2018-07-31 14:30:29 +02:00
|
|
|
if ( this_house != nullptr )
|
2016-02-19 19:26:35 +01:00
|
|
|
this_house->walk_on( chr );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ( chr->registered_house > 0 )
|
|
|
|
|
{
|
|
|
|
|
Multi::UMulti* multi = system_find_multi( chr->registered_house );
|
2018-07-31 14:30:29 +02:00
|
|
|
if ( multi != nullptr )
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
|
|
|
|
multi->unregister_object( chr );
|
|
|
|
|
}
|
|
|
|
|
chr->registered_house = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// teleport( chr );
|
|
|
|
|
if ( chr->has_active_client() )
|
|
|
|
|
{
|
|
|
|
|
passert_assume( chr->client !=
|
2018-07-31 14:30:29 +02:00
|
|
|
nullptr ); // tells compiler to assume this is true during static code analysis
|
2016-02-19 19:26:35 +01:00
|
|
|
|
2020-04-04 17:22:24 +02:00
|
|
|
if ( oldpos.realm() != chr->realm() )
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
|
|
|
|
send_new_subserver( chr->client );
|
|
|
|
|
send_owncreate( chr->client, chr );
|
|
|
|
|
}
|
|
|
|
|
send_goxyz( chr->client, chr );
|
|
|
|
|
|
|
|
|
|
// send_goxyz seems to stop the weather. This will force a refresh, if the client cooperates.
|
2018-07-31 14:30:29 +02:00
|
|
|
chr->client->gd->weather_region = nullptr;
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
2016-12-12 22:21:59 +01:00
|
|
|
if ( chr->isa( UOBJ_CLASS::CLASS_NPC ) ||
|
2016-02-19 19:26:35 +01:00
|
|
|
chr->client ) // dave 3/26/3 dont' tell moves of offline PCs
|
|
|
|
|
{
|
|
|
|
|
chr->tellmove();
|
|
|
|
|
}
|
|
|
|
|
if ( chr->has_active_client() )
|
|
|
|
|
{
|
|
|
|
|
send_objects_newly_inrange( chr->client );
|
|
|
|
|
chr->check_light_region_change();
|
2016-02-11 22:54:43 +01:00
|
|
|
}
|
2018-07-31 14:30:29 +02:00
|
|
|
if ( walkon_item != nullptr )
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
|
|
|
|
walkon_item->walk_on( chr );
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-04 17:22:24 +02:00
|
|
|
chr->lastxyz = chr->pos().xyz();
|
2016-02-19 19:26:35 +01:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* For us to care, the item must:
|
|
|
|
|
1) be directly under the current position
|
|
|
|
|
2) have a "walk on" script
|
|
|
|
|
*/
|
|
|
|
|
|
2020-04-19 12:46:57 +02:00
|
|
|
Items::Item* find_walkon_item( ItemsVector& ivec, s8 z )
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
|
|
|
|
for ( ItemsVector::const_iterator itr = ivec.begin(), end = ivec.end(); itr != end; ++itr )
|
|
|
|
|
{
|
|
|
|
|
Items::Item* item = ( *itr );
|
2020-04-04 17:22:24 +02:00
|
|
|
if ( z == item->z() || z == item->z() + 1 )
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
|
|
|
|
if ( !item->itemdesc().walk_on_script.empty() )
|
|
|
|
|
{
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-31 14:30:29 +02:00
|
|
|
return nullptr;
|
2016-02-19 19:26:35 +01:00
|
|
|
}
|
2018-11-03 13:14:53 +01:00
|
|
|
} // namespace Core
|
|
|
|
|
} // namespace Pol
|