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-16 14:12:27 +0000
committerStijn Buys <ingar@osirion.org>2010-09-16 14:12:27 +0000
commit0c509866a37ab47ff0e48d357ca55e31658c37c2 (patch)
tree57f69397ac1b30ce42a3e3fcd19c2fd8ed67d4e0 /src/core
parent3392cb739f212aea561eceb1781cd2e10e55c932 (diff)
map info support, initial trade window
Diffstat (limited to 'src/core')
-rw-r--r--src/core/entity.cc12
-rw-r--r--src/core/entity.h4
-rw-r--r--src/core/gameserver.cc6
-rw-r--r--src/core/parser.cc18
-rw-r--r--src/core/parser.h11
5 files changed, 48 insertions, 3 deletions
diff --git a/src/core/entity.cc b/src/core/entity.cc
index aa9e45b..baefcea 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -204,6 +204,10 @@ void Entity::clear_updates()
void Entity::set_info(Info *info)
{
entity_info = info;
+ if (entity_info) {
+ entity_info->set_model(model());
+ entity_info->set_name(name());
+ }
}
void Entity::set_inventory(Inventory *inventory)
@@ -237,7 +241,13 @@ void Entity::set_model(model::Model *model)
entity_model = model;
if (entity_model) {
entity_radius = entity_model->radius();
- entity_modelname = entity_model->name();
+ entity_modelname.assign(entity_model->name());
+ } else {
+ entity_modelname.clear();
+ }
+
+ if (entity_info) {
+ entity_info->set_model(entity_model);
}
}
diff --git a/src/core/entity.h b/src/core/entity.h
index 5ddce3a..6a7fa7e 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -162,12 +162,12 @@ public:
}
///entity inventory
- inline Inventory *inventory() {
+ inline Inventory *inventory() const {
return entity_inventory;
}
/// entity info
- inline const Info *info() const {
+ inline Info *info() const {
return entity_info;
}
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index 2e848e0..4181824 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -13,6 +13,7 @@
#include "core/func.h"
#include "core/gameserver.h"
#include "core/loader.h"
+#include "core/parser.h"
#include "core/netserver.h"
#include "filesystem/filesystem.h"
#include "sys/sys.h"
@@ -127,7 +128,10 @@ GameServer::GameServer() : GameInterface()
server_maxplayerid = 1;
server_startup = application()->timestamp();
+ Parser::init();
+
server_module = Loader::init();
+
if (!server_module) {
con_error << "No module loaded.\n";
abort();
@@ -223,6 +227,8 @@ GameServer::~GameServer()
*/
Func::remove("time");
Func::remove("who");
+
+ Parser::done();
server_instance = 0;
}
diff --git a/src/core/parser.cc b/src/core/parser.cc
index c5e0a38..7ef44d9 100644
--- a/src/core/parser.cc
+++ b/src/core/parser.cc
@@ -11,6 +11,17 @@
namespace core
{
+InfoType *Parser::entity_infotype = 0;
+
+void Parser::init()
+{
+ entity_infotype = new InfoType("entity");
+}
+
+void Parser::done()
+{
+ entity_infotype = 0;
+}
bool Parser::got_entity_key(filesystem::IniFile &inifile, core::Entity *entity)
{
@@ -47,6 +58,13 @@ bool Parser::got_entity_key(filesystem::IniFile &inifile, core::Entity *entity)
return false;
}
+ } else if (inifile.got_key_string("info", strval)) {
+ if (!entity->info()) {
+ entity->set_info(new Info(entity_infotype, entity->label().c_str()));
+ }
+ entity->info()->add_text(strval);
+ return true;
+
} else if (inifile.got_key_string("label", strval)) {
entity->set_label(strval);
return true;
diff --git a/src/core/parser.h b/src/core/parser.h
index 06ddc27..993c307 100644
--- a/src/core/parser.h
+++ b/src/core/parser.h
@@ -18,8 +18,19 @@ namespace core
class Parser
{
public:
+ /// initialize parser infotypes
+ static void init();
+
+ /// clean up parser internals
+ static void done();
+
/// read default entity keys from an ini file
static bool got_entity_key(filesystem::IniFile &inifile, core::Entity *entity);
+
+private:
+ /// default infotype for entities
+ static InfoType *entity_infotype;
+
};
}