mirror of
https://github.com/mangosfour/server.git
synced 2025-12-23 16:37:03 +00:00
[7909] Applied coding style. (cherry picked from commit ed7e72975f4d4f95f5c429f1af6a2c021adfd5a1)
Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
84464e5f3f
commit
f84fdc6757
16 changed files with 1433 additions and 1467 deletions
|
|
@ -58,7 +58,7 @@ char input_path[1024]=".";
|
|||
bool hasInputPathParam = false;
|
||||
char tmp[512];
|
||||
bool preciseVectorData = false;
|
||||
//char gamepath[1024];
|
||||
//char gamepath[1024];
|
||||
|
||||
//Convert function
|
||||
//bool ConvertADT(char*,char*);
|
||||
|
|
@ -86,7 +86,7 @@ static const char * GetPlainName(const char * szFileName)
|
|||
szFileName = szTemp + 1;
|
||||
return szFileName;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
static void ShowProcessedFile(const char * szFileName)
|
||||
{
|
||||
char szLine[80];
|
||||
|
|
@ -101,14 +101,11 @@ static void ShowProcessedFile(const char * szFileName)
|
|||
printf("\r%s\n", szLine);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
||||
{
|
||||
|
||||
char* szListFile = "";
|
||||
char* szListFile = "";
|
||||
char szLocalFile[MAX_PATH] = "";
|
||||
HANDLE hMpq = "";
|
||||
HANDLE hMpq = "";
|
||||
BOOL bResult = FALSE;
|
||||
|
||||
//const char* ParsArchiveNames[] = {"patch-2.MPQ", "patch.MPQ", "common.MPQ", "expansion.MPQ"};
|
||||
|
|
@ -118,9 +115,8 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
|||
szListFile = NULL;
|
||||
//char tmp[1024];
|
||||
//for (size_t i=0; i<4; i++)
|
||||
for (size_t i=0; i<pArchiveNames.size(); i++)
|
||||
for (size_t i=0; i<pArchiveNames.size(); ++i)
|
||||
{
|
||||
|
||||
//sprintf(tmp,"%s\\%s", input_path, ParsArchiveNames[i]);
|
||||
//if(!SFileOpenArchive(tmp, 0, 0, &hMpq))
|
||||
if(!SFileOpenArchive(pArchiveNames[i].c_str(), 0, 0, &hMpq))
|
||||
|
|
@ -128,7 +124,7 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
|||
|
||||
// Copy files from archive
|
||||
if(nError == ERROR_SUCCESS)
|
||||
{
|
||||
{
|
||||
SFILE_FIND_DATA wf;
|
||||
HANDLE hFind = SFileFindFirstFile(hMpq,"*.wmo*", &wf, szListFile);
|
||||
bResult = TRUE;
|
||||
|
|
@ -149,11 +145,11 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
|||
{
|
||||
char cpy[4];
|
||||
strncpy((char*)cpy,rchr,4);
|
||||
for (int i=0;i<4;i++)
|
||||
for (int i=0;i<4; ++i)
|
||||
{
|
||||
int m = cpy[i];
|
||||
if(isdigit(m))
|
||||
p++;
|
||||
p++;
|
||||
}
|
||||
}
|
||||
if(p != 3)
|
||||
|
|
@ -167,12 +163,12 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
|||
bResult = SFileFindNextFile(hFind, &wf);
|
||||
continue;
|
||||
}
|
||||
FILE *output=fopen(szLocalFile,"wb");
|
||||
FILE *output=fopen(szLocalFile,"wb");
|
||||
froot->ConvertToVMAPRootWmo(output);
|
||||
int Wmo_nVertices = 0;
|
||||
if(froot->nGroups !=0)
|
||||
{
|
||||
for (int i=0; i<froot->nGroups; i++)
|
||||
for (int i=0; i<froot->nGroups; ++i)
|
||||
{
|
||||
char temp[512];
|
||||
strcpy(temp, wf.cFileName);
|
||||
|
|
@ -189,14 +185,16 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
|||
bResult = SFileFindNextFile(hFind, &wf);
|
||||
break;
|
||||
}
|
||||
Wmo_nVertices += fgroup->ConvertToVMAPGroupWmo(output, preciseVectorData);
|
||||
Wmo_nVertices += fgroup->ConvertToVMAPGroupWmo(output, preciseVectorData);
|
||||
}
|
||||
}
|
||||
fseek(output, 8, SEEK_SET); // store the correct no of vertices
|
||||
fwrite(&Wmo_nVertices,sizeof(int),1,output);
|
||||
fclose(output);
|
||||
fclose(output);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
fclose(n);
|
||||
}
|
||||
wf.dwFileFlags &= ~MPQ_FILE_HAS_EXTRA;
|
||||
|
|
@ -220,29 +218,27 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
|
|||
printf("\nExtract wmo complete (No errors)\n");
|
||||
|
||||
return nError;
|
||||
|
||||
}
|
||||
|
||||
void ExtractMapsFromMpq()
|
||||
{
|
||||
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ParsMapFiles()
|
||||
{
|
||||
char fn[512];
|
||||
char id_filename[64];
|
||||
char id[10];
|
||||
for (unsigned int i=0; i<map_count; i++)
|
||||
for (unsigned int i=0; i<map_count; ++i)
|
||||
{
|
||||
sprintf(id,"%03u",map_ids[i].id);
|
||||
sprintf(fn,"World\\Maps\\%s\\%s.wdt", map_ids[i].name, map_ids[i].name);
|
||||
WDTFile WDT(fn,map_ids[i].name);
|
||||
if(WDT.init(id))
|
||||
{
|
||||
for (int x=0; x<64; x++)
|
||||
for (int x=0; x<64; ++x)
|
||||
{
|
||||
for (int y=0; y<64; y++)
|
||||
for (int y=0; y<64; ++y)
|
||||
{
|
||||
if (ADTFile*ADT = WDT.GetMap(x,y))
|
||||
{
|
||||
|
|
@ -250,7 +246,6 @@ void ParsMapFiles()
|
|||
ADT->init(id_filename);
|
||||
delete ADT;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -259,31 +254,28 @@ void ParsMapFiles()
|
|||
#if 0
|
||||
void ParsMapFiles()
|
||||
{
|
||||
|
||||
char fn[512];
|
||||
for (unsigned int i=0; i<map_count; i++)
|
||||
for (unsigned int i=0; i<map_count; ++i)
|
||||
{
|
||||
sprintf(fn,"World\\Maps\\%s\\%s.wdt", map_ids[i].name, map_ids[i].name);
|
||||
WDTFile WDT(fn,map_ids[i].name);
|
||||
if(WDT.init())
|
||||
{
|
||||
for (int x=0; x<64; x++)
|
||||
for (int x=0; x<64; ++x)
|
||||
{
|
||||
for (int y=0; y<64; y++)
|
||||
for (int y=0; y<64; ++y)
|
||||
{
|
||||
if (ADTFile*ADT = WDT.GetMap(x,y))
|
||||
{
|
||||
ADT->init();
|
||||
delete ADT;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
void getGamePath()
|
||||
{
|
||||
|
|
@ -297,18 +289,16 @@ void getGamePath()
|
|||
//l = RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Blizzard Entertainment\\Burning Crusade Closed Beta",0,KEY_QUERY_VALUE,&key);
|
||||
l = RegQueryValueEx(key,"InstallPath",0,&t,(LPBYTE)input_path,&s);
|
||||
RegCloseKey(key);
|
||||
if (strlen(input_path) > 0)
|
||||
{
|
||||
if (input_path[strlen(input_path) - 1] != '\\') strcat(input_path, "\\");
|
||||
}
|
||||
if (strlen(input_path) > 0)
|
||||
{
|
||||
if (input_path[strlen(input_path) - 1] != '\\') strcat(input_path, "\\");
|
||||
}
|
||||
strcat(input_path,"Data\\");
|
||||
#else
|
||||
strcpy(input_path,"data/");
|
||||
#endif
|
||||
}
|
||||
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
bool scan_patches(char* scanmatch, std::vector<std::string>& pArchiveNames)
|
||||
{
|
||||
int i;
|
||||
|
|
@ -338,7 +328,7 @@ bool scan_patches(char* scanmatch, std::vector<std::string>& pArchiveNames)
|
|||
}
|
||||
|
||||
matches.reverse();
|
||||
for (std::list<std::string>::iterator i = matches.begin(); i != matches.end(); i++)
|
||||
for (std::list<std::string>::iterator i = matches.begin(); i != matches.end(); ++i)
|
||||
{
|
||||
pArchiveNames.push_back(i->c_str());
|
||||
}
|
||||
|
|
@ -348,11 +338,8 @@ bool scan_patches(char* scanmatch, std::vector<std::string>& pArchiveNames)
|
|||
return(true);
|
||||
}
|
||||
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames) {
|
||||
//srand((unsigned int)time(0));
|
||||
|
||||
bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames)
|
||||
{
|
||||
if(!hasInputPathParam)
|
||||
getGamePath();
|
||||
|
||||
|
|
@ -408,11 +395,12 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames) {
|
|||
// now, scan for the patch levels in the core dir
|
||||
printf("Loading patch levels from data directory.\n");
|
||||
sprintf(path, "%spatch", input_path);
|
||||
if (!scan_patches(path, pArchiveNames)) return(false);
|
||||
if (!scan_patches(path, pArchiveNames))
|
||||
return(false);
|
||||
|
||||
// now, scan for the patch levels in locale dirs
|
||||
printf("Loading patch levels from locale directories.\n");
|
||||
for (std::vector<std::string>::iterator i = locales.begin(); i != locales.end(); i++)
|
||||
for (std::vector<std::string>::iterator i = locales.begin(); i != locales.end(); ++i)
|
||||
{
|
||||
printf("Locale: %s\n", i->c_str());
|
||||
sprintf(path, "%s%s\\patch-%s", input_path, i->c_str(), i->c_str());
|
||||
|
|
@ -433,7 +421,7 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames) {
|
|||
|
||||
// open locale expansion and common files
|
||||
printf("Opening data files from locale directories.\n");
|
||||
for (std::vector<std::string>::iterator i = locales.begin(); i != locales.end(); i++)
|
||||
for (std::vector<std::string>::iterator i = locales.begin(); i != locales.end(); ++i)
|
||||
{
|
||||
printf("Locale: %s\n", i->c_str());
|
||||
sprintf(path, "%s%s\\lichking-locale-%s.mpq", input_path, i->c_str(), i->c_str());
|
||||
|
|
@ -446,8 +434,6 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames) {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
// return false it normal processing can not proceed
|
||||
|
||||
bool processArgv(int argc, char ** argv, char*versionString)
|
||||
{
|
||||
|
|
@ -455,29 +441,43 @@ bool processArgv(int argc, char ** argv, char*versionString)
|
|||
hasInputPathParam = false;
|
||||
bool preciseVectorData = false;
|
||||
|
||||
for(int i=1; i< argc; ++i) {
|
||||
if(strcmp("-s",argv[i]) == 0) {
|
||||
preciseVectorData = false;
|
||||
} else if(strcmp("-d",argv[i]) == 0) {
|
||||
if((i+1)<argc) {
|
||||
for(int i=1; i< argc; ++i)
|
||||
{
|
||||
if(strcmp("-s",argv[i]) == 0)
|
||||
{
|
||||
preciseVectorData = false;
|
||||
}
|
||||
else if(strcmp("-d",argv[i]) == 0)
|
||||
{
|
||||
if((i+1)<argc)
|
||||
{
|
||||
hasInputPathParam = true;
|
||||
strcpy(input_path, argv[i+1]);
|
||||
if (input_path[strlen(input_path) - 1] != '\\' || input_path[strlen(input_path) - 1] != '/')
|
||||
strcat(input_path, "\\");
|
||||
++i;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
} else if(strcmp("-?",argv[1]) == 0) {
|
||||
}
|
||||
else if(strcmp("-?",argv[1]) == 0)
|
||||
{
|
||||
result = false;
|
||||
} else if(strcmp("-l",argv[i]) == 0) {
|
||||
preciseVectorData = true;
|
||||
} else {
|
||||
}
|
||||
else if(strcmp("-l",argv[i]) == 0)
|
||||
{
|
||||
preciseVectorData = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!result) {
|
||||
if(!result)
|
||||
{
|
||||
printf("Extract %s.\n",versionString);
|
||||
printf("%s [-?][-s][-l][-d <path>]\n", argv[0]);
|
||||
printf(" -s : (default) small size (data size optimization), ~500MB less vmap data.\n");
|
||||
|
|
@ -512,9 +512,9 @@ int main(int argc, char ** argv)
|
|||
char *versionString = "V2.4 2007_07_12";
|
||||
|
||||
// Use command line arguments, when some
|
||||
if(!processArgv(argc, argv, versionString))
|
||||
if(!processArgv(argc, argv, versionString))
|
||||
return 1;
|
||||
|
||||
|
||||
printf("Extract %s. Beginning work ....\n",versionString);
|
||||
// Set the lowest priority to allow running in the background
|
||||
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL);
|
||||
|
|
@ -528,7 +528,7 @@ int main(int argc, char ** argv)
|
|||
nError = GetLastError();
|
||||
if(nError == ERROR_ALREADY_EXISTS)
|
||||
nError = ERROR_SUCCESS;
|
||||
}
|
||||
}
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
// patch goes first -> fake priority handling
|
||||
std::vector<MPQArchive*> archives;
|
||||
|
|
@ -537,7 +537,8 @@ int main(int argc, char ** argv)
|
|||
std::vector<std::string> archiveNames;
|
||||
|
||||
fillArchiveNameVector(archiveNames);
|
||||
for (size_t i=0; i<archiveNames.size(); i++) {
|
||||
for (size_t i=0; i<archiveNames.size(); ++i)
|
||||
{
|
||||
archives.push_back(new MPQArchive(archiveNames[i].c_str()));
|
||||
}
|
||||
ExtractWmo(archiveNames);
|
||||
|
|
@ -550,11 +551,11 @@ int main(int argc, char ** argv)
|
|||
dbc->open();
|
||||
map_count=dbc->getRecordCount ();
|
||||
map_ids=new map_id[map_count];
|
||||
for(unsigned int x=0;x<map_count;x++)
|
||||
for(unsigned int x=0;x<map_count;++x)
|
||||
{
|
||||
map_ids[x].id=dbc->getRecord (x).getUInt(0);
|
||||
strcpy(map_ids[x].name,dbc->getRecord(x).getString(1));
|
||||
printf("Map - %s\n",map_ids[x].name);
|
||||
printf("Map - %s\n",map_ids[x].name);
|
||||
}
|
||||
|
||||
delete dbc;
|
||||
|
|
@ -564,7 +565,8 @@ int main(int argc, char ** argv)
|
|||
}
|
||||
|
||||
clreol();
|
||||
if(nError != ERROR_SUCCESS) {
|
||||
if(nError != ERROR_SUCCESS)
|
||||
{
|
||||
printf("ERROR: Extract %s. Work NOT complete.\n Precise vector data=%d.\nPress any key.\n",versionString, preciseVectorData);
|
||||
_getch();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue