special = game_status;
else if (game_status == GAME_MODE_PSEUDO_TYPENAME)
special = GFX_SPECIAL_ARG_MAIN;
+ else if (game_status == GAME_MODE_PSEUDO_TYPENAMES)
+ special = GFX_SPECIAL_ARG_NAMES;
if (special != -1)
return font_info[font_nr].special_bitmap_id[special];
Warn("custom graphic rejected for this element/action");
if (graphic == fallback_graphic)
- Error(ERR_EXIT, "no fallback graphic available");
+ Fail("no fallback graphic available");
Warn("fallback done to 'char_exclam' for this graphic");
Warn("---");
IMG_BACKGROUND_TITLE_INITIAL,
IMG_BACKGROUND_TITLE,
IMG_BACKGROUND_MAIN,
+ IMG_BACKGROUND_NAMES,
IMG_BACKGROUND_LEVELS,
IMG_BACKGROUND_LEVELNR,
IMG_BACKGROUND_SCORES,
Warn("custom graphic rejected for this element/action");
if (i == fallback_graphic)
- Error(ERR_EXIT, "no fallback graphic available");
+ Fail("no fallback graphic available");
Warn("fallback done to 'char_exclam' for this graphic");
Warn("---");
Warn("custom graphic rejected for this element/action");
if (i == fallback_graphic)
- Error(ERR_EXIT, "no fallback graphic available");
+ Fail("no fallback graphic available");
Warn("fallback done to 'char_exclam' for this graphic");
Warn("---");
{
// check if element_name_info entry defined for each element in "main.h"
if (i < MAX_NUM_ELEMENTS && element_name_info[i].token_name == NULL)
- Error(ERR_EXIT, "undefined 'element_name_info' entry for element %d", i);
+ Fail("undefined 'element_name_info' entry for element %d", i);
element_info[i].token_name = element_name_info[i].token_name;
element_info[i].class_name = element_name_info[i].class_name;
// check if global_anim_name_info defined for each entry in "main.h"
if (i < NUM_GLOBAL_ANIM_TOKENS &&
global_anim_name_info[i].token_name == NULL)
- Error(ERR_EXIT, "undefined 'global_anim_name_info' entry for anim %d", i);
+ Fail("undefined 'global_anim_name_info' entry for anim %d", i);
global_anim_info[i].token_name = global_anim_name_info[i].token_name;
}
global.autoplay_leveldir = NULL;
global.patchtapes_leveldir = NULL;
global.convert_leveldir = NULL;
+ global.dumplevel_leveldir = NULL;
+ global.dumptape_leveldir = NULL;
global.create_images_dir = NULL;
global.frames_per_second = 0;
global.anim_status = global.anim_status_next = GAME_MODE_LOADING;
global.use_envelope_request = FALSE;
+
+ global.user_names = NULL;
}
static void Execute_Command(char *command)
{
char *filename = &command[11];
- if (!fileExists(filename))
- Error(ERR_EXIT, "cannot open file '%s'", filename);
+ if (fileExists(filename))
+ {
+ LoadLevelFromFilename(&level, filename);
+ DumpLevel(&level);
- LoadLevelFromFilename(&level, filename);
- DumpLevel(&level);
+ exit(0);
+ }
- exit(0);
+ char *leveldir = getStringCopy(filename); // read command parameters
+ char *level_nr = strchr(leveldir, ' ');
+
+ if (level_nr == NULL)
+ Fail("cannot open file '%s'", filename);
+
+ *level_nr++ = '\0';
+
+ global.dumplevel_leveldir = leveldir;
+ global.dumplevel_level_nr = atoi(level_nr);
+
+ program.headless = TRUE;
}
else if (strPrefix(command, "dump tape "))
{
char *filename = &command[10];
- if (!fileExists(filename))
- Error(ERR_EXIT, "cannot open file '%s'", filename);
+ if (fileExists(filename))
+ {
+ LoadTapeFromFilename(filename);
+ DumpTape(&tape);
- LoadTapeFromFilename(filename);
- DumpTape(&tape);
+ exit(0);
+ }
- exit(0);
+ char *leveldir = getStringCopy(filename); // read command parameters
+ char *level_nr = strchr(leveldir, ' ');
+
+ if (level_nr == NULL)
+ Fail("cannot open file '%s'", filename);
+
+ *level_nr++ = '\0';
+
+ global.dumptape_leveldir = leveldir;
+ global.dumptape_level_nr = atoi(level_nr);
+
+ program.headless = TRUE;
}
else if (strPrefix(command, "autoplay ") ||
strPrefix(command, "autoffwd ") ||
str_ptr++;
if (*str_ptr == '\0')
- Error(ERR_EXIT, "cannot find MODE in command '%s'", command);
+ Fail("cannot find MODE in command '%s'", command);
global.patchtapes_mode = str_ptr; // store patch mode
if (strEqual(global.patchtapes_mode, "help"))
global.patchtapes_leveldir = UNDEFINED_LEVELSET;
else
- Error(ERR_EXIT, "cannot find LEVELDIR in command '%s'", command);
+ Fail("cannot find LEVELDIR in command '%s'", command);
}
program.headless = TRUE;
global.create_images_dir = getStringCopy(&command[14]);
if (access(global.create_images_dir, W_OK) != 0)
- Error(ERR_EXIT, "image target directory '%s' not found or not writable",
- global.create_images_dir);
+ Fail("image target directory '%s' not found or not writable",
+ global.create_images_dir);
}
else if (strPrefix(command, "create CE image "))
{
}
else
{
- Error(ERR_EXIT_HELP, "unrecognized command '%s'", command);
+ FailWithHelp("unrecognized command '%s'", command);
}
// disable networking if any valid command was recognized
static void InitSetup(void)
{
+ LoadUserNames(); // global user names
+ LoadUserSetup(); // global user number
+
LoadSetup(); // global setup info
LoadSetup_AutoSetup(); // global auto setup info
{
game.restart_level = FALSE;
game.restart_game_message = NULL;
+
game.request_active = FALSE;
+ game.request_active_or_moving = FALSE;
}
static void InitPlayerInfo(void)
}
if (filename_font_initial == NULL) // should not happen
- Error(ERR_EXIT, "cannot get filename for '%s'", CONFIG_TOKEN_FONT_INITIAL);
+ Fail("cannot get filename for '%s'", CONFIG_TOKEN_FONT_INITIAL);
InitGfxBuffers();
InitGfxCustomArtworkInfo();
}
if (filename_anim_initial == NULL) // should not happen
- Error(ERR_EXIT, "cannot get filename for '%s'", CONFIG_TOKEN_GLOBAL_BUSY);
+ Fail("cannot get filename for '%s'", CONFIG_TOKEN_GLOBAL_BUSY);
anim_initial.bitmaps =
checked_calloc(sizeof(Bitmap *) * NUM_IMG_BITMAP_POINTERS);
static char *getNewArtworkIdentifier(int type)
{
- static char *leveldir_current_identifier[3] = { NULL, NULL, NULL };
+ static char *last_leveldir_identifier[3] = { NULL, NULL, NULL };
+ static char *last_artwork_identifier[3] = { NULL, NULL, NULL };
static boolean last_override_level_artwork[3] = { FALSE, FALSE, FALSE };
static boolean last_has_level_artwork_set[3] = { FALSE, FALSE, FALSE };
static boolean initialized[3] = { FALSE, FALSE, FALSE };
else
artwork_current_identifier = setup_artwork_set;
-
/* 2nd step: check if it is really needed to reload artwork set
------------------------------------------------------------ */
// ---------- reload if level set and also artwork set has changed ----------
- if (leveldir_current_identifier[type] != leveldir_identifier &&
+ if (last_leveldir_identifier[type] != leveldir_identifier &&
(last_has_level_artwork_set[type] || has_level_artwork_set))
artwork_new_identifier = artwork_current_identifier;
- leveldir_current_identifier[type] = leveldir_identifier;
+ last_leveldir_identifier[type] = leveldir_identifier;
last_has_level_artwork_set[type] = has_level_artwork_set;
// ---------- reload if "override artwork" setting has changed --------------
last_override_level_artwork[type] = setup_override_artwork;
// ---------- reload if current artwork identifier has changed --------------
- if (!strEqual(ARTWORK_CURRENT_IDENTIFIER(artwork, type),
- artwork_current_identifier))
+ if (!strEqual(last_artwork_identifier[type], artwork_current_identifier))
artwork_new_identifier = artwork_current_identifier;
- *(ARTWORK_CURRENT_IDENTIFIER_PTR(artwork, type))= artwork_current_identifier;
+ // (we cannot compare string pointers here, so copy string content itself)
+ setString(&last_artwork_identifier[type], artwork_current_identifier);
+
+ *(ARTWORK_CURRENT_IDENTIFIER_PTR(artwork, type)) = artwork_current_identifier;
// ---------- do not reload directly after starting -------------------------
if (!initialized[type])
InitOverrideArtwork();
- force_reload_gfx |= AdjustGraphicsForEMC();
- force_reload_snd |= AdjustSoundsForEMC();
+ AdjustGraphicsForEMC();
+ AdjustSoundsForEMC();
gfx_new_identifier = getNewArtworkIdentifier(ARTWORK_TYPE_GRAPHICS);
snd_new_identifier = getNewArtworkIdentifier(ARTWORK_TYPE_SOUNDS);
print_timestamp_time("[init setup/config stuff (1)]");
- InitScoresInfo();
-
if (options.execute_command)
Execute_Command(options.execute_command);
ConvertLevels();
return;
}
+ else if (global.dumplevel_leveldir)
+ {
+ DumpLevels();
+ return;
+ }
+ else if (global.dumptape_leveldir)
+ {
+ DumpTapes();
+ return;
+ }
else if (global.create_images_dir)
{
CreateLevelSketchImages();
// using SDL_WaitThread()
//
// Code used with SDL 1.2:
- // if (network_server) // terminate network server
- // SDL_KillThread(server_thread);
+ // if (network.server_thread) // terminate network server
+ // SDL_KillThread(network.server_thread);
CloseVideoDisplay();
ClosePlatformDependentStuff();