Each function receives parameters and has access to global variables and functions. That is the only data on which it may operate or make decisions. Since this function is used to display hover text to the active player sitting at the computer, it makes sense to use the active team.
Code:
if (pPlot->isImpassable([B]GC.getGameINLINE().getActiveTeam()[/B]))
{
szString.append(NEWLINE);
szString.append(gDLL->getText("TXT_KEY_PLOT_IMPASSABLE"));
}
"getTeam()" works in CvUnit member functions because they can access CvUnit::getTeam() via the implied "this" pointer defined by every member function. A member function is a non-static function defined inside a "class <foo> { ... }" block. It must be called for a specific object of that class type.
Code:
if ([I]CvPlayerAI::getPlayer[/I]([I]CvGlobals::getInstance[/I]().[B]getGameINLINE[/B]().[B]getActivePlayer[/B]()).[B]isHuman[/B]())
...
The two
italic functions CvPlayerAI::getPlayer() and CvGlobals::getInstace() are static functions. These are essentially global functions that you can call without an object. The three
bold functions are member functions. CvGlobals::getInstance() returns the single CvGlobals object created by the game. Its getGameINLINE() function returns the current CvGame object whose getActivePlayer() function returns the active player ID tracked by the CvGame which is passed to CvPlayerAI::getPlayer() which returns a reference (like a pointer) to the CvPlayer object attached to the given ID. Finally, the reference is used to call its isHuman() member function.
To show the objects returned by each function, the above code could be rewritten verbosely as
Code:
CvGlobals& globals = [I]CvGlobals::getInstance[/I]();
CvGame& game = globals.[B]getGameINLINE[/B]();
PlayerTypes ePlayer = game.[B]getActivePlayer[/B]();
CvPlayer& player = [I]CvPlayerAI::getPlayer[/I](ePlayer);
if (player.[B]isHuman[/B]())
...
Inside every member function is an automatic local variable called "this" which is a pointer to the object that received the function call. You can use "this->" to reference any other member function or variable or omit it to let the compiler figure it out. In CvUnit::canMoveInto(), "getTeam()" becomes "this->getTeam()".
Since the CvGameTextMgr object (the game creates only one, but it could create any number of them just like CvPlayer and CvUnit) doesn't track any particular team or player, it doesn't define a getTeam() member function. This is why you need to come up with a team yourself, and the active team makes sense when it comes to hover text that will be displayed on-screen, always to the active player/team.