diff options
author | ai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2010-11-23 15:11:22 +0000 |
---|---|---|
committer | ai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2010-11-23 15:11:22 +0000 |
commit | 1dd1fafb2935fa55585889d299afce18b3eb7cd5 (patch) | |
tree | 14bba87f5e639ef4b61dff5ecd921919c16abf3f | |
parent | 326bb46c02abb20c39239b2067f3bf4df884cbe3 (diff) | |
download | hercules-1dd1fafb2935fa55585889d299afce18b3eb7cd5.tar.gz hercules-1dd1fafb2935fa55585889d299afce18b3eb7cd5.tar.bz2 hercules-1dd1fafb2935fa55585889d299afce18b3eb7cd5.tar.xz hercules-1dd1fafb2935fa55585889d299afce18b3eb7cd5.zip |
* Fixed script command getusers causing map server to crash when called with type 0 without attached character (bugreport:4565).
- Lack of character is now reported like other script commands do. Additionally invalid types are reported as well.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/renewal@14495 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r-- | Changelog-Renewal.txt | 4 | ||||
-rw-r--r-- | src/map/script.c | 37 |
2 files changed, 34 insertions, 7 deletions
diff --git a/Changelog-Renewal.txt b/Changelog-Renewal.txt index a24133031..5b17814e7 100644 --- a/Changelog-Renewal.txt +++ b/Changelog-Renewal.txt @@ -8,7 +8,9 @@ Date Added - Fixed data type inconsistency in @statuspoint and @skillpoint (since r5762, related r13541). - Silenced truncation warnings in CR_ACIDDEMONSTRATION damage calculation and cardfix application (since r13700). - Reformatted unit_blown to make it look cleaner (follow up to r14492). - * Labels longer than 23 characters will no longer cause the server to exit immediately (bugreport:4563, since r1213). + * Labels longer than 23 characters will no longer cause the server to exit immediately (bugreport:4563, since r1213). [Ai4rei] + * Fixed script command getusers causing map server to crash when called with type 0 without attached character (bugreport:4565). [Ai4rei] + - Lack of character is now reported like other script commands do. Additionally invalid types are reported as well. 2010/11/22 * mail_deliveryfail no longer attempts to log (since r12910) and give items (since r11855), when there is no item attached to the mail (bugreport:3239). [Ai4rei] * Fixed a crash when shutting down char-server (TXT only), after it failed to load storage save data (since r1275). [Ai4rei] diff --git a/src/map/script.c b/src/map/script.c index 906dce510..c71debc0d 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -8220,13 +8220,38 @@ BUILDIN_FUNC(areaannounce) *------------------------------------------*/ BUILDIN_FUNC(getusers) { - int flag=script_getnum(st,2); - struct block_list *bl=map_id2bl((flag&0x08)?st->oid:st->rid); - int val=0; - switch(flag&0x07){ - case 0: val=map[bl->m].users; break; - case 1: val=map_getusers(); break; + int flag, val = 0; + struct map_session_data* sd; + struct block_list* bl = NULL; + + flag = script_getnum(st,2); + + if(flag&0x8) + {// npc + bl = map_id2bl(st->oid); } + else if((sd = script_rid2sd(st))!=NULL) + {// pc + bl = &sd->bl; + } + + switch(flag&0x07) + { + case 0: + if(bl) + { + val = map[bl->m].users; + } + break; + case 1: + val = map_getusers(); + break; + default: + ShowWarning("buildin_getusers: Unknown type %d.\n", flag); + script_pushint(st,0); + return 1; + } + script_pushint(st,val); return 0; } |