summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2011-12-27 05:59:55 +0800
committerErik Schilling <ablu.erikschilling@googlemail.com>2012-01-02 19:59:31 +0800
commite4a7536e7ca14dcc257d60f8562a9dab61c4fd34 (patch)
treef4f1e8630b1fc15cf2bc9bfd13f25a69bb4c99cc /src/common
parent646fb10397e440ab67fb5a678bf034c53b050109 (diff)
downloadmanaserv-e4a7536e7ca14dcc257d60f8562a9dab61c4fd34.tar.gz
manaserv-e4a7536e7ca14dcc257d60f8562a9dab61c4fd34.tar.xz
manaserv-e4a7536e7ca14dcc257d60f8562a9dab61c4fd34.zip
Made all beings capable of having a gender
Reviewed-by: o11c, bjorn, Bertram.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/defines.h2
-rw-r--r--src/common/manaserv_protocol.h39
2 files changed, 39 insertions, 2 deletions
diff --git a/src/common/defines.h b/src/common/defines.h
index 140a692..ca59631 100644
--- a/src/common/defines.h
+++ b/src/common/defines.h
@@ -21,6 +21,8 @@
#ifndef DEFINES_H
#define DEFINES_H
+#include "common/manaserv_protocol.h"
+
// Precomputed square-root of 2.
#define SQRT2 1.4142135623730950488
diff --git a/src/common/manaserv_protocol.h b/src/common/manaserv_protocol.h
index 13e7f8c..7ad2bc1 100644
--- a/src/common/manaserv_protocol.h
+++ b/src/common/manaserv_protocol.h
@@ -22,6 +22,10 @@
#ifndef MANASERV_PROTOCOL_H
#define MANASERV_PROTOCOL_H
+#include <string>
+
+#include "utils/string.h"
+
namespace ManaServ {
enum {
@@ -112,8 +116,8 @@ enum {
PGMSG_RESPAWN = 0x0180, // -
GPMSG_BEING_ENTER = 0x0200, // B type, W being id, B action, W*2 position, B direction
// character: S name, B hair style, B hair color, B gender, B sprite layers changed, { B slot type, W item id }*
- // monster: W type id
- // npc: W type id
+ // monster: W type id gender
+ // npc: W type id gender
GPMSG_BEING_LEAVE = 0x0201, // W being id
GPMSG_ITEM_APPEAR = 0x0202, // W item id, W*2 position
GPMSG_BEING_LOOKS_CHANGE = 0x0210, // B sprite layers changed, { B slot type, W item id }*
@@ -441,6 +445,37 @@ enum BeingGender
GENDER_UNSPECIFIED
};
+// Helper functions for gender
+
+/**
+* Helper function for getting gender by int
+*/
+inline ManaServ::BeingGender getGender(int gender)
+{
+ switch (gender)
+ {
+ case 0:
+ return ManaServ::GENDER_MALE;
+ case 1:
+ return ManaServ::GENDER_FEMALE;
+ default:
+ return ManaServ::GENDER_UNSPECIFIED;
+ }
+};
+
+/**
+* Helper function for getting gender by string
+*/
+inline ManaServ::BeingGender getGender(std::string gender)
+{
+ if (utils::toLower(gender) == "male")
+ return ManaServ::GENDER_MALE;
+ else if (utils::toLower(gender) == "female")
+ return ManaServ::GENDER_FEMALE;
+ else
+ return ManaServ::GENDER_UNSPECIFIED;
+};
+
} // namespace ManaServ
#endif // MANASERV_PROTOCOL_H