summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/mmo.h15
-rw-r--r--src/common/utils.c22
-rw-r--r--src/common/utils.h1
3 files changed, 33 insertions, 5 deletions
diff --git a/src/common/mmo.h b/src/common/mmo.h
index 9bb9837ab..fe67d6efb 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -593,7 +593,7 @@ struct mmo_charstatus {
int mother;
int child;
- unsigned int base_exp,job_exp;
+ uint64 base_exp, job_exp;
int zeny;
int bank_vault;
@@ -612,10 +612,14 @@ struct mmo_charstatus {
int spear_faith, spear_calls;
int sword_faith, sword_calls;
- short weapon; // enum weapon_type
- short shield; // view-id
- short head_top,head_mid,head_bottom;
- short robe;
+ struct {
+ short weapon; ///< Weapon view sprite id.
+ short shield; ///< Shield view sprite id.
+ short head_top; ///< Top headgear view sprite id.
+ short head_mid; ///< Middle headgear view sprite id.
+ short head_bottom; ///< Bottom headgear view sprite id.
+ short robe; ///< Robe view sprite id.
+ } look;
char name[NAME_LENGTH];
int base_level, job_level;
@@ -1132,6 +1136,7 @@ enum ammo_type {
A_KUNAI, //7
A_CANNONBALL, //8
A_THROWWEAPON, //9
+ MAX_AMMO_TYPE
};
enum e_char_server_type {
diff --git a/src/common/utils.c b/src/common/utils.c
index bcfc153e3..0d76a885e 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -359,6 +359,28 @@ unsigned int get_percentage(const unsigned int A, const unsigned int B)
return (unsigned int)floor(result);
}
+/// calculates the value of A / B, in percent (rounded down)
+uint64 get_percentage64(const uint64 A, const uint64 B)
+{
+ double result;
+
+ if( B == 0 )
+ {
+ ShowError("get_percentage(): division by zero! (A=%"PRIu64",B=%"PRIu64")\n", A, B);
+ return ~0U;
+ }
+
+ result = 100 * ((double)A / (double)B);
+
+ if( result > UINT_MAX )
+ {
+ ShowError("get_percentage(): result percentage too high! (A=%"PRIu64",B=%"PRIu64",result=%g)\n", A, B, result);
+ return UINT_MAX;
+ }
+
+ return (uint64)floor(result);
+}
+
/**
* Applies a percentual rate modifier.
*
diff --git a/src/common/utils.h b/src/common/utils.h
index 9d3c323ef..e77c63cf2 100644
--- a/src/common/utils.h
+++ b/src/common/utils.h
@@ -44,6 +44,7 @@ bool exists(const char* filename);
/// calculates the value of A / B, in percent (rounded down)
unsigned int get_percentage(const unsigned int A, const unsigned int B);
+uint64 get_percentage64(const uint64 A, const uint64 B);
int64 apply_percentrate64(int64 value, int rate, int maxrate);
int apply_percentrate(int value, int rate, int maxrate);