unofficial version 0.7: multiplayer improvements
[netris.git] / inet.c
diff --git a/inet.c b/inet.c
index 85b1b70a1fc384f6911e306cd7cc6ce6d3e504e5..b21b1374437b668bcbf4251401f3809676ea37b1 100644 (file)
--- a/inet.c
+++ b/inet.c
@@ -37,30 +37,13 @@ ExtFunc MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event);
 EventGenRec netGen[MAX_SCREENS] = {
        { NULL, 0, FT_read, -1, NetGenFunc, EM_net, 0, "\0", 0, HEADER_SIZE3 } };
 
-//static char netBuf[64];
-//static int netBufSize, netBufGoal = HEADER_SIZE3;
 
-ExtFunc void make_netGen(void)
-{
-       int i;
-
-       for (i = 1; i <= MAX_SCREENS; i++)
-               memcpy(netGen+i, &netGen[0], sizeof(EventGenRec));
-} //Make_netGen
-
-
-ExtFunc int InitiateConnection(char *hostStr, char *portStr)
+ExtFunc int InitiateConnection(char *hostStr, short port)
 { //connect to host
        struct sockaddr_in addr;
        struct hostent *host;
-       short port;
 
-//     make_netGen();
        AtExit(CloseNet);
-       if (portStr)
-               port = atoi(portStr);   /* XXX Error checking */
-       else
-               port = DEFAULT_PORT;
        host = gethostbyname(hostStr);
        if (!host)
                die("gethostbyname");
@@ -80,7 +63,7 @@ ExtFunc int InitiateConnection(char *hostStr, char *portStr)
                goto again;
        }
        AddEventGen(&netGen[0]);
-       totalPlayers = 0;
+       totalPlayers = 1;
        return 0;
 } //InitiateConnection
 
@@ -111,7 +94,8 @@ ExtFunc void HandShake(void)
                        }
                        case NP_gamedata:
                        {
-                               fprintf(stderr, ": %d\n", event.type);
+                               memcpy(&Game, event.u.net.data, event.u.net.size);
+                               SRandom(Game.seed);
                                break;
                        }
                        case NP_newPlayer: