X-Git-Url: http://git.shiar.net/netris.git/blobdiff_plain/b5a9cdfd671a10cd5b5e9f1f53105e9993414247..5902d7f327fcf57d2b1a47f1b4a3aa98f4ab08a8:/util.c diff --git a/util.c b/util.c index 791a007..306c197 100644 --- a/util.c +++ b/util.c @@ -34,7 +34,7 @@ static MyEventType AlarmGenFunc(EventGenRec *gen, MyEvent *event); static EventGenRec alarmGen = - { &alarmGen, 0, FT_read, -1, AlarmGenFunc, EM_alarm }; + { &alarmGen, 0, FT_read, -1, AlarmGenFunc, EM_alarm }; static EventGenRec *nextGen = &alarmGen; static int myRandSeed = 1; @@ -56,80 +56,80 @@ void AtExit(void (*handler)(void)) void Header(void) { fprintf(stderr, - "NETRIS %s\t(c) 1994-1996,1999 Mark H. Weaver \n" - " \t(c) 2002 Shiar \n\n", - version_string); + "NETRIS %s\t(c) 1994-1996,1999 Mark H. Weaver \n" + " \t(c) 2002 Shiar \n\n", + version_string); } //Header void Usage(void) { Header(); fprintf(stderr, - "Usage: netris \n" - "\n" - " -h, --help\t\tPrint this usage information\n" - " -H, --info\t\tShow distribution and warranty information\n" - " -R, --rules\t\tShow game rules\n" - "\n" - " -S, --slowterm\tDisable inverse/bold/color for slow terminals\n" - " -a, --ascii\t\tUse ascii characters\n" - " -C, --color=0\t\tDisable color\n" - "\n" - " -c, --connect \tInitiate connection\n" - " -p, --port \tSet port number (default is %d)\n" - "\n" - " -t, --team \tJoin a team (don't receive lines from your teammates)\n" - " -l, --level \tBegin at a higher level (can be used as handicap)\n" - " -k, --keys \tRemap keys (default is \"%s\" for cursors)\n" - " -d, --dropmode\tDrops go into drop mode\n" - " -D, --instadrop\tInstant drop\n" - "\n" - " -r, --robot \tExecute program to control the game instead of keyboard\n" - " -F, --fair-robot\tUse fair robot interface\n" - "\n", DEFAULT_PORT, DEFAULT_KEYS); + "Usage: netris \n" + "\n" + " -h, --help\t\tPrint this usage information\n" + " -H, --info\t\tShow distribution and warranty information\n" + " -R, --rules\t\tShow game rules\n" + "\n" + " -S, --slowterm\tDisable inverse/bold/color for slow terminals\n" + " -a, --ascii\t\tUse ascii characters\n" + " -C, --color=0\t\tDisable color\n" + "\n" + " -c, --connect \tInitiate connection\n" + " -p, --port \tSet port number (default is %d)\n" + "\n" + " -t, --team \tJoin a team (don't receive lines from your teammates)\n" + " -l, --level \tBegin at a higher level (can be used as handicap)\n" + " -k, --keys \tRemap keys (default is \"%s\" for cursors)\n" + " -d, --dropmode\tDrops go into drop mode\n" + " -D, --instadrop\tInstant drop\n" + "\n" + " -r, --robot \tExecute program to control the game instead of keyboard\n" + " -F, --fair-robot\tUse fair robot interface\n" + "\n", DEFAULT_PORT, DEFAULT_KEYS); } void DistInfo(void) { fprintf(stderr, - "This program is free software; you can redistribute it and/or modify\n" - "it under the terms of the GNU General Public License as published by\n" - "the Free Software Foundation; either version 2 of the License, or\n" - "(at your option) any later version.\n" - "\n" - "This program is distributed in the hope that it will be useful,\n" - "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" - "GNU General Public License for more details.\n" - "\n" - "You should have received a copy of the GNU General Public License\n" - "along with this program; if not, write to the Free Software\n" - "Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n" - "\n"); + "This program is free software; you can redistribute it and/or modify\n" + "it under the terms of the GNU General Public License as published by\n" + "the Free Software Foundation; either version 2 of the License, or\n" + "(at your option) any later version.\n" + "\n" + "This program is distributed in the hope that it will be useful,\n" + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + "GNU General Public License for more details.\n" + "\n" + "You should have received a copy of the GNU General Public License\n" + "along with this program; if not, write to the Free Software\n" + "Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n" + "\n"); } //DistInfo void Rules(void) { Header(); fprintf(stderr, - "One player mode\n" - "---------------\n" - "Good old Tetris. Scoring is like on the GameBoy version (so try to\n" - "remove as many lines at once as you can). After removing ten lines\n" - "you go to the next level, which will be faster thus making the game\n" - "harder to play.\n" - "\n" - "Two player mode\n" - "---------------\n" - "It's just like normal T*tris except that when you clear more than\n" - "one row with a single piece, the other player receives penalty lines\n" - "For clearing 2, 3 or 4 rows, respectively 1, 2 or 4 junk rows will\n" - "be added to the bottom of your opponent's board respectively.\n" - "The junk rows have exactly one empty column, which will line up for\n" - "multiple rows.\n" - "\n" - "The longest surviving player wins the game.\n" - "\n"); + "One player mode\n" + "---------------\n" + "Good old Tetris. Scoring is like on the GameBoy version (so try to\n" + "remove as many lines at once as you can). After removing ten lines\n" + "you go to the next level, which will be faster thus making the game\n" + "harder to play.\n" + "\n" + "Two player mode\n" + "---------------\n" + "It's just like normal T*tris except that when you clear more than\n" + "one row with a single piece, the other player receives penalty lines\n" + "For clearing 2, 3 or 4 rows, respectively 1, 2 or 4 junk rows will\n" + "be added to the bottom of your opponent's board respectively.\n" + "The junk rows have exactly one empty column, which will line up for\n" + "multiple rows.\n" + "\n" + "The longest surviving player wins the game.\n" + "\n"); } //Rules ///////////// RANDOM ///////////// @@ -374,7 +374,7 @@ MyEventType WaitMyEvent(MyEvent *event, int mask) tv.tv_sec = 0; tv.tv_usec = (retry && !anyReady) ? 500000 : 0; result = select(FD_SETSIZE, &fds[FT_read], &fds[FT_write], - &fds[FT_except], anyReady ? &tv : NULL); + &fds[FT_except], anyReady ? &tv : NULL); } else { if (retry && !anyReady) @@ -383,9 +383,10 @@ MyEventType WaitMyEvent(MyEvent *event, int mask) } gen = nextGen; do { - if ((gen->mask & mask) - && (gen->ready || (result > 0 && gen->fd >= 0 - && FD_ISSET(gen->fd, &fds[gen->fdType])))) { + if ((gen->mask & mask) && (gen->ready || ( + result > 0 && gen->fd >= 0 + && FD_ISSET(gen->fd, &fds[gen->fdType]) + ))) { gen->ready = 0; event->type = gen->func(gen, event); if (event->type != E_none) {