Add various fixes to frozen-bubble:

- allow building with base-clang (from gkoehler@, thanks!)
- remove BROKEN-{amd64,i386} after gkoehler@'s p5-SDL fix
- replace various use of my() in false conditionals, it's fatal
  with Perl 5.30
- deinterlace some PNGs to silence some libpng warnings

OK gkoehler@ afresh1@ (who tested on sparc64 and i386)
This commit is contained in:
cwen 2020-02-04 22:54:09 +00:00
parent be83b26049
commit c1017865d4
4 changed files with 225 additions and 2 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.28 2019/07/17 14:49:22 danj Exp $
# $OpenBSD: Makefile,v 1.29 2020/02/04 22:54:09 cwen Exp $
COMMENT-main = bubble popping game, like puzzle bobble
COMMENT-server = server for the frozen-bubble bubble popping game
@ -6,7 +6,7 @@ COMMENT-server = server for the frozen-bubble bubble popping game
VER = 2.2.0
DISTNAME = frozen-bubble-${VER}
PKGNAME-main = ${DISTNAME}
REVISION-main = 14
REVISION-main = 15
PKGNAME-server = frozen-bubble-server-${VER}
REVISION-server = 10
CATEGORIES = games
@ -29,6 +29,9 @@ BUILD_DEPENDS = devel/p5-SDL \
devel/p5-Locale-gettext \
devel/gettext,-tools
# Needed for post-patch deinterlacing
BUILD_DEPENDS += graphics/ImageMagick
RUN_DEPENDS-main = devel/p5-SDL \
devel/p5-Locale-gettext \
${BASE_PKGPATH},-server
@ -47,4 +50,13 @@ WANTLIB-server = c glib-2.0 intl pthread
MULTI_PACKAGES = -main -server
# fix "Interlace handling should be turned on when using png_read_image"
post-patch:
@cd ${WRKSRC} && for interlaced in gfx/flags/flag-de.png \
gfx/flags/flag-fi.png \
gfx/flags/flag-no.png; \
do \
${LOCALBASE}/bin/mogrify -interlace none $${interlaced} ;\
done
.include <bsd.port.mk>

View File

@ -0,0 +1,125 @@
$OpenBSD: patch-c_stuff_fb_c_stuff_xs,v 1.1 2020/02/04 22:54:09 cwen Exp $
Fix build with clang: it errors when functions are inside other
functions. Rename sqr(int) to prevent conflict with sqr(float).
Index: c_stuff/fb_c_stuff.xs
--- c_stuff/fb_c_stuff.xs.orig
+++ c_stuff/fb_c_stuff.xs
@@ -94,17 +94,17 @@ int rand_(double val) { return 1+(int) (val*rand()/(RA
/* -------------- Double Store ------------------ */
+static void copy_line(int l, SDL_Surface * s, SDL_Surface * img) {
+ memcpy(s->pixels + l*img->pitch, img->pixels + l*img->pitch, img->pitch);
+}
+static void copy_column(int c, SDL_Surface * s, SDL_Surface * img) {
+ int bpp = img->format->BytesPerPixel;
+ for (y=0; y<YRES; y++)
+ memcpy(s->pixels + y*img->pitch + c*bpp, img->pixels + y*img->pitch + c*bpp, bpp);
+}
+
void store_effect(SDL_Surface * s, SDL_Surface * img)
{
- void copy_line(int l) {
- memcpy(s->pixels + l*img->pitch, img->pixels + l*img->pitch, img->pitch);
- }
- void copy_column(int c) {
- int bpp = img->format->BytesPerPixel;
- for (y=0; y<YRES; y++)
- memcpy(s->pixels + y*img->pitch + c*bpp, img->pixels + y*img->pitch + c*bpp, bpp);
- }
-
int step = 0;
int store_thickness = 15;
@@ -116,8 +116,8 @@ void store_effect(SDL_Surface * s, SDL_Surface * img)
for (i=0; i<=YRES/2/store_thickness; i++) {
int v = step - i;
if (v >= 0 && v < store_thickness) {
- copy_line(i*store_thickness + v);
- copy_line(YRES - 1 - (i*store_thickness + v));
+ copy_line(i*store_thickness + v, s, img);
+ copy_line(YRES - 1 - (i*store_thickness + v), s, img);
}
}
step++;
@@ -133,8 +133,8 @@ void store_effect(SDL_Surface * s, SDL_Surface * img)
for (i=0; i<=XRES/2/store_thickness; i++) {
int v = step - i;
if (v >= 0 && v < store_thickness) {
- copy_column(i*store_thickness + v);
- copy_column(XRES - 1 - (i*store_thickness + v));
+ copy_column(i*store_thickness + v, s, img);
+ copy_column(XRES - 1 - (i*store_thickness + v), s, img);
}
}
step++;
@@ -176,21 +176,22 @@ void bars_effect(SDL_Surface * s, SDL_Surface * img)
/* -------------- Squares ------------------ */
+static const int squares_size = 32;
+
+static int fillrect(int i, int j, SDL_Surface * s, SDL_Surface * img, int bpp) {
+ int c, v;
+ if (i >= XRES/squares_size || j >= YRES/squares_size)
+ return 0;
+ v = i*squares_size*bpp + j*squares_size*img->pitch;
+ for (c=0; c<squares_size; c++)
+ memcpy(s->pixels + v + c*img->pitch, img->pixels + v + c*img->pitch, squares_size*bpp);
+ return 1;
+}
+
void squares_effect(SDL_Surface * s, SDL_Surface * img)
{
int bpp = img->format->BytesPerPixel;
- const int squares_size = 32;
- int fillrect(int i, int j) {
- int c, v;
- if (i >= XRES/squares_size || j >= YRES/squares_size)
- return 0;
- v = i*squares_size*bpp + j*squares_size*img->pitch;
- for (c=0; c<squares_size; c++)
- memcpy(s->pixels + v + c*img->pitch, img->pixels + v + c*img->pitch, squares_size*bpp);
- return 1;
- }
-
int still_moving = 1;
for (i=0; still_moving; i++) {
@@ -200,7 +201,7 @@ void squares_effect(SDL_Surface * s, SDL_Surface * img
still_moving = 0;
for (j=i; j>=0; j--) {
- if (fillrect(j, k))
+ if (fillrect(j, k, s, img, bpp))
still_moving = 1;
k++;
}
@@ -212,20 +213,20 @@ void squares_effect(SDL_Surface * s, SDL_Surface * img
/* -------------- Circle ------------------ */
+static int sqi(int v) { return v*v; }
+
int * circle_steps;
const int circle_max_steps = 40;
void circle_init(void)
{
- int sqr(int v) { return v*v; }
-
circle_steps = malloc(XRES * YRES * sizeof(int));
if (!circle_steps)
fb__out_of_memory();
for (y=0; y<YRES; y++)
for (x=0; x<XRES; x++) {
- int max = sqrt(sqr(XRES/2) + sqr(YRES/2));
- int value = sqrt(sqr(x-XRES/2) + sqr(y-YRES/2));
+ int max = sqrt(sqi(XRES/2) + sqi(YRES/2));
+ int value = sqrt(sqi(x-XRES/2) + sqi(y-YRES/2));
circle_steps[x+y*XRES] = (max-value)*circle_max_steps/max;
}
}

View File

@ -0,0 +1,34 @@
$OpenBSD: patch-c_stuff_lib_FBLE_pm,v 1.1 2020/02/04 22:54:09 cwen Exp $
Perl 5.30+ prohibits using my() in false conditionals
Index: c_stuff/lib/FBLE.pm
--- c_stuff/lib/FBLE.pm.orig
+++ c_stuff/lib/FBLE.pm
@@ -31,6 +31,8 @@
package FBLE;
+use feature qw(state);
+
use POSIX(qw(floor ceil));
use SDL;
use SDL::App;
@@ -1405,7 +1407,7 @@ sub display_levelset_screenshot {
$rect{middle}->y + $rect{middle}->height/2 - $rect{screenshot}->height/8 - 3 + $widgetMove);
- my %shrinks if 0;
+ state %shrinks;
my $current_nb = $start_level || 1;
if (!exists $shrinks{$name}{$current_nb}) {
my $surf = SDL::Surface->new(-name => "$FPATH/gfx/menu/please_wait.png");
@@ -1417,7 +1419,7 @@ sub display_levelset_screenshot {
$app->update($rect{middle});
#- sorta "read ahead": will compute next 10 levels screenshots as well
- my $s_save if 0;
+ state $s_save;
if (!$s_save) {
$s_save = SDL::Surface->new(-name => "$FPATH/gfx/level_editor.png");
}

View File

@ -0,0 +1,52 @@
$OpenBSD: patch-frozen-bubble,v 1.1 2020/02/04 22:54:09 cwen Exp $
Perl 5.30+ prohibits using my() in false conditionals
Index: frozen-bubble
--- frozen-bubble.orig
+++ frozen-bubble
@@ -47,6 +47,8 @@ use vars qw($TARGET_ANIM_SPEED $BUBBLE_SIZE $ROW_SIZE
$lev_number $playermalus $mptrainingdiff $loaded_levelset $direct_levelset $chainreaction %chains %img_mini $frame $sock $gameserver $mynick
$continuegamewhenplayersleave $singleplayertargetting $mylatitude $mylongitude %autokick $replayparam $autorecord $comment $saveframes $saveframesbase $saveframescounter);
+use feature qw(state);
+
use Getopt::Long;
use Data::Dumper;
use Locale::gettext;
@@ -269,7 +271,7 @@ sub play_music($) {
$app->delay(400);
$app->delay(10) while $mixer->playing_music; #- mikmod will segfault if we try to load a music while old one is still fading out
my %musics = (intro => '/snd/introzik.ogg', main1p => '/snd/frozen-mainzik-1p.ogg', main2p => '/snd/frozen-mainzik-2p.xm');
- my $mus if 0; #- I need to keep a reference on the music or it will be collected at the end of this function, thus I manually collect previous music
+ state $mus; #- I need to keep a reference on the music or it will be collected at the end of this function, thus I manually collect previous music
if (@playlist) {
my $tryanother = sub {
my $elem = chomp_(shift @playlist);
@@ -3488,7 +3490,7 @@ sub choose_1p_game_mode() {
};
my $img = $imgbin{'1p_panel'};
- my $save if 0;
+ state $save;
my $drect = SDL::Rect->new(-width => $img->width, -height => $img->height,
-x => $MENUPOS{xpos_panel}, '-y' => $MENUPOS{ypos_panel});
if ($save) {
@@ -5573,7 +5575,7 @@ sub menu {
'highscores' => { pos => 8, type => 'run',
run => sub { $menu_display_highscores->() } },
);
- my $current_pos if 0; $current_pos ||= 1;
+ state $current_pos; $current_pos ||= 1;
my @menu_invalids;
$invalidate_all = sub { push @menu_invalids, $menu_entries{$_}->{pos} foreach keys %menu_entries };
@@ -5724,7 +5726,7 @@ sub menu {
}
if ($graphics_level > 1) {
- my $banner_pos if 0;
+ state $banner_pos;
$banner_pos ||= 670;
foreach my $b (keys %banners) {
my $xpos = $banners{$b} - $banner_pos;