From: Holger Schemel Date: Fri, 20 Nov 1998 00:54:43 +0000 (+0100) Subject: rnd-19981120-1 X-Git-Tag: 1.2.0^2~19 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=3dc317d10b44cc6b75db10ac194966ad8114d390;p=rocksndiamonds.git rnd-19981120-1 --- diff --git a/INSTALL b/INSTALL new file mode 100644 index 00000000..298ff6d6 --- /dev/null +++ b/INSTALL @@ -0,0 +1,68 @@ + +WHAT TO DO TO INSTALL "ROCKS_N_DIAMONDS-0.9" ON YOUR SYSTEM +=========================================================== + +If you have a Linux system (Intel based, a.out, kernel 1.2.x), you +can use the precompiled binary. + +If you have another Unix system, or an ELF system or just want to +compile the program by yourself, do the following: + +Edit the file "Makefile" and set the following options: + +XPM_INCLUDE_FILE - change this to the location where you + have your XPM-Library include file. + + You must have the XPM-Library "libXpm" + installed on your system to run this game. + If you don't have it, look at your local + FTP site with X11 archive to get it! :) + +GAME_DIR - You can leave these values untouched + if you use the default location for + the game directory. + If you want to move it to other places in + your directory tree, just change them + accordingly. (You can use symlinks instead, + of course.) + You might want to set GAME_DIR to the full + path of the game in your file system, so + you don't have to go to the game directory + when you want to play it. + +SOUNDS - If you never want to hear any sounds, + set this to "-DNO_SOUNDS", but be warned: + It's much less fun playing without sound! :) + (The program detects by itself if it can + play sounds or not, anyway.) + +SCORE_ENTRIES - Set this to "-DONE_PER_NAME" if you want + to allow only one entry per player in the + score file for each level. This is useful + if there are many players to prevent one + single player to "flood" the Hall Of Fame + of every level completely with his name... + On single user systems, "-DMANY_PER_NAME" + might be useful to have your name more + than once in the list. + +SYSTEM - If you have problems with the default + settings, it might be useful to uncomment + one of the defines for "SYSTEM" in the + Makefile, which defines values like + "-DSYSV" and something like that. + +CC, INCL, LIBS - Set these ones to the appropriate values + you usually use on your system to compile. + + +Now you can 'make clean' and 'make' and the game binary should be +compiled right out of the box. I have tested it with "-Wall" on my +system, so I hope that it compiles fine on other systems, too. + +The program should compile and run on Linux (of course), +HP-UX, AIX, Net-BSD, SUN and IRIX. + +Have fun! + +Holger Schemel, 22. Oktober 1995 diff --git a/Makefile b/Makefile index 65fa3028..23b693e5 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ clean: $(MAKE_CMD) clean backup: - ./scripts/make_backup.sh + ./Scripts/make_backup.sh depend: $(MAKE_CMD) depend diff --git a/src/events.c b/src/events.c index 15f72051..9d4e3837 100644 --- a/src/events.c +++ b/src/events.c @@ -426,9 +426,17 @@ void HandleKey(KeySym key, int key_status) return; } + + +#ifndef DEBUG + if (game_status == PLAYING && (tape.playing || tape.pausing)) return; +#endif + + + switch(game_status) { case TYPENAME: @@ -496,7 +504,12 @@ void HandleKey(KeySym key, int key_status) case XK_8: case XK_9: if (key == XK_0) - GameFrameDelay = 500; + { + if (GameFrameDelay == 500) + GameFrameDelay = GAME_FRAME_DELAY; + else + GameFrameDelay = 500; + } else GameFrameDelay = (key - XK_0) * 10; printf("Game speed == %d%% (%d ms delay between two frames)\n", diff --git a/src/game.c b/src/game.c index 13ae62bb..a48ad78b 100644 --- a/src/game.c +++ b/src/game.c @@ -23,6 +23,52 @@ #include "joystick.h" #include "network.h" +#ifdef DEBUG +static unsigned int getStateCheckSum(int counter) +{ + int x, y; + unsigned int mult = 1; + unsigned int checksum = 0; + static short lastFeld[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; + static boolean first_game = TRUE; + + for (y=0; ylights_still_needed = 0; player->friends_still_needed = 0; - for(j=0; j<4; j++) + for (j=0; j<4; j++) player->key[j] = FALSE; player->dynamite = 0; @@ -99,8 +145,8 @@ void InitGame() player->last_jx = player->last_jy = 0; player->jx = player->jy = 0; - DigField(player, 0,0,0,0,DF_NO_PUSH); - SnapField(player, 0,0); + DigField(player, 0, 0, 0, 0, DF_NO_PUSH); + SnapField(player, 0, 0); player->LevelSolved = FALSE; player->GameOver = FALSE; @@ -125,24 +171,31 @@ void InitGame() AllPlayersGone = SiebAktiv = FALSE; - for(i=0;i0 && Feld[x-1][y]==EL_SALZSAEURE) + 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) + 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) + 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) + else if (y > 0 && Feld[x][y-1] == EL_BADEWANNE2) Feld[x][y] = EL_BADEWANNE5; break; case EL_KAEFER_R: @@ -223,14 +276,14 @@ void InitGame() case EL_MAMPFER2: case EL_ROBOT: case EL_PACMAN: - InitMovDir(x,y); + InitMovDir(x, y); break; case EL_AMOEBE_VOLL: case EL_AMOEBE_BD: - InitAmoebaNr(x,y); + InitAmoebaNr(x, y); break; case EL_TROPFEN: - if (y==lev_fieldy-1) + if (y == lev_fieldy - 1) { Feld[x][y] = EL_AMOEBING; Store[x][y] = EL_AMOEBE_NASS; @@ -251,7 +304,7 @@ void InitGame() break; case EL_SCHWEIN: case EL_DRACHE: - MovDir[x][y] = 1<connected && !player->present) { - for(j=0; jjx, jy = some_player->jy; @@ -290,11 +343,11 @@ void InitGame() /* when in single player mode, eliminate all but the first active player */ if (!options.network && !setup.team_mode) { - for(i=0; ijx, jy = player->jy; @@ -310,7 +363,7 @@ void InitGame() } } - for(i=0; igems_still_needed,3),FS_SMALL,FC_YELLOW); - DrawTextExt(pix[PIX_DB_DOOR],gc, - DOOR_GFX_PAGEX1+XX_DYNAMITE,DOOR_GFX_PAGEY1+YY_DYNAMITE, - int2str(local_player->dynamite,3),FS_SMALL,FC_YELLOW); - DrawTextExt(pix[PIX_DB_DOOR],gc, - DOOR_GFX_PAGEX1+XX_SCORE,DOOR_GFX_PAGEY1+YY_SCORE, - int2str(local_player->score,5),FS_SMALL,FC_YELLOW); - DrawTextExt(pix[PIX_DB_DOOR],gc, - DOOR_GFX_PAGEX1+XX_TIME,DOOR_GFX_PAGEY1+YY_TIME, - int2str(TimeLeft,3),FS_SMALL,FC_YELLOW); + XCopyArea(display, pix[PIX_DOOR], pix[PIX_DB_DOOR], gc, + DOOR_GFX_PAGEX5, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, + DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1); + DrawTextExt(pix[PIX_DB_DOOR], gc, + DOOR_GFX_PAGEX1 + XX_LEVEL, DOOR_GFX_PAGEY1 + YY_LEVEL, + int2str(level_nr, 2), FS_SMALL, FC_YELLOW); + DrawTextExt(pix[PIX_DB_DOOR], gc, + DOOR_GFX_PAGEX1 + XX_EMERALDS, DOOR_GFX_PAGEY1 + YY_EMERALDS, + int2str(local_player->gems_still_needed,3), FS_SMALL, FC_YELLOW); + DrawTextExt(pix[PIX_DB_DOOR], gc, + DOOR_GFX_PAGEX1 + XX_DYNAMITE, DOOR_GFX_PAGEY1 + YY_DYNAMITE, + int2str(local_player->dynamite, 3), FS_SMALL, FC_YELLOW); + DrawTextExt(pix[PIX_DB_DOOR], gc, + DOOR_GFX_PAGEX1 + XX_SCORE, DOOR_GFX_PAGEY1 + YY_SCORE, + int2str(local_player->score, 5), FS_SMALL, FC_YELLOW); + DrawTextExt(pix[PIX_DB_DOOR], gc, + DOOR_GFX_PAGEX1 + XX_TIME, DOOR_GFX_PAGEY1 + YY_TIME, + int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); DrawGameButton(BUTTON_GAME_STOP); DrawGameButton(BUTTON_GAME_PAUSE); DrawGameButton(BUTTON_GAME_PLAY); - DrawSoundDisplay(BUTTON_SOUND_MUSIC | (BUTTON_ON * setup.sound_music)); - DrawSoundDisplay(BUTTON_SOUND_LOOPS | (BUTTON_ON * setup.sound_loops)); - DrawSoundDisplay(BUTTON_SOUND_SIMPLE | (BUTTON_ON * setup.sound_simple)); - XCopyArea(display,drawto,pix[PIX_DB_DOOR],gc, - DX+GAME_CONTROL_XPOS,DY+GAME_CONTROL_YPOS, - GAME_CONTROL_XSIZE,2*GAME_CONTROL_YSIZE, - DOOR_GFX_PAGEX1+GAME_CONTROL_XPOS, - DOOR_GFX_PAGEY1+GAME_CONTROL_YPOS); + DrawSoundDisplay(BUTTON_SOUND_MUSIC | (setup.sound_music ? BUTTON_ON : 0)); + DrawSoundDisplay(BUTTON_SOUND_LOOPS | (setup.sound_loops ? BUTTON_ON : 0)); + DrawSoundDisplay(BUTTON_SOUND_SIMPLE | (setup.sound_simple ? BUTTON_ON : 0)); + XCopyArea(display, drawto, pix[PIX_DB_DOOR], gc, + DX + GAME_CONTROL_XPOS, DY + GAME_CONTROL_YPOS, + GAME_CONTROL_XSIZE, 2 * GAME_CONTROL_YSIZE, + DOOR_GFX_PAGEX1 + GAME_CONTROL_XPOS, + DOOR_GFX_PAGEY1 + GAME_CONTROL_YPOS); OpenDoor(DOOR_OPEN_1); @@ -382,7 +435,7 @@ void InitGame() XAutoRepeatOff(display); - for (i=0;i<4;i++) + for (i=0; i<4; i++) printf("Spieler %d %saktiv.\n", i+1, (stored_player[i].active ? "" : "nicht ")); @@ -393,10 +446,10 @@ void InitMovDir(int x, int y) int i, element = Feld[x][y]; static int xy[4][2] = { - { 0,+1 }, - { +1,0 }, - { 0,-1 }, - { -1,0 } + { 0, +1 }, + { +1, 0 }, + { 0, -1 }, + { -1, 0 } }; static int direction[2][4] = { @@ -411,59 +464,57 @@ void InitMovDir(int x, int y) case EL_KAEFER_L: case EL_KAEFER_U: Feld[x][y] = EL_KAEFER; - MovDir[x][y] = direction[0][element-EL_KAEFER_R]; + MovDir[x][y] = direction[0][element - EL_KAEFER_R]; break; case EL_FLIEGER_R: case EL_FLIEGER_O: case EL_FLIEGER_L: case EL_FLIEGER_U: Feld[x][y] = EL_FLIEGER; - MovDir[x][y] = direction[0][element-EL_FLIEGER_R]; + MovDir[x][y] = direction[0][element - EL_FLIEGER_R]; break; case EL_BUTTERFLY_R: case EL_BUTTERFLY_O: case EL_BUTTERFLY_L: case EL_BUTTERFLY_U: Feld[x][y] = EL_BUTTERFLY; - MovDir[x][y] = direction[0][element-EL_BUTTERFLY_R]; + MovDir[x][y] = direction[0][element - EL_BUTTERFLY_R]; break; case EL_FIREFLY_R: case EL_FIREFLY_O: case EL_FIREFLY_L: case EL_FIREFLY_U: Feld[x][y] = EL_FIREFLY; - MovDir[x][y] = direction[0][element-EL_FIREFLY_R]; + MovDir[x][y] = direction[0][element - EL_FIREFLY_R]; break; case EL_PACMAN_R: case EL_PACMAN_O: case EL_PACMAN_L: case EL_PACMAN_U: Feld[x][y] = EL_PACMAN; - MovDir[x][y] = direction[0][element-EL_PACMAN_R]; + MovDir[x][y] = direction[0][element - EL_PACMAN_R]; break; default: - MovDir[x][y] = 1<= 0) + if ((hi_pos = NewHiScore()) >= 0) { game_status = HALLOFFAME; DrawHallOfFame(hi_pos); @@ -567,37 +618,37 @@ void GameWon() boolean NewHiScore() { - int k,l; + int k, l; int position = -1; LoadScore(level_nr); if (!strcmp(setup.player_name, EMPTY_ALIAS) || local_player->score < highscore[MAX_SCORE_ENTRIES-1].Score) - return(-1); + return -1; - for(k=0;kscore > highscore[k].Score) { /* Spieler kommt in Highscore-Liste */ - if (kk;l--) + for (l=m; l>k; l--) { - strcpy(highscore[l].Name,highscore[l-1].Name); - highscore[l].Score = highscore[l-1].Score; + strcpy(highscore[l].Name, highscore[l - 1].Name); + highscore[l].Score = highscore[l - 1].Score; } } @@ -618,16 +669,16 @@ boolean NewHiScore() } - if (position>=0) + if (position >= 0) SaveScore(level_nr); - return(position); + return position; } void InitMovingField(int x, int y, int direction) { - int newx = x + (direction==MV_LEFT ? -1 : direction==MV_RIGHT ? +1 : 0); - int newy = y + (direction==MV_UP ? -1 : direction==MV_DOWN ? +1 : 0); + int newx = x + (direction == MV_LEFT ? -1 : direction == MV_RIGHT ? +1 : 0); + int newy = y + (direction == MV_UP ? -1 : direction == MV_DOWN ? +1 : 0); MovDir[x][y] = direction; MovDir[newx][newy] = direction; @@ -638,8 +689,8 @@ void InitMovingField(int x, int y, int direction) void Moving2Blocked(int x, int y, int *goes_to_x, int *goes_to_y) { int direction = MovDir[x][y]; - int newx = x + (direction==MV_LEFT ? -1 : direction==MV_RIGHT ? +1 : 0); - int newy = y + (direction==MV_UP ? -1 : direction==MV_DOWN ? +1 : 0); + int newx = x + (direction == MV_LEFT ? -1 : direction == MV_RIGHT ? +1 : 0); + int newy = y + (direction == MV_UP ? -1 : direction == MV_DOWN ? +1 : 0); *goes_to_x = newx; *goes_to_y = newy; @@ -650,13 +701,13 @@ void Blocked2Moving(int x, int y, int *comes_from_x, int *comes_from_y) int oldx = x, oldy = y; int direction = MovDir[x][y]; - if (direction==MV_LEFT) + if (direction == MV_LEFT) oldx++; - else if (direction==MV_RIGHT) + else if (direction == MV_RIGHT) oldx--; - else if (direction==MV_UP) + else if (direction == MV_UP) oldy++; - else if (direction==MV_DOWN) + else if (direction == MV_DOWN) oldy--; *comes_from_x = oldx; @@ -667,15 +718,15 @@ int MovingOrBlocked2Element(int x, int y) { int element = Feld[x][y]; - if (element==EL_BLOCKED) + if (element == EL_BLOCKED) { - int oldx,oldy; + int oldx, oldy; - Blocked2Moving(x,y,&oldx,&oldy); - return(Feld[oldx][oldy]); + Blocked2Moving(x, y, &oldx, &oldy); + return Feld[oldx][oldy]; } else - return(element); + return element; } static void RemoveField(int x, int y) @@ -688,29 +739,29 @@ static void RemoveField(int x, int y) void RemoveMovingField(int x, int y) { - int oldx = x,oldy = y, newx = x,newy = y; + int oldx = x, oldy = y, newx = x, newy = y; - if (Feld[x][y] != EL_BLOCKED && !IS_MOVING(x,y)) + if (Feld[x][y] != EL_BLOCKED && !IS_MOVING(x, y)) return; - if (IS_MOVING(x,y)) + if (IS_MOVING(x, y)) { - Moving2Blocked(x,y,&newx,&newy); + Moving2Blocked(x, y, &newx, &newy); if (Feld[newx][newy] != EL_BLOCKED) return; } - else if (Feld[x][y]==EL_BLOCKED) + else if (Feld[x][y] == EL_BLOCKED) { - Blocked2Moving(x,y,&oldx,&oldy); - if (!IS_MOVING(oldx,oldy)) + Blocked2Moving(x, y, &oldx, &oldy); + if (!IS_MOVING(oldx, oldy)) return; } - if (Feld[x][y]==EL_BLOCKED && - (Store[oldx][oldy]==EL_MORAST_LEER || - Store[oldx][oldy]==EL_SIEB_LEER || - Store[oldx][oldy]==EL_SIEB2_LEER || - Store[oldx][oldy]==EL_AMOEBE_NASS)) + if (Feld[x][y] == EL_BLOCKED && + (Store[oldx][oldy] == EL_MORAST_LEER || + Store[oldx][oldy] == EL_SIEB_LEER || + Store[oldx][oldy] == EL_SIEB2_LEER || + Store[oldx][oldy] == EL_AMOEBE_NASS)) { Feld[oldx][oldy] = Store[oldx][oldy]; Store[oldx][oldy] = Store2[oldx][oldy] = 0; @@ -722,8 +773,8 @@ void RemoveMovingField(int x, int y) MovPos[oldx][oldy] = MovDir[oldx][oldy] = MovDelay[oldx][oldy] = 0; MovPos[newx][newy] = MovDir[newx][newy] = MovDelay[newx][newy] = 0; - DrawLevelField(oldx,oldy); - DrawLevelField(newx,newy); + DrawLevelField(oldx, oldy); + DrawLevelField(newx, newy); } void DrawDynamite(int x, int y) @@ -732,27 +783,27 @@ void DrawDynamite(int x, int y) int graphic = el2gfx(Feld[x][y]); int phase; - if (!IN_SCR_FIELD(sx,sy) || IS_PLAYER(x,y)) + if (!IN_SCR_FIELD(sx, sy) || IS_PLAYER(x, y)) return; if (Store[x][y]) - DrawGraphic(sx,sy, el2gfx(Store[x][y])); + DrawGraphic(sx, sy, el2gfx(Store[x][y])); - if (Feld[x][y]==EL_DYNAMIT) + if (Feld[x][y] == EL_DYNAMIT) { - if ((phase = (96-MovDelay[x][y])/12) > 6) + if ((phase = (96 - MovDelay[x][y]) / 12) > 6) phase = 6; } else { - if ((phase = ((96-MovDelay[x][y])/6) % 8) > 3) - phase = 7-phase; + if ((phase = ((96 - MovDelay[x][y]) / 6) % 8) > 3) + phase = 7 - phase; } if (Store[x][y]) - DrawGraphicThruMask(sx,sy, graphic + phase); + DrawGraphicThruMask(sx, sy, graphic + phase); else - DrawGraphic(sx,sy, graphic + phase); + DrawGraphic(sx, sy, graphic + phase); } void CheckDynamite(int x, int y) @@ -763,59 +814,59 @@ void CheckDynamite(int x, int y) if (MovDelay[x][y]) { if (!(MovDelay[x][y] % 12)) - PlaySoundLevel(x,y,SND_ZISCH); + PlaySoundLevel(x, y, SND_ZISCH); - if (Feld[x][y]==EL_DYNAMIT && !(MovDelay[x][y] % 12)) - DrawDynamite(x,y); - else if (Feld[x][y]==EL_DYNABOMB && !(MovDelay[x][y] % 6)) - DrawDynamite(x,y); + if (Feld[x][y] == EL_DYNAMIT && !(MovDelay[x][y] % 12)) + DrawDynamite(x, y); + else if (Feld[x][y] == EL_DYNABOMB && !(MovDelay[x][y] % 6)) + DrawDynamite(x, y); return; } } StopSound(SND_ZISCH); - Bang(x,y); + Bang(x, y); } void Explode(int ex, int ey, int phase, int mode) { - int x,y; + int x, y; int num_phase = 9, delay = 2; - int last_phase = num_phase*delay; - int half_phase = (num_phase/2)*delay; + int last_phase = num_phase * delay; + int half_phase = (num_phase / 2) * delay; - if (phase==0) /* Feld 'Store' initialisieren */ + if (phase == 0) /* Feld 'Store' initialisieren */ { int center_element = Feld[ex][ey]; - if (IS_MOVING(ex,ey) || IS_BLOCKED(ex,ey)) + if (IS_MOVING(ex, ey) || IS_BLOCKED(ex, ey)) { - center_element = MovingOrBlocked2Element(ex,ey); - RemoveMovingField(ex,ey); + center_element = MovingOrBlocked2Element(ex, ey); + RemoveMovingField(ex, ey); } - for(y=ey-1;ydynabomb_size; j++) + for (j=1; j<=player->dynabomb_size; j++) { int x = ex+j*xy[i%4][0]; int y = ey+j*xy[i%4][1]; int element; - if (!IN_LEV_FIELD(x,y) || IS_MASSIV(Feld[x][y])) + if (!IN_LEV_FIELD(x, y) || IS_MASSIV(Feld[x][y])) break; element = Feld[x][y]; - Explode(x,y,0,EX_BORDER); + Explode(x, y, 0, EX_BORDER); if (element != EL_LEERRAUM && element != EL_ERDREICH && @@ -975,7 +1027,7 @@ void Bang(int x, int y) { int element = Feld[x][y]; - PlaySoundLevel(x,y,SND_ROAAAR); + PlaySoundLevel(x, y, SND_ROAAAR); switch(element) { @@ -988,20 +1040,20 @@ void Bang(int x, int y) case EL_ROBOT: case EL_PACMAN: RaiseScoreElement(element); - Explode(x,y,0,EX_NORMAL); + Explode(x, y, 0, EX_NORMAL); break; case EL_DYNABOMB: case EL_DYNABOMB_NR: case EL_DYNABOMB_SZ: case EL_DYNABOMB_XL: - DynaExplode(x,y); + DynaExplode(x, y); break; case EL_BIRNE_AUS: case EL_BIRNE_EIN: - Explode(x,y,0,EX_CENTER); + Explode(x, y, 0, EX_CENTER); break; default: - Explode(x,y,0,EX_NORMAL); + Explode(x, y, 0, EX_NORMAL); break; } } @@ -1012,16 +1064,16 @@ void Blurb(int x, int y) if (element!=EL_BLURB_LEFT && element!=EL_BLURB_RIGHT) /* Anfang */ { - PlaySoundLevel(x,y,SND_BLURB); - if (IN_LEV_FIELD(x-1,y) && IS_FREE(x-1,y) && - (!IN_LEV_FIELD(x-1,y-1) || - !CAN_FALL(MovingOrBlocked2Element(x-1,y-1)))) + PlaySoundLevel(x, y, SND_BLURB); + if (IN_LEV_FIELD(x-1, y) && IS_FREE(x-1, y) && + (!IN_LEV_FIELD(x-1, y-1) || + !CAN_FALL(MovingOrBlocked2Element(x-1, y-1)))) { Feld[x-1][y] = EL_BLURB_LEFT; } - if (IN_LEV_FIELD(x+1,y) && IS_FREE(x+1,y) && - (!IN_LEV_FIELD(x+1,y-1) || - !CAN_FALL(MovingOrBlocked2Element(x+1,y-1)))) + if (IN_LEV_FIELD(x+1, y) && IS_FREE(x+1, y) && + (!IN_LEV_FIELD(x+1, y-1) || + !CAN_FALL(MovingOrBlocked2Element(x+1, y-1)))) { Feld[x+1][y] = EL_BLURB_RIGHT; } @@ -1036,13 +1088,13 @@ void Blurb(int x, int y) if (MovDelay[x][y]) /* neue Phase / in Wartezustand */ { MovDelay[x][y]--; - if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x),SCREENY(y))) - DrawGraphic(SCREENX(x),SCREENY(y),graphic+4-MovDelay[x][y]/2); + if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + DrawGraphic(SCREENX(x), SCREENY(y), graphic+4-MovDelay[x][y]/2); if (!MovDelay[x][y]) { Feld[x][y] = EL_LEERRAUM; - DrawLevelField(x,y); + DrawLevelField(x, y); } } } @@ -1050,7 +1102,7 @@ void Blurb(int x, int y) void Impact(int x, int y) { - boolean lastline = (y==lev_fieldy-1); + boolean lastline = (y == lev_fieldy-1); boolean object_hit = FALSE; int element = Feld[x][y]; int smashed = 0; @@ -1061,34 +1113,34 @@ void Impact(int x, int y) if (Feld[x][y+1] == EL_PLAYER_IS_LEAVING) return; - object_hit = (!IS_FREE(x,y+1) && (!IS_MOVING(x,y+1) || + object_hit = (!IS_FREE(x, y+1) && (!IS_MOVING(x, y+1) || MovDir[x][y+1]!=MV_DOWN || MovPos[x][y+1]<=TILEY/2)); if (object_hit) - smashed = MovingOrBlocked2Element(x,y+1); + smashed = MovingOrBlocked2Element(x, y+1); } /* Auftreffendes Element fällt in Salzsäure */ - if (!lastline && smashed==EL_SALZSAEURE) + if (!lastline && smashed == EL_SALZSAEURE) { - Blurb(x,y); + Blurb(x, y); return; } /* Auftreffendes Element ist Bombe */ - if (element==EL_BOMBE && (lastline || object_hit)) + if (element == EL_BOMBE && (lastline || object_hit)) { - Bang(x,y); + Bang(x, y); return; } /* Auftreffendes Element ist Säuretropfen */ - if (element==EL_TROPFEN && (lastline || object_hit)) + if (element == EL_TROPFEN && (lastline || object_hit)) { - if (object_hit && IS_PLAYER(x,y+1)) - KillHero(PLAYERINFO(x,y+1)); - else if (object_hit && (smashed==EL_MAULWURF || smashed==EL_PINGUIN)) - Bang(x,y+1); + if (object_hit && IS_PLAYER(x, y+1)) + KillHero(PLAYERINFO(x, y+1)); + else if (object_hit && (smashed == EL_MAULWURF || smashed == EL_PINGUIN)) + Bang(x, y+1); else { Feld[x][y] = EL_AMOEBING; @@ -1101,53 +1153,53 @@ void Impact(int x, int y) if (!lastline && object_hit) { if (CAN_CHANGE(element) && - (smashed==EL_SIEB_LEER || smashed==EL_SIEB2_LEER) && !SiebAktiv) + (smashed == EL_SIEB_LEER || smashed == EL_SIEB2_LEER) && !SiebAktiv) SiebAktiv = level.dauer_sieb * FRAMES_PER_SECOND; - if (IS_PLAYER(x,y+1)) + if (IS_PLAYER(x, y+1)) { - KillHero(PLAYERINFO(x,y+1)); + KillHero(PLAYERINFO(x, y+1)); return; } - else if (smashed==EL_MAULWURF || smashed==EL_PINGUIN) + else if (smashed == EL_MAULWURF || smashed == EL_PINGUIN) { - Bang(x,y+1); + Bang(x, y+1); return; } - else if (element==EL_EDELSTEIN_BD) + else if (element == EL_EDELSTEIN_BD) { if (IS_ENEMY(smashed) && IS_BD_ELEMENT(smashed)) { - Bang(x,y+1); + Bang(x, y+1); return; } } - else if (element==EL_FELSBROCKEN) + else if (element == EL_FELSBROCKEN) { - if (IS_ENEMY(smashed) || smashed==EL_BOMBE || smashed==EL_SONDE || - smashed==EL_SCHWEIN || smashed==EL_DRACHE) + if (IS_ENEMY(smashed) || smashed == EL_BOMBE || smashed == EL_SONDE || + smashed == EL_SCHWEIN || smashed == EL_DRACHE) { - Bang(x,y+1); + Bang(x, y+1); return; } - else if (!IS_MOVING(x,y+1)) + else if (!IS_MOVING(x, y+1)) { - if (smashed==EL_BIRNE_AUS || smashed==EL_BIRNE_EIN) + if (smashed == EL_BIRNE_AUS || smashed == EL_BIRNE_EIN) { - Bang(x,y+1); + Bang(x, y+1); return; } - else if (smashed==EL_KOKOSNUSS) + else if (smashed == EL_KOKOSNUSS) { Feld[x][y+1] = EL_CRACKINGNUT; - PlaySoundLevel(x,y,SND_KNACK); + PlaySoundLevel(x, y, SND_KNACK); RaiseScoreElement(EL_KOKOSNUSS); return; } - else if (smashed==EL_DIAMANT) + else if (smashed == EL_DIAMANT) { Feld[x][y+1] = EL_LEERRAUM; - PlaySoundLevel(x,y,SND_QUIRK); + PlaySoundLevel(x, y, SND_QUIRK); return; } } @@ -1155,9 +1207,10 @@ void Impact(int x, int y) } /* Geräusch beim Durchqueren des Siebes */ - if (!lastline && (Feld[x][y+1]==EL_SIEB_LEER || Feld[x][y+1]==EL_SIEB2_LEER)) + if (!lastline && + (Feld[x][y+1] == EL_SIEB_LEER || Feld[x][y+1] == EL_SIEB2_LEER)) { - PlaySoundLevel(x,y,SND_QUIRK); + PlaySoundLevel(x, y, SND_QUIRK); return; } @@ -1199,7 +1252,7 @@ void Impact(int x, int y) } if (sound>=0) - PlaySoundLevel(x,y,sound); + PlaySoundLevel(x, y, sound); } } @@ -1207,20 +1260,20 @@ void TurnRound(int x, int y) { static struct { - int x,y; + int x, y; } move_xy[] = { - { 0,0 }, - {-1,0 }, - {+1,0 }, - { 0,0 }, - { 0,-1 }, - { 0,0 }, { 0,0 }, { 0,0 }, - { 0,+1 } + { 0, 0 }, + {-1, 0 }, + {+1, 0 }, + { 0, 0 }, + { 0, -1 }, + { 0, 0 }, { 0, 0 }, { 0, 0 }, + { 0, +1 } }; static struct { - int left,right,back; + int left, right, back; } turn[] = { { 0, 0, 0 }, @@ -1247,48 +1300,48 @@ void TurnRound(int x, int y) int right_x = x+right_dx, right_y = y+right_dy; int move_x = x+move_dx, move_y = y+move_dy; - if (element==EL_KAEFER || element==EL_BUTTERFLY) + if (element == EL_KAEFER || element == EL_BUTTERFLY) { - TestIfBadThingHitsOtherBadThing(x,y); + TestIfBadThingHitsOtherBadThing(x, y); - if (IN_LEV_FIELD(right_x,right_y) && - IS_FREE_OR_PLAYER(right_x,right_y)) + if (IN_LEV_FIELD(right_x, right_y) && + IS_FREE_OR_PLAYER(right_x, right_y)) MovDir[x][y] = right_dir; - else if (!IN_LEV_FIELD(move_x,move_y) || - !IS_FREE_OR_PLAYER(move_x,move_y)) + else if (!IN_LEV_FIELD(move_x, move_y) || + !IS_FREE_OR_PLAYER(move_x, move_y)) MovDir[x][y] = left_dir; - if (element==EL_KAEFER && MovDir[x][y] != old_move_dir) + if (element == EL_KAEFER && MovDir[x][y] != old_move_dir) MovDelay[x][y] = 9; - else if (element==EL_BUTTERFLY) /* && MovDir[x][y]==left_dir) */ + else if (element == EL_BUTTERFLY) /* && MovDir[x][y] == left_dir) */ MovDelay[x][y] = 1; } - else if (element==EL_FLIEGER || element==EL_FIREFLY) + else if (element == EL_FLIEGER || element == EL_FIREFLY) { - TestIfBadThingHitsOtherBadThing(x,y); + TestIfBadThingHitsOtherBadThing(x, y); - if (IN_LEV_FIELD(left_x,left_y) && - IS_FREE_OR_PLAYER(left_x,left_y)) + if (IN_LEV_FIELD(left_x, left_y) && + IS_FREE_OR_PLAYER(left_x, left_y)) MovDir[x][y] = left_dir; - else if (!IN_LEV_FIELD(move_x,move_y) || - !IS_FREE_OR_PLAYER(move_x,move_y)) + else if (!IN_LEV_FIELD(move_x, move_y) || + !IS_FREE_OR_PLAYER(move_x, move_y)) MovDir[x][y] = right_dir; - if (element==EL_FLIEGER && MovDir[x][y] != old_move_dir) + if (element == EL_FLIEGER && MovDir[x][y] != old_move_dir) MovDelay[x][y] = 9; - else if (element==EL_FIREFLY) /* && MovDir[x][y]==right_dir) */ + else if (element == EL_FIREFLY) /* && MovDir[x][y] == right_dir) */ MovDelay[x][y] = 1; } - else if (element==EL_MAMPFER) + else if (element == EL_MAMPFER) { boolean can_turn_left = FALSE, can_turn_right = FALSE; - if (IN_LEV_FIELD(left_x,left_y) && - (IS_FREE_OR_PLAYER(left_x,left_y) || + if (IN_LEV_FIELD(left_x, left_y) && + (IS_FREE_OR_PLAYER(left_x, left_y) || Feld[left_x][left_y] == EL_DIAMANT)) can_turn_left = TRUE; - if (IN_LEV_FIELD(right_x,right_y) && - (IS_FREE_OR_PLAYER(right_x,right_y) || + if (IN_LEV_FIELD(right_x, right_y) && + (IS_FREE_OR_PLAYER(right_x, right_y) || Feld[right_x][right_y] == EL_DIAMANT)) can_turn_right = TRUE; @@ -1303,16 +1356,16 @@ void TurnRound(int x, int y) MovDelay[x][y] = 16+16*RND(3); } - else if (element==EL_MAMPFER2) + else if (element == EL_MAMPFER2) { boolean can_turn_left = FALSE, can_turn_right = FALSE; - if (IN_LEV_FIELD(left_x,left_y) && - (IS_FREE_OR_PLAYER(left_x,left_y) || + if (IN_LEV_FIELD(left_x, left_y) && + (IS_FREE_OR_PLAYER(left_x, left_y) || IS_MAMPF2(Feld[left_x][left_y]))) can_turn_left = TRUE; - if (IN_LEV_FIELD(right_x,right_y) && - (IS_FREE_OR_PLAYER(right_x,right_y) || + if (IN_LEV_FIELD(right_x, right_y) && + (IS_FREE_OR_PLAYER(right_x, right_y) || IS_MAMPF2(Feld[right_x][right_y]))) can_turn_right = TRUE; @@ -1327,16 +1380,16 @@ void TurnRound(int x, int y) MovDelay[x][y] = 16+16*RND(3); } - else if (element==EL_PACMAN) + else if (element == EL_PACMAN) { boolean can_turn_left = FALSE, can_turn_right = FALSE; - if (IN_LEV_FIELD(left_x,left_y) && - (IS_FREE_OR_PLAYER(left_x,left_y) || + if (IN_LEV_FIELD(left_x, left_y) && + (IS_FREE_OR_PLAYER(left_x, left_y) || IS_AMOEBOID(Feld[left_x][left_y]))) can_turn_left = TRUE; - if (IN_LEV_FIELD(right_x,right_y) && - (IS_FREE_OR_PLAYER(right_x,right_y) || + if (IN_LEV_FIELD(right_x, right_y) && + (IS_FREE_OR_PLAYER(right_x, right_y) || IS_AMOEBOID(Feld[right_x][right_y]))) can_turn_right = TRUE; @@ -1351,7 +1404,7 @@ void TurnRound(int x, int y) MovDelay[x][y] = 6+RND(40); } - else if (element==EL_SCHWEIN) + else if (element == EL_SCHWEIN) { boolean can_turn_left = FALSE, can_turn_right = FALSE, can_move_on = FALSE; boolean should_turn_left = FALSE, should_turn_right = FALSE; @@ -1359,32 +1412,32 @@ void TurnRound(int x, int y) int rnd_value = 24; int rnd = RND(rnd_value); - if (IN_LEV_FIELD(left_x,left_y) && - (IS_FREE(left_x,left_y) || IS_GEM(Feld[left_x][left_y]))) + if (IN_LEV_FIELD(left_x, left_y) && + (IS_FREE(left_x, left_y) || IS_GEM(Feld[left_x][left_y]))) can_turn_left = TRUE; - if (IN_LEV_FIELD(right_x,right_y) && - (IS_FREE(right_x,right_y) || IS_GEM(Feld[right_x][right_y]))) + if (IN_LEV_FIELD(right_x, right_y) && + (IS_FREE(right_x, right_y) || IS_GEM(Feld[right_x][right_y]))) can_turn_right = TRUE; - if (IN_LEV_FIELD(move_x,move_y) && - (IS_FREE(move_x,move_y) || IS_GEM(Feld[move_x][move_y]))) + if (IN_LEV_FIELD(move_x, move_y) && + (IS_FREE(move_x, move_y) || IS_GEM(Feld[move_x][move_y]))) can_move_on = TRUE; if (can_turn_left && (!can_move_on || - (IN_LEV_FIELD(x+back_dx+left_dx,y+back_dy+left_dy) && - !IS_FREE(x+back_dx+left_dx,y+back_dy+left_dy)))) + (IN_LEV_FIELD(x+back_dx+left_dx, y+back_dy+left_dy) && + !IS_FREE(x+back_dx+left_dx, y+back_dy+left_dy)))) should_turn_left = TRUE; if (can_turn_right && (!can_move_on || - (IN_LEV_FIELD(x+back_dx+right_dx,y+back_dy+right_dy) && - !IS_FREE(x+back_dx+right_dx,y+back_dy+right_dy)))) + (IN_LEV_FIELD(x+back_dx+right_dx, y+back_dy+right_dy) && + !IS_FREE(x+back_dx+right_dx, y+back_dy+right_dy)))) should_turn_right = TRUE; if (can_move_on && (!can_turn_left || !can_turn_right || - (IN_LEV_FIELD(x+move_dx+left_dx,y+move_dy+left_dy) && - !IS_FREE(x+move_dx+left_dx,y+move_dy+left_dy)) || - (IN_LEV_FIELD(x+move_dx+right_dx,y+move_dy+right_dy) && - !IS_FREE(x+move_dx+right_dx,y+move_dy+right_dy)))) + (IN_LEV_FIELD(x+move_dx+left_dx, y+move_dy+left_dy) && + !IS_FREE(x+move_dx+left_dx, y+move_dy+left_dy)) || + (IN_LEV_FIELD(x+move_dx+right_dx, y+move_dy+right_dy) && + !IS_FREE(x+move_dx+right_dx, y+move_dy+right_dy)))) should_move_on = TRUE; if (should_turn_left || should_turn_right || should_move_on) @@ -1417,23 +1470,23 @@ void TurnRound(int x, int y) else MovDir[x][y] = back_dir; - if (!IS_FREE(x+move_xy[MovDir[x][y]].x,y+move_xy[MovDir[x][y]].y) && + if (!IS_FREE(x+move_xy[MovDir[x][y]].x, y+move_xy[MovDir[x][y]].y) && !IS_GEM(Feld[x+move_xy[MovDir[x][y]].x][y+move_xy[MovDir[x][y]].y])) MovDir[x][y] = old_move_dir; MovDelay[x][y] = 0; } - else if (element==EL_DRACHE) + else if (element == EL_DRACHE) { boolean can_turn_left = FALSE, can_turn_right = FALSE, can_move_on = FALSE; int rnd_value = 24; int rnd = RND(rnd_value); - if (IN_LEV_FIELD(left_x,left_y) && IS_FREE(left_x,left_y)) + if (IN_LEV_FIELD(left_x, left_y) && IS_FREE(left_x, left_y)) can_turn_left = TRUE; - if (IN_LEV_FIELD(right_x,right_y) && IS_FREE(right_x,right_y)) + if (IN_LEV_FIELD(right_x, right_y) && IS_FREE(right_x, right_y)) can_turn_right = TRUE; - if (IN_LEV_FIELD(move_x,move_y) && IS_FREE(move_x,move_y)) + if (IN_LEV_FIELD(move_x, move_y) && IS_FREE(move_x, move_y)) can_move_on = TRUE; if (can_move_on && rnd > rnd_value/8) @@ -1447,13 +1500,13 @@ void TurnRound(int x, int y) else MovDir[x][y] = back_dir; - if (!IS_FREE(x+move_xy[MovDir[x][y]].x,y+move_xy[MovDir[x][y]].y)) + if (!IS_FREE(x+move_xy[MovDir[x][y]].x, y+move_xy[MovDir[x][y]].y)) MovDir[x][y] = old_move_dir; MovDelay[x][y] = 0; } - else if (element==EL_ROBOT || element==EL_SONDE || - element==EL_MAULWURF || element==EL_PINGUIN) + else if (element == EL_ROBOT || element == EL_SONDE || + element == EL_MAULWURF || element == EL_PINGUIN) { int attr_x = -1, attr_y = -1; @@ -1466,7 +1519,7 @@ void TurnRound(int x, int y) { int i; - for(i=0; ijx, jy = player->jy; @@ -1482,29 +1535,29 @@ void TurnRound(int x, int y) } } - if (element==EL_ROBOT && ZX>=0 && ZY>=0) + if (element == EL_ROBOT && ZX>=0 && ZY>=0) { attr_x = ZX; attr_y = ZY; } - if (element==EL_MAULWURF || element==EL_PINGUIN) + if (element == EL_MAULWURF || element == EL_PINGUIN) { int i; static int xy[4][2] = { - { 0,-1 }, - { -1,0 }, - { +1,0 }, - { 0,+1 } + { 0, -1 }, + { -1, 0 }, + { +1, 0 }, + { 0, +1 } }; - for(i=0;i<4;i++) + for (i=0; i<4; i++) { int ex = x + xy[i%4][0]; int ey = y + xy[i%4][1]; - if (IN_LEV_FIELD(ex,ey) && Feld[ex][ey] == EL_AUSGANG_AUF) + if (IN_LEV_FIELD(ex, ey) && Feld[ex][ey] == EL_AUSGANG_AUF) { attr_x = ex; attr_y = ey; @@ -1523,15 +1576,15 @@ void TurnRound(int x, int y) else if (attr_y>y) MovDir[x][y] |= (AllPlayersGone ? MV_UP : MV_DOWN); - if (element==EL_ROBOT) + if (element == EL_ROBOT) { int newx, newy; if ((MovDir[x][y]&(MV_LEFT|MV_RIGHT)) && (MovDir[x][y]&(MV_UP|MV_DOWN))) MovDir[x][y] &= (RND(2) ? (MV_LEFT|MV_RIGHT) : (MV_UP|MV_DOWN)); - Moving2Blocked(x,y,&newx,&newy); + Moving2Blocked(x, y, &newx, &newy); - if (IN_LEV_FIELD(newx,newy) && IS_FREE_OR_PLAYER(newx,newy)) + if (IN_LEV_FIELD(newx, newy) && IS_FREE_OR_PLAYER(newx, newy)) MovDelay[x][y] = 8+8*!RND(3); else MovDelay[x][y] = 16; @@ -1549,24 +1602,24 @@ void TurnRound(int x, int y) MovDir[x][y] = new_move_dir & (first_horiz ? (MV_LEFT|MV_RIGHT) : (MV_UP|MV_DOWN)); - Moving2Blocked(x,y,&newx,&newy); + Moving2Blocked(x, y, &newx, &newy); - if (IN_LEV_FIELD(newx,newy) && - (IS_FREE(newx,newy) || + if (IN_LEV_FIELD(newx, newy) && + (IS_FREE(newx, newy) || Feld[newx][newy] == EL_SALZSAEURE || - ((element == EL_MAULWURF || element==EL_PINGUIN) && + ((element == EL_MAULWURF || element == EL_PINGUIN) && (Feld[newx][newy] == EL_AUSGANG_AUF || IS_MAMPF3(Feld[newx][newy]))))) return; MovDir[x][y] = new_move_dir & (!first_horiz ? (MV_LEFT|MV_RIGHT) : (MV_UP|MV_DOWN)); - Moving2Blocked(x,y,&newx,&newy); + Moving2Blocked(x, y, &newx, &newy); - if (IN_LEV_FIELD(newx,newy) && - (IS_FREE(newx,newy) || + if (IN_LEV_FIELD(newx, newy) && + (IS_FREE(newx, newy) || Feld[newx][newy] == EL_SALZSAEURE || - ((element == EL_MAULWURF || element==EL_PINGUIN) && + ((element == EL_MAULWURF || element == EL_PINGUIN) && (Feld[newx][newy] == EL_AUSGANG_AUF || IS_MAMPF3(Feld[newx][newy]))))) return; @@ -1582,7 +1635,7 @@ static boolean JustBeingPushed(int x, int y) { int i; - for(i=0; ijy + (player->jy - player->last_jy); if (x == next_jx && y == next_jy) - return(TRUE); + return TRUE; } } - return(FALSE); + return FALSE; } void StartMoving(int x, int y) @@ -1609,19 +1662,19 @@ void StartMoving(int x, int y) if (CAN_FALL(element) && y0 && IS_PLAYER(x-1,y)) || (x0 && IS_PLAYER(x-1, y)) || (x0 && IS_FREE(x-1,y) && - (IS_FREE(x-1,y+1) || Feld[x-1][y+1]==EL_SALZSAEURE)); - boolean right = (x0 && IS_FREE(x-1, y) && + (IS_FREE(x-1, y+1) || Feld[x-1][y+1] == EL_SALZSAEURE)); + boolean right = (x3) phase = 7-phase; - if (IN_SCR_FIELD(SCREENX(x),SCREENY(y))) - DrawGraphic(SCREENX(x),SCREENY(y), el2gfx(element)+phase); + if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + DrawGraphic(SCREENX(x), SCREENY(y), el2gfx(element)+phase); - if ((element==EL_MAMPFER || element==EL_MAMPFER2) - && MovDelay[x][y]%4==3) - PlaySoundLevel(x,y,SND_NJAM); + if ((element == EL_MAMPFER || element == EL_MAMPFER2) + && MovDelay[x][y]%4 == 3) + PlaySoundLevel(x, y, SND_NJAM); } - else if (element==EL_DRACHE) + else if (element == EL_DRACHE) { int i; int dir = MovDir[x][y]; @@ -1788,33 +1842,33 @@ void StartMoving(int x, int y) dir == MV_DOWN ? GFX_FLAMMEN_DOWN : GFX_LEERRAUM); int phase = FrameCounter % 2; - for(i=1;i<=3;i++) + for (i=1; i<=3; i++) { int xx = x + i*dx, yy = y + i*dy; int sx = SCREENX(xx), sy = SCREENY(yy); - if (!IN_LEV_FIELD(xx,yy) || - IS_SOLID(Feld[xx][yy]) || Feld[xx][yy]==EL_EXPLODING) + if (!IN_LEV_FIELD(xx, yy) || + IS_SOLID(Feld[xx][yy]) || Feld[xx][yy] == EL_EXPLODING) break; if (MovDelay[x][y]) { - int flamed = MovingOrBlocked2Element(xx,yy); + int flamed = MovingOrBlocked2Element(xx, yy); if (IS_ENEMY(flamed) || IS_EXPLOSIVE(flamed)) - Bang(xx,yy); + Bang(xx, yy); else - RemoveMovingField(xx,yy); + RemoveMovingField(xx, yy); Feld[xx][yy] = EL_BURNING; - if (IN_SCR_FIELD(sx,sy)) - DrawGraphic(sx,sy, graphic + phase*3 + i-1); + if (IN_SCR_FIELD(sx, sy)) + DrawGraphic(sx, sy, graphic + phase*3 + i-1); } else { if (Feld[xx][yy] == EL_BURNING) Feld[xx][yy] = EL_LEERRAUM; - DrawLevelField(xx,yy); + DrawLevelField(xx, yy); } } } @@ -1823,45 +1877,45 @@ void StartMoving(int x, int y) return; } - if (element==EL_KAEFER || element==EL_BUTTERFLY) + if (element == EL_KAEFER || element == EL_BUTTERFLY) { - PlaySoundLevel(x,y,SND_KLAPPER); + PlaySoundLevel(x, y, SND_KLAPPER); } - else if (element==EL_FLIEGER || element==EL_FIREFLY) + else if (element == EL_FLIEGER || element == EL_FIREFLY) { - PlaySoundLevel(x,y,SND_ROEHR); + PlaySoundLevel(x, y, SND_ROEHR); } /* neuer Schritt / Wartezustand beendet */ - Moving2Blocked(x,y,&newx,&newy); /* wohin soll's gehen? */ + Moving2Blocked(x, y, &newx, &newy); /* wohin soll's gehen? */ - if (IS_ENEMY(element) && IS_PLAYER(newx,newy)) + if (IS_ENEMY(element) && IS_PLAYER(newx, newy)) { /* Spieler erwischt */ MovDir[x][y] = 0; - KillHero(PLAYERINFO(newx,newy)); + KillHero(PLAYERINFO(newx, newy)); return; } else if ((element == EL_MAULWURF || element == EL_PINGUIN || - element==EL_ROBOT || element==EL_SONDE) && - IN_LEV_FIELD(newx,newy) && - MovDir[x][y]==MV_DOWN && Feld[newx][newy]==EL_SALZSAEURE) + element == EL_ROBOT || element == EL_SONDE) && + IN_LEV_FIELD(newx, newy) && + MovDir[x][y] == MV_DOWN && Feld[newx][newy] == EL_SALZSAEURE) { - Blurb(x,y); + Blurb(x, y); Store[x][y] = EL_SALZSAEURE; } else if ((element == EL_MAULWURF || element == EL_PINGUIN) && - IN_LEV_FIELD(newx,newy)) + IN_LEV_FIELD(newx, newy)) { if (Feld[newx][newy] == EL_AUSGANG_AUF) { Feld[x][y] = EL_LEERRAUM; - DrawLevelField(x,y); + DrawLevelField(x, y); - PlaySoundLevel(newx,newy,SND_BUING); - if (IN_SCR_FIELD(SCREENX(newx),SCREENY(newy))) - DrawGraphicThruMask(SCREENX(newx),SCREENY(newy),el2gfx(element)); + PlaySoundLevel(newx, newy, SND_BUING); + if (IN_SCR_FIELD(SCREENX(newx), SCREENY(newy))) + DrawGraphicThruMask(SCREENX(newx), SCREENY(newy), el2gfx(element)); local_player->friends_still_needed--; if (!local_player->friends_still_needed && @@ -1872,49 +1926,49 @@ void StartMoving(int x, int y) } else if (IS_MAMPF3(Feld[newx][newy])) { - if (DigField(local_player, newx,newy, 0,0, DF_DIG) == MF_MOVING) - DrawLevelField(newx,newy); + if (DigField(local_player, newx, newy, 0, 0, DF_DIG) == MF_MOVING) + DrawLevelField(newx, newy); else MovDir[x][y] = MV_NO_MOVING; } - else if (!IS_FREE(newx,newy)) + else if (!IS_FREE(newx, newy)) { - if (IS_PLAYER(x,y)) - DrawPlayerField(x,y); + if (IS_PLAYER(x, y)) + DrawPlayerField(x, y); else - DrawLevelField(x,y); + DrawLevelField(x, y); return; } } - else if (element == EL_SCHWEIN && IN_LEV_FIELD(newx,newy)) + else if (element == EL_SCHWEIN && IN_LEV_FIELD(newx, newy)) { if (IS_GEM(Feld[newx][newy])) { - if (IS_MOVING(newx,newy)) - RemoveMovingField(newx,newy); + if (IS_MOVING(newx, newy)) + RemoveMovingField(newx, newy); else { Feld[newx][newy] = EL_LEERRAUM; - DrawLevelField(newx,newy); + DrawLevelField(newx, newy); } } - else if (!IS_FREE(newx,newy)) + else if (!IS_FREE(newx, newy)) { - if (IS_PLAYER(x,y)) - DrawPlayerField(x,y); + if (IS_PLAYER(x, y)) + DrawPlayerField(x, y); else - DrawLevelField(x,y); + DrawLevelField(x, y); return; } } - else if (element==EL_DRACHE && IN_LEV_FIELD(newx,newy)) + else if (element == EL_DRACHE && IN_LEV_FIELD(newx, newy)) { - if (!IS_FREE(newx,newy)) + if (!IS_FREE(newx, newy)) { - if (IS_PLAYER(x,y)) - DrawPlayerField(x,y); + if (IS_PLAYER(x, y)) + DrawPlayerField(x, y); else - DrawLevelField(x,y); + DrawLevelField(x, y); return; } else @@ -1923,111 +1977,113 @@ void StartMoving(int x, int y) int dx = newx - x, dy = newy - y; int newx1 = newx+1*dx, newy1 = newy+1*dy; int newx2 = newx+2*dx, newy2 = newy+2*dy; - int element1 = (IN_LEV_FIELD(newx1,newy1) ? - MovingOrBlocked2Element(newx1,newy1) : EL_BETON); - int element2 = (IN_LEV_FIELD(newx2,newy2) ? - MovingOrBlocked2Element(newx2,newy2) : EL_BETON); + int element1 = (IN_LEV_FIELD(newx1, newy1) ? + MovingOrBlocked2Element(newx1, newy1) : EL_BETON); + int element2 = (IN_LEV_FIELD(newx2, newy2) ? + MovingOrBlocked2Element(newx2, newy2) : EL_BETON); if ((wanna_flame || IS_ENEMY(element1) || IS_ENEMY(element2)) && element1 != EL_DRACHE && element2 != EL_DRACHE && element1 != EL_BURNING && element2 != EL_BURNING) { - if (IS_PLAYER(x,y)) - DrawPlayerField(x,y); + if (IS_PLAYER(x, y)) + DrawPlayerField(x, y); else - DrawLevelField(x,y); + DrawLevelField(x, y); MovDelay[x][y] = 50; Feld[newx][newy] = EL_BURNING; - if (IN_LEV_FIELD(newx1,newy1) && Feld[newx1][newy1] == EL_LEERRAUM) + if (IN_LEV_FIELD(newx1, newy1) && Feld[newx1][newy1] == EL_LEERRAUM) Feld[newx1][newy1] = EL_BURNING; - if (IN_LEV_FIELD(newx2,newy2) && Feld[newx2][newy2] == EL_LEERRAUM) + if (IN_LEV_FIELD(newx2, newy2) && Feld[newx2][newy2] == EL_LEERRAUM) Feld[newx2][newy2] = EL_BURNING; return; } } } - else if (element==EL_MAMPFER && IN_LEV_FIELD(newx,newy) && - Feld[newx][newy]==EL_DIAMANT) + else if (element == EL_MAMPFER && IN_LEV_FIELD(newx, newy) && + Feld[newx][newy] == EL_DIAMANT) { - if (IS_MOVING(newx,newy)) - RemoveMovingField(newx,newy); + if (IS_MOVING(newx, newy)) + RemoveMovingField(newx, newy); else { Feld[newx][newy] = EL_LEERRAUM; - DrawLevelField(newx,newy); + DrawLevelField(newx, newy); } } - else if (element==EL_MAMPFER2 && IN_LEV_FIELD(newx,newy) && + else if (element == EL_MAMPFER2 && IN_LEV_FIELD(newx, newy) && IS_MAMPF2(Feld[newx][newy])) { if (AmoebaNr[newx][newy]) { AmoebaCnt2[AmoebaNr[newx][newy]]--; - if (Feld[newx][newy]==EL_AMOEBE_VOLL || Feld[newx][newy]==EL_AMOEBE_BD) + if (Feld[newx][newy] == EL_AMOEBE_VOLL || + Feld[newx][newy] == EL_AMOEBE_BD) AmoebaCnt[AmoebaNr[newx][newy]]--; } - if (IS_MOVING(newx,newy)) - RemoveMovingField(newx,newy); + if (IS_MOVING(newx, newy)) + RemoveMovingField(newx, newy); else { Feld[newx][newy] = EL_LEERRAUM; - DrawLevelField(newx,newy); + DrawLevelField(newx, newy); } } - else if (element==EL_PACMAN && IN_LEV_FIELD(newx,newy) && + else if (element == EL_PACMAN && IN_LEV_FIELD(newx, newy) && IS_AMOEBOID(Feld[newx][newy])) { if (AmoebaNr[newx][newy]) { AmoebaCnt2[AmoebaNr[newx][newy]]--; - if (Feld[newx][newy]==EL_AMOEBE_VOLL || Feld[newx][newy]==EL_AMOEBE_BD) + if (Feld[newx][newy] == EL_AMOEBE_VOLL || + Feld[newx][newy] == EL_AMOEBE_BD) AmoebaCnt[AmoebaNr[newx][newy]]--; } Feld[newx][newy] = EL_LEERRAUM; - DrawLevelField(newx,newy); + DrawLevelField(newx, newy); } - else if (!IN_LEV_FIELD(newx,newy) || !IS_FREE(newx,newy)) + else if (!IN_LEV_FIELD(newx, newy) || !IS_FREE(newx, newy)) { /* gegen Wand gelaufen */ - TurnRound(x,y); + TurnRound(x, y); if (element == EL_KAEFER || element == EL_FLIEGER) - DrawLevelField(x,y); + DrawLevelField(x, y); else if (element == EL_BUTTERFLY || element == EL_FIREFLY) - DrawGraphicAnimation(x,y, el2gfx(element), 2, 4, ANIM_NORMAL); - else if (element==EL_SONDE) - DrawGraphicAnimation(x,y, GFX_SONDE_START, 8, 2, ANIM_NORMAL); + DrawGraphicAnimation(x, y, el2gfx(element), 2, 4, ANIM_NORMAL); + else if (element == EL_SONDE) + DrawGraphicAnimation(x, y, GFX_SONDE_START, 8, 2, ANIM_NORMAL); return; } - if (element==EL_ROBOT && IN_SCR_FIELD(x,y)) - PlaySoundLevel(x,y,SND_SCHLURF); + if (element == EL_ROBOT && IN_SCR_FIELD(x, y)) + PlaySoundLevel(x, y, SND_SCHLURF); - InitMovingField(x,y,MovDir[x][y]); + InitMovingField(x, y, MovDir[x][y]); } if (MovDir[x][y]) - ContinueMoving(x,y); + ContinueMoving(x, y); } void ContinueMoving(int x, int y) { int element = Feld[x][y]; int direction = MovDir[x][y]; - int dx = (direction==MV_LEFT ? -1 : direction==MV_RIGHT ? +1 : 0); - int dy = (direction==MV_UP ? -1 : direction==MV_DOWN ? +1 : 0); + int dx = (direction == MV_LEFT ? -1 : direction == MV_RIGHT ? +1 : 0); + int dy = (direction == MV_UP ? -1 : direction == MV_DOWN ? +1 : 0); int horiz_move = (dx!=0); int newx = x + dx, newy = y + dy; int step = (horiz_move ? dx : dy) * TILEX/8; if (CAN_FALL(element) && horiz_move) step*=2; - else if (element==EL_TROPFEN) + else if (element == EL_TROPFEN) step/=2; - else if (Store[x][y]==EL_MORAST_VOLL || Store[x][y]==EL_MORAST_LEER) + else if (Store[x][y] == EL_MORAST_VOLL || Store[x][y] == EL_MORAST_LEER) step/=4; MovPos[x][y] += step; @@ -2037,44 +2093,44 @@ void ContinueMoving(int x, int y) Feld[x][y] = EL_LEERRAUM; Feld[newx][newy] = element; - if (Store[x][y]==EL_MORAST_VOLL) + if (Store[x][y] == EL_MORAST_VOLL) { Store[x][y] = 0; Feld[newx][newy] = EL_MORAST_VOLL; element = EL_MORAST_VOLL; } - else if (Store[x][y]==EL_MORAST_LEER) + else if (Store[x][y] == EL_MORAST_LEER) { Store[x][y] = 0; Feld[x][y] = EL_MORAST_LEER; } - else if (Store[x][y]==EL_SIEB_VOLL) + else if (Store[x][y] == EL_SIEB_VOLL) { Store[x][y] = 0; element = Feld[newx][newy] = (SiebAktiv ? EL_SIEB_VOLL : EL_SIEB_TOT); } - else if (Store[x][y]==EL_SIEB_LEER) + else if (Store[x][y] == EL_SIEB_LEER) { Store[x][y] = Store2[x][y] = 0; Feld[x][y] = (SiebAktiv ? EL_SIEB_LEER : EL_SIEB_TOT); } - else if (Store[x][y]==EL_SIEB2_VOLL) + else if (Store[x][y] == EL_SIEB2_VOLL) { Store[x][y] = 0; element = Feld[newx][newy] = (SiebAktiv ? EL_SIEB2_VOLL : EL_SIEB2_TOT); } - else if (Store[x][y]==EL_SIEB2_LEER) + else if (Store[x][y] == EL_SIEB2_LEER) { Store[x][y] = Store2[x][y] = 0; Feld[x][y] = (SiebAktiv ? EL_SIEB2_LEER : EL_SIEB2_TOT); } - else if (Store[x][y]==EL_SALZSAEURE) + else if (Store[x][y] == EL_SALZSAEURE) { Store[x][y] = 0; Feld[newx][newy] = EL_SALZSAEURE; element = EL_SALZSAEURE; } - else if (Store[x][y]==EL_AMOEBE_NASS) + else if (Store[x][y] == EL_AMOEBE_NASS) { Store[x][y] = 0; Feld[x][y] = EL_AMOEBE_NASS; @@ -2086,27 +2142,27 @@ void ContinueMoving(int x, int y) if (!CAN_MOVE(element)) MovDir[newx][newy] = 0; - DrawLevelField(x,y); - DrawLevelField(newx,newy); + DrawLevelField(x, y); + DrawLevelField(newx, newy); Stop[newx][newy] = TRUE; JustHit[x][newy] = 3; if (DONT_TOUCH(element)) /* Käfer oder Flieger */ { - TestIfBadThingHitsHero(newx,newy); - TestIfBadThingHitsFriend(newx,newy); - TestIfBadThingHitsOtherBadThing(newx,newy); + TestIfBadThingHitsHero(newx, newy); + TestIfBadThingHitsFriend(newx, newy); + TestIfBadThingHitsOtherBadThing(newx, newy); } else if (element == EL_PINGUIN) - TestIfFriendHitsBadThing(newx,newy); + TestIfFriendHitsBadThing(newx, newy); - if (CAN_SMASH(element) && direction==MV_DOWN && - (newy==lev_fieldy-1 || !IS_FREE(x,newy+1))) - Impact(x,newy); + if (CAN_SMASH(element) && direction == MV_DOWN && + (newy == lev_fieldy-1 || !IS_FREE(x, newy+1))) + Impact(x, newy); } else /* noch in Bewegung */ - DrawLevelField(x,y); + DrawLevelField(x, y); } int AmoebeNachbarNr(int ax, int ay) @@ -2116,53 +2172,53 @@ int AmoebeNachbarNr(int ax, int ay) int group_nr = 0; static int xy[4][2] = { - { 0,-1 }, - { -1,0 }, - { +1,0 }, - { 0,+1 } + { 0, -1 }, + { -1, 0 }, + { +1, 0 }, + { 0, +1 } }; - for(i=0;i<4;i++) + for (i=0; i<4; i++) { int x = ax+xy[i%4][0]; int y = ay+xy[i%4][1]; - if (!IN_LEV_FIELD(x,y)) + 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]; } - return(group_nr); + return group_nr; } void AmoebenVereinigen(int ax, int ay) { - int i,x,y,xx,yy; + int i, x, y, xx, yy; int new_group_nr = AmoebaNr[ax][ay]; static int xy[4][2] = { - { 0,-1 }, - { -1,0 }, - { +1,0 }, - { 0,+1 } + { 0, -1 }, + { -1, 0 }, + { +1, 0 }, + { 0, +1 } }; if (!new_group_nr) return; - for(i=0;i<4;i++) + for (i=0; i<4; i++) { x = ax+xy[i%4][0]; y = ay+xy[i%4][1]; - if (!IN_LEV_FIELD(x,y)) + if (!IN_LEV_FIELD(x, y)) continue; - if ((Feld[x][y]==EL_AMOEBE_VOLL || - Feld[x][y]==EL_AMOEBE_BD || - Feld[x][y]==EL_AMOEBE_TOT) && + if ((Feld[x][y] == EL_AMOEBE_VOLL || + Feld[x][y] == EL_AMOEBE_BD || + Feld[x][y] == EL_AMOEBE_TOT) && AmoebaNr[x][y] != new_group_nr) { int old_group_nr = AmoebaNr[x][y]; @@ -2172,8 +2228,8 @@ void AmoebenVereinigen(int ax, int ay) AmoebaCnt2[new_group_nr] += AmoebaCnt2[old_group_nr]; AmoebaCnt2[old_group_nr] = 0; - for(yy=0;yy= 200 && element==EL_AMOEBE_BD) + if (AmoebaCnt2[new_group_nr] >= 200 && element == EL_AMOEBE_BD) { - AmoebeUmwandeln2(newax,neway,EL_FELSBROCKEN); + AmoebeUmwandeln2(newax, neway, EL_FELSBROCKEN); return; } } } - if (element!=EL_AMOEBE_NASS || newaylife[1]) { Feld[xx][yy] = EL_LEERRAUM; if (!Stop[xx][yy]) - DrawLevelField(xx,yy); + DrawLevelField(xx, yy); Stop[xx][yy] = TRUE; } } - else if (IS_FREE(xx,yy) || Feld[xx][yy]==EL_ERDREICH) + else if (IS_FREE(xx, yy) || Feld[xx][yy] == EL_ERDREICH) { /* Randfeld ohne Amoebe */ if (nachbarn>=life[2] && nachbarn<=life[3]) { Feld[xx][yy] = element; - MovDelay[xx][yy] = (element==EL_LIFE ? 0 : life_time-1); + MovDelay[xx][yy] = (element == EL_LIFE ? 0 : life_time-1); if (!Stop[xx][yy]) - DrawLevelField(xx,yy); + DrawLevelField(xx, yy); Stop[xx][yy] = TRUE; } } @@ -2478,17 +2536,17 @@ void Ablenk(int x, int y) MovDelay[x][y]--; if (MovDelay[x][y]) { - if (IN_SCR_FIELD(SCREENX(x),SCREENY(y))) - DrawGraphic(SCREENX(x),SCREENY(y),GFX_ABLENK+MovDelay[x][y]%4); + if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + DrawGraphic(SCREENX(x), SCREENY(y), GFX_ABLENK+MovDelay[x][y]%4); if (!(MovDelay[x][y]%4)) - PlaySoundLevel(x,y,SND_MIEP); + PlaySoundLevel(x, y, SND_MIEP); return; } } Feld[x][y] = EL_ABLENK_AUS; - DrawLevelField(x,y); - if (ZX==x && ZY==y) + DrawLevelField(x, y); + if (ZX == x && ZY == y) ZX = ZY = -1; } @@ -2508,7 +2566,7 @@ void Birne(int x, int y) Feld[x][y]=EL_ABLENK_EIN; else Feld[x][y]=EL_ABLENK_AUS; - DrawLevelField(x,y); + DrawLevelField(x, y); Feld[x][y]=EL_ABLENK_EIN; } return; @@ -2516,17 +2574,17 @@ void Birne(int x, int y) } Feld[x][y]=EL_ABLENK_AUS; - DrawLevelField(x,y); - if (ZX==x && ZY==y) + DrawLevelField(x, y); + if (ZX == x && ZY == y) ZX=ZY=-1; } void Blubber(int x, int y) { - if (y > 0 && IS_MOVING(x,y-1) && MovDir[x][y-1] == MV_DOWN) - DrawLevelField(x,y-1); + if (y > 0 && IS_MOVING(x, y-1) && MovDir[x][y-1] == MV_DOWN) + DrawLevelField(x, y-1); else - DrawGraphicAnimation(x,y, GFX_GEBLUBBER, 4, 10, ANIM_NORMAL); + DrawGraphicAnimation(x, y, GFX_GEBLUBBER, 4, 10, ANIM_NORMAL); } void NussKnacken(int x, int y) @@ -2537,22 +2595,23 @@ void NussKnacken(int x, int y) if (MovDelay[x][y]) /* neue Phase / in Wartezustand */ { MovDelay[x][y]--; - if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x),SCREENY(y))) - DrawGraphic(SCREENX(x),SCREENY(y),GFX_CRACKINGNUT+3-MovDelay[x][y]/2); + if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + DrawGraphic(SCREENX(x), SCREENY(y), GFX_CRACKINGNUT+3-MovDelay[x][y]/2); if (!MovDelay[x][y]) { Feld[x][y] = EL_EDELSTEIN; - DrawLevelField(x,y); + DrawLevelField(x, y); } } } void SiebAktivieren(int x, int y, int typ) { - if (!(SiebAktiv % 4) && IN_SCR_FIELD(SCREENX(x),SCREENY(y))) - DrawGraphic(SCREENX(x),SCREENY(y), - (typ==1 ? GFX_SIEB_VOLL : GFX_SIEB2_VOLL)+3-(SiebAktiv%16)/4); + if (!(SiebAktiv % 4) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + DrawGraphic(SCREENX(x), SCREENY(y), + (typ == 1 ? GFX_SIEB_VOLL : + GFX_SIEB2_VOLL) + 3 - (SiebAktiv % 16) / 4); } void AusgangstuerPruefen(int x, int y) @@ -2584,29 +2643,29 @@ void AusgangstuerOeffnen(int x, int y) MovDelay[x][y]--; tuer = MovDelay[x][y]/delay; - if (!(MovDelay[x][y]%delay) && IN_SCR_FIELD(SCREENX(x),SCREENY(y))) - DrawGraphic(SCREENX(x),SCREENY(y),GFX_AUSGANG_AUF-tuer); + if (!(MovDelay[x][y]%delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + DrawGraphic(SCREENX(x), SCREENY(y), GFX_AUSGANG_AUF-tuer); if (!MovDelay[x][y]) { Feld[x][y] = EL_AUSGANG_AUF; - DrawLevelField(x,y); + DrawLevelField(x, y); } } } void AusgangstuerBlinken(int x, int y) { - DrawGraphicAnimation(x,y, GFX_AUSGANG_AUF, 4, 4, ANIM_OSCILLATE); + DrawGraphicAnimation(x, y, GFX_AUSGANG_AUF, 4, 4, ANIM_OSCILLATE); } void EdelsteinFunkeln(int x, int y) { - if (!IN_SCR_FIELD(SCREENX(x),SCREENY(y)) || IS_MOVING(x,y)) + if (!IN_SCR_FIELD(SCREENX(x), SCREENY(y)) || IS_MOVING(x, y)) return; if (Feld[x][y] == EL_EDELSTEIN_BD) - DrawGraphicAnimation(x,y, GFX_EDELSTEIN_BD, 4, 4, ANIM_REVERSE); + DrawGraphicAnimation(x, y, GFX_EDELSTEIN_BD, 4, 4, ANIM_REVERSE); else { if (!MovDelay[x][y]) /* neue Phase / noch nicht gewartet */ @@ -2619,7 +2678,7 @@ void EdelsteinFunkeln(int x, int y) if (setup.direct_draw && MovDelay[x][y]) SetDrawtoField(DRAW_BUFFERED); - DrawGraphic(SCREENX(x),SCREENY(y), el2gfx(Feld[x][y])); + DrawGraphic(SCREENX(x), SCREENY(y), el2gfx(Feld[x][y])); if (MovDelay[x][y]) { @@ -2628,17 +2687,17 @@ void EdelsteinFunkeln(int x, int y) if (phase > 2) phase = 4-phase; - DrawGraphicThruMask(SCREENX(x),SCREENY(y), GFX_FUNKELN_WEISS + phase); + DrawGraphicThruMask(SCREENX(x), SCREENY(y), GFX_FUNKELN_WEISS + phase); if (setup.direct_draw) { - int dest_x,dest_y; + int dest_x, dest_y; dest_x = FX + SCREENX(x)*TILEX; dest_y = FY + SCREENY(y)*TILEY; - XCopyArea(display,drawto_field,window,gc, - dest_x,dest_y, TILEX,TILEY, dest_x,dest_y); + XCopyArea(display, drawto_field, window, gc, + dest_x, dest_y, TILEX, TILEY, dest_x, dest_y); SetDrawtoField(DRAW_DIRECT); } } @@ -2659,8 +2718,8 @@ void MauerWaechst(int x, int y) MovDelay[x][y]--; phase = 2-MovDelay[x][y]/delay; - if (!(MovDelay[x][y]%delay) && IN_SCR_FIELD(SCREENX(x),SCREENY(y))) - DrawGraphic(SCREENX(x),SCREENY(y), + if (!(MovDelay[x][y]%delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + DrawGraphic(SCREENX(x), SCREENY(y), (MovDir[x][y] == MV_LEFT ? GFX_MAUER_LEFT : MovDir[x][y] == MV_RIGHT ? GFX_MAUER_RIGHT : MovDir[x][y] == MV_UP ? GFX_MAUER_UP : @@ -2670,29 +2729,29 @@ void MauerWaechst(int x, int y) { if (MovDir[x][y] == MV_LEFT) { - if (IN_LEV_FIELD(x-1,y) && IS_MAUER(Feld[x-1][y])) - DrawLevelField(x-1,y); + if (IN_LEV_FIELD(x-1, y) && IS_MAUER(Feld[x-1][y])) + DrawLevelField(x-1, y); } else if (MovDir[x][y] == MV_RIGHT) { - if (IN_LEV_FIELD(x+1,y) && IS_MAUER(Feld[x+1][y])) - DrawLevelField(x+1,y); + if (IN_LEV_FIELD(x+1, y) && IS_MAUER(Feld[x+1][y])) + DrawLevelField(x+1, y); } else if (MovDir[x][y] == MV_UP) { - if (IN_LEV_FIELD(x,y-1) && IS_MAUER(Feld[x][y-1])) - DrawLevelField(x,y-1); + if (IN_LEV_FIELD(x, y-1) && IS_MAUER(Feld[x][y-1])) + DrawLevelField(x, y-1); } else { - if (IN_LEV_FIELD(x,y+1) && IS_MAUER(Feld[x][y+1])) - DrawLevelField(x,y+1); + if (IN_LEV_FIELD(x, y+1) && IS_MAUER(Feld[x][y+1])) + DrawLevelField(x, y+1); } Feld[x][y] = Store[x][y]; Store[x][y] = 0; MovDir[x][y] = MV_NO_MOVING; - DrawLevelField(x,y); + DrawLevelField(x, y); } } } @@ -2715,13 +2774,13 @@ void MauerAbleger(int ax, int ay) return; } - if (IN_LEV_FIELD(ax,ay-1) && IS_FREE(ax,ay-1)) + if (IN_LEV_FIELD(ax, ay-1) && IS_FREE(ax, ay-1)) oben_frei = TRUE; - if (IN_LEV_FIELD(ax,ay+1) && IS_FREE(ax,ay+1)) + if (IN_LEV_FIELD(ax, ay+1) && IS_FREE(ax, ay+1)) unten_frei = TRUE; - if (IN_LEV_FIELD(ax-1,ay) && IS_FREE(ax-1,ay)) + if (IN_LEV_FIELD(ax-1, ay) && IS_FREE(ax-1, ay)) links_frei = TRUE; - if (IN_LEV_FIELD(ax+1,ay) && IS_FREE(ax+1,ay)) + if (IN_LEV_FIELD(ax+1, ay) && IS_FREE(ax+1, ay)) rechts_frei = TRUE; if (element == EL_MAUER_Y || element == EL_MAUER_XY) @@ -2731,16 +2790,16 @@ void MauerAbleger(int ax, int ay) Feld[ax][ay-1] = EL_MAUERND; Store[ax][ay-1] = element; MovDir[ax][ay-1] = MV_UP; - if (IN_SCR_FIELD(SCREENX(ax),SCREENY(ay-1))) - DrawGraphic(SCREENX(ax),SCREENY(ay-1),GFX_MAUER_UP); + if (IN_SCR_FIELD(SCREENX(ax), SCREENY(ay-1))) + DrawGraphic(SCREENX(ax), SCREENY(ay-1), GFX_MAUER_UP); } if (unten_frei) { Feld[ax][ay+1] = EL_MAUERND; Store[ax][ay+1] = element; MovDir[ax][ay+1] = MV_DOWN; - if (IN_SCR_FIELD(SCREENX(ax),SCREENY(ay+1))) - DrawGraphic(SCREENX(ax),SCREENY(ay+1),GFX_MAUER_DOWN); + if (IN_SCR_FIELD(SCREENX(ax), SCREENY(ay+1))) + DrawGraphic(SCREENX(ax), SCREENY(ay+1), GFX_MAUER_DOWN); } } @@ -2752,29 +2811,29 @@ void MauerAbleger(int ax, int ay) Feld[ax-1][ay] = EL_MAUERND; Store[ax-1][ay] = element; MovDir[ax-1][ay] = MV_LEFT; - if (IN_SCR_FIELD(SCREENX(ax-1),SCREENY(ay))) - DrawGraphic(SCREENX(ax-1),SCREENY(ay),GFX_MAUER_LEFT); + if (IN_SCR_FIELD(SCREENX(ax-1), SCREENY(ay))) + DrawGraphic(SCREENX(ax-1), SCREENY(ay), GFX_MAUER_LEFT); } if (rechts_frei) { Feld[ax+1][ay] = EL_MAUERND; Store[ax+1][ay] = element; MovDir[ax+1][ay] = MV_RIGHT; - if (IN_SCR_FIELD(SCREENX(ax+1),SCREENY(ay))) - DrawGraphic(SCREENX(ax+1),SCREENY(ay),GFX_MAUER_RIGHT); + if (IN_SCR_FIELD(SCREENX(ax+1), SCREENY(ay))) + DrawGraphic(SCREENX(ax+1), SCREENY(ay), GFX_MAUER_RIGHT); } } if (element == EL_MAUER_LEBT && (links_frei || rechts_frei)) - DrawLevelField(ax,ay); + DrawLevelField(ax, ay); - if (!IN_LEV_FIELD(ax,ay-1) || IS_MAUER(Feld[ax][ay-1])) + if (!IN_LEV_FIELD(ax, ay-1) || IS_MAUER(Feld[ax][ay-1])) oben_massiv = TRUE; - if (!IN_LEV_FIELD(ax,ay+1) || IS_MAUER(Feld[ax][ay+1])) + if (!IN_LEV_FIELD(ax, ay+1) || IS_MAUER(Feld[ax][ay+1])) unten_massiv = TRUE; - if (!IN_LEV_FIELD(ax-1,ay) || IS_MAUER(Feld[ax-1][ay])) + if (!IN_LEV_FIELD(ax-1, ay) || IS_MAUER(Feld[ax-1][ay])) links_massiv = TRUE; - if (!IN_LEV_FIELD(ax+1,ay) || IS_MAUER(Feld[ax+1][ay])) + if (!IN_LEV_FIELD(ax+1, ay) || IS_MAUER(Feld[ax+1][ay])) rechts_massiv = TRUE; if (((oben_massiv && unten_massiv) || @@ -2786,23 +2845,23 @@ void MauerAbleger(int ax, int ay) void CheckForDragon(int x, int y) { - int i,j; + int i, j; boolean dragon_found = FALSE; static int xy[4][2] = { - { 0,-1 }, - { -1,0 }, - { +1,0 }, - { 0,+1 } + { 0, -1 }, + { -1, 0 }, + { +1, 0 }, + { 0, +1 } }; - for(i=0;i<4;i++) + for (i=0; i<4; i++) { - for(j=0;j<4;j++) + for (j=0; j<4; j++) { int xx = x + j*xy[i][0], yy = y + j*xy[i][1]; - if (IN_LEV_FIELD(xx,yy) && + if (IN_LEV_FIELD(xx, yy) && (Feld[xx][yy] == EL_BURNING || Feld[xx][yy] == EL_DRACHE)) { if (Feld[xx][yy] == EL_DRACHE) @@ -2815,16 +2874,16 @@ void CheckForDragon(int x, int y) if (!dragon_found) { - for(i=0;i<4;i++) + for (i=0; i<4; i++) { - for(j=0;j<3;j++) + for (j=0; j<3; j++) { int xx = x + j*xy[i][0], yy = y + j*xy[i][1]; - if (IN_LEV_FIELD(xx,yy) && Feld[xx][yy] == EL_BURNING) + if (IN_LEV_FIELD(xx, yy) && Feld[xx][yy] == EL_BURNING) { Feld[xx][yy] = EL_LEERRAUM; - DrawLevelField(xx,yy); + DrawLevelField(xx, yy); } else break; @@ -2861,12 +2920,12 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) player->frame_reset_delay = 0; if (button1) - snapped = SnapField(player, dx,dy); + snapped = SnapField(player, dx, dy); else { if (button2) bombed = PlaceBomb(player); - moved = MoveFigure(player, dx,dy); + moved = MoveFigure(player, dx, dy); } if (tape.recording && (moved || snapped || bombed)) @@ -2887,12 +2946,12 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) } else if (tape.playing && snapped) - SnapField(player, 0,0); /* stop snapping */ + SnapField(player, 0, 0); /* stop snapping */ } else { - DigField(player, 0,0, 0,0, DF_NO_PUSH); - SnapField(player, 0,0); + DigField(player, 0, 0, 0, 0, DF_NO_PUSH); + SnapField(player, 0, 0); if (++player->frame_reset_delay > MoveSpeed) player->Frame = 0; } @@ -2915,10 +2974,10 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) { int dx = (next_joy == JOY_LEFT ? -1 : +1); - if (IN_LEV_FIELD(jx+dx,jy) && IS_PUSHABLE(Feld[jx+dx][jy])) + if (IN_LEV_FIELD(jx+dx, jy) && IS_PUSHABLE(Feld[jx+dx][jy])) { int el = Feld[jx+dx][jy]; - int push_delay = (IS_SB_ELEMENT(el) || el==EL_SONDE ? 2 : 10); + int push_delay = (IS_SB_ELEMENT(el) || el == EL_SONDE ? 2 : 10); if (tape.delay_played + push_delay >= tape.pos[tape.counter].delay) { @@ -2936,7 +2995,7 @@ void GameActions() static long action_delay = 0; long action_delay_value; int sieb_x = 0, sieb_y = 0; - int i, x,y, element; + int i, x, y, element; byte *recorded_player_action; byte summarized_player_action = 0; @@ -2992,7 +3051,7 @@ void GameActions() recorded_player_action = (tape.playing ? TapePlayAction() : NULL); - for(i=0; ieffective_action = summarized_player_action; - for(i=0; igone) + { + extern unsigned int last_RND(); + + printf("DEBUG: %03d last RND was %d \t [state checksum is %d]\n", + level.time - TimeLeft, + last_RND(), + getStateCheckSum(level.time - TimeLeft)); + } +#endif + + + +#ifdef DEBUG + if (GameFrameDelay >= 500) + printf("FrameCounter == %d\n", FrameCounter); +#endif + + + + + FrameCounter++; TimeFrames++; - for(y=0;y0) JustHit[x][y]--; #if DEBUG - if (IS_BLOCKED(x,y)) + if (IS_BLOCKED(x, y)) { - int oldx,oldy; + int oldx, oldy; - Blocked2Moving(x,y,&oldx,&oldy); - if (!IS_MOVING(oldx,oldy)) + Blocked2Moving(x, y, &oldx, &oldy); + if (!IS_MOVING(oldx, oldy)) { printf("GameActions(): (BLOCKED=>MOVING) context corrupted!\n"); - printf("GameActions(): BLOCKED: x = %d, y = %d\n",x,y); - printf("GameActions(): !MOVING: oldx = %d, oldy = %d\n",oldx,oldy); + printf("GameActions(): BLOCKED: x = %d, y = %d\n", x, y); + printf("GameActions(): !MOVING: oldx = %d, oldy = %d\n", oldx, oldy); printf("GameActions(): This should never happen!\n"); } } #endif } - for(y=0;yjx, jy = local_player->jy; - if (element==EL_SIEB_LEER || element==EL_SIEB_VOLL || - Store[x][y]==EL_SIEB_LEER) + if (element == EL_SIEB_LEER || element == EL_SIEB_VOLL || + Store[x][y] == EL_SIEB_LEER) { SiebAktivieren(x, y, 1); sieb = TRUE; } - else if (element==EL_SIEB2_LEER || element==EL_SIEB2_VOLL || - Store[x][y]==EL_SIEB2_LEER) + else if (element == EL_SIEB2_LEER || element == EL_SIEB2_VOLL || + Store[x][y] == EL_SIEB2_LEER) { SiebAktivieren(x, y, 2); sieb = TRUE; @@ -3136,22 +3221,22 @@ void GameActions() if (SiebAktiv) { if (!(SiebAktiv%4)) - PlaySoundLevel(sieb_x,sieb_y,SND_MIEP); + PlaySoundLevel(sieb_x, sieb_y, SND_MIEP); SiebAktiv--; if (!SiebAktiv) { - for(y=0;ygone || (!dx && !dy)) - return(MF_NO_ACTION); + return MF_NO_ACTION; player->MovDir = (dx < 0 ? MV_LEFT : dx > 0 ? MV_RIGHT : dy < 0 ? MV_UP : dy > 0 ? MV_DOWN : MV_NO_MOVING); - if (!IN_LEV_FIELD(new_jx,new_jy)) - return(MF_NO_ACTION); + if (!IN_LEV_FIELD(new_jx, new_jy)) + return MF_NO_ACTION; - if (!options.network && !AllPlayersInSight(player, new_jx,new_jy)) - return(MF_NO_ACTION); + if (!options.network && !AllPlayersInSight(player, new_jx, new_jy)) + return MF_NO_ACTION; - element = MovingOrBlocked2Element(new_jx,new_jy); + element = MovingOrBlocked2Element(new_jx, new_jy); if (DONT_GO_TO(element)) { - if (element==EL_SALZSAEURE && dx==0 && dy==1) + if (element == EL_SALZSAEURE && dx == 0 && dy == 1) { - Blurb(jx,jy); + Blurb(jx, jy); Feld[jx][jy] = EL_SPIELFIGUR; - InitMovingField(jx,jy,MV_DOWN); + InitMovingField(jx, jy, MV_DOWN); Store[jx][jy] = EL_SALZSAEURE; - ContinueMoving(jx,jy); + ContinueMoving(jx, jy); BuryHero(player); } else KillHero(player); - return(MF_MOVING); + return MF_MOVING; } - can_move = DigField(player, new_jx,new_jy, real_dx,real_dy, DF_DIG); + can_move = DigField(player, new_jx, new_jy, real_dx, real_dy, DF_DIG); if (can_move != MF_MOVING) - return(can_move); + return can_move; StorePlayer[jx][jy] = 0; player->last_jx = jx; @@ -3303,7 +3388,7 @@ boolean MoveFigureOneStep(struct PlayerInfo *player, ScrollFigure(player, SCROLL_INIT); - return(MF_MOVING); + return MF_MOVING; } boolean MoveFigure(struct PlayerInfo *player, int dx, int dy) @@ -3313,10 +3398,10 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy) int moved = MF_NO_ACTION; if (player->gone || (!dx && !dy)) - return(FALSE); + return FALSE; - if (!FrameReached(&player->move_delay,MoveSpeed) && !tape.playing) - return(FALSE); + if (!FrameReached(&player->move_delay, MoveSpeed) && !tape.playing) + return FALSE; if (player->MovPos) { @@ -3339,13 +3424,13 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy) if (player->last_move_dir & (MV_LEFT | MV_RIGHT)) { - if (!(moved |= MoveFigureOneStep(player, 0,dy, dx,dy))) - moved |= MoveFigureOneStep(player, dx,0, dx,dy); + if (!(moved |= MoveFigureOneStep(player, 0, dy, dx, dy))) + moved |= MoveFigureOneStep(player, dx, 0, dx, dy); } else { - if (!(moved |= MoveFigureOneStep(player, dx,0, dx,dy))) - moved |= MoveFigureOneStep(player, 0,dy, dx,dy); + if (!(moved |= MoveFigureOneStep(player, dx, 0, dx, dy))) + moved |= MoveFigureOneStep(player, 0, dy, dx, dy); } jx = player->jx; @@ -3357,7 +3442,7 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy) int old_scroll_x = scroll_x, old_scroll_y = scroll_y; int offset = (setup.scroll_delay ? 3 : 0); - if (!IN_VIS_FIELD(SCREENX(jx),SCREENY(jy))) + if (!IN_VIS_FIELD(SCREENX(jx), SCREENY(jy))) { /* actual player has left the screen -- scroll in that direction */ if (jx != old_jx) /* player has moved horizontally */ @@ -3432,19 +3517,19 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy) else if (old_jx == jx && old_jy != jy) player->MovDir = (old_jy < jy ? MV_DOWN : MV_UP); - DrawLevelField(jx,jy); /* für "ErdreichAnbroeckeln()" */ + DrawLevelField(jx, jy); /* für "ErdreichAnbroeckeln()" */ player->last_move_dir = player->MovDir; } else player->last_move_dir = MV_NO_MOVING; - TestIfHeroHitsBadThing(jx,jy); + TestIfHeroHitsBadThing(jx, jy); if (player->gone) RemoveHero(player); - return(moved); + return moved; } void ScrollFigure(struct PlayerInfo *player, int mode) @@ -3466,7 +3551,7 @@ void ScrollFigure(struct PlayerInfo *player, int mode) DrawPlayer(player); return; } - else if (!FrameReached(&player->actual_frame_counter,1)) + else if (!FrameReached(&player->actual_frame_counter, 1)) return; player->MovPos += (player->MovPos > 0 ? -1 : 1) * TILEX/8; @@ -3504,7 +3589,7 @@ void ScrollScreen(struct PlayerInfo *player, int mode) ScreenGfxPos = ScrollStepSize * (ScreenMovPos / ScrollStepSize); return; } - else if (!FrameReached(&screen_frame_counter,1)) + else if (!FrameReached(&screen_frame_counter, 1)) return; if (ScreenMovPos) @@ -3522,10 +3607,10 @@ void TestIfGoodThingHitsBadThing(int goodx, int goody) int i, killx = goodx, killy = goody; static int xy[4][2] = { - { 0,-1 }, - { -1,0 }, - { +1,0 }, - { 0,+1 } + { 0, -1 }, + { -1, 0 }, + { +1, 0 }, + { 0, +1 } }; static int harmless[4] = { @@ -3535,13 +3620,13 @@ void TestIfGoodThingHitsBadThing(int goodx, int goody) MV_DOWN }; - for(i=0; i<4; i++) + for (i=0; i<4; i++) { - int x,y, element; + int x, y, element; x = goodx + xy[i][0]; y = goody + xy[i][1]; - if (!IN_LEV_FIELD(x,y)) + if (!IN_LEV_FIELD(x, y)) continue; element = Feld[x][y]; @@ -3559,10 +3644,10 @@ void TestIfGoodThingHitsBadThing(int goodx, int goody) if (killx != goodx || killy != goody) { - if (IS_PLAYER(goodx,goody)) - KillHero(PLAYERINFO(goodx,goody)); + if (IS_PLAYER(goodx, goody)) + KillHero(PLAYERINFO(goodx, goody)); else - Bang(goodx,goody); + Bang(goodx, goody); } } @@ -3571,10 +3656,10 @@ void TestIfBadThingHitsGoodThing(int badx, int bady) int i, killx = badx, killy = bady; static int xy[4][2] = { - { 0,-1 }, - { -1,0 }, - { +1,0 }, - { 0,+1 } + { 0, -1 }, + { -1, 0 }, + { +1, 0 }, + { 0, +1 } }; static int harmless[4] = { @@ -3584,18 +3669,18 @@ void TestIfBadThingHitsGoodThing(int badx, int bady) MV_DOWN }; - for(i=0; i<4; i++) + for (i=0; i<4; i++) { - int x,y, element; + int x, y, element; x = badx + xy[i][0]; y = bady + xy[i][1]; - if (!IN_LEV_FIELD(x,y)) + if (!IN_LEV_FIELD(x, y)) continue; element = Feld[x][y]; - if (IS_PLAYER(x,y)) + if (IS_PLAYER(x, y)) { killx = x; killy = y; @@ -3603,7 +3688,7 @@ void TestIfBadThingHitsGoodThing(int badx, int bady) } else if (element == EL_PINGUIN) { - if (MovDir[x][y] == harmless[i] && IS_MOVING(x,y)) + if (MovDir[x][y] == harmless[i] && IS_MOVING(x, y)) continue; killx = x; @@ -3614,31 +3699,31 @@ void TestIfBadThingHitsGoodThing(int badx, int bady) if (killx != badx || killy != bady) { - if (IS_PLAYER(killx,killy)) - KillHero(PLAYERINFO(killx,killy)); + if (IS_PLAYER(killx, killy)) + KillHero(PLAYERINFO(killx, killy)); else - Bang(killx,killy); + Bang(killx, killy); } } void TestIfHeroHitsBadThing(int x, int y) { - TestIfGoodThingHitsBadThing(x,y); + TestIfGoodThingHitsBadThing(x, y); } void TestIfBadThingHitsHero(int x, int y) { - TestIfBadThingHitsGoodThing(x,y); + TestIfBadThingHitsGoodThing(x, y); } void TestIfFriendHitsBadThing(int x, int y) { - TestIfGoodThingHitsBadThing(x,y); + TestIfGoodThingHitsBadThing(x, y); } void TestIfBadThingHitsFriend(int x, int y) { - TestIfBadThingHitsGoodThing(x,y); + TestIfBadThingHitsGoodThing(x, y); } void TestIfBadThingHitsOtherBadThing(int badx, int bady) @@ -3646,19 +3731,19 @@ void TestIfBadThingHitsOtherBadThing(int badx, int bady) int i, killx = badx, killy = bady; static int xy[4][2] = { - { 0,-1 }, - { -1,0 }, - { +1,0 }, - { 0,+1 } + { 0, -1 }, + { -1, 0 }, + { +1, 0 }, + { 0, +1 } }; - for(i=0; i<4; i++) + for (i=0; i<4; i++) { - int x,y, element; + int x, y, element; x=badx + xy[i][0]; y=bady + xy[i][1]; - if (!IN_LEV_FIELD(x,y)) + if (!IN_LEV_FIELD(x, y)) continue; element = Feld[x][y]; @@ -3672,7 +3757,7 @@ void TestIfBadThingHitsOtherBadThing(int badx, int bady) } if (killx != badx || killy != bady) - Bang(badx,bady); + Bang(badx, bady); } void KillHero(struct PlayerInfo *player) @@ -3685,7 +3770,7 @@ void KillHero(struct PlayerInfo *player) if (IS_PFORTE(Feld[jx][jy])) Feld[jx][jy] = EL_LEERRAUM; - Bang(jx,jy); + Bang(jx, jy); BuryHero(player); } @@ -3696,8 +3781,8 @@ void BuryHero(struct PlayerInfo *player) if (player->gone) return; - PlaySoundLevel(jx,jy, SND_AUTSCH); - PlaySoundLevel(jx,jy, SND_LACHEN); + PlaySoundLevel(jx, jy, SND_AUTSCH); + PlaySoundLevel(jx, jy, SND_LACHEN); player->GameOver = TRUE; RemoveHero(player); @@ -3711,7 +3796,7 @@ void RemoveHero(struct PlayerInfo *player) player->gone = TRUE; StorePlayer[jx][jy] = 0; - for(i=0; ipush_delay = 0; - return(MF_NO_ACTION); + return MF_NO_ACTION; } - if (IS_MOVING(x,y) || IS_PLAYER(x,y)) - return(MF_NO_ACTION); + if (IS_MOVING(x, y) || IS_PLAYER(x, y)) + return MF_NO_ACTION; element = Feld[x][y]; @@ -3758,7 +3843,7 @@ int DigField(struct PlayerInfo *player, case EL_EDELSTEIN_ROT: case EL_EDELSTEIN_LILA: case EL_DIAMANT: - RemoveField(x,y); + RemoveField(x, y); local_player->gems_still_needed -= (element == EL_DIAMANT ? 3 : 1); if (local_player->gems_still_needed < 0) local_player->gems_still_needed = 0; @@ -3770,35 +3855,35 @@ int DigField(struct PlayerInfo *player, break; case EL_DYNAMIT_AUS: - RemoveField(x,y); + RemoveField(x, y); player->dynamite++; RaiseScoreElement(EL_DYNAMIT); DrawText(DX_DYNAMITE, DY_DYNAMITE, int2str(local_player->dynamite, 3), FS_SMALL, FC_YELLOW); - PlaySoundLevel(x,y,SND_PONG); + PlaySoundLevel(x, y, SND_PONG); break; case EL_DYNABOMB_NR: - RemoveField(x,y); + RemoveField(x, y); player->dynabomb_count++; player->dynabombs_left++; RaiseScoreElement(EL_DYNAMIT); - PlaySoundLevel(x,y,SND_PONG); + PlaySoundLevel(x, y, SND_PONG); break; case EL_DYNABOMB_SZ: - RemoveField(x,y); + RemoveField(x, y); player->dynabomb_size++; RaiseScoreElement(EL_DYNAMIT); - PlaySoundLevel(x,y,SND_PONG); + PlaySoundLevel(x, y, SND_PONG); break; case EL_DYNABOMB_XL: - RemoveField(x,y); + RemoveField(x, y); player->dynabomb_xl = TRUE; RaiseScoreElement(EL_DYNAMIT); - PlaySoundLevel(x,y,SND_PONG); + PlaySoundLevel(x, y, SND_PONG); break; case EL_SCHLUESSEL1: @@ -3808,16 +3893,16 @@ int DigField(struct PlayerInfo *player, { int key_nr = element-EL_SCHLUESSEL1; - RemoveField(x,y); + RemoveField(x, y); player->key[key_nr] = TRUE; RaiseScoreElement(EL_SCHLUESSEL); - DrawMiniGraphicExt(drawto,gc, - DX_KEYS+key_nr*MINI_TILEX,DY_KEYS, + DrawMiniGraphicExt(drawto, gc, + DX_KEYS+key_nr*MINI_TILEX, DY_KEYS, GFX_SCHLUESSEL1+key_nr); - DrawMiniGraphicExt(window,gc, - DX_KEYS+key_nr*MINI_TILEX,DY_KEYS, + DrawMiniGraphicExt(window, gc, + DX_KEYS+key_nr*MINI_TILEX, DY_KEYS, GFX_SCHLUESSEL1+key_nr); - PlaySoundLevel(x,y,SND_PONG); + PlaySoundLevel(x, y, SND_PONG); break; } @@ -3825,46 +3910,46 @@ int DigField(struct PlayerInfo *player, Feld[x][y] = EL_ABLENK_EIN; ZX = x; ZY = y; - DrawLevelField(x,y); - return(MF_ACTION); + DrawLevelField(x, y); + return MF_ACTION; break; case EL_FELSBROCKEN: case EL_BOMBE: case EL_KOKOSNUSS: case EL_ZEIT_LEER: - if (dy || mode==DF_SNAP) - return(MF_NO_ACTION); + if (dy || mode == DF_SNAP) + return MF_NO_ACTION; player->Pushing = TRUE; - if (!IN_LEV_FIELD(x+dx,y+dy) || !IS_FREE(x+dx,y+dy)) - return(MF_NO_ACTION); + if (!IN_LEV_FIELD(x+dx, y+dy) || !IS_FREE(x+dx, y+dy)) + return MF_NO_ACTION; if (real_dy) { - if (IN_LEV_FIELD(jx,jy+real_dy) && !IS_SOLID(Feld[jx][jy+real_dy])) - return(MF_NO_ACTION); + if (IN_LEV_FIELD(jx, jy+real_dy) && !IS_SOLID(Feld[jx][jy+real_dy])) + return MF_NO_ACTION; } if (player->push_delay == 0) player->push_delay = FrameCounter; if (!FrameReached(&player->push_delay, player->push_delay_value) && !tape.playing) - return(MF_NO_ACTION); + return MF_NO_ACTION; - RemoveField(x,y); + RemoveField(x, y); Feld[x+dx][y+dy] = element; player->push_delay_value = 2+RND(8); - DrawLevelField(x+dx,y+dy); - if (element==EL_FELSBROCKEN) - PlaySoundLevel(x+dx,y+dy,SND_PUSCH); - else if (element==EL_KOKOSNUSS) - PlaySoundLevel(x+dx,y+dy,SND_KNURK); + DrawLevelField(x+dx, y+dy); + if (element == EL_FELSBROCKEN) + PlaySoundLevel(x+dx, y+dy, SND_PUSCH); + else if (element == EL_KOKOSNUSS) + PlaySoundLevel(x+dx, y+dy, SND_KNURK); else - PlaySoundLevel(x+dx,y+dy,SND_KLOPF); + PlaySoundLevel(x+dx, y+dy, SND_KLOPF); break; case EL_PFORTE1: @@ -3872,7 +3957,7 @@ int DigField(struct PlayerInfo *player, case EL_PFORTE3: case EL_PFORTE4: if (!player->key[element-EL_PFORTE1]) - return(MF_NO_ACTION); + return MF_NO_ACTION; break; case EL_PFORTE1X: @@ -3880,24 +3965,24 @@ int DigField(struct PlayerInfo *player, case EL_PFORTE3X: case EL_PFORTE4X: if (!player->key[element-EL_PFORTE1X]) - return(MF_NO_ACTION); + return MF_NO_ACTION; break; case EL_AUSGANG_ZU: case EL_AUSGANG_ACT: /* Tür ist (noch) nicht offen! */ - return(MF_NO_ACTION); + return MF_NO_ACTION; break; case EL_AUSGANG_AUF: - if (mode==DF_SNAP) - return(MF_NO_ACTION); + if (mode == DF_SNAP) + return MF_NO_ACTION; - PlaySoundLevel(x,y,SND_BUING); + PlaySoundLevel(x, y, SND_BUING); /* player->gone = TRUE; - PlaySoundLevel(x,y,SND_BUING); + PlaySoundLevel(x, y, SND_BUING); if (!local_player->friends_still_needed) player->LevelSolved = player->GameOver = TRUE; @@ -3908,18 +3993,18 @@ int DigField(struct PlayerInfo *player, case EL_BIRNE_AUS: Feld[x][y] = EL_BIRNE_EIN; local_player->lights_still_needed--; - DrawLevelField(x,y); - PlaySoundLevel(x,y,SND_DENG); - return(MF_ACTION); + DrawLevelField(x, y); + PlaySoundLevel(x, y, SND_DENG); + return MF_ACTION; break; case EL_ZEIT_VOLL: Feld[x][y] = EL_ZEIT_LEER; TimeLeft += 10; - DrawText(DX_TIME,DY_TIME,int2str(TimeLeft,3),FS_SMALL,FC_YELLOW); - DrawLevelField(x,y); - PlaySoundStereo(SND_GONG,PSND_MAX_RIGHT); - return(MF_ACTION); + DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); + DrawLevelField(x, y); + PlaySoundStereo(SND_GONG, PSND_MAX_RIGHT); + return MF_ACTION; break; case EL_SOKOBAN_FELD_LEER: @@ -3928,33 +4013,33 @@ int DigField(struct PlayerInfo *player, case EL_SOKOBAN_FELD_VOLL: case EL_SOKOBAN_OBJEKT: case EL_SONDE: - if (mode==DF_SNAP) - return(MF_NO_ACTION); + if (mode == DF_SNAP) + return MF_NO_ACTION; player->Pushing = TRUE; - if (!IN_LEV_FIELD(x+dx,y+dy) - || (!IS_FREE(x+dx,y+dy) + if (!IN_LEV_FIELD(x+dx, y+dy) + || (!IS_FREE(x+dx, y+dy) && (Feld[x+dx][y+dy] != EL_SOKOBAN_FELD_LEER || !IS_SB_ELEMENT(element)))) - return(MF_NO_ACTION); + return MF_NO_ACTION; if (dx && real_dy) { - if (IN_LEV_FIELD(jx,jy+real_dy) && !IS_SOLID(Feld[jx][jy+real_dy])) - return(MF_NO_ACTION); + if (IN_LEV_FIELD(jx, jy+real_dy) && !IS_SOLID(Feld[jx][jy+real_dy])) + return MF_NO_ACTION; } else if (dy && real_dx) { - if (IN_LEV_FIELD(jx+real_dx,jy) && !IS_SOLID(Feld[jx+real_dx][jy])) - return(MF_NO_ACTION); + if (IN_LEV_FIELD(jx+real_dx, jy) && !IS_SOLID(Feld[jx+real_dx][jy])) + return MF_NO_ACTION; } if (player->push_delay == 0) player->push_delay = FrameCounter; if (!FrameReached(&player->push_delay, player->push_delay_value) && !tape.playing) - return(MF_NO_ACTION); + return MF_NO_ACTION; if (IS_SB_ELEMENT(element)) { @@ -3964,36 +4049,36 @@ int DigField(struct PlayerInfo *player, local_player->sokobanfields_still_needed++; } else - RemoveField(x,y); + RemoveField(x, y); if (Feld[x+dx][y+dy] == EL_SOKOBAN_FELD_LEER) { Feld[x+dx][y+dy] = EL_SOKOBAN_FELD_VOLL; local_player->sokobanfields_still_needed--; if (element == EL_SOKOBAN_OBJEKT) - PlaySoundLevel(x,y,SND_DENG); + PlaySoundLevel(x, y, SND_DENG); } else Feld[x+dx][y+dy] = EL_SOKOBAN_OBJEKT; } else { - RemoveField(x,y); + RemoveField(x, y); Feld[x+dx][y+dy] = element; } player->push_delay_value = 2; - DrawLevelField(x,y); - DrawLevelField(x+dx,y+dy); - PlaySoundLevel(x+dx,y+dy,SND_PUSCH); + DrawLevelField(x, y); + DrawLevelField(x+dx, y+dy); + PlaySoundLevel(x+dx, y+dy, SND_PUSCH); if (IS_SB_ELEMENT(element) && local_player->sokobanfields_still_needed == 0 && game_emulation == EMU_SOKOBAN) { player->LevelSolved = player->GameOver = TRUE; - PlaySoundLevel(x,y,SND_BUING); + PlaySoundLevel(x, y, SND_BUING); } break; @@ -4005,13 +4090,13 @@ int DigField(struct PlayerInfo *player, break; default: - return(MF_NO_ACTION); + return MF_NO_ACTION; break; } player->push_delay = 0; - return(MF_MOVING); + return MF_MOVING; } boolean SnapField(struct PlayerInfo *player, int dx, int dy) @@ -4019,34 +4104,34 @@ boolean SnapField(struct PlayerInfo *player, int dx, int dy) int jx = player->jx, jy = player->jy; int x = jx + dx, y = jy + dy; - if (player->gone || !IN_LEV_FIELD(x,y)) - return(FALSE); + if (player->gone || !IN_LEV_FIELD(x, y)) + return FALSE; if (dx && dy) - return(FALSE); + return FALSE; if (!dx && !dy) { player->snapped = FALSE; - return(FALSE); + return FALSE; } if (player->snapped) - return(FALSE); + return FALSE; player->MovDir = (dx < 0 ? MV_LEFT : dx > 0 ? MV_RIGHT : dy < 0 ? MV_UP : dy > 0 ? MV_DOWN : MV_NO_MOVING); - if (!DigField(player, x,y, 0,0, DF_SNAP)) - return(FALSE); + if (!DigField(player, x, y, 0, 0, DF_SNAP)) + return FALSE; player->snapped = TRUE; - DrawLevelField(x,y); + DrawLevelField(x, y); BackToFront(); - return(TRUE); + return TRUE; } boolean PlaceBomb(struct PlayerInfo *player) @@ -4055,13 +4140,14 @@ boolean PlaceBomb(struct PlayerInfo *player) int element; if (player->gone || player->MovPos) - return(FALSE); + return FALSE; element = Feld[jx][jy]; - if ((player->dynamite==0 && player->dynabombs_left==0) || - element==EL_DYNAMIT || element==EL_DYNABOMB || element==EL_EXPLODING) - return(FALSE); + if ((player->dynamite == 0 && player->dynabombs_left == 0) || + element == EL_DYNAMIT || element == EL_DYNABOMB || + element == EL_EXPLODING) + return FALSE; if (element != EL_LEERRAUM) Store[jx][jy] = element; @@ -4073,8 +4159,8 @@ boolean PlaceBomb(struct PlayerInfo *player) player->dynamite--; DrawText(DX_DYNAMITE, DY_DYNAMITE, int2str(local_player->dynamite, 3), FS_SMALL, FC_YELLOW); - if (IN_SCR_FIELD(SCREENX(jx),SCREENY(jy))) - DrawGraphicThruMask(SCREENX(jx),SCREENY(jy),GFX_DYNAMIT); + if (IN_SCR_FIELD(SCREENX(jx), SCREENY(jy))) + DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), GFX_DYNAMIT); } else { @@ -4082,11 +4168,11 @@ boolean PlaceBomb(struct PlayerInfo *player) Store2[jx][jy] = player->element_nr; /* for DynaExplode() */ MovDelay[jx][jy] = 96; player->dynabombs_left--; - if (IN_SCR_FIELD(SCREENX(jx),SCREENY(jy))) - DrawGraphicThruMask(SCREENX(jx),SCREENY(jy),GFX_DYNABOMB); + if (IN_SCR_FIELD(SCREENX(jx), SCREENY(jy))) + DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), GFX_DYNABOMB); } - return(TRUE); + return TRUE; } void PlaySoundLevel(int x, int y, int sound_nr) @@ -4099,7 +4185,7 @@ void PlaySoundLevel(int x, int y, int sound_nr) (!setup.sound_loops && IS_LOOP_SOUND(sound_nr))) return; - if (!IN_LEV_FIELD(x,y) || + if (!IN_LEV_FIELD(x, y) || sx < -silence_distance || sx >= SCR_FIELDX+silence_distance || sy < -silence_distance || sy >= SCR_FIELDY+silence_distance) return; @@ -4114,7 +4200,7 @@ void PlaySoundLevel(int x, int y, int sound_nr) if(stereo < PSND_MAX_LEFT) stereo = PSND_MAX_LEFT; #endif - if (!IN_SCR_FIELD(sx,sy)) + if (!IN_SCR_FIELD(sx, sy)) { int dx = ABS(sx-SCR_FIELDX/2)-SCR_FIELDX/2; int dy = ABS(sy-SCR_FIELDY/2)-SCR_FIELDY/2; diff --git a/src/init.c b/src/init.c index a8039334..5f5419f2 100644 --- a/src/init.c +++ b/src/init.c @@ -318,6 +318,7 @@ void InitWindow(int argc, char *argv[]) int win_xpos = WIN_XPOS, win_ypos = WIN_YPOS; unsigned long pen_fg = WhitePixel(display,screen); unsigned long pen_bg = BlackPixel(display,screen); + const int width = WIN_XSIZE, height = WIN_YSIZE; #ifndef MSDOS static struct IconFileInfo icon_pic = @@ -330,9 +331,6 @@ void InitWindow(int argc, char *argv[]) screen_width = XDisplayWidth(display, screen); screen_height = XDisplayHeight(display, screen); - width = WIN_XSIZE; - height = WIN_YSIZE; - win_xpos = (screen_width - width) / 2; win_ypos = (screen_height - height) / 2; diff --git a/src/main.c b/src/main.c index 6626f701..969947e1 100644 --- a/src/main.c +++ b/src/main.c @@ -50,7 +50,9 @@ char *joystick_device_name[MAX_PLAYERS] = DEV_JOYSTICK_3 }; +/* int width, height; +*/ char *program_name = NULL; diff --git a/src/main.h b/src/main.h index ef8ee9cd..fffe9ab3 100644 --- a/src/main.h +++ b/src/main.h @@ -387,7 +387,10 @@ extern int sound_device; extern char *sound_device_name; extern int joystick_device; extern char *joystick_device_name[]; + +/* extern int width, height; +*/ extern char *program_name; diff --git a/src/misc.c b/src/misc.c index b11c080f..2c01f364 100644 --- a/src/misc.c +++ b/src/misc.c @@ -159,9 +159,22 @@ unsigned int SimpleRND(unsigned int max) return (root % max); } +#ifdef DEBUG +static unsigned int last_RND_value = 0; + +unsigned int last_RND() +{ + return last_RND_value; +} +#endif + unsigned int RND(unsigned int max) { +#ifdef DEBUG + return (last_RND_value = random_linux_libc() % max); +#else return (random_linux_libc() % max); +#endif } unsigned int InitRND(long seed) diff --git a/src/tools.c b/src/tools.c index a2b46c86..b37667c1 100644 --- a/src/tools.c +++ b/src/tools.c @@ -260,22 +260,21 @@ void FadeToFront() void ClearWindow() { - XFillRectangle(display,backbuffer,gc, - REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE); + XFillRectangle(display, backbuffer, gc, + REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE); - if (setup.soft_scrolling && game_status==PLAYING) + if (setup.soft_scrolling && game_status == PLAYING) { - XFillRectangle(display,fieldbuffer,gc, - 0,0, FXSIZE,FYSIZE); + XFillRectangle(display, fieldbuffer, gc, 0, 0, FXSIZE, FYSIZE); SetDrawtoField(DRAW_BUFFERED); } else SetDrawtoField(DRAW_BACKBUFFER); - if (setup.direct_draw && game_status==PLAYING) + if (setup.direct_draw && game_status == PLAYING) { - XFillRectangle(display,window,gc, - REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE); + XFillRectangle(display, window, gc, + REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE); SetDrawtoField(DRAW_DIRECT); } @@ -297,40 +296,38 @@ void DrawTextExt(Drawable d, GC gc, int x, int y, int font_width, font_height, font_start; int font_pixmap; - if (font!=FS_SMALL && font!=FS_BIG) + if (font != FS_SMALL && font != FS_BIG) font = FS_SMALL; - if (font_colorFC_SPECIAL2) + if (font_color < FC_RED || font_color > FC_SPECIAL2) font_color = FC_RED; - font_width = - (font==FS_BIG ? FONT1_XSIZE : - font_color='a' && c<='z') + if (c >= 'a' && c <= 'z') c = 'A' + (c - 'a'); - else if (c=='ä' || c=='Ä') + else if (c == 'ä' || c == 'Ä') c = 91; - else if (c=='ö' || c=='Ö') + else if (c == 'ö' || c == 'Ö') c = 92; - else if (c=='ü' || c=='Ü') + else if (c == 'ü' || c == 'Ü') c = 93; - if (c>=32 && c<=95) - XCopyArea(display,pix[font_pixmap],d,gc, - ((c-32) % FONT_CHARS_PER_LINE)*font_width, - ((c-32) / FONT_CHARS_PER_LINE)*font_height + font_start, - font_width,font_height, x,y); + if (c >= 32 && c <= 95) + XCopyArea(display, pix[font_pixmap], d, gc, + ((c - 32) % FONT_CHARS_PER_LINE) * font_width, + ((c - 32) / FONT_CHARS_PER_LINE) * font_height + font_start, + font_width, font_height, x, y); x += font_width; } @@ -364,7 +361,7 @@ void DrawPlayer(struct PlayerInfo *player) int graphic, phase; if (!player->active || player->gone || - !IN_SCR_FIELD(SCREENX(last_jx),SCREENY(last_jy))) + !IN_SCR_FIELD(SCREENX(last_jx), SCREENY(last_jy))) return; #if DEBUG @@ -386,29 +383,29 @@ void DrawPlayer(struct PlayerInfo *player) { if (Store[last_jx][last_jy]) { - DrawLevelElement(last_jx,last_jy, Store[last_jx][last_jy]); - DrawLevelFieldThruMask(last_jx,last_jy); + DrawLevelElement(last_jx, last_jy, Store[last_jx][last_jy]); + DrawLevelFieldThruMask(last_jx, last_jy); } else if (Feld[last_jx][last_jy] == EL_DYNAMIT) - DrawDynamite(last_jx,last_jy); + DrawDynamite(last_jx, last_jy); else - DrawLevelField(last_jx,last_jy); + DrawLevelField(last_jx, last_jy); - if (player->Pushing && IN_SCR_FIELD(SCREENX(next_jx),SCREENY(next_jy))) + if (player->Pushing && IN_SCR_FIELD(SCREENX(next_jx), SCREENY(next_jy))) { if (player->GfxPos) { if (Feld[next_jx][next_jy] == EL_SOKOBAN_FELD_VOLL) - DrawLevelElement(next_jx,next_jy, EL_SOKOBAN_FELD_LEER); + DrawLevelElement(next_jx, next_jy, EL_SOKOBAN_FELD_LEER); else - DrawLevelElement(next_jx,next_jy, EL_LEERRAUM); + DrawLevelElement(next_jx, next_jy, EL_LEERRAUM); } else - DrawLevelField(next_jx,next_jy); + DrawLevelField(next_jx, next_jy); } } - if (!IN_SCR_FIELD(sx,sy)) + if (!IN_SCR_FIELD(sx, sy)) return; if (setup.direct_draw) @@ -417,17 +414,17 @@ void DrawPlayer(struct PlayerInfo *player) /* draw things behind the player, if needed */ if (Store[jx][jy]) - DrawLevelElement(jx,jy, Store[jx][jy]); + DrawLevelElement(jx, jy, Store[jx][jy]); else if (element != EL_DYNAMIT && element != EL_DYNABOMB) - DrawLevelField(jx,jy); + DrawLevelField(jx, jy); /* draw player himself */ - if (player->MovDir==MV_LEFT) + if (player->MovDir == MV_LEFT) graphic = (player->Pushing ? GFX_SPIELER1_PUSH_LEFT : GFX_SPIELER1_LEFT); - else if (player->MovDir==MV_RIGHT) + else if (player->MovDir == MV_RIGHT) graphic = (player->Pushing ? GFX_SPIELER1_PUSH_RIGHT : GFX_SPIELER1_RIGHT); - else if (player->MovDir==MV_UP) + else if (player->MovDir == MV_UP) graphic = GFX_SPIELER1_UP; else /* MV_DOWN || MV_NO_MOVING */ graphic = GFX_SPIELER1_DOWN; @@ -446,7 +443,7 @@ void DrawPlayer(struct PlayerInfo *player) if (!setup.soft_scrolling && ScreenMovPos) sxx = syy = 0; - DrawGraphicShiftedThruMask(sx,sy, sxx,syy, graphic, NO_CUTTING); + DrawGraphicShiftedThruMask(sx, sy, sxx, syy, graphic, NO_CUTTING); if (player->Pushing && player->GfxPos) { @@ -454,7 +451,8 @@ void DrawPlayer(struct PlayerInfo *player) if (Feld[jx][jy] == EL_SOKOBAN_FELD_LEER || Feld[next_jx][next_jy] == EL_SOKOBAN_FELD_VOLL) - DrawGraphicShiftedThruMask(px,py,sxx,syy, GFX_SOKOBAN_OBJEKT,NO_CUTTING); + DrawGraphicShiftedThruMask(px, py, sxx, syy, GFX_SOKOBAN_OBJEKT, + NO_CUTTING); else { int element = Feld[next_jx][next_jy]; @@ -470,7 +468,7 @@ void DrawPlayer(struct PlayerInfo *player) graphic += (phase+4)%4; } - DrawGraphicShifted(px,py, sxx,syy, graphic, NO_CUTTING, NO_MASKING); + DrawGraphicShifted(px, py, sxx, syy, graphic, NO_CUTTING, NO_MASKING); } } @@ -482,37 +480,38 @@ void DrawPlayer(struct PlayerInfo *player) if (element == EL_DYNAMIT) { - if ((phase = (96-MovDelay[jx][jy])/12) > 6) + if ((phase = (96 - MovDelay[jx][jy]) / 12) > 6) phase = 6; } else { - if ((phase = ((96-MovDelay[jx][jy])/6) % 8) > 3) - phase = 7-phase; + if ((phase = ((96 - MovDelay[jx][jy]) / 6) % 8) > 3) + phase = 7 - phase; } - DrawGraphicThruMask(sx,sy, graphic + phase); + DrawGraphicThruMask(sx, sy, graphic + phase); } - if ((last_jx != jx || last_jy != jy) && Feld[last_jx][last_jy]==EL_EXPLODING) + if ((last_jx != jx || last_jy != jy) && + Feld[last_jx][last_jy] == EL_EXPLODING) { int phase = Frame[last_jx][last_jy]; int delay = 2; if (phase > 2) - DrawGraphicThruMask(SCREENX(last_jx),SCREENY(last_jy), - GFX_EXPLOSION + ((phase-1)/delay-1)); + DrawGraphicThruMask(SCREENX(last_jx), SCREENY(last_jy), + GFX_EXPLOSION + ((phase - 1) / delay - 1)); } if (setup.direct_draw) { - int dest_x = SX + SCREENX(MIN(jx,last_jx))*TILEX; - int dest_y = SY + SCREENY(MIN(jy,last_jy))*TILEY; + int dest_x = SX + SCREENX(MIN(jx, last_jx)) * TILEX; + int dest_y = SY + SCREENY(MIN(jy, last_jy)) * TILEY; int x_size = TILEX * (1 + ABS(jx - last_jx)); int y_size = TILEY * (1 + ABS(jy - last_jy)); - XCopyArea(display,drawto_field,window,gc, - dest_x,dest_y, x_size,y_size, dest_x,dest_y); + XCopyArea(display, drawto_field, window, gc, + dest_x, dest_y, x_size, y_size, dest_x, dest_y); SetDrawtoField(DRAW_DIRECT); } @@ -525,7 +524,7 @@ static int getGraphicAnimationPhase(int frames, int delay, int mode) if (mode == ANIM_OSCILLATE) { - int max_anim_frames = frames*2 - 2; + int max_anim_frames = 2 * frames - 2; phase = (FrameCounter % (delay * max_anim_frames)) / delay; phase = (phase < frames ? phase : max_anim_frames - phase); } @@ -543,25 +542,25 @@ void DrawGraphicAnimationExt(int x, int y, int graphic, { int phase = getGraphicAnimationPhase(frames, delay, mode); - if (!(FrameCounter % delay) && IN_SCR_FIELD(SCREENX(x),SCREENY(y))) + if (!(FrameCounter % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) { if (mask_mode == USE_MASKING) - DrawGraphicThruMask(SCREENX(x),SCREENY(y), graphic + phase); + DrawGraphicThruMask(SCREENX(x), SCREENY(y), graphic + phase); else - DrawGraphic(SCREENX(x),SCREENY(y), graphic + phase); + DrawGraphic(SCREENX(x), SCREENY(y), graphic + phase); } } void DrawGraphicAnimation(int x, int y, int graphic, int frames, int delay, int mode) { - DrawGraphicAnimationExt(x,y, graphic, frames,delay,mode, NO_MASKING); + DrawGraphicAnimationExt(x, y, graphic, frames, delay, mode, NO_MASKING); } void DrawGraphicAnimationThruMask(int x, int y, int graphic, int frames, int delay, int mode) { - DrawGraphicAnimationExt(x,y, graphic, frames,delay,mode, USE_MASKING); + DrawGraphicAnimationExt(x, y, graphic, frames, delay, mode, USE_MASKING); } void DrawGraphic(int x, int y, int graphic) @@ -575,7 +574,7 @@ void DrawGraphic(int x, int y, int graphic) } #endif - DrawGraphicExt(drawto_field, gc, FX+x*TILEX, FY+y*TILEY, graphic); + DrawGraphicExt(drawto_field, gc, FX + x*TILEX, FY + y*TILEY, graphic); MarkTileDirty(x,y); } @@ -584,30 +583,30 @@ void DrawGraphicExt(Drawable d, GC gc, int x, int y, int graphic) if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN) { graphic -= GFX_START_ROCKSSCREEN; - XCopyArea(display,pix[PIX_BACK],d,gc, + XCopyArea(display, pix[PIX_BACK], d, gc, SX + (graphic % GFX_PER_LINE) * TILEX, SY + (graphic / GFX_PER_LINE) * TILEY, - TILEX,TILEY, x,y); + TILEX, TILEY, x, y); } else if (graphic >= GFX_START_ROCKSHEROES && graphic <= GFX_END_ROCKSHEROES) { graphic -= GFX_START_ROCKSHEROES; - XCopyArea(display,pix[PIX_HEROES],d,gc, + XCopyArea(display, pix[PIX_HEROES], d, gc, (graphic % HEROES_PER_LINE) * TILEX, (graphic / HEROES_PER_LINE) * TILEY, - TILEX,TILEY, x,y); + TILEX, TILEY, x, y); } else if (graphic >= GFX_START_ROCKSFONT && graphic <= GFX_END_ROCKSFONT) { graphic -= GFX_START_ROCKSFONT; - XCopyArea(display,pix[PIX_BIGFONT],d,gc, + XCopyArea(display, pix[PIX_BIGFONT], d, gc, (graphic % FONT_CHARS_PER_LINE) * TILEX, (graphic / FONT_CHARS_PER_LINE) * TILEY + FC_SPECIAL1 * FONT_LINES_PER_FONT * TILEY, - TILEX,TILEY, x,y); + TILEX, TILEY, x, y); } else - XFillRectangle(display,d,gc, x,y, TILEX,TILEY); + XFillRectangle(display, d, gc, x, y, TILEX, TILEY); } void DrawGraphicThruMask(int x, int y, int graphic) @@ -621,7 +620,7 @@ void DrawGraphicThruMask(int x, int y, int graphic) } #endif - DrawGraphicThruMaskExt(drawto_field, FX+x*TILEX, FY+y*TILEY, graphic); + DrawGraphicThruMaskExt(drawto_field, FX + x*TILEX, FY + y*TILEY, graphic); MarkTileDirty(x,y); } @@ -637,16 +636,16 @@ void DrawGraphicThruMaskExt(Drawable d, int dest_x, int dest_y, int graphic) src_pixmap = pix[PIX_BACK]; drawing_gc = clip_gc[PIX_BACK]; graphic -= GFX_START_ROCKSSCREEN; - src_x = SX+(graphic % GFX_PER_LINE)*TILEX; - src_y = SY+(graphic / GFX_PER_LINE)*TILEY; + src_x = SX + (graphic % GFX_PER_LINE) * TILEX; + src_y = SY + (graphic / GFX_PER_LINE) * TILEY; } else if (graphic >= GFX_START_ROCKSHEROES && graphic <= GFX_END_ROCKSHEROES) { src_pixmap = pix[PIX_HEROES]; drawing_gc = clip_gc[PIX_HEROES]; graphic -= GFX_START_ROCKSHEROES; - src_x = (graphic % HEROES_PER_LINE)*TILEX; - src_y = (graphic / HEROES_PER_LINE)*TILEY; + src_x = (graphic % HEROES_PER_LINE) * TILEX; + src_y = (graphic / HEROES_PER_LINE) * TILEY; } else { @@ -657,9 +656,9 @@ void DrawGraphicThruMaskExt(Drawable d, int dest_x, int dest_y, int graphic) if (tile_clipmask[tile] != None) { XSetClipMask(display, tile_clip_gc, tile_clipmask[tile]); - XSetClipOrigin(display, tile_clip_gc, dest_x,dest_y); + XSetClipOrigin(display, tile_clip_gc, dest_x, dest_y); XCopyArea(display, src_pixmap, drawto_field, tile_clip_gc, - src_x,src_y, TILEX,TILEY, dest_x,dest_y); + src_x, src_y, TILEX, TILEY, dest_x, dest_y); } else { @@ -669,13 +668,13 @@ void DrawGraphicThruMaskExt(Drawable d, int dest_x, int dest_y, int graphic) XSetClipOrigin(display, drawing_gc, dest_x-src_x, dest_y-src_y); XCopyArea(display, src_pixmap, drawto_field, drawing_gc, - src_x,src_y, TILEX,TILEY, dest_x,dest_y); + src_x, src_y, TILEX, TILEY, dest_x, dest_y); } } void DrawMiniGraphic(int x, int y, int graphic) { - DrawMiniGraphicExt(drawto,gc, SX+x*MINI_TILEX,SY+y*MINI_TILEY, graphic); + DrawMiniGraphicExt(drawto,gc, SX + x*MINI_TILEX, SY + y*MINI_TILEY, graphic); MarkTileDirty(x/2, y/2); } @@ -684,22 +683,22 @@ void DrawMiniGraphicExt(Drawable d, GC gc, int x, int y, int graphic) if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN) { graphic -= GFX_START_ROCKSSCREEN; - XCopyArea(display,pix[PIX_BACK],d,gc, - MINI_GFX_STARTX+(graphic % MINI_GFX_PER_LINE)*MINI_TILEX, - MINI_GFX_STARTY+(graphic / MINI_GFX_PER_LINE)*MINI_TILEY, - MINI_TILEX,MINI_TILEY, x,y); + XCopyArea(display, pix[PIX_BACK], d, gc, + MINI_GFX_STARTX + (graphic % MINI_GFX_PER_LINE) * MINI_TILEX, + MINI_GFX_STARTY + (graphic / MINI_GFX_PER_LINE) * MINI_TILEY, + MINI_TILEX, MINI_TILEY, x, y); } else if (graphic >= GFX_START_ROCKSFONT && graphic <= GFX_END_ROCKSFONT) { graphic -= GFX_START_ROCKSFONT; - XCopyArea(display,pix[PIX_SMALLFONT],d,gc, - (graphic % FONT_CHARS_PER_LINE)*FONT4_XSIZE, - (graphic / FONT_CHARS_PER_LINE)*FONT4_YSIZE + - FC_SPECIAL2*FONT2_YSIZE*FONT_LINES_PER_FONT, - MINI_TILEX,MINI_TILEY, x,y); + XCopyArea(display, pix[PIX_SMALLFONT], d, gc, + (graphic % FONT_CHARS_PER_LINE) * FONT4_XSIZE, + (graphic / FONT_CHARS_PER_LINE) * FONT4_YSIZE + + FC_SPECIAL2 * FONT2_YSIZE * FONT_LINES_PER_FONT, + MINI_TILEX, MINI_TILEY, x, y); } else - XFillRectangle(display,d,gc, x,y, MINI_TILEX,MINI_TILEY); + XFillRectangle(display, d, gc, x, y, MINI_TILEX, MINI_TILEY); } void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, @@ -707,14 +706,14 @@ void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, { int width = TILEX, height = TILEY; int cx = 0, cy = 0; - int src_x,src_y, dest_x,dest_y; + int src_x, src_y, dest_x, dest_y; int tile = graphic; Pixmap src_pixmap; GC drawing_gc; if (graphic < 0) { - DrawGraphic(x,y,graphic); + DrawGraphic(x, y, graphic); return; } @@ -733,13 +732,13 @@ void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, width = -dx; dx = TILEX + dx; } - else if (x==BX1 && dx<0) /* Element verläßt links das Bild */ + else if (x==BX1 && dx < 0) /* Element verläßt links das Bild */ { width += dx; cx = -dx; dx = 0; } - else if (x==BX2 && dx>0) /* Element verläßt rechts das Bild */ + else if (x==BX2 && dx > 0) /* Element verläßt rechts das Bild */ width -= dx; else if (dx) /* allg. Bewegung in x-Richtung */ MarkTileDirty(x + SIGN(dx), y); @@ -760,23 +759,23 @@ void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, height = -dy; dy = TILEY + dy; } - else if (y==BY1 && dy<0) /* Element verläßt oben das Bild */ + else if (y==BY1 && dy < 0) /* Element verläßt oben das Bild */ { height += dy; cy = -dy; dy = 0; } - else if (dy > 0 && cut_mode==CUT_ABOVE) + else if (dy > 0 && cut_mode == CUT_ABOVE) { if (y == BY2) /* Element unterhalb des Bildes */ return; height = dy; - cy = TILEY-dy; + cy = TILEY - dy; dy = TILEY; MarkTileDirty(x, y + 1); } /* Element verläßt unten das Bild */ - else if (dy > 0 && (y == BY2 || cut_mode==CUT_BELOW)) + else if (dy > 0 && (y == BY2 || cut_mode == CUT_BELOW)) height -= dy; else if (dy) /* allg. Bewegung in y-Richtung */ MarkTileDirty(x, y + SIGN(dy)); @@ -787,20 +786,20 @@ void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, src_pixmap = pix[PIX_BACK]; drawing_gc = clip_gc[PIX_BACK]; graphic -= GFX_START_ROCKSSCREEN; - src_x = SX+(graphic % GFX_PER_LINE)*TILEX+cx; - src_y = SY+(graphic / GFX_PER_LINE)*TILEY+cy; + src_x = SX + (graphic % GFX_PER_LINE) * TILEX + cx; + src_y = SY + (graphic / GFX_PER_LINE) * TILEY + cy; } else if (graphic >= GFX_START_ROCKSHEROES && graphic <= GFX_END_ROCKSHEROES) { src_pixmap = pix[PIX_HEROES]; drawing_gc = clip_gc[PIX_HEROES]; graphic -= GFX_START_ROCKSHEROES; - src_x = (graphic % HEROES_PER_LINE)*TILEX+cx; - src_y = (graphic / HEROES_PER_LINE)*TILEY+cy; + src_x = (graphic % HEROES_PER_LINE) * TILEX + cx; + src_y = (graphic / HEROES_PER_LINE) * TILEY + cy; } - dest_x = FX + x*TILEX + dx; - dest_y = FY + y*TILEY + dy; + dest_x = FX + x * TILEX + dx; + dest_y = FY + y * TILEY + dy; #if DEBUG if (!IN_SCR_FIELD(x,y)) @@ -816,9 +815,9 @@ void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, if (tile_clipmask[tile] != None) { XSetClipMask(display, tile_clip_gc, tile_clipmask[tile]); - XSetClipOrigin(display, tile_clip_gc, dest_x,dest_y); + XSetClipOrigin(display, tile_clip_gc, dest_x, dest_y); XCopyArea(display, src_pixmap, drawto_field, tile_clip_gc, - src_x,src_y, TILEX,TILEY, dest_x,dest_y); + src_x, src_y, TILEX, TILEY, dest_x, dest_y); } else { @@ -826,14 +825,14 @@ void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, printf("DrawGraphicShifted(): tile '%d' needs clipping!\n", tile); #endif - XSetClipOrigin(display, drawing_gc, dest_x-src_x, dest_y-src_y); + XSetClipOrigin(display, drawing_gc, dest_x - src_x, dest_y - src_y); XCopyArea(display, src_pixmap, drawto_field, drawing_gc, - src_x,src_y, width,height, dest_x,dest_y); + src_x, src_y, width, height, dest_x, dest_y); } } else XCopyArea(display, src_pixmap, drawto_field, gc, - src_x,src_y, width,height, dest_x,dest_y); + src_x, src_y, width, height, dest_x, dest_y); MarkTileDirty(x,y); } @@ -849,11 +848,11 @@ void DrawScreenElementExt(int x, int y, int dx, int dy, int element, { int ux = LEVELX(x), uy = LEVELY(y); int graphic = el2gfx(element); - int phase4 = ABS(MovPos[ux][uy])/(TILEX/4); + int phase4 = ABS(MovPos[ux][uy]) / (TILEX / 4); int phase = phase4 / 2; int dir = MovDir[ux][uy]; - if (element==EL_PACMAN || element==EL_KAEFER || element==EL_FLIEGER) + if (element == EL_PACMAN || element == EL_KAEFER || element == EL_FLIEGER) { graphic += 4*!phase; @@ -864,61 +863,61 @@ void DrawScreenElementExt(int x, int y, int dx, int dy, int element, else if (dir == MV_DOWN) graphic += 3; } - else if (element==EL_MAULWURF || element==EL_PINGUIN || - element==EL_SCHWEIN || element==EL_DRACHE) - { - if (dir==MV_LEFT) - graphic = (element==EL_MAULWURF ? GFX_MAULWURF_LEFT : - element==EL_PINGUIN ? GFX_PINGUIN_LEFT : - element==EL_SCHWEIN ? GFX_SCHWEIN_LEFT : GFX_DRACHE_LEFT); - else if (dir==MV_RIGHT) - graphic = (element==EL_MAULWURF ? GFX_MAULWURF_RIGHT : - element==EL_PINGUIN ? GFX_PINGUIN_RIGHT : - element==EL_SCHWEIN ? GFX_SCHWEIN_RIGHT : GFX_DRACHE_RIGHT); - else if (dir==MV_UP) - graphic = (element==EL_MAULWURF ? GFX_MAULWURF_UP : - element==EL_PINGUIN ? GFX_PINGUIN_UP : - element==EL_SCHWEIN ? GFX_SCHWEIN_UP : GFX_DRACHE_UP); + else if (element == EL_MAULWURF || element == EL_PINGUIN || + element == EL_SCHWEIN || element == EL_DRACHE) + { + if (dir == MV_LEFT) + graphic = (element == EL_MAULWURF ? GFX_MAULWURF_LEFT : + element == EL_PINGUIN ? GFX_PINGUIN_LEFT : + element == EL_SCHWEIN ? GFX_SCHWEIN_LEFT : GFX_DRACHE_LEFT); + else if (dir == MV_RIGHT) + graphic = (element == EL_MAULWURF ? GFX_MAULWURF_RIGHT : + element == EL_PINGUIN ? GFX_PINGUIN_RIGHT : + element == EL_SCHWEIN ? GFX_SCHWEIN_RIGHT : GFX_DRACHE_RIGHT); + else if (dir == MV_UP) + graphic = (element == EL_MAULWURF ? GFX_MAULWURF_UP : + element == EL_PINGUIN ? GFX_PINGUIN_UP : + element == EL_SCHWEIN ? GFX_SCHWEIN_UP : GFX_DRACHE_UP); else - graphic = (element==EL_MAULWURF ? GFX_MAULWURF_DOWN : - element==EL_PINGUIN ? GFX_PINGUIN_DOWN : - element==EL_SCHWEIN ? GFX_SCHWEIN_DOWN : GFX_DRACHE_DOWN); + graphic = (element == EL_MAULWURF ? GFX_MAULWURF_DOWN : + element == EL_PINGUIN ? GFX_PINGUIN_DOWN : + element == EL_SCHWEIN ? GFX_SCHWEIN_DOWN : GFX_DRACHE_DOWN); graphic += phase4; } - else if (element==EL_SONDE) + else if (element == EL_SONDE) { graphic = GFX_SONDE_START + getGraphicAnimationPhase(8, 2, ANIM_NORMAL); } - else if (element==EL_SALZSAEURE) + else if (element == EL_SALZSAEURE) { graphic = GFX_GEBLUBBER + getGraphicAnimationPhase(4, 10, ANIM_NORMAL); } - else if (element==EL_BUTTERFLY || element==EL_FIREFLY) + else if (element == EL_BUTTERFLY || element == EL_FIREFLY) { graphic += !phase; } - else if ((element==EL_FELSBROCKEN || IS_GEM(element)) && !cut_mode) + else if ((element == EL_FELSBROCKEN || IS_GEM(element)) && !cut_mode) { - graphic += phase * (element==EL_FELSBROCKEN ? 2 : 1); + graphic += phase * (element == EL_FELSBROCKEN ? 2 : 1); } - else if ((element==EL_SIEB_LEER || element==EL_SIEB2_LEER || - element==EL_SIEB_VOLL || element==EL_SIEB2_VOLL) && SiebAktiv) + else if ((element == EL_SIEB_LEER || element == EL_SIEB2_LEER || + element == EL_SIEB_VOLL || element == EL_SIEB2_VOLL) && SiebAktiv) { - graphic += 3-(SiebAktiv%8)/2; + graphic += 3 - (SiebAktiv % 8) / 2; } else if (IS_AMOEBOID(element)) { - graphic = (element==EL_AMOEBE_TOT ? GFX_AMOEBE_TOT : GFX_AMOEBE_LEBT); - graphic += (x+2*y) % 4; + graphic = (element == EL_AMOEBE_TOT ? GFX_AMOEBE_TOT : GFX_AMOEBE_LEBT); + graphic += (x + 2 * y + 4) % 4; } - else if (element==EL_MAUER_LEBT) + else if (element == EL_MAUER_LEBT) { boolean links_massiv = FALSE, rechts_massiv = FALSE; - if (!IN_LEV_FIELD(ux-1,uy) || IS_MAUER(Feld[ux-1][uy])) + if (!IN_LEV_FIELD(ux-1, uy) || IS_MAUER(Feld[ux-1][uy])) links_massiv = TRUE; - if (!IN_LEV_FIELD(ux+1,uy) || IS_MAUER(Feld[ux+1][uy])) + if (!IN_LEV_FIELD(ux+1, uy) || IS_MAUER(Feld[ux+1][uy])) rechts_massiv = TRUE; if (links_massiv && rechts_massiv) @@ -930,46 +929,46 @@ void DrawScreenElementExt(int x, int y, int dx, int dy, int element, } if (dx || dy) - DrawGraphicShifted(x,y, dx,dy, graphic, cut_mode, mask_mode); + DrawGraphicShifted(x, y, dx, dy, graphic, cut_mode, mask_mode); else if (mask_mode == USE_MASKING) - DrawGraphicThruMask(x,y, graphic); + DrawGraphicThruMask(x, y, graphic); else - DrawGraphic(x,y, graphic); + DrawGraphic(x, y, graphic); } void DrawLevelElementExt(int x, int y, int dx, int dy, int element, int cut_mode, int mask_mode) { - if (IN_LEV_FIELD(x,y) && IN_SCR_FIELD(SCREENX(x),SCREENY(y))) - DrawScreenElementExt(SCREENX(x),SCREENY(y), dx,dy, element, + if (IN_LEV_FIELD(x, y) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + DrawScreenElementExt(SCREENX(x), SCREENY(y), dx, dy, element, cut_mode, mask_mode); } void DrawScreenElementShifted(int x, int y, int dx, int dy, int element, int cut_mode) { - DrawScreenElementExt(x,y, dx,dy, element, cut_mode, NO_MASKING); + DrawScreenElementExt(x, y, dx, dy, element, cut_mode, NO_MASKING); } void DrawLevelElementShifted(int x, int y, int dx, int dy, int element, int cut_mode) { - DrawLevelElementExt(x,y, dx,dy, element, cut_mode, NO_MASKING); + DrawLevelElementExt(x, y, dx, dy, element, cut_mode, NO_MASKING); } void DrawScreenElementThruMask(int x, int y, int element) { - DrawScreenElementExt(x,y, 0,0, element, NO_CUTTING, USE_MASKING); + DrawScreenElementExt(x, y, 0, 0, element, NO_CUTTING, USE_MASKING); } void DrawLevelElementThruMask(int x, int y, int element) { - DrawLevelElementExt(x,y, 0,0, element, NO_CUTTING, USE_MASKING); + DrawLevelElementExt(x, y, 0, 0, element, NO_CUTTING, USE_MASKING); } void DrawLevelFieldThruMask(int x, int y) { - DrawLevelElementExt(x,y, 0,0, Feld[x][y], NO_CUTTING, USE_MASKING); + DrawLevelElementExt(x, y, 0, 0, Feld[x][y], NO_CUTTING, USE_MASKING); } void ErdreichAnbroeckeln(int x, int y) @@ -980,43 +979,43 @@ void ErdreichAnbroeckeln(int x, int y) int snip = 4; static int xy[4][2] = { - { 0,-1 }, - { -1,0 }, - { +1,0 }, - { 0,+1 } + { 0, -1 }, + { -1, 0 }, + { +1, 0 }, + { 0, +1 } }; - if (!IN_LEV_FIELD(ux,uy)) + if (!IN_LEV_FIELD(ux, uy)) return; element = Feld[ux][uy]; - if (element==EL_ERDREICH) + if (element == EL_ERDREICH) { - if (!IN_SCR_FIELD(x,y)) + if (!IN_SCR_FIELD(x, y)) return; graphic = GFX_ERDENRAND; - for(i=0;i<4;i++) + for(i=0; i<4; i++) { - int uxx,uyy; + int uxx, uyy; - uxx = ux+xy[i][0]; - uyy = uy+xy[i][1]; - if (!IN_LEV_FIELD(uxx,uyy)) + uxx = ux + xy[i][0]; + uyy = uy + xy[i][1]; + if (!IN_LEV_FIELD(uxx, uyy)) element = EL_BETON; else element = Feld[uxx][uyy]; - if (element==EL_ERDREICH) + if (element == EL_ERDREICH) continue; - if (i==1 || i==2) + if (i == 1 || i == 2) { width = snip; height = TILEY; - cx = (i==2 ? TILEX-snip : 0); + cx = (i == 2 ? TILEX - snip : 0); cy = 0; } else @@ -1024,39 +1023,39 @@ void ErdreichAnbroeckeln(int x, int y) width = TILEX; height = snip; cx = 0; - cy = (i==3 ? TILEY-snip : 0); + cy = (i == 3 ? TILEY - snip : 0); } - XCopyArea(display,pix[PIX_BACK],drawto_field,gc, - SX+(graphic % GFX_PER_LINE)*TILEX+cx, - SY+(graphic / GFX_PER_LINE)*TILEY+cy, - width,height, FX+x*TILEX+cx,FY+y*TILEY+cy); + XCopyArea(display, pix[PIX_BACK], drawto_field, gc, + SX + (graphic % GFX_PER_LINE) * TILEX + cx, + SY + (graphic / GFX_PER_LINE) * TILEY + cy, + width, height, FX + x * TILEX + cx, FY + y * TILEY + cy); } - MarkTileDirty(x,y); + MarkTileDirty(x, y); } else { graphic = GFX_ERDENRAND; - for(i=0;i<4;i++) + for(i=0; i<4; i++) { - int xx,yy,uxx,uyy; + int xx, yy, uxx, uyy; - xx = x+xy[i][0]; - yy = y+xy[i][1]; - uxx = ux+xy[i][0]; - uyy = uy+xy[i][1]; + xx = x + xy[i][0]; + yy = y + xy[i][1]; + uxx = ux + xy[i][0]; + uyy = uy + xy[i][1]; - if (!IN_LEV_FIELD(uxx,uyy) || Feld[uxx][uyy]!=EL_ERDREICH || - !IN_SCR_FIELD(xx,yy)) + if (!IN_LEV_FIELD(uxx, uyy) || Feld[uxx][uyy] != EL_ERDREICH || + !IN_SCR_FIELD(xx, yy)) continue; - if (i==1 || i==2) + if (i == 1 || i == 2) { width = snip; height = TILEY; - cx = (i==1 ? TILEX-snip : 0); + cx = (i == 1 ? TILEX - snip : 0); cy = 0; } else @@ -1067,26 +1066,26 @@ void ErdreichAnbroeckeln(int x, int y) cy = (i==0 ? TILEY-snip : 0); } - XCopyArea(display,pix[PIX_BACK],drawto_field,gc, - SX+(graphic % GFX_PER_LINE)*TILEX+cx, - SY+(graphic / GFX_PER_LINE)*TILEY+cy, - width,height, FX+xx*TILEX+cx,FY+yy*TILEY+cy); + XCopyArea(display, pix[PIX_BACK], drawto_field, gc, + SX + (graphic % GFX_PER_LINE) * TILEX + cx, + SY + (graphic / GFX_PER_LINE) * TILEY + cy, + width, height, FX + xx * TILEX + cx, FY + yy * TILEY + cy); - MarkTileDirty(xx,yy); + MarkTileDirty(xx, yy); } } } void DrawScreenElement(int x, int y, int element) { - DrawScreenElementExt(x,y, 0,0, element, NO_CUTTING, NO_MASKING); - ErdreichAnbroeckeln(x,y); + DrawScreenElementExt(x, y, 0, 0, element, NO_CUTTING, NO_MASKING); + ErdreichAnbroeckeln(x, y); } void DrawLevelElement(int x, int y, int element) { - if (IN_LEV_FIELD(x,y) && IN_SCR_FIELD(SCREENX(x),SCREENY(y))) - DrawScreenElement(SCREENX(x),SCREENY(y),element); + if (IN_LEV_FIELD(x, y) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + DrawScreenElement(SCREENX(x), SCREENY(y), element); } void DrawScreenField(int x, int y) @@ -1094,61 +1093,62 @@ void DrawScreenField(int x, int y) int ux = LEVELX(x), uy = LEVELY(y); int element; - if (!IN_LEV_FIELD(ux,uy)) + if (!IN_LEV_FIELD(ux, uy)) { - DrawScreenElement(x,y,EL_BETON); + DrawScreenElement(x, y, EL_BETON); return; } element = Feld[ux][uy]; - if (IS_MOVING(ux,uy)) + if (IS_MOVING(ux, uy)) { - int horiz_move = (MovDir[ux][uy]==MV_LEFT || MovDir[ux][uy]==MV_RIGHT); + int horiz_move = (MovDir[ux][uy] == MV_LEFT || MovDir[ux][uy] == MV_RIGHT); boolean cut_mode = NO_CUTTING; - if (Store[ux][uy]==EL_MORAST_LEER || - Store[ux][uy]==EL_SIEB_LEER || - Store[ux][uy]==EL_SIEB2_LEER || - Store[ux][uy]==EL_AMOEBE_NASS) + if (Store[ux][uy] == EL_MORAST_LEER || + Store[ux][uy] == EL_SIEB_LEER || + Store[ux][uy] == EL_SIEB2_LEER || + Store[ux][uy] == EL_AMOEBE_NASS) cut_mode = CUT_ABOVE; - else if (Store[ux][uy]==EL_MORAST_VOLL || - Store[ux][uy]==EL_SIEB_VOLL || - Store[ux][uy]==EL_SIEB2_VOLL) + else if (Store[ux][uy] == EL_MORAST_VOLL || + Store[ux][uy] == EL_SIEB_VOLL || + Store[ux][uy] == EL_SIEB2_VOLL) cut_mode = CUT_BELOW; - if (cut_mode==CUT_ABOVE) - DrawScreenElementShifted(x,y, 0,0, Store[ux][uy], NO_CUTTING); + if (cut_mode == CUT_ABOVE) + DrawScreenElementShifted(x, y, 0, 0, Store[ux][uy], NO_CUTTING); else - DrawScreenElement(x,y,EL_LEERRAUM); + DrawScreenElement(x, y, EL_LEERRAUM); if (horiz_move) - DrawScreenElementShifted(x,y, MovPos[ux][uy],0, element, NO_CUTTING); + DrawScreenElementShifted(x, y, MovPos[ux][uy], 0, element, NO_CUTTING); else - DrawScreenElementShifted(x,y, 0,MovPos[ux][uy], element, cut_mode); + DrawScreenElementShifted(x, y, 0, MovPos[ux][uy], element, cut_mode); if (Store[ux][uy] == EL_SALZSAEURE) - DrawLevelElementThruMask(ux,uy+1, EL_SALZSAEURE); + DrawLevelElementThruMask(ux, uy + 1, EL_SALZSAEURE); } - else if (IS_BLOCKED(ux,uy)) + else if (IS_BLOCKED(ux, uy)) { - int oldx,oldy; + int oldx, oldy; int sx, sy; int horiz_move; boolean cut_mode = NO_CUTTING; - Blocked2Moving(ux,uy,&oldx,&oldy); + Blocked2Moving(ux, uy, &oldx, &oldy); sx = SCREENX(oldx); sy = SCREENY(oldy); - horiz_move = (MovDir[oldx][oldy]==MV_LEFT || MovDir[oldx][oldy]==MV_RIGHT); + horiz_move = (MovDir[oldx][oldy] == MV_LEFT || + MovDir[oldx][oldy] == MV_RIGHT); - if (Store[oldx][oldy]==EL_MORAST_LEER || - Store[oldx][oldy]==EL_SIEB_LEER || - Store[oldx][oldy]==EL_SIEB2_LEER || - Store[oldx][oldy]==EL_AMOEBE_NASS) + if (Store[oldx][oldy] == EL_MORAST_LEER || + Store[oldx][oldy] == EL_SIEB_LEER || + Store[oldx][oldy] == EL_SIEB2_LEER || + Store[oldx][oldy] == EL_AMOEBE_NASS) cut_mode = CUT_ABOVE; - DrawScreenElement(x,y,EL_LEERRAUM); + DrawScreenElement(x, y, EL_LEERRAUM); element = Feld[oldx][oldy]; if (horiz_move) @@ -1157,30 +1157,30 @@ void DrawScreenField(int x, int y) DrawScreenElementShifted(sx,sy, 0,MovPos[oldx][oldy],element,cut_mode); } else if (IS_DRAWABLE(element)) - DrawScreenElement(x,y,element); + DrawScreenElement(x, y, element); else - DrawScreenElement(x,y,EL_LEERRAUM); + DrawScreenElement(x, y, EL_LEERRAUM); } void DrawLevelField(int x, int y) { - if (IN_SCR_FIELD(SCREENX(x),SCREENY(y))) - DrawScreenField(SCREENX(x),SCREENY(y)); - else if (IS_MOVING(x,y)) + if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + DrawScreenField(SCREENX(x), SCREENY(y)); + else if (IS_MOVING(x, y)) { int newx,newy; - Moving2Blocked(x,y,&newx,&newy); - if (IN_SCR_FIELD(SCREENX(newx),SCREENY(newy))) - DrawScreenField(SCREENX(newx),SCREENY(newy)); + Moving2Blocked(x, y, &newx, &newy); + if (IN_SCR_FIELD(SCREENX(newx), SCREENY(newy))) + DrawScreenField(SCREENX(newx), SCREENY(newy)); } - else if (IS_BLOCKED(x,y)) + else if (IS_BLOCKED(x, y)) { - int oldx,oldy; + int oldx, oldy; - Blocked2Moving(x,y,&oldx,&oldy); - if (IN_SCR_FIELD(SCREENX(oldx),SCREENY(oldy))) - DrawScreenField(SCREENX(oldx),SCREENY(oldy)); + Blocked2Moving(x, y, &oldx, &oldy); + if (IN_SCR_FIELD(SCREENX(oldx), SCREENY(oldy))) + DrawScreenField(SCREENX(oldx), SCREENY(oldy)); } } @@ -1190,39 +1190,39 @@ void DrawMiniElement(int x, int y, int element) if (!element) { - DrawMiniGraphic(x,y,-1); + DrawMiniGraphic(x, y, -1); return; } graphic = el2gfx(element); - DrawMiniGraphic(x,y,graphic); + DrawMiniGraphic(x, y, graphic); } void DrawMiniElementOrWall(int sx, int sy, int scroll_x, int scroll_y) { int x = sx + scroll_x, y = sy + scroll_y; - if (x<-1 || x>lev_fieldx || y<-1 || y>lev_fieldy) - DrawMiniElement(sx,sy,EL_LEERRAUM); - else if (x==-1 || x==lev_fieldx || y==-1 || y==lev_fieldy) - DrawMiniElement(sx,sy,EL_BETON); + if (x < -1 || x > lev_fieldx || y < -1 || y > lev_fieldy) + DrawMiniElement(sx, sy, EL_LEERRAUM); + else if (x == -1 || x == lev_fieldx || y == -1 || y == lev_fieldy) + DrawMiniElement(sx, sy, EL_BETON); else - DrawMiniElement(sx,sy,Feld[x][y]); + DrawMiniElement(sx, sy, Feld[x][y]); } void DrawMicroElement(int xpos, int ypos, int element) { int graphic; - if (element==EL_LEERRAUM) + if (element == EL_LEERRAUM) return; graphic = el2gfx(element); - XCopyArea(display,pix[PIX_BACK],drawto,gc, - MICRO_GFX_STARTX+(graphic % MICRO_GFX_PER_LINE)*MICRO_TILEX, - MICRO_GFX_STARTY+(graphic / MICRO_GFX_PER_LINE)*MICRO_TILEY, - MICRO_TILEX,MICRO_TILEY, xpos,ypos); + XCopyArea(display, pix[PIX_BACK], drawto, gc, + MICRO_GFX_STARTX + (graphic % MICRO_GFX_PER_LINE) * MICRO_TILEX, + MICRO_GFX_STARTY + (graphic / MICRO_GFX_PER_LINE) * MICRO_TILEY, + MICRO_TILEX, MICRO_TILEY, xpos, ypos); } void DrawLevel() @@ -1233,12 +1233,11 @@ void DrawLevel() for(x=BX1; x<=BX2; x++) for(y=BY1; y<=BY2; y++) - DrawScreenField(x,y); + DrawScreenField(x, y); if (setup.soft_scrolling) - XCopyArea(display,fieldbuffer,backbuffer,gc, - FX,FY, SXSIZE,SYSIZE, - SX,SY); + XCopyArea(display, fieldbuffer, backbuffer, gc, + FX, FY, SXSIZE, SYSIZE, SX, SY); redraw_mask |= (REDRAW_FIELD | REDRAW_FROM_BACKBUFFER); } @@ -1249,9 +1248,9 @@ void DrawMiniLevel(int scroll_x, int scroll_y) ClearWindow(); - for(x=0;x<2*SCR_FIELDX;x++) - for(y=0;y<2*SCR_FIELDY;y++) - DrawMiniElementOrWall(x,y,scroll_x,scroll_y); + for(x=0; x<2*SCR_FIELDX; x++) + for(y=0; y<2*SCR_FIELDY; y++) + DrawMiniElementOrWall(x, y, scroll_x, scroll_y); redraw_mask |= REDRAW_FIELD; } @@ -1260,33 +1259,33 @@ void DrawMicroLevel(int xpos, int ypos) { int x,y; - XFillRectangle(display,drawto,gc, - xpos-MICRO_TILEX,ypos-MICRO_TILEY, - MICRO_TILEX*(STD_LEV_FIELDX+2), - MICRO_TILEY*(STD_LEV_FIELDY+2)); + XFillRectangle(display, drawto, gc, + xpos - MICRO_TILEX, ypos - MICRO_TILEY, + MICRO_TILEX * (STD_LEV_FIELDX + 2), + MICRO_TILEY * (STD_LEV_FIELDY + 2)); if (lev_fieldx < STD_LEV_FIELDX) xpos += (STD_LEV_FIELDX - lev_fieldx)/2 * MICRO_TILEX; if (lev_fieldy < STD_LEV_FIELDY) ypos += (STD_LEV_FIELDY - lev_fieldy)/2 * MICRO_TILEY; - for(x=-1;x<=STD_LEV_FIELDX;x++) - for(y=-1;y<=STD_LEV_FIELDY;y++) - if (x>=0 && x=0 && y=-1 && x=-1 && y= 0 && x < lev_fieldx && y >= 0 && y < lev_fieldy) + DrawMicroElement(xpos + x * MICRO_TILEX, ypos + y * MICRO_TILEY, + Ur[x][y]); + else if (x >= -1 && x < lev_fieldx+1 && y >= -1 && y < lev_fieldy+1) + DrawMicroElement(xpos + x * MICRO_TILEX, ypos + y * MICRO_TILEY, EL_BETON); - XFillRectangle(display,drawto,gc, SX,MICROLABEL_YPOS, SXSIZE,FONT4_YSIZE); + XFillRectangle(display, drawto,gc, SX, MICROLABEL_YPOS, SXSIZE, FONT4_YSIZE); if (level.name) { int len = strlen(level.name); - int lxpos = SX+(SXSIZE-len*FONT4_XSIZE)/2; + int lxpos = SX + (SXSIZE - len * FONT4_XSIZE) / 2; int lypos = MICROLABEL_YPOS; - DrawText(lxpos,lypos,level.name,FS_SMALL,FC_SPECIAL2); + DrawText(lxpos, lypos, level.name, FS_SMALL, FC_SPECIAL2); } redraw_mask |= REDRAW_MICROLEV; @@ -1294,19 +1293,19 @@ void DrawMicroLevel(int xpos, int ypos) int REQ_in_range(int x, int y) { - if (y>DY+249 && y DY+249 && y < DY+278) { - if (x>DX+1 && xDX+51 && x DX+1 && x < DX+48) + return 1; + else if (x > DX+51 && x < DX+98) + return 2; } - return(0); + return 0; } boolean Request(char *text, unsigned int req_state) { - int mx,my, ty, result = -1; + int mx, my, ty, result = -1; unsigned int old_door_state; /* pause network game while waiting for request to answer */ @@ -1320,25 +1319,26 @@ boolean Request(char *text, unsigned int req_state) CloseDoor(DOOR_CLOSE_1); /* Alten Türinhalt sichern */ - XCopyArea(display,pix[PIX_DB_DOOR],pix[PIX_DB_DOOR],gc, - DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY1, DXSIZE,DYSIZE, - DOOR_GFX_PAGEX2,DOOR_GFX_PAGEY1); + XCopyArea(display, pix[PIX_DB_DOOR], pix[PIX_DB_DOOR], gc, + DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, + DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1); /* Fragetext schreiben */ - XFillRectangle(display,pix[PIX_DB_DOOR],gc, - DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY1,DXSIZE,DYSIZE); + XFillRectangle(display, pix[PIX_DB_DOOR], gc, + DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE); - for(ty=0;ty<13;ty++) + for(ty=0; ty<13; ty++) { - int tx,tl,tc; + int tx, tl, tc; char txt[256]; - if (!(*text)) + if (!*text) break; - for(tl=0,tx=0;tx<7;tl++,tx++) + + for(tl=0,tx=0; tx<7; tl++,tx++) { - tc=*(text+tx); - if (!tc || tc==32) + tc = *(text + tx); + if (!tc || tc == 32) break; } if (!tl) @@ -1347,11 +1347,12 @@ boolean Request(char *text, unsigned int req_state) ty--; continue; } - sprintf(txt,text); - txt[tl]=0; - DrawTextExt(pix[PIX_DB_DOOR],gc, - DOOR_GFX_PAGEX1+51-(tl*14)/2,SY+ty*16,txt,FS_SMALL,FC_YELLOW); - text+=(tl+(tc==32)); + sprintf(txt, text); + txt[tl] = 0; + DrawTextExt(pix[PIX_DB_DOOR], gc, + DOOR_GFX_PAGEX1 + 51 - (tl * 14)/2, SY + ty * 16, + txt, FS_SMALL, FC_YELLOW); + text += tl + (tc == 32 ? 1 : 0); } if (req_state & REQ_ASK) @@ -1528,9 +1529,9 @@ unsigned int OpenDoor(unsigned int door_state) if (door_state & DOOR_COPY_BACK) { - XCopyArea(display,pix[PIX_DB_DOOR],pix[PIX_DB_DOOR],gc, - DOOR_GFX_PAGEX2,DOOR_GFX_PAGEY1, DXSIZE,DYSIZE+VYSIZE, - DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY1); + XCopyArea(display, pix[PIX_DB_DOOR], pix[PIX_DB_DOOR], gc, + DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE + VYSIZE, + DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1); door_state &= ~DOOR_COPY_BACK; } @@ -1543,10 +1544,10 @@ unsigned int CloseDoor(unsigned int door_state) { unsigned int new_door_state; - XCopyArea(display,backbuffer,pix[PIX_DB_DOOR],gc, - DX,DY, DXSIZE,DYSIZE, DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY1); - XCopyArea(display,backbuffer,pix[PIX_DB_DOOR],gc, - VX,VY, VXSIZE,VYSIZE, DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY2); + XCopyArea(display, backbuffer, pix[PIX_DB_DOOR], gc, + DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1); + XCopyArea(display, backbuffer, pix[PIX_DB_DOOR], gc, + VX, VY, VXSIZE, VYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY2); new_door_state = MoveDoor(door_state); @@ -1569,13 +1570,13 @@ unsigned int MoveDoor(unsigned int door_state) if (door_state == DOOR_GET_STATE) return(door1 | door2); - if (door1==DOOR_OPEN_1 && door_state & DOOR_OPEN_1) + if (door1 == DOOR_OPEN_1 && door_state & DOOR_OPEN_1) door_state &= ~DOOR_OPEN_1; - else if (door1==DOOR_CLOSE_1 && door_state & DOOR_CLOSE_1) + else if (door1 == DOOR_CLOSE_1 && door_state & DOOR_CLOSE_1) door_state &= ~DOOR_CLOSE_1; - if (door2==DOOR_OPEN_2 && door_state & DOOR_OPEN_2) + if (door2 == DOOR_OPEN_2 && door_state & DOOR_OPEN_2) door_state &= ~DOOR_OPEN_2; - else if (door2==DOOR_CLOSE_2 && door_state & DOOR_CLOSE_2) + else if (door2 == DOOR_CLOSE_2 && door_state & DOOR_CLOSE_2) door_state &= ~DOOR_CLOSE_2; if (setup.quick_doors) @@ -1588,7 +1589,7 @@ unsigned int MoveDoor(unsigned int door_state) if (door_state & DOOR_ACTION) { if (!(door_state & DOOR_NO_DELAY)) - PlaySoundStereo(SND_OEFFNEN,PSND_MAX_RIGHT); + PlaySoundStereo(SND_OEFFNEN, PSND_MAX_RIGHT); start = ((door_state & DOOR_NO_DELAY) ? DXSIZE : 0); @@ -1599,73 +1600,74 @@ unsigned int MoveDoor(unsigned int door_state) if (door_state & DOOR_ACTION_1) { int i = (door_state & DOOR_OPEN_1 ? DXSIZE-x : x); - int j = (DXSIZE - i)/3; - - XCopyArea(display,pix[PIX_DB_DOOR],drawto,gc, - DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY1+i/2, - DXSIZE,DYSIZE-i/2, DX,DY); - - XFillRectangle(display,drawto,gc,DX,DY+DYSIZE-i/2,DXSIZE,i/2); - - XSetClipOrigin(display,clip_gc[PIX_DOOR], - DX-i,(DY+j)-DOOR_GFX_PAGEY1); - XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR], - DXSIZE,DOOR_GFX_PAGEY1, i,77, DX+DXSIZE-i,DY+j); - XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR], - DXSIZE,DOOR_GFX_PAGEY1+140, i,63, DX+DXSIZE-i,DY+140+j); - XSetClipOrigin(display,clip_gc[PIX_DOOR], - DX-DXSIZE+i,DY-(DOOR_GFX_PAGEY1+j)); - XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR], - DXSIZE-i,DOOR_GFX_PAGEY1+j, i,77-j, DX,DY); - XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR], - DXSIZE-i,DOOR_GFX_PAGEY1+140, i,63, DX,DY+140-j); - - XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR], - DXSIZE-i,DOOR_GFX_PAGEY1+77, i,63, - DX,DY+77-j); - XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR], - DXSIZE-i,DOOR_GFX_PAGEY1+203, i,77, - DX,DY+203-j); - XSetClipOrigin(display,clip_gc[PIX_DOOR], - DX-i,(DY+j)-DOOR_GFX_PAGEY1); - XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR], - DXSIZE,DOOR_GFX_PAGEY1+77, i,63, - DX+DXSIZE-i,DY+77+j); - XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR], - DXSIZE,DOOR_GFX_PAGEY1+203, i,77-j, - DX+DXSIZE-i,DY+203+j); + int j = (DXSIZE - i) / 3; + + XCopyArea(display, pix[PIX_DB_DOOR], drawto, gc, + DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1 + i/2, + DXSIZE,DYSIZE - i/2, DX, DY); + + XFillRectangle(display, drawto, gc, DX, DY + DYSIZE - i/2, DXSIZE,i/2); + + XSetClipOrigin(display, clip_gc[PIX_DOOR], + DX - i, (DY + j) - DOOR_GFX_PAGEY1); + XCopyArea(display, pix[PIX_DOOR], drawto,clip_gc[PIX_DOOR], + DXSIZE, DOOR_GFX_PAGEY1, i, 77, DX + DXSIZE - i, DY + j); + XCopyArea(display, pix[PIX_DOOR], drawto, clip_gc[PIX_DOOR], + DXSIZE, DOOR_GFX_PAGEY1 + 140, i, 63, DX + DXSIZE - i, + DY + 140 + j); + XSetClipOrigin(display, clip_gc[PIX_DOOR], + DX - DXSIZE + i, DY - (DOOR_GFX_PAGEY1 + j)); + XCopyArea(display, pix[PIX_DOOR], drawto, clip_gc[PIX_DOOR], + DXSIZE - i, DOOR_GFX_PAGEY1 + j, i, 77 - j, DX, DY); + XCopyArea(display, pix[PIX_DOOR], drawto, clip_gc[PIX_DOOR], + DXSIZE-i, DOOR_GFX_PAGEY1 + 140, i, 63, DX, DY + 140 - j); + + XCopyArea(display, pix[PIX_DOOR], drawto, clip_gc[PIX_DOOR], + DXSIZE - i, DOOR_GFX_PAGEY1 + 77, i, 63, + DX, DY + 77 - j); + XCopyArea(display, pix[PIX_DOOR], drawto, clip_gc[PIX_DOOR], + DXSIZE - i, DOOR_GFX_PAGEY1 + 203, i, 77, + DX, DY + 203 - j); + XSetClipOrigin(display, clip_gc[PIX_DOOR], + DX - i, (DY + j) - DOOR_GFX_PAGEY1); + XCopyArea(display, pix[PIX_DOOR], drawto, clip_gc[PIX_DOOR], + DXSIZE, DOOR_GFX_PAGEY1 + 77, i, 63, + DX + DXSIZE - i, DY + 77 + j); + XCopyArea(display, pix[PIX_DOOR], drawto, clip_gc[PIX_DOOR], + DXSIZE, DOOR_GFX_PAGEY1 + 203, i, 77 - j, + DX + DXSIZE - i, DY + 203 + j); redraw_mask |= REDRAW_DOOR_1; } if (door_state & DOOR_ACTION_2) { - int i = (door_state & DOOR_OPEN_2 ? VXSIZE-x : x); - int j = (VXSIZE - i)/3; - - XCopyArea(display,pix[PIX_DB_DOOR],drawto,gc, - DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY2+i/2, - VXSIZE,VYSIZE-i/2, VX,VY); - - XFillRectangle(display,drawto,gc,VX,VY+VYSIZE-i/2,VXSIZE,i/2); - - XSetClipOrigin(display,clip_gc[PIX_DOOR], - VX-i,(VY+j)-DOOR_GFX_PAGEY2); - XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR], - VXSIZE,DOOR_GFX_PAGEY2, i,VYSIZE/2, VX+VXSIZE-i,VY+j); - XSetClipOrigin(display,clip_gc[PIX_DOOR], - VX-VXSIZE+i,VY-(DOOR_GFX_PAGEY2+j)); - XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR], - VXSIZE-i,DOOR_GFX_PAGEY2+j, i,VYSIZE/2-j, VX,VY); - - XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR], - VXSIZE-i,DOOR_GFX_PAGEY2+VYSIZE/2, i,VYSIZE/2, - VX,VY+VYSIZE/2-j); - XSetClipOrigin(display,clip_gc[PIX_DOOR], - VX-i,(VY+j)-DOOR_GFX_PAGEY2); - XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR], - VXSIZE,DOOR_GFX_PAGEY2+VYSIZE/2, i,VYSIZE/2-j, - VX+VXSIZE-i,VY+VYSIZE/2+j); + int i = (door_state & DOOR_OPEN_2 ? VXSIZE - x : x); + int j = (VXSIZE - i) / 3; + + XCopyArea(display, pix[PIX_DB_DOOR], drawto, gc, + DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY2 + i/2, + VXSIZE, VYSIZE - i/2, VX, VY); + + XFillRectangle(display, drawto, gc, VX, VY + VYSIZE-i/2, VXSIZE, i/2); + + XSetClipOrigin(display, clip_gc[PIX_DOOR], + VX - i, (VY + j) - DOOR_GFX_PAGEY2); + XCopyArea(display, pix[PIX_DOOR], drawto, clip_gc[PIX_DOOR], + VXSIZE, DOOR_GFX_PAGEY2, i, VYSIZE / 2, VX + VXSIZE-i, VY+j); + XSetClipOrigin(display, clip_gc[PIX_DOOR], + VX - VXSIZE + i, VY - (DOOR_GFX_PAGEY2 + j)); + XCopyArea(display, pix[PIX_DOOR], drawto,clip_gc[PIX_DOOR], + VXSIZE - i, DOOR_GFX_PAGEY2 + j, i, VYSIZE / 2 - j, VX, VY); + + XCopyArea(display, pix[PIX_DOOR], drawto, clip_gc[PIX_DOOR], + VXSIZE - i, DOOR_GFX_PAGEY2 + VYSIZE / 2, i, VYSIZE / 2, + VX, VY + VYSIZE / 2 - j); + XSetClipOrigin(display, clip_gc[PIX_DOOR], + VX - i, (VY + j) - DOOR_GFX_PAGEY2); + XCopyArea(display, pix[PIX_DOOR], drawto, clip_gc[PIX_DOOR], + VXSIZE, DOOR_GFX_PAGEY2 + VYSIZE / 2, i, VYSIZE / 2 - j, + VX + VXSIZE - i, VY + VYSIZE / 2 + j); redraw_mask |= REDRAW_DOOR_2; } @@ -1692,142 +1694,142 @@ int ReadPixel(Drawable d, int x, int y) { static XImage *pixelimage; - pixelimage = XGetImage(display, d, x,y, 1,1, AllPlanes, ZPixmap); - return(XGetPixel(pixelimage,0,0)); + pixelimage = XGetImage(display, d, x, y, 1, 1, AllPlanes, ZPixmap); + return(XGetPixel(pixelimage, 0, 0)); } int el2gfx(int element) { switch(element) { - case EL_LEERRAUM: return(-1); - case EL_ERDREICH: return(GFX_ERDREICH); - case EL_MAUERWERK: return(GFX_MAUERWERK); - case EL_FELSBODEN: return(GFX_FELSBODEN); - case EL_FELSBROCKEN: return(GFX_FELSBROCKEN); - case EL_SCHLUESSEL: return(GFX_SCHLUESSEL); - case EL_EDELSTEIN: return(GFX_EDELSTEIN); - case EL_AUSGANG_ZU: return(GFX_AUSGANG_ZU); - case EL_AUSGANG_ACT: return(GFX_AUSGANG_ACT); - case EL_AUSGANG_AUF: return(GFX_AUSGANG_AUF); - case EL_SPIELFIGUR: return(GFX_SPIELFIGUR); - case EL_SPIELER1: return(GFX_SPIELER1); - case EL_SPIELER2: return(GFX_SPIELER2); - case EL_SPIELER3: return(GFX_SPIELER3); - case EL_SPIELER4: return(GFX_SPIELER4); - case EL_KAEFER: return(GFX_KAEFER); - case EL_KAEFER_R: return(GFX_KAEFER_R); - case EL_KAEFER_O: return(GFX_KAEFER_O); - case EL_KAEFER_L: return(GFX_KAEFER_L); - case EL_KAEFER_U: return(GFX_KAEFER_U); - case EL_FLIEGER: return(GFX_FLIEGER); - case EL_FLIEGER_R: return(GFX_FLIEGER_R); - case EL_FLIEGER_O: return(GFX_FLIEGER_O); - case EL_FLIEGER_L: return(GFX_FLIEGER_L); - case EL_FLIEGER_U: return(GFX_FLIEGER_U); - case EL_BUTTERFLY: return(GFX_BUTTERFLY); - case EL_BUTTERFLY_R: return(GFX_BUTTERFLY_R); - case EL_BUTTERFLY_O: return(GFX_BUTTERFLY_O); - case EL_BUTTERFLY_L: return(GFX_BUTTERFLY_L); - case EL_BUTTERFLY_U: return(GFX_BUTTERFLY_U); - case EL_FIREFLY: return(GFX_FIREFLY); - case EL_FIREFLY_R: return(GFX_FIREFLY_R); - case EL_FIREFLY_O: return(GFX_FIREFLY_O); - case EL_FIREFLY_L: return(GFX_FIREFLY_L); - case EL_FIREFLY_U: return(GFX_FIREFLY_U); - case EL_MAMPFER: return(GFX_MAMPFER); - case EL_ROBOT: return(GFX_ROBOT); - case EL_BETON: return(GFX_BETON); - case EL_DIAMANT: return(GFX_DIAMANT); - case EL_MORAST_LEER: return(GFX_MORAST_LEER); - case EL_MORAST_VOLL: return(GFX_MORAST_VOLL); - case EL_TROPFEN: return(GFX_TROPFEN); - case EL_BOMBE: return(GFX_BOMBE); - case EL_SIEB_LEER: return(GFX_SIEB_LEER); - case EL_SIEB_VOLL: return(GFX_SIEB_VOLL); - case EL_SIEB_TOT: return(GFX_SIEB_TOT); - case EL_SALZSAEURE: return(GFX_SALZSAEURE); - case EL_AMOEBE_TOT: return(GFX_AMOEBE_TOT); - case EL_AMOEBE_NASS: return(GFX_AMOEBE_NASS); - case EL_AMOEBE_NORM: return(GFX_AMOEBE_NORM); - case EL_AMOEBE_VOLL: return(GFX_AMOEBE_VOLL); - case EL_AMOEBE_BD: return(GFX_AMOEBE_BD); - case EL_AMOEBA2DIAM: return(GFX_AMOEBA2DIAM); - case EL_KOKOSNUSS: return(GFX_KOKOSNUSS); - case EL_LIFE: return(GFX_LIFE); - case EL_LIFE_ASYNC: return(GFX_LIFE_ASYNC); - case EL_DYNAMIT: return(GFX_DYNAMIT); - case EL_BADEWANNE: return(GFX_BADEWANNE); - case EL_BADEWANNE1: return(GFX_BADEWANNE1); - case EL_BADEWANNE2: return(GFX_BADEWANNE2); - case EL_BADEWANNE3: return(GFX_BADEWANNE3); - case EL_BADEWANNE4: return(GFX_BADEWANNE4); - case EL_BADEWANNE5: return(GFX_BADEWANNE5); - case EL_ABLENK_AUS: return(GFX_ABLENK_AUS); - case EL_ABLENK_EIN: return(GFX_ABLENK_EIN); - case EL_SCHLUESSEL1: return(GFX_SCHLUESSEL1); - case EL_SCHLUESSEL2: return(GFX_SCHLUESSEL2); - case EL_SCHLUESSEL3: return(GFX_SCHLUESSEL3); - case EL_SCHLUESSEL4: return(GFX_SCHLUESSEL4); - case EL_PFORTE1: return(GFX_PFORTE1); - case EL_PFORTE2: return(GFX_PFORTE2); - case EL_PFORTE3: return(GFX_PFORTE3); - case EL_PFORTE4: return(GFX_PFORTE4); - case EL_PFORTE1X: return(GFX_PFORTE1X); - case EL_PFORTE2X: return(GFX_PFORTE2X); - case EL_PFORTE3X: return(GFX_PFORTE3X); - case EL_PFORTE4X: return(GFX_PFORTE4X); - case EL_DYNAMIT_AUS: return(GFX_DYNAMIT_AUS); - case EL_PACMAN: return(GFX_PACMAN); - case EL_PACMAN_R: return(GFX_PACMAN_R); - case EL_PACMAN_O: return(GFX_PACMAN_O); - case EL_PACMAN_L: return(GFX_PACMAN_L); - case EL_PACMAN_U: return(GFX_PACMAN_U); - case EL_UNSICHTBAR: return(GFX_UNSICHTBAR); - case EL_ERZ_EDEL: return(GFX_ERZ_EDEL); - case EL_ERZ_DIAM: return(GFX_ERZ_DIAM); - case EL_BIRNE_AUS: return(GFX_BIRNE_AUS); - case EL_BIRNE_EIN: return(GFX_BIRNE_EIN); - case EL_ZEIT_VOLL: return(GFX_ZEIT_VOLL); - case EL_ZEIT_LEER: return(GFX_ZEIT_LEER); - case EL_MAUER_LEBT: return(GFX_MAUER_LEBT); - case EL_MAUER_X: return(GFX_MAUER_X); - case EL_MAUER_Y: return(GFX_MAUER_Y); - case EL_MAUER_XY: return(GFX_MAUER_XY); - case EL_EDELSTEIN_BD: return(GFX_EDELSTEIN_BD); - case EL_EDELSTEIN_GELB: return(GFX_EDELSTEIN_GELB); - case EL_EDELSTEIN_ROT: return(GFX_EDELSTEIN_ROT); - case EL_EDELSTEIN_LILA: return(GFX_EDELSTEIN_LILA); - case EL_ERZ_EDEL_BD: return(GFX_ERZ_EDEL_BD); - case EL_ERZ_EDEL_GELB: return(GFX_ERZ_EDEL_GELB); - case EL_ERZ_EDEL_ROT: return(GFX_ERZ_EDEL_ROT); - case EL_ERZ_EDEL_LILA: return(GFX_ERZ_EDEL_LILA); - case EL_MAMPFER2: return(GFX_MAMPFER2); - case EL_SIEB2_LEER: return(GFX_SIEB2_LEER); - case EL_SIEB2_VOLL: return(GFX_SIEB2_VOLL); - case EL_SIEB2_TOT: return(GFX_SIEB2_TOT); - case EL_DYNABOMB: return(GFX_DYNABOMB); - case EL_DYNABOMB_NR: return(GFX_DYNABOMB_NR); - case EL_DYNABOMB_SZ: return(GFX_DYNABOMB_SZ); - case EL_DYNABOMB_XL: return(GFX_DYNABOMB_XL); - case EL_SOKOBAN_OBJEKT: return(GFX_SOKOBAN_OBJEKT); - case EL_SOKOBAN_FELD_LEER: return(GFX_SOKOBAN_FELD_LEER); - case EL_SOKOBAN_FELD_VOLL: return(GFX_SOKOBAN_FELD_VOLL); - case EL_MAULWURF: return(GFX_MAULWURF); - case EL_PINGUIN: return(GFX_PINGUIN); - case EL_SCHWEIN: return(GFX_SCHWEIN); - case EL_DRACHE: return(GFX_DRACHE); - case EL_SONDE: return(GFX_SONDE); - case EL_PFEIL_L: return(GFX_PFEIL_L); - case EL_PFEIL_R: return(GFX_PFEIL_R); - case EL_PFEIL_O: return(GFX_PFEIL_O); - case EL_PFEIL_U: return(GFX_PFEIL_U); + case EL_LEERRAUM: return -1; + case EL_ERDREICH: return GFX_ERDREICH; + case EL_MAUERWERK: return GFX_MAUERWERK; + case EL_FELSBODEN: return GFX_FELSBODEN; + case EL_FELSBROCKEN: return GFX_FELSBROCKEN; + case EL_SCHLUESSEL: return GFX_SCHLUESSEL; + case EL_EDELSTEIN: return GFX_EDELSTEIN; + case EL_AUSGANG_ZU: return GFX_AUSGANG_ZU; + case EL_AUSGANG_ACT: return GFX_AUSGANG_ACT; + case EL_AUSGANG_AUF: return GFX_AUSGANG_AUF; + case EL_SPIELFIGUR: return GFX_SPIELFIGUR; + case EL_SPIELER1: return GFX_SPIELER1; + case EL_SPIELER2: return GFX_SPIELER2; + case EL_SPIELER3: return GFX_SPIELER3; + case EL_SPIELER4: return GFX_SPIELER4; + case EL_KAEFER: return GFX_KAEFER; + case EL_KAEFER_R: return GFX_KAEFER_R; + case EL_KAEFER_O: return GFX_KAEFER_O; + case EL_KAEFER_L: return GFX_KAEFER_L; + case EL_KAEFER_U: return GFX_KAEFER_U; + case EL_FLIEGER: return GFX_FLIEGER; + case EL_FLIEGER_R: return GFX_FLIEGER_R; + case EL_FLIEGER_O: return GFX_FLIEGER_O; + case EL_FLIEGER_L: return GFX_FLIEGER_L; + case EL_FLIEGER_U: return GFX_FLIEGER_U; + case EL_BUTTERFLY: return GFX_BUTTERFLY; + case EL_BUTTERFLY_R: return GFX_BUTTERFLY_R; + case EL_BUTTERFLY_O: return GFX_BUTTERFLY_O; + case EL_BUTTERFLY_L: return GFX_BUTTERFLY_L; + case EL_BUTTERFLY_U: return GFX_BUTTERFLY_U; + case EL_FIREFLY: return GFX_FIREFLY; + case EL_FIREFLY_R: return GFX_FIREFLY_R; + case EL_FIREFLY_O: return GFX_FIREFLY_O; + case EL_FIREFLY_L: return GFX_FIREFLY_L; + case EL_FIREFLY_U: return GFX_FIREFLY_U; + case EL_MAMPFER: return GFX_MAMPFER; + case EL_ROBOT: return GFX_ROBOT; + case EL_BETON: return GFX_BETON; + case EL_DIAMANT: return GFX_DIAMANT; + case EL_MORAST_LEER: return GFX_MORAST_LEER; + case EL_MORAST_VOLL: return GFX_MORAST_VOLL; + case EL_TROPFEN: return GFX_TROPFEN; + case EL_BOMBE: return GFX_BOMBE; + case EL_SIEB_LEER: return GFX_SIEB_LEER; + case EL_SIEB_VOLL: return GFX_SIEB_VOLL; + case EL_SIEB_TOT: return GFX_SIEB_TOT; + case EL_SALZSAEURE: return GFX_SALZSAEURE; + case EL_AMOEBE_TOT: return GFX_AMOEBE_TOT; + case EL_AMOEBE_NASS: return GFX_AMOEBE_NASS; + case EL_AMOEBE_NORM: return GFX_AMOEBE_NORM; + case EL_AMOEBE_VOLL: return GFX_AMOEBE_VOLL; + case EL_AMOEBE_BD: return GFX_AMOEBE_BD; + case EL_AMOEBA2DIAM: return GFX_AMOEBA2DIAM; + case EL_KOKOSNUSS: return GFX_KOKOSNUSS; + case EL_LIFE: return GFX_LIFE; + case EL_LIFE_ASYNC: return GFX_LIFE_ASYNC; + case EL_DYNAMIT: return GFX_DYNAMIT; + case EL_BADEWANNE: return GFX_BADEWANNE; + case EL_BADEWANNE1: return GFX_BADEWANNE1; + case EL_BADEWANNE2: return GFX_BADEWANNE2; + case EL_BADEWANNE3: return GFX_BADEWANNE3; + case EL_BADEWANNE4: return GFX_BADEWANNE4; + case EL_BADEWANNE5: return GFX_BADEWANNE5; + case EL_ABLENK_AUS: return GFX_ABLENK_AUS; + case EL_ABLENK_EIN: return GFX_ABLENK_EIN; + case EL_SCHLUESSEL1: return GFX_SCHLUESSEL1; + case EL_SCHLUESSEL2: return GFX_SCHLUESSEL2; + case EL_SCHLUESSEL3: return GFX_SCHLUESSEL3; + case EL_SCHLUESSEL4: return GFX_SCHLUESSEL4; + case EL_PFORTE1: return GFX_PFORTE1; + case EL_PFORTE2: return GFX_PFORTE2; + case EL_PFORTE3: return GFX_PFORTE3; + case EL_PFORTE4: return GFX_PFORTE4; + case EL_PFORTE1X: return GFX_PFORTE1X; + case EL_PFORTE2X: return GFX_PFORTE2X; + case EL_PFORTE3X: return GFX_PFORTE3X; + case EL_PFORTE4X: return GFX_PFORTE4X; + case EL_DYNAMIT_AUS: return GFX_DYNAMIT_AUS; + case EL_PACMAN: return GFX_PACMAN; + case EL_PACMAN_R: return GFX_PACMAN_R; + case EL_PACMAN_O: return GFX_PACMAN_O; + case EL_PACMAN_L: return GFX_PACMAN_L; + case EL_PACMAN_U: return GFX_PACMAN_U; + case EL_UNSICHTBAR: return GFX_UNSICHTBAR; + case EL_ERZ_EDEL: return GFX_ERZ_EDEL; + case EL_ERZ_DIAM: return GFX_ERZ_DIAM; + case EL_BIRNE_AUS: return GFX_BIRNE_AUS; + case EL_BIRNE_EIN: return GFX_BIRNE_EIN; + case EL_ZEIT_VOLL: return GFX_ZEIT_VOLL; + case EL_ZEIT_LEER: return GFX_ZEIT_LEER; + case EL_MAUER_LEBT: return GFX_MAUER_LEBT; + case EL_MAUER_X: return GFX_MAUER_X; + case EL_MAUER_Y: return GFX_MAUER_Y; + case EL_MAUER_XY: return GFX_MAUER_XY; + case EL_EDELSTEIN_BD: return GFX_EDELSTEIN_BD; + case EL_EDELSTEIN_GELB: return GFX_EDELSTEIN_GELB; + case EL_EDELSTEIN_ROT: return GFX_EDELSTEIN_ROT; + case EL_EDELSTEIN_LILA: return GFX_EDELSTEIN_LILA; + case EL_ERZ_EDEL_BD: return GFX_ERZ_EDEL_BD; + case EL_ERZ_EDEL_GELB: return GFX_ERZ_EDEL_GELB; + case EL_ERZ_EDEL_ROT: return GFX_ERZ_EDEL_ROT; + case EL_ERZ_EDEL_LILA: return GFX_ERZ_EDEL_LILA; + case EL_MAMPFER2: return GFX_MAMPFER2; + case EL_SIEB2_LEER: return GFX_SIEB2_LEER; + case EL_SIEB2_VOLL: return GFX_SIEB2_VOLL; + case EL_SIEB2_TOT: return GFX_SIEB2_TOT; + case EL_DYNABOMB: return GFX_DYNABOMB; + case EL_DYNABOMB_NR: return GFX_DYNABOMB_NR; + case EL_DYNABOMB_SZ: return GFX_DYNABOMB_SZ; + case EL_DYNABOMB_XL: return GFX_DYNABOMB_XL; + case EL_SOKOBAN_OBJEKT: return GFX_SOKOBAN_OBJEKT; + case EL_SOKOBAN_FELD_LEER: return GFX_SOKOBAN_FELD_LEER; + case EL_SOKOBAN_FELD_VOLL: return GFX_SOKOBAN_FELD_VOLL; + case EL_MAULWURF: return GFX_MAULWURF; + case EL_PINGUIN: return GFX_PINGUIN; + case EL_SCHWEIN: return GFX_SCHWEIN; + case EL_DRACHE: return GFX_DRACHE; + case EL_SONDE: return GFX_SONDE; + case EL_PFEIL_L: return GFX_PFEIL_L; + case EL_PFEIL_R: return GFX_PFEIL_R; + case EL_PFEIL_O: return GFX_PFEIL_O; + case EL_PFEIL_U: return GFX_PFEIL_U; default: { if (IS_CHAR(element)) - return(GFX_CHAR_START + (element-EL_CHAR_START)); + return GFX_CHAR_START + (element - EL_CHAR_START); else - return(-1); + return -1; } } }