Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2010-09-22 21:32:34 +0000
committerStijn Buys <ingar@osirion.org>2010-09-22 21:32:34 +0000
commita6f9773c358dd7d091ff64cbda504ab8d8066dd3 (patch)
tree226e23c4656957e908623ccda9d3d1c50240a0b4 /src/core/gameconnection.cc
parentbbb43d1c15f2858573f5abb595aa62f8224e4d76 (diff)
full trading support for networked games
Diffstat (limited to 'src/core/gameconnection.cc')
-rw-r--r--src/core/gameconnection.cc53
1 files changed, 11 insertions, 42 deletions
diff --git a/src/core/gameconnection.cc b/src/core/gameconnection.cc
index 3167790..f64c8fb 100644
--- a/src/core/gameconnection.cc
+++ b/src/core/gameconnection.cc
@@ -91,7 +91,7 @@ bool GameConnection::interactive() const
return true;
}
-Info *GameConnection::info(unsigned int id)
+Info *GameConnection::request_info(const unsigned int id)
{
if (!id) {
con_warn << "Information requested for illegal id 0!" << std::endl;
@@ -104,12 +104,11 @@ Info *GameConnection::info(unsigned int id)
info = new Info(id);
}
- if ( !info->timestamp() || (connection_timestamp < info->timestamp() + INFOTIMEOUT) )
+ if (info->type() || (connection_timestamp < info->timestamp() + INFOTIMEOUT) )
return info;
// send an information request to the server
if (connection_network) {
- info->set_timestamp(connection_timestamp);
connection_network->send_info_request(info);
connection_network->transmit();
} else {
@@ -119,51 +118,21 @@ Info *GameConnection::info(unsigned int id)
return info;
}
-/*
-Info *GameConnection::info(const std::string &type, const std::string &label)
+Inventory *GameConnection::request_inventory(Entity *entity)
{
- if (!type.size()) {
- con_warn << "Information requested with empty type label!" << std::endl;
- return 0;
- }
-
- if (!label.size()) {
- con_warn << "Information requested with empty label!" << std::endl;
+ if (!entity) {
+ con_warn << "Inventory request for NULL entity" << std::endl;
return 0;
}
- // find the info record type
- InfoType *infotype = InfoType::find(type);
- if (!infotype) {
- // create a new info record type and set the label
- infotype = new InfoType(type.c_str());
- }
-
- // find the info record
- Info *info = Info::find(infotype, label);
- if (info) {
- if (!info->timestamp() || (connection_timestamp - info->timestamp()) < INFOTIMEOUT)
- return info;
- } else {
- // create a new info record and set the label
- info = new Info(infotype, label);
- info->add_text("Requesting information...");
- }
-
- // send an information request to the server
- if (connection_network) {
- //con_debug << "Requesting info for " << info->type()->label() << ":" << info->label() << std::endl;
- info->set_timestamp(connection_timestamp);
- connection_network->send_info_request(info);
+ if (entity->inventory() && connection_network) {
+ connection_network->send_inventory_request(entity);
connection_network->transmit();
- } else {
- info->add_text("^RNot connected.");
- info->set_timestamp(0);
- }
- return info;
+ }
+
+ return (entity->inventory());
}
-*/
-
+
void GameConnection::abort()
{
connection_running = false;