View Single Post
  #1  
Old 10-31-2012, 09:54 AM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default overriding and casting

i'm still learning C++ and i'm having a little bit of trouble wrapping my head around something. i've seen areas where group members are being iterated over as mobs, IsClient() is checked, and if true, a Client method is called on the mob through CastToClient(). can the check and cast be skipped if the method being called is overridden in the Client class? is it only necessary when the method being called is unique to Client? i'm wondering because IsClient() is only set to return a value of true in the definition of Client, but is false in Entity and Mob, and this leads me to believe the client check and cast would be superfluous.

for example, if i wanted to override Mob::IsEngaged() in client.h with

Code:
virtual inline bool IsEngaged() { return (IsAIControlled() ? !hate_list.IsEmpty() : AggroCount > 0);
would i be able to skip IsClient() and CastToClient() for each group member?

thanks in advance.
Reply With Quote