Merge remote-tracking branch 'origin/simplify-world' into game_protocol

This commit is contained in:
hiker 2016-12-13 17:17:25 +11:00
commit 177c8c8f63
94 changed files with 579 additions and 455 deletions

57
.appveyor.yml Normal file
View File

@ -0,0 +1,57 @@
environment:
DEPS_DIR: c:\\projects\dependencies
ASSETS_DIR: c:\\projects\stk-assets
APPVEYOR_CACHE_ENTRY_ZIP_ARGS: -t7z -m0=lzma2 -mx=9
os: Visual Studio 2015
clone_depth: 1
shallow_clone: true
platform:
- x86
#- x64
configuration:
- Debug
- Release
matrix:
fast_finish: true
cache:
- '%DEPS_DIR%'
#- '%ASSETS_DIR%'
install:
- ps: >-
If(!(Test-Path "$env:DEPS_DIR")) {
Write-Host "Downloading dependencies";
Start-Process -FilePath "git" -ArgumentList "clone --branch master --single-branch --depth 1 https://github.com/supertuxkart/dependencies.git $env:DEPS_DIR" -Wait;
}
Else {
Write-Host "Updating dependencies";
Start-Process -FilePath "git" -ArgumentList "fetch --depth 1" -WorkingDirectory "$env:DEPS_DIR" -Wait;
}
Get-ChildItem $env:DEPS_DIR | Measure-Object -property length -sum
#- ps: >-
#If(!(Test-Path "$env:ASSETS_DIR")) {
# Write-Host "Downloading assets";
# Start-Process -FilePath "svn" -ArgumentList "checkout https://svn.code.sf.net/p/supertuxkart/code/stk-assets $env:ASSETS_DIR" -Wait;
#}
#Else {
# Write-Host "Updating assets";
# Start-Process -FilePath "svn" -ArgumentList "update" -WorkingDirectory "$env:ASSETS_DIR" -Wait;
#}
#Get-ChildItem $env:ASSETS_DIR | Measure-Object -property length -sum
before_build:
- ps: Copy-Item "${env:DEPS_DIR}\windows\dependencies" c:\projects\stk-code\dependencies Recurse
- cmd: |
md build
cd build
if "%platform%"=="x86" set CMAKE_GENERATOR_NAME="Visual Studio 14 2015"
cmake -G %CMAKE_GENERATOR_NAME% -DCMAKE_BUILD_TYPE="%configuration%" .. -DCHECK_ASSETS=OFF
build:
parallel: true
project: build\ALL_BUILD.vcxproj

View File

@ -14,8 +14,10 @@ matrix:
env:
matrix:
- BUILD_TYPE="Debug"
- BUILD_TYPE="Release"
- BUILD_TYPE="Debug" SERVER_ONLY="OFF"
- BUILD_TYPE="Debug" SERVER_ONLY="ON"
- BUILD_TYPE="Release" SERVER_ONLY="OFF"
- BUILD_TYPE="Release" SERVER_ONLY="ON"
addons:
apt:
@ -39,8 +41,9 @@ addons:
before_script:
# Unfortunately using all threads crashes g++: "g++: internal compiler error: Killed (program cc1plus)"
# Use half of the available threads, gcc is memory hungry
- 'if [ ${CC} = "gcc" ]; then
export THREADS=4;
export THREADS=$((`nproc` / 2));
else
export THREADS=$((`nproc` + 1));
fi'
@ -50,7 +53,7 @@ before_script:
script:
- mkdir "build"
- cd "build"
- cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCHECK_ASSETS=off
- cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSERVER_ONLY=$SERVER_ONLY -DCHECK_ASSETS=off
- make VERBOSE=1 -j $THREADS
notifications:

View File

@ -54,6 +54,7 @@ void main(void)
float scattering = mix(fPowEdotL, fLdotNBack, .5);
float specmap = texture(SpecMap, uv).g;
vec3 LightFactor = color.xyz * (scattering * 0.1) + getLightFactor(color.xyz, vec3(1.), specmap, 0.);
float emitmap = texture(SpecMap, uv).b;
vec3 LightFactor = color.xyz * (scattering * 0.1) + getLightFactor(color.xyz, vec3(1.), specmap, emitmap);
FragColor = vec4(LightFactor, 1.);
}

View File

@ -25,6 +25,7 @@ void main(void)
#ifdef Use_Bindless_Texture
vec4 color = texture(handle, uv);
float specmap = texture(secondhandle, uv).g;
float emitmap = texture(secondhandle, uv).b;
float mask = texture(thirdhandle, uv).a;
#ifdef SRGBBindlessFix
color.xyz = pow(color.xyz, vec3(2.2));
@ -32,6 +33,7 @@ void main(void)
#else
vec4 color = texture(Albedo, uv);
float specmap = texture(SpecMap, uv).g;
float emitmap = texture(SpecMap, uv).b;
float mask = texture(colorization_mask, uv).a;
#endif
if (color.a < 0.5) discard;
@ -60,6 +62,7 @@ void main(void)
float fLdotNBack = max(0., - dot(nor, L) * 0.6 + 0.4);
float scattering = mix(fPowEdotL, fLdotNBack, .5);
vec3 LightFactor = color.xyz * (scattering * 0.1) + getLightFactor(color.xyz, vec3(1.), specmap, 0.);
vec3 LightFactor = color.xyz * (scattering * 0.1) + getLightFactor(color.xyz, vec3(1.), specmap, emitmap);
FragColor = vec4(LightFactor, 1.);
}

View File

@ -341,11 +341,25 @@ namespace video
delete BridgeCalls;
#if defined(EGL_VERSION_1_0)
// HACK : the following is commented because destroying the context crashes under Linux (Thibault 04-feb-10)
/*eglMakeCurrent(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroyContext(EglDisplay, EglContext);
eglDestroySurface(EglDisplay, EglSurface);*/
eglTerminate(EglDisplay);
eglMakeCurrent(EglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (EglContext != EGL_NO_CONTEXT)
{
eglDestroyContext(EglDisplay, EglContext);
EglContext = EGL_NO_CONTEXT;
}
if (EglSurface != EGL_NO_SURFACE)
{
eglDestroySurface(EglDisplay, EglSurface);
EglSurface = EGL_NO_SURFACE;
}
if (EglDisplay != EGL_NO_DISPLAY)
{
eglTerminate(EglDisplay);
EglDisplay = EGL_NO_DISPLAY;
}
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
if (HDc)

View File

@ -22,7 +22,7 @@
#include <libkern/OSByteOrder.h>
#define bswap_16(X) OSReadSwapInt16(&X,0)
#define bswap_32(X) OSReadSwapInt32(&X,0)
#elif defined(__FreeBSD__)
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
#include <sys/endian.h>
#define bswap_16(X) bswap16(X)
#define bswap_32(X) bswap32(X)

View File

@ -436,7 +436,7 @@ bool ChallengeData::isChallengeFulfilled() const
// Single races
// ------------
World *world = World::getWorld();
std::string track_name = world->getTrack()->getIdent();
std::string track_name = Track::getCurrentTrack()->getIdent();
int d = race_manager->getDifficulty();

View File

@ -158,10 +158,10 @@ void DisplaceProvider::OnSetConstants(IMaterialRendererServices *srv, int)
void DisplaceProvider::update()
{
if (World::getWorld() == NULL) return;
if (!Track::getCurrentTrack()) return;
const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
const float speed = World::getWorld()->getTrack()->getDisplacementSpeed();
const float speed = Track::getCurrentTrack()->getDisplacementSpeed();
float strength = time;
strength = fabsf(noise2d(strength / 10.0f)) * 0.006f + 0.002f;

View File

@ -19,9 +19,8 @@
#include "graphics/camera.hpp"
#include <cmath>
#include "audio/sfx_manager.hpp"
#include "config/stk_config.hpp"
#include "config/user_config.hpp"
#include "graphics/camera_debug.hpp"
#include "graphics/camera_end.hpp"
@ -34,7 +33,6 @@
#include "karts/kart.hpp"
#include "karts/kart_properties.hpp"
#include "karts/skidding.hpp"
#include "modes/world.hpp"
#include "physics/btKart.hpp"
#include "race/race_manager.hpp"
#include "tracks/track.hpp"
@ -44,6 +42,8 @@
#include "ISceneManager.h"
#include <cmath>
std::vector<Camera*> Camera::m_all_cameras;
Camera* Camera::s_active_camera = NULL;
Camera::CameraType Camera::m_default_type = Camera::CM_TYPE_NORMAL;
@ -125,7 +125,7 @@ Camera::Camera(CameraType type, int camera_index, AbstractKart* kart)
setupCamera();
setKart(kart);
m_ambient_light = World::getWorld()->getTrack()->getDefaultAmbientColor();
m_ambient_light = Track::getCurrentTrack()->getDefaultAmbientColor();
reset();
} // Camera
@ -229,7 +229,7 @@ void Camera::setupCamera()
} // switch
m_camera->setFOV(m_fov);
m_camera->setAspectRatio(m_aspect);
m_camera->setFarValue(World::getWorld()->getTrack()->getCameraFar());
m_camera->setFarValue(Track::getCurrentTrack()->getCameraFar());
} // setupCamera
// ----------------------------------------------------------------------------

View File

@ -19,12 +19,12 @@
#include "graphics/camera_normal.hpp"
#include "config/stk_config.hpp"
#include "karts/abstract_kart.hpp"
#include "karts/explosion_animation.hpp"
#include "karts/kart.hpp"
#include "karts/kart_properties.hpp"
#include "karts/skidding.hpp"
#include "modes/world.hpp"
#include "tracks/track.hpp"
// ============================================================================
@ -41,7 +41,7 @@ CameraNormal::CameraNormal(Camera::CameraType type, int camera_index,
: Camera(type, camera_index, kart)
{
m_distance = kart ? kart->getKartProperties()->getCameraDistance() : 1000.0f;
m_ambient_light = World::getWorld()->getTrack()->getDefaultAmbientColor();
m_ambient_light = Track::getCurrentTrack()->getDefaultAmbientColor();
m_smooth_dt = 0.0f;
// TODO: Put these values into a config file

View File

@ -28,7 +28,6 @@
#include "graphics/stk_mesh.hpp"
#include "graphics/stk_mesh_scene_node.hpp"
#include "graphics/vao_manager.hpp"
#include "modes/world.hpp"
#include "tracks/track.hpp"
#include "utils/profiler.hpp"
@ -196,10 +195,9 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node,
}
// Transparent
if (World::getWorld() && World::getWorld()->isFogEnabled())
const Track* const track = Track::getCurrentTrack();
if (track&& track->isFogEnabled())
{
const Track * const track = World::getWorld()->getTrack();
// Todo : put everything in a ubo
const float fogmax = track->getFogMax();
const float startH = track->getFogStartHeight();
@ -229,9 +227,9 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node,
// Use sun color to determine custom alpha for ghost karts
float custom_alpha = 1.0f;
if (World::getWorld())
if (track)
{
const video::SColor& c = World::getWorld()->getTrack()->getSunColor();
const video::SColor& c = track->getSunColor();
float y = 0.2126f * c.getRed() + 0.7152f * c.getGreen() + 0.0722f * c.getBlue();
custom_alpha = y > 128.0f ? 0.5f : 0.35f;
}

View File

@ -43,7 +43,7 @@ void FixedPipelineRenderer::render(float dt)
irr_driver->getVideoDriver()->beginScene(/*backBuffer clear*/ true,
/*zBuffer*/ true,
world->getClearColor());
irr_driver->getClearColor());
irr_driver->getVideoDriver()->enableMaterial2D();
@ -71,7 +71,7 @@ void FixedPipelineRenderer::render(float dt)
// is not set up properly. This is only used for
// the bullet debug view.
if (UserConfigParams::m_artist_debug_mode)
World::getWorld()->getPhysics()->draw();
Physics::getInstance()->draw();
} // for i<world->getNumKarts()
// Set the viewport back to the full screen for race gui

View File

@ -25,6 +25,7 @@
#include "graphics/rtts.hpp"
#include "graphics/shaders.hpp"
#include "modes/world.hpp"
#include "tracks/track.hpp"
#include "utils/tuple.hpp"
#include <SColor.h>
#include <S3DVertex.h>
@ -260,7 +261,8 @@ void AbstractGeometryPasses::renderTransparent(const DrawCalls& draw_calls,
if (CVS->isARBBaseInstanceUsable())
glBindVertexArray(VAOManager::getInstance()->getVAO(video::EVT_STANDARD));
if (World::getWorld() && World::getWorld()->isFogEnabled())
const Track* const track = Track::getCurrentTrack();
if (track && track->isFogEnabled())
{
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
renderTransparenPass<Shaders::TransparentFogShader, video::EVT_STANDARD,

View File

@ -140,8 +140,9 @@ IrrDriver::IrrDriver()
m_mipviz = m_wireframe = m_normals = m_ssaoviz = false;
m_lightviz = m_shadowviz = m_distortviz = m_rsm = m_rh = m_gi = false;
m_boundingboxesviz = false;
m_boundingboxesviz = false;
m_last_light_bucket_distance = 0;
m_clear_color = video::SColor(255, 100, 101, 140);
} // IrrDriver
// ----------------------------------------------------------------------------
@ -2077,9 +2078,9 @@ void IrrDriver::update(float dt)
GUIEngine::render(dt);
}
if (world->getPhysics() != NULL)
if (Physics::getInstance())
{
IrrDebugDrawer* debug_drawer = world->getPhysics()->getDebugDrawer();
IrrDebugDrawer* debug_drawer = Physics::getInstance()->getDebugDrawer();
if (debug_drawer != NULL && debug_drawer->debugEnabled())
{
debug_drawer->beginNextFrame();

View File

@ -172,6 +172,10 @@ private:
bool m_distortviz;
bool m_boundingboxesviz;
/** Background colour to reset a buffer. Can be changed by each track. */
irr::video::SColor m_clear_color;
unsigned m_last_light_bucket_distance;
u32 m_renderpass;
class STKMeshSceneNode *m_sun_interposer;
@ -307,6 +311,15 @@ public:
std::unique_ptr<RenderTarget> createRenderTarget(const irr::core::dimension2du &dimension,
const std::string &name);
#endif
// ------------------------------------------------------------------------
/** Returns the color to clear the back buffer. */
const irr::video::SColor& getClearColor() const { return m_clear_color; }
// ------------------------------------------------------------------------
/** Sets the color to use when clearing the back buffer. */
void setClearbackBufferColor(irr::video::SColor color)
{
m_clear_color = color;
} // setClearbackBufferColor
// ------------------------------------------------------------------------
/** Convenience function that loads a texture with default parameters

View File

@ -621,7 +621,8 @@ void LightingPasses::renderLights( bool has_shadow,
}
// Render sunlight if and only if track supports shadow
if (!World::getWorld() || World::getWorld()->getTrack()->hasShadows())
const Track* const track = Track::getCurrentTrack();
if (!track|| track->hasShadows())
{
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_SUN));
if (World::getWorld() && CVS->isShadowEnabled() && has_shadow)
@ -664,7 +665,7 @@ void LightingPasses::renderLights( bool has_shadow,
// ----------------------------------------------------------------------------
void LightingPasses::renderAmbientScatter(GLuint depth_stencil_texture)
{
const Track * const track = World::getWorld()->getTrack();
const Track * const track = Track::getCurrentTrack();
// This function is only called once per frame - thus no need for setters.
float start = track->getFogStart() + .001f;
@ -694,7 +695,7 @@ void LightingPasses::renderLightsScatter(GLuint depth_stencil_texture,
glClearColor(0., 0., 0., 0.);
glClear(GL_COLOR_BUFFER_BIT);
const Track * const track = World::getWorld()->getTrack();
const Track * const track = Track::getCurrentTrack();
// This function is only called once per frame - thus no need for setters.
float start = track->getFogStart() + .001f;

View File

@ -35,9 +35,9 @@
#include "graphics/shaders.hpp"
#include "graphics/texture_manager.hpp"
#include "io/file_manager.hpp"
#include "race/race_manager.hpp"
#include "io/xml_node.hpp"
#include "utils/string_utils.hpp"
#include "modes/world.hpp"
#include "tracks/track.hpp"
#include "utils/log.hpp"
#include "utils/vs.hpp"

View File

@ -464,10 +464,11 @@ scene::IMesh* MeshTools::createMeshWithTangents(scene::IMesh* mesh,
scene::SAnimatedMesh* amesh = new scene::SAnimatedMesh(clone);
clone->drop();
meshCache->addMesh(path, amesh);
if (World::getWorld())
Track* track = Track::getCurrentTrack();
if (track)
{
irr_driver->grabAllTextures(amesh);
World::getWorld()->getTrack()->addCachedMesh(amesh);
track->addCachedMesh(amesh);
return amesh;
}
amesh->drop();

View File

@ -1300,7 +1300,7 @@ void PostProcessing::renderGodRays(scene::ICameraSceneNode * const camnode,
const FrameBuffer &quarter1_fbo,
const FrameBuffer &quarter2_fbo)
{
Track* track = World::getWorld()->getTrack();
Track* track = Track::getCurrentTrack();
glEnable(GL_DEPTH_TEST);
// Grab the sky
@ -1435,8 +1435,7 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode,
glDisable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
World *world = World::getWorld();
Physics *physics = world ? world->getPhysics() : NULL;
Physics *physics = Physics::getInstance();
if (isRace && UserConfigParams::m_dof && (physics == NULL || !physics->isDebug()))
{
@ -1448,8 +1447,9 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode,
}
bool hasgodrays = false;
if (World::getWorld() != NULL)
hasgodrays = World::getWorld()->getTrack()->hasGodRays();
const Track * const track = Track::getCurrentTrack();
if (track)
hasgodrays = track->hasGodRays();
if (isRace && UserConfigParams::m_light_shaft && hasgodrays)
{
@ -1563,14 +1563,10 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode,
{
PROFILER_PUSH_CPU_MARKER("- Lightning", 0xFF, 0x00, 0x00);
ScopedGPUTimer Timer(irr_driver->getGPUTimer(Q_LIGHTNING));
if (World::getWorld() != NULL)
Weather* weather = Weather::getInstance();
if ( weather && weather->shouldLightning() )
{
Weather* m_weather = World::getWorld()->getWeather();
if (m_weather != NULL && m_weather->shouldLightning())
{
renderLightning(m_weather->getIntensity());
}
renderLightning(weather->getIntensity());
}
PROFILER_POP_CPU_MARKER();
}

View File

@ -168,7 +168,7 @@ void ShaderBasedRenderer::prepareForwardRenderer()
{
irr::video::SColor clearColor(0, 150, 150, 150);
if (World::getWorld() != NULL)
clearColor = World::getWorld()->getClearColor();
clearColor = irr_driver->getClearColor();
glClear(GL_COLOR_BUFFER_BIT);
glDepthMask(GL_TRUE);
@ -408,7 +408,7 @@ void ShaderBasedRenderer::renderScene(scene::ICameraSceneNode * const camnode,
m_rtts->getFBO(FBO_COLORS).bind();
video::SColor clearColor(0, 150, 150, 150);
if (World::getWorld() != NULL)
clearColor = World::getWorld()->getClearColor();
clearColor = irr_driver->getClearColor();
glClearColor(clearColor.getRed() / 255.f, clearColor.getGreen() / 255.f,
clearColor.getBlue() / 255.f, clearColor.getAlpha() / 255.f);
@ -429,8 +429,8 @@ void ShaderBasedRenderer::renderScene(scene::ICameraSceneNode * const camnode,
}
// Render ambient scattering
if (CVS->isDefferedEnabled() && World::getWorld() != NULL &&
World::getWorld()->isFogEnabled())
const Track * const track = Track::getCurrentTrack();
if (CVS->isDefferedEnabled() && track && track->isFogEnabled())
{
PROFILER_PUSH_CPU_MARKER("- Ambient scatter", 0xFF, 0x00, 0x00);
ScopedGPUTimer Timer(irr_driver->getGPUTimer(Q_FOG));
@ -446,8 +446,7 @@ void ShaderBasedRenderer::renderScene(scene::ICameraSceneNode * const camnode,
}
// Render discrete lights scattering
if (CVS->isDefferedEnabled() && World::getWorld() != NULL &&
World::getWorld()->isFogEnabled())
if (CVS->isDefferedEnabled() && track && track->isFogEnabled())
{
PROFILER_PUSH_CPU_MARKER("- PointLight Scatter", 0xFF, 0x00, 0x00);
ScopedGPUTimer Timer(irr_driver->getGPUTimer(Q_FOG));
@ -548,15 +547,16 @@ void ShaderBasedRenderer::debugPhysics()
// the bullet debug view, since otherwise the camera
// is not set up properly. This is only used for
// the bullet debug view.
World *world = World::getWorld();
if (UserConfigParams::m_artist_debug_mode)
world->getPhysics()->draw();
if (world != NULL && world->getPhysics() != NULL)
if(Physics::getInstance())
{
IrrDebugDrawer* debug_drawer = world->getPhysics()->getDebugDrawer();
if (UserConfigParams::m_artist_debug_mode)
Physics::getInstance()->draw();
IrrDebugDrawer* debug_drawer = Physics::getInstance()->getDebugDrawer();
if (debug_drawer != NULL && debug_drawer->debugEnabled())
{
const std::map<video::SColor, std::vector<float> >& lines = debug_drawer->getLines();
const std::map<video::SColor, std::vector<float> >& lines =
debug_drawer->getLines();
std::map<video::SColor, std::vector<float> >::const_iterator it;
Shaders::ColoredLine *line = Shaders::ColoredLine::getInstance();
@ -802,7 +802,7 @@ void ShaderBasedRenderer::render(float dt)
m_post_processing->begin();
World *world = World::getWorld(); // Never NULL.
Track *track = world->getTrack();
Track *track = Track::getCurrentTrack();
RaceGUIBase *rg = world->getRaceGUI();
if (rg) rg->update(dt);

View File

@ -355,7 +355,8 @@ void ShadowMatrices::computeMatrixesAndCameras(scene::ICameraSceneNode *const ca
m_sun_ortho_matrices.clear();
const core::matrix4 &sun_cam_view_matrix = m_sun_cam->getViewMatrix();
if (World::getWorld() && World::getWorld()->getTrack())
const Track* const track = Track::getCurrentTrack();
if (track)
{
float FarValues[] =
{
@ -423,13 +424,12 @@ void ShadowMatrices::computeMatrixesAndCameras(scene::ICameraSceneNode *const ca
}
// Rsm Matrix and camera
if (!m_rsm_matrix_initialized &&
World::getWorld()->getTrack()->getPtrTriangleMesh())
if (!m_rsm_matrix_initialized && track->getPtrTriangleMesh())
{
// Compute track extent
Vec3 vmin, vmax;
World::getWorld()->getTrack()->getTriangleMesh().getCollisionShape()
.getAabb(btTransform::getIdentity(), vmin, vmax);
track->getTriangleMesh().getCollisionShape()
.getAabb(btTransform::getIdentity(), vmin, vmax);
core::aabbox3df trackbox(vmin.toIrrVector(), vmax.toIrrVector() -
core::vector3df(0, 30, 0));

View File

@ -512,7 +512,8 @@ void STKMeshSceneNode::render()
else
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
if (World::getWorld() && World::getWorld()->isFogEnabled())
const Track * const track = Track::getCurrentTrack();
if (track && track->isFogEnabled())
{
Shaders::TransparentFogShader::getInstance()->use();
for (unsigned i = 0; i < GLmeshes.size(); i++)
@ -523,19 +524,17 @@ void STKMeshSceneNode::render()
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
const Track * const track = World::getWorld()->getTrack();
// This function is only called once per frame - thus no need for setters.
const float fogmax = track->getFogMax();
const float startH = track->getFogStartHeight();
const float endH = track->getFogEndHeight();
const float start = track->getFogStart();
const float end = track->getFogEnd();
const float endH = track->getFogEndHeight();
const float start = track->getFogStart();
const float end = track->getFogEnd();
const video::SColor tmpcol = track->getFogColor();
video::SColorf col(tmpcol.getRed() / 255.0f,
tmpcol.getGreen() / 255.0f,
tmpcol.getBlue() / 255.0f);
tmpcol.getGreen() / 255.0f,
tmpcol.getBlue() / 255.0f);
compressTexture(mesh.textures[0], true);
#if !defined(USE_GLES2)

View File

@ -20,24 +20,25 @@
#include "audio/sfx_manager.hpp"
#include "graphics/weather.hpp"
#include "modes/world.hpp"
#include "tracks/track.hpp"
#include "utils/random_generator.hpp"
// The weather manager
Weather::Weather(bool lightning, std::string sound)
/** The weather manager stores information about the weather.
*/
Weather::Weather()
{
m_lightning_enabled = lightning;
m_thunder_sound = NULL;
m_weather_sound = NULL;
m_lightning = 0.0f;
if (m_lightning_enabled)
if (Track::getCurrentTrack()->getWeatherLightning())
{
m_thunder_sound = SFXManager::get()->createSoundSource("thunder");
}
if (sound != "")
const std::string &sound = Track::getCurrentTrack()->getWeatherSound();
if (!sound.empty())
{
m_weather_sound = SFXManager::get()->createSoundSource(sound);
}
@ -61,7 +62,7 @@ Weather::~Weather()
void Weather::update(float dt)
{
if (!m_lightning_enabled)
if (!Track::getCurrentTrack()->getWeatherLightning())
return;
if (World::getWorld()->getRaceGUI() == NULL)

View File

@ -19,13 +19,13 @@
#ifndef HEADER_WEATHER_HPP
#define HEADER_WEATHER_HPP
#include "utils/singleton.hpp"
#include <vector3d.h>
class SFXBase;
class Weather
class Weather : public AbstractSingleton<Weather>
{
bool m_lightning_enabled;
float m_next_lightning;
float m_lightning;
@ -33,7 +33,7 @@ class Weather
SFXBase* m_weather_sound;
public:
Weather(bool lightning, std::string sound);
Weather();
virtual ~Weather();
void update(float dt);

View File

@ -80,27 +80,45 @@ KartStatsWidget::KartStatsWidget(core::recti area, const int player_id,
m_children.push_back(skill_bar);
}
setValues(props);
move(area.UpperLeftCorner.X, area.UpperLeftCorner.Y,
area.getWidth(), area.getHeight());
} // KartStatsWidget
// -----------------------------------------------------------------------------
void KartStatsWidget::setValues(const KartProperties* props)
{
// Use kart properties computed for "hard" difficulty to show the user, so
// that properties don't change according to the the last used difficulty
// (And because this code uses arbitrary scaling factors to make them look
// nice and the arbitrary factors were optimised for hard difficulty)
RaceManager::Difficulty previous_difficulty = race_manager->getDifficulty();
race_manager->setDifficulty(RaceManager::DIFFICULTY_HARD);
KartProperties kp_computed;
kp_computed.copyForPlayer(props);
// Scale the values so they look better
// The scaling factor and offset were found by trial and error.
// It should look nice and you should be able to see the difference between
// different masses or velocities.
m_skills[SKILL_MASS]->setValue((int)
((props->getCombinedCharacteristic()->getMass() - 20) / 4));
((kp_computed.getCombinedCharacteristic()->getMass() - 20) / 4));
m_skills[SKILL_MASS]->setLabel(_("WEIGHT"));
m_skills[SKILL_MASS]->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_mass", m_player_id);
m_skills[SKILL_SPEED]->setValue((int)
((props->getCombinedCharacteristic()->getEngineMaxSpeed() - 15) * 6));
((kp_computed.getCombinedCharacteristic()->getEngineMaxSpeed() - 15) * 6));
m_skills[SKILL_SPEED]->setLabel(_("SPEED"));
m_skills[SKILL_SPEED]->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_speed", m_player_id);
m_skills[SKILL_POWER]->setValue((int) ((props->getAvgPower() - 30) / 20));
m_skills[SKILL_POWER]->setValue((int)((kp_computed.getAvgPower() - 30) / 20));
m_skills[SKILL_POWER]->setLabel(_("POWER"));
m_skills[SKILL_POWER]->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_power", m_player_id);
move(area.UpperLeftCorner.X, area.UpperLeftCorner.Y,
area.getWidth(), area.getHeight());
} // KartStatsWidget
race_manager->setDifficulty(previous_difficulty);
}
// -----------------------------------------------------------------------------

View File

@ -30,6 +30,7 @@
#include "guiengine/widgets/progress_bar_widget.hpp"
#include "guiengine/widgets/skill_level_widget.hpp"
class KartProperties;
namespace GUIEngine
{
@ -91,6 +92,8 @@ namespace GUIEngine
* inside itself */
void setSize(const int x, const int y, const int w, const int h);
void setValues(const KartProperties* props);
/** Change the value of the widget, it must be a percent. */
void setValue(Stats type, int value);

View File

@ -573,10 +573,10 @@ void Attachment::update(float dt)
Vec3 hit_point;
Vec3 normal;
const Material* material_hit;
World* world = World::getWorld();
world->getTrack()->getTriangleMesh().castRay(m_kart->getXYZ(),
m_kart->getTrans().getBasis() * Vec3(0, -10000, 0), &hit_point,
&material_hit, &normal);
Track::getCurrentTrack()->getTriangleMesh().castRay(m_kart->getXYZ(),
m_kart->getTrans().getBasis() * Vec3(0, -10000, 0),
&hit_point,&material_hit, &normal );
// This can happen if the kart is 'over nothing' when dropping
// the bubble gum
if(material_hit)

View File

@ -133,7 +133,7 @@ void Flyable::createPhysics(float forw_offset, const Vec3 &velocity,
m_shape = shape;
createBody(m_mass, trans, m_shape, restitution);
m_user_pointer.set(this);
World::getWorld()->getPhysics()->addBody(getBody());
Physics::getInstance()->addBody(getBody());
m_body->setGravity(gravity);
@ -199,7 +199,7 @@ void Flyable::init(const XMLNode &node, scene::IMesh *model,
Flyable::~Flyable()
{
if(m_shape) delete m_shape;
World::getWorld()->getPhysics()->removeBody(getBody());
Physics::getInstance()->removeBody(getBody());
} // ~Flyable
//-----------------------------------------------------------------------------
@ -371,7 +371,7 @@ bool Flyable::updateAndDelete(float dt)
const Vec3 &xyz=getXYZ();
// Check if the flyable is outside of the track. If so, explode it.
const Vec3 *min, *max;
World::getWorld()->getTrack()->getAABB(&min, &max);
Track::getCurrentTrack()->getAABB(&min, &max);
// I have seen that the bullet AABB can be slightly different from the
// one computed here - I assume due to minor floating point errors
@ -515,13 +515,13 @@ void Flyable::explode(AbstractKart *kart_hit, PhysicalObject *object,
// The explosion animation will register itself with the kart
// and will free it later.
ExplosionAnimation::create(kart, getXYZ(), kart==kart_hit);
if(kart==kart_hit && world->getTrack()->isArena())
if(kart==kart_hit && Track::getCurrentTrack()->isArena())
{
world->kartHit(kart->getWorldKartId());
}
}
}
world->getTrack()->handleExplosion(getXYZ(), object, secondary_hits);
Track::getCurrentTrack()->handleExplosion(getXYZ(), object,secondary_hits);
} // explode
// ----------------------------------------------------------------------------

View File

@ -76,8 +76,7 @@ Item::Item(ItemType type, const Vec3& xyz, const Vec3& normal,
debug_name += m_type;
m_node->setName(debug_name.c_str());
#endif
World::getWorld()->getTrack()->adjustForFog(m_node);
Track::getCurrentTrack()->adjustForFog(m_node);
m_node->setAutomaticCulling(scene::EAC_FRUSTUM_BOX);
m_node->setPosition(xyz.toIrrVector());
Vec3 hpr;
@ -195,7 +194,7 @@ void Item::switchTo(ItemType type, scene::IMesh *mesh, scene::IMesh *lowmesh)
irr_driver->applyObjectPassShader(m_node->getAllNodes()[0]);
World::getWorld()->getTrack()->adjustForFog(m_node);
Track::getCurrentTrack()->adjustForFog(m_node);
#endif
} // switchTo
@ -224,7 +223,7 @@ void Item::switchBack()
((scene::IMeshSceneNode*)node)->setMesh(m_original_lowmesh);
}
World::getWorld()->getTrack()->adjustForFog(m_node);
Track::getCurrentTrack()->adjustForFog(m_node);
Vec3 hpr;
hpr.setHPR(m_original_rotation);
m_node->setRotation(hpr.toIrrHPR());

View File

@ -30,7 +30,6 @@
#include "io/file_manager.hpp"
#include "karts/abstract_kart.hpp"
#include "karts/controller/spare_tire_ai.hpp"
#include "modes/linear_world.hpp"
#include "network/network_config.hpp"
#include "network/race_event_manager.hpp"
#include "physics/triangle_mesh.hpp"
@ -577,8 +576,7 @@ bool ItemManager::randomItemsForArena(const AlignedArray<btTransform>& pos)
const Material* m;
Vec3 normal;
Vec3 hit_point;
const TriangleMesh& tm =
World::getWorld()->getTrack()->getTriangleMesh();
const TriangleMesh& tm = Track::getCurrentTrack()->getTriangleMesh();
bool success = tm.castRay(loc, an->getCenter() + (-10000*quad_normal),
&hit_point, &m, &normal);

View File

@ -28,7 +28,6 @@
#include "karts/abstract_kart.hpp"
#include "karts/controller/controller.hpp"
#include "karts/kart_properties.hpp"
#include "modes/world.hpp"
#include "physics/physical_object.hpp"
#include "physics/physics.hpp"
#include "tracks/track.hpp"
@ -174,7 +173,7 @@ bool Plunger::hit(AbstractKart *kart, PhysicalObject *obj)
m_keep_alive = 0;
// Make this object invisible.
getNode()->setVisible(false);
World::getWorld()->getPhysics()->removeBody(getBody());
Physics::getInstance()->removeBody(getBody());
}
else
{
@ -188,7 +187,7 @@ bool Plunger::hit(AbstractKart *kart, PhysicalObject *obj)
{
node->setVisible(false);
}
World::getWorld()->getPhysics()->removeBody(getBody());
Physics::getInstance()->removeBody(getBody());
if(kart)
{

View File

@ -279,8 +279,10 @@ void Powerup::use()
const Material* material_hit;
Vec3 pos = m_kart->getXYZ();
Vec3 to = pos+ m_kart->getTrans().getBasis() * Vec3(0, -10000, 0);
world->getTrack()->getTriangleMesh().castRay(pos, to, &hit_point,
&material_hit, &normal);
Track::getCurrentTrack()->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)

View File

@ -492,7 +492,7 @@ void RubberBall::interpolate(Vec3 *next_xyz, float dt)
*/
bool RubberBall::checkTunneling()
{
const TriangleMesh &tm = World::getWorld()->getTrack()->getTriangleMesh();
const TriangleMesh &tm = Track::getCurrentTrack()->getTriangleMesh();
Vec3 hit_point;
const Material *material;
@ -595,9 +595,10 @@ float RubberBall::updateHeight()
* \returns The distance to the terrain element found by raycast in the up
direction. If no terrain found, it returns 99990
*/
float RubberBall::getTunnelHeight(const Vec3 &next_xyz, const float vertical_offset) const
float RubberBall::getTunnelHeight(const Vec3 &next_xyz,
const float vertical_offset) const
{
const TriangleMesh &tm = World::getWorld()->getTrack()->getTriangleMesh();
const TriangleMesh &tm = Track::getCurrentTrack()->getTriangleMesh();
Vec3 from(next_xyz + vertical_offset*getNormal());
Vec3 to(next_xyz + 10000.0f*getNormal());
Vec3 hit_point;
@ -623,7 +624,7 @@ void RubberBall::updateDistanceToTarget()
m_distance_to_target = target_distance - ball_distance;
if(m_distance_to_target < 0)
{
m_distance_to_target += world->getTrack()->getTrackLength();
m_distance_to_target += Track::getCurrentTrack()->getTrackLength();
}
if(UserConfigParams::logFlyable())
Log::debug("[RubberBall]", "ball %d: target %f %f %f distance_2_target %f",
@ -652,7 +653,7 @@ void RubberBall::updateDistanceToTarget()
// new target. If the new distance is nearly the full track
// length, assume that the rubber ball has overtaken the
// original target, and start deleting it.
if(m_distance_to_target > 0.9f * world->getTrack()->getTrackLength())
if(m_distance_to_target > 0.9f * Track::getCurrentTrack()->getTrackLength())
{
m_delete_timer = m_st_delete_time;
#ifdef PRINT_BALL_REMOVE_INFO

View File

@ -29,7 +29,6 @@
#include "karts/abstract_kart.hpp"
#include "karts/kart_properties.hpp"
#include "karts/max_speed.hpp"
#include "modes/world.hpp"
#include "physics/physics.hpp"
#include "race/race_manager.hpp"
#include "utils/string_utils.hpp"
@ -215,8 +214,7 @@ void RubberBand::checkForHit(const Vec3 &k, const Vec3 &p)
m_owner->getBody()->getBroadphaseHandle()->m_collisionFilterGroup = 0;
// Do the raycast
World::getWorld()->getPhysics()->getPhysicsWorld()->rayTest(k, p,
ray_callback);
Physics::getInstance()->getPhysicsWorld()->rayTest(k, p, ray_callback);
// Reset collision groups
m_plunger->getBody()->getBroadphaseHandle()->m_collisionFilterGroup = old_plunger_group;
if(m_owner->getBody()->getBroadphaseHandle())

View File

@ -22,7 +22,6 @@
#include "karts/abstract_kart.hpp"
#include "karts/kart_model.hpp"
#include "karts/skidding.hpp"
#include "modes/world.hpp"
#include "physics/physics.hpp"
AbstractKartAnimation::AbstractKartAnimation(AbstractKart *kart,
@ -48,7 +47,7 @@ AbstractKartAnimation::AbstractKartAnimation(AbstractKart *kart,
// Register this animation with the kart (which will free it
// later).
kart->setKartAnimation(this);
World::getWorld()->getPhysics()->removeKart(m_kart);
Physics::getInstance()->removeKart(m_kart);
kart->getSkidding()->reset();
kart->getSlipstream()->reset();
if(kart->isSquashed())
@ -74,7 +73,7 @@ AbstractKartAnimation::~AbstractKartAnimation()
if(m_timer < 0)
{
m_kart->getBody()->setAngularVelocity(btVector3(0,0,0));
World::getWorld()->getPhysics()->addKart(m_kart);
Physics::getInstance()->addKart(m_kart);
}
} // ~AbstractKartAnimation

View File

@ -26,6 +26,7 @@
#include "karts/controller/ai_properties.hpp"
#include "modes/linear_world.hpp"
#include "tracks/drive_graph.hpp"
#include "tracks/track.hpp"
#include "utils/constants.hpp"
@ -90,7 +91,7 @@ AIBaseLapController::AIBaseLapController(AbstractKart *kart)
race_manager->getMinorMode()!=RaceManager::MINOR_MODE_SOCCER)
{
m_world = dynamic_cast<LinearWorld*>(World::getWorld());
m_track = m_world->getTrack();
m_track = Track::getCurrentTrack();
computePath();
}
else

View File

@ -27,6 +27,7 @@
#include "karts/controller/spare_tire_ai.hpp"
#include "modes/three_strikes_battle.hpp"
#include "tracks/arena_graph.hpp"
#include "tracks/track.hpp"
#ifdef AI_DEBUG
#include "irrlicht.h"
@ -47,7 +48,7 @@ BattleAI::BattleAI(AbstractKart *kart)
m_debug_sphere_next->setVisible(true);
#endif
m_world = dynamic_cast<ThreeStrikesBattle*>(World::getWorld());
m_track = m_world->getTrack();
m_track = Track::getCurrentTrack();
// Don't call our own setControllerName, since this will add a
// billboard showing 'AIBaseController' to the kart.

View File

@ -72,7 +72,7 @@ LocalPlayerController::LocalPlayerController(AbstractKart *kart,
m_full_sound = SFXManager::get()->createSoundSource("energy_bar_full");
// Attach Particle System
Track *track = World::getWorld()->getTrack();
Track *track = Track::getCurrentTrack();
#ifndef SERVER_ONLY
if (UserConfigParams::m_weather_effects &&
track->getSkyParticles() != NULL)

View File

@ -1694,7 +1694,7 @@ void SkiddingAI::handleNitroAndZipper()
{
float diff = DriveGraph::get()->getDistanceFromStart(last)
- DriveGraph::get()->getDistanceFromStart(m_track_node);
if(diff<0) diff+=World::getWorld()->getTrack()->getTrackLength();
if(diff<0) diff += Track::getCurrentTrack()->getTrackLength();
if(diff>m_ai_properties->m_straight_length_for_zipper)
m_controls->setFire(true);
}

View File

@ -25,6 +25,7 @@
#include "karts/kart_properties.hpp"
#include "modes/soccer_world.hpp"
#include "tracks/arena_graph.hpp"
#include "tracks/track.hpp"
#ifdef AI_DEBUG
#include "irrlicht.h"
@ -59,7 +60,7 @@ SoccerAI::SoccerAI(AbstractKart *kart)
#endif
m_world = dynamic_cast<SoccerWorld*>(World::getWorld());
m_track = m_world->getTrack();
m_track = Track::getCurrentTrack();
m_cur_team = m_world->getKartTeam(m_kart->getWorldKartId());
m_opp_team = (m_cur_team == SOCCER_TEAM_BLUE ?
SOCCER_TEAM_RED : SOCCER_TEAM_BLUE);

View File

@ -113,7 +113,7 @@ void SpareTireAI::spawn(float time_to_last)
findDefaultPath();
m_timer = time_to_last;
World::getWorld()->getPhysics()->addKart(m_kart);
Physics::getInstance()->addKart(m_kart);
m_kart->startEngineSFX();
m_kart->getKartGFX()->reset();
m_kart->getNode()->setVisible(true);

View File

@ -1743,7 +1743,7 @@ void SkiddingAI::handleNitroAndZipper()
{
float diff = DriveGraph::get()->getDistanceFromStart(last)
- DriveGraph::get()->getDistanceFromStart(m_track_node);
if(diff<0) diff+=World::getWorld()->getTrack()->getTrackLength();
if (diff < 0) diff += Track::getCurrentTrack()->getTrackLength();
if(diff>m_ai_properties->m_straight_length_for_zipper)
m_controls->setFire(true);
}

View File

@ -24,7 +24,6 @@
#include "items/attachment.hpp"
#include "karts/abstract_kart.hpp"
#include "karts/kart_properties.hpp"
#include "modes/world.hpp"
#include "tracks/track.hpp"
/** A static create function that does only create an explosion if
@ -91,7 +90,7 @@ ExplosionAnimation::ExplosionAnimation(AbstractKart *kart,
// Since v(explosion_time*0.5) = 0, the following forumla computes
// the right initial velocity for a kart to land back after
// the specified time.
m_velocity = 0.5f * m_timer * World::getWorld()->getTrack()->getGravity();
m_velocity = 0.5f * m_timer * Track::getCurrentTrack()->getGravity();
m_curr_rotation.setHeading(m_kart->getHeading());
m_curr_rotation.setPitch(m_kart->getPitch());
@ -141,7 +140,7 @@ ExplosionAnimation::~ExplosionAnimation()
*/
void ExplosionAnimation::update(float dt)
{
m_velocity -= dt*World::getWorld()->getTrack()->getGravity();
m_velocity -= dt*Track::getCurrentTrack()->getGravity();
m_xyz = m_xyz + dt*m_velocity*m_normal;
// Make sure the kart does not end up under the track

View File

@ -273,7 +273,7 @@ Kart::~Kart()
// Ghost karts don't have a body
if(m_body)
{
World::getWorld()->getPhysics()->removeKart(this);
Physics::getInstance()->removeKart(this);
delete m_vehicle;
delete m_vehicle_raycaster;
}
@ -310,8 +310,8 @@ void Kart::reset()
// don't have one).
if(m_body)
{
World::getWorld()->getPhysics()->removeKart(this);
World::getWorld()->getPhysics()->addKart(this);
Physics::getInstance()->removeKart(this);
Physics::getInstance()->addKart(this);
}
m_min_nitro_time = 0.0f;
@ -671,9 +671,9 @@ void Kart::createPhysics()
// Create the actual vehicle
// -------------------------
m_vehicle_raycaster =
new btKartRaycaster(World::getWorld()->getPhysics()->getPhysicsWorld(),
new btKartRaycaster(Physics::getInstance()->getPhysicsWorld(),
stk_config->m_smooth_normals &&
World::getWorld()->getTrack()->smoothNormals());
Track::getCurrentTrack()->smoothNormals());
m_vehicle = new btKart(m_body, m_vehicle_raycaster, this);
// never deactivate the vehicle
@ -1158,7 +1158,7 @@ void Kart::eliminate()
{
if (!getKartAnimation())
{
World::getWorld()->getPhysics()->removeKart(this);
Physics::getInstance()->removeKart(this);
}
if (m_stars_effect)
{
@ -1360,7 +1360,7 @@ void Kart::update(float dt)
const float roll = quad_normal.angle
((Vec3(0, 1, 0).rotate(q.getAxis(), q.getAngle())));
if (World::getWorld()->getTrack()->isAutoRescueEnabled() &&
if (Track::getCurrentTrack()->isAutoRescueEnabled() &&
(!m_terrain_info->getMaterial() ||
!m_terrain_info->getMaterial()->hasGravity()) &&
!has_animation_before && fabs(roll) > 60 * DEGREE_TO_RAD &&
@ -1420,14 +1420,14 @@ void Kart::update(float dt)
{
if (!m_flying)
{
float g = World::getWorld()->getTrack()->getGravity();
float g = Track::getCurrentTrack()->getGravity();
Vec3 gravity(0, -g, 0);
btRigidBody *body = getVehicle()->getRigidBody();
body->setGravity(gravity);
}
// let kart fall a bit before rescuing
const Vec3 *min, *max;
World::getWorld()->getTrack()->getAABB(&min, &max);
Track::getCurrentTrack()->getAABB(&min, &max);
if((min->getY() - getXYZ().getY() > 17 || dist_to_sector > 25) && !m_flying &&
!getKartAnimation())
@ -1437,7 +1437,7 @@ void Kart::update(float dt)
{
if (!m_flying)
{
float g = World::getWorld()->getTrack()->getGravity();
float g = Track::getCurrentTrack()->getGravity();
Vec3 gravity(0.0f, -g, 0.0f);
btRigidBody *body = getVehicle()->getRigidBody();
// If the material should overwrite the gravity,
@ -1519,7 +1519,7 @@ void Kart::update(float dt)
m_kart_model->getAnimation() == KartModel::AF_DEFAULT)
{
float v = getVelocity().getY();
float force = World::getWorld()->getTrack()->getGravity();
float force = Track::getCurrentTrack()->getGravity();
// Velocity / force is the time it takes to reach the peak
// of the jump (i.e. when vertical speed becomes 0). Assuming
// that jump start height and end height are the same, it will
@ -2027,7 +2027,7 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
else if(m_kart_properties->getTerrainImpulseType()
==KartProperties::IMPULSE_TO_DRIVELINE &&
lw && m_vehicle->getCentralImpulseTime()<=0 &&
World::getWorld()->getTrack()->isPushBackEnabled())
Track::getCurrentTrack()->isPushBackEnabled())
{
int sector = lw->getSectorForKart(this);
if(sector!=Graph::UNKNOWN_SECTOR)

View File

@ -545,6 +545,8 @@ public:
bool getSkidEnabled() const;
/* <characteristics-end kpdefs> */
LEAK_CHECK()
}; // KartProperties
#endif

View File

@ -23,7 +23,6 @@
#include "graphics/irr_driver.hpp"
#include "graphics/material.hpp"
#include "graphics/material_manager.hpp"
#include "modes/world.hpp"
#include "tracks/track.hpp"
#include "ISceneNode.h"
@ -118,7 +117,7 @@ void Moveable::flyDown()
// ----------------------------------------------------------------------------
void Moveable::stopFlying()
{
m_body->setGravity(btVector3(0.0, -World::getWorld()->getTrack()->getGravity(), 0.0));
m_body->setGravity(btVector3(0.0, -Track::getCurrentTrack()->getGravity(), 0.0));
} // stopFlying
//-----------------------------------------------------------------------------

View File

@ -89,7 +89,7 @@ RescueAnimation::~RescueAnimation()
{
m_kart->getBody()->setLinearVelocity(btVector3(0,0,0));
m_kart->getBody()->setAngularVelocity(btVector3(0,0,0));
World::getWorld()->getPhysics()->addKart(m_kart);
Physics::getInstance()->addKart(m_kart);
for(unsigned int i=0; i<Camera::getNumCameras(); i++)
{
Camera *camera = Camera::getCamera(i);

View File

@ -287,7 +287,7 @@ void Skidding::update(float dt, bool is_on_ground,
// be displayed, update the data
if(m_remaining_jump_time>0)
{
m_jump_speed -= World::getWorld()->getTrack()->getGravity()*dt;
m_jump_speed -= Track::getCurrentTrack()->getGravity()*dt;
m_gfx_jump_offset += m_jump_speed * dt;
m_remaining_jump_time -= dt;
if(m_remaining_jump_time<0)
@ -339,13 +339,13 @@ void Skidding::update(float dt, bool is_on_ground,
// the same time to come down again), based on v = gravity * t.
// Then use this speed to determine the impulse necessary to
// reach this speed.
float v = World::getWorld()->getTrack()->getGravity()
float v = Track::getCurrentTrack()->getGravity()
* 0.5f * kp->getSkidPhysicalJumpTime();
btVector3 imp(0, v / m_kart->getBody()->getInvMass(),0);
m_kart->getVehicle()->getRigidBody()->applyCentralImpulse(imp);
// Some karts might use a graphical-only jump. Set it up:
m_jump_speed = World::getWorld()->getTrack()->getGravity()
m_jump_speed = Track::getCurrentTrack()->getGravity()
* 0.5f * kp->getSkidGraphicalJumpTime();
m_remaining_jump_time = kp->getSkidGraphicalJumpTime();

View File

@ -75,7 +75,7 @@ void CutsceneWorld::init()
dynamic_cast<CutsceneGUI*>(m_race_gui)->setFadeLevel(1.0f);
getTrack()->startMusic();
Track::getCurrentTrack()->startMusic();
m_duration = -1.0f;
@ -85,7 +85,8 @@ void CutsceneWorld::init()
m_camera->bindTargetAndRotation(true); // no "look-at"
// --- Build list of sounds to play at certain frames
PtrVector<TrackObject>& objects = m_track->getTrackObjectManager()->getObjects();
PtrVector<TrackObject>& objects = Track::getCurrentTrack()
->getTrackObjectManager()->getObjects();
for (TrackObject* curr : objects)
{
if (curr->getType() == "particle-emitter" &&
@ -199,7 +200,8 @@ void CutsceneWorld::update(float dt)
{
//printf("INITIAL TIME for CutsceneWorld\n");
PtrVector<TrackObject>& objects = m_track->getTrackObjectManager()->getObjects();
PtrVector<TrackObject>& objects = Track::getCurrentTrack()
->getTrackObjectManager()->getObjects();
TrackObject* curr;
for_in(curr, objects)
{
@ -213,7 +215,8 @@ void CutsceneWorld::update(float dt)
{
m_second_reset = false;
PtrVector<TrackObject>& objects = m_track->getTrackObjectManager()->getObjects();
PtrVector<TrackObject>& objects = Track::getCurrentTrack()
->getTrackObjectManager()->getObjects();
TrackObject* curr;
for_in(curr, objects)
{
@ -265,7 +268,8 @@ void CutsceneWorld::update(float dt)
//printf("Estimated current frame : %f\n", curr_frame);
const std::vector<Subtitle>& subtitles = m_track->getSubtitles();
const std::vector<Subtitle>& subtitles = Track::getCurrentTrack()
->getSubtitles();
bool foundSubtitle = false;
for (unsigned int n = 0; n < subtitles.size(); n++)
{
@ -287,7 +291,8 @@ void CutsceneWorld::update(float dt)
World::update((float)dt);
World::updateTrack((float)dt);
PtrVector<TrackObject>& objects = m_track->getTrackObjectManager()->getObjects();
PtrVector<TrackObject>& objects = Track::getCurrentTrack()
->getTrackObjectManager()->getObjects();
TrackObject* curr;
for_in(curr, objects)
{

View File

@ -126,7 +126,7 @@ void EasterEggHunt::readData(const std::string &filename)
race_manager->getDifficultyAsString(act_difficulty).c_str());
continue;
}
World::getTrack()->itemCommand(egg);
Track::getCurrentTrack()->itemCommand(egg);
m_number_of_eggs++;
} // for i <num_nodes

View File

@ -105,12 +105,12 @@ int FollowTheLeaderRace::getScoreForPosition(int p)
const btTransform &FollowTheLeaderRace::getStartTransform(int index)
{
if (index == 0) // Leader start position
return m_track->getStartTransform(index);
return Track::getCurrentTrack()->getStartTransform(index);
// Otherwise the karts will start at the rear starting positions
int start_index = stk_config->m_max_karts
- race_manager->getNumberOfKarts() + index;
return m_track->getStartTransform(start_index);
return Track::getCurrentTrack()->getStartTransform(start_index);
} // getStartTransform
//-----------------------------------------------------------------------------

View File

@ -61,8 +61,8 @@ void LinearWorld::init()
{
WorldWithRank::init();
assert(!m_track->isArena());
assert(!m_track->isSoccer());
assert(!Track::getCurrentTrack()->isArena());
assert(!Track::getCurrentTrack()->isSoccer());
m_last_lap_sfx_played = false;
m_last_lap_sfx_playing = false;
@ -102,7 +102,7 @@ void LinearWorld::reset()
// the track length must be extended (to avoid negative numbers in
// estimateFinishTimeForKart()). On the other hand future game modes
// might not follow this rule, so check the distance for all karts here:
m_distance_increase = m_track->getTrackLength();
m_distance_increase = Track::getCurrentTrack()->getTrackLength();
for(unsigned int i=0; i<kart_amount; i++)
{
m_distance_increase = std::min(m_distance_increase,
@ -112,8 +112,8 @@ void LinearWorld::reset()
// be increased to avoid negative values in estimateFinishTimeForKart
// Increase this value somewhat in case that a kart drivess/slides
// backwards a little bit at start.
m_distance_increase = m_track->getTrackLength() - m_distance_increase
+ 5.0f;
m_distance_increase = Track::getCurrentTrack()->getTrackLength()
- m_distance_increase + 5.0f;
if(m_distance_increase<0) m_distance_increase = 1.0f; // shouldn't happen
@ -187,7 +187,7 @@ void LinearWorld::update(float dt)
continue;
getTrackSector(n)->update(kart->getFrontXYZ());
kart_info.m_overall_distance = kart_info.m_race_lap
* m_track->getTrackLength()
* Track::getCurrentTrack()->getTrackLength()
+ getDistanceDownTrackForKart(kart->getWorldKartId());
} // for n
@ -277,7 +277,8 @@ void LinearWorld::newLap(unsigned int kart_index)
kart_info.m_time_at_last_lap=getTime();
kart_info.m_race_lap++;
m_kart_info[kart_index].m_overall_distance =
m_kart_info[kart_index].m_race_lap * m_track->getTrackLength()
m_kart_info[kart_index].m_race_lap
* Track::getCurrentTrack()->getTrackLength()
+ getDistanceDownTrackForKart(kart->getWorldKartId());
}
// Last lap message (kart_index's assert in previous block already)
@ -549,7 +550,7 @@ float LinearWorld::estimateFinishTimeForKart(AbstractKart* kart)
const KartInfo &kart_info = m_kart_info[kart->getWorldKartId()];
float full_distance = race_manager->getNumLaps()
* m_track->getTrackLength();
* Track::getCurrentTrack()->getTrackLength();
if(full_distance == 0)
full_distance = 1.0f; // For 0 lap races avoid warning below
@ -651,7 +652,7 @@ btTransform LinearWorld::getRescueTransform(unsigned int index) const
else q1 = btQuaternion(Vec3(0,1,0),0);
// First apply the heading change, than the 'parallelisation' to the plane
btQuaternion q2(btVector3(0,1,0), m_track->getAngle(index));
btQuaternion q2(btVector3(0,1,0), Track::getCurrentTrack()->getAngle(index));
pos.setRotation(q1*q2);
return pos;
} // getRescueTransform

View File

@ -112,7 +112,7 @@ void OverWorld::update(float dt)
setPhase(RACE_PHASE);
// Normally done in WorldStatus::update(), during phase SET_PHASE,
// so we have to start music 'manually', since we skip all phases.
World::getWorld()->getTrack()->startMusic();
Track::getCurrentTrack()->startMusic();
if (UserConfigParams::m_music)
music_manager->startMusic();
@ -212,7 +212,7 @@ void OverWorld::createRaceGUI()
void OverWorld::onFirePressed(Controller* who)
{
const std::vector<OverworldChallenge>& challenges =
m_track->getChallengeList();
Track::getCurrentTrack()->getChallengeList();
AbstractKart* k = getKart(0);
Vec3 kart_xyz = k->getXYZ();

View File

@ -244,7 +244,7 @@ void ProfileWorld::enterRaceOverState()
all_groups.insert(kart->getController()->getControllerName());
float distance = (float)(m_profile_mode==PROFILE_LAPS
? race_manager->getNumLaps() : 1);
distance *= m_track->getTrackLength();
distance *= Track::getCurrentTrack()->getTrackLength();
ss << distance/kart->getFinishTime() << " " << kart->getTopSpeed() << " ";
ss << kart->getSkiddingTime() << " " << kart->getRescueTime() << " ";
ss << kart->getRescueCount() << " " << kart->getBrakeCount() << " ";
@ -300,7 +300,7 @@ void ProfileWorld::enterRaceOverState()
float distance = (float)(m_profile_mode==PROFILE_LAPS
? race_manager->getNumLaps() : 1);
distance *= m_track->getTrackLength();
distance *= Track::getCurrentTrack()->getTrackLength();
Log::verbose("profile",
"%s %4.2f %3.2f %6.2f %4.2f %3d %5d %4.2f %3d %3d %3d %3d %3d %3d %5d %4.2f",

View File

@ -91,13 +91,14 @@ void SoccerWorld::init()
m_goal_target = race_manager->getMaxGoal();
m_goal_sound = SFXManager::get()->createSoundSource("goal_scored");
if (m_track->hasNavMesh())
Track *track = Track::getCurrentTrack();
if (track->hasNavMesh())
{
// Init track sector for ball if navmesh is found
m_ball_track_sector = new TrackSector();
}
TrackObjectManager* tom = getTrack()->getTrackObjectManager();
TrackObjectManager* tom = track->getTrackObjectManager();
assert(tom);
PtrVector<TrackObject>& objects = tom->getObjects();
for (unsigned int i = 0; i < objects.size(); i++)
@ -150,7 +151,7 @@ void SoccerWorld::reset()
m_goal_sound->stop();
}
if (m_track->hasNavMesh())
if (Track::getCurrentTrack()->hasNavMesh())
{
m_ball_track_sector->reset();
}
@ -181,7 +182,7 @@ const std::string& SoccerWorld::getIdent() const
void SoccerWorld::update(float dt)
{
updateBallPosition(dt);
if (m_track->hasNavMesh())
if (Track::getCurrentTrack()->hasNavMesh())
{
updateSectorForKarts();
updateAIData();
@ -457,7 +458,7 @@ void SoccerWorld::updateBallPosition(float dt)
m_ball_body->getLinearVelocity().getZ());
}
if (m_track->hasNavMesh())
if (Track::getCurrentTrack()->hasNavMesh())
{
m_ball_track_sector
->update(getBallPosition(), true/*ignore_vertical*/);

View File

@ -149,7 +149,7 @@ void ThreeStrikesBattle::reset()
TrackObject *obj;
for_in(obj, m_tires)
{
m_track->getTrackObjectManager()->removeObject(obj);
Track::getCurrentTrack()->getTrackObjectManager()->removeObject(obj);
}
m_tires.clearWithoutDeleting();
@ -357,7 +357,7 @@ void ThreeStrikesBattle::update(float dt)
WorldWithRank::updateTrack(dt);
spawnSpareTireKarts();
if (m_track->hasNavMesh())
if (Track::getCurrentTrack()->hasNavMesh())
updateSectorForKarts();
// insert blown away tire(s) now if was requested
@ -419,7 +419,7 @@ void ThreeStrikesBattle::update(float dt)
"movable", tire_presentation,
true /* is_dynamic */,
&physics_settings);
getTrack()->getTrackObjectManager()->insertObject(tire_obj);
Track::getCurrentTrack()->getTrackObjectManager()->insertObject(tire_obj);
// FIXME: orient the force relative to kart orientation
tire_obj->getPhysicalObject()->getBody()
@ -730,7 +730,7 @@ void ThreeStrikesBattle::loadCustomModels()
m_karts.push_back(sta);
race_manager->addSpareTireKart(sta_list[i]);
m_track->adjustForFog(sta->getNode());
Track::getCurrentTrack()->adjustForFog(sta->getNode());
// Copy STA pointer to m_spare_tire_karts array, allowing them
// to respawn easily

View File

@ -29,7 +29,8 @@ TutorialWorld::TutorialWorld()
unsigned int TutorialWorld::getRescuePositionIndex(AbstractKart *kart)
{
const int start_spots_amount = getTrack()->getNumberOfStartPositions();
const int start_spots_amount =
Track::getCurrentTrack()->getNumberOfStartPositions();
assert(start_spots_amount > 0);
float closest_distance = 999999.0f;

View File

@ -114,25 +114,21 @@ World* World::m_world = NULL;
* after the constructor. Those functions must be called in the init()
* function, which is called immediately after the constructor.
*/
World::World() : WorldStatus(), m_clear_color(255,100,101,140)
World::World() : WorldStatus()
{
#ifdef DEBUG
m_magic_number = 0xB01D6543;
#endif
m_physics = NULL;
m_race_gui = NULL;
m_saved_race_gui = NULL;
m_use_highscores = true;
m_track = NULL;
m_schedule_pause = false;
m_schedule_unpause = false;
m_schedule_exit_race = false;
m_schedule_tutorial = false;
m_is_network_world = false;
m_weather = NULL;
m_force_disable_fog = false;
m_stop_music_when_dialog_open = true;
@ -168,9 +164,9 @@ void World::init()
RewindManager::create();
// Grab the track file
m_track = track_manager->getTrack(race_manager->getTrackName());
m_script_engine = new Scripting::ScriptEngine();
if(!m_track)
Track *track = track_manager->getTrack(race_manager->getTrackName());
Scripting::ScriptEngine::getInstance<Scripting::ScriptEngine>();
if(!track)
{
std::ostringstream msg;
msg << "Track '" << race_manager->getTrackName()
@ -178,18 +174,19 @@ void World::init()
throw std::runtime_error(msg.str());
}
std::string script_path = World::getWorld()->getTrack()->getTrackFile("scripting.as");
m_script_engine->loadScript(script_path, true);
std::string script_path = track->getTrackFile("scripting.as");
Scripting::ScriptEngine::getInstance()->loadScript(script_path, true);
// Create the physics
m_physics = new Physics();
Physics::getInstance<Physics>();
unsigned int num_karts = race_manager->getNumberOfKarts();
//assert(num_karts > 0);
// Load the track models - this must be done before the karts so that the
// karts can be positioned properly on (and not in) the tracks.
m_track->loadTrackModel(race_manager->getReverseTrack());
// This also defines the static Track::getCurrentTrack function.
track->loadTrackModel(race_manager->getReverseTrack());
if (gk > 0)
{
@ -216,7 +213,7 @@ void World::init()
race_manager->getKartType(i),
race_manager->getPlayerDifficulty(i));
m_karts.push_back(newkart);
m_track->adjustForFog(newkart->getNode());
track->adjustForFog(newkart->getNode());
} // for i
@ -235,8 +232,7 @@ void World::init()
if (UserConfigParams::m_weather_effects)
{
m_weather = new Weather(m_track->getWeatherLightning(),
m_track->getWeatherSound());
Weather::getInstance<Weather>(); // create Weather instance
}
} // init
@ -282,7 +278,7 @@ void World::reset()
// Note: track reset must be called after all karts exist, since check
// objects need to allocate data structures depending on the number
// of karts.
m_track->reset();
Track::getCurrentTrack()->reset();
// Reset the race gui.
m_race_gui->reset();
@ -387,7 +383,7 @@ AbstractKart *World::createKart(const std::string &kart_ident, int index,
* \param index Index of kart ranging from 0 to kart_num-1. */
const btTransform &World::getStartTransform(int index)
{
return m_track->getStartTransform(index);
return Track::getCurrentTrack()->getStartTransform(index);
} // getStartTransform
//-----------------------------------------------------------------------------
@ -437,9 +433,9 @@ World::~World()
irr_driver->onUnloadWorld();
// In case that a race is aborted (e.g. track not found) m_track is 0.
if(m_track)
m_track->cleanup();
// In case that a race is aborted (e.g. track not found) track is 0.
if(Track::getCurrentTrack())
Track::getCurrentTrack()->cleanup();
// Delete the in-race-gui:
if(m_saved_race_gui)
@ -457,8 +453,7 @@ World::~World()
delete m_race_gui;
}
if (m_weather != NULL)
delete m_weather;
Weather::kill();
for ( unsigned int i = 0 ; i < m_karts.size() ; i++ )
{
@ -489,11 +484,12 @@ World::~World()
Camera::removeAllCameras();
projectile_manager->cleanup();
// In case that the track is not found, m_physics is still undefined.
if(m_physics)
delete m_physics;
delete m_script_engine;
// In case that the track is not found, Physics was not instantiated,
// but kill handles this correctly.
Physics::kill();
Scripting::ScriptEngine::kill();
m_world = NULL;
@ -555,7 +551,7 @@ void World::terminateRace()
// Check achievements
PlayerManager::increaseAchievement(AchievementInfo::ACHIEVE_COLUMBUS,
getTrack()->getIdent(), 1);
Track::getCurrentTrack()->getIdent(), 1);
if (raceHasLaps())
{
PlayerManager::increaseAchievement(AchievementInfo::ACHIEVE_MARATHONER,
@ -654,7 +650,7 @@ void World::resetAllKarts()
{
// Reset the physics 'remaining' time to 0 so that the number
// of timesteps is reproducible if doing a physics-based history run
getPhysics()->getPhysicsWorld()->resetLocalTime();
Physics::getInstance()->getPhysicsWorld()->resetLocalTime();
// If track checking is requested, check all rescue positions if
// they are high enough.
@ -697,13 +693,14 @@ void World::resetAllKarts()
Vec3 up_offset = (*i)->getNormal() * (0.5f * ((*i)->getKartHeight()));
(*i)->setXYZ(xyz+up_offset);
bool kart_over_ground = m_track->findGround(*i);
bool kart_over_ground = Track::getCurrentTrack()->findGround(*i);
if (!kart_over_ground)
{
Log::error("World",
"No valid starting position for kart %d on track %s.",
(int)(i-m_karts.begin()), m_track->getIdent().c_str());
(int)(i - m_karts.begin()),
Track::getCurrentTrack()->getIdent().c_str());
if (UserConfigParams::m_artist_debug_mode)
{
Log::warn("World", "Activating fly mode.");
@ -719,14 +716,14 @@ void World::resetAllKarts()
// Do a longer initial simulation, which should be long enough for all
// karts to be firmly on ground.
float g = World::getWorld()->getTrack()->getGravity();
float g = Track::getCurrentTrack()->getGravity();
for (KartList::iterator i = m_karts.begin(); i != m_karts.end(); i++)
{
if ((*i)->isGhostKart()) continue;
(*i)->getBody()->setGravity((*i)->getMaterial()->hasGravity() ?
(*i)->getNormal() * -g : Vec3(0, -g, 0));
}
for(int i=0; i<60; i++) m_physics->update(1.f/60.f);
for(int i=0; i<60; i++) Physics::getInstance()->update(1.f/60.f);
for ( KartList::iterator i=m_karts.begin(); i!=m_karts.end(); i++)
{
@ -780,7 +777,7 @@ void World::moveKartTo(AbstractKart* kart, const btTransform &transform)
// Project kart to surface of track
// This will set the physics transform
m_track->findGround(kart);
Track::getCurrentTrack()->findGround(kart);
} // moveKartTo
@ -991,17 +988,18 @@ void World::update(float dt)
PROFILER_POP_CPU_MARKER();
if(race_manager->isRecordingRace()) ReplayRecorder::get()->update(dt);
if (m_script_engine) m_script_engine->update(dt);
Scripting::ScriptEngine *script_engine = Scripting::ScriptEngine::getInstance();
if (script_engine) script_engine->update(dt);
if (!history->dontDoPhysics())
{
m_physics->update(dt);
Physics::getInstance()->update(dt);
}
PROFILER_PUSH_CPU_MARKER("World::update (weather)", 0x80, 0x7F, 0x00);
if (UserConfigParams::m_graphical_effects && m_weather)
if (UserConfigParams::m_graphical_effects && Weather::getInstance())
{
m_weather->update(dt);
Weather::getInstance()->update(dt);
}
PROFILER_POP_CPU_MARKER();
@ -1046,7 +1044,7 @@ void World::updateTime(const float dt)
*/
void World::updateTrack(float dt)
{
m_track->update(dt);
Track::getCurrentTrack()->update(dt);
} // update Track
// ----------------------------------------------------------------------------
@ -1275,12 +1273,6 @@ void World::escapePressed()
new RacePausedDialog(0.8f, 0.6f);
} // escapePressed
//-----------------------------------------------------------------------------
bool World::isFogEnabled() const
{
return !m_force_disable_fog && (m_track != NULL && m_track->isFogEnabled());
} // isFogEnabled
// ----------------------------------------------------------------------------
/** Returns the start transform with the give index.
* \param rescue_pos Index of the start position to be returned.
@ -1288,7 +1280,7 @@ bool World::isFogEnabled() const
*/
btTransform World::getRescueTransform(unsigned int rescue_pos) const
{
return m_track->getStartTransform(rescue_pos);
return Track::getCurrentTrack()->getStartTransform(rescue_pos);
} // getRescueTransform
//-----------------------------------------------------------------------------
@ -1296,7 +1288,7 @@ btTransform World::getRescueTransform(unsigned int rescue_pos) const
*/
unsigned int World::getNumberOfRescuePositions() const
{
return m_track->getNumberOfStartPositions();
return Track::getCurrentTrack()->getNumberOfStartPositions();
} // getNumberOfRescuePositions
/* EOF */

View File

@ -41,8 +41,6 @@ class AbstractKart;
class btRigidBody;
class Controller;
class PhysicalObject;
class Physics;
class Track;
namespace Scripting
{
@ -96,8 +94,6 @@ protected:
KartList m_karts;
RandomGenerator m_random;
Physics* m_physics;
bool m_force_disable_fog;
AbstractKart* m_fastest_kart;
/** Number of eliminated karts. */
int m_eliminated_karts;
@ -125,11 +121,6 @@ protected:
int local_player_id, int global_player_id,
RaceManager::KartType type,
PerPlayerDifficulty difficulty);
/** Pointer to the track. The track is managed by world. */
Track* m_track;
/**Pointer to scripting engine */
Scripting::ScriptEngine* m_script_engine;
/** Pointer to the race GUI. The race GUI is handled by world. */
RaceGUIBase *m_race_gui;
@ -141,8 +132,6 @@ protected:
there are scene nodes). */
RaceGUIBase *m_saved_race_gui;
irr::video::SColor m_clear_color;
/** Pausing/unpausing are not done immediately, but at next udpdate. The
* use of this is when switching between screens : if we leave a screen
* that paused the game, only to go to another screen that pauses back
@ -171,10 +160,6 @@ protected:
/** Set when the world is online and counts network players. */
bool m_is_network_world;
/** Used to show weather graphical effects. */
Weather* m_weather;
virtual void onGo() OVERRIDE;
/** Returns true if the race is over. Must be defined by all modes. */
virtual bool isRaceOver() = 0;
@ -294,6 +279,7 @@ public:
AbstractKart* getPlayerKart(unsigned int player) const;
AbstractKart* getLocalPlayerKart(unsigned int n) const;
virtual const btTransform &getStartTransform(int index);
void moveKartTo(AbstractKart* kart, const btTransform &t);
// ------------------------------------------------------------------------
/** Returns a pointer to the race gui. */
RaceGUIBase *getRaceGUI() const { return m_race_gui;}
@ -317,20 +303,6 @@ public:
unsigned int getCurrentNumPlayers() const { return m_num_players -
m_eliminated_players;}
// ------------------------------------------------------------------------
/** Returns a pointer to the physics. */
Physics *getPhysics() const { return m_physics; }
// ------------------------------------------------------------------------
/** Returns a pointer to the track. */
Track *getTrack() const { return m_track; }
// ------------------------------------------------------------------------
/** Returns a pointer to the Scripting Engine. */
Scripting::ScriptEngine *getScriptEngine()
const { return m_script_engine; }
//-------------------------------------------------------------------------
bool isFogEnabled() const;
// ------------------------------------------------------------------------
void moveKartTo(AbstractKart* kart, const btTransform &t);
// ------------------------------------------------------------------------
/** The code that draws the timer should call this first to know
* whether the game mode wants a timer drawn. */
virtual bool shouldDrawTimer() const
@ -339,17 +311,6 @@ public:
/** \return whether this world can generate/have highscores */
bool useHighScores() const { return m_use_highscores; }
// ------------------------------------------------------------------------
/** Returns the color to clear the back buffer. */
const irr::video::SColor& getClearColor() const { return m_clear_color; }
// ------------------------------------------------------------------------
/** Sets the color to use when clearing the back buffer. */
void setClearbackBufferColor(irr::video::SColor color)
{
m_clear_color = color;
}
/** Override track fog value to force disabled */
void forceFogDisabled(bool v) { m_force_disable_fog = v; }
// ------------------------------------------------------------------------
/** Override if you want to know when a kart presses fire */
virtual void onFirePressed(Controller* who) {}
// ------------------------------------------------------------------------
@ -366,8 +327,6 @@ public:
bool isNetworkWorld() const { return m_is_network_world; }
/** Returns a pointer to the weather. */
Weather* getWeather() {return m_weather;}
}; // World
#endif

View File

@ -74,8 +74,8 @@ void WorldStatus::reset()
if (UserConfigParams::m_race_now)
{
// Setup music and sound
if (World::getWorld()->getWeather() != NULL)
World::getWorld()->getWeather()->playSound();
if (Weather::getInstance())
Weather::getInstance()->playSound();
// Start engines
for (unsigned int i = 0; i < World::getWorld()->getNumKarts(); i++)
@ -92,7 +92,7 @@ void WorldStatus::reset()
device->getTimer()->start();
// Set the right music
World::getWorld()->getTrack()->startMusic();
Track::getCurrentTrack()->startMusic();
// In case of a networked race the race can only start once
// all protocols are up. This flag is used to wait for
// a confirmation before starting the actual race.
@ -196,9 +196,9 @@ void WorldStatus::updateTime(const float dt)
m_track_intro_sound->play();
}
if (World::getWorld()->getWeather() != NULL)
if (Weather::getInstance())
{
World::getWorld()->getWeather()->playSound();
Weather::getInstance()->playSound();
}
return; // Do not increase time

View File

@ -52,8 +52,9 @@ void WorldWithRank::init()
#endif
stk_config->getAllScores(&m_score_for_position, getNumKarts());
Track *track = Track::getCurrentTrack();
// Don't init track sector if navmesh is not found in arena
if ((m_track->isArena() || m_track->isSoccer()) && !m_track->hasNavMesh())
if ((track->isArena() || track->isSoccer()) && !track->hasNavMesh())
return;
for (unsigned int i = 0; i < m_karts.size(); i++)
@ -167,7 +168,8 @@ void WorldWithRank::endSetKartPositions()
unsigned int WorldWithRank::getRescuePositionIndex(AbstractKart *kart)
{
const int start_spots_amount = getTrack()->getNumberOfStartPositions();
const int start_spots_amount =
Track::getCurrentTrack()->getNumberOfStartPositions();
assert(start_spots_amount > 0);
float largest_accumulated_distance_found = -1;

View File

@ -217,8 +217,8 @@ void ServerLobby::update(float dt)
signalRaceStartToClients();
m_server_delay = 0.02f;
m_client_ready_count.getData() = 0;
m_client_ready_count.unlock();
}
m_client_ready_count.unlock();
// Initialise counter again, to wait for all clients to indicate that
// they have started the race/
break;
@ -887,11 +887,11 @@ void ServerLobby::finishedLoadingWorldClient(Event *event)
m_client_ready_count.unlock();
return;
}
Log::info("ServerLobbyeProtocol", "Player %d is ready (%d/%d).",
player_id, m_client_ready_count.getData(),
m_game_setup->getPlayerCount() );
m_player_states[player_id] = true;
m_client_ready_count.getData()++;
Log::info("ServerLobbyeProtocol", "Player %d is ready (%d/%d).",
player_id, m_client_ready_count.getData(),
m_game_setup->getPlayerCount());
}
m_client_ready_count.unlock();

View File

@ -18,7 +18,6 @@
#include "network/rewind_info.hpp"
#include "modes/world.hpp"
#include "physics/physics.hpp"
/** Constructor for a state: it only takes the size, and allocates a buffer
@ -42,8 +41,8 @@ RewindInfoState::RewindInfoState(float time, Rewinder *rewinder,
BareNetworkString *buffer, bool is_confirmed)
: RewindInfoRewinder(time, rewinder, buffer, is_confirmed)
{
m_local_physics_time = World::getWorld()->getPhysics()->getPhysicsWorld()
->getLocalTime();
m_local_physics_time = Physics::getInstance()->getPhysicsWorld()
->getLocalTime();
} // RewindInfoState
// ============================================================================

View File

@ -322,7 +322,7 @@ void RewindManager::rewindTo(float rewind_time)
// Now start the rewind with the full state:
world->setTime(exact_rewind_time);
float local_physics_time = state->getLocalPhysicsTime();
world->getPhysics()->getPhysicsWorld()->setLocalTime(local_physics_time);
Physics::getInstance()->getPhysicsWorld()->setLocalTime(local_physics_time);
// Restore all states from the current time - the full state of a race
// will be potentially stored in several state objects. State can be NULL

View File

@ -24,7 +24,6 @@
#include "graphics/material.hpp"
#include "karts/kart.hpp"
#include "modes/world.hpp"
#include "physics/triangle_mesh.hpp"
#include "tracks/terrain_info.hpp"
#include "tracks/track.hpp"
@ -1026,7 +1025,7 @@ void btKart::debugDraw(btIDebugDraw* debugDrawer)
int n = w.m_raycastInfo.m_triangle_index;
if (n > -1)
{
const TriangleMesh &tm = World::getWorld()->getTrack()->getTriangleMesh();
const TriangleMesh &tm = Track::getCurrentTrack()->getTriangleMesh();
btVector3 *p1, *p2, *p3;
tm.getTriangle(n, &p1, &p2, &p3);
const btVector3 *n1, *n2, *n3;

View File

@ -72,7 +72,7 @@ void* btKartRaycaster::castRay(const btVector3& from, const btVector3& to,
result.m_distFraction = rayCallback.m_closestHitFraction;
result.m_triangle_index = -1;
const TriangleMesh &tm =
World::getWorld()->getTrack()->getTriangleMesh();
Track::getCurrentTrack()->getTriangleMesh();
if(m_smooth_normals &&
rayCallback.getTriangleIndex()>-1)
{

View File

@ -18,18 +18,12 @@
#include "physics/physical_object.hpp"
#include <memory>
#include <string>
#include <vector>
using namespace irr;
#include "config/stk_config.hpp"
#include "graphics/material.hpp"
#include "graphics/material_manager.hpp"
#include "graphics/mesh_tools.hpp"
#include "io/file_manager.hpp"
#include "io/xml_node.hpp"
#include "modes/world.hpp"
#include "physics/physics.hpp"
#include "physics/triangle_mesh.hpp"
#include "tracks/track.hpp"
@ -40,6 +34,11 @@ using namespace irr;
#include <ISceneManager.h>
#include <IMeshSceneNode.h>
#include <ITexture.h>
using namespace irr;
#include <memory>
#include <string>
#include <vector>
/** Creates a physical Settings object with the given type, radius and mass.
*/
@ -180,7 +179,7 @@ PhysicalObject::PhysicalObject(bool is_dynamic,
// ----------------------------------------------------------------------------
PhysicalObject::~PhysicalObject()
{
World::getWorld()->getPhysics()->removeBody(m_body);
Physics::getInstance()->removeBody(m_body);
delete m_body;
delete m_motion_state;
@ -540,7 +539,7 @@ void PhysicalObject::init(const PhysicalObject::Settings& settings)
m_body->setActivationState(DISABLE_DEACTIVATION);
}
World::getWorld()->getPhysics()->addBody(m_body);
Physics::getInstance()->addBody(m_body);
m_body_added = true;
if(m_triangle_mesh)
m_triangle_mesh->setBody(m_body);
@ -672,7 +671,7 @@ void PhysicalObject::removeBody()
{
if (m_body_added)
{
World::getWorld()->getPhysics()->removeBody(m_body);
Physics::getInstance()->removeBody(m_body);
m_body_added = false;
}
} // Remove body
@ -684,7 +683,7 @@ void PhysicalObject::addBody()
if (!m_body_added)
{
m_body_added = true;
World::getWorld()->getPhysics()->addBody(m_body);
Physics::getInstance()->addBody(m_body);
}
} // Add body

View File

@ -69,7 +69,7 @@ void Physics::init(const Vec3 &world_min, const Vec3 &world_max)
m_karts_to_delete.clear();
m_dynamics_world->setGravity(
btVector3(0.0f,
-World::getWorld()->getTrack()->getGravity(),
-Track::getCurrentTrack()->getGravity(),
0.0f));
m_debug_drawer = new IrrDebugDrawer();
m_dynamics_world->setDebugDrawer(m_debug_drawer);
@ -169,7 +169,8 @@ void Physics::update(float dt)
p->getContactPointCS(0),
p->getUserPointer(1)->getPointerKart(),
p->getContactPointCS(1) );
Scripting::ScriptEngine* script_engine = World::getWorld()->getScriptEngine();
Scripting::ScriptEngine* script_engine =
Scripting::ScriptEngine::getInstance();
int kartid1 = p->getUserPointer(0)->getPointerKart()->getWorldKartId();
int kartid2 = p->getUserPointer(1)->getPointerKart()->getWorldKartId();
script_engine->runFunction(false, "void onKartKartCollision(int, int)",
@ -184,7 +185,7 @@ void Physics::update(float dt)
{
// Kart hits physical object
// -------------------------
Scripting::ScriptEngine* script_engine = World::getWorld()->getScriptEngine();
Scripting::ScriptEngine* script_engine = Scripting::ScriptEngine::getInstance();
AbstractKart *kart = p->getUserPointer(1)->getPointerKart();
int kartId = kart->getWorldKartId();
PhysicalObject* obj = p->getUserPointer(0)->getPointerPhysicalObject();
@ -267,7 +268,7 @@ void Physics::update(float dt)
{
// Projectile hits physical object
// -------------------------------
Scripting::ScriptEngine* script_engine = World::getWorld()->getScriptEngine();
Scripting::ScriptEngine* script_engine = Scripting::ScriptEngine::getInstance();
Flyable* flyable = p->getUserPointer(0)->getPointerFlyable();
PhysicalObject* obj = p->getUserPointer(1)->getPointerPhysicalObject();
std::string obj_id = obj->getID();

View File

@ -32,6 +32,7 @@
#include "physics/irr_debug_drawer.hpp"
#include "physics/stk_dynamics_world.hpp"
#include "physics/user_pointer.hpp"
#include "utils/singleton.hpp"
class AbstractKart;
class STKDynamicsWorld;
@ -41,6 +42,7 @@ class Vec3;
* \ingroup physics
*/
class Physics : public btSequentialImpulseConstraintSolver
, public AbstractSingleton<Physics>
{
private:
/** Bullet can report the same collision more than once (up to 4
@ -53,7 +55,8 @@ private:
* overhead (since it will likely use a tree to sort the entries).
* Considering that the number of collisions is usually rather small
* a simple list and linear search is faster is is being used here. */
class CollisionPair {
class CollisionPair
{
private:
/** The user pointer of the objects involved in this collision. */
const UserPointer *m_up[2];
@ -140,14 +143,22 @@ private:
/** Used in physics debugging to draw the physics world. */
IrrDebugDrawer *m_debug_drawer;
btCollisionDispatcher *m_dispatcher;
btBroadphaseInterface *m_axis_sweep;
btDefaultCollisionConfiguration *m_collision_conf;
CollisionList m_all_collisions;
/** Singleton. */
static Physics *m_physics;
Physics();
virtual ~Physics();
// Give the singleton access to the constructor
friend class AbstractSingleton<Physics>;
public:
Physics ();
~Physics ();
void init (const Vec3 &min_world, const Vec3 &max_world);
void addKart (const AbstractKart *k);
void addBody (btRigidBody* b) {m_dynamics_world->addRigidBody(b);}

View File

@ -21,6 +21,10 @@
#include "btBulletDynamicsCommon.h"
/** A thin wrapper around bullet's btDiscreteDynamicsWorld. Used to
* be able to query and set the 'left over' time from a previous
* time step, which is needed for more precise rewind/replays.
*/
class STKDynamicsWorld : public btDiscreteDynamicsWorld
{
public:

View File

@ -18,13 +18,13 @@
#include "physics/triangle_mesh.hpp"
#include "btBulletDynamicsCommon.h"
#include "modes/world.hpp"
#include "config/stk_config.hpp"
#include "physics/physics.hpp"
#include "utils/constants.hpp"
#include "utils/time.hpp"
#include "btBulletDynamicsCommon.h"
#include <fstream>
// -----------------------------------------------------------------------------
@ -190,7 +190,7 @@ void TriangleMesh::createPhysicalBody(btCollisionObject::CollisionFlags flags,
m_collision_shape);
info.m_restitution = 0.8f;
m_body=new btRigidBody(info);
World::getWorld()->getPhysics()->addBody(m_body);
Physics::getInstance()->addBody(m_body);
m_body->setUserPointer(&m_user_pointer);
m_body->setCollisionFlags(m_body->getCollisionFlags() |
@ -210,7 +210,7 @@ void TriangleMesh::removeAll()
// Don't free the physical body if it was created outside this object.
if(m_body && m_free_body)
{
World::getWorld()->getPhysics()->removeBody(m_body);
Physics::getInstance()->removeBody(m_body);
delete m_body;
delete m_motion_state;
m_body = NULL;

View File

@ -181,7 +181,7 @@ void History::Save()
fprintf(fd, "difficulty: %d\n", race_manager->getDifficulty());
fprintf(fd, "reverse: %c\n", race_manager->getReverseTrack() ? 'y' : 'n');
fprintf(fd, "track: %s\n", world->getTrack()->getIdent().c_str());
fprintf(fd, "track: %s\n", Track::getCurrentTrack()->getIdent().c_str());
assert(num_karts > 0);

View File

@ -203,7 +203,7 @@ void ReplayRecorder::save()
std::string time = StringUtils::toString(min_time);
std::replace(time.begin(), time.end(), '.', '_');
std::ostringstream oss;
oss << world->getTrack()->getIdent() << "_" << year << month << day
oss << Track::getCurrentTrack()->getIdent() << "_" << year << month << day
<< "_" << num_karts << "_" << time << ".replay";
m_filename = oss.str();
@ -230,7 +230,7 @@ void ReplayRecorder::save()
fprintf(fd, "kart_list_end\n");
fprintf(fd, "reverse: %d\n", (int)race_manager->getReverseTrack());
fprintf(fd, "difficulty: %d\n", race_manager->getDifficulty());
fprintf(fd, "track: %s\n", world->getTrack()->getIdent().c_str());
fprintf(fd, "track: %s\n", Track::getCurrentTrack()->getIdent().c_str());
fprintf(fd, "laps: %d\n", race_manager->getNumLaps());
fprintf(fd, "min_time: %f\n", min_time);

View File

@ -48,37 +48,41 @@ namespace Scripting
* @{
*/
// --------------------------------------------------------------------
/** Get number of challenges that were completed at any difficulty */
int getCompletedChallengesCount()
{
::Track* track = World::getWorld()->getTrack();
return track->getNumOfCompletedChallenges();
}
return ::Track::getCurrentTrack()->getNumOfCompletedChallenges();
} // getCompletedChallengesCount
// --------------------------------------------------------------------
/** Get total number of challenges */
int getChallengeCount()
{
::Track* track = World::getWorld()->getTrack();
return track->getChallengeList().size();
}
return ::Track::getCurrentTrack()->getChallengeList().size();
} // getChallengeCount
// --------------------------------------------------------------------
int getChallengeRequiredPoints(std::string* challenge_name)
{
const ChallengeData* challenge = unlock_manager->getChallengeData(*challenge_name);
const ChallengeData* challenge =
unlock_manager->getChallengeData(*challenge_name);
if (challenge == NULL)
{
if (*challenge_name != "tutorial")
Log::error("track", "Cannot find challenge named '%s'\n",
challenge_name->c_str());
challenge_name->c_str());
return false;
}
return challenge->getNumTrophies();
}
} // getChallengeRequiredPoints
// --------------------------------------------------------------------
bool isChallengeUnlocked(std::string* challenge_name)
{
const ChallengeData* challenge = unlock_manager->getChallengeData(*challenge_name);
const ChallengeData* challenge =
unlock_manager->getChallengeData(*challenge_name);
if (challenge == NULL)
{
if (*challenge_name != "tutorial")
@ -90,8 +94,9 @@ namespace Scripting
const unsigned int val = challenge->getNumTrophies();
bool shown = (PlayerManager::getCurrentPlayer()->getPoints() >= val);
return shown;
}
} // isChallengeUnlocked
// --------------------------------------------------------------------
/** @}*/
/** @}*/
@ -101,15 +106,27 @@ namespace Scripting
engine->SetDefaultNamespace("Challenges");
r = engine->RegisterGlobalFunction("int getCompletedChallengesCount()", asFUNCTION(getCompletedChallengesCount), asCALL_CDECL); assert(r >= 0);
r = engine->RegisterGlobalFunction("int getChallengeCount()", asFUNCTION(getChallengeCount), asCALL_CDECL); assert(r >= 0);
r = engine->RegisterGlobalFunction("bool isChallengeUnlocked(string &in)", asFUNCTION(isChallengeUnlocked), asCALL_CDECL); assert(r >= 0);
r = engine->RegisterGlobalFunction("int getChallengeRequiredPoints(string &in)", asFUNCTION(getChallengeRequiredPoints), asCALL_CDECL); assert(r >= 0);
}
r = engine->RegisterGlobalFunction("int getCompletedChallengesCount()",
asFUNCTION(getCompletedChallengesCount),
asCALL_CDECL);
assert(r >= 0);
r = engine->RegisterGlobalFunction("int getChallengeCount()",
asFUNCTION(getChallengeCount),
asCALL_CDECL);
assert(r >= 0);
r = engine->RegisterGlobalFunction("bool isChallengeUnlocked(string &in)",
asFUNCTION(isChallengeUnlocked),
asCALL_CDECL);
assert(r >= 0);
r = engine->RegisterGlobalFunction("int getChallengeRequiredPoints(string &in)",
asFUNCTION(getChallengeRequiredPoints),
asCALL_CDECL);
assert(r >= 0);
} // registerScriptFunctions
}
} // namespace Challenges
/** \cond DOXYGEN_IGNORE */
}
} // namespace Scripting
/** \endcond */

View File

@ -19,14 +19,15 @@
#ifndef HEADER_SCRIPT_ENGINE_HPP
#define HEADER_SCRIPT_ENGINE_HPP
#include <string>
#include <angelscript.h>
#include <functional>
#include <map>
#include "scriptengine/script_utils.hpp"
#include "utils/no_copy.hpp"
#include "utils/ptr_vector.hpp"
#include "utils/singleton.hpp"
#include <angelscript.h>
#include <functional>
#include <map>
#include <string>
class TrackObjectPresentation;
@ -55,12 +56,16 @@ namespace Scripting
~PendingTimeout();
};
class ScriptEngine
class ScriptEngine : public AbstractSingleton<ScriptEngine>
{
ScriptEngine();
~ScriptEngine();
// Give the singleton access to the constructor.
friend class AbstractSingleton<ScriptEngine>;
public:
ScriptEngine();
~ScriptEngine();
void runFunction(bool warn_if_not_found, std::string function_name);
void runFunction(bool warn_if_not_found, std::string function_name,

View File

@ -67,7 +67,8 @@ namespace Scripting
*/
::TrackObject* getTrackObject(std::string* libraryInstance, std::string* objID)
{
return World::getWorld()->getTrack()->getTrackObjectManager()->getTrackObject(*libraryInstance, *objID);
return ::Track::getCurrentTrack()->getTrackObjectManager()
->getTrackObject(*libraryInstance, *objID);
}
/** Creates a trigger at the specified location */
@ -84,7 +85,7 @@ namespace Scripting
::TrackObject* tobj = new ::TrackObject(posi, hpr, scale,
"none", newtrigger, false /* isDynamic */, NULL /* physics settings */);
tobj->setID(*triggerID);
World::getWorld()->getTrack()->getTrackObjectManager()->insertObject(tobj);
::Track::getCurrentTrack()->getTrackObjectManager()->insertObject(tobj);
}
void createTextBillboard(std::string* text, SimpleVec3* location)
@ -104,7 +105,7 @@ namespace Scripting
irr_driver->getSceneManager(), -1, xyz,
core::vector3df(1.5f, 1.5f, 1.5f));
World::getWorld()->getTrack()->addNode(tb);
::Track::getCurrentTrack()->addNode(tb);
tb->drop();
}
else
@ -121,7 +122,7 @@ namespace Scripting
-1, // id
GUIEngine::getSkin()->getColor("font::bottom"),
GUIEngine::getSkin()->getColor("font::top"));
World::getWorld()->getTrack()->addNode(sn);
::Track::getCurrentTrack()->addNode(sn);
}
#endif
}
@ -155,7 +156,7 @@ namespace Scripting
void setFog(float maxDensity, float start, float end, int r, int g, int b, float duration)
{
PropertyAnimator* animator = PropertyAnimator::get();
::Track* track = World::getWorld()->getTrack();
::Track* track = ::Track::getCurrentTrack();
animator->add(
new AnimatedProperty(FOG_MAX, 1,
new double[1] { track->getFogMax() },

View File

@ -22,7 +22,6 @@
#include "input/device_manager.hpp"
#include "input/input_device.hpp"
#include "input/input_manager.hpp"
#include "modes/world.hpp"
#include "scriptengine/script_engine.hpp"
#include "states_screens/dialogs/tutorial_message_dialog.hpp"
#include "tracks/track.hpp"
@ -109,8 +108,7 @@ namespace Scripting
/** Runs the script function specified by the given string */
void runScript(const std::string* str)
{
ScriptEngine* script_engine = World::getWorld()->getScriptEngine();
script_engine->runFunction(true, *str);
ScriptEngine::getInstance()->runFunction(true, *str);
}
/** Generate a random integer value */
@ -129,13 +127,13 @@ namespace Scripting
/** Call a function after the specified delay */
void setTimeout(const std::string* callback_name, float delay)
{
World::getWorld()->getScriptEngine()->addPendingTimeout(delay, *callback_name);
ScriptEngine::getInstance()->addPendingTimeout(delay, *callback_name);
}
/** Call a method from the given object after the specified delay */
void setTimeoutDelegate(asIScriptFunction* obj, float delay)
{
World::getWorld()->getScriptEngine()->addPendingTimeout(delay, obj);
ScriptEngine::getInstance()->addPendingTimeout(delay, obj);
}
/** Log to the console */

View File

@ -21,7 +21,6 @@
#include "guiengine/widgets/button_widget.hpp"
#include "guiengine/widgets/label_widget.hpp"
#include "guiengine/widgets/text_box_widget.hpp"
#include "modes/world.hpp"
#include "scriptengine/script_engine.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/translation.hpp"
@ -80,7 +79,8 @@ void ScriptingConsole::runScript()
core::stringw script = textCtrl->getText();
textCtrl->setText(L"");
World::getWorld()->getScriptEngine()->evalScript(core::stringc(script.c_str()).c_str());
Scripting::ScriptEngine::getInstance()
->evalScript(core::stringc(script.c_str()).c_str());
}
// -----------------------------------------------------------------------------

View File

@ -161,7 +161,7 @@ void GrandPrixLose::onUpdate(float dt)
void GrandPrixLose::setKarts(std::vector<std::string> ident_arg)
{
TrackObjectManager* tobjman = World::getWorld()->getTrack()->getTrackObjectManager();
TrackObjectManager* tobjman = Track::getCurrentTrack()->getTrackObjectManager();
assert(ident_arg.size() > 0);
if ((int)ident_arg.size() > MAX_KART_COUNT)

View File

@ -292,9 +292,10 @@ void GrandPrixWin::onUpdate(float dt)
void GrandPrixWin::setKarts(const std::string idents_arg[3])
{
TrackObjectManager* tobjman = World::getWorld()->getTrack()->getTrackObjectManager();
TrackObjectManager* tobjman = Track::getCurrentTrack()->getTrackObjectManager();
// reorder in "podium order" (i.e. second player to the left, first player in the middle, last at the right)
// reorder in "podium order" (i.e. second player to the left, first player
// in the middle, last at the right)
std::string idents[3];
idents[0] = idents_arg[1];
idents[1] = idents_arg[0];

View File

@ -809,15 +809,10 @@ void KartSelectionScreen::updateKartStats(uint8_t widget_id,
const KartProperties *kp =
kart_properties_manager->getKart(selection);
if (kp != NULL)
{
// Scale the values so they look better
w->setValue(KartStatsWidget::SKILL_MASS, (int)
((kp->getCombinedCharacteristic()->getMass() - 20) / 4));
w->setValue(KartStatsWidget::SKILL_SPEED, (int)
((kp->getCombinedCharacteristic()->getEngineMaxSpeed() - 15) * 6));
w->setValue(KartStatsWidget::SKILL_POWER, (int)
((kp->getAvgPower() - 30) / 20));
w->setValues(kp);
w->update(0);
}
}

View File

@ -216,7 +216,7 @@ void RaceGUI::renderGlobal(float dt)
drawGlobalMiniMap();
if (!m_is_tutorial) drawGlobalPlayerIcons(m_map_height);
if(world->getTrack()->isSoccer()) drawScores();
if(Track::getCurrentTrack()->isSoccer()) drawScores();
#endif
} // renderGlobal
@ -378,10 +378,9 @@ void RaceGUI::drawGlobalTimer()
void RaceGUI::drawGlobalMiniMap()
{
#ifndef SERVER_ONLY
World *world = World::getWorld();
// draw a map when arena has a navigation mesh.
if ((world->getTrack()->isArena() || world->getTrack()->isSoccer()) &&
!(world->getTrack()->hasNavMesh()))
Track *track = Track::getCurrentTrack();
if ( (track->isArena() || track->isSoccer()) && !(track->hasNavMesh()) )
return;
int upper_y = irr_driver->getActualScreenSize().Height - m_map_bottom - m_map_height;
@ -390,8 +389,9 @@ void RaceGUI::drawGlobalMiniMap()
core::rect<s32> dest(m_map_left, upper_y,
m_map_left + m_map_width, lower_y);
world->getTrack()->drawMiniMap(dest);
track->drawMiniMap(dest);
World *world = World::getWorld();
for(unsigned int i=0; i<world->getNumKarts(); i++)
{
const AbstractKart *kart = world->getKart(i);
@ -401,7 +401,7 @@ void RaceGUI::drawGlobalMiniMap()
if(kart->isEliminated() && !(sta && sta->isMoving())) continue;
const Vec3& xyz = kart->getXYZ();
Vec3 draw_at;
world->getTrack()->mapPoint2MiniMap(xyz, &draw_at);
track->mapPoint2MiniMap(xyz, &draw_at);
draw_at *= UserConfigParams::m_scale_rtts_factor;
video::ITexture* icon = sta ?
@ -424,7 +424,7 @@ void RaceGUI::drawGlobalMiniMap()
if (sw)
{
Vec3 draw_at;
world->getTrack()->mapPoint2MiniMap(sw->getBallPosition(), &draw_at);
track->mapPoint2MiniMap(sw->getBallPosition(), &draw_at);
draw_at *= UserConfigParams::m_scale_rtts_factor;
video::ITexture* icon =
irr_driver->getTexture(FileManager::GUI, "soccer_ball_normal.png");

View File

@ -740,7 +740,7 @@ void RaceGUIBase::drawGlobalPlayerIcons(int bottom_margin)
LinearWorld *linear_world = (LinearWorld*)(World::getWorld());
float distance = linear_world->getDistanceDownTrackForKart(kart_id)
+ linear_world->getTrack()->getTrackLength()*lap;
+ Track::getCurrentTrack()->getTrackLength()*lap;
if ((position>1) &&
(previous_distance-distance<m_dist_show_overlap) &&
(!kart->hasFinishedRace()) )

View File

@ -303,9 +303,9 @@ void RaceGUIOverworld::drawGlobalMiniMap()
#ifndef SERVER_ONLY
World *world = World::getWorld();
// arenas currently don't have a map.
if(world->getTrack()->isArena() || world->getTrack()->isSoccer()) return;
Track* track = Track::getCurrentTrack();
if(track->isArena() || track->isSoccer()) return;
Track* track = world->getTrack();
const std::vector<OverworldChallenge>& challenges =
track->getChallengeList();
@ -332,7 +332,7 @@ void RaceGUIOverworld::drawGlobalMiniMap()
core::rect<s32> dest(m_map_left, upper_y,
m_map_left + m_map_width, lower_y);
world->getTrack()->drawMiniMap(dest);
track->drawMiniMap(dest);
Vec3 kart_xyz;

View File

@ -24,7 +24,6 @@
#include "graphics/camera.hpp"
#include "io/xml_node.hpp"
#include "karts/abstract_kart.hpp"
#include "modes/world.hpp"
#include "race/race_manager.hpp"
#include "tracks/track.hpp"
@ -47,7 +46,6 @@ void AmbientLightSphere::update(float dt)
{
CheckStructure::update(dt);
World *world = World::getWorld();
for(unsigned int i=0; i<Camera::getNumCameras(); i++)
{
Camera *camera = Camera::getCamera(i);
@ -57,7 +55,7 @@ void AmbientLightSphere::update(float dt)
{
float d2=getDistance2ForKart(i);
video::SColor color;
Track *track=world->getTrack();
Track *track=Track::getCurrentTrack();
if(d2<m_inner_radius2)
{ // Inside inner radius --> use new ambient color
color = m_ambient_color;

View File

@ -64,7 +64,7 @@ bool CheckLap::isTriggered(const Vec3 &old_pos, const Vec3 &new_pos,
World* w = World::getWorld();
LinearWorld* lin_world = dynamic_cast<LinearWorld*>(w);
float track_length = w->getTrack()->getTrackLength();
float track_length = Track::getCurrentTrack()->getTrackLength();
// Can happen if a non-lap based race mode is used with a scene file that
// has check defined.
if(!lin_world)

View File

@ -28,6 +28,7 @@
#include "tracks/arena_node_3d.hpp"
#include "tracks/drive_node_2d.hpp"
#include "tracks/drive_node_3d.hpp"
#include "tracks/track.hpp"
#include "utils/log.hpp"
const int Graph::UNKNOWN_SECTOR = -1;
@ -243,10 +244,9 @@ RenderTarget* Graph::makeMiniMap(const core::dimension2du &dimension,
// Skip minimap when profiling
if (ProfileWorld::isNoGraphics()) return NULL;
const video::SColor oldClearColor = World::getWorld()->getClearColor();
World::getWorld()
->setClearbackBufferColor(video::SColor(0, 255, 255, 255));
World::getWorld()->forceFogDisabled(true);
const video::SColor oldClearColor = irr_driver->getClearColor();
irr_driver->setClearbackBufferColor(video::SColor(0, 255, 255, 255));
Track::getCurrentTrack()->forceFogDisabled(true);
#ifndef SERVER_ONLY
m_render_target = irr_driver->createRenderTarget(dimension, name);
#endif
@ -330,8 +330,8 @@ RenderTarget* Graph::makeMiniMap(const core::dimension2du &dimension,
cleanupDebugMesh();
irr_driver->removeCameraSceneNode(camera);
World::getWorld()->setClearbackBufferColor(oldClearColor);
World::getWorld()->forceFogDisabled(false);
irr_driver->setClearbackBufferColor(oldClearColor);
Track::getCurrentTrack()->forceFogDisabled(false);
irr_driver->getSceneManager()->clear();
VAOManager::kill();

View File

@ -18,7 +18,6 @@
#include "tracks/terrain_info.hpp"
#include "modes/world.hpp"
#include "physics/triangle_mesh.hpp"
#include "race/race_manager.hpp"
#include "tracks/track.hpp"
@ -58,11 +57,11 @@ void TerrainInfo::update(const Vec3 &from)
btVector3 to(from);
to.setY(-10000.0f);
const TriangleMesh &tm = World::getWorld()->getTrack()->getTriangleMesh();
const TriangleMesh &tm = Track::getCurrentTrack()->getTriangleMesh();
tm.castRay(from, to, &m_hit_point, &m_material, &m_normal,
/*interpolate*/false);
// Now also raycast against all track objects (that are driveable).
World::getWorld()->getTrack()->getTrackObjectManager()
Track::getCurrentTrack()->getTrackObjectManager()
->castRay(from, to, &m_hit_point, &m_material,
&m_normal, /*interpolate*/false);
} // update
@ -83,15 +82,15 @@ void TerrainInfo::update(const btMatrix3x3 &rotation, const Vec3 &from)
btVector3 to(0, -10000.0f, 0);
to = from + rotation*to;
const TriangleMesh &tm = World::getWorld()->getTrack()->getTriangleMesh();
const TriangleMesh &tm = Track::getCurrentTrack()->getTriangleMesh();
tm.castRay(from, to, &m_hit_point, &m_material, &m_normal,
/*interpolate*/true);
// Now also raycast against all track objects (that are driveable). If
// there should be a closer result (than the one against the main track
// mesh), its data will be returned.
World::getWorld()->getTrack()->getTrackObjectManager()
->castRay(from, to, &m_hit_point, &m_material,
&m_normal, /*interpolate*/true);
Track::getCurrentTrack()->getTrackObjectManager()
->castRay(from, to, &m_hit_point, &m_material,
&m_normal, /*interpolate*/true);
} // update
//-----------------------------------------------------------------------------
/** Update the terrain information based on the latest position.
@ -103,7 +102,7 @@ void TerrainInfo::update(const Vec3 &from, const Vec3 &towards)
Vec3 direction = towards.normalized();
btVector3 to = from + 10000.0f*direction;
const TriangleMesh &tm = World::getWorld()->getTrack()->getTriangleMesh();
const TriangleMesh &tm = Track::getCurrentTrack()->getTriangleMesh();
tm.castRay(from, to, &m_hit_point, &m_material, &m_normal);
} // update
@ -120,7 +119,7 @@ bool TerrainInfo::getSurfaceInfo(const Vec3 &from, Vec3 *position,
const Material **material)
{
Vec3 to=from+Vec3(0, 10000, 0);
const TriangleMesh &tm = World::getWorld()->getTrack()->getGFXEffectMesh();
const TriangleMesh &tm = Track::getCurrentTrack()->getGFXEffectMesh();
return tm.castRay(from, to, position, material);
} // getSurfaceInfo

View File

@ -86,6 +86,7 @@ using namespace irr;
const float Track::NOHIT = -99999.9f;
bool Track::m_dont_load_navmesh = false;
Track *Track::m_current_track = NULL;
// ----------------------------------------------------------------------------
Track::Track(const std::string &filename)
@ -145,8 +146,9 @@ Track::Track(const std::string &filename)
m_render_target = NULL;
m_minimap_x_scale = 1.0f;
m_minimap_y_scale = 1.0f;
m_startup_run = false;
m_default_number_of_laps= 3;
m_force_disable_fog = false;
m_startup_run = false;
m_default_number_of_laps = 3;
m_all_nodes.clear();
m_static_physics_only_nodes.clear();
m_all_cached_meshes.clear();
@ -456,9 +458,9 @@ void Track::cleanup()
}
#endif
Scripting::ScriptEngine* script_engine =
World::getWorld()->getScriptEngine();
script_engine->cleanupCache();
Scripting::ScriptEngine::getInstance()->cleanupCache();
m_current_track = NULL;
} // cleanup
//-----------------------------------------------------------------------------
@ -1179,7 +1181,7 @@ bool Track::loadMainTrack(const XMLNode &root)
// could be relaxed to fix this, it is not certain how the physics
// will handle items that are out of the AABB
m_aabb_max.setY(m_aabb_max.getY()+30.0f);
World::getWorld()->getPhysics()->init(m_aabb_min, m_aabb_max);
Physics::getInstance()->init(m_aabb_min, m_aabb_max);
ModelDefinitionLoader lodLoader(this);
@ -1445,8 +1447,7 @@ void Track::update(float dt)
{
if (!m_startup_run) // first time running update = good point to run startup script
{
Scripting::ScriptEngine* script_engine = World::getWorld()->getScriptEngine();
script_engine->runFunction(false, "void onStart()");
Scripting::ScriptEngine::getInstance()->runFunction(false, "void onStart()");
m_startup_run = true;
}
m_track_object_manager->update(dt);
@ -1577,6 +1578,8 @@ void Track::createWater(const XMLNode &node)
*/
void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
{
assert(!m_current_track);
// Use m_filename to also get the path, not only the identifier
irr_driver->setTextureErrorMessage("While loading track '%s'",
m_filename );
@ -1669,11 +1672,14 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
throw std::runtime_error(msg.str());
}
m_current_track = this;
// Load the graph only now: this function is called from world, after
// the race gui was created. The race gui is needed since it stores
// the information about the size of the texture to render the mini
// map to.
if (!m_is_arena && !m_is_soccer && !m_is_cutscene) loadDriveGraph(mode_id, reverse_track);
if (!m_is_arena && !m_is_soccer && !m_is_cutscene)
loadDriveGraph(mode_id, reverse_track);
else if ((m_is_arena || m_is_soccer) && !m_is_cutscene && m_has_navmesh)
loadArenaGraph(*root);
@ -1737,6 +1743,7 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
}
loadMainTrack(*root);
unsigned int main_track_count = (unsigned int)m_all_nodes.size();
ModelDefinitionLoader model_def_loader(this);
@ -1759,7 +1766,7 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
model_def_loader.cleanLibraryNodesAfterLoad();
World::getWorld()->getScriptEngine()->compileLoadedScripts();
Scripting::ScriptEngine::getInstance()->compileLoadedScripts();
// Init all track objects
m_track_object_manager->init();
@ -1823,7 +1830,7 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
}
else if(m_sky_type==SKY_COLOR)
{
World::getWorld()->setClearbackBufferColor(m_sky_color);
irr_driver->setClearbackBufferColor(m_sky_color);
}
#ifdef USE_RESIZE_CACHE
@ -1932,6 +1939,7 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
}
irr_driver->unsetTextureErrorMessage();
} // loadTrackModel
//-----------------------------------------------------------------------------

View File

@ -54,7 +54,6 @@ class RenderTarget;
class TrackObject;
class TrackObjectManager;
class TriangleMesh;
class World;
class XMLNode;
const int HEIGHT_MAP_RESOLUTION = 256;
@ -97,6 +96,10 @@ class Track
{
private:
/** If a race is in progress, this stores the active track object.
* NULL otherwise. */
static Track *m_current_track;
#ifdef DEBUG
unsigned int m_magic_number;
#endif
@ -313,7 +316,12 @@ private:
/** The name used in sorting the track. */
core::stringw m_sort_name;
/** True if the track uses fog. */
bool m_use_fog;
/** Can be set to force fog off (e.g. for rendering minimap). */
bool m_force_disable_fog;
/** True if this track supports using smoothed normals. */
bool m_smooth_normals;
@ -382,7 +390,10 @@ private:
public:
bool reverseAvailable() const { return m_reverse_available; }
/** Static function to get the current track. NULL if no current
* track is defined (i.e. no race is active atm) */
static Track* getCurrentTrack() { return m_current_track; }
// ------------------------------------------------------------------------
void handleAnimatedTextures(scene::ISceneNode *node, const XMLNode &xml);
/** Flag to avoid loading navmeshes (useful to speedup debugging: e.g.
@ -435,6 +446,9 @@ public:
/** Returns true if this track has easter eggs. */
bool hasEasterEggs() const { return m_has_easter_eggs; }
// ------------------------------------------------------------------------
/** Returns true if this race can be driven in reverse. */
bool reverseAvailable() const { return m_reverse_available; }
// ------------------------------------------------------------------------
/** Returns true if this track navmesh. */
bool hasNavMesh() const { return m_has_navmesh; }
// ------------------------------------------------------------------------
@ -444,10 +458,6 @@ public:
// ------------------------------------------------------------------------
bool isSoccer () const { return m_is_soccer; }
// ------------------------------------------------------------------------
void loadTrackModel (World* parent,
bool reverse_track = false,
unsigned int mode_id=0);
// ------------------------------------------------------------------------
void addMusic (MusicInformation* mi)
{m_music.push_back(mi); }
// ------------------------------------------------------------------------
@ -542,11 +552,20 @@ public:
// ------------------------------------------------------------------------
bool getWeatherLightning() {return m_weather_lightning;}
// ------------------------------------------------------------------------
std::string getWeatherSound() {return m_weather_sound;}
const std::string& getWeatherSound() {return m_weather_sound;}
// ------------------------------------------------------------------------
ParticleKind* getSkyParticles () { return m_sky_particles; }
// ------------------------------------------------------------------------
bool isFogEnabled() const { return m_use_fog; }
/** Override track fog value to force disabled */
void forceFogDisabled(bool v) { m_force_disable_fog = v; }
//-------------------------------------------------------------------------
/** Returns if fog is currently enabled. It can be disabled per track, or
* temporary be disabled (e.g. for rendering mini map). */
bool isFogEnabled() const
{
return !m_force_disable_fog && m_use_fog;
} // isFogEnabled
// ------------------------------------------------------------------------
float getFogStart() const { return m_fog_start; }
// ------------------------------------------------------------------------

View File

@ -27,7 +27,6 @@
#include "io/xml_node.hpp"
#include "input/device_manager.hpp"
#include "items/item_manager.hpp"
#include "modes/world.hpp"
#include "physics/physical_object.hpp"
#include "race/race_manager.hpp"
#include "scriptengine/script_engine.hpp"
@ -364,7 +363,8 @@ void TrackObject::onWorldReady()
else if (m_visibility_condition.size() > 0)
{
unsigned char result = -1;
Scripting::ScriptEngine* script_engine = World::getWorld()->getScriptEngine();
Scripting::ScriptEngine* script_engine =
Scripting::ScriptEngine::getInstance();
std::ostringstream fn_signature;
std::vector<std::string> arguments;

View File

@ -193,10 +193,7 @@ TrackObjectPresentationLibraryNode::TrackObjectPresentationLibraryNode(
if (!model_def_loader.containsLibraryNode(name))
{
World* world = World::getWorld();
Track* track = NULL;
if (world != NULL)
track = world->getTrack();
Track* track = Track::getCurrentTrack();
std::string local_lib_node_path;
std::string local_script_file_path;
if (track != NULL)
@ -206,19 +203,20 @@ TrackObjectPresentationLibraryNode::TrackObjectPresentationLibraryNode(
}
std::string lib_node_path = lib_path + "node.xml";
std::string lib_script_file_path = lib_path + "scripting.as";
World* world = World::getWorld();
if (local_lib_node_path.size() > 0 && file_manager->fileExists(local_lib_node_path))
{
lib_path = track->getTrackFile("library/" + name);
libroot = file_manager->createXMLTree(local_lib_node_path);
if (track != NULL)
World::getWorld()->getScriptEngine()->loadScript(local_script_file_path, false);
Scripting::ScriptEngine::getInstance()->loadScript(local_script_file_path, false);
}
else if (file_manager->fileExists(lib_node_path))
{
libroot = file_manager->createXMLTree(lib_node_path);
if (track != NULL)
World::getWorld()->getScriptEngine()->loadScript(lib_script_file_path, false);
Scripting::ScriptEngine::getInstance()->loadScript(lib_script_file_path, false);
}
else
{
@ -267,8 +265,9 @@ TrackObjectPresentationLibraryNode::TrackObjectPresentationLibraryNode(
m_node->updateAbsolutePosition();
assert(libroot != NULL);
World::getWorld()->getTrack()->loadObjects(libroot, lib_path, model_def_loader,
create_lod_definitions, m_node, parent);
Track::getCurrentTrack()->loadObjects(libroot, lib_path, model_def_loader,
create_lod_definitions, m_node,
parent);
m_parent = parent;
} // TrackObjectPresentationLibraryNode
@ -494,9 +493,9 @@ void TrackObjectPresentationMesh::init(const XMLNode* xml_node,
m_force_always_hidden = true;
m_frame_start = 0;
m_frame_end = 0;
if (World::getWorld() && World::getWorld()->getTrack() && xml_node)
World::getWorld()->getTrack()->addPhysicsOnlyNode(m_node);
Track *track = Track::getCurrentTrack();
if (track && track && xml_node)
track->addPhysicsOnlyNode(m_node);
}
}
else if (m_is_in_skybox)
@ -526,9 +525,9 @@ void TrackObjectPresentationMesh::init(const XMLNode* xml_node,
if (xml_node)
xml_node->get("frame-end", &m_frame_end);
if (World::getWorld() && World::getWorld()->getTrack() && xml_node)
World::getWorld()->getTrack()
->handleAnimatedTextures(m_node, *xml_node);
Track *track = Track::getCurrentTrack();
if (track && track && xml_node)
track->handleAnimatedTextures(m_node, *xml_node);
}
else
{
@ -547,9 +546,9 @@ void TrackObjectPresentationMesh::init(const XMLNode* xml_node,
m_frame_start = 0;
m_frame_end = 0;
if (World::getWorld() && World::getWorld()->getTrack() && xml_node)
World::getWorld()->getTrack()
->handleAnimatedTextures(m_node, *xml_node);
Track *track = Track::getCurrentTrack();
if (track && xml_node)
track->handleAnimatedTextures(m_node, *xml_node);
}
if(!enabled)
@ -674,7 +673,7 @@ TrackObjectPresentationSound::TrackObjectPresentationSound(
xml_node.get("max_dist", &max_dist );
// first try track dir, then global dir
std::string soundfile = World::getWorld()->getTrack()->getTrackFile(sound);
std::string soundfile = Track::getCurrentTrack()->getTrackFile(sound);
//std::string soundfile = file_manager->getAsset(FileManager::MODEL,sound);
if (!file_manager->fileExists(soundfile))
{
@ -1099,13 +1098,11 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached()
{
if (!m_action_active) return;
Scripting::ScriptEngine* script_engine =
World::getWorld()->getScriptEngine();
m_action_active = false; // TODO: allow auto re-activating?
int idKart = 0;
Camera* camera = Camera::getActiveCamera();
if (camera != NULL && camera->getKart() != NULL)
idKart = camera->getKart()->getWorldKartId();
script_engine->runFunction(true, "void " + m_action + "(int)",
[=](asIScriptContext* ctx) { ctx->SetArgDWord(0, idKart); });
Scripting::ScriptEngine::getInstance()->runFunction(true, "void " + m_action + "(int)",
[=](asIScriptContext* ctx) { ctx->SetArgDWord(0, idKart); });
} // onTriggerItemApproached

View File

@ -230,7 +230,7 @@ bool handleContextMenuAction(s32 cmd_id)
{
World *world = World::getWorld();
Physics *physics = world ? world->getPhysics() : NULL;
Physics *physics = Physics::getInstance();
switch(cmd_id)
{
case DEBUG_GRAPHICS_RELOAD_SHADERS:
@ -325,8 +325,8 @@ bool handleContextMenuAction(s32 cmd_id)
{
irr_driver->resetDebugModes();
if (!world) return false;
Physics *physics = world->getPhysics();
Physics *physics = Physics::getInstance();
if (!physics) return false;
physics->setDebugMode(IrrDebugDrawer::DM_NO_KARTS_GRAPHICS);
break;
}

View File

@ -140,11 +140,11 @@ void Log::printMessage(int level, const char *component, const char *format,
android_LogPriority alp;
switch (level)
{
// STK is using the levels slightly different from android
// (debug lowest, verbose above it; while android reverses
// this order. So to get the same behaviour (e.g. filter
// out debug message, but still get verbose, we swap
// the order here.
// STK is using the levels slightly different from android
// (debug lowest, verbose above it; while android reverses
// this order. So to get the same behaviour (e.g. filter
// out debug message, but still get verbose, we swap
// the order here.
case LL_VERBOSE: alp = ANDROID_LOG_DEBUG; break;
case LL_DEBUG: alp = ANDROID_LOG_VERBOSE; break;
case LL_INFO: alp = ANDROID_LOG_INFO; break;
@ -153,8 +153,8 @@ void Log::printMessage(int level, const char *component, const char *format,
case LL_FATAL: alp = ANDROID_LOG_FATAL; break;
default: alp = ANDROID_LOG_FATAL;
}
__android_log_vprint(alp, "SuperTuxKart", format, args);
#else
#endif
static const char *names[] = {"debug", "verbose ", "info ",
"warn ", "error ", "fatal "};
@ -178,8 +178,12 @@ void Log::printMessage(int level, const char *component, const char *format,
va_copy(out, args);
setTerminalColor((LogLevel)level);
#ifdef ANDROID
__android_log_vprint(alp, "SuperTuxKart", format, out);
#else
printf("[%s] %s: ", names[level], component);
vprintf(format, out);
#endif
resetTerminalColor(); // this prints a \n
va_end(out);
@ -225,8 +229,6 @@ void Log::printMessage(int level, const char *component, const char *format,
MessageBoxA(NULL, message.c_str(), "SuperTuxKart - Fatal error", MB_OK);
}
#endif
#endif
} // printMessage