Avoid extern and superfluous declares; static wherever possible.
return board[scr][y][x];
}
return board[scr][y][x];
}
-void SetBlock(int scr, int y, int x, unsigned char type)
+static void SetBlock(int scr, int y, int x, unsigned char type)
{
if (y >= 0 && y < Players[scr].boardHeight
&& x >= 0 && x < Players[scr].boardWidth) {
{
if (y >= 0 && y < Players[scr].boardHeight
&& x >= 0 && x < Players[scr].boardWidth) {
extern char ChooseOption(float options[7]);
extern void ClearField(int scr);
extern unsigned char GetBlock(int scr, int y, int x);
extern char ChooseOption(float options[7]);
extern void ClearField(int scr);
extern unsigned char GetBlock(int scr, int y, int x);
-extern void SetBlock(int scr, int y, int x, unsigned char type);
extern int RefreshBoard(int scr);
extern int GlanceFunc(int scr, int y, int x, unsigned char type);
extern int ShadowFunc(int scr, int y, int x, unsigned char type);
extern int RefreshBoard(int scr);
extern int GlanceFunc(int scr, int y, int x, unsigned char type);
extern int ShadowFunc(int scr, int y, int x, unsigned char type);
-void handle_setkeys(char *newKeys)
+static void handle_setkeys(char *newKeys)
{
int i, k, ch;
char used[256];
{
int i, k, ch;
char used[256];
{
Header();
fprintf(stderr,
{
Header();
fprintf(stderr,
-void handle_arg(char tag, char *value)
+static void handle_arg(char tag, char *value)
{
switch (tag) {
case 'a': //ascii
{
switch (tag) {
case 'a': //ascii
-void handle_conffile(char *filename)
+static void handle_conffile(char *filename)
{
FILE *file_in;
char buf[513];
{
FILE *file_in;
char buf[513];
-int game_piece(int scr, char shape)
+static int game_piece(int scr, char shape)
{
Players[scr].score.pieces++;
{
{
Players[scr].score.pieces++;
{
-void game_setpaused(void)
+static void game_setpaused(void)
{ //check whether anyone paused the game
int i;
{ //check whether anyone paused the game
int i;
paused |= (Players[i].flags & SCF_paused) != 0;
}
paused |= (Players[i].flags & SCF_paused) != 0;
}
+static void game_reset(void)
-void game_clear(int scr)
+static void game_clear(int scr)
{ //check for full lines
int linesCleared;
int linevalues[] = { 40, 100, 400, 1200, }; //= 50*lines! - 10*(lines==1)
{ //check for full lines
int linesCleared;
int linevalues[] = { 40, 100, 400, 1200, }; //= 50*lines! - 10*(lines==1)
+static void game_loop(void)
{
bool changed = 0;
short gameStatus = 2; //2=loop; 1=new piece; 0=quit
{
bool changed = 0;
short gameStatus = 2; //2=loop; 1=new piece; 0=quit
int PlayerDisp[MAX_SCREENS];
#define MSG_HEIGHT 64 //max history
int PlayerDisp[MAX_SCREENS];
#define MSG_HEIGHT 64 //max history
-char *message[MSG_HEIGHT];
-char messages[MSG_HEIGHT][MSG_WIDTH];
+static char *message[MSG_HEIGHT];
+static char messages[MSG_HEIGHT][MSG_WIDTH];
static char *term_vi; /* String to make cursor invisible */
static char *term_ve; /* String to make cursor visible */
static char *term_vi; /* String to make cursor invisible */
static char *term_ve; /* String to make cursor visible */
OutputTermStr(term_ve, 1);
}
OutputTermStr(term_ve, 1);
}
-void GetTermcapInfo(void)
+static void GetTermcapInfo(void)
{
char *term, *buf, *data;
int bufSize = 8192;
{
char *term, *buf, *data;
int bufSize = 8192;
term_vi = term_ve = NULL;
}
term_vi = term_ve = NULL;
}
-void OutputTermStr(char *str, int flush)
+static void OutputTermStr(char *str, int flush)
{
if (str) {
fputs(str, stdout);
{
if (str) {
fputs(str, stdout);
+static void DrawTitle(void)
{
int rows, cols;
char *s;
{
int rows, cols;
char *s;
-void DisplayMessage(char *p)
+static void DisplayMessage(char *p)
{
char s[MSG_WIDTH];
char *psearch;
{
char s[MSG_WIDTH];
char *psearch;
-void PlotBlock1(int y, int x, unsigned char type)
+static void PlotBlock1(int y, int x, unsigned char type)
{ //display block on screen
move(y, x);
if (type == BT_none) addstr(" ");
{ //display block on screen
move(y, x);
if (type == BT_none) addstr(" ");
#endif
} //display one brick
}
#endif
} //display one brick
}
-void PlotBlock1S(int y, int x, unsigned char type)
+static void PlotBlock1S(int y, int x, unsigned char type)
{ //display block small
move(y, x);
if (type == BT_none) addch(' ');
{ //display block small
move(y, x);
if (type == BT_none) addch(' ');
-void CatchWinCh(int sig)
+static void CatchWinCh(int sig)
{ //handle window resize
endwin(); //exit curses
refresh(); //and reinit display (with different sizes)
{ //handle window resize
endwin(); //exit curses
refresh(); //and reinit display (with different sizes)
extern void InitScreens(void);
extern void CleanupScreens(void);
extern void InitScreens(void);
extern void CleanupScreens(void);
-extern void GetTermcapInfo(void);
-extern void OutputTermStr(char *str, int flush);
-extern void DrawTitle(void);
+static void GetTermcapInfo(void);
+static void OutputTermStr(char *str, int flush);
extern void DrawBox(int x1, int y1, int x2, int y2);
extern void DrawField(int scr);
extern void InitFields(void);
extern void DrawBox(int x1, int y1, int x2, int y2);
extern void DrawField(int scr);
extern void InitFields(void);
-extern void DisplayMessage(char *p);
+static void DisplayMessage(char *p);
extern void Messagef(char *fmt, ...);
extern void Messagetype(char c, int x, char *s);
extern void Messagef(char *fmt, ...);
extern void Messagetype(char c, int x, char *s);
-extern void PlotBlock1(int y, int x, unsigned char type);
-extern void PlotBlock1S(int y, int x, unsigned char type);
extern void PlotBlock(int scr, int y, int x, unsigned char type);
extern void PlotBlockXY(int y, int x, unsigned char type);
extern void ShowScore(int scr, struct _Score score);
extern void PlotBlock(int scr, int y, int x, unsigned char type);
extern void PlotBlockXY(int y, int x, unsigned char type);
extern void ShowScore(int scr, struct _Score score);
extern void ShowPause(int playa);
extern void ShowTime(void);
extern void ScheduleFullRedraw(void);
extern void ShowPause(int playa);
extern void ShowTime(void);
extern void ScheduleFullRedraw(void);
-extern void CatchWinCh(int sig);
+static void CatchWinCh(int sig);
#define HEADER_SIZE sizeof(netint2[2])
#define HEADER_SIZE3 sizeof(netint4[3])
#define HEADER_SIZE sizeof(netint2[2])
#define HEADER_SIZE3 sizeof(netint4[3])
-MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event);
-EventGenRec netGen = {
+static MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event);
+static EventGenRec netGen = {
NULL, 0, FT_read, -1, NetGenFunc, EM_net, 0, "\0", 0, HEADER_SIZE3
};
static sigjmp_buf close_env;
NULL, 0, FT_read, -1, NetGenFunc, EM_net, 0, "\0", 0, HEADER_SIZE3
};
static sigjmp_buf close_env;
+static void CatchInt(int sig)
{
siglongjmp(close_env, 1);
}
{
siglongjmp(close_env, 1);
}
-MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event)
+static MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event)
{ //receive
int result;
short uid, type, size;
{ //receive
int result;
short uid, type, size;
#ifndef __INET_H
#define __INET_H
#ifndef __INET_H
#define __INET_H
-extern MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event);
extern int InitiateConnection(char *hostStr, short port);
extern void HandShake(void);
extern int InitiateConnection(char *hostStr, short port);
extern void HandShake(void);
-extern MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event);
extern void SendPacket(short uid, NetPacketType type, int size, void *data);
extern void SendPacket(short uid, NetPacketType type, int size, void *data);
-extern void CloseNet(void);
+static void CloseNet(void);
int bufSize, bufGoal;
} EventGenRec;
int bufSize, bufGoal;
} EventGenRec;
-MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event);
-
/* NP_startConn flags */
#define SCF_paused 1
/* NP_startConn flags */
#define SCF_paused 1
-MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event);
+static MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event);
static EventGenRec netGen[MAX_SCREENS] = {
{ NULL, 0, FT_read, -1, NetGenFunc, EM_net, 0, "\0", 0, HEADER_SIZE }
};
static EventGenRec netGen[MAX_SCREENS] = {
{ NULL, 0, FT_read, -1, NetGenFunc, EM_net, 0, "\0", 0, HEADER_SIZE }
};
static sigjmp_buf close_env;
static sigjmp_buf close_env;
-void SendPacketTo(short playa, short uid, NetPacketType type, int size, void *data)
+static void SendPacketTo(short playa, short uid, NetPacketType type, int size, void *data)
{ //send to someone
netint4 header[3];
{ //send to someone
netint4 header[3];
-void SCloseNet(short playa)
+static void SCloseNet(short playa)
{ //kick some connection's ass!
MyEvent event;
{ //kick some connection's ass!
MyEvent event;
RemoveEventGen(&netGen[playa]);
}
RemoveEventGen(&netGen[playa]);
}
+static void CloseNets(void)
{ //nou oogjes dicht en snaveltjes toe
int i;
{ //nou oogjes dicht en snaveltjes toe
int i;
fprintf(stderr, MSG_SERVER_CLOSE_ALL_DONE "\n\n");
}
fprintf(stderr, MSG_SERVER_CLOSE_ALL_DONE "\n\n");
}
-MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event)
+static MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event)
{ //receive
int result;
short uid, type, size;
{ //receive
int result;
short uid, type, size;
+static void CountPlayers(void)
{ //count number of players/teams
int i, j;
playercount = 0;
{ //count number of players/teams
int i, j;
playercount = 0;
+static int StartServer(void)
{
MyEvent event;
netint2 currentpiece[MAX_SCREENS];
{
MyEvent event;
netint2 currentpiece[MAX_SCREENS];
+static void SHeader(void)
{
fprintf(stderr, MSG_SERVER_TITLE "\n\n", version_string);
}
{
fprintf(stderr, MSG_SERVER_TITLE "\n\n", version_string);
}
+static void SUsage(void)
{
SHeader();
fprintf(stderr,
{
SHeader();
fprintf(stderr,
-void HandleOption(char tag, char *value)
+static void HandleOption(char tag, char *value)
{
switch (tag) {
case 'v': //verbose
{
switch (tag) {
case 'v': //verbose
-void ReadConf(char *filename)
+static void ReadConf(char *filename)
{
FILE *file_in;
char buf[513];
{
FILE *file_in;
char buf[513];
+static void CatchInt(int sig)
{
siglongjmp(close_env, 1);
}
{
siglongjmp(close_env, 1);
}
extern void AddEventGen(EventGenRec *gen);
extern void RemoveEventGen(EventGenRec *gen);
extern MyEventType WaitMyEvent(MyEvent *event, int mask);
extern void AddEventGen(EventGenRec *gen);
extern void RemoveEventGen(EventGenRec *gen);
extern MyEventType WaitMyEvent(MyEvent *event, int mask);
-extern void CatchInt(int sig);