diff options
author | Stijn Buys <ingar@osirion.org> | 2008-05-05 17:45:30 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-05-05 17:45:30 +0000 |
commit | c11c0174ece92b4502648ad33653975bfdfc39a0 (patch) | |
tree | 88860bfcbb7206834e61533af79f7631b5638cb2 | |
parent | 7218e3bd4616d4706090ec47d72845a2bb89c6a3 (diff) |
lights with entity color, sunlight, network stats
-rw-r--r-- | TODO | 6 | ||||
-rw-r--r-- | osirion.kdevelop.pcs | bin | 634891 -> 639076 bytes | |||
-rw-r--r-- | osirion.kdevses | 21 | ||||
-rw-r--r-- | src/client/view.cc | 3 | ||||
-rw-r--r-- | src/core/Makefile.am | 5 | ||||
-rw-r--r-- | src/core/entity.cc | 5 | ||||
-rw-r--r-- | src/core/entity.h | 3 | ||||
-rw-r--r-- | src/core/net.h | 1 | ||||
-rw-r--r-- | src/core/netclient.cc | 2 | ||||
-rw-r--r-- | src/core/netconnection.cc | 3 | ||||
-rw-r--r-- | src/core/netserver.cc | 22 | ||||
-rw-r--r-- | src/game/star.cc | 2 | ||||
-rw-r--r-- | src/game/star.h | 2 | ||||
-rw-r--r-- | src/model/light.cc | 4 | ||||
-rw-r--r-- | src/model/light.h | 4 | ||||
-rw-r--r-- | src/model/map.cc | 8 | ||||
-rw-r--r-- | src/render/draw.cc | 69 | ||||
-rw-r--r-- | src/server/server.cc | 11 |
18 files changed, 113 insertions, 58 deletions
@@ -6,6 +6,8 @@ filesystem: model: split map loader from model + support map classes (e.g. func_rotate) + engine flare key core: connection to remote game (ok) @@ -26,6 +28,7 @@ network: rcon, commands zlib compression fix lag + protocol version in handshake client: input handler switching (ok) @@ -44,9 +47,12 @@ render: text quads render pipe + add small camera light, fix lighting without sun + win32 port: network not functional (ok) texture loading is broken (ok) screenshots are broken (ok) directory creation + diff --git a/osirion.kdevelop.pcs b/osirion.kdevelop.pcs Binary files differindex f1f2d2d..c991dc8 100644 --- a/osirion.kdevelop.pcs +++ b/osirion.kdevelop.pcs diff --git a/osirion.kdevses b/osirion.kdevses index e8415d1..2f81c5c 100644 --- a/osirion.kdevses +++ b/osirion.kdevses @@ -1,7 +1,26 @@ <?xml version = '1.0' encoding = 'UTF-8'?> <!DOCTYPE KDevPrjSession> <KDevPrjSession> - <DocsAndViews NumberOfDocuments="0" /> + <DocsAndViews NumberOfDocuments="6" > + <Doc0 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/gameconnection.cc" > + <View0 Encoding="" line="44" Type="Source" /> + </Doc0> + <Doc1 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/gameserver.cc" > + <View0 Encoding="" line="313" Type="Source" /> + </Doc1> + <Doc2 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/entity.cc" > + <View0 Encoding="" line="0" Type="Source" /> + </Doc2> + <Doc3 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/netconnection.cc" > + <View0 Encoding="" line="330" Type="Source" /> + </Doc3> + <Doc4 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/entity.h" > + <View0 Encoding="" line="44" Type="Source" /> + </Doc4> + <Doc5 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/netserver.cc" > + <View0 Encoding="" line="277" Type="Source" /> + </Doc5> + </DocsAndViews> <pluginList> <kdevdebugger> <breakpointList/> diff --git a/src/client/view.cc b/src/client/view.cc index aaf8210..660930b 100644 --- a/src/client/view.cc +++ b/src/client/view.cc @@ -21,6 +21,7 @@ #include "render/render.h" #include "render/textures.h" #include "core/core.h" +#include "core/stats.h" #include "math/mathlib.h" #include "sys/sys.h" @@ -153,6 +154,8 @@ void draw_status() stats << "tris " << std::setw(5) << render::Stats::tris << "\n"; stats << "quads " << std::setw(5) << render::Stats::quads << "\n"; } + stats << "tx "<< std::setw(5) << (core::Stats::network_bytes_sent >> 10) << "\n"; + stats << "rx "<< std::setw(5) << (core::Stats::network_bytes_received >> 10) << "\n"; draw_text(video::width-CHARWIDTH*12, CHARHEIGHT*2, stats); } diff --git a/src/core/Makefile.am b/src/core/Makefile.am index 33b4c44..7c18362 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -3,12 +3,13 @@ INCLUDES = -I$(top_srcdir)/src libcore_la_SOURCES = application.cc commandbuffer.cc core.cc cvar.cc entity.cc \ func.cc gameconnection.cc gameinterface.cc gameserver.cc module.cc netclient.cc \ - netconnection.cc netserver.cc player.cc + netconnection.cc netserver.cc player.cc stats.cc libcore_la_LDFLAGS = -avoid-version -no-undefined libcore_la_LIBADD = $(top_builddir)/src/filesystem/libfilesystem.la \ $(top_builddir)/src/math/libmath.la $(top_builddir)/src/sys/libsys.la $(top_builddir)/src/model/libmodel.la noinst_LTLIBRARIES = libcore.la noinst_HEADERS = application.h commandbuffer.h core.h cvar.h entity.h func.h \ - gameconnection.h gameinterface.h gameserver.h module.h net.h netconnection.h player.h + gameconnection.h gameinterface.h gameserver.h module.h net.h \ + netclient.h netconnection.h netserver.cc player.h stats.h diff --git a/src/core/entity.cc b/src/core/entity.cc index d05bef2..d2fef43 100644 --- a/src/core/entity.cc +++ b/src/core/entity.cc @@ -379,13 +379,16 @@ void EntityControlable::set_roll(float roll) EntityGlobe::EntityGlobe(unsigned int flags) : Entity(flags) { - entity_texture_id = 0; + render_texture = 0; entity_shape = Sphere; } EntityGlobe::EntityGlobe(std::istream & is) : Entity(is) { + render_texture = 0; + entity_shape = Sphere; + std::string n; char c; while ( (is.get(c)) && (c != '"')); diff --git a/src/core/entity.h b/src/core/entity.h index ba86c53..1e80435 100644 --- a/src/core/entity.h +++ b/src/core/entity.h @@ -315,7 +315,6 @@ public: ~EntityGlobe(); virtual void serialize(std::ostream & os) const; - /*----- inspectors ------------------------------------------------ */ @@ -325,7 +324,7 @@ public: std::string entity_texture; /// client side, texture id - unsigned int entity_texture_id; + unsigned int render_texture; }; } diff --git a/src/core/net.h b/src/core/net.h index a659a7f..3c49467 100644 --- a/src/core/net.h +++ b/src/core/net.h @@ -7,7 +7,6 @@ #ifndef __INCLUDED_CORE_NET_H__ #define __INCLUDED_CORE_NET_H__ -/// this namespace contains the network subsystem namespace core { diff --git a/src/core/netclient.cc b/src/core/netclient.cc index 0c0d72a..b90f164 100644 --- a/src/core/netclient.cc +++ b/src/core/netclient.cc @@ -10,6 +10,7 @@ #include "sys/sys.h" #include "core/net.h" #include "core/application.h" +#include "core/stats.h" namespace core { @@ -145,6 +146,7 @@ void NetClient::transmit(int serverfd) } sendq.erase(0, bytes_sent); + Stats::network_bytes_sent += bytes_sent; } sendq.clear(); diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc index fd590c0..dda339c 100644 --- a/src/core/netconnection.cc +++ b/src/core/netconnection.cc @@ -11,6 +11,7 @@ #include "core/gameconnection.h" #include "core/netconnection.h" #include "core/player.h" +#include "core/stats.h" namespace core { @@ -136,6 +137,7 @@ void NetConnection::receive() memset(recvbuf, '\0', BLOCKSIZE); bytes_received = ::recv(connection_fd, recvbuf, BLOCKSIZE-1, 0); + Stats::network_bytes_received += bytes_received; connection_timeout = core::application()->time(); if (bytes_received == 0) { @@ -249,6 +251,7 @@ void NetConnection::transmit() // assert (bytes_sent <= sendbuf.size()); sendq.erase(0, bytes_sent); + Stats::network_bytes_sent += bytes_sent; } connection_keepalive = application()->time(); diff --git a/src/core/netserver.cc b/src/core/netserver.cc index ca08def..3005922 100644 --- a/src/core/netserver.cc +++ b/src/core/netserver.cc @@ -28,6 +28,7 @@ #include "core/cvar.h" #include "core/func.h" #include "core/core.h" +#include "core/stats.h" #ifdef _WIN32 typedef int socklen_t; @@ -203,7 +204,8 @@ void NetServer::receive() } else { //con_debug << "Incoming data '" << recbuf << "'"<< bytes_received << " bytes" << std::endl; } - + Stats::network_bytes_received += bytes_received; + // originator std::string client_host (inet_ntoa(client_addr.sin_addr)); unsigned int client_port = ntohs(client_addr.sin_port); @@ -284,20 +286,10 @@ void NetServer::client_initialize(NetClient *client) { std::map<unsigned int, Entity *>::iterator it; for (it=Entity::registry.begin(); it != Entity::registry.end(); it++) { netmsg.str(""); - switch ((*it).second->type()) { - case Entity::Default: - case Entity::Dynamic: - case Entity::Controlable: - netmsg << "ent "; - (*it).second->serialize(netmsg); - netmsg << "\n"; - - client->send(netmsg.str()); - - break; - default: - break; - } + netmsg << "ent "; + (*it).second->serialize(netmsg); + netmsg << "\n"; + client->send(netmsg.str()); } netmsg.str("connect\n"); client->send(netmsg.str()); diff --git a/src/game/star.cc b/src/game/star.cc index 1d154fe..0a12593 100644 --- a/src/game/star.cc +++ b/src/game/star.cc @@ -10,7 +10,7 @@ namespace game { -Star::Star() : core::Entity(core::Entity::Static | core::Entity::Solid | core::Entity::Bright) +Star::Star() : core::EntityGlobe(core::Entity::Static | core::Entity::Solid | core::Entity::Bright) { entity_shape = core::Entity::Sphere; // a star is a sphere entity_color = math::Color(1,1,1,1); // white diff --git a/src/game/star.h b/src/game/star.h index e953f3c..ecc7ade 100644 --- a/src/game/star.h +++ b/src/game/star.h @@ -17,7 +17,7 @@ namespace game { /// a star, that shines so bright -class Star : public core::Entity { +class Star : public core::EntityGlobe { public: Star(); ~Star(); diff --git a/src/model/light.cc b/src/model/light.cc index f9f6b5c..f391a44 100644 --- a/src/model/light.cc +++ b/src/model/light.cc @@ -12,6 +12,7 @@ Light::Light() : light_location(), light_color(1.0f, 1.0f, 1.0f) { + light_entity = false; light_strobe = false; light_radius = 1.0f; light_frequency = 1.0f; @@ -21,6 +22,7 @@ Light::Light() : render_texture = 0; } +/* Light::Light(math::Vector3f const & location, math::Color const & color, bool strobe) : light_location(location), light_color(color) @@ -33,7 +35,7 @@ Light::Light(math::Vector3f const & location, math::Color const & color, bool st light_flare = 0; render_texture = 0; } - +*/ Light::~Light() {} diff --git a/src/model/light.h b/src/model/light.h index 9605497..b834623 100644 --- a/src/model/light.h +++ b/src/model/light.h @@ -29,6 +29,9 @@ public: /// true if this is a strobe light inline bool strobe() const { return light_strobe; } + /// true if this light has entity color + inline bool entity() const { return light_entity; } + /// size if the light, default is 1.0f inline float radius() const { return light_radius; } @@ -50,6 +53,7 @@ public: math::Vector3f light_location; math::Color light_color; bool light_strobe; + bool light_entity; float light_radius; float light_frequency; float light_offset; diff --git a/src/model/map.cc b/src/model/map.cc index 8b70b95..618db79 100644 --- a/src/model/map.cc +++ b/src/model/map.cc @@ -14,6 +14,11 @@ namespace model { +// function to test spawnflags +inline bool spawnflag_isset(unsigned int spawnflags, unsigned int flag) { + return ((spawnflags & flag) == flag); +} + Model * Map::load(std::string const &name) { // open the .map file @@ -49,7 +54,8 @@ Model * Map::load(std::string const &name) continue; } else if (mapfile.got_key_int("spawnflags", u)) { - light->light_strobe = ((u & 1) == 1); + light->light_strobe = spawnflag_isset(u, 1); + light->light_entity = spawnflag_isset(u, 2); } else if (mapfile.got_key_float("light", light->light_radius)) { light->light_radius /= 100.0f; diff --git a/src/render/draw.cc b/src/render/draw.cc index c0e21cc..1017746 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -57,6 +57,10 @@ inline bool test_drawfx_distance(core::Entity *entity) return ((entity->entity_renderstate & core::Entity::InCloseRange) == core::Entity::InCloseRange); } +// function to test flags +inline bool flag_is_set(unsigned int spawnflags, unsigned int flag) { + return ((spawnflags & flag) == flag); +} /* ----- Default Entity shapes ------------------------------------- */ @@ -202,15 +206,6 @@ void draw_model_engines(core::EntityControlable *entity) } -void draw_model_radius(core::Entity *entity) -{ - - math::Color color = entity->color(); - color.a = 0.25f; - - draw_sphere(color, entity->model()->radius()); -} - void draw_model_shield(core::EntityControlable *entity) { // shield rotation @@ -286,7 +281,16 @@ void pass_visibility() // entities within drawdistance entity->entity_renderstate = core::Entity::InRange; } - } + + } else if ((entity->type() == core::Entity::Globe) && flag_is_set(entity->flags(), core::Entity::Bright)) { + // bright globes set level light + GLfloat light_position[4]; + for (size_t i=0; i <3; i++) + light_position[i] = entity->location()[i]; + light_position[3] = 1.0f; + + glLightfv(GL_LIGHT0, GL_POSITION, light_position); + } } } @@ -303,20 +307,21 @@ void draw_pass_default() gl::translate(entity->location()); gl::multmatrix(entity->axis()); - if ((entity->flags() & core::Entity::Bright) == core::Entity::Bright) + if (flag_is_set(entity->flags(), core::Entity::Bright)) { gl::disable(GL_LIGHTING); + } switch(entity->shape()) { case core::Entity::Sphere: draw_entity_sphere(entity); break; - + case core::Entity::Diamond: - + case core::Entity::Axis: draw_entity_axis(entity); break; - + case core::Entity::Cube: default: @@ -324,8 +329,10 @@ void draw_pass_default() break; } - if ((entity->flags() & core::Entity::Bright) == core::Entity::Bright) - gl::enable(GL_LIGHTING); + if (flag_is_set(entity->flags(), core::Entity::Bright)) { + gl::enable(GL_LIGHTING); + } + gl::pop(); } } @@ -370,8 +377,8 @@ void draw_pass_model_evertex() } } -/* Draw model shields and engines */ -void draw_pass_model_fx() { +/* Draw model shields */ +void draw_pass_model_shields() { for (std::map<unsigned int, core::Entity *>::iterator it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) { @@ -385,7 +392,6 @@ void draw_pass_model_fx() { gl::translate(entity->location()); gl::multmatrix(entity->axis()); -// draw_model_engines((core::EntityControlable *)entity); draw_model_shield((core::EntityControlable *)entity); gl::pop(); } @@ -394,8 +400,8 @@ void draw_pass_model_fx() { } } -/* draw model lights */ -void draw_pass_model_lights() +/* draw model lights and engines */ +void draw_pass_model_fx() { float t; @@ -429,7 +435,12 @@ void draw_pass_model_lights() gl::begin(gl::Quads); } - math::Color color((*lit)->color()); + math::Color color; + if ((*lit)->entity()) { + color.assign(entity->color()); + } else { + color.assign((*lit)->color()); + } color.a = 0.8; gl::color(color); @@ -491,21 +502,20 @@ void draw_pass_model_lights() gl::disable(GL_TEXTURE_2D); } -void draw_pass_model_radius() +void draw_pass_model_corona() { if (!(r_radius && r_radius->value())) return; for (std::map<unsigned int, core::Entity *>::iterator it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) { - core::Entity *entity = (*it).second; if (test_draw_distance(entity)) { gl::push(); gl::translate(entity->location()); - - draw_model_radius(entity); - + math::Color color = entity->color(); + color.a = 0.25f; + draw_sphere(color, entity->model()->radius()); gl::pop(); } } @@ -603,13 +613,12 @@ void draw(math::Axis const &axis, math::Vector3f const &eye, math::Vector3f cons draw_pass_spacegrid(); // draw the blue spacegrid - draw_pass_model_fx(); // draw entity shield and engines - draw_pass_model_lights(); // draw entity lights + draw_pass_model_fx(); // draw entity lights and engines gl::enable(GL_LIGHTING); gl::enable(GL_RESCALE_NORMAL); - draw_pass_model_radius(); //draw entity radius + draw_pass_model_corona(); // draw entity radius and star corona glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); diff --git a/src/server/server.cc b/src/server/server.cc index 69e8923..1c95ee8 100644 --- a/src/server/server.cc +++ b/src/server/server.cc @@ -4,7 +4,11 @@ the terms and conditions of the GNU General Public License version 2 */ +#include <iostream> +#include <iomanip> + #include "core/core.h" +#include "core/stats.h" #include "server/console.h" #include "server/server.h" #include "server/timer.h" @@ -93,8 +97,12 @@ void Server::run() void Server::shutdown() { - con_debug << "Shutting down server..." << std::endl; + con_print << "Shutting down server..." << std::endl; + con_debug << "Network statistics:" << std::endl; + con_debug << " bytes sent " << std::setw(6) << core::Stats::network_bytes_sent / 1024 << " Kb" << std::endl; + con_debug << " bytes received " << std::setw(6) << core::Stats::network_bytes_received / 1024 << " Kb" << std::endl; + console::shutdown(); core::Application::shutdown(); @@ -107,6 +115,5 @@ void Server::quit(int status) core::Application::quit(status); } - } // namespace server |