#define MIN_SCORE 0
#define MAX_SCORE 255
-/* values for elements with content */
-#define MIN_ELEM_CONTENT 1
-#define MAX_ELEM_CONTENT 8
-
/* values for the control window */
#define ED_CTRL_BUTTONS_GFX_YPOS 236
#define ED_CTRL_BUTTONS_ALT_GFX_YPOS 142
},
{
ED_COUNT_ELEM_CONTENT_XPOS, ED_COUNT_ELEM_CONTENT_YPOS,
- MIN_ELEM_CONTENT, MAX_ELEM_CONTENT,
+ MIN_ELEMENT_CONTENTS, MAX_ELEMENT_CONTENTS,
GADGET_ID_ELEM_CONTENT_DOWN, GADGET_ID_ELEM_CONTENT_UP,
GADGET_ID_ELEM_CONTENT_TEXT,
- &MampferMax,
+ &level.num_yam_contents,
"element content", NULL
},
{
0, 999,
GADGET_ID_LEVEL_COLLECT_DOWN, GADGET_ID_LEVEL_COLLECT_UP,
GADGET_ID_LEVEL_COLLECT_TEXT,
- &level.edelsteine,
+ &level.gems_needed,
"number of emeralds to collect", NULL
},
{
static boolean draw_with_brush = FALSE;
static int properties_element = 0;
-static short ElementContent[MAX_ELEM_CONTENT][3][3];
+static short ElementContent[MAX_ELEMENT_CONTENTS][3][3];
static short FieldBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY];
static int undo_buffer_position = 0;
level_editor_gadget[id] = gi;
/* ... up to eight areas for element content ... */
- for (i=0; i<MAX_ELEM_CONTENT; i++)
+ for (i=0; i<MAX_ELEMENT_CONTENTS; i++)
{
int gx = SX + ED_AREA_ELEM_CONTENT_XPOS + 5 * (i % 4) * MINI_TILEX;
int gy = SX + ED_AREA_ELEM_CONTENT_YPOS + 6 * (i / 4) * MINI_TILEY;
DrawText(SX + ED_SETTINGS2_XPOS, SY + ED_SETTINGS2_YPOS,
"Editor Settings", FS_BIG, FC_YELLOW);
-
- /*
- gadget_level_xsize_value = &lev_fieldx;
- gadget_level_ysize_value = &lev_fieldy;
- gadget_level_random_value = &random_placement_value;
- gadget_level_collect_value = &level.edelsteine;
- gadget_level_timelimit_value = &level.time;
- gadget_level_timescore_value = &level.score[SC_ZEITBONUS];
- */
-
-
/* draw counter gadgets */
for (i=ED_COUNTER_ID_LEVEL_FIRST; i<=ED_COUNTER_ID_LEVEL_LAST; i++)
{
DrawTextF(x, y, font_color, infotext);
}
-
- /*
- ModifyEditorCounter(i, **counterbutton_info[i].counter_value);
- */
-
ModifyEditorCounter(i, *counterbutton_info[i].value);
-
MapCounterButtons(i);
}
int font_color = FC_GREEN;
int x, y;
- ElementContent[0][0][0] = level.amoebe_inhalt;
+ ElementContent[0][0][0] = level.amoeba_content;
/* draw decorative border for the object */
for (y=0; y<2; y++)
static void DrawElementContentAreas()
{
- int *num_areas = &MampferMax;
+ int counter_id = ED_COUNTER_ID_ELEM_CONTENT;
int area_x = ED_AREA_ELEM_CONTENT_XPOS / MINI_TILEX;
int area_y = ED_AREA_ELEM_CONTENT_YPOS / MINI_TILEY;
int area_sx = SX + ED_AREA_ELEM_CONTENT_XPOS;
int font_color = FC_GREEN;
int i, x, y;
- for (i=0; i<MAX_ELEM_CONTENT; i++)
+ for (i=0; i<MAX_ELEMENT_CONTENTS; i++)
for (y=0; y<3; y++)
for (x=0; x<3; x++)
- ElementContent[i][x][y] = level.mampfer_inhalt[i][x][y];
+ ElementContent[i][x][y] = level.yam_content[i][x][y];
- for (i=0; i<MAX_ELEM_CONTENT; i++)
+ for (i=0; i<MAX_ELEMENT_CONTENTS; i++)
UnmapDrawingArea(GADGET_ID_ELEM_CONTENT_0 + i);
/* display counter to choose number of element content areas */
-
- /*
- gadget_elem_content_value = num_areas;
- */
-
-
- x = counterbutton_info[ED_COUNTER_ID_ELEM_CONTENT].x + xoffset_right;
- y = counterbutton_info[ED_COUNTER_ID_ELEM_CONTENT].y + yoffset_right;
+ x = counterbutton_info[counter_id].x + xoffset_right;
+ y = counterbutton_info[counter_id].y + yoffset_right;
DrawTextF(x, y, font_color, "number of content areas");
- /*
- ModifyEditorCounter(ED_COUNTER_ID_ELEM_CONTENT, *gadget_elem_content_value);
- */
-
-
- ModifyEditorCounter(ED_COUNTER_ID_ELEM_CONTENT,
- *counterbutton_info[ED_COUNTER_ID_ELEM_CONTENT].value);
-
- MapCounterButtons(ED_COUNTER_ID_ELEM_CONTENT);
+ ModifyEditorCounter(counter_id, *counterbutton_info[counter_id].value);
+ MapCounterButtons(counter_id);
/* delete content areas in case of reducing number of them */
XFillRectangle(display, backbuffer, gc,
SXSIZE, 12 * MINI_TILEY);
/* draw some decorative border for the objects */
- for (i=0; i<*num_areas; i++)
+ for (i=0; i<level.num_yam_contents; i++)
{
for (y=0; y<4; y++)
for (x=0; x<4; x++)
DrawText(area_sx + (5 * 4 - 1) * MINI_TILEX, area_sy + 2 * MINI_TILEY + 1,
"smashed", FS_SMALL, font_color);
- for (i=0; i<*num_areas; i++)
+ for (i=0; i<level.num_yam_contents; i++)
{
for (y=0; y<3; y++)
for (x=0; x<3; x++)
font_color, "%d", i + 1);
}
- for (i=0; i<*num_areas; i++)
+ for (i=0; i<level.num_yam_contents; i++)
MapDrawingArea(GADGET_ID_ELEM_CONTENT_0 + i);
}
static void DrawPropertiesWindow()
{
+ int counter_id = ED_COUNTER_ID_ELEM_SCORE;
int num_elements_in_level;
float percentage;
int xoffset_right = counter_xsize;
{ EL_EM_KEY_2_FILE, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING },
{ EL_EM_KEY_3_FILE, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING },
{ EL_EM_KEY_4_FILE, &level.score[SC_SCHLUESSEL], TEXT_COLLECTING },
- { EL_AMOEBE_NASS, &level.tempo_amoebe, TEXT_SPEED },
- { EL_AMOEBE_NORM, &level.tempo_amoebe, TEXT_SPEED },
- { EL_AMOEBE_VOLL, &level.tempo_amoebe, TEXT_SPEED },
- { EL_AMOEBE_BD, &level.tempo_amoebe, TEXT_SPEED },
- { EL_SIEB_INAKTIV, &level.dauer_sieb, TEXT_DURATION },
- { EL_ABLENK_AUS, &level.dauer_ablenk, TEXT_DURATION },
+ { EL_AMOEBE_NASS, &level.amoeba_speed, TEXT_SPEED },
+ { EL_AMOEBE_NORM, &level.amoeba_speed, TEXT_SPEED },
+ { EL_AMOEBE_VOLL, &level.amoeba_speed, TEXT_SPEED },
+ { EL_AMOEBE_BD, &level.amoeba_speed, TEXT_SPEED },
+ { EL_SIEB_INAKTIV, &level.time_magic_wall, TEXT_DURATION },
+ { EL_ABLENK_AUS, &level.time_wheel, TEXT_DURATION },
{ -1, NULL, NULL }
};
{
if (elements_with_counter[i].element == properties_element)
{
- int x = counterbutton_info[ED_COUNTER_ID_ELEM_SCORE].x + xoffset_right;
- int y = counterbutton_info[ED_COUNTER_ID_ELEM_SCORE].y + yoffset_right;
-
-
- /*
- gadget_elem_score_value = elements_with_counter[i].counter_value;
- */
-
-
- counterbutton_info[ED_COUNTER_ID_ELEM_SCORE].value =
- elements_with_counter[i].value;
+ int x = counterbutton_info[counter_id].x + xoffset_right;
+ int y = counterbutton_info[counter_id].y + yoffset_right;
+ counterbutton_info[counter_id].value = elements_with_counter[i].value;
DrawTextF(x, y, font_color, elements_with_counter[i].text);
-
- /*
- ModifyEditorCounter(ED_COUNTER_ID_ELEM_SCORE, *gadget_elem_score_value);
- */
-
-
- ModifyEditorCounter(ED_COUNTER_ID_ELEM_SCORE,
- *counterbutton_info[ED_COUNTER_ID_ELEM_SCORE].value);
-
- MapCounterButtons(ED_COUNTER_ID_ELEM_SCORE);
+ ModifyEditorCounter(counter_id, *counterbutton_info[counter_id].value);
+ MapCounterButtons(counter_id);
break;
}
}
el2gfx(new_element));
if (id == GADGET_ID_AMOEBA_CONTENT)
- level.amoebe_inhalt = new_element;
+ level.amoeba_content = new_element;
else if (id == GADGET_ID_RANDOM_BACKGROUND)
random_placement_background_element = new_element;
else if (id >= GADGET_ID_ELEM_CONTENT_0 &&
id <= GADGET_ID_ELEM_CONTENT_7)
- level.mampfer_inhalt[id - GADGET_ID_ELEM_CONTENT_0][sx][sy] =
+ level.yam_content[id - GADGET_ID_ELEM_CONTENT_0][sx][sy] =
new_element;
}
break;
would be far better) set for each X11 window individually.
The effect would be keyboard auto repeat while playing the game
(game_status == PLAYING), which is not desired.
- To avoid this special case, we just wait 1/50 second before
+ To avoid this special case, we just wait 1/10 second before
processing the 'FocusIn' event.
*/
- Delay(20);
if (game_status == PLAYING)
+ {
+ Delay(100);
XAutoRepeatOff(display);
+ }
if (old_joystick_status != -1)
joystick_status = old_joystick_status;
}
Feld[x][y] = Ur[x][y] = EL_ERDREICH;
level.time = 100;
- level.edelsteine = 0;
- level.tempo_amoebe = 10;
- level.dauer_sieb = 10;
- level.dauer_ablenk = 10;
- level.amoebe_inhalt = EL_DIAMANT;
+ level.gems_needed = 0;
+ level.amoeba_speed = 10;
+ level.time_magic_wall = 10;
+ level.time_wheel = 10;
+ level.amoeba_content = EL_DIAMANT;
level.double_speed = FALSE;
level.gravity = FALSE;
for(i=0; i<LEVEL_SCORE_ELEMENTS; i++)
level.score[i] = 10;
- MampferMax = 4;
- for(i=0; i<8; i++)
+ level.num_yam_contents = STD_ELEMENT_CONTENTS;
+ for(i=0; i<MAX_ELEMENT_CONTENTS; i++)
for(x=0; x<3; x++)
for(y=0; y<3; y++)
- level.mampfer_inhalt[i][x][y] = EL_FELSBROCKEN;
+ level.yam_content[i][x][y] = EL_FELSBROCKEN;
Feld[0][0] = Ur[0][0] = EL_SPIELFIGUR;
Feld[STD_LEV_FIELDX-1][STD_LEV_FIELDY-1] =
lev_fieldx = level.fieldx = fgetc(file);
lev_fieldy = level.fieldy = fgetc(file);
- level.time = (fgetc(file)<<8) | fgetc(file);
- level.edelsteine = (fgetc(file)<<8) | fgetc(file);
+ level.time = getFile16BitInteger(file, BYTE_ORDER_BIG_ENDIAN);
+ level.gems_needed = getFile16BitInteger(file, BYTE_ORDER_BIG_ENDIAN);
for(i=0; i<MAX_LEVEL_NAME_LEN; i++)
- level.name[i] = fgetc(file);
+ level.name[i] = fgetc(file);
level.name[MAX_LEVEL_NAME_LEN] = 0;
for(i=0; i<LEVEL_SCORE_ELEMENTS; i++)
- level.score[i] = fgetc(file);
+ level.score[i] = fgetc(file);
- MampferMax = 4;
- for(i=0; i<8; i++)
+ level.num_yam_contents = STD_ELEMENT_CONTENTS;
+ for(i=0; i<MAX_ELEMENT_CONTENTS; i++)
{
for(y=0; y<3; y++)
{
for(x=0; x<3; x++)
{
- if (i < 4)
- level.mampfer_inhalt[i][x][y] = fgetc(file);
+ if (i < STD_ELEMENT_CONTENTS)
+ level.yam_content[i][x][y] = fgetc(file);
else
- level.mampfer_inhalt[i][x][y] = EL_LEERRAUM;
+ level.yam_content[i][x][y] = EL_LEERRAUM;
}
}
}
- level.tempo_amoebe = fgetc(file);
- level.dauer_sieb = fgetc(file);
- level.dauer_ablenk = fgetc(file);
- level.amoebe_inhalt = fgetc(file);
+ level.amoeba_speed = fgetc(file);
+ level.time_magic_wall = fgetc(file);
+ level.time_wheel = fgetc(file);
+ level.amoeba_content = fgetc(file);
level.double_speed = (fgetc(file) == 1 ? TRUE : FALSE);
level.gravity = (fgetc(file) == 1 ? TRUE : FALSE);
}
/* look for optional content chunk */
- if (strcmp(chunk, "CONT") == 0 && chunk_length == 4 + 8 * 3 * 3)
+ if (strcmp(chunk, "CONT") == 0 &&
+ chunk_length == 4 + MAX_ELEMENT_CONTENTS * 3 * 3)
{
fgetc(file);
- MampferMax = fgetc(file);
+ level.num_yam_contents = fgetc(file);
fgetc(file);
fgetc(file);
- for(i=0; i<8; i++)
+ for(i=0; i<MAX_ELEMENT_CONTENTS; i++)
for(y=0; y<3; y++)
for(x=0; x<3; x++)
- level.mampfer_inhalt[i][x][y] = fgetc(file);
+ level.yam_content[i][x][y] = fgetc(file);
getFileChunk(file, chunk, &chunk_length, BYTE_ORDER_BIG_ENDIAN);
}
fputc(level.fieldx, file);
fputc(level.fieldy, file);
- fputc(level.time / 256, file);
- fputc(level.time % 256, file);
- fputc(level.edelsteine / 256, file);
- fputc(level.edelsteine % 256, file);
+
+ putFile16BitInteger(file, level.time, BYTE_ORDER_BIG_ENDIAN);
+ putFile16BitInteger(file, level.gems_needed, BYTE_ORDER_BIG_ENDIAN);
for(i=0; i<MAX_LEVEL_NAME_LEN; i++)
fputc(level.name[i], file);
for(i=0; i<LEVEL_SCORE_ELEMENTS; i++)
fputc(level.score[i], file);
- for(i=0; i<4; i++)
+ for(i=0; i<STD_ELEMENT_CONTENTS; i++)
for(y=0; y<3; y++)
for(x=0; x<3; x++)
- fputc(level.mampfer_inhalt[i][x][y], file);
- fputc(level.tempo_amoebe, file);
- fputc(level.dauer_sieb, file);
- fputc(level.dauer_ablenk, file);
- fputc(level.amoebe_inhalt, file);
+ fputc(level.yam_content[i][x][y], file);
+ fputc(level.amoeba_speed, file);
+ fputc(level.time_magic_wall, file);
+ fputc(level.time_wheel, file);
+ fputc(level.amoeba_content, file);
fputc((level.double_speed ? 1 : 0), file);
fputc((level.gravity ? 1 : 0), file);
for(i=0; i<MAX_LEVEL_AUTHOR_LEN; i++)
fputc(level.author[i], file);
- putFileChunk(file, "CONT", 4 + 8 * 3 * 3, BYTE_ORDER_BIG_ENDIAN);
+ putFileChunk(file, "CONT", 4 + MAX_ELEMENT_CONTENTS * 3 * 3,
+ BYTE_ORDER_BIG_ENDIAN);
fputc(EL_MAMPFER, file);
- fputc(MampferMax, file);
+ fputc(level.num_yam_contents, file);
fputc(0, file);
fputc(0, file);
- for(i=0; i<8; i++)
+ for(i=0; i<MAX_ELEMENT_CONTENTS; i++)
for(y=0; y<3; y++)
for(x=0; x<3; x++)
- fputc(level.mampfer_inhalt[i][x][y], file);
+ fputc(level.yam_content[i][x][y], file);
putFileChunk(file, "BODY", lev_fieldx * lev_fieldy, BYTE_ORDER_BIG_ENDIAN);
/* read chunk "HEAD" */
if (file_version >= FILE_VERSION_1_2)
{
- /* first check header chunk identifier and chunk length */
- fgets(chunk, CHUNK_ID_LEN + 1, file);
- chunk_length =
- (fgetc(file)<<24) | (fgetc(file)<<16) | (fgetc(file)<<8) | fgetc(file);
-
+ getFileChunk(file, chunk, &chunk_length, BYTE_ORDER_BIG_ENDIAN);
if (strcmp(chunk, "HEAD") || chunk_length != TAPE_HEADER_SIZE)
{
Error(ERR_WARN, "wrong 'HEAD' chunk of tape file '%s'", filename);
}
}
- tape.random_seed =
- (fgetc(file)<<24) | (fgetc(file)<<16) | (fgetc(file)<<8) | fgetc(file);
- tape.date =
- (fgetc(file)<<24) | (fgetc(file)<<16) | (fgetc(file)<<8) | fgetc(file);
- tape.length =
- (fgetc(file)<<24) | (fgetc(file)<<16) | (fgetc(file)<<8) | fgetc(file);
+ tape.random_seed = getFile32BitInteger(file, BYTE_ORDER_BIG_ENDIAN);
+ tape.date = getFile32BitInteger(file, BYTE_ORDER_BIG_ENDIAN);
+ tape.length = getFile32BitInteger(file, BYTE_ORDER_BIG_ENDIAN);
/* read header fields that are new since version 1.2 */
if (file_version >= FILE_VERSION_1_2)
/* read chunk "BODY" */
if (file_version >= FILE_VERSION_1_2)
{
- /* next check body chunk identifier and chunk length */
- fgets(chunk, CHUNK_ID_LEN + 1, file);
- chunk_length =
- (fgetc(file)<<24) | (fgetc(file)<<16) | (fgetc(file)<<8) | fgetc(file);
+ getFileChunk(file, chunk, &chunk_length, BYTE_ORDER_BIG_ENDIAN);
if (strcmp(chunk, "BODY") ||
chunk_length != (num_participating_players + 1) * tape.length)
{
boolean new_tape = TRUE;
byte store_participating_players;
int num_participating_players;
- int chunk_length;
InitTapeDirectory(leveldir[leveldir_nr].filename);
fputs(TAPE_COOKIE, file); /* file identifier */
fputc('\n', file);
- fputs("HEAD", file); /* chunk identifier for file header */
+ putFileChunk(file, "HEAD", TAPE_HEADER_SIZE, BYTE_ORDER_BIG_ENDIAN);
- chunk_length = TAPE_HEADER_SIZE;
-
- fputc((chunk_length >> 24) & 0xff, file);
- fputc((chunk_length >> 16) & 0xff, file);
- fputc((chunk_length >> 8) & 0xff, file);
- fputc((chunk_length >> 0) & 0xff, file);
-
- fputc((tape.random_seed >> 24) & 0xff, file);
- fputc((tape.random_seed >> 16) & 0xff, file);
- fputc((tape.random_seed >> 8) & 0xff, file);
- fputc((tape.random_seed >> 0) & 0xff, file);
-
- fputc((tape.date >> 24) & 0xff, file);
- fputc((tape.date >> 16) & 0xff, file);
- fputc((tape.date >> 8) & 0xff, file);
- fputc((tape.date >> 0) & 0xff, file);
-
- fputc((tape.length >> 24) & 0xff, file);
- fputc((tape.length >> 16) & 0xff, file);
- fputc((tape.length >> 8) & 0xff, file);
- fputc((tape.length >> 0) & 0xff, file);
+ putFile32BitInteger(file, tape.random_seed, BYTE_ORDER_BIG_ENDIAN);
+ putFile32BitInteger(file, tape.date, BYTE_ORDER_BIG_ENDIAN);
+ putFile32BitInteger(file, tape.length, BYTE_ORDER_BIG_ENDIAN);
fputc(store_participating_players, file);
for(i=0; i<TAPE_HEADER_UNUSED; i++) /* set unused header bytes to zero */
fputc(0, file);
- fputs("BODY", file); /* chunk identifier for file body */
- chunk_length = (num_participating_players + 1) * tape.length;
-
- fputc((chunk_length >> 24) & 0xff, file);
- fputc((chunk_length >> 16) & 0xff, file);
- fputc((chunk_length >> 8) & 0xff, file);
- fputc((chunk_length >> 0) & 0xff, file);
+ putFileChunk(file, "BODY", (num_participating_players + 1) * tape.length,
+ BYTE_ORDER_BIG_ENDIAN);
for(i=0; i<tape.length; i++)
{
if (!options.network || player->connected)
{
player->active = TRUE;
- player->gone = FALSE;
/* remove potentially duplicate players */
if (StorePlayer[jx][jy] == Feld[x][y])
player->programmed_action = 0;
player->score = 0;
- player->gems_still_needed = level.edelsteine;
+ player->gems_still_needed = level.gems_needed;
player->sokobanfields_still_needed = 0;
player->lights_still_needed = 0;
player->friends_still_needed = 0;
player->snapped = FALSE;
- player->gone = TRUE;
-
player->last_jx = player->last_jy = 0;
player->jx = player->jy = 0;
ZX = ZY = -1;
- MampferNr = 0;
+ game.yam_content_nr = 0;
FrameCounter = 0;
TimeFrames = 0;
TimePlayed = 0;
ScrollStepSize = 0; /* will be correctly initialized by ScrollScreen() */
AllPlayersGone = FALSE;
- SiebAktiv = FALSE;
- SiebCount = 0;
+ game.magic_wall_active = FALSE;
+ game.magic_wall_time_left = 0;
for (i=0; i<MAX_NUM_AMOEBA; i++)
AmoebaCnt[i] = AmoebaCnt2[i] = 0;
{
player->present = TRUE;
player->active = TRUE;
- player->gone = FALSE;
some_player->present = FALSE;
StorePlayer[jx][jy] = player->element_nr;
int jx = player->jx, jy = player->jy;
player->active = FALSE;
- player->gone = TRUE;
StorePlayer[jx][jy] = 0;
Feld[jx][jy] = EL_LEERRAUM;
}
int jx = player->jx, jy = player->jy;
player->active = FALSE;
- player->gone = TRUE;
StorePlayer[jx][jy] = 0;
Feld[jx][jy] = EL_LEERRAUM;
}
}
}
- game_emulation = (emulate_bd ? EMU_BOULDERDASH :
+ game.emulation = (emulate_bd ? EMU_BOULDERDASH :
emulate_sb ? EMU_SOKOBAN :
emulate_sp ? EMU_SUPAPLEX : EMU_NONE);
phase = 7 - phase;
}
- if (game_emulation == EMU_SUPAPLEX)
+ if (game.emulation == EMU_SUPAPLEX)
DrawGraphic(sx, sy, GFX_SP_DISK_RED);
else if (Store[x][y])
DrawGraphicThruMask(sx, sy, graphic + phase);
break;
}
- if (game_emulation == EMU_SUPAPLEX)
+ if (game.emulation == EMU_SUPAPLEX)
Store[x][y] = EL_LEERRAUM;
}
else if (center_element == EL_MAULWURF)
else if (center_element == EL_SP_ELECTRON)
Store[x][y] = EL_SP_INFOTRON;
else if (center_element == EL_MAMPFER)
- Store[x][y] = level.mampfer_inhalt[MampferNr][x-ex+1][y-ey+1];
+ Store[x][y] = level.yam_content[game.yam_content_nr][x-ex+1][y-ey+1];
else if (center_element == EL_AMOEBA2DIAM)
- Store[x][y] = level.amoebe_inhalt;
+ Store[x][y] = level.amoeba_content;
else if (element == EL_ERZ_EDEL)
Store[x][y] = EL_EDELSTEIN;
else if (element == EL_ERZ_DIAM)
}
if (center_element == EL_MAMPFER)
- MampferNr = (MampferNr + 1) % MampferMax;
+ game.yam_content_nr = (game.yam_content_nr + 1) % level.num_yam_contents;
return;
}
{
int graphic = GFX_EXPLOSION;
- if (game_emulation == EMU_SUPAPLEX)
+ if (game.emulation == EMU_SUPAPLEX)
graphic = (Store[x][y] == EL_SP_INFOTRON ?
GFX_SP_EXPLODE_INFOTRON :
GFX_SP_EXPLODE_EMPTY);
{
int element = Feld[x][y];
- if (game_emulation == EMU_SUPAPLEX)
+ if (game.emulation == EMU_SUPAPLEX)
PlaySoundLevel(x, y, SND_SP_BOOOM);
else
PlaySoundLevel(x, y, SND_ROAAAR);
if (Feld[x][y] == smashed)
Feld[x][y] = activated_magic_wall;
- SiebCount = level.dauer_sieb * FRAMES_PER_SECOND;
- SiebAktiv = TRUE;
+ game.magic_wall_time_left = level.time_magic_wall * FRAMES_PER_SECOND;
+ game.magic_wall_active = TRUE;
}
if (IS_PLAYER(x, y+1))
struct PlayerInfo *player = &stored_player[i];
int jx = player->jx, jy = player->jy;
- if (!player->active || player->gone)
+ if (!player->active)
continue;
if (attr_x == -1 || ABS(jx-x)+ABS(jy-y) < ABS(attr_x-x)+ABS(attr_y-y))
{
struct PlayerInfo *player = &stored_player[i];
- if (player->active && !player->gone &&
- player->Pushing && player->MovPos)
+ if (player->active && player->Pushing && player->MovPos)
{
int next_jx = player->jx + (player->jx - player->last_jx);
int next_jy = player->jy + (player->jy - player->last_jy);
if (left || right)
{
- if (left && right && game_emulation != EMU_BOULDERDASH)
+ if (left && right && game.emulation != EMU_BOULDERDASH)
left = !(right = RND(2));
InitMovingField(x, y, left ? MV_LEFT : MV_RIGHT);
else if (Store[x][y] == EL_SIEB_VOLL)
{
Store[x][y] = 0;
- element = Feld[newx][newy] = (SiebAktiv ? EL_SIEB_VOLL : EL_SIEB_TOT);
+ element = Feld[newx][newy] =
+ (game.magic_wall_active ? EL_SIEB_VOLL : EL_SIEB_TOT);
}
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);
+ Feld[x][y] = (game.magic_wall_active ? EL_SIEB_LEER : EL_SIEB_TOT);
}
else if (Store[x][y] == EL_SIEB2_VOLL)
{
Store[x][y] = 0;
- element = Feld[newx][newy] = (SiebAktiv ? EL_SIEB2_VOLL : EL_SIEB2_TOT);
+ element = Feld[newx][newy] =
+ (game.magic_wall_active ? EL_SIEB2_VOLL : EL_SIEB2_TOT);
}
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);
+ Feld[x][y] = (game.magic_wall_active ? EL_SIEB2_LEER : EL_SIEB2_TOT);
}
else if (Store[x][y] == EL_SALZSAEURE)
{
{ 0, +1 }
};
- if (!level.tempo_amoebe)
+ if (!level.amoeba_speed)
{
Feld[ax][ay] = EL_AMOEBE_TOT;
DrawLevelField(ax, ay);
}
if (!MovDelay[ax][ay]) /* start making new amoeba field */
- MovDelay[ax][ay] = RND(FRAMES_PER_SECOND * 25 / (1 + level.tempo_amoebe));
+ MovDelay[ax][ay] = RND(FRAMES_PER_SECOND * 25 / (1 + level.amoeba_speed));
if (MovDelay[ax][ay]) /* wait some time before making new amoeba */
{
if (newax == ax && neway == ay) /* amoeba cannot grow */
{
- if (i == 4 && (!waiting_for_player || game_emulation == EMU_BOULDERDASH))
+ if (i == 4 && (!waiting_for_player || game.emulation == EMU_BOULDERDASH))
{
Feld[ax][ay] = EL_AMOEBE_TOT;
DrawLevelField(ax, ay);
if (element == EL_AMOEBE_VOLL)
AmoebeUmwandeln(ax, ay);
else if (element == EL_AMOEBE_BD)
- AmoebeUmwandelnBD(ax, ay, level.amoebe_inhalt);
+ AmoebeUmwandelnBD(ax, ay, level.amoeba_content);
}
}
return;
void Ablenk(int x, int y)
{
if (!MovDelay[x][y]) /* next animation frame */
- MovDelay[x][y] = level.dauer_ablenk * FRAMES_PER_SECOND;
+ MovDelay[x][y] = level.time_wheel * FRAMES_PER_SECOND;
if (MovDelay[x][y]) /* wait some time before next frame */
{
stored_player_action[player->index_nr] = 0;
num_stored_actions++;
- if (!player->active || player->gone || tape.pausing)
+ if (!player->active || tape.pausing)
return;
if (player_action)
#ifdef DEBUG
#if 0
- if (TimeFrames == 0 && !local_player->gone)
+ if (TimeFrames == 0 && local_player->active)
{
extern unsigned int last_RND();
else if (element == EL_SP_TERMINAL_ACTIVE)
DrawGraphicAnimation(x, y, GFX2_SP_TERMINAL_ACTIVE, 7, 4, ANIM_NORMAL);
- if (SiebAktiv)
+ if (game.magic_wall_active)
{
boolean sieb = FALSE;
int jx = local_player->jx, jy = local_player->jy;
}
}
- if (SiebAktiv)
+ if (game.magic_wall_active)
{
- if (!(SiebCount % 4))
+ if (!(game.magic_wall_time_left % 4))
PlaySoundLevel(sieb_x, sieb_y, SND_MIEP);
- if (SiebCount > 0)
+ if (game.magic_wall_time_left > 0)
{
- SiebCount--;
- if (!SiebCount)
+ game.magic_wall_time_left--;
+ if (!game.magic_wall_time_left)
{
for (y=0; y<lev_fieldy; y++) for (x=0; x<lev_fieldx; x++)
{
}
}
- SiebAktiv = FALSE;
+ game.magic_wall_active = FALSE;
}
}
}
{
int jx = stored_player[i].jx, jy = stored_player[i].jy;
- if (!stored_player[i].active || stored_player[i].gone ||
- &stored_player[i] == player)
+ if (!stored_player[i].active || &stored_player[i] == player)
continue;
min_x = MIN(min_x, jx);
{
int jx = stored_player[i].jx, jy = stored_player[i].jy;
- if (!stored_player[i].active || stored_player[i].gone)
+ if (!stored_player[i].active)
continue;
if (!IN_VIS_FIELD(SCREENX(jx), SCREENY(jy)))
int element;
int can_move;
- if (player->gone || (!dx && !dy))
+ if (!player->active || (!dx && !dy))
return MF_NO_ACTION;
player->MovDir = (dx < 0 ? MV_LEFT :
int old_jx = jx, old_jy = jy;
int moved = MF_NO_ACTION;
- if (player->gone || (!dx && !dy))
+ if (!player->active || (!dx && !dy))
return FALSE;
if (!FrameReached(&player->move_delay, player->move_delay_value) &&
TestIfHeroHitsBadThing(jx, jy);
- if (player->gone)
+ if (!player->active)
RemoveHero(player);
return moved;
int last_jx = player->last_jx, last_jy = player->last_jy;
int move_stepsize = TILEX / player->move_delay_value;
- if (!player->active || player->gone || !player->MovPos)
+ if (!player->active || !player->MovPos)
return;
if (mode == SCROLL_INIT)
{
int jx = player->jx, jy = player->jy;
- if (player->gone)
+ if (!player->active)
return;
if (IS_PFORTE(Feld[jx][jy]))
{
int jx = player->jx, jy = player->jy;
- if (player->gone)
+ if (!player->active)
return;
PlaySoundLevel(jx, jy, SND_AUTSCH);
int jx = player->jx, jy = player->jy;
int i, found = FALSE;
- player->gone = TRUE;
+ player->present = FALSE;
+ player->active = FALSE;
+
StorePlayer[jx][jy] = 0;
for (i=0; i<MAX_PLAYERS; i++)
- if (stored_player[i].active && !stored_player[i].gone)
+ if (stored_player[i].active)
found = TRUE;
if (!found)
if (IS_SB_ELEMENT(element) &&
local_player->sokobanfields_still_needed == 0 &&
- game_emulation == EMU_SOKOBAN)
+ game.emulation == EMU_SOKOBAN)
{
player->LevelSolved = player->GameOver = TRUE;
PlaySoundLevel(x, y, SND_BUING);
int jx = player->jx, jy = player->jy;
int x = jx + dx, y = jy + dy;
- if (player->gone || !IN_LEV_FIELD(x, y))
+ if (!player->active || !IN_LEV_FIELD(x, y))
return FALSE;
if (dx && dy)
int jx = player->jx, jy = player->jy;
int element;
- if (player->gone || player->MovPos)
+ if (!player->active || player->MovPos)
return FALSE;
element = Feld[jx][jy];
FS_SMALL, FC_YELLOW);
if (IN_SCR_FIELD(SCREENX(jx), SCREENY(jy)))
{
- if (game_emulation == EMU_SUPAPLEX)
+ if (game.emulation == EMU_SUPAPLEX)
DrawGraphic(SCREENX(jx), SCREENY(jy), GFX_SP_DISK_RED);
else
DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), GFX_DYNAMIT);
int ZX,ZY, ExitX,ExitY;
int AllPlayersGone;
int FrameCounter, TimeFrames, TimePlayed, TimeLeft;
-int MampferMax, MampferNr;
-boolean SiebAktiv;
-int SiebCount;
-
-int game_emulation = EMU_NONE;
boolean network_player_action_received = FALSE;
struct SetupInfo setup;
struct SetupFileList *setup_list = NULL;
struct SetupFileList *level_setup_list = NULL;
+struct GameInfo game;
+struct GlobalInfo global;
/* data needed for playing sounds */
char *sound_name[NUM_SOUNDS] =
#define MAX_ELEMENTS 512
#define MAX_NUM_AMOEBA 100
+/* values for elements with content */
+#define MIN_ELEMENT_CONTENTS 1
+#define STD_ELEMENT_CONTENTS 4
+#define MAX_ELEMENT_CONTENTS 8
+
#define LEVEL_SCORE_ELEMENTS 16 /* level elements with score */
/* fundamental game speed values */
byte programmed_action; /* action forced by game itself (like moving
through doors); overrides other actions */
-
-#if 0
- byte programmed_speed; /* speed (for only one move) forced by game */
-#endif
-
-
int joystick_fd; /* file descriptor of player's joystick */
int jx,jy, last_jx,last_jy;
int Frame;
boolean Pushing;
- boolean gone, LevelSolved, GameOver;
+ boolean LevelSolved, GameOver;
boolean snapped;
unsigned long move_delay;
int fieldx;
int fieldy;
int time;
- int edelsteine;
+ int gems_needed;
char name[MAX_LEVEL_NAME_LEN + 1];
char author[MAX_LEVEL_AUTHOR_LEN + 1];
int score[LEVEL_SCORE_ELEMENTS];
- int mampfer_inhalt[8][3][3];
- int tempo_amoebe;
- int dauer_sieb;
- int dauer_ablenk;
- int amoebe_inhalt;
+ int yam_content[MAX_ELEMENT_CONTENTS][3][3];
+ int num_yam_contents;
+ int amoeba_speed;
+ int amoeba_content;
+ int time_magic_wall;
+ int time_wheel;
boolean double_speed;
boolean gravity;
};
} pos[MAX_TAPELEN];
};
+struct GameInfo
+{
+ int emulation;
+ int yam_content_nr;
+ boolean magic_wall_active;
+ int magic_wall_time_left;
+};
+
+struct GlobalInfo
+{
+};
+
extern Display *display;
extern Visual *visual;
extern int screen;
extern int ZX,ZY, ExitX,ExitY;
extern int AllPlayersGone;
extern int FrameCounter, TimeFrames, TimePlayed, TimeLeft;
-extern int MampferMax, MampferNr;
extern boolean SiebAktiv;
extern int SiebCount;
-extern int game_emulation;
-
extern boolean network_player_action_received;
extern struct LevelDirInfo leveldir[];
extern struct SetupInfo setup;
extern struct SetupFileList *setup_list;
extern struct SetupFileList *level_setup_list;
+extern struct GameInfo game;
+extern struct GlobalInfo global;
extern char *sound_name[];
extern int background_loop[];
return ptr;
}
-void getFileChunk(FILE *file, char *chunk_buffer, int *chunk_length,
- int byte_order)
+short getFile16BitInteger(FILE *file, int byte_order)
{
- const int chunk_identifier_length = 4;
-
- fgets(chunk_buffer, chunk_identifier_length + 1, file);
+ if (byte_order == BYTE_ORDER_BIG_ENDIAN)
+ return ((fgetc(file) << 8) |
+ (fgetc(file) << 0));
+ else /* BYTE_ORDER_LITTLE_ENDIAN */
+ return ((fgetc(file) << 0) |
+ (fgetc(file) << 8));
+}
+void putFile16BitInteger(FILE *file, short value, int byte_order)
+{
if (byte_order == BYTE_ORDER_BIG_ENDIAN)
- *chunk_length = ((fgetc(file) << 24) |
- (fgetc(file) << 16) |
- (fgetc(file) << 8) |
- (fgetc(file) << 0));
+ {
+ fputc((value >> 8) & 0xff, file);
+ fputc((value >> 0) & 0xff, file);
+ }
else /* BYTE_ORDER_LITTLE_ENDIAN */
- *chunk_length = ((fgetc(file) << 0) |
- (fgetc(file) << 8) |
- (fgetc(file) << 16) |
- (fgetc(file) << 24));
+ {
+ fputc((value >> 0) & 0xff, file);
+ fputc((value >> 8) & 0xff, file);
+ }
}
-void putFileChunk(FILE *file, char *chunk_name, int chunk_length,
- int byte_order)
+int getFile32BitInteger(FILE *file, int byte_order)
{
- fputs(chunk_name, file);
+ if (byte_order == BYTE_ORDER_BIG_ENDIAN)
+ return ((fgetc(file) << 24) |
+ (fgetc(file) << 16) |
+ (fgetc(file) << 8) |
+ (fgetc(file) << 0));
+ else /* BYTE_ORDER_LITTLE_ENDIAN */
+ return ((fgetc(file) << 0) |
+ (fgetc(file) << 8) |
+ (fgetc(file) << 16) |
+ (fgetc(file) << 24));
+}
+void putFile32BitInteger(FILE *file, int value, int byte_order)
+{
if (byte_order == BYTE_ORDER_BIG_ENDIAN)
{
- fputc((chunk_length >> 24) & 0xff, file);
- fputc((chunk_length >> 16) & 0xff, file);
- fputc((chunk_length >> 8) & 0xff, file);
- fputc((chunk_length >> 0) & 0xff, file);
+ fputc((value >> 24) & 0xff, file);
+ fputc((value >> 16) & 0xff, file);
+ fputc((value >> 8) & 0xff, file);
+ fputc((value >> 0) & 0xff, file);
}
else /* BYTE_ORDER_LITTLE_ENDIAN */
{
- fputc((chunk_length >> 0) & 0xff, file);
- fputc((chunk_length >> 8) & 0xff, file);
- fputc((chunk_length >> 16) & 0xff, file);
- fputc((chunk_length >> 24) & 0xff, file);
+ fputc((value >> 0) & 0xff, file);
+ fputc((value >> 8) & 0xff, file);
+ fputc((value >> 16) & 0xff, file);
+ fputc((value >> 24) & 0xff, file);
}
}
+void getFileChunk(FILE *file, char *chunk_buffer, int *chunk_length,
+ int byte_order)
+{
+ const int chunk_identifier_length = 4;
+
+ /* read chunk identifier */
+ fgets(chunk_buffer, chunk_identifier_length + 1, file);
+
+ /* read chunk length */
+ *chunk_length = getFile32BitInteger(file, byte_order);
+}
+
+void putFileChunk(FILE *file, char *chunk_name, int chunk_length,
+ int byte_order)
+{
+ /* write chunk identifier */
+ fputs(chunk_name, file);
+
+ /* write chunk length */
+ putFile32BitInteger(file, chunk_length, byte_order);
+}
+
#define TRANSLATE_KEYSYM_TO_KEYNAME 0
#define TRANSLATE_KEYSYM_TO_X11KEYNAME 1
#define TRANSLATE_X11KEYNAME_TO_KEYSYM 2
#define ERR_EXIT_NETWORK_SERVER (ERR_EXIT | ERR_NETWORK_SERVER)
#define ERR_EXIT_NETWORK_CLIENT (ERR_EXIT | ERR_NETWORK_CLIENT)
-/* values for getFileChunk() and putFileChunk() */
+/* values for getFile...() and putFile...() */
#define BYTE_ORDER_BIG_ENDIAN 0
#define BYTE_ORDER_LITTLE_ENDIAN 1
void Error(int, char *, ...);
void *checked_malloc(unsigned long);
void *checked_calloc(unsigned long);
+short getFile16BitInteger(FILE *, int);
+void putFile16BitInteger(FILE *, short, int);
+int getFile32BitInteger(FILE *, int);
+void putFile32BitInteger(FILE *, int, int);
void getFileChunk(FILE *, char *, int *, int);
void putFileChunk(FILE *, char *, int, int);
char *getKeyNameFromKeySym(KeySym);
int graphic, phase;
boolean player_is_moving = (last_jx != jx || last_jy != jy ? TRUE : FALSE);
- if (!player->active || player->gone ||
- !IN_SCR_FIELD(SCREENX(last_jx), SCREENY(last_jy)))
+ if (!player->active || !IN_SCR_FIELD(SCREENX(last_jx), SCREENY(last_jy)))
return;
#if DEBUG
/* draw player himself */
- if (game_emulation == EMU_SUPAPLEX)
+ if (game.emulation == EMU_SUPAPLEX)
{
static int last_dir = MV_LEFT;
int action = (player->programmed_action ? player->programmed_action :
phase = 7 - phase;
}
- if (game_emulation == EMU_SUPAPLEX)
+ if (game.emulation == EMU_SUPAPLEX)
DrawGraphic(sx, sy, GFX_SP_DISK_RED);
else
DrawGraphicThruMask(sx, sy, graphic + phase);