Merge remote-tracking branch 'origin/win-64bit'
This commit is contained in:
commit
88e15147b8
@ -10,6 +10,13 @@ endif()
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
|
||||
include(CMakeDependentOption)
|
||||
|
||||
set(DEPENDENCIES "dependencies")
|
||||
# In case of 64-bit windows, use a different path for dependencies
|
||||
# so that both dependencies can be installed next to each other
|
||||
if ( WIN32 AND (CMAKE_SIZEOF_VOID_P EQUAL 8 ) )
|
||||
set(DEPENDENCIES "dependencies-64bit")
|
||||
endif()
|
||||
|
||||
include(BuildTypeSTKRelease)
|
||||
if (NOT CMAKE_BUILD_TYPE)
|
||||
message(STATUS "No build type selected, default to STKRelease")
|
||||
@ -62,9 +69,9 @@ set(STK_INSTALL_DATA_DIR "share/supertuxkart" CACHE
|
||||
|
||||
# These variables enable MSVC to find libraries located in "dependencies"
|
||||
if(WIN32)
|
||||
set(ENV{PATH} "$ENV{PATH};${PROJECT_SOURCE_DIR}/dependencies/include")
|
||||
set(ENV{LIB} ${PROJECT_SOURCE_DIR}/dependencies/lib)
|
||||
set(ENV{OPENALDIR} ${PROJECT_SOURCE_DIR}/dependencies)
|
||||
set(ENV{PATH} "$ENV{PATH};${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/include")
|
||||
set(ENV{LIB} ${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib)
|
||||
set(ENV{OPENALDIR} ${PROJECT_SOURCE_DIR}/${DEPENDENCIES})
|
||||
add_definitions(-D_IRR_STATIC_LIB_)
|
||||
add_definitions(-DNO_IRR_COMPILE_WITH_X11_)
|
||||
endif()
|
||||
@ -352,7 +359,7 @@ else()
|
||||
elseif(MINGW)
|
||||
set(PTHREAD_NAMES "winpthread-1" "libwinpthread-1" "pthreadGC2")
|
||||
endif()
|
||||
find_library(PTHREAD_LIBRARY NAMES pthread ${PTHREAD_NAMES} PATHS ${PROJECT_SOURCE_DIR}/dependencies/lib)
|
||||
find_library(PTHREAD_LIBRARY NAMES pthread ${PTHREAD_NAMES} PATHS ${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib)
|
||||
mark_as_advanced(PTHREAD_LIBRARY)
|
||||
|
||||
# Set data dir (absolute or relative to CMAKE_INSTALL_PREFIX)
|
||||
@ -374,9 +381,9 @@ endif()
|
||||
|
||||
# CURL
|
||||
if(MSVC)
|
||||
target_link_libraries(supertuxkart ${PROJECT_SOURCE_DIR}/dependencies/lib/libcurl.lib)
|
||||
target_link_libraries(supertuxkart ${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib/libcurl.lib)
|
||||
elseif(MINGW)
|
||||
target_link_libraries(supertuxkart ${PROJECT_SOURCE_DIR}/dependencies/lib/libcurldll.a)
|
||||
target_link_libraries(supertuxkart ${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib/libcurldll.a)
|
||||
else()
|
||||
find_package(CURL REQUIRED)
|
||||
include_directories(${CURL_INCLUDE_DIRS})
|
||||
@ -451,7 +458,7 @@ if(USE_WIIUSE)
|
||||
if(WIIUSE_BUILD)
|
||||
target_link_libraries(supertuxkart wiiuse)
|
||||
else()
|
||||
target_link_libraries(supertuxkart ${PROJECT_SOURCE_DIR}/dependencies/lib/wiiuse.lib)
|
||||
target_link_libraries(supertuxkart ${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib/wiiuse.lib)
|
||||
endif()
|
||||
else()
|
||||
target_link_libraries(supertuxkart wiiuse bluetooth)
|
||||
@ -464,7 +471,7 @@ if(MSVC OR MINGW)
|
||||
target_link_libraries(supertuxkart iphlpapi.lib)
|
||||
add_custom_command(TARGET supertuxkart POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
"${PROJECT_SOURCE_DIR}/dependencies/dll"
|
||||
"${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/dll"
|
||||
$<TARGET_FILE_DIR:supertuxkart>)
|
||||
add_custom_target(stkshaders SOURCES ${STK_SHADERS})
|
||||
endif()
|
||||
|
@ -10,8 +10,8 @@
|
||||
# Freetype library list
|
||||
|
||||
if(WIN32)
|
||||
find_path(FREETYPE_INCLUDE_DIRS NAMES freetype/freetype.h PATHS "${PROJECT_SOURCE_DIR}/dependencies/include")
|
||||
find_library(FREETYPE_LIBRARY NAMES freetype PATHS "${PROJECT_SOURCE_DIR}/dependencies/lib")
|
||||
find_path(FREETYPE_INCLUDE_DIRS NAMES freetype/freetype.h PATHS "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/include")
|
||||
find_library(FREETYPE_LIBRARY NAMES freetype PATHS "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib")
|
||||
set(FREETYPE_FOUND 1)
|
||||
set(FREETYPE_LIBRARIES ${FREETYPE_LIBRARY})
|
||||
elseif(APPLE)
|
||||
|
@ -24,8 +24,8 @@ else()
|
||||
endif()
|
||||
|
||||
if(NOT FRIBIDI_FOUND)
|
||||
find_path(FRIBIDI_INCLUDE_DIR NAMES fribidi/fribidi.h PATHS /Library/Frameworks/fribidi.framework/Headers "${PROJECT_SOURCE_DIR}/dependencies/include")
|
||||
find_library(FRIBIDI_LIBRARY NAMES fribidi PATHS /Library/Frameworks/fribidi.framework "${PROJECT_SOURCE_DIR}/dependencies/lib")
|
||||
find_path(FRIBIDI_INCLUDE_DIR NAMES fribidi/fribidi.h PATHS /Library/Frameworks/fribidi.framework/Headers "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/include")
|
||||
find_library(FRIBIDI_LIBRARY NAMES fribidi PATHS /Library/Frameworks/fribidi.framework "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib")
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Fribidi DEFAULT_MSG FRIBIDI_INCLUDE_DIR FRIBIDI_LIBRARY)
|
||||
|
@ -10,12 +10,12 @@
|
||||
# OggVorbis library list
|
||||
|
||||
|
||||
find_path(OGGVORBIS_OGG_INCLUDE_DIR NAMES ogg/ogg.h PATHS "${PROJECT_SOURCE_DIR}/dependencies/include")
|
||||
find_path(OGGVORBIS_VORBIS_INCLUDE_DIR NAMES vorbis/vorbisfile.h PATHS "${PROJECT_SOURCE_DIR}/dependencies/include")
|
||||
find_library(OGGVORBIS_OGG_LIBRARY NAMES ogg Ogg libogg PATHS "${PROJECT_SOURCE_DIR}/dependencies/lib")
|
||||
find_library(OGGVORBIS_VORBIS_LIBRARY NAMES vorbis Vorbis libvorbis PATHS "${PROJECT_SOURCE_DIR}/dependencies/lib")
|
||||
find_library(OGGVORBIS_VORBISFILE_LIBRARY NAMES vorbisfile libvorbisfile PATHS "${PROJECT_SOURCE_DIR}/dependencies/lib")
|
||||
find_library(OGGVORBIS_VORBISENC_LIBRARY NAMES vorbisenc libvorbisenc PATHS "${PROJECT_SOURCE_DIR}/dependencies/lib")
|
||||
find_path(OGGVORBIS_OGG_INCLUDE_DIR NAMES ogg/ogg.h PATHS "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/include")
|
||||
find_path(OGGVORBIS_VORBIS_INCLUDE_DIR NAMES vorbis/vorbisfile.h PATHS "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/include")
|
||||
find_library(OGGVORBIS_OGG_LIBRARY NAMES ogg Ogg libogg PATHS "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib")
|
||||
find_library(OGGVORBIS_VORBIS_LIBRARY NAMES vorbis Vorbis libvorbis PATHS "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib")
|
||||
find_library(OGGVORBIS_VORBISFILE_LIBRARY NAMES vorbisfile libvorbisfile PATHS "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib")
|
||||
find_library(OGGVORBIS_VORBISENC_LIBRARY NAMES vorbisenc libvorbisenc PATHS "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib")
|
||||
|
||||
if (APPLE)
|
||||
set(OGGVORBIS_OGG_INCLUDE_DIR "/Library/Frameworks/Ogg.framework/Headers/")
|
||||
|
@ -213,7 +213,7 @@ protected:
|
||||
|
||||
int *intPtr=0;
|
||||
short *shtPtr=0;
|
||||
#ifdef __MINGW64__
|
||||
#if defined(__MINGW64__) || defined(_WIN64)
|
||||
char *cp = 0;int dataLen =0;intptr_t nr=0;
|
||||
#else
|
||||
char *cp = 0;int dataLen =0;long nr=0;
|
||||
@ -251,7 +251,7 @@ protected:
|
||||
cp++;
|
||||
}
|
||||
{
|
||||
#ifdef __MINGW64__
|
||||
#if defined(__MINGW64__) || defined(_WIN64)
|
||||
nr= (intptr_t)cp;
|
||||
#else
|
||||
nr= (long)cp;
|
||||
@ -290,7 +290,7 @@ protected:
|
||||
}
|
||||
|
||||
{
|
||||
#ifdef __MINGW64__
|
||||
#if defined(__MINGW64__) || defined(_WIN64)
|
||||
nr= (intptr_t)cp;
|
||||
#else
|
||||
nr= (long)cp;
|
||||
|
@ -529,7 +529,7 @@ void SFXManager::loadSfx()
|
||||
delete root;
|
||||
|
||||
// Now load them in parallel
|
||||
const int max = m_all_sfx_types.size();
|
||||
const int max = (int)m_all_sfx_types.size();
|
||||
SFXBuffer **array = new SFXBuffer *[max];
|
||||
i = 0;
|
||||
|
||||
|
@ -172,7 +172,7 @@ void SavedGrandPrix::loadKarts(std::vector<RaceManager::KartStatus> & kart_list)
|
||||
else
|
||||
{
|
||||
// Get correct player
|
||||
for(unsigned int x = kart_list.size()-m_player_karts;
|
||||
for(unsigned int x = (unsigned int)kart_list.size()-m_player_karts;
|
||||
x < kart_list.size(); x++)
|
||||
{
|
||||
if(kart_list[x].m_local_player_id == m_karts[i].m_local_player_id)
|
||||
|
@ -122,7 +122,7 @@ void GroupUserConfigParam::writeInner(std::ofstream& stream, int level) const
|
||||
{
|
||||
std::string tab(level * 4,' ');
|
||||
for(int i = 0; i < level; i++) tab =+ " ";
|
||||
const int children_amount = m_attributes.size();
|
||||
const int children_amount = (int)m_attributes.size();
|
||||
|
||||
stream << " " << tab.c_str() << "<" << m_param_name.c_str() << "\n";
|
||||
|
||||
@ -144,7 +144,7 @@ void GroupUserConfigParam::findYourDataInAChildOf(const XMLNode* node)
|
||||
return;
|
||||
}
|
||||
|
||||
const int attributes_amount = m_attributes.size();
|
||||
const int attributes_amount = (int)m_attributes.size();
|
||||
for (int n=0; n<attributes_amount; n++)
|
||||
{
|
||||
m_attributes[n]->findYourDataInAnAttributeOf(child);
|
||||
@ -246,7 +246,7 @@ ListUserConfigParam<T, U>::ListUserConfigParam(const char* param_name,
|
||||
template<typename T, typename U>
|
||||
void ListUserConfigParam<T, U>::write(std::ofstream& stream) const
|
||||
{
|
||||
const int elts_amount = m_elements.size();
|
||||
const int elts_amount = (int)m_elements.size();
|
||||
|
||||
// comment
|
||||
if(m_comment.size() > 0) stream << " <!-- " << m_comment.c_str();
|
||||
@ -728,7 +728,7 @@ bool UserConfig::loadConfig()
|
||||
UserConfigParams::m_saved_grand_prix_list.clearAndDeleteAll();
|
||||
std::vector<XMLNode*> saved_gps;
|
||||
root->getNodes("SavedGP", saved_gps);
|
||||
const int gp_amount = saved_gps.size();
|
||||
const int gp_amount = (int)saved_gps.size();
|
||||
for (int i=0; i<gp_amount; i++)
|
||||
{
|
||||
UserConfigParams::m_saved_grand_prix_list.push_back(
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
FT_Face getFace(unsigned int i) const;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Return the total TTF files loaded. */
|
||||
unsigned int getTotalFaces() const { return m_faces.size(); }
|
||||
unsigned int getTotalFaces() const { return (unsigned int)m_faces.size(); }
|
||||
|
||||
}; // FaceTTF
|
||||
|
||||
|
@ -55,7 +55,8 @@ Camera::CameraType Camera::m_default_type = Camera::CM_TYPE_NORMAL;
|
||||
*/
|
||||
Camera* Camera::createCamera(AbstractKart* kart)
|
||||
{
|
||||
Camera *camera = createCamera(m_all_cameras.size(), m_default_type, kart);
|
||||
Camera *camera = createCamera((int)m_all_cameras.size(),
|
||||
m_default_type, kart );
|
||||
m_all_cameras.push_back(camera);
|
||||
return camera;
|
||||
} // createCamera(kart)
|
||||
|
@ -74,13 +74,13 @@ template<typename T>
|
||||
void FillInstances_impl(const InstanceList& instance_list,
|
||||
T * instance_buffer,
|
||||
DrawElementsIndirectCommand *command_buffer,
|
||||
size_t &instance_buffer_offset,
|
||||
size_t &command_buffer_offset,
|
||||
size_t &poly_count)
|
||||
unsigned int &instance_buffer_offset,
|
||||
unsigned int &command_buffer_offset,
|
||||
unsigned int&poly_count)
|
||||
{
|
||||
// Should never be empty
|
||||
GLMesh *mesh = instance_list.m_mesh;
|
||||
size_t initial_offset = instance_buffer_offset;
|
||||
unsigned int initial_offset = instance_buffer_offset;
|
||||
|
||||
for (unsigned i = 0; i < instance_list.m_instance_settings.size(); i++)
|
||||
{
|
||||
@ -92,7 +92,7 @@ void FillInstances_impl(const InstanceList& instance_list,
|
||||
DrawElementsIndirectCommand &CurrentCommand = command_buffer[command_buffer_offset++];
|
||||
CurrentCommand.baseVertex = mesh->vaoBaseVertex;
|
||||
CurrentCommand.count = mesh->IndexCount;
|
||||
CurrentCommand.firstIndex = mesh->vaoOffset / 2;
|
||||
CurrentCommand.firstIndex = GLuint(mesh->vaoOffset / 2);
|
||||
CurrentCommand.baseInstance = initial_offset;
|
||||
CurrentCommand.instanceCount = instance_buffer_offset - initial_offset;
|
||||
|
||||
@ -145,12 +145,12 @@ protected:
|
||||
DrawElementsIndirectCommand *m_draw_indirect_cmd;
|
||||
|
||||
std::array<std::vector<GLMesh *>, N> m_meshes;
|
||||
std::array<size_t,N> m_offset;
|
||||
std::array<size_t,N> m_size;
|
||||
std::array<unsigned int,N> m_offset;
|
||||
std::array<unsigned int,N> m_size;
|
||||
|
||||
size_t m_poly_count;
|
||||
size_t m_instance_buffer_offset;
|
||||
size_t m_command_buffer_offset;
|
||||
unsigned int m_poly_count;
|
||||
unsigned int m_instance_buffer_offset;
|
||||
unsigned int m_command_buffer_offset;
|
||||
|
||||
void clearMeshes();
|
||||
void mapIndirectBuffer();
|
||||
@ -230,7 +230,7 @@ public:
|
||||
CommandBuffer();
|
||||
virtual ~CommandBuffer() { glDeleteBuffers(1, &m_draw_indirect_cmd_id); }
|
||||
|
||||
inline size_t getPolyCount() const {return m_poly_count;}
|
||||
inline unsigned int getPolyCount() const {return m_poly_count;}
|
||||
|
||||
inline void bind() const
|
||||
{
|
||||
|
@ -964,7 +964,7 @@ int32_t DrawCalls::getSkinningOffset() const
|
||||
{
|
||||
return std::accumulate(m_mesh_for_skinning.begin(),
|
||||
m_mesh_for_skinning.end(), 0, []
|
||||
(const size_t previous, const STKAnimatedMesh* m)
|
||||
(const unsigned int previous, const STKAnimatedMesh* m)
|
||||
{ return previous + m->getTotalJoints(); });
|
||||
} // getSkinningOffset
|
||||
#endif // !SERVER_ONLY
|
||||
|
@ -226,8 +226,8 @@ unsigned GPUTimer::elapsedTimeus()
|
||||
|
||||
FrameBuffer::FrameBuffer() {}
|
||||
|
||||
FrameBuffer::FrameBuffer(const std::vector<GLuint> &RTTs, size_t w, size_t h,
|
||||
bool layered)
|
||||
FrameBuffer::FrameBuffer(const std::vector<GLuint> &RTTs, unsigned int w,
|
||||
unsigned int h, bool layered)
|
||||
: fbolayer(0), RenderTargets(RTTs), DepthTexture(0),
|
||||
width(w), height(h)
|
||||
{
|
||||
@ -248,8 +248,8 @@ FrameBuffer::FrameBuffer(const std::vector<GLuint> &RTTs, size_t w, size_t h,
|
||||
assert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE_EXT);
|
||||
}
|
||||
|
||||
FrameBuffer::FrameBuffer(const std::vector<GLuint> &RTTs, GLuint DS, size_t w,
|
||||
size_t h, bool layered)
|
||||
FrameBuffer::FrameBuffer(const std::vector<GLuint> &RTTs, GLuint DS, unsigned int w,
|
||||
unsigned int h, bool layered)
|
||||
: fbolayer(0), RenderTargets(RTTs), DepthTexture(DS), width(w),
|
||||
height(h)
|
||||
{
|
||||
|
@ -66,18 +66,18 @@ private:
|
||||
GLuint fbo, fbolayer;
|
||||
std::vector<GLuint> RenderTargets;
|
||||
GLuint DepthTexture;
|
||||
size_t width, height;
|
||||
unsigned int width, height;
|
||||
public:
|
||||
FrameBuffer();
|
||||
FrameBuffer(const std::vector <GLuint> &RTTs, size_t w, size_t h, bool layered = false);
|
||||
FrameBuffer(const std::vector <GLuint> &RTTs, GLuint DS, size_t w, size_t h, bool layered = false);
|
||||
FrameBuffer(const std::vector <GLuint> &RTTs, unsigned int w, unsigned int h, bool layered = false);
|
||||
FrameBuffer(const std::vector <GLuint> &RTTs, GLuint DS, unsigned int w, unsigned int h, bool layered = false);
|
||||
~FrameBuffer();
|
||||
void bind() const;
|
||||
void bindLayer(unsigned) const;
|
||||
const std::vector<GLuint> &getRTT() const { return RenderTargets; }
|
||||
GLuint getDepthTexture() const { assert(DepthTexture); return DepthTexture; }
|
||||
size_t getWidth() const { return width; }
|
||||
size_t getHeight() const { return height; }
|
||||
unsigned int getWidth() const { return width; }
|
||||
unsigned int getHeight() const { return height; }
|
||||
static void Blit(const FrameBuffer &Src, const FrameBuffer &Dst, GLbitfield mask = GL_COLOR_BUFFER_BIT, GLenum filter = GL_NEAREST);
|
||||
void BlitToDefault(size_t, size_t, size_t, size_t);
|
||||
|
||||
|
@ -261,7 +261,7 @@ public:
|
||||
/** If *this < other. */
|
||||
bool operator< (const Version &other) const
|
||||
{
|
||||
unsigned int min_n = std::min(m_version.size(), other.m_version.size());
|
||||
unsigned int min_n = (unsigned int)std::min(m_version.size(), other.m_version.size());
|
||||
for (unsigned int i = 0; i<min_n; i++)
|
||||
{
|
||||
if (m_version[i] > other.m_version[i]) return false;
|
||||
@ -276,7 +276,7 @@ public:
|
||||
/** If *this <= other. */
|
||||
bool operator<= (const Version &other) const
|
||||
{
|
||||
unsigned int min_n = std::min(m_version.size(), other.m_version.size());
|
||||
unsigned int min_n = (unsigned int)std::min(m_version.size(), other.m_version.size());
|
||||
for (unsigned int i = 0; i<min_n; i++)
|
||||
{
|
||||
if (m_version[i] > other.m_version[i]) return false;
|
||||
|
@ -317,7 +317,7 @@ public:
|
||||
{
|
||||
if (m_hue_settings.empty())
|
||||
return 0.0f;
|
||||
const unsigned int hue = m_random_hue.get(m_hue_settings.size());
|
||||
const unsigned int hue = m_random_hue.get((int)m_hue_settings.size());
|
||||
assert(hue < m_hue_settings.size());
|
||||
return m_hue_settings[hue];
|
||||
}
|
||||
|
@ -998,7 +998,7 @@ void PostProcessing::renderGaussian3Blur(const FrameBuffer &in_fbo,
|
||||
// ----------------------------------------------------------------------------
|
||||
void PostProcessing::renderGaussian6BlurLayer(const FrameBuffer &in_fbo,
|
||||
const FrameBuffer &scalar_fbo,
|
||||
size_t layer, float sigma_h,
|
||||
unsigned int layer, float sigma_h,
|
||||
float sigma_v) const
|
||||
{
|
||||
#if !defined(USE_GLES2)
|
||||
|
@ -93,7 +93,7 @@ public:
|
||||
void renderHorizontalBlur(const FrameBuffer &in_fbo, const FrameBuffer &auxiliary) const;
|
||||
|
||||
void renderGaussian6BlurLayer(const FrameBuffer &in_fbo, const FrameBuffer &scalar_fbo,
|
||||
size_t layer, float sigmaH, float sigmaV) const;
|
||||
unsigned int layer, float sigmaH, float sigmaV) const;
|
||||
void renderGaussian17TapBlur(const FrameBuffer &in_fbo,
|
||||
const FrameBuffer &auxiliary,
|
||||
const FrameBuffer &linear_depth) const;
|
||||
|
@ -76,7 +76,10 @@ public:
|
||||
*/
|
||||
bool isStatic() const { return m_dynamic_hue.empty(); }
|
||||
// ------------------------------------------------------------------------
|
||||
unsigned int getNumberOfHue() const { return m_dynamic_hue.size(); }
|
||||
unsigned int getNumberOfHue() const
|
||||
{
|
||||
return (unsigned int)m_dynamic_hue.size();
|
||||
} // getNumberOfHue
|
||||
// ------------------------------------------------------------------------
|
||||
float getDynamicHue(unsigned int hue) const
|
||||
{
|
||||
|
@ -25,7 +25,9 @@
|
||||
#include "graphics/materials.hpp"
|
||||
#include "utils/log.hpp"
|
||||
|
||||
static GLuint generateRTT3D(GLenum target, size_t w, size_t h, size_t d, GLint internalFormat, GLint format, GLint type, unsigned mipmaplevel = 1)
|
||||
static GLuint generateRTT3D(GLenum target, unsigned int w, unsigned int h,
|
||||
unsigned int d, GLint internalFormat, GLint format,
|
||||
GLint type, unsigned mipmaplevel = 1)
|
||||
{
|
||||
GLuint result;
|
||||
glGenTextures(1, &result);
|
||||
@ -49,10 +51,10 @@ static GLuint generateRTT(const core::dimension2du &res, GLint internalFormat, G
|
||||
return result;
|
||||
}
|
||||
|
||||
RTT::RTT(size_t width, size_t height, float rtt_scale)
|
||||
RTT::RTT(unsigned int width, unsigned int height, float rtt_scale)
|
||||
{
|
||||
m_width = size_t(width * rtt_scale);
|
||||
m_height = size_t(height * rtt_scale);
|
||||
m_width = (unsigned int)(width * rtt_scale);
|
||||
m_height = (unsigned int)(height * rtt_scale);
|
||||
m_shadow_FBO = NULL;
|
||||
m_RH_FBO = NULL;
|
||||
m_RSM = NULL;
|
||||
|
@ -144,11 +144,11 @@ enum TypeRTT : unsigned int
|
||||
class RTT
|
||||
{
|
||||
public:
|
||||
RTT(size_t width, size_t height, float rtt_scale = 1.0f);
|
||||
RTT(unsigned int width, unsigned int height, float rtt_scale = 1.0f);
|
||||
~RTT();
|
||||
|
||||
size_t getWidth () const { return m_width ; }
|
||||
size_t getHeight() const { return m_height; }
|
||||
unsigned int getWidth () const { return m_width ; }
|
||||
unsigned int getHeight() const { return m_height; }
|
||||
|
||||
FrameBuffer &getShadowFrameBuffer() { return *m_shadow_FBO; }
|
||||
FrameBuffer &getRadianceHintFrameBuffer() { return *m_RH_FBO; }
|
||||
@ -165,8 +165,8 @@ private:
|
||||
std::vector<uint64_t> m_prefilled_handles;
|
||||
unsigned DepthStencilTexture;
|
||||
|
||||
size_t m_width;
|
||||
size_t m_height;
|
||||
unsigned int m_width;
|
||||
unsigned int m_height;
|
||||
|
||||
unsigned shadowColorTex, shadowDepthTex;
|
||||
unsigned RSM_Color, RSM_Normal, RSM_Depth;
|
||||
|
@ -187,7 +187,7 @@ void ShaderBasedRenderer::uploadLightingData() const
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void ShaderBasedRenderer::computeMatrixesAndCameras(scene::ICameraSceneNode *const camnode,
|
||||
size_t width, size_t height)
|
||||
unsigned int width, unsigned int height)
|
||||
{
|
||||
m_current_screen_size = core::vector2df((float)width, (float)height);
|
||||
m_shadow_matrices.computeMatrixesAndCameras(camnode, width, height,
|
||||
@ -668,8 +668,8 @@ ShaderBasedRenderer::~ShaderBasedRenderer()
|
||||
void ShaderBasedRenderer::onLoadWorld()
|
||||
{
|
||||
const core::recti &viewport = Camera::getCamera(0)->getViewport();
|
||||
size_t width = viewport.LowerRightCorner.X - viewport.UpperLeftCorner.X;
|
||||
size_t height = viewport.LowerRightCorner.Y - viewport.UpperLeftCorner.Y;
|
||||
unsigned int width = viewport.LowerRightCorner.X - viewport.UpperLeftCorner.X;
|
||||
unsigned int height = viewport.LowerRightCorner.Y - viewport.UpperLeftCorner.Y;
|
||||
RTT* rtts = new RTT(width, height, CVS->isDefferedEnabled() ?
|
||||
UserConfigParams::m_scale_rtts_factor : 1.0f);
|
||||
setRTT(rtts);
|
||||
|
@ -52,7 +52,7 @@ private:
|
||||
/** Static glowing things are loaded once per track.
|
||||
* Glowing items can appear ordisappear each frame */
|
||||
std::vector<GlowData> m_glowing;
|
||||
size_t m_nb_static_glowing;
|
||||
unsigned int m_nb_static_glowing;
|
||||
|
||||
void setOverrideMaterial();
|
||||
|
||||
@ -64,7 +64,7 @@ private:
|
||||
void uploadLightingData() const;
|
||||
|
||||
void computeMatrixesAndCameras(scene::ICameraSceneNode * const camnode,
|
||||
size_t width, size_t height);
|
||||
unsigned int width, unsigned int height);
|
||||
|
||||
void resetShadowCamNodes(){m_shadow_matrices.resetShadowCamNodes();}
|
||||
|
||||
|
@ -195,7 +195,7 @@ GLuint ShaderFilesManager::loadShader(const std::string &file, unsigned type)
|
||||
Log::info("ShaderFilesManager", "Compiling shader : %s", file.c_str());
|
||||
const std::string &source = code.str();
|
||||
char const *source_pointer = source.c_str();
|
||||
int len = source.size();
|
||||
int len = (int)source.size();
|
||||
glShaderSource(id, 1, &source_pointer, &len);
|
||||
glCompileShader(id);
|
||||
|
||||
|
@ -206,7 +206,7 @@ void Skybox::generateSpecularCubemap()
|
||||
{
|
||||
glGenTextures(1, &m_specular_probe);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, m_specular_probe);
|
||||
size_t cubemap_size = 256;
|
||||
unsigned int cubemap_size = 256;
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
#if !defined(USE_GLES2)
|
||||
|
@ -233,7 +233,8 @@ namespace
|
||||
* \param sh_rgba The 6 cubemap faces (sRGB byte textures)
|
||||
* \param edge_size Size of the cubemap face
|
||||
*/
|
||||
void SphericalHarmonics::generateSphericalHarmonics(unsigned char *sh_rgba[6], size_t edge_size)
|
||||
void SphericalHarmonics::generateSphericalHarmonics(unsigned char *sh_rgba[6],
|
||||
unsigned int edge_size)
|
||||
{
|
||||
|
||||
#if SIMD_SSE2_SUPPORT
|
||||
@ -644,7 +645,7 @@ void SphericalHarmonics::printCoeff() {
|
||||
* \param Yml The sphericals harmonics functions values
|
||||
* \param[out] output The environment map texels values
|
||||
*/
|
||||
void SphericalHarmonics::unprojectSH(size_t width, size_t height,
|
||||
void SphericalHarmonics::unprojectSH(unsigned int width, unsigned int height,
|
||||
float *Y00[], float *Y1minus1[], float *Y10[],
|
||||
float *Y11[], float *Y2minus2[], float *Y2minus1[],
|
||||
float *Y20[], float *Y21[], float *Y22[],
|
||||
|
@ -49,7 +49,7 @@ private:
|
||||
/** The spherical harmonics coefficients */
|
||||
SHCoefficients *m_SH_coeff;
|
||||
|
||||
void generateSphericalHarmonics(unsigned char *sh_rgba[6], size_t edge_size);
|
||||
void generateSphericalHarmonics(unsigned char *sh_rgba[6], unsigned int edge_size);
|
||||
|
||||
public:
|
||||
SphericalHarmonics(const std::vector<irr::video::ITexture *> &spherical_harmonics_textures);
|
||||
@ -65,7 +65,7 @@ public:
|
||||
|
||||
void printCoeff();
|
||||
|
||||
void unprojectSH (size_t width, size_t height,
|
||||
void unprojectSH (unsigned int width, unsigned int height,
|
||||
float *Y00[], float *Y1minus1[], float *Y10[],
|
||||
float *Y11[], float *Y2minus2[], float *Y2minus1[],
|
||||
float * Y20[], float *Y21[], float *Y22[],
|
||||
|
@ -52,11 +52,11 @@ struct GLMesh
|
||||
video::ITexture *textures[8];
|
||||
GLenum PrimitiveType;
|
||||
GLenum IndexType;
|
||||
size_t IndexCount;
|
||||
size_t Stride;
|
||||
unsigned int IndexCount;
|
||||
unsigned int Stride;
|
||||
core::vector2df texture_trans;
|
||||
size_t vaoBaseVertex;
|
||||
size_t vaoOffset;
|
||||
unsigned int vaoBaseVertex;
|
||||
intptr_t vaoOffset;
|
||||
video::E_VERTEX_TYPE VAOType;
|
||||
uint64_t TextureHandles[8];
|
||||
scene::IMeshBuffer *mb;
|
||||
@ -72,7 +72,7 @@ GLMesh allocateMeshBuffer(scene::IMeshBuffer* mb,
|
||||
const std::string& debug_name,
|
||||
RenderInfo* render_info);
|
||||
void fillLocalBuffer(GLMesh &, scene::IMeshBuffer* mb);
|
||||
video::E_VERTEX_TYPE getVTXTYPEFromStride(size_t stride);
|
||||
video::E_VERTEX_TYPE getVTXTYPEFromStride(unsigned int stride);
|
||||
GLuint createVAO(GLuint vbo, GLuint idx, video::E_VERTEX_TYPE type);
|
||||
core::matrix4 computeMVP(const core::matrix4 &ModelViewProjectionMatrix);
|
||||
bool isObject(video::E_MATERIAL_TYPE type);
|
||||
|
@ -158,7 +158,7 @@ void STKMeshSceneNode::drawGlow(const GLMesh &mesh)
|
||||
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
unsigned int count = mesh.IndexCount;
|
||||
ColorizeShader::getInstance()->setUniforms(AbsoluteTransformation, video::SColorf(glowcolor.getRed() / 255.f, glowcolor.getGreen() / 255.f, glowcolor.getBlue() / 255.f));
|
||||
glDrawElementsBaseVertex(ptype, count, itype, (GLvoid *)mesh.vaoOffset, mesh.vaoBaseVertex);
|
||||
}
|
||||
@ -352,7 +352,7 @@ void STKMeshSceneNode::render()
|
||||
GLMesh &mesh = GLmeshes[i];
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
unsigned int count = mesh.IndexCount;
|
||||
|
||||
#if !defined(USE_GLES2)
|
||||
if (CVS->isAZDOEnabled())
|
||||
@ -392,7 +392,7 @@ void STKMeshSceneNode::render()
|
||||
GLMesh &mesh = GLmeshes[i];
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
unsigned int count = mesh.IndexCount;
|
||||
|
||||
#if !defined(USE_GLES2)
|
||||
if (CVS->isAZDOEnabled())
|
||||
@ -484,7 +484,7 @@ void STKMeshSceneNode::render()
|
||||
irr_driver->increaseObjectCount();
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
unsigned int count = mesh.IndexCount;
|
||||
|
||||
// This function is only called once per frame - thus no need for setters.
|
||||
const float fogmax = track->getFogMax();
|
||||
@ -531,7 +531,7 @@ void STKMeshSceneNode::render()
|
||||
GLMesh &mesh = GLmeshes[i];
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
size_t count = mesh.IndexCount;
|
||||
unsigned int count = mesh.IndexCount;
|
||||
|
||||
#if !defined(USE_GLES2)
|
||||
if (CVS->isAZDOEnabled())
|
||||
|
@ -65,7 +65,7 @@ STKTexture::STKTexture(const std::string& path, TexConfig* tc, bool no_upload)
|
||||
} // STKTexture
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
STKTexture::STKTexture(uint8_t* data, const std::string& name, size_t size,
|
||||
STKTexture::STKTexture(uint8_t* data, const std::string& name, unsigned int size,
|
||||
bool single_channel, bool delete_ttl)
|
||||
: video::ITexture(name.c_str()), m_texture_handle(0),
|
||||
m_single_channel(single_channel), m_tex_config(NULL),
|
||||
|
@ -90,7 +90,7 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
STKTexture(const std::string& path, TexConfig* tc, bool no_upload = false);
|
||||
// ------------------------------------------------------------------------
|
||||
STKTexture(uint8_t* data, const std::string& name, size_t size,
|
||||
STKTexture(uint8_t* data, const std::string& name, unsigned int size,
|
||||
bool single_channel = false, bool delete_ttl = false);
|
||||
// ------------------------------------------------------------------------
|
||||
STKTexture(video::IImage* img, const std::string& name);
|
||||
|
@ -83,7 +83,9 @@ VAOManager::~VAOManager()
|
||||
}
|
||||
|
||||
static void
|
||||
resizeBufferIfNecessary(size_t &lastIndex, size_t newLastIndex, size_t& bufferSize, size_t stride, GLenum type, GLuint &id, void *&Pointer)
|
||||
resizeBufferIfNecessary(unsigned int &lastIndex, unsigned int newLastIndex,
|
||||
unsigned int &bufferSize, unsigned int stride, GLenum type,
|
||||
GLuint &id, void *&Pointer)
|
||||
{
|
||||
if (newLastIndex >= bufferSize)
|
||||
{
|
||||
@ -116,11 +118,14 @@ resizeBufferIfNecessary(size_t &lastIndex, size_t newLastIndex, size_t& bufferSi
|
||||
lastIndex = newLastIndex;
|
||||
}
|
||||
|
||||
void VAOManager::regenerateBuffer(enum VTXTYPE tp, size_t newlastvertex, size_t newlastindex)
|
||||
void VAOManager::regenerateBuffer(enum VTXTYPE tp, unsigned int newlastvertex,
|
||||
unsigned int newlastindex)
|
||||
{
|
||||
glBindVertexArray(0);
|
||||
resizeBufferIfNecessary(last_vertex[tp], newlastvertex, RealVBOSize[tp], getVertexPitch(tp), GL_ARRAY_BUFFER, vbo[tp], VBOPtr[tp]);
|
||||
resizeBufferIfNecessary(last_index[tp], newlastindex, RealIBOSize[tp], sizeof(u16), GL_ELEMENT_ARRAY_BUFFER, ibo[tp], IBOPtr[tp]);
|
||||
resizeBufferIfNecessary(last_vertex[tp], newlastvertex, RealVBOSize[tp],
|
||||
getVertexPitch(tp), GL_ARRAY_BUFFER, vbo[tp], VBOPtr[tp]);
|
||||
resizeBufferIfNecessary(last_index[tp], newlastindex, RealIBOSize[tp],
|
||||
sizeof(u16), GL_ELEMENT_ARRAY_BUFFER, ibo[tp], IBOPtr[tp]);
|
||||
}
|
||||
|
||||
void VAOManager::regenerateVAO(enum VTXTYPE tp)
|
||||
@ -265,7 +270,7 @@ void VAOManager::regenerateInstancedVAO()
|
||||
|
||||
}
|
||||
|
||||
size_t VAOManager::getVertexPitch(enum VTXTYPE tp) const
|
||||
unsigned int VAOManager::getVertexPitch(enum VTXTYPE tp) const
|
||||
{
|
||||
switch (tp)
|
||||
{
|
||||
@ -318,8 +323,8 @@ irr::video::E_VERTEX_TYPE VAOManager::getVertexType(enum VTXTYPE tp)
|
||||
|
||||
void VAOManager::append(scene::IMeshBuffer *mb, VTXTYPE tp)
|
||||
{
|
||||
size_t old_vtx_cnt = last_vertex[tp];
|
||||
size_t old_idx_cnt = last_index[tp];
|
||||
unsigned int old_vtx_cnt = last_vertex[tp];
|
||||
unsigned int old_idx_cnt = last_index[tp];
|
||||
|
||||
regenerateBuffer(tp, old_vtx_cnt + mb->getVertexCount(), old_idx_cnt + mb->getIndexCount());
|
||||
#if !defined(USE_GLES2)
|
||||
|
@ -194,16 +194,16 @@ class VAOManager : public Singleton<VAOManager>
|
||||
GLuint instance_vbo[InstanceTypeCount];
|
||||
void *Ptr[InstanceTypeCount];
|
||||
void *VBOPtr[VTXTYPE_COUNT], *IBOPtr[VTXTYPE_COUNT];
|
||||
size_t RealVBOSize[VTXTYPE_COUNT], RealIBOSize[VTXTYPE_COUNT];
|
||||
size_t last_vertex[VTXTYPE_COUNT], last_index[VTXTYPE_COUNT];
|
||||
unsigned int RealVBOSize[VTXTYPE_COUNT], RealIBOSize[VTXTYPE_COUNT];
|
||||
unsigned int last_vertex[VTXTYPE_COUNT], last_index[VTXTYPE_COUNT];
|
||||
std::unordered_map<irr::scene::IMeshBuffer*, unsigned> mappedBaseVertex[VTXTYPE_COUNT], mappedBaseIndex[VTXTYPE_COUNT];
|
||||
std::map<std::pair<irr::video::E_VERTEX_TYPE, InstanceType>, GLuint> InstanceVAO;
|
||||
|
||||
void cleanInstanceVAOs();
|
||||
void regenerateBuffer(enum VTXTYPE, size_t, size_t);
|
||||
void regenerateBuffer(enum VTXTYPE, unsigned int, unsigned int);
|
||||
void regenerateVAO(enum VTXTYPE);
|
||||
void regenerateInstancedVAO();
|
||||
size_t getVertexPitch(enum VTXTYPE) const;
|
||||
unsigned int getVertexPitch(enum VTXTYPE) const;
|
||||
VTXTYPE getVTXTYPE(irr::video::E_VERTEX_TYPE type);
|
||||
irr::video::E_VERTEX_TYPE getVertexType(enum VTXTYPE tp);
|
||||
void append(irr::scene::IMeshBuffer *, VTXTYPE tp);
|
||||
|
@ -170,7 +170,10 @@ namespace GUIEngine
|
||||
// --------------------------------------------------------------------
|
||||
/** Returns the number of screens on the stack. Is used to decide
|
||||
* if exiting a screen would cause STK to end or not. */
|
||||
unsigned int getMenuStackSize() const { return m_menu_stack.size(); }
|
||||
unsigned int getMenuStackSize() const
|
||||
{
|
||||
return (unsigned int)m_menu_stack.size();
|
||||
}
|
||||
}; // Class AbstractStateManager
|
||||
|
||||
} // GUIEngine
|
||||
|
@ -318,7 +318,7 @@ void SpinnerWidget::addLabel(stringw label)
|
||||
{
|
||||
m_labels.push_back(label);
|
||||
m_min = 0;
|
||||
m_max = m_labels.size()-1;
|
||||
m_max = (int)m_labels.size()-1;
|
||||
|
||||
if (m_element != NULL) setValue(0);
|
||||
}
|
||||
|
@ -1038,7 +1038,7 @@ EventPropagation InputManager::input(const SEvent& event)
|
||||
else if (event.EventType == EET_TOUCH_INPUT_EVENT)
|
||||
{
|
||||
MultitouchDevice* device = m_device_manager->getMultitouchDevice();
|
||||
unsigned int id = event.TouchInput.ID;
|
||||
unsigned int id = (unsigned int)event.TouchInput.ID;
|
||||
|
||||
if (device != NULL && id < device->m_events.size())
|
||||
{
|
||||
|
@ -114,7 +114,7 @@ public:
|
||||
void reset();
|
||||
|
||||
/** Returns the number of created buttons */
|
||||
unsigned int getButtonsCount() {return m_buttons.size();}
|
||||
unsigned int getButtonsCount() { return (unsigned int)m_buttons.size();}
|
||||
|
||||
/** Returns pointer to the selected button */
|
||||
MultitouchButton* getButton(unsigned int i) {return m_buttons.at(i);}
|
||||
|
@ -828,7 +828,7 @@ float Kart::getSpeedForTurnRadius(float radius) const
|
||||
{
|
||||
InterpolationArray turn_angle_at_speed = m_kart_properties->getTurnRadius();
|
||||
// Convert the turn radius into turn angle
|
||||
for(std::size_t i = 0; i < turn_angle_at_speed.size(); i++)
|
||||
for(int i = 0; i < (int)turn_angle_at_speed.size(); i++)
|
||||
turn_angle_at_speed.setY(i, sin(m_kart_properties->getWheelBase() /
|
||||
turn_angle_at_speed.getY(i)));
|
||||
|
||||
@ -842,7 +842,7 @@ float Kart::getMaxSteerAngle(float speed) const
|
||||
{
|
||||
InterpolationArray turn_angle_at_speed = m_kart_properties->getTurnRadius();
|
||||
// Convert the turn radius into turn angle
|
||||
for(std::size_t i = 0; i < turn_angle_at_speed.size(); i++)
|
||||
for(int i = 0; i < (int)turn_angle_at_speed.size(); i++)
|
||||
turn_angle_at_speed.setY(i, sin(m_kart_properties->getWheelBase() /
|
||||
turn_angle_at_speed.getY(i)));
|
||||
|
||||
|
@ -251,7 +251,7 @@ void FollowTheLeaderRace::terminateRace()
|
||||
endSetKartPositions();
|
||||
|
||||
// Mark all still racing karts to be finished.
|
||||
for (int i = m_karts.size(); i>0; i--)
|
||||
for (int i = (int)m_karts.size(); i>0; i--)
|
||||
{
|
||||
AbstractKart *kart = getKartAtPosition(i);
|
||||
if (kart->isEliminated() || kart->hasFinishedRace())
|
||||
|
@ -618,7 +618,7 @@ void SoccerWorld::enterRaceOverState()
|
||||
std::sort(m_goal_frame.begin(), m_goal_frame.end());
|
||||
|
||||
const int mean = std::accumulate(m_goal_frame.begin(),
|
||||
m_goal_frame.end(), 0) / m_goal_frame.size();
|
||||
m_goal_frame.end(), 0) / (int)m_goal_frame.size();
|
||||
|
||||
// Prevent overflow if there is a large frame in vector
|
||||
double squared_sum = 0;
|
||||
@ -660,9 +660,9 @@ void SoccerWorld::enterRaceOverState()
|
||||
}
|
||||
|
||||
int red_goal = ((int(m_red_scorers.size()) - blue_own_goal) >= 0 ?
|
||||
m_red_scorers.size() - blue_own_goal : 0);
|
||||
(int)m_red_scorers.size() - blue_own_goal : 0);
|
||||
int blue_goal = ((int(m_blue_scorers.size()) - red_own_goal) >= 0 ?
|
||||
m_blue_scorers.size() - red_own_goal : 0);
|
||||
(int)m_blue_scorers.size() - red_own_goal : 0);
|
||||
|
||||
Log::verbose("Soccer AI profiling", "Red goal: %d, Red own goal: %d,"
|
||||
"Blue goal: %d, Blue own goal: %d", red_goal, red_own_goal,
|
||||
|
@ -340,8 +340,8 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
int getScore(SoccerTeam team) const
|
||||
{
|
||||
return (team == SOCCER_TEAM_BLUE ? m_blue_scorers.size() :
|
||||
m_red_scorers.size());
|
||||
return (int)(team == SOCCER_TEAM_BLUE ? m_blue_scorers.size()
|
||||
: m_red_scorers.size());
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
const std::vector<ScorerData>& getScorers(SoccerTeam team) const
|
||||
|
@ -655,7 +655,7 @@ void ThreeStrikesBattle::spawnSpareTireKarts()
|
||||
if (ratio < 1.5f) return;
|
||||
unsigned int spawn_sta = unsigned(ratio);
|
||||
if (spawn_sta > m_spare_tire_karts.size())
|
||||
spawn_sta = m_spare_tire_karts.size();
|
||||
spawn_sta = (int)m_spare_tire_karts.size();
|
||||
m_race_gui->addMessage(_P("%i spare tire kart has been spawned!",
|
||||
"%i spare tire karts have been spawned!",
|
||||
spawn_sta), NULL, 2.0f);
|
||||
@ -714,15 +714,15 @@ void ThreeStrikesBattle::loadCustomModels()
|
||||
|
||||
// Compute a random kart list
|
||||
std::vector<std::string> sta_list;
|
||||
kart_properties_manager->getRandomKartList(pos.size(), NULL,
|
||||
&sta_list);
|
||||
kart_properties_manager->getRandomKartList((int)pos.size(), NULL,
|
||||
&sta_list);
|
||||
|
||||
assert(sta_list.size() == pos.size());
|
||||
// Now add them
|
||||
for (unsigned int i = 0; i < pos.size(); i++)
|
||||
{
|
||||
AbstractKart* sta = new Kart(sta_list[i], m_karts.size(),
|
||||
m_karts.size() + 1, pos[i], PLAYER_DIFFICULTY_NORMAL,
|
||||
AbstractKart* sta = new Kart(sta_list[i], (int)m_karts.size(),
|
||||
(int)m_karts.size() + 1, pos[i], PLAYER_DIFFICULTY_NORMAL,
|
||||
KRT_RED);
|
||||
sta->init(RaceManager::KartType::KT_SPARE_TIRE);
|
||||
sta->setController(new SpareTireAI(sta));
|
||||
|
@ -49,7 +49,7 @@ Event::Event(ENetEvent* event)
|
||||
if (m_type == EVENT_TYPE_MESSAGE)
|
||||
{
|
||||
m_data = new NetworkString(event->packet->data,
|
||||
event->packet->dataLength);
|
||||
(int)event->packet->dataLength);
|
||||
}
|
||||
else
|
||||
m_data = NULL;
|
||||
|
@ -75,7 +75,7 @@ void NetworkString::unitTesting()
|
||||
* the characters of the given string. */
|
||||
BareNetworkString& BareNetworkString::encodeString(const std::string &value)
|
||||
{
|
||||
int len = value.size();
|
||||
int len = (int)value.size();
|
||||
if(len<=255)
|
||||
return this->addUInt8(len).addString(value);
|
||||
else
|
||||
|
@ -171,7 +171,7 @@ public:
|
||||
* difference to size() happens if the string to be sent was previously
|
||||
* read, and has m_current_offset != 0. Even in this case the whole
|
||||
* string must be sent. */
|
||||
unsigned int getTotalSize() const { return m_buffer.size(); }
|
||||
unsigned int getTotalSize() const { return (unsigned int)m_buffer.size(); }
|
||||
// ------------------------------------------------------------------------
|
||||
// All functions related to adding data to a network string
|
||||
/** Add 8 bit unsigned int. */
|
||||
|
@ -53,9 +53,9 @@ Protocol::~Protocol()
|
||||
/** Returns a network string with the given type.
|
||||
* \capacity Default preallocated size for the message.
|
||||
*/
|
||||
NetworkString* Protocol::getNetworkString(int capacity)
|
||||
NetworkString* Protocol::getNetworkString(size_t capacity)
|
||||
{
|
||||
return new NetworkString(m_type, capacity);
|
||||
return new NetworkString(m_type, (int)capacity);
|
||||
} // getNetworkString
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -128,7 +128,7 @@ public:
|
||||
virtual void asynchronousUpdate() = 0;
|
||||
|
||||
/// functions to check incoming data easily
|
||||
NetworkString* getNetworkString(int capacity=16);
|
||||
NetworkString* getNetworkString(size_t capacity = 16);
|
||||
bool checkDataSize(Event* event, unsigned int minimum_size);
|
||||
void sendMessageToPeersChangingToken(NetworkString *message,
|
||||
bool reliable = true);
|
||||
|
@ -128,7 +128,7 @@ void LatencyProtocol::asynchronousUpdate()
|
||||
{
|
||||
NetworkString *ping_request =
|
||||
getNetworkString(5);
|
||||
ping_request->addUInt8(1).addUInt32(m_pings[i].size());
|
||||
ping_request->addUInt8(1).addUInt32((int)m_pings[i].size());
|
||||
m_pings[i] [ m_pings_count ] = current_time;
|
||||
peers[i]->sendPacket(ping_request, false);
|
||||
delete ping_request;
|
||||
|
@ -172,7 +172,7 @@ unsigned int RewindManager::findFirstIndex(float target_time) const
|
||||
#ifdef REWIND_SEARCH_STATS
|
||||
m_count_of_searches++;
|
||||
#endif
|
||||
int index = m_rewind_info.size()-1;
|
||||
int index = (int)m_rewind_info.size()-1;
|
||||
int index_last_state = -1;
|
||||
while(index>=0)
|
||||
{
|
||||
@ -294,7 +294,7 @@ void RewindManager::rewindTo(float rewind_time)
|
||||
|
||||
// Then undo the rewind infos going backwards in time
|
||||
// --------------------------------------------------
|
||||
for(int i=m_rewind_info.size()-1; i>=(int)index; i--)
|
||||
for(int i=(int)m_rewind_info.size()-1; i>=(int)index; i--)
|
||||
{
|
||||
m_rewind_info[i]->undo();
|
||||
|
||||
|
@ -618,7 +618,7 @@ void STKHost::handleDirectSocketRequest()
|
||||
// current players, and the client's ip address and port
|
||||
// number (which solves the problem which network interface
|
||||
// might be the right one if there is more than one).
|
||||
BareNetworkString s(name.size()+1+11);
|
||||
BareNetworkString s((int)name.size()+1+11);
|
||||
s.encodeString(name);
|
||||
s.addUInt8(NetworkConfig::get()->getMaxPlayers());
|
||||
s.addUInt8(0); // FIXME: current number of connected players
|
||||
|
@ -499,9 +499,9 @@ bool GrandPrixData::isEditable() const
|
||||
unsigned int GrandPrixData::getNumberOfTracks(bool includeLocked) const
|
||||
{
|
||||
if (includeLocked)
|
||||
return m_tracks.size();
|
||||
return (unsigned int)m_tracks.size();
|
||||
else
|
||||
return getTrackNames(false).size();
|
||||
return (unsigned int)getTrackNames(false).size();
|
||||
} // getNumberOfTracks
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -338,7 +338,7 @@ void RaceManager::startNew(bool from_overworld)
|
||||
->getUniqueID(),
|
||||
m_grand_prix.getId(),
|
||||
m_minor_mode,
|
||||
m_player_karts.size());
|
||||
(unsigned int)m_player_karts.size());
|
||||
|
||||
// Saved GP only in offline mode
|
||||
if (m_continue_saved_gp)
|
||||
@ -394,7 +394,7 @@ void RaceManager::startNew(bool from_overworld)
|
||||
|
||||
// Then add the AI karts (randomly chosen)
|
||||
// ----------------------------------------
|
||||
const unsigned int ai_kart_count = m_ai_kart_list.size();
|
||||
const unsigned int ai_kart_count = (unsigned int)m_ai_kart_list.size();
|
||||
for(unsigned int i = 0; i < ai_kart_count; i++)
|
||||
{
|
||||
m_kart_status.push_back(KartStatus(m_ai_kart_list[i], i, -1, -1,
|
||||
@ -445,7 +445,7 @@ void RaceManager::startNew(bool from_overworld)
|
||||
->getUniqueID(),
|
||||
m_grand_prix.getId(),
|
||||
m_minor_mode,
|
||||
m_player_karts.size());
|
||||
(unsigned int)m_player_karts.size());
|
||||
} // while m_saved_gp
|
||||
} // if m_continue_saved_gp
|
||||
} // if grand prix
|
||||
|
@ -218,7 +218,7 @@ bool ReplayPlay::addReplayFile(const std::string& fn, bool custom_replay)
|
||||
assert(m_replay_file_list.size() > 0);
|
||||
// Force to use custom replay file immediately
|
||||
if (custom_replay)
|
||||
m_current_replay_file = m_replay_file_list.size() - 1;
|
||||
m_current_replay_file = (unsigned int)m_replay_file_list.size() - 1;
|
||||
|
||||
return true;
|
||||
|
||||
|
@ -132,15 +132,16 @@ public:
|
||||
{ return m_replay_file_list.at(n); }
|
||||
// ------------------------------------------------------------------------
|
||||
const unsigned int getNumReplayFile() const
|
||||
{ return m_replay_file_list.size(); }
|
||||
{ return (unsigned int)m_replay_file_list.size(); }
|
||||
// ------------------------------------------------------------------------
|
||||
GhostKart* getGhostKart(int n) { return m_ghost_karts.get(n); }
|
||||
// ------------------------------------------------------------------------
|
||||
const unsigned int getNumGhostKart() const
|
||||
{
|
||||
assert(m_replay_file_list.size() > 0);
|
||||
return m_replay_file_list.at(m_current_replay_file).m_kart_list.size();
|
||||
}
|
||||
return (unsigned int)m_replay_file_list.at(m_current_replay_file)
|
||||
.m_kart_list.size();
|
||||
} // getNumGhostKart
|
||||
// ------------------------------------------------------------------------
|
||||
const std::string& getGhostKartName(int n) const
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ namespace Scripting
|
||||
/** Get total number of challenges */
|
||||
int getChallengeCount()
|
||||
{
|
||||
return ::Track::getCurrentTrack()->getChallengeList().size();
|
||||
return (int)::Track::getCurrentTrack()->getChallengeList().size();
|
||||
} // getChallengeCount
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
@ -108,7 +108,7 @@ namespace Scripting
|
||||
// Read the entire file
|
||||
std::string script;
|
||||
script.resize(len);
|
||||
int c = fread(&script[0], len, 1, f);
|
||||
size_t c = fread(&script[0], len, 1, f);
|
||||
fclose(f);
|
||||
if (c != 1)
|
||||
{
|
||||
|
@ -342,7 +342,7 @@ void ArenasScreen::buildTrackList()
|
||||
if (m_unsupported_arena.size() > 0)
|
||||
w->setText( _P("%d arena unavailable in single player.",
|
||||
"%d arenas unavailable in single player.",
|
||||
m_unsupported_arena.size()) );
|
||||
(int)m_unsupported_arena.size()) );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
@ -137,7 +137,7 @@ void GPInfoScreen::beforeAddingWidget()
|
||||
race_manager->getMinorMode(),
|
||||
race_manager->getNumLocalPlayers());
|
||||
|
||||
int tracks = m_gp.getTrackNames().size();
|
||||
int tracks = (int)m_gp.getTrackNames().size();
|
||||
bool continue_visible = saved_gp && saved_gp->getNextTrack() > 0 &&
|
||||
saved_gp->getNextTrack() < tracks;
|
||||
|
||||
|
@ -135,7 +135,7 @@ void RaceResultGUI::init()
|
||||
else
|
||||
{
|
||||
m_start_track = 0;
|
||||
m_end_track = tracks.size();
|
||||
m_end_track = (int)tracks.size();
|
||||
}
|
||||
} // init
|
||||
|
||||
@ -1317,7 +1317,7 @@ void RaceResultGUI::backToLobby()
|
||||
// ----------------------------------------------------------------------------
|
||||
void RaceResultGUI::cleanupGPProgress()
|
||||
{
|
||||
for (size_t i = 0; i < m_gp_progress_widgets.size(); i++)
|
||||
for (unsigned int i = 0; i < m_gp_progress_widgets.size(); i++)
|
||||
m_widgets.remove(m_gp_progress_widgets.get(i));
|
||||
m_gp_progress_widgets.clearAndDeleteAll();
|
||||
} // cleanupGPProgress
|
||||
|
@ -149,11 +149,11 @@ void ArenaGraph::loadNavmesh(const std::string &navmesh)
|
||||
|
||||
createQuad(all_vertices[quad_index[0]],
|
||||
all_vertices[quad_index[1]], all_vertices[quad_index[2]],
|
||||
all_vertices[quad_index[3]], m_all_nodes.size(),
|
||||
all_vertices[quad_index[3]], (int)m_all_nodes.size(),
|
||||
false/*invisible*/, false/*ai_ignore*/, true/*is_arena*/,
|
||||
false/*ignore*/);
|
||||
|
||||
ArenaNode* cur_node = getNode(m_all_nodes.size() - 1);
|
||||
ArenaNode* cur_node = getNode((int)m_all_nodes.size() - 1);
|
||||
cur_node->setAdjacentNodes(adjacent_quad_index);
|
||||
}
|
||||
}
|
||||
@ -349,7 +349,7 @@ void ArenaGraph::setNearbyNodesOfAllNodes()
|
||||
{
|
||||
std::vector<float>::iterator it =
|
||||
std::min_element(dist.begin(), dist.end());
|
||||
const int pos = it - dist.begin();
|
||||
const int pos = int(it - dist.begin());
|
||||
nearby_nodes.push_back(pos);
|
||||
dist[pos] = 999999.0f;
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ void DriveGraph::load(const std::string &quad_file_name,
|
||||
ai_ignore = true;
|
||||
}
|
||||
|
||||
createQuad(p0, p1, p2, p3, m_all_nodes.size(), invisible, ai_ignore,
|
||||
createQuad(p0, p1, p2, p3, (unsigned int)m_all_nodes.size(), invisible, ai_ignore,
|
||||
false/*is_arena*/, ignored);
|
||||
}
|
||||
for (unsigned i = 0; i < m_all_nodes.size(); i++)
|
||||
@ -167,8 +167,8 @@ void DriveGraph::load(const std::string &quad_file_name,
|
||||
|
||||
if (m_all_nodes.size() > 0)
|
||||
{
|
||||
m_lap_length = getNode(m_all_nodes.size()-1)->getDistanceFromStart()
|
||||
+ getNode(m_all_nodes.size()-1)->getDistanceToSuccessor(0);
|
||||
m_lap_length = getNode((int)m_all_nodes.size()-1)->getDistanceFromStart()
|
||||
+ getNode((int)m_all_nodes.size()-1)->getDistanceToSuccessor(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -149,7 +149,7 @@ public:
|
||||
return m_all_nodes[i];
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
unsigned int getNumNodes() const { return m_all_nodes.size(); }
|
||||
unsigned int getNumNodes() const { return (unsigned int)m_all_nodes.size(); }
|
||||
// ------------------------------------------------------------------------
|
||||
void findRoadSector(const Vec3& XYZ, int *sector,
|
||||
std::vector<int> *all_sectors = NULL,
|
||||
|
@ -233,7 +233,7 @@ void TrackManager::removeTrack(const std::string &ident)
|
||||
if (it == m_tracks.end())
|
||||
Log::fatal("TrackManager", "Cannot find track '%s' in map!!", ident.c_str());
|
||||
|
||||
int index = it - m_tracks.begin();
|
||||
int index = int(it - m_tracks.begin());
|
||||
|
||||
// Remove the track from all groups it belongs to
|
||||
Group2Indices &group_2_indices =
|
||||
|
@ -376,8 +376,8 @@ void TrackObject::onWorldReady()
|
||||
// There are arguments to pass to the function
|
||||
// TODO: For the moment we only support string arguments
|
||||
// TODO: this parsing could be improved
|
||||
unsigned first = m_visibility_condition.find("(");
|
||||
unsigned last = m_visibility_condition.find_last_of(")");
|
||||
unsigned first = (unsigned)m_visibility_condition.find("(");
|
||||
unsigned last = (unsigned)m_visibility_condition.find_last_of(")");
|
||||
std::string fn_name = m_visibility_condition.substr(0, first);
|
||||
std::string str_arguments = m_visibility_condition.substr(first + 1, last - first - 1);
|
||||
arguments = StringUtils::split(str_arguments, ',');
|
||||
@ -406,7 +406,7 @@ void TrackObject::onWorldReady()
|
||||
{
|
||||
ctx->SetArgObject(i, &arguments[i]);
|
||||
}
|
||||
ctx->SetArgObject(arguments.size(), self);
|
||||
ctx->SetArgObject((int)arguments.size(), self);
|
||||
},
|
||||
[&](asIScriptContext* ctx) { result = ctx->GetReturnByte(); });
|
||||
|
||||
|
@ -17,10 +17,13 @@
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "crash_reporting.hpp"
|
||||
#include "log.hpp"
|
||||
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(WIN32) && !defined(DEBUG) && !defined(__MINGW32__) && !defined(_WIN64)
|
||||
#if defined(WIN32) && !defined(DEBUG) && !defined(__MINGW32__)
|
||||
// --------------------- Windows version -----------------
|
||||
#include <Windows.h>
|
||||
#include <DbgHelp.h>
|
||||
@ -76,11 +79,19 @@
|
||||
_In_ DWORD maxStringLength,
|
||||
_In_ DWORD flags
|
||||
);
|
||||
typedef BOOL (__stdcall *tSymFromAddr) (
|
||||
_In_ HANDLE hProcess,
|
||||
_In_ DWORD64 Address,
|
||||
_Out_opt_ PDWORD64 Displacement,
|
||||
_Inout_ PSYMBOL_INFO Symbol
|
||||
);
|
||||
|
||||
|
||||
namespace CrashReporting
|
||||
{
|
||||
void getCallStackWithContext(std::string& callstack, PCONTEXT pContext);
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void winCrashHandler(PCONTEXT pContext=NULL)
|
||||
{
|
||||
std::string callstack;
|
||||
@ -95,35 +106,43 @@
|
||||
"\n"
|
||||
"Call stack:\n";
|
||||
msg += callstack;
|
||||
Log::error("StackTrace", "%s", msg.c_str());
|
||||
MessageBoxA(NULL, msg.c_str(), "SuperTuxKart crashed :/", MB_OK);
|
||||
}
|
||||
} // winCrashHandler
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
LONG WINAPI sehHandler(_In_ struct _EXCEPTION_POINTERS *ExceptionInfo)
|
||||
{
|
||||
winCrashHandler(ExceptionInfo->ContextRecord);
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
} // sehHandler
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void pureCallHandler()
|
||||
{
|
||||
winCrashHandler();
|
||||
}
|
||||
} // pureCallHandler
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
int newHandler( size_t )
|
||||
{
|
||||
winCrashHandler();
|
||||
return 0;
|
||||
}
|
||||
} // newHandler
|
||||
|
||||
void invalidParameterHandler(const wchar_t *, const wchar_t *, const wchar_t *, unsigned int, uintptr_t)
|
||||
// --------------------------------------------------------------------
|
||||
void invalidParameterHandler(const wchar_t *, const wchar_t *,
|
||||
const wchar_t *, unsigned int, uintptr_t)
|
||||
{
|
||||
winCrashHandler();
|
||||
}
|
||||
} // invalidParameterHandler
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void signalHandler(int code)
|
||||
{
|
||||
winCrashHandler();
|
||||
}
|
||||
} // signalHandler
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
void installHandlers()
|
||||
{
|
||||
@ -144,182 +163,161 @@
|
||||
|
||||
// ----- Per-thread handlers -----
|
||||
// TODO
|
||||
}
|
||||
} // installHandlers
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void getCallStackWithContext(std::string& callstack, PCONTEXT pContext)
|
||||
{
|
||||
HINSTANCE hImageHlpDll = LoadLibraryA("imagehlp.dll");
|
||||
if(!hImageHlpDll)
|
||||
HINSTANCE hDbgHelpDll = LoadLibraryA("DbgHelp.dll");
|
||||
if (!hDbgHelpDll)
|
||||
{
|
||||
Log::warn("CrashReporting", "Failed to load DLL imagehlp.dll");
|
||||
callstack = "Crash reporting failed to load DLL imagehlp.dll";
|
||||
Log::warn("CrashReporting", "Failed to load DLL dbghelp.dll");
|
||||
callstack = "Crash reporting failed to load DLL dbghelp.dll";
|
||||
return;
|
||||
}
|
||||
|
||||
// Retrieve the DLL functions
|
||||
#define GET_FUNC_PTR(FuncName) \
|
||||
t##FuncName _##FuncName = (t##FuncName)GetProcAddress(hImageHlpDll, #FuncName); \
|
||||
if(!_##FuncName) { \
|
||||
Log::warn("CrashReporting", "Failed to import symbol " #FuncName " from imagehlp.dll"); \
|
||||
FreeLibrary(hImageHlpDll); \
|
||||
return; \
|
||||
}
|
||||
|
||||
GET_FUNC_PTR(SymCleanup )
|
||||
GET_FUNC_PTR(SymFunctionTableAccess64 )
|
||||
GET_FUNC_PTR(SymGetLineFromAddr64 )
|
||||
GET_FUNC_PTR(SymGetModuleBase64 )
|
||||
GET_FUNC_PTR(SymGetSymFromAddr64 )
|
||||
GET_FUNC_PTR(SymInitialize )
|
||||
GET_FUNC_PTR(SymSetOptions )
|
||||
GET_FUNC_PTR(StackWalk64 )
|
||||
GET_FUNC_PTR(UnDecorateSymbolName )
|
||||
t##FuncName _##FuncName = (t##FuncName)GetProcAddress(hDbgHelpDll, #FuncName); \
|
||||
if(!_##FuncName) \
|
||||
{ \
|
||||
Log::warn("CrashReporting", "Failed to import symbol " #FuncName \
|
||||
" from hDbgHelpDll"); \
|
||||
FreeLibrary(hDbgHelpDll); \
|
||||
return; \
|
||||
}
|
||||
|
||||
GET_FUNC_PTR(SymCleanup)
|
||||
GET_FUNC_PTR(SymFunctionTableAccess64)
|
||||
GET_FUNC_PTR(SymGetLineFromAddr64)
|
||||
GET_FUNC_PTR(SymGetModuleBase64)
|
||||
GET_FUNC_PTR(SymGetSymFromAddr64)
|
||||
GET_FUNC_PTR(SymInitialize)
|
||||
GET_FUNC_PTR(SymSetOptions)
|
||||
GET_FUNC_PTR(UnDecorateSymbolName)
|
||||
GET_FUNC_PTR(SymFromAddr);
|
||||
GET_FUNC_PTR(StackWalk64);
|
||||
#undef GET_FUNC_PTR
|
||||
|
||||
const HANDLE hProcess = GetCurrentProcess();
|
||||
const HANDLE hThread = GetCurrentThread();
|
||||
|
||||
// Since the stack trace can also be used for leak checks, don't
|
||||
// initialise this all the time.
|
||||
static bool first_time = true;
|
||||
|
||||
// Initialize the symbol hander for the process
|
||||
if (first_time)
|
||||
{
|
||||
// Get the file path of the executable
|
||||
char filepath[512];
|
||||
char filepath[512];
|
||||
GetModuleFileNameA(NULL, filepath, sizeof(filepath));
|
||||
if(!filepath)
|
||||
if (!filepath)
|
||||
{
|
||||
Log::warn("CrashReporting", "GetModuleFileNameA failed");
|
||||
FreeLibrary(hImageHlpDll);
|
||||
FreeLibrary(hDbgHelpDll);
|
||||
return;
|
||||
}
|
||||
// Only keep the directory
|
||||
std::string s(filepath);
|
||||
std::string path = StringUtils::getPath(s);
|
||||
|
||||
// Finally initialize the symbol handler.
|
||||
BOOL bOk = _SymInitialize(hProcess,
|
||||
path.empty() ? NULL : path.c_str(),
|
||||
TRUE);
|
||||
if (!bOk)
|
||||
{
|
||||
Log::warn("CrashReporting", "SymInitialize() failed");
|
||||
FreeLibrary(hDbgHelpDll);
|
||||
return;
|
||||
}
|
||||
|
||||
// Only keep the directory
|
||||
char* last_separator = strrchr(filepath, '/');
|
||||
if(!last_separator) last_separator = strrchr(filepath, '\\');
|
||||
if(last_separator)
|
||||
last_separator[0] = '\0';
|
||||
|
||||
// Since the stack trace can also be used for leak checks, don't
|
||||
// initialise this all the time.
|
||||
static bool first_time = true;
|
||||
|
||||
if (first_time)
|
||||
{
|
||||
// Finally initialize the symbol handler.
|
||||
BOOL bOk = _SymInitialize(hProcess, filepath ? filepath : NULL, TRUE);
|
||||
if (!bOk)
|
||||
{
|
||||
Log::warn("CrashReporting", "SymInitialize() failed");
|
||||
FreeLibrary(hImageHlpDll);
|
||||
return;
|
||||
}
|
||||
|
||||
_SymSetOptions(SYMOPT_LOAD_LINES);
|
||||
first_time = false;
|
||||
}
|
||||
}
|
||||
_SymSetOptions(SYMOPT_LOAD_LINES);
|
||||
first_time = false;
|
||||
} // if first_time
|
||||
|
||||
// Get the stack trace
|
||||
{
|
||||
// Initialize the IMAGEHLP_SYMBOL64 structure
|
||||
const size_t MaxNameLength = 256;
|
||||
IMAGEHLP_SYMBOL64* sym = (IMAGEHLP_SYMBOL64*)_malloca(sizeof(IMAGEHLP_SYMBOL64) + MaxNameLength);
|
||||
sym->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL64);
|
||||
sym->MaxNameLength = MaxNameLength;
|
||||
|
||||
// Initialize the STACKFRAME structure so that it
|
||||
// corresponds to the current function call
|
||||
STACKFRAME64 stackframe;
|
||||
memset(&stackframe, 0, sizeof(stackframe));
|
||||
stackframe.AddrPC.Offset = pContext->Eip;
|
||||
stackframe.AddrPC.Mode = AddrModeFlat;
|
||||
stackframe.AddrStack.Offset = pContext->Esp;
|
||||
stackframe.AddrStack.Mode = AddrModeFlat;
|
||||
stackframe.AddrFrame.Offset = pContext->Ebp;
|
||||
stackframe.AddrFrame.Mode = AddrModeFlat;
|
||||
#ifdef _WIN64
|
||||
stackframe.AddrPC.Offset = pContext->Rip;
|
||||
stackframe.AddrStack.Offset = pContext->Rsp;
|
||||
stackframe.AddrFrame.Offset = pContext->Rsp;
|
||||
const DWORD machine_type = IMAGE_FILE_MACHINE_AMD64;
|
||||
#else
|
||||
stackframe.AddrPC.Offset = pContext->Eip;
|
||||
stackframe.AddrStack.Offset = pContext->Esp;
|
||||
stackframe.AddrFrame.Offset = pContext->Ebp;
|
||||
const DWORD machine_type = IMAGE_FILE_MACHINE_I386;
|
||||
#endif
|
||||
|
||||
const DWORD machine_type = IMAGE_FILE_MACHINE_I386;
|
||||
|
||||
// Walk the stack
|
||||
const int max_nb_calls = 32;
|
||||
for(int i=0 ; i < max_nb_calls ; i++)
|
||||
{
|
||||
const BOOL stackframe_ok = _StackWalk64( machine_type,
|
||||
hProcess,
|
||||
hThread,
|
||||
&stackframe,
|
||||
pContext,
|
||||
NULL,
|
||||
_SymFunctionTableAccess64,
|
||||
_SymGetModuleBase64,
|
||||
NULL);
|
||||
if(stackframe_ok)
|
||||
const BOOL stackframe_ok =
|
||||
_StackWalk64(machine_type, hProcess, hThread,
|
||||
&stackframe, pContext, NULL,
|
||||
_SymFunctionTableAccess64,
|
||||
_SymGetModuleBase64, NULL );
|
||||
if (!stackframe_ok) break;
|
||||
|
||||
// Decode the symbol and add it to the call stack
|
||||
DWORD64 sym_displacement;
|
||||
char buffer[ sizeof(SYMBOL_INFO) +
|
||||
MAX_SYM_NAME * sizeof(TCHAR) ];
|
||||
PSYMBOL_INFO symbol = (PSYMBOL_INFO)buffer;
|
||||
symbol->MaxNameLen = MAX_SYM_NAME;
|
||||
symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
|
||||
if (!_SymFromAddr(hProcess, stackframe.AddrPC.Offset,
|
||||
&sym_displacement, symbol))
|
||||
{
|
||||
// Decode the symbol and add it to the call stack
|
||||
DWORD64 sym_displacement;
|
||||
if(_SymGetSymFromAddr64( hProcess,
|
||||
stackframe.AddrPC.Offset,
|
||||
&sym_displacement,
|
||||
sym))
|
||||
{
|
||||
IMAGEHLP_LINE64 line64;
|
||||
DWORD dwDisplacement = (DWORD)sym_displacement;
|
||||
if(_SymGetLineFromAddr64(hProcess, stackframe.AddrPC.Offset, &dwDisplacement, &line64))
|
||||
{
|
||||
callstack += "\n ";
|
||||
|
||||
// Directory + filename -> filename only
|
||||
const char* filename = line64.FileName;
|
||||
const char* ptr = line64.FileName;
|
||||
while(*ptr)
|
||||
{
|
||||
if(*ptr == '\\' || *ptr == '/')
|
||||
filename = ptr+1;
|
||||
ptr++;
|
||||
}
|
||||
callstack += filename;
|
||||
callstack += ":";
|
||||
callstack += sym->Name;
|
||||
|
||||
char str[128];
|
||||
_itoa(line64.LineNumber, str, 10);
|
||||
callstack += ":";
|
||||
callstack += str;
|
||||
}
|
||||
else
|
||||
{
|
||||
callstack += "\n ";
|
||||
callstack += sym->Name;
|
||||
}
|
||||
}
|
||||
else
|
||||
callstack += "\n <no symbol available>";
|
||||
callstack += "\n <no symbol available>";
|
||||
continue;
|
||||
}
|
||||
IMAGEHLP_LINE64 line64;
|
||||
DWORD dwDisplacement = (DWORD)sym_displacement;
|
||||
if (_SymGetLineFromAddr64(hProcess,
|
||||
stackframe.AddrPC.Offset,
|
||||
&dwDisplacement, &line64))
|
||||
{
|
||||
std::string s(line64.FileName);
|
||||
callstack += "\n " + StringUtils::getBasename(s)
|
||||
+ ":" + symbol->Name + ":"
|
||||
+ StringUtils::toString(line64.LineNumber);
|
||||
} // if SymGetLineFromAddr64
|
||||
else
|
||||
break; // done
|
||||
}
|
||||
}
|
||||
|
||||
FreeLibrary(hImageHlpDll);
|
||||
}
|
||||
{
|
||||
callstack += std::string("\n ") + symbol->Name;
|
||||
}
|
||||
} // for i < max_calls
|
||||
} // get the stack trace
|
||||
|
||||
FreeLibrary(hDbgHelpDll);
|
||||
} // // getCallStackWithContext
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void getCallStack(std::string& callstack)
|
||||
{
|
||||
// Get the current CONTEXT
|
||||
// NB: this code is ONLY VALID FOR X86 (32 bit)!
|
||||
CONTEXT ctx;
|
||||
memset(&ctx, '\0', sizeof(ctx));
|
||||
ctx.ContextFlags = CONTEXT_FULL;
|
||||
__asm call x
|
||||
__asm x: pop eax // get eip (can't directly use mov)
|
||||
__asm mov ctx.Eip, eax
|
||||
__asm mov ctx.Ebp, ebp
|
||||
__asm mov ctx.Esp, esp
|
||||
CONTEXT context;
|
||||
memset(&context, 0, sizeof(CONTEXT));
|
||||
context.ContextFlags = CONTEXT_FULL;
|
||||
RtlCaptureContext(&context);
|
||||
getCallStackWithContext(callstack, &context);
|
||||
} // getCallStack
|
||||
|
||||
getCallStackWithContext(callstack, &ctx);
|
||||
}
|
||||
} // end namespace CrashReporting
|
||||
|
||||
// ============================================================================
|
||||
|
||||
#elif ENABLE_LIBBFD
|
||||
// --------------------- Unix version -----------------------
|
||||
/* Derived from addr2line.c from binutils
|
||||
|
@ -24,7 +24,7 @@
|
||||
namespace CrashReporting
|
||||
{
|
||||
void installHandlers();
|
||||
void getCallStack(std::string& callstack);
|
||||
void getCallStack(std::string& callstack);
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "utils/aligned_array.hpp"
|
||||
|
||||
@ -161,7 +162,7 @@ public:
|
||||
{
|
||||
TYPE * pointer = m_contents_vector[n];
|
||||
delete pointer;
|
||||
m_contents_vector[n] = (TYPE*)0xDEADBEEF;
|
||||
m_contents_vector[n] = (TYPE*)(intptr_t)0xDEADBEEF;
|
||||
|
||||
// When deleting, it's important that the same pointer cannot be
|
||||
// twice in the vector, resulting in a double delete
|
||||
|
@ -451,7 +451,7 @@ bool Translations::isRTLText(const wchar_t *in_ptr)
|
||||
FriBidiChar *fribidiInput = toFribidiChar(in_ptr);
|
||||
|
||||
FriBidiCharType *types = new FriBidiCharType[length];
|
||||
fribidi_get_bidi_types(fribidiInput, length, types);
|
||||
fribidi_get_bidi_types(fribidiInput, (FriBidiStrIndex)length, types);
|
||||
freeFribidiChar(fribidiInput);
|
||||
|
||||
// Declare as RTL if one character is RTL
|
||||
@ -608,7 +608,7 @@ core::stringw Translations::fribidizeLine(const core::stringw &str)
|
||||
FriBidiChar *fribidiOutput = new FriBidiChar[length + 1];
|
||||
memset(fribidiOutput, 0, (length + 1) * sizeof(FriBidiChar));
|
||||
fribidi_boolean result = fribidi_log2vis(fribidiInput,
|
||||
length,
|
||||
(FriBidiStrIndex)length,
|
||||
&pbase_dir,
|
||||
fribidiOutput,
|
||||
/* gint *position_L_to_V_list */ NULL,
|
||||
|
Loading…
x
Reference in New Issue
Block a user