rendered paste bodyndex: CharacterHandler.cpp===================================================================--- CharacterHandler.cpp (revision 5746)+++ CharacterHandler.cpp (working copy)@@ -521,8 +521,52 @@ MapManager::Instance().GetMap(pCurrChar->GetMapId(), pCurrChar)->Add(pCurrChar); ObjectAccessor::Instance().AddObject(pCurrChar);- //sLog.outDebug("Player %s added to Map.",pCurrChar->GetName());-+ if (MapManager::Instance().GetMap(pCurrChar->GetMapId(), pCurrChar)->Instanceable())+ {+ uint32 limit=MapManager::Instance().GetMap(pCurrChar->GetMapId(), pCurrChar)->GetMaxPlayers();+ uint32 cur=MapManager::Instance().GetMap(pCurrChar->GetMapId(), pCurrChar)->GetPlayersCountExceptGMs();+ if (cur>limit)+ {+ sLog.outError("Player %s exceed limit and will be teleported",pCurrChar->GetName());+ uint32 map_id = MapManager::Instance().GetMap(pCurrChar->GetMapId(), pCurrChar)->GetId();+ QueryResult *result = WorldDatabase.PQuery("SELECT id FROM areatrigger_teleport WHERE target_map ='%u'", map_id);+ uint32 Trigger_ID;+ if(result){+ QueryResult *result2 = WorldDatabase.PQuery("SELECT parent_map FROM instance_template WHERE map ='%u'", map_id);+ AreaTriggerEntry const* atEntry;+ if(result2){+ uint32 parentmap;+ Field *field2 = result2->Fetch();+ parentmap = field2[0].GetUInt32();+ for (uint64 i=0; i < result->GetRowCount(); i++){+ Field *fields = result->Fetch();+ Trigger_ID = fields[0].GetUInt32();+ atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID);+ if(atEntry->mapid == parentmap)+ break;+ result->NextRow();+ }else{+ delete result2;+ Field *fields = result->Fetch();+ Trigger_ID = fields[0].GetUInt32();+ atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID);+ }+ }+ + if(atEntry){+ pCurrChar->TeleportTo(atEntry->mapid, atEntry->x, atEntry->y,atEntry->z, pCurrChar->GetOrientation());+ sLog.outError("TEleport to %u",atEntry->mapid);+ }else{+ sLog.outError("Not find the instance areatrigger. Player: %s, Trigger_ID: %i,teleport to Home.",pCurrChar->GetName(),Trigger_ID);+ pCurrChar->TeleportTo(pCurrChar->m_homebindMapId, pCurrChar->m_homebindX, pCurrChar->m_homebindY,pCurrChar->m_homebindZ, pCurrChar->GetOrientation());+ }+ }else{+ sLog.outError("Query bug");+ }+ delete result;+ }+ }+ pCurrChar->SendInitialPacketsAfterAddToMap(); CharacterDatabase.PExecute("UPDATE characters SET online = 1 WHERE guid = '%u'", pCurrChar->GetGUIDLow());