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

This commit is contained in:
Benau 2016-12-10 10:09:30 +08:00
commit 8ca0c54bdc
137 changed files with 2042 additions and 1134 deletions

View File

@ -15,6 +15,7 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "STKRelease") set(CMAKE_BUILD_TYPE "STKRelease")
endif() endif()
option(SERVER_ONLY "Create a server only (i.e. no graphics or sound)" OFF)
option(USE_FRIBIDI "Support for right-to-left languages" ON) option(USE_FRIBIDI "Support for right-to-left languages" ON)
option(CHECK_ASSETS "Check if assets are installed in ../stk-assets" ON) option(CHECK_ASSETS "Check if assets are installed in ../stk-assets" ON)
option(USE_SYSTEM_ANGELSCRIPT "Use system angelscript instead of built-in angelscript. If you enable this option, make sure to use a compatible version." OFF) option(USE_SYSTEM_ANGELSCRIPT "Use system angelscript instead of built-in angelscript. If you enable this option, make sure to use a compatible version." OFF)
@ -34,7 +35,7 @@ else()
set(WIIUSE_BUILD ON) set(WIIUSE_BUILD ON)
endif() endif()
if(MINGW OR CYGWIN) if(MINGW OR CYGWIN OR SERVER_ONLY)
option(USE_WIIUSE "Support for wiimote input devices" OFF) option(USE_WIIUSE "Support for wiimote input devices" OFF)
else() else()
option(USE_WIIUSE "Support for wiimote input devices" ON) option(USE_WIIUSE "Support for wiimote input devices" ON)
@ -68,6 +69,11 @@ if(USE_GLES2)
add_definitions(-DUSE_GLES2) add_definitions(-DUSE_GLES2)
endif() endif()
if(SERVER_ONLY)
add_definitions(-DSERVER_ONLY)
add_definitions(-DNO_IRR_COMPILE_WITH_X11_)
endif()
# Build the Bullet physics library # Build the Bullet physics library
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/bullet") add_subdirectory("${PROJECT_SOURCE_DIR}/lib/bullet")
include_directories("${PROJECT_SOURCE_DIR}/lib/bullet/src") include_directories("${PROJECT_SOURCE_DIR}/lib/bullet/src")
@ -77,7 +83,7 @@ add_subdirectory("${PROJECT_SOURCE_DIR}/lib/enet")
include_directories("${PROJECT_SOURCE_DIR}/lib/enet/include") include_directories("${PROJECT_SOURCE_DIR}/lib/enet/include")
# Build glew library # Build glew library
if(NOT USE_GLES2) if(NOT USE_GLES2 AND NOT SERVER_ONLY)
add_definitions(-DGLEW_NO_GLU) add_definitions(-DGLEW_NO_GLU)
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/glew") add_subdirectory("${PROJECT_SOURCE_DIR}/lib/glew")
include_directories("${PROJECT_SOURCE_DIR}/lib/glew/include") include_directories("${PROJECT_SOURCE_DIR}/lib/glew/include")
@ -206,12 +212,13 @@ if (OPENMP_FOUND)
endif() endif()
# OpenGL # OpenGL
if(NOT USE_GLES2) if(NOT USE_GLES2 AND NOT SERVER_ONLY)
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR}) include_directories(${OPENGL_INCLUDE_DIR})
endif() endif()
if(UNIX AND NOT APPLE)
if(UNIX AND NOT APPLE AND NOT SERVER_ONLY)
find_package(X11 REQUIRED) find_package(X11 REQUIRED)
include_directories(${X11_INCLUDE_DIR}) include_directories(${X11_INCLUDE_DIR})
@ -370,10 +377,12 @@ target_link_libraries(supertuxkart
${FREETYPE_LIBRARIES} ${FREETYPE_LIBRARIES}
) )
if(NOT USE_GLES2) if(NOT SERVER_ONLY)
target_link_libraries(supertuxkart ${OPENGL_LIBRARIES} glew) if(NOT USE_GLES2)
else() target_link_libraries(supertuxkart ${OPENGL_LIBRARIES} glew)
target_link_libraries(supertuxkart EGL GLESv2) else()
target_link_libraries(supertuxkart EGL GLESv2)
endif()
endif() endif()
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)

View File

@ -54,6 +54,7 @@ void main(void)
float scattering = mix(fPowEdotL, fLdotNBack, .5); float scattering = mix(fPowEdotL, fLdotNBack, .5);
float specmap = texture(SpecMap, uv).g; 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.); FragColor = vec4(LightFactor, 1.);
} }

View File

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

View File

@ -1,5 +1,6 @@
# CMakeLists.txt - glew # CMakeLists.txt - glew
if (NOT SERVER_ONLY)
include_directories("include") include_directories("include")
if(APPLE) if(APPLE)
@ -18,3 +19,5 @@ add_library(glew STATIC
) )
target_link_libraries(glew ${OPENGL_LIBRARIES}) target_link_libraries(glew ${OPENGL_LIBRARIES})
endif()

View File

@ -8,9 +8,14 @@ include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include/"
"${ZLIB_INCLUDE_DIR}" "${ZLIB_INCLUDE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}/../zlib/") # For zconf.h on WIN32 "${CMAKE_CURRENT_BINARY_DIR}/../zlib/") # For zconf.h on WIN32
if(NOT USE_GLES2) if (SERVER_ONLY)
find_package(OpenGL REQUIRED) add_definitions(-DNO_IRR_COMPILE_WITH_OPENGL_)
include_directories(${OPENGL_INCLUDE_DIR}) add_definitions(-DNO_IRR_COMPILE_WITH_X11_)
else()
if(NOT USE_GLES2)
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})
endif()
endif() endif()
if (UNIX AND NOT APPLE) if (UNIX AND NOT APPLE)

View File

@ -246,6 +246,10 @@ define out. */
#ifdef NO_IRR_LINUX_XCURSOR_ #ifdef NO_IRR_LINUX_XCURSOR_
#undef _IRR_LINUX_XCURSOR_ #undef _IRR_LINUX_XCURSOR_
#endif #endif
#else
#undef _IRR_LINUX_X11_VIDMODE_
#undef _IRR_LINUX_X11_RANDR_
#endif #endif

View File

@ -68,12 +68,14 @@ namespace irr
} }
} // end namespace irr } // end namespace irr
#if defined(_IRR_COMPILE_WITH_X11_)
namespace namespace
{ {
Atom X_ATOM_CLIPBOARD; Atom X_ATOM_CLIPBOARD;
Atom X_ATOM_TARGETS; Atom X_ATOM_TARGETS;
Atom X_ATOM_UTF8_STRING; Atom X_ATOM_UTF8_STRING;
}; };
#endif
namespace irr namespace irr
{ {
@ -598,6 +600,7 @@ static GLXContext getMeAGLContext(Display *display, GLXFBConfig glxFBConfig, boo
Context = glXCreateNewContext(display, glxFBConfig, GLX_RGBA_TYPE, NULL, True); Context = glXCreateNewContext(display, glxFBConfig, GLX_RGBA_TYPE, NULL, True);
return Context; return Context;
} }
#endif #endif
bool CIrrDeviceLinux::createWindow() bool CIrrDeviceLinux::createWindow()

View File

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

View File

@ -1,5 +1,5 @@
# Modify this file to change the last-modified date when you add/remove a file. # Modify this file to change the last-modified date when you add/remove a file.
# This will then trigger a new cmake run automatically. # This will then trigger a new cmake run automatically.
file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp") file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp")
file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp") file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp")
file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*") file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*")

View File

@ -264,6 +264,9 @@ const std::string& getOSVersion()
*/ */
void reportHardwareStats() void reportHardwareStats()
{ {
#ifdef SERVER_ONLY
return;
#else
if(!UserConfigParams::m_hw_report_enable) if(!UserConfigParams::m_hw_report_enable)
return; return;
@ -335,8 +338,10 @@ void reportHardwareStats()
if(nr_procs>0) if(nr_procs>0)
json.add("cpu_numprocs", nr_procs); json.add("cpu_numprocs", nr_procs);
#ifndef SERVER_ONLY
json.add("GL_EXTENSIONS", getGLExtensions()); json.add("GL_EXTENSIONS", getGLExtensions());
getGLLimits(&json); getGLLimits(&json);
#endif
json.finish(); json.finish();
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@ -391,7 +396,7 @@ void reportHardwareStats()
request->setURL((std::string)UserConfigParams::m_server_hw_report+"/upload/v1/"); request->setURL((std::string)UserConfigParams::m_server_hw_report+"/upload/v1/");
//request->setURL("http://127.0.0.1:8000/upload/v1/"); //request->setURL("http://127.0.0.1:8000/upload/v1/");
request->queue(); request->queue();
#endif // !SERVER_ONLY
} // reportHardwareStats } // reportHardwareStats
} // namespace HardwareStats } // namespace HardwareStats

View File

@ -527,6 +527,7 @@ void FontWithFace::render(const core::stringw& text,
FontSettings* font_settings, FontSettings* font_settings,
FontCharCollector* char_collector) FontCharCollector* char_collector)
{ {
#ifndef SERVER_ONLY
const bool black_border = font_settings ? const bool black_border = font_settings ?
font_settings->useBlackBorder() : false; font_settings->useBlackBorder() : false;
const bool rtl = font_settings ? font_settings->isRTL() : false; const bool rtl = font_settings ? font_settings->isRTL() : false;
@ -778,4 +779,5 @@ void FontWithFace::render(const core::stringw& text,
} }
} }
} }
#endif
} // render } // render

View File

@ -15,6 +15,7 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/2dutils.hpp" #include "graphics/2dutils.hpp"
#include "graphics/central_settings.hpp" #include "graphics/central_settings.hpp"
@ -779,3 +780,6 @@ void GL32_draw2DRectangle(video::SColor color, const core::rect<s32>& position,
glGetError(); glGetError();
} // GL32_draw2DRectangle } // GL32_draw2DRectangle
#endif // !SERVER_ONLY

View File

@ -15,6 +15,7 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/central_settings.hpp" #include "graphics/central_settings.hpp"
#include "config/user_config.hpp" #include "config/user_config.hpp"
@ -447,3 +448,4 @@ bool CentralVideoSettings::supportsHardwareSkinning() const
{ {
return isARBUniformBufferObjectUsable() && isARBExplicitAttribLocationUsable() && getGLSLVersion() >= 330; return isARBUniformBufferObjectUsable() && isARBExplicitAttribLocationUsable() && getGLSLVersion() >= 330;
} }
#endif // !SERVER_ONLY

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/command_buffer.hpp" #include "graphics/command_buffer.hpp"
#include "graphics/central_settings.hpp" #include "graphics/central_settings.hpp"
#include "utils/cpp2011.hpp" #include "utils/cpp2011.hpp"
@ -275,4 +277,6 @@ void GlowCommandBuffer::fill(OtherMeshMap *mesh_map)
glUnmapBuffer(GL_DRAW_INDIRECT_BUFFER); glUnmapBuffer(GL_DRAW_INDIRECT_BUFFER);
} //GlowCommandBuffer::fill } //GlowCommandBuffer::fill
#endif // !defined(USE_GLES2) #endif // !defined(USE_GLES2)
#endif // !SERVER_ONLY

View File

@ -18,6 +18,8 @@
#ifndef HEADER_COMMAND_BUFFER_HPP #ifndef HEADER_COMMAND_BUFFER_HPP
#define HEADER_COMMAND_BUFFER_HPP #define HEADER_COMMAND_BUFFER_HPP
#ifndef SERVER_ONLY
#include "graphics/draw_tools.hpp" #include "graphics/draw_tools.hpp"
#include "graphics/gl_headers.hpp" #include "graphics/gl_headers.hpp"
#include "graphics/material.hpp" #include "graphics/material.hpp"
@ -653,5 +655,6 @@ public:
} }
} // multidraw } // multidraw
}; };
#endif // !defined(USE_GLES2) #endif // !defined(USE_GLES2)
#endif //HEADER_COMMAND_BUFFER_HPP #endif // !SERVER_ONLY
#endif // HEADER_COMMAND_BUFFER_HPP

View File

@ -15,7 +15,9 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/draw_calls.hpp" #include "graphics/draw_calls.hpp"
#include "config/user_config.hpp" #include "config/user_config.hpp"
#include "graphics/draw_tools.hpp" #include "graphics/draw_tools.hpp"
#include "graphics/gpu_particles.hpp" #include "graphics/gpu_particles.hpp"
@ -899,3 +901,4 @@ int32_t DrawCalls::getSkinningOffset() const
(const size_t previous, const STKAnimatedMesh* m) (const size_t previous, const STKAnimatedMesh* m)
{ return previous + m->getTotalJointSize(); }); { return previous + m->getTotalJointSize(); });
} // getSkinningOffset } // getSkinningOffset
#endif // !SERVER_ONLY

View File

@ -18,6 +18,7 @@
#ifndef HEADER_DRAW_CALLS_HPP #ifndef HEADER_DRAW_CALLS_HPP
#define HEADER_DRAW_CALLS_HPP #define HEADER_DRAW_CALLS_HPP
#ifndef SERVER_ONLY
#include "graphics/command_buffer.hpp" #include "graphics/command_buffer.hpp"
#include <irrlicht.h> #include <irrlicht.h>
#include <unordered_map> #include <unordered_map>
@ -110,4 +111,5 @@ public:
int32_t getSkinningOffset() const; int32_t getSkinningOffset() const;
}; };
#endif // !SERVER_ONLY
#endif //HEADER_DRAW_CALLS_HPP #endif //HEADER_DRAW_CALLS_HPP

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/draw_policies.hpp" #include "graphics/draw_policies.hpp"
#include "graphics/draw_tools.hpp" #include "graphics/draw_tools.hpp"
#include "graphics/materials.hpp" #include "graphics/materials.hpp"
@ -352,3 +354,5 @@ void MultidrawPolicy::drawReflectiveShadowMap(const DrawCalls& draw_calls,
draw_calls.multidrawReflectiveShadowMaps(rsm_matrix); draw_calls.multidrawReflectiveShadowMaps(rsm_matrix);
#endif //!defined(USE_GLES2) #endif //!defined(USE_GLES2)
} }
#endif // !SERVER_ONLY

View File

@ -18,6 +18,8 @@
#ifndef HEADER_DRAW_POLICIES_HPP #ifndef HEADER_DRAW_POLICIES_HPP
#define HEADER_DRAW_POLICIES_HPP #define HEADER_DRAW_POLICIES_HPP
#ifndef SERVER_ONLY
#include "graphics/draw_calls.hpp" #include "graphics/draw_calls.hpp"
@ -91,5 +93,5 @@ public:
const core::matrix4 &rsm_matrix ) const; const core::matrix4 &rsm_matrix ) const;
}; };
#endif // !SERVER_ONLY
#endif //HEADER_DRAW_POLICIES_HPP #endif // HEADER_DRAW_POLICIES_HPP

View File

@ -41,9 +41,11 @@ Explosion::Explosion(const Vec3& coord, const char* explosion_sound, const char
m_remaining_time = burst_time; m_remaining_time = burst_time;
m_emission_frames = 0; m_emission_frames = 0;
#ifndef SERVER_ONLY
ParticleKindManager* pkm = ParticleKindManager::get(); ParticleKindManager* pkm = ParticleKindManager::get();
ParticleKind* particles = pkm->getParticles(particle_file); ParticleKind* particles = pkm->getParticles(particle_file);
m_emitter = new ParticleEmitter(particles, coord, NULL); m_emitter = new ParticleEmitter(particles, coord, NULL);
#endif
} // Explosion } // Explosion
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -51,10 +53,12 @@ Explosion::Explosion(const Vec3& coord, const char* explosion_sound, const char
*/ */
Explosion::~Explosion() Explosion::~Explosion()
{ {
#ifndef SERVER_ONLY
if(m_emitter) if(m_emitter)
{ {
delete m_emitter; delete m_emitter;
} }
#endif
} // ~Explosion } // ~Explosion
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -71,6 +75,7 @@ bool Explosion::updateAndDelete(float dt)
m_emission_frames++; m_emission_frames++;
m_remaining_time -= dt; m_remaining_time -= dt;
#ifndef SERVER_ONLY
if (m_remaining_time < 0.0f && m_remaining_time >= -explosion_time) if (m_remaining_time < 0.0f && m_remaining_time >= -explosion_time)
{ {
scene::ISceneNode* node = m_emitter->getNode(); scene::ISceneNode* node = m_emitter->getNode();
@ -88,7 +93,7 @@ bool Explosion::updateAndDelete(float dt)
node->getMaterial(0).DiffuseColor.setRed(intensity); node->getMaterial(0).DiffuseColor.setRed(intensity);
node->getMaterial(0).EmissiveColor.setRed(intensity); node->getMaterial(0).EmissiveColor.setRed(intensity);
} }
#endif
// Do nothing more if the animation is still playing // Do nothing more if the animation is still playing
if (m_remaining_time>0) return false; if (m_remaining_time>0) return false;
@ -98,6 +103,7 @@ bool Explosion::updateAndDelete(float dt)
// object is removed. // object is removed.
if (m_remaining_time > -explosion_time) if (m_remaining_time > -explosion_time)
{ {
#ifndef SERVER_ONLY
// if framerate is very low, emit for at least a few frames, in case // if framerate is very low, emit for at least a few frames, in case
// burst time is lower than the time of 1 frame // burst time is lower than the time of 1 frame
if (m_emission_frames > 2) if (m_emission_frames > 2)
@ -106,6 +112,7 @@ bool Explosion::updateAndDelete(float dt)
m_emitter->getNode()->getEmitter()->setMinParticlesPerSecond(0); m_emitter->getNode()->getEmitter()->setMinParticlesPerSecond(0);
m_emitter->getNode()->getEmitter()->setMaxParticlesPerSecond(0); m_emitter->getNode()->getEmitter()->setMaxParticlesPerSecond(0);
} }
#endif
} }
else else
{ {

View File

@ -15,6 +15,7 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/fixed_pipeline_renderer.hpp" #include "graphics/fixed_pipeline_renderer.hpp"
#include "config/user_config.hpp" #include "config/user_config.hpp"
#include "graphics/camera.hpp" #include "graphics/camera.hpp"
@ -112,3 +113,4 @@ std::unique_ptr<RenderTarget> FixedPipelineRenderer::createRenderTarget(const ir
{ {
return std::unique_ptr<RenderTarget>(new GL1RenderTarget(dimension, name)); return std::unique_ptr<RenderTarget>(new GL1RenderTarget(dimension, name));
} }
#endif

View File

@ -18,6 +18,7 @@
#ifndef HEADER_FIXED_PIPELINE_RENDERER_HPP #ifndef HEADER_FIXED_PIPELINE_RENDERER_HPP
#define HEADER_FIXED_PIPELINE_RENDERER_HPP #define HEADER_FIXED_PIPELINE_RENDERER_HPP
#ifndef SERVER_ONLY
#include "graphics/abstract_renderer.hpp" #include "graphics/abstract_renderer.hpp"
#include <map> #include <map>
@ -37,4 +38,5 @@ public:
const std::string &name); const std::string &name);
}; };
#endif // !SERVER_ONLY
#endif //HEADER_FIXED_PIPELINE_RENDERER_HPP #endif //HEADER_FIXED_PIPELINE_RENDERER_HPP

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/geometry_passes.hpp" #include "graphics/geometry_passes.hpp"
#include "graphics/callbacks.hpp" #include "graphics/callbacks.hpp"
#include "graphics/draw_tools.hpp" #include "graphics/draw_tools.hpp"
@ -380,5 +382,4 @@ void AbstractGeometryPasses::renderTransparent(const DrawCalls& draw_calls,
} // renderTransparent } // renderTransparent
#endif // !SERVER_ONLY

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#ifndef HEADER_GEOMETRY_PASSES_HPP #ifndef HEADER_GEOMETRY_PASSES_HPP
#define HEADER_GEOMETRY_PASSES_HPP #define HEADER_GEOMETRY_PASSES_HPP
@ -171,4 +173,5 @@ public:
}; };
#endif //HEADER_GEOMETRY_PASSES_HPP #endif // !SERVER_ONLY
#endif // HEADER_GEOMETRY_PASSES_HPP

View File

@ -18,6 +18,8 @@
#ifndef GL_HEADER_HPP #ifndef GL_HEADER_HPP
#define GL_HEADER_HPP #define GL_HEADER_HPP
#ifndef SERVER_ONLY
#define GLEW_STATIC #define GLEW_STATIC
extern "C" { extern "C" {
@ -80,5 +82,12 @@ struct DrawElementsIndirectCommand{
GLuint baseVertex; GLuint baseVertex;
GLuint baseInstance; GLuint baseInstance;
}; };
#else
typedef unsigned int GLuint;
typedef unsigned int GLsync;
typedef unsigned int GLenum;
#endif // server only
#endif #endif

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/glwrap.hpp" #include "graphics/glwrap.hpp"
#include "config/hardware_stats.hpp" #include "config/hardware_stats.hpp"
@ -758,3 +760,6 @@ else \
#endif // ifdef XX #endif // ifdef XX
} // getGLLimits } // getGLLimits
#endif // !SERVER_ONLY

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#ifndef GLWRAP_HEADER_H #ifndef GLWRAP_HEADER_H
#define GLWRAP_HEADER_H #define GLWRAP_HEADER_H
@ -168,3 +170,6 @@ const std::string getGLExtensions();
void getGLLimits(HardwareStats::Json *json); void getGLLimits(HardwareStats::Json *json);
#endif #endif
#endif // supertuxkart

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/gpu_particles.hpp" #include "graphics/gpu_particles.hpp"
#include "config/user_config.hpp" #include "config/user_config.hpp"
@ -633,3 +635,5 @@ void ParticleSystemProxy::render() {
draw(); draw();
} }
} }
#endif // SERVER_ONLY

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#ifndef HEADER_GPU_PARTICLES_HPP #ifndef HEADER_GPU_PARTICLES_HPP
#define HEADER_GPU_PARTICLES_HPP #define HEADER_GPU_PARTICLES_HPP
@ -109,3 +111,5 @@ public:
}; };
#endif // GPUPARTICLES_H #endif // GPUPARTICLES_H
#endif // !SERVER_ONLY

View File

@ -70,11 +70,13 @@
* Should help prevent distros building against an incompatible library. * Should help prevent distros building against an incompatible library.
*/ */
#if (IRRLICHT_VERSION_MAJOR < 1 || IRRLICHT_VERSION_MINOR < 7 || \ #if ( IRRLICHT_VERSION_MAJOR < 1 || \
_IRR_MATERIAL_MAX_TEXTURES_ < 8 || \ IRRLICHT_VERSION_MINOR < 7 || \
(!defined(_IRR_COMPILE_WITH_OPENGL_) && \ _IRR_MATERIAL_MAX_TEXTURES_ < 8 || \
!defined(_IRR_COMPILE_WITH_OGLES2_)) || \ ( !defined(_IRR_COMPILE_WITH_OPENGL_) && \
!defined(_IRR_COMPILE_WITH_B3D_LOADER_)) !defined(SERVER_ONLY) && \
!defined(_IRR_COMPILE_WITH_OGLES2_) ) || \
!defined(_IRR_COMPILE_WITH_B3D_LOADER_) )
#error "Building against an incompatible Irrlicht. Distros, \ #error "Building against an incompatible Irrlicht. Distros, \
please use the included version." please use the included version."
#endif #endif
@ -97,8 +99,9 @@ struct android_app* global_android_app;
/** singleton */ /** singleton */
IrrDriver *irr_driver = NULL; IrrDriver *irr_driver = NULL;
#ifndef SERVER_ONLY
GPUTimer m_perf_query[Q_LAST]; GPUTimer m_perf_query[Q_LAST];
#endif
const int MIN_SUPPORTED_HEIGHT = 768; const int MIN_SUPPORTED_HEIGHT = 768;
const int MIN_SUPPORTED_WIDTH = 1024; const int MIN_SUPPORTED_WIDTH = 1024;
@ -148,16 +151,19 @@ IrrDriver::IrrDriver()
IrrDriver::~IrrDriver() IrrDriver::~IrrDriver()
{ {
assert(m_device != NULL); assert(m_device != NULL);
#ifndef SERVER_ONLY
cleanUnicolorTextures(); cleanUnicolorTextures();
#endif
m_device->drop(); m_device->drop();
m_device = NULL; m_device = NULL;
m_modes.clear(); m_modes.clear();
#ifndef SERVER_ONLY
if (CVS->isGLSL()) if (CVS->isGLSL())
{ {
Shaders::destroy(); Shaders::destroy();
} }
#endif
delete m_wind; delete m_wind;
delete m_renderer; delete m_renderer;
} // ~IrrDriver } // ~IrrDriver
@ -167,7 +173,9 @@ IrrDriver::~IrrDriver()
*/ */
void IrrDriver::reset() void IrrDriver::reset()
{ {
#ifndef SERVER_ONLY
m_renderer->resetPostProcessing(); m_renderer->resetPostProcessing();
#endif
} // reset } // reset
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -195,15 +203,17 @@ core::array<video::IRenderTarget> &IrrDriver::getMainSetup()
} // getMainSetup } // getMainSetup
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifndef SERVER_ONLY #ifndef SERVER_ONLY
GPUTimer &IrrDriver::getGPUTimer(unsigned i) GPUTimer &IrrDriver::getGPUTimer(unsigned i)
{ {
return m_perf_query[i]; return m_perf_query[i];
} // getGPUTimer } // getGPUTimer
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifndef SERVER_ONLY
std::unique_ptr<RenderTarget> IrrDriver::createRenderTarget(const irr::core::dimension2du &dimension, std::unique_ptr<RenderTarget> IrrDriver::createRenderTarget(const irr::core::dimension2du &dimension,
const std::string &name) const std::string &name)
{ {
@ -221,6 +231,7 @@ If window is the root window, returns window.
*/ */
Window get_toplevel_parent(Display* display, Window window) Window get_toplevel_parent(Display* display, Window window)
{ {
#ifndef SERVER_ONLY
Window parent; Window parent;
Window root; Window root;
Window * children; Window * children;
@ -243,6 +254,9 @@ Window get_toplevel_parent(Display* display, Window window)
window = parent; window = parent;
} }
} }
#else
return NULL;
#endif
} }
#endif #endif
@ -253,8 +267,9 @@ Window get_toplevel_parent(Display* display, Window window)
*/ */
void IrrDriver::updateConfigIfRelevant() void IrrDriver::updateConfigIfRelevant()
{ {
if (!UserConfigParams::m_fullscreen && #ifndef SERVER_ONLY
UserConfigParams::m_remember_window_location) if (!UserConfigParams::m_fullscreen &&
UserConfigParams::m_remember_window_location)
{ {
#ifdef WIN32 #ifdef WIN32
const video::SExposedVideoData& videoData = m_device->getVideoDriver() const video::SExposedVideoData& videoData = m_device->getVideoDriver()
@ -306,6 +321,8 @@ void IrrDriver::updateConfigIfRelevant()
} }
#endif #endif
} }
#endif // !SERVER_ONLY
} // updateConfigIfRelevant } // updateConfigIfRelevant
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -518,6 +535,7 @@ void IrrDriver::initDevice()
{ {
Log::fatal("irr_driver", "Couldn't initialise irrlicht device. Quitting.\n"); Log::fatal("irr_driver", "Couldn't initialise irrlicht device. Quitting.\n");
} }
#ifndef SERVER_ONLY
CVS->init(); CVS->init();
@ -536,12 +554,14 @@ void IrrDriver::initDevice()
params.ForceLegacyDevice = true; params.ForceLegacyDevice = true;
recreate_device = true; recreate_device = true;
} }
#endif
// This is the ugly hack for intel driver on linux, which doesn't // This is the ugly hack for intel driver on linux, which doesn't
// use sRGB-capable visual, even if we request it. This causes // use sRGB-capable visual, even if we request it. This causes
// the screen to be darker than expected. It affects mesa 10.6 and newer. // the screen to be darker than expected. It affects mesa 10.6 and newer.
// Though we are able to force to use the proper format on mesa side by // Though we are able to force to use the proper format on mesa side by
// setting WithAlphaChannel parameter. // setting WithAlphaChannel parameter.
#ifndef SERVER_ONLY
else if (CVS->needsSRGBCapableVisualWorkaround()) else if (CVS->needsSRGBCapableVisualWorkaround())
{ {
Log::warn("irr_driver", "Created visual is not sRGB-capable. " Log::warn("irr_driver", "Created visual is not sRGB-capable. "
@ -567,17 +587,19 @@ void IrrDriver::initDevice()
CVS->init(); CVS->init();
} }
#endif
m_scene_manager = m_device->getSceneManager(); m_scene_manager = m_device->getSceneManager();
m_gui_env = m_device->getGUIEnvironment(); m_gui_env = m_device->getGUIEnvironment();
m_video_driver = m_device->getVideoDriver(); m_video_driver = m_device->getVideoDriver();
m_actual_screen_size = m_video_driver->getCurrentRenderTargetSize(); m_actual_screen_size = m_video_driver->getCurrentRenderTargetSize();
#ifndef SERVER_ONLY
if(CVS->isGLSL()) if(CVS->isGLSL())
m_renderer = new ShaderBasedRenderer(); m_renderer = new ShaderBasedRenderer();
else else
m_renderer = new FixedPipelineRenderer(); m_renderer = new FixedPipelineRenderer();
#endif
if (UserConfigParams::m_shadows_resolution != 0 && if (UserConfigParams::m_shadows_resolution != 0 &&
(UserConfigParams::m_shadows_resolution < 512 || (UserConfigParams::m_shadows_resolution < 512 ||
@ -596,6 +618,7 @@ void IrrDriver::initDevice()
m_video_driver->beginScene(/*backBuffer clear*/true, /* Z */ false); m_video_driver->beginScene(/*backBuffer clear*/true, /* Z */ false);
m_video_driver->endScene(); m_video_driver->endScene();
#ifndef SERVER_ONLY
if (CVS->isGLSL()) if (CVS->isGLSL())
{ {
Log::info("irr_driver", "GLSL supported."); Log::info("irr_driver", "GLSL supported.");
@ -608,6 +631,7 @@ void IrrDriver::initDevice()
UserConfigParams::m_gi = false; UserConfigParams::m_gi = false;
}*/ }*/
// m_glsl might be reset in rtt if an error occurs. // m_glsl might be reset in rtt if an error occurs.
if (CVS->isGLSL()) if (CVS->isGLSL())
{ {
@ -622,11 +646,12 @@ void IrrDriver::initDevice()
Log::warn("irr_driver", "Using the fixed pipeline (old GPU, or " Log::warn("irr_driver", "Using the fixed pipeline (old GPU, or "
"shaders disabled in options)"); "shaders disabled in options)");
} }
#endif
// Only change video driver settings if we are showing graphics // Only change video driver settings if we are showing graphics
if (!ProfileWorld::isNoGraphics()) if (!ProfileWorld::isNoGraphics())
{ {
#if defined(__linux__) && !defined(ANDROID) #if defined(__linux__) && !defined(ANDROID) && !defined(SERVER_ONLY)
// Set class hints on Linux, used by Window Managers. // Set class hints on Linux, used by Window Managers.
const video::SExposedVideoData& videoData = m_video_driver const video::SExposedVideoData& videoData = m_video_driver
->getExposedVideoData(); ->getExposedVideoData();
@ -676,10 +701,12 @@ void IrrDriver::initDevice()
material2D.AntiAliasing=video::EAAM_FULL_BASIC; material2D.AntiAliasing=video::EAAM_FULL_BASIC;
//m_video_driver->enableMaterial2D(); //m_video_driver->enableMaterial2D();
#ifndef SERVER_ONLY
// set cursor visible by default (what's the default is not too clearly documented, // set cursor visible by default (what's the default is not too clearly documented,
// so let's decide ourselves...) // so let's decide ourselves...)
m_device->getCursorControl()->setVisible(true); m_device->getCursorControl()->setVisible(true);
m_pointer_shown = true; m_pointer_shown = true;
#endif
} // initDevice } // initDevice
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -703,6 +730,7 @@ void IrrDriver::cleanSunInterposer()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void IrrDriver::createSunInterposer() void IrrDriver::createSunInterposer()
{ {
#ifndef SERVER_ONLY
scene::IMesh * sphere = m_scene_manager->getGeometryCreator() scene::IMesh * sphere = m_scene_manager->getGeometryCreator()
->createSphereMesh(1, 16, 16); ->createSphereMesh(1, 16, 16);
for (unsigned i = 0; i < sphere->getMeshBufferCount(); ++i) for (unsigned i = 0; i < sphere->getMeshBufferCount(); ++i)
@ -731,15 +759,18 @@ void IrrDriver::createSunInterposer()
m_sun_interposer->getMaterial(0).MaterialType = Shaders::getShader(ES_OBJECTPASS); m_sun_interposer->getMaterial(0).MaterialType = Shaders::getShader(ES_OBJECTPASS);
sphere->drop(); sphere->drop();
#endif
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void IrrDriver::getOpenGLData(std::string *vendor, std::string *renderer, void IrrDriver::getOpenGLData(std::string *vendor, std::string *renderer,
std::string *version) std::string *version)
{ {
#ifndef SERVER_ONLY
*vendor = (char*)glGetString(GL_VENDOR ); *vendor = (char*)glGetString(GL_VENDOR );
*renderer = (char*)glGetString(GL_RENDERER); *renderer = (char*)glGetString(GL_RENDERER);
*version = (char*)glGetString(GL_VERSION ); *version = (char*)glGetString(GL_VERSION );
#endif
} // getOpenGLData } // getOpenGLData
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -783,6 +814,7 @@ core::position2di IrrDriver::getMouseLocation()
*/ */
bool IrrDriver::moveWindow(int x, int y) bool IrrDriver::moveWindow(int x, int y)
{ {
#ifndef SERVER_ONLY
#ifdef WIN32 #ifdef WIN32
const video::SExposedVideoData& videoData = const video::SExposedVideoData& videoData =
m_video_driver->getExposedVideoData(); m_video_driver->getExposedVideoData();
@ -821,6 +853,7 @@ bool IrrDriver::moveWindow(int x, int y)
// TODO: Actually handle possible failure // TODO: Actually handle possible failure
XMoveWindow(display, videoData.OpenGLLinux.X11Window, x, y); XMoveWindow(display, videoData.OpenGLLinux.X11Window, x, y);
#endif
#endif #endif
return true; return true;
} }
@ -850,6 +883,7 @@ void IrrDriver::changeResolution(const int w, const int h,
void IrrDriver::applyResolutionSettings() void IrrDriver::applyResolutionSettings()
{ {
#ifndef SERVER_ONLY
// show black before resolution switch so we don't see OpenGL's buffer // show black before resolution switch so we don't see OpenGL's buffer
// garbage during switch // garbage during switch
m_video_driver->beginScene(true, true, video::SColor(255,100,101,140)); m_video_driver->beginScene(true, true, video::SColor(255,100,101,140));
@ -939,6 +973,7 @@ void IrrDriver::applyResolutionSettings()
// above) - this happens dynamically when the tracks are loaded. // above) - this happens dynamically when the tracks are loaded.
GUIEngine::reshowCurrentScreen(); GUIEngine::reshowCurrentScreen();
MessageQueue::updatePosition(); MessageQueue::updatePosition();
#endif // !SERVER_ONLY
} // applyResolutionSettings } // applyResolutionSettings
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -1154,6 +1189,7 @@ scene::IMeshSceneNode *IrrDriver::addSphere(float radius,
m.EmissiveColor = color; m.EmissiveColor = color;
m.BackfaceCulling = false; m.BackfaceCulling = false;
m.MaterialType = video::EMT_SOLID; m.MaterialType = video::EMT_SOLID;
#ifndef SERVER_ONLY
//m.setTexture(0, getUnicolorTexture(video::SColor(128, 255, 105, 180))); //m.setTexture(0, getUnicolorTexture(video::SColor(128, 255, 105, 180)));
m.setTexture(0, getUnicolorTexture(color)); m.setTexture(0, getUnicolorTexture(color));
m.setTexture(1, getUnicolorTexture(video::SColor(0, 0, 0, 0))); m.setTexture(1, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
@ -1167,6 +1203,7 @@ scene::IMeshSceneNode *IrrDriver::addSphere(float radius,
NULL, -1, "sphere"); NULL, -1, "sphere");
return node; return node;
} }
#endif
scene::IMeshSceneNode *node = m_scene_manager->addMeshSceneNode(mesh); scene::IMeshSceneNode *node = m_scene_manager->addMeshSceneNode(mesh);
return node; return node;
@ -1192,6 +1229,9 @@ scene::IMeshSceneNode *IrrDriver::addMesh(scene::IMesh *mesh,
bool all_parts_colorized, bool all_parts_colorized,
int frame_for_mesh) int frame_for_mesh)
{ {
#ifdef SERVER_ONLY
return m_scene_manager->addMeshSceneNode(mesh, parent);
#else
if (!CVS->isGLSL()) if (!CVS->isGLSL())
return m_scene_manager->addMeshSceneNode(mesh, parent); return m_scene_manager->addMeshSceneNode(mesh, parent);
@ -1210,6 +1250,7 @@ scene::IMeshSceneNode *IrrDriver::addMesh(scene::IMesh *mesh,
node->drop(); node->drop();
return node; return node;
#endif
} // addMesh } // addMesh
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -1233,6 +1274,7 @@ scene::ISceneNode *IrrDriver::addBillboard(const core::dimension2d< f32 > size,
bool alphaTesting) bool alphaTesting)
{ {
scene::IBillboardSceneNode* node; scene::IBillboardSceneNode* node;
#ifndef SERVER_ONLY
if (CVS->isGLSL()) if (CVS->isGLSL())
{ {
if (!parent) if (!parent)
@ -1243,13 +1285,14 @@ scene::ISceneNode *IrrDriver::addBillboard(const core::dimension2d< f32 > size,
node->drop(); node->drop();
} }
else else
#endif
node = m_scene_manager->addBillboardSceneNode(parent, size); node = m_scene_manager->addBillboardSceneNode(parent, size);
assert(node->getMaterialCount() > 0); assert(node->getMaterialCount() > 0);
node->setMaterialTexture(0, texture); node->setMaterialTexture(0, texture);
if(alphaTesting) if(alphaTesting)
node->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF); node->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF);
return node; return node;
} // addMesh } // addBillboard
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** Creates a quad mesh with a given material. /** Creates a quad mesh with a given material.
@ -1391,13 +1434,16 @@ scene::IAnimatedMeshSceneNode *IrrDriver::addAnimatedMesh(scene::IAnimatedMesh *
const std::string& debug_name, scene::ISceneNode* parent, const std::string& debug_name, scene::ISceneNode* parent,
RenderInfo* render_info, bool all_parts_colorized) RenderInfo* render_info, bool all_parts_colorized)
{ {
#ifndef SERVER_ONLY
if (!CVS->isGLSL()) if (!CVS->isGLSL())
{ {
#endif
return m_scene_manager->addAnimatedMeshSceneNode(mesh, parent, -1, return m_scene_manager->addAnimatedMeshSceneNode(mesh, parent, -1,
core::vector3df(0, 0, 0), core::vector3df(0, 0, 0),
core::vector3df(0, 0, 0), core::vector3df(0, 0, 0),
core::vector3df(1, 1, 1), core::vector3df(1, 1, 1),
/*addIfMeshIsZero*/true); /*addIfMeshIsZero*/true);
#ifndef SERVER_ONLY
} }
if (!parent) if (!parent)
@ -1408,6 +1454,7 @@ scene::IAnimatedMeshSceneNode *IrrDriver::addAnimatedMesh(scene::IAnimatedMesh *
core::vector3df(1, 1, 1), render_info, all_parts_colorized); core::vector3df(1, 1, 1), render_info, all_parts_colorized);
node->drop(); node->drop();
return node; return node;
#endif
} // addAnimatedMesh } // addAnimatedMesh
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -1448,19 +1495,24 @@ scene::ISceneNode *IrrDriver::addSkyDome(video::ITexture *texture,
scene::ISceneNode *IrrDriver::addSkyBox(const std::vector<video::ITexture*> &texture, scene::ISceneNode *IrrDriver::addSkyBox(const std::vector<video::ITexture*> &texture,
const std::vector<video::ITexture*> &spherical_harmonics_textures) const std::vector<video::ITexture*> &spherical_harmonics_textures)
{ {
#ifndef SERVER_ONLY
assert(texture.size() == 6); assert(texture.size() == 6);
m_renderer->addSkyBox(texture, spherical_harmonics_textures); m_renderer->addSkyBox(texture, spherical_harmonics_textures);
#endif
return m_scene_manager->addSkyBoxSceneNode(texture[0], texture[1], return m_scene_manager->addSkyBoxSceneNode(texture[0], texture[1],
texture[2], texture[3], texture[2], texture[3],
texture[4], texture[5]); texture[4], texture[5]);
} // addSkyBox } // addSkyBox
// ----------------------------------------------------------------------------
void IrrDriver::suppressSkyBox() void IrrDriver::suppressSkyBox()
{ {
#ifndef SERVER_ONLY
m_renderer->removeSkyBox();; m_renderer->removeSkyBox();;
} #endif
} // suppressSkyBox
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** Adds a camera to the scene. /** Adds a camera to the scene.
@ -1811,13 +1863,17 @@ video::ITexture* IrrDriver::applyMask(video::ITexture* texture,
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void IrrDriver::onLoadWorld() void IrrDriver::onLoadWorld()
{ {
#ifndef SERVER_ONLY
m_renderer->onLoadWorld(); m_renderer->onLoadWorld();
} #endif
// ---------------------------------------------------------------------------- } // onLoadWorld
// ----------------------------------------------------------------------------
void IrrDriver::onUnloadWorld() void IrrDriver::onUnloadWorld()
{ {
m_renderer->onUnloadWorld(); m_renderer->onUnloadWorld();
} } // onUnloadWorld
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** Sets the ambient light. /** Sets the ambient light.
* \param light The colour of the light to set. * \param light The colour of the light to set.
@ -1826,10 +1882,13 @@ void IrrDriver::onUnloadWorld()
*/ */
void IrrDriver::setAmbientLight(const video::SColorf &light, bool force_SH_computation) void IrrDriver::setAmbientLight(const video::SColorf &light, bool force_SH_computation)
{ {
#ifndef SERVER_ONLY
m_scene_manager->setAmbientLight(light); m_scene_manager->setAmbientLight(light);
m_renderer->setAmbientLight(light, force_SH_computation); m_renderer->setAmbientLight(light, force_SH_computation);
#endif
} // setAmbientLight } // setAmbientLight
// ----------------------------------------------------------------------------
video::SColorf IrrDriver::getAmbientLight() const video::SColorf IrrDriver::getAmbientLight() const
{ {
return m_scene_manager->getAmbientLight(); return m_scene_manager->getAmbientLight();
@ -1840,6 +1899,7 @@ video::SColorf IrrDriver::getAmbientLight() const
*/ */
void IrrDriver::displayFPS() void IrrDriver::displayFPS()
{ {
#ifndef SERVER_ONLY
gui::IGUIFont* font = GUIEngine::getSmallFont(); gui::IGUIFont* font = GUIEngine::getSmallFont();
core::rect<s32> position; core::rect<s32> position;
@ -1911,6 +1971,7 @@ void IrrDriver::displayFPS()
static video::SColor fpsColor = video::SColor(255, 0, 0, 0); static video::SColor fpsColor = video::SColor(255, 0, 0, 0);
font->draw( fps_string.c_str(), position, fpsColor, false ); font->draw( fps_string.c_str(), position, fpsColor, false );
#endif
} // updateFPS } // updateFPS
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -2009,6 +2070,7 @@ void IrrDriver::update(float dt)
if (world) if (world)
{ {
#ifndef SERVER_ONLY
m_renderer->render(dt); m_renderer->render(dt);
GUIEngine::Screen* current_screen = GUIEngine::getCurrentScreen(); GUIEngine::Screen* current_screen = GUIEngine::getCurrentScreen();
@ -2025,6 +2087,7 @@ void IrrDriver::update(float dt)
debug_drawer->beginNextFrame(); debug_drawer->beginNextFrame();
} }
} }
#endif
} }
else else
{ {
@ -2094,10 +2157,16 @@ bool IrrDriver::OnEvent(const irr::SEvent &event)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool IrrDriver::supportsSplatting() bool IrrDriver::supportsSplatting()
{ {
#ifndef SERVER_ONLY
return CVS->isGLSL(); return CVS->isGLSL();
} #else
return false;
#endif
} // supportsSplatting
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifndef SERVER_ONLY
void IrrDriver::applyObjectPassShader(scene::ISceneNode * const node, bool rimlit) void IrrDriver::applyObjectPassShader(scene::ISceneNode * const node, bool rimlit)
{ {
if (!CVS->isGLSL()) if (!CVS->isGLSL())
@ -2175,6 +2244,8 @@ void IrrDriver::applyObjectPassShader()
applyObjectPassShader(m_scene_manager->getRootSceneNode()); applyObjectPassShader(m_scene_manager->getRootSceneNode());
} }
#endif // !SERVER_ONLY
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
scene::ISceneNode *IrrDriver::addLight(const core::vector3df &pos, scene::ISceneNode *IrrDriver::addLight(const core::vector3df &pos,
@ -2182,6 +2253,7 @@ scene::ISceneNode *IrrDriver::addLight(const core::vector3df &pos,
float r, float g, float b, float r, float g, float b,
bool sun, scene::ISceneNode* parent) bool sun, scene::ISceneNode* parent)
{ {
#ifndef SERVER_ONLY
if (CVS->isGLSL()) if (CVS->isGLSL())
{ {
if (parent == NULL) parent = m_scene_manager->getRootSceneNode(); if (parent == NULL) parent = m_scene_manager->getRootSceneNode();
@ -2218,6 +2290,9 @@ scene::ISceneNode *IrrDriver::addLight(const core::vector3df &pos,
light->setRadius(radius); light->setRadius(radius);
return light; return light;
} }
#else
return NULL;
#endif
} // addLight } // addLight
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -305,8 +305,10 @@ public:
void unsetTextureErrorMessage(); void unsetTextureErrorMessage();
class GPUTimer &getGPUTimer(unsigned); class GPUTimer &getGPUTimer(unsigned);
#ifndef SERVER_ONLY
std::unique_ptr<RenderTarget> createRenderTarget(const irr::core::dimension2du &dimension, std::unique_ptr<RenderTarget> createRenderTarget(const irr::core::dimension2du &dimension,
const std::string &name); const std::string &name);
#endif
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Convenience function that loads a texture with default parameters /** Convenience function that loads a texture with default parameters

View File

@ -1,22 +1,24 @@
// SuperTuxKart - a fun racing game with go-kart // SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2015 SuperTuxKart-Team // Copyright (C) 2015 SuperTuxKart-Team
// //
// This program is free software; you can redistribute it and/or // This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License // modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3 // as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version. // of the License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "graphics/lighting_passes.hpp" #ifndef SERVER_ONLY
#include "config/user_config.hpp"
#include "graphics/lighting_passes.hpp"
#include "config/user_config.hpp"
#include "graphics/central_settings.hpp" #include "graphics/central_settings.hpp"
#include "graphics/glwrap.hpp" #include "graphics/glwrap.hpp"
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
@ -735,3 +737,4 @@ void LightingPasses::renderLightsScatter(GLuint depth_stencil_texture,
colors_framebuffer.getHeight()); colors_framebuffer.getHeight());
} // renderLightsScatter } // renderLightsScatter
#endif

View File

@ -254,6 +254,7 @@ void LODNode::OnRegisterSceneNode()
m_previous_visibility = (shown ? WAS_SHOWN : WAS_HIDDEN); m_previous_visibility = (shown ? WAS_SHOWN : WAS_HIDDEN);
m_last_tick = now; m_last_tick = now;
#ifndef SERVER_ONLY
if (!CVS->isGLSL()) if (!CVS->isGLSL())
{ {
for (core::list<ISceneNode*>::Iterator it = Children.begin(); for (core::list<ISceneNode*>::Iterator it = Children.begin();
@ -262,7 +263,7 @@ void LODNode::OnRegisterSceneNode()
(*it)->updateAbsolutePosition(); (*it)->updateAbsolutePosition();
} }
} }
#endif
scene::ISceneNode::OnRegisterSceneNode(); scene::ISceneNode::OnRegisterSceneNode();
} }
@ -296,5 +297,8 @@ void LODNode::add(int level, scene::ISceneNode* node, bool reparent)
node->drop(); node->drop();
node->updateAbsolutePosition(); node->updateAbsolutePosition();
#ifndef SERVER_ONLY
irr_driver->applyObjectPassShader(node); irr_driver->applyObjectPassShader(node);
#endif
} }

View File

@ -716,6 +716,7 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
m_texname.c_str()); m_texname.c_str());
} }
#ifndef SERVER_ONLY
// Backface culling // Backface culling
if(!m_backface_culling) if(!m_backface_culling)
m->setFlag(video::EMF_BACK_FACE_CULLING, false); m->setFlag(video::EMF_BACK_FACE_CULLING, false);
@ -869,7 +870,7 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
} }
m->setTexture(1, glossytex); m->setTexture(1, glossytex);
} }
#endif
if (m_shader_type == SHADERTYPE_SOLID_UNLIT) if (m_shader_type == SHADERTYPE_SOLID_UNLIT)
{ {
@ -1013,6 +1014,7 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
void Material::adjustForFog(scene::ISceneNode* parent, video::SMaterial *m, void Material::adjustForFog(scene::ISceneNode* parent, video::SMaterial *m,
bool use_fog) const bool use_fog) const
{ {
#ifndef SERVER_ONLY
if (CVS->isGLSL()) if (CVS->isGLSL())
{ {
// to disable fog in the new pipeline, we slightly abuse the steps : // to disable fog in the new pipeline, we slightly abuse the steps :
@ -1036,6 +1038,7 @@ void Material::adjustForFog(scene::ISceneNode* parent, video::SMaterial *m,
if (parent != NULL) if (parent != NULL)
parent->setMaterialFlag(video::EMF_FOG_ENABLE, m_fog && use_fog); parent->setMaterialFlag(video::EMF_FOG_ENABLE, m_fog && use_fog);
} }
#endif
} // adjustForFog } // adjustForFog
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -1043,7 +1046,9 @@ void Material::adjustForFog(scene::ISceneNode* parent, video::SMaterial *m,
/** Callback from LOD nodes to create some effects */ /** Callback from LOD nodes to create some effects */
void Material::onMadeVisible(scene::IMeshBuffer* who) void Material::onMadeVisible(scene::IMeshBuffer* who)
{ {
#ifndef SERVER_ONLY
if (!CVS->isGLSL()) return; if (!CVS->isGLSL()) return;
#endif
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -1051,14 +1056,18 @@ void Material::onMadeVisible(scene::IMeshBuffer* who)
/** Callback from LOD nodes to create some effects */ /** Callback from LOD nodes to create some effects */
void Material::onHidden(scene::IMeshBuffer* who) void Material::onHidden(scene::IMeshBuffer* who)
{ {
#ifndef SERVER_ONLY
if (!CVS->isGLSL()) return; if (!CVS->isGLSL()) return;
#endif
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void Material::isInitiallyHidden(scene::IMeshBuffer* who) void Material::isInitiallyHidden(scene::IMeshBuffer* who)
{ {
#ifndef SERVER_ONLY
if (!CVS->isGLSL()) return; if (!CVS->isGLSL()) return;
#endif
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@ -145,6 +145,7 @@ Material* MaterialManager::getDefaultMaterial(video::E_MATERIAL_TYPE shader_type
// Try to find a cleaner way // Try to find a cleaner way
// If graphics are disabled, shaders should not be accessed (getShader // If graphics are disabled, shaders should not be accessed (getShader
// asserts that shaders are initialised). // asserts that shaders are initialised).
#ifndef SERVER_ONLY
if(!ProfileWorld::isNoGraphics() && CVS->isGLSL() && if(!ProfileWorld::isNoGraphics() && CVS->isGLSL() &&
shader_type == Shaders::getShader(ShaderType::ES_OBJECT_UNLIT)) shader_type == Shaders::getShader(ShaderType::ES_OBJECT_UNLIT))
default_material->setShaderType(Material::SHADERTYPE_SOLID_UNLIT); default_material->setShaderType(Material::SHADERTYPE_SOLID_UNLIT);
@ -156,7 +157,7 @@ Material* MaterialManager::getDefaultMaterial(video::E_MATERIAL_TYPE shader_type
// default_material->setShaderType(Material::SHADERTYPE_ALPHA_BLEND); // default_material->setShaderType(Material::SHADERTYPE_ALPHA_BLEND);
else else
default_material->setShaderType(Material::SHADERTYPE_SOLID); default_material->setShaderType(Material::SHADERTYPE_SOLID);
#endif
m_default_materials[shader_type] = default_material; m_default_materials[shader_type] = default_material;
return default_material; return default_material;
} }

View File

@ -17,6 +17,8 @@
#include "graphics/materials.hpp" #include "graphics/materials.hpp"
#ifndef SERVER_ONLY
const STK::Tuple<size_t> DefaultMaterial::FirstPassTextures const STK::Tuple<size_t> DefaultMaterial::FirstPassTextures
= STK::Tuple<size_t>(1); = STK::Tuple<size_t>(1);
const STK::Tuple<size_t, size_t, size_t> DefaultMaterial::SecondPassTextures const STK::Tuple<size_t, size_t, size_t> DefaultMaterial::SecondPassTextures
@ -84,3 +86,5 @@ const STK::Tuple<size_t, size_t, size_t, size_t, size_t>
const STK::Tuple<> SplattingMat::ShadowTextures; const STK::Tuple<> SplattingMat::ShadowTextures;
const STK::Tuple<size_t, size_t, size_t, size_t, size_t> SplattingMat::RSMTextures const STK::Tuple<size_t, size_t, size_t, size_t, size_t> SplattingMat::RSMTextures
= STK::Tuple<size_t, size_t, size_t, size_t, size_t>(1, 3, 4, 5, 6); = STK::Tuple<size_t, size_t, size_t, size_t, size_t>(1, 3, 4, 5, 6);
#endif

View File

@ -18,6 +18,8 @@
#ifndef HEADER_MATERIAL_TYPE_HPP #ifndef HEADER_MATERIAL_TYPE_HPP
#define HEADER_MATERIAL_TYPE_HPP #define HEADER_MATERIAL_TYPE_HPP
#ifndef SERVER_ONLY
#include "graphics/shader.hpp" #include "graphics/shader.hpp"
#include "graphics/shaders.hpp" #include "graphics/shaders.hpp"
#include "graphics/stk_mesh.hpp" #include "graphics/stk_mesh.hpp"
@ -871,4 +873,5 @@ struct SplattingMat
}; // SplattingMat }; // SplattingMat
#endif //HEADER_MATERIAL_TYPE_HPP #endif // !SERVER_ONLY
#endif // HEADER_MATERIAL_TYPE_HPP

View File

@ -328,6 +328,7 @@ void recalculateTangents(scene::IMesh* mesh, bool recalculate_normals, bool smoo
} }
} }
#ifndef SERVER_ONLY
bool MeshTools::isNormalMap(scene::IMeshBuffer* mb) bool MeshTools::isNormalMap(scene::IMeshBuffer* mb)
{ {
if (!CVS->isGLSL()) if (!CVS->isGLSL())
@ -335,6 +336,7 @@ bool MeshTools::isNormalMap(scene::IMeshBuffer* mb)
return (mb->getMaterial().MaterialType == Shaders::getShader(ES_NORMAL_MAP) && return (mb->getMaterial().MaterialType == Shaders::getShader(ES_NORMAL_MAP) &&
mb->getVertexType() != video::EVT_TANGENTS); mb->getVertexType() != video::EVT_TANGENTS);
} }
#endif
// Copied from irrlicht // Copied from irrlicht
scene::IMesh* MeshTools::createMeshWithTangents(scene::IMesh* mesh, scene::IMesh* MeshTools::createMeshWithTangents(scene::IMesh* mesh,

View File

@ -16,6 +16,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/particle_emitter.hpp" #include "graphics/particle_emitter.hpp"
#include "graphics/central_settings.hpp" #include "graphics/central_settings.hpp"
@ -764,3 +766,5 @@ void ParticleEmitter::resizeBox(float size)
} }
#endif #endif
} }
#endif // !SERVER_ONLY

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#ifndef SERVER_ONLY
#include "graphics/post_processing.hpp" #include "graphics/post_processing.hpp"
#include "config/user_config.hpp" #include "config/user_config.hpp"
@ -1597,3 +1599,5 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode,
return out_fbo; return out_fbo;
} // render } // render
#endif // !SERVER_ONLY

View File

@ -147,7 +147,7 @@ Referee::Referee()
m_scene_node->setScale(m_st_scale.toIrrVector()); m_scene_node->setScale(m_st_scale.toIrrVector());
m_scene_node->setFrameLoop(m_st_first_start_frame, m_scene_node->setFrameLoop(m_st_first_start_frame,
m_st_last_start_frame); m_st_last_start_frame);
#ifndef SERVER_ONLY
irr_driver->applyObjectPassShader(m_scene_node); irr_driver->applyObjectPassShader(m_scene_node);
if (CVS->isGLSL() && CVS->isDefferedEnabled()) if (CVS->isGLSL() && CVS->isDefferedEnabled())
@ -156,6 +156,7 @@ Referee::Referee()
0.7f /* r */, 0.0 /* g */, 0.0f /* b */, false /* sun */, m_scene_node); 0.7f /* r */, 0.0 /* g */, 0.0f /* b */, false /* sun */, m_scene_node);
} }
else else
#endif
{ {
m_light = NULL; m_light = NULL;
} }
@ -184,7 +185,9 @@ Referee::Referee(const AbstractKart &kart)
m_scene_node->setFrameLoop(m_st_first_rescue_frame, m_scene_node->setFrameLoop(m_st_first_rescue_frame,
m_st_last_rescue_frame); m_st_last_rescue_frame);
#ifndef SERVER_ONLY
irr_driver->applyObjectPassShader(m_scene_node); irr_driver->applyObjectPassShader(m_scene_node);
#endif
} // Referee } // Referee
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -15,6 +15,7 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/render_target.hpp" #include "graphics/render_target.hpp"
#include "graphics/2dutils.hpp" #include "graphics/2dutils.hpp"
@ -151,3 +152,5 @@ void GL3RenderTarget::draw2DImage(const irr::core::rect<s32>& dest_rect,
glDisable(GL_FRAMEBUFFER_SRGB); glDisable(GL_FRAMEBUFFER_SRGB);
} // draw2DImage } // draw2DImage
#endif // !SERVER_ONLY

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/rtts.hpp" #include "graphics/rtts.hpp"
#include "config/user_config.hpp" #include "config/user_config.hpp"
@ -58,14 +60,14 @@ RTT::RTT(size_t width, size_t height)
using namespace video; using namespace video;
using namespace core; using namespace core;
dimension2du res(width * UserConfigParams::m_scale_rtts_factor, dimension2du res(int(width * UserConfigParams::m_scale_rtts_factor),
height * UserConfigParams::m_scale_rtts_factor); int(height * UserConfigParams::m_scale_rtts_factor) );
const dimension2du half = res/2; const dimension2du half = res/2;
const dimension2du quarter = res/4; const dimension2du quarter = res/4;
const dimension2du eighth = res/8; const dimension2du eighth = res/8;
const u16 shadowside = 1024 * UserConfigParams::m_scale_rtts_factor; const u16 shadowside = u16(1024 * UserConfigParams::m_scale_rtts_factor);
const dimension2du shadowsize0(shadowside, shadowside); const dimension2du shadowsize0(shadowside, shadowside);
const dimension2du shadowsize1(shadowside / 2, shadowside / 2); const dimension2du shadowsize1(shadowside / 2, shadowside / 2);
const dimension2du shadowsize2(shadowside / 4, shadowside / 4); const dimension2du shadowsize2(shadowside / 4, shadowside / 4);
@ -350,3 +352,5 @@ RTT::~RTT()
} }
} }
#endif // !SERVER_ONLY

View File

@ -16,6 +16,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/shader.hpp" #include "graphics/shader.hpp"
#include "graphics/central_settings.hpp" #include "graphics/central_settings.hpp"
@ -362,3 +364,5 @@ GLuint ShaderBase::createVAO()
} // createVAO } // createVAO
// ============================================================================ // ============================================================================
#endif // !SERVER_ONLY

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#ifndef HEADER_SHADER_HPP #ifndef HEADER_SHADER_HPP
#define HEADER_SHADER_HPP #define HEADER_SHADER_HPP
@ -383,3 +385,6 @@ public:
// ============================================================================ // ============================================================================
#endif #endif
#endif // !SERVER_ONLY

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/shader_based_renderer.hpp" #include "graphics/shader_based_renderer.hpp"
#include "config/user_config.hpp" #include "config/user_config.hpp"
@ -957,3 +959,5 @@ void ShaderBasedRenderer::renderToTexture(GL3RenderTarget *render_target,
irr_driver->getSceneManager()->setActiveCamera(NULL); irr_driver->getSceneManager()->setActiveCamera(NULL);
} //renderToTexture } //renderToTexture
#endif // !SERVER_ONLY

View File

@ -18,6 +18,8 @@
#ifndef HEADER_SHADER_BASED_RENDERER_HPP #ifndef HEADER_SHADER_BASED_RENDERER_HPP
#define HEADER_SHADER_BASED_RENDERER_HPP #define HEADER_SHADER_BASED_RENDERER_HPP
#ifndef SERVER_ONLY
#include "graphics/abstract_renderer.hpp" #include "graphics/abstract_renderer.hpp"
#include "graphics/draw_calls.hpp" #include "graphics/draw_calls.hpp"
#include "graphics/lighting_passes.hpp" #include "graphics/lighting_passes.hpp"
@ -125,4 +127,5 @@ public:
}; };
#endif //HEADER_SHADER_BASED_RENDERER_HPP #endif // !SERVER_ONLY
#endif // HEADER_SHADER_BASED_RENDERER_HPP

View File

@ -16,6 +16,8 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
/** /**
\page shaders_overview Shaders Overview \page shaders_overview Shaders Overview
@ -421,3 +423,5 @@ Shaders::ColoredLine::ColoredLine()
glBindVertexArray(0); glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0);
} // Shaders::ColoredLine } // Shaders::ColoredLine
#endif // !SERVER_ONLY

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#ifndef HEADER_SHADERS_HPP #ifndef HEADER_SHADERS_HPP
#define HEADER_SHADERS_HPP #define HEADER_SHADERS_HPP
@ -176,3 +178,5 @@ public:
}; // class Shaders }; // class Shaders
#endif #endif
#endif // SHADER_ONLY

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/shadow_matrices.hpp" #include "graphics/shadow_matrices.hpp"
#include "config/user_config.hpp" #include "config/user_config.hpp"
@ -523,3 +525,5 @@ void ShadowMatrices::renderShadowsDebug(const FrameBuffer &shadow_framebuffer,
renderWireFrameFrustrum(m_shadows_cam[3], 3); renderWireFrameFrustrum(m_shadows_cam[3], 3);
glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height); glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height);
} }
#endif // !SERVER_ONLY

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/shared_gpu_objects.hpp" #include "graphics/shared_gpu_objects.hpp"
#include "graphics/central_settings.hpp" #include "graphics/central_settings.hpp"
@ -232,3 +234,6 @@ void SharedGPUObjects::reset()
{ {
m_has_been_initialised = false; m_has_been_initialised = false;
} // reset } // reset
#endif // !SERVER_ONLY

View File

@ -16,6 +16,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/show_curve.hpp" #include "graphics/show_curve.hpp"
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
@ -200,3 +202,6 @@ void ShowCurve::setPosition(const Vec3 &xyz)
m_scene_node->setPosition(xyz.toIrrVector()); m_scene_node->setPosition(xyz.toIrrVector());
} // setPosition } // setPosition
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#endif // !SERVER_ONLY

View File

@ -131,12 +131,14 @@ void SkidMarks::update(float dt, bool force_skid_marks,
if (!is_skidding) // end skid marking if (!is_skidding) // end skid marking
{ {
m_skid_marking = false; m_skid_marking = false;
#ifndef SERVER_ONLY
// The vertices and indices will not change anymore // The vertices and indices will not change anymore
// (till these skid mark quads are deleted) // (till these skid mark quads are deleted)
m_left[m_current]->setHardwareMappingHint(scene::EHM_STATIC); m_left[m_current]->setHardwareMappingHint(scene::EHM_STATIC);
m_right[m_current]->setHardwareMappingHint(scene::EHM_STATIC); m_right[m_current]->setHardwareMappingHint(scene::EHM_STATIC);
if (STKMeshSceneNode* stkm = dynamic_cast<STKMeshSceneNode*>(m_nodes[m_current])) if (STKMeshSceneNode* stkm = dynamic_cast<STKMeshSceneNode*>(m_nodes[m_current]))
stkm->setReloadEachFrame(false); stkm->setReloadEachFrame(false);
#endif
return; return;
} }
@ -192,11 +194,13 @@ void SkidMarks::update(float dt, bool force_skid_marks,
custom_color); custom_color);
new_mesh->addMeshBuffer(smq_right); new_mesh->addMeshBuffer(smq_right);
scene::IMeshSceneNode *new_node = irr_driver->addMesh(new_mesh, "skidmark"); scene::IMeshSceneNode *new_node = irr_driver->addMesh(new_mesh, "skidmark");
#ifndef SERVER_ONLY
if (STKMeshSceneNode* stkm = dynamic_cast<STKMeshSceneNode*>(new_node)) if (STKMeshSceneNode* stkm = dynamic_cast<STKMeshSceneNode*>(new_node))
stkm->setReloadEachFrame(true); stkm->setReloadEachFrame(true);
#ifdef DEBUG #ifdef DEBUG
std::string debug_name = m_kart.getIdent()+" (skid-mark)"; std::string debug_name = m_kart.getIdent()+" (skid-mark)";
new_node->setName(debug_name.c_str()); new_node->setName(debug_name.c_str());
#endif
#endif #endif
// We don't keep a reference to the mesh here, so we have to decrement // We don't keep a reference to the mesh here, so we have to decrement

View File

@ -15,6 +15,7 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/skybox.hpp" #include "graphics/skybox.hpp"
#include "graphics/central_settings.hpp" #include "graphics/central_settings.hpp"
@ -375,4 +376,5 @@ void Skybox::render(const scene::ICameraSceneNode *camera) const
glBindVertexArray(0); glBindVertexArray(0);
} // renderSkybox } // renderSkybox
#endif // !SERVER_ONLY

View File

@ -51,10 +51,12 @@ SlipStream::SlipStream(AbstractKart* kart) : MovingTexture(0, 0), m_kart(kart)
scene::IMeshBuffer* buffer = m_mesh->getMeshBuffer(0); scene::IMeshBuffer* buffer = m_mesh->getMeshBuffer(0);
material->setMaterialProperties(&buffer->getMaterial(), buffer); material->setMaterialProperties(&buffer->getMaterial(), buffer);
#ifndef SERVER_ONLY
STKMeshSceneNode* stk_node = dynamic_cast<STKMeshSceneNode*>(m_node); STKMeshSceneNode* stk_node = dynamic_cast<STKMeshSceneNode*>(m_node);
if (stk_node != NULL) if (stk_node != NULL)
stk_node->setReloadEachFrame(true); stk_node->setReloadEachFrame(true);
m_mesh->drop(); m_mesh->drop();
#endif
#ifdef DEBUG #ifdef DEBUG
std::string debug_name = m_kart->getIdent()+" (slip-stream)"; std::string debug_name = m_kart->getIdent()+" (slip-stream)";
@ -99,8 +101,10 @@ SlipStream::SlipStream(AbstractKart* kart) : MovingTexture(0, 0), m_kart(kart)
} }
video::SMaterial &mat = buffer->getMaterial(); video::SMaterial &mat = buffer->getMaterial();
// Meshes need a texture, otherwise stk crashes. // Meshes need a texture, otherwise stk crashes.
#ifndef SERVER_ONLY
video::ITexture *red_texture = getUnicolorTexture(red); video::ITexture *red_texture = getUnicolorTexture(red);
mat.setTexture(0, red_texture); mat.setTexture(0, red_texture);
#endif
buffer->recalculateBoundingBox(); buffer->recalculateBoundingBox();
m_mesh->setBoundingBox(buffer->getBoundingBox()); m_mesh->setBoundingBox(buffer->getBoundingBox());
@ -231,7 +235,9 @@ void SlipStream::createMesh(Material* material)
} // for j<num_circles-1 } // for j<num_circles-1
material->setMaterialProperties(&buffer->getMaterial(), buffer); material->setMaterialProperties(&buffer->getMaterial(), buffer);
#ifndef SERVER_ONLY
if (!CVS->isGLSL()) if (!CVS->isGLSL())
#endif
{ {
buffer->Material.setFlag(video::EMF_BACK_FACE_CULLING, false); buffer->Material.setFlag(video::EMF_BACK_FACE_CULLING, false);
buffer->Material.setFlag(video::EMF_COLOR_MATERIAL, true); buffer->Material.setFlag(video::EMF_COLOR_MATERIAL, true);

View File

@ -15,6 +15,7 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#include "graphics/spherical_harmonics.hpp" #include "graphics/spherical_harmonics.hpp"
@ -528,3 +529,5 @@ void SphericalHarmonics::unprojectSH(size_t width, size_t height,
} }
} // unprojectSH } // unprojectSH
#endif // !SERVER_ONLY

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/stk_animated_mesh.hpp" #include "graphics/stk_animated_mesh.hpp"
#include "graphics/central_settings.hpp" #include "graphics/central_settings.hpp"
@ -344,3 +346,5 @@ void STKAnimatedMesh::resetSkinningState(scene::IAnimatedMesh* mesh)
m_skinned_mesh = NULL; m_skinned_mesh = NULL;
} }
} }
#endif // !SERVER_ONLY

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/stk_billboard.hpp" #include "graphics/stk_billboard.hpp"
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
@ -118,3 +120,6 @@ void STKBillboard::render()
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0); glBindVertexArray(0);
} // render } // render
#endif // !SERVER_ONLY

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/stk_mesh.hpp" #include "graphics/stk_mesh.hpp"
#include "graphics/callbacks.hpp" #include "graphics/callbacks.hpp"
@ -471,3 +473,6 @@ void initTexturesTransparent(GLMesh &mesh)
} }
#endif #endif
} // initTexturesTransparent } // initTexturesTransparent
#endif // !SERVER_ONLY

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/stk_mesh_scene_node.hpp" #include "graphics/stk_mesh_scene_node.hpp"
#include "graphics/central_settings.hpp" #include "graphics/central_settings.hpp"
@ -608,3 +610,6 @@ void STKMeshSceneNode::render()
} }
} }
} }
#endif // !SERVER_ONLY

View File

@ -73,8 +73,10 @@ public:
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i); scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
if (!mb) if (!mb)
continue; continue;
#ifndef SERVER_ONLY
if (isDisplacement) if (isDisplacement)
mb->getMaterial().MaterialType = Shaders::getShader(ES_DISPLACE); mb->getMaterial().MaterialType = Shaders::getShader(ES_DISPLACE);
#endif
} }
} }
virtual bool glow() const { return isGlow; } virtual bool glow() const { return isGlow; }

View File

@ -0,0 +1,67 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2014-2015 SuperTuxKart-Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/stk_scene_manager.hpp"
#include <SViewFrustum.h>
#include <vector>
using namespace irr;
// From irrlicht code
static
bool isBoxInFrontOfPlane(const core::plane3df &plane, const core::vector3df edges[8])
{
for (u32 j = 0; j<8; ++j)
if (plane.classifyPointRelation(edges[j]) != core::ISREL3D_FRONT)
return false;
return true;
}
std::vector<float> BoundingBoxes;
void addEdge(const core::vector3df &P0, const core::vector3df &P1)
{
BoundingBoxes.push_back(P0.X);
BoundingBoxes.push_back(P0.Y);
BoundingBoxes.push_back(P0.Z);
BoundingBoxes.push_back(P1.X);
BoundingBoxes.push_back(P1.Y);
BoundingBoxes.push_back(P1.Z);
}
bool isCulledPrecise(const scene::ICameraSceneNode *cam, const scene::ISceneNode *node)
{
if (!node->getAutomaticCulling())
return false;
const core::matrix4 &trans = node->getAbsoluteTransformation();
const scene::SViewFrustum &frust = *cam->getViewFrustum();
core::vector3df edges[8];
node->getBoundingBox().getEdges(edges);
for (unsigned i = 0; i < 8; i++)
trans.transformVect(edges[i]);
for (s32 i = 0; i < scene::SViewFrustum::VF_PLANE_COUNT; ++i)
if (isBoxInFrontOfPlane(frust.planes[i], edges))
return true;
return false;
}
#endif // !SERVER_ONLY

View File

@ -0,0 +1,37 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2014-2015 SuperTuxKart-Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Not really a scene manager yet but hold algorithm that
// rework scene manager output
#ifndef SERVER_ONLY
#ifndef HEADER_STKSCENEMANAGER_HPP
#define HEADER_STKSCENEMANAGER_HPP
#include <ICameraSceneNode.h>
#include <ISceneNode.h>
#include <vector3d.h>
void addEdge(const irr::core::vector3df &P0, const irr::core::vector3df &P1);
bool isCulledPrecise(const irr::scene::ICameraSceneNode *cam, const irr::scene::ISceneNode *node);
#endif
#endif // supertuxkart

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/stk_text_billboard.hpp" #include "graphics/stk_text_billboard.hpp"
#include "graphics/shaders.hpp" #include "graphics/shaders.hpp"
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
@ -190,3 +192,6 @@ void STKTextBillboard::collectChar(video::ITexture* texture,
{ {
m_chars.push_back(STKTextBillboardChar(texture, destRect, sourceRect, colors)); m_chars.push_back(STKTextBillboardChar(texture, destRect, sourceRect, colors));
} }
#endif // !SERVER_ONLY

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/texture_manager.hpp" #include "graphics/texture_manager.hpp"
#include "graphics/central_settings.hpp" #include "graphics/central_settings.hpp"
@ -277,3 +279,6 @@ video::ITexture* getUnicolorTexture(const video::SColor &c)
return tex; return tex;
} }
} }
#endif // !SERVER_ONLY

View File

@ -16,6 +16,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/texture_shader.hpp" #include "graphics/texture_shader.hpp"
#include "graphics/central_settings.hpp" #include "graphics/central_settings.hpp"
@ -366,3 +368,6 @@ GLuint TextureShaderBase::createSemiTrilinearSampler()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#endif // !SERVER_ONLY

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SHADER_ONLY
#ifndef HEADER_TEXTURE_SHADER_HPP #ifndef HEADER_TEXTURE_SHADER_HPP
#define HEADER_TEXTURE_SHADER_HPP #define HEADER_TEXTURE_SHADER_HPP
@ -259,3 +261,5 @@ public:
}; // class TextureShader }; // class TextureShader
#endif #endif
#endif // SHADER_ONLY

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/vao_manager.hpp" #include "graphics/vao_manager.hpp"
#include "graphics/central_settings.hpp" #include "graphics/central_settings.hpp"
@ -367,3 +369,5 @@ std::pair<unsigned, unsigned> VAOManager::getBase(scene::IMeshBuffer *mb, Render
assert(It != mappedBaseIndex[tp].end()); assert(It != mappedBaseIndex[tp].end());
return std::pair<unsigned, unsigned>(vtx, It->second); return std::pair<unsigned, unsigned>(vtx, It->second);
} }
#endif // !SERVER_ONLY

View File

@ -16,6 +16,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "graphics/water.hpp" #include "graphics/water.hpp"
#include "graphics/callbacks.hpp" #include "graphics/callbacks.hpp"
@ -89,3 +91,6 @@ void WaterNode::OnRegisterSceneNode()
ISceneNode::OnRegisterSceneNode(); ISceneNode::OnRegisterSceneNode();
} }
} }
#endif // !SERVER_ONLY

View File

@ -174,6 +174,7 @@ void STKModifiedSpriteBank::draw2DSprite(u32 index,
const core::rect<s32>* clip, const video::SColor& color, const core::rect<s32>* clip, const video::SColor& color,
u32 starttime, u32 currenttime, bool loop, bool center) u32 starttime, u32 currenttime, bool loop, bool center)
{ {
#ifndef SERVER_ONLY
assert( m_magic_number == 0xCAFEC001 ); assert( m_magic_number == 0xCAFEC001 );
if (index >= Sprites.size() || Sprites[index].Frames.empty() ) if (index >= Sprites.size() || Sprites[index].Frames.empty() )
return; return;
@ -221,7 +222,7 @@ void STKModifiedSpriteBank::draw2DSprite(u32 index,
*/ */
draw2DImage(tex, dest, r /* source rect */, clip, draw2DImage(tex, dest, r /* source rect */, clip,
NULL /* colors */, true); NULL /* colors */, true);
#endif
} // draw2DSprite } // draw2DSprite
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -664,7 +664,9 @@ namespace GUIEngine
#include "font/regular_face.hpp" #include "font/regular_face.hpp"
#include "input/input_manager.hpp" #include "input/input_manager.hpp"
#include "io/file_manager.hpp" #include "io/file_manager.hpp"
#ifndef SERVER_ONLY
#include "graphics/2dutils.hpp" #include "graphics/2dutils.hpp"
#endif
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#include "guiengine/event_handler.hpp" #include "guiengine/event_handler.hpp"
#include "guiengine/modaldialog.hpp" #include "guiengine/modaldialog.hpp"
@ -1121,6 +1123,7 @@ namespace GUIEngine
void render(float elapsed_time) void render(float elapsed_time)
{ {
#ifndef SERVER_ONLY
GUIEngine::dt = elapsed_time; GUIEngine::dt = elapsed_time;
// Not yet initialized, or already cleaned up // Not yet initialized, or already cleaned up
@ -1208,7 +1211,6 @@ namespace GUIEngine
y_from - count*text_height), y_from - count*text_height),
core::dimension2d<s32>(screen_size.Width, core::dimension2d<s32>(screen_size.Width,
text_height) ); text_height) );
GL32_draw2DRectangle(SColor(255,252,248,230), GL32_draw2DRectangle(SColor(255,252,248,230),
msgRect); msgRect);
Private::g_font->draw((*it).m_message.c_str(), Private::g_font->draw((*it).m_message.c_str(),
@ -1244,7 +1246,7 @@ namespace GUIEngine
DemoWorld::resetIdleTime(); DemoWorld::resetIdleTime();
} }
#endif
} // render } // render
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@ -1252,6 +1254,7 @@ namespace GUIEngine
void renderLoading(bool clearIcons) void renderLoading(bool clearIcons)
{ {
#ifndef SERVER_ONLY
if (clearIcons) g_loading_icons.clear(); if (clearIcons) g_loading_icons.clear();
g_skin->drawBgImage(); g_skin->drawBgImage();
@ -1315,7 +1318,7 @@ namespace GUIEngine
x = ICON_MARGIN; x = ICON_MARGIN;
} }
} }
#endif
} // renderLoading } // renderLoading
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------

View File

@ -93,6 +93,8 @@ void ScalableFont::draw(const core::stringw& text,
const video::SColor& color, bool hcenter, bool vcenter, const video::SColor& color, bool hcenter, bool vcenter,
const core::rect<s32>* clip, bool ignoreRTL) const core::rect<s32>* clip, bool ignoreRTL)
{ {
#ifndef SERVER_ONLY
bool previousRTL = m_font_settings->isRTL(); bool previousRTL = m_font_settings->isRTL();
if (ignoreRTL) if (ignoreRTL)
m_font_settings->setRTL(false); m_font_settings->setRTL(false);
@ -102,7 +104,7 @@ void ScalableFont::draw(const core::stringw& text,
if (ignoreRTL) if (ignoreRTL)
m_font_settings->setRTL(previousRTL); m_font_settings->setRTL(previousRTL);
#endif
} // draw } // draw
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -326,7 +326,7 @@ Skin::~Skin()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void Skin::drawBgImage() void Skin::drawBgImage()
{ {
#ifndef SERVER_ONLY
// ---- background image // ---- background image
// on one end, making these static is not too clean. // on one end, making these static is not too clean.
// on another end, these variables are really only used locally, // on another end, these variables are really only used locally,
@ -370,6 +370,7 @@ void Skin::drawBgImage()
/* no clipping */0, /*color*/ 0, /* no clipping */0, /*color*/ 0,
/*alpha*/false); /*alpha*/false);
irr_driver->getVideoDriver()->enableMaterial2D(false); irr_driver->getVideoDriver()->enableMaterial2D(false);
#endif
} // drawBgImage } // drawBgImage
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -401,6 +402,7 @@ void Skin::drawBoxFromStretchableTexture(SkinWidgetContainer* w,
bool deactivated, bool deactivated,
const core::recti* clipRect) const core::recti* clipRect)
{ {
#ifndef SERVER_ONLY
// check if widget moved. if so, recalculate coords // check if widget moved. if so, recalculate coords
if (w->m_skin_x != dest.UpperLeftCorner.X || if (w->m_skin_x != dest.UpperLeftCorner.X ||
w->m_skin_y != dest.UpperLeftCorner.Y || w->m_skin_y != dest.UpperLeftCorner.Y ||
@ -701,7 +703,7 @@ X##_yflip.LowerRightCorner.Y = w->m_skin_dest_y + \
{ {
delete[] colorptr; delete[] colorptr;
} }
#endif
} // drawBoxFromStretchableTexture } // drawBoxFromStretchableTexture
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -844,6 +846,7 @@ void Skin::drawProgress(Widget* w, const core::recti &rect,
void Skin::drawRatingBar(Widget *w, const core::recti &rect, void Skin::drawRatingBar(Widget *w, const core::recti &rect,
const bool pressed, const bool focused) const bool pressed, const bool focused)
{ {
#ifndef SERVER_ONLY
RatingBarWidget *ratingBar = (RatingBarWidget*)w; RatingBarWidget *ratingBar = (RatingBarWidget*)w;
const ITexture *texture = SkinConfig::m_render_params["rating::neutral"].getImage(); const ITexture *texture = SkinConfig::m_render_params["rating::neutral"].getImage();
@ -897,7 +900,7 @@ void Skin::drawRatingBar(Widget *w, const core::recti &rect,
(w->m_deactivated || ID_DEBUG) ? colors : 0, (w->m_deactivated || ID_DEBUG) ? colors : 0,
true /* alpha */); true /* alpha */);
} }
#endif
} // drawRatingBar } // drawRatingBar
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -921,6 +924,7 @@ void Skin::drawRibbon(const core::recti &rect, Widget* widget,
void Skin::drawRibbonChild(const core::recti &rect, Widget* widget, void Skin::drawRibbonChild(const core::recti &rect, Widget* widget,
const bool pressed, bool focused) const bool pressed, bool focused)
{ {
#ifndef SERVER_ONLY
// for now, when this kind of widget is disabled, just hide it. we can // for now, when this kind of widget is disabled, just hide it. we can
// change that behaviour if we ever need to... // change that behaviour if we ever need to...
//if (widget->m_deactivated) return; //if (widget->m_deactivated) return;
@ -1220,6 +1224,7 @@ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget,
m_tooltips.push_back(widget); m_tooltips.push_back(widget);
} }
} }
#endif
} // drawRibbonChild } // drawRibbonChild
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -1435,6 +1440,7 @@ void Skin::drawSpinnerChild(const core::recti &rect, Widget* widget,
void Skin::drawIconButton(const core::recti &rect, Widget* widget, void Skin::drawIconButton(const core::recti &rect, Widget* widget,
const bool pressed, bool focused) const bool pressed, bool focused)
{ {
#ifndef SERVER_ONLY
RibbonWidget* parentRibbon = dynamic_cast<RibbonWidget*>(widget->m_event_handler); RibbonWidget* parentRibbon = dynamic_cast<RibbonWidget*>(widget->m_event_handler);
IGUIElement* focusedElem = NULL; IGUIElement* focusedElem = NULL;
if (GUIEngine::getFocusForPlayer(PLAYER_ID_GAME_MASTER) != NULL) if (GUIEngine::getFocusForPlayer(PLAYER_ID_GAME_MASTER) != NULL)
@ -1543,6 +1549,7 @@ void Skin::drawIconButton(const core::recti &rect, Widget* widget,
{ {
irr_driver->getVideoDriver()->enableMaterial2D(); irr_driver->getVideoDriver()->enableMaterial2D();
} }
#endif
} // drawIconButton } // drawIconButton
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -1662,6 +1669,7 @@ void Skin::drawListSelection(const core::recti &rect, Widget* widget,
void Skin::drawListHeader(const irr::core::rect< irr::s32 > &rect, void Skin::drawListHeader(const irr::core::rect< irr::s32 > &rect,
Widget* widget) Widget* widget)
{ {
#ifndef SERVER_ONLY
bool isSelected = bool isSelected =
(((ListWidget*)widget->m_event_handler)->m_selected_column == widget && (((ListWidget*)widget->m_event_handler)->m_selected_column == widget &&
((ListWidget*)widget->m_event_handler)->m_sort_default == false); ((ListWidget*)widget->m_event_handler)->m_sort_default == false);
@ -1689,7 +1697,7 @@ void Skin::drawListHeader(const irr::core::rect< irr::s32 > &rect,
draw2DImage(img, destRect, srcRect, draw2DImage(img, destRect, srcRect,
NULL, NULL, /* alpha */true); NULL, NULL, /* alpha */true);
} }
#endif
} // drawListHeader } // drawListHeader
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -1698,6 +1706,7 @@ void Skin::drawListHeader(const irr::core::rect< irr::s32 > &rect,
*/ */
void Skin::renderSections(PtrVector<Widget>* within_vector) void Skin::renderSections(PtrVector<Widget>* within_vector)
{ {
#ifndef SERVER_ONLY
if (within_vector == NULL) within_vector = &getCurrentScreen()->m_widgets; if (within_vector == NULL) within_vector = &getCurrentScreen()->m_widgets;
const unsigned short widgets_amount = within_vector->size(); const unsigned short widgets_amount = within_vector->size();
@ -1770,12 +1779,13 @@ void Skin::renderSections(PtrVector<Widget>* within_vector)
} }
} }
} // next } // next
#endif // !SERVER_ONLY
} // renderSections } // renderSections
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void Skin::drawScrollbarBackground(const irr::core::rect< irr::s32 > &rect) void Skin::drawScrollbarBackground(const irr::core::rect< irr::s32 > &rect)
{ {
#ifndef SERVER_ONLY
// leave square space at both ends for up/down buttons (yeah, irrlicht // leave square space at both ends for up/down buttons (yeah, irrlicht
// doesn't handle that) // doesn't handle that)
core::recti rect2 = rect; core::recti rect2 = rect;
@ -1789,12 +1799,13 @@ void Skin::drawScrollbarBackground(const irr::core::rect< irr::s32 > &rect)
p.m_source_area_center, p.m_source_area_center,
0 /* no clipping */, 0, 0 /* no clipping */, 0,
true /* alpha */); true /* alpha */);
#endif
} // drawScrollbarBackground } // drawScrollbarBackground
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void Skin::drawScrollbarThumb(const irr::core::rect< irr::s32 > &rect) void Skin::drawScrollbarThumb(const irr::core::rect< irr::s32 > &rect)
{ {
#ifndef SERVER_ONLY
BoxRenderParams& p = BoxRenderParams& p =
SkinConfig::m_render_params["scrollbar_thumb::neutral"]; SkinConfig::m_render_params["scrollbar_thumb::neutral"];
@ -1802,7 +1813,7 @@ void Skin::drawScrollbarThumb(const irr::core::rect< irr::s32 > &rect)
p.m_source_area_center, p.m_source_area_center,
0 /* no clipping */, 0, 0 /* no clipping */, 0,
true /* alpha */); true /* alpha */);
#endif
} // drawScrollbarThumb } // drawScrollbarThumb
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -1958,7 +1969,9 @@ void Skin::process3DPane(IGUIElement *element, const core::recti &rect,
else if (type == WTYPE_MODEL_VIEW) else if (type == WTYPE_MODEL_VIEW)
{ {
ModelViewWidget* mvw = dynamic_cast<ModelViewWidget*>(widget); ModelViewWidget* mvw = dynamic_cast<ModelViewWidget*>(widget);
#ifndef SERVER_ONLY
mvw->drawRTTScene(rect); mvw->drawRTTScene(rect);
#endif
} }
else if (type == WTYPE_ICON_BUTTON) else if (type == WTYPE_ICON_BUTTON)
{ {
@ -2016,6 +2029,7 @@ void Skin::process3DPane(IGUIElement *element, const core::recti &rect,
void doDrawBadge(ITexture* texture, const core::recti& rect, void doDrawBadge(ITexture* texture, const core::recti& rect,
float max_icon_size, bool badge_at_left) float max_icon_size, bool badge_at_left)
{ {
#ifndef SERVER_ONLY
// In case of a problem // In case of a problem
if(!texture) return; if(!texture) return;
@ -2041,6 +2055,7 @@ void doDrawBadge(ITexture* texture, const core::recti& rect,
draw2DImage(texture, rect2, source_area, draw2DImage(texture, rect2, source_area,
0 /* no clipping */, 0, 0 /* no clipping */, 0,
true /* alpha */); true /* alpha */);
#endif
} // doDrawBadge } // doDrawBadge
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -2139,6 +2154,7 @@ void Skin::draw3DSunkenPane (IGUIElement *element, video::SColor bgcolor,
bool flat, bool fillBackGround, bool flat, bool fillBackGround,
const core::recti &rect, const core::recti *clip) const core::recti &rect, const core::recti *clip)
{ {
#ifndef SERVER_ONLY
const int id = element->getID(); const int id = element->getID();
Widget* widget = GUIEngine::getWidget(id); Widget* widget = GUIEngine::getWidget(id);
@ -2257,18 +2273,21 @@ void Skin::draw3DSunkenPane (IGUIElement *element, video::SColor bgcolor,
return; return;
} }
#endif
} // draw3DSunkenPane } // draw3DSunkenPane
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void Skin::drawBGFadeColor() void Skin::drawBGFadeColor()
{ {
#ifndef SERVER_ONLY
// fade out background // fade out background
SColor color = SkinConfig::m_colors["dialog_background::neutral"]; SColor color = SkinConfig::m_colors["dialog_background::neutral"];
if (m_dialog_size < 1.0f) if (m_dialog_size < 1.0f)
color.setAlpha( (unsigned int)(color.getAlpha()*m_dialog_size )); color.setAlpha( (unsigned int)(color.getAlpha()*m_dialog_size ));
GL32_draw2DRectangle(color, core::recti(position2d< s32 >(0,0), GL32_draw2DRectangle(color, core::recti(position2d< s32 >(0,0),
irr_driver->getActualScreenSize())); irr_driver->getActualScreenSize()));
#endif
} // drawBGFadeColor } // drawBGFadeColor
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -2316,8 +2335,10 @@ core::recti Skin::draw3DWindowBackground(IGUIElement *element,
void Skin::draw3DMenuPane (IGUIElement *element, const core::recti &rect, void Skin::draw3DMenuPane (IGUIElement *element, const core::recti &rect,
const core::recti *clip) const core::recti *clip)
{ {
#ifndef SERVER_ONLY
SColor color = SColor(150, 96, 74, 196); SColor color = SColor(150, 96, 74, 196);
GL32_draw2DRectangle(color, rect); GL32_draw2DRectangle(color, rect);
#endif
} // draw3DMenuPane } // draw3DMenuPane
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -2376,7 +2397,9 @@ void Skin::draw2DImage(const video::ITexture* texture, const core::rect<s32>& de
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect,
const video::SColor* const colors, bool useAlphaChannelOfTexture) const video::SColor* const colors, bool useAlphaChannelOfTexture)
{ {
#ifndef SERVER_ONLY
::draw2DImage(texture, destRect, sourceRect, clipRect, colors, useAlphaChannelOfTexture); ::draw2DImage(texture, destRect, sourceRect, clipRect, colors, useAlphaChannelOfTexture);
#endif
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@ -99,6 +99,7 @@ CGUIEditBox::CGUIEditBox(const wchar_t* text, bool border,
//! destructor //! destructor
CGUIEditBox::~CGUIEditBox() CGUIEditBox::~CGUIEditBox()
{ {
#ifndef SERVER_ONLY
if (OverrideFont) if (OverrideFont)
OverrideFont->drop(); OverrideFont->drop();
@ -108,6 +109,7 @@ CGUIEditBox::~CGUIEditBox()
CIrrDeviceLinux* dl = dynamic_cast<CIrrDeviceLinux*>(irr_driver->getDevice()); CIrrDeviceLinux* dl = dynamic_cast<CIrrDeviceLinux*>(irr_driver->getDevice());
dl->setIMEEnable(false); dl->setIMEEnable(false);
#endif #endif
#endif
} }
@ -235,6 +237,7 @@ void CGUIEditBox::setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT ver
//! called if an event happened. //! called if an event happened.
bool CGUIEditBox::OnEvent(const SEvent& event) bool CGUIEditBox::OnEvent(const SEvent& event)
{ {
#ifndef SERVER_ONLY
if (isEnabled()) if (isEnabled())
{ {
@ -280,7 +283,7 @@ bool CGUIEditBox::OnEvent(const SEvent& event)
break; break;
} }
} }
#endif
return IGUIElement::OnEvent(event); return IGUIElement::OnEvent(event);
} }
@ -903,6 +906,7 @@ core::position2di CGUIEditBox::calculateICPos()
//! draws the element and its children //! draws the element and its children
void CGUIEditBox::draw() void CGUIEditBox::draw()
{ {
#ifndef SERVER_ONLY
if (!IsVisible) if (!IsVisible)
return; return;
@ -1104,6 +1108,7 @@ void CGUIEditBox::draw()
// draw children // draw children
IGUIElement::draw(); IGUIElement::draw();
#endif
} }
@ -1563,6 +1568,7 @@ void CGUIEditBox::inputChar(wchar_t c)
void CGUIEditBox::calculateScrollPos() void CGUIEditBox::calculateScrollPos()
{ {
#ifndef SERVER_ONLY
if (!AutoScroll) if (!AutoScroll)
return; return;
@ -1616,6 +1622,7 @@ void CGUIEditBox::calculateScrollPos()
dl->setIMELocation(calculateICPos()); dl->setIMELocation(calculateICPos());
} }
#endif #endif
#endif // SERVER_ONLY
} }
//! set text markers //! set text markers

View File

@ -52,13 +52,17 @@ IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_TEXTURE_ASPECT_RATIO, false,
m_properties[PROP_ICON]="gui/main_help.png"; m_properties[PROP_ICON]="gui/main_help.png";
m_rtt_unsupported = false; m_rtt_unsupported = false;
} } // ModelViewWidget
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
ModelViewWidget::~ModelViewWidget() ModelViewWidget::~ModelViewWidget()
{ {
GUIEngine::needsUpdate.remove(this); GUIEngine::needsUpdate.remove(this);
#ifndef SERVER_ONLY
delete m_render_info; delete m_render_info;
} #endif
} // ~ModelViewWidget
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void ModelViewWidget::add() void ModelViewWidget::add()
{ {
@ -92,7 +96,7 @@ void ModelViewWidget::clearModels()
m_rtt_main_node = NULL; m_rtt_main_node = NULL;
m_camera = NULL; m_camera = NULL;
m_light = NULL; m_light = NULL;
} } // clearModels
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -107,10 +111,11 @@ void ModelViewWidget::addModel(irr::scene::IMesh* mesh, const Vec3& location,
m_model_scale.push_back(scale); m_model_scale.push_back(scale);
m_model_frames.push_back(frame); m_model_frames.push_back(frame);
m_model_render_info_affected.push_back(all_parts_colorized); m_model_render_info_affected.push_back(all_parts_colorized);
#ifndef SERVER_ONLY
if (!CVS->isGLSL()) if (!CVS->isGLSL())
m_render_target = NULL; m_render_target = NULL;
} #endif
} // addModel
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void ModelViewWidget::update(float delta) void ModelViewWidget::update(float delta)
@ -161,7 +166,10 @@ void ModelViewWidget::update(float delta)
// stop rotating when target reached // stop rotating when target reached
if (fabsf(m_angle - m_rotation_target) < 2.0f) m_rotation_mode = ROTATE_OFF; if (fabsf(m_angle - m_rotation_target) < 2.0f) m_rotation_mode = ROTATE_OFF;
} }
#ifdef SERVER_ONLY
return;
#else
if (m_render_target == NULL) if (m_render_target == NULL)
{ {
std::string name = "model view "; std::string name = "model view ";
@ -181,10 +189,13 @@ void ModelViewWidget::update(float delta)
m_render_target->renderToTexture(m_camera, GUIEngine::getLatestDt()); m_render_target->renderToTexture(m_camera, GUIEngine::getLatestDt());
m_rtt_main_node->setVisible(false); m_rtt_main_node->setVisible(false);
} #endif
} // update
// ----------------------------------------------------------------------------
void ModelViewWidget::setupRTTScene() void ModelViewWidget::setupRTTScene()
{ {
#ifndef SERVER_ONLY
irr_driver->suppressSkyBox(); irr_driver->suppressSkyBox();
if (m_rtt_main_node != NULL) m_rtt_main_node->remove(); if (m_rtt_main_node != NULL) m_rtt_main_node->remove();
@ -297,42 +308,57 @@ void ModelViewWidget::setupRTTScene()
m_camera->setFOV(DEGREE_TO_RAD*50.0f); m_camera->setFOV(DEGREE_TO_RAD*50.0f);
m_camera->updateAbsolutePosition(); m_camera->updateAbsolutePosition();
} #endif
} // setupRTTScene
// ----------------------------------------------------------------------------
void ModelViewWidget::setRotateOff() void ModelViewWidget::setRotateOff()
{ {
m_rotation_mode = ROTATE_OFF; m_rotation_mode = ROTATE_OFF;
} } // setRotateOff
// ----------------------------------------------------------------------------
void ModelViewWidget::setRotateContinuously(float speed) void ModelViewWidget::setRotateContinuously(float speed)
{ {
m_rotation_mode = ROTATE_CONTINUOUSLY; m_rotation_mode = ROTATE_CONTINUOUSLY;
m_rotation_speed = speed; m_rotation_speed = speed;
} } // setRotateContinuously
// ----------------------------------------------------------------------------
void ModelViewWidget::setRotateTo(float targetAngle, float speed) void ModelViewWidget::setRotateTo(float targetAngle, float speed)
{ {
m_rotation_mode = ROTATE_TO; m_rotation_mode = ROTATE_TO;
m_rotation_speed = speed; m_rotation_speed = speed;
m_rotation_target = targetAngle; m_rotation_target = targetAngle;
} } // setRotateTo
// ----------------------------------------------------------------------------
bool ModelViewWidget::isRotating() bool ModelViewWidget::isRotating()
{ {
return m_rotation_mode != ROTATE_OFF ? true : false; return m_rotation_mode != ROTATE_OFF ? true : false;
} } // isRotating
// ----------------------------------------------------------------------------
void ModelViewWidget::elementRemoved() void ModelViewWidget::elementRemoved()
{ {
#ifndef SERVER_ONLY
m_render_target = NULL; m_render_target = NULL;
IconButtonWidget::elementRemoved(); IconButtonWidget::elementRemoved();
} #endif
} // elementRemoved
// ----------------------------------------------------------------------------
void ModelViewWidget::clearRttProvider() void ModelViewWidget::clearRttProvider()
{ {
m_render_target = NULL; m_render_target = NULL;
} } // clearRttProvider
// ----------------------------------------------------------------------------
void ModelViewWidget::drawRTTScene(const irr::core::rect<s32>& dest_rect) const void ModelViewWidget::drawRTTScene(const irr::core::rect<s32>& dest_rect) const
{ {
#ifndef SERVER_ONLY
if(m_render_target != NULL) if(m_render_target != NULL)
m_render_target->draw2DImage(dest_rect, NULL, video::SColor(255, 255, 255, 255), true); m_render_target->draw2DImage(dest_rect, NULL, video::SColor(255, 255, 255, 255), true);
} #endif
} // drawRTTScene

View File

@ -182,7 +182,7 @@ void Attachment::set(AttachmentType type, float time,
} }
} }
m_node->setVisible(true); m_node->setVisible(true);
#ifndef SERVER_ONLY
irr_driver->applyObjectPassShader(m_node); irr_driver->applyObjectPassShader(m_node);
// Save event about the new attachment // Save event about the new attachment
@ -193,6 +193,7 @@ void Attachment::set(AttachmentType type, float time,
saveState(buffer); saveState(buffer);
rwm->addEvent(this, buffer); rwm->addEvent(this, buffer);
} }
#endif
} // set } // set
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@ -76,6 +76,7 @@ Flyable::Flyable(AbstractKart *kart, PowerupManager::PowerupType type,
m_max_lifespan = -1; m_max_lifespan = -1;
// Add the graphical model // Add the graphical model
#ifndef SERVER_ONLY
setNode(irr_driver->addMesh(m_st_model[type], StringUtils::insertValues("flyable_%i", (int)type))); setNode(irr_driver->addMesh(m_st_model[type], StringUtils::insertValues("flyable_%i", (int)type)));
irr_driver->applyObjectPassShader(getNode()); irr_driver->applyObjectPassShader(getNode());
#ifdef DEBUG #ifdef DEBUG
@ -83,7 +84,7 @@ Flyable::Flyable(AbstractKart *kart, PowerupManager::PowerupType type,
debug_name += type; debug_name += type;
getNode()->setName(debug_name.c_str()); getNode()->setName(debug_name.c_str());
#endif #endif
#endif
} // Flyable } // Flyable
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -185,6 +185,7 @@ void Item::switchTo(ItemType type, scene::IMesh *mesh, scene::IMesh *lowmesh)
scene::ISceneNode* node = m_node->getAllNodes()[0]; scene::ISceneNode* node = m_node->getAllNodes()[0];
((scene::IMeshSceneNode*)node)->setMesh(mesh); ((scene::IMeshSceneNode*)node)->setMesh(mesh);
#ifndef SERVER_ONLY
if (lowmesh != NULL) if (lowmesh != NULL)
{ {
node = m_node->getAllNodes()[1]; node = m_node->getAllNodes()[1];
@ -195,6 +196,7 @@ void Item::switchTo(ItemType type, scene::IMesh *mesh, scene::IMesh *lowmesh)
irr_driver->applyObjectPassShader(m_node->getAllNodes()[0]); irr_driver->applyObjectPassShader(m_node->getAllNodes()[0]);
World::getWorld()->getTrack()->adjustForFog(m_node); World::getWorld()->getTrack()->adjustForFog(m_node);
#endif
} // switchTo } // switchTo
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@ -68,14 +68,17 @@ RubberBand::RubberBand(Plunger *plunger, AbstractKart *kart)
verts[i].Color = color; verts[i].Color = color;
} }
#ifndef SERVER_ONLY
// Color // Color
mb->getMaterial().setTexture(0, getUnicolorTexture(video::SColor(255, 255, 255, 255))); mb->getMaterial().setTexture(0, getUnicolorTexture(video::SColor(255, 255, 255, 255)));
// Gloss // Gloss
mb->getMaterial().setTexture(1, getUnicolorTexture(video::SColor(0, 0, 0, 0))); mb->getMaterial().setTexture(1, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
// Colorization mask // Colorization mask
mb->getMaterial().setTexture(2, getUnicolorTexture(video::SColor(0, 0, 0, 0))); mb->getMaterial().setTexture(2, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
#endif
updatePosition(); updatePosition();
m_node = irr_driver->addMesh(m_mesh, "rubberband"); m_node = irr_driver->addMesh(m_mesh, "rubberband");
#ifndef SERVER_ONLY
irr_driver->applyObjectPassShader(m_node); irr_driver->applyObjectPassShader(m_node);
if (STKMeshSceneNode *stkm = dynamic_cast<STKMeshSceneNode *>(m_node)) if (STKMeshSceneNode *stkm = dynamic_cast<STKMeshSceneNode *>(m_node))
stkm->setReloadEachFrame(true); stkm->setReloadEachFrame(true);
@ -83,6 +86,7 @@ RubberBand::RubberBand(Plunger *plunger, AbstractKart *kart)
std::string debug_name = m_owner->getIdent()+" (rubber-band)"; std::string debug_name = m_owner->getIdent()+" (rubber-band)";
m_node->setName(debug_name.c_str()); m_node->setName(debug_name.c_str());
#endif #endif
#endif
} // RubberBand } // RubberBand

View File

@ -73,6 +73,7 @@ LocalPlayerController::LocalPlayerController(AbstractKart *kart,
// Attach Particle System // Attach Particle System
Track *track = World::getWorld()->getTrack(); Track *track = World::getWorld()->getTrack();
#ifndef SERVER_ONLY
if (UserConfigParams::m_weather_effects && if (UserConfigParams::m_weather_effects &&
track->getSkyParticles() != NULL) track->getSkyParticles() != NULL)
{ {
@ -88,7 +89,7 @@ LocalPlayerController::LocalPlayerController(AbstractKart *kart,
// of the heightmap being calculated and kept in memory // of the heightmap being calculated and kept in memory
m_sky_particles_emitter->addHeightMapAffector(track); m_sky_particles_emitter->addHeightMapAffector(track);
} }
#endif
} // LocalPlayerController } // LocalPlayerController
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -191,6 +192,7 @@ void LocalPlayerController::update(float dt)
// look backward when the player requests or // look backward when the player requests or
// if automatic reverse camera is active // if automatic reverse camera is active
#ifndef SERVER_ONLY
Camera *camera = Camera::getCamera(m_camera_index); Camera *camera = Camera::getCamera(m_camera_index);
if (camera->getType() != Camera::CM_TYPE_END) if (camera->getType() != Camera::CM_TYPE_END)
{ {
@ -217,7 +219,7 @@ void LocalPlayerController::update(float dt)
} }
} }
} }
#endif
if (m_kart->getKartAnimation() && m_sound_schedule == false && if (m_kart->getKartAnimation() && m_sound_schedule == false &&
m_kart->getAttachment()->getType() != Attachment::ATTACH_TINYTUX) m_kart->getAttachment()->getType() != Attachment::ATTACH_TINYTUX)
{ {
@ -299,8 +301,11 @@ void LocalPlayerController::handleZipper(bool play_sound)
m_wee_sound->play(); m_wee_sound->play();
} }
#ifndef SERVER_ONLY
// Apply the motion blur according to the speed of the kart // Apply the motion blur according to the speed of the kart
irr_driver->giveBoost(m_camera_index); irr_driver->giveBoost(m_camera_index);
#endif
} // handleZipper } // handleZipper
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@ -212,7 +212,11 @@ void Kart::init(RaceManager::KartType type)
} }
#ifdef SERVER_ONLY
bool animations = false; // server never animates
#else
bool animations = true; bool animations = true;
#endif
const int anims = UserConfigParams::m_show_steering_animations; const int anims = UserConfigParams::m_show_steering_animations;
if (anims == ANIMS_NONE) if (anims == ANIMS_NONE)
{ {
@ -333,9 +337,10 @@ void Kart::reset()
m_kart_gfx->reset(); m_kart_gfx->reset();
m_skidding->reset(); m_skidding->reset();
#ifndef SERVER_ONLY
if (m_collision_particles) if (m_collision_particles)
m_collision_particles->setCreationRateAbsolute(0.0f); m_collision_particles->setCreationRateAbsolute(0.0f);
#endif
m_race_position = m_initial_position; m_race_position = m_initial_position;
m_finished_race = false; m_finished_race = false;
@ -2051,6 +2056,7 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
if(m && m->getCollisionReaction() != Material::NORMAL && if(m && m->getCollisionReaction() != Material::NORMAL &&
!getKartAnimation()) !getKartAnimation())
{ {
#ifndef SERVER_ONLY
std::string particles = m->getCrashResetParticles(); std::string particles = m->getCrashResetParticles();
if (particles.size() > 0) if (particles.size() > 0)
{ {
@ -2076,7 +2082,7 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
"crash-reset properties\n", particles.c_str()); "crash-reset properties\n", particles.c_str());
} }
} }
#endif
if (m->getCollisionReaction() == Material::RESCUE) if (m->getCollisionReaction() == Material::RESCUE)
{ {
new RescueAnimation(this); new RescueAnimation(this);
@ -2542,12 +2548,13 @@ void Kart::loadData(RaceManager::KartType type, bool is_animated_model)
track_manager->getTrack(race_manager->getTrackName()) track_manager->getTrack(race_manager->getTrackName())
->isFogEnabled() ); ->isFogEnabled() );
} }
#ifndef SERVER_ONLY
if (!CVS->supportsShadows()) if (!CVS->supportsShadows())
{ {
m_shadow = new Shadow(m_kart_properties.get(), m_node, m_shadow = new Shadow(m_kart_properties.get(), m_node,
-m_kart_model->getLowestPoint()); -m_kart_model->getLowestPoint());
} }
#endif
World::getWorld()->kartAdded(this, m_node); World::getWorld()->kartAdded(this, m_node);
} // loadData } // loadData
@ -2857,6 +2864,7 @@ btQuaternion Kart::getVisualRotation() const
*/ */
void Kart::setOnScreenText(const wchar_t *text) void Kart::setOnScreenText(const wchar_t *text)
{ {
#ifndef SERVER_ONLY
BoldFace* bold_face = font_manager->getFont<BoldFace>(); BoldFace* bold_face = font_manager->getFont<BoldFace>();
core::dimension2d<u32> textsize = bold_face->getDimension(text); core::dimension2d<u32> textsize = bold_face->getDimension(text);
@ -2889,6 +2897,7 @@ void Kart::setOnScreenText(const wchar_t *text)
// No need to store the reference to the billboard scene node: // No need to store the reference to the billboard scene node:
// It has one reference to the parent, and will get deleted // It has one reference to the parent, and will get deleted
// when the parent is deleted. // when the parent is deleted.
#endif
} // setOnScreenText } // setOnScreenText
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------

View File

@ -52,6 +52,7 @@ KartGFX::KartGFX(const AbstractKart *kart)
scene::ISceneNode *node = m_kart->getNode(); scene::ISceneNode *node = m_kart->getNode();
// Create nitro light // Create nitro light
core::vector3df location(0.0f, 0.5f, -0.5f*length - 0.05f); core::vector3df location(0.0f, 0.5f, -0.5f*length - 0.05f);
#ifndef SERVER_ONLY
m_nitro_light = irr_driver->addLight(location, /*force*/ 0.4f, m_nitro_light = irr_driver->addLight(location, /*force*/ 0.4f,
/*radius*/CVS->isGLSL() ? 5.0f : 1.0f, /*radius*/CVS->isGLSL() ? 5.0f : 1.0f,
0.0f, 0.4f, 1.0f, 0.0f, 0.4f, 1.0f,
@ -82,13 +83,16 @@ KartGFX::KartGFX(const AbstractKart *kart)
m_skidding_light_2->setVisible(false); m_skidding_light_2->setVisible(false);
m_skidding_light_2->setName( ("skidding emitter 2 (" + m_kart->getIdent() m_skidding_light_2->setName( ("skidding emitter 2 (" + m_kart->getIdent()
+ ")").c_str() ); + ")").c_str() );
#endif
#ifndef SERVER_ONLY
if (CVS->isGLSL()) if (CVS->isGLSL())
{ {
m_nitro_light->grab(); m_nitro_light->grab();
m_skidding_light_1->grab(); m_skidding_light_1->grab();
m_skidding_light_2->grab(); m_skidding_light_2->grab();
} }
#endif
// Create particle effects // Create particle effects
Vec3 rear_left(kart->getWheelGraphicsPosition(3).getX(), 0.05f, Vec3 rear_left(kart->getWheelGraphicsPosition(3).getX(), 0.05f,
@ -131,13 +135,15 @@ KartGFX::~KartGFX()
if(m_all_emitters[i]) if(m_all_emitters[i])
delete m_all_emitters[i]; delete m_all_emitters[i];
} // for i < KGFX_COUNT } // for i < KGFX_COUNT
#ifndef SERVER_ONLY
if (CVS->isGLSL()) if (CVS->isGLSL())
{ {
m_nitro_light->drop(); m_nitro_light->drop();
m_skidding_light_1->drop(); m_skidding_light_1->drop();
m_skidding_light_2->drop(); m_skidding_light_2->drop();
} }
#endif
} // ~KartGFX } // ~KartGFX
@ -151,6 +157,7 @@ KartGFX::~KartGFX()
void KartGFX::addEffect(KartGFXType type, const std::string &file_name, void KartGFX::addEffect(KartGFXType type, const std::string &file_name,
const Vec3 &position, bool important) const Vec3 &position, bool important)
{ {
#ifndef SERVER_ONLY
if (!UserConfigParams::m_graphical_effects && if (!UserConfigParams::m_graphical_effects &&
(!important || m_kart->getType() == RaceManager::KT_AI || (!important || m_kart->getType() == RaceManager::KT_AI ||
m_kart->getType() == RaceManager::KT_SPARE_TIRE)) m_kart->getType() == RaceManager::KT_SPARE_TIRE))
@ -196,6 +203,7 @@ void KartGFX::addEffect(KartGFXType type, const std::string &file_name,
m_skid_kind1 = kind; m_skid_kind1 = kind;
else if (type==KGFX_SKID2L || type==KGFX_SKID2R) else if (type==KGFX_SKID2L || type==KGFX_SKID2R)
m_skid_kind2 = kind; m_skid_kind2 = kind;
#endif
} // addEffect } // addEffect
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -204,6 +212,7 @@ void KartGFX::addEffect(KartGFXType type, const std::string &file_name,
void KartGFX::reset() void KartGFX::reset()
{ {
m_wheel_toggle = 1; m_wheel_toggle = 1;
#ifndef SERVER_ONLY
for(unsigned int i=0; i<m_all_emitters.size(); i++) for(unsigned int i=0; i<m_all_emitters.size(); i++)
{ {
if(m_all_emitters[i]) if(m_all_emitters[i])
@ -212,6 +221,7 @@ void KartGFX::reset()
m_all_emitters[i]->clearParticles(); m_all_emitters[i]->clearParticles();
} }
} }
#endif
} // reset } // reset
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -224,6 +234,7 @@ void KartGFX::setSkidLevel(const unsigned int level)
assert(level >= 1); assert(level >= 1);
assert(level <= 2); assert(level <= 2);
const ParticleKind *pk = level==1 ? m_skid_kind1 : m_skid_kind2; const ParticleKind *pk = level==1 ? m_skid_kind1 : m_skid_kind2;
#ifndef SERVER_ONLY
if(m_all_emitters[KGFX_SKID1L]) if(m_all_emitters[KGFX_SKID1L])
m_all_emitters[KGFX_SKID1L]->setParticleType(pk); m_all_emitters[KGFX_SKID1L]->setParticleType(pk);
if(m_all_emitters[KGFX_SKID1R]) if(m_all_emitters[KGFX_SKID1R])
@ -232,6 +243,7 @@ void KartGFX::setSkidLevel(const unsigned int level)
// set to indicate that the bonus is now available. // set to indicate that the bonus is now available.
setCreationRateRelative(KartGFX::KGFX_SKIDL, 0.0f); setCreationRateRelative(KartGFX::KGFX_SKIDL, 0.0f);
setCreationRateRelative(KartGFX::KGFX_SKIDR, 0.0f); setCreationRateRelative(KartGFX::KGFX_SKIDR, 0.0f);
#endif
} // setSkidLevel } // setSkidLevel
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -242,10 +254,12 @@ void KartGFX::setSkidLevel(const unsigned int level)
*/ */
void KartGFX::setParticleKind(const KartGFXType type, const ParticleKind *pk) void KartGFX::setParticleKind(const KartGFXType type, const ParticleKind *pk)
{ {
#ifndef SERVER_ONLY
ParticleEmitter *pe = m_all_emitters[KGFX_TERRAIN]; ParticleEmitter *pe = m_all_emitters[KGFX_TERRAIN];
if(!pe) return; if(!pe) return;
pe->setParticleType(pk); pe->setParticleType(pk);
#endif
} // setParticleKind } // setParticleKind
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -255,9 +269,11 @@ void KartGFX::setParticleKind(const KartGFXType type, const ParticleKind *pk)
*/ */
void KartGFX::setXYZ(const KartGFXType type, const Vec3 &xyz) void KartGFX::setXYZ(const KartGFXType type, const Vec3 &xyz)
{ {
#ifndef SERVER_ONLY
ParticleEmitter *pe = m_all_emitters[KGFX_TERRAIN]; ParticleEmitter *pe = m_all_emitters[KGFX_TERRAIN];
if(!pe) return; if(!pe) return;
pe->setPosition(xyz); pe->setPosition(xyz);
#endif
} // setXYZ } // setXYZ
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -268,8 +284,10 @@ void KartGFX::setXYZ(const KartGFXType type, const Vec3 &xyz)
*/ */
void KartGFX::setCreationRateAbsolute(KartGFXType type, float f) void KartGFX::setCreationRateAbsolute(KartGFXType type, float f)
{ {
#ifndef SERVER_ONLY
if(m_all_emitters[type]) if(m_all_emitters[type])
m_all_emitters[type]->setCreationRateAbsolute(f); m_all_emitters[type]->setCreationRateAbsolute(f);
#endif
} // setCreationRateAbsolute } // setCreationRateAbsolute
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -282,6 +300,7 @@ void KartGFX::setCreationRateAbsolute(KartGFXType type, float f)
*/ */
void KartGFX::setCreationRateRelative(KartGFXType type, float f) void KartGFX::setCreationRateRelative(KartGFXType type, float f)
{ {
#ifndef SERVER_ONLY
if(m_all_emitters[type]) if(m_all_emitters[type])
{ {
if(f<0) if(f<0)
@ -289,6 +308,7 @@ void KartGFX::setCreationRateRelative(KartGFXType type, float f)
else else
m_all_emitters[type]->setCreationRateRelative(f); m_all_emitters[type]->setCreationRateRelative(f);
} }
#endif
} // setCreationRateRelative } // setCreationRateRelative
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -301,8 +321,10 @@ void KartGFX::setCreationRateRelative(KartGFXType type, float f)
*/ */
void KartGFX::resizeBox(KartGFXType type, float new_size) void KartGFX::resizeBox(KartGFXType type, float new_size)
{ {
#ifndef SERVER_ONLY
if(m_all_emitters[type]) if(m_all_emitters[type])
m_all_emitters[type]->resizeBox(std::max(0.25f, new_size)); m_all_emitters[type]->resizeBox(std::max(0.25f, new_size));
#endif
} // resizeBox } // resizeBox
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -314,6 +336,7 @@ void KartGFX::resizeBox(KartGFXType type, float new_size)
*/ */
void KartGFX::updateTerrain(const ParticleKind *pk) void KartGFX::updateTerrain(const ParticleKind *pk)
{ {
#ifndef SERVER_ONLY
ParticleEmitter *pe = m_all_emitters[KGFX_TERRAIN]; ParticleEmitter *pe = m_all_emitters[KGFX_TERRAIN];
if(!pe) return; if(!pe) return;
@ -346,6 +369,7 @@ void KartGFX::updateTerrain(const ParticleKind *pk)
// m_skidding can be > 2, and speed > maxSpeed (if powerups are used). // m_skidding can be > 2, and speed > maxSpeed (if powerups are used).
if(rate>1.0f) rate = 1.0f; if(rate>1.0f) rate = 1.0f;
pe->setCreationRateRelative(rate); pe->setCreationRateRelative(rate);
#endif
} // updateTerrain } // updateTerrain
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -370,6 +394,7 @@ void KartGFX::update(float dt)
*/ */
void KartGFX::updateNitroGraphics(float nitro_frac) void KartGFX::updateNitroGraphics(float nitro_frac)
{ {
#ifndef SERVER_ONLY
// Upate particle effects (creation rate, and emitter size // Upate particle effects (creation rate, and emitter size
// depending on speed) // depending on speed)
// -------------------------------------------------------- // --------------------------------------------------------
@ -389,7 +414,7 @@ void KartGFX::updateNitroGraphics(float nitro_frac)
setCreationRateAbsolute(KartGFX::KGFX_NITROSMOKE2, 0); setCreationRateAbsolute(KartGFX::KGFX_NITROSMOKE2, 0);
m_nitro_light->setVisible(false); m_nitro_light->setVisible(false);
} }
#endif
} // updateGraphics } // updateGraphics
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -399,14 +424,17 @@ void KartGFX::updateNitroGraphics(float nitro_frac)
*/ */
void KartGFX::updateSkidLight(unsigned int level) void KartGFX::updateSkidLight(unsigned int level)
{ {
#ifndef SERVER_ONLY
m_skidding_light_1->setVisible(level == 1); m_skidding_light_1->setVisible(level == 1);
m_skidding_light_2->setVisible(level > 1); m_skidding_light_2->setVisible(level > 1);
#endif
} // updateSkidLight } // updateSkidLight
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void KartGFX::getGFXStatus(int* nitro, bool* zipper, void KartGFX::getGFXStatus(int* nitro, bool* zipper,
int* skidding, bool* red_skidding) const int* skidding, bool* red_skidding) const
{ {
#ifndef SERVER_ONLY
int n = 0; int n = 0;
bool z = false; bool z = false;
int s = 0; int s = 0;
@ -432,13 +460,14 @@ void KartGFX::getGFXStatus(int* nitro, bool* zipper,
*zipper = z; *zipper = z;
*skidding = s; *skidding = s;
*red_skidding = r; *red_skidding = r;
#endif
} // getGFXStatus } // getGFXStatus
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void KartGFX::setGFXFromReplay(int nitro, bool zipper, void KartGFX::setGFXFromReplay(int nitro, bool zipper,
int skidding, bool red_skidding) int skidding, bool red_skidding)
{ {
#ifndef SERVER_ONLY
if (nitro > 0) if (nitro > 0)
{ {
setCreationRateAbsolute(KartGFX::KGFX_NITRO1, (float)nitro); setCreationRateAbsolute(KartGFX::KGFX_NITRO1, (float)nitro);
@ -492,12 +521,15 @@ void KartGFX::setGFXFromReplay(int nitro, bool zipper,
m_skidding_light_1->setVisible(false); m_skidding_light_1->setVisible(false);
m_skidding_light_2->setVisible(false); m_skidding_light_2->setVisible(false);
} }
#endif
} // setGFXFromReplay } // setGFXFromReplay
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void KartGFX::setGFXInvisible() void KartGFX::setGFXInvisible()
{ {
#ifndef SERVER_ONLY
m_nitro_light->setVisible(false); m_nitro_light->setVisible(false);
m_skidding_light_1->setVisible(false); m_skidding_light_1->setVisible(false);
m_skidding_light_2->setVisible(false); m_skidding_light_2->setVisible(false);
#endif
} // setGFXInvisible } // setGFXInvisible

View File

@ -357,6 +357,7 @@ scene::ISceneNode* KartModel::attachModel(bool animated_models, bool always_anim
irr_driver->getSceneManager()->getRootSceneNode(), irr_driver->getSceneManager()->getRootSceneNode(),
irr_driver->getSceneManager() ); irr_driver->getSceneManager() );
#ifndef SERVER_ONLY
node = irr_driver->addAnimatedMesh(m_mesh, "kartmesh", node = irr_driver->addAnimatedMesh(m_mesh, "kartmesh",
NULL/*parent*/, getRenderInfo()); NULL/*parent*/, getRenderInfo());
@ -365,7 +366,7 @@ scene::ISceneNode* KartModel::attachModel(bool animated_models, bool always_anim
node->setAutomaticCulling(scene::EAC_OFF); node->setAutomaticCulling(scene::EAC_OFF);
else else
node->setAutomaticCulling(scene::EAC_FRUSTUM_BOX); node->setAutomaticCulling(scene::EAC_FRUSTUM_BOX);
#endif
if (always_animated) if (always_animated)
{ {
// give a huge LOD distance for the player's kart. the reason is that it should // give a huge LOD distance for the player's kart. the reason is that it should
@ -409,7 +410,7 @@ scene::ISceneNode* KartModel::attachModel(bool animated_models, bool always_anim
if(!m_speed_weighted_objects[i].m_node) continue; if(!m_speed_weighted_objects[i].m_node) continue;
m_speed_weighted_objects[i].m_node->setParent(lod_node); m_speed_weighted_objects[i].m_node->setParent(lod_node);
} }
#ifndef SERVER_ONLY
// Enable rim lighting for the kart // Enable rim lighting for the kart
irr_driver->applyObjectPassShader(lod_node, true); irr_driver->applyObjectPassShader(lod_node, true);
std::vector<scene::ISceneNode*> &lodnodes = lod_node->getAllNodes(); std::vector<scene::ISceneNode*> &lodnodes = lod_node->getAllNodes();
@ -418,6 +419,7 @@ scene::ISceneNode* KartModel::attachModel(bool animated_models, bool always_anim
{ {
irr_driver->applyObjectPassShader(lodnodes[i], true); irr_driver->applyObjectPassShader(lodnodes[i], true);
} }
#endif
} }
else else
{ {
@ -428,12 +430,13 @@ scene::ISceneNode* KartModel::attachModel(bool animated_models, bool always_anim
: 0; : 0;
scene::IMesh* main_frame = m_mesh; scene::IMesh* main_frame = m_mesh;
#ifndef SERVER_ONLY
if (!CVS->isGLSL()) if (!CVS->isGLSL())
{ {
main_frame = m_mesh->getMesh(straight_frame); main_frame = m_mesh->getMesh(straight_frame);
main_frame->setHardwareMappingHint(scene::EHM_STATIC); main_frame->setHardwareMappingHint(scene::EHM_STATIC);
} }
#endif
std::string debug_name; std::string debug_name;
#ifdef DEBUG #ifdef DEBUG
@ -510,12 +513,13 @@ bool KartModel::loadModels(const KartProperties &kart_properties)
return false; return false;
} }
#ifndef SERVER_ONLY
scene::ISkinnedMesh* sm = dynamic_cast<scene::ISkinnedMesh*>(m_mesh); scene::ISkinnedMesh* sm = dynamic_cast<scene::ISkinnedMesh*>(m_mesh);
if (sm) if (sm)
{ {
MeshTools::createSkinnedMeshWithTangents(sm, &MeshTools::isNormalMap); MeshTools::createSkinnedMeshWithTangents(sm, &MeshTools::isNormalMap);
} }
#endif
m_mesh->grab(); m_mesh->grab();
irr_driver->grabAllTextures(m_mesh); irr_driver->grabAllTextures(m_mesh);
@ -564,7 +568,7 @@ bool KartModel::loadModels(const KartProperties &kart_properties)
// Grab all textures. This is done for the master only, so // Grab all textures. This is done for the master only, so
// the destructor will only free the textures if a master // the destructor will only free the textures if a master
// copy is freed. // copy is freed.
#ifndef SERVER_ONLY
scene::ISkinnedMesh* sm = scene::ISkinnedMesh* sm =
dynamic_cast<scene::ISkinnedMesh*>(obj.m_model); dynamic_cast<scene::ISkinnedMesh*>(obj.m_model);
if (sm) if (sm)
@ -573,7 +577,7 @@ bool KartModel::loadModels(const KartProperties &kart_properties)
&MeshTools::isNormalMap); &MeshTools::isNormalMap);
} }
irr_driver->grabAllTextures(obj.m_model); irr_driver->grabAllTextures(obj.m_model);
#endif
// Update min/max // Update min/max
Vec3 obj_min, obj_max; Vec3 obj_min, obj_max;
MeshTools::minMax3D(obj.m_model, &obj_min, &obj_max); MeshTools::minMax3D(obj.m_model, &obj_min, &obj_max);
@ -614,8 +618,10 @@ bool KartModel::loadModels(const KartProperties &kart_properties)
std::string full_wheel = std::string full_wheel =
kart_properties.getKartDir()+m_wheel_filename[i]; kart_properties.getKartDir()+m_wheel_filename[i];
m_wheel_model[i] = irr_driver->getMesh(full_wheel); m_wheel_model[i] = irr_driver->getMesh(full_wheel);
#ifndef SERVER_ONLY
m_wheel_model[i] = MeshTools::createMeshWithTangents(m_wheel_model[i], m_wheel_model[i] = MeshTools::createMeshWithTangents(m_wheel_model[i],
&MeshTools::isNormalMap); &MeshTools::isNormalMap);
#endif
// Grab all textures. This is done for the master only, so // Grab all textures. This is done for the master only, so
// the destructor will only free the textures if a master // the destructor will only free the textures if a master
// copy is freed. // copy is freed.

View File

@ -249,10 +249,12 @@ void KartProperties::load(const std::string &filename, const std::string &node)
else else
m_minimap_icon = NULL; m_minimap_icon = NULL;
#ifndef SERVER_ONLY
if (m_minimap_icon == NULL) if (m_minimap_icon == NULL)
{ {
m_minimap_icon = getUnicolorTexture(m_color); m_minimap_icon = getUnicolorTexture(m_color);
} }
#endif
// Only load the model if the .kart file has the appropriate version, // Only load the model if the .kart file has the appropriate version,
// otherwise warnings are printed. // otherwise warnings are printed.

View File

@ -66,6 +66,7 @@ void Moveable::setNode(scene::ISceneNode *n)
void Moveable::updateGraphics(float dt, const Vec3& offset_xyz, void Moveable::updateGraphics(float dt, const Vec3& offset_xyz,
const btQuaternion& rotation) const btQuaternion& rotation)
{ {
#ifndef SERVER_ONLY
Vec3 xyz=getXYZ()+offset_xyz; Vec3 xyz=getXYZ()+offset_xyz;
m_node->setPosition(xyz.toIrrVector()); m_node->setPosition(xyz.toIrrVector());
btQuaternion r_all = getRotation()*rotation; btQuaternion r_all = getRotation()*rotation;
@ -75,6 +76,7 @@ void Moveable::updateGraphics(float dt, const Vec3& offset_xyz,
Vec3 hpr; Vec3 hpr;
hpr.setHPR(r_all); hpr.setHPR(r_all);
m_node->setRotation(hpr.toIrrHPR()); m_node->setRotation(hpr.toIrrHPR());
#endif
} // updateGraphics } // updateGraphics
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@ -60,8 +60,8 @@
physics -> audio physics -> audio
"translations\n(too many connections\nto draw)" "translations\n(too many connections\nto draw)"
"configuration\n(too many connections\nto draw)" "configuration\n(too many connections\nto draw)"
# addons -> tracks addons -> tracks
# addons -> karts addons -> karts
guiengine -> addons guiengine -> addons
guiengine -> race guiengine -> race
addons -> online_manager addons -> online_manager
@ -222,6 +222,7 @@
#include "replay/replay_play.hpp" #include "replay/replay_play.hpp"
#include "replay/replay_recorder.hpp" #include "replay/replay_recorder.hpp"
#include "states_screens/main_menu_screen.hpp" #include "states_screens/main_menu_screen.hpp"
#include "states_screens/networking_lobby.hpp"
#include "states_screens/register_screen.hpp" #include "states_screens/register_screen.hpp"
#include "states_screens/state_manager.hpp" #include "states_screens/state_manager.hpp"
#include "states_screens/user_screen.hpp" #include "states_screens/user_screen.hpp"
@ -572,8 +573,10 @@ void cmdLineHelp()
// " (so n=1 means all Ais will be the test ai)\n" // " (so n=1 means all Ais will be the test ai)\n"
// " // "
" --server=name Start a server (not a playing client).\n" " --server=name Start a server (not a playing client).\n"
" --public-server Allow direct connection to the server (without stk server)\n"
" --lan-server=name Start a LAN server (not a playing client).\n" " --lan-server=name Start a LAN server (not a playing client).\n"
" --server-password= Sets a password for a server (both client&server).\n" " --server-password= Sets a password for a server (both client&server).\n"
" --connect-now=ip Connect to a server with IP known now (in format x.x.x.x:xxx(port)).\n"
" --login=s Automatically log in (set the login).\n" " --login=s Automatically log in (set the login).\n"
" --password=s Automatically log in (set the password).\n" " --password=s Automatically log in (set the password).\n"
" --port=n Port number to use.\n" " --port=n Port number to use.\n"
@ -978,6 +981,34 @@ int handleCmdLine()
// Networking command lines // Networking command lines
NetworkConfig::get()-> NetworkConfig::get()->
setMaxPlayers(UserConfigParams::m_server_max_players); setMaxPlayers(UserConfigParams::m_server_max_players);
if (CommandLine::has("--port", &n))
{
// We don't know if this instance is going to be a client
// or server, so just set both ports, only one will be used anyway
NetworkConfig::get()->setClientPort(n);
NetworkConfig::get()->setServerPort(n);
}
if (CommandLine::has("--public-server"))
{
NetworkConfig::get()->setIsPublicServer();
}
if (CommandLine::has("--connect-now", &s))
{
TransportAddress ip(s);
TransportAddress me(2130706433/*127.0.0.1*/,
NetworkConfig::get()->getServerDiscoveryPort() );
NetworkConfig::get()->setIsLAN();
NetworkConfig::get()->setIsServer(false);
NetworkConfig::get()->setMyAddress(me);
Log::info("main", "Try to connect to server '%s'.",
ip.toString().c_str() );
irr::core::stringw name = StringUtils::utf8ToWide(ip.toString());
ServersManager::get()->addServer(new Server(name, /*lan*/true,
16, 0, ip));
ServersManager::get()->setJoinedServer(0);
STKHost::create();
}
if(CommandLine::has("--server", &s)) if(CommandLine::has("--server", &s))
{ {
NetworkConfig::get()->setServerName(core::stringw(s.c_str())); NetworkConfig::get()->setServerName(core::stringw(s.c_str()));
@ -1613,6 +1644,7 @@ int main(int argc, char *argv[] )
} }
Log::warn("OpenGL", "Driver is too old!"); Log::warn("OpenGL", "Driver is too old!");
} }
#ifndef SERVER_ONLY
else if (!CVS->isGLSL()) else if (!CVS->isGLSL())
{ {
if (UserConfigParams::m_old_driver_popup) if (UserConfigParams::m_old_driver_popup)
@ -1631,7 +1663,7 @@ int main(int argc, char *argv[] )
} }
Log::warn("OpenGL", "OpenGL version is too old!"); Log::warn("OpenGL", "OpenGL version is too old!");
} }
#endif
// Note that on the very first run of STK internet status is set to // Note that on the very first run of STK internet status is set to
// "not asked", so the report will only be sent in the next run. // "not asked", so the report will only be sent in the next run.
if(UserConfigParams::m_internet_status==Online::RequestManager::IPERM_ALLOWED) if(UserConfigParams::m_internet_status==Online::RequestManager::IPERM_ALLOWED)
@ -1639,7 +1671,13 @@ int main(int argc, char *argv[] )
HardwareStats::reportHardwareStats(); HardwareStats::reportHardwareStats();
} }
if(!UserConfigParams::m_no_start_screen) // This can only be the case if --connect-now was used, which adds
// a server to the server list.
if (ServersManager::get()->getNumServers()==1)
{
NetworkingLobby::getInstance()->push();
}
else if (!UserConfigParams::m_no_start_screen)
{ {
// If there is a current player, it was saved in the config file, // If there is a current player, it was saved in the config file,
// so we immediately start the main menu (unless it was requested // so we immediately start the main menu (unless it was requested
@ -1894,6 +1932,8 @@ void runUnitTests()
GraphicsRestrictions::unitTesting(); GraphicsRestrictions::unitTesting();
Log::info("UnitTest", "NetworkString"); Log::info("UnitTest", "NetworkString");
NetworkString::unitTesting(); NetworkString::unitTesting();
Log::info("UnitTest", "TransportAddress");
TransportAddress::unitTesting();
Log::info("UnitTest", "Easter detection"); Log::info("UnitTest", "Easter detection");
// Test easter mode: in 2015 Easter is 5th of April - check with 0 days // Test easter mode: in 2015 Easter is 5th of April - check with 0 days

View File

@ -320,6 +320,7 @@ void SoccerWorld::countdownReachedZero()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void SoccerWorld::initKartList() void SoccerWorld::initKartList()
{ {
#ifndef SERVER_ONLY
const unsigned int kart_amount = (unsigned int)m_karts.size(); const unsigned int kart_amount = (unsigned int)m_karts.size();
//Loading the indicator textures //Loading the indicator textures
@ -340,13 +341,14 @@ void SoccerWorld::initKartList()
float arrow_pos_height = km->getHeight() + 0.5f; float arrow_pos_height = km->getHeight() + 0.5f;
SoccerTeam team = getKartTeam(i); SoccerTeam team = getKartTeam(i);
arrow_node = irr_driver->addBillboard(core::dimension2d<irr::f32>(0.3f, arrow_node = irr_driver->addBillboard(
0.3f), team == SOCCER_TEAM_BLUE ? blue : red, m_karts[i] core::dimension2d<irr::f32>(0.3f,0.3f),
->getNode(), true); team == SOCCER_TEAM_BLUE ? blue : red,
m_karts[i]->getNode(), true);
arrow_node->setPosition(core::vector3df(0, arrow_pos_height, 0)); arrow_node->setPosition(core::vector3df(0, arrow_pos_height, 0));
} }
#endif
} // initKartList } // initKartList
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@ -224,8 +224,10 @@ void World::init()
// Load other custom models if needed // Load other custom models if needed
loadCustomModels(); loadCustomModels();
#ifndef SERVER_ONLY
// Now that all models are loaded, apply the overrides // Now that all models are loaded, apply the overrides
irr_driver->applyObjectPassShader(); irr_driver->applyObjectPassShader();
#endif
// Must be called after all karts are created // Must be called after all karts are created
m_race_gui->init(); m_race_gui->init();

View File

@ -28,6 +28,8 @@
#include "karts/abstract_kart.hpp" #include "karts/abstract_kart.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "network/network_config.hpp" #include "network/network_config.hpp"
#include "network/protocols/client_lobby.hpp"
#include "network/protocols/server_lobby.hpp"
#include "network/race_event_manager.hpp" #include "network/race_event_manager.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
@ -51,7 +53,6 @@ WorldStatus::WorldStatus()
if (device->getTimer()->isStopped()) if (device->getTimer()->isStopped())
device->getTimer()->start(); device->getTimer()->start();
m_ready_to_race = false;
} // WorldStatus } // WorldStatus
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -93,9 +94,9 @@ void WorldStatus::reset()
// Set the right music // Set the right music
World::getWorld()->getTrack()->startMusic(); World::getWorld()->getTrack()->startMusic();
// In case of a networked race the race can only start once // In case of a networked race the race can only start once
// all protocols are up. This flag waits for that, and is // all protocols are up. This flag is used to wait for
// set by // a confirmation before starting the actual race.
m_ready_to_race = !NetworkConfig::get()->isNetworking(); m_server_is_ready = false;
} // reset } // reset
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -179,10 +180,6 @@ void WorldStatus::update(float dt)
*/ */
void WorldStatus::updateTime(const float dt) void WorldStatus::updateTime(const float dt)
{ {
// In case of a networked race wait till all necessary protocols are
// ready before progressing the timer
if (!m_ready_to_race) return;
switch (m_phase) switch (m_phase)
{ {
// Note: setup phase must be a separate phase, since the race_manager // Note: setup phase must be a separate phase, since the race_manager
@ -243,35 +240,34 @@ void WorldStatus::updateTime(const float dt)
m_prestart_sound->play(); m_prestart_sound->play();
// In a networked game the client needs to wait for a notification // In a networked game the client needs to wait for a notification
// from the server that ready-set-go can start now. So client will go // from the server that all clients and the server are ready to
// to the 'wait_for_server_phase', from which they will progress once // start the game. The server will actually wait for all clients
// the notification is received. In all other cases (no networking or // to confirm that they have started the race before starting
// server), immediately go to race start // itself. In a normal race, this phase is skipped and the race
if(!NetworkConfig::get()->isNetworking() || // starts immediately.
NetworkConfig::get()->isServer() ) m_phase = NetworkConfig::get()->isNetworking() ? WAIT_FOR_SERVER_PHASE
{ : READY_PHASE;
// Notify the clients that they can start ready-set-go
if(NetworkConfig::get()->isServer())
RaceEventManager::getInstance()->startReadySetGo();
m_server_is_ready = true;
} // if not networked
m_phase = WAIT_FOR_SERVER_PHASE;
return; // Don't increase time return; // Don't increase time
case WAIT_FOR_SERVER_PHASE: case WAIT_FOR_SERVER_PHASE:
// On a client this phase waits for the server to be ready. On a {
// server or in case of non-networked game this phase is reached // This stage is only reached in case of a networked game.
// with m_server_is_ready set to true, so it will immediately // A client waits for a message from the server that it can
// start the engines and then the race // start the race (i.e. that all clients and the server have
if(!m_server_is_ready) return; // loaded the world). The server waits for a confirmation from
// each client that they have started (to guarantee that the
// server is running with a local time behind all clients).
if (!m_server_is_ready) return;
m_phase = READY_PHASE; m_phase = READY_PHASE;
Protocol *p = LobbyProtocol::get();
ClientLobby *cl = dynamic_cast<ClientLobby*>(p);
if (cl)
cl->startingRaceNow();
return; // Don't increase time
}
case READY_PHASE:
startEngines(); startEngines();
// Receiving a 'startReadySetGo' message from the server triggers
// a call to startReadySetGo() here, which will change the phase
// (or state) of the finite state machine.
return; // Don't increase time
case READY_PHASE:
if (m_auxiliary_timer > 1.0) if (m_auxiliary_timer > 1.0)
{ {
if (m_play_ready_set_go_sounds) if (m_play_ready_set_go_sounds)
@ -432,8 +428,11 @@ void WorldStatus::updateTime(const float dt)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** Called on the client when it receives a notification from the server that /** Called on the client when it receives a notification from the server that
* the server is now starting its ready-set-go phase. This function changes * all clients (and server) are ready to start the race. The server will
* the state of the finite state machine to be ready. * then additionally wait for all clients to report back that they are
* starting, which guarantees that the server is running far enough behind
* clients time that at server time T all events from the clients at time
* T have arrived, minimising rollback impact.
*/ */
void WorldStatus::startReadySetGo() void WorldStatus::startReadySetGo()
{ {

View File

@ -94,9 +94,6 @@ protected:
/** If the start race should be played, disabled in cutscenes. */ /** If the start race should be played, disabled in cutscenes. */
bool m_play_racestart_sounds; bool m_play_racestart_sounds;
/** A flag that causes the world to wait in case of a networking race
* till all protocols are up and running. */
bool m_ready_to_race;
private: private:
/** Sound to play at the beginning of a race, during which a /** Sound to play at the beginning of a race, during which a
* a camera intro of the track can be shown. */ * a camera intro of the track can be shown. */
@ -130,10 +127,10 @@ private:
bool m_engines_started; bool m_engines_started;
void startEngines(); void startEngines();
/** In networked game the client must wait for the server to start 'ready set go' /** In networked game a client must wait for the server to start 'ready
* (to guarantee that the client's time is not ahead of the server), This flag * set go' to make sure all client are actually ready to start the game.
* indicates that the notification from the server was received, and that the * A server on the other hand will run behind all clients, so it will
* client can go to 'ready' phase. */ * wait for all clients to indicate that they have started the race. */
bool m_server_is_ready; bool m_server_is_ready;
public: public:
@ -198,7 +195,7 @@ public:
/** Get the time since start regardless of which way the clock counts */ /** Get the time since start regardless of which way the clock counts */
float getTimeSinceStart() const { return m_count_up_timer; } float getTimeSinceStart() const { return m_count_up_timer; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
void setReadyToRace() { m_ready_to_race = true; } void setReadyToRace() { m_server_is_ready = true; }
}; // WorldStatus }; // WorldStatus

View File

@ -37,6 +37,7 @@ NetworkConfig::NetworkConfig()
{ {
m_network_type = NETWORK_NONE; m_network_type = NETWORK_NONE;
m_is_server = false; m_is_server = false;
m_is_public_server = false;
m_max_players = 4; m_max_players = 4;
m_is_registered = false; m_is_registered = false;
m_server_name = ""; m_server_name = "";

View File

@ -34,11 +34,18 @@ private:
static NetworkConfig *m_network_config; static NetworkConfig *m_network_config;
enum NetworkType enum NetworkType
{ NETWORK_NONE, NETWORK_WAN, NETWORK_LAN }; {
NETWORK_NONE, NETWORK_WAN, NETWORK_LAN
};
/** Keeps the type of network connection: none (yet), LAN or WAN. */ /** Keeps the type of network connection: none (yet), LAN or WAN. */
NetworkType m_network_type; NetworkType m_network_type;
/** If set it allows clients to connect directly to this server without
* using the stk server in between. It requires obviously that this
* server is accessible (through the firewall) from the outside. */
bool m_is_public_server;
/** True if this host is a server, false otherwise. */ /** True if this host is a server, false otherwise. */
bool m_is_server; bool m_is_server;
@ -79,7 +86,7 @@ public:
/** Singleton get, which creates this object if necessary. */ /** Singleton get, which creates this object if necessary. */
static NetworkConfig *get() static NetworkConfig *get()
{ {
if(!m_network_config) if (!m_network_config)
m_network_config = new NetworkConfig(); m_network_config = new NetworkConfig();
return m_network_config; return m_network_config;
} // get } // get
@ -102,19 +109,19 @@ public:
} // setServerDiscoveryPort } // setServerDiscoveryPort
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Sets the port on which this server listens. */ /** Sets the port on which this server listens. */
void setServerPort(uint16_t port) { m_server_port = port; } void setServerPort(uint16_t port) { m_server_port = port; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Sets the port on which a client listens for server connection. */ /** Sets the port on which a client listens for server connection. */
void setClientPort(uint16_t port) { m_client_port = port; } void setClientPort(uint16_t port) { m_client_port = port; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the port on which this server listenes. */ /** Returns the port on which this server listenes. */
uint16_t getServerPort() const { return m_server_port; } uint16_t getServerPort() const { return m_server_port; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the port for LAN server discovery. */ /** Returns the port for LAN server discovery. */
uint16_t getServerDiscoveryPort() const { return m_server_discovery_port; } uint16_t getServerDiscoveryPort() const { return m_server_discovery_port; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the port on which a client listens for server connections. */ /** Returns the port on which a client listens for server connections. */
uint16_t getClientPort() const { return m_client_port; } uint16_t getClientPort() const { return m_client_port; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Sets the password for a server. */ /** Sets the password for a server. */
void setPassword(const std::string &password) { m_password = password; } void setPassword(const std::string &password) { m_password = password; }
@ -122,6 +129,12 @@ public:
/** Returns the password. */ /** Returns the password. */
const std::string& getPassword() const { return m_password; } const std::string& getPassword() const { return m_password; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Sets that this server can be contacted directly. */
void setIsPublicServer() { m_is_public_server = true; }
// ------------------------------------------------------------------------
/** Returns if connections directly to the server are to be accepted. */
bool isPublicServer() const { return m_is_public_server; }
// ------------------------------------------------------------------------
/** Return if a network setting is happening. A network setting is active /** Return if a network setting is happening. A network setting is active
* if a host (server or client) exists. */ * if a host (server or client) exists. */
bool isNetworking() const { return m_network_type!=NETWORK_NONE; } bool isNetworking() const { return m_network_type!=NETWORK_NONE; }

View File

@ -21,10 +21,9 @@
#include "main_loop.hpp" #include "main_loop.hpp"
#include "network/network_config.hpp" #include "network/network_config.hpp"
#include "network/network_player_profile.hpp" #include "network/network_player_profile.hpp"
#include "network/protocol_manager.hpp"
#include "network/stk_host.hpp" #include "network/stk_host.hpp"
#include "network/protocols/client_lobby_room_protocol.hpp" #include "network/protocols/client_lobby.hpp"
#include "network/protocols/server_lobby_room_protocol.hpp" #include "network/protocols/server_lobby.hpp"
#include "network/protocols/stop_server.hpp" #include "network/protocols/stop_server.hpp"
#include "network/stk_peer.hpp" #include "network/stk_peer.hpp"
#include "utils/log.hpp" #include "utils/log.hpp"
@ -79,27 +78,23 @@ void* NetworkConsole::mainLoop(void* data)
} }
else if (str == "start" && NetworkConfig::get()->isServer()) else if (str == "start" && NetworkConfig::get()->isServer())
{ {
ServerLobbyRoomProtocol* protocol = ServerLobby* protocol =
static_cast<ServerLobbyRoomProtocol*> dynamic_cast<ServerLobby*>(LobbyProtocol::get());
(ProtocolManager::getInstance()->getProtocol(PROTOCOL_LOBBY_ROOM)); protocol->signalRaceStartToClients();
assert(protocol);
protocol->startGame();
} }
else if (str == "selection" && NetworkConfig::get()->isServer()) else if (str == "selection" && NetworkConfig::get()->isServer())
{ {
ServerLobbyRoomProtocol* protocol = ServerLobby* protocol =
static_cast<ServerLobbyRoomProtocol*> dynamic_cast<ServerLobby*>(LobbyProtocol::get());
(ProtocolManager::getInstance()->getProtocol(PROTOCOL_LOBBY_ROOM));
assert(protocol);
protocol->startSelection(); protocol->startSelection();
} }
else if (str == "select" && NetworkConfig::get()->isClient()) else if (str == "select" && NetworkConfig::get()->isClient())
{ {
std::string str2; std::string str2;
getline(std::cin, str2); getline(std::cin, str2);
Protocol* protocol = ServerLobby* protocol =
ProtocolManager::getInstance()->getProtocol(PROTOCOL_LOBBY_ROOM); dynamic_cast<ServerLobby*>(LobbyProtocol::get());
ClientLobbyRoomProtocol* clrp = static_cast<ClientLobbyRoomProtocol*>(protocol); ClientLobby* clrp = dynamic_cast<ClientLobby*>(protocol);
std::vector<NetworkPlayerProfile*> players = std::vector<NetworkPlayerProfile*> players =
STKHost::get()->getMyPlayerProfiles(); STKHost::get()->getMyPlayerProfiles();
// For now send a vote for each local player // For now send a vote for each local player
@ -114,10 +109,9 @@ void* NetworkConsole::mainLoop(void* data)
std::cout << "Vote for ? (track/laps/reversed/major/minor/race#) :"; std::cout << "Vote for ? (track/laps/reversed/major/minor/race#) :";
std::string str2; std::string str2;
getline(std::cin, str2); getline(std::cin, str2);
Protocol* protocol = ProtocolManager::getInstance() LobbyProtocol* protocol = LobbyProtocol::get();
->getProtocol(PROTOCOL_LOBBY_ROOM); ClientLobby* clrp =
ClientLobbyRoomProtocol* clrp = dynamic_cast<ClientLobby*>(protocol);
static_cast<ClientLobbyRoomProtocol*>(protocol);
std::vector<NetworkPlayerProfile*> players = std::vector<NetworkPlayerProfile*> players =
STKHost::get()->getMyPlayerProfiles(); STKHost::get()->getMyPlayerProfiles();
if (str2 == "track") if (str2 == "track")

View File

@ -118,8 +118,7 @@ void Protocol::findAndTerminateProtocol(ProtocolType type)
if (protocol) if (protocol)
protocol->requestTerminate(); protocol->requestTerminate();
else else
Log::error("ClientLobbyRoomProtocol", Log::error("Protocol", "No protocol %d registered.", type);
"No protocol %d registered.", type);
} // findAndTerminateProtocol } // findAndTerminateProtocol
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -16,15 +16,15 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "network/protocols/client_lobby_room_protocol.hpp" #include "network/protocols/client_lobby.hpp"
#include "config/player_manager.hpp" #include "config/player_manager.hpp"
#include "modes/world_with_rank.hpp" #include "modes/world_with_rank.hpp"
#include "network/event.hpp" #include "network/event.hpp"
#include "network/network_config.hpp" #include "network/network_config.hpp"
#include "network/network_player_profile.hpp" #include "network/network_player_profile.hpp"
#include "network/protocols/start_game_protocol.hpp"
#include "network/protocol_manager.hpp" #include "network/protocol_manager.hpp"
#include "network/protocols/latency_protocol.hpp"
#include "network/race_event_manager.hpp" #include "network/race_event_manager.hpp"
#include "network/stk_host.hpp" #include "network/stk_host.hpp"
#include "network/stk_peer.hpp" #include "network/stk_peer.hpp"
@ -35,26 +35,52 @@
#include "states_screens/state_manager.hpp" #include "states_screens/state_manager.hpp"
#include "utils/log.hpp" #include "utils/log.hpp"
ClientLobbyRoomProtocol:: // ============================================================================
ClientLobbyRoomProtocol(const TransportAddress& server_address) /** The protocol that manages starting a race with the server. It uses a
: LobbyRoomProtocol(NULL) * finite state machine:
\dot
digraph interaction {
"NONE" -> "LINKED" [label="ENet connection with server established"]
"LINKED" -> "REQUESTING_CONNECTION" [label="Request connection from server"]
"REQUESTING_CONNECTION" -> CONNECTED [label="Connection accepted by server"]
"REQUESTING_CONNECTION" -> "?? TO BE DONE ??" [label="Connection refused by server"]
"CONNECTED" -> "KART_SELECTION" [label="Server tells us to start kart selection"]
"KART_SELECTION" -> "SELECTING_KARTS" [label="Show kart selection screen"]
"SELECTING_KARTS" -> "PLAYING" [label="Server sends start race message"]
}
\enddot
Note that some states are actually managed outside of the client lobby. For
example to select race details after selecting a kart is managed by the GUI
engine.
*/
ClientLobby::ClientLobby() : LobbyProtocol(NULL)
{ {
m_server_address.copy(server_address);
m_server_address.clear();
m_server = NULL; m_server = NULL;
setHandleDisconnections(true); setHandleDisconnections(true);
} // ClientLobbyRoomProtocol } // ClientLobby
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
ClientLobbyRoomProtocol::~ClientLobbyRoomProtocol() ClientLobby::~ClientLobby()
{ {
} // ClientLobbyRoomProtocol } // ClientLobby
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** Sets the address of the server.
void ClientLobbyRoomProtocol::setup() */
void ClientLobby::setAddress(const TransportAddress &address)
{ {
m_setup = STKHost::get()->setupNewGame(); // create a new setup m_server_address.copy(address);
} // setAddress
//-----------------------------------------------------------------------------
void ClientLobby::setup()
{
m_game_setup = STKHost::get()->setupNewGame(); // create a new game setup
m_state = NONE; m_state = NONE;
} // setup } // setup
@ -63,8 +89,8 @@ void ClientLobbyRoomProtocol::setup()
* \param player_id The global player id of the voting player. * \param player_id The global player id of the voting player.
* \param kart_name Name of the selected kart. * \param kart_name Name of the selected kart.
*/ */
void ClientLobbyRoomProtocol::requestKartSelection(uint8_t player_id, void ClientLobby::requestKartSelection(uint8_t player_id,
const std::string &kart_name) const std::string &kart_name)
{ {
NetworkString *request = getNetworkString(3+kart_name.size()); NetworkString *request = getNetworkString(3+kart_name.size());
request->addUInt8(LE_KART_SELECTION).addUInt8(player_id) request->addUInt8(LE_KART_SELECTION).addUInt8(player_id)
@ -80,7 +106,7 @@ void ClientLobbyRoomProtocol::requestKartSelection(uint8_t player_id,
* \param player_id The global player id of the voting player. * \param player_id The global player id of the voting player.
* \param major Major mode voted for. * \param major Major mode voted for.
*/ */
void ClientLobbyRoomProtocol::voteMajor(uint8_t player_id, uint32_t major) void ClientLobby::voteMajor(uint8_t player_id, uint32_t major)
{ {
NetworkString *request = getNetworkString(6); NetworkString *request = getNetworkString(6);
request->addUInt8(LE_VOTE_MAJOR).addUInt8(player_id) request->addUInt8(LE_VOTE_MAJOR).addUInt8(player_id)
@ -96,7 +122,7 @@ void ClientLobbyRoomProtocol::voteMajor(uint8_t player_id, uint32_t major)
* \param player_id The global player id of the voting player. * \param player_id The global player id of the voting player.
* \param count NUmber of tracks to play. * \param count NUmber of tracks to play.
*/ */
void ClientLobbyRoomProtocol::voteRaceCount(uint8_t player_id, uint8_t count) void ClientLobby::voteRaceCount(uint8_t player_id, uint8_t count)
{ {
NetworkString *request = getNetworkString(3); NetworkString *request = getNetworkString(3);
request->addUInt8(LE_VOTE_RACE_COUNT).addUInt8(player_id).addUInt8(count); request->addUInt8(LE_VOTE_RACE_COUNT).addUInt8(player_id).addUInt8(count);
@ -111,7 +137,7 @@ void ClientLobbyRoomProtocol::voteRaceCount(uint8_t player_id, uint8_t count)
* \param player_id The global player id of the voting player. * \param player_id The global player id of the voting player.
* \param minor Voted minor mode. * \param minor Voted minor mode.
*/ */
void ClientLobbyRoomProtocol::voteMinor(uint8_t player_id, uint32_t minor) void ClientLobby::voteMinor(uint8_t player_id, uint32_t minor)
{ {
NetworkString *request = getNetworkString(6); NetworkString *request = getNetworkString(6);
request->addUInt8(LE_VOTE_MINOR).addUInt8(player_id).addUInt32(minor); request->addUInt8(LE_VOTE_MINOR).addUInt8(player_id).addUInt32(minor);
@ -127,7 +153,7 @@ void ClientLobbyRoomProtocol::voteMinor(uint8_t player_id, uint32_t minor)
* \param track Name of the track. * \param track Name of the track.
* \param At which place in the list of tracks this track should be played. * \param At which place in the list of tracks this track should be played.
*/ */
void ClientLobbyRoomProtocol::voteTrack(uint8_t player_id, void ClientLobby::voteTrack(uint8_t player_id,
const std::string &track, const std::string &track,
uint8_t track_nb) uint8_t track_nb)
{ {
@ -147,7 +173,7 @@ void ClientLobbyRoomProtocol::voteTrack(uint8_t player_id,
* \param track_nb Index for the track to be voted on in the list of all * \param track_nb Index for the track to be voted on in the list of all
* tracks. * tracks.
*/ */
void ClientLobbyRoomProtocol::voteReversed(uint8_t player_id, bool reversed, void ClientLobby::voteReversed(uint8_t player_id, bool reversed,
uint8_t track_nb) uint8_t track_nb)
{ {
NetworkString *request = getNetworkString(9); NetworkString *request = getNetworkString(9);
@ -164,7 +190,7 @@ void ClientLobbyRoomProtocol::voteReversed(uint8_t player_id, bool reversed,
* \param laps Number of laps for the specified track. * \param laps Number of laps for the specified track.
* \param track_nb Index of the track in the list of all tracks. * \param track_nb Index of the track in the list of all tracks.
*/ */
void ClientLobbyRoomProtocol::voteLaps(uint8_t player_id, uint8_t laps, void ClientLobby::voteLaps(uint8_t player_id, uint8_t laps,
uint8_t track_nb) uint8_t track_nb)
{ {
NetworkString *request = getNetworkString(10); NetworkString *request = getNetworkString(10);
@ -177,7 +203,7 @@ void ClientLobbyRoomProtocol::voteLaps(uint8_t player_id, uint8_t laps,
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** Called when a client selects to exit a server. /** Called when a client selects to exit a server.
*/ */
void ClientLobbyRoomProtocol::leave() void ClientLobby::leave()
{ {
m_server->disconnect(); m_server->disconnect();
STKHost::get()->removePeer(m_server); STKHost::get()->removePeer(m_server);
@ -190,7 +216,7 @@ void ClientLobbyRoomProtocol::leave()
* screen. It notifies the server that this client has exited the screen and * screen. It notifies the server that this client has exited the screen and
* is back at the lobby. * is back at the lobby.
*/ */
void ClientLobbyRoomProtocol::doneWithResults() void ClientLobby::doneWithResults()
{ {
NetworkString *done = getNetworkString(1); NetworkString *done = getNetworkString(1);
done->addUInt8(LE_RACE_FINISHED_ACK); done->addUInt8(LE_RACE_FINISHED_ACK);
@ -200,18 +226,19 @@ void ClientLobbyRoomProtocol::doneWithResults()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool ClientLobbyRoomProtocol::notifyEvent(Event* event) bool ClientLobby::notifyEvent(Event* event)
{ {
assert(m_setup); // assert that the setup exists assert(m_game_setup); // assert that the setup exists
NetworkString &data = event->data(); NetworkString &data = event->data();
assert(data.size()); // assert that data isn't empty assert(data.size()); // assert that data isn't empty
uint8_t message_type = data.getUInt8(); uint8_t message_type = data.getUInt8();
Log::info("ClientLobbyRoomProtocol", "Synchronous message of type %d", Log::info("ClientLobby", "Synchronous message of type %d",
message_type); message_type);
switch(message_type) switch(message_type)
{ {
case LE_KART_SELECTION_UPDATE: kartSelectionUpdate(event); break; case LE_KART_SELECTION_UPDATE: kartSelectionUpdate(event); break;
case LE_LOAD_WORLD: loadWorld(); break;
case LE_RACE_FINISHED: raceFinished(event); break; case LE_RACE_FINISHED: raceFinished(event); break;
case LE_EXIT_RESULT: exitResultScreen(event); break; case LE_EXIT_RESULT: exitResultScreen(event); break;
default: default:
@ -223,16 +250,16 @@ bool ClientLobbyRoomProtocol::notifyEvent(Event* event)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool ClientLobbyRoomProtocol::notifyEventAsynchronous(Event* event) bool ClientLobby::notifyEventAsynchronous(Event* event)
{ {
assert(m_setup); // assert that the setup exists assert(m_game_setup); // assert that the setup exists
if (event->getType() == EVENT_TYPE_MESSAGE) if (event->getType() == EVENT_TYPE_MESSAGE)
{ {
NetworkString &data = event->data(); NetworkString &data = event->data();
assert(data.size()); // assert that data isn't empty assert(data.size()); // assert that data isn't empty
uint8_t message_type = data.getUInt8(); uint8_t message_type = data.getUInt8();
Log::info("ClientLobbyRoomProtocol", "Asynchronous message of type %d", Log::info("ClientLobby", "Asynchronous message of type %d",
message_type); message_type);
switch(message_type) switch(message_type)
{ {
@ -269,7 +296,7 @@ bool ClientLobbyRoomProtocol::notifyEventAsynchronous(Event* event)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void ClientLobbyRoomProtocol::update(float dt) void ClientLobby::update(float dt)
{ {
switch (m_state) switch (m_state)
{ {
@ -309,6 +336,10 @@ void ClientLobbyRoomProtocol::update(float dt)
NetworkKartSelectionScreen::getInstance(); NetworkKartSelectionScreen::getInstance();
screen->push(); screen->push();
m_state = SELECTING_KARTS; m_state = SELECTING_KARTS;
Protocol *p = new LatencyProtocol();
p->requestStart();
Log::info("LobbyProtocol", "LatencyProtocol started.");
} }
break; break;
case SELECTING_KARTS: case SELECTING_KARTS:
@ -338,7 +369,7 @@ void ClientLobbyRoomProtocol::update(float dt)
* Data | player_id | hostid | player name | * Data | player_id | hostid | player name |
* ------------------------------------- * -------------------------------------
*/ */
void ClientLobbyRoomProtocol::newPlayer(Event* event) void ClientLobby::newPlayer(Event* event)
{ {
if (!checkDataSize(event, 2)) return; if (!checkDataSize(event, 2)) return;
const NetworkString &data = event->data(); const NetworkString &data = event->data();
@ -350,21 +381,21 @@ void ClientLobbyRoomProtocol::newPlayer(Event* event)
// FIXME need adjusting when splitscreen is used/ // FIXME need adjusting when splitscreen is used/
if(STKHost::get()->getGameSetup()->isLocalMaster(player_id)) if(STKHost::get()->getGameSetup()->isLocalMaster(player_id))
{ {
Log::error("ClientLobbyRoomProtocol", Log::error("ClientLobby",
"The server notified me that I'm a new player in the " "The server notified me that I'm a new player in the "
"room (not normal)."); "room (not normal).");
} }
else if (m_setup->getProfile(player_id) == NULL) else if (m_game_setup->getProfile(player_id) == NULL)
{ {
Log::verbose("ClientLobbyRoomProtocol", "New player connected."); Log::verbose("ClientLobby", "New player connected.");
NetworkPlayerProfile* profile = NetworkPlayerProfile* profile =
new NetworkPlayerProfile(name, player_id, host_id); new NetworkPlayerProfile(name, player_id, host_id);
m_setup->addPlayer(profile); m_game_setup->addPlayer(profile);
NetworkingLobby::getInstance()->addPlayer(profile); NetworkingLobby::getInstance()->addPlayer(profile);
} }
else else
{ {
Log::error("ClientLobbyRoomProtocol", Log::error("ClientLobby",
"One of the player notified in the list is myself."); "One of the player notified in the list is myself.");
} }
} // newPlayer } // newPlayer
@ -381,7 +412,7 @@ void ClientLobbyRoomProtocol::newPlayer(Event* event)
* Data | player id *| * Data | player id *|
* -------------- * --------------
*/ */
void ClientLobbyRoomProtocol::disconnectedPlayer(Event* event) void ClientLobby::disconnectedPlayer(Event* event)
{ {
if (!checkDataSize(event, 1)) return; if (!checkDataSize(event, 1)) return;
@ -389,16 +420,16 @@ void ClientLobbyRoomProtocol::disconnectedPlayer(Event* event)
while(data.size()>0) while(data.size()>0)
{ {
const NetworkPlayerProfile *profile = const NetworkPlayerProfile *profile =
m_setup->getProfile(data.getUInt8()); m_game_setup->getProfile(data.getUInt8());
if (m_setup->removePlayer(profile)) if (m_game_setup->removePlayer(profile))
{ {
Log::info("ClientLobbyRoomProtocol", Log::info("ClientLobby",
"Player %d removed successfully.", "Player %d removed successfully.",
profile->getGlobalPlayerId()); profile->getGlobalPlayerId());
} }
else else
{ {
Log::error("ClientLobbyRoomProtocol", Log::error("ClientLobby",
"The disconnected peer wasn't known."); "The disconnected peer wasn't known.");
} }
} // while } // while
@ -418,7 +449,7 @@ void ClientLobbyRoomProtocol::disconnectedPlayer(Event* event)
* Data | player_id| hostid | authorised |playernames* | * Data | player_id| hostid | authorised |playernames* |
* --------------------------------------------------------- * ---------------------------------------------------------
*/ */
void ClientLobbyRoomProtocol::connectionAccepted(Event* event) void ClientLobby::connectionAccepted(Event* event)
{ {
// At least 3 bytes should remain now // At least 3 bytes should remain now
if(!checkDataSize(event, 3)) return; if(!checkDataSize(event, 3)) return;
@ -428,7 +459,7 @@ void ClientLobbyRoomProtocol::connectionAccepted(Event* event)
// Accepted // Accepted
// ======== // ========
Log::info("ClientLobbyRoomProtocol", Log::info("ClientLobby",
"The server accepted the connection."); "The server accepted the connection.");
// self profile // self profile
@ -448,7 +479,7 @@ void ClientLobbyRoomProtocol::connectionAccepted(Event* event)
NetworkPlayerProfile* profile = NetworkPlayerProfile* profile =
new NetworkPlayerProfile(name, my_player_id, my_host_id); new NetworkPlayerProfile(name, my_player_id, my_host_id);
STKHost::get()->getGameSetup()->setLocalMaster(my_player_id); STKHost::get()->getGameSetup()->setLocalMaster(my_player_id);
m_setup->setNumLocalPlayers(1); m_game_setup->setNumLocalPlayers(1);
// connection token // connection token
uint32_t token = data.getToken(); uint32_t token = data.getToken();
peer->setClientServerToken(token); peer->setClientServerToken(token);
@ -464,7 +495,7 @@ void ClientLobbyRoomProtocol::connectionAccepted(Event* event)
NetworkPlayerProfile* profile2 = NetworkPlayerProfile* profile2 =
new NetworkPlayerProfile(name, player_id, host_id); new NetworkPlayerProfile(name, player_id, host_id);
m_setup->addPlayer(profile2); m_game_setup->addPlayer(profile2);
// Inform the network lobby of all players so that the GUI can // Inform the network lobby of all players so that the GUI can
// show all currently connected players. // show all currently connected players.
NetworkingLobby::getInstance()->addPlayer(profile2); NetworkingLobby::getInstance()->addPlayer(profile2);
@ -472,7 +503,7 @@ void ClientLobbyRoomProtocol::connectionAccepted(Event* event)
// Add self after other players so that player order is identical // Add self after other players so that player order is identical
// on server and all clients. // on server and all clients.
m_setup->addPlayer(profile); m_game_setup->addPlayer(profile);
NetworkingLobby::getInstance()->addPlayer(profile); NetworkingLobby::getInstance()->addPlayer(profile);
m_server = event->getPeer(); m_server = event->getPeer();
m_state = CONNECTED; m_state = CONNECTED;
@ -490,7 +521,7 @@ void ClientLobbyRoomProtocol::connectionAccepted(Event* event)
* Data | refusal code | * Data | refusal code |
* ---------------- * ----------------
*/ */
void ClientLobbyRoomProtocol::connectionRefused(Event* event) void ClientLobby::connectionRefused(Event* event)
{ {
if (!checkDataSize(event, 1)) return; if (!checkDataSize(event, 1)) return;
const NetworkString &data = event->data(); const NetworkString &data = event->data();
@ -498,17 +529,17 @@ void ClientLobbyRoomProtocol::connectionRefused(Event* event)
switch (data.getUInt8()) // the second byte switch (data.getUInt8()) // the second byte
{ {
case 0: case 0:
Log::info("ClientLobbyRoomProtocol", Log::info("ClientLobby",
"Connection refused : too many players."); "Connection refused : too many players.");
break; break;
case 1: case 1:
Log::info("ClientLobbyRoomProtocol", "Connection refused : banned."); Log::info("ClientLobby", "Connection refused : banned.");
break; break;
case 2: case 2:
Log::info("ClientLobbyRoomProtocol", "Client busy."); Log::info("ClientLobby", "Client busy.");
break; break;
default: default:
Log::info("ClientLobbyRoomProtocol", "Connection refused."); Log::info("ClientLobby", "Connection refused.");
break; break;
} }
} // connectionRefused } // connectionRefused
@ -525,7 +556,7 @@ void ClientLobbyRoomProtocol::connectionRefused(Event* event)
* Data | refusal code | * Data | refusal code |
* ---------------- * ----------------
*/ */
void ClientLobbyRoomProtocol::kartSelectionRefused(Event* event) void ClientLobby::kartSelectionRefused(Event* event)
{ {
if(!checkDataSize(event, 1)) return; if(!checkDataSize(event, 1)) return;
@ -534,15 +565,15 @@ void ClientLobbyRoomProtocol::kartSelectionRefused(Event* event)
switch (data.getUInt8()) // the error code switch (data.getUInt8()) // the error code
{ {
case 0: case 0:
Log::info("ClientLobbyRoomProtocol", Log::info("ClientLobby",
"Kart selection refused : already taken."); "Kart selection refused : already taken.");
break; break;
case 1: case 1:
Log::info("ClientLobbyRoomProtocol", Log::info("ClientLobby",
"Kart selection refused : not available."); "Kart selection refused : not available.");
break; break;
default: default:
Log::info("ClientLobbyRoomProtocol", "Kart selection refused."); Log::info("ClientLobby", "Kart selection refused.");
break; break;
} }
} // kartSelectionRefused } // kartSelectionRefused
@ -559,48 +590,64 @@ void ClientLobbyRoomProtocol::kartSelectionRefused(Event* event)
* Data | player id | N (kart name size) | kart name | * Data | player id | N (kart name size) | kart name |
* -------------------------------------------------- * --------------------------------------------------
*/ */
void ClientLobbyRoomProtocol::kartSelectionUpdate(Event* event) void ClientLobby::kartSelectionUpdate(Event* event)
{ {
if(!checkDataSize(event, 3)) return; if(!checkDataSize(event, 3)) return;
const NetworkString &data = event->data(); const NetworkString &data = event->data();
uint8_t player_id = data.getUInt8(); uint8_t player_id = data.getUInt8();
std::string kart_name; std::string kart_name;
data.decodeString(&kart_name); data.decodeString(&kart_name);
if (!m_setup->isKartAvailable(kart_name)) if (!m_game_setup->isKartAvailable(kart_name))
{ {
Log::error("ClientLobbyRoomProtocol", Log::error("ClientLobby",
"The updated kart is taken already."); "The updated kart is taken already.");
} }
m_setup->setPlayerKart(player_id, kart_name); m_game_setup->setPlayerKart(player_id, kart_name);
NetworkKartSelectionScreen::getInstance()->playerSelected(player_id, NetworkKartSelectionScreen::getInstance()->playerSelected(player_id,
kart_name); kart_name);
} // kartSelectionUpdate } // kartSelectionUpdate
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/*! \brief Called when the race needs to be started. /*! \brief Called when the server broadcasts to start the race.
race needs to be started.
* \param event : Event providing the information (no additional information * \param event : Event providing the information (no additional information
* in this case). * in this case).
*/ */
void ClientLobbyRoomProtocol::startGame(Event* event) void ClientLobby::startGame(Event* event)
{ {
const NetworkString &data = event->data();
m_state = PLAYING; m_state = PLAYING;
ProtocolManager::getInstance() // Triggers the world finite state machine to go from WAIT_FOR_SERVER_PHASE
->requestStart(new StartGameProtocol(m_setup)); // to READY_PHASE.
Log::info("ClientLobbyRoomProtocol", "Starting new game"); World::getWorld()->setReadyToRace();
Log::info("ClientLobby", "Starting new game");
} // startGame } // startGame
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** Called from WorldStatus when reaching the READY phase, i.e. when the race
* was started. It is going to inform the server of the race start. This
* allows the server to wait for all clients to start, so the server will
* be running behind the client with the biggest latency, which should
* make it likely that at local time T on the server all messages from
* all clients at their local time T have arrived.
*/
void ClientLobby::startingRaceNow()
{
NetworkString *ns = getNetworkString(2);
ns->addUInt8(LE_STARTED_RACE);
sendToServer(ns, /*reliable*/true);
terminateLatencyProtocol();
} // startingRaceNow
//-----------------------------------------------------------------------------
/*! \brief Called when the kart selection starts. /*! \brief Called when the kart selection starts.
* \param event : Event providing the information (no additional information * \param event : Event providing the information (no additional information
* in this case). * in this case).
*/ */
void ClientLobbyRoomProtocol::startSelection(Event* event) void ClientLobby::startSelection(Event* event)
{ {
m_state = KART_SELECTION; m_state = KART_SELECTION;
Log::info("ClientLobbyRoomProtocol", "Kart selection starts now"); Log::info("ClientLobby", "Kart selection starts now");
} // startSelection } // startSelection
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -615,12 +662,12 @@ void ClientLobbyRoomProtocol::startSelection(Event* event)
* Data | Kart 1 ID | kart id 2 | ... | * Data | Kart 1 ID | kart id 2 | ... |
* ------------------------------- * -------------------------------
*/ */
void ClientLobbyRoomProtocol::raceFinished(Event* event) void ClientLobby::raceFinished(Event* event)
{ {
if(!checkDataSize(event, 1)) return; if(!checkDataSize(event, 1)) return;
NetworkString &data = event->data(); NetworkString &data = event->data();
Log::error("ClientLobbyRoomProtocol", Log::error("ClientLobby",
"Server notified that the race is finished."); "Server notified that the race is finished.");
// stop race protocols // stop race protocols
@ -629,7 +676,7 @@ void ClientLobbyRoomProtocol::raceFinished(Event* event)
if (protocol) if (protocol)
ProtocolManager::getInstance()->requestTerminate(protocol); ProtocolManager::getInstance()->requestTerminate(protocol);
else else
Log::error("ClientLobbyRoomProtocol", Log::error("ClientLobby",
"No controller events protocol registered."); "No controller events protocol registered.");
protocol = ProtocolManager::getInstance() protocol = ProtocolManager::getInstance()
@ -637,7 +684,7 @@ void ClientLobbyRoomProtocol::raceFinished(Event* event)
if (protocol) if (protocol)
ProtocolManager::getInstance()->requestTerminate(protocol); ProtocolManager::getInstance()->requestTerminate(protocol);
else else
Log::error("ClientLobbyRoomProtocol", Log::error("ClientLobby",
"No kart update protocol registered."); "No kart update protocol registered.");
protocol = ProtocolManager::getInstance() protocol = ProtocolManager::getInstance()
@ -645,7 +692,7 @@ void ClientLobbyRoomProtocol::raceFinished(Event* event)
if (protocol) if (protocol)
ProtocolManager::getInstance()->requestTerminate(protocol); ProtocolManager::getInstance()->requestTerminate(protocol);
else else
Log::error("ClientLobbyRoomProtocol", Log::error("ClientLobby",
"No game events protocol registered."); "No game events protocol registered.");
// finish the race // finish the race
@ -657,7 +704,7 @@ void ClientLobbyRoomProtocol::raceFinished(Event* event)
{ {
uint8_t kart_id = data.getUInt8(); uint8_t kart_id = data.getUInt8();
ranked_world->setKartPosition(kart_id,position); ranked_world->setKartPosition(kart_id,position);
Log::info("ClientLobbyRoomProtocol", "Kart %d has finished #%d", Log::info("ClientLobby", "Kart %d has finished #%d",
kart_id, position); kart_id, position);
position++; position++;
} }
@ -670,7 +717,7 @@ void ClientLobbyRoomProtocol::raceFinished(Event* event)
/** Called when the server informs the clients to exit the race result screen. /** Called when the server informs the clients to exit the race result screen.
* It exits the race, and goes back to the lobby. * It exits the race, and goes back to the lobby.
*/ */
void ClientLobbyRoomProtocol::exitResultScreen(Event *event) void ClientLobby::exitResultScreen(Event *event)
{ {
RaceResultGUI::getInstance()->backToLobby(); RaceResultGUI::getInstance()->backToLobby();
} // exitResultScreen } // exitResultScreen
@ -686,14 +733,14 @@ void ClientLobbyRoomProtocol::exitResultScreen(Event *event)
* Data |player id | major mode vote | * Data |player id | major mode vote |
* ------------------------------ * ------------------------------
*/ */
void ClientLobbyRoomProtocol::playerMajorVote(Event* event) void ClientLobby::playerMajorVote(Event* event)
{ {
const NetworkString &data = event->data(); const NetworkString &data = event->data();
if (!checkDataSize(event, 2)) if (!checkDataSize(event, 2))
return; return;
uint8_t player_id = data.getUInt8(); uint8_t player_id = data.getUInt8();
uint8_t mode = data.getUInt8(); uint8_t mode = data.getUInt8();
m_setup->getRaceConfig()->setPlayerMajorVote(player_id, mode); m_game_setup->getRaceConfig()->setPlayerMajorVote(player_id, mode);
} // playerMajorVote } // playerMajorVote
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -707,13 +754,13 @@ void ClientLobbyRoomProtocol::playerMajorVote(Event* event)
* Data | player id | races count | * Data | player id | races count |
* --------------------------- * ---------------------------
*/ */
void ClientLobbyRoomProtocol::playerRaceCountVote(Event* event) void ClientLobby::playerRaceCountVote(Event* event)
{ {
if (!checkDataSize(event, 2)) return; if (!checkDataSize(event, 2)) return;
const NetworkString &data = event->data(); const NetworkString &data = event->data();
uint8_t player_id = data.getUInt8(); uint8_t player_id = data.getUInt8();
uint8_t count = data.getUInt8(); uint8_t count = data.getUInt8();
m_setup->getRaceConfig()->setPlayerRaceCountVote(player_id, count); m_game_setup->getRaceConfig()->setPlayerRaceCountVote(player_id, count);
} // playerRaceCountVote } // playerRaceCountVote
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -727,13 +774,13 @@ void ClientLobbyRoomProtocol::playerRaceCountVote(Event* event)
* Data | player id | minor mode vote | * Data | player id | minor mode vote |
* ------------------------------- * -------------------------------
*/ */
void ClientLobbyRoomProtocol::playerMinorVote(Event* event) void ClientLobby::playerMinorVote(Event* event)
{ {
if (!checkDataSize(event, 2)) return; if (!checkDataSize(event, 2)) return;
const NetworkString &data = event->data(); const NetworkString &data = event->data();
uint8_t player_id = data.getUInt8(); uint8_t player_id = data.getUInt8();
uint8_t minor = data.getUInt8(); uint8_t minor = data.getUInt8();
m_setup->getRaceConfig()->setPlayerMinorVote(player_id, minor); m_game_setup->getRaceConfig()->setPlayerMinorVote(player_id, minor);
} // playerMinorVote } // playerMinorVote
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -748,7 +795,7 @@ void ClientLobbyRoomProtocol::playerMinorVote(Event* event)
* Data | player id | track number (gp) | N | track name | * Data | player id | track number (gp) | N | track name |
* -------------------------------------------------- * --------------------------------------------------
*/ */
void ClientLobbyRoomProtocol::playerTrackVote(Event* event) void ClientLobby::playerTrackVote(Event* event)
{ {
if (!checkDataSize(event, 3)) return; if (!checkDataSize(event, 3)) return;
const NetworkString &data = event->data(); const NetworkString &data = event->data();
@ -756,7 +803,7 @@ void ClientLobbyRoomProtocol::playerTrackVote(Event* event)
uint8_t player_id = data.getUInt8(); uint8_t player_id = data.getUInt8();
uint8_t number = data.getUInt8(); uint8_t number = data.getUInt8();
int N = data.decodeString(&track_name); int N = data.decodeString(&track_name);
m_setup->getRaceConfig()->setPlayerTrackVote(player_id, track_name, m_game_setup->getRaceConfig()->setPlayerTrackVote(player_id, track_name,
number); number);
} // playerTrackVote } // playerTrackVote
@ -772,14 +819,14 @@ void ClientLobbyRoomProtocol::playerTrackVote(Event* event)
* Data | player id |reversed | track number (gp) | * Data | player id |reversed | track number (gp) |
* ------------------------------------------- * -------------------------------------------
*/ */
void ClientLobbyRoomProtocol::playerReversedVote(Event* event) void ClientLobby::playerReversedVote(Event* event)
{ {
if (!checkDataSize(event, 3)) return; if (!checkDataSize(event, 3)) return;
const NetworkString &data = event->data(); const NetworkString &data = event->data();
uint8_t player_id = data.getUInt8(); uint8_t player_id = data.getUInt8();
uint8_t reversed = data.getUInt8(); uint8_t reversed = data.getUInt8();
uint8_t number = data.getUInt8(); uint8_t number = data.getUInt8();
m_setup->getRaceConfig()->setPlayerReversedVote(player_id, reversed!=0, m_game_setup->getRaceConfig()->setPlayerReversedVote(player_id, reversed!=0,
number); number);
} // playerReversedVote } // playerReversedVote
@ -792,17 +839,39 @@ void ClientLobbyRoomProtocol::playerReversedVote(Event* event)
* Byte 0 1 2 * Byte 0 1 2
* ---------------------------------------- * ----------------------------------------
* Size | 1 | 1 | 1 | * Size | 1 | 1 | 1 |
* Data | player id | laps | track number (gp) | * Data | player id | laps | track number (gp) |
* ---------------------------------------- * ----------------------------------------
*/ */
void ClientLobbyRoomProtocol::playerLapsVote(Event* event) void ClientLobby::playerLapsVote(Event* event)
{ {
if (!checkDataSize(event, 3)) return; if (!checkDataSize(event, 3)) return;
const NetworkString &data = event->data(); const NetworkString &data = event->data();
uint8_t player_id = data.getUInt8(); uint8_t player_id = data.getUInt8();
uint8_t laps = data.getUInt8(); uint8_t laps = data.getUInt8();
uint8_t number = data.getUInt8(); uint8_t number = data.getUInt8();
m_setup->getRaceConfig()->setPlayerLapsVote(player_id, laps, number); m_game_setup->getRaceConfig()->setPlayerLapsVote(player_id, laps, number);
} // playerLapsVote } // playerLapsVote
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** Callback when the world is loaded. The client will inform the server
* that the players on this host are ready to start the race. It is called by
* the RaceManager after the world is loaded.
*/
void ClientLobby::finishedLoadingWorld()
{
assert(STKHost::get()->getPeerCount() == 1);
std::vector<NetworkPlayerProfile*> players =
STKHost::get()->getMyPlayerProfiles();
NetworkString *ns = getNetworkString(2);
ns->addUInt8(LE_CLIENT_LOADED_WORLD);
ns->addUInt8( uint8_t(players.size()) ) ;
for (unsigned int i = 0; i < players.size(); i++)
{
ns->addUInt8(players[i]->getGlobalPlayerId());
Log::info("ClientLobby",
"Player %d ready, notifying server.",
players[i]->getGlobalPlayerId());
} // for i < players.size()
sendToServer(ns, /*reliable*/true);
delete ns;
} // finishedLoadingWorld

View File

@ -1,13 +1,13 @@
#ifndef CLIENT_LOBBY_ROOM_PROTOCOL_HPP #ifndef CLIENT_LOBBY_HPP
#define CLIENT_LOBBY_ROOM_PROTOCOL_HPP #define CLIENT_LOBBY_HPP
#include "network/protocols/lobby_room_protocol.hpp" #include "network/protocols/lobby_protocol.hpp"
#include "network/transport_address.hpp" #include "network/transport_address.hpp"
#include "utils/cpp2011.hpp" #include "utils/cpp2011.hpp"
class STKPeer; class STKPeer;
class ClientLobbyRoomProtocol : public LobbyRoomProtocol class ClientLobby : public LobbyProtocol
{ {
private: private:
void newPlayer(Event* event); void newPlayer(Event* event);
@ -50,11 +50,12 @@ private:
STATE m_state; STATE m_state;
public: public:
ClientLobbyRoomProtocol(const TransportAddress& server_address); ClientLobby();
virtual ~ClientLobbyRoomProtocol(); virtual ~ClientLobby();
void requestKartSelection(uint8_t player_id, virtual void requestKartSelection(uint8_t player_id,
const std::string &kart_name); const std::string &kart_name) OVERRIDE;
void setAddress(const TransportAddress &address);
void voteMajor(uint8_t player_id, uint32_t major); void voteMajor(uint8_t player_id, uint32_t major);
void voteRaceCount(uint8_t player_id, uint8_t count); void voteRaceCount(uint8_t player_id, uint8_t count);
void voteMinor(uint8_t player_id, uint32_t minor); void voteMinor(uint8_t player_id, uint32_t minor);
@ -63,14 +64,16 @@ public:
void voteReversed(uint8_t player_id, bool reversed, uint8_t track_nb = 0); void voteReversed(uint8_t player_id, bool reversed, uint8_t track_nb = 0);
void voteLaps(uint8_t player_id, uint8_t laps, uint8_t track_nb = 0); void voteLaps(uint8_t player_id, uint8_t laps, uint8_t track_nb = 0);
void doneWithResults(); void doneWithResults();
void startingRaceNow();
void leave(); void leave();
virtual bool notifyEvent(Event* event) OVERRIDE; virtual bool notifyEvent(Event* event) OVERRIDE;
virtual bool notifyEventAsynchronous(Event* event) OVERRIDE; virtual bool notifyEventAsynchronous(Event* event) OVERRIDE;
virtual void finishedLoadingWorld() OVERRIDE;
virtual void setup() OVERRIDE; virtual void setup() OVERRIDE;
virtual void update(float dt) OVERRIDE; virtual void update(float dt) OVERRIDE;
virtual void asynchronousUpdate() OVERRIDE {} virtual void asynchronousUpdate() OVERRIDE {}
}; };
#endif // CLIENT_LOBBY_ROOM_PROTOCOL_HPP #endif // CLIENT_LOBBY_HPP

View File

@ -26,7 +26,7 @@
#include "network/protocols/hide_public_address.hpp" #include "network/protocols/hide_public_address.hpp"
#include "network/protocols/request_connection.hpp" #include "network/protocols/request_connection.hpp"
#include "network/protocols/ping_protocol.hpp" #include "network/protocols/ping_protocol.hpp"
#include "network/protocols/client_lobby_room_protocol.hpp" #include "network/protocols/client_lobby.hpp"
#include "network/protocol_manager.hpp" #include "network/protocol_manager.hpp"
#include "network/servers_manager.hpp" #include "network/servers_manager.hpp"
#include "network/stk_host.hpp" #include "network/stk_host.hpp"
@ -238,7 +238,9 @@ void ConnectToServer::asynchronousUpdate()
// lobby room protocol if we're connected only // lobby room protocol if we're connected only
if(STKHost::get()->getPeers()[0]->isConnected()) if(STKHost::get()->getPeers()[0]->isConnected())
{ {
Protocol *p = new ClientLobbyRoomProtocol(m_server_address); ClientLobby *p =
LobbyProtocol::create<ClientLobby>();
p->setAddress(m_server_address);
p->requestStart(); p->requestStart();
} }
} }

View File

@ -39,7 +39,7 @@ GameEventsProtocol::~GameEventsProtocol()
*/ */
void GameEventsProtocol::setup() void GameEventsProtocol::setup()
{ {
World::getWorld()->setReadyToRace(); m_count_ready_clients = 0;
} // setup } // setup
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -63,16 +63,16 @@ bool GameEventsProtocol::notifyEvent(Event* event)
int8_t type = data.getUInt8(); int8_t type = data.getUInt8();
switch (type) switch (type)
{ {
case GE_ITEM_COLLECTED: case GE_CLIENT_STARTED_RSG:
collectedItem(data); break; receivedClientHasStarted(event); break;
case GE_KART_FINISHED_RACE: case GE_ITEM_COLLECTED:
kartFinishedRace(data); break; collectedItem(data); break;
case GE_START_READY_SET_GO: case GE_KART_FINISHED_RACE:
receivedReadySetGo(); break; kartFinishedRace(data); break;
default: default:
Log::warn("GameEventsProtocol", "Unkown message type."); Log::warn("GameEventsProtocol", "Unkown message type.");
break; break;
} }
return true; return true;
} // notifyEvent } // notifyEvent
@ -164,26 +164,37 @@ void GameEventsProtocol::kartFinishedRace(const NetworkString &ns)
} // kartFinishedRace } // kartFinishedRace
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** This function is called on a server when the world starts the ready-set-go /** Called on a client when it has started its ready-set-go. The client will
* phase. It signals to all clients to do the same. * inform the server anout this. The server will wait for all clients to
* have started before it will start its own countdown.
*/ */
void GameEventsProtocol::startReadySetGo() void GameEventsProtocol::clientHasStarted()
{
assert(NetworkConfig::get()->isServer());
NetworkString *ns = getNetworkString(1);
ns->setSynchronous(true);
ns->addUInt8(GE_START_READY_SET_GO);
sendMessageToPeersChangingToken(ns, /*reliable*/true);
delete ns;
} // startReadySetGo
// ----------------------------------------------------------------------------
/** Called on the client when it receives the message that the server has
* started its ready-set-go. Signal to world that it can go to the next
* phase (ready phase) now.
*/
void GameEventsProtocol::receivedReadySetGo()
{ {
assert(NetworkConfig::get()->isClient()); assert(NetworkConfig::get()->isClient());
World::getWorld()->startReadySetGo(); NetworkString *ns = getNetworkString(1);
} // receivedReadySetGo ns->setSynchronous(true);
ns->addUInt8(GE_CLIENT_STARTED_RSG);
sendToServer(ns, /*reliable*/true);
delete ns;
} // clientHasStarted
// ----------------------------------------------------------------------------
/** Called on the server when a client has signaled that it has started ready
* set go. The server waits for the last client before it starts its own
* ready set go. */
void GameEventsProtocol::receivedClientHasStarted(Event *event)
{
assert(NetworkConfig::get()->isServer());
m_count_ready_clients++;
Log::verbose("GameEvent",
"Host %d has started ready-set-go: %d out of %d done",
event->getPeer()->getHostId(), m_count_ready_clients,
STKHost::get()->getGameSetup()->getPlayerCount() );
if (m_count_ready_clients==STKHost::get()->getGameSetup()->getPlayerCount())
{
Log::verbose("GameEvent", "All %d clients have started.",
STKHost::get()->getGameSetup()->getPlayerCount());
// SIgnal the server to start now - since it is now behind the client
// times by the latency of the 'slowest' client.
World::getWorld()->startReadySetGo();
}
} // receivedClientHasStarted

View File

@ -11,11 +11,18 @@ class GameEventsProtocol : public Protocol
{ {
private: private:
enum GameEventType { enum GameEventType {
GE_START_READY_SET_GO = 0x01, GE_CLIENT_STARTED_RSG = 0x01,
GE_ITEM_COLLECTED = 0x02, GE_ITEM_COLLECTED = 0x02,
GE_KART_FINISHED_RACE = 0x03 GE_KART_FINISHED_RACE = 0x03
}; // GameEventType }; // GameEventType
/** Count how many clients have started 'ready'. The server
* will only go to its 'ready' phase if all client shave done so.
* This means the server time is far enough behind the clients
* that at time T all client messages for time T have been
* received (short of latency spikes). */
int m_count_ready_clients;
public: public:
GameEventsProtocol(); GameEventsProtocol();
virtual ~GameEventsProtocol(); virtual ~GameEventsProtocol();
@ -24,9 +31,9 @@ public:
void collectedItem(Item* item, AbstractKart* kart); void collectedItem(Item* item, AbstractKart* kart);
void collectedItem(const NetworkString &ns); void collectedItem(const NetworkString &ns);
void kartFinishedRace(AbstractKart *kart, float time); void kartFinishedRace(AbstractKart *kart, float time);
void clientHasStarted();
void receivedClientHasStarted(Event *event);
void kartFinishedRace(const NetworkString &ns); void kartFinishedRace(const NetworkString &ns);
void startReadySetGo();
void receivedReadySetGo();
virtual void setup() OVERRIDE; virtual void setup() OVERRIDE;
virtual void update(float dt) OVERRIDE {}; virtual void update(float dt) OVERRIDE {};
virtual void asynchronousUpdate() OVERRIDE{} virtual void asynchronousUpdate() OVERRIDE{}

View File

@ -0,0 +1,140 @@
#include "network/protocols/latency_protocol.hpp"
#include "network/event.hpp"
#include "network/network_config.hpp"
#include "network/stk_host.hpp"
#include "network/stk_peer.hpp"
#include "utils/time.hpp"
//-----------------------------------------------------------------------------
/** This protocol tries to determine the average latency between client and
* server. While this information is not used atm, it might be useful for
* the server to determine how much behind the clients it should start.
* FIXME: ATM the main thread will load the world as part of an update
* of the ProtocolManager (which updates the protocols). Since all protocols
* are locked dusing this update, the synchronisation protocol is actually
* delayed from starting while world is loading (since finding the protocol
* for a message requires the protocol lock) - causing at least two frames
* of significanlty delayed pings :(
*/
LatencyProtocol::LatencyProtocol()
: Protocol(PROTOCOL_SYNCHRONIZATION)
{
unsigned int size = STKHost::get()->getPeerCount();
m_pings.resize(size, std::map<uint32_t,double>());
m_successed_pings.resize(size, 0);
m_total_diff.resize(size, 0);
m_average_ping.resize(size, 0);
m_pings_count = 0;
} // LatencyProtocol
//-----------------------------------------------------------------------------
LatencyProtocol::~LatencyProtocol()
{
} // ~LatencyProtocol
//-----------------------------------------------------------------------------
void LatencyProtocol::setup()
{
Log::info("LatencyProtocol", "Ready !");
} // setup
//-----------------------------------------------------------------------------
/** Called when receiving a message. On the client side the message is a ping
* from the server, which is answered back. On the server the received message
* is a reply to a previous ping request. The server will keep track of
* average latency.
*/
bool LatencyProtocol::notifyEventAsynchronous(Event* event)
{
if (event->getType() != EVENT_TYPE_MESSAGE)
return true;
if(!checkDataSize(event, 5)) return true;
const NetworkString &data = event->data();
uint32_t request = data.getUInt8();
uint32_t sequence = data.getUInt32();
const std::vector<STKPeer*> &peers = STKHost::get()->getPeers();
assert(peers.size() > 0);
// Find the right peer id. The host id (i.e. each host sendings its
// host id) can not be used here, since host ids can have gaps (if a
// host should disconnect)
uint8_t peer_id = -1;
for (unsigned int i = 0; i < peers.size(); i++)
{
if (peers[i]->isSamePeer(event->getPeer()))
{
peer_id = i;
break;
}
}
if (request)
{
// Only a client should receive a request for a ping response
assert(NetworkConfig::get()->isClient());
NetworkString *response = getNetworkString(5);
// The '0' indicates a response to a ping request
response->addUInt8(0).addUInt32(sequence);
event->getPeer()->sendPacket(response, false);
delete response;
}
else // receive response to a ping request
{
// Only a server should receive this kind of message
assert(NetworkConfig::get()->isServer());
if (sequence >= m_pings[peer_id].size())
{
Log::warn("LatencyProtocol",
"The sequence# %u isn't known.", sequence);
return true;
}
double current_time = StkTime::getRealTime();
m_total_diff[peer_id] += current_time - m_pings[peer_id][sequence];
m_successed_pings[peer_id]++;
m_average_ping[peer_id] =
(int)((m_total_diff[peer_id]/m_successed_pings[peer_id])*1000.0);
Log::debug("LatencyProtocol",
"Peer %d sequence %d ping %u average %u at %lf",
peer_id, sequence,
(unsigned int)((current_time - m_pings[peer_id][sequence])*1000),
m_average_ping[peer_id],
StkTime::getRealTime());
}
return true;
} // notifyEventAsynchronous
//-----------------------------------------------------------------------------
/** Waits for the countdown to be started. On the server the start of the
* countdown is triggered by ServerLobby::finishedLoadingWorld(),
* which is called once all clients have confirmed that they are ready to
* start. The server will send a ping request to each client once a second,
* and include the information if the countdown has started (and its current
* value). On the client the countdown is started in notifyEvenAsynchronous()
* when a server ping is received that indicates that the countdown has
* started. The measured times can be used later to estimate the latency
* between server and client.
*/
void LatencyProtocol::asynchronousUpdate()
{
float current_time = float(StkTime::getRealTime());
if (NetworkConfig::get()->isServer() && current_time > m_last_time+1)
{
const std::vector<STKPeer*> &peers = STKHost::get()->getPeers();
for (unsigned int i = 0; i < peers.size(); i++)
{
NetworkString *ping_request =
getNetworkString(5);
ping_request->addUInt8(1).addUInt32(m_pings[i].size());
m_pings[i] [ m_pings_count ] = current_time;
peers[i]->sendPacket(ping_request, false);
delete ping_request;
} // for i M peers
m_last_time = current_time;
m_pings_count++;
} // if current_time > m_last_time + 0.1
} // asynchronousUpdate

Some files were not shown because too many files have changed in this diff Show More