pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] CVS: Games/Pingus/src client.cxx,1.26,1.27 client.hxx,1.21,


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src client.cxx,1.26,1.27 client.hxx,1.21,1.22 credits.cxx,1.11,1.12 credits.hxx,1.8,1.9 demo_recorder.cxx,1.6,1.7 demo_recorder.hxx,1.6,1.7 demo_session.cxx,1.1,1.2 demo_session.hxx,1.1,1.2 game_session.cxx,1.15,1.16 game_session.hxx,1.11,1.12 gui_screen.cxx,1.11,1.12 gui_screen.hxx,1.11,1.12 option_menu.cxx,1.8,1.9 option_menu.hxx,1.7,1.8 pingus_counter.cxx,1.7,1.8 pingus_counter.hxx,1.8,1.9 playfield.cxx,1.24,1.25 screen_manager.cxx,1.20,1.21 server.cxx,1.20,1.21 server.hxx,1.10,1.11 server_event.cxx,1.1,1.2 server_event.hxx,1.1,1.2 true_server.cxx,1.14,1.15 true_server.hxx,1.9,1.10 xml_pdf.cxx,1.1,1.2 xml_plf.cxx,1.29,1.30
Date: 3 Oct 2002 12:33:11 -0000

Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv12772

Modified Files:
        client.cxx client.hxx credits.cxx credits.hxx 
        demo_recorder.cxx demo_recorder.hxx demo_session.cxx 
        demo_session.hxx game_session.cxx game_session.hxx 
        gui_screen.cxx gui_screen.hxx option_menu.cxx option_menu.hxx 
        pingus_counter.cxx pingus_counter.hxx playfield.cxx 
        screen_manager.cxx server.cxx server.hxx server_event.cxx 
        server_event.hxx true_server.cxx true_server.hxx xml_pdf.cxx 
        xml_plf.cxx 
Log Message:
- some more tweaks/fixes to the demo recording, should be mostly working know
- added fastforward and scrolling to the demo player (its a dirty hack, but 
should be enough for some testing)
- misc other cleanup

Index: client.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/client.cxx,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- client.cxx  2 Oct 2002 19:20:18 -0000       1.26
+++ client.cxx  3 Oct 2002 12:33:08 -0000       1.27
@@ -69,14 +69,13 @@
   button_panel = new ButtonPanel(server->get_plf (), 2, 
CL_Display::get_height()/2);
   playfield    = new Playfield(this, server->get_plf (), server->get_world());
   hurry_up     = new HurryUp();
-  pcounter     = new PingusCounter();  
+  pcounter     = new PingusCounter(server);  
   small_map    = new SmallMap();
   time_display = new TimeDisplay();
 
   button_panel->set_client(this);
   button_panel->set_server(server);
   hurry_up->set_client(this);
-  pcounter->set_client(this);
   small_map->set_client(this);
   time_display->set_server(server);
 
@@ -106,16 +105,6 @@
 Client::update (const GameDelta& delta)
 {
   GUIScreen::update (delta);
-}
-
-void 
-Client::update (float delta)
-{
-  if (server->is_finished())
-    {
-      std::cout << "Client: update(): Server is finished" << std::endl;
-      ScreenManager::instance ()->pop_screen ();
-    }
 }
 
 #if 0

Index: client.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/client.hxx,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- client.hxx  1 Oct 2002 21:48:32 -0000       1.21
+++ client.hxx  3 Oct 2002 12:33:08 -0000       1.22
@@ -115,8 +115,6 @@
   void on_action_axis_move (float);
 
 private:
-  void update (float delta);
-
   Client (const Client&);
   Client& operator= (const Client&);
 };

Index: credits.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/credits.cxx,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- credits.cxx 14 Sep 2002 19:06:33 -0000      1.11
+++ credits.cxx 3 Oct 2002 12:33:08 -0000       1.12
@@ -112,8 +112,10 @@
 }
 
 void 
-Credits::draw_background ()
+Credits::draw_background (GraphicContext& gc)
 {
+  UNUSED_ARG(gc);
+
   int x;
   int y;
   int yof;

Index: credits.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/credits.hxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- credits.hxx 27 Sep 2002 11:26:43 -0000      1.8
+++ credits.hxx 3 Oct 2002 12:33:08 -0000       1.9
@@ -57,7 +57,7 @@
 
   void init ();
   void update (float);
-  void draw_background ();
+  void draw_background (GraphicContext& gc);
 
   void on_startup ();
 

Index: demo_recorder.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/demo_recorder.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- demo_recorder.cxx   3 Oct 2002 01:02:12 -0000       1.6
+++ demo_recorder.cxx   3 Oct 2002 12:33:08 -0000       1.7
@@ -22,6 +22,9 @@
 #include "console.hxx"
 #include "pingus_error.hxx"
 #include "demo_recorder.hxx"
+#include "server_event.hxx"
+#include "server.hxx"
+#include "plf.hxx"
 
 /* Headers needed for i18n / gettext */
 #include <clocale>
@@ -30,29 +33,45 @@
 
 using namespace std;
 
-DemoRecorder::DemoRecorder()
+DemoRecorder::DemoRecorder(Server* server)
 {
+  std::string levelname = server->get_plf()->get_filename();
+
+  if (!levelname.empty())
+    {
+      std::string filename = System::get_statdir() + "demos/" + levelname + 
"-" + get_date() + ".xml";
+      std::cout << "DemoRecorder: Writing demo to: " << filename << std::endl;
+      out.open(filename.c_str());
+
+      if (!out)
+       {
+         assert(!"DemoRecorder: Couldn't write DemoFile");
+       }
+      
+      // Write file header
+      out << "<pingus-demo>\n"
+         << "  <level>" << levelname << "</level>\n"
+         << "  <events>" << std::endl;
+    }
+  else
+    {
+      assert(!"DemoRecorder Couldn't get levelname");
+    }
 }
 
 DemoRecorder::~DemoRecorder()
 {
+  // Write file footer
+  out << "  </events>\n"
+      << "</pingus-demo>" << std::endl;
+  out.close();
 }
 
 void
-DemoRecorder::set_levelname(const string& levelname)
+DemoRecorder::record_event (const ServerEvent& event)
 {
-  filename = System::get_statdir() + "demos/" + levelname + "-" + get_date() + 
".pdm";
-
-  //std::cout << "Demo filename: " + filename << std::endl;
-  console << "Recording demo to: " << filename << std::endl;
-  
-  std::cout << "DemoRecorder: levelname = " << levelname << std::endl;
-  out.open(filename.c_str());
-
-  out << levelname << std::endl;
-
-  if (!out)
-    PingusError::raise(_("DemoRecorder: Couldn't open: ") + filename);
+  event.write_xml(out);  
+  event.write_xml(std::cout);
 }
 
 string 
@@ -63,7 +82,7 @@
   struct tm *loctime;
   curtime = time (NULL);
   loctime = localtime(&curtime);
-  strftime(buffer, 32, "%Y%m%d-%H%M%S", loctime);
+  strftime(buffer, 32, "%Y-%m-%d_%H:%M:%S", loctime);
 
   return string(buffer);
 }

Index: demo_recorder.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/demo_recorder.hxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- demo_recorder.hxx   3 Oct 2002 01:02:12 -0000       1.6
+++ demo_recorder.hxx   3 Oct 2002 12:33:08 -0000       1.7
@@ -24,19 +24,25 @@
 #include <fstream>
 #include <string>
 
+class Server;
+class ServerEvent;
+
 class DemoRecorder
 {
 private:
+  /** Stream to which the events are written */
   std::ofstream out;
+
+  /** Filename to which the events are written */
   std::string   filename;
 
   std::string get_date();
 public:
-  DemoRecorder();
+  DemoRecorder(Server* server);
   ~DemoRecorder();
-
-  void set_levelname(const std::string&);
   
+  void record_event (const ServerEvent& event);
+
 private:
   DemoRecorder (const DemoRecorder&);
   DemoRecorder& operator= (const DemoRecorder&);

Index: demo_session.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/demo_session.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- demo_session.cxx    3 Oct 2002 01:02:12 -0000       1.1
+++ demo_session.cxx    3 Oct 2002 12:33:08 -0000       1.2
@@ -17,10 +17,16 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+#include <ClanLib/Display/Input/input.h>
+#include <ClanLib/Display/Input/keyboard.h>
 #include "xml_pdf.hxx"
 #include "true_server.hxx"
 #include "world.hxx"
 #include "demo_player.hxx"
+#include "pingus_counter.hxx"
+#include "gui/gui_manager.hxx"
+#include "vector.hxx"
+#include "graphic_context.hxx"
 #include "demo_session.hxx"
 
 DemoSession::DemoSession(const std::string& filename)
@@ -30,8 +36,11 @@
 
   // Create server
   server = new TrueServer(pdf->get_plf());
-
   demo_player = new DemoPlayer(server, pdf);
+
+  // Create GUI
+  pcounter = new PingusCounter(server);
+  gui_manager->add (pcounter, true);
 }
 
 DemoSession::~DemoSession()
@@ -41,19 +50,41 @@
 }
 
 /** Draw this screen */
-bool
-DemoSession::draw (GraphicContext& gc)
+void
+DemoSession::draw_background(GraphicContext& gc)
 {
+  if (CL_Keyboard::get_keycode(CL_KEY_LEFT))
+    gc.move(Vector(10.0, 0.0));
+  
+  if(CL_Keyboard::get_keycode(CL_KEY_RIGHT))
+    gc.move(Vector(-10.0, 0.0));
+
+  if(CL_Keyboard::get_keycode(CL_KEY_UP))
+    gc.move(Vector(0.0, 10.0));
+
+  if(CL_Keyboard::get_keycode(CL_KEY_DOWN))
+    gc.move(Vector(0.0, -10.0));
+
   server->get_world()->draw(gc);
 }
 
 /** Pass a delta to the screen */
 void
-DemoSession::update (const GameDelta& delta)
+DemoSession::update(float delta)
 {
+  UNUSED_ARG(delta);
+
   // FIXME: Duplicate all timing code here?!
   server->update();
   demo_player->update();
+
+  int skip_count = 0;
+  while (CL_Keyboard::get_keycode(CL_KEY_SPACE) && skip_count < 10)
+    {
+      ++skip_count;
+      server->update();
+      demo_player->update();
+    }
 }
 
 /* EOF */

Index: demo_session.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/demo_session.hxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- demo_session.hxx    3 Oct 2002 01:02:12 -0000       1.1
+++ demo_session.hxx    3 Oct 2002 12:33:08 -0000       1.2
@@ -20,30 +20,34 @@
 #ifndef HEADER_PINGUS_DEMO_SESSION_HXX
 #define HEADER_PINGUS_DEMO_SESSION_HXX
 
-#include "screen.hxx"
+#include "gui_screen.hxx"
 
 class Server;
 class XMLPDF;
+class PingusCounter;
 
 /** A DemoSession is analog to a GameSession, but instead of loading a
     level and letting the player play a game, a demo file will be
     loaded and the level will be played automatically. */
-class DemoSession : public Screen
+class DemoSession : public GUIScreen
 {
 private:
   XMLPDF*     pdf;
   Server*     server;
   DemoPlayer* demo_player;
+
+  // GUI stuff
+  PingusCounter* pcounter;
 public:
   /** @param filename the complete filename of the demo file */
   DemoSession(const std::string& filename);
   ~DemoSession();
 
   /** Draw this screen */
-  bool draw (GraphicContext& gc);
+  void draw_background(GraphicContext& gc);
 
   /** Pass a delta to the screen */
-  void update (const GameDelta& delta);
+  void update(float delta);
   
 private:
   DemoSession (const DemoSession&);

Index: game_session.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/game_session.cxx,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- game_session.cxx    2 Oct 2002 19:20:19 -0000       1.15
+++ game_session.cxx    3 Oct 2002 12:33:08 -0000       1.16
@@ -73,7 +73,7 @@
 }
 
 bool
-PingusGameSession::draw (GraphicContext& gc)
+PingusGameSession::draw(GraphicContext& gc)
 {
   ++number_of_redraws;
   client->draw (gc);

Index: game_session.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/game_session.hxx,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- game_session.hxx    3 Oct 2002 01:02:12 -0000       1.11
+++ game_session.hxx    3 Oct 2002 12:33:08 -0000       1.12
@@ -71,7 +71,7 @@
 
   // Overloaded Screen functions 
   /** Draw this screen */
-  bool draw (GraphicContext& gc);
+  bool draw(GraphicContext& gc);
 
   /** Pass a delta to the screen */
   void update (const GameDelta& delta);

Index: gui_screen.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/gui_screen.cxx,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- gui_screen.cxx      2 Oct 2002 12:54:18 -0000       1.11
+++ gui_screen.cxx      3 Oct 2002 12:33:08 -0000       1.12
@@ -41,9 +41,9 @@
 bool
 GUIScreen::draw (GraphicContext& gc)
 {
-  draw_background ();
+  draw_background (gc);
   gui_manager->draw (gc);
-  draw_foreground ();
+  draw_foreground (gc);
   return true;
 }
 

Index: gui_screen.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/gui_screen.hxx,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- gui_screen.hxx      1 Oct 2002 21:48:32 -0000       1.11
+++ gui_screen.hxx      3 Oct 2002 12:33:08 -0000       1.12
@@ -42,8 +42,8 @@
   virtual ~GUIScreen ();
 
   /** Draw this screen */
-  virtual void draw_foreground () {}
-  virtual void draw_background () {}
+  virtual void draw_foreground (GraphicContext& gc) { UNUSED_ARG(gc); }
+  virtual void draw_background (GraphicContext& gc) { UNUSED_ARG(gc); }
   virtual bool draw (GraphicContext& gc);
 
   /** Pass a game delta to the screen */

Index: option_menu.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/option_menu.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- option_menu.cxx     1 Oct 2002 21:48:32 -0000       1.8
+++ option_menu.cxx     3 Oct 2002 12:33:08 -0000       1.9
@@ -317,8 +317,10 @@
 }
 
 void
-OptionMenu::draw_background()
+OptionMenu::draw_background(GraphicContext& gc)
 {
+  UNUSED_ARG(gc);
+
   for(int y=0; y < CL_Display::get_height(); y += background.get_height()) {
     for(int x=0; x < CL_Display::get_width(); x += background.get_width()) {
       background.put_screen(x, y);

Index: option_menu.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/option_menu.hxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- option_menu.hxx     1 Oct 2002 21:48:32 -0000       1.7
+++ option_menu.hxx     3 Oct 2002 12:33:08 -0000       1.8
@@ -96,7 +96,7 @@
 
   void init ();
   void display ();
-  void draw_background ();
+  void draw_background (GraphicContext& gc);
   void preload () { init (); }
   void update (float delta);
   bool draw (GraphicContext& gc);

Index: pingus_counter.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_counter.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- pingus_counter.cxx  6 Sep 2002 17:33:29 -0000       1.7
+++ pingus_counter.cxx  3 Oct 2002 12:33:08 -0000       1.8
@@ -23,7 +23,6 @@
 #include "pingus_resource.hxx"
 #include "pingus_counter.hxx"
 #include "world.hxx"
-#include "client.hxx"
 
 /* Headers needed for i18n / gettext */
 #include <clocale>
@@ -32,8 +31,9 @@
 #include "server.hxx"
 
 
-PingusCounter::PingusCounter()
-  : background (PingusResource::load_surface("Buttons/info","core"))
+PingusCounter::PingusCounter(Server* s)
+  : server(s),
+    background (PingusResource::load_surface("Buttons/info","core"))
 {
   font = PingusResource::load_font("Fonts/pingus_small","fonts");
 }
@@ -45,7 +45,7 @@
 
   background.put_screen (CL_Display::get_width ()/2 - 
background.get_width()/2, 0);
   
-  World* world = client->get_server()->get_world();
+  World* world = server->get_world();
   
   snprintf(str, 128, _("Released: %3d/%3d  Out: %3d  Saved: %3d/%3d"),
           world->get_released_pingus(),
@@ -56,12 +56,6 @@
 
   font->print_center(CL_Display::get_width ()/2,3, str);
   UNUSED_ARG(gc);
-}
-
-void
-PingusCounter::set_client(Client* c)
-{
-  client = c;
 }
 
 /* EOF */

Index: pingus_counter.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_counter.hxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- pingus_counter.hxx  27 Sep 2002 11:26:44 -0000      1.8
+++ pingus_counter.hxx  3 Oct 2002 12:33:08 -0000       1.9
@@ -25,21 +25,19 @@
 
 class CL_Font;
 class World;
-class Client;
+class Server;
 
 class PingusCounter : public GUI::Component
 {
 private:
+  Server* server;
   CL_Font* font;
   CL_Surface background;
-  Client* client;
 public:
-  PingusCounter();
+  PingusCounter(Server* s);
   virtual ~PingusCounter() {}
 
   void draw(GraphicContext& gc);
-  void set_client(Client*);
-  
 private:
   PingusCounter (const PingusCounter&);
   PingusCounter& operator= (const PingusCounter&);

Index: playfield.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/playfield.cxx,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- playfield.cxx       2 Oct 2002 19:20:19 -0000       1.24
+++ playfield.cxx       3 Oct 2002 12:33:08 -0000       1.25
@@ -224,6 +224,9 @@
 void 
 Playfield::on_primary_button_press(int x, int y)
 {
+  UNUSED_ARG(x);
+  UNUSED_ARG(y);
+
   if (current_pingu)
     {
       server->send_pingu_action_event(current_pingu, 
buttons->get_action_name());

Index: screen_manager.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/screen_manager.cxx,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- screen_manager.cxx  2 Oct 2002 12:54:18 -0000       1.20
+++ screen_manager.cxx  3 Oct 2002 12:33:08 -0000       1.21
@@ -194,8 +194,8 @@
 ScreenManager::fade_over (const ScreenPtr& old_screen, const ScreenPtr& 
new_screen)
 {
   FadeOut::fade_to_black();
-  //UNUSED_ARG(old_screen);
-  //UNUSED_ARG(new_screen);
+  UNUSED_ARG(old_screen);
+  UNUSED_ARG(new_screen);
 
 #if 0
   DeltaManager delta_manager;

Index: server.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/server.cxx,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- server.cxx  3 Oct 2002 01:02:12 -0000       1.20
+++ server.cxx  3 Oct 2002 12:33:08 -0000       1.21
@@ -29,6 +29,7 @@
 #include "string_converter.hxx"
 #include "game_time.hxx"
 #include "world.hxx"
+#include "demo_recorder.hxx"
 
 using namespace std;
 using Actions::action_from_string;
@@ -83,44 +84,20 @@
 }
 
 
-Server::Server (PLF* plf)
-  : action_holder (plf)
+Server::Server (PLF* arg_plf)
+  : plf(arg_plf),
+    action_holder (plf)
 {
   demo_mode = false;
   get_next_event = true;
   finished = false;
-  //demo_out.open("/tmp/demo.plt", (PingusDemoMode)record); 
+  demo_recorder = new DemoRecorder(this);
 }
 
 Server::~Server ()
 {
-  // Here we write down the demo file
-  // FIXME: syntax will be different in the final version, this is just a 
quick hack
-  std::string date_str;
-  
-  {
-    char buffer[32];
-    time_t curtime;
-    struct tm *loctime;
-    curtime = time (NULL);
-    loctime = localtime(&curtime);
-    strftime(buffer, 32, "%Y%m%d-%H%M%S", loctime);
-
-    date_str = buffer;
-    
-    date_str = System::get_statdir() + "demos/" + date_str + ".xml";
-  }
-
-  std::cout << "Writing demo to: " << date_str << std::endl;
-
-  std::ofstream xml(date_str.c_str());
-  
-  xml << "<pingus-events>" << std::endl;
-  for(std::vector<ServerEvent>::iterator i = events.begin();
-      i != events.end();
-      ++i)
-    i->write_xml(xml);
-  xml << "</pingus-events>" << std::endl;
+  // Demo Server is exited and writes down its log
+  delete demo_recorder;
 }
 
 World*
@@ -140,7 +117,7 @@
   armageddon = true;
   world->armageddon();
 
-  events.push_back(ServerEvent::make_armageddon_event(get_time()));
+  demo_recorder->record_event(ServerEvent::make_armageddon_event(get_time()));
 }
 
 void
@@ -156,7 +133,7 @@
        }
     }
 
-  events.push_back(ServerEvent::make_pingu_action_event(get_time(), 
pingu->get_id(), action));
+  demo_recorder->record_event(ServerEvent::make_pingu_action_event(get_time(), 
pingu->get_id(), action));
 }
 
 bool

Index: server.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/server.hxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- server.hxx  3 Oct 2002 01:02:12 -0000       1.10
+++ server.hxx  3 Oct 2002 12:33:08 -0000       1.11
@@ -27,6 +27,7 @@
 class Pingu;
 class PLF;
 class World;
+class DemoRecorder;
 
 /** An Event in the Pingus World
 
@@ -54,7 +55,8 @@
 class Server
 {
 protected:
-  std::vector<ServerEvent> events;
+  PLF* plf;
+  DemoRecorder* demo_recorder;
   World* world;
   ActionHolder action_holder;
   bool demo_mode;
@@ -63,7 +65,6 @@
   bool get_next_event;
   bool finished;
   bool armageddon;
-
 public:
   Server(PLF*);
   virtual ~Server();
@@ -78,7 +79,7 @@
 
   virtual bool get_armageddon () { return armageddon; }
 
-  virtual PLF* get_plf () =0;
+  PLF* get_plf () { return plf; }
 
   int get_time();
 

Index: server_event.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/server_event.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- server_event.cxx    3 Oct 2002 01:02:12 -0000       1.1
+++ server_event.cxx    3 Oct 2002 12:33:08 -0000       1.2
@@ -31,6 +31,8 @@
 
 ServerEvent::ServerEvent(xmlDocPtr doc, xmlNodePtr cur)
 {
+  UNUSED_ARG(doc);
+
   if (XMLhelper::equal_str(cur->name, "armageddon"))
     {
       type = ARMAGEDDON_EVENT;
@@ -62,7 +64,7 @@
 }
 
 void
-ServerEvent::write_xml(std::ostream& xml)
+ServerEvent::write_xml(std::ostream& xml) const
 {
   switch(type)
     {

Index: server_event.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/server_event.hxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- server_event.hxx    3 Oct 2002 01:02:12 -0000       1.1
+++ server_event.hxx    3 Oct 2002 12:33:08 -0000       1.2
@@ -55,7 +55,7 @@
   /** Construct an server event from an xml subtree */
   ServerEvent(xmlDocPtr doc, xmlNodePtr cur);
 
-  void write_xml(std::ostream& xml);
+  void write_xml(std::ostream& xml) const;
 
   /** Send this event to the server */
   void send(Server*);

Index: true_server.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/true_server.cxx,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- true_server.cxx     3 Oct 2002 01:02:12 -0000       1.14
+++ true_server.cxx     3 Oct 2002 12:33:08 -0000       1.15
@@ -27,8 +27,7 @@
 using namespace std;
 
 TrueServer::TrueServer(PLF* arg_plf)
-  : Server (arg_plf),
-    plf (arg_plf)
+  : Server (arg_plf)
 {
   armageddon = false;
   world = 0;
@@ -89,12 +88,6 @@
 TrueServer::get_pause()
 {
   return pause;
-}
-
-PLF*
-TrueServer::get_plf ()
-{
-  return plf;
 }
 
 bool

Index: true_server.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/true_server.hxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- true_server.hxx     3 Oct 2002 01:02:12 -0000       1.9
+++ true_server.hxx     3 Oct 2002 12:33:08 -0000       1.10
@@ -22,7 +22,8 @@
 
 #include "server.hxx"
 
-/** FIXME: This whole Server/Client concept is screwed */
+/** FIXME: This whole Server/Client concept is screwed and the
+    TrueServer/Server thing even more... */
 class TrueServer : public Server
 {
 private:
@@ -31,16 +32,11 @@
   unsigned int  last_time;
   float delta;
 
-  /** Reference to the PLF for this level, this must not be deleted */
-  PLF* plf;
-  
 public:
   TrueServer(PLF* plf);
   virtual ~TrueServer();
 
   void update();
-  /** Return a reference to the plf used for this level */
-  PLF* get_plf ();
   void set_fast_forward(bool value);
   bool get_fast_forward();
   

Index: xml_pdf.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/xml_pdf.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- xml_pdf.cxx 3 Oct 2002 01:02:12 -0000       1.1
+++ xml_pdf.cxx 3 Oct 2002 12:33:09 -0000       1.2
@@ -82,7 +82,7 @@
   if (levelname.empty())
     PingusError::raise("XMLPDF: No level given");
 
-  plf = PLF::create(path_manager.complete("levels/" + levelname));
+  plf = PLF::create(path_manager.complete("levels/" + levelname + ".xml"));
 
   std::cout << "XXXXXXXXX Read Demo file: " << std::endl;
   write_xml(std::cout);

Index: xml_plf.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/xml_plf.cxx,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- xml_plf.cxx 1 Oct 2002 23:10:41 -0000       1.29
+++ xml_plf.cxx 3 Oct 2002 12:33:09 -0000       1.30
@@ -33,19 +33,23 @@
 
 using Actions::action_from_string;
 
-XMLPLF::XMLPLF (const std::string& filename)
+XMLPLF::XMLPLF (const std::string& arg_filename)
 {
   //  std::cout << "----- Parsing .xml file" << std::endl;
   //std::cout << "--- Checksum: " << std::flush;
-  std::string str = System::checksum (filename);
+  std::string str = System::checksum (arg_filename);
   //std::cout << str << std::endl;
 
-  doc = xmlParseFile(filename.c_str());
+  doc = xmlParseFile(arg_filename.c_str());
 
   if (doc == NULL)
-    PingusError::raise("XMLPLF: Couldn't open \"" + filename + "\"");
+    PingusError::raise("XMLPLF: Couldn't open \"" + arg_filename + "\"");
 
   parse_file();
+
+  // FIXME: Dirty hack, should be replaced with a unified file namespace
+  filename = System::basename(arg_filename);
+  filename = filename.substr(0, filename.length()-4);
 }
 
 XMLPLF::~XMLPLF()





reply via email to

[Prev in Thread] Current Thread [Next in Thread]