[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src capture_rectangle.cxx,1.8,1.9 client.
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src capture_rectangle.cxx,1.8,1.9 client.cxx,1.25,1.26 game_session.cxx,1.14,1.15 pingu.cxx,1.29,1.30 pingu.hxx,1.19,1.20 pingu_holder.cxx,1.11,1.12 pingu_holder.hxx,1.9,1.10 playfield.cxx,1.23,1.24 server.cxx,1.18,1.19 server.hxx,1.8,1.9 |
Date: |
2 Oct 2002 19:20:21 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv14838
Modified Files:
capture_rectangle.cxx client.cxx game_session.cxx pingu.cxx
pingu.hxx pingu_holder.cxx pingu_holder.hxx playfield.cxx
server.cxx server.hxx
Log Message:
some cleanup
Index: capture_rectangle.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/capture_rectangle.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- capture_rectangle.cxx 28 Sep 2002 11:52:21 -0000 1.8
+++ capture_rectangle.cxx 2 Oct 2002 19:20:18 -0000 1.9
@@ -24,6 +24,8 @@
#include "capture_rectangle.hxx"
#include "pingu_action.hxx"
#include "button_panel.hxx"
+#include "globals.hxx"
+#include "string_converter.hxx"
CaptureRectangle::CaptureRectangle(ButtonPanel* arg_button_panel)
: pingu (0),
@@ -59,7 +61,8 @@
sur = &bad;
if (s == 1.0)
- {
+ { // FIXME: this should use GC and should probally be cached
+ // FIXME: as long as the pingu is the same
std::string action_str = pingu->get_action()->get_name();
PinguAction * wall_action = pingu->get_wall_action();
@@ -77,6 +80,11 @@
action_str += "]";
}
+
+ if (maintainer_mode)
+ {
+ action_str += " Id: " + to_string(pingu->get_id());
+ }
// Draw the caputure rectangle
sur->put_screen(pingu->get_center_pos() + Vector(x_offset,y_offset));
Index: client.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/client.cxx,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- client.cxx 1 Oct 2002 21:48:32 -0000 1.25
+++ client.cxx 2 Oct 2002 19:20:18 -0000 1.26
@@ -329,7 +329,7 @@
break;
case CL_KEY_A:
- server->send_event("armageddon");
+ server->send_armageddon_event();
break;
case CL_KEY_R:
@@ -395,7 +395,7 @@
void
Client::on_armageddon_press ()
{
- server->send_event("armageddon");
+ server->send_armageddon_event();
}
void
Index: game_session.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/game_session.cxx,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- game_session.cxx 2 Oct 2002 12:54:18 -0000 1.14
+++ game_session.cxx 2 Oct 2002 19:20:19 -0000 1.15
@@ -88,32 +88,28 @@
int time_passed = (CL_System::get_time() - last_update) + left_over_time;
int update_time = game_speed;
+ int min_frame_skip = 0;
left_over_time = 0;
- if (time_passed > update_time)
+ int i;
+ for (i = 0; i * update_time < time_passed || i < min_frame_skip; i += 1)
{
- int i;
- for (i = 0; i < time_passed; i += update_time)
- {
- // This updates the world and all objects
- server->update ();
- ++number_of_updates;
- }
+ // This updates the world and all objects
+ server->update ();
+ ++number_of_updates;
+ }
- left_over_time = time_passed % update_time;
+ // Time that got not used for updates
+ left_over_time = time_passed - (i * update_time);
- // This updates something else... what?! Well, userinterface and
- // things like that...
- last_update = CL_System::get_time();
- }
- else
+ last_update = CL_System::get_time();
+
+ if (!max_cpu_usage && left_over_time < 0)
{
- if (!max_cpu_usage)
- {
- CL_System::sleep(update_time - time_passed);
- }
+ CL_System::sleep(-left_over_time);
}
+
// Client is independend of the update limit, well, not completly...
client->update (delta);
Index: pingu.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu.cxx,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- pingu.cxx 1 Oct 2002 19:53:44 -0000 1.29
+++ pingu.cxx 2 Oct 2002 19:20:19 -0000 1.30
@@ -33,16 +33,16 @@
using namespace Actions;
+// FIXME: We should read all this 'constants' from a configuration file at
startup
const float deadly_velocity = 20.0;
-int Pingu::id_counter = 0;
// Init a pingu at the given position while falling
-Pingu::Pingu (const Vector& arg_pos, int owner)
+Pingu::Pingu (int arg_id, const Vector& arg_pos, int owner)
: action(0),
countdown_action (0),
wall_action(0),
fall_action(0),
- id(++id_counter),
+ id(arg_id),
action_time(-1),
owner_id(owner),
status(PS_ALIVE),
@@ -412,12 +412,6 @@
Pingu::get_center_pos () const
{
return Vector(pos_x, pos_y) + Vector (0, -16);
-}
-
-int
-Pingu::set_id (int i)
-{
- return (id = i);
}
int
Index: pingu.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu.hxx,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- pingu.hxx 1 Oct 2002 19:53:44 -0000 1.19
+++ pingu.hxx 2 Oct 2002 19:20:19 -0000 1.20
@@ -35,10 +35,6 @@
class Pingu
{
private:
- /** Static id_counter, which holds the id last pingu, which
- got created. */
- static int id_counter;
-
/** The primary action with is currently in use */
PinguAction* action;
@@ -77,9 +73,10 @@
void set_action (PinguAction*);
/** Creates a new Pingu at the given coordinates
+ @param arg_id The uniq id of the pingu
@param pos The start position of the pingu
@param owner The owner id of the pingu (used for multiplayer) */
- Pingu (const Vector& pos, int owner);
+ Pingu (int arg_id, const Vector& pos, int owner);
/** Destruct the pingu... */
~Pingu ();
@@ -117,10 +114,7 @@
/// Returns the unique id of the pingu
int get_id (void);
-
- /// Set's the unique id of the pingu
- int set_id (int);
-
+
/// 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.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- pingu_holder.cxx 1 Oct 2002 19:53:44 -0000 1.11
+++ pingu_holder.cxx 2 Oct 2002 19:20:19 -0000 1.12
@@ -44,20 +44,27 @@
return total_size_count;
}
+/*
void
PinguHolder::add (Pingu* pingu)
{
total_size_count++;
pingu->set_id(id_count++);
pingus.push_back(pingu);
-}
+ }*/
Pingu*
PinguHolder::create_pingu (const Vector& pos, int owner_id)
{
- Pingu* pingu = new Pingu (pos, owner_id);
- // This list will get evaluated and deleted and destruction
+ Pingu* pingu = new Pingu (id_count++, pos, owner_id);
+
+ ++total_size_count;
+
+ // This list will deleted
all_pingus.push_back (pingu);
+
+ // This list holds the active pingus
+ pingus.push_back(pingu);
return pingu;
}
Index: pingu_holder.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu_holder.hxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- pingu_holder.hxx 1 Oct 2002 19:53:44 -0000 1.9
+++ pingu_holder.hxx 2 Oct 2002 19:20:19 -0000 1.10
@@ -57,15 +57,11 @@
int total_size();
int get_saved() { return saved_pingus; }
-
- /** Adds a pingu to the list of active pingus (the ones that are
- displayed and walk around) */
- void add (Pingu* pingu);
/** Return a reference to a newly create Pingu, the PinguHolder will
take care of the deletion. The caller *must* not delete the
Pingu */
- Pingu* create_pingu (const Vector& pos, int owner_id);
+ Pingu* create_pingu(const Vector& pos, int owner_id);
float get_z_pos() const;
Index: playfield.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/playfield.cxx,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- playfield.cxx 28 Sep 2002 11:52:22 -0000 1.23
+++ playfield.cxx 2 Oct 2002 19:20:19 -0000 1.24
@@ -224,13 +224,9 @@
void
Playfield::on_primary_button_press(int x, int y)
{
- std::cout << "Playfield::on_primary_button_press(" << x << ", " << y <<
std::endl;
if (current_pingu)
{
- char str[128];
- snprintf(str, 128, "Pingu: %d:%s", current_pingu->get_id(),
-
Actions::action_to_string(buttons->get_action_name()).c_str());
- server->send_event(str);
+ server->send_pingu_action_event(current_pingu,
buttons->get_action_name());
}
}
Index: server.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/server.cxx,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- server.cxx 1 Oct 2002 19:53:44 -0000 1.18
+++ server.cxx 2 Oct 2002 19:20:19 -0000 1.19
@@ -32,6 +32,21 @@
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 ()
{
}
@@ -120,87 +135,24 @@
*/
}
-// Some simple event management
void
-Server::send_event(std::string event)
+Server::send_armageddon_event()
{
- process_event(event);
+ world->armageddon();
}
-/** 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);
- }
-};
-
void
-Server::process_event(std::string event)
+Server::send_pingu_action_event(Pingu* pingu, Actions::ActionName action)
{
- char* event_str = strdup(event.c_str());
- std::string token;
- const char delimiters[] = ":";
-
- //std::cout << "Event: " << GameTime::get_time() << ":" << event <<
std::endl;
-
- token = strtok(event_str, delimiters); // Get GameTime
-
- if (token == "armageddon")
- {
- world->armageddon();
- std::cout << std::endl;
- }
- else if (token == "Pingu")
- {
- int pingu_id;
- PinguHolder* pingus;
-
- std::string action;
-
- token = strtok(NULL, delimiters); // Get Pingu id
- pingu_id = atoi(token.c_str());
-
-
- token = strtok(NULL, delimiters); // Get action name
- action = token;
-
- pingus = world->get_pingu_p();
-
- // FIXME: This could need some optimization
- PinguIter pingu = find_if(pingus->begin(), pingus->end(),
PinguId(pingu_id));
-
- if (pingu != pingus->end())
- {
- PinguAction* tmp_action =
action_holder.get_action(action_from_string(action));
+ PinguAction* tmp_action = action_holder.get_action(action);
- if (tmp_action)
- {
- if (!(*pingu)->request_set_action(tmp_action))
- {
- action_holder.push_action(action_from_string(action));
- }
- }
- }
- else
+ if (tmp_action)
+ {
+ if (!(pingu->request_set_action(tmp_action)))
{
- std::cout << "Server: PinguID: " << pingu_id << " not found, demo
file corrupt?!" << std::endl;
+ action_holder.push_action(action);
}
}
- else
- {
- std::cout << "Server: Couldn't ident token: \"" << token << "\"" <<
std::endl;
- std::cout << "Server: Unknown Event: " << event << std::endl;
- }
-
- free(event_str); // from a strdup
}
bool
Index: server.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/server.hxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- server.hxx 1 Oct 2002 19:53:44 -0000 1.8
+++ server.hxx 2 Oct 2002 19:20:19 -0000 1.9
@@ -22,6 +22,7 @@
#include "action_holder.hxx"
+class Pingu;
class PLF;
class World;
@@ -80,8 +81,10 @@
ActionHolder* get_action_holder();
bool is_finished();
void set_finished();
- void process_event(std::string);
- void send_event(std::string);
+
+ /* Event handling stuff */
+ void send_armageddon_event();
+ void send_pingu_action_event(Pingu* pingu, Actions::ActionName action);
private:
Server (const Server&);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src capture_rectangle.cxx,1.8,1.9 client.cxx,1.25,1.26 game_session.cxx,1.14,1.15 pingu.cxx,1.29,1.30 pingu.hxx,1.19,1.20 pingu_holder.cxx,1.11,1.12 pingu_holder.hxx,1.9,1.10 playfield.cxx,1.23,1.24 server.cxx,1.18,1.19 server.hxx,1.8,1.9,
grumbel <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src/worldobjs entrance.cxx,1.3,1.4 entrance.hxx,1.2,1.3 hotspot.cxx,1.4,1.5 hotspot.hxx,1.4,1.5
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src/actions faller.cxx,1.26,1.27 walker.cxx,1.25,1.26
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src/worldobjs entrance.cxx,1.3,1.4 entrance.hxx,1.2,1.3 hotspot.cxx,1.4,1.5 hotspot.hxx,1.4,1.5
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src/actions faller.cxx,1.26,1.27 walker.cxx,1.25,1.26
- Index(es):