Skip to content

Commit

Permalink
feat: ADded Maps Compatibility with another Cores
Browse files Browse the repository at this point in the history
  • Loading branch information
seobryn committed Jul 27, 2023
1 parent 526ccc8 commit 604f728
Show file tree
Hide file tree
Showing 3 changed files with 731 additions and 655 deletions.
16 changes: 8 additions & 8 deletions src/common/Collision/VMapDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@

#ifndef _VMAPDEFINITIONS_H
#define _VMAPDEFINITIONS_H
#include <cstring>
#include <cstdio>
#include <cstring>

#define LIQUID_TILE_SIZE (533.333f / 128.f)

namespace VMAP
{
const char VMAP_MAGIC[] = "VMAP_4.8";
const char RAW_VMAP_MAGIC[] = "VMAP048"; // used in extracted vmap files with raw data
const char GAMEOBJECT_MODELS[] = "GameObjectModels.dtree";
const char VMAP_MAGIC[] = "VMAP_4.4";
const char RAW_VMAP_MAGIC[] = "VMAP044"; // used in extracted vmap files with raw data
const char GAMEOBJECT_MODELS[] = "GameObjectModels.dtree";

// defined in TileAssembler.cpp currently...
bool readChunk(FILE* rf, char *dest, const char *compare, uint32 len);
}
// defined in TileAssembler.cpp currently...
bool readChunk(FILE *rf, char *dest, const char *compare, uint32 len);
} // namespace VMAP

// Set of helper macros for extractors (VMAP and MMAP)
#ifndef NO_CORE_FUNCS
Expand All @@ -40,7 +40,7 @@ namespace VMAP
#else
#define VMAP_ERROR_LOG(FILTER, ...) (void)sizeof(FILTER)
#define VMAP_DEBUG_LOG(FILTER, ...) (void)sizeof(FILTER)
#define VMAP_INFO_LOG(FILTER, ...) (void)sizeof(FILTER)
#define VMAP_INFO_LOG(FILTER, ...) (void)sizeof(FILTER)
#endif

#endif
16 changes: 8 additions & 8 deletions src/server/game/Maps/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
BOOST_1_74_FIBONACCI_HEAP_MSVC_COMPILE_FIX(RespawnListContainer::value_type)

u_map_magic MapMagic = { {'M','A','P','S'} };
uint32 MapVersionMagic = 10;
u_map_magic MapVersionMagic = { {'v','1','.','6'} };
u_map_magic MapAreaMagic = { {'A','R','E','A'} };
u_map_magic MapHeightMagic = { {'M','H','G','T'} };
u_map_magic MapLiquidMagic = { {'M','L','I','Q'} };
Expand Down Expand Up @@ -111,13 +111,13 @@ void Map::DiscoverGridMapFiles()
if (FILE* tileList = fopen(tileListName.c_str(), "rb"))
{
u_map_magic mapMagic;
uint32 versionMagic;
u_map_magic versionMagic;
uint32 build;
char tilesData[MAX_NUMBER_OF_GRIDS * MAX_NUMBER_OF_GRIDS];
if (fread(&mapMagic.asUInt, sizeof(u_map_magic), 1, tileList) == 1
&& mapMagic.asUInt == MapMagic.asUInt
&& fread(&versionMagic, sizeof(versionMagic), 1, tileList) == 1
&& versionMagic == MapVersionMagic
&& fread(&versionMagic.asUInt, sizeof(versionMagic.asUInt), 1, tileList) == 1
&& versionMagic.asUInt == MapVersionMagic.asUInt
&& fread(&build, sizeof(build), 1, tileList) == 1
&& fread(&tilesData[0], MAX_NUMBER_OF_GRIDS * MAX_NUMBER_OF_GRIDS, 1, tileList) == 1)
{
Expand Down Expand Up @@ -162,11 +162,11 @@ bool Map::ExistMap(uint32 mapid, int gx, int gy, bool log /*= true*/)
map_fileheader header;
if (fread(&header, sizeof(header), 1, file) == 1)
{
if (header.mapMagic.asUInt != MapMagic.asUInt || header.versionMagic != MapVersionMagic)
if (header.mapMagic.asUInt != MapMagic.asUInt || header.versionMagic.asUInt != MapVersionMagic.asUInt)
{
if (log)
LOG_ERROR("maps", "Map file '%s' is from an incompatible map version (%.*s v%u), %.*s v%u is expected. Please pull your source, recompile tools and recreate maps using the updated mapextractor, then replace your old map files with new files. If you still have problems search on forum for error FCE00018.",
fileName.c_str(), 4, header.mapMagic.asChar, header.versionMagic, 4, MapMagic.asChar, MapVersionMagic);
fileName.c_str(), 4, header.mapMagic.asChar, header.versionMagic.asUInt, 4, MapMagic.asChar, MapVersionMagic.asUInt);
}
else
ret = true;
Expand Down Expand Up @@ -1798,7 +1798,7 @@ GridMap::LoadResult GridMap::loadData(const char* filename)
return LoadResult::InvalidFile;
}

if (header.mapMagic.asUInt == MapMagic.asUInt && header.versionMagic == MapVersionMagic)
if (header.mapMagic.asUInt == MapMagic.asUInt && header.versionMagic.asUInt == MapVersionMagic.asUInt)
{
// load up area data
if (header.areaMapOffset && !loadAreaData(in, header.areaMapOffset, header.areaMapSize))
Expand Down Expand Up @@ -1833,7 +1833,7 @@ GridMap::LoadResult GridMap::loadData(const char* filename)
}

LOG_ERROR("maps", "Map file '%s' is from an incompatible map version (%.*s v%u), %.*s v%u is expected. Please pull your source, recompile tools and recreate maps using the updated mapextractor, then replace your old map files with new files. If you still have problems search on forum for error FCE00018.",
filename, 4, header.mapMagic.asChar, header.versionMagic, 4, MapMagic.asChar, MapVersionMagic);
filename, 4, header.mapMagic.asChar, header.versionMagic.asUInt, 4, MapMagic.asChar, MapVersionMagic.asUInt);
fclose(in);
return LoadResult::InvalidFile;
}
Expand Down
Loading

0 comments on commit 604f728

Please sign in to comment.