(SDK) What is GET_PLAYER actually returning?

Discussion in 'Civ4 - SDK/Python' started by isau, Oct 21, 2007.

  1. isau

    isau Deity

    Joined:
    Jan 15, 2007
    Messages:
    3,071
    I'm not a C++ guy, so some help is appreciated. :)

    The more I look at it, the more GET_PLAYER confuses me. It seems to return an instance of CvPlayerAI, but most of the public methods available to CvPlayerAI can't be used with GET_PLAYER. For example:

    Code:
    GET_PLAYER( GC.getGame().getActivePlayer() ).getCanDoCivics(eCivic)
    ..throws an error similar to "getCanDoCivics is not a member of CvPlayerAI." I know I must be missing something super obvious, but after a few hours of looking at this I'm not any closer to an answer. Can someone help me out?

    -isau
     
  2. PeteT

    PeteT Warlord

    Joined:
    Jan 2, 2002
    Messages:
    273
    Location:
    Winterpeg
    Where did "getCanDoCivics" come from? I can't find it in the version I have.
     
  3. Kalimakhus

    Kalimakhus Emperor

    Joined:
    May 8, 2007
    Messages:
    1,249
    @isau
    The function should be canDoCivics(eCivic)

    GET_PLAYER is a macro. A macro in C++ is like an alias. If you look in the file CvPlayerAI.h line #425 you will see this:

    #define GET_PLAYER CvPlayerAI::getPlayer

    This means that every time GET_PLAYER is found it is replaced with CvPlayerAI::getPlayer. You don't need to know more details unless you actually want to learn C++.
     
  4. isau

    isau Deity

    Joined:
    Jan 15, 2007
    Messages:
    3,071
    Lol ok I got you.

    This is embaressing but the problem is that I was typing getCanDoCivics instead of canDoCivics. 10 hours of programming baked me I guess. I was thinking maybe C++ differed radically from C# in how it does inheritance... lol anyway it works now. Thank you both so much for replying.

    --isau
     

Share This Page