summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/script_commands.txt14
-rw-r--r--src/char/char.c30
-rw-r--r--src/char/char.h1
-rw-r--r--src/char/inter.c116
-rw-r--r--src/char/inter.h1
-rw-r--r--src/login/login.c40
-rw-r--r--src/map/atcommand.c2
-rw-r--r--src/map/battle.c48
-rw-r--r--src/map/script.c13
9 files changed, 159 insertions, 106 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index aa8698418..6a48692e8 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -638,7 +638,7 @@ even a value from an another array) to get at an array value:
This will make @arrayofnumbers[100] equal to 10.
Notice that index numbering always starts with 0. Arrays can hold over
-4 billion variables.
+2 billion variables.
And array indexes probably can't be negative. Nobody tested what happens
when you try to get a negatively numbered variable from an array, but it's
@@ -4939,21 +4939,17 @@ the command will end silently.
---------------------------------------
-*successrefitem <equipment slot>;
+*successrefitem <equipment slot>{,<upgrade_count>};
This command will refine an item in the specified equipment slot of the
-invoking character by +1. For a list of equipment slots see 'getequipid'.
-This command will not only add the +1, but also display a 'refine success'
+invoking character by +1 (unless <upgrade_count> is specified).
+For a list of equipment slots see 'getequipid'.
+This command will also display a 'refine success'
effect on the character and put appropriate messages into their chat
window. It will also give the character fame points if a weapon reached
+10 this way, even though these will only take effect for blacksmith who
will later forge a weapon.
-The official scripts seems to use the 'successrefitem' command as a
-function instead: 'successrefitem(<number>)' but it returns nothing on the
-stack. This is since jAthena, so probably nobody knows for sure why is it
-so.
-
---------------------------------------
*failedrefitem <equipment slot>;
diff --git a/src/char/char.c b/src/char/char.c
index 709148db1..4ea1f8451 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -2558,6 +2558,26 @@ int parse_fromlogin(int fd) {
}
break;
+ case 0x2736: // Failed accinfo lookup to forward to mapserver
+ if (RFIFOREST(fd) < 18)
+ return 0;
+
+ mapif_parse_accinfo2(false, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14),
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1, 0, 0);
+ RFIFOSKIP(fd,18);
+ break;
+
+ case 0x2737: // Successful accinfo lookup to forward to mapserver
+ if (RFIFOREST(fd) < 183)
+ return 0;
+
+ mapif_parse_accinfo2(true, RFIFOL(fd,167), RFIFOL(fd,171), RFIFOL(fd,175), RFIFOL(fd,179),
+ (char*)RFIFOP(fd,2), (char*)RFIFOP(fd,26), (char*)RFIFOP(fd,59),
+ (char*)RFIFOP(fd,99), (char*)RFIFOP(fd,119), (char*)RFIFOP(fd,151),
+ (char*)RFIFOP(fd,156), RFIFOL(fd,115), RFIFOL(fd,143), RFIFOL(fd,147));
+ RFIFOSKIP(fd,183);
+ break;
+
default:
ShowError("Unknown packet 0x%04x received from login-server, disconnecting.\n", command);
set_eof(fd);
@@ -2852,6 +2872,16 @@ void mapif_on_disconnect(int id)
mapif_server_reset(id);
}
+void mapif_on_parse_accinfo(int account_id, int u_fd, int u_aid, int u_group, int map_fd) {
+ WFIFOHEAD(login_fd,22);
+ WFIFOW(login_fd,0) = 0x2740;
+ WFIFOL(login_fd,2) = account_id;
+ WFIFOL(login_fd,6) = u_fd;
+ WFIFOL(login_fd,10) = u_aid;
+ WFIFOL(login_fd,14) = u_group;
+ WFIFOL(login_fd,18) = map_fd;
+ WFIFOSET(login_fd,22);
+}
int parse_frommap(int fd)
{
diff --git a/src/char/char.h b/src/char/char.h
index 06c0556c5..372af91f7 100644
--- a/src/char/char.h
+++ b/src/char/char.h
@@ -63,6 +63,7 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit
int mapif_sendall(unsigned char *buf,unsigned int len);
int mapif_sendallwos(int fd,unsigned char *buf,unsigned int len);
int mapif_send(int fd,unsigned char *buf,unsigned int len);
+void mapif_on_parse_accinfo(int account_id,int u_fd, int aid, int castergroup, int map_fd);
int char_married(int pl1,int pl2);
int char_child(int parent_id, int child_id);
diff --git a/src/char/inter.c b/src/char/inter.c
index 34ecebd36..ff99865f8 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -511,83 +511,65 @@ void mapif_parse_accinfo(int fd) {
}
/* it will only get here if we have a single match */
+ /* and we will send packet with account id to login server asking for account info */
if( account_id ) {
- char userid[NAME_LENGTH], user_pass[NAME_LENGTH], email[40], last_ip[20], lastlogin[30], pin_code[5], birthdate[11];
- short level = -1;
- int logincount = 0,state = 0;
- // FIXME: No, this doesn't really look right. We can't, and shouldn't, access the login table from the char server.
- if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `userid`, `user_pass`, `email`, `last_ip`, `group_id`, `lastlogin`, `logincount`, `state`,`pincode`,`birthdate` FROM `login` WHERE `account_id` = '%d' LIMIT 1", account_id)
- || SQL->NumRows(sql_handle) == 0 ) {
- if( SQL->NumRows(sql_handle) == 0 ) {
- inter_msg_to_fd(fd, u_fd, aid, "No account with ID '%d' was found.", account_id );
- } else {
- inter_msg_to_fd(fd, u_fd, aid, "An error occured, bother your admin about it.");
- Sql_ShowDebug(sql_handle);
- }
- } else {
- SQL->NextRow(sql_handle);
- SQL->GetData(sql_handle, 0, &data, NULL); safestrncpy(userid, data, sizeof(userid));
- SQL->GetData(sql_handle, 1, &data, NULL); safestrncpy(user_pass, data, sizeof(user_pass));
- SQL->GetData(sql_handle, 2, &data, NULL); safestrncpy(email, data, sizeof(email));
- SQL->GetData(sql_handle, 3, &data, NULL); safestrncpy(last_ip, data, sizeof(last_ip));
- SQL->GetData(sql_handle, 4, &data, NULL); level = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); safestrncpy(lastlogin, data, sizeof(lastlogin));
- SQL->GetData(sql_handle, 6, &data, NULL); logincount = atoi(data);
- SQL->GetData(sql_handle, 7, &data, NULL); state = atoi(data);
- SQL->GetData(sql_handle, 8, &data, NULL); safestrncpy(pin_code, data, sizeof(pin_code));
- SQL->GetData(sql_handle, 9, &data, NULL); safestrncpy(birthdate, data, sizeof(birthdate));
- }
-
- SQL->FreeResult(sql_handle);
-
- if (level == -1)
- return;
-
- inter_msg_to_fd(fd, u_fd, aid, "-- Account %d --", account_id );
- inter_msg_to_fd(fd, u_fd, aid, "User: %s | GM Group: %d | State: %d", userid, level, state );
+ mapif_on_parse_accinfo(account_id, u_fd, aid, castergroup, fd);
+ }
- if (level < castergroup) { /* only show pass if your gm level is greater than the one you're searching for */
- if( strlen(pin_code) )
- inter_msg_to_fd(fd, u_fd, aid, "Password: %s (PIN:%s)", user_pass, pin_code );
- else
- inter_msg_to_fd(fd, u_fd, aid, "Password: %s", user_pass );
- }
+ return;
+}
+void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int account_id, const char *userid, const char *user_pass, const char *email, const char *last_ip, const char *lastlogin, const char *pin_code, const char *birthdate, int group_id, int logincount, int state) {
+ if (map_fd <= 0 || !session_isActive(map_fd))
+ return; // check if we have a valid fd
- inter_msg_to_fd(fd, u_fd, aid, "Account e-mail: %s | Birthdate: %s", email, birthdate);
- inter_msg_to_fd(fd, u_fd, aid, "Last IP: %s (%s)", last_ip, geoip_getcountry(str2ip(last_ip)) );
- inter_msg_to_fd(fd, u_fd, aid, "This user has logged %d times, the last time were at %s", logincount, lastlogin );
- inter_msg_to_fd(fd, u_fd, aid, "-- Character Details --" );
+ if (!success) {
+ inter_msg_to_fd(map_fd, u_fd, u_aid, "No account with ID '%d' was found.", account_id);
+ return;
+ }
+ inter_msg_to_fd(map_fd, u_fd, u_aid, "-- Account %d --", account_id);
+ inter_msg_to_fd(map_fd, u_fd, u_aid, "User: %s | GM Group: %d | State: %d", userid, group_id, state);
- if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `char_id`, `name`, `char_num`, `class`, `base_level`, `job_level`, `online` FROM `%s` WHERE `account_id` = '%d' ORDER BY `char_num` LIMIT %d", char_db, account_id, MAX_CHARS)
- || SQL->NumRows(sql_handle) == 0 ) {
+ if (user_pass && *user_pass != '\0') { /* password is only received if your gm level is greater than the one you're searching for */
+ if (pin_code && *pin_code != '\0')
+ inter_msg_to_fd(map_fd, u_fd, u_aid, "Password: %s (PIN:%s)", user_pass, pin_code);
+ else
+ inter_msg_to_fd(map_fd, u_fd, u_aid, "Password: %s", user_pass );
+ }
- if( SQL->NumRows(sql_handle) == 0 )
- inter_msg_to_fd(fd, u_fd, aid,"This account doesn't have characters.");
- else {
- inter_msg_to_fd(fd, u_fd, aid,"An error occured, bother your admin about it.");
- Sql_ShowDebug(sql_handle);
- }
+ inter_msg_to_fd(map_fd, u_fd, u_aid, "Account e-mail: %s | Birthdate: %s", email, birthdate);
+ inter_msg_to_fd(map_fd, u_fd, u_aid, "Last IP: %s (%s)", last_ip, geoip_getcountry(str2ip(last_ip)));
+ inter_msg_to_fd(map_fd, u_fd, u_aid, "This user has logged %d times, the last time were at %s", logincount, lastlogin);
+ inter_msg_to_fd(map_fd, u_fd, u_aid, "-- Character Details --");
+ if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `char_id`, `name`, `char_num`, `class`, `base_level`, `job_level`, `online` "
+ "FROM `%s` WHERE `account_id` = '%d' ORDER BY `char_num` LIMIT %d", char_db, account_id, MAX_CHARS)
+ || SQL->NumRows(sql_handle) == 0 ) {
+ if (SQL->NumRows(sql_handle) == 0) {
+ inter_msg_to_fd(map_fd, u_fd, u_aid, "This account doesn't have characters.");
} else {
- while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
- int char_id, class_;
- short char_num, base_level, job_level, online;
- char name[NAME_LENGTH];
-
- SQL->GetData(sql_handle, 0, &data, NULL); char_id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
- SQL->GetData(sql_handle, 2, &data, NULL); char_num = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); class_ = atoi(data);
- SQL->GetData(sql_handle, 4, &data, NULL); base_level = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); job_level = atoi(data);
- SQL->GetData(sql_handle, 6, &data, NULL); online = atoi(data);
-
- inter_msg_to_fd(fd, u_fd, aid, "[Slot/CID: %d/%d] %s | %s | Level: %d/%d | %s", char_num, char_id, name, job_name(class_), base_level, job_level, online?"On":"Off");
- }
+ inter_msg_to_fd(map_fd, u_fd, u_aid, "An error occured, bother your admin about it.");
+ Sql_ShowDebug(sql_handle);
+ }
+ } else {
+ while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
+ char *data;
+ int char_id, class_;
+ short char_num, base_level, job_level, online;
+ char name[NAME_LENGTH];
+
+ SQL->GetData(sql_handle, 0, &data, NULL); char_id = atoi(data);
+ SQL->GetData(sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
+ SQL->GetData(sql_handle, 2, &data, NULL); char_num = atoi(data);
+ SQL->GetData(sql_handle, 3, &data, NULL); class_ = atoi(data);
+ SQL->GetData(sql_handle, 4, &data, NULL); base_level = atoi(data);
+ SQL->GetData(sql_handle, 5, &data, NULL); job_level = atoi(data);
+ SQL->GetData(sql_handle, 6, &data, NULL); online = atoi(data);
+
+ inter_msg_to_fd(map_fd, u_fd, u_aid, "[Slot/CID: %d/%d] %s | %s | Level: %d/%d | %s", char_num, char_id, name, job_name(class_), base_level, job_level, online?"On":"Off");
}
- SQL->FreeResult(sql_handle);
}
+ SQL->FreeResult(sql_handle);
return;
}
diff --git a/src/char/inter.h b/src/char/inter.h
index 2c07b20e2..b484a1610 100644
--- a/src/char/inter.h
+++ b/src/char/inter.h
@@ -15,6 +15,7 @@ int inter_parse_frommap(int fd);
int inter_mapif_init(int fd);
int mapif_send_gmaccounts(void);
int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason);
+void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int account_id, const char *userid, const char *user_pass, const char *email, const char *last_ip, const char *lastlogin, const char *pin_code, const char *birthdate, int group_id, int logincount, int state);
int inter_log(char *fmt,...);
int inter_vlog(char *fmt, va_list ap);
diff --git a/src/login/login.c b/src/login/login.c
index 249d008ec..252031bb8 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -832,6 +832,46 @@ int parse_fromchar(int fd)
}
break;
+ case 0x2740: // Accinfo request forwarded by charserver on mapserver's account
+ if( RFIFOREST(fd) < 22 )
+ return 0;
+ else {
+ struct mmo_account acc;
+ int account_id = RFIFOL(fd, 2), u_fd = RFIFOL(fd, 6), u_aid = RFIFOL(fd, 10), u_group = RFIFOL(fd, 14), map_fd = RFIFOL(fd, 18);
+ if (accounts->load_num(accounts, &acc, account_id)) {
+ WFIFOHEAD(fd,183);
+ WFIFOW(fd,0) = 0x2737;
+ safestrncpy((char*)WFIFOP(fd,2), acc.userid, NAME_LENGTH);
+ if (u_group >= acc.group_id) {
+ safestrncpy((char*)WFIFOP(fd,26), acc.pass, 33);
+ }
+ safestrncpy((char*)WFIFOP(fd,59), acc.email, 40);
+ safestrncpy((char*)WFIFOP(fd,99), acc.last_ip, 16);
+ WFIFOL(fd,115) = acc.group_id;
+ safestrncpy((char*)WFIFOP(fd,119), acc.lastlogin, 24);
+ WFIFOL(fd,143) = acc.logincount;
+ WFIFOL(fd,147) = acc.state;
+ if (u_group >= acc.group_id) {
+ safestrncpy((char*)WFIFOP(fd,151), acc.pincode, 5);
+ }
+ safestrncpy((char*)WFIFOP(fd,156), acc.birthdate, 11);
+ WFIFOL(fd,167) = map_fd;
+ WFIFOL(fd,171) = u_fd;
+ WFIFOL(fd,175) = u_aid;
+ WFIFOL(fd,179) = account_id;
+ WFIFOSET(fd,183);
+ } else {
+ WFIFOHEAD(fd,18);
+ WFIFOW(fd,0) = 0x2736;
+ WFIFOL(fd,2) = map_fd;
+ WFIFOL(fd,6) = u_fd;
+ WFIFOL(fd,10) = u_aid;
+ WFIFOL(fd,14) = account_id;
+ WFIFOSET(fd,18);
+ }
+ RFIFOSKIP(fd,22);
+ }
+ break;
default:
ShowError("parse_fromchar: Unknown packet 0x%x from a char-server! Disconnecting!\n", command);
set_eof(fd);
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 6177fad23..2849ada0b 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -64,7 +64,7 @@ struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
if( *name == atcommand->at_symbol || *name == atcommand->char_symbol )
name++; // for backwards compatibility
- ARR_FIND( 0, atcommand->binding_count, i, strcmp(atcommand->binding[i]->command, name) == 0 );
+ ARR_FIND( 0, atcommand->binding_count, i, strcmpi(atcommand->binding[i]->command, name) == 0 );
return ( i < atcommand->binding_count ) ? atcommand->binding[i] : NULL;
}
diff --git a/src/map/battle.c b/src/map/battle.c
index 687db1b95..1a04aeff9 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -3411,36 +3411,36 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
ad.damage = battle->calc_cardfix(BF_MAGIC, src, target, nk, s_ele, 0, ad.damage, 0, ad.flag);
#endif
if(sd) {
- uint16 skill;
+ uint16 rskill;/* redirect skill */
//Damage bonuses
if ((i = pc->skillatk_bonus(sd, skill_id)))
ad.damage += ad.damage*i/100;
switch(skill_id){
case WL_CHAINLIGHTNING_ATK:
- skill = WL_CHAINLIGHTNING;
+ rskill = WL_CHAINLIGHTNING;
break;
case AB_DUPLELIGHT_MAGIC:
- skill = AB_DUPLELIGHT;
+ rskill = AB_DUPLELIGHT;
break;
case WL_TETRAVORTEX_FIRE:
case WL_TETRAVORTEX_WATER:
case WL_TETRAVORTEX_WIND:
case WL_TETRAVORTEX_GROUND:
- skill = WL_TETRAVORTEX;
+ rskill = WL_TETRAVORTEX;
break;
case WL_SUMMON_ATK_FIRE:
case WL_SUMMON_ATK_WIND:
case WL_SUMMON_ATK_WATER:
case WL_SUMMON_ATK_GROUND:
- skill = WL_RELEASE;
+ rskill = WL_RELEASE;
break;
case WM_REVERBERATION_MAGIC:
- skill = WM_REVERBERATION;
+ rskill = WM_REVERBERATION;
break;
default:
- skill = skill_id;
+ rskill = skill_id;
}
- if( (i = battle->adjust_skill_damage(src->m,skill)) )
+ if( (i = battle->adjust_skill_damage(src->m,rskill)) )
MATK_RATE(i);
//Ignore Defense?
@@ -3877,15 +3877,15 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
#endif
md.damage = battle->calc_cardfix(BF_MISC, src, target, nk, s_ele, 0, md.damage, 0, md.flag);
if(skill_id){
- uint16 skill;
+ uint16 rskill;/* redirect skill id */
switch(skill_id){
case GN_HELLS_PLANT_ATK:
- skill = GN_HELLS_PLANT;
+ rskill = GN_HELLS_PLANT;
break;
default:
- skill = skill_id;
+ rskill = skill_id;
}
- if (sd && (i = pc->skillatk_bonus(sd, skill)))
+ if (sd && (i = pc->skillatk_bonus(sd, rskill)))
md.damage += md.damage*i/100;
}
if( (i = battle->adjust_skill_damage(src->m,skill_id)) )
@@ -4734,40 +4734,40 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
break;
}
if( skill_id ){
- uint16 skill;
+ uint16 rskill;/* redirect skill id */
switch(skill_id){
case AB_DUPLELIGHT_MELEE:
- skill = AB_DUPLELIGHT;
+ rskill = AB_DUPLELIGHT;
break;
case LG_OVERBRAND_BRANDISH:
case LG_OVERBRAND_PLUSATK:
- skill = LG_OVERBRAND;
+ rskill = LG_OVERBRAND;
break;
case WM_SEVERE_RAINSTORM_MELEE:
- skill = WM_SEVERE_RAINSTORM;
+ rskill = WM_SEVERE_RAINSTORM;
break;
case WM_REVERBERATION_MELEE:
- skill = WM_REVERBERATION;
+ rskill = WM_REVERBERATION;
break;
case GN_CRAZYWEED_ATK:
- skill = GN_CRAZYWEED;
+ rskill = GN_CRAZYWEED;
break;
case GN_SLINGITEM_RANGEMELEEATK:
- skill = GN_SLINGITEM;
+ rskill = GN_SLINGITEM;
break;
case RL_R_TRIP_PLUSATK:
- skill = RL_R_TRIP;
+ rskill = RL_R_TRIP;
break;
case RL_B_FLICKER_ATK:
- skill = RL_FLICKER;
+ rskill = RL_FLICKER;
break;
case RL_GLITTERING_GREED_ATK:
- skill = RL_GLITTERING_GREED;
+ rskill = RL_GLITTERING_GREED;
break;
default:
- skill = skill_id;
+ rskill = skill_id;
}
- if( (i = battle->adjust_skill_damage(src->m,skill)) )
+ if( (i = battle->adjust_skill_damage(src->m,rskill)) )
ATK_RATE(i);
}
diff --git a/src/map/script.c b/src/map/script.c
index 4fb4e7224..7ca6a7ddd 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -7666,9 +7666,8 @@ BUILDIN(getequippercentrefinery) {
/*==========================================
* Refine +1 item at pos and log and display refine
*------------------------------------------*/
-BUILDIN(successrefitem)
-{
- int i=-1,num,ep;
+BUILDIN(successrefitem) {
+ int i = -1 , num, ep, up = 1;
TBL_PC *sd;
num = script_getnum(st,2);
@@ -7676,6 +7675,9 @@ BUILDIN(successrefitem)
if( sd == NULL )
return true;
+ if( script_hasdata(st, 3) )
+ up = script_getnum(st, 3);
+
if (num > 0 && num <= ARRAYLENGTH(script->equip))
i=pc->checkequip(sd,script->equip[num-1]);
if(i >= 0) {
@@ -7687,7 +7689,8 @@ BUILDIN(successrefitem)
if (sd->status.inventory[i].refine >= MAX_REFINE)
return true;
- sd->status.inventory[i].refine++;
+ sd->status.inventory[i].refine += up;
+ sd->status.inventory[i].refine = cap_value( sd->status.inventory[i].refine, 0, MAX_REFINE);
pc->unequipitem(sd,i,2); // status calc will happen in pc->equipitem() below
clif->refine(sd->fd,0,i,sd->status.inventory[i].refine);
@@ -18580,7 +18583,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(getequiprefinerycnt,"i"),
BUILDIN_DEF(getequipweaponlv,"i"),
BUILDIN_DEF(getequippercentrefinery,"i"),
- BUILDIN_DEF(successrefitem,"i"),
+ BUILDIN_DEF(successrefitem,"i?"),
BUILDIN_DEF(failedrefitem,"i"),
BUILDIN_DEF(downrefitem,"i?"),
BUILDIN_DEF(statusup,"i"),