summaryrefslogtreecommitdiff
path: root/lisp/play/gamegrid.el
diff options
context:
space:
mode:
authorColin Walters <walters@gnu.org>2002-04-10 19:13:35 +0000
committerColin Walters <walters@gnu.org>2002-04-10 19:13:35 +0000
commitbaf9c39a8c126e8dad9a528bf5f1f0c1f08c6531 (patch)
tree36c3c81f1b26347b9d1ea20a42be44fc60dbaf36 /lisp/play/gamegrid.el
parentb23af4699917734d50dc9f0daf7942866da7c466 (diff)
downloademacs-baf9c39a8c126e8dad9a528bf5f1f0c1f08c6531.tar.gz
(gamegrid-add-score): Rewrite from scratch to use `update-game-score'.
Diffstat (limited to 'lisp/play/gamegrid.el')
-rw-r--r--lisp/play/gamegrid.el46
1 files changed, 28 insertions, 18 deletions
diff --git a/lisp/play/gamegrid.el b/lisp/play/gamegrid.el
index 2ff50ad53eb..ffb179d52d2 100644
--- a/lisp/play/gamegrid.el
+++ b/lisp/play/gamegrid.el
@@ -406,25 +406,35 @@ static char *noname[] = {
(defun gamegrid-add-score (file score)
"Add the current score to the high score file."
+ (let ((result nil)
+ (errbuf (generate-new-buffer " *update-game-score loss*")))
+ (let ((default-directory "/"))
+ (apply
+ 'call-process
+ (append
+ (list
+ (expand-file-name "update-game-score" exec-directory)
+ nil errbuf nil
+ "-m" (int-to-string gamegrid-score-file-length) file
+ (int-to-string score)
+ (concat
+ (user-full-name)
+ " <"
+ (cond ((fboundp 'user-mail-address)
+ (user-mail-address))
+ ((boundp 'user-mail-address)
+ user-mail-address)
+ (t ""))
+ "> "
+ (current-time-string)))))
+ (if (buffer-modified-p errbuf)
+ (progn
+ (display-buffer errbuf)
+ (error "Failed to update game score file"))
+ (kill-buffer errbuf))))
(save-excursion
- (find-file-other-window file)
- (setq buffer-read-only nil)
- (goto-char (point-max))
- (insert (format "%05d\t%s\t%s <%s>\n"
- score
- (current-time-string)
- (user-full-name)
- (cond ((fboundp 'user-mail-address)
- (user-mail-address))
- ((boundp 'user-mail-address)
- user-mail-address)
- (t ""))))
- (sort-numeric-fields 1 (point-min) (point-max))
- (reverse-region (point-min) (point-max))
- (goto-line (1+ gamegrid-score-file-length))
- (delete-region (point) (point-max))
- (setq buffer-read-only t)
- (save-buffer)))
+ (find-file-read-only-other-window (expand-file-name file game-score-directory))))
+
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;