406 |
|
|
407 |
(defun gamegrid-add-score (file score) |
(defun gamegrid-add-score (file score) |
408 |
"Add the current score to the high score file." |
"Add the current score to the high score file." |
409 |
|
(case system-type |
410 |
|
((ms-dos windows-nt) |
411 |
|
(gamegrid-add-score-insecure file score)) |
412 |
|
(t |
413 |
|
(gamegrid-add-score-with-update-game-score file score)))) |
414 |
|
|
415 |
|
(defun gamegrid-add-score-with-update-game-score (file score) |
416 |
(let ((result nil) |
(let ((result nil) |
417 |
(errbuf (generate-new-buffer " *update-game-score loss*")) |
(errbuf (generate-new-buffer " *update-game-score loss*")) |
418 |
(target (if game-score-directory |
(target (if game-score-directory |
452 |
(save-excursion |
(save-excursion |
453 |
(find-file-read-only-other-window target)))) |
(find-file-read-only-other-window target)))) |
454 |
|
|
455 |
|
(defun gamegrid-add-score-insecure (file score) |
456 |
|
(save-excursion |
457 |
|
(setq file (expand-file-name file temporary-file-directory)) |
458 |
|
(find-file-other-window file) |
459 |
|
(setq buffer-read-only nil) |
460 |
|
(goto-char (point-max)) |
461 |
|
(insert (format "%05d\t%s\t%s <%s>\n" |
462 |
|
score |
463 |
|
(current-time-string) |
464 |
|
(user-full-name) |
465 |
|
(cond ((fboundp 'user-mail-address) |
466 |
|
(user-mail-address)) |
467 |
|
((boundp 'user-mail-address) |
468 |
|
user-mail-address) |
469 |
|
(t "")))) |
470 |
|
(sort-numeric-fields 1 (point-min) (point-max)) |
471 |
|
(reverse-region (point-min) (point-max)) |
472 |
|
(goto-line (1+ gamegrid-score-file-length)) |
473 |
|
(delete-region (point) (point-max)) |
474 |
|
(setq buffer-read-only t) |
475 |
|
(save-buffer))) |
476 |
|
|
477 |
|
|
478 |
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
479 |
|
|