Fix -WShadow definition warning

Cleanup some leftover
This commit is contained in:
lighta 2014-06-27 06:07:50 -04:00
parent e7b654aaab
commit b124498263
25 changed files with 554 additions and 556 deletions

View File

@ -688,7 +688,7 @@ int chmapif_parse_fwlog_changestatus(int fd){
RFIFOSKIP(fd,44);
Sql_EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`name`,`char_id`,`unban_time` FROM `%s` WHERE `name` = '%s'", schema_config.char_db, esc_name) )
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id` FROM `%s` WHERE `name` = '%s'", schema_config.char_db, esc_name) )
Sql_ShowDebug(sql_handle);
else if( Sql_NumRows(sql_handle) == 0 ) {
result = 1; // 1-player not found
@ -697,12 +697,10 @@ int chmapif_parse_fwlog_changestatus(int fd){
Sql_ShowDebug(sql_handle);
result = 1;
} else {
char name[NAME_LENGTH];
int account_id;
int t_aid; //targit account id
char* data;
Sql_GetData(sql_handle, 0, &data, NULL); account_id = atoi(data);
Sql_GetData(sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
Sql_GetData(sql_handle, 0, &data, NULL); t_aid = atoi(data);
Sql_FreeResult(sql_handle);
if(!chlogif_isconnected())
@ -715,40 +713,40 @@ int chmapif_parse_fwlog_changestatus(int fd){
case 1: // block
WFIFOHEAD(login_fd,10);
WFIFOW(login_fd,0) = 0x2724;
WFIFOL(login_fd,2) = account_id;
WFIFOL(login_fd,2) = t_aid;
WFIFOL(login_fd,6) = 5; // new account status
WFIFOSET(login_fd,10);
break;
case 2: // ban
WFIFOHEAD(login_fd,10);
WFIFOW(login_fd, 0) = 0x2725;
WFIFOL(login_fd, 2) = account_id;
WFIFOL(login_fd, 2) = t_aid;
WFIFOL(login_fd, 6) = timediff;
WFIFOSET(login_fd,10);
break;
case 3: // unblock
WFIFOHEAD(login_fd,10);
WFIFOW(login_fd,0) = 0x2724;
WFIFOL(login_fd,2) = account_id;
WFIFOL(login_fd,2) = t_aid;
WFIFOL(login_fd,6) = 0; // new account status
WFIFOSET(login_fd,10);
break;
case 4: // unban
WFIFOHEAD(login_fd,6);
WFIFOW(login_fd,0) = 0x272a;
WFIFOL(login_fd,2) = account_id;
WFIFOL(login_fd,2) = t_aid;
WFIFOSET(login_fd,6);
break;
case 5: // changesex
answer = false;
WFIFOHEAD(login_fd,6);
WFIFOW(login_fd,0) = 0x2727;
WFIFOL(login_fd,2) = account_id;
WFIFOL(login_fd,2) = t_aid;
WFIFOSET(login_fd,6);
break;
case 6:
answer = (val1&4); // vip_req val1=type, &1 login send return, &2 update timestamp, &4 map send answer
chlogif_reqvipdata(account_id, val1, timediff, fd);
chlogif_reqvipdata(t_aid, val1, timediff, fd);
break;
case 7:
answer = (val1&1); //val&1 request answer, val1&2 save data

View File

@ -445,16 +445,16 @@ struct guild * inter_guild_fromsql(int guild_id)
while( SQL_SUCCESS == Sql_NextRow(sql_handle) )
{
int position;
struct guild_position* p;
struct guild_position* gpos;
Sql_GetData(sql_handle, 0, &data, NULL); position = atoi(data);
if( position < 0 || position >= MAX_GUILDPOSITION )
continue;// invalid position
p = &g->position[position];
Sql_GetData(sql_handle, 1, &data, &len); memcpy(p->name, data, min(len, NAME_LENGTH));
Sql_GetData(sql_handle, 2, &data, NULL); p->mode = atoi(data);
Sql_GetData(sql_handle, 3, &data, NULL); p->exp_mode = atoi(data);
p->modified = GS_POSITION_UNMODIFIED;
gpos = &g->position[position];
Sql_GetData(sql_handle, 1, &data, &len); memcpy(gpos->name, data, min(len, NAME_LENGTH));
Sql_GetData(sql_handle, 2, &data, NULL); gpos->mode = atoi(data);
Sql_GetData(sql_handle, 3, &data, NULL); gpos->exp_mode = atoi(data);
gpos->modified = GS_POSITION_UNMODIFIED;
}
//printf("- Read guild_alliance %d from sql \n",guild_id);

View File

@ -300,9 +300,9 @@ static FILELIST* filelist_find(const char* fname)
// returns the original file name
char* grfio_find_file(const char* fname)
{
FILELIST *filelist = filelist_find(fname);
if (!filelist) return NULL;
return (!filelist->fnd ? filelist->fn : filelist->fnd);
FILELIST *filelist_res = filelist_find(fname);
if (!filelist_res) return NULL;
return (!filelist_res->fnd ? filelist_res->fn : filelist_res->fnd);
}
// adds a FILELIST entry into the list of loaded files

View File

@ -989,9 +989,10 @@ bool sv_readdb(const char* directory, const char* filename, char delim, int minc
int lines = 0;
int entries = 0;
char** fields; // buffer for fields ([0] is reserved)
int columns, fields_length;
char path[1024], *line, colsize[512];
int columns, nb_cols;
char path[1024], *line;
char* match;
const short colsize=512;
snprintf(path, sizeof(path), "%s/%s", directory, filename);
@ -1004,12 +1005,12 @@ bool sv_readdb(const char* directory, const char* filename, char delim, int minc
}
// allocate enough memory for the maximum requested amount of columns plus the reserved one
fields_length = maxcols+1;
fields = (char**)aMalloc(fields_length*sizeof(char*));
line = (char*)aMalloc(fields_length*sizeof(colsize));
nb_cols = maxcols+1;
fields = (char**)aMalloc(nb_cols*sizeof(char*));
line = (char*)aMalloc(nb_cols*colsize);
// process rows one by one
while( fgets(line, fields_length*sizeof(colsize), fp) )
while( fgets(line, maxcols*colsize, fp) )
{
lines++;
@ -1023,7 +1024,7 @@ bool sv_readdb(const char* directory, const char* filename, char delim, int minc
if( line[0] == '\0' || line[0] == '\n' || line[0] == '\r')
continue;
columns = sv_split(line, strlen(line), 0, delim, fields, fields_length, (e_svopt)(SV_TERMINATE_LF|SV_TERMINATE_CRLF));
columns = sv_split(line, strlen(line), 0, delim, fields, nb_cols, (e_svopt)(SV_TERMINATE_LF|SV_TERMINATE_CRLF));
if( columns < mincols )
{

View File

@ -574,9 +574,9 @@ static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int acc
while( SQL_SUCCESS == Sql_NextRow(sql_handle) )
{
char* data;
Sql_GetData(sql_handle, 0, &data, NULL); safestrncpy(acc->account_reg2[i].str, data, sizeof(acc->account_reg2[i].str));
Sql_GetData(sql_handle, 1, &data, NULL); safestrncpy(acc->account_reg2[i].value, data, sizeof(acc->account_reg2[i].value));
char* data_tmp;
Sql_GetData(sql_handle, 0, &data_tmp, NULL); safestrncpy(acc->account_reg2[i].str, data_tmp, sizeof(acc->account_reg2[i].str));
Sql_GetData(sql_handle, 1, &data_tmp, NULL); safestrncpy(acc->account_reg2[i].value, data_tmp, sizeof(acc->account_reg2[i].value));
++i;
}
Sql_FreeResult(sql_handle);

View File

@ -30,7 +30,7 @@ static char* msg_table[LOGIN_MAX_MSG]; /// Login Server messages_conf
struct Login_Config login_config; /// Configuration of login-serv
int login_fd; // login server socket
struct mmo_char_server server[MAX_SERVERS]; // char server data
struct mmo_char_server ch_server[MAX_SERVERS]; // char server data
// Account engines available
static struct{
@ -220,9 +220,9 @@ int charif_sendallwos(int sfd, uint8* buf, size_t len)
{
int i, c;
for( i = 0, c = 0; i < ARRAYLENGTH(server); ++i )
for( i = 0, c = 0; i < ARRAYLENGTH(ch_server); ++i )
{
int fd = server[i].fd;
int fd = ch_server[i].fd;
if( session_isValid(fd) && fd != sfd )
{
WFIFOHEAD(fd,len);
@ -239,18 +239,18 @@ int charif_sendallwos(int sfd, uint8* buf, size_t len)
/// Initializes a server structure.
void chrif_server_init(int id)
{
memset(&server[id], 0, sizeof(server[id]));
server[id].fd = -1;
memset(&ch_server[id], 0, sizeof(ch_server[id]));
ch_server[id].fd = -1;
}
/// Destroys a server structure.
void chrif_server_destroy(int id)
{
if( server[id].fd != -1 )
if( ch_server[id].fd != -1 )
{
do_close(server[id].fd);
server[id].fd = -1;
do_close(ch_server[id].fd);
ch_server[id].fd = -1;
}
}
@ -267,7 +267,7 @@ void chrif_server_reset(int id)
/// Called when the connection to Char Server is disconnected.
void chrif_on_disconnect(int id)
{
ShowStatus("Char-server '%s' has disconnected.\n", server[id].name);
ShowStatus("Char-server '%s' has disconnected.\n", ch_server[id].name);
chrif_server_reset(id);
}
@ -495,7 +495,7 @@ int chrif_parse_reqaccdata(int fd, int cid, char *ip) {
uint32 aid = RFIFOL(fd,2);
RFIFOSKIP(fd,6);
if( chrif_send_accdata(fd,aid) < 0 )
ShowNotice("Char-server '%s': account %d NOT found (ip: %s).\n", server[cid].name, aid, ip);
ShowNotice("Char-server '%s': account %d NOT found (ip: %s).\n", ch_server[cid].name, aid, ip);
}
return 0;
}
@ -581,8 +581,8 @@ int parse_fromchar(int fd){
uint32 ipl;
char ip[16];
ARR_FIND( 0, ARRAYLENGTH(server), id, server[id].fd == fd );
if( id == ARRAYLENGTH(server) ){// not a char server
ARR_FIND( 0, ARRAYLENGTH(ch_server), id, ch_server[id].fd == fd );
if( id == ARRAYLENGTH(ch_server) ){// not a char server
ShowDebug("parse_fromchar: Disconnecting invalid session #%d (is not a char-server)\n", fd);
set_eof(fd);
do_close(fd);
@ -591,12 +591,12 @@ int parse_fromchar(int fd){
if( session[fd]->flag.eof ){
do_close(fd);
server[id].fd = -1;
ch_server[id].fd = -1;
chrif_on_disconnect(id);
return 0;
}
ipl = server[id].ip;
ipl = ch_server[id].ip;
ip2str(ipl, ip);
while( RFIFOREST(fd) >= 2 ){
@ -643,7 +643,7 @@ int parse_fromchar(int fd){
// each auth entry can only be used once
idb_remove(auth_db, account_id);
}else{// authentication not found
ShowStatus("Char-server '%s': authentication of the account %d REFUSED (ip: %s).\n", server[id].name, account_id, ip);
ShowStatus("Char-server '%s': authentication of the account %d REFUSED (ip: %s).\n", ch_server[id].name, account_id, ip);
WFIFOHEAD(fd,25);
WFIFOW(fd,0) = 0x2713;
WFIFOL(fd,2) = account_id;
@ -667,10 +667,10 @@ int parse_fromchar(int fd){
RFIFOSKIP(fd,6);
// how many users on world? (update)
if( server[id].users != users ){
ShowStatus("set users %s : %d\n", server[id].name, users);
if( ch_server[id].users != users ){
ShowStatus("set users %s : %d\n", ch_server[id].name, users);
server[id].users = users;
ch_server[id].users = users;
}
}
break;
@ -687,12 +687,12 @@ int parse_fromchar(int fd){
RFIFOSKIP(fd,46);
if( e_mail_check(email) == 0 )
ShowNotice("Char-server '%s': Attempt to create an e-mail on an account with a default e-mail REFUSED - e-mail is invalid (account: %d, ip: %s)\n", server[id].name, account_id, ip);
ShowNotice("Char-server '%s': Attempt to create an e-mail on an account with a default e-mail REFUSED - e-mail is invalid (account: %d, ip: %s)\n", ch_server[id].name, account_id, ip);
else if( !accounts->load_num(accounts, &acc, account_id) || strcmp(acc.email, "a@a.com") == 0 || acc.email[0] == '\0' )
ShowNotice("Char-server '%s': Attempt to create an e-mail on an account with a default e-mail REFUSED - account doesn't exist or e-mail of account isn't default e-mail (account: %d, ip: %s).\n", server[id].name, account_id, ip);
ShowNotice("Char-server '%s': Attempt to create an e-mail on an account with a default e-mail REFUSED - account doesn't exist or e-mail of account isn't default e-mail (account: %d, ip: %s).\n", ch_server[id].name, account_id, ip);
else{
memcpy(acc.email, email, 40);
ShowNotice("Char-server '%s': Create an e-mail on an account with a default e-mail (account: %d, new e-mail: %s, ip: %s).\n", server[id].name, account_id, email, ip);
ShowNotice("Char-server '%s': Create an e-mail on an account with a default e-mail (account: %d, new e-mail: %s, ip: %s).\n", ch_server[id].name, account_id, email, ip);
// Save
accounts->save(accounts, &acc);
}
@ -723,18 +723,18 @@ int parse_fromchar(int fd){
RFIFOSKIP(fd, 86);
if( e_mail_check(actual_email) == 0 )
ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual email is invalid (account: %d, ip: %s)\n", server[id].name, account_id, ip);
ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual email is invalid (account: %d, ip: %s)\n", ch_server[id].name, account_id, ip);
else if( e_mail_check(new_email) == 0 )
ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a invalid new e-mail (account: %d, ip: %s)\n", server[id].name, account_id, ip);
ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a invalid new e-mail (account: %d, ip: %s)\n", ch_server[id].name, account_id, ip);
else if( strcmpi(new_email, "a@a.com") == 0 )
ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a default e-mail (account: %d, ip: %s)\n", server[id].name, account_id, ip);
ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a default e-mail (account: %d, ip: %s)\n", ch_server[id].name, account_id, ip);
else if( !accounts->load_num(accounts, &acc, account_id) )
ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but account doesn't exist (account: %d, ip: %s).\n", server[id].name, account_id, ip);
ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but account doesn't exist (account: %d, ip: %s).\n", ch_server[id].name, account_id, ip);
else if( strcmpi(acc.email, actual_email) != 0 )
ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual e-mail is incorrect (account: %d (%s), actual e-mail: %s, proposed e-mail: %s, ip: %s).\n", server[id].name, account_id, acc.userid, acc.email, actual_email, ip);
ShowNotice("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual e-mail is incorrect (account: %d (%s), actual e-mail: %s, proposed e-mail: %s, ip: %s).\n", ch_server[id].name, account_id, acc.userid, acc.email, actual_email, ip);
else{
safestrncpy(acc.email, new_email, 40);
ShowNotice("Char-server '%s': Modify an e-mail on an account (@email GM command) (account: %d (%s), new e-mail: %s, ip: %s).\n", server[id].name, account_id, acc.userid, new_email, ip);
ShowNotice("Char-server '%s': Modify an e-mail on an account (@email GM command) (account: %d (%s), new e-mail: %s, ip: %s).\n", ch_server[id].name, account_id, acc.userid, new_email, ip);
// Save
accounts->save(accounts, &acc);
}
@ -752,11 +752,11 @@ int parse_fromchar(int fd){
RFIFOSKIP(fd,10);
if( !accounts->load_num(accounts, &acc, account_id) )
ShowNotice("Char-server '%s': Error of Status change (account: %d not found, suggested status %d, ip: %s).\n", server[id].name, account_id, state, ip);
ShowNotice("Char-server '%s': Error of Status change (account: %d not found, suggested status %d, ip: %s).\n", ch_server[id].name, account_id, state, ip);
else if( acc.state == state )
ShowNotice("Char-server '%s': Error of Status change - actual status is already the good status (account: %d, status %d, ip: %s).\n", server[id].name, account_id, state, ip);
ShowNotice("Char-server '%s': Error of Status change - actual status is already the good status (account: %d, status %d, ip: %s).\n", ch_server[id].name, account_id, state, ip);
else{
ShowNotice("Char-server '%s': Status change (account: %d, new status %d, ip: %s).\n", server[id].name, account_id, state, ip);
ShowNotice("Char-server '%s': Status change (account: %d, new status %d, ip: %s).\n", ch_server[id].name, account_id, state, ip);
acc.state = state;
// Save
@ -786,7 +786,7 @@ int parse_fromchar(int fd){
RFIFOSKIP(fd,10);
if( !accounts->load_num(accounts, &acc, account_id) )
ShowNotice("Char-server '%s': Error of ban request (account: %d not found, ip: %s).\n", server[id].name, account_id, ip);
ShowNotice("Char-server '%s': Error of ban request (account: %d not found, ip: %s).\n", ch_server[id].name, account_id, ip);
else{
time_t timestamp;
if (acc.unban_time == 0 || acc.unban_time < time(NULL))
@ -795,14 +795,14 @@ int parse_fromchar(int fd){
timestamp = acc.unban_time; // add to existing ban
timestamp += timediff;
if (timestamp == -1)
ShowNotice("Char-server '%s': Error of ban request (account: %d, invalid date, ip: %s).\n", server[id].name, account_id, ip);
ShowNotice("Char-server '%s': Error of ban request (account: %d, invalid date, ip: %s).\n", ch_server[id].name, account_id, ip);
else if( timestamp <= time(NULL) || timestamp == 0 )
ShowNotice("Char-server '%s': Error of ban request (account: %d, new date unbans the account, ip: %s).\n", server[id].name, account_id, ip);
ShowNotice("Char-server '%s': Error of ban request (account: %d, new date unbans the account, ip: %s).\n", ch_server[id].name, account_id, ip);
else{
uint8 buf[11];
char tmpstr[24];
timestamp2string(tmpstr, sizeof(tmpstr), timestamp, login_config.date_format);
ShowNotice("Char-server '%s': Ban request (account: %d, new final date of banishment: %d (%s), ip: %s).\n", server[id].name, account_id, timestamp, tmpstr, ip);
ShowNotice("Char-server '%s': Ban request (account: %d, new final date of banishment: %d (%s), ip: %s).\n", ch_server[id].name, account_id, timestamp, tmpstr, ip);
acc.unban_time = timestamp;
@ -829,14 +829,14 @@ int parse_fromchar(int fd){
RFIFOSKIP(fd,6);
if( !accounts->load_num(accounts, &acc, account_id) )
ShowNotice("Char-server '%s': Error of sex change (account: %d not found, ip: %s).\n", server[id].name, account_id, ip);
ShowNotice("Char-server '%s': Error of sex change (account: %d not found, ip: %s).\n", ch_server[id].name, account_id, ip);
else if( acc.sex == 'S' )
ShowNotice("Char-server '%s': Error of sex change - account to change is a Server account (account: %d, ip: %s).\n", server[id].name, account_id, ip);
ShowNotice("Char-server '%s': Error of sex change - account to change is a Server account (account: %d, ip: %s).\n", ch_server[id].name, account_id, ip);
else{
unsigned char buf[7];
char sex = ( acc.sex == 'M' ) ? 'F' : 'M'; //Change gender
ShowNotice("Char-server '%s': Sex change (account: %d, new sex %c, ip: %s).\n", server[id].name, account_id, sex, ip);
ShowNotice("Char-server '%s': Sex change (account: %d, new sex %c, ip: %s).\n", ch_server[id].name, account_id, sex, ip);
acc.sex = sex;
// Save
@ -860,11 +860,11 @@ int parse_fromchar(int fd){
int account_id = RFIFOL(fd,4);
if( !accounts->load_num(accounts, &acc, account_id) )
ShowStatus("Char-server '%s': receiving (from the char-server) of account_reg2 (account: %d not found, ip: %s).\n", server[id].name, account_id, ip);
ShowStatus("Char-server '%s': receiving (from the char-server) of account_reg2 (account: %d not found, ip: %s).\n", ch_server[id].name, account_id, ip);
else{
int len;
int p;
ShowNotice("char-server '%s': receiving (from the char-server) of account_reg2 (account: %d, ip: %s).\n", server[id].name, account_id, ip);
ShowNotice("char-server '%s': receiving (from the char-server) of account_reg2 (account: %d, ip: %s).\n", ch_server[id].name, account_id, ip);
for( j = 0, p = 13; j < ACCOUNT_REG2_NUM && p < RFIFOW(fd,2); ++j ){
sscanf((char*)RFIFOP(fd,p), "%31c%n", acc.account_reg2[j].str, &len);
acc.account_reg2[j].str[len]='\0';
@ -898,11 +898,11 @@ int parse_fromchar(int fd){
RFIFOSKIP(fd,6);
if( !accounts->load_num(accounts, &acc, account_id) )
ShowNotice("Char-server '%s': Error of UnBan request (account: %d not found, ip: %s).\n", server[id].name, account_id, ip);
ShowNotice("Char-server '%s': Error of UnBan request (account: %d not found, ip: %s).\n", ch_server[id].name, account_id, ip);
else if( acc.unban_time == 0 )
ShowNotice("Char-server '%s': Error of UnBan request (account: %d, no change for unban date, ip: %s).\n", server[id].name, account_id, ip);
ShowNotice("Char-server '%s': Error of UnBan request (account: %d, no change for unban date, ip: %s).\n", ch_server[id].name, account_id, ip);
else{
ShowNotice("Char-server '%s': UnBan request (account: %d, ip: %s).\n", server[id].name, account_id, ip);
ShowNotice("Char-server '%s': UnBan request (account: %d, ip: %s).\n", ch_server[id].name, account_id, ip);
acc.unban_time = 0;
accounts->save(accounts, &acc);
}
@ -978,8 +978,8 @@ int parse_fromchar(int fd){
case 0x2736: // WAN IP update from char-server
if( RFIFOREST(fd) < 6 )
return 0;
server[id].ip = ntohl(RFIFOL(fd,2));
ShowInfo("Updated IP of Server #%d to %d.%d.%d.%d.\n",id, CONVIP(server[id].ip));
ch_server[id].ip = ntohl(RFIFOL(fd,2));
ShowInfo("Updated IP of Server #%d to %d.%d.%d.%d.\n",id, CONVIP(ch_server[id].ip));
RFIFOSKIP(fd,6);
break;
@ -1038,7 +1038,7 @@ int parse_fromchar(int fd){
RFIFOSKIP(fd,11);
if( !accounts->load_num(accounts, &acc, account_id) )
ShowNotice("Char-server '%s': Error on banking (account: %d not found, ip: %s).\n", server[id].name, account_id, ip);
ShowNotice("Char-server '%s': Error on banking (account: %d not found, ip: %s).\n", ch_server[id].name, account_id, ip);
else{
unsigned char buf[12];
if(type==2){ // upd and Save
@ -1305,8 +1305,8 @@ void login_auth_ok(struct login_session_data* sd)
}
server_num = 0;
for( i = 0; i < ARRAYLENGTH(server); ++i )
if( session_isActive(server[i].fd) )
for( i = 0; i < ARRAYLENGTH(ch_server); ++i )
if( session_isActive(ch_server[i].fd) )
server_num++;
if( server_num == 0 )
@ -1364,18 +1364,18 @@ void login_auth_ok(struct login_session_data* sd)
memset(WFIFOP(fd,20), 0, 24);
WFIFOW(fd,44) = 0; // unknown
WFIFOB(fd,46) = sex_str2num(sd->sex);
for( i = 0, n = 0; i < ARRAYLENGTH(server); ++i )
for( i = 0, n = 0; i < ARRAYLENGTH(ch_server); ++i )
{
if( !session_isValid(server[i].fd) )
if( !session_isValid(ch_server[i].fd) )
continue;
subnet_char_ip = lan_subnetcheck(ip); // Advanced subnet check [LuzZza]
WFIFOL(fd,47+n*32) = htonl((subnet_char_ip) ? subnet_char_ip : server[i].ip);
WFIFOW(fd,47+n*32+4) = ntows(htons(server[i].port)); // [!] LE byte order here [!]
memcpy(WFIFOP(fd,47+n*32+6), server[i].name, 20);
WFIFOW(fd,47+n*32+26) = server[i].users;
WFIFOW(fd,47+n*32+28) = server[i].type;
WFIFOW(fd,47+n*32+30) = server[i].new_;
WFIFOL(fd,47+n*32) = htonl((subnet_char_ip) ? subnet_char_ip : ch_server[i].ip);
WFIFOW(fd,47+n*32+4) = ntows(htons(ch_server[i].port)); // [!] LE byte order here [!]
memcpy(WFIFOP(fd,47+n*32+6), ch_server[i].name, 20);
WFIFOW(fd,47+n*32+26) = ch_server[i].users;
WFIFOW(fd,47+n*32+28) = ch_server[i].type;
WFIFOW(fd,47+n*32+30) = ch_server[i].new_;
n++;
}
WFIFOSET(fd,47+32*server_num);
@ -1684,17 +1684,17 @@ int parse_login(int fd)
if( runflag == LOGINSERVER_ST_RUNNING &&
result == -1 &&
sd->sex == 'S' &&
sd->account_id >= 0 && sd->account_id < ARRAYLENGTH(server) &&
!session_isValid(server[sd->account_id].fd) )
sd->account_id >= 0 && sd->account_id < ARRAYLENGTH(ch_server) &&
!session_isValid(ch_server[sd->account_id].fd) )
{
ShowStatus("Connection of the char-server '%s' accepted.\n", server_name);
safestrncpy(server[sd->account_id].name, server_name, sizeof(server[sd->account_id].name));
server[sd->account_id].fd = fd;
server[sd->account_id].ip = server_ip;
server[sd->account_id].port = server_port;
server[sd->account_id].users = 0;
server[sd->account_id].type = type;
server[sd->account_id].new_ = new_;
safestrncpy(ch_server[sd->account_id].name, server_name, sizeof(ch_server[sd->account_id].name));
ch_server[sd->account_id].fd = fd;
ch_server[sd->account_id].ip = server_ip;
ch_server[sd->account_id].port = server_port;
ch_server[sd->account_id].users = 0;
ch_server[sd->account_id].type = type;
ch_server[sd->account_id].new_ = new_;
session[fd]->func_parse = parse_fromchar;
session[fd]->flag.server = 1;
@ -1963,7 +1963,7 @@ void do_final(void)
online_db->destroy(online_db, NULL);
auth_db->destroy(auth_db, NULL);
for( i = 0; i < ARRAYLENGTH(server); ++i )
for( i = 0; i < ARRAYLENGTH(ch_server); ++i )
chrif_server_destroy(i);
if( login_fd != -1 )
@ -1998,7 +1998,7 @@ void do_shutdown(void)
runflag = LOGINSERVER_ST_SHUTDOWN;
ShowStatus("Shutting down...\n");
// TODO proper shutdown procedure; kick all characters, wait for acks, ... [FlavioJS]
for( id = 0; id < ARRAYLENGTH(server); ++id )
for( id = 0; id < ARRAYLENGTH(ch_server); ++id )
chrif_server_reset(id);
flush_fifos();
runflag = CORE_ST_STOP;
@ -2033,7 +2033,7 @@ int do_init(int argc, char** argv)
rnd_init();
for( i = 0; i < ARRAYLENGTH(server); ++i )
for( i = 0; i < ARRAYLENGTH(ch_server); ++i )
chrif_server_init(i);
// initialize logging

View File

@ -110,7 +110,7 @@ void login_do_final_msg(void);
#define MAX_SERVERS 30 ///number of charserv loginserv can handle
extern struct mmo_char_server server[MAX_SERVERS]; ///array of char-servs data
extern struct mmo_char_server ch_server[MAX_SERVERS]; ///array of char-servs data
extern struct Login_Config login_config; ///config of login serv

View File

@ -2893,7 +2893,6 @@ ACMD_FUNC(char_ban)
char * modif_p;
int32 timediff=0; //don't set this as uint as we may want to decrease banned time
int bantype=0; //2=account block, 6=char specific
char output[256];
nullpo_retr(-1, sd);
@ -2933,9 +2932,11 @@ ACMD_FUNC(char_ban)
else
chrif_req_charban(sd->status.account_id, atcmd_player_name,timediff);
safesnprintf(output,sizeof(output),msg_txt(sd,88),bantype==6?"char":"login"); // Sending request to %s server...
clif_displaymessage(fd, output);
{
char output[256];
safesnprintf(output,sizeof(output),msg_txt(sd,88),bantype==6?"char":"login"); // Sending request to %s server...
clif_displaymessage(fd, output);
}
return 0;
}

View File

@ -361,17 +361,17 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d
if( atk_elem == ELE_FIRE && battle_getcurrentskill(target) == GN_WALLOFTHORN ) {
struct skill_unit *su = (struct skill_unit*)target;
struct skill_unit_group *sg;
struct block_list *src;
struct block_list *src2;
if( !su || !su->alive || (sg = su->group) == NULL || !sg || sg->val3 == -1 ||
(src = map_id2bl(sg->src_id)) == NULL || status_isdead(src) )
(src2 = map_id2bl(sg->src_id)) == NULL || status_isdead(src2) )
return 0;
if( sg->unit_id != UNT_FIREWALL ) {
int x,y;
x = sg->val3 >> 16;
y = sg->val3 & 0xffff;
skill_unitsetting(src,su->group->skill_id,su->group->skill_lv,x,y,1);
skill_unitsetting(src2,su->group->skill_id,su->group->skill_lv,x,y,1);
sg->val3 = -1;
sg->limit = DIFF_TICK(gettick(),sg->tick)+300;
}
@ -4236,9 +4236,8 @@ struct Damage battle_calc_defense_reduction(struct Damage wd, struct block_list
//Kagerou/Oboro Earth Charm effect +5% eDEF
ARR_FIND(1, 6, type, sd->talisman[type] > 0);
if (type == 2) {
short i = 5 * sd->talisman[type];
def1 = (def1 * (100 + i)) / 100;
short j = 5 * sd->talisman[type];
def1 = (def1 * (100 + j)) / 100;
}
}

View File

@ -64,7 +64,7 @@ enum e_buyingstore_failure
static unsigned int buyingstore_nextid = 0;
static const short buyingstore_blankslots[MAX_SLOTS] = { 0 }; // used when checking whether or not an item's card slots are blank
static const unsigned short buyingstore_blankslots[MAX_SLOTS] = { 0 }; // used when checking whether or not an item's card slots are blank
/// Returns unique buying store id

View File

@ -3796,7 +3796,7 @@ void clif_joinchatok(struct map_session_data *sd,struct chat_data* cd)
/// 00dc <users>.W <name>.24B
void clif_addchat(struct chat_data* cd,struct map_session_data *sd)
{
unsigned char buf[32];
unsigned char buf[29];
nullpo_retv(sd);
nullpo_retv(cd);
@ -5816,14 +5816,14 @@ void clif_pvpset(struct map_session_data *sd,int pvprank,int pvpnum,int type)
/*==========================================
*
*------------------------------------------*/
void clif_map_property_mapall(int map, enum map_property property)
void clif_map_property_mapall(int map_idx, enum map_property property)
{
struct block_list bl;
unsigned char buf[16];
bl.id = 0;
bl.type = BL_NUL;
bl.m = map;
bl.m = map_idx;
WBUFW(buf,0)=0x199;
WBUFW(buf,2)=property;
clif_send(buf,packet_len(0x199),&bl,ALL_SAMEMAP);
@ -15917,7 +15917,7 @@ void clif_instance_create(struct map_session_data *sd, const char *name, int num
if(!sd) return;
WBUFW(buf,0) = 0x2cb;
safestrncpy( WBUFP(buf,2), name, 62 );
safestrncpy((char *)WBUFP(buf,2), name, 62 );
WBUFW(buf,63) = num;
if(flag) // A timer has changed or been added
clif_send(buf,packet_len(0x2cb),&sd->bl,PARTY);
@ -15954,7 +15954,7 @@ void clif_instance_status(struct map_session_data *sd, const char *name, unsigne
if(!sd) return; //party_getavailablesd can return NULL
WBUFW(buf,0) = 0x2cd;
safestrncpy( WBUFP(buf,2), name, 62 );
safestrncpy((char *)WBUFP(buf,2), name, 62 );
WBUFL(buf,63) = limit1;
WBUFL(buf,67) = limit2;
if(flag) // A timer has changed or been added

View File

@ -1587,10 +1587,10 @@ int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id
for (i = 0; i < 2 - (flag & 1); i++) { // Retransmission of the relationship list to all members
if(g[i]!=NULL)
for(j=0;j<g[i]->max_member;j++) {
struct map_session_data *sd = g[i]->member[j].sd;
if( sd!=NULL){
clif_guild_allianceinfo(sd);
channel_gjoin(sd,2); //join ally join
struct map_session_data *sd_mem = g[i]->member[j].sd;
if( sd_mem!=NULL){
clif_guild_allianceinfo(sd_mem);
channel_gjoin(sd_mem,2); //join ally join
}
}
}

View File

@ -420,7 +420,7 @@ void log_npc(struct map_session_data* sd, const char* message)
/// logs chat
void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, const char* message)
void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid, const char* mapname, int x, int y, const char* dst_charname, const char* message)
{
if( ( log_config.chat&type ) == 0 )
{// disabled
@ -436,13 +436,13 @@ void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid,
#ifdef BETA_THREAD_TEST
char entry[512];
int e_length = 0;
e_length = sprintf(entry, LOG_QUERY " INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%c', '%d', '%d', '%d', '%s', '%d', '%d', '%s', '%s')", log_config.log_chat, log_chattype2char(type), type_id, src_charid, src_accid, map, x, y, dst_charname, message );
e_length = sprintf(entry, LOG_QUERY " INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%c', '%d', '%d', '%d', '%s', '%d', '%d', '%s', '%s')", log_config.log_chat, log_chattype2char(type), type_id, src_charid, src_accid, mapname, x, y, dst_charname, message );
queryThread_log(entry,e_length);
#else
SqlStmt* stmt;
stmt = SqlStmt_Malloc(logmysql_handle);
if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%c', '%d', '%d', '%d', '%s', '%d', '%d', ?, ?)", log_config.log_chat, log_chattype2char(type), type_id, src_charid, src_accid, map, x, y)
if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%c', '%d', '%d', '%d', '%s', '%d', '%d', ?, ?)", log_config.log_chat, log_chattype2char(type), type_id, src_charid, src_accid, mapname, x, y)
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, (char*)dst_charname, safestrnlen(dst_charname, NAME_LENGTH))
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, CHAT_SIZE_MAX))
|| SQL_SUCCESS != SqlStmt_Execute(stmt) )
@ -464,7 +464,7 @@ void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid,
return;
time(&curtime);
strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime));
fprintf(logfp, "%s - %c,%d,%d,%d,%s,%d,%d,%s,%s\n", timestring, log_chattype2char(type), type_id, src_charid, src_accid, map, x, y, dst_charname, message);
fprintf(logfp, "%s - %c,%d,%d,%d,%s,%d,%d,%s,%s\n", timestring, log_chattype2char(type), type_id, src_charid, src_accid, mapname, x, y, dst_charname, message);
fclose(logfp);
}
}

View File

@ -2981,7 +2981,7 @@ static char *map_init_mapcache(FILE *fp)
nullpo_ret(buffer);
// Read file into buffer..
if(fread(buffer, sizeof(char), size, fp) != size) {
if(fread(buffer, 1, size, fp) != size) {
ShowError("map_init_mapcache: Could not read entire mapcache file\n");
return NULL;
}
@ -3317,7 +3317,7 @@ static int char_ip_set = 0;
int parse_console(const char* buf){
char type[64];
char command[64];
char map[64];
char mapname[64];
int16 x = 0;
int16 y = 0;
int16 m;
@ -3327,7 +3327,7 @@ int parse_console(const char* buf){
memset(&sd, 0, sizeof(struct map_session_data));
strcpy(sd.status.name, "console");
if( ( n = sscanf(buf, "%63[^:]:%63[^:]:%63s %hd %hd[^\n]", type, command, map, &x, &y) ) < 5 ){
if( ( n = sscanf(buf, "%63[^:]:%63[^:]:%63s %hd %hd[^\n]", type, command, mapname, &x, &y) ) < 5 ){
if( ( n = sscanf(buf, "%63[^:]:%63[^\n]", type, command) ) < 2 ) {
if((n = sscanf(buf, "%63[^\n]", type))<1) return -1; //nothing to do no arg
}
@ -3337,19 +3337,19 @@ int parse_console(const char* buf){
if( n < 2 ) {
ShowNotice("Type of command: '%s'\n", type);
command[0] = '\0';
map[0] = '\0';
mapname[0] = '\0';
}
else {
ShowNotice("Type of command: '%s' || Command: '%s'\n", type, command);
map[0] = '\0';
mapname[0] = '\0';
}
}
else
ShowNotice("Type of command: '%s' || Command: '%s' || Map: '%s' Coords: %d %d\n", type, command, map, x, y);
ShowNotice("Type of command: '%s' || Command: '%s' || Map: '%s' Coords: %d %d\n", type, command, mapname, x, y);
if(strcmpi("admin",type) == 0 ) {
if(strcmpi("map",command) == 0){
m = map_mapname2mapid(map);
m = map_mapname2mapid(mapname);
if( m < 0 ){
ShowWarning("Console: Unknown map.\n");
return 0;
@ -3360,7 +3360,7 @@ int parse_console(const char* buf){
sd.bl.x = x;
if( y > 0 )
sd.bl.y = y;
ShowNotice("Now at: '%s' Coords: %d %d\n", map, x, y);
ShowNotice("Now at: '%s' Coords: %d %d\n", mapname, x, y);
}
else if( !is_atcommand(sd.fd, &sd, command, 2) )
ShowInfo("Console: Invalid atcommand.\n");

View File

@ -505,14 +505,14 @@ int npc_timerevent_export(struct npc_data *nd, int i)
if (sscanf(lname, "OnTimer%d%n", &t, &k) == 1 && lname[k] == '\0') {
// Timer event
struct npc_timerevent_list *te = nd->u.scr.timer_event;
int j, k = nd->u.scr.timeramount;
int j, k2 = nd->u.scr.timeramount;
if (te == NULL)
te = (struct npc_timerevent_list *)aMalloc(sizeof(struct npc_timerevent_list));
else
te = (struct npc_timerevent_list *)aRealloc( te, sizeof(struct npc_timerevent_list) * (k+1) );
for (j = 0; j < k; j++) {
te = (struct npc_timerevent_list *)aRealloc( te, sizeof(struct npc_timerevent_list) * (k2+1) );
for (j = 0; j < k2; j++) {
if (te[j].timer > t) {
memmove(te+j+1, te+j, sizeof(struct npc_timerevent_list)*(k-j));
memmove(te+j+1, te+j, sizeof(struct npc_timerevent_list)*(k2-j));
break;
}
}
@ -1303,19 +1303,15 @@ int npc_buysellsel(struct map_session_data* sd, int id, int type)
if (nd->subtype == ITEMSHOP) {
char output[CHAT_SIZE_MAX];
struct item_data *id = itemdb_exists(nd->u.shop.itemshop_nameid);
struct item_data *itd = itemdb_exists(nd->u.shop.itemshop_nameid);
memset(output,'\0',sizeof(output));
if (id) {
sprintf(output,msg_txt(sd,714),id->jname,id->nameid); // Item Shop List: %s (%hu)
if (itd) {
sprintf(output,msg_txt(sd,714),itd->jname,itd->nameid); // Item Shop List: %s (%hu)
clif_broadcast(&sd->bl,output,strlen(output) + 1,BC_BLUE,SELF);
}
} else if (nd->subtype == POINTSHOP) {
char output[CHAT_SIZE_MAX];
memset(output,'\0',sizeof(output));
sprintf(output,msg_txt(sd,715),nd->u.shop.pointshop_str); // Point Shop List: '%s'
clif_broadcast(&sd->bl,output,strlen(output) + 1,BC_BLUE,SELF);
}
@ -2458,34 +2454,31 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const
nd->u.shop.count = 0;
while ( p ) {
unsigned short nameid;
unsigned short nameid2;
int value;
struct item_data* id;
if( p == NULL )
break;
if( sscanf(p, ",%hu:%d", &nameid, &value) != 2 ) {
if( sscanf(p, ",%hu:%d", &nameid2, &value) != 2 ) {
ShowError("npc_parse_shop: Invalid item definition in file '%s', line '%d'. Ignoring the rest of the line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
break;
}
if( (id = itemdb_exists(nameid)) == NULL ) {
ShowWarning("npc_parse_shop: Invalid sell item in file '%s', line '%d' (id '%hu').\n", filepath, strline(buffer,start-buffer), nameid);
if( (id = itemdb_exists(nameid2)) == NULL ) {
ShowWarning("npc_parse_shop: Invalid sell item in file '%s', line '%d' (id '%hu').\n", filepath, strline(buffer,start-buffer), nameid2);
p = strchr(p+1,',');
continue;
}
if( value < 0 ) {
if( type == SHOP ) value = id->value_buy;
else value = 0; // Cashshop doesn't have a "buy price" in the item_db
}
if( (type == SHOP || type == ITEMSHOP || type == POINTSHOP) && value == 0 ) { // NPC selling items for free!
ShowWarning("npc_parse_shop: Item %s [%hu] is being sold for FREE in file '%s', line '%d'.\n",
id->name, nameid, filepath, strline(buffer,start-buffer));
id->name, nameid2, filepath, strline(buffer,start-buffer));
}
if( type == SHOP && value*0.75 < id->value_sell*1.24 ) { // Exploit possible: you can buy and sell back with profit
ShowWarning("npc_parse_shop: Item %s [%hu] discounted buying price (%d->%d) is less than overcharged selling price (%d->%d) at file '%s', line '%d'.\n",
id->name, nameid, value, (int)(value*0.75), id->value_sell, (int)(id->value_sell*1.24), filepath, strline(buffer,start-buffer));
id->name, nameid2, value, (int)(value*0.75), id->value_sell, (int)(id->value_sell*1.24), filepath, strline(buffer,start-buffer));
}
//for logs filters, atcommands and iteminfo script command
if( id->maxchance == 0 )
@ -2496,7 +2489,7 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const
else
CREATE(nd->u.shop.shop_item, struct npc_item_list,1);
nd->u.shop.shop_item[nd->u.shop.count].nameid = nameid;
nd->u.shop.shop_item[nd->u.shop.count].nameid = nameid2;
nd->u.shop.shop_item[nd->u.shop.count].value = value;
nd->u.shop.count++;
p = strchr(p+1,',');
@ -3187,10 +3180,10 @@ int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const c
}
if( sd->npc_id != 0 ) { // Enqueue the event trigger.
int i;
ARR_FIND( 0, MAX_EVENTQUEUE, i, sd->eventqueue[i][0] == '\0' );
if( i < MAX_EVENTQUEUE ) {
safestrncpy(sd->eventqueue[i],eventname,50); //Event enqueued.
int l;
ARR_FIND( 0, MAX_EVENTQUEUE, l, sd->eventqueue[l][0] == '\0' );
if( l < MAX_EVENTQUEUE ) {
safestrncpy(sd->eventqueue[l],eventname,50); //Event enqueued.
return 0;
}
@ -3803,7 +3796,7 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit)
len = ftell(fp);
buffer = (char*)aMalloc(len+1);
fseek(fp, 0, SEEK_SET);
len = fread(buffer, sizeof(char), len, fp);
len = fread(buffer, 1, len, fp);
buffer[len] = '\0';
if( ferror(fp) )
{

View File

@ -767,7 +767,7 @@ int party_changeleader(struct map_session_data *sd, struct map_session_data *tsd
/// - changes maps
/// - logs in or out
/// - gains a level (disabled)
int party_recv_movemap(int party_id,int account_id,int char_id, unsigned short map,int online,int lv)
int party_recv_movemap(int party_id,int account_id,int char_id, unsigned short map_idx,int online,int lv)
{
struct party_member* m;
struct party_data* p;
@ -785,7 +785,7 @@ int party_recv_movemap(int party_id,int account_id,int char_id, unsigned short m
}
m = &p->party.member[i];
m->map = map;
m->map = map_idx;
m->online = online;
m->lv = lv;
//Check if they still exist on this map server

View File

@ -409,15 +409,15 @@ bool path_search(struct walkpath_data *wpd,int16 m,int16 x0,int16 y0,int16 x1,in
wpd->path_len = len;
wpd->path_pos = 0;
for(i=rp,j=len-1;j>=0;i=tp[i].before,j--) {
int dx = tp[i].x - tp[tp[i].before].x;
int dy = tp[i].y - tp[tp[i].before].y;
int dx2 = tp[i].x - tp[tp[i].before].x;
int dy2 = tp[i].y - tp[tp[i].before].y;
uint8 dir;
if( dx == 0 ) {
dir = (dy > 0 ? 0 : 4);
} else if( dx > 0 ) {
dir = (dy == 0 ? 6 : (dy < 0 ? 5 : 7) );
if( dx2 == 0 ) {
dir = (dy2 > 0 ? 0 : 4);
} else if( dx2 > 0 ) {
dir = (dy2 == 0 ? 6 : (dy2 < 0 ? 5 : 7) );
} else {
dir = (dy == 0 ? 2 : (dy > 0 ? 1 : 3) );
dir = (dy2 == 0 ? 2 : (dy2 > 0 ? 1 : 3) );
}
wpd->path[j] = dir;
}

View File

@ -1489,7 +1489,7 @@ static int pc_calc_skillpoint(struct map_session_data* sd)
*------------------------------------------*/
void pc_calc_skilltree(struct map_session_data *sd)
{
int i,id=0,flag;
int i,flag;
int c=0;
nullpo_retv(sd);
@ -1552,9 +1552,10 @@ void pc_calc_skilltree(struct map_session_data *sd)
if ((sd->class_&MAPID_UPPERMASK) != MAPID_TAEKWON) {
uint16 c_ = pc_class2idx(JOB_TAEKWON);
for (i = 0; i < MAX_SKILL_TREE; i++) {
uint16 x = skill_get_index(skill_tree[c_][i].id), id;
if ((id = sd->status.skill[x].id)) {
if (id == NV_BASIC || id == NV_FIRSTAID || id == WE_CALLBABY)
uint16 x = skill_get_index(skill_tree[c_][i].id);
uint16 skid;
if ((skid = sd->status.skill[x].id)) {
if (skid == NV_BASIC || skid == NV_FIRSTAID || skid == WE_CALLBABY)
continue;
sd->status.skill[x].id = 0;
}
@ -1596,11 +1597,12 @@ void pc_calc_skilltree(struct map_session_data *sd)
}
do {
short skid=0;
flag = 0;
for( i = 0; i < MAX_SKILL_TREE && (id = skill_tree[c][i].id) > 0; i++ )
for( i = 0; i < MAX_SKILL_TREE && (skid = skill_tree[c][i].id) > 0; i++ )
{
int f;
if( sd->status.skill[id].id )
if( sd->status.skill[skid].id )
continue; //Skill already known.
f = 1;
@ -1634,20 +1636,20 @@ void pc_calc_skilltree(struct map_session_data *sd)
if( f ) {
int inf2;
inf2 = skill_get_inf2(id);
inf2 = skill_get_inf2(skid);
if(!sd->status.skill[id].lv && (
if(!sd->status.skill[skid].lv && (
(inf2&INF2_QUEST_SKILL && !battle_config.quest_skill_learn) ||
inf2&INF2_WEDDING_SKILL ||
(inf2&INF2_SPIRIT_SKILL && !sd->sc.data[SC_SPIRIT])
))
continue; //Cannot be learned via normal means. Note this check DOES allows raising already known skills.
sd->status.skill[id].id = id;
sd->status.skill[skid].id = skid;
if(inf2&INF2_SPIRIT_SKILL) { //Spirit skills cannot be learned, they will only show up on your tree when you get buffed.
sd->status.skill[id].lv = 1; // need to manually specify a skill level
sd->status.skill[id].flag = SKILL_FLAG_TEMPORARY; //So it is not saved, and tagged as a "bonus" skill.
sd->status.skill[skid].lv = 1; // need to manually specify a skill level
sd->status.skill[skid].flag = SKILL_FLAG_TEMPORARY; //So it is not saved, and tagged as a "bonus" skill.
}
flag = 1; // skill list has changed, perform another pass
}
@ -1655,23 +1657,22 @@ void pc_calc_skilltree(struct map_session_data *sd)
} while(flag);
if( c > 0 && sd->status.skill_point == 0 && pc_is_taekwon_ranker(sd) ) {
short skid=0;
/* Taekwon Ranker Bonus Skill Tree
============================================
- Grant All Taekwon Tree, but only as Bonus Skills in case they drop from ranking.
- (c > 0) to avoid grant Novice Skill Tree in case of Skill Reset (need more logic)
- (sd->status.skill_point == 0) to wait until all skill points are assigned to avoid problems with Job Change quest. */
for( i = 0; i < MAX_SKILL_TREE && (id = skill_tree[c][i].id) > 0; i++ ) {
if( (skill_get_inf2(id)&(INF2_QUEST_SKILL|INF2_WEDDING_SKILL)) )
for( i = 0; i < MAX_SKILL_TREE && (skid = skill_tree[c][i].id) > 0; i++ ) {
if( (skill_get_inf2(skid)&(INF2_QUEST_SKILL|INF2_WEDDING_SKILL)) )
continue; //Do not include Quest/Wedding skills.
if( sd->status.skill[id].id == 0 ) {
sd->status.skill[id].id = id;
sd->status.skill[id].flag = SKILL_FLAG_TEMPORARY; // So it is not saved, and tagged as a "bonus" skill.
} else if( id != NV_BASIC )
sd->status.skill[id].flag = SKILL_FLAG_REPLACED_LV_0 + sd->status.skill[id].lv; // Remember original level
sd->status.skill[id].lv = skill_tree_get_max(id, sd->status.class_);
if( sd->status.skill[skid].id == 0 ) { //do we really want skid as index ? //Lighta
sd->status.skill[skid].id = skid;
sd->status.skill[skid].flag = SKILL_FLAG_TEMPORARY; // So it is not saved, and tagged as a "bonus" skill.
} else if( skid != NV_BASIC )
sd->status.skill[skid].flag = SKILL_FLAG_REPLACED_LV_0 + sd->status.skill[skid].lv; // Remember original level
sd->status.skill[skid].lv = skill_tree_get_max(skid, sd->status.class_);
}
}
}
@ -7393,10 +7394,10 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
|| (type == 2 && sd->status.inventory[i].equip)
|| type == 3)
{
int k;
ARR_FIND( 0, MAX_INVENTORY, k, eq_n[k] <= 0 );
if( k < MAX_INVENTORY )
eq_n[k] = i;
int l;
ARR_FIND( 0, MAX_INVENTORY, l, eq_n[l] <= 0 );
if( l < MAX_INVENTORY )
eq_n[l] = i;
eq_num++;
}
@ -8847,21 +8848,24 @@ static int pc_checkcombo(struct map_session_data *sd, struct item_data *data) {
uint16 i;
int success = 0;
for( i = 0; i < data->combos_count; i++ ) {
int16 *combo_idx = NULL, idx, j;
short *combo_idx = NULL, idx, j;
int nb_itemCombo;
/* ensure this isn't a duplicate combo */
if( sd->combos.bonus != NULL ) {
int x;
ARR_FIND( 0, sd->combos.count, x, sd->combos.id[x] == data->combos[i]->id );
/* found a match, skip this combo */
if( x < sd->combos.count )
continue;
}
CREATE(combo_idx,int16,data->combos[i]->count);
memset(combo_idx,-1,data->combos[i]->count * sizeof(int16));
for( j = 0; j < data->combos[i]->count; j++ ) {
nb_itemCombo = data->combos[i]->count;
if(nb_itemCombo<2) //a combo with less then 2 item ?? how that possible
continue;
CREATE(combo_idx,short,nb_itemCombo);
memset(combo_idx,-1,nb_itemCombo * sizeof(short));
for( j = 0; j < nb_itemCombo; j++ ) {
uint16 id = data->combos[i]->nameid[j], k;
bool found = false;
@ -8877,7 +8881,7 @@ static int pc_checkcombo(struct map_session_data *sd, struct item_data *data) {
continue;
if( j > 0 ) {
uint8 z;
for (z = 0; z < data->combos[i]->count; z++)
for (z = 0; z < nb_itemCombo; z++)
if(combo_idx[z] == index) //we already have that index recorded
do_continue=true;
if(do_continue)
@ -8891,9 +8895,10 @@ static int pc_checkcombo(struct map_session_data *sd, struct item_data *data) {
found = true;
break;
} else { //Cards
uint16 z;
//uint16 z;
if ( sd->inventory_data[index]->slot == 0 || itemdb_isspecial(sd->status.inventory[index].card[0]) )
continue;
/* WIP this will break some combo currently
for (z = 0; z < sd->inventory_data[index]->slot; z++) {
if (sd->status.inventory[index].card[z] != id)
continue;
@ -8901,6 +8906,7 @@ static int pc_checkcombo(struct map_session_data *sd, struct item_data *data) {
found = true;
break;
}
*/
}
}
if( !found )
@ -8908,7 +8914,7 @@ static int pc_checkcombo(struct map_session_data *sd, struct item_data *data) {
}
aFree(combo_idx);
/* means we broke out of the count loop w/o finding all ids, we can move to the next combo */
if( j < data->combos[i]->count )
if( j < nb_itemCombo )
continue;
/* we got here, means all items in the combo are matching */
idx = sd->combos.count;

View File

@ -145,20 +145,20 @@ static void read_config(void)
iter = db_iterator(pc_group_db);
for (group_settings = dbi_first(iter); dbi_exists(iter); group_settings = dbi_next(iter)) {
config_setting_t *commands = group_settings->commands, *permissions = group_settings->permissions;
int count = 0, i;
int count = 0, j;
// Make sure there is "commands" group
if (commands == NULL)
commands = group_settings->commands = config_setting_add(group_settings->root, "commands", CONFIG_TYPE_GROUP);
count = config_setting_length(commands);
for (i = 0; i < count; ++i) {
config_setting_t *command = config_setting_get_elem(commands, i);
for (j = 0; j < count; ++j) {
config_setting_t *command = config_setting_get_elem(commands, j);
const char *name = config_setting_name(command);
if (!atcommand_exists(name)) {
ShowConfigWarning(command, "pc_groups:read_config: non-existent command name '%s', removing...", name);
config_setting_remove(commands, name);
--i;
--j;
--count;
}
}
@ -168,16 +168,16 @@ static void read_config(void)
permissions = group_settings->permissions = config_setting_add(group_settings->root, "permissions", CONFIG_TYPE_GROUP);
count = config_setting_length(permissions);
for(i = 0; i < count; ++i) {
config_setting_t *permission = config_setting_get_elem(permissions, i);
for(j = 0; j < count; ++j) {
config_setting_t *permission = config_setting_get_elem(permissions, j);
const char *name = config_setting_name(permission);
int j;
int p;
ARR_FIND(0, ARRAYLENGTH(pc_g_permission_name), j, strcmp(pc_g_permission_name[j].name, name) == 0);
if (j == ARRAYLENGTH(pc_g_permission_name)) {
ARR_FIND(0, ARRAYLENGTH(pc_g_permission_name), p, strcmp(pc_g_permission_name[p].name, name) == 0);
if (p == ARRAYLENGTH(pc_g_permission_name)) {
ShowConfigWarning(permission, "pc_groups:read_config: non-existent permission name '%s', removing...", name);
config_setting_remove(permissions, name);
--i;
--p;
--count;
}
}
@ -223,15 +223,15 @@ static void read_config(void)
// Copy settings (commands/permissions) that are not defined yet
if (inherited_group->commands != NULL) {
int i = 0, commands_count = config_setting_length(inherited_group->commands);
for (i = 0; i < commands_count; ++i)
config_setting_copy(commands, config_setting_get_elem(inherited_group->commands, i));
int l = 0, commands_count = config_setting_length(inherited_group->commands);
for (l = 0; l < commands_count; ++l)
config_setting_copy(commands, config_setting_get_elem(inherited_group->commands, l));
}
if (inherited_group->permissions != NULL) {
int i = 0, permissions_count = config_setting_length(inherited_group->permissions);
for (i = 0; i < permissions_count; ++i)
config_setting_copy(permissions, config_setting_get_elem(inherited_group->permissions, i));
int l = 0, permissions_count = config_setting_length(inherited_group->permissions);
for (l = 0; l < permissions_count; ++l)
config_setting_copy(permissions, config_setting_get_elem(inherited_group->permissions, l));
}
++done; // copied commands and permissions from one of inherited groups
@ -255,10 +255,10 @@ static void read_config(void)
iter = db_iterator(pc_group_db);
for (group_settings = dbi_first(iter); dbi_exists(iter); group_settings = dbi_next(iter)) {
config_setting_t *permissions = group_settings->permissions;
int i, count = config_setting_length(permissions);
int c, count = config_setting_length(permissions);
for (i = 0; i < count; ++i) {
config_setting_t *perm = config_setting_get_elem(permissions, i);
for (c = 0; c < count; ++c) {
config_setting_t *perm = config_setting_get_elem(permissions, c);
const char *name = config_setting_name(perm);
int val = config_setting_get_bool(perm);
int j;

View File

@ -866,17 +866,17 @@ static void add_scriptl(int l)
/*==========================================
* Resolve the label
*------------------------------------------*/
void set_label(int l,int pos, const char* script_pos)
void set_label(int l,int pos, const char* script_pos_cur)
{
int i,next;
if(str_data[l].type==C_INT || str_data[l].type==C_PARAM || str_data[l].type==C_FUNC)
{ //Prevent overwriting constants values, parameters and built-in functions [Skotlex]
disp_error_message("set_label: invalid label name",script_pos);
disp_error_message("set_label: invalid label name",script_pos_cur);
return;
}
if(str_data[l].label!=-1){
disp_error_message("set_label: dup label ",script_pos);
disp_error_message("set_label: dup label ",script_pos_cur);
return;
}
str_data[l].type=(str_data[l].type == C_USERFUNC ? C_USERFUNC_POS : C_POS);
@ -2051,15 +2051,15 @@ const char* parse_syntax_close_sub(const char* p,int* flag)
}
return p;
} else if(syntax.curly[pos].type == TYPE_DO) {
int l;
char label[256];
int l2;
char label2[256];
const char *p2;
if(syntax.curly[pos].flag) {
// (Come here continue) to form the label here
sprintf(label,"__DO%x_NXT",syntax.curly[pos].index);
l=add_str(label);
set_label(l,script_pos,p);
sprintf(label2,"__DO%x_NXT",syntax.curly[pos].index);
l2=add_str(label2);
set_label(l2,script_pos,p);
}
// Skip to the end point if the condition is false
@ -2076,24 +2076,24 @@ const char* parse_syntax_close_sub(const char* p,int* flag)
// do-block end is a new line
parse_nextline(false, p);
sprintf(label,"__DO%x_FIN",syntax.curly[pos].index);
sprintf(label2,"__DO%x_FIN",syntax.curly[pos].index);
add_scriptl(add_str("jump_zero"));
add_scriptc(C_ARG);
p=parse_expr(p);
p=skip_space(p);
add_scriptl(add_str(label));
add_scriptl(add_str(label2));
add_scriptc(C_FUNC);
// Skip to the starting point
sprintf(label,"goto __DO%x_BGN;",syntax.curly[pos].index);
sprintf(label2,"goto __DO%x_BGN;",syntax.curly[pos].index);
syntax.curly[syntax.curly_count++].type = TYPE_NULL;
parse_line(label);
parse_line(label2);
syntax.curly_count--;
// Form label of the end point conditions
sprintf(label,"__DO%x_FIN",syntax.curly[pos].index);
l=add_str(label);
set_label(l,script_pos,p);
sprintf(label2,"__DO%x_FIN",syntax.curly[pos].index);
l2=add_str(label2);
set_label(l2,script_pos,p);
p = skip_space(p);
if(*p != ';') {
disp_error_message("parse_syntax: expected ';'",p);
@ -2135,19 +2135,19 @@ const char* parse_syntax_close_sub(const char* p,int* flag)
syntax.curly_count--;
return p;
} else if(syntax.curly[syntax.curly_count-1].type == TYPE_USERFUNC) {
int pos = syntax.curly_count-1;
char label[256];
int l;
int pos2 = syntax.curly_count-1;
char label2[256];
int l2;
// Back
sprintf(label,"return;");
sprintf(label2,"return;");
syntax.curly[syntax.curly_count++].type = TYPE_NULL;
parse_line(label);
parse_line(label2);
syntax.curly_count--;
// Put the label of the location
sprintf(label,"__FN%x_FIN",syntax.curly[pos].index);
l=add_str(label);
set_label(l,script_pos,p);
sprintf(label2,"__FN%x_FIN",syntax.curly[pos2].index);
l2=add_str(label2);
set_label(l2,script_pos,p);
syntax.curly_count--;
return p;
} else {
@ -2338,7 +2338,7 @@ static const char* script_print_line(StringBuf* buf, const char* p, const char*
return p+i+(p[i] == '\n' ? 1 : 0);
}
void script_errorwarning_sub(StringBuf *buf, const char* src, const char* file, int start_line, const char* error_msg, const char* error_pos) {
void script_errorwarning_sub(StringBuf *buf, const char* src, const char* file, int start_line, const char* error_msg_cur, const char* error_pos_cur) {
// Find the line where the error occurred
int j;
int line = start_line;
@ -2347,7 +2347,7 @@ void script_errorwarning_sub(StringBuf *buf, const char* src, const char* file,
for(p=src;p && *p;line++){
const char *lineend=strchr(p,'\n');
if(lineend==NULL || error_pos<lineend){
if(lineend==NULL || error_pos_cur<lineend){
break;
}
for( j = 0; j < 4; j++ ) {
@ -2358,34 +2358,34 @@ void script_errorwarning_sub(StringBuf *buf, const char* src, const char* file,
}
StringBuf_Printf(buf, "script error on %s line %d\n", file, line);
StringBuf_Printf(buf, " %s\n", error_msg);
StringBuf_Printf(buf, " %s\n", error_msg_cur);
for(j = 0; j < 5; j++ ) {
script_print_line(buf, linestart[j], NULL, line + j - 5);
}
p = script_print_line(buf, p, error_pos, -line);
p = script_print_line(buf, p, error_pos_cur, -line);
for(j = 0; j < 5; j++) {
p = script_print_line(buf, p, NULL, line + j + 1 );
}
}
void script_error(const char* src, const char* file, int start_line, const char* error_msg, const char* error_pos) {
void script_error(const char* src, const char* file, int start_line, const char* error_msg_cur, const char* error_pos_cur) {
StringBuf buf;
StringBuf_Init(&buf);
StringBuf_AppendStr(&buf, "\a\n");
script_errorwarning_sub(&buf, src, file, start_line, error_msg, error_pos);
script_errorwarning_sub(&buf, src, file, start_line, error_msg_cur, error_pos_cur);
ShowError("%s", StringBuf_Value(&buf));
StringBuf_Destroy(&buf);
}
void script_warning(const char* src, const char* file, int start_line, const char* error_msg, const char* error_pos) {
void script_warning(const char* src, const char* file, int start_line, const char* error_msg_cur, const char* error_pos_cur) {
StringBuf buf;
StringBuf_Init(&buf);
script_errorwarning_sub(&buf, src, file, start_line, error_msg, error_pos);
script_errorwarning_sub(&buf, src, file, start_line, error_msg_cur, error_pos_cur);
ShowWarning("%s", StringBuf_Value(&buf));
StringBuf_Destroy(&buf);
@ -2430,7 +2430,7 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o
if( setjmp( error_jump ) != 0 ) {
//Restore program state when script has problems. [from jA]
int i;
int j;
const int size = ARRAYLENGTH(syntax.curly);
if( error_report )
script_error(src,file,line,error_msg,error_pos);
@ -2439,10 +2439,10 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o
script_pos = 0;
script_size = 0;
script_buf = NULL;
for(i=LABEL_START;i<str_num;i++)
if(str_data[i].type == C_NOP) str_data[i].type = C_NAME;
for(i=0; i<size; i++)
linkdb_final(&syntax.curly[i].case_label);
for(j=LABEL_START;j<str_num;j++)
if(str_data[j].type == C_NOP) str_data[j].type = C_NAME;
for(j=0; j<size; j++)
linkdb_final(&syntax.curly[j].case_label);
return NULL;
}
@ -6545,9 +6545,9 @@ BUILDIN_FUNC(getitem2)
get_val(st,data);
if( data_isstring(data) ) {
const char *name=conv_str(st,data);
struct item_data *item_data = itemdb_searchname(name);
if( item_data )
nameid=item_data->nameid;
struct item_data *item_data_tmp = itemdb_searchname(name);
if( item_data_tmp )
nameid=item_data_tmp->nameid;
else
nameid=UNKNOWN_ITEM_ID;
} else
@ -8917,7 +8917,7 @@ BUILDIN_FUNC(savepoint)
{
int x;
int y;
short map;
short map_idx;
const char* str;
TBL_PC* sd;
@ -8928,9 +8928,9 @@ BUILDIN_FUNC(savepoint)
str = script_getstr(st, 2);
x = script_getnum(st,3);
y = script_getnum(st,4);
map = mapindex_name2id(str);
if( map )
pc_setsavepoint(sd, map, x, y);
map_idx = mapindex_name2id(str);
if( map_idx )
pc_setsavepoint(sd, map_idx, x, y);
return SCRIPT_CMD_SUCCESS;
}
@ -9482,9 +9482,9 @@ BUILDIN_FUNC(clone)
TBL_PC *sd, *msd=NULL;
int char_id,master_id=0,x,y, mode = 0, flag = 0, m;
unsigned int duration = 0;
const char *map,*event;
const char *mapname,*event;
map=script_getstr(st,2);
mapname=script_getstr(st,2);
x=script_getnum(st,3);
y=script_getnum(st,4);
event=script_getstr(st,5);
@ -9504,7 +9504,7 @@ BUILDIN_FUNC(clone)
check_event(st, event);
m = map_mapname2mapid(map);
m = map_mapname2mapid(mapname);
if (m < 0) return 0;
sd = map_charid2sd(char_id);
@ -12299,11 +12299,11 @@ BUILDIN_FUNC(strmobinfo)
BUILDIN_FUNC(guardian)
{
int class_=0,x=0,y=0,guardian=0;
const char *str,*map,*evt="";
const char *str,*mapname,*evt="";
struct script_data *data;
bool has_index = false;
map =script_getstr(st,2);
mapname =script_getstr(st,2);
x =script_getnum(st,3);
y =script_getnum(st,4);
str =script_getstr(st,5);
@ -12332,7 +12332,7 @@ BUILDIN_FUNC(guardian)
}
check_event(st, evt);
script_pushint(st, mob_spawn_guardian(map,x,y,str,class_,evt,guardian,has_index));
script_pushint(st, mob_spawn_guardian(mapname,x,y,str,class_,evt,guardian,has_index));
return SCRIPT_CMD_SUCCESS;
}
@ -12341,11 +12341,11 @@ BUILDIN_FUNC(guardian)
*------------------------------------------*/
BUILDIN_FUNC(setwall)
{
const char *map, *name;
const char *mapname, *name;
int x, y, m, size, dir;
bool shootable;
map = script_getstr(st,2);
mapname = script_getstr(st,2);
x = script_getnum(st,3);
y = script_getnum(st,4);
size = script_getnum(st,5);
@ -12353,7 +12353,7 @@ BUILDIN_FUNC(setwall)
shootable = script_getnum(st,7);
name = script_getstr(st,8);
if( (m = map_mapname2mapid(map)) < 0 )
if( (m = map_mapname2mapid(mapname)) < 0 )
return 0; // Invalid Map
map_iwall_set(m, x, y, size, dir, shootable, name);
@ -12822,18 +12822,18 @@ BUILDIN_FUNC(playBGMall)
name = script_getstr(st,2);
if( script_hasdata(st,7) ) {// specified part of map
const char* map = script_getstr(st,3);
const char* mapname = script_getstr(st,3);
int x0 = script_getnum(st,4);
int y0 = script_getnum(st,5);
int x1 = script_getnum(st,6);
int y1 = script_getnum(st,7);
map_foreachinarea(playBGM_sub, map_mapname2mapid(map), x0, y0, x1, y1, BL_PC, name);
map_foreachinarea(playBGM_sub, map_mapname2mapid(mapname), x0, y0, x1, y1, BL_PC, name);
}
else if( script_hasdata(st,3) ) {// entire map
const char* map = script_getstr(st,3);
const char* mapname = script_getstr(st,3);
map_foreachinmap(playBGM_sub, map_mapname2mapid(map), BL_PC, name);
map_foreachinmap(playBGM_sub, map_mapname2mapid(mapname), BL_PC, name);
}
else {// entire server
map_foreachpc(&playBGM_foreachpc_sub, name);
@ -12892,18 +12892,18 @@ BUILDIN_FUNC(soundeffectall)
else
if(!script_hasdata(st,5))
{ // entire map
const char* map = script_getstr(st,4);
map_foreachinmap(soundeffect_sub, map_mapname2mapid(map), BL_PC, name, type);
const char* mapname = script_getstr(st,4);
map_foreachinmap(soundeffect_sub, map_mapname2mapid(mapname), BL_PC, name, type);
}
else
if(script_hasdata(st,8))
{ // specified part of map
const char* map = script_getstr(st,4);
const char* mapname = script_getstr(st,4);
int x0 = script_getnum(st,5);
int y0 = script_getnum(st,6);
int x1 = script_getnum(st,7);
int y1 = script_getnum(st,8);
map_foreachinarea(soundeffect_sub, map_mapname2mapid(map), x0, y0, x1, y1, BL_PC, name, type);
map_foreachinarea(soundeffect_sub, map_mapname2mapid(mapname), x0, y0, x1, y1, BL_PC, name, type);
}
else
{
@ -13283,7 +13283,7 @@ int recovery_sub(struct map_session_data* sd, int revive)
BUILDIN_FUNC(recovery)
{
TBL_PC *sd;
int map = 0, type = 0, revive = 1;
int map_idx = 0, type = 0, revive = 1;
type = script_getnum(st,2);
@ -13305,8 +13305,8 @@ BUILDIN_FUNC(recovery)
//When no party given, we use invoker party
int p_id = 0, i;
if(script_hasdata(st,5)) {//Bad maps shouldn't cause issues
map = map_mapname2mapid(script_getstr(st,5));
if(map < 1) { //But we'll check anyways
map_idx = map_mapname2mapid(script_getstr(st,5));
if(map_idx < 1) { //But we'll check anyways
ShowDebug("recovery: bad map name given (%s)\n", script_getstr(st,5));
return 1;
}
@ -13320,7 +13320,7 @@ BUILDIN_FUNC(recovery)
return 0;
for (i = 0; i < MAX_PARTY; i++) {
if((!(pl_sd = p->data[i].sd) || pl_sd->status.party_id != p_id)
|| (map && pl_sd->bl.m != map))
|| (map_idx && pl_sd->bl.m != map_idx))
continue;
recovery_sub(pl_sd, revive);
}
@ -13333,8 +13333,8 @@ BUILDIN_FUNC(recovery)
//When no guild given, we use invoker guild
int g_id = 0, i;
if(script_hasdata(st,5)) {//Bad maps shouldn't cause issues
map = map_mapname2mapid(script_getstr(st,5));
if(map < 1) { //But we'll check anyways
map_idx = map_mapname2mapid(script_getstr(st,5));
if(map_idx < 1) { //But we'll check anyways
ShowDebug("recovery: bad map name given (%s)\n", script_getstr(st,5));
return 1;
}
@ -13348,7 +13348,7 @@ BUILDIN_FUNC(recovery)
return 0;
for (i = 0; i < MAX_GUILD; i++) {
if((!(pl_sd = g->member[i].sd) || pl_sd->status.guild_id != g_id)
|| (map && pl_sd->bl.m != map))
|| (map_idx && pl_sd->bl.m != map_idx))
continue;
recovery_sub(pl_sd, revive);
}
@ -13356,10 +13356,10 @@ BUILDIN_FUNC(recovery)
}
case 3:
if(script_hasdata(st,3))
map = map_mapname2mapid(script_getstr(st,3));
map_idx = map_mapname2mapid(script_getstr(st,3));
else if((sd = script_rid2sd(st)))
map = sd->bl.m;
if(map < 1)
map_idx = sd->bl.m;
if(map_idx < 1)
return 1; //No sd and no map given - return
case 4:
{
@ -13371,7 +13371,7 @@ BUILDIN_FUNC(recovery)
revive = script_getnum(st,3); // recovery 4,<revive_flag>;
iter = mapit_getallusers();
for (sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter)) {
if(type == 3 && sd->bl.m != map)
if(type == 3 && sd->bl.m != map_idx)
continue;
recovery_sub(sd, revive);
}
@ -16026,7 +16026,7 @@ BUILDIN_FUNC(unitkill)
BUILDIN_FUNC(unitwarp)
{
int unit_id;
int map;
int map_idx;
short x;
short y;
struct block_list* bl;
@ -16043,12 +16043,12 @@ BUILDIN_FUNC(unitwarp)
bl = map_id2bl(unit_id);
if( strcmp(mapname,"this") == 0 )
map = bl?bl->m:-1;
map_idx = bl?bl->m:-1;
else
map = map_mapname2mapid(mapname);
map_idx = map_mapname2mapid(mapname);
if( map >= 0 && bl != NULL )
script_pushint(st, unit_warp(bl,map,x,y,CLR_OUTSIGHT));
if( map_idx >= 0 && bl != NULL )
script_pushint(st, unit_warp(bl,map_idx,x,y,CLR_OUTSIGHT));
else
script_pushint(st, 0);
@ -16990,17 +16990,17 @@ BUILDIN_FUNC(bg_warp)
BUILDIN_FUNC(bg_monster)
{
int class_ = 0, x = 0, y = 0, bg_id = 0;
const char *str,*map, *evt="";
const char *str,*mapname, *evt="";
bg_id = script_getnum(st,2);
map = script_getstr(st,3);
mapname = script_getstr(st,3);
x = script_getnum(st,4);
y = script_getnum(st,5);
str = script_getstr(st,6);
class_ = script_getnum(st,7);
if( script_hasdata(st,8) ) evt = script_getstr(st,8);
check_event(st, evt);
script_pushint(st, mob_spawn_bg(map,x,y,str,class_,evt,bg_id));
script_pushint(st, mob_spawn_bg(mapname,x,y,str,class_,evt,bg_id));
return SCRIPT_CMD_SUCCESS;
}
@ -18088,12 +18088,12 @@ static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
BUILDIN_FUNC(cleanmap)
{
const char *map;
const char *mapname;
int16 m;
int16 x0 = 0, y0 = 0, x1 = 0, y1 = 0;
map = script_getstr(st, 2);
m = map_mapname2mapid(map);
mapname = script_getstr(st, 2);
m = map_mapname2mapid(mapname);
if (!m)
return 1;

View File

@ -134,7 +134,7 @@ struct script_state {
unsigned op2ref : 1;// used by op_2
unsigned npc_item_flag : 1;
unsigned mes_active : 1; // Store if invoking character has a NPC dialog box open.
unsigned char* funcname; // Stores the current running function name
char* funcname; // Stores the current running function name
};
struct script_reg {

View File

@ -1303,10 +1303,10 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
sc_start(src,bl,SC_FREEZE,100,skill_lv,skill_get_time(skill_id,skill_lv));
break;
case RA_WUGBITE: {
int rate = (50 + 10 * skill_lv) + 2 * ((sd) ? pc_checkskill(sd,RA_TOOTHOFWUG)*2 : skill_get_max(RA_TOOTHOFWUG)) - (status_get_agi(bl) / 4);
if (rate < 50)
rate = 50;
sc_start(src,bl, SC_BITE, rate, skill_lv, (skill_get_time(skill_id,skill_lv) + ((sd) ? pc_checkskill(sd,RA_TOOTHOFWUG)*500 : skill_get_max(RA_TOOTHOFWUG))) );
int wug_rate = (50 + 10 * skill_lv) + 2 * ((sd) ? pc_checkskill(sd,RA_TOOTHOFWUG)*2 : skill_get_max(RA_TOOTHOFWUG)) - (status_get_agi(bl) / 4);
if (wug_rate < 50)
wug_rate = 50;
sc_start(src,bl, SC_BITE, wug_rate, skill_lv, (skill_get_time(skill_id,skill_lv) + ((sd) ? pc_checkskill(sd,RA_TOOTHOFWUG)*500 : skill_get_max(RA_TOOTHOFWUG))) );
}
break;
case RA_SENSITIVEKEEN:
@ -1771,7 +1771,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
{
struct block_list *tbl;
struct unit_data *ud;
int i, skill_lv, type;
int i, autospl_skill_lv, type;
for (i = 0; i < ARRAYLENGTH(sd->autospell) && sd->autospell[i].id; i++) {
@ -1787,8 +1787,8 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
continue;
sd->state.autocast = 0;
skill_lv = sd->autospell[i].lv?sd->autospell[i].lv:1;
if (skill_lv < 0) skill_lv = 1+rnd()%(-skill_lv);
autospl_skill_lv = sd->autospell[i].lv?sd->autospell[i].lv:1;
if (autospl_skill_lv < 0) autospl_skill_lv = 1+rnd()%(-autospl_skill_lv);
rate = (!sd->state.arrow_atk) ? sd->autospell[i].rate : sd->autospell[i].rate / 2;
@ -1801,16 +1801,16 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
int maxcount = 0;
if( !(BL_PC&battle_config.skill_reiteration) &&
skill_get_unit_flag(skill)&UF_NOREITERATION &&
skill_check_unit_range(src,tbl->x,tbl->y,skill,skill_lv)
skill_check_unit_range(src,tbl->x,tbl->y,skill,autospl_skill_lv)
)
continue;
if( BL_PC&battle_config.skill_nofootset &&
skill_get_unit_flag(skill)&UF_NOFOOTSET &&
skill_check_unit_range2(src,tbl->x,tbl->y,skill,skill_lv,false)
skill_check_unit_range2(src,tbl->x,tbl->y,skill,autospl_skill_lv,false)
)
continue;
if( BL_PC&battle_config.land_skill_limit &&
(maxcount = skill_get_maxcount(skill, skill_lv)) > 0
(maxcount = skill_get_maxcount(skill, autospl_skill_lv)) > 0
) {
int v;
for(v=0;v<MAX_SKILLUNITGROUP && sd->ud.skillunit[v] && maxcount;v++) {
@ -1822,7 +1822,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
}
}
if( battle_config.autospell_check_range &&
!battle_check_range(src, tbl, skill_get_range2(src, skill,skill_lv) + (skill == RG_CLOSECONFINE?0:1)) )
!battle_check_range(src, tbl, skill_get_range2(src, skill,autospl_skill_lv) + (skill == RG_CLOSECONFINE?0:1)) )
continue;
if (skill == AS_SONICBLOW)
@ -1831,24 +1831,24 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
type = CAST_GROUND;
sd->state.autocast = 1;
skill_consume_requirement(sd,skill,skill_lv,1);
skill_consume_requirement(sd,skill,autospl_skill_lv,1);
skill_toggle_magicpower(src, skill);
switch (type) {
case CAST_GROUND:
skill_castend_pos2(src, tbl->x, tbl->y, skill, skill_lv, tick, 0);
skill_castend_pos2(src, tbl->x, tbl->y, skill, autospl_skill_lv, tick, 0);
break;
case CAST_NODAMAGE:
skill_castend_nodamage_id(src, tbl, skill, skill_lv, tick, 0);
skill_castend_nodamage_id(src, tbl, skill, autospl_skill_lv, tick, 0);
break;
case CAST_DAMAGE:
skill_castend_damage_id(src, tbl, skill, skill_lv, tick, 0);
skill_castend_damage_id(src, tbl, skill, autospl_skill_lv, tick, 0);
break;
}
sd->state.autocast = 0;
//Set canact delay. [Skotlex]
ud = unit_bl2ud(src);
if (ud) {
rate = skill_delayfix(src, skill, skill_lv);
rate = skill_delayfix(src, skill, autospl_skill_lv);
if (DIFF_TICK(ud->canact_tick, tick + rate) < 0){
ud->canact_tick = tick+rate;
if ( battle_config.display_status_timers && sd )
@ -2117,7 +2117,7 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list *
{
struct block_list *tbl;
struct unit_data *ud;
int i, skill_id, skill_lv, rate, type;
int i, autospl_skill_id, autospl_skill_lv, autospl_rate, type;
for (i = 0; i < ARRAYLENGTH(dstsd->autospell2) && dstsd->autospell2[i].id; i++) {
@ -2126,41 +2126,41 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list *
((dstsd->autospell2[i].flag)&attack_type)&BF_SKILLMASK))
continue; // one or more trigger conditions were not fulfilled
skill_id = (dstsd->autospell2[i].id > 0) ? dstsd->autospell2[i].id : -dstsd->autospell2[i].id;
skill_lv = dstsd->autospell2[i].lv?dstsd->autospell2[i].lv:1;
if (skill_lv < 0) skill_lv = 1+rnd()%(-skill_lv);
autospl_skill_id = (dstsd->autospell2[i].id > 0) ? dstsd->autospell2[i].id : -dstsd->autospell2[i].id;
autospl_skill_lv = dstsd->autospell2[i].lv?dstsd->autospell2[i].lv:1;
if (autospl_skill_lv < 0) autospl_skill_lv = 1+rnd()%(-autospl_skill_lv);
rate = dstsd->autospell2[i].rate;
autospl_rate = dstsd->autospell2[i].rate;
if (attack_type&BF_LONG)
rate>>=1;
autospl_rate>>=1;
dstsd->state.autocast = 1;
if ( skill_isNotOk(skill_id, dstsd) )
if ( skill_isNotOk(autospl_skill_id, dstsd) )
continue;
dstsd->state.autocast = 0;
if (rnd()%1000 >= rate)
if (rnd()%1000 >= autospl_rate)
continue;
tbl = (dstsd->autospell2[i].id < 0) ? bl : src;
if( (type = skill_get_casttype(skill_id)) == CAST_GROUND ) {
if( (type = skill_get_casttype(autospl_skill_id)) == CAST_GROUND ) {
int maxcount = 0;
if( !(BL_PC&battle_config.skill_reiteration) &&
skill_get_unit_flag(skill_id)&UF_NOREITERATION &&
skill_check_unit_range(bl,tbl->x,tbl->y,skill_id,skill_lv)
skill_get_unit_flag(autospl_skill_id)&UF_NOREITERATION &&
skill_check_unit_range(bl,tbl->x,tbl->y,autospl_skill_id,autospl_skill_lv)
)
continue;
if( BL_PC&battle_config.skill_nofootset &&
skill_get_unit_flag(skill_id)&UF_NOFOOTSET &&
skill_check_unit_range2(bl,tbl->x,tbl->y,skill_id,skill_lv,false)
skill_get_unit_flag(autospl_skill_id)&UF_NOFOOTSET &&
skill_check_unit_range2(bl,tbl->x,tbl->y,autospl_skill_id,autospl_skill_lv,false)
)
continue;
if( BL_PC&battle_config.land_skill_limit &&
(maxcount = skill_get_maxcount(skill_id, skill_lv)) > 0
(maxcount = skill_get_maxcount(autospl_skill_id, autospl_skill_lv)) > 0
) {
int v;
for(v=0;v<MAX_SKILLUNITGROUP && dstsd->ud.skillunit[v] && maxcount;v++) {
if(dstsd->ud.skillunit[v]->skill_id == skill_id)
if(dstsd->ud.skillunit[v]->skill_id == autospl_skill_id)
maxcount--;
}
if( maxcount == 0 ) {
@ -2169,31 +2169,31 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list *
}
}
if( !battle_check_range(src, tbl, skill_get_range2(src, skill_id,skill_lv) + (skill_id == RG_CLOSECONFINE?0:1)) && battle_config.autospell_check_range )
if( !battle_check_range(src, tbl, skill_get_range2(src, autospl_skill_id,autospl_skill_lv) + (autospl_skill_id == RG_CLOSECONFINE?0:1)) && battle_config.autospell_check_range )
continue;
dstsd->state.autocast = 1;
skill_consume_requirement(dstsd,skill_id,skill_lv,1);
skill_consume_requirement(dstsd,autospl_skill_id,autospl_skill_lv,1);
switch (type) {
case CAST_GROUND:
skill_castend_pos2(bl, tbl->x, tbl->y, skill_id, skill_lv, tick, 0);
skill_castend_pos2(bl, tbl->x, tbl->y, autospl_skill_id, autospl_skill_lv, tick, 0);
break;
case CAST_NODAMAGE:
skill_castend_nodamage_id(bl, tbl, skill_id, skill_lv, tick, 0);
skill_castend_nodamage_id(bl, tbl, autospl_skill_id, autospl_skill_lv, tick, 0);
break;
case CAST_DAMAGE:
skill_castend_damage_id(bl, tbl, skill_id, skill_lv, tick, 0);
skill_castend_damage_id(bl, tbl, autospl_skill_id, autospl_skill_lv, tick, 0);
break;
}
dstsd->state.autocast = 0;
//Set canact delay. [Skotlex]
ud = unit_bl2ud(bl);
if (ud) {
rate = skill_delayfix(bl, skill_id, skill_lv);
if (DIFF_TICK(ud->canact_tick, tick + rate) < 0){
ud->canact_tick = tick+rate;
autospl_rate = skill_delayfix(bl, autospl_skill_id, autospl_skill_lv);
if (DIFF_TICK(ud->canact_tick, tick + autospl_rate) < 0){
ud->canact_tick = tick+autospl_rate;
if ( battle_config.display_status_timers && dstsd )
clif_status_change(bl, SI_ACTIONDELAY, 1, rate, 0, 0, 0);
clif_status_change(bl, SI_ACTIONDELAY, 1, autospl_rate, 0, 0, 0);
}
}
}
@ -4661,8 +4661,8 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
**/
case RK_DRAGONBREATH_WATER:
case RK_DRAGONBREATH: {
struct status_change *tsc = NULL;
if( (tsc = status_get_sc(bl)) && (tsc->data[SC_HIDING] )) {
struct status_change *tsc2 = NULL;
if( (tsc2 = status_get_sc(bl)) && (tsc2->data[SC_HIDING] )) {
clif_skill_nodamage(src,src,skill_id,skill_lv,1);
} else
skill_attack(BF_MISC,src,src,bl,skill_id,skill_lv,tick,flag);
@ -4670,8 +4670,8 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
break;
case NPC_SELFDESTRUCTION: {
struct status_change *tsc = NULL;
if( (tsc = status_get_sc(bl)) && tsc->data[SC_HIDING] )
struct status_change *tsc2 = NULL;
if( (tsc2 = status_get_sc(bl)) && tsc2->data[SC_HIDING] )
break;
}
case HVAN_EXPLOSION:
@ -4796,8 +4796,8 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case GC_PHANTOMMENACE:
if( flag&1 )
{ // Only Hits Invisible Targets
struct status_change *tsc = status_get_sc(bl);
if(tsc && (tsc->option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) || tsc->data[SC__INVISIBILITY]) )
struct status_change *tsc2 = status_get_sc(bl);
if(tsc2 && (tsc2->option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) || tsc2->data[SC__INVISIBILITY]) )
skill_attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag);
}
break;
@ -4871,7 +4871,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
// Priority is to release SpellBook
if( sc && sc->data[SC_READING_SB] )
{ // SpellBook
uint16 skill_id, skill_lv, point, s = 0;
uint16 pres_skill_id, pres_skill_lv, point, s = 0;
int spell[SC_MAXSPELLBOOK-SC_SPELLBOOK1 + 1];
int cooldown;
@ -4883,8 +4883,8 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
i = spell[s==1?0:rand()%s];// Random select of spell to be released.
if(sc->data[i] ){// Now extract the data from the preserved spell
skill_id = sc->data[i]->val1;
skill_lv = sc->data[i]->val2;
pres_skill_id = sc->data[i]->val1;
pres_skill_lv = sc->data[i]->val2;
point = sc->data[i]->val3;
status_change_end(src, (sc_type)i, INVALID_TIMER);
}else //something went wrong :(
@ -4896,32 +4896,32 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
status_change_end(src, SC_READING_SB, INVALID_TIMER);
if( bl->type != BL_SKILL ) /* skill types will crash the client */
clif_skill_nodamage(src, bl, skill_id, skill_lv, 1);
if( !skill_check_condition_castbegin(sd, skill_id, skill_lv) )
clif_skill_nodamage(src, bl, pres_skill_id, pres_skill_lv, 1);
if( !skill_check_condition_castbegin(sd, pres_skill_id, pres_skill_lv) )
break;
// SC_MAGICPOWER needs to switch states before any damage is actually dealt
skill_toggle_magicpower(src, skill_id);
skill_toggle_magicpower(src, pres_skill_id);
switch( skill_get_casttype(skill_id) )
switch( skill_get_casttype(pres_skill_id) )
{
case CAST_GROUND:
skill_castend_pos2(src, bl->x, bl->y, skill_id, skill_lv, tick, 0);
skill_castend_pos2(src, bl->x, bl->y, pres_skill_id, pres_skill_lv, tick, 0);
break;
case CAST_NODAMAGE:
skill_castend_nodamage_id(src, bl, skill_id, skill_lv, tick, 0);
skill_castend_nodamage_id(src, bl, pres_skill_id, pres_skill_lv, tick, 0);
break;
case CAST_DAMAGE:
skill_castend_damage_id(src, bl, skill_id, skill_lv, tick, 0);
skill_castend_damage_id(src, bl, pres_skill_id, pres_skill_lv, tick, 0);
break;
}
sd->ud.canact_tick = tick + skill_delayfix(src, skill_id, skill_lv);
clif_status_change(src, SI_ACTIONDELAY, 1, skill_delayfix(src, skill_id, skill_lv), 0, 0, 0);
sd->ud.canact_tick = tick + skill_delayfix(src, pres_skill_id, pres_skill_lv);
clif_status_change(src, SI_ACTIONDELAY, 1, skill_delayfix(src, pres_skill_id, pres_skill_lv), 0, 0, 0);
cooldown = pc_get_skillcooldown(sd,skill_id, skill_lv);
cooldown = pc_get_skillcooldown(sd,pres_skill_id, pres_skill_lv);
if( cooldown )
skill_blockpc_start(sd, skill_id, cooldown);
skill_blockpc_start(sd, pres_skill_id, cooldown);
}
else
{ // Summon Balls
@ -4999,8 +4999,8 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case RA_SENSITIVEKEEN:
if( bl->type != BL_SKILL ) { // Only Hits Invisible Targets
struct status_change * tsc = status_get_sc(bl);
if( tsc && tsc->option&(OPTION_HIDE|OPTION_CLOAK) ){
struct status_change * tsc2 = status_get_sc(bl);
if( tsc2 && tsc2->option&(OPTION_HIDE|OPTION_CLOAK) ){
skill_attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag);
status_change_end(bl, SC_CLOAKINGEXCEED, INVALID_TIMER);
}
@ -5141,8 +5141,8 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
break;
case SO_POISON_BUSTER: {
struct status_change *tsc = status_get_sc(bl);
if( tsc && tsc->data[SC_POISON] ) {
struct status_change *tsc2 = status_get_sc(bl);
if( tsc2 && tsc2->data[SC_POISON] ) {
skill_attack(skill_get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, flag);
status_change_end(bl, SC_POISON, INVALID_TIMER);
}
@ -5243,14 +5243,14 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case EL_TIDAL_WEAPON:
if( src->type == BL_ELEM ) {
struct elemental_data *ele = BL_CAST(BL_ELEM,src);
struct status_change *sc = status_get_sc(&ele->bl);
struct status_change *tsc = status_get_sc(bl);
struct status_change *sc2 = status_get_sc(&ele->bl);
struct status_change *tsc2 = status_get_sc(bl);
sc_type type = status_skill2sc(skill_id), type2;
type2 = type-1;
clif_skill_nodamage(src,battle_get_master(src),skill_id,skill_lv,1);
clif_skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
if( (sc && sc->data[type2]) || (tsc && tsc->data[type]) ) {
if( (sc2 && sc2->data[type2]) || (tsc2 && tsc2->data[type]) ) {
elemental_clean_single_effect(ele, skill_id);
}
if( rnd()%100 < 50 )
@ -6971,7 +6971,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case AM_BERSERKPITCHER:
case AM_POTIONPITCHER:
{
int i,hp = 0,sp = 0;
int j,hp = 0,sp = 0;
if( dstmd && dstmd->mob_id == MOBID_EMPERIUM ) {
map_freeblock_unlock();
return 1;
@ -6980,19 +6980,19 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
int x,bonus=100;
struct skill_condition require = skill_get_requirement(sd, skill_id, skill_lv);
x = skill_lv%11 - 1;
i = pc_search_inventory(sd, require.itemid[x]);
if (i < 0 || require.itemid[x] <= 0) {
j = pc_search_inventory(sd, require.itemid[x]);
if (j < 0 || require.itemid[x] <= 0) {
clif_skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
map_freeblock_unlock();
return 1;
}
if (sd->inventory_data[i] == NULL || sd->status.inventory[i].amount < require.amount[x]) {
if (sd->inventory_data[j] == NULL || sd->status.inventory[j].amount < require.amount[x]) {
clif_skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
map_freeblock_unlock();
return 1;
}
if( skill_id == AM_BERSERKPITCHER ) {
if( dstsd && dstsd->status.base_level < (unsigned int)sd->inventory_data[i]->elv ) {
if( dstsd && dstsd->status.base_level < (unsigned int)sd->inventory_data[j]->elv ) {
clif_skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
map_freeblock_unlock();
return 1;
@ -7001,7 +7001,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
potion_flag = 1;
potion_hp = potion_sp = potion_per_hp = potion_per_sp = 0;
potion_target = bl->id;
run_script(sd->inventory_data[i]->script,0,sd->bl.id,0);
run_script(sd->inventory_data[j]->script,0,sd->bl.id,0);
potion_flag = potion_target = 0;
if( sd->sc.data[SC_SPIRIT] && sd->sc.data[SC_SPIRIT]->val2 == SL_ALCHEMIST )
bonus += sd->status.base_level;
@ -7032,9 +7032,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
sp += sp * bonus / 100;
}
if( (i = pc_skillheal_bonus(sd, skill_id)) ) {
hp += hp * i / 100;
sp += sp * i / 100;
if( (j = pc_skillheal_bonus(sd, skill_id)) ) {
hp += hp * j / 100;
sp += sp * j / 100;
}
} else {
//Maybe replace with potion_hp, but I'm unsure how that works [Playtester]
@ -7049,9 +7049,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if( dstsd )
hp = hp * (100 + pc_checkskill(dstsd,SM_RECOVERY)*10) / 100;
}
if( dstsd && (i = pc_skillheal2_bonus(dstsd, skill_id)) ) {
hp += hp * i / 100;
sp += sp * i / 100;
if( dstsd && (j = pc_skillheal2_bonus(dstsd, skill_id)) ) {
hp += hp * j / 100;
sp += sp * j / 100;
}
if( tsc && tsc->count ) {
if( tsc->data[SC_CRITICALWOUND] ) {
@ -7362,8 +7362,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
maxlv = skill_lv - 4;
}
else if(skill_lv >=2) {
int i = rnd()%3;
spellid = spellarray[i];
int i_rnd = rnd()%3;
spellid = spellarray[i_rnd];
maxlv = skill_lv - 1;
}
else if(skill_lv > 0) {
@ -7476,11 +7476,11 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case NPC_SPEEDUP:
{
// or does it increase casting rate? just a guess xD
int i = SC_ASPDPOTION0 + skill_lv - 1;
if (i > SC_ASPDPOTION3)
i = SC_ASPDPOTION3;
int i_type = SC_ASPDPOTION0 + skill_lv - 1;
if (i_type > SC_ASPDPOTION3)
i_type = SC_ASPDPOTION3;
clif_skill_nodamage(src,bl,skill_id,skill_lv,
sc_start(src,bl,(sc_type)i,100,skill_lv,skill_lv * 60000));
sc_start(src,bl,(sc_type)i_type,100,skill_lv,skill_lv * 60000));
}
break;
@ -7633,15 +7633,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
{
if( skill_get_itemid(su->group->skill_id, i+1) > 0 )
{
int flag;
int flag2;
struct item item_tmp;
memset(&item_tmp,0,sizeof(item_tmp));
item_tmp.nameid = skill_get_itemid(su->group->skill_id, i+1);
item_tmp.identify = 1;
item_tmp.amount = skill_get_itemqty(su->group->skill_id, i+1);
if( item_tmp.nameid && (flag=pc_additem(sd,&item_tmp,item_tmp.amount,LOG_TYPE_OTHER)) )
{
clif_additem(sd,0,0,flag);
if( item_tmp.nameid && (flag2=pc_additem(sd,&item_tmp,item_tmp.amount,LOG_TYPE_OTHER)) ){
clif_additem(sd,0,0,flag2);
map_addflooritem(&item_tmp,item_tmp.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,4);
}
}
@ -7827,12 +7826,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case CR_FULLPROTECTION:
{
unsigned int equip[] = {EQP_WEAPON, EQP_SHIELD, EQP_ARMOR, EQP_HEAD_TOP};
int i, s = 0, skilltime = skill_get_time(skill_id,skill_lv);
int i_eqp, s = 0, skilltime = skill_get_time(skill_id,skill_lv);
for (i = 0; i < 4; i++) {
if( bl->type != BL_PC || ( dstsd && pc_checkequip(dstsd,equip[i]) < 0 ) )
for (i_eqp = 0; i_eqp < 4; i_eqp++) {
if( bl->type != BL_PC || ( dstsd && pc_checkequip(dstsd,equip[i_eqp]) < 0 ) )
continue;
sc_start(src,bl,(sc_type)(SC_CP_WEAPON + i),100,skill_lv,skilltime);
sc_start(src,bl,(sc_type)(SC_CP_WEAPON + i_eqp),100,skill_lv,skilltime);
s++;
}
if( sd && !s ){
@ -9841,27 +9840,27 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case KO_KAZEHU_SEIRAN:
case KO_DOHU_KOUKAI:
if(sd) {
int i, ttype = skill_get_ele(skill_id, skill_lv);
int i_tal, ttype = skill_get_ele(skill_id, skill_lv);
clif_skill_nodamage(src, bl, skill_id, skill_lv, 1);
ARR_FIND(1, 6, i, sd->talisman[i] > 0 && ttype != i);
if( i < 6 )
pc_del_talisman(sd, sd->talisman[i], i); // Replace talisman
ARR_FIND(1, 6, i_tal, sd->talisman[i_tal] > 0 && ttype != i_tal);
if( i_tal < 6 )
pc_del_talisman(sd, sd->talisman[i_tal], i_tal); // Replace talisman
pc_add_talisman(sd, skill_get_time(skill_id, skill_lv), 10, ttype);
}
break;
case KO_ZANZOU:
if(sd){
struct mob_data *md;
struct mob_data *md2;
md = mob_once_spawn_sub(src, src->m, src->x, src->y, status_get_name(src), MOBID_ZANZOU, "", SZ_SMALL, AI_NONE);
if( md )
md2 = mob_once_spawn_sub(src, src->m, src->x, src->y, status_get_name(src), MOBID_ZANZOU, "", SZ_SMALL, AI_NONE);
if( md2 )
{
md->master_id = src->id;
md->special_state.ai = AI_ZANZOU;
if( md->deletetimer != INVALID_TIMER )
delete_timer(md->deletetimer, mob_timer_delete);
md->deletetimer = add_timer (gettick() + skill_get_time(skill_id, skill_lv), mob_timer_delete, md->bl.id, 0);
mob_spawn( md );
md2->master_id = src->id;
md2->special_state.ai = AI_ZANZOU;
if( md2->deletetimer != INVALID_TIMER )
delete_timer(md2->deletetimer, mob_timer_delete);
md2->deletetimer = add_timer (gettick() + skill_get_time(skill_id, skill_lv), mob_timer_delete, md2->bl.id, 0);
mob_spawn( md2 );
pc_setinvincibletimer(sd,500);// unlock target lock
clif_skill_nodamage(src,bl,skill_id,skill_lv,1);
skill_blown(src,bl,skill_get_blewcount(skill_id,skill_lv),unit_getdir(bl),0);
@ -10036,13 +10035,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
int summons[5] = {MOBID_S_HORNET, MOBID_S_GIANT_HORNET, MOBID_S_GIANT_HORNET, MOBID_S_LUCIOLA_VESPA, MOBID_S_LUCIOLA_VESPA};
int qty[5] = {3 , 3 , 4 , 4 , 5};
struct mob_data *sum_md;
int i,c=0;
int i_slave,c=0;
int maxcount = qty[skill_lv-1];
i = map_foreachinmap(skill_check_condition_mob_master_sub ,hd->bl.m, BL_MOB, hd->bl.id, summons[skill_lv-1], skill_id, &c);
i_slave = map_foreachinmap(skill_check_condition_mob_master_sub ,hd->bl.m, BL_MOB, hd->bl.id, summons[skill_lv-1], skill_id, &c);
if(c >= maxcount) return 0; //max qty already spawned
for(i=0; i<qty[skill_lv - 1]; i++){ //easy way
for(i_slave=0; i_slave<qty[skill_lv - 1]; i_slave++){ //easy way
sum_md = mob_once_spawn_sub(src, src->m, src->x, src->y, status_get_name(src), summons[skill_lv - 1], "", SZ_SMALL, AI_ATTACK);
if (sum_md) {
sum_md->master_id = src->id;
@ -10070,11 +10069,11 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
break;
case RL_C_MARKER:
if (sd && (dstsd || (bl->type == BL_MOB && dstmd))) {
uint8 i;
uint8 i_scm;
sd->c_marker.count = 0;
//Find empty slot. If already exist, renew it!
ARR_FIND(0,MAX_SKILL_CRIMSON_MARKER,i,sd->c_marker.target[i] == bl->id || !sd->c_marker.target[i]);
if (i >= MAX_SKILL_CRIMSON_MARKER) { //No slot
ARR_FIND(0,MAX_SKILL_CRIMSON_MARKER,i_scm,sd->c_marker.target[i_scm] == bl->id || !sd->c_marker.target[i_scm]);
if (i_scm >= MAX_SKILL_CRIMSON_MARKER) { //No slot
clif_skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
break;
}
@ -10083,7 +10082,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
clif_skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
break;
}
sd->c_marker.target[i] = bl->id;
sd->c_marker.target[i_scm] = bl->id;
clif_skill_nodamage(src,bl,skill_id,skill_lv,1);
}
break;
@ -10762,16 +10761,16 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
case SA_DELUGE:
case SA_VIOLENTGALE:
{ //Does not consumes if the skill is already active. [Skotlex]
struct skill_unit_group *sg;
if ((sg= skill_locate_element_field(src)) != NULL && ( sg->skill_id == SA_VOLCANO || sg->skill_id == SA_DELUGE || sg->skill_id == SA_VIOLENTGALE ))
struct skill_unit_group *sg2;
if ((sg2= skill_locate_element_field(src)) != NULL && ( sg2->skill_id == SA_VOLCANO || sg2->skill_id == SA_DELUGE || sg2->skill_id == SA_VIOLENTGALE ))
{
if (sg->limit - DIFF_TICK(gettick(), sg->tick) > 0)
if (sg2->limit - DIFF_TICK(gettick(), sg2->tick) > 0)
{
skill_unitsetting(src,skill_id,skill_lv,x,y,0);
return 0; // not to consume items
}
else
sg->limit = 0; //Disable it.
sg2->limit = 0; //Disable it.
}
skill_unitsetting(src,skill_id,skill_lv,x,y,0);
break;
@ -11003,11 +11002,11 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
// Slim Pitcher [Celest]
case CR_SLIMPITCHER:
if (sd) {
int i = 0, j = 0;
int i_lv = 0, j = 0;
struct skill_condition require = skill_get_requirement(sd, skill_id, skill_lv);
i = skill_lv%11 - 1;
j = pc_search_inventory(sd, require.itemid[i]);
if (j < 0 || require.itemid[i] <= 0 || sd->inventory_data[j] == NULL || sd->status.inventory[j].amount < require.amount[i])
i_lv = skill_lv%11 - 1;
j = pc_search_inventory(sd, require.itemid[i_lv]);
if (j < 0 || require.itemid[i_lv] <= 0 || sd->inventory_data[j] == NULL || sd->status.inventory[j].amount < require.amount[i_lv])
{
clif_skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 1;
@ -11018,39 +11017,39 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
run_script(sd->inventory_data[j]->script,0,sd->bl.id,0);
potion_flag = 0;
//Apply skill bonuses
i = pc_checkskill(sd,CR_SLIMPITCHER)*10
i_lv = pc_checkskill(sd,CR_SLIMPITCHER)*10
+ pc_checkskill(sd,AM_POTIONPITCHER)*10
+ pc_checkskill(sd,AM_LEARNINGPOTION)*5
+ pc_skillheal_bonus(sd, skill_id);
potion_hp = potion_hp * (100+i)/100;
potion_sp = potion_sp * (100+i)/100;
potion_hp = potion_hp * (100+i_lv)/100;
potion_sp = potion_sp * (100+i_lv)/100;
if(potion_hp > 0 || potion_sp > 0) {
i = skill_get_splash(skill_id, skill_lv);
i_lv = skill_get_splash(skill_id, skill_lv);
map_foreachinarea(skill_area_sub,
src->m,x-i,y-i,x+i,y+i,BL_CHAR,
src->m,x-i_lv,y-i_lv,x+i_lv,y+i_lv,BL_CHAR,
src,skill_id,skill_lv,tick,flag|BCT_PARTY|BCT_GUILD|1,
skill_castend_nodamage_id);
}
} else {
int i = skill_get_itemid(skill_id, skill_lv);
int id = skill_get_itemid(skill_id, skill_lv);
struct item_data *item;
item = itemdb_search(i);
item = itemdb_search(id);
potion_flag = 1;
potion_hp = 0;
potion_sp = 0;
run_script(item->script,0,src->id,0);
potion_flag = 0;
i = skill_get_max(CR_SLIMPITCHER)*10;
id = skill_get_max(CR_SLIMPITCHER)*10;
potion_hp = potion_hp * (100+i)/100;
potion_sp = potion_sp * (100+i)/100;
potion_hp = potion_hp * (100+id)/100;
potion_sp = potion_sp * (100+id)/100;
if(potion_hp > 0 || potion_sp > 0) {
i = skill_get_splash(skill_id, skill_lv);
id = skill_get_splash(skill_id, skill_lv);
map_foreachinarea(skill_area_sub,
src->m,x-i,y-i,x+i,y+i,BL_CHAR,
src->m,x-id,y-id,x+id,y+id,BL_CHAR,
src,skill_id,skill_lv,tick,flag|BCT_PARTY|BCT_GUILD|1,
skill_castend_nodamage_id);
}
@ -11088,13 +11087,13 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
clif_skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
} else {
TBL_MOB* md = mob_once_spawn_sub(src, src->m, x, y, "--ja--",(skill_lv < 2 ? MOBID_BLACK_MUSHROOM + rnd()%2 : MOBID_RED_PLANT + rnd()%6),"", SZ_SMALL, AI_NONE);
int i;
int t;
if (!md) break;
if ((i = skill_get_time(skill_id, skill_lv)) > 0)
if ((t = skill_get_time(skill_id, skill_lv)) > 0)
{
if( md->deletetimer != INVALID_TIMER )
delete_timer(md->deletetimer, mob_timer_delete);
md->deletetimer = add_timer (tick + i, mob_timer_delete, md->bl.id, 0);
md->deletetimer = add_timer (tick + t, mob_timer_delete, md->bl.id, 0);
}
mob_spawn (md);
}
@ -11193,18 +11192,18 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
case WL_EARTHSTRAIN:
{
int i, wave = skill_lv + 4, dir = map_calc_dir(src,x,y);
int w, wave = skill_lv + 4, dir = map_calc_dir(src,x,y);
int sx = x = src->x, sy = y = src->y; // Store first caster's location to avoid glitch on unit setting
for( i = 1; i <= wave; i++ )
for( w = 1; w <= wave; w++ )
{
switch( dir ){
case 0: case 1: case 7: sy = y + i; break;
case 3: case 4: case 5: sy = y - i; break;
case 2: sx = x - i; break;
case 6: sx = x + i; break;
case 0: case 1: case 7: sy = y + w; break;
case 3: case 4: case 5: sy = y - w; break;
case 2: sx = x - w; break;
case 6: sx = x + w; break;
}
skill_addtimerskill(src,gettick() + (140 * i),0,sx,sy,skill_id,skill_lv,dir,flag&2);
skill_addtimerskill(src,gettick() + (140 * w),0,sx,sy,skill_id,skill_lv,dir,flag&2);
}
}
break;
@ -11335,33 +11334,33 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
}
break;
case GN_FIRE_EXPANSION: {
int i;
int i_su;
struct unit_data *ud = unit_bl2ud(src);
if( !ud ) break;
for( i = 0; i < MAX_SKILLUNITGROUP && ud->skillunit[i]; i ++ ) {
if( ud->skillunit[i]->skill_id == GN_DEMONIC_FIRE &&
distance_xy(x, y, ud->skillunit[i]->unit->bl.x, ud->skillunit[i]->unit->bl.y) < 4 ) {
for( i_su = 0; i_su < MAX_SKILLUNITGROUP && ud->skillunit[i_su]; i_su ++ ) {
if( ud->skillunit[i_su]->skill_id == GN_DEMONIC_FIRE &&
distance_xy(x, y, ud->skillunit[i_su]->unit->bl.x, ud->skillunit[i_su]->unit->bl.y) < 4 ) {
switch( skill_lv ) {
case 1:
ud->skillunit[i]->unit->val2 = skill_lv;
ud->skillunit[i]->unit->group->val2 = skill_lv;
ud->skillunit[i_su]->unit->val2 = skill_lv;
ud->skillunit[i_su]->unit->group->val2 = skill_lv;
break;
case 2:
map_foreachinarea(skill_area_sub,src->m,
ud->skillunit[i]->unit->bl.x - 2,ud->skillunit[i]->unit->bl.y - 2,
ud->skillunit[i]->unit->bl.x + 2,ud->skillunit[i]->unit->bl.y + 2, BL_CHAR,
ud->skillunit[i_su]->unit->bl.x - 2,ud->skillunit[i_su]->unit->bl.y - 2,
ud->skillunit[i_su]->unit->bl.x + 2,ud->skillunit[i_su]->unit->bl.y + 2, BL_CHAR,
src, GN_DEMONIC_FIRE, skill_lv + 20, tick, flag|BCT_ENEMY|SD_LEVEL|1, skill_castend_damage_id);
skill_delunit(ud->skillunit[i]->unit);
skill_delunit(ud->skillunit[i_su]->unit);
break;
case 3:
skill_delunit(ud->skillunit[i]->unit);
skill_delunit(ud->skillunit[i_su]->unit);
skill_unitsetting(src, GN_FIRE_EXPANSION_SMOKE_POWDER, 1, x, y, 0);
flag |= 1;
break;
case 4:
skill_delunit(ud->skillunit[i]->unit);
skill_delunit(ud->skillunit[i_su]->unit);
skill_unitsetting(src, GN_FIRE_EXPANSION_TEAR_GAS, 1, x, y, 0);
flag |= 1;
break;
@ -11370,10 +11369,10 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
if( sd && pc_checkskill(sd, CR_ACIDDEMONSTRATION) > 5 )
acid_lv = pc_checkskill(sd, CR_ACIDDEMONSTRATION);
map_foreachinarea(skill_area_sub, src->m,
ud->skillunit[i]->unit->bl.x - 2, ud->skillunit[i]->unit->bl.y - 2,
ud->skillunit[i]->unit->bl.x + 2, ud->skillunit[i]->unit->bl.y + 2, BL_CHAR,
ud->skillunit[i_su]->unit->bl.x - 2, ud->skillunit[i_su]->unit->bl.y - 2,
ud->skillunit[i_su]->unit->bl.x + 2, ud->skillunit[i_su]->unit->bl.y + 2, BL_CHAR,
src, GN_FIRE_EXPANSION_ACID, acid_lv, tick, flag|BCT_ENEMY|SD_LEVEL|1, skill_castend_damage_id);
skill_delunit(ud->skillunit[i]->unit);
skill_delunit(ud->skillunit[i_su]->unit);
}
break;
}
@ -11442,21 +11441,21 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
}
break;
case RL_FIRE_RAIN: {
int i, wave = skill_lv + 5, dir = map_calc_dir(src,x,y);
int w, wave = skill_lv + 5, dir = map_calc_dir(src,x,y);
int sx = x = src->x, sy = y = src->y;
for (i = 1; i <= wave; i++) {
for (w = 1; w <= wave; w++) {
switch (dir) {
case 0: sy = y + i; break;
case 1: sy = y + i; sx = x - i; break;
case 2: sx = x - i; break;
case 3: sx = x - i; sy = y - i; break;
case 4: sy = y - i; break;
case 5: sx = x + i; sy = y - i; break;
case 6: sx = x + i; break;
case 7: sy = y + i; sx = x + i; break;
case 0: sy = y + w; break;
case 1: sy = y + w; sx = x - w; break;
case 2: sx = x - w; break;
case 3: sx = x - w; sy = y - w; break;
case 4: sy = y - w; break;
case 5: sx = x + w; sy = y - w; break;
case 6: sx = x + w; break;
case 7: sy = y + w; sx = x + w; break;
}
skill_addtimerskill(src,gettick() + (140 * i),0,sx,sy,skill_id,skill_lv,dir,flag);
skill_addtimerskill(src,gettick() + (140 * w),0,sx,sy,skill_id,skill_lv,dir,flag);
}
}
break;
@ -11488,7 +11487,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
/*==========================================
*
*------------------------------------------*/
int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char *map)
int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char *mapname)
{
nullpo_ret(sd);
@ -11511,9 +11510,9 @@ int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char
pc_stop_walking(sd,0);
if(battle_config.skill_log && battle_config.skill_log&BL_PC)
ShowInfo("PC %d skill castend skill =%d map=%s\n",sd->bl.id,skill_id,map);
ShowInfo("PC %d skill castend skill =%d map=%s\n",sd->bl.id,skill_id,mapname);
if(strcmp(map,"cancel")==0) {
if(strcmp(mapname,"cancel")==0) {
skill_failed(sd);
return 0;
}
@ -11525,7 +11524,7 @@ int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char
//The storage window is closed automatically by the client when there's
//any kind of map change, so we need to restore it automatically
//bugreport:8027
if(strcmp(map,"Random") == 0)
if(strcmp(mapname,"Random") == 0)
pc_randomwarp(sd,CLR_TELEPORT);
else if (sd->menuskill_val > 1 || skill_id == ALL_ODINS_RECALL) //Need lv2 to be able to warp here.
pc_setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
@ -11542,7 +11541,7 @@ int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char
int x,y;
unsigned short mapindex;
mapindex = mapindex_name2id((char*)map);
mapindex = mapindex_name2id((char*)mapname);
if(!mapindex) { //Given map not found?
clif_skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
skill_failed(sd);
@ -12102,8 +12101,8 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill
struct skill_unit *unit;
int ux = x + layout->dx[i];
int uy = y + layout->dy[i];
int val1 = skill_lv;
int val2 = 0;
int val1_2 = skill_lv;
int val2_2 = 0;
int alive = 1;
// are the coordinates out of range?
@ -12120,11 +12119,11 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill
{
case MG_FIREWALL:
case NJ_KAENSIN:
val2=group->val2;
val2_2=group->val2;
break;
case WZ_ICEWALL:
val1 = (skill_lv <= 1) ? 500 : 200 + 200*skill_lv;
val2 = map_getcell(src->m, ux, uy, CELL_GETTYPE);
val1_2 = (skill_lv <= 1) ? 500 : 200 + 200*skill_lv;
val2_2 = map_getcell(src->m, ux, uy, CELL_GETTYPE);
break;
case HT_LANDMINE:
case MA_LANDMINE:
@ -12149,35 +12148,35 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill
case RA_FIRINGTRAP:
case RA_ICEBOUNDTRAP:
case RL_B_TRAP:
val1 = 3500;
val1_2 = 3500;
break;
case GS_DESPERADO:
val1 = abs(layout->dx[i]);
val2 = abs(layout->dy[i]);
if (val1 < 2 || val2 < 2) { //Nearby cross, linear decrease with no diagonals
if (val2 > val1) val1 = val2;
if (val1) val1--;
val1 = 36 -12*val1;
val1_2 = abs(layout->dx[i]);
val2_2 = abs(layout->dy[i]);
if (val1_2 < 2 || val2_2 < 2) { //Nearby cross, linear decrease with no diagonals
if (val2_2 > val1_2) val1_2 = val2_2;
if (val1_2) val1_2--;
val1_2 = 36 -12*val1_2;
} else //Diagonal edges
val1 = 28 -4*val1 -4*val2;
if (val1 < 1) val1 = 1;
val2 = 0;
val1_2 = 28 -4*val1_2 -4*val2_2;
if (val1_2 < 1) val1_2 = 1;
val2_2 = 0;
break;
case WM_REVERBERATION:
case WM_POEMOFNETHERWORLD:
val1 = 1 + skill_lv;
val1_2 = 1 + skill_lv;
break;
case GN_WALLOFTHORN:
val1 = 2000 + 2000 * skill_lv;
val2 = 20;
val1_2 = 2000 + 2000 * skill_lv;
val2_2 = 20;
break;
default:
if (group->state.song_dance&0x1)
val2 = unit_flag&(UF_DANCE|UF_SONG); //Store whether this is a song/dance
val2_2 = unit_flag&(UF_DANCE|UF_SONG); //Store whether this is a song/dance
break;
}
if (unit_flag&UF_RANGEDSINGLEUNIT && i == (layout->count / 2))
val2 |= UF_RANGEDSINGLEUNIT; // center.
val2_2 |= UF_RANGEDSINGLEUNIT; // center.
if( sd && map_getcell(src->m, ux, uy, CELL_CHKMAELSTROM) ) //Does not recover SP from monster skills
map_foreachincell(skill_maelstrom_suction,src->m,ux,uy,BL_SKILL,skill_id,skill_lv);
@ -12187,7 +12186,7 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill
if( !alive )
continue;
nullpo_retr(NULL, unit=skill_initunit(group,i,ux,uy,val1,val2));
nullpo_retr(NULL, unit=skill_initunit(group,i,ux,uy,val1_2,val2_2));
unit->limit=limit;
unit->range=range;
@ -13810,9 +13809,9 @@ bool skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_i
|| (sd->bl.type != BL_PC && battle_config.monster_cloak_check_type&1) )) { //Check for walls.
static int dx[] = { 0, 1, 0, -1, -1, 1, 1, -1};
static int dy[] = {-1, 0, 1, 0, -1, -1, 1, 1};
int i;
ARR_FIND( 0, 8, i, map_getcell(sd->bl.m, sd->bl.x+dx[i], sd->bl.y+dy[i], CELL_CHKNOPASS) != 0 );
if( i == 8 ) {
int di;
ARR_FIND( 0, 8, di, map_getcell(sd->bl.m, sd->bl.x+dx[di], sd->bl.y+dy[di], CELL_CHKNOPASS) != 0 );
if( di == 8 ) {
clif_skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return false;
}
@ -13962,11 +13961,11 @@ bool skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_i
break;
case CG_MOONLIT: //Check there's no wall in the range+1 area around the caster. [Skotlex]
{
int i,range = skill_get_splash(skill_id, skill_lv)+1;
int s,range = skill_get_splash(skill_id, skill_lv)+1;
int size = range*2+1;
for (i=0;i<size*size;i++) {
int x = sd->bl.x+(i%size-range);
int y = sd->bl.y+(i/size-range);
for (s=0;s<size*size;s++) {
int x = sd->bl.x+(s%size-range);
int y = sd->bl.y+(s/size-range);
if (map_getcell(sd->bl.m,x,y,CELL_CHKWALL)) {
clif_skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return false;
@ -13987,11 +13986,11 @@ bool skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_i
case HP_BASILICA:
if( !sc || (sc && !sc->data[SC_BASILICA])) {
if( sd ) {
int i,range = skill_get_unit_range(skill_id,skill_lv)+1;
int s,range = skill_get_unit_range(skill_id,skill_lv)+1;
int size = range*2+1;
for( i=0;i<size*size;i++ ) {
int x = sd->bl.x+(i%size-range);
int y = sd->bl.y+(i/size-range);
for( s=0;s<size*size;s++ ) {
int x = sd->bl.x+(s%size-range);
int y = sd->bl.y+(s/size-range);
if( map_getcell(sd->bl.m,x,y,CELL_CHKWALL) ) {
clif_skill_fail(sd,skill_id,USESKILL_FAIL,0);
return false;
@ -14460,10 +14459,10 @@ bool skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_i
/* check the status required */
if (require.status_count) {
uint8 i;
uint8 c;
/* May has multiple requirements */
for (i = 0; i < require.status_count; i++) {
enum sc_type req_sc = require.status[i];
for (c = 0; c < require.status_count; c++) {
enum sc_type req_sc = require.status[c];
if (req_sc == SC_NONE)
continue;
@ -17564,11 +17563,11 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, unsigned sh
}
if( skill_id == RK_RUNEMASTERY ) {
int temp_qty, skill_lv = pc_checkskill(sd,skill_id);
int temp_qty, runemastery_skill_lv = pc_checkskill(sd,skill_id);
data = itemdb_search(nameid);
if( skill_lv == 10 ) temp_qty = 1 + rnd()%3;
else if( skill_lv > 5 ) temp_qty = 1 + rnd()%2;
if( runemastery_skill_lv == 10 ) temp_qty = 1 + rnd()%3;
else if( runemastery_skill_lv > 5 ) temp_qty = 1 + rnd()%2;
else temp_qty = 1;
if (data->stack.inventory) {

View File

@ -8548,9 +8548,9 @@ int status_change_start(struct block_list* src, struct block_list* bl,enum sc_ty
if (status->hp - diff < status->max_hp>>2)
diff = status->hp - (status->max_hp>>2);
if( val2 && bl->type == BL_MOB ) {
struct block_list* src = map_id2bl(val2);
if( src )
mob_log_damage((TBL_MOB*)bl,src,diff);
struct block_list* src2 = map_id2bl(val2);
if( src2 )
mob_log_damage((TBL_MOB*)bl,src2,diff);
}
status_zap(bl, diff, 0);
}
@ -8757,7 +8757,7 @@ int status_change_start(struct block_list* src, struct block_list* bl,enum sc_ty
struct status_change *psc = pbl?status_get_sc(pbl):NULL;
struct status_change_entry *psce = psc?psc->data[SC_MARIONETTE]:NULL;
// Fetch target's stats
struct status_data* status = status_get_status_data(bl); // Battle status
struct status_data* status2 = status_get_status_data(bl); // Battle status
if (!psce)
return 0;
@ -8765,12 +8765,12 @@ int status_change_start(struct block_list* src, struct block_list* bl,enum sc_ty
val3 = 0;
val4 = 0;
max_stat = battle_config.max_parameter; // Cap to 99 (default)
stat = (psce->val3 >>16)&0xFF; stat = min(stat, max_stat - status->str ); val3 |= cap_value(stat,0,0xFF)<<16;
stat = (psce->val3 >> 8)&0xFF; stat = min(stat, max_stat - status->agi ); val3 |= cap_value(stat,0,0xFF)<<8;
stat = (psce->val3 >> 0)&0xFF; stat = min(stat, max_stat - status->vit ); val3 |= cap_value(stat,0,0xFF);
stat = (psce->val4 >>16)&0xFF; stat = min(stat, max_stat - status->int_); val4 |= cap_value(stat,0,0xFF)<<16;
stat = (psce->val4 >> 8)&0xFF; stat = min(stat, max_stat - status->dex ); val4 |= cap_value(stat,0,0xFF)<<8;
stat = (psce->val4 >> 0)&0xFF; stat = min(stat, max_stat - status->luk ); val4 |= cap_value(stat,0,0xFF);
stat = (psce->val3 >>16)&0xFF; stat = min(stat, max_stat - status2->str ); val3 |= cap_value(stat,0,0xFF)<<16;
stat = (psce->val3 >> 8)&0xFF; stat = min(stat, max_stat - status2->agi ); val3 |= cap_value(stat,0,0xFF)<<8;
stat = (psce->val3 >> 0)&0xFF; stat = min(stat, max_stat - status2->vit ); val3 |= cap_value(stat,0,0xFF);
stat = (psce->val4 >>16)&0xFF; stat = min(stat, max_stat - status2->int_); val4 |= cap_value(stat,0,0xFF)<<16;
stat = (psce->val4 >> 8)&0xFF; stat = min(stat, max_stat - status2->dex ); val4 |= cap_value(stat,0,0xFF)<<8;
stat = (psce->val4 >> 0)&0xFF; stat = min(stat, max_stat - status2->luk ); val4 |= cap_value(stat,0,0xFF);
break;
}
case SC_REJECTSWORD:
@ -8817,9 +8817,9 @@ int status_change_start(struct block_list* src, struct block_list* bl,enum sc_ty
case SC_COMA: // Coma. Sends a char to 1HP. If val2, do not zap sp
if( val3 && bl->type == BL_MOB ) {
struct block_list* src = map_id2bl(val3);
if( src )
mob_log_damage((TBL_MOB*)bl,src,status->hp - 1);
struct block_list* src2 = map_id2bl(val3);
if( src2 )
mob_log_damage((TBL_MOB*)bl,src2,status->hp - 1);
}
status_zap(bl, status->hp-1, val2?0:status->sp);
return 1;
@ -8827,18 +8827,18 @@ int status_change_start(struct block_list* src, struct block_list* bl,enum sc_ty
case SC_TINDER_BREAKER2:
case SC_CLOSECONFINE2:
{
struct block_list *src = val2?map_id2bl(val2):NULL;
struct status_change *sc2 = src?status_get_sc(src):NULL;
struct block_list *src2 = val2?map_id2bl(val2):NULL;
struct status_change *sc2 = src2?status_get_sc(src2):NULL;
enum sc_type type2 = ((type == SC_TINDER_BREAKER2)?SC_TINDER_BREAKER:SC_CLOSECONFINE);
struct status_change_entry *sce2 = sc2?sc2->data[type2]:NULL;
if (src && sc2) {
if (src2 && sc2) {
if (!sce2) // Start lock on caster.
sc_start4(src,src,type2,100,val1,1,0,0,tick+1000);
sc_start4(src2,src2,type2,100,val1,1,0,0,tick+1000);
else { // Increase count of locked enemies and refresh time.
(sce2->val2)++;
delete_timer(sce2->timer, status_change_timer);
sce2->timer = add_timer(gettick()+tick+1000, status_change_timer, src->id, type2);
sce2->timer = add_timer(gettick()+tick+1000, status_change_timer, src2->id, type2);
}
} else // Status failed.
return 0;
@ -9011,11 +9011,11 @@ int status_change_start(struct block_list* src, struct block_list* bl,enum sc_ty
if (sd) {
if (sd->mapindex != val2) {
int pos = (bl->x&0xFFFF)|(bl->y<<16), // Current Coordinates
map = sd->mapindex; // Current Map
map_idx = sd->mapindex; // Current Map
// 1. Place in Jail (val2 -> Jail Map, val3 -> x, val4 -> y
pc_setpos(sd,(unsigned short)val2,val3,val4, CLR_TELEPORT);
// 2. Set restore point (val3 -> return map, val4 return coords
val3 = map;
val3 = map_idx;
val4 = pos;
} else if (!val3 || val3 == sd->mapindex) { // Use save point.
val3 = sd->status.save_point.map;
@ -9495,20 +9495,20 @@ int status_change_start(struct block_list* src, struct block_list* bl,enum sc_ty
break;
case SC_GT_CHANGE:
{ // Take note there is no def increase as skill desc says. [malufett]
struct block_list * src;
struct block_list * src2;
val3 = status->agi * val1 / 60; // ASPD increase: [(Target AGI x Skill Level) / 60] %
if( (src = map_id2bl(val2)) )
val4 = ( 200/status_get_int(src) ) * val1; // MDEF decrease: MDEF [(200 / Caster INT) x Skill Level]
if( (src2 = map_id2bl(val2)) )
val4 = ( 200/status_get_int(src2) ) * val1; // MDEF decrease: MDEF [(200 / Caster INT) x Skill Level]
if( val4 < 0 )
val4 = 0;
}
break;
case SC_GT_REVITALIZE:
{ // Take note there is no vit,aspd,speed increase as skill desc says. [malufett]
struct block_list * src;
struct block_list * src2;
val3 = val1 * 30 + 50; // Natural HP recovery increase: [(Skill Level x 30) + 50] %
if( (src = map_id2bl(val2)) ) // The stat def is not shown in the status window and it is process differently
val4 = ( status_get_vit(src)/4 ) * val1; // STAT DEF increase: [(Caster VIT / 4) x Skill Level]
if( (src2 = map_id2bl(val2)) ) // The stat def is not shown in the status window and it is process differently
val4 = ( status_get_vit(src2)/4 ) * val1; // STAT DEF increase: [(Caster VIT / 4) x Skill Level]
}
break;
case SC_PYROTECHNIC_OPTION:
@ -10562,15 +10562,15 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
case SC_BLADESTOP:
if(sce->val4) {
int tid = sce->val4;
struct block_list *tbl = map_id2bl(tid);
int tid2 = sce->val4; //stop the status for the other guy of bladestop as well
struct block_list *tbl = map_id2bl(tid2);
struct status_change *tsc = status_get_sc(tbl);
sce->val4 = 0;
if(tbl && tsc && tsc->data[SC_BLADESTOP]) {
tsc->data[SC_BLADESTOP]->val4 = 0;
status_change_end(tbl, SC_BLADESTOP, INVALID_TIMER);
}
clif_bladestop(bl, tid, 0);
clif_bladestop(bl, tid2, 0);
}
break;
case SC_DANCING:
@ -10844,8 +10844,8 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
case SC_CURSEDCIRCLE_TARGET:
{
struct block_list *src = map_id2bl(sce->val2);
struct status_change *sc = status_get_sc(src);
if( sc && sc->data[SC_CURSEDCIRCLE_ATKER] && --(sc->data[SC_CURSEDCIRCLE_ATKER]->val2) == 0 ) {
struct status_change *sc2 = status_get_sc(src);
if( sc2 && sc2->data[SC_CURSEDCIRCLE_ATKER] && --(sc2->data[SC_CURSEDCIRCLE_ATKER]->val2) == 0 ) {
status_change_end(src, SC_CURSEDCIRCLE_ATKER, INVALID_TIMER);
clif_bladestop(bl, sce->val2, 0);
}
@ -10855,8 +10855,8 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
if( sce->val2 ) {
struct block_list *src = map_id2bl(sce->val2);
if(src) {
struct status_change *sc = status_get_sc(src);
sc->bs_counter--;
struct status_change *sc2 = status_get_sc(src);
sc2->bs_counter--;
}
}
break;
@ -11701,8 +11701,8 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
case SC_ELECTRICSHOCKER:
if( --(sce->val4) >= 0 ) {
if (!status_charge(bl, 0, 5 * sce->val1 * status->max_sp / 100))
; // Keep immobilize status even the SP is already running out.
status_charge(bl, 0, 5 * sce->val1 * status->max_sp / 100);
// Keep immobilize status even the SP is already running out.
sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
return 0;
}

View File

@ -832,14 +832,14 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool
if( sd->status.pet_id > 0 && sd->pd && sd->pd->pet.intimate > 0 ){
// Check if pet needs to be teleported. [Skotlex]
int flag = 0;
struct block_list* bl = &sd->pd->bl;
if( !checkpath && !path_search(NULL,bl->m,bl->x,bl->y,dst_x,dst_y,0,CELL_CHKNOPASS) )
struct block_list* pbl = &sd->pd->bl;
if( !checkpath && !path_search(NULL,pbl->m,pbl->x,pbl->y,dst_x,dst_y,0,CELL_CHKNOPASS) )
flag = 1;
else if (!check_distance_bl(&sd->bl, bl, AREA_SIZE)) // Too far, teleport.
else if (!check_distance_bl(&sd->bl, pbl, AREA_SIZE)) // Too far, teleport.
flag = 2;
if( flag ) {
unit_movepos(bl,sd->bl.x,sd->bl.y, 0, 0);
clif_slide(bl,bl->x,bl->y);
unit_movepos(pbl,sd->bl.x,sd->bl.y, 0, 0);
clif_slide(pbl,pbl->x,pbl->y);
}
}
}
@ -2636,10 +2636,10 @@ int unit_free(struct block_list *bl, clr_type clrtype)
sd->reg_num = 0;
}
if( sd->regstr ) {
int i;
for( i = 0; i < sd->regstr_num; ++i )
if( sd->regstr[i].data )
aFree(sd->regstr[i].data);
int j;
for( j = 0; j < sd->regstr_num; ++j )
if( sd->regstr[j].data )
aFree(sd->regstr[j].data);
aFree(sd->regstr);
sd->regstr = NULL;
sd->regstr_num = 0;

View File

@ -14,6 +14,7 @@
#include "../common/malloc.h"
#include "../common/mmo.h"
#include "../common/showmsg.h"
#include "../common/utils.h"
#include "../config/renewal.h"