robots.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* $NetBSD: robots.h,v 1.18 2004/01/27 20:30:30 jsm Exp $ */
  2. /*
  3. * Copyright (c) 1980, 1993
  4. * The Regents of the University of California. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. Neither the name of the University nor the names of its contributors
  15. * may be used to endorse or promote products derived from this software
  16. * without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  22. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  24. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  25. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  26. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  27. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. * SUCH DAMAGE.
  29. *
  30. * @(#)robots.h 8.1 (Berkeley) 5/31/93
  31. */
  32. # include <sys/ttydefaults.h>
  33. # include <sys/endian.h>
  34. # include <ctype.h>
  35. # include <curses.h>
  36. # include <err.h>
  37. # include <errno.h>
  38. # include <fcntl.h>
  39. # include <pwd.h>
  40. # include <setjmp.h>
  41. # include <signal.h>
  42. # include <stdlib.h>
  43. # include <string.h>
  44. # include <termios.h>
  45. # include <unistd.h>
  46. /*
  47. * miscellaneous constants
  48. */
  49. # define Y_FIELDSIZE 23
  50. # define X_FIELDSIZE 60
  51. # define Y_SIZE 24
  52. # define X_SIZE 80
  53. # define MAXLEVELS 4
  54. # define MAXROBOTS (MAXLEVELS * 10)
  55. # define ROB_SCORE 10
  56. # undef S_BONUS
  57. # define S_BONUS (60 * ROB_SCORE)
  58. # define Y_SCORE 21
  59. # define X_SCORE (X_FIELDSIZE + 9)
  60. # define Y_PROMPT (Y_FIELDSIZE - 1)
  61. # define X_PROMPT (X_FIELDSIZE + 2)
  62. # define MAXSCORES (Y_SIZE - 2)
  63. # define MAXNAME 16
  64. # define MS_NAME "Ten"
  65. /*
  66. * characters on screen
  67. */
  68. # define ROBOT '+'
  69. # define HEAP '*'
  70. # define PLAYER '@'
  71. /*
  72. * type definitions
  73. */
  74. typedef struct {
  75. int y, x;
  76. } COORD;
  77. typedef struct {
  78. u_int32_t s_uid;
  79. u_int32_t s_score;
  80. u_int32_t s_auto;
  81. u_int32_t s_level;
  82. char s_name[MAXNAME];
  83. } SCORE;
  84. typedef struct passwd PASSWD;
  85. /*
  86. * global variables
  87. */
  88. extern bool Dead, Full_clear, Jump, Newscore, Real_time, Running,
  89. Teleport, Waiting, Was_bonus, Auto_bot;
  90. #ifdef FANCY
  91. extern bool Pattern_roll, Stand_still;
  92. #endif
  93. extern char Cnt_move, Field[Y_FIELDSIZE][X_FIELDSIZE], Run_ch;
  94. extern const char *Next_move, *Move_list;
  95. extern int Count, Level, Num_robots, Num_scrap, Num_scores,
  96. Start_level, Wait_bonus, Num_games;
  97. extern u_int32_t Score;
  98. extern COORD Max, Min, My_pos, Robots[], Scrap[];
  99. extern jmp_buf End_move;
  100. /*
  101. * functions types
  102. */
  103. void add_score(int);
  104. bool another(void);
  105. char automove(void);
  106. int cmp_sc(const void *, const void *);
  107. bool do_move(int, int);
  108. bool eaten(const COORD *);
  109. void flush_in(void);
  110. void get_move(void);
  111. void init_field(void);
  112. bool jumping(void);
  113. void make_level(void);
  114. void move_robots(int);
  115. bool must_telep(void);
  116. void play_level(void);
  117. int query(const char *);
  118. void quit(int) __attribute__((__noreturn__));
  119. void reset_count(void);
  120. int rnd(int);
  121. COORD *rnd_pos(void);
  122. void score(int);
  123. void set_name(SCORE *);
  124. void show_score(void);
  125. int sign(int);
  126. void telmsg(int);