1995-04-08 05:06:23 +00:00
|
|
|
*** highscore.c.orig Wed Jan 4 17:13:31 1995
|
|
|
|
--- highscore.c Fri Apr 7 00:13:54 1995
|
1995-04-01 22:12:16 +00:00
|
|
|
***************
|
1995-04-08 05:06:23 +00:00
|
|
|
*** 54,59 ****
|
|
|
|
--- 54,60 ----
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <time.h>
|
1995-04-01 22:12:16 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
+ #include <sys/stat.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
***************
|
1995-04-08 05:06:23 +00:00
|
|
|
*** 118,124 ****
|
1995-04-01 22:12:16 +00:00
|
|
|
static void InitialiseHighScores(void);
|
|
|
|
static void SortHighScores(void);
|
|
|
|
static void DeleteScore(int i);
|
|
|
|
! static int LockUnlock(int cmd);
|
|
|
|
#else
|
|
|
|
static int LockUnlock();
|
|
|
|
static void DeleteScore();
|
1995-04-08 05:06:23 +00:00
|
|
|
--- 119,125 ----
|
1995-04-01 22:12:16 +00:00
|
|
|
static void InitialiseHighScores(void);
|
|
|
|
static void SortHighScores(void);
|
|
|
|
static void DeleteScore(int i);
|
|
|
|
! static int LockUnlock(int cmd, int fd);
|
|
|
|
#else
|
|
|
|
static int LockUnlock();
|
|
|
|
static void DeleteScore();
|
|
|
|
***************
|
1995-04-08 05:06:23 +00:00
|
|
|
*** 839,845 ****
|
1995-04-01 22:12:16 +00:00
|
|
|
|
|
|
|
/* Lock the file for me only */
|
|
|
|
if (type == GLOBAL)
|
|
|
|
! id = LockUnlock(LOCK_FILE);
|
|
|
|
|
|
|
|
/* Read in the lastest scores */
|
|
|
|
if (ReadHighScoreTable(type) == False)
|
1995-04-08 05:06:23 +00:00
|
|
|
--- 840,846 ----
|
1995-04-01 22:12:16 +00:00
|
|
|
|
|
|
|
/* Lock the file for me only */
|
|
|
|
if (type == GLOBAL)
|
|
|
|
! id = LockUnlock(LOCK_FILE, -1);
|
|
|
|
|
|
|
|
/* Read in the lastest scores */
|
|
|
|
if (ReadHighScoreTable(type) == False)
|
|
|
|
***************
|
1995-04-08 05:06:23 +00:00
|
|
|
*** 869,875 ****
|
1995-04-01 22:12:16 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Don't add as score is smaller */
|
|
|
|
! return False;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} /* for */
|
1995-04-08 05:06:23 +00:00
|
|
|
--- 870,876 ----
|
1995-04-01 22:12:16 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Don't add as score is smaller */
|
|
|
|
! goto doUnlock;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} /* for */
|
|
|
|
***************
|
1995-04-08 05:06:23 +00:00
|
|
|
*** 891,906 ****
|
1995-04-01 22:12:16 +00:00
|
|
|
|
|
|
|
/* Unlock the file now thanks */
|
|
|
|
if (id != -1)
|
|
|
|
! id = LockUnlock(UNLOCK_FILE);
|
|
|
|
|
|
|
|
/* Yes - it was placed in the highscore */
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Unlock the file now thanks */
|
|
|
|
if (id != -1)
|
|
|
|
! id = LockUnlock(UNLOCK_FILE);
|
|
|
|
|
|
|
|
/* Not even a highscore - loser! */
|
|
|
|
return False;
|
1995-04-08 05:06:23 +00:00
|
|
|
--- 892,908 ----
|
1995-04-01 22:12:16 +00:00
|
|
|
|
|
|
|
/* Unlock the file now thanks */
|
|
|
|
if (id != -1)
|
|
|
|
! id = LockUnlock(UNLOCK_FILE, id);
|
|
|
|
|
|
|
|
/* Yes - it was placed in the highscore */
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ doUnlock:
|
|
|
|
/* Unlock the file now thanks */
|
|
|
|
if (id != -1)
|
|
|
|
! id = LockUnlock(UNLOCK_FILE, id);
|
|
|
|
|
|
|
|
/* Not even a highscore - loser! */
|
|
|
|
return False;
|
|
|
|
***************
|
1995-04-08 05:06:23 +00:00
|
|
|
*** 1178,1187 ****
|
1995-04-01 22:12:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if NeedFunctionPrototypes
|
|
|
|
! static int LockUnlock(int cmd)
|
|
|
|
#else
|
|
|
|
! static int LockUnlock(cmd)
|
|
|
|
! int cmd;
|
|
|
|
#endif
|
|
|
|
{
|
1995-04-08 05:06:23 +00:00
|
|
|
static int inter = -1;
|
|
|
|
--- 1180,1189 ----
|
1995-04-01 22:12:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if NeedFunctionPrototypes
|
|
|
|
! static int LockUnlock(int cmd, int fd)
|
|
|
|
#else
|
|
|
|
! static int LockUnlock(cmd, fd)
|
|
|
|
! int cmd, fd;
|
|
|
|
#endif
|
|
|
|
{
|
1995-04-08 05:06:23 +00:00
|
|
|
static int inter = -1;
|
1995-04-01 22:12:16 +00:00
|
|
|
***************
|
1995-04-08 05:06:23 +00:00
|
|
|
*** 1218,1223 ****
|
|
|
|
--- 1220,1228 ----
|
1995-04-01 22:12:16 +00:00
|
|
|
/* Open the highscore file for both read & write */
|
|
|
|
if (cmd == LOCK_FILE)
|
1995-04-08 05:06:23 +00:00
|
|
|
inter = open(filename, O_CREAT | O_RDWR, 0666);
|
1995-04-01 22:12:16 +00:00
|
|
|
+ else
|
|
|
|
+ /* use old fd to unlock */
|
|
|
|
+ inter = fd;
|
|
|
|
|
|
|
|
#ifndef NO_LOCKING
|
1995-04-08 05:06:23 +00:00
|
|
|
|