Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am4
-rw-r--r--src/client/client.cc5
-rw-r--r--src/core/entity.cc6
-rw-r--r--src/core/entity.h6
-rw-r--r--src/core/net.h2
-rw-r--r--src/core/netserver.cc14
-rw-r--r--src/core/player.cc13
-rw-r--r--src/core/player.h12
-rw-r--r--src/game/game.cc21
-rw-r--r--src/math/color.h17
-rw-r--r--src/model/map.cc12
-rw-r--r--src/render/draw.cc16
12 files changed, 95 insertions, 33 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index b192682..15dfcb9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -30,9 +30,9 @@ osiriond_LDADD = $(top_builddir)/src/auxiliary/libauxiliary.la \
# client
osirion_SOURCES = osirion.cc
EXTRA_osirion_SOURCES = osirion-res.rc
-osirion_DEPENDENCIES = $(ICON_CLIENT) \
+osirion_DEPENDENCIES = $(ICON_CLIENT) $(top_builddir)/src/core/libcore.la \
$(top_builddir)/src/audio/libaudio.la $(top_builddir)/src/render/librender.la \
- $(top_builddir)/src/client/libclient.la
+ $(top_builddir)/src/client/libclient.la $(top_builddir)/src/game/libgame.la
osirion_CFLAGS = $(LIBSDL_CFLAGS) $(GL_CFLAGS) $(GLUT_CFLAGS)
osirion_LDADD = $(top_builddir)/src/game/libgame.la \
$(top_builddir)/src/client/libclient.la $(top_builddir)/src/audio/libaudio.la \
diff --git a/src/client/client.cc b/src/client/client.cc
index 7951577..9db7f7e 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -82,7 +82,10 @@ void Client::init(int count, char **arguments)
cvar->set_info("[str] player name");
cvar = core::Cvar::get("cl_color", "1.0 1.0 1.0", core::Cvar::Archive | core::Cvar::Info);
- cvar->set_info("[r g b] player color");
+ cvar->set_info("[r g b] player primary color");
+
+ cvar = core::Cvar::get("cl_colorsecond", "1.0 1.0 1.0", core::Cvar::Archive | core::Cvar::Info);
+ cvar->set_info("[r g b] player secondary color");
cl_framerate = core::Cvar::get("cl_framerate", "120", core::Cvar::Archive);
cl_framerate->set_info("[int] client framerate in frames/sec");
diff --git a/src/core/entity.cc b/src/core/entity.cc
index a0b859b..bc1c698 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -80,7 +80,8 @@ void Entity::list()
Entity::Entity(unsigned int flags) :
entity_location(0.0f, 0.0f, 0.0f),
- entity_color(1.0f, 1.0f, 1.0f, 1.0f)
+ entity_color(1.0f, 1.0f, 1.0f, 1.0f),
+ entity_color_second(1.0f, 1.0f, 1.0f, 1.0f)
{
entity_id = 0;
entity_flags = flags;
@@ -114,6 +115,7 @@ Entity::Entity(std::istream & is)
is >> entity_flags;
is >> entity_location;
is >> entity_color;
+ is >> entity_color_second;
is >> s; // shape
entity_shape = (Shape) s;
@@ -153,7 +155,6 @@ Entity::Entity(std::istream & is)
// this entity is created clientside
entity_clientstate = 0;
-
add(this, entity_id);
}
@@ -171,6 +172,7 @@ void Entity::serialize(std::ostream & os) const
<< entity_flags << " "
<< entity_location << " "
<< entity_color << " "
+ << entity_color_second << " "
<< entity_shape << " "
<< entity_radius << " "
<< entity_axis.forward() << " "
diff --git a/src/core/entity.h b/src/core/entity.h
index bf35bfe..0b25dad 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -92,9 +92,12 @@ public:
/// local coordinate system of the entity
inline math::Axis & axis() { return entity_axis; }
- /// base color of the entity
+ /// primary color of the entity
inline math::Color const & color() const { return entity_color; }
+ /// secondary
+ inline math::Color const & color_second() const { return entity_color_second; }
+
/// base shape of the entity
inline Shape shape() const { return entity_shape; }
@@ -153,6 +156,7 @@ public:
model::Model *entity_model;
Shape entity_shape;
math::Color entity_color;
+ math::Color entity_color_second;
unsigned int entity_moduletypeid;
unsigned int entity_flags;
diff --git a/src/core/net.h b/src/core/net.h
index 2ca81fe..177aa14 100644
--- a/src/core/net.h
+++ b/src/core/net.h
@@ -11,7 +11,7 @@ namespace core
{
/// network protocol version
-const unsigned int PROTOCOLVERSION = 1;
+const unsigned int PROTOCOLVERSION = 2;
/// maximum lenght of a (compressed) network message block
const unsigned int FRAMESIZE = 1152;
diff --git a/src/core/netserver.cc b/src/core/netserver.cc
index 065d695..2d59788 100644
--- a/src/core/netserver.cc
+++ b/src/core/netserver.cc
@@ -493,12 +493,20 @@ void NetServer::parse_incoming_message(NetClient *client, const std::string & me
unsigned int protover;
if (msgstream >> protover) {
if (protover != PROTOCOLVERSION) {
+ // set protocol version mismatch notification
std::stringstream netmsgstream("");
- netmsgstream << "Protocol version mismatch: ";
+ netmsgstream << "^WProtocol version mismatch: ";
netmsgstream << "client " << protover << " server " << PROTOCOLVERSION << "!\n";
con_print << client->host() << ":" << client->port() << " " << netmsgstream.str() << std::endl;
- server()->send(client->player(), netmsgstream.str());
+ send_message(client, "info", netmsgstream.str());
+
+ netmsgstream.str("disconnect\n");
+ netmsgstream.clear();
+
+ client->send(netmsgstream.str());
+ client->transmit(fd());
+ client->abort();
} else {
client_initialize(client);
}
@@ -506,7 +514,7 @@ void NetServer::parse_incoming_message(NetClient *client, const std::string & me
std::string message("Unknown client protocol version!");
con_print << client->host() << ":" << client->port() << " " << message << std::endl;
server()->send(client->player(), message);
- client->abort();
+
}
return;
}
diff --git a/src/core/player.cc b/src/core/player.cc
index 4ad2c3a..18dabed 100644
--- a/src/core/player.cc
+++ b/src/core/player.cc
@@ -59,18 +59,27 @@ void Player::update_info()
if (cl_color) {
std::istringstream is(cl_color->str());
if (is >> color)
- player_color = color;
+ player_color.assign(color);
+ }
+
+ Cvar *cl_color_second = Cvar::find("cl_colorsecond");
+ math::Color color_second(1.0, 1.0, 1.0, 1.0);
+ if (cl_color_second) {
+ std::istringstream is(cl_color_second->str());
+ if (is >> color_second)
+ player_color_second.assign(color_second);
}
}
void Player::serialize_client_update(std::ostream & os)
{
- os << " " << player_color << " \"" << player_name << "\"";
+ os << " " << player_color << " " << player_color_second << " \"" << player_name << "\"";
}
void Player::recieve_client_update(std::istream &is)
{
is >> player_color;
+ is >> player_color_second;
std::string n;
char c;
diff --git a/src/core/player.h b/src/core/player.h
index fa13b22..e37c577 100644
--- a/src/core/player.h
+++ b/src/core/player.h
@@ -44,9 +44,12 @@ public:
/// the entity the Player is currently controling
inline EntityControlable *control() const { return player_control; }
- /// player base color
+ /// player primary color
inline math::Color const & color() const { return player_color; }
+ /// player secondary color
+ inline math::Color const & color_second() const { return player_color_second; }
+
/// player has been muted by admin or console
inline bool mute() const { return player_mute; }
@@ -93,12 +96,15 @@ public:
/// id of the player
int player_id;
- // name of the player
+ /// name of the player
std::string player_name;
- /// player color
+ /// player primary color
math::Color player_color;
+ /// player secondary color
+ math::Color player_color_second;
+
/// player is muted by admin
bool player_mute;
diff --git a/src/game/game.cc b/src/game/game.cc
index 50ac3ec..8fe2ad4 100644
--- a/src/game/game.cc
+++ b/src/game/game.cc
@@ -98,6 +98,7 @@ void func_buy(core::Player *player, std::string const &args)
player->player_control = new Ship(player, shipmodel);
player->control()->entity_color = player->color();
+ player->control()->entity_color_second = player->color_second();
core::server()->broadcast("^B" + player->name() + " ^Bpurchased " + aux::article(shipmodel->name()));
core::server()->send_sound(player, "game/buy-ship");
@@ -200,7 +201,6 @@ void Game::init()
con_warn << worldini.name() << " unknown key '" << worldini.key() << "' at line " << worldini.line() << std::endl;
} else if (worldini.section().compare("entity") == 0) {
-
std::string shapename;
if (worldini.got_key_string("shape", shapename)) {
if (shapename.compare("axis") == 0) {
@@ -215,13 +215,13 @@ void Game::init()
con_warn << worldini.name() << " unknown shape '" << shapename << "' at line " << worldini.line() << std::endl;
}
continue;
- } else if (worldini.got_key_string("label", entity->entity_label))
+ } else if (worldini.got_key_string("label", entity->entity_label)) {
continue;
- else if (worldini.got_key_string("name", entity->entity_name))
+ } else if (worldini.got_key_string("name", entity->entity_name)) {
continue;
- else if (worldini.got_key_string("model", entity->entity_modelname))
+ } else if (worldini.got_key_string("model", entity->entity_modelname)) {
continue;
- else if (worldini.got_key_angle("direction", direction)) {
+ } else if (worldini.got_key_angle("direction", direction)) {
entity->axis().change_direction(direction);
continue;
} else if (worldini.got_key_angle("pitch", pitch)) {
@@ -230,14 +230,17 @@ void Game::init()
} else if (worldini.got_key_angle("roll", roll)) {
entity->axis().change_roll(roll);
continue;
- } else if (worldini.got_key_angle("radius", entity->entity_radius))
+ } else if (worldini.got_key_angle("radius", entity->entity_radius)) {
continue;
- else if (worldini.got_key_vector3f("location", entity->entity_location))
+ } else if (worldini.got_key_vector3f("location", entity->entity_location)) {
continue;
- else if (worldini.got_key_color("color", entity->entity_color))
+ } else if (worldini.got_key_color("color", entity->entity_color)) {
continue;
- else
+ } else if (worldini.got_key_color("colorsecond", entity->entity_color_second)) {
+ continue;
+ } else {
con_warn << worldini.name() << " unknown key '" << worldini.key() << "' at line " << worldini.line() << std::endl;
+ }
}
} else if (worldini.got_section("star")) {
star = new Star();
diff --git a/src/math/color.h b/src/math/color.h
index 4f3df16..c938708 100644
--- a/src/math/color.h
+++ b/src/math/color.h
@@ -49,7 +49,22 @@ public:
/// multiply rgb values with scalar value.
Color & operator*=(const float scalar);
- inline float operator[](size_t index) const { return rgba_data[index]; }
+ /// assign a value to an element of this color
+ /*! WARNING: range is not checked
+ * @param index the index of the element to assign to ( 0 <= index < 4 )
+ */
+ inline float& operator[](const size_t index) {
+ return rgba_data[index];
+ }
+
+ /// returns the value of an element of this color
+ /*! WARNING: range is not checked
+ * @param index the index of the element to return ( 0 <= index < 4 )
+ */
+ inline float operator[](const size_t index) const {
+ return rgba_data[index];
+ }
+
/// pointer to the internal data
inline float *ptr() const { return (float *) rgba_data; };
diff --git a/src/model/map.cc b/src/model/map.cc
index 405ce98..ad569eb 100644
--- a/src/model/map.cc
+++ b/src/model/map.cc
@@ -462,21 +462,21 @@ void Map::make_brushface(Plane *face)
} else if (face->texture().compare("colors/blue") == 0) {
color.assign(0, 0, 1);
- } else if ((face->texture().compare("common/entity") == 0) || (face->texture().compare("common/primary") == 0)) {
+ } else if (face->texture().compare("common/entity") == 0) {
material |= Material::Primary;
- } else if (face->texture().compare("common/primary_dark") == 0) {
+ } else if (face->texture().compare("common/entity_dark") == 0) {
material |= Material::Primary;
material |= Material::Dark;
- } else if (face->texture().compare("common/secundary") == 0) {
+ } else if (face->texture().compare("common/entity_second") == 0) {
material |= Material::Secondary;
- } else if (face->texture().compare("common/secundary_dark") == 0) {
+ } else if (face->texture().compare("common/entity_second_dark") == 0) {
material |= Material::Secondary;
material |= Material::Dark;
- } else if (face->texture().compare("common/tertiary") == 0) {
+ } else if (face->texture().compare("common/entity_third") == 0) {
material |= Material::Tertiary;
- } else if (face->texture().compare("common/tertiary_dark") == 0) {
+ } else if (face->texture().compare("common/entity_thirdy_dark") == 0) {
material |= Material::Tertiary;
material |= Material::Dark;
}
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 54a56a0..47f0d7a 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -296,11 +296,23 @@ void draw_model_fragments(core::Entity *entity)
use_color_array = false;
glDisableClientState(GL_COLOR_ARRAY);
}
- // FIXME Primary, Secondary Tertiary color
- math::Color color(entity->color());
+
+ math::Color color;
+
+ if ((material & Material::Tertiary) == Material::Tertiary) {
+ for (size_t i = 0; i < 3; i++)
+ color[i] = (entity->color()[i] + entity->color_second()[i]) / 2;
+
+ } else if ((material & Material::Secondary) == Material::Secondary) {
+ color.assign(entity->color_second());
+
+ } if ((material & Material::Primary) == Material::Primary) {
+ color.assign(entity->color());
+ }
if (material & Material::Dark)
color *= 0.5f;
+
gl::color(color);
} else {