Core/Startup: Write current and expected maps version when there's a version mismatch
This commit is contained in:
1 parent
037c912bb5
commit
03f97f75ec
3 files changed
+30
-25
No files matched your search
@@ -36,12 +36,6 @@
|
||||
#include "Vehicle.h"
|
||||
#include "VMapFactory.h"
|
||||
|
||||
union u_map_magic
|
||||
{
|
||||
char asChar[4];
|
||||
uint32 asUInt;
|
||||
};
|
||||
|
||||
u_map_magic MapMagic = { {'M','A','P','S'} };
|
||||
u_map_magic MapVersionMagic = { {'v','1','.','3'} };
|
||||
u_map_magic MapAreaMagic = { {'A','R','E','A'} };
|
||||
@@ -77,28 +71,30 @@ Map::~Map()
|
||||
|
||||
bool Map::ExistMap(uint32 mapid, int gx, int gy)
|
||||
{
|
||||
int len = sWorld->GetDataPath().length()+strlen("maps/%03u%02u%02u.map")+1;
|
||||
char* tmp = new char[len];
|
||||
snprintf(tmp, len, (char *)(sWorld->GetDataPath()+"maps/%03u%02u%02u.map").c_str(), mapid, gx, gy);
|
||||
int len = sWorld->GetDataPath().length() + strlen("maps/%03u%02u%02u.map") + 1;
|
||||
char* fileName = new char[len];
|
||||
snprintf(fileName, len, (char *)(sWorld->GetDataPath() + "maps/%03u%02u%02u.map").c_str(), mapid, gx, gy);
|
||||
|
||||
bool ret = false;
|
||||
FILE* pf=fopen(tmp, "rb");
|
||||
FILE* pf = fopen(fileName, "rb");
|
||||
|
||||
if (!pf)
|
||||
sLog->outError(LOG_FILTER_MAPS, "Map file '%s': does not exist!", tmp);
|
||||
sLog->outError(LOG_FILTER_MAPS, "Map file '%s': does not exist!", fileName);
|
||||
else
|
||||
{
|
||||
map_fileheader header;
|
||||
if (fread(&header, sizeof(header), 1, pf) == 1)
|
||||
{
|
||||
if (header.mapMagic != MapMagic.asUInt || header.versionMagic != MapVersionMagic.asUInt)
|
||||
sLog->outError(LOG_FILTER_MAPS, "Map file '%s' is from an incompatible clientversion. Please recreate using the mapextractor.", tmp);
|
||||
if (header.mapMagic.asUInt != MapMagic.asUInt || header.versionMagic.asUInt != MapVersionMagic.asUInt)
|
||||
sLog->outError(LOG_FILTER_MAPS, "Map file '%s' is from an incompatible map version (%.*s %.*s), %.*s %.*s is expected. Please recreate using the mapextractor.",
|
||||
fileName, 4, header.mapMagic.asChar, 4, header.versionMagic.asChar, 4, MapMagic.asChar, 4, MapVersionMagic.asChar);
|
||||
else
|
||||
ret = true;
|
||||
}
|
||||
fclose(pf);
|
||||
}
|
||||
delete [] tmp;
|
||||
|
||||
delete[] fileName;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1102,23 +1098,23 @@ bool GridMap::loadData(char* filename)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (header.mapMagic == MapMagic.asUInt && header.versionMagic == MapVersionMagic.asUInt)
|
||||
if (header.mapMagic.asUInt == MapMagic.asUInt && header.versionMagic.asUInt == MapVersionMagic.asUInt)
|
||||
{
|
||||
// loadup area data
|
||||
// load up area data
|
||||
if (header.areaMapOffset && !loadAreaData(in, header.areaMapOffset, header.areaMapSize))
|
||||
{
|
||||
sLog->outError(LOG_FILTER_MAPS, "Error loading map area data\n");
|
||||
fclose(in);
|
||||
return false;
|
||||
}
|
||||
// loadup height data
|
||||
// load up height data
|
||||
if (header.heightMapOffset && !loadHeightData(in, header.heightMapOffset, header.heightMapSize))
|
||||
{
|
||||
sLog->outError(LOG_FILTER_MAPS, "Error loading map height data\n");
|
||||
fclose(in);
|
||||
return false;
|
||||
}
|
||||
// loadup liquid data
|
||||
// load up liquid data
|
||||
if (header.liquidMapOffset && !loadLiquidData(in, header.liquidMapOffset, header.liquidMapSize))
|
||||
{
|
||||
sLog->outError(LOG_FILTER_MAPS, "Error loading map liquids data\n");
|
||||
@@ -1128,7 +1124,9 @@ bool GridMap::loadData(char* filename)
|
||||
fclose(in);
|
||||
return true;
|
||||
}
|
||||
sLog->outError(LOG_FILTER_MAPS, "Map file '%s' is from an incompatible clientversion. Please recreate using the mapextractor.", filename);
|
||||
|
||||
sLog->outError(LOG_FILTER_MAPS, "Map file '%s' is from an incompatible map version (%.*s %.*s), %.*s %.*s is expected. Please recreate using the mapextractor.",
|
||||
filename, 4, header.mapMagic.asChar, 4, header.versionMagic.asChar, 4, MapMagic.asChar, 4, MapVersionMagic.asChar);
|
||||
fclose(in);
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user