Skip to content

Commit

Permalink
Merge branch 'master' into 030624_NewFunction-isPlayerSpawned
Browse files Browse the repository at this point in the history
  • Loading branch information
TracerDS committed Jun 18, 2024
2 parents 008dde2 + f5b599c commit 379ba7d
Show file tree
Hide file tree
Showing 14 changed files with 221 additions and 95 deletions.
5 changes: 3 additions & 2 deletions Client/cefweb/CWebView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -996,8 +996,9 @@ bool CWebView::OnJSDialog(CefRefPtr<CefBrowser> browser, const CefString& origin
// //
// //
////////////////////////////////////////////////////////////////////
bool CWebView::OnFileDialog(CefRefPtr<CefBrowser> browser, CefDialogHandler::FileDialogMode mode, const CefString& title, const CefString& default_file_path,
const std::vector<CefString>& accept_filters, CefRefPtr<CefFileDialogCallback> callback)
bool CWebView::OnFileDialog(CefRefPtr<CefBrowser> browser, FileDialogMode mode, const CefString& title, const CefString& default_file_path,
const std::vector<CefString>& accept_filters, const std::vector<CefString>& accept_extensions, const std::vector<CefString>& accept_descriptions,
CefRefPtr<CefFileDialogCallback> callback)
{
// Don't show the dialog
return true;
Expand Down
5 changes: 3 additions & 2 deletions Client/cefweb/CWebView.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@ class CWebView : public CWebViewInterface,
bool& suppress_message) override;

// CefDialogHandler methods
virtual bool OnFileDialog(CefRefPtr<CefBrowser> browser, CefDialogHandler::FileDialogMode mode, const CefString& title, const CefString& default_file_path,
const std::vector<CefString>& accept_filters, CefRefPtr<CefFileDialogCallback> callback) override;
virtual bool OnFileDialog(CefRefPtr<CefBrowser> browser, FileDialogMode mode, const CefString& title, const CefString& default_file_path,
const std::vector<CefString>& accept_filters, const std::vector<CefString>& accept_extensions, const std::vector<CefString>& accept_descriptions,
CefRefPtr<CefFileDialogCallback> callback) override;

// CefDisplayHandler methods
virtual void OnTitleChange(CefRefPtr<CefBrowser> browser, const CefString& title) override;
Expand Down
21 changes: 11 additions & 10 deletions Client/mods/deathmatch/logic/CClientPed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3271,7 +3271,7 @@ void CClientPed::SetTargetRotation(unsigned long ulDelay, float fRotation, float
{
m_ulBeginRotationTime = CClientTime::GetTime();
m_ulEndRotationTime = m_ulBeginRotationTime + ulDelay;
m_fBeginRotation = (m_pPlayerPed) ? m_pPlayerPed->GetTargetRotation() : m_fCurrentRotation;
m_fBeginRotation = (m_pPlayerPed) ? m_pPlayerPed->GetCurrentRotation() : m_fCurrentRotation;
m_fTargetRotationA = fRotation;
m_fBeginCameraRotation = GetCameraRotation();
m_fTargetCameraRotation = fCameraRotation;
Expand Down Expand Up @@ -3329,23 +3329,24 @@ void CClientPed::Interpolate()
{
// We're not at the end?
if (ulCurrentTime < m_ulEndRotationTime)
{
// Interpolate the player rotation
float fDeltaTime = float(m_ulEndRotationTime - m_ulBeginRotationTime);
float fDelta = GetOffsetDegrees(m_fBeginRotation, m_fTargetRotationA);
float fCameraDelta = GetOffsetDegrees(m_fBeginCameraRotation, m_fTargetCameraRotation);
float fProgress = float(ulCurrentTime - m_ulBeginRotationTime);
float fNewRotation = m_fBeginRotation + (fDelta / fDeltaTime * fProgress);
float fNewCameraRotation = m_fBeginCameraRotation + (fCameraDelta / fDeltaTime * fProgress);
{
const float fDelta = GetOffsetRadians(m_fBeginRotation, m_fTargetRotationA);

// Hack for the wrap-around (the edge seems to be varying...)
if (fDelta < -5.0f || fDelta > 5.0f)
if (fDelta < -M_PI || fDelta > M_PI)
{
SetCurrentRotation(m_fTargetRotationA);
SetCameraRotation(m_fTargetCameraRotation);
}
else
{
// Interpolate the player rotation
const float fDeltaTime = float(m_ulEndRotationTime - m_ulBeginRotationTime);
const float fCameraDelta = GetOffsetRadians(m_fBeginCameraRotation, m_fTargetCameraRotation);
const float fProgress = float(ulCurrentTime - m_ulBeginRotationTime);
const float fNewRotation = m_fBeginRotation + fDelta * (fProgress / fDeltaTime);
const float fNewCameraRotation = m_fBeginCameraRotation + fCameraDelta * (fProgress / fDeltaTime);

SetCurrentRotation(fNewRotation);
SetCameraRotation(fNewCameraRotation);
}
Expand Down
4 changes: 2 additions & 2 deletions Client/mods/deathmatch/logic/CPacketHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,7 @@ void CPacketHandler::Packet_DebugEcho(NetBitStreamInterface& bitStream)
if (!bitStream.Read(ucLevel))
return;

if (ucLevel == 0)
if (ucLevel == 0 || ucLevel == 4)
{
// Read out the color
if (!bitStream.Read(ucRed) || !bitStream.Read(ucGreen) || !bitStream.Read(ucBlue))
Expand All @@ -1481,7 +1481,7 @@ void CPacketHandler::Packet_DebugEcho(NetBitStreamInterface& bitStream)
}

// Valid length?
int iBytesRead = (ucLevel == 0) ? 4 : 1;
int iBytesRead = (ucLevel == 0 || ucLevel == 4) ? 4 : 1;
int iNumberOfBytesUsed = bitStream.GetNumberOfBytesUsed() - iBytesRead;
if (iNumberOfBytesUsed >= MIN_DEBUGECHO_LENGTH && iNumberOfBytesUsed <= MAX_DEBUGECHO_LENGTH)
{
Expand Down
96 changes: 72 additions & 24 deletions Client/mods/deathmatch/logic/CPedSync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,29 +179,50 @@ void CPedSync::Packet_PedSync(NetBitStreamInterface& BitStream)
unsigned char ucFlags = 0;
BitStream.Read(ucFlags);

CVector vecPosition, vecMoveSpeed;
CVector vecPosition{ CVector::NoInit{} }, vecMoveSpeed{ CVector::NoInit{} };
float fRotation, fHealth, fArmor;
bool bOnFire;
bool bIsInWater;

// Read out the position
if (ucFlags & 0x01)
if (BitStream.Can(eBitStreamVersion::PedSync_Revision))
{
BitStream.Read(vecPosition.fX);
BitStream.Read(vecPosition.fY);
BitStream.Read(vecPosition.fZ);
}
// Read out the position
SPositionSync position(false);
if (ucFlags & 0x01)
BitStream.Read(&position);

// And rotation
if (ucFlags & 0x02)
BitStream.Read(fRotation);
// And rotation
SPedRotationSync rotation;
if (ucFlags & 0x02)
BitStream.Read(&rotation);

// And the move speed
SVelocitySync velocity;
if (ucFlags & 0x04)
BitStream.Read(&velocity);

// And the move speed
if (ucFlags & 0x04)
vecPosition = position.data.vecPosition;
fRotation = rotation.data.fRotation;
vecMoveSpeed = velocity.data.vecVelocity;
}
else
{
BitStream.Read(vecMoveSpeed.fX);
BitStream.Read(vecMoveSpeed.fY);
BitStream.Read(vecMoveSpeed.fZ);
if (ucFlags & 0x01)
{
BitStream.Read(vecPosition.fX);
BitStream.Read(vecPosition.fY);
BitStream.Read(vecPosition.fZ);
}

if (ucFlags & 0x02)
BitStream.Read(fRotation);

if (ucFlags & 0x04)
{
BitStream.Read(vecMoveSpeed.fX);
BitStream.Read(vecMoveSpeed.fY);
BitStream.Read(vecMoveSpeed.fZ);
}
}

// And health with armour
Expand All @@ -223,9 +244,9 @@ void CPedSync::Packet_PedSync(NetBitStreamInterface& BitStream)
if (pPed && pPed->CanUpdateSync(ucSyncTimeContext))
{
if (ucFlags & 0x01)
pPed->SetPosition(vecPosition);
pPed->SetTargetPosition(vecPosition, PED_SYNC_RATE);
if (ucFlags & 0x02)
pPed->SetCurrentRotation(fRotation);
pPed->SetTargetRotation(PED_SYNC_RATE, fRotation, 0.0f);
if (ucFlags & 0x04)
pPed->SetMoveSpeed(vecMoveSpeed);
if (ucFlags & 0x08)
Expand Down Expand Up @@ -303,24 +324,51 @@ void CPedSync::WritePedInformation(NetBitStreamInterface* pBitStream, CClientPed
// Write position if needed
if (ucFlags & 0x01)
{
pBitStream->Write(vecPosition.fX);
pBitStream->Write(vecPosition.fY);
pBitStream->Write(vecPosition.fZ);
if (pBitStream->Can(eBitStreamVersion::PedSync_Revision))
{
SPositionSync position(false);
position.data.vecPosition = vecPosition;
pBitStream->Write(&position);
}
else
{
pBitStream->Write(vecPosition.fX);
pBitStream->Write(vecPosition.fY);
pBitStream->Write(vecPosition.fZ);
}

pPed->m_LastSyncedData->vPosition = vecPosition;
}

if (ucFlags & 0x02)
{
pBitStream->Write(pPed->GetCurrentRotation());
if (pBitStream->Can(eBitStreamVersion::PedSync_Revision))
{
SPedRotationSync rotation;
rotation.data.fRotation = pPed->GetCurrentRotation();
pBitStream->Write(&rotation);
}
else
pBitStream->Write(pPed->GetCurrentRotation());

pPed->m_LastSyncedData->fRotation = pPed->GetCurrentRotation();
}

// Write velocity
if (ucFlags & 0x04)
{
pBitStream->Write(vecVelocity.fX);
pBitStream->Write(vecVelocity.fY);
pBitStream->Write(vecVelocity.fZ);
if (pBitStream->Can(eBitStreamVersion::PedSync_Revision))
{
SVelocitySync velocity;
pBitStream->Write(&velocity);
}
else
{
pBitStream->Write(vecVelocity.fX);
pBitStream->Write(vecVelocity.fY);
pBitStream->Write(vecVelocity.fZ);
}

pPed->m_LastSyncedData->vVelocity = vecVelocity;
}

Expand Down
6 changes: 3 additions & 3 deletions Server/mods/deathmatch/logic/CPedSync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,13 @@ void CPedSync::Packet_PedSync(CPedSyncPacket& Packet)
// Apply the data to the ped
if (Data.ucFlags & 0x01)
{
pPed->SetPosition(Data.vecPosition);
pPed->SetPosition(Data.position.data.vecPosition);
g_pGame->GetColManager()->DoHitDetection(pPed->GetPosition(), pPed);
}
if (Data.ucFlags & 0x02)
pPed->SetRotation(Data.fRotation);
pPed->SetRotation(Data.rotation.data.fRotation);
if (Data.ucFlags & 0x04)
pPed->SetVelocity(Data.vecVelocity);
pPed->SetVelocity(Data.velocity.data.vecVelocity);

if (Data.ucFlags & 0x08)
{
Expand Down
2 changes: 1 addition & 1 deletion Server/mods/deathmatch/logic/packets/CDebugEchoPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bool CDebugEchoPacket::Write(NetBitStreamInterface& BitStream) const
{
// Write the level
BitStream.Write(static_cast<unsigned char>(m_uiLevel));
if (m_uiLevel == 0)
if (m_uiLevel == 0 || m_uiLevel == 4)
{
// Write the color
BitStream.Write(m_ucRed);
Expand Down
114 changes: 83 additions & 31 deletions Server/mods/deathmatch/logic/packets/CPedSyncPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,8 @@ bool CPedSyncPacket::Read(NetBitStreamInterface& BitStream)

// Did we recieve position?
if (ucFlags & 0x01)
{
if (!BitStream.Read(Data.vecPosition.fX) || !BitStream.Read(Data.vecPosition.fY) || !BitStream.Read(Data.vecPosition.fZ))
return false;
}

// Rotation
if (ucFlags & 0x02)
{
if (!BitStream.Read(Data.fRotation))
return false;
}

// Velocity
if (ucFlags & 0x04)
{
if (!BitStream.Read(Data.vecVelocity.fX) || !BitStream.Read(Data.vecVelocity.fY) || !BitStream.Read(Data.vecVelocity.fZ))
{
if (!(BitStream.Can(eBitStreamVersion::PedSync_Revision) ? Data.ReadSpatialData(BitStream) : Data.ReadSpatialDataBC(BitStream)))
return false;
}

Expand Down Expand Up @@ -108,25 +94,39 @@ bool CPedSyncPacket::Write(NetBitStreamInterface& BitStream) const

BitStream.Write(Data.ucFlags);

// Position and rotation
if (Data.ucFlags & 0x01)
if (BitStream.Can(eBitStreamVersion::PedSync_Revision))
{
BitStream.Write(Data.vecPosition.fX);
BitStream.Write(Data.vecPosition.fY);
BitStream.Write(Data.vecPosition.fZ);
}
// Position and rotation
if (Data.ucFlags & 0x01)
BitStream.Write(&Data.position);

if (Data.ucFlags & 0x02)
{
BitStream.Write(Data.fRotation);
}
if (Data.ucFlags & 0x02)
BitStream.Write(&Data.rotation);

// Velocity
if (Data.ucFlags & 0x04)
// Velocity
if (Data.ucFlags & 0x04)
BitStream.Write(&Data.velocity);
}
else
{
BitStream.Write(Data.vecVelocity.fX);
BitStream.Write(Data.vecVelocity.fY);
BitStream.Write(Data.vecVelocity.fZ);
// Position and rotation
if (Data.ucFlags & 0x01)
{
BitStream.Write(Data.position.data.vecPosition.fX);
BitStream.Write(Data.position.data.vecPosition.fY);
BitStream.Write(Data.position.data.vecPosition.fZ);
}

if (Data.ucFlags & 0x02)
BitStream.Write(Data.rotation.data.fRotation);

// Velocity
if (Data.ucFlags & 0x04)
{
BitStream.Write(Data.velocity.data.vecVelocity.fX);
BitStream.Write(Data.velocity.data.vecVelocity.fY);
BitStream.Write(Data.velocity.data.vecVelocity.fZ);
}
}

// Health, armour, on fire and is in water
Expand All @@ -141,3 +141,55 @@ bool CPedSyncPacket::Write(NetBitStreamInterface& BitStream) const

return true;
}

bool CPedSyncPacket::SyncData::ReadSpatialData(NetBitStreamInterface& BitStream)
{
// Did we recieve position?
if (ucFlags & 0x01)
{
if (!BitStream.Read(&position))
return false;
}

// Rotation
if (ucFlags & 0x02)
{
if (!BitStream.Read(&rotation))
return false;
}

// Velocity
if (ucFlags & 0x04)
{
if (!BitStream.Read(&velocity))
return false;
}

return true;
}

bool CPedSyncPacket::SyncData::ReadSpatialDataBC(NetBitStreamInterface& BitStream)
{
// Did we recieve position?
if (ucFlags & 0x01)
{
if (!BitStream.Read(position.data.vecPosition.fX) || !BitStream.Read(position.data.vecPosition.fY) || !BitStream.Read(position.data.vecPosition.fZ))
return false;
}

// Rotation
if (ucFlags & 0x02)
{
if (!BitStream.Read(rotation.data.fRotation))
return false;
}

// Velocity
if (ucFlags & 0x04)
{
if (!BitStream.Read(velocity.data.vecVelocity.fX) || !BitStream.Read(velocity.data.vecVelocity.fY) || !BitStream.Read(velocity.data.vecVelocity.fZ))
return false;
}

return true;
}
Loading

0 comments on commit 379ba7d

Please sign in to comment.