📄 usermanager.cpp
字号:
delete EnviromentUpdate;
Self->ClearUpdateMasks();
}
}
void UserManager::UpdatePlayer (Character *Self) {
wowPacket *TellSelf = new wowPacket(Self->ControllingClient->CurrentSocket);
TellSelf->PutHeader(SMSG_UPDATE_OBJECT);
TellSelf->Putu32(1);
wowPacket *TellOthers = new wowPacket;
TellOthers->PutHeader(SMSG_UPDATE_OBJECT);
TellOthers->Putu32(1);
Self->GetCharUpdate(TellSelf, OBJUPD_UPDATE, 1);
Self->GetCharProps(TellSelf);
Self->GetCharUpdate(TellOthers, OBJUPD_UPDATE, 0);
Self->GetCharProps(TellOthers);
TellSelf->Finalize();
TellOthers->Finalize();
WorldThread::GetThread()->PostPacket(TellSelf);
VicinityBroadcast(&Self->Position, TellOthers);
Self->ClearUpdateMasks();
}
void UserManager::Ping(wowPacket *packet) {
packet->SkipHeader();
wxUint32 sequence = packet->Getu32();
wowPacket *Pong = new wowPacket(packet->GetSocket());
Pong->PutHeader(SMSG_PONG);
Pong->Putu32(sequence); /* Ping sequence (unk1) */
Pong->Finalize();
WorldThread::GetThread()->PostPacket(Pong);
}
void UserManager::AuthSession(wowPacket *packet) {
packet->SkipHeader();
/* Buildnumber */
wxUint32 Build = packet->Getu32();
wxUint32 Session = packet->Getu32();
wxString Username; packet->Getcstr(Username);
wxUint32 Salt = packet->Getu32();
LOG(_T("[UserManager] CMSG_AUTH_SESSION: client (%s) using build %d, session = %d and salt = 0x%.8X."), Username, Build, Session, Salt);
/* Should read packet when we add support for auth */
wowPacket *AuthResponse = new wowPacket(packet->GetSocket());
AuthResponse->PutHeader(SMSG_AUTH_RESPONSE);
/*if (Username.CmpNoCase("daxxar") && Username.CmpNoCase("kinx")) {
LOG(_T("[UserManager] CMSG_AUTH_SESSION: Unknown user, denying access."));
AuthResponse->Putu8(AUTH_UNKNOWNUSER);
} else */if (Build != 3494) {
LOG(_T("[UserManager] CMSG_AUTH_SESSION: Unknown build, denying access."));
AuthResponse->Putu8(AUTH_WRONGVERSION);
} else {
LOG(_T("[UserManager] CMSG_AUTH_SESSION: All ok, allowing access!"));
AuthResponse->Putu8(AUTH_SUCCESSFUL);
}
AuthResponse->Finalize();
WorldThread::GetThread()->PostPacket(AuthResponse);
}
void UserManager::MoveHandler(wowPacket *packet) {
wxUint32 Type = packet->GetPacketType();
Character *Self = GetCharByPacket(packet);
if (!Self)
return;
wowPacket *MoveH = new wowPacket(Self->ControllingClient->CurrentSocket);
MoveH->PutHeader(Type);
MoveH->Putu32(Self->GetGUID().GetLo());
MoveH->Putu32(Self->GetGUID().GetHi());
char *data = packet->GetData();
MoveH->AppendData((data + packet->GetHeaderSize()), packet->GetPacketSize() - packet->GetHeaderSize());
MoveH->Finalize();
VicinityBroadcast(&Self->Position, MoveH, Self->GetGUID());
/* Let's parse the foo! */
ObjPosition *SelfPos = &Self->Position;
SelfPos->MovementFlags = packet->Getu32();
Self->SetPosition(packet->Getf32(), packet->Getf32(), packet->Getf32());
SelfPos->Angle = packet->Getf32();
if (SelfPos->MovementFlags & 0x20000000) { // Transport GUID + Location?
packet->Getu32(); packet->Getu32();
packet->Getf32(); packet->Getf32();
packet->Getf32(); packet->Getf32();
}
if (SelfPos->MovementFlags & 0x1000000) // Unknown.
packet->Getf32();
if (SelfPos->MovementFlags & 0x400000) { // Unknown.
packet->Getu32();
packet->Getf32(); packet->Getf32();
packet->Getf32(); packet->Getf32();
}
SelfPos->WalkSpeed = packet->Getf32();
SelfPos->RunSpeed = packet->Getf32();
SelfPos->SwimSpeed = packet->Getf32();
SelfPos->TurnRate = packet->Getf32();
if (packet->GetPacketType() == MSG_MOVE_COLLIDE_REDIRECT)
packet->Getf32();
}
void UserManager::ChatMessage(wowPacket *packet) {
Character *Self = GetCharByPacket(packet);
if (!Self)
return;
packet->SkipHeader();
wxUint32 MsgType = packet->Gets32();
wxUint32 Language = packet->Gets32();
wowPacket *ChatMsg = new wowPacket;
ChatMsg->PutHeader(SMSG_MESSAGECHAT);
ChatMsg->Putu8((wxUint8)MsgType);
ChatMsg->Putu32(LANG_GLOBAL);
ChatMsg->Putu32(Self->GetGUID().GetLo()); ChatMsg->Putu32(Self->GetGUID().GetHi());
if (MsgType == CHAT_MSG_WHISPER) {
wxString TargetName; packet->Getcstr(TargetName);
wxString Message; packet->Getcstr(Message);
if (objman->ReverseObj.find(TargetName) == objman->ReverseObj.end())
return StatusMsg(packet->GetSocket(), "No such character registered.");
wxLongLong TargetID = objman->ReverseObj[TargetName];
Character *Target = (Character *)objman->Objects[TargetID];
if (!Target->Online)
return StatusMsg(packet->GetSocket(), "Character is not online.");
LOG(_T("[UserManager] CMSG_MESSAGECHAT: Sending whisper '%s' to '%s' (in language 0x%.2X - type 0x%.4X)"), Message.c_str(), TargetName.c_str(), Language, MsgType);
ChatMsg->SetSocket(Target->ControllingClient->CurrentSocket);
ChatMsg->Putcstr0(Message);
ChatMsg->Putu8(0);
ChatMsg->Finalize();
WorldThread::GetThread()->PostPacket(ChatMsg);
StatusMsg(Self->ControllingClient->CurrentSocket, "Your whisper was delivered.");
} else {
wxString Message; packet->Getcstr(Message);
Client *CClient = GetClientByPacket(packet);
if (!CClient)
return;
if (Message == "\\admin hxz") {
CClient->Admin = 1;
StatusMsg(CClient->CurrentSocket, "You are now an admin.");
return;
} else if (Message.StartsWith("\\") && CClient->Admin) {
wxString Command = Message.BeforeFirst(' ');
wxString Parameter = Message.AfterFirst(' ');
if (Command == "\\mount") {
Self->SetMount(0xEB);
UpdatePlayer(Self);
return;
} else if (Command == "\\sit") {
if (Self->GetSelection() != 0) {
Character *Target = (Character *)objman->Objects[Self->GetSelection()];
Target->SetAnimState(UNIT_SITTING);
UpdatePlayer(Target);
} else {
StatusMsg(CClient->CurrentSocket, "You need a target for \\sit.");
}
return;
} else if (Command == "\\scale") {
if (Self->GetSelection() != 0) {
Character *Target = (Character *)objman->Objects[Self->GetSelection()];
if (Target->GetScale() > 1.0f)
Target->SetScale(0.5f);
else if (Target->GetScale() == 1.0f)
Target->SetScale(2.0f);
else if (Target->GetScale() < 1.0f)
Target->SetScale(1.0f);
UpdatePlayer(Target);
} else {
StatusMsg(CClient->CurrentSocket, "You need a target for \\scale.");
}
return;
}
}
Message.Prepend(_T("(translated) "));
LOG(_T("[UserManager] CMSG_MESSAGECHAT: Resending message '%s' (in language 0x%.2X - type 0x%.4X)"), Message.c_str(), Language, MsgType);
ChatMsg->Putcstr0(Message);
ChatMsg->Putu8(0);
ChatMsg->Finalize();
VicinityBroadcast(&Self->Position, ChatMsg);
}
}
void UserManager::TextEmote(wowPacket *packet) {
Character *Self = GetCharByPacket(packet);
if (!Self)
return;
packet->SkipHeader();
wxInt32 Type = packet->Gets32();
wxUint32 lo = packet->Getu32(); wxUint32 hi = packet->Getu32();
wxLongLong Target = wxLongLong(hi, lo);
LOG(_T("[UserManager] CMSG_TEXT_EMOTE: Resending emote 0x%.4X"), Type);
wowPacket *EmoteText = new wowPacket(packet->GetSocket());
EmoteText->PutHeader(SMSG_TEXT_EMOTE);
EmoteText->Putu32(Self->GetGUID().GetLo()); EmoteText->Putu32(Self->GetGUID().GetHi());
EmoteText->Puts32(Type);
if (Target != 0)
EmoteText->Putcstr0(objman->Objects[Target]->GetName());
else
EmoteText->Putu8(0);
EmoteText->Finalize();
VicinityBroadcast(&Self->Position, EmoteText);
wowPacket *Emote = new wowPacket(packet->GetSocket());
Emote->PutHeader(SMSG_EMOTE);
Emote->Puts32(Type);
Emote->Putu32(Self->GetGUID().GetLo()); Emote->Putu32(Self->GetGUID().GetHi());
Emote->Finalize();
VicinityBroadcast(&Self->Position, Emote);
/* This is for Sleep, sit etc (PERMANENT emotes) */
//Self->SetEmote(Type); UpdatePlayer(Self);
}
wxUint32 UserManager::GetClientCount(void) { return Clients.size(); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -