[Core/Maps] Activate creatures and objects during opening cinematics

As well as other flyby cameras (like sunwell etc)

Requires re-running map extractor to extract camera m2 files from data
files. These are very small.
This commit is contained in:
r00ty-tc committed 2016-05-18 21:31:07 +01:00
1 parent aec309a533
commit 527654b512
18 files changed
+859 -12

No files matched your search

+90 -5
View File
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <deque>
#include <list>
#include <vector>
#include <cstdlib>
#include <cstring>
@@ -75,11 +76,12 @@ char input_path[128] = ".";
enum Extract
{
EXTRACT_MAP = 1,
EXTRACT_DBC = 2
EXTRACT_DBC = 2,
EXTRACT_CAMERA = 4
};
// Select data for extract
int CONF_extract = EXTRACT_MAP | EXTRACT_DBC;
int CONF_extract = EXTRACT_MAP | EXTRACT_DBC | EXTRACT_CAMERA;
// This option allow limit minimum height to some value (Allow save some memory)
bool CONF_allow_height_limit = true;
@@ -169,7 +171,7 @@ void Usage(char const* prg)
"%s -[var] [value]\n"\
"-i set input path\n"\
"-o set output path\n"\
"-e extract only MAP(1)/DBC(2) - standard: both(3)\n"\
"-e extract only MAP(1)/DBC(2)/Camera(4) - standard: all(7)\n"\
"-f height stored as int (less map size but lost some accuracy) 1 by default\n"\
"-b target build (default %u)\n"\
"Example: %s -f 0 -i \"c:\\games\\game\"", prg, CONF_TargetBuild, prg);
@@ -182,7 +184,7 @@ void HandleArgs(int argc, char* arg[])
{
// i - input path
// o - output path
// e - extract only MAP(1)/DBC(2) - standard both(3)
// e - extract only MAP(1)/DBC(2)/Camera(4) - standard: all(7)
// f - use float to int conversion
// h - limit minimum height
// b - target client build
@@ -213,7 +215,7 @@ void HandleArgs(int argc, char* arg[])
if (c + 1 < argc) // all ok
{
CONF_extract = atoi(arg[c++ + 1]);
if (!(CONF_extract > 0 && CONF_extract < 4))
if (!(CONF_extract > 0 && CONF_extract < 8))
Usage(arg[0]);
}
else
@@ -1130,6 +1132,73 @@ void ExtractDB2Files(int l, bool basicLocale)
printf("Extracted %u DB2 files\n\n", count);
}
void ExtractCameraFiles(int locale, bool basicLocale)
{
printf("Extracting camera files...\n");
HANDLE dbcFile;
if (!SFileOpenFileEx(LocaleMpq, "DBFilesClient\\CinematicCamera.dbc", SFILE_OPEN_PATCHED_FILE, &dbcFile))
{
printf("Fatal error: Cannot find Map.dbc in archive!\n");
exit(1);
}
DBCFile camdbc(dbcFile);
if (!camdbc.open())
{
printf("Unable to open CinematicCamera.dbc. Camera extract aborted.\n");
return;
}
// get camera file list from DBC
std::vector<std::string> camerafiles;
size_t cam_count = camdbc.getRecordCount();
for (size_t i = 0; i < cam_count; ++i)
{
std::string camFile(camdbc.getRecord(i).getString(1));
size_t loc = camFile.find(".mdx");
if (loc != std::string::npos)
camFile.replace(loc, 4, ".m2");
camerafiles.push_back(std::string(camFile));
}
SFileCloseFile(dbcFile);
std::string path = output_path;
path += "/Cameras/";
CreateDir(path);
if (!basicLocale)
{
path += Locales[locale];
path += "/";
CreateDir(path);
}
// extract M2s
uint32 count = 0;
for (std::string thisFile : camerafiles)
{
std::string filename = path;
HANDLE dbcFile = NULL;
filename += (thisFile.c_str() + strlen("Cameras\\"));
if (FileExists(filename.c_str()))
continue;
if (!SFileOpenFileEx(WorldMpq, thisFile.c_str(), SFILE_OPEN_PATCHED_FILE, &dbcFile))
{
printf("Unable to open file %s in the archive\n", thisFile.c_str());
continue;
}
if (ExtractFile(dbcFile, filename.c_str()))
++count;
SFileCloseFile(dbcFile);
}
printf("Extracted %u camera files\n", count);
}
bool LoadLocaleMPQFile(int locale)
{
TCHAR buff[512];
@@ -1312,6 +1381,22 @@ int main(int argc, char * arg[])
return 0;
}
if (CONF_extract & EXTRACT_CAMERA)
{
printf("Using locale: %s\n", Locales[FirstLocale]);
// Open MPQs
LoadLocaleMPQFile(FirstLocale);
LoadCommonMPQFiles(build);
// Extract cameras
ExtractCameraFiles(FirstLocale, true);
// Close MPQs
SFileCloseArchive(WorldMpq);
SFileCloseArchive(LocaleMpq);
}
if (CONF_extract & EXTRACT_MAP)
{
printf("Using locale: %s\n", Locales[FirstLocale]);