summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-03-14 03:56:02 +0300
committerAndrei Karas <akaras@inbox.ru>2012-03-14 04:06:13 +0300
commit112d2ad1904051160822d1845d1418cca889c0d5 (patch)
tree9731934d9dc367f931c028158f3d26a670e18feb /src
parent02e9a62ce9a0f288804bfa2aa59c3a84b0376c4a (diff)
downloadManaVerse-112d2ad1904051160822d1845d1418cca889c0d5.tar.gz
ManaVerse-112d2ad1904051160822d1845d1418cca889c0d5.tar.bz2
ManaVerse-112d2ad1904051160822d1845d1418cca889c0d5.tar.xz
ManaVerse-112d2ad1904051160822d1845d1418cca889c0d5.zip
Add support for other gender.
Fix per gender and race items separation.
Diffstat (limited to 'src')
-rw-r--r--src/being.cpp29
-rw-r--r--src/being.h10
-rw-r--r--src/gui/charcreatedialog.cpp16
-rw-r--r--src/gui/charcreatedialog.h1
-rw-r--r--src/gui/register.cpp25
-rw-r--r--src/gui/register.h1
-rw-r--r--src/net/ea/beinghandler.cpp8
-rw-r--r--src/net/ea/guildhandler.cpp8
-rw-r--r--src/net/ea/loginhandler.cpp18
-rw-r--r--src/net/tmwa/beinghandler.cpp3
-rw-r--r--src/net/tmwa/charserverhandler.cpp2
-rw-r--r--src/net/tmwa/gamehandler.cpp2
-rw-r--r--src/net/tmwa/playerhandler.cpp4
-rw-r--r--src/resources/itemdb.cpp3
-rw-r--r--src/resources/iteminfo.cpp6
15 files changed, 108 insertions, 28 deletions
diff --git a/src/being.cpp b/src/being.cpp
index db8940662..15d93f251 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -2627,6 +2627,35 @@ void Being::updatePercentHP()
}
}
+int Being::genderToInt(Gender sex)
+{
+ switch (sex)
+ {
+ case GENDER_FEMALE:
+ case GENDER_UNSPECIFIED:
+ default:
+ return 0;
+ case GENDER_MALE:
+ return 1;
+ case GENDER_OTHER:
+ return 3;
+ }
+}
+
+Gender Being::intToGender(int sex)
+{
+ switch (sex)
+ {
+ case 0:
+ default:
+ return GENDER_FEMALE;
+ case 1:
+ return GENDER_MALE;
+ case 3:
+ return GENDER_OTHER;
+ }
+}
+
BeingEquipBackend::BeingEquipBackend(Being *being):
mBeing(being)
{
diff --git a/src/being.h b/src/being.h
index 7ad2199ff..19b7ccbb7 100644
--- a/src/being.h
+++ b/src/being.h
@@ -68,7 +68,8 @@ enum Gender
{
GENDER_MALE = 0,
GENDER_FEMALE = 1,
- GENDER_UNSPECIFIED = 2
+ GENDER_UNSPECIFIED = 2,
+ GENDER_OTHER = 3
};
@@ -101,8 +102,9 @@ class Being : public ActorSprite, public ConfigListener
FLAG_SHOP = 1,
FLAG_AWAY = 2,
FLAG_INACTIVE = 4,
+ FLAG_GENDER_OTHER = 32,
FLAG_GM = 64,
- FLAG_GENDER = 128,
+ FLAG_GENDER_MALE = 128,
FLAG_SPECIAL = 128 + 64
};
@@ -780,6 +782,10 @@ class Being : public ActorSprite, public ConfigListener
std::string getRaceName()
{ return mRaceName; }
+ static int genderToInt(Gender sex);
+
+ static Gender intToGender(int sex);
+
protected:
/**
* Sets the new path for this being.
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp
index 124476f1c..0b20952c8 100644
--- a/src/gui/charcreatedialog.cpp
+++ b/src/gui/charcreatedialog.cpp
@@ -124,15 +124,18 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
mCancelButton = new Button(_("Cancel"), "cancel", this);
mMale = new RadioButton(_("Male"), "gender");
mFemale = new RadioButton(_("Female"), "gender");
+ mOther = new RadioButton(_("Other"), "gender");
// Default to a Male character
mMale->setSelected(true);
mMale->setActionEventId("gender");
mFemale->setActionEventId("gender");
+ mOther->setActionEventId("gender");
mMale->addActionListener(this);
mFemale->addActionListener(this);
+ mOther->addActionListener(this);
mPlayerBox = new PlayerBox(mPlayer);
mPlayerBox->setWidth(74);
@@ -186,6 +189,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
mMale->setPosition(30, 120);
mFemale->setPosition(100, 120);
+ mOther->setPosition(170, 120);
add(mPlayerBox);
add(mNameField);
@@ -215,6 +219,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
add(mMale);
add(mFemale);
+ add(mOther);
center();
setVisible(true);
@@ -453,11 +458,19 @@ void CharCreateDialog::setFixedGender(bool fixed, Gender gender)
{
mFemale->setSelected(true);
mMale->setSelected(false);
+ mOther->setSelected(false);
}
- else
+ else if (gender == GENDER_MALE)
{
+ mFemale->setSelected(false);
mMale->setSelected(true);
+ mOther->setSelected(false);
+ }
+ else
+ {
mFemale->setSelected(false);
+ mMale->setSelected(false);
+ mOther->setSelected(true);
}
mPlayer->setGender(gender);
@@ -466,6 +479,7 @@ void CharCreateDialog::setFixedGender(bool fixed, Gender gender)
{
mMale->setVisible(false);
mFemale->setVisible(false);
+ mOther->setVisible(false);
}
}
diff --git a/src/gui/charcreatedialog.h b/src/gui/charcreatedialog.h
index ceafcc08e..8be421543 100644
--- a/src/gui/charcreatedialog.h
+++ b/src/gui/charcreatedialog.h
@@ -115,6 +115,7 @@ class CharCreateDialog : public Window, public gcn::ActionListener
gcn::RadioButton *mMale;
gcn::RadioButton *mFemale;
+ gcn::RadioButton *mOther;
std::vector<gcn::Slider*> mAttributeSlider;
std::vector<gcn::Label*> mAttributeLabel;
diff --git a/src/gui/register.cpp b/src/gui/register.cpp
index 4f696dc9d..eebbfa603 100644
--- a/src/gui/register.cpp
+++ b/src/gui/register.cpp
@@ -67,6 +67,7 @@ RegisterDialog::RegisterDialog(LoginData *data):
mEmailField(nullptr),
mMaleButton(nullptr),
mFemaleButton(nullptr),
+ mOtherButton(nullptr),
mWrongDataNoticeListener(new WrongDataNoticeListener),
mLoginData(data)
{
@@ -97,8 +98,18 @@ RegisterDialog::RegisterDialog(LoginData *data):
{
mMaleButton = new RadioButton(_("Male"), "sex", true);
mFemaleButton = new RadioButton(_("Female"), "sex", false);
- placer(1, row, mMaleButton);
- placer(2, row, mFemaleButton);
+ if (serverVersion >= 5)
+ {
+ mOtherButton = new RadioButton(_("Other"), "sex", false);
+ placer(0, row, mMaleButton);
+ placer(1, row, mFemaleButton);
+ placer(2, row, mOtherButton);
+ }
+ else
+ {
+ placer(1, row, mMaleButton);
+ placer(2, row, mFemaleButton);
+ }
row++;
}
@@ -235,9 +246,13 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
mLoginData->username = mUserField->getText();
mLoginData->password = mPasswordField->getText();
- if (mFemaleButton)
- mLoginData->gender = mFemaleButton->isSelected() ?
- GENDER_FEMALE : GENDER_MALE;
+ if (mFemaleButton && mFemaleButton->isSelected())
+ mLoginData->gender = GENDER_FEMALE;
+ else if (mOtherButton && mOtherButton->isSelected())
+ mLoginData->gender = GENDER_OTHER;
+ else
+ mLoginData->gender = GENDER_MALE;
+
if (mEmailField)
mLoginData->email = mEmailField->getText();
mLoginData->registerLogin = true;
diff --git a/src/gui/register.h b/src/gui/register.h
index ecda27d28..606050428 100644
--- a/src/gui/register.h
+++ b/src/gui/register.h
@@ -96,6 +96,7 @@ class RegisterDialog : public Window, public gcn::ActionListener,
gcn::Button *mCancelButton;
gcn::RadioButton *mMaleButton;
gcn::RadioButton *mFemaleButton;
+ gcn::RadioButton *mOtherButton;
WrongDataNoticeListener *mWrongDataNoticeListener;
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index f1d608717..f669163be 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -259,8 +259,8 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
if (dstBeing->getType() == ActorSprite::PLAYER)
{
- gender &= 1;
- dstBeing->setGender((gender == 0) ? GENDER_FEMALE : GENDER_MALE);
+ gender &= 3;
+ dstBeing->setGender(Being::intToGender(gender));
// Set these after the gender, as the sprites may be gender-specific
setSprite(dstBeing, EA_SPRITE_HAIR, hairStyle * -1,
ColorDB::getHairColor(hairColor));
@@ -283,13 +283,15 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
case 3:
dstBeing->setGender(GENDER_MALE);
break;
+ case 4:
+ dstBeing->setGender(GENDER_OTHER);
+ break;
default:
dstBeing->setGender(GENDER_UNSPECIFIED);
break;
}
}
-
if (!visible)
{
Uint16 srcX, srcY, dstX, dstY;
diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp
index 96a361838..950f26b03 100644
--- a/src/net/ea/guildhandler.cpp
+++ b/src/net/ea/guildhandler.cpp
@@ -251,13 +251,7 @@ void GuildHandler::processGuildMemberList(Net::MessageIn &msg)
m->setOnline(online);
m->setID(id);
m->setCharId(charId);
- if (!gender)
- m->setGender(GENDER_FEMALE);
- else if (gender == 1)
- m->setGender(GENDER_MALE);
- else
- m->setGender(GENDER_UNSPECIFIED);
-
+ m->setGender(Being::intToGender(gender));
m->setLevel(level);
m->setExp(exp);
m->setPos(pos);
diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp
index 560893a4f..d35e5a0d5 100644
--- a/src/net/ea/loginhandler.cpp
+++ b/src/net/ea/loginhandler.cpp
@@ -97,7 +97,21 @@ void LoginHandler::registerAccount(LoginData *loginData)
return;
std::string username = loginData->username;
- username.append((loginData->gender == GENDER_FEMALE) ? "_F" : "_M");
+ switch (loginData->gender)
+ {
+ case GENDER_FEMALE:
+ username.append("_F");
+ break;
+ case GENDER_MALE:
+ username.append("_M");
+ break;
+ case GENDER_OTHER:
+ username.append("_O");
+ break;
+ case GENDER_UNSPECIFIED:
+ default:
+ break;
+ }
sendLoginRegister(username, loginData->password);
}
@@ -181,7 +195,7 @@ void LoginHandler::processLoginData(Net::MessageIn &msg)
// msg.skip(30); // unknown
// reserve bits for future usage
- mToken.sex = (msg.readInt8() & 1) ? GENDER_MALE : GENDER_FEMALE;
+ mToken.sex = Being::intToGender(msg.readInt8() & 3);
for (int i = 0; i < worldCount; i++)
{
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index 8d279fc32..5eb02d299 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -515,8 +515,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType)
dstBeing->setStatusEffectBlock(32, msg.readInt16()); // opt3
msg.readInt8(); // karma
// reserving bit for future usage
- dstBeing->setGender(((msg.readInt8() & 1) == 0)
- ? GENDER_FEMALE : GENDER_MALE);
+ dstBeing->setGender(Being::intToGender(msg.readInt8() & 3));
// Set these after the gender, as the sprites may be gender-specific
dstBeing->setSprite(SPRITE_WEAPON, weapon, "", 1, true);
diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp
index 1bee91144..6202070bb 100644
--- a/src/net/tmwa/charserverhandler.cpp
+++ b/src/net/tmwa/charserverhandler.cpp
@@ -333,7 +333,7 @@ void CharServerHandler::connect()
outMsg.writeInt16(CLIENT_PROTOCOL_VERSION);
else
outMsg.writeInt16(CLIENT_TMW_PROTOCOL_VERSION);
- outMsg.writeInt8((token.sex == GENDER_MALE) ? 1 : 0);
+ outMsg.writeInt8(Being::genderToInt(token.sex));
// We get 4 useless bytes before the real answer comes in (what are these?)
mNetwork->skip(4);
diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp
index 5acf9ae6c..2496898d1 100644
--- a/src/net/tmwa/gamehandler.cpp
+++ b/src/net/tmwa/gamehandler.cpp
@@ -125,7 +125,7 @@ void GameHandler::connect()
outMsg.writeInt32(mCharID);
outMsg.writeInt32(token.session_ID1);
outMsg.writeInt32(token.session_ID2);
- outMsg.writeInt8((token.sex == GENDER_MALE) ? 1 : 0);
+ outMsg.writeInt8(Being::genderToInt(token.sex));
/*
if (player_node)
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index a63af770a..eb9dac6f0 100644
--- a/src/net/tmwa/playerhandler.cpp
+++ b/src/net/tmwa/playerhandler.cpp
@@ -259,8 +259,10 @@ void PlayerHandler::processOnlineList(Net::MessageIn &msg)
{
if (config.getBoolValue("showgender"))
{
- if (status & Being::FLAG_GENDER)
+ if (status & Being::FLAG_GENDER_MALE)
gender = GENDER_MALE;
+ else if (status & Being::FLAG_GENDER_OTHER)
+ gender = GENDER_OTHER;
else
gender = GENDER_FEMALE;
}
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 3aadc662e..eb6d4a6b8 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -169,6 +169,7 @@ void ItemDB::load()
std::string errFile = paths.getStringValue("spriteErrorFile");
mUnknown->setSprite(errFile, GENDER_MALE, 0);
mUnknown->setSprite(errFile, GENDER_FEMALE, 0);
+ mUnknown->setSprite(errFile, GENDER_OTHER, 0);
mUnknown->addTag(mTags["All"]);
XML::Document doc("items.xml");
@@ -604,6 +605,8 @@ void loadSpriteRef(ItemInfo *itemInfo, XmlNodePtr node)
itemInfo->setSprite(filename, GENDER_MALE, race);
if (gender == "female" || gender == "unisex")
itemInfo->setSprite(filename, GENDER_FEMALE, race);
+ if (gender == "other" || gender == "unisex")
+ itemInfo->setSprite(filename, GENDER_OTHER, race);
}
void loadSoundRef(ItemInfo *itemInfo, XmlNodePtr node)
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index 15454dccd..2bf71bcec 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -112,13 +112,13 @@ const std::string &ItemInfo::getSprite(Gender gender, int race) const
{
static const std::string empty("");
std::map<int, std::string>::const_iterator i =
- mAnimationFiles.find(static_cast<int>(gender) * 2 + race);
+ mAnimationFiles.find(static_cast<int>(gender) + race * 4);
if (i != mAnimationFiles.end())
return i->second;
if (serverVersion > 0)
{
- i = mAnimationFiles.find(static_cast<int>(gender) * 2);
+ i = mAnimationFiles.find(static_cast<int>(gender));
if (i != mAnimationFiles.end())
return i->second;
}
@@ -325,5 +325,5 @@ int ItemInfo::getDrawPriority(int direction) const
void ItemInfo::setSprite(const std::string &animationFile,
Gender gender, int race)
{
- mAnimationFiles[static_cast<int>(gender) * 2 + race] = animationFile;
+ mAnimationFiles[static_cast<int>(gender) + race * 4] = animationFile;
}