[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src ActionHolder.cc,1.33,1.34 ActionHolde
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src ActionHolder.cc,1.33,1.34 ActionHolder.hh,1.15,1.16 CaptureRectangle.cc,1.19,1.20 CaptureRectangle.hh,1.16,1.17 Entrance.cc,1.28,1.29 Pingu.cc,1.74,1.75 Pingu.hh,1.41,1.42 PinguAction.cc,1.24,1.25 PinguActionFactory.cc,1.4,1.5 PinguActionFactory.hh,1.3,1.4 PinguHolder.cc,1.19,1.20 PinguInfo.cc,1.11,1.12 PingusMain.cc,1.61,1.62 Server.cc,1.29,1.30 |
Date: |
9 Jun 2002 00:56:28 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv27823
Modified Files:
ActionHolder.cc ActionHolder.hh CaptureRectangle.cc
CaptureRectangle.hh Entrance.cc Pingu.cc Pingu.hh
PinguAction.cc PinguActionFactory.cc PinguActionFactory.hh
PinguHolder.cc PinguInfo.cc PingusMain.cc Server.cc
Log Message:
- replaced shared_ptr<PinguAction> with PinguAction*
- this commit is incomplete, it compiles, but segfault at level startup, will
fix that tomorrow if I find the bug
Index: ActionHolder.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/ActionHolder.cc,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- ActionHolder.cc 8 Jun 2002 22:38:32 -0000 1.33
+++ ActionHolder.cc 9 Jun 2002 00:56:25 -0000 1.34
@@ -61,12 +61,12 @@
return available_actions[name];
}
-boost::shared_ptr<PinguAction>
+PinguAction*
ActionHolder::get_action(const std::string& name)
{
if (unlimited_actions) // runtime option; defined in global.hh
{
- return shared_ptr<PinguAction>(PinguActionFactory::instance
()->create(name));
+ return PinguActionFactory::instance ()->create(name);
}
else
{
@@ -74,11 +74,11 @@
if (count > 0)
{
--count;
- return shared_ptr<PinguAction>(PinguActionFactory::instance
()->create(name));
+ return PinguActionFactory::instance ()->create(name);
}
else // Out of actions
{
- return shared_ptr<PinguAction>();
+ return 0;
}
}
}
Index: ActionHolder.hh
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/ActionHolder.hh,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- ActionHolder.hh 8 Jun 2002 22:38:32 -0000 1.15
+++ ActionHolder.hh 9 Jun 2002 00:56:25 -0000 1.16
@@ -80,7 +80,7 @@
* actions if necessary. If the actions are out, it returns 0.
* The deletion of the action is handled by this class.
*/
- boost::shared_ptr<PinguAction> get_action(const std::string&);
+ PinguAction* get_action(const std::string&);
};
#endif
Index: CaptureRectangle.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/CaptureRectangle.cc,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- CaptureRectangle.cc 8 Jun 2002 23:11:07 -0000 1.19
+++ CaptureRectangle.cc 9 Jun 2002 00:56:25 -0000 1.20
@@ -31,6 +31,7 @@
CaptureRectangle::CaptureRectangle()
: pingu (0),
+ button_action (0),
owner_id (0),
good (PingusResource::load_surface("Cursors/capgood", "game")),
bad (PingusResource::load_surface("Cursors/capbad", "game")),
@@ -59,8 +60,7 @@
{
Sprite * sur;
- if (button_action.get()
- && (button_action->get_environment() & pingu->get_environment()))
+ if (button_action && (button_action->get_environment() &
pingu->get_environment()))
sur = &bad;
else
sur = &good;
@@ -69,11 +69,11 @@
{
std::string action_str = pingu->get_action()->get_name();
- std::vector<boost::shared_ptr<PinguAction> >* persitant =
pingu->get_persistent_actions ();
+ std::vector<PinguAction*>* persitant = pingu->get_persistent_actions
();
if (persitant->size() > 0)
{
action_str += " [";
- for (std::vector<boost::shared_ptr<PinguAction> >::iterator i =
persitant->begin ();
+ for (std::vector<PinguAction*>::iterator i = persitant->begin ();
i != persitant->end (); ++i)
{
action_str += (*i)->get_persistent_char ();
@@ -85,7 +85,7 @@
sur->put_screen(pingu->get_center_pos() +
CL_Vector(x_offset,y_offset));
// If pingu has an action, print its name
- if (pingu->get_action().get())
+ if (pingu->get_action())
{
font->print_center(int(pingu->get_center_pos().x) + x_offset,
int(pingu->get_center_pos().y) + y_offset - 32,
@@ -116,7 +116,7 @@
// Sets the current buttons action, it is used to change the color of
// the cap rect, if the action can't be applied.
void
-CaptureRectangle::set_action(shared_ptr<PinguAction> action)
+CaptureRectangle::set_action(PinguAction* action)
{
button_action = action;
}
Index: CaptureRectangle.hh
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/CaptureRectangle.hh,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- CaptureRectangle.hh 8 Jun 2002 23:11:07 -0000 1.16
+++ CaptureRectangle.hh 9 Jun 2002 00:56:25 -0000 1.17
@@ -40,7 +40,7 @@
{
private:
Pingu* pingu;
- boost::shared_ptr<PinguAction> button_action;
+ PinguAction* button_action;
/// The id of the owner of this capture rectangle
int owner_id;
@@ -56,7 +56,7 @@
~CaptureRectangle();
void set_pingu(Pingu* pingu);
- void set_action(boost::shared_ptr<PinguAction>);
+ void set_action(PinguAction*);
void draw_offset(int x_offset, int y_offset, float s = 1.0);
};
Index: Entrance.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/Entrance.cc,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- Entrance.cc 8 Jun 2002 16:08:16 -0000 1.28
+++ Entrance.cc 9 Jun 2002 00:56:25 -0000 1.29
@@ -37,6 +37,8 @@
last_release = -release_rate;
direction = data.direction;
owner_id = data.owner_id;
+
+ std::cout << "XXXXXXXXXXX: Entrance: owner_id: " << owner_id << std::endl;
}
bool
@@ -56,13 +58,14 @@
static int last_direction;
Direction d;
- Pingu* p (world->get_pingu_p()->create_pingu (pos, owner_id));
-
+ std::cout << "XXX Entrance::get_pingu()" << std::endl;
+ Pingu* pingu = world->get_pingu_p()->create_pingu (pos, owner_id);
+ std::cout << "XXX Pingu created" << std::endl;
switch (direction)
{
case EntranceData::LEFT:
d.left();
- p->set_direction(d);
+ pingu->set_direction(d);
break;
case EntranceData::MISC:
@@ -76,22 +79,23 @@
d.right();
last_direction = 1;
}
- p->set_direction(d);
+ pingu->set_direction(d);
break;
case EntranceData::RIGHT:
d.right();
- p->set_direction(d);
+ pingu->set_direction(d);
break;
default:
std::cout << "Entrance:: Warning direction is wrong: " << direction <<
std::endl;
d.right();
- p->set_direction(d);
+ pingu->set_direction(d);
break;
}
- return p;
+ std::cout << "XXX Entrance::get_pingu(): done" << std::endl;
+ return pingu;
}
void
Index: Pingu.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/Pingu.cc,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -d -r1.74 -r1.75
--- Pingu.cc 8 Jun 2002 23:11:07 -0000 1.74
+++ Pingu.cc 9 Jun 2002 00:56:25 -0000 1.75
@@ -44,13 +44,17 @@
// Init a pingu at the given position while falling
Pingu::Pingu(const CL_Vector& arg_pos, int owner)
- : id (++id_counter),
+ : action (0),
+ countdown_action (0),
+ id (++id_counter),
font (PingusResource::load_font("Fonts/numbers", "fonts")),
status (PS_ALIVE),
environment (ENV_LAND),
owner_id (owner),
pos (arg_pos)
{
+ std::cout << "XXXXXXXXXXX: Pingu: owner_id: " << owner_id << std::endl;
+
action_time = -1;
direction.left ();
@@ -59,6 +63,7 @@
velocity.x = 0;
velocity.y = 0;
+ std::cout << "XXX setting action" << std::endl;
set_action("faller");
}
@@ -110,9 +115,11 @@
// Set the action of the pingu (bridger, blocker, bomber, etc.)
// This function is used by external stuff, like the ButtonPanel, etc
int
-Pingu::set_action(boost::shared_ptr<PinguAction> act)
+Pingu::set_action(PinguAction* act)
{
- assert(act.get());
+ assert(act);
+
+ std::cout << "XXX Action:" << act << std::endl;
if (status == PS_DEAD)
{
@@ -121,6 +128,7 @@
return 0;
}
+ std::cout << "1. Pingu" << id << "::set_action(PinguAction* act): " << this
<< std::endl;
act->set_pingu(this);
// Use the activation time of the action
@@ -137,7 +145,7 @@
<< int(act->get_type() & (ActionType)WALL) << std::endl;
}
- for(std::vector<boost::shared_ptr<PinguAction> >::iterator i =
persist.begin(); i != persist.end(); i++)
+ for(std::vector<PinguAction*>::iterator i = persist.begin(); i !=
persist.end(); i++)
{
if ((*i)->get_name() == act->get_name())
{
@@ -166,7 +174,7 @@
if (act->activation_time() == -1)
{ // Immediately activate the action
- if (action.get() && (action->get_name() == act->get_name()))
+ if (action && (action->get_name() == act->get_name()))
{
if (pingus_debug_flags & PINGUS_DEBUG_ACTIONS)
std::cout << "Pingu: Already have action" << std::endl;
@@ -177,7 +185,7 @@
}
else
{ // Use the activation time, given by t
- if (countdown_action.get() && countdown_action->get_name() ==
act->get_name())
+ if (countdown_action && countdown_action->get_name() ==
act->get_name())
{
return false;
}
@@ -192,20 +200,21 @@
void
Pingu::set_action (const std::string& action_name)
{
- set_action (PinguActionFactory::instance ()->create_sp (action_name));
+ set_action (PinguActionFactory::instance ()->create (action_name));
}
void
Pingu::set_paction(const std::string& action_name)
{
- set_paction (PinguActionFactory::instance ()->create_sp (action_name));
+ set_paction (PinguActionFactory::instance ()->create (action_name));
}
// Sets an action without any checking
void
-Pingu::set_paction(boost::shared_ptr<PinguAction> act)
+Pingu::set_paction(PinguAction* act)
{
action = act;
+ std::cout << "2. Pingu::set_paction(PinguAction* act): " << this <<
std::endl;
action->set_pingu(this);
}
@@ -255,13 +264,13 @@
Pingu::update_persistent(float /*delta*/)
{
//
- if (environment == ENV_AIR && action.get() == 0 && rel_getpixel(0, -1) ==
ColMap::NOTHING)
+ if (environment == ENV_AIR && action == 0 && rel_getpixel(0, -1) ==
ColMap::NOTHING)
{
for (unsigned int i=0; i < persist.size(); ++i)
{
if (persist[i]->get_type() & (ActionType)FALL)
{
- if (action.get() && persist[i]->get_name() == action->get_name())
+ if (action && persist[i]->get_name() == action->get_name())
{
if (pingus_debug_flags & PINGUS_DEBUG_ACTIONS)
std::cout << "Pingu: Not using action, we already did." <<
std::endl;
@@ -295,22 +304,23 @@
if (action_time > -1)
--action_time;
- if (action_time == 0 && countdown_action.get())
+ if (action_time == 0 && countdown_action)
{
action = countdown_action;
+ std::cout << "3. Pingu::set_action(PinguAction* act): " << this <<
std::endl;
action->set_pingu(this);
}
- if (action.get() && action->is_finished)
+ if (action && action->is_finished)
{
- action.reset ();
+ action = 0;
}
update_persistent(delta);
/** When we have an action evaluate it, else evaluate the normal
walking */
- if (action.get())
+ if (action)
action->update(delta);
else
update_normal(delta);
@@ -334,7 +344,7 @@
char str[64];
y += 2;
- if (action.get())
+ if (action)
action->draw_offset(x, y,s);
if (action_time != -1)
@@ -376,7 +386,7 @@
if (status == PS_DEAD)
return false;
- if (action.get())
+ if (action)
return action->need_catch();
else
return false;
@@ -397,7 +407,7 @@
return false;
}
-boost::shared_ptr<PinguAction>
+PinguAction*
Pingu::get_action()
{
return action;
@@ -433,7 +443,7 @@
bool
Pingu::catchable ()
{
- if (action.get())
+ if (action)
return action->catchable ();
std::cout << "Pingu:catchable: No action given, default to true" <<
std::endl;
Index: Pingu.hh
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/Pingu.hh,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- Pingu.hh 8 Jun 2002 23:11:07 -0000 1.41
+++ Pingu.hh 9 Jun 2002 00:56:25 -0000 1.42
@@ -42,16 +42,16 @@
static int id_counter;
/** The primary action with is currently in use */
- boost::shared_ptr<PinguAction> action;
+ PinguAction* action;
/** A secondary action with will turn active after a given amount of time
The only example is currently the bomber. */
- boost::shared_ptr<PinguAction> countdown_action;
+ PinguAction* countdown_action;
/** A list of action with are activated on-demand, so when the pingu
is in the air a floater will get activated, if he needs to climb
a climber gets active. */
- std::vector<boost::shared_ptr<PinguAction> > persist;
+ std::vector<PinguAction*> persist;
/** The uniq id of the Pingu, this is used to refer to the Pingu in
a demo file or in a network connection */
@@ -72,7 +72,7 @@
/** Creates a new Pingu at the given coordinates
@param pos The start position of the pingu
@param owner The owner id of the pingu (used for multiplayer) */
- Pingu(const CL_Vector& pos, int owner = 0);
+ Pingu(const CL_Vector& pos, int owner);
/** Destruct the pingu... */
~Pingu();
@@ -121,17 +121,17 @@
// Set the pingu in the gives direction
void set_direction(Direction d);
- int set_action (boost::shared_ptr<PinguAction>);
+ int set_action (PinguAction*);
void set_action (const std::string& action_name);
/// FIXME: Stupid function name, need a better one.
- void set_paction (boost::shared_ptr<PinguAction>);
+ void set_paction (PinguAction*);
void set_paction (const std::string& action_name);
///
- boost::shared_ptr<PinguAction> get_action();
+ PinguAction* get_action();
- std::vector<boost::shared_ptr<PinguAction> >* get_persistent_actions () {
return &persist; }
+ std::vector<PinguAction*>* get_persistent_actions () { return &persist; }
/** Returns the `color' of the colmap in the walking direction
Examples:
Index: PinguAction.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/PinguAction.cc,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- PinguAction.cc 8 Jun 2002 23:11:07 -0000 1.24
+++ PinguAction.cc 9 Jun 2002 00:56:25 -0000 1.25
@@ -28,6 +28,7 @@
const int PinguAction::pingu_height = 26;
PinguAction::PinguAction()
+ : pingu (0)
{
is_finished = false;
}
@@ -39,8 +40,10 @@
void
PinguAction::set_pingu(Pingu* pingu_data)
{
+ std::cout << "PinguAction::set_pingu(" << pingu << ")" << std::endl;
+ std::cout << "Pingu:X: " << pingu->get_pos ().x << std::endl;;
pingu = pingu_data;
- //assert(pingu);
+ assert(pingu);
init();
}
Index: PinguActionFactory.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/PinguActionFactory.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- PinguActionFactory.cc 8 Jun 2002 20:19:53 -0000 1.4
+++ PinguActionFactory.cc 9 Jun 2002 00:56:25 -0000 1.5
@@ -101,13 +101,23 @@
if (it == factories.end())
throw PingusError("PinguActionFactory: Invalid id: " + id);
else
- return it->second->create ();
+ {
+ PinguAction* action;
+ all_actions.push_back (action);
+ return action;
+ }
}
-boost::shared_ptr<PinguAction>
-PinguActionFactory::create_sp (const std::string& id)
+void
+PinguActionFactory::delete_actions ()
{
- return boost::shared_ptr<PinguAction>(create (id));
+ std::cout << "PinguActionFactory::delete_actions (): Deleting all Actions"
<< std::endl;
+ for (std::vector<PinguAction*>::iterator i = all_actions.begin ();
+ i != all_actions.end (); ++i)
+ {
+ delete *i;
+ }
+ std::cout << "PinguActionFactory::delete_actions (): Deleting all Actions:
done" << std::endl;
}
void
Index: PinguActionFactory.hh
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/PinguActionFactory.hh,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- PinguActionFactory.hh 8 Jun 2002 20:19:53 -0000 1.3
+++ PinguActionFactory.hh 9 Jun 2002 00:56:25 -0000 1.4
@@ -33,6 +33,9 @@
class PinguActionFactory
{
private:
+ /** This vector saves all allocated actions to delete them at a later point
*/
+ std::vector<PinguAction*> all_actions;
+
std::map<std::string, PinguActionAbstractFactory*> factories;
static PinguActionFactory* instance_;
@@ -42,10 +45,13 @@
static PinguActionFactory* instance ();
void register_factory (const std::string& id, PinguActionAbstractFactory*);
+ /** Delete all actions which this class has allocated. This needs to
+ be called seperatly from the constructor, due to the used
+ singleton pattern. [FIXME] */
+ void delete_actions ();
+
/** Allocate the given action */
PinguAction* create (const std::string& id);
- /** Allocate the given action into a shared_ptr<> */
- boost::shared_ptr<PinguAction> create_sp (const std::string& id);
};
class PinguActionAbstractFactory
Index: PinguHolder.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/PinguHolder.cc,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- PinguHolder.cc 8 Jun 2002 23:11:07 -0000 1.19
+++ PinguHolder.cc 9 Jun 2002 00:56:25 -0000 1.20
@@ -55,7 +55,10 @@
Pingu*
PinguHolder::create_pingu (const CL_Vector& pos, int owner_id)
{
+ std::cout << "XXXXXXXXXXX: PinguHolder: owner_id: " << owner_id << std::endl;
+
Pingu* pingu = new Pingu (pos, owner_id);
+ std::cout << "XXXXX: Allocating new pingu done" << std::endl;
// This list will get evaluated and deleted and destruction
all_pingus.push_back (pingu);
@@ -86,7 +89,7 @@
{
// We don't draw the actions here, since we want them above
// all other pingus, for better visibility
- if (!((*pingu)->get_action().get()))
+ if (!(*pingu)->get_action())
(*pingu)->draw_offset(x_of, y_of, s);
}
}
@@ -94,7 +97,7 @@
// We draw all actions here, so we have them above all others
for(PinguIter pingu = pingus.begin(); pingu != pingus.end(); pingu++)
{
- if ((*pingu)->get_action().get())
+ if ((*pingu)->get_action())
(*pingu)->draw_offset(x_of, y_of, s);
}
}
Index: PinguInfo.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/PinguInfo.cc,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- PinguInfo.cc 8 Jun 2002 16:08:16 -0000 1.11
+++ PinguInfo.cc 9 Jun 2002 00:56:25 -0000 1.12
@@ -31,6 +31,7 @@
PinguInfo::PinguInfo()
+ : pingu (0)
{
font = PingusResource::load_font("Fonts/courier_small","fonts");
}
@@ -55,7 +56,7 @@
y_pos + CL_Display::get_height() - 50,
tolowerstr(str1));
- if (pingu->get_action().get()) {
+ if (pingu->get_action()) {
sprintf(str2, _("action %s"), pingu->get_action()->get_name().c_str());
} else {
sprintf(str2, _("action none"));
Index: PingusMain.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/PingusMain.cc,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- PingusMain.cc 8 Jun 2002 23:11:07 -0000 1.61
+++ PingusMain.cc 9 Jun 2002 00:56:25 -0000 1.62
@@ -855,8 +855,8 @@
PingusMain::main(int argc, char** argv)
{
// Register the segfault_handler
- signal(SIGSEGV, signal_handler);
- signal(SIGINT, signal_handler);
+ //signal(SIGSEGV, signal_handler);
+ //signal(SIGINT, signal_handler);
#ifdef WIN32
CL_ConsoleWindow cl_console(PACKAGE VERSION);
Index: Server.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/Server.cc,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- Server.cc 8 Jun 2002 23:11:08 -0000 1.29
+++ Server.cc 9 Jun 2002 00:56:26 -0000 1.30
@@ -165,9 +165,9 @@
if (pingu != pingus->end())
{
- boost::shared_ptr<PinguAction> tmp_action =
action_holder.get_action(action);
+ PinguAction* tmp_action = action_holder.get_action(action);
- if (tmp_action.get())
+ if (tmp_action)
{
if (!(*pingu)->set_action(tmp_action))
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src ActionHolder.cc,1.33,1.34 ActionHolder.hh,1.15,1.16 CaptureRectangle.cc,1.19,1.20 CaptureRectangle.hh,1.16,1.17 Entrance.cc,1.28,1.29 Pingu.cc,1.74,1.75 Pingu.hh,1.41,1.42 PinguAction.cc,1.24,1.25 PinguActionFactory.cc,1.4,1.5 PinguActionFactory.hh,1.3,1.4 PinguHolder.cc,1.19,1.20 PinguInfo.cc,1.11,1.12 PingusMain.cc,1.61,1.62 Server.cc,1.29,1.30,
grumbel <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src/actions Faller.cc,1.13,1.14 Walker.cc,1.14,1.15
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src/actions Boarder.cc,1.5,1.6 Faller.cc,1.14,1.15 Walker.cc,1.15,1.16
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src/actions Faller.cc,1.13,1.14 Walker.cc,1.14,1.15
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src/actions Boarder.cc,1.5,1.6 Faller.cc,1.14,1.15 Walker.cc,1.15,1.16
- Index(es):