class with static think function

Grab your favourite IDE and tinker with the innards of game engines

class with static think function

Postby davidc538 on Tue Jan 11, 2011 10:18 pm

With hl2 code is there a way for a class to have a static think() function? if there is how do i implement it?
User avatar
davidc538
Been Here A While
Been Here A While
 
Joined: Mon Aug 11, 2008 4:27 pm

Re: class with static think function

Postby omnicoder on Tue Jan 11, 2011 10:28 pm

Mark the function as static and only let it get registered once.
Image
If only the future implemented IForeseeable...
"whats threading? does it have to do with strings?" - stegarootbeer
User avatar
omnicoder
Been Here A While
Been Here A While
 
Joined: Sun Feb 07, 2010 8:35 am

Re: class with static think function

Postby davidc538 on Sat Jan 15, 2011 12:32 am

marking the function as static is quite easy but how do you make sure it only gets registered once?
User avatar
davidc538
Been Here A While
Been Here A While
 
Joined: Mon Aug 11, 2008 4:27 pm

Re: class with static think function

Postby zombie@computer on Sat Jan 15, 2011 6:55 pm

davidc538 wrote:marking the function as static is quite easy but how do you make sure it only gets registered once?




Code: Select all
bool m_bRegisteredStaticThink = false;
void RegisterThink()
{
   if (!m_bRegisteredStaticThink)
      register think blah blah
   m_bRegisteredStaticThink = true;
}




When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Return to Programming

Who is online

Users browsing this forum: No registered users