X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=3051f5ac9d93771620536c019413d08420dceec0;hb=9de8eede744c45187c7011543ef8097d1ebc879c;hp=6326b223d920bae9a0879b70c65ecbf9ee31a9d8;hpb=b21faa39ac22e1987db2bc6158374388e0090dfe;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index 6326b223..3051f5ac 100644 --- a/src/game.c +++ b/src/game.c @@ -89,6 +89,9 @@ #define DOUBLE_PLAYER_SPEED(p) (HALVE_MOVE_DELAY((p)->move_delay_value)) #define HALVE_PLAYER_SPEED(p) (DOUBLE_MOVE_DELAY((p)->move_delay_value)) +/* values for other actions */ +#define MOVE_STEPSIZE_NORMAL (TILEX / MOVE_DELAY_NORMAL_SPEED) + #define INIT_GFX_RANDOM() (SimpleRND(1000000)) #define GET_NEW_PUSH_DELAY(e) ( (element_info[e].push_delay_fixed) + \ @@ -164,8 +167,9 @@ static void CheckGravityMovement(struct PlayerInfo *); static void KillHeroUnlessProtected(int, int); static void TestIfPlayerTouchesCustomElement(int, int); +static void TestIfElementTouchesCustomElement(int, int); -static boolean CheckTriggeredElementChange(int, int); +static boolean CheckTriggeredElementChange(int, int, int, int); static boolean CheckElementChange(int, int, int, int); static void ChangeElementNow(int, int, int); @@ -372,6 +376,25 @@ push_delay_list[] = { EL_UNDEFINED, 0, 0 }, }; +struct +{ + int element; + int move_stepsize; +} +move_stepsize_list[] = +{ + { EL_AMOEBA_DROP, 2 }, + { EL_AMOEBA_DROPPING, 2 }, + { EL_QUICKSAND_FILLING, 1 }, + { EL_QUICKSAND_EMPTYING, 1 }, + { EL_MAGIC_WALL_FILLING, 2 }, + { EL_BD_MAGIC_WALL_FILLING, 2 }, + { EL_MAGIC_WALL_EMPTYING, 2 }, + { EL_BD_MAGIC_WALL_EMPTYING, 2 }, + + { EL_UNDEFINED, 0 }, +}; + struct { int element; @@ -379,17 +402,17 @@ struct } gem_count_list[] = { - { EL_EMERALD, 1 }, - { EL_BD_DIAMOND, 1 }, - { EL_EMERALD_YELLOW, 1 }, - { EL_EMERALD_RED, 1 }, - { EL_EMERALD_PURPLE, 1 }, - { EL_DIAMOND, 3 }, - { EL_SP_INFOTRON, 1 }, - { EL_PEARL, 5 }, - { EL_CRYSTAL, 8 }, - - { EL_UNDEFINED, 0 }, + { EL_EMERALD, 1 }, + { EL_BD_DIAMOND, 1 }, + { EL_EMERALD_YELLOW, 1 }, + { EL_EMERALD_RED, 1 }, + { EL_EMERALD_PURPLE, 1 }, + { EL_DIAMOND, 3 }, + { EL_SP_INFOTRON, 1 }, + { EL_PEARL, 5 }, + { EL_CRYSTAL, 8 }, + + { EL_UNDEFINED, 0 }, }; static boolean changing_element[MAX_NUM_ELEMENTS]; @@ -399,7 +422,6 @@ static unsigned long trigger_events[MAX_NUM_ELEMENTS]; #define IS_JUST_CHANGING(x, y) (ChangeDelay[x][y] != 0) #define IS_CHANGING(x, y) (IS_AUTO_CHANGING(Feld[x][y]) || \ IS_JUST_CHANGING(x, y)) -#define TRIGGERS_BY_COLLECTING(e) (trigger_events[e] & CE_OTHER_COLLECTING) void GetPlayerConfig() @@ -824,7 +846,7 @@ static void InitGameEngine() /* add trigger events from element change event properties */ for (i=0; iPushing && player->MovPos != 0); -#else - boolean pushing = (player != NULL && player->Pushing && player->is_moving); -#endif -#endif - -#if 0 - if (player && player->is_moving && player->MovPos == 0) - printf("::: !!!\n"); -#endif - - if (element == EL_AMOEBA_DROP || element == EL_AMOEBA_DROPPING) - step /= 2; - else if (element == EL_QUICKSAND_FILLING || - element == EL_QUICKSAND_EMPTYING) - step /= 4; - else if (element == EL_MAGIC_WALL_FILLING || - element == EL_BD_MAGIC_WALL_FILLING || - element == EL_MAGIC_WALL_EMPTYING || - element == EL_BD_MAGIC_WALL_EMPTYING) - step /= 2; - else if (CAN_FALL(element) && horiz_move && - y < lev_fieldy-1 && IS_BELT_ACTIVE(Feld[x][y+1])) - step /= 2; - else if (element == EL_SPRING && horiz_move) - step *= 2; - else if (IS_CUSTOM_ELEMENT(element)) - step = SIGN(step) * element_info[element].move_stepsize; -#if OLD_GAME_BEHAVIOUR - else if (CAN_FALL(element) && horiz_move && !IS_SP_ELEMENT(element)) - step*=2; -#endif + /* special values for move stepsize for spring and things on conveyor belt */ + if (horiz_move) + { + if (CAN_FALL(element) && + y < lev_fieldy - 1 && IS_BELT_ACTIVE(Feld[x][y + 1])) + step = sign * MOVE_STEPSIZE_NORMAL / 2; + else if (element == EL_SPRING) + step = sign * MOVE_STEPSIZE_NORMAL * 2; + } MovPos[x][y] += step; -#if 1 -#if 1 if (pushed) /* special case: moving object pushed by player */ -#else - if (pushing) /* special case: moving object pushed by player */ -#endif -#if 1 MovPos[x][y] = SIGN(MovPos[x][y]) * (TILEX - ABS(PLAYERINFO(x,y)->MovPos)); -#else - MovPos[x][y] = SIGN(MovPos[x][y]) * (TILEX - ABS(PLAYERINFO(x,y)->GfxPos)); -#endif -#endif - -#if 0 - if (element == EL_SPRING) - printf("::: spring moves %d [%d: %d, %d, %d/%d]\n", - MovPos[x][y], - pushing, - (player?player->Pushing:-42), - (player?player->is_moving:-42), - (player?player->MovPos:-42), - (player?player->GfxPos:-42)); -#endif if (ABS(MovPos[x][y]) >= TILEX) /* object reached its destination */ { @@ -4043,31 +4033,11 @@ void ContinueMoving(int x, int y) if (element == EL_MOLE) { - int i; - static int xy[4][2] = - { - { 0, -1 }, - { -1, 0 }, - { +1, 0 }, - { 0, +1 } - }; - Feld[x][y] = EL_SAND; - DrawLevelField(x, y); - - for(i=0; i<4; i++) - { - int xx, yy; - - xx = x + xy[i][0]; - yy = y + xy[i][1]; - if (IN_LEV_FIELD(xx, yy) && Feld[xx][yy] == EL_SAND) - DrawLevelField(xx, yy); /* for "crumbled sand" */ - } + DrawLevelFieldCrumbledSandNeighbours(x, y); } - - if (element == EL_QUICKSAND_FILLING) + else if (element == EL_QUICKSAND_FILLING) { element = Feld[newx][newy] = get_next_element(element); Store[newx][newy] = Store[x][y]; @@ -4141,7 +4111,6 @@ void ContinueMoving(int x, int y) ResetGfxAnimation(x, y); /* reset animation values for old field */ -#if 1 #if 0 /* 2.1.1 (does not work correctly for spring) */ if (!CAN_MOVE(element)) @@ -4163,20 +4132,14 @@ void ContinueMoving(int x, int y) (CAN_FALL(element) && MovDir[newx][newy] == MV_DOWN)) MovDir[newx][newy] = 0; #endif - -#endif #endif DrawLevelField(x, y); DrawLevelField(newx, newy); -#if 0 - if (game.engine_version >= RELEASE_IDENT(2,2,0,7) || !pushing) -#endif - Stop[newx][newy] = TRUE; /* ignore this element until the next frame */ -#if 1 + Stop[newx][newy] = TRUE; /* ignore this element until the next frame */ + if (!pushed) /* special case: moving object pushed by player */ -#endif JustStopped[newx][newy] = 3; if (DONT_TOUCH(element)) /* object may be nasty to player or others */ @@ -4188,29 +4151,15 @@ void ContinueMoving(int x, int y) else if (element == EL_PENGUIN) TestIfFriendTouchesBadThing(newx, newy); -#if 1 if (CAN_FALL(element) && direction == MV_DOWN && (newy == lev_fieldy - 1 || !IS_FREE(x, newy + 1))) Impact(x, newy); -#else - if (CAN_SMASH(element) && direction == MV_DOWN && - (newy == lev_fieldy - 1 || !IS_FREE(x, newy + 1))) - Impact(x, newy); -#endif -#if 0 - if (!IN_LEV_FIELD(nextx, nexty) || !IS_FREE(nextx, nexty)) - CheckTriggeredElementChange(element, CE_COLLISION); -#else -#if 1 if (!IN_LEV_FIELD(nextx, nexty) || !IS_FREE(nextx, nexty)) CheckElementChange(newx, newy, element, CE_COLLISION); -#else - if ((!IN_LEV_FIELD(nextx, nexty) || !IS_FREE(nextx, nexty)) && - CAN_CHANGE(element) && HAS_CHANGE_EVENT(element, CE_COLLISION)) - ChangeElementNow(newx, newy, element); -#endif -#endif + + TestIfPlayerTouchesCustomElement(newx, newy); + TestIfElementTouchesCustomElement(newx, newy); } else /* still moving on */ { @@ -5123,40 +5072,14 @@ static void ChangeElementNowExt(int x, int y, int target_element) DrawLevelField(x, y); if (CAN_BE_CRUMBLED(Feld[x][y])) - { - int sx = SCREENX(x), sy = SCREENY(y); - static int xy[4][2] = - { - { 0, -1 }, - { -1, 0 }, - { +1, 0 }, - { 0, +1 } - }; - int i; - - for(i=0; i<4; i++) - { - int xx = x + xy[i][0]; - int yy = y + xy[i][1]; - int sxx = sx + xy[i][0]; - int syy = sy + xy[i][1]; - - if (!IN_LEV_FIELD(xx, yy) || - !IN_SCR_FIELD(sxx, syy) || - !CAN_BE_CRUMBLED(Feld[xx][yy]) || - IS_MOVING(xx, yy)) - continue; - - DrawLevelField(xx, yy); - } - } + DrawLevelFieldCrumbledSandNeighbours(x, y); } static void ChangeElementNow(int x, int y, int element) { struct ElementChangeInfo *change = &element_info[element].change; - CheckTriggeredElementChange(Feld[x][y], CE_OTHER_CHANGING); + CheckTriggeredElementChange(x, y, Feld[x][y], CE_OTHER_IS_CHANGING); if (change->explode) { @@ -5324,7 +5247,7 @@ static void ChangeElement(int x, int y) } } -static boolean CheckTriggeredElementChange(int trigger_element, +static boolean CheckTriggeredElementChange(int lx, int ly, int trigger_element, int trigger_event) { int i, x, y; @@ -5335,11 +5258,14 @@ static boolean CheckTriggeredElementChange(int trigger_element, for (i=0; ipush_delay_value = GET_NEW_PUSH_DELAY(element); - CheckTriggeredElementChange(element, CE_OTHER_PUSHING); + CheckTriggeredElementChange(x, y, element, CE_OTHER_GETS_PUSHED); CheckElementChange(x, y, element, CE_PUSHED_BY_PLAYER); break; } else { - CheckTriggeredElementChange(element, CE_OTHER_PRESSING); + CheckTriggeredElementChange(x, y, element, CE_OTHER_GETS_PRESSED); CheckElementChange(x, y, element, CE_PRESSED_BY_PLAYER); }