Applied changes from statistics branch to trunk (r9413 - r9484).

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9503 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2011-08-15 02:00:50 +00:00
parent 8a9bdc1505
commit 2172f1c4df
8 changed files with 2390 additions and 2272 deletions

View File

@ -36,6 +36,7 @@
#include "items/projectile_manager.hpp" #include "items/projectile_manager.hpp"
#include "karts/kart_properties_manager.hpp" #include "karts/kart_properties_manager.hpp"
#include "main_loop.hpp" #include "main_loop.hpp"
#include "modes/profile_world.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "states_screens/dialogs/confirm_resolution_dialog.hpp" #include "states_screens/dialogs/confirm_resolution_dialog.hpp"
#include "states_screens/state_manager.hpp" #include "states_screens/state_manager.hpp"
@ -83,6 +84,13 @@ IrrDriver::~IrrDriver()
void IrrDriver::initDevice() void IrrDriver::initDevice()
{ {
// If --no-graphics option was used, just create a device with NULL renderer
if (ProfileWorld::isNoGraphics())
{
m_device = createDevice(video::EDT_NULL);
}
else
{
static bool firstTime = true; static bool firstTime = true;
// ---- the first time, get a list of available video modes // ---- the first time, get a list of available video modes
@ -218,6 +226,7 @@ void IrrDriver::initDevice()
fprintf(stderr, "An invalid resolution was set in the config file, reverting to saner values\n"); fprintf(stderr, "An invalid resolution was set in the config file, reverting to saner values\n");
} }
} }
}
if(!m_device) if(!m_device)
{ {
@ -225,26 +234,31 @@ void IrrDriver::initDevice()
exit(-1); exit(-1);
} }
m_device->setResizable(false); m_scene_manager = m_device->getSceneManager();
m_gui_env = m_device->getGUIEnvironment();
m_video_driver = m_device->getVideoDriver();
// Only change video driver settings if we are showing graphics
if (!ProfileWorld::isNoGraphics()) {
m_device->setResizable(false);
m_device->setWindowCaption(L"SuperTuxKart");
m_device->getVideoDriver()
->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
m_device->getVideoDriver()
->setTextureCreationFlag(video::ETCF_OPTIMIZED_FOR_QUALITY, true);
if (!UserConfigParams::m_fbo) if (!UserConfigParams::m_fbo)
{ {
m_device->getVideoDriver()->disableFeature(EVDF_FRAMEBUFFER_OBJECT); m_device->getVideoDriver()->disableFeature(EVDF_FRAMEBUFFER_OBJECT);
} }
// Stores the new file system pointer.
file_manager->setDevice(m_device);
m_device->setWindowCaption(L"SuperTuxKart");
m_scene_manager = m_device->getSceneManager();
// Force creation of mipmaps even if the mipmaps flag in a b3d file // Force creation of mipmaps even if the mipmaps flag in a b3d file
// does not set the 'enable mipmap' flag. // does not set the 'enable mipmap' flag.
m_scene_manager->getParameters() m_scene_manager->getParameters()
->setAttribute(scene::B3D_LOADER_IGNORE_MIPMAP_FLAG, true); ->setAttribute(scene::B3D_LOADER_IGNORE_MIPMAP_FLAG, true);
m_device->getVideoDriver()->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS,true); }
m_device->getVideoDriver()->setTextureCreationFlag(video::ETCF_OPTIMIZED_FOR_QUALITY,true);
m_gui_env = m_device->getGUIEnvironment(); // Stores the new file system pointer.
m_video_driver = m_device->getVideoDriver(); file_manager->setDevice(m_device);
// Initialize material2D // Initialize material2D
video::SMaterial& material2D = m_video_driver->getMaterial2D(); video::SMaterial& material2D = m_video_driver->getMaterial2D();

View File

@ -121,6 +121,7 @@
<ClCompile Include="..\..\guiengine\widgets\CGUIEditBox.cpp" /> <ClCompile Include="..\..\guiengine\widgets\CGUIEditBox.cpp" />
<ClCompile Include="..\..\items\rubber_ball.cpp" /> <ClCompile Include="..\..\items\rubber_ball.cpp" />
<ClCompile Include="..\..\items\swatter.cpp" /> <ClCompile Include="..\..\items\swatter.cpp" />
<ClCompile Include="..\..\karts\kart_with_stats.cpp" />
<ClCompile Include="..\..\main.cpp" /> <ClCompile Include="..\..\main.cpp" />
<ClCompile Include="..\..\main_loop.cpp" /> <ClCompile Include="..\..\main_loop.cpp" />
<ClCompile Include="..\..\guiengine\abstract_state_manager.cpp" /> <ClCompile Include="..\..\guiengine\abstract_state_manager.cpp" />
@ -167,6 +168,7 @@
<ClCompile Include="..\..\tinygettext\po_parser.cpp" /> <ClCompile Include="..\..\tinygettext\po_parser.cpp" />
<ClCompile Include="..\..\tinygettext\stk_file_system.cpp" /> <ClCompile Include="..\..\tinygettext\stk_file_system.cpp" />
<ClCompile Include="..\..\tinygettext\tinygettext.cpp" /> <ClCompile Include="..\..\tinygettext\tinygettext.cpp" />
<ClCompile Include="..\..\tracks\track_sector.cpp" />
<ClCompile Include="..\..\utils\constants.cpp" /> <ClCompile Include="..\..\utils\constants.cpp" />
<ClCompile Include="..\..\utils\profiler.cpp" /> <ClCompile Include="..\..\utils\profiler.cpp" />
<ClCompile Include="..\..\utils\random_generator.cpp" /> <ClCompile Include="..\..\utils\random_generator.cpp" />
@ -337,6 +339,7 @@
<ClInclude Include="..\..\guiengine\widgets\CGUIEditBox.h" /> <ClInclude Include="..\..\guiengine\widgets\CGUIEditBox.h" />
<ClInclude Include="..\..\items\rubber_ball.hpp" /> <ClInclude Include="..\..\items\rubber_ball.hpp" />
<ClInclude Include="..\..\items\swatter.hpp" /> <ClInclude Include="..\..\items\swatter.hpp" />
<ClInclude Include="..\..\karts\kart_with_stats.hpp" />
<ClInclude Include="..\..\main_loop.hpp" /> <ClInclude Include="..\..\main_loop.hpp" />
<ClInclude Include="..\..\guiengine\abstract_state_manager.hpp" /> <ClInclude Include="..\..\guiengine\abstract_state_manager.hpp" />
<ClInclude Include="..\..\guiengine\abstract_top_level_container.hpp" /> <ClInclude Include="..\..\guiengine\abstract_top_level_container.hpp" />
@ -397,6 +400,7 @@
<ClInclude Include="..\..\tinygettext\po_parser.hpp" /> <ClInclude Include="..\..\tinygettext\po_parser.hpp" />
<ClInclude Include="..\..\tinygettext\stk_file_system.hpp" /> <ClInclude Include="..\..\tinygettext\stk_file_system.hpp" />
<ClInclude Include="..\..\tinygettext\tinygettext.hpp" /> <ClInclude Include="..\..\tinygettext\tinygettext.hpp" />
<ClInclude Include="..\..\tracks\track_sector.hpp" />
<ClInclude Include="..\..\utils\constants.hpp" /> <ClInclude Include="..\..\utils\constants.hpp" />
<ClInclude Include="..\..\utils\no_copy.hpp" /> <ClInclude Include="..\..\utils\no_copy.hpp" />
<ClInclude Include="..\..\utils\profiler.hpp" /> <ClInclude Include="..\..\utils\profiler.hpp" />

View File

@ -792,6 +792,12 @@
<ClCompile Include="..\..\graphics\post_processing.cpp"> <ClCompile Include="..\..\graphics\post_processing.cpp">
<Filter>Quelldateien\graphics</Filter> <Filter>Quelldateien\graphics</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\karts\kart_with_stats.cpp">
<Filter>Quelldateien\karts</Filter>
</ClCompile>
<ClCompile Include="..\..\tracks\track_sector.cpp">
<Filter>Quelldateien\tracks</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\main_loop.hpp"> <ClInclude Include="..\..\main_loop.hpp">
@ -1502,5 +1508,11 @@
<ClInclude Include="..\..\graphics\post_processing.hpp"> <ClInclude Include="..\..\graphics\post_processing.hpp">
<Filter>Headerdateien\graphics</Filter> <Filter>Headerdateien\graphics</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\karts\kart_with_stats.hpp">
<Filter>Headerdateien\karts</Filter>
</ClInclude>
<ClInclude Include="..\..\tracks\track_sector.hpp">
<Filter>Headerdateien\tracks</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -235,7 +235,7 @@ public:
void adjustSpeed (float f); void adjustSpeed (float f);
void capSpeed (float max_speed); void capSpeed (float max_speed);
void updatedWeight (); void updatedWeight ();
void collectedItem (Item *item, int random_attachment); virtual void collectedItem (Item *item, int random_attachment);
virtual void reset (); virtual void reset ();
void handleZipper (const Material *m=NULL, bool play_sound=false); void handleZipper (const Material *m=NULL, bool play_sound=false);
void setSquash (float time, float slowdown); void setSquash (float time, float slowdown);

View File

@ -19,6 +19,8 @@
#include "karts/kart_with_stats.hpp" #include "karts/kart_with_stats.hpp"
#include "items/item.hpp"
KartWithStats::KartWithStats(const std::string& ident, Track* track, KartWithStats::KartWithStats(const std::string& ident, Track* track,
int position, bool is_first_kart, int position, bool is_first_kart,
const btTransform& init_transform, const btTransform& init_transform,
@ -40,6 +42,11 @@ void KartWithStats::reset()
m_skidding_time = 0.0f; m_skidding_time = 0.0f;
m_rescue_count = 0; m_rescue_count = 0;
m_rescue_time = 0.0f; m_rescue_time = 0.0f;
m_bonus_count = 0;
m_banana_count = 0;
m_small_nitro_count = 0;
m_large_nitro_count = 0;
m_bubblegum_count = 0;
} // reset } // reset
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -97,3 +104,38 @@ void KartWithStats::forceRescue(bool is_auto_rescue)
} // forceRescue } // forceRescue
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** Called when an item is collected. It will increment private variables that
* represent counters for each type of item hit.
* \param item The item that was hit.
* \param add_info Additional info, used in networking games to force
* a specific item to be used (instead of a random item) to keep
* all karts in synch.
*/
void KartWithStats::collectedItem(Item *item, int add_info)
{
Kart::collectedItem(item, add_info);
const Item::ItemType type = item->getType();
switch (type)
{
case Item::ITEM_BANANA:
m_banana_count++;
break;
case Item::ITEM_NITRO_SMALL:
m_small_nitro_count++;
break;
case Item::ITEM_NITRO_BIG:
m_large_nitro_count++;
break;
case Item::ITEM_BONUS_BOX:
m_bonus_count++;
break;
case Item::ITEM_BUBBLEGUM:
m_bubblegum_count++;
break;
default : break;
} // switch TYPE
} // collectedItem
//-----------------------------------------------------------------------------

View File

@ -44,6 +44,21 @@ private:
/** How often a kart was rescued. */ /** How often a kart was rescued. */
unsigned int m_rescue_count; unsigned int m_rescue_count;
/** How many bonuses were taken */
unsigned int m_bonus_count;
/** How many bananas were taken */
unsigned int m_banana_count;
/** How many small nitro tanks were taken */
unsigned int m_small_nitro_count;
/** How many large nitro tanks were taken */
unsigned int m_large_nitro_count;
/** How many bubblegums were taken */
unsigned int m_bubblegum_count;
/** How much time was spent in rescue. */ /** How much time was spent in rescue. */
float m_rescue_time; float m_rescue_time;
@ -59,6 +74,7 @@ public:
virtual void reset(); virtual void reset();
virtual void handleExplosion(const Vec3& pos, bool direct_hit); virtual void handleExplosion(const Vec3& pos, bool direct_hit);
virtual void forceRescue(bool is_auto_rescue=false); virtual void forceRescue(bool is_auto_rescue=false);
virtual void collectedItem(Item *item, int add_info);
/** Returns the top speed of this kart. */ /** Returns the top speed of this kart. */
float getTopSpeed() const { return m_top_speed; } float getTopSpeed() const { return m_top_speed; }
@ -75,6 +91,21 @@ public:
/** Returns how often a kart was rescued. */ /** Returns how often a kart was rescued. */
unsigned int getRescueCount() const { return m_rescue_count; } unsigned int getRescueCount() const { return m_rescue_count; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the number of bonuses that were taken */
unsigned int getBonusCount() const { return m_bonus_count; }
// ------------------------------------------------------------------------
/** Returns the number of bananas that were taken */
unsigned int getBananaCount() const { return m_banana_count; }
// ------------------------------------------------------------------------
/** Returns the number of small nitro tanks that were taken */
unsigned int getSmallNitroCount() const { return m_small_nitro_count; }
// ------------------------------------------------------------------------
/** Returns the number of large nitro tanks that were taken */
unsigned int getLargeNitroCount() const { return m_large_nitro_count; }
// ------------------------------------------------------------------------
/** Returns the number of bubblegums that were taken */
unsigned int getBubblegumCount() const { return m_bubblegum_count; }
// ------------------------------------------------------------------------
/** Returns how long a kart was rescued all in all. */ /** Returns how long a kart was rescued all in all. */
float getRescueTime() const { return m_rescue_time; } float getRescueTime() const { return m_rescue_time; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------

View File

@ -239,7 +239,7 @@ void cmdLineHelp (char* invocation)
" -N, --no-start-screen Immediately start race without showing a menu.\n" " -N, --no-start-screen Immediately start race without showing a menu.\n"
" -R, --race-now Same as -N but also skip the ready-set-go phase and the music.\n" " -R, --race-now Same as -N but also skip the ready-set-go phase and the music.\n"
" -t, --track NAME Start at track NAME (see --list-tracks).\n" " -t, --track NAME Start at track NAME (see --list-tracks).\n"
" --gp name Start the specified Grand Prix.\n" " --gp NAME Start the specified Grand Prix.\n"
" --stk-config FILE use ./data/FILE instead of ./data/stk_config.xml\n" " --stk-config FILE use ./data/FILE instead of ./data/stk_config.xml\n"
" -l, --list-tracks Show available tracks.\n" " -l, --list-tracks Show available tracks.\n"
" -k, --numkarts NUM Number of karts on the racetrack.\n" " -k, --numkarts NUM Number of karts on the racetrack.\n"
@ -249,17 +249,17 @@ void cmdLineHelp (char* invocation)
" --laps N Define number of laps to N.\n" " --laps N Define number of laps to N.\n"
" --mode N N=1 novice, N=2 driver, N=3 racer.\n" " --mode N N=1 novice, N=2 driver, N=3 racer.\n"
// TODO: add back "--players" switch // TODO: add back "--players" switch
//" --players n Define number of players to between 1 and 4.\n" // " --players n Define number of players to between 1 and 4.\n"
" --item STYLE Use STYLE as your item style.\n" " --item STYLE Use STYLE as your item style.\n"
" -f, --fullscreen Select fullscreen display.\n" " -f, --fullscreen Select fullscreen display.\n"
" -w, --windowed Windowed display (default).\n" " -w, --windowed Windowed display (default).\n"
" -s, --screensize WxH Set the screen size (e.g. 320x200).\n" " -s, --screensize WxH Set the screen size (e.g. 320x200).\n"
" -v, --version Show version of SuperTuxKart.\n" " -v, --version Show version of SuperTuxKart.\n"
" --trackdir DIR A directory from which additional tracks are loaded.\n" " --trackdir DIR A directory from which additional tracks are loaded.\n"
" --renderer NUM Choose the renderer. Valid renderers are:" " --renderer NUM Choose the renderer. Valid renderers are:\n"
" (Default: 0, OpenGL: 1, Direct3D9: 2, \n" " Default: 0, OpenGL: 1, Direct3D9: 2, \n"
" Direct3D8: 3, Software: 4, \n" " Direct3D8: 3, Software: 4, \n"
" Burning's Software: 5, Null device: 6).\n" " Burning's Software: 5, Null device: 6\n"
" --animations=n Play karts' animations (All: 2, Humans only: 1, Nobody: 0).\n" " --animations=n Play karts' animations (All: 2, Humans only: 1, Nobody: 0).\n"
" --gfx=n Play other graphical effects like impact stars dance,\n" " --gfx=n Play other graphical effects like impact stars dance,\n"
" water animations or explosions (Enable: 1, Disable: 0).\n" " water animations or explosions (Enable: 1, Disable: 0).\n"
@ -348,6 +348,10 @@ int handleCmdLinePreliminary(int argc, char **argv)
KartPropertiesManager::addKartSearchDir(argv[i+1]); KartPropertiesManager::addKartSearchDir(argv[i+1]);
i++; i++;
} }
else if( !strcmp(argv[i], "--no-graphics") )
{
ProfileWorld::disableGraphics();
}
#if !defined(WIN32) && !defined(__CYGWIN) #if !defined(WIN32) && !defined(__CYGWIN)
else if ( !strcmp(argv[i], "--fullscreen") || !strcmp(argv[i], "-f")) else if ( !strcmp(argv[i], "--fullscreen") || !strcmp(argv[i], "-f"))
{ {
@ -648,7 +652,7 @@ int handleCmdLine(int argc, char **argv)
const Track *track = track_manager->getTrack(i); const Track *track = track_manager->getTrack(i);
if (!unlock_manager->isLocked(track->getIdent())) if (!unlock_manager->isLocked(track->getIdent()))
{ {
fprintf ( stdout, "\t%10s: %ls\n", fprintf ( stdout, "\t%14s: %ls\n",
track->getIdent().c_str(), track->getIdent().c_str(),
track->getName()); track->getName());
} }
@ -709,7 +713,12 @@ int handleCmdLine(int argc, char **argv)
} }
else if( !strcmp(argv[i], "--no-graphics") ) else if( !strcmp(argv[i], "--no-graphics") )
{ {
ProfileWorld::disableGraphics(); // Set default profile mode of 1 lap if we haven't already set one
if (!ProfileWorld::isProfileMode()) {
UserConfigParams::m_no_start_screen = true;
ProfileWorld::setProfileModeLaps(1);
race_manager->setNumLaps(1);
}
} }
else if( sscanf(argv[i], "--history=%d", &n)==1) else if( sscanf(argv[i], "--history=%d", &n)==1)
{ {

View File

@ -178,9 +178,12 @@ void ProfileWorld::enterRaceOverState()
m_karts[i]->finishedRace(estimateFinishTimeForKart(m_karts[i])); m_karts[i]->finishedRace(estimateFinishTimeForKart(m_karts[i]));
} }
// Print framerate statistics
float runtime = (irr_driver->getRealTime()-m_start_time)*0.001f; float runtime = (irr_driver->getRealTime()-m_start_time)*0.001f;
printf("Number of frames: %d time %f, Average FPS: %f\n", printf("Number of frames: %d time %f, Average FPS: %f\n",
m_frame_count, runtime, (float)m_frame_count/runtime); m_frame_count, runtime, (float)m_frame_count/runtime);
// Print geometry statistics if we're not in no-graphics mode
if(!m_no_graphics) if(!m_no_graphics)
{ {
printf("Average # drawn nodes %f k\n", printf("Average # drawn nodes %f k\n",
@ -195,45 +198,48 @@ void ProfileWorld::enterRaceOverState()
(float)m_num_trans_effect/m_frame_count); (float)m_num_trans_effect/m_frame_count);
} }
// Print race statistics for each individual kart
float min_t=999999.9f, max_t=0.0, av_t=0.0; float min_t=999999.9f, max_t=0.0, av_t=0.0;
printf("Name\t\tstart\tend\ttime\t"); printf("name,start_position,end_position,time,");
if(m_profile_mode==PROFILE_LAPS)
printf("aver.\t"); if (m_profile_mode==PROFILE_LAPS) {
printf("top\tskid\trescue\trescue\t" printf("average_speed,");
"expl.\texpl.\n"); }
printf("\t\t\t\t\t");
if(m_profile_mode==PROFILE_LAPS) printf("top_speed,skid_time,rescue_time,rescue_count,explosion_time,explosion_count,bonus_count,banana_count,small_nitro_count,large_nitro_count,bubblegum_count\n");
printf("speed\t");
printf("speed\ttime\ttime\tcount\ttime\tcount\n");
for ( KartList::size_type i = 0; i < m_karts.size(); ++i) for ( KartList::size_type i = 0; i < m_karts.size(); ++i)
{ {
max_t = std::max(max_t, m_karts[i]->getFinishTime()); KartWithStats* kart = dynamic_cast<KartWithStats*>(m_karts[i]);
min_t = std::min(min_t, m_karts[i]->getFinishTime());
av_t += m_karts[i]->getFinishTime(); max_t = std::max(max_t, kart->getFinishTime());
printf("%s\t%s", m_karts[i]->getIdent().c_str(), min_t = std::min(min_t, kart->getFinishTime());
m_karts[i]->getIdent().size()<8 ? "\t" : ""); av_t += kart->getFinishTime();
printf("%d\t%d\t", 1 + (int)i, m_karts[i]->getPosition()); printf("%s,", kart->getIdent().c_str());
printf("%4.2f\t", m_karts[i]->getFinishTime()); printf("%d,", 1 + (int)i);
printf("%d,", kart->getPosition());
printf("%4.2f,", kart->getFinishTime());
if(m_profile_mode==PROFILE_LAPS) if(m_profile_mode==PROFILE_LAPS)
{ {
float distance = race_manager->getNumLaps() float distance = race_manager->getNumLaps()
* m_track->getTrackLength(); * m_track->getTrackLength();
printf("%4.2f\t",distance/m_karts[i]->getFinishTime()); printf("%4.2f,", distance/kart->getFinishTime());
} }
printf("%3.2f\t", dynamic_cast<KartWithStats*> printf("%3.2f,", kart->getTopSpeed());
(m_karts[i])->getTopSpeed()); printf("%4.2f,", kart->getSkiddingTime());
printf("%4.2f\t", dynamic_cast<KartWithStats*> printf("%4.2f,%d,", kart->getRescueTime(),
(m_karts[i])->getSkiddingTime()); kart->getRescueCount());
printf("%4.2f\t%d\t", dynamic_cast<KartWithStats*> printf("%4.2f,%d,", kart->getExplosionTime(),
(m_karts[i])->getRescueTime(), kart->getExplosionCount() );
dynamic_cast<KartWithStats*> printf("%d,", kart->getBonusCount() );
(m_karts[i])->getRescueCount()); printf("%d,", kart->getBananaCount() );
printf("%4.2f\t%d\t", dynamic_cast<KartWithStats*> printf("%d,", kart->getSmallNitroCount() );
(m_karts[i])->getExplosionTime(), printf("%d,", kart->getLargeNitroCount() );
dynamic_cast<KartWithStats*> printf("%d", kart->getBubblegumCount() );
(m_karts[i])->getExplosionCount() );
printf("\n"); printf("\n");
} }
// Print group statistics of all karts
printf("min %f max %f av %f\n",min_t, max_t, av_t/m_karts.size()); printf("min %f max %f av %f\n",min_t, max_t, av_t/m_karts.size());
std::exit(-2); std::exit(-2);