From: Holger Schemel Date: Wed, 15 Feb 2006 23:02:52 +0000 (+0100) Subject: rnd-20060216-1-src X-Git-Tag: 3.2.0^2~69 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=d14ff3d04c44d90b4dc151fd7774946e20da0152;p=rocksndiamonds.git rnd-20060216-1-src * fixed bug with adding score when playing tape with EMC game engine * added steel wall border for levels using EMC engine without border * finally fixed delayed scrolling in EMC engine also for small levels --- diff --git a/ChangeLog b/ChangeLog index d9114718..915e1ba5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-02-15 + * fixed bug with adding score when playing tape with EMC game engine + * added steel wall border for levels using EMC engine without border + * finally fixed delayed scrolling in EMC engine also for small levels + 2006-02-12 * fixed potential crash bug in WarnBuggyBase() (missing boundary check) diff --git a/src/conftime.h b/src/conftime.h index 99eb7d90..efe090e5 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2006-02-12 13:35]" +#define COMPILE_DATE_STRING "[2006-02-15 23:26]" diff --git a/src/files.c b/src/files.c index 3d4bd2ef..0088e431 100644 --- a/src/files.c +++ b/src/files.c @@ -119,6 +119,10 @@ #define CONF_CONTENTS_ELEMENT(b,c,x,y) ((b[CONF_CONTENT_BYTE_POS(c,x,y)]<< 8)|\ (b[CONF_CONTENT_BYTE_POS(c,x,y) + 1])) +#if 0 +static void LoadLevel_InitPlayfield(struct LevelInfo *, char *); +#endif + static struct LevelInfo li; static struct @@ -2497,6 +2501,45 @@ void CopyNativeLevel_RND_to_EM(struct LevelInfo *level) for (x = 0; x < EM_MAX_CAVE_WIDTH; x++) level_em->cave[x][y] = ZBORDER; +#if 1 + +#if 0 +#if 1 + LoadLevel_InitPlayfield(); +#else + lev_fieldx = lev->width; /* !!! also in LoadLevel_InitPlayfield() !!! */ + lev_fieldy = lev->height; /* !!! also in LoadLevel_InitPlayfield() !!! */ + SetBorderElement(); /* !!! also in LoadLevel_InitPlayfield() !!! */ +#endif +#endif + +#if 0 + printf("::: BorderElement == %d\n", BorderElement); +#endif + + if (BorderElement == EL_STEELWALL) + { + for (y = 0; y < lev->height + 2; y++) + for (x = 0; x < lev->width + 2; x++) + level_em->cave[x + 1][y + 1] = map_element_RND_to_EM(EL_STEELWALL); + } + + /* then copy the real level contents from level file into the playfield */ + for (y = 0; y < lev->height; y++) for (x = 0; x < lev->width; x++) + { + int new_element = map_element_RND_to_EM(level->field[x][y]); + int offset = (BorderElement == EL_STEELWALL ? 1 : 0); + int xx = x + 1 + offset; + int yy = y + 1 + offset; + + if (level->field[x][y] == EL_AMOEBA_DEAD) + new_element = map_element_RND_to_EM(EL_AMOEBA_WET); + + level_em->cave[xx][yy] = new_element; + } + +#else + /* then copy the real level contents from level file into the playfield */ for (y = 0; y < lev->height; y++) for (x = 0; x < lev->width; x++) { @@ -2508,6 +2551,8 @@ void CopyNativeLevel_RND_to_EM(struct LevelInfo *level) level_em->cave[x + 1][y + 1] = new_element; } +#endif + #if 1 for (i = 0; i < MAX_PLAYERS; i++) @@ -2531,15 +2576,17 @@ void CopyNativeLevel_RND_to_EM(struct LevelInfo *level) { #if 1 - if (ELEM_IS_PLAYER(level->field[x][y])) { int player_nr = GET_PLAYER_NR(level->field[x][y]); + int offset = (BorderElement == EL_STEELWALL ? 1 : 0); + int xx = x + 1 + offset; + int yy = y + 1 + offset; - ply[player_nr]->x_initial = x + 1; - ply[player_nr]->y_initial = y + 1; + ply[player_nr]->x_initial = xx; + ply[player_nr]->y_initial = yy; - level_em->cave[x + 1][y + 1] = map_element_RND_to_EM(EL_EMPTY); + level_em->cave[xx][yy] = map_element_RND_to_EM(EL_EMPTY); } #else @@ -2571,6 +2618,14 @@ void CopyNativeLevel_RND_to_EM(struct LevelInfo *level) #endif } + + if (BorderElement == EL_STEELWALL) + { +#if 1 + lev->width += 2; + lev->height += 2; +#endif + } } void CopyNativeLevel_EM_to_RND(struct LevelInfo *level) @@ -3145,10 +3200,15 @@ void LoadLevelFromFileInfo(struct LevelInfo *level, if (level->game_engine_type == GAME_ENGINE_TYPE_UNKNOWN) level->game_engine_type = GAME_ENGINE_TYPE_RND; +#if 1 + if (level_file_info->type != LEVEL_FILE_TYPE_RND) + CopyNativeLevel_Native_to_RND(level); +#else if (level_file_info->type == LEVEL_FILE_TYPE_RND) CopyNativeLevel_RND_to_Native(level); else CopyNativeLevel_Native_to_RND(level); +#endif } void LoadLevelFromFilename(struct LevelInfo *level, char *filename) @@ -3447,6 +3507,21 @@ static void LoadLevel_InitPlayfield(struct LevelInfo *level, char *filename) SetBorderElement(); } +static void LoadLevel_InitNativeEngines(struct LevelInfo *level,char *filename) +{ + struct LevelFileInfo *level_file_info = &level->file_info; + +#if 1 + if (level_file_info->type == LEVEL_FILE_TYPE_RND) + CopyNativeLevel_RND_to_Native(level); +#else + if (level_file_info->type == LEVEL_FILE_TYPE_RND) + CopyNativeLevel_RND_to_Native(level); + else + CopyNativeLevel_Native_to_RND(level); +#endif +} + void LoadLevelTemplate(int nr) { char *filename; @@ -3477,6 +3552,8 @@ void LoadLevel(int nr) LoadLevel_InitVersion(&level, filename); LoadLevel_InitElements(&level, filename); LoadLevel_InitPlayfield(&level, filename); + + LoadLevel_InitNativeEngines(&level, filename); } static void SaveLevel_VERS(FILE *file, struct LevelInfo *level) diff --git a/src/game.c b/src/game.c index 79ba0e8a..9e4d2871 100644 --- a/src/game.c +++ b/src/game.c @@ -2657,6 +2657,13 @@ void GameWon() BackToFront(); +#if 0 + if (tape.playing) + printf("::: TAPE PLAYING -> DO NOT SAVE SCORE\n"); + else + printf("::: NO TAPE PLAYING -> SAVING SCORE\n"); +#endif + if (tape.playing) return; diff --git a/src/game_em/convert.c b/src/game_em/convert.c index 7b3b036a..e695f373 100644 --- a/src/game_em/convert.c +++ b/src/game_em/convert.c @@ -548,7 +548,7 @@ void convert_em_level(unsigned char *src, int file_version) { 0x800, 0x809, 0x812, 0x81B, 0x840, 0x849, 0x852, 0x85B }; - unsigned int i, x, y, temp; + int i, x, y, temp; #if 1 lev.time_seconds = src[0x83E] << 8 | src[0x83F]; @@ -901,7 +901,7 @@ void convert_em_level(unsigned char *src, int file_version) void prepare_em_level(void) { - unsigned int i, x, y; + int i, x, y; int players_left; /* reset all runtime variables to their initial values */ diff --git a/src/game_em/global.h b/src/game_em/global.h index e60f9629..2f062e51 100644 --- a/src/game_em/global.h +++ b/src/game_em/global.h @@ -14,7 +14,7 @@ extern int debug; extern char *progname; extern char *arg_basedir; -extern unsigned int frame; +extern int frame; extern short ulaw_to_linear[256]; extern unsigned char linear_to_ulaw[65536]; diff --git a/src/game_em/graphics.c b/src/game_em/graphics.c index 5682a24e..236b8289 100644 --- a/src/game_em/graphics.c +++ b/src/game_em/graphics.c @@ -7,11 +7,15 @@ #include "display.h" #include "level.h" +#define MIN_SCREEN_XPOS 1 +#define MIN_SCREEN_YPOS 1 +#define MAX_SCREEN_XPOS MAX(1, lev.width - (SCR_FIELDX - 1)) +#define MAX_SCREEN_YPOS MAX(1, lev.height - (SCR_FIELDY - 1)) -#define MIN_SCREEN_X (TILEX) -#define MIN_SCREEN_Y (TILEY) -#define MAX_SCREEN_X ((lev.width - (SCR_FIELDX - 1)) * TILEX) -#define MAX_SCREEN_Y ((lev.height - (SCR_FIELDY - 1)) * TILEY) +#define MIN_SCREEN_X (MIN_SCREEN_XPOS * TILEX) +#define MIN_SCREEN_Y (MIN_SCREEN_YPOS * TILEY) +#define MAX_SCREEN_X (MAX_SCREEN_XPOS * TILEX) +#define MAX_SCREEN_Y (MAX_SCREEN_YPOS * TILEY) #define VALID_SCREEN_X(x) ((x) < MIN_SCREEN_X ? MIN_SCREEN_X : \ (x) > MAX_SCREEN_X ? MAX_SCREEN_X : (x)) @@ -26,18 +30,18 @@ - ((SCR_FIELDY - 1) * TILEY) / 2) -unsigned int frame; /* current screen frame */ +int frame; /* current screen frame */ #if 0 -unsigned int screen_x; /* current scroll position */ -unsigned int screen_y; +int screen_x; /* current scroll position */ +int screen_y; #else int screen_x; /* current scroll position */ int screen_y; #endif /* tiles currently on screen */ -static unsigned int screentiles[MAX_BUF_YSIZE][MAX_BUF_XSIZE]; -static unsigned int crumbled_state[MAX_BUF_YSIZE][MAX_BUF_XSIZE]; +static int screentiles[MAX_BUF_YSIZE][MAX_BUF_XSIZE]; +static int crumbled_state[MAX_BUF_YSIZE][MAX_BUF_XSIZE]; static boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; @@ -49,8 +53,8 @@ static boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; void BlitScreenToBitmap_EM(Bitmap *target_bitmap) { - unsigned int x = screen_x % (MAX_BUF_XSIZE * TILEX); - unsigned int y = screen_y % (MAX_BUF_YSIZE * TILEY); + int x = screen_x % (MAX_BUF_XSIZE * TILEX); + int y = screen_y % (MAX_BUF_YSIZE * TILEY); if (x < 2 * TILEX && y < 2 * TILEY) { @@ -97,8 +101,8 @@ void blitscreen(void) #if 1 static boolean scrolling_last = FALSE; - unsigned int left = screen_x / TILEX; - unsigned int top = screen_y / TILEY; + int left = screen_x / TILEX; + int top = screen_y / TILEY; boolean scrolling = (screen_x % TILEX != 0 || screen_y % TILEY != 0); int x, y; @@ -182,7 +186,7 @@ static void DrawLevelFieldCrumbled_EM(int x, int y, int sx, int sy, { int tile = Draw[y][x]; struct GraphicInfo_EM *g = &graphic_info_em_object[tile][frame]; - unsigned int i; + int i; if (crm == 0) /* no crumbled edges for this tile */ return; @@ -295,9 +299,9 @@ static void DrawLevelPlayer_EM(int x1, int y1, int player_nr, int anim, static void animscreen(void) { - unsigned int x, y, i; - unsigned int left = screen_x / TILEX; - unsigned int top = screen_y / TILEY; + int x, y, i; + int left = screen_x / TILEX; + int top = screen_y / TILEY; static int xy[4][2] = { { 0, -1 }, @@ -314,8 +318,8 @@ static void animscreen(void) int sy = y % MAX_BUF_YSIZE; int tile = Draw[y][x]; struct GraphicInfo_EM *g = &graphic_info_em_object[tile][frame]; - unsigned int obj = g->unique_identifier; - unsigned int crm = 0; + int obj = g->unique_identifier; + int crm = 0; /* re-calculate crumbled state of this tile */ if (g->has_crumbled_graphics) @@ -361,7 +365,7 @@ static void animscreen(void) static void blitplayer(struct PLAYER *ply) { - unsigned int x1, y1, x2, y2; + int x1, y1, x2, y2; if (!ply->alive) return; @@ -372,8 +376,8 @@ static void blitplayer(struct PLAYER *ply) x2 = x1 + TILEX - 1; y2 = y1 + TILEY - 1; - if ((unsigned int)(x2 - screen_x) < ((MAX_BUF_XSIZE - 1) * TILEX - 1) && - (unsigned int)(y2 - screen_y) < ((MAX_BUF_YSIZE - 1) * TILEY - 1)) + if ((int)(x2 - screen_x) < ((MAX_BUF_XSIZE - 1) * TILEX - 1) && + (int)(y2 - screen_y) < ((MAX_BUF_YSIZE - 1) * TILEY - 1)) { /* some casts to "int" are needed because of negative calculation values */ int dx = (int)ply->x - (int)ply->oldx; @@ -439,7 +443,7 @@ static void blitplayer(struct PLAYER *ply) void game_initscreen(void) { - unsigned int x,y; + int x,y; int dynamite_state = ply[0].dynamite; /* !!! ONLY PLAYER 1 !!! */ int all_keys_state = ply[0].keys | ply[1].keys | ply[2].keys | ply[3].keys; int player_nr = 0; /* !!! FIX THIS (CENTERED TO PLAYER 1) !!! */ @@ -483,10 +487,10 @@ void RedrawPlayfield_EM() int offset = (setup.scroll_delay ? 3 : 0) * TILEX; /* calculate new screen scrolling position, with regard to scroll delay */ - screen_x = VALID_SCREEN_X(sx < screen_x - offset ? sx + offset : - sx > screen_x + offset ? sx - offset : screen_x); - screen_y = VALID_SCREEN_Y(sy < screen_y - offset ? sy + offset : - sy > screen_y + offset ? sy - offset : screen_y); + screen_x = VALID_SCREEN_X(sx + offset < screen_x ? sx + offset : + sx - offset > screen_x ? sx - offset : screen_x); + screen_y = VALID_SCREEN_Y(sy + offset < screen_y ? sy + offset : + sy - offset > screen_y ? sy - offset : screen_y); #else diff --git a/src/game_em/init.c b/src/game_em/init.c index 54759eef..f2f074a7 100644 --- a/src/game_em/init.c +++ b/src/game_em/init.c @@ -299,18 +299,18 @@ void em_close_all(void) /* ---------------------------------------------------------------------- */ -extern unsigned int screen_x; -extern unsigned int screen_y; +extern int screen_x; +extern int screen_y; void play_element_sound(int x, int y, int sample, int element) { #if 0 - unsigned int left = screen_x / TILEX; - unsigned int top = screen_y / TILEY; + int left = screen_x / TILEX; + int top = screen_y / TILEY; if ((x == -1 && y == -1) || /* play sound in the middle of the screen */ - ((unsigned int)(y - top) <= SCR_FIELDY && - (unsigned int)(x - left) <= SCR_FIELDX)) + ((int)(y - top) <= SCR_FIELDY && + (int)(x - left) <= SCR_FIELDX)) #endif { #if 1 diff --git a/src/game_em/input.c b/src/game_em/input.c index ae3e1d55..172d6989 100644 --- a/src/game_em/input.c +++ b/src/game_em/input.c @@ -13,16 +13,16 @@ unsigned long RandomEM; struct LEVEL lev; struct PLAYER ply[MAX_PLAYERS]; -unsigned short **Boom; -unsigned short **Cave; -unsigned short **Next; -unsigned short **Draw; +short **Boom; +short **Cave; +short **Next; +short **Draw; -static unsigned short *Index[4][HEIGHT]; -static unsigned short Array[4][HEIGHT][WIDTH]; +static short *Index[4][HEIGHT]; +static short Array[4][HEIGHT][WIDTH]; -extern unsigned int screen_x; -extern unsigned int screen_y; +extern int screen_x; +extern int screen_y; void game_init_vars(void) { @@ -191,8 +191,8 @@ void GameActions_EM(byte action) void readjoy(byte action, struct PLAYER *ply) { - unsigned int north = 0, east = 0, south = 0, west = 0; - unsigned int snap = 0, drop = 0; + int north = 0, east = 0, south = 0, west = 0; + int snap = 0, drop = 0; if (action & JOY_LEFT) west = 1; @@ -228,8 +228,8 @@ void readjoy(byte action, struct PLAYER *ply) void readjoy(byte action) { - unsigned int north = 0, east = 0, south = 0, west = 0; - unsigned int snap = 0, drop = 0; + int north = 0, east = 0, south = 0, west = 0; + int snap = 0, drop = 0; if (action & JOY_LEFT) west = 1; diff --git a/src/game_em/level.h b/src/game_em/level.h index 9fb51dd9..6aed9682 100644 --- a/src/game_em/level.h +++ b/src/game_em/level.h @@ -16,9 +16,9 @@ extern struct LevelInfo_EM native_em_level; extern struct GraphicInfo_EM graphic_info_em_object[TILE_MAX][8]; extern struct GraphicInfo_EM graphic_info_em_player[MAX_PLAYERS][SPR_MAX][8]; -extern unsigned short **Boom; -extern unsigned short **Cave; -extern unsigned short **Next; -extern unsigned short **Draw; +extern short **Boom; +extern short **Cave; +extern short **Next; +extern short **Draw; #endif diff --git a/src/game_em/main_em.h b/src/game_em/main_em.h index 88f673f9..5781a40e 100644 --- a/src/game_em/main_em.h +++ b/src/game_em/main_em.h @@ -6,8 +6,14 @@ /* 2000-07-30T11:06:03Z ---------------------------------------------------- */ +#if 1 +/* one border for ZBORDER elements, one border for steelwall, if needed */ +#define EM_MAX_CAVE_WIDTH (MAX_PLAYFIELD_WIDTH + 2 + 2) +#define EM_MAX_CAVE_HEIGHT (MAX_PLAYFIELD_HEIGHT + 2 + 2) +#else #define EM_MAX_CAVE_WIDTH 102 #define EM_MAX_CAVE_HEIGHT 102 +#endif /* define these for backwards compatibility */ #define EM_ENGINE_BAD_ROLL @@ -18,9 +24,9 @@ ----------------------------------------------------------------------------- definition of elements used in the Emerald Mine Club engine; the element names have the following properties: - - elements that start with an 'X' can be stored in a level file; - - elements that start with an 'Y' indicate moving elements; - - elements that end with a 'B' are the "backside" of a moving element. + - elements that start with 'X' can be stored in a level file + - elements that start with 'Y' indicate moving elements + - elements that end with 'B' are the "backside" of moving elements ----------------------------------------------------------------------------- */ @@ -520,111 +526,111 @@ enum struct LEVEL { - unsigned int home_initial; /* number of players (initial) */ - unsigned int home; /* number of players not yet at home */ - /* 0 == all players at home */ + int home_initial; /* number of players (initial) */ + int home; /* number of players not yet at home */ + /* 0 == all players at home */ - unsigned int width; /* playfield width */ - unsigned int height; /* playfield height */ + int width; /* playfield width */ + int height; /* playfield height */ - unsigned int time_seconds; /* available time (seconds) */ - unsigned int time_initial; /* available time (initial) */ - unsigned int time; /* time remaining (runtime) */ + int time_seconds; /* available time (seconds) */ + int time_initial; /* available time (initial) */ + int time; /* time remaining (runtime) */ - boolean killed_out_of_time; /* kill player due to time out */ + boolean killed_out_of_time; /* kill player due to time out */ - unsigned int required_initial; /* emeralds needed (initial) */ - unsigned int required; /* emeralds needed (runtime) */ + int required_initial; /* emeralds needed (initial) */ + int required; /* emeralds needed (runtime) */ - unsigned int score; /* score */ + int score; /* score */ /* all below entries must be filled every time a level is read */ - unsigned int alien_score; /* score for killing alien */ - unsigned int amoeba_time; /* amoeba speed */ - unsigned int android_move_cnt_initial;/* android move counter (initial) */ - unsigned int android_move_cnt; /* android move counter */ - unsigned int android_move_time; /* android move reset time */ - unsigned int android_clone_cnt_initial;/* android clone counter (initial) */ - unsigned int android_clone_cnt; /* android clone counter */ - unsigned int android_clone_time; /* android clone reset time */ - unsigned int ball_cnt; /* ball counter */ - unsigned int ball_pos; /* ball array pos counter */ - unsigned int ball_random; /* ball is random flag */ - unsigned int ball_state_initial; /* ball active flag (initial) */ - unsigned int ball_state; /* ball active flag */ - unsigned int ball_time; /* ball reset time */ - unsigned int bug_score; /* score for killing bug */ - unsigned int diamond_score; /* score for collecting diamond */ - unsigned int dynamite_score; /* score for collecting dynamite */ - unsigned int eater_pos; /* eater array pos */ - unsigned int eater_score; /* score for killing eater */ - unsigned int emerald_score; /* score for collecting emerald */ - unsigned int exit_score; /* score for entering exit */ - unsigned int key_score; /* score for colleting key */ - unsigned int lenses_cnt_initial; /* lenses counter (initial) */ - unsigned int lenses_cnt; /* lenses counter */ - unsigned int lenses_score; /* score for collecting lenses */ - unsigned int lenses_time; /* lenses reset time */ - unsigned int magnify_cnt_initial; /* magnify counter (initial) */ - unsigned int magnify_cnt; /* magnify counter */ - unsigned int magnify_score; /* score for collecting magnifier */ - unsigned int magnify_time; /* magnify reset time */ - unsigned int nut_score; /* score for cracking nut */ - unsigned int shine_cnt; /* shine counter for emerald/diamond */ - unsigned int slurp_score; /* score for slurping alien */ - unsigned int tank_score; /* score for killing tank */ - unsigned int wheel_cnt_initial; /* wheel counter (initial) */ - unsigned int wheel_cnt; /* wheel counter */ - unsigned int wheel_x_initial; /* wheel x pos (initial) */ - unsigned int wheel_x; /* wheel x pos */ - unsigned int wheel_y_initial; /* wheel y pos (initial) */ - unsigned int wheel_y; /* wheel y pos */ - unsigned int wheel_time; /* wheel reset time */ - unsigned int wind_cnt_initial; /* wind counter (initial) */ - unsigned int wind_cnt; /* wind time counter */ - unsigned int wind_direction_initial; /* wind direction (initial) */ - unsigned int wind_direction; /* wind direction */ - unsigned int wind_time; /* wind reset time */ - unsigned int wonderwall_state_initial;/* wonderwall active flag (initial) */ - unsigned int wonderwall_state; /* wonderwall active flag */ - unsigned int wonderwall_time_initial; /* wonderwall time (initial) */ - unsigned int wonderwall_time; /* wonderwall time */ - unsigned short eater_array[8][9]; /* eater data */ - unsigned short ball_array[8][8]; /* ball data */ - unsigned short android_array[TILE_MAX];/* android clone table */ - unsigned int num_ball_arrays; /* number of ball data arrays used */ + int alien_score; /* score for killing alien */ + int amoeba_time; /* amoeba speed */ + int android_move_cnt_initial; /* android move counter (initial) */ + int android_move_cnt; /* android move counter */ + int android_move_time; /* android move reset time */ + int android_clone_cnt_initial;/* android clone counter (initial) */ + int android_clone_cnt; /* android clone counter */ + int android_clone_time; /* android clone reset time */ + int ball_cnt; /* ball counter */ + int ball_pos; /* ball array pos counter */ + int ball_random; /* ball is random flag */ + int ball_state_initial; /* ball active flag (initial) */ + int ball_state; /* ball active flag */ + int ball_time; /* ball reset time */ + int bug_score; /* score for killing bug */ + int diamond_score; /* score for collecting diamond */ + int dynamite_score; /* score for collecting dynamite */ + int eater_pos; /* eater array pos */ + int eater_score; /* score for killing eater */ + int emerald_score; /* score for collecting emerald */ + int exit_score; /* score for entering exit */ + int key_score; /* score for colleting key */ + int lenses_cnt_initial; /* lenses counter (initial) */ + int lenses_cnt; /* lenses counter */ + int lenses_score; /* score for collecting lenses */ + int lenses_time; /* lenses reset time */ + int magnify_cnt_initial; /* magnify counter (initial) */ + int magnify_cnt; /* magnify counter */ + int magnify_score; /* score for collecting magnifier */ + int magnify_time; /* magnify reset time */ + int nut_score; /* score for cracking nut */ + int shine_cnt; /* shine counter for emerald/diamond */ + int slurp_score; /* score for slurping alien */ + int tank_score; /* score for killing tank */ + int wheel_cnt_initial; /* wheel counter (initial) */ + int wheel_cnt; /* wheel counter */ + int wheel_x_initial; /* wheel x pos (initial) */ + int wheel_x; /* wheel x pos */ + int wheel_y_initial; /* wheel y pos (initial) */ + int wheel_y; /* wheel y pos */ + int wheel_time; /* wheel reset time */ + int wind_cnt_initial; /* wind counter (initial) */ + int wind_cnt; /* wind time counter */ + int wind_direction_initial; /* wind direction (initial) */ + int wind_direction; /* wind direction */ + int wind_time; /* wind reset time */ + int wonderwall_state_initial; /* wonderwall active flag (initial) */ + int wonderwall_state; /* wonderwall active flag */ + int wonderwall_time_initial; /* wonderwall time (initial) */ + int wonderwall_time; /* wonderwall time */ + short eater_array[8][9]; /* eater data */ + short ball_array[8][8]; /* ball data */ + short android_array[TILE_MAX];/* android clone table */ + int num_ball_arrays; /* number of ball data arrays used */ }; struct PLAYER { - unsigned int num; - unsigned int exists; - unsigned int alive_initial; - unsigned int alive; - - unsigned int dynamite; - unsigned int dynamite_cnt; - unsigned int keys; - unsigned int anim; - - unsigned int x_initial; - unsigned int y_initial; - unsigned int x; - unsigned int y; - unsigned int oldx; - unsigned int oldy; - - unsigned int last_move_dir; - - unsigned joy_n:1; - unsigned joy_e:1; - unsigned joy_s:1; - unsigned joy_w:1; - unsigned joy_snap:1; - unsigned joy_drop:1; - unsigned joy_stick:1; - unsigned joy_spin:1; + int num; + int exists; + int alive_initial; + int alive; + + int dynamite; + int dynamite_cnt; + int keys; + int anim; + + int x_initial; + int y_initial; + int x; + int y; + int oldx; + int oldy; + + int last_move_dir; + + int joy_n:1; + int joy_e:1; + int joy_s:1; + int joy_w:1; + int joy_snap:1; + int joy_drop:1; + int joy_stick:1; + int joy_spin:1; }; @@ -649,7 +655,7 @@ struct LevelInfo_EM { int file_version; - unsigned short cave[EM_MAX_CAVE_WIDTH][EM_MAX_CAVE_HEIGHT]; + short cave[EM_MAX_CAVE_WIDTH][EM_MAX_CAVE_HEIGHT]; struct LEVEL *lev; struct PLAYER *ply[MAX_PLAYERS]; diff --git a/src/game_em/synchro_1.c b/src/game_em/synchro_1.c index 0b3710e1..058c79e3 100644 --- a/src/game_em/synchro_1.c +++ b/src/game_em/synchro_1.c @@ -142,8 +142,8 @@ void synchro_1(void) static boolean player_killed(struct PLAYER *ply) { - register unsigned int x = ply->x; - register unsigned int y = ply->y; + int x = ply->x; + int y = ply->y; #if 0 printf("::: %d: %d, %d\n", ply->num, x, y); @@ -272,8 +272,8 @@ static boolean player_killed(struct PLAYER *ply) static void kill_player(struct PLAYER *ply) { - register unsigned int x = ply->x; - register unsigned int y = ply->y; + int x = ply->x; + int y = ply->y; ply->alive = 0; @@ -437,11 +437,11 @@ static void kill_player(struct PLAYER *ply) static void check_player(struct PLAYER *ply) { - unsigned int oldx = ply->x; - unsigned int oldy = ply->y; - register unsigned int x = oldx; - register unsigned int y = oldy; - unsigned int anim = 0; + int oldx = ply->x; + int oldy = ply->y; + int x = oldx; + int y = oldy; + int anim = 0; int dx = 0, dy = 0; #if 0 @@ -595,10 +595,10 @@ static void check_player(struct PLAYER *ply) static boolean player_digfield(struct PLAYER *ply, int dx, int dy) { int anim = (dx < 0 ? 3 : dx > 0 ? 1 : dy < 0 ? 0 : dy > 0 ? 2 : 2); - unsigned int oldx = ply->x; - unsigned int oldy = ply->y; - register unsigned int x = oldx + dx; - register unsigned int y = oldy + dy; + int oldx = ply->x; + int oldy = ply->y; + int x = oldx + dx; + int y = oldy + dy; boolean result = TRUE; if (!dx && !dy) /* no direction specified */ diff --git a/src/game_em/synchro_2.c b/src/game_em/synchro_2.c index 5079b7c2..3207f368 100644 --- a/src/game_em/synchro_2.c +++ b/src/game_em/synchro_2.c @@ -44,15 +44,15 @@ static void set_nearest_player_xy(int x, int y, int *dx, int *dy) void synchro_2(void) { - register unsigned int x = 0; - register unsigned int y = 1; - register unsigned long random = RandomEM; - register unsigned short *cave_cache = Cave[y]; /* might be a win */ - unsigned long score = 0; - - unsigned int temp = 0; /* initialized to make compilers happy */ - unsigned int dx; /* only needed to find closest player */ - unsigned int dy; + int x = 0; + int y = 1; + unsigned long random = RandomEM; + short *cave_cache = Cave[y]; /* might be a win */ + int score = 0; + + int temp = 0; /* initialized to make compilers happy */ + int dx; /* only needed to find closest player */ + int dy; int element; loop: diff --git a/src/game_em/synchro_3.c b/src/game_em/synchro_3.c index 449ecab0..226d0194 100644 --- a/src/game_em/synchro_3.c +++ b/src/game_em/synchro_3.c @@ -12,10 +12,10 @@ void synchro_3(void) { - register unsigned int x; - register unsigned int y; - register unsigned int count; - register unsigned long random; + int x; + int y; + int count; + unsigned long random; /* update variables */ diff --git a/src/libgame/system.h b/src/libgame/system.h index 3fd6798d..8c575f12 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -213,6 +213,10 @@ #define CURSOR_PLAYFIELD 1 +/* maximum playfield size supported by libgame functions */ +#define MAX_PLAYFIELD_WIDTH 128 +#define MAX_PLAYFIELD_HEIGHT 128 + /* maximum number of parallel players supported by libgame functions */ #define MAX_PLAYERS 4 diff --git a/src/main.h b/src/main.h index 7dfec0fd..cdfd00cc 100644 --- a/src/main.h +++ b/src/main.h @@ -50,8 +50,8 @@ #define MIN_LEV_FIELDY 3 #define STD_LEV_FIELDX 64 #define STD_LEV_FIELDY 32 -#define MAX_LEV_FIELDX 128 -#define MAX_LEV_FIELDY 128 +#define MAX_LEV_FIELDX MAX_PLAYFIELD_WIDTH +#define MAX_LEV_FIELDY MAX_PLAYFIELD_HEIGHT #define SCREENX(a) ((a) - scroll_x) #define SCREENY(a) ((a) - scroll_y) diff --git a/src/screens.c b/src/screens.c index 9ee9ca49..1b3de852 100644 --- a/src/screens.c +++ b/src/screens.c @@ -3088,16 +3088,36 @@ void HandleGameActions() byte tape_action[MAX_PLAYERS]; int i; +#if 1 if (level.native_em_level->lev->home == 0) /* all players at home */ { + local_player->LevelSolved = TRUE; + AllPlayersGone = TRUE; + + level.native_em_level->lev->home = -1; + } + + if (local_player->LevelSolved) GameWon(); - if (!TAPE_IS_STOPPED(tape)) + if (AllPlayersGone && !TAPE_IS_STOPPED(tape)) + TapeStop(); + + if (game_status != GAME_MODE_PLAYING) + return; +#else + if (level.native_em_level->lev->home == 0) /* all players at home */ + { + if (local_player->LevelSolved) + GameWon(); + + if (AllPlayersGone && !TAPE_IS_STOPPED(tape)) TapeStop(); if (game_status != GAME_MODE_PLAYING) return; } +#endif if (level.native_em_level->ply[0]->alive == 0 && level.native_em_level->ply[1]->alive == 0 &&