Position speed checks should be based on the client tick. This fixes excessive rubber banding

ryzomclassic-develop
kaetemi 3 years ago
parent 3f63f27143
commit 4407fc2970
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

@ -1711,6 +1711,7 @@ bool CUserEntity::sendToServer(CBitMemStream &out)
if (_Primitive) _Primitive->getGlobalPosition(_LastGPosSent, dynamicWI); if (_Primitive) _Primitive->getGlobalPosition(_LastGPosSent, dynamicWI);
// Send Position & Orientation // Send Position & Orientation
CPositionMsg positionMsg; CPositionMsg positionMsg;
positionMsg.Tick = NetMngr.getCurrentClientTick();
positionMsg.X = (sint32)(pos().x * 1000); positionMsg.X = (sint32)(pos().x * 1000);
positionMsg.Y = (sint32)(pos().y * 1000); positionMsg.Y = (sint32)(pos().y * 1000);
positionMsg.Z = (sint32)(pos().z * 1000); positionMsg.Z = (sint32)(pos().z * 1000);

@ -43,7 +43,7 @@
<leaf name="INIT_BANK" /> <leaf name="INIT_BANK" />
<leaf name="RESET_BANK" /> <leaf name="RESET_BANK" />
</branch> </branch>
<leaf name="POSITION" sendto="GPMS" format="s32 s32 s32 f" usecycle="yes" description="the client moves to ($i32,$i32,$i32) with heading $f" /> <leaf name="POSITION" sendto="GPMS" format="u32 s32 s32 s32 f" usecycle="yes" description="the client moves to ($i32,$i32,$i32) with heading $f" />
<branch name="HARVEST"> <branch name="HARVEST">
<leaf name="DEPOSIT" sendto="EGS" format="u16" description="the client shearch a deposit for harvest/digging (param = skill used)" /> <leaf name="DEPOSIT" sendto="EGS" format="u16" description="the client shearch a deposit for harvest/digging (param = skill used)" />
<leaf name="CORPSE" /> <leaf name="CORPSE" />

@ -563,6 +563,7 @@ public:
class CPositionMsg class CPositionMsg
{ {
public: public:
NLMISC::TGameCycle Tick;
sint32 X; sint32 X;
sint32 Y; sint32 Y;
sint32 Z; sint32 Z;
@ -571,6 +572,7 @@ public:
void serial(NLMISC::CBitMemStream &f) void serial(NLMISC::CBitMemStream &f)
{ {
// Serialize the user character. // Serialize the user character.
f.serial(Tick);
f.serial(X); f.serial(X);
f.serial(Y); f.serial(Y);
f.serial(Z); f.serial(Z);

@ -50,8 +50,8 @@ void cbClientPosition( CMessage& msgin, const string &serviceName, NLNET::TServi
H_AUTO(cbClientPosition); H_AUTO(cbClientPosition);
CEntityId id; CEntityId id;
NLMISC::TGameCycle tick; NLMISC::TGameCycle fsTick;
msgin.serial(id, tick); msgin.serial(id, fsTick);
TDataSetRow entityIndex = TheDataset.getDataSetRow( id ); TDataSetRow entityIndex = TheDataset.getDataSetRow( id );
if ( !entityIndex.isValid() ) if ( !entityIndex.isValid() )
@ -62,15 +62,16 @@ void cbClientPosition( CMessage& msgin, const string &serviceName, NLNET::TServi
} }
// entity pos (x, y, z, theta) // entity pos (x, y, z, theta)
NLMISC::TGameCycle clientTick;
sint32 x, y, z; sint32 x, y, z;
float heading; float heading;
msgin.serial(x, y, z, heading); msgin.serial(clientTick, x, y, z, heading);
if (IsRingShard) if (IsRingShard)
{ {
// make sure the move that the player is trying to make is legal // make sure the move that the player is trying to make is legal
// if the move wasn't legal then the values of 'x' and 'y' will be changed to make them legal // if the move wasn't legal then the values of 'x' and 'y' will be changed to make them legal
bool moveWasLegal= pCGPMS->MoveChecker->checkMove(entityIndex, x, y, tick); bool moveWasLegal= pCGPMS->MoveChecker->checkMove(entityIndex, x, y, clientTick);
// if the move wasn't legal then dispatch a message to the player // if the move wasn't legal then dispatch a message to the player
if (!moveWasLegal) if (!moveWasLegal)
@ -102,7 +103,7 @@ void cbClientPosition( CMessage& msgin, const string &serviceName, NLNET::TServi
CMirrorPropValue1DS<sint32>( TheDataset, entityIndex, DSPropertyPOSY )= y; CMirrorPropValue1DS<sint32>( TheDataset, entityIndex, DSPropertyPOSY )= y;
CMirrorPropValue1DS<sint32>( TheDataset, entityIndex, DSPropertyPOSZ )= (z&~7) + (local ? 1 : 0) + (interior ? 2 : 0) + (water ? 4 : 0); CMirrorPropValue1DS<sint32>( TheDataset, entityIndex, DSPropertyPOSZ )= (z&~7) + (local ? 1 : 0) + (interior ? 2 : 0) + (water ? 4 : 0);
CMirrorPropValue1DS<float>( TheDataset, entityIndex, DSPropertyORIENTATION )= heading; CMirrorPropValue1DS<float>( TheDataset, entityIndex, DSPropertyORIENTATION )= heading;
CMirrorPropValue1DS<NLMISC::TGameCycle>( TheDataset, entityIndex, DSPropertyTICK_POS )= tick; CMirrorPropValue1DS<NLMISC::TGameCycle>( TheDataset, entityIndex, DSPropertyTICK_POS )= clientTick;
CMirrorPropValue1DS<TYPE_CELL> cell ( TheDataset, entityIndex, DSPropertyCELL ); CMirrorPropValue1DS<TYPE_CELL> cell ( TheDataset, entityIndex, DSPropertyCELL );
uint32 cx = (uint16) ( + x/CWorldPositionManager::getCellSize() ); uint32 cx = (uint16) ( + x/CWorldPositionManager::getCellSize() );
@ -143,7 +144,7 @@ void cbClientPosition( CMessage& msgin, const string &serviceName, NLNET::TServi
//CWorldPositionManager::setEntityPosition(id, x, y, z, heading, tick); //CWorldPositionManager::setEntityPosition(id, x, y, z, heading, tick);
if (player->getType() == CWorldEntity::Player && player->CheckMotion && player->PosInitialised) if (player->getType() == CWorldEntity::Player && player->CheckMotion && player->PosInitialised)
{ {
CWorldPositionManager::movePlayer(player, x, y, z, heading, tick); CWorldPositionManager::movePlayer(player, x, y, z, heading, clientTick);
} }
} }
} // cbClientPosition // } // cbClientPosition //

@ -2218,15 +2218,9 @@ void CWorldPositionManager::movePlayer(CWorldEntity *entity, sint32 x, sint32 y,
if (movNorm > sqr(maxDist)) if (movNorm > sqr(maxDist))
{ {
if (movNorm > sqr(5 * SecuritySpeedFactor * CTickEventHandler::getGameTimeStep() * ticksSinceLastUpdate)) {
movVector *= (maxDist / sqrt(movNorm)); movVector *= (maxDist / sqrt(movNorm));
nlwarning("Player limitSpeed=%2.f, entitySpeed=%.2f, masterSpeed=%.2f", limitSpeedToUse, maxSpeed(), mountWalkSpeed); nlwarning("Player limitSpeed=%2.f, entitySpeed=%.2f, masterSpeed=%.2f", limitSpeedToUse, maxSpeed(), mountWalkSpeed);
} }
else
{
nlwarning("Player limitSpeed=%2.f, entitySpeed=%.2f, masterSpeed=%.2f", limitSpeedToUse, maxSpeed(), mountWalkSpeed);
}
}
} }
// check entity has a primitive // check entity has a primitive

Loading…
Cancel
Save