[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src ActionHolder.cc,1.34,1.35 EntranceDat
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src ActionHolder.cc,1.34,1.35 EntranceData.cc,1.7,1.8 EntranceData.hh,1.10,1.11 ExitData.cc,1.10,1.11 ExitData.hh,1.8,1.9 HotspotData.cc,1.7,1.8 HotspotData.hh,1.8,1.9 LiquidData.cc,1.8,1.9 LiquidData.hh,1.11,1.12 PLF.cc,1.31,1.32 PLF.hh,1.30,1.31 PLFPLF.cc,1.14,1.15 PinguActionFactory.cc,1.6,1.7 PingusGameSession.cc,1.14,1.15 TrapData.cc,1.10,1.11 TrapData.hh,1.13,1.14 World.cc,1.69,1.70 WorldObjDataFactory.cc,1.5,1.6 WorldObjDataFactory.hh,1.5,1.6 WorldObjGroupData.cc,1.4,1.5 WorldObjGroupData.hh,1.2,1.3 XMLPLF.cc,1.44,1.45 |
Date: |
9 Jun 2002 13:03:14 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv9453
Modified Files:
ActionHolder.cc EntranceData.cc EntranceData.hh ExitData.cc
ExitData.hh HotspotData.cc HotspotData.hh LiquidData.cc
LiquidData.hh PLF.cc PLF.hh PLFPLF.cc PinguActionFactory.cc
PingusGameSession.cc TrapData.cc TrapData.hh World.cc
WorldObjDataFactory.cc WorldObjDataFactory.hh
WorldObjGroupData.cc WorldObjGroupData.hh XMLPLF.cc
Log Message:
- replaced shared_ptr<WorldObjData> with WorldObjData*
- the changes trigger a bug in the owner_id, which causes it to be
uninitialized, not sure if my new code causes this, or just triggers it (since
I have seen that before)
Index: ActionHolder.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/ActionHolder.cc,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- ActionHolder.cc 9 Jun 2002 00:56:25 -0000 1.34
+++ ActionHolder.cc 9 Jun 2002 13:03:11 -0000 1.35
@@ -41,6 +41,10 @@
ActionHolder::~ActionHolder ()
{
+ //FIXME: This is not really a good place to free the actions
+ //FIXME: But not otherwise to possible at the moment due to the
+ //FIXME: singleton thing.
+ PinguActionFactory::instance ()->delete_actions ();
}
void
Index: EntranceData.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/EntranceData.cc,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- EntranceData.cc 8 Jun 2002 23:11:07 -0000 1.7
+++ EntranceData.cc 9 Jun 2002 13:03:11 -0000 1.8
@@ -24,10 +24,8 @@
#include "StringConverter.hh"
#include "XMLhelper.hh"
-boost::shared_ptr<WorldObjData>
-EntranceData::create(xmlDocPtr doc, xmlNodePtr cur)
+EntranceData::EntranceData (xmlDocPtr doc, xmlNodePtr cur)
{
- EntranceData* entrance = new EntranceData ();
cur = cur->children;
while (cur != NULL)
{
@@ -40,35 +38,35 @@
if (strcmp((char*)cur->name, "type") == 0)
{
char* name = (char*)xmlNodeListGetString(doc, cur->children, 1);
- entrance->type = name;
+ type = name;
free(name);
}
else if (strcmp((char*)cur->name, "owner-id") == 0)
{
- entrance->owner_id = XMLhelper::parse_int(doc, cur);
+ owner_id = XMLhelper::parse_int(doc, cur);
}
else if (strcmp((char*)cur->name, "position") == 0)
{
- entrance->pos = XMLhelper::parse_vector(doc, cur);
+ pos = XMLhelper::parse_vector(doc, cur);
}
else if (strcmp((char*)cur->name, "release-rate") == 0)
{
- char* release_rate = (char*)xmlNodeListGetString(doc, cur->children,
1);
- entrance->release_rate = StringConverter::to_int(release_rate);
- free(release_rate);
+ char* release_rate_str = (char*)xmlNodeListGetString(doc,
cur->children, 1);
+ release_rate = StringConverter::to_int(release_rate_str);
+ free(release_rate_str);
}
else if (strcmp((char*)cur->name, "direction") == 0)
{
- char* direction = (char*)xmlNodeListGetString(doc, cur->children, 1);
+ char* direction_str = (char*)xmlNodeListGetString(doc, cur->children,
1);
- if (strcmp(direction, "left") == 0)
- entrance->direction = EntranceData::LEFT;
- else if (strcmp(direction, "right") == 0)
- entrance->direction = EntranceData::RIGHT;
- else if (strcmp(direction, "misc") == 0)
- entrance->direction = EntranceData::MISC;
+ if (strcmp(direction_str, "left") == 0)
+ direction = EntranceData::LEFT;
+ else if (strcmp(direction_str, "right") == 0)
+ direction = EntranceData::RIGHT;
+ else if (strcmp(direction_str, "misc") == 0)
+ direction = EntranceData::MISC;
- free(direction);
+ free(direction_str);
}
else
{
@@ -76,8 +74,6 @@
}
cur = cur->next;
}
-
- return boost::shared_ptr<WorldObjData>(entrance);
}
void
Index: EntranceData.hh
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/EntranceData.hh,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- EntranceData.hh 8 Jun 2002 23:11:07 -0000 1.10
+++ EntranceData.hh 9 Jun 2002 13:03:11 -0000 1.11
@@ -41,6 +41,8 @@
/// The type of the entrance type (woodthing, generic, etc.)
std::string type;
+ EntranceData (xmlDocPtr doc, xmlNodePtr cur);
+
EntranceData() {
clean();
}
@@ -55,7 +57,6 @@
}
void write_xml(std::ofstream *);
- static boost::shared_ptr<WorldObjData> create(xmlDocPtr doc, xmlNodePtr cur);
EditorObjLst create_EditorObj();
boost::shared_ptr<WorldObj> create_WorldObj();
Index: ExitData.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/ExitData.cc,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- ExitData.cc 8 Jun 2002 23:11:07 -0000 1.10
+++ ExitData.cc 9 Jun 2002 13:03:11 -0000 1.11
@@ -22,37 +22,18 @@
#include "StringConverter.hh"
#include "XMLhelper.hh"
-void
-ExitData::write_xml(std::ofstream* xml)
-{
- (*xml) << "<exit use-old-pos-handling=\"" << use_old_pos_handling << "\">\n";
-
- // FIXME: Repair me
- //pos.x += surf.get_width ()/2;
- //pos.y += surf.get_height ();
- XMLhelper::write_vector_xml(xml, pos);
-
- XMLhelper::write_desc_xml(xml, desc);
- (*xml) << " <owner-id>" << owner_id << "</owner-id>"
- << "</exit>\n"
- << std::endl;
-}
-
-boost::shared_ptr<WorldObjData>
-ExitData::create(xmlDocPtr doc, xmlNodePtr cur)
+ExitData::ExitData (xmlDocPtr doc, xmlNodePtr cur)
{
- ExitData* exit = new ExitData ();
-
char* pos_handling = (char*)xmlGetProp(cur,
(xmlChar*)"use-old-pos-handling");
if (pos_handling)
{
std::cout << "XMLPLF: Use Old Pos Handling: " << pos_handling <<
std::endl;
- exit->use_old_pos_handling = static_cast<bool>(StringConverter::to_int
(pos_handling));
+ use_old_pos_handling = static_cast<bool>(StringConverter::to_int
(pos_handling));
free (pos_handling);
}
else
{
- exit->use_old_pos_handling = true;
+ use_old_pos_handling = true;
}
cur = cur->children;
@@ -66,15 +47,15 @@
if (strcmp((char*)cur->name, "position") == 0)
{
- exit->pos = XMLhelper::parse_vector(doc, cur);
+ pos = XMLhelper::parse_vector(doc, cur);
}
else if (strcmp((char*)cur->name, "surface") == 0)
{
- exit->desc = XMLhelper::parse_surface(doc, cur);
+ desc = XMLhelper::parse_surface(doc, cur);
}
else if (strcmp((char*)cur->name, "owner-id") == 0)
{
- exit->owner_id = XMLhelper::parse_int(doc, cur);
+ owner_id = XMLhelper::parse_int(doc, cur);
}
else
{
@@ -82,8 +63,22 @@
}
cur = cur->next;
}
+}
- return boost::shared_ptr<WorldObjData> (exit);
+void
+ExitData::write_xml(std::ofstream* xml)
+{
+ (*xml) << "<exit use-old-pos-handling=\"" << use_old_pos_handling << "\">\n";
+
+ // FIXME: Repair me
+ //pos.x += surf.get_width ()/2;
+ //pos.y += surf.get_height ();
+ XMLhelper::write_vector_xml(xml, pos);
+
+ XMLhelper::write_desc_xml(xml, desc);
+ (*xml) << " <owner-id>" << owner_id << "</owner-id>"
+ << "</exit>\n"
+ << std::endl;
}
boost::shared_ptr<WorldObj>
Index: ExitData.hh
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/ExitData.hh,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- ExitData.hh 8 Jun 2002 20:19:53 -0000 1.8
+++ ExitData.hh 9 Jun 2002 13:03:11 -0000 1.9
@@ -44,6 +44,8 @@
///
ExitData() { clean (); }
+ ExitData (xmlDocPtr doc, xmlNodePtr cur);
+
/// Reset the values to default
void clean(void)
{
@@ -52,7 +54,6 @@
}
void write_xml(std::ofstream *);
- static boost::shared_ptr<WorldObjData> create(xmlDocPtr doc, xmlNodePtr cur);
boost::shared_ptr<WorldObj> create_WorldObj();
EditorObjLst create_EditorObj();
Index: HotspotData.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/HotspotData.cc,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- HotspotData.cc 8 Jun 2002 23:11:07 -0000 1.7
+++ HotspotData.cc 9 Jun 2002 13:03:11 -0000 1.8
@@ -34,10 +34,8 @@
<< std::endl;
}
-boost::shared_ptr<WorldObjData>
-HotspotData::create(xmlDocPtr doc, xmlNodePtr cur)
+HotspotData::HotspotData (xmlDocPtr doc, xmlNodePtr cur)
{
- HotspotData* hotspot = new HotspotData ();
cur = cur->children;
while (cur != NULL)
{
@@ -49,19 +47,19 @@
if (strcmp((char*)cur->name, "surface") == 0)
{
- hotspot->desc = XMLhelper::parse_surface(doc, cur);
+ desc = XMLhelper::parse_surface(doc, cur);
}
else if (strcmp((char*)cur->name, "position") == 0)
{
- hotspot->pos = XMLhelper::parse_vector(doc, cur);
+ pos = XMLhelper::parse_vector(doc, cur);
}
else if (strcmp((char*)cur->name, "speed") == 0)
{
- hotspot->speed = XMLhelper::parse_int(doc, cur);
+ speed = XMLhelper::parse_int(doc, cur);
}
else if (strcmp((char*)cur->name, "parallax") == 0)
{
- hotspot->para = XMLhelper::parse_int(doc, cur);
+ para = XMLhelper::parse_int(doc, cur);
}
else
{
@@ -69,8 +67,6 @@
}
cur = cur->next;
}
-
- return boost::shared_ptr<WorldObjData> (hotspot);
}
boost::shared_ptr<WorldObj>
Index: HotspotData.hh
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/HotspotData.hh,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- HotspotData.hh 8 Jun 2002 23:11:07 -0000 1.8
+++ HotspotData.hh 9 Jun 2002 13:03:11 -0000 1.9
@@ -39,6 +39,8 @@
HotspotData() {
clean();
}
+ HotspotData (xmlDocPtr doc, xmlNodePtr cur);
+
void clean() {
pos.x = 0;
@@ -49,7 +51,6 @@
}
void write_xml(std::ofstream *);
- static boost::shared_ptr<WorldObjData> create(xmlDocPtr doc, xmlNodePtr cur);
boost::shared_ptr<WorldObj> create_WorldObj();
EditorObjLst create_EditorObj();
Index: LiquidData.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/LiquidData.cc,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- LiquidData.cc 8 Jun 2002 21:43:36 -0000 1.8
+++ LiquidData.cc 9 Jun 2002 13:03:11 -0000 1.9
@@ -36,23 +36,21 @@
<< "</liquid>\n" << std::endl;
}
-boost::shared_ptr<WorldObjData>
-LiquidData::create(xmlDocPtr doc, xmlNodePtr cur)
+LiquidData::LiquidData (xmlDocPtr doc, xmlNodePtr cur)
{
std::cout << "LiquidData::create(xmlDocPtr doc, xmlNodePtr cur)" <<
std::endl;
- LiquidData* liquid = new LiquidData ();
char* width_handling = (char*)xmlGetProp(cur,
(xmlChar*)"use-old-width-handling");
if (width_handling)
{
std::cout << "XMLPLF: Use Old Width Handling: " << width_handling <<
std::endl;
- liquid->old_width_handling
+ old_width_handling
= static_cast<bool>(StringConverter::to_int (width_handling));
free (width_handling);
}
else
{
- liquid->old_width_handling = true;
+ old_width_handling = true;
}
cur = cur->children;
@@ -65,13 +63,13 @@
}
if (strcmp((char*)cur->name, "position") == 0)
- liquid->pos = XMLhelper::parse_vector(doc, cur);
+ pos = XMLhelper::parse_vector(doc, cur);
else if (strcmp((char*)cur->name, "surface") == 0)
- liquid->desc = XMLhelper::parse_surface(doc, cur);
+ desc = XMLhelper::parse_surface(doc, cur);
else if (strcmp((char*)cur->name, "speed") == 0)
- liquid->speed = XMLhelper::parse_int(doc, cur);
+ speed = XMLhelper::parse_int(doc, cur);
else if (strcmp((char*)cur->name, "width") == 0)
- liquid->width = XMLhelper::parse_int(doc, cur);
+ width = XMLhelper::parse_int(doc, cur);
else
{
std::cout << "XMLPLF::parse_liquid: Unhandled: " << cur->name <<
std::endl;
@@ -79,8 +77,6 @@
cur = cur->next;
}
-
- return boost::shared_ptr<WorldObjData> (liquid);
}
boost::shared_ptr<WorldObj>
Index: LiquidData.hh
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/LiquidData.hh,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- LiquidData.hh 8 Jun 2002 23:11:07 -0000 1.11
+++ LiquidData.hh 9 Jun 2002 13:03:11 -0000 1.12
@@ -46,6 +46,7 @@
{
clean();
}
+ LiquidData (xmlDocPtr doc, xmlNodePtr cur);
/** Reset the object to some reasonable defaults */
void clean()
@@ -59,7 +60,6 @@
}
void write_xml(std::ofstream*);
- static boost::shared_ptr<WorldObjData> create(xmlDocPtr doc, xmlNodePtr cur);
/** Create an WorldObj from the given data object */
boost::shared_ptr<WorldObj> create_WorldObj ();
Index: PLF.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/PLF.cc,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- PLF.cc 8 Jun 2002 23:11:07 -0000 1.31
+++ PLF.cc 9 Jun 2002 13:03:11 -0000 1.32
@@ -22,7 +22,8 @@
#include <cstdlib>
#include <fstream>
-#include "PLF.hh"
+#include "XMLPLF.hh"
+#include "PLFPLF.hh"
#include "algo.hh"
#include "globals.hh"
#include "PingusError.hh"
@@ -49,6 +50,12 @@
// Destroy all data
PLF::~PLF()
{
+ std::cout << "PLF::~PLF: Deleting std::vector<WorldObjData*>" << std::endl;
+ for (std::vector<WorldObjData*>::iterator i = worldobjs_data.begin ();
+ i != worldobjs_data.end (); ++i)
+ {
+ delete *i;
+ }
}
/*
vector<shared_ptr<BackgroundData> >
@@ -217,11 +224,24 @@
}
///
-std::vector<shared_ptr<WorldObjData> >
+std::vector<WorldObjData*>
PLF::get_worldobjs_data ()
{
//std::cout << "World: " << worldobjs_data.size () << std::endl;
return worldobjs_data;
+}
+
+PLF*
+PLF::create (const std::string& pathname)
+{
+ std::string extension = System::extension (pathname);
+
+ if (extension == "xml")
+ return new XMLPLF (pathname);
+ else if (extension == "plf")
+ return new PLFPLF (pathname);
+ else // filename does not have an extension, default to xml
+ return new XMLPLF (pathname);
}
/* EOF */
Index: PLF.hh
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/PLF.hh,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- PLF.hh 8 Jun 2002 23:11:07 -0000 1.30
+++ PLF.hh 9 Jun 2002 13:03:11 -0000 1.31
@@ -79,7 +79,10 @@
std::vector<ActionData> actions;
std::vector<GroundpieceData> groundpieces;
std::vector<WeatherData> weathers;
- std::vector<boost::shared_ptr<WorldObjData> > worldobjs_data;
+
+ /** FIXME: PLF should probally become and interface only, it currently is a
+ bit overfull */
+ std::vector<WorldObjData*> worldobjs_data;
public:
///
@@ -144,7 +147,14 @@
std::vector<ActionData> get_actions(void);
std::vector<GroundpieceData> get_groundpieces(void);
std::vector<WeatherData> get_weather(void);
- std::vector<boost::shared_ptr<WorldObjData> > get_worldobjs_data ();
+
+ /** Return a access to the worldobj_data, the caller must not delete
+ anything in this vector */
+ std::vector<WorldObjData*> get_worldobjs_data ();
+
+ /** Creates a PLF (XMLPLF or PLFPLF, depending on the file
+ extension) from a file. The pathname must be complete */
+ static PLF* create (const std::string& pathname);
};
#endif
Index: PLFPLF.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/PLFPLF.cc,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- PLFPLF.cc 8 Jun 2002 23:11:07 -0000 1.14
+++ PLFPLF.cc 9 Jun 2002 13:03:11 -0000 1.15
@@ -331,32 +331,32 @@
// flush collected data
switch(current_group) {
case PLFPLF::BACKGROUND:
- worldobjs_data.push_back(boost::shared_ptr<WorldObjData> (new
SurfaceBackgroundData(sur_background)));
+ worldobjs_data.push_back(new SurfaceBackgroundData(sur_background));
sur_background = SurfaceBackgroundData ();
break;
case PLFPLF::EXIT:
- worldobjs_data.push_back(boost::shared_ptr<WorldObjData> (new
ExitData(exit_s)));
+ worldobjs_data.push_back(new ExitData(exit_s));
exit_s.clean();
break;
case PLFPLF::ENTRANCE:
- worldobjs_data.push_back(boost::shared_ptr<WorldObjData> (new
EntranceData(entrance_s)));
+ worldobjs_data.push_back(new EntranceData(entrance_s));
entrance_s.clean();
break;
case PLFPLF::TRAP:
- worldobjs_data.push_back(boost::shared_ptr<WorldObjData> (new TrapData
(trap_s)));
+ worldobjs_data.push_back(new TrapData (trap_s));
trap_s.clean();
break;
case PLFPLF::HOTSPOT:
- worldobjs_data.push_back(boost::shared_ptr<WorldObjData> (new HotspotData
(hotspot_s)));
+ worldobjs_data.push_back(new HotspotData (hotspot_s));
hotspot_s.clean();
break;
case PLFPLF::LIQUID:
- worldobjs_data.push_back(boost::shared_ptr<WorldObjData> (new
LiquidData(liquid_s)));
+ worldobjs_data.push_back(new LiquidData(liquid_s));
liquid_s.clean();
break;
Index: PinguActionFactory.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/PinguActionFactory.cc,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- PinguActionFactory.cc 9 Jun 2002 11:18:50 -0000 1.6
+++ PinguActionFactory.cc 9 Jun 2002 13:03:11 -0000 1.7
@@ -117,6 +117,7 @@
{
delete *i;
}
+ all_actions.clear ();
std::cout << "PinguActionFactory::delete_actions (): Deleting all Actions:
done" << std::endl;
}
Index: PingusGameSession.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/PingusGameSession.cc,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- PingusGameSession.cc 8 Jun 2002 20:19:53 -0000 1.14
+++ PingusGameSession.cc 9 Jun 2002 13:03:11 -0000 1.15
@@ -17,8 +17,6 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#include "XMLPLF.hh"
-#include "PLFPLF.hh"
#include "Client.hh"
#include "TrueServer.hh"
#include "MouseController.hh"
@@ -30,7 +28,7 @@
PingusGameSession::PingusGameSession (std::string arg_filename)
: filename (arg_filename),
- plf(create_plf (filename)),
+ plf(PLF::create (filename)),
server (new TrueServer (plf)),
client (new Client(shared_ptr<Controller>(new MouseController ()),
server))
@@ -56,19 +54,6 @@
PingusGameSession::get_result ()
{
return PingusGameSessionResult ();
-}
-
-PLF*
-PingusGameSession::create_plf (std::string pathname)
-{
- std::string extension = System::extension (pathname);
-
- if (extension == "xml")
- return new XMLPLF (filename);
- else if (extension == "plf")
- return new PLFPLF (filename);
- else // filename does not have an extension, default to xml
- return new XMLPLF (filename);
}
/* EOF */
Index: TrapData.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/TrapData.cc,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- TrapData.cc 8 Jun 2002 21:43:36 -0000 1.10
+++ TrapData.cc 9 Jun 2002 13:03:11 -0000 1.11
@@ -31,20 +31,8 @@
#include "XMLhelper.hh"
#include "TrapData.hh"
-void
-TrapData::write_xml(std::ofstream* xml)
-{
- (*xml) << "<trap>\n"
- << " <type>" << type << "</type>\n";
- XMLhelper::write_vector_xml(xml, pos);
- (*xml) << "</trap>\n"
- << std::endl;
-}
-
-boost::shared_ptr<WorldObjData>
-TrapData::create(xmlDocPtr doc, xmlNodePtr cur)
+TrapData::TrapData (xmlDocPtr doc, xmlNodePtr cur)
{
- TrapData* trap = new TrapData ();
cur = cur->children;
while (cur != NULL)
{
@@ -60,18 +48,27 @@
if (name)
{
// std::cout << "parse_trap: name = " << name << std::endl;
- trap->type = name;
+ type = name;
free(name);
}
}
else if (strcmp((char*)cur->name, "position") == 0)
{
- trap->pos = XMLhelper::parse_vector(doc, cur);
+ pos = XMLhelper::parse_vector(doc, cur);
}
cur = cur->next;
}
- return boost::shared_ptr<WorldObjData>(trap);
+}
+
+void
+TrapData::write_xml(std::ofstream* xml)
+{
+ (*xml) << "<trap>\n"
+ << " <type>" << type << "</type>\n";
+ XMLhelper::write_vector_xml(xml, pos);
+ (*xml) << "</trap>\n"
+ << std::endl;
}
boost::shared_ptr<WorldObj>
Index: TrapData.hh
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/TrapData.hh,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- TrapData.hh 8 Jun 2002 20:19:54 -0000 1.13
+++ TrapData.hh 9 Jun 2002 13:03:11 -0000 1.14
@@ -47,12 +47,11 @@
: WorldObjData(data),
type (data.type),
pos (data.pos) {}
+ TrapData (xmlDocPtr doc, xmlNodePtr cur);
virtual ~TrapData(){}
void clean(){}
void write_xml(std::ofstream* xml);
-
- static boost::shared_ptr<WorldObjData> create(xmlDocPtr doc, xmlNodePtr cur);
/** Create an WorldObj from the given data object */
boost::shared_ptr<WorldObj> create_WorldObj ();
Index: World.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/World.cc,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- World.cc 8 Jun 2002 16:08:16 -0000 1.69
+++ World.cc 9 Jun 2002 13:03:11 -0000 1.70
@@ -194,8 +194,8 @@
void
World::init_worldobjs()
{
- vector<WeatherData> weather_d = plf->get_weather();
- vector<shared_ptr<WorldObjData> > worldobj_d = plf->get_worldobjs_data ();
+ vector<WeatherData> weather_d = plf->get_weather();
+ vector<WorldObjData*> worldobj_d = plf->get_worldobjs_data ();
for(vector<WeatherData>::iterator i = weather_d.begin();
i != weather_d.end();
@@ -204,7 +204,7 @@
world_obj.push_back(WeatherGenerator::create(*i));
}
- for (vector<shared_ptr<WorldObjData> >::iterator i = worldobj_d.begin ();
+ for (vector<WorldObjData*>::iterator i = worldobj_d.begin ();
i != worldobj_d.end ();
i++)
{
Index: WorldObjDataFactory.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/WorldObjDataFactory.cc,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- WorldObjDataFactory.cc 30 Nov 2001 20:22:20 -0000 1.5
+++ WorldObjDataFactory.cc 9 Jun 2002 13:03:11 -0000 1.6
@@ -74,7 +74,7 @@
return instance_;
}
-boost::shared_ptr<WorldObjData>
+WorldObjData*
WorldObjDataFactory::create (xmlDocPtr doc, xmlNodePtr cur)
{
std::cout << "WorldObjDataFactory::create (xmlDocPtr doc, xmlNodePtr cur)"
<< std::endl;
@@ -89,7 +89,7 @@
}
}
-boost::shared_ptr<WorldObjData>
+WorldObjData*
WorldObjDataFactory::create (const std::string& id,
xmlDocPtr doc, xmlNodePtr cur)
{
@@ -100,7 +100,7 @@
if (it == factories.end())
throw PingusError("WorldObjDataFactory: Invalid id: " + id);
else
- return boost::shared_ptr<WorldObjData> (it->second->create (doc, cur));
+ return it->second->create (doc, cur);
}
void
Index: WorldObjDataFactory.hh
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/WorldObjDataFactory.hh,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- WorldObjDataFactory.hh 15 Jan 2002 11:27:34 -0000 1.5
+++ WorldObjDataFactory.hh 9 Jun 2002 13:03:11 -0000 1.6
@@ -48,13 +48,13 @@
/** Create a WorldObjData type from a given piece of xml, use the
'type' property for determinating the object type. */
- boost::shared_ptr<WorldObjData> create (xmlDocPtr doc, xmlNodePtr cur);
+ WorldObjData* create (xmlDocPtr doc, xmlNodePtr cur);
/** Create a WorldObjData type from a given piece of xml, use the
given id value for determinating the object type instead of the
'type' property. This is for backward compatibility only! */
- boost::shared_ptr<WorldObjData> create (const std::string& id,
- xmlDocPtr doc, xmlNodePtr cur);
+ WorldObjData* create (const std::string& id,
+ xmlDocPtr doc, xmlNodePtr cur);
};
/** WorldObjDataAbstractFactory, interface for creating factories */
@@ -65,7 +65,7 @@
WorldObjDataFactory::instance ()-> register_factory (id, this);
}
- virtual boost::shared_ptr<WorldObjData> create (xmlDocPtr doc, xmlNodePtr
cur) =0;
+ virtual WorldObjData* create (xmlDocPtr doc, xmlNodePtr cur) =0;
};
/** Template to create factories, usage:
@@ -77,8 +77,8 @@
WorldObjDataFactoryImpl (const std::string& id)
: WorldObjDataAbstractFactory (id) {}
- boost::shared_ptr<WorldObjData> create (xmlDocPtr doc, xmlNodePtr cur) {
- return T::create (doc, cur);
+ WorldObjData* create (xmlDocPtr doc, xmlNodePtr cur) {
+ return new T (doc, cur);
}
};
Index: WorldObjGroupData.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/WorldObjGroupData.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- WorldObjGroupData.cc 8 Jun 2002 20:19:54 -0000 1.4
+++ WorldObjGroupData.cc 9 Jun 2002 13:03:11 -0000 1.5
@@ -23,8 +23,19 @@
#include "WorldObj.hh"
#include "WorldObjGroupData.hh"
+WorldObjGroupData::WorldObjGroupData ()
+{
+}
+
+WorldObjGroupData::~WorldObjGroupData ()
+{
+ std::cout << "WorldObjGroupData::~WorldObjGroupData ()" << std::endl;
+ for (ObjsIter i = objs.begin (); i != objs.end (); ++i)
+ delete *i;
+}
+
void
-WorldObjGroupData::add (boost::shared_ptr<WorldObjData> data)
+WorldObjGroupData::add (WorldObjData* data)
{
objs.push_back (data);
}
Index: WorldObjGroupData.hh
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/WorldObjGroupData.hh,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- WorldObjGroupData.hh 15 Jan 2002 10:48:49 -0000 1.2
+++ WorldObjGroupData.hh 9 Jun 2002 13:03:11 -0000 1.3
@@ -29,11 +29,14 @@
class WorldObjGroupData : public WorldObjData
{
private:
- std::list<boost::shared_ptr<WorldObjData> > objs;
- typedef std::list<boost::shared_ptr<WorldObjData> >::iterator ObjsIter;
+ std::vector<WorldObjData*> objs;
+ typedef std::vector<WorldObjData*>::iterator ObjsIter;
public:
- void add (boost::shared_ptr<WorldObjData>);
+ WorldObjGroupData ();
+ ~WorldObjGroupData ();
+
+ void add (WorldObjData*);
void write_xml (std::ofstream* xml);
Index: XMLPLF.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/XMLPLF.cc,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- XMLPLF.cc 8 Jun 2002 21:43:36 -0000 1.44
+++ XMLPLF.cc 9 Jun 2002 13:03:11 -0000 1.45
@@ -114,23 +114,23 @@
}
else if (strcmp((char*)cur->name, "exit") == 0)
{
- worldobjs_data.push_back (ExitData::create (doc, cur));
+ worldobjs_data.push_back (new ExitData (doc, cur));
}
else if (strcmp((char*)cur->name, "entrance") == 0)
{
- worldobjs_data.push_back (EntranceData::create (doc, cur));
+ worldobjs_data.push_back (new EntranceData (doc, cur));
}
else if (strcmp((char*)cur->name, "trap") == 0)
{
- worldobjs_data.push_back (TrapData::create (doc, cur));
+ worldobjs_data.push_back (new TrapData (doc, cur));
}
else if (strcmp((char*)cur->name, "hotspot") == 0)
{
- worldobjs_data.push_back(HotspotData::create (doc, cur));
+ worldobjs_data.push_back(new HotspotData (doc, cur));
}
else if (strcmp((char*)cur->name, "liquid") == 0)
{
- worldobjs_data.push_back(LiquidData::create (doc, cur));
+ worldobjs_data.push_back(new LiquidData (doc, cur));
}
else if (strcmp ((char*)cur->name, "worldobj") == 0)
{
@@ -235,23 +235,23 @@
}
else if (strcmp((char*)cur->name, "exit") == 0)
{
- group->add (ExitData::create (doc, cur));
+ group->add (new ExitData (doc, cur));
}
else if (strcmp((char*)cur->name, "entrance") == 0)
{
- group->add (EntranceData::create (doc, cur));
+ group->add (new EntranceData (doc, cur));
}
else if (strcmp((char*)cur->name, "trap") == 0)
{
- group->add (TrapData::create (doc, cur));
+ group->add (new TrapData (doc, cur));
}
else if (strcmp((char*)cur->name, "hotspot") == 0)
{
- group->add(HotspotData::create (doc, cur));
+ group->add(new HotspotData (doc, cur));
}
else if (strcmp((char*)cur->name, "liquid") == 0)
{
- group->add(LiquidData::create (doc, cur));
+ group->add(new LiquidData (doc, cur));
}
else if (strcmp((char*)cur->name, "group") == 0)
{
@@ -268,7 +268,7 @@
cur = cur->next;
}
- worldobjs_data.push_back (boost::shared_ptr<WorldObjData> (group));
+ worldobjs_data.push_back (group);
}
void
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src ActionHolder.cc,1.34,1.35 EntranceData.cc,1.7,1.8 EntranceData.hh,1.10,1.11 ExitData.cc,1.10,1.11 ExitData.hh,1.8,1.9 HotspotData.cc,1.7,1.8 HotspotData.hh,1.8,1.9 LiquidData.cc,1.8,1.9 LiquidData.hh,1.11,1.12 PLF.cc,1.31,1.32 PLF.hh,1.30,1.31 PLFPLF.cc,1.14,1.15 PinguActionFactory.cc,1.6,1.7 PingusGameSession.cc,1.14,1.15 TrapData.cc,1.10,1.11 TrapData.hh,1.13,1.14 World.cc,1.69,1.70 WorldObjDataFactory.cc,1.5,1.6 WorldObjDataFactory.hh,1.5,1.6 WorldObjGroupData.cc,1.4,1.5 WorldObjGroupData.hh,1.2,1.3 XMLPLF.cc,1.44,1.45,
grumbel <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src/backgrounds SolidColorBackground.cc,1.13,1.14 SolidColorBackground.hh,1.16,1.17 StarfieldBackground.cc,1.20,1.21 StarfieldBackground.hh,1.16,1.17 SurfaceBackgroundData.cc,1.18,1.19 SurfaceBackgroundData.hh,1.15,1.16 ThunderstormBackgroundData.cc,1.11,1.12 ThunderstormBackgroundData.hh,1.8,1.9
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src/worldobjs ConveyorBelt.cc,1.33,1.34 ConveyorBelt.hh,1.20,1.21 IceBlock.cc,1.27,1.28 IceBlock.hh,1.21,1.22 InfoBox.cc,1.6,1.7 InfoBox.hh,1.5,1.6 SwitchDoor.cc,1.29,1.30 SwitchDoor.hh,1.22,1.23 Teleporter.cc,1.36,1.37 Teleporter.hh,1.27,1.28
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src/backgrounds SolidColorBackground.cc,1.13,1.14 SolidColorBackground.hh,1.16,1.17 StarfieldBackground.cc,1.20,1.21 StarfieldBackground.hh,1.16,1.17 SurfaceBackgroundData.cc,1.18,1.19 SurfaceBackgroundData.hh,1.15,1.16 ThunderstormBackgroundData.cc,1.11,1.12 ThunderstormBackgroundData.hh,1.8,1.9
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src/worldobjs ConveyorBelt.cc,1.33,1.34 ConveyorBelt.hh,1.20,1.21 IceBlock.cc,1.27,1.28 IceBlock.hh,1.21,1.22 InfoBox.cc,1.6,1.7 InfoBox.hh,1.5,1.6 SwitchDoor.cc,1.29,1.30 SwitchDoor.hh,1.22,1.23 Teleporter.cc,1.36,1.37 Teleporter.hh,1.27,1.28
- Index(es):