From: Holger Schemel Date: Wed, 16 Sep 2020 16:32:57 +0000 (+0200) Subject: changed warnings and debug output to use new generic logging functions X-Git-Tag: 4.2.0.3~36 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=4cd59cef0737229da365e385a8762e681a5e471f changed warnings and debug output to use new generic logging functions --- diff --git a/src/editor.c b/src/editor.c index 2aba3638..f2436f9e 100644 --- a/src/editor.c +++ b/src/editor.c @@ -5749,10 +5749,10 @@ static void ReinitializeElementList(void) int element = (*editor_elements_info[i].element_list)[j]; if (element >= NUM_FILE_ELEMENTS) - Error(ERR_WARN, "editor element %d is runtime element", element); + Warn("editor element %d is runtime element", element); if (strEqual(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT)) - Error(ERR_WARN, "no element description text for element %d", element); + Warn("no element description text for element %d", element); } } @@ -8408,8 +8408,7 @@ static void CheckElementDescriptions(void) for (i = 0; i < NUM_FILE_ELEMENTS; i++) if (getElementDescriptionFilename(i) == NULL && !IS_OBSOLETE(i)) - Error(ERR_WARN, "no element description file for element '%s'", - EL_NAME(i)); + Warn("no element description file for element '%s'", EL_NAME(i)); } #endif diff --git a/src/events.c b/src/events.c index 3a303fa5..b5f83725 100644 --- a/src/events.c +++ b/src/events.c @@ -503,7 +503,7 @@ static boolean CheckVirtualButtonPressed(int mx, int my, int button) void HandleButtonEvent(ButtonEvent *event) { #if DEBUG_EVENTS_BUTTON - Error(ERR_DEBUG, "BUTTON EVENT: button %d %s, x/y %d/%d\n", + Debug("event:button", "button %d %s, x/y %d/%d\n", event->button, event->type == EVENT_BUTTONPRESS ? "pressed" : "released", event->x, event->y); @@ -535,7 +535,7 @@ void HandleMotionEvent(MotionEvent *event) motion_status = TRUE; #if DEBUG_EVENTS_MOTION - Error(ERR_DEBUG, "MOTION EVENT: button %d moved, x/y %d/%d\n", + Debug("event:motion", "button %d moved, x/y %d/%d\n", button_status, event->x, event->y); #endif @@ -548,11 +548,11 @@ void HandleWheelEvent(WheelEvent *event) #if DEBUG_EVENTS_WHEEL #if 1 - Error(ERR_DEBUG, "WHEEL EVENT: mouse == %d, x/y == %d/%d\n", + Debug("event:wheel", "mouse == %d, x/y == %d/%d\n", event->which, event->x, event->y); #else // (SDL_MOUSEWHEEL_NORMAL/SDL_MOUSEWHEEL_FLIPPED needs SDL 2.0.4 or newer) - Error(ERR_DEBUG, "WHEEL EVENT: mouse == %d, x/y == %d/%d, direction == %s\n", + Debug("event:wheel", "mouse == %d, x/y == %d/%d, direction == %s\n", event->which, event->x, event->y, (event->direction == SDL_MOUSEWHEEL_NORMAL ? "SDL_MOUSEWHEEL_NORMAL" : "SDL_MOUSEWHEEL_FLIPPED")); @@ -603,7 +603,7 @@ void HandleWindowEvent(WindowEvent *event) subtype == SDL_WINDOWEVENT_CLOSE ? "SDL_WINDOWEVENT_CLOSE" : "(UNKNOWN)"); - Error(ERR_DEBUG, "WINDOW EVENT: '%s', %ld, %ld", + Debug("event:window", "name: '%s', data1: %ld, data2: %ld", event_name, event->data1, event->data2); #endif @@ -714,7 +714,7 @@ static void HandleFingerEvent_VirtualButtons(FingerEvent *event) // for any touch input event, enable overlay buttons (if activated) SetOverlayEnabled(TRUE); - Error(ERR_DEBUG, "::: key '%s' was '%s' [fingerId: %lld]", + Debug("event:finger", "key '%s' was '%s' [fingerId: %lld]", getKeyNameFromKey(key), key_status_name, event->fingerId); if (key_status == KEY_PRESSED) @@ -728,7 +728,7 @@ static void HandleFingerEvent_VirtualButtons(FingerEvent *event) if (touch_info[i].touched && touch_info[i].finger_id == event->fingerId) { - // Error(ERR_DEBUG, "MARK 1: %d", i); + // Debug("event:finger", "MARK 1: %d", i); break; } @@ -748,12 +748,12 @@ static void HandleFingerEvent_VirtualButtons(FingerEvent *event) oldest_pos = i; oldest_counter = touch_info[i].counter; - // Error(ERR_DEBUG, "MARK 2: %d", i); + // Debug("event:finger", "MARK 2: %d", i); } if (!touch_info[i].touched) { - // Error(ERR_DEBUG, "MARK 3: %d", i); + // Debug("event:finger", "MARK 3: %d", i); break; } @@ -764,7 +764,7 @@ static void HandleFingerEvent_VirtualButtons(FingerEvent *event) // all slots allocated -- use oldest slot i = oldest_pos; - // Error(ERR_DEBUG, "MARK 4: %d", i); + // Debug("event:finger", "MARK 4: %d", i); } } else @@ -775,7 +775,7 @@ static void HandleFingerEvent_VirtualButtons(FingerEvent *event) { HandleKey(key, KEY_RELEASED); - Error(ERR_DEBUG, "=> key == '%s', key_status == '%s' [slot %d] [1]", + Debug("event:finger", "key == '%s', key_status == '%s' [slot %d] [1]", getKeyNameFromKey(key), "KEY_RELEASED", i); } } @@ -794,7 +794,7 @@ static void HandleFingerEvent_VirtualButtons(FingerEvent *event) // undraw previous grid button when moving finger away overlay.grid_button_action &= ~touch_info[i].action; - Error(ERR_DEBUG, "=> key == '%s', key_status == '%s' [slot %d] [2]", + Debug("event:finger", "key == '%s', key_status == '%s' [slot %d] [2]", getKeyNameFromKey(touch_info[i].key), "KEY_RELEASED", i); } @@ -802,7 +802,7 @@ static void HandleFingerEvent_VirtualButtons(FingerEvent *event) { HandleKey(key, KEY_PRESSED); - Error(ERR_DEBUG, "=> key == '%s', key_status == '%s' [slot %d] [3]", + Debug("event:finger", "key == '%s', key_status == '%s' [slot %d] [3]", getKeyNameFromKey(key), "KEY_PRESSED", i); } } @@ -819,7 +819,7 @@ static void HandleFingerEvent_VirtualButtons(FingerEvent *event) { HandleKey(touch_info[i].key, KEY_RELEASED); - Error(ERR_DEBUG, "=> key == '%s', key_status == '%s' [slot %d] [4]", + Debug("event:finger", "key == '%s', key_status == '%s' [slot %d] [4]", getKeyNameFromKey(touch_info[i].key), "KEY_RELEASED", i); } @@ -862,7 +862,7 @@ static void HandleFingerEvent_WipeGestures(FingerEvent *event) motion_key_x = KSYM_UNDEFINED; motion_key_y = KSYM_UNDEFINED; - Error(ERR_DEBUG, "---------- MOVE STARTED (WAIT) ----------"); + Debug("event:finger", "---------- MOVE STARTED (WAIT) ----------"); } else { @@ -877,7 +877,7 @@ static void HandleFingerEvent_WipeGestures(FingerEvent *event) HandleKey(button_key, KEY_PRESSED); - Error(ERR_DEBUG, "---------- SNAP STARTED ----------"); + Debug("event:finger", "---------- SNAP STARTED ----------"); } } else if (event->type == EVENT_FINGERRELEASE) @@ -894,7 +894,7 @@ static void HandleFingerEvent_WipeGestures(FingerEvent *event) motion_key_x = KSYM_UNDEFINED; motion_key_y = KSYM_UNDEFINED; - Error(ERR_DEBUG, "---------- MOVE STOPPED ----------"); + Debug("event:finger", "---------- MOVE STOPPED ----------"); } else if (event->fingerId == button_id) { @@ -905,7 +905,7 @@ static void HandleFingerEvent_WipeGestures(FingerEvent *event) button_key = KSYM_UNDEFINED; - Error(ERR_DEBUG, "---------- SNAP STOPPED ----------"); + Debug("event:finger", "---------- SNAP STOPPED ----------"); } } else if (event->type == EVENT_FINGERMOTION) @@ -954,7 +954,7 @@ static void HandleFingerEvent_WipeGestures(FingerEvent *event) motion_key_x = new_motion_key_x; motion_key_y = new_motion_key_y; - Error(ERR_DEBUG, "---------- MOVE STARTED (MOVE) ----------"); + Debug("event:finger", "---------- MOVE STARTED (MOVE) ----------"); } } else if (event->fingerId == button_id) @@ -975,7 +975,7 @@ static void HandleFingerEvent_WipeGestures(FingerEvent *event) HandleKey(button_key, KEY_PRESSED); - Error(ERR_DEBUG, "---------- DROP STARTED ----------"); + Debug("event:finger", "---------- DROP STARTED ----------"); } } } @@ -984,7 +984,7 @@ static void HandleFingerEvent_WipeGestures(FingerEvent *event) void HandleFingerEvent(FingerEvent *event) { #if DEBUG_EVENTS_FINGER - Error(ERR_DEBUG, "FINGER EVENT: finger was %s, touch ID %lld, finger ID %lld, x/y %f/%f, dx/dy %f/%f, pressure %f", + Debug("event:finger", "finger was %s, touch ID %lld, finger ID %lld, x/y %f/%f, dx/dy %f/%f, pressure %f", event->type == EVENT_FINGERPRESS ? "pressed" : event->type == EVENT_FINGERRELEASE ? "released" : "moved", event->touchId, @@ -1051,7 +1051,7 @@ static void HandleButtonOrFinger_WipeGestures_MM(int mx, int my, int button) ClearPlayerMouseAction(); - Error(ERR_DEBUG, "---------- TOUCH ACTION STARTED ----------"); + Debug("event:finger", "---------- TOUCH ACTION STARTED ----------"); } } else if (button == MB_RELEASED && touched) @@ -1065,7 +1065,7 @@ static void HandleButtonOrFinger_WipeGestures_MM(int mx, int my, int button) else SetPlayerMouseAction(old_mx, old_my, MB_RELEASED); - Error(ERR_DEBUG, "---------- TOUCH ACTION STOPPED ----------"); + Debug("event:finger", "---------- TOUCH ACTION STOPPED ----------"); } if (touched) @@ -1090,7 +1090,7 @@ static void HandleButtonOrFinger_WipeGestures_MM(int mx, int my, int button) last_button = button_nr; - Error(ERR_DEBUG, "---------- TOUCH ACTION: ROTATING ----------"); + Debug("event:finger", "---------- TOUCH ACTION: ROTATING ----------"); } else { @@ -1098,7 +1098,7 @@ static void HandleButtonOrFinger_WipeGestures_MM(int mx, int my, int button) SetPlayerMouseAction(old_mx, old_my, MB_RELEASED); - Error(ERR_DEBUG, "---------- TOUCH ACTION PAUSED ----------"); + Debug("event:finger", "---------- TOUCH ACTION PAUSED ----------"); } } } @@ -1137,7 +1137,7 @@ static void HandleButtonOrFinger_FollowFinger_MM(int mx, int my, int button) ClearPlayerMouseAction(); - Error(ERR_DEBUG, "---------- TOUCH ACTION STARTED ----------"); + Debug("event:finger", "---------- TOUCH ACTION STARTED ----------"); } } else if (button == MB_RELEASED && touched) @@ -1151,7 +1151,7 @@ static void HandleButtonOrFinger_FollowFinger_MM(int mx, int my, int button) else SetPlayerMouseAction(old_mx, old_my, MB_RELEASED); - Error(ERR_DEBUG, "---------- TOUCH ACTION STOPPED ----------"); + Debug("event:finger", "---------- TOUCH ACTION STOPPED ----------"); } if (touched) @@ -1180,7 +1180,7 @@ static void HandleButtonOrFinger_FollowFinger_MM(int mx, int my, int button) tapped = FALSE; - Error(ERR_DEBUG, "---------- TOUCH ACTION: ROTATING ----------"); + Debug("event:finger", "---------- TOUCH ACTION: ROTATING ----------"); } else { @@ -1188,7 +1188,7 @@ static void HandleButtonOrFinger_FollowFinger_MM(int mx, int my, int button) SetPlayerMouseAction(old_mx, old_my, MB_RELEASED); - Error(ERR_DEBUG, "---------- TOUCH ACTION PAUSED ----------"); + Debug("event:finger", "---------- TOUCH ACTION PAUSED ----------"); } } } @@ -1223,7 +1223,7 @@ static void HandleButtonOrFinger_FollowFinger(int mx, int my, int button) motion_key_x = KSYM_UNDEFINED; motion_key_y = KSYM_UNDEFINED; - Error(ERR_DEBUG, "---------- TOUCH ACTION STARTED ----------"); + Debug("event:finger", "---------- TOUCH ACTION STARTED ----------"); } } else if (button == MB_RELEASED && touched) @@ -1242,13 +1242,13 @@ static void HandleButtonOrFinger_FollowFinger(int mx, int my, int button) { if (player_is_dropping) { - Error(ERR_DEBUG, "---------- DROP STOPPED ----------"); + Debug("event:finger", "---------- DROP STOPPED ----------"); HandleKey(setup.input[0].key.drop, KEY_RELEASED); } else { - Error(ERR_DEBUG, "---------- SNAP STOPPED ----------"); + Debug("event:finger", "---------- SNAP STOPPED ----------"); HandleKey(setup.input[0].key.snap, KEY_RELEASED); } @@ -1257,7 +1257,7 @@ static void HandleButtonOrFinger_FollowFinger(int mx, int my, int button) motion_key_x = KSYM_UNDEFINED; motion_key_y = KSYM_UNDEFINED; - Error(ERR_DEBUG, "---------- TOUCH ACTION STOPPED ----------"); + Debug("event:finger", "---------- TOUCH ACTION STOPPED ----------"); } if (touched) @@ -1301,13 +1301,13 @@ static void HandleButtonOrFinger_FollowFinger(int mx, int my, int button) if (player_is_dropping) { - Error(ERR_DEBUG, "---------- DROP STARTED ----------"); + Debug("event:finger", "---------- DROP STARTED ----------"); HandleKey(setup.input[0].key.drop, KEY_PRESSED); } else { - Error(ERR_DEBUG, "---------- SNAP STARTED ----------"); + Debug("event:finger", "---------- SNAP STARTED ----------"); HandleKey(setup.input[0].key.snap, KEY_PRESSED); } @@ -1317,7 +1317,7 @@ static void HandleButtonOrFinger_FollowFinger(int mx, int my, int button) if (player_is_dropping && player_drop_count == getPlayerInventorySize(0)) { - Error(ERR_DEBUG, "---------- DROP -> SNAP ----------"); + Debug("event:finger", "---------- DROP -> SNAP ----------"); HandleKey(setup.input[0].key.drop, KEY_RELEASED); HandleKey(setup.input[0].key.snap, KEY_PRESSED); @@ -1328,7 +1328,7 @@ static void HandleButtonOrFinger_FollowFinger(int mx, int my, int button) if (new_motion_key_x != motion_key_x) { - Error(ERR_DEBUG, "---------- %s %s ----------", + Debug("event:finger", "---------- %s %s ----------", started_on_player && !player_is_dropping ? "SNAPPING" : "MOVING", dx < 0 ? "LEFT" : dx > 0 ? "RIGHT" : "PAUSED"); @@ -1340,7 +1340,7 @@ static void HandleButtonOrFinger_FollowFinger(int mx, int my, int button) if (new_motion_key_y != motion_key_y) { - Error(ERR_DEBUG, "---------- %s %s ----------", + Debug("event:finger", "---------- %s %s ----------", started_on_player && !player_is_dropping ? "SNAPPING" : "MOVING", dy < 0 ? "UP" : dy > 0 ? "DOWN" : "PAUSED"); @@ -1400,7 +1400,7 @@ void HandleTextEvent(TextEvent *event) Key key = getKeyFromKeyName(text); #if DEBUG_EVENTS_TEXT - Error(ERR_DEBUG, "TEXT EVENT: text == '%s' [%d byte(s), '%c'/%d], resulting key == %d (%s) [%04x]", + Debug("event:text", "text == '%s' [%d byte(s), '%c'/%d], resulting key == %d (%s) [%04x]", text, strlen(text), text[0], (int)(text[0]), @@ -1437,7 +1437,7 @@ void HandleKeyEvent(KeyEvent *event) Key keymod = (with_modifiers ? GetEventKey(event, FALSE) : key); #if DEBUG_EVENTS_KEY - Error(ERR_DEBUG, "KEY EVENT: key was %s, keysym.scancode == %d, keysym.sym == %d, keymod = %d, GetKeyModState() = 0x%04x, resulting key == %d (%s)", + Debug("event:key", "key was %s, keysym.scancode == %d, keysym.sym == %d, keymod = %d, GetKeyModState() = 0x%04x, resulting key == %d (%s)", event->type == EVENT_KEYPRESS ? "pressed" : "released", event->keysym.scancode, event->keysym.sym, @@ -1478,12 +1478,12 @@ void HandleKeyEvent(KeyEvent *event) static int HandleDropFileEvent(char *filename) { - Error(ERR_DEBUG, "DROP FILE EVENT: '%s'", filename); + Debug("event:dropfile", "filename == '%s'", filename); // check and extract dropped zip files into correct user data directory if (!strSuffixLower(filename, ".zip")) { - Error(ERR_WARN, "file '%s' not supported", filename); + Warn("file '%s' not supported", filename); return TREE_TYPE_UNDEFINED; } @@ -1494,7 +1494,7 @@ static int HandleDropFileEvent(char *filename) if (directory == NULL) { - Error(ERR_WARN, "zip file '%s' has invalid content!", filename); + Warn("zip file '%s' has invalid content!", filename); return TREE_TYPE_UNDEFINED; } @@ -1536,7 +1536,7 @@ static int HandleDropFileEvent(char *filename) static void HandleDropTextEvent(char *text) { - Error(ERR_DEBUG, "DROP TEXT EVENT: '%s'", text); + Debug("event:droptext", "text == '%s'", text); } static void HandleDropCompleteEvent(int num_level_sets_succeeded, @@ -1808,7 +1808,7 @@ static void HandleKeysSpecial(Key key) cheat_input[cheat_input_len] = '\0'; #if DEBUG_EVENTS_KEY - Error(ERR_DEBUG, "SPECIAL KEY '%s' [%d]\n", cheat_input, cheat_input_len); + Debug("event:key:special", "'%s' [%d]\n", cheat_input, cheat_input_len); #endif if (game_status == GAME_MODE_MAIN) @@ -1959,13 +1959,13 @@ boolean HandleKeysDebug(Key key, int key_status) SetVideoFrameDelay(GameFrameDelay); if (GameFrameDelay > ONE_SECOND_DELAY) - Error(ERR_INFO, "frame delay == %d ms", GameFrameDelay); + Debug("event:key:debug", "frame delay == %d ms", GameFrameDelay); else if (GameFrameDelay != 0) - Error(ERR_INFO, "frame delay == %d ms (max. %d fps / %d %%)", + Debug("event:key:debug", "frame delay == %d ms (max. %d fps / %d %%)", GameFrameDelay, ONE_SECOND_DELAY / GameFrameDelay, GAME_FRAME_DELAY * 100 / GameFrameDelay); else - Error(ERR_INFO, "frame delay == 0 ms (maximum speed)"); + Debug("event:key:debug", "frame delay == 0 ms (maximum speed)"); return TRUE; } @@ -1978,14 +1978,14 @@ boolean HandleKeysDebug(Key key, int key_status) { options.debug = !options.debug; - Error(ERR_INFO, "debug mode %s", + Debug("event:key:debug", "debug mode %s", (options.debug ? "enabled" : "disabled")); return TRUE; } else if (key == KSYM_v) { - Error(ERR_INFO, "currently using game engine version %d", + Debug("event:key:debug", "currently using game engine version %d", game.engine_version); return TRUE; diff --git a/src/files.c b/src/files.c index 49813391..3882e34d 100644 --- a/src/files.c +++ b/src/files.c @@ -2070,7 +2070,7 @@ static char *getPackedLevelBasename(int type) if ((dir = openDirectory(directory)) == NULL) { - Error(ERR_WARN, "cannot read current level directory '%s'", directory); + Warn("cannot read current level directory '%s'", directory); return basename; } @@ -2375,7 +2375,7 @@ static int getMappedElement(int element) default: if (element >= NUM_FILE_ELEMENTS) { - Error(ERR_WARN, "invalid level element %d", element); + Warn("invalid level element %d", element); element = EL_UNKNOWN; } @@ -2623,7 +2623,7 @@ static int LoadLevel_CNT2(File *file, int chunk_size, struct LevelInfo *level) } else { - Error(ERR_WARN, "cannot load content for element '%d'", element); + Warn("cannot load content for element '%d'", element); } return chunk_size; @@ -2683,7 +2683,7 @@ static int LoadLevel_CUS1(File *file, int chunk_size, struct LevelInfo *level) if (IS_CUSTOM_ELEMENT(element)) element_info[element].properties[EP_BITFIELD_BASE_NR] = properties; else - Error(ERR_WARN, "invalid custom element number %d", element); + 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) @@ -2716,7 +2716,7 @@ static int LoadLevel_CUS2(File *file, int chunk_size, struct LevelInfo *level) if (IS_CUSTOM_ELEMENT(element)) element_info[element].change->target_element = custom_target_element; else - Error(ERR_WARN, "invalid custom element number %d", element); + Warn("invalid custom element number %d", element); } level->file_has_custom_elements = TRUE; @@ -2744,7 +2744,7 @@ static int LoadLevel_CUS3(File *file, int chunk_size, struct LevelInfo *level) if (!IS_CUSTOM_ELEMENT(element)) { - Error(ERR_WARN, "invalid custom element number %d", element); + Warn("invalid custom element number %d", element); element = EL_INTERNAL_DUMMY; } @@ -2830,9 +2830,10 @@ static int LoadLevel_CUS4(File *file, int chunk_size, struct LevelInfo *level) if (!IS_CUSTOM_ELEMENT(element)) { - Error(ERR_WARN, "invalid custom element number %d", element); + Warn("invalid custom element number %d", element); ReadUnusedBytesFromFile(file, chunk_size - 2); + return chunk_size; } @@ -2978,9 +2979,10 @@ static int LoadLevel_GRP1(File *file, int chunk_size, struct LevelInfo *level) if (!IS_GROUP_ELEMENT(element)) { - Error(ERR_WARN, "invalid group element number %d", element); + Warn("invalid group element number %d", element); ReadUnusedBytesFromFile(file, chunk_size - 2); + return chunk_size; } @@ -3042,9 +3044,8 @@ static int LoadLevel_MicroChunk(File *file, struct LevelFileConfigInfo *conf, if (num_entities > max_num_entities) { - Error(ERR_WARN, - "truncating number of entities for element %d from %d to %d", - element, num_entities, max_num_entities); + Warn("truncating number of entities for element %d from %d to %d", + element, num_entities, max_num_entities); num_entities = max_num_entities; } @@ -3053,8 +3054,7 @@ static int LoadLevel_MicroChunk(File *file, struct LevelFileConfigInfo *conf, data_type == TYPE_CONTENT_LIST)) { // for element and content lists, zero entities are not allowed - Error(ERR_WARN, "found empty list of entities for element %d", - element); + Warn("found empty list of entities for element %d", element); // do not set "num_entities" here to prevent reading behind buffer @@ -3145,9 +3145,9 @@ static int LoadLevel_MicroChunk(File *file, struct LevelFileConfigInfo *conf, int error_conf_chunk_token = conf_type & CONF_MASK_TOKEN; int error_element = real_element; - Error(ERR_WARN, "cannot load micro chunk '%s(%d)' value for element %d ['%s']", - error_conf_chunk_bytes, error_conf_chunk_token, - error_element, EL_NAME(error_element)); + Warn("cannot load micro chunk '%s(%d)' value for element %d ['%s']", + error_conf_chunk_bytes, error_conf_chunk_token, + error_element, EL_NAME(error_element)); } return micro_chunk_size; @@ -3264,8 +3264,8 @@ static int LoadLevel_CUSX(File *file, int chunk_size, struct LevelInfo *level) if (ei->num_change_pages == -1) { - Error(ERR_WARN, "LoadLevel_CUSX(): missing 'num_change_pages' for '%s'", - EL_NAME(element)); + Warn("LoadLevel_CUSX(): missing 'num_change_pages' for '%s'", + EL_NAME(element)); ei->num_change_pages = 1; @@ -3352,7 +3352,7 @@ static void LoadLevelFromFileInfo_RND(struct LevelInfo *level, if (level_info_only) return; - Error(ERR_WARN, "cannot read level '%s' -- using empty level", filename); + Warn("cannot read level '%s' -- using empty level", filename); if (!setup.editor.use_template_for_new_levels) return; @@ -3379,7 +3379,7 @@ static void LoadLevelFromFileInfo_RND(struct LevelInfo *level, { level->no_valid_file = TRUE; - Error(ERR_WARN, "unknown format of level file '%s'", filename); + Warn("unknown format of level file '%s'", filename); closeFile(file); @@ -3398,7 +3398,7 @@ static void LoadLevelFromFileInfo_RND(struct LevelInfo *level, { level->no_valid_file = TRUE; - Error(ERR_WARN, "unknown format of level file '%s'", filename); + Warn("unknown format of level file '%s'", filename); closeFile(file); @@ -3409,7 +3409,7 @@ static void LoadLevelFromFileInfo_RND(struct LevelInfo *level, { level->no_valid_file = TRUE; - Error(ERR_WARN, "unsupported version of level file '%s'", filename); + Warn("unsupported version of level file '%s'", filename); closeFile(file); @@ -3470,15 +3470,17 @@ static void LoadLevelFromFileInfo_RND(struct LevelInfo *level, if (chunk_info[i].name == NULL) { - Error(ERR_WARN, "unknown chunk '%s' in level file '%s'", - chunk_name, filename); + Warn("unknown chunk '%s' in level file '%s'", + chunk_name, filename); + ReadUnusedBytesFromFile(file, chunk_size); } else if (chunk_info[i].size != -1 && chunk_info[i].size != chunk_size) { - Error(ERR_WARN, "wrong size (%d) of chunk '%s' in level file '%s'", - chunk_size, chunk_name, filename); + Warn("wrong size (%d) of chunk '%s' in level file '%s'", + chunk_size, chunk_name, filename); + ReadUnusedBytesFromFile(file, chunk_size); } else @@ -3492,8 +3494,8 @@ static void LoadLevelFromFileInfo_RND(struct LevelInfo *level, // 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); + Warn("wrong size (%d) of chunk '%s' in level file '%s'", + chunk_size, chunk_name, filename); } } } @@ -3820,7 +3822,7 @@ static void CopyNativeLevel_SP_to_RND(struct LevelInfo *level) { num_invalid_elements++; - Error(ERR_DEBUG, "invalid element %d at position %d, %d", + Debug("level:native:SP", "invalid element %d at position %d, %d", element_old, x, y); } @@ -3829,8 +3831,8 @@ static void CopyNativeLevel_SP_to_RND(struct LevelInfo *level) } if (num_invalid_elements > 0) - Error(ERR_WARN, "found %d invalid elements%s", num_invalid_elements, - (!options.debug ? " (use '--debug' for more details)" : "")); + Warn("found %d invalid elements%s", num_invalid_elements, + (!options.debug ? " (use '--debug' for more details)" : "")); for (i = 0; i < MAX_PLAYERS; i++) level->initial_player_gravity[i] = @@ -3866,8 +3868,7 @@ static void CopyNativeLevel_SP_to_RND(struct LevelInfo *level) if (port_x < 0 || port_x >= level->fieldx || port_y < 0 || port_y >= level->fieldy) { - Error(ERR_WARN, "special port position (%d, %d) out of bounds", - port_x, port_y); + Warn("special port position (%d, %d) out of bounds", port_x, port_y); continue; } @@ -3877,7 +3878,7 @@ static void CopyNativeLevel_SP_to_RND(struct LevelInfo *level) if (port_element < EL_SP_GRAVITY_PORT_RIGHT || port_element > EL_SP_GRAVITY_PORT_UP) { - Error(ERR_WARN, "no special port at position (%d, %d)", port_x, port_y); + Warn("no special port at position (%d, %d)", port_x, port_y); continue; } @@ -3943,8 +3944,8 @@ static void CopyNativeTape_RND_to_SP(struct LevelInfo *level) if (demo->length + demo_entries >= SP_MAX_TAPE_LEN) { - Error(ERR_WARN, "tape truncated: size exceeds maximum SP demo size %d", - SP_MAX_TAPE_LEN); + Warn("tape truncated: size exceeds maximum SP demo size %d", + SP_MAX_TAPE_LEN); break; } @@ -3997,8 +3998,8 @@ static void CopyNativeTape_SP_to_RND(struct LevelInfo *level) if (!success) { - Error(ERR_WARN, "SP demo truncated: size exceeds maximum tape size %d", - MAX_TAPE_LEN); + Warn("SP demo truncated: size exceeds maximum tape size %d", + MAX_TAPE_LEN); break; } @@ -5554,7 +5555,8 @@ static int getMappedElement_DC(int element) element = EL_INVISIBLE_SAND; else { - Error(ERR_WARN, "unknown Diamond Caves element 0x%04x", element); + Warn("unknown Diamond Caves element 0x%04x", element); + element = EL_UNKNOWN; } break; @@ -5602,7 +5604,7 @@ static void LoadLevelFromFileStream_DC(File *file, struct LevelInfo *level, { level->no_valid_file = TRUE; - Error(ERR_WARN, "cannot decode level from stream -- using empty level"); + Warn("cannot decode level from stream -- using empty level"); return; } @@ -5735,7 +5737,7 @@ static void LoadLevelFromFileInfo_DC(struct LevelInfo *level, level->no_valid_file = TRUE; if (!level_info_only) - Error(ERR_WARN, "cannot read level '%s' -- using empty level", filename); + Warn("cannot read level '%s' -- using empty level", filename); return; } @@ -5753,8 +5755,7 @@ static void LoadLevelFromFileInfo_DC(struct LevelInfo *level, { level->no_valid_file = TRUE; - Error(ERR_WARN, "unknown DC level file '%s' -- using empty level", - filename); + Warn("unknown DC level file '%s' -- using empty level", filename); return; } @@ -5780,8 +5781,7 @@ static void LoadLevelFromFileInfo_DC(struct LevelInfo *level, { level->no_valid_file = TRUE; - Error(ERR_WARN, "cannot fseek in file '%s' -- using empty level", - filename); + Warn("cannot fseek in file '%s' -- using empty level", filename); return; } @@ -5799,8 +5799,7 @@ static void LoadLevelFromFileInfo_DC(struct LevelInfo *level, { level->no_valid_file = TRUE; - Error(ERR_WARN, "unknown DC2 level file '%s' -- using empty level", - filename); + Warn("unknown DC2 level file '%s' -- using empty level", filename); return; } @@ -5875,7 +5874,7 @@ static void LoadLevelFromFileInfo_SB(struct LevelInfo *level, level->no_valid_file = TRUE; if (!level_info_only) - Error(ERR_WARN, "cannot read level '%s' -- using empty level", filename); + Warn("cannot read level '%s' -- using empty level", filename); return; } @@ -6049,7 +6048,7 @@ static void LoadLevelFromFileInfo_SB(struct LevelInfo *level, { level->no_valid_file = TRUE; - Error(ERR_WARN, "cannot read level '%s' -- using empty level", filename); + Warn("cannot read level '%s' -- using empty level", filename); return; } @@ -6631,7 +6630,7 @@ void LoadLevelTemplate(int nr) { if (!fileExists(getGlobalLevelTemplateFilename())) { - Error(ERR_WARN, "no level template found for this level"); + Warn("no level template found for this level"); return; } @@ -6872,7 +6871,8 @@ static void SaveLevel_CNT2(FILE *file, struct LevelInfo *level, int element) // chunk header already written -- write empty chunk data WriteUnusedBytesToFile(file, LEVEL_CHUNK_CNT2_SIZE); - Error(ERR_WARN, "cannot save content for element '%d'", element); + Warn("cannot save content for element '%d'", element); + return; } @@ -6940,7 +6940,7 @@ static void SaveLevel_CUS1(FILE *file, struct LevelInfo *level, } if (check != num_changed_custom_elements) // should not happen - Error(ERR_WARN, "inconsistent number of custom element properties"); + Warn("inconsistent number of custom element properties"); } #endif @@ -6969,7 +6969,7 @@ static void SaveLevel_CUS2(FILE *file, struct LevelInfo *level, } if (check != num_changed_custom_elements) // should not happen - Error(ERR_WARN, "inconsistent number of custom target elements"); + Warn("inconsistent number of custom target elements"); } #endif @@ -7052,7 +7052,7 @@ static void SaveLevel_CUS3(FILE *file, struct LevelInfo *level, } if (check != num_changed_custom_elements) // should not happen - Error(ERR_WARN, "inconsistent number of custom element properties"); + Warn("inconsistent number of custom element properties"); } #endif @@ -7430,7 +7430,8 @@ static void SaveLevelFromFilename(struct LevelInfo *level, char *filename, if (!(file = fopen(filename, MODE_WRITE))) { - Error(ERR_WARN, "cannot save level file '%s'", filename); + Warn("cannot save level file '%s'", filename); + return; } @@ -7555,7 +7556,7 @@ void DumpLevel(struct LevelInfo *level) { if (level->no_level_file || level->no_valid_file) { - Error(ERR_WARN, "cannot dump -- no valid level file found"); + Warn("cannot dump -- no valid level file found"); return; } @@ -7746,7 +7747,7 @@ static int LoadTape_BODY(File *file, int chunk_size, struct TapeInfo *tape) { if (i >= MAX_TAPE_LEN) { - Error(ERR_WARN, "tape truncated -- size exceeds maximum tape size %d", + Warn("tape truncated -- size exceeds maximum tape size %d", MAX_TAPE_LEN); // tape too large; read and ignore remaining tape data from this chunk @@ -7892,7 +7893,7 @@ static void LoadTape_SokobanSolution(char *filename) default: tape.no_valid_file = TRUE; - Error(ERR_WARN, "unsupported Sokoban solution file '%s' ['%d']", filename, c); + Warn("unsupported Sokoban solution file '%s' ['%d']", filename, c); break; } @@ -7941,7 +7942,7 @@ void LoadTapeFromFilename(char *filename) { tape.no_valid_file = TRUE; - Error(ERR_WARN, "unknown format of tape file '%s'", filename); + Warn("unknown format of tape file '%s'", filename); closeFile(file); @@ -7960,7 +7961,7 @@ void LoadTapeFromFilename(char *filename) { tape.no_valid_file = TRUE; - Error(ERR_WARN, "unknown format of tape file '%s'", filename); + Warn("unknown format of tape file '%s'", filename); closeFile(file); @@ -7971,7 +7972,7 @@ void LoadTapeFromFilename(char *filename) { tape.no_valid_file = TRUE; - Error(ERR_WARN, "unsupported version of tape file '%s'", filename); + Warn("unsupported version of tape file '%s'", filename); closeFile(file); @@ -8015,15 +8016,17 @@ void LoadTapeFromFilename(char *filename) if (chunk_info[i].name == NULL) { - Error(ERR_WARN, "unknown chunk '%s' in tape file '%s'", + Warn("unknown chunk '%s' in tape file '%s'", chunk_name, filename); + ReadUnusedBytesFromFile(file, chunk_size); } else if (chunk_info[i].size != -1 && chunk_info[i].size != chunk_size) { - Error(ERR_WARN, "wrong size (%d) of chunk '%s' in tape file '%s'", + Warn("wrong size (%d) of chunk '%s' in tape file '%s'", chunk_size, chunk_name, filename); + ReadUnusedBytesFromFile(file, chunk_size); } else @@ -8037,7 +8040,7 @@ void LoadTapeFromFilename(char *filename) // information, so check them here if (chunk_size_expected != chunk_size) { - Error(ERR_WARN, "wrong size (%d) of chunk '%s' in tape file '%s'", + Warn("wrong size (%d) of chunk '%s' in tape file '%s'", chunk_size, chunk_name, filename); } } @@ -8153,7 +8156,8 @@ void SaveTapeToFilename(char *filename) if (!(file = fopen(filename, MODE_WRITE))) { - Error(ERR_WARN, "cannot save level recording file '%s'", filename); + Warn("cannot save level recording file '%s'", filename); + return; } @@ -8242,7 +8246,7 @@ void DumpTape(struct TapeInfo *tape) if (tape->no_valid_file) { - Error(ERR_WARN, "cannot dump -- no valid tape file found"); + Warn("cannot dump -- no valid tape file found"); return; } @@ -8322,15 +8326,18 @@ void LoadScore(int nr) if (!checkCookieString(cookie, SCORE_COOKIE)) { - Error(ERR_WARN, "unknown format of score file '%s'", filename); + Warn("unknown format of score file '%s'", filename); + fclose(file); + return; } for (i = 0; i < MAX_SCORE_ENTRIES; i++) { if (fscanf(file, "%d", &highscore[i].Score) == EOF) - Error(ERR_WARN, "fscanf() failed; %s", strerror(errno)); + Warn("fscanf() failed; %s", strerror(errno)); + if (fgets(line, MAX_LINE_LEN, file) == NULL) line[0] = '\0'; @@ -8363,7 +8370,8 @@ void SaveScore(int nr) if (!(file = fopen(filename, MODE_WRITE))) { - Error(ERR_WARN, "cannot save score for level %d", nr); + Warn("cannot save score for level %d", nr); + return; } @@ -9622,7 +9630,7 @@ void LoadSetupFromFilename(char *filename) } else { - Error(ERR_DEBUG, "using default setup values"); + Debug("setup", "using default setup values"); } } @@ -9739,7 +9747,7 @@ static void LoadSetup_ReadGameControllerMappings(SetupFileHash *mappings_hash, if (!(file = fopen(filename, MODE_READ))) { - Error(ERR_WARN, "cannot read game controller mappings file '%s'", filename); + Warn("cannot read game controller mappings file '%s'", filename); return; } @@ -9767,7 +9775,8 @@ void SaveSetup(void) if (!(file = fopen(filename, MODE_WRITE))) { - Error(ERR_WARN, "cannot write setup file '%s'", filename); + Warn("cannot write setup file '%s'", filename); + return; } @@ -9865,8 +9874,10 @@ void SaveSetup_AutoSetup(void) if (!(file = fopen(filename, MODE_WRITE))) { - Error(ERR_WARN, "cannot write auto setup file '%s'", filename); + Warn("cannot write auto setup file '%s'", filename); + free(filename); + return; } @@ -9892,8 +9903,10 @@ void SaveSetup_EditorCascade(void) if (!(file = fopen(filename, MODE_WRITE))) { - Error(ERR_WARN, "cannot write editor cascade state file '%s'", filename); + Warn("cannot write editor cascade state file '%s'", filename); + free(filename); + return; } @@ -9916,7 +9929,7 @@ static void SaveSetup_WriteGameControllerMappings(SetupFileHash *mappings_hash, if (!(file = fopen(filename, MODE_WRITE))) { - Error(ERR_WARN, "cannot write game controller mappings file '%s'",filename); + Warn("cannot write game controller mappings file '%s'", filename); return; } @@ -9989,7 +10002,7 @@ static int getElementFromToken(char *token) if (value != NULL) return atoi(value); - Error(ERR_WARN, "unknown element token '%s'", token); + Warn("unknown element token '%s'", token); return EL_UNDEFINED; } @@ -11342,19 +11355,19 @@ void LoadUserDefinedEditorElementList(int **elements, int *num_elements) { if (num_unknown_tokens == 0) { - Error(ERR_INFO_LINE, "-"); - Error(ERR_INFO, "warning: unknown token(s) found in config file:"); - Error(ERR_INFO, "- config file: '%s'", filename); + Warn("---"); + Warn("unknown token(s) found in config file:"); + Warn("- config file: '%s'", filename); num_unknown_tokens++; } - Error(ERR_INFO, "- token: '%s'", list->token); + Warn("- token: '%s'", list->token); } } if (num_unknown_tokens > 0) - Error(ERR_INFO_LINE, "-"); + Warn("---"); while (*num_elements % 4) // pad with empty elements, if needed (*elements)[(*num_elements)++] = EL_EMPTY; @@ -11364,8 +11377,8 @@ void LoadUserDefinedEditorElementList(int **elements, int *num_elements) #if 0 for (i = 0; i < *num_elements; i++) - printf("editor: element '%s' [%d]\n", - element_info[(*elements)[i]].token_name, (*elements)[i]); + Debug("editor", "element '%s' [%d]\n", + element_info[(*elements)[i]].token_name, (*elements)[i]); #endif } @@ -11544,7 +11557,8 @@ void LoadMusicInfo(void) if ((dir = openDirectory(music_directory)) == NULL) { - Error(ERR_WARN, "cannot read music directory '%s'", music_directory); + Warn("cannot read music directory '%s'", music_directory); + return; } @@ -11632,18 +11646,18 @@ static void print_unknown_token(char *filename, char *token, int token_nr) { if (token_nr == 0) { - Error(ERR_INFO_LINE, "-"); - Error(ERR_INFO, "warning: unknown token(s) found in config file:"); - Error(ERR_INFO, "- config file: '%s'", filename); + Warn("---"); + Warn("unknown token(s) found in config file:"); + Warn("- config file: '%s'", filename); } - Error(ERR_INFO, "- token: '%s'", token); + Warn("- token: '%s'", token); } static void print_unknown_token_end(int token_nr) { if (token_nr > 0) - Error(ERR_INFO_LINE, "-"); + Warn("---"); } void LoadHelpAnimInfo(void) @@ -12071,7 +12085,7 @@ void CreateLevelSketchImages(void) if (options.debug) fprintf(stderr, "\n"); - Error(ERR_INFO, "%d normal and small images created", NUM_FILE_ELEMENTS); + Info("%d normal and small images created", NUM_FILE_ELEMENTS); CloseAllAndExit(0); } diff --git a/src/game.c b/src/game.c index db613cc7..a7aa7752 100644 --- a/src/game.c +++ b/src/game.c @@ -11495,8 +11495,8 @@ static void GameActionsExt(void) EL_NAME(recursion_loop_element), " caused endless loop! Quit the game?"); - Error(ERR_WARN, "element '%s' caused endless loop in game engine", - EL_NAME(recursion_loop_element)); + Warn("element '%s' caused endless loop in game engine", + EL_NAME(recursion_loop_element)); RequestQuitGameExt(FALSE, level_editor_test_game, message); diff --git a/src/game_em/cave.c b/src/game_em/cave.c index c620133c..e33bdd58 100644 --- a/src/game_em/cave.c +++ b/src/game_em/cave.c @@ -109,7 +109,7 @@ boolean LoadNativeLevel_EM(char *filename, boolean level_info_only) if (!(file = openFile(filename, MODE_READ))) { if (!level_info_only) - Error(ERR_WARN, "cannot open level '%s' -- using empty level", filename); + Warn("cannot open level '%s' -- using empty level", filename); return FALSE; } @@ -120,7 +120,7 @@ boolean LoadNativeLevel_EM(char *filename, boolean level_info_only) if (raw_leveldata_length <= 0) { - Error(ERR_WARN, "cannot read level '%s' -- using empty level", filename); + Warn("cannot read level '%s' -- using empty level", filename); return FALSE; } @@ -129,7 +129,7 @@ boolean LoadNativeLevel_EM(char *filename, boolean level_info_only) if (file_version == FILE_VERSION_EM_UNKNOWN) { - Error(ERR_WARN, "unknown EM level '%s' -- using empty level", filename); + Warn("unknown EM level '%s' -- using empty level", filename); return FALSE; } diff --git a/src/game_em/convert.c b/src/game_em/convert.c index 2ea8e962..9219e197 100644 --- a/src/game_em/convert.c +++ b/src/game_em/convert.c @@ -217,7 +217,7 @@ int map_em_element_C_to_X(int element_em_cave) { if (element_em_cave < 0 || element_em_cave >= CAVE_TILE_MAX) { - Error(ERR_WARN, "invalid EM cave element %d", element_em_cave); + Warn("invalid EM cave element %d", element_em_cave); return Xblank; } @@ -246,7 +246,7 @@ int map_em_element_X_to_C(int element_em_game) if (element_em_game < 0 || element_em_game >= GAME_TILE_MAX) { - Error(ERR_WARN, "invalid EM game element %d", element_em_game); + Warn("invalid EM game element %d", element_em_game); return Cblank; } @@ -254,7 +254,7 @@ int map_em_element_X_to_C(int element_em_game) int element_em_cave = map_reverse[element_em_game]; if (element_em_cave == Cblank && element_em_game != Xblank) - Error(ERR_WARN, "unknown EM game element %d", element_em_game); + Warn("unknown EM game element %d", element_em_game); return element_em_cave; } diff --git a/src/game_em/reademc.c b/src/game_em/reademc.c index 5184d8d7..a192b9ba 100644 --- a/src/game_em/reademc.c +++ b/src/game_em/reademc.c @@ -693,8 +693,7 @@ int cleanup_em_level(unsigned char *src, int length, char *filename) /* if file has length of old-style level file, print (wrong) magic byte */ if (length < 2110) - Error(ERR_WARN, "unknown magic byte 0x%02x at position 0x%04x", - src[1983], 1983); + Warn("unknown magic byte 0x%02x at position 0x%04x", src[1983], 1983); return FILE_VERSION_EM_UNKNOWN; } @@ -788,7 +787,7 @@ int cleanup_em_level(unsigned char *src, int length, char *filename) length = 2172; if (options.debug) - Error(ERR_DEBUG, "EM level file version: %d", file_version); + Debug("level:native:EM", "EM level file version: %d", file_version); return file_version; } diff --git a/src/game_mm/mm_files.c b/src/game_mm/mm_files.c index caa92e02..542c847d 100644 --- a/src/game_mm/mm_files.c +++ b/src/game_mm/mm_files.c @@ -136,7 +136,8 @@ static int checkLevelElement(int element) { if (element >= EL_FIRST_RUNTIME_EL) { - Error(ERR_WARN, "invalid level element %d", element); + Warn("invalid level element %d", element); + element = EL_CHAR_FRAGE; } @@ -270,7 +271,7 @@ boolean LoadNativeLevel_MM(char *filename, boolean level_info_only) if (!(file = openFile(filename, MODE_READ))) { if (!level_info_only) - Error(ERR_WARN, "cannot read level '%s' - creating new level", filename); + Warn("cannot read level '%s' - creating new level", filename); return FALSE; } @@ -283,7 +284,7 @@ boolean LoadNativeLevel_MM(char *filename, boolean level_info_only) getFileChunk(file, chunk_name, NULL, BYTE_ORDER_BIG_ENDIAN); if (strcmp(chunk_name, "CAVE") != 0) { - Error(ERR_WARN, "unknown format of level file '%s'", filename); + Warn("unknown format of level file '%s'", filename); closeFile(file); @@ -299,7 +300,7 @@ boolean LoadNativeLevel_MM(char *filename, boolean level_info_only) if (!checkCookieString(cookie, LEVEL_COOKIE_TMPL)) { - Error(ERR_WARN, "unknown format of level file '%s'", filename); + Warn("unknown format of level file '%s'", filename); closeFile(file); @@ -309,7 +310,7 @@ boolean LoadNativeLevel_MM(char *filename, boolean level_info_only) if ((native_mm_level.file_version = getFileVersionFromCookieString(cookie)) == -1) { - Error(ERR_WARN, "unsupported version of level file '%s'", filename); + Warn("unsupported version of level file '%s'", filename); closeFile(file); @@ -327,7 +328,7 @@ boolean LoadNativeLevel_MM(char *filename, boolean level_info_only) if (chunk_info[i].name == NULL) { - Error(ERR_WARN, "unknown chunk '%s' in level file '%s'", + Warn("unknown chunk '%s' in level file '%s'", chunk_name, filename); ReadUnusedBytesFromFile(file, chunk_size); @@ -335,7 +336,7 @@ boolean LoadNativeLevel_MM(char *filename, boolean level_info_only) else if (chunk_info[i].size != -1 && chunk_info[i].size != chunk_size) { - Error(ERR_WARN, "wrong size (%d) of chunk '%s' in level file '%s'", + Warn("wrong size (%d) of chunk '%s' in level file '%s'", chunk_size, chunk_name, filename); ReadUnusedBytesFromFile(file, chunk_size); @@ -350,7 +351,7 @@ boolean LoadNativeLevel_MM(char *filename, boolean level_info_only) // 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'", + Warn("wrong size (%d) of chunk '%s' in level file '%s'", chunk_size, chunk_name, filename); } } @@ -419,7 +420,7 @@ void SaveNativeLevel_MM(char *filename) if (!(file = fopen(filename, MODE_WRITE))) { - Error(ERR_WARN, "cannot save level file '%s'", filename); + Warn("cannot save level file '%s'", filename); return; } diff --git a/src/game_mm/mm_game.c b/src/game_mm/mm_game.c index 30db4607..e3437a7c 100644 --- a/src/game_mm/mm_game.c +++ b/src/game_mm/mm_game.c @@ -717,7 +717,7 @@ void AddLaserEdge(int lx, int ly) if (clx < -2 || cly < -2 || clx >= SXSIZE + 2 || cly >= SYSIZE + 2) { - Error(ERR_WARN, "AddLaserEdge: out of bounds: %d, %d", lx, ly); + Warn("AddLaserEdge: out of bounds: %d, %d", lx, ly); return; } @@ -1042,14 +1042,14 @@ static void DrawLaserExt(int start_edge, int num_edges, int mode) if (start_edge < 0) { - Error(ERR_WARN, "DrawLaserExt: start_edge < 0"); + Warn("DrawLaserExt: start_edge < 0"); return; } if (num_edges < 0) { - Error(ERR_WARN, "DrawLaserExt: num_edges < 0"); + Warn("DrawLaserExt: num_edges < 0"); return; } @@ -1224,7 +1224,7 @@ void DrawLaser(int start_edge, int mode) { if (laser.num_edges - start_edge < 0) { - Error(ERR_WARN, "DrawLaser: laser.num_edges - start_edge < 0"); + Warn("DrawLaser: laser.num_edges - start_edge < 0"); return; } @@ -2879,7 +2879,8 @@ void RotateMirror(int x, int y, int button) if (edge == 0) { - Error(ERR_WARN, "RotateMirror: inconsistent field Hit[][]!\n"); + Warn("RotateMirror: inconsistent field Hit[][]!\n"); + edge = 1; } diff --git a/src/game_sp/file.c b/src/game_sp/file.c index a702fd4d..a66187c5 100644 --- a/src/game_sp/file.c +++ b/src/game_sp/file.c @@ -256,7 +256,7 @@ static void LoadNativeLevelFromFileStream_SP(File *file, int width, int height, } if (i >= SP_MAX_TAPE_LEN) - Error(ERR_WARN, "SP demo truncated: size exceeds maximum SP demo size %d", + Warn("SP demo truncated: size exceeds maximum SP demo size %d", SP_MAX_TAPE_LEN); native_sp_level.demo.length = i; @@ -292,7 +292,7 @@ boolean LoadNativeLevel_SP(char *filename, int level_pos, if (!(file = openFile(filename, MODE_READ))) { if (!level_info_only) - Error(ERR_WARN, "cannot open file '%s' -- using empty level", filename); + Warn("cannot open file '%s' -- using empty level", filename); return FALSE; } @@ -308,8 +308,7 @@ boolean LoadNativeLevel_SP(char *filename, int level_pos, if (!strEqual(mpx_chunk_name, "MPX ")) { - Error(ERR_WARN, "cannot find MPX ID in file '%s' -- using empty level", - filename); + Warn("cannot find MPX ID in file '%s' -- using empty level", filename); return FALSE; } @@ -318,8 +317,7 @@ boolean LoadNativeLevel_SP(char *filename, int level_pos, if (mpx_version != 1) { - Error(ERR_WARN, "unknown MPX version in file '%s' -- using empty level", - filename); + Warn("unknown MPX version in file '%s' -- using empty level", filename); return FALSE; } @@ -328,16 +326,14 @@ boolean LoadNativeLevel_SP(char *filename, int level_pos, if (mpx_level_count < 1) { - Error(ERR_WARN, "no MPX levels found in file '%s' -- using empty level", - filename); + Warn("no MPX levels found in file '%s' -- using empty level", filename); return FALSE; } if (level_pos >= mpx_level_count) { - Error(ERR_WARN, "MPX level not found in file '%s' -- using empty level", - filename); + Warn("MPX level not found in file '%s' -- using empty level", filename); return FALSE; } @@ -363,7 +359,7 @@ boolean LoadNativeLevel_SP(char *filename, int level_pos, // position file stream to the requested level (in case of level package) if (seekFile(file, file_seek_pos, SEEK_SET) != 0) { - Error(ERR_WARN, "cannot fseek in file '%s' -- using empty level", filename); + Warn("cannot fseek in file '%s' -- using empty level", filename); return FALSE; } @@ -475,7 +471,7 @@ boolean LoadNativeLevel_SP(char *filename, int level_pos, if (multipart_xpos * SP_STD_PLAYFIELD_WIDTH > SP_MAX_PLAYFIELD_WIDTH || multipart_ypos * SP_STD_PLAYFIELD_HEIGHT > SP_MAX_PLAYFIELD_HEIGHT) { - Error(ERR_WARN, "multi-part level is too big -- ignoring part of it"); + Warn("multi-part level is too big -- ignoring part of it"); break; } @@ -505,7 +501,7 @@ boolean LoadNativeLevel_SP(char *filename, int level_pos, { setLevelInfoToDefaults_SP(); - Error(ERR_WARN, "single part of multi-part level -- using empty level"); + Warn("single part of multi-part level -- using empty level"); } if (reading_multipart_level) @@ -524,7 +520,7 @@ void SaveNativeLevel_SP(char *filename) if (!(file = fopen(filename, MODE_WRITE))) { - Error(ERR_WARN, "cannot save native level file '%s'", filename); + Warn("cannot save native level file '%s'", filename); return; } diff --git a/src/init.c b/src/init.c index 1674aa56..bbf62e67 100644 --- a/src/init.c +++ b/src/init.c @@ -1224,13 +1224,13 @@ static int get_graphic_parameter_value(char *value_raw, char *suffix, int type) if (value == NULL) { - Error(ERR_INFO_LINE, "-"); - Error(ERR_INFO, "warning: error found in config file:"); - Error(ERR_INFO, "- config file: '%s'", getImageConfigFilename()); - Error(ERR_INFO, "error: invalid element token '%s'", value_raw); - Error(ERR_INFO, "custom graphic rejected for this element/action"); - Error(ERR_INFO, "fallback done to undefined element for this graphic"); - Error(ERR_INFO_LINE, "-"); + Warn("---"); + Warn("error found in config file:"); + Warn("- config file: '%s'", getImageConfigFilename()); + Warn("error: invalid element token '%s'", value_raw); + Warn("custom graphic rejected for this element/action"); + Warn("fallback done to undefined element for this graphic"); + Warn("---"); } return (value != NULL ? atoi(value) : EL_UNDEFINED); @@ -1242,13 +1242,13 @@ static int get_graphic_parameter_value(char *value_raw, char *suffix, int type) if (value == NULL) { - Error(ERR_INFO_LINE, "-"); - Error(ERR_INFO, "warning: error found in config file:"); - Error(ERR_INFO, "- config file: '%s'", getImageConfigFilename()); - Error(ERR_INFO, "error: invalid graphic token '%s'", value_raw); - Error(ERR_INFO, "custom graphic rejected for this element/action"); - Error(ERR_INFO, "fallback done to 'char_exclam' for this graphic"); - Error(ERR_INFO_LINE, "-"); + Warn("---"); + Warn("error found in config file:"); + Warn("- config file: '%s'", getImageConfigFilename()); + Warn("error: invalid graphic token '%s'", value_raw); + Warn("custom graphic rejected for this element/action"); + Warn("fallback done to 'char_exclam' for this graphic"); + Warn("---"); } return (value != NULL ? atoi(value) : fallback_graphic); @@ -1379,20 +1379,20 @@ static void set_graphic_parameters_ext(int graphic, int *parameter, { if (g->width <= 0) { - Error(ERR_INFO_LINE, "-"); - Error(ERR_WARN, "invalid value %d for '%s.width' (fallback done to %d)", - g->width, getTokenFromImageID(graphic), TILEX); - Error(ERR_INFO_LINE, "-"); + Warn("---"); + Warn("invalid value %d for '%s.width' (fallback done to %d)", + g->width, getTokenFromImageID(graphic), TILEX); + Warn("---"); g->width = TILEX; // will be checked to be inside bitmap later } if (g->height <= 0) { - Error(ERR_INFO_LINE, "-"); - Error(ERR_WARN, "invalid value %d for '%s.height' (fallback done to %d)", - g->height, getTokenFromImageID(graphic), TILEY); - Error(ERR_INFO_LINE, "-"); + Warn("---"); + Warn("invalid value %d for '%s.height' (fallback done to %d)", + g->height, getTokenFromImageID(graphic), TILEY); + Warn("---"); g->height = TILEY; // will be checked to be inside bitmap later } @@ -1650,18 +1650,18 @@ static void set_cloned_graphic_parameters(int graphic) if (num_references_followed >= max_num_images) { - Error(ERR_INFO_LINE, "-"); - Error(ERR_INFO, "warning: error found in config file:"); - Error(ERR_INFO, "- config file: '%s'", getImageConfigFilename()); - Error(ERR_INFO, "- config token: '%s'", getTokenFromImageID(graphic)); - Error(ERR_INFO, "error: loop discovered when resolving cloned graphics"); - Error(ERR_INFO, "custom graphic rejected for this element/action"); + Warn("---"); + Warn("error found in config file:"); + Warn("- config file: '%s'", getImageConfigFilename()); + Warn("- config token: '%s'", getTokenFromImageID(graphic)); + Warn("error: loop discovered when resolving cloned graphics"); + Warn("custom graphic rejected for this element/action"); if (graphic == fallback_graphic) Error(ERR_EXIT, "no fallback graphic available"); - Error(ERR_INFO, "fallback done to 'char_exclam' for this graphic"); - Error(ERR_INFO_LINE, "-"); + Warn("fallback done to 'char_exclam' for this graphic"); + Warn("---"); graphic_info[graphic] = graphic_info[fallback_graphic]; } @@ -1800,22 +1800,21 @@ static void InitGraphicInfo(void) src_x + width > src_bitmap_width || src_y + height > src_bitmap_height) { - Error(ERR_INFO_LINE, "-"); - Error(ERR_INFO, "warning: error found in config file:"); - Error(ERR_INFO, "- config file: '%s'", getImageConfigFilename()); - Error(ERR_INFO, "- config token: '%s'", getTokenFromImageID(i)); - Error(ERR_INFO, "- image file: '%s'", src_bitmap->source_filename); - Error(ERR_INFO, "- frame size: %d, %d", width, height); - Error(ERR_INFO, - "error: first animation frame out of bounds (%d, %d) [%d, %d]", - src_x, src_y, src_bitmap_width, src_bitmap_height); - Error(ERR_INFO, "custom graphic rejected for this element/action"); + Warn("---"); + Warn("error found in config file:"); + Warn("- config file: '%s'", getImageConfigFilename()); + Warn("- config token: '%s'", getTokenFromImageID(i)); + Warn("- image file: '%s'", src_bitmap->source_filename); + Warn("- frame size: %d, %d", width, height); + Warn("error: first animation frame out of bounds (%d, %d) [%d, %d]", + src_x, src_y, src_bitmap_width, src_bitmap_height); + Warn("custom graphic rejected for this element/action"); if (i == fallback_graphic) Error(ERR_EXIT, "no fallback graphic available"); - Error(ERR_INFO, "fallback done to 'char_exclam' for this graphic"); - Error(ERR_INFO_LINE, "-"); + Warn("fallback done to 'char_exclam' for this graphic"); + Warn("---"); graphic_info[i] = graphic_info[fallback_graphic]; @@ -1832,22 +1831,21 @@ static void InitGraphicInfo(void) src_x + width > src_bitmap_width || src_y + height > src_bitmap_height) { - Error(ERR_INFO_LINE, "-"); - Error(ERR_INFO, "warning: error found in config file:"); - Error(ERR_INFO, "- config file: '%s'", getImageConfigFilename()); - Error(ERR_INFO, "- config token: '%s'", getTokenFromImageID(i)); - Error(ERR_INFO, "- image file: '%s'", src_bitmap->source_filename); - Error(ERR_INFO, "- frame size: %d, %d", width, height); - Error(ERR_INFO, - "error: last animation frame (%d) out of bounds (%d, %d) [%d, %d]", - last_frame, src_x, src_y, src_bitmap_width, src_bitmap_height); - Error(ERR_INFO, "custom graphic rejected for this element/action"); + Warn("---"); + Warn("error found in config file:"); + Warn("- config file: '%s'", getImageConfigFilename()); + Warn("- config token: '%s'", getTokenFromImageID(i)); + Warn("- image file: '%s'", src_bitmap->source_filename); + Warn("- frame size: %d, %d", width, height); + Warn("error: last animation frame (%d) out of bounds (%d, %d) [%d, %d]", + last_frame, src_x, src_y, src_bitmap_width, src_bitmap_height); + Warn("custom graphic rejected for this element/action"); if (i == fallback_graphic) Error(ERR_EXIT, "no fallback graphic available"); - Error(ERR_INFO, "fallback done to 'char_exclam' for this graphic"); - Error(ERR_INFO_LINE, "-"); + Warn("fallback done to 'char_exclam' for this graphic"); + Warn("---"); graphic_info[i] = graphic_info[fallback_graphic]; } @@ -2442,7 +2440,7 @@ static void ResolveGroupElementExt(int group_element, int recursion_depth) if (recursion_depth > NUM_GROUP_ELEMENTS) // recursion too deep { - Error(ERR_WARN, "recursion too deep when resolving group element %d", + Warn("recursion too deep when resolving group element %d", group_element - EL_GROUP_START + 1); // replace element which caused too deep recursion by question mark @@ -6155,7 +6153,7 @@ void OpenAll(void) #if defined(PLATFORM_UNIX) NetworkServer(network.server_port, TRUE); #else - Error(ERR_WARN, "networking only supported in Unix version"); + Warn("networking only supported in Unix version"); #endif exit(0); // never reached, server loops forever @@ -6260,16 +6258,16 @@ void OpenAll(void) DrawMainMenu(); #if 0 - Error(ERR_DEBUG, "::: SDL_GetBasePath() == '%s'", + Debug("internal:path", "SDL_GetBasePath() == '%s'", SDL_GetBasePath()); - Error(ERR_DEBUG, "::: SDL_GetPrefPath() == '%s'", + Debug("internal:path", "SDL_GetPrefPath() == '%s'", SDL_GetPrefPath("artsoft", "rocksndiamonds")); #if defined(PLATFORM_ANDROID) - Error(ERR_DEBUG, "::: SDL_AndroidGetInternalStoragePath() == '%s'", + Debug("internal:path", "SDL_AndroidGetInternalStoragePath() == '%s'", SDL_AndroidGetInternalStoragePath()); - Error(ERR_DEBUG, "::: SDL_AndroidGetExternalStoragePath() == '%s'", + Debug("internal:path", "SDL_AndroidGetExternalStoragePath() == '%s'", SDL_AndroidGetExternalStoragePath()); - Error(ERR_DEBUG, "::: SDL_AndroidGetExternalStorageState() == '%s'", + Debug("internal:path", "SDL_AndroidGetExternalStorageState() == '%s'", (SDL_AndroidGetExternalStorageState() & SDL_ANDROID_EXTERNAL_STORAGE_WRITE ? "writable" : SDL_AndroidGetExternalStorageState() & diff --git a/src/libgame/image.c b/src/libgame/image.c index b26a508a..820b966c 100644 --- a/src/libgame/image.c +++ b/src/libgame/image.c @@ -43,8 +43,8 @@ static void *Load_Image(char *filename) if ((img_info->bitmaps[IMG_BITMAP_STANDARD] = LoadImage(filename)) == NULL) { - Error(ERR_WARN, "cannot load image file '%s': LoadImage() failed: %s", - filename, GetError()); + Warn("cannot load image file '%s': LoadImage() failed: %s", + filename, GetError()); free(img_info); diff --git a/src/libgame/joystick.c b/src/libgame/joystick.c index 0c61c57a..4a1bc7d5 100644 --- a/src/libgame/joystick.c +++ b/src/libgame/joystick.c @@ -211,10 +211,11 @@ int JoystickExt(int player_nr, boolean use_as_joystick_nr) if (!ReadJoystick(joystick_nr, &js_x, &js_y, &js_b1, &js_b2)) { - Error(ERR_WARN, "cannot read joystick device '%s'", - setup.input[player_nr].joy.device_name); + Warn("cannot read joystick device '%s'", + setup.input[player_nr].joy.device_name); joystick.status = JOYSTICK_NOT_AVAILABLE; + return JOY_NO_ACTION; } diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 7047ba92..24b6d248 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1870,7 +1870,7 @@ static void translate_keyname(Key *keysym, char **x11name, char **name, int mode } if (key == KSYM_UNDEFINED) - Error(ERR_WARN, "getKeyFromKeyName(): not completely implemented"); + Warn("getKeyFromKeyName(): not completely implemented"); *keysym = key; } @@ -3389,53 +3389,53 @@ static void LoadArtworkConfigFromFilename(struct ArtworkListInfo *artwork_info, if (options.debug && dynamic_tokens_found) { - Error(ERR_INFO_LINE, "-"); - Error(ERR_INFO, "dynamic token(s) found in config file:"); - Error(ERR_INFO, "- config file: '%s'", filename); + Debug("config", "---"); + Debug("config", "dynamic token(s) found in config file:"); + Debug("config", "- config file: '%s'", filename); for (list = setup_file_list; list != NULL; list = list->next) { char *value = getHashEntry(extra_file_hash, list->token); if (value != NULL && strEqual(value, known_token_value)) - Error(ERR_INFO, "- dynamic token: '%s'", list->token); + Debug("config", "- dynamic token: '%s'", list->token); } - Error(ERR_INFO_LINE, "-"); + Debug("config", "---"); } if (unknown_tokens_found) { - Error(ERR_INFO_LINE, "-"); - Error(ERR_INFO, "warning: unknown token(s) found in config file:"); - Error(ERR_INFO, "- config file: '%s'", filename); + Warn("---"); + Warn("unknown token(s) found in config file:"); + Warn("- config file: '%s'", filename); for (list = setup_file_list; list != NULL; list = list->next) { char *value = getHashEntry(extra_file_hash, list->token); if (value != NULL && !strEqual(value, known_token_value)) - Error(ERR_INFO, "- dynamic token: '%s'", list->token); + Warn("- dynamic token: '%s'", list->token); } - Error(ERR_INFO_LINE, "-"); + Warn("---"); } if (undefined_values_found) { - Error(ERR_INFO_LINE, "-"); - Error(ERR_INFO, "warning: undefined values found in config file:"); - Error(ERR_INFO, "- config file: '%s'", filename); + Warn("---"); + Warn("undefined values found in config file:"); + Warn("- config file: '%s'", filename); for (list = setup_file_list; list != NULL; list = list->next) { char *value = getHashEntry(empty_file_hash, list->token); if (value != NULL) - Error(ERR_INFO, "- undefined value for token: '%s'", list->token); + Warn("- undefined value for token: '%s'", list->token); } - Error(ERR_INFO_LINE, "-"); + Warn("---"); } freeSetupFileList(setup_file_list); @@ -3541,7 +3541,7 @@ static void replaceArtworkListEntry(struct ArtworkListInfo *artwork_info, if (filename == NULL) { - Error(ERR_WARN, "cannot find artwork file '%s'", basename); + Warn("cannot find artwork file '%s'", basename); basename = file_list_entry->default_filename; @@ -3567,7 +3567,7 @@ static void replaceArtworkListEntry(struct ArtworkListInfo *artwork_info, file_list_entry->fallback_to_default = TRUE; - Error(ERR_WARN, "trying default artwork file '%s'", basename); + Warn("trying default artwork file '%s'", basename); filename = getCustomArtworkFilename(basename, artwork_info->type); @@ -3725,8 +3725,8 @@ void OpenLogFiles(void) { program.log_file[i] = program.log_file_default[i]; // reset to default - Error(ERR_WARN, "cannot open file '%s' for writing: %s", - program.log_filename[i], strerror(errno)); + Warn("cannot open file '%s' for writing: %s", + program.log_filename[i], strerror(errno)); } // output should be unbuffered so it is not truncated in a crash diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index 40766745..794bad30 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -266,14 +266,14 @@ static void SDLSetWindowIcon(char *basename) if (filename == NULL) { - Error(ERR_WARN, "SDLSetWindowIcon(): cannot find file '%s'", basename); + Warn("SDLSetWindowIcon(): cannot find file '%s'", basename); return; } if ((surface = IMG_Load(filename)) == NULL) { - Error(ERR_WARN, "IMG_Load('%s') failed: %s", basename, SDL_GetError()); + Warn("IMG_Load('%s') failed: %s", basename, SDL_GetError()); return; } @@ -615,21 +615,21 @@ static boolean SDLCreateScreen(boolean fullscreen) new_surface = SDL_CreateRGBSurface(0, width, height, 32, 0,0,0, 0); if (new_surface == NULL) - Error(ERR_WARN, "SDL_CreateRGBSurface() failed: %s", SDL_GetError()); + Warn("SDL_CreateRGBSurface() failed: %s", SDL_GetError()); } else { - Error(ERR_WARN, "SDL_CreateTexture() failed: %s", SDL_GetError()); + Warn("SDL_CreateTexture() failed: %s", SDL_GetError()); } } else { - Error(ERR_WARN, "SDL_CreateRenderer() failed: %s", SDL_GetError()); + Warn("SDL_CreateRenderer() failed: %s", SDL_GetError()); } } else { - Error(ERR_WARN, "SDL_CreateWindow() failed: %s", SDL_GetError()); + Warn("SDL_CreateWindow() failed: %s", SDL_GetError()); } SDLSetScreenProperties(); @@ -798,7 +798,7 @@ void SDLSetDisplaySize(void) video.display_height = h; #if 0 - Error(ERR_DEBUG, "SDL renderer size: %d x %d", + Debug("video", "SDL renderer size: %d x %d", video.display_width, video.display_height); #endif } @@ -812,7 +812,7 @@ void SDLSetDisplaySize(void) video.display_height = display_bounds.h; #if 0 - Error(ERR_DEBUG, "SDL display size: %d x %d", + Debug("video", "SDL display size: %d x %d", video.display_width, video.display_height); #endif } @@ -843,7 +843,7 @@ void SDLSetScreenSizeAndOffsets(int width, int height) video.screen_yoffset = (video.screen_height - height) / 2; #if 0 - Error(ERR_DEBUG, "Changing screen from %dx%d to %dx%d (%.2f to %.2f)", + Debug("video", "Changing screen from %dx%d to %dx%d (%.2f to %.2f)", width, height, video.screen_width, video.screen_height, ratio_video, ratio_display); @@ -2393,7 +2393,8 @@ void SDLOpenAudio(void) if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) { - Error(ERR_WARN, "SDL_InitSubSystem() failed: %s", SDL_GetError()); + Warn("SDL_InitSubSystem() failed: %s", SDL_GetError()); + return; } @@ -2401,7 +2402,8 @@ void SDLOpenAudio(void) AUDIO_NUM_CHANNELS_STEREO, setup.system.audio_fragment_size) < 0) { - Error(ERR_WARN, "Mix_OpenAudio() failed: %s", SDL_GetError()); + Warn("Mix_OpenAudio() failed: %s", SDL_GetError()); + return; } @@ -2492,7 +2494,7 @@ boolean SDLOpenJoystick(int nr) sdl_is_controller[nr] = SDL_IsGameController(nr); #if DEBUG_JOYSTICKS - Error(ERR_DEBUG, "opening joystick %d (%s)", + Debug("joystick", "opening joystick %d (%s)", nr, (sdl_is_controller[nr] ? "game controller" : "joystick")); #endif @@ -2510,7 +2512,7 @@ void SDLCloseJoystick(int nr) return; #if DEBUG_JOYSTICKS - Error(ERR_DEBUG, "closing joystick %d", nr); + Debug("joystick", "closing joystick %d", nr); #endif if (sdl_is_controller[nr]) @@ -2596,7 +2598,7 @@ void HandleJoystickEvent(Event *event) { case SDL_CONTROLLERDEVICEADDED: #if DEBUG_JOYSTICKS - Error(ERR_DEBUG, "SDL_CONTROLLERDEVICEADDED: device %d added", + Debug("joystick", "SDL_CONTROLLERDEVICEADDED: device %d added", event->cdevice.which); #endif InitJoysticks(); @@ -2604,7 +2606,7 @@ void HandleJoystickEvent(Event *event) case SDL_CONTROLLERDEVICEREMOVED: #if DEBUG_JOYSTICKS - Error(ERR_DEBUG, "SDL_CONTROLLERDEVICEREMOVED: device %d removed", + Debug("joystick", "SDL_CONTROLLERDEVICEREMOVED: device %d removed", event->cdevice.which); #endif InitJoysticks(); @@ -2612,7 +2614,7 @@ void HandleJoystickEvent(Event *event) case SDL_CONTROLLERAXISMOTION: #if DEBUG_JOYSTICKS - Error(ERR_DEBUG, "SDL_CONTROLLERAXISMOTION: device %d, axis %d: %d", + Debug("joystick", "SDL_CONTROLLERAXISMOTION: device %d, axis %d: %d", event->caxis.which, event->caxis.axis, event->caxis.value); #endif setJoystickAxis(event->caxis.which, @@ -2622,7 +2624,7 @@ void HandleJoystickEvent(Event *event) case SDL_CONTROLLERBUTTONDOWN: #if DEBUG_JOYSTICKS - Error(ERR_DEBUG, "SDL_CONTROLLERBUTTONDOWN: device %d, button %d", + Debug("joystick", "SDL_CONTROLLERBUTTONDOWN: device %d, button %d", event->cbutton.which, event->cbutton.button); #endif setJoystickButton(event->cbutton.which, @@ -2632,7 +2634,7 @@ void HandleJoystickEvent(Event *event) case SDL_CONTROLLERBUTTONUP: #if DEBUG_JOYSTICKS - Error(ERR_DEBUG, "SDL_CONTROLLERBUTTONUP: device %d, button %d", + Debug("joystick", "SDL_CONTROLLERBUTTONUP: device %d, button %d", event->cbutton.which, event->cbutton.button); #endif setJoystickButton(event->cbutton.which, @@ -2645,7 +2647,7 @@ void HandleJoystickEvent(Event *event) break; #if DEBUG_JOYSTICKS - Error(ERR_DEBUG, "SDL_JOYAXISMOTION: device %d, axis %d: %d", + Debug("joystick", "SDL_JOYAXISMOTION: device %d, axis %d: %d", event->jaxis.which, event->jaxis.axis, event->jaxis.value); #endif if (event->jaxis.axis < 4) @@ -2659,7 +2661,7 @@ void HandleJoystickEvent(Event *event) break; #if DEBUG_JOYSTICKS - Error(ERR_DEBUG, "SDL_JOYBUTTONDOWN: device %d, button %d", + Debug("joystick", "SDL_JOYBUTTONDOWN: device %d, button %d", event->jbutton.which, event->jbutton.button); #endif if (event->jbutton.button < 4) @@ -2673,7 +2675,7 @@ void HandleJoystickEvent(Event *event) break; #if DEBUG_JOYSTICKS - Error(ERR_DEBUG, "SDL_JOYBUTTONUP: device %d, button %d", + Debug("joystick", "SDL_JOYBUTTONUP: device %d, button %d", event->jbutton.which, event->jbutton.button); #endif if (event->jbutton.button < 4) @@ -2707,6 +2709,7 @@ void SDLInitJoysticks(void) if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) < 0) { Error(ERR_EXIT, "SDL_Init() failed: %s", SDL_GetError()); + return; } @@ -2714,10 +2717,11 @@ void SDLInitJoysticks(void) // the included game controller base mappings should always be found if (num_mappings == -1) - Error(ERR_WARN, "no game controller base mappings found"); + Warn("no game controller base mappings found"); #if DEBUG_JOYSTICKS else - Error(ERR_INFO, "%d game controller base mapping(s) added", num_mappings); + Debug("joystick", "%d game controller base mapping(s) added", + num_mappings); #endif num_mappings = SDL_GameControllerAddMappingsFromFile(mappings_file_user); @@ -2725,11 +2729,12 @@ void SDLInitJoysticks(void) #if DEBUG_JOYSTICKS // the personal game controller user mappings may or may not be found if (num_mappings == -1) - Error(ERR_WARN, "no game controller user mappings found"); + Warn("no game controller user mappings found"); else - Error(ERR_INFO, "%d game controller user mapping(s) added", num_mappings); + Debug("joystick", , "%d game controller user mapping(s) added", + num_mappings); - Error(ERR_INFO, "%d joystick(s) found:", SDL_NumJoysticks()); + Debug("joystick", "%d joystick(s) found:", SDL_NumJoysticks()); #endif checked_free(mappings_file_base); @@ -2751,7 +2756,7 @@ void SDLInitJoysticks(void) type = "joystick"; } - Error(ERR_INFO, "- joystick %d (%s): '%s'", + Debug("joystick", "- joystick %d (%s): '%s'", i, type, (name ? name : "(Unknown)")); } #endif @@ -2767,7 +2772,7 @@ void SDLInitJoysticks(void) if (joystick_nr >= SDL_NumJoysticks()) { if (setup.input[i].use_joystick && print_warning) - Error(ERR_WARN, "cannot find joystick %d", joystick_nr); + Warn("cannot find joystick %d", joystick_nr); joystick_nr = -1; } @@ -2786,7 +2791,7 @@ void SDLInitJoysticks(void) if (SDLOpenJoystick(i)) joystick.status = JOYSTICK_ACTIVATED; else if (print_warning) - Error(ERR_WARN, "cannot open joystick %d", i); + Warn("cannot open joystick %d", i); } SDLClearJoystickState(); diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 5beaafd2..599bff5d 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -820,9 +820,7 @@ char *getCustomImageFilename(char *basename) { free(filename); - if (options.debug) - Error(ERR_WARN, "cannot find artwork file '%s' (using fallback)", - basename); + Warn("cannot find artwork file '%s' (using fallback)", basename); // 6th try: look for fallback artwork in old default artwork directory // (needed to prevent errors when trying to access unused artwork files) @@ -893,9 +891,7 @@ char *getCustomSoundFilename(char *basename) { free(filename); - if (options.debug) - Error(ERR_WARN, "cannot find artwork file '%s' (using fallback)", - basename); + Warn("cannot find artwork file '%s' (using fallback)", basename); // 6th try: look for fallback artwork in old default artwork directory // (needed to prevent errors when trying to access unused artwork files) @@ -966,9 +962,7 @@ char *getCustomMusicFilename(char *basename) { free(filename); - if (options.debug) - Error(ERR_WARN, "cannot find artwork file '%s' (using fallback)", - basename); + Warn("cannot find artwork file '%s' (using fallback)", basename); // 6th try: look for fallback artwork in old default artwork directory // (needed to prevent errors when trying to access unused artwork files) @@ -1639,8 +1633,7 @@ void createDirectory(char *dir, char *text, int permission_class) } if (posix_mkdir(dir, dir_mode) != 0) - Error(ERR_WARN, "cannot create %s directory '%s': %s", - text, dir, strerror(errno)); + Warn("cannot create %s directory '%s': %s", text, dir, strerror(errno)); if (permission_class == PERMS_PUBLIC && !running_setgid) chmod(dir, dir_mode); @@ -2054,25 +2047,25 @@ static boolean getTokenValueFromSetupLineExt(char *line, { if (!token_value_separator_warning) { - Error(ERR_INFO_LINE, "-"); + Debug("setup", "---"); if (filename != NULL) { - Error(ERR_WARN, "missing token/value separator(s) in config file:"); - Error(ERR_INFO, "- config file: '%s'", filename); + Debug("setup", "missing token/value separator(s) in config file:"); + Debug("setup", "- config file: '%s'", filename); } else { - Error(ERR_WARN, "missing token/value separator(s):"); + Debug("setup", "missing token/value separator(s):"); } token_value_separator_warning = TRUE; } if (filename != NULL) - Error(ERR_INFO, "- line %d: '%s'", line_nr, line_raw); + Debug("setup", "- line %d: '%s'", line_nr, line_raw); else - Error(ERR_INFO, "- line: '%s'", line_raw); + Debug("setup", "- line: '%s'", line_raw); } #endif } @@ -2125,7 +2118,7 @@ static boolean loadSetupFileData(void *setup_file_data, char *filename, if (!(file = openFile(filename, MODE_READ))) { #if DEBUG_NO_CONFIG_FILE - Error(ERR_DEBUG, "cannot open configuration file '%s'", filename); + Debug("setup", "cannot open configuration file '%s'", filename); #endif return FALSE; @@ -2206,7 +2199,7 @@ static boolean loadSetupFileData(void *setup_file_data, char *filename, } else { - Error(ERR_WARN, "ignoring already processed file '%s'", value); + Warn("ignoring already processed file '%s'", value); } } else @@ -2221,16 +2214,16 @@ static boolean loadSetupFileData(void *setup_file_data, char *filename, { if (!token_already_exists_warning) { - Error(ERR_INFO_LINE, "-"); - Error(ERR_WARN, "duplicate token(s) found in config file:"); - Error(ERR_INFO, "- config file: '%s'", filename); + Debug("setup", "---"); + Debug("setup", "duplicate token(s) found in config file:"); + Debug("setup", "- config file: '%s'", filename); token_already_exists_warning = TRUE; } - Error(ERR_INFO, "- token: '%s' (in line %d)", token, line_nr); - Error(ERR_INFO, " old value: '%s'", old_value); - Error(ERR_INFO, " new value: '%s'", value); + Debug("setup", "- token: '%s' (in line %d)", token, line_nr); + Debug("setup", " old value: '%s'", old_value); + Debug("setup", " new value: '%s'", value); } #endif @@ -2250,16 +2243,16 @@ static boolean loadSetupFileData(void *setup_file_data, char *filename, #if CHECK_TOKEN_VALUE_SEPARATOR__WARN_IF_MISSING if (token_value_separator_warning) - Error(ERR_INFO_LINE, "-"); + Debug("setup", "---"); #endif #if CHECK_TOKEN__WARN_IF_ALREADY_EXISTS_IN_HASH if (token_already_exists_warning) - Error(ERR_INFO_LINE, "-"); + Debug("setup", "---"); #endif if (token_count == 0 && include_count == 0) - Error(ERR_WARN, "configuration file '%s' is empty", filename); + Warn("configuration file '%s' is empty", filename); if (top_recursion_level) freeSetupFileHash(include_filename_hash); @@ -2273,7 +2266,7 @@ static void saveSetupFileHash(SetupFileHash *hash, char *filename) if (!(file = fopen(filename, MODE_WRITE))) { - Error(ERR_WARN, "cannot write configuration file '%s'", filename); + Warn("cannot write configuration file '%s'", filename); return; } @@ -2512,7 +2505,7 @@ static void setTreeInfoToDefaultsFromParent(TreeInfo *ti, TreeInfo *parent) { if (parent == NULL) { - Error(ERR_WARN, "setTreeInfoToDefaultsFromParent(): parent == NULL"); + Warn("setTreeInfoToDefaultsFromParent(): parent == NULL"); setTreeInfoToDefaults(ti, TREE_TYPE_UNDEFINED); @@ -2999,7 +2992,7 @@ static TreeInfo *getArtworkInfoCacheEntry(LevelDirTree *level_node, int type) // check if cache entry for this item is mandatory, but missing if (value == NULL && !optional) { - Error(ERR_WARN, "missing cache entry '%s'", token); + Warn("missing cache entry '%s'", token); cached = FALSE; } @@ -3236,7 +3229,7 @@ char *ExtractZipFileIntoDirectory(char *zip_filename, char *directory, if (!zip_file_valid) { - Error(ERR_WARN, "zip file '%s' rejected!", zip_filename); + Warn("zip file '%s' rejected!", zip_filename); return NULL; } @@ -3245,12 +3238,12 @@ char *ExtractZipFileIntoDirectory(char *zip_filename, char *directory, if (zip_entries == NULL) { - Error(ERR_WARN, "zip file '%s' could not be extracted!", zip_filename); + Warn("zip file '%s' could not be extracted!", zip_filename); return NULL; } - Error(ERR_INFO, "zip file '%s' successfully extracted!", zip_filename); + Info("zip file '%s' successfully extracted!", zip_filename); // first zip file entry contains top level directory char *top_dir = zip_entries[0]; @@ -3271,7 +3264,7 @@ static void ProcessZipFilesInDirectory(char *directory, int tree_type) // display error if directory is main "options.graphics_directory" etc. if (tree_type == TREE_TYPE_LEVEL_DIR || directory == OPTIONS_ARTWORK_DIRECTORY(tree_type)) - Error(ERR_WARN, "cannot read directory '%s'", directory); + Warn("cannot read directory '%s'", directory); return; } @@ -3337,7 +3330,7 @@ static boolean LoadLevelInfoFromLevelConf(TreeInfo **node_first, if (setup_file_hash == NULL) { #if DEBUG_NO_CONFIG_FILE - Error(ERR_WARN, "ignoring level directory '%s'", directory_path); + Debug("setup", "ignoring level directory '%s'", directory_path); #endif free(directory_path); @@ -3448,7 +3441,7 @@ static void LoadLevelInfoFromLevelDir(TreeInfo **node_first, if ((dir = openDirectory(level_directory)) == NULL) { - Error(ERR_WARN, "cannot read level directory '%s'", level_directory); + Warn("cannot read level directory '%s'", level_directory); return; } @@ -3498,7 +3491,7 @@ static void LoadLevelInfoFromLevelDir(TreeInfo **node_first, } if (!valid_entry_found) - Error(ERR_WARN, "cannot find any valid level series in directory '%s'", + Warn("cannot find any valid level series in directory '%s'", level_directory); } @@ -3595,7 +3588,7 @@ static boolean LoadArtworkInfoFromArtworkConf(TreeInfo **node_first, { #if DEBUG_NO_CONFIG_FILE if (!strEqual(directory_name, ".")) - Error(ERR_WARN, "ignoring artwork directory '%s'", directory_path); + Debug("setup", "ignoring artwork directory '%s'", directory_path); #endif free(directory_path); @@ -3710,7 +3703,7 @@ static void LoadArtworkInfoFromArtworkDir(TreeInfo **node_first, { // display error if directory is main "options.graphics_directory" etc. if (base_directory == OPTIONS_ARTWORK_DIRECTORY(type)) - Error(ERR_WARN, "cannot read directory '%s'", base_directory); + Warn("cannot read directory '%s'", base_directory); return; } @@ -3752,8 +3745,7 @@ static void LoadArtworkInfoFromArtworkDir(TreeInfo **node_first, base_directory, ".", type); if (!valid_entry_found) - Error(ERR_WARN, "cannot find any valid artwork in directory '%s'", - base_directory); + Warn("cannot find any valid artwork in directory '%s'", base_directory); } static TreeInfo *getDummyArtworkInfo(int type) @@ -4200,7 +4192,8 @@ boolean CreateUserLevelSet(char *level_subdir, char *level_name, if (!(file = fopen(filename, MODE_WRITE))) { - Error(ERR_WARN, "cannot write level info file '%s'", filename); + Warn("cannot write level info file '%s'", filename); + free(filename); return FALSE; @@ -4411,7 +4404,7 @@ void LoadLevelSetup_LastSeries(void) } else { - Error(ERR_DEBUG, "using default setup values"); + Debug("setup", "using default setup values"); } free(filename); @@ -4435,7 +4428,7 @@ static void SaveLevelSetup_LastSeries_Ext(boolean deactivate_last_level_series) if (!(file = fopen(filename, MODE_WRITE))) { - Error(ERR_WARN, "cannot write setup file '%s'", filename); + Warn("cannot write setup file '%s'", filename); free(filename); @@ -4486,7 +4479,7 @@ static void checkSeriesInfo(void) if ((dir = openDirectory(level_directory)) == NULL) { - Error(ERR_WARN, "cannot read level directory '%s'", level_directory); + Warn("cannot read level directory '%s'", level_directory); return; } @@ -4508,12 +4501,14 @@ static void checkSeriesInfo(void) if (levelnum_value < leveldir_current->first_level) { - Error(ERR_WARN, "additional level %d found", levelnum_value); + Warn("additional level %d found", levelnum_value); + leveldir_current->first_level = levelnum_value; } else if (levelnum_value > leveldir_current->last_level) { - Error(ERR_WARN, "additional level %d found", levelnum_value); + Warn("additional level %d found", levelnum_value); + leveldir_current->last_level = levelnum_value; } } @@ -4615,7 +4610,7 @@ void LoadLevelSetup_SeriesInfo(void) } else { - Error(ERR_DEBUG, "using default setup values"); + Debug("setup", "using default setup values"); } free(filename); @@ -4640,8 +4635,10 @@ void SaveLevelSetup_SeriesInfo(void) if (!(file = fopen(filename, MODE_WRITE))) { - Error(ERR_WARN, "cannot write setup file '%s'", filename); + Warn("cannot write setup file '%s'", filename); + free(filename); + return; } diff --git a/src/libgame/sound.c b/src/libgame/sound.c index 4f5ddd0b..2375c06f 100644 --- a/src/libgame/sound.c +++ b/src/libgame/sound.c @@ -409,8 +409,8 @@ static void Mixer_InsertSound(SoundControl snd_ctrl) { if (!mixer[i].active) { - Error(ERR_INFO, "Mixer_InsertSound: Channel %d inactive", i); - Error(ERR_INFO, "Mixer_InsertSound: This should never happen!"); + Debug("audio", "Mixer_InsertSound: Channel %d inactive", i); + Debug("audio", "Mixer_InsertSound: This should never happen!"); mixer_active_channels--; } @@ -538,8 +538,10 @@ static void *Load_WAV(char *filename) if ((snd_info->data_ptr = Mix_LoadWAV(filename)) == NULL) { - Error(ERR_WARN, "cannot read sound file '%s': %s", filename, Mix_GetError()); + Warn("cannot read sound file '%s': %s", filename, Mix_GetError()); + free(snd_info); + return NULL; } @@ -562,8 +564,10 @@ static void *Load_MOD(char *filename) if ((mod_info->data_ptr = Mix_LoadMUS(filename)) == NULL) { - Error(ERR_WARN, "cannot read music file '%s': %s", filename, Mix_GetError()); + Warn("cannot read music file '%s': %s", filename, Mix_GetError()); + free(mod_info); + return NULL; } @@ -607,7 +611,7 @@ static void LoadCustomMusic_NoConf(void) if ((dir = openDirectory(music_directory)) == NULL) { - Error(ERR_WARN, "cannot read music directory '%s'", music_directory); + Warn("cannot read music directory '%s'", music_directory); audio.music_available = FALSE; diff --git a/src/libgame/system.c b/src/libgame/system.c index 2f2150a7..b0b8d477 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -137,14 +137,14 @@ void InitScoresInfo(void) { if (program.global_scores) { - Error(ERR_DEBUG, "Using global, multi-user scores directory '%s'.", + Debug("internal:path", "Using global, multi-user scores directory '%s'.", global_scores_dir); - Error(ERR_DEBUG, "Remove to enable single-user scores directory."); - Error(ERR_DEBUG, "(This enables multipe score entries per user.)"); + Debug("internal:path", "Remove to enable single-user scores directory."); + Debug("internal:path", "(This enables multipe score entries per user.)"); } else { - Error(ERR_DEBUG, "Using private, single-user scores directory."); + Debug("internal:path", "Using private, single-user scores directory."); } } #endif @@ -1169,7 +1169,8 @@ void ReloadCustomImage(Bitmap *bitmap, char *basename) if (filename == NULL) // (should never happen) { - Error(ERR_WARN, "ReloadCustomImage(): cannot find file '%s'", basename); + Warn("ReloadCustomImage(): cannot find file '%s'", basename); + return; } @@ -1184,16 +1185,19 @@ void ReloadCustomImage(Bitmap *bitmap, char *basename) if ((new_bitmap = LoadImage(filename)) == NULL) { - Error(ERR_WARN, "LoadImage('%s') failed: %s", basename, GetError()); + Warn("LoadImage('%s') failed: %s", basename, GetError()); + return; } if (bitmap->width != new_bitmap->width || bitmap->height != new_bitmap->height) { - Error(ERR_WARN, "ReloadCustomImage: new image '%s' has wrong dimensions", + Warn("ReloadCustomImage: new image '%s' has wrong dimensions", filename); + FreeBitmap(new_bitmap); + return; } diff --git a/src/libgame/text.c b/src/libgame/text.c index fbf7683e..dbec20df 100644 --- a/src/libgame/text.c +++ b/src/libgame/text.c @@ -639,7 +639,7 @@ int DrawTextBufferVA(int x, int y, char *format, va_list ap, int font_nr, int text_length = vsnprintf(text_buffer, MAX_OUTPUT_LINESIZE, format, ap); if (text_length >= MAX_OUTPUT_LINESIZE) - Error(ERR_WARN, "string too long in DrawTextBufferVA() -- truncated"); + Warn("string too long in DrawTextBufferVA() -- truncated"); int num_lines_printed = DrawTextBuffer(x, y, text_buffer, font_nr, line_length, cut_length, max_lines, diff --git a/src/netserv.c b/src/netserv.c index 0833cfb0..0f07ddb0 100644 --- a/src/netserv.c +++ b/src/netserv.c @@ -328,7 +328,7 @@ int getNetworkBufferFile(struct NetworkBuffer *nb, char *filename) if (!(file = fopen(filename, MODE_WRITE))) { - Error(ERR_WARN, "cannot write file '%s' from network buffer", filename); + Warn("cannot write file '%s' from network buffer", filename); return 0; } @@ -356,7 +356,7 @@ int putNetworkBufferFile(struct NetworkBuffer *nb, char *filename) if (!(file = openFile(filename, MODE_READ))) { - Error(ERR_WARN, "cannot read file '%s' to network buffer", filename); + Warn("cannot read file '%s' to network buffer", filename); return 0; } @@ -919,7 +919,7 @@ void NetworkServer(int port, int serveronly) // accept incoming TCP connections if (SDLNet_SocketReady(lfd)) { - Error(ERR_DEBUG, "got TCP packet"); + Debug("network:server", "got TCP packet"); TCPsocket newsock; @@ -932,7 +932,7 @@ void NetworkServer(int port, int serveronly) // accept incoming UDP packets if (SDLNet_SocketReady(udp)) { - Error(ERR_DEBUG, "got UDP packet"); + Debug("network:server", "got UDP packet"); static UDPpacket packet; diff --git a/src/network.c b/src/network.c index 3384a478..b4ee83c3 100644 --- a/src/network.c +++ b/src/network.c @@ -90,7 +90,7 @@ static void DrawNetworkTextExt(char *message, int font_nr, boolean initialize) ypos = SY + ypos_2; } - Error(ERR_DEBUG, "========== %s ==========", message); + Debug("network:client", "========== %s ==========", message); } else { @@ -104,7 +104,7 @@ static void DrawNetworkTextExt(char *message, int font_nr, boolean initialize) ypos += (num_lines_printed + num_lines_spacing) * font_height; - Error(ERR_DEBUG, "%s", message); + Debug("network:client", "%s", message); } BackToFront(); @@ -332,7 +332,7 @@ boolean ConnectToServer(char *hostname, int port) SDLNet_Write16(port, &ip.port); } - Error(ERR_DEBUG, "trying to connect to network server at %d.%d.%d.%d ...", + Debug("network:client", "trying to connect to network server at %d.%d.%d.%d ...", (server_host >> 24) & 0xff, (server_host >> 16) & 0xff, (server_host >> 8) & 0xff, @@ -505,8 +505,8 @@ static void Handle_OP_BAD_PROTOCOL_VERSION(void) int protocol_version_major = getNetworkBuffer8BitInteger(read_buffer); int protocol_version_minor = getNetworkBuffer8BitInteger(read_buffer); - Error(ERR_WARN, "protocol version mismatch"); - Error(ERR_WARN, "server expects %d.%d.x instead of %d.%d.%d", + Warn("protocol version mismatch"); + Warn("server expects %d.%d.x instead of %d.%d.%d", protocol_version_major, protocol_version_minor, PROTOCOL_VERSION_MAJOR, @@ -702,7 +702,7 @@ static void Handle_OP_START_PLAYING(void) if (!strEqual(new_leveldir_identifier, network_level.leveldir_identifier)) { - Error(ERR_WARN, "no such level identifier: '%s'", new_leveldir_identifier); + Warn("no such level identifier: '%s'", new_leveldir_identifier); stop_network_game = TRUE; @@ -808,11 +808,10 @@ static void Handle_OP_MOVE_PLAYER(void) if (server_frame_counter != FrameCounter) { - Error(ERR_INFO, "frame counters of client %d and server out of sync", - player_nr); - Error(ERR_INFO, "frame counter of client is %d", FrameCounter); - Error(ERR_INFO, "frame counter of server is %d", server_frame_counter); - Error(ERR_INFO, "this should not happen -- please debug"); + Warn("frame counters of client %d and server out of sync", player_nr); + Warn("frame counter of client is %d", FrameCounter); + Warn("frame counter of server is %d", server_frame_counter); + Warn("this should not happen -- please debug"); stop_network_game = TRUE; diff --git a/src/screens.c b/src/screens.c index fe814ec7..2917ac72 100644 --- a/src/screens.c +++ b/src/screens.c @@ -7605,9 +7605,9 @@ static boolean ConfigureJoystickMapButtonsAndAxes(SDL_Joystick *joystick) #if DEBUG_JOYSTICKS // print info about the joystick we are watching - Error(ERR_DEBUG, "watching joystick %d: (%s)\n", + Debug("joystick", "watching joystick %d: (%s)", SDL_JoystickInstanceID(joystick), name); - Error(ERR_DEBUG, "joystick has %d axes, %d hats, %d balls, and %d buttons\n", + Debug("joystick", "joystick has %d axes, %d hats, %d balls, and %d buttons", SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick), SDL_JoystickNumBalls(joystick), SDL_JoystickNumButtons(joystick)); #endif @@ -7864,7 +7864,7 @@ static boolean ConfigureJoystickMapButtonsAndAxes(SDL_Joystick *joystick) if (success) { #if DEBUG_JOYSTICKS - Error(ERR_DEBUG, "New game controller mapping:\n\n%s\n\n", mapping); + Debug("joystick", "New game controller mapping:\n\n%s\n\n", mapping); #endif // activate mapping for this game diff --git a/src/tools.c b/src/tools.c index bf441229..b27c0112 100644 --- a/src/tools.c +++ b/src/tools.c @@ -752,7 +752,7 @@ static void PrintFrameTimeDebugging(void) diff_bar[pos++] = '\0'; - Error(ERR_INFO, "%06d [%02d] [%c%02d] %s", + Debug("time:frame", "%06d [%02d] [%c%02d] %s", counter, diff_1, (diff_2 < 0 ? '-' : diff_2 > 0 ? '+' : ' '), ABS(diff_2), @@ -7704,7 +7704,7 @@ int map_element_RND_to_EM_cave(int element_rnd) if (element_rnd < 0 || element_rnd >= NUM_FILE_ELEMENTS) { - Error(ERR_WARN, "invalid RND level element %d", element_rnd); + Warn("invalid RND level element %d", element_rnd); return EL_UNKNOWN; } @@ -7734,7 +7734,7 @@ int map_element_EM_to_RND_cave(int element_em_cave) if (element_em_cave < 0 || element_em_cave >= CAVE_TILE_MAX) { - Error(ERR_WARN, "invalid EM cave element %d", element_em_cave); + Warn("invalid EM cave element %d", element_em_cave); return EL_UNKNOWN; } @@ -7764,7 +7764,7 @@ int map_element_EM_to_RND_game(int element_em_game) if (element_em_game < 0 || element_em_game >= GAME_TILE_MAX) { - Error(ERR_WARN, "invalid EM game element %d", element_em_game); + Warn("invalid EM game element %d", element_em_game); return EL_UNKNOWN; }