Merge branch 'master' of github.com:TrinityCore/TrinityCore into 4.3.4

This commit is contained in:
Vincent_Michael
2013-02-23 23:53:23 +01:00
8 changed files with 118 additions and 91 deletions

View File

@@ -0,0 +1 @@
DELETE FROM `gameobject` WHERE `guid`=61090;

View File

@@ -27,7 +27,18 @@
AccountMgr::AccountMgr()
{
}
AccountMgr::~AccountMgr()
{
for (RBACPermissionsContainer::iterator itr = _permissions.begin(); itr != _permissions.end(); ++itr)
delete itr->second;
for (RBACRolesContainer::iterator itr = _roles.begin(); itr != _roles.end(); ++itr)
delete itr->second;
for (RBACGroupsContainer::iterator itr = _groups.begin(); itr != _groups.end(); ++itr)
delete itr->second;
}
AccountOpResult AccountMgr::CreateAccount(std::string username, std::string password)

View File

@@ -45,6 +45,7 @@ class AccountMgr
private:
AccountMgr();
~AccountMgr();
public:
AccountOpResult CreateAccount(std::string username, std::string password);

View File

@@ -40,6 +40,12 @@ CalendarMgr::CalendarMgr()
CalendarMgr::~CalendarMgr()
{
for (CalendarEventStore::iterator itr = _events.begin(); itr != _events.end(); ++itr)
delete *itr;
for (CalendarEventInviteStore::iterator itr = _invites.begin(); itr != _invites.end(); ++itr)
for (CalendarInviteStore::iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2)
delete *itr2;
}
void CalendarMgr::LoadFromDB()
@@ -153,7 +159,7 @@ void CalendarMgr::RemoveEvent(uint64 eventId, uint64 remover)
PreparedStatement* stmt;
MailDraft mail(calendarEvent->BuildCalendarMailSubject(remover), calendarEvent->BuildCalendarMailBody());
std::vector<CalendarInvite*>::iterator itr = _invites[eventId].begin();
CalendarInviteStore::iterator itr = _invites[eventId].begin();
while (itr != _invites[eventId].end())
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_INVITE);
@@ -187,7 +193,7 @@ void CalendarMgr::RemoveInvite(uint64 inviteId, uint64 eventId, uint64 /*remover
if (!calendarEvent)
return;
std::vector<CalendarInvite*>::iterator itr = _invites[eventId].begin();
CalendarInviteStore::iterator itr = _invites[eventId].begin();
for (; itr != _invites[eventId].end(); ++itr)
if ((*itr)->GetInviteId() == inviteId)
break;
@@ -254,8 +260,8 @@ void CalendarMgr::RemoveAllPlayerEventsAndInvites(uint64 guid)
if ((*itr)->GetCreatorGUID() == guid)
RemoveEvent((*itr)->GetEventId(), 0); // don't send mail if removing a character
std::vector<CalendarInvite*> playerInvites = GetPlayerInvites(guid);
for (std::vector<CalendarInvite*>::const_iterator itr = playerInvites.begin(); itr != playerInvites.end(); ++itr)
CalendarInviteStore playerInvites = GetPlayerInvites(guid);
for (CalendarInviteStore::const_iterator itr = playerInvites.begin(); itr != playerInvites.end(); ++itr)
RemoveInvite((*itr)->GetInviteId(), (*itr)->GetEventId(), guid);
}
@@ -265,14 +271,14 @@ void CalendarMgr::RemovePlayerGuildEventsAndSignups(uint64 guid, uint32 guildId)
if ((*itr)->GetCreatorGUID() == guid && ((*itr)->IsGuildEvent() || (*itr)->IsGuildAnnouncement()))
RemoveEvent((*itr)->GetEventId(), guid);
std::vector<CalendarInvite*> playerInvites = GetPlayerInvites(guid);
for (std::vector<CalendarInvite*>::const_iterator itr = playerInvites.begin(); itr != playerInvites.end(); ++itr)
CalendarInviteStore playerInvites = GetPlayerInvites(guid);
for (CalendarInviteStore::const_iterator itr = playerInvites.begin(); itr != playerInvites.end(); ++itr)
if (CalendarEvent* calendarEvent = GetEvent((*itr)->GetEventId()))
if (calendarEvent->IsGuildEvent() && calendarEvent->GetGuildId() == guildId)
RemoveInvite((*itr)->GetInviteId(), (*itr)->GetEventId(), guid);
}
CalendarEvent* CalendarMgr::GetEvent(uint64 eventId)
CalendarEvent* CalendarMgr::GetEvent(uint64 eventId) const
{
for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr)
if ((*itr)->GetEventId() == eventId)
@@ -282,10 +288,10 @@ CalendarEvent* CalendarMgr::GetEvent(uint64 eventId)
return NULL;
}
CalendarInvite* CalendarMgr::GetInvite(uint64 inviteId)
CalendarInvite* CalendarMgr::GetInvite(uint64 inviteId) const
{
for (CalendarInviteStore::const_iterator itr = _invites.begin(); itr != _invites.end(); ++itr)
for (std::vector<CalendarInvite*>::const_iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2)
for (CalendarEventInviteStore::const_iterator itr = _invites.begin(); itr != _invites.end(); ++itr)
for (CalendarInviteStore::const_iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2)
if ((*itr2)->GetInviteId() == inviteId)
return *itr2;
@@ -305,12 +311,10 @@ uint64 CalendarMgr::GetFreeEventId()
{
if (_freeEventIds.empty())
return ++_maxEventId;
else
{
uint64 eventId = _freeEventIds.front();
_freeEventIds.pop_front();
return eventId;
}
uint64 eventId = _freeEventIds.front();
_freeEventIds.pop_front();
return eventId;
}
void CalendarMgr::FreeInviteId(uint64 id)
@@ -325,20 +329,18 @@ uint64 CalendarMgr::GetFreeInviteId()
{
if (_freeInviteIds.empty())
return ++_maxInviteId;
else
{
uint64 inviteId = _freeInviteIds.front();
_freeInviteIds.pop_front();
return inviteId;
}
uint64 inviteId = _freeInviteIds.front();
_freeInviteIds.pop_front();
return inviteId;
}
CalendarEventStore CalendarMgr::GetPlayerEvents(uint64 guid)
{
CalendarEventStore events;
for (CalendarInviteStore::const_iterator itr = _invites.begin(); itr != _invites.end(); ++itr)
for (std::vector<CalendarInvite*>::const_iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2)
for (CalendarEventInviteStore::const_iterator itr = _invites.begin(); itr != _invites.end(); ++itr)
for (CalendarInviteStore::const_iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2)
if ((*itr2)->GetInviteeGUID() == guid)
events.insert(GetEvent(itr->first));
@@ -350,17 +352,17 @@ CalendarEventStore CalendarMgr::GetPlayerEvents(uint64 guid)
return events;
}
std::vector<CalendarInvite*> CalendarMgr::GetEventInvites(uint64 eventId)
CalendarInviteStore const& CalendarMgr::GetEventInvites(uint64 eventId)
{
return _invites[eventId];
}
std::vector<CalendarInvite*> CalendarMgr::GetPlayerInvites(uint64 guid)
CalendarInviteStore CalendarMgr::GetPlayerInvites(uint64 guid)
{
std::vector<CalendarInvite*> invites;
CalendarInviteStore invites;
for (CalendarInviteStore::const_iterator itr = _invites.begin(); itr != _invites.end(); ++itr)
for (std::vector<CalendarInvite*>::const_iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2)
for (CalendarEventInviteStore::const_iterator itr = _invites.begin(); itr != _invites.end(); ++itr)
for (CalendarInviteStore::const_iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2)
if ((*itr2)->GetInviteeGUID() == guid)
invites.push_back(*itr2);
@@ -369,13 +371,22 @@ std::vector<CalendarInvite*> CalendarMgr::GetPlayerInvites(uint64 guid)
uint32 CalendarMgr::GetPlayerNumPending(uint64 guid)
{
std::vector<CalendarInvite*> const& invites = GetPlayerInvites(guid);
CalendarInviteStore const& invites = GetPlayerInvites(guid);
uint32 pendingNum = 0;
for (std::vector<CalendarInvite*>::const_iterator itr = invites.begin(); itr != invites.end(); ++itr)
// correct?
if ((*itr)->GetStatus() == CALENDAR_STATUS_INVITED || (*itr)->GetStatus() == CALENDAR_STATUS_TENTATIVE || (*itr)->GetStatus() == CALENDAR_STATUS_NOT_SIGNED_UP)
++pendingNum;
for (CalendarInviteStore::const_iterator itr = invites.begin(); itr != invites.end(); ++itr)
{
switch ((*itr)->GetStatus())
{
case CALENDAR_STATUS_INVITED:
case CALENDAR_STATUS_TENTATIVE:
case CALENDAR_STATUS_NOT_SIGNED_UP:
++pendingNum;
break;
default:
break;
}
}
return pendingNum;
}
@@ -535,7 +546,7 @@ void CalendarMgr::SendCalendarEvent(uint64 guid, CalendarEvent const& calendarEv
if (!player)
return;
std::vector<CalendarInvite*> const& eventInviteeList = _invites[calendarEvent.GetEventId()];
CalendarInviteStore const& eventInviteeList = _invites[calendarEvent.GetEventId()];
WorldPacket data(SMSG_CALENDAR_SEND_EVENT, 60 + eventInviteeList.size() * 32);
data << uint8(sendType);
@@ -555,7 +566,7 @@ void CalendarMgr::SendCalendarEvent(uint64 guid, CalendarEvent const& calendarEv
data << uint64(guild ? guild->GetGUID() : 0);
data << uint32(eventInviteeList.size());
for (std::vector<CalendarInvite*>::const_iterator itr = eventInviteeList.begin(); itr != eventInviteeList.end(); ++itr)
for (CalendarInviteStore::const_iterator itr = eventInviteeList.begin(); itr != eventInviteeList.end(); ++itr)
{
CalendarInvite const* calendarInvite = (*itr);
uint64 inviteeGuid = calendarInvite->GetInviteeGUID();
@@ -633,8 +644,8 @@ void CalendarMgr::SendPacketToAllEventRelatives(WorldPacket packet, CalendarEven
guild->BroadcastPacket(&packet);
// Send packet to all invitees if event is non-guild, in other case only to non-guild invitees (packet was broadcasted for them)
std::vector<CalendarInvite*> invites = _invites[calendarEvent.GetEventId()];
for (std::vector<CalendarInvite*>::iterator itr = invites.begin(); itr != invites.end(); ++itr)
CalendarInviteStore invites = _invites[calendarEvent.GetEventId()];
for (CalendarInviteStore::iterator itr = invites.begin(); itr != invites.end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer((*itr)->GetInviteeGUID()))
if (!calendarEvent.IsGuildEvent() || (calendarEvent.IsGuildEvent() && player->GetGuildId() != calendarEvent.GetGuildId()))
player->SendDirectMessage(&packet);

View File

@@ -262,9 +262,9 @@ struct CalendarEvent
std::string _title;
std::string _description;
};
typedef std::vector<CalendarInvite*> CalendarInviteStore;
typedef std::set<CalendarEvent*> CalendarEventStore;
typedef std::map<uint64 /* eventId */, std::vector<CalendarInvite*> > CalendarInviteStore;
typedef std::map<uint64 /* eventId */, CalendarInviteStore > CalendarEventInviteStore;
class CalendarMgr
{
@@ -275,7 +275,7 @@ class CalendarMgr
~CalendarMgr();
CalendarEventStore _events;
CalendarInviteStore _invites;
CalendarEventInviteStore _invites;
std::deque<uint64> _freeEventIds;
std::deque<uint64> _freeInviteIds;
@@ -285,14 +285,14 @@ class CalendarMgr
public:
void LoadFromDB();
CalendarEvent* GetEvent(uint64 eventId);
CalendarEvent* GetEvent(uint64 eventId) const;
CalendarEventStore const& GetEvents() const { return _events; }
CalendarEventStore GetPlayerEvents(uint64 guid);
CalendarInvite* GetInvite(uint64 inviteId);
CalendarInviteStore const& GetInvites() const { return _invites; }
std::vector<CalendarInvite*> GetEventInvites(uint64 eventId);
std::vector<CalendarInvite*> GetPlayerInvites(uint64 guid);
CalendarInvite* GetInvite(uint64 inviteId) const;
CalendarEventInviteStore const& GetInvites() const { return _invites; }
CalendarInviteStore const& GetEventInvites(uint64 eventId);
CalendarInviteStore GetPlayerInvites(uint64 guid);
void FreeEventId(uint64 id);
uint64 GetFreeEventId();

View File

@@ -436,10 +436,6 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
// exits the vehicle will dismiss. That's why the actual adding the passenger to the vehicle is scheduled
// asynchronously, so it can be cancelled easily in case the vehicle is uninstalled meanwhile.
SeatMap::iterator seat;
VehicleJoinEvent* e = new VehicleJoinEvent(this, unit);
unit->m_Events.AddEvent(e, unit->m_Events.CalculateTime(0));
_pendingJoinEvents.push_back(e);
if (seatId < 0) // no specific seat requirement
{
for (seat = Seats.begin(); seat != Seats.end(); ++seat)
@@ -447,23 +443,22 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
break;
if (seat == Seats.end()) // no available seat
{
CancelJoinEvent(e);
return false;
}
e->Seat = seat;
VehicleJoinEvent* e = new VehicleJoinEvent(this, unit, seat);
_pendingJoinEvents.push_back(e);
unit->m_Events.AddEvent(e, unit->m_Events.CalculateTime(0));
}
else
{
seat = Seats.find(seatId);
if (seat == Seats.end())
{
CancelJoinEvent(e);
return false;
}
e->Seat = seat;
VehicleJoinEvent* e = new VehicleJoinEvent(this, unit, seat);
_pendingJoinEvents.push_back(e);
unit->m_Events.AddEvent(e, unit->m_Events.CalculateTime(0));
if (seat->second.Passenger)
{
Unit* passenger = ObjectAccessor::GetUnit(*GetBase(), seat->second.Passenger);
@@ -687,24 +682,6 @@ void Vehicle::CalculatePassengerOffset(float& x, float& y, float& z, float& o)
x = (inx + iny * tan(GetBase()->GetOrientation())) / (cos(GetBase()->GetOrientation()) + std::sin(GetBase()->GetOrientation()) * tan(GetBase()->GetOrientation()));
}
/**
* @fn void Vehicle::CancelJoinEvent(VehicleJoinEvent* e)
*
* @brief Aborts delayed @VehicleJoinEvent objects.
* Implies that the related unit will not be boarding the vehicle after all.
*
* @author Machiavelli
* @date 17-2-2013
*
* @param [in,out] e The VehicleJoinEvent* to process.
*/
void Vehicle::CancelJoinEvent(VehicleJoinEvent* e)
{
e->to_Abort = true;
_pendingJoinEvents.pop_back();
}
/**
* @fn void Vehicle::RemovePendingEvent(VehicleJoinEvent* e)
*
@@ -720,7 +697,7 @@ void Vehicle::CancelJoinEvent(VehicleJoinEvent* e)
void Vehicle::RemovePendingEvent(VehicleJoinEvent* e)
{
for (std::deque<VehicleJoinEvent*>::iterator itr = _pendingJoinEvents.begin(); itr != _pendingJoinEvents.end(); ++itr)
for (PendingJoinEventContainer::iterator itr = _pendingJoinEvents.begin(); itr != _pendingJoinEvents.end(); ++itr)
{
if (*itr == e)
{
@@ -730,6 +707,31 @@ void Vehicle::RemovePendingEvent(VehicleJoinEvent* e)
}
}
/**
* @fn void Vehicle::RemovePendingEventsForSeat(uint8 seatId)
*
* @brief Removes any pending events for given seatId. Executed when a @VehicleJoinEvent::Execute is called
*
* @author Machiavelli
* @date 23-2-2013
*
* @param seatId Identifier for the seat.
*/
void Vehicle::RemovePendingEventsForSeat(int8 seatId)
{
for (PendingJoinEventContainer::iterator itr = _pendingJoinEvents.begin(); itr != _pendingJoinEvents.end();)
{
if ((*itr)->Seat->first == seatId)
{
(*itr)->to_Abort = true;
_pendingJoinEvents.erase(itr++);
}
else
++itr;
}
}
/**
* @fn bool VehicleJoinEvent::Execute(uint64, uint32)
*
@@ -750,6 +752,8 @@ bool VehicleJoinEvent::Execute(uint64, uint32)
ASSERT(Passenger->IsInWorld());
ASSERT(Target->GetBase()->IsInWorld());
Target->RemovePendingEventsForSeat(Seat->first);
Passenger->m_vehicle = Target;
Seat->second.Passenger = Passenger->GetGUID();
if (Seat->second.SeatInfo->CanEnterOrExit())

View File

@@ -23,7 +23,7 @@
#include "Object.h"
#include "VehicleDefines.h"
#include "Unit.h"
#include <deque>
#include <list>
struct VehicleEntry;
class Unit;
@@ -63,12 +63,8 @@ class Vehicle : public TransportBase
void RelocatePassengers();
void RemoveAllPassengers();
void Dismiss();
void TeleportVehicle(float x, float y, float z, float ang);
bool IsVehicleInUse() { return Seats.begin() != Seats.end(); }
void SetLastShootPos(Position const& pos) { m_lastShootPos.Relocate(pos); }
Position GetLastShootPos() { return m_lastShootPos; }
SeatMap Seats; ///< The collection of all seats on the vehicle. Including vacant ones.
VehicleSeatEntry const* GetSeatForPassenger(Unit* passenger);
@@ -94,23 +90,26 @@ class Vehicle : public TransportBase
/// This method transforms supplied global coordinates into local offsets
void CalculatePassengerOffset(float& x, float& y, float& z, float& o);
void RemovePendingEvent(VehicleJoinEvent* e);
void RemovePendingEventsForSeat(int8 seatId);
private:
Unit* _me; ///< The underlying unit with the vehicle kit. Can be player or creature.
VehicleEntry const* _vehicleInfo; ///< DBC data for vehicle
GuidSet vehiclePlayers;
uint32 _creatureEntry; ///< Can be different than the entry of _me in case of players
Status _status; ///< Internal variable for sanity checks
Position m_lastShootPos;
std::deque<VehicleJoinEvent*> _pendingJoinEvents; ///< Collection of delayed join events for prospective passengers
void CancelJoinEvent(VehicleJoinEvent* e);
void RemovePendingEvent(VehicleJoinEvent* e);
typedef std::list<VehicleJoinEvent*> PendingJoinEventContainer;
PendingJoinEventContainer _pendingJoinEvents; ///< Collection of delayed join events for prospective passengers
};
class VehicleJoinEvent : public BasicEvent
{
friend class Vehicle;
protected:
VehicleJoinEvent(Vehicle* v, Unit* u) : Target(v), Passenger(u), Seat(Target->Seats.end()) {}
VehicleJoinEvent(Vehicle* v, Unit* u, SeatMap::iterator seat) : Target(v), Passenger(u), Seat(seat) {}
~VehicleJoinEvent() { Target->RemovePendingEvent(this); }
bool Execute(uint64, uint32);
void Abort(uint64);

View File

@@ -57,9 +57,9 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/)
WorldPacket data(SMSG_CALENDAR_SEND_CALENDAR, 1000); // Average size if no instance
std::vector<CalendarInvite*> invites = sCalendarMgr->GetPlayerInvites(guid);
CalendarInviteStore invites = sCalendarMgr->GetPlayerInvites(guid);
data << uint32(invites.size());
for (std::vector<CalendarInvite*>::const_iterator itr = invites.begin(); itr != invites.end(); ++itr)
for (CalendarInviteStore::const_iterator itr = invites.begin(); itr != invites.end(); ++itr)
{
data << uint64((*itr)->GetEventId());
data << uint64((*itr)->GetInviteId());
@@ -351,9 +351,9 @@ void WorldSession::HandleCalendarCopyEvent(WorldPacket& recvData)
newEvent->SetEventTime(time_t(time));
sCalendarMgr->AddEvent(newEvent, CALENDAR_SENDTYPE_COPY);
std::vector<CalendarInvite*> invites = sCalendarMgr->GetEventInvites(eventId);
CalendarInviteStore invites = sCalendarMgr->GetEventInvites(eventId);
for (std::vector<CalendarInvite*>::const_iterator itr = invites.begin(); itr != invites.end(); ++itr)
for (CalendarInviteStore::const_iterator itr = invites.begin(); itr != invites.end(); ++itr)
sCalendarMgr->AddInvite(newEvent, new CalendarInvite(**itr, sCalendarMgr->GetFreeInviteId(), newEvent->GetEventId()));
// should we change owner when somebody makes a copy of event owned by another person?