From 70fc89d31b81a0cc49fc4b8daf527dd187544d9e Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 8 Jun 2008 18:39:17 +0000 Subject: disable client prediction by default, add --without-client option to configure --- configure.in | 112 +++++++++++++++++++++++++++------------------- osirion.kdevelop.pcs | Bin 757694 -> 758234 bytes src/Makefile.am | 14 +++++- src/core/application.cc | 2 +- src/core/gameinterface.cc | 4 +- src/model/engine.cc | 2 + src/model/engine.h | 2 + src/model/map.cc | 4 +- src/render/draw.cc | 61 ++++++++++++++----------- 9 files changed, 123 insertions(+), 78 deletions(-) diff --git a/configure.in b/configure.in index 257549e..61b94c7 100644 --- a/configure.in +++ b/configure.in @@ -108,61 +108,78 @@ AC_ARG_ENABLE(debug_messages, AC_DEFINE_UNQUOTED(HAVE_DEBUG_MESSAGES, 1, [Defines if debug information is enabled]) ) -AC_CHECK_HEADER(GL/gl.h, - HAVE_OPENGL=yes - AC_DEFINE(HAVE_OPENGL, 1, [Define this if you have OpenGL]), - HAVE_OPENGL=no -) +BUILD_CLIENT=no -AC_CHECK_HEADER(GL/glext.h, - HAVE_OPENGL_GLEXT=yes - AC_DEFINE(HAVE_OPENGL_GLEXT, 1, [Define this if you have OpenGL Extensions]), - HAVE_OPENGL_GLEXT=no, - [#include ] +AC_ARG_WITH(client, + AC_HELP_STRING([--without-client], [build the dedicated server only]) ) +AC_MSG_CHECKING(whether to build client) -GL_LIBS="$HOST_GL_LIBS" - -AC_SUBST(GL_LIBS) -AC_SUBST(GL_CFLAGS) +if test "x${with_client}" = xno; then -AC_CHECK_HEADER(AL/al.h, - HAVE_OPENGL=yes - AC_DEFINE(HAVE_OPENAL, 1, [Define this if you have OpenAL]), - HAVE_OPENAL=no -) + AC_MSG_RESULT(no) -AL_LIBS="$HOST_AL_LIBS" -AC_SUBST(AL_LIBS) - -AC_MSG_CHECKING([looking for SDL]) -KDE_FIND_PATH(sdl-config, LIBSDL_CONFIG, [${prefix}/bin ${exec_prefix}/bin /usr/local/bin /opt/local/bin], [ - AC_MSG_WARN([Could not find libSDL, check http://www.sdl.org]) -]) +else + AC_MSG_RESULT(yes) -if test -n "$LIBSDL_CONFIG"; then - LIBSDL_LIBS="`$LIBSDL_CONFIG --libs`" - LIBSDL_RPATH= - for args in $LIBSDL_LIBS; do - case $args in - -L*) - LIBSDL_RPATH="$LIBSDL_RPATH $args" - ;; - esac - done - LIBSDL_RPATH=`echo $LIBSDL_RPATH | sed -e "s/-L/-R/g"` - LIBSDL_CFLAGS="`$LIBSDL_CONFIG --cflags`" - - AC_DEFINE_UNQUOTED(HAVE_LIBSDL, 1, [Defines if your system has the LIBSDL library]) + BUILD_CLIENT=yes + AC_DEFINE(BUILD_CLIENT, 1, [Define this to build a client]) + + AC_CHECK_HEADER(GL/gl.h, + HAVE_OPENGL=yes + AC_DEFINE(HAVE_OPENGL, 1, [Define this if you have OpenGL]), + AC_MSG_WARN([OpenGL include file GL/gl.h not found]) + ) + + AC_CHECK_HEADER(GL/glext.h, + HAVE_OPENGL_GLEXT=yes + AC_DEFINE(HAVE_OPENGL_GLEXT, 1, [Define this if you have OpenGL Extensions]), + AC_MSG_ERROR([OpenGL include file GL/glext.h not found]) + ) + + GL_LIBS="$HOST_GL_LIBS" + + AC_SUBST(GL_LIBS) + AC_SUBST(GL_CFLAGS) + + AC_CHECK_HEADER(AL/al.h, + HAVE_OPENGL=yes + AC_DEFINE(HAVE_OPENAL, 1, [Define this if you have OpenAL]), + AC_MSG_ERROR([OpenAL include file AL/al.h not found]) + ) + + AL_LIBS="$HOST_AL_LIBS" + AC_SUBST(AL_LIBS) + + AC_MSG_CHECKING([looking for SDL]) + KDE_FIND_PATH(sdl-config, LIBSDL_CONFIG, [${prefix}/bin ${exec_prefix}/bin /usr/local/bin /opt/local/bin], [ + AC_MSG_ERROR([SDL not found]) + ]) + + if test -n "$LIBSDL_CONFIG"; then + LIBSDL_LIBS="`$LIBSDL_CONFIG --libs`" + LIBSDL_RPATH= + for args in $LIBSDL_LIBS; do + case $args in + -L*) + LIBSDL_RPATH="$LIBSDL_RPATH $args" + ;; + esac + done + LIBSDL_RPATH=`echo $LIBSDL_RPATH | sed -e "s/-L/-R/g"` + LIBSDL_CFLAGS="`$LIBSDL_CONFIG --cflags`" + + AC_DEFINE_UNQUOTED(HAVE_LIBSDL, 1, [Defines if your system has the LIBSDL library]) + fi + + AC_MSG_RESULT($HAVE_LIBSDL) + + AC_SUBST(LIBSDL_LIBS) + AC_SUBST(LIBSDL_CFLAGS) + AC_SUBST(LIBSDL_RPATH) fi -AC_MSG_RESULT($HAVE_LIBSDL) - -AC_SUBST(LIBSDL_LIBS) -AC_SUBST(LIBSDL_CFLAGS) -AC_SUBST(LIBSDL_RPATH) - CXXFLAGS="-pipe $DEBUG_CFLAGS $WARN_CFLAGS $CXXFLAGS" AC_SUBST(CXXFLAGS) @@ -195,6 +212,8 @@ AC_DEFINE_UNQUOTED(PACKAGE_LIBDIR, "$PACKAGE_LIBDIR", dnl --------------------------------------------------------------- dnl Write makefiles and config.h +AM_CONDITIONAL(BUILD_CLIENT, test "x$BUILD_CLIENT" = xyes) + AC_OUTPUT(Makefile src/Makefile src/audio/Makefile src/auxiliary/Makefile \ src/client/Makefile src/core/Makefile src/filesystem/Makefile src/game/Makefile \ src/math/Makefile src/model/Makefile src/render/Makefile src/server/Makefile src/sys/Makefile) @@ -209,6 +228,7 @@ Configuration summary: platform ........... $host flags .............. $CXXFLAGS libraries .......... $HOST_LIBS + build client ....... $BUILD_CLIENT opengl ............. $GL_LIBS openal ............. $AL_LIBS diff --git a/osirion.kdevelop.pcs b/osirion.kdevelop.pcs index 5125b19..3c3a627 100644 Binary files a/osirion.kdevelop.pcs and b/osirion.kdevelop.pcs differ diff --git a/src/Makefile.am b/src/Makefile.am index 37e1b2e..9c55179 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,10 +4,20 @@ SUFFIXES = .rc .rc.o: windres $< -o $@ -SUBDIRS = sys math auxiliary filesystem model core server audio render client \ - game +if BUILD_CLIENT + MAYBE_CLIENT_SUBDIRS = audio render client + MAYBE_CLIENT_PROGRAMS = osirion +endif + +SUBDIRS = sys math auxiliary filesystem model core server $(MAYBE_CLIENT_SUBDIRS) game + noinst_HEADERS = config.h + +if BUILD_CLIENT bin_PROGRAMS = osiriond osirion +else +bin_PROGRAMS = osiriond +endif # dedicated server osiriond_SOURCES = osiriond.cc diff --git a/src/core/application.cc b/src/core/application.cc index fb82c6c..738a071 100644 --- a/src/core/application.cc +++ b/src/core/application.cc @@ -132,7 +132,7 @@ void Application::init(int count, char **arguments) Cvar::sv_private = Cvar::get("sv_private", "0"); Cvar::sv_private->set_info("[bool] enable or disable network server for a client"); - Cvar::cl_prediction = Cvar::get("cl_prediction", "1", Cvar::Archive); + Cvar::cl_prediction = Cvar::get("cl_prediction", "0", Cvar::Archive); Cvar::cl_prediction->set_info("[bool] enable or disable client prediction"); // load configuration diff --git a/src/core/gameinterface.cc b/src/core/gameinterface.cc index cfa557b..4aa59be 100644 --- a/src/core/gameinterface.cc +++ b/src/core/gameinterface.cc @@ -244,8 +244,8 @@ void GameInterface::update_clientstate(float seconds) float GameInterface::timeoffset() { - //if (game_clientframetime > game_serverframetime) - // return 1; + if (game_clientframetime > game_serverframetime) + return 1; float d = game_serverframetime - game_previousframetime; if (d <= 0) diff --git a/src/model/engine.cc b/src/model/engine.cc index 1a89ea2..7c8d117 100644 --- a/src/model/engine.cc +++ b/src/model/engine.cc @@ -16,6 +16,8 @@ Engine::Engine() : engine_location() { engine_radius = 1.0f; + engine_flare = 0; + engine_color.assign(1.0f, 0.0f, 0.0f , 1.0f); } Engine::Engine(math::Vector3f const & location) : diff --git a/src/model/engine.h b/src/model/engine.h index 5254973..569eb4e 100644 --- a/src/model/engine.h +++ b/src/model/engine.h @@ -23,6 +23,8 @@ public: inline math::Vector3f const & location() const { return engine_location; } + inline math::Color const & color() const { return engine_color; } + inline float radius() const { return engine_radius; } inline unsigned int flare() const { return engine_flare; } diff --git a/src/model/map.cc b/src/model/map.cc index 6769ba8..39e2b9c 100644 --- a/src/model/map.cc +++ b/src/model/map.cc @@ -138,7 +138,9 @@ Model * Map::load(std::string const &name) } else if (mapfile.got_key_int("flare", engine->engine_flare)) { continue; - } + } else if (mapfile.got_key_color("_color", engine->engine_color)) { + continue; + } } } diff --git a/src/render/draw.cc b/src/render/draw.cc index f3df6c0..448b2ce 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -232,14 +232,26 @@ void pass_prepare(float seconds) for (std::list::iterator lit = entity->model()->model_light.begin(); lit != entity->model()->model_light.end(); lit++) { model::Light *light = (*lit); - // load flare texture + // load light texture // FIXME optimize std::stringstream flarename; flarename << "bitmaps/fx/flare" << std::setfill('0') << std::setw(2) << light->flare(); light->render_texture = Textures::load(flarename.str()); } - for (std::list::iterator flit = entity->model()->model_flare.begin(); flit != entity->model()->model_flare.end(); flit++) { + for(std::list::iterator eit = entity->model()->model_engine.begin(); eit != entity->model()->model_engine.end(); eit++) { + model::Engine *engine = (*eit); + + if (!engine->flare()) engine->engine_flare = 1; + + // load engine texture + // FIXME optimize + std::stringstream flarename; + flarename << "bitmaps/fx/flare" << std::setfill('0') << std::setw(2) << engine->flare(); + engine->render_texture = Textures::load(flarename.str()); + } + + for (std::list::iterator flit = entity->model()->model_flare.begin(); flit != entity->model()->model_flare.end(); flit++) { model::Flare *flare = (*flit); // load flare texture @@ -444,7 +456,6 @@ void draw_pass_model_fx() float t; size_t flare_texture = Textures::bind("bitmaps/fx/flare00"); - size_t engine_texture = Textures::find("bitmaps/fx/flare01"); gl::enable(GL_TEXTURE_2D); @@ -464,20 +475,22 @@ void draw_pass_model_fx() t = (core::application()->time() + entity->state()->fuzz() - (*lit)->offset()) * (*lit)->frequency(); if (!(*lit)->strobe() || (( t - floorf(t)) <= (*lit)->time())) { - math::Vector3f location = entity->state()->location() + (entity->state()->axis() * (*lit)->location()); + model::Light *light = (*lit); + + math::Vector3f location = entity->state()->location() + (entity->state()->axis() * light->location()); float light_size = 0.0625 * (*lit)->radius(); - if ((*lit)->render_texture != flare_texture) { + if (flare_texture != light->texture()) { gl::end(); - flare_texture = Textures::bind((*lit)->render_texture); + flare_texture = Textures::bind(light->texture()); gl::begin(gl::Quads); } math::Color color; - if ((*lit)->entity()) { + if (light->entity()) { color.assign(entity->color()); } else { - color.assign((*lit)->color()); + color.assign(light->color()); } color.a = 0.8; gl::color(color); @@ -514,9 +527,9 @@ void draw_pass_model_fx() math::Vector3f location = entity->state()->location() + (entity->state()->axis() * flare->location()); float light_size = 0.0625 * flare->radius(); - if (flare->render_texture != flare_texture) { + if (flare_texture != flare->texture()) { gl::end(); - flare_texture = Textures::bind(flare->render_texture); + flare_texture = Textures::bind(flare->texture()); gl::begin(gl::Quads); } @@ -550,26 +563,22 @@ void draw_pass_model_fx() // draw model engines for Controlable entities if (entity->type() == core::Entity::Controlable && entity->model()->model_engine.size()) { - if (flare_texture != engine_texture) { - gl::end(); - flare_texture = Textures::bind(engine_texture); - gl::begin(gl::Quads); - } - float u = static_cast(entity)->thrust(); - t = entity->state()->fuzz() + core::application()->time() * 4; - - t = t - floorf(t); - if (t > 0.5) - t = 1-t; - t = 0.75f + t/2; - for(std::list::iterator eit = entity->model()->model_engine.begin(); eit != entity->model()->model_engine.end(); eit++) { - math::Vector3f location = entity->state()->location() + (entity->state()->axis() * (*eit)->location()); - float engine_size = 0.0625 * (*eit)->radius() * t; - math::Color color(1.0f, 0.0f, 0.0f, 0.9f * u); + model::Engine *engine = (*eit); + + math::Vector3f location = entity->state()->location() + (entity->state()->axis() * engine->location()); + float engine_size = 0.0625 * engine->radius(); + math::Color color(engine->color()); + color.a = 0.9f * u; + + if (flare_texture != engine->texture() ) { + gl::end(); + flare_texture = Textures::bind(engine->texture()); + gl::begin(gl::Quads); + } gl::color(color); glTexCoord2f(0,1); -- cgit v1.2.3