aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/Maps/Map.cpp36
-rw-r--r--src/server/game/Maps/Map.h17
-rw-r--r--src/server/scripts/Commands/cs_npc.cpp2
3 files changed, 30 insertions, 25 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index 7fe516a1eb4..3d6285a806c 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -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;
}
diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h
index c9686d36a42..6bf7edf3a2f 100644
--- a/src/server/game/Maps/Map.h
+++ b/src/server/game/Maps/Map.h
@@ -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;
diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp
index 818a17438bf..8dc466296fd 100644
--- a/src/server/scripts/Commands/cs_npc.cpp
+++ b/src/server/scripts/Commands/cs_npc.cpp
@@ -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++)