Solved conflicts before merge hilnius branch

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@14637 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
deveee 2013-12-05 17:28:04 +00:00
parent 401f5caac2
commit 33e09e8f59
8 changed files with 1037 additions and 3959 deletions

View File

@ -11,9 +11,11 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "STKRelease") set(CMAKE_BUILD_TYPE "STKRelease")
endif() endif()
option(USE_WIIUSE "Support for wiimote input devices" OFF) option(USE_WIIUSE "Support for wiimote input devices" ON)
option(USE_FRIBIDI "Support for right-to-left languages" ON) option(USE_FRIBIDI "Support for right-to-left languages" ON)
option(USE_CPP2011 "Activate C++ 2011 mode (GCC only)" OFF) if(UNIX)
option(USE_CPP2011 "Activate C++ 2011 mode (GCC only)" OFF)
endif()
if(MSVC) if(MSVC)
# Normally hide the option to build wiiuse on VS, since it depends # Normally hide the option to build wiiuse on VS, since it depends
# on the installation of the Windows DDK (Driver Developer Kit), # on the installation of the Windows DDK (Driver Developer Kit),
@ -57,8 +59,6 @@ if(USE_WIIUSE)
include_directories("${PROJECT_SOURCE_DIR}/lib/wiiuse") include_directories("${PROJECT_SOURCE_DIR}/lib/wiiuse")
endif() endif()
include_directories("${PROJECT_SOURCE_DIR}/lib/irrlicht/source/Irrlicht")
# Set include paths # Set include paths
include_directories(${STK_SOURCE_DIR}) include_directories(${STK_SOURCE_DIR})
@ -74,6 +74,8 @@ endif()
if(APPLE) if(APPLE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch i386") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch i386")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch i386 -F/Library/Frameworks") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch i386 -F/Library/Frameworks")
elseif(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") # Enable multi-processor compilation (faster)
endif() endif()
# OpenAL # OpenAL
@ -117,8 +119,10 @@ if(USE_FRIBIDI)
endif() endif()
endif() endif()
if(USE_CPP2011) if(UNIX)
if(USE_CPP2011)
add_definitions("-std=gnu++11") add_definitions("-std=gnu++11")
endif()
endif() endif()
# OpenGL # OpenGL
@ -167,7 +171,7 @@ source_group_hierarchy(STK_SOURCES STK_HEADERS)
if(APPLE) if(APPLE)
# icon files to copy in the bundle # icon files to copy in the bundle
set(OSX_ICON_FILES ${PROJECT_SOURCE_DIR}/src/ide/Xcode/stk.icns) set(OSX_ICON_FILES ${PROJECT_SOURCE_DIR}/data/supertuxkart.icns)
set_source_files_properties(${OSX_ICON_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) set_source_files_properties(${OSX_ICON_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
set(STK_SOURCES ${STK_SOURCES} ${OSX_ICON_FILES}) set(STK_SOURCES ${STK_SOURCES} ${OSX_ICON_FILES})
@ -189,7 +193,7 @@ if(APPLE)
# configure CMake to use a custom Info.plist # configure CMake to use a custom Info.plist
set_target_properties(supertuxkart PROPERTIES set_target_properties(supertuxkart PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/src/ide/Xcode/SuperTuxKart-Info.plist) MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/data/SuperTuxKart-Info.plist)
if(CMAKE_GENERATOR MATCHES "Xcode") if(CMAKE_GENERATOR MATCHES "Xcode")
add_custom_command(TARGET supertuxkart POST_BUILD add_custom_command(TARGET supertuxkart POST_BUILD
@ -236,9 +240,6 @@ if(APPLE)
# CMake pick the library it wants essentially means I can't build. # CMake pick the library it wants essentially means I can't build.
set_target_properties(supertuxkart PROPERTIES LINK_FLAGS "-arch i386 -F/Library/Frameworks -framework OpenAL -framework Ogg -framework Vorbis") set_target_properties(supertuxkart PROPERTIES LINK_FLAGS "-arch i386 -F/Library/Frameworks -framework OpenAL -framework Ogg -framework Vorbis")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/Library/Frameworks/OpenAL.framework/Versions/A/Headers") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/Library/Frameworks/OpenAL.framework/Versions/A/Headers")
elseif(MSVC)
# We need to link with Iphlpapi.lib for some networking support:
target_link_libraries(supertuxkart "Iphlpapi.lib")
endif() endif()
if(USE_FRIBIDI) if(USE_FRIBIDI)
@ -293,6 +294,7 @@ install(TARGETS supertuxkart RUNTIME DESTINATION ${STK_INSTALL_BINARY_DIR} BUNDL
install(DIRECTORY ${STK_DATA_DIR} DESTINATION ${STK_INSTALL_DATA_DIR} PATTERN ".svn" EXCLUDE) install(DIRECTORY ${STK_DATA_DIR} DESTINATION ${STK_INSTALL_DATA_DIR} PATTERN ".svn" EXCLUDE)
install(FILES ${PROJECT_BINARY_DIR}/supertuxkart.desktop DESTINATION share/applications) install(FILES ${PROJECT_BINARY_DIR}/supertuxkart.desktop DESTINATION share/applications)
install(FILES data/supertuxkart_32.png data/supertuxkart_128.png DESTINATION share/pixmaps) install(FILES data/supertuxkart_32.png data/supertuxkart_128.png DESTINATION share/pixmaps)
install(FILES data/supertuxkart.appdata DESTINATION share/appdata)
set(PREFIX ${CMAKE_INSTALL_PREFIX}) set(PREFIX ${CMAKE_INSTALL_PREFIX})
configure_file(data/supertuxkart_desktop.template supertuxkart.desktop) configure_file(data/supertuxkart_desktop.template supertuxkart.desktop)

View File

@ -10,8 +10,7 @@
#include "IVideoDriver.h" #include "IVideoDriver.h"
#include "IGUIFont.h" #include "IGUIFont.h"
#include "IGUISpriteBank.h" #include "IGUISpriteBank.h"
#include "CGUIScrollBar.h" #include "IGUIScrollBar.h"
//#include "os.h"
#include "utils/time.hpp" #include "utils/time.hpp"
@ -37,9 +36,10 @@ CGUISTKListBox::CGUISTKListBox(IGUIEnvironment* environment, IGUIElement* parent
IGUISkin* skin = Environment->getSkin(); IGUISkin* skin = Environment->getSkin();
const s32 s = skin->getSize(EGDS_SCROLLBAR_SIZE); const s32 s = skin->getSize(EGDS_SCROLLBAR_SIZE);
ScrollBar = new CGUIScrollBar(false, Environment, this, -1, ScrollBar = Environment->addScrollBar(false,
core::rect<s32>(RelativeRect.getWidth() - s, 0, RelativeRect.getWidth(), RelativeRect.getHeight()), core::rect<s32>(RelativeRect.getWidth() - s, 0,
!clip); RelativeRect.getWidth(), RelativeRect.getHeight()), this, -1);
ScrollBar->grab();
ScrollBar->setSubElement(true); ScrollBar->setSubElement(true);
ScrollBar->setTabStop(false); ScrollBar->setTabStop(false);
ScrollBar->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); ScrollBar->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);

File diff suppressed because it is too large Load Diff

View File

@ -111,7 +111,7 @@ void WiimoteManager::launchDetection(int timeout)
wiiuse_rumble(wiimote_handle, 1); wiiuse_rumble(wiimote_handle, 1);
} }
Time::sleep(200); StkTime::sleep(200);
for(unsigned int i=0 ; i < m_wiimotes.size(); i++) for(unsigned int i=0 ; i < m_wiimotes.size(); i++)
{ {
@ -285,7 +285,7 @@ void WiimoteManager::threadFunc()
} }
} }
Time::sleep(1); // 'cause come on, the whole CPU is not ours :) StkTime::sleep(1); // 'cause come on, the whole CPU is not ours :)
} // end while } // end while
} // threadFunc } // threadFunc

View File

@ -1,6 +1,6 @@
// //
// SuperTuxKart - a fun racing game with go-kart // SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2006 Joerg Henrichs // Copyright (C) 2006-2013 Joerg Henrichs
// //
// This program is free software; you can redistribute it and/or // This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License // modify it under the terms of the GNU General Public License
@ -25,6 +25,7 @@
#include "graphics/explosion.hpp" #include "graphics/explosion.hpp"
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#include "items/attachment_manager.hpp" #include "items/attachment_manager.hpp"
#include "items/item_manager.hpp"
#include "items/projectile_manager.hpp" #include "items/projectile_manager.hpp"
#include "items/swatter.hpp" #include "items/swatter.hpp"
#include "karts/abstract_kart.hpp" #include "karts/abstract_kart.hpp"
@ -33,9 +34,13 @@
#include "karts/kart_properties.hpp" #include "karts/kart_properties.hpp"
#include "modes/three_strikes_battle.hpp" #include "modes/three_strikes_battle.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "physics/triangle_mesh.hpp"
#include "tracks/track.hpp"
#include "physics/triangle_mesh.hpp"
#include "tracks/track.hpp"
#include "utils/constants.hpp" #include "utils/constants.hpp"
#include "utils/log.hpp" //TODO: remove after debugging is done #include "utils/log.hpp"
// Log::verbose("attachment", "Decreasing shield \n");
/** Initialises the attachment each kart has. /** Initialises the attachment each kart has.
*/ */
Attachment::Attachment(AbstractKart* kart) Attachment::Attachment(AbstractKart* kart)
@ -46,6 +51,8 @@ Attachment::Attachment(AbstractKart* kart)
m_kart = kart; m_kart = kart;
m_previous_owner = NULL; m_previous_owner = NULL;
m_bomb_sound = NULL; m_bomb_sound = NULL;
m_bubble_explode_sound = NULL;
m_node_scale = 1.0f;
// If we attach a NULL mesh, we get a NULL scene node back. So we // If we attach a NULL mesh, we get a NULL scene node back. So we
// have to attach some kind of mesh, but make it invisible. // have to attach some kind of mesh, but make it invisible.
@ -74,6 +81,12 @@ Attachment::~Attachment()
sfx_manager->deleteSFX(m_bomb_sound); sfx_manager->deleteSFX(m_bomb_sound);
m_bomb_sound = NULL; m_bomb_sound = NULL;
} }
if (m_bubble_explode_sound)
{
sfx_manager->deleteSFX(m_bubble_explode_sound);
m_bubble_explode_sound = NULL;
}
} // ~Attachment } // ~Attachment
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -109,6 +122,7 @@ void Attachment::set(AttachmentType type, float time,
} }
clear(); clear();
m_node_scale = 0.3f;
// If necessary create the appropriate plugin which encapsulates // If necessary create the appropriate plugin which encapsulates
// the associated behavior // the associated behavior
@ -140,6 +154,8 @@ void Attachment::set(AttachmentType type, float time,
m_node->setCurrentFrame(0); m_node->setCurrentFrame(0);
} }
m_node->setScale(core::vector3df(m_node_scale,m_node_scale,m_node_scale));
m_type = type; m_type = type;
m_time_left = time; m_time_left = time;
m_previous_owner = current_kart; m_previous_owner = current_kart;
@ -161,6 +177,8 @@ void Attachment::set(AttachmentType type, float time,
} }
} }
m_node->setVisible(true); m_node->setVisible(true);
irr_driver->applyObjectPassShader(m_node);
} // set } // set
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -206,9 +224,10 @@ void Attachment::clear()
void Attachment::hitBanana(Item *item, int new_attachment) void Attachment::hitBanana(Item *item, int new_attachment)
{ {
//Bubble gum shield effect: //Bubble gum shield effect:
if(m_type == ATTACH_BUBBLEGUM_SHIELD) if(m_type == ATTACH_BUBBLEGUM_SHIELD ||
m_type == ATTACH_NOLOK_BUBBLEGUM_SHIELD)
{ {
m_time_left -= stk_config->m_bubblegum_shield_time; m_time_left = 0.0f;
return; return;
} }
@ -307,6 +326,12 @@ void Attachment::handleCollisionWithKart(AbstractKart *other)
if(getType()==Attachment::ATTACH_BOMB) if(getType()==Attachment::ATTACH_BOMB)
{ {
// Don't attach a bomb when the kart is shielded
if(other->isShielded())
{
other->decreaseShieldTime();
return;
}
// If both karts have a bomb, explode them immediately: // If both karts have a bomb, explode them immediately:
if(attachment_other->getType()==Attachment::ATTACH_BOMB) if(attachment_other->getType()==Attachment::ATTACH_BOMB)
{ {
@ -331,6 +356,12 @@ void Attachment::handleCollisionWithKart(AbstractKart *other)
else if(attachment_other->getType()==Attachment::ATTACH_BOMB && else if(attachment_other->getType()==Attachment::ATTACH_BOMB &&
(attachment_other->getPreviousOwner()!=m_kart || World::getWorld()->getNumKarts() <= 2)) (attachment_other->getPreviousOwner()!=m_kart || World::getWorld()->getNumKarts() <= 2))
{ {
// Don't attach a bomb when the kart is shielded
if(m_kart->isShielded())
{
m_kart->decreaseShieldTime();
return;
}
set(ATTACH_BOMB, other->getAttachment()->getTimeLeft()+ set(ATTACH_BOMB, other->getAttachment()->getTimeLeft()+
stk_config->m_bomb_time_increase, other); stk_config->m_bomb_time_increase, other);
other->getAttachment()->clear(); other->getAttachment()->clear();
@ -350,6 +381,17 @@ void Attachment::update(float dt)
if(m_type==ATTACH_NOTHING) return; if(m_type==ATTACH_NOTHING) return;
m_time_left -=dt; m_time_left -=dt;
bool is_shield = (m_type == ATTACH_BUBBLEGUM_SHIELD|| m_type == ATTACH_NOLOK_BUBBLEGUM_SHIELD);
float m_wanted_node_scale = is_shield ? std::max(1.0f, m_kart->getHighestPoint()*1.1f) : 1.0f;
if (m_node_scale < m_wanted_node_scale)
{
m_node_scale += dt*1.5f;
if (m_node_scale > m_wanted_node_scale) m_node_scale = m_wanted_node_scale;
m_node->setScale(core::vector3df(m_node_scale,m_node_scale,m_node_scale));
}
if(m_plugin) if(m_plugin)
{ {
bool discard = m_plugin->updateAndTestFinished(dt); bool discard = m_plugin->updateAndTestFinished(dt);
@ -412,15 +454,34 @@ void Attachment::update(float dt)
// Nothing to do for tinytux, this is all handled in EmergencyAnimation // Nothing to do for tinytux, this is all handled in EmergencyAnimation
break; break;
case ATTACH_BUBBLEGUM_SHIELD: case ATTACH_BUBBLEGUM_SHIELD:
if(!m_kart->isShielded()) case ATTACH_NOLOK_BUBBLEGUM_SHIELD:
if (m_time_left < 0)
{ {
m_time_left = 0.0f; m_time_left = 0.0f;
if (m_kart->m_bubble_drop) if (m_bubble_explode_sound) sfx_manager->deleteSFX(m_bubble_explode_sound);
{ m_bubble_explode_sound = sfx_manager->createSoundSource("bubblegum_explode");
Log::verbose("Attachment", "Drop a small bubble gum. \n");; m_bubble_explode_sound->position(m_kart->getXYZ());
//TODO: drop a bubble gum item on the track m_bubble_explode_sound->play();
}
// drop a small bubble gum
Vec3 hit_point;
Vec3 normal;
const Material* material_hit;
Vec3 pos = m_kart->getXYZ();
Vec3 to=pos+Vec3(0, -10000, 0);
World* world = World::getWorld();
world->getTrack()->getTriangleMesh().castRay(pos, to, &hit_point,
&material_hit, &normal);
// This can happen if the kart is 'over nothing' when dropping
// the bubble gum
if(material_hit)
{
normal.normalize();
pos.setY(hit_point.getY()-0.05f);
ItemManager::get()->newItem(Item::ITEM_BUBBLEGUM, pos, normal, m_kart);
}
} }
break; break;
} // switch } // switch

View File

@ -1,7 +1,7 @@
// //
// SuperTuxKart - a fun racing game with go-kart // SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2004-2005 Steve Baker <sjbaker1@airmail.net> // Copyright (C) 2004-2013 Steve Baker <sjbaker1@airmail.net>
// Copyright (C) 2006 SuperTuxKart-Team, Joerg Henrichs, Steve Baker // Copyright (C) 2006-2013 SuperTuxKart-Team, Joerg Henrichs, Steve Baker
// //
// This program is free software; you can redistribute it and/or // This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License // modify it under the terms of the GNU General Public License
@ -70,6 +70,7 @@
#include "tracks/track_manager.hpp" #include "tracks/track_manager.hpp"
#include "utils/constants.hpp" #include "utils/constants.hpp"
#include "utils/log.hpp" //TODO: remove after debugging is done #include "utils/log.hpp" //TODO: remove after debugging is done
#include "utils/vs.hpp"
@ -157,6 +158,7 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id,
m_engine_sound = sfx_manager->createSoundSource(m_kart_properties->getEngineSfxType()); m_engine_sound = sfx_manager->createSoundSource(m_kart_properties->getEngineSfxType());
m_beep_sound = sfx_manager->createSoundSource( "horn" ); m_beep_sound = sfx_manager->createSoundSource( "horn" );
m_crash_sound = sfx_manager->createSoundSource( "crash" ); m_crash_sound = sfx_manager->createSoundSource( "crash" );
m_boing_sound = sfx_manager->createSoundSource( "boing" );
m_goo_sound = sfx_manager->createSoundSource( "goo" ); m_goo_sound = sfx_manager->createSoundSource( "goo" );
m_skid_sound = sfx_manager->createSoundSource( "skid" ); m_skid_sound = sfx_manager->createSoundSource( "skid" );
m_terrain_sound = NULL; m_terrain_sound = NULL;
@ -181,6 +183,7 @@ void Kart::init(RaceManager::KartType type)
m_goo_sound->volume( 1.0f / factor ); m_goo_sound->volume( 1.0f / factor );
m_skid_sound->volume( 1.0f / factor ); m_skid_sound->volume( 1.0f / factor );
m_crash_sound->volume( 1.0f / factor ); m_crash_sound->volume( 1.0f / factor );
m_boing_sound->volume( 1.0f / factor );
m_beep_sound->volume( 1.0f / factor ); m_beep_sound->volume( 1.0f / factor );
} }
else else
@ -189,6 +192,7 @@ void Kart::init(RaceManager::KartType type)
m_skid_sound->volume( 1.0f / race_manager->getNumberOfKarts() ); m_skid_sound->volume( 1.0f / race_manager->getNumberOfKarts() );
m_crash_sound->volume( 1.0f / race_manager->getNumberOfKarts() ); m_crash_sound->volume( 1.0f / race_manager->getNumberOfKarts() );
m_beep_sound->volume( 1.0f / race_manager->getNumberOfKarts() ); m_beep_sound->volume( 1.0f / race_manager->getNumberOfKarts() );
m_boing_sound->volume( 1.0f / race_manager->getNumberOfKarts() );
} }
} }
@ -244,6 +248,7 @@ Kart::~Kart()
sfx_manager->deleteSFX(m_skid_sound ); sfx_manager->deleteSFX(m_skid_sound );
sfx_manager->deleteSFX(m_goo_sound ); sfx_manager->deleteSFX(m_goo_sound );
sfx_manager->deleteSFX(m_beep_sound ); sfx_manager->deleteSFX(m_beep_sound );
sfx_manager->deleteSFX(m_boing_sound );
delete m_kart_gfx; delete m_kart_gfx;
if(m_terrain_sound) sfx_manager->deleteSFX(m_terrain_sound); if(m_terrain_sound) sfx_manager->deleteSFX(m_terrain_sound);
if(m_previous_terrain_sound) sfx_manager->deleteSFX(m_previous_terrain_sound); if(m_previous_terrain_sound) sfx_manager->deleteSFX(m_previous_terrain_sound);
@ -526,8 +531,7 @@ void Kart::blockViewWithPlunger()
m_kart_properties->getPlungerInFaceTime(); m_kart_properties->getPlungerInFaceTime();
if(isShielded()) if(isShielded())
{ {
decreaseShieldTime(0.0f); //decrease the default amount of time decreaseShieldTime();
Log::verbose("Kart", "Decreasing shield, because of removing the plunger. \n");
} }
} // blockViewWithPlunger } // blockViewWithPlunger
@ -839,15 +843,22 @@ void Kart::finishedRace(float time)
RaceGUIBase* m = World::getWorld()->getRaceGUI(); RaceGUIBase* m = World::getWorld()->getRaceGUI();
if(m) if(m)
{ {
m->addMessage((getPosition() == 2 ? _("You won the race!") : _("You finished the race!")) , if (getPosition() == 2)
this, 2.0f); m->addMessage(_("You won the race!"), this, 2.0f);
} }
} }
else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_3_STRIKES) else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_3_STRIKES ||
race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
{ {
setController(new EndController(this, m_controller->getPlayer(), setController(new EndController(this, m_controller->getPlayer(),
m_controller)); m_controller));
} }
else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_EASTER_EGG)
{
m_kart_model->setAnimation(KartModel::AF_WIN_START);
setController(new EndController(this, m_controller->getPlayer(),
m_controller));
}
} // finishedRace } // finishedRace
@ -877,7 +888,7 @@ void Kart::collectedItem(Item *item, int add_info)
break; break;
case Item::ITEM_BONUS_BOX : case Item::ITEM_BONUS_BOX :
{ {
m_powerup->hitBonusBox(*item, add_info); // selects the powerup m_powerup->hitBonusBox(*item, add_info);
break; break;
} }
case Item::ITEM_BUBBLEGUM: case Item::ITEM_BUBBLEGUM:
@ -974,9 +985,15 @@ void Kart::setShieldTime(float t)
bool Kart::isShielded() const bool Kart::isShielded() const
{ {
if(getAttachment() != NULL) if(getAttachment() != NULL)
return getAttachment()->getType() == Attachment::ATTACH_BUBBLEGUM_SHIELD; {
Attachment::AttachmentType type = getAttachment()->getType();
return type == Attachment::ATTACH_BUBBLEGUM_SHIELD ||
type == Attachment::ATTACH_NOLOK_BUBBLEGUM_SHIELD;
}
else else
{
return false; return false;
}
} // isShielded } // isShielded
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@ -996,24 +1013,12 @@ float Kart::getShieldTime() const
* Decreases the kart's shield time. * Decreases the kart's shield time.
* \param t The time substracted from the shield timer. If t == 0.0f, the default amout of time is substracted. * \param t The time substracted from the shield timer. If t == 0.0f, the default amout of time is substracted.
*/ */
void Kart::decreaseShieldTime(float t) void Kart::decreaseShieldTime()
{ {
if(isShielded()) if (isShielded())
{ {
getAttachment()->setTimeLeft( getAttachment()->getTimeLeft() - t ); getAttachment()->setTimeLeft(0.0f);
if(t == 0.0f)
{
getAttachment()->setTimeLeft( getAttachment()->getTimeLeft()
- stk_config->m_bubblegum_shield_time);
} }
}
//Let the kart drop a bubble gum, if the shield was not damaged.
//This is the default, whenever a powerup is used by a kart.
//It is turned off, if the shield was reduced below zero by a hit. (Or by intently damaging the shield.)
if(!isShielded())
m_bubble_drop = false;
} // decreaseShieldTime } // decreaseShieldTime
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -1038,6 +1043,7 @@ void Kart::eliminate()
m_stars_effect->update(1); m_stars_effect->update(1);
} }
m_kart_gfx->setCreationRateAbsolute(KartGFX::KGFX_TERRAIN, 0);
m_eliminated = true; m_eliminated = true;
m_node->setVisible(false); m_node->setVisible(false);
@ -1155,7 +1161,6 @@ void Kart::update(float dt)
// since use() can test if something needs to be switched on/off. // since use() can test if something needs to be switched on/off.
m_powerup->use() ; m_powerup->use() ;
World::getWorld()->onFirePressed(getController()); World::getWorld()->onFirePressed(getController());
m_bubble_drop = true;
m_fire_clicked = 1; m_fire_clicked = 1;
} }
@ -1170,6 +1175,7 @@ void Kart::update(float dt)
m_engine_sound->position ( getXYZ() ); m_engine_sound->position ( getXYZ() );
m_crash_sound->position ( getXYZ() ); m_crash_sound->position ( getXYZ() );
m_skid_sound->position ( getXYZ() ); m_skid_sound->position ( getXYZ() );
m_boing_sound->position ( getXYZ() );
// Check if a kart is (nearly) upside down and not moving much --> automatic rescue // Check if a kart is (nearly) upside down and not moving much --> automatic rescue
if(World::getWorld()->getTrack()->isAutoRescueEnabled() && if(World::getWorld()->getTrack()->isAutoRescueEnabled() &&
@ -1309,7 +1315,12 @@ void Kart::update(float dt)
m_jump_time = 0; m_jump_time = 0;
} }
if( (!isOnGround() || emergency) && m_shadow_enabled) //const bool dyn_shadows = World::getWorld()->getTrack()->hasShadows() &&
// UserConfigParams::m_shadows &&
// irr_driver->isGLSL();
// Disable the fake shadow if we're flying
if((!isOnGround() || emergency) && m_shadow_enabled)
{ {
m_shadow_enabled = false; m_shadow_enabled = false;
m_shadow->disableShadow(); m_shadow->disableShadow();
@ -1342,8 +1353,7 @@ void Kart::setSquash(float time, float slowdown)
if (isShielded()) if (isShielded())
{ {
decreaseShieldTime(stk_config->m_bubblegum_shield_time/2.0f); decreaseShieldTime();
Log::verbose("Kart", "Decreasing shield \n");
return; return;
} }
@ -1407,6 +1417,7 @@ void Kart::handleMaterialSFX(const Material *material)
m_terrain_sound = NULL; m_terrain_sound = NULL;
} }
} }
if(m_previous_terrain_sound && if(m_previous_terrain_sound &&
m_previous_terrain_sound->getStatus()==SFXManager::SFX_STOPPED) m_previous_terrain_sound->getStatus()==SFXManager::SFX_STOPPED)
{ {
@ -1417,14 +1428,18 @@ void Kart::handleMaterialSFX(const Material *material)
m_previous_terrain_sound = NULL; m_previous_terrain_sound = NULL;
} }
bool m_schedule_pause = m_flying ||
dynamic_cast<RescueAnimation*>(getKartAnimation()) ||
dynamic_cast<ExplosionAnimation*>(getKartAnimation());
// terrain sound is not necessarily a looping sound so check its status before // terrain sound is not necessarily a looping sound so check its status before
// setting its speed, to avoid 'ressuscitating' sounds that had already stopped // setting its speed, to avoid 'ressuscitating' sounds that had already stopped
if(m_terrain_sound if(m_terrain_sound &&
&& (m_terrain_sound->getStatus() == SFXManager::SFX_PLAYING (m_terrain_sound->getStatus()==SFXManager::SFX_PLAYING ||
|| m_terrain_sound->getStatus() == SFXManager::SFX_PAUSED)) m_terrain_sound->getStatus()==SFXManager::SFX_PAUSED))
{ {
m_terrain_sound->position(getXYZ()); m_terrain_sound->position(getXYZ());
material->setSFXSpeed(m_terrain_sound, m_speed); material->setSFXSpeed(m_terrain_sound, m_speed, m_schedule_pause);
} }
} // handleMaterialSFX } // handleMaterialSFX
@ -1670,7 +1685,7 @@ void Kart::crashed(AbstractKart *k, bool update_attachments)
getAttachment()->handleCollisionWithKart(k); getAttachment()->handleCollisionWithKart(k);
} }
m_controller->crashed(k); m_controller->crashed(k);
crashed(); crashed(NULL, k);
} // crashed(Kart, update_attachments } // crashed(Kart, update_attachments
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -1810,13 +1825,15 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
} // if(m && m->getCollisionReaction() != Material::NORMAL && } // if(m && m->getCollisionReaction() != Material::NORMAL &&
// !getKartAnimation()) // !getKartAnimation())
m_controller->crashed(m); m_controller->crashed(m);
crashed(); crashed(m, NULL);
} // crashed(Material) } // crashed(Material)
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
/** Common code used when a kart or a material was hit. /** Common code used when a kart or a material was hit.
* @param m The material collided into, or NULL if none
* @param k The kart collided into, or NULL if none
*/ */
void Kart::crashed() void Kart::crashed(const Material* m, AbstractKart *k)
{ {
if(World::getWorld()->getTime()-m_time_last_crash < 0.5f) return; if(World::getWorld()->getTime()-m_time_last_crash < 0.5f) return;
@ -1830,9 +1847,17 @@ void Kart::crashed()
{ {
// In case that the sfx is longer than 0.5 seconds, only play it if // In case that the sfx is longer than 0.5 seconds, only play it if
// it's not already playing. // it's not already playing.
if (isShielded() || (k != NULL && k->isShielded()))
{
if (m_boing_sound->getStatus() != SFXManager::SFX_PLAYING)
m_boing_sound->play();
}
else
{
if(m_crash_sound->getStatus() != SFXManager::SFX_PLAYING) if(m_crash_sound->getStatus() != SFXManager::SFX_PLAYING)
m_crash_sound->play(); m_crash_sound->play();
} }
}
m_bounce_back_time = 0.1f; m_bounce_back_time = 0.1f;
} }
@ -1944,7 +1969,7 @@ void Kart::updatePhysics(float dt)
m_skidding->update(dt, isOnGround(), m_controls.m_steer, m_skidding->update(dt, isOnGround(), m_controls.m_steer,
m_controls.m_skid); m_controls.m_skid);
m_vehicle->setVisualRotation(m_skidding->getVisualSkidRotation());
if(( m_skidding->getSkidState() == Skidding::SKID_ACCUMULATE_LEFT || if(( m_skidding->getSkidState() == Skidding::SKID_ACCUMULATE_LEFT ||
m_skidding->getSkidState() == Skidding::SKID_ACCUMULATE_RIGHT ) && m_skidding->getSkidState() == Skidding::SKID_ACCUMULATE_RIGHT ) &&
m_skidding->getGraphicalJumpOffset()==0) m_skidding->getGraphicalJumpOffset()==0)
@ -2000,6 +2025,13 @@ void Kart::updatePhysics(float dt)
//at low velocity, forces on kart push it back and forth so we ignore this //at low velocity, forces on kart push it back and forth so we ignore this
if(fabsf(m_speed) < 0.2f) // quick'n'dirty workaround for bug 1776883 if(fabsf(m_speed) < 0.2f) // quick'n'dirty workaround for bug 1776883
m_speed = 0; m_speed = 0;
if (dynamic_cast<RescueAnimation*>(getKartAnimation()) ||
dynamic_cast<ExplosionAnimation*>(getKartAnimation()))
{
m_speed = 0;
}
updateEngineSFX(); updateEngineSFX();
#ifdef XX #ifdef XX
Log::info("Kart","forward %f %f %f %f side %f %f %f %f angVel %f %f %f heading %f\n" Log::info("Kart","forward %f %f %f %f side %f %f %f %f angVel %f %f %f heading %f\n"
@ -2307,23 +2339,6 @@ void Kart::loadData(RaceManager::KartType type, bool is_animated_model)
} // loadData } // loadData
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** Stores the current suspension length. This function is called from world
* after all karts are in resting position (see World::resetAllKarts), so
* that the default suspension rest length can be stored. This is then used
* later to move the wheels depending on actual suspension, so that when
* a kart is in rest, the wheels are at the position at which they were
* modelled.
*/
void Kart::setSuspensionLength()
{
for(unsigned int i=0; i<4; i++)
{
m_default_suspension_length[i] =
m_vehicle->getWheelInfo(i).m_raycastInfo.m_suspensionLength;
} // for i
} // setSuspensionLength
//-----------------------------------------------------------------------------
/** Applies engine power to all the wheels that are traction capable, /** Applies engine power to all the wheels that are traction capable,
* so other parts of code do not have to be adjusted to simulate different * so other parts of code do not have to be adjusted to simulate different
* kinds of vehicles in the general case, only if they are trying to * kinds of vehicles in the general case, only if they are trying to
@ -2361,25 +2376,11 @@ void Kart::applyEngineForce(float force)
void Kart::updateGraphics(float dt, const Vec3& offset_xyz, void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
const btQuaternion& rotation) const btQuaternion& rotation)
{ {
float wheel_up_axis[4]; // Upate particle effects (creation rate, and emitter size
for(unsigned int i=0; i<4; i++) // depending on speed)
{ // --------------------------------------------------------
// Set the suspension length if ( (m_controls.m_nitro || m_min_nitro_time > 0.0f) &&
wheel_up_axis[i] = m_default_suspension_length[i] isOnGround() && m_collected_energy > 0 )
- m_vehicle->getWheelInfo(i).m_raycastInfo.m_suspensionLength;
}
m_kart_model->update(m_wheel_rotation_dt, getSteerPercent(), wheel_up_axis);
Vec3 center_shift = m_kart_properties->getGravityCenterShift();
float y = m_vehicle->getWheelInfo(0).m_chassisConnectionPointCS.getY()
- m_default_suspension_length[0]
- m_vehicle->getWheelInfo(0).m_wheelsRadius
- (m_kart_model->getWheelGraphicsRadius(0)
-m_kart_model->getWheelGraphicsPosition(0).getY() );
y += m_skidding->getGraphicalJumpOffset();
center_shift.setY(y);
if ((m_controls.m_nitro || m_min_nitro_time > 0.0f) && isOnGround() && m_collected_energy > 0)
{ {
// fabs(speed) is important, otherwise the negative number will // fabs(speed) is important, otherwise the negative number will
// become a huge unsigned number in the particle scene node! // become a huge unsigned number in the particle scene node!
@ -2407,6 +2408,8 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
m_kart_gfx->resizeBox(KartGFX::KGFX_ZIPPER, getSpeed(), dt); m_kart_gfx->resizeBox(KartGFX::KGFX_ZIPPER, getSpeed(), dt);
// Handle leaning of karts
// -----------------------
// Note that we compare with maximum speed of the kart, not // Note that we compare with maximum speed of the kart, not
// maximum speed including terrain effects. This avoids that // maximum speed including terrain effects. This avoids that
// leaning might get less if a kart gets a special that increases // leaning might get less if a kart gets a special that increases
@ -2461,6 +2464,50 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
} }
} }
// Now determine graphical chassis and wheel position depending on
// the physics result. The center of gravity of the chassis is at the
// bottom of the chassis, but the position of the graphical chassis is at
// the bottom of the wheels (i.e. in blender the kart is positioned on
// the horizonal plane through (0,0,0)). So first determine how far
// above the terrain is the center of the physics body. If the minimum
// of those values is larger than the lowest point of the chassis model
// the kart chassis would be too high (and look odd), so in this case
// move the chassis down so that the wheels (when touching the ground)
// look close enough to the chassis.
float height_above_terrain[4];
float min_hat = 9999.9f;
for(unsigned int i=0; i<4; i++)
{
// Set the suspension length
height_above_terrain[i] =
( m_vehicle->getWheelInfo(i).m_raycastInfo.m_hardPointWS
- m_vehicle->getWheelInfo(i).m_raycastInfo.m_contactPointWS).length()
- m_vehicle->getWheelInfo(i).m_chassisConnectionPointCS.getY();
if(height_above_terrain[i] < min_hat) min_hat = height_above_terrain[i];
}
float chassis_delta = 0;
// Check if the chassis needs to be moved down so that the wheels look
// like they are in the rest state, i.e. the wheels are not too far down.
if(min_hat > m_kart_model->getLowestPoint())
{
chassis_delta = min_hat - m_kart_model->getLowestPoint();
for(unsigned int i=0; i<4; i++)
height_above_terrain[i] -= chassis_delta;
}
m_kart_model->update(dt, m_wheel_rotation_dt, getSteerPercent(),
height_above_terrain, m_speed);
// If the kart is leaning, part of the kart might end up 'in' the track.
// To avoid this, raise the kart enough to offset the leaning.
float lean_height = tan(fabsf(m_current_lean)) * getKartWidth()*0.5f;
Vec3 center_shift = m_kart_properties->getGravityCenterShift();
center_shift.setY(m_skidding->getGraphicalJumpOffset() + lean_height
- m_kart_model->getLowestPoint() -chassis_delta );
float heading = m_skidding->getVisualSkidRotation(); float heading = m_skidding->getVisualSkidRotation();
Moveable::updateGraphics(dt, center_shift, Moveable::updateGraphics(dt, center_shift,
btQuaternion(heading, 0, m_current_lean)); btQuaternion(heading, 0, m_current_lean));

View File

@ -1,6 +1,6 @@
// //
// SuperTuxKart - a fun racing game with go-kart // SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2006 Joerg Henrichs // Copyright (C) 2006-2013 Joerg Henrichs
// //
// This program is free software; you can redistribute it and/or // This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License // modify it under the terms of the GNU General Public License
@ -22,11 +22,12 @@
#include "animations/three_d_animation.hpp" #include "animations/three_d_animation.hpp"
#include "karts/abstract_kart.hpp" #include "karts/abstract_kart.hpp"
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#include "graphics/stars.hpp"
#include "items/flyable.hpp"
#include "karts/kart_properties.hpp" #include "karts/kart_properties.hpp"
#include "karts/rescue_animation.hpp" #include "karts/rescue_animation.hpp"
#include "items/flyable.hpp" #include "modes/soccer_world.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "graphics/stars.hpp"
#include "karts/explosion_animation.hpp" #include "karts/explosion_animation.hpp"
#include "physics/btKart.hpp" #include "physics/btKart.hpp"
#include "physics/btUprightConstraint.hpp" #include "physics/btUprightConstraint.hpp"
@ -189,6 +190,12 @@ void Physics::update(float dt)
const KartProperties* kp = kart->getKartProperties(); const KartProperties* kp = kart->getKartProperties();
kart->setSquash(kp->getSquashDuration(), kp->getSquashSlowdown()); kart->setSquash(kp->getSquashDuration(), kp->getSquashSlowdown());
} }
else if(obj->isSoccerBall())
{
int kartId = p->getUserPointer(1)->getPointerKart()->getWorldKartId();
SoccerWorld* soccerWorld = (SoccerWorld*)World::getWorld();
soccerWorld->setLastKartTohitBall(kartId);
}
continue; continue;
} }
@ -229,6 +236,13 @@ void Physics::update(float dt)
// ------------------------------- // -------------------------------
p->getUserPointer(0)->getPointerFlyable() p->getUserPointer(0)->getPointerFlyable()
->hit(NULL, p->getUserPointer(1)->getPointerPhysicalObject()); ->hit(NULL, p->getUserPointer(1)->getPointerPhysicalObject());
PhysicalObject* obj = p->getUserPointer(1)->getPointerPhysicalObject();
if(obj->isSoccerBall())
{
int kartId = p->getUserPointer(0)->getPointerFlyable()->getOwnerId();
SoccerWorld* soccerWorld = (SoccerWorld*)World::getWorld();
soccerWorld->setLastKartTohitBall(kartId);
}
} }
else if(p->getUserPointer(1)->is(UserPointer::UP_KART)) else if(p->getUserPointer(1)->is(UserPointer::UP_KART))
@ -472,6 +486,16 @@ btScalar Physics::solveGroup(btCollisionObject** bodies, int numBodies,
.m_normalWorldOnB; .m_normalWorldOnB;
kart->crashed(m, normal); kart->crashed(m, normal);
} }
else if(upB->is(UserPointer::UP_PHYSICAL_OBJECT))
{
int n = contact_manifold->getContactPoint(0).m_index1;
const Material *m
= n>=0 ? upA->getPointerTriangleMesh()->getMaterial(n)
: NULL;
const btVector3 &normal = contact_manifold->getContactPoint(0)
.m_normalWorldOnB;
upB->getPointerPhysicalObject()->hit(m, normal);
}
} }
// 2) object a is a kart // 2) object a is a kart
// ===================== // =====================
@ -538,6 +562,16 @@ btScalar Physics::solveGroup(btCollisionObject** bodies, int numBodies,
m_all_collisions.push_back( m_all_collisions.push_back(
upA, contact_manifold->getContactPoint(0).m_localPointA, upA, contact_manifold->getContactPoint(0).m_localPointA,
upB, contact_manifold->getContactPoint(0).m_localPointB); upB, contact_manifold->getContactPoint(0).m_localPointB);
else if(upB->is(UserPointer::UP_TRACK))
{
int n = contact_manifold->getContactPoint(0).m_index1;
const Material *m
= n>=0 ? upB->getPointerTriangleMesh()->getMaterial(n)
: NULL;
const btVector3 &normal = contact_manifold->getContactPoint(0)
.m_normalWorldOnB;
upA->getPointerPhysicalObject()->hit(m, normal);
}
} }
else if (upA->is(UserPointer::UP_ANIMATION)) else if (upA->is(UserPointer::UP_ANIMATION))
{ {

View File

@ -1,6 +1,6 @@
//
// SuperTuxKart - a fun racing game with go-kart // SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2004 Steve Baker <sjbaker1@airmail.net> //
// Copyright (C) 2013 SuperTuxKart-Team
// //
// This program is free software; you can redistribute it and/or // This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License // modify it under the terms of the GNU General Public License
@ -39,6 +39,9 @@ class StkTime
public: public:
typedef time_t TimeType; typedef time_t TimeType;
static double getRealTime(long startAt=0);
static void getDate(int *day=NULL, int *month=NULL, int *year=NULL);
/** Converts the time in this object to a human readable string. */ /** Converts the time in this object to a human readable string. */
static std::string toString(const TimeType &tt) static std::string toString(const TimeType &tt)
{ {
@ -125,7 +128,7 @@ public:
t.tm_mon += month; t.tm_mon += month;
t.tm_mday += day; t.tm_mday += day;
return mktime(&t); return mktime(&t);
} } // addInterval
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
class ScopeProfiler class ScopeProfiler
@ -143,7 +146,7 @@ public:
float f2 = (float)getRealTime(); float f2 = (float)getRealTime();
printf("} // took %f s\n", (f2 - m_time)); printf("} // took %f s\n", (f2 - m_time));
} }
}; }; // class ScopeProfiler
}; // namespace time }; // namespace time
#endif #endif