2010-09-02 09:14:07 -04:00
|
|
|
// SuperTuxKart - a fun racing game with go-kart
|
|
|
|
// Copyright (C) 2010 Joerg Henrichs
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation; either version 3
|
|
|
|
// of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
#ifndef HEADER_WORLD_WITH_RANK_HPP
|
|
|
|
#define HEADER_WORLD_WITH_RANK_HPP
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "modes/world.hpp"
|
|
|
|
|
2012-03-19 16:21:11 -04:00
|
|
|
class AbstractKart;
|
|
|
|
|
2010-09-02 09:14:07 -04:00
|
|
|
/**
|
|
|
|
* A WorldWithRank is a world where the karts are ranked. This is the base
|
|
|
|
* class for races and battle modes - all of which rank the kart.
|
2010-09-10 01:16:52 -04:00
|
|
|
* A class using this as a subclass must call setKartPosition(kart id, position)
|
2010-09-02 09:14:07 -04:00
|
|
|
* and this class is used to access the ranks from other objects.
|
|
|
|
* \ingroup modes
|
|
|
|
*/
|
|
|
|
class WorldWithRank : public World
|
|
|
|
{
|
2010-12-19 20:19:05 -05:00
|
|
|
protected:
|
2010-09-02 09:14:07 -04:00
|
|
|
/** This contains a mapping from race position to kart index. */
|
|
|
|
std::vector<int> m_position_index;
|
2010-09-05 10:05:59 -04:00
|
|
|
|
2010-12-19 20:19:05 -05:00
|
|
|
/** Whether to display the rank in the race GUI */
|
|
|
|
bool m_display_rank;
|
|
|
|
|
2010-09-05 10:05:59 -04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/** Used for debugging to help detect if the same kart position
|
|
|
|
* is used more than once. */
|
|
|
|
std::vector<bool> m_position_used;
|
|
|
|
|
|
|
|
/** True if beginSetKartPositions was called, false after
|
|
|
|
* endSetKartPositions. Used to make sure the sequence of calls
|
|
|
|
* is correct. */
|
|
|
|
bool m_position_setting_initialised;
|
|
|
|
#endif
|
|
|
|
|
2010-09-02 09:14:07 -04:00
|
|
|
public:
|
|
|
|
WorldWithRank() : World() {}
|
|
|
|
/** call just after instanciating. can't be moved to the contructor as child
|
|
|
|
classes must be instanciated, otherwise polymorphism will fail and the
|
|
|
|
results will be incorrect */
|
|
|
|
virtual void init();
|
|
|
|
|
2010-12-19 20:19:05 -05:00
|
|
|
bool displayRank() const { return m_display_rank; }
|
|
|
|
|
2010-09-05 10:05:59 -04:00
|
|
|
void beginSetKartPositions();
|
|
|
|
bool setKartPosition(unsigned int kart_id,
|
2010-09-02 09:14:07 -04:00
|
|
|
unsigned int position);
|
2010-09-05 10:05:59 -04:00
|
|
|
void endSetKartPositions();
|
|
|
|
|
2012-03-19 16:21:11 -04:00
|
|
|
AbstractKart* getKartAtPosition(unsigned int p) const;
|
2010-09-05 10:05:59 -04:00
|
|
|
}; // WorldWithRank
|
2010-09-02 09:14:07 -04:00
|
|
|
|
|
|
|
#endif
|