- put a proper copyright to all replay-files
- changed name of class "Buffer" to "ReplayBuffer" .. "Buffer" at global scope was not a good idea of mine .. ;) git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1268 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
38d41f933c
commit
32b88d2091
@ -1,7 +1,7 @@
|
||||
// $Id: replay_base.cpp ikework $
|
||||
// $Id$
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2006 SuperTuxKart-Team
|
||||
// Copyright (C) 2007 Maik Semder <ikework@gmx.de>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
@ -17,32 +17,32 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifdef HAVE_GHOST_REPLAY
|
||||
|
||||
#include "replay_base.hpp"
|
||||
|
||||
|
||||
const std::string ReplayBase::REPLAY_FOLDER = "replay";
|
||||
const std::string ReplayBase::REPLAY_FILE_EXTENSION_HUMAN_READABLE = "rph";
|
||||
const std::string ReplayBase::REPLAY_FILE_EXTENSION_BINARY = "rpb";
|
||||
|
||||
|
||||
ReplayBase::ReplayBase()
|
||||
: m_ReplayBuffers()
|
||||
{
|
||||
}
|
||||
|
||||
ReplayBase::~ReplayBase()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
void ReplayBase::destroy()
|
||||
{
|
||||
m_ReplayBuffers.destroy();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // HAVE_GHOST_REPLAY
|
||||
#ifdef HAVE_GHOST_REPLAY
|
||||
|
||||
#include "replay_base.hpp"
|
||||
|
||||
|
||||
const std::string ReplayBase::REPLAY_FOLDER = "replay";
|
||||
const std::string ReplayBase::REPLAY_FILE_EXTENSION_HUMAN_READABLE = "rph";
|
||||
const std::string ReplayBase::REPLAY_FILE_EXTENSION_BINARY = "rpb";
|
||||
|
||||
|
||||
ReplayBase::ReplayBase()
|
||||
: m_ReplayBuffers()
|
||||
{
|
||||
}
|
||||
|
||||
ReplayBase::~ReplayBase()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
void ReplayBase::destroy()
|
||||
{
|
||||
m_ReplayBuffers.destroy();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // HAVE_GHOST_REPLAY
|
||||
|
@ -1,7 +1,7 @@
|
||||
// $Id$
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2007 Damien Morel <divdams@free.fr>
|
||||
// Copyright (C) 2007 Maik Semder <ikework@gmx.de>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
|
@ -1,7 +1,7 @@
|
||||
// $Id$
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2007 Damien Morel <divdams@free.fr>
|
||||
// Copyright (C) 2007 Maik Semder <ikework@gmx.de>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
@ -42,20 +42,20 @@
|
||||
#endif
|
||||
|
||||
|
||||
template<typename T> class BufferArray;
|
||||
template<typename T> class ReplayBufferArray;
|
||||
|
||||
template<typename T>
|
||||
class Buffer
|
||||
class ReplayBuffer
|
||||
{
|
||||
friend class BufferArray<T>;
|
||||
friend class ReplayBufferArray<T>;
|
||||
|
||||
public:
|
||||
Buffer() : m_pp_blocks(NULL),m_number_blocks(0),m_block_size(0),m_number_objects_used(0),m_healthy(true) {}
|
||||
~Buffer() { destroy(); }
|
||||
ReplayBuffer() : m_pp_blocks(NULL),m_number_blocks(0),m_block_size(0),m_number_objects_used(0),m_healthy(true) {}
|
||||
~ReplayBuffer() { destroy(); }
|
||||
|
||||
private:
|
||||
Buffer( Buffer<T> const &c );
|
||||
Buffer<T> const &operator=( Buffer<T> const &c );
|
||||
ReplayBuffer( ReplayBuffer<T> const &c );
|
||||
ReplayBuffer<T> const &operator=( ReplayBuffer<T> const &c );
|
||||
|
||||
public:
|
||||
bool init( size_t number_preallocated_objects );
|
||||
@ -103,14 +103,14 @@ private:
|
||||
};
|
||||
|
||||
|
||||
// does the same as Buffer<T>, but it returns an array of objects, rather than just one
|
||||
// does the same as ReplayBuffer<T>, but it returns an array of objects, rather than just one
|
||||
// object ..
|
||||
template<typename T>
|
||||
class BufferArray
|
||||
class ReplayBufferArray
|
||||
{
|
||||
public:
|
||||
BufferArray() : m_Buffer(), m_array_size(0) {}
|
||||
~BufferArray() { destroy(); }
|
||||
ReplayBufferArray() : m_Buffer(), m_array_size(0) {}
|
||||
~ReplayBufferArray() { destroy(); }
|
||||
|
||||
void destroy();
|
||||
bool init( size_t number_preallocated_arrays, size_t array_size );
|
||||
@ -125,15 +125,15 @@ public:
|
||||
bool isHealthy() const { return m_Buffer.isHealthy(); }
|
||||
|
||||
private:
|
||||
Buffer<T> m_Buffer;
|
||||
size_t m_array_size;
|
||||
ReplayBuffer<T> m_Buffer;
|
||||
size_t m_array_size;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T>
|
||||
bool Buffer<T>::init( size_t number_preallocated_objects )
|
||||
bool ReplayBuffer<T>::init( size_t number_preallocated_objects )
|
||||
{
|
||||
// make sure *clean* usage
|
||||
assert( !m_pp_blocks );
|
||||
@ -146,7 +146,7 @@ bool Buffer<T>::init( size_t number_preallocated_objects )
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Buffer<T>::destroy()
|
||||
void ReplayBuffer<T>::destroy()
|
||||
{
|
||||
size_t tmp;
|
||||
if( m_pp_blocks )
|
||||
@ -163,7 +163,7 @@ void Buffer<T>::destroy()
|
||||
// returns a new *free* frame to be used to store the current frame-data into it
|
||||
// used to *record* the replay
|
||||
template<typename T>
|
||||
T* Buffer<T>::getNewObject()
|
||||
T* ReplayBuffer<T>::getNewObject()
|
||||
{
|
||||
// make sure initialization was called properly
|
||||
assert( m_pp_blocks );
|
||||
@ -191,7 +191,7 @@ T* Buffer<T>::getNewObject()
|
||||
// returs frame at given position from replay data
|
||||
// used to *show* the replay
|
||||
template<typename T>
|
||||
T const* Buffer<T>::getObjectAt( size_t index ) const
|
||||
T const* ReplayBuffer<T>::getObjectAt( size_t index ) const
|
||||
{
|
||||
// make sure initialization was called properly
|
||||
assert( m_pp_blocks );
|
||||
@ -204,7 +204,7 @@ T const* Buffer<T>::getObjectAt( size_t index ) const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T* Buffer<T>::getObjectAt( size_t index )
|
||||
T* ReplayBuffer<T>::getObjectAt( size_t index )
|
||||
{
|
||||
// make sure initialization was called properly
|
||||
assert( m_pp_blocks );
|
||||
@ -218,7 +218,7 @@ T* Buffer<T>::getObjectAt( size_t index )
|
||||
|
||||
// adds a new block of objects to m_pp_blocks with a size of m_block_size
|
||||
template<typename T>
|
||||
bool Buffer<T>::addNewBlock()
|
||||
bool ReplayBuffer<T>::addNewBlock()
|
||||
{
|
||||
assert( m_block_size );
|
||||
|
||||
@ -261,14 +261,14 @@ bool Buffer<T>::addNewBlock()
|
||||
|
||||
|
||||
template<typename T>
|
||||
void BufferArray<T>::destroy()
|
||||
void ReplayBufferArray<T>::destroy()
|
||||
{
|
||||
m_Buffer.destroy();
|
||||
m_array_size = 0;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool BufferArray<T>::init( size_t number_preallocated_arrays, size_t array_size )
|
||||
bool ReplayBufferArray<T>::init( size_t number_preallocated_arrays, size_t array_size )
|
||||
{
|
||||
assert( number_preallocated_arrays );
|
||||
assert( array_size );
|
||||
@ -278,7 +278,7 @@ bool BufferArray<T>::init( size_t number_preallocated_arrays, size_t array_size
|
||||
|
||||
// returns a new *free* array of objects
|
||||
template<typename T>
|
||||
T* BufferArray<T>::getNewArray()
|
||||
T* ReplayBufferArray<T>::getNewArray()
|
||||
{
|
||||
if( !isHealthy() ) return NULL;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
// $Id: replay_buffers.cpp ikework $
|
||||
// $Id$
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2006 SuperTuxKart-Team
|
||||
// Copyright (C) 2007 Maik Semder <ikework@gmx.de>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
|
@ -1,7 +1,7 @@
|
||||
// $Id$
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2007 Damien Morel <divdams@free.fr>
|
||||
// Copyright (C) 2007 Maik Semder <ikework@gmx.de>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
@ -63,8 +63,8 @@ private:
|
||||
bool isHealthy() const { return m_BufferFrame.isHealthy() && m_BufferKartState.isHealthy(); }
|
||||
|
||||
private:
|
||||
typedef Buffer<ReplayFrame> BufferFrame;
|
||||
typedef BufferArray<ReplayKartState> BufferKartState;
|
||||
typedef ReplayBuffer<ReplayFrame> BufferFrame;
|
||||
typedef ReplayBufferArray<ReplayKartState> BufferKartState;
|
||||
|
||||
unsigned int m_number_karts;
|
||||
BufferFrame m_BufferFrame;
|
||||
|
@ -1,7 +1,7 @@
|
||||
// $Id: replay_player.cpp ikework $
|
||||
// $Id$
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2006 SuperTuxKart-Team
|
||||
// Copyright (C) 2007 Maik Semder <ikework@gmx.de>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
|
@ -1,7 +1,7 @@
|
||||
// $Id: $
|
||||
// $Id$
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2007 Damien Morel <divdams@free.fr>
|
||||
// Copyright (C) 2007 Maik Semder <ikework@gmx.de>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
|
@ -1,7 +1,7 @@
|
||||
// $Id: replay_recorder.cpp ikework $
|
||||
// $Id$
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2006 SuperTuxKart-Team
|
||||
// Copyright (C) 2007 Maik Semder <ikework@gmx.de>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
@ -17,41 +17,41 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifdef HAVE_GHOST_REPLAY
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "replay_recorder.hpp"
|
||||
#include "world.hpp"
|
||||
|
||||
const float ReplayRecorder::REPLAY_TIME_STEP_MIN = 1.0f / (float)ReplayRecorder::REPLAY_FREQUENCY_MAX;
|
||||
|
||||
ReplayRecorder::ReplayRecorder()
|
||||
: ReplayBase()
|
||||
{
|
||||
}
|
||||
|
||||
ReplayRecorder::~ReplayRecorder()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
void ReplayRecorder::destroy()
|
||||
{
|
||||
ReplayBase::destroy();
|
||||
}
|
||||
|
||||
bool ReplayRecorder::initRecorder( unsigned int number_karts, size_t number_preallocated_frames )
|
||||
{
|
||||
assert( number_karts );
|
||||
|
||||
destroy();
|
||||
|
||||
if( !m_ReplayBuffers.init( number_karts, number_preallocated_frames ) ) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GHOST_REPLAY
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "replay_recorder.hpp"
|
||||
#include "world.hpp"
|
||||
|
||||
const float ReplayRecorder::REPLAY_TIME_STEP_MIN = 1.0f / (float)ReplayRecorder::REPLAY_FREQUENCY_MAX;
|
||||
|
||||
ReplayRecorder::ReplayRecorder()
|
||||
: ReplayBase()
|
||||
{
|
||||
}
|
||||
|
||||
ReplayRecorder::~ReplayRecorder()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
void ReplayRecorder::destroy()
|
||||
{
|
||||
ReplayBase::destroy();
|
||||
}
|
||||
|
||||
bool ReplayRecorder::initRecorder( unsigned int number_karts, size_t number_preallocated_frames )
|
||||
{
|
||||
assert( number_karts );
|
||||
|
||||
destroy();
|
||||
|
||||
if( !m_ReplayBuffers.init( number_karts, number_preallocated_frames ) ) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ReplayRecorder::pushFrame()
|
||||
{
|
||||
// we dont record the startphase ..
|
||||
@ -80,6 +80,6 @@ bool ReplayRecorder::pushFrame()
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#endif // HAVE_GHOST_REPLAY
|
||||
|
||||
|
||||
#endif // HAVE_GHOST_REPLAY
|
||||
|
@ -1,7 +1,7 @@
|
||||
// $Id$
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2007 Damien Morel <divdams@free.fr>
|
||||
// Copyright (C) 2007 Maik Semder <ikework@gmx.de>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
|
Loading…
Reference in New Issue
Block a user