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>2008-09-28 15:05:13 +0000
committerStijn Buys <ingar@osirion.org>2008-09-28 15:05:13 +0000
commitfd778219e40c5fbb4d0af1839cbc313caaf10d9d (patch)
treeb6e413f4c1a5ba4091503ba97c784278485d3933 /src/game/base/shipmodel.cc
parentbedcff956d253621ec00aa7d2919c22a4c88b0b2 (diff)
move base game module to new subdirectory
Diffstat (limited to 'src/game/base/shipmodel.cc')
-rw-r--r--src/game/base/shipmodel.cc72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/game/base/shipmodel.cc b/src/game/base/shipmodel.cc
new file mode 100644
index 0000000..6018414
--- /dev/null
+++ b/src/game/base/shipmodel.cc
@@ -0,0 +1,72 @@
+/*
+ base/shipmodel.cc
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
+*/
+
+#include "sys/sys.h"
+#include "base/shipmodel.h"
+
+namespace base {
+
+// the ship model registry
+std::map<std::string, ShipModel *> ShipModel::registry;
+
+ShipModel::ShipModel()
+{
+ //default specifications
+ shipmodel_acceleration = 1.0f; // thruster acceleration in game untits/second^2
+ shipmodel_maxspeed = 3.0f; // maximum thruster speed in game units/second
+ shipmodel_turnspeed = 45.0f; // 45 degrees per second
+
+ shipmodel_jumpdrive = false;
+}
+
+ShipModel::~ShipModel()
+{}
+
+
+// clear the ship model registry
+void ShipModel::clear()
+{
+ for (iterator smit = registry.begin(); smit != registry.end(); smit++) {
+ delete (*smit).second;
+ }
+ registry.clear();
+}
+
+void ShipModel::list()
+{
+ for (iterator smit = registry.begin(); smit != registry.end(); smit++) {
+ con_print <<
+ " " << (*smit).second->label() <<
+ " " << (*smit).second->name() <<
+ " accel " << (*smit).second->acceleration() <<
+ " max " << (*smit).second->maxspeed() <<
+ " turn " << (*smit).second->turnspeed() << "\n";
+ }
+ con_print << registry.size() << " registered ship models\n";
+}
+
+ShipModel *ShipModel::find(const std::string label)
+{
+ std::map<std::string, ShipModel *>::iterator it = registry.find(label);
+ if (it == registry.end())
+ return 0;
+ else
+ return (*it).second;
+}
+
+// add a new ship model
+void ShipModel::add(ShipModel *shipmodel)
+{
+ ShipModel *m = find(shipmodel->label());
+ if (m) {
+ con_warn << "Duplicate ship model " << shipmodel->label() << "!\n";
+ delete m;
+ }
+
+ registry[shipmodel->label()] = shipmodel;
+}
+
+}