Some CPPCheck clean ups
Signed-off-by: Cydh Ramdh <house.bad@gmail.com>
This commit is contained in:
@@ -352,7 +352,6 @@ int chlogif_parse_ackchangesex(int fd, struct char_session_data* sd){
|
||||
return 0;
|
||||
{
|
||||
unsigned char buf[7];
|
||||
int i;
|
||||
|
||||
int acc = RFIFOL(fd,2);
|
||||
int sex = RFIFOB(fd,6);
|
||||
@@ -363,7 +362,7 @@ int chlogif_parse_ackchangesex(int fd, struct char_session_data* sd){
|
||||
int char_id[MAX_CHARS];
|
||||
int class_[MAX_CHARS];
|
||||
int guild_id[MAX_CHARS];
|
||||
int num;
|
||||
unsigned char num, i;
|
||||
char* data;
|
||||
DBMap* auth_db = char_get_authdb();
|
||||
|
||||
|
||||
106
src/char/inter.c
106
src/char/inter.c
@@ -330,10 +330,10 @@ void geoip_readdb(void){
|
||||
const char* geoip_getcountry(uint32 ipnum){
|
||||
int depth;
|
||||
unsigned int x;
|
||||
const unsigned char *buf;
|
||||
unsigned int offset = 0;
|
||||
|
||||
for (depth = 31; depth >= 0; depth--) {
|
||||
const unsigned char *buf;
|
||||
buf = geoip_cache + (long)6 *offset;
|
||||
if (ipnum & (1 << depth)) {
|
||||
/* Take the right-hand branch */
|
||||
@@ -512,7 +512,6 @@ void mapif_parse_accinfo(int fd) {
|
||||
// Save registry to sql
|
||||
int inter_accreg_tosql(int account_id, int char_id, struct accreg* reg, int type)
|
||||
{
|
||||
struct global_reg* r;
|
||||
StringBuf buf;
|
||||
int i;
|
||||
|
||||
@@ -522,24 +521,23 @@ int inter_accreg_tosql(int account_id, int char_id, struct accreg* reg, int type
|
||||
reg->char_id = char_id;
|
||||
|
||||
//`global_reg_value` (`type`, `account_id`, `char_id`, `str`, `value`)
|
||||
switch( type )
|
||||
{
|
||||
case 3: //Char Reg
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`=3 AND `char_id`='%d'", schema_config.reg_db, char_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
account_id = 0;
|
||||
break;
|
||||
case 2: //Account Reg
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`=2 AND `account_id`='%d'", schema_config.reg_db, account_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
char_id = 0;
|
||||
break;
|
||||
case 1: //Account2 Reg
|
||||
ShowError("inter_accreg_tosql: Char server shouldn't handle type 1 registry values (##). That is the login server's work!\n");
|
||||
return 0;
|
||||
default:
|
||||
ShowError("inter_accreg_tosql: Invalid type %d\n", type);
|
||||
return 0;
|
||||
switch( type ) {
|
||||
case 3: //Char Reg
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`=3 AND `char_id`='%d'", schema_config.reg_db, char_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
account_id = 0;
|
||||
break;
|
||||
case 2: //Account Reg
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`=2 AND `account_id`='%d'", schema_config.reg_db, account_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
char_id = 0;
|
||||
break;
|
||||
case 1: //Account2 Reg
|
||||
ShowError("inter_accreg_tosql: Char server shouldn't handle type 1 registry values (##). That is the login server's work!\n");
|
||||
return 0;
|
||||
default:
|
||||
ShowError("inter_accreg_tosql: Invalid type %d\n", type);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( reg->reg_num <= 0 )
|
||||
@@ -549,7 +547,7 @@ int inter_accreg_tosql(int account_id, int char_id, struct accreg* reg, int type
|
||||
StringBuf_Printf(&buf, "INSERT INTO `%s` (`type`,`account_id`,`char_id`,`str`,`value`) VALUES ", schema_config.reg_db);
|
||||
|
||||
for( i = 0; i < reg->reg_num; ++i ) {
|
||||
r = ®->reg[i];
|
||||
struct global_reg* r = ®->reg[i];
|
||||
if( r->str[0] != '\0' && r->value[0] != '\0' ) {
|
||||
char str[32];
|
||||
char val[256];
|
||||
@@ -576,7 +574,6 @@ int inter_accreg_tosql(int account_id, int char_id, struct accreg* reg, int type
|
||||
// Load account_reg from sql (type=2)
|
||||
int inter_accreg_fromsql(int account_id,int char_id, struct accreg *reg, int type)
|
||||
{
|
||||
struct global_reg* r;
|
||||
char* data;
|
||||
size_t len;
|
||||
int i;
|
||||
@@ -589,26 +586,24 @@ int inter_accreg_fromsql(int account_id,int char_id, struct accreg *reg, int typ
|
||||
reg->char_id = char_id;
|
||||
|
||||
//`global_reg_value` (`type`, `account_id`, `char_id`, `str`, `value`)
|
||||
switch( type )
|
||||
{
|
||||
case 3: //char reg
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `str`, `value` FROM `%s` WHERE `type`=3 AND `char_id`='%d'", schema_config.reg_db, char_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
case 2: //account reg
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `str`, `value` FROM `%s` WHERE `type`=2 AND `account_id`='%d'", schema_config.reg_db, account_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
case 1: //account2 reg
|
||||
ShowError("inter_accreg_fromsql: Char server shouldn't handle type 1 registry values (##). That is the login server's work!\n");
|
||||
return 0;
|
||||
default:
|
||||
ShowError("inter_accreg_fromsql: Invalid type %d\n", type);
|
||||
return 0;
|
||||
switch( type ) {
|
||||
case 3: //char reg
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `str`, `value` FROM `%s` WHERE `type`=3 AND `char_id`='%d'", schema_config.reg_db, char_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
case 2: //account reg
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `str`, `value` FROM `%s` WHERE `type`=2 AND `account_id`='%d'", schema_config.reg_db, account_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
case 1: //account2 reg
|
||||
ShowError("inter_accreg_fromsql: Char server shouldn't handle type 1 registry values (##). That is the login server's work!\n");
|
||||
return 0;
|
||||
default:
|
||||
ShowError("inter_accreg_fromsql: Invalid type %d\n", type);
|
||||
return 0;
|
||||
}
|
||||
for( i = 0; i < MAX_REG_NUM && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i )
|
||||
{
|
||||
r = ®->reg[i];
|
||||
for( i = 0; i < MAX_REG_NUM && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i ) {
|
||||
struct global_reg* r = ®->reg[i];
|
||||
// str
|
||||
Sql_GetData(sql_handle, 0, &data, &len);
|
||||
memcpy(r->str, data, min(len, sizeof(r->str)));
|
||||
@@ -634,8 +629,7 @@ int inter_accreg_sql_init(void)
|
||||
*------------------------------------------*/
|
||||
static int inter_config_read(const char* cfgName)
|
||||
{
|
||||
int i;
|
||||
char line[1024], w1[1024], w2[1024];
|
||||
char line[1024];
|
||||
FILE* fp;
|
||||
|
||||
fp = fopen(cfgName, "r");
|
||||
@@ -644,30 +638,24 @@ static int inter_config_read(const char* cfgName)
|
||||
return 1;
|
||||
}
|
||||
|
||||
while(fgets(line, sizeof(line), fp))
|
||||
{
|
||||
i = sscanf(line, "%[^:]: %[^\r\n]", w1, w2);
|
||||
if(i != 2)
|
||||
while(fgets(line, sizeof(line), fp)) {
|
||||
char w1[24], w2[1024];
|
||||
|
||||
if (sscanf(line, "%23[^:]: %1023[^\r\n]", w1, w2) != 2);
|
||||
continue;
|
||||
|
||||
if(!strcmpi(w1,"char_server_ip")) {
|
||||
if(!strcmpi(w1,"char_server_ip"))
|
||||
strcpy(char_server_ip,w2);
|
||||
} else
|
||||
if(!strcmpi(w1,"char_server_port")) {
|
||||
else if(!strcmpi(w1,"char_server_port"))
|
||||
char_server_port = atoi(w2);
|
||||
} else
|
||||
if(!strcmpi(w1,"char_server_id")) {
|
||||
else if(!strcmpi(w1,"char_server_id"))
|
||||
strcpy(char_server_id,w2);
|
||||
} else
|
||||
if(!strcmpi(w1,"char_server_pw")) {
|
||||
else if(!strcmpi(w1,"char_server_pw"))
|
||||
strcpy(char_server_pw,w2);
|
||||
} else
|
||||
if(!strcmpi(w1,"char_server_db")) {
|
||||
else if(!strcmpi(w1,"char_server_db"))
|
||||
strcpy(char_server_db,w2);
|
||||
} else
|
||||
if(!strcmpi(w1,"default_codepage")) {
|
||||
else if(!strcmpi(w1,"default_codepage"))
|
||||
strcpy(default_codepage,w2);
|
||||
}
|
||||
else if(!strcmpi(w1,"party_share_level"))
|
||||
party_share_level = (unsigned int)atof(w2);
|
||||
else if(!strcmpi(w1,"log_inter"))
|
||||
|
||||
@@ -991,7 +991,6 @@ bool sv_readdb(const char* directory, const char* filename, char delim, int minc
|
||||
char** fields; // buffer for fields ([0] is reserved)
|
||||
int columns, nb_cols;
|
||||
char path[1024], *line;
|
||||
char* match;
|
||||
const short colsize=512;
|
||||
|
||||
snprintf(path, sizeof(path), "%s/%s", directory, filename);
|
||||
@@ -1012,6 +1011,7 @@ bool sv_readdb(const char* directory, const char* filename, char delim, int minc
|
||||
// process rows one by one
|
||||
while( fgets(line, maxcols*colsize, fp) )
|
||||
{
|
||||
char *match;
|
||||
lines++;
|
||||
|
||||
if( ( match = strstr(line, "//") ) != NULL )
|
||||
@@ -1099,10 +1099,9 @@ int StringBuf_Printf(StringBuf* self, const char* fmt, ...)
|
||||
/// Appends the result of vprintf to the StringBuf
|
||||
int StringBuf_Vprintf(StringBuf* self, const char* fmt, va_list ap)
|
||||
{
|
||||
int n, size, off;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
int n, size, off;
|
||||
va_list apcopy;
|
||||
/* Try to print in the allocated space. */
|
||||
size = self->max_ - (self->ptr_ - self->buf_);
|
||||
|
||||
@@ -485,7 +485,6 @@ int logchrif_parse_reqchgsex(int fd, int id, char* ip){
|
||||
* @return 0 not enough info transmitted, 1 success
|
||||
*/
|
||||
int logchrif_parse_updreg2(int fd, int id, char* ip){
|
||||
int j;
|
||||
if( RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2) )
|
||||
return 0;
|
||||
else{
|
||||
@@ -498,6 +497,7 @@ int logchrif_parse_updreg2(int fd, int id, char* ip){
|
||||
else{
|
||||
int len;
|
||||
int p;
|
||||
char j;
|
||||
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);
|
||||
@@ -614,7 +614,6 @@ int logchrif_parse_updonlinedb(int fd, int id){
|
||||
* @return 0 not enough info transmitted, 1 success
|
||||
*/
|
||||
int logchrif_parse_reqacc2reg(int fd){
|
||||
int j;
|
||||
if (RFIFOREST(fd) < 10)
|
||||
return 0;
|
||||
else{
|
||||
@@ -634,6 +633,7 @@ int logchrif_parse_reqacc2reg(int fd){
|
||||
|
||||
off = 13;
|
||||
if( accounts->load_num(accounts, &acc, account_id) ){
|
||||
char j;
|
||||
for( j = 0; j < acc.account_reg2_num; j++ ){
|
||||
if( acc.account_reg2[j].str[0] != '\0' ){
|
||||
off += sprintf((char*)WFIFOP(fd,off), "%s", acc.account_reg2[j].str)+1; //We add 1 to consider the '\0' in place.
|
||||
|
||||
@@ -308,7 +308,7 @@ static int logclif_parse_reqauth(int fd, struct login_session_data *sd, int comm
|
||||
|
||||
version = RFIFOL(fd,4);
|
||||
|
||||
if(uAccLen > NAME_LENGTH - 1 || uAccLen <= 0 || uTokenLen > NAME_LENGTH - 1 || uTokenLen <= 0)
|
||||
if(uAccLen > NAME_LENGTH - 1 || uAccLen == 0 || uTokenLen > NAME_LENGTH - 1 || uTokenLen == 0)
|
||||
{
|
||||
logclif_auth_failed(sd, 3);
|
||||
return 0;
|
||||
|
||||
@@ -630,8 +630,8 @@ void buyingstore_reopen( struct map_session_data* sd ){
|
||||
pc_cleareventtimer(sd);
|
||||
|
||||
// Open the buyingstore again
|
||||
if( (fail = buyingstore_setup( sd, (unsigned char)autotraders[i]->count ) == 0) &&
|
||||
(fail = buyingstore_create( sd, autotraders[i]->limit, 1, autotraders[i]->title, data, autotraders[i]->count ) == 0) )
|
||||
if( (fail = buyingstore_setup( sd, (unsigned char)autotraders[i]->count )) == 0 &&
|
||||
(fail = buyingstore_create( sd, autotraders[i]->limit, 1, autotraders[i]->title, data, autotraders[i]->count )) == 0 )
|
||||
{
|
||||
ShowInfo("Loaded buyingstore for '"CL_WHITE"%s"CL_RESET"' with '"CL_WHITE"%d"CL_RESET"' items at "CL_WHITE"%s (%d,%d)"CL_RESET"\n",
|
||||
sd->status.name, count, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
|
||||
|
||||
@@ -3323,7 +3323,7 @@ void clif_arrow_fail(struct map_session_data *sd,int type)
|
||||
/// 01ad <packet len>.W { <name id>.W }*
|
||||
void clif_arrow_create_list(struct map_session_data *sd)
|
||||
{
|
||||
int i, c, j;
|
||||
int i, c;
|
||||
int fd;
|
||||
|
||||
nullpo_retv(sd);
|
||||
@@ -3333,6 +3333,7 @@ void clif_arrow_create_list(struct map_session_data *sd)
|
||||
WFIFOW(fd,0) = 0x1ad;
|
||||
|
||||
for (i = 0, c = 0; i < MAX_SKILL_ARROW_DB; i++) {
|
||||
short j;
|
||||
if (skill_arrow_db[i].nameid > 0 &&
|
||||
(j = pc_search_inventory(sd, skill_arrow_db[i].nameid)) >= 0 &&
|
||||
!sd->status.inventory[j].equip && sd->status.inventory[j].identify)
|
||||
@@ -6043,7 +6044,6 @@ void clif_item_repair_list(struct map_session_data *sd,struct map_session_data *
|
||||
{
|
||||
int i,c;
|
||||
int fd;
|
||||
unsigned short nameid;
|
||||
|
||||
nullpo_retv(sd);
|
||||
nullpo_retv(dstsd);
|
||||
@@ -6053,6 +6053,7 @@ void clif_item_repair_list(struct map_session_data *sd,struct map_session_data *
|
||||
WFIFOHEAD(fd, MAX_INVENTORY * 13 + 4);
|
||||
WFIFOW(fd,0)=0x1fc;
|
||||
for(i=c=0;i<MAX_INVENTORY;i++){
|
||||
unsigned short nameid;
|
||||
if((nameid=dstsd->status.inventory[i].nameid) > 0 && dstsd->status.inventory[i].attribute!=0){// && skill_can_repair(sd,nameid)){
|
||||
WFIFOW(fd,c*13+4) = i;
|
||||
WFIFOW(fd,c*13+6) = nameid;
|
||||
@@ -6117,7 +6118,6 @@ void clif_item_refine_list(struct map_session_data *sd)
|
||||
int i,c;
|
||||
int fd;
|
||||
uint16 skill_lv;
|
||||
int wlv;
|
||||
int refine_item[5];
|
||||
|
||||
nullpo_retv(sd);
|
||||
@@ -6134,6 +6134,7 @@ void clif_item_refine_list(struct map_session_data *sd)
|
||||
WFIFOHEAD(fd, MAX_INVENTORY * 13 + 4);
|
||||
WFIFOW(fd,0)=0x221;
|
||||
for(i=c=0;i<MAX_INVENTORY;i++){
|
||||
unsigned char wlv;
|
||||
if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].refine < skill_lv &&
|
||||
sd->status.inventory[i].identify && (wlv=itemdb_wlv(sd->status.inventory[i].nameid)) >=1 &&
|
||||
refine_item[wlv]!=-1 && !(sd->status.inventory[i].equip&EQP_ARMS)){
|
||||
@@ -12611,9 +12612,9 @@ static bool clif_validate_emblem(const uint8* emblem, unsigned long emblem_len)
|
||||
return -1;
|
||||
|
||||
if(battle_config.emblem_transparency_limit != 100) {
|
||||
int i, j, transcount = 1, tmp[3];
|
||||
int i, transcount = 1, tmp[3];
|
||||
for(i = offset; i < buf_len-1; i++) {
|
||||
j = i%3;
|
||||
int j = i%3;
|
||||
tmp[j] = RBUFL(buf,i);
|
||||
if(j == 2 && (tmp[0] == 0xFFFF00FF) && (tmp[1] == 0xFFFF00) && (tmp[2] == 0xFF00FFFF)) //if pixel is transparent
|
||||
transcount++;
|
||||
@@ -14620,7 +14621,6 @@ void clif_Auction_results(struct map_session_data *sd, short count, short pages,
|
||||
int i, fd = sd->fd, len = sizeof(struct auction_data);
|
||||
struct auction_data auction;
|
||||
struct item_data *item;
|
||||
int k;
|
||||
|
||||
WFIFOHEAD(fd,12 + (count * 83));
|
||||
WFIFOW(fd,0) = 0x252;
|
||||
@@ -14629,8 +14629,8 @@ void clif_Auction_results(struct map_session_data *sd, short count, short pages,
|
||||
WFIFOL(fd,8) = count;
|
||||
|
||||
for( i = 0; i < count; i++ ) {
|
||||
int k = 12 + (i * 83);
|
||||
memcpy(&auction, RBUFP(buf,i * len), len);
|
||||
k = 12 + (i * 83);
|
||||
|
||||
WFIFOL(fd,k) = auction.auction_id;
|
||||
safestrncpy((char*)WFIFOP(fd,4+k), auction.seller_name, NAME_LENGTH);
|
||||
@@ -15364,7 +15364,6 @@ void clif_quest_add(struct map_session_data * sd, struct quest * qd)
|
||||
{
|
||||
int fd = sd->fd;
|
||||
int i;
|
||||
struct mob_db *mob;
|
||||
struct quest_db *qi = quest_db(qd->quest_id);
|
||||
|
||||
WFIFOHEAD(fd, packet_len(0x2b3));
|
||||
@@ -15376,6 +15375,7 @@ void clif_quest_add(struct map_session_data * sd, struct quest * qd)
|
||||
WFIFOW(fd, 15) = qi->num_objectives;
|
||||
|
||||
for( i = 0; i < qi->num_objectives; i++ ) {
|
||||
struct mob_db *mob;
|
||||
WFIFOL(fd, i*30+17) = qi->mob[i];
|
||||
WFIFOW(fd, i*30+21) = qd->count[i];
|
||||
mob = mob_db(qi->mob[i]);
|
||||
@@ -17046,16 +17046,14 @@ void clif_parse_client_version(int fd, struct map_session_data *sd) {
|
||||
|
||||
/// ranking pointlist { <name>.24B <point>.L }*10
|
||||
void clif_sub_ranklist(unsigned char *buf,int idx,struct map_session_data* sd, int16 rankingtype){
|
||||
const char* name;
|
||||
struct fame_list* list;
|
||||
int skip = 0;
|
||||
|
||||
switch(rankingtype+1) //to keep the same case as char.c
|
||||
{
|
||||
case 1: list = smith_fame_list; break;
|
||||
case 2: list = chemist_fame_list; break;
|
||||
case 3: list = taekwon_fame_list; break;
|
||||
default: skip=1; break;
|
||||
switch(rankingtype+1) { //to keep the same case as char.c
|
||||
case 1: list = smith_fame_list; break;
|
||||
case 2: list = chemist_fame_list; break;
|
||||
case 3: list = taekwon_fame_list; break;
|
||||
default: skip=1; break;
|
||||
}
|
||||
|
||||
if(!skip) {
|
||||
@@ -17064,6 +17062,7 @@ void clif_sub_ranklist(unsigned char *buf,int idx,struct map_session_data* sd, i
|
||||
//Packet size limits this list to 10 elements. [Skotlex]
|
||||
for (i = 0; i < min(10,MAX_FAME_LIST); i++) {
|
||||
if (list[i].id > 0) {
|
||||
const char* name;
|
||||
if (strcmp(list[i].name, "-") == 0 &&
|
||||
(name = map_charid2nick(list[i].id)) != NULL)
|
||||
{
|
||||
@@ -17512,7 +17511,6 @@ void packetdb_readdb(void)
|
||||
{
|
||||
FILE *fp;
|
||||
char line[1024];
|
||||
int ln=0;
|
||||
int cmd,i,j;
|
||||
int max_cmd=-1;
|
||||
bool skip_ver = false;
|
||||
@@ -18009,6 +18007,7 @@ void packetdb_readdb(void)
|
||||
|
||||
clif_config.packet_db_ver = MAX_PACKET_VER;
|
||||
for(f = 0; f<ARRAYLENGTH(filename); f++){
|
||||
int ln=0;
|
||||
int entries = 0;
|
||||
int packet_ver = MAX_PACKET_VER; // read into packet_db's version by default
|
||||
|
||||
@@ -18021,8 +18020,7 @@ void packetdb_readdb(void)
|
||||
return;
|
||||
}
|
||||
|
||||
while( fgets(line, sizeof(line), fp) )
|
||||
{
|
||||
while( fgets(line, sizeof(line), fp) ) {
|
||||
ln++;
|
||||
if(line[0]=='/' && line[1]=='/')
|
||||
continue;
|
||||
@@ -18078,8 +18076,7 @@ void packetdb_readdb(void)
|
||||
continue; // Skipping current packet version
|
||||
|
||||
memset(str,0,sizeof(str));
|
||||
for(j=0,p=line;j<4 && p; ++j)
|
||||
{
|
||||
for(j=0,p=line;j<4 && p; ++j) {
|
||||
str[j]=p;
|
||||
p=strchr(p,',');
|
||||
if(p) *p++=0;
|
||||
@@ -18145,13 +18142,12 @@ void packetdb_readdb(void)
|
||||
entries++;
|
||||
}
|
||||
fclose(fp);
|
||||
if(max_cmd > MAX_PACKET_DB)
|
||||
{
|
||||
if(max_cmd > MAX_PACKET_DB) {
|
||||
ShowWarning("Found packets up to 0x%X, ignored 0x%X and above.\n", max_cmd, MAX_PACKET_DB);
|
||||
ShowWarning("Please increase MAX_PACKET_DB and recompile.\n");
|
||||
}
|
||||
if (!clif_config.connect_cmd[clif_config.packet_db_ver])
|
||||
{ //Locate the nearest version that we still support. [Skotlex]
|
||||
//Locate the nearest version that we still support. [Skotlex]
|
||||
if (!clif_config.connect_cmd[clif_config.packet_db_ver]) {
|
||||
for(j = clif_config.packet_db_ver; j >= 0 && !clif_config.connect_cmd[j]; j--);
|
||||
|
||||
clif_config.packet_db_ver = j?j:MAX_PACKET_VER;
|
||||
|
||||
@@ -584,9 +584,9 @@ static void itemdb_read_itemgroup_sub(const char* filename, bool silent)
|
||||
if (line[0] == '/' && line[1] == '/')
|
||||
continue;
|
||||
if (strstr(line,"import")) {
|
||||
char w1[1024], w2[1024];
|
||||
char w1[16], w2[64];
|
||||
|
||||
if (sscanf(line,"%[^:]: %[^\r\n]",w1,w2) == 2 &&
|
||||
if (sscanf(line,"%15[^:]: %63[^\r\n]",w1,w2) == 2 &&
|
||||
strcmpi(w1,"import") == 0)
|
||||
{
|
||||
itemdb_read_itemgroup_sub(w2, 0);
|
||||
|
||||
@@ -70,7 +70,7 @@ bool mail_setitem(struct map_session_data *sd, short idx, unsigned short amount)
|
||||
return false;
|
||||
|
||||
if( idx == 0 ) { // Zeny Transfer
|
||||
if( amount < 0 || !pc_can_give_items(sd) )
|
||||
if( !pc_can_give_items(sd) )
|
||||
return false;
|
||||
|
||||
if( amount > sd->status.zeny )
|
||||
@@ -85,7 +85,7 @@ bool mail_setitem(struct map_session_data *sd, short idx, unsigned short amount)
|
||||
|
||||
if( idx < 0 || idx >= MAX_INVENTORY )
|
||||
return false;
|
||||
if( amount < 0 || amount > sd->status.inventory[idx].amount )
|
||||
if( amount > sd->status.inventory[idx].amount )
|
||||
return false;
|
||||
if( !pc_can_give_items(sd) || sd->status.inventory[idx].expire_time
|
||||
|| !itemdb_available(sd->status.inventory[idx].nameid)
|
||||
|
||||
@@ -2020,11 +2020,9 @@ int npc_unload(struct npc_data* nd, bool single) {
|
||||
static void npc_clearsrcfile(void)
|
||||
{
|
||||
struct npc_src_list* file = npc_src_files;
|
||||
struct npc_src_list* file_tofree;
|
||||
|
||||
while( file != NULL )
|
||||
{
|
||||
file_tofree = file;
|
||||
while( file != NULL ) {
|
||||
struct npc_src_list* file_tofree = file;
|
||||
file = file->next;
|
||||
aFree(file_tofree);
|
||||
}
|
||||
@@ -3553,7 +3551,7 @@ static const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, con
|
||||
else if (!strcmpi(w3, "pvp_nightmaredrop")) {
|
||||
char drop_arg1[16], drop_arg2[16];
|
||||
int drop_per = 0;
|
||||
if (sscanf(w4, "%[^,],%[^,],%d", drop_arg1, drop_arg2, &drop_per) == 3) {
|
||||
if (sscanf(w4, "%15[^,],%15[^,],%d", drop_arg1, drop_arg2, &drop_per) == 3) {
|
||||
int drop_id = 0, drop_type = 0;
|
||||
if (!strcmpi(drop_arg1, "random"))
|
||||
drop_id = -1;
|
||||
|
||||
@@ -1003,10 +1003,11 @@ static int pet_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap)
|
||||
static int pet_delay_item_drop(int tid, unsigned int tick, int id, intptr_t data)
|
||||
{
|
||||
struct item_drop_list *list;
|
||||
struct item_drop *ditem, *ditem_prev;
|
||||
struct item_drop *ditem;
|
||||
list=(struct item_drop_list *)data;
|
||||
ditem = list->item;
|
||||
while (ditem) {
|
||||
struct item_drop *ditem_prev;
|
||||
map_addflooritem(&ditem->item_data,ditem->item_data.amount,
|
||||
list->m,list->x,list->y,
|
||||
list->first_charid,list->second_charid,list->third_charid,4);
|
||||
@@ -1229,9 +1230,8 @@ int pet_skill_support_timer(int tid, unsigned int tick, int id, intptr_t data)
|
||||
*------------------------------------------*/
|
||||
void read_petdb(){
|
||||
char* filename[] = {"pet_db.txt",DBIMPORT"/pet_db.txt"};
|
||||
FILE *fp;
|
||||
unsigned short nameid;
|
||||
int i,j,k;
|
||||
int i,j;
|
||||
|
||||
// Remove any previous scripts in case reloaddb was invoked.
|
||||
for( j = 0; j < MAX_PET_DB; j++ )
|
||||
@@ -1256,9 +1256,10 @@ void read_petdb(){
|
||||
{
|
||||
char line[1024];
|
||||
int lines, entries;
|
||||
FILE *fp;
|
||||
|
||||
sprintf(line, "%s/%s", db_path, filename[i]);
|
||||
fp=fopen(line,"r");
|
||||
fp = fopen(line,"r");
|
||||
if( fp == NULL ) {
|
||||
if( i == 0 ) ShowError("can't read %s\n",line);
|
||||
continue;
|
||||
@@ -1268,6 +1269,7 @@ void read_petdb(){
|
||||
while( fgets(line, sizeof(line), fp) && j < MAX_PET_DB )
|
||||
{
|
||||
char *str[22], *p;
|
||||
unsigned k;
|
||||
lines++;
|
||||
|
||||
if(line[0] == '/' && line[1] == '/')
|
||||
|
||||
174
src/map/script.c
174
src/map/script.c
@@ -3700,10 +3700,9 @@ void run_script(struct script_code *rootscript,int pos,int rid,int oid)
|
||||
|
||||
void script_stop_sleeptimers(int id)
|
||||
{
|
||||
struct script_state* st;
|
||||
for(;;)
|
||||
{
|
||||
st = (struct script_state*)linkdb_erase(&sleep_db,(void*)__64BPRTSIZE(id));
|
||||
struct script_state* st = (struct script_state*)linkdb_erase(&sleep_db,(void*)__64BPRTSIZE(id));
|
||||
if( st == NULL )
|
||||
break; // no more sleep timers
|
||||
script_free_state(st);
|
||||
@@ -4662,7 +4661,6 @@ BUILDIN_FUNC(menu)
|
||||
if( sd->state.menu_or_input == 0 )
|
||||
{
|
||||
struct StringBuf buf;
|
||||
struct script_data* data;
|
||||
|
||||
if( script_lastdata(st) % 2 == 0 )
|
||||
{// argument count is not even (1st argument is at index 2)
|
||||
@@ -4675,6 +4673,7 @@ BUILDIN_FUNC(menu)
|
||||
sd->npc_menu = 0;
|
||||
for( i = 2; i < script_lastdata(st); i += 2 )
|
||||
{
|
||||
struct script_data* data;
|
||||
// menu options
|
||||
text = script_getstr(st, i);
|
||||
|
||||
@@ -5128,12 +5127,11 @@ BUILDIN_FUNC(rand)
|
||||
{
|
||||
int range;
|
||||
int min;
|
||||
int max;
|
||||
|
||||
if( script_hasdata(st,3) )
|
||||
{// min,max
|
||||
int max = script_getnum(st,3);
|
||||
min = script_getnum(st,2);
|
||||
max = script_getnum(st,3);
|
||||
if( max < min )
|
||||
swap(min, max);
|
||||
range = max - min + 1;
|
||||
@@ -6360,7 +6358,6 @@ int checkweight_sub(TBL_PC *sd, int nbargs, unsigned short *eitemid, int32 *eamo
|
||||
BUILDIN_FUNC(checkweight)
|
||||
{
|
||||
struct map_session_data* sd;
|
||||
struct script_data* data;
|
||||
struct item_data* id = NULL;
|
||||
unsigned short nameid[SCRIPT_MAX_ARRAYSIZE];
|
||||
int32 amount[SCRIPT_MAX_ARRAYSIZE];
|
||||
@@ -6377,7 +6374,7 @@ BUILDIN_FUNC(checkweight)
|
||||
}
|
||||
|
||||
for(i=2; i<nbargs; i=i+2) {
|
||||
data = script_getdata(st,i);
|
||||
struct script_data* data = script_getdata(st,i);
|
||||
get_val(st, data); // Convert into value in case of a variable
|
||||
if( data_isstring(data) ) // item name
|
||||
id = itemdb_searchname(conv_str(st, data));
|
||||
@@ -6568,14 +6565,13 @@ BUILDIN_FUNC(getitem)
|
||||
*------------------------------------------*/
|
||||
BUILDIN_FUNC(getitem2)
|
||||
{
|
||||
int amount, get_count, i;
|
||||
int amount;
|
||||
unsigned short nameid;
|
||||
int iden, ref, attr;
|
||||
unsigned short c1, c2, c3, c4;
|
||||
char bound = BOUND_NONE;
|
||||
struct item_data *item_data = NULL;
|
||||
struct item item_tmp;
|
||||
unsigned char flag = 0;
|
||||
TBL_PC *sd;
|
||||
struct script_data *data;
|
||||
const char* command = script_getfuncname(st);
|
||||
@@ -6625,6 +6621,7 @@ BUILDIN_FUNC(getitem2)
|
||||
c4 = (unsigned short)script_getnum(st,10);
|
||||
|
||||
if( item_data ) {
|
||||
int get_count = 0, i;
|
||||
memset(&item_tmp,0,sizeof(item_tmp));
|
||||
if( item_data->type == IT_WEAPON || item_data->type == IT_ARMOR || item_data->type == IT_SHADOWGEAR ) {
|
||||
if(ref > MAX_REFINE)
|
||||
@@ -6660,6 +6657,7 @@ BUILDIN_FUNC(getitem2)
|
||||
// if not pet egg
|
||||
if (!pet_create_egg(sd, nameid))
|
||||
{
|
||||
unsigned char flag = 0;
|
||||
if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_SCRIPT)))
|
||||
{
|
||||
clif_additem(sd, 0, 0, flag);
|
||||
@@ -7079,7 +7077,7 @@ static void buildin_delitem_delete(struct map_session_data* sd, int idx, int* am
|
||||
static bool buildin_delitem_search(struct map_session_data* sd, struct item* it, bool exact_match, uint8 loc)
|
||||
{
|
||||
bool delete_items = false;
|
||||
int i, amount, important, size;
|
||||
int i, amount, size;
|
||||
struct item *items;
|
||||
|
||||
// prefer always non-equipped items
|
||||
@@ -7111,8 +7109,8 @@ static bool buildin_delitem_search(struct map_session_data* sd, struct item* it,
|
||||
|
||||
for(;;)
|
||||
{
|
||||
unsigned short important = 0;
|
||||
amount = it->amount;
|
||||
important = 0;
|
||||
|
||||
// 1st pass -- less important items / exact match
|
||||
for( i = 0; amount && i < size; i++ )
|
||||
@@ -7532,25 +7530,29 @@ BUILDIN_FUNC(getpartyname)
|
||||
BUILDIN_FUNC(getpartymember)
|
||||
{
|
||||
struct party_data *p;
|
||||
int i,j=0,type=0;
|
||||
int type = 0;
|
||||
unsigned char j = 0;
|
||||
|
||||
p=party_search(script_getnum(st,2));
|
||||
p = party_search(script_getnum(st,2));
|
||||
|
||||
if( script_hasdata(st,3) )
|
||||
type=script_getnum(st,3);
|
||||
if (p != NULL){
|
||||
unsigned char i;
|
||||
|
||||
if(p!=NULL){
|
||||
for(i=0;i<MAX_PARTY;i++){
|
||||
if(p->party.member[i].account_id){
|
||||
if (script_hasdata(st,3))
|
||||
type = script_getnum(st,3);
|
||||
|
||||
for (i = 0;i<MAX_PARTY;i++) {
|
||||
if (p->party.member[i].account_id) {
|
||||
switch (type) {
|
||||
case 2:
|
||||
mapreg_setreg(reference_uid(add_str("$@partymemberaid"), j),p->party.member[i].account_id);
|
||||
break;
|
||||
case 1:
|
||||
mapreg_setreg(reference_uid(add_str("$@partymembercid"), j),p->party.member[i].char_id);
|
||||
break;
|
||||
default:
|
||||
mapreg_setregstr(reference_uid(add_str("$@partymembername$"), j),p->party.member[i].name);
|
||||
case 2:
|
||||
mapreg_setreg(reference_uid(add_str("$@partymemberaid"), j),p->party.member[i].account_id);
|
||||
break;
|
||||
case 1:
|
||||
mapreg_setreg(reference_uid(add_str("$@partymembercid"), j),p->party.member[i].char_id);
|
||||
break;
|
||||
default:
|
||||
mapreg_setregstr(reference_uid(add_str("$@partymembername$"), j),p->party.member[i].name);
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
@@ -8038,9 +8040,9 @@ BUILDIN_FUNC(getequippercentrefinery)
|
||||
return 0;
|
||||
|
||||
if (num > 0 && num <= ARRAYLENGTH(equip))
|
||||
i=pc_checkequip(sd,equip[num-1]);
|
||||
i = pc_checkequip(sd,equip[num-1]);
|
||||
if(i >= 0 && sd->status.inventory[i].nameid && sd->status.inventory[i].refine < MAX_REFINE)
|
||||
script_pushint(st,status_get_refine_chance(itemdb_wlv(sd->status.inventory[i].nameid), (int)sd->status.inventory[i].refine));
|
||||
script_pushint(st,status_get_refine_chance((enum refine_type)itemdb_wlv(sd->status.inventory[i].nameid), (int)sd->status.inventory[i].refine));
|
||||
else
|
||||
script_pushint(st,0);
|
||||
|
||||
@@ -8052,7 +8054,7 @@ BUILDIN_FUNC(getequippercentrefinery)
|
||||
*------------------------------------------*/
|
||||
BUILDIN_FUNC(successrefitem)
|
||||
{
|
||||
int i = -1, num, ep, up = 1;
|
||||
int i = -1, num, up = 1;
|
||||
TBL_PC *sd;
|
||||
|
||||
num = script_getnum(st,2);
|
||||
@@ -8064,9 +8066,9 @@ BUILDIN_FUNC(successrefitem)
|
||||
up = script_getnum(st, 3);
|
||||
|
||||
if (num > 0 && num <= ARRAYLENGTH(equip))
|
||||
i=pc_checkequip(sd,equip[num-1]);
|
||||
i = pc_checkequip(sd,equip[num-1]);
|
||||
if(i >= 0) {
|
||||
ep=sd->status.inventory[i].equip;
|
||||
unsigned int ep = sd->status.inventory[i].equip;
|
||||
|
||||
//Logs items, got from (N)PC scripts [Lupus]
|
||||
log_pick_pc(sd, LOG_TYPE_SCRIPT, -1, &sd->status.inventory[i]);
|
||||
@@ -8141,7 +8143,7 @@ BUILDIN_FUNC(failedrefitem)
|
||||
*------------------------------------------*/
|
||||
BUILDIN_FUNC(downrefitem)
|
||||
{
|
||||
int i = -1, num, ep, down = 1;
|
||||
int i = -1, num, down = 1;
|
||||
TBL_PC *sd;
|
||||
|
||||
sd = script_rid2sd(st);
|
||||
@@ -8154,7 +8156,7 @@ BUILDIN_FUNC(downrefitem)
|
||||
if (num > 0 && num <= ARRAYLENGTH(equip))
|
||||
i = pc_checkequip(sd,equip[num-1]);
|
||||
if(i >= 0) {
|
||||
ep = sd->status.inventory[i].equip;
|
||||
unsigned int ep = sd->status.inventory[i].equip;
|
||||
|
||||
//Logs items, got from (N)PC scripts [Lupus]
|
||||
log_pick_pc(sd, LOG_TYPE_SCRIPT, -1, &sd->status.inventory[i]);
|
||||
@@ -10136,7 +10138,7 @@ BUILDIN_FUNC(getmapguildusers)
|
||||
const char *str;
|
||||
int16 m;
|
||||
int gid;
|
||||
int i=0,c=0;
|
||||
int c=0;
|
||||
struct guild *g = NULL;
|
||||
str=script_getstr(st,2);
|
||||
gid=script_getnum(st,3);
|
||||
@@ -10147,6 +10149,7 @@ BUILDIN_FUNC(getmapguildusers)
|
||||
g = guild_search(gid);
|
||||
|
||||
if (g){
|
||||
unsigned short i;
|
||||
for(i = 0; i < g->max_member; i++)
|
||||
{
|
||||
if (g->member[i].sd && g->member[i].sd->bl.m == m)
|
||||
@@ -10539,7 +10542,7 @@ BUILDIN_FUNC(homunculus_evolution)
|
||||
*------------------------------------------*/
|
||||
BUILDIN_FUNC(homunculus_mutate)
|
||||
{
|
||||
int homun_id, m_class, m_id, i;
|
||||
int homun_id;
|
||||
TBL_PC *sd;
|
||||
|
||||
sd = script_rid2sd(st);
|
||||
@@ -10552,10 +10555,9 @@ BUILDIN_FUNC(homunculus_mutate)
|
||||
homun_id = 6048 + (rnd() % 4);
|
||||
|
||||
if( sd->hd->homunculus.vaporize == HOM_ST_MORPH ) {
|
||||
m_class = hom_class2mapid(sd->hd->homunculus.class_);
|
||||
m_id = hom_class2mapid(homun_id);
|
||||
|
||||
i = pc_search_inventory(sd, ITEMID_STRANGE_EMBRYO);
|
||||
int m_class = hom_class2mapid(sd->hd->homunculus.class_);
|
||||
int m_id = hom_class2mapid(homun_id);
|
||||
short i = pc_search_inventory(sd, ITEMID_STRANGE_EMBRYO);
|
||||
|
||||
if ( m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99 && i >= 0 ) {
|
||||
sd->hd->homunculus.vaporize = HOM_ST_REST; // Remove morph state.
|
||||
@@ -10581,7 +10583,6 @@ BUILDIN_FUNC(homunculus_mutate)
|
||||
BUILDIN_FUNC(morphembryo)
|
||||
{
|
||||
struct item item_tmp;
|
||||
int m_class, i=0;
|
||||
TBL_PC *sd;
|
||||
|
||||
sd = script_rid2sd(st);
|
||||
@@ -10589,9 +10590,10 @@ BUILDIN_FUNC(morphembryo)
|
||||
return 0;
|
||||
|
||||
if( hom_is_active(sd->hd) ) {
|
||||
m_class = hom_class2mapid(sd->hd->homunculus.class_);
|
||||
int m_class = hom_class2mapid(sd->hd->homunculus.class_);
|
||||
|
||||
if ( m_class != -1 && m_class&HOM_EVO && sd->hd->homunculus.level >= 99 ) {
|
||||
char i;
|
||||
memset(&item_tmp, 0, sizeof(item_tmp));
|
||||
item_tmp.nameid = ITEMID_STRANGE_EMBRYO;
|
||||
item_tmp.identify = 1;
|
||||
@@ -10849,7 +10851,6 @@ BUILDIN_FUNC(globalmes)
|
||||
BUILDIN_FUNC(waitingroom)
|
||||
{
|
||||
struct npc_data* nd;
|
||||
int pub = 1;
|
||||
const char* title = script_getstr(st, 2);
|
||||
int limit = script_getnum(st, 3);
|
||||
const char* ev = script_hasdata(st,4) ? script_getstr(st,4) : "";
|
||||
@@ -10860,7 +10861,7 @@ BUILDIN_FUNC(waitingroom)
|
||||
|
||||
nd = (struct npc_data *)map_id2bl(st->oid);
|
||||
if( nd != NULL )
|
||||
chat_createnpcchat(nd, title, limit, pub, trigger, ev, zeny, minLvl, maxLvl);
|
||||
chat_createnpcchat(nd, title, limit, 1, trigger, ev, zeny, minLvl, maxLvl);
|
||||
|
||||
return SCRIPT_CMD_SUCCESS;
|
||||
}
|
||||
@@ -11007,7 +11008,6 @@ BUILDIN_FUNC(warpwaitingpc)
|
||||
const char* map_name;
|
||||
struct npc_data* nd;
|
||||
struct chat_data* cd;
|
||||
TBL_PC* sd;
|
||||
|
||||
nd = (struct npc_data *)map_id2bl(st->oid);
|
||||
if( nd == NULL || (cd=(struct chat_data *)map_id2bl(nd->chat_id)) == NULL )
|
||||
@@ -11023,7 +11023,7 @@ BUILDIN_FUNC(warpwaitingpc)
|
||||
|
||||
for( i = 0; i < n && cd->users > 0; i++ )
|
||||
{
|
||||
sd = cd->usersd[0];
|
||||
TBL_PC* sd = cd->usersd[0];
|
||||
|
||||
if( strcmp(map_name,"SavePoint") == 0 && map[sd->bl.m].flag.noteleport )
|
||||
{// can't teleport on this map
|
||||
@@ -11956,7 +11956,7 @@ BUILDIN_FUNC(getequipcardcnt)
|
||||
/// and give them to the character. If any cards were removed in this manner, it will also show a success effect.
|
||||
/// successremovecards <slot>;
|
||||
BUILDIN_FUNC(successremovecards) {
|
||||
int i=-1,j,c,cardflag=0;
|
||||
int i=-1,c,cardflag=0;
|
||||
|
||||
TBL_PC* sd = script_rid2sd(st);
|
||||
int num = script_getnum(st,2);
|
||||
@@ -11988,7 +11988,7 @@ BUILDIN_FUNC(successremovecards) {
|
||||
}
|
||||
|
||||
if(cardflag == 1) {//if card was remove remplace item with no card
|
||||
unsigned char flag = 0;
|
||||
unsigned char flag = 0, j;
|
||||
struct item item_tmp;
|
||||
memset(&item_tmp,0,sizeof(item_tmp));
|
||||
|
||||
@@ -12020,7 +12020,7 @@ BUILDIN_FUNC(successremovecards) {
|
||||
/// <type>=2 : will keep the cards, but destroy the item.
|
||||
/// <type>=? : will just display the failure effect.
|
||||
BUILDIN_FUNC(failedremovecards) {
|
||||
int i=-1,j,c,cardflag=0;
|
||||
int i=-1,c,cardflag=0;
|
||||
|
||||
TBL_PC* sd = script_rid2sd(st);
|
||||
int num = script_getnum(st,2);
|
||||
@@ -12061,7 +12061,7 @@ BUILDIN_FUNC(failedremovecards) {
|
||||
pc_delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
|
||||
}
|
||||
if(typefail == 1){ // destroy the card
|
||||
unsigned char flag = 0;
|
||||
unsigned char flag = 0, j;
|
||||
struct item item_tmp;
|
||||
|
||||
memset(&item_tmp,0,sizeof(item_tmp));
|
||||
@@ -12352,7 +12352,6 @@ BUILDIN_FUNC(guardian)
|
||||
{
|
||||
int class_=0,x=0,y=0,guardian=0;
|
||||
const char *str,*mapname,*evt="";
|
||||
struct script_data *data;
|
||||
bool has_index = false;
|
||||
|
||||
mapname =script_getstr(st,2);
|
||||
@@ -12367,7 +12366,7 @@ BUILDIN_FUNC(guardian)
|
||||
guardian=script_getnum(st,8);
|
||||
has_index = true;
|
||||
} else if( script_hasdata(st,7) ){
|
||||
data=script_getdata(st,7);
|
||||
struct script_data *data = script_getdata(st,7);
|
||||
get_val(st,data);
|
||||
if( data_isstring(data) )
|
||||
{// "<event label>"
|
||||
@@ -12539,7 +12538,6 @@ BUILDIN_FUNC(getitemslots)
|
||||
BUILDIN_FUNC(getiteminfo)
|
||||
{
|
||||
unsigned short item_id,n;
|
||||
int *item_arr;
|
||||
struct item_data *i_data;
|
||||
|
||||
item_id = script_getnum(st,2);
|
||||
@@ -12547,7 +12545,7 @@ BUILDIN_FUNC(getiteminfo)
|
||||
i_data = itemdb_exists(item_id);
|
||||
|
||||
if (i_data && n <= 14) {
|
||||
item_arr = (int*)&i_data->value_buy;
|
||||
int *item_arr = (int*)&i_data->value_buy;
|
||||
script_pushint(st,item_arr[n]);
|
||||
} else
|
||||
script_pushint(st,-1);
|
||||
@@ -12581,7 +12579,6 @@ BUILDIN_FUNC(setiteminfo)
|
||||
{
|
||||
unsigned short item_id;
|
||||
int n,value;
|
||||
int *item_arr;
|
||||
struct item_data *i_data;
|
||||
|
||||
item_id = script_getnum(st,2);
|
||||
@@ -12590,7 +12587,7 @@ BUILDIN_FUNC(setiteminfo)
|
||||
i_data = itemdb_exists(item_id);
|
||||
|
||||
if (i_data && n>=0 && n<=14) {
|
||||
item_arr = (int*)&i_data->value_buy;
|
||||
int *item_arr = (int*)&i_data->value_buy;
|
||||
item_arr[n] = value;
|
||||
script_pushint(st,value);
|
||||
} else
|
||||
@@ -12841,12 +12838,10 @@ BUILDIN_FUNC(misceffect)
|
||||
*------------------------------------------*/
|
||||
BUILDIN_FUNC(playBGM)
|
||||
{
|
||||
const char* name;
|
||||
struct map_session_data* sd;
|
||||
|
||||
if( ( sd = script_rid2sd(st) ) != NULL ) {
|
||||
name = script_getstr(st,2);
|
||||
clif_playBGM(sd, name);
|
||||
clif_playBGM(sd, script_getstr(st,2));
|
||||
}
|
||||
return SCRIPT_CMD_SUCCESS;
|
||||
}
|
||||
@@ -13352,7 +13347,6 @@ BUILDIN_FUNC(recovery)
|
||||
case 1:
|
||||
{
|
||||
struct party_data* p;
|
||||
struct map_session_data* pl_sd;
|
||||
//When no party given, we use invoker party
|
||||
int p_id = 0, i;
|
||||
if(script_hasdata(st,5)) {//Bad maps shouldn't cause issues
|
||||
@@ -13370,6 +13364,7 @@ BUILDIN_FUNC(recovery)
|
||||
if(p == NULL)
|
||||
return 0;
|
||||
for (i = 0; i < MAX_PARTY; i++) {
|
||||
struct map_session_data* pl_sd;
|
||||
if((!(pl_sd = p->data[i].sd) || pl_sd->status.party_id != p_id)
|
||||
|| (map_idx && pl_sd->bl.m != map_idx))
|
||||
continue;
|
||||
@@ -13380,7 +13375,6 @@ BUILDIN_FUNC(recovery)
|
||||
case 2:
|
||||
{
|
||||
struct guild* g;
|
||||
struct map_session_data* pl_sd;
|
||||
//When no guild given, we use invoker guild
|
||||
int g_id = 0, i;
|
||||
if(script_hasdata(st,5)) {//Bad maps shouldn't cause issues
|
||||
@@ -13398,6 +13392,7 @@ BUILDIN_FUNC(recovery)
|
||||
if(g == NULL)
|
||||
return 0;
|
||||
for (i = 0; i < MAX_GUILD; i++) {
|
||||
struct map_session_data* pl_sd;
|
||||
if((!(pl_sd = g->member[i].sd) || pl_sd->status.guild_id != g_id)
|
||||
|| (map_idx && pl_sd->bl.m != map_idx))
|
||||
continue;
|
||||
@@ -13511,7 +13506,7 @@ BUILDIN_FUNC(gethominfo)
|
||||
/// getmercinfo <type>[,<char id>];
|
||||
BUILDIN_FUNC(getmercinfo)
|
||||
{
|
||||
int type, char_id;
|
||||
int type;
|
||||
struct map_session_data* sd;
|
||||
struct mercenary_data* md;
|
||||
|
||||
@@ -13519,7 +13514,7 @@ BUILDIN_FUNC(getmercinfo)
|
||||
|
||||
if( script_hasdata(st,3) )
|
||||
{
|
||||
char_id = script_getnum(st,3);
|
||||
int char_id = script_getnum(st,3);
|
||||
|
||||
if( ( sd = map_charid2sd(char_id) ) == NULL )
|
||||
{
|
||||
@@ -13658,13 +13653,13 @@ BUILDIN_FUNC(message)
|
||||
BUILDIN_FUNC(npctalk)
|
||||
{
|
||||
const char* str;
|
||||
char name[NAME_LENGTH], message[256];
|
||||
|
||||
struct npc_data* nd = (struct npc_data *)map_id2bl(st->oid);
|
||||
str = script_getstr(st,2);
|
||||
|
||||
if(nd)
|
||||
{
|
||||
char name[NAME_LENGTH], message[256];
|
||||
safestrncpy(name, nd->name, sizeof(name));
|
||||
strtok(name, "#"); // discard extra name identifier if present
|
||||
safesnprintf(message, sizeof(message), "%s : %s", name, str);
|
||||
@@ -14218,7 +14213,6 @@ BUILDIN_FUNC(day)
|
||||
//-------------------------------------------------------
|
||||
BUILDIN_FUNC(unequip)
|
||||
{
|
||||
int i;
|
||||
size_t num;
|
||||
TBL_PC *sd;
|
||||
|
||||
@@ -14226,7 +14220,7 @@ BUILDIN_FUNC(unequip)
|
||||
sd = script_rid2sd(st);
|
||||
if( sd != NULL && num >= 1 && num <= ARRAYLENGTH(equip) )
|
||||
{
|
||||
i = pc_checkequip(sd,equip[num-1]);
|
||||
short i = pc_checkequip(sd,equip[num-1]);
|
||||
if (i >= 0)
|
||||
pc_unequipitem(sd,i,1|2);
|
||||
}
|
||||
@@ -14587,10 +14581,8 @@ BUILDIN_FUNC(explode)
|
||||
BUILDIN_FUNC(implode)
|
||||
{
|
||||
struct script_data* data = script_getdata(st, 2);
|
||||
const char *glue = NULL, *name, *temp;
|
||||
const char *name;
|
||||
int32 glue_len = 0, array_size, id;
|
||||
size_t len = 0;
|
||||
int i, k = 0;
|
||||
|
||||
TBL_PC* sd = NULL;
|
||||
|
||||
@@ -14639,6 +14631,10 @@ BUILDIN_FUNC(implode)
|
||||
output = (char*)aMalloc(sizeof(char)*5);
|
||||
sprintf(output,"%s","NULL");
|
||||
} else {
|
||||
const char *glue = NULL, *temp;
|
||||
size_t len = 0;
|
||||
int i, k = 0;
|
||||
|
||||
for(i = 0; i <= array_size; ++i) {
|
||||
temp = (char*) get_val2(st, reference_uid(id, i), reference_getref(data));
|
||||
len += strlen(temp);
|
||||
@@ -15453,7 +15449,7 @@ BUILDIN_FUNC(getd)
|
||||
|
||||
buffer = script_getstr(st, 2);
|
||||
|
||||
if(sscanf(buffer, "%[^[][%d]", varname, &elem) < 2)
|
||||
if(sscanf(buffer, "%99[^[][%d]", varname, &elem) < 2)
|
||||
elem = 0;
|
||||
|
||||
// Push the 'pointer' so it's more flexible [Lance]
|
||||
@@ -15686,7 +15682,7 @@ BUILDIN_FUNC(addmonsterdrop)
|
||||
struct mob_db *mob;
|
||||
struct script_data *data;
|
||||
unsigned short item_id;
|
||||
int rate,i,c = 0;
|
||||
int rate;
|
||||
|
||||
data = script_getdata(st, 2);
|
||||
get_val(st, data); // Convert into value in case of a variable
|
||||
@@ -15704,6 +15700,7 @@ BUILDIN_FUNC(addmonsterdrop)
|
||||
}
|
||||
|
||||
if(mob) { //We got a valid monster, check for available drop slot
|
||||
unsigned char i, c = 0;
|
||||
for(i = 0; i < MAX_MOB_DROP; i++) {
|
||||
if(mob->dropitem[i].nameid) {
|
||||
if(mob->dropitem[i].nameid == item_id) { //If it equals item_id we update that drop
|
||||
@@ -15742,7 +15739,6 @@ BUILDIN_FUNC(delmonsterdrop)
|
||||
struct mob_db *mob;
|
||||
struct script_data *data;
|
||||
unsigned short item_id;
|
||||
int i;
|
||||
|
||||
data = script_getdata(st, 2);
|
||||
get_val(st, data); // Convert into value in case of a variable
|
||||
@@ -15759,6 +15755,7 @@ BUILDIN_FUNC(delmonsterdrop)
|
||||
}
|
||||
|
||||
if(mob) { //We got a valid monster, check for item drop on monster
|
||||
unsigned char i;
|
||||
for(i = 0; i < MAX_MOB_DROP; i++) {
|
||||
if(mob->dropitem[i].nameid == item_id) {
|
||||
mob->dropitem[i].nameid = 0;
|
||||
@@ -16754,7 +16751,7 @@ Questlog script commands
|
||||
BUILDIN_FUNC(questinfo)
|
||||
{
|
||||
TBL_NPC* nd = map_id2nd(st->oid);
|
||||
int quest_id, icon, job, color = 0;
|
||||
int quest_id, icon;
|
||||
struct questinfo qi;
|
||||
|
||||
if( nd == NULL || nd->bl.m == -1 )
|
||||
@@ -16778,7 +16775,7 @@ BUILDIN_FUNC(questinfo)
|
||||
qi.nd = nd;
|
||||
|
||||
if( script_hasdata(st, 4) ) {
|
||||
color = script_getnum(st, 4);
|
||||
int color = script_getnum(st, 4);
|
||||
if( color < 0 || color > 3 ) {
|
||||
ShowWarning("buildin_questinfo: invalid color '%d', changing to 0\n",color);
|
||||
script_reportfunc(st);
|
||||
@@ -16790,7 +16787,7 @@ BUILDIN_FUNC(questinfo)
|
||||
qi.hasJob = false;
|
||||
|
||||
if(script_hasdata(st, 5)) {
|
||||
job = script_getnum(st, 5);
|
||||
int job = script_getnum(st, 5);
|
||||
|
||||
if (!pcdb_checkid(job))
|
||||
ShowError("buildin_questinfo: Nonexistant Job Class.\n");
|
||||
@@ -16927,8 +16924,8 @@ BUILDIN_FUNC(waitingroom2bg)
|
||||
struct npc_data *nd;
|
||||
struct chat_data *cd;
|
||||
const char *map_name, *ev = "", *dev = "";
|
||||
int x, y, i, mapindex = 0, bg_id, n;
|
||||
struct map_session_data *sd;
|
||||
int x, y, mapindex = 0, bg_id, n;
|
||||
unsigned char i;
|
||||
|
||||
if( script_hasdata(st,7) )
|
||||
nd = npc_name2id(script_getstr(st,7));
|
||||
@@ -16966,6 +16963,7 @@ BUILDIN_FUNC(waitingroom2bg)
|
||||
n = cd->users;
|
||||
for( i = 0; i < n && i < MAX_BG_MEMBERS; i++ )
|
||||
{
|
||||
struct map_session_data *sd;
|
||||
if( (sd = cd->usersd[i]) != NULL && bg_team_join(bg_id, sd) )
|
||||
mapreg_setreg(reference_uid(add_str("$@arenamembers"), i), sd->bl.id);
|
||||
else
|
||||
@@ -17101,7 +17099,6 @@ BUILDIN_FUNC(bg_getareausers)
|
||||
int bg_id;
|
||||
int i = 0, c = 0;
|
||||
struct battleground_data *bg = NULL;
|
||||
struct map_session_data *sd;
|
||||
|
||||
bg_id = script_getnum(st,2);
|
||||
str = script_getstr(st,3);
|
||||
@@ -17119,6 +17116,7 @@ BUILDIN_FUNC(bg_getareausers)
|
||||
|
||||
for( i = 0; i < MAX_BG_MEMBERS; i++ )
|
||||
{
|
||||
struct map_session_data *sd;
|
||||
if( (sd = bg->members[i].sd) == NULL )
|
||||
continue;
|
||||
if( sd->bl.m != m || sd->bl.x < x0 || sd->bl.y < y0 || sd->bl.x > x1 || sd->bl.y > y1 )
|
||||
@@ -17339,7 +17337,6 @@ BUILDIN_FUNC(instance_id)
|
||||
BUILDIN_FUNC(instance_warpall)
|
||||
{
|
||||
struct party_data *p;
|
||||
struct map_session_data *pl_sd;
|
||||
int16 m, i;
|
||||
short instance_id;
|
||||
const char *mapn;
|
||||
@@ -17359,8 +17356,10 @@ BUILDIN_FUNC(instance_warpall)
|
||||
if( !(p = party_search(instance_data[instance_id].party_id)) )
|
||||
return 0;
|
||||
|
||||
for( i = 0; i < MAX_PARTY; i++ )
|
||||
for( i = 0; i < MAX_PARTY; i++ ) {
|
||||
struct map_session_data *pl_sd;
|
||||
if( (pl_sd = p->data[i].sd) && map[pl_sd->bl.m].instance_id == instance_id ) pc_setpos(pl_sd,map_id2index(m),x,y,CLR_TELEPORT);
|
||||
}
|
||||
|
||||
return SCRIPT_CMD_SUCCESS;
|
||||
}
|
||||
@@ -17409,7 +17408,6 @@ BUILDIN_FUNC(instance_announce) {
|
||||
*------------------------------------------*/
|
||||
BUILDIN_FUNC(instance_check_party)
|
||||
{
|
||||
struct map_session_data *pl_sd;
|
||||
int amount, min, max, i, party_id, c = 0;
|
||||
struct party_data *p = NULL;
|
||||
|
||||
@@ -17434,7 +17432,8 @@ BUILDIN_FUNC(instance_check_party)
|
||||
return 0;
|
||||
}
|
||||
|
||||
for( i = 0; i < MAX_PARTY; i++ )
|
||||
for( i = 0; i < MAX_PARTY; i++ ) {
|
||||
struct map_session_data *pl_sd;
|
||||
if( (pl_sd = p->data[i].sd) )
|
||||
if(map_id2bl(pl_sd->bl.id)) {
|
||||
if(pl_sd->status.base_level < min) {
|
||||
@@ -17446,6 +17445,7 @@ BUILDIN_FUNC(instance_check_party)
|
||||
}
|
||||
c++;
|
||||
}
|
||||
}
|
||||
|
||||
if(c < amount)
|
||||
script_pushint(st, 0); // Not enough Members in the Party to join Instance.
|
||||
@@ -18665,7 +18665,6 @@ BUILDIN_FUNC(montransform) {
|
||||
|
||||
TBL_PC *sd;
|
||||
enum sc_type type;
|
||||
char msg[CHAT_SIZE_MAX];
|
||||
int tick, mob_id, val1, val2, val3, val4;
|
||||
struct script_data *data;
|
||||
|
||||
@@ -18714,6 +18713,7 @@ BUILDIN_FUNC(montransform) {
|
||||
val4 = script_getnum(st, 8);
|
||||
|
||||
if (tick != 0) {
|
||||
char msg[CHAT_SIZE_MAX];
|
||||
struct mob_db *monster = mob_db(mob_id);
|
||||
|
||||
if (battle_config.mon_trans_disable_in_gvg && map_flag_gvg2(sd->bl.m)) {
|
||||
@@ -18867,15 +18867,17 @@ BUILDIN_FUNC(disable_command) {
|
||||
*/
|
||||
BUILDIN_FUNC(getguildmember)
|
||||
{
|
||||
int i, j = 0, type = 0;
|
||||
unsigned char j = 0;
|
||||
struct guild *g = NULL;
|
||||
|
||||
g = guild_search(script_getnum(st,2));
|
||||
|
||||
if (script_hasdata(st,3))
|
||||
type = script_getnum(st,3);
|
||||
|
||||
if (g) {
|
||||
unsigned char i, type = 0;
|
||||
|
||||
if (script_hasdata(st,3))
|
||||
type = (unsigned char)script_getnum(st,3);
|
||||
|
||||
for (i = 0; i < MAX_GUILD; i++) {
|
||||
if (g->member[i].account_id) {
|
||||
switch (type) {
|
||||
|
||||
Reference in New Issue
Block a user