From 5ddb64795cc959916eeedbec8dc3f65c06f49698 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Thu, 12 Nov 2009 20:53:35 +0000 Subject: initial commodities and entity inventory, bump network proto version to 18 --- src/game/base/shipmodel.cc | 75 +++++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 34 deletions(-) (limited to 'src/game/base/shipmodel.cc') 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 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()); -- cgit v1.2.3