Index: source/blender/blenkernel/intern/image.c =================================================================== --- source/blender/blenkernel/intern/image.c (revision 14383) +++ source/blender/blenkernel/intern/image.c (working copy) @@ -1236,24 +1236,16 @@ void BKE_makepicstring(char *string, char *base, int frame, int imtype) { - short i, len, digits= 4; /* digits in G.scene? */ - char num[10]; - if (string==NULL) return; BLI_strncpy(string, base, FILE_MAX - 10); /* weak assumption */ + + /* if we dont have any #'s to insert numbers into, use 4 numbers by default */ + if (strchr(string, '#')==NULL) + strcat(string, "####"); /* 4 numbers */ + BLI_convertstringcode(string, G.sce, frame); - len= strlen(string); - - i= digits - sprintf(num, "%d", frame); - for(; i>0; i--){ - string[len]= '0'; - len++; - } - string[len]= 0; - strcat(string, num); - if(G.scene->r.scemode & R_EXTENSION) BKE_add_image_extension(string, imtype); Index: source/blender/blenkernel/intern/particle_system.c =================================================================== --- source/blender/blenkernel/intern/particle_system.c (revision 14383) +++ source/blender/blenkernel/intern/particle_system.c (working copy) @@ -4546,7 +4546,7 @@ (ob->fluidsimSettings)) { ParticleSettings *part = psys->part; ParticleData *pa=0; - char *suffix = "fluidsurface_particles_#"; + char *suffix = "fluidsurface_particles_####"; char *suffix2 = ".gz"; char filename[256]; char debugStrBuffer[256]; Index: source/blender/blenkernel/intern/DerivedMesh.c =================================================================== --- source/blender/blenkernel/intern/DerivedMesh.c (revision 14383) +++ source/blender/blenkernel/intern/DerivedMesh.c (working copy) @@ -3312,9 +3312,9 @@ srcob->data = srcob->fluidsimSettings->orgMesh; return; } else if(displaymode==2) { - strcat(targetDir,"fluidsurface_preview_#"); + strcat(targetDir,"fluidsurface_preview_####"); } else { // 3 - strcat(targetDir,"fluidsurface_final_#"); + strcat(targetDir,"fluidsurface_final_####"); } BLI_convertstringcode(targetDir, G.sce, curFrame); // fixed #frame-no strcpy(targetFile,targetDir); Index: source/blender/blenkernel/intern/effect.c =================================================================== --- source/blender/blenkernel/intern/effect.c (revision 14383) +++ source/blender/blenkernel/intern/effect.c (working copy) @@ -1711,7 +1711,7 @@ if( (1) && (ob->fluidsimFlag & OB_FLUIDSIM_ENABLE) && // broken, disabled for now! (ob->fluidsimSettings) && (ob->fluidsimSettings->type == OB_FLUIDSIM_PARTICLE)) { - char *suffix = "fluidsurface_particles_#"; + char *suffix = "fluidsurface_particles_####"; char *suffix2 = ".gz"; char filename[256]; char debugStrBuffer[256]; Index: source/blender/blenlib/intern/util.c =================================================================== --- source/blender/blenlib/intern/util.c (revision 14383) +++ source/blender/blenlib/intern/util.c (working copy) @@ -41,6 +41,7 @@ #include #include #include +#include /* for log10 */ #include "MEM_guardedalloc.h" @@ -1027,7 +1028,8 @@ int BLI_convertstringcode(char *path, const char *basepath, int framenum) { - int len, wasrelative; + int wasrelative; + int ch_sta, ch_end; char tmp[FILE_MAX]; char base[FILE_MAX]; char vol[3] = {'\0', '\0', '\0'}; @@ -1082,12 +1084,53 @@ MEM_freeN(filepart); } - - len= strlen(tmp); - if(len && tmp[len-1]=='#') { - sprintf(tmp+len-1, "%04d", framenum); + + + /* Insert current frame: file### -> file001 */ + ch_end = 0; + for (ch_sta = 0; tmp[ch_sta] != '\0'; ch_sta++) { + if (tmp[ch_sta] == '#') { + ch_end = ch_sta+1; + while (tmp[ch_end] == '#') { + ch_end++; + } + break; + } } - + if (ch_end) { /* warning, ch_end is the last # +1 */ + /* Add the frame number? */ + short numlen, hashlen; + char format[16]; /* 6 is realistically the maxframe (300000), so 8 should be enough, but 16 to be safe. */ + + numlen = 1 + (int)log10((double)framenum); /* this is the number of chars in the number */ + hashlen = ch_end - ch_sta; + + sprintf(format, "%d", framenum); + + if (numlen==hashlen) { /* simple case */ + memcpy(tmp+ch_sta, format, numlen); + } else if (numlen < hashlen) { + memcpy(tmp+ch_sta + (hashlen-numlen), format, numlen); /*dont copy the string terminator */ + memset(tmp+ch_sta, '0', hashlen-numlen); + } else { + /* number is longer then number of #'s */ + if (tmp[ch_end] == '\0') { /* hashes are last, no need to move any string*/ + memcpy(tmp+ch_sta, format, numlen+1); /* add 1 to get the string terminator \0 */ + } else { + /* we need to move the end characters */ + int i = strlen(tmp); /* +1 to copy the string terminator */ + int j = i + (numlen-hashlen); /* from/to */ + while (i >= ch_end) { + tmp[j] = tmp[i]; + i--; + j--; + } + memcpy(tmp + ch_sta, format, numlen); + } + } + } + /* done with file### stuff */ + strcpy(path, tmp); #ifdef WIN32 /* skip first two chars, which in case of