#include "main.h"
-/* List values that are not defined in the configuration file are set to
- reliable default values. If that value is GFX_ARG_UNDEFINED, it will
- be dynamically determined, using some of the other list values. */
+// List values that are not defined in the configuration file are set to
+// reliable default values. If that value is GFX_ARG_UNDEFINED, it will
+// be dynamically determined, using some of the other list values.
struct ConfigTypeInfo image_config_suffix[] =
{
{ "door_2.top_border_correction.width", "108" },
{ "door_2.top_border_correction.height", "8" },
- /* the last image entry apparently gets overwritten by very last entry
- of "image_config[]"; so far this bug could not be found and fixed */
+ // the last image entry apparently gets overwritten by very last entry
+ // of "image_config[]"; so far this bug could not be found and fixed
{ "last_image_entry_bug", UNDEFINED_FILENAME },
// non-image definitions
// ==========================================================================
- /* the following directives are not associated with an image, but
- probably make sense to be defined in "graphicsinfo.conf", too */
+ // the following directives are not associated with an image, but
+ // probably make sense to be defined in "graphicsinfo.conf", too
// keyword to start parser: "CONFIG_VARS_START" <-- do not change!
#include "main.h"
-/* List values that are not defined in the configuration file are set to
- reliable default values. If that value is GFX_ARG_UNDEFINED, it will
- be dynamically determined, using some of the other list values. */
+// List values that are not defined in the configuration file are set to
+// reliable default values. If that value is GFX_ARG_UNDEFINED, it will
+// be dynamically determined, using some of the other list values.
struct ConfigInfo helpanim_config[] =
{
#include "main.h"
-/* List values that are not defined in the configuration file are set to
- reliable default values. If that value is MUS_ARG_UNDEFINED, it will
- be dynamically determined, using some of the other list values. */
+// List values that are not defined in the configuration file are set to
+// reliable default values. If that value is MUS_ARG_UNDEFINED, it will
+// be dynamically determined, using some of the other list values.
struct ConfigTypeInfo music_config_suffix[] =
{
{ "background.titlemessage_4", UNDEFINED_FILENAME },
{ "background.titlemessage_5", UNDEFINED_FILENAME },
- /* there is no definition for "background.PLAYING", because this would
- prevent selecting music from music directory that is not defined in
- "musicinfo.conf", when no default music is defined here */
+ // there is no definition for "background.PLAYING", because this would
+ // prevent selecting music from music directory that is not defined in
+ // "musicinfo.conf", when no default music is defined here
{ NULL, NULL }
};
#include "main.h"
-/* List values that are not defined in the configuration file are set to
- reliable default values. If that value is SND_ARG_UNDEFINED, it will
- be dynamically determined, using some of the other list values. */
+// List values that are not defined in the configuration file are set to
+// reliable default values. If that value is SND_ARG_UNDEFINED, it will
+// be dynamically determined, using some of the other list values.
struct ConfigTypeInfo sound_config_suffix[] =
{
#define INFOTEXT_UNKNOWN_ELEMENT "unknown"
-/*
- -----------------------------------------------------------------------------
- screen and artwork graphic pixel position definitions
- -----------------------------------------------------------------------------
-*/
+// ----------------------------------------------------------------------------
+// screen and artwork graphic pixel position definitions
+// ----------------------------------------------------------------------------
// values for the control window
#define ED_CTRL1_BUTTONS_HORIZ 4 // toolbox
SYSIZE - INFOTEXT_YSIZE)
-/*
- -----------------------------------------------------------------------------
- editor gadget definitions
- -----------------------------------------------------------------------------
-*/
+// ----------------------------------------------------------------------------
+// editor gadget definitions
+// ----------------------------------------------------------------------------
enum
{
#define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
-/*
- -----------------------------------------------------------------------------
- some internally used definitions
- -----------------------------------------------------------------------------
-*/
+// ----------------------------------------------------------------------------
+// some internally used definitions
+// ----------------------------------------------------------------------------
// values for CopyLevelToUndoBuffer()
#define UNDO_IMMEDIATE 0
#define DEFAULT_EDITOR_TILESIZE_MM TILESIZE
-/*
- -----------------------------------------------------------------------------
- some internally used data structure definitions
- -----------------------------------------------------------------------------
-*/
+// ----------------------------------------------------------------------------
+// some internally used data structure definitions
+// ----------------------------------------------------------------------------
static struct
{
char shortcut;
} controlbutton_info[ED_NUM_CTRL_BUTTONS] =
{
- /* note: some additional characters are already reserved for "cheat mode"
- shortcuts (":XYZ" style) -- for details, see "events.c" */
+ // note: some additional characters are already reserved for "cheat mode"
+ // shortcuts (":XYZ" style) -- for details, see "events.c"
// ---------- toolbox control buttons ---------------------------------------
};
-/*
- -----------------------------------------------------------------------------
- some internally used variables
- -----------------------------------------------------------------------------
-*/
+// ----------------------------------------------------------------------------
+// some internally used variables
+// ----------------------------------------------------------------------------
// maximal size of level editor drawing area
static int MAX_ED_FIELDX, MAX_ED_FIELDY;
};
-/*
- -----------------------------------------------------------------------------
- functions
- -----------------------------------------------------------------------------
-*/
+// ----------------------------------------------------------------------------
+// functions
+// ----------------------------------------------------------------------------
static int getMaxInfoTextLength(void)
{
if (selectbox_info[i].size == -1) // dynamically determine size
{
- /* (we cannot use -1 for uninitialized values if we directly compare
- with results from strlen(), because the '<' and '>' operation will
- implicitely cast -1 to an unsigned integer value!) */
+ // (we cannot use -1 for uninitialized values if we directly compare
+ // with results from strlen(), because the '<' and '>' operation will
+ // implicitely cast -1 to an unsigned integer value!)
selectbox_info[i].size = 0;
for (j = 0; selectbox_info[i].options[j].text != NULL; j++)
radius = (int)(sqrt((float)(len_x * len_x + len_y * len_y)) + 0.5);
- /* not optimal (some points get drawn twice) but simple,
- and fast enough for the few points we are drawing */
+ // not optimal (some points get drawn twice) but simple,
+ // and fast enough for the few points we are drawing
for (x = 0; x <= radius; x++)
{
case GADGET_ID_SAVE:
{
- /* saving read-only levels into personal level set modifies global vars
- "leveldir_current" and "level_nr"; restore them after saving level */
+ // saving read-only levels into personal level set modifies global vars
+ // "leveldir_current" and "level_nr"; restore them after saving level
LevelDirTree *leveldir_former = leveldir_current;
int level_nr_former = level_nr;
char *level_filename;
static void HandleEventActions(void);
-/* event filter especially needed for SDL event filtering due to
- delay problems with lots of mouse motion events when mouse button
- not pressed (X11 can handle this with 'PointerMotionHintMask') */
+// event filter especially needed for SDL event filtering due to
+// delay problems with lots of mouse motion events when mouse button
+// not pressed (X11 can handle this with 'PointerMotionHintMask')
-/* event filter addition for SDL2: as SDL2 does not have a function to enable
- or disable keyboard auto-repeat, filter repeated keyboard events instead */
+// event filter addition for SDL2: as SDL2 does not have a function to enable
+// or disable keyboard auto-repeat, filter repeated keyboard events instead
static int FilterEvents(const Event *event)
{
return 1;
}
-/* to prevent delay problems, skip mouse motion events if the very next
- event is also a mouse motion event (and therefore effectively only
- handling the last of a row of mouse motion events in the event queue) */
+// to prevent delay problems, skip mouse motion events if the very next
+// event is also a mouse motion event (and therefore effectively only
+// handling the last of a row of mouse motion events in the event queue)
static boolean SkipPressedMouseMotionEvent(const Event *event)
{
case EVENT_UNMAPNOTIFY:
#if 0
- /* This causes the game to stop not only when iconified, but also
- when on another virtual desktop, which might be not desired. */
+ // This causes the game to stop not only when iconified, but also
+ // when on another virtual desktop, which might be not desired.
SleepWhileUnmapped();
#endif
break;
// execute event related actions after pending events have been processed
HandleEventActions();
- /* don't use all CPU time when idle; the main loop while playing
- has its own synchronization and is CPU friendly, too */
+ // don't use all CPU time when idle; the main loop while playing
+ // has its own synchronization and is CPU friendly, too
if (game_status == GAME_MODE_PLAYING)
HandleGameActions();
break;
case EVENT_UNMAPNOTIFY:
- /* this is only to surely prevent the 'should not happen' case
- * of recursively looping between 'SleepWhileUnmapped()' and
- * 'HandleOtherEvents()' which usually calls this funtion.
- */
+ // this is only to surely prevent the 'should not happen' case
+ // of recursively looping between 'SleepWhileUnmapped()' and
+ // 'HandleOtherEvents()' which usually calls this funtion.
break;
default:
The effect would be keyboard auto repeat while playing the game
(game_status == GAME_MODE_PLAYING), which is not desired.
To avoid this special case, we just wait 1/10 second before
- processing the 'FocusIn' event.
- */
+ processing the 'FocusIn' event. */
if (game_status == GAME_MODE_PLAYING)
{
}
}
- /* Currently there is no special action needed to activate the template
- data, because 'element_info' property settings overwrite the original
- level data, while all other variables do not change. */
+ // Currently there is no special action needed to activate the template
+ // data, because 'element_info' property settings overwrite the original
+ // level data, while all other variables do not change.
- /* Exception: 'from_level_template' elements in the original level playfield
- are overwritten with the corresponding elements at the same position in
- playfield from the level template. */
+ // Exception: 'from_level_template' elements in the original level playfield
+ // are overwritten with the corresponding elements at the same position in
+ // playfield from the level template.
for (x = 0; x < level.fieldx; x++)
for (y = 0; y < level.fieldy; y++)
static boolean checkForPackageFromBasename(char *basename)
{
- /* !!! WON'T WORK ANYMORE IF getFileTypeFromBasename() ALSO DETECTS !!!
- !!! SINGLE LEVELS (CURRENTLY ONLY DETECTS LEVEL PACKAGES !!! */
+ // !!! WON'T WORK ANYMORE IF getFileTypeFromBasename() ALSO DETECTS !!!
+ // !!! SINGLE LEVELS (CURRENTLY ONLY DETECTS LEVEL PACKAGES !!!
return (getFileTypeFromBasename(basename) != LEVEL_FILE_TYPE_UNKNOWN);
}
else
Error(ERR_WARN, "invalid custom element number %d", element);
- /* older game versions that wrote level files with CUS1 chunks used
- different default push delay values (not yet stored in level file) */
+ // older game versions that wrote level files with CUS1 chunks used
+ // different default push delay values (not yet stored in level file)
element_info[element].push_delay_fixed = 2;
element_info[element].push_delay_random = 8;
}
int chunk_size_expected =
(chunk_info[i].loader)(file, chunk_size, level);
- /* the size of some chunks cannot be checked before reading other
- chunks first (like "HEAD" and "BODY") that contain some header
- information, so check them here */
+ // the size of some chunks cannot be checked before reading other
+ // chunks first (like "HEAD" and "BODY") that contain some header
+ // information, so check them here
if (chunk_size_expected != chunk_size)
{
Error(ERR_WARN, "wrong size (%d) of chunk '%s' in level file '%s'",
else if (element >= EL_SP_GRAVITY_PORT_RIGHT &&
element <= EL_SP_GRAVITY_PORT_UP)
{
- /* change R'n'D style gravity inverting special port to normal port
- (there are no gravity inverting ports in native Supaplex engine) */
+ // change R'n'D style gravity inverting special port to normal port
+ // (there are no gravity inverting ports in native Supaplex engine)
gravity_port_found = TRUE;
gravity_port_valid = FALSE;
continue;
}
- /* change previous (wrong) gravity inverting special port to either
- gravity enabling special port or gravity disabling special port */
+ // change previous (wrong) gravity inverting special port to either
+ // gravity enabling special port or gravity disabling special port
level->field[port_x][port_y] +=
(gravity == 1 ? EL_SP_GRAVITY_ON_PORT_RIGHT :
EL_SP_GRAVITY_OFF_PORT_RIGHT) - EL_SP_GRAVITY_PORT_RIGHT;
level->extra_time = header[56] | (header[57] << 8);
level->shield_normal_time = header[58] | (header[59] << 8);
- /* Diamond Caves has the same (strange) behaviour as Emerald Mine that gems
- can slip down from flat walls, like normal walls and steel walls */
+ // Diamond Caves has the same (strange) behaviour as Emerald Mine that gems
+ // can slip down from flat walls, like normal walls and steel walls
level->em_slippery_gems = TRUE;
}
{
int i, j;
- /* map custom element change events that have changed in newer versions
- (these following values were accidentally changed in version 3.0.1)
- (this seems to be needed only for 'ab_levelset3' and 'ab_levelset4') */
+ // map custom element change events that have changed in newer versions
+ // (these following values were accidentally changed in version 3.0.1)
+ // (this seems to be needed only for 'ab_levelset3' and 'ab_levelset4')
if (level->game_version <= VERSION_IDENT(3,0,0,0))
{
for (i = 0; i < NUM_CUSTOM_ELEMENTS; i++)
int chunk_size_expected =
(chunk_info[i].loader)(file, chunk_size, &tape);
- /* the size of some chunks cannot be checked before reading other
- chunks first (like "HEAD" and "BODY") that contain some header
- information, so check them here */
+ // the size of some chunks cannot be checked before reading other
+ // chunks first (like "HEAD" and "BODY") that contain some header
+ // information, so check them here
if (chunk_size_expected != chunk_size)
{
Error(ERR_WARN, "wrong size (%d) of chunk '%s' in tape file '%s'",
static int get_inventory_element_from_pos(struct PlayerInfo *player, int pos)
{
- /* pos >= 0: get element from bottom of the stack;
- pos < 0: get element from top of the stack */
+ // pos >= 0: get element from bottom of the stack;
+ // pos < 0: get element from top of the stack
if (pos < 0)
{
}
-/*
- =============================================================================
- InitGameEngine()
- -----------------------------------------------------------------------------
- initialize game engine due to level / tape version number
- =============================================================================
-*/
+// ============================================================================
+// InitGameEngine()
+// ----------------------------------------------------------------------------
+// initialize game engine due to level / tape version number
+// ============================================================================
static void InitGameEngine(void)
{
}
-/*
- =============================================================================
- InitGame()
- -----------------------------------------------------------------------------
- initialize and start new game
- =============================================================================
-*/
+// ============================================================================
+// InitGame()
+// ----------------------------------------------------------------------------
+// initialize and start new game
+// ============================================================================
#if DEBUG_INIT_PLAYER
static void DebugPrintPlayerStatus(char *message)
}
else if (network.enabled)
{
- /* add team mode players connected over the network (needed for correct
- assignment of player figures from level to locally playing players) */
+ // add team mode players connected over the network (needed for correct
+ // assignment of player figures from level to locally playing players)
for (i = 0; i < MAX_PLAYERS; i++)
if (stored_player[i].connected_network)
}
else if (game.team_mode)
{
- /* try to guess locally connected team mode players (needed for correct
- assignment of player figures from level to locally playing players) */
+ // try to guess locally connected team mode players (needed for correct
+ // assignment of player figures from level to locally playing players)
for (i = 0; i < MAX_PLAYERS; i++)
if (setup.input[i].use_joystick ||
if (EVEN(SCR_FIELDY) && full_lev_fieldy > SCR_FIELDY)
SBY_Upper--;
- /* if local player not found, look for custom element that might create
- the player (make some assumptions about the right custom element) */
+ // if local player not found, look for custom element that might create
+ // the player (make some assumptions about the right custom element)
if (!local_player->present)
{
int start_x = 0, start_y = 0;
is_moving_before = (WasJustMoving[x][y] != 0);
is_moving_after = (getElementMoveStepsizeExt(x, y, direction) != 0);
- /* reset animation only for moving elements which change direction of moving
- or which just started or stopped moving
- (else CEs with property "can move" / "not moving" are reset each frame) */
+ // reset animation only for moving elements which change direction of moving
+ // or which just started or stopped moving
+ // (else CEs with property "can move" / "not moving" are reset each frame)
if (is_moving_before != is_moving_after ||
direction != MovDir[x][y])
ResetGfxAnimation(x, y);
static int MovingOrBlocked2ElementIfNotLeaving(int x, int y)
{
- /* like MovingOrBlocked2Element(), but if element is moving
- and (x,y) is the field the moving element is just leaving,
- return EL_BLOCKED instead of the element value */
+ // like MovingOrBlocked2Element(), but if element is moving
+ // and (x,y) is the field the moving element is just leaving,
+ // return EL_BLOCKED instead of the element value
int element = Feld[x][y];
if (IS_MOVING(x, y))
if (Feld[newx][newy] != EL_BLOCKED)
{
- /* element is moving, but target field is not free (blocked), but
- already occupied by something different (example: acid pool);
- in this case, only remove the moving field, but not the target */
+ // element is moving, but target field is not free (blocked), but
+ // already occupied by something different (example: acid pool);
+ // in this case, only remove the moving field, but not the target
RemoveField(oldx, oldy);
Store[x][y] = EL_EMPTY;
}
- /* !!! check this case -- currently needed for rnd_rado_negundo_v,
- !!! levels 015 018 019 020 021 022 023 026 027 028 !!! */
+ // !!! check this case -- currently needed for rnd_rado_negundo_v,
+ // !!! levels 015 018 019 020 021 022 023 026 027 028 !!!
else if (ELEM_IS_PLAYER(center_element))
Store[x][y] = EL_EMPTY;
else if (center_element == EL_YAMYAM)
else if (element_info[center_element].content.e[xx][yy] != EL_EMPTY)
Store[x][y] = element_info[center_element].content.e[xx][yy];
#if 1
- /* needed because EL_BD_BUTTERFLY is not defined as "CAN_EXPLODE"
- (killing EL_BD_BUTTERFLY with dynamite would result in BD diamond
- otherwise) -- FIX THIS !!! */
+ // needed because EL_BD_BUTTERFLY is not defined as "CAN_EXPLODE"
+ // (killing EL_BD_BUTTERFLY with dynamite would result in BD diamond
+ // otherwise) -- FIX THIS !!!
else if (!CAN_EXPLODE(element) && element != EL_BD_BUTTERFLY)
Store[x][y] = element_info[element].content.e[1][1];
#else
border_explosion = TRUE;
}
- /* if an element just explodes due to another explosion (chain-reaction),
- do not immediately end the new explosion when it was the last frame of
- the explosion (as it would be done in the following "if"-statement!) */
+ // if an element just explodes due to another explosion (chain-reaction),
+ // do not immediately end the new explosion when it was the last frame of
+ // the explosion (as it would be done in the following "if"-statement!)
if (border_explosion && phase == last_phase)
return;
}
if (!MovDelay[x][y]) // start new movement phase
{
- /* all objects that can change their move direction after each step
- (YAMYAM, DARK_YAMYAM and PACMAN go straight until they hit a wall */
+ // all objects that can change their move direction after each step
+ // (YAMYAM, DARK_YAMYAM and PACMAN go straight until they hit a wall
if (element != EL_YAMYAM &&
element != EL_DARK_YAMYAM &&
Feld[x][y] = EL_EMPTY;
TEST_DrawLevelField(x, y);
- /* don't let mole enter this field in this cycle;
- (give priority to objects falling to this field from above) */
+ // don't let mole enter this field in this cycle;
+ // (give priority to objects falling to this field from above)
Stop[x][y] = TRUE;
}
}
TEST_DrawLevelFieldCrumbledNeighbours(x, y);
}
- /* check if element under the player changes from accessible to unaccessible
- (needed for special case of dropping element which then changes) */
+ // check if element under the player changes from accessible to unaccessible
+ // (needed for special case of dropping element which then changes)
// (must be checked after creating new element for walkable group elements)
if (IS_PLAYER(x, y) && !player_explosion_protected &&
IS_ACCESSIBLE(old_element) && !IS_ACCESSIBLE(new_element))
{
int old_element = Feld[x][y];
- /* prevent changed element from moving in same engine frame
- unless both old and new element can either fall or move */
+ // prevent changed element from moving in same engine frame
+ // unless both old and new element can either fall or move
if ((!CAN_FALL(old_element) || !CAN_FALL(element)) &&
(!CAN_MOVE(old_element) || !CAN_MOVE(element)))
Stop[x][y] = TRUE;
This can also be seen from the debug output for this test element.)
*/
- /* when a custom element is about to change (for example by change delay),
- do not reset graphic animation when the custom element is moving */
+ // when a custom element is about to change (for example by change delay),
+ // do not reset graphic animation when the custom element is moving
if (game.graphics_engine_version < 4 &&
!IS_MOVING(x, y))
{
{
if (change->can_change && !change_done)
{
- /* if element already changed in this frame, not only prevent
- another element change (checked in ChangeElement()), but
- also prevent additional element actions for this element */
+ // if element already changed in this frame, not only prevent
+ // another element change (checked in ChangeElement()), but
+ // also prevent additional element actions for this element
if (ChangeCount[x][y] >= game.max_num_changes_per_frame &&
!level.use_action_after_change_bug)
}
else if (change->has_action)
{
- /* if element already changed in this frame, not only prevent
- another element change (checked in ChangeElement()), but
- also prevent additional element actions for this element */
+ // if element already changed in this frame, not only prevent
+ // another element change (checked in ChangeElement()), but
+ // also prevent additional element actions for this element
if (ChangeCount[x][y] >= game.max_num_changes_per_frame &&
!level.use_action_after_change_bug)
int chunk_size_expected =
(chunk_info[i].loader)(file, chunk_size, &native_mm_level);
- /* the size of some chunks cannot be checked before reading other
- chunks first (like "HEAD" and "BODY") that contain some header
- information, so check them here */
+ // the size of some chunks cannot be checked before reading other
+ // chunks first (like "HEAD" and "BODY") that contain some header
+ // information, so check them here
if (chunk_size_expected != chunk_size)
Error(ERR_WARN, "wrong size (%d) of chunk '%s' in level file '%s'",
chunk_size, chunk_name, filename);
{
if (button == MB_LEFTBUTTON)
{
- /* left mouse button only for manual adjustment, no auto-rotating;
- freeze mirror for until mouse button released */
+ // left mouse button only for manual adjustment, no auto-rotating;
+ // freeze mirror for until mouse button released
hold_x = x;
hold_y = y;
}
#define WALL_TOP (WALL_TOPLEFT | WALL_TOPRIGHT)
#define WALL_BOTTOM (WALL_BOTTOMLEFT | WALL_BOTTOMRIGHT)
-/* game elements:
-** 0 - 499: real elements, stored in level file
-** 500 - 699: flag elements, only used at runtime
-*/
+// game elements:
+// 0 - 499: real elements, stored in level file
+// 500 - 699: flag elements, only used at runtime
+
// "real" level elements
#define EL_MM_START 0
#define EL_MM_START_1 EL_MM_START
#define EL_MM_MASK_CIRCLE 709
-/* game graphics:
-** 0 - 191: graphics from "MirrorScreen"
-** 192 - 255: pseudo graphics mapped to "MirrorScreen"
-** 256 - 511: graphics from "MirrorFont"
-** 512 - 767: graphics from "MirrorDF"
-*/
+// game graphics:
+// 0 - 191: graphics from "MirrorScreen"
+// 192 - 255: pseudo graphics mapped to "MirrorScreen"
+// 256 - 511: graphics from "MirrorFont"
+// 512 - 767: graphics from "MirrorDF"
#define IMG_EMPTY IMG_EMPTY_SPACE
#define MM_VERSION_MINOR(x) VERSION_PART_2(x)
#define MM_VERSION_PATCH(x) VERSION_PART_3(x)
-/* file version numbers for resource files (levels, score, setup, etc.)
-** currently supported/known file version numbers:
-** 1.4 (still in use)
-** 2.0 (actual)
-*/
+// file version numbers for resource files (levels, score, setup, etc.)
+// currently supported/known file version numbers:
+// 1.4 (still in use)
+// 2.0 (actual)
+
#define MM_FILE_VERSION_1_4 MM_VERSION_IDENT(1,4,0)
#define MM_FILE_VERSION_2_0 MM_VERSION_IDENT(2,0,0)
-/* file version does not change for every program version, but is changed
- when new features are introduced that are incompatible with older file
- versions, so that they can be treated accordingly */
+// file version does not change for every program version, but is changed
+// when new features are introduced that are incompatible with older file
+// versions, so that they can be treated accordingly
#define MM_FILE_VERSION_ACTUAL MM_FILE_VERSION_2_0
#define MM_GAME_VERSION_ACTUAL MM_VERSION_IDENT(PROGRAM_VERSION_MAJOR, \
-/***********************************************************
-* Mirror Magic -- McDuffin's Revenge *
-*----------------------------------------------------------*
-* (c) 1994-2001 Artsoft Entertainment *
-* Holger Schemel *
-* Detmolder Strasse 189 *
-* 33604 Bielefeld *
-* Germany *
-* e-mail: info@artsoft.org *
-*----------------------------------------------------------*
-* tools.c *
-***********************************************************/
+// ============================================================================
+// Mirror Magic -- McDuffin's Revenge
+// ----------------------------------------------------------------------------
+// (c) 1994-2017 by Artsoft Entertainment
+// Holger Schemel
+// info@artsoft.org
+// http://www.artsoft.org/
+// ----------------------------------------------------------------------------
+// mm_tools.c
+// ============================================================================
#include "main_mm.h"
-/***********************************************************
-* Mirror Magic -- McDuffin's Revenge *
-*----------------------------------------------------------*
-* (c) 1994-2001 Artsoft Entertainment *
-* Holger Schemel *
-* Detmolder Strasse 189 *
-* 33604 Bielefeld *
-* Germany *
-* e-mail: info@artsoft.org *
-*----------------------------------------------------------*
-* tools.h *
-***********************************************************/
+// ============================================================================
+// Mirror Magic -- McDuffin's Revenge
+// ----------------------------------------------------------------------------
+// (c) 1994-2017 by Artsoft Entertainment
+// Holger Schemel
+// info@artsoft.org
+// http://www.artsoft.org/
+// ----------------------------------------------------------------------------
+// mm_tools.h
+// ============================================================================
#ifndef MM_TOOLS_H
#define MM_TOOLS_H
LevelInfoType *header = &native_sp_level.header;
int i, x, y;
- /* for details of the Supaplex level format, see Herman Perk's Supaplex
- documentation file "SPFIX63.DOC" from his Supaplex "SpeedFix" package */
+ // for details of the Supaplex level format, see Herman Perk's Supaplex
+ // documentation file "SPFIX63.DOC" from his Supaplex "SpeedFix" package
native_sp_level.width = MIN(width, SP_MAX_PLAYFIELD_WIDTH);
native_sp_level.height = MIN(height, SP_MAX_PLAYFIELD_HEIGHT);
// initial "freeze zonks": 2 == "on", anything else (0, 1) == "off"
header->InitialFreezeZonks = getFile8Bit(file);
- /* number of infotrons needed; 0 means that Supaplex will count the total
- amount of infotrons in the level and use the low byte of that number
- (a multiple of 256 infotrons will result in "0 infotrons needed"!) */
+ // number of infotrons needed; 0 means that Supaplex will count the total
+ // amount of infotrons in the level and use the low byte of that number
+ // (a multiple of 256 infotrons will result in "0 infotrons needed"!)
header->InfotronsNeeded = getFile8Bit(file);
// number of special ("gravity") port entries below (maximum 10 allowed)
if (!reading_multipart_level && !is_multipart_level)
{
- /* the current level is simply a normal single-part level, and we are
- not reading a multi-part level yet, so return the level as it is */
+ // the current level is simply a normal single-part level, and we are
+ // not reading a multi-part level yet, so return the level as it is
break;
}
if (!reading_multipart_level && is_multipart_level && !is_first_part)
{
- /* this is a part of a multi-part level, but not the first part
- (and we are not already reading parts of a multi-part level);
- in this case, use an empty level instead of the single part */
+ // this is a part of a multi-part level, but not the first part
+ // (and we are not already reading parts of a multi-part level);
+ // in this case, use an empty level instead of the single part
use_empty_level = TRUE;
!strEqualN(header->LevelTitle, multipart_level.header.LevelTitle,
SP_LEVEL_NAME_LEN)))
{
- /* we are already reading parts of a multi-part level, but this level is
- either not a multi-part level, or a part of a different multi-part
- level; in both cases, the multi-part level seems to be complete */
+ // we are already reading parts of a multi-part level, but this level is
+ // either not a multi-part level, or a part of a different multi-part
+ // level; in both cases, the multi-part level seems to be complete
break;
}
}
// reset non-redefined ".active" font graphics if normal font is redefined
- /* (this different treatment is needed because normal and active fonts are
- independently defined ("active" is not a property of font definitions!) */
+ // (this different treatment is needed because normal and active fonts are
+ // independently defined ("active" is not a property of font definitions!)
for (i = 0; i < NUM_FONTS; i++)
{
int font_nr_base = i;
boolean active_redefined =
getImageListEntryFromImageID(active_graphic)->redefined;
- /* same as above, but check special graphic definitions, for example:
- redefined "font.menu_1.MAIN" invalidates "font.menu_1.active.MAIN" */
+ // same as above, but check special graphic definitions, for example:
+ // redefined "font.menu_1.MAIN" invalidates "font.menu_1.active.MAIN"
if (base_redefined && !active_redefined)
{
font_info[font_nr_active].special_graphic[j] =
UPDATE_BUSY_STATE();
- /* adjust graphics with 2nd tile for movement according to direction
- (do this before correcting '-1' values to minimize calculations) */
+ // adjust graphics with 2nd tile for movement according to direction
+ // (do this before correcting '-1' values to minimize calculations)
for (i = 0; i < MAX_NUM_ELEMENTS; i++)
{
for (act = 0; act < NUM_ACTIONS; act++)
}
}
- /* copy sound settings to some elements that are only stored in level file
- in native R'n'D levels, but are used by game engine in native EM levels */
+ // copy sound settings to some elements that are only stored in level file
+ // in native R'n'D levels, but are used by game engine in native EM levels
for (i = 0; copy_properties[i][0] != -1; i++)
for (j = 1; j <= 4; j++)
for (act = 0; act < NUM_ACTIONS; act++)
}
// now set all '-1' values to menu specific default values
- /* (undefined values of "levelset.music[]" might stay at "-1" to
- allow dynamic selection of music files from music directory!) */
+ // (undefined values of "levelset.music[]" might stay at "-1" to
+ // allow dynamic selection of music files from music directory!)
for (i = 0; i < MAX_LEVELS; i++)
if (levelset.music[i] == -1)
levelset.music[i] = default_levelset_music;
EL_WALL_PEARL,
EL_WALL_CRYSTAL,
- /* the following elements are a direct copy of "indestructible" elements,
- except "EL_ACID", which is "indestructible", but not "solid"! */
+ // the following elements are a direct copy of "indestructible" elements,
+ // except "EL_ACID", which is "indestructible", but not "solid"!
#if 0
EL_ACID,
#endif
the used memory is static, but will be overwritten by later calls,
so if you want to save the result, copy it to a private string buffer;
there can be 10 local calls of int2str() without buffering the result --
- the 11th call will then destroy the result from the first call and so on.
-*/
+ the 11th call will then destroy the result from the first call and so on. */
char *int2str(int number, int size)
{
}
-/* something similar to "int2str()" above, but allocates its own memory
- and has a different interface; we cannot use "itoa()", because this
- seems to be already defined when cross-compiling to the win32 target */
+// something similar to "int2str()" above, but allocates its own memory
+// and has a different interface; we cannot use "itoa()", because this
+// seems to be already defined when cross-compiling to the win32 target
char *i_to_a(unsigned int i)
{
}
-/* calculate base-2 logarithm of argument (rounded down to integer;
- this function returns the number of the highest bit set in argument) */
+// calculate base-2 logarithm of argument (rounded down to integer;
+// this function returns the number of the highest bit set in argument)
int log_2(unsigned int x)
{
// copy the name string, but not more than MAX_USERNAME_LEN characters
while (*from_ptr && (int)(to_ptr - real_name_new) < MAX_USERNAME_LEN - 1)
{
- /* the name field read from "passwd" file may also contain additional
- user information, separated by commas, which will be removed here */
+ // the name field read from "passwd" file may also contain additional
+ // user information, separated by commas, which will be removed here
if (*from_ptr == ',')
break;
- /* the user's real name may contain 'german sharp s' characters,
- which have no equivalent in upper case letters (used by our fonts) */
+ // the user's real name may contain 'german sharp s' characters,
+ // which have no equivalent in upper case letters (used by our fonts)
if (*from_ptr == CHAR_BYTE_SHARP_S)
{
from_ptr++;
return getStringCopyN(token, strlen(token) - len_suffix);
}
-/* This function checks if a string <s> of the format "string1, string2, ..."
- exactly contains a string <s_contained>. */
+// This function checks if a string <s> of the format "string1, string2, ..."
+// exactly contains a string <s_contained>.
static boolean string_has_parameter(char *s, char *s_contained)
{
// check if the old and the new artwork file are the same
if (*listnode && strEqual((*listnode)->source_filename, filename))
{
- /* The old and new artwork are the same (have the same filename and path).
- This usually means that this artwork does not exist in this artwork set
- and a fallback to the existing artwork is done. */
+ // The old and new artwork are the same (have the same filename and path).
+ // This usually means that this artwork does not exist in this artwork set
+ // and a fallback to the existing artwork is done.
return;
}
static void SDLSetWindowIcon(char *basename)
{
- /* (setting the window icon on Mac OS X would replace the high-quality
- dock icon with the currently smaller (and uglier) icon from file) */
+ // (setting the window icon on Mac OS X would replace the high-quality
+ // dock icon with the currently smaller (and uglier) icon from file)
#if !defined(PLATFORM_MACOSX)
char *filename = getCustomImageFilename(basename);
}
-/*
- -----------------------------------------------------------------------------
- quick (no, it's slow) and dirty hack to "invert" rectangle inside SDL surface
- -----------------------------------------------------------------------------
-*/
+// ----------------------------------------------------------------------------
+// quick (no, it's slow) and dirty hack to "invert" rectangle inside SDL surface
+// ----------------------------------------------------------------------------
void SDLInvertArea(Bitmap *bitmap, int src_x, int src_y,
int width, int height, Uint32 color)
// http://www.ferzkopp.net/Software/SDL_gfx-2.0/index.html
// ============================================================================
-/*
- -----------------------------------------------------------------------------
- 32 bit zoomer
-
- zoomes 32bit RGBA/ABGR 'src' surface to 'dst' surface.
- -----------------------------------------------------------------------------
-*/
+// ----------------------------------------------------------------------------
+// 32 bit zoomer
+//
+// zoomes 32bit RGBA/ABGR 'src' surface to 'dst' surface.
+// ----------------------------------------------------------------------------
typedef struct
{
return 0;
}
-/*
- -----------------------------------------------------------------------------
- 8 bit zoomer
-
- zoomes 8 bit palette/Y 'src' surface to 'dst' surface
- -----------------------------------------------------------------------------
-*/
+// ----------------------------------------------------------------------------
+// 8 bit zoomer
+//
+// zoomes 8 bit palette/Y 'src' surface to 'dst' surface
+// ----------------------------------------------------------------------------
static int zoomSurfaceY(SDL_Surface * src, SDL_Surface * dst)
{
return 0;
}
-/*
- -----------------------------------------------------------------------------
- zoomSurface()
-
- Zooms a 32bit or 8bit 'src' surface to newly created 'dst' surface.
- 'zoomx' and 'zoomy' are scaling factors for width and height.
- If the surface is not 8bit or 32bit RGBA/ABGR it will be converted
- into a 32bit RGBA format on the fly.
- -----------------------------------------------------------------------------
-*/
+// ----------------------------------------------------------------------------
+// zoomSurface()
+//
+// Zooms a 32bit or 8bit 'src' surface to newly created 'dst' surface.
+// 'zoomx' and 'zoomy' are scaling factors for width and height.
+// If the surface is not 8bit or 32bit RGBA/ABGR it will be converted
+// into a 32bit RGBA format on the fly.
+// ----------------------------------------------------------------------------
static SDL_Surface *zoomSurface(SDL_Surface *src, int dst_width, int dst_height)
{
if (directoryExists(dir))
return;
- /* leave "other" permissions in umask untouched, but ensure group parts
- of USERDATA_DIR_MODE are not masked */
+ // leave "other" permissions in umask untouched, but ensure group parts
+ // of USERDATA_DIR_MODE are not masked
mode_t dir_mode = (permission_class == PERMS_PRIVATE ?
DIR_PERMS_PRIVATE : DIR_PERMS_PUBLIC);
mode_t last_umask = posix_umask(0);
boolean getTokenValueFromSetupLine(char *line, char **token, char **value)
{
- /* while the internal (old) interface does not require a token/value
- separator (for downwards compatibility with existing files which
- don't use them), it is mandatory for the external (new) interface */
+ // while the internal (old) interface does not require a token/value
+ // separator (for downwards compatibility with existing files which
+ // don't use them), it is mandatory for the external (new) interface
return getTokenValueFromSetupLineExt(line, token, value, NULL, NULL, 0, TRUE);
}
if (src_bitmap == dst_bitmap)
{
- /* needed when blitting directly to same bitmap -- should not be needed with
- recent SDL libraries, but apparently does not work in 1.2.11 directly */
+ // needed when blitting directly to same bitmap -- should not be needed with
+ // recent SDL libraries, but apparently does not work in 1.2.11 directly
static Bitmap *tmp_bitmap = NULL;
static int tmp_bitmap_xsize = 0;
if (strEqual(filename, bitmap->source_filename))
{
- /* The old and new image are the same (have the same filename and path).
- This usually means that this image does not exist in this graphic set
- and a fallback to the existing image is done. */
+ // The old and new image are the same (have the same filename and path).
+ // This usually means that this image does not exist in this graphic set
+ // and a fallback to the existing image is done.
return;
}
};
static const char **cursor_image_playfield = cursor_image_dot;
#else
-/* some people complained about a "white dot" on the screen and thought it
- was a graphical error... OK, let's just remove the whole pointer :-) */
+// some people complained about a "white dot" on the screen and thought it
+// was a graphical error... OK, let's just remove the whole pointer :-)
static const char **cursor_image_playfield = cursor_image_none;
#endif
// areas in bitmap PIX_DOOR
-/* meaning in PIX_DB_DOOR: (3 PAGEs)
- PAGEX1: 1. buffer for DOOR_1
- PAGEX2: 2. buffer for DOOR_1
- PAGEX3: buffer for animations
-*/
+// meaning in PIX_DB_DOOR: (3 PAGEs)
+// PAGEX1: 1. buffer for DOOR_1
+// PAGEX2: 2. buffer for DOOR_1
+// PAGEX3: buffer for animations
// these values are hard-coded to be able to use them in initialization
#define DOOR_GFX_PAGE_WIDTH 100 // should be set to "gfx.dxsize"
// font definitions
// ----------------------------------------------------------------------------
-/* Important: When one entry is a prefix of another entry, the longer entry
- must come first, because the dynamic configuration does prefix matching!
- (These definitions must match the corresponding definitions in "main.h"!) */
+// Important: When one entry is a prefix of another entry, the longer entry
+// must come first, because the dynamic configuration does prefix matching!
+// (These definitions must match the corresponding definitions in "main.h"!)
struct FontInfo font_info[NUM_FONTS + 1] =
{
exit(exit_value);
}
-/* the following is not used for a standalone server;
- the pointer points to an integer containing the port-number */
+// the following is not used for a standalone server;
+// the pointer points to an integer containing the port-number
int NetworkServerThread(void *ptr)
{
NetworkServer(*((int *) ptr), 0);
break;
case SDL_JOYHATMOTION:
- /* ignore centering; we're probably just coming back
- to the center from the previous item we set */
+ // ignore centering; we're probably just coming back
+ // to the center from the previous item we set
if (event.jhat.value == SDL_HAT_CENTERED)
break;
}
-/* ------------------------------------------------------------------------- *
- * tape autoplay functions
- * ------------------------------------------------------------------------- */
+// ----------------------------------------------------------------------------
+// tape autoplay functions
+// ----------------------------------------------------------------------------
void AutoPlayTape(void)
{
#define VIDEO_PRESS_EJECT(x) ((x) ? VIDEO_PRESS_EJECT_ON: VIDEO_PRESS_EJECT_OFF)
// tags to draw video display labels or symbols only
-/* (negative values to prevent misinterpretation in DrawVideoDisplay(), where
- the variable "value" is also used for tape length -- better fix this) */
+// (negative values to prevent misinterpretation in DrawVideoDisplay(), where
+// the variable "value" is also used for tape length -- better fix this)
#define VIDEO_DISPLAY_DEFAULT 0
#define VIDEO_DISPLAY_LABEL_ONLY -1
#define VIDEO_DISPLAY_SYMBOL_ONLY -2
int x2 = x + SIGN(dx);
int y2 = y + SIGN(dy);
- /* movement with two-tile animations must be sync'ed with movement position,
- not with current GfxFrame (which can be higher when using slow movement) */
+ // movement with two-tile animations must be sync'ed with movement position,
+ // not with current GfxFrame (which can be higher when using slow movement)
int anim_pos = (dx ? ABS(dx) : ABS(dy));
int anim_frames = graphic_info[graphic].anim_frames;
int last_player_frame = player->Frame;
int frame = 0;
- /* GfxElement[][] is set to the element the player is digging or collecting;
- remove also for off-screen player if the player is not moving anymore */
+ // GfxElement[][] is set to the element the player is digging or collecting;
+ // remove also for off-screen player if the player is not moving anymore
if (IN_LEV_FIELD(jx, jy) && !player_is_moving)
GfxElement[jx][jy] = EL_UNDEFINED;
graphic = getPlayerGraphic(player, move_dir);
- /* in the case of changed player action or direction, prevent the current
- animation frame from being restarted for identical animations */
+ // in the case of changed player action or direction, prevent the current
+ // animation frame from being restarted for identical animations
if (player->Frame == 0 && equalGraphics(graphic, last_player_graphic))
player->Frame = last_player_frame;
graphic = getPlayerGraphic(player, move_dir);
- /* in the case of changed player action or direction, prevent the current
- animation frame from being restarted for identical animations */
+ // in the case of changed player action or direction, prevent the current
+ // animation frame from being restarted for identical animations
if (player->Frame == 0 && equalGraphics(graphic, last_player_graphic))
player->Frame = last_player_frame;
boolean has_crumbled_graphics,
int crumbled, int sync_frame)
{
- /* if element can be crumbled, but certain action graphics are just empty
- space (like instantly snapping sand to empty space in 1 frame), do not
- treat these empty space graphics as crumbled graphics in EMC engine */
+ // if element can be crumbled, but certain action graphics are just empty
+ // space (like instantly snapping sand to empty space in 1 frame), do not
+ // treat these empty space graphics as crumbled graphics in EMC engine
if (crumbled == IMG_EMPTY_SPACE)
has_crumbled_graphics = FALSE;
action == ACTION_FILLING ||
action == ACTION_EMPTYING);
- /* special case: graphic uses "2nd movement tile" and has defined
- 7 frames for movement animation (or less) => use default graphic
- for last (8th) frame which ends the movement animation */
+ // special case: graphic uses "2nd movement tile" and has defined
+ // 7 frames for movement animation (or less) => use default graphic
+ // for last (8th) frame which ends the movement animation
if (g->double_movement && g->anim_frames < 8 && frame_em == 7)
{
action = ACTION_DEFAULT; // (keep action_* unchanged for now)
struct GraphicInfo *g = &graphic_info[graphic];
int sync_frame;
- /* special case: graphic uses "2nd movement tile" and has defined
- 7 frames for movement animation (or less) => use default graphic
- for last (8th) frame which ends the movement animation */
+ // special case: graphic uses "2nd movement tile" and has defined
+ // 7 frames for movement animation (or less) => use default graphic
+ // for last (8th) frame which ends the movement animation
if (g->double_movement && g->anim_frames < 8 && frame_em == 7)
{
effective_action = ACTION_DEFAULT;
getGraphicSourceExt(graphic, frame, &g_em->bitmap, &g_em->src_x, &g_em->src_y,
g->double_movement && is_backside);
- /* (updating the "crumbled" graphic definitions is probably not really needed,
- as animations for crumbled graphics can't be longer than one EMC cycle) */
+ // (updating the "crumbled" graphic definitions is probably not really needed,
+ // as animations for crumbled graphics can't be longer than one EMC cycle)
set_crumbled_graphics_EM(g_em, has_crumbled_graphics, crumbled,
sync_frame);
}