/*====================================================
* Return taxed experience from player sd to guild
*---------------------------------------------------*/
unsigned int guild_payexp(struct map_session_data *sd,unsigned int exp) {
struct guild *g;
struct guild_expcache *c;
int per;
nullpo_ret(sd);
if (!exp) return 0;
if (sd->status.guild_id == 0 ||
(g = sd->guild) == NULL ||
(per = guild_getposition(g,sd)) < 0 ||
(per = g->position[per].exp_mode) < 1)
return 0;
if (per < 100)
exp = exp * per / 100;
//Otherwise tax everything.
c = db_data2ptr(guild_expcache_db->ensure(guild_expcache_db, db_i2key(sd->status.char_id), create_expcache, sd));
if (c->exp > UINT64_MAX - exp)
c->exp = UINT64_MAX;
else
c->exp += exp;
return exp;
}
/*====================================================
* Player sd pay a tribute experience to his guild
* Add this experience to guild exp
* [Celest]
*---------------------------------------------------*/
int guild_getexp(struct map_session_data *sd,int exp) {
struct guild_expcache *c;
nullpo_ret(sd);
if (sd->status.guild_id == 0 || sd->guild == NULL)
return 0;
c = db_data2ptr(guild_expcache_db->ensure(guild_expcache_db, db_i2key(sd->status.char_id), create_expcache, sd));
if (c->exp > UINT64_MAX - exp)
c->exp = UINT64_MAX;
else
c->exp += exp;
return exp;
}