void WorldSession::HandleCharterSign( WorldPacket & recv_data ) { uint64 item_guid; recv_data >> item_guid; if( !_player->IsInWorld() ) return; Charter * c = objmgr.GetCharterByItemGuid(item_guid); if(c == 0) return; if( _player->m_playerInfo->charterId[c->CharterType] != 0 ) { SendNotification("You cannot sign two charters of the same type."); return; } for(uint32 i = 0; i < 9; ++i) { if(c->Signatures[i] == _player->GetGUID()) { SendNotification("You have already signed that charter."); return; } } if(c->IsFull()) return; c->AddSignature(_player->GetLowGUID()); c->SaveToDB(); _player->m_playerInfo->charterId[c->CharterType] = c->GetID(); _player->SaveToDB(false); Player * l = _player->GetMapMgr()->GetPlayer(c->GetLeader()); if(l == 0) return; WorldPacket data(SMSG_PETITION_SIGN_RESULTS, 100); data << item_guid << _player->GetGUID() << uint32(0); l->GetSession()->SendPacket(&data); data.clear(); data << item_guid << (uint64)c->GetLeader() << uint32(0); SendPacket(&data); }
void WorldSession::HandleCharterSign( WorldPacket & recv_data ) { uint64 item_guid; recv_data >> item_guid; Charter * c = objmgr.GetCharterByItemGuid(item_guid); if( c == NULL ) return; for(uint32 i = 0; i < c->SignatureCount; ++i) { if(c->Signatures[i] == _player->GetGUID()) { SendNotification(_player->GetSession()->LocalizedWorldSrv(79)); return; } } if(c->IsFull()) return; c->AddSignature(_player->GetLowGUID()); c->SaveToDB(); _player->m_charters[c->CharterType] = c; _player->SaveToDB(false); Player * l = _player->GetMapMgr()->GetPlayer(c->GetLeader()); if(l == 0) return; WorldPacket data(SMSG_PETITION_SIGN_RESULTS, 100); data << item_guid << _player->GetGUID() << uint32(0); l->GetSession()->SendPacket(&data); data.clear(); data << item_guid << (uint64)c->GetLeader() << uint32(0); SendPacket(&data); }
void WorldSession::HandleCharterTurnInCharter(WorldPacket & recv_data) { uint64 mooguid; recv_data >> mooguid; Charter * pCharter = objmgr.GetCharterByItemGuid(mooguid); if(!pCharter) return; if(pCharter->CharterType == CHARTER_TYPE_GUILD) { Charter * gc = pCharter; if(gc == NULL) return; if( gc->GetLeader() != _player->GetLowGUID() ) return; if(gc->SignatureCount < 9 && Config.MainConfig.GetBoolDefault("Server", "RequireAllSignatures", false)) { SendNotification("You don't have the required amount of signatures to turn in this petition."); return; } // dont know hacky or not but only solution for now // If everything is fine create guild Guild *pGuild = Guild::Create(); pGuild->CreateFromCharter(gc, this); // Destroy the charter _player->m_playerInfo->charterId[CHARTER_TYPE_GUILD] = 0; gc->Destroy(); _player->GetItemInterface()->RemoveItemAmt(ITEM_ENTRY_GUILD_CHARTER, 1); sHookInterface.OnGuildCreate(_player, pGuild); } else { /* Arena charter - TODO: Replace with correct messages */ ArenaTeam * team; uint32 type; uint32 i; uint32 icon, iconcolor, bordercolor, border, background; recv_data >> iconcolor >>icon >> bordercolor >> border >> background; switch(pCharter->CharterType) { case CHARTER_TYPE_ARENA_2V2: type = ARENA_TEAM_TYPE_2V2; break; case CHARTER_TYPE_ARENA_3V3: type = ARENA_TEAM_TYPE_3V3; break; case CHARTER_TYPE_ARENA_5V5: type = ARENA_TEAM_TYPE_5V5; break; default: SendNotification("Internal Error"); return; } if( pCharter->GetLeader() != _player->GetLowGUID() ) return; if(_player->m_playerInfo->arenaTeam[pCharter->CharterType-1] != NULL) { sChatHandler.SystemMessage(this, "You are already in an arena team."); return; } if(pCharter->SignatureCount < pCharter->GetNumberOfSlotsByType() && Config.MainConfig.GetBoolDefault("Server", "RequireAllSignatures", false)) { sChatHandler.SystemMessage(this, "You don't have the required amount of signatures to turn in this petition."); return; } team = new ArenaTeam(type, objmgr.GenerateArenaTeamId()); team->m_name = pCharter->GuildName; team->m_emblemColour = iconcolor; team->m_emblemStyle = icon; team->m_borderColour = bordercolor; team->m_borderStyle = border; team->m_backgroundColour = background; team->m_leader=_player->GetLowGUID(); team->m_stat_rating=1500; objmgr.AddArenaTeam(team); objmgr.UpdateArenaTeamRankings(); team->AddMember(_player->m_playerInfo); /* Add the members */ for(i = 0; i < pCharter->SignatureCount; ++i) { PlayerInfo * info = objmgr.GetPlayerInfo(pCharter->Signatures[i]); if(info) { team->AddMember(info); } } _player->GetItemInterface()->SafeFullRemoveItemByGuid(mooguid); _player->m_playerInfo->charterId[pCharter->CharterType] = 0; pCharter->Destroy(); } WorldPacket data(4); data.SetOpcode(SMSG_TURN_IN_PETITION_RESULTS); data << uint32(0); SendPacket( &data ); }