[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src goal_manager.cxx,NONE,1.1 goal_manage
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src goal_manager.cxx,NONE,1.1 goal_manager.hxx,NONE,1.1 Makefile.am,1.114,1.115 action_button.cxx,1.15,1.16 action_button.hxx,1.13,1.14 button_panel.cxx,1.15,1.16 button_panel.hxx,1.12,1.13 client.cxx,1.27,1.28 client.hxx,1.22,1.23 game_session.cxx,1.16,1.17 game_session.hxx,1.12,1.13 hurry_up.cxx,1.3,1.4 level_result.cxx,1.5,1.6 multiplayer_client_child.cxx,1.12,1.13 multiplayer_client_child.hxx,1.7,1.8 pingu.cxx,1.32,1.33 pingu.hxx,1.20,1.21 pingu_holder.cxx,1.14,1.15 pingu_holder.hxx,1.12,1.13 pingus_counter.cxx,1.9,1.10 pingus_counter_bar.cxx,1.3,1.4 plf.cxx,1.10,1.11 server.cxx,1.21,1.22 server.hxx,1.11,1.12 smallmap.cxx,1.18,1.19 time_display.cxx,1.7,1.8 true_server.cxx,1.15,1.16 true_server.hxx,1.10,1.11 world.cxx,1.29,1.30 world.hxx,1.16,1.17 |
Date: |
4 Oct 2002 16:54:06 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv3709
Modified Files:
Makefile.am action_button.cxx action_button.hxx
button_panel.cxx button_panel.hxx client.cxx client.hxx
game_session.cxx game_session.hxx hurry_up.cxx
level_result.cxx multiplayer_client_child.cxx
multiplayer_client_child.hxx pingu.cxx pingu.hxx
pingu_holder.cxx pingu_holder.hxx pingus_counter.cxx
pingus_counter_bar.cxx plf.cxx server.cxx server.hxx
smallmap.cxx time_display.cxx true_server.cxx true_server.hxx
world.cxx world.hxx
Added Files:
goal_manager.cxx goal_manager.hxx
Log Message:
cleaned up the whole goal condition section, worlds should exit now again
--- NEW FILE: goal_manager.cxx ---
// $Id: goal_manager.cxx,v 1.1 2002/10/04 16:54:04 grumbel Exp $
//
// Pingus - A free Lemmings clone
// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "server.hxx"
#include "world.hxx"
#include "plf.hxx"
#include "pingu_holder.hxx"
#include "goal_manager.hxx"
GoalManager::GoalManager(Server* s)
: server(s), goal(GT_NONE)
{
}
bool
GoalManager::is_finished()
{
if (goal == GT_NONE)
{
return false;
}
else
{
std::cout << "XXXX goal reached: " << goal << std::endl;
return true;
}
}
void
GoalManager::update()
{
World* world = server->get_world();
PinguHolder* pingus = world->get_pingus();
PLF* plf = server->get_plf();
if (pingus->get_number_of_allowed() == pingus->get_number_of_released()
&& pingus->get_number_of_alive() == 0)
{
goal = GT_NO_PINGUS_IN_WORLD;
}
else if (pingus->get_number_of_alive() == 0 && world->check_armageddon())
{
goal = GT_ARMAGEDDON;
}
else if (plf->get_time() != -1
&& plf->get_time() <= server->get_time())
{
goal = GT_OUT_OF_TIME;
}
}
void
GoalManager::set_abort_goal()
{
goal = GT_GAME_ABORTED;
}
/* EOF */
--- NEW FILE: goal_manager.hxx ---
// $Id: goal_manager.hxx,v 1.1 2002/10/04 16:54:04 grumbel Exp $
//
// Pingus - A free Lemmings clone
// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_PINGUS_GOAL_MANAGER_HXX
#define HEADER_PINGUS_GOAL_MANAGER_HXX
class Server;
/** Class that looks at the server and searches for goal conditions,
such no pingus in the world, time up or Escape pressed. */
class GoalManager
{
private:
Server* server;
enum GoalType { GT_NONE, // No goal is reached
GT_OUT_OF_TIME, // if the timelimit has passed
GT_NO_PINGUS_IN_WORLD, // if all pingus are released and
exited/killed
GT_ARMAGEDDON, // if armageddon as destroyed all pingus
GT_GAME_ABORTED }; // if the user pressed Escape to exit the
level };
GoalType goal;
public:
GoalManager(Server* plf);
/** @return true if a goal is reached and the server can shutdown */
bool is_finished();
/** Abort the level */
void set_abort_goal();
/** Check for goal conditions and set finished accordingly */
void update();
private:
GoalManager (const GoalManager&);
GoalManager& operator= (const GoalManager&);
};
#endif
/* EOF */
Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/Makefile.am,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -d -r1.114 -r1.115
--- Makefile.am 4 Oct 2002 13:46:56 -0000 1.114
+++ Makefile.am 4 Oct 2002 16:54:03 -0000 1.115
@@ -150,6 +150,8 @@
global_event.hxx \
globals.cxx \
globals.hxx \
+goal_manager.hxx \
+goal_manager.cxx \
groundtype.hxx \
groundtype.cxx \
graphic_context.hxx \
Index: action_button.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/action_button.cxx,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- action_button.cxx 4 Oct 2002 11:38:28 -0000 1.15
+++ action_button.cxx 4 Oct 2002 16:54:03 -0000 1.16
@@ -24,7 +24,8 @@
#include "globals.hxx"
#include "pingus_resource.hxx"
#include "action_button.hxx"
-#include "server.hxx"
+#include "true_server.hxx"
+#include "world.hxx"
#include "string_converter.hxx"
using namespace Actions;
@@ -171,7 +172,7 @@
UNUSED_ARG(gc);
}
-ArmageddonButton::ArmageddonButton (Server* s, int x, int y)
+ArmageddonButton::ArmageddonButton (TrueServer* s, int x, int y)
: server (s),
x_pos (x),
y_pos (y),
@@ -189,7 +190,7 @@
void
ArmageddonButton::draw (GraphicContext& gc)
{
- if (server->get_armageddon ())
+ if (server->get_world()->check_armageddon ())
{
backgroundhl.put_screen (x_pos, y_pos);
surface.put_screen(x_pos, y_pos, ++counter);
@@ -249,7 +250,7 @@
if(x); if(y);
}
-ForwardButton::ForwardButton (Server* s, int x, int y)
+ForwardButton::ForwardButton (TrueServer* s, int x, int y)
: server (s),
x_pos (x), y_pos (y),
background (PingusResource::load_surface("buttons/hbuttonbgb", "core")),
@@ -296,7 +297,7 @@
if(x); if(y);
}
-PauseButton::PauseButton (Server* s, int x, int y)
+PauseButton::PauseButton (TrueServer* s, int x, int y)
: server (s),
x_pos(x), y_pos(y),
background (PingusResource::load_surface("buttons/hbuttonbgb", "core")),
Index: action_button.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/action_button.hxx,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- action_button.hxx 28 Sep 2002 11:52:21 -0000 1.13
+++ action_button.hxx 4 Oct 2002 16:54:03 -0000 1.14
@@ -28,7 +28,7 @@
using Actions::ActionName;
-class Server;
+class TrueServer;
class ActionHolder;
class CL_Font;
class Vector;
@@ -40,7 +40,7 @@
class ArmageddonButton : public GUI::Component
{
private:
- Server* server;
+ TrueServer* server;
int x_pos;
int y_pos;
bool pressed;
@@ -52,7 +52,7 @@
AnimCounter counter;
friend class ButtonPanel;
public:
- ArmageddonButton(Server*, int x, int y);
+ ArmageddonButton(TrueServer*, int x, int y);
virtual ~ArmageddonButton();
void draw(GraphicContext& gc);
@@ -74,7 +74,7 @@
class ForwardButton : public GUI::Component
{
private:
- Server* server;
+ TrueServer* server;
int x_pos;
int y_pos;
CL_Surface surface;
@@ -82,7 +82,7 @@
CL_Surface backgroundhl;
friend class ButtonPanel;
public:
- ForwardButton(Server*, int x, int y);
+ ForwardButton(TrueServer*, int x, int y);
virtual ~ForwardButton();
void draw(GraphicContext& gc);
@@ -103,7 +103,7 @@
class PauseButton : public GUI::Component
{
private:
- Server* server;
+ TrueServer* server;
int x_pos;
int y_pos;
CL_Surface surface;
@@ -111,7 +111,7 @@
CL_Surface backgroundhl;
friend class ButtonPanel;
public:
- PauseButton(Server*, int x, int y);
+ PauseButton(TrueServer*, int x, int y);
virtual ~PauseButton();
void draw(GraphicContext& gc);
Index: button_panel.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/button_panel.cxx,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- button_panel.cxx 28 Sep 2002 11:52:21 -0000 1.15
+++ button_panel.cxx 4 Oct 2002 16:54:03 -0000 1.16
@@ -21,7 +21,7 @@
#include <ClanLib/Core/System/system.h>
#include "globals.hxx"
#include "button_panel.hxx"
-#include "server.hxx"
+#include "true_server.hxx"
#include "plf.hxx"
using namespace Actions;
@@ -107,7 +107,7 @@
}
void
-ButtonPanel::set_server(Server* s)
+ButtonPanel::set_server(TrueServer* s)
{
server = s;
Index: button_panel.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/button_panel.hxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- button_panel.hxx 27 Sep 2002 11:26:43 -0000 1.12
+++ button_panel.hxx 4 Oct 2002 16:54:03 -0000 1.13
@@ -37,7 +37,7 @@
typedef std::vector<ActionButton*>::iterator AButtonIter;
AButtonIter pressed_button;
- Server* server;
+ TrueServer* server;
Client* client;
int armageddon_pressed;
@@ -60,7 +60,7 @@
ActionName get_action_name();
void update(float delta);
void draw(GraphicContext& gc);
- void set_server(Server*);
+ void set_server(TrueServer*);
void set_client(Client*);
void set_button(int);
Index: client.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/client.cxx,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- client.cxx 3 Oct 2002 12:33:08 -0000 1.27
+++ client.cxx 4 Oct 2002 16:54:03 -0000 1.28
@@ -34,12 +34,12 @@
#include "hurry_up.hxx"
#include "path_manager.hxx"
#include "cursor.hxx"
-#include "server.hxx"
+#include "true_server.hxx"
#include "button_panel.hxx"
#include "screen_manager.hxx"
#include "gui/gui_manager.hxx"
-Client::Client (Server * s)
+Client::Client (TrueServer * s)
: server (s),
skip_frame (0),
do_replay (false),
Index: client.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/client.hxx,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- client.hxx 3 Oct 2002 12:33:08 -0000 1.22
+++ client.hxx 4 Oct 2002 16:54:03 -0000 1.23
@@ -47,7 +47,7 @@
class PLF;
class PingusCounter;
class Playfield;
-class Server;
+class TrueServer;
class SmallMap;
class TimeDisplay;
@@ -56,7 +56,7 @@
{
private:
Result result;
- Server* server;
+ TrueServer* server;
int skip_frame;
bool do_replay;
@@ -71,18 +71,12 @@
SmallMap* small_map;
HurryUp* hurry_up;
-#if 0
- void process_button_event (Input::ButtonEvent*);
- void process_pointer_event (Input::PointerEvent*);
- void process_axis_event (Input::AxisEvent*);
-#endif
-
bool enabled;
public:
- Client(Server * s);
+ Client(TrueServer* s);
virtual ~Client();
- Server* get_server() { return server; }
+ TrueServer* get_server() { return server; }
Playfield* get_playfield() { return playfield; }
bool replay();
Index: game_session.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/game_session.cxx,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- game_session.cxx 3 Oct 2002 12:33:08 -0000 1.16
+++ game_session.cxx 4 Oct 2002 16:54:04 -0000 1.17
@@ -26,6 +26,7 @@
#include "timer.hxx"
#include "plf.hxx"
#include "globals.hxx"
+#include "screen_manager.hxx"
PingusGameSession::PingusGameSession (std::string arg_filename)
: filename (arg_filename)
@@ -84,6 +85,11 @@
void
PingusGameSession::update (const GameDelta& delta)
{
+ if (server->is_finished())
+ {
+ ScreenManager::instance()->pop_screen();
+ }
+
//std::cout << "Left Over Time: " << left_over_time << std::endl;
int time_passed = (CL_System::get_time() - last_update) + left_over_time;
@@ -109,7 +115,6 @@
{
CL_System::sleep(-left_over_time);
}
-
// Client is independend of the update limit, well, not completly...
client->update (delta);
Index: game_session.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/game_session.hxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- game_session.hxx 3 Oct 2002 12:33:08 -0000 1.12
+++ game_session.hxx 4 Oct 2002 16:54:04 -0000 1.13
@@ -24,7 +24,7 @@
#include "screen.hxx"
class Client;
-class Server;
+class TrueServer;
class PLF;
class PingusGameSessionResult;
class DemoPlayer;
@@ -41,7 +41,7 @@
PLF* plf;
/// The server
- Server* server;
+ TrueServer* server;
/// The client
Client* client;
Index: hurry_up.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/hurry_up.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- hurry_up.cxx 6 Sep 2002 17:33:29 -0000 1.3
+++ hurry_up.cxx 4 Oct 2002 16:54:04 -0000 1.4
@@ -24,16 +24,17 @@
#include "hurry_up.hxx"
#include "client.hxx"
#include "world.hxx"
-#include "server.hxx"
+#include "true_server.hxx"
-HurryUp::HurryUp () : font(PingusResource::load_font("Fonts/pingus","fonts")),
- is_running(false),
- is_finished(false),
- center_reached(false),
- client(0),
- wait_counter(0),
- x_pos(-200.0),
- speed(3.0f)
+HurryUp::HurryUp ()
+ : font(PingusResource::load_font("Fonts/pingus","fonts")),
+ is_running(false),
+ is_finished(false),
+ center_reached(false),
+ client(0),
+ wait_counter(0),
+ x_pos(-200.0),
+ speed(3.0f)
{
}
@@ -93,9 +94,12 @@
}
else if (!is_finished)
{
+ // FIXME: broken
+#if 0
if ( client->get_server()->get_world()->get_time_left() != -1
- && client->get_server()->get_world()->get_time_left() < 10 * 15)
+ && client->get_server()->get_world()->get_time_left() < 10 * 15)
is_running = true;
+#endif
}
}
Index: level_result.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/level_result.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- level_result.cxx 4 Oct 2002 13:46:56 -0000 1.5
+++ level_result.cxx 4 Oct 2002 16:54:04 -0000 1.6
@@ -68,12 +68,13 @@
*/
snprintf(str, 128, _("Pingus saved: %3d/%3d"),
world->get_pingus()->get_number_of_exited(),
- world->get_allowed_pingus());
+ world->get_pingus()->get_number_of_allowed());
font->print_center(CL_Display::get_width() / 2, 140, str);
snprintf(str, 128, _("Pingus killed: %3d/%3d"),
- world->get_allowed_pingus() -
world->get_pingus()->get_number_of_exited(),
- world->get_allowed_pingus());
+ world->get_pingus()->get_number_of_allowed()
+ - world->get_pingus()->get_number_of_exited(),
+ world->get_pingus()->get_number_of_allowed());
font->print_center(CL_Display::get_width() / 2, 160, str);
/*
Index: multiplayer_client_child.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/multiplayer_client_child.cxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- multiplayer_client_child.cxx 28 Sep 2002 11:52:21 -0000 1.12
+++ multiplayer_client_child.cxx 4 Oct 2002 16:54:04 -0000 1.13
@@ -19,10 +19,10 @@
#include <stdio.h>
#include <ClanLib/Display/Input/key.h>
-#include "server.hxx"
+#include "true_server.hxx"
#include "multiplayer_client_child.hxx"
-MultiplayerClientChild::MultiplayerClientChild (Server * s, const CL_Rect&
arg_rect)
+MultiplayerClientChild::MultiplayerClientChild (TrueServer * s, const CL_Rect&
arg_rect)
: server (s),
cursor (new Cursor ("cursors/cross", "core")),
button_panel (new ButtonPanel (s->get_plf (), arg_rect.x1, arg_rect.y1)),
Index: multiplayer_client_child.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/multiplayer_client_child.hxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- multiplayer_client_child.hxx 28 Sep 2002 11:52:22 -0000 1.7
+++ multiplayer_client_child.hxx 4 Oct 2002 16:54:04 -0000 1.8
@@ -27,13 +27,12 @@
#include "pingus_counter_bar.hxx"
#include <string>
-class Server;
+class TrueServer;
class MultiplayerClientChild : public GuiObj
{
private:
-
- Server* server;
+ TrueServer* server;
Cursor* cursor;
ButtonPanel* button_panel;
Sprite capture_rect;
@@ -49,7 +48,7 @@
Vector scroll_vec;
public:
- MultiplayerClientChild (Server * s, const CL_Rect& arg_rect);
+ MultiplayerClientChild (TrueServer * s, const CL_Rect& arg_rect);
~MultiplayerClientChild ();
void draw ();
Index: pingu.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu.cxx,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- pingu.cxx 4 Oct 2002 11:38:28 -0000 1.32
+++ pingu.cxx 4 Oct 2002 16:54:04 -0000 1.33
@@ -59,7 +59,7 @@
delete velocity;
}
-int
+unsigned int
Pingu::get_id ()
{
return id;
Index: pingu.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu.hxx,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- pingu.hxx 2 Oct 2002 19:20:19 -0000 1.20
+++ pingu.hxx 4 Oct 2002 16:54:04 -0000 1.21
@@ -50,7 +50,7 @@
/** The uniq id of the Pingu, this is used to refer to the Pingu in
a demo file or in a network connection */
- int id;
+ unsigned int id;
int action_time;
int owner_id;
@@ -113,7 +113,7 @@
PinguAction* get_action ();
/// Returns the unique id of the pingu
- int get_id (void);
+ unsigned int get_id (void);
/// Set the pingu to the given coordinates
void set_pos (float x, float y);
Index: pingu_holder.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu_holder.cxx,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- pingu_holder.cxx 4 Oct 2002 13:46:56 -0000 1.14
+++ pingu_holder.cxx 4 Oct 2002 16:54:04 -0000 1.15
@@ -20,10 +20,11 @@
#include <iostream>
#include "pingu_holder.hxx"
#include "pingu.hxx"
+#include "plf.hxx"
#include "pingu_action.hxx"
-PinguHolder::PinguHolder()
- : id_count(0),
+PinguHolder::PinguHolder(PLF* plf)
+ : number_of_allowed(plf->get_pingus()),
number_of_exited(0)
{
}
@@ -40,15 +41,24 @@
Pingu*
PinguHolder::create_pingu (const Vector& pos, int owner_id)
{
- Pingu* pingu = new Pingu (id_count++, pos, owner_id);
+ if (number_of_allowed > get_number_of_released())
+ {
+ // We use all_pingus.size() as pingu_id, so that id == array
+ // index
+ Pingu* pingu = new Pingu (all_pingus.size(), pos, owner_id);
- // This list will deleted
- all_pingus.push_back (pingu);
+ // This list will deleted
+ all_pingus.push_back (pingu);
- // This list holds the active pingus
- pingus.push_back(pingu);
+ // This list holds the active pingus
+ pingus.push_back(pingu);
- return pingu;
+ return pingu;
+ }
+ else
+ {
+ return 0;
+ }
}
void
@@ -111,16 +121,23 @@
}
Pingu*
-PinguHolder::get_pingu(int id)
+PinguHolder::get_pingu(unsigned int id)
{
- for(std::list<Pingu*>::iterator pingu = pingus.begin();
- pingu != pingus.end();
- ++pingu)
+ if (id < all_pingus.size())
{
- if ((*pingu)->get_id() == id)
- return *pingu;
+ Pingu* pingu = all_pingus[id];
+
+ assert(pingu->get_id() == id);
+
+ if (pingu->get_status() == PS_ALIVE)
+ return pingu;
+ else
+ return 0;
+ }
+ else
+ {
+ return 0;
}
- return 0;
}
float
@@ -151,6 +168,12 @@
PinguHolder::get_number_of_released()
{
return all_pingus.size();
+}
+
+int
+PinguHolder::get_number_of_allowed()
+{
+ return number_of_allowed;
}
/* EOF */
Index: pingu_holder.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu_holder.hxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- pingu_holder.hxx 4 Oct 2002 13:46:56 -0000 1.12
+++ pingu_holder.hxx 4 Oct 2002 16:54:04 -0000 1.13
@@ -24,6 +24,7 @@
#include <vector>
#include "worldobj.hxx"
+class PLF;
class Vector;
class Pingu;
@@ -33,9 +34,9 @@
class PinguHolder : public WorldObj
{
private:
- /** The uniq id for the next Pingu, starts at 0 and is increased
- with every Pingu. Id's are not recycled if Pingus die. */
- int id_count;
+ /** The total number of pingus that will get released in this
+ level */
+ int number_of_allowed;
/** Number of pingus that made it to the exit, we cache this, since
else we would have to iterate over the whole list and count them
@@ -51,7 +52,7 @@
std::list<Pingu*> pingus;
public:
- PinguHolder();
+ PinguHolder(PLF*);
~PinguHolder();
/address@hidden
@@ -76,21 +77,30 @@
int get_number_of_killed();
/** @return the number of pingus that are still alive, this is shown
- in the PingusCounter panel as 'Out' */
+ in the PingusCounter panel as 'Out'. Exited pingus are *not*
+ counted. FIXME: name should be different (out, active?!) */
int get_number_of_alive();
/** @return the total number of pingus released, this is alive +
killed + exited */
int get_number_of_released();
+
+ /** @return the maximal number of pingus that will get released in
+ this level */
+ int get_number_of_allowed();
- /** Return a reference to a newly create Pingu, the PinguHolder will
- take care of the deletion. The caller *must* not delete the
- Pingu */
+ /** @return a reference to a newly create Pingu, the PinguHolder
+ will take care of the deletion. The caller *must* not delete the
+ Pingu. Might return 0 if all available pingus are already
+ released */
Pingu* create_pingu(const Vector& pos, int owner_id);
- /** Get a pingu by id
- @return the pingu with the id, or 0 if none found */
- Pingu* get_pingu(int id);
+ /** Get a pingu by id, references to dead or exited Pingus are not
+ returned, but 0 instead
+
+ @return the pingu with the id, or 0 if none found or pingu is
+ dead or exited */
+ Pingu* get_pingu(unsigned int id);
// FIXME: Dirty cruft, needs cleanup
std::list<Pingu*>::iterator begin () { return pingus.begin (); }
Index: pingus_counter.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_counter.cxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- pingus_counter.cxx 4 Oct 2002 13:46:56 -0000 1.9
+++ pingus_counter.cxx 4 Oct 2002 16:54:04 -0000 1.10
@@ -26,7 +26,7 @@
#include "world.hxx"
#include "pingu_holder.hxx"
#include "server.hxx"
-
+#include "plf.hxx"
PingusCounter::PingusCounter(Server* s)
: server(s),
@@ -46,10 +46,10 @@
snprintf(str, 128, _("Released: %3d/%3d Out: %3d Saved: %3d/%3d"),
world->get_pingus()->get_number_of_released(),
- world->get_allowed_pingus(),
+ world->get_pingus()->get_number_of_allowed(),
world->get_pingus()->get_number_of_alive(),
world->get_pingus()->get_number_of_exited(),
- world->get_number_to_save());
+ server->get_plf()->get_number_to_save());
font->print_center(CL_Display::get_width ()/2,3, str);
UNUSED_ARG(gc);
Index: pingus_counter_bar.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_counter_bar.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- pingus_counter_bar.cxx 4 Oct 2002 13:46:56 -0000 1.3
+++ pingus_counter_bar.cxx 4 Oct 2002 16:54:04 -0000 1.4
@@ -45,7 +45,7 @@
{
int length = rect.y2 - rect.y1;
- int complete = server->get_world ()->get_allowed_pingus ();
+ int complete = server->get_world
()->get_pingus()->get_number_of_allowed();
int current_out = server->get_world
()->get_pingus()->get_number_of_released();
int current_saved = server->get_world
()->get_pingus()->get_number_of_exited();
Index: plf.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/plf.cxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- plf.cxx 28 Sep 2002 11:52:22 -0000 1.10
+++ plf.cxx 4 Oct 2002 16:54:04 -0000 1.11
@@ -28,7 +28,7 @@
start_x_pos = start_y_pos = 0;
width = 1600; height = 800;
number_of_pingus = 100;
- max_time = 9000;
+ max_time = -1;
number_to_save = 0;
number_of_pingus = 100;
difficulty = 5;
Index: server.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/server.cxx,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- server.cxx 3 Oct 2002 12:33:08 -0000 1.21
+++ server.cxx 4 Oct 2002 16:54:04 -0000 1.22
@@ -30,74 +30,26 @@
#include "game_time.hxx"
#include "world.hxx"
#include "demo_recorder.hxx"
+#include "goal_manager.hxx"
using namespace std;
using Actions::action_from_string;
-/** PinguID search functor */
-struct PinguId : public unary_function<Pingu*, bool>
-{
- int pingu_id;
-
- PinguId(){}
- PinguId(int i) {
- pingu_id = i;
- }
-
- bool operator()(Pingu* pingu) {
- return (pingu->get_id() == pingu_id);
- }
-};
-
-PingusEvent::PingusEvent ()
-{
-}
-
-PingusEvent::PingusEvent (const std::string& event_str)
-{
- std::string game_time_str;
- std::string::size_type split_pos = event_str.find(":");
-
- game_time_str = event_str.substr(0, split_pos);
- str = event_str.substr(split_pos + 1);
-
- if (sscanf(game_time_str.c_str(), "%d", &game_time) != 1) {
- PingusError::raise("PingusEvent: Unable to parse: " + event_str);
- }
-}
-
-PingusEvent::PingusEvent (const PingusEvent& old) : game_time(old.game_time),
- str(old.str)
-{
-}
-
-PingusEvent&
-PingusEvent::operator= (const PingusEvent& old)
-{
- if (this == &old)
- return *this;
-
- game_time = old.game_time;
- str = old.str;
-
- return *this;
-}
-
-
Server::Server (PLF* arg_plf)
: plf(arg_plf),
- action_holder (plf)
+ world(new World (plf)),
+ action_holder (plf),
+ goal_manager(new GoalManager(this)),
+ demo_recorder(new DemoRecorder(this))
{
- demo_mode = false;
- get_next_event = true;
- finished = false;
- demo_recorder = new DemoRecorder(this);
}
Server::~Server ()
{
// Demo Server is exited and writes down its log
+ delete goal_manager;
delete demo_recorder;
+ delete world;
}
World*
@@ -109,15 +61,17 @@
void
Server::update()
{
+ world->update();
+ goal_manager->update();
}
void
Server::send_armageddon_event()
{
- armageddon = true;
world->armageddon();
- demo_recorder->record_event(ServerEvent::make_armageddon_event(get_time()));
+ if (demo_recorder)
+
demo_recorder->record_event(ServerEvent::make_armageddon_event(get_time()));
}
void
@@ -133,23 +87,22 @@
}
}
- demo_recorder->record_event(ServerEvent::make_pingu_action_event(get_time(),
pingu->get_id(), action));
+ if (demo_recorder)
+
demo_recorder->record_event(ServerEvent::make_pingu_action_event(get_time(),
+
pingu->get_id(),
+ action));
}
bool
Server::is_finished()
{
- if (finished) {
- return true;
- } else {
- return world->is_finished();
- }
+ goal_manager->is_finished();
}
void
Server::set_finished()
{
- finished = true;
+ goal_manager->set_abort_goal();
}
ActionHolder*
Index: server.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/server.hxx,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- server.hxx 3 Oct 2002 12:33:08 -0000 1.11
+++ server.hxx 4 Oct 2002 16:54:04 -0000 1.12
@@ -28,56 +28,27 @@
class PLF;
class World;
class DemoRecorder;
-
-/** An Event in the Pingus World
-
- Possible events are the applying of an action, an armageddon,
- scrolling, etc.
-
- FIXME: The concept is ok, but implementation sucks
-*/
-class PingusEvent {
-public:
- /// The GameTime at which the event happend
- int game_time;
- /// A string describing the event
- std::string str;
-
-public:
- PingusEvent ();
- PingusEvent (const std::string& event_str);
-
- PingusEvent (const PingusEvent& old);
- PingusEvent& operator= (const PingusEvent&);
-};
+class GoalManager;
/** A abstract server-like class */
class Server
{
-protected:
+private:
PLF* plf;
- DemoRecorder* demo_recorder;
World* world;
+
+ /** Manager class for the number of available actions */
ActionHolder action_holder;
- bool demo_mode;
- std::string demo_file;
- bool get_next_event;
- bool finished;
- bool armageddon;
+ GoalManager* goal_manager;
+
+ DemoRecorder* demo_recorder;
+
public:
Server(PLF*);
virtual ~Server();
virtual void update();
-
- virtual void set_fast_forward(bool) = 0;
- virtual bool get_fast_forward() = 0;
-
- virtual bool get_pause() = 0;
- virtual void set_pause(bool) = 0;
-
- virtual bool get_armageddon () { return armageddon; }
PLF* get_plf () { return plf; }
@@ -85,7 +56,13 @@
World* get_world();
ActionHolder* get_action_holder();
+
+ /** @return true if the server is finished and the game can be
+ exited */
bool is_finished();
+
+ /** set the server into the finshed state, this is used when you
+ press ESCAPE inside a game */
void set_finished();
/* Event handling stuff */
Index: smallmap.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/smallmap.cxx,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- smallmap.cxx 4 Oct 2002 13:46:56 -0000 1.18
+++ smallmap.cxx 4 Oct 2002 16:54:04 -0000 1.19
@@ -26,7 +26,7 @@
#include "pingus_resource.hxx"
#include "smallmap.hxx"
#include "col_map.hxx"
-#include "server.hxx"
+#include "true_server.hxx"
#include "pingu.hxx"
#include "math.hxx"
Index: time_display.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/time_display.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- time_display.cxx 6 Sep 2002 17:33:29 -0000 1.7
+++ time_display.cxx 4 Oct 2002 16:54:04 -0000 1.8
@@ -26,6 +26,7 @@
#include "time_display.hxx"
#include "world.hxx"
#include "server.hxx"
+#include "plf.hxx"
TimeDisplay::TimeDisplay ()
{
@@ -36,7 +37,7 @@
void
TimeDisplay::draw (GraphicContext& gc)
{
- int time_value = server->get_world()->get_time_left();
+ int time_value = server->get_plf()->get_time() -
server->get_world()->get_time_passed();
char time_string[8];
if (time_value == -1 && !(pingus_debug_flags & PINGUS_DEBUG_GAMETIME))
Index: true_server.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/true_server.cxx,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- true_server.cxx 3 Oct 2002 12:33:08 -0000 1.15
+++ true_server.cxx 4 Oct 2002 16:54:04 -0000 1.16
@@ -29,22 +29,12 @@
TrueServer::TrueServer(PLF* arg_plf)
: Server (arg_plf)
{
- armageddon = false;
- world = 0;
- finished = false;
fast_forward = false;
pause = false;
- last_time = 0;
-
- world = new World (plf);
}
TrueServer::~TrueServer()
{
- if (world) {
- std::cout << "TrueServer: Deleting World" << std::endl;
- delete world;
- }
}
void
@@ -56,13 +46,13 @@
// times
for (int i = 0; i < 4; ++i)
{
- world->update();
+ Server::update();
}
}
else
{
if (!pause)
- world->update();
+ Server::update();
}
}
@@ -88,12 +78,6 @@
TrueServer::get_pause()
{
return pause;
-}
-
-bool
-TrueServer::get_armageddon ()
-{
- return armageddon;
}
/* EOF */
Index: true_server.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/true_server.hxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- true_server.hxx 3 Oct 2002 12:33:08 -0000 1.10
+++ true_server.hxx 4 Oct 2002 16:54:04 -0000 1.11
@@ -29,21 +29,18 @@
private:
bool fast_forward;
bool pause;
- unsigned int last_time;
- float delta;
public:
TrueServer(PLF* plf);
virtual ~TrueServer();
void update();
+
void set_fast_forward(bool value);
bool get_fast_forward();
void set_pause(bool);
bool get_pause();
-
- bool get_armageddon ();
private:
TrueServer (const TrueServer&);
Index: world.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/world.cxx,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- world.cxx 4 Oct 2002 13:46:56 -0000 1.29
+++ world.cxx 4 Oct 2002 16:54:04 -0000 1.30
@@ -54,21 +54,13 @@
World::World(PLF* plf)
: game_time (new GameTime (game_speed)),
particle_holder (new ParticleHolder()),
- pingus (new PinguHolder()),
+ pingus (new PinguHolder(plf)),
view (0)
{
// Not perfect, but works
WorldObj::set_world(this);
- exit_world = false;
do_armageddon = false;
- allowed_pingus = plf->get_pingus();
- number_to_save = plf->get_number_to_save();
-
- exit_time = plf->get_time();
- if (exit_time != -1 && !(exit_time > 100))
- std::cout << "World: Time is not in the tolerated range: " << exit_time <<
std::endl;
- shutdown_time = -1;
// Create the groundmap
gfx_map = new PingusSpotMap(plf);
@@ -158,19 +150,6 @@
{
game_time->update ();
- // if a exit condition is schedule a shutdown of the world in the
- // next 75 ticks
- if (!exit_world && (static_cast<int>(allowed_pingus) ==
pingus->get_number_of_released()
- || do_armageddon)
- && pingus->size() == 0)
- {
- if (verbose)
- std::cout << "World: world finished, going down in the next seconds..."
<< std::endl;
-
- exit_world = true;
- shutdown_time = game_time->get_ticks() + 75;
- }
-
if (do_armageddon && armageddon_count != pingus->end())
{
// The iterator here might be invalid
@@ -217,19 +196,6 @@
}
int
-World::get_time_left()
-{
- if (exit_time != -1) // There is a time limit
- {
- return exit_time - game_time->get_ticks();
- }
- else // No timelimit given
- {
- return -1;
- }
-}
-
-int
World::get_time_passed()
{
return game_time->get_ticks();
@@ -242,24 +208,6 @@
do_armageddon = true;
// FIXME: Ugly to use iterator, since it can get invalid
armageddon_count = pingus->begin();
-}
-
-bool
-World::is_finished(void)
-{
- // Return true if the world is finished and some time has passed
- if (((exit_time != -1) && (exit_time < (game_time->get_ticks())))
- || ((shutdown_time != -1) && shutdown_time < game_time->get_ticks()))
- {
- std::cout << "ExitTime: " << exit_time << std::endl
- << "GameTime: " << game_time->get_ticks() << std::endl
- << "ShutDown: " << shutdown_time << std::endl;
- return true;
- }
- else
- {
- return false;
- }
}
ColMap*
Index: world.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/world.hxx,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- world.hxx 4 Oct 2002 13:46:56 -0000 1.16
+++ world.hxx 4 Oct 2002 16:54:04 -0000 1.17
@@ -67,23 +67,6 @@
of them, should use pingus_id instead */
std::list<Pingu*>::iterator armageddon_count;
- /** number of total pingus available in this level */
- unsigned int allowed_pingus;
-
- /** number of pingus to save */
- unsigned int number_to_save;
-
- /** */
- bool exit_world;
-
- /** End the world when the given time is reached, this is set by
- armageddon or similar events. */
- int shutdown_time;
-
- /** The time in which you have to finish a level, aka the time limit
- of a level */
- int exit_time;
-
std::vector<WorldObj*> world_obj;
typedef std::vector<WorldObj*>::iterator WorldObjIter;
@@ -119,18 +102,11 @@
/** @return true if the world is finished, meaning the time limit
has passed or the world is out of pingus (which is simulated by
the time => FIXME: hack) */
- bool is_finished ();
+ bool finished ();
/** Returns the time passed since the level was started */
int get_time_passed();
- /** Returns the time left until the time is out or -1 if there is no
- time limit */
- int get_time_left();
-
- /** True if there is a time limit in this world */
- bool has_time_limit();
-
/** @return A pointer to the collision map used in this world */
ColMap* get_colmap();
@@ -142,13 +118,6 @@
/** @return true if the world is currently doing an armageddon */
bool check_armageddon() { return do_armageddon; }
-
- /** @return the number of totally allowed pingus */
- unsigned int get_allowed_pingus() { return allowed_pingus; }
-
- /** @return number of pingus which need to get saved in this level
- to finish it successfull */
- unsigned int get_number_to_save() { return number_to_save; }
/** Play a sound as if it would have been generated at the given
position, adjust panning and volume by the position relative to
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src goal_manager.cxx,NONE,1.1 goal_manager.hxx,NONE,1.1 Makefile.am,1.114,1.115 action_button.cxx,1.15,1.16 action_button.hxx,1.13,1.14 button_panel.cxx,1.15,1.16 button_panel.hxx,1.12,1.13 client.cxx,1.27,1.28 client.hxx,1.22,1.23 game_session.cxx,1.16,1.17 game_session.hxx,1.12,1.13 hurry_up.cxx,1.3,1.4 level_result.cxx,1.5,1.6 multiplayer_client_child.cxx,1.12,1.13 multiplayer_client_child.hxx,1.7,1.8 pingu.cxx,1.32,1.33 pingu.hxx,1.20,1.21 pingu_holder.cxx,1.14,1.15 pingu_holder.hxx,1.12,1.13 pingus_counter.cxx,1.9,1.10 pingus_counter_bar.cxx,1.3,1.4 plf.cxx,1.10,1.11 server.cxx,1.21,1.22 server.hxx,1.11,1.12 smallmap.cxx,1.18,1.19 time_display.cxx,1.7,1.8 true_server.cxx,1.15,1.16 true_server.hxx,1.10,1.11 world.cxx,1.29,1.30 world.hxx,1.16,1.17,
grumbel <=