[7913] Fixed vmap_assambler sources. Updated binary.

* Fixed week ago added bugs into vmap code that break vmap_assambler sources work.
  Note: vmap_assambler binary not updated from nov 2008 until this commit and it has been correct working.
* Add to vmap assambler process show output and add appropriate error messages output.
* vmap_assambler binary updated.
This commit is contained in:
VladimirMangos 2009-05-30 04:06:36 +04:00
parent 81267151ad
commit 548f47b2b3
5 changed files with 348 additions and 336 deletions

View file

@ -78,15 +78,18 @@ bool readConfigFile(char *pConffile, VMAP::TileAssembler* pTa)
//=======================================================
int main(int argc, char* argv[])
{
if(argc == 3 || argc == 4)
if(argc != 3 && argc != 4)
{
bool ok = true;
printf("\nusage: %s <raw data dir> <vmap dest dir> [config file name]\n", argv[0]);
return 1;
}
char *src = argv[1];
char *dest = argv[2];
char *conffile = NULL;
if(argc >= 4) {
if(argc >= 4)
conffile = argv[3];
}
VMAP::TileAssembler* ta = new VMAP::TileAssembler(std::string(src), std::string(dest));
ta->setModelNameFilterMethod(modelNameFilter);
@ -94,25 +97,24 @@ int main(int argc, char* argv[])
All the names in the list are considered to be world maps or huge instances.
These maps will be spilt into tiles in the vmap assemble process
*/
if(conffile != NULL) {
ok = readConfigFile(conffile, ta);
if(!ok) {
printf("Can not open file config file: %s\n", conffile);
}
}
if(ok) { ok = ta->convertWorld(); }
if(ok) {
printf("Ok, all done\n");
} else {
printf("exit with errors\n");
return 1;
}
delete ta;
}
else
if(conffile != NULL)
{
printf("\nusage: %s <raw data dir> <vmap dest dir> [config file name]\n", argv[0]);
if(!readConfigFile(conffile, ta))
{
printf("Can not open file config file: %s\n", conffile);
delete ta;
return 1;
}
}
if(!ta->convertWorld())
{
printf("exit with errors\n");
delete ta;
return 1;
}
delete ta;
printf("Ok, all done\n");
return 0;
}

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "7912"
#define REVISION_NR "7913"
#endif // __REVISION_NR_H__

View file

@ -85,12 +85,14 @@ namespace VMAP
bool CoordModelMapping::readCoordinateMapping(const std::string& pDirectoryFileName)
{
FILE *f = fopen(pDirectoryFileName.c_str(), "rb");
bool result = false;
if(!f)
{
printf("ERROR: Can't open file: %s\n",pDirectoryFileName.c_str());
return false;
}
char buffer[500+1];
if(f)
{
result = true;
CMappingEntry* cMappingEntry;
while(fgets(buffer, 500, f))
{
@ -119,6 +121,7 @@ namespace VMAP
if(!iMapIds.contains(mapId))
{
iMapIds.append(mapId);
printf("Coords for map %u...\n",mapId);
}
if(!isWorldAreaMap(mapId))
{
@ -140,8 +143,7 @@ namespace VMAP
}
}
fclose(f);
}
return result;
return true;
}
//============================================================

View file

@ -148,37 +148,41 @@ namespace VMAP
# endif
#endif
bool result = true;
std::string fname = iSrcDir;
fname.append("/");
fname.append("dir");
iCoordModelMapping->setModelNameFilterMethod(iFilterMethod);
iCoordModelMapping->readCoordinateMapping(fname);
printf("Read coordinate mapping...\n");
if(!iCoordModelMapping->readCoordinateMapping(fname))
return false;
Array<unsigned int> mapIds = iCoordModelMapping->getMaps();
if(mapIds.size() == 0)
{
result = false;
printf("Fatal error: empty map list!\n");
return false;
}
for(int i=0; i<mapIds.size() && result; ++i)
for(int i=0; i<mapIds.size(); ++i)
{
unsigned int mapId = mapIds[i];
#ifdef _ASSEMBLER_DEBUG
if(mapId == 0) // "Azeroth" just for debug
{
for(int x=28; x<29 && result; ++x) //debug
for(int x=28; x<29; ++x) //debug
{
for(int y=28; y<29 && result; ++y)
for(int y=28; y<29; ++y)
{
#else
// ignore DeeprunTram (369) it is too large for short vector and not important
// ignore test (13), Test (29) , development (451)
if(mapId != 369 && mapId != 13 && mapId != 29 && mapId != 451)
{
for(int x=0; x<66 && result; ++x)
for(int x=0; x<66; ++x)
{
for(int y=0; y<66 && result; ++y)
for(int y=0; y<66; ++y)
{
#endif
Array<ModelContainer*> mc;
@ -188,15 +192,23 @@ namespace VMAP
{
sprintf(buffer, "%03u_%d_%d",mapId,y,x); // Let's flip x and y here
dirname = std::string(buffer);
printf("%s...\n",dirname.c_str());
}
else
{
sprintf(buffer, "%03u",mapId);
dirname = std::string(buffer);
// prevent spam for small maps
if(x==0 && y==0)
printf("%s...\n",dirname.c_str());
}
result = fillModelContainerArray(dirname, mapId, x, y, mc);
bool result = fillModelContainerArray(dirname, mapId, x, y, mc);
emptyArray(mc);
if(!result)
return false;
}
}
}
@ -205,28 +217,31 @@ namespace VMAP
if(::g_df) fclose(::g_df);
#endif
return result;
return true;
}
//=================================================================
bool TileAssembler::fillModelContainerArray(const std::string& pDirFileName, unsigned int pMapId, int pXPos, int pYPos, Array<ModelContainer*>& pMC)
{
bool result = true;
ModelContainer* modelContainer;
NameCollection nameCollection = iCoordModelMapping->getFilenamesForCoordinate(pMapId, pXPos, pYPos);
if(nameCollection.size() > 0)
{
result = false;
if(nameCollection.size() == 0)
return true; // no data...
char dirfilename[500];
sprintf(dirfilename,"%s/%s.vmdir",iDestDir.c_str(),pDirFileName.c_str());
FILE *dirfile = fopen(dirfilename, "ab");
if(dirfile)
if(!dirfile)
{
result = true;
printf("ERROR: Can't create file %s",dirfilename);
return false;
}
char destnamebuffer[500];
char fullnamedestnamebuffer[500];
if(nameCollection.iMainFiles.size() >0)
{
sprintf(destnamebuffer,"%03u_%i_%i.vmap",pMapId, pYPos, pXPos); // flip it here too
@ -241,18 +256,14 @@ namespace VMAP
sprintf(fullnamedestnamebuffer,"%s/%s",iDestDir.c_str(),destnamebuffer);
modelContainer = processNames(nameCollection.iMainFiles, fullnamedestnamebuffer);
if(modelContainer)
{
pMC.append(modelContainer);
}
else
{
result = false;
}
printf("warning: (if) problems in processing data for %s\n",destnamebuffer);
}
}
// process the large singe files
int pos = 0;
while(result && (pos < nameCollection.iSingeFiles.size()))
while(pos < nameCollection.iSingeFiles.size())
{
std::string destFileName = iDestDir;
destFileName.append("/");
@ -275,21 +286,16 @@ namespace VMAP
modelContainer = processNames(positionarray, destFileName.c_str());
iCoordModelMapping->addAlreadyProcessedSingleFile(nameCollection.iSingeFiles[pos]);
if(modelContainer)
{
pMC.append(modelContainer);
}
else
{
result = false;
}
printf("warning: (while) problems in processing data for %s\n",destFileName.c_str());
}
}
++pos;
}
fclose(dirfile);
}
}
return(result);
return true;
}
//=================================================================
@ -346,8 +352,6 @@ namespace VMAP
//=================================================================
bool TileAssembler::readRawFile(std::string& pModelFilename, ModelPosition& pModelPosition, AABSPTree<SubModel *> *pMainTree)
{
bool result = false;
std::string filename = iSrcDir;
if(filename.length() >0)
filename.append("/");
@ -363,6 +367,14 @@ namespace VMAP
filename.append(baseModelFilename);
rf = fopen(filename.c_str(), "rb");
}
if(!rf)
{
printf("ERROR: Can't open model file in form: %s",pModelFilename.c_str());
printf("... or form: %s",filename );
return false;
}
char ident[8];
int trianglecount =0;
@ -379,11 +391,11 @@ namespace VMAP
#endif
// temporary use defines to simplify read/check code (close file and return at fail)
#define READ_OR_RETURN(V,S) if(fread((V), (S), 1, rf) != 1) { fclose(rf); return(false); }
#define CMP_OR_RETURN(V,S) if(strcmp((V),(S)) != 0) { fclose(rf); return(false); }
#define READ_OR_RETURN(V,S) if(fread((V), (S), 1, rf) != 1) { \
fclose(rf); return(false); }
#define CMP_OR_RETURN(V,S) if(strcmp((V),(S)) != 0) { \
fclose(rf); return(false); }
if(rf)
{
READ_OR_RETURN(&ident, 8);
if(strcmp(ident, "VMAP001") == 0)
{
@ -420,8 +432,10 @@ namespace VMAP
// add free gtree at fail
#undef READ_OR_RETURN
#undef CMP_OR_RETURN
#define READ_OR_RETURN(V,S) if(fread((V), (S), 1, rf) != 1) { fclose(rf); delete gtree; return(false); }
#define CMP_OR_RETURN(V,S) if(strcmp((V),(S)) != 0) { fclose(rf); delete gtree; return(false); }
#define READ_OR_RETURN(V,S) if(fread((V), (S), 1, rf) != 1) { \
fclose(rf); delete gtree; return(false); }
#define CMP_OR_RETURN(V,S) if(strcmp((V),(S)) != 0) { \
fclose(rf); delete gtree; return(false); }
G3D::uint32 flags;
READ_OR_RETURN(&flags, sizeof(G3D::uint32));
@ -447,7 +461,7 @@ namespace VMAP
if(nindexes >0)
{
unsigned short *indexarray = new unsigned short[nindexes*sizeof(unsigned short)];
READ_OR_RETURN(indexarray, sizeof(unsigned short));
READ_OR_RETURN(indexarray, nindexes*sizeof(unsigned short));
for(int i=0;i<(int)nindexes; i++)
{
unsigned short val = indexarray[i];
@ -468,13 +482,15 @@ namespace VMAP
// add vectorarray free
#undef READ_OR_RETURN
#undef CMP_OR_RETURN
#define READ_OR_RETURN(V,S) if(fread((V), (S), 1, rf) != 1) { fclose(rf); delete gtree; delete[] vectorarray; return(false); }
#define CMP_OR_RETURN(V,S) if(strcmp((V),(S)) != 0) { fclose(rf); delete gtree; delete[] vectorarray; return(false); }
#define READ_OR_RETURN(V,S) if(fread((V), (S), 1, rf) != 1) { \
fclose(rf); delete gtree; delete[] vectorarray; return(false); }
#define CMP_OR_RETURN(V,S) if(strcmp((V),(S)) != 0) { \
fclose(rf); delete gtree; delete[] vectorarray; return(false); }
if(nvectors >0)
{
vectorarray = new float[nvectors*sizeof(float)*3];
READ_OR_RETURN(vectorarray, sizeof(float)*3);
READ_OR_RETURN(vectorarray, nvectors*sizeof(float)*3);
}
// ----- liquit
if(flags & 1)
@ -544,16 +560,13 @@ namespace VMAP
delete gtree;
}
fclose(rf);
result = true;
}
return(result);
return true;
}
//=================================================================
bool TileAssembler::fillModelIntoTree(AABSPTree<SubModel *> *pMainTree, const Vector3& pBasePos, std::string& pPos, std::string& pModelFilename)
{
bool result = false;
ModelPosition modelPosition;
getModelPosition(pPos, modelPosition);
// all should be relative to object base position
@ -561,12 +574,7 @@ namespace VMAP
modelPosition.init();
if(readRawFile(pModelFilename, modelPosition, pMainTree))
{
result = true;
}
return result;
return readRawFile(pModelFilename, modelPosition, pMainTree);
}
//=================================================================