Replace macro max and min, by some inline functions :
-To avoid having long operation repeated twice, peoples shouldn'tuse long operation into does macro but they do so... -To avoid double increment or thing like such. -Yes this involve some implicite cast sometime, but that still better then redo 10 dereference...
This commit is contained in:
parent
b480cb3d47
commit
214ff17c19
@ -1550,7 +1550,7 @@ int char_delete_char_sql(uint32 char_id){
|
|||||||
Sql_GetData(sql_handle, 8, &data, NULL); mother_id = atoi(data);
|
Sql_GetData(sql_handle, 8, &data, NULL); mother_id = atoi(data);
|
||||||
Sql_GetData(sql_handle, 9, &data, NULL); elemental_id = atoi(data);
|
Sql_GetData(sql_handle, 9, &data, NULL); elemental_id = atoi(data);
|
||||||
|
|
||||||
Sql_EscapeStringLen(sql_handle, esc_name, name, min(len, NAME_LENGTH));
|
Sql_EscapeStringLen(sql_handle, esc_name, name, zmin(len, NAME_LENGTH));
|
||||||
Sql_FreeResult(sql_handle);
|
Sql_FreeResult(sql_handle);
|
||||||
|
|
||||||
//check for config char del condition [Lupus]
|
//check for config char del condition [Lupus]
|
||||||
@ -1715,16 +1715,16 @@ int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p)
|
|||||||
|
|
||||||
buf = WBUFP(buffer,0);
|
buf = WBUFP(buffer,0);
|
||||||
WBUFL(buf,0) = p->char_id;
|
WBUFL(buf,0) = p->char_id;
|
||||||
WBUFL(buf,4) = min(p->base_exp, INT32_MAX);
|
WBUFL(buf,4) = umin(p->base_exp, INT32_MAX);
|
||||||
WBUFL(buf,8) = p->zeny;
|
WBUFL(buf,8) = p->zeny;
|
||||||
WBUFL(buf,12) = min(p->job_exp, INT32_MAX);
|
WBUFL(buf,12) = umin(p->job_exp, INT32_MAX);
|
||||||
WBUFL(buf,16) = p->job_level;
|
WBUFL(buf,16) = p->job_level;
|
||||||
WBUFL(buf,20) = 0; // probably opt1
|
WBUFL(buf,20) = 0; // probably opt1
|
||||||
WBUFL(buf,24) = 0; // probably opt2
|
WBUFL(buf,24) = 0; // probably opt2
|
||||||
WBUFL(buf,28) = p->option;
|
WBUFL(buf,28) = p->option;
|
||||||
WBUFL(buf,32) = p->karma;
|
WBUFL(buf,32) = p->karma;
|
||||||
WBUFL(buf,36) = p->manner;
|
WBUFL(buf,36) = p->manner;
|
||||||
WBUFW(buf,40) = min(p->status_point, INT16_MAX);
|
WBUFW(buf,40) = umin(p->status_point, INT16_MAX);
|
||||||
WBUFL(buf,42) = p->hp;
|
WBUFL(buf,42) = p->hp;
|
||||||
WBUFL(buf,46) = p->max_hp;
|
WBUFL(buf,46) = p->max_hp;
|
||||||
offset+=4;
|
offset+=4;
|
||||||
@ -1745,7 +1745,7 @@ int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p)
|
|||||||
WBUFW(buf,56) = p->option&(0x20|0x80000|0x100000|0x200000|0x400000|0x800000|0x1000000|0x2000000|0x4000000|0x8000000) ? 0 : p->weapon;
|
WBUFW(buf,56) = p->option&(0x20|0x80000|0x100000|0x200000|0x400000|0x800000|0x1000000|0x2000000|0x4000000|0x8000000) ? 0 : p->weapon;
|
||||||
|
|
||||||
WBUFW(buf,58) = p->base_level;
|
WBUFW(buf,58) = p->base_level;
|
||||||
WBUFW(buf,60) = min(p->skill_point, INT16_MAX);
|
WBUFW(buf,60) = umin(p->skill_point, INT16_MAX);
|
||||||
WBUFW(buf,62) = p->head_bottom;
|
WBUFW(buf,62) = p->head_bottom;
|
||||||
WBUFW(buf,64) = p->shield;
|
WBUFW(buf,64) = p->shield;
|
||||||
WBUFW(buf,66) = p->head_top;
|
WBUFW(buf,66) = p->head_top;
|
||||||
@ -1753,12 +1753,12 @@ int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p)
|
|||||||
WBUFW(buf,70) = p->hair_color;
|
WBUFW(buf,70) = p->hair_color;
|
||||||
WBUFW(buf,72) = p->clothes_color;
|
WBUFW(buf,72) = p->clothes_color;
|
||||||
memcpy(WBUFP(buf,74), p->name, NAME_LENGTH);
|
memcpy(WBUFP(buf,74), p->name, NAME_LENGTH);
|
||||||
WBUFB(buf,98) = min(p->str, UINT8_MAX);
|
WBUFB(buf,98) = u16min(p->str, UINT8_MAX);
|
||||||
WBUFB(buf,99) = min(p->agi, UINT8_MAX);
|
WBUFB(buf,99) = u16min(p->agi, UINT8_MAX);
|
||||||
WBUFB(buf,100) = min(p->vit, UINT8_MAX);
|
WBUFB(buf,100) = u16min(p->vit, UINT8_MAX);
|
||||||
WBUFB(buf,101) = min(p->int_, UINT8_MAX);
|
WBUFB(buf,101) = u16min(p->int_, UINT8_MAX);
|
||||||
WBUFB(buf,102) = min(p->dex, UINT8_MAX);
|
WBUFB(buf,102) = u16min(p->dex, UINT8_MAX);
|
||||||
WBUFB(buf,103) = min(p->luk, UINT8_MAX);
|
WBUFB(buf,103) = u16min(p->luk, UINT8_MAX);
|
||||||
WBUFW(buf,104) = p->slot;
|
WBUFW(buf,104) = p->slot;
|
||||||
WBUFW(buf,106) = ( p->rename > 0 ) ? 0 : 1;
|
WBUFW(buf,106) = ( p->rename > 0 ) ? 0 : 1;
|
||||||
offset += 2;
|
offset += 2;
|
||||||
@ -1956,7 +1956,7 @@ void char_read_fame_list(void)
|
|||||||
smith_fame_list[i].fame = atoi(data);
|
smith_fame_list[i].fame = atoi(data);
|
||||||
// name
|
// name
|
||||||
Sql_GetData(sql_handle, 2, &data, &len);
|
Sql_GetData(sql_handle, 2, &data, &len);
|
||||||
memcpy(smith_fame_list[i].name, data, min(len, NAME_LENGTH));
|
memcpy(smith_fame_list[i].name, data, zmin(len, NAME_LENGTH));
|
||||||
}
|
}
|
||||||
// Build Alchemist ranking list
|
// Build Alchemist ranking list
|
||||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", schema_config.char_db, JOB_ALCHEMIST, JOB_CREATOR, JOB_BABY_ALCHEMIST, JOB_GENETIC, JOB_GENETIC_T, JOB_BABY_GENETIC, fame_list_size_chemist) )
|
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d' OR `class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", schema_config.char_db, JOB_ALCHEMIST, JOB_CREATOR, JOB_BABY_ALCHEMIST, JOB_GENETIC, JOB_GENETIC_T, JOB_BABY_GENETIC, fame_list_size_chemist) )
|
||||||
@ -1971,7 +1971,7 @@ void char_read_fame_list(void)
|
|||||||
chemist_fame_list[i].fame = atoi(data);
|
chemist_fame_list[i].fame = atoi(data);
|
||||||
// name
|
// name
|
||||||
Sql_GetData(sql_handle, 2, &data, &len);
|
Sql_GetData(sql_handle, 2, &data, &len);
|
||||||
memcpy(chemist_fame_list[i].name, data, min(len, NAME_LENGTH));
|
memcpy(chemist_fame_list[i].name, data, zmin(len, NAME_LENGTH));
|
||||||
}
|
}
|
||||||
// Build Taekwon ranking list
|
// Build Taekwon ranking list
|
||||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", schema_config.char_db, JOB_TAEKWON, fame_list_size_taekwon) )
|
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='%d') ORDER BY `fame` DESC LIMIT 0,%d", schema_config.char_db, JOB_TAEKWON, fame_list_size_taekwon) )
|
||||||
@ -1986,7 +1986,7 @@ void char_read_fame_list(void)
|
|||||||
taekwon_fame_list[i].fame = atoi(data);
|
taekwon_fame_list[i].fame = atoi(data);
|
||||||
// name
|
// name
|
||||||
Sql_GetData(sql_handle, 2, &data, &len);
|
Sql_GetData(sql_handle, 2, &data, &len);
|
||||||
memcpy(taekwon_fame_list[i].name, data, min(len, NAME_LENGTH));
|
memcpy(taekwon_fame_list[i].name, data, zmin(len, NAME_LENGTH));
|
||||||
}
|
}
|
||||||
Sql_FreeResult(sql_handle);
|
Sql_FreeResult(sql_handle);
|
||||||
}
|
}
|
||||||
|
@ -362,8 +362,8 @@ struct guild * inter_guild_fromsql(int guild_id)
|
|||||||
CREATE(g, struct guild, 1);
|
CREATE(g, struct guild, 1);
|
||||||
|
|
||||||
g->guild_id = guild_id;
|
g->guild_id = guild_id;
|
||||||
Sql_GetData(sql_handle, 0, &data, &len); memcpy(g->name, data, min(len, NAME_LENGTH));
|
Sql_GetData(sql_handle, 0, &data, &len); memcpy(g->name, data, zmin(len, NAME_LENGTH));
|
||||||
Sql_GetData(sql_handle, 1, &data, &len); memcpy(g->master, data, min(len, NAME_LENGTH));
|
Sql_GetData(sql_handle, 1, &data, &len); memcpy(g->master, data, zmin(len, NAME_LENGTH));
|
||||||
Sql_GetData(sql_handle, 2, &data, NULL); g->guild_lv = atoi(data);
|
Sql_GetData(sql_handle, 2, &data, NULL); g->guild_lv = atoi(data);
|
||||||
Sql_GetData(sql_handle, 3, &data, NULL); g->connect_member = atoi(data);
|
Sql_GetData(sql_handle, 3, &data, NULL); g->connect_member = atoi(data);
|
||||||
Sql_GetData(sql_handle, 4, &data, NULL); g->max_member = atoi(data);
|
Sql_GetData(sql_handle, 4, &data, NULL); g->max_member = atoi(data);
|
||||||
@ -376,8 +376,8 @@ struct guild * inter_guild_fromsql(int guild_id)
|
|||||||
Sql_GetData(sql_handle, 6, &data, NULL); g->exp = strtoull(data, NULL, 10);
|
Sql_GetData(sql_handle, 6, &data, NULL); g->exp = strtoull(data, NULL, 10);
|
||||||
Sql_GetData(sql_handle, 7, &data, NULL); g->next_exp = (unsigned int)strtoul(data, NULL, 10);
|
Sql_GetData(sql_handle, 7, &data, NULL); g->next_exp = (unsigned int)strtoul(data, NULL, 10);
|
||||||
Sql_GetData(sql_handle, 8, &data, NULL); g->skill_point = atoi(data);
|
Sql_GetData(sql_handle, 8, &data, NULL); g->skill_point = atoi(data);
|
||||||
Sql_GetData(sql_handle, 9, &data, &len); memcpy(g->mes1, data, min(len, sizeof(g->mes1)));
|
Sql_GetData(sql_handle, 9, &data, &len); memcpy(g->mes1, data, zmin(len, sizeof(g->mes1)));
|
||||||
Sql_GetData(sql_handle, 10, &data, &len); memcpy(g->mes2, data, min(len, sizeof(g->mes2)));
|
Sql_GetData(sql_handle, 10, &data, &len); memcpy(g->mes2, data, zmin(len, sizeof(g->mes2)));
|
||||||
Sql_GetData(sql_handle, 11, &data, &len); g->emblem_len = atoi(data);
|
Sql_GetData(sql_handle, 11, &data, &len); g->emblem_len = atoi(data);
|
||||||
Sql_GetData(sql_handle, 12, &data, &len); g->emblem_id = atoi(data);
|
Sql_GetData(sql_handle, 12, &data, &len); g->emblem_id = atoi(data);
|
||||||
Sql_GetData(sql_handle, 13, &data, &len);
|
Sql_GetData(sql_handle, 13, &data, &len);
|
||||||
@ -428,7 +428,7 @@ struct guild * inter_guild_fromsql(int guild_id)
|
|||||||
Sql_GetData(sql_handle, 10, &data, NULL); m->position = atoi(data);
|
Sql_GetData(sql_handle, 10, &data, NULL); m->position = atoi(data);
|
||||||
if( m->position >= MAX_GUILDPOSITION ) // Fix reduction of MAX_GUILDPOSITION [PoW]
|
if( m->position >= MAX_GUILDPOSITION ) // Fix reduction of MAX_GUILDPOSITION [PoW]
|
||||||
m->position = MAX_GUILDPOSITION - 1;
|
m->position = MAX_GUILDPOSITION - 1;
|
||||||
Sql_GetData(sql_handle, 11, &data, &len); memcpy(m->name, data, min(len, NAME_LENGTH));
|
Sql_GetData(sql_handle, 11, &data, &len); memcpy(m->name, data, zmin(len, NAME_LENGTH));
|
||||||
m->modified = GS_MEMBER_UNMODIFIED;
|
m->modified = GS_MEMBER_UNMODIFIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,7 +448,7 @@ struct guild * inter_guild_fromsql(int guild_id)
|
|||||||
if( position < 0 || position >= MAX_GUILDPOSITION )
|
if( position < 0 || position >= MAX_GUILDPOSITION )
|
||||||
continue;// invalid position
|
continue;// invalid position
|
||||||
gpos = &g->position[position];
|
gpos = &g->position[position];
|
||||||
Sql_GetData(sql_handle, 1, &data, &len); memcpy(gpos->name, data, min(len, NAME_LENGTH));
|
Sql_GetData(sql_handle, 1, &data, &len); memcpy(gpos->name, data, zmin(len, NAME_LENGTH));
|
||||||
Sql_GetData(sql_handle, 2, &data, NULL); gpos->mode = atoi(data);
|
Sql_GetData(sql_handle, 2, &data, NULL); gpos->mode = atoi(data);
|
||||||
Sql_GetData(sql_handle, 3, &data, NULL); gpos->exp_mode = atoi(data);
|
Sql_GetData(sql_handle, 3, &data, NULL); gpos->exp_mode = atoi(data);
|
||||||
gpos->modified = GS_POSITION_UNMODIFIED;
|
gpos->modified = GS_POSITION_UNMODIFIED;
|
||||||
@ -467,7 +467,7 @@ struct guild * inter_guild_fromsql(int guild_id)
|
|||||||
|
|
||||||
Sql_GetData(sql_handle, 0, &data, NULL); a->opposition = atoi(data);
|
Sql_GetData(sql_handle, 0, &data, NULL); a->opposition = atoi(data);
|
||||||
Sql_GetData(sql_handle, 1, &data, NULL); a->guild_id = atoi(data);
|
Sql_GetData(sql_handle, 1, &data, NULL); a->guild_id = atoi(data);
|
||||||
Sql_GetData(sql_handle, 2, &data, &len); memcpy(a->name, data, min(len, NAME_LENGTH));
|
Sql_GetData(sql_handle, 2, &data, &len); memcpy(a->name, data, zmin(len, NAME_LENGTH));
|
||||||
}
|
}
|
||||||
|
|
||||||
//printf("- Read guild_expulsion %d from sql \n",guild_id);
|
//printf("- Read guild_expulsion %d from sql \n",guild_id);
|
||||||
@ -482,8 +482,8 @@ struct guild * inter_guild_fromsql(int guild_id)
|
|||||||
struct guild_expulsion *e = &g->expulsion[i];
|
struct guild_expulsion *e = &g->expulsion[i];
|
||||||
|
|
||||||
Sql_GetData(sql_handle, 0, &data, NULL); e->account_id = atoi(data);
|
Sql_GetData(sql_handle, 0, &data, NULL); e->account_id = atoi(data);
|
||||||
Sql_GetData(sql_handle, 1, &data, &len); memcpy(e->name, data, min(len, NAME_LENGTH));
|
Sql_GetData(sql_handle, 1, &data, &len); memcpy(e->name, data, zmin(len, NAME_LENGTH));
|
||||||
Sql_GetData(sql_handle, 2, &data, &len); memcpy(e->mes, data, min(len, sizeof(e->mes)));
|
Sql_GetData(sql_handle, 2, &data, &len); memcpy(e->mes, data, zmin(len, sizeof(e->mes)));
|
||||||
}
|
}
|
||||||
|
|
||||||
//printf("- Read guild_skill %d from sql \n",guild_id);
|
//printf("- Read guild_skill %d from sql \n",guild_id);
|
||||||
|
@ -195,7 +195,7 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
|
|||||||
Sql_GetData(sql_handle, 21, &data, NULL); hd->vaporize = atoi(data);
|
Sql_GetData(sql_handle, 21, &data, NULL); hd->vaporize = atoi(data);
|
||||||
Sql_FreeResult(sql_handle);
|
Sql_FreeResult(sql_handle);
|
||||||
|
|
||||||
hd->intimacy = min(hd->intimacy,100000);
|
hd->intimacy = umin(hd->intimacy,100000);
|
||||||
hd->hunger = cap_value(hd->hunger, 0, 100);
|
hd->hunger = cap_value(hd->hunger, 0, 100);
|
||||||
|
|
||||||
// Load Homunculus Skill
|
// Load Homunculus Skill
|
||||||
|
@ -217,7 +217,7 @@ struct party_data *inter_party_fromsql(int party_id)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
p->party.party_id = party_id;
|
p->party.party_id = party_id;
|
||||||
Sql_GetData(sql_handle, 1, &data, &len); memcpy(p->party.name, data, min(len, NAME_LENGTH));
|
Sql_GetData(sql_handle, 1, &data, &len); memcpy(p->party.name, data, zmin(len, NAME_LENGTH));
|
||||||
Sql_GetData(sql_handle, 2, &data, NULL); p->party.exp = (atoi(data) ? 1 : 0);
|
Sql_GetData(sql_handle, 2, &data, NULL); p->party.exp = (atoi(data) ? 1 : 0);
|
||||||
Sql_GetData(sql_handle, 3, &data, NULL); p->party.item = atoi(data);
|
Sql_GetData(sql_handle, 3, &data, NULL); p->party.item = atoi(data);
|
||||||
Sql_GetData(sql_handle, 4, &data, NULL); leader_id = atoi(data);
|
Sql_GetData(sql_handle, 4, &data, NULL); leader_id = atoi(data);
|
||||||
@ -235,7 +235,7 @@ struct party_data *inter_party_fromsql(int party_id)
|
|||||||
m = &p->party.member[i];
|
m = &p->party.member[i];
|
||||||
Sql_GetData(sql_handle, 0, &data, NULL); m->account_id = atoi(data);
|
Sql_GetData(sql_handle, 0, &data, NULL); m->account_id = atoi(data);
|
||||||
Sql_GetData(sql_handle, 1, &data, NULL); m->char_id = atoi(data);
|
Sql_GetData(sql_handle, 1, &data, NULL); m->char_id = atoi(data);
|
||||||
Sql_GetData(sql_handle, 2, &data, &len); memcpy(m->name, data, min(len, NAME_LENGTH));
|
Sql_GetData(sql_handle, 2, &data, &len); memcpy(m->name, data, zmin(len, NAME_LENGTH));
|
||||||
Sql_GetData(sql_handle, 3, &data, NULL); m->lv = atoi(data);
|
Sql_GetData(sql_handle, 3, &data, NULL); m->lv = atoi(data);
|
||||||
Sql_GetData(sql_handle, 4, &data, NULL); m->map = mapindex_name2id(data);
|
Sql_GetData(sql_handle, 4, &data, NULL); m->map = mapindex_name2id(data);
|
||||||
Sql_GetData(sql_handle, 5, &data, NULL); m->online = (atoi(data) ? 1 : 0);
|
Sql_GetData(sql_handle, 5, &data, NULL); m->online = (atoi(data) ? 1 : 0);
|
||||||
|
@ -76,7 +76,7 @@ int inter_pet_fromsql(int pet_id, struct s_pet* p)
|
|||||||
{
|
{
|
||||||
p->pet_id = pet_id;
|
p->pet_id = pet_id;
|
||||||
Sql_GetData(sql_handle, 1, &data, NULL); p->class_ = atoi(data);
|
Sql_GetData(sql_handle, 1, &data, NULL); p->class_ = atoi(data);
|
||||||
Sql_GetData(sql_handle, 2, &data, &len); memcpy(p->name, data, min(len, NAME_LENGTH));
|
Sql_GetData(sql_handle, 2, &data, &len); memcpy(p->name, data, zmin(len, NAME_LENGTH));
|
||||||
Sql_GetData(sql_handle, 3, &data, NULL); p->account_id = atoi(data);
|
Sql_GetData(sql_handle, 3, &data, NULL); p->account_id = atoi(data);
|
||||||
Sql_GetData(sql_handle, 4, &data, NULL); p->char_id = atoi(data);
|
Sql_GetData(sql_handle, 4, &data, NULL); p->char_id = atoi(data);
|
||||||
Sql_GetData(sql_handle, 5, &data, NULL); p->level = atoi(data);
|
Sql_GetData(sql_handle, 5, &data, NULL); p->level = atoi(data);
|
||||||
|
@ -1040,7 +1040,7 @@ int mapif_parse_WisRequest(int fd)
|
|||||||
// to be sure of the correct name, rewrite it
|
// to be sure of the correct name, rewrite it
|
||||||
Sql_GetData(sql_handle, 0, &data, &len);
|
Sql_GetData(sql_handle, 0, &data, &len);
|
||||||
memset(name, 0, NAME_LENGTH);
|
memset(name, 0, NAME_LENGTH);
|
||||||
memcpy(name, data, min(len, NAME_LENGTH));
|
memcpy(name, data, zmin(len, NAME_LENGTH));
|
||||||
// if source is destination, don't ask other servers.
|
// if source is destination, don't ask other servers.
|
||||||
if( strncmp((const char*)RFIFOP(fd,4), name, NAME_LENGTH) == 0 )
|
if( strncmp((const char*)RFIFOP(fd,4), name, NAME_LENGTH) == 0 )
|
||||||
{
|
{
|
||||||
|
@ -286,14 +286,6 @@ typedef char bool;
|
|||||||
#define swap(a,b) if (a != b) ((a ^= b), (b ^= a), (a ^= b))
|
#define swap(a,b) if (a != b) ((a ^= b), (b ^= a), (a ^= b))
|
||||||
#define swap_ptr(a,b) if ((a) != (b)) ((a) = (void*)((intptr_t)(a) ^ (intptr_t)(b)), (b) = (void*)((intptr_t)(a) ^ (intptr_t)(b)), (a) = (void*)((intptr_t)(a) ^ (intptr_t)(b)))
|
#define swap_ptr(a,b) if ((a) != (b)) ((a) = (void*)((intptr_t)(a) ^ (intptr_t)(b)), (b) = (void*)((intptr_t)(a) ^ (intptr_t)(b)), (a) = (void*)((intptr_t)(a) ^ (intptr_t)(b)))
|
||||||
|
|
||||||
#ifndef max
|
|
||||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef min
|
|
||||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// should not happen
|
// should not happen
|
||||||
#ifndef NULL
|
#ifndef NULL
|
||||||
@ -358,7 +350,7 @@ typedef char bool;
|
|||||||
#define TOUPPER(c) (toupper((unsigned char)(c)))
|
#define TOUPPER(c) (toupper((unsigned char)(c)))
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// length of a static array
|
// length of a static array (size_t)
|
||||||
#define ARRAYLENGTH(A) ( sizeof(A)/sizeof((A)[0]) )
|
#define ARRAYLENGTH(A) ( sizeof(A)/sizeof((A)[0]) )
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -404,5 +396,35 @@ void SET_FUNCPOINTER(T1& var, T2 p)
|
|||||||
#define SET_FUNCPOINTER(var,p) (var) = (p)
|
#define SET_FUNCPOINTER(var,p) (var) = (p)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//#ifndef max
|
||||||
|
//#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||||
|
//wish we could have template in C
|
||||||
|
static inline int max(int a, int b){ return (a > b) ? a : b; } //default is int
|
||||||
|
static inline int8 i8max(int8 a, int8 b){ return (a > b) ? a : b; }
|
||||||
|
static inline int16 i16max(int16 a, int16 b){ return (a > b) ? a : b; }
|
||||||
|
static inline int32 i32max(int32 a, int32 b){ return (a > b) ? a : b; }
|
||||||
|
static inline int64 i64max(int64 a, int64 b){ return (a > b) ? a : b; }
|
||||||
|
static inline uint32 umax(uint32 a, uint32 b){ return (a > b) ? a : b; }
|
||||||
|
static inline uint8 u8max(uint8 a, uint8 b){ return (a > b) ? a : b; }
|
||||||
|
static inline uint16 u16max(uint16 a, uint16 b){ return (a > b) ? a : b; }
|
||||||
|
static inline uint32 u32max(uint32 a, uint32 b){ return (a > b) ? a : b; }
|
||||||
|
static inline uint64 u64max(uint64 a, uint64 b){ return (a > b) ? a : b; }
|
||||||
|
static inline size_t zmax(size_t a, size_t b){ return (a > b) ? a : b; } //cause those varie
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
//#ifndef min
|
||||||
|
//#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||||
|
//#endif
|
||||||
|
static inline int min(int a, int b){ return (a < b) ? a : b; } //default is int
|
||||||
|
static inline int8 i8min(int8 a, int8 b){ return (a < b) ? a : b; }
|
||||||
|
static inline int16 i16min(int16 a, int16 b){ return (a < b) ? a : b; }
|
||||||
|
static inline int32 i32min(int32 a, int32 b){ return (a < b) ? a : b; }
|
||||||
|
static inline int64 i64min(int64 a, int64 b){ return (a < b) ? a : b; }
|
||||||
|
static inline uint32 umin(uint32 a, uint32 b){ return (a < b) ? a : b; }
|
||||||
|
static inline uint8 u8min(uint8 a, uint8 b){ return (a < b) ? a : b; }
|
||||||
|
static inline uint16 u16min(uint16 a, uint16 b){ return (a < b) ? a : b; }
|
||||||
|
static inline uint32 u32min(uint32 a, uint32 b){ return (a < b) ? a : b; }
|
||||||
|
static inline uint64 u64min(uint64 a, uint64 b){ return (a < b) ? a : b; }
|
||||||
|
static inline size_t zmin(size_t a, size_t b){ return (a < b) ? a : b; }
|
||||||
|
|
||||||
#endif /* _CBASETYPES_H_ */
|
#endif /* _CBASETYPES_H_ */
|
||||||
|
@ -33,7 +33,7 @@ const char* mapindex_getmapname(const char* string, char* output) {
|
|||||||
if (len >= 4 && stricmp(&string[len-4], ".gat") == 0)
|
if (len >= 4 && stricmp(&string[len-4], ".gat") == 0)
|
||||||
len -= 4; // strip .gat extension
|
len -= 4; // strip .gat extension
|
||||||
|
|
||||||
len = min(len, MAP_NAME_LENGTH-1);
|
len = zmin(len, MAP_NAME_LENGTH-1);
|
||||||
safestrncpy(dest, string, len+1);
|
safestrncpy(dest, string, len+1);
|
||||||
memset(&dest[len], '\0', MAP_NAME_LENGTH-len);
|
memset(&dest[len], '\0', MAP_NAME_LENGTH-len);
|
||||||
|
|
||||||
|
@ -3322,11 +3322,11 @@ ACMD_FUNC(lostskill)
|
|||||||
*------------------------------------------*/
|
*------------------------------------------*/
|
||||||
ACMD_FUNC(spiritball)
|
ACMD_FUNC(spiritball)
|
||||||
{
|
{
|
||||||
int max_spiritballs;
|
uint32 max_spiritballs;
|
||||||
int number;
|
int number;
|
||||||
nullpo_retr(-1, sd);
|
nullpo_retr(-1, sd);
|
||||||
|
|
||||||
max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
|
max_spiritballs = zmin(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
|
||||||
|
|
||||||
if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
|
if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
|
||||||
{
|
{
|
||||||
@ -3854,8 +3854,9 @@ ACMD_FUNC(partysharelvl) {
|
|||||||
if(!message || !*message) {
|
if(!message || !*message) {
|
||||||
clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
|
clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
|
||||||
return -1;
|
return -1;
|
||||||
} else
|
} else {
|
||||||
share_lvl = min(abs(atoi(message)),MAX_LEVEL);
|
share_lvl = min(abs(atoi(message)),MAX_LEVEL);
|
||||||
|
}
|
||||||
|
|
||||||
if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
|
if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
|
||||||
clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
|
clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
|
||||||
|
@ -492,7 +492,7 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d
|
|||||||
else
|
else
|
||||||
damage = damage + (damage * (ratio - 100) / 100);
|
damage = damage + (damage * (ratio - 100) / 100);
|
||||||
|
|
||||||
return max(damage,0);
|
return i64max(damage,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1470,7 +1470,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
|
|||||||
if (flag & BF_LONG)
|
if (flag & BF_LONG)
|
||||||
damage = damage * battle_config.pk_long_damage_rate / 100;
|
damage = damage * battle_config.pk_long_damage_rate / 100;
|
||||||
}
|
}
|
||||||
damage = max(damage,1);
|
damage = i64max(damage,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(battle_config.skill_min_damage && damage > 0 && damage < div_) {
|
if(battle_config.skill_min_damage && damage > 0 && damage < div_) {
|
||||||
@ -1550,7 +1550,7 @@ int64 battle_calc_bg_damage(struct block_list *src, struct block_list *bl, int64
|
|||||||
damage = damage * battle_config.bg_long_damage_rate / 100;
|
damage = damage * battle_config.bg_long_damage_rate / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
damage = max(damage,1); //min 1 damage
|
damage = i64max(damage,1); //min 1 damage
|
||||||
return damage;
|
return damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1619,7 +1619,7 @@ int64 battle_calc_gvg_damage(struct block_list *src,struct block_list *bl,int64
|
|||||||
if (flag & BF_LONG)
|
if (flag & BF_LONG)
|
||||||
damage = damage * battle_config.gvg_long_damage_rate / 100;
|
damage = damage * battle_config.gvg_long_damage_rate / 100;
|
||||||
}
|
}
|
||||||
damage = max(damage,1);
|
damage = i64max(damage,1);
|
||||||
return damage;
|
return damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4478,7 +4478,6 @@ struct Damage battle_calc_defense_reduction(struct Damage wd, struct block_list
|
|||||||
|
|
||||||
if (sd) {
|
if (sd) {
|
||||||
int i = sd->ignore_def_by_race[tstatus->race] + sd->ignore_def_by_race[RC_ALL];
|
int i = sd->ignore_def_by_race[tstatus->race] + sd->ignore_def_by_race[RC_ALL];
|
||||||
|
|
||||||
if (i) {
|
if (i) {
|
||||||
i = min(i,100); //cap it to 100 for 0 def min
|
i = min(i,100); //cap it to 100 for 0 def min
|
||||||
def1 -= def1 * i / 100;
|
def1 -= def1 * i / 100;
|
||||||
@ -4487,9 +4486,8 @@ struct Damage battle_calc_defense_reduction(struct Damage wd, struct block_list
|
|||||||
|
|
||||||
//Kagerou/Oboro Earth Charm effect +10% eDEF
|
//Kagerou/Oboro Earth Charm effect +10% eDEF
|
||||||
if(sd->spiritcharm_type == CHARM_TYPE_LAND && sd->spiritcharm > 0) {
|
if(sd->spiritcharm_type == CHARM_TYPE_LAND && sd->spiritcharm > 0) {
|
||||||
short i = 10 * sd->spiritcharm;
|
short si = 10 * sd->spiritcharm;
|
||||||
|
def1 = (def1 * (100 + si)) / 100;
|
||||||
def1 = (def1 * (100 + i)) / 100;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6665,7 +6663,7 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i
|
|||||||
if (flag & BF_SHORT) {//Bounces back part of the damage.
|
if (flag & BF_SHORT) {//Bounces back part of the damage.
|
||||||
if ( !status_reflect && sd && sd->bonus.short_weapon_damage_return ) {
|
if ( !status_reflect && sd && sd->bonus.short_weapon_damage_return ) {
|
||||||
rdamage += damage * sd->bonus.short_weapon_damage_return / 100;
|
rdamage += damage * sd->bonus.short_weapon_damage_return / 100;
|
||||||
rdamage = max(rdamage,1);
|
rdamage = i64max(rdamage,1);
|
||||||
} else if( status_reflect && sc && sc->count ) {
|
} else if( status_reflect && sc && sc->count ) {
|
||||||
if( sc->data[SC_REFLECTSHIELD] ) {
|
if( sc->data[SC_REFLECTSHIELD] ) {
|
||||||
struct status_change_entry *sce_d;
|
struct status_change_entry *sce_d;
|
||||||
@ -6731,7 +6729,7 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i
|
|||||||
#ifdef RENEWAL
|
#ifdef RENEWAL
|
||||||
rdamage = cap_value(rdamage, 1, max_damage);
|
rdamage = cap_value(rdamage, 1, max_damage);
|
||||||
#else
|
#else
|
||||||
rdamage = max(rdamage,1);
|
rdamage = i64max(rdamage,1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -678,7 +678,7 @@ void do_init_buyingstore_autotrade( void ) {
|
|||||||
Sql_GetData(mmysql_handle, 1, &data, NULL); at->account_id = atoi(data);
|
Sql_GetData(mmysql_handle, 1, &data, NULL); at->account_id = atoi(data);
|
||||||
Sql_GetData(mmysql_handle, 2, &data, NULL); at->char_id = atoi(data);
|
Sql_GetData(mmysql_handle, 2, &data, NULL); at->char_id = atoi(data);
|
||||||
Sql_GetData(mmysql_handle, 3, &data, NULL); at->sex = (data[0] == 'F') ? 0 : 1;
|
Sql_GetData(mmysql_handle, 3, &data, NULL); at->sex = (data[0] == 'F') ? 0 : 1;
|
||||||
Sql_GetData(mmysql_handle, 4, &data, &len); safestrncpy(at->title, data, min(len + 1, MESSAGE_SIZE));
|
Sql_GetData(mmysql_handle, 4, &data, &len); safestrncpy(at->title, data, zmin(len + 1, MESSAGE_SIZE));
|
||||||
Sql_GetData(mmysql_handle, 5, &data, NULL); at->limit = atoi(data);
|
Sql_GetData(mmysql_handle, 5, &data, NULL); at->limit = atoi(data);
|
||||||
Sql_GetData(mmysql_handle, 6, &data, NULL); at->dir = atoi(data);
|
Sql_GetData(mmysql_handle, 6, &data, NULL); at->dir = atoi(data);
|
||||||
Sql_GetData(mmysql_handle, 7, &data, NULL); at->head_dir = atoi(data);
|
Sql_GetData(mmysql_handle, 7, &data, NULL); at->head_dir = atoi(data);
|
||||||
|
@ -1433,7 +1433,7 @@ void clif_hominfo(struct map_session_data *sd, struct homun_data *hd, int flag)
|
|||||||
#else
|
#else
|
||||||
WBUFW(buf,35)=cap_value(status->rhw.atk2+status->batk, 0, INT16_MAX);
|
WBUFW(buf,35)=cap_value(status->rhw.atk2+status->batk, 0, INT16_MAX);
|
||||||
#endif
|
#endif
|
||||||
WBUFW(buf,37)=min(status->matk_max, INT16_MAX); //FIXME capping to INT16 here is too late
|
WBUFW(buf,37)=i16min(status->matk_max, INT16_MAX); //FIXME capping to INT16 here is too late
|
||||||
WBUFW(buf,39)=status->hit;
|
WBUFW(buf,39)=status->hit;
|
||||||
if (battle_config.hom_setting&HOMSET_DISPLAY_LUK)
|
if (battle_config.hom_setting&HOMSET_DISPLAY_LUK)
|
||||||
WBUFW(buf,41)=status->luk/3 + 1; //crit is a +1 decimal value! Just display purpose.[Vicious]
|
WBUFW(buf,41)=status->luk/3 + 1; //crit is a +1 decimal value! Just display purpose.[Vicious]
|
||||||
@ -16869,14 +16869,14 @@ void clif_search_store_info_ack(struct map_session_data* sd)
|
|||||||
unsigned int i, start, end;
|
unsigned int i, start, end;
|
||||||
|
|
||||||
start = sd->searchstore.pages*SEARCHSTORE_RESULTS_PER_PAGE;
|
start = sd->searchstore.pages*SEARCHSTORE_RESULTS_PER_PAGE;
|
||||||
end = min(sd->searchstore.count, start+SEARCHSTORE_RESULTS_PER_PAGE);
|
end = umin(sd->searchstore.count, start+SEARCHSTORE_RESULTS_PER_PAGE);
|
||||||
|
|
||||||
WFIFOHEAD(fd,7+(end-start)*blocksize);
|
WFIFOHEAD(fd,7+(end-start)*blocksize);
|
||||||
WFIFOW(fd,0) = 0x836;
|
WFIFOW(fd,0) = 0x836;
|
||||||
WFIFOW(fd,2) = 7+(end-start)*blocksize;
|
WFIFOW(fd,2) = 7+(end-start)*blocksize;
|
||||||
WFIFOB(fd,4) = !sd->searchstore.pages;
|
WFIFOB(fd,4) = !sd->searchstore.pages;
|
||||||
WFIFOB(fd,5) = searchstore_querynext(sd);
|
WFIFOB(fd,5) = searchstore_querynext(sd);
|
||||||
WFIFOB(fd,6) = (unsigned char)min(sd->searchstore.uses, UINT8_MAX);
|
WFIFOB(fd,6) = (unsigned char)umin(sd->searchstore.uses, UINT8_MAX);
|
||||||
|
|
||||||
for( i = start; i < end; i++ ) {
|
for( i = start; i < end; i++ ) {
|
||||||
struct s_search_store_info_item* ssitem = &sd->searchstore.items[i];
|
struct s_search_store_info_item* ssitem = &sd->searchstore.items[i];
|
||||||
@ -16944,7 +16944,7 @@ void clif_open_search_store_info(struct map_session_data* sd)
|
|||||||
WFIFOW(fd,0) = 0x83a;
|
WFIFOW(fd,0) = 0x83a;
|
||||||
WFIFOW(fd,2) = sd->searchstore.effect;
|
WFIFOW(fd,2) = sd->searchstore.effect;
|
||||||
#if PACKETVER > 20100701
|
#if PACKETVER > 20100701
|
||||||
WFIFOB(fd,4) = (unsigned char)min(sd->searchstore.uses, UINT8_MAX);
|
WFIFOB(fd,4) = (unsigned char)umin(sd->searchstore.uses, UINT8_MAX);
|
||||||
#endif
|
#endif
|
||||||
WFIFOSET(fd,packet_len(0x83a));
|
WFIFOSET(fd,packet_len(0x83a));
|
||||||
}
|
}
|
||||||
|
@ -565,10 +565,10 @@ int map_foreachinrange(int (*func)(struct block_list*,va_list), struct block_lis
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
m = center->m;
|
m = center->m;
|
||||||
x0 = max(center->x - range, 0);
|
x0 = i16max(center->x - range, 0);
|
||||||
y0 = max(center->y - range, 0);
|
y0 = i16max(center->y - range, 0);
|
||||||
x1 = min(center->x + range, map[ m ].xs - 1);
|
x1 = i16min(center->x + range, map[ m ].xs - 1);
|
||||||
y1 = min(center->y + range, map[ m ].ys - 1);
|
y1 = i16min(center->y + range, map[ m ].ys - 1);
|
||||||
|
|
||||||
if ( type&~BL_MOB )
|
if ( type&~BL_MOB )
|
||||||
for ( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ ) {
|
for ( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ ) {
|
||||||
@ -633,10 +633,10 @@ int map_foreachinshootrange(int (*func)(struct block_list*,va_list),struct block
|
|||||||
if ( m < 0 )
|
if ( m < 0 )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
x0 = max(center->x-range, 0);
|
x0 = i16max(center->x-range, 0);
|
||||||
y0 = max(center->y-range, 0);
|
y0 = i16max(center->y-range, 0);
|
||||||
x1 = min(center->x+range, map[m].xs-1);
|
x1 = i16min(center->x+range, map[m].xs-1);
|
||||||
y1 = min(center->y+range, map[m].ys-1);
|
y1 = i16min(center->y+range, map[m].ys-1);
|
||||||
|
|
||||||
if ( type&~BL_MOB )
|
if ( type&~BL_MOB )
|
||||||
for( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ ) {
|
for( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ ) {
|
||||||
@ -707,10 +707,10 @@ int map_foreachinarea(int (*func)(struct block_list*,va_list), int16 m, int16 x0
|
|||||||
if ( y1 < y0 )
|
if ( y1 < y0 )
|
||||||
swap(y0, y1);
|
swap(y0, y1);
|
||||||
|
|
||||||
x0 = max(x0, 0);
|
x0 = i16max(x0, 0);
|
||||||
y0 = max(y0, 0);
|
y0 = i16max(y0, 0);
|
||||||
x1 = min(x1, map[ m ].xs - 1);
|
x1 = i16min(x1, map[ m ].xs - 1);
|
||||||
y1 = min(y1, map[ m ].ys - 1);
|
y1 = i16min(y1, map[ m ].ys - 1);
|
||||||
if ( type&~BL_MOB )
|
if ( type&~BL_MOB )
|
||||||
for( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ )
|
for( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ )
|
||||||
for( bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++ )
|
for( bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++ )
|
||||||
@ -755,10 +755,10 @@ int map_forcountinrange(int (*func)(struct block_list*,va_list), struct block_li
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
m = center->m;
|
m = center->m;
|
||||||
x0 = max(center->x - range, 0);
|
x0 = i16max(center->x - range, 0);
|
||||||
y0 = max(center->y - range, 0);
|
y0 = i16max(center->y - range, 0);
|
||||||
x1 = min(center->x + range, map[ m ].xs - 1);
|
x1 = i16min(center->x + range, map[ m ].xs - 1);
|
||||||
y1 = min(center->y + range, map[ m ].ys - 1);
|
y1 = i16min(center->y + range, map[ m ].ys - 1);
|
||||||
|
|
||||||
if ( type&~BL_MOB )
|
if ( type&~BL_MOB )
|
||||||
for ( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ ) {
|
for ( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ ) {
|
||||||
@ -823,10 +823,10 @@ int map_forcountinarea(int (*func)(struct block_list*,va_list), int16 m, int16 x
|
|||||||
if ( y1 < y0 )
|
if ( y1 < y0 )
|
||||||
swap(y0, y1);
|
swap(y0, y1);
|
||||||
|
|
||||||
x0 = max(x0, 0);
|
x0 = i16max(x0, 0);
|
||||||
y0 = max(y0, 0);
|
y0 = i16max(y0, 0);
|
||||||
x1 = min(x1, map[ m ].xs - 1);
|
x1 = i16min(x1, map[ m ].xs - 1);
|
||||||
y1 = min(y1, map[ m ].ys - 1);
|
y1 = i16min(y1, map[ m ].ys - 1);
|
||||||
|
|
||||||
if ( type&~BL_MOB )
|
if ( type&~BL_MOB )
|
||||||
for( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ )
|
for( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ )
|
||||||
@ -872,7 +872,7 @@ int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_
|
|||||||
int returnCount = 0; //total sum of returned values of func() [Skotlex]
|
int returnCount = 0; //total sum of returned values of func() [Skotlex]
|
||||||
struct block_list *bl;
|
struct block_list *bl;
|
||||||
int blockcount = bl_list_count, i;
|
int blockcount = bl_list_count, i;
|
||||||
int x0, x1, y0, y1;
|
int16 x0, x1, y0, y1;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
if ( !range ) return 0;
|
if ( !range ) return 0;
|
||||||
@ -904,10 +904,10 @@ int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_
|
|||||||
x1 = x0 + dx - 1;
|
x1 = x0 + dx - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
x0 = max(x0, 0);
|
x0 = i16max(x0, 0);
|
||||||
y0 = max(y0, 0);
|
y0 = i16max(y0, 0);
|
||||||
x1 = min(x1, map[ m ].xs - 1);
|
x1 = i16min(x1, map[ m ].xs - 1);
|
||||||
y1 = min(y1, map[ m ].ys - 1);
|
y1 = i16min(y1, map[ m ].ys - 1);
|
||||||
|
|
||||||
for( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ ) {
|
for( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ ) {
|
||||||
for( bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++ ) {
|
for( bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++ ) {
|
||||||
@ -931,11 +931,10 @@ int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // Diagonal movement
|
} else { // Diagonal movement
|
||||||
|
x0 = i16max(x0, 0);
|
||||||
x0 = max(x0, 0);
|
y0 = i16max(y0, 0);
|
||||||
y0 = max(y0, 0);
|
x1 = i16min(x1, map[ m ].xs - 1);
|
||||||
x1 = min(x1, map[ m ].xs - 1);
|
y1 = i16min(y1, map[ m ].ys - 1);
|
||||||
y1 = min(y1, map[ m ].ys - 1);
|
|
||||||
|
|
||||||
for( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ ) {
|
for( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ ) {
|
||||||
for( bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++ ) {
|
for( bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++ ) {
|
||||||
|
@ -1097,10 +1097,10 @@ int npc_check_areanpc(int flag, int16 m, int16 x, int16 y, int16 range)
|
|||||||
int xs,ys;
|
int xs,ys;
|
||||||
|
|
||||||
if (range < 0) return 0;
|
if (range < 0) return 0;
|
||||||
x0 = max(x-range, 0);
|
x0 = i16max(x-range, 0);
|
||||||
y0 = max(y-range, 0);
|
y0 = i16max(y-range, 0);
|
||||||
x1 = min(x+range, map[m].xs-1);
|
x1 = i16min(x+range, map[m].xs-1);
|
||||||
y1 = min(y+range, map[m].ys-1);
|
y1 = i16min(y+range, map[m].ys-1);
|
||||||
|
|
||||||
//First check for npc_cells on the range given
|
//First check for npc_cells on the range given
|
||||||
i = 0;
|
i = 0;
|
||||||
|
46
src/map/pc.c
46
src/map/pc.c
@ -554,20 +554,20 @@ void pc_inventory_rentals(struct map_session_data *sd)
|
|||||||
else {
|
else {
|
||||||
expire_tick = (unsigned int)(sd->status.inventory[i].expire_time - time(NULL)) * 1000;
|
expire_tick = (unsigned int)(sd->status.inventory[i].expire_time - time(NULL)) * 1000;
|
||||||
clif_rental_time(sd->fd, sd->status.inventory[i].nameid, (int)(expire_tick / 1000));
|
clif_rental_time(sd->fd, sd->status.inventory[i].nameid, (int)(expire_tick / 1000));
|
||||||
next_tick = min(expire_tick, next_tick);
|
next_tick = umin(expire_tick, next_tick);
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( c > 0 ) // min(next_tick,3600000) 1 hour each timer to keep announcing to the owner, and to avoid a but with rental time > 15 days
|
if( c > 0 ) // min(next_tick,3600000) 1 hour each timer to keep announcing to the owner, and to avoid a but with rental time > 15 days
|
||||||
sd->rental_timer = add_timer(gettick() + min(next_tick,3600000), pc_inventory_rental_end, sd->bl.id, 0);
|
sd->rental_timer = add_timer(gettick() + umin(next_tick,3600000), pc_inventory_rental_end, sd->bl.id, 0);
|
||||||
else
|
else
|
||||||
sd->rental_timer = INVALID_TIMER;
|
sd->rental_timer = INVALID_TIMER;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pc_inventory_rental_add(struct map_session_data *sd, int seconds)
|
void pc_inventory_rental_add(struct map_session_data *sd, unsigned int seconds)
|
||||||
{
|
{
|
||||||
int tick = seconds * 1000;
|
unsigned int tick = seconds * 1000;
|
||||||
|
|
||||||
if( sd == NULL )
|
if( sd == NULL )
|
||||||
return;
|
return;
|
||||||
@ -581,7 +581,7 @@ void pc_inventory_rental_add(struct map_session_data *sd, int seconds)
|
|||||||
sd->rental_timer = add_timer(gettick() + tick, pc_inventory_rental_end, sd->bl.id, 0);
|
sd->rental_timer = add_timer(gettick() + tick, pc_inventory_rental_end, sd->bl.id, 0);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
sd->rental_timer = add_timer(gettick() + min(tick,3600000), pc_inventory_rental_end, sd->bl.id, 0);
|
sd->rental_timer = add_timer(gettick() + umin(tick,3600000), pc_inventory_rental_end, sd->bl.id, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2051,14 +2051,14 @@ static void pc_bonus_autospell_onskill(struct s_autospell *spell, int max, short
|
|||||||
/**
|
/**
|
||||||
* Add inflict effect bonus for player while attacking/atatcked
|
* Add inflict effect bonus for player while attacking/atatcked
|
||||||
* @param effect Effect array
|
* @param effect Effect array
|
||||||
* @param max Max array
|
* @param pmax Max array
|
||||||
* @param sc SC/Effect type
|
* @param sc SC/Effect type
|
||||||
* @param rate Success chance
|
* @param rate Success chance
|
||||||
* @param arrow_rate success chance if bonus comes from arrow-type item
|
* @param arrow_rate success chance if bonus comes from arrow-type item
|
||||||
* @param flag Target flag
|
* @param flag Target flag
|
||||||
* @param duration Duration. If 0 use default duration lookup for associated skill with level 7
|
* @param duration Duration. If 0 use default duration lookup for associated skill with level 7
|
||||||
**/
|
**/
|
||||||
static void pc_bonus_addeff(struct s_addeffect* effect, int max, enum sc_type sc, short rate, short arrow_rate, unsigned char flag, unsigned int duration)
|
static void pc_bonus_addeff(struct s_addeffect* effect, int pmax, enum sc_type sc, short rate, short arrow_rate, unsigned char flag, unsigned int duration)
|
||||||
{
|
{
|
||||||
uint16 i;
|
uint16 i;
|
||||||
|
|
||||||
@ -2070,18 +2070,18 @@ static void pc_bonus_addeff(struct s_addeffect* effect, int max, enum sc_type sc
|
|||||||
flag |= ATF_WEAPON; //Default type: weapon.
|
flag |= ATF_WEAPON; //Default type: weapon.
|
||||||
|
|
||||||
if (!duration)
|
if (!duration)
|
||||||
duration = skill_get_time2(status_sc2skill(sc),7);
|
duration =(unsigned int) skill_get_time2(status_sc2skill(sc),7);
|
||||||
|
|
||||||
for (i = 0; i < max && effect[i].flag; i++) {
|
for (i = 0; i < pmax && effect[i].flag; i++) {
|
||||||
if (effect[i].sc == sc && effect[i].flag == flag) {
|
if (effect[i].sc == sc && effect[i].flag == flag) {
|
||||||
effect[i].rate += rate;
|
effect[i].rate += rate;
|
||||||
effect[i].arrow_rate += arrow_rate;
|
effect[i].arrow_rate += arrow_rate;
|
||||||
effect[i].duration = max(effect[i].duration, duration);
|
effect[i].duration = umax(effect[i].duration, duration);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i == max) {
|
if (i == pmax) {
|
||||||
ShowWarning("pc_bonus_addeff: Reached max (%d) number of add effects per character!\n", max);
|
ShowWarning("pc_bonus_addeff: Reached max (%d) number of add effects per character!\n", pmax);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
effect[i].sc = sc;
|
effect[i].sc = sc;
|
||||||
@ -2094,28 +2094,28 @@ static void pc_bonus_addeff(struct s_addeffect* effect, int max, enum sc_type sc
|
|||||||
/**
|
/**
|
||||||
* Add inflict effect bonus for player while attacking using skill
|
* Add inflict effect bonus for player while attacking using skill
|
||||||
* @param effect Effect array
|
* @param effect Effect array
|
||||||
* @param max Max array
|
* @param pmax Max array
|
||||||
* @param sc SC/Effect type
|
* @param sc SC/Effect type
|
||||||
* @param rate Success chance
|
* @param rate Success chance
|
||||||
* @param flag Target flag
|
* @param flag Target flag
|
||||||
* @param duration Duration. If 0 use default duration lookup for associated skill with level 7
|
* @param duration Duration. If 0 use default duration lookup for associated skill with level 7
|
||||||
**/
|
**/
|
||||||
static void pc_bonus_addeff_onskill(struct s_addeffectonskill* effect, int max, enum sc_type sc, short rate, short skill_id, unsigned char target, unsigned int duration)
|
static void pc_bonus_addeff_onskill(struct s_addeffectonskill* effect, int pmax, enum sc_type sc, short rate, short skill_id, unsigned char target, unsigned int duration)
|
||||||
{
|
{
|
||||||
uint8 i;
|
uint8 i;
|
||||||
|
|
||||||
if (!duration)
|
if (!duration)
|
||||||
duration = skill_get_time2(status_sc2skill(sc),7);
|
duration =(unsigned int) skill_get_time2(status_sc2skill(sc),7);
|
||||||
|
|
||||||
for( i = 0; i < max && effect[i].skill_id; i++ ) {
|
for( i = 0; i < pmax && effect[i].skill_id; i++ ) {
|
||||||
if( effect[i].sc == sc && effect[i].skill_id == skill_id && effect[i].target == target ) {
|
if( effect[i].sc == sc && effect[i].skill_id == skill_id && effect[i].target == target ) {
|
||||||
effect[i].rate += rate;
|
effect[i].rate += rate;
|
||||||
effect[i].duration = max(effect[i].duration, duration);
|
effect[i].duration = umax(effect[i].duration, duration);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( i == max ) {
|
if( i == pmax ) {
|
||||||
ShowWarning("pc_bonus_addeff_onskill: Reached max (%d) number of add effects on skill per character!\n", max);
|
ShowWarning("pc_bonus_addeff_onskill: Reached max (%d) number of add effects on skill per character!\n", pmax);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
effect[i].sc = sc;
|
effect[i].sc = sc;
|
||||||
@ -4413,7 +4413,7 @@ char pc_additem(struct map_session_data *sd,struct item *item,int amount,e_log_p
|
|||||||
clif_rental_expired(sd->fd, i, sd->status.inventory[i].nameid);
|
clif_rental_expired(sd->fd, i, sd->status.inventory[i].nameid);
|
||||||
pc_delitem(sd, i, sd->status.inventory[i].amount, 1, 0, LOG_TYPE_OTHER);
|
pc_delitem(sd, i, sd->status.inventory[i].amount, 1, 0, LOG_TYPE_OTHER);
|
||||||
} else {
|
} else {
|
||||||
int seconds = (int)( item->expire_time - time(NULL) );
|
unsigned int seconds = ( item->expire_time - time(NULL) );
|
||||||
clif_rental_time(sd->fd, sd->status.inventory[i].nameid, seconds);
|
clif_rental_time(sd->fd, sd->status.inventory[i].nameid, seconds);
|
||||||
pc_inventory_rental_add(sd, seconds);
|
pc_inventory_rental_add(sd, seconds);
|
||||||
}
|
}
|
||||||
@ -5455,7 +5455,7 @@ bool pc_memo(struct map_session_data* sd, int pos)
|
|||||||
uint8 i;
|
uint8 i;
|
||||||
// prevent memo-ing the same map multiple times
|
// prevent memo-ing the same map multiple times
|
||||||
ARR_FIND( 0, MAX_MEMOPOINTS, i, sd->status.memo_point[i].map == map_id2index(sd->bl.m) );
|
ARR_FIND( 0, MAX_MEMOPOINTS, i, sd->status.memo_point[i].map == map_id2index(sd->bl.m) );
|
||||||
memmove(&sd->status.memo_point[1], &sd->status.memo_point[0], (min(i,MAX_MEMOPOINTS-1))*sizeof(struct point));
|
memmove(&sd->status.memo_point[1], &sd->status.memo_point[0], (u8min(i,MAX_MEMOPOINTS-1))*sizeof(struct point));
|
||||||
pos = 0;
|
pos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7461,7 +7461,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
|
|||||||
if (base_penalty > 0){ //recheck after altering to speedup
|
if (base_penalty > 0){ //recheck after altering to speedup
|
||||||
if (battle_config.pk_mode && src && src->type==BL_PC)
|
if (battle_config.pk_mode && src && src->type==BL_PC)
|
||||||
base_penalty*=2;
|
base_penalty*=2;
|
||||||
sd->status.base_exp -= min(sd->status.base_exp, base_penalty);
|
sd->status.base_exp -= u32min(sd->status.base_exp, base_penalty);
|
||||||
clif_updatestatus(sd,SP_BASEEXP);
|
clif_updatestatus(sd,SP_BASEEXP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7474,7 +7474,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
|
|||||||
if(job_penalty) {
|
if(job_penalty) {
|
||||||
if (battle_config.pk_mode && src && src->type==BL_PC)
|
if (battle_config.pk_mode && src && src->type==BL_PC)
|
||||||
job_penalty*=2;
|
job_penalty*=2;
|
||||||
sd->status.job_exp -= min(sd->status.job_exp, job_penalty);
|
sd->status.job_exp -= u32min(sd->status.job_exp, job_penalty);
|
||||||
clif_updatestatus(sd,SP_JOBEXP);
|
clif_updatestatus(sd,SP_JOBEXP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1160,7 +1160,7 @@ int map_night_timer(int tid, unsigned int tick, int id, intptr_t data); // by [y
|
|||||||
// Rental System
|
// Rental System
|
||||||
void pc_inventory_rentals(struct map_session_data *sd);
|
void pc_inventory_rentals(struct map_session_data *sd);
|
||||||
void pc_inventory_rental_clear(struct map_session_data *sd);
|
void pc_inventory_rental_clear(struct map_session_data *sd);
|
||||||
void pc_inventory_rental_add(struct map_session_data *sd, int seconds);
|
void pc_inventory_rental_add(struct map_session_data *sd, unsigned int seconds);
|
||||||
void pc_rental_expire(struct map_session_data *sd, int i);
|
void pc_rental_expire(struct map_session_data *sd, int i);
|
||||||
|
|
||||||
int pc_read_motd(void); // [Valaris]
|
int pc_read_motd(void); // [Valaris]
|
||||||
|
@ -2659,7 +2659,7 @@ void skill_combo_toogle_inf(struct block_list* bl, uint16 skill_id, int inf){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void skill_combo(struct block_list* src,struct block_list *dsrc, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int tick){
|
void skill_combo(struct block_list* src,struct block_list *dsrc, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int tick){
|
||||||
int duration = 0; //Set to duration the user can use a combo skill or 1 for aftercast delay of pre-skill
|
unsigned int duration = 0; //Set to duration the user can use a combo skill or 1 for aftercast delay of pre-skill
|
||||||
int nodelay = 0; //Set to 1 for no walk/attack delay, set to 2 for no walk delay
|
int nodelay = 0; //Set to 1 for no walk/attack delay, set to 2 for no walk delay
|
||||||
int target_id = bl->id; //Set to 0 if combo skill should not autotarget
|
int target_id = bl->id; //Set to 0 if combo skill should not autotarget
|
||||||
struct status_change_entry *sce;
|
struct status_change_entry *sce;
|
||||||
@ -2751,7 +2751,7 @@ void skill_combo(struct block_list* src,struct block_list *dsrc, struct block_li
|
|||||||
|
|
||||||
if (duration) { //Possible to chain
|
if (duration) { //Possible to chain
|
||||||
if(sd && duration==1) duration = DIFF_TICK(sd->ud.canact_tick, tick); //Auto calc duration
|
if(sd && duration==1) duration = DIFF_TICK(sd->ud.canact_tick, tick); //Auto calc duration
|
||||||
duration = max(status_get_amotion(src),duration); //Never less than aMotion
|
duration = umax(status_get_amotion(src),duration); //Never less than aMotion
|
||||||
sc_start4(src,src,SC_COMBO,100,skill_id,target_id,nodelay,0,duration);
|
sc_start4(src,src,SC_COMBO,100,skill_id,target_id,nodelay,0,duration);
|
||||||
clif_combo_delay(src, duration);
|
clif_combo_delay(src, duration);
|
||||||
}
|
}
|
||||||
@ -4905,7 +4905,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
|
|||||||
clif_spiritball(src);
|
clif_spiritball(src);
|
||||||
}
|
}
|
||||||
skill_attack(BF_MISC, src, src, bl, skill_id, skill_lv, tick, flag);
|
skill_attack(BF_MISC, src, src, bl, skill_id, skill_lv, tick, flag);
|
||||||
status_set_hp(src, max(status_get_max_hp(src) / 100, 1), 0);
|
status_set_hp(src, umax(status_get_max_hp(src) / 100, 1), 0);
|
||||||
status_change_end(src, SC_NEN, INVALID_TIMER);
|
status_change_end(src, SC_NEN, INVALID_TIMER);
|
||||||
status_change_end(src, SC_HIDING, INVALID_TIMER);
|
status_change_end(src, SC_HIDING, INVALID_TIMER);
|
||||||
}
|
}
|
||||||
@ -10159,10 +10159,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
|
|||||||
case KO_KAZEHU_SEIRAN:
|
case KO_KAZEHU_SEIRAN:
|
||||||
case KO_DOHU_KOUKAI:
|
case KO_DOHU_KOUKAI:
|
||||||
if (sd) {
|
if (sd) {
|
||||||
int type = skill_get_ele(skill_id,skill_lv);
|
int ele_type = skill_get_ele(skill_id,skill_lv);
|
||||||
|
|
||||||
clif_skill_nodamage(src,bl,skill_id,skill_lv,1);
|
clif_skill_nodamage(src,bl,skill_id,skill_lv,1);
|
||||||
pc_addspiritcharm(sd,skill_get_time(skill_id,skill_lv),MAX_SPIRITCHARM,type);
|
pc_addspiritcharm(sd,skill_get_time(skill_id,skill_lv),MAX_SPIRITCHARM,ele_type);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KO_ZANZOU:
|
case KO_ZANZOU:
|
||||||
|
@ -2918,30 +2918,30 @@ static int status_get_spbonus(struct block_list *bl, enum e_status_bonus type) {
|
|||||||
* @return max The max value of HP or SP
|
* @return max The max value of HP or SP
|
||||||
*/
|
*/
|
||||||
static unsigned int status_calc_maxhpsp_pc(struct map_session_data* sd, unsigned int stat, bool isHP) {
|
static unsigned int status_calc_maxhpsp_pc(struct map_session_data* sd, unsigned int stat, bool isHP) {
|
||||||
double max = 0;
|
double dmax = 0;
|
||||||
uint16 idx, level, job_id;
|
uint16 idx, level, job_id;
|
||||||
|
|
||||||
nullpo_ret(sd);
|
nullpo_ret(sd);
|
||||||
|
|
||||||
job_id = pc_mapid2jobid(sd->class_,sd->status.sex);
|
job_id = pc_mapid2jobid(sd->class_,sd->status.sex);
|
||||||
idx = pc_class2idx(job_id);
|
idx = pc_class2idx(job_id);
|
||||||
level = max(sd->status.base_level,1);
|
level = umax(sd->status.base_level,1);
|
||||||
|
|
||||||
if (isHP) { //Calculates MaxHP
|
if (isHP) { //Calculates MaxHP
|
||||||
max = job_info[idx].base_hp[level-1] * (1 + (max(stat,1) * 0.01)) * ((sd->class_&JOBL_UPPER)?1.25:1);
|
dmax = job_info[idx].base_hp[level-1] * (1 + (umax(stat,1) * 0.01)) * ((sd->class_&JOBL_UPPER)?1.25:1);
|
||||||
max += status_get_hpbonus(&sd->bl,STATUS_BONUS_FIX);
|
dmax += status_get_hpbonus(&sd->bl,STATUS_BONUS_FIX);
|
||||||
max += (int64)(max * status_get_hpbonus(&sd->bl,STATUS_BONUS_RATE) / 100); //Aegis accuracy
|
dmax += (int64)(dmax * status_get_hpbonus(&sd->bl,STATUS_BONUS_RATE) / 100); //Aegis accuracy
|
||||||
}
|
}
|
||||||
else { //Calculates MaxSP
|
else { //Calculates MaxSP
|
||||||
max = job_info[idx].base_sp[level-1] * (1 + (max(stat,1) * 0.01)) * ((sd->class_&JOBL_UPPER)?1.25:1);
|
dmax = job_info[idx].base_sp[level-1] * (1 + (umax(stat,1) * 0.01)) * ((sd->class_&JOBL_UPPER)?1.25:1);
|
||||||
max += status_get_spbonus(&sd->bl,STATUS_BONUS_FIX);
|
dmax += status_get_spbonus(&sd->bl,STATUS_BONUS_FIX);
|
||||||
max += (int64)(max * status_get_spbonus(&sd->bl,STATUS_BONUS_RATE) / 100); //Aegis accuracy
|
dmax += (int64)(dmax * status_get_spbonus(&sd->bl,STATUS_BONUS_RATE) / 100); //Aegis accuracy
|
||||||
}
|
}
|
||||||
|
|
||||||
//Make sure it's not negative before casting to unsigned int
|
//Make sure it's not negative before casting to unsigned int
|
||||||
if(max < 1) max = 1;
|
if(dmax < 1) dmax = 1;
|
||||||
|
|
||||||
return cap_value((unsigned int)max,1,UINT_MAX);
|
return cap_value((unsigned int)dmax,1,UINT_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -4238,7 +4238,7 @@ void status_calc_state( struct block_list *bl, struct status_change *sc, enum sc
|
|||||||
// Can't move
|
// Can't move
|
||||||
if( flag&SCS_NOMOVE ) {
|
if( flag&SCS_NOMOVE ) {
|
||||||
if( !(flag&SCS_NOMOVECOND) )
|
if( !(flag&SCS_NOMOVECOND) )
|
||||||
sc->cant.move += ( start ? 1 : -1 );
|
sc->cant.move += ( start ? 1 : ((sc->cant.move)? -1:0) );
|
||||||
else if(
|
else if(
|
||||||
(sc->data[SC_GOSPEL] && sc->data[SC_GOSPEL]->val4 == BCT_SELF) // cannot move while gospel is in effect
|
(sc->data[SC_GOSPEL] && sc->data[SC_GOSPEL]->val4 == BCT_SELF) // cannot move while gospel is in effect
|
||||||
|| (sc->data[SC_BASILICA] && sc->data[SC_BASILICA]->val4 == bl->id) // Basilica caster cannot move
|
|| (sc->data[SC_BASILICA] && sc->data[SC_BASILICA]->val4 == bl->id) // Basilica caster cannot move
|
||||||
@ -4247,8 +4247,7 @@ void status_calc_state( struct block_list *bl, struct status_change *sc, enum sc
|
|||||||
|| (sc->data[SC_CAMOUFLAGE] && sc->data[SC_CAMOUFLAGE]->val1 < 3)
|
|| (sc->data[SC_CAMOUFLAGE] && sc->data[SC_CAMOUFLAGE]->val1 < 3)
|
||||||
|| (sc->data[SC_MAGNETICFIELD] && sc->data[SC_MAGNETICFIELD]->val2 != bl->id)
|
|| (sc->data[SC_MAGNETICFIELD] && sc->data[SC_MAGNETICFIELD]->val2 != bl->id)
|
||||||
)
|
)
|
||||||
sc->cant.move += ( start ? 1 : -1 );
|
sc->cant.move += ( start ? 1 : ((sc->cant.move)? -1:0) );
|
||||||
sc->cant.move = max(sc->cant.move,0); // safecheck
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can't use skills
|
// Can't use skills
|
||||||
@ -4564,7 +4563,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag)
|
|||||||
if(battle_config.hp_rate != 100)
|
if(battle_config.hp_rate != 100)
|
||||||
status->max_hp = (unsigned int)(battle_config.hp_rate * (status->max_hp/100.));
|
status->max_hp = (unsigned int)(battle_config.hp_rate * (status->max_hp/100.));
|
||||||
|
|
||||||
status->max_hp = min(status->max_hp,(unsigned int)battle_config.max_hp);
|
status->max_hp = umin(status->max_hp,(unsigned int)battle_config.max_hp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
status->max_hp = status_calc_maxhp(bl, b_status->max_hp);
|
status->max_hp = status_calc_maxhp(bl, b_status->max_hp);
|
||||||
@ -4582,7 +4581,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag)
|
|||||||
if(battle_config.sp_rate != 100)
|
if(battle_config.sp_rate != 100)
|
||||||
status->max_sp = (unsigned int)(battle_config.sp_rate * (status->max_sp/100.));
|
status->max_sp = (unsigned int)(battle_config.sp_rate * (status->max_sp/100.));
|
||||||
|
|
||||||
status->max_sp = min(status->max_sp,(unsigned int)battle_config.max_sp);
|
status->max_sp = umin(status->max_sp,(unsigned int)battle_config.max_sp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
status->max_sp = status_calc_maxsp(bl, b_status->max_sp);
|
status->max_sp = status_calc_maxsp(bl, b_status->max_sp);
|
||||||
|
@ -580,7 +580,8 @@ bool gstorage_additem2(struct guild_storage* stor, struct item* item, int amount
|
|||||||
for (i = 0; i < MAX_GUILD_STORAGE; i++) {
|
for (i = 0; i < MAX_GUILD_STORAGE; i++) {
|
||||||
if (compare_item(&stor->items[i], item)) {
|
if (compare_item(&stor->items[i], item)) {
|
||||||
// Set the amount, make it fit with max amount
|
// Set the amount, make it fit with max amount
|
||||||
amount = min(amount, ((id->stack.guildstorage) ? id->stack.amount : MAX_AMOUNT) - stor->items[i].amount);
|
int da = ((id->stack.guildstorage) ? id->stack.amount : MAX_AMOUNT) - stor->items[i].amount;
|
||||||
|
amount = min(amount, da);
|
||||||
if (amount != item->amount)
|
if (amount != item->amount)
|
||||||
ShowWarning("gstorage_additem2: Stack limit reached! Altered amount of item \""CL_WHITE"%s"CL_RESET"\" (%d). '"CL_WHITE"%d"CL_RESET"' -> '"CL_WHITE"%d"CL_RESET"'.\n", id->name, id->nameid, item->amount, amount);
|
ShowWarning("gstorage_additem2: Stack limit reached! Altered amount of item \""CL_WHITE"%s"CL_RESET"\" (%d). '"CL_WHITE"%d"CL_RESET"' -> '"CL_WHITE"%d"CL_RESET"'.\n", id->name, id->nameid, item->amount, amount);
|
||||||
stor->items[i].amount += amount;
|
stor->items[i].amount += amount;
|
||||||
|
@ -567,7 +567,7 @@ void do_init_vending_autotrade(void)
|
|||||||
Sql_GetData(mmysql_handle, 1, &data, NULL); at->account_id = atoi(data);
|
Sql_GetData(mmysql_handle, 1, &data, NULL); at->account_id = atoi(data);
|
||||||
Sql_GetData(mmysql_handle, 2, &data, NULL); at->char_id = atoi(data);
|
Sql_GetData(mmysql_handle, 2, &data, NULL); at->char_id = atoi(data);
|
||||||
Sql_GetData(mmysql_handle, 3, &data, NULL); at->sex = (data[0] == 'F') ? SEX_FEMALE : SEX_MALE;
|
Sql_GetData(mmysql_handle, 3, &data, NULL); at->sex = (data[0] == 'F') ? SEX_FEMALE : SEX_MALE;
|
||||||
Sql_GetData(mmysql_handle, 4, &data, &len); safestrncpy(at->title, data, min(len + 1, MESSAGE_SIZE));
|
Sql_GetData(mmysql_handle, 4, &data, &len); safestrncpy(at->title, data, zmin(len + 1, MESSAGE_SIZE));
|
||||||
Sql_GetData(mmysql_handle, 5, &data, NULL); at->dir = atoi(data);
|
Sql_GetData(mmysql_handle, 5, &data, NULL); at->dir = atoi(data);
|
||||||
Sql_GetData(mmysql_handle, 6, &data, NULL); at->head_dir = atoi(data);
|
Sql_GetData(mmysql_handle, 6, &data, NULL); at->head_dir = atoi(data);
|
||||||
Sql_GetData(mmysql_handle, 7, &data, NULL); at->sit = atoi(data);
|
Sql_GetData(mmysql_handle, 7, &data, NULL); at->sit = atoi(data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user