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-03-16 09:39:02 +0000
committerStijn Buys <ingar@osirion.org>2008-03-16 09:39:02 +0000
commitc186b58679c50b06966997d33d5e91a99c5621ea (patch)
treec666439f63f62825e2fff419728d4c026661f9ed /src/game/game.cc
parent11acb6ebad36c20de5f22fb5b7edbf11d8b29254 (diff)
fixes compilation on soliter, abort dedicated server on error
Diffstat (limited to 'src/game/game.cc')
-rw-r--r--src/game/game.cc94
1 files changed, 50 insertions, 44 deletions
diff --git a/src/game/game.cc b/src/game/game.cc
index ff42817..88718b4 100644
--- a/src/game/game.cc
+++ b/src/game/game.cc
@@ -20,13 +20,13 @@ namespace game
ShipModel *default_shipmodel;
/*----- engine game functions ------------------------------------- */
-// list the ship model registry
+/// list the ship model registry
void func_list_ship(std::string const &args)
{
ShipModel::list();
}
-// a player joins the game
+/// a player joins the game
void func_join(core::Player *player, std::string const &args)
{
if (player->control())
@@ -118,35 +118,35 @@ void Game::init()
ShipModel::clear();
// setup the game world
- filesystem::IniFile f;
- f.open("world");
+ filesystem::IniFile worldini;
+ worldini.open("world");
- if (!f.is_open()) {
+ if (!worldini.is_open()) {
return;
}
Star *star = 0;
core::Entity *entity = 0;
- while (f.getline()) {
- if (f.got_key()) {
- if (f.section().compare("star") == 0) {
- if (f.got_key_string("name", star->entity_name))
+ while (worldini.getline()) {
+ if (worldini.got_key()) {
+ if (worldini.section().compare("star") == 0) {
+ if (worldini.got_key_string("name", star->entity_name))
continue;
- else if (f.got_key_string("model", star->entity_modelname))
+ else if (worldini.got_key_string("model", star->entity_modelname))
continue;
- else if (f.got_key_vector3f("location", star->entity_location ))
+ else if (worldini.got_key_vector3f("location", star->entity_location ))
continue;
- else if (f.got_key_color("color", star->entity_color))
+ else if (worldini.got_key_color("color", star->entity_color))
continue;
else
- con_warn << f.name() << " unknown key '" << f.key() << "' at line " << f.line() << std::endl;
+ con_warn << worldini.name() << " unknown key '" << worldini.key() << "' at line " << worldini.line() << std::endl;
- } else if (f.section().compare("entity") == 0) {
+ } else if (worldini.section().compare("entity") == 0) {
std::string shapename;
- if (f.got_key_string("shape", shapename)) {
+ if (worldini.got_key_string("shape", shapename)) {
if (shapename.compare("axis") == 0) {
entity->entity_shape = core::Entity::Axis;
} else if (shapename.compare("cube") == 0) {
@@ -156,35 +156,35 @@ void Game::init()
} else if (shapename.compare("sphere") == 0) {
entity->entity_shape = core::Entity::Sphere;
} else {
- con_warn << f.name() << " unknown shape '" << shapename << "' at line " << f.line() << std::endl;
+ con_warn << worldini.name() << " unknown shape '" << shapename << "' at line " << worldini.line() << std::endl;
}
continue;
- } else if (f.got_key_string("name", entity->entity_name))
+ } else if (worldini.got_key_string("name", entity->entity_name))
continue;
- else if (f.got_key_string("model", entity->entity_modelname))
+ else if (worldini.got_key_string("model", entity->entity_modelname))
continue;
- else if (f.got_key_angle("direction", entity->entity_direction))
+ else if (worldini.got_key_angle("direction", entity->entity_direction))
continue;
- else if (f.got_key_angle("radius", entity->entity_radius))
+ else if (worldini.got_key_angle("radius", entity->entity_radius))
continue;
- else if (f.got_key_vector3f("location", entity->entity_location))
+ else if (worldini.got_key_vector3f("location", entity->entity_location))
continue;
- else if (f.got_key_color("color", entity->entity_color))
+ else if (worldini.got_key_color("color", entity->entity_color))
continue;
else
- con_warn << f.name() << " unknown key '" << f.key() << "' at line " << f.line() << std::endl;
+ con_warn << worldini.name() << " unknown key '" << worldini.key() << "' at line " << worldini.line() << std::endl;
}
- } else if (f.got_section("star")) {
+ } else if (worldini.got_section("star")) {
star = new Star();
- } else if (f.got_section("entity")) {
+ } else if (worldini.got_section("entity")) {
entity = new core::Entity();
- } else if (f.got_section()) {
- con_warn << f.name() << " unknown section '" << f.section() << "' at line " << f.line() << std::endl;
+ } else if (worldini.got_section()) {
+ con_warn << worldini.name() << " unknown section '" << worldini.section() << "' at line " << worldini.line() << std::endl;
}
}
- f.close();
+ worldini.close();
/*
// the green cube
@@ -220,42 +220,48 @@ void Game::init()
axis->entity_name = "axis: Origin";
*/
// read ship model specifications
- f.open("ships");
- if (!f.is_open())
+ // note:
+ // do not reuse the previous IniFile instance, some gcc versions do not like it
+ filesystem::IniFile shipsini;
+ shipsini.open("ships");
+ if (!shipsini.is_open())
return;
ShipModel *shipmodel = 0;
default_shipmodel = 0;
- while (f.getline()) {
- if (f.got_key()) {
- if (f.section() == "ship") {
+ while (shipsini.getline()) {
+ if (shipsini.got_key()) {
+ if (shipsini.section() == "ship") {
- if (f.got_key_string("name",shipmodel->shipmodel_name)) {
+ if (shipsini.got_key_string("name",shipmodel->shipmodel_name)) {
continue;
- } else if (f.got_key_string("model", shipmodel->shipmodel_modelname)) {
+ } else if (shipsini.got_key_string("model", shipmodel->shipmodel_modelname)) {
continue;
- } else if (f.got_key("default")) {
+ } else if (shipsini.got_key("default")) {
default_shipmodel = shipmodel;
continue;
- } else if (f.got_key_float("acceleration", shipmodel->shipmodel_acceleration)) {
+ } else if (shipsini.got_key_float("acceleration", shipmodel->shipmodel_acceleration)) {
continue;
- } else if (f.got_key_float("maxspeed", shipmodel->shipmodel_maxspeed)) {
+ } else if (shipsini.got_key_float("maxspeed", shipmodel->shipmodel_maxspeed)) {
continue;
- } else if (f.got_key_float("turnspeed", shipmodel->shipmodel_turnspeed)) {
+ } else if (shipsini.got_key_float("turnspeed", shipmodel->shipmodel_turnspeed)) {
continue;
} else {
- con_warn << f.name() << " unknown key '" << f.key() << "' at line " << f.line() << std::endl;
+ con_warn << shipsini.name() << " unknown key '" << shipsini.key() << "' at line " << shipsini.line() << std::endl;
}
}
- } else if (f.got_section("ship")) {
+ } else if (shipsini.got_section("ship")) {
shipmodel = new ShipModel();
- } else if (f.got_section()) {
- con_warn << f.name() << " unknown section '" << f.section() << "' at line " << f.line() << std::endl;
+ if (!default_shipmodel)
+ default_shipmodel = shipmodel;
+
+ } else if (shipsini.got_section()) {
+ con_warn << shipsini.name() << " unknown section '" << shipsini.section() << "' at line " << shipsini.line() << std::endl;
}
}
- f.close();
+ shipsini.close();
if (!default_shipmodel) {
con_error << "No default ship model\n";