Пример #1
0
// ギルドのEXP上納
unsigned int guild_payexp(struct map_session_data *sd,unsigned int exp)
{
	struct guild *g;
	struct guild_expcache *c;
	int per;
	
	nullpo_retr(0, sd);

	if (!exp) return 0;
	
	if (sd->status.guild_id == 0 ||
		(g = guild_search(sd->status.guild_id)) == NULL ||
		(per = guild_getposition(sd,g)) < 0 ||
		(per = g->position[per].exp_mode) < 1)
		return 0;
	

	if (per < 100)
		exp = (unsigned int) exp * per / 100;
	//Otherwise tax everything.
	
	c = guild_expcache_db->ensure(guild_expcache_db, i2key(sd->status.char_id), create_expcache, sd);

	if (c->exp > UINT_MAX - exp)
		c->exp = UINT_MAX;
	else
		c->exp += exp;
	
	return exp;
}
Пример #2
0
// Celest
int guild_getexp(struct map_session_data *sd,int exp)
{
	struct guild *g;
	struct guild_expcache *c;
	nullpo_retr(0, sd);

	if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL)
		return 0;

	c = guild_expcache_db->ensure(guild_expcache_db, i2key(sd->status.char_id), create_expcache, sd);
	if (c->exp > UINT_MAX - exp)
		c->exp = UINT_MAX;
	else
		c->exp += exp;
	return exp;
}