Is it a bug? (player.cc pack/unpack update)
by Yui Chung, Ng · in Torque Game Engine · 09/02/2003 (5:33 am) · 1 replies
I read the follow pair of blocks of code from the player.cc file:
function PackUpdate(...){
...
if (stream->writeFlag(mask & ActionMask &&
mActionAnimation.action != PlayerData::NullAnimation &&
mActionAnimation.action >= PlayerData::NumTableActionAnims)) {
stream->writeInt(mActionAnimation.action,PlayerData::ActionAnimBits);
stream->writeFlag(mActionAnimation.holdAtEnd);
stream->writeFlag(mActionAnimation.atEnd);
stream->writeFlag(mActionAnimation.firstPerson);
if (!mActionAnimation.atEnd) {
// If somewhere in middle on initial update, must send position-
F32 where = mShapeInstance->getPos(mActionAnimation.thread);
if (stream->writeFlag((mask & InitialUpdateMask) != 0 && where > 0))
stream->writeSignedFloat(where, 6);
}
}
.....
function UnpackUpdate(...){
...
if (stream->readFlag()) {
U32 action = stream->readInt(PlayerData::ActionAnimBits);
bool hold = stream->readFlag();
bool atEnd = stream->readFlag();
bool fsp = stream->readFlag();
F32 animPos = -1.0;
if (!atEnd && stream->readFlag())
animPos = stream->readSignedFloat(6);
.....
From the PackUpdate Code, a flag (the second one) was wrote only when ActionAnimation.atEnd is false, but the UnpackUpdate Code read that flag everytime. will it cause the stream shifted? Or I mis-understood something?
Could anyone kindly clairifly it for me? Thanks in advance.
Bon
function PackUpdate(...){
...
if (stream->writeFlag(mask & ActionMask &&
mActionAnimation.action != PlayerData::NullAnimation &&
mActionAnimation.action >= PlayerData::NumTableActionAnims)) {
stream->writeInt(mActionAnimation.action,PlayerData::ActionAnimBits);
stream->writeFlag(mActionAnimation.holdAtEnd);
stream->writeFlag(mActionAnimation.atEnd);
stream->writeFlag(mActionAnimation.firstPerson);
if (!mActionAnimation.atEnd) {
// If somewhere in middle on initial update, must send position-
F32 where = mShapeInstance->getPos(mActionAnimation.thread);
if (stream->writeFlag((mask & InitialUpdateMask) != 0 && where > 0))
stream->writeSignedFloat(where, 6);
}
}
.....
function UnpackUpdate(...){
...
if (stream->readFlag()) {
U32 action = stream->readInt(PlayerData::ActionAnimBits);
bool hold = stream->readFlag();
bool atEnd = stream->readFlag();
bool fsp = stream->readFlag();
F32 animPos = -1.0;
if (!atEnd && stream->readFlag())
animPos = stream->readSignedFloat(6);
.....
From the PackUpdate Code, a flag (the second one) was wrote only when ActionAnimation.atEnd is false, but the UnpackUpdate Code read that flag everytime. will it cause the stream shifted? Or I mis-understood something?
Could anyone kindly clairifly it for me? Thanks in advance.
Bon
Torque Owner Chris \"Hobbiticus\" Weiland