projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
removed shadowing of outer variable by local variable
[rocksndiamonds.git]
/
src
/
editor.c
diff --git
a/src/editor.c
b/src/editor.c
index ddbcd1a9f228aa32f35bf40d19691b537baba4a3..080c1761d73095360dd92d84a65b0a66c5f2be0e 100644
(file)
--- a/
src/editor.c
+++ b/
src/editor.c
@@
-10431,12
+10431,12
@@
static void DrawEditorElementName(int x, int y, int font_nr)
int font_height = getFontHeight(font_nr);
int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
int max_chars_per_line = max_text_width / font_width;
int font_height = getFontHeight(font_nr);
int max_text_width = SXSIZE - x - ED_ELEMENT_SETTINGS_X(0);
int max_chars_per_line = max_text_width / font_width;
- char buffer[max_chars_per_line + 1];
if (strlen(element_name) <= max_chars_per_line)
DrawTextS(x, y, font_nr, element_name);
else
{
if (strlen(element_name) <= max_chars_per_line)
DrawTextS(x, y, font_nr, element_name);
else
{
+ char buffer[max_chars_per_line + 1];
int next_pos = max_chars_per_line;
strncpy(buffer, element_name, max_chars_per_line);
int next_pos = max_chars_per_line;
strncpy(buffer, element_name, max_chars_per_line);
@@
-12904,8
+12904,6
@@
static void CopyLevelTemplateToUserLevelSet(char *levelset_subdir)
static void HandleDrawingAreas(struct GadgetInfo *gi)
{
static boolean started_inside_drawing_area = FALSE;
static void HandleDrawingAreas(struct GadgetInfo *gi)
{
static boolean started_inside_drawing_area = FALSE;
- static int last_sx = -1, last_sy = -1;
- static int last_sx2 = -1, last_sy2 = -1;
int id = gi->custom_id;
int type_id = gi->custom_type_id;
boolean button_press_event;
int id = gi->custom_id;
int type_id = gi->custom_type_id;
boolean button_press_event;
@@
-12925,8
+12923,6
@@
static void HandleDrawingAreas(struct GadgetInfo *gi)
int dx = sx2 % 2;
int dy = sy2 % 2;
int lx = 0, ly = 0;
int dx = sx2 % 2;
int dy = sy2 % 2;
int lx = 0, ly = 0;
- int min_lx = 0, min_ly = 0;
- int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
int x, y;
button_press_event = (gi->event.type == GD_EVENT_PRESSED);
int x, y;
button_press_event = (gi->event.type == GD_EVENT_PRESSED);
@@
-12938,6
+12934,9
@@
static void HandleDrawingAreas(struct GadgetInfo *gi)
if (draw_level)
{
if (draw_level)
{
+ int min_lx = 0, min_ly = 0;
+ int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
+
// get positions inside level field
lx = sx + level_xpos;
ly = sy + level_ypos;
// get positions inside level field
lx = sx + level_xpos;
ly = sy + level_ypos;
@@
-12966,15
+12965,12
@@
static void HandleDrawingAreas(struct GadgetInfo *gi)
sy2 = sy * 2 + dy;
}
sy2 = sy * 2 + dy;
}
- if (button_release_event)
- {
- last_sx = -1;
- last_sy = -1;
- last_sx2 = -1;
- last_sy2 = -1;
- }
- else if (!button_press_event)
+ if (!button_press_event && !button_release_event)
{
{
+ static int last_sx = -1;
+ static int last_sy = -1;
+ static int last_sx2 = -1;
+ static int last_sy2 = -1;
int old_element = (IN_LEV_FIELD(lx, ly) ? Tile[lx][ly] : EL_UNDEFINED);
boolean hires_drawing = (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
isHiresTileElement(old_element) &&
int old_element = (IN_LEV_FIELD(lx, ly) ? Tile[lx][ly] : EL_UNDEFINED);
boolean hires_drawing = (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
isHiresTileElement(old_element) &&
@@
-12984,12
+12980,12
@@
static void HandleDrawingAreas(struct GadgetInfo *gi)
if ((sx == last_sx && sy == last_sy && !hires_drawing) ||
(sx2 == last_sx2 && sy2 == last_sy2))
return;
if ((sx == last_sx && sy == last_sy && !hires_drawing) ||
(sx2 == last_sx2 && sy2 == last_sy2))
return;
- }
- last_sx = sx;
- last_sy = sy;
- last_sx2 = sx2;
- last_sy2 = sy2;
+ last_sx = sx;
+ last_sy = sy;
+ last_sx2 = sx2;
+ last_sy2 = sy2;
+ }
if (button_press_event)
started_inside_drawing_area = inside_drawing_area;
if (button_press_event)
started_inside_drawing_area = inside_drawing_area;
@@
-13122,22
+13118,19
@@
static void HandleDrawingAreas(struct GadgetInfo *gi)
if (button_release_event)
CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
if (button_release_event)
CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
- if (button)
- {
- SetDrawModeHiRes(new_element);
+ SetDrawModeHiRes(new_element);
-
if (getDrawModeHiRes())
-
{
-
sx = sx2;
-
sy = sy2;
-
}
+ if (getDrawModeHiRes())
+ {
+ sx = sx2;
+ sy = sy2;
+ }
-
if (!button_press_event)
-
DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
+ if (!button_press_event)
+ DrawLine(last_sx, last_sy, sx, sy, new_element, TRUE);
- last_sx = sx;
- last_sy = sy;
- }
+ last_sx = sx;
+ last_sy = sy;
}
break;
}
break;
@@
-14226,7
+14219,8
@@
static void HandleControlButtons(struct GadgetInfo *gi)
id <= GADGET_ID_ELEMENTLIST_LAST)
{
int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
id <= GADGET_ID_ELEMENTLIST_LAST)
{
int element_position = id - GADGET_ID_ELEMENTLIST_FIRST;
- int new_element = editor_elements[element_position + element_shift];
+
+ new_element = editor_elements[element_position + element_shift];
if (IS_EDITOR_CASCADE(new_element))
{
if (IS_EDITOR_CASCADE(new_element))
{
@@
-14520,7
+14514,6
@@
static void ClearEditorGadgetInfoText(void)
void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
{
char infotext[MAX_OUTPUT_LINESIZE + 1];
void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
{
char infotext[MAX_OUTPUT_LINESIZE + 1];
- char shortcut[MAX_OUTPUT_LINESIZE + 1];
int max_infotext_len = getMaxInfoTextLength();
if (gi == NULL || strlen(gi->info_text) == 0)
int max_infotext_len = getMaxInfoTextLength();
if (gi == NULL || strlen(gi->info_text) == 0)
@@
-14535,6
+14528,8
@@
void PrintEditorGadgetInfoText(struct GadgetInfo *gi)
if (key)
{
if (key)
{
+ char shortcut[MAX_OUTPUT_LINESIZE + 1];
+
if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
sprintf(shortcut, " ('.' or '%c')", key);
else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
sprintf(shortcut, " ('.' or '%c')", key);
else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
@@
-14578,7
+14573,6
@@
void HandleEditorGadgetInfoText(void *ptr)
static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
{
static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
{
- static int start_lx, start_ly;
int id = gi->custom_id;
int type_id = gi->custom_type_id;
int sx = gi->event.x;
int id = gi->custom_id;
int type_id = gi->custom_type_id;
int sx = gi->event.x;
@@
-14591,7
+14585,6
@@
static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
int actual_drawing_function = drawing_function;
int max_infotext_len = getMaxInfoTextLength();
char infotext[MAX_OUTPUT_LINESIZE + 1];
int actual_drawing_function = drawing_function;
int max_infotext_len = getMaxInfoTextLength();
char infotext[MAX_OUTPUT_LINESIZE + 1];
- char *text;
infotext[0] = '\0'; // start with empty info text
infotext[0] = '\0'; // start with empty info text
@@
-14632,6
+14625,10
@@
static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
{
if (button_status) // if (gi->state == GD_BUTTON_PRESSED)
{
{
if (button_status) // if (gi->state == GD_BUTTON_PRESSED)
{
+ static int start_lx = 0;
+ static int start_ly = 0;
+ char *text;
+
if (gi->event.type == GD_EVENT_PRESSED)
{
start_lx = lx;
if (gi->event.type == GD_EVENT_PRESSED)
{
start_lx = lx;