Changeset 569
- Timestamp:
- 09/17/07 07:51:13 (1 year ago)
- Files:
-
- trunk/src/Makefile.src (modified) (1 diff)
- trunk/src/Makefile.std (modified) (2 diffs)
- trunk/src/doc (added)
- trunk/src/doc/doxygen.conf (added)
- trunk/src/z-blockfile.h (modified) (18 diffs)
- trunk/src/z-file.h (modified) (24 diffs)
- trunk/src/z-form.h (modified) (1 diff)
- trunk/src/z-msg.h (modified) (9 diffs)
- trunk/src/z-rand.h (modified) (5 diffs)
- trunk/src/z-util.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/Makefile.src
r545 r569 6 6 # 7 7 8 VERSION = 3. 0.98 VERSION = 3.1.0 9 9 10 HDRS = h-basic.h 11 INCS = angband.h config.h defines.h externs.h types.h option.h main-gtk.h cairo-utils.h \ 12 z-term.h z-rand.h z-type.h z-util.h z-virt.h z-form.h 10 HEADERS = \ 11 angband.h \ 12 cairo-utils.h \ 13 cmds.h \ 14 compress.h \ 15 config.h \ 16 defines.h \ 17 effects.h \ 18 externs.h \ 19 game-cmd.h \ 20 game-event.h \ 21 h-basic.h \ 22 init.h \ 23 maid-x11.h \ 24 main-gtk.h \ 25 main.h \ 26 option.h \ 27 randname.h \ 28 types.h \ 29 ui-event.h \ 30 ui.h \ 31 ui-menu.h \ 32 z-blockfile.h \ 33 z-file.h \ 34 z-form.h \ 35 z-msg.h \ 36 z-quark.h \ 37 z-rand.h \ 38 z-smap.h \ 39 z-term.h \ 40 z-type.h \ 41 z-util.h \ 42 z-virt.h 13 43 14 44 ZFILES = z-file.o z-form.o z-msg.o z-quark.o z-rand.o z-term.o z-type.o \ trunk/src/Makefile.std
r545 r569 112 112 install: ../$(EXE) 113 113 114 docs: doc/index.html 114 115 115 116 ../$(EXE): $(EXE) … … 160 161 161 162 # X11 dependencies 162 $(X11OBJS) : $( INCS) maid-x11.h main.h163 $(X11OBJS) : $(HEADERS) maid-x11.h main.h 163 164 164 165 # Basic dependencies for main-xxx.c, main.c 165 $(MAINOBJS) : main.h $( INCS)166 $(MAINOBJS) : main.h $(HEADERS) 166 167 167 168 # fake Dependency 169 doc/index.html: $(HEADERS) 170 doxygen doc/doxygen.conf trunk/src/z-blockfile.h
r515 r569 8 8 /*** Constants ***/ 9 9 10 /* 10 /** 11 11 * For use with bf_open(). Indicate mode of file opening, and when "BF_SAVE" 12 12 * is set, the file will be marked as a savefile on participating OSes. … … 25 25 26 26 27 /* 27 /** 28 28 * The basic "blockfile" type. 29 29 * … … 41 41 }; 42 42 43 /* 43 /** 44 44 * A block, stored in a blockfile 45 45 * … … 58 58 }; 59 59 60 /* 60 /** 61 61 * A record in a block. 62 62 */ … … 73 73 /** Opening/saving/closing **/ 74 74 75 /* 75 /** 76 76 * Open a new blockfile, with the filename "name" and flags as follows: 77 77 * … … 86 86 blockfile_t *bf_open(const char *name, u32b flags); 87 87 88 /* 88 /** 89 89 * Save all currently held data to the blockfile. 90 90 * … … 94 94 void bf_save(blockfile_t *bf); 95 95 96 /* 96 /** 97 97 * Close a blockfile handle. 98 98 * … … 105 105 /** Block info **/ 106 106 107 /* 107 /** 108 108 * Returns the number of blocks in the blockfile represented by `bf`. 109 109 */ … … 113 113 /** Block creation **/ 114 114 115 /* 115 /** 116 116 * Create a new block in the blockfile `bf` with name `name`. 117 117 * … … 126 126 /** Finding blocks **/ 127 127 128 /* 128 /** 129 129 * Finds a block in the blockfile `bf` with the name `name`. 130 130 * … … 134 134 block_t *bf_findblock(blockfile_t *bf, const char *name); 135 135 136 /* 136 /** 137 137 * Return the next block in the blockfile `bf`. 138 138 * … … 145 145 block_t *bf_nextblock(blockfile_t *bf); 146 146 147 /* 147 /** 148 148 * Reset the current block in the blockfile `bf`. This is only useful if, 149 149 * having once iterated through some blocks in the file, you want to return to … … 153 153 154 154 155 /* 155 /** 156 156 * Calls the provided function for each block in the file `bf`, in the order in 157 157 * which they were written. … … 162 162 /** Block information **/ 163 163 164 /* 164 /** 165 165 * Returns the name of block `block`. 166 166 */ 167 167 const char *bf_name(block_t *block); 168 168 169 /* 169 /** 170 170 * Returns the size of block `block`. 171 171 */ 172 172 u32b bf_blocksize(block_t *block); 173 173 174 /* 174 /** 175 175 * Returns the number of records stored within the block `block`. 176 176 */ … … 181 181 /** Record creation and reading **/ 182 182 183 /* 183 /** 184 184 * Create a new record in the block `block`, with data `data` of length `len`. 185 185 * … … 189 189 void bf_createrecord(block_t *block, void *data, u32b len); 190 190 191 /* 191 /** 192 192 * Return the data of the next record in the block `block`, and place the 193 193 * length of this data in *`len`. … … 201 201 const void *bf_nextrecord(block_t *block, u32b *len); 202 202 203 /* 203 /** 204 204 * Reset the current record in the block `block`. This is only useful if, 205 205 * having once iterated through some records in the block, you want to return … … 208 208 void bf_rewindrecord(block_t *block); 209 209 210 /* 210 /** 211 211 * Calls the supplied `fn` to iterate over each record in the block `block`. 212 212 */ trunk/src/z-file.h
r536 r569 6 6 /*** Permissions code ***/ 7 7 8 /* 8 /** 9 9 * Player's user ID and group ID, respectively. 10 10 * … … 14 14 extern int player_egid; 15 15 16 /* 16 /** 17 17 * Drop or grab privileges. 18 18 * … … 32 32 /*** Path building code ***/ 33 33 34 /* 34 /** 35 35 * Concatenates "leaf" onto the end of "base", using system-specific path 36 36 * separators, and places the result in buf[], truncated to "len" bytes. … … 44 44 /*** Byte-flipping functions ***/ 45 45 46 /* 46 /** 47 47 * "Flip" the bits of the integer specified in `arg` to make them big-endian. 48 48 * Useful when writing to files intended to be portable across systems. … … 60 60 /** Data types **/ 61 61 62 /* 62 /** 63 63 * An opaque file handle for Angband file handling. 64 64 */ 65 65 typedef struct ang_file ang_file; 66 66 67 /* 67 /** 68 68 * Specifies what kind of access is required to a file. See file_open(). 69 69 */ … … 75 75 } file_mode; 76 76 77 /* 78 * Specifie dwhat kind of thing a file is, when writing. See file_open().77 /** 78 * Specifies what kind of thing a file is, when writing. See file_open(). 79 79 */ 80 80 typedef enum … … 89 89 /** Utility functions **/ 90 90 91 /* 91 /** 92 92 * Returns TRUE if `fname` exists (and is a file), FALSE otherwise. 93 93 */ 94 94 bool file_exists(const char *fname); 95 95 96 /* 96 /** 97 97 * Tries to delete `fname`. 98 98 * … … 101 101 bool file_delete(const char *fname); 102 102 103 /* 103 /** 104 104 * Moves the file `fname` to `newname`. 105 105 * … … 108 108 bool file_move(const char *fname, const char *newname); 109 109 110 /* 110 /** 111 111 * Returns TRUE if the file `first` is newer than `second`. 112 112 */ … … 116 116 /** File handle creation **/ 117 117 118 /* 118 /** 119 119 * Open file `buf`, returning a a file handling representing that file. 120 120 * … … 133 133 ang_file *file_open(const char *buf, file_mode mode, file_type ftype); 134 134 135 /* 135 /** 136 136 * Attempt to close the file handle `f`. 137 137 * … … 143 143 /** File locking **/ 144 144 145 /* 145 /** 146 146 * Lock or unlock the file represented by `f` for writing. 147 147 * If the file is not open for writing, this call will fail. … … 155 155 /** Line-based IO **/ 156 156 157 /* 157 /** 158 158 * Get a line of text from the file represented by `f`, placing it into `buf` 159 159 * to a maximum length of `n`. … … 166 166 bool file_getl(ang_file *f, char *buf, size_t n); 167 167 168 /* 168 /** 169 169 * Write the string pointed to by `buf` to the file represented by `f`. 170 170 * … … 173 173 bool file_put(ang_file *f, const char *buf); 174 174 175 /* 175 /** 176 176 * Format (using strnfmt) the given args, and then call file_put(). 177 177 */ … … 181 181 /** Byte-based IO */ 182 182 183 /* 183 /** 184 184 * Seek to position `pos` in the file represented by `f`. 185 185 * … … 188 188 bool file_seek(ang_file *f, u32b pos); 189 189 190 /* 190 /** 191 191 * Reads `n` bytes from the file represented by `f` into the buffer `buf`. 192 192 * Do not mix with calls to file_readc(). … … 196 196 size_t file_read(ang_file *f, char *buf, size_t n); 197 197 198 /* 198 /** 199 199 * Write the first `n` bytes following the pointer `buf` to the file represented 200 200 * by `f`. Do not mix with calls to file_writec(). … … 204 204 bool file_write(ang_file *f, const char *buf, size_t n); 205 205 206 /* 206 /** 207 207 * Read a byte from the file represented by `f` and place it at the location 208 208 * specified by 'b'. … … 212 212 bool file_readc(ang_file *f, byte *b); 213 213 214 /* 214 /** 215 215 * Write the byte `b` to the file represented by `f`. 216 216 * … … 223 223 /*** Directory code ***/ 224 224 225 /* 225 /** 226 226 * An opaque file handle for Angband directory handling. 227 227 */ … … 229 229 230 230 231 /* 231 /** 232 232 * Opens a directory handle. 233 233 * … … 239 239 ang_dir *my_dopen(const char *dirname); 240 240 241 /* 241 /** 242 242 * Reads a directory entry. 243 243 * … … 250 250 bool my_dread(ang_dir *dir, char *fname, size_t len); 251 251 252 /* 252 /** 253 253 * Close a directory handle. 254 254 */ trunk/src/z-form.h
r155 r569 1 /* File z-form.h */2 3 /*4 * Copyright (c) 1997 Ben Harrison5 *6 * This software may be copied and distributed for educational, research,7 * and not for profit purposes provided that this copyright and statement8 * are included in all such copies.9 */10 11 1 #ifndef INCLUDED_Z_FORM_H 12 2 #define INCLUDED_Z_FORM_H trunk/src/z-msg.h
r514 r569 171 171 /** Initialisation/exit **/ 172 172 173 /* 173 /** 174 174 * Initialise the messages package. Should be called before using any other 175 175 * functions in the package. … … 177 177 errr messages_init(void); 178 178 179 /* 179 /** 180 180 * Free the message package. 181 181 */ … … 185 185 /** General info **/ 186 186 187 /* 187 /** 188 188 * Return the current number of messages stored. 189 189 */ … … 193 193 /** Individual message handling **/ 194 194 195 /* 195 /** 196 196 * Save a new message into the memory buffer, with text `str` and type `type`. 197 197 * The type should be one of the MSG_ constants defined above. … … 204 204 205 205 206 /* 206 /** 207 207 * Returns the text of the message of age `age`. The age of the most recently 208 208 * saved message is 0, the one before that is of age 1, etc. … … 213 213 const char *message_str(u16b age); 214 214 215 /* 215 /** 216 216 * Returns the number of times the message of age `age` was saved. The age of 217 217 * the most recently saved message is 0, the one before that is of age 1, etc. … … 223 223 u16b message_count(u16b age); 224 224 225 /* 225 /** 226 226 * Returns the type of the message of age `age`. The age of the most recently 227 227 * saved message is 0, the one before that is of age 1, etc. … … 231 231 u16b message_type(u16b age); 232 232 233 /* 233 /** 234 234 * Returns the display colour of the message memorised `age` messages ago. 235 235 * (i.e. age = 0 represents the last memorised message, age = 1 is the one … … 241 241 /** Message type changes **/ 242 242 243 /* 243 /** 244 244 * Returns the colour for the message type `type`. 245 245 */ 246 246 byte message_type_color(u16b type); 247 247 248 /* 248 /** 249 249 * Defines the color `color` for the message type `type`. 250 250 */ trunk/src/z-rand.h
r461 r569 1 /* File: z-rand.h */2 3 /*4 * Copyright (c) 1997 Ben Harrison, and others5 *6 * This software may be copied and distributed for educational, research,7 * and not for profit purposes provided that this copyright and statement8 * are included in all such copies. Other copyrights may also apply.9 */10 11 1 #ifndef INCLUDED_Z_RAND_H 12 2 #define INCLUDED_Z_RAND_H … … 15 5 16 6 7 /**** Constants ****/ 17 8 18 /**** Available constants ****/ 19 20 21 /* 9 /** 22 10 * The "degree" of the "complex" Random Number Generator. 23 11 * This value is hard-coded at 63 for a wide variety of reasons. … … 27 15 28 16 29 30 17 /**** Available macros ****/ 31 18 32 33 /* 34 * Generates a random long integer X where O<=X<M.19 /** 20 * Generates a random signed long integer X where "0 <= X < M" holds. 21 * 35 22 * The integer X falls along a uniform distribution. 36 * For example, if M is 100, you get "percentile dice"37 23 */ 38 #define rand_int(M) \ 39 ((s32b)(Rand_div(M))) 24 #define rand_int(M) ((s32b) Rand_div(M)) 40 25 41 26 42 /* 43 * Generates a random long integer X where 1<=X<=M.27 /** 28 * Generates a random signed long integer X where "1 <= X <= M" holds. 44 29 * 45 * Note that the behaviour for M < 1 is undefined.30 * The integer X falls along a uniform distribution. 46 31 */ 47 #define randint(M) \ 48 (rand_int(M) + 1) 49 50 /* 51 * Generates a random long integer X where 1<=X<=M. 52 * 53 * Note that the behaviour for M < 1 is undefined. 54 */ 55 #define rand_die(M) \ 56 (rand_int(M) + 1) 32 #define randint(M) ((s32b) Rand_div(M) + 1) 33 #define rand_die(M) (rand_int(M) + 1) 57 34 58 35 59 /* 60 * Generates a random long integer X where A<=X<=B 36 /** 37 * Generates a random signed long integer X where "A <= X <= B" 38 * Note that "rand_range(0, N-1)" == "rand_int(N)" 39 * 61 40 * The integer X falls along a uniform distribution. 62 * Note: rand_range(0,N-1) == rand_int(N)63 41 */ 64 #define rand_range(A,B) \ 65 ((A) + (rand_int(1+(B)-(A)))) 42 #define rand_range(A,B) ((A) + (rand_int(1+(B)-(A)))) 66 43 67 /* 68 * Generate a random long integer X where A-D<=X<=A+D 44 45 /** 46 * Generate a random signed long integer X where "A-D <= X <= A+D" holds. 47 * Note that "rand_spread(A, D)" == "rand_range(A-D, A+D)" 48 * 69 49 * The integer X falls along a uniform distribution. 70 * Note: rand_spread(A,D) == rand_range(A-D,A+D)71 50 */ 72 #define rand_spread(A,D) \ 73 ((A) + (rand_int(1+(D)+(D))) - (D)) 51 #define rand_spread(A,D) ((A) + (rand_int(1+(D)+(D))) - (D)) 74 52 75 53 … … 77 55 /**** Available Variables ****/ 78 56 79 57 /** 58 * Do not tweak these variables. 59 */ 80 60 extern bool Rand_quick; 81 61 extern u32b Rand_value; … … 86 66 /**** Available Functions ****/ 87 67 68 /** 69 * Initialise the RNG state with the given seed. 70 */ 71 void Rand_state_init(u32b seed); 88 72 89 extern void Rand_state_init(u32b seed); 90 extern u32b Rand_div(u32b m); 91 extern s16b Rand_normal(int mean, int stand); 92 extern u32b Rand_simple(u32b m); 73 /** 74 * Generates a random unsigned long integer X where "0 <= X < M" holds. 75 * 76 * The integer X falls along a uniform distribution. 77 */ 78 u32b Rand_div(u32b m); 93 79 94 extern int damroll(int num, int sides); 80 /** 81 * Generate a signed random integer within `stand` standard deviations of 82 * `mean`, following a normal distribution. 83 */ 84 s16b Rand_normal(int mean, int stand); 85 86 /** 87 * Generate a semi-random number from 0 to m-1, in a way that doesn't affect 88 * gameplay. This is intended for use by external program parts like the 89 * main-*.c files. 90 */ 91 u32b Rand_simple(u32b m); 92 93 /** 94 * Emulate a number `num` of dice rolls of dice with `sides` sides. 95 */ 96 int damroll(int num, int sides); 95 97 96 98 trunk/src/z-util.h
r337 r569 1 /* File z-util.h */2 3 /*4 * Copyright (c) 1997 Ben Harrison5 *6 * This software may be copied and distributed for educational, research,7 * and not for profit purposes provided that this copyright and statement8 * are included in all such copies.9 */10 11 1 #ifndef INCLUDED_Z_UTIL_H 12 2 #define INCLUDED_Z_UTIL_H … … 15 5 16 6 17 /*18 * Extremely basic stuff, like global temp and constant variables.19 * Also, some very useful low level functions, such as "streq()".20 * All variables and functions in this file are "addressable".21 */22 23 24 7 /**** Available variables ****/ 25 8 26 /* A cptr to the name of the program */ 27 extern cptr argv0; 9 /** 10 * The name of the program. 11 */ 12 extern const char *argv0; 28 13 29 14 … … 35 20 /**** Available Functions ****/ 36 21 37 /* Case insensitive comparison between two strings */ 22 /** 23 * Case insensitive comparison between two strings 24 */ 38 25 extern int my_stricmp(const char *s1, const char *s2); 26 27 /** 28 * Case insensitive comparison between two strings, up to n characters long. 29 */ 39 30 extern int my_strnicmp(cptr a, cptr b, int n); 40 31 41 /* Case-insensitive strstr */ 32 /** 33 * Case-insensitive strstr 34 */ 42 35 extern char *my_stristr(const char *string, const char *pattern); 43 36 44 /* Copy a string */ 37 /** 38 * Copy up to 'bufsize'-1 characters from 'src' to 'buf' and NULL-terminate 39 * the result. The 'buf' and 'src' strings may not overlap. 40 * 41 * Returns: strlen(src). This makes checking for truncation 42 * easy. Example: 43 * if (my_strcpy(buf, src, sizeof(buf)) >= sizeof(buf)) ...; 44 * 45 * This function should be equivalent to the strlcpy() function in BSD. 46 */ 45 47 extern size_t my_strcpy(char *buf, const char *src, size_t bufsize); 46 48 47 /* Concatenate two strings */ 49 /** 50 * Try to append a string to an existing NULL-terminated string, never writing 51 * more characters into the buffer than indicated by 'bufsize', and 52 * NULL-terminating the buffer. The 'buf' and 'src' strings may not overlap. 53 * 54 * my_strcat() returns strlen(buf) + strlen(src). This makes checking for 55 * truncation easy. Example: 56 * if (my_strcat(buf, src, sizeof(buf)) >= sizeof(buf)) ...; 57 * 58 * This function should be equivalent to the strlcat() function in BSD. 59 */ 48 60 extern size_t my_strcat(char *buf, const char *src, size_t bufsize); 49 61
