AlexVinS 10 年之前
父節點
當前提交
3bf9696b13
共有 1 個文件被更改,包括 13 次插入9 次删除
  1. 13 9
      lib/mapping/MapFormatJson.cpp

+ 13 - 9
lib/mapping/MapFormatJson.cpp

@@ -15,6 +15,8 @@
 #include "../filesystem/COutputStream.h"
 #include "CMap.h"
 #include "../CModHandler.h"
+#include "../CHeroHandler.h"
+#include "../CTownHandler.h"
 #include "../VCMI_Lib.h"
 #include "../mapObjects/ObjectTemplate.h"
 #include "../mapObjects/CObjectHandler.h"
@@ -116,14 +118,6 @@ namespace TerrainDetail
 	};
 }
 
-namespace MapHeaderDetail
-{
-	static const std::array<std::string, PlayerColor::PLAYER_LIMIT_I>  playerColorNames =
-	{
-		"red", "blue", "tan", "green", "orange", "purple", "teal", "pink"
-	};
-}
-
 static std::string tailString(const std::string & input, char separator)
 {
 	std::string ret;
@@ -413,7 +407,7 @@ void CMapLoaderJson::readTeams(const JsonNode& input)
 		{
 			for(const JsonNode & playerData : srcVector[team].Vector())
 			{
-				PlayerColor player = PlayerColor(vstd::find_pos(MapHeaderDetail::playerColorNames, playerData.String()));
+				PlayerColor player = PlayerColor(vstd::find_pos(GameConstants::PLAYER_COLOR_NAMES, playerData.String()));
 				if(player.isValidPlayer())
 				{
 					if(map->players[player.getNum()].canAnyonePlay())
@@ -604,6 +598,16 @@ void CMapLoaderJson::MapObjectLoader::construct()
 void CMapLoaderJson::MapObjectLoader::configure()
 {
 	instance->readJson(configuration, false);
+
+	if(instance->ID == Obj::TOWN)
+	{
+		owner->map->towns.push_back(static_cast<CGTownInstance *>(instance));
+	}
+	if(instance->ID == Obj::HERO)
+	{
+		logGlobal->debugStream() << "Hero: " << VLC->heroh->heroes[instance->subID]->name << " at " << instance->pos;
+		owner->map->heroesOnMap.push_back(static_cast<CGHeroInstance*>(instance));
+	}
 }
 
 void CMapLoaderJson::readObjects()