shape frequency in global game data
authorMischa POSLAWSKY <netris@shiar.org>
Sun, 11 Mar 2007 02:01:50 +0000 (03:01 +0100)
committerMischa POSLAWSKY <netris@shiar.org>
Sun, 11 Mar 2007 02:01:50 +0000 (03:01 +0100)
board.c
board.h
client.c
inet.c
netris.h
server.c

diff --git a/board.c b/board.c
index a452f6dc0035f24fc0b62e7b1384bdd34be8764f..71ad1dcc25556dfa9e118d55fadd8b503fb3a9b3 100644 (file)
--- a/board.c
+++ b/board.c
@@ -172,8 +172,6 @@ int shape_iterate(char s, int scr, int y, int x, ShapeDrawFunc func)
 }
 
 
-float stdOptions[7] = {1, 1, 1, 1, 1, 1, 1}; //stdOptions
-
 char ChooseOption(float options[7])
 { //Return a random piece with given piece weight
        int i;
diff --git a/board.h b/board.h
index 5bd6a5d5245045099cd24219b44ea7ac0027d070..84074da823a6390ca0368cdfb9541fdf6cf6da30 100644 (file)
--- a/board.h
+++ b/board.h
@@ -1,8 +1,6 @@
 #ifndef __BOARD_H
 #define __BOARD_H
 
-extern float stdOptions[7];
-
 typedef int (*ShapeDrawFunc)(int scr, int y, int x, unsigned char type);
 extern int shape_iterate(char s, int scr, int y, int x, ShapeDrawFunc func);
 extern char ChooseOption(float options[7]);
index 1555e64e235c9399ff7eefa18c21cc5f98c8a176..43c741d6f159b4090eda450e56a84cb09f405ea0 100644 (file)
--- a/client.c
+++ b/client.c
@@ -262,7 +262,7 @@ static void game_reset(void)
 
        ResetBaseTime();  //reset timer
        SetITimer(Game.speed, Game.speed);
-       Players[me].nextShape = ChooseOption(stdOptions);
+       Players[me].nextShape = ChooseOption(Game.shapes);
        for (i = 1; i <= maxPlayer; i++) {
                Players[i].score.score = Players[i].score.lines
                = Players[i].score.adds = 0;
@@ -684,7 +684,7 @@ static void game_loop(void)
        while (gameStatus) {
                gameStatus = 2;
                if (Players[me].alive > 0) {
-                       if (!player_piece(me, ChooseOption(stdOptions))) {
+                       if (!player_piece(me, ChooseOption(Game.shapes))) {
                                netint4 data[4];
 
                                Players[me].alive = 0;
@@ -812,7 +812,10 @@ int main(int argc, char **argv)
                game_loop();
        } //client
        else {
+               int i;
                Game.seed = time(0);
+               for (i = 0; i < sizeof(Game.shapes) / sizeof(Game.shapes[0]); i++)
+                       Game.shapes[i] = 1;
                Game.started = 2;
                me = 1;
                memcpy(&Players[me], &Players[0], sizeof(player_t));
diff --git a/inet.c b/inet.c
index e6740443f3b64355270d054d488d508a7c52c773..33d49b05c0a767b826c951c031bc1caea82b76da 100644 (file)
--- a/inet.c
+++ b/inet.c
@@ -117,6 +117,7 @@ void HandShake(void)
                                        int started;     //2
                                        int continuous;  //3
                                        long seed;       //4
+                                       float shapes[7];
                                        int initspeed;   //5
                                } data;
 
index 99c8dcbd06c192fc2ed8c5ddf6e64296ed462f02..31c08f1f1c4f905dc741abd193b7f73f74faa59b 100644 (file)
--- a/netris.h
+++ b/netris.h
@@ -57,7 +57,7 @@ typedef long netint4;
 
 /* Protocol versions */
 #define MAJOR_VERSION     1
-#define PROTOCOL_VERSION  4
+#define PROTOCOL_VERSION  6
 
 #define DEFAULT_PORT 9284  /* Very arbitrary */
 
@@ -180,6 +180,7 @@ typedef struct {
        int started;     //2
        int continuous;  //3
        long seed;       //4
+       float shapes[7];
        int initspeed;   //5
        int speed;
 } game_t;
index ff09dc43f9895969d72822e12e0087abd6c6f5ca..70406a3b4daec99a11f2226fd91fd05302e77f6d 100644 (file)
--- a/server.c
+++ b/server.c
@@ -306,6 +306,7 @@ static int StartServer(void)
                                                        int started;    //2
                                                        int continuous; //3
                                                        long seed;              //4
+                                                       float shapes[7];
                                                        int initspeed;  //5
                                                } data;
 
@@ -531,6 +532,7 @@ static void CatchInt(int sig)
 
 int main(int argc, char **argv)
 {
+       int i;
        char ch;
 
        if (sigsetjmp(close_env, 1)) exit(0);
@@ -539,6 +541,8 @@ int main(int argc, char **argv)
        maxplayers = 8;
        Game.initspeed = DEFAULT_INTERVAL;
        Game.seed = time(0);
+       for (i = 0; i < sizeof(Game.shapes) / sizeof(Game.shapes[0]); i++)
+               Game.shapes[i] = 1;
        Game.gravity = 0;
        {
                int i;