Back to index

supertuxkart  0.5+dfsg1
replay_recorder.hpp
Go to the documentation of this file.
00001 //  $Id$
00002 //
00003 //  SuperTuxKart - a fun racing game with go-kart
00004 //  Copyright (C) 2007 Maik Semder <ikework@gmx.de>
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 #ifndef HEADER_REPLAYRECORDER_H
00021 #define HEADER_REPLAYRECORDER_H
00022 
00023 #ifdef HAVE_GHOST_REPLAY
00024 
00025 #include "replay_base.hpp"
00026 
00027 
00028 // class managing:
00029 //      - the recording of the replay
00030 //      - the serializing to file
00031 class ReplayRecorder : public ReplayBase
00032 {
00033 private:
00034     // assuming 10 minutes with 50 frames per second
00035     enum { BUFFER_PREALLOCATE_FRAMES = 10 * 50 * 60, };
00036     enum { REPLAY_FREQUENCY_MAX = 30 };
00037     // calculated from REPLAY_FREQUENCY_MAX
00038     static const float  REPLAY_TIME_STEP_MIN;
00039 
00040 public:
00041     ReplayRecorder();
00042     virtual ~ReplayRecorder();
00043 
00044     void            destroy();
00045     bool            initRecorder( unsigned int number_karts, 
00046                                   size_t number_preallocated_frames = BUFFER_PREALLOCATE_FRAMES );
00047 
00048     // something might go wrong, since a new buffer may be allocated, so false means
00049     // no memory available
00050     bool            pushFrame();
00051 
00052 private:
00053     // returns a new *free* frame to be used to store the current frame-data into it
00054     // used to *record* the replay
00055     ReplayFrame*    getNewFrame() { return m_ReplayBuffers.getNewFrame(); }
00056 };
00057 
00058 
00059 
00060 #endif // HAVE_GHOST_REPLAY
00061 
00062 #endif // HEADER_REPLAYRECORDER_H
00063