summaryrefslogtreecommitdiff
path: root/src/map/chat.c
diff options
context:
space:
mode:
authorshennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-01-18 09:04:28 +0000
committershennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-01-18 09:04:28 +0000
commitbea3f9774fe6134d927002d8f7a9b68f2c2d37fd (patch)
tree1078f6767ff8b5b345d06822c70f855620d68808 /src/map/chat.c
parent72305739e4c89c8c95175fb700c59756c4a1631c (diff)
downloadhercules-bea3f9774fe6134d927002d8f7a9b68f2c2d37fd.tar.gz
hercules-bea3f9774fe6134d927002d8f7a9b68f2c2d37fd.tar.bz2
hercules-bea3f9774fe6134d927002d8f7a9b68f2c2d37fd.tar.xz
hercules-bea3f9774fe6134d927002d8f7a9b68f2c2d37fd.zip
Optimized chat room kicking (r15487) so that it doesn't alloc a db map unnecessarily since NPC chats do not kick players.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15488 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/chat.c')
-rw-r--r--src/map/chat.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/map/chat.c b/src/map/chat.c
index e2e5077e6..48c0b07f1 100644
--- a/src/map/chat.c
+++ b/src/map/chat.c
@@ -58,7 +58,8 @@ static struct chat_data* chat_createchat(struct block_list* bl, const char* titl
map_addiddb(&cd->bl);
- cd->kick_list = idb_alloc(DB_OPT_BASE);
+ if( bl->type != BL_NPC )
+ cd->kick_list = idb_alloc(DB_OPT_BASE);
return cd;
}
@@ -144,7 +145,7 @@ int chat_joinchat(struct map_session_data* sd, int chatid, const char* pass)
return 0;
}
- if( idb_exists(cd->kick_list,sd->status.char_id) ) {
+ if( cd->owner->type != BL_NPC && idb_exists(cd->kick_list,sd->status.char_id) ) {
clif_joinchatfail(sd,2);//You have been kicked out of the room.
return 0;
}
@@ -200,10 +201,9 @@ int chat_leavechat(struct map_session_data* sd, bool kicked)
cd->usersd[i] = cd->usersd[i+1];
- if( cd->users == 0 && cd->owner->type == BL_PC )
- { // Delete empty chatroom
+ if( cd->users == 0 && cd->owner->type == BL_PC ) { // Delete empty chatroom
clif_clearchat(cd, 0);
- cd->kick_list->destroy(cd->kick_list, NULL);
+ db_destroy(cd->kick_list);
map_deliddb(&cd->bl);
map_delblock(&cd->bl);
map_freeblock(&cd->bl);
@@ -331,22 +331,19 @@ int chat_createnpcchat(struct npc_data* nd, const char* title, int limit, bool p
struct chat_data* cd;
nullpo_ret(nd);
- if( nd->chat_id )
- {
+ if( nd->chat_id ) {
ShowError("chat_createnpcchat: npc '%s' already has a chatroom, cannot create new one!\n", nd->exname);
return 0;
}
- if( zeny > MAX_ZENY || maxLvl > MAX_LEVEL )
- {
+ if( zeny > MAX_ZENY || maxLvl > MAX_LEVEL ) {
ShowError("chat_createnpcchat: npc '%s' has a required lvl or amount of zeny over the max limit!\n", nd->exname);
return 0;
}
cd = chat_createchat(&nd->bl, title, "", limit, pub, trigger, ev, zeny, minLvl, maxLvl);
- if( cd )
- {
+ if( cd ) {
nd->chat_id = cd->bl.id;
clif_dispchat(cd,0);
}