From 6b1f6251013f5cf018e37ec7e67fe629a7f34455 Mon Sep 17 00:00:00 2001 From: Gerfried Fuchs Date: Fri, 30 May 2008 08:34:31 +0200 Subject: [PATCH] Imported Debian patch 0.52-7 --- board.c | 13 - curses.c | 42 +-- debian/changelog | 26 ++ debian/control | 7 +- debian/copyright | 7 +- debian/menu | 2 +- debian/netris-sample-robot.6 | 16 +- debian/patches/01_multi-games-with-scoring | 406 +++++++++++++++++++++ debian/patches/02_line-count-patch | 97 +++++ debian/patches/03_staircase-effect-fix | 51 +++ debian/patches/04_robot-close-fixup | 31 ++ debian/patches/05_init-static-vars | 13 + debian/patches/06_curses.c-include-term.h | 15 + debian/patches/07_curses.c-include-time.h | 15 + debian/patches/08_various-fixes | 37 ++ debian/patches/series | 8 + debian/postinst | 2 + debian/postrm | 2 + debian/rules | 10 +- game.c | 261 ++++++------- inet.c | 2 - netris.h | 17 +- robot.c | 13 +- util.c | 3 +- 24 files changed, 847 insertions(+), 249 deletions(-) create mode 100644 debian/patches/01_multi-games-with-scoring create mode 100644 debian/patches/02_line-count-patch create mode 100644 debian/patches/03_staircase-effect-fix create mode 100644 debian/patches/04_robot-close-fixup create mode 100644 debian/patches/05_init-static-vars create mode 100644 debian/patches/06_curses.c-include-term.h create mode 100644 debian/patches/07_curses.c-include-time.h create mode 100644 debian/patches/08_various-fixes create mode 100644 debian/patches/series diff --git a/board.c b/board.c index 621677c..d1cb66b 100644 --- a/board.c +++ b/board.c @@ -36,19 +36,6 @@ static int oldFalling[MAX_SCREENS][MAX_BOARD_WIDTH]; ExtFunc void InitBoard(int scr) { - int s,w,h; - - for(s = 0 ; s < MAX_SCREENS ; s++) - for(h = 0 ; h < MAX_BOARD_HEIGHT ; h++) - for(w = 0 ; w < MAX_BOARD_WIDTH ; w++) { - board[s][h][w] = 0; - oldBoard[s][h][w] = 0; - changed[s][h] = 0; - falling[s][w] = 0; - oldFalling[s][w] = 0; - } - - boardHeight[scr] = MAX_BOARD_HEIGHT; boardVisible[scr] = 20; boardWidth[scr] = 10; diff --git a/curses.c b/curses.c index dc708bd..14e9ce4 100644 --- a/curses.c +++ b/curses.c @@ -20,10 +20,8 @@ */ #include "netris.h" -#include #include #include -#include #include #include #include @@ -59,7 +57,6 @@ static EventGenRec keyGen = static int boardYPos[MAX_SCREENS], boardXPos[MAX_SCREENS]; static int statusYPos, statusXPos; static int haveColor; -static int screens_dirty = 0; static char *term_vi; /* String to make cursor invisible */ static char *term_ve; /* String to make cursor visible */ @@ -101,7 +98,6 @@ ExtFunc void InitScreens(void) #endif AtExit(CleanupScreens); - screens_dirty = 1; RestoreSignals(NULL, &oldMask); cbreak(); @@ -120,12 +116,9 @@ ExtFunc void InitScreens(void) ExtFunc void CleanupScreens(void) { - if (screens_dirty) { - RemoveEventGen(&keyGen); - endwin(); - OutputTermStr(term_ve, 1); - screens_dirty = 0; - } + RemoveEventGen(&keyGen); + endwin(); + OutputTermStr(term_ve, 1); } ExtFunc void GetTermcapInfo(void) @@ -208,8 +201,6 @@ ExtFunc void InitScreen(int scr) for (y = boardVisible[scr] - 1; y >= 0; --y) { move(boardYPos[scr] - y, boardXPos[scr] - 1); addch('|'); - for (x = boardWidth[scr] - 1; x >= 0; --x) - addstr(" "); move(boardYPos[scr] - y, boardXPos[scr] + 2 * boardWidth[scr]); addch('|'); } @@ -265,29 +256,6 @@ ExtFunc void PlotUnderline(int scr, int x, int flag) ExtFunc void ShowDisplayInfo(void) { - if (game == GT_classicTwo) { - move(statusYPos - 5, statusXPos); - printw("Enemy lines: %3d/%4d", enemyLinesCleared, enemyTotalLinesCleared); - } - move(statusYPos - 4, statusXPos); - printw("My lines: %3d/%4d", myLinesCleared, myTotalLinesCleared); - move(statusYPos - 3, statusXPos); - printw("Won: %3d", won); - move(statusYPos - 2, statusXPos); - printw("Lost: %3d", lost); - - move(statusYPos - 1, statusXPos); - switch(gameState) { - case STATE_WAIT_CONNECTION: - addstr("Waiting for opponent... "); - break; - case STATE_WAIT_KEYPRESS: - addstr("Press the key for a new game."); - break; - default: - addstr(" "); - } - move(statusYPos - 9, statusXPos); printw("Seed: %d", initSeed); clrtoeol(); @@ -295,7 +263,7 @@ ExtFunc void ShowDisplayInfo(void) printw("Speed: %dms", speed / 1000); clrtoeol(); if (robotEnable) { - move(statusYPos - 7, statusXPos); + move(statusYPos - 6, statusXPos); if (fairRobot) addstr("Controlled by a fair robot"); else @@ -303,7 +271,7 @@ ExtFunc void ShowDisplayInfo(void) clrtoeol(); } if (opponentFlags & SCF_usingRobot) { - move(statusYPos - 6, statusXPos); + move(statusYPos - 5, statusXPos); if (opponentFlags & SCF_fairRobot) addstr("The opponent is a fair robot"); else diff --git a/debian/changelog b/debian/changelog index a1e40ec..46ef7fe 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,29 @@ +netris (0.52-7) unstable; urgency=low + + * The "once every release" release. + * Moved patches to quilt, split them into: + - multi-games-with-scoring: allow multiple games in a row without + restarting. + - line-count-patch: patch to display cleared line counts + - staircase-effect-fix: fix displaying of error messages + - robot-close-fixup: Small fix for CloseRobot function to close only if a + robot is used. + - init-static-vars: initialize lostConn and gotEndConn static var in + InitNet function. + - curses.c-include-term.h: patch to fix function call that otherwise use + implicit pointer conversion. + - curses.c-include-time.h: patch to fix segfault on amd64. + * New patches: + - various-fixes: various small changes to fix compile warnings + * Linked to GPL-2 in copyright file directly, added hint for later versions. + * Added copyright informations into the debianization scripts. + * Added Homepage: control field. + * Updated package to Standards-Version 3.7.3, updating menu section for that. + * Don't ignore make clean errors anymore. + * Small cosmetic updates to the netris-sample-robot manpage. + + -- Gerfried Fuchs Fri, 30 May 2008 08:34:31 +0200 + netris (0.52-6) unstable; urgency=low * #include in curses.c (closes: #345305) diff --git a/debian/control b/debian/control index d097518..11d13ab 100644 --- a/debian/control +++ b/debian/control @@ -1,9 +1,10 @@ Source: netris Section: games Priority: optional -Maintainer: Gerfried Fuchs -Build-Depends: libncurses5-dev -Standards-Version: 3.7.2 +Maintainer: Gerfried Fuchs +Build-Depends: libncurses5-dev, quilt +Standards-Version: 3.7.3 +Homepage: http://netris.org/ Package: netris Architecture: any diff --git a/debian/copyright b/debian/copyright index 63c4f91..4f411d7 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,5 +1,6 @@ This package was first debianized by Gergely Madarasz on Wed, 6 Aug 1997 22:10:42 +0200. +It is maintained since 2002 by Gerfried Fuchs . It was downloaded from ftp://ftp.netris.org/pub/netris/ @@ -21,4 +22,8 @@ It was downloaded from ftp://ftp.netris.org/pub/netris/ Boston, MA 02110-1301 USA. On Debian GNU/Linux systems, the complete text of the GNU General -Public License can be found in `/usr/share/common-licenses/GPL'. +Public License version 2 can be found in `/usr/share/common-licenses/GPL-2', +later versions can be found in the same directory. + +The Debian packaging is (C) 2002-2008 Gerfried Fuchs , +licensed the same way as netris itself. diff --git a/debian/menu b/debian/menu index 604f852..8565c31 100644 --- a/debian/menu +++ b/debian/menu @@ -1,2 +1,2 @@ -?package(netris):needs="text" section="Games/Tetris-like" title="Netris" \ +?package(netris):needs="text" section="Games/Blocks" title="Netris" \ command="/usr/games/netris" longtitle="Networked Tetris" diff --git a/debian/netris-sample-robot.6 b/debian/netris-sample-robot.6 index f43a183..552e0ee 100644 --- a/debian/netris-sample-robot.6 +++ b/debian/netris-sample-robot.6 @@ -1,11 +1,11 @@ .TH netris-sample-robot 6 "16 Feb 2002" "0.5" "Netris Sample Robot" .SH "NAME" -netris-sample-robot \- sample robot for netris +netris\-sample\-robot \- sample robot for netris .SH "SYNOPSIS" .B netris-sample-robot .RB [\| \-l \|] .SH "DESCRIPTION" -The netris-sample-robot is a sample implementation of the robot protocol. It +The netris\-sample\-robot is a sample implementation of the robot protocol. It plays quite well but isn't too hard to beat. The robot should be started from netris with the option .B \-r @@ -21,8 +21,8 @@ in the current working directory. If it can't it bails out. .SH "EXAMPLES" .TP -To start the netris-sample-robot waiting for another connection with logfile use the following line: -netris -w -r 'netris-sample-robot -l' +To start the netris\-sample\-robot waiting for another connection with logfile use the following line: +netris \-w \-r 'netris\-sample\-robot \-l' .P You then just have to start netris somewhere else which connects to that robot. @@ -30,10 +30,10 @@ You then just have to start netris somewhere else which connects to that robot. .BR netris (6) .SH "BUGS" -One known bug of the netris-sample-robot is that it hangs quite often. This was -already filed as a bugreport against the package so please refrain from doing -so again. If you have an idea why this happens or know a solution how to fix -it feel free to mail me. +One known bug of the netris\-sample\-robot is that it hangs quite often. +This was already filed as a bugreport against the package so please +refrain from doing so again. If you have an idea why this happens or +know a solution how to fix it feel free to mail us. .SH "AUTHORS" Netris was written by Mark H. Weaver . diff --git a/debian/patches/01_multi-games-with-scoring b/debian/patches/01_multi-games-with-scoring new file mode 100644 index 0000000..3d08e9c --- /dev/null +++ b/debian/patches/01_multi-games-with-scoring @@ -0,0 +1,406 @@ +Index: netris-0.52/curses.c +=================================================================== +--- netris-0.52.orig/curses.c ++++ netris-0.52/curses.c +@@ -201,6 +201,8 @@ ExtFunc void InitScreen(int scr) + for (y = boardVisible[scr] - 1; y >= 0; --y) { + move(boardYPos[scr] - y, boardXPos[scr] - 1); + addch('|'); ++ for (x = boardWidth[scr] - 1; x >= 0; --x) ++ addstr(" "); + move(boardYPos[scr] - y, boardXPos[scr] + 2 * boardWidth[scr]); + addch('|'); + } +@@ -256,6 +258,23 @@ ExtFunc void PlotUnderline(int scr, int + + ExtFunc void ShowDisplayInfo(void) + { ++ move(statusYPos - 3, statusXPos); ++ printw("Won: %3d", won); ++ move(statusYPos - 2, statusXPos); ++ printw("Lost: %3d", lost); ++ ++ move(statusYPos - 1, statusXPos); ++ switch(gameState) { ++ case STATE_WAIT_CONNECTION: ++ addstr("Waiting for opponent... "); ++ break; ++ case STATE_WAIT_KEYPRESS: ++ addstr("Press the key for a new game."); ++ break; ++ default: ++ addstr(" "); ++ } ++ + move(statusYPos - 9, statusXPos); + printw("Seed: %d", initSeed); + clrtoeol(); +Index: netris-0.52/netris.h +=================================================================== +--- netris-0.52.orig/netris.h ++++ netris-0.52/netris.h +@@ -65,7 +65,7 @@ typedef long netint4; + + #define DEFAULT_PORT 9284 /* Very arbitrary */ + +-#define DEFAULT_KEYS "jkl mspf^l" ++#define DEFAULT_KEYS "jkl mspf^ln" + + /* Protocol versions */ + #define MAJOR_VERSION 1 +@@ -152,6 +152,13 @@ typedef struct _ShapeOption { + typedef int (*ShapeDrawFunc)(int scr, int y, int x, + BlockType type, void *data); + ++enum States { ++ STATE_STARTING, ++ STATE_PLAYING, ++ STATE_WAIT_CONNECTION, ++ STATE_WAIT_KEYPRESS ++}; ++ + EXT GameType game; + EXT int boardHeight[MAX_SCREENS]; + EXT int boardVisible[MAX_SCREENS], boardWidth[MAX_SCREENS]; +@@ -167,6 +174,9 @@ EXT long stepDownInterval, speed; + + EXT int myFlags, opponentFlags; + ++EXT int won, lost; ++EXT enum States gameState; ++ + EXT char scratch[1024]; + + extern ShapeOption stdOptions[]; +Index: netris-0.52/util.c +=================================================================== +--- netris-0.52.orig/util.c ++++ netris-0.52/util.c +@@ -74,7 +74,7 @@ ExtFunc void Usage(void) + " -p Set port number (default is %d)\n" + " -k Remap keys. The argument is a prefix of the string\n" + " containing the keys in order: left, rotate, right, drop,\n" +- " down-faster, toggle-spying, pause, faster, redraw.\n" ++ " down-faster, toggle-spying, pause, faster, redraw, new.\n" + " \"^\" prefixes controls. (default is \"%s\")\n" + " -i Set the step-down interval, in seconds\n" + " -r Execute (a command) as a robot controlling\n" +Index: netris-0.52/game.c +=================================================================== +--- netris-0.52.orig/game.c ++++ netris-0.52/game.c +@@ -28,11 +28,11 @@ + #include + + enum { KT_left, KT_rotate, KT_right, KT_drop, KT_down, +- KT_toggleSpy, KT_pause, KT_faster, KT_redraw, KT_numKeys }; ++ KT_toggleSpy, KT_pause, KT_faster, KT_redraw, KT_new, KT_numKeys }; + + static char *keyNames[KT_numKeys+1] = { + "Left", "Rotate", "Right", "Drop", "Down", "ToggleSpy", "Pause", +- "Faster", "Redraw", NULL }; ++ "Faster", "Redraw", "New", NULL }; + + static char *gameNames[GT_len] = { "OnePlayer", "ClassicTwo" }; + +@@ -40,6 +40,10 @@ static char keyTable[KT_numKeys+1]; + static int dropModeEnable = 0; + static char *robotProg; + ++static int wonLast = 0; ++int lost = 0, won = 0; ++enum States gameState = STATE_STARTING; ++ + ExtFunc void MapKeys(char *newKeys) + { + int i, k, ch; +@@ -323,6 +327,7 @@ ExtFunc void OneGame(int scr, int scr2) + break; + case E_lostRobot: + case E_lostConn: ++ wonLast = 1; + goto gameOver; + default: + break; +@@ -350,14 +355,17 @@ ExtFunc void OneGame(int scr, int scr2) + SendPacket(NP_giveJunk, sizeof(data), data); + } + } ++ wonLast = 0; ++ + gameOver: + SetITimer(0, 0); + } + + ExtFunc int main(int argc, char **argv) + { +- int initConn = 0, waitConn = 0, ch; ++ int initConn = 0, waitConn = 0, ch, done = 0; + char *hostStr = NULL, *portStr = NULL; ++ MyEvent event; + + standoutEnable = colorEnable = 1; + stepDownInterval = DEFAULT_INTERVAL; +@@ -422,112 +430,139 @@ ExtFunc int main(int argc, char **argv) + if (fairRobot && !robotEnable) + fatal("You can't use the -F option without the -r option"); + InitUtil(); +- if (robotEnable) +- InitRobot(robotProg); +- InitNet(); + InitScreens(); +- if (initConn || waitConn) { +- MyEvent event; +- +- game = GT_classicTwo; +- if (initConn) +- InitiateConnection(hostStr, portStr); +- else if (waitConn) +- WaitForConnection(portStr); +- { +- netint4 data[2]; +- int major; +- +- data[0] = hton4(MAJOR_VERSION); +- data[1] = hton4(PROTOCOL_VERSION); +- SendPacket(NP_version, sizeof(data), data); +- if (WaitMyEvent(&event, EM_net) != E_net) +- fatal("Network negotiation failed"); +- memcpy(data, event.u.net.data, sizeof(data)); +- major = ntoh4(data[0]); +- protocolVersion = ntoh4(data[1]); +- if (event.u.net.type != NP_version || major < MAJOR_VERSION) +- fatal("Your opponent is using an old, incompatible version\n" +- "of Netris. They should get the latest version."); +- if (major > MAJOR_VERSION) +- fatal("Your opponent is using an newer, incompatible version\n" +- "of Netris. Get the latest version."); +- if (protocolVersion > PROTOCOL_VERSION) +- protocolVersion = PROTOCOL_VERSION; +- } +- if (protocolVersion < 3 && stepDownInterval != DEFAULT_INTERVAL) +- fatal("Your opponent's version of Netris predates the -i option.\n" +- "For fairness, you shouldn't use the -i option either."); +- { +- netint4 data[3]; +- int len; +- int seed; ++ while(!done) { ++ if (robotEnable) ++ InitRobot(robotProg); ++ InitNet(); ++ if (!initSeed) ++ SRandom(time(0)); ++ if (initConn || waitConn) { ++ game = GT_classicTwo; ++ if(gameState != STATE_STARTING) { ++ gameState = STATE_WAIT_CONNECTION; ++ ShowDisplayInfo(); ++ RefreshScreen(); ++ } ++ if (initConn) ++ InitiateConnection(hostStr, portStr); ++ else if (waitConn) ++ WaitForConnection(portStr); ++ gameState = STATE_PLAYING; ++ ShowDisplayInfo(); ++ RefreshScreen(); ++ { ++ netint4 data[2]; ++ int major; ++ ++ data[0] = hton4(MAJOR_VERSION); ++ data[1] = hton4(PROTOCOL_VERSION); ++ SendPacket(NP_version, sizeof(data), data); ++ if (WaitMyEvent(&event, EM_net) != E_net) ++ fatal("Network negotiation failed"); ++ memcpy(data, event.u.net.data, sizeof(data)); ++ major = ntoh4(data[0]); ++ protocolVersion = ntoh4(data[1]); ++ if (event.u.net.type != NP_version || major < MAJOR_VERSION) ++ fatal("Your opponent is using an old, incompatible version\n" ++ "of Netris. They should get the latest version."); ++ if (major > MAJOR_VERSION) ++ fatal("Your opponent is using an newer, incompatible version\n" ++ "of Netris. Get the latest version."); ++ if (protocolVersion > PROTOCOL_VERSION) ++ protocolVersion = PROTOCOL_VERSION; ++ } ++ if (protocolVersion < 3 && stepDownInterval != DEFAULT_INTERVAL) ++ fatal("Your opponent's version of Netris predates the -i option.\n" ++ "For fairness, you shouldn't use the -i option either."); ++ { ++ netint4 data[3]; ++ int len; ++ int seed; + +- if (protocolVersion >= 3) +- len = sizeof(data); +- else +- len = sizeof(netint4[2]); +- if ((myFlags & SCF_setSeed)) +- seed = initSeed; +- else +- seed = time(0); +- if (waitConn) +- SRandom(seed); +- data[0] = hton4(myFlags); +- data[1] = hton4(seed); +- data[2] = hton4(stepDownInterval); +- SendPacket(NP_startConn, len, data); +- if (WaitMyEvent(&event, EM_net) != E_net || +- event.u.net.type != NP_startConn) +- fatal("Network negotiation failed"); +- memcpy(data, event.u.net.data, len); +- opponentFlags = ntoh4(data[0]); +- seed = ntoh4(data[1]); +- if (initConn) { +- if ((opponentFlags & SCF_setSeed) != (myFlags & SCF_setSeed)) +- fatal("If one player sets the random number seed, " +- "both must."); +- if ((myFlags & SCF_setSeed) && seed != initSeed) +- fatal("Both players have set the random number seed, " +- "and they are unequal."); +- if (protocolVersion >= 3 && stepDownInterval != ntoh4(data[2])) +- fatal("Your opponent is using a different step-down " +- "interval (-i).\nYou must both use the same one."); +- SRandom(seed); ++ if (protocolVersion >= 3) ++ len = sizeof(data); ++ else ++ len = sizeof(netint4[2]); ++ if ((myFlags & SCF_setSeed)) ++ seed = initSeed; ++ else ++ seed = time(0); ++ if (waitConn) ++ SRandom(seed); ++ data[0] = hton4(myFlags); ++ data[1] = hton4(seed); ++ data[2] = hton4(stepDownInterval); ++ SendPacket(NP_startConn, len, data); ++ if (WaitMyEvent(&event, EM_net) != E_net || ++ event.u.net.type != NP_startConn) ++ fatal("Network negotiation failed"); ++ memcpy(data, event.u.net.data, len); ++ opponentFlags = ntoh4(data[0]); ++ seed = ntoh4(data[1]); ++ if (initConn) { ++ if ((opponentFlags & SCF_setSeed) != (myFlags & SCF_setSeed)) ++ fatal("If one player sets the random number seed, " ++ "both must."); ++ if ((myFlags & SCF_setSeed) && seed != initSeed) ++ fatal("Both players have set the random number seed, " ++ "and they are unequal."); ++ if (protocolVersion >= 3 && stepDownInterval != ntoh4(data[2])) ++ fatal("Your opponent is using a different step-down " ++ "interval (-i).\nYou must both use the same one."); ++ SRandom(seed); ++ } ++ } ++ { ++ char *userName; ++ int len, i; ++ ++ userName = getenv("LOGNAME"); ++ if (!userName || !userName[0]) ++ userName = getenv("USER"); ++ if (!userName || !userName[0]) ++ strcpy(userName, "???"); ++ len = strlen(userName)+1; ++ if (len > sizeof(opponentName)) ++ len = sizeof(opponentName); ++ SendPacket(NP_userName, len, userName); ++ if (WaitMyEvent(&event, EM_net) != E_net || ++ event.u.net.type != NP_userName) ++ fatal("Network negotiation failed"); ++ strncpy(opponentName, event.u.net.data, ++ sizeof(opponentName)-1); ++ opponentName[sizeof(opponentName)-1] = 0; ++ for (i = 0; opponentName[i]; ++i) ++ if (!isprint(opponentName[i])) ++ opponentName[i] = '?'; ++ for (i = 0; opponentHost[i]; ++i) ++ if (!isprint(opponentHost[i])) ++ opponentHost[i] = '?'; + } ++ OneGame(0, 1); + } +- { +- char *userName; +- int len, i; +- +- userName = getenv("LOGNAME"); +- if (!userName || !userName[0]) +- userName = getenv("USER"); +- if (!userName || !userName[0]) +- strcpy(userName, "???"); +- len = strlen(userName)+1; +- if (len > sizeof(opponentName)) +- len = sizeof(opponentName); +- SendPacket(NP_userName, len, userName); +- if (WaitMyEvent(&event, EM_net) != E_net || +- event.u.net.type != NP_userName) +- fatal("Network negotiation failed"); +- strncpy(opponentName, event.u.net.data, +- sizeof(opponentName)-1); +- opponentName[sizeof(opponentName)-1] = 0; +- for (i = 0; opponentName[i]; ++i) +- if (!isprint(opponentName[i])) +- opponentName[i] = '?'; +- for (i = 0; opponentHost[i]; ++i) +- if (!isprint(opponentHost[i])) +- opponentHost[i] = '?'; ++ else { ++ game = GT_onePlayer; ++ OneGame(0, -1); ++ } ++ if (wonLast) { ++ won++; ++ } else { ++ lost++; ++ WaitMyEvent(&event, EM_net); ++ } ++ CloseNet(); ++ if (robotEnable) { ++ CloseRobot(); ++ } else { ++ gameState = STATE_WAIT_KEYPRESS; ++ ShowDisplayInfo(); ++ RefreshScreen(); ++ while(getchar() != keyTable[KT_new]) ++ ; + } +- OneGame(0, 1); +- } +- else { +- game = GT_onePlayer; +- OneGame(0, -1); + } ++ + return 0; + } + +Index: netris-0.52/board.c +=================================================================== +--- netris-0.52.orig/board.c ++++ netris-0.52/board.c +@@ -36,6 +36,18 @@ static int oldFalling[MAX_SCREENS][MAX_B + + ExtFunc void InitBoard(int scr) + { ++ int s,w,h; ++ ++ for(s = 0 ; s < MAX_SCREENS ; s++) ++ for(h = 0 ; h < MAX_BOARD_HEIGHT ; h++) ++ for(w = 0 ; w < MAX_BOARD_WIDTH ; w++) { ++ board[s][h][w] = 0; ++ oldBoard[s][h][w] = 0; ++ changed[s][h] = 0; ++ falling[s][w] = 0; ++ oldFalling[s][w] = 0; ++ } ++ + boardHeight[scr] = MAX_BOARD_HEIGHT; + boardVisible[scr] = 20; + boardWidth[scr] = 10; diff --git a/debian/patches/02_line-count-patch b/debian/patches/02_line-count-patch new file mode 100644 index 0000000..eefc7b4 --- /dev/null +++ b/debian/patches/02_line-count-patch @@ -0,0 +1,97 @@ +Author: Piotr Krukowiecki vim:ft=diff: +Description: patch to display line counter, BTS #304224 + +Index: netris-0.52/curses.c +=================================================================== +--- netris-0.52.orig/curses.c ++++ netris-0.52/curses.c +@@ -258,6 +258,12 @@ ExtFunc void PlotUnderline(int scr, int + + ExtFunc void ShowDisplayInfo(void) + { ++ if (game == GT_classicTwo) { ++ move(statusYPos - 5, statusXPos); ++ printw("Enemy lines: %3d/%4d", enemyLinesCleared, enemyTotalLinesCleared); ++ } ++ move(statusYPos - 4, statusXPos); ++ printw("My lines: %3d/%4d", myLinesCleared, myTotalLinesCleared); + move(statusYPos - 3, statusXPos); + printw("Won: %3d", won); + move(statusYPos - 2, statusXPos); +@@ -282,7 +288,7 @@ ExtFunc void ShowDisplayInfo(void) + printw("Speed: %dms", speed / 1000); + clrtoeol(); + if (robotEnable) { +- move(statusYPos - 6, statusXPos); ++ move(statusYPos - 7, statusXPos); + if (fairRobot) + addstr("Controlled by a fair robot"); + else +@@ -290,7 +296,7 @@ ExtFunc void ShowDisplayInfo(void) + clrtoeol(); + } + if (opponentFlags & SCF_usingRobot) { +- move(statusYPos - 5, statusXPos); ++ move(statusYPos - 6, statusXPos); + if (opponentFlags & SCF_fairRobot) + addstr("The opponent is a fair robot"); + else +Index: netris-0.52/game.c +=================================================================== +--- netris-0.52.orig/game.c ++++ netris-0.52/game.c +@@ -103,6 +103,7 @@ ExtFunc void OneGame(int scr, int scr2) + int key; + char *p, *cmd; + ++ myLinesCleared = enemyLinesCleared = 0; + speed = stepDownInterval; + ResetBaseTime(); + InitBoard(scr); +@@ -297,7 +298,15 @@ ExtFunc void OneGame(int scr, int scr2) + DropPiece(scr2); + break; + case NP_clear: +- ClearFullLines(scr2); ++ { ++ int cleared = ClearFullLines(scr2); ++ if (cleared) { ++ enemyLinesCleared += cleared; ++ enemyTotalLinesCleared += cleared; ++ ShowDisplayInfo(); ++ RefreshScreen(); ++ } ++ } + break; + case NP_insertJunk: + { +@@ -343,7 +352,12 @@ ExtFunc void OneGame(int scr, int scr2) + nextPiece: + dropMode = 0; + FreezePiece(scr); +- linesCleared = ClearFullLines(scr); ++ myLinesCleared += linesCleared = ClearFullLines(scr); ++ myTotalLinesCleared += linesCleared; ++ if (linesCleared) { ++ ShowDisplayInfo(); ++ RefreshScreen(); ++ } + if (linesCleared > 0 && spied) + SendPacket(NP_clear, 0, NULL); + if (game == GT_classicTwo && linesCleared > 1) { +Index: netris-0.52/netris.h +=================================================================== +--- netris-0.52.orig/netris.h ++++ netris-0.52/netris.h +@@ -182,6 +182,11 @@ EXT char scratch[1024]; + extern ShapeOption stdOptions[]; + extern char *version_string; + ++EXT int myLinesCleared; ++EXT int enemyLinesCleared; ++EXT int myTotalLinesCleared; ++EXT int enemyTotalLinesCleared; ++ + #include "proto.h" + + #endif /* NETRIS_H */ diff --git a/debian/patches/03_staircase-effect-fix b/debian/patches/03_staircase-effect-fix new file mode 100644 index 0000000..514e867 --- /dev/null +++ b/debian/patches/03_staircase-effect-fix @@ -0,0 +1,51 @@ +Author: Per von Zweigbergk vim:ft=diff: +Description: fix staircase effect in error message, BTS #83039 + +Index: netris-0.52/util.c +=================================================================== +--- netris-0.52.orig/util.c ++++ netris-0.52/util.c +@@ -267,6 +267,7 @@ ExtFunc volatile void die(char *msg) + + ExtFunc volatile void fatal(char *msg) + { ++ CleanupScreens (); + fprintf(stderr, "%s\n", msg); + exit(1); + } +Index: netris-0.52/curses.c +=================================================================== +--- netris-0.52.orig/curses.c ++++ netris-0.52/curses.c +@@ -57,6 +57,7 @@ static EventGenRec keyGen = + static int boardYPos[MAX_SCREENS], boardXPos[MAX_SCREENS]; + static int statusYPos, statusXPos; + static int haveColor; ++static int screens_dirty = 0; + + static char *term_vi; /* String to make cursor invisible */ + static char *term_ve; /* String to make cursor visible */ +@@ -98,6 +99,7 @@ ExtFunc void InitScreens(void) + #endif + + AtExit(CleanupScreens); ++ screens_dirty = 1; + RestoreSignals(NULL, &oldMask); + + cbreak(); +@@ -116,9 +118,12 @@ ExtFunc void InitScreens(void) + + ExtFunc void CleanupScreens(void) + { +- RemoveEventGen(&keyGen); +- endwin(); +- OutputTermStr(term_ve, 1); ++ if (screens_dirty) { ++ RemoveEventGen(&keyGen); ++ endwin(); ++ OutputTermStr(term_ve, 1); ++ screens_dirty = 0; ++ } + } + + ExtFunc void GetTermcapInfo(void) diff --git a/debian/patches/04_robot-close-fixup b/debian/patches/04_robot-close-fixup new file mode 100644 index 0000000..74cfec4 --- /dev/null +++ b/debian/patches/04_robot-close-fixup @@ -0,0 +1,31 @@ +Index: netris-0.52/robot.c +=================================================================== +--- netris-0.52.orig/robot.c ++++ netris-0.52/robot.c +@@ -35,7 +35,7 @@ static EventGenRec robotGen = + { NULL, 0, FT_read, -1, RobotGenFunc, EM_robot }; + + static int robotProcess; +-static FILE *toRobot; ++static FILE *toRobot = NULL; + static int toRobotFd, fromRobotFd; + + static char robotBuf[128]; +@@ -112,10 +112,13 @@ ExtFunc void RobotTimeStamp(void) + ExtFunc void CloseRobot(void) + { + RemoveEventGen(&robotGen); +- if (robotProcess > 0) +- RobotCmd(1, "Exit\n"); +- fclose(toRobot); +- close(fromRobotFd); ++ if(toRobot) { ++ if (robotProcess > 0) ++ RobotCmd(1, "Exit\n"); ++ fclose(toRobot); ++ close(fromRobotFd); ++ toRobot = NULL; ++ } + } + + static MyEventType RobotGenFunc(EventGenRec *gen, MyEvent *event) diff --git a/debian/patches/05_init-static-vars b/debian/patches/05_init-static-vars new file mode 100644 index 0000000..cf3bec3 --- /dev/null +++ b/debian/patches/05_init-static-vars @@ -0,0 +1,13 @@ +Index: netris-0.52/inet.c +=================================================================== +--- netris-0.52.orig/inet.c ++++ netris-0.52/inet.c +@@ -42,6 +42,8 @@ static int isServer, lostConn, gotEndCon + + ExtFunc void InitNet(void) + { ++ lostConn = 0; ++ gotEndConn = 0; + AtExit(CloseNet); + } + diff --git a/debian/patches/06_curses.c-include-term.h b/debian/patches/06_curses.c-include-term.h new file mode 100644 index 0000000..88aafcb --- /dev/null +++ b/debian/patches/06_curses.c-include-term.h @@ -0,0 +1,15 @@ +Author: David Mosberger vim:ft=diff: +Description: #include to avoid implicit pointer conversion, BTS #325926 + +Index: netris-0.52/curses.c +=================================================================== +--- netris-0.52.orig/curses.c ++++ netris-0.52/curses.c +@@ -22,6 +22,7 @@ + #include "netris.h" + #include + #include ++#include + #include + #include + #include diff --git a/debian/patches/07_curses.c-include-time.h b/debian/patches/07_curses.c-include-time.h new file mode 100644 index 0000000..e9c25df --- /dev/null +++ b/debian/patches/07_curses.c-include-time.h @@ -0,0 +1,15 @@ +Author: Brian Brazil vim:ft=diff: +Description: #include to avoid segfault on amd64, BTS #345305 + +Index: netris-0.52/curses.c +=================================================================== +--- netris-0.52.orig/curses.c ++++ netris-0.52/curses.c +@@ -20,6 +20,7 @@ + */ + + #include "netris.h" ++#include + #include + #include + #include diff --git a/debian/patches/08_various-fixes b/debian/patches/08_various-fixes new file mode 100644 index 0000000..a145ee8 --- /dev/null +++ b/debian/patches/08_various-fixes @@ -0,0 +1,37 @@ +Index: netris-0.52/game.c +=================================================================== +--- netris-0.52.orig/game.c ++++ netris-0.52/game.c +@@ -21,6 +21,7 @@ + + #define NOEXT + #include "netris.h" ++#include + #include + #include + #include +Index: netris-0.52/inet.c +=================================================================== +--- netris-0.52.orig/inet.c ++++ netris-0.52/inet.c +@@ -52,7 +52,7 @@ ExtFunc int WaitForConnection(char *port + struct sockaddr_in addr; + struct hostent *host; + int sockListen; +- int addrLen; ++ socklen_t addrLen; + short port; + int val1; + struct linger val2; +Index: netris-0.52/util.c +=================================================================== +--- netris-0.52.orig/util.c ++++ netris-0.52/util.c +@@ -20,6 +20,7 @@ + */ + + #include "netris.h" ++#include + #include + #include + #include diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..0ebda8e --- /dev/null +++ b/debian/patches/series @@ -0,0 +1,8 @@ +01_multi-games-with-scoring +02_line-count-patch +03_staircase-effect-fix +04_robot-close-fixup +05_init-static-vars +06_curses.c-include-term.h +07_curses.c-include-time.h +08_various-fixes diff --git a/debian/postinst b/debian/postinst index 32be2bd..2487d92 100644 --- a/debian/postinst +++ b/debian/postinst @@ -1,5 +1,7 @@ #!/bin/sh -e # postinst script for netris +# copyright 2002++ by Gerfried Fuchs +# Licenced the same way as netris itself if [ "$1" != configure ]; then exit 0 diff --git a/debian/postrm b/debian/postrm index cc7789d..ca83453 100644 --- a/debian/postrm +++ b/debian/postrm @@ -1,5 +1,7 @@ #!/bin/sh -e # postrm script for netris +# copyright 2002++ by Gerfried Fuchs +# Licenced the same way as netris itself if [ -x /usr/bin/update-menus ]; then update-menus diff --git a/debian/rules b/debian/rules index 3267cbb..3816853 100755 --- a/debian/rules +++ b/debian/rules @@ -1,5 +1,7 @@ #!/usr/bin/make -f # rules file for netris +# copyright 2002++ by Gerfried Fuchs +# Licenced the same way as netris itself COPT = -g INSTALL = install @@ -18,17 +20,19 @@ ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) endif -clean: +include /usr/share/quilt/quilt.make + +clean: unpatch $(checkdir) $(checkroot) -rm -rf debian/netris debian/substvars debian/files \ build-stamp install-stamp config.h .depend - -$(MAKE) clean + [ ! -f Makefile ] || $(MAKE) clean -rm -rf Makefile build: build-stamp -build-stamp: +build-stamp: patch $(checkdir) ./Configure -g $(MAKE) COPT="$(COPT)" diff --git a/game.c b/game.c index e57e7ca..b40c129 100644 --- a/game.c +++ b/game.c @@ -28,11 +28,11 @@ #include enum { KT_left, KT_rotate, KT_right, KT_drop, KT_down, - KT_toggleSpy, KT_pause, KT_faster, KT_redraw, KT_new, KT_numKeys }; + KT_toggleSpy, KT_pause, KT_faster, KT_redraw, KT_numKeys }; static char *keyNames[KT_numKeys+1] = { "Left", "Rotate", "Right", "Drop", "Down", "ToggleSpy", "Pause", - "Faster", "Redraw", "New", NULL }; + "Faster", "Redraw", NULL }; static char *gameNames[GT_len] = { "OnePlayer", "ClassicTwo" }; @@ -40,10 +40,6 @@ static char keyTable[KT_numKeys+1]; static int dropModeEnable = 0; static char *robotProg; -static int wonLast = 0; -int lost = 0, won = 0; -enum States gameState = STATE_STARTING; - ExtFunc void MapKeys(char *newKeys) { int i, k, ch; @@ -103,7 +99,6 @@ ExtFunc void OneGame(int scr, int scr2) int key; char *p, *cmd; - myLinesCleared = enemyLinesCleared = 0; speed = stepDownInterval; ResetBaseTime(); InitBoard(scr); @@ -298,15 +293,7 @@ ExtFunc void OneGame(int scr, int scr2) DropPiece(scr2); break; case NP_clear: - { - int cleared = ClearFullLines(scr2); - if (cleared) { - enemyLinesCleared += cleared; - enemyTotalLinesCleared += cleared; - ShowDisplayInfo(); - RefreshScreen(); - } - } + ClearFullLines(scr2); break; case NP_insertJunk: { @@ -336,7 +323,6 @@ ExtFunc void OneGame(int scr, int scr2) break; case E_lostRobot: case E_lostConn: - wonLast = 1; goto gameOver; default: break; @@ -352,12 +338,7 @@ ExtFunc void OneGame(int scr, int scr2) nextPiece: dropMode = 0; FreezePiece(scr); - myLinesCleared += linesCleared = ClearFullLines(scr); - myTotalLinesCleared += linesCleared; - if (linesCleared) { - ShowDisplayInfo(); - RefreshScreen(); - } + linesCleared = ClearFullLines(scr); if (linesCleared > 0 && spied) SendPacket(NP_clear, 0, NULL); if (game == GT_classicTwo && linesCleared > 1) { @@ -369,17 +350,14 @@ ExtFunc void OneGame(int scr, int scr2) SendPacket(NP_giveJunk, sizeof(data), data); } } - wonLast = 0; - gameOver: SetITimer(0, 0); } ExtFunc int main(int argc, char **argv) { - int initConn = 0, waitConn = 0, ch, done = 0; + int initConn = 0, waitConn = 0, ch; char *hostStr = NULL, *portStr = NULL; - MyEvent event; standoutEnable = colorEnable = 1; stepDownInterval = DEFAULT_INTERVAL; @@ -444,139 +422,112 @@ ExtFunc int main(int argc, char **argv) if (fairRobot && !robotEnable) fatal("You can't use the -F option without the -r option"); InitUtil(); - InitScreens(); - while(!done) { - if (robotEnable) - InitRobot(robotProg); - InitNet(); - if (!initSeed) - SRandom(time(0)); - if (initConn || waitConn) { - game = GT_classicTwo; - if(gameState != STATE_STARTING) { - gameState = STATE_WAIT_CONNECTION; - ShowDisplayInfo(); - RefreshScreen(); - } - if (initConn) - InitiateConnection(hostStr, portStr); - else if (waitConn) - WaitForConnection(portStr); - gameState = STATE_PLAYING; - ShowDisplayInfo(); - RefreshScreen(); - { - netint4 data[2]; - int major; - - data[0] = hton4(MAJOR_VERSION); - data[1] = hton4(PROTOCOL_VERSION); - SendPacket(NP_version, sizeof(data), data); - if (WaitMyEvent(&event, EM_net) != E_net) - fatal("Network negotiation failed"); - memcpy(data, event.u.net.data, sizeof(data)); - major = ntoh4(data[0]); - protocolVersion = ntoh4(data[1]); - if (event.u.net.type != NP_version || major < MAJOR_VERSION) - fatal("Your opponent is using an old, incompatible version\n" - "of Netris. They should get the latest version."); - if (major > MAJOR_VERSION) - fatal("Your opponent is using an newer, incompatible version\n" - "of Netris. Get the latest version."); - if (protocolVersion > PROTOCOL_VERSION) - protocolVersion = PROTOCOL_VERSION; - } - if (protocolVersion < 3 && stepDownInterval != DEFAULT_INTERVAL) - fatal("Your opponent's version of Netris predates the -i option.\n" - "For fairness, you shouldn't use the -i option either."); - { - netint4 data[3]; - int len; - int seed; - - if (protocolVersion >= 3) - len = sizeof(data); - else - len = sizeof(netint4[2]); - if ((myFlags & SCF_setSeed)) - seed = initSeed; - else - seed = time(0); - if (waitConn) - SRandom(seed); - data[0] = hton4(myFlags); - data[1] = hton4(seed); - data[2] = hton4(stepDownInterval); - SendPacket(NP_startConn, len, data); - if (WaitMyEvent(&event, EM_net) != E_net || - event.u.net.type != NP_startConn) - fatal("Network negotiation failed"); - memcpy(data, event.u.net.data, len); - opponentFlags = ntoh4(data[0]); - seed = ntoh4(data[1]); - if (initConn) { - if ((opponentFlags & SCF_setSeed) != (myFlags & SCF_setSeed)) - fatal("If one player sets the random number seed, " - "both must."); - if ((myFlags & SCF_setSeed) && seed != initSeed) - fatal("Both players have set the random number seed, " - "and they are unequal."); - if (protocolVersion >= 3 && stepDownInterval != ntoh4(data[2])) - fatal("Your opponent is using a different step-down " - "interval (-i).\nYou must both use the same one."); - SRandom(seed); - } - } - { - char *userName; - int len, i; + if (robotEnable) + InitRobot(robotProg); + InitNet(); + InitScreens(); + if (initConn || waitConn) { + MyEvent event; - userName = getenv("LOGNAME"); - if (!userName || !userName[0]) - userName = getenv("USER"); - if (!userName || !userName[0]) - strcpy(userName, "???"); - len = strlen(userName)+1; - if (len > sizeof(opponentName)) - len = sizeof(opponentName); - SendPacket(NP_userName, len, userName); - if (WaitMyEvent(&event, EM_net) != E_net || - event.u.net.type != NP_userName) - fatal("Network negotiation failed"); - strncpy(opponentName, event.u.net.data, - sizeof(opponentName)-1); - opponentName[sizeof(opponentName)-1] = 0; - for (i = 0; opponentName[i]; ++i) - if (!isprint(opponentName[i])) - opponentName[i] = '?'; - for (i = 0; opponentHost[i]; ++i) - if (!isprint(opponentHost[i])) - opponentHost[i] = '?'; - } - OneGame(0, 1); - } - else { - game = GT_onePlayer; - OneGame(0, -1); + game = GT_classicTwo; + if (initConn) + InitiateConnection(hostStr, portStr); + else if (waitConn) + WaitForConnection(portStr); + { + netint4 data[2]; + int major; + + data[0] = hton4(MAJOR_VERSION); + data[1] = hton4(PROTOCOL_VERSION); + SendPacket(NP_version, sizeof(data), data); + if (WaitMyEvent(&event, EM_net) != E_net) + fatal("Network negotiation failed"); + memcpy(data, event.u.net.data, sizeof(data)); + major = ntoh4(data[0]); + protocolVersion = ntoh4(data[1]); + if (event.u.net.type != NP_version || major < MAJOR_VERSION) + fatal("Your opponent is using an old, incompatible version\n" + "of Netris. They should get the latest version."); + if (major > MAJOR_VERSION) + fatal("Your opponent is using an newer, incompatible version\n" + "of Netris. Get the latest version."); + if (protocolVersion > PROTOCOL_VERSION) + protocolVersion = PROTOCOL_VERSION; } - if (wonLast) { - won++; - } else { - lost++; - WaitMyEvent(&event, EM_net); + if (protocolVersion < 3 && stepDownInterval != DEFAULT_INTERVAL) + fatal("Your opponent's version of Netris predates the -i option.\n" + "For fairness, you shouldn't use the -i option either."); + { + netint4 data[3]; + int len; + int seed; + + if (protocolVersion >= 3) + len = sizeof(data); + else + len = sizeof(netint4[2]); + if ((myFlags & SCF_setSeed)) + seed = initSeed; + else + seed = time(0); + if (waitConn) + SRandom(seed); + data[0] = hton4(myFlags); + data[1] = hton4(seed); + data[2] = hton4(stepDownInterval); + SendPacket(NP_startConn, len, data); + if (WaitMyEvent(&event, EM_net) != E_net || + event.u.net.type != NP_startConn) + fatal("Network negotiation failed"); + memcpy(data, event.u.net.data, len); + opponentFlags = ntoh4(data[0]); + seed = ntoh4(data[1]); + if (initConn) { + if ((opponentFlags & SCF_setSeed) != (myFlags & SCF_setSeed)) + fatal("If one player sets the random number seed, " + "both must."); + if ((myFlags & SCF_setSeed) && seed != initSeed) + fatal("Both players have set the random number seed, " + "and they are unequal."); + if (protocolVersion >= 3 && stepDownInterval != ntoh4(data[2])) + fatal("Your opponent is using a different step-down " + "interval (-i).\nYou must both use the same one."); + SRandom(seed); + } } - CloseNet(); - if (robotEnable) { - CloseRobot(); - } else { - gameState = STATE_WAIT_KEYPRESS; - ShowDisplayInfo(); - RefreshScreen(); - while(getchar() != keyTable[KT_new]) - ; + { + char *userName; + int len, i; + + userName = getenv("LOGNAME"); + if (!userName || !userName[0]) + userName = getenv("USER"); + if (!userName || !userName[0]) + strcpy(userName, "???"); + len = strlen(userName)+1; + if (len > sizeof(opponentName)) + len = sizeof(opponentName); + SendPacket(NP_userName, len, userName); + if (WaitMyEvent(&event, EM_net) != E_net || + event.u.net.type != NP_userName) + fatal("Network negotiation failed"); + strncpy(opponentName, event.u.net.data, + sizeof(opponentName)-1); + opponentName[sizeof(opponentName)-1] = 0; + for (i = 0; opponentName[i]; ++i) + if (!isprint(opponentName[i])) + opponentName[i] = '?'; + for (i = 0; opponentHost[i]; ++i) + if (!isprint(opponentHost[i])) + opponentHost[i] = '?'; } + OneGame(0, 1); + } + else { + game = GT_onePlayer; + OneGame(0, -1); } - return 0; } diff --git a/inet.c b/inet.c index 068cb89..a8d9a9d 100644 --- a/inet.c +++ b/inet.c @@ -42,8 +42,6 @@ static int isServer, lostConn, gotEndConn; ExtFunc void InitNet(void) { - lostConn = 0; - gotEndConn = 0; AtExit(CloseNet); } diff --git a/netris.h b/netris.h index db746e5..45d61bf 100644 --- a/netris.h +++ b/netris.h @@ -65,7 +65,7 @@ typedef long netint4; #define DEFAULT_PORT 9284 /* Very arbitrary */ -#define DEFAULT_KEYS "jkl mspf^ln" +#define DEFAULT_KEYS "jkl mspf^l" /* Protocol versions */ #define MAJOR_VERSION 1 @@ -152,13 +152,6 @@ typedef struct _ShapeOption { typedef int (*ShapeDrawFunc)(int scr, int y, int x, BlockType type, void *data); -enum States { - STATE_STARTING, - STATE_PLAYING, - STATE_WAIT_CONNECTION, - STATE_WAIT_KEYPRESS -}; - EXT GameType game; EXT int boardHeight[MAX_SCREENS]; EXT int boardVisible[MAX_SCREENS], boardWidth[MAX_SCREENS]; @@ -174,19 +167,11 @@ EXT long stepDownInterval, speed; EXT int myFlags, opponentFlags; -EXT int won, lost; -EXT enum States gameState; - EXT char scratch[1024]; extern ShapeOption stdOptions[]; extern char *version_string; -EXT int myLinesCleared; -EXT int enemyLinesCleared; -EXT int myTotalLinesCleared; -EXT int enemyTotalLinesCleared; - #include "proto.h" #endif /* NETRIS_H */ diff --git a/robot.c b/robot.c index cbd5cb2..23875a3 100644 --- a/robot.c +++ b/robot.c @@ -35,7 +35,7 @@ static EventGenRec robotGen = { NULL, 0, FT_read, -1, RobotGenFunc, EM_robot }; static int robotProcess; -static FILE *toRobot = NULL; +static FILE *toRobot; static int toRobotFd, fromRobotFd; static char robotBuf[128]; @@ -112,13 +112,10 @@ ExtFunc void RobotTimeStamp(void) ExtFunc void CloseRobot(void) { RemoveEventGen(&robotGen); - if(toRobot) { - if (robotProcess > 0) - RobotCmd(1, "Exit\n"); - fclose(toRobot); - close(fromRobotFd); - toRobot = NULL; - } + if (robotProcess > 0) + RobotCmd(1, "Exit\n"); + fclose(toRobot); + close(fromRobotFd); } static MyEventType RobotGenFunc(EventGenRec *gen, MyEvent *event) diff --git a/util.c b/util.c index 1fcae89..cb7f421 100644 --- a/util.c +++ b/util.c @@ -74,7 +74,7 @@ ExtFunc void Usage(void) " -p Set port number (default is %d)\n" " -k Remap keys. The argument is a prefix of the string\n" " containing the keys in order: left, rotate, right, drop,\n" - " down-faster, toggle-spying, pause, faster, redraw, new.\n" + " down-faster, toggle-spying, pause, faster, redraw.\n" " \"^\" prefixes controls. (default is \"%s\")\n" " -i Set the step-down interval, in seconds\n" " -r Execute (a command) as a robot controlling\n" @@ -267,7 +267,6 @@ ExtFunc volatile void die(char *msg) ExtFunc volatile void fatal(char *msg) { - CleanupScreens (); fprintf(stderr, "%s\n", msg); exit(1); } -- 2.39.5