[7909] Applied coding style. (cherry picked from commit ed7e72975f4d4f95f5c429f1af6a2c021adfd5a1)

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
tomrus88 2009-05-28 18:44:51 +04:00 committed by VladimirMangos
parent 84464e5f3f
commit f84fdc6757
16 changed files with 1433 additions and 1467 deletions

View file

@ -12,7 +12,7 @@ bool Model::open()
ok = !f.isEof();
if (!ok)
if (!ok)
{
f.close();
printf("Error loading model %s\n", filename.c_str());
@ -20,20 +20,20 @@ bool Model::open()
}
memcpy(&header, f.getBuffer(), sizeof(ModelHeader));
if(header.nBoundingTriangles > 0)
if(header.nBoundingTriangles > 0)
{
f.seek(0);
f.seekRelative(header.ofsBoundingVertices);
vertices = new Vec3D[header.nBoundingVertices];
f.read(vertices,header.nBoundingVertices*12);
f.seekRelative(header.ofsBoundingVertices);
vertices = new Vec3D[header.nBoundingVertices];
f.read(vertices,header.nBoundingVertices*12);
for (uint32 i=0; i<header.nBoundingVertices; i++)
{
vertices[i] = fixCoordSystem(vertices[i]);
}
f.seek(0);
f.seekRelative(header.ofsBoundingTriangles);
indices = new uint16[header.nBoundingTriangles];
f.read(indices,header.nBoundingTriangles*2);
f.seekRelative(header.ofsBoundingTriangles);
indices = new uint16[header.nBoundingTriangles];
f.read(indices,header.nBoundingTriangles*2);
f.close();
}
else
@ -45,10 +45,8 @@ bool Model::open()
return true;
}
bool Model::ConvertToVMAPModel(char * outfilename)
{
int N[] = {0x00000000};
FILE * output=fopen(outfilename,"wb");
if(!output)
@ -76,7 +74,7 @@ bool Model::ConvertToVMAPModel(char * outfilename)
wsize = sizeof(uint32) + sizeof(unsigned short) * nIndexes;
fwrite(&wsize, sizeof(int), 1, output);
fwrite(&nIndexes, sizeof(uint32), 1, output);
if(nIndexes >0)
if(nIndexes >0)
{
fwrite(indices, sizeof(unsigned short), nIndexes, output);
}
@ -84,7 +82,7 @@ bool Model::ConvertToVMAPModel(char * outfilename)
wsize = sizeof(int) + sizeof(float) * 3 * nVertices;
fwrite(&wsize, sizeof(int), 1, output);
fwrite(&nVertices, sizeof(int), 1, output);
if(nVertices >0)
if(nVertices >0)
{
for(uint32 vpos=0; vpos <nVertices; ++vpos)
{
@ -133,27 +131,25 @@ ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName,const char*Map
sprintf(tempname, ".\\buildings\\%s", ModelInstName);
FILE *input;
input = fopen(tempname, "r+b");
if(!input)
{
return;
}
fseek(input, 8, SEEK_SET); // get the correct no of vertices
int nVertices;
fread(&nVertices, sizeof (int), 1, input);
fclose(input);
if(nVertices == 0)
{
return;
}
if(pDirfile)
if(!input)
return;
fseek(input, 8, SEEK_SET); // get the correct no of vertices
int nVertices;
fread(&nVertices, sizeof (int), 1, input);
fclose(input);
if(nVertices == 0)
return;
if(pDirfile)
{
int realx1 = (int) ((float) pos.x / 533.333333f);
int realy1 = (int) ((float) pos.z / 533.333333f);
int realx2 = (int) ((float) pos.x / 533.333333f);
int realy2 = (int) ((float) pos.z / 533.333333f);
fprintf(pDirfile,"%s/%s %f,%f,%f_%f,%f,%f %f %d %d %d,%d %d\n",
MapName,
ModelInstName,
@ -163,6 +159,6 @@ ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName,const char*Map
nVertices,
realx1, realy1,
realx2, realy2
);
);
}
}