Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/entity.cc14
-rw-r--r--src/core/gameserver.cc6
-rw-r--r--src/core/netclient.cc5
-rw-r--r--src/core/netserver.cc2
4 files changed, 20 insertions, 7 deletions
diff --git a/src/core/entity.cc b/src/core/entity.cc
index 475af39..b186c64 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -231,13 +231,19 @@ void EntityDynamic::recieve_client_update(std::istream &is)
void EntityDynamic::serialize_server_update(std::ostream & os) const
{
- os << entity_location << " " << entity_axis << " " << entity_speed;
+ os << entity_location << " ";
+ os << entity_axis.forward() << " ";
+ os << entity_axis.left() << " ";
+ os << entity_axis.up() << " ";
+ os << entity_speed;
}
void EntityDynamic::recieve_server_update(std::istream &is)
{
is >> entity_location;
- is >> entity_axis;
+ is >> entity_axis[0];
+ is >> entity_axis[1];
+ is >> entity_axis[2];
is >> entity_speed;
}
@@ -253,6 +259,7 @@ EntityControlable::EntityControlable(Player *player, unsigned int flags) :
target_direction = 0.0f;
target_thrust = 0.0f;
+ target_pitch = 0.0f;
}
EntityControlable::EntityControlable(std::istream & is) :
@@ -285,13 +292,16 @@ void EntityControlable::serialize_client_update(std::ostream & os) const
{
EntityDynamic::serialize_client_update(os);
os << " " << target_direction;
+ os << " " << target_pitch;
os << " " << target_thrust;
+
}
void EntityControlable::recieve_client_update(std::istream &is)
{
EntityDynamic::recieve_client_update(is);
is >> target_direction;
+ is >> target_pitch;
is >> target_thrust;
}
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index 1aa57f0..2169e21 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -143,7 +143,7 @@ void GameServer::say(Player *player, std::string const &message)
con_print <<player->name() << ": " << message << "\n";
// broadcast to remote clients
- if (server_network != 0 ) {
+ if (server_network) {
std::string netmessage("msg public ");
netmessage.append(player->name());
netmessage.append(": ");
@@ -286,12 +286,14 @@ void GameServer::frame(float seconds)
if (entity->entity_destroyed) {
if (!entity->entity_created) {
std::ostringstream netmsg;
+ netmsg.str("");
netmsg << "die " << entity->id() << "\n";
server_network->broadcast(netmsg.str());
}
core::Entity::remove(entity->id());
} else if (entity->entity_created) {
std::ostringstream netmsg;
+ netmsg.str("");
netmsg << "ent ";
entity->serialize(netmsg);
netmsg << "\n";
@@ -300,9 +302,11 @@ void GameServer::frame(float seconds)
} else if (entity->dirty()) {
std::ostringstream netmsg;
+ netmsg.str("");
netmsg << "sup " << entity->id() << " ";
entity->serialize_server_update(netmsg);
netmsg << "\n";
+ netmsg.flush();
server_network->broadcast(netmsg.str());
}
entity->entity_dirty = false;
diff --git a/src/core/netclient.cc b/src/core/netclient.cc
index c910e26..0c0d72a 100644
--- a/src/core/netclient.cc
+++ b/src/core/netclient.cc
@@ -121,7 +121,6 @@ void NetClient::send(std::string const &msg)
void NetClient::transmit(int serverfd)
{
-
if (!sendq.size()) {
if (client_keepalive + NETTIMEOUT/2 < application()->time()) {
sendq.assign("ping\n");
@@ -129,7 +128,7 @@ void NetClient::transmit(int serverfd)
return;
}
} else if (sendq.size() >= FRAMESIZE) {
- con_warn << "Outgoing message exceeds " << FRAMESIZE << " bytes!\n";
+ con_warn << "Outgoing message exceeds " << FRAMESIZE -1 << " bytes!\n";
//sendq.clear();
//return;
}
@@ -137,7 +136,7 @@ void NetClient::transmit(int serverfd)
ssize_t bytes_sent = 0;
while (sendq.size() && !error()) {
- bytes_sent = ::sendto(serverfd, sendq.c_str(), sendq.size(), 0,
+ bytes_sent = ::sendto(serverfd, sendq.c_str(), sendq.size()+1, 0,
(struct sockaddr *)&client_addr, sizeof(client_addr));
if (bytes_sent < 0) {
diff --git a/src/core/netserver.cc b/src/core/netserver.cc
index 8b9cbe5..064229b 100644
--- a/src/core/netserver.cc
+++ b/src/core/netserver.cc
@@ -178,7 +178,7 @@ void NetServer::receive()
timeval timeout;
timeout.tv_sec = 0;
- timeout.tv_usec = 0;
+ timeout.tv_usec = 25000;
fd_set readset = serverset;
int nb = select(fd()+1, &readset, NULL, NULL, &timeout);