summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-11-23 15:11:22 +0000
committerai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-11-23 15:11:22 +0000
commite9abbffca3b9e007a14a795d481c4b720d7f590e (patch)
tree6363c1dd1724f59583ac6508c4de33946b84be53 /src
parent6c4eb13453184c70239c9c9b874ccab495741497 (diff)
downloadhercules-e9abbffca3b9e007a14a795d481c4b720d7f590e.tar.gz
hercules-e9abbffca3b9e007a14a795d481c4b720d7f590e.tar.bz2
hercules-e9abbffca3b9e007a14a795d481c4b720d7f590e.tar.xz
hercules-e9abbffca3b9e007a14a795d481c4b720d7f590e.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/trunk@14495 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/map/script.c37
1 files changed, 31 insertions, 6 deletions
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;
}