From 74f4eb419c2d22287e39139fcc4142ed0e9b95a3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 3 Aug 2018 11:32:36 +0200 Subject: Cleanup: remove leftover game player code. --- source/blender/blenloader/BLO_readfile.h | 2 - source/blender/blenloader/BLO_runtime.h | 53 -------- source/blender/blenloader/BLO_writefile.h | 2 + source/blender/blenloader/CMakeLists.txt | 2 - source/blender/blenloader/intern/blend_validate.c | 2 +- source/blender/blenloader/intern/readfile.c | 44 +------ source/blender/blenloader/intern/runtime.c | 141 ---------------------- source/blender/blenloader/intern/writefile.c | 1 - 8 files changed, 9 insertions(+), 238 deletions(-) delete mode 100644 source/blender/blenloader/BLO_runtime.h delete mode 100644 source/blender/blenloader/intern/runtime.c (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index 1251424719a..9040405e537 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -143,8 +143,6 @@ void BLO_library_link_copypaste(struct Main *mainl, BlendHandle *bh); void *BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char *blockname); -BlendFileData *blo_read_blendafterruntime(int file, const char *name, int actualsize, struct ReportList *reports); - /* internal function but we need to expose it */ void blo_lib_link_restore( struct Main *newmain, struct wmWindowManager *curwm, diff --git a/source/blender/blenloader/BLO_runtime.h b/source/blender/blenloader/BLO_runtime.h deleted file mode 100644 index 09f25bdca53..00000000000 --- a/source/blender/blenloader/BLO_runtime.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * - */ - -#ifndef __BLO_RUNTIME_H__ -#define __BLO_RUNTIME_H__ - -/** \file BLO_runtime.h - * \ingroup blenloader - */ - -#ifdef __cplusplus -extern "C" { -#endif - -struct BlendFileData; -struct Main; -struct ReportList; - -int BLO_is_a_runtime(const char *file); -struct BlendFileData *BLO_read_runtime(const char *file, struct ReportList *reports); - -bool BLO_main_validate_libraries(struct Main *bmain, struct ReportList *reports); - -#ifdef __cplusplus -} -#endif - -#endif /* __BLO_RUNTIME_H__ */ diff --git a/source/blender/blenloader/BLO_writefile.h b/source/blender/blenloader/BLO_writefile.h index f6d0be6f5f0..d615514f081 100644 --- a/source/blender/blenloader/BLO_writefile.h +++ b/source/blender/blenloader/BLO_writefile.h @@ -44,4 +44,6 @@ extern bool BLO_write_file( extern bool BLO_write_file_mem( struct Main *mainvar, struct MemFile *compare, struct MemFile *current, int write_flags); +bool BLO_main_validate_libraries(struct Main *bmain, struct ReportList *reports); + #endif diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt index 72fa155553d..f2b7f35d353 100644 --- a/source/blender/blenloader/CMakeLists.txt +++ b/source/blender/blenloader/CMakeLists.txt @@ -52,7 +52,6 @@ set(SRC intern/blend_validate.c intern/readblenentry.c intern/readfile.c - intern/runtime.c intern/undofile.c intern/versioning_250.c intern/versioning_260.c @@ -64,7 +63,6 @@ set(SRC BLO_blend_defs.h BLO_readfile.h - BLO_runtime.h BLO_undofile.h BLO_writefile.h intern/readfile.h diff --git a/source/blender/blenloader/intern/blend_validate.c b/source/blender/blenloader/intern/blend_validate.c index 4fb5d0e1286..1bc503719b4 100644 --- a/source/blender/blenloader/intern/blend_validate.c +++ b/source/blender/blenloader/intern/blend_validate.c @@ -47,7 +47,7 @@ #include "BKE_report.h" #include "BLO_readfile.h" -#include "BLO_runtime.h" +#include "BLO_writefile.h" #include "readfile.h" diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index b7aeee491c5..a990e9213c3 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -340,6 +340,12 @@ static void oldnewmap_insert(OldNewMap *onm, const void *oldaddr, void *newaddr, if (oldaddr==NULL || newaddr==NULL) return; + for (int i = 0; i < onm->nentries; i++) { + if (onm->entries[i].old == oldaddr && onm->entries[i].newp != newaddr) { + abort(); + } + } + if (UNLIKELY(onm->nentries == onm->entriessize)) { onm->entriessize *= 2; onm->entries = MEM_reallocN(onm->entries, sizeof(*onm->entries) * onm->entriessize); @@ -1034,20 +1040,6 @@ static int *read_file_thumbnail(FileData *fd) return blend_thumb; } -static int fd_read_from_file(FileData *filedata, void *buffer, unsigned int size) -{ - int readsize = read(filedata->filedes, buffer, size); - - if (readsize < 0) { - readsize = EOF; - } - else { - filedata->seek += readsize; - } - - return readsize; -} - static int fd_read_gzip_from_file(FileData *filedata, void *buffer, unsigned int size) { int readsize = gzread(filedata->gzfiledes, buffer, size); @@ -10982,27 +10974,3 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) BKE_main_free(main_newid); } - -/* reading runtime */ - -BlendFileData *blo_read_blendafterruntime(int file, const char *name, int actualsize, ReportList *reports) -{ - BlendFileData *bfd = NULL; - FileData *fd = filedata_new(); - fd->filedes = file; - fd->buffersize = actualsize; - fd->read = fd_read_from_file; - - /* needed for library_append and read_libraries */ - BLI_strncpy(fd->relabase, name, sizeof(fd->relabase)); - - fd = blo_decode_and_check(fd, reports); - if (!fd) - return NULL; - - fd->reports = reports; - bfd = blo_read_file_internal(fd, ""); - blo_freefiledata(fd); - - return bfd; -} diff --git a/source/blender/blenloader/intern/runtime.c b/source/blender/blenloader/intern/runtime.c deleted file mode 100644 index 985e8169819..00000000000 --- a/source/blender/blenloader/intern/runtime.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * - */ - -/** - * \file runtime.c - * \brief This file handles the loading of .blend files embedded in runtimes - * \ingroup blenloader - */ - -#include -#include -#include -#include -#include - -#ifdef WIN32 -# include // read, open -# include "BLI_winstuff.h" -#else // ! WIN32 -# include // read -#endif - -#include "BLI_blenlib.h" -#include "BLI_utildefines.h" - -#include "BLO_readfile.h" -#include "BLO_runtime.h" - -#include "BKE_report.h" - -/* Runtime reading */ - -static int handle_read_msb_int(int handle) -{ - unsigned char buf[4]; - - if (read(handle, buf, 4) != 4) - return -1; - - return (buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + (buf[3] << 0); -} - -int BLO_is_a_runtime(const char *path) -{ - int res = 0, fd = BLI_open(path, O_BINARY | O_RDONLY, 0); - int datastart; - char buf[8]; - - if (fd == -1) - goto cleanup; - - lseek(fd, -12, SEEK_END); - - datastart = handle_read_msb_int(fd); - - if (datastart == -1) - goto cleanup; - else if (read(fd, buf, 8) != 8) - goto cleanup; - else if (memcmp(buf, "BRUNTIME", 8) != 0) - goto cleanup; - else - res = 1; - -cleanup: - if (fd != -1) - close(fd); - - return res; -} - -BlendFileData *BLO_read_runtime(const char *path, ReportList *reports) -{ - BlendFileData *bfd = NULL; - size_t actualsize; - int fd, datastart; - char buf[8]; - - fd = BLI_open(path, O_BINARY | O_RDONLY, 0); - - if (fd == -1) { - BKE_reportf(reports, RPT_ERROR, "Unable to open '%s': %s", path, strerror(errno)); - goto cleanup; - } - - actualsize = BLI_file_descriptor_size(fd); - - lseek(fd, -12, SEEK_END); - - datastart = handle_read_msb_int(fd); - - if (datastart == -1) { - BKE_reportf(reports, RPT_ERROR, "Unable to read '%s' (problem seeking)", path); - goto cleanup; - } - else if (read(fd, buf, 8) != 8) { - BKE_reportf(reports, RPT_ERROR, "Unable to read '%s' (truncated header)", path); - goto cleanup; - } - else if (memcmp(buf, "BRUNTIME", 8) != 0) { - BKE_reportf(reports, RPT_ERROR, "Unable to read '%s' (not a blend file)", path); - goto cleanup; - } - else { - //printf("starting to read runtime from %s at datastart %d\n", path, datastart); - lseek(fd, datastart, SEEK_SET); - bfd = blo_read_blendafterruntime(fd, path, actualsize - datastart, reports); - fd = -1; // file was closed in blo_read_blendafterruntime() - } - -cleanup: - if (fd != -1) - close(fd); - - return bfd; -} diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 3883e024ab7..2d7b5f13b07 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -191,7 +191,6 @@ #include "BLO_writefile.h" #include "BLO_readfile.h" -#include "BLO_runtime.h" #include "BLO_undofile.h" #include "BLO_blend_defs.h" -- cgit v1.2.3