summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/mmo.h14
-rw-r--r--src/common/utils.c52
-rw-r--r--src/common/utils.h10
3 files changed, 74 insertions, 2 deletions
diff --git a/src/common/mmo.h b/src/common/mmo.h
index 07a05677f..d535d2874 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -632,11 +632,21 @@ enum fame_list_type {
RANKTYPE_PK = 3, //Not supported yet
};
-enum { //Change Guild Infos
+/**
+ * Guild Basic Information
+ * It is used to request changes via intif_guild_change_basicinfo in map-server and to
+ * signalize changes made in char-server via mapif_parse_GuildMemberInfoChange
+ **/
+enum guild_basic_info {
GBI_EXP = 1, ///< Guild Experience (EXP)
GBI_GUILDLV, ///< Guild level
GBI_SKILLPOINT, ///< Guild skillpoints
- GBI_SKILLLV, ///< Guild skill_lv ?? seem unused
+
+ /**
+ * Changes a skill level, struct guild_skill should be sent.
+ * All checks regarding max skill level should be done in _map-server_
+ **/
+ GBI_SKILLLV, ///< Guild skill_lv
};
enum { //Change Member Infos
diff --git a/src/common/utils.c b/src/common/utils.c
index 9a7d4971b..47747dd32 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -263,7 +263,59 @@ uint32 MakeDWord(uint16 word0, uint16 word1)
( (uint32)(word0 ) )|
( (uint32)(word1 << 0x10) );
}
+/*************************************
+* Big-endian compatibility functions *
+* From mapcache.c *
+*************************************/
+// Converts an int16 from current machine order to little-endian
+int16 MakeShortLE(int16 val)
+{
+ unsigned char buf[2];
+ buf[0] = (unsigned char)( (val & 0x00FF) );
+ buf[1] = (unsigned char)( (val & 0xFF00) >> 0x08 );
+ return *((int16*)buf);
+}
+
+// Converts an int32 from current machine order to little-endian
+int32 MakeLongLE(int32 val)
+{
+ unsigned char buf[4];
+ buf[0] = (unsigned char)( (val & 0x000000FF) );
+ buf[1] = (unsigned char)( (val & 0x0000FF00) >> 0x08 );
+ buf[2] = (unsigned char)( (val & 0x00FF0000) >> 0x10 );
+ buf[3] = (unsigned char)( (val & 0xFF000000) >> 0x18 );
+ return *((int32*)buf);
+}
+
+// Reads an uint16 in little-endian from the buffer
+uint16 GetUShort(const unsigned char* buf)
+{
+ return ( ((uint16)(buf[0])) )
+ |( ((uint16)(buf[1])) << 0x08 );
+}
+
+// Reads an uint32 in little-endian from the buffer
+uint32 GetULong(const unsigned char* buf)
+{
+ return ( ((uint32)(buf[0])) )
+ |( ((uint32)(buf[1])) << 0x08 )
+ |( ((uint32)(buf[2])) << 0x10 )
+ |( ((uint32)(buf[3])) << 0x18 );
+}
+
+// Reads an int32 in little-endian from the buffer
+int32 GetLong(const unsigned char* buf)
+{
+ return (int32)GetULong(buf);
+}
+
+// Reads a float (32 bits) from the buffer
+float GetFloat(const unsigned char* buf)
+{
+ uint32 val = GetULong(buf);
+ return *((float*)(void*)&val);
+}
/// calculates the value of A / B, in percent (rounded down)
unsigned int get_percentage(const unsigned int A, const unsigned int B)
diff --git a/src/common/utils.h b/src/common/utils.h
index 68dd01ac4..f89546b8a 100644
--- a/src/common/utils.h
+++ b/src/common/utils.h
@@ -36,6 +36,16 @@ extern uint16 GetWord(uint32 val, int idx);
extern uint16 MakeWord(uint8 byte0, uint8 byte1);
extern uint32 MakeDWord(uint16 word0, uint16 word1);
+//////////////////////////////////////////////////////////////////////////
+// Big-endian compatibility functions
+//////////////////////////////////////////////////////////////////////////
+extern int16 MakeShortLE(int16 val);
+extern int32 MakeLongLE(int32 val);
+extern uint16 GetUShort(const unsigned char* buf);
+extern uint32 GetULong(const unsigned char* buf);
+extern int32 GetLong(const unsigned char* buf);
+extern float GetFloat(const unsigned char* buf);
+
size_t hread(void * ptr, size_t size, size_t count, FILE * stream);
size_t hwrite(const void * ptr, size_t size, size_t count, FILE * stream);