pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r3620 - trunk/pingus/src


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3620 - trunk/pingus/src
Date: Wed, 2 Jul 2008 06:29:52 +0200

Author: grumbel
Date: 2008-07-02 06:29:50 +0200 (Wed, 02 Jul 2008)
New Revision: 3620

Modified:
   trunk/pingus/src/demo_session.cpp
   trunk/pingus/src/server.cpp
   trunk/pingus/src/server_event.cpp
   trunk/pingus/src/server_event.hpp
Log:
Record positions for pingu events to detect desync

Modified: trunk/pingus/src/demo_session.cpp
===================================================================
--- trunk/pingus/src/demo_session.cpp   2008-07-02 04:05:18 UTC (rev 3619)
+++ trunk/pingus/src/demo_session.cpp   2008-07-02 04:29:50 UTC (rev 3620)
@@ -62,7 +62,8 @@
 
   // Create server
   server   = std::auto_ptr<Server>(new Server(PingusLevel(Pathname("levels/" + 
demo->get_levelname()  + ".pingus", 
-                                                                   
Pathname::DATA_PATH)), false));
+                                                                   
Pathname::DATA_PATH)), 
+                                              false));
 
   // Create GUI
   pcounter = new PingusCounter(server.get());

Modified: trunk/pingus/src/server.cpp
===================================================================
--- trunk/pingus/src/server.cpp 2008-07-02 04:05:18 UTC (rev 3619)
+++ trunk/pingus/src/server.cpp 2008-07-02 04:29:50 UTC (rev 3620)
@@ -111,7 +111,7 @@
 void
 Server::send_pingu_action_event (Pingu* pingu, Actions::ActionName action)
 {
-  record(ServerEvent::make_pingu_action_event(get_time(), pingu->get_id(), 
action));
+  record(ServerEvent::make_pingu_action_event(get_time(), pingu->get_id(), 
pingu->get_pos(), action));
 
   if (action_holder.pop_action(action))
     {

Modified: trunk/pingus/src/server_event.cpp
===================================================================
--- trunk/pingus/src/server_event.cpp   2008-07-02 04:05:18 UTC (rev 3619)
+++ trunk/pingus/src/server_event.cpp   2008-07-02 04:29:50 UTC (rev 3620)
@@ -23,6 +23,7 @@
 #include "server.hpp"
 #include "world.hpp"
 #include "pingu_holder.hpp"
+#include "pingu.hpp"
 #include "string_util.hpp"
 
 ServerEvent::ServerEvent() :
@@ -50,6 +51,7 @@
       type = PINGU_ACTION_EVENT;
       reader.read_int ("time",   time_stamp);
       reader.read_int ("id",     pingu_id);
+      reader.read_vector("pos",    pos);
       reader.read_enum("action", pingu_action, Actions::action_from_string);
     }
   else
@@ -76,6 +78,7 @@
       out << "(pingu-action "
           << "(time " << time_stamp << ") "
           << "(id " << pingu_id << ") "
+          << "(pos " << pos.x << " " << pos.y << " " << pos.z << ") "
           << "(action \"" << Actions::action_to_string(pingu_action) << "\"))"
           << std::endl;
       break;
@@ -104,12 +107,13 @@
 }
 
 ServerEvent
-ServerEvent::make_pingu_action_event(int t, int id, Actions::ActionName action)
+ServerEvent::make_pingu_action_event(int t, int id, const Vector3f& pos, 
Actions::ActionName action)
 {
   ServerEvent event;
   event.type         = PINGU_ACTION_EVENT;
   event.time_stamp   = t;
   event.pingu_id     = id;
+  event.pos          = pos;
   event.pingu_action = action;
   return event;
 }
@@ -130,6 +134,7 @@
     case PINGU_ACTION_EVENT:
       {
        Pingu* pingu = server->get_world()->get_pingus()->get_pingu(pingu_id);
+        std::cout << "Apply: " << pos << " == " << pingu->get_pos() << 
std::endl;
        if (pingu)
          {
            server->send_pingu_action_event(pingu,

Modified: trunk/pingus/src/server_event.hpp
===================================================================
--- trunk/pingus/src/server_event.hpp   2008-07-02 04:05:18 UTC (rev 3619)
+++ trunk/pingus/src/server_event.hpp   2008-07-02 04:29:50 UTC (rev 3620)
@@ -23,8 +23,8 @@
 #include <iosfwd>
 #include "file_reader.hpp"
 #include "pingu_enums.hpp"
+#include "math/vector3f.hpp"
 
-
 class Server;
 
 /** This class represents an event that the Server can recieve from
@@ -49,6 +49,8 @@
   /** Id of the pingu which should get the actions */
   int pingu_id;
 
+  Vector3f pos;
+
   /** action name */
   Actions::ActionName pingu_action;
 
@@ -65,7 +67,7 @@
   // Pseudo constructors
   static ServerEvent make_finish_event(int time);
   static ServerEvent make_armageddon_event(int time);
-  static ServerEvent make_pingu_action_event(int t, int id, 
Actions::ActionName action);
+  static ServerEvent make_pingu_action_event(int t, int id, const Vector3f& 
pos, Actions::ActionName action);
 };
 
 





reply via email to

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