Created
November 14, 2012 02:57
-
-
Save JensenDied/4070002 to your computer and use it in GitHub Desktop.
Helbreath Client / Player Speed Issues
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
// Pointing out the exact bad code that causes various speed discrepancies between players in Helbreath | |
int CMapData::iObjectFrameCounter(char * cPlayerName, short sViewPointX, short sViewPointY) { | |
/* Snip */ | |
// dwFrameTime = expected frame time + delay | |
dwFrameTime = m_stFrame[m_pData[dX][dY].m_sOwnerType][m_pData[dX][dY].m_cOwnerAction].m_sFrameTime + iDelay | |
// if (time since last frame update > expected frame time) | |
if ((dwTime - m_pData[dX][dY].m_dwOwnerTime) > dwFrameTime) { | |
// For slow people: Skip up to 3 frames if this actually happens | |
if ((dwTime - m_pData[dX][dY].m_dwOwnerTime) >= (dwFrameTime +dwFrameTime)) { | |
iSkipFrame = ((dwTime - m_pData[dX][dY].m_dwOwnerTime)/dwFrameTime); | |
if (iSkipFrame > 3) iSkipFrame = 3; | |
m_pData[dX][dY].m_cOwnerFrame += iSkipFrame; | |
} else { | |
// Update frame if just one frame | |
m_pData[dX][dY].m_cOwnerFrame++; | |
} | |
// Set last action time to current time (NOT ADJUSTED FOR ABSOLUTE TIME) | |
m_pData[dX][dY].m_dwOwnerTime = dwTime; | |
/* Snip */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The frame skip also needs to be addressed, the branching isn't necessary and creates weird complexity without adding value.