/* Purpose: Angband utilities -BEN- */
#include "angband.h"
+#include "monster-hook.h"
static int num_more = 0;
/* Temp file */
s = tmpnam(NULL);
- /* Oops */
if (!s) return (-1);
/* Format to length */
errr my_fgets(FILE *fff, char *buf, huge n)
{
huge i = 0;
-
char *s;
-
char tmp[1024];
/* Read a line */
/*
* Hack -- replacement for "fputs()"
- *
* Dump a string, plus a newline, to a file
- *
- * XXX XXX XXX Process internal weirdness?
+ * Process internal weirdness?
*/
errr my_fputs(FILE *fff, cptr buf, huge n)
{
/*
- * Code Warrior is a little weird about some functions
- */
-#ifdef BEN_HACK
-extern int open(const char *, int, ...);
-extern int close(int);
-extern int read(int, void *, unsigned int);
-extern int write(int, const void *, unsigned int);
-extern long lseek(int, long, int);
-#endif /* BEN_HACK */
-
-
-/*
* The Macintosh is a little bit brain-dead sometimes
*/
#ifdef MACINTOSH
/* Remove */
(void)remove(buf);
- /* XXX XXX XXX */
return (0);
}
/* Rename */
(void)rename(buf, aux);
- /* XXX XXX XXX */
return (0);
}
fd_close(src_fd);
fd_close(dst_fd);
- /* XXX XXX XXX */
return (0);
}
/*
* Hack -- attempt to open a file descriptor (create file)
- *
* This function should fail if the file already exists
- *
* Note that we assume that the file should be "binary"
- *
- * XXX XXX XXX The horrible "BEN_HACK" code is for compiling under
- * the CodeWarrior compiler, in which case, for some reason, none
- * of the "O_*" flags are defined, and we must fake the definition
- * of "O_RDONLY", "O_WRONLY", and "O_RDWR" in "A-win-h", and then
- * we must simulate the effect of the proper "open()" call below.
*/
-int fd_make(cptr file, int mode)
+int fd_make(cptr file, BIT_FLAGS mode)
{
char buf[1024];
/* Hack -- Try to parse the path */
if (path_parse(buf, 1024, file)) return (-1);
-#ifdef BEN_HACK
-
- /* Check for existance */
- /* if (fd_close(fd_open(file, O_RDONLY | O_BINARY))) return (1); */
-
- /* Mega-Hack -- Create the file */
- (void)my_fclose(my_fopen(file, "wb"));
-
- /* Re-open the file for writing */
- return (open(buf, O_WRONLY | O_BINARY, mode));
-
-#else /* BEN_HACK */
-
#if defined(MAC_MPW) || defined(MACH_O_CARBON)
{
int fdes;
/* Return the descriptor */
return (fdes);
}
-# else
+#else
/* Create the file, fail if exists, write-only, binary */
return (open(buf, O_CREAT | O_EXCL | O_WRONLY | O_BINARY, mode));
-# endif
+#endif
-#endif /* BEN_HACK */
}
/* Close */
(void)close(fd);
- /* XXX XXX XXX */
return (0);
}
/*
- * XXX XXX XXX Important note about "colors" XXX XXX XXX
+ * Important note about "colors"
*
* The "TERM_*" color definitions list the "composition" of each
* "Angband color" in terms of "quarters" of each of the three color
/* Hex-mode XXX */
if (*str == 'x')
{
- *s = 16 * dehex(*++str);
- *s++ += dehex(*++str);
+ *s = 16 * (char)dehex(*++str);
+ *s++ += (char)dehex(*++str);
}
/* Hack -- simple way to specify "backslash" */
/* Octal-mode */
else if (*str == '0')
{
- *s = 8 * deoct(*++str);
- *s++ += deoct(*++str);
+ *s = 8 * (char)deoct(*++str);
+ *s++ += (char)deoct(*++str);
}
/* Octal-mode */
else if (*str == '1')
{
- *s = 64 + 8 * deoct(*++str);
- *s++ += deoct(*++str);
+ *s = 64 + 8 * (char)deoct(*++str);
+ *s++ += (char)deoct(*++str);
}
/* Octal-mode */
else if (*str == '2')
{
- *s = 64 * 2 + 8 * deoct(*++str);
- *s++ += deoct(*++str);
+ *s = 64 * 2 + 8 * (char)deoct(*++str);
+ *s++ += (char)deoct(*++str);
}
/* Octal-mode */
else if (*str == '3')
{
- *s = 64 * 3 + 8 * deoct(*++str);
- *s++ += deoct(*++str);
+ *s = 64 * 3 + 8 * (char)deoct(*++str);
+ *s++ += (char)deoct(*++str);
}
/* Skip the final char */
switch(ch)
{
case '&':
- while ((tmp = my_strchr(macro_modifier_chr, *str)))
+ while ((tmp = my_strchr(macro_modifier_chr, *str)) != 0)
{
j = (int)(tmp - macro_modifier_chr);
tmp = macro_modifier_name[j];
n = i;
s = t;
}
-
- /* Result */
return (n);
}
* Add a macro definition (or redefinition).
*
* We should use "act == NULL" to "remove" a macro, but this might make it
- * impossible to save the "removal" of a macro definition. XXX XXX XXX
+ * impossible to save the "removal" of a macro definition.
*
* We should consider refusing to allow macros which contain existing macros,
* or which are contained in existing macros, because this would simplify the
- * macro analysis code. XXX XXX XXX
+ * macro analysis code.
*
* We should consider removing the "command macro" crap, and replacing it
* with some kind of "powerful keymap" ability, but this might make it hard
- * to change the "roguelike" option from inside the game. XXX XXX XXX
+ * to change the "roguelike" option from inside the game.
*/
errr macro_add(cptr pat, cptr act)
{
/*
* Hack -- Select floor music.
*/
-void select_floor_music()
+void select_floor_music(void)
{
int i;
/* No sound */
return;
}
- for(i = 0; i < max_quests; i++)
+ for(i = 0; i < max_q_idx; i++)
{ // TODO マクロで類似条件を統合すること
if(quest[i].status == QUEST_STATUS_TAKEN &&
(quest[i].type == QUEST_TYPE_KILL_LEVEL || quest[i].type == QUEST_TYPE_RANDOM) &&
* Only 500 (0+1+2+...+29+30) milliseconds may elapse between each key in
* the macro trigger sequence. If a key sequence forms the "prefix" of a
* macro trigger, 500 milliseconds must pass before the key sequence is
- * known not to be that macro trigger. XXX XXX XXX
+ * known not to be that macro trigger.
*/
static char inkey_aux(void)
{
/* Excessive delay */
if (w >= 10) break;
- /* Delay */
Term_xtra(TERM_XTRA_DELAY, w);
}
}
/*
- * Mega-Hack -- special "inkey_next" pointer. XXX XXX XXX
+ * Mega-Hack -- special "inkey_next" pointer.
*
* This special pointer allows a sequence of keys to be "inserted" into
* the stream of keys returned by "inkey()". This key sequence will not
#ifdef ALLOW_BORG
/*
- * Mega-Hack -- special "inkey_hack" hook. XXX XXX XXX
+ * Mega-Hack -- special "inkey_hack" hook.
*
* This special function hook allows the "Borg" (see elsewhere) to take
* control of the "inkey()" function, and substitute in fake keypresses.
/* Wait for (and remove) a pending key */
if (0 == Term_inkey(&ch, TRUE, TRUE))
{
- /* Done */
break;
}
- /* Oops */
break;
}
/* Check for (and remove) a pending key */
if (0 == Term_inkey(&ch, FALSE, TRUE))
{
- /* Done */
break;
}
/* Excessive delay */
if (w >= 100) break;
- /* Delay */
Term_xtra(TERM_XTRA_DELAY, w);
}
}
- /* Done */
break;
}
{
/* Strip this key */
ch = 0;
-
- /* Continue */
continue;
}
/*
* Add a new "quark" to the set of quarks.
*/
-s16b quark_add(cptr str)
+u16b quark_add(cptr str)
{
- int i;
+ u16b i;
/* Look for an existing quark */
for (i = 1; i < quark__num; i++)
/*
* This function looks up a quark
*/
-cptr quark_str(s16b i)
+cptr quark_str(STR_OFFSET i)
{
cptr q;
*/
void message_add(cptr str)
{
- int i, k, x, m, n;
+ u32b i, n;
+ int k, x, m;
char u[4096];
char splitted1[81];
now_message++;
}
- /* Done */
break;
}
* The global "msg_flag" variable can be cleared to tell us to
* "erase" any "pending" messages still on the screen.
*
- * XXX XXX XXX Note that we must be very careful about using the
+ * Note that we must be very careful about using the
* "msg_print()" functions without explicitly calling the special
* "msg_print(NULL)" function, since this may result in the loss
* of information if the screen is cleared, or if anything is
* displayed on the top line.
*
- * XXX XXX XXX Note that "msg_print(NULL)" will clear the top line
+ * Note that "msg_print(NULL)" will clear the top line
* even if no messages are pending. This is probably a hack.
*/
void msg_print(cptr msg)
/* Hack -- flush when requested or needed */
if (p && (!msg || ((p + n) > 72)))
{
- /* Flush */
msg_flush(p);
/* Forget it */
}
else
{
- sprintf(buf, ("T:%d - %s"), turn, msg);
+ sprintf(buf, ("T:%d - %s"), (int)turn, msg);
}
/* New Message Length */
- n = (buf ? strlen(buf) : 0);
+ n = strlen(buf);
/* Memorize the message */
if (character_generated) message_add(buf);
/* Memorize the tail */
/* if (character_generated) message_add(t); */
- /* Window stuff */
p_ptr->window |= (PW_MESSAGE);
window_stuff();
* At the given location, using the given attribute, if allowed,
* add the given string. Do not clear the line.
*/
-void c_put_str(byte attr, cptr str, int row, int col)
+void c_put_str(TERM_COLOR attr, cptr str, int row, int col)
{
/* Position cursor, Dump the attr/text */
Term_putstr(col, row, -1, attr, str);
{
int i, n = 0;
- byte av[256];
+ TERM_COLOR av[256];
char cv[256];
/* Wrap word */
{
bool res;
- /* Paranoia XXX XXX XXX */
+ /* Paranoia */
msg_print(NULL);
/* Display prompt */
/* Clear prompt */
prt("", 0, 0);
-
- /* Result */
return (res);
}
* mode & CHECK_NO_HISTORY : no message_add
* mode & CHECK_DEFAULT_Y : accept any key as y, except n and Esc.
*/
-bool get_check_strict(cptr prompt, int mode)
+bool get_check_strict(cptr prompt, BIT_FLAGS mode)
{
int i;
char buf[80];
num_more = 0;
}
- /* Paranoia XXX XXX XXX */
+ /* Paranoia */
msg_print(NULL);
if (!rogue_like_commands)
*/
bool get_com(cptr prompt, char *command, bool z_escape)
{
- /* Paranoia XXX XXX XXX */
+ /* Paranoia */
msg_print(NULL);
/* Display a prompt */
*
* Hack -- allow "command_arg" to specify a quantity
*/
-s16b get_quantity(cptr prompt, int max)
+QUANTITY get_quantity(cptr prompt, QUANTITY max)
{
- bool res;
- int amt;
+ bool res, result;
+ QUANTITY amt;
char tmp[80];
char buf[80];
+ COMMAND_CODE code;
/* Use "command_arg" */
return (amt);
}
-#ifdef ALLOW_REPEAT /* TNB */
-
/* Get the item index */
- if ((max != 1) && repeat_pull(&amt))
+ result = repeat_pull(&code);
+ amt = (QUANTITY)code;
+ if ((max != 1) && result)
{
/* Enforce the maximum */
if (amt > max) amt = max;
return (amt);
}
-#endif /* ALLOW_REPEAT -- TNB */
-
/* Build a prompt if needed */
if (!prompt)
{
prompt = tmp;
}
- /* Paranoia XXX XXX XXX */
+ /* Paranoia */
msg_print(NULL);
/* Display prompt */
if (!res) return 0;
/* Extract a number */
- amt = atoi(buf);
+ amt = (COMMAND_CODE)atoi(buf);
/* A letter means "all" */
if (isalpha(buf[0])) amt = max;
/* Enforce the minimum */
if (amt < 0) amt = 0;
-#ifdef ALLOW_REPEAT /* TNB */
-
- if (amt) repeat_push(amt);
-
-#endif /* ALLOW_REPEAT -- TNB */
+ if (amt) repeat_push((COMMAND_CODE)amt);
/* Return the result */
return (amt);
/*
- * Pause for user response XXX XXX XXX
+ * Pause for user response
*/
void pause_line(int row)
{
* Note that this command is used both in the dungeon and in
* stores, and must be careful to work in both situations.
*
- * Note that "p_ptr->command_new" may not work any more. XXX XXX XXX
+ * Note that "p_ptr->command_new" may not work any more.
*/
void request_command(int shopping)
{
int i;
- char cmd;
+ s16b cmd;
int mode;
cptr act;
/* Command Count */
if (cmd == '0')
{
- int old_arg = command_arg;
+ COMMAND_ARG old_arg = command_arg;
/* Reset */
command_arg = 0;
{
/* Clear count */
command_arg = 0;
-
- /* Continue */
continue;
}
}
/* Start using the buffer */
inkey_next = request_command_buffer;
-
- /* Continue */
continue;
}
/* Use command */
command_cmd = (byte)cmd;
- /* Done */
break;
}
if (always_repeat && (command_arg <= 0))
{
/* Hack -- auto repeat certain commands */
- if (my_strchr("TBDoc+", command_cmd))
+ if (my_strchr("TBDoc+", (char)command_cmd))
{
/* Repeat 99 times */
command_arg = 99;
}
else
{
- int mode;
+ BIT_FLAGS mode;
cptr act, s;
/* Roguelike */
}
-#ifdef ALLOW_REPEAT /* TNB */
-
#define REPEAT_MAX 20
/* Number of chars saved */
static int repeat__idx = 0;
/* Saved "stuff" */
-static int repeat__key[REPEAT_MAX];
+static COMMAND_CODE repeat__key[REPEAT_MAX];
-void repeat_push(int what)
+void repeat_push(COMMAND_CODE what)
{
/* Too many keys */
if (repeat__cnt == REPEAT_MAX) return;
}
-bool repeat_pull(int *what)
+bool repeat_pull(COMMAND_CODE *what)
{
/* All out of keys */
if (repeat__idx == repeat__cnt) return (FALSE);
void repeat_check(void)
{
- int what;
+ COMMAND_CODE what;
/* Ignore some commands */
if (command_cmd == ESCAPE) return;
}
}
-#endif /* ALLOW_REPEAT -- TNB */
-
#ifdef SORT_R_INFO
continue;
}
#endif
- *str = tolower(*str);
+ *str = (char)tolower(*str);
}
}