diff options
164 files changed, 1081 insertions, 785 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d8918fa7a3a..60fcaab2f13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,7 +156,7 @@ endif() if(UNIX AND NOT APPLE) option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support and unicode input)" ON) - option(WITH_X11_XF86VMODE "Enable X11 video mode switching" OFF) + option(WITH_X11_XF86VMODE "Enable X11 video mode switching" ON) option(WITH_BUILTIN_GLEW "Use GLEW OpenGL wrapper library bundled with blender" ON) option(WITH_XDG_USER_DIRS "Build with XDG Base Directory Specification (only config and documents for now)" OFF) mark_as_advanced(WITH_XDG_USER_DIRS) diff --git a/extern/libmv/CMakeLists.txt b/extern/libmv/CMakeLists.txt index 671520a76f8..1e370e5f31b 100644 --- a/extern/libmv/CMakeLists.txt +++ b/extern/libmv/CMakeLists.txt @@ -22,7 +22,7 @@ # # ***** END GPL LICENSE BLOCK ***** -# NOTEL This file is automatically generated by bundle.sh script +# NOTE: This file is automatically generated by bundle.sh script # If you're doing changes in this file, please update template # in that script too diff --git a/extern/libmv/SConscript b/extern/libmv/SConscript index a2132e73f03..fbcd92503d8 100644 --- a/extern/libmv/SConscript +++ b/extern/libmv/SConscript @@ -1,6 +1,6 @@ #!/usr/bin/python -# NOTEL This file is automatically generated by bundle.sh script +# NOTE: This file is automatically generated by bundle.sh script # If you're doing changes in this file, please update template # in that script too diff --git a/extern/libmv/bundle.sh b/extern/libmv/bundle.sh index ca808e12d7e..f5cfcc0d488 100755 --- a/extern/libmv/bundle.sh +++ b/extern/libmv/bundle.sh @@ -113,7 +113,7 @@ cat > CMakeLists.txt << EOF # # ***** END GPL LICENSE BLOCK ***** -# NOTEL This file is automatically generated by bundle.sh script +# NOTE: This file is automatically generated by bundle.sh script # If you're doing changes in this file, please update template # in that script too @@ -209,7 +209,7 @@ EOF cat > SConscript << EOF #!/usr/bin/python -# NOTEL This file is automatically generated by bundle.sh script +# NOTE: This file is automatically generated by bundle.sh script # If you're doing changes in this file, please update template # in that script too diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index caf5b0a99b1..608cb33eadd 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -228,7 +228,12 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d) for(b_ob->dupli_list.begin(b_dup); b_dup != b_ob->dupli_list.end(); ++b_dup) { Transform tfm = get_transform(b_dup->matrix()); - sync_object(*b_ob, b_index, b_dup->object(), tfm, ob_layer); + BL::Object b_dup_ob = b_dup->object(); + bool dup_hide = (b_v3d)? b_dup_ob.hide(): b_dup_ob.hide_render(); + + if(!(b_dup->hide() || dup_hide)) + sync_object(*b_ob, b_index, b_dup_ob, tfm, ob_layer); + b_index++; } diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index 1f0be1599bf..e4beb4d7d8c 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -255,8 +255,6 @@ vector<DeviceInfo>& Device::available_devices() static bool devices_init = false; if(!devices_init) { - device_cpu_info(devices); - #ifdef WITH_CUDA if(cuLibraryInit()) device_cuda_info(devices); @@ -271,6 +269,8 @@ vector<DeviceInfo>& Device::available_devices() device_multi_info(devices); #endif + device_cpu_info(devices); + #ifdef WITH_NETWORK device_network_info(devices); #endif diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index e29266b0a7d..f4b2b7a8269 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -272,7 +272,7 @@ void device_cpu_info(vector<DeviceInfo>& devices) info.id = "CPU"; info.num = 0; - devices.push_back(info); + devices.insert(devices.begin(), info); } CCL_NAMESPACE_END diff --git a/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp b/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp index 4c67616a4c4..1b875e657d9 100644 --- a/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp +++ b/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp @@ -17,6 +17,11 @@ * * Contributor(s): Campbell Barton * + * Mode switching + * Copyright (C) 1997-2001 Id Software, Inc. + * Copyright (c) 1993-2011 Tim Riker + * Copyright (C) 2012 Alex Fraser + * * ***** END GPL LICENSE BLOCK ***** */ @@ -47,7 +52,19 @@ GHOST_TSuccess GHOST_DisplayManagerSDL::getNumDisplaySettings(GHOST_TUns8 displa GHOST_TInt32& numSettings) const { GHOST_ASSERT(display < 1, "Only single display systems are currently supported.\n"); - numSettings= GHOST_TInt32(1); + int i; + SDL_Rect **vidmodes; + + vidmodes = SDL_ListModes(NULL, SDL_HWSURFACE | SDL_OPENGL | + SDL_FULLSCREEN | SDL_HWPALETTE); + if (!vidmodes) { + fprintf(stderr, "Could not get available video modes: %s.\n", + SDL_GetError()); + return GHOST_kFailure; + } + for (i = 0; vidmodes[i]; i++); + numSettings = GHOST_TInt32(i); + return GHOST_kSuccess; } @@ -56,18 +73,38 @@ GHOST_DisplayManagerSDL::getDisplaySetting(GHOST_TUns8 display, GHOST_TInt32 index, GHOST_DisplaySetting& setting) const { - GHOST_ASSERT(display < 1, "Only single display systems are currently supported.\n"); - GHOST_ASSERT(index < 1, "Requested setting outside of valid range.\n"); - SDL_DisplayMode mode; - SDL_GetDesktopDisplayMode(display, &mode); + int i; + SDL_Rect **vidmodes; + /* NULL is passed in here to get the modes for the current bit depth. + * Other bit depths may be possible; in that case, an SDL_PixelFormat struct + * should be passed in. To get a complete profile, all possible bit depths + * would need to be iterated over. - z0r */ + vidmodes = SDL_ListModes(NULL, SDL_HWSURFACE | SDL_OPENGL | + SDL_FULLSCREEN | SDL_HWPALETTE); + if (!vidmodes) { + fprintf(stderr, "Could not get available video modes: %s.\n", + SDL_GetError()); + return GHOST_kFailure; + } + for (i = 0; vidmodes[i]; i++); + GHOST_ASSERT(index < i, "Requested setting outside of valid range.\n"); + + setting.xPixels = vidmodes[index]->w; + setting.yPixels = vidmodes[index]->h; - setting.xPixels= mode.w; - setting.yPixels= mode.h; - setting.bpp= SDL_BYTESPERPIXEL(mode.format); - /* assume 60 when unset */ - setting.frequency= mode.refresh_rate ? mode.refresh_rate : 60; + SDL_Surface *surf; + surf = SDL_GetVideoSurface(); + if (surf == NULL) { + fprintf(stderr, "Getting display setting: %s\n", SDL_GetError()); + /* Just guess the bit depth */ + setting.bpp = 32; + } else { + setting.bpp = surf->format->BitsPerPixel; + } + /* Just guess the frequency :( */ + setting.frequency = 60; return GHOST_kSuccess; } @@ -76,17 +113,100 @@ GHOST_TSuccess GHOST_DisplayManagerSDL::getCurrentDisplaySetting(GHOST_TUns8 display, GHOST_DisplaySetting& setting) const { - return getDisplaySetting(display,GHOST_TInt32(0),setting); + SDL_Surface *surf; + const SDL_VideoInfo *info; + + /* Note: not using SDL_GetDesktopDisplayMode because that does not return + * the current mode. Try to use GetVideoSurface first, as it seems more + * accurate. If that fails, try other methods. - z0r */ + surf = SDL_GetVideoSurface(); + + if (surf != NULL) { + setting.xPixels = surf->w; + setting.yPixels = surf->h; + setting.bpp = surf->format->BitsPerPixel; + /* Just guess the frequency :( */ + setting.frequency = 60; + } else { + /* This may happen if the surface hasn't been created yet, e.g. on + * application startup. */ + info = SDL_GetVideoInfo(); + setting.xPixels = info->current_w; + setting.yPixels = info->current_h; + setting.bpp = info->vfmt->BitsPerPixel; + /* Just guess the frequency :( */ + setting.frequency = 60; + } + + return GHOST_kSuccess; } GHOST_TSuccess GHOST_DisplayManagerSDL:: setCurrentDisplaySetting(GHOST_TUns8 display, const GHOST_DisplaySetting& setting) { - // This is never going to work robustly in X - // but it's currently part of the full screen interface - // we fudge it for now. + /* + * Mode switching code ported from Quake 2 version 3.21 and bzflag version + * 2.4.0: + * ftp://ftp.idsoftware.com/idstuff/source/q2source-3.21.zip + * See linux/gl_glx.c:GLimp_SetMode + * http://wiki.bzflag.org/BZFlag_Source + * See src/platform/SDLDisplay.cxx:SDLDisplay and createWindow + */ + SDL_Surface *surf; + int best_fit, best_dist, dist, x, y; + + SDL_Rect **vidmodes = SDL_ListModes(NULL, SDL_HWSURFACE | SDL_OPENGL | + SDL_FULLSCREEN | SDL_HWPALETTE); + if (!vidmodes) { + fprintf(stderr, "Could not get available video modes: %s.\n", + SDL_GetError()); + } + + best_dist = 9999999; + best_fit = -1; + + if (vidmodes == (SDL_Rect **) -1) { + /* Any mode is OK. */ + x = setting.xPixels; + y = setting.yPixels; + } else { + for (int i = 0; vidmodes[i]; i++) { + if (setting.xPixels > vidmodes[i]->w || + setting.yPixels > vidmodes[i]->h) + continue; + + x = setting.xPixels - vidmodes[i]->w; + y = setting.yPixels - vidmodes[i]->h; + dist = (x * x) + (y * y); + if (dist < best_dist) { + best_dist = dist; + best_fit = i; + } + } + + if (best_fit == -1) + return GHOST_kFailure; + + x = vidmodes[best_fit]->w; + y = vidmodes[best_fit]->h; + } + +# ifdef _DEBUG + printf("Switching to video mode %dx%d\n", x, y); +# endif + + // limit us to the main display + static char singleDisplayEnv[] = "SDL_SINGLEDISPLAY=1"; + putenv(singleDisplayEnv); + + // change to the mode + surf = SDL_SetVideoMode(x, y, setting.bpp, SDL_OPENGL | SDL_FULLSCREEN); + if (surf == NULL) { + fprintf(stderr, "Could not set video mode: %s.\n", SDL_GetError()); + return GHOST_kFailure; + } return GHOST_kSuccess; } diff --git a/intern/ghost/intern/GHOST_DisplayManagerX11.cpp b/intern/ghost/intern/GHOST_DisplayManagerX11.cpp index 411203b6475..b8fe271fd4d 100644 --- a/intern/ghost/intern/GHOST_DisplayManagerX11.cpp +++ b/intern/ghost/intern/GHOST_DisplayManagerX11.cpp @@ -67,10 +67,32 @@ getNumDisplaySettings( GHOST_TUns8 display, GHOST_TInt32& numSettings ) const{ - +#ifdef WITH_X11_XF86VMODE + int majorVersion, minorVersion; + XF86VidModeModeInfo **vidmodes; + Display *dpy = m_system->getXDisplay(); + + GHOST_ASSERT(display < 1, "Only single display systems are currently supported.\n"); + + if (dpy == NULL) + return GHOST_kFailure; + + majorVersion = minorVersion = 0; + if (!XF86VidModeQueryVersion(dpy, &majorVersion, &minorVersion)) { + fprintf(stderr, "Error: XF86VidMode extension missing!\n"); + return GHOST_kFailure; + } + + /* The X11 man page says vidmodes needs to be freed, but doing so causes a + * segfault. - z0r */ + XF86VidModeGetAllModeLines(dpy, DefaultScreen(dpy), &numSettings, &vidmodes); + +#else // We only have one X11 setting at the moment. GHOST_ASSERT(display < 1, "Only single display systems are currently supported.\n"); numSettings = GHOST_TInt32(1); +#endif + return GHOST_kSuccess; } @@ -81,7 +103,34 @@ getDisplaySetting( GHOST_TInt32 index, GHOST_DisplaySetting& setting ) const { - + +#ifdef WITH_X11_XF86VMODE + int majorVersion, minorVersion; + XF86VidModeModeInfo **vidmodes; + Display *dpy = m_system->getXDisplay(); + int numSettings; + + GHOST_ASSERT(display < 1, "Only single display systems are currently supported.\n"); + + if (dpy == NULL) + return GHOST_kFailure; + + majorVersion = minorVersion = 0; + if (!XF86VidModeQueryVersion(dpy, &majorVersion, &minorVersion)) { + fprintf(stderr, "Error: XF86VidMode extension missing!\n"); + return GHOST_kFailure; + } + + /* The X11 man page says vidmodes needs to be freed, but doing so causes a + * segfault. - z0r */ + XF86VidModeGetAllModeLines(dpy, DefaultScreen(dpy), &numSettings, &vidmodes); + GHOST_ASSERT(index < numSettings, "Requested setting outside of valid range.\n"); + + setting.xPixels = vidmodes[index]->hdisplay; + setting.yPixels = vidmodes[index]->vdisplay; + setting.bpp = DefaultDepth(dpy,DefaultScreen(dpy)); + +#else GHOST_ASSERT(display < 1, "Only single display systems are currently supported.\n"); GHOST_ASSERT(index < 1, "Requested setting outside of valid range.\n"); @@ -94,6 +143,7 @@ getDisplaySetting( setting.xPixels = DisplayWidth(x_display, DefaultScreen(x_display)); setting.yPixels = DisplayHeight(x_display, DefaultScreen(x_display)); setting.bpp = DefaultDepth(x_display,DefaultScreen(x_display)); +#endif // Don't think it's possible to get this value from X! // So let's guess!! @@ -108,6 +158,9 @@ getCurrentDisplaySetting( GHOST_TUns8 display, GHOST_DisplaySetting& setting ) const { + /* According to the xf86vidmodegetallmodelines man page, + * "The first element of the array corresponds to the current video mode." + */ return getDisplaySetting(display,GHOST_TInt32(0),setting); } @@ -130,6 +183,9 @@ setCurrentDisplaySetting( int scrnum, num_vidmodes; int best_fit, best_dist, dist, x, y; + if (dpy == NULL) + return GHOST_kFailure; + scrnum = DefaultScreen(dpy); // Get video mode list @@ -143,6 +199,8 @@ setCurrentDisplaySetting( majorVersion, minorVersion); # endif + /* The X11 man page says vidmodes needs to be freed, but doing so causes a + * segfault. - z0r */ XF86VidModeGetAllModeLines(dpy, scrnum, &num_vidmodes, &vidmodes); best_dist = 9999999; diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index 7490502c605..a045f47cb40 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -198,6 +198,8 @@ void BLF_dir_free(char **dirs, int count); #define BLF_MATRIX (1<<4) #define BLF_ASPECT (1<<5) +#define BLF_DRAW_STR_DUMMY_MAX 1024 + // XXX, bad design extern int blf_mono_font; extern int blf_mono_font_render; // dont mess drawing with render threads. diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index 8836999bc9b..b301b7cf03b 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -82,7 +82,7 @@ void free_armature(struct bArmature *arm); void make_local_armature(struct bArmature *arm); struct bArmature *copy_armature(struct bArmature *arm); -int bone_autoside_name (char name[32], int strip_number, short axis, float head, float tail); +int bone_autoside_name (char name[64], int strip_number, short axis, float head, float tail); struct Bone *get_named_bone (struct bArmature *arm, const char *name); diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h index 9a27f292f36..11747899aa9 100644 --- a/source/blender/blenkernel/BKE_deform.h +++ b/source/blender/blenkernel/BKE_deform.h @@ -69,7 +69,7 @@ void defvert_normalize_lock(struct MDeformVert *dvert, const int def_nr_lock); /* utility function, note that 32 chars is the maximum string length since its only * used with defgroups currently */ -void flip_side_name(char name[32], const char from_name[32], int strip_number); +void flip_side_name(char name[64], const char from_name[64], int strip_number); #endif diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 8229978454f..67de699c7c4 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -76,7 +76,7 @@ struct Object; */ typedef struct bNodeSocketTemplate { int type, limit; - char name[32]; + char name[64]; /* MAX_NAME */ float val1, val2, val3, val4; /* default alloc value for inputs */ float min, max; PropertySubType subtype; @@ -95,7 +95,7 @@ typedef void (*NodeSocketButtonFunction)(const struct bContext *C, struct uiBloc */ typedef struct bNodeSocketType { int type; - char ui_name[32]; + char ui_name[64]; /* MAX_NAME */ char ui_description[128]; int ui_icon; char ui_color[4]; @@ -125,7 +125,7 @@ typedef struct bNodeType { short needs_free; /* set for allocated types that need to be freed */ int type; - char name[32]; + char name[64]; /* MAX_NAME */ float width, minwidth, maxwidth; float height, minheight, maxheight; short nclass, flag, compatibility; diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 3a4ac279852..ed0730b7f09 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -306,7 +306,7 @@ typedef struct SeqLoadInfo { int tot_error; int len; /* only for image strips */ char path[512]; - char name[32]; + char name[64]; } SeqLoadInfo; /* SeqLoadInfo.flag */ diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index ec2e6b3c078..d454bef3184 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -1503,7 +1503,7 @@ BoidState *boid_new_state(BoidSettings *boids) state->id = boids->last_state_id++; if(state->id) - sprintf(state->name, "State %i", state->id); + BLI_snprintf(state->name, sizeof(state->name), "State %i", state->id); else strcpy(state->name, "State"); diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 2f557ae3842..1ad439ef29b 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -1578,7 +1578,7 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data, data->layers[index].data = newlayerdata; if(name || (name=typeInfo->defaultname)) { - BLI_strncpy(data->layers[index].name, name, 32); + BLI_strncpy(data->layers[index].name, name, sizeof(data->layers[index].name)); CustomData_set_layer_unique_name(data, index); } else diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index d848185cd07..91345c26154 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -479,22 +479,22 @@ void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_ switch(name[0]) { case 'l': strcpy(replace, "r"); - strcpy(suffix, name+1); + BLI_strncpy(suffix, name+1, sizeof(suffix)); prefix[0]= 0; break; case 'r': strcpy(replace, "l"); - strcpy(suffix, name+1); + BLI_strncpy(suffix, name+1, sizeof(suffix)); prefix[0]= 0; break; case 'L': strcpy(replace, "R"); - strcpy(suffix, name+1); + BLI_strncpy(suffix, name+1, sizeof(suffix)); prefix[0]= 0; break; case 'R': strcpy(replace, "L"); - strcpy(suffix, name+1); + BLI_strncpy(suffix, name+1, sizeof(suffix)); prefix[0]= 0; break; } @@ -504,29 +504,29 @@ void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_ index = BLI_strcasestr(prefix, "right"); if (index==prefix || index==prefix+len-5) { if (index[0]=='r') - strcpy (replace, "left"); + strcpy(replace, "left"); else { if (index[1]=='I') - strcpy (replace, "LEFT"); + strcpy(replace, "LEFT"); else - strcpy (replace, "Left"); + strcpy(replace, "Left"); } *index= 0; - strcpy (suffix, index+5); + BLI_strncpy(suffix, index+5, sizeof(suffix)); } else { index = BLI_strcasestr(prefix, "left"); if (index==prefix || index==prefix+len-4) { if (index[0]=='l') - strcpy (replace, "right"); + strcpy(replace, "right"); else { if (index[1]=='E') - strcpy (replace, "RIGHT"); + strcpy(replace, "RIGHT"); else - strcpy (replace, "Right"); + strcpy(replace, "Right"); } *index= 0; - strcpy (suffix, index+4); + BLI_strncpy(suffix, index + 4, sizeof(suffix)); } } } diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 070f091b10a..54684bc4f66 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -361,8 +361,8 @@ void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface) surface->depth_clamp = 1.0f; } else { - sprintf(surface->output_name, "dp_"); - strcpy(surface->output_name2,surface->output_name); + strcpy(surface->output_name, "dp_"); + strcpy(surface->output_name2, surface->output_name); surface->flags &= ~MOD_DPAINT_ANTIALIAS; surface->depth_clamp = 0.0f; } @@ -1323,7 +1323,7 @@ void dynamicPaint_setInitialColor(DynamicPaintSurface *surface) MTFace *tface; MFace *mface = dm->getTessFaceArray(dm); int numOfFaces = dm->getNumTessFaces(dm); - char uvname[40]; + char uvname[MAX_CUSTOMDATA_LAYER_NAME]; if (!tex) return; @@ -1871,7 +1871,8 @@ struct DerivedMesh *dynamicPaint_Modifier_do(DynamicPaintModifierData *pmd, Scen * px,py : origin pixel x and y * n_index : lookup direction index (use neighX,neighY to get final index) */ -static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh *dm, char *uvname, int w, int h, int px, int py, int n_index) +static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh *dm, + const char *uvname, int w, int h, int px, int py, int n_index) { /* Note: Current method only uses polygon edges to detect neighbouring pixels. * -> It doesn't always lead to the optimum pixel but is accurate enough @@ -2073,7 +2074,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) int ty; int w,h; int numOfFaces; - char uvname[32]; + char uvname[MAX_CUSTOMDATA_LAYER_NAME]; int active_points = 0; int error = 0; diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index a5c8f5c905d..5b3b9b4e1c4 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1168,7 +1168,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d char *name = scene_find_last_marker_name(scene, CFRA); if (name) BLI_strncpy(text, name, sizeof(text)); - else strcpy(text, "<none>"); + else BLI_strncpy(text, "<none>", sizeof(text)); BLI_snprintf(stamp_data->marker, sizeof(stamp_data->marker), do_prefix ? "Marker %s":"%s", text); } else { @@ -1202,14 +1202,14 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d } if (scene->r.stamp & R_STAMP_FRAME) { - char format[32]; + char fmtstr[32]; int digits= 1; if(scene->r.efra>9) digits= 1 + (int) log10(scene->r.efra); - BLI_snprintf(format, sizeof(format), do_prefix ? "Frame %%0%di":"%%0%di", digits); - BLI_snprintf (stamp_data->frame, sizeof(stamp_data->frame), format, scene->r.cfra); + BLI_snprintf(fmtstr, sizeof(fmtstr), do_prefix ? "Frame %%0%di":"%%0%di", digits); + BLI_snprintf (stamp_data->frame, sizeof(stamp_data->frame), fmtstr, scene->r.cfra); } else { stamp_data->frame[0] = '\0'; } @@ -1224,7 +1224,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d if (camera && camera->type == OB_CAMERA) { BLI_snprintf(text, sizeof(text), "%.2f", ((Camera *)camera->data)->lens); } - else strcpy(text, "<none>"); + else BLI_strncpy(text, "<none>", sizeof(text)); BLI_snprintf(stamp_data->cameralens, sizeof(stamp_data->cameralens), do_prefix ? "Lens %s":"%s", text); } else { @@ -1241,7 +1241,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d Sequence *seq= seq_foreground_frame_get(scene, scene->r.cfra); if (seq) BLI_strncpy(text, seq->name+2, sizeof(text)); - else strcpy(text, "<none>"); + else BLI_strncpy(text, "<none>", sizeof(text)); BLI_snprintf(stamp_data->strip, sizeof(stamp_data->strip), do_prefix ? "Strip %s":"%s", text); } else { diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 9890a2629fc..40fe3626848 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -328,9 +328,9 @@ static char *shapekey_adrcodes_to_paths (int adrcode, int *UNUSED(array_index)) /* block will be attached to ID_KE block, and setting that we alter is the 'value' (which sets keyblock.curval) */ // XXX adrcode 0 was dummy 'speed' curve if (adrcode == 0) - sprintf(buf, "speed"); + strcpy(buf, "speed"); else - sprintf(buf, "key_blocks[%d].value", adrcode); + BLI_snprintf(buf, sizeof(buf), "key_blocks[%d].value", adrcode); return buf; } @@ -915,7 +915,7 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co /* note, strings are not escapted and they should be! */ if ((actname && actname[0]) && (constname && constname[0])) { /* Constraint in Pose-Channel */ - sprintf(buf, "pose.bones[\"%s\"].constraints[\"%s\"]", actname, constname); + BLI_snprintf(buf, sizeof(buf), "pose.bones[\"%s\"].constraints[\"%s\"]", actname, constname); } else if (actname && actname[0]) { if ((blocktype == ID_OB) && strcmp(actname, "Object")==0) { @@ -928,16 +928,16 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co } else { /* Pose-Channel */ - sprintf(buf, "pose.bones[\"%s\"]", actname); + BLI_snprintf(buf, sizeof(buf), "pose.bones[\"%s\"]", actname); } } else if (constname && constname[0]) { /* Constraint in Object */ - sprintf(buf, "constraints[\"%s\"]", constname); + BLI_snprintf(buf, sizeof(buf), "constraints[\"%s\"]", constname); } else if (seq) { /* Sequence names in Scene */ - sprintf(buf, "sequence_editor.sequences_all[\"%s\"]", seq->name+2); + BLI_snprintf(buf, sizeof(buf), "sequence_editor.sequences_all[\"%s\"]", seq->name+2); } else { buf[0]= '\0'; /* empty string */ @@ -954,7 +954,7 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co /* if there was no array index pointer provided, add it to the path */ if (array_index == NULL) { - sprintf(buf, "[\"%d\"]", dummy_index); + BLI_snprintf(buf, sizeof(buf), "[\"%d\"]", dummy_index); BLI_dynstr_append(path, buf); } diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 740b7535fcd..8a615b379e8 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -991,7 +991,7 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor ID *id; for (i=0, id= lb->first; id; id= id->next, i++) { - char buf[32]; + char numstr[32]; if (nr && id==link) *nr= i+1; @@ -1002,12 +1002,12 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor if ( ((Image *)id)->source==IMA_SRC_VIEWER ) continue; - get_flags_for_id(id, buf); + get_flags_for_id(id, numstr); - BLI_dynstr_append(pupds, buf); + BLI_dynstr_append(pupds, numstr); BLI_dynstr_append(pupds, id->name+2); - BLI_snprintf(buf, sizeof(buf), "%%x%d", i+1); - BLI_dynstr_append(pupds, buf); + BLI_snprintf(numstr, sizeof(numstr), "%%x%d", i+1); + BLI_dynstr_append(pupds, numstr); /* icon */ switch(GS(id->name)) @@ -1017,8 +1017,8 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor case ID_IM: /* fall through */ case ID_WO: /* fall through */ case ID_LA: /* fall through */ - BLI_snprintf(buf, sizeof(buf), "%%i%d", BKE_icon_getid(id) ); - BLI_dynstr_append(pupds, buf); + BLI_snprintf(numstr, sizeof(numstr), "%%i%d", BKE_icon_getid(id) ); + BLI_dynstr_append(pupds, numstr); break; default: break; @@ -1136,10 +1136,12 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) { ID *idtest; int nr= 0, nrtest, a, left_len; - char left[32], leftest[32], in_use[32]; + char in_use[64]; /* use as a boolean array, unrelated to name length */ + + char left[MAX_ID_NAME + 8], leftest[MAX_ID_NAME + 8]; /* make sure input name is terminated properly */ - /* if( strlen(name) > 21 ) name[21]= 0; */ + /* if( strlen(name) > MAX_ID_NAME-3 ) name[MAX_ID_NAME-3]= 0; */ /* removed since this is only ever called from one place - campbell */ while (1) { @@ -1151,20 +1153,20 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) if( idtest == NULL ) return 0; /* we have a dup; need to make a new name */ - /* quick check so we can reuse one of first 32 ids if vacant */ + /* quick check so we can reuse one of first 64 ids if vacant */ memset(in_use, 0, sizeof(in_use)); /* get name portion, number portion ("name.number") */ left_len= BLI_split_name_num(left, &nr, name, '.'); /* if new name will be too long, truncate it */ - if(nr > 999 && left_len > 16) { - left[16]= 0; - left_len= 16; + if(nr > 999 && left_len > (MAX_ID_NAME - 8)) { + left[MAX_ID_NAME - 8]= 0; + left_len= MAX_ID_NAME - 8; } - else if(left_len > 17) { - left[17]= 0; - left_len= 17; + else if(left_len > (MAX_ID_NAME - 7)) { + left[MAX_ID_NAME - 7]= 0; + left_len= MAX_ID_NAME - 7; } for(idtest= lb->first; idtest; idtest= idtest->next) { @@ -1206,11 +1208,11 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) /* otherwise just continue and use a number suffix */ } - if(nr > 999 && left_len > 16) { + if(nr > 999 && left_len > (MAX_ID_NAME - 8)) { /* this would overflow name buffer */ - left[16] = 0; - /* left_len = 16; */ /* for now this isnt used again */ - memcpy(name, left, sizeof(char) * 17); + left[MAX_ID_NAME - 8] = 0; + /* left_len = MAX_ID_NAME - 8; */ /* for now this isnt used again */ + memcpy(name, left, sizeof(char) * (MAX_ID_NAME - 7)); continue; } /* this format specifier is from hell... */ @@ -1245,7 +1247,7 @@ int new_id(ListBase *lb, ID *id, const char *tname) strncpy(name, tname, sizeof(name)-1); - /* if result > 21, strncpy don't put the final '\0' to name. + /* if result > MAX_ID_NAME-3, strncpy don't put the final '\0' to name. * easier to assign each time then to check if its needed */ name[sizeof(name)-1]= 0; diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 4fda85a3247..f685d0ec151 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -51,6 +51,7 @@ #include "BLI_listbase.h" #include "BLI_utildefines.h" #include "BLI_bpath.h" +#include "BLI_string.h" #include "BKE_animsys.h" #include "BKE_displist.h" @@ -1614,7 +1615,7 @@ static void calculate_tface_materialname(char *matname, char *newname, int flag) int digits = integer_getdigits(flag); /* clamp the old name, remove the MA prefix and add the .TF.flag suffix e.g. matname = "MALoooooooooooooongName"; newname = "Loooooooooooooon.TF.2" */ - sprintf(newname, "%.*s.TF.%0*d", MAX_ID_NAME-(digits+5), matname, digits, flag); + BLI_snprintf(newname, MAX_ID_NAME, "%.*s.TF.%0*d", MAX_ID_NAME-(digits+5), matname, digits, flag); } /* returns -1 if no match */ @@ -1661,8 +1662,8 @@ static short convert_tfacenomaterial(Main *main, Mesh *me, MTFace *tf, int flag) short mat_nr= -1; /* new material, the name uses the flag*/ - sprintf(idname, "MAMaterial.TF.%0*d", integer_getdigits(flag), flag); - + BLI_snprintf(idname, sizeof(idname), "MAMaterial.TF.%0*d", integer_getdigits(flag), flag); + if ((ma= BLI_findstring(&main->mat, idname+2, offsetof(ID, name)+2))) { mat_nr= mesh_getmaterialnumber(me, ma); /* assign the material to the mesh */ diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 57fc7473860..fe2c10d7091 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -356,7 +356,7 @@ int is_basis_mball(Object *ob) int is_mball_basis_for(Object *ob1, Object *ob2) { int basis1nr, basis2nr; - char basis1name[32], basis2name[32]; + char basis1name[MAX_ID_NAME], basis2name[MAX_ID_NAME]; BLI_split_name_num(basis1name, &basis1nr, ob1->id.name+2, '.'); BLI_split_name_num(basis2name, &basis2nr, ob2->id.name+2, '.'); @@ -378,7 +378,7 @@ void copy_mball_properties(Scene *scene, Object *active_object) Object *ob; MetaBall *active_mball = (MetaBall*)active_object->data; int basisnr, obnr; - char basisname[32], obname[32]; + char basisname[MAX_ID_NAME], obname[MAX_ID_NAME]; BLI_split_name_num(basisname, &basisnr, active_object->id.name+2, '.'); @@ -423,7 +423,7 @@ Object *find_basis_mball(Scene *scene, Object *basis) Object *ob,*bob= basis; MetaElem *ml=NULL; int basisnr, obnr; - char basisname[32], obname[32]; + char basisname[MAX_ID_NAME], obname[MAX_ID_NAME]; BLI_split_name_num(basisname, &basisnr, basis->id.name+2, '.'); totelem= 0; @@ -1596,7 +1596,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ float size, totsize, obinv[4][4], obmat[4][4], vec[3]; //float max=0.0; int a, obnr, zero_size=0; - char obname[32]; + char obname[MAX_ID_NAME]; copy_m4_m4(obmat, ob->obmat); /* to cope with duplicators from next_object */ invert_m4_m4(obinv, ob->obmat); @@ -1619,7 +1619,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ else ml= mb->elems.first; } else { - char name[32]; + char name[MAX_ID_NAME]; int nr; BLI_split_name_num(name, &nr, bob->id.name+2, '.'); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 8424824903e..3d8729bc788 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -831,7 +831,7 @@ Object *add_object(struct Scene *scene, int type) { Object *ob; Base *base; - char name[32]; + char name[MAX_ID_NAME]; BLI_strncpy(name, get_obdata_defname(type), sizeof(name)); ob = add_only_object(type, name); diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 7be8aefc883..2decc40da81 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -251,7 +251,7 @@ static char *find_new_name(char *name) if (fop_exists(name)) { for (number = 1; number <= 999; number++) { - sprintf(tempname, "%s.%03d", name, number); + BLI_snprintf(tempname, sizeof(tempname), "%s.%03d", name, number); if (! fop_exists(tempname)) { break; } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 921e62769bf..a645cb79953 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3411,14 +3411,14 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *n psys->part = psys_new_settings("ParticleSettings", NULL); if(BLI_countlist(&ob->particlesystem)>1) - sprintf(psys->name, "ParticleSystem %i", BLI_countlist(&ob->particlesystem)); + BLI_snprintf(psys->name, sizeof(psys->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem)); else strcpy(psys->name, "ParticleSystem"); md= modifier_new(eModifierType_ParticleSystem); if(name) BLI_strncpy(md->name, name, sizeof(md->name)); - else sprintf(md->name, "ParticleSystem %i", BLI_countlist(&ob->particlesystem)); + else BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem)); modifier_unique_name(&ob->modifiers, md); psmd= (ParticleSystemModifierData*) md; diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 5fbbb2a43b7..c5f948bb27f 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -3096,7 +3096,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, const char *name_src, const c } closedir(dir); - strcpy(pid->cache->name, old_name); + BLI_strncpy(pid->cache->name, old_name, sizeof(pid->cache->name)); } void BKE_ptcache_load_external(PTCacheID *pid) @@ -3217,11 +3217,11 @@ void BKE_ptcache_update_info(PTCacheID *pid) /* smoke doesn't use frame 0 as info frame so can't check based on totpoint */ if(pid->type == PTCACHE_TYPE_SMOKE_DOMAIN && totframes) - sprintf(cache->info, "%i frames found!", totframes); + BLI_snprintf(cache->info, sizeof(cache->info), "%i frames found!", totframes); else if(totframes && cache->totpoint) - sprintf(cache->info, "%i points found!", cache->totpoint); + BLI_snprintf(cache->info, sizeof(cache->info), "%i points found!", cache->totpoint); else - sprintf(cache->info, "No valid data to read!"); + BLI_snprintf(cache->info, sizeof(cache->info), "No valid data to read!"); return; } @@ -3231,9 +3231,9 @@ void BKE_ptcache_update_info(PTCacheID *pid) int totpoint = pid->totpoint(pid->calldata, 0); if(cache->totpoint > totpoint) - sprintf(mem_info, "%i cells + High Resolution cached", totpoint); + BLI_snprintf(mem_info, sizeof(mem_info), "%i cells + High Resolution cached", totpoint); else - sprintf(mem_info, "%i cells cached", totpoint); + BLI_snprintf(mem_info, sizeof(mem_info), "%i cells cached", totpoint); } else { int cfra = cache->startframe; @@ -3243,7 +3243,7 @@ void BKE_ptcache_update_info(PTCacheID *pid) totframes++; } - sprintf(mem_info, "%i frames on disk", totframes); + BLI_snprintf(mem_info, sizeof(mem_info), "%i frames on disk", totframes); } } else { @@ -3267,20 +3267,21 @@ void BKE_ptcache_update_info(PTCacheID *pid) mb = (bytes > 1024.0f * 1024.0f); - sprintf(mem_info, "%i frames in memory (%.1f %s)", + BLI_snprintf(mem_info, sizeof(mem_info), "%i frames in memory (%.1f %s)", totframes, bytes / (mb ? 1024.0f * 1024.0f : 1024.0f), mb ? "Mb" : "kb"); } if(cache->flag & PTCACHE_OUTDATED) { - sprintf(cache->info, "%s, cache is outdated!", mem_info); + BLI_snprintf(cache->info, sizeof(cache->info), "%s, cache is outdated!", mem_info); } else if(cache->flag & PTCACHE_FRAMES_SKIPPED) { - sprintf(cache->info, "%s, not exact since frame %i.", mem_info, cache->last_exact); + BLI_snprintf(cache->info, sizeof(cache->info), "%s, not exact since frame %i.", mem_info, cache->last_exact); + } + else { + BLI_snprintf(cache->info, sizeof(cache->info), "%s.", mem_info); } - else - sprintf(cache->info, "%s.", mem_info); } void BKE_ptcache_validate(PointCache *cache, int framenr) diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c index d6c4b5f3a2e..5668907b094 100644 --- a/source/blender/blenkernel/intern/property.c +++ b/source/blender/blenkernel/intern/property.c @@ -171,7 +171,7 @@ void unique_property(bProperty *first, bProperty *prop, int force) i= 0; do { /* ensure we have enough chars for the new number in the name */ - sprintf(num, "%d", i++); + BLI_snprintf(num, sizeof(num), "%d", i++); BLI_strncpy(new_name, base_name, sizeof(prop->name) - strlen(num)); strcat(new_name, num); } while(get_property__internal(first, prop, new_name)); diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index f7eda6bd9b3..92dfe90eec1 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -428,7 +428,7 @@ void init_actuator(bActuator *act) case ACT_CAMERA: act->data= MEM_callocN(sizeof(bCameraActuator), "camact"); ca = act->data; - ca->axis = ACT_CAMERA_X; + ca->axis = OB_POSX; ca->damping = 1.0/32.0; break; case ACT_EDIT_OBJECT: diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 731f82e1b80..a8f89b0a1eb 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -176,7 +176,7 @@ static void open_plugin_seq(PluginSeq *pis, const char *seqname) MEM_freeN(info); cp= BLI_dynlib_find_symbol(pis->handle, "seqname"); - if(cp) BLI_strncpy(cp, seqname, 21); + if(cp) BLI_strncpy(cp, seqname, SEQ_NAME_MAXSTR); } else { printf ("Plugin returned unrecognized version number\n"); return; @@ -303,7 +303,10 @@ static struct ImBuf * do_plugin_effect( cp = BLI_dynlib_find_symbol( seq->plugin->handle, "seqname"); - if(cp) strncpy(cp, seq->name+2, 22); + /* XXX: it's crappy to limit copying buffer by it's lemgth, + * but assuming plugin stuff is using correct buffer size + * it should be fine */ + if(cp) strncpy(cp, seq->name+2, sizeof(seq->name)-2); if (seq->plugin->current_private_data) { *seq->plugin->current_private_data diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 6da9199ddc4..71377799651 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -833,8 +833,8 @@ void clear_scene_in_allseqs(Main *bmain, Scene *scene) typedef struct SeqUniqueInfo { Sequence *seq; - char name_src[32]; - char name_dest[32]; + char name_src[SEQ_NAME_MAXSTR]; + char name_dest[SEQ_NAME_MAXSTR]; int count; int match; } SeqUniqueInfo; @@ -850,7 +850,8 @@ static void seqbase_unique_name(ListBase *seqbasep, SeqUniqueInfo *sui) Sequence *seq; for(seq=seqbasep->first; seq; seq= seq->next) { if (sui->seq != seq && strcmp(sui->name_dest, seq->name+2)==0) { - sprintf(sui->name_dest, "%.17s.%03d", sui->name_src, sui->count++); /*24 - 2 for prefix, -1 for \0 */ + /* SEQ_NAME_MAXSTR - 2 for prefix, -1 for \0, -4 for the number */ + BLI_snprintf(sui->name_dest, sizeof(sui->name_dest), "%.59s.%03d", sui->name_src, sui->count++); sui->match= 1; /* be sure to re-scan */ } } @@ -3388,13 +3389,13 @@ int seq_swap(Sequence *seq_a, Sequence *seq_b, const char **error_str) /* XXX - hackish function needed for transforming strips! TODO - have some better solution */ void seq_offset_animdata(Scene *scene, Sequence *seq, int ofs) { - char str[32]; + char str[SEQ_NAME_MAXSTR+3]; FCurve *fcu; if(scene->adt==NULL || ofs==0 || scene->adt->action==NULL) return; - sprintf(str, "[\"%s\"]", seq->name+2); + BLI_snprintf(str, sizeof(str), "[\"%s\"]", seq->name+2); for (fcu= scene->adt->action->curves.first; fcu; fcu= fcu->next) { if(strstr(fcu->rna_path, "sequence_editor.sequences_all[") && strstr(fcu->rna_path, str)) { @@ -3411,7 +3412,7 @@ void seq_offset_animdata(Scene *scene, Sequence *seq, int ofs) void seq_dupe_animdata(Scene *scene, const char *name_src, const char *name_dst) { - char str_from[32]; + char str_from[SEQ_NAME_MAXSTR+3]; FCurve *fcu; FCurve *fcu_last; FCurve *fcu_cpy; @@ -3420,7 +3421,7 @@ void seq_dupe_animdata(Scene *scene, const char *name_src, const char *name_dst) if(scene->adt==NULL || scene->adt->action==NULL) return; - sprintf(str_from, "[\"%s\"]", name_src); + BLI_snprintf(str_from, sizeof(str_from), "[\"%s\"]", name_src); fcu_last= scene->adt->action->curves.last; @@ -3441,13 +3442,13 @@ void seq_dupe_animdata(Scene *scene, const char *name_src, const char *name_dst) /* XXX - hackish function needed to remove all fcurves belonging to a sequencer strip */ static void seq_free_animdata(Scene *scene, Sequence *seq) { - char str[32]; + char str[SEQ_NAME_MAXSTR+3]; FCurve *fcu; if(scene->adt==NULL || scene->adt->action==NULL) return; - sprintf(str, "[\"%s\"]", seq->name+2); + BLI_snprintf(str, sizeof(str), "[\"%s\"]", seq->name+2); fcu= scene->adt->action->curves.first; diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 649984a7934..f5b677203f6 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -233,7 +233,7 @@ struct bSound* sound_new_buffer(struct Main *bmain, struct bSound *source) { bSound* sound = NULL; - char name[25]; + char name[MAX_ID_NAME+5]; strcpy(name, "buf_"); strcpy(name + 4, source->id.name); @@ -257,7 +257,7 @@ struct bSound* sound_new_limiter(struct Main *bmain, struct bSound *source, floa { bSound* sound = NULL; - char name[25]; + char name[MAX_ID_NAME+5]; strcpy(name, "lim_"); strcpy(name + 4, source->id.name); diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 7051376a1f4..88858c9ff51 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -168,7 +168,7 @@ PluginTex *add_plugin_tex(char *str) pit= MEM_callocN(sizeof(PluginTex), "plugintex"); - strcpy(pit->name, str); + BLI_strncpy(pit->name, str, sizeof(pit->name)); open_plugin_tex(pit); if(pit->doit==NULL) { diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index e55f4dfbf78..2f9689bfe0e 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -651,7 +651,7 @@ void BKE_tracking_clipboard_paste_tracks(MovieTracking *tracking, MovieTrackingO /*********************** tracks map *************************/ typedef struct TracksMap { - char object_name[32]; + char object_name[MAX_NAME]; int is_camera; int num_tracks; @@ -669,7 +669,7 @@ static TracksMap *tracks_map_new(const char *object_name, int is_camera, int num { TracksMap *map= MEM_callocN(sizeof(TracksMap), "TrackingsMap"); - strcpy(map->object_name, object_name); + BLI_strncpy(map->object_name, object_name, sizeof(map->object_name)); map->is_camera= is_camera; map->num_tracks= num_tracks; @@ -1529,7 +1529,7 @@ typedef struct MovieReconstructContext { struct libmv_Reconstruction *reconstruction; #endif - char object_name[32]; + char object_name[MAX_NAME]; int is_camera; float focal_length; @@ -1784,7 +1784,7 @@ MovieReconstructContext* BKE_tracking_reconstruction_context_new(MovieTracking * int sfra= INT_MAX, efra= INT_MIN; MovieTrackingTrack *track; - strcpy(context->object_name, object->name); + BLI_strncpy(context->object_name, object->name, sizeof(context->object_name)); context->is_camera = object->flag&TRACKING_OBJECT_CAMERA; context->tracks_map= tracks_map_new(context->object_name, context->is_camera, num_tracks, 0); diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index bf547584b9e..bcdd93ed70b 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -1077,9 +1077,9 @@ IDProperty *ffmpeg_property_add(RenderData *rd, const char *type, int opt_index, } if (parent_index) { - sprintf(name, "%s:%s", parent->name, o->name); + BLI_snprintf(name, sizeof(name), "%s:%s", parent->name, o->name); } else { - strcpy(name, o->name); + BLI_strncpy(name, o->name, sizeof(name)); } fprintf(stderr, "ffmpeg_property_add: %s %d %d %s\n", diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 9adb39f09ef..6d631051496 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -627,8 +627,10 @@ int BLI_path_frame_range(char *path, int sta, int end, int digits) if (stringframe_chars(path, &ch_sta, &ch_end)) { /* warning, ch_end is the last # +1 */ char tmp[FILE_MAX]; - sprintf(tmp, "%.*s%.*d-%.*d%s", ch_sta, path, ch_end-ch_sta, sta, ch_end-ch_sta, end, path+ch_end); - strcpy(path, tmp); + BLI_snprintf(tmp, sizeof(tmp), + "%.*s%.*d-%.*d%s", + ch_sta, path, ch_end-ch_sta, sta, ch_end-ch_sta, end, path+ch_end); + BLI_strncpy(path, tmp, FILE_MAX); return 1; } return 0; diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index c5b6f46b3bc..df0634e4fcf 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -203,7 +203,7 @@ static void bli_builddir(const char *dirname, const char *relname) char buf[256]; DIR *dir; - strcpy(buf,relname); + BLI_strncpy(buf, relname, sizeof(buf)); rellen=strlen(relname); if (rellen){ @@ -220,7 +220,7 @@ static void bli_builddir(const char *dirname, const char *relname) while ((fname = (struct dirent*) readdir(dir)) != NULL) { dlink = (struct dirlink *)malloc(sizeof(struct dirlink)); if (dlink){ - strcpy(buf+rellen,fname->d_name); + BLI_strncpy(buf + rellen ,fname->d_name, sizeof(buf) - rellen); dlink->name = BLI_strdup(buf); BLI_addhead(dirbase,dlink); newnum++; @@ -343,8 +343,8 @@ static void bli_adddirstrings(void) tm= localtime(&file->s.st_mtime); // prevent impossible dates in windows if(tm==NULL) tm= localtime(&zero); - strftime(file->time, 8, "%H:%M", tm); - strftime(file->date, 16, "%d-%b-%y", tm); + strftime(file->time, sizeof(file->time), "%H:%M", tm); + strftime(file->date, sizeof(file->date), "%d-%b-%y", tm); /* * Seems st_size is signed 32-bit value in *nix and Windows. This @@ -354,38 +354,43 @@ static void bli_adddirstrings(void) st_size= file->s.st_size; if (st_size > 1024*1024*1024) { - sprintf(file->size, "%.2f GB", ((double)st_size)/(1024*1024*1024)); + BLI_snprintf(file->size, sizeof(file->size), "%.2f GB", ((double)st_size)/(1024*1024*1024)); } else if (st_size > 1024*1024) { - sprintf(file->size, "%.1f MB", ((double)st_size)/(1024*1024)); + BLI_snprintf(file->size, sizeof(file->size), "%.1f MB", ((double)st_size)/(1024*1024)); } else if (st_size > 1024) { - sprintf(file->size, "%d KB", (int)(st_size/1024)); + BLI_snprintf(file->size, sizeof(file->size), "%d KB", (int)(st_size/1024)); } else { - sprintf(file->size, "%d B", (int)st_size); + BLI_snprintf(file->size, sizeof(file->size), "%d B", (int)st_size); } - strftime(datum, 32, "%d-%b-%y %H:%M", tm); + strftime(datum, 32, "%d-%b-%y %H:%M", tm); /* XXX, is this used? - campbell */ if (st_size < 1000) { - sprintf(size, "%10d", (int) st_size); - } else if (st_size < 1000 * 1000) { - sprintf(size, "%6d %03d", (int) (st_size / 1000), (int) (st_size % 1000)); - } else if (st_size < 100 * 1000 * 1000) { - sprintf(size, "%2d %03d %03d", (int) (st_size / (1000 * 1000)), (int) ((st_size / 1000) % 1000), (int) ( st_size % 1000)); - } else { - sprintf(size, "> %4.1f M", (double) (st_size / (1024.0 * 1024.0))); - sprintf(size, "%10d", (int) st_size); + BLI_snprintf(size, sizeof(size), "%10d", + (int) st_size); + } + else if (st_size < 1000 * 1000) { + BLI_snprintf(size, sizeof(size), "%6d %03d", + (int) (st_size / 1000), (int) (st_size % 1000)); + } + else if (st_size < 100 * 1000 * 1000) { + BLI_snprintf(size, sizeof(size), "%2d %03d %03d", + (int) (st_size / (1000 * 1000)), (int) ((st_size / 1000) % 1000), (int) ( st_size % 1000)); + } + else { + /* XXX, whats going on here?. 2x calls - campbell */ + BLI_snprintf(size, sizeof(size), "> %4.1f M", (double) (st_size / (1024.0 * 1024.0))); + BLI_snprintf(size, sizeof(size), "%10d", (int) st_size); } - sprintf(buf,"%s %s %s %7s %s %s %10s %s", file->mode1, file->mode2, file->mode3, file->owner, file->date, file->time, size, - file->relname); + BLI_snprintf(buf, sizeof(buf), "%s %s %s %7s %s %s %10s %s", + file->mode1, file->mode2, file->mode3, file->owner, + file->date, file->time, size, file->relname); - file->string=MEM_mallocN(strlen(buf)+1, "filestring"); - if (file->string){ - strcpy(file->string,buf); - } + file->string = BLI_strdup(buf); } } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index a3b2c721213..8a07fe69ec8 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6639,14 +6639,14 @@ static void customdata_version_242(Mesh *me) if (layer->type == CD_MTFACE) { if (layer->name[0] == 0) { if (mtfacen == 0) strcpy(layer->name, "UVMap"); - else sprintf(layer->name, "UVMap.%.3d", mtfacen); + else BLI_snprintf(layer->name, sizeof(layer->name), "UVMap.%.3d", mtfacen); } mtfacen++; } else if (layer->type == CD_MCOL) { if (layer->name[0] == 0) { if (mcoln == 0) strcpy(layer->name, "Col"); - else sprintf(layer->name, "Col.%.3d", mcoln); + else BLI_snprintf(layer->name, sizeof(layer->name), "Col.%.3d", mcoln); } mcoln++; } @@ -9141,8 +9141,9 @@ static void do_versions(FileData *fd, Library *lib, Main *main) strcpy(kb->name, "Basis"); } else { - if(kb->name[0]==0) - sprintf(kb->name, "Key %d", index); + if (kb->name[0]==0) { + BLI_snprintf(kb->name, sizeof(kb->name), "Key %d", index); + } kb->adrcode= index++; } } @@ -10135,7 +10136,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) BLI_addtail(&ob->particlesystem, psys); md= modifier_new(eModifierType_ParticleSystem); - sprintf(md->name, "ParticleSystem %i", BLI_countlist(&ob->particlesystem)); + BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem)); psmd= (ParticleSystemModifierData*) md; psmd->psys=psys; BLI_addtail(&ob->modifiers, md); @@ -13020,7 +13021,23 @@ static void do_versions(FileData *fd, Library *lib, Main *main) /* put compatibility code here until next subversion bump */ { - + { + /* convert Camera Actuator values to defines */ + Object *ob; + bActuator *act; + for(ob = main->object.first; ob; ob= ob->id.next) { + for(act= ob->actuators.first; act; act= act->next) { + if (act->type == ACT_CAMERA) { + bCameraActuator *ba= act->data; + + if(ba->axis==(float) 'x') ba->axis=OB_POSX; + else if (ba->axis==(float)'y') ba->axis=OB_POSY; + /* don't do an if/else to avoid imediate subversion bump*/ +// ba->axis=((ba->axis == (float) 'x')?OB_POSX_X:OB_POSY); + } + } + } + } } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 569125e1055..32e5fe82ed4 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -180,7 +180,7 @@ void ANIM_timecode_string_from_frame (char *str, Scene *scene, int power, short static void draw_cfra_number (Scene *scene, View2D *v2d, float cfra, short time) { float xscale, yscale, x, y; - char str[32] = " t"; /* t is the character to start replacing from */ + char numstr[32] = " t"; /* t is the character to start replacing from */ short slen; /* because the frame number text is subject to the same scaling as the contents of the view */ @@ -193,10 +193,10 @@ static void draw_cfra_number (Scene *scene, View2D *v2d, float cfra, short time) * but power = 1 is required for frames (to get integer frames) */ if (time) - ANIM_timecode_string_from_frame(&str[4], scene, 0, time, FRA2TIME(cfra)); + ANIM_timecode_string_from_frame(&numstr[4], scene, 0, time, FRA2TIME(cfra)); else - ANIM_timecode_string_from_frame(&str[4], scene, 1, time, cfra); - slen= (short)UI_GetStringWidth(str) - 1; + ANIM_timecode_string_from_frame(&numstr[4], scene, 1, time, cfra); + slen= (short)UI_GetStringWidth(numstr) - 1; /* get starting coordinates for drawing */ x= cfra * xscale; @@ -208,7 +208,7 @@ static void draw_cfra_number (Scene *scene, View2D *v2d, float cfra, short time) /* draw current frame number - black text */ UI_ThemeColor(TH_TEXT); - UI_DrawString(x-5, y+3, str); + UI_DrawString(x-5, y+3, numstr); /* restore view transform */ glScalef(xscale, 1.0, 1.0); diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index 8c4e0065a19..169d6b94413 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -134,8 +134,8 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) char c= RNA_property_array_item_char(prop, fcu->array_index); /* we need to write the index to a temp buffer (in py syntax) */ - if (c) sprintf(arrayindbuf, "%c ", c); - else sprintf(arrayindbuf, "[%d]", fcu->array_index); + if (c) BLI_snprintf(arrayindbuf, sizeof(arrayindbuf), "%c ", c); + else BLI_snprintf(arrayindbuf, sizeof(arrayindbuf), "[%d]", fcu->array_index); arrayname= &arrayindbuf[0]; } diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 6369d4e3faf..d751bf89176 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -3457,7 +3457,7 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); EditBone *bone; float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3]; - char name[32]; + char name[MAXBONENAME]; RNA_string_get(op->ptr, "name", name); @@ -3507,7 +3507,7 @@ void ARMATURE_OT_bone_primitive_add(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_string(ot->srna, "name", "Bone", 32, "Name", "Name of the newly created bone"); + RNA_def_string(ot->srna, "name", "Bone", MAXBONENAME, "Name", "Name of the newly created bone"); } @@ -5499,7 +5499,7 @@ static int armature_autoside_names_exec (bContext *C, wmOperator *op) { Object *ob= CTX_data_edit_object(C); bArmature *arm; - char newname[32]; + char newname[MAXBONENAME]; short axis= RNA_enum_get(op->ptr, "type"); /* paranoia checks */ diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c index 451e672da7c..9ec27b69835 100644 --- a/source/blender/editors/armature/editarmature_retarget.c +++ b/source/blender/editors/armature/editarmature_retarget.c @@ -450,7 +450,7 @@ static void renameTemplateBone(char *name, char *template_name, ListBase *editbo { int i, j; - for (i = 0, j = 0; template_name[i] != '\0' && i < 31 && j < 31; i++) + for (i = 0, j = 0; template_name[i] != '\0' && i < (MAXBONENAME-1) && j < (MAXBONENAME-1); i++) { if (template_name[i] == '&') { @@ -485,7 +485,7 @@ static void renameTemplateBone(char *name, char *template_name, ListBase *editbo static RigControl *cloneControl(RigGraph *rg, RigGraph *src_rg, RigControl *src_ctrl, GHash *ptr_hash, char *side_string, char *num_string) { RigControl *ctrl; - char name[32]; + char name[MAXBONENAME]; ctrl = newRigControl(rg); @@ -541,7 +541,7 @@ static RigArc *cloneArc(RigGraph *rg, RigGraph *src_rg, RigArc *src_arc, GHash * if (src_edge->bone != NULL) { - char name[32]; + char name[MAXBONENAME]; renameTemplateBone(name, src_edge->bone->name, rg->editbones, side_string, num_string); edge->bone = duplicateEditBoneObjects(src_edge->bone, name, rg->editbones, src_rg->ob, rg->ob); edge->bone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL); @@ -1453,7 +1453,7 @@ static void RIG_printCtrl(RigControl *ctrl, char *indent) printf("%sBone: %s\n", indent, ctrl->bone->name); printf("%sLink: %s\n", indent, ctrl->link ? ctrl->link->name : "!NONE!"); - sprintf(text, "%soffset", indent); + BLI_snprintf(text, sizeof(text), "%soffset", indent); print_v3(text, ctrl->offset); printf("%sFlag: %i\n", indent, ctrl->flag); diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 6197b66656a..5c378da33df 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -45,6 +45,7 @@ #include "BLI_math.h" #include "BLI_edgehash.h" #include "BLI_memarena.h" +#include "BLI_string.h" #include "BKE_DerivedMesh.h" #include "BKE_modifier.h" @@ -1617,7 +1618,7 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind NLContext *context; float vec[3], gridvec[3]; int a, b, x, y, z, totvar; - char message[1024]; + char message[256]; /* setup variable indices */ mdb->varidx= MEM_callocN(sizeof(int)*mdb->size3, "MeshDeformDSvaridx"); @@ -1719,7 +1720,7 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind break; } - sprintf(message, "Mesh deform solve %d / %d |||", a+1, mdb->totcagevert); + BLI_snprintf(message, sizeof(message), "Mesh deform solve %d / %d |||", a+1, mdb->totcagevert); progress_bar((float)(a+1)/(float)(mdb->totcagevert), message); } diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index efc8ffe4c7d..c28b688e377 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -523,28 +523,28 @@ static void pose_slide_reset (tPoseSlideOp *pso) /* draw percentage indicator in header */ static void pose_slide_draw_status (tPoseSlideOp *pso) { - char statusStr[32]; - char mode[32]; + char status_str[32]; + char mode_str[32]; switch (pso->mode) { case POSESLIDE_PUSH: - strcpy(mode, "Push Pose"); + strcpy(mode_str, "Push Pose"); break; case POSESLIDE_RELAX: - strcpy(mode, "Relax Pose"); + strcpy(mode_str, "Relax Pose"); break; case POSESLIDE_BREAKDOWN: - strcpy(mode, "Breakdown"); + strcpy(mode_str, "Breakdown"); break; default: // unknown - strcpy(mode, "Sliding-Tool"); + strcpy(mode_str, "Sliding-Tool"); break; } - sprintf(statusStr, "%s: %d %%", mode, (int)(pso->percentage*100.0f)); - ED_area_headerprint(pso->sa, statusStr); + BLI_snprintf(status_str, sizeof(status_str), "%s: %d %%", mode_str, (int)(pso->percentage*100.0f)); + ED_area_headerprint(pso->sa, status_str); } /* common code for invoke() methods */ diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index 5cdb9c76396..dcddde207f0 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -977,7 +977,9 @@ static void poselib_preview_apply (bContext *C, wmOperator *op) /* do header print - if interactively previewing */ if (pld->state == PL_PREVIEW_RUNNING) { if (pld->flag & PL_PREVIEW_SHOWORIGINAL) { - sprintf(pld->headerstr, "PoseLib Previewing Pose: [Showing Original Pose] | Use Tab to start previewing poses again"); + BLI_strncpy(pld->headerstr, + "PoseLib Previewing Pose: [Showing Original Pose] | Use Tab to start previewing poses again", + sizeof(pld->headerstr)); ED_area_headerprint(pld->sa, pld->headerstr); } else if (pld->searchstr[0]) { @@ -988,10 +990,10 @@ static void poselib_preview_apply (bContext *C, wmOperator *op) /* get search-string */ index= pld->search_cursor; - if (index >= 0 && index <= 64) { + if (index >= 0 && index <= sizeof(tempstr) - 1) { memcpy(&tempstr[0], &pld->searchstr[0], index); tempstr[index]= '|'; - memcpy(&tempstr[index+1], &pld->searchstr[index], 64-index); + memcpy(&tempstr[index+1], &pld->searchstr[index], (sizeof(tempstr) - 1) - index); } else { BLI_strncpy(tempstr, pld->searchstr, sizeof(tempstr)); @@ -1000,11 +1002,18 @@ static void poselib_preview_apply (bContext *C, wmOperator *op) /* get marker name */ BLI_strncpy(markern, pld->marker ? pld->marker->name : "No Matches", sizeof(markern)); - sprintf(pld->headerstr, "PoseLib Previewing Pose: Filter - [%s] | Current Pose - \"%s\" | Use ScrollWheel or PageUp/Down to change", tempstr, markern); + BLI_snprintf(pld->headerstr, sizeof(pld->headerstr), + "PoseLib Previewing Pose: Filter - [%s] | " + "Current Pose - \"%s\" | " + "Use ScrollWheel or PageUp/Down to change", + tempstr, markern); ED_area_headerprint(pld->sa, pld->headerstr); } else { - sprintf(pld->headerstr, "PoseLib Previewing Pose: \"%s\" | Use ScrollWheel or PageUp/Down to change", pld->marker->name); + BLI_snprintf(pld->headerstr, sizeof(pld->headerstr), + "PoseLib Previewing Pose: \"%s\" | " + "Use ScrollWheel or PageUp/Down to change", + pld->marker->name); ED_area_headerprint(pld->sa, pld->headerstr); } } diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 832ee55997b..b14ce7e4690 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -1777,7 +1777,7 @@ static int pose_autoside_names_exec (bContext *C, wmOperator *op) { Object *ob= object_pose_armature_get(CTX_data_active_object(C)); bArmature *arm; - char newname[32]; + char newname[MAXBONENAME]; short axis= RNA_enum_get(op->ptr, "axis"); /* paranoia checks */ diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c index 06225a38311..10a886edd7a 100644 --- a/source/blender/editors/armature/reeb.c +++ b/source/blender/editors/armature/reeb.c @@ -2036,10 +2036,9 @@ void REEB_exportGraph(ReebGraph *rg, int count) if (count == -1) { - sprintf(filename, "test.txt"); + strcpy(filename, "test.txt"); } - else - { + else { sprintf(filename, "test%05i.txt", count); } f = fopen(filename, "w"); diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index db28b6b7fdf..22568cd676e 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1069,17 +1069,17 @@ static void curve_rename_fcurves(Object *obedit, ListBase *orig_curves) while (a--) { keyIndex= getCVKeyIndex(editnurb, bezt); if(keyIndex) { - sprintf(rna_path, "splines[%d].bezier_points[%d]", nu_index, pt_index); - sprintf(orig_rna_path, "splines[%d].bezier_points[%d]", keyIndex->nu_index, keyIndex->pt_index); + BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d].bezier_points[%d]", nu_index, pt_index); + BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d].bezier_points[%d]", keyIndex->nu_index, keyIndex->pt_index); if(keyIndex->switched) { char handle_path[64], orig_handle_path[64]; - sprintf(orig_handle_path, "%s.handle_left", orig_rna_path); - sprintf(handle_path, "%s.handle_right", rna_path); + BLI_snprintf(orig_handle_path, sizeof(orig_rna_path), "%s.handle_left", orig_rna_path); + BLI_snprintf(handle_path, sizeof(rna_path), "%s.handle_right", rna_path); fcurve_path_rename(ad, orig_handle_path, handle_path, orig_curves, &curves); - sprintf(orig_handle_path, "%s.handle_right", orig_rna_path); - sprintf(handle_path, "%s.handle_left", rna_path); + BLI_snprintf(orig_handle_path, sizeof(orig_rna_path), "%s.handle_right", orig_rna_path); + BLI_snprintf(handle_path, sizeof(rna_path), "%s.handle_left", rna_path); fcurve_path_rename(ad, orig_handle_path, handle_path, orig_curves, &curves); } @@ -1100,8 +1100,8 @@ static void curve_rename_fcurves(Object *obedit, ListBase *orig_curves) while (a--) { keyIndex= getCVKeyIndex(editnurb, bp); if(keyIndex) { - sprintf(rna_path, "splines[%d].points[%d]", nu_index, pt_index); - sprintf(orig_rna_path, "splines[%d].points[%d]", keyIndex->nu_index, keyIndex->pt_index); + BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d].points[%d]", nu_index, pt_index); + BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d].points[%d]", keyIndex->nu_index, keyIndex->pt_index); fcurve_path_rename(ad, orig_rna_path, rna_path, orig_curves, &curves); keyIndex->nu_index= nu_index; @@ -1140,8 +1140,8 @@ static void curve_rename_fcurves(Object *obedit, ListBase *orig_curves) } if(keyIndex) { - sprintf(rna_path, "splines[%d]", nu_index); - sprintf(orig_rna_path, "splines[%d]", keyIndex->nu_index); + BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d]", nu_index); + BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d]", keyIndex->nu_index); fcurve_path_rename(ad, orig_rna_path, rna_path, orig_curves, &curves); } diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c index 760faf01b6c..53ef16a70a0 100644 --- a/source/blender/editors/gpencil/gpencil_buttons.c +++ b/source/blender/editors/gpencil/gpencil_buttons.c @@ -143,9 +143,9 @@ static void gp_drawui_layer (uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, con /* name */ if (gpl->flag & GP_LAYER_HIDE) - sprintf(name, "%s (Hidden)", gpl->info); + BLI_snprintf(name, sizeof(name), "%s (Hidden)", gpl->info); else - sprintf(name, "%s (Locked)", gpl->info); + BLI_snprintf(name, sizeof(name), "%s (Locked)", gpl->info); uiItemL(sub, name, ICON_NONE); /* delete button (only if hidden but not locked!) */ diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 2e9186b6c2f..d345f16b768 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -62,7 +62,7 @@ typedef struct EditBone normal bones when leaving editmode. */ void *temp; /* Used to store temporary data */ - char name[32]; + char name[64]; /* MAX_NAME */ float roll; /* Roll along axis. We'll ultimately use the axis/angle method for determining the transformation matrix of the bone. The axis is tail-head while roll provides the angle. Refer to Graphics diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 4948073f9c6..239dae7d236 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2920,7 +2920,7 @@ static void autocomplete_id(bContext *C, char *str, void *arg_v) /* search if str matches the beginning of an ID struct */ if(str[0]) { - AutoComplete *autocpl= autocomplete_begin(str, 22); + AutoComplete *autocpl= autocomplete_begin(str, MAX_ID_NAME-2); ID *id; for(id= listb->first; id; id= id->next) diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 84f0c61cd0c..5e42b06e1a7 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1208,7 +1208,7 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, const char *s if(itemptr.type && RNA_struct_is_ID(itemptr.type)) { ID *id= itemptr.data; - char name_ui[32]; + char name_ui[MAX_ID_NAME]; #if 0 /* this name is used for a string comparison and can't be modified, TODO */ name_uiprefix_id(name_ui, id); diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index c535f2c1ad0..973b43fca78 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -2109,7 +2109,7 @@ uiBlock *ui_block_func_COL(bContext *C, uiPopupBlockHandle *handle, void *arg_bu uiBut *but= arg_but; uiBlock *block; - block= uiBeginBlock(C, handle->region, "colorpicker", UI_EMBOSS); + block= uiBeginBlock(C, handle->region, __func__, UI_EMBOSS); if (but->rnaprop) { if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) { @@ -2299,8 +2299,8 @@ uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut uiStyle *style= UI_GetStyle(); uiPopupBlockHandle *handle; uiPopupMenu *pup; - pup= MEM_callocN(sizeof(uiPopupMenu), "menu dummy"); - pup->block= uiBeginBlock(C, NULL, "ui_button_menu_create", UI_EMBOSSP); + pup= MEM_callocN(sizeof(uiPopupMenu), __func__); + pup->block= uiBeginBlock(C, NULL, __func__, UI_EMBOSSP); pup->layout= uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style); pup->slideout= (but && (but->block->flag & UI_BLOCK_LOOP)); pup->but= but; @@ -2361,7 +2361,7 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon) uiPopupMenu *pup= MEM_callocN(sizeof(uiPopupMenu), "popup menu"); uiBut *but; - pup->block= uiBeginBlock(C, NULL, "uiPupMenuBegin", UI_EMBOSSP); + pup->block= uiBeginBlock(C, NULL, __func__, UI_EMBOSSP); pup->block->flag |= UI_BLOCK_POPUP_MEMORY; pup->block->puphash= ui_popup_menu_hash(title); pup->layout= uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style); diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 0e9dbaf3022..16b543737d0 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -180,7 +180,7 @@ void uiStyleFontDrawExt(uiFontStyle *fs, rcti *rect, const char *str, if (fs->kerning == 1) BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT); - BLF_draw(fs->uifont_id, str, 65535); /* XXX, use real length */ + BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX); BLF_disable(fs->uifont_id, BLF_CLIPPING); if (fs->shadow) BLF_disable(fs->uifont_id, BLF_SHADOW); @@ -243,7 +243,7 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str) if (fs->kerning == 1) BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT); - BLF_draw(fs->uifont_id, str, 65535); /* XXX, use real length */ + BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX); BLF_disable(fs->uifont_id, BLF_ROTATION); BLF_disable(fs->uifont_id, BLF_CLIPPING); if (fs->shadow) @@ -291,7 +291,7 @@ void UI_DrawString(float x, float y, const char *str) uiStyleFontSet(&style->widget); BLF_position(style->widget.uifont_id, x, y, 0.0f); - BLF_draw(style->widget.uifont_id, str, 65535); /* XXX, use real length */ + BLF_draw(style->widget.uifont_id, str, BLF_DRAW_STR_DUMMY_MAX); if (style->widget.kerning == 1) BLF_disable(style->widget.uifont_id, BLF_KERNING_DEFAULT); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 2cf73eeea6d..44224c808cc 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -140,7 +140,7 @@ static void id_search_cb(const bContext *C, void *arg_template, const char *str, continue; if(BLI_strcasestr(id->name+2, str)) { - char name_ui[32]; + char name_ui[MAX_ID_NAME]; name_uiprefix_id(name_ui, id); iconid= ui_id_icon_get((bContext*)C, id, 1); @@ -413,11 +413,11 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str } if(id->us > 1) { - char str[32]; + char numstr[32]; - BLI_snprintf(str, sizeof(str), "%d", id->us); + BLI_snprintf(numstr, sizeof(numstr), "%d", id->us); - but= uiDefBut(block, BUT, 0, str, 0,0,UI_UNIT_X + ((id->us < 10) ? 0:10), UI_UNIT_Y, NULL, 0, 0, 0, 0, + but= uiDefBut(block, BUT, 0, numstr, 0,0,UI_UNIT_X + ((id->us < 10) ? 0:10), UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Display number of users of this data (click to make a single-user copy)")); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ALONE)); @@ -1621,7 +1621,7 @@ static uiBlock *curvemap_clipping_func(bContext *C, struct ARegion *ar, void *cu uiBut *bt; float width= 8*UI_UNIT_X; - block= uiBeginBlock(C, ar, "curvemap_clipping_func", UI_EMBOSS); + block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); /* use this for a fake extra empy space around the buttons */ uiDefBut(block, LABEL, 0, "", -4, 16, width+8, 6*UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); @@ -1680,7 +1680,7 @@ static uiBlock *curvemap_tools_func(bContext *C, struct ARegion *ar, void *cumap uiBlock *block; short yco= 0, menuwidth=10*UI_UNIT_X; - block= uiBeginBlock(C, ar, "curvemap_tools_func", UI_EMBOSS); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, ""); @@ -1702,7 +1702,7 @@ static uiBlock *curvemap_brush_tools_func(bContext *C, struct ARegion *ar, void uiBlock *block; short yco= 0, menuwidth=10*UI_UNIT_X; - block= uiBeginBlock(C, ar, "curvemap_tools_func", UI_EMBOSS); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, ""); @@ -2281,7 +2281,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * uiBlock *block; uiBut *but; Panel *pa; - char *name, str[32]; + const char *name; + char numstr[32]; int rnaicon=0, icon=0, i= 0, activei= 0, len= 0, items, found, min, max; /* validate arguments */ @@ -2372,7 +2373,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * uiItemL(row, (name)? name: "", icon); if(name) - MEM_freeN(name); + MEM_freeN((void *)name); } i++; @@ -2385,8 +2386,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * uiItemL(row, "", ICON_NONE); /* next/prev button */ - BLI_snprintf(str, sizeof(str), "%d :", i); - but= uiDefIconTextButR_prop(block, NUM, 0, 0, str, 0,0,UI_UNIT_X*5,UI_UNIT_Y, activeptr, activeprop, 0, 0, 0, 0, 0, ""); + BLI_snprintf(numstr, sizeof(numstr), "%d :", i); + but= uiDefIconTextButR_prop(block, NUM, 0, 0, numstr, 0,0,UI_UNIT_X*5,UI_UNIT_Y, activeptr, activeprop, 0, 0, 0, 0, 0, ""); if(i == 0) uiButSetFlag(but, UI_BUT_DISABLED); } @@ -2470,12 +2471,15 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char int len= strlen(ot->name); /* display name for menu, can hold hotkey */ - BLI_strncpy(name, ot->name, 256); + BLI_strncpy(name, ot->name, sizeof(name)); /* check for hotkey */ - if(len < 256-6) { - if(WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, TRUE, &name[len+1], 256-len-1)) + if(len < sizeof(name)-6) { + if (WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, TRUE, + &name[len+1], sizeof(name)-len-1)) + { name[len]= '|'; + } } if(0==uiSearchItemAdd(items, name, ot, 0)) diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 57d46de9cb7..b8201d762df 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1507,7 +1507,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short static void scroll_printstr(Scene *scene, float x, float y, float val, int power, short unit, char dir) { int len; - char str[32]; + char timecode_str[32]; /* adjust the scale unit to work ok */ if (dir == 'v') { @@ -1522,10 +1522,10 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power } /* get string to print */ - ANIM_timecode_string_from_frame(str, scene, power, (unit == V2D_UNIT_SECONDS), val); + ANIM_timecode_string_from_frame(timecode_str, scene, power, (unit == V2D_UNIT_SECONDS), val); /* get length of string, and adjust printing location to fit it into the horizontal scrollbar */ - len= strlen(str); + len= strlen(timecode_str); if (dir == 'h') { /* seconds/timecode display has slightly longer strings... */ if (unit == V2D_UNIT_SECONDS) @@ -1536,12 +1536,12 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power /* Add degree sympbol to end of string for vertical scrollbar? */ if ((dir == 'v') && (unit == V2D_UNIT_DEGREES)) { - str[len]= 186; - str[len+1]= 0; + timecode_str[len]= 186; + timecode_str[len+1]= 0; } /* draw it */ - BLF_draw_default_ascii(x, y, 0.0f, str, sizeof(str)-1); + BLF_draw_default_ascii(x, y, 0.0f, timecode_str, sizeof(timecode_str)); } /* Draw scrollbars in the given 2d-region */ @@ -2093,11 +2093,11 @@ void UI_view2d_text_cache_draw(ARegion *ar) } if(v2s->rect.xmin >= v2s->rect.xmax) - BLF_draw_default((float)v2s->mval[0]+xofs, (float)v2s->mval[1]+yofs, 0.0, str, 65535); + BLF_draw_default((float)v2s->mval[0]+xofs, (float)v2s->mval[1]+yofs, 0.0, str, BLF_DRAW_STR_DUMMY_MAX); else { BLF_clipping_default(v2s->rect.xmin-4, v2s->rect.ymin-4, v2s->rect.xmax+4, v2s->rect.ymax+4); BLF_enable_default(BLF_CLIPPING); - BLF_draw_default(v2s->rect.xmin+xofs, v2s->rect.ymin+yofs, 0.0f, str, 65535); + BLF_draw_default(v2s->rect.xmin+xofs, v2s->rect.ymin+yofs, 0.0f, str, BLF_DRAW_STR_DUMMY_MAX); BLF_disable_default(BLF_CLIPPING); } } diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 93ea76db569..8ba4bb15849 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -524,7 +524,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event) Mesh *me; Object *obedit; int exitmode= 0; - char name[32]; + char name[MAX_ID_NAME-2]; /* Check context */ if(base==NULL || base->object->type!=OB_MESH) { @@ -593,7 +593,7 @@ void MESH_OT_drop_named_image(wmOperatorType *ot) ot->flag= OPTYPE_UNDO; /* properties */ - RNA_def_string(ot->srna, "name", "Image", 24, "Name", "Image name to assign"); + RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME-2, "Name", "Image name to assign"); RNA_def_string(ot->srna, "filepath", "Path", FILE_MAX, "Filepath", "Path to image file"); } diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 438d04ba69b..a2d73ac8b5d 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1922,7 +1922,7 @@ static int add_named_exec(bContext *C, wmOperator *op) Object *ob; int linked= RNA_boolean_get(op->ptr, "linked"); int dupflag= (linked)? 0: U.dupflag; - char name[32]; + char name[MAX_ID_NAME-2]; /* find object, create fake base */ RNA_string_get(op->ptr, "name", name); @@ -1977,7 +1977,7 @@ void OBJECT_OT_add_named(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; RNA_def_boolean(ot->srna, "linked", 0, "Linked", "Duplicate object but not object data, linking to the original data"); - RNA_def_string(ot->srna, "name", "Cube", 24, "Name", "Object name to add"); + RNA_def_string(ot->srna, "name", "Cube", MAX_ID_NAME-2, "Name", "Object name to add"); } diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 8266f3501c5..ac73f03c2d7 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -542,7 +542,7 @@ static int edit_constraint_poll(bContext *C) static void edit_constraint_properties(wmOperatorType *ot) { - RNA_def_string(ot->srna, "constraint", "", 32, "Constraint", "Name of the constraint to edit"); + RNA_def_string(ot->srna, "constraint", "", MAX_NAME, "Constraint", "Name of the constraint to edit"); RNA_def_enum(ot->srna, "owner", constraint_owner_items, 0, "Owner", "The owner of this constraint"); } @@ -575,7 +575,7 @@ static int edit_constraint_invoke_properties(bContext *C, wmOperator *op) static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int type) { - char constraint_name[32]; + char constraint_name[MAX_NAME]; int owner = RNA_enum_get(op->ptr, "owner"); bConstraint *con; ListBase *list=NULL; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 631dfce297a..ea39e857643 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1484,7 +1484,7 @@ static int game_property_new(bContext *C, wmOperator *op) { Object *ob= CTX_data_active_object(C); bProperty *prop; - char name[32]; + char name[MAX_NAME]; int type= RNA_enum_get(op->ptr, "type"); prop= new_property(type); @@ -1517,7 +1517,7 @@ void OBJECT_OT_game_property_new(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; RNA_def_enum(ot->srna, "type", gameproperty_type_items, 2, "Type", "Type of game property to add"); - RNA_def_string(ot->srna, "name", "", 32, "Name", "Name of the game property to add"); + RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Name of the game property to add"); } static int game_property_remove(bContext *C, wmOperator *op) diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index 74cf174d7b4..1b8c0fd0840 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -192,7 +192,7 @@ static int group_create_exec(bContext *C, wmOperator *op) Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Group *group= NULL; - char name[32]; /* id name */ + char name[MAX_ID_NAME-2]; /* id name */ RNA_string_get(op->ptr, "name", name); @@ -223,7 +223,7 @@ void GROUP_OT_create(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_string(ot->srna, "name", "Group", 32, "Name", "Name of the new group"); + RNA_def_string(ot->srna, "name", "Group", MAX_ID_NAME-2, "Name", "Name of the new group"); } /****************** properties window operators *********************/ diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 925a59e8344..73bd8f433fd 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -432,7 +432,7 @@ static void add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *o HookModifierData *hmd = NULL; float cent[3]; int tot, ok, *indexar; - char name[32]; + char name[MAX_NAME]; ok = object_hook_index_array(scene, obedit, &tot, &indexar, name, cent); @@ -752,7 +752,7 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op) Object *ob=NULL; HookModifierData *hmd=NULL; float cent[3]; - char name[32]; + char name[MAX_NAME]; int *indexar, tot; if (ptr.data) { /* if modifier context is available, use that */ diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 069c211d639..1e7cd9f7624 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -740,7 +740,7 @@ static int edit_modifier_poll(bContext *C) static void edit_modifier_properties(wmOperatorType *ot) { - RNA_def_string(ot->srna, "modifier", "", 32, "Modifier", "Name of the modifier to edit"); + RNA_def_string(ot->srna, "modifier", "", MAX_NAME, "Modifier", "Name of the modifier to edit"); } static int edit_modifier_invoke_properties(bContext *C, wmOperator *op) @@ -762,7 +762,7 @@ static int edit_modifier_invoke_properties(bContext *C, wmOperator *op) static ModifierData *edit_modifier_property_get(wmOperator *op, Object *ob, int type) { - char modifier_name[32]; + char modifier_name[MAX_NAME]; ModifierData *md; RNA_string_get(op->ptr, "modifier", modifier_name); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 3daffe415d1..57c54f256d4 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -246,7 +246,7 @@ void ED_operatormacros_object(void) ot= WM_operatortype_append_macro("OBJECT_OT_add_named_cursor", "Add named object at cursor", OPTYPE_UNDO|OPTYPE_REGISTER); if(ot) { ot->description = "Add named object at cursor"; - RNA_def_string(ot->srna, "name", "Cube", 24, "Name", "Object name to add"); + RNA_def_string(ot->srna, "name", "Cube", MAX_ID_NAME-2, "Name", "Object name to add"); WM_operatortype_macro_define(ot, "VIEW3D_OT_cursor3d"); WM_operatortype_macro_define(ot, "OBJECT_OT_add_named"); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index ca1293926bc..56fd1b4409a 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -333,7 +333,7 @@ static int make_proxy_exec (bContext *C, wmOperator *op) if (ob) { Object *newob; Base *newbase, *oldbase= BASACT; - char name[32]; + char name[MAX_ID_NAME+4]; /* Add new object for the proxy */ newob= add_object(scene, OB_EMPTY); @@ -1888,7 +1888,7 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, wmEvent *even Main *bmain= CTX_data_main(C); Base *base= ED_view3d_give_base_under_cursor(C, event->mval); Material *ma; - char name[32]; + char name[MAX_ID_NAME-2]; RNA_string_get(op->ptr, "name", name); ma= (Material *)find_id("MA", name); @@ -1921,5 +1921,5 @@ void OBJECT_OT_drop_named_material(wmOperatorType *ot) ot->flag= OPTYPE_UNDO; /* properties */ - RNA_def_string(ot->srna, "name", "Material", 24, "Name", "Material name to assign"); + RNA_def_string(ot->srna, "name", "Material", MAX_ID_NAME-2, "Name", "Material name to assign"); } diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index b48b2e8718d..da69c2a0640 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -841,7 +841,7 @@ void OBJECT_OT_select_all(wmOperatorType *ot) static int object_select_same_group_exec(bContext *C, wmOperator *op) { Group *group; - char group_name[32]; + char group_name[MAX_ID_NAME]; /* passthrough if no objects are visible */ if (CTX_DATA_COUNT(C, visible_bases) == 0) return OPERATOR_PASS_THROUGH; @@ -882,7 +882,7 @@ void OBJECT_OT_select_same_group(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_string(ot->srna, "group", "", 32, "Group", "Name of the group to select"); + RNA_def_string(ot->srna, "group", "", MAX_ID_NAME, "Group", "Name of the group to select"); } /**************************** Select Mirror ****************************/ diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 5294e29d3d5..0bb5dbef0ea 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -1042,7 +1042,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor fsset->surfaceSmoothing = domainSettings->surfaceSmoothing; fsset->surfaceSubdivs = domainSettings->surfaceSubdivs; fsset->farFieldSize = domainSettings->farFieldSize; - BLI_strncpy(fsset->outputPath, targetFile, 240); + BLI_strncpy(fsset->outputPath, targetFile, sizeof(fsset->outputPath)); // domain channels fsset->channelSizeFrameTime = diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 08833b335eb..e4088fe10c4 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -478,7 +478,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar) glClear(GL_COLOR_BUFFER_BIT); UI_ThemeColor(TH_TEXT); - BLF_draw_default(20, 8, 0.0f, ar->headerstr, 65535); /* XXX, use real length */ + BLF_draw_default(20, 8, 0.0f, ar->headerstr, BLF_DRAW_STR_DUMMY_MAX); } else if(at->draw) { at->draw(C, ar); @@ -1809,5 +1809,5 @@ void ED_region_info_draw(ARegion *ar, const char *text, int block, float alpha) /* text */ UI_ThemeColor(TH_TEXT_HI); BLF_position(fontid, 12, rect.ymin + 5, 0.0f); - BLF_draw(fontid, text, 256); + BLF_draw(fontid, text, BLF_DRAW_STR_DUMMY_MAX); } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index e14ba9b8c4f..694485f51f2 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -236,7 +236,7 @@ typedef struct StrokeCache { float vertex_rotation; - char saved_active_brush_name[24]; + char saved_active_brush_name[MAX_ID_NAME]; int alt_smooth; float plane_trim_squared; diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 619e76e9e50..309b455e2a2 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -119,7 +119,7 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) } } { /* second pass: widgets */ - uiBlock *block= uiBeginBlock(C, ar, "dopesheet channel buttons", UI_EMBOSS); + uiBlock *block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); size_t channel_index = 0; y= (float)ACHANNEL_FIRST; diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c index 1c352b1cb21..6777e2c2d85 100644 --- a/source/blender/editors/space_buttons/buttons_header.c +++ b/source/blender/editors/space_buttons/buttons_header.c @@ -108,7 +108,7 @@ void buttons_header_buttons(const bContext *C, ARegion *ar) buttons_context_compute(C, sbuts); - block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockSetHandleFunc(block, do_buttons_buttons, NULL); xco= ED_area_header_switchbutton(C, block, yco); diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 1593ecd7cb8..0d1c312792a 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -75,20 +75,20 @@ void clip_draw_curfra_label(SpaceClip *sc, float x, float y) { uiStyle *style= UI_GetStyle(); int fontid= style->widget.uifont_id; - char str[32]; + char numstr[32]; float font_dims[2] = {0.0f, 0.0f}; /* frame number */ BLF_size(fontid, 11.0f, U.dpi); - BLI_snprintf(str, sizeof(str), "%d", sc->user.framenr); + BLI_snprintf(numstr, sizeof(numstr), "%d", sc->user.framenr); - BLF_width_and_height(fontid, str, &font_dims[0], &font_dims[1]); + BLF_width_and_height(fontid, numstr, &font_dims[0], &font_dims[1]); glRecti(x, y, x + font_dims[0] + 6.0f, y + font_dims[1] + 4.0f); UI_ThemeColor(TH_TEXT); BLF_position(fontid, x+2.0f, y+2.0f, 0.0f); - BLF_draw(fontid, str, sizeof(str)); + BLF_draw(fontid, numstr, sizeof(numstr)); } static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Scene *scene) diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 41aae64445a..c84a9d10ab4 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -118,7 +118,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) const int separator = 4; /* Additional locals. */ - char name[32]; + char uiblockstr[32]; int loadbutton; int fnumbuttons; int min_x = 10; @@ -134,8 +134,8 @@ void file_draw_buttons(const bContext *C, ARegion *ar) ARegion* artmp; /* Initialize UI block. */ - sprintf(name, "win %p", (void *)ar); - block = uiBeginBlock(C, ar, name, UI_EMBOSS); + BLI_snprintf(uiblockstr, sizeof(uiblockstr), "win %p", (void *)ar); + block = uiBeginBlock(C, ar, uiblockstr, UI_EMBOSS); uiBlockSetHandleFunc(block, do_file_buttons, NULL); /* exception to make space for collapsed region icon */ @@ -450,7 +450,7 @@ void file_draw_list(const bContext *C, ARegion *ar) struct FileList* files = sfile->files; struct direntry *file; ImBuf *imb; - uiBlock *block = uiBeginBlock(C, ar, "FileNames", UI_EMBOSS); + uiBlock *block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); int numfiles; int numfiles_layout; int sx, sy; diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 288ff76d9ff..32fe8498eaf 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -970,7 +970,7 @@ int filelist_islibrary(struct FileList* filelist, char* dir, char* group) return BLO_is_a_library(filelist->dir, dir, group); } -static int groupname_to_code(char *group) +static int groupname_to_code(const char *group) { char buf[32]; char *lslash; @@ -1199,10 +1199,10 @@ void filelist_from_main(struct FileList *filelist) if(idcode == ID_MA || idcode == ID_TE || idcode == ID_LA || idcode == ID_WO || idcode == ID_IM) { files->flags |= IMAGEFILE; } - if(id->lib && fake) sprintf(files->extra, "LF %d", id->us); - else if(id->lib) sprintf(files->extra, "L %d", id->us); - else if(fake) sprintf(files->extra, "F %d", id->us); - else sprintf(files->extra, " %d", id->us); + if(id->lib && fake) BLI_snprintf(files->extra, sizeof(files->extra), "LF %d", id->us); + else if(id->lib) BLI_snprintf(files->extra, sizeof(files->extra), "L %d", id->us); + else if(fake) BLI_snprintf(files->extra, sizeof(files->extra), "F %d", id->us); + else BLI_snprintf(files->extra, sizeof(files->extra), " %d", id->us); if(id->lib) { if(totlib==0) firstlib= files; diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index c1dfa97a508..9e1ff82c20d 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -647,7 +647,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) uiItemL(row, "Driver Value:", ICON_NONE); - sprintf(valBuf, "%.3f", driver->curval); + BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval); uiItemL(row, valBuf, ICON_NONE); } @@ -702,18 +702,18 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) graph_panel_driverVar__transChan(box, ale->id, dvar); break; } - - /* value of variable */ - if (driver->flag & DRIVER_FLAG_SHOWDEBUG) { - char valBuf[32]; - - box= uiLayoutBox(col); - row= uiLayoutRow(box, 1); + + /* value of variable */ + if (driver->flag & DRIVER_FLAG_SHOWDEBUG) { + char valBuf[32]; + + box= uiLayoutBox(col); + row= uiLayoutRow(box, 1); uiItemL(row, "Value:", ICON_NONE); - sprintf(valBuf, "%.3f", dvar->curval); + BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval); uiItemL(row, valBuf, ICON_NONE); - } + } } /* cleanup */ diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 7091fe094c6..7bdb37d9651 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -1003,7 +1003,7 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) } } { /* second pass: widgets */ - uiBlock *block= uiBeginBlock(C, ar, "graph channel buttons", UI_EMBOSS); + uiBlock *block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); size_t channel_index = 0; y= (float)ACHANNEL_FIRST; diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 8d8c79386c5..43bea1c311d 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -335,7 +335,7 @@ static void image_panel_preview(ScrArea *sa, short cntrl) // IMAGE_HANDLER_PREVI return; } - block= uiBeginBlock(C, ar, "image_panel_preview", UI_EMBOSS); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | UI_PNL_SCALE | cntrl); uiSetPanelHandler(IMAGE_HANDLER_PREVIEW); // for close and esc @@ -682,7 +682,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char uiButSetFunc(but, image_freecache_cb, ima, NULL); if(iuser->frames) - sprintf(str, "(%d) Frames:", iuser->framenr); + BLI_snprintf(str, sizeof(str), "(%d) Frames:", iuser->framenr); else strcpy(str, "Frames:"); uiBlockBeginAlign(block); uiDefButI(block, NUM, imagechanged, str, 10, 90,150, 20, &iuser->frames, 0.0, MAXFRAMEF, 0, 0, "Number of images of a movie to use"); @@ -763,7 +763,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char col= uiLayoutColumn(split, 0); - sprintf(str, "(%d) Frames", iuser->framenr); + BLI_snprintf(str, sizeof(str), "(%d) Frames", iuser->framenr); uiItemR(col, userptr, "frame_duration", 0, str, ICON_NONE); if(ima->anim) { block= uiLayoutGetBlock(col); diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index dc712e286a1..21a4f35bcb8 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -139,7 +139,7 @@ void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y, BLF_size(blf_mono_font, 11, 72); glColor3ub(255, 255, 255); - sprintf(str, "X:%-4d Y:%-4d |", x, y); + BLI_snprintf(str, sizeof(str), "X:%-4d Y:%-4d |", x, y); // UI_DrawString(6, 6, str); // works ok but fixed width is nicer. BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); @@ -147,14 +147,14 @@ void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y, if(zp) { glColor3ub(255, 255, 255); - sprintf(str, " Z:%-.4f |", 0.5f+0.5f*(((float)*zp)/(float)0x7fffffff)); + BLI_snprintf(str, sizeof(str), " Z:%-.4f |", 0.5f+0.5f*(((float)*zp)/(float)0x7fffffff)); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); } if(zpf) { glColor3ub(255, 255, 255); - sprintf(str, " Z:%-.3f |", *zpf); + BLI_snprintf(str, sizeof(str), " Z:%-.3f |", *zpf); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); @@ -163,33 +163,33 @@ void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y, if(channels >= 3) { glColor3ubv(red); if (fp) - sprintf(str, " R:%-.4f", fp[0]); + BLI_snprintf(str, sizeof(str), " R:%-.4f", fp[0]); else if (cp) - sprintf(str, " R:%-3d", cp[0]); + BLI_snprintf(str, sizeof(str), " R:%-3d", cp[0]); else - sprintf(str, " R:-"); + BLI_snprintf(str, sizeof(str), " R:-"); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); glColor3ubv(green); if (fp) - sprintf(str, " G:%-.4f", fp[1]); + BLI_snprintf(str, sizeof(str), " G:%-.4f", fp[1]); else if (cp) - sprintf(str, " G:%-3d", cp[1]); + BLI_snprintf(str, sizeof(str), " G:%-3d", cp[1]); else - sprintf(str, " G:-"); + BLI_snprintf(str, sizeof(str), " G:-"); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); glColor3ubv(blue); if (fp) - sprintf(str, " B:%-.4f", fp[2]); + BLI_snprintf(str, sizeof(str), " B:%-.4f", fp[2]); else if (cp) - sprintf(str, " B:%-3d", cp[2]); + BLI_snprintf(str, sizeof(str), " B:%-3d", cp[2]); else - sprintf(str, " B:-"); + BLI_snprintf(str, sizeof(str), " B:-"); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); @@ -197,11 +197,11 @@ void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y, if(channels == 4) { glColor3ub(255, 255, 255); if (fp) - sprintf(str, " A:%-.4f", fp[3]); + BLI_snprintf(str, sizeof(str), " A:%-.4f", fp[3]); else if (cp) - sprintf(str, " A:%-3d", cp[3]); + BLI_snprintf(str, sizeof(str), " A:%-3d", cp[3]); else - sprintf(str, "- "); + BLI_snprintf(str, sizeof(str), "- "); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); @@ -269,12 +269,12 @@ void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y, rgb_to_yuv((float)cp[0]/255.0f, (float)cp[0]/255.0f, (float)cp[0]/255.0f, &lum, &u, &v); } - sprintf(str, "V:%-.4f", val); + BLI_snprintf(str, sizeof(str), "V:%-.4f", val); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); - sprintf(str, " L:%-.4f", lum); + BLI_snprintf(str, sizeof(str), " L:%-.4f", lum); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); @@ -289,22 +289,22 @@ void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y, rgb_to_yuv((float)cp[0]/255.0f, (float)cp[1]/255.0f, (float)cp[2]/255.0f, &lum, &u, &v); } - sprintf(str, "H:%-.4f", hue); + BLI_snprintf(str, sizeof(str), "H:%-.4f", hue); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); - sprintf(str, " S:%-.4f", sat); + BLI_snprintf(str, sizeof(str), " S:%-.4f", sat); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); - sprintf(str, " V:%-.4f", val); + BLI_snprintf(str, sizeof(str), " V:%-.4f", val); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); - sprintf(str, " L:%-.4f", lum); + BLI_snprintf(str, sizeof(str), " L:%-.4f", lum); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index deff1c77912..2090b4eae0a 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -143,7 +143,7 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event) Main *bmain= CTX_data_main(C); uiPopupMenu *pup; uiLayout *layout; - char title[128]; + char title[64]; int count = 0; count = countPackedFiles(bmain); @@ -155,9 +155,9 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event) } if(count == 1) - sprintf(title, "Unpack 1 file"); + strcpy(title, "Unpack 1 file"); else - sprintf(title, "Unpack %d files", count); + BLI_snprintf(title, sizeof(title), "Unpack %d files", count); pup= uiPupMenuBegin(C, title, ICON_NONE); layout= uiPupMenuLayout(pup); diff --git a/source/blender/editors/space_logic/logic_ops.c b/source/blender/editors/space_logic/logic_ops.c index ce6b7d2e910..b0f5e786eef 100644 --- a/source/blender/editors/space_logic/logic_ops.c +++ b/source/blender/editors/space_logic/logic_ops.c @@ -88,8 +88,8 @@ static int edit_actuator_poll(bContext *C) static void edit_sensor_properties(wmOperatorType *ot) { - RNA_def_string(ot->srna, "sensor", "", 32, "Sensor", "Name of the sensor to edit"); - RNA_def_string(ot->srna, "object", "", 32, "Object", "Name of the object the sensor belongs to"); + RNA_def_string(ot->srna, "sensor", "", MAX_NAME, "Sensor", "Name of the sensor to edit"); + RNA_def_string(ot->srna, "object", "", MAX_NAME, "Object", "Name of the object the sensor belongs to"); } static int edit_sensor_invoke_properties(bContext *C, wmOperator *op) @@ -113,14 +113,14 @@ static int edit_sensor_invoke_properties(bContext *C, wmOperator *op) static Object *edit_object_property_get(bContext *C, wmOperator *op) { - char ob_name[32]; + char ob_name[MAX_NAME]; Object *ob; RNA_string_get(op->ptr, "object", ob_name); /* if ob_name is valid try to find the object with this name otherwise gets the active object */ - if (BLI_strnlen(ob_name, 32) > 0) + if (BLI_strnlen(ob_name, MAX_NAME) > 0) ob = BLI_findstring(&(CTX_data_main(C)->object), ob_name, offsetof(ID, name) + 2); else ob= ED_object_active_context(C); @@ -130,7 +130,7 @@ static Object *edit_object_property_get(bContext *C, wmOperator *op) static bSensor *edit_sensor_property_get(bContext *C, wmOperator *op, Object **ob) { - char sensor_name[32]; + char sensor_name[MAX_NAME]; bSensor *sens; RNA_string_get(op->ptr, "sensor", sensor_name); @@ -144,8 +144,8 @@ static bSensor *edit_sensor_property_get(bContext *C, wmOperator *op, Object **o static void edit_controller_properties(wmOperatorType *ot) { - RNA_def_string(ot->srna, "controller", "", 32, "Controller", "Name of the controller to edit"); - RNA_def_string(ot->srna, "object", "", 32, "Object", "Name of the object the controller belongs to"); + RNA_def_string(ot->srna, "controller", "", MAX_NAME, "Controller", "Name of the controller to edit"); + RNA_def_string(ot->srna, "object", "", MAX_NAME, "Object", "Name of the object the controller belongs to"); } static int edit_controller_invoke_properties(bContext *C, wmOperator *op) @@ -169,7 +169,7 @@ static int edit_controller_invoke_properties(bContext *C, wmOperator *op) static bController *edit_controller_property_get(bContext *C, wmOperator *op, Object **ob) { - char controller_name[32]; + char controller_name[MAX_NAME]; bController *cont; RNA_string_get(op->ptr, "controller", controller_name); @@ -183,8 +183,8 @@ static bController *edit_controller_property_get(bContext *C, wmOperator *op, Ob static void edit_actuator_properties(wmOperatorType *ot) { - RNA_def_string(ot->srna, "actuator", "", 32, "Actuator", "Name of the actuator to edit"); - RNA_def_string(ot->srna, "object", "", 32, "Object", "Name of the object the actuator belongs to"); + RNA_def_string(ot->srna, "actuator", "", MAX_NAME, "Actuator", "Name of the actuator to edit"); + RNA_def_string(ot->srna, "object", "", MAX_NAME, "Object", "Name of the object the actuator belongs to"); } static int edit_actuator_invoke_properties(bContext *C, wmOperator *op) @@ -208,7 +208,7 @@ static int edit_actuator_invoke_properties(bContext *C, wmOperator *op) static bActuator *edit_actuator_property_get(bContext *C, wmOperator *op, Object **ob) { - char actuator_name[32]; + char actuator_name[MAX_NAME]; bActuator *act; RNA_string_get(op->ptr, "actuator", actuator_name); @@ -278,7 +278,7 @@ static int sensor_add_exec(bContext *C, wmOperator *op) PointerRNA sens_ptr; PropertyRNA *prop; const char *sens_name; - char name[32]; + char name[MAX_NAME]; int type= RNA_enum_get(op->ptr, "type"); ob= edit_object_property_get(C, op); @@ -293,7 +293,7 @@ static int sensor_add_exec(bContext *C, wmOperator *op) prop = RNA_struct_find_property(&sens_ptr, "type"); RNA_string_get(op->ptr, "name", name); - if(BLI_strnlen(name, 32) < 1){ + if(BLI_strnlen(name, MAX_NAME) < 1){ RNA_property_enum_name(C, &sens_ptr, prop, RNA_property_enum_get(&sens_ptr, prop), &sens_name); BLI_strncpy(sens->name, sens_name, sizeof(sens->name)); } @@ -328,8 +328,8 @@ static void LOGIC_OT_sensor_add(wmOperatorType *ot) /* properties */ ot->prop= prop= RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, SENS_ALWAYS, "Type", "Type of sensor to add"); RNA_def_enum_funcs(prop, rna_Sensor_type_itemf); - RNA_def_string(ot->srna, "name", "", 32, "Name", "Name of the Sensor to add"); - RNA_def_string(ot->srna, "object", "", 32, "Object", "Name of the Object to add the Sensor to"); + RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Name of the Sensor to add"); + RNA_def_string(ot->srna, "object", "", MAX_NAME, "Object", "Name of the Object to add the Sensor to"); } /* ************* Add/Remove Controller Operator ************* */ @@ -382,7 +382,7 @@ static int controller_add_exec(bContext *C, wmOperator *op) PropertyRNA *prop; const char *cont_name; int bit; - char name[32]; + char name[MAX_NAME]; int type= RNA_enum_get(op->ptr, "type"); ob= edit_object_property_get(C, op); @@ -397,7 +397,7 @@ static int controller_add_exec(bContext *C, wmOperator *op) prop = RNA_struct_find_property(&cont_ptr, "type"); RNA_string_get(op->ptr, "name", name); - if(BLI_strnlen(name, 32) < 1){ + if(BLI_strnlen(name, MAX_NAME) < 1){ RNA_property_enum_name(C, &cont_ptr, prop, RNA_property_enum_get(&cont_ptr, prop), &cont_name); BLI_strncpy(cont->name, cont_name, sizeof(cont->name)); } @@ -442,8 +442,8 @@ static void LOGIC_OT_controller_add(wmOperatorType *ot) /* properties */ ot->prop= RNA_def_enum(ot->srna, "type", controller_type_items, CONT_LOGIC_AND, "Type", "Type of controller to add"); - RNA_def_string(ot->srna, "name", "", 32, "Name", "Name of the Controller to add"); - RNA_def_string(ot->srna, "object", "", 32, "Object", "Name of the Object to add the Controller to"); + RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Name of the Controller to add"); + RNA_def_string(ot->srna, "object", "", MAX_NAME, "Object", "Name of the Object to add the Controller to"); } /* ************* Add/Remove Actuator Operator ************* */ @@ -495,7 +495,7 @@ static int actuator_add_exec(bContext *C, wmOperator *op) PointerRNA act_ptr; PropertyRNA *prop; const char *act_name; - char name[32]; + char name[MAX_NAME]; int type= RNA_enum_get(op->ptr, "type"); ob= edit_object_property_get(C, op); @@ -510,7 +510,7 @@ static int actuator_add_exec(bContext *C, wmOperator *op) prop = RNA_struct_find_property(&act_ptr, "type"); RNA_string_get(op->ptr, "name", name); - if (BLI_strnlen(name, 32) < 1){ + if (BLI_strnlen(name, MAX_NAME) < 1){ RNA_property_enum_name(C, &act_ptr, prop, RNA_property_enum_get(&act_ptr, prop), &act_name); BLI_strncpy(act->name, act_name, sizeof(act->name)); } @@ -545,8 +545,8 @@ static void LOGIC_OT_actuator_add(wmOperatorType *ot) /* properties */ ot->prop= prop= RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, CONT_LOGIC_AND, "Type", "Type of actuator to add"); RNA_def_enum_funcs(prop, rna_Actuator_type_itemf); - RNA_def_string(ot->srna, "name", "", 32, "Name", "Name of the Actuator to add"); - RNA_def_string(ot->srna, "object", "", 32, "Object", "Name of the Object to add the Actuator to"); + RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Name of the Actuator to add"); + RNA_def_string(ot->srna, "object", "", MAX_NAME, "Object", "Name of the Object to add the Actuator to"); } /* ************* Move Logic Bricks Operator ************* */ diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index e5255448ae9..2c1e7a0c546 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -1187,7 +1187,7 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short ts= sens->data; - /* uiDefBut(block, TEX, 1, "Property:", xco,yco-22,width, 19, &ts->name, 0, 31, 0, 0, "Only look for Objects with this property"); */ + /* uiDefBut(block, TEX, 1, "Property:", xco,yco-22,width, 19, &ts->name, 0, MAX_NAME, 0, 0, "Only look for Objects with this property"); */ uiDefIDPoinBut(block, test_matpoin_but, ID_MA, 1, "MA:",(short)(xco + 10),(short)(yco-44), (short)(width - 20), 19, &ts->ma, "Only look for floors with this Material"); ///* uiDefButF(block, NUM, 1, "Margin:", xco+width/2,yco-44,width/2, 19, &ts->dist, 0.0, 10.0, 100, 0, "Extra margin (distance) for larger sensitivity"); yco-= ysize; @@ -1216,11 +1216,11 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short if (cs->mode & SENS_COLLISION_MATERIAL) { uiDefBut(block, TEX, 1, "Material:", (short)(xco + 10 + 0.40 * (width-20)), - (short)(yco-44), (short)(0.6*(width-20)), 19, &cs->materialName, 0, 31, 0, 0, + (short)(yco-44), (short)(0.6*(width-20)), 19, &cs->materialName, 0, MAX_NAME, 0, 0, "Only look for Objects with this material"); } else { uiDefBut(block, TEX, 1, "Property:", (short)(xco + 10 + 0.40 * (width-20)), (short)(yco-44), - (short)(0.6*(width-20)), 19, &cs->name, 0, 31, 0, 0, + (short)(0.6*(width-20)), 19, &cs->name, 0, MAX_NAME, 0, 0, "Only look for Objects with this property"); } @@ -1240,7 +1240,7 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short ns= sens->data; uiDefBut(block, TEX, 1, "Property:",(short)(10+xco),(short)(yco-44), (short)(width-20), 19, - &ns->name, 0, 31, 0, 0, "Only look for Objects with this property"); + &ns->name, 0, MAX_NAME, 0, 0, "Only look for Objects with this property"); uiDefButF(block, NUM, 1, "Dist",(short)(10+xco),(short)(yco-68),(short)((width-22)/2), 19, &ns->dist, 0.0, 1000.0, 1000, 0, "Trigger distance"); uiDefButF(block, NUM, 1, "Reset",(short)(10+xco+(width-22)/2), (short)(yco-68), (short)((width-22)/2), 19, @@ -1261,7 +1261,7 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short uiDefBut(block, TEX, 1, "Prop:", (short)(10+xco),(short)(yco-44), (short)(0.7 * (width-20)), 19, - &rs->name, 0, 31, 0, 0, + &rs->name, 0, MAX_NAME, 0, 0, "Only look for Objects with this property"); str = "Type %t|+X axis %x0|+Y axis %x1|+Z axis %x2|-X axis %x3|-Y axis %x4|-Z axis %x5"; @@ -1316,14 +1316,14 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short /* line 4: toggle property for string logging mode */ uiDefBut(block, TEX, 1, "LogToggle: ", xco+10, yco-((ks->type&1) ? 68:92), (width-20), 19, - ks->toggleName, 0, 31, 0, 0, + ks->toggleName, 0, MAX_NAME, 0, 0, "Property that indicates whether to log " "keystrokes as a string"); /* line 5: target property for string logging mode */ uiDefBut(block, TEX, 1, "Target: ", xco+10, yco-((ks->type&1) ? 92:116), (width-20), 19, - ks->targetName, 0, 31, 0, 0, + ks->targetName, 0, MAX_NAME, 0, 0, "Property that receives the keystrokes in case " "a string is logged"); @@ -1349,21 +1349,21 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short if (ps->type != SENS_PROP_EXPRESSION) { uiDefBut(block, TEX, 1, "Prop: ", xco+30,yco-68,width-60, 19, - ps->name, 0, 31, 0, 0, "Property name"); + ps->name, 0, MAX_NAME, 0, 0, "Property name"); } if(ps->type == SENS_PROP_INTERVAL) { uiDefBut(block, TEX, 1, "Min: ", xco,yco-92,width/2, 19, - ps->value, 0, 31, 0, 0, "check for min value"); + ps->value, 0, MAX_NAME, 0, 0, "check for min value"); uiDefBut(block, TEX, 1, "Max: ", xco+width/2,yco-92,width/2, 19, - ps->maxvalue, 0, 31, 0, 0, "check for max value"); + ps->maxvalue, 0, MAX_NAME, 0, 0, "check for max value"); } else if(ps->type == SENS_PROP_CHANGED); else { uiDefBut(block, TEX, 1, "Value: ", xco+30,yco-92,width-60, 19, - ps->value, 0, 31, 0, 0, "check for value"); + ps->value, 0, MAX_NAME, 0, 0, "check for value"); } yco-= ysize; @@ -1384,12 +1384,12 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short uiBlockBeginAlign(block); but = uiDefBut(block, TEX, 1, "Bone: ", (xco+10), (yco-44), (width-20)/2, 19, - arm->posechannel, 0, 31, 0, 0, + arm->posechannel, 0, MAX_NAME, 0, 0, "Bone on which you want to check a constraint"); uiButSetFunc(but, check_armature_sensor, but, arm); but = uiDefBut(block, TEX, 1, "Cons: ", (xco+10)+(width-20)/2, (yco-44), (width-20)/2, 19, - arm->constraint, 0, 31, 0, 0, + arm->constraint, 0, MAX_NAME, 0, 0, "Name of the constraint you want to control"); uiButSetFunc(but, check_armature_sensor, but, arm); uiBlockEndAlign(block); @@ -1420,7 +1420,7 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short as= sens->data; uiDefBut(block, TEX, 1, "Act: ", xco+30,yco-44,width-60, 19, - as->name, 0, 31, 0, 0, "Actuator name, actuator active state modifications will be detected"); + as->name, 0, MAX_NAME, 0, 0, "Actuator name, actuator active state modifications will be detected"); yco-= ysize; break; } @@ -1513,13 +1513,13 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short if (raySens->mode & SENS_COLLISION_MATERIAL) { uiDefBut(block, TEX, 1, "Material:", xco + 10 + 0.20 * (width-20), yco-44, 0.8*(width-20), 19, - &raySens->matname, 0, 31, 0, 0, + &raySens->matname, 0, MAX_NAME, 0, 0, "Only look for Objects with this material"); } else { uiDefBut(block, TEX, 1, "Property:", xco + 10 + 0.20 * (width-20), yco-44, 0.8*(width-20), 19, - &raySens->propname, 0, 31, 0, 0, + &raySens->propname, 0, MAX_NAME, 0, 0, "Only look for Objects with this property"); } @@ -1557,7 +1557,7 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short /* line 2: Subject filter */ uiDefBut(block, TEX, 1, "Subject: ", (xco+10), (yco-44), (width-20), 19, - mes->subject, 0, 31, 0, 0, + mes->subject, 0, MAX_NAME, 0, 0, "Optional subject filter: only accept messages with this subject" ", or empty for all"); @@ -1683,7 +1683,7 @@ static short draw_controllerbuttons(bController *cont, uiBlock *block, short xco ec= cont->data; /* uiDefBut(block, BUT, 1, "Variables", xco,yco-24,80, 19, NULL, 0, 0, 0, 0, "Available variables for expression"); */ uiDefBut(block, TEX, 1, "Exp:", xco + 10 , yco-21, width-20, 19, - ec->str, 0, 127, 0, 0, + ec->str, 0, sizeof(ec->str), 0, 0, "Expression"); yco-= ysize; @@ -1704,7 +1704,7 @@ static short draw_controllerbuttons(bController *cont, uiBlock *block, short xco if(pc->mode==0) uiDefIDPoinBut(block, test_scriptpoin_but, ID_TXT, 1, "", xco+70,yco-23,width-74, 19, &pc->text, "Blender textblock to run as a script"); else { - uiDefBut(block, TEX, 1, "", xco+70,yco-23,(width-70)-25, 19, pc->module, 0, 63, 0, 0, "Module name and function to run e.g. \"someModule.main\". Internal texts and external python files can be used"); + uiDefBut(block, TEX, 1, "", xco+70,yco-23,(width-70)-25, 19, pc->module, 0, sizeof(pc->module), 0, 0, "Module name and function to run e.g. \"someModule.main\". Internal texts and external python files can be used"); uiDefButBitI(block, TOG, CONT_PY_DEBUG, B_REDR, "D", (xco+width)-25, yco-23, 19, 19, &pc->flag, 0, 0, 0, 0, "Continuously reload the module from disk for editing external modules without restarting"); } uiBlockEndAlign(block); @@ -2032,7 +2032,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo if(aa->type == ACT_ACTION_FROM_PROP) { - uiDefBut(block, TEX, 0, "Prop: ",xco+10, yco-44, width-20, 19, aa->name, 0.0, 31.0, 0, 0, "Use this property to define the Action position"); + uiDefBut(block, TEX, 0, "Prop: ",xco+10, yco-44, width-20, 19, aa->name, 0.0, MAX_NAME, 0, 0, "Use this property to define the Action position"); } else { @@ -2043,7 +2043,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo uiDefButS(block, NUM, 0, "Blendin: ", xco+10, yco-64, (width-20)/2, 19, &aa->blendin, 0.0, 32767, 0.0, 0.0, "Number of frames of motion blending"); uiDefButS(block, NUM, 0, "Priority: ", xco+10+(width-20)/2, yco-64, (width-20)/2, 19, &aa->priority, 0.0, 100.0, 0.0, 0.0, "Execution priority - lower numbers will override actions with higher numbers, With 2 or more actions at once, the overriding channels must be lower in the stack"); - uiDefBut(block, TEX, 0, "FrameProp: ",xco+10, yco-84, width-20, 19, aa->frameProp, 0.0, 31.0, 0, 0, "Assign the action's current frame number to this property"); + uiDefBut(block, TEX, 0, "FrameProp: ",xco+10, yco-84, width-20, 19, aa->frameProp, 0.0, MAX_NAME, 0, 0, "Assign the action's current frame number to this property"); #ifdef __NLA_ACTION_BY_MOTION_ACTUATOR @@ -2094,7 +2094,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo if(ia->type==ACT_IPO_FROM_PROP) { uiDefBut(block, TEX, 0, "Prop: ", xco+10, yco-44, width-80, 19, - ia->name, 0.0, 31.0, 0, 0, + ia->name, 0.0, MAX_NAME, 0, 0, "Use this property to define the Ipo position"); } else { @@ -2113,7 +2113,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo "Update IPO on all children Objects as well"); uiDefBut(block, TEX, 0, "FrameProp: ", xco+10, yco-64, width-20, 19, - ia->frameProp, 0.0, 31.0, 0, 0, + ia->frameProp, 0.0, MAX_NAME, 0, 0, "Assign the action's current frame number to this property"); yco-= ysize; @@ -2131,7 +2131,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo str= "Type%t|Assign%x0|Add %x1|Copy %x2|Toggle (bool/int/float/timer)%x3"; uiDefButI(block, MENU, B_REDR, str, xco+30,yco-24,width-60, 19, &pa->type, 0, 31, 0, 0, "Type"); - uiDefBut(block, TEX, 1, "Prop: ", xco+30,yco-44,width-60, 19, pa->name, 0, 31, 0, 0, "Property name"); + uiDefBut(block, TEX, 1, "Prop: ", xco+30,yco-44,width-60, 19, pa->name, 0, MAX_NAME, 0, 0, "Property name"); if(pa->type==ACT_PROP_TOGGLE) { @@ -2140,10 +2140,10 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo } else if(pa->type==ACT_PROP_COPY) { uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-64, (width-20)/2, 19, &(pa->ob), "Copy from this Object"); - uiDefBut(block, TEX, 1, "Prop: ", xco+10+(width-20)/2, yco-64, (width-20)/2, 19, pa->value, 0, 31, 0, 0, "Copy this property"); + uiDefBut(block, TEX, 1, "Prop: ", xco+10+(width-20)/2, yco-64, (width-20)/2, 19, pa->value, 0, MAX_NAME, 0, 0, "Copy this property"); } else { - uiDefBut(block, TEX, 1, "Value: ", xco+30,yco-64,width-60, 19, pa->value, 0, 31, 0, 0, "change with this value, use \"\" around strings"); + uiDefBut(block, TEX, 1, "Value: ", xco+30,yco-64,width-60, 19, pa->value, 0, MAX_NAME, 0, 0, "change with this value, use \"\" around strings"); } yco-= ysize; @@ -2175,7 +2175,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo char dummy_str[] = "Sound mode %t|Play Stop %x0|Play End %x1|Loop Stop %x2|" "Loop End %x3|Loop Ping Pong Stop %x5|Loop Ping Pong %x4"; uiDefBut(block, TEX, B_IDNAME, "SO:",xco+30,yco-22,wval-20,19, - ((ID *)sa->sound)->name+2, 0.0, 21.0, 0, 0, ""); + ((ID *)sa->sound)->name+2, 0.0, MAX_ID_NAME-2, 0, 0, ""); uiDefButS(block, MENU, 1, dummy_str,xco+10,yco-44,width-20, 19, &sa->type, 0.0, 0.0, 0, 0, ""); uiDefButF(block, NUM, 0, "Volume:", xco+10,yco-66,wval, 19, &sa->volume, @@ -2397,13 +2397,13 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo if (coa->flag & ACT_CONST_MATERIAL) { uiDefBut(block, TEX, 1, "Material:", xco + 50, yco-84, (width-60), 19, - coa->matprop, 0, 31, 0, 0, + coa->matprop, 0, MAX_NAME, 0, 0, "Ray detects only Objects with this material"); } else { uiDefBut(block, TEX, 1, "Property:", xco + 50, yco-84, (width-60), 19, - coa->matprop, 0, 31, 0, 0, + coa->matprop, 0, MAX_NAME, 0, 0, "Ray detect only Objects with this property"); } uiDefButBitS(block, TOG, ACT_CONST_PERMANENT, 0, "PER", xco+10, yco-103, 40, 19, @@ -2456,13 +2456,13 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo if (coa->flag & ACT_CONST_MATERIAL) { uiDefBut(block, TEX, 1, "Material:", xco + 50, yco-84, (width-60), 19, - coa->matprop, 0, 31, 0, 0, + coa->matprop, 0, MAX_NAME, 0, 0, "Ray detects only Objects with this material"); } else { uiDefBut(block, TEX, 1, "Property:", xco + 50, yco-84, (width-60), 19, - coa->matprop, 0, 31, 0, 0, + coa->matprop, 0, MAX_NAME, 0, 0, "Ray detect only Objects with this property"); } uiDefButBitS(block, TOG, ACT_CONST_PERMANENT, 0, "PER", xco+10, yco-103, 40, 19, @@ -2554,8 +2554,8 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo ysize = 48; glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefBut(block, TEX, 1, "File: ", xco+10, yco-44,width-20,19, &(gma->filename), 0, 63, 0, 0, "Load this blend file, use the \"//\" prefix for a path relative to the current blend file"); -// uiDefBut(block, TEX, 1, "Anim: ", xco+10, yco-64,width-20,19, &(gma->loadaniname), 0, 63, 0, 0, "Use this loadinganimation"); + uiDefBut(block, TEX, 1, "File: ", xco+10, yco-44,width-20,19, &(gma->filename), 0, sizeof(gma->filename), 0, 0, "Load this blend file, use the \"//\" prefix for a path relative to the current blend file"); +// uiDefBut(block, TEX, 1, "Anim: ", xco+10, yco-64,width-20,19, &(gma->loadaniname), 0, sizeof(gma->loadaniname), 0, 0, "Use this loadinganimation"); } /* else if (gma->type == ACT_GAME_START) { @@ -2563,8 +2563,8 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefBut(block, TEX, 1, "File: ", xco+10, yco-44,width-20,19, &(gma->filename), 0, 63, 0, 0, "Load this file"); - uiDefBut(block, TEX, 1, "Anim: ", xco+10, yco-64,width-20,19, &(gma->loadaniname), 0, 63, 0, 0, "Use this loadinganimation"); + uiDefBut(block, TEX, 1, "File: ", xco+10, yco-44,width-20,19, &(gma->filename), 0, sizeof(gma->filename), 0, 0, "Load this file"); + uiDefBut(block, TEX, 1, "Anim: ", xco+10, yco-64,width-20,19, &(gma->loadaniname), 0, sizeof(gma->loadaniname), 0, 0, "Use this loadinganimation"); } */ else if (ELEM4(gma->type, ACT_GAME_RESTART, ACT_GAME_QUIT, ACT_GAME_SAVECFG, ACT_GAME_LOADCFG)) { @@ -2592,11 +2592,11 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo uiDefButS(block, MENU, 1, str, xco+20, yco-24, width-40, 19, &ga->type, 0, 0, 0, 0, ""); if(ga->type==ACT_GROUP_SET) { - uiDefBut(block, TEX, 0, "Key: ", xco+20, yco-44, (width-10)/2, 19, ga->name, 0.0, 31.0, 0, 0, "This name defines groupkey to be set"); + uiDefBut(block, TEX, 0, "Key: ", xco+20, yco-44, (width-10)/2, 19, ga->name, 0.0, MAX_NAME, 0, 0, "This name defines groupkey to be set"); uiDefButI(block, NUM, 0, "Frame:", xco+20+(width-10)/2, yco-44, (width-70)/2, 19, &ga->sta, 0.0, 2500.0, 0, 0, "Set this frame"); } else if(ga->type==ACT_GROUP_FROM_PROP) { - uiDefBut(block, TEX, 0, "Prop: ", xco+20, yco-44, width-40, 19, ga->name, 0.0, 31.0, 0, 0, "Use this property to define the Group position"); + uiDefBut(block, TEX, 0, "Prop: ", xco+20, yco-44, width-40, 19, ga->name, 0.0, MAX_NAME, 0, 0, "Use this property to define the Group position"); } else { uiDefButI(block, NUM, 0, "State", xco+20, yco-44, (width-40)/2, 19, &ga->sta, 0.0, 2500.0, 0, 0, "Start frame"); @@ -2698,7 +2698,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo /* 3. property */ uiDefBut(block, TEX, 1, "Property:", (xco+10), yco-44, (width-20), 19, - &randAct->propname, 0, 31, 0, 0, + &randAct->propname, 0, MAX_NAME, 0, 0, "Assign the random value to this property"); /*4. and 5. arguments for the distribution*/ @@ -2789,13 +2789,13 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo /* line 1: To */ uiDefBut(block, TEX, 1, "To: ", (xco+10), (yco-(myline++*24)), (width-20), 19, - &ma->toPropName, 0, 31, 0, 0, + &ma->toPropName, 0, MAX_NAME, 0, 0, "Optional send message to objects with this name only, or empty to broadcast"); /* line 2: Message Subject */ uiDefBut(block, TEX, 1, "Subject: ", (xco+10), (yco-(myline++*24)), (width-20), 19, - &ma->subject, 0, 31, 0, 0, + &ma->subject, 0, MAX_NAME, 0, 0, "Optional message subject. This is what can be filtered on"); /* line 3: Text/Property */ @@ -2809,14 +2809,14 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo /* line 3: Message Body */ uiDefBut(block, TEX, 1, "Body: ", (xco+10+(0.20*(width-20))),(yco-(myline++*24)),(0.8*(width-20)),19, - &ma->body, 0, 31, 0, 0, + &ma->body, 0, MAX_NAME, 0, 0, "Optional message body Text"); } else { /* line 3: Property body (set by property) */ uiDefBut(block, TEX, 1, "Propname: ", (xco+10+(0.20*(width-20))),(yco-(myline++*24)),(0.8*(width-20)),19, - &ma->body, 0, 31, 0, 0, + &ma->body, 0, MAX_NAME, 0, 0, "The message body will be set by the Property Value"); } @@ -2923,12 +2923,12 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo uiBlockBeginAlign(block); but = uiDefBut(block, TEX, 1, "Bone: ", (xco+5), (yco-44), (width-10)/2, 19, - armAct->posechannel, 0, 31, 0, 0, + armAct->posechannel, 0, MAX_NAME, 0, 0, "Bone on which the constraint is defined"); uiButSetFunc(but, check_armature_actuator, but, armAct); but = uiDefBut(block, TEX, 1, "Cons: ", (xco+5)+(width-10)/2, (yco-44), (width-10)/2, 19, - armAct->constraint, 0, 31, 0, 0, + armAct->constraint, 0, MAX_NAME, 0, 0, "Name of the constraint you want to control"); uiButSetFunc(but, check_armature_actuator, but, armAct); uiBlockEndAlign(block); @@ -2999,7 +2999,7 @@ static uiBlock *sensor_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) uiBlock *block; int yco=0; - block= uiBeginBlock(C, ar, "filemenu", UI_EMBOSSP); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSSP); uiBlockSetButmFunc(block, do_sensor_menu, NULL); uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); @@ -3048,7 +3048,7 @@ static uiBlock *controller_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) uiBlock *block; int yco=0; - block= uiBeginBlock(C, ar, "filemenu", UI_EMBOSSP); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSSP); uiBlockSetButmFunc(block, do_controller_menu, NULL); uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); @@ -3097,7 +3097,7 @@ static uiBlock *actuator_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) uiBlock *block; int xco=0; - block= uiBeginBlock(C, ar, "filemenu", UI_EMBOSSP); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSSP); uiBlockSetButmFunc(block, do_actuator_menu, NULL); uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); @@ -3143,7 +3143,7 @@ static uiBlock *controller_state_mask_menu(bContext *C, ARegion *ar, void *arg_c short yco = 12, xco = 0, stbit, offset; - block= uiBeginBlock(C, ar, "Controller state mask", UI_EMBOSS); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); /* use this for a fake extra empy space around the buttons */ uiDefBut(block, LABEL, 0, "", -5, -5, 200, 34, NULL, 0, 0, 0, 0, ""); @@ -3191,7 +3191,7 @@ static uiBlock *object_state_mask_menu(bContext *C, ARegion *ar, void *arg_obj) uiBlock *block; short xco = 0; - block= uiBeginBlock(C, ar, "obstatemenu", UI_EMBOSSP); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSSP); uiBlockSetButmFunc(block, do_object_state_menu, arg_obj); uiDefBut(block, BUTM, 1, "Set all bits", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); @@ -3580,7 +3580,7 @@ static void draw_controller_header(uiLayout *layout, PointerRNA *ptr, int xco, i bController *cont= (bController *)ptr->data; char state[3]; - sprintf(state, "%d", RNA_int_get(ptr, "states")); + BLI_snprintf(state, sizeof(state), "%d", RNA_int_get(ptr, "states")); box= uiLayoutBox(layout); row= uiLayoutRow(box, 0); @@ -4488,7 +4488,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) uiLayout *layout, *row, *box; uiBlock *block; uiBut *but; - char name[32]; + char uiblockstr[32]; short a, count; int xco, yco, width; @@ -4497,8 +4497,8 @@ static void logic_buttons_new(bContext *C, ARegion *ar) RNA_pointer_create(NULL, &RNA_SpaceLogicEditor, slogic, &logic_ptr); idar= get_selected_and_linked_obs(C, &count, slogic->scaflag); - sprintf(name, "buttonswin %p", (void *)ar); - block= uiBeginBlock(C, ar, name, UI_EMBOSS); + BLI_snprintf(uiblockstr, sizeof(uiblockstr), "buttonswin %p", (void *)ar); + block= uiBeginBlock(C, ar, uiblockstr, UI_EMBOSS); uiBlockSetHandleFunc(block, do_logic_buts, NULL); /* loop over all objects and set visible/linked flags for the logic bricks */ @@ -4802,7 +4802,7 @@ void logic_buttons(bContext *C, ARegion *ar) int a, iact, stbit, offset; int xco, yco, width, ycoo; short count; - char name[32]; + char numstr[32]; /* pin is a bool used for actuator and sensor drawing with states * pin so changing states dosnt hide the logic brick */ char pin; @@ -4815,8 +4815,8 @@ void logic_buttons(bContext *C, ARegion *ar) if(ob==NULL) return; // uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); - sprintf(name, "buttonswin %p", (void *)ar); - block= uiBeginBlock(C, ar, name, UI_EMBOSS); + BLI_snprintf(numstr, sizeof(numstr), "buttonswin %p", (void *)ar); + block= uiBeginBlock(C, ar, numstr, UI_EMBOSS); uiBlockSetHandleFunc(block, do_logic_buts, NULL); RNA_pointer_create(NULL, &RNA_SpaceLogicEditor, slogic, &logic_ptr); @@ -4932,13 +4932,13 @@ void logic_buttons(bContext *C, ARegion *ar) uiDefIconButBitS(block, ICONTOG, CONT_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, UI_UNIT_Y, &cont->flag, 0, 0, 0, 0, "Controller settings"); uiDefIconButBitS(block, TOG, CONT_PRIO, B_REDR, ICON_BOOKMARKS, (short)(xco+width-66), yco, 22, UI_UNIT_Y, &cont->flag, 0, 0, 0, 0, "Mark controller for execution before all non-marked controllers (good for startup scripts)"); - sprintf(name, "%d", first_bit(cont->state_mask)+1); - uiDefBlockBut(block, controller_state_mask_menu, cont, name, (short)(xco+width-44), yco, 22, UI_UNIT_Y, "Set controller state index (from 1 to 30)"); + sprintf(numstr, "%d", first_bit(cont->state_mask)+1); + uiDefBlockBut(block, controller_state_mask_menu, cont, numstr, (short)(xco+width-44), yco, 22, UI_UNIT_Y, "Set controller state index (from 1 to 30)"); if(cont->flag & CONT_SHOW) { cont->otype= cont->type; uiDefButS(block, MENU, B_CHANGE_CONT, controller_pup(),(short)(xco+22), yco, 70, UI_UNIT_Y, &cont->type, 0, 0, 0, 0, "Controller type"); - but= uiDefBut(block, TEX, 1, "", (short)(xco+92), yco, (short)(width-158), UI_UNIT_Y, cont->name, 0, 31, 0, 0, "Controller name"); + but= uiDefBut(block, TEX, 1, "", (short)(xco+92), yco, (short)(width-158), UI_UNIT_Y, cont->name, 0, MAX_NAME, 0, 0, "Controller name"); uiButSetFunc(but, make_unique_prop_names_cb, cont->name, (void*) 0); ycoo= yco; @@ -5030,7 +5030,7 @@ void logic_buttons(bContext *C, ARegion *ar) if(sens->flag & SENS_SHOW) { uiDefButS(block, MENU, B_CHANGE_SENS, sensor_pup(), (short)(xco+22), yco, 80, UI_UNIT_Y, &sens->type, 0, 0, 0, 0, "Sensor type"); - but= uiDefBut(block, TEX, 1, "", (short)(xco+102), yco, (short)(width-(pin?146:124)), UI_UNIT_Y, sens->name, 0, 31, 0, 0, "Sensor name"); + but= uiDefBut(block, TEX, 1, "", (short)(xco+102), yco, (short)(width-(pin?146:124)), UI_UNIT_Y, sens->name, 0, MAX_NAME, 0, 0, "Sensor name"); uiButSetFunc(but, make_unique_prop_names_cb, sens->name, (void*) 0); sens->otype= sens->type; @@ -5042,7 +5042,7 @@ void logic_buttons(bContext *C, ARegion *ar) glRecti(xco+22, yco, xco+width-22,yco+19); but= uiDefBut(block, LABEL, 0, sensor_name(sens->type), (short)(xco+22), yco, 80, UI_UNIT_Y, sens, 0, 0, 0, 0, ""); //uiButSetFunc(but, old_sca_move_sensor, sens, NULL); - but= uiDefBut(block, LABEL, 0, sens->name, (short)(xco+102), yco, (short)(width-(pin?146:124)), UI_UNIT_Y, sens, 0, 31, 0, 0, ""); + but= uiDefBut(block, LABEL, 0, sens->name, (short)(xco+102), yco, (short)(width-(pin?146:124)), UI_UNIT_Y, sens, 0, MAX_NAME, 0, 0, ""); //uiButSetFunc(but, old_sca_move_sensor, sens, NULL); uiBlockBeginAlign(block); @@ -5108,7 +5108,7 @@ void logic_buttons(bContext *C, ARegion *ar) if(act->flag & ACT_SHOW) { act->otype= act->type; uiDefButS(block, MENU, B_CHANGE_ACT, actuator_pup(ob), (short)(xco+22), yco, 90, UI_UNIT_Y, &act->type, 0, 0, 0, 0, "Actuator type"); - but= uiDefBut(block, TEX, 1, "", (short)(xco+112), yco, (short)(width-(pin?156:134)), UI_UNIT_Y, act->name, 0, 31, 0, 0, "Actuator name"); + but= uiDefBut(block, TEX, 1, "", (short)(xco+112), yco, (short)(width-(pin?156:134)), UI_UNIT_Y, act->name, 0, MAX_NAME, 0, 0, "Actuator name"); uiButSetFunc(but, make_unique_prop_names_cb, act->name, (void*) 0); ycoo= yco; diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 6af43e7618d..d7a1053f3c1 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -514,7 +514,7 @@ static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, V { const float ytol = 1.0f; /* small offset to vertical positioning of text, for legibility */ const char col[4] = {220, 220, 220, 255}; /* light grey */ - char str[32] = ""; + char numstr[32] = ""; /* Always draw times above the strip, whereas sequencer drew below + above. @@ -524,12 +524,12 @@ static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, V * while also preserving some accuracy, since we do use floats */ /* start frame */ - BLI_snprintf(str, sizeof(str), "%.1f", strip->start); - UI_view2d_text_cache_add(v2d, strip->start-1.0f, ymaxc+ytol, str, col); + BLI_snprintf(numstr, sizeof(numstr), "%.1f", strip->start); + UI_view2d_text_cache_add(v2d, strip->start-1.0f, ymaxc+ytol, numstr, col); /* end frame */ - BLI_snprintf(str, sizeof(str), "%.1f", strip->end); - UI_view2d_text_cache_add(v2d, strip->end, ymaxc+ytol, str, col); + BLI_snprintf(numstr, sizeof(numstr), "%.1f", strip->end); + UI_view2d_text_cache_add(v2d, strip->end, ymaxc+ytol, numstr, col); } /* ---------------------- */ @@ -715,7 +715,7 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie } sel = SEL_NLT(nlt); - strcpy(name, nlt->name); + BLI_strncpy(name, nlt->name, sizeof(name)); // draw manually still doDraw= 1; @@ -958,7 +958,7 @@ void draw_nla_channel_list (bContext *C, bAnimContext *ac, ARegion *ar) draw_nla_channel_list_gl(ac, &anim_data, v2d, y); } { /* second pass: UI widgets */ - uiBlock *block= uiBeginBlock(C, ar, "NLA channel buttons", UI_EMBOSS); + uiBlock *block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); size_t channel_index = 0; y= (float)(-NLACHANNEL_HEIGHT(snla)); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 6c0cc15559c..3f8d9a75244 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -132,7 +132,7 @@ static uiBlock *socket_component_menu(bContext *C, ARegion *ar, void *args_v) uiBlock *block; uiLayout *layout; - block= uiBeginBlock(C, ar, "socket menu", UI_EMBOSS); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN); layout= uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, args->x, args->y+2, args->width, NODE_DY, UI_GetStyle()), 0); @@ -631,7 +631,7 @@ static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket * if (sock->flag & SOCK_DYNAMIC) { bt = uiDefBut(gnode->block, TEX, 0, "", sock->locx+xoffset, sock->locy+1+yoffset, 72, NODE_DY, - sock->name, 0, 31, 0, 0, ""); + sock->name, 0, sizeof(sock->name), 0, 0, ""); if (in_out==SOCK_IN) uiButSetFunc(bt, update_group_input_cb, snode, ngroup); else @@ -640,7 +640,7 @@ static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket * else { uiDefBut(gnode->block, LABEL, 0, sock->name, sock->locx+xoffset, sock->locy+1+yoffset, 72, NODE_DY, - NULL, 0, 31, 0, 0, ""); + NULL, 0, sizeof(sock->name), 0, 0, ""); } } @@ -1203,10 +1203,10 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA * /* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */ Scene *scene= CTX_data_scene(C); ImageUser *iuser= node->storage; - char tstr[32]; + char numstr[32]; const int framenr= BKE_image_user_get_frame(iuser, CFRA, 0); - BLI_snprintf(tstr, sizeof(tstr), "Frame: %d", framenr); - uiItemL(layout, tstr, ICON_NONE); + BLI_snprintf(numstr, sizeof(numstr), "Frame: %d", framenr); + uiItemL(layout, numstr, ICON_NONE); } if (ELEM(source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) { @@ -2308,7 +2308,7 @@ void draw_nodespace_color_info(ARegion *ar, int color_manage, int channels, int BLF_size(blf_mono_font, 11, 72); glColor3ub(255, 255, 255); - sprintf(str, "X:%-4d Y:%-4d |", x, y); + BLI_snprintf(str, sizeof(str), "X:%-4d Y:%-4d |", x, y); // UI_DrawString(6, 6, str); // works ok but fixed width is nicer. BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); @@ -2317,14 +2317,14 @@ void draw_nodespace_color_info(ARegion *ar, int color_manage, int channels, int #if 0 /* XXX no Z value in compo backdrop atm */ if(zp) { glColor3ub(255, 255, 255); - sprintf(str, " Z:%-.4f |", 0.5f+0.5f*(((float)*zp)/(float)0x7fffffff)); + BLI_snprintf(str, sizeof(str), " Z:%-.4f |", 0.5f+0.5f*(((float)*zp)/(float)0x7fffffff)); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); } if(zpf) { glColor3ub(255, 255, 255); - sprintf(str, " Z:%-.3f |", *zpf); + BLI_snprintf(str, sizeof(str), " Z:%-.3f |", *zpf); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); @@ -2334,33 +2334,33 @@ void draw_nodespace_color_info(ARegion *ar, int color_manage, int channels, int if(channels >= 3) { glColor3ubv(red); if (fp) - sprintf(str, " R:%-.4f", fp[0]); + BLI_snprintf(str, sizeof(str), " R:%-.4f", fp[0]); else if (cp) - sprintf(str, " R:%-3d", cp[0]); + BLI_snprintf(str, sizeof(str), " R:%-3d", cp[0]); else - sprintf(str, " R:-"); + BLI_snprintf(str, sizeof(str), " R:-"); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); glColor3ubv(green); if (fp) - sprintf(str, " G:%-.4f", fp[1]); + BLI_snprintf(str, sizeof(str), " G:%-.4f", fp[1]); else if (cp) - sprintf(str, " G:%-3d", cp[1]); + BLI_snprintf(str, sizeof(str), " G:%-3d", cp[1]); else - sprintf(str, " G:-"); + BLI_snprintf(str, sizeof(str), " G:-"); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); glColor3ubv(blue); if (fp) - sprintf(str, " B:%-.4f", fp[2]); + BLI_snprintf(str, sizeof(str), " B:%-.4f", fp[2]); else if (cp) - sprintf(str, " B:%-3d", cp[2]); + BLI_snprintf(str, sizeof(str), " B:%-3d", cp[2]); else - sprintf(str, " B:-"); + BLI_snprintf(str, sizeof(str), " B:-"); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); @@ -2368,11 +2368,11 @@ void draw_nodespace_color_info(ARegion *ar, int color_manage, int channels, int if(channels == 4) { glColor3ub(255, 255, 255); if (fp) - sprintf(str, " A:%-.4f", fp[3]); + BLI_snprintf(str, sizeof(str), " A:%-.4f", fp[3]); else if (cp) - sprintf(str, " A:%-3d", cp[3]); + BLI_snprintf(str, sizeof(str), " A:%-3d", cp[3]); else - sprintf(str, "- "); + BLI_snprintf(str, sizeof(str), "- "); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); @@ -2440,12 +2440,12 @@ void draw_nodespace_color_info(ARegion *ar, int color_manage, int channels, int rgb_to_yuv((float)cp[0]/255.0f, (float)cp[0]/255.0f, (float)cp[0]/255.0f, &lum, &u, &v); } - sprintf(str, "V:%-.4f", val); + BLI_snprintf(str, sizeof(str), "V:%-.4f", val); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); - sprintf(str, " L:%-.4f", lum); + BLI_snprintf(str, sizeof(str), " L:%-.4f", lum); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); @@ -2460,22 +2460,22 @@ void draw_nodespace_color_info(ARegion *ar, int color_manage, int channels, int rgb_to_yuv((float)cp[0]/255.0f, (float)cp[1]/255.0f, (float)cp[2]/255.0f, &lum, &u, &v); } - sprintf(str, "H:%-.4f", hue); + BLI_snprintf(str, sizeof(str), "H:%-.4f", hue); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); - sprintf(str, " S:%-.4f", sat); + BLI_snprintf(str, sizeof(str), " S:%-.4f", sat); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); - sprintf(str, " V:%-.4f", val); + BLI_snprintf(str, sizeof(str), " V:%-.4f", val); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); - sprintf(str, " L:%-.4f", lum); + BLI_snprintf(str, sizeof(str), " L:%-.4f", lum); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index da7f22b2030..a82ea9e9046 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -195,18 +195,18 @@ static void node_scaling_widget(int color_id, float aspect, float xmin, float ym static void node_uiblocks_init(const bContext *C, bNodeTree *ntree) { bNode *node; - char str[32]; + char uiblockstr[32]; /* add node uiBlocks in drawing order - prevents events going to overlapping nodes */ - for(node= ntree->nodes.first; node; node=node->next) { - /* ui block */ - sprintf(str, "node buttons %p", (void *)node); - node->block= uiBeginBlock(C, CTX_wm_region(C), str, UI_EMBOSS); - uiBlockSetHandleFunc(node->block, do_node_internal_buttons, node); - - /* this cancels events for background nodes */ - uiBlockSetFlag(node->block, UI_BLOCK_CLIP_EVENTS); + for (node= ntree->nodes.first; node; node= node->next) { + /* ui block */ + BLI_snprintf(uiblockstr, sizeof(uiblockstr), "node buttons %p", (void *)node); + node->block= uiBeginBlock(C, CTX_wm_region(C), uiblockstr, UI_EMBOSS); + uiBlockSetHandleFunc(node->block, do_node_internal_buttons, node); + + /* this cancels events for background nodes */ + uiBlockSetFlag(node->block, UI_BLOCK_CLIP_EVENTS); } } @@ -673,7 +673,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN BLI_strncpy(showname, nodeLabel(node), sizeof(showname)); //if(node->flag & NODE_MUTED) - // sprintf(showname, "[%s]", showname); + // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); // XXX - dont print into self! uiDefBut(node->block, LABEL, 0, showname, (short)(rct->xmin+15), (short)(rct->ymax-NODE_DY), (int)(iconofs - rct->xmin-18.0f), NODE_DY, NULL, 0, 0, 0, 0, ""); @@ -835,7 +835,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b BLI_strncpy(showname, nodeLabel(node), sizeof(showname)); //if(node->flag & NODE_MUTED) - // sprintf(showname, "[%s]", showname); + // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); // XXX - dont print into self! uiDefBut(node->block, LABEL, 0, showname, (short)(rct->xmin+15), (short)(centy-10), (int)(rct->xmax - rct->xmin-18.0f -12.0f), NODE_DY, NULL, 0, 0, 0, 0, ""); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 1fe754466f4..3523e6bd9ab 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -751,7 +751,7 @@ static int edit_node_poll(bContext *C) static void edit_node_properties(wmOperatorType *ot) { /* XXX could node be a context pointer? */ - RNA_def_string(ot->srna, "node", "", 32, "Node", ""); + RNA_def_string(ot->srna, "node", "", MAX_NAME, "Node", ""); RNA_def_int(ot->srna, "socket", 0, 0, MAX_SOCKET, "Socket", "", 0, MAX_SOCKET); RNA_def_enum(ot->srna, "in_out", socket_in_out_items, SOCK_IN, "Socket Side", ""); } @@ -779,7 +779,7 @@ static void edit_node_properties_get(wmOperator *op, bNodeTree *ntree, bNode **r { bNode *node; bNodeSocket *sock=NULL; - char nodename[32]; + char nodename[MAX_NAME]; int sockindex; int in_out; @@ -889,7 +889,7 @@ static int node_group_socket_add_exec(bContext *C, wmOperator *op) { SpaceNode *snode = CTX_wm_space_node(C); int in_out= -1; - char name[32]= ""; + char name[MAX_NAME]= ""; int type= SOCK_FLOAT; bNodeTree *ngroup= snode->edittree; /* bNodeSocket *sock; */ /* UNUSED */ @@ -932,7 +932,7 @@ void NODE_OT_group_socket_add(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; RNA_def_enum(ot->srna, "in_out", socket_in_out_items, SOCK_IN, "Socket Type", "Input or Output"); - RNA_def_string(ot->srna, "name", "", 32, "Name", "Group socket name"); + RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Group socket name"); RNA_def_enum(ot->srna, "type", node_socket_type_items, SOCK_FLOAT, "Type", "Type of the group socket"); } @@ -3451,7 +3451,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op) } else if(RNA_property_is_set(op->ptr, "name")) { - char name[32]; + char name[MAX_ID_NAME-2]; RNA_string_get(op->ptr, "name", name); ima= (Image *)find_id("IM", name); @@ -3517,7 +3517,7 @@ void NODE_OT_add_file(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH); //XXX TODO, relative_path - RNA_def_string(ot->srna, "name", "Image", 24, "Name", "Datablock name to assign"); + RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME-2, "Name", "Datablock name to assign"); } /********************** New node tree operator *********************/ diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index f3bab197b3c..71cb83ad231 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -1649,7 +1649,7 @@ void draw_outliner(const bContext *C) /* draw outliner stuff (background, hierachy lines and names) */ outliner_back(ar); - block= uiBeginBlock(C, ar, "outliner buttons", UI_EMBOSS); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); outliner_draw_tree((bContext *)C, block, scene, ar, soops); if(ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) { diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 9b1bd1d7b31..0ccbf9127c6 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -749,7 +749,7 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so TreeElement *last_find; TreeStoreElem *tselem; int ytop, xdelta, prevFound=0; - char name[32]; + char name[sizeof(soops->search_string)]; /* get last found tree-element based on stored search_tse */ last_find= outliner_find_tse(soops, &soops->search_tse); @@ -803,7 +803,7 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so /* store selection */ soops->search_tse= *tselem; - BLI_strncpy(soops->search_string, name, 33); + BLI_strncpy(soops->search_string, name, sizeof(soops->search_string)); soops->search_flags= flags; /* redraw */ diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 084e48c0d6e..a45b493ffb3 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -1342,7 +1342,7 @@ static int outliner_filter_has_name(TreeElement *te, const char *name, int flags } else { char fn_name[sizeof(((struct SpaceOops *)NULL)->search_string) + 2]; - sprintf(fn_name, "*%s*", name); + BLI_snprintf(fn_name, sizeof(fn_name), "*%s*", name); found= fnmatch(fn_name, te->name, fn_flag)==0; } return found; diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 2b59a02deae..176ffd91e3b 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -328,7 +328,7 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, float pixelx, short dire float x1, x2, y1, y2; float handsize; float minhandle, maxhandle; - char str[32]; + char numstr[32]; unsigned int whichsel=0; x1= seq->startdisp; @@ -392,15 +392,15 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, float pixelx, short dire if(G.moving || (seq->flag & whichsel)) { const char col[4]= {255, 255, 255, 255}; if (direction == SEQ_LEFTHANDLE) { - sprintf(str, "%d", seq->startdisp); + BLI_snprintf(numstr, sizeof(numstr),"%d", seq->startdisp); x1= rx1; y1 -= 0.45f; } else { - sprintf(str, "%d", seq->enddisp - 1); + BLI_snprintf(numstr, sizeof(numstr), "%d", seq->enddisp - 1); x1= x2 - handsize*0.75f; y1= y2 + 0.05f; } - UI_view2d_text_cache_add(v2d, x1, y1, str, col); + UI_view2d_text_cache_add(v2d, x1, y1, numstr, col); } } diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 637c8fcdbcf..25b9c2f2864 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -75,7 +75,7 @@ static void text_font_end(SpaceText *UNUSED(st)) static int text_font_draw(SpaceText *UNUSED(st), int x, int y, char *str) { BLF_position(mono, x, y, 0); - BLF_draw(mono, str, 65535); /* XXX, use real length */ + BLF_draw(mono, str, BLF_DRAW_STR_DUMMY_MAX); return BLF_width(mono, str); } @@ -1766,7 +1766,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) else UI_ThemeColor(TH_TEXT); - sprintf(linenr, "%*d", st->linenrs_tot, i + linecount + 1); + BLI_snprintf(linenr, sizeof(linenr), "%*d", st->linenrs_tot, i + linecount + 1); /* itoa(i + linecount + 1, linenr, 10); */ /* not ansi-c :/ */ text_font_draw(st, TXT_OFFSET - 7, y, linenr); diff --git a/source/blender/editors/space_view3d/drawanimviz.c b/source/blender/editors/space_view3d/drawanimviz.c index 1784d949761..638bf5b41a7 100644 --- a/source/blender/editors/space_view3d/drawanimviz.c +++ b/source/blender/editors/space_view3d/drawanimviz.c @@ -218,23 +218,23 @@ void draw_motion_path_instance(Scene *scene, col[3]= 255; for (i=0, mpv=mpv_start; i < len; i+=stepsize, mpv+=stepsize) { - char str[32]; + char numstr[32]; float co[3]; /* only draw framenum if several consecutive highlighted points don't occur on same point */ if (i == 0) { - sprintf(str, "%d", (i+sfra)); + sprintf(numstr, "%d", (i+sfra)); mul_v3_m4v3(co, ob->imat, mpv->co); - view3d_cached_text_draw_add(co, str, 0, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, col); + view3d_cached_text_draw_add(co, numstr, 0, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, col); } else if ((i > stepsize) && (i < len-stepsize)) { bMotionPathVert *mpvP = (mpv - stepsize); bMotionPathVert *mpvN = (mpv + stepsize); if ((equals_v3v3(mpv->co, mpvP->co)==0) || (equals_v3v3(mpv->co, mpvN->co)==0)) { - sprintf(str, "%d", (sfra+i)); + sprintf(numstr, "%d", (sfra+i)); mul_v3_m4v3(co, ob->imat, mpv->co); - view3d_cached_text_draw_add(co, str, 0, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, col); + view3d_cached_text_draw_add(co, numstr, 0, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, col); } } } @@ -293,11 +293,11 @@ void draw_motion_path_instance(Scene *scene, float mframe= (float)(sfra + i); if (BLI_dlrbTree_search_exact(&keys, compare_ak_cfraPtr, &mframe)) { - char str[32]; + char numstr[32]; - sprintf(str, "%d", (sfra+i)); + sprintf(numstr, "%d", (sfra+i)); mul_v3_m4v3(co, ob->imat, mpv->co); - view3d_cached_text_draw_add(co, str, 0, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, col); + view3d_cached_text_draw_add(co, numstr, 0, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, col); } } } diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 8e65fc5a15c..f2c8fafb8b8 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -576,7 +576,7 @@ static int draw_em_tf_mapped__set_draw(void *userData, int index) } } -static int wpaint__setSolidDrawOptions(void *userData, int index, int *drawSmooth_r) +static int wpaint__setSolidDrawOptions_material(void *userData, int index, int *drawSmooth_r) { Mesh *me = (Mesh*)userData; @@ -591,6 +591,16 @@ static int wpaint__setSolidDrawOptions(void *userData, int index, int *drawSmoot return 1; } +/* when face select is on, use face hidden flag */ +static int wpaint__setSolidDrawOptions_facemask(void *userData, int index, int *drawSmooth_r) +{ + Mesh *me = (Mesh*)userData; + MFace *mface = &me->mface[index]; + if (mface->flag & ME_HIDE) return 0; + *drawSmooth_r = 1; + return 1; +} + static void draw_mesh_text(Scene *scene, Object *ob, int glsl) { Mesh *me = ob->data; @@ -729,7 +739,7 @@ void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec } else if(draw_flags & DRAW_FACE_SELECT) { if(ob->mode & OB_MODE_WEIGHT_PAINT) - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, GPU_enable_material, NULL, me, 1); + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions_facemask, GPU_enable_material, NULL, me, 1); else dm->drawMappedFacesTex(dm, me->mpoly ? draw_tface_mapped__set_draw : NULL, NULL, me); } @@ -888,7 +898,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o /* weight paint mode exception */ int useColors= 1; - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions_material, GPU_enable_material, NULL, ob->data, useColors); } else { diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 5c33a138ad9..e3f65bbafdf 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2719,7 +2719,7 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS { Mesh *me= ob->data; float v1[3], v2[3], v3[3], vmid[3], fvec[3]; - char val[32]; /* Stores the measurement display text here */ + char numstr[32]; /* Stores the measurement display text here */ const char *conv_float; /* Use a float conversion matching the grid size */ unsigned char col[4]= {0, 0, 0, 255}; /* color of the text to draw */ float area; /* area of the face */ @@ -2760,11 +2760,11 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS mul_mat3_m4_v3(ob->obmat, v2); } if(unit->system) - bUnit_AsString(val, sizeof(val), len_v3v3(v1, v2)*unit->scale_length, 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); + bUnit_AsString(numstr, sizeof(numstr), len_v3v3(v1, v2)*unit->scale_length, 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); else - sprintf(val, conv_float, len_v3v3(v1, v2)); + sprintf(numstr, conv_float, len_v3v3(v1, v2)); - view3d_cached_text_draw_add(vmid, val, 0, V3D_CACHE_TEXT_ASCII, col); + view3d_cached_text_draw_add(vmid, numstr, 0, V3D_CACHE_TEXT_ASCII, col); } } } @@ -2775,15 +2775,15 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS BMFace *f; int n; -#define DRAW_EM_MEASURE_STATS_FACEAREA()\ - if (BM_TestHFlag(f, BM_SELECT)) {\ - mul_v3_fl(vmid, 1.0/n);\ - if(unit->system)\ - bUnit_AsString(val, sizeof(val), area*unit->scale_length,\ - 3, unit->system, B_UNIT_LENGTH, do_split, FALSE);\ - else\ - sprintf(val, conv_float, area);\ - view3d_cached_text_draw_add(vmid, val, 0, V3D_CACHE_TEXT_ASCII, col);\ +#define DRAW_EM_MEASURE_STATS_FACEAREA() \ + if (BM_TestHFlag(f, BM_SELECT)) { \ + mul_v3_fl(vmid, 1.0/n); \ + if(unit->system) \ + bUnit_AsString(numstr, sizeof(numstr), area*unit->scale_length, \ + 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); \ + else \ + BLI_snprintf(numstr, sizeof(numstr), conv_float, area); \ + view3d_cached_text_draw_add(vmid, numstr, 0, V3D_CACHE_TEXT_ASCII, col); \ } UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEAREA, col); @@ -2851,11 +2851,12 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS mul_mat3_m4_v3(ob->obmat, v3); } - if(BM_TestHFlag(efa, BM_SELECT) || - (do_moving && BM_TestHFlag(loop->v, BM_SELECT))){ - sprintf(val,"%.3g", RAD2DEGF(angle_v3v3v3(v1, v2, v3))); + if ( (BM_TestHFlag(efa, BM_SELECT)) || + (do_moving && BM_TestHFlag(loop->v, BM_SELECT))) + { + BLI_snprintf(numstr, sizeof(numstr), "%.3g", RAD2DEGF(angle_v3v3v3(v1, v2, v3))); interp_v3_v3v3(fvec, vmid, v2, 0.8f); - view3d_cached_text_draw_add(fvec, val, 0, V3D_CACHE_TEXT_ASCII, col); + view3d_cached_text_draw_add(fvec, numstr, 0, V3D_CACHE_TEXT_ASCII, col); } } } @@ -2868,7 +2869,7 @@ static void draw_em_indices(BMEditMesh *em) BMFace *f; BMVert *v; int i; - char val[32]; + char numstr[32]; float pos[3]; unsigned char col[4]; @@ -2881,8 +2882,8 @@ static void draw_em_indices(BMEditMesh *em) UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col); BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) { if (BM_TestHFlag(v, BM_SELECT)) { - sprintf(val, "%d", i); - view3d_cached_text_draw_add(v->co, val, 0, V3D_CACHE_TEXT_ASCII, col); + sprintf(numstr, "%d", i); + view3d_cached_text_draw_add(v->co, numstr, 0, V3D_CACHE_TEXT_ASCII, col); } i++; } @@ -2893,9 +2894,9 @@ static void draw_em_indices(BMEditMesh *em) UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGELEN, col); BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { if (BM_TestHFlag(e, BM_SELECT)) { - sprintf(val, "%d", i); + sprintf(numstr, "%d", i); mid_v3_v3v3(pos, e->v1->co, e->v2->co); - view3d_cached_text_draw_add(pos, val, 0, V3D_CACHE_TEXT_ASCII, col); + view3d_cached_text_draw_add(pos, numstr, 0, V3D_CACHE_TEXT_ASCII, col); } i++; } @@ -2907,8 +2908,8 @@ static void draw_em_indices(BMEditMesh *em) BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) { if (BM_TestHFlag(f, BM_SELECT)) { BM_Compute_Face_CenterMean(bm, f, pos); - sprintf(val, "%d", i); - view3d_cached_text_draw_add(pos, val, 0, V3D_CACHE_TEXT_ASCII, col); + sprintf(numstr, "%d", i); + view3d_cached_text_draw_add(pos, numstr, 0, V3D_CACHE_TEXT_ASCII, col); } i++; } @@ -4115,7 +4116,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv int a, totpart, totpoint=0, totve=0, drawn, draw_as, totchild=0; int select=ob->flag&SELECT, create_cdata=0, need_v=0; GLint polygonmode[2]; - char val[32]; + char numstr[32]; unsigned char tcol[4]= {0, 0, 0, 255}; /* 1. */ @@ -4503,8 +4504,8 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv if((part->draw & PART_DRAW_NUM || part->draw & PART_DRAW_HEALTH) && (v3d->flag2 & V3D_RENDER_OVERRIDE)==0){ float vec_txt[3]; - char *val_pos= val; - val[0]= '\0'; + char *val_pos= numstr; + numstr[0]= '\0'; if(part->draw&PART_DRAW_NUM) { if(a < totpart && (part->draw & PART_DRAW_HEALTH) && (part->phystype==PART_PHYS_BOIDS)) { @@ -4523,7 +4524,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv /* in path drawing state.co is the end point */ /* use worldspace beause object matrix is already applied */ mul_v3_m4v3(vec_txt, ob->imat, state.co); - view3d_cached_text_draw_add(vec_txt, val, 10, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, tcol); + view3d_cached_text_draw_add(vec_txt, numstr, 10, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, tcol); } } } @@ -4612,10 +4613,10 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv for(a=0, pa=psys->particles; a<totpart; a++, pa++){ float vec_txt[3]; - sprintf(val, "%i", a); + BLI_snprintf(numstr, sizeof(numstr), "%i", a); /* use worldspace beause object matrix is already applied */ mul_v3_m4v3(vec_txt, ob->imat, cache[a]->co); - view3d_cached_text_draw_add(vec_txt, val, 10, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, tcol); + view3d_cached_text_draw_add(vec_txt, numstr, 10, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, tcol); } } } diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 391b344df01..951aa1a5ebd 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -1349,7 +1349,7 @@ static void view3d_panel_preview(bContext *C, ARegion *ar, short cntrl) // VIEW3 View3D *v3d= sa->spacedata.first; int ofsx, ofsy; - block= uiBeginBlock(C, ar, "view3d_panel_preview", UI_EMBOSS); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | UI_PNL_SCALE | cntrl); uiSetPanelHandler(VIEW3D_HANDLER_PREVIEW); // for close and esc diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 3b355177852..ad85ff6dea8 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -863,24 +863,24 @@ static void draw_selected_name(Scene *scene, Object *ob) } } if(name && markern) - sprintf(info, "(%d) %s %s <%s>", CFRA, ob->id.name+2, name, markern); + BLI_snprintf(info, sizeof(info), "(%d) %s %s <%s>", CFRA, ob->id.name+2, name, markern); else if(name) - sprintf(info, "(%d) %s %s", CFRA, ob->id.name+2, name); + BLI_snprintf(info, sizeof(info), "(%d) %s %s", CFRA, ob->id.name+2, name); else - sprintf(info, "(%d) %s", CFRA, ob->id.name+2); + BLI_snprintf(info, sizeof(info), "(%d) %s", CFRA, ob->id.name+2); } else if(ELEM3(ob->type, OB_MESH, OB_LATTICE, OB_CURVE)) { Key *key= NULL; KeyBlock *kb = NULL; - char shapes[75]; + char shapes[MAX_NAME + 10]; /* try to display active shapekey too */ - shapes[0] = 0; + shapes[0] = '\0'; key = ob_get_key(ob); if(key){ kb = BLI_findlink(&key->block, ob->shapenr-1); if(kb){ - sprintf(shapes, ": %s ", kb->name); + BLI_snprintf(shapes, sizeof(shapes), ": %s ", kb->name); if(ob->shapeflag == OB_SHAPE_LOCK){ strcat(shapes, " (Pinned)"); } @@ -888,16 +888,16 @@ static void draw_selected_name(Scene *scene, Object *ob) } if(markern) - sprintf(info, "(%d) %s %s <%s>", CFRA, ob->id.name+2, shapes, markern); + BLI_snprintf(info, sizeof(info), "(%d) %s %s <%s>", CFRA, ob->id.name+2, shapes, markern); else - sprintf(info, "(%d) %s %s", CFRA, ob->id.name+2, shapes); + BLI_snprintf(info, sizeof(info), "(%d) %s %s", CFRA, ob->id.name+2, shapes); } else { /* standard object */ if (markern) - sprintf(info, "(%d) %s <%s>", CFRA, ob->id.name+2, markern); + BLI_snprintf(info, sizeof(info), "(%d) %s <%s>", CFRA, ob->id.name+2, markern); else - sprintf(info, "(%d) %s", CFRA, ob->id.name+2); + BLI_snprintf(info, sizeof(info), "(%d) %s", CFRA, ob->id.name+2); } /* color depends on whether there is a keyframe */ @@ -909,9 +909,9 @@ static void draw_selected_name(Scene *scene, Object *ob) else { /* no object */ if (markern) - sprintf(info, "(%d) <%s>", CFRA, markern); + BLI_snprintf(info, sizeof(info), "(%d) <%s>", CFRA, markern); else - sprintf(info, "(%d)", CFRA); + BLI_snprintf(info, sizeof(info), "(%d)", CFRA); /* color is always white */ UI_ThemeColor(TH_TEXT_HI); @@ -920,7 +920,7 @@ static void draw_selected_name(Scene *scene, Object *ob) if (U.uiflag & USER_SHOW_ROTVIEWICON) offset = 14 + (U.rvisize * 2); - BLF_draw_default(offset, 10, 0.0f, info, sizeof(info)-1); + BLF_draw_default(offset, 10, 0.0f, info, sizeof(info)); } static void view3d_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, rctf *viewborder_r, short no_shift, short no_zoom) @@ -2623,7 +2623,7 @@ static void draw_viewport_fps(Scene *scene, ARegion *ar) BLI_snprintf(printable, sizeof(printable), "fps: %i", (int)(fps+0.5f)); } - BLF_draw_default_ascii(22, ar->winy-17, 0.0f, printable, sizeof(printable)-1); + BLF_draw_default_ascii(22, ar->winy-17, 0.0f, printable, sizeof(printable)); } static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar) @@ -2890,14 +2890,15 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha draw_viewport_name(ar, v3d); } if (grid_unit) { /* draw below the viewport name */ - char tstr[32]= ""; + char numstr[32]= ""; UI_ThemeColor(TH_TEXT_HI); if(v3d->grid != 1.0f) { - BLI_snprintf(tstr, sizeof(tstr), "%s x %.4g", grid_unit, v3d->grid); + BLI_snprintf(numstr, sizeof(numstr), "%s x %.4g", grid_unit, v3d->grid); } - BLF_draw_default_ascii(22, ar->winy-(USER_SHOW_VIEWPORTNAME?40:20), 0.0f, tstr[0]?tstr : grid_unit, sizeof(tstr)); /* XXX, use real length */ + BLF_draw_default_ascii(22, ar->winy-(USER_SHOW_VIEWPORTNAME?40:20), 0.0f, + numstr[0] ? numstr : grid_unit, sizeof(numstr)); } } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index fa970f7f9d8..6e591a714e4 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2960,7 +2960,7 @@ static int background_image_add_invoke(bContext *C, wmOperator *op, wmEvent *UNU View3D *v3d= CTX_wm_view3d(C); Image *ima= NULL; BGpic *bgpic; - char name[32]; + char name[MAX_ID_NAME-2]; /* check input variables */ if(RNA_property_is_set(op->ptr, "filepath")) { @@ -3007,7 +3007,7 @@ void VIEW3D_OT_background_image_add(wmOperatorType *ot) ot->flag = 0; /* properties */ - RNA_def_string(ot->srna, "name", "Image", 24, "Name", "Image name to assign"); + RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME-2, "Name", "Image name to assign"); RNA_def_string(ot->srna, "filepath", "Path", FILE_MAX, "Filepath", "Path to image file"); } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 2ac7a520322..8a021922aa7 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -2563,9 +2563,9 @@ static void headerResize(TransInfo *t, float vec[3], char *str) outputNumInput(&(t->num), tvec); } else { - sprintf(&tvec[0], "%.4f", vec[0]); - sprintf(&tvec[20], "%.4f", vec[1]); - sprintf(&tvec[40], "%.4f", vec[2]); + BLI_snprintf(&tvec[0], 20, "%.4f", vec[0]); + BLI_snprintf(&tvec[20], 20, "%.4f", vec[1]); + BLI_snprintf(&tvec[40], 20, "%.4f", vec[2]); } if (t->con.mode & CON_APPLY) { diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 44aaca6ff3f..090b12e401e 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -293,7 +293,7 @@ typedef struct TransInfo { char *undostr; /* if set, uses this string for undo */ float spacemtx[3][3]; /* orientation matrix of the current space */ - char spacename[32]; /* name of the current space */ + char spacename[64]; /* name of the current space, MAX_NAME */ struct Object *poseobj; /* if t->flag & T_POSE, this denotes pose object */ diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index b88e57e1861..bd34477c13f 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -59,6 +59,7 @@ #include "BLI_math.h" #include "BLI_utildefines.h" +#include "BLI_string.h" //#include "blendef.h" // @@ -552,7 +553,7 @@ static void applyObjectConstraintRot(TransInfo *t, TransData *td, float vec[3], void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[]) { - strncpy(t->con.text + 1, text, 48); + BLI_strncpy(t->con.text + 1, text, sizeof(t->con.text) - 1); copy_m3_m3(t->con.mtx, space); t->con.mode = mode; getConstraintMatrix(t); @@ -579,7 +580,7 @@ void setLocalConstraint(TransInfo *t, int mode, const char text[]) setConstraint(t, t->data->axismtx, mode, text); } else { - strncpy(t->con.text + 1, text, 48); + BLI_strncpy(t->con.text + 1, text, sizeof(t->con.text) - 1); copy_m3_m3(t->con.mtx, t->data->axismtx); t->con.mode = mode; getConstraintMatrix(t); @@ -598,7 +599,7 @@ void setLocalConstraint(TransInfo *t, int mode, const char text[]) /* Set the constraint according to the user defined orientation - ftext is a format string passed to sprintf. It will add the name of + ftext is a format string passed to BLI_snprintf. It will add the name of the orientation where %s is (logically). */ void setUserConstraint(TransInfo *t, short orientation, int mode, const char ftext[]) @@ -609,28 +610,28 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char fte case V3D_MANIP_GLOBAL: { float mtx[3][3]= MAT3_UNITY; - sprintf(text, ftext, "global"); + BLI_snprintf(text, sizeof(text), ftext, "global"); setConstraint(t, mtx, mode, text); } break; case V3D_MANIP_LOCAL: - sprintf(text, ftext, "local"); + BLI_snprintf(text, sizeof(text), ftext, "local"); setLocalConstraint(t, mode, text); break; case V3D_MANIP_NORMAL: - sprintf(text, ftext, "normal"); + BLI_snprintf(text, sizeof(text), ftext, "normal"); setConstraint(t, t->spacemtx, mode, text); break; case V3D_MANIP_VIEW: - sprintf(text, ftext, "view"); + BLI_snprintf(text, sizeof(text), ftext, "view"); setConstraint(t, t->spacemtx, mode, text); break; case V3D_MANIP_GIMBAL: - sprintf(text, ftext, "gimbal"); + BLI_snprintf(text, sizeof(text), ftext, "gimbal"); setConstraint(t, t->spacemtx, mode, text); break; default: /* V3D_MANIP_CUSTOM */ - sprintf(text, ftext, t->spacename); + BLI_snprintf(text, sizeof(text), ftext, t->spacename); setConstraint(t, t->spacemtx, mode, text); break; } @@ -874,11 +875,11 @@ static void setNearestAxis2d(TransInfo *t) /* no correction needed... just use whichever one is lower */ if ( abs(t->mval[0]-t->con.imval[0]) < abs(t->mval[1]-t->con.imval[1]) ) { t->con.mode |= CON_AXIS1; - sprintf(t->con.text, " along Y axis"); + BLI_snprintf(t->con.text, sizeof(t->con.text), " along Y axis"); } else { t->con.mode |= CON_AXIS0; - sprintf(t->con.text, " along X axis"); + BLI_snprintf(t->con.text, sizeof(t->con.text), " along X axis"); } } @@ -929,31 +930,31 @@ static void setNearestAxis3d(TransInfo *t) if (len[0] <= len[1] && len[0] <= len[2]) { if (t->modifiers & MOD_CONSTRAINT_PLANE) { t->con.mode |= (CON_AXIS1|CON_AXIS2); - sprintf(t->con.text, " locking %s X axis", t->spacename); + BLI_snprintf(t->con.text, sizeof(t->con.text), " locking %s X axis", t->spacename); } else { t->con.mode |= CON_AXIS0; - sprintf(t->con.text, " along %s X axis", t->spacename); + BLI_snprintf(t->con.text, sizeof(t->con.text), " along %s X axis", t->spacename); } } else if (len[1] <= len[0] && len[1] <= len[2]) { if (t->modifiers & MOD_CONSTRAINT_PLANE) { t->con.mode |= (CON_AXIS0|CON_AXIS2); - sprintf(t->con.text, " locking %s Y axis", t->spacename); + BLI_snprintf(t->con.text, sizeof(t->con.text), " locking %s Y axis", t->spacename); } else { t->con.mode |= CON_AXIS1; - sprintf(t->con.text, " along %s Y axis", t->spacename); + BLI_snprintf(t->con.text, sizeof(t->con.text), " along %s Y axis", t->spacename); } } else if (len[2] <= len[1] && len[2] <= len[0]) { if (t->modifiers & MOD_CONSTRAINT_PLANE) { t->con.mode |= (CON_AXIS0|CON_AXIS1); - sprintf(t->con.text, " locking %s Z axis", t->spacename); + BLI_snprintf(t->con.text, sizeof(t->con.text), " locking %s Z axis", t->spacename); } else { t->con.mode |= CON_AXIS2; - sprintf(t->con.text, " along %s Z axis", t->spacename); + BLI_snprintf(t->con.text, sizeof(t->con.text), " along %s Z axis", t->spacename); } } } diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 90f95bea696..81a2b7158ee 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -268,7 +268,7 @@ static void TRANSFORM_OT_delete_orientation(struct wmOperatorType *ot) static int create_orientation_exec(bContext *C, wmOperator *op) { - char name[36]; + char name[MAX_NAME]; int use = RNA_boolean_get(op->ptr, "use"); int overwrite = RNA_boolean_get(op->ptr, "overwrite"); @@ -301,7 +301,7 @@ static void TRANSFORM_OT_create_orientation(struct wmOperatorType *ot) ot->poll = ED_operator_areaactive; ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_string(ot->srna, "name", "", 35, "Name", "Text to insert at the cursor position"); + RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Text to insert at the cursor position"); RNA_def_boolean(ot->srna, "use", 0, "Use after creation", "Select orientation after its creation"); RNA_def_boolean(ot->srna, "overwrite", 0, "Overwrite previous", "Overwrite previously created orientation with same name"); } diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 0fa38e016ed..0e3dfad7107 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -146,7 +146,7 @@ TransformOrientation *createObjectSpace(bContext *C, ReportList *UNUSED(reports) /* use object name if no name is given */ if (name[0] == 0) { - strncpy(name, ob->id.name+2, 35); + strncpy(name, ob->id.name+2, MAX_ID_NAME-2); } return addMatrixSpace(C, mat, name, overwrite); @@ -290,7 +290,7 @@ TransformOrientation* addMatrixSpace(bContext *C, float mat[3][3], char name[], { ts = MEM_callocN(sizeof(TransformOrientation), "UserTransSpace from matrix"); BLI_addtail(transform_spaces, ts); - strncpy(ts->name, name, 35); + strncpy(ts->name, name, sizeof(ts->name)); } /* copy matrix into transform space */ @@ -423,10 +423,11 @@ const char * BIF_menustringTransformOrientation(const bContext *C, const char *t TransformOrientation *ts; int i = V3D_MANIP_CUSTOM; char *str_menu, *p; + const int elem_size = MAX_NAME + 4; title = IFACE_(title); - str_menu = MEM_callocN(strlen(menu) + strlen(title) + 1 + 40 * BIF_countTransformOrientation(C), TIP_("UserTransSpace from matrix")); + str_menu = MEM_callocN(strlen(menu) + strlen(title) + 1 + elem_size * BIF_countTransformOrientation(C), TIP_("UserTransSpace from matrix")); p = str_menu; p += sprintf(str_menu, "%s", title); diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 169135478f6..b46ca538896 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -179,18 +179,18 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha BLI_strncpy(local_name, abs_name, sizeof(local_name)); BLI_splitdirstring(local_name, fi); - sprintf(local_name, "//%s/%s", folder, fi); + BLI_snprintf(local_name, sizeof(local_name), "//%s/%s", folder, fi); if(strcmp(abs_name, local_name)!=0) { switch(checkPackedFile(local_name, pf)) { case PF_NOFILE: - sprintf(line, "Create %s", local_name); + BLI_snprintf(line, sizeof(line), "Create %s", local_name); props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL); RNA_string_set(&props_ptr, "id", id_name); break; case PF_EQUAL: - sprintf(line, "Use %s (identical)", local_name); + BLI_snprintf(line, sizeof(line), "Use %s (identical)", local_name); //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_LOCAL); props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL); @@ -198,13 +198,13 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha break; case PF_DIFFERS: - sprintf(line, "Use %s (differs)", local_name); + BLI_snprintf(line, sizeof(line), "Use %s (differs)", local_name); //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_LOCAL); props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL); RNA_string_set(&props_ptr, "id", id_name); - sprintf(line, "Overwrite %s", local_name); + BLI_snprintf(line, sizeof(line), "Overwrite %s", local_name); //uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_LOCAL); props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL); @@ -216,27 +216,27 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha switch(checkPackedFile(abs_name, pf)) { case PF_NOFILE: - sprintf(line, "Create %s", abs_name); + BLI_snprintf(line, sizeof(line), "Create %s", abs_name); //uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_ORIGINAL); props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); break; case PF_EQUAL: - sprintf(line, "Use %s (identical)", abs_name); + BLI_snprintf(line, sizeof(line), "Use %s (identical)", abs_name); //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_ORIGINAL); props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); break; case PF_DIFFERS: - sprintf(line, "Use %s (differs)", abs_name); + BLI_snprintf(line, sizeof(line), "Use %s (differs)", abs_name); //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_ORIGINAL); props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); - sprintf(line, "Overwrite %s", abs_name); + BLI_snprintf(line, sizeof(line), "Overwrite %s", abs_name); //uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_ORIGINAL); props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL); diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c index 6c8713aa03e..52422d37f29 100644 --- a/source/blender/editors/util/numinput.c +++ b/source/blender/editors/util/numinput.c @@ -31,9 +31,10 @@ #include <math.h> /* fabs */ -#include <stdio.h> /* for sprintf */ +#include <stdio.h> /* for size_t */ #include "BLI_utildefines.h" +#include "BLI_string.h" #include "WM_types.h" @@ -84,34 +85,34 @@ void outputNumInput(NumInput *n, char *str) inv[0] = 0; if( n->val[i] > 1e10f || n->val[i] < -1e10f ) - sprintf(&str[j*20], "%s%.4e%c", inv, n->val[i], cur); + BLI_snprintf(&str[j*20], 20, "%s%.4e%c", inv, n->val[i], cur); else switch (n->ctrl[i]) { case 0: - sprintf(&str[j*20], "%sNONE%c", inv, cur); + BLI_snprintf(&str[j*20], 20, "%sNONE%c", inv, cur); break; case 1: case -1: - sprintf(&str[j*20], "%s%.0f%c", inv, n->val[i], cur); + BLI_snprintf(&str[j*20], 20, "%s%.0f%c", inv, n->val[i], cur); break; case 10: case -10: - sprintf(&str[j*20], "%s%.f.%c", inv, n->val[i], cur); + BLI_snprintf(&str[j*20], 20, "%s%.f.%c", inv, n->val[i], cur); break; case 100: case -100: - sprintf(&str[j*20], "%s%.1f%c", inv, n->val[i], cur); + BLI_snprintf(&str[j*20], 20, "%s%.1f%c", inv, n->val[i], cur); break; case 1000: case -1000: - sprintf(&str[j*20], "%s%.2f%c", inv, n->val[i], cur); + BLI_snprintf(&str[j*20], 20, "%s%.2f%c", inv, n->val[i], cur); break; case 10000: case -10000: - sprintf(&str[j*20], "%s%.3f%c", inv, n->val[i], cur); + BLI_snprintf(&str[j*20], 20, "%s%.3f%c", inv, n->val[i], cur); break; default: - sprintf(&str[j*20], "%s%.4e%c", inv, n->val[i], cur); + BLI_snprintf(&str[j*20], 20, "%s%.4e%c", inv, n->val[i], cur); } } } diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 6df7ce45a64..f3019448240 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -48,6 +48,7 @@ #include "BLI_uvproject.h" #include "BLI_utildefines.h" #include "BLI_rand.h" +#include "BLI_string.h" #include "BKE_context.h" #include "BKE_customdata.h" @@ -379,7 +380,7 @@ static void minimize_stretch_iteration(bContext *C, wmOperator *op, int interact param_flush(ms->handle); if(sa) { - sprintf(str, "Minimize Stretch. Blend %.2f.", ms->blend); + BLI_snprintf(str, sizeof(str), "Minimize Stretch. Blend %.2f", ms->blend); ED_area_headerprint(sa, str); } diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h index 1dbe9ed7371..9fb0dd1ae07 100644 --- a/source/blender/gpu/GPU_extensions.h +++ b/source/blender/gpu/GPU_extensions.h @@ -167,7 +167,7 @@ void GPU_shader_uniform_vector(GPUShader *shader, int location, int length, int arraysize, float *value); void GPU_shader_uniform_texture(GPUShader *shader, int location, GPUTexture *tex); -int GPU_shader_get_attribute(GPUShader *shader, char *name); +int GPU_shader_get_attribute(GPUShader *shader, const char *name); /* Vertex attributes for shaders */ @@ -179,7 +179,7 @@ typedef struct GPUVertexAttribs { int glindex; int gltexco; int attribid; - char name[32]; + char name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ } layer[GPU_MAX_ATTRIB]; int totlayer; diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index c4ed88635b7..cc486b75245 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -1156,7 +1156,7 @@ void GPU_shader_uniform_texture(GPUShader *UNUSED(shader), int location, GPUText GPU_print_error("Post Uniform Texture"); } -int GPU_shader_get_attribute(GPUShader *shader, char *name) +int GPU_shader_get_attribute(GPUShader *shader, const char *name) { int index; diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 93ea067cfb7..ef2abb20cf3 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -173,7 +173,7 @@ static void gpu_material_set_attrib_id(GPUMaterial *material) * removed by the glsl compiler by dead code elimination */ for(a=0, b=0; a<attribs->totlayer; a++) { - sprintf(name, "att%d", attribs->layer[a].attribid); + BLI_snprintf(name, sizeof(name), "att%d", attribs->layer[a].attribid); attribs->layer[a].glindex = GPU_shader_get_attribute(shader, name); if(attribs->layer[a].glindex >= 0) { diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index e6d09285685..a0903379528 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -1289,7 +1289,7 @@ struct ImBuf * IMB_anim_absolute(struct anim * anim, int position, if (ibuf) { if (filter_y) IMB_filtery(ibuf); - sprintf(ibuf->name, "%s.%04d", anim->name, anim->curposition + 1); + BLI_snprintf(ibuf->name, sizeof(ibuf->name), "%s.%04d", anim->name, anim->curposition + 1); } return(ibuf); diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index f0e126db813..f311d94703f 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -53,7 +53,7 @@ typedef struct IDProperty { struct IDProperty *next, *prev; char type, subtype; short flag; - char name[32]; + char name[64]; /* MAX_IDPROP_NAME */ int saved; /*saved is used to indicate if this struct has been saved yet. seemed like a good idea as a pad var was needed anyway :)*/ IDPropertyData data; /* note, alignment for 64 bits */ @@ -65,7 +65,7 @@ typedef struct IDProperty { saved.*/ } IDProperty; -#define MAX_IDPROP_NAME 32 +#define MAX_IDPROP_NAME 64 #define DEFAULT_ALLOC_FOR_NULL_STRINGS 64 /*->type*/ @@ -96,7 +96,8 @@ typedef struct IDProperty { * provides a common handle to place all data in double-linked lists. * */ -#define MAX_ID_NAME 24 +/* 2 characters for ID code and 64 for actual name */ +#define MAX_ID_NAME 66 /* There's a nasty circular dependency here.... void* to the rescue! I * really wonder why this is needed. */ @@ -104,14 +105,14 @@ typedef struct ID { void *next, *prev; struct ID *newid; struct Library *lib; - char name[24]; - short us; + char name[66]; + short pad, us; /** * LIB_... flags report on status of the datablock this ID belongs * to. */ short flag; - int icon_id; + int icon_id, pad2; IDProperty *properties; } ID; diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index 9cee4e188ff..7df4ebd3c55 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -184,7 +184,7 @@ typedef struct bPoseChannel { IDProperty *prop; /* User-Defined Properties on this PoseChannel */ ListBase constraints;/* Constraints that act on this PoseChannel */ - char name[32]; /* Channels need longer names than normal blender objects */ + char name[72]; /* Channels need longer names than normal blender objects */ short flag; /* dynamic, for detecting transform changes */ short ikflag; /* settings for IK bones */ @@ -345,7 +345,7 @@ typedef struct bPose { void *ikparam; /* IK solver parameters, structure depends on iksolver */ bAnimVizSettings avs; /* settings for visualization of bone animation */ - char proxy_act_bone[32]; /* proxy active bone name*/ + char proxy_act_bone[64]; /* proxy active bone name, MAXBONENAME */ } bPose; @@ -669,7 +669,7 @@ typedef struct bActionChannel { ListBase constraintChannels; /* Constraint Channels (when Action Channel represents an Object or Bone) */ int flag; /* settings accessed via bitmapping */ - char name[32]; /* channel name */ + char name[64]; /* channel name, MAX_NAME */ int temp; /* temporary setting - may be used to indicate group that channel belongs to during syncing */ } bActionChannel; diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h index a4280a6e463..3be46538c22 100644 --- a/source/blender/makesdna/DNA_actuator_types.h +++ b/source/blender/makesdna/DNA_actuator_types.h @@ -50,8 +50,8 @@ typedef struct bActionActuator { struct bAction *act; /* Pointer to action */ short type, flag; /* Playback type */ // not in use float sta, end; /* Start & End frames */ - char name[32]; /* For property-driven playback */ - char frameProp[32]; /* Set this property to the actions current frame */ + char name[64]; /* For property-driven playback, MAX_NAME */ + char frameProp[64]; /* Set this property to the actions current frame, MAX_NAME */ short blendin; /* Number of frames of blending */ short priority; /* Execution priority */ short layer; /* Animation layer */ @@ -90,7 +90,7 @@ typedef struct bEditObjectActuator { short type, flag; struct Object *ob; struct Mesh *me; - char name[32]; + char name[64]; /* MAX_NAME */ float linVelocity[3]; /* initial lin. velocity on creation */ float angVelocity[3]; /* initial ang. velocity on creation */ float mass; @@ -107,7 +107,7 @@ typedef struct bSceneActuator { typedef struct bPropertyActuator { int pad, type; - char name[32], value[32]; + char name[64], value[64]; /* MAX_NAME */ struct Object *ob; } bPropertyActuator; @@ -125,8 +125,8 @@ typedef struct bObjectActuator { typedef struct bIpoActuator { short flag, type; float sta, end; - char name[32]; - char frameProp[32]; /* Set this property to the actions current frame */ + char name[64]; /* MAX_NAME */ + char frameProp[64]; /* Set this property to the actions current frame, MAX_NAME */ short pad1, pad2, pad3, pad4; @@ -147,13 +147,13 @@ typedef struct bConstraintActuator { int pad; float minloc[3], maxloc[3]; float minrot[3], maxrot[3]; - char matprop[32]; + char matprop[64]; /* MAX_NAME */ } bConstraintActuator; typedef struct bGroupActuator { short flag, type; int sta, end; - char name[32]; /* property or groupkey */ + char name[64]; /* property or groupkey, MAX_NAME */ short pad[3], cur, butsta, butend;/* not referenced, can remove? */ /* struct Group *group; not used, remove */ @@ -168,16 +168,16 @@ typedef struct bRandomActuator { int int_arg_2; float float_arg_1; float float_arg_2; - char propname[32]; + char propname[64]; /* MAX_NAME */ } bRandomActuator; typedef struct bMessageActuator { - char toPropName[32]; /* Send to all objects with this propertyname. Empty to broadcast. */ + char toPropName[64]; /* Send to all objects with this propertyname. Empty to broadcast. MAX_NAME. */ struct Object *toObject;/* (Possible future use) pointer to a single destination object. */ - char subject[32]; /* Message Subject to send. */ + char subject[64]; /* Message Subject to send. MAX_NAME. */ short bodyType, pad1; /* bodyType is either 'User defined text' or PropName */ int pad2; - char body[32]; /* Either User Defined Text or our PropName to send value of */ + char body[64]; /* Either User Defined Text or our PropName to send value of, MAX_NAME */ } bMessageActuator; typedef struct bGameActuator { @@ -220,8 +220,8 @@ typedef struct bStateActuator { } bStateActuator; typedef struct bArmatureActuator { - char posechannel[32]; - char constraint[32]; + char posechannel[64]; /* MAX_NAME */ + char constraint[64]; /* MAX_NAME */ int type; /* 0=run, 1=enable, 2=disable, 3=set target, 4=set weight */ float weight; struct Object *target; @@ -250,7 +250,7 @@ typedef struct bActuator { */ short flag; short otype, go; - char name[32]; + char name[64]; /* MAX_NAME */ /** * data must point to an object actuator type struct. @@ -520,10 +520,6 @@ typedef struct bActuator { #define ACT_STATE_REMOVE 2 #define ACT_STATE_CHANGE 3 -/* cameraactuator->axis */ -#define ACT_CAMERA_X (float)'x' -#define ACT_CAMERA_Y (float)'y' - /* steeringactuator->type */ #define ACT_STEERING_SEEK 0 #define ACT_STEERING_FLEE 1 diff --git a/source/blender/makesdna/DNA_armature_types.h b/source/blender/makesdna/DNA_armature_types.h index 45c30315575..33f965663de 100644 --- a/source/blender/makesdna/DNA_armature_types.h +++ b/source/blender/makesdna/DNA_armature_types.h @@ -49,7 +49,7 @@ typedef struct Bone { IDProperty *prop; /* User-Defined Properties on this Bone */ struct Bone *parent; /* Parent (ik parent if appropriate flag is set */ ListBase childbase; /* Children */ - char name[32]; /* Name of the bone - must be unique within the armature */ + char name[64]; /* Name of the bone - must be unique within the armature, MAXBONENAME */ float roll; /* roll is input for editmode, length calculated */ float head[3]; @@ -200,6 +200,6 @@ typedef enum eBone_Flag { BONE_NO_LOCAL_LOCATION = (1<<22) /* bone location is in armature space */ } eBone_Flag; -#define MAXBONENAME 32 +#define MAXBONENAME 64 #endif diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h index c829d5be294..fdc493ddfd3 100644 --- a/source/blender/makesdna/DNA_constraint_types.h +++ b/source/blender/makesdna/DNA_constraint_types.h @@ -61,11 +61,12 @@ typedef struct bConstraint { char ownspace; /* Space that owner should be evaluated in */ char tarspace; /* Space that target should be evaluated in (only used if 1 target) */ - char name[30]; /* Constraint name */ + char name[64]; /* Constraint name, MAX_NAME */ + + short pad; float enforce; /* Amount of influence exherted by constraint (0.0-1.0) */ float headtail; /* Point along subtarget bone where the actual target is. 0=head (default for all), 1=tail*/ - int pad; struct Ipo *ipo DNA_DEPRECATED; /* local influence ipo or driver */ /* old animation system, deprecated for 2.5 */ @@ -85,7 +86,7 @@ typedef struct bConstraintTarget { struct bConstraintTarget *next, *prev; struct Object *tar; /* object to use as target */ - char subtarget[32]; /* subtarget - pchan or vgroup name */ + char subtarget[64]; /* subtarget - pchan or vgroup name, MAX_ID_NAME-2 */ float matrix[4][4]; /* matrix used during constraint solving - should be cleared before each use */ @@ -121,7 +122,7 @@ typedef struct bPythonConstraint { ListBase targets; /* a list of targets that this constraint has (bConstraintTarget-s) */ struct Object *tar; /* target from previous implementation (version-patch sets this to NULL on file-load) */ - char subtarget[32]; /* subtarger from previous implentation (version-patch sets this to "" on file-load) */ + char subtarget[64]; /* subtarger from previous implentation (version-patch sets this to "" on file-load), MAX_ID_NAME-2 */ } bPythonConstraint; @@ -137,9 +138,9 @@ typedef struct bKinematicConstraint { short flag; /* All & CopyPose: some options Like CONSTRAINT_IK_TIP */ short rootbone; /* All: index to rootbone, if zero go all the way to mother bone */ short max_rootbone; /* CopyPose: for auto-ik, maximum length of chain */ - char subtarget[32]; /* All: String to specify sub-object target */ + char subtarget[64]; /* All: String to specify sub-object target, MAX_ID_NAME-2 */ struct Object *poletar; /* All: Pole vector target */ - char polesubtarget[32]; /* All: Pole vector sub-object target */ + char polesubtarget[64]; /* All: Pole vector sub-object target, MAX_ID_NAME-2 */ float poleangle; /* All: Pole vector rest angle */ float weight; /* All: Weight of constraint in IK tree */ float orientweight; /* CopyPose: Amount of rotation a target applies on chain */ @@ -187,7 +188,7 @@ typedef struct bTrackToConstraint { int reserved2; int flags; int pad; - char subtarget[32]; + char subtarget[64]; /* MAX_ID_NAME-2 */ } bTrackToConstraint; /* Copy Rotation Constraint */ @@ -195,7 +196,7 @@ typedef struct bRotateLikeConstraint { struct Object *tar; int flag; int reserved1; - char subtarget[32]; + char subtarget[64]; /* MAX_ID_NAME-2 */ } bRotateLikeConstraint; /* Copy Location Constraint */ @@ -203,7 +204,7 @@ typedef struct bLocateLikeConstraint { struct Object *tar; int flag; int reserved1; - char subtarget[32]; + char subtarget[64]; /* MAX_ID_NAME-2 */ } bLocateLikeConstraint; /* Copy Scale Constraint */ @@ -211,7 +212,7 @@ typedef struct bSizeLikeConstraint { struct Object *tar; int flag; int reserved1; - char subtarget[32]; + char subtarget[64]; /* MAX_ID_NAME-2 */ } bSizeLikeConstraint; /* Maintain Volume Constraint */ @@ -223,7 +224,7 @@ typedef struct bSameVolumeConstraint { /* Copy Transform Constraint */ typedef struct bTransLikeConstraint { struct Object *tar; - char subtarget[32]; + char subtarget[64]; /* MAX_ID_NAME-2 */ } bTransLikeConstraint; /* Floor Constraint */ @@ -234,7 +235,7 @@ typedef struct bMinMaxConstraint { int flag; short sticky, stuck, pad1, pad2; /* for backward compatibility */ float cache[3]; - char subtarget[32]; + char subtarget[64]; /* MAX_ID_NAME-2 */ } bMinMaxConstraint; /* Action Constraint */ @@ -248,7 +249,7 @@ typedef struct bActionConstraint { float max; int pad; struct bAction *act; - char subtarget[32]; + char subtarget[64]; /* MAX_ID_NAME-2 */ } bActionConstraint; /* Locked Axis Tracking constraint */ @@ -256,7 +257,7 @@ typedef struct bLockTrackConstraint { struct Object *tar; int trackflag; int lockflag; - char subtarget[32]; + char subtarget[64]; /* MAX_ID_NAME-2 */ } bLockTrackConstraint; /* Damped Tracking constraint */ @@ -264,7 +265,7 @@ typedef struct bDampTrackConstraint { struct Object *tar; int trackflag; int pad; - char subtarget[32]; + char subtarget[64]; /* MAX_ID_NAME-2 */ } bDampTrackConstraint; /* Follow Path constraints */ @@ -287,7 +288,7 @@ typedef struct bStretchToConstraint { int plane; float orglength; float bulge; - char subtarget[32]; + char subtarget[64]; /* MAX_ID_NAME-2 */ } bStretchToConstraint; /* Rigid Body constraint */ @@ -323,13 +324,13 @@ typedef struct bChildOfConstraint { int flag; /* settings */ int pad; float invmat[4][4]; /* parent-inverse matrix to use */ - char subtarget[32]; /* string to specify a subobject target */ + char subtarget[64]; /* string to specify a subobject target, MAX_ID_NAME-2 */ } bChildOfConstraint; /* Generic Transform->Transform Constraint */ typedef struct bTransformConstraint { struct Object *tar; /* target (i.e. 'driver' object/bone) */ - char subtarget[32]; + char subtarget[64]; /* MAX_ID_NAME-2 */ short from, to; /* can be loc(0) , rot(1), or size(2) */ char map[3]; /* defines which target-axis deform is copied by each owner-axis */ @@ -348,7 +349,7 @@ typedef struct bPivotConstraint { * Either target object + offset, or just offset is used */ struct Object *tar; /* target object (optional) */ - char subtarget[32]; /* subtarget name (optional) */ + char subtarget[64]; /* subtarget name (optional), MAX_ID_NAME-2 */ float offset[3]; /* offset from the target to use, regardless of whether it exists */ /* Rotation-driven activation: @@ -391,7 +392,7 @@ typedef struct bSizeLimitConstraint { /* Limit Distance Constraint */ typedef struct bDistLimitConstraint { struct Object *tar; - char subtarget[32]; + char subtarget[64]; /* MAX_ID_NAME-2 */ float dist; /* distance (radius of clamping sphere) from target */ float soft; /* distance from clamping-sphere to start applying 'fade' */ @@ -413,9 +414,9 @@ typedef struct bShrinkwrapConstraint { /* Follow Track constraints */ typedef struct bFollowTrackConstraint { struct MovieClip *clip; - char track[24]; + char track[64]; /* MAX_NAME */ int flag, pad; - char object[24]; + char object[64]; /* MAX_NAME */ struct Object *camera; struct Object *depth_ob; } bFollowTrackConstraint; @@ -430,7 +431,7 @@ typedef struct bCameraSolverConstraint { typedef struct bObjectSolverConstraint { struct MovieClip *clip; int flag, pad; - char object[24]; + char object[64]; /* MAX_NAME */ float invmat[4][4]; /* parent-inverse matrix to use */ struct Object *camera; } bObjectSolverConstraint; diff --git a/source/blender/makesdna/DNA_controller_types.h b/source/blender/makesdna/DNA_controller_types.h index c8f4325d717..51ab29db7ae 100644 --- a/source/blender/makesdna/DNA_controller_types.h +++ b/source/blender/makesdna/DNA_controller_types.h @@ -54,7 +54,7 @@ typedef struct bController { short type, flag, inputs, totlinks; short otype, totslinks, pad2, pad3; - char name[32]; + char name[64]; void *data; struct bActuator **links; diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h index 13a1f4fbe8a..33b4107abcb 100644 --- a/source/blender/makesdna/DNA_customdata_types.h +++ b/source/blender/makesdna/DNA_customdata_types.h @@ -48,10 +48,12 @@ typedef struct CustomDataLayer { int active_clone; /* number of the layer to render*/ int active_mask; /* number of the layer to render*/ int uid; /* shape keyblock unique id reference*/ - char name[32]; /* layer name */ + char name[64]; /* layer name, MAX_CUSTOMDATA_LAYER_AAME */ void *data; /* layer data */ } CustomDataLayer; +#define MAX_CUSTOMDATA_LAYER_NAME 64 + typedef struct CustomDataExternal { char filename[240]; /* FILE_MAX */ } CustomDataExternal; diff --git a/source/blender/makesdna/DNA_defs.h b/source/blender/makesdna/DNA_defs.h index e23175b40e4..a5496e319e9 100644 --- a/source/blender/makesdna/DNA_defs.h +++ b/source/blender/makesdna/DNA_defs.h @@ -48,4 +48,7 @@ /* Must not be defined for BMesh, as this guards code for pre-BMesh code to load BMesh .blend files */ /* #define USE_BMESH_FORWARD_COMPAT */ +/* non-id name variables should use this length */ +#define MAX_NAME 64 + #endif /* DNA_DEFS_H */ diff --git a/source/blender/makesdna/DNA_dynamicpaint_types.h b/source/blender/makesdna/DNA_dynamicpaint_types.h index d58e11d9640..cee8e5cd8d7 100644 --- a/source/blender/makesdna/DNA_dynamicpaint_types.h +++ b/source/blender/makesdna/DNA_dynamicpaint_types.h @@ -111,7 +111,7 @@ typedef struct DynamicPaintSurface { /* initial color */ float init_color[4]; struct Tex *init_texture; - char init_layername[40]; + char init_layername[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ int dry_speed, diss_speed; float depth_clamp, disp_factor; @@ -124,10 +124,10 @@ typedef struct DynamicPaintSurface { int pad_; - char uvlayer_name[32]; + char uvlayer_name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ char image_output_path[240]; - char output_name[40]; - char output_name2[40]; /* some surfaces have 2 outputs */ + char output_name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ + char output_name2[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ /* some surfaces have 2 outputs */ } DynamicPaintSurface; diff --git a/source/blender/makesdna/DNA_effect_types.h b/source/blender/makesdna/DNA_effect_types.h index b7437b5e973..ddff22aae37 100644 --- a/source/blender/makesdna/DNA_effect_types.h +++ b/source/blender/makesdna/DNA_effect_types.h @@ -118,7 +118,7 @@ typedef struct PartEff { short staticstep, omat, timetex, speedtex, flag2, flag2neg; short disp, vertgroup_v; - char vgroupname[32], vgroupname_v[32]; + char vgroupname[64], vgroupname_v[64]; /* MAX_VGROUP_NAME */ float imat[4][4]; /* inverse matrix of parent Object */ Particle *keys; diff --git a/source/blender/makesdna/DNA_key_types.h b/source/blender/makesdna/DNA_key_types.h index ee5cf96f110..f1e134dcb8c 100644 --- a/source/blender/makesdna/DNA_key_types.h +++ b/source/blender/makesdna/DNA_key_types.h @@ -48,8 +48,8 @@ typedef struct KeyBlock { void *data; float *weights; - char name[32]; - char vgroup[32]; + char name[64]; /* MAX_NAME */ + char vgroup[64]; /* MAX_VGROUP_NAME */ float slidermin; float slidermax; @@ -63,7 +63,7 @@ typedef struct Key { struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */ KeyBlock *refkey; - char elemstr[32]; + char elemstr[64]; /* MAX_NAME */ int elemsize; float curval DNA_DEPRECATED; diff --git a/source/blender/makesdna/DNA_lattice_types.h b/source/blender/makesdna/DNA_lattice_types.h index 2a67afb5708..0a73ed5b24f 100644 --- a/source/blender/makesdna/DNA_lattice_types.h +++ b/source/blender/makesdna/DNA_lattice_types.h @@ -66,7 +66,7 @@ typedef struct Lattice { struct Key *key; struct MDeformVert *dvert; - char vgroup[32]; /* multiply the influence */ + char vgroup[64]; /* multiply the influence, MAX_VGROUP_NAME */ /* used while deforming, always free and NULL after use */ float *latticedata; diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index 55e9328a72a..eacc1b222e4 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -121,7 +121,7 @@ typedef struct Material { float hasize, flaresize, subsize, flareboost; float strand_sta, strand_end, strand_ease, strand_surfnor; float strand_min, strand_widthfade; - char strand_uvname[32]; + char strand_uvname[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ float sbias; /* shadow bias to prevent terminator prob */ float lbias; /* factor to multiply lampbias with (0.0 = no mult) */ diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 2d6143a1bc2..d398fcef3ad 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -99,7 +99,7 @@ typedef struct ModifierData { int type, mode; int stackindex, pad; - char name[32]; + char name[64]; /* MAX_NAME */ /* XXX for timing info set by caller... solve later? (ton) */ struct Scene *scene; @@ -120,7 +120,7 @@ typedef struct MappingInfoModifierData { struct Tex *texture; struct Object *map_object; - char uvlayer_name[32]; + char uvlayer_name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ int uvlayer_tmp; int texmapping; } MappingInfoModifierData; @@ -137,14 +137,14 @@ typedef struct LatticeModifierData { ModifierData modifier; struct Object *object; - char name[32]; /* optional vertexgroup name */ + char name[64]; /* optional vertexgroup name, MAX_VGROUP_NAME */ } LatticeModifierData; typedef struct CurveModifierData { ModifierData modifier; struct Object *object; - char name[32]; /* optional vertexgroup name */ + char name[64]; /* optional vertexgroup name, MAX_VGROUP_NAME */ short defaxis; /* axis along which curve deforms */ char pad[6]; } CurveModifierData; @@ -169,7 +169,7 @@ typedef struct MaskModifierData { ModifierData modifier; struct Object *ob_arm; /* armature to use to in place of hardcoded vgroup */ - char vgroup[32]; /* name of vertex group to use to mask */ + char vgroup[64]; /* name of vertex group to use to mask, MAX_VGROUP_NAME */ int mode; /* using armature or hardcoded vgroup */ int flag; /* flags for various things */ @@ -281,7 +281,7 @@ typedef struct BevelModifierData { short lim_flags; /* flags to tell the tool how to limit the bevel */ short e_flags; /* flags to direct how edge weights are applied to verts */ float bevel_angle; /* if the BME_BEVEL_ANGLE is set, this will be how "sharp" an edge must be before it gets beveled */ - char defgrp_name[32]; /* if the BME_BEVEL_VWEIGHT option is set, this will be the name of the vert group */ + char defgrp_name[64]; /* if the BME_BEVEL_VWEIGHT option is set, this will be the name of the vert group, MAX_VGROUP_NAME */ } BevelModifierData; typedef struct BMeshModifierData { @@ -313,14 +313,14 @@ typedef struct DisplaceModifierData { /* keep in sync with MappingInfoModifierData */ struct Tex *texture; struct Object *map_object; - char uvlayer_name[32]; + char uvlayer_name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ int uvlayer_tmp; int texmapping; /* end MappingInfoModifierData */ float strength; int direction; - char defgrp_name[32]; + char defgrp_name[64]; /* MAX_VGROUP_NAME */ float midlevel; int pad; } DisplaceModifierData; @@ -352,7 +352,7 @@ typedef struct UVProjectModifierData { int num_projectors; float aspectx, aspecty; float scalex, scaley; - char uvlayer_name[32]; + char uvlayer_name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ int uvlayer_tmp, pad; } UVProjectModifierData; @@ -376,7 +376,7 @@ typedef struct DecimateModifierData { typedef struct SmoothModifierData { ModifierData modifier; float fac; - char defgrp_name[32]; + char defgrp_name[64]; /* MAX_VGROUP_NAME */ short flag, repeat; } SmoothModifierData; @@ -400,7 +400,7 @@ typedef struct CastModifierData { float fac; float radius; float size; - char defgrp_name[32]; + char defgrp_name[64]; /* MAX_VGROUP_NAME */ short flag, type; } CastModifierData; @@ -419,13 +419,13 @@ typedef struct WaveModifierData { /* keep in sync with MappingInfoModifierData */ struct Tex *texture; struct Object *map_object; - char uvlayer_name[32]; + char uvlayer_name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ int uvlayer_tmp; int texmapping; /* end MappingInfoModifierData */ struct Object *objectcenter; - char defgrp_name[32]; + char defgrp_name[64]; /* MAX_VGROUP_NAME */ short flag, pad; @@ -443,14 +443,14 @@ typedef struct ArmatureModifierData { int pad2; struct Object *object; float *prevCos; /* stored input of previous modifier, for vertexgroup blending */ - char defgrp_name[32]; + char defgrp_name[64]; /* MAX_VGROUP_NAME */ } ArmatureModifierData; typedef struct HookModifierData { ModifierData modifier; struct Object *object; - char subtarget[32]; /* optional name of bone target */ + char subtarget[64]; /* optional name of bone target, MAX_ID_NAME-2 */ float parentinv[4][4]; /* matrix making current transform unmodified */ float cent[3]; /* visualization of hook */ @@ -459,7 +459,7 @@ typedef struct HookModifierData { int *indexar; /* if NULL, it's using vertexgroup */ int totindex; float force; - char name[32]; /* optional vertexgroup name */ + char name[64]; /* optional vertexgroup name, MAX_VGROUP_NAME */ } HookModifierData; typedef struct SoftbodyModifierData { @@ -540,7 +540,7 @@ typedef struct MeshDeformModifierData { ModifierData modifier; struct Object *object; /* mesh object */ - char defgrp_name[32]; /* optional vertexgroup name */ + char defgrp_name[64]; /* optional vertexgroup name, MAX_VGROUP_NAME */ short gridsize, flag, mode, pad; @@ -616,7 +616,7 @@ typedef struct ExplodeModifierData { int *facepa; short flag, vgroup; float protect; - char uvname[32]; + char uvname[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ } ExplodeModifierData; typedef struct MultiresModifierData { @@ -643,7 +643,7 @@ typedef struct ShrinkwrapModifierData { struct Object *target; /* shrink target */ struct Object *auxTarget; /* additional shrink target */ - char vgroup_name[32]; /* optional vertexgroup name */ + char vgroup_name[64]; /* optional vertexgroup name, MAX_VGROUP_NAME */ float keepDist; /* distance offset to keep from mesh/projection point */ short shrinkType; /* shrink type projection */ short shrinkOpts; /* shrink options */ @@ -684,7 +684,7 @@ typedef struct SimpleDeformModifierData { ModifierData modifier; struct Object *origin; /* object to control the origin of modifier space coordinates */ - char vgroup_name[32]; /* optional vertexgroup name */ + char vgroup_name[64]; /* optional vertexgroup name, MAX_VGROUP_NAME */ float factor; /* factors to control simple deforms */ float limit[2]; /* lower and upper limit */ @@ -716,7 +716,7 @@ typedef struct ShapeKeyModifierData { typedef struct SolidifyModifierData { ModifierData modifier; - char defgrp_name[32]; /* name of vertex group to use */ + char defgrp_name[64]; /* name of vertex group to use, MAX_VGROUP_NAME */ float offset; /* new surface offset level*/ float offset_fac; /* midpoint of the offset */ float offset_fac_vg; /* factor for the minimum weight to use when vgroups are used, avoids 0.0 weights giving duplicate geometry */ @@ -778,7 +778,7 @@ typedef struct OceanModifierData { int bakeend; char cachepath[240]; // FILE_MAX - char foamlayername[32]; + char foamlayername[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ char cached; char geometry_mode; @@ -823,7 +823,7 @@ typedef struct WarpModifierData { /* keep in sync with MappingInfoModifierData */ struct Tex *texture; struct Object *map_object; - char uvlayer_name[32]; + char uvlayer_name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ int uvlayer_tmp; int texmapping; /* end MappingInfoModifierData */ @@ -831,7 +831,7 @@ typedef struct WarpModifierData { struct Object *object_from; struct Object *object_to; struct CurveMapping *curfalloff; - char defgrp_name[32]; /* optional vertexgroup name */ + char defgrp_name[64]; /* optional vertexgroup name, MAX_VGROUP_NAME */ float strength; float falloff_radius; char flag; /* not used yet */ @@ -859,7 +859,7 @@ typedef struct WeightVGEditModifierData { /* Note: I tried to keep everything logically ordered - provided the * alignment constraints... */ - char defgrp_name[32]; /* Name of vertex group to edit. */ + char defgrp_name[64]; /* Name of vertex group to edit. MAX_VGROUP_NAME. */ short edit_flags; /* Using MOD_WVG_EDIT_* flags. */ short falloff_type; /* Using MOD_WVG_MAPPING_* defines. */ @@ -874,7 +874,7 @@ typedef struct WeightVGEditModifierData { /* Masking options. */ float mask_constant; /* The global "influence", if no vgroup nor tex is used as mask. */ /* Name of mask vertex group from which to get weight factors. */ - char mask_defgrp_name[32]; + char mask_defgrp_name[64]; /* MAX_VGROUP_NAME */ /* Texture masking. */ int mask_tex_use_channel; /* Which channel to use as weightf. */ @@ -882,7 +882,7 @@ typedef struct WeightVGEditModifierData { struct Object *mask_tex_map_obj; /* Name of the map object. */ /* How to map the texture (using MOD_DISP_MAP_* constants). */ int mask_tex_mapping; - char mask_tex_uvlayer_name[32]; /* Name of the UV map. */ + char mask_tex_uvlayer_name[64]; /* Name of the UV map. MAX_CUSTOMDATA_LAYER_NAME */ /* Padding... */ int pad_i1; @@ -908,8 +908,8 @@ typedef struct WeightVGMixModifierData { /* XXX Note: I tried to keep everything logically ordered – provided the * alignment constraints... */ - char defgrp_name_a[32]; /* Name of vertex group to modify/weight. */ - char defgrp_name_b[32]; /* Name of other vertex group to mix in. */ + char defgrp_name_a[64]; /* Name of vertex group to modify/weight. MAX_VGROUP_NAME. */ + char defgrp_name_b[64]; /* Name of other vertex group to mix in. MAX_VGROUP_NAME. */ float default_weight_a; /* Default weight value for first vgroup. */ float default_weight_b; /* Default weight value to mix in. */ char mix_mode; /* How second vgroups weights affect first ones */ @@ -920,14 +920,14 @@ typedef struct WeightVGMixModifierData { /* Masking options. */ float mask_constant; /* The global "influence", if no vgroup nor tex is used as mask. */ /* Name of mask vertex group from which to get weight factors. */ - char mask_defgrp_name[32]; + char mask_defgrp_name[64]; /* MAX_VGROUP_NAME */ /* Texture masking. */ int mask_tex_use_channel; /* Which channel to use as weightf. */ struct Tex *mask_texture; /* The texture. */ struct Object *mask_tex_map_obj; /* Name of the map object. */ int mask_tex_mapping; /* How to map the texture! */ - char mask_tex_uvlayer_name[32]; /* Name of the UV map. */ + char mask_tex_uvlayer_name[64]; /* Name of the UV map. MAX_CUSTOMDATA_LAYER_NAME. */ /* Padding... */ int pad_i1; @@ -955,7 +955,7 @@ typedef struct WeightVGProximityModifierData { /* Note: I tried to keep everything logically ordered - provided the * alignment constraints... */ - char defgrp_name[32]; /* Name of vertex group to modify/weight. */ + char defgrp_name[64]; /* Name of vertex group to modify/weight. MAX_VGROUP_NAME. */ /* Proximity modes. */ int proximity_mode; @@ -967,14 +967,14 @@ typedef struct WeightVGProximityModifierData { /* Masking options. */ float mask_constant; /* The global "influence", if no vgroup nor tex is used as mask. */ /* Name of mask vertex group from which to get weight factors. */ - char mask_defgrp_name[32]; + char mask_defgrp_name[64]; /* MAX_VGROUP_NAME */ /* Texture masking. */ int mask_tex_use_channel; /* Which channel to use as weightf. */ struct Tex *mask_texture; /* The texture. */ struct Object *mask_tex_map_obj; /* Name of the map object. */ int mask_tex_mapping; /* How to map the texture! */ - char mask_tex_uvlayer_name[32]; /* Name of the UV Map. */ + char mask_tex_uvlayer_name[64]; /* Name of the UV Map. MAX_CUSTOMDATA_LAYER_NAME. */ float min_dist, max_dist; /* Distances mapping to 0.0/1.0 weights. */ diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 01ffbb44c13..fe4f6905f42 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -49,7 +49,7 @@ struct bGPdata; struct uiBlock; struct Image; -#define NODE_MAXSTR 32 +#define NODE_MAXSTR 64 typedef struct bNodeStack { float vec[4]; @@ -71,7 +71,7 @@ typedef struct bNodeStack { typedef struct bNodeSocket { struct bNodeSocket *next, *prev, *new_sock; - char name[32]; + char name[64]; /* MAX_NAME */ void *storage; /* custom storage */ @@ -142,7 +142,7 @@ typedef struct bNodePreview { typedef struct bNode { struct bNode *next, *prev, *new_node; - char name[32]; + char name[64]; /* MAX_NAME */ short type, flag; short done, level; /* both for dependency and sorting */ short lasty, menunr; /* lasty: check preview render status, menunr: browse ID blocks */ @@ -160,7 +160,7 @@ typedef struct bNode { int update; /* update flags */ - char label[32]; /* custom user-defined label */ + char label[64]; /* custom user-defined label, MAX_NAME */ short custom1, custom2; /* to be abused for buttons */ float custom3, custom4; @@ -369,12 +369,12 @@ typedef struct NodeTwoFloats { } NodeTwoFloats; typedef struct NodeGeometry { - char uvname[32]; - char colname[32]; + char uvname[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ + char colname[64]; } NodeGeometry; typedef struct NodeVertexCol { - char name[32]; + char name[64]; } NodeVertexCol; /* qdn: Defocus blur node */ @@ -497,7 +497,7 @@ typedef struct NodeShaderAttribute { /* TEX_output */ typedef struct TexNodeOutput { - char name[32]; + char name[64]; } TexNodeOutput; /* comp channel matte */ diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h index cb72e396356..28c28bbf329 100644 --- a/source/blender/makesdna/DNA_object_force.h +++ b/source/blender/makesdna/DNA_object_force.h @@ -274,7 +274,7 @@ typedef struct SoftBody { /* general options */ float nodemass; /* softbody mass of *vertex* */ - char namedVG_Mass[32]; /* along with it introduce mass painting + char namedVG_Mass[64]; /* MAX_VGROUP_NAME */ /* along with it introduce mass painting starting to fix old bug .. nastyness that VG are indexes rather find them by name tag to find it -> jow20090613 */ float grav; /* softbody amount of gravitaion to apply */ @@ -289,7 +289,7 @@ typedef struct SoftBody { float maxgoal; float defgoal; /* default goal for vertices without vgroup */ short vertgroup; /* index starting at 1 */ - char namedVG_Softgoal[32]; /* starting to fix old bug .. nastyness that VG are indexes + char namedVG_Softgoal[64]; /* MAX_VGROUP_NAME */ /* starting to fix old bug .. nastyness that VG are indexes rather find them by name tag to find it -> jow20090613 */ short fuzzyness; /* */ @@ -297,7 +297,7 @@ typedef struct SoftBody { /* springs */ float inspring; /* softbody inner springs */ float infrict; /* softbody inner springs friction */ - char namedVG_Spring_K[32]; /* along with it introduce Spring_K painting + char namedVG_Spring_K[64]; /* MAX_VGROUP_NAME */ /* along with it introduce Spring_K painting starting to fix old bug .. nastyness that VG are indexes rather find them by name tag to find it -> jow20090613 */ diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 7f1239195ec..b8580b47269 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -61,11 +61,11 @@ struct bGPdata; /* Vertex Groups - Name Info */ typedef struct bDeformGroup { struct bDeformGroup *next, *prev; - char name[32]; + char name[64]; /* MAX_VGROUP_NAME */ /* need this flag for locking weights */ char flag, pad[7]; } bDeformGroup; -#define MAX_VGROUP_NAME 32 +#define MAX_VGROUP_NAME 64 /* bDeformGroup->flag */ #define DG_LOCK_WEIGHT 1 @@ -107,7 +107,7 @@ typedef struct Object { short type, partype; int par1, par2, par3; /* can be vertexnrs */ - char parsubstr[32]; /* String describing subobject info */ + char parsubstr[64]; /* String describing subobject info, MAX_ID_NAME-2 */ struct Object *parent, *track; /* if ob->proxy (or proxy_group), this object is proxy for object ob->proxy */ /* proxy_from is set in target back to the proxy. */ @@ -273,7 +273,7 @@ typedef struct ObHook { float cent[3]; /* visualization of hook */ float falloff; /* if not zero, falloff is distance where influence zero */ - char name[32]; + char name[64]; /* MAX_NAME */ int *indexar; int totindex, curindex; /* curindex is cache for fast lookup */ diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h index 07efd17df7f..4c3279c6527 100644 --- a/source/blender/makesdna/DNA_particle_types.h +++ b/source/blender/makesdna/DNA_particle_types.h @@ -261,7 +261,7 @@ typedef struct ParticleSystem struct ListBase targets; /* used for keyed and boid physics */ - char name[32]; /* particle system name */ + char name[64]; /* particle system name, MAX_NAME */ float imat[4][4]; /* used for duplicators */ float cfra, tree_frame, bvhtree_frame; @@ -269,7 +269,7 @@ typedef struct ParticleSystem int flag, totpart, totunexist, totchild, totcached, totchildcache; short recalc, target_psys, totkeyed, bakespace; - char bb_uvname[3][32]; /* billboard uv name */ + char bb_uvname[3][64]; /* billboard uv name, MAX_CUSTOMDATA_LAYER_NAME */ /* if you change these remember to update array lengths to PSYS_TOT_VG! */ short vgroup[12], vg_neg, rt3; /* vertex groups, 0==disable, 1==starting index */ diff --git a/source/blender/makesdna/DNA_property_types.h b/source/blender/makesdna/DNA_property_types.h index e74ae41a421..a36e362632b 100644 --- a/source/blender/makesdna/DNA_property_types.h +++ b/source/blender/makesdna/DNA_property_types.h @@ -43,7 +43,7 @@ typedef struct bProperty { struct bProperty *next, *prev; - char name[32]; + char name[64]; /* MAX_NAME */ short type, flag; int data; /* data should be 4 bytes to store int,float stuff */ void *poin; /* references data unless its a string which is malloc'd */ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 7d611acc551..d3eb4f12b2a 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -171,7 +171,7 @@ typedef struct AudioData { typedef struct SceneRenderLayer { struct SceneRenderLayer *next, *prev; - char name[32]; + char name[64]; /* MAX_NAME */ struct Material *mat_override; struct Group *light_override; @@ -804,8 +804,9 @@ typedef struct VPaint { typedef struct TransformOrientation { struct TransformOrientation *next, *prev; - char name[36]; + char name[64]; /* MAX_NAME */ float mat[3][3]; + int pad; } TransformOrientation; /* *************************************************************** */ diff --git a/source/blender/makesdna/DNA_sensor_types.h b/source/blender/makesdna/DNA_sensor_types.h index e7444b06898..80f19b30079 100644 --- a/source/blender/makesdna/DNA_sensor_types.h +++ b/source/blender/makesdna/DNA_sensor_types.h @@ -40,7 +40,7 @@ struct Material; /* ****************** SENSORS ********************* */ typedef struct bNearSensor { - char name[32]; + char name[64]; /* MAX_NAME */ float dist, resetdist; int lastval, pad; } bNearSensor; @@ -59,7 +59,7 @@ typedef struct bMouseSensor { } bMouseSensor; typedef struct bTouchSensor { - char name[32]; + char name[64]; /* MAX_NAME */ struct Material *ma; float dist, pad; } bTouchSensor; @@ -70,25 +70,25 @@ typedef struct bKeyboardSensor { /** * Name of the target property */ - char targetName[32]; + char targetName[64]; /* MAX_NAME */ /** * Name of the toggle property */ - char toggleName[32]; + char toggleName[64]; /* MAX_NAME */ } bKeyboardSensor; typedef struct bPropertySensor { int type; int pad; - char name[32]; - char value[32]; - char maxvalue[32]; + char name[64]; /* MAX_NAME */ + char value[64]; + char maxvalue[64]; } bPropertySensor; typedef struct bActuatorSensor { int type; int pad; - char name[32]; + char name[64]; /* MAX_NAME */ } bActuatorSensor; typedef struct bDelaySensor { @@ -99,8 +99,8 @@ typedef struct bDelaySensor { } bDelaySensor; typedef struct bCollisionSensor { - char name[32]; /* property name */ - char materialName[32]; /* material */ + char name[64]; /* property name. MAX_NAME */ + char materialName[64]; /* material */ // struct Material *ma; // XXX remove materialName short damptimer, damp; short mode; /* flag to choose material or property */ @@ -108,23 +108,23 @@ typedef struct bCollisionSensor { } bCollisionSensor; typedef struct bRadarSensor { - char name[32]; + char name[64]; /* MAX_NAME */ float angle; float range; short flag, axis; } bRadarSensor; typedef struct bRandomSensor { - char name[32]; + char name[64]; /* MAX_NAME */ int seed; int delay; } bRandomSensor; typedef struct bRaySensor { - char name[32]; + char name[64]; /* MAX_NAME */ float range; - char propname[32]; - char matname[32]; + char propname[64]; + char matname[64]; //struct Material *ma; // XXX remove materialName short mode; short pad1; @@ -132,8 +132,8 @@ typedef struct bRaySensor { } bRaySensor; typedef struct bArmatureSensor { - char posechannel[32]; - char constraint[32]; + char posechannel[64]; /* MAX_NAME */ + char constraint[64]; /* MAX_NAME */ int type; float value; } bArmatureSensor; @@ -147,12 +147,12 @@ typedef struct bMessageSensor { /** * Can be used to filter on subjects like this */ - char subject[32]; + char subject[64]; /** * (Possible future use) body to filter on */ - char body[32]; + char body[64]; } bMessageSensor; typedef struct bSensor { @@ -160,7 +160,7 @@ typedef struct bSensor { /* pulse and freq are the bool toggle and frame count for pulse mode */ short type, otype, flag, pulse; short freq, totlinks, pad1, pad2; - char name[32]; + char name[64]; /* MAX_NAME */ void *data; struct bController **links; @@ -175,7 +175,7 @@ typedef struct bSensor { } bSensor; typedef struct bJoystickSensor { - char name[32]; + char name[64]; /* MAX_NAME */ char type; char joyindex; short flag; diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index aab20dbeee1..fa501de8d6d 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -127,7 +127,7 @@ typedef struct Sequence { struct Sequence *next, *prev; void *tmp; /* tmp var for copying, and tagging for linked selection */ void *lib; /* needed (to be like ipo), else it will raise libdata warnings, this should never be used */ - char name[24]; /* SEQ_NAME_MAXSTR - name, set by default and needs to be unique, for RNA paths */ + char name[64]; /* SEQ_NAME_MAXSTR - name, set by default and needs to be unique, for RNA paths */ int flag, type; /*flags bitmap (see below) and the type of sequence*/ int len; /* the length of the contense of this strip - before handles are applied */ @@ -255,7 +255,7 @@ typedef struct SpeedControlVars { #define SEQ_SPEED_COMPRESS_IPO_Y 4 /* ***************** SEQUENCE ****************** */ -#define SEQ_NAME_MAXSTR 24 +#define SEQ_NAME_MAXSTR 64 /* seq->flag */ #define SEQ_LEFTSEL (1<<1) diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index 82ffa82cf60..e711124d39c 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -60,7 +60,7 @@ typedef struct MTex { short texco, mapto, maptoneg, blendtype; struct Object *object; struct Tex *tex; - char uvname[32]; + char uvname[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ char projx, projy, projz, mapping; float ofs[3], size[3], rot; diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h index 131c540ac47..a8b3a7183cf 100644 --- a/source/blender/makesdna/DNA_tracking_types.h +++ b/source/blender/makesdna/DNA_tracking_types.h @@ -75,7 +75,7 @@ typedef struct MovieTrackingMarker { typedef struct MovieTrackingTrack { struct MovieTrackingTrack *next, *prev; - char name[24]; + char name[64]; /* MAX_NAME */ /* ** setings ** */ float pat_min[2], pat_max[2]; /* positions of left-bottom and right-top corners of pattern (in unified 0..1 space) */ @@ -178,7 +178,7 @@ typedef struct MovieTrackingReconstruction { typedef struct MovieTrackingObject { struct MovieTrackingObject *next, *prev; - char name[24]; /* Name of tracking object */ + char name[64]; /* Name of tracking object, MAX_NAME */ int flag; float scale; /* scale of object solution in amera space */ diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index ae026b0bcc9..58c3f091d6d 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -173,7 +173,7 @@ typedef struct View3D { struct View3D *localvd; /* allocated backup of its self while in localview */ - char ob_centre_bone[32]; /* optional string for armature bone to define center */ + char ob_centre_bone[64]; /* optional string for armature bone to define center, MAXBONENAME */ unsigned int lay; int layact; diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index 57989424d4a..156d2ebbb20 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -168,7 +168,7 @@ typedef struct wmWindow { struct bScreen *screen; /* active screen */ struct bScreen *newscreen; /* temporary when switching */ - char screenname[32]; /* MAX_ID_NAME for matching window with active screen after file read */ + char screenname[64]; /* MAX_ID_NAME for matching window with active screen after file read */ short posx, posy, sizex, sizey; /* window coords */ short windowstate; /* borderless, full */ diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 612c34d1c92..6098e885df5 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -867,8 +867,10 @@ static void rna_def_camera_actuator(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_axis_items[] ={ - {ACT_CAMERA_X, "X", 0, "X", "Camera tries to get behind the X axis"}, - {ACT_CAMERA_Y, "Y", 0, "Y", "Camera tries to get behind the Y axis"}, + {OB_POSX, "POS_X", 0, "+X", "Camera tries to get behind the X axis"}, + {OB_POSY, "POS_Y", 0, "+Y", "Camera tries to get behind the Y axis"}, + {OB_NEGX, "NEG_X", 0, "-X", "Camera tries to get behind the -X axis"}, + {OB_NEGY, "NEG_Y", 0, "-Y", "Camera tries to get behind the -Y axis"}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "CameraActuator", "Actuator"); @@ -905,7 +907,7 @@ static void rna_def_camera_actuator(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Damping", "Strength of the constraint that drives the camera behind the target"); RNA_def_property_update(prop, NC_LOGIC, NULL); - /* x/y */ + /* +x/+y/-x/-y */ prop= RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "axis"); RNA_def_property_enum_items(prop, prop_axis_items); diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 9e7f4a349e7..7059c001283 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -107,6 +107,15 @@ static void rna_Image_fields_update(Main *UNUSED(bmain), Scene *UNUSED(scene), P BKE_image_release_ibuf(ima, lock); } +static void rna_Image_free_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + Image *ima= ptr->id.data; + BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE); + WM_main_add_notifier(NC_IMAGE|NA_EDITED, &ima->id); + DAG_id_tag_update(&ima->id, 0); +} + + static void rna_Image_reload_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Image *ima= ptr->id.data; @@ -476,12 +485,12 @@ static void rna_def_image(BlenderRNA *brna) prop= RNA_def_property(srna, "use_premultiply", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_DO_PREMUL); RNA_def_property_ui_text(prop, "Premultiply", "Convert RGB from key alpha to premultiplied alpha"); - RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_reload_update"); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_free_update"); prop= RNA_def_property(srna, "use_color_unpremultiply", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_CM_PREDIVIDE); RNA_def_property_ui_text(prop, "Color Unpremultiply", "For premultiplied alpha images, do color space conversion on colors without alpha, to avoid fringing for images with light backgrounds"); - RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_reload_update"); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_free_update"); prop= RNA_def_property(srna, "is_dirty", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_Image_dirty_get", NULL); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index cc046a75a8f..d38d2270fc5 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -1972,7 +1972,7 @@ static void rna_def_modifier_explode(BlenderRNA *brna) prop= RNA_def_property(srna, "particle_uv", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "uvname"); - RNA_def_property_string_maxlength(prop, 32); + RNA_def_property_string_maxlength(prop, MAX_CUSTOMDATA_LAYER_NAME); RNA_def_property_ui_text(prop, "Particle UV", "UV map to change with particle age"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); } diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 05b33877f10..2b5925179d8 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -3234,7 +3234,7 @@ static void rna_def_group_sockets_api(BlenderRNA *brna, PropertyRNA *cprop, int func= RNA_def_function(srna, "new", (in_out==SOCK_IN ? "rna_NodeTree_input_new" : "rna_NodeTree_output_new")); RNA_def_function_ui_description(func, "Add a socket to the group tree"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - RNA_def_string(func, "name", "Socket", 32, "Name", "Name of the socket"); + RNA_def_string(func, "name", "Socket", MAX_NAME, "Name", "Name of the socket"); RNA_def_enum(func, "type", node_socket_type_items, SOCK_FLOAT, "Type", "Type of socket"); /* return value */ parm= RNA_def_pointer(func, "socket", "NodeSocket", "", "New socket"); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index d7a2ddd62d0..a5eb610dd29 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -2448,15 +2448,20 @@ static void rna_def_dupli_object(BlenderRNA *brna) prop= RNA_def_property(srna, "matrix_original", PROP_FLOAT, PROP_MATRIX); RNA_def_property_float_sdna(prop, NULL, "omat"); RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE|PROP_EDITABLE); RNA_def_property_ui_text(prop, "Object Matrix", "The original matrix of this object before it was duplicated"); prop= RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX); RNA_def_property_float_sdna(prop, NULL, "mat"); RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE|PROP_EDITABLE); RNA_def_property_ui_text(prop, "Object Duplicate Matrix", "Object duplicate transformation matrix"); + prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "no_draw", 0); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE|PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Hide", "Don't show dupli object in viewport or render"); + /* TODO: DupliObject has more properties that can be wrapped */ } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 97770f83a7a..1eb7457fed6 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1001,7 +1001,7 @@ static void rna_RenderSettings_color_management_update(Main *bmain, Scene *UNUSE WM_main_add_notifier(NC_NODE|NA_EDITED, node); if (node->type == CMP_NODE_IMAGE) - BKE_image_signal((Image *)node->id, NULL, IMA_SIGNAL_RELOAD); + BKE_image_signal((Image *)node->id, NULL, IMA_SIGNAL_FREE); } } } diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 16748d4c8ac..01f3889d684 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -807,7 +807,7 @@ static void rna_def_trackingTrack(BlenderRNA *brna) prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Name", "Unique name of track"); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_trackingTrack_name_set"); - RNA_def_property_string_maxlength(prop, MAX_ID_NAME); + RNA_def_property_string_maxlength(prop, MAX_ID_NAME-2); RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL); RNA_def_struct_name_property(srna, prop); @@ -1179,7 +1179,7 @@ static void rna_def_trackingObject(BlenderRNA *brna) prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Name", "Unique name of object"); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_trackingObject_name_set"); - RNA_def_property_string_maxlength(prop, MAX_ID_NAME); + RNA_def_property_string_maxlength(prop, MAX_ID_NAME-2); RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL); RNA_def_struct_name_property(srna, prop); diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c index 55fcf1a9367..55a2cab4a76 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -69,7 +69,7 @@ static void copyData(ModifierData *md, ModifierData *target) tamd->object = amd->object; tamd->deformflag = amd->deformflag; tamd->multi = amd->multi; - BLI_strncpy(tamd->defgrp_name, amd->defgrp_name, 32); + BLI_strncpy(tamd->defgrp_name, amd->defgrp_name, sizeof(tamd->defgrp_name)); } static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md)) diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index 57d8943f681..1a3f8cdb7f3 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -74,7 +74,7 @@ static void copyData(ModifierData *md, ModifierData *target) tbmd->lim_flags = bmd->lim_flags; tbmd->e_flags = bmd->e_flags; tbmd->bevel_angle = bmd->bevel_angle; - BLI_strncpy(tbmd->defgrp_name, bmd->defgrp_name, 32); + BLI_strncpy(tbmd->defgrp_name, bmd->defgrp_name, sizeof(tbmd->defgrp_name)); } static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c index fa31018e0f6..75aecc4f5af 100644 --- a/source/blender/modifiers/intern/MOD_cast.c +++ b/source/blender/modifiers/intern/MOD_cast.c @@ -76,7 +76,7 @@ static void copyData(ModifierData *md, ModifierData *target) tcmd->flag = cmd->flag; tcmd->type = cmd->type; tcmd->object = cmd->object; - BLI_strncpy(tcmd->defgrp_name, cmd->defgrp_name, 32); + BLI_strncpy(tcmd->defgrp_name, cmd->defgrp_name, sizeof(tcmd->defgrp_name)); } static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c index 85a46713894..945c5c5a583 100644 --- a/source/blender/modifiers/intern/MOD_curve.c +++ b/source/blender/modifiers/intern/MOD_curve.c @@ -64,7 +64,7 @@ static void copyData(ModifierData *md, ModifierData *target) tcmd->defaxis = cmd->defaxis; tcmd->object = cmd->object; - BLI_strncpy(tcmd->name, cmd->name, 32); + BLI_strncpy(tcmd->name, cmd->name, sizeof(tcmd->name)); } static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index 38a0e2baa34..e0972ff2d32 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -74,11 +74,11 @@ static void copyData(ModifierData *md, ModifierData *target) tdmd->texture = dmd->texture; tdmd->strength = dmd->strength; tdmd->direction = dmd->direction; - BLI_strncpy(tdmd->defgrp_name, dmd->defgrp_name, 32); + BLI_strncpy(tdmd->defgrp_name, dmd->defgrp_name, sizeof(tdmd->defgrp_name)); tdmd->midlevel = dmd->midlevel; tdmd->texmapping = dmd->texmapping; tdmd->map_object = dmd->map_object; - BLI_strncpy(tdmd->uvlayer_name, dmd->uvlayer_name, 32); + BLI_strncpy(tdmd->uvlayer_name, dmd->uvlayer_name, sizeof(tdmd->uvlayer_name)); } static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index ecacbe4a332..97e406c6960 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -71,8 +71,8 @@ static void copyData(ModifierData *md, ModifierData *target) thmd->totindex = hmd->totindex; thmd->indexar = MEM_dupallocN(hmd->indexar); memcpy(thmd->parentinv, hmd->parentinv, sizeof(hmd->parentinv)); - BLI_strncpy(thmd->name, hmd->name, 32); - BLI_strncpy(thmd->subtarget, hmd->subtarget, 32); + BLI_strncpy(thmd->name, hmd->name, sizeof(thmd->name)); + BLI_strncpy(thmd->subtarget, hmd->subtarget, sizeof(thmd->subtarget)); } static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c index bc4d9147089..605c057c855 100644 --- a/source/blender/modifiers/intern/MOD_lattice.c +++ b/source/blender/modifiers/intern/MOD_lattice.c @@ -56,7 +56,7 @@ static void copyData(ModifierData *md, ModifierData *target) LatticeModifierData *tlmd = (LatticeModifierData*) target; tlmd->object = lmd->object; - BLI_strncpy(tlmd->name, lmd->name, 32); + BLI_strncpy(tlmd->name, lmd->name, sizeof(tlmd->name)); } static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c index 1eaef86cea2..01b012655d0 100644 --- a/source/blender/modifiers/intern/MOD_smooth.c +++ b/source/blender/modifiers/intern/MOD_smooth.c @@ -67,7 +67,7 @@ static void copyData(ModifierData *md, ModifierData *target) tsmd->fac = smd->fac; tsmd->repeat = smd->repeat; tsmd->flag = smd->flag; - BLI_strncpy(tsmd->defgrp_name, smd->defgrp_name, 32); + BLI_strncpy(tsmd->defgrp_name, smd->defgrp_name, sizeof(tsmd->defgrp_name)); } static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c index 5a1eb6daae2..7fdbea19cfb 100644 --- a/source/blender/modifiers/intern/MOD_util.c +++ b/source/blender/modifiers/intern/MOD_util.c @@ -100,7 +100,7 @@ void get_texture_coords(MappingInfoModifierData *dmd, Object *ob, char *done = MEM_callocN(sizeof(*done) * numVerts, "get_texture_coords done"); int numPolys = dm->getNumPolys(dm); - char uvname[32]; + char uvname[MAX_CUSTOMDATA_LAYER_NAME]; MLoopUV *mloop_uv; CustomData_validate_layer_name(&dm->loopData, CD_MLOOPUV, dmd->uvlayer_name, uvname); diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c index 47c8e2a7d05..603d379c357 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.c +++ b/source/blender/modifiers/intern/MOD_uvproject.c @@ -158,7 +158,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, Projector projectors[MOD_UVPROJECT_MAXPROJECTORS]; int num_projectors = 0; float aspect; - char uvname[32]; + char uvname[MAX_CUSTOMDATA_LAYER_NAME]; float aspx= umd->aspectx ? umd->aspectx : 1.0f; float aspy= umd->aspecty ? umd->aspecty : 1.0f; float scax= umd->scalex ? umd->scalex : 1.0f; diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c index cb2f6f4d6bc..15f78e15073 100644 --- a/source/blender/modifiers/intern/MOD_wave.c +++ b/source/blender/modifiers/intern/MOD_wave.c @@ -97,7 +97,7 @@ static void copyData(ModifierData *md, ModifierData *target) twmd->texture = wmd->texture; twmd->map_object = wmd->map_object; twmd->texmapping = wmd->texmapping; - BLI_strncpy(twmd->defgrp_name, wmd->defgrp_name, 32); + BLI_strncpy(twmd->defgrp_name, wmd->defgrp_name, sizeof(twmd->defgrp_name)); } static int dependsOnTime(ModifierData *UNUSED(md)) diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c index 5631b7e716a..9794635e428 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.c +++ b/source/blender/modifiers/intern/MOD_weightvg_util.c @@ -112,7 +112,7 @@ void weightvg_do_map(int num, float *new_w, short falloff_type, CurveMapping *cm * XXX The standard “factor” value is assumed in [0.0, 1.0] range. Else, weird results might appear. */ void weightvg_do_mask(int num, const int *indices, float *org_w, const float *new_w, - Object *ob, DerivedMesh *dm, float fact, const char defgrp_name[32], + Object *ob, DerivedMesh *dm, float fact, const char defgrp_name[MAX_VGROUP_NAME], Tex *texture, int tex_use_channel, int tex_mapping, Object *tex_map_object, const char *tex_uvlayer_name) { diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.h b/source/blender/modifiers/intern/MOD_weightvg_util.h index 2f364a2017f..5ae1e991073 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.h +++ b/source/blender/modifiers/intern/MOD_weightvg_util.h @@ -73,7 +73,7 @@ void weightvg_do_map(int num, float *new_w, short mode, struct CurveMapping *cma * XXX The standard “factor” value is assumed in [0.0, 1.0] range. Else, weird results might appear. */ void weightvg_do_mask(int num, const int *indices, float *org_w, const float *new_w, Object *ob, - DerivedMesh *dm, float fact, const char defgrp_name[32], Tex *texture, + DerivedMesh *dm, float fact, const char defgrp_name[MAX_VGROUP_NAME], Tex *texture, int tex_use_channel, int tex_mapping, Object *tex_map_object, const char *tex_uvlayer_name); diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index d6a1c50162b..93456d39c9c 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -604,8 +604,8 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview) if(ntree->progress && totnode) ntree->progress(ntree->prh, (1.0f - curnode/(float)totnode)); if(ntree->stats_draw) { - char str[64]; - sprintf(str, "Compositing %d %s", curnode, node->name); + char str[128]; + BLI_snprintf(str, sizeof(str), "Compositing %d %s", curnode, node->name); ntree->stats_draw(ntree->sdh, str); } curnode--; diff --git a/source/blender/nodes/texture/nodes/node_texture_output.c b/source/blender/nodes/texture/nodes/node_texture_output.c index 0ed6d232b81..829cd06dfc0 100644 --- a/source/blender/nodes/texture/nodes/node_texture_output.c +++ b/source/blender/nodes/texture/nodes/node_texture_output.c @@ -103,8 +103,8 @@ static void unique_name(bNode *node) } else { suffix = 0; new_len = len + 4; - if(new_len > 31) - new_len = 31; + if(new_len > (sizeof(tno->name) - 1)) + new_len = (sizeof(tno->name) - 1); } new_name = MEM_mallocN(new_len + 1, "new_name"); diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c index db3519a3056..ecf65275483 100644 --- a/source/blender/python/generic/bpy_internal_import.c +++ b/source/blender/python/generic/bpy_internal_import.c @@ -101,7 +101,7 @@ void bpy_text_filename_get(char *fn, size_t fn_len, Text *text) PyObject *bpy_text_import(Text *text) { char *buf = NULL; - char modulename[24]; + char modulename[MAX_ID_NAME+2]; int len; if (!text->compiled) { diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c index c058ee1d4f0..516c0afa883 100644 --- a/source/blender/python/generic/idprop_py_api.c +++ b/source/blender/python/generic/idprop_py_api.c @@ -249,7 +249,7 @@ static int BPy_IDGroup_SetName(BPy_IDProperty *self, PyObject *value, void *UNUS name = _PyUnicode_AsStringAndSize(value, &name_size); if (name_size > MAX_IDPROP_NAME) { - PyErr_SetString(PyExc_TypeError, "string length cannot exceed 31 characters!"); + PyErr_SetString(PyExc_TypeError, "string length cannot exceed 63 characters!"); return -1; } @@ -359,7 +359,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty Py_ssize_t name_size; name = _PyUnicode_AsStringAndSize(name_obj, &name_size); if (name_size > MAX_IDPROP_NAME) { - return "the length of IDProperty names is limited to 31 characters"; + return "the length of IDProperty names is limited to 63 characters"; } } diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index 43d03ec60a4..f414be60b0a 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -36,6 +36,7 @@ /* ------------------------------------------------------------------------- */ #include "DNA_color_types.h" +#include "DNA_customdata_types.h" #include "DNA_scene_types.h" #include "DNA_world_types.h" #include "DNA_object_types.h" @@ -306,8 +307,8 @@ typedef struct ObjectRen { struct HaloRen **bloha; struct StrandBuffer *strandbuf; - char (*mtface)[32]; - char (*mcol)[32]; + char (*mtface)[MAX_CUSTOMDATA_LAYER_NAME]; + char (*mcol)[MAX_CUSTOMDATA_LAYER_NAME]; int actmtface, actmcol, bakemtface; float obmat[4][4]; /* only used in convertblender.c, for instancing */ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 2ab876b2165..638a94db20a 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -939,7 +939,7 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op) int width= 300; - block= uiBeginBlock(C, ar, "redo_popup", UI_EMBOSS); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockClearFlag(block, UI_BLOCK_LOOP); uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1|UI_BLOCK_MOVEMOUSE_QUIT); @@ -1015,7 +1015,7 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *ar, void *userData) uiLayout *layout; uiStyle *style= UI_GetStyle(); - block = uiBeginBlock(C, ar, "operator dialog", UI_EMBOSS); + block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockClearFlag(block, UI_BLOCK_LOOP); uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1|UI_BLOCK_MOVEMOUSE_QUIT); @@ -1056,7 +1056,7 @@ static uiBlock *wm_operator_ui_create(bContext *C, ARegion *ar, void *userData) uiLayout *layout; uiStyle *style= UI_GetStyle(); - block= uiBeginBlock(C, ar, "opui_popup", UI_EMBOSS); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockClearFlag(block, UI_BLOCK_LOOP); uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1|UI_BLOCK_MOVEMOUSE_QUIT); @@ -1257,8 +1257,9 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar version_str = &version_buf[0]; revision_str = &revision_buf[0]; - sprintf(version_str, "%d.%02d.%d", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION); - sprintf(revision_str, "r%s", build_rev); + BLI_snprintf(version_str, sizeof(version_str), + "%d.%02d.%d", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION); + BLI_snprintf(revision_str, sizeof(revision_str), "r%s", build_rev); BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.dpi); ver_width = (int)BLF_width(style->widgetlabel.uifont_id, version_str) + 5; diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index db1c3fbd07e..4f79121f38e 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -383,7 +383,7 @@ void uiItemBooleanO(struct uiLayout *layout, char *name, int icon, char *opname, void uiItemIntO(struct uiLayout *layout, char *name, int icon, char *opname, char *propname, int value){} void uiItemFloatO(struct uiLayout *layout, char *name, int icon, char *opname, char *propname, float value){} void uiItemStringO(struct uiLayout *layout, char *name, int icon, char *opname, char *propname, char *value){} -void uiItemL(struct uiLayout *layout, char *name, int icon){} +void uiItemL(struct uiLayout *layout, const char *name, int icon){} void uiItemM(struct uiLayout *layout, struct bContext *C, char *menuname, char *name, int icon){} void uiItemS(struct uiLayout *layout){} void uiItemFullR(struct uiLayout *layout, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int flag, char *name, int icon){} diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index f4b173763d3..be14400f33a 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -300,7 +300,7 @@ void BL_ConvertActuators(const char* maggiename, camact->height, camact->min, camact->max, - camact->axis=='x', + camact->axis, camact->damping); baseact = tmpcamact; } diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index d4aae68dafb..cd0aff0a87b 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -53,7 +53,7 @@ KX_CameraActuator::KX_CameraActuator( float hght, float minhght, float maxhght, - bool xytog, + short axis, float damping ): SCA_IActuator(gameobj, KX_ACT_CAMERA), @@ -61,7 +61,7 @@ KX_CameraActuator::KX_CameraActuator( m_height (hght), m_minHeight (minhght), m_maxHeight (maxhght), - m_x (xytog), + m_axis(axis), m_damping (damping) { if (m_ob) @@ -264,23 +264,50 @@ bool KX_CameraActuator::Update(double curtime, bool frame) /* C4: camera behind actor */ - if (m_x) { - fp1[0] = actormat[0][0]; - fp1[1] = actormat[1][0]; - fp1[2] = actormat[2][0]; - - fp2[0] = frommat[0][0]; - fp2[1] = frommat[1][0]; - fp2[2] = frommat[2][0]; - } - else { - fp1[0] = actormat[0][1]; - fp1[1] = actormat[1][1]; - fp1[2] = actormat[2][1]; - - fp2[0] = frommat[0][1]; - fp2[1] = frommat[1][1]; - fp2[2] = frommat[2][1]; + switch (m_axis) { + case OB_POSX: + /* X */ + fp1[0] = actormat[0][0]; + fp1[1] = actormat[1][0]; + fp1[2] = actormat[2][0]; + + fp2[0] = frommat[0][0]; + fp2[1] = frommat[1][0]; + fp2[2] = frommat[2][0]; + break; + case OB_POSY: + /* Y */ + fp1[0] = actormat[0][1]; + fp1[1] = actormat[1][1]; + fp1[2] = actormat[2][1]; + + fp2[0] = frommat[0][1]; + fp2[1] = frommat[1][1]; + fp2[2] = frommat[2][1]; + break; + case OB_NEGX: + /* -X */ + fp1[0] = -actormat[0][0]; + fp1[1] = -actormat[1][0]; + fp1[2] = -actormat[2][0]; + + fp2[0] = frommat[0][0]; + fp2[1] = frommat[1][0]; + fp2[2] = frommat[2][0]; + break; + case OB_NEGY: + /* -Y */ + fp1[0] = -actormat[0][1]; + fp1[1] = -actormat[1][1]; + fp1[2] = -actormat[2][1]; + + fp2[0] = frommat[0][1]; + fp2[1] = frommat[1][1]; + fp2[2] = frommat[2][1]; + break; + default: + assert(0); + break; } inp= fp1[0]*fp2[0] + fp1[1]*fp2[1] + fp1[2]*fp2[2]; @@ -389,7 +416,7 @@ PyAttributeDef KX_CameraActuator::Attributes[] = { KX_PYATTRIBUTE_FLOAT_RW("min",-FLT_MAX,FLT_MAX,KX_CameraActuator,m_minHeight), KX_PYATTRIBUTE_FLOAT_RW("max",-FLT_MAX,FLT_MAX,KX_CameraActuator,m_maxHeight), KX_PYATTRIBUTE_FLOAT_RW("height",-FLT_MAX,FLT_MAX,KX_CameraActuator,m_height), - KX_PYATTRIBUTE_BOOL_RW("useXY",KX_CameraActuator,m_x), + KX_PYATTRIBUTE_SHORT_RW("axis", 0, 3, true, KX_CameraActuator,m_axis), KX_PYATTRIBUTE_RW_FUNCTION("object", KX_CameraActuator, pyattr_get_object, pyattr_set_object), KX_PYATTRIBUTE_FLOAT_RW("damping",0.f,10.f,KX_CameraActuator,m_damping), {NULL} diff --git a/source/gameengine/Ketsji/KX_CameraActuator.h b/source/gameengine/Ketsji/KX_CameraActuator.h index a6344ae380a..1cae676fe3f 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.h +++ b/source/gameengine/Ketsji/KX_CameraActuator.h @@ -70,8 +70,8 @@ private : /** max (float), */ float m_maxHeight; - /** xy toggle (pick one): true == x, false == y */ - bool m_x; + /** axis the camera tries to get behind: +x/+y/-x/-y */ + short m_axis; /** damping (float), */ float m_damping; @@ -97,7 +97,7 @@ private : float hght, float minhght, float maxhght, - bool xytog, + short axis, float damping ); |