Пример #1
0
void WorldSession::HandleIgnoreTrade(WorldPacket & recv_data)
{
	if(!_player->IsInWorld()) return;
	uint32 TradeStatus = TRADE_STATUS_PLAYER_IGNORED;

	Player * plr = _player->GetTradeTarget();
	if(_player->mTradeTarget == 0 || plr == 0)
	{
#ifdef USING_BIG_ENDIAN
		TradeStatus = swap32(uint32(TRADE_STATUS_PLAYER_NOT_FOUND));
#else
		TradeStatus = TRADE_STATUS_PLAYER_NOT_FOUND;
#endif
		OutPacket(TRADE_STATUS_PLAYER_NOT_FOUND, 4, &TradeStatus);
		return;
	}

#ifdef USING_BIG_ENDIAN
	swap32(&TradeStatus);
	OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
	plr->m_session->OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
	swap32(&TradeStatus);
#else
	OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
	plr->m_session->OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
#endif

	plr->mTradeStatus = TradeStatus;
	_player->mTradeStatus = TradeStatus;

	plr->mTradeTarget = 0;
	_player->mTradeTarget = 0;
}
Пример #2
0
void WorldSocket::Authenticate()
{
	WorldSession * pSession = mSession;
	ASSERT(pAuthenticationPacket);
	mQueued = false;

	if(!pSession) return;
	pSession->deleteMutex.Acquire();

	if(pSession->HasFlag(ACCOUNT_FLAG_XPACK_01))
		OutPacket(SMSG_AUTH_RESPONSE, 11, "\x0C\x30\x78\x00\x00\x00\x00\x00\x00\x00\x01");
	else
		OutPacket(SMSG_AUTH_RESPONSE, 11, "\x0C\x30\x78\x00\x00\x00\x00\x00\x00\x00\x00");

	sAddonMgr.SendAddonInfoPacket(pAuthenticationPacket, (uint32)pAuthenticationPacket->rpos(), pSession);
	pSession->_latency = _latency;

	delete pAuthenticationPacket;
	pAuthenticationPacket = 0;

	if(mSession)
	{
		sWorld.AddSession(mSession);
		sWorld.AddGlobalSession(mSession);

/*		if(pSession->HasFlag(ACCOUNT_FLAG_XTEND_INFO))
			sWorld.AddExtendedSession(pSession);*/

		if(pSession->HasGMPermissions() && mSession)
			sWorld.gmList.insert(pSession);
	}

	pSession->deleteMutex.Release();
}
Пример #3
0
void WorldSocket::Authenticate()
{
	WorldSession * pSession = mSession;
	ASSERT(pAuthenticationPacket);
	mQueued = false;

	if(!pSession)
	{
		DEBUG_LOG( "WorldSocket","Lost Session");
		return;
	}

	if(pSession->HasFlag(ACCOUNT_FLAG_XPACK_02))
		OutPacket(SMSG_AUTH_RESPONSE, 11, "\x0C\x30\x78\x00\x00\x00\x00\x00\x00\x00\x02");
	else if(pSession->HasFlag(ACCOUNT_FLAG_XPACK_01))
		OutPacket(SMSG_AUTH_RESPONSE, 11, "\x0C\x30\x78\x00\x00\x00\x00\x00\x00\x00\x01");
	else
		OutPacket(SMSG_AUTH_RESPONSE, 11, "\x0C\x30\x78\x00\x00\x00\x00\x00\x00\x00\x00");

	sAddonMgr.SendAddonInfoPacket(pAuthenticationPacket, (uint32)pAuthenticationPacket->rpos(), pSession);
	pSession->_latency = _latency;

	delete pAuthenticationPacket;
	pAuthenticationPacket = NULL;

	sWorld.AddSession(pSession);
	sWorld.AddGlobalSession(pSession);
}
Пример #4
0
void WorldSession::HandleBusyTrade(WorldPacket & recv_data)
{
	CHECK_INWORLD_RETURN

	uint32 TradeStatus = TRADE_STATUS_PLAYER_BUSY;

	Player* plr = _player->GetTradeTarget();
	if(_player->mTradeTarget == 0 || plr == 0)
	{

		TradeStatus = TRADE_STATUS_PLAYER_NOT_FOUND;

		OutPacket(TRADE_STATUS_PLAYER_NOT_FOUND, 4, &TradeStatus);
		return;
	}


	OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
	plr->m_session->OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);

	plr->mTradeStatus = TradeStatus;
	_player->mTradeStatus = TradeStatus;

	plr->mTradeTarget = 0;
	_player->mTradeTarget = 0;
}
Пример #5
0
void WorldSession::HandleClearTradeItem(WorldPacket & recv_data)
{
	CHECK_PACKET_SIZE(recv_data, 1);
	if(_player->mTradeTarget == 0)
		return;

	uint8 TradeSlot = recv_data.contents()[0];
	if(TradeSlot > 6)
		return;

  // clean status
	Player * plr = _player->GetTradeTarget();
	if ( !plr ) return;

	uint32 TradeStatus = TRADE_STATUS_STATE_CHANGED;

#ifdef USING_BIG_ENDIAN
	swap32(&TradeStatus);
	OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
	plr->m_session->OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
	swap32(&TradeStatus);
#else
	OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
	plr->m_session->OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
#endif

	plr->mTradeStatus = TradeStatus;
	_player->mTradeStatus = TradeStatus;


	_player->mTradeItems[TradeSlot] = 0;
	_player->SendTradeUpdate();
}
Пример #6
0
void WorldSession::HandleSetTradeGold(WorldPacket & recv_data)
{
	if(_player->mTradeTarget == 0)
		return;
  // cebernic: TradeGold sameway.
	uint32 TradeStatus = TRADE_STATUS_STATE_CHANGED;
	Player * plr = _player->GetTradeTarget();
	if(!plr) return;

#ifdef USING_BIG_ENDIAN
	swap32(&TradeStatus);
	OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
	plr->m_session->OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
	swap32(&TradeStatus);
#else
	OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
	plr->m_session->OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
#endif

	plr->mTradeStatus = TradeStatus;
	_player->mTradeStatus = TradeStatus;


	uint32 Gold;
	recv_data >> Gold;

	if(_player->mTradeGold != Gold)
	{
		_player->mTradeGold = (Gold > _player->GetUInt32Value(PLAYER_FIELD_COINAGE) ? _player->GetUInt32Value(PLAYER_FIELD_COINAGE) : Gold);
		_player->SendTradeUpdate();
	}
}
Пример #7
0
void WorldSession::HandleLfgInviteAccept(WorldPacket & recvPacket)
{
	CHECK_INWORLD_RETURN;
	
	_player->PartLFGChannel();
	if(_player->m_lfgMatch == NULL && _player->m_lfgInviterGuid == 0)
	{
		if(_player->m_lfgMatch == NULL)
			OutPacket(SMSG_LFG_AUTOJOIN_FAILED_NO_PLAYER);		// Matched Player(s) have gone offline.
		else
			OutPacket(SMSG_LFG_AUTOJOIN_FAILED);				// Group no longer available.

		return;
	}

	if( _player->m_lfgMatch != NULL )
	{
		// move into accepted players
		_player->m_lfgMatch->lock.Acquire();
		_player->m_lfgMatch->PendingPlayers.erase(_player);

		if( !_player->GetGroup() )
		{
			_player->m_lfgMatch->AcceptedPlayers.insert(_player);

			if(!_player->m_lfgMatch->PendingPlayers.size())
			{
				// all players have accepted
				Group * pGroup = new Group(true);
				for(set<Player*>::iterator itr = _player->m_lfgMatch->AcceptedPlayers.begin(); itr != _player->m_lfgMatch->AcceptedPlayers.end(); ++itr)
					pGroup->AddMember((*itr)->m_playerInfo);

				_player->m_lfgMatch->pGroup = pGroup;
			}
		}
		_player->m_lfgMatch->lock.Release();
	}
	else
	{
		Player * pPlayer = objmgr.GetPlayer(_player->m_lfgInviterGuid);
		if( pPlayer == NULL )
		{
			OutPacket(SMSG_LFG_AUTOJOIN_FAILED_NO_PLAYER);			// Matched Player(s) have gone offline.
			return;
		}

		if( pPlayer->GetGroup() == NULL || pPlayer->GetGroup()->IsFull() || pPlayer->GetGroup()->GetLeader() != pPlayer->m_playerInfo )
		{
			OutPacket(SMSG_LFG_AUTOJOIN_FAILED);
			return;
		}

		pPlayer->GetGroup()->AddMember(_player->m_playerInfo);
	}
	_player->m_lfgInviterGuid = 0;
	_player->m_lfgMatch = NULL;
}
Пример #8
0
void WorldSocket::Authenticate()
{
	ASSERT(pAuthenticationPacket);
	delete pAuthenticationPacket;
	pAuthenticationPacket = 0;

	if(m_session->m_accountFlags & 8)
		OutPacket(SMSG_AUTH_RESPONSE, 11, "\x0C\x30\x78\x00\x00\x00\x00\x00\x00\x00\x01");
	else
		OutPacket(SMSG_AUTH_RESPONSE, 11, "\x0C\x30\x78\x00\x00\x00\x00\x00\x00\x00\x00");
}
Пример #9
0
void WorldSocket::OnConnect()
{
    sWorld.mAcceptedConnections++;
    _latency = getMSTime();

#ifdef USING_BIG_ENDIAN
    uint32 swapped = swap32(mSeed);
    OutPacket(SMSG_AUTH_CHALLENGE, 4, &swapped);
#else
    OutPacket(SMSG_AUTH_CHALLENGE, 4, &mSeed);
#endif
}
Пример #10
0
void WorldSession::HandleBeginTrade(WorldPacket & recv_data)
{
	if(!_player->IsInWorld()) 
	{ 
		return;
	}
#ifdef FORCED_GM_TRAINEE_MODE
	if( CanUseCommand('k') && !HasGMPermissions() )
	{
		GetPlayer()->BroadcastMessage( "You are not allowed to use this feature" );
		return;
	}
#endif
	if( sWorld.getIntRate( INTRATE_DISABLE_TRADE_FEATURE ) )
	{
		GetPlayer()->BroadcastMessage( "Trade feature is disabled right now" );
		return;
	}
	sLog.outDebug( "WORLD: got CMSG_BEGIN_TRADE from player %s.", _player->GetName() );
	packetSMSG_TRADE_STATUS data;
	memset( &data, 0, sizeof( data ) );
	data.trade_status = TRADE_STATUS_INITIATED;
	data.trade_id = TRADE_ID_CONST;	//this the constant used in status update also !

	Player * plr = _player->GetTradeTarget();
	if(_player->mTradeTarget == 0 || plr == 0)
	{
		data.trade_status = TRADE_STATUS_PLAYER_NOT_FOUND;
		OutPacket(SMSG_TRADE_STATUS,sizeof( packetSMSG_TRADE_STATUS ), &data);
		return;
	}
	// We're too far from target now?
	Player * plr2 = objmgr.GetPlayer(_player->mTradeTarget);
	if( plr2 == NULL )
	{
		return; //wtf ? player is inside the map and not in objectmanager ?
	}
	if( _player->CalcDistance( plr2 ) > 10.0f )
		data.trade_status = TRADE_STATUS_TOO_FAR_AWAY;

	//send to ourself
	OutPacket(SMSG_TRADE_STATUS,sizeof( packetSMSG_TRADE_STATUS ), &data);
	//send to our target
	plr->m_session->OutPacket(SMSG_TRADE_STATUS,sizeof( packetSMSG_TRADE_STATUS ), &data);

	plr->mTradeStatus = data.trade_status;
	_player->mTradeStatus = data.trade_status;

//	_player->SendTradeUpdate( 0 );
//	plr->SendTradeUpdate( 0 );
}
Пример #11
0
void WorldSession::SendItemPushResult(Item * pItem, bool Created, bool Received, bool SendToSet, bool NewItem, uint8 DestBagSlot, uint32 DestSlot, uint32 AddCount)
{
	/*WorldPacket data(SMSG_ITEM_PUSH_RESULT, 60);
	data << _player->GetGUID();
	data << uint32(Received);
	data << uint32(Created);
	data << uint32(1);
	data << uint8(DestBagSlot);
	data << uint32(NewItem ? DestSlot : 0xFFFFFFFF);
	data << pItem->GetEntry();
	data << pItem->GetItemRandomSuffixFactor();
	data << pItem->GetUInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID);
	data << AddCount;
	data << pItem->GetUInt32Value(ITEM_FIELD_STACK_COUNT);*/

	packetSMSG_ITEM_PUSH_RESULT data;
	data.guid = _player->GetGUID();
	data.received = Received;
	data.created = Created;
	data.unk1 = 1;
	data.destbagslot = DestBagSlot;
	data.destslot = NewItem ? DestSlot : 0xFFFFFFFF;
	data.entry = pItem->GetEntry();
	data.suffix = pItem->GetItemRandomSuffixFactor();
	data.randomprop = pItem->GetUInt32Value( ITEM_FIELD_RANDOM_PROPERTIES_ID );
	data.count = AddCount;
	data.stackcount = pItem->GetUInt32Value(ITEM_FIELD_STACK_COUNT);

	if(SendToSet)
	{
		/*if(Created)
			_player->SendMessageToSet(&data, true);
		else
		{*/
			/*if(_player->GetGroup())
				_player->GetGroup()->SendPacketToAll(&data);
			else
				SendPacket(&data);*/
		/*}*/

		if( _player->GetGroup() )
			_player->GetGroup()->OutPacketToAll( SMSG_ITEM_PUSH_RESULT, sizeof( packetSMSG_ITEM_PUSH_RESULT ), &data );
		else
			OutPacket( SMSG_ITEM_PUSH_RESULT, sizeof( packetSMSG_ITEM_PUSH_RESULT ), &data );
	}
	else
	{
		//SendPacket(&data);
		OutPacket( SMSG_ITEM_PUSH_RESULT, sizeof( packetSMSG_ITEM_PUSH_RESULT ), &data );
	}
}
Пример #12
0
void WorldSocket::Authenticate()
{
    if(m_session->m_accountFlags & 16)
        OutPacket(SMSG_AUTH_RESPONSE, 11, "\x0C\x30\x78\x00\x00\x00\x00\x00\x00\x00\x02");
    else if(m_session->m_accountFlags & 8)
        OutPacket(SMSG_AUTH_RESPONSE, 11, "\x0C\x30\x78\x00\x00\x00\x00\x00\x00\x00\x01");
    else
        OutPacket(SMSG_AUTH_RESPONSE, 11, "\x0C\x30\x78\x00\x00\x00\x00\x00\x00\x00\x00");

    SendAddonInfoPacket(pAuthenticationPacket, (uint32)pAuthenticationPacket->rpos(), m_session);

    delete pAuthenticationPacket;
    pAuthenticationPacket = 0;
}
Пример #13
0
void WorldSession::HandleCancelTrade(WorldPacket & recv_data)
{
	if(!_player->IsInWorld()) 
	{ 
		return;
	}

	sLog.outDebug( "WORLD: got CMSG_CANCEL_TRADE from player %s.", _player->GetName() );
	if(_player->mTradeTarget == 0 || _player->mTradeStatus == TRADE_STATUS_COMPLETE)
	{ 
		return;
	}

	packetSMSG_TRADE_STATUS data;
	memset( &data, 0, sizeof( data ) );
	data.trade_status = TRADE_STATUS_CANCELLED;

	//send to ourself
	OutPacket(SMSG_TRADE_STATUS,sizeof( packetSMSG_TRADE_STATUS ), &data);

	Player * plr = _player->GetTradeTarget();
    if(plr)
    {
		//send to our target
        if(plr->m_session && plr->m_session->GetSocket())
			plr->m_session->OutPacket(SMSG_TRADE_STATUS,sizeof( packetSMSG_TRADE_STATUS ), &data);
	
		plr->ResetTradeVariables();
    }
	
	_player->ResetTradeVariables();
}
Пример #14
0
void WorldServerSocket::OnConnect()
{
	sWorld.AcceptedConnections++;
	_latency = (uint32)time(NULL);

	OutPacket(SMSG_AUTH_CHALLENGE, 4, &mSeed);
}
Пример #15
0
bool WorldSession::ClusterTryPlayerLogin(uint32 Guid, uint32 ClientBuild, string GMPermissions, uint32 Account_Flags)
{
	DEBUG_LOG( "WorldSession"," Recvd Player Logon Message" );

	if(objmgr.GetPlayer(Guid) != NULL || m_loggingInPlayer || _player)
	{
		// A character with that name already exists 0x3E
		uint8 respons = 0x3E;
		OutPacket(SMSG_CHARACTER_LOGIN_FAILED, 1, &respons);
		return false;
	}

	Player* plr = new Player(Guid);
	ASSERT(plr);
	plr->Init();

	permissioncount = 0;//just to make sure it's 0
	SetClientBuild(ClientBuild);
	LoadSecurity(GMPermissions);
	SetAccountFlags(Account_Flags);

	plr->SetSession(this);
	m_bIsWLevelSet = false;

	DEBUG_LOG("WorldSession", "Async loading player %u", Guid);
	m_loggingInPlayer = plr;
	plr->LoadFromDB(Guid);
	return true;
}
Пример #16
0
void WorldSession::HandleCancelTrade(WorldPacket & recv_data)
{
	if(!_player->IsInWorld()) return;
	if(_player->mTradeTarget == 0 || _player->mTradeStatus == TRADE_STATUS_COMPLETE)
		return;

#ifdef USING_BIG_ENDIAN
	uint32 TradeStatus = swap32(uint32(TRADE_STATUS_CANCELLED));
#else
    uint32 TradeStatus = TRADE_STATUS_CANCELLED;
#endif

    OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);

	Player * plr = _player->GetTradeTarget();
    if(plr)
    {
        if(plr->m_session && plr->m_session->GetSocket())
		plr->m_session->OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
	
	    plr->mTradeTarget = 0;
		plr->ResetTradeVariables();
    }
	
	_player->mTradeTarget = 0;
	_player->ResetTradeVariables();
}
Пример #17
0
void WorldSession::HandleBeginTrade(WorldPacket& recv_data)
{
    CHECK_INWORLD_RETURN

    uint32 TradeStatus = TRADE_STATUS_INITIATED;

    Player* plr = _player->GetTradeTarget();
    if (_player->mTradeTarget == 0 || plr == 0)
    {
        TradeStatus = TRADE_STATUS_PLAYER_NOT_FOUND;

        OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
        return;
    }

    // We're too far from target now?
    if (_player->CalcDistance(objmgr.GetPlayer(_player->mTradeTarget)) > 10.0f)
        TradeStatus = TRADE_STATUS_TOO_FAR_AWAY;

    WorldPacket data(SMSG_TRADE_STATUS, 8);

    data << uint32(TradeStatus);
    data << uint32(0x19);

    plr->m_session->SendPacket(&data);

    SendPacket(&data);

    plr->mTradeStatus = TradeStatus;
    _player->mTradeStatus = TradeStatus;
}
Пример #18
0
void WorldSession::HandlePlayerLoginOpcode( WorldPacket & recv_data )
{
	CHECK_PACKET_SIZE(recv_data, 8);
	uint64 playerGuid = 0;

	sLog.outDebug( "WORLD: Recvd Player Logon Message" );

	recv_data >> playerGuid; // this is the GUID selected by the player
	if(objmgr.GetPlayer((uint32)playerGuid) != NULL || m_loggingInPlayer || _player)
	{
		// A character with that name already exists 0x3E
		uint8 respons = CHAR_LOGIN_DUPLICATE_CHARACTER;
		OutPacket(SMSG_CHARACTER_LOGIN_FAILED, 1, &respons);
		return;
	}

	Player* plr = new Player((uint32)playerGuid);
	ASSERT(plr);
	plr->SetSession(this);
	m_bIsWLevelSet = false;
	
	Log.Debug("WorldSession", "Async loading player %u", (uint32)playerGuid);
	m_loggingInPlayer = plr;
	plr->LoadFromDB((uint32)playerGuid);
}
Пример #19
0
void WorldSession::HandleQuestgiverCancelOpcode(WorldPacket & recvPacket)
{
	CHECK_INWORLD_RETURN

	OutPacket(SMSG_GOSSIP_COMPLETE, 0, NULL);

	LOG_DEBUG("WORLD: Sent SMSG_GOSSIP_COMPLETE");
}
Пример #20
0
//////////////////////////////////////////////////////////////
/// This function handles CMSG_QUERY_TIME:
//////////////////////////////////////////////////////////////
void WorldSession::HandleQueryTimeOpcode( WorldPacket & recv_data )
{
	uint32 t = (uint32)UNIXTIME;
#ifdef USING_BIG_ENDIAN
	swap32(&t);
#endif
	OutPacket(SMSG_QUERY_TIME_RESPONSE, 4, &t);
}
Пример #21
0
// Output n'th path element via OutPacket
void ARec::OutPathElement(int n, PartialPath pp)
{
   Word wrd = NULL;
   char *w, *t;
   float ac,lm,score;     // various likelihoods
   float confidence;      // acoustic confidence
   HTime tst,tet;         // start and end times
   PhraseType k;
   NetNode *node;
   Path *p = pp.path;
   int i,frame;
   float prevLike,lmScore;

   // not very efficient but paths never very long
   for (i=pp.n; i>n; i--) {assert(p); p = p->prev;}
   assert(p);

   PathMap::const_iterator it = opMap.find(p);
   if (it != opMap.end()){
      i = opMap[p]; opMap[p] += 1;
      return;
   }
   node = p->owner->node; assert(node);
   t = node->tag; w = NULL;
   if (node->info.pron != NULL) wrd = node->info.pron->word;
   if (wrd != NULL) {w = wrd->wordName->name; k = Word_PT;}
   if (wrd == NULL || (wrd != NULL && strcmp(w,"!NULL")==0)){
      k = Null_PT; w = NULL;
   }
   if (t!=NULL){
      if (strstr(t,"!SUBLAT_(") != NULL){
         k=OpenTag_PT;  t = NULL;
      }else if (strstr(t,"!)_SUBLAT-") != NULL){
         k=CloseTag_PT; t += 10;
      }
   }
   frame = (n==1)?pp.startFrame:p->prev->owner->frame;
   tst = frame * sampPeriod;
   tet = p->owner->frame *sampPeriod;
   prevLike = (n==1)?pp.startLike:float(p->prev->like);
   lmScore = p->lm;  /* SJY 10/12/03  - lm used to be unscaled so this value was scaled
                          here, but now scaling done during recognition */
   // pronScore = (k == Word_PT)?node->info.pron->prob*pp.pronScale:0.0;
   wordPen = float((k==Word_PT)?pp.wordPen:0.0);
   ac = float(p->like - prevLike - lmScore - wordPen);
   lm = lmScore + wordPen;
   score = float(p->like);
   char *none="";
   confidence = GetConfidence(pri,frame+1,p->owner->frame,ac,(w!=NULL)?w:none);

   // printf("CONFB %d. ac=%.1f, prevLike=%.1f, lmScore=%.1f, wordPen=%.1f, lm=%.1f, score=%.1f conf=%.1f\n",
   //   p->owner->frame, ac,prevLike,lmScore,wordPen,lm,score,confidence);

   OutPacket(k, string((w!=NULL)?w:""), string((t!=NULL)?t:""),
	     outseqnum, 0, ac, lm, score, confidence, (float)tact/frameCount,
	     tst+stTime, tet+stTime);
   opMap[p] = 1;
}
Пример #22
0
void WorldSession::HandleUnacceptTrade(WorldPacket & recv_data)
{
	if(!_player->IsInWorld()) return;
	Player * plr = _player->GetTradeTarget();
	//_player->ResetTradeVariables();

	if(_player->mTradeTarget == 0 || plr == 0)
		return;

#ifdef USING_BIG_ENDIAN
	uint32 TradeStatus = swap32(uint32(TRADE_STATUS_UNACCEPTED));
#else
	uint32 TradeStatus = TRADE_STATUS_UNACCEPTED;
#endif

	OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
	plr->m_session->OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);



	TradeStatus = TRADE_STATUS_STATE_CHANGED;

#ifdef USING_BIG_ENDIAN
	swap32(&TradeStatus);
	OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
	plr->m_session->OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
	swap32(&TradeStatus);
#else
	OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
	plr->m_session->OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
#endif

	plr->mTradeStatus = TradeStatus;
	_player->mTradeStatus = TradeStatus;

  //cebernic,why target & self erased? we are not cancelled !
  //this merged from p2wow's svn.
	//plr->mTradeTarget = 0;
	//_player->mTradeTarget = 0;

/*	plr->mTradeTarget = 0;
	_player->mTradeTarget = 0;
	plr->ResetTradeVariables(); */
}
Пример #23
0
void WorldSession::HandleBeginTrade(WorldPacket & recv_data)
{
	if(!_player->IsInWorld()) return;
	uint32 TradeStatus = TRADE_STATUS_INITIATED;

	Player * plr = _player->GetTradeTarget();
	if(_player->mTradeTarget == 0 || plr == 0)
	{
		TradeStatus = TRADE_STATUS_PLAYER_NOT_FOUND;
		OutPacket(TRADE_STATUS_PLAYER_NOT_FOUND, 4, &TradeStatus);
		return;
	}

	OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
	plr->m_session->OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);

	plr->mTradeStatus = TradeStatus;
	_player->mTradeStatus = TradeStatus;
}
Пример #24
0
void WorldSession::SendTaxiList(Creature* pCreature)
{
	uint32 curloc;
	uint8 field;
	uint32 TaxiMask[NUM_TAXI_NODES];
	uint32 submask;
	uint64 guid = pCreature->GetGUID();

	curloc = pCreature->m_TaxiNode;
	if (!curloc)
		return;

	field = (uint8)((curloc - 1) / 32);
	submask = 1<<((curloc-1)%32);

	// Check for known nodes
	if (!(GetPlayer( )->GetTaximask(field) & submask))
	{
		GetPlayer()->SetTaximask(field, (submask | GetPlayer( )->GetTaximask(field)) );

		OutPacket(SMSG_NEW_TAXI_PATH);

		//Send packet
		WorldPacket update(SMSG_TAXINODE_STATUS, 9);
		update << guid << uint8( 1 );
		SendPacket( &update );
	}

	//Set Mask
	for(uint8 i = 0; i < NUM_TAXI_NODES; i++)
	{
		TaxiMask[i] = 0;
	}
	sTaxiMgr.GetGlobalTaxiNodeMask(curloc, TaxiMask);
	TaxiMask[field] |= 1 << ((curloc-1)%32);

	//Remove nodes unknown to player
	for(uint8 i = 0; i < NUM_TAXI_NODES; i++)
	{
		TaxiMask[i] &= GetPlayer( )->GetTaximask(i);
	}

	WorldPacket data(48);
	data.Initialize( SMSG_SHOWTAXINODES );
	data << uint32( 1 ) << guid;
	data << uint32( curloc );
	for(int i = 0; i < NUM_TAXI_NODES; i++)
	{
		data << TaxiMask[i];
	}
	SendPacket( &data );

	DEBUG_LOG( "WORLD: Sent SMSG_SHOWTAXINODES" );
}
Пример #25
0
void WorldSocket::_HandlePing(WorldPacket* recvPacket)
{
    uint32 ping;
    if(recvPacket->size() < 4)
    {
        sLog.outString("Socket closed due to incomplete ping packet.");
        Disconnect();
        return;
    }

    *recvPacket >> ping;
    *recvPacket >> _latency;

    if(mSession)
    {
        mSession->_latency = _latency;
        mSession->m_lastPing = (uint32)UNIXTIME;

        // reset the move time diff calculator, don't worry it will be re-calculated next movement packet.
        mSession->m_clientTimeDelay = 0;
    }

#ifdef USING_BIG_ENDIAN
    swap32(&ping);
#endif

    OutPacket(SMSG_PONG, 4, &ping);

#ifdef WIN32
    // Dynamically change nagle buffering status based on latency.
    //if(_latency >= 250)
    // I think 350 is better, in a MMO 350 latency isn't that big that we need to worry about reducing the number of packets being sent.
    if(_latency >= 350)
    {
        if(!m_nagleEanbled)
        {
            u_long arg = 0;
            setsockopt(GetFd(), 0x6, 0x1, (const char*)&arg, sizeof(arg));
            m_nagleEanbled = true;
        }
    }
    else
    {
        if(m_nagleEanbled)
        {
            u_long arg = 1;
            setsockopt(GetFd(), 0x6, 0x1, (const char*)&arg, sizeof(arg));
            m_nagleEanbled = false;
        }
    }
#endif
}
Пример #26
0
void WorldSession::HandleUnacceptTrade(WorldPacket & recv_data)
{
	if(!_player->IsInWorld()) 
	{ 
		return;
	}
	Player * plr = _player->GetTradeTarget();
	//_player->ResetTradeVariables();

	if(_player->mTradeTarget == 0 || plr == 0)
	{ 
		return;
	}

	packetSMSG_TRADE_STATUS data;
	memset( &data, 0, sizeof( data ) );
	data.trade_status = TRADE_STATUS_UNACCEPTED;

	//send to ourself
	OutPacket(SMSG_TRADE_STATUS,sizeof( packetSMSG_TRADE_STATUS ), &data);
	plr->m_session->OutPacket(SMSG_TRADE_STATUS,sizeof( packetSMSG_TRADE_STATUS ), &data);

	data.trade_status = TRADE_STATUS_STATE_CHANGED;

	OutPacket(SMSG_TRADE_STATUS,sizeof( packetSMSG_TRADE_STATUS ), &data);
	plr->m_session->OutPacket(SMSG_TRADE_STATUS,sizeof( packetSMSG_TRADE_STATUS ), &data);

	plr->mTradeStatus = data.trade_status;
	_player->mTradeStatus = data.trade_status;

  //cebernic,why target & self erased? we are not cancelled !
  //this merged from p2wow's svn.
	//plr->mTradeTarget = 0;
	//_player->mTradeTarget = 0;

/*	plr->mTradeTarget = 0;
	_player->mTradeTarget = 0;
	plr->ResetTradeVariables(); */
}
Пример #27
0
// Flush  a single observation
Boolean ARec::FlushObservation()
{
   APacket pkt;
   AStringData *sd;
   AObsData *od;
   PacketKind kind;
   Boolean flushing = TRUE;

   stTime = -1.0;  // ensure -ve before switching to runstate
   if (runmode&RUN_IMMED) // no flushing
      return TRUE;

   while (in->NumPackets()>0){
      pkt = in->PeekPacket(); kind = pkt.GetKind();

      if (kind==StringPacket) {
         in->PopPacket(); StoreMarker(pkt);
         sd = (AStringData *)pkt.GetData();
         if (sd->data.find("TERMINATED")!=string::npos) terminated=TRUE;
         if (runmode&FLUSH_TOMARK) {
            // if start or endoflist marker found, flushing complete
            string::size_type posn = sd->data.find("ENDOFLIST");
            if (posn != string::npos ) {
               OutPacket(Start_PT, "","ENDOFLIST",0,0,0.0,0.0,0.0,-1,0.0,0.0,0.0);
               terminated = TRUE;
               return TRUE;
            }
            posn = sd->data.find("START");
            if (posn != string::npos) {
               string::size_type pos1 = sd->data.find("(");
               string::size_type pos2 = sd->data.find(")");
               if (pos1<1 || pos2<pos1) return TRUE;
               fname = string(sd->data,pos1+1,pos2-pos1-1);
               return TRUE;
            }
         }
         OutMarkers(GetTimeNow());
      } else
         if (kind==ObservationPacket){
            // if speech flagged observation, flushing complete
            if (runmode&FLUSH_TOSPEECH) {
               od = (AObsData *)pkt.GetData();
               if (od->data.vq[0]) return TRUE;
            }
            in->PopPacket();
         } else {
            in->PopPacket();	// ignore non-string or -obs packets
         }
   }
   return FALSE;
}
Пример #28
0
void WorldSocket::_HandlePing(WorldPacket* recvPacket)
{
	uint32 ping;
	if(recvPacket->size() < 4)
	{
		sLog.outString("Socket closed due to incomplete ping packet.");
		Disconnect();
		return;
	}

	*recvPacket >> ping;
	*recvPacket >> _latency;
	OutPacket(SMSG_PONG, 4, &ping);
}
Пример #29
0
void WorldSession::HandleBeginTrade(WorldPacket & recv_data)
{
	if(!_player->IsInWorld()) return;
	uint32 TradeStatus = TRADE_STATUS_INITIATED;

	Player * plr = _player->GetTradeTarget();
	if(_player->mTradeTarget == 0 || plr == 0)
	{
#ifdef USING_BIG_ENDIAN
		TradeStatus = swap32(uint32(TRADE_STATUS_PLAYER_NOT_FOUND));
#else
		TradeStatus = TRADE_STATUS_PLAYER_NOT_FOUND;
#endif
		OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
		return;
	}
	// We're too far from target now?
	if( _player->CalcDistance( objmgr.GetPlayer(_player->mTradeTarget) ) > 10.0f )
	TradeStatus = TRADE_STATUS_TOO_FAR_AWAY;

#ifdef USING_BIG_ENDIAN
	swap32(&TradeStatus);
	OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
	plr->m_session->OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
	swap32(&TradeStatus);
#else
/*	OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
	plr->m_session->OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);*/
	WorldPacket data(SMSG_TRADE_STATUS, 8);
	data << TradeStatus << uint32(0x19);
	plr->m_session->SendPacket(&data);
	SendPacket(&data);
#endif

	plr->mTradeStatus = TradeStatus;
	_player->mTradeStatus = TradeStatus;
}
Пример #30
0
void WorldSession::HandleInitiateTrade(WorldPacket & recv_data)
{
	if(!_player->IsInWorld()) return;
	CHECK_PACKET_SIZE(recv_data, 8);
	uint64 guid;
	recv_data >> guid;
	Player * pTarget = _player->GetMapMgr()->GetPlayer((uint32)guid);
	uint32 TradeStatus = TRADE_STATUS_PROPOSED;
	WorldPacket data(SMSG_TRADE_STATUS, 12);

	if(pTarget == 0)
	{
#ifdef USING_BIG_ENDIAN
		TradeStatus = swap32(uint32(TRADE_STATUS_PLAYER_NOT_FOUND));
#else
		TradeStatus = TRADE_STATUS_PLAYER_NOT_FOUND;
#endif
		OutPacket(SMSG_TRADE_STATUS, 4, &TradeStatus);
		return;
	}

	// Handle possible error outcomes
	if(pTarget->CalcDistance(_player) > 10.0f)		// This needs to be checked
		TradeStatus = TRADE_STATUS_TOO_FAR_AWAY;
	else if(pTarget->isDead())
		TradeStatus = TRADE_STATUS_DEAD;
	else if(pTarget->mTradeTarget != 0)
		TradeStatus = TRADE_STATUS_ALREADY_TRADING;
	else if(pTarget->GetTeam() != _player->GetTeam() && GetPermissionCount() == 0 && !sWorld.interfaction_trade)
		TradeStatus = TRADE_STATUS_WRONG_FACTION;

	data << TradeStatus;

	if(TradeStatus == TRADE_STATUS_PROPOSED)
	{
		_player->ResetTradeVariables();
		pTarget->ResetTradeVariables();

		pTarget->mTradeTarget = _player->GetLowGUID();
		_player->mTradeTarget = pTarget->GetLowGUID();

		pTarget->mTradeStatus = TradeStatus;
		_player->mTradeStatus = TradeStatus;

		data << _player->GetGUID();
	}

	pTarget->m_session->SendPacket(&data);
}