浏览代码

Fix issue 1877. Allow to buy heroes in ally towns

Also removed TODO because check already implemented in CGameHandler::hireHero
ArseniyShestakov 10 年之前
父节点
当前提交
0d83f6fedd
共有 1 个文件被更改,包括 3 次插入4 次删除
  1. 3 4
      server/NetPacksServer.cpp

+ 3 - 4
server/NetPacksServer.cpp

@@ -209,10 +209,9 @@ bool SetFormation::applyGh( CGameHandler *gh )
 bool HireHero::applyGh( CGameHandler *gh )
 {
 	const CGObjectInstance *obj = gh->getObj(tid);
-
-	if(obj->ID == Obj::TOWN)
-		ERROR_IF_NOT_OWNS(tid);
-	//TODO check for visiting hero
+	const CGTownInstance *town = dynamic_cast<const CGTownInstance *>(obj);
+	if(town && PlayerRelations::ENEMIES == gh->getPlayerRelations(obj->tempOwner, gh->getPlayerAt(c)))
+		COMPLAIN_AND_RETURN("Can't buy hero in enemy town!");
 
 	return gh->hireHero(obj, hid,player);
 }