From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Dieter Deyke Newsgroups: gmane.emacs.devel Subject: [ELPA] Patches for sokoban 1.4 Date: Sat, 27 May 2017 12:58:18 +0200 Message-ID: <87bmqek1md.fsf@deyke2> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1495883793 9717 195.159.176.226 (27 May 2017 11:16:33 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 27 May 2017 11:16:33 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat May 27 13:16:28 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dEZhr-0002Ks-Pf for ged-emacs-devel@m.gmane.org; Sat, 27 May 2017 13:16:27 +0200 Original-Received: from localhost ([::1]:40269 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dEZhx-0006w5-78 for ged-emacs-devel@m.gmane.org; Sat, 27 May 2017 07:16:33 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dEZQR-0004hR-G1 for emacs-devel@gnu.org; Sat, 27 May 2017 06:58:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dEZQO-0007fc-AF for emacs-devel@gnu.org; Sat, 27 May 2017 06:58:27 -0400 Original-Received: from mail-wr0-x232.google.com ([2a00:1450:400c:c0c::232]:35062) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dEZQN-0007fO-WF for emacs-devel@gnu.org; Sat, 27 May 2017 06:58:24 -0400 Original-Received: by mail-wr0-x232.google.com with SMTP id z52so13262395wrc.2 for ; Sat, 27 May 2017 03:58:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:user-agent:mime-version; bh=VDHnUe54GXpaOMtfdaFCUHW9zaI1CUzTpYmfHXICQFM=; b=rC/mkyx0JGl64Cb8iRajzPjCEpOh04/naGUTfsF5iOpcm9edI/VIxnjFtsgrl5VnuL cE+ukgWLpxuQnCe4cIw+feoRpFSG0lIxbTLl/Savxq80mc75EDMYkZikgdFPFDDGo+gO gkNic1UmR2X2w0JsZVDZsMXpVQyD+xf1aKCDjCVvQlBL3t5I98TqR067HyvAXVZX3rJN hg/IzuutX4jxgVHzBII8HI8Drf5IuGg9X1+tOHKWkph6XzeR8Hfl6a7JmLbyVlFS7Asz Q+rOp/En+iMo6jqG01IQVx/IgoJsS3jfEcCEK0r0yzw714XcAY1sAOtNI3BT7/APEKTY B03w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version; bh=VDHnUe54GXpaOMtfdaFCUHW9zaI1CUzTpYmfHXICQFM=; b=kYktn5x0ZiA1rXRN1yQnwTL340BKb53glIMBrM0/c6rQBnz+8qHV2m+5rYDemuhvj1 dkMD413kPffU6PwvQ2J4VpPzTMS4nUr54vA47eRC5glLBk49jxvDYDqm0nkb0oFmY/7D kUplsoQx2vCvFI0Fr03UGO/Fs9Es3J0HoiiUCNKHADx5LuA7gHxbOdEsLdwPtKuqCm4d Z+aiUDKksVbuuaAO3cAZ9oXgf+vcQk0bFGA1kJwVO1zx0+z/lCgttXjk3mSr0/tQByfr 8h/5Wt1jhki2RB8vGBDqnPZYJrgb9oW8NfywImg99yEy6l0ftRUlQ3gjV0HGxuyLiwcR jWfw== X-Gm-Message-State: AODbwcBQmOppxktNq5vJ/vsdYxkaPq+1YHuVfkAZskvipDU8BuhUbIs1 8FpDTQ2pDE/426qN X-Received: by 10.223.176.194 with SMTP id j2mr4356052wra.81.1495882702318; Sat, 27 May 2017 03:58:22 -0700 (PDT) Original-Received: from deyke2.fritz.box (p5B12DAB1.dip0.t-ipconnect.de. [91.18.218.177]) by smtp.gmail.com with ESMTPSA id y6sm3824424wrc.51.2017.05.27.03.58.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 27 May 2017 03:58:21 -0700 (PDT) Original-Received: from [127.0.0.1] (helo=deyke2.localdomain) by deyke2 with esmtp (Exim 4.89) (envelope-from ) id 1dEZQI-00063q-Ue for emacs-devel@gnu.org; Sat, 27 May 2017 12:58:19 +0200 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::232 X-Mailman-Approved-At: Sat, 27 May 2017 07:15:54 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:215262 Archived-At: --=-=-= Content-Type: text/plain Hi, while I was playing sokoban from ELPA, I had the need for some local patches: 1) fix off-by-1 error in sokoban-draw-score which caused on-screen score to be truncated 2) save sokoban-level when a level is completed, restore sokoban-level when a game is started This allowed me to continue the game on the next day without me having to remember what level I was on. Eventually I finished all levels and looked on the net for new level files. Having found some required: 3) allow for levels which are wider and higher, and for levels where the player character would already be on a target field at start These 3 patches are attached to this mail. If they are useful, someone could apply them to ELPA. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-fix-off-by-1-error-in-sokoban-draw-score-which-cause.patch >From 96ca5427cd2b950008a55bb5586702d40f5c078e Mon Sep 17 00:00:00 2001 From: Dieter Deyke Date: Thu, 25 May 2017 13:27:08 +0200 Subject: [PATCH] fix off-by-1 error in sokoban-draw-score which caused on-screen score to be truncated --- packages/sokoban/sokoban.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/sokoban/sokoban.el b/packages/sokoban/sokoban.el index 6e8bee25c..ae6f845cf 100644 --- a/packages/sokoban/sokoban.el +++ b/packages/sokoban/sokoban.el @@ -1,9 +1,9 @@ ;;; sokoban.el --- Implementation of Sokoban for Emacs. -;; Copyright (C) 1998, 2013 Free Software Foundation, Inc. +;; Copyright (C) 1998, 2013, 2017 Free Software Foundation, Inc. ;; Author: Glynn Clements -;; Version: 1.4 +;; Version: 1.4.1 ;; Created: 1997-09-11 ;; Keywords: games ;; Package-Type: multi @@ -41,6 +41,8 @@ ;; Modified: 1998-06-04, added `undo' feature ;; added number of blocks done/total to score and modeline ;; Modified: 2003-06-14, update email address, remove URL +;; Modified: 2017-05-25, fix off-by-1 error in sokoban-draw-score which +;; caused on-screen score to be truncated ;; Tested with XEmacs 20.3/4/5 and Emacs 19.34 @@ -517,7 +519,7 @@ static char * player_xpm[] = { (format "Done: %d/%d" sokoban-done sokoban-targets)))) - (dotimes (y 2) + (dotimes (y 3) (let* ((string (aref strings y)) (len (length string))) (dotimes (x len) -- 2.11.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-save-sokoban-level-when-a-level-is-completed-restore.patch >From 4caa9c202fd67fdd3e31448dfd47973efafcaa66 Mon Sep 17 00:00:00 2001 From: Dieter Deyke Date: Sat, 27 May 2017 10:45:38 +0200 Subject: [PATCH] save sokoban-level when a level is completed, restore sokoban-level when game is started --- packages/sokoban/sokoban.el | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/sokoban/sokoban.el b/packages/sokoban/sokoban.el index ae6f845cf..3575d2818 100644 --- a/packages/sokoban/sokoban.el +++ b/packages/sokoban/sokoban.el @@ -3,7 +3,7 @@ ;; Copyright (C) 1998, 2013, 2017 Free Software Foundation, Inc. ;; Author: Glynn Clements -;; Version: 1.4.1 +;; Version: 1.4.2 ;; Created: 1997-09-11 ;; Keywords: games ;; Package-Type: multi @@ -43,6 +43,8 @@ ;; Modified: 2003-06-14, update email address, remove URL ;; Modified: 2017-05-25, fix off-by-1 error in sokoban-draw-score which ;; caused on-screen score to be truncated +;; Modified: 2017-05-27, save sokoban-level when a level is completed, +;; restore sokoban-level when game is started ;; Tested with XEmacs 20.3/4/5 and Emacs 19.34 @@ -96,6 +98,8 @@ (defvar sokoban-level-data nil) +(defconst sokoban-state-filename (locate-user-emacs-file "sokoban-state")) + ;; ;;;;;;;;;;;;; constants ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defconst sokoban-floor-xpm "\ @@ -616,6 +620,9 @@ static char * player_xpm[] = { (incf sokoban-done)) (sokoban-add-push dx dy) (cond ((= sokoban-done sokoban-targets) + (let ((level sokoban-level)) + (with-temp-file sokoban-state-filename + (print level (current-buffer)))) (sit-for 3) (sokoban-next-level)))))))))) @@ -774,7 +781,14 @@ sokoban-mode keybindings: (switch-to-buffer sokoban-buffer-name) (gamegrid-kill-timer) (sokoban-mode) - (sokoban-start-game)) + (setq sokoban-level 0) + (if (file-exists-p sokoban-state-filename) + (setq sokoban-level + (with-temp-buffer + (insert-file-contents sokoban-state-filename) + (goto-char (point-min)) + (read (current-buffer))))) + (sokoban-next-level)) ;;;###autoload (unless (featurep 'xemacs) -- 2.11.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0003-allow-for-player-to-start-on-a-target-allow-for-wide.patch >From ab2c9cfaed47c56ed213e1efbbde6fe9bae5a86e Mon Sep 17 00:00:00 2001 From: Dieter Deyke Date: Sat, 27 May 2017 12:43:34 +0200 Subject: [PATCH] allow for player to start on a target, allow for wider and higher levels --- packages/sokoban/sokoban.el | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/sokoban/sokoban.el b/packages/sokoban/sokoban.el index 3575d2818..d59de952c 100644 --- a/packages/sokoban/sokoban.el +++ b/packages/sokoban/sokoban.el @@ -3,7 +3,7 @@ ;; Copyright (C) 1998, 2013, 2017 Free Software Foundation, Inc. ;; Author: Glynn Clements -;; Version: 1.4.2 +;; Version: 1.4.3 ;; Created: 1997-09-11 ;; Keywords: games ;; Package-Type: multi @@ -45,6 +45,8 @@ ;; caused on-screen score to be truncated ;; Modified: 2017-05-27, save sokoban-level when a level is completed, ;; restore sokoban-level when game is started +;; Modified: 2017-05-27, allow for player to start on a target, +;; allow for wider and higher levels ;; Tested with XEmacs 20.3/4/5 and Emacs 19.34 @@ -87,14 +89,14 @@ (and (file-exists-p file) file)) (expand-file-name "sokoban.levels" data-directory)))) -(defvar sokoban-width 20) -(defvar sokoban-height 16) +(defvar sokoban-width 27) +(defvar sokoban-height 20) -(defvar sokoban-buffer-width 20) -(defvar sokoban-buffer-height 20) +(defvar sokoban-buffer-width sokoban-width) +(defvar sokoban-buffer-height (+ 4 sokoban-height)) (defvar sokoban-score-x 0) -(defvar sokoban-score-y 17) +(defvar sokoban-score-y (+ 1 sokoban-height)) (defvar sokoban-level-data nil) @@ -309,13 +311,14 @@ static char * player_xpm[] = { }; ") -(defconst sokoban-floor ?\+) +(defconst sokoban-floor ?\&) ;; note - space character in level file is also allowed to indicate floor (defconst sokoban-target ?\.) (defconst sokoban-wall ?\#) (defconst sokoban-block ?\$) (defconst sokoban-player ?\@) (defconst sokoban-block-on-target ?\*) +(defconst sokoban-player-on-target ?\+) ;; ;;;;;;;;;;;;; display options ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -488,7 +491,8 @@ static char * player_xpm[] = { (dotimes (x sokoban-width) (let ((c (aref (aref sokoban-level-map y) x))) (cond - ((= c sokoban-target) + ((or (= c sokoban-target) + (= c sokoban-player-on-target)) (incf sokoban-targets)) ((= c sokoban-block-on-target) (incf sokoban-targets) @@ -499,7 +503,8 @@ static char * player_xpm[] = { (defun sokoban-get-floor (x y) (let ((c (aref (aref sokoban-level-map y) x))) (if (or (= c sokoban-target) - (= c sokoban-block-on-target)) + (= c sokoban-block-on-target) + (= c sokoban-player-on-target)) sokoban-target sokoban-floor))) @@ -513,6 +518,10 @@ static char * player_xpm[] = { (if (= c sokoban-player) (setq sokoban-x x sokoban-y y)) + (if (= c sokoban-player-on-target) + (setq sokoban-x x + sokoban-y y + c sokoban-player)) (if (= c sokoban-block-on-target) (setq c sokoban-block)) (gamegrid-set-cell x y c))))) -- 2.11.0 --=-=-= Content-Type: text/plain -- Dieter Deyke mailto:dieter.deyke@gmail.com Get my Gnupg key: gpg --keyserver keys.gnupg.net --recv-keys B116EA20 --=-=-=--