diff options
author | ai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2011-05-14 11:04:30 +0000 |
---|---|---|
committer | ai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2011-05-14 11:04:30 +0000 |
commit | 1a89ef9c1411199ebdfdf87837613a35b72914f1 (patch) | |
tree | d62b4d4734df140d036c5b58aa6c018088b56a47 /src/map/mob.c | |
parent | 6f305abdd5de99afd4114d9ed1d9b4df1f166980 (diff) | |
download | hercules-1a89ef9c1411199ebdfdf87837613a35b72914f1.tar.gz hercules-1a89ef9c1411199ebdfdf87837613a35b72914f1.tar.bz2 hercules-1a89ef9c1411199ebdfdf87837613a35b72914f1.tar.xz hercules-1a89ef9c1411199ebdfdf87837613a35b72914f1.zip |
* 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://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14817 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/mob.c')
-rw-r--r-- | src/map/mob.c | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/src/map/mob.c b/src/map/mob.c index ccb4ab923..0a99b83b1 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -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] - 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; - 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); + if( npc_event_isspecial(data->eventname) ) + {//Portable monster big/small implementation. [Skotlex] + int 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; } + data->eventname[0] = '\0'; //Clear event as it is not used. + } + 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; } |