Applied a temp patch to make some npc-executed atcommands work again (bugreport:790).

Added support for right-click-gm-menu kicking NPC objects.
Removed redundant function npc_checknear2().

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@12073 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
ultramage 2008-01-14 11:34:59 +00:00
parent d5455fabfc
commit 1859b5e45a
7 changed files with 31 additions and 37 deletions

View File

@ -5,6 +5,8 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2008/01/14
* Applied a temp patch to make some npc-executed atcommands work again
* Added support for right-click-gm-menu kicking NPC objects [ultramage]
* Fixed dangling pointer crashes when bleeding or Deadly poison kills a
spawn-once monster.
* Fixed a possible ERS entry corruption when Deadly Poison kills a target

View File

@ -35,6 +35,7 @@ int atcommand_kick(const int fd, struct map_session_data* sd, const char* comman
int atcommand_broadcast(const int fd, struct map_session_data* sd,const char* command, const char* message);
int atcommand_localbroadcast(const int fd, struct map_session_data* sd,const char* command, const char* message);
int atcommand_reset(const int fd, struct map_session_data* sd,const char* command, const char* message);
int atcommand_unloadnpc(const int fd, struct map_session_data* sd, const char* command, const char* message);
#define MAX_MSG 1000
extern char* msg_table[MAX_MSG];

View File

@ -10231,20 +10231,34 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd)
}
clif_GM_kick(sd, tsd, 1);
if(log_config.gm && lv >= log_config.gm) {
char message[NAME_LENGTH+6];
sprintf(message, "/kick %d", tsd->status.char_id);
char message[256];
sprintf(message, "/kick %s (%d)", tsd->status.name, tsd->status.char_id);
log_atcommand(sd, message);
}
break;
}
break;
case BL_MOB:
status_percent_damage(&sd->bl, target, 100, 0, true);
if(log_config.gm && lv >= log_config.gm) {
char message[NAME_LENGTH+16];
char message[256];
sprintf(message, "/kick %s (%d)", status_get_name(target), status_get_class(target));
log_atcommand(sd, message);
}
break;
break;
case BL_NPC:
{
struct npc_data* nd = (struct npc_data *)target;
lv = get_atcommand_level(atcommand_unloadnpc);
if( pc_isGM(sd) < lv )
return;
npc_unload(nd);
if( log_config.gm && lv >= log_config.gm ) {
char message[256];
sprintf(message, "/kick %s (%d)", status_get_name(target), status_get_class(target));
log_atcommand(sd, message);
}
}
break;
default:
clif_GM_kickack(sd, 0);
}

View File

@ -869,28 +869,6 @@ int npc_check_areanpc(int flag, int m, int x, int y, int range)
return (map[m].npc[i]->bl.id);
}
/*==========================================
* ß­©Ç¤©Ì»è
*------------------------------------------*/
int npc_checknear2(struct map_session_data* sd, struct block_list* bl)
{
nullpo_retr(1, sd);
if(bl == NULL) return 1;
if(sd->state.using_fake_npc && sd->npc_id == bl->id)
return 0;
if (status_get_class(bl)<0) //Class-less npc, enable click from anywhere.
return 0;
if (bl->m!=sd->bl.m ||
bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)
return 1;
return 0;
}
struct npc_data* npc_checknear(struct map_session_data* sd, struct block_list* bl)
{
struct npc_data *nd;

View File

@ -48,7 +48,6 @@ int npc_check_areanpc(int flag, int m, int x, int y, int range);
int npc_click(struct map_session_data* sd, struct npc_data* nd);
int npc_scriptcont(struct map_session_data* sd, int id);
struct npc_data* npc_checknear(struct map_session_data* sd, struct block_list* bl);
int npc_checknear2(struct map_session_data* sd, struct block_list* bl);
int npc_buysellsel(struct map_session_data* sd, int id, int type);
int npc_buylist(struct map_session_data* sd,int n, unsigned short* item_list);
int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list);

View File

@ -91,7 +91,7 @@ int pc_isGM(struct map_session_data* sd)
nullpo_retr(0, sd);
if( sd->bl.type != BL_PC )
return 0;
return 99;
ARR_FIND( 0, GM_num, i, gm_account[i].account_id == sd->status.account_id );
return ( i < GM_num ) ? gm_account[i].level : 0;

View File

@ -4035,14 +4035,14 @@ const char* status_get_name(struct block_list *bl)
int status_get_class(struct block_list *bl)
{
nullpo_retr(0, bl);
if(bl->type==BL_MOB) //Class used on all code should be the view class of the mob.
return ((struct mob_data *)bl)->vd->class_;
if(bl->type==BL_PC)
return ((struct map_session_data *)bl)->status.class_;
if(bl->type==BL_PET)
return ((struct pet_data *)bl)->pet.class_;
if(bl->type==BL_HOM)
return ((struct homun_data *)bl)->homunculus.class_;
switch( bl->type )
{
case BL_PC: return ((TBL_PC*)bl)->status.class_;
case BL_MOB: return ((TBL_MOB*)bl)->vd->class_; //Class used on all code should be the view class of the mob.
case BL_PET: return ((TBL_PET*)bl)->pet.class_;
case BL_HOM: return ((TBL_HOM*)bl)->homunculus.class_;
case BL_NPC: return ((TBL_NPC*)bl)->class_;
}
return 0;
}
/*==========================================