1 // 2 // SuperTuxKart - a fun racing game with go-kart 3 // Copyright (C) 2009-2015 Joerg Henrichs 4 // 5 // This program is free software; you can redistribute it and/or 6 // modify it under the terms of the GNU General Public License 7 // as published by the Free Software Foundation; either version 3 8 // of the License, or (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with this program; if not, write to the Free Software 17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 19 #ifndef HEADER_PROFILE_WORLD_HPP 20 #define HEADER_PROFILE_WORLD_HPP 21 22 #include "modes/standard_race.hpp" 23 24 class Kart; 25 26 /** 27 * \brief An implementation of World, used for profiling only 28 * \ingroup modes 29 */ 30 class ProfileWorld : public StandardRace 31 { 32 private: 33 /** Profiling modes. */ 34 enum ProfileType {PROFILE_NONE, PROFILE_TIME, PROFILE_LAPS}; 35 36 /** If profiling is done, and if so, which mode. */ 37 static ProfileType m_profile_mode; 38 39 /** In time based profiling only: time to run. */ 40 static float m_time; 41 42 /** Return value of real time at start of race. */ 43 unsigned int m_start_time; 44 45 /** Number of frames. For statistics only. */ 46 int m_frame_count; 47 48 /** Number of primitives drawn (in 1000). */ 49 long long m_num_triangles; 50 51 /** Number of culled triangles. */ 52 long long m_num_culls; 53 54 /** Numer of solid triangles drawn. */ 55 long long m_num_solid; 56 57 /** Number of transparent triangles drawn. */ 58 long long m_num_transparent; 59 60 /** Number of transparent effect triangles drawn. */ 61 long long m_num_trans_effect; 62 63 /** Number of calls to draw. */ 64 long long m_num_calls; 65 66 protected: 67 /** In laps based profiling: number of laps to run. Also 68 * used by DemoWorld. */ 69 static int m_num_laps; 70 71 virtual std::shared_ptr<AbstractKart> createKart 72 (const std::string &kart_ident, int index, int local_player_id, 73 int global_player_id, RaceManager::KartType type, 74 HandicapLevel handicap); 75 76 public: 77 ProfileWorld(); 78 virtual ~ProfileWorld(); 79 /** Returns identifier for this world. */ getInternalCode() const80 virtual std::string getInternalCode() const {return "PROFILE"; } 81 virtual void update(int ticks); 82 virtual bool isRaceOver(); 83 virtual void enterRaceOverState(); 84 85 static void setProfileModeTime(float time); 86 static void setProfileModeLaps(int laps); 87 // ------------------------------------------------------------------------ 88 /** Returns true if profile mode was selected. */ isProfileMode()89 static bool isProfileMode() {return m_profile_mode!=PROFILE_NONE; } 90 }; 91 92 #endif 93