Game Development Community

gameconnection::onconnect()

by kcpdad · in Torque 3D Professional · 08/15/2012 (8:04 am) · 1 replies

I'm a bit confused by GameConnection::OnConnect() which appears in 2 files
  1. core/scripts/server/clientConnection.cs
  2. scripts/server/gameCore.cs
When I run either locally or connecting to a remote server the function in clientConnection.cs does not get called, only the function in gameCore.cs
What is the intent of the clientConnection.cs version of the function if it never gets called or when does it get called?

It wasn't apparent where this function gets called from but it is in T3D/gamebase/gameConnection.cpp
around line 339
argv[0] = "onConnect";
      for(U32 i = 0; i < mConnectArgc; i++)
         argv[i + 2] = mConnectArgv[i];
      // NOTE: Need to fallback to Con::execute() as IMPLEMENT_CALLBACK does not 
      // support variadic functions.
      Con::execute(this, mConnectArgc + 2, argv);
   }
I ran into this when I modified the clientConnection version of the function and found it had no effect. A bit confusing.
Any insight is appreciated.
Thanks!

About the author

Hobbyist working on a tank game when time allows. Play the prototype at => http://www.sytrept.com/60tons/


#1
08/15/2012 (10:08 am)
The onConnect() method within gameCore.cs overrides that of the one in clientConnection.cs -- if the gameCore version didn't exist then the 'core' version would execute when called. If I remember correctly I overrode it specifically because of changes to the playerList GUI.

Why didn't I just change the existing function? Because at the time GarageGames treated the 'core' directory as an external directory within their SVN repository and any changes within it would have been reflected across all projects. The override was specific to the FPS Genre Kit -- which eventually got reduced to the Full Template and FPS Example -- and wasn't necessary or useful for other projects.

Any function that exists within a package can be overridden or extended (parent calls) from a later package or child/inherited namespaces. This is useful but not always obvious behavior unless you know about it.