2007-05-27 12:01:53 -04:00
|
|
|
// $Id$
|
|
|
|
//
|
|
|
|
// SuperTuxKart - a fun racing game with go-kart
|
|
|
|
// Copyright (C) 2004 SuperTuxKart-Team
|
|
|
|
//
|
|
|
|
// 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 2
|
|
|
|
// 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_H
|
|
|
|
#define HEADER_WORLD_H
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <plib/ssg.h>
|
|
|
|
#include "track.hpp"
|
|
|
|
#include "player_kart.hpp"
|
|
|
|
#include "physics.hpp"
|
|
|
|
#include "kart.hpp"
|
|
|
|
#include "highscores.hpp"
|
2007-09-19 05:23:02 -04:00
|
|
|
#ifdef HAVE_GHOST_REPLAY
|
|
|
|
# include "replay_recorder.hpp"
|
|
|
|
class ReplayPlayer;
|
|
|
|
#endif
|
2007-05-27 12:01:53 -04:00
|
|
|
|
|
|
|
/** This class keeps all the state of a race, scenegraph, time,
|
|
|
|
etc. */
|
|
|
|
class World
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef std::vector<Kart*> Karts;
|
|
|
|
|
|
|
|
/** resources, this should be put in a separate class or replaced by a smart
|
|
|
|
* resource manager
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum Phase {
|
2008-02-12 20:02:02 -05:00
|
|
|
// Game setup, e.g. track loading
|
|
|
|
SETUP_PHASE,
|
|
|
|
// 'Ready' is displayed
|
|
|
|
READY_PHASE,
|
|
|
|
// 'Set' is displayed
|
|
|
|
SET_PHASE,
|
|
|
|
// 'Go' is displayed, but this is already race phase
|
|
|
|
GO_PHASE,
|
|
|
|
// the actual race has started, no ready/set/go is displayed anymore
|
2007-05-27 12:01:53 -04:00
|
|
|
RACE_PHASE,
|
|
|
|
// All players have finished, now wait a certain amount of time for AI
|
|
|
|
// karts to finish. If they do not finish in that time, finish the race
|
|
|
|
DELAY_FINISH_PHASE,
|
|
|
|
// The player crossed the finishing line and his and the time of
|
|
|
|
// the other players is displayed, controll is automatic
|
|
|
|
FINISH_PHASE,
|
|
|
|
// The state after finish where no calculations are done.
|
|
|
|
LIMBO_PHASE,
|
|
|
|
};
|
|
|
|
|
2007-09-25 23:43:02 -04:00
|
|
|
Track* m_track;
|
2007-05-27 12:01:53 -04:00
|
|
|
|
|
|
|
/** debug text that will be overlaid to the screen */
|
|
|
|
std::string m_debug_text[10];
|
|
|
|
|
1) Removed race_setup and race_mode data structures. All this
information is now only managed by the race_manager, no
more in-between objects to transfer information along.
2) The scores for grand prix are now defined in the stk_config.dat
file (10, 8, 6, 5, 4, .., 1, 0, 0) points
3) Bugfix: unlock information wasn't saved anymore. Added specific
saving after unlocking, plus re-inserted the 'generic' save
at the end of STK again.
4) bugfix/work around: Visual Studio complains about incompatible
iterators in sdldrv - apparently caused by using erase, and
then keep on using the iterator.
5) Fixed bug when running a race in a GP again (scores/times
were added each time).
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1681 178a84e3-b1eb-0310-8ba1-8eac791a3b58
2008-04-09 09:52:48 -04:00
|
|
|
World();
|
2008-01-29 23:55:11 -05:00
|
|
|
virtual ~World();
|
|
|
|
void update(float delta);
|
2008-02-13 21:24:54 -05:00
|
|
|
// Note: GO_PHASE is both: start phase and race phase
|
2008-02-12 22:40:31 -05:00
|
|
|
bool isStartPhase() const {return m_phase<GO_PHASE;}
|
2008-02-13 21:24:54 -05:00
|
|
|
bool isRacePhase() const {return m_phase>=GO_PHASE && m_phase<LIMBO_PHASE;}
|
2008-01-29 23:55:11 -05:00
|
|
|
void restartRace();
|
|
|
|
void disableRace(); // Put race into limbo phase
|
2007-05-27 12:01:53 -04:00
|
|
|
|
1) Removed race_setup and race_mode data structures. All this
information is now only managed by the race_manager, no
more in-between objects to transfer information along.
2) The scores for grand prix are now defined in the stk_config.dat
file (10, 8, 6, 5, 4, .., 1, 0, 0) points
3) Bugfix: unlock information wasn't saved anymore. Added specific
saving after unlocking, plus re-inserted the 'generic' save
at the end of STK again.
4) bugfix/work around: Visual Studio complains about incompatible
iterators in sdldrv - apparently caused by using erase, and
then keep on using the iterator.
5) Fixed bug when running a race in a GP again (scores/times
were added each time).
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1681 178a84e3-b1eb-0310-8ba1-8eac791a3b58
2008-04-09 09:52:48 -04:00
|
|
|
PlayerKart* getPlayerKart(int player) const
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
1) Removed race_setup and race_mode data structures. All this
information is now only managed by the race_manager, no
more in-between objects to transfer information along.
2) The scores for grand prix are now defined in the stk_config.dat
file (10, 8, 6, 5, 4, .., 1, 0, 0) points
3) Bugfix: unlock information wasn't saved anymore. Added specific
saving after unlocking, plus re-inserted the 'generic' save
at the end of STK again.
4) bugfix/work around: Visual Studio complains about incompatible
iterators in sdldrv - apparently caused by using erase, and
then keep on using the iterator.
5) Fixed bug when running a race in a GP again (scores/times
were added each time).
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1681 178a84e3-b1eb-0310-8ba1-8eac791a3b58
2008-04-09 09:52:48 -04:00
|
|
|
return m_player_karts[player];
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1) Removed race_setup and race_mode data structures. All this
information is now only managed by the race_manager, no
more in-between objects to transfer information along.
2) The scores for grand prix are now defined in the stk_config.dat
file (10, 8, 6, 5, 4, .., 1, 0, 0) points
3) Bugfix: unlock information wasn't saved anymore. Added specific
saving after unlocking, plus re-inserted the 'generic' save
at the end of STK again.
4) bugfix/work around: Visual Studio complains about incompatible
iterators in sdldrv - apparently caused by using erase, and
then keep on using the iterator.
5) Fixed bug when running a race in a GP again (scores/times
were added each time).
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1681 178a84e3-b1eb-0310-8ba1-8eac791a3b58
2008-04-09 09:52:48 -04:00
|
|
|
Kart* getKart(int kartId) const
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
|
|
|
assert(kartId >= 0 &&
|
|
|
|
kartId < int(m_kart.size()));
|
|
|
|
return m_kart[kartId];
|
|
|
|
}
|
1) Removed race_setup and race_mode data structures. All this
information is now only managed by the race_manager, no
more in-between objects to transfer information along.
2) The scores for grand prix are now defined in the stk_config.dat
file (10, 8, 6, 5, 4, .., 1, 0, 0) points
3) Bugfix: unlock information wasn't saved anymore. Added specific
saving after unlocking, plus re-inserted the 'generic' save
at the end of STK again.
4) bugfix/work around: Visual Studio complains about incompatible
iterators in sdldrv - apparently caused by using erase, and
then keep on using the iterator.
5) Fixed bug when running a race in a GP again (scores/times
were added each time).
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1681 178a84e3-b1eb-0310-8ba1-8eac791a3b58
2008-04-09 09:52:48 -04:00
|
|
|
unsigned int getNumKarts() const {return (int)m_kart.size(); }
|
|
|
|
unsigned int getNumPlayers() const {return (unsigned int)m_player_karts.size();}
|
2007-05-27 12:01:53 -04:00
|
|
|
|
|
|
|
/** Returns the phase of the game */
|
|
|
|
Phase getPhase() const { return m_phase; }
|
|
|
|
Physics *getPhysics() const { return m_physics; }
|
2007-11-08 07:31:54 -05:00
|
|
|
Track *getTrack() const { return m_track; }
|
2007-05-27 12:01:53 -04:00
|
|
|
Kart* getFastestKart() const { return m_fastest_kart; }
|
|
|
|
float getFastestLapTime() const { return m_fastest_lap; }
|
|
|
|
void setFastestLap(Kart *k, float time) {m_fastest_kart=k;m_fastest_lap=time;}
|
|
|
|
const Highscores* getHighscores() const { return m_highscores; }
|
2008-02-07 23:43:35 -05:00
|
|
|
float getTime() const { return m_clock; }
|
2007-06-09 21:13:39 -04:00
|
|
|
|
|
|
|
void pause();
|
|
|
|
void unpause();
|
2008-02-12 20:02:02 -05:00
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
private:
|
|
|
|
Karts m_kart;
|
1) Removed race_setup and race_mode data structures. All this
information is now only managed by the race_manager, no
more in-between objects to transfer information along.
2) The scores for grand prix are now defined in the stk_config.dat
file (10, 8, 6, 5, 4, .., 1, 0, 0) points
3) Bugfix: unlock information wasn't saved anymore. Added specific
saving after unlocking, plus re-inserted the 'generic' save
at the end of STK again.
4) bugfix/work around: Visual Studio complains about incompatible
iterators in sdldrv - apparently caused by using erase, and
then keep on using the iterator.
5) Fixed bug when running a race in a GP again (scores/times
were added each time).
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1681 178a84e3-b1eb-0310-8ba1-8eac791a3b58
2008-04-09 09:52:48 -04:00
|
|
|
std::vector<PlayerKart*> m_player_karts;
|
2007-05-27 12:01:53 -04:00
|
|
|
float m_finish_delay_start_time;
|
|
|
|
Physics* m_physics;
|
|
|
|
float m_fastest_lap;
|
|
|
|
Kart* m_fastest_kart;
|
|
|
|
Highscores* m_highscores;
|
|
|
|
Phase m_phase;
|
2008-02-07 23:43:35 -05:00
|
|
|
float m_clock;
|
2007-05-27 12:01:53 -04:00
|
|
|
|
|
|
|
void updateRacePosition( int k );
|
|
|
|
void loadTrack();
|
2008-02-12 20:02:02 -05:00
|
|
|
void updateRaceStatus(float dt);
|
2007-05-27 12:01:53 -04:00
|
|
|
void resetAllKarts();
|
1) Removed race_setup and race_mode data structures. All this
information is now only managed by the race_manager, no
more in-between objects to transfer information along.
2) The scores for grand prix are now defined in the stk_config.dat
file (10, 8, 6, 5, 4, .., 1, 0, 0) points
3) Bugfix: unlock information wasn't saved anymore. Added specific
saving after unlocking, plus re-inserted the 'generic' save
at the end of STK again.
4) bugfix/work around: Visual Studio complains about incompatible
iterators in sdldrv - apparently caused by using erase, and
then keep on using the iterator.
5) Fixed bug when running a race in a GP again (scores/times
were added each time).
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1681 178a84e3-b1eb-0310-8ba1-8eac791a3b58
2008-04-09 09:52:48 -04:00
|
|
|
Kart* loadRobot(const std::string& kart_name, int position,
|
|
|
|
sgCoord init_pos);
|
2007-09-19 05:23:02 -04:00
|
|
|
|
|
|
|
#ifdef HAVE_GHOST_REPLAY
|
2007-09-21 14:02:53 -04:00
|
|
|
private:
|
|
|
|
bool saveReplayHumanReadable( std::string const &filename ) const;
|
|
|
|
bool loadReplayHumanReadable( std::string const &filename );
|
2007-09-19 05:23:02 -04:00
|
|
|
|
|
|
|
ReplayRecorder m_replay_recorder;
|
|
|
|
ReplayPlayer *m_p_replay_player;
|
|
|
|
#endif
|
2007-09-21 14:02:53 -04:00
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
extern World* world;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* EOF */
|