--- /dev/null
+diff -purN aop-0.6.orig/Makefile aop-0.6/Makefile
+--- aop-0.6.orig/Makefile 2009-09-02 08:19:08.652153613 +0200
++++ aop-0.6/Makefile 2009-09-02 09:26:25.984152748 +0200
+@@ -1,14 +1,27 @@
++DESTDIR =
+
++CC = gcc
++CFLAGS = -Wall -O2
+ LDFLAGS = -lncurses
++SRCS = scoring.c aop.c
++OBJS = $(SRCS:.c=.o)
+
+-aop: aop.c
++all: aop
++
++.c.o:
++ $(CC) $(CFLAGS) -c $*.c -o $*.o
++
++aop: $(OBJS)
++ $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@
+
+ install: aop
+- install -d /usr/local/bin
+- install -d /usr/local/share/aop
+- install -m 755 aop /usr/local/bin/aop
+- install -m 644 aop-level-*.txt /usr/local/share/aop/
++ install -d $(DESTDIR)/usr/bin
++ install -d $(DESTDIR)/usr/share/aop
++ install -m 755 aop $(DESTDIR)/usr/bin/aop
++ install -m 644 aop-level-*.txt $(DESTDIR)/usr/share/aop/
++ install -d -m 777 $(DESTDIR)/var/spool/aop
++ touch $(DESTDIR)/var/spool/aop/score
++ chmod 666 $(DESTDIR)/var/spool/aop/score
+
+ clean:
+- rm -f aop core* *~
+-
++ rm -f aop *.o *~
+diff -purN aop-0.6.orig/aop.c aop-0.6/aop.c
+--- aop-0.6.orig/aop.c 2009-09-02 08:19:08.652153613 +0200
++++ aop-0.6/aop.c 2009-09-02 10:22:28.457051144 +0200
+@@ -2,14 +2,20 @@
+ /* Raffael Himmelreich <raffi@raffi.at> */
+ /* Clifford Wolf <clifford@clifford.at> */
+
++/* Patched by Jose V Beneyto <sepen@mikeux.dyndns.org> */
++
+ #include <curses.h>
+ #include <unistd.h>
+ #include <string.h>
++#include <pwd.h>
++#include "scoring.h"
+
+ int main(int argc, char *argv[]) {
+- int px, py, opx, opy, ipx, ipy, x, y, c=0, p=0, op, dir;
++ int px, py, opx, opy, ipx, ipy, x, y, c=0, p=0, op, dir, scorepos;
+ int last_lv = argc>=2 ? argc-1 : 11, level=1, lifes=5; FILE *f;
+ char ch, field[25][81], tmp[96], *lastword = "Bye.";
++ char *playerName=NULL;
++ struct passwd *userinfo;
+
+ if ( argc > 1 && *argv[1] == '-' ) {
+ printf("Usage: %s [aop-level-01.txt [..] ]\n", argv[0]);
+@@ -21,7 +27,7 @@ int main(int argc, char *argv[]) {
+ init_pair(1, COLOR_RED, COLOR_BLACK);
+
+ start: memset(field, ' ', 25*81);
+- snprintf(tmp, 96, "/usr/local/share/aop/aop-level-%02d.txt", level);
++ snprintf(tmp, 96, "/usr/share/aop/aop-level-%02d.txt", level);
+ f = fopen(argc>=2 ? argv[level] : tmp, "r");
+ if (!f) { endwin(); printf("Can't open level file.\n"); return 1; }
+ opx=ipx=px=3, opy=ipy=py=2; op=p; p += 700000 + level*373737;
+@@ -55,10 +61,28 @@ start: memset(field, ' ', 25*81);
+ attron(COLOR_PAIR(1));
+ mvprintw(0, 0, "Lifes: %d, Points: %d ",
+ lifes, p=p-(dir < 5 ? 1 : 2));
+- refresh(); usleep(dir < 5 ? 50000 : 100000);
++ refresh(); usleep(dir < 5 ? 100000 : 200000);
+ } while( (c=getch()) != 'q' );
+- endwin(); printf("%s (%d points)\n", lastword, p);
++ endwin();
++ printf("%s (%d points)\n", lastword, p);
++ if (playerName==NULL) {
++ userinfo = getpwuid(getuid());
++ if (userinfo!=NULL) {
++ playerName = strdup(userinfo->pw_name);
++ }
++ else {
++ playerName = strdup("UNKNOWN");
++ }
++ }
++ scorepos = add_high_score(playerName, level, p);
++ if (scorepos==0) {
++ fprintf(stderr,"\nUnable to write highscore file %s\n\n", HIGHSCOREFILE);
++ }
++ else {
++ if (scorepos != MAXHIGHSCORES+1) {
++ printf("\nYou got into position %d in the score table\n\n", scorepos);
++ }
++ print_high_scores();
++ }
+ return strcmp(lastword, "Sucker!") == 0;
+ }
+-
+-/* Yup - This are 64 lines of C code. ;-) */
+diff -purN aop-0.6.orig/scoring.c aop-0.6/scoring.c
+--- aop-0.6.orig/scoring.c 1970-01-01 01:00:00.000000000 +0100
++++ aop-0.6/scoring.c 2009-09-02 10:24:39.536533588 +0200
+@@ -0,0 +1,128 @@
++/*
++ Routines to deal with high score files for tetris.
++ Copyright 1999 Jonathan McDowell for Project Purple
++ 21/05/99
++
++ 27/06/99 - Added date field
++
++ Jose V Beneyto <sepen@mikeux.dyndns.org>
++ 02/09/09 - Removed basedelay from the struct and fixed highscorefile usage
++*/
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <time.h>
++#include "scoring.h"
++
++int get_high_scores(struct highscoreent *highscores[], int *numscores)
++{
++ FILE *scorefile;
++ long filelen;
++
++ if ((scorefile=fopen(HIGHSCOREFILE,"r"))==NULL) {
++ return 0;
++ }
++
++ fseek(scorefile, 0, SEEK_END);
++ filelen=ftell(scorefile)+1;
++ rewind(scorefile);
++
++ if ((*highscores=malloc(filelen))==NULL) {
++ return 0;
++ }
++
++ fread(*highscores, 1, filelen, scorefile);
++ *numscores=filelen/sizeof(struct highscoreent);
++ if (*numscores>MAXHIGHSCORES) *numscores=MAXHIGHSCORES;
++
++ fclose(scorefile);
++ return 1;
++}
++
++int save_high_scores(struct highscoreent highscores[], int *numscores)
++{
++ FILE *scorefile;
++
++ if ((scorefile=fopen(HIGHSCOREFILE,"w"))==NULL) {
++ return 0;
++ }
++
++ if (*numscores>MAXHIGHSCORES) *numscores=MAXHIGHSCORES;
++ fwrite(highscores, 1, *numscores * sizeof(struct highscoreent), scorefile);
++
++ fclose(scorefile);
++ return 1;
++}
++
++/* Checks if a score got into the high score table and if so add it to
++ the high score file. Returns 0 if unable to do so, MAXHIGHSCORES+1
++ if the score didn't get into the high score table, otherwise the
++ position in the table. */
++int add_high_score(const char name[], unsigned int endlvl, unsigned int score)
++{
++ struct highscoreent highscore;
++ struct highscoreent *scores, *newscores;
++ int loop, numscores;
++
++ strncpy(highscore.name, name, 15);
++ highscore.name[15]=numscores=0;
++ highscore.endlvl=endlvl;
++ highscore.score=score;
++ highscore.date=time(NULL);
++
++ if (get_high_scores(&scores, &numscores)==0 || numscores==0) {
++ numscores=1;
++ if (save_high_scores(&highscore, &numscores))
++ return 1;
++ else
++ return 0;
++ }
++
++ if (numscores==MAXHIGHSCORES) numscores--;
++
++ if ((newscores=malloc(sizeof(struct highscoreent)*(numscores+1)))==NULL) {
++ return 0;
++ }
++
++ memcpy(newscores, scores, sizeof(struct highscoreent)*numscores);
++
++ loop=0;
++ while (score<(scores[loop]).score && loop<numscores) loop++;
++
++ if (score<(scores[loop]).score) {
++ /* didn't get on score table */
++ return (MAXHIGHSCORES+1);
++ }
++
++ if (loop<numscores) {
++ memmove(&(newscores[loop+1]), &(newscores[loop]), sizeof(struct highscoreent)*(numscores-loop));
++ }
++ memcpy(&(newscores[loop]), &highscore, sizeof(highscore));
++ ++numscores;
++ save_high_scores(newscores, &numscores);
++
++ return (loop+1);
++}
++
++void print_high_scores(void)
++{
++ struct highscoreent *scores;
++ int numscores,loop;
++ char tempdate[30];
++
++ if (get_high_scores(&scores, &numscores)==1) {
++ printf("+------------------+-------+----------+-----------------------+\n");
++ printf("| Name | Level | Score | Date |\n");
++ printf("+------------------+-------+----------+-----------------------+\n");
++ for (loop=0; loop<numscores; loop++) {
++ strncpy(tempdate, ctime(&scores[loop].date), 29);
++ strncpy(tempdate+16,tempdate+19,5);
++ tempdate[21]=0;
++ printf("| %-16s | %5d | %8d | %21s |\n", scores[loop].name, scores[loop].endlvl, scores[loop].score, tempdate);
++ }
++ printf("+------------------+-------+----------+-----------------------+\n");
++ } else {
++ printf("Couldn't read high score file.\n");
++ }
++}
+diff -purN aop-0.6.orig/scoring.h aop-0.6/scoring.h
+--- aop-0.6.orig/scoring.h 1970-01-01 01:00:00.000000000 +0100
++++ aop-0.6/scoring.h 2009-09-02 09:18:04.072154104 +0200
+@@ -0,0 +1,30 @@
++/*
++ Routines to deal with high score files for tetris.
++ Copyright 1999 Jonathan McDowell for Project Purple
++ 21/05/99
++
++ Jose V Beneyto <sepen@mikeux.dyndns.org>
++ 02/09/09 - Removed basedelay from the struct and fixed highscorefile usage
++*/
++
++#include <time.h>
++
++/* Default high score file location */
++#define HIGHSCOREFILE "/var/spool/aop/score"
++/* Max number of high scores we store */
++#define MAXHIGHSCORES 20
++
++struct highscoreent {
++ char name[16];
++ unsigned int endlvl, lines, score;
++ time_t date;
++};
++
++int get_high_scores(struct highscoreent *highscores[], int *numscores);
++int save_high_scores(struct highscoreent highscores[], int *numscores);
++/* Checks if a score got into the high score table and if so add it to
++ the high score file. Returns 0 if unable to do so, MAXHIGHSCORE+1
++ if the score didn't get into the high score table, otherwise the
++ position in the table. */
++int add_high_score(const char name[], unsigned int endlvl, unsigned int score);
++void print_high_scores(void);