[SCM] Packaging for spacehero branch, master, updated. upstream/0.0.5-11-gf3015a0
Arne Wichmann
arnew at rasentrimmer.org
Fri Feb 20 15:38:40 UTC 2009
The following commit has been merged in the master branch:
commit 98664459909d5b05fe743949959a83120785f05c
Merge: 450f190a7261d358f3e5ebfa95be2a24a7ab45d7 411e8c5483e5c56c049e01eec7d709d3ca1780a0
Author: Arne Wichmann <arnew at rasentrimmer.org>
Date: Fri Feb 20 16:12:31 2009 +0100
Merge commit 'upstream/0.0.6'
diff --combined Level.cpp
index d73b010,99c32ed..6788b8d
--- a/Level.cpp
+++ b/Level.cpp
@@@ -1,4 -1,21 +1,20 @@@
+ /*
+ * This file is part of Spacehero.
+ *
+ * Spacehero is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Foobar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Spacehero. If not, see <http://www.gnu.org/licenses/>.
+ */
#include "Universe.h"
-#include <fstream>
Level::Level(std::ifstream &in) :
t0(),
@@@ -13,52 -30,162 +29,52 @@@
seed(0)
{
- char c; int i;
- bool D=false,G=false;
- std::ios_base::iostate s = in.exceptions();
- in.exceptions(std::ios_base::badbit|std::ios_base::failbit|std::ios_base::eofbit);
- in >> c >> i;
- if(c!='V' && i!=1) throw Error::ParseLevel("wrong version in level file");
- try {
- while( in >> c, in.good()) {
- std::cerr << "level: trying to read: " << c << std::endl;
- switch(c) {
- case 'D':
- goal = Goal(in);
- D=true;
- break;
- case 'G':
- {
- Galaxy g(in);
- galaxies.push_back( g );
- std::cerr << "master galaxy? " << g.getmaster() << std::endl;
- if(g.getmaster()) G=true; // at least one master galaxy needed
- }
- break;
- case 'H':
- holes.push_back( Blackhole(in) );
- break;
- case 'S':
- in >> seed;
- break;
- case 'T':
- in >> maxtime;
- break;
- default:
- std::cerr << "unexpected char: " << c << std::endl;
- throw Error::ParseLevel("funny data in level");
- }
- std::cerr << "---" << std::endl;
- }
- } catch (std::ios_base::failure) {
- std::ios_base::iostate r = in.exceptions();
- if(r&std::ios_base::eofbit) {
- // end of level reached
- if(!(D&&G)) {
- if (!D) throw Error::ParseLevel("at least one goal needed");
- if (!G) throw Error::ParseLevel("at least one master galaxy needed");
- }
- } else {
- throw;
- }
- }
- in.exceptions(s);
-}
-
-Goal::Goal(std::ifstream &in)
-{
- bool P=false,R=false;
- char c;
- bool done=false;
- while( !done) {
- in >> c, in.good();
- std::cerr << "goal: trying to read: " << c << std::endl;
+ goal = Goal(in);
+ while(in.good()) {
+ char c;
+ in >> c;
+ if(!in.good()) break;
+ std::cerr << "Type: " << c << std::endl;
switch(c) {
- case 'D':
- done=true;
+ case 'M':
+ galaxies.push_back( Galaxy(in,true) );
break;
- case 'P':
- in >> x >> y >> z;
- P=true;
+ case 'G':
+ galaxies.push_back( Galaxy(in) );
break;
- case 'R':
- in >> radius;
- R=true;
+ case 'H':
+ holes.push_back( Blackhole(in) );
+ break;
+ case 'S':
+ in >> seed;
break;
- default:
- std::cerr << "unexpected char: " << c << std::endl;
- throw Error::ParseLevel("funny data in goal");
}
}
- if(!P) throw Error::ParseLevel("Missing Position for Goal");
- if(!R) throw Error::ParseLevel("Missing Radius for Goal");
+ maxtime = 30.0;
+}
+
+Goal::Goal(std::ifstream &in)
+{
+ in >> x >> y >> z;
+ in >> radius;
setlevel();
};
Blackhole::Blackhole(std::ifstream &in) {
- bool P=false,W=false;
- char c;
- bool done=false;
- while( !done) {
- in >> c, in.good();
- std::cerr << "hole: trying to read: " << c << std::endl;
- switch(c) {
- case 'H':
- done=true;
- break;
- case 'P':
- in >> x >> y >> z;
- P=true;
- break;
- case 'V':
- double t;
- in >> t >> t >> t;
- break;
- case 'W':
- in >> mass;
- W=true;
- break;
- default:
- std::cerr << "unexpected char: " << c << std::endl;
- throw Error::ParseLevel("funny data in hole");
- }
- }
- if(!P) throw Error::ParseLevel("Missing Position for Hole");
- if(!W) throw Error::ParseLevel("Missing Weight for Hole");
+ double t;
+ in >> x >> y >> z;
+ in >> t >> t >> t;
+ in >> mass;
radius = HOLESIZE*sqrt(mass/HOLEMEDIUMMASS);
setlevel();
};
-Galaxy::Galaxy(std::ifstream &in) :
- master(false),
+Galaxy::Galaxy(std::ifstream &in, bool master) :
+ master(master),
lr(true)
{
- bool P=false,V=false,W=false;
- char c;
- bool done=false;
- while( !done) {
- in >> c, in.good();
- std::cerr << "galaxy: trying to read: " << c << std::endl;
- switch(c) {
- case 'G':
- done=true;
- break;
- case 'P':
- in >> x >> y >> z;
- P=true;
- break;
- case 'V':
- in >> vx >> vy >> vz;
- V=true;
- break;
- case 'M':
- master=true;
- std::cerr << "Setting Galaxy as master" << std::endl;
- break;
- case 'W':
- in >> mass;
- W=true;
- break;
- default:
- std::cerr << "unexpected char: " << c << std::endl;
- throw Error::ParseLevel("funny data in galaxy");
- }
- }
- if(!P) throw Error::ParseLevel("Missing Position for Galaxy");
- if(!V) throw Error::ParseLevel("Missing Velocity for Galaxy");
- if(!W) throw Error::ParseLevel("Missing Weight for Galaxy");
- if(getmaster()) std::cerr << "this galaxy thinks it is master" << std::endl;
-
- setlevel();
+ in >> x >> y >> z;
+ in >> vx >> vy >> vz;
+ in >> mass;
radius = BULGESIZE;
};
diff --combined SpaceDisplay.cpp
index c5906ce,d587b04..b622c6b
--- a/SpaceDisplay.cpp
+++ b/SpaceDisplay.cpp
@@@ -1,3 -1,19 +1,19 @@@
+ /*
+ * This file is part of Spacehero.
+ *
+ * Spacehero is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Foobar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Spacehero. If not, see <http://www.gnu.org/licenses/>.
+ */
#include "SpaceDisplay.h"
#include "local.h"
#include "Spacehero.h"
@@@ -9,7 -25,7 +25,7 @@@ SpaceDisplay::SpaceDisplay(std::string
display()
#endif
,textures(path)
- ,illustrator()
+ ,illustrator(path)
,buttons(textures, illustrator)
,isActive(1)
,event()
@@@ -389,6 -405,7 +405,6 @@@ void SpaceDisplay::handleEvents(BridgeV
GLdouble projMatrix[16];
int viewport[4];
double mousex, mousey, mousez, zpos;
- FileManager saveas;
while ( SDL_PollEvent( &event ) )
{
@@@ -454,6 -471,9 +470,6 @@@
case SDLK_e:
flags.activateFlag((AbstractButtonFlags::Actions)ButtonFlags::startEditor);
break;
- case SDLK_s:
- std::cout << "Wuerde jetzt gespeichert werden in: " << saveas.getFile() << std::endl;
- break;
case SDLK_SPACE:
flags.activateFlag((AbstractButtonFlags::Actions)ButtonFlags::breakIntro);
break;
diff --combined SpaceDisplay.h
index 48a0454,c339af7..7e36038
--- a/SpaceDisplay.h
+++ b/SpaceDisplay.h
@@@ -1,3 -1,19 +1,19 @@@
+ /*
+ * This file is part of Spacehero.
+ *
+ * Spacehero is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Foobar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Spacehero. If not, see <http://www.gnu.org/licenses/>.
+ */
#ifndef _SPACEDISPLAY_H_
#define _SPACEDISPLAY_H_
@@@ -29,6 -45,8 +45,6 @@@
#include "PictureBook.h"
#include "Illustrator.h"
-#include "FileManager.h"
-
class Editor;
class SpaceDisplay
diff --combined Universe.h
index 298f59e,5e72b0f..798fe6e
--- a/Universe.h
+++ b/Universe.h
@@@ -1,3 -1,19 +1,19 @@@
+ /*
+ * This file is part of Spacehero.
+ *
+ * Spacehero is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Foobar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Spacehero. If not, see <http://www.gnu.org/licenses/>.
+ */
#ifndef _UNIVERSE_H_
#define _UNIVERSE_H_
@@@ -20,6 -36,15 +36,6 @@@ using boost::timer
using boost::progress_timer;
using boost::progress_display;
-namespace Error {
- class ParseLevel {
- const char *p;
- public:
- ParseLevel(const char* q): p(q) {}
- const char* msg() {return p;}
- };
-}
-
class SkyObject {
public:
double x, y, z; /* in 600000 LJ (0.5 = 300000 LJ = Mitte vom Spielfeld) */
@@@ -83,7 -108,7 +99,7 @@@ class Galaxy : public SkyMass
Galaxy();
public:
- Galaxy(std::ifstream &in);
+ Galaxy(std::ifstream &in, bool master=false);
Galaxy(double ix, double iy, double imass, bool imaster, bool ilr) : SkyMass(ix, iy, imass, BULGESIZE), master(imaster), lr(ilr) {};
std::vector<Star> getStars(int seed);
@@@ -132,7 -157,7 +148,7 @@@ class Level
double ldelta(double weight=0.1 ) { return weight*m_delta + (1-weight)*(elapsed()-lastt); };
double delta() { return m_delta; }; // filtered delta
- double getmaxtime() const { return maxtime; }; // get maxtime
+ double getmaxtime() { return maxtime; }; // get maxtime
bool timeout() {return elapsed() > maxtime; }; // TODO: fix to use summed movement time
double fps() {
diff --combined main.cpp
index 2f68dd1,157b1d1..0639bfc
--- a/main.cpp
+++ b/main.cpp
@@@ -1,3 -1,19 +1,19 @@@
+ /*
+ * This file is part of Spacehero.
+ *
+ * Spacehero is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Foobar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Spacehero. If not, see <http://www.gnu.org/licenses/>.
+ */
#include "boost/filesystem.hpp"
#include <iostream>
@@@ -48,12 -64,17 +64,12 @@@ int main(int argc, char *argv[]
for (directory_iterator itr(levels); itr != directory_iterator(); ++itr) {
std::cerr << "trying to load level: " << itr->path() << std::endl;
std::ifstream level(itr->path().string().c_str());
- std::ofstream levelwrite("/tmp/level.out");
if(level) {
- try {
- Level l(level);
- levelwrite << l;
- Universe u(l);
- Spacehero s(display,u);
- s.play();
- } catch (Error::ParseLevel e) {
- std::cerr << e.msg() << std::endl;
- }
+ Level l(level);
+ std::cerr << l << std::endl;
+ Universe u(l);
+ Spacehero s(display,u);
+ s.play();
}
}
diff --combined output.cpp
index afefd5f,9f6727e..c22bf59
--- a/output.cpp
+++ b/output.cpp
@@@ -1,45 -1,67 +1,61 @@@
+ /*
+ * This file is part of Spacehero.
+ *
+ * Spacehero is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Foobar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Spacehero. If not, see <http://www.gnu.org/licenses/>.
+ */
#include "Universe.h"
+
+
std::ostream& operator<< (std::ostream &o, const SkyObject &g) {
-// o << "SkyObject: " << std::endl;
- o << "P " << g.x << " " << g.y << " " << g.z << std::endl;
+ o << "SkyObject: " << std::endl;
+ o << "(x,y,z): " << g.x << " " << g.y << " " << g.z << std::endl;
return o;
}
std::ostream& operator<< (std::ostream &o, const SkyMass &g) {
- //o << "SkyMass: " << std::endl;
+ o << "SkyMass: " << std::endl;
+ o << "mass: " << g.mass << std::endl;
//o << "(fx,fy,fz): " << g.fx << " " << g.fy << " " << g.fz << std::endl;
- o << static_cast<SkyObject>(g);
- o << "V " << g.vx << " " << g.vy << " " << g.vz << std::endl;
- o << "W " << g.mass << std::endl;
+ o << "(vx,vy,vz)" << g.vx << " " << g.vy << " " << g.vz << std::endl;
+ o << static_cast<SkyObject>(g) << std::endl;
return o;
}
std::ostream& operator<< (std::ostream &o, const Goal &g) {
- o << "D " << std::endl;
- o << static_cast<SkyObject>(g);
- o << "R " << g.radius << std::endl;
- o << "D " << std::endl << std::endl;
+ o << "Goal: " << std::endl;
+ o << "radius: " << g.radius << std::endl;
+ o << static_cast<SkyObject>(g) << std::endl;
return o;
}
std::ostream& operator<< (std::ostream &o, const Blackhole &g) {
- o << "H" << std::endl;
- o << static_cast<SkyMass>(g);
- o << "H" << std::endl << std::endl;
+ o << "Blackhole: " << std::endl;
+ o << static_cast<SkyMass>(g) << std::endl;
return o;
}
std::ostream& operator<< (std::ostream &o, const Star &g) {
- o << "S" << std::endl;
- o << static_cast<SkyMass>(g);
- o << "S" << std::endl << std::endl;
+ o << "Star: " << std::endl;
+ o << static_cast<SkyMass>(g) << std::endl;
return o;
}
std::ostream& operator<< (std::ostream &o, const Galaxy &g) {
- o << "G" << std::endl;
- o << (g.master?"M ":"") << std::endl;
- o << static_cast<SkyMass>(g);
- o << "G" << std::endl << std::endl;
+ o << "Galaxy: " << std::endl;
+ o << static_cast<SkyMass>(g) << std::endl;
return o;
}
-
std::ostream& operator<< (std::ostream &o, const Level &l) {
- o << "V 1" << std::endl;
- o << "T " << l.getmaxtime() << std::endl;
- o << l.goal;
+ o << l.goal << std::endl;
copy(l.holes.begin(),l.holes.end(),std::ostream_iterator<Blackhole>(o));
copy(l.galaxies.begin(),l.galaxies.end(),std::ostream_iterator<Galaxy>(o));
return o;
--
Packaging for spacehero
More information about the Pkg-games-commits
mailing list