public static void HandleCharacterEnum(ref PacketReader packet, ref WorldSession session) { //"SELECT c.guid, c.name, c.race, c.class, c.gender, c.playerBytes, c.playerBytes2, c.level, c.zone, c.map, c.position_x, c.position_y, c.position_z, gm.guildid, c.playerFlags, c.at_login, cp.entry, cp.modelid, //cp.level, c.equipmentCache, cb.guid, c.slot FROM characters AS c LEFT JOIN character_pet AS cp ON c.guid = cp.owner AND cp.slot = ? LEFT JOIN guild_member AS gm ON c.guid = gm.guid //LEFT JOIN character_banned AS cb ON c.guid = cb.guid AND cb.active = 1 WHERE c.account = ?"; PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.CHAR_SEL_ENUM); stmt.AddValue(0, (byte)0); stmt.AddValue(1, session.GetAccountId()); SQLResult result = DB.Characters.Select(stmt); PacketWriter data = new PacketWriter(Opcodes.SMSG_CharEnum); data.WriteBits(0, 23); data.WriteBits(result.Count, 17); if (result.Count != 0) { BuildEnumData(result, ref data); } else { data.WriteBit(1); data.BitFlush(); } session.Send(data); }
static bool HandleAccountCommand(StringArguments args, CommandHandler handler) { if (handler.GetSession() == null) { return(false); } // GM Level AccountTypes gmLevel = handler.GetSession().GetSecurity(); handler.SendSysMessage(CypherStrings.AccountLevel, gmLevel); // Security level required WorldSession session = handler.GetSession(); bool hasRBAC = (session.HasPermission(RBACPermissions.EmailConfirmForPassChange) ? true : false); uint pwConfig = 0; // 0 - PW_NONE, 1 - PW_EMAIL, 2 - PW_RBAC handler.SendSysMessage(CypherStrings.AccountSecType, (pwConfig == 0 ? "Lowest level: No Email input required." : pwConfig == 1 ? "Highest level: Email input required." : pwConfig == 2 ? "Special level: Your account may require email input depending on settings. That is the case if another lien is printed." : "Unknown security level: Notify technician for details.")); // RBAC required display - is not displayed for console if (pwConfig == 2 && hasRBAC) { handler.SendSysMessage(CypherStrings.RbacEmailRequired); } // Email display if sufficient rights if (session.HasPermission(RBACPermissions.MayCheckOwnEmail)) { string emailoutput; uint accountId = session.GetAccountId(); PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.GET_EMAIL_BY_ID); stmt.AddValue(0, accountId); SQLResult result = DB.Login.Query(stmt); if (!result.IsEmpty()) { emailoutput = result.Read <string>(0); handler.SendSysMessage(CypherStrings.CommandEmailOutput, emailoutput); } } return(true); }
static bool HandleCharacterRenameCommand(StringArguments args, CommandHandler handler) { Player target; ObjectGuid targetGuid; string targetName; if (!handler.ExtractPlayerTarget(args, out target, out targetGuid, out targetName)) { return(false); } string newNameStr = args.NextString(); if (!string.IsNullOrEmpty(newNameStr)) { string playerOldName; string newName = newNameStr; if (target) { // check online security if (handler.HasLowerSecurity(target, ObjectGuid.Empty)) { return(false); } playerOldName = target.GetName(); } else { // check offline security if (handler.HasLowerSecurity(null, targetGuid)) { return(false); } Global.CharacterCacheStorage.GetCharacterNameByGuid(targetGuid, out playerOldName); } if (!ObjectManager.NormalizePlayerName(ref newName)) { handler.SendSysMessage(CypherStrings.BadValue); return(false); } if (ObjectManager.CheckPlayerName(newName, target ? target.GetSession().GetSessionDbcLocale() : Global.WorldMgr.GetDefaultDbcLocale(), true) != ResponseCodes.CharNameSuccess) { handler.SendSysMessage(CypherStrings.BadValue); return(false); } WorldSession session = handler.GetSession(); if (session != null) { if (!session.HasPermission(RBACPermissions.SkipCheckCharacterCreationReservedname) && Global.ObjectMgr.IsReservedName(newName)) { handler.SendSysMessage(CypherStrings.ReservedName); return(false); } } PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_CHECK_NAME); stmt.AddValue(0, newName); SQLResult result = DB.Characters.Query(stmt); if (!result.IsEmpty()) { handler.SendSysMessage(CypherStrings.RenamePlayerAlreadyExists, newName); return(false); } // Remove declined name from db stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_CHAR_DECLINED_NAME); stmt.AddValue(0, targetGuid.GetCounter()); DB.Characters.Execute(stmt); if (target) { target.SetName(newName); session = target.GetSession(); if (session != null) { session.KickPlayer(); } } else { stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_NAME_BY_GUID); stmt.AddValue(0, newName); stmt.AddValue(1, targetGuid.GetCounter()); DB.Characters.Execute(stmt); } Global.CharacterCacheStorage.UpdateCharacterData(targetGuid, newName); handler.SendSysMessage(CypherStrings.RenamePlayerWithNewName, playerOldName, newName); Player player = handler.GetPlayer(); if (player) { Log.outCommand(session.GetAccountId(), "GM {0} (Account: {1}) forced rename {2} to player {3} (Account: {4})", player.GetName(), session.GetAccountId(), newName, playerOldName, Global.CharacterCacheStorage.GetCharacterAccountIdByGuid(targetGuid)); } else { Log.outCommand(0, "CONSOLE forced rename '{0}' to '{1}' ({2})", playerOldName, newName, targetGuid.ToString()); } } else { if (target) { // check online security if (handler.HasLowerSecurity(target, ObjectGuid.Empty)) { return(false); } handler.SendSysMessage(CypherStrings.RenamePlayer, handler.GetNameLink(target)); target.SetAtLoginFlag(AtLoginFlags.Rename); } else { // check offline security if (handler.HasLowerSecurity(null, targetGuid)) { return(false); } string oldNameLink = handler.PlayerLink(targetName); handler.SendSysMessage(CypherStrings.RenamePlayerGuid, oldNameLink, targetGuid.ToString()); PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_ADD_AT_LOGIN_FLAG); stmt.AddValue(0, AtLoginFlags.Rename); stmt.AddValue(1, targetGuid.GetCounter()); DB.Characters.Execute(stmt); } } return(true); }
static bool HandleCharacterChangeAccountCommand(StringArguments args, CommandHandler handler) { string playerNameStr; string accountName; handler.ExtractOptFirstArg(args, out playerNameStr, out accountName); if (accountName.IsEmpty()) { return(false); } ObjectGuid targetGuid; string targetName; if (!handler.ExtractPlayerTarget(new StringArguments(playerNameStr), out _, out targetGuid, out targetName)) { return(false); } CharacterCacheEntry characterInfo = Global.CharacterCacheStorage.GetCharacterCacheByGuid(targetGuid); if (characterInfo == null) { handler.SendSysMessage(CypherStrings.PlayerNotFound); return(false); } uint oldAccountId = characterInfo.AccountId; uint newAccountId = oldAccountId; PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_ACCOUNT_ID_BY_NAME); stmt.AddValue(0, accountName); SQLResult result = DB.Login.Query(stmt); if (!result.IsEmpty()) { newAccountId = result.Read <uint>(0); } else { handler.SendSysMessage(CypherStrings.AccountNotExist, accountName); return(false); } // nothing to do :) if (newAccountId == oldAccountId) { return(true); } uint charCount = Global.AccountMgr.GetCharactersCount(newAccountId); if (charCount != 0) { if (charCount >= WorldConfig.GetIntValue(WorldCfg.CharactersPerRealm)) { handler.SendSysMessage(CypherStrings.AccountCharacterListFull, accountName, newAccountId); return(false); } } stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_ACCOUNT_BY_GUID); stmt.AddValue(0, newAccountId); stmt.AddValue(1, targetGuid.GetCounter()); DB.Characters.DirectExecute(stmt); Global.WorldMgr.UpdateRealmCharCount(oldAccountId); Global.WorldMgr.UpdateRealmCharCount(newAccountId); Global.CharacterCacheStorage.UpdateCharacterAccountId(targetGuid, newAccountId); handler.SendSysMessage(CypherStrings.ChangeAccountSuccess, targetName, accountName); string logString = $"changed ownership of player {targetName} ({targetGuid}) from account {oldAccountId} to account {newAccountId}"; WorldSession session = handler.GetSession(); if (session != null) { Player player = session.GetPlayer(); if (player != null) { Log.outCommand(session.GetAccountId(), $"GM {player.GetName()} (Account: {session.GetAccountId()}) {logString}"); } } else { Log.outCommand(0, $"{handler.GetCypherString(CypherStrings.Console)} {logString}"); } return(true); }
public static bool InvokeHandler(ref PacketReader reader, WorldSession session, Opcodes opcode) { if (OpcodeHandlers.ContainsKey(opcode)) { OpcodeHandlers[opcode].Invoke(ref reader, ref session); return(true); } else { Log.outDebug("Received unhandled opcode {0} from AcountId:{1}", opcode, session.GetAccountId()); return(false); } }
public static void HandlePlayerLogin(ref PacketReader packet, ref WorldSession session) { var mask = new byte[] { 5, 7, 6, 1, 2, 3, 4, 0 }; var bytes = new byte[] { 6, 4, 3, 5, 0, 2, 7, 1 }; var guid = packet.GetGuid(mask, bytes); Player pChar = new Player(ref session); session.SetPlayer(pChar); if (!pChar.LoadCharacter(guid)) { session.SetPlayer(null); session.KickPlayer(); // disconnect client, player no set to session and it will not deleted or saved at kick //m_playerLoading = false; return; } //pCurrChar->GetMotionMaster()->Initialize(); //pCurrChar->SendDungeonDifficulty(false); PacketWriter world = new PacketWriter(Opcodes.SMSG_NewWorld); world.WriteUInt32(pChar.GetMapId()); world.WriteFloat(pChar.Position.Y); world.WriteFloat(pChar.Position.Orientation); world.WriteFloat(pChar.Position.X); world.WriteFloat(pChar.Position.Z); session.Send(world); //LoadAccountData(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADACCOUNTDATA), PER_CHARACTER_CACHE_MASK); //SendAccountDataTimes(PER_CHARACTER_CACHE_MASK); session.SendAccountDataTimes(AccountDataMasks.PerCharacterCacheMask); PacketWriter feature = new PacketWriter(Opcodes.SMSG_FeatureSystemStatus); feature.WriteUInt8(2); // SystemStatus feature.WriteUInt32(1); // Unknown, Mostly 1 feature.WriteUInt32(1); // Unknown, Mostly 1 feature.WriteUInt32(2); // Unknown, Mostly same as SystemStatus, but seen other values feature.WriteUInt32(0); // Unknown, Hmm??? feature.WriteBit(true); // Unknown feature.WriteBit(true); // Unknown feature.WriteBit(false); // Unknown feature.WriteBit(true); // Unknown feature.WriteBit(false); // EnableVoiceChat, not sure feature.WriteBit(false); // Unknown feature.BitFlush(); feature.WriteUInt32(1); // Only seen 1 feature.WriteUInt32(0); // Unknown, like random values feature.WriteUInt32(0xA); // Only seen 10 feature.WriteUInt32(0x3C); // Only seen 60 //session.Send(feature); MiscHandler.SendMOTD(ref session); //if (pChar.GuildGuid != 0) { //Guild guild = GuildMgr.GetGuildByGuid(pChar.GuildGuid); //if (guild != null) { //var member = guild.GetMember(pChar.Guid); //pChar.SetInGuild(pChar.GuildGuid); //pChar.SetGuildRank(member.RankId); //pChar.SetGuildLevel(guild.GetLevel()); //guild.HandleMemberLogin(pChar); } //else { //pChar.SetInGuild(0); //pChar.SetGuildRank(0); //pChar.SetGuildLevel(0); } } PacketWriter data = new PacketWriter(Opcodes.SMSG_LearnedDanceMoves); data.WriteUInt64(0); //session.Send(data); //hotfix pChar.SendInitialPacketsBeforeAddToMap(); /* * //Show cinematic at the first time that player login * if (!pCurrChar->getCinematic()) * { * pCurrChar->setCinematic(1); * * if (ChrClassesEntry cEntry = sChrClassesStore.LookupEntry(pCurrChar->getClass())) * { * if (cEntry->CinematicSequence) * pCurrChar->SendCinematicStart(cEntry->CinematicSequence); * else if (ChrRacesEntry rEntry = sChrRacesStore.LookupEntry(pCurrChar->getRace())) * pCurrChar->SendCinematicStart(rEntry->CinematicSequence); * * // send new char string if not empty * if (!sWorld->GetNewCharString().empty()) * chH.PSendSysMessage("%s", sWorld->GetNewCharString().c_str()); * } * } * if (Group* group = pCurrChar->GetGroup()) * { * if (group->isLFGGroup()) * { * LfgDungeonSet Dungeons; * Dungeons.insert(sLFGMgr->GetDungeon(group->GetGUID())); * sLFGMgr->SetSelectedDungeons(pCurrChar->GetGUID(), Dungeons); * sLFGMgr->SetState(pCurrChar->GetGUID(), sLFGMgr->GetState(group->GetGUID())); * } * } */ if (!pChar.GetMap().AddPlayer(pChar))//|| !pCurrChar.CheckInstanceLoginValid()) { //AreaTrigger at = sObjectMgr->GetGoBackTrigger(pCurrChar->GetMapId()); //if (at) //pCurrChar->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, pCurrChar->GetOrientation()); //else //pCurrChar->TeleportTo(pCurrChar->m_homebindMapId, pCurrChar->m_homebindX, pCurrChar->m_homebindY, pCurrChar->m_homebindZ, pCurrChar->GetOrientation()); } ObjMgr.AddObject(pChar); pChar.SendInitialPacketsAfterAddToMap(); PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.CHAR_UPD_CHAR_ONLINE); stmt.AddValue(0, pChar.GetGUIDLow()); DB.Characters.Execute(stmt); stmt = DB.Auth.GetPreparedStatement(LoginStatements.Upd_AccountOnline); stmt.AddValue(0, session.GetAccountId()); DB.Auth.Execute(stmt); //pCurrChar->SetInGameTime(getMSTime()); // announce group about member online (must be after add to player list to receive announce to self) //if (Group* group = pCurrChar->GetGroup()) { //pCurrChar->groupInfo.group->SendInit(this); // useless //group->SendUpdate(); //group->ResetMaxEnchantingLevel(); } // friend status //sSocialMgr->SendFriendStatus(pCurrChar, FRIEND_ONLINE, pCurrChar->GetGUIDLow(), true); // Place character in world (and load zone) before some object loading //pCurrChar->LoadCorpse(); // setting Ghost+speed if dead //if (pCurrChar->m_deathState != ALIVE) { // not blizz like, we must correctly save and load player instead... //if (pCurrChar->getRace() == RACE_NIGHTELF) //pCurrChar->CastSpell(pCurrChar, 20584, true, 0);// auras SPELL_AURA_INCREASE_SPEED(+speed in wisp form), SPELL_AURA_INCREASE_SWIM_SPEED(+swim speed in wisp form), SPELL_AURA_TRANSFORM (to wisp form) //pCurrChar->CastSpell(pCurrChar, 8326, true, 0); // auras SPELL_AURA_GHOST, SPELL_AURA_INCREASE_SPEED(why?), SPELL_AURA_INCREASE_SWIM_SPEED(why?) //pCurrChar->SendMovementSetWaterWalking(true); } //pCurrChar->ContinueTaxiFlight(); // reset for all pets before pet loading //if (pChar.HasAtLoginFlag(AtLoginFlags.ResetPetTalents)) //resetTalentsForAllPetsOf(pCurrChar); // Load pet if any (if player not alive and in taxi flight or another then pet will remember as temporary unsummoned) //pCurrChar->LoadPet(); // Set FFA PvP for non GM in non-rest mode //if (sWorld->IsFFAPvPRealm() && !pCurrChar->isGameMaster() && !pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING)) //pCurrChar->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); //if (pChar.HasFlag(PlayerFields.PlayerFlags, PlayerFlags.ContestedPVP)) //pChar->SetContestedPvP(); // Apply at_login requests if (pChar.HasAtLoginFlag(AtLoginFlags.ResetSpells)) { //pChar.resetSpells(); pChar.SendNotification(CypherStrings.ResetSpells); } if (pChar.HasAtLoginFlag(AtLoginFlags.ResetTalents)) { //pChar.ResetTalents(true); //pChar.SendTalentsInfoData(false); // original talents send already in to SendInitialPacketsBeforeAddToMap, resend reset state pChar.SendNotification(CypherStrings.ResetTalents); } if (pChar.HasAtLoginFlag(AtLoginFlags.LoginFirst)) { pChar.RemoveAtLoginFlag(AtLoginFlags.LoginFirst); } // show time before shutdown if shutdown planned. //if (sWorld->IsShuttingDown()) //sWorld->ShutdownMsg(true, pChar); //if (sWorld->getBoolConfig(CONFIG_ALL_TAXI_PATHS)) //pChar->SetTaxiCheater(true); if (pChar.isGameMaster()) { pChar.SendNotification(CypherStrings.GmOn); } //string IP_str = GetRemoteAddress(); Log.outDebug("Account: {0} (IP: {1}) Login Character:[{2}] (GUID: {3}) Level: {4}", session.GetAccountId(), 0, pChar.GetName(), pChar.GetGUIDLow(), pChar.getLevel()); //if (!pChar->IsStandState() && !pChar->HasUnitState(UNIT_STATE_STUNNED)) //pChar->SetStandState(UNIT_STAND_STATE_STAND); //m_playerLoading = false; //sScriptMgr->OnPlayerLogin(pCurrChar); }