From: Holger Schemel Date: Fri, 6 Dec 2024 19:49:33 +0000 (+0100) Subject: fixed some issues found by Cppcheck (static C/C++ code analysis tool) X-Git-Tag: 4.4.0.0-test-5~2 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=5623d02a136c231ea4ea1fcb1a6b3175ad75e3fe;p=rocksndiamonds.git fixed some issues found by Cppcheck (static C/C++ code analysis tool) --- diff --git a/src/anim.c b/src/anim.c index 53435a97..5e7b0d8e 100644 --- a/src/anim.c +++ b/src/anim.c @@ -671,7 +671,6 @@ static void SetGlobalAnimEventsForCustomElements(int list_pos) void InitGlobalAnimEventsForCustomElements(void) { int m, a, p; - int control; // custom element events for global animations only relevant while playing m = GAME_MODE_PLAYING; @@ -679,8 +678,7 @@ void InitGlobalAnimEventsForCustomElements(void) for (a = 0; a < NUM_GLOBAL_ANIMS; a++) { int ctrl_id = GLOBAL_ANIM_ID_CONTROL_FIRST + a; - - control = global_anim_info[ctrl_id].graphic[GLOBAL_ANIM_ID_PART_BASE][m]; + int control = global_anim_info[ctrl_id].graphic[GLOBAL_ANIM_ID_PART_BASE][m]; // if no base animation parameters defined, use default values if (control == IMG_UNDEFINED) @@ -720,7 +718,7 @@ static void BlitGlobalAnimation(struct GlobalAnimPartControlInfo *part, Bitmap *fade_bitmap = (drawing_target == DRAW_TO_FADE_SOURCE ? gfx.fade_bitmap_source : drawing_target == DRAW_TO_FADE_TARGET ? gfx.fade_bitmap_target : NULL); - int alpha = (c->fade_mode & FADE_MODE_FADE ? part->fade_alpha : g->alpha); + int alpha = ((c->fade_mode & FADE_MODE_FADE) != 0 ? part->fade_alpha : g->alpha); int x, y; for (y = 0; y < c->stacked_yfactor; y++) @@ -801,7 +799,6 @@ static void DrawGlobalAnimationsExt(int drawing_target, int drawing_stage) boolean before_fading = (global.anim_status == GAME_MODE_PSEUDO_FADING); boolean after_fading = (anim_status_last == GAME_MODE_PSEUDO_FADING); int anim_classes_next = game_mode_anim_classes[global.anim_status_next]; - int i; if (drawing_target == DRAW_TO_FADE_TARGET) after_fading = TRUE; @@ -2185,14 +2182,14 @@ static void ResetGlobalAnim_Clicked(void) void RestartGlobalAnimsByStatus(int status) { - int anim_status_last = global.anim_status; + int global_anim_status_last = global.anim_status; global.anim_status = status; // force restarting global animations by changed global animation status DrawGlobalAnimationsExt(DRAW_TO_SCREEN, DRAW_GLOBAL_ANIM_STAGE_RESTART); - global.anim_status = anim_status_last; + global.anim_status = global_anim_status_last; } void SetAnimStatusBeforeFading(int status) diff --git a/src/editor.c b/src/editor.c index 1f9d89cb..38a1c735 100644 --- a/src/editor.c +++ b/src/editor.c @@ -8136,10 +8136,10 @@ static void ReinitializeElementList(void) // fill element list for (i = 0; editor_elements_info[i].setup_value != NULL; i++) { - boolean found_inactive_cascade = FALSE; - if (*editor_elements_info[i].setup_value) { + boolean found_inactive_cascade = FALSE; + if (setup.editor.el_headlines) { // required for correct padding of palette headline buttons @@ -10480,19 +10480,22 @@ static boolean CopyCustomElement(int element_old, int element_new, { int copy_mode_orig = copy_mode; - if (copy_mode == GADGET_ID_CUSTOM_COPY) + if (element_old == -1 || element_new == -1) // special case for copy/paste element { - element_new = (IS_CUSTOM_ELEMENT(element_old) ? - EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP); - copy_mode = GADGET_ID_CUSTOM_COPY_TO; - } - else if (copy_mode == GADGET_ID_CUSTOM_PASTE) - { - element_old = (IS_CUSTOM_ELEMENT(element_new) ? - EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP); - copy_mode = GADGET_ID_CUSTOM_COPY_TO; + if (copy_mode == GADGET_ID_CUSTOM_COPY) + { + element_new = (IS_CUSTOM_ELEMENT(element_old) ? + EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP); + copy_mode = GADGET_ID_CUSTOM_COPY_TO; + } + else if (copy_mode == GADGET_ID_CUSTOM_PASTE) + { + element_old = (IS_CUSTOM_ELEMENT(element_new) ? + EL_INTERNAL_CLIPBOARD_CUSTOM : EL_INTERNAL_CLIPBOARD_GROUP); + copy_mode = GADGET_ID_CUSTOM_COPY_TO; - level.changed = TRUE; + level.changed = TRUE; + } } else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new)) { @@ -12332,7 +12335,6 @@ static void DrawPropertiesInfo(void) int num_elements_in_level = 0; int num_similar_in_level = 0; int num_hires_tiles_in_level = 0; - int num_standard_properties = 0; int font1_nr = FONT_TEXT_1; int font2_nr = FONT_TEXT_2; int font1_width = getFontWidth(font1_nr); @@ -12429,6 +12431,8 @@ static void DrawPropertiesInfo(void) level.game_engine_type == GAME_ENGINE_TYPE_EM || level.game_engine_type == GAME_ENGINE_TYPE_SP) { + int num_standard_properties = 0; + DrawTextS(xpos, ypos, font1_nr, properties_text); ypos += line1_height;