* Some NPC event related cleaning.
- Made event label deprecation message a warning rather than an error, as the scripts still work regardless of whether '::On' is used or not (since r6592). - Introduced constant EVENT_NAME_LENGTH (51) for all event name struct fields to eliminate size inconsistency across all objects (was 50 and 51). - Fixed event names, that are considered special attributes, were not wiped when the value was 0 (since r5707). git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@14817 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
f34de92ef0
commit
aaab80fb80
@ -1,6 +1,10 @@
|
||||
Date Added
|
||||
|
||||
2011/05/14
|
||||
* Some NPC event related cleaning. [Ai4rei]
|
||||
- Made event label deprecation message a warning rather than an error, as the scripts still work regardless of whether '::On' is used or not (since r6592).
|
||||
- Introduced constant EVENT_NAME_LENGTH (51) for all event name struct fields to eliminate size inconsistency across all objects (was 50 and 51).
|
||||
- Fixed event names, that are considered special attributes, were not wiped when the value was 0 (since r5707).
|
||||
* Removed impossible condition in mob_parse_dataset as spawn_data::eventname was/is the same size as mob_data::npc_event (since r5707). [Ai4rei]
|
||||
* Fixed map-server printing deprecation message, when monster event label was used as transport for special attributes (small/large monsters etc.) in script command 'monster' and related commands (bugreport:1274, since r6592, related r5707). [Ai4rei]
|
||||
2011/05/13
|
||||
|
@ -22,8 +22,8 @@ struct battleground_data {
|
||||
// BG Cementery
|
||||
unsigned short mapindex, x, y;
|
||||
// Logout Event
|
||||
char logout_event[50];
|
||||
char die_event[50];
|
||||
char logout_event[EVENT_NAME_LENGTH];
|
||||
char die_event[EVENT_NAME_LENGTH];
|
||||
};
|
||||
|
||||
void do_init_battleground(void);
|
||||
|
@ -22,7 +22,7 @@ struct chat_data {
|
||||
uint32 maxLvl; // maximum base level allowed to join
|
||||
struct map_session_data* usersd[20];
|
||||
struct block_list* owner;
|
||||
char npc_event[50];
|
||||
char npc_event[EVENT_NAME_LENGTH];
|
||||
};
|
||||
|
||||
|
||||
|
@ -36,7 +36,7 @@ static DBMap* guild_infoevent_db; // int guild_id -> struct eventlist*
|
||||
static DBMap* guild_castleinfoevent_db; // int castle_id_index -> struct eventlist*
|
||||
|
||||
struct eventlist {
|
||||
char name[50];
|
||||
char name[EVENT_NAME_LENGTH];
|
||||
struct eventlist *next;
|
||||
};
|
||||
|
||||
@ -1545,7 +1545,7 @@ int guild_broken(int guild_id,int flag)
|
||||
struct guild_castle *gc=NULL;
|
||||
struct map_session_data *sd;
|
||||
int i;
|
||||
char name[50];
|
||||
char name[EVENT_NAME_LENGTH];
|
||||
|
||||
if(flag!=0 || g==NULL)
|
||||
return 0;
|
||||
|
@ -159,6 +159,8 @@ enum {
|
||||
#define CHATROOM_PASS_SIZE (8 + 1)
|
||||
//Max allowed chat text length
|
||||
#define CHAT_SIZE_MAX (255 + 1)
|
||||
//24 for npc name + 24 for label + 2 for a "::" and 1 for EOS
|
||||
#define EVENT_NAME_LENGTH ( NAME_LENGTH * 2 + 3 )
|
||||
|
||||
#define DEFAULT_AUTOSAVE_INTERVAL 5*60*1000
|
||||
|
||||
@ -268,7 +270,7 @@ struct spawn_data {
|
||||
unsigned ai :2; //Holds if mob is special ai.
|
||||
unsigned dynamic :1; //Whether this data is indexed by a map's dynamic mob list
|
||||
} state;
|
||||
char name[NAME_LENGTH],eventname[50]; //Name/event
|
||||
char name[NAME_LENGTH],eventname[EVENT_NAME_LENGTH]; //Name/event
|
||||
};
|
||||
|
||||
|
||||
|
@ -160,7 +160,8 @@ struct view_data * mob_get_viewdata(int class_)
|
||||
*------------------------------------------*/
|
||||
int mob_parse_dataset(struct spawn_data *data)
|
||||
{
|
||||
int i;
|
||||
size_t len;
|
||||
|
||||
//FIXME: This implementation is not stable, npc scripts will stop working once MAX_MOB_DB changes value! [Skotlex]
|
||||
if(data->class_ > 2*MAX_MOB_DB){ // large/tiny mobs [Valaris]
|
||||
data->state.size=2;
|
||||
@ -173,32 +174,33 @@ int mob_parse_dataset(struct spawn_data *data)
|
||||
if ((!mobdb_checkid(data->class_) && !mob_is_clone(data->class_)) || !data->num)
|
||||
return 0;
|
||||
|
||||
if (data->eventname[0])
|
||||
if( npc_event_isspecial(data->eventname) )
|
||||
{//Portable monster big/small implementation. [Skotlex]
|
||||
int i = atoi(data->eventname);
|
||||
|
||||
if( i )
|
||||
{
|
||||
if(npc_event_isspecial(data->eventname))
|
||||
{ //Portable monster big/small implementation. [Skotlex]
|
||||
i = atoi(data->eventname);
|
||||
if (i) {
|
||||
if (i&2)
|
||||
data->state.size=1;
|
||||
else if (i&4)
|
||||
data->state.size=2;
|
||||
if (i&8)
|
||||
data->state.ai=1;
|
||||
if( i&2 )
|
||||
data->state.size = 1;
|
||||
else if( i&4 )
|
||||
data->state.size = 2;
|
||||
if( i&8 )
|
||||
data->state.ai = 1;
|
||||
}
|
||||
data->eventname[0] = '\0'; //Clear event as it is not used.
|
||||
}
|
||||
} else if( ( i = strlen(data->eventname) ) > 0 ) {
|
||||
if (data->eventname[i-1] == '"')
|
||||
data->eventname[i-1] = '\0'; //Remove trailing quote.
|
||||
if (data->eventname[0] == '"') //Strip leading quotes
|
||||
memmove(data->eventname, data->eventname+1, i-1);
|
||||
}
|
||||
else if( ( len = strlen(data->eventname) ) > 0 )
|
||||
{
|
||||
if( data->eventname[len-1] == '"' )
|
||||
data->eventname[len-1] = '\0'; //Remove trailing quote.
|
||||
if( data->eventname[0] == '"' ) //Strip leading quotes
|
||||
memmove(data->eventname, data->eventname+1, len-1);
|
||||
}
|
||||
|
||||
if(strcmp(data->name,"--en--")==0)
|
||||
strncpy(data->name,mob_db(data->class_)->name,NAME_LENGTH-1);
|
||||
safestrncpy(data->name, mob_db(data->class_)->name, sizeof(data->name));
|
||||
else if(strcmp(data->name,"--ja--")==0)
|
||||
strncpy(data->name,mob_db(data->class_)->jname,NAME_LENGTH-1);
|
||||
safestrncpy(data->name, mob_db(data->class_)->jname, sizeof(data->name));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ struct mob_data {
|
||||
|
||||
short skillidx;
|
||||
unsigned int skilldelay[MAX_MOBSKILL];
|
||||
char npc_event[50];
|
||||
char npc_event[EVENT_NAME_LENGTH];
|
||||
};
|
||||
|
||||
|
||||
|
@ -105,7 +105,7 @@ struct view_data* npc_get_viewdata(int class_)
|
||||
|
||||
int npc_ontouch_event(struct map_session_data *sd, struct npc_data *nd)
|
||||
{
|
||||
char name[NAME_LENGTH*2+3];
|
||||
char name[EVENT_NAME_LENGTH];
|
||||
|
||||
if( nd->touching_id )
|
||||
return 0; // Attached a player already. Can't trigger on anyone else.
|
||||
@ -119,7 +119,7 @@ int npc_ontouch_event(struct map_session_data *sd, struct npc_data *nd)
|
||||
|
||||
int npc_ontouch2_event(struct map_session_data *sd, struct npc_data *nd)
|
||||
{
|
||||
char name[NAME_LENGTH*2+3];
|
||||
char name[EVENT_NAME_LENGTH];
|
||||
|
||||
if( sd->areanpc_id == nd->bl.id )
|
||||
return 0;
|
||||
@ -245,7 +245,7 @@ int npc_event_export(char* lname, void* data, va_list ap)
|
||||
|
||||
if ((lname[0]=='O' || lname[0]=='o')&&(lname[1]=='N' || lname[1]=='n')) {
|
||||
struct event_data *ev;
|
||||
char buf[NAME_LENGTH*2+3];
|
||||
char buf[EVENT_NAME_LENGTH];
|
||||
char* p = strchr(lname, ':');
|
||||
// ƒGƒNƒXƒ|<7C>[ƒg‚³‚ê‚é
|
||||
ev = (struct event_data *) aMalloc(sizeof(struct event_data));
|
||||
@ -644,7 +644,7 @@ void npc_timerevent_quit(struct map_session_data* sd)
|
||||
// Execute OnTimerQuit
|
||||
if( nd && nd->bl.type == BL_NPC )
|
||||
{
|
||||
char buf[NAME_LENGTH*2+3];
|
||||
char buf[EVENT_NAME_LENGTH];
|
||||
struct event_data *ev;
|
||||
|
||||
snprintf(buf, ARRAYLENGTH(buf), "%s::OnTimerQuit", nd->exname);
|
||||
@ -821,7 +821,7 @@ int npc_touchnext_areanpc(struct map_session_data* sd, bool leavemap)
|
||||
sd->bl.y < nd->bl.y - ys || sd->bl.y > nd->bl.y + ys ||
|
||||
pc_ishiding(sd) || leavemap )
|
||||
{
|
||||
char name[NAME_LENGTH*2+3];
|
||||
char name[EVENT_NAME_LENGTH];
|
||||
|
||||
nd->touching_id = sd->touching_id = 0;
|
||||
snprintf(name, ARRAYLENGTH(name), "%s::%s", nd->exname, script_config.ontouch_name);
|
||||
@ -902,7 +902,7 @@ int npc_touch_areanpc(struct map_session_data* sd, int m, int x, int y)
|
||||
int npc_touch_areanpc2(struct mob_data *md)
|
||||
{
|
||||
int i, m = md->bl.m, x = md->bl.x, y = md->bl.y, id;
|
||||
char eventname[NAME_LENGTH*2+3];
|
||||
char eventname[EVENT_NAME_LENGTH];
|
||||
struct event_data* ev;
|
||||
int xs, ys;
|
||||
|
||||
@ -1152,7 +1152,7 @@ int npc_buysellsel(struct map_session_data* sd, int id, int type)
|
||||
//npc_buylist for script-controlled shops.
|
||||
static int npc_buylist_sub(struct map_session_data* sd, int n, unsigned short* item_list, struct npc_data* nd)
|
||||
{
|
||||
char npc_ev[NAME_LENGTH*2+3];
|
||||
char npc_ev[EVENT_NAME_LENGTH];
|
||||
int i;
|
||||
int key_nameid = 0;
|
||||
int key_amount = 0;
|
||||
@ -1387,7 +1387,7 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list)
|
||||
/// npc_selllist for script-controlled shops
|
||||
static int npc_selllist_sub(struct map_session_data* sd, int n, unsigned short* item_list, struct npc_data* nd)
|
||||
{
|
||||
char npc_ev[NAME_LENGTH*2+3];
|
||||
char npc_ev[EVENT_NAME_LENGTH];
|
||||
int i, idx;
|
||||
int key_nameid = 0;
|
||||
int key_amount = 0;
|
||||
@ -2219,7 +2219,7 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons
|
||||
if ((lname[0] == 'O' || lname[0] == 'o') && (lname[1] == 'N' || lname[1] == 'n'))
|
||||
{
|
||||
struct event_data* ev;
|
||||
char buf[NAME_LENGTH*2+3]; // 24 for npc name + 24 for label + 2 for a "::" and 1 for EOS
|
||||
char buf[EVENT_NAME_LENGTH];
|
||||
snprintf(buf, ARRAYLENGTH(buf), "%s::%s", nd->exname, lname);
|
||||
|
||||
// generate the data and insert it
|
||||
@ -2407,7 +2407,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch
|
||||
if ((lname[0] == 'O' || lname[0] == 'o') && (lname[1] == 'N' || lname[1] == 'n'))
|
||||
{
|
||||
struct event_data* ev;
|
||||
char buf[NAME_LENGTH*2+3]; // 24 for npc name + 24 for label + 2 for a "::" and 1 for EOS
|
||||
char buf[EVENT_NAME_LENGTH];
|
||||
snprintf(buf, ARRAYLENGTH(buf), "%s::%s", nd->exname, lname);
|
||||
|
||||
// generate the data and insert it
|
||||
|
@ -378,7 +378,7 @@ struct map_session_data {
|
||||
unsigned short pvp_rank, pvp_lastusers;
|
||||
unsigned short pvp_won, pvp_lost;
|
||||
|
||||
char eventqueue[MAX_EVENTQUEUE][NAME_LENGTH*2+3];
|
||||
char eventqueue[MAX_EVENTQUEUE][EVENT_NAME_LENGTH];
|
||||
int eventtimer[MAX_EVENTTIMER];
|
||||
unsigned short eventcount; // [celest]
|
||||
|
||||
|
@ -585,7 +585,7 @@ static void check_event(struct script_state *st, const char *evt)
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowError("NPC event parameter deprecated! Please use 'NPCNAME::OnEVENT' instead of '%s'.\n", evt);
|
||||
ShowWarning("NPC event parameter deprecated! Please use 'NPCNAME::OnEVENT' instead of '%s'.\n", evt);
|
||||
script_reportsrc(st);
|
||||
}
|
||||
}
|
||||
@ -8187,8 +8187,8 @@ BUILDIN_FUNC(cmdothernpc) // Added by RoVeRT
|
||||
{
|
||||
const char* npc = script_getstr(st,2);
|
||||
const char* command = script_getstr(st,3);
|
||||
char event[51];
|
||||
snprintf(event, 51, "%s::OnCommand%s", npc, command);
|
||||
char event[EVENT_NAME_LENGTH];
|
||||
snprintf(event, sizeof(event), "%s::OnCommand%s", npc, command);
|
||||
check_event(st, event);
|
||||
npc_event_do(event);
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user