diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/entity.cc | 12 | ||||
-rw-r--r-- | src/core/entity.h | 13 | ||||
-rw-r--r-- | src/core/gameserver.cc | 5 | ||||
-rw-r--r-- | src/core/parser.cc | 14 | ||||
-rw-r--r-- | src/core/parser.h | 11 | ||||
-rw-r--r-- | src/game/base/cargo.cc | 5 | ||||
-rw-r--r-- | src/game/base/cargo.h | 2 | ||||
-rw-r--r-- | src/game/base/faction.cc | 5 | ||||
-rw-r--r-- | src/game/base/faction.h | 2 | ||||
-rw-r--r-- | src/game/base/game.cc | 30 | ||||
-rw-r--r-- | src/game/base/jumppoint.cc | 29 | ||||
-rw-r--r-- | src/game/base/ship.cc | 2 | ||||
-rw-r--r-- | src/game/base/shipmodel.cc | 11 | ||||
-rw-r--r-- | src/game/base/shipmodel.h | 12 | ||||
-rw-r--r-- | src/game/base/template.cc | 7 | ||||
-rw-r--r-- | src/game/base/template.h | 2 |
16 files changed, 120 insertions, 42 deletions
diff --git a/src/core/entity.cc b/src/core/entity.cc index 7f48c08..9e467fe 100644 --- a/src/core/entity.cc +++ b/src/core/entity.cc @@ -29,6 +29,8 @@ using math::Vector3f; /* ---- Static functions for the Entity registry ------------------- */ +const InfoType *Entity::entity_infotype = 0; + Entity::Registry Entity::entity_registry; size_t Entity::entity_nextid = 0; @@ -314,7 +316,9 @@ void Entity::set_model(model::Model *model) // server-side property should not clear modelname entity_model = model; if (entity_model) { - entity_radius = entity_model->radius(); + + //entity_radius = entity_model->radius(); + entity_modelname.assign(entity_model->name()); } @@ -502,6 +506,10 @@ void Entity::remove_menu(std::string const &label) void Entity::reset() { + if (!radius()) { + return; + } + // location and orientation btTransform t; t.setIdentity(); @@ -918,7 +926,7 @@ void EntityControlable::set_zone(Zone *zone) if (entity_zone) { entity_zone->add(this); - if (body() && entity_zone->physics()) { + if (body() && entity_zone->physics()) { entity_zone->physics()->addRigidBody(body()); entity_zone->physics()->addAction(entity_actioninterface); reset(); diff --git a/src/core/entity.h b/src/core/entity.h index 48dd949..1996e10 100644 --- a/src/core/entity.h +++ b/src/core/entity.h @@ -402,6 +402,16 @@ public: virtual void serialize_server_update(std::ostream & os) const; /* ---- static --------------------------------------------- */ + + /// default infotype for entities + static inline const InfoType *infotype() { + return entity_infotype; + } + + /// set the default infotype for entities + static inline void set_infotype(const InfoType *infotype) { + entity_infotype = infotype; + } /// type definition for the entity registry typedef std::map<unsigned int, Entity*> Registry; @@ -492,6 +502,9 @@ private: static size_t entity_nextid; static void add(Entity *ent); + + static const InfoType *entity_infotype; + }; diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc index 5ea6206..7d6fc96 100644 --- a/src/core/gameserver.cc +++ b/src/core/gameserver.cc @@ -130,7 +130,8 @@ GameServer::GameServer() : GameInterface() server_maxplayerid = 1; server_startup = application()->timestamp(); - Parser::init(); + // create the default infotype for entities + Entity::set_infotype(new InfoType("entity")); Physics::init(); @@ -237,7 +238,7 @@ GameServer::~GameServer() Physics::done(); - Parser::done(); + Entity::set_infotype(0); server_instance = 0; } diff --git a/src/core/parser.cc b/src/core/parser.cc index 3806b99..953cd50 100644 --- a/src/core/parser.cc +++ b/src/core/parser.cc @@ -11,18 +11,6 @@ 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) { math::Vector3f v; @@ -60,7 +48,7 @@ bool Parser::got_entity_key(filesystem::IniFile &inifile, core::Entity *entity) } else if (inifile.got_key_string("info", strval)) { if (!entity->info()) { - entity->set_info(new Info(entity_infotype, entity->label().c_str())); + entity->set_info(new Info(Entity::infotype(), entity->label().c_str())); } entity->info()->add_text(strval); return true; diff --git a/src/core/parser.h b/src/core/parser.h index 993c307..06ddc27 100644 --- a/src/core/parser.h +++ b/src/core/parser.h @@ -18,19 +18,8 @@ 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; - }; } diff --git a/src/game/base/cargo.cc b/src/game/base/cargo.cc index 41cce1b..e75064e 100644 --- a/src/game/base/cargo.cc +++ b/src/game/base/cargo.cc @@ -104,6 +104,11 @@ bool Cargo::init() return true; } +void Cargo::done() +{ + core::Func::remove("list_cargo"); +} + /* ---- class Cargo -------------------------------------------- */ Cargo::Cargo() : core::Info(cargo_infotype) diff --git a/src/game/base/cargo.h b/src/game/base/cargo.h index bee0502..4d90611 100644 --- a/src/game/base/cargo.h +++ b/src/game/base/cargo.h @@ -29,6 +29,8 @@ public: static bool init(); + static void done(); + static void list(); static inline const core::InfoType *infotype() { diff --git a/src/game/base/faction.cc b/src/game/base/faction.cc index 2194844..6fb70cf 100644 --- a/src/game/base/faction.cc +++ b/src/game/base/faction.cc @@ -108,6 +108,11 @@ bool Faction::init() return true; } +void Faction::done() +{ + core::Func::remove("list_faction"); +} + Faction::Faction() : core::Info(faction_infotype), faction_color(), diff --git a/src/game/base/faction.h b/src/game/base/faction.h index 608f7c7..997b6fc 100644 --- a/src/game/base/faction.h +++ b/src/game/base/faction.h @@ -54,6 +54,8 @@ public: */ static bool init(); + static void done(); + /** * @brief list available factions */ diff --git a/src/game/base/game.cc b/src/game/base/game.cc index fa83a0a..30970f9 100644 --- a/src/game/base/game.cc +++ b/src/game/base/game.cc @@ -887,7 +887,7 @@ Game::Game() : core::Module("Project::OSiRiON", true) return; } - // add engine functions + // add game functions core::Func *func = 0; func = core::Func::add("join", Game::func_join); @@ -966,8 +966,17 @@ Game::~Game() // clear defaults Default::clear(); + // clear Cargo + Cargo::done(); + + // clear ShipModel + ShipModel::done(); + + // clear Templates + Template::done(); + // clear Factions - Faction::clear(); + Faction::done(); } bool Game::load_world() @@ -1081,6 +1090,7 @@ bool Game::load_zone(core::Zone *zone) while (zoneini.getline()) { if (zoneini.got_section()) { + if (zoneini.got_section("zone")) { continue; @@ -1094,24 +1104,28 @@ bool Game::load_zone(core::Zone *zone) navpoint = new NavPoint(); entity = navpoint; navpoint->set_zone(zone); + navpoint->set_radius(0); count ++; } else if (zoneini.got_section("jumpgate")) { jumppoint = new JumpGate(); entity = jumppoint; jumppoint->set_zone(zone); + jumppoint->set_radius(0); count ++; } else if (zoneini.got_section("jumppoint")) { jumppoint = new JumpPoint(); entity = jumppoint; jumppoint->set_zone(zone); + jumppoint->set_radius(0); count ++; } else if (zoneini.got_section("racetrack")) { racetrack = new RaceTrack(); entity = racetrack; racetrack->set_zone(zone); + racetrack->set_radius(0); } else if (zoneini.got_section("checkpoint")) { checkpoint = new CheckPoint(racetrack); @@ -1119,6 +1133,7 @@ bool Game::load_zone(core::Zone *zone) if (!racetrack) { zoneini.unknown_error("checkpoint without racetrack"); } + checkpoint->set_radius(0); } else if (zoneini.got_section("planet")) { planet = new Planet(); @@ -1130,11 +1145,13 @@ bool Game::load_zone(core::Zone *zone) station = new Station(); entity = station; station->set_zone(zone); + station->set_radius(0); count ++; } else if (zoneini.got_section("entity")) { entity = new core::Entity(); entity->set_zone(zone); + entity->set_radius(0); count ++; } else if (zoneini.got_section("cargo")) { @@ -1422,6 +1439,15 @@ bool Game::validate_zone(core::Zone *zone) } } + if (!entity->radius()) { + if (entity->model()) { + entity->set_radius(entity->model()->radius()); + } else { + entity->set_radius(0.25f); + } + con_debug << " " << entity->label() << " radius set to " << entity->radius() << std::endl; + } + // initialize physics on planets and entities with a model if ((entity->entity_moduletypeid == planet_enttype) || (entity->model())) { entity->reset(); diff --git a/src/game/base/jumppoint.cc b/src/game/base/jumppoint.cc index 82ed489..8af39b0 100644 --- a/src/game/base/jumppoint.cc +++ b/src/game/base/jumppoint.cc @@ -71,9 +71,22 @@ void JumpPoint::validate() } jumppoint_target = static_cast<JumpPoint *>(targetentity); + + // overwrite name and info, remove the "system" part from the name + std::string name("Jumppoint " + zone()->name() + " -> " + target()->zone()->name()); + for (size_t pos = name.find(" system"); pos != std::string::npos; pos = name.find(" system")) { + name.erase(pos, 7); + } + set_name(name); + + if (!info()) { + set_info(new core::Info(core::Entity::infotype(), label().c_str())); + } + info()->clear_text(); + info()->add_text("Jumppoint to the " + target()->zone()->name()); + - con_debug << " jumppoint to " << targetzone->label() << std::endl; - //con_debug << " Jumppoint " << zone->label() << ":" << label() << " with target " << targetlabel() << std::endl; + con_debug << " " << label() << " jumppoint to " << target()->zone()->label() << ":" << target()->label() << std::endl; } /* ---- class JumpGate --------------------------------------------- */ @@ -97,6 +110,18 @@ JumpGate::~JumpGate() void JumpGate::validate() { JumpPoint::validate(); + + // overwrite name and info + // overwrite name and info, remove the "system" part from the name + std::string name("Jumpgate " + zone()->name() + " -> " + target()->zone()->name()); + for (size_t pos = name.find(" system"); pos != std::string::npos; pos = name.find(" system")) { + name.erase(pos, 7); + } + set_name(name); + + info()->clear_text(); + info()->add_text("Jumpgate to the " + target()->zone()->name()); + if (target()) { set_flag(core::Entity::Dockable); } else { diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc index 38ade38..0b31a91 100644 --- a/src/game/base/ship.cc +++ b/src/game/base/ship.cc @@ -68,7 +68,7 @@ Ship::Ship(core::Player *owner, ShipModel *shipmodel) : core::EntityControlable( set_label(shipmodel->label()); } - if (shipmodel->dock()) { + if (shipmodel->dockable()) { using core::MenuDescription; using core::ButtonDescription; diff --git a/src/game/base/shipmodel.cc b/src/game/base/shipmodel.cc index 4cf55bf..1cea640 100644 --- a/src/game/base/shipmodel.cc +++ b/src/game/base/shipmodel.cc @@ -73,7 +73,7 @@ bool ShipModel::init() shipmodel->set_jumpdrive(b); continue; } else if (inifile.got_key_bool("dock", b)) { - shipmodel->set_dock(b); + shipmodel->set_dockable(b); continue; } else if (inifile.got_key_float("maxspeed", f)) { shipmodel->set_maxspeed(f * 0.01f); @@ -145,6 +145,11 @@ bool ShipModel::init() return true; } +void ShipModel::done() +{ + core::Func::remove("list_ship"); +} + ShipModel::ShipModel() : core::Info(shipmodel_infotype) { shipmodel_maxspeed = 0; @@ -159,7 +164,7 @@ ShipModel::ShipModel() : core::Info(shipmodel_infotype) shipmodel_maxcargo = 0.0f; shipmodel_jumpdrive = false; // no jumpdrive capability - shipmodel_dock = false; // not dockable + shipmodel_dockable = false; // not dockable } ShipModel::~ShipModel() @@ -195,7 +200,7 @@ void ShipModel::generate_info() add_text("^Bhyperspace jump drive"); } - if (dock()) { + if (dockable()) { add_text("^Bdockable"); } } diff --git a/src/game/base/shipmodel.h b/src/game/base/shipmodel.h index 9da50a6..25473d4 100644 --- a/src/game/base/shipmodel.h +++ b/src/game/base/shipmodel.h @@ -34,8 +34,8 @@ public: } /// indicates if players can dock this ship model - inline const bool dock() const { - return shipmodel_dock; + inline const bool dockable() const { + return shipmodel_dockable; } /// default mass @@ -139,8 +139,8 @@ protected: } /// set dock capability - inline void set_dock(const bool dock) { - shipmodel_dock = dock; + inline void set_dockable(const bool dockable) { + shipmodel_dockable = dockable; } /// set radius @@ -166,6 +166,8 @@ public: static bool init(); + static void done(); + static void list(); static inline const core::InfoType *infotype() { @@ -187,7 +189,7 @@ private: float shipmodel_maxcargo; bool shipmodel_jumpdrive; - bool shipmodel_dock; + bool shipmodel_dockable; const Template *shipmodel_template; diff --git a/src/game/base/template.cc b/src/game/base/template.cc index 1cdac1a..7861538 100644 --- a/src/game/base/template.cc +++ b/src/game/base/template.cc @@ -116,7 +116,7 @@ bool Template::init() entitytemplate = Template::find(std::string("navpoint")); NavPoint::set_template(entitytemplate); - if (entitytemplate) { + if (!entitytemplate) { con_warn << "Template 'navpoint' not found!" << std::endl; } @@ -128,6 +128,11 @@ bool Template::init() return true; } +void Template::done() +{ + core::Func::remove("list_template"); +} + Template::Template() : core::Info(template_infotype), template_color(), diff --git a/src/game/base/template.h b/src/game/base/template.h index 47c9ff3..5780e9c 100644 --- a/src/game/base/template.h +++ b/src/game/base/template.h @@ -66,6 +66,8 @@ public: static bool init(); + static void done(); + static void list(); static Template *find(const std::string & label); |