home *** CD-ROM | disk | FTP | other *** search
- /* vars.c 8/4/91
- *
- * Copyright 1991 Perry R. Ross
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation without fee is hereby granted, subject to the restrictions
- * detailed in the README file, which is included here by reference.
- * Any other use requires written permission from the author. This software
- * is distributed "as is" without any warranty, including any implied
- * warranties of merchantability or fitness for a particular purpose.
- * The author shall not be liable for any damages resulting from the
- * use of this software. By using this software, the user agrees
- * to these terms.
- */
-
- #include "ldb.h"
-
- /*======================================================================
- * This file contains the definition for all global variables, as well
- * as the static initialization values for those that need it.
- *======================================================================
- */
-
- int Pflag; /* should I process local input? */
- int Rflag; /* should I look for mail? */
- struct game *ghead; /* head of linked list of games */
- struct game *gtail; /* tail of linked list of games */
- struct legal *lhead; /* head of list of legal moves */
- struct legal *ltail; /* tail of list of legal moves */
- struct packet P; /* last packet read */
- char cr_mycolor; /* my color when game is created */
- char cr_opcolor; /* opponent's color for new games */
- char cr_mydir; /* my direction for new games */
- char blk76[] = /* 76 blanks */
- " ";
-
- char FeIsActive = 0; /* has the front-end been initialized? */
-
- char *states[] = { /* description of the states */
- "Waiting for opponent to start game",
- "Waiting for opponent to move",
- "Waiting for opponent to accept double",
- "Your turn (you haven't rolled yet)",
- "Your move (you have rolled)",
- "Waiting for you to accept double",
- "Game over"
- };
-
- struct opt options[] = {
- "read", OPT_READ, "",
- "\t\t\tRead incoming mail but do not play",
- "play", OPT_PLAY, "",
- "\t\t\tPlay any waiting games but do not read mail",
- "color", OPT_COLOR, " xx",
- "\t\tSet colors for new game [r, w, and b]",
- "direction", OPT_DIRECTION, " dir",
- "\t\tSet direction for new game [up or down]",
- "myaddr", OPT_MYADDR, " addr",
- "\t\tSet local e-mail address",
- "start", OPT_START, " user",
- "\t\tStart a game with another user",
- "remotestart", OPT_RSTART, " u1 u2",
- "\tStart a game between u1 and u2",
- "broadcast", OPT_BCAST, " file",
- "\tSend a mail message to all opponents",
- "control", OPT_CONTROL, "",
- "\t\tPerform control functions on games",
- "help", OPT_HELP, "",
- "\t\t\tPrint this message",
- NULL, -1, NULL, NULL
- };
-
- char *opcodes[] = {
- "START", "USTART", "TIE", "MOVE", "OFFERDOUBLE", "ACCEPTDOUBLE",
- "DECLINEDOUBLE", "CONCEDE", "REMOTESTART", "RESTART",
- NULL
- };
-
- char *bdlabels[] = {
- "Board Before Opponent's Move",
- "Board After Opponent's Move",
- "Current Board"
- };
-
- struct namevalue nv_rcfile[] = {
- "myname", FT_STRING, Offset(struct ldbrc *,myname),
- "myaddr", FT_STRING, Offset(struct ldbrc *,myaddr),
- "gamefile", FT_STRING, Offset(struct ldbrc *,gfile),
- "backupfile", FT_STRING, Offset(struct ldbrc *,gbackup),
- "mailfile", FT_STRING, Offset(struct ldbrc *,mfile),
- "sendcmd", FT_STRING, Offset(struct ldbrc *,sendcmd),
- "tempfile", FT_STRING, Offset(struct ldbrc *,tempfile),
- "colors", FT_STRING, Offset(struct ldbrc *,defclrs),
- "direction", FT_STRING, Offset(struct ldbrc *,defdir),
- "initialboard", FT_STRING, Offset(struct ldbrc *,initboard),
- "autoroll", FT_STRING, Offset(struct ldbrc *,autoroll),
- "automove", FT_STRING, Offset(struct ldbrc *,automove),
- "autodouble", FT_INT, Offset(struct ldbrc *,autodouble),
- "supercmd", FT_STRING, Offset(struct ldbrc *,supercmd),
- "superkey", FT_CHAR, Offset(struct ldbrc *,superkey),
- "checkpoint", FT_STRING, Offset(struct ldbrc *,chkpt),
- NULL, 0, -1
- };
-
- struct namevalue nv_gfile[] = { /* extracts into global var G */
- "gameid", FT_STRING, Offset(struct game *,gameid),
- "opaddr", FT_STRING, Offset(struct game *,opaddr),
- "opname", FT_STRING, Offset(struct game *,opname),
- "mycolor", FT_CHAR, Offset(struct game *,mycolor),
- "opcolor", FT_CHAR, Offset(struct game *,opcolor),
- "mydir", FT_CHAR, Offset(struct game *,mydir),
- "opdir", FT_CHAR, Offset(struct game *,opdir),
- "gameval", FT_INT, Offset(struct game *,gameval),
- "flags", FT_INT, Offset(struct game *,flags),
- "state", FT_CHAR, Offset(struct game *,state),
- "term", FT_CHAR, Offset(struct game *,term),
- "seq", FT_INT, Offset(struct game *,seq),
- "lastop", FT_STRLKUP, Offset(struct game *,lastop),
- "mycmt", FT_STRING, Offset(struct game *,mycmt),
- "mycmt2", FT_STRING, Offset(struct game *,mycmt2),
- "opcmt", FT_STRING, Offset(struct game *,opcmt),
- "opcmt2", FT_STRING, Offset(struct game *,opcmt2),
- "dispmsg", FT_STRING, Offset(struct game *,dispmsg),
- "opmvs0", FT_MOVE, Offset(struct game *,opmvs[0]),
- "opmvs1", FT_MOVE, Offset(struct game *,opmvs[1]),
- "opmvs2", FT_MOVE, Offset(struct game *,opmvs[2]),
- "opmvs3", FT_MOVE, Offset(struct game *,opmvs[3]),
- "blot0", FT_CHAR, Offset(struct game *,blot[0]),
- "blot1", FT_CHAR, Offset(struct game *,blot[1]),
- "blot2", FT_CHAR, Offset(struct game *,blot[2]),
- "blot3", FT_CHAR, Offset(struct game *,blot[3]),
- "mvs0", FT_MOVE, Offset(struct game *,mvs[0]),
- "mvs1", FT_MOVE, Offset(struct game *,mvs[1]),
- "mvs2", FT_MOVE, Offset(struct game *,mvs[2]),
- "mvs3", FT_MOVE, Offset(struct game *,mvs[3]),
- "maxused", FT_INT, Offset(struct game *,maxused),
- "hiused", FT_INT, Offset(struct game *,hiused),
- "adcnt", FT_INT, Offset(struct game *,adcnt),
- "admax", FT_INT, Offset(struct game *,admax),
- "opbd", FT_BOARD, Offset(struct game *,opbd[0]),
- "mybd", FT_BOARD, Offset(struct game *,mybd[0]),
- "board", FT_BOARD, Offset(struct game *,board[0]),
- "curbd", FT_CHAR, Offset(struct game *,curbd),
- "end", FT_END, -1,
- NULL, 0, -1
- };
-
- struct namevalue nv_packet[] = {
- "version", FT_INT, Offset(struct packet *,version),
- "timestamp", FT_TIME, Offset(struct packet *,timestamp),
- "gameid", FT_STRING, Offset(struct packet *,gameid),
- "opcode", FT_STRLKUP, Offset(struct packet *,opcode),
- "move0", FT_MOVE, Offset(struct packet *,mvs[0]),
- "move1", FT_MOVE, Offset(struct packet *,mvs[1]),
- "move2", FT_MOVE, Offset(struct packet *,mvs[2]),
- "move3", FT_MOVE, Offset(struct packet *,mvs[3]),
- "name", FT_STRING, Offset(struct packet *,name),
- "addr", FT_STRING, Offset(struct packet *,addr),
- "comment", FT_STRING, Offset(struct packet *,comment),
- "comment2", FT_STRING, Offset(struct packet *,comment2),
- "seq", FT_INT, Offset(struct packet *,seq),
- "colors", FT_STRING, Offset(struct packet *,colors),
- "direction", FT_STRING, Offset(struct packet *,dir),
- "autodouble", FT_STRING, Offset(struct packet *,autodbl),
- "end", FT_END, -1,
- NULL, 0, -1
- };
-
- int (*func[OPSTATES][NOP])() = { /*
- START USTART TIE MOVE OFRDBL ACPTDBL DECDBL CONCEDE RSTART RESTART*/
- start, istart, tie, opmove, smerr, smerr, smerr, opconc, smerr, restart,
- smerr, smerr, smerr, opmove, opofr, smerr, smerr, opconc, smerr, smerr,
- smerr, smerr, smerr, smerr, smerr, opacpt, opdec, opconc, smerr, smerr
- };
-
- char *rejmsg[] = { /* explanation of reject codes */
- "Move Accepted.", /* no error */
- "Move does not contain a legal roll.", /* bad roll */
- "Cannot remove pieces before filling inner table.",
- "There is no piece at the specified location.",
- "The destination of this move is occupied.",
- "Attempt to move while pieces are on the bar.",
- "Attempt to move wrong color.",
- "That piece must be borne off by an exact roll."
- };
-