File: solution.h

package info (click to toggle)
tworld 1.3.0-5
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 6,620 kB
  • ctags: 1,407
  • sloc: ansic: 12,442; perl: 2,465; makefile: 191; sh: 16
file content (92 lines) | stat: -rw-r--r-- 3,228 bytes parent folder | download | duplicates (4)
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
/* solution.c: Functions for reading and writing the solution files.
 *
 * Copyright (C) 2001-2006 by Brian Raiter, under the GNU General Public
 * License. No warranty. See COPYING for details.
 */

#ifndef	_solution_h_
#define	_solution_h_

#include	"defs.h"
#include	"fileio.h"

/* The path of the directory containing the user's solution files.
 */
extern char    *savedir;

/* No file modification will be done unless this variable is FALSE.
 */
extern int	readonly;

/* Initialize or reinitialize list as empty.
 */
extern void initmovelist(actlist *list);

/* Append move to the end of list.
 */
extern void addtomovelist(actlist *list, action move);

/* Make to an independent copy of from.
 */
extern void copymovelist(actlist *to, actlist const *from);

/* Deallocate list.
 */
extern void destroymovelist(actlist *list);

/* Expand a level's solution data into the actual solution, including
 * the full list of moves. FALSE is returned if the solution is
 * invalid or absent.
 */
extern int expandsolution(solutioninfo *solution, gamesetup const *game);

/* Take the given solution and compress it, storing the compressed
 * data as part of the level's setup. FALSE is returned if an error
 * occurs. (It is not an error to compress the null solution.)
 */
extern int contractsolution(solutioninfo const *solution, gamesetup *game);

/* Read all the solutions for the given series into memory. FALSE is
 * returned if an error occurs. Note that it is not an error for the
 * solution file to not exist.
 */
extern int readsolutions(gameseries *series);

/* Write out all the solutions for the given series. The solution file
 * is created if it does not currently exist. The solution file's
 * directory is also created if it does not currently exist. (Nothing
 * is done if the directory's name has been unset, however.) FALSE is
 * returned if an error occurs.
 */
extern int savesolutions(gameseries *series);

/* Free all memory allocated for storing the game's solutions, and mark
 * the levels as being unsolved.
 */
extern void clearsolutions(gameseries *series);

/* Read the solution file at filename to see if it contains a set
 * name. If so, copy it into buffer and return its length in bytes (up
 * to 255). Zero is returned if the solution file contains no set
 * name. A negative value is returned if the file cannot be read or is
 * not a valid solution file.
 */
extern int loadsolutionsetname(char const *filename, char *buffer);

/* Produce a list of available solution files associated with the
 * given series (i.e. that have the name of the series as their
 * prefix). An array of filenames is returned through pfilelist, the
 * array's size is returned through pcount, and the table of the
 * filenames is returned through table. FALSE is returned if no table
 * was returned. If morethanone is TRUE, and less than two solution
 * files are found, FALSE is returned and the table is not created.
 */
extern int createsolutionfilelist(gameseries const *series, int morethanone,
				  char const ***pfilelist, int *pcount,
				  tablespec *table);

/* Free the memory allocated by createsolutionfilelist().
 */
extern void freesolutionfilelist(char const **filelist, tablespec *table);

#endif