Files
haikuports/games-puzzle/pathological/patches/pathological-1.1.3_17.patchset
OscarL 053368db2f pathological: fixes and recipe cleanups. (#11814)
- Use original .xm music files.
  We don't package .ogg files, so until we do (we need to convert them at build
  time), just drop that Debian patch.
- Fix startup from Tracker/Deskbar.
- This is now an "any" package (it is just a Python script after all).
  Drop usage and references to write_highscores{.c}. We're not Debian.
- Added a very simple icon (best I can do... I'm not fond of IOM's workflow/UI/UX).

Now Pathological is easy to find among Deskbar's Applications, and starts just fine
from Deskbar/Tracker (and from Terminal too).
2025-02-21 06:49:46 +00:00

1206 lines
38 KiB
Plaintext

From 3556268449361cf4f15a3352cdbfcf97595c6940 Mon Sep 17 00:00:00 2001
From: Begasus <begasus@gmail.com>
Date: Sat, 29 Apr 2023 12:52:35 +0200
Subject: applying patch 10_makefile.patch
diff --git a/Makefile b/Makefile
index dc42b93..432353b 100644
--- a/Makefile
+++ b/Makefile
@@ -2,59 +2,60 @@ DESTDIR =
DATADIR = $(DESTDIR)/usr/share/games/pathological
-all: write-highscores html/wheel.png
+all: write-highscores docs
write-highscores: write-highscores.c
gcc -s -o write-highscores write-highscores.c
+docs: html/wheel.png
html/wheel.png:
./makehtml
-install: all
- mkdir -p $(DATADIR)
- cp pathological.py $(DATADIR)/
+install: install-dep install-indep install-scores
+
+# Install architecture-independent data
+install-indep:
+ install -d $(DATADIR)
+ install -D -m 755 pathological.py $(DATADIR)/pathological.py
cp -r circuits graphics music sounds $(DATADIR)/
rm -f $(DATADIR)/graphics/*.xcf
rm -f $(DATADIR)/sounds/*.orig
- mkdir -p $(DESTDIR)/usr/games
- cp pathological $(DESTDIR)/usr/games/
-
- mkdir -p $(DESTDIR)/usr/lib/pathological/bin
- cp write-highscores $(DESTDIR)/usr/lib/pathological/bin
-
- # The following changes should also be performed in a post-install script
- -chgrp games $(DESTDIR)/usr/lib/pathological/bin/write-highscores
- -chmod 2755 $(DESTDIR)/usr/lib/pathological/bin/write-highscores
+ install -D -m 755 pathological $(DESTDIR)/usr/games/pathological
- mkdir -p $(DESTDIR)/usr/X11R6/include/X11/pixmaps
- cp pathological.xpm $(DESTDIR)/usr/X11R6/include/X11/pixmaps
+ zcat pathological.6.gz > pathological.6
+ install -D -m 644 pathological.6 $(DESTDIR)/usr/share/man/man6/pathological.6
- mkdir -p $(DESTDIR)/var/games
- cp pathological_scores $(DESTDIR)/var/games
+ install -d $(DESTDIR)/usr/share/doc/pathological
+ cp -r html $(DESTDIR)/usr/share/doc/pathological
- # The following changes should also be performed in a post-install script
- -chgrp games $(DESTDIR)/var/games/pathological_scores
- -chmod 664 $(DESTDIR)/var/games/pathological_scores
+ install -D -m 644 pathological.xpm $(DESTDIR)/usr/share/pixmaps/pathological.xpm
- mkdir -p $(DESTDIR)/usr/share/man/man6
- cp pathological.6.gz $(DESTDIR)/usr/share/man/man6
+# Install architecture-dependent data
+install-dep:
+ install -d $(DESTDIR)/var/games
+ install -D -m 2755 --owner=root --group=games write-highscores $(DESTDIR)/usr/lib/games/pathological/bin/write-highscores
- mkdir -p $(DESTDIR)/usr/share/doc/pathological
- cp -r html $(DESTDIR)/usr/share/doc/pathological
+# Install the scores file, if it doesn't already exist.
+install-scores:
+ if [ ! -e $(DESTDIR)/var/games/pathological_scores ]; then \
+ install -D -m 644 pathological_scores $(DESTDIR)/var/games/pathological_scores; \
+ fi
uninstall:
rm -rf $(DATADIR)
- rm -rf $(DESTDIR)/usr/lib/pathological
+ rm -rf $(DESTDIR)/usr/lib/games/pathological
rm -f $(DESTDIR)/usr/games/pathological
- rm -f $(DESTDIR)/usr/X11R6/include/X11/pixmaps/pathological.xpm
+ rm -f $(DESTDIR)/usr/share/pixmaps/pathological.xpm
rm -f $(DESTDIR)/usr/share/man/man6/pathological.6.gz
purge: uninstall
rm -f $(DESTDIR)/var/games/pathological_scores
empty: distclean
+distclean: clean
-distclean:
+clean:
rm -f write-highscores
rm -f html/*.png
+ rm -f pathological.6
--
2.45.2
From 94ac69fbaf7fadfeac8907cc9385fb337128b940 Mon Sep 17 00:00:00 2001
From: Begasus <begasus@gmail.com>
Date: Sat, 29 Apr 2023 12:52:35 +0200
Subject: applying patch 20_highscores.patch
diff --git a/pathological b/pathological
index ca356b3..8a77cb7 100755
--- a/pathological
+++ b/pathological
@@ -32,8 +32,4 @@ done
cd /usr/share/games/pathological
-if [ -z "$scoresfile" ]; then
- scoresfile=/var/games/pathological_scores
-fi
-
-exec ./pathological.py $options $scoresfile
+exec ./pathological.py $options
diff --git a/pathological.py b/pathological.py
index 5c15009..bf5dde4 100755
--- a/pathological.py
+++ b/pathological.py
@@ -1,6 +1,8 @@
#!/usr/bin/python
+# -*- coding: iso-8859-1 -*-
"""
Copyright (C) 2003 John-Paul Gignac
+ (C) 2004 Joe Wreschnig
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -22,7 +24,7 @@ import os, pygame, random, time, math, re, sys, md5
from pygame.locals import *
# Parse the command line
-highscores_file = "pathological_scores"
+highscores_file = os.path.join(os.environ["HOME"], "config/settings/pathological_scores")
screenshot = 0
fullscreen = 0
colorblind = 0
@@ -51,7 +53,7 @@ else:
# The location of the setgid script for writing highscores
# This script is only used if the highscores file is not writable directly
-write_highscores = "/usr/lib/pathological/bin/write-highscores"
+write_highscores = "/system/lib/pathological/bin/write-highscores"
# Game constants
wheel_steps = 9
@@ -1562,7 +1564,7 @@ def popdown( popup_rc):
pygame.display.update( popup_rc[1])
class Game:
- def __init__(self, screen, circuit, highscores):
+ def __init__(self, screen, circuit, highscores, level = 0):
self.screen = screen
self.circuit = circuit
self.highscores = highscores
@@ -1578,7 +1580,7 @@ class Game:
f.close()
self.numlevels = j / vert_tiles
- self.level = 0
+ self.level = level
self.score = 0
self.lives = initial_lives
@@ -1829,6 +1831,7 @@ def get_name( screen, font, cursor_box, backcol, forecol):
class IntroScreen:
menu = ("Start Game", "High Scores", "Fullscreen:", "Music:",
"Sound Effects:", "Quit Game")
+ start_level = 1
menu_width = 240
menu_pos = ((800 - menu_width)/2, 145)
menu_font_height = 32
@@ -1914,6 +1917,14 @@ class IntroScreen:
self.screen.blit( menu_option, (self.menu_pos[0], y))
y += self.menu_font_height
+ levelt = self.menu_font.render("(Lvl. %d)" %
+ IntroScreen.start_level,
+ 1, self.menu_color)
+ lt_r = levelt.get_rect()
+ lt_r.right = self.menu_pos[0] + self.menu_option_left + 40
+ lt_r.top = self.menu_pos[1]
+ self.screen.blit(levelt, lt_r)
+
if fullscreen: offon = 'On'
else: offon = 'Off'
offon = self.menu_font.render( offon, 1, self.menu_color)
@@ -1966,6 +1977,15 @@ class IntroScreen:
self.curpage = 1
self.draw_menu()
+ def inc_level(self):
+ if (IntroScreen.start_level <
+ max([s[2] for s in self.highscores.scores])):
+ IntroScreen.start_level += 1
+
+ def dec_level(self):
+ if IntroScreen.start_level > 1:
+ IntroScreen.start_level -= 1
+
def do(self, show_highscores=0):
self.scroller_pos = -self.scroller_rect[2]
@@ -2028,7 +2048,15 @@ class IntroScreen:
self.draw_menu()
elif event.key == K_SPACE or event.key == K_RETURN:
rc = self.menu_select( self.menu_cursor)
- if rc < 1: return rc
+ if rc: return rc
+ elif event.key == K_LEFT:
+ if self.menu_cursor == 0:
+ self.dec_level()
+ self.draw_menu()
+ elif event.key == K_RIGHT:
+ if self.menu_cursor == 0:
+ self.inc_level()
+ self.draw_menu()
continue
elif event.type is MOUSEBUTTONDOWN:
if self.curpage == 1:
@@ -2044,9 +2072,8 @@ class IntroScreen:
if pos[1] < self.menu_pos[1]: continue
i = (pos[1] - self.menu_pos[1]) / self.menu_font_height
if i >= len(self.menu): continue
-
rc = self.menu_select( i)
- if rc < 1: return rc
+ if rc: return rc
pygame.display.update( self.dirty_rects)
@@ -2057,7 +2084,7 @@ class IntroScreen:
# 1 - Unknown option
def menu_select( self, i):
if i == 0:
- return 0
+ return IntroScreen.start_level
elif i == 1:
play_sound( menu_select)
self.go_to_highscores()
@@ -2075,7 +2102,7 @@ class IntroScreen:
self.draw_menu()
elif i == 5:
return -1
- return 1
+ return 0
hs_font_height = 24
hs_width = 320
@@ -2157,7 +2184,10 @@ def setup_everything():
pygame.mixer.pre_init(44100,-16,1,4096)
# Initialize the game module
- pygame.init()
+ pygame.display.init()
+ pygame.mixer.init()
+ pygame.font.init()
+ pygame.key.set_repeat(500, 30)
if not pygame.font: print 'Warning, fonts disabled'
if not pygame.mixer: print 'Warning, sound disabled'
@@ -2189,7 +2219,8 @@ while 1:
if rc < 0: break # Handle the QUIT message
- game = Game(screen, 'all-boards', highscores)
+ # If rc is positive, it's a level.
+ game = Game(screen, 'all-boards', highscores, rc - 1)
show_highscores = 1
--
2.45.2
From de5bb482ca334752134013bf1ac2603c3624660d Mon Sep 17 00:00:00 2001
From: Begasus <begasus@gmail.com>
Date: Sat, 29 Apr 2023 12:52:35 +0200
Subject: applying patch 30_no_soundcard.patch
diff --git a/pathological.py b/pathological.py
index bf5dde4..5fab5ea 100755
--- a/pathological.py
+++ b/pathological.py
@@ -2185,7 +2185,12 @@ def setup_everything():
# Initialize the game module
pygame.display.init()
- pygame.mixer.init()
+ try:
+ pygame.mixer.init()
+ except:
+ print "error on pygame.mixer.init() inside setup_everything():"
+ print sys.exc_info()[0],":",sys.exc_info()[1]
+ print "...ignoring it"
pygame.font.init()
pygame.key.set_repeat(500, 30)
--
2.45.2
From e381bb545dd314d348e42d494061d9e1deb87933 Mon Sep 17 00:00:00 2001
From: Begasus <begasus@gmail.com>
Date: Sat, 29 Apr 2023 12:52:35 +0200
Subject: applying patch 40_pygame_181.patch
diff --git a/pathological.py b/pathological.py
index 5fab5ea..2b6cfe0 100755
--- a/pathological.py
+++ b/pathological.py
@@ -169,6 +169,7 @@ def start_music(name, volume=-1):
if not pygame.mixer or not pygame.mixer.music:
print "Background music not available."
return
+ pygame.mixer.music.stop()
fullname = os.path.join('music', name)
try:
pygame.mixer.music.load(fullname)
--
2.45.2
From 7e6bc003c2fb028448471a85a673e141704d188b Mon Sep 17 00:00:00 2001
From: Begasus <begasus@gmail.com>
Date: Sat, 29 Apr 2023 12:52:35 +0200
Subject: applying patch define-music_pending_song.patch
diff --git a/pathological.py b/pathological.py
index 2b6cfe0..87d2e6c 100755
--- a/pathological.py
+++ b/pathological.py
@@ -30,6 +30,7 @@ fullscreen = 0
colorblind = 0
sound_on = 1
music_on = 1
+music_pending_song = 0
for arg in sys.argv[1:]:
if arg == '-s':
screenshot = 1
@@ -197,7 +198,7 @@ def toggle_sound():
sound_on = sound_on ^ 1
def toggle_music():
- global music_on
+ global music_pending_song, music_on
music_on = music_on ^ 1
if music_on:
if music_pending_song:
--
2.45.2
From b04847e2c610dc26153726bda32e3f97456f81b4 Mon Sep 17 00:00:00 2001
From: Begasus <begasus@gmail.com>
Date: Sat, 29 Apr 2023 12:52:35 +0200
Subject: applying patch python3.patch
diff --git a/pathological.py b/pathological.py
index 87d2e6c..6ac07ff 100755
--- a/pathological.py
+++ b/pathological.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
# -*- coding: iso-8859-1 -*-
"""
Copyright (C) 2003 John-Paul Gignac
@@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
# Import Modules
-import os, pygame, random, time, math, re, sys, md5
+import os, pygame, random, time, math, re, sys, hashlib
from pygame.locals import *
# Parse the command line
@@ -42,7 +42,7 @@ for arg in sys.argv[1:]:
sound_on = 0
music_on = 0
elif arg[0] == '-':
- print "Usage: "+sys.argv[0]+" [-cb] [-f] [-s] [highscores-file]\n"
+ print("Usage: "+sys.argv[0]+" [-cb] [-f] [-s] [highscores-file]\n")
sys.exit(1)
else:
highscores_file = arg
@@ -104,10 +104,10 @@ for i in range(wheel_steps):
c = math.floor( 0.5 + math.cos(theta)*holecenter_radius)
s = math.floor( 0.5 + math.sin(theta)*holecenter_radius)
holecenters.append((
- (tile_size/2 + s, tile_size/2 - c),
- (tile_size/2 + c, tile_size/2 + s),
- (tile_size/2 - s, tile_size/2 + c),
- (tile_size/2 - c, tile_size/2 - s)))
+ (tile_size//2 + s, tile_size//2 - c),
+ (tile_size//2 + c, tile_size//2 + s),
+ (tile_size//2 - s, tile_size//2 + c),
+ (tile_size//2 - c, tile_size//2 - s)))
# Direction references
dirs = ((0,-1),(1,0),(0,1),(-1,0))
@@ -125,16 +125,16 @@ def load_image(name, colorkey=-1, size=None):
fullname = os.path.join('graphics', name)
try:
image = pygame.image.load(fullname)
- except pygame.error, message:
- print 'Cannot load image:', fullname
- raise SystemExit, message
+ except pygame.error as message:
+ print('Cannot load image:', fullname)
+ raise SystemExit(message)
if size is not None:
image = pygame.transform.scale( image, size)
image = image.convert()
if colorkey is not None:
- if colorkey is -1:
+ if colorkey == -1:
colorkey = image.get_at((0,0))
image.set_colorkey(colorkey, RLEACCEL)
return image
@@ -147,8 +147,8 @@ def load_sound(name, volume=1.0):
fullname = os.path.join('sounds', name)
try:
sound = pygame.mixer.Sound(fullname)
- except pygame.error, message:
- print 'Cannot load sound:', fullname
+ except pygame.error as message:
+ print('Cannot load sound:', fullname)
return NoneSound()
sound.set_volume( volume * sound_effects_volume)
@@ -168,14 +168,14 @@ def start_music(name, volume=-1):
return
if not pygame.mixer or not pygame.mixer.music:
- print "Background music not available."
+ print("Background music not available.")
return
pygame.mixer.music.stop()
fullname = os.path.join('music', name)
try:
pygame.mixer.music.load(fullname)
- except pygame.error, message:
- print 'Cannot load music:', fullname
+ except pygame.error as message:
+ print('Cannot load music:', fullname)
return
music_loaded = 1
pygame.mixer.music.play(-1)
@@ -263,17 +263,17 @@ def load_fonts():
def load_images():
Marble.images = []
for i in range(9):
- Marble.images.append( load_image('marble-'+`i`+cbext, -1,
+ Marble.images.append( load_image('marble-'+repr(i)+cbext, -1,
(marble_size, marble_size)))
Tile.plain_tiles = []
Tile.tunnels = []
for i in range(16):
tile = load_image('tile.png', (206,53,53), (tile_size,tile_size))
- path = load_image('path-'+`i`+'.png', -1, (tile_size,tile_size))
+ path = load_image('path-'+repr(i)+'.png', -1, (tile_size,tile_size))
tile.blit( path, (0,0))
Tile.plain_tiles.append( tile)
- Tile.tunnels.append(load_image('tunnel-'+`i`+'.png',
+ Tile.tunnels.append(load_image('tunnel-'+repr(i)+'.png',
-1,(tile_size,tile_size)))
Tile.paths = 0
@@ -295,12 +295,12 @@ def load_images():
Painter.images = []
for i in range(8):
- Painter.images.append( load_image('painter-'+`i`+cbext, -1,
+ Painter.images.append( load_image('painter-'+repr(i)+cbext, -1,
(tile_size,tile_size)))
Filter.images = []
for i in range(8):
- Filter.images.append( load_image('filter-'+`i`+cbext, -1,
+ Filter.images.append( load_image('filter-'+repr(i)+cbext, -1,
(tile_size,tile_size)))
Director.images = (
@@ -318,7 +318,7 @@ def load_images():
for j in range(4):
if i == j: Switch.images[i].append( None)
else: Switch.images[i].append( load_image(
- 'switch-'+`i`+`j`+'.png',-1,(tile_size,tile_size)))
+ 'switch-'+repr(i)+repr(j)+'.png',-1,(tile_size,tile_size)))
Replicator.image = load_image('replicator.png',-1,(tile_size,tile_size))
@@ -340,7 +340,7 @@ def load_images():
Board.launcher_v = load_image('launcher-v.png', None,
(marble_size, vert_tiles * tile_size + marble_size))
Board.launcher_corner = load_image('launcher-corner.png', (255,0,0),
- ((tile_size-marble_size)/2+marble_size,marble_size))
+ ((tile_size-marble_size)//2+marble_size,marble_size))
Board.launcher_entrance = load_image('entrance.png', -1,
(tile_size,marble_size))
@@ -414,7 +414,7 @@ class Tile:
def click(self, board, posx, posy, tile_x, tile_y): pass
def affect_marble(self, board, marble, rpos):
- if rpos == (tile_size/2,tile_size/2):
+ if rpos == (tile_size//2,tile_size//2):
if self.paths & (1 << marble.direction): return
# Figure out the new direction
@@ -442,8 +442,8 @@ class Wheel(Tile):
for i in range(4):
holecenter = holecenters[self.spinpos][i]
surface.blit( self.moving_holes[self.completed],
- (holecenter[0]-marble_size/2+self.rect.left,
- holecenter[1]-marble_size/2+self.rect.top))
+ (holecenter[0]-marble_size//2+self.rect.left,
+ holecenter[1]-marble_size//2+self.rect.top))
else:
surface.blit( self.images[self.completed], self.rect.topleft)
@@ -452,8 +452,8 @@ class Wheel(Tile):
if color >= 0:
holecenter = holecenters[self.spinpos][i]
surface.blit( Marble.images[color],
- (holecenter[0]-marble_size/2+self.rect.left,
- holecenter[1]-marble_size/2+self.rect.top))
+ (holecenter[0]-marble_size//2+self.rect.left,
+ holecenter[1]-marble_size//2+self.rect.top))
return 1
@@ -538,10 +538,10 @@ class Wheel(Tile):
def affect_marble(self, board, marble, rpos):
# Watch for marbles entering
- if rpos[0]+marble_size/2 == wheel_margin or \
- rpos[0]-marble_size/2 == tile_size - wheel_margin or \
- rpos[1]+marble_size/2 == wheel_margin or \
- rpos[1]-marble_size/2 == tile_size - wheel_margin:
+ if rpos[0]+marble_size//2 == wheel_margin or \
+ rpos[0]-marble_size//2 == tile_size - wheel_margin or \
+ rpos[1]+marble_size//2 == wheel_margin or \
+ rpos[1]-marble_size//2 == tile_size - wheel_margin:
if self.spinpos or self.marbles[marble.direction^2] >= -1:
# Reject the marble
marble.direction = marble.direction ^ 2
@@ -618,8 +618,8 @@ class Buffer(Tile):
if color >= 0:
holecenter = self.rect.center
surface.blit( Marble.images[color],
- (holecenter[0]-marble_size/2,
- holecenter[1]-marble_size/2))
+ (holecenter[0]-marble_size//2,
+ holecenter[1]-marble_size//2))
else:
surface.blit( self.bottom, self.rect.topleft)
@@ -633,10 +633,10 @@ class Buffer(Tile):
def affect_marble(self, board, marble, rpos):
# Watch for marbles entering
- if (rpos[0]+marble_size == tile_size/2 and marble.direction == 1) or \
- (rpos[0]-marble_size == tile_size/2 and marble.direction == 3) or \
- (rpos[1]+marble_size == tile_size/2 and marble.direction == 2) or \
- (rpos[1]-marble_size == tile_size/2 and marble.direction == 0):
+ if (rpos[0]+marble_size == tile_size//2 and marble.direction == 1) or \
+ (rpos[0]-marble_size == tile_size//2 and marble.direction == 3) or \
+ (rpos[1]+marble_size == tile_size//2 and marble.direction == 2) or \
+ (rpos[1]-marble_size == tile_size//2 and marble.direction == 0):
if self.entering is not None:
# Bump the marble that is currently entering
@@ -648,7 +648,7 @@ class Buffer(Tile):
# Let the base class affect the marble
Tile.affect_marble(self, board, newmarble,
- (tile_size/2,tile_size/2))
+ (tile_size//2,tile_size//2))
elif self.marble >= 0:
# Bump the marble that is currently caught
newmarble = Marble( self.marble, self.rect.center, marble.direction)
@@ -659,7 +659,7 @@ class Buffer(Tile):
# Let the base class affect the marble
Tile.affect_marble(self, board, newmarble,
- (tile_size/2,tile_size/2))
+ (tile_size//2,tile_size//2))
self.marble = -1
self.drawn = 0
@@ -667,7 +667,7 @@ class Buffer(Tile):
# Remember which marble is on its way in
self.entering = marble
- elif rpos == (tile_size/2, tile_size/2):
+ elif rpos == (tile_size//2, tile_size//2):
# Catch this marble
self.marble = marble.color
board.marbles.remove( marble)
@@ -686,7 +686,7 @@ class Painter(Tile):
def affect_marble(self, board, marble, rpos):
Tile.affect_marble( self, board, marble, rpos)
- if rpos == (tile_size/2, tile_size/2):
+ if rpos == (tile_size//2, tile_size//2):
if marble.color != self.color:
# Change the color
marble.color = self.color
@@ -703,7 +703,7 @@ class Filter(Tile):
return 0
def affect_marble(self, board, marble, rpos):
- if rpos == (tile_size/2, tile_size/2):
+ if rpos == (tile_size//2, tile_size//2):
# If the color is wrong, bounce the marble
if marble.color != self.color and marble.color != 8:
marble.direction = marble.direction ^ 2
@@ -723,7 +723,7 @@ class Director(Tile):
return 0
def affect_marble(self, board, marble, rpos):
- if rpos == (tile_size/2, tile_size/2):
+ if rpos == (tile_size//2, tile_size//2):
marble.direction = self.direction
play_sound( direct_marble)
@@ -737,7 +737,7 @@ class Shredder(Tile):
return 0
def affect_marble(self, board, marble, rpos):
- if rpos == (tile_size/2, tile_size/2):
+ if rpos == (tile_size//2, tile_size//2):
board.marbles.remove( marble)
play_sound( shredder)
@@ -764,7 +764,7 @@ class Switch(Tile):
return rc
def affect_marble(self, board, marble, rpos):
- if rpos == (tile_size/2, tile_size/2):
+ if rpos == (tile_size//2, tile_size//2):
marble.direction = self.curdir
self.switch()
@@ -800,7 +800,7 @@ class Replicator(Tile):
def affect_marble(self, board, marble, rpos):
Tile.affect_marble( self, board, marble, rpos)
- if rpos == (tile_size/2, tile_size/2):
+ if rpos == (tile_size//2, tile_size//2):
# Add the marble to the pending list
self.pending.append( [marble.color,marble.direction,
self.count - 1, replicator_delay]);
@@ -823,7 +823,7 @@ class Teleporter(Tile):
other.other = self
def affect_marble(self, board, marble, rpos):
- if rpos == (tile_size/2, tile_size/2):
+ if rpos == (tile_size//2, tile_size//2):
marble.rect.center = self.other.rect.center
play_sound( teleport)
@@ -857,8 +857,8 @@ class Trigger(Tile):
if self.marbles is not None:
for i in range(4):
surface.blit( Marble.images[self.marbles[i]],
- (holecenters[0][i][0]+self.rect.left-marble_size/2,
- holecenters[0][i][1]+self.rect.top-marble_size/2))
+ (holecenters[0][i][0]+self.rect.left-marble_size//2,
+ holecenters[0][i][1]+self.rect.top-marble_size//2))
return 1
def complete(self, board):
@@ -916,7 +916,7 @@ class Board:
# Create the board array
self.tiles = []
for j in range( vert_tiles):
- row = range( horiz_tiles)
+ row = list(range( horiz_tiles))
self.tiles.append( row)
# Load the level
@@ -928,21 +928,21 @@ class Board:
# Compute a hash of the current level, involving
# a static timestamp. This provides a consistent,
# backtrackable pseudo-random function.
- hash = md5.new(`game.gamestart`+"/"+`game.level`).digest()
+ hash = hashlib.md5((repr(game.gamestart)+"/"+repr(game.level)).encode()).digest()
hashval = (ord(hash[0]) + (ord(hash[1]) << 8) + \
(ord(hash[2]) << 16) + (ord(hash[3]) << 24)) & 32767;
self._load( game.circuit, hashval % game.numlevels);
# Create the launch timer text object
self.launch_timer_text = launch_timer_font.render(
- `self.launch_timer`, 1, (255,255,255))
+ repr(self.launch_timer), 1, (255,255,255))
self.launch_timer_text_rect = self.launch_timer_text.get_rect()
- self.launch_timer_text_rect.centerx = launch_timer_pos[0]+timer_width/2+1
+ self.launch_timer_text_rect.centerx = launch_timer_pos[0]+timer_width//2+1
self.launch_timer_text_rect.bottom = \
launch_timer_pos[1] + timer_height - timer_margin
# Fill up the launch queue
- for i in range( vert_tiles * tile_size / marble_size + 2):
+ for i in range( vert_tiles * tile_size // marble_size + 2):
self.launch_queue.append(random.choice(self.colors))
# Create The Background
@@ -964,11 +964,11 @@ class Board:
self.background.blit( self.launcher_entrance,
(board_pos[0]+tile_size*i, board_pos[1]-marble_size))
self.background.blit( self.launcher_corner,
- (board_pos[0]+horiz_tiles*tile_size-(tile_size-marble_size)/2,
+ (board_pos[0]+horiz_tiles*tile_size-(tile_size-marble_size)//2,
board_pos[1] - marble_size))
# Draw the board name
- board_name = `self.game.level+1` + " - " + self.name
+ board_name = repr(self.game.level+1) + " - " + self.name
if self.game.level >= self.game.numlevels:
board_name += " (Random)"
text = info_font.render( board_name, 1, (0,0,0))
@@ -1002,7 +1002,7 @@ class Board:
timer_width-timer_margin*2,height))
dirty_rects.append( rect)
else:
- height = timer_height*self.launch_timeout/self.launch_timeout_start
+ height = timer_height*self.launch_timeout//self.launch_timeout_start
if height < self.launch_timer_height:
rect = (launch_timer_pos[0] + timer_margin,
launch_timer_pos[1] + timer_height - self.launch_timer_height,
@@ -1021,15 +1021,15 @@ class Board:
dirty_rects.append( rect)
# Draw the score
- text = "Score: "+("00000000"+`self.game.score`)[-8:]
+ text = "Score: "+("00000000"+repr(self.game.score))[-8:]
text = info_font.render( text, 1, (0,0,0))
rect = text.get_rect()
rect.left = self.score_pos
self.screen.blit( text, rect)
# Draw the board timer
- time_remaining = (self.board_timeout+frames_per_sec-1)/frames_per_sec
- text = `time_remaining/60`+":"+("00"+`time_remaining%60`)[-2:]
+ time_remaining = (self.board_timeout+frames_per_sec-1)//frames_per_sec
+ text = repr(time_remaining//60)+":"+("00"+repr(time_remaining%60))[-2:]
text = info_font.render( text, 1, (0,0,0))
rect = text.get_rect()
rect.left = self.board_timer_pos
@@ -1039,7 +1039,7 @@ class Board:
right_edge = self.board_timer_pos - 32
for i in range(self.game.lives - 1):
rect = self.life_marble.get_rect()
- rect.centery = info_height / 2
+ rect.centery = info_height // 2
rect.right = right_edge
self.screen.blit( self.life_marble, rect)
right_edge -= rect.width + 4
@@ -1048,11 +1048,11 @@ class Board:
num_marbles = len(self.marbles)
if num_marbles > self.live_marbles_limit:
num_marbles = self.live_marbles_limit
- text = `num_marbles`+"/"+`self.live_marbles_limit`
+ text = repr(num_marbles)+"/"+repr(self.live_marbles_limit)
text = active_marbles_font.render( text, 1, (40,40,40))
rect = text.get_rect()
rect.left = self.pos[0] + 8
- rect.centery = self.pos[1] - marble_size / 2
+ rect.centery = self.pos[1] - marble_size // 2
rect.width += 100
self.screen.set_clip( rect)
self.screen.blit( self.background, (0,0))
@@ -1167,7 +1167,7 @@ class Board:
def set_launch_timer(self, passes):
self.launch_timer = passes
self.launch_timeout_start = (marble_size +
- (horiz_tiles * tile_size - marble_size) * passes) / marble_speed
+ (horiz_tiles * tile_size - marble_size) * passes) // marble_speed
self.launch_timer_height = None
def set_board_timer(self, seconds):
@@ -1178,8 +1178,8 @@ class Board:
def launch_marble(self):
self.launch_queue.append(random.choice(self.colors))
self.marbles.insert( 0, Marble( self.launch_queue[0],
- (self.pos[0]+tile_size*horiz_tiles+marble_size/2,
- self.pos[1]-marble_size/2), 3))
+ (self.pos[0]+tile_size*horiz_tiles+marble_size//2,
+ self.pos[1]-marble_size//2), 3))
del self.launch_queue[0]
self.launched = 1
@@ -1192,15 +1192,15 @@ class Board:
cy = c[1] - self.pos[1]
# Bounce marbles off of the top
- if cy == marble_size/2:
+ if cy == marble_size//2:
marble.direction = 2
return
if cy < 0:
- if cx == marble_size/2:
+ if cx == marble_size//2:
marble.direction = 1
return
- if cx == tile_size * horiz_tiles - marble_size/2 \
+ if cx == tile_size * horiz_tiles - marble_size//2 \
and marble.direction == 1:
marble.direction = 3
return
@@ -1209,11 +1209,11 @@ class Board:
effective_cx = cx
effective_cy = cy + marble_size
else:
- effective_cx = cx + marble_size/2 * dirs[marble.direction][0]
- effective_cy = cy + marble_size/2 * dirs[marble.direction][1]
+ effective_cx = cx + marble_size//2 * dirs[marble.direction][0]
+ effective_cy = cy + marble_size//2 * dirs[marble.direction][1]
- tile_x = effective_cx / tile_size
- tile_y = effective_cy / tile_size
+ tile_x = effective_cx // tile_size
+ tile_y = effective_cy // tile_size
tile_xr = cx - tile_x * tile_size
tile_yr = cy - tile_y * tile_size
@@ -1223,7 +1223,7 @@ class Board:
if cy < 0 and marble.direction != 2:
# The special case of new marbles at the top
- if tile_xr == tile_size / 2 and (tile.paths & 1):
+ if tile_xr == tile_size // 2 and (tile.paths & 1):
if isinstance( tile, Wheel):
if tile.spinpos > 0 or tile.marbles[0] != -3: return
tile.marbles[0] = -2
@@ -1237,8 +1237,8 @@ class Board:
def click(self, pos):
# Determine which tile the pointer is in
- tile_x = (pos[0] - self.pos[0]) / tile_size
- tile_y = (pos[1] - self.pos[1]) / tile_size
+ tile_x = (pos[0] - self.pos[0]) // tile_size
+ tile_y = (pos[1] - self.pos[1]) // tile_size
tile_xr = pos[0] - self.pos[0] - tile_x * tile_size
tile_yr = pos[1] - self.pos[1] - tile_y * tile_size
if tile_x >= 0 and tile_x < horiz_tiles and \
@@ -1397,10 +1397,10 @@ class Board:
# Handle Input Events
for event in pygame.event.get():
- if event.type is QUIT:
+ if event.type == QUIT:
return -4
- elif event.type is KEYDOWN:
- if event.key is K_ESCAPE: return -3
+ elif event.type == KEYDOWN:
+ if event.key == K_ESCAPE: return -3
elif event.key == ord('n'): return 2
elif event.key == ord('b'): return 3
elif event.key == ord(' ') or \
@@ -1421,7 +1421,7 @@ class Board:
elif event.key == K_F4:
toggle_sound()
- elif event.type is MOUSEBUTTONDOWN:
+ elif event.type == MOUSEBUTTONDOWN:
if self.paused:
self.paused = 0
popdown( pause_popup)
@@ -1491,16 +1491,16 @@ class HighScores:
except:
try:
f = os.popen(write_highscores, "w")
- except OSError, message:
- print "Warning: Can't save highscores:", message
+ except OSError as message:
+ print("Warning: Can't save highscores:", message)
return
try:
for i in self.scores:
- f.write( `i[0]`+' '+i[1]+' '+`i[2]`+' '+i[3]+'\n')
+ f.write( repr(i[0])+' '+i[1]+' '+repr(i[2])+' '+i[3]+'\n')
f.close()
except:
- print "Warning: Problem saving highscores."
+ print("Warning: Problem saving highscores.")
def wait_one_sec():
time.sleep(1)
@@ -1580,7 +1580,7 @@ class Game:
if line == '': break
if line[0] == '|': j += 1
f.close()
- self.numlevels = j / vert_tiles
+ self.numlevels = j // vert_tiles
self.level = level
self.score = 0
@@ -1593,7 +1593,7 @@ class Game:
self.score += amount
# Award any extra lives that are due
- extra_lives = amount / extra_life_frequency + \
+ extra_lives = amount // extra_life_frequency + \
(self.score % extra_life_frequency < amount % extra_life_frequency)
extra_lives = min( extra_lives, max_spare_lives+1 - self.lives)
if extra_lives > 0:
@@ -1653,7 +1653,7 @@ class Game:
"You have a highscore!\n"+
"Please enter your name:", (300, 180))
name = get_name( self.screen, popup_font,
- ((screen_width-250)/2,310,250,popup_font.get_height()),
+ ((screen_width-250)//2,310,250,popup_font.get_height()),
(255,255,255), (0,0,0))
if name is None: return -1
@@ -1672,7 +1672,7 @@ class Game:
# The board was completed
# Compute time remaining bonus
- time_remaining = 100 * board.board_timeout / \
+ time_remaining = 100 * board.board_timeout // \
board.board_timeout_start
time_bonus = 5 * time_remaining
@@ -1685,16 +1685,16 @@ class Game:
total_holes += 4
for i in tile.marbles:
if i < 0: empty_holes += 1
- empty_holes = (100 * empty_holes + total_holes/2) / total_holes
+ empty_holes = (100 * empty_holes + total_holes//2) // total_holes
holes_bonus = 2 * empty_holes
self.increase_score( time_bonus + holes_bonus)
message = 'Level Complete!\n'+ \
- "Bonus for " + `time_remaining` + "% time remaining: " + \
- `time_bonus` + "\n" + \
- "Bonus for " + `empty_holes` + "% holes empty: " + \
- `holes_bonus` + '\nClick to continue.'
+ "Bonus for " + repr(time_remaining) + "% time remaining: " + \
+ repr(time_bonus) + "\n" + \
+ "Bonus for " + repr(empty_holes) + "% holes empty: " + \
+ repr(holes_bonus) + '\nClick to continue.'
rc = self.board_dialog( message, 1, 1)
self.level += 1
@@ -1715,9 +1715,9 @@ class Game:
while 1:
pygame.time.wait(20)
for event in pygame.event.get():
- if event.type is QUIT:
+ if event.type == QUIT:
return -2
- elif event.type is KEYDOWN:
+ elif event.type == KEYDOWN:
if event.key == K_ESCAPE: return -1
if event.key == ord('b'):
if self.level > 0: self.level -= 1
@@ -1746,7 +1746,7 @@ class Game:
event.key == K_RCTRL:
continue
return 1
- elif event.type is MOUSEBUTTONDOWN:
+ elif event.type == MOUSEBUTTONDOWN:
return 1
def translate_key( key, shift_state):
@@ -1776,7 +1776,7 @@ def translate_key( key, shift_state):
return key
def get_name( screen, font, cursor_box, backcol, forecol):
- cursor_width = cursor_box[3] / 3
+ cursor_width = cursor_box[3] // 3
cursor_pos = [cursor_box[0], cursor_box[1], cursor_width, cursor_box[3]]
name = ""
@@ -1801,14 +1801,14 @@ def get_name( screen, font, cursor_box, backcol, forecol):
pygame.time.wait(20)
for event in pygame.event.get():
- if event.type is QUIT:
+ if event.type == QUIT:
return None
- elif event.type is KEYUP:
+ elif event.type == KEYUP:
if event.key == K_LSHIFT:
shift_state &= ~KMOD_LSHIFT
elif event.key == K_RSHIFT:
shift_state &= ~KMOD_RSHIFT
- elif event.type is KEYDOWN:
+ elif event.type == KEYDOWN:
if event.key == K_LSHIFT:
shift_state |= KMOD_LSHIFT
elif event.key == K_RSHIFT:
@@ -1835,7 +1835,7 @@ class IntroScreen:
"Sound Effects:", "Quit Game")
start_level = 1
menu_width = 240
- menu_pos = ((800 - menu_width)/2, 145)
+ menu_pos = ((800 - menu_width)//2, 145)
menu_font_height = 32
menu_color = (255,255,255)
menu_cursor_color = (60,60,60)
@@ -2014,12 +2014,12 @@ class IntroScreen:
pygame.time.wait(20)
for event in pygame.event.get():
- if event.type is QUIT:
+ if event.type == QUIT:
if self.curpage == 1:
self.go_to_main_menu()
continue
return -2
- elif event.type is KEYDOWN:
+ elif event.type == KEYDOWN:
if event.key == K_F2:
play_sound( menu_select)
if not toggle_fullscreen(): return -3
@@ -2060,7 +2060,7 @@ class IntroScreen:
self.inc_level()
self.draw_menu()
continue
- elif event.type is MOUSEBUTTONDOWN:
+ elif event.type == MOUSEBUTTONDOWN:
if self.curpage == 1:
self.go_to_main_menu()
continue
@@ -2072,7 +2072,7 @@ class IntroScreen:
if pos[0] < self.menu_pos[0]: continue
if pos[0] >= self.menu_pos[0] + self.menu_width: continue
if pos[1] < self.menu_pos[1]: continue
- i = (pos[1] - self.menu_pos[1]) / self.menu_font_height
+ i = (pos[1] - self.menu_pos[1]) // self.menu_font_height
if i >= len(self.menu): continue
rc = self.menu_select( i)
if rc: return rc
@@ -2108,7 +2108,7 @@ class IntroScreen:
hs_font_height = 24
hs_width = 320
- hs_pos = ((800-hs_width)/2, 114)
+ hs_pos = ((800-hs_width)//2, 114)
hs_margin = 8
hs_column_margin = 70
hs_score_width = 70
@@ -2162,7 +2162,7 @@ class IntroScreen:
numcolor = color = self.hs_current_color
y += self.hs_font_height
- number = self.hs_font.render(`j+1`+'.',1,numcolor)
+ number = self.hs_font.render(repr(j+1)+'.',1,numcolor)
self.screen.blit( number,
(x + number_width - number.get_size()[0], y))
if i[3] != '':
@@ -2170,9 +2170,9 @@ class IntroScreen:
if name.get_width() > name_width:
name = name.subsurface( (0,0,name_width,name.get_height()))
self.screen.blit( name, (x + name_left, y))
- level = self.hs_font.render( `i[2]`, 1, color)
+ level = self.hs_font.render( repr(i[2]), 1, color)
self.screen.blit( level, (x + level_right - level.get_width(), y))
- score = self.hs_font.render( `i[0]`, 1, color)
+ score = self.hs_font.render( repr(i[0]), 1, color)
self.screen.blit( score, (x + score_right - score.get_width(), y))
self.dirty_rects.append( self.hs_rect)
@@ -2190,14 +2190,14 @@ def setup_everything():
try:
pygame.mixer.init()
except:
- print "error on pygame.mixer.init() inside setup_everything():"
- print sys.exc_info()[0],":",sys.exc_info()[1]
- print "...ignoring it"
+ print("error on pygame.mixer.init() inside setup_everything():")
+ print(sys.exc_info()[0],":",sys.exc_info()[1])
+ print("...ignoring it")
pygame.font.init()
pygame.key.set_repeat(500, 30)
- if not pygame.font: print 'Warning, fonts disabled'
- if not pygame.mixer: print 'Warning, sound disabled'
+ if not pygame.font: print('Warning, fonts disabled')
+ if not pygame.mixer: print('Warning, sound disabled')
set_video_mode()
load_sounds()
--
2.45.2
From abc9874de98bd26dc211597730c40724f9a70ba6 Mon Sep 17 00:00:00 2001
From: Begasus <begasus@gmail.com>
Date: Sat, 29 Apr 2023 12:53:17 +0200
Subject: Fix installation paths
diff --git a/Makefile b/Makefile
index 432353b..1ab6afd 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,15 @@
DESTDIR =
+BINDIR= $(DESTDIR)/usr/games/pathological
+
DATADIR = $(DESTDIR)/usr/share/games/pathological
+DOCDIR = $(DESTDIR)/usr/share/doc/pathological
+
+LIBDIR = $(DESTDIR)/usr/lib/games
+
+MANDIR = $(DESTDIR)/usr/share/man
+
all: write-highscores docs
write-highscores: write-highscores.c
@@ -21,20 +29,20 @@ install-indep:
rm -f $(DATADIR)/graphics/*.xcf
rm -f $(DATADIR)/sounds/*.orig
- install -D -m 755 pathological $(DESTDIR)/usr/games/pathological
+ install -D -m 755 pathological $(BINDIR)
zcat pathological.6.gz > pathological.6
- install -D -m 644 pathological.6 $(DESTDIR)/usr/share/man/man6/pathological.6
+ install -D -m 644 pathological.6 $(MANDIR)/man6/pathological.6
- install -d $(DESTDIR)/usr/share/doc/pathological
- cp -r html $(DESTDIR)/usr/share/doc/pathological
+ install -d $(DOCDIR)
+ cp -r html $(DOCDIR)
install -D -m 644 pathological.xpm $(DESTDIR)/usr/share/pixmaps/pathological.xpm
# Install architecture-dependent data
install-dep:
install -d $(DESTDIR)/var/games
- install -D -m 2755 --owner=root --group=games write-highscores $(DESTDIR)/usr/lib/games/pathological/bin/write-highscores
+ install -D -m 2755 write-highscores $(LIBDIR)/pathological/bin/write-highscores
# Install the scores file, if it doesn't already exist.
install-scores:
--
2.45.2
From 2eec49ff43325ebfd487e19167d321b960e906c1 Mon Sep 17 00:00:00 2001
From: Oscar Lesta <oscar.lesta@gmail.com>
Date: Wed, 19 Feb 2025 20:54:20 -0300
Subject: Fix app startup from Tracker/Deskbar.
Pathological expects to start on its data directory.
This patch should allow for that to work OK on both system-wide
and "home" .hpkg installs.
diff --git a/pathological.py b/pathological.py
index 6ac07ff..f3803c9 100755
--- a/pathological.py
+++ b/pathological.py
@@ -2206,6 +2206,22 @@ def setup_everything():
introscreen = IntroScreen( screen, highscores)
+# Pathological needs to start on its data directory.
+# Find out where we're installed, and chdir() to it:
+dataDirs = [
+ '/boot/home/config/data/pathological',
+ '/system/data/pathological',
+]
+couldChDir=False
+for dir in dataDirs:
+ if os.path.exists(dir):
+ os.chdir(dir)
+ couldChDir=True
+ break
+
+if not couldChDir:
+ exit("Could not chdir() into Pathological's data directory.")
+
# Load the highscores file
highscores = HighScores( highscores_file)
--
2.45.2