本文整理汇总了C++中Being::getGender方法的典型用法代码示例。如果您正苦于以下问题:C++ Being::getGender方法的具体用法?C++ Being::getGender怎么用?C++ Being::getGender使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Being
的用法示例。
在下文中一共展示了Being::getGender方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: informPlayer
/**
* Informs a player of what happened around the character.
*/
static void informPlayer(MapComposite *map, Character *p)
{
MessageOut moveMsg(GPMSG_BEINGS_MOVE);
MessageOut damageMsg(GPMSG_BEINGS_DAMAGE);
const Point &pold = p->getOldPosition(), ppos = p->getPosition();
int pid = p->getPublicID(), pflags = p->getUpdateFlags();
int visualRange = Configuration::getValue("game_visualRange", 448);
// Inform client about activities of other beings near its character
for (BeingIterator it(map->getAroundBeingIterator(p, visualRange));
it; ++it)
{
Being *o = *it;
const Point &oold = o->getOldPosition(), opos = o->getPosition();
int otype = o->getType();
int oid = o->getPublicID(), oflags = o->getUpdateFlags();
int flags = 0;
// Check if the character p and the moving object o are around.
bool wereInRange = pold.inRangeOf(oold, visualRange) &&
!((pflags | oflags) & UPDATEFLAG_NEW_ON_MAP);
bool willBeInRange = ppos.inRangeOf(opos, visualRange);
if (!wereInRange && !willBeInRange)
{
// Nothing to report: o and p are far away from each other.
continue;
}
if (wereInRange && willBeInRange)
{
// Send attack messages.
if ((oflags & UPDATEFLAG_ATTACK) && oid != pid)
{
MessageOut AttackMsg(GPMSG_BEING_ATTACK);
AttackMsg.writeInt16(oid);
AttackMsg.writeInt8(o->getDirection());
AttackMsg.writeInt8(static_cast< Being * >(o)->getAttackId());
gameHandler->sendTo(p, AttackMsg);
}
// Send action change messages.
if ((oflags & UPDATEFLAG_ACTIONCHANGE))
{
MessageOut ActionMsg(GPMSG_BEING_ACTION_CHANGE);
ActionMsg.writeInt16(oid);
ActionMsg.writeInt8(static_cast< Being * >(o)->getAction());
gameHandler->sendTo(p, ActionMsg);
}
// Send looks change messages.
if (oflags & UPDATEFLAG_LOOKSCHANGE)
{
MessageOut LooksMsg(GPMSG_BEING_LOOKS_CHANGE);
LooksMsg.writeInt16(oid);
Character * c = static_cast<Character * >(o);
serializeLooks(c, LooksMsg);
LooksMsg.writeInt16(c->getHairStyle());
LooksMsg.writeInt16(c->getHairColor());
LooksMsg.writeInt16(c->getGender());
gameHandler->sendTo(p, LooksMsg);
}
// Send emote messages.
if (oflags & UPDATEFLAG_EMOTE)
{
int emoteId = o->getLastEmote();
if (emoteId > -1)
{
MessageOut EmoteMsg(GPMSG_BEING_EMOTE);
EmoteMsg.writeInt16(oid);
EmoteMsg.writeInt16(emoteId);
gameHandler->sendTo(p, EmoteMsg);
}
}
// Send direction change messages.
if (oflags & UPDATEFLAG_DIRCHANGE)
{
MessageOut DirMsg(GPMSG_BEING_DIR_CHANGE);
DirMsg.writeInt16(oid);
DirMsg.writeInt8(o->getDirection());
gameHandler->sendTo(p, DirMsg);
}
// Send damage messages.
if (o->canFight())
{
Being *victim = static_cast< Being * >(o);
const Hits &hits = victim->getHitsTaken();
for (Hits::const_iterator j = hits.begin(),
j_end = hits.end(); j != j_end; ++j)
{
damageMsg.writeInt16(oid);
damageMsg.writeInt16(*j);
//.........这里部分代码省略.........
示例2: handleMessage
void PartyHandler::handleMessage(MessageIn *msg)
{
switch (msg->getId())
{
case SMSG_PARTY_CREATE:
mParty->createResponse(msg->readInt8());
break;
case SMSG_PARTY_INFO:
break;
case SMSG_PARTY_INVITE:
{
std::string nick = msg->readString(24);
int status = msg->readInt8();
mParty->inviteResponse(nick, status);
break;
}
case SMSG_PARTY_INVITED:
{
int id = msg->readInt32();
Being *being = beingManager->findBeing(id);
if (!being)
{
break;
}
std::string nick;
int gender = 0;
std::string partyName = "";
if (being->getType() != Being::PLAYER)
{
nick = "";
}
else
{
nick = being->getName();
gender = being->getGender();
partyName = msg->readString(24);
}
mParty->invitedAsk(nick, gender, partyName);
break;
}
case SMSG_PARTY_SETTINGS:
break;
case SMSG_PARTY_MEMBER_INFO:
break;
case SMSG_PARTY_LEAVE:
{
/*int id = */msg->readInt32();
std::string nick = msg->readString(24);
/*int fail = */msg->readInt8();
mParty->leftResponse(nick);
break;
}
case SMSG_PARTY_UPDATE_HP:
break;
case SMSG_PARTY_UPDATE_COORDS:
break;
case SMSG_PARTY_MESSAGE:
{ // new block to enable local variables
int msgLength = msg->readInt16() - 8;
if (msgLength <= 0)
return;
int id = msg->readInt32();
Being *being = beingManager->findBeing(id);
std::string chatMsg = msg->readString(msgLength);
mParty->receiveChat(being, chatMsg);
}
break;
}
}