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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool move_character_to( Mobile::Character* chr, unsigned short x, unsigned short y, short z,
|
|
|
|
|
int flags, Realms::Realm* oldrealm )
|
|
|
|
|
{
|
|
|
|
|
// FIXME consider consolidating with similar code in CHARACTER.CPP
|
|
|
|
|
short 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;
|
|
|
|
|
|
|
|
|
|
if ( flags & MOVEITEM_FORCELOCATION )
|
|
|
|
|
{
|
|
|
|
|
if ( x >= chr->realm->width() || y >= chr->realm->height() )
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
chr->realm->walkheight( x, y, z, &newz, &supporting_multi, &walkon_item, true, chr->movemode,
|
|
|
|
|
&new_boost );
|
|
|
|
|
newz = z;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ( !chr->realm->walkheight( chr, x, y, z, &newz, &supporting_multi, &walkon_item,
|
|
|
|
|
&new_boost ) )
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
chr->set_dirty();
|
|
|
|
|
|
2018-07-31 14:30:29 +02:00
|
|
|
if ( ( oldrealm != nullptr ) && ( oldrealm != chr->realm ) )
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
|
|
|
|
chr->lastx = 0;
|
|
|
|
|
chr->lasty = 0;
|
|
|
|
|
chr->lastz = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
chr->lastx = chr->x;
|
|
|
|
|
chr->lasty = chr->y;
|
|
|
|
|
chr->lastz = chr->z;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MoveCharacterWorldPosition( chr->x, chr->y, x, y, chr, oldrealm );
|
|
|
|
|
chr->x = x;
|
|
|
|
|
chr->y = y;
|
|
|
|
|
chr->z = static_cast<s8>( newz );
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
if ( oldrealm != chr->realm )
|
|
|
|
|
{
|
|
|
|
|
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 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
chr->lastx = chr->x;
|
|
|
|
|
chr->lasty = chr->y;
|
|
|
|
|
chr->lastz = chr->z;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* For us to care, the item must:
|
|
|
|
|
1) be directly under the current position
|
|
|
|
|
2) have a "walk on" script
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
Items::Item* find_walkon_item( ItemsVector& ivec, short z )
|
|
|
|
|
{
|
|
|
|
|
for ( ItemsVector::const_iterator itr = ivec.begin(), end = ivec.end(); itr != end; ++itr )
|
|
|
|
|
{
|
|
|
|
|
Items::Item* item = ( *itr );
|
|
|
|
|
if ( z == item->z || z == item->z + 1 )
|
|
|
|
|
{
|
|
|
|
|
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
|