本文整理汇总了C++中raknet::BitStream::WriteCompressed方法的典型用法代码示例。如果您正苦于以下问题:C++ BitStream::WriteCompressed方法的具体用法?C++ BitStream::WriteCompressed怎么用?C++ BitStream::WriteCompressed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类raknet::BitStream
的用法示例。
在下文中一共展示了BitStream::WriteCompressed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: send_input
void Network::send_input(){
if(status=="client"){
if(game.in_progress){
if(commands_this_second<rate_commands && ++counter_commands>=(uint32_t)ceil(UPDATE_RATE/(double)rate_commands)){
counter_commands=0;
commands_this_second++;
RakNet::BitStream bitstream;
bitstream.Write((RakNet::MessageID)ID_GAME_INPUT);
bitstream.WriteCompressed((int)command_buffer.size());
for(int i=0;i<command_buffer.size();i++){
bitstream.WriteCompressed((RakNet::RakString)command_buffer[i].c_str());
}
command_buffer.clear();
bitstream.WriteCompressed((int)game.command_states.size());
for(int i=0;i<game.command_states.size();i++){
bitstream.WriteCompressed((RakNet::RakString)game.command_states[i].c_str());
}
stat_counter_bytes_sent+=bitstream.GetNumberOfBytesUsed();
peer->Send(&bitstream,HIGH_PRIORITY,RELIABLE_ORDERED,ORDERING_CHANNEL_INPUT,server_id,false);
}
}
}
}
示例2: PushReference
void FileListTransfer::PushReference(SystemAddress systemAddress)
{
// Was previously using GetStatistics to get outgoing buffer size, but TCP with UnifiedSend doesn't have this
unsigned int i=0;
unsigned int bytesRead;
char *dataBlocks[2];
int lengths[2];
RakNet::BitStream outBitstream;
while (i < filesToPush.Size())
{
if (filesToPush[i].systemAddress==systemAddress)
{
outBitstream.Reset();
outBitstream.Write((MessageID)ID_FILE_LIST_REFERENCE_PUSH);
outBitstream.Write(filesToPush[i].fileListNode.context);
outBitstream.Write(filesToPush[i].setID);
stringCompressor->EncodeString(filesToPush[i].fileListNode.filename, 512, &outBitstream);
outBitstream.WriteCompressed(filesToPush[i].setIndex);
outBitstream.WriteCompressed(filesToPush[i].fileListNode.dataLengthBytes); // Original length in bytes
// Read and send chunk. If done, delete at this index
void *buff = rakMalloc_Ex(filesToPush[i].chunkSize, __FILE__, __LINE__);
if (buff==0)
{
notifyOutOfMemory(__FILE__, __LINE__);
continue;
}
bytesRead=filesToPush[i].incrementalReadInterface->GetFilePart(filesToPush[i].fileListNode.fullPathToFile, filesToPush[i].currentOffset, filesToPush[i].chunkSize, buff, filesToPush[i].fileListNode.context);
outBitstream.WriteCompressed(filesToPush[i].currentOffset);
filesToPush[i].currentOffset+=bytesRead;
outBitstream.WriteCompressed(bytesRead);
bool done = bytesRead!=filesToPush[i].chunkSize;
outBitstream.Write(done);
if (callback)
{
callback->OnFilePush(filesToPush[i].fileListNode.filename, filesToPush[i].fileListNode.fileLengthBytes, filesToPush[i].currentOffset-bytesRead, bytesRead, done, filesToPush[i].systemAddress);
}
dataBlocks[0]=(char*) outBitstream.GetData();
lengths[0]=outBitstream.GetNumberOfBytesUsed();
dataBlocks[1]=(char*) buff;
lengths[1]=bytesRead;
//rakPeerInterface->SendList(dataBlocks,lengths,2,filesToPush[i].packetPriority, RELIABLE_ORDERED, filesToPush[i].orderingChannel, filesToPush[i].systemAddress, false);
SendListUnified(dataBlocks,lengths,2,filesToPush[i].packetPriority, RELIABLE_ORDERED, filesToPush[i].orderingChannel, filesToPush[i].systemAddress, false);
if (done)
{
// Done
RakNet::OP_DELETE_ARRAY(filesToPush[i].fileListNode.filename, __FILE__, __LINE__);
filesToPush.RemoveAtIndex(i);
}
rakFree_Ex(buff, __FILE__, __LINE__ );
return;
}
else
i++;
}
}
示例3: SetRespawnTime
void CPickupSendPackets::SetRespawnTime( unsigned char uc )
{
RakNet::BitStream bs;
PreparePacket(ID_PICKUP_SETRESPAWNTIME, bs);
bs.WriteCompressed( uc );
CNet::GetInterface()->Send(&bs, HIGH_PRIORITY, RELIABLE, 0);
}
示例4: send_client_data
void Network::send_client_data(bool first_send){
if(status=="client"){
char ordering_channel=ORDERING_CHANNEL_CLIENT_DATA;
if(first_send){
ordering_channel=ORDERING_CHANNEL_CONNECTION;
}
RakNet::BitStream bitstream;
bitstream.Write((RakNet::MessageID)ID_GAME_CLIENT_DATA);
bitstream.WriteCompressed(first_send);
bitstream.WriteCompressed((RakNet::RakString)game.option_name.c_str());
bitstream.WriteCompressed(rate_bytes);
bitstream.WriteCompressed(rate_updates);
stat_counter_bytes_sent+=bitstream.GetNumberOfBytesUsed();
peer->Send(&bitstream,MEDIUM_PRIORITY,RELIABLE_ORDERED,ordering_channel,server_id,false);
}
}
示例5: OnDeath
void CLocalPlayer::OnDeath( CNetworkPlayer * pKiller )
{
// Are we not marked as dead?
if( !IsDead() )
{
// Get the old camera lock state
bOldCameraState = pCore->GetCamera()->IsLocked ();
// Get the old control state
bOldCTRLState = AreControlsLocked ();
// Mark as dead
SetDead( true );
// Set the death time
m_ulDeathTime = SharedUtility::GetTime();
// Mark as not spawned
SetSpawned( false );
// Mark as not aiming
SetAiming( false );
// Mark as not shooting
SetShooting( false );
// Set the death time
SetDeathTime( SharedUtility::GetTime() );
// Remove all the weapons
m_pPlayerPed->RemoveAllWeapons ();
// Construct a new bitstream
RakNet::BitStream pBitStream;
// Write the killerid
pBitStream.WriteCompressed( (pKiller ? pKiller->GetId() : INVALID_ENTITY_ID) );
// Send RPC to server
pCore->GetNetworkModule()->Call( RPC_PLAYER_DEATH, &pBitStream, HIGH_PRIORITY, RELIABLE, true );
// Fade out the screen
pCore->GetHud()->FadeOut ( 3000 );
// Fade out the sound
pCore->GetGame()->FadeSound ( true, 3 );
// Lock the camera control
pCore->GetCamera()->LockControl ( true );
// Lock the player controls
LockControls ( true );
}
}
示例6: SetPickupRespawnTime
void CPickupSendPackets::SetPickupRespawnTime( unsigned int ui, unsigned char uc )
{
CPickupPool* pPickup = CPickupPoolManager::Find( ui );
if ( pPickup )
{
RakNet::BitStream bs;
PreparePacket(ID_PICKUP_SETPICKUPRESPAWNTIME, bs);
bs.Write( ui );
bs.WriteCompressed( uc );
CNet::GetInterface()->Send(&bs, HIGH_PRIORITY, RELIABLE, 0);
}
}
示例7:
void RPC4::Call( const char* uniqueID, RakNet::BitStream * bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast )
{
RakNet::BitStream out;
out.Write((MessageID) ID_RPC_PLUGIN);
out.Write((MessageID) ID_RPC4_CALL);
out.WriteCompressed(uniqueID);
out.Write(false); // Nonblocking
if (bitStream)
{
bitStream->ResetReadPointer();
out.AlignWriteToByteBoundary();
out.Write(bitStream);
}
SendUnified(&out,priority,reliability,orderingChannel,systemIdentifier,broadcast);
}
示例8: main
int main(void)
{
printf("Demonstration of the RPC4 plugin.\n");
printf("Difficulty: Beginner\n\n");
rakPeer1=RakNet::RakPeerInterface::GetInstance();
rakPeer2=RakNet::RakPeerInterface::GetInstance();
RakNet::SocketDescriptor sd1(1234,0);
RakNet::SocketDescriptor sd2(1235,0);
rakPeer1->Startup(8,&sd1,1);
rakPeer2->Startup(8,&sd2,1);
rakPeer1->SetMaximumIncomingConnections(8);
rakPeer2->Connect("127.0.0.1", sd1.port, 0, 0);
RakSleep(100);
RPC4 rpc1, rpc2;
rakPeer1->AttachPlugin(&rpc1);
rakPeer2->AttachPlugin(&rpc2);
rpc1.RegisterSlot("Event1", CFunc1, 0);
rpc2.RegisterSlot("Event1", CFunc1, 0);
rpc1.RegisterSlot("Event1", CFunc2, 0);
rpc2.RegisterSlot("Event1", CFunc2, 0);
RakNet::BitStream testBs;
testBs.WriteCompressed("testData");
rpc1.Signal("Event1", &testBs, HIGH_PRIORITY,RELIABLE_ORDERED,0,rakPeer2->GetSystemAddressFromIndex(0),false, true);
RakNet::Packet *packet;
packet = rakPeer1->Receive();
RakAssert(packet->data[0]==ID_NEW_INCOMING_CONNECTION);
rakPeer1->DeallocatePacket(packet);
packet = rakPeer2->Receive();
RakAssert(packet->data[0]==ID_CONNECTION_REQUEST_ACCEPTED);
rakPeer2->DeallocatePacket(packet);
RakSleep(100);
for (packet=rakPeer1->Receive(); packet; rakPeer1->DeallocatePacket(packet), rakPeer1->Receive())
;
for (packet=rakPeer2->Receive(); packet; rakPeer2->DeallocatePacket(packet), rakPeer2->Receive())
;
rakPeer1->Shutdown(100,0);
rakPeer2->Shutdown(100,0);
RakNet::RakPeerInterface::DestroyInstance(rakPeer1);
RakNet::RakPeerInterface::DestroyInstance(rakPeer2);
return 1;
}
示例9: PlayerChat
void PlayerChat(RakNet::BitStream * pBitStream, RakNet::Packet * pPacket)
{
// Get the playerid
EntityId playerId = (EntityId) pPacket->guid.systemIndex;
// Read if this is a command
bool bIsCommand = pBitStream->ReadBit();
// Read the input
RakNet::RakString strInput;
pBitStream->Read(strInput);
// Is the player active?
if (CServer::GetInstance()->GetPlayerManager()->DoesExists(playerId))
{
// Get a pointer to the player
CPlayerEntity * pPlayer = CServer::GetInstance()->GetPlayerManager()->GetAt(playerId);
// Is the pointer valid?
if (pPlayer)
{
// Is this not a command?
if (!bIsCommand)
{
CLogFile::Printf("[chat] %s: %s", pPlayer->GetName().Get(), strInput.C_String());
// Send the RPC back to other players
RakNet::BitStream bitStream;
bitStream.WriteCompressed(playerId);
bitStream.Write(strInput);
CServer::GetInstance()->GetNetworkModule()->Call(GET_RPC_CODEX(RPC_PLAYER_CHAT), &bitStream, HIGH_PRIORITY, RELIABLE_ORDERED, playerId, true);
}
else
{
CLogFile::Printf("[command] %s: %s", pPlayer->GetName().Get(), strInput.C_String());
CScriptArguments args;
args.push(strInput);
args.push(pPlayer->GetScriptPlayer());
CEvents::GetInstance()->Call("onCommand", &args, CEventHandler::eEventType::GLOBAL_EVENT, nullptr);
}
}
}
}
示例10: RespawnPickupForPlayer
void CPickupSendPackets::RespawnPickupForPlayer( unsigned char uc, unsigned int ui )
{
CPlayerPool* pPlayer = CPlayerPoolManager::Find( ui );
if ( pPlayer )
{
CPickupPool* pPickup = CPickupPoolManager::Find( ui );
if ( pPickup )
{
RakNet::BitStream bs;
PreparePacket(ID_PICKUP_RESPAWNPICKUPFORPLAYER, bs);
bs.WriteCompressed( uc );
bs.Write( ui );
CNet::GetInterface()->Send(&bs, HIGH_PRIORITY, RELIABLE, 0);
}
}
}
示例11: InitGameForPlayer
void InitGameForPlayer(PLAYERID playerID)
{
RakNet::BitStream bsInitGame;
bsInitGame.WriteCompressed((bool)1); // m_bZoneNames
bsInitGame.WriteCompressed((bool)1); // m_bUseCJWalk
bsInitGame.WriteCompressed((bool)1); // m_bAllowWeapons
bsInitGame.WriteCompressed((bool)0); // m_bLimitGlobalChatRadius
bsInitGame.Write((float)200.00f); // m_fGlobalChatRadius
bsInitGame.WriteCompressed((bool)0); // bStuntBonus
bsInitGame.Write((float)70.0f); // m_fNameTagDrawDistance
bsInitGame.WriteCompressed((bool)0); // m_bDisableEnterExits
bsInitGame.WriteCompressed((bool)1); // m_bNameTagLOS
bsInitGame.WriteCompressed((bool)1); // m_bTirePopping
bsInitGame.Write((int)1); // m_iSpawnsAvailable
bsInitGame.Write(playerID); // MyPlayerID
bsInitGame.WriteCompressed((bool)1); // m_bShowPlayerTags
bsInitGame.Write((int)1); // m_iShowPlayerMarkers
bsInitGame.Write((BYTE)12); // m_byteWorldTime
bsInitGame.Write((BYTE)10); // m_byteWeather
bsInitGame.Write((float)0.008); // m_fGravity
bsInitGame.WriteCompressed((bool)0); // bLanMode
bsInitGame.Write((int)0); // m_iDeathDropMoney
bsInitGame.WriteCompressed((bool)0); // m_bInstagib
bsInitGame.Write((int)40); // iNetModeNormalOnfootSendRate
bsInitGame.Write((int)40); // iNetModeNormalIncarSendRate
bsInitGame.Write((int)40); // iNetModeFiringSendRate
bsInitGame.Write((int)10); // iNetModeSendMultiplier
BYTE bServerNameLen = (BYTE)strlen(serverName);
bsInitGame.Write(bServerNameLen);
bsInitGame.Write(serverName, bServerNameLen);
BYTE vehModels[212];
memset(vehModels, 1, 212);
bsInitGame.Write((char *)&vehModels, 212);
pRakServer->RPC(&RPC_InitGame, &bsInitGame, HIGH_PRIORITY, RELIABLE,
0, pRakServer->GetPlayerIDFromIndex(playerID), FALSE, FALSE, UNASSIGNED_NETWORK_ID, NULL);
}
示例12:
void RPC4::Signal(const char *sharedIdentifier, RakNet::BitStream *bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast, bool invokeLocal)
{
RakNet::BitStream out;
out.Write((MessageID) ID_RPC_PLUGIN);
out.Write((MessageID) ID_RPC4_SIGNAL);
out.WriteCompressed(sharedIdentifier);
if (bitStream)
{
bitStream->ResetReadPointer();
out.AlignWriteToByteBoundary();
out.Write(bitStream);
}
SendUnified(&out,priority,reliability,orderingChannel,systemIdentifier,broadcast);
if (invokeLocal)
{
DataStructures::HashIndex functionIndex;
functionIndex = localSlots.GetIndexOf(sharedIdentifier);
if (functionIndex.IsInvalid())
return;
Packet p;
p.guid=rakPeerInterface->GetMyGUID();
p.systemAddress=rakPeerInterface->GetMyBoundAddress(0);
p.wasGeneratedLocally=true;
RakNet::BitStream *bsptr, bstemp;
if (bitStream)
{
bitStream->ResetReadPointer();
p.length=bitStream->GetNumberOfBytesUsed();
p.bitSize=bitStream->GetNumberOfBitsUsed();
bsptr=bitStream;
}
else
{
p.length=0;
p.bitSize=0;
bsptr=&bstemp;
}
InvokeSignal(functionIndex, bsptr, &p);
}
}
示例13: OnEnterVehicle
void CLocalPlayer::OnEnterVehicle( void )
{
// Get the vehicle instance from the vehicle guid
CNetworkVehicle * pNetworkVehicle = pCore->GetVehicleManager()->GetFromGameGUID( GetPlayerPed()->GetCurrentVehicle()->m_dwGUID );
// Is the vehicle instance valid?
if( pNetworkVehicle )
{
#ifdef _DEBUG
M2Vehicle * pVehicle = pNetworkVehicle->GetVehicle()->GetVehicle();
DWORD dwVehicleData = (DWORD)(pVehicle) + 0xA8;
pCore->GetChat()->AddDebugMessage ( "Vehicle: 0x%p, VehicleData: 0x%p", pVehicle, dwVehicleData );
#endif
// Set the initial seat as the driver
EntityId seat = 0;
// Is the player in the passenger seat?
//if( GetState() == PLAYERSTATE_PASSENGER )
// seat = pNetworkVehicle->GetVehicle()->GetPedOccupiedSeat( GetPlayerPed()->GetPed() );
// Does the vehicle already have a driver?
if ( pNetworkVehicle->GetDriver () )
seat = pNetworkVehicle->GetVehicle()->GetPedOccupiedSeat( GetPlayerPed()->GetPed() );
// Are we getting in as the driver?
if( seat == 0 )
SetState( PLAYERSTATE_DRIVER );
else
SetState( PLAYERSTATE_PASSENGER );
#ifdef _DEBUG
pCore->GetChat()->AddDebugMessage( "Seat: %d, Driver: 0x%p, State: %d", seat, pNetworkVehicle->GetDriver (), GetState () );
#endif
// Construct a new bitstream
RakNet::BitStream pBitStream;
// Write the vehicle id
pBitStream.WriteCompressed( pNetworkVehicle->GetId() );
// Write the seat
pBitStream.WriteCompressed( seat );
// Send to the server
pCore->GetNetworkModule()->Call( RPC_ENTER_VEHICLE, &pBitStream, HIGH_PRIORITY, RELIABLE_ORDERED, true );
#ifdef _DEBUG
pCore->GetChat()->AddDebugMessage( "CLocalPlayer::OnEnterVehicle( %d, %d )", pNetworkVehicle->GetId(), seat );
#endif
// Handle this enter with the network vehicle
pNetworkVehicle->HandlePlayerEnter( this, seat );
// Set the vehicle
SetVehicle( pNetworkVehicle );
// Set the seat
SetSeat( seat );
// Set the target data
SetEnteringVehicle( pNetworkVehicle, seat );
}
}
示例14: SendIRIToAddressCB
int SendIRIToAddressCB(FileListTransfer::ThreadData threadData, bool *returnOutput, void* perThreadData)
{
(void) perThreadData;
FileListTransfer *fileListTransfer = threadData.fileListTransfer;
SystemAddress systemAddress = threadData.systemAddress;
*returnOutput=false;
// Was previously using GetStatistics to get outgoing buffer size, but TCP with UnifiedSend doesn't have this
unsigned int bytesRead;
const char *dataBlocks[2];
int lengths[2];
unsigned int smallFileTotalSize=0;
RakNet::BitStream outBitstream;
unsigned int ftpIndex;
fileListTransfer->fileToPushRecipientListMutex.Lock();
for (ftpIndex=0; ftpIndex < fileListTransfer->fileToPushRecipientList.Size(); ftpIndex++)
{
FileListTransfer::FileToPushRecipient *ftpr = fileListTransfer->fileToPushRecipientList[ftpIndex];
// Referenced by both ftpr and list
ftpr->AddRef();
fileListTransfer->fileToPushRecipientListMutex.Unlock();
if (ftpr->systemAddress==systemAddress)
{
FileListTransfer::FileToPush *ftp = ftpr->filesToPush.Peek();
// Read and send chunk. If done, delete at this index
void *buff = rakMalloc_Ex(ftp->chunkSize, _FILE_AND_LINE_);
if (buff==0)
{
ftpr->Deref();
notifyOutOfMemory(_FILE_AND_LINE_);
return 0;
}
// Read the next file chunk
bytesRead=ftp->incrementalReadInterface->GetFilePart(ftp->fileListNode.fullPathToFile, ftp->currentOffset, ftp->chunkSize, buff, ftp->fileListNode.context);
bool done = ftp->fileListNode.dataLengthBytes == ftp->currentOffset+bytesRead;
while (done && ftp->currentOffset==0 && ftpr->filesToPush.Size()>=2 && smallFileTotalSize<ftp->chunkSize)
{
// Send all small files at once, rather than wait for ID_FILE_LIST_REFERENCE_PUSH. But at least one ID_FILE_LIST_REFERENCE_PUSH must be sent
outBitstream.Reset();
outBitstream.Write((MessageID)ID_FILE_LIST_TRANSFER_FILE);
// outBitstream.Write(ftp->fileListNode.context);
outBitstream << ftp->fileListNode.context;
outBitstream.Write(ftp->setID);
StringCompressor::Instance()->EncodeString(ftp->fileListNode.filename, 512, &outBitstream);
outBitstream.WriteCompressed(ftp->setIndex);
outBitstream.WriteCompressed(ftp->fileListNode.dataLengthBytes); // Original length in bytes
outBitstream.AlignWriteToByteBoundary();
dataBlocks[0]=(char*) outBitstream.GetData();
lengths[0]=outBitstream.GetNumberOfBytesUsed();
dataBlocks[1]=(const char*) buff;
lengths[1]=bytesRead;
fileListTransfer->SendListUnified(dataBlocks,lengths,2,ftp->packetPriority, RELIABLE_ORDERED, ftp->orderingChannel, systemAddress, false);
// LWS : fixed freed pointer reference
// unsigned int chunkSize = ftp->chunkSize;
RakNet::OP_DELETE(ftp,_FILE_AND_LINE_);
ftpr->filesToPush.Pop();
smallFileTotalSize+=bytesRead;
//done = bytesRead!=ftp->chunkSize;
ftp = ftpr->filesToPush.Peek();
bytesRead=ftp->incrementalReadInterface->GetFilePart(ftp->fileListNode.fullPathToFile, ftp->currentOffset, ftp->chunkSize, buff, ftp->fileListNode.context);
done = ftp->fileListNode.dataLengthBytes == ftp->currentOffset+bytesRead;
}
outBitstream.Reset();
outBitstream.Write((MessageID)ID_FILE_LIST_REFERENCE_PUSH);
// outBitstream.Write(ftp->fileListNode.context);
outBitstream << ftp->fileListNode.context;
outBitstream.Write(ftp->setID);
StringCompressor::Instance()->EncodeString(ftp->fileListNode.filename, 512, &outBitstream);
outBitstream.WriteCompressed(ftp->setIndex);
outBitstream.WriteCompressed(ftp->fileListNode.dataLengthBytes); // Original length in bytes
outBitstream.WriteCompressed(ftp->currentOffset);
ftp->currentOffset+=bytesRead;
outBitstream.WriteCompressed(bytesRead);
outBitstream.Write(done);
for (unsigned int flpcIndex=0; flpcIndex < fileListTransfer->fileListProgressCallbacks.Size(); flpcIndex++)
fileListTransfer->fileListProgressCallbacks[flpcIndex]->OnFilePush(ftp->fileListNode.filename, ftp->fileListNode.fileLengthBytes, ftp->currentOffset-bytesRead, bytesRead, done, systemAddress, ftp->setID);
dataBlocks[0]=(char*) outBitstream.GetData();
lengths[0]=outBitstream.GetNumberOfBytesUsed();
dataBlocks[1]=(char*) buff;
lengths[1]=bytesRead;
//rakPeerInterface->SendList(dataBlocks,lengths,2,ftp->packetPriority, RELIABLE_ORDERED, ftp->orderingChannel, ftp->systemAddress, false);
fileListTransfer->SendListUnified(dataBlocks,lengths,2,ftp->packetPriority, RELIABLE_ORDERED, ftp->orderingChannel, systemAddress, false);
// Mutex state: FileToPushRecipient (ftpr) has AddRef. fileToPushRecipientListMutex not locked.
if (done)
{
//.........这里部分代码省略.........
示例15: OnLeaveVehicle
void CLocalPlayer::OnLeaveVehicle( void )
{
// Set the player state
SetState( PLAYERSTATE_ONFOOT );
// Is the vehicle instance valid?
if( m_pVehicle )
{
// Get the seat of this player
EntityId seat = m_seat;
// Construct a new bitstream
RakNet::BitStream pBitStream;
// Write the vehicle id
pBitStream.WriteCompressed( m_pVehicle->GetId() );
// Write the seat
pBitStream.WriteCompressed( seat );
// Write if we're exiting quickly!
m_bFastExitVehicle ? pBitStream.Write1() : pBitStream.Write0();
// Send to the server
pCore->GetNetworkModule()->Call( RPC_EXIT_VEHICLE, &pBitStream, HIGH_PRIORITY, RELIABLE_ORDERED, true );
#ifdef DEBUG
pCore->GetChat()->AddDebugMessage( "CLocalPlayer::OnExitVehicle( %d, %d ) - Forcefully: %s", m_pVehicle->GetId(), seat, (IsBeingRemovedForcefully () ? "Yes" : "No") );
#endif
// Are we not being removed forcefully?
if ( !IsBeingRemovedForcefully () )
{
// Handle this enter with the network vehicle
m_pVehicle->HandlePlayerExit( this, seat, false );
// Do we need to respawn this vehicle? (Set to true when vehicle enters water)
if( bRespawnVehicle && m_seat == 0 )
{
// Respawn the vehicle
m_pVehicle->Respawn();
//
bRespawnVehicle = false;
}
// Are we a passenger?
if( m_seat > 0 )
{
// Restore the player controls
LockControls( bOldControlState );
// Restore the camera lock state
pCore->GetCamera()->LockControl( bOldCameraState );
//
*(DWORD *)(m_pPlayerPed->GetPed() + 0x310) = 6;
}
}
// Reset the vehicle
SetVehicle( NULL );
// Reset the seat
SetSeat( INVALID_ENTITY_ID );
// Reset the target data
SetEnteringVehicle( NULL, INVALID_ENTITY_ID );
// Reset the fast vehicle exit flag
FlagForFastExitVehicle ( false );
// Reset the forceful exit flag
SetRemoveForcefully ( false );
}
}