From: Holger Schemel Date: Sun, 27 Dec 1998 22:58:05 +0000 (+0100) Subject: rnd-19981227-1 X-Git-Tag: 1.3.0^2~46 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=95d786b6fe8474c30a22f839751e0d04c7682ded;p=rocksndiamonds.git rnd-19981227-1 --- diff --git a/src/game.c b/src/game.c index 682c4516..ec95ff6d 100644 --- a/src/game.c +++ b/src/game.c @@ -171,6 +171,138 @@ void GetPlayerConfig() InitJoysticks(); } +static void InitField(int x, int y, boolean init_game) +{ + switch (Feld[x][y]) + { + case EL_SPIELFIGUR: + if (init_game) + Feld[x][y] = EL_SPIELER1; + /* no break! */ + case EL_SPIELER1: + case EL_SPIELER2: + case EL_SPIELER3: + case EL_SPIELER4: + if (init_game) + { + struct PlayerInfo *player = &stored_player[Feld[x][y] - EL_SPIELER1]; + int jx = player->jx, jy = player->jy; + + player->present = TRUE; + + /* + if (!network_playing || player->connected) + */ + + if (!options.network || player->connected) + { + player->active = TRUE; + + /* remove potentially duplicate players */ + if (StorePlayer[jx][jy] == Feld[x][y]) + StorePlayer[jx][jy] = 0; + + StorePlayer[x][y] = Feld[x][y]; + + if (options.verbose) + { + printf("Player %d activated.\n", player->element_nr); + printf("[Local player is %d and currently %s.]\n", + local_player->element_nr, + local_player->active ? "active" : "not active"); + } + } + + Feld[x][y] = EL_LEERRAUM; + player->jx = player->last_jx = x; + player->jy = player->last_jy = y; + } + break; + + case EL_BADEWANNE: + if (x < lev_fieldx-1 && Feld[x+1][y] == EL_SALZSAEURE) + Feld[x][y] = EL_BADEWANNE1; + else if (x > 0 && Feld[x-1][y] == EL_SALZSAEURE) + Feld[x][y] = EL_BADEWANNE2; + else if (y > 0 && Feld[x][y-1] == EL_BADEWANNE1) + Feld[x][y] = EL_BADEWANNE3; + else if (y > 0 && Feld[x][y-1] == EL_SALZSAEURE) + Feld[x][y] = EL_BADEWANNE4; + else if (y > 0 && Feld[x][y-1] == EL_BADEWANNE2) + Feld[x][y] = EL_BADEWANNE5; + break; + + case EL_KAEFER_R: + case EL_KAEFER_O: + case EL_KAEFER_L: + case EL_KAEFER_U: + case EL_KAEFER: + case EL_FLIEGER_R: + case EL_FLIEGER_O: + case EL_FLIEGER_L: + case EL_FLIEGER_U: + case EL_FLIEGER: + case EL_BUTTERFLY_R: + case EL_BUTTERFLY_O: + case EL_BUTTERFLY_L: + case EL_BUTTERFLY_U: + case EL_BUTTERFLY: + case EL_FIREFLY_R: + case EL_FIREFLY_O: + case EL_FIREFLY_L: + case EL_FIREFLY_U: + case EL_FIREFLY: + case EL_PACMAN_R: + case EL_PACMAN_O: + case EL_PACMAN_L: + case EL_PACMAN_U: + case EL_MAMPFER: + case EL_MAMPFER2: + case EL_ROBOT: + case EL_PACMAN: + InitMovDir(x, y); + break; + + case EL_AMOEBE_VOLL: + case EL_AMOEBE_BD: + InitAmoebaNr(x, y); + break; + + case EL_TROPFEN: + if (y == lev_fieldy - 1) + { + Feld[x][y] = EL_AMOEBING; + Store[x][y] = EL_AMOEBE_NASS; + } + break; + + case EL_DYNAMIT: + MovDelay[x][y] = 96; + break; + + case EL_BIRNE_AUS: + local_player->lights_still_needed++; + break; + + case EL_SOKOBAN_FELD_LEER: + local_player->sokobanfields_still_needed++; + break; + + case EL_MAULWURF: + case EL_PINGUIN: + local_player->friends_still_needed++; + break; + + case EL_SCHWEIN: + case EL_DRACHE: + MovDir[x][y] = 1 << RND(4); + break; + + default: + break; + } +} + void InitGame() { int i, j, x, y; @@ -283,123 +415,7 @@ void InitGame() if (emulate_sb && !IS_SB_ELEMENT(Feld[x][y])) emulate_sb = FALSE; - switch (Feld[x][y]) - { - case EL_SPIELFIGUR: - Feld[x][y] = EL_SPIELER1; - /* no break! */ - case EL_SPIELER1: - case EL_SPIELER2: - case EL_SPIELER3: - case EL_SPIELER4: - { - struct PlayerInfo *player = &stored_player[Feld[x][y] - EL_SPIELER1]; - int jx = player->jx, jy = player->jy; - - player->present = TRUE; - - /* - if (!network_playing || player->connected) - */ - - if (!options.network || player->connected) - { - player->active = TRUE; - - /* remove potentially duplicate players */ - if (StorePlayer[jx][jy] == Feld[x][y]) - StorePlayer[jx][jy] = 0; - - StorePlayer[x][y] = Feld[x][y]; - - if (options.verbose) - { - printf("Player %d activated.\n", player->element_nr); - printf("[Local player is %d and currently %s.]\n", - local_player->element_nr, - local_player->active ? "active" : "not active"); - } - } - - Feld[x][y] = EL_LEERRAUM; - player->jx = player->last_jx = x; - player->jy = player->last_jy = y; - - break; - } - case EL_BADEWANNE: - if (x < lev_fieldx-1 && Feld[x+1][y] == EL_SALZSAEURE) - Feld[x][y] = EL_BADEWANNE1; - else if (x > 0 && Feld[x-1][y] == EL_SALZSAEURE) - Feld[x][y] = EL_BADEWANNE2; - else if (y > 0 && Feld[x][y-1] == EL_BADEWANNE1) - Feld[x][y] = EL_BADEWANNE3; - else if (y > 0 && Feld[x][y-1] == EL_SALZSAEURE) - Feld[x][y] = EL_BADEWANNE4; - else if (y > 0 && Feld[x][y-1] == EL_BADEWANNE2) - Feld[x][y] = EL_BADEWANNE5; - break; - case EL_KAEFER_R: - case EL_KAEFER_O: - case EL_KAEFER_L: - case EL_KAEFER_U: - case EL_KAEFER: - case EL_FLIEGER_R: - case EL_FLIEGER_O: - case EL_FLIEGER_L: - case EL_FLIEGER_U: - case EL_FLIEGER: - case EL_BUTTERFLY_R: - case EL_BUTTERFLY_O: - case EL_BUTTERFLY_L: - case EL_BUTTERFLY_U: - case EL_BUTTERFLY: - case EL_FIREFLY_R: - case EL_FIREFLY_O: - case EL_FIREFLY_L: - case EL_FIREFLY_U: - case EL_FIREFLY: - case EL_PACMAN_R: - case EL_PACMAN_O: - case EL_PACMAN_L: - case EL_PACMAN_U: - case EL_MAMPFER: - case EL_MAMPFER2: - case EL_ROBOT: - case EL_PACMAN: - InitMovDir(x, y); - break; - case EL_AMOEBE_VOLL: - case EL_AMOEBE_BD: - InitAmoebaNr(x, y); - break; - case EL_TROPFEN: - if (y == lev_fieldy - 1) - { - Feld[x][y] = EL_AMOEBING; - Store[x][y] = EL_AMOEBE_NASS; - } - break; - case EL_DYNAMIT: - MovDelay[x][y] = 96; - break; - case EL_BIRNE_AUS: - local_player->lights_still_needed++; - break; - case EL_SOKOBAN_FELD_LEER: - local_player->sokobanfields_still_needed++; - break; - case EL_MAULWURF: - case EL_PINGUIN: - local_player->friends_still_needed++; - break; - case EL_SCHWEIN: - case EL_DRACHE: - MovDir[x][y] = 1 << RND(4); - break; - default: - break; - } + InitField(x, y, TRUE); } /* check if any connected player was not found in playfield */ @@ -1089,6 +1105,7 @@ void Explode(int ex, int ey, int phase, int mode) element = Feld[x][y] = Store[x][y]; Store[x][y] = Store2[x][y] = 0; MovDir[x][y] = MovPos[x][y] = MovDelay[x][y] = 0; + InitField(x, y, FALSE); if (CAN_MOVE(element) || COULD_MOVE(element)) InitMovDir(x, y); DrawLevelField(x, y); @@ -2301,13 +2318,13 @@ int AmoebeNachbarNr(int ax, int ay) for (i=0; i<4; i++) { - int x = ax+xy[i%4][0]; - int y = ay+xy[i%4][1]; + int x = ax + xy[i][0]; + int y = ay + xy[i][1]; if (!IN_LEV_FIELD(x, y)) continue; - if (Feld[x][y] == element && AmoebaNr[x][y]>0) + if (Feld[x][y] == element && AmoebaNr[x][y] > 0) group_nr = AmoebaNr[x][y]; } @@ -2326,13 +2343,13 @@ void AmoebenVereinigen(int ax, int ay) { 0, +1 } }; - if (!new_group_nr) + if (new_group_nr == 0) return; for (i=0; i<4; i++) { - x = ax+xy[i%4][0]; - y = ay+xy[i%4][1]; + x = ax + xy[i][0]; + y = ay + xy[i][1]; if (!IN_LEV_FIELD(x, y)) continue; @@ -2344,14 +2361,22 @@ void AmoebenVereinigen(int ax, int ay) { int old_group_nr = AmoebaNr[x][y]; + if (old_group_nr == 0) + return; + AmoebaCnt[new_group_nr] += AmoebaCnt[old_group_nr]; AmoebaCnt[old_group_nr] = 0; AmoebaCnt2[new_group_nr] += AmoebaCnt2[old_group_nr]; AmoebaCnt2[old_group_nr] = 0; - for (yy=0; yy= 200 && element == EL_AMOEBE_BD) + if (element == EL_AMOEBE_BD && AmoebaCnt2[new_group_nr] >= 200) { - AmoebeUmwandeln2(newax, neway, EL_FELSBROCKEN); + AmoebeUmwandelnBD(newax, neway, EL_FELSBROCKEN); return; } } } - if (element!=EL_AMOEBE_NASS || newaygems_still_needed -= (element == EL_DIAMANT ? 3 : 1); if (local_player->gems_still_needed < 0) @@ -4251,7 +4317,11 @@ int DigField(struct PlayerInfo *player, break; default: - return MF_NO_ACTION; + if (IS_EATABLE(element)) /* other kinds of 'dirt' */ + Feld[x][y] = EL_LEERRAUM; + else + return MF_NO_ACTION; + break; } diff --git a/src/game.h b/src/game.h index 4834b796..56ba8a31 100644 --- a/src/game.h +++ b/src/game.h @@ -39,7 +39,7 @@ void StartMoving(int, int); void ContinueMoving(int, int); int AmoebeNachbarNr(int, int); void AmoebeUmwandeln(int, int); -void AmoebeUmwandeln2(int, int, int); +void AmoebeUmwandelnBD(int, int, int); void AmoebeWaechst(int, int); void AmoebeAbleger(int, int); void Life(int, int); diff --git a/src/init.c b/src/init.c index 4b871020..63e6e576 100644 --- a/src/init.c +++ b/src/init.c @@ -1366,6 +1366,14 @@ void InitElementProperties() }; static int ep_has_content_num = sizeof(ep_has_content)/sizeof(int); + static int ep_eatable[] = + { + EL_ERDREICH, + EL_SP_BASE, + EL_SP_BUG + }; + static int ep_eatable_num = sizeof(ep_eatable)/sizeof(int); + static long ep_bit[] = { EP_BIT_AMOEBALIVE, @@ -1393,7 +1401,8 @@ void InitElementProperties() EP_BIT_MAMPF3, EP_BIT_PUSHABLE, EP_BIT_PLAYER, - EP_BIT_HAS_CONTENT + EP_BIT_HAS_CONTENT, + EP_BIT_EATABLE }; static int *ep_array[] = { @@ -1422,7 +1431,8 @@ void InitElementProperties() ep_mampf3, ep_pushable, ep_player, - ep_has_content + ep_has_content, + ep_eatable }; static int *ep_num[] = { @@ -1451,7 +1461,8 @@ void InitElementProperties() &ep_mampf3_num, &ep_pushable_num, &ep_player_num, - &ep_has_content_num + &ep_has_content_num, + &ep_eatable_num }; static int num_properties = sizeof(ep_num)/sizeof(int *); diff --git a/src/main.h b/src/main.h index 26861a74..3c77e192 100644 --- a/src/main.h +++ b/src/main.h @@ -96,33 +96,34 @@ typedef unsigned char byte; #define IN_SCR_FIELD(x,y) ((x)>=BX1 && (x)<=BX2 && (y)>=BY1 &&(y)<=BY2) #define IN_LEV_FIELD(x,y) ((x)>=0 && (x)=0 &&(y)= GFX_START_ROCKSMORE && graphic <= GFX_END_ROCKSMORE) + { + graphic -= GFX_START_ROCKSMORE; XCopyArea(display, pix[PIX_MORE], drawto, gc, MICRO_MORE_STARTX + (graphic % MICRO_MORE_PER_LINE) *MICRO_TILEX, MICRO_MORE_STARTY + (graphic / MICRO_MORE_PER_LINE) *MICRO_TILEY, MICRO_TILEX, MICRO_TILEY, xpos, ypos); + } else XCopyArea(display, pix[PIX_BACK], drawto, gc, MICRO_GFX_STARTX + (graphic % MICRO_GFX_PER_LINE) * MICRO_TILEX,