From: Holger Schemel Date: Sun, 16 Feb 2020 20:20:32 +0000 (+0100) Subject: moved global random variable for EM engine to game structure X-Git-Tag: 4.2.0.0~110 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=fbc0c609bdd53fdab1d4f3b2b680dbe22aad3515;p=rocksndiamonds.git moved global random variable for EM engine to game structure --- diff --git a/src/game_em/export.h b/src/game_em/export.h index 3089d48f..66dd1334 100644 --- a/src/game_em/export.h +++ b/src/game_em/export.h @@ -28,6 +28,8 @@ struct GlobalInfo_EM struct GameInfo_EM { + unsigned int random; + boolean level_solved; boolean game_over; @@ -73,12 +75,12 @@ struct GraphicInfo_EM struct EngineSnapshotInfo_EM { struct GameInfo_EM game_em; - unsigned int RandomEM; struct LOGIC lev; struct PLAYER ply[MAX_PLAYERS]; + + int frame; int screen_x; int screen_y; - int frame; }; diff --git a/src/game_em/global.h b/src/game_em/global.h index 40d4e2cc..00b190c6 100644 --- a/src/game_em/global.h +++ b/src/game_em/global.h @@ -3,9 +3,14 @@ #include "main_em.h" + +/* global variables */ + extern int frame; +extern int screen_x, screen_y; + -/* all global function prototypes */ +/* global function prototypes */ void readjoy(byte, struct PLAYER *); diff --git a/src/game_em/init.c b/src/game_em/init.c index c99cb8e7..8be34d40 100644 --- a/src/game_em/init.c +++ b/src/game_em/init.c @@ -49,13 +49,13 @@ unsigned int InitEngineRandom_EM(int seed) int simple_rnd = GetSimpleRandom(1000); int i; - for (i = 0; i < simple_rnd || RandomEM == NEW_RANDOMIZE; i++) - RandomEM = RandomEM * 129 + 1; + for (i = 0; i < simple_rnd || game_em.random == NEW_RANDOMIZE; i++) + game_em.random = game_em.random * 129 + 1; - seed = RandomEM; + seed = game_em.random; } - RandomEM = seed; + game_em.random = seed; - return (unsigned int) seed; + return (unsigned int)seed; } diff --git a/src/game_em/input.c b/src/game_em/input.c index 7eccf546..6eadbbdf 100644 --- a/src/game_em/input.c +++ b/src/game_em/input.c @@ -6,20 +6,15 @@ #include "main_em.h" -unsigned int RandomEM; - struct CAVE cav; struct LOGIC lev; struct PLAYER ply[MAX_PLAYERS]; -extern int screen_x; -extern int screen_y; - struct EngineSnapshotInfo_EM engine_snapshot_em; void game_init_random(void) { - RandomEM = 1684108901; + game_em.random = 1684108901; } void game_init_cave_buffers(void) @@ -72,7 +67,7 @@ void GameActions_EM(byte action[MAX_PLAYERS], boolean warp_mode) int i; boolean any_player_dropping = FALSE; - RandomEM = RandomEM * 129 + 1; + game_em.random = game_em.random * 129 + 1; frame = (frame - 1) & 7; @@ -169,9 +164,7 @@ void SaveEngineSnapshotValues_EM(void) engine_snapshot_em.game_em = game_em; engine_snapshot_em.lev = lev; - engine_snapshot_em.RandomEM = RandomEM; engine_snapshot_em.frame = frame; - engine_snapshot_em.screen_x = screen_x; engine_snapshot_em.screen_y = screen_y; @@ -186,9 +179,7 @@ void LoadEngineSnapshotValues_EM(void) game_em = engine_snapshot_em.game_em; lev = engine_snapshot_em.lev; - RandomEM = engine_snapshot_em.RandomEM; frame = engine_snapshot_em.frame; - screen_x = engine_snapshot_em.screen_x; screen_y = engine_snapshot_em.screen_y; diff --git a/src/game_em/logic.c b/src/game_em/logic.c index 42166ebb..73b2d94c 100644 --- a/src/game_em/logic.c +++ b/src/game_em/logic.c @@ -1313,7 +1313,8 @@ static void check_player(struct PLAYER *ply) ply->dynamite_cnt = 0; } - RandomEM += 7; /* be a bit more random if the player doesn't move */ + /* be a bit more random if the player doesn't move */ + game_em.random += 7; return; } @@ -7157,7 +7158,8 @@ void logic_players(void) ply[i].anim = PLY_still; } - start_check_nr = (RandomEM & 128 ? 0 : 1) * 2 + (RandomEM & 256 ? 0 : 1); + start_check_nr = ((game_em.random & 128 ? 0 : 1) * 2 + + (game_em.random & 256 ? 0 : 1)); for (i = 0; i < MAX_PLAYERS; i++) { @@ -7194,7 +7196,7 @@ void logic_objects(void) next = lev.next; boom = lev.boom; - seed = RandomEM; + seed = game_em.random; score = 0; for (y = lev.top; y < lev.bottom; y++) @@ -7206,7 +7208,7 @@ void logic_objects(void) else game_em.game_over = TRUE; - RandomEM = seed; + game_em.random = seed; /* triple buffering */ void *temp = lev.cave; @@ -7254,7 +7256,7 @@ void logic_globals(void) /* grow amoeba */ - random = RandomEM; + random = game_em.random; for (count = lev.amoeba_time; count--;) { @@ -7268,7 +7270,7 @@ void logic_globals(void) random = random * 129 + 1; } - RandomEM = random; + game_em.random = random; /* handle explosions */ diff --git a/src/game_em/main_em.h b/src/game_em/main_em.h index 0e988595..2daa1e86 100644 --- a/src/game_em/main_em.h +++ b/src/game_em/main_em.h @@ -85,8 +85,6 @@ extern int SX, SY; // exported variables // ---------------------------------------------------------------------------- -extern unsigned int RandomEM; - extern struct CAVE cav; extern struct LOGIC lev; extern struct PLAYER ply[MAX_PLAYERS];