GDI_END);
if (gi == NULL)
- Error(ERR_EXIT, "cannot create gadget");
+ Fail("cannot create gadget");
level_editor_gadget[id] = gi;
}
GDI_END);
if (gi == NULL)
- Error(ERR_EXIT, "cannot create gadget");
+ Fail("cannot create gadget");
level_editor_gadget[id] = gi;
}
GDI_END);
if (gi == NULL)
- Error(ERR_EXIT, "cannot create gadget");
+ Fail("cannot create gadget");
level_editor_gadget[id] = gi;
}
GDI_END);
if (gi == NULL)
- Error(ERR_EXIT, "cannot create gadget");
+ Fail("cannot create gadget");
level_editor_gadget[id] = gi;
right_gadget_border[id] =
GDI_END);
if (gi == NULL)
- Error(ERR_EXIT, "cannot create gadget");
+ Fail("cannot create gadget");
level_editor_gadget[id] = gi;
right_gadget_border[id] =
GDI_END);
if (gi == NULL)
- Error(ERR_EXIT, "cannot create gadget");
+ Fail("cannot create gadget");
level_editor_gadget[id] = gi;
right_gadget_border[id] =
GDI_END);
if (gi == NULL)
- Error(ERR_EXIT, "cannot create gadget");
+ Fail("cannot create gadget");
level_editor_gadget[id] = gi;
}
GDI_END);
if (gi == NULL)
- Error(ERR_EXIT, "cannot create gadget");
+ Fail("cannot create gadget");
level_editor_gadget[id] = gi;
}
GDI_END);
if (gi == NULL)
- Error(ERR_EXIT, "cannot create gadget");
+ Fail("cannot create gadget");
level_editor_gadget[id] = gi;
right_gadget_border[id] =
GDI_END);
if (gi == NULL)
- Error(ERR_EXIT, "cannot create gadget");
+ Fail("cannot create gadget");
level_editor_gadget[id] = gi;
right_gadget_border[id] =
GDI_END);
if (gi == NULL)
- Error(ERR_EXIT, "cannot create gadget");
+ Fail("cannot create gadget");
level_editor_gadget[id] = gi;
right_gadget_border[id] =
GDI_END);
if (gi == NULL)
- Error(ERR_EXIT, "cannot create gadget");
+ Fail("cannot create gadget");
level_editor_gadget[id] = gi;
}
GDI_END);
if (gi == NULL)
- Error(ERR_EXIT, "cannot create gadget");
+ Fail("cannot create gadget");
level_editor_gadget[id] = gi;
right_gadget_border[id] =
GDI_END);
if (gi == NULL)
- Error(ERR_EXIT, "cannot create gadget");
+ Fail("cannot create gadget");
level_editor_gadget[id] = gi;
right_gadget_border[id] =
global.convert_leveldir);
if (convert_leveldir == NULL)
- Error(ERR_EXIT, "no such level identifier: '%s'",
- global.convert_leveldir);
+ Fail("no such level identifier: '%s'", global.convert_leveldir);
leveldir_current = convert_leveldir;
BlitBitmap(drawto, bitmap1, SX, SY, TILEX, TILEY, 0, 0);
if (SDL_SaveBMP(bitmap1->surface, filename1) != 0)
- Error(ERR_EXIT, "cannot save level sketch image file '%s'", filename1);
+ Fail("cannot save level sketch image file '%s'", filename1);
DrawSizedElement(0, 0, element, MINI_TILESIZE);
BlitBitmap(drawto, bitmap2, SX, SY, MINI_TILEX, MINI_TILEY, 0, 0);
if (SDL_SaveBMP(bitmap2->surface, filename2) != 0)
- Error(ERR_EXIT, "cannot save level sketch image file '%s'", filename2);
+ Fail("cannot save level sketch image file '%s'", filename2);
free(filename1);
free(filename2);
}
if (SDL_SaveBMP(bitmap->surface, dst_filename) != 0)
- Error(ERR_EXIT, "cannot save CE graphics file '%s'", dst_filename);
+ Fail("cannot save CE graphics file '%s'", dst_filename);
FreeBitmap(bitmap);
GDI_END);
if (gi == NULL)
- Error(ERR_EXIT, "cannot create gadget");
+ Fail("cannot create gadget");
game_gadget[id] = gi;
}
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("---");
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;
}
char *filename = &command[11];
if (!fileExists(filename))
- Error(ERR_EXIT, "cannot open file '%s'", filename);
+ Fail("cannot open file '%s'", filename);
LoadLevelFromFilename(&level, filename);
DumpLevel(&level);
char *filename = &command[10];
if (!fileExists(filename))
- Error(ERR_EXIT, "cannot open file '%s'", filename);
+ Fail("cannot open file '%s'", filename);
LoadTapeFromFilename(filename);
DumpTape(&tape);
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
}
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);
}
if (next_free_gadget_id <= 0) // cannot get new gadget id
- Error(ERR_EXIT, "too much gadgets -- this should not happen");
+ Fail("too much gadgets -- this should not happen");
return id;
}
break;
default:
- Error(ERR_EXIT, "HandleGadgetTags(): unknown tag %d", tag);
+ Fail("HandleGadgetTags(): unknown tag %d", tag);
}
tag = va_arg(ap, int); // read next tag
gi->height = 2 * border_ysize + font_height;
if (gi->selectbox.options == NULL)
- Error(ERR_EXIT, "selectbox gadget incomplete (missing options array)");
+ Fail("selectbox gadget incomplete (missing options array)");
gi->selectbox.num_values = 0;
while (gi->selectbox.options[gi->selectbox.num_values].text != NULL)
if (gi->width == 0 || gi->height == 0 ||
gs->items_max == 0 || gs->items_visible == 0)
- Error(ERR_EXIT, "scrollbar gadget incomplete (missing tags)");
+ Fail("scrollbar gadget incomplete (missing tags)");
// calculate internal scrollbar values
gs->size_min = (gi->type == GD_TYPE_SCROLLBAR_VERTICAL ?
vprintf_log(format, ap);
}
+static void Log(int log_level, char *mode, char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ vLog(log_level, mode, format, ap);
+ va_end(ap);
+}
+
void Debug(char *mode, char *format, ...)
{
va_list ap;
va_end(ap);
}
+void Fail(char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ vLog(LOG_FATAL, NULL, format, ap);
+ va_end(ap);
+
+ if (!network.is_server_thread)
+ {
+ va_start(ap, format);
+ program.exit_message_function(format, ap);
+ va_end(ap);
+ }
+
+ Log(LOG_FATAL, NULL, "aborting");
+
+ // network server thread: normal exit
+ if (network.is_server_thread)
+ exit(1);
+
+ // main process: clean up stuff
+ program.exit_function(1);
+}
+
+void FailWithHelp(char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ vLog(LOG_FATAL, NULL, format, ap);
+ va_end(ap);
+
+ Log(LOG_FATAL, NULL, "try option '--help' for more information");
+ Log(LOG_FATAL, NULL, "aborting");
+
+ // main process: clean up stuff
+ program.exit_function(1);
+}
+
// ----------------------------------------------------------------------------
// string functions
int option_len = strlen(option);
if (option_len >= MAX_OPTION_LEN)
- Error(ERR_EXIT_HELP, "unrecognized option '%s'", option);
+ FailWithHelp("unrecognized option '%s'", option);
strcpy(option_str, option); // copy argument into buffer
option = option_str;
{
*option_arg++ = '\0'; // cut argument from option
if (*option_arg == '\0') // no argument after '='
- Error(ERR_EXIT_HELP, "option '%s' has invalid argument", option_str);
+ FailWithHelp("option '%s' has invalid argument", option_str);
}
option_len = strlen(option);
if (strEqual(option, "-"))
{
- Error(ERR_EXIT_HELP, "unrecognized option '%s'", option);
+ FailWithHelp("unrecognized option '%s'", option);
}
else if (strncmp(option, "-help", option_len) == 0)
{
else if (strncmp(option, "-basepath", option_len) == 0)
{
if (option_arg == NULL)
- Error(ERR_EXIT_HELP, "option '%s' requires an argument", option_str);
+ FailWithHelp("option '%s' requires an argument", option_str);
// this should be extended to separate options for ro and rw data
options.ro_base_directory = ro_base_path = getStringCopy(option_arg);
else if (strncmp(option, "-levels", option_len) == 0)
{
if (option_arg == NULL)
- Error(ERR_EXIT_HELP, "option '%s' requires an argument", option_str);
+ FailWithHelp("option '%s' requires an argument", option_str);
options.level_directory = getStringCopy(option_arg);
if (option_arg == next_option)
else if (strncmp(option, "-graphics", option_len) == 0)
{
if (option_arg == NULL)
- Error(ERR_EXIT_HELP, "option '%s' requires an argument", option_str);
+ FailWithHelp("option '%s' requires an argument", option_str);
options.graphics_directory = getStringCopy(option_arg);
if (option_arg == next_option)
else if (strncmp(option, "-sounds", option_len) == 0)
{
if (option_arg == NULL)
- Error(ERR_EXIT_HELP, "option '%s' requires an argument", option_str);
+ FailWithHelp("option '%s' requires an argument", option_str);
options.sounds_directory = getStringCopy(option_arg);
if (option_arg == next_option)
else if (strncmp(option, "-music", option_len) == 0)
{
if (option_arg == NULL)
- Error(ERR_EXIT_HELP, "option '%s' requires an argument", option_str);
+ FailWithHelp("option '%s' requires an argument", option_str);
options.music_directory = getStringCopy(option_arg);
if (option_arg == next_option)
else if (strncmp(option, "-execute", option_len) == 0)
{
if (option_arg == NULL)
- Error(ERR_EXIT_HELP, "option '%s' requires an argument", option_str);
+ FailWithHelp("option '%s' requires an argument", option_str);
options.execute_command = getStringCopy(option_arg);
if (option_arg == next_option)
#endif
else if (*option == '-')
{
- Error(ERR_EXIT_HELP, "unrecognized option '%s'", option_str);
+ FailWithHelp("unrecognized option '%s'", option_str);
}
else if (options.server_host == NULL)
{
{
options.server_port = atoi(*options_left);
if (options.server_port < 1024)
- Error(ERR_EXIT_HELP, "bad port number '%d'", options.server_port);
+ FailWithHelp("bad port number '%d'", options.server_port);
}
else
- Error(ERR_EXIT_HELP, "too many arguments");
+ FailWithHelp("too many arguments");
options_left++;
}
ptr = malloc(size);
if (ptr == NULL)
- Error(ERR_EXIT, "cannot allocate %d bytes -- out of memory", size);
+ Fail("cannot allocate %d bytes -- out of memory", size);
return ptr;
}
ptr = calloc(1, size);
if (ptr == NULL)
- Error(ERR_EXIT, "cannot allocate %d bytes -- out of memory", size);
+ Fail("cannot allocate %d bytes -- out of memory", size);
return ptr;
}
ptr = realloc(ptr, size);
if (ptr == NULL)
- Error(ERR_EXIT, "cannot allocate %d bytes -- out of memory", size);
+ Fail("cannot allocate %d bytes -- out of memory", size);
return ptr;
}
float timestamp_interval;
if (counter_nr < 0)
- Error(ERR_EXIT, "debugging: invalid negative counter");
+ Fail("debugging: invalid negative counter");
else if (counter_nr >= DEBUG_NUM_TIMESTAMPS)
- Error(ERR_EXIT, "debugging: increase DEBUG_NUM_TIMESTAMPS in misc.c");
+ Fail("debugging: increase DEBUG_NUM_TIMESTAMPS in misc.c");
#if DEBUG_TIME_IN_MICROSECONDS
static double counter[DEBUG_NUM_TIMESTAMPS][2];
void Debug(char *, char *, ...);
void Info(char *, ...);
void Warn(char *, ...);
+void Fail(char *, ...);
+void FailWithHelp(char *, ...);
char *int2str(int, int);
char *i_to_a(unsigned int);
new_surface = SDL_ConvertSurface(surface, &format, 0);
if (new_surface == NULL)
- Error(ERR_EXIT, "SDL_ConvertSurface() failed: %s", SDL_GetError());
+ Fail("SDL_ConvertSurface() failed: %s", SDL_GetError());
// workaround for a bug in SDL 2.0.12 (which does not convert the color key)
if (SDLHasColorKey(surface) && !SDLHasColorKey(new_surface))
SDL_Texture *texture = SDL_CreateTextureFromSurface(sdl_renderer, surface);
if (texture == NULL)
- Error(ERR_EXIT, "SDL_CreateTextureFromSurface() failed: %s",
- SDL_GetError());
+ Fail("SDL_CreateTextureFromSurface() failed: %s", SDL_GetError());
return texture;
}
// initialize SDL video
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
- Error(ERR_EXIT, "SDL_InitSubSystem() failed: %s", SDL_GetError());
+ Fail("SDL_InitSubSystem() failed: %s", SDL_GetError());
// set default SDL depth
video.default_depth = 32; // (how to determine video depth in SDL2?)
// open SDL video output device (window or fullscreen mode)
if (!SDLSetVideoMode(fullscreen))
- Error(ERR_EXIT, "setting video mode failed");
+ Fail("setting video mode failed");
// !!! SDL2 can only set the window icon if the window already exists !!!
// set window icon
SDL_CreateRGBSurface(SURFACE_FLAGS, width, height, depth, 0,0,0, 0);
if (surface == NULL)
- Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s", SDL_GetError());
+ Fail("SDL_CreateRGBSurface() failed: %s", SDL_GetError());
SDLSetNativeSurface(&surface);
return NULL;
if ((new_surface = SDLGetNativeSurface(surface)) == NULL)
- Error(ERR_EXIT, "SDLGetNativeSurface() failed");
+ Fail("SDLGetNativeSurface() failed");
// remove alpha channel from native non-transparent surface, if defined
SDLSetAlpha(new_surface, FALSE, 0);
// load image to temporary surface
if ((sdl_image_tmp = IMG_Load(filename)) == NULL)
- Error(ERR_EXIT, "IMG_Load('%s') failed: %s", getBaseNamePtr(filename),
- SDL_GetError());
+ Fail("IMG_Load('%s') failed: %s", getBaseNamePtr(filename), SDL_GetError());
print_timestamp_time("IMG_Load");
// create native non-transparent surface for current image
if ((new_bitmap->surface = SDLGetOpaqueSurface(sdl_image_tmp)) == NULL)
- Error(ERR_EXIT, "SDLGetOpaqueSurface() failed");
+ Fail("SDLGetOpaqueSurface() failed");
print_timestamp_time("SDLGetNativeSurface (opaque)");
// create native transparent surface for current image
if ((new_bitmap->surface_masked = SDLGetNativeSurface(sdl_image_tmp)) == NULL)
- Error(ERR_EXIT, "SDLGetNativeSurface() failed");
+ Fail("SDLGetNativeSurface() failed");
print_timestamp_time("SDLGetNativeSurface (masked)");
SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) < 0)
- {
- Error(ERR_EXIT, "SDL_Init() failed: %s", SDL_GetError());
-
- return;
- }
+ Fail("SDL_Init() failed: %s", SDL_GetError());
num_mappings = SDL_GameControllerAddMappingsFromFile(mappings_file_base);
create_hashtable(16, 0.75, get_hash_from_key, keys_are_equal);
if (new_hash == NULL)
- Error(ERR_EXIT, "create_hashtable() failed -- out of memory");
+ Fail("create_hashtable() failed -- out of memory");
return new_hash;
}
// change value; if it does not exist, insert it as new
if (!change_hash_entry(hash, token, value_copy))
if (!insert_hash_entry(hash, getStringCopy(token), value_copy))
- Error(ERR_EXIT, "cannot insert into hash -- aborting");
+ Fail("cannot insert into hash -- aborting");
}
char *removeHashEntry(SetupFileHash *hash, char *token)
leveldir_current = getFirstValidTreeInfoEntry(leveldir_first);
if (leveldir_first == NULL)
- Error(ERR_EXIT, "cannot find any valid level series in any directory");
+ Fail("cannot find any valid level series in any directory");
sortTreeInfo(&leveldir_first);
char *tree_subdir_new, int type)
{
if (!AddTreeSetToTreeInfoExt(tree_node, tree_dir, tree_subdir_new, type))
- Error(ERR_EXIT, "internal tree info structure corrupted -- aborting");
+ Fail("internal tree info structure corrupted -- aborting");
}
void AddUserLevelSetToLevelInfo(char *level_subdir_new)
ti = getTreeInfoFromIdentifier(artwork_first_node,
ARTWORK_DEFAULT_SUBDIR(type));
if (ti == NULL)
- Error(ERR_EXIT, "cannot find default graphics -- should not happen");
+ Fail("cannot find default graphics -- should not happen");
}
return ti;
int sdl_init_flags = SDL_INIT_EVENTS | SDL_INIT_NOPARACHUTE;
if (SDL_Init(sdl_init_flags) < 0)
- Error(ERR_EXIT, "SDL_Init() failed: %s", SDL_GetError());
+ Fail("SDL_Init() failed: %s", SDL_GetError());
SDLNet_Init();
}
Bitmap *new_bitmap;
if (filename == NULL)
- Error(ERR_EXIT, "LoadCustomImage(): cannot find file '%s'", basename);
+ Fail("LoadCustomImage(): cannot find file '%s'", basename);
if ((new_bitmap = LoadImage(filename)) == NULL)
- Error(ERR_EXIT, "LoadImage('%s') failed: %s", basename, GetError());
+ Fail("LoadImage('%s') failed: %s", basename, GetError());
return new_bitmap;
}
va_end(ap);
if (strlen(buffer) > MAX_OUTPUT_LINESIZE)
- Error(ERR_EXIT, "string too long in DrawTextF() -- aborting");
+ Fail("string too long in DrawTextF() -- aborting");
DrawText(gfx.sx + x, gfx.sy + y, buffer, font_nr);
}
va_end(ap);
if (strlen(buffer) > MAX_OUTPUT_LINESIZE)
- Error(ERR_EXIT, "string too long in DrawTextFCentered() -- aborting");
+ Fail("string too long in DrawTextFCentered() -- aborting");
DrawText(gfx.sx + (gfx.sxsize - getTextWidth(buffer, font_nr)) / 2,
gfx.sy + y, buffer, font_nr);
#endif
if (SDLNet_ResolveHost(&ip, NULL, port) == -1)
- Error(ERR_EXIT_NETWORK_SERVER, "SDLNet_ResolveHost() failed: %s",
- SDLNet_GetError());
+ Fail("SDLNet_ResolveHost() failed: %s", SDLNet_GetError());
if ((fds = SDLNet_AllocSocketSet(MAX_PLAYERS + 1 + 1)) == NULL)
- Error(ERR_EXIT_NETWORK_SERVER, "SDLNet_AllocSocketSet() failed: %s"),
- SDLNet_GetError();
+ Fail("SDLNet_AllocSocketSet() failed: %s"), SDLNet_GetError();
if ((lfd = SDLNet_TCP_Open(&ip)) == NULL)
- Error(ERR_EXIT_NETWORK_SERVER, "SDLNet_TCP_Open() failed: %s"),
- SDLNet_GetError();
+ Fail("SDLNet_TCP_Open() failed: %s"), SDLNet_GetError();
if (SDLNet_TCP_AddSocket(fds, lfd) == -1)
- Error(ERR_EXIT_NETWORK_SERVER, "SDLNet_TCP_AddSocket() failed: %s"),
- SDLNet_GetError();
+ Fail("SDLNet_TCP_AddSocket() failed: %s"), SDLNet_GetError();
if ((udp = SDLNet_UDP_Open(port)) == NULL)
- Error(ERR_EXIT_NETWORK_SERVER, "SDLNet_UDP_Open() failed: %s",
- SDLNet_GetError());
+ Fail("SDLNet_UDP_Open() failed: %s", SDLNet_GetError());
if (SDLNet_UDP_AddSocket(fds, udp) == -1)
- Error(ERR_EXIT_NETWORK_SERVER, "SDLNet_TCP_AddSocket() failed: %s"),
- SDLNet_GetError();
+ Fail("SDLNet_TCP_AddSocket() failed: %s"), SDLNet_GetError();
Debug("network:server", "started up, listening on port %d", port);
Debug("network:server", "using protocol version %d.%d.%d",
break;
if (player == NULL) // should not happen
- Error(ERR_EXIT, "protocol error: reference to non-existing player %d",
- player_nr);
+ Fail("protocol error: reference to non-existing player %d", player_nr);
return player;
}
SDLNet_SocketSet udp_socket_set = SDLNet_AllocSocketSet(1);
if (!udp_socket_set)
- Error(ERR_EXIT, "SDLNet_AllocSocketSet() failed: %s"), SDLNet_GetError();
+ Fail("SDLNet_AllocSocketSet() failed: %s"), SDLNet_GetError();
udp = SDLNet_UDP_Open(0);
if (!udp)
- Error(ERR_EXIT, "SDLNet_UDP_Open() failed: %s", SDLNet_GetError());
+ Fail("SDLNet_UDP_Open() failed: %s", SDLNet_GetError());
if (SDLNet_UDP_AddSocket(udp_socket_set, udp) == -1)
- Error(ERR_EXIT_NETWORK_SERVER, "SDLNet_TCP_AddSocket() failed: %s"),
- SDLNet_GetError();
+ Fail("SDLNet_TCP_AddSocket() failed: %s"), SDLNet_GetError();
char *data_ptr = "network server UDB broadcast";
int data_len = strlen(data_ptr) + 1;
}
if (first_player.nr > MAX_PLAYERS)
- Error(ERR_EXIT, "sorry, more than %d players not allowed", MAX_PLAYERS);
+ Fail("sorry, more than %d players not allowed", MAX_PLAYERS);
Debug("network:client", "you get client # %d", new_client_nr);
for (player = &first_player; player; player = player->next)
{
if (player->nr == new_client_nr)
- Error(ERR_EXIT, "multiplayer server sent duplicate player id");
+ Fail("multiplayer server sent duplicate player id");
last_player = player;
}
leveldir_identifier = getStringCopy(getNetworkBufferString(read_buffer));
if (hasPathSeparator(leveldir_identifier))
- Error(ERR_EXIT, "protocol error: invalid filename from network client");
+ Fail("protocol error: invalid filename from network client");
InitNetworkLevelDirectory(leveldir_identifier);
file_info->filename = getPath2(network_level_dir, file_info->basename);
if (hasPathSeparator(file_info->basename))
- Error(ERR_EXIT, "protocol error: invalid filename from network client");
+ Fail("protocol error: invalid filename from network client");
int num_bytes = getNetworkBufferFile(read_buffer, file_info->filename);
tmpl_info->filename = getPath2(network_level_dir, tmpl_info->basename);
if (hasPathSeparator(tmpl_info->basename))
- Error(ERR_EXIT, "protocol error: invalid filename from network client");
+ Fail("protocol error: invalid filename from network client");
getNetworkBufferFile(read_buffer, tmpl_info->filename);
GDI_END);
if (gi == NULL)
- Error(ERR_EXIT, "cannot create gadget");
+ Fail("cannot create gadget");
screen_gadget[id] = gi;
}
GDI_END);
if (gi == NULL)
- Error(ERR_EXIT, "cannot create gadget");
+ Fail("cannot create gadget");
screen_gadget[id] = gi;
}
GDI_END);
if (gi == NULL)
- Error(ERR_EXIT, "cannot create gadget");
+ Fail("cannot create gadget");
screen_gadget[id] = gi;
}
GDI_END);
if (gi == NULL)
- Error(ERR_EXIT, "cannot create gadget");
+ Fail("cannot create gadget");
screen_gadget[id] = gi;
}
global.autoplay_leveldir);
if (autoplay_leveldir == NULL)
- Error(ERR_EXIT, "no such level identifier: '%s'",
- global.autoplay_leveldir);
+ Fail("no such level identifier: '%s'", global.autoplay_leveldir);
leveldir_current = autoplay_leveldir;
global.patchtapes_leveldir);
if (patchtapes_leveldir == NULL)
- Error(ERR_EXIT, "no such level identifier: '%s'",
- global.patchtapes_leveldir);
+ Fail("no such level identifier: '%s'", global.patchtapes_leveldir);
leveldir_current = patchtapes_leveldir;
GDI_END);
if (gi == NULL)
- Error(ERR_EXIT, "cannot create gadget");
+ Fail("cannot create gadget");
tape_gadget[id] = gi;
}
safety++;
if (safety > max_fieldx * max_fieldy)
- Error(ERR_EXIT, "Something went wrong in 'FloodFill()'. Please debug.");
+ Fail("Something went wrong in 'FloodFill()'. Please debug.");
old_element = field[from_x][from_y];
field[from_x][from_y] = fill_element;
GDI_END);
if (gi == NULL)
- Error(ERR_EXIT, "cannot create gadget");
+ Fail("cannot create gadget");
tool_gadget[id] = gi;
}