[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src Makefile.am,1.118,1.119 action_data.h
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src Makefile.am,1.118,1.119 action_data.hxx,1.5,1.6 pingus_main.cxx,1.28,1.29 pingus_main.hxx,1.5,1.6 pingus_resource.cxx,1.20,1.21 pingus_resource.hxx,1.10,1.11 generic_main.cxx,1.3,NONE generic_main.hxx,1.4,NONE |
Date: |
2 Nov 2002 19:03:42 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv31913
Modified Files:
Makefile.am action_data.hxx pingus_main.cxx pingus_main.hxx
pingus_resource.cxx pingus_resource.hxx
Removed Files:
generic_main.cxx generic_main.hxx
Log Message:
some cleanup of the startup code and probally some memory leak fixes
Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/Makefile.am,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -d -r1.118 -r1.119
--- Makefile.am 16 Oct 2002 11:29:30 -0000 1.118
+++ Makefile.am 2 Nov 2002 19:03:40 -0000 1.119
@@ -147,8 +147,6 @@
game_session_result.hxx \
game_time.cxx \
game_time.hxx \
-generic_main.cxx \
-generic_main.hxx \
global_event.cxx \
global_event.hxx \
globals.cxx \
Index: action_data.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/action_data.hxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- action_data.hxx 25 Aug 2002 09:08:48 -0000 1.5
+++ action_data.hxx 2 Nov 2002 19:03:40 -0000 1.6
@@ -34,6 +34,9 @@
int number_of;
};
+/** Actions that are available through the GUI in the level editor,
+ only useable action are here, hidden actions like walker or drawn
+ are not here */
extern std::vector<ActionData> default_actions;
void init_default_actions ();
Index: pingus_main.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_main.cxx,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- pingus_main.cxx 2 Nov 2002 14:46:29 -0000 1.28
+++ pingus_main.cxx 2 Nov 2002 19:03:40 -0000 1.29
@@ -41,7 +41,12 @@
#include <ClanLib/Display/setupdisplay.h>
#include <ClanLib/Display/Display/display.h>
#include <ClanLib/Display/Input/input.h>
+
+#include <ClanLib/Core/System/setupcore.h>
#include <ClanLib/jpeg.h>
+#include <ClanLib/png.h>
+#include <ClanLib/GUI/setupgui.h>
+
#ifdef HAVE_LIBCLANGL
# include <ClanLib/gl.h>
@@ -79,6 +84,7 @@
#include "xml_helper.hxx"
#include "input_debug_screen.hxx"
#include "pingus_menu_manager.hxx"
+#include "pingus_resource.hxx"
using EditorNS::Editor;
@@ -306,7 +312,15 @@
sound_enabled = true;
break;
case 'g':
- resolution = optarg;
+ {
+ char c;
+ if (sscanf(optarg, "%d%c%d", &screen_width, &c, &screen_height) != 3
&& c != 'x')
+ {
+ std::cout << "Resolution std::string is wrong, it should be like:
\n"
+ << "\"640x480\" or \"800x600\"" << std::endl;
+ exit(EXIT_FAILURE);
+ }
+ }
break;
case 'S':
std::cout << "not impl. XALA" << std::endl;
@@ -614,41 +628,9 @@
}
}
-void
-PingusMain::init_pingus()
-{
- if (verbose)
- {
- std::cout <<
-
_("-----------------------------------------------------------------\n")
- << std::endl;
- std::cout <<
- _(" Verbosity set to: ") << verbose << "\n"
- << std::endl;
- std::cout <<
- _(" If you don't like to get lots of debug messages, than set the\n"
- " verbosity down to 0, like this:\n\n"
- " $ ./pingus --verbose 0\n"
-
"-----------------------------------------------------------------\n")
- << std::endl;
- }
-
- Fonts::init_fonts ();
- fps_counter.init();
- console.init();
- XMLhelper::init();
-
- pout.add (std::cerr);
- pout.add (console);
- pwarn.add (std::cerr);
- pout.add (console);
- perr.add (std::cerr);
- perr.add (console);
-}
-
// Get all filenames and directories
void
-PingusMain::get_filenames()
+PingusMain::init_path_finder()
{
System::init_directories();
@@ -698,131 +680,10 @@
textdomain (PACKAGE);
#endif
std::cout << "BasePath: " << path_manager.get_base_path () << std::endl;
-
- // First we try to open the file which was given, if that is not
- // there then we try again with filename+".plf". If still no success
- // we try to search for that file in the pingus_path, if its not
- // there, then we try to search for the filename+".plf" in the
- // pingus_path.
- /* This code really shouldn't be here
- std::string custom_levelfile = levelfile;
- bool levelfile_not_found = false;
- if (!custom_levelfile.empty() && !System::exist(custom_levelfile))
- {
- if (System::exist(custom_levelfile + ".plf"))
- {
- custom_levelfile += ".plf";
- }
- else
- {
- if (verbose)
- std::cout << "Levelfile not found, trying fallbacks" << std::endl;
-
- // Search for the level in the datadir
- custom_levelfile = find_file(pingus_datadir, "/levels/" + levelfile);
- levelfile_not_found = !System::exist(custom_levelfile.c_str());
-
- if (levelfile_not_found)
- {
- custom_levelfile = find_file(pingus_datadir, "/levels/" + levelfile +
".plf");
- levelfile_not_found = !System::exist(custom_levelfile.c_str());
- }
-
- if (levelfile_not_found)
- {
- std::cout << "Couldn't find level file: \"" << levelfile << "\"" <<
std::endl;
- exit(EXIT_FAILURE);
- }
- }
- }
-
- levelfile = custom_levelfile;
-
- if (verbose)
- std::cout << "Pingus Level File: " << levelfile << std::endl;
- */
-}
-
-void
-PingusMain::init (int argc, char** argv)
-{
- char c;
-
- PingusMain::quick_check_args(argc, argv);
- PingusMain::read_rc_file();
- PingusMain::check_args(argc, argv);
-
- init_default_actions ();
-
- // Translate the geometry std::string to some int's
- if (!resolution.empty())
- {
- if (sscanf(resolution.c_str(), "%d%c%d", &screen_width, &c,
&screen_height) != 3)
- {
- std::cout << "Resolution std::string is wrong, it should be like: \n"
- << "\"640x480\" or \"800x600\"" << std::endl;
- exit(EXIT_FAILURE);
- }
- }
- // Loading data and initialisising
- get_filenames();
- // register_actions();
}
void
-PingusMain::init_clanlib ()
-{
- // Init ClanLib
- if (verbose)
- std::cout << "Init ClanLib" << std::endl;
-
-#ifdef HAVE_LIBCLANGL
- if (use_opengl) {
- CL_SetupGL::init();
- std::cout << "Using OpenGL" << std::endl;
- }
-#endif
- CL_SetupDisplay::init();
-
- if (sound_enabled || music_enabled)
- {
- if (verbose)
- std::cout << "Init Sound" << std::endl;
-
- PingusSound::init (new PingusSoundReal ());
- }
- else
- {
- if (verbose)
- std::cout << "Sound disabled" << std::endl;
- PingusSound::init (new PingusSoundDummy ());
- }
-
- if (verbose)
- {
- std::cout << "Using resolution: "
- << screen_width << "x" << screen_height << std::endl;
- }
-
- // Initing the display
- CL_Display::set_videomode(screen_width, screen_height, 16,
- fullscreen_enabled,
- false); // allow resize
-
-#ifdef HAVE_LIBCLANGL
- if (use_opengl)
- {
- CL_OpenGL::begin_2d ();
- glEnable (GL_BLEND);
- }
-#endif
-
- CL_Display::clear_display ();
- CL_Display::flip_display ();
-}
-
-void
-PingusMain::start_game(void)
+PingusMain::start_game ()
{
if (verbose) {
pout << _("PingusMain: Starting Main: ") << CL_System::get_time() <<
std::endl;
@@ -896,29 +757,35 @@
int
PingusMain::main(int argc, char** argv)
{
+ executable_name = argv[0];
+
// Register the segfault_handler
//signal(SIGSEGV, signal_handler);
//signal(SIGINT, signal_handler);
-#if 0 // used to be WIN32
+#ifdef WIN32
+ // Redirect stdout to somewhere where it is readable
CL_ConsoleWindow cl_console(PACKAGE VERSION);
cl_console.redirect_stdio();
#endif
- executable_name = argv[0];
- try {
- init(argc, argv);
- init_clanlib();
- init_pingus();
-
- if (!intro_disabled && levelfile.empty())
- {
- //intro.draw();
- }
+ try
+ {
+ quick_check_args(argc, argv);
+ read_rc_file();
+ check_args(argc, argv);
+
+ init_path_finder();
+
+ init_clanlib();
+ init_pingus();
- start_game();
- }
+ start_game();
+
+ deinit_pingus();
+ deinit_clanlib();
+ }
catch (const CL_Error& err) {
std::cout << _("Error caught from ClanLib: ") << err.message << std::endl;
@@ -942,5 +809,115 @@
return 0;
}
+
+
+void
+PingusMain::init_clanlib()
+{
+ CL_SetupCore::init ();
+ CL_SetupPNG::init ();
+ CL_SetupJPEG::init ();
+ CL_SetupGUI::init ();
+
+#ifdef HAVE_LIBCLANGL
+ if (use_opengl) {
+ CL_SetupGL::init();
+ std::cout << "Using OpenGL" << std::endl;
+ }
+#endif
+
+ CL_SetupDisplay::init();
+
+ if (verbose)
+ {
+ std::cout << "Using resolution: "
+ << screen_width << "x" << screen_height << std::endl;
+ }
+
+ // Initing the display
+ CL_Display::set_videomode(screen_width, screen_height, 16,
+ fullscreen_enabled,
+ false); // allow resize
+
+#ifdef HAVE_LIBCLANGL
+ if (use_opengl)
+ {
+ CL_OpenGL::begin_2d ();
+ glEnable (GL_BLEND);
+ }
+#endif
+
+ CL_Display::clear_display ();
+ CL_Display::flip_display ();
+
+}
+
+void
+PingusMain::deinit_clanlib()
+{
+ CL_SetupDisplay::deinit();
+#ifdef HAVE_LIBCLANGL
+ if (use_opengl)
+ CL_SetupGL::deinit();
+#endif
+ CL_SetupGUI::deinit ();
+ CL_SetupPNG::deinit();
+ CL_SetupJPEG::deinit();
+ CL_SetupCore::deinit();
+}
+
+void
+PingusMain::init_pingus()
+{
+ if (verbose)
+ {
+ std::cout <<
+
_("-----------------------------------------------------------------\n")
+ << std::endl;
+ std::cout <<
+ _(" Verbosity set to: ") << verbose << "\n"
+ << std::endl;
+ std::cout <<
+ _(" If you don't like to get lots of debug messages, than set the\n"
+ " verbosity down to 0, like this:\n\n"
+ " $ ./pingus --verbose 0\n"
+
"-----------------------------------------------------------------\n")
+ << std::endl;
+ }
+
+ Fonts::init_fonts ();
+ PingusResource::init();
+ fps_counter.init();
+ console.init();
+ XMLhelper::init();
+
+ pout.add (std::cerr);
+ pout.add (console);
+ pwarn.add (std::cerr);
+ pout.add (console);
+ perr.add (std::cerr);
+ perr.add (console);
+
+ if (sound_enabled || music_enabled)
+ {
+ if (verbose)
+ std::cout << "Init Sound" << std::endl;
+
+ PingusSound::init (new PingusSoundReal ());
+ }
+ else
+ {
+ if (verbose)
+ std::cout << "Sound disabled" << std::endl;
+ PingusSound::init (new PingusSoundDummy ());
+ }
+
+}
+
+void
+PingusMain::deinit_pingus()
+{
+
+}
/* EOF */
Index: pingus_main.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_main.hxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- pingus_main.hxx 27 Sep 2002 11:26:44 -0000 1.5
+++ pingus_main.hxx 2 Nov 2002 19:03:40 -0000 1.6
@@ -22,12 +22,12 @@
#include <string>
#include <ClanLib/Signals/slot.h>
-
-#include "generic_main.hxx"
+#include <ClanLib/application.h>
+#include "pingus.hxx"
void segfault_handler(int);
-class PingusMain : public AbstractMain
+class PingusMain : public CL_ClanApplication
{
private:
bool no_config_file;
@@ -46,23 +46,28 @@
virtual int main(int argc, char** argv);
virtual char* get_title();
- void start_game(void);
+private:
+ /** After all subsystems have been inited, the screen will get
+ setup, the game (the menu, the editor or a level, depending on
+ command line flags) will start and the user will get
+ controll. */
+ void start_game();
void check_args(int argc, char** argv);
void quick_check_args(int argc, char** argv);
void read_rc_file(void);
- void get_filenames(void);
- void init(int argc, char** argv);
- void init_clanlib(void);
- /// void intro(void);
- void init_pingus(void);
+ void init_clanlib();
+ void deinit_clanlib();
+
+ void init_pingus();
+ void init_path_finder();
+ void deinit_pingus();
-private:
PingusMain (const PingusMain&);
PingusMain& operator= (const PingusMain&);
-};
+} app; // golbal class instance
#endif
Index: pingus_resource.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_resource.cxx,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- pingus_resource.cxx 19 Oct 2002 23:23:44 -0000 1.20
+++ pingus_resource.cxx 2 Nov 2002 19:03:40 -0000 1.21
@@ -73,9 +73,25 @@
return filename;
}
-PingusResource::PingusResource()
+
+void
+PingusResource::init()
{
- //std::cout << "PingusResource Constructor called" << std::endl;
+ // do nothing
+}
+
+void
+PingusResource::deinit()
+{
+ for (std::map<std::string, CL_ResourceManager*>::iterator i =
resource_map.begin();
+ i != resource_map.end ();
+ ++i)
+ delete i->second;
+
+ for (std::map<ResDescriptor, CL_Font*>::iterator i = font_map.begin();
+ i != font_map.end ();
+ ++i)
+ delete i->second;
}
CL_ResourceManager*
Index: pingus_resource.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_resource.hxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- pingus_resource.hxx 27 Sep 2002 11:26:44 -0000 1.10
+++ pingus_resource.hxx 2 Nov 2002 19:03:40 -0000 1.11
@@ -43,8 +43,8 @@
static CL_Surface apply_modifier (const CL_Surface&, const ResDescriptor&
res_desc);
public:
- /** */
- PingusResource();
+ static void init();
+ static void deinit();
/** */
static unsigned int get_mtime (const std::string& res_name,
--- generic_main.cxx DELETED ---
--- generic_main.hxx DELETED ---
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src Makefile.am,1.118,1.119 action_data.hxx,1.5,1.6 pingus_main.cxx,1.28,1.29 pingus_main.hxx,1.5,1.6 pingus_resource.cxx,1.20,1.21 pingus_resource.hxx,1.10,1.11 generic_main.cxx,1.3,NONE generic_main.hxx,1.4,NONE,
grumbel <=