From 0e6d1c3828ceb06a67304c90ece188e97eac9241 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sun, 11 Mar 2007 03:01:50 +0100 Subject: [PATCH] shape frequency in global game data --- board.c | 2 -- board.h | 2 -- client.c | 7 +++++-- inet.c | 1 + netris.h | 3 ++- server.c | 4 ++++ 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/board.c b/board.c index a452f6d..71ad1dc 100644 --- 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 5bd6a5d..84074da 100644 --- 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]); diff --git a/client.c b/client.c index 1555e64..43c741d 100644 --- 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 e674044..33d49b0 100644 --- 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; diff --git a/netris.h b/netris.h index 99c8dcb..31c08f1 100644 --- 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; diff --git a/server.c b/server.c index ff09dc4..70406a3 100644 --- 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; -- 2.30.0