home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / volume6 / sokoban2 / patch1 < prev   
Encoding:
Internet Message Format  |  1989-03-22  |  11.7 KB

  1. Path: uunet!tektronix!tekgen!tekred!games
  2. From: games@tekred.CNA.TEK.COM
  3. Newsgroups: comp.sources.games
  4. Subject: v06i033:  sokoban2 - curses based, get the money game (Version 2), Patch1
  5. Message-ID: <3750@tekred.CNA.TEK.COM>
  6. Date: 21 Mar 89 22:38:12 GMT
  7. Sender: billr@tekred.CNA.TEK.COM
  8. Lines: 337
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: ching@pepsi.AMD.COM (Mike Ching)
  12. Posting-number: Volume 6, Issue 33
  13. Archive-name: sokoban2/Patch1
  14.  
  15.     [From the author...]
  16.     [[This is a set of diffs for version 2 of sokoban to run under
  17.       MSDOS using the Turbo C compiler. I'm contemplating doing
  18.       graphics similar to EGA-wanderer if I can stop playing the
  19.       game long enough.]]
  20.     [I applied Mike's diffs and recreated a set of context diffs
  21.      from the original source.  The MSDOS stuff is #ifdef'd. -br]
  22.  
  23. #! /bin/sh
  24. # This is a shell archive.  Remove anything before this line, then unpack
  25. # it by saving it into a file and typing "sh file".  To overwrite existing
  26. # files, type "sh file -c".  You can also feed this as standard input via
  27. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  28. # will see the following message at the end:
  29. #        "End of shell archive."
  30. # Contents:  Patches01
  31. # Wrapped by billr@saab on Tue Mar 21 13:38:17 1989
  32. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  33. if test -f 'Patches01' -a "${1}" != "-c" ; then 
  34.   echo shar: Will not clobber existing file \"'Patches01'\"
  35. else
  36. echo shar: Extracting \"'Patches01'\" \(9992 characters\)
  37. sed "s/^X//" >'Patches01' <<'END_OF_FILE'
  38. X*** sokoban.h.orig    Wed Mar 15 14:44:26 1989
  39. X--- sokoban.h    Tue Mar 21 11:55:14 1989
  40. X***************
  41. X*** 66,72 ****
  42. X     packet =      { '$', '$', 0 },
  43. X     save =      { '*', '$', 1 },
  44. X     ground =      { ' ', ' ', 0 },
  45. X!    wall =      { '#', ' ', 1 };
  46. X  
  47. X  /*************************************************************************
  48. X  ********************** DO NOT CHANGE BELOW THIS LINE *********************
  49. X--- 66,72 ----
  50. X     packet =      { '$', '$', 0 },
  51. X     save =      { '*', '$', 1 },
  52. X     ground =      { ' ', ' ', 0 },
  53. X!    wall =      { '#', '#', 1 };
  54. X  
  55. X  /*************************************************************************
  56. X  ********************** DO NOT CHANGE BELOW THIS LINE *********************
  57. X*** readscreen.c.orig    Wed Mar 15 14:43:56 1989
  58. X--- readscreen.c    Tue Mar 21 11:54:43 1989
  59. X***************
  60. X*** 14,20 ****
  61. X     char *fnam;
  62. X     short j, c, ret = 0;
  63. X  
  64. X!    fnam = malloc( strlen( SCREENPATH) + 11);
  65. X     sprintf( fnam, "%s/screen.%d", SCREENPATH, level);
  66. X     if( (screen = fopen( fnam, "r")) == NULL) 
  67. X        ret = E_FOPENSCREEN;
  68. X--- 14,20 ----
  69. X     char *fnam;
  70. X     short j, c, ret = 0;
  71. X  
  72. X!    fnam = malloc( strlen( SCREENPATH) + 12);
  73. X     sprintf( fnam, "%s/screen.%d", SCREENPATH, level);
  74. X     if( (screen = fopen( fnam, "r")) == NULL) 
  75. X        ret = E_FOPENSCREEN;
  76. X*** save.c.orig    Wed Mar 15 14:43:57 1989
  77. X--- save.c    Tue Mar 21 11:54:52 1989
  78. X***************
  79. X*** 23,30 ****
  80. X     short ret = 0;
  81. X  
  82. X     signal( SIGINT, SIG_IGN);
  83. X!    sfname = malloc( strlen( SAVEPATH) + strlen( username) + 5);
  84. X     sprintf( sfname, "%s/%s.sav", SAVEPATH, username);
  85. X     if( (savefile = fopen( sfname, "w")) == NULL)
  86. X        ret = E_FOPENSAVE;
  87. X     else {
  88. X--- 23,54 ----
  89. X     short ret = 0;
  90. X  
  91. X     signal( SIGINT, SIG_IGN);
  92. X!    sfname = malloc( strlen( SAVEPATH) + strlen( username) + 6);
  93. X     sprintf( sfname, "%s/%s.sav", SAVEPATH, username);
  94. X+ #ifdef __MSDOS__
  95. X+    if( (savefile = fopen( sfname, "wb")) == NULL)
  96. X+       ret = E_FOPENSAVE;
  97. X+    else {
  98. X+       if( fwrite( map, 1, MAXROW*MAXCOL, savefile) != MAXROW*MAXCOL)
  99. X+      ret = E_WRITESAVE;
  100. X+       else if( fwrite( &ppos, 1, sizeof( POS), savefile) != sizeof( POS))     
  101. X+      ret = E_WRITESAVE;
  102. X+       else if( fwrite( &level, 1, 2, savefile) != 2)    ret = E_WRITESAVE;
  103. X+       else if( fwrite( &moves, 1, 2, savefile) != 2)    ret = E_WRITESAVE;
  104. X+       else if( fwrite( &pushes, 1, 2, savefile) != 2)   ret = E_WRITESAVE;
  105. X+       else if( fwrite( &packets, 1, 2, savefile) != 2)  ret = E_WRITESAVE;
  106. X+       else if( fwrite( &savepack, 1, 2, savefile) != 2) ret = E_WRITESAVE;
  107. X+       else if( fwrite( &rows, 1, 2, savefile) != 2)     ret = E_WRITESAVE;
  108. X+       else if( fwrite( &cols, 1, 2, savefile) != 2)     ret = E_WRITESAVE;
  109. X+       else {
  110. X+      fclose( savefile);
  111. X+      if( stat( sfname, &sfstat) != 0) ret = E_STATSAVE;
  112. X+      else if( (savefile = fopen( sfname, "ab")) == NULL)
  113. X+             ret = E_FOPENSAVE;
  114. X+          else {
  115. X+         if( fwrite( &sfstat, 1, sizeof( sfstat), savefile) != sizeof( sfstat))
  116. X+            ret = E_WRITESAVE;
  117. X+ #else
  118. X     if( (savefile = fopen( sfname, "w")) == NULL)
  119. X        ret = E_FOPENSAVE;
  120. X     else {
  121. X***************
  122. X*** 33,39 ****
  123. X       ret = E_WRITESAVE;
  124. X        else if( write( savedbn, &ppos, sizeof( POS)) != sizeof( POS))     
  125. X       ret = E_WRITESAVE;
  126. X-       else if( write( savedbn, &scoring, 2) != 2)  ret = E_WRITESAVE;
  127. X        else if( write( savedbn, &level, 2) != 2)    ret = E_WRITESAVE;
  128. X        else if( write( savedbn, &moves, 2) != 2)    ret = E_WRITESAVE;
  129. X        else if( write( savedbn, &pushes, 2) != 2)   ret = E_WRITESAVE;
  130. X--- 57,62 ----
  131. X***************
  132. X*** 49,54 ****
  133. X--- 72,78 ----
  134. X           else {
  135. X          if( write( savedbn, &sfstat, sizeof( sfstat)) != sizeof( sfstat))
  136. X             ret = E_WRITESAVE;
  137. X+ #endif
  138. X          fclose( savefile);
  139. X       }
  140. X        }
  141. X***************
  142. X*** 65,75 ****
  143. X     struct stat oldsfstat;
  144. X  
  145. X     signal( SIGINT, SIG_IGN);
  146. X!    sfname = malloc( strlen( SAVEPATH) + strlen( username) + 5);
  147. X     sprintf( sfname, "%s/%s.sav", SAVEPATH, username);
  148. X     if( stat( sfname, &oldsfstat) < -1) 
  149. X        ret = E_NOSAVEFILE;
  150. X     else {
  151. X        if( (savefile = fopen( sfname, "r")) == NULL)
  152. X       ret = E_FOPENSAVE;
  153. X        else {
  154. X--- 89,119 ----
  155. X     struct stat oldsfstat;
  156. X  
  157. X     signal( SIGINT, SIG_IGN);
  158. X!    sfname = malloc( strlen( SAVEPATH) + strlen( username) + 6);
  159. X     sprintf( sfname, "%s/%s.sav", SAVEPATH, username);
  160. X+ #ifdef __MSDOS__
  161. X     if( stat( sfname, &oldsfstat) < -1) 
  162. X        ret = E_NOSAVEFILE;
  163. X     else {
  164. X+       if( (savefile = fopen( sfname, "rb")) == NULL)
  165. X+      ret = E_FOPENSAVE;
  166. X+       else {
  167. X+          if( fread( map, 1, MAXROW*MAXCOL, savefile) != MAXROW*MAXCOL)
  168. X+         ret = E_READSAVE;
  169. X+          else if( fread( &ppos, 1, sizeof( POS), savefile) != sizeof( POS))     
  170. X+         ret = E_READSAVE;
  171. X+          else if( fread( &level, 1, 2, savefile) != 2)    ret = E_READSAVE;
  172. X+          else if( fread( &moves, 1, 2, savefile) != 2)    ret = E_READSAVE;
  173. X+          else if( fread( &pushes, 1, 2, savefile) != 2)   ret = E_READSAVE;
  174. X+          else if( fread( &packets, 1, 2, savefile) != 2)  ret = E_READSAVE;
  175. X+          else if( fread( &savepack, 1, 2, savefile) != 2) ret = E_READSAVE;
  176. X+          else if( fread( &rows, 1, 2, savefile) != 2)     ret = E_READSAVE;
  177. X+          else if( fread( &cols, 1, 2, savefile) != 2)     ret = E_READSAVE;
  178. X+      else if( fread( &sfstat, 1, sizeof( sfstat), savefile) != sizeof( sfstat))
  179. X+ #else
  180. X+    if( stat( sfname, &oldsfstat) < -1) 
  181. X+       ret = E_NOSAVEFILE;
  182. X+    else {
  183. X        if( (savefile = fopen( sfname, "r")) == NULL)
  184. X       ret = E_FOPENSAVE;
  185. X        else {
  186. X***************
  187. X*** 78,84 ****
  188. X          ret = E_READSAVE;
  189. X           else if( read( savedbn, &ppos, sizeof( POS)) != sizeof( POS))     
  190. X          ret = E_READSAVE;
  191. X-          else if( read( savedbn, &scoring, 2) != 2)  ret = E_READSAVE;
  192. X           else if( read( savedbn, &level, 2) != 2)    ret = E_READSAVE;
  193. X           else if( read( savedbn, &moves, 2) != 2)    ret = E_READSAVE;
  194. X           else if( read( savedbn, &pushes, 2) != 2)   ret = E_READSAVE;
  195. X--- 122,127 ----
  196. X***************
  197. X*** 87,92 ****
  198. X--- 130,136 ----
  199. X           else if( read( savedbn, &rows, 2) != 2)     ret = E_READSAVE;
  200. X           else if( read( savedbn, &cols, 2) != 2)     ret = E_READSAVE;
  201. X       else if( read( savedbn, &sfstat, sizeof( sfstat)) != sizeof( sfstat))
  202. X+ #endif
  203. X          ret = E_READSAVE;
  204. X       else if( (sfstat.st_dev != oldsfstat.st_dev) ||
  205. X                    (sfstat.st_ino != oldsfstat.st_ino) ||
  206. X***************
  207. X*** 101,103 ****
  208. X--- 145,148 ----
  209. X     signal( SIGINT, SIG_DFL);
  210. X     return( ret);
  211. X  }
  212. X+ 
  213. X*** score.c.orig    Wed Mar 15 14:43:58 1989
  214. X--- score.c    Tue Mar 21 11:54:58 1989
  215. X***************
  216. X*** 33,43 ****
  217. X--- 33,51 ----
  218. X  
  219. X     while( creat( LOCKFILE, 0666) < 0) ;
  220. X     scoreentries = 0;
  221. X+ #ifdef __MSDOS__
  222. X+    if( (scorefile = fopen( SCOREFILE, "wb")) == NULL)
  223. X+       ret = E_FOPENSCORE;
  224. X+    else {
  225. X+     if (fwrite (&scoreentries, 1, sizeof( scoreentries), scorefile) != sizeof(scoreentries))
  226. X+         ret = E_WRITESCORE;
  227. X+ #else
  228. X     if( (scorefile = fopen( SCOREFILE, "w")) == NULL)
  229. X        ret = E_FOPENSCORE;
  230. X     else {
  231. X        sfdbn = fileno( scorefile);
  232. X        if( write( sfdbn, &scoreentries, 2) != 2) ret = E_WRITESCORE;
  233. X+ #endif
  234. X        fclose( scorefile);
  235. X     }
  236. X     unlink( LOCKFILE);
  237. X***************
  238. X*** 50,56 ****
  239. X--- 58,68 ----
  240. X     short ret = 0, pos;
  241. X  
  242. X     while( creat( LOCKFILE, 0666) < 0);
  243. X+ #ifdef __MSDOS__
  244. X+    if( (scorefile = fopen( SCOREFILE, "rb")) == NULL)
  245. X+ #else
  246. X     if( (scorefile = fopen( SCOREFILE, "r")) == NULL)
  247. X+ #endif
  248. X        ret = E_FOPENSCORE;
  249. X     else {
  250. X        if( (ret = readscore()) == 0)
  251. X***************
  252. X*** 78,83 ****
  253. X--- 90,106 ----
  254. X     short ret = 0;
  255. X     long tmp;
  256. X  
  257. X+ #ifdef __MSDOS__
  258. X+    if( (scorefile = fopen( SCOREFILE, "rb")) == NULL)
  259. X+       ret = E_FOPENSCORE;
  260. X+    else {
  261. X+       tmp = sizeof( scoreentries);
  262. X+       if( fread( &scoreentries, 1, tmp, scorefile) != tmp) ret = E_READSCORE;
  263. X+       else {
  264. X+      tmp = scoreentries * sizeof( scoretable[0]);
  265. X+      if( fread( scoretable, 1, tmp, scorefile) != tmp) ret = E_READSCORE;
  266. X+       }
  267. X+ #else
  268. X     if( (scorefile = fopen( SCOREFILE, "r")) == NULL)
  269. X        ret = E_FOPENSCORE;
  270. X     else {
  271. X***************
  272. X*** 87,92 ****
  273. X--- 110,116 ----
  274. X       tmp = scoreentries * sizeof( scoretable[0]);
  275. X       if( read( sfdbn, &(scoretable[0]), tmp) != tmp) ret = E_READSCORE;
  276. X        }
  277. X+ #endif
  278. X        fclose( scorefile);
  279. X     }
  280. X     return( ret);
  281. X***************
  282. X*** 161,166 ****
  283. X--- 185,201 ----
  284. X     short ret = 0;
  285. X     long tmp;
  286. X  
  287. X+ #ifdef __MSDOS__
  288. X+    if( (scorefile = fopen( SCOREFILE, "wb")) == NULL)
  289. X+       ret = E_FOPENSCORE;
  290. X+    else {
  291. X+       tmp = sizeof( scoreentries);
  292. X+       if( fwrite( &scoreentries, 1, tmp, scorefile) != tmp) ret = E_WRITESCORE;
  293. X+       else {
  294. X+      tmp = scoreentries * sizeof( scoretable[0]);
  295. X+      if( fwrite( scoretable, 1, tmp, scorefile) != tmp) ret = E_WRITESCORE;
  296. X+       }
  297. X+ #else
  298. X     if( (scorefile = fopen( SCOREFILE, "w")) == NULL)
  299. X        ret = E_FOPENSCORE;
  300. X     else {
  301. X***************
  302. X*** 170,175 ****
  303. X--- 205,211 ----
  304. X       tmp = scoreentries * sizeof( scoretable[0]);
  305. X       if( write( sfdbn, &(scoretable[0]), tmp) != tmp) ret = E_WRITESCORE;
  306. X        }
  307. X+ #endif
  308. X        fclose( scorefile);
  309. X     }
  310. X     return( ret);
  311. X*** showscreen.c.orig    Wed Mar 15 14:44:25 1989
  312. X--- showscreen.c    Tue Mar 21 11:55:05 1989
  313. X***************
  314. X*** 1,3 ****
  315. X--- 1,4 ----
  316. X+ #include <stdio.h>
  317. X  #include <curses.h>
  318. X  #include "sokoban.h"
  319. X  
  320. X*** sok.c.orig    Wed Mar 15 14:44:26 1989
  321. X--- sok.c    Tue Mar 21 11:55:09 1989
  322. X***************
  323. X*** 1,5 ****
  324. X--- 1,15 ----
  325. X+ #include <stdio.h>
  326. X  #include <curses.h>
  327. X  #include "sokoban.h"
  328. X+ #ifdef __MSDOS__
  329. X+ char * getlogin()        /* interactive login name */
  330. X+ {    static char loginname[MAXUSERNAME];
  331. X+     fputs("\nName? ", stdout);
  332. X+     fgets(loginname, MAXUSERNAME, stdin);
  333. X+     loginname[strlen(loginname)-1] = 0;
  334. X+     return(loginname);
  335. X+ }
  336. X+ #endif
  337. X  
  338. X  extern char  *strrchr(), *getlogin(), *getpass();
  339. X  extern short readscreen(), play(), outputscore(), getuserlevel(),
  340. END_OF_FILE
  341. if test 9992 -ne `wc -c <'Patches01'`; then
  342.     echo shar: \"'Patches01'\" unpacked with wrong size!
  343. fi
  344. # end of 'Patches01'
  345. fi
  346. echo shar: End of shell archive.
  347. exit 0
  348.