[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src Makefile.static,1.12,1.13 game_sessio
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src Makefile.static,1.12,1.13 game_session.cxx,1.29,1.30 game_session.hxx,1.16,1.17 pingus_main.cxx,1.48,1.49 pingus_resource.cxx,1.22,1.23 pingus_resource.hxx,1.11,1.12 theme.cxx,1.12,1.13 world.cxx,1.39,1.40 world.hxx,1.25,1.26 |
Date: |
3 Mar 2003 20:32:20 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv31575
Modified Files:
Makefile.static game_session.cxx game_session.hxx
pingus_main.cxx pingus_resource.cxx pingus_resource.hxx
theme.cxx world.cxx world.hxx
Log Message:
seperated PLF loading a bit, not 100% sure if this is a good idea or not.
Index: Makefile.static
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/Makefile.static,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- Makefile.static 19 Feb 2003 23:03:51 -0000 1.12
+++ Makefile.static 3 Mar 2003 20:32:18 -0000 1.13
@@ -2,7 +2,6 @@
colliders/libpingus_colliders.a \
editor/libpingus_editor.a \
editorobjs/libpingus_editorobjs.a \
-entrances/libpingus_entrances.a \
generic/libpingus_generic.a \
gui/libpingus_gui.a \
input/libpingus_input.a \
@@ -61,7 +60,8 @@
-lSM \
-lICE \
-lXxf86vm \
--lstdc++
+-lstdc++ \
+-ldl
all : pingus.static pingus.static.comp
Index: game_session.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/game_session.cxx,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- game_session.cxx 28 Feb 2003 22:14:05 -0000 1.29
+++ game_session.cxx 3 Mar 2003 20:32:18 -0000 1.30
@@ -24,18 +24,19 @@
#include "game_session.hxx"
#include "game_session_result.hxx"
#include "timer.hxx"
+#include "pingus_resource.hxx"
#include "plf.hxx"
#include "globals.hxx"
-PingusGameSession::PingusGameSession (std::string arg_filename)
- : filename (arg_filename)
+PingusGameSession::PingusGameSession (PLFHandle arg_plf)
+ : plf(arg_plf)
{
Timer plf_timer("GameSession plf creation");
- plf = PLF::create(filename);
+
plf_timer.stop();
Timer server_timer("GameSession server creation");
- server = new TrueServer(plf);
+ server = new TrueServer(*plf);
server_timer.stop();
Timer client_timer("GameSession client creation");
@@ -58,7 +59,6 @@
delete client;
delete server;
- delete plf;
}
void
Index: game_session.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/game_session.hxx,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- game_session.hxx 19 Feb 2003 11:33:00 -0000 1.16
+++ game_session.hxx 3 Mar 2003 20:32:18 -0000 1.17
@@ -22,10 +22,10 @@
#include <string>
#include "gui/screen.hxx"
+#include "plf_handle.hxx"
class Client;
class TrueServer;
-class PLF;
class PingusGameSessionResult;
class DemoPlayer;
@@ -34,11 +34,8 @@
class PingusGameSession : public Screen
{
private:
- /// The filename of the level
- std::string filename;
-
/// The level data
- PLF* plf;
+ PLFHandle plf;
/// The server
TrueServer* server;
@@ -57,10 +54,7 @@
unsigned int number_of_redraws;
public:
- /** Create a new game session which is launched on start ()
- @param arg_filename The filename of a Pingus Level file
- FIXME: Absolute or relative filename? */
- PingusGameSession (std::string arg_filename);
+ PingusGameSession (PLFHandle arg_plf);
/** Clean up */
~PingusGameSession ();
Index: pingus_main.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_main.cxx,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- pingus_main.cxx 19 Feb 2003 12:34:16 -0000 1.48
+++ pingus_main.cxx 3 Mar 2003 20:32:18 -0000 1.49
@@ -725,7 +725,7 @@
}
else
{
- ScreenManager::instance()->push_screen(new PingusGameSession
(levelfile), true);
+ ScreenManager::instance()->push_screen(new PingusGameSession
(PingusResource::load_plf_raw(levelfile)), true);
}
}
}
Index: pingus_resource.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_resource.cxx,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- pingus_resource.cxx 18 Feb 2003 21:38:08 -0000 1.22
+++ pingus_resource.cxx 3 Mar 2003 20:32:18 -0000 1.23
@@ -33,10 +33,13 @@
#include "pingus_resource.hxx"
#include "blitter.hxx"
#include "debug.hxx"
+#include "plf.hxx"
+#include "debug.hxx"
std::map<std::string, CL_ResourceManager*> PingusResource::resource_map;
-std::map<ResDescriptor, CL_Surface> PingusResource::surface_map;
+std::map<ResDescriptor, CL_Surface> PingusResource::surface_map;
std::map<ResDescriptor, CL_Font*> PingusResource::font_map;
+PingusResource::PLFMap PingusResource::plf_map;
void
PingusResource::init()
@@ -334,6 +337,49 @@
std::cout << "PingusResource::get_mtime: CL_Error: " << err.message <<
std::endl;
return 0;
}
+}
+
+PLFHandle
+PingusResource::load_plf_raw(const std::string& filename)
+{
+ std::string res_name = System::basename(filename);
+ res_name = res_name.substr(0, res_name.length()-4);
+
+ pout(PINGUS_DEBUG_LOADING) << "PingusResource: Loading level: '" << res_name
<< "' -> '" << filename << "'" << std::endl;
+
+ PLFMap::iterator i = plf_map.find(res_name);
+
+ if (i == plf_map.end ())
+ {
+ PLF* plf = PLF::create(filename);
+ plf_map[res_name] = plf;
+ return PLFHandle (plf);
+ }
+ else
+ {
+ return PLFHandle (i->second);
+ }
+}
+
+PLFHandle
+PingusResource::load_plf(const std::string& res_name)
+{
+ PLFMap::iterator i = plf_map.find(res_name);
+ std::string filename = path_manager.complete("levels/" + res_name + ".xml");
+
+ pout(PINGUS_DEBUG_LOADING) << "PingusResource: Loading level: '" << res_name
<< "' -> '" << filename << "'" << std::endl;
+
+ if (i == plf_map.end ())
+ {
+ PLF* plf = PLF::create(filename);
+ plf_map[res_name] = plf;
+ return PLFHandle (plf);
+ }
+ else
+ {
+ return PLFHandle (i->second);
+ }
+
}
/* EOF */
Index: pingus_resource.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_resource.hxx,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- pingus_resource.hxx 2 Nov 2002 19:03:40 -0000 1.11
+++ pingus_resource.hxx 3 Mar 2003 20:32:18 -0000 1.12
@@ -23,6 +23,7 @@
#include <map>
#include <ClanLib/Display/Display/surface.h>
+#include "plf_handle.hxx"
#include "res_descriptor.hxx"
class CL_Font;
@@ -34,6 +35,9 @@
class PingusResource
{
private:
+ typedef std::map<std::string, PLF*> PLFMap;
+ static PLFMap plf_map;
+
static std::map<std::string, CL_ResourceManager*> resource_map;
static std::map<ResDescriptor, CL_Surface> surface_map;
static std::map<ResDescriptor, CL_Font*> font_map;
@@ -49,6 +53,13 @@
/** */
static unsigned int get_mtime (const std::string& res_name,
const std::string& datafile);
+
+ /** @returns a handle to the PLF, which the caller *must not* delete */
+ static PLFHandle load_plf(const std::string& res_name);
+
+ /** @return a handle to the PLF, instead of loading it from a
+ res_name, load it from a system dependend filename */
+ static PLFHandle load_plf_raw(const std::string& filename);
/** Load a surface with res_name from datafile */
static CL_Surface load_surface(const std::string& res_name,
Index: theme.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/theme.cxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- theme.cxx 19 Feb 2003 09:50:36 -0000 1.12
+++ theme.cxx 3 Mar 2003 20:32:18 -0000 1.13
@@ -262,7 +262,7 @@
assert (!"Theme::play unimplemented");
ScreenManager::instance()->push_screen
- (new PingusGameSession(path_manager.complete("levels/" +
plt.get_levels()[current_level])));
+ (new
PingusGameSession(PingusResource::load_plf(plt.get_levels()[current_level])));
if (current_level == accessible_levels)
++accessible_levels;
Index: world.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/world.cxx,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- world.cxx 26 Feb 2003 17:08:29 -0000 1.39
+++ world.cxx 3 Mar 2003 20:32:18 -0000 1.40
@@ -245,7 +245,7 @@
}*/
void
-World::play_wav (std::string name, const Vector& pos, float volume)
+World::play_sound(std::string name, const Vector& pos, float volume)
{
if (view)
{
@@ -259,11 +259,11 @@
if (panning < -1.0f)
panning = -1.0f;
- PingusSound::play_sound(name, volume, panning);
+ PingusSound::play_sound("sounds/" + name + ".wav", volume, panning);
}
else // No view available, so no stereo enabled
{
- PingusSound::play_sound(name, volume);
+ PingusSound::play_sound("sounds/" + name + ".wav", volume);
}
}
Index: world.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/world.hxx,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- world.hxx 26 Feb 2003 17:08:29 -0000 1.25
+++ world.hxx 3 Mar 2003 20:32:18 -0000 1.26
@@ -119,11 +119,6 @@
/** @return The absolute width of the world */
int get_width();
- /** @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 finished ();
-
/** Returns the time passed since the level was started */
int get_time_passed();
@@ -151,12 +146,12 @@
/** Play a sound as if it would have been generated at the given
position, adjust panning and volume by the position relative to
the center of the screen
- @param name Filename of the wav file to play
+ @param name The name of the sound to play ("ohno", not "sounds/ohno.wav")
@param pos Position from which the sound seems to come (z-pos is
- going to be ignored) void play_wav (std::string name, const
+ going to be ignored) void play_sound (std::string name, const
@param volume The volume of the sound
*/
- void play_wav (std::string name, const Vector& pos, float volume = 0.5f);
+ void play_sound (std::string name, const Vector& pos, float volume = 0.5f);
/** Sets the main view, it is needed to play stereo wave and for
other screen orientated effects
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src Makefile.static,1.12,1.13 game_session.cxx,1.29,1.30 game_session.hxx,1.16,1.17 pingus_main.cxx,1.48,1.49 pingus_resource.cxx,1.22,1.23 pingus_resource.hxx,1.11,1.12 theme.cxx,1.12,1.13 world.cxx,1.39,1.40 world.hxx,1.25,1.26,
grumbel <=