code indenting/alignment fixes
[netris.git] / server.c
index 7d63e022ac06db2281ce6ec27a24f1664fb2b3a5..11c42e31a2e733d1c8e890934db1b83625bcf62e 100644 (file)
--- a/server.c
+++ b/server.c
 #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;
@@ -105,7 +105,7 @@ void SCloseNet(short playa)
        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;
@@ -188,7 +188,7 @@ static MyEventType ConnGenFunc(EventGenRec *gen, MyEvent *event)
                                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);
@@ -221,7 +221,7 @@ int StartServer(void)
        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)) {
@@ -251,7 +251,7 @@ int StartServer(void)
                                                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);
@@ -365,7 +365,7 @@ int StartServer(void)
                                        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)
@@ -424,27 +424,27 @@ int StartServer(void)
 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 WriteConf(void)
@@ -466,36 +466,36 @@ void WriteConf(void)
 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;
@@ -516,8 +516,8 @@ void ReadConf(char *filename)
                        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;
 
@@ -564,8 +564,9 @@ int main(int argc, char **argv)
 //             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();
@@ -595,7 +596,7 @@ int main(int argc, char **argv)
                        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)