Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pvp channel support #13

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/being/being.cpp
Expand Up @@ -213,6 +213,7 @@ Being::Being(const BeingId id,
mMaxHit(0),
mCriticalHit(0),
mPvpRank(0),
mPvpChannel(0),
mNumber(100),
mUsageCounter(1),
mKarma(0),
Expand Down Expand Up @@ -2349,6 +2350,7 @@ bool Being::updateFromCache()
setGuildName(entry->getGuildName());
setLevel(entry->getLevel());
setPvpRank(entry->getPvpRank());
setPvpChannel(entry->getPvpChannel());
setIp(entry->getIp());

mAdvanced = entry->isAdvanced();
Expand Down Expand Up @@ -2404,6 +2406,7 @@ void Being::addToCache() const
entry->setGuildName(getGuildName());
entry->setTime(cur_time);
entry->setPvpRank(getPvpRank());
entry->setPvpChannel(getPvpChannel());
entry->setIp(getIp());
entry->setAdvanced(isAdvanced());
if (isAdvanced())
Expand Down
7 changes: 7 additions & 0 deletions src/being/being.h
Expand Up @@ -676,6 +676,12 @@ class Being notfinal : public ActorSprite,
void setPvpRank(const unsigned int rank)
{ mPvpRank = rank; }

unsigned int getPvpChannel() const A_WARN_UNUSED
{ return mPvpChannel; }

void setPvpChannel(const unsigned int channel)
{ mPvpChannel = channel; }

void setHP(const int n);

void setMaxHP(const int hp);
Expand Down Expand Up @@ -1100,6 +1106,7 @@ class Being notfinal : public ActorSprite,
int mMaxHit;
int mCriticalHit;
unsigned int mPvpRank;
unsigned int mPvpChannel;
unsigned int mNumber;
int mUsageCounter;
int mKarma;
Expand Down
8 changes: 8 additions & 0 deletions src/being/beingcacheentry.h
Expand Up @@ -38,6 +38,7 @@ class BeingCacheEntry final
mId(id),
mLevel(0),
mPvpRank(0),
mPvpChannel(0),
mTime(0),
mFlags(0),
mIsAdvanced(false)
Expand Down Expand Up @@ -96,6 +97,12 @@ class BeingCacheEntry final
void setPvpRank(const int r)
{ mPvpRank = r; }

unsigned getPvpChannel() const
{ return mPvpChannel; }

void setPvpChannel(const int r)
{ mPvpChannel = r; }

std::string getIp() const
{ return mIp; }

Expand All @@ -122,6 +129,7 @@ class BeingCacheEntry final
BeingId mId; /**< Unique sprite id */
int mLevel;
unsigned int mPvpRank;
unsigned int mPvpChannel;
int mTime;
int mFlags;
bool mIsAdvanced;
Expand Down
22 changes: 21 additions & 1 deletion src/net/ea/beinghandler.cpp
Expand Up @@ -415,12 +415,32 @@ void BeingHandler::processPvpSet(Net::MessageIn &msg)
BLOCK_START("BeingHandler::processPvpSet")
const BeingId id = msg.readBeingId("being id");
const int rank = msg.readInt32("rank");
msg.readInt32("num");
const int channel = msg.readInt32("channel");
if (actorManager)
{
Being *const dstBeing = actorManager->findBeing(id);
if (dstBeing)
{
dstBeing->setPvpRank(rank);
dstBeing->setPvpChannel(channel);
if (id != localPlayer->getId())
{
if(channel == 0 ||
dstBeing->getPvpChannel() != localPlayer->getPvpChannel())
{
dstBeing->setEnemy(false);
dstBeing->addToCache();
dstBeing->updateColors();
}
else if (dstBeing->getPvpChannel() == localPlayer->getPvpChannel()
&& channel > 0)
{
dstBeing->setEnemy(true);
dstBeing->addToCache();
dstBeing->updateColors();
}
}
}
}
BLOCK_END("BeingHandler::processPvpSet")
}
Expand Down