Raised This Month: $ Target: $400
 0% 

FM_CmdStart and client_PreThink


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fr33m@n
Veteran Member
Join Date: May 2008
Location: France Marne
Old 03-09-2017 , 07:18   FM_CmdStart and client_PreThink
Reply With Quote #1

I was on the move to update some forward in some plugins, for performance reasons.

I saw many usage of client_PreThink + get_user_button for the only purpose of getting what button is used at this very moment.

Since CmdStart, if i remember right, is called at the same frame and the same number of time as client_prethink, since CmdStart can directly pass the button in a uc_handle

What is better ?

client_prethink + get_user_button
or CmdStart + get_uc(uc_handle, UC_Buttons)

Last edited by Fr33m@n; 03-09-2017 at 07:18.
Fr33m@n is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 03-09-2017 , 07:34   Re: FM_CmdStart and client_PreThink
Reply With Quote #2

https://forums.alliedmods.net/showth...823#post351823
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
Fr33m@n
Veteran Member
Join Date: May 2008
Location: France Marne
Old 03-09-2017 , 09:10   Re: FM_CmdStart and client_PreThink
Reply With Quote #3

This topic don't cover the question. Plus most of the post are vague.
Fr33m@n is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 03-09-2017 , 09:19   Re: FM_CmdStart and client_PreThink
Reply With Quote #4

CmdStart + get_uc(uc_handle, UC_Buttons)
__________________
edon1337 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 03-09-2017 , 09:47   Re: FM_CmdStart and client_PreThink
Reply With Quote #5

https://github.com/dreamstalker/rehl....cpp#L777-L808
This is the difference in code. CmdStart is called at line 777, PlayerPreThink is called at 808.

The order is: CmdStart -> PlayerPreThink -> Think -> PlayerPostThink -> CmdEnd.

HLSDK Says:

  • Code:
    CmdStart
    
    We're about to run this usercmd for the specified player.  We can set up groupinfo and masking here, etc.
    This is the time to examine the usercmd for anything extra.  This call happens even if think does not.

  • Code:
    PlayerPreThink
    
    Called every frame before physics are run

  • Code:
    PlayerPostThink
    
    Called every frame after physics are run

  • Code:
    CmdEnd
    
    Each cmdstart is exactly matched with a cmd end, clean up any group trace flags, etc. here

Only Think (Not PreThink and PostThink) may not happen every frame.

Looks like game dll inspects button presses and does physics stuff in PreThink and advances animations and such on PostThink. My best guess is to do whatever you want related to button presses/physics in PlayerPreThink post-hook and totally avoid CmdStart, unless you need that usercmd_t pointer.

Last edited by klippy; 03-09-2017 at 09:50.
klippy is offline
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 17:52.


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