[c12536] Happy New Year 2013

Update authorship information and prepare for easier ways next year

Signed-off-by: Schmoozerd <schmoozerd@cmangos>

(based on commit [12325] - b7dbcda)
This commit is contained in:
Schmoozerd 2013-03-03 17:39:21 +02:00 committed by Antz
parent 86a243c910
commit a05738717a
542 changed files with 3274 additions and 1846 deletions

24
AUTHORS
View file

@ -1,9 +1,17 @@
SPECIAL THANKS TO THE MAIN CONTRIBUTORS OF THE MaNGOS PROJECT (LISTED BELOW)
This file contains authorship information related to the Continued-MaNGOS Project
Julius "h" Kivimaki
Ryan "I'm Sabu" Cleary
Chris "Realm of Tearrrroorr" Metzen
Jeffrey "Tigole" Kaplan
Rob "EnoYls" Pardo
Michael "Lamborghini" Morhaime
Bobby "I need a raise" Kotick
The code of C-MaNGOS is shipped as it is without any form of warenty,
and - except for third party libraries - licensed under the GPL 2.0,
which you can read from the file "COPYING"
* The authors are assigned to by git commit authorship information,
listed within the git commit messages, or if forgotten before mentioned in the github comments related to a commit.
* The most recent history can be checked at https://github.com/cmangos/mangos-wotlk
* The older history (from svn times) is backed up and can be checked at https://github.com/cmangos/mangos-svn
* Initially the code for this project was written by Wow Daemon team.
The third party libraries have their own way of addressing authorship, and the authorship of commits importing/ updating
a third party library reflects who did the importing instead of who wrote the code within the commit.

View file

@ -1,5 +1,5 @@
#
# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

2
NEWS
View file

@ -1,6 +1,6 @@
= MaNGOS -- History of visible changes =
Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
This file is part of the Continued-MaNGOS Project
See the COPYING file for copying conditions.

View file

@ -1,5 +1,5 @@
#
# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
#
# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
#
# Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
#
# Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
This small Python script is intended to help with the convertion

View file

@ -1,4 +1,4 @@
# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without

View file

@ -1,4 +1,4 @@
# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without

View file

@ -1,6 +1,6 @@
#!/bin/sh
# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without

View file

@ -1,6 +1,6 @@
#!/bin/sh
# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without

View file

@ -1,4 +1,4 @@
# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -52,9 +52,10 @@
#define NUM_REMOTES 2
#define NUM_DATABASES 3
char remotes[NUM_REMOTES][MAX_REMOTE] = {
"git@github.com:mangos/server.git",
"git://github.com/mangos/server.git" // used for fetch if present
char remotes[NUM_REMOTES][MAX_REMOTE] =
{
"git@github.com:cmangos/mangos-cata.git",
"git://github.com/cmangos/mangos-cata.git" // used for fetch if present
};
char remote_branch[MAX_REMOTE] = "master";
@ -63,30 +64,46 @@ char rev_sql_file[MAX_PATH] = "src/shared/revision_sql.h";
char sql_update_dir[MAX_PATH] = "sql/updates";
char new_index_file[MAX_PATH] = ".git/git_id_index";
char databases[NUM_DATABASES][MAX_DB] = {
char databases[NUM_DATABASES][MAX_DB] =
{
"characters",
"mangos",
"realmd"
};
char db_version_table[NUM_DATABASES][MAX_DB] = {
char db_version_table[NUM_DATABASES][MAX_DB] =
{
"character_db_version",
"db_version",
"realmd_db_version",
};
char db_sql_file[NUM_DATABASES][MAX_PATH] = {
char db_sql_file[NUM_DATABASES][MAX_PATH] =
{
"sql/characters.sql",
"sql/mangos.sql",
"sql/realmd.sql"
};
char db_sql_rev_field[NUM_DATABASES][MAX_PATH] = {
char db_sql_rev_field[NUM_DATABASES][MAX_PATH] =
{
"REVISION_DB_CHARACTERS",
"REVISION_DB_MANGOS",
"REVISION_DB_REALMD"
};
bool db_sql_rev_parent[NUM_DATABASES] =
{
false,
false,
true
};
#define REV_PREFIX "c"
#define REV_SCAN REV_PREFIX "%d"
#define REV_PRINT REV_PREFIX "%04d"
#define REV_FORMAT "[" REV_PRINT "]"
bool allow_replace = false;
bool local = false;
bool do_fetch = false;
@ -97,8 +114,8 @@ bool generate_makefile = false; // not need for cmak
char origins[NUM_REMOTES][MAX_REMOTE];
int rev;
int last_sql_rev[NUM_DATABASES] = {0,0,0};
int last_sql_nr[NUM_DATABASES] = {0,0,0};
int last_sql_rev[NUM_DATABASES] = {0, 0, 0};
int last_sql_nr[NUM_DATABASES] = {0, 0, 0};
char head_message[MAX_MSG];
char path_prefix[MAX_PATH] = "";
@ -112,18 +129,18 @@ char new_index_cmd[MAX_CMD];
std::set<std::string> new_sql_updates;
FILE *cmd_pipe;
FILE* cmd_pipe;
bool find_path()
{
printf("+ finding path\n");
char *ptr;
char* ptr;
char cur_path[MAX_PATH];
getcwd(cur_path, MAX_PATH);
size_t len = strlen(cur_path);
strncpy(base_path, cur_path, len+1);
strncpy(base_path, cur_path, len + 1);
if(cur_path[len-1] == '/' || cur_path[len-1] == '\\')
if (cur_path[len - 1] == '/' || cur_path[len - 1] == '\\')
{
// we're in root, don't bother
return false;
@ -131,15 +148,15 @@ bool find_path()
// don't count the root
int count_fwd = 0, count_back = 0;
for(ptr = cur_path-1; ptr = strchr(ptr+1, '/'); count_fwd++);
for(ptr = cur_path-1; ptr = strchr(ptr+1, '\\'); count_back++);
for (ptr = cur_path - 1; ptr = strchr(ptr + 1, '/'); count_fwd++);
for (ptr = cur_path - 1; ptr = strchr(ptr + 1, '\\'); count_back++);
int count = std::max(count_fwd, count_back);
char path[MAX_PATH];
for(int i = 0; i < count; i++)
for (int i = 0; i < count; i++)
{
snprintf(path, MAX_PATH, "%s.git", path_prefix);
if(0 == chdir(path))
if (0 == chdir(path))
{
chdir(cur_path);
return true;
@ -147,11 +164,11 @@ bool find_path()
strncat(path_prefix, "../", MAX_PATH);
ptr = strrchr(base_path, '\\');
if(ptr) *ptr = '\0';
if (ptr) *ptr = '\0';
else
{
ptr = strrchr(base_path, '/');
if(ptr) *ptr = '\0';
if (ptr) *ptr = '\0';
}
}
@ -161,17 +178,17 @@ bool find_path()
bool find_origin()
{
printf("+ finding origin\n");
if( (cmd_pipe = popen( "git remote -v", "r" )) == NULL )
if ((cmd_pipe = popen("git remote -v", "r")) == NULL)
return false;
bool ret = false;
while(fgets(buffer, MAX_BUF, cmd_pipe))
while (fgets(buffer, MAX_BUF, cmd_pipe))
{
char name[256], remote[MAX_REMOTE];
sscanf(buffer, "%s %s", name, remote);
for(int i = 0; i < NUM_REMOTES; i++)
for (int i = 0; i < NUM_REMOTES; i++)
{
if(strcmp(remote, remotes[i]) == 0)
if (strcmp(remote, remotes[i]) == 0)
{
strncpy(origins[i], name, MAX_REMOTE);
ret = true;
@ -195,21 +212,21 @@ bool check_fwd()
{
printf("+ checking fast forward\n");
snprintf(cmd, MAX_CMD, "git log -n 1 --pretty=\"format:%%H\" %s/%s", (origins[1][0] ? origins[1] : origins[0]), remote_branch);
if( (cmd_pipe = popen( cmd, "r" )) == NULL )
if ((cmd_pipe = popen(cmd, "r")) == NULL)
return false;
if(!fgets(buffer, MAX_BUF, cmd_pipe)) return false;
if (!fgets(buffer, MAX_BUF, cmd_pipe)) return false;
strncpy(origin_hash, buffer, MAX_HASH);
pclose(cmd_pipe);
if( (cmd_pipe = popen( "git log --pretty=\"format:%H\"", "r" )) == NULL )
if ((cmd_pipe = popen("git log --pretty=\"format:%H\"", "r")) == NULL)
return false;
bool found = false;
while(fgets(buffer, MAX_BUF, cmd_pipe))
while (fgets(buffer, MAX_BUF, cmd_pipe))
{
buffer[strlen(buffer) - 1] = '\0';
if(strncmp(origin_hash, buffer, MAX_BUF) == 0)
if (strncmp(origin_hash, buffer, MAX_BUF) == 0)
{
found = true;
break;
@ -217,22 +234,24 @@ bool check_fwd()
}
pclose(cmd_pipe);
if(!found)
if (!found)
{
// with fetch you still get the latest rev, you just rebase afterwards and push
// without it you may not get the right rev
if(do_fetch) printf("WARNING: non-fastforward, use rebase!\n");
if (do_fetch) printf("WARNING: non-fastforward, use rebase!\n");
else { printf("ERROR: non-fastforward, use rebase!\n"); return false; }
}
return true;
}
int get_rev(const char *from_msg)
int get_rev(const char* from_msg)
{
// accept only the rev number format, not the sql update format
char nr_str[256];
if(sscanf(from_msg, "[%[0123456789]]", nr_str) != 1) return 0;
if(from_msg[strlen(nr_str)+1] != ']') return 0;
if (sscanf(from_msg, "[" REV_PREFIX "%[0123456789]]", nr_str) != 1) return 0;
// ("[")+(REV_PREFIX)+("]")-1
if (from_msg[strlen(nr_str) + strlen(REV_PREFIX) + 2 - 1] != ']') return 0;
return atoi(nr_str);
}
@ -240,26 +259,26 @@ bool find_rev()
{
printf("+ finding next revision number\n");
// find the highest rev number on either of the remotes
for(int i = 0; i < NUM_REMOTES; i++)
for (int i = 0; i < NUM_REMOTES; i++)
{
if(!local && !origins[i][0]) continue;
if (!local && !origins[i][0]) continue;
if(local) snprintf(cmd, MAX_CMD, "git log HEAD --pretty=\"format:%%s\"");
if (local) snprintf(cmd, MAX_CMD, "git log HEAD --pretty=\"format:%%s\"");
else sprintf(cmd, "git log %s/%s --pretty=\"format:%%s\"", origins[i], remote_branch);
if( (cmd_pipe = popen( cmd, "r" )) == NULL )
if ((cmd_pipe = popen(cmd, "r")) == NULL)
continue;
int nr;
while(fgets(buffer, MAX_BUF, cmd_pipe))
while (fgets(buffer, MAX_BUF, cmd_pipe))
{
nr = get_rev(buffer);
if(nr >= rev)
rev = nr+1;
if (nr >= rev)
rev = nr + 1;
}
pclose(cmd_pipe);
}
if(rev > 0) printf("Found [%d].\n", rev);
if (rev > 0) printf("Found " REV_FORMAT ".\n", rev);
return rev > 0;
}
@ -279,38 +298,40 @@ std::string generateSqlHeader()
std::ostringstream newData;
newData << "#ifndef __REVISION_SQL_H__" << std::endl;
newData << "#define __REVISION_SQL_H__" << std::endl;
for(int i = 0; i < NUM_DATABASES; ++i)
for (int i = 0; i < NUM_DATABASES; ++i)
{
newData << " #define " << db_sql_rev_field[i] << " \"required_" << last_sql_update[i] << "\"" << std::endl;
}
newData << "#endif // __REVISION_SQL_H__" << std::endl;
return newData.str();
}
void system_switch_index(const char *cmd)
void system_switch_index(const char* cmd)
{
// do the command for the original index and then for the new index
// both need to be updated with the changes before commit
// but the new index will contains only the desired changes
// while the old may contain others
system(cmd);
if(!use_new_index) return;
if(putenv(new_index_cmd) != 0) return;
if (!use_new_index) return;
if (putenv(new_index_cmd) != 0) return;
system(cmd);
if(putenv(old_index_cmd) != 0) return;
if (putenv(old_index_cmd) != 0) return;
}
bool write_rev_nr()
{
printf("+ writing revision_nr.h\n");
char rev_str[256];
sprintf(rev_str, "%d", rev);
sprintf(rev_str, "%04d", rev);
std::string header = generateNrHeader(rev_str);
char prefixed_file[MAX_PATH];
snprintf(prefixed_file, MAX_PATH, "%s%s", path_prefix, rev_nr_file);
if(FILE* OutputFile = fopen(prefixed_file, "wb"))
if (FILE* OutputFile = fopen(prefixed_file, "wb"))
{
fprintf(OutputFile,"%s", header.c_str());
fprintf(OutputFile, "%s", header.c_str());
fclose(OutputFile);
// add the file to both indices, to be committed later
@ -325,16 +346,16 @@ bool write_rev_nr()
bool write_rev_sql()
{
if(new_sql_updates.empty()) return true;
if (new_sql_updates.empty()) return true;
printf("+ writing revision_sql.h\n");
std::string header = generateSqlHeader();
char prefixed_file[MAX_PATH];
snprintf(prefixed_file, MAX_PATH, "%s%s", path_prefix, rev_sql_file);
if(FILE* OutputFile = fopen(prefixed_file, "wb"))
if (FILE* OutputFile = fopen(prefixed_file, "wb"))
{
fprintf(OutputFile,"%s", header.c_str());
fprintf(OutputFile, "%s", header.c_str());
fclose(OutputFile);
// add the file to both indices, to be committed later
@ -350,28 +371,28 @@ bool write_rev_sql()
bool find_head_msg()
{
printf("+ finding last message on HEAD\n");
if( (cmd_pipe = popen( "git log -n 1 --pretty=\"format:%s%n%n%b\"", "r" )) == NULL )
if ((cmd_pipe = popen("git log -n 1 --pretty=\"format:%s%n%n%b\"", "r")) == NULL)
return false;
int poz = 0;
while(poz < 16384-1 && EOF != (head_message[poz++] = fgetc(cmd_pipe)));
head_message[poz-1] = '\0';
while (poz < 16384 - 1 && EOF != (head_message[poz++] = fgetc(cmd_pipe)));
head_message[poz - 1] = '\0';
pclose(cmd_pipe);
if(int head_rev = get_rev(head_message))
if (int head_rev = get_rev(head_message))
{
if(!allow_replace)
if (!allow_replace)
{
printf("Last commit on HEAD is [%d]. Use -r to replace it with [%d].\n", head_rev, rev);
printf("Last commit on HEAD is " REV_FORMAT ". Use -r to replace it with " REV_FORMAT ".\n", head_rev, rev);
return false;
}
// skip the rev number in the commit
char *p = strchr(head_message, ']'), *q = head_message;
assert(p && *(p+1));
p+=2;
while(*p) *q = *p, p++, q++;
char* p = strchr(head_message, ']'), *q = head_message;
assert(p && *(p + 1));
p += 2;
while (*p) *q = *p, p++, q++;
*q = 0;
return true;
}
@ -384,14 +405,14 @@ bool amend_commit()
printf("+ amending last commit\n");
// commit the contents of the (new) index
if(use_new_index && putenv(new_index_cmd) != 0) return false;
if (use_new_index && putenv(new_index_cmd) != 0) return false;
snprintf(cmd, MAX_CMD, "git commit --amend -F-");
if( (cmd_pipe = popen( cmd, "w" )) == NULL )
if ((cmd_pipe = popen(cmd, "w")) == NULL)
return false;
fprintf(cmd_pipe, "[%d] %s", rev, head_message);
fprintf(cmd_pipe, REV_FORMAT " %s", rev, head_message);
pclose(cmd_pipe);
if(use_new_index && putenv(old_index_cmd) != 0) return false;
if (use_new_index && putenv(old_index_cmd) != 0) return false;
return true;
}
@ -399,6 +420,7 @@ bool amend_commit()
struct sql_update_info
{
int rev;
char parentRev[MAX_BUF];
int nr;
int db_idx;
char db[MAX_BUF];
@ -406,24 +428,24 @@ struct sql_update_info
bool has_table;
};
bool get_sql_update_info(const char *buffer, sql_update_info &info)
bool get_sql_update_info(const char* buffer, sql_update_info& info)
{
info.table[0] = '\0';
int dummy[3];
if(sscanf(buffer, "%d_%d_%d", &dummy[0], &dummy[1], &dummy[2]) == 3)
if (sscanf(buffer, REV_SCAN "_%[^_]_%d_%d", &dummy[0], &dummy[1], &dummy[2]) == 3)
return false;
if(sscanf(buffer, "%d_%d_%[^_]_%[^.].sql", &info.rev, &info.nr, info.db, info.table) != 4 &&
sscanf(buffer, "%d_%d_%[^.].sql", &info.rev, &info.nr, info.db) != 3)
if (sscanf(buffer, REV_SCAN "_%[^_]_%d_%[^_]_%[^.].sql", &info.rev, &info.nr, info.db, info.table) != 4 &&
sscanf(buffer, REV_SCAN "_%[^_]_%d_%[^.].sql", &info.rev, &info.nr, info.db) != 3)
{
info.rev = 0; // this may be set by the first scans, even if they fail
if(sscanf(buffer, "%d_%[^_]_%[^.].sql", &info.nr, info.db, info.table) != 3 &&
sscanf(buffer, "%d_%[^.].sql", &info.nr, info.db) != 2)
if (sscanf(buffer, "%d_%[^_]_%[^.].sql", &info.nr, info.db, info.table) != 3 &&
sscanf(buffer, "%d_%[^.].sql", &info.nr, info.db) != 2)
return false;
}
for(info.db_idx = 0; info.db_idx < NUM_DATABASES; info.db_idx++)
if(strncmp(info.db, databases[info.db_idx], MAX_DB) == 0) break;
for (info.db_idx = 0; info.db_idx < NUM_DATABASES; info.db_idx++)
if (strncmp(info.db, databases[info.db_idx], MAX_DB) == 0) break;
info.has_table = (info.table[0] != '\0');
return true;
}
@ -433,24 +455,24 @@ bool find_sql_updates()
printf("+ finding new sql updates on HEAD\n");
// add all updates from HEAD
snprintf(cmd, MAX_CMD, "git show HEAD:%s", sql_update_dir);
if( (cmd_pipe = popen( cmd, "r" )) == NULL )
if ((cmd_pipe = popen(cmd, "r")) == NULL)
return false;
// skip first two lines
if(!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; }
if(!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; }
if (!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; }
if (!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; }
sql_update_info info;
while(fgets(buffer, MAX_BUF, cmd_pipe))
while (fgets(buffer, MAX_BUF, cmd_pipe))
{
buffer[strlen(buffer) - 1] = '\0';
if(!get_sql_update_info(buffer, info)) continue;
if (!get_sql_update_info(buffer, info)) continue;
if(info.db_idx == NUM_DATABASES)
if (info.db_idx == NUM_DATABASES)
{
if(info.rev > 0) printf("WARNING: incorrect database name for sql update %s\n", buffer);
continue;
if (info.rev > 0) printf("WARNING: incorrect database name for sql update %s\n", buffer);
continue;
}
new_sql_updates.insert(buffer);
@ -458,27 +480,35 @@ bool find_sql_updates()
pclose(cmd_pipe);
// Add last milestone's file information
last_sql_rev[0] = 12300;
last_sql_nr[0] = 2;
sscanf("12300_02_characters_mail", "%s", last_sql_update[0]);
last_sql_rev[2] = 12112;
last_sql_nr[2] = 1;
sscanf("12112_01_realmd_account_access", "%s", last_sql_update[2]);
// remove updates from the last commit also found on origin
snprintf(cmd, MAX_CMD, "git show %s:%s", origin_hash, sql_update_dir);
if( (cmd_pipe = popen( cmd, "r" )) == NULL )
if ((cmd_pipe = popen(cmd, "r")) == NULL)
return false;
// skip first two lines
if(!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; }
if(!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; }
if (!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; }
if (!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; }
while(fgets(buffer, MAX_BUF, cmd_pipe))
while (fgets(buffer, MAX_BUF, cmd_pipe))
{
buffer[strlen(buffer) - 1] = '\0';
if(!get_sql_update_info(buffer, info)) continue;
if (!get_sql_update_info(buffer, info)) continue;
// find the old update with the highest rev for each database
// (will be the required version for the new update)
std::set<std::string>::iterator itr = new_sql_updates.find(buffer);
if(itr != new_sql_updates.end() )
if (itr != new_sql_updates.end())
{
if(info.rev > 0 && (info.rev > last_sql_rev[info.db_idx] ||
(info.rev == last_sql_rev[info.db_idx] && info.nr > last_sql_nr[info.db_idx])))
if (info.rev > 0 && (info.rev > last_sql_rev[info.db_idx] ||
(info.rev == last_sql_rev[info.db_idx] && info.nr > last_sql_nr[info.db_idx])))
{
last_sql_rev[info.db_idx] = info.rev;
last_sql_nr[info.db_idx] = info.nr;
@ -490,9 +520,9 @@ bool find_sql_updates()
pclose(cmd_pipe);
if(!new_sql_updates.empty())
if (!new_sql_updates.empty())
{
for(std::set<std::string>::iterator itr = new_sql_updates.begin(); itr != new_sql_updates.end(); ++itr)
for (std::set<std::string>::iterator itr = new_sql_updates.begin(); itr != new_sql_updates.end(); ++itr)
printf("%s\n", itr->c_str());
}
else
@ -501,14 +531,14 @@ bool find_sql_updates()
return true;
}
bool copy_file(const char *src_file, const char *dst_file)
bool copy_file(const char* src_file, const char* dst_file)
{
FILE * fin = fopen( src_file, "rb" );
if(!fin) return false;
FILE * fout = fopen( dst_file, "wb" );
if(!fout) { fclose(fin); return false; }
FILE* fin = fopen(src_file, "rb");
if (!fin) return false;
FILE* fout = fopen(dst_file, "wb");
if (!fout) { fclose(fin); return false; }
for(char c = getc(fin); !feof(fin); putc(c, fout), c = getc(fin));
for (char c = getc(fin); !feof(fin); putc(c, fout), c = getc(fin));
fclose(fin);
fclose(fout);
@ -517,16 +547,16 @@ bool copy_file(const char *src_file, const char *dst_file)
bool convert_sql_updates()
{
if(new_sql_updates.empty()) return true;
if (new_sql_updates.empty()) return true;
printf("+ converting sql updates\n");
// rename the sql update files and add the required update statement
for(std::set<std::string>::iterator itr = new_sql_updates.begin(); itr != new_sql_updates.end(); ++itr)
for (std::set<std::string>::iterator itr = new_sql_updates.begin(); itr != new_sql_updates.end(); ++itr)
{
sql_update_info info;
if(!get_sql_update_info(itr->c_str(), info)) return false;
if(info.db_idx == NUM_DATABASES) return false;
if (!get_sql_update_info(itr->c_str(), info)) return false;
if (info.db_idx == NUM_DATABASES) return false;
// generating the new name should work for updates with or without a rev
char src_file[MAX_PATH], new_name[MAX_PATH], dst_file[MAX_PATH];
@ -534,8 +564,8 @@ bool convert_sql_updates()
snprintf(new_name, MAX_PATH, "%d_%0*d_%s%s%s", rev, 2, info.nr, info.db, info.has_table ? "_" : "", info.table);
snprintf(dst_file, MAX_PATH, "%s%s/%s.sql", path_prefix, sql_update_dir, new_name);
FILE * fin = fopen( src_file, "r" );
if(!fin) return false;
FILE* fin = fopen(src_file, "r");
if (!fin) return false;
std::ostringstream out_buff;
@ -546,12 +576,12 @@ bool convert_sql_updates()
// skip the first one or two lines from the input
// if it already contains update requirements
if(fgets(buffer, MAX_BUF, fin))
if (fgets(buffer, MAX_BUF, fin))
{
char dummy[MAX_BUF];
if(sscanf(buffer, "ALTER TABLE %s CHANGE COLUMN required_%s required_%s bit", dummy, dummy, dummy) == 3)
if (sscanf(buffer, "ALTER TABLE %s CHANGE COLUMN required_%s required_%s bit", dummy, dummy, dummy) == 3)
{
if(fgets(buffer, MAX_BUF, fin) && buffer[0] != '\n')
if (fgets(buffer, MAX_BUF, fin) && buffer[0] != '\n')
out_buff << buffer;
}
else
@ -559,15 +589,15 @@ bool convert_sql_updates()
}
// copy the rest of the file
while(fgets(buffer, MAX_BUF, fin))
while (fgets(buffer, MAX_BUF, fin))
out_buff << buffer;
fclose(fin);
FILE * fout = fopen( dst_file, "w" );
if(!fout) { fclose(fin); return false; }
FILE* fout = fopen(dst_file, "w");
if (!fout) { fclose(fin); return false; }
fprintf(fout, "%s",out_buff.str().c_str());
fprintf(fout, "%s", out_buff.str().c_str());
fclose(fout);
@ -576,7 +606,7 @@ bool convert_sql_updates()
system_switch_index(cmd);
// delete src file if it different by name from dst file
if(strncmp(src_file,dst_file,MAX_PATH))
if (strncmp(src_file, dst_file, MAX_PATH))
{
snprintf(cmd, MAX_CMD, "git rm --quiet %s", src_file);
system_switch_index(cmd);
@ -591,30 +621,30 @@ bool convert_sql_updates()
bool generate_sql_makefile()
{
if(new_sql_updates.empty()) return true;
if (new_sql_updates.empty()) return true;
// find all files in the update dir
snprintf(cmd, MAX_CMD, "git show HEAD:%s", sql_update_dir);
if( (cmd_pipe = popen( cmd, "r" )) == NULL )
if ((cmd_pipe = popen(cmd, "r")) == NULL)
return false;
// skip first two lines
if(!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; }
if(!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; }
if (!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; }
if (!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; }
char newname[MAX_PATH];
std::set<std::string> file_list;
sql_update_info info;
while(fgets(buffer, MAX_BUF, cmd_pipe))
while (fgets(buffer, MAX_BUF, cmd_pipe))
{
buffer[strlen(buffer) - 1] = '\0';
if(buffer[strlen(buffer) - 1] != '/' &&
strncmp(buffer, "Makefile.am", MAX_BUF) != 0)
if (buffer[strlen(buffer) - 1] != '/' &&
strncmp(buffer, "Makefile.am", MAX_BUF) != 0)
{
if(new_sql_updates.find(buffer) != new_sql_updates.end())
if (new_sql_updates.find(buffer) != new_sql_updates.end())
{
if(!get_sql_update_info(buffer, info)) return false;
if (!get_sql_update_info(buffer, info)) return false;
snprintf(newname, MAX_PATH, "%d_%0*d_%s%s%s.sql", rev, 2, info.nr, info.db, info.has_table ? "_" : "", info.table);
file_list.insert(newname);
}
@ -628,11 +658,11 @@ bool generate_sql_makefile()
// write the makefile
char file_name[MAX_PATH];
snprintf(file_name, MAX_PATH, "%s%s/Makefile.am", path_prefix, sql_update_dir);
FILE *fout = fopen(file_name, "w");
if(!fout) { pclose(cmd_pipe); return false; }
FILE* fout = fopen(file_name, "w");
if (!fout) { pclose(cmd_pipe); return false; }
fprintf(fout,
"# Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>\n"
"# This file is part of the Continued-MaNGOS Project\n"
"#\n"
"# This program is free software; you can redistribute it and/or modify\n"
"# it under the terms of the GNU General Public License as published by\n"
@ -669,12 +699,12 @@ bool generate_sql_makefile()
}
fprintf(fout,
"\n## Additional files to include when running 'make dist'\n"
"# SQL update files, to upgrade database schema from older revisions\n"
"EXTRA_DIST = \\\n"
);
"\n## Additional files to include when running 'make dist'\n"
"# SQL update files, to upgrade database schema from older revisions\n"
"EXTRA_DIST = \\\n"
);
for(std::set<std::string>::iterator itr = file_list.begin(), next; itr != file_list.end(); ++itr)
for (std::set<std::string>::iterator itr = file_list.begin(), next; itr != file_list.end(); ++itr)
{
next = itr; ++next;
fprintf(fout, "\t%s%s\n", itr->c_str(), next == file_list.end() ? "" : " \\");
@ -690,14 +720,14 @@ bool generate_sql_makefile()
bool change_sql_database()
{
if(new_sql_updates.empty()) return true;
if (new_sql_updates.empty()) return true;
printf("+ changing database sql files\n");
// rename the database files, copy their contents back
// and change the required update line
for(int i = 0; i < NUM_DATABASES; i++)
for (int i = 0; i < NUM_DATABASES; i++)
{
if(last_sql_update[i][0] == '\0') continue;
if (last_sql_update[i][0] == '\0') continue;
char old_file[MAX_PATH], tmp_file[MAX_PATH], dummy[MAX_BUF];
@ -706,28 +736,29 @@ bool change_sql_database()
rename(old_file, tmp_file);
FILE *fin = fopen( tmp_file, "r" );
if(!fin) return false;
FILE *fout = fopen( old_file, "w" );
if(!fout) return false;
FILE* fin = fopen(tmp_file, "r");
if (!fin) return false;
FILE* fout = fopen(old_file, "w");
if (!fout) return false;
snprintf(dummy, MAX_CMD, "CREATE TABLE `%s` (\n", db_version_table[i]);
while(fgets(buffer, MAX_BUF, fin))
while (fgets(buffer, MAX_BUF, fin))
{
fputs(buffer, fout);
if(strncmp(buffer, dummy, MAX_BUF) == 0)
if (strncmp(buffer, dummy, MAX_BUF) == 0)
break;
}
while(1)
while (1)
{
if(!fgets(buffer, MAX_BUF, fin)) return false;
if(sscanf(buffer, " `required_%s`", dummy) == 1) break;
if (!fgets(buffer, MAX_BUF, fin)) return false;
if (sscanf(buffer, " `required_%s`", dummy) == 1) break;
fputs(buffer, fout);
}
fprintf(fout, " `required_%s` bit(1) default NULL\n", last_sql_update[i]);
while(fgets(buffer, MAX_BUF, fin))
while (fgets(buffer, MAX_BUF, fin))
fputs(buffer, fout);
fclose(fin);
@ -743,26 +774,26 @@ bool change_sql_database()
bool change_sql_history()
{
snprintf(cmd, MAX_CMD, "git log HEAD --pretty=\"format:%%H\"");
if( (cmd_pipe = popen( cmd, "r" )) == NULL )
if ((cmd_pipe = popen(cmd, "r")) == NULL)
return false;
std::list<std::string> hashes;
while(fgets(buffer, MAX_BUF, cmd_pipe))
while (fgets(buffer, MAX_BUF, cmd_pipe))
{
buffer[strlen(buffer) - 1] = '\0';
if(strncmp(origin_hash, buffer, MAX_HASH) == 0)
if (strncmp(origin_hash, buffer, MAX_HASH) == 0)
break;
hashes.push_back(buffer);
}
pclose(cmd_pipe);
if(hashes.empty()) return false; // must have at least one commit
if(hashes.size() < 2) return true; // only one commit, ok but nothing to do
if (hashes.empty()) return false; // must have at least one commit
if (hashes.size() < 2) return true; // only one commit, ok but nothing to do
snprintf(cmd, MAX_CMD, "git reset --hard %s", origin_hash);
system(cmd);
for(std::list<std::string>::reverse_iterator next = hashes.rbegin(), itr = next++; next != hashes.rend(); ++itr, ++next)
for (std::list<std::string>::reverse_iterator next = hashes.rbegin(), itr = next++; next != hashes.rend(); ++itr, ++next)
{
// stage the changes from the orignal commit
snprintf(cmd, MAX_CMD, "git cherry-pick -n %s", itr->c_str());
@ -774,10 +805,10 @@ bool change_sql_history()
// remove the newly added files
snprintf(cmd, MAX_CMD, "git diff --cached --diff-filter=A --name-only %s%s", path_prefix, sql_update_dir);
if( (cmd_pipe = popen( cmd, "r" )) == NULL )
if ((cmd_pipe = popen(cmd, "r")) == NULL)
return false;
while(fgets(buffer, MAX_BUF, cmd_pipe))
while (fgets(buffer, MAX_BUF, cmd_pipe))
{
buffer[strlen(buffer) - 1] = '\0';
snprintf(cmd, MAX_CMD, "git rm -f --quiet %s%s", path_prefix, buffer);
@ -800,15 +831,16 @@ bool change_sql_history()
bool prepare_new_index()
{
if(!use_new_index) return true;
if (!use_new_index) return true;
// only use a new index if there are staged changes that should be preserved
if( (cmd_pipe = popen( "git diff --cached", "r" )) == NULL ) {
if ((cmd_pipe = popen("git diff --cached", "r")) == NULL)
{
use_new_index = false;
return false;
}
if(!fgets(buffer, MAX_BUF, cmd_pipe))
if (!fgets(buffer, MAX_BUF, cmd_pipe))
{
use_new_index = false;
pclose(cmd_pipe);
@ -822,29 +854,29 @@ bool prepare_new_index()
// copy the existing index file to a new one
char src_file[MAX_PATH], dst_file[MAX_PATH];
char *old_index = getenv("GIT_INDEX_FILE");
if(old_index) strncpy(src_file, old_index, MAX_PATH);
char* old_index = getenv("GIT_INDEX_FILE");
if (old_index) strncpy(src_file, old_index, MAX_PATH);
else snprintf(src_file, MAX_PATH, "%s.git/index", path_prefix);
snprintf(dst_file, MAX_PATH, "%s%s", path_prefix, new_index_file);
if(!copy_file(src_file, dst_file)) return false;
if (!copy_file(src_file, dst_file)) return false;
// doesn't seem to work with path_prefix
snprintf(new_index_cmd, MAX_CMD, "GIT_INDEX_FILE=%s/%s", base_path, new_index_file);
if(putenv(new_index_cmd) != 0) return false;
if (putenv(new_index_cmd) != 0) return false;
// clear the new index
system("git reset -q --mixed HEAD");
// revert to old index
snprintf(old_index_cmd, MAX_CMD, "GIT_INDEX_FILE=");
if(putenv(old_index_cmd) != 0) return false;
if (putenv(old_index_cmd) != 0) return false;
return true;
}
bool cleanup_new_index()
{
if(!use_new_index) return true;
if (!use_new_index) return true;
printf("+ cleaning up the new index\n");
char idx_file[MAX_PATH];
snprintf(idx_file, MAX_PATH, "%s%s", path_prefix, new_index_file);
@ -854,22 +886,22 @@ bool cleanup_new_index()
#define DO(cmd) if(!cmd) { printf("FAILED\n"); return 1; }
int main(int argc, char *argv[])
int main(int argc, char* argv[])
{
for(int i = 1; i < argc; i++)
for (int i = 1; i < argc; i++)
{
if(argv[i] == NULL) continue;
if(strncmp(argv[i], "-r", 2) == 0 || strncmp(argv[i], "--replace", 9) == 0)
if (argv[i] == NULL) continue;
if (strncmp(argv[i], "-r", 2) == 0 || strncmp(argv[i], "--replace", 9) == 0)
allow_replace = true;
else if(strncmp(argv[i], "-l", 2) == 0 || strncmp(argv[i], "--local", 7) == 0)
else if (strncmp(argv[i], "-l", 2) == 0 || strncmp(argv[i], "--local", 7) == 0)
local = true;
else if(strncmp(argv[i], "-f", 2) == 0 || strncmp(argv[i], "--fetch", 7) == 0)
else if (strncmp(argv[i], "-f", 2) == 0 || strncmp(argv[i], "--fetch", 7) == 0)
do_fetch = true;
else if(strncmp(argv[i], "-s", 2) == 0 || strncmp(argv[i], "--sql", 5) == 0)
else if (strncmp(argv[i], "-s", 2) == 0 || strncmp(argv[i], "--sql", 5) == 0)
do_sql = true;
else if(strncmp(argv[i], "--branch=", 9) == 0)
else if (strncmp(argv[i], "--branch=", 9) == 0)
snprintf(remote_branch, MAX_REMOTE, "%s", argv[i] + 9);
else if(strncmp(argv[i], "-h", 2) == 0 || strncmp(argv[i], "--help", 6) == 0)
else if (strncmp(argv[i], "-h", 2) == 0 || strncmp(argv[i], "--help", 6) == 0)
{
printf("Usage: git_id [OPTION]\n");
printf("Generates a new rev number and updates revision_nr.h and the commit message.\n");
@ -893,30 +925,30 @@ int main(int argc, char *argv[])
return 1;
}
DO( find_path() );
if(!local)
DO(find_path());
if (!local)
{
DO( find_origin() );
if(do_fetch)
DO( fetch_origin() );
DO( check_fwd() );
DO(find_origin());
if (do_fetch)
DO(fetch_origin());
DO(check_fwd());
}
DO( find_rev() );
DO( find_head_msg() );
if(do_sql)
DO( find_sql_updates() );
DO( prepare_new_index() );
DO( write_rev_nr() );
if(do_sql)
DO(find_rev());
DO(find_head_msg());
if (do_sql)
DO(find_sql_updates());
DO(prepare_new_index());
DO(write_rev_nr());
if (do_sql)
{
DO( convert_sql_updates() );
DO(convert_sql_updates());
if (generate_makefile)
DO( generate_sql_makefile() );
DO( change_sql_database() );
DO( write_rev_sql() );
DO(generate_sql_makefile());
DO(change_sql_database());
DO(write_rev_sql());
}
DO( amend_commit() );
DO( cleanup_new_index() );
DO(amend_commit());
DO(cleanup_new_index());
//if(do_sql)
// DO( change_sql_history() );

View file

@ -1,4 +1,4 @@
# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without

View file

@ -1,7 +1,7 @@
#!/usr/bin/python
"""
Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
This file is part of the Continued-MaNGOS Project
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,6 +1,6 @@
<?php
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,4 +1,4 @@
# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,4 +1,4 @@
# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without

View file

@ -1,4 +1,4 @@
# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
@ -12,5 +12,5 @@ cmake_minimum_required (VERSION 2.6)
project (MANGOS_IOMAP_EXTRACTOR)
LINK_DIRECTORIES( ${LINK_DIRECTORIES} ../../../dep/libmpq/libmpq/.libs/ )
add_executable(vmapextractor adtfile.cpp dbcfile.cpp model.cpp mpq_libmpq.cpp vmapexport.cpp wdtfile.cpp wmo.cpp)
add_executable(vmapextractor adtfile.cpp dbcfile.cpp gameobject_extract.cpp model.cpp mpq_libmpq.cpp vmapexport.cpp wdtfile.cpp wmo.cpp)
target_link_libraries(vmapextractor libmpq.a bz2 z)

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -28,54 +28,55 @@
#define snprintf _snprintf
#endif
const char * GetPlainName(const char * FileName)
const char* GetPlainName(const char* FileName)
{
const char * szTemp;
const char* szTemp;
if((szTemp = strrchr(FileName, '\\')) != NULL)
if ((szTemp = strrchr(FileName, '\\')) != NULL)
FileName = szTemp + 1;
return FileName;
}
char * GetPlainName(char * FileName)
char* GetPlainName(char* FileName)
{
char * szTemp;
char* szTemp;
if((szTemp = strrchr(FileName, '\\')) != NULL)
if ((szTemp = strrchr(FileName, '\\')) != NULL)
FileName = szTemp + 1;
return FileName;
}
void fixnamen(char *name, size_t len)
void fixnamen(char* name, size_t len)
{
for (size_t i=0; i<len-3; i++)
for (size_t i = 0; i < len - 3; i++)
{
if (i>0 && name[i]>='A' && name[i]<='Z' && isalpha(name[i-1]))
if (i > 0 && name[i] >= 'A' && name[i] <= 'Z' && isalpha(name[i - 1]))
{
name[i] |= 0x20;
} else if ((i==0 || !isalpha(name[i-1])) && name[i]>='a' && name[i]<='z')
}
else if ((i == 0 || !isalpha(name[i - 1])) && name[i] >= 'a' && name[i] <= 'z')
{
name[i] &= ~0x20;
}
}
//extension in lowercase
for(size_t i=len-3; i<len; i++)
for (size_t i = len - 3; i < len; i++)
name[i] |= 0x20;
}
void fixname2(char *name, size_t len)
void fixname2(char* name, size_t len)
{
for (size_t i=0; i<len-3; i++)
for (size_t i = 0; i < len - 3; i++)
{
if(name[i] == ' ')
name[i] = '_';
if (name[i] == ' ')
name[i] = '_';
}
}
char * GetExtension(char * FileName)
char* GetExtension(char* FileName)
{
char * szTemp;
if((szTemp = strrchr(FileName, '.')) != NULL)
char* szTemp;
if ((szTemp = strrchr(FileName, '.')) != NULL)
return szTemp;
return NULL;
}
@ -87,9 +88,9 @@ ADTFile::ADTFile(char* filename): ADT(WorldMpq, filename)
Adtfilename.append(filename);
}
bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY)
bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY, StringSet& failedPaths)
{
if(ADT.isEof ())
if (ADT.isEof())
return false;
uint32 size;
@ -97,12 +98,12 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY)
string xMap;
string yMap;
Adtfilename.erase(Adtfilename.find(".adt"),4);
Adtfilename.erase(Adtfilename.find(".adt"), 4);
string TempMapNumber;
TempMapNumber = Adtfilename.substr(Adtfilename.length()-6,6);
xMap = TempMapNumber.substr(TempMapNumber.find("_")+1,(TempMapNumber.find_last_of("_")-1) - (TempMapNumber.find("_")));
yMap = TempMapNumber.substr(TempMapNumber.find_last_of("_")+1,(TempMapNumber.length()) - (TempMapNumber.find_last_of("_")));
Adtfilename.erase((Adtfilename.length()-xMap.length()-yMap.length()-2), (xMap.length()+yMap.length()+2));
TempMapNumber = Adtfilename.substr(Adtfilename.length() - 6, 6);
xMap = TempMapNumber.substr(TempMapNumber.find("_") + 1, (TempMapNumber.find_last_of("_") - 1) - (TempMapNumber.find("_")));
yMap = TempMapNumber.substr(TempMapNumber.find_last_of("_") + 1, (TempMapNumber.length()) - (TempMapNumber.find_last_of("_")));
Adtfilename.erase((Adtfilename.length() - xMap.length() - yMap.length() - 2), (xMap.length() + yMap.length() + 2));
string AdtMapNumber = xMap + ' ' + yMap + ' ' + GetPlainName((char*)Adtfilename.c_str());
//printf("Processing map %s...\n", AdtMapNumber.c_str());
//printf("MapNumber = %s\n", TempMapNumber.c_str());
@ -110,9 +111,9 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY)
//printf("yMap = %s\n", yMap.c_str());
std::string dirname = std::string(szWorkDirWmo) + "/dir_bin";
FILE *dirfile;
FILE* dirfile;
dirfile = fopen(dirname.c_str(), "ab");
if(!dirfile)
if (!dirfile)
{
printf("Can't open dirfile!'%s'\n", dirname.c_str());
return false;
@ -121,89 +122,90 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY)
while (!ADT.isEof())
{
char fourcc[5];
ADT.read(&fourcc,4);
ADT.read(&fourcc, 4);
ADT.read(&size, 4);
flipcc(fourcc);
fourcc[4] = 0;
size_t nextpos = ADT.getPos() + size;
if (!strcmp(fourcc,"MCIN"))
if (!strcmp(fourcc, "MCIN"))
{
}
else if (!strcmp(fourcc,"MTEX"))
else if (!strcmp(fourcc, "MTEX"))
{
}
else if (!strcmp(fourcc,"MMDX"))
else if (!strcmp(fourcc, "MMDX"))
{
if (size)
{
char *buf = new char[size];
char* buf = new char[size];
ADT.read(buf, size);
char *p=buf;
int t=0;
char* p = buf;
int t = 0;
ModelInstansName = new string[size];
while (p<buf+size)
while (p < buf + size)
{
fixnamen(p,strlen(p));
fixnamen(p, strlen(p));
char* s = GetPlainName(p);
fixname2(s,strlen(s));
fixname2(s, strlen(s));
ModelInstansName[t++] = s;
string path(p);
ExtractSingleModel(path, failedPaths);
p = p+strlen(p)+1;
p = p + strlen(p) + 1;
}
delete[] buf;
}
}
else if (!strcmp(fourcc,"MWMO"))
else if (!strcmp(fourcc, "MWMO"))
{
if (size)
{
char *buf = new char[size];
char* buf = new char[size];
ADT.read(buf, size);
char *p=buf;
char* p = buf;
int q = 0;
WmoInstansName = new string[size];
while (p<buf+size)
while (p < buf + size)
{
string path(p);
char* s=GetPlainName(p);
fixnamen(s,strlen(s));
fixname2(s,strlen(s));
p=p+strlen(p)+1;
char* s = GetPlainName(p);
fixnamen(s, strlen(s));
fixname2(s, strlen(s));
p = p + strlen(p) + 1;
WmoInstansName[q++] = s;
}
delete[] buf;
}
}
//======================
else if (!strcmp(fourcc,"MDDF"))
else if (!strcmp(fourcc, "MDDF"))
{
if (size)
{
nMDX = (int)size / 36;
for (int i=0; i<nMDX; ++i)
for (int i = 0; i < nMDX; ++i)
{
uint32 id;
ADT.read(&id, 4);
ModelInstance inst(ADT,ModelInstansName[id].c_str(), map_num, tileX, tileY, dirfile);
ModelInstance inst(ADT, ModelInstansName[id].c_str(), map_num, tileX, tileY, dirfile);
}
delete[] ModelInstansName;
}
}
else if (!strcmp(fourcc,"MODF"))
else if (!strcmp(fourcc, "MODF"))
{
if (size)
{
nWMO = (int)size / 64;
for (int i=0; i<nWMO; ++i)
for (int i = 0; i < nWMO; ++i)
{
uint32 id;
ADT.read(&id, 4);
WMOInstance inst(ADT,WmoInstansName[id].c_str(), map_num, tileX, tileY, dirfile);
WMOInstance inst(ADT, WmoInstansName[id].c_str(), map_num, tileX, tileY, dirfile);
}
delete[] WmoInstansName;
}
@ -213,6 +215,7 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY)
}
ADT.close();
fclose(dirfile);
return true;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -21,6 +21,7 @@
#include "mpqfile.h"
#include "wmo.h"
#include "vmapexport.h"
#include "model.h"
#define TILESIZE (533.33333f)
@ -34,7 +35,7 @@ typedef struct
float x;
float y;
float z;
}svec;
} svec;
struct vec
{
@ -50,9 +51,9 @@ struct triangle
typedef struct
{
float v9[16*8+1][16*8+1];
float v8[16*8][16*8];
}Cell;
float v9[16 * 8 + 1][16 * 8 + 1];
float v8[16 * 8][16 * 8];
} Cell;
typedef struct
{
@ -62,12 +63,12 @@ typedef struct
//Liquid *lq;
float waterlevel[9][9];
uint8 flag;
}chunk;
} chunk;
typedef struct
{
chunk ch[16][16];
}mcell;
} mcell;
struct MapChunkHeader
{
@ -109,35 +110,35 @@ struct MapChunkHeader
class ADTFile
{
public:
ADTFile(char* filename);
~ADTFile();
int nWMO;
int nMDX;
string* WmoInstansName;
string* ModelInstansName;
bool init(uint32 map_num, uint32 tileX, uint32 tileY);
//void LoadMapChunks();
public:
ADTFile(char* filename);
~ADTFile();
int nWMO;
int nMDX;
string* WmoInstansName;
string* ModelInstansName;
bool init(uint32 map_num, uint32 tileX, uint32 tileY, StringSet& failedPaths);
//void LoadMapChunks();
//uint32 wmo_count;
/*
const mcell& Getmcell() const
{
return Mcell;
}
*/
private:
//size_t mcnk_offsets[256], mcnk_sizes[256];
MPQFile ADT;
//mcell Mcell;
string Adtfilename;
//uint32 wmo_count;
/*
const mcell& Getmcell() const
{
return Mcell;
}
*/
private:
//size_t mcnk_offsets[256], mcnk_sizes[256];
MPQFile ADT;
//mcell Mcell;
string Adtfilename;
};
const char * GetPlainName(const char * FileName);
char * GetPlainName(char * FileName);
char * GetExtension(char * FileName);
void fixnamen(char *name, size_t len);
void fixname2(char *name, size_t len);
const char* GetPlainName(const char* FileName);
char* GetPlainName(char* FileName);
char* GetExtension(char* FileName);
void fixnamen(char* name, size_t len);
void fixname2(char* name, size_t len);
//void fixMapNamen(char *name, size_t len);
#endif

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -69,7 +69,7 @@ bool DBCFile::open()
return false;
_data = new unsigned char[_recordSize * _recordCount + _stringSize];
_stringTable = _data + _recordSize*_recordCount;
_stringTable = _data + _recordSize * _recordCount;
size_t data_size = _recordSize * _recordCount + _stringSize;
readBytes = 0;
@ -90,7 +90,7 @@ DBCFile::~DBCFile()
DBCFile::Record DBCFile::getRecord(size_t id)
{
assert(_data);
return Record(*this, _data + id*_recordSize);
return Record(*this, _data + id * _recordSize);
}
size_t DBCFile::getMaxId()
@ -98,7 +98,7 @@ size_t DBCFile::getMaxId()
assert(_data);
size_t maxId = 0;
for(size_t i = 0; i < getRecordCount(); ++i)
for (size_t i = 0; i < getRecordCount(); ++i)
if (maxId < getRecord(i).getUInt(0))
maxId = getRecord(i).getUInt(0);

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -35,17 +35,17 @@ class DBCFile
class Exception
{
public:
Exception(const std::string &message) : message(message) { }
Exception(const std::string& message) : message(message) { }
virtual ~Exception() { }
const std::string &getMessage() { return message; }
const std::string& getMessage() { return message; }
private:
std::string message;
};
class NotFound: public Exception
{
public:
NotFound(): Exception("Key was not found") { }
public:
NotFound(): Exception("Key was not found") { }
};
// Iteration over database
@ -56,22 +56,22 @@ class DBCFile
float getFloat(size_t field) const
{
assert(field < file._fieldCount);
return *reinterpret_cast<float*>(offset+field*4);
return *reinterpret_cast<float*>(offset + field * 4);
}
unsigned int getUInt(size_t field) const
{
assert(field < file._fieldCount);
return *reinterpret_cast<unsigned int*>(offset+field*4);
return *reinterpret_cast<unsigned int*>(offset + field * 4);
}
int getInt(size_t field) const
{
assert(field < file._fieldCount);
return *reinterpret_cast<int*>(offset+field*4);
return *reinterpret_cast<int*>(offset + field * 4);
}
const char *getString(size_t field) const
const char* getString(size_t field) const
{
assert(field < file._fieldCount);
size_t stringOffset = getUInt(field);
@ -80,9 +80,9 @@ class DBCFile
}
private:
Record(DBCFile &file, unsigned char *offset): file(file), offset(offset) {}
unsigned char *offset;
DBCFile &file;
Record(DBCFile& file, unsigned char* offset): file(file), offset(offset) {}
unsigned char* offset;
DBCFile& file;
friend class DBCFile;
friend class DBCFile::Iterator;
@ -92,26 +92,26 @@ class DBCFile
class Iterator
{
public:
Iterator(DBCFile &file, unsigned char *offset) : record(file, offset) { }
Iterator(DBCFile& file, unsigned char* offset) : record(file, offset) { }
/// Advance (prefix only)
Iterator & operator++()
Iterator& operator++()
{
record.offset += record.file._recordSize;
return *this;
}
/// Return address of current instance
Record const & operator*() const { return record; }
Record const& operator*() const { return record; }
const Record* operator->() const { return &record; }
/// Comparison
bool operator==(const Iterator &b) const
bool operator==(const Iterator& b) const
{
return record.offset == b.record.offset;
}
bool operator!=(const Iterator &b) const
bool operator!=(const Iterator& b) const
{
return record.offset != b.record.offset;
}
@ -138,7 +138,7 @@ class DBCFile
size_t _recordCount;
size_t _fieldCount;
size_t _stringSize;
unsigned char *_data;
unsigned char* _data;
unsigned char* _stringTable;
};

View file

@ -0,0 +1,111 @@
#include "model.h"
#include "dbcfile.h"
#include "adtfile.h"
#include "vmapexport.h"
#include <algorithm>
#include <stdio.h>
bool ExtractSingleModel(std::string& fname, StringSet& failedPaths)
{
char* name = GetPlainName((char*)fname.c_str());
char* ext = GetExtension(name);
// < 3.1.0 ADT MMDX section store filename.mdx filenames for corresponded .m2 file
if (!strcmp(ext, ".mdx"))
{
// replace .mdx -> .m2
fname.erase(fname.length() - 2, 2);
fname.append("2");
}
// >= 3.1.0 ADT MMDX section store filename.m2 filenames for corresponded .m2 file
// nothing do
std::string output(szWorkDirWmo);
output += "/";
output += name;
if (FileExists(output.c_str()))
return true;
Model mdl(fname);
if (!mdl.open(failedPaths))
return false;
return mdl.ConvertToVMAPModel(output.c_str());
}
extern HANDLE LocaleMpq;
void ExtractGameobjectModels()
{
printf("\n");
printf("Extracting GameObject models...\n");
DBCFile dbc(LocaleMpq, "DBFilesClient\\GameObjectDisplayInfo.dbc");
if (!dbc.open())
{
printf("Fatal error: Invalid GameObjectDisplayInfo.dbc file format!\n");
exit(1);
}
std::string basepath = szWorkDirWmo;
basepath += "/";
std::string path;
StringSet failedPaths;
FILE* model_list = fopen((basepath + "temp_gameobject_models").c_str(), "wb");
for (DBCFile::Iterator it = dbc.begin(); it != dbc.end(); ++it)
{
path = it->getString(1);
if (path.length() < 4)
continue;
fixnamen((char*)path.c_str(), path.size());
char* name = GetPlainName((char*)path.c_str());
fixname2(name, strlen(name));
char* ch_ext = GetExtension(name);
if (!ch_ext)
continue;
strToLower(ch_ext);
bool result = false;
if (!strcmp(ch_ext, ".wmo"))
{
result = ExtractSingleWmo(path);
}
else if (!strcmp(ch_ext, ".mdl"))
{
// TODO: extract .mdl files, if needed
continue;
}
else //if (!strcmp(ch_ext, ".mdx") || !strcmp(ch_ext, ".m2"))
{
result = ExtractSingleModel(path, failedPaths);
}
if (result)
{
uint32 displayId = it->getUInt(0);
uint32 path_length = strlen(name);
fwrite(&displayId, sizeof(uint32), 1, model_list);
fwrite(&path_length, sizeof(uint32), 1, model_list);
fwrite(name, sizeof(char), path_length, model_list);
}
}
fclose(model_list);
if (!failedPaths.empty())
{
printf("Warning: Some models could not be extracted, see below\n");
for (StringSet::const_iterator itr = failedPaths.begin(); itr != failedPaths.end(); ++itr)
printf("Could not find file of model %s\n", itr->c_str());
printf("A few of these warnings are expected to happen, so be not alarmed!\n");
}
printf("Done!\n");
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -52,7 +52,8 @@ typedef uint8_t uint8;
//
struct file_MVER
{
union{
union
{
uint32 fcc;
char fcc_txt[4];
};
@ -60,18 +61,19 @@ struct file_MVER
uint32 ver;
};
class FileLoader{
uint8 *data;
uint32 data_size;
public:
virtual bool prepareLoadedData();
uint8 *GetData() {return data;}
uint32 GetDataSize() {return data_size;}
class FileLoader
{
uint8* data;
uint32 data_size;
public:
virtual bool prepareLoadedData();
uint8* GetData() {return data;}
uint32 GetDataSize() {return data_size;}
file_MVER *version;
FileLoader();
~FileLoader();
bool loadFile(char *filename, bool log = true);
virtual void free();
file_MVER* version;
FileLoader();
~FileLoader();
bool loadFile(char* filename, bool log = true);
virtual void free();
};
#endif

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -28,11 +28,11 @@
extern HANDLE WorldMpq;
Model::Model(std::string &filename) : filename(filename), vertices(0), indices(0)
Model::Model(std::string& filename) : filename(filename), vertices(0), indices(0)
{
}
bool Model::open()
bool Model::open(StringSet& failedPaths)
{
MPQFile f(WorldMpq, filename.c_str());
@ -41,28 +41,27 @@ bool Model::open()
if (!ok)
{
f.close();
// Do not show this error on console to avoid confusion, the extractor can continue working even if some models fail to load
//printf("Error loading model %s\n", filename.c_str());
failedPaths.insert(filename);
return false;
}
_unload();
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);
for (uint32 i=0; i<header.nBoundingVertices; i++)
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.read(indices, header.nBoundingTriangles * 2);
f.close();
}
else
@ -74,52 +73,52 @@ bool Model::open()
return true;
}
bool Model::ConvertToVMAPModel(const char * outfilename)
bool Model::ConvertToVMAPModel(const char* outfilename)
{
int N[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
FILE * output=fopen(outfilename,"wb");
if(!output)
int N[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
FILE* output = fopen(outfilename, "wb");
if (!output)
{
printf("Can't create the output file '%s'\n",outfilename);
printf("Can't create the output file '%s'\n", outfilename);
return false;
}
fwrite(szRawVMAPMagic,8,1,output);
fwrite(szRawVMAPMagic, 8, 1, output);
uint32 nVertices = 0;
nVertices = header.nBoundingVertices;
fwrite(&nVertices, sizeof(int), 1, output);
uint32 nofgroups = 1;
fwrite(&nofgroups,sizeof(uint32), 1, output);
fwrite(N,4*3,1,output);// rootwmoid, flags, groupid
fwrite(N,sizeof(float),3*2,output);//bbox, only needed for WMO currently
fwrite(N,4,1,output);// liquidflags
fwrite("GRP ",4,1,output);
fwrite(&nofgroups, sizeof(uint32), 1, output);
fwrite(N, 4 * 3, 1, output); // rootwmoid, flags, groupid
fwrite(N, sizeof(float), 3 * 2, output); //bbox, only needed for WMO currently
fwrite(N, 4, 1, output); // liquidflags
fwrite("GRP ", 4, 1, output);
uint32 branches = 1;
int wsize;
wsize = sizeof(branches) + sizeof(uint32) * branches;
fwrite(&wsize, sizeof(int), 1, output);
fwrite(&branches,sizeof(branches), 1, output);
fwrite(&branches, sizeof(branches), 1, output);
uint32 nIndexes = 0;
nIndexes = header.nBoundingTriangles;
fwrite(&nIndexes,sizeof(uint32), 1, output);
fwrite("INDX",4, 1, output);
fwrite(&nIndexes, sizeof(uint32), 1, output);
fwrite("INDX", 4, 1, output);
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);
}
fwrite("VERT",4, 1, output);
fwrite("VERT", 4, 1, output);
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)
for (uint32 vpos = 0; vpos < nVertices; ++vpos)
{
std::swap(vertices[vpos].y, vertices[vpos].z);
}
fwrite(vertices, sizeof(float)*3, nVertices, output);
fwrite(vertices, sizeof(float) * 3, nVertices, output);
}
fclose(output);
@ -138,24 +137,24 @@ Vec3D fixCoordSystem2(Vec3D v)
return Vec3D(v.x, v.z, v.y);
}
ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE *pDirfile)
ModelInstance::ModelInstance(MPQFile& f, const char* ModelInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE* pDirfile)
{
float ff[3];
f.read(&id, 4);
f.read(ff,12);
pos = fixCoords(Vec3D(ff[0],ff[1],ff[2]));
f.read(ff,12);
rot = Vec3D(ff[0],ff[1],ff[2]);
f.read(&scale,4);
f.read(ff, 12);
pos = fixCoords(Vec3D(ff[0], ff[1], ff[2]));
f.read(ff, 12);
rot = Vec3D(ff[0], ff[1], ff[2]);
f.read(&scale, 4);
// scale factor - divide by 1024. blizzard devs must be on crack, why not just use a float?
sc = scale / 1024.0f;
char tempname[512];
sprintf(tempname, "%s/%s", szWorkDirWmo, ModelInstName);
FILE *input;
FILE* input;
input = fopen(tempname, "r+b");
if(!input)
if (!input)
{
//printf("ModelInstance::ModelInstance couldn't open %s\n", tempname);
return;
@ -163,15 +162,15 @@ ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName, uint32 mapID,
fseek(input, 8, SEEK_SET); // get the correct no of vertices
int nVertices;
fread(&nVertices, sizeof (int), 1, input);
fread(&nVertices, sizeof(int), 1, input);
fclose(input);
if(nVertices == 0)
if (nVertices == 0)
return;
uint16 adtId = 0;// not used for models
uint32 flags = MOD_M2;
if(tileX == 65 && tileY == 65) flags |= MOD_WORLDSPAWN;
if (tileX == 65 && tileY == 65) flags |= MOD_WORLDSPAWN;
//write mapID, tileX, tileY, Flags, ID, Pos, Rot, Scale, name
fwrite(&mapID, sizeof(uint32), 1, pDirfile);
fwrite(&tileX, sizeof(uint32), 1, pDirfile);
@ -182,7 +181,7 @@ ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName, uint32 mapID,
fwrite(&pos, sizeof(float), 3, pDirfile);
fwrite(&rot, sizeof(float), 3, pDirfile);
fwrite(&sc, sizeof(float), 1, pDirfile);
uint32 nlen=strlen(ModelInstName);
uint32 nlen = strlen(ModelInstName);
fwrite(&nlen, sizeof(uint32), 1, pDirfile);
fwrite(ModelInstName, sizeof(char), nlen, pDirfile);

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -23,8 +23,8 @@
//#include "mpq.h"
#include "modelheaders.h"
#include <vector>
#include "vmapexport.h"
class Model;
class WMOInstance;
class MPQFile;
@ -32,46 +32,45 @@ Vec3D fixCoordSystem(Vec3D v);
class Model
{
public:
ModelHeader header;
uint32 offsBB_vertices, offsBB_indices;
Vec3D *BB_vertices, *vertices;
uint16 *BB_indices, *indices;
size_t nIndices;
public:
ModelHeader header;
uint32 offsBB_vertices, offsBB_indices;
Vec3D* BB_vertices, *vertices;
uint16* BB_indices, *indices;
size_t nIndices;
bool open();
bool ConvertToVMAPModel(const char * outfilename);
bool open(StringSet& failedPaths);
bool ConvertToVMAPModel(const char* outfilename);
bool ok;
bool ok;
Model(std::string &filename);
~Model() {_unload();}
Model(std::string& filename);
~Model() {_unload();}
private:
void _unload()
{
delete[] vertices;
delete[] indices;
vertices = NULL;
indices = NULL;
}
std::string filename;
char outfilename;
private:
void _unload()
{
delete[] vertices;
delete[] indices;
vertices = NULL;
indices = NULL;
}
std::string filename;
char outfilename;
};
class ModelInstance
{
public:
Model *model;
public:
Model* model;
uint32 id;
Vec3D pos, rot;
unsigned int d1, scale;
float w,sc;
ModelInstance() {}
ModelInstance(MPQFile &f,const char* ModelInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE *pDirfile);
uint32 id;
Vec3D pos, rot;
unsigned int d1, scale;
float w, sc;
ModelInstance() {}
ModelInstance(MPQFile& f, const char* ModelInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE* pDirfile);
};
#endif

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -54,7 +54,8 @@ size_t MPQFile::read(void* dest, size_t bytes)
if (eof) return 0;
size_t rpos = pointer + bytes;
if (rpos > size) {
if (rpos > size)
{
bytes = size - pointer;
eof = true;
}

View file

@ -44,38 +44,38 @@ using namespace std;
class MPQFile
{
//MPQHANDLE handle;
bool eof;
char *buffer;
size_t pointer,size;
//MPQHANDLE handle;
bool eof;
char* buffer;
size_t pointer, size;
// disable copying
MPQFile(const MPQFile &f);
void operator=(const MPQFile &f);
// disable copying
MPQFile(const MPQFile& f);
void operator=(const MPQFile& f);
public:
MPQFile(HANDLE mpq, const char* filename); // filenames are not case sensitive
~MPQFile() { close(); }
size_t read(void* dest, size_t bytes);
size_t getSize() { return size; }
size_t getPos() { return pointer; }
char* getBuffer() { return buffer; }
char* getPointer() { return buffer + pointer; }
bool isEof() { return eof; }
void seek(int offset);
void seekRelative(int offset);
void close();
public:
MPQFile(HANDLE mpq, const char* filename); // filenames are not case sensitive
~MPQFile() { close(); }
size_t read(void* dest, size_t bytes);
size_t getSize() { return size; }
size_t getPos() { return pointer; }
char* getBuffer() { return buffer; }
char* getPointer() { return buffer + pointer; }
bool isEof() { return eof; }
void seek(int offset);
void seekRelative(int offset);
void close();
};
inline void flipcc(char *fcc)
inline void flipcc(char* fcc)
{
char t;
t=fcc[0];
fcc[0]=fcc[3];
fcc[3]=t;
t=fcc[1];
fcc[1]=fcc[2];
fcc[2]=t;
t = fcc[0];
fcc[0] = fcc[3];
fcc[3] = t;
t = fcc[1];
fcc[1] = fcc[2];
fcc[2] = t;
}
#endif

View file

@ -0,0 +1,232 @@
#ifndef VEC3D_H
#define VEC3D_H
#include <iostream>
#include <cmath>
class Vec3D
{
public:
float x, y, z;
Vec3D(float x0 = 0.0f, float y0 = 0.0f, float z0 = 0.0f) : x(x0), y(y0), z(z0) {}
Vec3D(const Vec3D& v) : x(v.x), y(v.y), z(v.z) {}
Vec3D& operator= (const Vec3D& v)
{
x = v.x;
y = v.y;
z = v.z;
return *this;
}
Vec3D operator+ (const Vec3D& v) const
{
Vec3D r(x + v.x, y + v.y, z + v.z);
return r;
}
Vec3D operator- (const Vec3D& v) const
{
Vec3D r(x - v.x, y - v.y, z - v.z);
return r;
}
float operator* (const Vec3D& v) const
{
return x * v.x + y * v.y + z * v.z;
}
Vec3D operator* (float d) const
{
Vec3D r(x * d, y * d, z * d);
return r;
}
friend Vec3D operator* (float d, const Vec3D& v)
{
return v * d;
}
Vec3D operator% (const Vec3D& v) const
{
Vec3D r(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x);
return r;
}
Vec3D& operator+= (const Vec3D& v)
{
x += v.x;
y += v.y;
z += v.z;
return *this;
}
Vec3D& operator-= (const Vec3D& v)
{
x -= v.x;
y -= v.y;
z -= v.z;
return *this;
}
Vec3D& operator*= (float d)
{
x *= d;
y *= d;
z *= d;
return *this;
}
float lengthSquared() const
{
return x * x + y * y + z * z;
}
float length() const
{
return sqrt(x * x + y * y + z * z);
}
Vec3D& normalize()
{
this->operator*= (1.0f / length());
return *this;
}
Vec3D operator~() const
{
Vec3D r(*this);
r.normalize();
return r;
}
friend std::istream& operator>>(std::istream& in, Vec3D& v)
{
in >> v.x >> v.y >> v.z;
return in;
}
friend std::ostream& operator<<(std::ostream& out, const Vec3D& v)
{
out << v.x << " " << v.y << " " << v.z;
return out;
}
operator float* ()
{
return (float*)this;
}
};
class Vec2D
{
public:
float x, y;
Vec2D(float x0 = 0.0f, float y0 = 0.0f) : x(x0), y(y0) {}
Vec2D(const Vec2D& v) : x(v.x), y(v.y) {}
Vec2D& operator= (const Vec2D& v)
{
x = v.x;
y = v.y;
return *this;
}
Vec2D operator+ (const Vec2D& v) const
{
Vec2D r(x + v.x, y + v.y);
return r;
}
Vec2D operator- (const Vec2D& v) const
{
Vec2D r(x - v.x, y - v.y);
return r;
}
float operator* (const Vec2D& v) const
{
return x * v.x + y * v.y;
}
Vec2D operator* (float d) const
{
Vec2D r(x * d, y * d);
return r;
}
friend Vec2D operator* (float d, const Vec2D& v)
{
return v * d;
}
Vec2D& operator+= (const Vec2D& v)
{
x += v.x;
y += v.y;
return *this;
}
Vec2D& operator-= (const Vec2D& v)
{
x -= v.x;
y -= v.y;
return *this;
}
Vec2D& operator*= (float d)
{
x *= d;
y *= d;
return *this;
}
float lengthSquared() const
{
return x * x + y * y;
}
float length() const
{
return sqrt(x * x + y * y);
}
Vec2D& normalize()
{
this->operator*= (1.0f / length());
return *this;
}
Vec2D operator~() const
{
Vec2D r(*this);
r.normalize();
return r;
}
friend std::istream& operator>>(std::istream& in, Vec2D& v)
{
in >> v.x >> v.y;
return in;
}
operator float* ()
{
return (float*)this;
}
};
inline void rotate(float x0, float y0, float* x, float* y, float angle)
{
float xa = *x - x0, ya = *y - y0;
*x = xa * cosf(angle) - ya * sinf(angle) + x0;
*y = xa * sinf(angle) + ya * cosf(angle) + y0;
}
#endif

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -23,13 +23,13 @@
#include <list>
#include <errno.h>
#ifdef WIN32
#include <Windows.h>
#include <sys/stat.h>
#include <direct.h>
#define mkdir _mkdir
#if defined WIN32
#include <Windows.h>
#include <sys/stat.h>
#include <direct.h>
#define mkdir _mkdir
#else
#include <sys/stat.h>
#include <sys/stat.h>
#endif
#undef min
@ -49,6 +49,8 @@
#include "vmapexport.h"
#include "vmapexport.h"
//------------------------------------------------------------------------------
// Defines
@ -62,7 +64,7 @@ HANDLE LocaleMpq = NULL;
uint32 CONF_TargetBuild = 15595; // 4.3.4.15595
// List MPQ for extract maps from
char const* CONF_mpq_list[]=
char const* CONF_mpq_list[] =
{
"world.MPQ",
"art.MPQ",
@ -92,20 +94,20 @@ typedef struct
{
char name[64];
unsigned int id;
}map_id;
} map_id;
map_id * map_ids;
uint16 *LiqType = 0;
map_id* map_ids;
uint16* LiqType = 0;
uint32 map_count;
char output_path[128]=".";
char input_path[1024]=".";
char output_path[128] = ".";
char input_path[1024] = ".";
bool preciseVectorData = false;
// Constants
//static const char * szWorkDirMaps = ".\\Maps";
const char* szWorkDirWmo = "./Buildings";
const char* szRawVMAPMagic = "VMAP004";
const char* szRawVMAPMagic = "VMAPc04";
bool LoadLocaleMPQFile(int locale)
{
@ -263,9 +265,9 @@ bool FileExists(const char* file)
void strToLower(char* str)
{
while(*str)
while (*str)
{
*str=tolower(*str);
*str = tolower(*str);
++str;
}
}
@ -276,7 +278,7 @@ void ReadLiquidTypeTableDBC()
printf("Read LiquidType.dbc file...");
DBCFile dbc(LocaleMpq, "DBFilesClient\\LiquidType.dbc");
if(!dbc.open())
if (!dbc.open())
{
printf("Fatal error: Invalid LiquidType.dbc file format!\n");
exit(1);
@ -287,7 +289,7 @@ void ReadLiquidTypeTableDBC()
LiqType = new uint16[LiqType_maxid + 1];
memset(LiqType, 0xff, (LiqType_maxid + 1) * sizeof(uint16));
for(uint32 x = 0; x < LiqType_count; ++x)
for (uint32 x = 0; x < LiqType_count; ++x)
LiqType[dbc.getRecord(x).getUInt(0)] = dbc.getRecord(x).getUInt(3);
printf("Done! (%u LiqTypes loaded)\n", (unsigned int)LiqType_count);
@ -324,24 +326,24 @@ bool ExtractSingleWmo(std::string& fname)
// Copy files from archive
char szLocalFile[1024];
const char * plain_name = GetPlainName(fname.c_str());
const char* plain_name = GetPlainName(fname.c_str());
sprintf(szLocalFile, "%s/%s", szWorkDirWmo, plain_name);
fixnamen(szLocalFile,strlen(szLocalFile));
fixnamen(szLocalFile, strlen(szLocalFile));
if (FileExists(szLocalFile))
return true;
int p = 0;
//Select root wmo files
const char * rchr = strrchr(plain_name, '_');
if(rchr != NULL)
const char* rchr = strrchr(plain_name, '_');
if (rchr != NULL)
{
char cpy[4];
strncpy((char*)cpy,rchr,4);
for (int i=0;i < 4; ++i)
strncpy((char*)cpy, rchr, 4);
for (int i = 0; i < 4; ++i)
{
int m = cpy[i];
if(isdigit(m))
if (isdigit(m))
p++;
}
}
@ -352,13 +354,13 @@ bool ExtractSingleWmo(std::string& fname)
bool file_ok = true;
std::cout << "Extracting " << fname << std::endl;
WMORoot froot(fname);
if(!froot.open())
if (!froot.open())
{
printf("Couldn't open RootWmo!!!\n");
return true;
}
FILE *output = fopen(szLocalFile,"wb");
if(!output)
FILE* output = fopen(szLocalFile, "wb");
if (!output)
{
printf("couldn't open %s for writing!\n", szLocalFile);
return false;
@ -366,20 +368,20 @@ bool ExtractSingleWmo(std::string& fname)
froot.ConvertToVMAPRootWmo(output);
int Wmo_nVertices = 0;
//printf("root has %d groups\n", froot->nGroups);
if (froot.nGroups !=0)
if (froot.nGroups != 0)
{
for (uint32 i = 0; i < froot.nGroups; ++i)
{
char temp[1024];
strcpy(temp, fname.c_str());
temp[fname.length()-4] = 0;
temp[fname.length() - 4] = 0;
char groupFileName[1024];
sprintf(groupFileName,"%s_%03d.wmo",temp, i);
sprintf(groupFileName, "%s_%03d.wmo", temp, i);
//printf("Trying to open groupfile %s\n",groupFileName);
string s = groupFileName;
WMOGroup fgroup(s);
if(!fgroup.open())
if (!fgroup.open())
{
printf("Could not open all Group file for: %s\n", plain_name);
file_ok = false;
@ -391,7 +393,7 @@ bool ExtractSingleWmo(std::string& fname)
}
fseek(output, 8, SEEK_SET); // store the correct no of vertices
fwrite(&Wmo_nVertices,sizeof(int),1,output);
fwrite(&Wmo_nVertices, sizeof(int), 1, output);
fclose(output);
// Delete the extracted file in the case of an error
@ -405,22 +407,23 @@ void ParsMapFiles()
char fn[512];
//char id_filename[64];
char id[10];
for (unsigned int i=0; i<map_count; ++i)
StringSet failedPaths;
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, map_ids[i].id))
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, map_ids[i].id))
{
printf("Processing Map %u\n[", map_ids[i].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))
if (ADTFile* ADT = WDT.GetMap(x, y))
{
//sprintf(id_filename,"%02u %02u %03u",x,y,map_ids[i].id);//!!!!!!!!!
ADT->init(map_ids[i].id, x, y);
ADT->init(map_ids[i].id, x, y, failedPaths);
delete ADT;
}
}
@ -430,14 +433,22 @@ void ParsMapFiles()
printf("]\n");
}
}
if (!failedPaths.empty())
{
printf("Warning: Some models could not be extracted, see below\n");
for (StringSet::const_iterator itr = failedPaths.begin(); itr != failedPaths.end(); ++itr)
printf("Could not find file of model %s\n", itr->c_str());
printf("A few not found models can be expected and are not alarming.\n");
}
}
void getGamePath()
{
#ifdef _WIN32
strcpy(input_path,"Data\\");
strcpy(input_path, "Data\\");
#else
strcpy(input_path,"Data/");
strcpy(input_path, "Data/");
#endif
}
@ -457,9 +468,9 @@ bool scan_patches(char* scanmatch, std::vector<std::string>& pArchiveNames)
sprintf(path, "%s.MPQ", scanmatch);
}
#ifdef __linux__
if(FILE* h = fopen64(path, "rb"))
if (FILE* h = fopen64(path, "rb"))
#else
if(FILE* h = fopen(path, "rb"))
if (FILE* h = fopen(path, "rb"))
#endif
{
fclose(h);
@ -471,24 +482,24 @@ bool scan_patches(char* scanmatch, std::vector<std::string>& pArchiveNames)
return(true);
}
bool processArgv(int argc, char ** argv, const char *versionString)
bool processArgv(int argc, char** argv)
{
bool result = true;
bool hasInputPathParam = false;
bool preciseVectorData = false;
for(int i=1; i< argc; ++i)
for (int i = 1; i < argc; ++i)
{
if(strcmp("-s",argv[i]) == 0)
if (strcmp("-s", argv[i]) == 0)
{
preciseVectorData = false;
}
else if(strcmp("-d",argv[i]) == 0)
else if (strcmp("-d", argv[i]) == 0)
{
if((i+1)<argc)
if ((i + 1) < argc)
{
hasInputPathParam = true;
strcpy(input_path, argv[i+1]);
strcpy(input_path, argv[i + 1]);
if (input_path[strlen(input_path) - 1] != '\\' || input_path[strlen(input_path) - 1] != '/')
strcat(input_path, "/");
++i;
@ -498,15 +509,15 @@ bool processArgv(int argc, char ** argv, const char *versionString)
result = false;
}
}
else if(strcmp("-?",argv[1]) == 0)
else if (strcmp("-?", argv[1]) == 0)
{
result = false;
}
else if(strcmp("-l",argv[i]) == 0)
else if (strcmp("-l", argv[i]) == 0)
{
preciseVectorData = true;
}
else if(strcmp("-b",argv[i]) == 0)
else if (strcmp("-b", argv[i]) == 0)
{
if (i + 1 < argc) // all ok
CONF_TargetBuild = atoi(argv[i++ + 1]);
@ -518,9 +529,9 @@ bool processArgv(int argc, char ** argv, const char *versionString)
}
}
if(!result)
if (!result)
{
printf("Extract %s.\n",versionString);
printf("Extract for %s.\n", szRawVMAPMagic);
printf("%s [-?][-s][-l][-d <path>]\n", argv[0]);
printf(" -s : (default) small size (data size optimization), ~500MB less vmap data.\n");
printf(" -l : large size, ~500MB more vmap data. (might contain more details)\n");
@ -529,7 +540,7 @@ bool processArgv(int argc, char ** argv, const char *versionString)
printf(" -? : This message.\n");
}
if(!hasInputPathParam)
if (!hasInputPathParam)
getGamePath();
return result;
@ -545,13 +556,12 @@ bool processArgv(int argc, char ** argv, const char *versionString)
// Arg2 - Listfile name
//
int main(int argc, char ** argv)
int main(int argc, char** argv)
{
bool success=true;
const char *versionString = "V4.00 2012_08";
bool success = true;
// Use command line arguments, when some
if(!processArgv(argc, argv, versionString))
if (!processArgv(argc, argv))
return 1;
// some simple check if working dir is dirty
@ -570,15 +580,15 @@ int main(int argc, char ** argv)
}
}
printf("Extract %s. Beginning work ....\n",versionString);
printf("Extract for %s. Beginning work ....\n", szRawVMAPMagic);
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// Create the working directory
if(mkdir(szWorkDirWmo
if (mkdir(szWorkDirWmo
#ifdef __linux__
, 0711
, 0711
#endif
))
success = (errno == EEXIST);
))
success = (errno == EEXIST);
LoadCommonMPQFiles(CONF_TargetBuild);
@ -601,27 +611,27 @@ int main(int argc, char ** argv)
ReadLiquidTypeTableDBC();
// extract data
if(success)
if (success)
success = ExtractWmo();
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//map.dbc
if(success)
if (success)
{
DBCFile * dbc = new DBCFile(LocaleMpq, "DBFilesClient\\Map.dbc");
if(!dbc->open())
DBCFile* dbc = new DBCFile(LocaleMpq, "DBFilesClient\\Map.dbc");
if (!dbc->open())
{
delete dbc;
printf("FATAL ERROR: Map.dbc not found in data file.\n");
return 1;
}
map_count=dbc->getRecordCount ();
map_ids=new map_id[map_count];
for(unsigned int x=0;x<map_count;++x)
map_count = dbc->getRecordCount();
map_ids = new map_id[map_count];
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);
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);
}
@ -629,19 +639,21 @@ int main(int argc, char ** argv)
ParsMapFiles();
delete [] map_ids;
//nError = ERROR_SUCCESS;
// Extract models, listed in DameObjectDisplayInfo.dbc
ExtractGameobjectModels();
}
SFileCloseArchive(LocaleMpq);
SFileCloseArchive(WorldMpq);
printf("\n");
if(!success)
if (!success)
{
printf("ERROR: Extract %s. Work NOT complete.\n Precise vector data=%d.\nPress any key.\n",versionString, preciseVectorData);
printf("ERROR: Extract for %s. Work NOT complete.\n Precise vector data=%d.\nPress any key.\n", szRawVMAPMagic, preciseVectorData);
getchar();
}
printf("Extract %s. Work complete. No errors.\n",versionString);
printf("Extract for %s. Work complete. No errors.\n", szRawVMAPMagic);
delete [] LiqType;
return 0;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -20,20 +20,26 @@
#define VMAPEXPORT_H
#include <string>
#include <set>
typedef std::set<std::string> StringSet;
enum ModelFlags
{
MOD_M2 = 1,
MOD_WORLDSPAWN = 1<<1,
MOD_HAS_BOUND = 1<<2
MOD_WORLDSPAWN = 1 << 1,
MOD_HAS_BOUND = 1 << 2
};
extern const char * szWorkDirWmo;
extern const char * szRawVMAPMagic; // vmap magic string for extracted raw vmap data
extern const char* szWorkDirWmo;
extern const char* szRawVMAPMagic; // vmap magic string for extracted raw vmap data
bool FileExists(const char * file);
bool FileExists(const char* file);
void strToLower(char* str);
bool ExtractSingleWmo(std::string& fname);
bool ExtractSingleModel(std::string& fname, StringSet& failedPaths);
void ExtractGameobjectModels();
#endif

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -22,23 +22,23 @@
#include "adtfile.h"
#include <cstdio>
char * wdtGetPlainName(char * FileName)
char* wdtGetPlainName(char* FileName)
{
char * szTemp;
char* szTemp;
if((szTemp = strrchr(FileName, '\\')) != NULL)
if ((szTemp = strrchr(FileName, '\\')) != NULL)
FileName = szTemp + 1;
return FileName;
}
extern HANDLE WorldMpq;
WDTFile::WDTFile(char* file_name, char* file_name1):WDT(WorldMpq, file_name)
WDTFile::WDTFile(char* file_name, char* file_name1): WDT(WorldMpq, file_name)
{
filename.append(file_name1,strlen(file_name1));
filename.append(file_name1, strlen(file_name1));
}
bool WDTFile::init(char *map_id, unsigned int mapID)
bool WDTFile::init(char* map_id, unsigned int mapID)
{
if (WDT.isEof())
{
@ -50,9 +50,9 @@ bool WDTFile::init(char *map_id, unsigned int mapID)
uint32 size;
std::string dirname = std::string(szWorkDirWmo) + "/dir_bin";
FILE *dirfile;
FILE* dirfile;
dirfile = fopen(dirname.c_str(), "ab");
if(!dirfile)
if (!dirfile)
{
printf("Can't open dirfile!'%s'\n", dirname.c_str());
return false;
@ -60,7 +60,7 @@ bool WDTFile::init(char *map_id, unsigned int mapID)
while (!WDT.isEof())
{
WDT.read(fourcc,4);
WDT.read(fourcc, 4);
WDT.read(&size, 4);
flipcc(fourcc);
@ -68,31 +68,31 @@ bool WDTFile::init(char *map_id, unsigned int mapID)
size_t nextpos = WDT.getPos() + size;
if (!strcmp(fourcc,"MAIN"))
if (!strcmp(fourcc, "MAIN"))
{
}
if (!strcmp(fourcc,"MWMO"))
if (!strcmp(fourcc, "MWMO"))
{
// global map objects
if (size)
{
char *buf = new char[size];
char* buf = new char[size];
WDT.read(buf, size);
char *p=buf;
char* p = buf;
int q = 0;
gWmoInstansName = new string[size];
while (p<buf+size)
while (p < buf + size)
{
string path(p);
char* s=wdtGetPlainName(p);
fixnamen(s,strlen(s));
p=p+strlen(p)+1;
char* s = wdtGetPlainName(p);
fixnamen(s, strlen(s));
p = p + strlen(p) + 1;
gWmoInstansName[q++] = s;
}
delete[] buf;
}
}
else if (!strcmp(fourcc,"MODF"))
else if (!strcmp(fourcc, "MODF"))
{
// global wmo instance data
if (size)
@ -103,11 +103,11 @@ bool WDTFile::init(char *map_id, unsigned int mapID)
fake_mapname = "65 65 ";
//gWMO_mapname = fake_mapname + filename;
gWMO_mapname = fake_mapname + std::string(map_id);
for (int i=0; i<gnWMO; ++i)
for (int i = 0; i < gnWMO; ++i)
{
int id;
WDT.read(&id, 4);
WMOInstance inst(WDT,gWmoInstansName[id].c_str(),mapID, 65, 65, dirfile);
WMOInstance inst(WDT, gWmoInstansName[id].c_str(), mapID, 65, 65, dirfile);
}
delete[] gWmoInstansName;
}
@ -127,11 +127,11 @@ WDTFile::~WDTFile(void)
ADTFile* WDTFile::GetMap(int x, int z)
{
if(!(x>=0 && z >= 0 && x<64 && z<64))
if (!(x >= 0 && z >= 0 && x < 64 && z < 64))
return NULL;
char name[512];
sprintf(name,"World\\Maps\\%s\\%s_%d_%d_obj0.adt", filename.c_str(), filename.c_str(), x, z);
sprintf(name, "World\\Maps\\%s\\%s_%d_%d_obj0.adt", filename.c_str(), filename.c_str(), x, z);
return new ADTFile(name);
}

View file

@ -0,0 +1,47 @@
/*
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef WDTFILE_H
#define WDTFILE_H
#include "mpqfile.h"
#include "wmo.h"
#include <string>
#include "stdlib.h"
class ADTFile;
class WDTFile
{
public:
WDTFile(char* file_name, char* file_name1);
~WDTFile(void);
bool init(char* map_id, unsigned int mapID);
string* gWmoInstansName;
int gnWMO, nMaps;
ADTFile* GetMap(int x, int z);
private:
MPQFile WDT;
bool maps[64][64];
string filename;
};
#endif

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -31,9 +31,9 @@
#include "mpqfile.h"
using namespace std;
extern uint16 *LiqType;
extern uint16* LiqType;
WMORoot::WMORoot(std::string &filename) : filename(filename)
WMORoot::WMORoot(std::string& filename) : filename(filename)
{
}
@ -42,9 +42,9 @@ extern HANDLE WorldMpq;
bool WMORoot::open()
{
MPQFile f(WorldMpq, filename.c_str());
if(f.isEof ())
if (f.isEof())
{
printf("No such file.\n");
printf("No such file %s.\n", filename.c_str());
return false;
}
@ -53,7 +53,7 @@ bool WMORoot::open()
while (!f.isEof())
{
f.read(fourcc,4);
f.read(fourcc, 4);
f.read(&size, 4);
flipcc(fourcc);
@ -61,7 +61,7 @@ bool WMORoot::open()
size_t nextpos = f.getPos() + size;
if (!strcmp(fourcc,"MOHD"))//header
if (!strcmp(fourcc, "MOHD")) //header
{
f.read(&nTextures, 4);
f.read(&nGroups, 4);
@ -72,8 +72,8 @@ bool WMORoot::open()
f.read(&nDoodadSets, 4);
f.read(&col, 4);
f.read(&RootWMOID, 4);
f.read(bbcorn1,12);
f.read(bbcorn2,12);
f.read(bbcorn1, 12);
f.read(bbcorn2, 12);
f.read(&liquidType, 4);
break;
}
@ -120,19 +120,19 @@ bool WMORoot::open()
*/
f.seek((int)nextpos);
}
f.close ();
f.close();
return true;
}
bool WMORoot::ConvertToVMAPRootWmo(FILE *pOutfile)
bool WMORoot::ConvertToVMAPRootWmo(FILE* pOutfile)
{
//printf("Convert RootWmo...\n");
fwrite(szRawVMAPMagic,1,8,pOutfile);
fwrite(szRawVMAPMagic, 1, 8, pOutfile);
unsigned int nVectors = 0;
fwrite(&nVectors,sizeof(nVectors),1,pOutfile); // will be filled later
fwrite(&nGroups,4,1,pOutfile);
fwrite(&RootWMOID,4,1,pOutfile);
fwrite(&nVectors, sizeof(nVectors), 1, pOutfile); // will be filled later
fwrite(&nGroups, 4, 1, pOutfile);
fwrite(&RootWMOID, 4, 1, pOutfile);
return true;
}
@ -140,15 +140,15 @@ WMORoot::~WMORoot()
{
}
WMOGroup::WMOGroup(std::string &filename) : filename(filename),
MOPY(0), MOVI(0), MoviEx(0), MOVT(0), MOBA(0), MobaEx(0), hlq(0), LiquEx(0), LiquBytes(0)
WMOGroup::WMOGroup(std::string& filename) : filename(filename),
MOPY(0), MOVI(0), MoviEx(0), MOVT(0), MOBA(0), MobaEx(0), hlq(0), LiquEx(0), LiquBytes(0)
{
}
bool WMOGroup::open()
{
MPQFile f(WorldMpq, filename.c_str());
if(f.isEof ())
if (f.isEof())
{
printf("No such file.\n");
return false;
@ -157,10 +157,10 @@ bool WMOGroup::open()
char fourcc[5];
while (!f.isEof())
{
f.read(fourcc,4);
f.read(fourcc, 4);
f.read(&size, 4);
flipcc(fourcc);
if (!strcmp(fourcc,"MOGP"))//Fix sizeoff = Data size.
if (!strcmp(fourcc, "MOGP")) //Fix sizeoff = Data size.
{
size = 68;
}
@ -169,7 +169,7 @@ bool WMOGroup::open()
LiquEx_size = 0;
liquflags = 0;
if (!strcmp(fourcc,"MOGP"))//header
if (!strcmp(fourcc, "MOGP")) //header
{
f.read(&groupName, 4);
f.read(&descGroupName, 4);
@ -183,40 +183,39 @@ bool WMOGroup::open()
f.read(&nBatchC, 4);
f.read(&fogIdx, 4);
f.read(&liquidType, 4);
f.read(&groupWMOID,4);
f.read(&groupWMOID, 4);
}
else if (!strcmp(fourcc,"MOPY"))
else if (!strcmp(fourcc, "MOPY"))
{
MOPY = new char[size];
mopy_size = size;
nTriangles = (int)size / 2;
f.read(MOPY, size);
}
else if (!strcmp(fourcc,"MOVI"))
else if (!strcmp(fourcc, "MOVI"))
{
MOVI = new uint16[size/2];
MOVI = new uint16[size / 2];
f.read(MOVI, size);
}
else if (!strcmp(fourcc,"MOVT"))
else if (!strcmp(fourcc, "MOVT"))
{
MOVT = new float[size/4];
MOVT = new float[size / 4];
f.read(MOVT, size);
nVertices = (int)size / 12;
}
else if (!strcmp(fourcc,"MONR"))
else if (!strcmp(fourcc, "MONR"))
{
}
else if (!strcmp(fourcc,"MOTV"))
else if (!strcmp(fourcc, "MOTV"))
{
}
else if (!strcmp(fourcc,"MOBA"))
else if (!strcmp(fourcc, "MOBA"))
{
MOBA = new uint16[size/2];
moba_size = size/2;
MOBA = new uint16[size / 2];
moba_size = size / 2;
f.read(MOBA, size);
}
else if (!strcmp(fourcc,"MLIQ"))
else if (!strcmp(fourcc, "MLIQ"))
{
liquflags |= 1;
hlq = new WMOLiquidHeader;
@ -241,79 +240,79 @@ bool WMOGroup::open()
return true;
}
int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, WMORoot *rootWMO, bool pPreciseVectorData)
int WMOGroup::ConvertToVMAPGroupWmo(FILE* output, WMORoot* rootWMO, bool pPreciseVectorData)
{
fwrite(&mogpFlags,sizeof(uint32),1,output);
fwrite(&groupWMOID,sizeof(uint32),1,output);
fwrite(&mogpFlags, sizeof(uint32), 1, output);
fwrite(&groupWMOID, sizeof(uint32), 1, output);
// group bound
fwrite(bbcorn1, sizeof(float), 3, output);
fwrite(bbcorn2, sizeof(float), 3, output);
fwrite(&liquflags,sizeof(uint32),1,output);
fwrite(&liquflags, sizeof(uint32), 1, output);
int nColTriangles = 0;
if(pPreciseVectorData)
if (pPreciseVectorData)
{
char GRP[] = "GRP ";
fwrite(GRP,1,4,output);
fwrite(GRP, 1, 4, output);
int k = 0;
int moba_batch = moba_size/12;
MobaEx = new int[moba_batch*4];
for(int i=8; i<moba_size; i+=12)
int moba_batch = moba_size / 12;
MobaEx = new int[moba_batch * 4];
for (int i = 8; i < moba_size; i += 12)
{
MobaEx[k++] = MOBA[i];
}
int moba_size_grp = moba_batch*4+4;
fwrite(&moba_size_grp,4,1,output);
fwrite(&moba_batch,4,1,output);
fwrite(MobaEx,4,k,output);
int moba_size_grp = moba_batch * 4 + 4;
fwrite(&moba_size_grp, 4, 1, output);
fwrite(&moba_batch, 4, 1, output);
fwrite(MobaEx, 4, k, output);
delete [] MobaEx;
uint32 nIdexes = nTriangles * 3;
if(fwrite("INDX",4, 1, output) != 1)
if (fwrite("INDX", 4, 1, output) != 1)
{
printf("Error while writing file nbraches ID");
exit(0);
}
int wsize = sizeof(uint32) + sizeof(unsigned short) * nIdexes;
if(fwrite(&wsize, sizeof(int), 1, output) != 1)
if (fwrite(&wsize, sizeof(int), 1, output) != 1)
{
printf("Error while writing file wsize");
// no need to exit?
}
if(fwrite(&nIdexes, sizeof(uint32), 1, output) != 1)
if (fwrite(&nIdexes, sizeof(uint32), 1, output) != 1)
{
printf("Error while writing file nIndexes");
exit(0);
}
if(nIdexes >0)
if (nIdexes > 0)
{
if(fwrite(MOVI, sizeof(unsigned short), nIdexes, output) != nIdexes)
if (fwrite(MOVI, sizeof(unsigned short), nIdexes, output) != nIdexes)
{
printf("Error while writing file indexarray");
exit(0);
}
}
if(fwrite("VERT",4, 1, output) != 1)
if (fwrite("VERT", 4, 1, output) != 1)
{
printf("Error while writing file nbraches ID");
exit(0);
}
wsize = sizeof(int) + sizeof(float) * 3 * nVertices;
if(fwrite(&wsize, sizeof(int), 1, output) != 1)
if (fwrite(&wsize, sizeof(int), 1, output) != 1)
{
printf("Error while writing file wsize");
// no need to exit?
}
if(fwrite(&nVertices, sizeof(int), 1, output) != 1)
if (fwrite(&nVertices, sizeof(int), 1, output) != 1)
{
printf("Error while writing file nVertices");
exit(0);
}
if(nVertices >0)
if (nVertices > 0)
{
if(fwrite(MOVT, sizeof(float)*3, nVertices, output) != nVertices)
if (fwrite(MOVT, sizeof(float) * 3, nVertices, output) != nVertices)
{
printf("Error while writing file vectors");
exit(0);
@ -325,44 +324,44 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, WMORoot *rootWMO, bool pPrecis
else
{
char GRP[] = "GRP ";
fwrite(GRP,1,4,output);
fwrite(GRP, 1, 4, output);
int k = 0;
int moba_batch = moba_size/12;
MobaEx = new int[moba_batch*4];
for(int i=8; i<moba_size; i+=12)
int moba_batch = moba_size / 12;
MobaEx = new int[moba_batch * 4];
for (int i = 8; i < moba_size; i += 12)
{
MobaEx[k++] = MOBA[i];
}
int moba_size_grp = moba_batch*4+4;
fwrite(&moba_size_grp,4,1,output);
fwrite(&moba_batch,4,1,output);
fwrite(MobaEx,4,k,output);
int moba_size_grp = moba_batch * 4 + 4;
fwrite(&moba_size_grp, 4, 1, output);
fwrite(&moba_batch, 4, 1, output);
fwrite(MobaEx, 4, k, output);
delete [] MobaEx;
//-------INDX------------------------------------
//-------MOPY--------
MoviEx = new uint16[nTriangles*3]; // "worst case" size...
int *IndexRenum = new int[nVertices];
memset(IndexRenum, 0xFF, nVertices*sizeof(int));
for (int i=0; i<nTriangles; ++i)
MoviEx = new uint16[nTriangles * 3]; // "worst case" size...
int* IndexRenum = new int[nVertices];
memset(IndexRenum, 0xFF, nVertices * sizeof(int));
for (int i = 0; i < nTriangles; ++i)
{
// Skip no collision triangles
if (MOPY[2*i]&WMO_MATERIAL_NO_COLLISION ||
!(MOPY[2*i]&(WMO_MATERIAL_HINT|WMO_MATERIAL_COLLIDE_HIT)) )
if (MOPY[2 * i]&WMO_MATERIAL_NO_COLLISION ||
!(MOPY[2 * i] & (WMO_MATERIAL_HINT | WMO_MATERIAL_COLLIDE_HIT)))
continue;
// Use this triangle
for (int j=0; j<3; ++j)
for (int j = 0; j < 3; ++j)
{
IndexRenum[MOVI[3*i + j]] = 1;
MoviEx[3*nColTriangles + j] = MOVI[3*i + j];
IndexRenum[MOVI[3 * i + j]] = 1;
MoviEx[3 * nColTriangles + j] = MOVI[3 * i + j];
}
++nColTriangles;
}
// assign new vertex index numbers
int nColVertices = 0;
for (uint32 i=0; i<nVertices; ++i)
for (uint32 i = 0; i < nVertices; ++i)
{
if (IndexRenum[i] == 1)
{
@ -372,35 +371,35 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, WMORoot *rootWMO, bool pPrecis
}
// translate triangle indices to new numbers
for (int i=0; i<3*nColTriangles; ++i)
for (int i = 0; i < 3 * nColTriangles; ++i)
{
assert(MoviEx[i] < nVertices);
MoviEx[i] = IndexRenum[MoviEx[i]];
}
// write triangle indices
int INDX[] = {0x58444E49, nColTriangles*6+4, nColTriangles*3};
fwrite(INDX,4,3,output);
fwrite(MoviEx,2,nColTriangles*3,output);
int INDX[] = {0x58444E49, nColTriangles * 6 + 4, nColTriangles * 3};
fwrite(INDX, 4, 3, output);
fwrite(MoviEx, 2, nColTriangles * 3, output);
// write vertices
int VERT[] = {0x54524556, nColVertices*3*sizeof(float)+4, nColVertices};// "VERT"
int check = 3*nColVertices;
fwrite(VERT,4,3,output);
for (uint32 i=0; i<nVertices; ++i)
if(IndexRenum[i] >= 0)
check -= fwrite(MOVT+3*i, sizeof(float), 3, output);
int VERT[] = {0x54524556, nColVertices * 3 * sizeof(float) + 4, nColVertices}; // "VERT"
int check = 3 * nColVertices;
fwrite(VERT, 4, 3, output);
for (uint32 i = 0; i < nVertices; ++i)
if (IndexRenum[i] >= 0)
check -= fwrite(MOVT + 3 * i, sizeof(float), 3, output);
assert(check==0);
assert(check == 0);
delete [] MoviEx;
delete [] IndexRenum;
}
//------LIQU------------------------
if(LiquEx_size != 0)
if (LiquEx_size != 0)
{
int LIQU_h[] = {0x5551494C, sizeof(WMOLiquidHeader) + LiquEx_size + hlq->xtiles*hlq->ytiles};// "LIQU"
int LIQU_h[] = {0x5551494C, sizeof(WMOLiquidHeader) + LiquEx_size + hlq->xtiles* hlq->ytiles}; // "LIQU"
fwrite(LIQU_h, 4, 2, output);
// according to WoW.Dev Wiki:
@ -463,10 +462,10 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, WMORoot *rootWMO, bool pPrecis
fwrite(hlq, sizeof(WMOLiquidHeader), 1, output);
// only need height values, the other values are unknown anyway
for (uint32 i = 0; i<LiquEx_size/sizeof(WMOLiquidVert); ++i)
for (uint32 i = 0; i < LiquEx_size / sizeof(WMOLiquidVert); ++i)
fwrite(&LiquEx[i].height, sizeof(float), 1, output);
// todo: compress to bit field
fwrite(LiquBytes, 1, hlq->xtiles*hlq->ytiles, output);
fwrite(LiquBytes, 1, hlq->xtiles * hlq->ytiles, output);
}
return nColTriangles;
@ -483,34 +482,34 @@ WMOGroup::~WMOGroup()
delete [] LiquBytes;
}
WMOInstance::WMOInstance(MPQFile &f,const char* WmoInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE *pDirfile)
WMOInstance::WMOInstance(MPQFile& f, const char* WmoInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE* pDirfile)
{
pos = Vec3D(0,0,0);
pos = Vec3D(0, 0, 0);
float ff[3];
f.read(&id, 4);
f.read(ff,12);
pos = Vec3D(ff[0],ff[1],ff[2]);
f.read(ff,12);
rot = Vec3D(ff[0],ff[1],ff[2]);
f.read(ff,12);
pos2 = Vec3D(ff[0],ff[1],ff[2]);
f.read(ff,12);
pos3 = Vec3D(ff[0],ff[1],ff[2]);
f.read(&d2,4);
f.read(ff, 12);
pos = Vec3D(ff[0], ff[1], ff[2]);
f.read(ff, 12);
rot = Vec3D(ff[0], ff[1], ff[2]);
f.read(ff, 12);
pos2 = Vec3D(ff[0], ff[1], ff[2]);
f.read(ff, 12);
pos3 = Vec3D(ff[0], ff[1], ff[2]);
f.read(&d2, 4);
uint16 trash,adtId;
f.read(&adtId,2);
f.read(&trash,2);
uint16 trash, adtId;
f.read(&adtId, 2);
f.read(&trash, 2);
//-----------add_in _dir_file----------------
char tempname[512];
sprintf(tempname, "%s/%s", szWorkDirWmo, WmoInstName);
FILE *input;
FILE* input;
input = fopen(tempname, "r+b");
if(!input)
if (!input)
{
printf("WMOInstance::WMOInstance: couldn't open %s\n", tempname);
return;
@ -518,19 +517,19 @@ WMOInstance::WMOInstance(MPQFile &f,const char* WmoInstName, uint32 mapID, uint3
fseek(input, 8, SEEK_SET); // get the correct no of vertices
int nVertices;
fread(&nVertices, sizeof (int), 1, input);
fread(&nVertices, sizeof(int), 1, input);
fclose(input);
if(nVertices == 0)
if (nVertices == 0)
return;
float x,z;
float x, z;
x = pos.x;
z = pos.z;
if(x==0 && z == 0)
if (x == 0 && z == 0)
{
pos.x = 533.33333f*32;
pos.z = 533.33333f*32;
pos.x = 533.33333f * 32;
pos.z = 533.33333f * 32;
}
pos = fixCoords(pos);
pos2 = fixCoords(pos2);
@ -538,7 +537,7 @@ WMOInstance::WMOInstance(MPQFile &f,const char* WmoInstName, uint32 mapID, uint3
float scale = 1.0f;
uint32 flags = MOD_HAS_BOUND;
if(tileX == 65 && tileY == 65) flags |= MOD_WORLDSPAWN;
if (tileX == 65 && tileY == 65) flags |= MOD_WORLDSPAWN;
//write mapID, tileX, tileY, Flags, ID, Pos, Rot, Scale, Bound_lo, Bound_hi, name
fwrite(&mapID, sizeof(uint32), 1, pDirfile);
fwrite(&tileX, sizeof(uint32), 1, pDirfile);
@ -551,7 +550,7 @@ WMOInstance::WMOInstance(MPQFile &f,const char* WmoInstName, uint32 mapID, uint3
fwrite(&scale, sizeof(float), 1, pDirfile);
fwrite(&pos2, sizeof(float), 3, pDirfile);
fwrite(&pos3, sizeof(float), 3, pDirfile);
uint32 nlen=strlen(WmoInstName);
uint32 nlen = strlen(WmoInstName);
fwrite(&nlen, sizeof(uint32), 1, pDirfile);
fwrite(WmoInstName, sizeof(char), nlen, pDirfile);

View file

@ -0,0 +1,136 @@
/*
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef WMO_H
#define WMO_H
#define TILESIZE (533.33333f)
#define CHUNKSIZE ((TILESIZE) / 16.0f)
#include <string>
#include <set>
#include "vec3d.h"
#include "mpqfile.h"
// MOPY flags
#define WMO_MATERIAL_NOCAMCOLLIDE 0x01
#define WMO_MATERIAL_DETAIL 0x02
#define WMO_MATERIAL_NO_COLLISION 0x04
#define WMO_MATERIAL_HINT 0x08
#define WMO_MATERIAL_RENDER 0x10
#define WMO_MATERIAL_COLLIDE_HIT 0x20
#define WMO_MATERIAL_WALL_SURFACE 0x40
class WMOInstance;
class WMOManager;
class MPQFile;
/* for whatever reason a certain company just can't stick to one coordinate system... */
static inline Vec3D fixCoords(const Vec3D& v) { return Vec3D(v.z, v.x, v.y); }
class WMORoot
{
public:
uint32 nTextures, nGroups, nP, nLights, nModels, nDoodads, nDoodadSets, RootWMOID, liquidType;
unsigned int col;
float bbcorn1[3];
float bbcorn2[3];
WMORoot(std::string& filename);
~WMORoot();
bool open();
bool ConvertToVMAPRootWmo(FILE* output);
private:
std::string filename;
char outfilename;
};
struct WMOLiquidHeader
{
int xverts, yverts, xtiles, ytiles;
float pos_x;
float pos_y;
float pos_z;
short type;
};
struct WMOLiquidVert
{
uint16 unk1;
uint16 unk2;
float height;
};
class WMOGroup
{
public:
// MOGP
int groupName, descGroupName, mogpFlags;
float bbcorn1[3];
float bbcorn2[3];
uint16 moprIdx;
uint16 moprNItems;
uint16 nBatchA;
uint16 nBatchB;
uint32 nBatchC, fogIdx, liquidType, groupWMOID;
int mopy_size, moba_size;
int LiquEx_size;
unsigned int nVertices; // number when loaded
int nTriangles; // number when loaded
char* MOPY;
uint16* MOVI;
uint16* MoviEx;
float* MOVT;
uint16* MOBA;
int* MobaEx;
WMOLiquidHeader* hlq;
WMOLiquidVert* LiquEx;
char* LiquBytes;
uint32 liquflags;
WMOGroup(std::string& filename);
~WMOGroup();
bool open();
int ConvertToVMAPGroupWmo(FILE* output, WMORoot* rootWMO, bool pPreciseVectorData);
private:
std::string filename;
char outfilename;
};
class WMOInstance
{
static std::set<int> ids;
public:
std::string MapName;
int currx;
int curry;
WMOGroup* wmo;
Vec3D pos;
Vec3D pos2, pos3, rot;
uint32 indx, id, d2, d3;
int doodadset;
WMOInstance(MPQFile& f, const char* WmoInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE* pDirfile);
static void reset();
};
#endif

View file

@ -12,7 +12,7 @@
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}</ProjectGuid>
<RootNamespace>vmapExtractor4</RootNamespace>
<RootNamespace>vmapExtractor</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
@ -86,6 +86,7 @@
<ItemGroup>
<ClCompile Include="..\..\vmapextract\adtfile.cpp" />
<ClCompile Include="..\..\vmapextract\dbcfile.cpp" />
<ClCompile Include="..\..\vmapextract\gameobject_extract.cpp" />
<ClCompile Include="..\..\vmapextract\model.cpp" />
<ClCompile Include="..\..\vmapextract\mpqfile.cpp" />
<ClCompile Include="..\..\vmapextract\vmapexport.cpp" />

View file

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}</ProjectGuid>
<RootNamespace>vmapExtractor</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\bin\$(Platform)_$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\bin\$(ProjectName)__$(Platform)_$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\bin\$(Platform)_$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\bin\$(ProjectName)__$(Platform)_$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\..\dep\StormLib\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>..\..\..\..\dep\StormLib\bin\StormLib\$(Platform)\$(Configuration)AD;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<TargetMachine>MachineX86</TargetMachine>
<SubSystem>Console</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>..\..\..\..\dep\StormLib\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>StormLibRAD.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>..\..\..\..\dep\StormLib\bin\StormLib\$(Platform)\$(Configuration)AD;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\vmapextract\adtfile.cpp" />
<ClCompile Include="..\..\vmapextract\dbcfile.cpp" />
<ClCompile Include="..\..\vmapextract\gameobject_extract.cpp" />
<ClCompile Include="..\..\vmapextract\model.cpp" />
<ClCompile Include="..\..\vmapextract\mpqfile.cpp" />
<ClCompile Include="..\..\vmapextract\vmapexport.cpp" />
<ClCompile Include="..\..\vmapextract\wdtfile.cpp" />
<ClCompile Include="..\..\vmapextract\wmo.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\vmapextract\adtfile.h" />
<ClInclude Include="..\..\vmapextract\dbcfile.h" />
<ClInclude Include="..\..\vmapextract\model.h" />
<ClInclude Include="..\..\vmapextract\modelheaders.h" />
<ClInclude Include="..\..\vmapextract\mpqfile.h" />
<ClInclude Include="..\..\vmapextract\vec3d.h" />
<ClInclude Include="..\..\vmapextract\vmapexport.h" />
<ClInclude Include="..\..\vmapextract\wdtfile.h" />
<ClInclude Include="..\..\vmapextract\wmo.h" />
<ClInclude Include="..\..\vmapextract\loadlib\loadlib.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="..\..\vmapextract\adtfile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\vmapextract\dbcfile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\vmapextract\model.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\vmapextract\mpqfile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\vmapextract\vmapexport.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\vmapextract\wdtfile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\vmapextract\wmo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\vmapextract\gameobject_extract.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\vmapextract\dbcfile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\vmapextract\adtfile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\vmapextract\loadlib\loadlib.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\vmapextract\model.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\vmapextract\mpqfile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\vmapextract\modelheaders.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\vmapextract\vmapexport.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\vmapextract\vec3d.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\vmapextract\wdtfile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\vmapextract\wmo.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{77920bff-80f2-4d57-8efb-d36d461d04a4}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{093fdfc3-8861-4d64-9c5e-4a58337b9c7e}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>

View file

@ -183,6 +183,10 @@
RelativePath="..\..\vmapextract\dbcfile.h"
>
</File>
<File
RelativePath="..\..\vmapextract\gameobject_extract.cpp"
>
</File>
<File
RelativePath="..\..\vmapextract\model.cpp"
>

View file

@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vmapExtractor4", "VC100\vmapExtractor4.vcxproj", "{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vmapExtractor", "VC100\vmapExtractor.vcxproj", "{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}"
ProjectSection(ProjectDependencies) = postProject
{78424708-1F6E-4D4B-920C-FB6D26847055} = {78424708-1F6E-4D4B-920C-FB6D26847055}
{B96F612A-C91D-43B3-A4C3-D4294817EC6C} = {B96F612A-C91D-43B3-A4C3-D4294817EC6C}

View file

@ -0,0 +1,116 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vmapExtractor", "VC110\vmapExtractor.vcxproj", "{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}"
ProjectSection(ProjectDependencies) = postProject
{78424708-1F6E-4D4B-920C-FB6D26847055} = {78424708-1F6E-4D4B-920C-FB6D26847055}
{B96F612A-C91D-43B3-A4C3-D4294817EC6C} = {B96F612A-C91D-43B3-A4C3-D4294817EC6C}
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "..\..\..\win\VC110\zlib.vcxproj", "{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bzip2", "..\..\..\win\VC110\bzip2.vcxproj", "{B96F612A-C91D-43B3-A4C3-D4294817EC6C}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StormLib", "..\..\..\dep\StormLib\StormLib_vc110.vcxproj", "{78424708-1F6E-4D4B-920C-FB6D26847055}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
DebugAD|Win32 = DebugAD|Win32
DebugAD|x64 = DebugAD|x64
DebugAS|Win32 = DebugAS|Win32
DebugAS|x64 = DebugAS|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
ReleaseAD|Win32 = ReleaseAD|Win32
ReleaseAD|x64 = ReleaseAD|x64
ReleaseAS|Win32 = ReleaseAS|Win32
ReleaseAS|x64 = ReleaseAS|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}.Debug|Win32.ActiveCfg = Debug|Win32
{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}.Debug|Win32.Build.0 = Debug|Win32
{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}.Debug|x64.ActiveCfg = Debug|Win32
{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}.DebugAD|Win32.ActiveCfg = Debug|Win32
{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}.DebugAD|Win32.Build.0 = Debug|Win32
{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}.DebugAD|x64.ActiveCfg = Debug|Win32
{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}.DebugAS|Win32.ActiveCfg = Debug|Win32
{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}.DebugAS|Win32.Build.0 = Debug|Win32
{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}.DebugAS|x64.ActiveCfg = Debug|Win32
{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}.Release|Win32.ActiveCfg = Release|Win32
{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}.Release|Win32.Build.0 = Release|Win32
{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}.Release|x64.ActiveCfg = Release|Win32
{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}.ReleaseAD|Win32.ActiveCfg = Release|Win32
{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}.ReleaseAD|Win32.Build.0 = Release|Win32
{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}.ReleaseAD|x64.ActiveCfg = Release|Win32
{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}.ReleaseAS|Win32.ActiveCfg = Release|Win32
{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}.ReleaseAS|Win32.Build.0 = Release|Win32
{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}.ReleaseAS|x64.ActiveCfg = Release|Win32
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug|Win32.ActiveCfg = Debug|Win32
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug|Win32.Build.0 = Debug|Win32
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug|x64.ActiveCfg = Debug|x64
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug|x64.Build.0 = Debug|x64
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.DebugAD|Win32.ActiveCfg = Debug|x64
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.DebugAD|x64.ActiveCfg = Debug|x64
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.DebugAD|x64.Build.0 = Debug|x64
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.DebugAS|Win32.ActiveCfg = Debug|x64
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.DebugAS|x64.ActiveCfg = Debug|x64
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.DebugAS|x64.Build.0 = Debug|x64
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release|Win32.ActiveCfg = Release|Win32
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release|Win32.Build.0 = Release|Win32
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release|x64.ActiveCfg = Release|x64
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release|x64.Build.0 = Release|x64
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.ReleaseAD|Win32.ActiveCfg = Release|x64
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.ReleaseAD|x64.ActiveCfg = Release|x64
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.ReleaseAD|x64.Build.0 = Release|x64
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.ReleaseAS|Win32.ActiveCfg = Release|x64
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.ReleaseAS|x64.ActiveCfg = Release|x64
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.ReleaseAS|x64.Build.0 = Release|x64
{B96F612A-C91D-43B3-A4C3-D4294817EC6C}.Debug|Win32.ActiveCfg = Debug|Win32
{B96F612A-C91D-43B3-A4C3-D4294817EC6C}.Debug|Win32.Build.0 = Debug|Win32
{B96F612A-C91D-43B3-A4C3-D4294817EC6C}.Debug|x64.ActiveCfg = Debug|Win32
{B96F612A-C91D-43B3-A4C3-D4294817EC6C}.DebugAD|Win32.ActiveCfg = Debug|Win32
{B96F612A-C91D-43B3-A4C3-D4294817EC6C}.DebugAD|Win32.Build.0 = Debug|Win32
{B96F612A-C91D-43B3-A4C3-D4294817EC6C}.DebugAD|x64.ActiveCfg = Debug|Win32
{B96F612A-C91D-43B3-A4C3-D4294817EC6C}.DebugAS|Win32.ActiveCfg = Debug|Win32
{B96F612A-C91D-43B3-A4C3-D4294817EC6C}.DebugAS|Win32.Build.0 = Debug|Win32
{B96F612A-C91D-43B3-A4C3-D4294817EC6C}.DebugAS|x64.ActiveCfg = Debug|Win32
{B96F612A-C91D-43B3-A4C3-D4294817EC6C}.Release|Win32.ActiveCfg = Release|Win32
{B96F612A-C91D-43B3-A4C3-D4294817EC6C}.Release|Win32.Build.0 = Release|Win32
{B96F612A-C91D-43B3-A4C3-D4294817EC6C}.Release|x64.ActiveCfg = Release|Win32
{B96F612A-C91D-43B3-A4C3-D4294817EC6C}.ReleaseAD|Win32.ActiveCfg = Release|Win32
{B96F612A-C91D-43B3-A4C3-D4294817EC6C}.ReleaseAD|Win32.Build.0 = Release|Win32
{B96F612A-C91D-43B3-A4C3-D4294817EC6C}.ReleaseAD|x64.ActiveCfg = Release|Win32
{B96F612A-C91D-43B3-A4C3-D4294817EC6C}.ReleaseAS|Win32.ActiveCfg = Release|Win32
{B96F612A-C91D-43B3-A4C3-D4294817EC6C}.ReleaseAS|Win32.Build.0 = Release|Win32
{B96F612A-C91D-43B3-A4C3-D4294817EC6C}.ReleaseAS|x64.ActiveCfg = Release|Win32
{78424708-1F6E-4D4B-920C-FB6D26847055}.Debug|Win32.ActiveCfg = DebugAD|Win32
{78424708-1F6E-4D4B-920C-FB6D26847055}.Debug|Win32.Build.0 = DebugAD|Win32
{78424708-1F6E-4D4B-920C-FB6D26847055}.Debug|x64.ActiveCfg = DebugAS|x64
{78424708-1F6E-4D4B-920C-FB6D26847055}.Debug|x64.Build.0 = DebugAS|x64
{78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAD|Win32.ActiveCfg = DebugAD|Win32
{78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAD|Win32.Build.0 = DebugAD|Win32
{78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAD|x64.ActiveCfg = DebugAD|x64
{78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAD|x64.Build.0 = DebugAD|x64
{78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAS|Win32.ActiveCfg = DebugAS|Win32
{78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAS|Win32.Build.0 = DebugAS|Win32
{78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAS|x64.ActiveCfg = DebugAS|x64
{78424708-1F6E-4D4B-920C-FB6D26847055}.DebugAS|x64.Build.0 = DebugAS|x64
{78424708-1F6E-4D4B-920C-FB6D26847055}.Release|Win32.ActiveCfg = ReleaseAD|Win32
{78424708-1F6E-4D4B-920C-FB6D26847055}.Release|Win32.Build.0 = ReleaseAD|Win32
{78424708-1F6E-4D4B-920C-FB6D26847055}.Release|x64.ActiveCfg = ReleaseAS|x64
{78424708-1F6E-4D4B-920C-FB6D26847055}.Release|x64.Build.0 = ReleaseAS|x64
{78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAD|Win32.ActiveCfg = ReleaseAD|Win32
{78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAD|Win32.Build.0 = ReleaseAD|Win32
{78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAD|x64.ActiveCfg = ReleaseAD|x64
{78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAD|x64.Build.0 = ReleaseAD|x64
{78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAS|Win32.ActiveCfg = ReleaseAS|Win32
{78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAS|Win32.Build.0 = ReleaseAS|Win32
{78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAS|x64.ActiveCfg = ReleaseAS|x64
{78424708-1F6E-4D4B-920C-FB6D26847055}.ReleaseAS|x64.Build.0 = ReleaseAS|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View file

@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vmapExtractor3", "VC90\vmapExtractor3.vcproj", "{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vmapExtractor", "VC90\vmapExtractor.vcproj", "{D4624B20-AC1E-4EE9-8C9C-0FB65EEE3393}"
ProjectSection(ProjectDependencies) = postProject
{B96F612A-C91D-43B3-A4C3-D4294817EC6C} = {B96F612A-C91D-43B3-A4C3-D4294817EC6C}
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}

View file

@ -1,46 +0,0 @@
@echo off
cls
echo.
echo Welcome to the vmaps extractor and assembler
echo.
echo You need 2GB of free space in disk, CTRL+C to stop process
echo Hit Enter to start . . .
pause>nul
cls
echo.
echo.
echo.
IF EXIST buildings\dir (ECHO The buildings folder already exist do you want to delete it?
echo If YES hit Enter to continue if no CLOSE the program now! . . .
pause>nul
DEL /S /Q buildings)
vmapExtractor4.exe
cls
echo.
echo.
echo.
IF NOT %ERRORLEVEL% LEQ 1 (echo The vmap extract tool finalized with errors.
echo Hit Enter to continue . . .
pause>nul)
cls
echo.
echo.
echo.
echo Vmaps extracted check log.txt for errors, now it's time to assemble the vmaps press any key to continue . . .
pause>nul
md vmaps
vmap_assembler.exe buildings vmaps
cls
echo.
echo.
echo.
IF NOT %ERRORLEVEL% LEQ 1 (echo The vmap assembler tool finalized with errors.
echo Hit Enter to continue . . .
pause>nul)
cls
echo.
echo.
echo.
echo Process done! copy vmaps folder to the MaNGOS main directory
echo Press any key to exit . . .
pause>nul

View file

@ -1,230 +0,0 @@
#ifndef VEC3D_H
#define VEC3D_H
#include <iostream>
#include <cmath>
class Vec3D
{
public:
float x,y,z;
Vec3D(float x0 = 0.0f, float y0 = 0.0f, float z0 = 0.0f) : x(x0), y(y0), z(z0) {}
Vec3D(const Vec3D& v) : x(v.x), y(v.y), z(v.z) {}
Vec3D& operator= (const Vec3D &v) {
x = v.x;
y = v.y;
z = v.z;
return *this;
}
Vec3D operator+ (const Vec3D &v) const
{
Vec3D r(x+v.x,y+v.y,z+v.z);
return r;
}
Vec3D operator- (const Vec3D &v) const
{
Vec3D r(x-v.x,y-v.y,z-v.z);
return r;
}
float operator* (const Vec3D &v) const
{
return x*v.x + y*v.y + z*v.z;
}
Vec3D operator* (float d) const
{
Vec3D r(x*d,y*d,z*d);
return r;
}
friend Vec3D operator* (float d, const Vec3D& v)
{
return v * d;
}
Vec3D operator% (const Vec3D &v) const
{
Vec3D r(y*v.z-z*v.y, z*v.x-x*v.z, x*v.y-y*v.x);
return r;
}
Vec3D& operator+= (const Vec3D &v)
{
x += v.x;
y += v.y;
z += v.z;
return *this;
}
Vec3D& operator-= (const Vec3D &v)
{
x -= v.x;
y -= v.y;
z -= v.z;
return *this;
}
Vec3D& operator*= (float d)
{
x *= d;
y *= d;
z *= d;
return *this;
}
float lengthSquared() const
{
return x*x+y*y+z*z;
}
float length() const
{
return sqrt(x*x+y*y+z*z);
}
Vec3D& normalize()
{
this->operator*= (1.0f/length());
return *this;
}
Vec3D operator~ () const
{
Vec3D r(*this);
r.normalize();
return r;
}
friend std::istream& operator>>(std::istream& in, Vec3D& v)
{
in >> v.x >> v.y >> v.z;
return in;
}
friend std::ostream& operator<<(std::ostream& out, const Vec3D& v)
{
out << v.x << " " << v.y << " " << v.z;
return out;
}
operator float*()
{
return (float*)this;
}
};
class Vec2D
{
public:
float x,y;
Vec2D(float x0 = 0.0f, float y0 = 0.0f) : x(x0), y(y0) {}
Vec2D(const Vec2D& v) : x(v.x), y(v.y) {}
Vec2D& operator= (const Vec2D &v) {
x = v.x;
y = v.y;
return *this;
}
Vec2D operator+ (const Vec2D &v) const
{
Vec2D r(x+v.x,y+v.y);
return r;
}
Vec2D operator- (const Vec2D &v) const
{
Vec2D r(x-v.x,y-v.y);
return r;
}
float operator* (const Vec2D &v) const
{
return x*v.x + y*v.y;
}
Vec2D operator* (float d) const
{
Vec2D r(x*d,y*d);
return r;
}
friend Vec2D operator* (float d, const Vec2D& v)
{
return v * d;
}
Vec2D& operator+= (const Vec2D &v)
{
x += v.x;
y += v.y;
return *this;
}
Vec2D& operator-= (const Vec2D &v)
{
x -= v.x;
y -= v.y;
return *this;
}
Vec2D& operator*= (float d)
{
x *= d;
y *= d;
return *this;
}
float lengthSquared() const
{
return x*x+y*y;
}
float length() const
{
return sqrt(x*x+y*y);
}
Vec2D& normalize()
{
this->operator*= (1.0f/length());
return *this;
}
Vec2D operator~ () const
{
Vec2D r(*this);
r.normalize();
return r;
}
friend std::istream& operator>>(std::istream& in, Vec2D& v)
{
in >> v.x >> v.y;
return in;
}
operator float*()
{
return (float*)this;
}
};
inline void rotate(float x0, float y0, float *x, float *y, float angle)
{
float xa = *x - x0, ya = *y - y0;
*x = xa*cosf(angle) - ya*sinf(angle) + x0;
*y = xa*sinf(angle) + ya*cosf(angle) + y0;
}
#endif

View file

@ -1,29 +0,0 @@
#ifndef WDTFILE_H
#define WDTFILE_H
#include "mpqfile.h"
#include "wmo.h"
#include <string>
#include "stdlib.h"
class ADTFile;
class WDTFile
{
public:
WDTFile(char* file_name, char* file_name1);
~WDTFile(void);
bool init(char *map_id, unsigned int mapID);
string* gWmoInstansName;
int gnWMO, nMaps;
ADTFile* GetMap(int x, int z);
private:
MPQFile WDT;
bool maps[64][64];
string filename;
};
#endif

View file

@ -1,136 +0,0 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef WMO_H
#define WMO_H
#define TILESIZE (533.33333f)
#define CHUNKSIZE ((TILESIZE) / 16.0f)
#include <string>
#include <set>
#include "vec3d.h"
#include "mpqfile.h"
// MOPY flags
#define WMO_MATERIAL_NOCAMCOLLIDE 0x01
#define WMO_MATERIAL_DETAIL 0x02
#define WMO_MATERIAL_NO_COLLISION 0x04
#define WMO_MATERIAL_HINT 0x08
#define WMO_MATERIAL_RENDER 0x10
#define WMO_MATERIAL_COLLIDE_HIT 0x20
#define WMO_MATERIAL_WALL_SURFACE 0x40
class WMOInstance;
class WMOManager;
class MPQFile;
/* for whatever reason a certain company just can't stick to one coordinate system... */
static inline Vec3D fixCoords(const Vec3D &v){ return Vec3D(v.z, v.x, v.y); }
class WMORoot
{
public:
uint32 nTextures, nGroups, nP, nLights, nModels, nDoodads, nDoodadSets, RootWMOID, liquidType;
unsigned int col;
float bbcorn1[3];
float bbcorn2[3];
WMORoot(std::string &filename);
~WMORoot();
bool open();
bool ConvertToVMAPRootWmo(FILE *output);
private:
std::string filename;
char outfilename;
};
struct WMOLiquidHeader
{
int xverts, yverts, xtiles, ytiles;
float pos_x;
float pos_y;
float pos_z;
short type;
};
struct WMOLiquidVert
{
uint16 unk1;
uint16 unk2;
float height;
};
class WMOGroup
{
public:
// MOGP
int groupName, descGroupName, mogpFlags;
float bbcorn1[3];
float bbcorn2[3];
uint16 moprIdx;
uint16 moprNItems;
uint16 nBatchA;
uint16 nBatchB;
uint32 nBatchC, fogIdx, liquidType, groupWMOID;
int mopy_size,moba_size;
int LiquEx_size;
unsigned int nVertices; // number when loaded
int nTriangles; // number when loaded
char *MOPY;
uint16 *MOVI;
uint16 *MoviEx;
float *MOVT;
uint16 *MOBA;
int *MobaEx;
WMOLiquidHeader *hlq;
WMOLiquidVert *LiquEx;
char *LiquBytes;
uint32 liquflags;
WMOGroup(std::string &filename);
~WMOGroup();
bool open();
int ConvertToVMAPGroupWmo(FILE *output, WMORoot *rootWMO, bool pPreciseVectorData);
private:
std::string filename;
char outfilename;
};
class WMOInstance
{
static std::set<int> ids;
public:
std::string MapName;
int currx;
int curry;
WMOGroup *wmo;
Vec3D pos;
Vec3D pos2, pos3, rot;
uint32 indx,id, d2, d3;
int doodadset;
WMOInstance(MPQFile &f,const char* WmoInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE *pDirfile);
static void reset();
};
#endif

View file

@ -1,5 +1,5 @@
#
# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
#
# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
#
# Copyright (C) 2005-2011 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
#
# Copyright (C) 2005-2011 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
#
# Copyright (C) 2005-2011 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
#
# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
#
# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
#
# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
#
# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
#
# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View file

@ -2,7 +2,7 @@
## Script processing
-- --------------------------
Copyright (C) 2010-2012 MaNGOS <http://getmangos.com/>
This file is part of the Continued-MaNGOS Project
-- --------------------------
## id

View file

@ -1,6 +1,6 @@
= MaNGOS -- README =
Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
This file is part of the Continued-MaNGOS Project
See the COPYING file for copying conditions.

View file

@ -1,6 +1,6 @@
= MaNGOS -- README =
Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
This file is part of the Continued-MaNGOS Project
See the COPYING file for copying conditions.

View file

@ -1,5 +1,5 @@
#
# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
#
# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
#
# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://www.mangosproject.org/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
#
# Copyright (C) 2005-2012 MaNGOS project <http://getmangos.com/>
# This file is part of the Continued-MaNGOS Project
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* This file is part of the Continued-MaNGOS Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

Some files were not shown because too many files have changed in this diff Show more