Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //After
- Player::Player(ProtocolGame* p) :
- Creature()
- {
- //Add this
- nextSpectator = 0;
- cast.isCasting = false;
- //After
- Player::~Player()
- {
- //Add this
- kickCastViewers();
- //After
- setWriteItem(nullptr);
- setEditHouse(nullptr);
- }
- //Add this
- bool Player::getCastingState() const {
- return cast.isCasting;
- }
- void Player::setCasting(bool castStatus) {
- cast.isCasting = castStatus;
- }
- PlayerCast Player::getCast() {
- return cast;
- }
- void Player::setCastPassword(std::string password_) {
- cast.password = password_;
- }
- void Player::addCastViewer(ProtocolGame* pg) {
- cSpectators[nextSpectator] = pg;
- nextSpectator++;
- std::stringstream ss;
- ss << "Spectator " << cast.curId;
- pg->viewerName = ss.str().c_str();
- cast.curId++;
- this->sendChannelEvent(this->cast.mCastChannelId, pg->viewerName, CHANNELEVENT_JOIN);
- }
- void Player::removeCastViewer(uint32_t id) {
- cSpectators.erase(id);
- }
- uint32_t Player::getCastIpByName(std::string n) {
- for (AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it)
- if (it->second->getViewerName() == n && it->second->getPlayer() == this)
- return it->second->getIP();
- return 0;
- }
- uint32_t Player::getCastViewerCount() const {
- uint32_t count = 0;
- for(AutoList<ProtocolGame>::const_iterator it = cSpectators.begin(); it != cSpectators.end(); ++it) {
- Connection_ptr tmpcon = it->second->getConnection();
- if(tmpcon) {
- //if (tmpcon->haveConnection())
- count++;
- }
- }
- return count;
- }
- void Player::kickCastViewers() {
- for (auto it : cSpectators) {
- it.second->disconnect();
- it.second->unRef();
- it.second->player = 0;
- //removeCastViewer(it.first);
- }
- cast = PlayerCast();
- cSpectators.clear();
- }
- bool Player::kickCastViewerByName(std::string n) {
- for (auto it = cSpectators.begin(); it != cSpectators.end(); it++)
- {
- if (it->second->viewerName == n)
- {
- if (it->second->player)
- {
- it->second->disconnect();
- it->second->unRef();
- it->second->player = 0;
- cSpectators.erase(it);
- return true;
- }
- }
- }
- return false;
- };
- //After
- switch (playerinfo) {
- //Add this
- case PLAYERINFO_LEVEL: return level;
- //After
- void Player::sendStats()
- {
- //Add this
- for (auto it : cSpectators)
- it.second->sendStats();
- //After
- lastPing = timeNow;
- //Add this
- for (auto it : cSpectators)
- it.second->sendPing();
- //After
- } else if (openContainer.index >= container->capacity()) {
- item = container->getItemByIndex(openContainer.index - 1);
- }
- //Add this
- for (auto spec : cSpectators)
- spec.second->sendAddContainerItem(it.first, slot, item);
- //After
- if (slot >= pageEnd) {
- continue;
- }
- //Add this
- for (auto spec : cSpectators)
- spec.second->sendUpdateContainerItem(it.first, slot, newItem);
- //After
- if (firstIndex > 0 && firstIndex >= container->size() - 1) {
- firstIndex -= container->capacity();
- sendContainer(it.first, container, false, firstIndex);
- }
- //Add this
- for (auto spec : cSpectators)
- spec.second->sendRemoveContainerItem(it.first, std::max<uint16_t>(slot, firstIndex), container->getItemByIndex(container->capacity() + firstIndex));
- //Replace
- client->sendCloseContainer(it.first);
- //With
- sendCloseContainer(it.first);
- //Replace
- client->sendContainer(it.first, container, hasParent, openContainer.index);
- //With
- sendContainer(it.first, container, hasParent, openContainer.index);
- //After
- for (uint32_t containerId : closeList) {
- closeContainer(containerId);
- //Add this
- for (auto it : cSpectators) //Cast System Felipe Monteiro
- it.second->sendCloseContainer(containerId);
Advertisement
Add Comment
Please, Sign In to add comment