summaryrefslogtreecommitdiff
path: root/games/xboing/files/patch-ad
blob: 7b5d3a776810633b40f74727ccf59b335f7e3323 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
*** highscore.c.orig	Wed Jan  4 17:13:31 1995
--- highscore.c	Fri Apr  7 00:13:54 1995
***************
*** 54,59 ****
--- 54,60 ----
  #include <unistd.h>
  #include <time.h>
  #include <sys/param.h>
+ #include <sys/stat.h>
  #include <netinet/in.h>
  #include <X11/Xlib.h>
  #include <X11/Xutil.h>
***************
*** 118,124 ****
  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();
--- 119,125 ----
  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();
***************
*** 839,845 ****
  
  	/* Lock the file for me only */
  	if (type == GLOBAL)
! 		id = LockUnlock(LOCK_FILE);
  
  	/* Read in the lastest scores */
  	if (ReadHighScoreTable(type) == False)
--- 840,846 ----
  
  	/* Lock the file for me only */
  	if (type == GLOBAL)
! 		id = LockUnlock(LOCK_FILE, -1);
  
  	/* Read in the lastest scores */
  	if (ReadHighScoreTable(type) == False)
***************
*** 869,875 ****
  				else
  				{
  					/* Don't add as score is smaller */
! 					return False;
  				}
  			}
  		}	/* for */
--- 870,876 ----
  				else
  				{
  					/* Don't add as score is smaller */
! 					goto doUnlock;
  				}
  			}
  		}	/* for */
***************
*** 891,906 ****
  
  				/* 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;
--- 892,908 ----
  
  				/* 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;
***************
*** 1178,1187 ****
  }
  
  #if NeedFunctionPrototypes
! static int LockUnlock(int cmd)
  #else
! static int LockUnlock(cmd)
! 	int cmd;
  #endif
  {
  	static int 	inter = -1;
--- 1180,1189 ----
  }
  
  #if NeedFunctionPrototypes
! static int LockUnlock(int cmd, int fd)
  #else
! static int LockUnlock(cmd, fd)
! 	int cmd, fd;
  #endif
  {
  	static int 	inter = -1;
***************
*** 1218,1223 ****
--- 1220,1228 ----
  	/* Open the highscore file for both read & write */
  	if (cmd == LOCK_FILE)
  		inter = open(filename, O_CREAT | O_RDWR, 0666);
+ 	else
+ 		/* use old fd to unlock */
+ 		inter = fd;
  
  #ifndef NO_LOCKING