Created
June 12, 2013 15:12
-
-
Save mattraykowski/5766165 to your computer and use it in GitHub Desktop.
The relevant CheckPlayerSpeed code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check player speed | |
// only consider (x,y) motion for speed and position correction | |
if (master->PlayerInfos != NULL && master->PlayerInfos->CheckSpeed && CheckPlayerSpeed && fabs(movVector.x)+fabs(movVector.y) > maxDist) | |
{ | |
double movNorm = sqr(movVector.x)+sqr(movVector.y); // already done if (entity != master) but here is a rare overspeed case | |
if (movNorm > sqr(maxDist)) | |
{ | |
if (VerboseSpeedAbuse) | |
{ | |
nlwarning("CWorldPositionManager::movePlayer%s: limited speed (movNorm=%.2f, movMax=%.2f, maxSpeed=%.2f)", entity->Id.toString().c_str(), sqrt(movNorm), maxDist, limitSpeedToUse*0.001*SecuritySpeedFactor); | |
} | |
movVector *= (maxDist / sqrt(movNorm)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment