From aaa4ff61f7b17759c4f4ccb3ac9011dd5f8a93f5 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Thu, 24 Jul 2008 00:47:13 +0000 Subject: primary, secondary, tertiary color rendering --- src/core/entity.cc | 6 ++++-- src/core/entity.h | 6 +++++- src/core/net.h | 2 +- src/core/netserver.cc | 14 +++++++++++--- src/core/player.cc | 13 +++++++++++-- src/core/player.h | 12 +++++++++--- 6 files changed, 41 insertions(+), 12 deletions(-) (limited to 'src/core') 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; -- cgit v1.2.3