Core/Startup: Write current and expected maps version when there's a version mismatch

This commit is contained in:
Nay
2013-02-19 01:16:24 +00:00
parent 037c912bb5
commit 03f97f75ec
3 changed files with 30 additions and 25 deletions

View File

@@ -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;
}

View File

@@ -58,8 +58,15 @@ struct ScriptAction
{
uint64 sourceGUID;
uint64 targetGUID;
uint64 ownerGUID; // owner of source if source is item
ScriptInfo const* script; // pointer to static script data
uint64 ownerGUID; ///> owner of source if source is item
ScriptInfo const* script; ///> pointer to static script data
};
/// Represents a map magic value of 4 bytes (used in versions)
union u_map_magic
{
char asChar[4]; ///> Non-null terminated string
uint32 asUInt; ///> uint32 representation
};
// ******************************************
@@ -67,9 +74,9 @@ struct ScriptAction
// ******************************************
struct map_fileheader
{
uint32 mapMagic;
uint32 versionMagic;
uint32 buildMagic;
u_map_magic mapMagic;
u_map_magic versionMagic;
u_map_magic buildMagic;
uint32 areaMapOffset;
uint32 areaMapSize;
uint32 heightMapOffset;

View File

@@ -653,7 +653,7 @@ public:
handler->PSendSysMessage(LANG_NPCINFO_DUNGEON_ID, target->GetInstanceId());
handler->PSendSysMessage(LANG_NPCINFO_PHASEMASK, target->GetPhaseMask());
handler->PSendSysMessage(LANG_NPCINFO_ARMOR, target->GetArmor());
handler->PSendSysMessage(LANG_NPCINFO_POSITION, float(target->GetPositionX()), float(target->GetPositionY()), float(target->GetPositionZ()));
handler->PSendSysMessage(LANG_NPCINFO_POSITION, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ());
handler->PSendSysMessage(LANG_NPCINFO_AIINFO, target->GetAIName().c_str(), target->GetScriptName().c_str());
for (uint8 i = 0; i < NPCFLAG_COUNT; i++)