This commit is contained in:
2011-05-05 10:14:56 +00:00
211 changed files with 5443 additions and 3029 deletions

View File

@@ -1274,6 +1274,12 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
writestruct(wd, DATA, "MDefInfluence", mmd->totinfluence, mmd->dyninfluences);
writedata(wd, DATA, sizeof(int)*mmd->totvert, mmd->dynverts);
}
else if (md->type==eModifierType_Warp) {
WarpModifierData *tmd = (WarpModifierData*) md;
if(tmd->curfalloff) {
write_curvemapping(wd, tmd->curfalloff);
}
}
}
}
@@ -1698,6 +1704,7 @@ static void write_textures(WriteData *wd, ListBase *idbase)
if(tex->type == TEX_POINTDENSITY && tex->pd) {
writestruct(wd, DATA, "PointDensity", 1, tex->pd);
if(tex->pd->coba) writestruct(wd, DATA, "ColorBand", 1, tex->pd->coba);
if(tex->pd->falloff_curve) write_curvemapping(wd, tex->pd->falloff_curve);
}
if(tex->type == TEX_VOXELDATA && tex->vd) writestruct(wd, DATA, "VoxelData", 1, tex->vd);
@@ -2623,187 +2630,3 @@ int BLO_write_file_mem(Main *mainvar, MemFile *compare, MemFile *current, int wr
if(err==0) return 1;
return 0;
}
/* Runtime writing */
static char *get_runtime_path(char *exename) {
char *installpath= get_install_dir();
if (!installpath) {
return NULL;
}
else {
char *path= BLI_sprintfN("%s%c%s", installpath, SEP, exename);
if (path == NULL) {
MEM_freeN(installpath);
return NULL;
}
MEM_freeN(installpath);
return path;
}
}
#ifdef __APPLE__
static int recursive_copy_runtime(const char *outname, char *exename, ReportList *reports)
{
char *runtime = get_runtime_path(exename);
char command[2 * (FILE_MAXDIR+FILE_MAXFILE) + 32];
int progfd = -1, error= 0;
if (!runtime) {
BKE_report(reports, RPT_ERROR, "Unable to find runtime");
error= 1;
goto cleanup;
}
//printf("runtimepath %s\n", runtime);
progfd= open(runtime, O_BINARY|O_RDONLY, 0);
if (progfd==-1) {
BKE_report(reports, RPT_ERROR, "Unable to find runtime");
error= 1;
goto cleanup;
}
sprintf(command, "/bin/cp -R \"%s\" \"%s\"", runtime, outname);
//printf("command %s\n", command);
if (system(command) == -1) {
BKE_report(reports, RPT_ERROR, "Couldn't copy runtime");
error= 1;
}
cleanup:
if (progfd!=-1)
close(progfd);
if (runtime)
MEM_freeN(runtime);
return !error;
}
int BLO_write_runtime(Main *mainvar, const char *file, char *exename, ReportList *reports)
{
char gamename[FILE_MAXDIR+FILE_MAXFILE];
int outfd = -1, error= 0;
// remove existing file / bundle
//printf("Delete file %s\n", file);
BLI_delete(file, 0, TRUE);
if (!recursive_copy_runtime(file, exename, reports)) {
error= 1;
goto cleanup;
}
BLI_snprintf(gamename, sizeof(gamename), "%s/Contents/Resources/game.blend", file);
//printf("gamename %s\n", gamename);
outfd= open(gamename, O_BINARY|O_WRONLY|O_CREAT|O_TRUNC, 0777);
if (outfd != -1) {
write_file_handle(mainvar, outfd, NULL,NULL, 0, G.fileflags, NULL);
if (write(outfd, " ", 1) != 1) {
BKE_report(reports, RPT_ERROR, "Unable to write to output file.");
error= 1;
goto cleanup;
}
} else {
BKE_report(reports, RPT_ERROR, "Unable to open blenderfile.");
error= 1;
}
cleanup:
if (outfd!=-1)
close(outfd);
BKE_reports_prepend(reports, "Unable to make runtime: ");
return !error;
}
#else /* !__APPLE__ */
static int handle_append_runtime(int handle, char *exename, ReportList *reports)
{
char *runtime= get_runtime_path(exename);
unsigned char buf[1024];
int count, progfd= -1, error= 0;
if (!BLI_exists(runtime)) {
BKE_report(reports, RPT_ERROR, "Unable to find runtime.");
error= 1;
goto cleanup;
}
progfd= open(runtime, O_BINARY|O_RDONLY, 0);
if (progfd==-1) {
BKE_report(reports, RPT_ERROR, "Unable to find runtime.@");
error= 1;
goto cleanup;
}
while ((count= read(progfd, buf, sizeof(buf)))>0) {
if (write(handle, buf, count)!=count) {
BKE_report(reports, RPT_ERROR, "Unable to write to output file.");
error= 1;
goto cleanup;
}
}
cleanup:
if (progfd!=-1)
close(progfd);
if (runtime)
MEM_freeN(runtime);
return !error;
}
static int handle_write_msb_int(int handle, int i)
{
unsigned char buf[4];
buf[0]= (i>>24)&0xFF;
buf[1]= (i>>16)&0xFF;
buf[2]= (i>>8)&0xFF;
buf[3]= (i>>0)&0xFF;
return (write(handle, buf, 4)==4);
}
int BLO_write_runtime(Main *mainvar, const char *file, char *exename, ReportList *reports)
{
int outfd= open(file, O_BINARY|O_WRONLY|O_CREAT|O_TRUNC, 0777);
int datastart, error= 0;
if (!outfd) {
BKE_report(reports, RPT_ERROR, "Unable to open output file.");
error= 1;
goto cleanup;
}
if (!handle_append_runtime(outfd, exename, reports)) {
error= 1;
goto cleanup;
}
datastart= lseek(outfd, 0, SEEK_CUR);
write_file_handle(mainvar, outfd, NULL,NULL, 0, G.fileflags, NULL);
if (!handle_write_msb_int(outfd, datastart) || (write(outfd, "BRUNTIME", 8)!=8)) {
BKE_report(reports, RPT_ERROR, "Unable to write to output file.");
error= 1;
goto cleanup;
}
cleanup:
if (outfd!=-1)
close(outfd);
BKE_reports_prepend(reports, "Unable to make runtime: ");
return !error;
}
#endif /* !__APPLE__ */