- Moved subtype from struct block_list to struct npc_data.

- Fixed some compilation warnings.


git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@11772 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
skotlex 2007-11-21 13:29:45 +00:00
parent cd362b8ca9
commit 6840bb28ab
11 changed files with 37 additions and 41 deletions

View File

@ -658,7 +658,7 @@
10000,0,0,0,0,0,0,1,0,no,0,0x10,0,none,0 ,GD_APPROVAL,Official Guild Approval 10000,0,0,0,0,0,0,1,0,no,0,0x10,0,none,0 ,GD_APPROVAL,Official Guild Approval
10001,0,0,0,0,0,0,1,0,no,0,0x10,0,none,0 ,GD_KAFRACONTRACT,Kafra Contract 10001,0,0,0,0,0,0,1,0,no,0,0x10,0,none,0 ,GD_KAFRACONTRACT,Kafra Contract
10002,0,0,0,0,0,0,1,0,no,0,0x10,0,none,0 ,GD_GUARDRESEARCH,Guardian Research 10002,0,0,0,0,0,0,1,0,no,0,0x10,0,none,0 ,GD_GUARDIANRESEARCH,Guardian Research
10003,0,0,0,0,0,0,1,0,no,0,0x10,0,none,0 ,GD_GUARDUP,Strengthen Guardians 10003,0,0,0,0,0,0,1,0,no,0,0x10,0,none,0 ,GD_GUARDUP,Strengthen Guardians
10004,0,0,0,0,0,0,10,0,no,0,0x10,0,none,0 ,GD_EXTENSION,Guild Extension 10004,0,0,0,0,0,0,10,0,no,0,0x10,0,none,0 ,GD_EXTENSION,Guild Extension
10005,0,0,0,0,0,0,1,0,no,0,0x10,0,none,0 ,GD_GLORYGUILD,Guild's Glory 10005,0,0,0,0,0,0,1,0,no,0,0x10,0,none,0 ,GD_GLORYGUILD,Guild's Glory

View File

@ -1074,7 +1074,6 @@ static int clif_set_unit_walking(struct block_list* bl, struct unit_data* ud, un
*------------------------------------------*/ *------------------------------------------*/
static int clif_set_unit_spawned(struct block_list* bl, unsigned char* buf) static int clif_set_unit_spawned(struct block_list* bl, unsigned char* buf)
{ {
struct status_change* sc = status_get_sc(bl);
struct view_data* vd = status_get_viewdata(bl); struct view_data* vd = status_get_viewdata(bl);
if( pcdb_checkid(vd->class_) ) if( pcdb_checkid(vd->class_) )
@ -3583,7 +3582,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl)
uint8 buf[128]; uint8 buf[128];
struct unit_data *ud; struct unit_data *ud;
struct view_data *vd; struct view_data *vd;
int len, fd = sd->fd; int len;
vd = status_get_viewdata(bl); vd = status_get_viewdata(bl);
if (!vd || vd->class_ == INVISIBLE_CLASS) if (!vd || vd->class_ == INVISIBLE_CLASS)

View File

@ -1955,7 +1955,7 @@ void map_removenpc(void)
clif_clearunit_area(&map[m].npc[i]->bl,2); clif_clearunit_area(&map[m].npc[i]->bl,2);
map_delblock(&map[m].npc[i]->bl); map_delblock(&map[m].npc[i]->bl);
idb_remove(id_db,map[m].npc[i]->bl.id); idb_remove(id_db,map[m].npc[i]->bl.id);
if(map[m].npc[i]->bl.subtype==SCRIPT) { if(map[m].npc[i]->subtype==SCRIPT) {
aFree(map[m].npc[i]->u.scr.script); aFree(map[m].npc[i]->u.scr.script);
aFree(map[m].npc[i]->u.scr.label_list); aFree(map[m].npc[i]->u.scr.label_list);
} }

View File

@ -189,7 +189,7 @@ enum bl_type {
#define BL_CHAR (BL_PC|BL_MOB|BL_HOM) #define BL_CHAR (BL_PC|BL_MOB|BL_HOM)
#define BL_ALL 0xfff #define BL_ALL 0xfff
enum bl_subtype { WARP, SHOP, SCRIPT, MONS }; enum npc_subtype { WARP, SHOP, SCRIPT };
enum { enum {
RC_FORMLESS=0, RC_FORMLESS=0,
@ -233,7 +233,6 @@ struct block_list {
int id; int id;
short m,x,y; short m,x,y;
enum bl_type type; enum bl_type type;
enum bl_subtype subtype;
}; };
struct walkpath_data { struct walkpath_data {
@ -824,6 +823,7 @@ struct npc_data {
struct unit_data ud; //Because they need to be able to move.... struct unit_data ud; //Because they need to be able to move....
struct view_data *vd; struct view_data *vd;
struct status_change sc; //They can't have status changes, but.. they want the visual opt values. struct status_change sc; //They can't have status changes, but.. they want the visual opt values.
struct npc_data *master_nd;
short n; short n;
short class_; short class_;
short speed; short speed;
@ -833,8 +833,7 @@ struct npc_data {
unsigned int next_walktime; unsigned int next_walktime;
void* chatdb; // pointer to a npc_parse struct (see npc_chat.c) void* chatdb; // pointer to a npc_parse struct (see npc_chat.c)
struct npc_data *master_nd; enum npc_subtype subtype;
union { union {
struct { struct {
struct script_code *script; struct script_code *script;

View File

@ -608,7 +608,6 @@ int merc_hom_alloc(struct map_session_data *sd, struct s_homunculus *hom)
return 1; return 1;
} }
sd->hd = hd = aCalloc(1,sizeof(struct homun_data)); sd->hd = hd = aCalloc(1,sizeof(struct homun_data));
hd->bl.subtype = MONS;
hd->bl.type = BL_HOM; hd->bl.type = BL_HOM;
hd->bl.id = npc_get_new_npc_id(); hd->bl.id = npc_get_new_npc_id();
@ -643,7 +642,6 @@ void merc_hom_init_timers(struct homun_data * hd)
{ {
if (hd->hungry_timer == -1) if (hd->hungry_timer == -1)
hd->hungry_timer = add_timer(gettick()+hd->homunculusDB->hungryDelay,merc_hom_hungry,hd->master->bl.id,0); hd->hungry_timer = add_timer(gettick()+hd->homunculusDB->hungryDelay,merc_hom_hungry,hd->master->bl.id,0);
hd->ud.canact_tick = 0; //Reset can-act delay
hd->regen.state.block = 0; //Restore HP/SP block. hd->regen.state.block = 0; //Restore HP/SP block.
} }

View File

@ -207,7 +207,6 @@ struct mob_data* mob_spawn_dataset(struct spawn_data *data)
struct mob_data *md = aCalloc(1, sizeof(struct mob_data)); struct mob_data *md = aCalloc(1, sizeof(struct mob_data));
md->bl.id= npc_get_new_npc_id(); md->bl.id= npc_get_new_npc_id();
md->bl.type = BL_MOB; md->bl.type = BL_MOB;
md->bl.subtype = MONS;
md->bl.m = data->m; md->bl.m = data->m;
md->bl.x = data->x; md->bl.x = data->x;
md->bl.y = data->y; md->bl.y = data->y;
@ -889,10 +888,11 @@ static int mob_warpchase_sub(struct block_list *bl,va_list ap)
target_nd= va_arg(ap, struct npc_data**); target_nd= va_arg(ap, struct npc_data**);
min_distance= va_arg(ap, int*); min_distance= va_arg(ap, int*);
if(bl->subtype != WARP)
return 0; //Not a warp
nd = (TBL_NPC*) bl; nd = (TBL_NPC*) bl;
if(nd->subtype != WARP)
return 0; //Not a warp
if(nd->u.warp.mapindex != map[target->m].index) if(nd->u.warp.mapindex != map[target->m].index)
return 0; //Does not lead to the same map. return 0; //Does not lead to the same map.

View File

@ -725,7 +725,7 @@ int npc_touch_areanpc(struct map_session_data* sd, int m, int x, int y)
continue; continue;
} }
switch(map[m].npc[i]->bl.subtype) { switch(map[m].npc[i]->subtype) {
case WARP: case WARP:
xs=map[m].npc[i]->u.warp.xs; xs=map[m].npc[i]->u.warp.xs;
ys=map[m].npc[i]->u.warp.ys; ys=map[m].npc[i]->u.warp.ys;
@ -746,7 +746,7 @@ int npc_touch_areanpc(struct map_session_data* sd, int m, int x, int y)
ShowError("npc_touch_areanpc : some bug \n"); ShowError("npc_touch_areanpc : some bug \n");
return 1; return 1;
} }
switch(map[m].npc[i]->bl.subtype) { switch(map[m].npc[i]->subtype) {
case WARP: case WARP:
// hidden chars cannot use warps -- is it the same for scripts too? // hidden chars cannot use warps -- is it the same for scripts too?
if (sd->sc.option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) || if (sd->sc.option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) ||
@ -785,7 +785,7 @@ int npc_touch_areanpc2(struct block_list* bl)
if (map[m].npc[i]->sc.option&OPTION_INVISIBLE) if (map[m].npc[i]->sc.option&OPTION_INVISIBLE)
continue; continue;
if (map[m].npc[i]->bl.subtype!=WARP) if (map[m].npc[i]->subtype!=WARP)
continue; continue;
xs=map[m].npc[i]->u.warp.xs; xs=map[m].npc[i]->u.warp.xs;
@ -840,7 +840,7 @@ int npc_check_areanpc(int flag, int m, int x, int y, int range)
if (map[m].npc[i]->sc.option&OPTION_INVISIBLE) if (map[m].npc[i]->sc.option&OPTION_INVISIBLE)
continue; continue;
switch(map[m].npc[i]->bl.subtype) switch(map[m].npc[i]->subtype)
{ {
case WARP: case WARP:
if (!(flag&1)) if (!(flag&1))
@ -949,7 +949,7 @@ int npc_click(struct map_session_data* sd, struct npc_data* nd)
if (nd->class_ < 0 || nd->sc.option&(OPTION_INVISIBLE|OPTION_HIDE)) if (nd->class_ < 0 || nd->sc.option&(OPTION_INVISIBLE|OPTION_HIDE))
return 1; return 1;
switch(nd->bl.subtype) { switch(nd->subtype) {
case SHOP: case SHOP:
clif_npcbuysell(sd,nd->bl.id); clif_npcbuysell(sd,nd->bl.id);
break; break;
@ -1000,7 +1000,7 @@ int npc_buysellsel(struct map_session_data* sd, int id, int type)
if ((nd = npc_checknear(sd,map_id2bl(id))) == NULL) if ((nd = npc_checknear(sd,map_id2bl(id))) == NULL)
return 1; return 1;
if (nd->bl.subtype!=SHOP) { if (nd->subtype!=SHOP) {
ShowError("no such shop npc : %d\n",id); ShowError("no such shop npc : %d\n",id);
if (sd->npc_id == id) if (sd->npc_id == id)
sd->npc_id=0; sd->npc_id=0;
@ -1052,7 +1052,7 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list)
if (nd->master_nd) //Script-based shops. if (nd->master_nd) //Script-based shops.
return npc_buylist_sub(sd,n,item_list,nd->master_nd); return npc_buylist_sub(sd,n,item_list,nd->master_nd);
if (nd->bl.subtype!=SHOP) if (nd->subtype!=SHOP)
return 3; return 3;
for(i=0,w=0,z=0;i<n;i++) { for(i=0,w=0,z=0;i<n;i++) {
@ -1228,7 +1228,7 @@ int npc_remove_map(struct npc_data* nd)
return 1; //Not assigned to a map. return 1; //Not assigned to a map.
m = nd->bl.m; m = nd->bl.m;
clif_clearunit_area(&nd->bl,2); clif_clearunit_area(&nd->bl,2);
if (nd->bl.subtype == WARP) if (nd->subtype == WARP)
{// Remove corresponding NPC CELLs {// Remove corresponding NPC CELLs
int j, xs, ys, x, y; int j, xs, ys, x, y;
x = nd->bl.x; x = nd->bl.x;
@ -1269,7 +1269,7 @@ static int npc_unload_dup_sub(DBKey key, void* data, va_list ap)
struct npc_data *nd = (struct npc_data *)data; struct npc_data *nd = (struct npc_data *)data;
int src_id; int src_id;
if(nd->bl.type!=BL_NPC || nd->bl.subtype != SCRIPT) if(nd->bl.type!=BL_NPC || nd->subtype != SCRIPT)
return 0; return 0;
src_id=va_arg(ap,int); src_id=va_arg(ap,int);
@ -1299,10 +1299,10 @@ int npc_unload(struct npc_data* nd)
npc_chat_finalize(nd); // deallocate npc PCRE data structures npc_chat_finalize(nd); // deallocate npc PCRE data structures
#endif #endif
if( nd->bl.subtype == SHOP ) if( nd->subtype == SHOP )
aFree(nd->u.shop.shop_item); aFree(nd->u.shop.shop_item);
else else
if( nd->bl.subtype == SCRIPT ) if( nd->subtype == SCRIPT )
{ {
ev_db->foreach(ev_db,npc_unload_ev,nd->exname); //Clean up all events related. ev_db->foreach(ev_db,npc_unload_ev,nd->exname); //Clean up all events related.
if (nd->u.scr.timerid != -1) { if (nd->u.scr.timerid != -1) {
@ -1508,7 +1508,7 @@ struct npc_data* npc_add_warp(short from_mapid, short from_x, short from_y, shor
nd->u.warp.xs = xs; nd->u.warp.xs = xs;
nd->u.warp.ys = xs; nd->u.warp.ys = xs;
nd->bl.type = BL_NPC; nd->bl.type = BL_NPC;
nd->bl.subtype = WARP; nd->subtype = WARP;
npc_setcells(nd); npc_setcells(nd);
map_addblock(&nd->bl); map_addblock(&nd->bl);
status_set_viewdata(&nd->bl, nd->class_); status_set_viewdata(&nd->bl, nd->class_);
@ -1568,7 +1568,7 @@ static const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const
nd->u.warp.ys = ys; nd->u.warp.ys = ys;
npc_warp++; npc_warp++;
nd->bl.type = BL_NPC; nd->bl.type = BL_NPC;
nd->bl.subtype = WARP; nd->subtype = WARP;
npc_setcells(nd); npc_setcells(nd);
map_addblock(&nd->bl); map_addblock(&nd->bl);
status_set_viewdata(&nd->bl, nd->class_); status_set_viewdata(&nd->bl, nd->class_);
@ -1653,7 +1653,7 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const
++npc_shop; ++npc_shop;
nd->bl.type = BL_NPC; nd->bl.type = BL_NPC;
nd->bl.subtype = SHOP; nd->subtype = SHOP;
if( m >= 0 ) if( m >= 0 )
{// normal shop npc {// normal shop npc
nd->n = map_addnpc(m,nd); nd->n = map_addnpc(m,nd);
@ -1888,7 +1888,7 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons
++npc_script; ++npc_script;
nd->bl.type = BL_NPC; nd->bl.type = BL_NPC;
nd->bl.subtype = SCRIPT; nd->subtype = SCRIPT;
if( m >= 0 ) if( m >= 0 )
{ {
@ -1969,7 +1969,7 @@ void npc_setcells(struct npc_data* nd)
int m = nd->bl.m, x = nd->bl.x, y = nd->bl.y, xs, ys; int m = nd->bl.m, x = nd->bl.x, y = nd->bl.y, xs, ys;
int i,j; int i,j;
if (nd->bl.subtype == WARP) { if (nd->subtype == WARP) {
xs = nd->u.warp.xs; xs = nd->u.warp.xs;
ys = nd->u.warp.ys; ys = nd->u.warp.ys;
} else { } else {
@ -2003,7 +2003,7 @@ void npc_unsetcells(struct npc_data* nd)
int m = nd->bl.m, x = nd->bl.x, y = nd->bl.y, xs, ys; int m = nd->bl.m, x = nd->bl.x, y = nd->bl.y, xs, ys;
int i,j, x0, x1, y0, y1; int i,j, x0, x1, y0, y1;
if (nd->bl.subtype == WARP) { if (nd->subtype == WARP) {
xs = nd->u.warp.xs; xs = nd->u.warp.xs;
ys = nd->u.warp.ys; ys = nd->u.warp.ys;
} else { } else {
@ -2862,7 +2862,7 @@ int do_final_npc(void)
static void npc_debug_warps_sub(struct npc_data* nd) static void npc_debug_warps_sub(struct npc_data* nd)
{ {
int m; int m;
if (nd->bl.type != BL_NPC || nd->bl.subtype != WARP || nd->bl.m < 0) if (nd->bl.type != BL_NPC || nd->subtype != WARP || nd->bl.m < 0)
return; return;
m = map_mapindex2mapid(nd->u.warp.mapindex); m = map_mapindex2mapid(nd->u.warp.mapindex);
@ -2952,7 +2952,7 @@ int do_init_npc(void)
npc_script++; npc_script++;
fake_nd->bl.type = BL_NPC; fake_nd->bl.type = BL_NPC;
fake_nd->bl.subtype = SCRIPT; fake_nd->subtype = SCRIPT;
strdb_put(npcname_db, fake_nd->exname, fake_nd); strdb_put(npcname_db, fake_nd->exname, fake_nd);
fake_nd->u.scr.timerid = -1; fake_nd->u.scr.timerid = -1;

View File

@ -395,7 +395,6 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *pet)
pd->bl.y = pd->ud.to_y; pd->bl.y = pd->ud.to_y;
pd->bl.id = npc_get_new_npc_id(); pd->bl.id = npc_get_new_npc_id();
pd->db = mob_db(pet->class_); pd->db = mob_db(pet->class_);
pd->bl.subtype = MONS;
pd->bl.type = BL_PET; pd->bl.type = BL_PET;
pd->msd = sd; pd->msd = sd;
status_set_viewdata(&pd->bl, pet->class_); status_set_viewdata(&pd->bl, pet->class_);

View File

@ -11691,7 +11691,7 @@ BUILDIN_FUNC(callshop)
if( script_hasdata(st,3) ) if( script_hasdata(st,3) )
flag = script_getnum(st,3); flag = script_getnum(st,3);
nd = npc_name2id(shopname); nd = npc_name2id(shopname);
if (!nd || nd->bl.type!=BL_NPC || nd->bl.subtype!=SHOP) { if (!nd || nd->bl.type!=BL_NPC || nd->subtype!=SHOP) {
ShowError("buildin_callshop: Shop [%s] not found (or NPC is not shop type)\n", shopname); ShowError("buildin_callshop: Shop [%s] not found (or NPC is not shop type)\n", shopname);
script_pushint(st,0); script_pushint(st,0);
return 1; return 1;
@ -11720,7 +11720,7 @@ BUILDIN_FUNC(npcshopitem)
int n, i; int n, i;
int amount; int amount;
if( !nd || nd->bl.subtype != SHOP ) if( !nd || nd->subtype != SHOP )
{ //Not found. { //Not found.
script_pushint(st,0); script_pushint(st,0);
return 0; return 0;
@ -11749,7 +11749,7 @@ BUILDIN_FUNC(npcshopadditem)
int n, i; int n, i;
int amount; int amount;
if( !nd || nd->bl.subtype != SHOP ) if( !nd || nd->subtype != SHOP )
{ //Not found. { //Not found.
script_pushint(st,0); script_pushint(st,0);
return 0; return 0;
@ -11778,7 +11778,7 @@ BUILDIN_FUNC(npcshopdelitem)
int amount; int amount;
int size; int size;
if( !nd || nd->bl.subtype != SHOP ) if( !nd || nd->subtype != SHOP )
{ //Not found. { //Not found.
script_pushint(st,0); script_pushint(st,0);
return 0; return 0;
@ -11815,7 +11815,7 @@ BUILDIN_FUNC(npcshopattach)
if( script_hasdata(st,3) ) if( script_hasdata(st,3) )
flag = script_getnum(st,3); flag = script_getnum(st,3);
if( !nd || nd->bl.subtype != SHOP ) if( !nd || nd->subtype != SHOP )
{ //Not found. { //Not found.
script_pushint(st,0); script_pushint(st,0);
return 0; return 0;
@ -12708,7 +12708,7 @@ BUILDIN_FUNC(getvariableofnpc)
} }
nd = npc_name2id(script_getstr(st,3)); nd = npc_name2id(script_getstr(st,3));
if( nd == NULL || nd->bl.subtype != SCRIPT || nd->u.scr.script == NULL ) if( nd == NULL || nd->subtype != SCRIPT || nd->u.scr.script == NULL )
{// NPC not found or has no script {// NPC not found or has no script
ShowError("script:getvariableofnpc: can't find npc %s\n", script_getstr(st,3)); ShowError("script:getvariableofnpc: can't find npc %s\n", script_getstr(st,3));
script_pushnil(st); script_pushnil(st);

View File

@ -4180,7 +4180,7 @@ int status_get_guild_id(struct block_list *bl)
return ((TBL_HOM*)bl)->master->status.guild_id; return ((TBL_HOM*)bl)->master->status.guild_id;
break; break;
case BL_NPC: case BL_NPC:
if (bl->subtype == SCRIPT) if (((TBL_NPC*)bl)->subtype == SCRIPT)
return ((TBL_NPC*)bl)->u.scr.guild_id; return ((TBL_NPC*)bl)->u.scr.guild_id;
break; break;
case BL_SKILL: case BL_SKILL:
@ -4214,7 +4214,7 @@ int status_get_emblem_id(struct block_list *bl)
return ((TBL_HOM*)bl)->master->guild_emblem_id; return ((TBL_HOM*)bl)->master->guild_emblem_id;
break; break;
case BL_NPC: case BL_NPC:
if (bl->subtype == SCRIPT && ((TBL_NPC*)bl)->u.scr.guild_id > 0) { if (((TBL_NPC*)bl)->subtype == SCRIPT && ((TBL_NPC*)bl)->u.scr.guild_id > 0) {
struct guild *g = guild_search(((TBL_NPC*)bl)->u.scr.guild_id); struct guild *g = guild_search(((TBL_NPC*)bl)->u.scr.guild_id);
if (g) if (g)
return g->emblem_id; return g->emblem_id;

View File

@ -1724,6 +1724,7 @@ int unit_remove_map(struct block_list *bl, int clrtype)
} }
} else if (bl->type == BL_HOM) { } else if (bl->type == BL_HOM) {
struct homun_data *hd = (struct homun_data *) bl; struct homun_data *hd = (struct homun_data *) bl;
ud->canact_tick = ud->canmove_tick; //It appears HOM do reset the can-act tick.
if(!hd->homunculus.intimacy && if(!hd->homunculus.intimacy &&
!(hd->master && hd->master->state.waitingdisconnect) !(hd->master && hd->master->state.waitingdisconnect)
) { //If logging out, this is deleted on unit_free ) { //If logging out, this is deleted on unit_free