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 */ | |
} |
The frame skip also needs to be addressed, the branching isn't necessary and creates weird complexity without adding value.
- Remove it - simple, slowdowns will in-fact slow down.
- Use as a multiplier against dwFrameTime - May be slightly inaccurate due to delay sources expiring.
- Look at the larger non-posted picture and possibly loop over the frame advancement for the larger set of things to rapidly advance to an accurate image of what the server thinks is happening.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should be the following:
This allows for consistent client timings based on the absolute start of the time and not loop speed. It also takes into account slowness based exactly on the frame time and delay.