|
|
@@ -211,13 +211,27 @@ void XFileMaterial::
|
|
|
make_texture_data(Datagram &raw_data) {
|
|
|
raw_data.clear();
|
|
|
|
|
|
+ // Convert the filename to an appropriate form for the X file.
|
|
|
+ string os_filename = _texture.to_os_specific();
|
|
|
+ // Now we have to double up the backslashes.
|
|
|
+ string filename;
|
|
|
+ for (string::const_iterator pi = os_filename.begin();
|
|
|
+ pi != os_filename.end();
|
|
|
+ ++pi) {
|
|
|
+ if ((*pi) == '\\') {
|
|
|
+ filename += '\\';
|
|
|
+ filename += '\\';
|
|
|
+ } else {
|
|
|
+ filename += (*pi);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// Get a char * pointer to the texture filename, to pass into the
|
|
|
// Microsoft DX file interface. Unfortunately, we can't delete this
|
|
|
// again, since it needs to live longer than the life of the
|
|
|
// XFileMaterial object itself, so this becomes a memory leak
|
|
|
// (unless the DX file interface frees it, but the documentation is
|
|
|
// far from clear). Too bad.
|
|
|
- string filename = _texture.to_os_specific();
|
|
|
char *filename_str = strdup(filename.c_str());
|
|
|
|
|
|
// The Microsoft convention is to stuff a pointer into a four-byte
|
|
|
@@ -269,7 +283,7 @@ read_texture_data(const Datagram &raw_data) {
|
|
|
// The Microsoft convention is to stuff a pointer into a four-byte
|
|
|
// field. Not terribly portable, but that's the interface.
|
|
|
const char *ptr = (const char *)di.get_int32();
|
|
|
- _texture = ptr;
|
|
|
+ _texture = Filename::from_os_specific(ptr);
|
|
|
_has_texture = true;
|
|
|
|
|
|
if (di.get_remaining_size() != 0) {
|