Raised This Month: $32 Target: $400
 8% 

[INFO] Think workflow


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 12-01-2009 , 09:52   [INFO] Think workflow
Reply With Quote #1

I posting this here because I think I'm right with my conclussions.
Anyway, I can fix any error i've made.

Because I didn't knew exactly how the things go inside the engine, I've read hlsdk to understand it.
Here's the flow of calls in PreThink and PostThink (see the attach)

So, as I understand, every call to PreThink implies (in order) calling PlayerPreThink, ItemPreFrame and UpdateClientData and after that, PreThink will return.

I only show that calls who can be used with hamsandwitch but there some other calls that we can't use in an amxx plugin (but yes for modules).

I think this is usefull to people who doesn't know the order of each call and when it's used.

If anyone know that I'm missing something or I'm wrong, please let me know.
Thanks

EDIT:

Here's the updated workflow (made by Connor, updated by me)

Code:
SV_Frame
{
        looped SV_ExecuteClientMessage ->      
        {
                pfnCmdStart (FM_CmdStart)
                pfnPlayerPreThink (client_PreThink , FM_PlayerPreThink)
                pfnThink (pfnThink, FM_Think)
                pfnPM_Move
                pfnPlayerPostThink (client_PostThink, FM_PlayerPostThink)
                pfnCmdEnd (FM_CmdEnt)
        }
 
        SV_Physics
        {
                pfnStartFrame (server_frame, FM_StartFrame)
                loop for each entity ->
                 {
                        if movetype ->
                        {
                                SV_Physics_* 
                                if touch => pfnTouch (pfnTouch, FM_Touch)
                        }
                        pfnThink (pfnThink, FM_Think) // entities only
                 }
        }
 
        SV_SendClientMessages (looping)
        {
                SV_WriteClientdataToMessage -> gEntityInterface.pfnUpdateClientData (FM_UpdateClientData)
                SV_WriteEntitiesToClient -> gEntityInterface.pfnAddToFullPack (FM_AddToFullPack)
        }
}
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.

Last edited by joropito; 07-31-2013 at 08:03.
joropito is offline
Send a message via MSN to joropito
Javivi
AlliedModders Donor
Join Date: Dec 2008
Old 12-01-2009 , 10:41   Re: [INFO] Think Flow
Reply With Quote #2

Interesting
__________________
Javivi is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-06-2009 , 06:34   Re: [INFO] Think workflow
Reply With Quote #3

I think you are wrong with PreThink() (Ham_Think) called from PlayerPreThink (Ham_Player_PreThink)

Reading HLSDK it seems to be :

PlayerPreThink (from client.cpp) I don't know if it's engine forward client_PreThink and fakemeta FM_PlayerPreThink but it sounds like it is correct.
Code:
/* ================ PlayerPreThink Called every frame before physics are run ================ */ void PlayerPreThink( edict_t *pEntity ) {     entvars_t *pev = &pEntity->v;     CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE(pEntity);     if (pPlayer)
        pPlayer->PreThink( );
}

Then CBasePlayer:reThink from player.cpp (Ham_Player_PreThink)
Code:
void CBasePlayer::PreThink(void) {     int buttonsChanged = (m_afButtonLast ^ pev->button);    // These buttons have changed this frame         // Debounced button codes for pressed/released     // UNDONE: Do we need auto-repeat?     m_afButtonPressed =  buttonsChanged & pev->button;    // The changed ones still down are "pressed"     m_afButtonReleased = buttonsChanged & (~pev->button);   // The ones not down are "released"
    g_pGameRules->PlayerThink( this );
    if ( g_fGameOver )         return;         // intermission or finale     UTIL_MakeVectors(pev->v_angle);             // is this still used?    
    ItemPreFrame( );
    WaterMove();     if ( g_pGameRules && g_pGameRules->FAllowFlashlight() )         m_iHideHUD &= ~HIDEHUD_FLASHLIGHT;     else         m_iHideHUD |= HIDEHUD_FLASHLIGHT;     // JOHN: checks if new client data (for HUD and view control) needs to be sent to the client
    UpdateClientData();

And from that one are called
* g_pGameRules->PlayerThink (CHalfLifeMultiplay :: PlayerThink in multiplayer that is hookable with orpheu module)
* ItemPreFrame
* UpdateClientData


Also, ItemPreFrame is not Ham_Item_PreFrame, it's CBasePlayer::ItemPreFrame (not hookable with hamsandwich) from where m_pActiveItem->ItemPreFrame( ); (Ham_Item_PreFrame) is called.

Code:
void CBasePlayer::ItemPreFrame()
{
#if defined( CLIENT_WEAPONS )
    if ( m_flNextAttack > 0 )
#else
    if ( gpGlobals->time < m_flNextAttack )
#endif
	{
		return;
	}

	if (!m_pActiveItem)
		return;

	m_pActiveItem->ItemPreFrame( );
}
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 12-06-2009 at 06:37.
ConnorMcLeod is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 12-06-2009 , 07:41   Re: [INFO] Think workflow
Reply With Quote #4

That's what I saw.

I don't mean each Ham_* where called directly but the sequence it's right.

I'm trying to understand (and show) the order in which each function is called.

I can put conditionals in the graphics to understand the difference you are talking about.
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-06-2009 , 08:56   Re: [INFO] Think workflow
Reply With Quote #5

You also forgot one thing for postthink, i guess it is like that :

Code:
PlayerPostThink (client_PreThink/FM_PlayerPostThink)
|
->    CBasePlayer::PostThink (Ham_Player_PostThink)
      |
      ->    CBasePlayer::ItemPostFrame (should be avaible with orpheu module)
            |
            ->    CBasePlayer::ImpulseCommands (Ham_Player_ImpulseCommands)
            ->    CBasePlayerWeapon::ItemPostFrame (Ham_Item_PostFrame)
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 12-06-2009 at 09:19.
ConnorMcLeod is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 05-25-2013 , 12:23   Re: [INFO] Think workflow
Reply With Quote #6

Just to keep track how things are called I post this here (credits to Connor)

Code:
SV_Frame
{
        looped SV_ExecuteClientMessage ->      
        {
                pfnCmdStart (FM_CmdStart)
                pfnPlayerPreThink (client_PreThink , FM_PlayerPreThink)
                pfnThink (pfnThink, FM_Think)
                pfnPM_Move
                pfnPlayerPostThink (client_PostThink, FM_PlayerPostThink)
                pfnCmdEnd (FM_CmdEnt)
        }
 
        SV_Physics
        {
                pfnStartFrame (server_frame, FM_StartFrame)
                loop for each entity ->
                 {
                        if movetype ->
                        {
                                SV_Physics_* 
                                if touch => pfnTouch (pfnTouch, FM_Touch)
                        }
                        pfnThink (pfnThink, FM_Think) // entities only
                 }
        }
 
        SV_SendClientMessages (looping)
        {
                SV_WriteClientdataToMessage -> gEntityInterface.pfnUpdateClientData (FM_UpdateClientData)
                SV_WriteEntitiesToClient -> gEntityInterface.pfnAddToFullPack (FM_AddToFullPack)
        }
}
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.

Last edited by joropito; 07-31-2013 at 08:02.
joropito is offline
Send a message via MSN to joropito
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-25-2013 , 12:58   Re: [INFO] Think workflow
Reply With Quote #7

I wanted to post it and completly forgot.
Everybody will notice that server_frame is called in the middle of the routine, can have its importance.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 07-31-2013 , 08:05   Re: [INFO] Think workflow
Reply With Quote #8

Small update in SV_Physics and moved updated workflow to first post
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-31-2013 , 08:11   Re: [INFO] Think workflow
Reply With Quote #9

What have you updated ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 07-31-2013 , 08:18   Re: [INFO] Think workflow
Reply With Quote #10

Quote:
Originally Posted by ConnorMcLeod View Post
What have you updated ?
SV_Physics

Code:
loop for each entity ->
{
         if movetype ->
         {
                 SV_Physics_*
                 if touch => pfnTouch (pfnTouch, FM_Touch)
         }
         pfnThink (pfnThink, FM_Think) // entities only
}
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:20.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode