projects
/
NeonServV5.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a023e2e
)
fixed event_neonserv_mode.c multi-thread support
author
pk910
<philipp@zoelle1.de>
Mon, 6 Feb 2012 15:16:46 +0000
(16:16 +0100)
committer
pk910
<philipp@zoelle1.de>
Mon, 6 Feb 2012 15:16:46 +0000
(16:16 +0100)
src/event_neonserv_mode.c
patch
|
blob
|
history
diff --git
a/src/event_neonserv_mode.c
b/src/event_neonserv_mode.c
index ef8bf77e77fccaca4f19157d8342dbd062f5ac7e..f0794a906b7aa30db06ba1fb9e5e62360cedb239 100644
(file)
--- a/
src/event_neonserv_mode.c
+++ b/
src/event_neonserv_mode.c
@@
-17,9
+17,7
@@
static USERLIST_CALLBACK(neonserv_event_mode_userlist_lookup);
static void neonserv_event_mode_async1(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, char *modes, char **argv, int argc);
static USERLIST_CALLBACK(neonserv_event_mode_userlist_lookup);
static void neonserv_event_mode_async1(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, char *modes, char **argv, int argc);
-static int neonserv_cmd_mode_botwar_detect(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan);
-
-static int botwar_detect_executed;
+static int neonserv_cmd_mode_botwar_detect(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, int *botwar_detect_executed);
struct neonserv_event_mode_cache {
struct ClientSocket *client;
struct neonserv_event_mode_cache {
struct ClientSocket *client;
@@
-73,7
+71,7
@@
static USERLIST_CALLBACK(neonserv_event_mode_userlist_lookup) {
static void neonserv_event_mode_async1(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, char *modes, char **argv, int argc) {
struct ClientSocket *textclient = ((client->flags & SOCKET_FLAG_PREFERRED) ? client : get_prefered_bot(client->botid));
static void neonserv_event_mode_async1(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, char *modes, char **argv, int argc) {
struct ClientSocket *textclient = ((client->flags & SOCKET_FLAG_PREFERRED) ? client : get_prefered_bot(client->botid));
- botwar_detect_executed = 0;
+
int
botwar_detect_executed = 0;
MYSQL_ROW row, defaults = NULL;
int i, arg, add = 1, skip = 0;
unsigned int modetype;
MYSQL_ROW row, defaults = NULL;
int i, arg, add = 1, skip = 0;
unsigned int modetype;
@@
-131,7
+129,7
@@
static void neonserv_event_mode_async1(struct ClientSocket *client, struct UserN
caccess = getChannelAccess(cuser, chan);
if(modes[i] == 'o' && !add && cuser == client->user) {
//someone deopped the bot???
caccess = getChannelAccess(cuser, chan);
if(modes[i] == 'o' && !add && cuser == client->user) {
//someone deopped the bot???
- if(!neonserv_cmd_mode_botwar_detect(client, user, chan))
+ if(!neonserv_cmd_mode_botwar_detect(client, user, chan
, &botwar_detect_executed
))
requestOp(client->user, chan);
}
if((modes[i] == 'o' || (modes[i] == 'h' && !with_halfops)) && !(add && isBot(cuser))) {
requestOp(client->user, chan);
}
if((modes[i] == 'o' || (modes[i] == 'h' && !with_halfops)) && !(add && isBot(cuser))) {
@@
-142,7
+140,7
@@
static void neonserv_event_mode_async1(struct ClientSocket *client, struct UserN
deop_user = 1;
}
if(db_canop == -1 && caccess < db_getop) {
deop_user = 1;
}
if(db_canop == -1 && caccess < db_getop) {
- if(!neonserv_cmd_mode_botwar_detect(client, user, chan))
+ if(!neonserv_cmd_mode_botwar_detect(client, user, chan
, &botwar_detect_executed
))
modeBufferSet(modeBuf, !add, modes[i], carg);
break;
}
modeBufferSet(modeBuf, !add, modes[i], carg);
break;
}
@@
-154,7
+152,7
@@
static void neonserv_event_mode_async1(struct ClientSocket *client, struct UserN
deop_user = 1;
}
if(db_canhalfop == -1 && caccess < db_gethalfop) {
deop_user = 1;
}
if(db_canhalfop == -1 && caccess < db_gethalfop) {
- if(!neonserv_cmd_mode_botwar_detect(client, user, chan))
+ if(!neonserv_cmd_mode_botwar_detect(client, user, chan
, &botwar_detect_executed
))
modeBufferSet(modeBuf, !add, modes[i], carg);
break;
}
modeBufferSet(modeBuf, !add, modes[i], carg);
break;
}
@@
-166,7
+164,7
@@
static void neonserv_event_mode_async1(struct ClientSocket *client, struct UserN
deop_user = 1;
}
if(db_canvoice == -1 && caccess < db_getvoice) {
deop_user = 1;
}
if(db_canvoice == -1 && caccess < db_getvoice) {
- if(!neonserv_cmd_mode_botwar_detect(client, user, chan))
+ if(!neonserv_cmd_mode_botwar_detect(client, user, chan
, &botwar_detect_executed
))
modeBufferSet(modeBuf, !add, modes[i], carg);
break;
}
modeBufferSet(modeBuf, !add, modes[i], carg);
break;
}
@@
-176,13
+174,13
@@
static void neonserv_event_mode_async1(struct ClientSocket *client, struct UserN
if(isBot(cuser)) {
//don't send this - just try to reop
//reply(textclient, user, "NS_SERVICE_IMMUNE", cuser->nick);
if(isBot(cuser)) {
//don't send this - just try to reop
//reply(textclient, user, "NS_SERVICE_IMMUNE", cuser->nick);
- if(!neonserv_cmd_mode_botwar_detect(client, user, chan))
+ if(!neonserv_cmd_mode_botwar_detect(client, user, chan
, &botwar_detect_executed
))
modeBufferSet(modeBuf, !add, modes[i], carg);
break;
}
if(isUserProtected(chan, cuser, user)) {
reply(textclient, user, "NS_USER_PROTECTED", cuser->nick);
modeBufferSet(modeBuf, !add, modes[i], carg);
break;
}
if(isUserProtected(chan, cuser, user)) {
reply(textclient, user, "NS_USER_PROTECTED", cuser->nick);
- if(!neonserv_cmd_mode_botwar_detect(client, user, chan))
+ if(!neonserv_cmd_mode_botwar_detect(client, user, chan
, &botwar_detect_executed
))
modeBufferSet(modeBuf, !add, modes[i], carg);
if(uaccess < db_getop)
deop_user = 1;
modeBufferSet(modeBuf, !add, modes[i], carg);
if(uaccess < db_getop)
deop_user = 1;
@@
-200,7
+198,7
@@
static void neonserv_event_mode_async1(struct ClientSocket *client, struct UserN
db_canban = -1;
}
if(db_canban == -1) {
db_canban = -1;
}
if(db_canban == -1) {
- if(!neonserv_cmd_mode_botwar_detect(client, user, chan))
+ if(!neonserv_cmd_mode_botwar_detect(client, user, chan
, &botwar_detect_executed
))
modeBufferSet(modeBuf, !add, modes[i], carg);
if(uaccess < db_getop)
deop_user = 1;
modeBufferSet(modeBuf, !add, modes[i], carg);
if(uaccess < db_getop)
deop_user = 1;
@@
-228,7
+226,7
@@
static void neonserv_event_mode_async1(struct ClientSocket *client, struct UserN
}
}
if(skip) {
}
}
if(skip) {
- if(!neonserv_cmd_mode_botwar_detect(client, user, chan))
+ if(!neonserv_cmd_mode_botwar_detect(client, user, chan
, &botwar_detect_executed
))
modeBufferSet(modeBuf, !add, modes[i], carg);
if(uaccess < db_getop)
deop_user = 1;
modeBufferSet(modeBuf, !add, modes[i], carg);
if(uaccess < db_getop)
deop_user = 1;
@@
-255,7
+253,7
@@
static void neonserv_event_mode_async1(struct ClientSocket *client, struct UserN
if(uaccess < db_getop)
deop_user = 1;
}
if(uaccess < db_getop)
deop_user = 1;
}
- if(!neonserv_cmd_mode_botwar_detect(client, user, chan))
+ if(!neonserv_cmd_mode_botwar_detect(client, user, chan
, &botwar_detect_executed
))
modeBufferSet(modeBuf, add, modes[i], modelock_val);
break;
}
modeBufferSet(modeBuf, add, modes[i], modelock_val);
break;
}
@@
-271,7
+269,7
@@
static void neonserv_event_mode_async1(struct ClientSocket *client, struct UserN
deop_user = 1;
}
sprintf(tmp, "%d", *modelock_val);
deop_user = 1;
}
sprintf(tmp, "%d", *modelock_val);
- if(!neonserv_cmd_mode_botwar_detect(client, user, chan))
+ if(!neonserv_cmd_mode_botwar_detect(client, user, chan
, &botwar_detect_executed
))
modeBufferSet(modeBuf, add, modes[i], tmp);
break;
}
modeBufferSet(modeBuf, add, modes[i], tmp);
break;
}
@@
-291,30
+289,30
@@
static void neonserv_event_mode_async1(struct ClientSocket *client, struct UserN
if(uaccess < db_getop)
deop_user = 1;
}
if(uaccess < db_getop)
deop_user = 1;
}
- if(!neonserv_cmd_mode_botwar_detect(client, user, chan))
+ if(!neonserv_cmd_mode_botwar_detect(client, user, chan
, &botwar_detect_executed
))
modeBufferSet(modeBuf, !add, modes[i], carg);
break;
}
break;
}
}
modeBufferSet(modeBuf, !add, modes[i], carg);
break;
}
break;
}
}
- if(deop_user && !neonserv_cmd_mode_botwar_detect(client, user, chan)) {
+ if(deop_user && !neonserv_cmd_mode_botwar_detect(client, user, chan
, &botwar_detect_executed
)) {
modeBufferDeop(modeBuf, user->nick);
}
freeModeBuffer(modeBuf);
freeModeNode(modelock);
}
modeBufferDeop(modeBuf, user->nick);
}
freeModeBuffer(modeBuf);
freeModeNode(modelock);
}
-static int neonserv_cmd_mode_botwar_detect(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan) {
+static int neonserv_cmd_mode_botwar_detect(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan
, int *botwar_detect_executed
) {
struct ChanUser *chanuser = getChanUser(user, chan);
if(!chanuser) return 0; //flying super cow?
if(time(0) - chanuser->changeTime > BOTWAR_DETECTION_TIME) {
chanuser->changeTime = time(0);
chanuser->chageEvents = 1;
} else {
struct ChanUser *chanuser = getChanUser(user, chan);
if(!chanuser) return 0; //flying super cow?
if(time(0) - chanuser->changeTime > BOTWAR_DETECTION_TIME) {
chanuser->changeTime = time(0);
chanuser->chageEvents = 1;
} else {
- if(!botwar_detect_executed)
+ if(!
*
botwar_detect_executed)
chanuser->chageEvents++;
chanuser->chageEvents++;
- botwar_detect_executed = 1;
+
*
botwar_detect_executed = 1;
if(chanuser->chageEvents >= BOTWAR_DETECTION_EVENTS || chanuser->chageEvents < 0) {
//BOTWAR!
chanuser->changeTime = time(0);
if(chanuser->chageEvents >= BOTWAR_DETECTION_EVENTS || chanuser->chageEvents < 0) {
//BOTWAR!
chanuser->changeTime = time(0);