Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2010-09-25 13:01:26 +0000
committerStijn Buys <ingar@osirion.org>2010-09-25 13:01:26 +0000
commitaeef4449ce3c1bdc531fb90699fef68bd48ca644 (patch)
tree969c2ec24f382a6a75e01b1b3315dd9fe8f26d46 /src/core
parent158706fac974527436a3167cfa94a7ea82070d41 (diff)
trading bugfixes: corrects client side screen update issues
Diffstat (limited to 'src/core')
-rw-r--r--src/core/inventory.cc1
-rw-r--r--src/core/item.cc15
-rw-r--r--src/core/netconnection.cc19
3 files changed, 20 insertions, 15 deletions
diff --git a/src/core/inventory.cc b/src/core/inventory.cc
index 7957294..28327a3 100644
--- a/src/core/inventory.cc
+++ b/src/core/inventory.cc
@@ -54,7 +54,6 @@ void Inventory::add(Item *item)
return;
}
inventory_items.push_back(item);
- inventory_dirty = true;
}
void Inventory::remove(Item *item)
diff --git a/src/core/item.cc b/src/core/item.cc
index e9d9f65..8ab4784 100644
--- a/src/core/item.cc
+++ b/src/core/item.cc
@@ -14,12 +14,17 @@ namespace core
/* ---- class Item ------------------------------------------------- */
+// Note: initializing the timestamp with 1 instead of 0 is a small hack
+// since cient-side inventory timestamps are initialized at 0, setting
+// the item timestamp to 0 would prevent the client from updating
+// the trade window the first time it is opened on a base
+
Item::Item(const Info *info)
{
item_info = info;
item_amount = 0;
item_price = info->price();
- set_timestamp(game() ? game()->timestamp() : 0);
+ set_timestamp(game() ? game()->timestamp() : 1);
}
Item::~Item()
@@ -31,25 +36,25 @@ Item::~Item()
void Item::set_amount(const long amount)
{
item_amount = amount;
- set_timestamp(game() ? game()->timestamp() : 0);
+ set_timestamp(game() ? game()->timestamp() : 1);
}
void Item::inc_amount(const long amount)
{
item_amount += amount;
- set_timestamp(game() ? game()->timestamp() : 0);
+ set_timestamp(game() ? game()->timestamp() : 1);
}
void Item::dec_amount(const long amount)
{
item_amount -= amount;
- set_timestamp(game() ? game()->timestamp() : 0);
+ set_timestamp(game() ? game()->timestamp() : 1);
}
void Item::set_price(const long price)
{
item_price = price;
- set_timestamp(game() ? game()->timestamp() : 0);
+ set_timestamp(game() ? game()->timestamp() : 1);
}
void Item::set_timestamp(const unsigned long timestamp)
diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc
index 11e23c9..3318c1e 100644
--- a/src/core/netconnection.cc
+++ b/src/core/netconnection.cc
@@ -432,7 +432,7 @@ void NetConnection::send_info_request(Info *info)
msg << "inf " << info->id() << "\n";
this->send_raw(msg.str());
- info->set_timestamp(timestamp());
+ info->set_timestamp(application()->timestamp());
}
// send an inventory update request
@@ -871,9 +871,9 @@ void NetConnection::parse_incoming_message(const std::string & message)
info->receive_server_update(msgstream);
//info->clear_timestamp();
- info->set_timestamp(timestamp());
+ info->set_timestamp(application()->timestamp());
- //con_debug << "Received info for " << info->id() << " " << info->type()->label() << ":" << info->label() << std::endl;
+ //con_debug << "CLIENT info for " << info->id() << " " << info->type()->label() << ":" << info->label() << " timestamp " << info->timestamp() << std::endl;
} else if (command.compare("inv") == 0) {
@@ -897,9 +897,8 @@ void NetConnection::parse_incoming_message(const std::string & message)
return;
}
- //con_debug << "CLIENT received inv message for entity " << id << " server timestamp " << server_timestamp << " client timestamp " << entity->inventory()->timestamp() << std::endl;
-
-
+ //con_debug << "CLIENT received inv message for entity " << id << " client timestamp " << entity->inventory()->timestamp() << " server timestamp " << server_timestamp << std::endl;
+
if (server_timestamp < entity->inventory()->timestamp())
return;
@@ -907,7 +906,7 @@ void NetConnection::parse_incoming_message(const std::string & message)
if (!(msgstream >> nbitems))
nbitems = 0;
- //con_debug << "CLIENT number of items: " << nbitems << std::endl;
+ //con_debug << "CLIENT number of items: " << nbitems << std::endl;
for (size_t i = 0; i < nbitems; i++) {
if (!(msgstream >> id)) {
con_warn << "Received inventory update without info id for existing entity " << id << "!" << std::endl;
@@ -922,9 +921,11 @@ void NetConnection::parse_incoming_message(const std::string & message)
}
item->receive_server_update(msgstream);
}
-
- entity->inventory()->set_timestamp(server_timestamp);
+
entity->inventory()->recalculate();
+ entity->inventory()->set_timestamp(server_timestamp);
+
+ //con_debug << "CLIENT inventory updated timestamp " << entity->inventory()->timestamp() << " for " << nbitems << " items" << std::endl;
}
}