Raised This Month: $51 Target: $400
 12% 

Cache values for custom ents


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dFF
sıɹɹoɥɔ ʞɔnu
Join Date: Oct 2009
Old 07-26-2013 , 14:40   Cache values for custom ents
Reply With Quote #1

PHP Code:
const MAX_PLAYERS 32
#define MAX_ENTS ( 900 +  MAX_PLAYERS * 15 )
#define ENTS_ARRAY_SIZE ( MAX_ENTS / 32 ) + _:!!( MAX_ENTS % 32 )

new Float:g_fVelocityENTS_ARRAY_SIZE ][ ]

public 
CreateEnts()
{
    new 
iEnt create_entity"info_target" )
    
peviEntpev_velocityg_fVelocityiEnt ] ) // index out of bounds
}

public 
EntsThinkiEnt )
{
    if( 
is_valid_entiEnt ) )
    {
        
PrintVelocityiEnt )
        
        
// set next think .. others
    
}
}

PrintVelocityiEnt )
{
    
server_print"print: %f %f %f"g_fVelocityiEnt ][ ], g_fVelocityiEnt ][ ], g_fVelocityiEnt ][ ] )

I want to cache some values from custom entityes into a global, but i get index out of bounds error.
It's not possible with bits calculation ?

edit:
it's work if i used
PHP Code:
new Float:g_fVelocityMAX_ENTS ][ 
but it's to big big big array .. it's not a way to do this in a better method ?

Last edited by dFF; 07-26-2013 at 14:49.
dFF is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-26-2013 , 14:58   Re: Cache values for custom ents
Reply With Quote #2

Just don't cache values, should be ok for performances.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
dFF
sıɹɹoɥɔ ʞɔnu
Join Date: Oct 2009
Old 07-26-2013 , 15:04   Re: Cache values for custom ents
Reply With Quote #3

For example: pev_origin
my entityes thinks at very 0.1 second and in EntsThink( iEnt ) it's useless to call everytime at 0.1 pev( iEnt, pev_origin, fOrigin ) so i thinks it's was better to cache some values they change never (only at create entityes).
But anyway, it's not a big problem. Just for my curiosity.
dFF is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-26-2013 , 15:17   Re: Cache values for custom ents
Reply With Quote #4

It's not a problem at all with a 0.1 period.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
dFF
sıɹɹoɥɔ ʞɔnu
Join Date: Oct 2009
Old 07-26-2013 , 15:20   Re: Cache values for custom ents
Reply With Quote #5

Okey, thanks.
dFF 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 03:31.


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