Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't get post engine prediction flags #33

Closed
iniw opened this issue Jul 9, 2020 · 3 comments
Closed

can't get post engine prediction flags #33

iniw opened this issue Jul 9, 2020 · 3 comments
Labels
❌ invalid this doesn't seem right
Milestone

Comments

@iniw
Copy link

iniw commented Jul 9, 2020

this is how i'm getting pre and post engine prediction flags:

	int iPreFlags = pLocal->GetFlags();

	/*
	 * CL_RunPrediction
	 * correct prediction when framerate is lower than tickrate
	 * https://github.com/VSES/SourceEngine2007/blob/master/se2007/engine/cl_pred.cpp#L41
	 */
	if (I::ClientState->iDeltaTick > 0)
		I::Prediction->Update(I::ClientState->iDeltaTick, I::ClientState->iDeltaTick > 0, I::ClientState->iLastCommandAck, I::ClientState->iLastOutgoingCommand + I::ClientState->nChokedCommands);

	CPrediction::Get().Start(pCmd, pLocal);
	{
		int iPostFlags = pLocal->GetFlags();

		CMiscellaneous::Get().Test(pCmd, iPreFlags, iPostFlags);

that test function does this:

void CMiscellaneous::Test(CUserCmd* pCmd, int iPreFlags, int iPostFlags)
{	
	if (iPreFlags & FL_ONGROUND)
	{
		L::PushConsoleColor(FOREGROUND_RED);
		L::Print(XorStr("PREFLAGS: ONGROUND"));
	}
	else if (!(iPreFlags & FL_ONGROUND))
	{
		L::PushConsoleColor(FOREGROUND_GREEN);
		L::Print(XorStr("PREFLAGS: ONAIR"));
	}

	if (iPostFlags & FL_ONGROUND)
	{
		L::PushConsoleColor(FOREGROUND_RED);
		L::Print(XorStr("POSTFLAGS: ONGROUND"));
	}
	else if (!(iPostFlags & FL_ONGROUND))
	{
		L::PushConsoleColor(FOREGROUND_GREEN);
		L::Print(XorStr("POSTFLAGS: ONAIR"));
	}
}

here's an example of what it looks like:
image

as you can see, post and pre engine prediction flags update at the same time, even tho post should update 1 tick before pre.

@rollraw
Copy link
Owner

rollraw commented Jul 10, 2020

u should call CMiscellaneous::Test after CPrediction::End
stop disinformation

also rn im maked simple edge jump implementation and all works fine men

@rollraw rollraw closed this as completed Jul 10, 2020
@rollraw rollraw added the ❌ invalid this doesn't seem right label Jul 10, 2020
@iniw
Copy link
Author

iniw commented Jul 10, 2020

do you mind sharing your code? i did that too and the result is the same
image

	CPrediction::Get().End(pCmd, pLocal);

	int iPostFlags = pLocal->GetFlags();
	
       CMiscellaneous::Get().Test(pCmd, iPreFlags, iPostFlags)

@rollraw
Copy link
Owner

rollraw commented Jul 10, 2020

already removed the code but can write pseudo for u

void PrePredictionEdgeJump(CBaseEntity* pLocal)
{
    if (pLocal->GetMoveType() == MOVETYPE_LADDER || pLocal->GetMoveType() == MOVETYPE_NOCLIP)
         return;

    /* save flags to static var in class */
    iFlagsBackup = pLocal->GetFlags();
}

void PostPredictionEdjeJump(CUserCmd* pCmd, CBaseEntity* pLocal)
{
    if (pLocal->GetMoveType() == MOVETYPE_LADDER || pLocal->GetMoveType() == MOVETYPE_NOCLIP)
        return;

    if (iFlagsBackup & FL_ONGROUND && !(pLocal->GetFlags() & FL_ONGROUND))
          pCmd->iButtons |= IN_JUMP;
}

then in cm

PrePredictionEdgeJump(pLocal);
CPrediction::Get().Start();
{
    // ...
}
CPrediction::Get().End();
PostPredictionEdgeJump(pCmd, pLocal);

@rollraw rollraw added this to the v1.0 milestone Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❌ invalid this doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants