Skip to content

Commit

Permalink
* Follow ups of:
Browse files Browse the repository at this point in the history
-- 51074a0: Moved the 'group' check when make 'must' item also as random item
-- 96443cd: Leftover, fixed @allstats issue
-- 7083ecf: 7083ecf#commitcomment-4952745
-- 744195a
* Added 'get_githash' script command.
* Fixed overflowed parameters calculation will gives 32767 stat effect instead 1 (ex. overflowed LUK will gives crit 32767)

Signed-off-by: Cydh Ramdh <house.bad@gmail.com>
  • Loading branch information
cydh committed Dec 30, 2013
1 parent 744195a commit 12007fe
Show file tree
Hide file tree
Showing 11 changed files with 468 additions and 464 deletions.
2 changes: 1 addition & 1 deletion db/magicmushroom_db.txt
@@ -1,4 +1,4 @@
// Magic Mushroom DB
// Magic Mushroom Database
// List of skills that are randomly used through Magic Mushroom status change.
//
// Structure of Database:
Expand Down
11 changes: 10 additions & 1 deletion doc/script_commands.txt
Expand Up @@ -4092,7 +4092,16 @@ This command will return the SVN revision number that the server is
currently running on.

if ( get_revision() >= 15000 )
mes "Welcome rAthena!";
mes "Welcome to rAthena!";

---------------------------------------

*get_githash()

This command will return the Git Hash that the server is currently running on.

set .@gitHash$,get_githash();
mes "Welcome to rAthena! Git Hash: "+.@gitHash$;

---------------------------------------
\\
Expand Down
99 changes: 46 additions & 53 deletions src/map/atcommand.c
Expand Up @@ -2410,10 +2410,10 @@ ACMD_FUNC(zeny)
*------------------------------------------*/
ACMD_FUNC(param)
{
int i, value = 0, new_value;
uint8 i;
int value = 0;
const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
short* status[6];
short max_status[6];
short new_value, *status[6], max_status[6];
//we don't use direct initialization because it isn't part of the c standard.
nullpo_retr(-1, sd);

Expand All @@ -2438,30 +2438,23 @@ ACMD_FUNC(param)
status[4] = &sd->status.dex;
status[5] = &sd->status.luk;

if( battle_config.atcommand_max_stat_bypass ){
max_status[0] = SHRT_MAX;
max_status[1] = SHRT_MAX;
max_status[2] = SHRT_MAX;
max_status[3] = SHRT_MAX;
max_status[4] = SHRT_MAX;
max_status[5] = SHRT_MAX;
}
if( battle_config.atcommand_max_stat_bypass )
max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
else {
max_status[0] = pc_maxparameter(sd->class_,sd->status.sex,PARAM_STR);
max_status[1] = pc_maxparameter(sd->class_,sd->status.sex,PARAM_AGI);
max_status[2] = pc_maxparameter(sd->class_,sd->status.sex,PARAM_VIT);
max_status[3] = pc_maxparameter(sd->class_,sd->status.sex,PARAM_INT);
max_status[4] = pc_maxparameter(sd->class_,sd->status.sex,PARAM_DEX);
max_status[5] = pc_maxparameter(sd->class_,sd->status.sex,PARAM_LUK);
max_status[0] = pc_maxparameter(sd,PARAM_STR);
max_status[1] = pc_maxparameter(sd,PARAM_AGI);
max_status[2] = pc_maxparameter(sd,PARAM_VIT);
max_status[3] = pc_maxparameter(sd,PARAM_INT);
max_status[4] = pc_maxparameter(sd,PARAM_DEX);
max_status[5] = pc_maxparameter(sd,PARAM_LUK);
}

if(value < 0 && *status[i] <= -value) {
new_value = 1;
} else if(max_status[i] - *status[i] < value) {
if(value > 0 && *status[i] + value >= max_status[i])
new_value = max_status[i];
} else {
else if(value < 0 && *status[i] <= -value)
new_value = 1;
else
new_value = *status[i] + value;
}

if (new_value != *status[i]) {
*status[i] = new_value;
Expand All @@ -2485,10 +2478,9 @@ ACMD_FUNC(param)
*------------------------------------------*/
ACMD_FUNC(stat_all)
{
int index, count, value, new_value;
short* status[PARAM_MAX];
short max_status[PARAM_MAX];
short values[PARAM_MAX];
int value = 0;
uint8 count, i;
short *status[PARAM_MAX], max_status[PARAM_MAX];
//we don't use direct initialization because it isn't part of the c standard.
nullpo_retr(-1, sd);

Expand All @@ -2500,39 +2492,40 @@ ACMD_FUNC(stat_all)
status[5] = &sd->status.luk;

if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
uint8 i;
for (i = 0; i < PARAM_MAX; i++) {
values[i] = pc_maxparameter(sd->class_,sd->status.sex,(enum e_params)i);
max_status[i] = pc_maxparameter(sd->class_,sd->status.sex,(enum e_params)i);
}
max_status[0] = pc_maxparameter(sd,PARAM_STR);
max_status[1] = pc_maxparameter(sd,PARAM_AGI);
max_status[2] = pc_maxparameter(sd,PARAM_VIT);
max_status[3] = pc_maxparameter(sd,PARAM_INT);
max_status[4] = pc_maxparameter(sd,PARAM_DEX);
max_status[5] = pc_maxparameter(sd,PARAM_LUK);
value = SHRT_MAX;
} else {
uint8 i;
for (i = 0; i < PARAM_MAX; i++)
values[i] = value;

if( battle_config.atcommand_max_stat_bypass ) {
for (i = 0; i < PARAM_MAX; i++)
max_status[i] = SHRT_MAX;
}
if( battle_config.atcommand_max_stat_bypass )
max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
else {
for (i = 0; i < PARAM_MAX; i++)
max_status[i] = pc_maxparameter(sd->class_,sd->status.sex,(enum e_params)i);
max_status[0] = pc_maxparameter(sd,PARAM_STR);
max_status[1] = pc_maxparameter(sd,PARAM_AGI);
max_status[2] = pc_maxparameter(sd,PARAM_VIT);
max_status[3] = pc_maxparameter(sd,PARAM_INT);
max_status[4] = pc_maxparameter(sd,PARAM_DEX);
max_status[5] = pc_maxparameter(sd,PARAM_LUK);
}
}

count = 0;
for (index = 0; index < ARRAYLENGTH(status); index++) {
if (values[index] > 0 && *status[index] > max_status[index] - values[index])
new_value = max_status[index];
else if (values[index] < 0 && *status[index] <= -values[index])
for (i = 0; i < ARRAYLENGTH(status); i++) {
short new_value;
if (value > 0 && *status[i] + value >= max_status[i])
new_value = max_status[i];
else if (value < 0 && *status[i] <= -value)
new_value = 1;
else
new_value = *status[index] +values[index];
new_value = *status[i] + value;

if (new_value != (int)*status[index]) {
*status[index] = new_value;
clif_updatestatus(sd, SP_STR + index);
clif_updatestatus(sd, SP_USTR + index);
if (new_value != *status[i]) {
*status[i] = new_value;
clif_updatestatus(sd, SP_STR + i);
clif_updatestatus(sd, SP_USTR + i);
count++;
}
}
Expand Down Expand Up @@ -5580,7 +5573,7 @@ ACMD_FUNC(marry)
return -1;
}

if (pc_marriage(sd, pl_sd) == 0) {
if (pc_marriage(sd, pl_sd)) {
clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
getring(sd); // Auto-give named rings (Aru)
Expand All @@ -5600,7 +5593,7 @@ ACMD_FUNC(divorce)
{
nullpo_retr(-1, sd);

if (pc_divorce(sd) != 0) {
if (!pc_divorce(sd)) {
sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
clif_displaymessage(fd, atcmd_output);
return -1;
Expand Down Expand Up @@ -8955,7 +8948,7 @@ ACMD_FUNC(cart) {
MC_CART_MDFY(1);
}

if( pc_setcart(sd, val) ) {
if( !pc_setcart(sd, val) ) {
if( need_skill ) {
MC_CART_MDFY(0);
}
Expand Down
17 changes: 9 additions & 8 deletions src/map/chrif.c
Expand Up @@ -1779,7 +1779,8 @@ int chrif_bsdata_request(int char_id) {
* @param sd
*/
int chrif_save_bsdata(struct map_session_data *sd) {
int i, count=0;
int i;
uint8 count = 0;
unsigned int tick;
struct bonus_script_data bs;
const struct TimerData *timer;
Expand All @@ -1801,7 +1802,7 @@ int chrif_save_bsdata(struct map_session_data *sd) {
pc_bonus_script_clear(sd,i);

for (i = 0; i < MAX_PC_BONUS_SCRIPT; i++) {
if (!(&sd->bonus_script[i]) || !sd->bonus_script[i].script || strlen(sd->bonus_script[i].script_str) == 0)
if (!(&sd->bonus_script[i]) || !sd->bonus_script[i].script || sd->bonus_script[i].script_str == '\0')
continue;

timer = get_timer(sd->bonus_script[i].tid);
Expand Down Expand Up @@ -1835,9 +1836,9 @@ int chrif_save_bsdata(struct map_session_data *sd) {
*/
int chrif_load_bsdata(int fd) {
struct map_session_data *sd;
struct bonus_script_data *bs;
int cid, count;
uint8 i, count_ = 0;
uint8 i;
bool calc = false;

cid = RFIFOL(fd,4);
sd = map_charid2sd(cid);
Expand All @@ -1856,9 +1857,9 @@ int chrif_load_bsdata(int fd) {

for (i = 0; i < count; i++) {
struct script_code *script;
bs = (struct bonus_script_data*)RFIFOP(fd,10 + i*sizeof(struct bonus_script_data));
struct bonus_script_data *bs = (struct bonus_script_data*)RFIFOP(fd,10 + i*sizeof(struct bonus_script_data));

if (!(script = parse_script(bs->script,"chrif_load_bsdata",1,1)))
if (bs->script == '\0' || !(script = parse_script(bs->script,"chrif_load_bsdata",1,1)))
continue;

memcpy(sd->bonus_script[i].script_str,bs->script,strlen(bs->script));
Expand All @@ -1869,9 +1870,9 @@ int chrif_load_bsdata(int fd) {
sd->bonus_script[i].icon = bs->icon;
if (bs->icon != SI_BLANK) //Gives status icon if exist
clif_status_change(&sd->bl,sd->bonus_script[i].icon,1,bs->tick,1,0,0);
count_++;
calc = true;
}
if (count_)
if (calc)
status_calc_pc(sd,false);
return 0;
}
Expand Down

0 comments on commit 12007fe

Please sign in to comment.