X-Git-Url: http://git.shiar.nl/netris.git/blobdiff_plain/c11ae0d113cc5f60bfd1bed29b47211013f8adef..HEAD:/netris.h diff --git a/netris.h b/netris.h index e5c69ec..31c08f1 100644 --- a/netris.h +++ b/netris.h @@ -1,6 +1,6 @@ /* - * Netris -- A free networked version of Tetris - * Copyright (C) 1994,1995 Mark Weaver + * Netris -- A free networked version of T*tris + * Copyright (C) 1994-1996,1999 Mark H. Weaver * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -15,31 +15,24 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id: netris.h,v 1.26 1995/07/11 08:53:26 mhw Exp $ */ -#ifndef NETRIS_H -#define NETRIS_H +#ifndef __NETRIS_H +#define __NETRIS_H #include "config.h" + #include #include #include #include -#define ExtFunc /* Marks functions that need prototypes */ +#define version_string "0.8" -#ifdef NOEXT +#ifdef NOEXT //prevent re-declaration # define EXT -# define IN(a) a #else # define EXT extern -# define IN(a) -#endif - -#ifndef NULL -# define NULL ((void *)0) #endif #ifdef HAS_SIGPROCMASK @@ -59,64 +52,82 @@ typedef long netint4; #define hton2(x) htons(x) #define hton4(x) htonl(x) - #define ntoh2(x) ntohs(x) #define ntoh4(x) ntohl(x) -#define DEFAULT_PORT 9284 /* Very arbitrary */ - /* Protocol versions */ -#define MAJOR_VERSION 1 -#define PROTOCOL_VERSION 3 -#define ROBOT_VERSION 1 +#define MAJOR_VERSION 1 +#define PROTOCOL_VERSION 6 -#define MAX_BOARD_WIDTH 32 -#define MAX_BOARD_HEIGHT 64 -#define MAX_SCREENS 2 +#define DEFAULT_PORT 9284 /* Very arbitrary */ -#define DEFAULT_INTERVAL 300000 /* Step-down interval in microseconds */ +#define CONFIG_FILE "netris.conf" -/* NP_startConn flags */ -#define SCF_usingRobot 000001 -#define SCF_fairRobot 000002 -#define SCF_setSeed 000004 +//#define DEFAULT_KEYS "hlkj mnfp^ltq" +//#define DEFAULT_KEYS "4685 02fp^l^mq" +#define DEFAULT_KEYS "dcaf xb^fp^l^mq" -/* Event masks */ -#define EM_alarm 000001 -#define EM_key 000002 -#define EM_net 000004 -#define EM_robot 000010 -#define EM_any 000777 +#define MAX_BOARD_WIDTH 32 +#define MAX_BOARD_HEIGHT 64 +#define MAX_SCREENS 9 //8 players -typedef enum _GameType { GT_onePlayer, GT_classicTwo, GT_len } GameType; -typedef enum _BlockTypeA { BT_none, BT_piece1, BT_wall, BT_len } BlockTypeA; -typedef enum _Dir { D_down, D_right, D_up, D_left } Dir; -typedef enum _Cmd { C_end, C_forw, C_back, C_left, C_right, C_plot } Cmd; +/* Event masks */ +#define EM_alarm 000001 +#define EM_key 000002 +#define EM_net 000004 +#define EM_connect 000020 +#define EM_any 000777 + +typedef enum _BlockTypeA { + BT_shadow, BT_none, + BT_S, BT_L, BT_I, BT_O, BT_Z, BT_J, BT_T, + BT_wall, BT_len +} BlockTypeA; typedef enum _FDType { FT_read, FT_write, FT_except, FT_len } FDType; -typedef enum _MyEventType { E_none, E_alarm, E_key, E_net, - E_lostConn, E_robot, E_lostRobot } MyEventType; -typedef enum _NetPacketType { NP_endConn, NP_giveJunk, NP_newPiece, - NP_down, NP_left, NP_right, - NP_rotate, NP_drop, NP_clear, - NP_insertJunk, NP_startConn, - NP_userName, NP_pause, NP_version, - NP_byeBye } NetPacketType; - -typedef signed char BlockType; - +typedef enum _MyEventType { + E_none, E_alarm, E_key, E_connect, E_net, E_lostConn +} MyEventType; +typedef enum _NetPacketType { + NP_endConn, //client/server quits + NP_byeBye, //unused atm + NP_error, //handshake error + NP_hello, //check versions + NP_gamedata, //game options + + NP_start, //game ok to start + NP_pause, //player (un)pauses + NP_stop, //game ended + NP_newPlayer, //add new player + NP_team, //player switched teams + NP_argghhh, //player died + NP_part, //player left + + NP_msg, //chat message + + NP_newPiece, //new piece info + NP_rotright, //rotate piece clockwise + NP_rotleft, //rotate piece counterclockwise + NP_left, //move piece left + NP_right, //move piece right + NP_down, //move piece one down + NP_drop, //drop piece to bottom + NP_clear, //line cleared + NP_insertJunk, //player added junk + + NP_giveJunk //player has to add junk +} NetPacketType; + +typedef struct { + short sender, uid; + NetPacketType type; + int size; + void *data; +} _netEvent; typedef struct _MyEvent { MyEventType type; union { char key; - struct { - NetPacketType type; - int size; - void *data; - } net; - struct { - int size; - char *data; - } robot; + _netEvent net; } u; } MyEvent; @@ -130,45 +141,59 @@ typedef struct _EventGenRec { int fd; EventGenFunc func; int mask; + short player; + char buf[512]; + int bufSize, bufGoal; } EventGenRec; -typedef struct _Shape { - struct _Shape *rotateTo; - int initY, initX, mirrored; - Dir initDir; - BlockType type; - Cmd *cmds; -} Shape; - -typedef struct _ShapeOption { - float weight; - Shape *shape; -} ShapeOption; - -typedef int (*ShapeDrawFunc)(int scr, int y, int x, - BlockType type, void *data); - -EXT GameType game; -EXT int boardHeight[MAX_SCREENS]; -EXT int boardVisible[MAX_SCREENS], boardWidth[MAX_SCREENS]; -EXT Shape *curShape[MAX_SCREENS]; -EXT int curY[MAX_SCREENS], curX[MAX_SCREENS]; -EXT char opponentName[16], opponentHost[256]; -EXT int standoutEnable; -EXT int robotEnable, robotVersion, fairRobot; -EXT int protocolVersion; - -EXT long initSeed; -EXT long stepDownInterval, speed; - -EXT int myFlags, opponentFlags; - -EXT char scratch[1024]; - -extern ShapeOption stdOptions[]; -extern char *version_string; - -#include "proto.h" +/* NP_startConn flags */ +#define SCF_paused 1 + +typedef struct { + int alive; + char name[16]; + int flags; + int team; + int boardHeight, boardWidth, boardVisible; + int curX, curY; + char curShape, nextShape; + struct score_t { + short level; + long score; + int pieces, lines, adds; + } score; + char host[256]; //last +} player_t; +EXT player_t Players[MAX_SCREENS]; +EXT short me; +EXT short maxPlayer; +EXT int spied; //in player.flags + +#define DEFAULT_INTERVAL 1000000 /* Step-down interval in microseconds */ +#define SPEEDINC 1.2 +#define SPEEDMINIMUM 40000 -#endif /* NETRIS_H */ +typedef enum _GameType { GT_onePlayer, GT_classicTwo, GT_len } GameType; +typedef struct { + GameType type; + int gravity; //1 + int started; //2 + int continuous; //3 + long seed; //4 + float shapes[7]; + int initspeed; //5 + int speed; +} game_t; +EXT game_t Game; + +#define MSG_WIDTH 128 + +EXT short port; // => just in client.c, parameter to inet connect + +static const char *teamname[] = { + "", "Green", "Cyan", "Blue", "Purple", + "Red", "Grey", "White", "*Orange" +}; + +#endif //__NETRIS_H