Fixed indentation issues

This commit is contained in:
Robert Osfield
2011-06-16 13:00:28 +00:00
parent 375c1456f6
commit 93d1fedd0b
11 changed files with 315 additions and 314 deletions

View File

@@ -104,18 +104,18 @@ bool trpgMatTable1_0::Read(trpgReadBuffer &buf)
// Now convert to the new style material table
for (i=0;i<shortTable.size();i++) {
trpgShortMaterial &shortMat = shortTable[i];
trpgMaterial &baseMat = baseMats[shortMat.baseMat];
AddMaterial(baseMat,false);
trpgMaterial newMat = baseMat;
newMat.SetNumTexture(shortMat.texids.size());
for (j=0;j<shortMat.texids.size();j++) {
int texId;
trpgTextureEnv texEnv;
baseMat.GetTexture(j,texId,texEnv);
newMat.SetTexture(j,shortMat.texids[j],texEnv);
}
trpgShortMaterial &shortMat = shortTable[i];
trpgMaterial &baseMat = baseMats[shortMat.baseMat];
AddMaterial(baseMat,false);
trpgMaterial newMat = baseMat;
newMat.SetNumTexture(shortMat.texids.size());
for (j=0;j<shortMat.texids.size();j++) {
int texId;
trpgTextureEnv texEnv;
baseMat.GetTexture(j,texId,texEnv);
newMat.SetTexture(j,shortMat.texids[j],texEnv);
}
}
valid = true;
@@ -235,17 +235,17 @@ bool trpgTexTable1_0::Read(trpgReadBuffer &buf)
int32 numTex;
try {
buf.Get(numTex);
//texList.resize(numTex);
for (int i=0;i<numTex;i++) {
trpgTexture1_0 tex1_0;
tex1_0.Read(buf);
AddTexture(tex1_0);
//texList[i] = tex1_0;
}
buf.Get(numTex);
//texList.resize(numTex);
for (int i=0;i<numTex;i++) {
trpgTexture1_0 tex1_0;
tex1_0.Read(buf);
AddTexture(tex1_0);
//texList[i] = tex1_0;
}
}
catch (...) {
return false;
return false;
}
valid = true;

View File

@@ -184,9 +184,9 @@ public:
if((verMajor >= TRPG_NOMERGE_VERSION_MAJOR) && (verMinor >=TRPG_NOMERGE_VERSION_MINOR))
{
if(isMaster)
flags |= ISMASTER;//set the master flag
flags |= ISMASTER;//set the master flag
else
flags &= ~ISMASTER;//clear the master flag
flags &= ~ISMASTER;//clear the master flag
}
}
bool GetIsMaster() const
@@ -198,9 +198,9 @@ public:
if((verMajor >= TRPG_NOMERGE_VERSION_MAJOR) && (verMinor >=TRPG_NOMERGE_VERSION_MINOR))
{
if(isLocal)
flags |= ISLOCAL;//set the local flag
flags |= ISLOCAL;//set the local flag
else
flags &= ~ISLOCAL;//clear the local flag
flags &= ~ISLOCAL;//clear the local flag
}
}
bool GetIsLocal() const
@@ -514,10 +514,10 @@ protected:
int32 numTile;
struct _attrSet
{
int fid;
int smc;
int stp;
int swc;
int fid;
int smc;
int stp;
int swc;
} attrSet;
std::vector<int> texids;
std::vector<trpgTextureEnv> texEnvs;

View File

@@ -131,7 +131,7 @@ bool trpgTextStyle::Write(trpgWriteBuffer &buf)
// If we do it this way it's easier to expand later.
class textStyleCB : public trpgr_Callback
{
public:
public:
void * Parse(trpgToken,trpgReadBuffer &);
trpgTextStyle *style;
};

View File

@@ -40,7 +40,7 @@ void trpgManagedTile::Reset()
{
// Null out the local material data
for (unsigned int i=0;i<localMatData.size();i++)
localMatData[i] = NULL;
localMatData[i] = NULL;
groupIDs.resize(0);
isLoaded = false;
@@ -498,20 +498,20 @@ void trpgPageManager::LodPageInfo::AddChildrenToLoadList(std::vector<trpgManaged
// a sanity check: if the lod is not the same then this
// parent is not at the right place
if(childLoc.lod != lod)
break;
break;
// Make sure it is within
if (childLoc.x >= sw.x &&
childLoc.x <= ne.x &&
childLoc.y >= sw.y &&
childLoc.y <= ne.y) {
childLoc.x <= ne.x &&
childLoc.y >= sw.y &&
childLoc.y <= ne.y) {
// Is it alread there ?
if(!tmpCurrent[(childLoc.y - sw.y)*dx + (childLoc.x - sw.x)]) {
// Is it alread there ?
if(!tmpCurrent[(childLoc.y - sw.y)*dx + (childLoc.x - sw.x)]) {
// Not there, add it
AddToLoadList(childLoc.x, childLoc.y, childLoc.addr);
}
// Not there, add it
AddToLoadList(childLoc.x, childLoc.y, childLoc.addr);
}
}
}
}
@@ -652,16 +652,16 @@ void trpgPageManager::LodPageInfo::Update()
// Allocate a new tile
trpgManagedTile *tile = NULL;
if (freeList.size() > 0) {
tile = freeList[0];
freeList.pop_front();
tile = freeList[0];
freeList.pop_front();
} else
tile = new trpgManagedTile();
tile = new trpgManagedTile();
tile->SetTileLoc(x+sw.x,y+sw.y,lod);
trpgwAppAddress addr;
float32 zmin, zmax;
if(tileTable && tileTable->GetTile(x+sw.x, y+sw.y, lod, addr, zmin, zmax))
tile->SetTileAddress(addr);
tile->SetTileAddress(addr);
load.push_back(tile);
}
@@ -797,7 +797,7 @@ void trpgPageManager::Init(trpgr_Archive *inArch, int maxLod)
head->GetVersion(majorVersion, minorVersion);
if(maxLod > numLod)
maxLod = numLod;
maxLod = numLod;
// Reset the terrain LOD paging classes.
valid = true;

View File

@@ -207,15 +207,15 @@ public:
*/
virtual trpgManagedTile *GetNextLoad(void);
/* Acknowledge Tile Load.
This method should be called when a tile has been
loaded by the caller. This method is used in conjunction
with GetNextLoad().
This method should be called when a tile has been
loaded by the caller. This method is used in conjunction
with GetNextLoad().
Version 2.1 and over supports variable lod so that we cannot know
from the tile table if a tile exist or not. So to manage this
the user must parse the loaded tile and extract its list of children
and pass it on to AckLoad() which will add to the appropriate lod list
the children info. If this is not done then only lod 0 will be pageable.
Version 2.1 and over supports variable lod so that we cannot know
from the tile table if a tile exist or not. So to manage this
the user must parse the loaded tile and extract its list of children
and pass it on to AckLoad() which will add to the appropriate lod list
the children info. If this is not done then only lod 0 will be pageable.
*/
virtual void AckLoad(std::vector<TileLocationInfo> const& children);
@@ -262,7 +262,7 @@ public:
// Print current status and content information
virtual void Print(trpgPrintBuffer &);
protected:
protected:
trpgr_Archive *archive;
// Center of paging
@@ -278,15 +278,15 @@ public:
virtual ~LodPageInfo(void);
/* Initializes the class with its current LOD.
It figures out all the rest.
It figures out all the rest.
*/
virtual bool Init(trpgr_Archive *, int myLod, double scale, int freeListDivider = 1);
/* Reset the location. This forces a recalculation
of what to load and unload if the cell has changed
or if this is the first SetLocation.
The location passed in must be relative to the southwest
corner of the TerraPage archive.
of what to load and unload if the cell has changed
or if this is the first SetLocation.
The location passed in must be relative to the southwest
corner of the TerraPage archive.
*/
virtual bool SetLocation(trpg2dPoint &);
@@ -370,15 +370,15 @@ public:
int lod;
/* Adjusted (e.g. paranoid) distance outward from
which to page this terrain LOD. This takes into
account the distance in the header as well as
any factor the user may have added.
which to page this terrain LOD. This takes into
account the distance in the header as well as
any factor the user may have added.
*/
double pageDist;
/* Max tiles we could have loaded in at any given time.
This is just a guess because it's up to the user
to load (and, more importantly) unload.
This is just a guess because it's up to the user
to load (and, more importantly) unload.
*/
int maxNumTiles;
@@ -389,13 +389,13 @@ public:
trpg2iPoint lodSize;
/* Area of interest size in cells
This is a linear distance "ahead" of the center cell.
This is a linear distance "ahead" of the center cell.
*/
trpg2iPoint aoiSize;
/* Our effective paging location sits at the middle
of this cell. We don't recalculate unless the
cell changes. */
of this cell. We don't recalculate unless the
cell changes. */
trpg2iPoint cell;
// List of tiles to load
@@ -459,7 +459,7 @@ public:
// the list of trpgChildRef nodes found.
TX_EXDECL class TX_CLDECL trpgr_ChildRefCB : public trpgr_Callback
{
public:
public:
void *Parse(trpgToken tok, trpgReadBuffer& rbuf);
// After parsing this will return the number of trpgChildRef node found.
unsigned int GetNbChildren() const;
@@ -469,7 +469,7 @@ TX_EXDECL class TX_CLDECL trpgr_ChildRefCB : public trpgr_Callback
// Clear the children list
void Reset();
protected:
protected:
// typedef std::vector<const trpgChildRef> ChildList;
// The const in the template parameter was removed because it causes GCC to
// freak out. I am of the opinion that const doesn't make sense in a template
@@ -485,7 +485,7 @@ TX_EXDECL class TX_CLDECL trpgr_ChildRefCB : public trpgr_Callback
*/
TX_EXDECL class TX_CLDECL trpgPageManageTester
{
public:
public:
trpgPageManageTester();
virtual ~trpgPageManageTester();
@@ -505,7 +505,7 @@ TX_EXDECL class TX_CLDECL trpgPageManageTester
*/
void RandomTest(int no=100,int seed=-1);
protected:
protected:
// Does the work of "load" and "unloading"
void ProcessChanges();

View File

@@ -59,9 +59,9 @@ bool trpgMatTable::isValid() const
// get an iterator for the materialMap
MaterialMapType::const_iterator itr = materialMap.begin();
for ( ; itr != materialMap.end( ); itr++) {
if(!(*itr).second.isValid()) {
return false;
}
if(!(*itr).second.isValid()) {
return false;
}
}
return true;
@@ -71,7 +71,7 @@ bool trpgMatTable::isValid() const
void trpgMatTable::SetNumTable(int no)
{
if ((no < 0) || (no==numTable))
return;
return;
numTable = no;
}
void trpgMatTable::SetNumMaterial(int /*no*/)
@@ -104,58 +104,58 @@ int trpgMatTable::AddMaterial(const trpgMaterial &mat,bool lookForExisting)
//int offset=baseMat;
if (lookForExisting) {
// Look for a matching base material minus the textures
//for (baseMat = 0;baseMat < numMat;baseMat++) {
MaterialMapType::const_iterator itr = materialMap.begin();
for ( ; itr != materialMap.end( ); itr++) {
baseMat = itr->first;
const trpgMaterial &bm = itr->second;
if (bm.shadeModel==999) {
// this is an 'empty' entry. Means we won't find it, either.
spaceInTable=true;
break;
}
// Look for a matching base material minus the textures
//for (baseMat = 0;baseMat < numMat;baseMat++) {
MaterialMapType::const_iterator itr = materialMap.begin();
for ( ; itr != materialMap.end( ); itr++) {
baseMat = itr->first;
const trpgMaterial &bm = itr->second;
if (bm.shadeModel==999) {
// this is an 'empty' entry. Means we won't find it, either.
spaceInTable=true;
break;
}
// Compare structures
if (CEQ(cmat.color,bm.color) && CEQ(cmat.ambient,bm.ambient) &&
CEQ(cmat.diffuse,bm.diffuse) && CEQ(cmat.specular,bm.specular) &&
CEQ(cmat.emission,bm.emission) && cmat.shininess == bm.shininess &&
cmat.shadeModel == bm.shadeModel && cmat.pointSize == bm.pointSize &&
cmat.lineWidth == bm.lineWidth && cmat.cullMode == bm.cullMode &&
cmat.alphaFunc == bm.alphaFunc && cmat.alphaRef == bm.alphaRef &&
cmat.attrSet.fid == bm.attrSet.fid && cmat.attrSet.smc == bm.attrSet.smc &&
cmat.attrSet.stp == bm.attrSet.stp && cmat.attrSet.swc == bm.attrSet.swc &&
cmat.autoNormal == bm.autoNormal && cmat.texEnvs.size() == bm.texEnvs.size()) {
// Test the texture envs
bool isSame=true;
// Compare structures
if (CEQ(cmat.color,bm.color) && CEQ(cmat.ambient,bm.ambient) &&
CEQ(cmat.diffuse,bm.diffuse) && CEQ(cmat.specular,bm.specular) &&
CEQ(cmat.emission,bm.emission) && cmat.shininess == bm.shininess &&
cmat.shadeModel == bm.shadeModel && cmat.pointSize == bm.pointSize &&
cmat.lineWidth == bm.lineWidth && cmat.cullMode == bm.cullMode &&
cmat.alphaFunc == bm.alphaFunc && cmat.alphaRef == bm.alphaRef &&
cmat.attrSet.fid == bm.attrSet.fid && cmat.attrSet.smc == bm.attrSet.smc &&
cmat.attrSet.stp == bm.attrSet.stp && cmat.attrSet.swc == bm.attrSet.swc &&
cmat.autoNormal == bm.autoNormal && cmat.texEnvs.size() == bm.texEnvs.size()) {
// Test the texture envs
bool isSame=true;
unsigned int i;
for (i=0;i<cmat.texEnvs.size();i++) {
const trpgTextureEnv &e1 = cmat.texEnvs[i];
const trpgTextureEnv &e2 = bm.texEnvs[i];
if (e1.envMode != e2.envMode ||
e1.minFilter != e2.minFilter ||
e1.magFilter != e2.magFilter ||
e1.wrapS != e2.wrapS || e1.wrapT != e2.wrapT ||
!CEQ(e1.borderCol,e2.borderCol))
isSame = false;
for (i=0;i<cmat.texEnvs.size();i++) {
const trpgTextureEnv &e1 = cmat.texEnvs[i];
const trpgTextureEnv &e2 = bm.texEnvs[i];
if (e1.envMode != e2.envMode ||
e1.minFilter != e2.minFilter ||
e1.magFilter != e2.magFilter ||
e1.wrapS != e2.wrapS || e1.wrapT != e2.wrapT ||
!CEQ(e1.borderCol,e2.borderCol))
isSame = false;
}
// Test the texture IDs
for (i=0;i<cmat.texids.size();i++) {
if (cmat.texids[i] != bm.texids[i])
isSame = false;
}
if (isSame)
return baseMat;
}
}
// Test the texture IDs
for (i=0;i<cmat.texids.size();i++) {
if (cmat.texids[i] != bm.texids[i])
isSame = false;
}
if (isSame)
return baseMat;
}
}
}
// Didn't find it. Add it
int idx;
if(cmat.writeHandle)
idx = cmat.GetHandle();
idx = cmat.GetHandle();
else
idx = numMat;
idx = numMat;
materialMap[idx] = cmat;
numMat = materialMap.size();
return idx;
@@ -402,30 +402,30 @@ void * textureEnvCB::Parse(trpgToken tok,trpgReadBuffer &buf)
trpgColor borderCol;
try {
switch (tok) {
case TRPGMAT_TXENV_MODE:
buf.Get(envMode);
tenv->SetEnvMode(envMode);
break;
case TRPGMAT_TXENV_FILTER:
buf.Get(minFilter);
buf.Get(magFilter);
tenv->SetMinFilter(minFilter);
tenv->SetMagFilter(magFilter);
break;
case TRPGMAT_TXENV_WRAP:
buf.Get(wrapS);
buf.Get(wrapT);
tenv->SetWrap(wrapS,wrapT);
break;
case TRPGMAT_TXENV_BORDER:
buf.Get(borderCol);
tenv->SetBorderColor(borderCol);
break;
default:
// Don't know this token. Skip
break;
}
switch (tok) {
case TRPGMAT_TXENV_MODE:
buf.Get(envMode);
tenv->SetEnvMode(envMode);
break;
case TRPGMAT_TXENV_FILTER:
buf.Get(minFilter);
buf.Get(magFilter);
tenv->SetMinFilter(minFilter);
tenv->SetMagFilter(magFilter);
break;
case TRPGMAT_TXENV_WRAP:
buf.Get(wrapS);
buf.Get(wrapT);
tenv->SetWrap(wrapS,wrapT);
break;
case TRPGMAT_TXENV_BORDER:
buf.Get(borderCol);
tenv->SetBorderColor(borderCol);
break;
default:
// Don't know this token. Skip
break;
}
}
catch (...) {
return NULL;
@@ -691,9 +691,9 @@ bool trpgMaterial::Write(trpgWriteBuffer &buf)
* If the terrapage version is >= 2.3, handle will be set to a unique identifier.
**/
if(writeHandle) {
buf.Begin(TRPGMAT_HANDLE);
buf.Add((int)handle);
buf.End();
buf.Begin(TRPGMAT_HANDLE);
buf.Add((int)handle);
buf.End();
}
buf.End();
@@ -800,7 +800,7 @@ bool trpgMaterial::GetNumTexture(int &no) const
bool trpgMaterial::GetTexture(int no,int &id,trpgTextureEnv &te) const
{
if (!isValid() || no < 0 || no >= numTex)
return false;
return false;
id = texids[no];
te = texEnvs[no];
return true;
@@ -919,16 +919,16 @@ void * materialCB::Parse(trpgToken tok,trpgReadBuffer &buf)
case TRPGMAT_TEXTURE:
buf.Get(numTex);
for (i=0;i<numTex;i++) {
buf.Get(texId);
// Parse the texture Env
buf.GetToken(envTok,len);
if (envTok != TRPGMAT_TEXENV) throw 1;
buf.PushLimit(len);
status = texEnv.Read(buf);
buf.PopLimit();
if (!status) throw 1;
buf.Get(texId);
// Parse the texture Env
buf.GetToken(envTok,len);
if (envTok != TRPGMAT_TEXENV) throw 1;
buf.PushLimit(len);
status = texEnv.Read(buf);
buf.PopLimit();
if (!status) throw 1;
mat->AddTexture(texId,texEnv);
mat->AddTexture(texId,texEnv);
}
break;
case TRPGMAT_BUMP:
@@ -1243,7 +1243,7 @@ void trpgTexture::AddTile()
bool trpgTexture::GetNumTile(int &num) const
{
if (!isValid())
return false;
return false;
num = useCount;
return true;
}
@@ -1300,6 +1300,7 @@ int trpgTexture::operator == (const trpgTexture &in) const
if (type == in.type && sizeX == in.sizeX && sizeY == in.sizeY &&
isMipmap == in.isMipmap)
return 1;
break;
}
return 0;
@@ -1583,8 +1584,8 @@ void trpgTexture::CalcMipLevelSizes()
row_size = x_size * pixel_size;
if (pad_size > 0) {
int left = row_size%pad_size;
if (left)
row_size += pad_size - left;
if (left)
row_size += pad_size - left;
}
level_size = row_size * y_size;
storageSize.push_back(level_size);

View File

@@ -49,8 +49,8 @@ void trpgGroup::Reset()
numChild = 0;
id = -1;
if ( name ) {
delete [] name;
name = 0;
delete [] name;
name = 0;
}
}
@@ -73,16 +73,16 @@ void trpgGroup::SetName(const char* newname )
{
if ( name )
{
delete [] name;
name = 0;
delete [] name;
name = 0;
}
if (newname)
{
if ( strlen(newname) )
{
name = new char[strlen(newname)+1];
strcpy(name,newname);
}
if ( strlen(newname) )
{
name = new char[strlen(newname)+1];
strcpy(name,newname);
}
}
}
@@ -118,14 +118,14 @@ bool trpgGroup::isValid() const
bool trpgGroup::Write(trpgWriteBuffer &buf)
{
if (!isValid())
return false;
return false;
buf.Begin(TRPG_GROUP);
buf.Add(numChild);
buf.Add(id);
if ( name && strlen(name) ) {
buf.Add(name);
buf.Add(name);
}
buf.End();
@@ -137,19 +137,18 @@ bool trpgGroup::Write(trpgWriteBuffer &buf)
bool trpgGroup::Read(trpgReadBuffer &buf)
{
try {
buf.Get(numChild);
if (numChild < 0) throw 1;
buf.Get(id);
if (id < 0) throw 1;
if ( !buf.isEmpty() ) {
char nm[1024] = {0};
buf.Get(nm,1024);
SetName(nm);
}
buf.Get(numChild);
if (numChild < 0) throw 1;
buf.Get(id);
if (id < 0) throw 1;
if ( !buf.isEmpty() ) {
char nm[1024] = {0};
buf.Get(nm,1024);
SetName(nm);
}
}
catch (...) {
return false;
return false;
}
return isValid();
@@ -181,8 +180,8 @@ void trpgBillboard::Reset()
numChild = 0;
if ( name )
{
delete [] name;
name = 0;
delete [] name;
name = 0;
}
}
@@ -235,7 +234,7 @@ bool trpgBillboard::GetType(int &t) const
bool trpgBillboard::Write(trpgWriteBuffer &buf)
{
if (!isValid())
return false;
return false;
buf.Begin(TRPG_BILLBOARD);
buf.Add(numChild);
@@ -246,7 +245,7 @@ bool trpgBillboard::Write(trpgWriteBuffer &buf)
buf.Add(axis);
if ( name && strlen(name) ) {
buf.Add(name);
buf.Add(name);
}
buf.End();
@@ -259,20 +258,20 @@ bool trpgBillboard::Read(trpgReadBuffer &buf)
uint8 uChar;
try {
buf.Get(numChild);
buf.Get(id);
buf.Get(uChar); type = uChar;
buf.Get(uChar); mode = uChar;
buf.Get(center);
buf.Get(axis);
if ( !buf.isEmpty() ) {
char nm[1024] = {0};
buf.Get(nm,1024);
SetName(nm);
}
buf.Get(numChild);
buf.Get(id);
buf.Get(uChar); type = uChar;
buf.Get(uChar); mode = uChar;
buf.Get(center);
buf.Get(axis);
if ( !buf.isEmpty() ) {
char nm[1024] = {0};
buf.Get(nm,1024);
SetName(nm);
}
}
catch (...) {
return false;
return false;
}
return isValid();
@@ -303,8 +302,8 @@ void trpgLod::Reset()
rangeIndex = -1;
valid = true;
if ( name ) {
delete [] name;
name = 0;
delete [] name;
name = 0;
}
}
@@ -317,7 +316,7 @@ void trpgLod::SetCenter(const trpg3dPoint &pt)
void trpgLod::SetNumChild(int no)
{
if (no < 0)
return;
return;
numRange = no;
}
@@ -335,14 +334,14 @@ void trpgLod::SetID(int inID)
void trpgLod::SetName(const char* newname )
{
if ( name ) {
delete [] name;
name = 0;
delete [] name;
name = 0;
}
if (newname) {
if ( strlen(newname) ) {
name = new char[strlen(newname)+1];
strcpy(name,newname);
}
if ( strlen(newname) ) {
name = new char[strlen(newname)+1];
strcpy(name,newname);
}
}
}
@@ -397,7 +396,7 @@ bool trpgLod::GetRangeIndex(int &ri) const
bool trpgLod::Write(trpgWriteBuffer &buf)
{
if (!isValid())
return false;
return false;
buf.Begin(TRPG_LOD);
buf.Add(id);
@@ -408,9 +407,9 @@ bool trpgLod::Write(trpgWriteBuffer &buf)
buf.Add(width);
if ( name && strlen(name) ) {
buf.Add(name);
buf.Add(name);
} else
buf.Add("");
buf.Add("");
buf.End();
@@ -422,25 +421,25 @@ bool trpgLod::Write(trpgWriteBuffer &buf)
bool trpgLod::Read(trpgReadBuffer &buf)
{
try {
buf.Get(id);
buf.Get(numRange);
if (numRange < 0) throw 1;
buf.Get(center);
buf.Get(switchIn);
buf.Get(switchOut);
buf.Get(width);
if ( !buf.isEmpty() ) {
char nm[1024] = {0};
buf.Get(nm,1024);
if (*nm)
SetName(nm);
// Look for a range index
if (!buf.isEmpty())
buf.Get(rangeIndex);
}
buf.Get(id);
buf.Get(numRange);
if (numRange < 0) throw 1;
buf.Get(center);
buf.Get(switchIn);
buf.Get(switchOut);
buf.Get(width);
if ( !buf.isEmpty() ) {
char nm[1024] = {0};
buf.Get(nm,1024);
if (*nm)
SetName(nm);
// Look for a range index
if (!buf.isEmpty())
buf.Get(rangeIndex);
}
}
catch (...) {
return false;
return false;
}
return isValid();
@@ -465,14 +464,14 @@ trpgLayer::~trpgLayer()
bool trpgLayer::Write(trpgWriteBuffer &buf)
{
if (!isValid())
return false;
return false;
buf.Begin(TRPG_LAYER);
buf.Add(numChild);
buf.Add(id);
if ( name && strlen(name) ) {
buf.Add(name);
buf.Add(name);
}
buf.End();
@@ -484,18 +483,18 @@ bool trpgLayer::Write(trpgWriteBuffer &buf)
bool trpgLayer::Read(trpgReadBuffer &buf)
{
try {
buf.Get(numChild);
if (numChild < 0) throw 1;
buf.Get(id);
if (id < 0) throw 1;
if ( !buf.isEmpty() ) {
char nm[1024] = {0};
buf.Get(nm,1024);
SetName(nm);
}
buf.Get(numChild);
if (numChild < 0) throw 1;
buf.Get(id);
if (id < 0) throw 1;
if ( !buf.isEmpty() ) {
char nm[1024] = {0};
buf.Get(nm,1024);
SetName(nm);
}
}
catch (...) {
return false;
return false;
}
return isValid();
@@ -506,8 +505,8 @@ void trpgLayer::Reset()
{
numChild = 0;
if ( name ) {
delete [] name;
name = 0;
delete [] name;
name = 0;
}
}
@@ -537,8 +536,8 @@ void trpgTransform::Reset()
m[3][0] = 0; m[3][1] = 0; m[3][2] = 0; m[3][3] = 1;
if ( name ) {
delete [] name;
name = 0;
delete [] name;
name = 0;
}
}
@@ -556,9 +555,9 @@ bool trpgTransform::GetMatrix(float64 *rm) const
{
if (!isValid()) return false;
for (int i=0;i<4;i++)
for (int j=0;j<4;j++)
// Note: is this right?
rm[i*4+j] = m[i][j];
for (int j=0;j<4;j++)
// Note: is this right?
rm[i*4+j] = m[i][j];
return true;
}
@@ -566,17 +565,17 @@ bool trpgTransform::GetMatrix(float64 *rm) const
bool trpgTransform::Write(trpgWriteBuffer &buf)
{
if (!isValid())
return false;
return false;
buf.Begin(TRPG_TRANSFORM);
buf.Add(numChild);
buf.Add(id);
for (int i=0;i<4;i++)
for (int j=0;j<4;j++)
buf.Add(m[i][j]);
for (int j=0;j<4;j++)
buf.Add(m[i][j]);
if ( name && strlen(name) ) {
buf.Add(name);
buf.Add(name);
}
buf.End();
@@ -587,20 +586,20 @@ bool trpgTransform::Write(trpgWriteBuffer &buf)
bool trpgTransform::Read(trpgReadBuffer &buf)
{
try {
buf.Get(numChild);
buf.Get(id);
if (numChild < 0) throw 1;
for (int i=0;i<4;i++)
for (int j=0;j<4;j++)
buf.Get(m[i][j]);
if ( !buf.isEmpty() ) {
char nm[1024] = {0};
buf.Get(nm,1024);
SetName(nm);
}
buf.Get(numChild);
buf.Get(id);
if (numChild < 0) throw 1;
for (int i=0;i<4;i++)
for (int j=0;j<4;j++)
buf.Get(m[i][j]);
if ( !buf.isEmpty() ) {
char nm[1024] = {0};
buf.Get(nm,1024);
SetName(nm);
}
}
catch (...) {
return false;
return false;
}
return isValid();
@@ -615,6 +614,7 @@ trpgModelRef::trpgModelRef()
{
Reset();
}
trpgModelRef::~trpgModelRef()
{
}
@@ -654,9 +654,9 @@ bool trpgModelRef::GetMatrix(float64 *rm) const
{
if (!isValid()) return false;
for (int i=0;i<4;i++)
for (int j=0;j<4;j++)
// Note: is this right?
rm[i*4+j] = m[i][j];
for (int j=0;j<4;j++)
// Note: is this right?
rm[i*4+j] = m[i][j];
return true;
}
@@ -664,13 +664,13 @@ bool trpgModelRef::GetMatrix(float64 *rm) const
bool trpgModelRef::Write(trpgWriteBuffer &buf)
{
if (!isValid())
return false;
return false;
buf.Begin(TRPG_MODELREF);
buf.Add(modelRef);
for (int i=0;i<4;i++)
for (int j=0;j<4;j++)
buf.Add(m[i][j]);
for (int j=0;j<4;j++)
buf.Add(m[i][j]);
buf.End();
return true;
@@ -680,15 +680,15 @@ bool trpgModelRef::Write(trpgWriteBuffer &buf)
bool trpgModelRef::Read(trpgReadBuffer &buf)
{
try {
buf.Get(modelRef);
if (modelRef < 0)
throw 1;
for (int i=0;i<4;i++)
for (int j=0;j<4;j++)
buf.Get(m[i][j]);
buf.Get(modelRef);
if (modelRef < 0)
throw 1;
for (int i=0;i<4;i++)
for (int j=0;j<4;j++)
buf.Get(m[i][j]);
}
catch (...) {
return false;
return false;
}
valid = true;
@@ -718,8 +718,8 @@ void trpgAttach::Reset()
parentID = -1;
childPos = -1;
if ( name ) {
delete [] name;
name = 0;
delete [] name;
name = 0;
}
}
@@ -767,7 +767,7 @@ bool trpgAttach::Write(trpgWriteBuffer &buf)
buf.Add(childPos);
if ( name && strlen(name) ) {
buf.Add(name);
buf.Add(name);
}
buf.End();
@@ -779,21 +779,21 @@ bool trpgAttach::Write(trpgWriteBuffer &buf)
bool trpgAttach::Read(trpgReadBuffer &buf)
{
try {
buf.Get(numChild);
buf.Get(id);
if (id < 0) throw 1;
buf.Get(parentID);
if (parentID < 0) throw 1;
buf.Get(childPos);
if (childPos < 0) throw 1;
if ( !buf.isEmpty() ) {
char nm[1024] = {0};
buf.Get(nm,1024);
SetName(nm);
}
buf.Get(numChild);
buf.Get(id);
if (id < 0) throw 1;
buf.Get(parentID);
if (parentID < 0) throw 1;
buf.Get(childPos);
if (childPos < 0) throw 1;
if ( !buf.isEmpty() ) {
char nm[1024] = {0};
buf.Get(nm,1024);
SetName(nm);
}
}
catch (...) {
return false;
return false;
}
return true;
@@ -923,19 +923,19 @@ bool trpgChildRef::Read(trpgReadBuffer &buf)
try
{
buf.Get(lod);
if (lod < 0) throw 1;
buf.Get(x);
buf.Get(y);
buf.Get(addr.file);
buf.Get(addr.offset);
buf.Get(zmin);
buf.Get(zmax);
buf.Get(lod);
if (lod < 0) throw 1;
buf.Get(x);
buf.Get(y);
buf.Get(addr.file);
buf.Get(addr.offset);
buf.Get(zmin);
buf.Get(zmax);
}
catch (...)
{
return false;
return false;
}
return true;

View File

@@ -98,10 +98,10 @@ class WriteWrapper : public trpgr_Callback {
public:
WriteWrapper(trpgReadWriteable *in_wr) { wr = in_wr; };
void *Parse(trpgToken,trpgReadBuffer &buf) {
if (wr->Read(buf))
return wr;
else
return NULL;
if (wr->Read(buf))
return wr;
else
return NULL;
}
protected:
trpgReadWriteable *wr;

View File

@@ -31,7 +31,7 @@
*/
TX_EXDECL class TX_CLDECL trpgr_Callback
{
public:
public:
virtual ~trpgr_Callback(void) { };
virtual void *Parse(trpgToken,trpgReadBuffer &) { return (void *)1; };
};
@@ -42,7 +42,7 @@ TX_EXDECL class TX_CLDECL trpgr_Callback
*/
TX_EXDECL class TX_CLDECL trpgr_Token
{
public:
public:
trpgr_Token(void);
trpgr_Token(int,trpgr_Callback *,bool destroy=true);
~trpgr_Token(void);
@@ -59,7 +59,7 @@ TX_EXDECL class TX_CLDECL trpgr_Token
*/
TX_EXDECL class TX_CLDECL trpgr_Parser
{
public:
public:
trpgr_Parser(void);
virtual ~trpgr_Parser(void);
bool isValid(void) const;
@@ -74,9 +74,9 @@ TX_EXDECL class TX_CLDECL trpgr_Parser
// Parse a read buffer
virtual bool Parse(trpgReadBuffer &);
virtual bool TokenIsValid(trpgToken); // Check token validity
protected:
protected:
void *lastObject;
private:
private:
// Note: Just how slow is a map<> anyway?
// This usage is self-contained and could be replaced with an array
#if defined(_WIN32)
@@ -184,7 +184,7 @@ TX_EXDECL class TX_CLDECL trpgrImageHelper
*/
TX_EXDECL class TX_CLDECL trpgr_Archive : public trpgCheckable
{
public:
public:
trpgr_Archive(void);
virtual ~trpgr_Archive(void);
@@ -223,7 +223,7 @@ TX_EXDECL class TX_CLDECL trpgr_Archive : public trpgCheckable
virtual trpgrAppFileCache* GetNewRAppFileCache(const char *fullBase, const char *ext);
virtual int32 GetHeaderData(char *dataPtr,int32 length,FILE *filehandle);
virtual int32 GetMagicNumber() {return TRPG_MAGIC;};
protected:
protected:
bool headerRead;
trpgEndian ness;
FILE *fp;
@@ -258,10 +258,10 @@ TX_EXDECL class TX_CLDECL trpgSceneParser : public trpgr_Parser
friend class trpgSceneHelperPush;
friend class trpgSceneHelperPop;
friend class trpgSceneHelperDefault;
public:
public:
trpgSceneParser(void);
virtual ~trpgSceneParser(void);
protected:
protected:
// Start defining children for the given object
virtual bool StartChildren(void *) { return true;};
virtual bool EndChildren(void *) { return true;};

View File

@@ -572,7 +572,7 @@ bool trpgrAppFile::Read(char *data,int32 baseOffset,int32 objOffset,int32 dataSi
// Read the raw data
// Note: What about byte swapping?
if (fread(data,sizeof(char),dataSize,fp) != (uint32)dataSize) {
if (fread(data,sizeof(char),dataSize,fp) != (uint32)dataSize) {
valid = false;
return false;
}

View File

@@ -839,7 +839,7 @@ bool trpgwArchive::WriteTile(unsigned int x,unsigned int y,unsigned int lod, flo
return false;
// Write the header first
unsigned int len;
unsigned int len;
const char *data;
if (head) {
data = head->getData();