<!doctype html public "-//W3C//DTD W3 HTML//EN">
<html><head><style type="text/css"><!--
blockquote, dl, ul, ol, li { padding-top: 0 ; padding-bottom: 0 }
 --></style><title>Re: [freespace2] bigendian model loading
probs</title></head><body>
<blockquote type="cite" cite>Ideally, you want to find where these
things are originally loaded from<br>
disk/read from the network, and swap them there if humanly
possible.</blockquote>
<div><br></div>
<div>...the data that needs to be swapped is loaded at
read_model_file():</div>
<div><br></div>
<div><font size="-1" color="#000000">pm-&gt;submodel[n].bsp_data_size
= cfread_int(fp);</font></div>
<div><font size="-1" color="#760F50">if</font><font size="-1"
color="#000000"> ( pm-&gt;submodel[n].bsp_data_size &gt;</font><font
size="-1" color="#0000FF"> 0</font><font size="-1" color="#000000">
)<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab>{</font></div>
<div><font size="-1"
color="#000000"><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab>pm-&gt;submodel[n].bsp_data = (ubyte
*)malloc(pm-&gt;submodel[n].bsp_data_size);</font></div>
<div><font size="-1"
color="#000000"><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab>cfread(pm-&gt;submodel[n].bsp_data,</font><font size="-1"
color="#0000FF">1</font><font size="-1"
color="#000000">,pm-&gt;submodel[n].bsp_data_size,fp);</font></div>
<div><font size="-1" color="#000000">}</font><font size="-1"
color="#760F50"> else</font><font size="-1" color="#000000">
{</font></div>
<div><font size="-1"
color="#000000"><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</x-tab>pm-&gt;submodel[n].bsp_data =</font><font size="-1"
color="#760F50"> NULL</font><font size="-1"
color="#000000">;</font></div>
<div><font size="-1" color="#000000">}</font></div>
<div><br></div>
<div><br></div>
<div>...So, the true weirdness is that this &quot;bsp_data&quot; is
referenced differently based on what is being looked for!&nbsp; This
seems to leave only a few options:</div>
<div><br></div>
<div>1. swap on read would need to mimic all of the
modeloctant/modelinterp parsing functions...and would be the obvious
reason why no one has done this yet!</div>
<div><br></div>
<div>2. could it be as easy as running blindly through a loop of
&quot;bsp_data_size&quot; and swap int's?</div>
<div><br></div>
<div>3. swap on use, which so far isn't working, because it's very
complex...</div>
<div><br></div>
<blockquote type="cite" cite>This is never fun. I've done this work
for several games, and it's a total<br>
motherfucker if byte ordering isn't respected during development.<br>
<br>
Trying to swap on the fly (i.e. -- &quot;will this get swapped more
than<br>
once?!&quot;) is a last resort, and should be avoided unless it's
seriously<br>
non-trivial to rewrite offending portions of code to behave.<br>
<br>
--ryan.</blockquote>
<div><br></div>
<div>tanx for writing back,</div>
<div>jamie</div>
</body>
</html>