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>2009-11-12 20:53:35 +0000
committerStijn Buys <ingar@osirion.org>2009-11-12 20:53:35 +0000
commit5ddb64795cc959916eeedbec8dc3f65c06f49698 (patch)
treeee7231607b0bf49528570e5d3badcdedcb33f54e /src/game/base/shipmodel.cc
parent3605a7bd8fffebfba38d31025b6f33cb82626a3b (diff)
initial commodities and entity inventory, bump network proto version to 18
Diffstat (limited to 'src/game/base/shipmodel.cc')
-rw-r--r--src/game/base/shipmodel.cc75
1 files changed, 41 insertions, 34 deletions
diff --git a/src/game/base/shipmodel.cc b/src/game/base/shipmodel.cc
index 6233120..fe1c88c 100644
--- a/src/game/base/shipmodel.cc
+++ b/src/game/base/shipmodel.cc
@@ -14,9 +14,9 @@ namespace game
{
// the ship model registry
-std::map<std::string, ShipModel *> ShipModel::registry;
+ShipModel::Registry ShipModel::registry;
-ShipModel::ShipModel()
+ShipModel::ShipModel(const unsigned int type_id)
{
//default specifications
shipmodel_acceleration = 1.0f; // thruster acceleration in game untits/second^2
@@ -26,6 +26,7 @@ ShipModel::ShipModel()
shipmodel_maxcargo = 0;
shipmodel_jumpdrive = false;
+ shipmodel_type_id = type_id;
}
ShipModel::~ShipModel()
@@ -51,45 +52,51 @@ void ShipModel::print()
con_print << " cargo: ^B" << maxcargo() << std::endl;
}
-void ShipModel::generate_info(core::Info *info)
+void ShipModel::generate_info()
{
- info->clear_text();
-
- info->set_name(name());
- info->set_modelname(modelname());
-
- // info text form ships.ini
- for (core::Info::Text::iterator it = shipmodel_infotext.begin(); it != shipmodel_infotext.end(); it++) {
- info->add_text((*it));
- }
-
- info->add_text("");
- info->add_text("^BSpecifications:^N");
- std::stringstream str;
- str << "price: ^B" << price() << " ^Ncredits";
- info->add_text(str.str());
- str.str("");
+ for (iterator it = registry.begin(); it != registry.end(); it++) {
+ ShipModel *shipmodel = (*it).second;
+ core::Info *info = new core::Info("ship/" + shipmodel->label());
+
+ info->clear_text();
+ info->set_name(shipmodel->name());
+ info->set_modelname(shipmodel->modelname());
+
+ // info text form ships.ini
+ for (core::Info::Text::iterator tit = shipmodel->shipmodel_infotext.begin();
+ tit != shipmodel->shipmodel_infotext.end(); tit++) {
+
+ info->add_text((*tit));
+ }
- str << "cargo hold: ^B" << 0.1f * maxcargo() << " ^Nmetric tonnes";
- info->add_text(str.str());
- str.str("");
+ info->add_text("");
+ info->add_text("^BSpecifications:^N");
+ std::stringstream str;
+ str << "price: ^B" << shipmodel->price() << " ^Ncredits";
+ info->add_text(str.str());
+ str.str("");
- str << "top speed: ^B" << 100.0f * maxspeed() << " ^Nmps";
- info->add_text(str.str());
- str.str("");
+ str << "cargo hold: ^B" << 0.1f * shipmodel->maxcargo() << " ^Nmetric tonnes";
+ info->add_text(str.str());
+ str.str("");
- str << "response: ^B" << turnspeed() << " ^Ndps";
- info->add_text(str.str());
- str.str("");
+ str << "top speed: ^B" << 100.0f * shipmodel->maxspeed() << " ^Nmps";
+ info->add_text(str.str());
+ str.str("");
- str << "acceleration: ^B" << acceleration() << " ^Nstandard";
- info->add_text(str.str());
- str.str("");
+ str << "response: ^B" << shipmodel->turnspeed() << " ^Ndps";
+ info->add_text(str.str());
+ str.str("");
- if (shipmodel_jumpdrive) {
- str << "hyperspace jump drive capable";
+ str << "acceleration: ^B" << shipmodel->acceleration() << " ^Nstandard";
info->add_text(str.str());
str.str("");
+
+ if (shipmodel->shipmodel_jumpdrive) {
+ str << "hyperspace jump drive capable";
+ info->add_text(str.str());
+ str.str("");
+ }
}
}
@@ -154,7 +161,7 @@ ShipModel *ShipModel::search(const std::string searchname)
return 0;
}
-// add a new ship model
+// add a ship model
void ShipModel::add(ShipModel *shipmodel)
{
ShipModel *m = find(shipmodel->label());