| 
														
															@@ -47,18 +47,21 @@ void ApplyGhNetPackVisitor::visitGamePause(GamePause & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 void ApplyGhNetPackVisitor::visitEndTurn(EndTurn & pack) 
														 | 
														
														 | 
														
															 void ApplyGhNetPackVisitor::visitEndTurn(EndTurn & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	gh.throwIfWrongPlayer(&pack); 
														 | 
														
														 | 
														
															 	gh.throwIfWrongPlayer(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	result = gh.turnOrder->onPlayerEndsTurn(pack.player); 
														 | 
														
														 | 
														
															 	result = gh.turnOrder->onPlayerEndsTurn(pack.player); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 void ApplyGhNetPackVisitor::visitDismissHero(DismissHero & pack) 
														 | 
														
														 | 
														
															 void ApplyGhNetPackVisitor::visitDismissHero(DismissHero & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.hid); 
														 | 
														
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.hid); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	result = gh.removeObject(gh.getObj(pack.hid), pack.player); 
														 | 
														
														 | 
														
															 	result = gh.removeObject(gh.getObj(pack.hid), pack.player); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 void ApplyGhNetPackVisitor::visitMoveHero(MoveHero & pack) 
														 | 
														
														 | 
														
															 void ApplyGhNetPackVisitor::visitMoveHero(MoveHero & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.hid); 
														 | 
														
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.hid); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	for (auto const & dest : pack.path) 
														 | 
														
														 | 
														
															 	for (auto const & dest : pack.path) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	{ 
														 | 
														
														 | 
														
															 	{ 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -75,6 +78,7 @@ void ApplyGhNetPackVisitor::visitMoveHero(MoveHero & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 void ApplyGhNetPackVisitor::visitCastleTeleportHero(CastleTeleportHero & pack) 
														 | 
														
														 | 
														
															 void ApplyGhNetPackVisitor::visitCastleTeleportHero(CastleTeleportHero & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.hid); 
														 | 
														
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.hid); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	result = gh.teleportHero(pack.hid, pack.dest, pack.source, pack.player); 
														 | 
														
														 | 
														
															 	result = gh.teleportHero(pack.hid, pack.dest, pack.source, pack.player); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -82,48 +86,63 @@ void ApplyGhNetPackVisitor::visitCastleTeleportHero(CastleTeleportHero & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 void ApplyGhNetPackVisitor::visitArrangeStacks(ArrangeStacks & pack) 
														 | 
														
														 | 
														
															 void ApplyGhNetPackVisitor::visitArrangeStacks(ArrangeStacks & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	gh.throwIfWrongPlayer(&pack); 
														 | 
														
														 | 
														
															 	gh.throwIfWrongPlayer(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	result = gh.arrangeStacks(pack.id1, pack.id2, pack.what, pack.p1, pack.p2, pack.val, pack.player); 
														 | 
														
														 | 
														
															 	result = gh.arrangeStacks(pack.id1, pack.id2, pack.what, pack.p1, pack.p2, pack.val, pack.player); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 void ApplyGhNetPackVisitor::visitBulkMoveArmy(BulkMoveArmy & pack) 
														 | 
														
														 | 
														
															 void ApplyGhNetPackVisitor::visitBulkMoveArmy(BulkMoveArmy & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.srcArmy); 
														 | 
														
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.srcArmy); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	result = gh.bulkMoveArmy(pack.srcArmy, pack.destArmy, pack.srcSlot); 
														 | 
														
														 | 
														
															 	result = gh.bulkMoveArmy(pack.srcArmy, pack.destArmy, pack.srcSlot); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 void ApplyGhNetPackVisitor::visitBulkSplitStack(BulkSplitStack & pack) 
														 | 
														
														 | 
														
															 void ApplyGhNetPackVisitor::visitBulkSplitStack(BulkSplitStack & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	gh.throwIfWrongPlayer(&pack); 
														 | 
														
														 | 
														
															 	gh.throwIfWrongPlayer(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	result = gh.bulkSplitStack(pack.src, pack.srcOwner, pack.amount); 
														 | 
														
														 | 
														
															 	result = gh.bulkSplitStack(pack.src, pack.srcOwner, pack.amount); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 void ApplyGhNetPackVisitor::visitBulkMergeStacks(BulkMergeStacks & pack) 
														 | 
														
														 | 
														
															 void ApplyGhNetPackVisitor::visitBulkMergeStacks(BulkMergeStacks & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	gh.throwIfWrongPlayer(&pack); 
														 | 
														
														 | 
														
															 	gh.throwIfWrongPlayer(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	result = gh.bulkMergeStacks(pack.src, pack.srcOwner); 
														 | 
														
														 | 
														
															 	result = gh.bulkMergeStacks(pack.src, pack.srcOwner); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 void ApplyGhNetPackVisitor::visitBulkSmartSplitStack(BulkSmartSplitStack & pack) 
														 | 
														
														 | 
														
															 void ApplyGhNetPackVisitor::visitBulkSmartSplitStack(BulkSmartSplitStack & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	gh.throwIfWrongPlayer(&pack); 
														 | 
														
														 | 
														
															 	gh.throwIfWrongPlayer(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	result = gh.bulkSmartSplitStack(pack.src, pack.srcOwner); 
														 | 
														
														 | 
														
															 	result = gh.bulkSmartSplitStack(pack.src, pack.srcOwner); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 void ApplyGhNetPackVisitor::visitDisbandCreature(DisbandCreature & pack) 
														 | 
														
														 | 
														
															 void ApplyGhNetPackVisitor::visitDisbandCreature(DisbandCreature & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.id); 
														 | 
														
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.id); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	result = gh.disbandCreature(pack.id, pack.pos); 
														 | 
														
														 | 
														
															 	result = gh.disbandCreature(pack.id, pack.pos); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 void ApplyGhNetPackVisitor::visitBuildStructure(BuildStructure & pack) 
														 | 
														
														 | 
														
															 void ApplyGhNetPackVisitor::visitBuildStructure(BuildStructure & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.tid); 
														 | 
														
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.tid); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	result = gh.buildStructure(pack.tid, pack.bid); 
														 | 
														
														 | 
														
															 	result = gh.buildStructure(pack.tid, pack.bid); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 void ApplyGhNetPackVisitor::visitRecruitCreatures(RecruitCreatures & pack) 
														 | 
														
														 | 
														
															 void ApplyGhNetPackVisitor::visitRecruitCreatures(RecruitCreatures & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	gh.throwIfWrongPlayer(&pack); 
														 | 
														
														 | 
														
															 	gh.throwIfWrongPlayer(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	// ownership checks are inside recruitCreatures 
														 | 
														
														 | 
														
															 	// ownership checks are inside recruitCreatures 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	result = gh.recruitCreatures(pack.tid, pack.dst, pack.crid, pack.amount, pack.level, pack.player); 
														 | 
														
														 | 
														
															 	result = gh.recruitCreatures(pack.tid, pack.dst, pack.crid, pack.amount, pack.level, pack.player); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -131,6 +150,8 @@ void ApplyGhNetPackVisitor::visitRecruitCreatures(RecruitCreatures & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 void ApplyGhNetPackVisitor::visitUpgradeCreature(UpgradeCreature & pack) 
														 | 
														
														 | 
														
															 void ApplyGhNetPackVisitor::visitUpgradeCreature(UpgradeCreature & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.id); 
														 | 
														
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.id); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	result = gh.upgradeCreature(pack.id, pack.pos, pack.cid); 
														 | 
														
														 | 
														
															 	result = gh.upgradeCreature(pack.id, pack.pos, pack.cid); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -139,6 +160,8 @@ void ApplyGhNetPackVisitor::visitGarrisonHeroSwap(GarrisonHeroSwap & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	const CGTownInstance * town = gh.getTown(pack.tid); 
														 | 
														
														 | 
														
															 	const CGTownInstance * town = gh.getTown(pack.tid); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	if(!gh.isPlayerOwns(&pack, pack.tid) && !(town->garrisonHero && gh.isPlayerOwns(&pack, town->garrisonHero->id))) 
														 | 
														
														 | 
														
															 	if(!gh.isPlayerOwns(&pack, pack.tid) && !(town->garrisonHero && gh.isPlayerOwns(&pack, town->garrisonHero->id))) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		gh.throwNotAllowedAction(&pack); //neither town nor garrisoned hero (if present) is ours 
														 | 
														
														 | 
														
															 		gh.throwNotAllowedAction(&pack); //neither town nor garrisoned hero (if present) is ours 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	result = gh.garrisonSwap(pack.tid); 
														 | 
														
														 | 
														
															 	result = gh.garrisonSwap(pack.tid); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -146,6 +169,8 @@ void ApplyGhNetPackVisitor::visitExchangeArtifacts(ExchangeArtifacts & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	if(gh.getHero(pack.src.artHolder)) 
														 | 
														
														 | 
														
															 	if(gh.getHero(pack.src.artHolder)) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		gh.throwIfWrongPlayer(&pack, gh.getOwner(pack.src.artHolder)); //second hero can be ally 
														 | 
														
														 | 
														
															 		gh.throwIfWrongPlayer(&pack, gh.getOwner(pack.src.artHolder)); //second hero can be ally 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	result = gh.moveArtifact(pack.player, pack.src, pack.dst); 
														 | 
														
														 | 
														
															 	result = gh.moveArtifact(pack.player, pack.src, pack.dst); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -155,11 +180,15 @@ void ApplyGhNetPackVisitor::visitBulkExchangeArtifacts(BulkExchangeArtifacts & p 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		gh.throwIfWrongOwner(&pack, pack.srcHero); 
														 | 
														
														 | 
														
															 		gh.throwIfWrongOwner(&pack, pack.srcHero); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	if(pack.swap) 
														 | 
														
														 | 
														
															 	if(pack.swap) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		gh.throwIfWrongOwner(&pack, pack.dstHero); 
														 | 
														
														 | 
														
															 		gh.throwIfWrongOwner(&pack, pack.dstHero); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	result = gh.bulkMoveArtifacts(pack.player, pack.srcHero, pack.dstHero, pack.swap, pack.equipped, pack.backpack); 
														 | 
														
														 | 
														
															 	result = gh.bulkMoveArtifacts(pack.player, pack.srcHero, pack.dstHero, pack.swap, pack.equipped, pack.backpack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 void ApplyGhNetPackVisitor::visitManageBackpackArtifacts(ManageBackpackArtifacts & pack) 
														 | 
														
														 | 
														
															 void ApplyGhNetPackVisitor::visitManageBackpackArtifacts(ManageBackpackArtifacts & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	if(gh.getPlayerRelations(pack.player, gh.getOwner(pack.artHolder)) != PlayerRelations::ENEMIES) 
														 | 
														
														 | 
														
															 	if(gh.getPlayerRelations(pack.player, gh.getOwner(pack.artHolder)) != PlayerRelations::ENEMIES) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	{ 
														 | 
														
														 | 
														
															 	{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		if(pack.cmd == ManageBackpackArtifacts::ManageCmd::SCROLL_LEFT) 
														 | 
														
														 | 
														
															 		if(pack.cmd == ManageBackpackArtifacts::ManageCmd::SCROLL_LEFT) 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -191,18 +220,21 @@ void ApplyGhNetPackVisitor::visitManageEquippedArtifacts(ManageEquippedArtifacts 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 void ApplyGhNetPackVisitor::visitAssembleArtifacts(AssembleArtifacts & pack) 
														 | 
														
														 | 
														
															 void ApplyGhNetPackVisitor::visitAssembleArtifacts(AssembleArtifacts & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.heroID); 
														 | 
														
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.heroID); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	// gh.throwIfPlayerNotActive(&pack); // Might happen when player captures artifacts in battle? 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	result = gh.assembleArtifacts(pack.heroID, pack.artifactSlot, pack.assemble, pack.assembleTo); 
														 | 
														
														 | 
														
															 	result = gh.assembleArtifacts(pack.heroID, pack.artifactSlot, pack.assemble, pack.assembleTo); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 void ApplyGhNetPackVisitor::visitEraseArtifactByClient(EraseArtifactByClient & pack) 
														 | 
														
														 | 
														
															 void ApplyGhNetPackVisitor::visitEraseArtifactByClient(EraseArtifactByClient & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	gh.throwIfWrongPlayer(&pack, gh.getOwner(pack.al.artHolder)); 
														 | 
														
														 | 
														
															 	gh.throwIfWrongPlayer(&pack, gh.getOwner(pack.al.artHolder)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	result = gh.eraseArtifactByClient(pack.al); 
														 | 
														
														 | 
														
															 	result = gh.eraseArtifactByClient(pack.al); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 void ApplyGhNetPackVisitor::visitBuyArtifact(BuyArtifact & pack) 
														 | 
														
														 | 
														
															 void ApplyGhNetPackVisitor::visitBuyArtifact(BuyArtifact & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.hid); 
														 | 
														
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.hid); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	result = gh.buyArtifact(pack.hid, pack.aid); 
														 | 
														
														 | 
														
															 	result = gh.buyArtifact(pack.hid, pack.aid); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -213,6 +245,7 @@ void ApplyGhNetPackVisitor::visitTradeOnMarketplace(TradeOnMarketplace & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	const auto * market = dynamic_cast<const IMarket*>(object); 
														 | 
														
														 | 
														
															 	const auto * market = dynamic_cast<const IMarket*>(object); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	gh.throwIfWrongPlayer(&pack); 
														 | 
														
														 | 
														
															 	gh.throwIfWrongPlayer(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	if(!object) 
														 | 
														
														 | 
														
															 	if(!object) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		gh.throwAndComplain(&pack, "Invalid market object"); 
														 | 
														
														 | 
														
															 		gh.throwAndComplain(&pack, "Invalid market object"); 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -317,12 +350,15 @@ void ApplyGhNetPackVisitor::visitTradeOnMarketplace(TradeOnMarketplace & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 void ApplyGhNetPackVisitor::visitSetFormation(SetFormation & pack) 
														 | 
														
														 | 
														
															 void ApplyGhNetPackVisitor::visitSetFormation(SetFormation & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.hid); 
														 | 
														
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.hid); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	result = gh.setFormation(pack.hid, pack.formation); 
														 | 
														
														 | 
														
															 	result = gh.setFormation(pack.hid, pack.formation); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 void ApplyGhNetPackVisitor::visitHireHero(HireHero & pack) 
														 | 
														
														 | 
														
															 void ApplyGhNetPackVisitor::visitHireHero(HireHero & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	gh.throwIfWrongPlayer(&pack); 
														 | 
														
														 | 
														
															 	gh.throwIfWrongPlayer(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	result = gh.heroPool->hireHero(pack.tid, pack.hid, pack.player, pack.nhid); 
														 | 
														
														 | 
														
															 	result = gh.heroPool->hireHero(pack.tid, pack.hid, pack.player, pack.nhid); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -330,6 +366,7 @@ void ApplyGhNetPackVisitor::visitHireHero(HireHero & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 void ApplyGhNetPackVisitor::visitBuildBoat(BuildBoat & pack) 
														 | 
														
														 | 
														
															 void ApplyGhNetPackVisitor::visitBuildBoat(BuildBoat & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	gh.throwIfWrongPlayer(&pack); 
														 | 
														
														 | 
														
															 	gh.throwIfWrongPlayer(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	if(gh.getPlayerRelations(gh.getOwner(pack.objid), pack.player) == PlayerRelations::ENEMIES) 
														 | 
														
														 | 
														
															 	if(gh.getPlayerRelations(gh.getOwner(pack.objid), pack.player) == PlayerRelations::ENEMIES) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		gh.throwAndComplain(&pack, "Can't build boat at enemy shipyard"); 
														 | 
														
														 | 
														
															 		gh.throwAndComplain(&pack, "Can't build boat at enemy shipyard"); 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -355,6 +392,7 @@ void ApplyGhNetPackVisitor::visitQueryReply(QueryReply & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 void ApplyGhNetPackVisitor::visitMakeAction(MakeAction & pack) 
														 | 
														
														 | 
														
															 void ApplyGhNetPackVisitor::visitMakeAction(MakeAction & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	gh.throwIfWrongPlayer(&pack); 
														 | 
														
														 | 
														
															 	gh.throwIfWrongPlayer(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	// allowed even if it is not our turn - will be filtered by battle sides 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	result = gh.battles->makePlayerBattleAction(pack.battleID, pack.player, pack.ba); 
														 | 
														
														 | 
														
															 	result = gh.battles->makePlayerBattleAction(pack.battleID, pack.player, pack.ba); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -362,12 +400,15 @@ void ApplyGhNetPackVisitor::visitMakeAction(MakeAction & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 void ApplyGhNetPackVisitor::visitDigWithHero(DigWithHero & pack) 
														 | 
														
														 | 
														
															 void ApplyGhNetPackVisitor::visitDigWithHero(DigWithHero & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.id); 
														 | 
														
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.id); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	result = gh.dig(gh.getHero(pack.id)); 
														 | 
														
														 | 
														
															 	result = gh.dig(gh.getHero(pack.id)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 void ApplyGhNetPackVisitor::visitCastAdvSpell(CastAdvSpell & pack) 
														 | 
														
														 | 
														
															 void ApplyGhNetPackVisitor::visitCastAdvSpell(CastAdvSpell & pack) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.hid); 
														 | 
														
														 | 
														
															 	gh.throwIfWrongOwner(&pack, pack.hid); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	gh.throwIfPlayerNotActive(&pack); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	if (!pack.sid.hasValue()) 
														 | 
														
														 | 
														
															 	if (!pack.sid.hasValue()) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		gh.throwNotAllowedAction(&pack); 
														 | 
														
														 | 
														
															 		gh.throwNotAllowedAction(&pack); 
														 |