#define HEADER_SIZE sizeof(netint4[3])
static struct option options[] = {
- { "wait", 0, 0, 'w' },
- { "port", 1, 0, 'p' },
- { "quadra", 1, 0, 'q' },
- { "min-players",1, 0, 'm' },
- { "max-players",1, 0, 'x' },
- { "continuous", 1, 0, 'c' },
- { "speed", 1, 0, 'i' },
- { "seed", 1, 0, 's' },
- { "verbose", 0, 0, 'v' },
- { "info", 0, 0, 'H' },
- { "help", 0, 0, 'h' },
- { 0, 0, 0, 0 }
+ { "wait", 0, 0, 'w' },
+ { "port", 1, 0, 'p' },
+ { "quadra", 1, 0, 'q' },
+ { "min-players", 1, 0, 'm' },
+ { "max-players", 1, 0, 'x' },
+ { "continuous", 1, 0, 'c' },
+ { "speed", 1, 0, 'i' },
+ { "seed", 1, 0, 's' },
+ { "verbose", 0, 0, 'v' },
+ { "info", 0, 0, 'H' },
+ { "help", 0, 0, 'h' },
+ { 0, 0, 0, 0 }
};
static char minplayers = 2;
if (netGen[playa].fd >= 0) {
if (Players[playa].alive >= 0) {
SendPacketTo(playa, 0, NP_endConn, 0, NULL);
- do{} while (WaitMyEvent(&event, EM_net) != E_lostConn);
+ do {} while (WaitMyEvent(&event, EM_net) != E_lostConn);
} //say bye to player
close(netGen[playa].fd);
netGen[playa].fd = -1;
sprintf(Players[new].host, "%s", inet_ntoa(addr.sin_addr));
if (addr.sin_family == AF_INET) {
host = gethostbyaddr((void *)&addr.sin_addr,
- sizeof(struct in_addr), AF_INET);
+ sizeof(struct in_addr), AF_INET);
if (host) {
strncpy(Players[new].host, host->h_name,
sizeof(Players[new].host) - 1);
int paused = 1;
int i;
char teams[10][7] = { "", "Green", "Cyan", "Blue", "Purple",
- "Red", "Grey", "White", "*Orange" };
+ "Red", "Grey", "White", "*Orange" };
do {
switch (WaitMyEvent(&event, EM_any)) {
major = ntoh4(versiondata[0]);
protocolVersion = ntoh4(versiondata[1]);
if (major != MAJOR_VERSION
- || protocolVersion != PROTOCOL_VERSION) {
+ || protocolVersion != PROTOCOL_VERSION) {
snprintf(data, sizeof(data),
"Version mismatch: received %d.%d",
major, protocolVersion);
sendtoall:
// if (event.u.net.type >= NP_pause)
if (event.u.net.type >= NP_rotright
- && Game.started < 2)
+ && Game.started < 2)
break;
for (i = 1; i < MAX_SCREENS; i++)
if (i != event.u.net.sender)
void SHeader(void)
{
fprintf(stderr,
- "NETRIS Server %s\t(c) 2002 Shiar <shiar@shiar.org>\n\n",
- version_string);
+ "NETRIS Server %s\t(c) 2002 Shiar <shiar@shiar.org>\n\n",
+ version_string);
}
void SUsage(void)
{
SHeader();
fprintf(stderr,
- "Usage: netris <options>\n"
- "\n"
- " -h, --help\t\tPrint this usage information\n"
- " -H, --info\t\tShow distribution and warranty information\n"
- "\n"
- " -p, --port <port>\tSet port number (default is %d)\n"
- "\n"
- " -s, --seed <seed>\tStart with given random seed\n"
- " -i, --speed <sec>\tSet the initial step-down interval, in seconds\n"
- " -m, --min-players <2>\tNumber of players required before starting the game\n"
- " -x, --max-players <8>\tMaximum number of players allowed in the game\n"
- " -c, --continuous\tDon'n quit the game\n"
- "\n", DEFAULT_PORT);
+ "Usage: netris <options>\n"
+ "\n"
+ " -h, --help\t\tPrint this usage information\n"
+ " -H, --info\t\tShow distribution and warranty information\n"
+ "\n"
+ " -p, --port <port>\tSet port number (default is %d)\n"
+ "\n"
+ " -s, --seed <seed>\tStart with given random seed\n"
+ " -i, --speed <sec>\tSet the initial step-down interval, in seconds\n"
+ " -m, --min-players <2>\tNumber of players required before starting the game\n"
+ " -x, --max-players <8>\tMaximum number of players allowed in the game\n"
+ " -c, --continuous\tDon'n quit the game\n"
+ "\n", DEFAULT_PORT);
}
-/*
-void DistInfo(void)
-{
- SHeader();
- 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");
-} //DistInfo
-*/
-
void WriteConf(void)
{
FILE *file_out;
void HandleOption(char tag, char *value)
{
switch (tag) {
- case 'v': //verbose
+ case 'v': //verbose
verbose = 1;
break;
- case 'p': //port
+ case 'p': //port
port = atoi(value);
break;
- case 'c': //min-players
+ case 'c': //min-players
Game.continuous = atoi(value);
break;
- case 'm': //min-players
+ case 'm': //min-players
minplayers = atoi(value);
break;
- case 'x': //max-players
+ case 'x': //max-players
maxplayers = atoi(value);
if (maxplayers >= MAX_SCREENS)
maxplayers = MAX_SCREENS;
break;
- case 'q': //quadra-style gravity
+ case 'q': //quadra-style gravity
Game.gravity ^= 1;
break;
- case 'i': //speed (of level 1)
+ case 'i': //speed (of level 1)
Game.initspeed = atof(value) * 1e6;
break;
- case 's': //seed
+ case 's': //seed
Game.seed = atoi(value);
break;
- case 'H': //info
+ case 'H': //info
+ SHeader();
DistInfo(); exit(0);
- case 'h': //help
+ case 'h': //help
SUsage(); exit(0);
default:
break;
if ((ch = strchr(buf, '#')))
*ch = '\0'; // truncate string from # char
for (i = strlen(buf)-1; i >= 0; i--)
- if (buf[i] == ' ' || buf[i] == '\t'
- || buf[i] == '\n' || buf[i] == 13)
+ if (buf[i] == ' ' || buf[i] == '\t'
+ || buf[i] == '\n' || buf[i] == 13)
buf[i] = '\0';
else break;
// ReadConf(optarg);
// else
ReadConf(CONFIG_FILE);
- while ((ch = getopt_long(argc, argv,
- "hHvqp:i:s:c:m:x:", options, NULL)) != -1)
+ while ((ch = getopt_long(
+ argc, argv, "hHvqp:i:s:c:m:x:", options, NULL
+ )) != -1)
HandleOption(ch, optarg);
if (optind < argc) {
SUsage();
die("socket");
val1 = 1;
setsockopt(connGen.fd, SOL_SOCKET, SO_REUSEADDR,
- (void *)&val1, sizeof(val1));
+ (void *)&val1, sizeof(val1));
if (bind(connGen.fd, (struct sockaddr *)&addr, sizeof(addr)) < 0)
die("bind");
if (listen(connGen.fd, 1) < 0)