summaryrefslogtreecommitdiffstats
path: root/src/fakerw/fake.cpp
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2020-07-29 09:34:28 +0200
committeraap <aap@papnet.eu>2020-07-29 09:34:28 +0200
commitfb4de46626b00079e169da562a0267126c1c1340 (patch)
tree30afeb6ed4245493dc7b8c87a52eb8b7c84e8c49 /src/fakerw/fake.cpp
parentCCollision done and fixes (diff)
parentMerge pull request #667 from erorcun/miami (diff)
downloadre3-fb4de46626b00079e169da562a0267126c1c1340.tar
re3-fb4de46626b00079e169da562a0267126c1c1340.tar.gz
re3-fb4de46626b00079e169da562a0267126c1c1340.tar.bz2
re3-fb4de46626b00079e169da562a0267126c1c1340.tar.lz
re3-fb4de46626b00079e169da562a0267126c1c1340.tar.xz
re3-fb4de46626b00079e169da562a0267126c1c1340.tar.zst
re3-fb4de46626b00079e169da562a0267126c1c1340.zip
Diffstat (limited to 'src/fakerw/fake.cpp')
-rw-r--r--src/fakerw/fake.cpp65
1 files changed, 45 insertions, 20 deletions
diff --git a/src/fakerw/fake.cpp b/src/fakerw/fake.cpp
index 0bc69abe..7139292e 100644
--- a/src/fakerw/fake.cpp
+++ b/src/fakerw/fake.cpp
@@ -376,23 +376,19 @@ RwStream *RwStreamOpen(RwStreamType type, RwStreamAccessType accessType, const v
file = rwNewT(StreamFile, 1, 0);
memcpy(file, &fakefile, sizeof(StreamFile));
#ifndef _WIN32
- // Be case-insensitive and fix backslashes (from https://github.com/OneSadCookie/fcaseopen/)
- FILE* first = fopen((char*)pData, "r");
- char *r;
- if (!first) {
- r = (char*)alloca(strlen((char*)pData) + 2);
- // Use default path(and pass error handling to librw) if we can't find any match
- if (!casepath((char*)pData, r))
- r = (char*)pData;
+ char *r = casepath((char*)pData);
+ if (r) {
+ if (file->open((char*)r, mode)) {
+ free(r);
+ return file;
+ }
+ free(r);
} else
- fclose(first);
-
- if(file->open((char*)r, mode))
- return file;
-#else
- if(file->open((char*)pData, mode))
- return file;
#endif
+ {
+ if (file->open((char*)pData, mode))
+ return file;
+ }
rwFree(file);
return nil;
}
@@ -856,12 +852,41 @@ RpSkin *RpSkinGeometryGetSkin( RpGeometry *geometry ) { return Skin::get(geometr
RpAtomic *RpSkinAtomicSetHAnimHierarchy( RpAtomic *atomic, RpHAnimHierarchy *hierarchy ) { Skin::setHierarchy(atomic, hierarchy); return atomic; }
RpHAnimHierarchy *RpSkinAtomicGetHAnimHierarchy( const RpAtomic *atomic ) { return Skin::getHierarchy(atomic); }
+RwImage *
+RtBMPImageWrite(RwImage *image, const RwChar *imageName)
+{
+#ifndef _WIN32
+ char *r = casepath(imageName);
+ if (r) {
+ rw::writeBMP(image, r);
+ free(r);
+ } else {
+ rw::writeBMP(image, imageName);
+ }
+
+#else
+ rw::writeBMP(image, imageName);
+#endif
+ return image;
+}
+RwImage *
+RtBMPImageRead(const RwChar *imageName)
+{
+#ifndef _WIN32
+ RwImage *image;
+ char *r = casepath(imageName);
+ if (r) {
+ image = rw::readBMP(r);
+ free(r);
+ } else {
+ image = rw::readBMP(imageName);
+ }
+ return image;
-
-
-
-RwImage *RtBMPImageWrite(RwImage * image, const RwChar * imageName) { rw::writeBMP(image, imageName); return image; }
-RwImage *RtBMPImageRead(const RwChar * imageName) { return rw::readBMP(imageName); }
+#else
+ return rw::readBMP(imageName);
+#endif
+}
#include "rtquat.h"