void ExtractMMaps(std::set<uint32>& mapIds, uint32 threads)
{
    DBC* dbc = MPQHandler->GetDBC("Map");
    printf("Map.dbc contains %u rows.\n", dbc->Records.size());
    for (std::vector<Record*>::iterator itr = dbc->Records.begin(); itr != dbc->Records.end(); ++itr)
    {
        uint32 mapId = (*itr)->Values[0];

        // Skip this map if a list of specific maps was provided and this one is not contained in it.
        if (!mapIds.empty() && mapIds.find(mapId) == mapIds.end())
        {
            if (Constants::Debug)
                printf("Map %u will not be built.\n", mapId);
            continue;
        }

        std::string name = (*itr)->GetString(1);
        WDT wdt("World\\maps\\" + name + "\\" + name + ".wdt");
        if (!wdt.IsValid)
        {
            printf("Could not find WDT data for map %u (%s)\n", mapId, name.c_str());
            continue;
        }
        printf("Building %s MapId %u\n", name.c_str(), mapId);
        ContinentBuilder builder(name, mapId, &wdt, threads);
        builder.Build();
    }
}
Example #2
0
int main(int argc, char **argv)
{
   std::shared_ptr<MC::Watchdog> wdt(new MC::Watchdog(5));
   Worker w(wdt);
   int ret = -1;

   wdt->start();
   w.run();
}
Example #3
0
void ExtractAllMaps(std::set<uint32>& mapIds, uint32 threads, bool debug)
{
    DBC* dbc = MPQHandler->GetDBC("Map");
    for (std::vector<Record*>::iterator itr = dbc->Records.begin(); itr != dbc->Records.end(); ++itr)
    {
        uint32 mapId = (*itr)->Values[0];

        // Skip this map if a list of specific maps was provided and this one is not contained in it.
        if (!mapIds.empty() && mapIds.find(mapId) == mapIds.end())
            continue;

        std::string name = (*itr)->GetString(1);
        WDT wdt("World\\maps\\" + name + "\\" + name + ".wdt");
        if (!wdt.IsValid || wdt.IsGlobalModel)
            continue;
        printf("Building %s MapId %u\n", name.c_str(), mapId);
        ContinentBuilder builder(name, mapId, &wdt, threads);
        builder.Build(debug);
    }
}
Example #4
0
void ExtractMapsFromMpq(uint32 build)
{
    char mpq_filename[1024];
    char output_filename[1024];
    char mpq_map_name[1024];

    printf("Extracting maps...\n");

    LoadMapMPQFiles();

    uint32 map_count = ReadMapDBC();

    ReadAreaTableDBC();
    ReadLiquidTypeTableDBC();

    std::string path = ".";
    path += "/maps/";
    CreateDir(path);

    std::vector<std::string> not_found;

    printf("Convert map files\n");
    HANDLE actualMPQ = WorldMPQ;
    for(uint32 z = 0; z < map_count; ++z)
    {
        // Loadup map grid data
        sprintf(mpq_map_name, "World\\Maps\\%s\\%s.wdt", map_ids[z].name, map_ids[z].name);
        WDT_file wdt(mpq_map_name, actualMPQ);
        if (wdt.isEof())
        {
            if (actualMPQ == WorldMPQ)
            {
                z--;
                actualMPQ = ExpansionsMPQ[0];
                continue;
            }
            if (actualMPQ == ExpansionsMPQ[0])
            {
                z--;
                actualMPQ = ExpansionsMPQ[1];
                continue;
            }
            if (actualMPQ == ExpansionsMPQ[1])
            {
                z--;
                actualMPQ = ExpansionsMPQ[2];
                continue;
            }
            actualMPQ = WorldMPQ;
            not_found.push_back(map_ids[z].name);
            printf("Extract %s (%d/%d) -- not found\n", map_ids[z].name, z+1, map_count);
            continue;
        }
        if (actualMPQ == WorldMPQ)
            printf("Extract %s (%d/%d) -- World.MPQ\n", map_ids[z].name, z+1, map_count);
        if (actualMPQ == ExpansionsMPQ[0])
            printf("Extract %s (%d/%d) -- expansion1.MPQ\n", map_ids[z].name, z+1, map_count);
        if (actualMPQ == ExpansionsMPQ[1])
            printf("Extract %s (%d/%d) -- expansion2.MPQ\n", map_ids[z].name, z+1, map_count);
        if (actualMPQ == ExpansionsMPQ[2])
            printf("Extract %s (%d/%d) -- expansion3.MPQ\n", map_ids[z].name, z+1, map_count);
        actualMPQ = WorldMPQ;

        wdt.prepareLoadedData();

        for(uint32 y = 0; y < WDT_MAP_SIZE; ++y)
        {
            for(uint32 x = 0; x < WDT_MAP_SIZE; ++x)
            {
                if (!wdt.main->adt_list[y][x].exist)
                    continue;
                sprintf(mpq_filename, "World\\Maps\\%s\\%s_%u_%u.adt", map_ids[z].name, map_ids[z].name, x, y);
                sprintf(output_filename, "./maps/%03u%02u%02u.map", map_ids[z].id, y, x);
                ConvertADT(mpq_filename, output_filename, y, x, build, WorldMPQ);
            }
            // draw progress bar
            //printf("Processing........................%d%%\r", (100 * (y+1)) / WDT_MAP_SIZE);
        }
    }
    printf("\n");
    delete [] areas;
    delete [] map_ids;
    //printf("Map not extracted : %u\n", not_found.size());
    //for(int i = 0; i < not_found.size(); i++)
    //    printf("    %s\n", not_found[i].c_str());
}