Changed the *(itr++) instances with *(itr), *(itr+1) with a seperate itr+=n etc. This

has been done to avoid VC6.0 optimization ordering problems.
This commit is contained in:
Robert Osfield
2004-06-09 16:28:51 +00:00
parent f75a7c6294
commit 3adacbdeb7
2 changed files with 67 additions and 58 deletions

View File

@@ -92,10 +92,11 @@ namespace iff
{ {
std::string tag; std::string tag;
for (int i=0; i<4; ++i) tag += *(it++); for (int i=0; i<4; ++i) tag += *(it++);
unsigned int len = ((static_cast<unsigned int>(*(it++)) & 0xFF) << 24) | unsigned int len = ((static_cast<unsigned int>(*(it)) & 0xFF) << 24) |
((static_cast<unsigned int>(*(it++)) & 0xFF) << 16) | ((static_cast<unsigned int>(*(it+1)) & 0xFF) << 16) |
((static_cast<unsigned int>(*(it++)) & 0xFF) << 8) | ((static_cast<unsigned int>(*(it+2)) & 0xFF) << 8) |
(static_cast<unsigned int>(*(it++)) & 0xFF); (static_cast<unsigned int>(*(it+3)) & 0xFF);
it += 4;
os_ << "DEBUG INFO: iffparser: reading chunk " << tag << ", length = " << len << ", context = " << context << "\n"; os_ << "DEBUG INFO: iffparser: reading chunk " << tag << ", length = " << len << ", context = " << context << "\n";
Chunk *chk = parse_chunk_data(tag, context, it, it+len); Chunk *chk = parse_chunk_data(tag, context, it, it+len);
if (!chk) os_ << "DEBUG INFO: iffparser: \tprevious chunk not handled\n"; if (!chk) os_ << "DEBUG INFO: iffparser: \tprevious chunk not handled\n";

View File

@@ -1,9 +1,9 @@
/**************************************************************************** /****************************************************************************
Functions for reading basic data types from LWO2 files Functions for reading basic data types from LWO2 files
Copyright (C) 2002 by Marco Jez Copyright (C) 2002 by Marco Jez
****************************************************************************/ ****************************************************************************/
@@ -18,128 +18,136 @@ namespace lwo2
template<class Iter> template<class Iter>
I1 read_I1(Iter &it) I1 read_I1(Iter &it)
{ {
return static_cast<I1>(*(it++)); return static_cast<I1>(*(it++));
} }
template<class Iter> template<class Iter>
I2 read_I2(Iter &it) I2 read_I2(Iter &it)
{ {
return ((static_cast<I2>(*(it++)) & 0xFF) << 8) | I2 i2(((static_cast<I2>(*(it)) & 0xFF) << 8) |
(static_cast<I2>(*(it++)) & 0xFF); (static_cast<I2>(*(it+1)) & 0xFF));
it += 2;
return i2;
} }
template<class Iter> template<class Iter>
I4 read_I4(Iter &it) I4 read_I4(Iter &it)
{ {
return ((static_cast<I4>(*(it++)) & 0xFF) << 24) | I4 i4(((static_cast<I4>(*(it)) & 0xFF) << 24) |
((static_cast<I4>(*(it++)) & 0xFF) << 16) | ((static_cast<I4>(*(it+1)) & 0xFF) << 16) |
((static_cast<I4>(*(it++)) & 0xFF) << 8) | ((static_cast<I4>(*(it+2)) & 0xFF) << 8) |
(static_cast<I4>(*(it++)) & 0xFF); (static_cast<I4>(*(it+3)) & 0xFF));
it += 4;
return i4;
} }
template<class Iter> template<class Iter>
U1 read_U1(Iter &it) U1 read_U1(Iter &it)
{ {
return static_cast<U1>(*(it++)); return static_cast<U1>(*(it++));
} }
template<class Iter> template<class Iter>
U2 read_U2(Iter &it) U2 read_U2(Iter &it)
{ {
return ((static_cast<U2>(*(it++)) & 0xFF) << 8) | U2 u2(((static_cast<U2>(*(it)) & 0xFF) << 8) |
(static_cast<U2>(*(it++)) & 0xFF); (static_cast<U2>(*(it+1)) & 0xFF));
it += 2;
return u2;
} }
template<class Iter> template<class Iter>
U4 read_U4(Iter &it) U4 read_U4(Iter &it)
{ {
return ((static_cast<U4>(*(it++)) & 0xFF) << 24) | U4 u4(((static_cast<U4>(*(it)) & 0xFF) << 24) |
((static_cast<U4>(*(it++)) & 0xFF) << 16) | ((static_cast<U4>(*(it+1)) & 0xFF) << 16) |
((static_cast<U4>(*(it++)) & 0xFF) << 8) | ((static_cast<U4>(*(it+2)) & 0xFF) << 8) |
(static_cast<U4>(*(it++)) & 0xFF); (static_cast<U4>(*(it+3)) & 0xFF));
it += 4;
return u4;
} }
template<class Iter> template<class Iter>
F4 read_F4(Iter &it) F4 read_F4(Iter &it)
{ {
U4 u4 = read_U4(it); U4 u4 = read_U4(it);
return *reinterpret_cast<F4 *>(&u4); return *reinterpret_cast<F4 *>(&u4);
} }
template<class Iter> template<class Iter>
ID4 read_ID4(Iter &it) ID4 read_ID4(Iter &it)
{ {
ID4 value; ID4 value;
for (int i=0; i<4; ++i) value.id[i] = *(it++); for (int i=0; i<4; ++i) value.id[i] = *(it++);
return value; return value;
} }
template<class Iter> template<class Iter>
S0 read_S0(Iter &it) S0 read_S0(Iter &it)
{ {
S0 value; S0 value;
while (*it) { while (*it) {
value += *(it++); value += *(it++);
} }
++it; ++it;
if (value.length() % 2 == 0) ++it; if (value.length() % 2 == 0) ++it;
return value; return value;
} }
template<class Iter> template<class Iter>
VX read_VX(Iter &it) VX read_VX(Iter &it)
{ {
VX vx; VX vx;
if ((*it & 0xFF) == 0xFF) { if ((*it & 0xFF) == 0xFF) {
vx.index = read_U4(it) & 0x00FFFFFF; vx.index = read_U4(it) & 0x00FFFFFF;
} else { } else {
vx.index = static_cast<U4>(read_U2(it)); vx.index = static_cast<U4>(read_U2(it));
} }
return vx; return vx;
} }
template<class Iter> template<class Iter>
COL12 read_COL12(Iter &it) COL12 read_COL12(Iter &it)
{ {
COL12 value; COL12 value;
value.red = read_F4(it); value.red = read_F4(it);
value.green = read_F4(it); value.green = read_F4(it);
value.blue = read_F4(it); value.blue = read_F4(it);
return value; return value;
} }
template<class Iter> template<class Iter>
VEC12 read_VEC12(Iter &it) VEC12 read_VEC12(Iter &it)
{ {
VEC12 value; VEC12 value;
value.X = read_F4(it); value.X = read_F4(it);
value.Y = read_F4(it); value.Y = read_F4(it);
value.Z = read_F4(it); value.Z = read_F4(it);
return value; return value;
} }
template<class Iter> template<class Iter>
FP4 read_FP4(Iter &it) FP4 read_FP4(Iter &it)
{ {
FP4 value; FP4 value;
value.fraction = read_F4(it); value.fraction = read_F4(it);
return value; return value;
} }
template<class Iter> template<class Iter>
ANG4 read_ANG4(Iter &it) ANG4 read_ANG4(Iter &it)
{ {
ANG4 value; ANG4 value;
value.radians = read_F4(it); value.radians = read_F4(it);
return value; return value;
} }
template<class Iter> template<class Iter>
FNAM0 read_FNAM0(Iter &it) FNAM0 read_FNAM0(Iter &it)
{ {
FNAM0 value; FNAM0 value;
value.name = read_S0(it); value.name = read_S0(it);
return value; return value;
} }
} }