blob: aa0c2c967e9f80209df1af28637ff74e9c28d339 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
/*
game/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 "game/shipmodel.h"
namespace game {
// the ship model registry
std::map<std::string, ShipModel *> ShipModel::registry;
ShipModel::ShipModel()
{
//default specifications
shipmodel_acceleration = 1.0f;
shipmodel_maxspeed = 3.0f;
shipmodel_turnspeed = 0.1f;
}
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;
}
}
|