Beispiel #1
0
	bool move_character_to( Mobile::Character* chr,
							unsigned short x,
							unsigned short y,
							short z,
							int flags,
							Plib::Realm* oldrealm )
	{
	  // FIXME consider consolidating with similar code in CHARACTER.CPP
	  short newz;
	  Multi::UMulti* supporting_multi = NULL;
	  Items::Item* walkon_item = NULL;
	  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();

	  if ( ( oldrealm != NULL ) && ( oldrealm != chr->realm ) )
	  {
		chr->lastx = 0;
		chr->lasty = 0;
		chr->lastz = 0;
	  }
	  else
	  {
		chr->lastx = chr->x;
		chr->lasty = chr->y;
		chr->lastz = chr->z;
	  }
	  // probably easier and safer to just check if (chr->logged_in)
	  if ( chr->isa( UObject::CLASS_NPC ) || chr->client ) //dave 3/26/3 otherwise exception trying to move offline mobile not found in characters list
	  {
		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.
	  if ( supporting_multi != NULL )
	  {
		supporting_multi->register_object( chr );
		Multi::UHouse* this_house = supporting_multi->as_house();
		if ( chr->registered_house == 0 )
		{
			chr->registered_house = supporting_multi->serial;

		    if ( this_house != NULL )
				this_house->walk_on( chr );
		}
	  }
	  else
	  {
		if ( chr->registered_house > 0 )
		{
          Multi::UMulti* multi = system_find_multi( chr->registered_house );
		  if ( multi != NULL )
		  {
			  multi->unregister_object( chr );
		  }
		  chr->registered_house = 0;
		}
	  }

	  // teleport( chr );
	  if ( chr->has_active_client() )
	  {
		passert_assume( chr->client != NULL ); // tells compiler to assume this is true during static code analysis

		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.
		chr->client->gd->weather_region = NULL;
	  }
	  if ( chr->isa( UObject::CLASS_NPC ) || 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();
	  }
	  if ( walkon_item != NULL )
	  {
		walkon_item->walk_on( chr );
	  }

	  chr->lastx = chr->x;
	  chr->lasty = chr->y;
	  chr->lastz = chr->z;

	  return true;
	}
Beispiel #2
0
void handle_msg_BF( Client* client, PKTBI_BF* msg )
	{
	UObject* obj = NULL;
	UMulti* multi = NULL;
	UHouse* house = NULL;
	switch(cfBEu16(msg->subcmd))
		{
		case PKTBI_BF::TYPE_CLIENT_LANGUAGE:
			client->chr->uclang = strlower(msg->client_lang);
			break;
		case PKTBI_BF::TYPE_REQ_FULL_CUSTOM_HOUSE:
			if( (client->UOExpansionFlag & AOS) == 0 )
				return;
			multi = system_find_multi(cfBEu32(msg->reqfullcustomhouse.house_serial));
			if(multi != NULL)
				{
				house = multi->as_house();
				if(house != NULL)
					{
					if(client->UOExpansionFlag & AOS)
						{
						send_object_cache(client, (UObject*)(house));
						}
					//consider sending working design to certain players, to assist building, or GM help
					CustomHousesSendFull( house, client, HOUSE_DESIGN_CURRENT );
					}
				}
			break;
		case PKTBI_BF::TYPE_OBJECT_CACHE:
			if( (client->UOExpansionFlag & AOS) == 0)
				return;
			obj = system_find_object(cfBEu32(msg->objectcache.serial));
			if(obj != NULL)
				{
				SendAOSTooltip(client,obj);
				}
			break;
		case PKTBI_BF::TYPE_SESPAM:
			return;
			break;
		case PKTBI_BF::TYPE_SPELL_SELECT:
			do_cast(client, cfBEu16(msg->spellselect.selected_spell) );
			break;
		case PKTBI_BF::TYPE_CHARACTER_RACE_CHANGER:
			character_race_changer_handler( client, msg );
			break;
		case PKTBI_BF::TYPE_PARTY_SYSTEM:
			party_cmd_handler( client, msg );
			break;
		case PKTBI_BF::TYPE_EXTENDED_STATS_IN:
			ext_stats_in(client, msg);
			break;
		case PKTBI_BF::TYPE_CLOSED_STATUS_GUMP:
			return;
			break;
		case PKTBI_BF::TYPE_SCREEN_SIZE:
			return;
			break;
		case PKTBI_BF::TYPE_TOGGLE_FLYING:
			if (client->chr->race==RACE_GARGOYLE)
				{
				// FIXME: add checks if its possible to stand with new movemode
				client->chr->movemode = (MOVEMODE)(client->chr->movemode ^ MOVEMODE_FLY);
				send_move_mobile_to_nearby_cansee( client->chr );
				send_goxyz( client, client->chr );
				}
			break;
		case PKTBI_BF::TYPE_CLIENTTYPE:
			client->UOExpansionFlagClient = ctBEu32( msg->clienttype.clientflag );
			break;
		default:
			handle_unknown_packet( client );
		}
	}