Merge remote-tracking branch 'origin/master' into render_kart_driver_differently

This commit is contained in:
Benau 2016-06-25 16:31:08 +08:00
commit 7e806fe86f
18 changed files with 369 additions and 36 deletions

View File

@ -39,6 +39,7 @@ endif()
if(UNIX AND NOT APPLE)
option(USE_XRANDR "Use xrandr instead of vidmode" ON)
option(USE_ASAN "Build with Leak/Address sanitizer" OFF)
option(USE_LIBBFD "Use libbfd for crash reporting and leak check" OFF)
endif()
set(STK_SOURCE_DIR "src")
@ -211,6 +212,17 @@ if(UNIX AND NOT APPLE)
find_library(IRRLICHT_XF86VM_LIBRARY Xxf86vm)
mark_as_advanced(IRRLICHT_XF86VM_LIBRARY)
endif()
if(USE_LIBBFD)
find_package(Libbfd)
if(LIBBFD_FOUND)
add_definitions(-DENABLE_LIBBFD)
include_directories(${LIBBFD_INCLUDE_DIRS})
else()
set(USE_LIBBFD OFF CACHE BOOL "Use libbfd for crash reporting and leak check" FORCE)
message(WARNING "Libbfd not found, disable integrated stack trace.")
endif()
endif()
endif()
# Set some compiler options
@ -360,6 +372,9 @@ if(UNIX AND NOT APPLE)
else()
target_link_libraries(supertuxkart ${IRRLICHT_XF86VM_LIBRARY})
endif()
if(USE_LIBBFD)
target_link_libraries(supertuxkart ${LIBBFD_LIBRARIES})
endif()
if(USE_ASAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
target_link_libraries(supertuxkart "-fsanitize=address")

89
cmake/FindLibbfd.cmake Normal file
View File

@ -0,0 +1,89 @@
# - Try to find libbfd
# Once done this will define
#
# LIBBFD_FOUND - system has libbfd
# LIBBFD_INCLUDE_DIRS - the libbfd include directory
# LIBBFD_LIBRARIES - Link these to use libbfd
# LIBBFD_DEFINITIONS - Compiler switches required for using libbfd
#
# Based on:
#
# Copyright (c) 2008 Bernhard Walle <bernhard.walle@gmx.de>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
if (LIBBFD_LIBRARIES AND LIBBFD_INCLUDE_DIRS)
set (LIBBFD_FIND_QUIETLY TRUE)
endif ()
find_path (LIBBFD_INCLUDE_DIRS
NAMES
bfd.h
dis-asm.h
PATHS
/usr/include
/usr/local/include
/opt/local/include
/opt/include
ENV CPATH)
# Ugly, yes ugly...
find_library (LIBBFD_BFD_LIBRARY
NAMES
bfd
PATHS
/usr/lib
/usr/lib64
/usr/local/lib
/usr/local/lib64
/usr/include
/opt/local/lib
/opt/usr/lib64
ENV LIBRARY_PATH
ENV LD_LIBRARY_PATH)
#find_library (LIBBFD_IBERTY_LIBRARY
# NAMES
# iberty
# PATHS
# /usr/lib
# /usr/lib64
# /usr/local/lib
# /usr/local/lib64
# /usr/include
# /opt/local/lib
# /opt/usr/lib64
# ENV LIBRARY_PATH
# ENV LD_LIBRARY_PATH)
#find_library (LIBBFD_OPCODES_LIBRARY
# NAMES
# opcodes
# PATHS
# /usr/lib
# /usr/lib64
# /usr/local/lib
# /usr/local/lib64
# /usr/include
# /opt/local/lib
# /opt/usr/lib64
# ENV LIBRARY_PATH
# ENV LD_LIBRARY_PATH)
include (FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LIBBFD_FOUND to TRUE if all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBBFD DEFAULT_MSG
LIBBFD_BFD_LIBRARY
# LIBBFD_IBERTY_LIBRARY
# LIBBFD_OPCODES_LIBRARY
LIBBFD_INCLUDE_DIRS)
set(LIBBFD_LIBRARIES "${LIBBFD_BFD_LIBRARY}")
mark_as_advanced(LIBBFD_INCLUDE_DIRS LIBBFD_LIBRARIES LIBBFD_BFD_LIBRARY)

View File

@ -26,5 +26,6 @@
1.32.20 -->
<card contains="Radeon" os="linux" version="<14.300" disable="DriverRecentEnough"/>
<card contains="Radeon" os="windows" version="<14.300" disable="DriverRecentEnough"/>
<card contains="ATI" os="windows" version="<14.300" disable="DriverRecentEnough"/>
</graphical-restrictions>

View File

@ -118,7 +118,7 @@
<!-- The field od views for 1-4 player split screen. fov-3 is
actually not used (since 3 player split screen uses the
same layout as 4 player split screen) -->
<camera fov-1="80" fov-2="65" fov-3="50" fov-4="75" />
<camera fov-1="80" fov-2="65" fov-3="50" fov-4="75" cutscene-fov="0.61" />
<!-- disable-while-unskid: Disable steering when stop skidding during
the time it takes to adjust the physical body with the graphics.

View File

@ -177,6 +177,7 @@ void STKConfig::init_defaults()
m_ai_acceleration = 1.0f;
m_disable_steer_while_unskid = false;
m_camera_follow_skid = false;
m_cutscene_fov = 0.61f;
m_score_increase.clear();
m_leader_intervals.clear();
@ -264,6 +265,7 @@ void STKConfig::getAllData(const XMLNode * root)
camera->get("fov-2", &m_camera_fov[1]);
camera->get("fov-3", &m_camera_fov[2]);
camera->get("fov-4", &m_camera_fov[3]);
camera->get("cutscene-fov", &m_cutscene_fov);
}
if (const XMLNode *music_node = root->getNode("music"))

View File

@ -143,6 +143,8 @@ public:
/** The field of view for 1, 2, 3, 4 player split screen. */
float m_camera_fov[4];
float m_cutscene_fov;
/** File names of the default fonts in STK. */
std::string m_font_default;
std::string m_font_default_fallback;

View File

@ -2756,7 +2756,7 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
float heading = m_skidding->getVisualSkidRotation();
Moveable::updateGraphics(dt, center_shift,
btQuaternion(heading, 0, m_current_lean));
btQuaternion(heading, 0, -m_current_lean));
// m_speed*dt is the distance the kart has moved, which determines
// how much the wheels need to rotate.

View File

@ -882,11 +882,11 @@ void KartModel::update(float dt, float distance, float steer, float speed,
// being compressed), but the other side will be in the air. To avoid
// this, increase the position of the wheels on the side that are
// higher in the ground so that the wheel still touch the ground.
if(current_lean_angle > 0 && (i&1) == 0) // i&1 == 0: left side
if(current_lean_angle > 0 && (i&1) == 1) // i&1 == 0: left side
{
pos.Y -= 2*current_lean_angle;
}
else if (current_lean_angle < 0 && (i&1) == 1) // i&1 == 1: right side
else if (current_lean_angle < 0 && (i&1) == 0) // i&1 == 1: right side
{
pos.Y += 2*current_lean_angle;
}

View File

@ -80,7 +80,7 @@ void CutsceneWorld::init()
Camera* stk_cam = Camera::createCamera(NULL);
m_camera = stk_cam->getCameraSceneNode();
m_camera->setFOV(0.61f);
m_camera->setFOV(stk_config->m_cutscene_fov);
m_camera->bindTargetAndRotation(true); // no "look-at"
// --- Build list of sounds to play at certain frames

View File

@ -188,6 +188,12 @@ public:
{
return m_kart_info[kart_index].m_overall_distance;
} // getOverallDistance
/** Returns time for the fastest laps */
float getFastestLap() const
{
return m_fastest_lap;
}
}; // LinearWorld
#endif

View File

@ -33,7 +33,7 @@
#include "network/stk_peer.hpp"
#include "online/online_profile.hpp"
#include "online/request_manager.hpp"
#include "states_screens//networking_lobby.hpp"
#include "states_screens/networking_lobby.hpp"
#include "states_screens/race_result_gui.hpp"
#include "states_screens/waiting_for_others.hpp"
#include "utils/log.hpp"

View File

@ -111,6 +111,7 @@ void PhysicalObject::Settings::init()
m_linear_factor = Vec3(1.0f, 1.0f, 1.0f);
m_angular_factor = Vec3(1.0f, 1.0f, 1.0f);
m_linear_damping = 0.0f;
// Make sure that the cones stop rolling by defining angular friction != 0.
m_angular_damping = 0.5f;
m_reset_when_too_low = false;
m_flatten_kart = false;
@ -521,8 +522,6 @@ void PhysicalObject::init(const PhysicalObject::Settings& settings)
btRigidBody::btRigidBodyConstructionInfo info(m_mass, m_motion_state,
m_shape, inertia);
// Make sure that the cones stop rolling by defining angular friction != 0.
info.m_angularDamping = 0.5f;
m_body = new btRigidBody(info);
m_user_pointer.set(this);
m_body->setUserPointer(&m_user_pointer);

View File

@ -98,7 +98,7 @@ void RaceResultGUI::init()
}
m_finish_sound = SFXManager::get()->quickSound(
human_win ? "gp_end" : "race_finish");
human_win ? "race_finish_victory" : "race_finish");
//std::string path = (human_win ? Different result music too later
// file_manager->getAsset(FileManager::MUSIC, "race_summary.music") :
@ -828,7 +828,7 @@ void RaceResultGUI::backToLobby()
if (race_manager->getMajorMode() != RaceManager::MAJOR_MODE_GRAND_PRIX ||
m_animation_state == RR_RACE_RESULT)
{
displayHighScores();
displayPostRaceInfo();
}
} // renderGlobal
@ -904,11 +904,11 @@ void RaceResultGUI::backToLobby()
//-----------------------------------------------------------------------------
/** Returns a string to display next to a kart. For a player that's the name
* of the player, for an AI kart it's the name of the driver.
* of the player, for an AI kart it's the name of the driver.
*/
core::stringw RaceResultGUI::getKartDisplayName(const AbstractKart *kart) const
{
const EndController *ec =
const EndController *ec =
dynamic_cast<const EndController*>(kart->getController());
// If the race was given up, there is no end controller for the
// players, so this case needs to be handled separately
@ -917,7 +917,7 @@ void RaceResultGUI::backToLobby()
else
{
// No end controller, check explicitely for a player controller
const PlayerController *pc =
const PlayerController *pc =
dynamic_cast<const PlayerController*>(kart->getController());
// Check if the kart is a player controller to get the real name
if(pc) return pc->getName();
@ -1322,21 +1322,24 @@ void RaceResultGUI::backToLobby()
} // cleanupGPProgress
// ----------------------------------------------------------------------------
void RaceResultGUI::displayHighScores()
void RaceResultGUI::displayPostRaceInfo()
{
// This happens in demo world
if (!World::getWorld())
return;
Highscores* scores = World::getWorld()->getHighscores();
video::SColor white_color = video::SColor(255, 255, 255, 255);
int x = (int)(UserConfigParams::m_width*0.65f);
int y = m_top;
int current_y = y;
// In some case for exemple FTL they will be no highscores
if (scores != NULL)
{
video::SColor white_color = video::SColor(255, 255, 255, 255);
int x = (int)(UserConfigParams::m_width*0.65f);
int y = m_top;
// First draw title
GUIEngine::getFont()->draw(_("Highscores"),
core::recti(x, y, 0, 0),
@ -1369,7 +1372,7 @@ void RaceResultGUI::backToLobby()
}
int current_x = x;
int current_y = y + (int)((i + 1) * m_distance_between_rows * 1.5f);
current_y = y + (int)((i + 1) * m_distance_between_rows * 1.5f);
const KartProperties* prop = kart_properties_manager->getKart(kart_name);
if (prop != NULL)
@ -1410,6 +1413,36 @@ void RaceResultGUI::backToLobby()
false, false, NULL, true /* ignoreRTL */);
}
}
if (race_manager->getMinorMode() != RaceManager::MINOR_MODE_SOCCER)
{
// display lap count
if (race_manager->modeHasLaps())
{
core::stringw laps = _("Laps: %i", race_manager->getNumLaps());
current_y += m_distance_between_rows * 0.8f * 2;
GUIEngine::getFont()->draw(laps, core::recti(x, current_y, 0, 0),
white_color, false, false, nullptr, true);
}
// display difficulty
const core::stringw& difficulty_name =
race_manager->getDifficultyName(race_manager->getDifficulty());
core::stringw difficulty_string = _("Difficulty: %s", difficulty_name);
current_y += m_distance_between_rows * 0.8f;
GUIEngine::getFont()->draw(difficulty_string, core::recti(x, current_y, 0, 0),
white_color, false, false, nullptr, true);
// show fastest lap
if (race_manager->modeHasLaps())
{
float best_lap_time = static_cast<LinearWorld*>(World::getWorld())->getFastestLap();
core::stringw best_lap_string = _("Best lap time: %s",
StringUtils::timeToString(best_lap_time).c_str());
current_y += m_distance_between_rows * 0.8f;
GUIEngine::getFont()->draw(best_lap_string,
core::recti(x, current_y, 0, 0), white_color, false, false,
nullptr, true);
}
}
}
// ----------------------------------------------------------------------------

View File

@ -191,7 +191,7 @@ private:
void addGPProgressWidget(GUIEngine::Widget* widget);
void displayGPProgress();
void cleanupGPProgress();
void displayHighScores();
void displayPostRaceInfo();
void displaySoccerResults();
void displayScreenShots();
irr::core::stringw getKartDisplayName(const AbstractKart *kart) const;

View File

@ -320,19 +320,201 @@
}
} // end namespace CrashReporting
#else
#elif ENABLE_LIBBFD
// --------------------- Unix version -----------------------
/* Derived from addr2line.c from binutils
addr2line.c -- convert addresses to line number and function name
Copyright (C) 1997-2015 Free Software Foundation, Inc.
Contributed by Ulrich Lauther <Ulrich.Lauther@mchp.siemens.de>
This file is part of GNU Binutils.
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 3, 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, 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
#define PACKAGE 1
#define PACKAGE_VERSION 1
#include <signal.h>
#include <execinfo.h>
#include <bfd.h>
#include "string_utils.hpp"
namespace CrashReporting
{
// BFD of current running STK binary, only can be useful
// if compiled with debug symbols
static bfd *m_stk_bfd = NULL;
// Symbol table
static asymbol **m_syms = NULL;
// Address in BFD to find file names or function name
static bfd_vma m_adress = 0;
static const char *m_file_name = NULL;
static const char *m_function_name = NULL;
static unsigned int m_line = 0;
static int m_found = 0;
// Look for an address in a section. This is called via
// bfd_map_over_sections.
void findAddressInSection(bfd* input, asection *section,
void *data ATTRIBUTE_UNUSED)
{
bfd_vma vma = 0;
bfd_size_type size = 0;
if (m_found)
return;
if ((bfd_get_section_flags(m_stk_bfd, section) & SEC_ALLOC) == 0)
return;
vma = bfd_get_section_vma(m_stk_bfd, section);
if (m_adress < vma)
return;
size = bfd_section_size(m_stk_bfd, section);
if (m_adress >= vma + size)
return;
m_found = bfd_find_nearest_line(m_stk_bfd, section, m_syms,
m_adress - vma, &m_file_name, &m_function_name, &m_line);
}
void signalHandler(int signal_no)
{
if (m_stk_bfd == NULL)
{
Log::warn("CrashReporting", "Failed loading or missing BFD of "
"STK binary, no backtrace available when reporting");
exit(0);
}
Log::error("CrashReporting", "STK has crashed! Backtrace info:");
std::string stack;
getCallStack(stack);
std::vector<std::string> each = StringUtils::split(stack, '\n');
for (unsigned int i = 3; i < each.size(); i++)
{
// Skip 3 stacks which are crash_reporting doing
Log::error("CrashReporting", "%s", each[i].c_str());
}
exit(0);
}
void loadSTKBFD()
{
const char* path = realpath("/proc/self/exe", NULL);
m_stk_bfd = bfd_openr(path, NULL);
free((void*)path);
if (m_stk_bfd == NULL)
{
return;
}
if (bfd_check_format(m_stk_bfd, bfd_archive))
{
m_stk_bfd = NULL;
return;
}
if (!bfd_check_format(m_stk_bfd, bfd_object))
{
m_stk_bfd = NULL;
return;
}
// Read in the symbol table.
unsigned int size = 0;
long symcount = 0;
if ((bfd_get_file_flags(m_stk_bfd) & HAS_SYMS) == 0)
{
m_stk_bfd = NULL;
return;
}
symcount = bfd_read_minisymbols(m_stk_bfd, false, (void**)&m_syms,
&size);
if (symcount == 0)
{
symcount = bfd_read_minisymbols(m_stk_bfd, true/* dynamic*/,
(void**)&m_syms, &size);
}
if (symcount < 0)
{
m_stk_bfd = NULL;
m_syms = NULL;
return;
}
}
void installHandlers()
{
// TODO!
loadSTKBFD();
struct sigaction sa = {0};
sa.sa_handler = &signalHandler;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART;
sigaction(SIGSEGV, &sa, NULL);
sigaction(SIGUSR1, &sa, NULL);
}
void getCallStack(std::string& callstack)
{
// TODO!
if (m_stk_bfd == NULL) return;
void *trace[16];
int i, trace_size = 0;
trace_size = backtrace(trace, 16);
for (i = 0; i < trace_size; i++)
{
m_adress = (bfd_vma)(trace[i]);
m_found = 0;
m_file_name = NULL;
m_function_name = NULL;
m_line = 0;
bfd_map_over_sections(m_stk_bfd, findAddressInSection, NULL);
if (m_found && m_file_name != NULL)
{
callstack = callstack + m_file_name + ":" +
StringUtils::toString(m_line) + "\n";
}
else if (m_function_name != NULL)
{
callstack = callstack + m_function_name + "\n";
}
else
callstack = callstack + "No symbol found" + "\n";
}
}
} // end namespace CrashReporting
#else
namespace CrashReporting
{
void installHandlers() {}
void getCallStack(std::string& callstack) {}
} // end namespace CrashReporting
#endif

View File

@ -26,8 +26,7 @@
#ifdef DEBUG
/** Switch this to 1 to get the backtrace of the leaks (slows down execution a little)
* Atm only implemented for OSX and windows. */
/** Define this to get the backtrace of the leaks (slows down execution a little) */
#undef GET_STACK_TRACE
Synchronised<int> m_lock_stacktrace;
@ -59,7 +58,7 @@ namespace MemoryLeaks
m_stack_size = backtrace(callstack, max_size);
m_stack = backtrace_symbols(callstack, m_stack_size);
# elif defined(WIN32)
# elif defined(WIN32) || ENABLE_LIBBFD
m_lock_stacktrace.lock();
CrashReporting::getCallStack(m_stack);
m_lock_stacktrace.unlock();
@ -79,7 +78,14 @@ namespace MemoryLeaks
void AllocatedObject::print() const
{
#ifdef GET_STACK_TRACE
# if defined(__APPLE__)
# if defined ENABLE_LIBBFD
std::vector<std::string> calls = StringUtils::split(m_stack, '\n');
// Ignore the first 3 entries
for (unsigned int i = 3; i < calls.size(); ++i)
{
Log::error("LeakCheck", " %s", calls[i].c_str());
}
# elif defined(__APPLE__)
for (int i = 0; i < m_stack_size; ++i)
{
Log::error("LeakCheck", " %s\n", m_stack[i]);

View File

@ -40,9 +40,9 @@ namespace MemoryLeaks
char **m_stack;
/** Keeps stacksize information if available (OSX only). */
int m_stack_size;
#elif defined(WIN32)
/** Keep the stack information the way it is returned by windows,
* a flat string, which will be split when printing it. */
#elif defined(WIN32) || ENABLE_LIBBFD
/** Keep the stack information the way it is returned by windows or
* libbfd, a flat string, which will be split when printing it. */
std::string m_stack;
#endif

View File

@ -151,7 +151,7 @@ Section "Main Section" SecMain
${!setIfUndefinedAndExists} EXEC_PATH ..\..\cmake_build\bin\RelWithDebInfo\*.*
${!setIfUndefinedAndExists} EXEC_PATH ..\..\cmake_build\bin\Release\*.*
File ${EXEC_PATH}
File /x *.ilk ${EXEC_PATH}
; Check various options for the editor. Note that us devs mostly use 'bld',
; but documented is the name 'build'
@ -242,7 +242,6 @@ Section "Uninstall"redist
DELETE /REBOOTOK "$INSTDIR\supertuxkart.exe"
DELETE /REBOOTOK "$INSTDIR\supertuxkart.ico"
DELETE /REBOOTOK "$INSTDIR\supertuxkart.icon"
DELETE /REBOOTOK "$INSTDIR\supertuxkart.ilk"
DELETE /REBOOTOK "$INSTDIR\supertuxkart.pdb"
DELETE /REBOOTOK "$INSTDIR\supertuxkart-editor.exe"
DELETE /REBOOTOK "$INSTDIR\supertuxkart-editor.ico"
@ -251,7 +250,6 @@ Section "Uninstall"redist
DELETE /REBOOTOK "$INSTDIR\vorbis.dll"
DELETE /REBOOTOK "$INSTDIR\wrap_oal.dll"
DELETE /REBOOTOK "$INSTDIR\zlib.dll"
DELETE /REBOOTOK "$INSTDIR\zlib.ilk"
DELETE /REBOOTOK "$INSTDIR\zlib.pdb"
DELETE /REBOOTOK "$INSTDIR\zlib1.dll"
@ -265,7 +263,7 @@ Section "Uninstall"redist
Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
Delete "$SMPROGRAMS\$MUI_TEMP\supertuxkart.lnk"
Delete "$SMPROGRAMS\$MUI_TEMP\supertuxkart-editor.lnk"
Delete "$SMPROGRAMS\$MUI_TEMP\supertuxkart-editor (beta).lnk"
;Delete empty start menu parent diretories
StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
@ -283,4 +281,4 @@ Section "Uninstall"redist
DeleteRegKey /ifempty HKCU "Software\SuperTuxKart"
SectionEnd
SectionEnd