Re: Super Methane Brothers V1.5.0 Release
Hi,
Thanks for the headsup on this new version. I've updated the Fedora
package of Super Methane Brothers to 1.5.0. This will be in
F-13, F-12 still has 1.4.7 as it still has the older ClanLib.
I've attached a number of patches I made agains the new release:
methane-fullscreen.patch:
-Allow switching between fullscreen and windowed mode in the initial
setup screen
-Start fullscreen by default
-Add -w cmdline option to start windowed
methane-highscore.patch:
-Save highscore to /var/games instead of to $HOME/.app-data/methane....,
this allows the highscores to be shared between players.
Note this is a Unix specific patch (not suitable for windows)
It should probably work on Max OS X too.
Regards,
Hans
On 10/22/2009 12:59 PM, Mark Page wrote:
My Methane game has been updated to use ClanLib 2.1
See http://methane.sourceforge.net/
afaik, it does not contain a package. Although, I believe it was on a SUSE distro around 5 years ago
If you want it, feel free to package it.
(The initial release was in the year 2001)
_________________________________________________________________
New Windows 7: Simplify what you do everyday. Find the right PC for you.
http://www.microsoft.com/windows/buy/
diff -up methane-1.5.0/sources/doc.cpp~ methane-1.5.0/sources/doc.cpp
--- methane-1.5.0/sources/doc.cpp~ 2009-10-22 10:33:21.000000000 +0200
+++ methane-1.5.0/sources/doc.cpp 2009-11-08 18:37:31.000000000 +0100
@@ -16,7 +16,10 @@
#include "doc.h"
#include "target.h"
#include "snddef.h"
+#include <stdio.h>
+extern FILE *methanescoresfptr;
+
//------------------------------------------------------------------------------
//! \brief Initialise Document
//!
@@ -110,28 +112,13 @@ void CMethDoc::DisplayOptions( CL_Displa
//------------------------------------------------------------------------------
void CMethDoc::LoadScores(void)
{
- CL_String dirname = CL_Directory::get_appdata("clanlib", "methane", "1.5", false);
-
- try
- {
- CL_File file(dirname+"highscores");
- HISCORES *hs;
- int cnt;
- for (cnt=0, hs=m_GameTarget.m_Game.m_HiScores; cnt<MAX_HISCORES; cnt++, hs++)
- {
- char buffer[5];
- file.read(buffer, 4, true);
- buffer[4] = 0;
- int score = file.read_int32();
-
- m_GameTarget.m_Game.InsertHiScore( score, buffer );
+ size_t ign;
- }
- }
- catch(CL_Exception& exception)
- {
- }
+ if (!methanescoresfptr) return; // No scores available
+ rewind(methanescoresfptr);
+ ign = fread(m_GameTarget.m_Game.m_HiScores, sizeof(HISCORES),
+ MAX_HISCORES, methanescoresfptr);
}
//------------------------------------------------------------------------------
@@ -139,21 +126,11 @@ void CMethDoc::LoadScores(void)
//------------------------------------------------------------------------------
void CMethDoc::SaveScores(void)
{
- CL_String dirname = CL_Directory::get_appdata("clanlib", "methane", "1.5");
+ size_t ign;
- try
- {
- CL_File file(dirname+"highscores", CL_File::create_always, CL_File::access_write);
- HISCORES *hs;
- int cnt;
- for (cnt=0, hs=m_GameTarget.m_Game.m_HiScores; cnt<MAX_HISCORES; cnt++, hs++)
- {
- file.write(hs->name, 4, true);
- file.write_int32(hs->score);
- }
- }
- catch(CL_Exception& exception)
- {
- }
-}
+ if (!methanescoresfptr) return; // No scores available
+ rewind(methanescoresfptr);
+ ign = fwrite(m_GameTarget.m_Game.m_HiScores, sizeof(HISCORES),
+ MAX_HISCORES, methanescoresfptr);
+}
diff -up methane-1.5.0/sources/game.cpp~ methane-1.5.0/sources/game.cpp
--- methane-1.5.0/sources/game.cpp~ 2009-04-28 16:42:43.000000000 +0200
+++ methane-1.5.0/sources/game.cpp 2009-11-08 18:44:46.000000000 +0100
@@ -27,6 +27,7 @@
#include "weapon.h"
#include "target.h"
#include <stdlib.h>
+#include <stdio.h>
//------------------------------------------------------------------------------
// The Game Version Number
diff -up methane-1.5.0/sources/methane.cpp~ methane-1.5.0/sources/methane.cpp
--- methane-1.5.0/sources/methane.cpp~ 2009-10-22 10:47:43.000000000 +0200
+++ methane-1.5.0/sources/methane.cpp 2009-11-08 18:30:40.000000000 +0100
@@ -12,6 +12,14 @@
//------------------------------------------------------------------------------
// Methane brothers main source file
//------------------------------------------------------------------------------
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE /* this must be done before the first include of unistd.h */
+#endif
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
#include <ClanLib/core.h>
#include <ClanLib/application.h>
#include <ClanLib/display.h>
@@ -24,6 +31,8 @@
#include "doc.h"
+FILE *methanescoresfptr = NULL;
+
RenderTarget GLOBAL_RenderTarget = opengl;
bool GLOBAL_SoundEnable = true;
@@ -236,6 +245,8 @@ public:
last_time = last_time + game_speed;
}
Game.SaveScores();
+ if (methanescoresfptr)
+ fclose(methanescoresfptr);
}
catch(CL_Exception& exception)
{
@@ -340,6 +351,15 @@ class Program
public:
static int main(const std::vector<CL_String> &args)
{
+ gid_t realgid = getgid();
+
+ methanescoresfptr = fopen("/var/games/methane.scores", "r+");
+
+ if (setresgid(-1, realgid, realgid) != 0) {
+ perror("Could not drop setgid privileges. Aborting.");
+ exit(1);
+ }
+
CL_SetupCore setup_core;
CL_SetupDisplay setup_display;
Only in methane-1.5.0.new: build
Only in methane-1.5.0.new: debugfiles.list
Only in methane-1.5.0.new: debuglinks.list
Only in methane-1.5.0.new: debugsources.list
Only in methane-1.5.0.new: methane
diff -ur methane-1.5.0/sources/methane.cpp methane-1.5.0.new/sources/methane.cpp
--- methane-1.5.0/sources/methane.cpp 2009-11-09 23:24:15.000000000 +0100
+++ methane-1.5.0.new/sources/methane.cpp 2009-11-09 23:20:25.000000000 +0100
@@ -36,6 +36,7 @@
RenderTarget GLOBAL_RenderTarget = opengl;
bool GLOBAL_SoundEnable = true;
+bool GLOBAL_FullScreenEnable = true;
//------------------------------------------------------------------------------
// Keyboard stuff
@@ -59,6 +60,20 @@
int main(const std::vector<CL_String> &args)
{
+ int i;
+
+ for (i = 1; i < args.size(); i++)
+ {
+ if (args[i].compare("-w") == 0)
+ GLOBAL_FullScreenEnable = false;
+ else
+ fprintf(stderr,
+ "Unknown commandline parameter: '%s', ignoring\n\n"
+ "Valid parameters:\n"
+ "'-w': start in windowed mode\n",
+ args[i].c_str());
+ }
+
// Create a console window for text-output if not available
CL_ConsoleWindow console("Console");
try
@@ -103,7 +118,13 @@
CL_DisplayWindowDescription desc;
desc.set_title("Super Methane Brothers");
desc.set_size(CL_Size(SCR_WIDTH*2,SCR_HEIGHT*2), true);
- desc.set_allow_resize(true);
+ if (GLOBAL_FullScreenEnable)
+ {
+ desc.set_fullscreen(true);
+ desc.set_decorations(false);
+ }
+ else
+ desc.set_allow_resize(true);
CL_DisplayWindow window(desc);
CMethDoc Game(window);
@@ -129,8 +150,6 @@
int last_time = CL_System::get_time();
int quit_flag = 0;
- int disable_scale_flag = 0;
- int full_screen_flag = 0;
int on_options_screen = 1;
int option_page = 0;
int game_speed = 60;
@@ -276,7 +295,8 @@
bool get_options()
{
- CL_DisplayWindow window("Methane Options", 640, 480);
+ CL_DisplayWindow window("Methane Options", 640, 480,
+ GLOBAL_FullScreenEnable);
// Connect the Window close event
CL_Slot slot_quit = window.sig_window_close().connect(this, &SuperMethaneBrothers::on_window_close);
@@ -311,6 +331,12 @@
}
}
+ if ( (LastKey == 'f') || (LastKey == 'F') )
+ {
+ LastKey = 0;
+ GLOBAL_FullScreenEnable = !GLOBAL_FullScreenEnable;
+ }
+
gc.clear(CL_Colorf(0.0f,0.0f,0.2f));
int ypos = 40;
@@ -333,6 +359,15 @@
{
options_font.draw_text(gc, 10, ypos, "Audio - Disabled. Press 'A' to modify");
}
+ ypos += 50;
+ if (GLOBAL_FullScreenEnable)
+ {
+ options_font.draw_text(gc, 10, ypos, "Full screen - Enabled. Press 'F' to modify");
+ }
+ else
+ {
+ options_font.draw_text(gc, 10, ypos, "Full screen - Disabled. Press 'F' to modify");
+ }
ypos += 100;
options_font.draw_text(gc, 10, ypos, "Press the spacebar to start");
Only in methane-1.5.0.new/sources: methane.cpp~
Reply to: