[Orxonox-commit 5405] r10068 - in code/branches/modularships/src/orxonox: . items
smerkli at orxonox.net
smerkli at orxonox.net
Thu May 22 13:12:35 CEST 2014
Author: smerkli
Date: 2014-05-22 13:12:35 +0200 (Thu, 22 May 2014)
New Revision: 10068
Added:
code/branches/modularships/src/orxonox/ShipPartManager.cc
code/branches/modularships/src/orxonox/ShipPartManager.h
Modified:
code/branches/modularships/src/orxonox/CMakeLists.txt
code/branches/modularships/src/orxonox/items/ShipPart.cc
Log:
Introduced a shippartmanager to hopefully fix the segfaults
Modified: code/branches/modularships/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/modularships/src/orxonox/CMakeLists.txt 2014-05-21 20:38:09 UTC (rev 10067)
+++ code/branches/modularships/src/orxonox/CMakeLists.txt 2014-05-22 11:12:35 UTC (rev 10068)
@@ -30,6 +30,7 @@
MoodManager.cc
PawnManager.cc
PlayerManager.cc
+ ShipPartManager.cc
Radar.cc
# Test.cc
Added: code/branches/modularships/src/orxonox/ShipPartManager.cc
===================================================================
--- code/branches/modularships/src/orxonox/ShipPartManager.cc (rev 0)
+++ code/branches/modularships/src/orxonox/ShipPartManager.cc 2014-05-22 11:12:35 UTC (rev 10068)
@@ -0,0 +1,61 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program 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 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "ShipPartManager.h"
+
+#include "util/ScopedSingletonManager.h"
+#include "core/CoreIncludes.h"
+#include "items/ShipPart.h"
+
+namespace orxonox
+{
+ ManageScopedSingleton(ShipPartManager, ScopeID::Root, false);
+
+ ShipPartManager::ShipPartManager()
+ {
+ RegisterObject(ShipPartManager);
+ }
+
+ ShipPartManager::~ShipPartManager()
+ {
+ // Be sure to delete all the pawns
+ for (ObjectList<ShipPart>::iterator it = ObjectList<ShipPart>::begin(); it != ObjectList<ShipPart>::end(); )
+ (it++)->death();
+ }
+
+ void ShipPartManager::preUpdate(const Clock& time)
+ {
+ for (ObjectList<ShipPart>::iterator it = ObjectList<ShipPart>::begin(); it != ObjectList<ShipPart>::end(); )
+ {
+ if (!it->isAlive())
+ (it++)->death();
+ else
+ ++it;
+ }
+ }
+}
Added: code/branches/modularships/src/orxonox/ShipPartManager.h
===================================================================
--- code/branches/modularships/src/orxonox/ShipPartManager.h (rev 0)
+++ code/branches/modularships/src/orxonox/ShipPartManager.h 2014-05-22 11:12:35 UTC (rev 10068)
@@ -0,0 +1,54 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program 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 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _ShipPartManager_H__
+#define _ShipPartManager_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "util/Singleton.h"
+#include "tools/interfaces/Tickable.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport ShipPartManager : public Singleton<ShipPartManager>, public Tickable
+ {
+ friend class Singleton<ShipPartManager>;
+ public:
+ ShipPartManager();
+ virtual ~ShipPartManager();
+
+ virtual void preUpdate(const Clock& time);
+
+ private:
+
+ static ShipPartManager* singletonPtr_s;
+ };
+}
+
+#endif /* _ShipPartManager_H__ */
Modified: code/branches/modularships/src/orxonox/items/ShipPart.cc
===================================================================
--- code/branches/modularships/src/orxonox/items/ShipPart.cc 2014-05-21 20:38:09 UTC (rev 10067)
+++ code/branches/modularships/src/orxonox/items/ShipPart.cc 2014-05-22 11:12:35 UTC (rev 10068)
@@ -84,8 +84,8 @@
*/
void ShipPart::death()
{
- if (!(this->isAlive()))
- return;
+ //if (!(this->isAlive()))
+ //return;
this->explode();
this->setAlive(false);
@@ -231,7 +231,8 @@
}
}
if (this->health_ < 0)
- this->death();
+ this->alive_ = false;
+ //this->death();
// (Ugly) Chatoutput of health, until a GUI for modularspaceships-shipparts is implemented.
if (this->health_ < 0.2 * this->maxHealth_)
More information about the Orxonox-commit
mailing list