viewing paste Unknown #13639 | C++

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
/*====================================================
 * 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;
}
 
Viewed 401 times, submitted by Pneuma.