summaryrefslogtreecommitdiff
path: root/src/map/party.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-08-15 17:13:04 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-08-15 17:13:04 +0000
commitc25d6f5e6c3f092f70bf28cb0a3ac71e2ab89ead (patch)
treeb55395038c48dc99235e7385fbd43df5645e464a /src/map/party.c
parent86b35597e549392cf2db3974fc140a50e021b5a0 (diff)
downloadhercules-c25d6f5e6c3f092f70bf28cb0a3ac71e2ab89ead.tar.gz
hercules-c25d6f5e6c3f092f70bf28cb0a3ac71e2ab89ead.tar.bz2
hercules-c25d6f5e6c3f092f70bf28cb0a3ac71e2ab89ead.tar.xz
hercules-c25d6f5e6c3f092f70bf28cb0a3ac71e2ab89ead.zip
* Some serious code cleanups
- adjusted @reloadbattleconf to not depend on variable ordering - changed all battle vars to 'int' (removes pointless duplicit coding) - added min, max and default columns to battle config data structure - added properly bounded values for these columns (or at least tried to) - battle-conf loading will now complain if it finds unknown settings, and will reject values that are outside of the allowed range - added CHATROOM_TITLE_SIZE and CHATROOM_PASS_SIZE - partially cleaned up chatroom manipulation code * Fixed 'Job_Professer' typo in mage jobchange quest git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11017 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/party.c')
-rw-r--r--src/map/party.c53
1 files changed, 18 insertions, 35 deletions
diff --git a/src/map/party.c b/src/map/party.c
index 5117ce5ed..2427dab98 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -702,20 +702,20 @@ int party_send_xy_clear(struct party_data *p)
}
// exp share and added zeny share [Valaris]
-int party_exp_share(struct party_data *p,struct block_list *src,unsigned int base_exp,unsigned int job_exp,int zeny)
+int party_exp_share(struct party_data* p, struct block_list* src, unsigned int base_exp, unsigned int job_exp, int zeny)
{
struct map_session_data* sd[MAX_PARTY];
- int i;
- unsigned short c;
+ unsigned int i, c;
nullpo_retr(0, p);
- for (i = c = 0; i < MAX_PARTY; i++)
- if ((sd[c] = p->data[i].sd)!=NULL && sd[c]->bl.m == src->m && !pc_isdead(sd[c])) {
- if (battle_config.idle_no_share && (sd[c]->chatID || sd[c]->vender_id || (sd[c]->idletime < (last_tick - battle_config.idle_no_share))))
- continue;
- c++;
- }
+ // count the number of players eligible for exp sharing
+ for (i = c = 0; i < MAX_PARTY; i++) {
+ if( (sd[c] = p->data[i].sd) == NULL || sd[c]->bl.m != src->m || pc_isdead(sd[c]) ||
+ battle_config.idle_no_share && (sd[c]->chatID || sd[c]->vender_id || sd[c]->idletime < last_tick - battle_config.idle_no_share) )
+ continue;
+ c++;
+ }
if (c < 1)
return 0;
@@ -723,32 +723,15 @@ int party_exp_share(struct party_data *p,struct block_list *src,unsigned int bas
job_exp/=c;
zeny/=c;
- if (battle_config.party_even_share_bonus && c > 1) {
- unsigned short bonus =100 + battle_config.party_even_share_bonus*(c-1);
- if (base_exp) {
- if (base_exp/100 > UINT_MAX/bonus)
- base_exp= UINT_MAX; //Exp overflow
- else if (base_exp > 10000)
- base_exp = (base_exp/100)*bonus; //Calculation overflow protection
- else
- base_exp = base_exp*bonus/100;
- }
- if (job_exp) {
- if (job_exp/100 > UINT_MAX/bonus)
- job_exp = UINT_MAX;
- else if (job_exp > 10000)
- job_exp = (job_exp/100)*bonus;
- else
- job_exp = job_exp*bonus/100;
- }
- if (zeny) {
- if (zeny/100 > INT_MAX/bonus)
- zeny = INT_MAX;
- else if (zeny > 10000)
- zeny = (zeny/100)*bonus;
- else
- zeny = zeny*bonus/100;
- }
+ if (battle_config.party_even_share_bonus && c > 1)
+ {
+ double bonus = 100 + battle_config.party_even_share_bonus*(c-1);
+ if (base_exp)
+ base_exp = (unsigned int) cap_value(base_exp * bonus/100, 0, UINT_MAX);
+ if (job_exp)
+ job_exp = (unsigned int) cap_value(job_exp * bonus/100, 0, UINT_MAX);
+ if (zeny)
+ zeny = (unsigned int) cap_value(zeny * bonus/100, INT_MIN, INT_MAX);
}
for (i = 0; i < c; i++)