Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SourceDayZ — DayZ Source

Este repositório contém o código-fonte do SourceDayZ.

## Aviso obrigatório: Steam e BattlEye

**NÃO remova o Steam nem o BattlEye deste projeto.**

- A integração com a **Steam** (`steam_api64`, Steamworks e arquivos relacionados) é obrigatória e não pode ser removida.
- O **BattlEye** e seus arquivos/serviços de proteção são obrigatórios e não podem ser removidos.
- Pull requests ou alterações que removam, desativem ou substituam a Steam ou o BattlEye **não serão aceitos**.
- Essa regra vale para o cliente, o servidor e qualquer script de build, instalação ou empacotamento.

Mantenha a Steam e o BattlEye intactos em qualquer alteração.
4 changes: 4 additions & 0 deletions lib/Inventory/inventory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ class InventoryItem : public PoweredItem

virtual float UpdateDistance() const override;

//! Items can be dropped from an inventory, so keep a valid position update
//! even when the item is not in the landscape on this client yet.
virtual bool AcceptPositionOutsideLandscape() const override {return true;}

virtual bool QIsManual() const override {return false;}
virtual AnimationStyle IsAnimated(int level) const override;

Expand Down
10 changes: 10 additions & 0 deletions lib/Network/networkClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4510,6 +4510,16 @@ void NetworkClient::OnMessage(int from, NetworkMessage *msg, NetworkMessageType
Vector3Val pos = owner->FutureVisualState().Position();
Vector3Val dir = owner->FutureVisualState().Direction();
item->ItemDrop(owner, pos, dir);

// The item is now a world object. Remote clients need both:
// - a generic update, which carries the inLandscape flag and makes
// the client call ItemMoveIn() (add the item to the landscape);
// - a position update, because the generic item update does NOT
// carry the transform. Without it the client keeps the item at
// its old inventory position and it looks like it disappeared.
UpdateObject(item, NMCUpdateGeneric, NMFGuaranteed);
UpdateObject(item, NMCUpdatePosition, NMFGuaranteed);
if (owner) UpdateObject(owner, NMCUpdateGeneric, NMFGuaranteed);
}
}
break;
Expand Down
12 changes: 12 additions & 0 deletions lib/simul.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5790,6 +5790,18 @@ TMError Entity::TransferMsg(NetworkMessageContext &ctx)
{
_remoteState.Free();
}
else if (positionValid && !IsInLandscape() && AcceptPositionOutsideLandscape())
{
// The object is not in the landscape on this client yet. This
// happens when an item is dropped: the server sends the new
// transform while the client may still have the item stored in an
// inventory slot. Store the transform now, so ItemMoveIn() puts the
// item at the position chosen by the server instead of leaving it
// at the old inventory transform.
_remoteState.Free();
Matrix4 trans = GetTransformFromRemoteState(remoteState.orient,remoteState.pos,FutureVisualState());
SetTransform(trans);
}
else if (positionValid && IsInLandscape()) // positionValid is IsInLandscape() on the sender side
{
VisualState &vs = FutureVisualState();
Expand Down
81 changes: 70 additions & 11 deletions lib/soldierOld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2443,6 +2443,7 @@ Matrix3 Man::HeadBobOrientation(const VisualStateAge vsa, CameraType camType, bo
int animCount = headBlend._list.Size();
int gestCount = headBlend._masked.Size();
bool cutSceneMode = false;
float headBobWeight = 0.0f;
for (int i = 0; i < animCount + gestCount; i++)
{
const AnimBlendInfo &animInfo = (i < animCount) ? headBlend._list.Get(i) : headBlend._masked.Get(i - animCount);
Expand Down Expand Up @@ -2516,8 +2517,14 @@ Matrix3 Man::HeadBobOrientation(const VisualStateAge vsa, CameraType camType, bo
partMatrix = partMatrix * headBobStrength + zeroStrengthMatrix * (1.0 - headBobStrength);
}
headBobMatrix += partMatrix * animFactor;
headBobWeight += fabs(animFactor);
}
headBobMatrix.Orthogonalize();
// Animation transitions can briefly have no weighted pose. Orthogonalizing
// a zero matrix produces an unstable view orientation in those frames.
if (headBobWeight > 1e-6f)
headBobMatrix.Orthogonalize();
else
headBobMatrix = MIdentity;

// final camera transformation
Matrix3 pilotOrient;
Expand Down Expand Up @@ -6472,7 +6479,7 @@ bool Man::CreatePotentialStateFreeFall(ManVisualState & moveTrans, Vector3& fric
return true;
}

const float SlideSlopeThreshold = 2.0f; //atan(sqrt(2))=cca=55�
const float SlideSlopeThreshold = 2.0f; //atan(sqrt(2))=cca=55�
inline float SlideSpeedWanted(float gradFwd, float gradAside, float forceStand)
{
if (forceStand) return 0;
Expand All @@ -6485,7 +6492,7 @@ inline float SlideSpeedWanted(float gradFwd, float gradAside, float forceStand)
else
return slope - 2*SlideSlopeThreshold; //brake is more efficient
}
const float StandSlopeThreshold = 0.6f; //atan(sqrt(2))=cca=38�
const float StandSlopeThreshold = 0.6f; //atan(sqrt(2))=cca=38�
inline bool ShouldStand(float gradFwd, float gradAside, bool forceStand)
{
//if (forceStand) return true; //NO! unable to prone on the road after such setting!
Expand Down Expand Up @@ -6566,7 +6573,14 @@ bool Man::CreatePotentialState(ManVisualState & moveTrans, float& turn, float de
if (QIsManual())
{
//if (IsDead()) LandSlope(_forceStand, _landGradFwd, _landGradAside);
float slideSpeedWanted = SlideSpeedWanted(_landGradFwd, _landGradAside, _forceStand);
// The player's animation already supplies the requested displacement.
// Adding slope slide on top of a running step makes ground contact and the
// attached camera bounce as the terrain correction changes each frame.
// Keep automatic sliding only when there is no locomotion input.
bool playerMoving = fabs(_walkSpeedWantedX) > 0.1f || fabs(_walkSpeedWantedZ) > 0.1f;
if (playerMoving)
_slideSpeed = 0;
float slideSpeedWanted = playerMoving ? 0 : SlideSpeedWanted(_landGradFwd, _landGradAside, _forceStand);
if (slideSpeedWanted>0 || _slideSpeed>0) //slide or brake slide
{
const float timeToReachTheSpeed = 2.0f; //from zero speed 2 seconds needed to reach the speed
Expand Down Expand Up @@ -15627,11 +15641,20 @@ void Soldier::KeyboardPilot(float deltaT, SimulationImportance prec)
{
float lookX = input->GetActionWithCurveExclusive(InputInterface::CurveFovMouse, UAAimHeadRight, UAAimHeadLeft);
float lookY = input->GetActionWithCurveExclusive(InputInterface::CurveFovMouse, UAAimHeadUp, UAAimHeadDown);
// Some 0.45 input profiles only bind the horizontal mouse to UAAimRight/
// UAAimLeft. Preserve free-look yaw in those profiles when the dedicated
// head-yaw pair has no binding or was already consumed by another view.
if (fabs(lookX) < 1e-6f)
lookX = input->GetActionWithCurve(InputInterface::CurveFovMouse, UAAimRight, UAAimLeft);
// Older profiles may bind horizontal mouse movement only to body aim.
// Select that fallback from the bindings, never from a zero input sample:
// zero samples also occur between mouse events and while sprinting, and
// switching input sources on those frames makes the camera stutter.
if (QIsManual() &&
GInput.GetActionKeys("AimHeadRight").Size() == 0 &&
GInput.GetActionKeys("AimHeadLeft").Size() == 0)
lookX = input->GetActionWithCurveExclusive(InputInterface::CurveFovMouse, UAAimRight, UAAimLeft);
Comment on lines +15648 to +15651

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Controller bindings block mouse freelook

With the character controller scheme enabled, KeyboardPilot ignores horizontal mouse input bound only to body aim during freelook. GetUserKeys counts thumbstick bindings as head-yaw bindings, so the mouse fallback never runs.

Learn more

The game stores normal body aim and freelook yaw as separate actions. GetActionKeys delegates to GetUserKeys, which supplies both profile and controller-scheme bindings. KeyListEx::Size adds the two lists together. The character controller scheme binds both head-yaw directions to the thumbstick. These entries disable the mouse fallback even when the profile has no head-yaw mouse bindings.

Example: Enable the built-in character controller scheme with a profile that binds mouse X only to AimLeft and AimRight. Hold freelook and move the mouse without touching the thumbstick. Neither mouse direction turns the camera horizontally, although both worked with the previous fallback.

Recommended fix: Select the yaw action for each mouse direction from its mouse-axis bindings, independently of controller bindings. Keep reading dedicated head-yaw controller input and use body aim only for mouse directions without a dedicated binding. Test a mixed mouse/controller profile and a profile with dedicated mouse head-yaw bindings.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.


// Mouse look must follow the current input. The head smoothing above is
// for automatic recentering and discrete look actions; leaving it active
// while walking makes horizontal camera motion trail and oscillate.
if (QIsManual() && (fabs(lookX) > 1e-6f || fabs(lookY) > 1e-6f))
_headSmoothMove = false;

float rotXWanted = (ironSight ? _gunXRotWanted : _lookXRotWanted) + lookY*deltaT;
float rotYWanted = (ironSight ? _gunYRotWanted : _lookYRotWanted) - lookX*deltaT;
Expand Down Expand Up @@ -15682,6 +15705,8 @@ void Soldier::KeyboardPilot(float deltaT, SimulationImportance prec)

float aimX = input->GetActionWithCurve(InputInterface::CurveFovMouse,UAAimRight,UAAimLeft);
float aimY = input->GetActionWithCurve(InputInterface::CurveFovMouse,UAAimUp,UAAimDown);
if (QIsManual() && (fabs(aimX) > 1e-6f || fabs(aimY) > 1e-6f))
_headSmoothMove = false;

bool useAimingDeadzone = IsAimingDeadzoneEnabled();

Expand Down Expand Up @@ -15977,10 +16002,14 @@ void Soldier::KeyboardPilot(float deltaT, SimulationImportance prec)
else
{
//GlobalShowMessage(100, "Slope %.2f",slope);
if (!_canMoveFast || !CanSprint(_landGradFwd, _landGradAside, dirFwd, dirAside))
// Terrain gradients can jump between adjacent samples on a steep hill.
// For the local player, changing the gait every frame makes the running
// animation (and its camera transform) oscillate. Preserve the chosen
// gait while the regular stamina and movement limits still apply.
if (!_canMoveFast || (!QIsManual() && !CanSprint(_landGradFwd, _landGradAside, dirFwd, dirAside)))
fastFlag = 0;
fastFlag++;
if (wantSlow && fastFlag==1 || !CanRun(_landGradFwd, _landGradAside, dirFwd, dirAside))
if (wantSlow && fastFlag==1 || (!QIsManual() && !CanRun(_landGradFwd, _landGradAside, dirFwd, dirAside)))
fastFlag = 0;
}
switch (fastFlag)
Expand Down Expand Up @@ -24112,6 +24141,22 @@ TMError Man::TransferMsg(NetworkMessageContext &ctx)
int lastLadderIndex = _ladderIndex;
PREPARE_TRANSFER(UpdatePositionMan)

// Position snapshots are authoritative for the body, but the local
// player's view angles are predicted from this frame's mouse input.
// Keep them before reading the server snapshot so an older look value
// cannot visibly pull the camera back after a local mouse movement.
const bool preserveLocalView = !ctx.IsSending() && GWorld && this == GWorld->GetRealPlayer();
const float localGunXRotWanted = _gunXRotWanted;
const float localGunYRotWanted = _gunYRotWanted;
const float localHeadXRotWanted = _headXRotWanted;
const float localHeadYRotWanted = _headYRotWanted;
const float localHeadXRotWantedCont = _headXRotWantedCont;
const float localHeadYRotWantedCont = _headYRotWantedCont;
const float localHeadXRotWantedPan = _headXRotWantedPan;
const float localHeadYRotWantedPan = _headYRotWantedPan;
const float localLookXRotWanted = _lookXRotWanted;
const float localLookYRotWanted = _lookYRotWanted;

TRANSF(gunXRotWanted)
TRANSF(gunYRotWanted)
TRANSF(headXRotWanted)
Expand All @@ -24124,6 +24169,20 @@ TMError Man::TransferMsg(NetworkMessageContext &ctx)
TRANSF(headYRotWantedPan)
TRANSF(leanZRotWanted)

if (preserveLocalView)
{
_gunXRotWanted = localGunXRotWanted;
_gunYRotWanted = localGunYRotWanted;
_headXRotWanted = localHeadXRotWanted;
_headYRotWanted = localHeadYRotWanted;
_headXRotWantedCont = localHeadXRotWantedCont;
_headYRotWantedCont = localHeadYRotWantedCont;
_headXRotWantedPan = localHeadXRotWantedPan;
_headYRotWantedPan = localHeadYRotWantedPan;
_lookXRotWanted = localLookXRotWanted;
_lookYRotWanted = localLookYRotWanted;
}

TRANSF_REF(ladderBuilding)
TRANSF(ladderIndex)
TRANSF(ladderPosition)
Expand Down
8 changes: 8 additions & 0 deletions lib/vehicle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1727,6 +1727,14 @@ class Entity: public ObjectTyped, public Animated
virtual Vector3 WorldSpeed() const;
virtual bool IsInLandscape() const;

//! Accept a valid position update even when this object is not in the landscape yet.
/*!
Used by items that can be moved between an inventory and the world. A
dropped item may receive the position update before the update which adds
it to the landscape, and the transform must not be lost in that case.
*/
virtual bool AcceptPositionOutsideLandscape() const {return false;}

void ResetDelete() {_delete = false;}
void ResetMoveOut();

Expand Down
Loading