Show whole topic Jan 05, 2012 9:57 pm
Nix Offline
Mitglied
Registered since: Dec 17, 2007
Location: -


Subject: Re: Couple of questions
I made a similar function to GetNextVehicle (basically the "Next unit" button), that browses idle production buildings. Any hints how this could be merged to the "Next unit" button? I think I'll add an extra button for the time being Smiling

Quote:

//--------------------------------------------------
------------------------
/** Returns the next building that is in "waiting" status with empty queue -Nixx */
//--------------------------------------------------
------------------------
cBuilding *cPlayer::GetNextBuilding ()
{
    cBuilding *b, *start;
    bool next = false;
    if ( Client->gameGUI.getSelBuilding() && Client->gameGUI.getSelBuilding()->owner == this )
    {
        start = Client->gameGUI.getSelBuilding();
        next = true;
    }
    else
        start = BuildingList;

    if ( !start )
        return NULL;
    b = start;
    do
    {
        if ( !next && !b->IsWorking && b->BuildList)
            return b;
        next = false;
        if ( b->next )
            b = b->next;
        else
            b = BuildingList;
    }
    while ( b != start );
    return NULL;
}