removed getTextBot() function and added textbot parameter to the CMD_BIND header...
[NeonServV5.git] / src / modules / NeonFun.mod / cmd_neonfun_4wins.c
index a282a144d836c2e65e5f9d386b3072d9eb6ba4aa..5a9c5876905ce2f56c94317a4d7540bbc3f3181c 100644 (file)
@@ -36,6 +36,11 @@ CMD_BIND(neonfun_cmd_4wins) {
         timeq_del(game->timer);
         game->timer = NULL;
         game->state = FOURWINS_STATE_RUNNING;
+        if((game->player[0]->user->flags & USERFLAG_ISAUTHED) && (game->player[1]->user->flags & USERFLAG_ISAUTHED) && !stricmp(game->player[0]->user->auth, game->player[1]->user->auth)) {
+            fourwins_reply(game, "NF_4WINS_SELF");
+            fourwins_free_game(game);
+            return;
+        }
         fourwins_reply(game, "NF_4WINS_START", user->nick);
         if((game->player[0]->user->flags & USERFLAG_ISAUTHED)) {
             char *tmp;
@@ -66,28 +71,32 @@ CMD_BIND(neonfun_cmd_4wins) {
         game->timer = timeq_add(120, module_id, fourwins_timeout, game);
     } else {
         if(!argc) {
-            reply(getTextBot(), user, "NF_4WINS_ENTER_OPPONENT");
+            reply(textclient, user, "NF_4WINS_ENTER_OPPONENT");
             return;
         }
         struct UserNode *opp_user = getUserByNick(argv[0]);
         if(!opp_user) {
-            reply(getTextBot(), user, "NS_USER_UNKNOWN", argv[0]);
+            reply(textclient, user, "NS_USER_UNKNOWN", argv[0]);
+            return;
+        }
+        if(opp_user == user) {
+            reply(textclient, user, "NF_4WINS_SELF");
             return;
         }
         struct ChanUser *opponent = getChanUser(opp_user, chan);
         if(!opponent) {
-            reply(getTextBot(), user, "NF_4WINS_OPPONENT_NOT_IN_CHAN", opp_user->nick);
+            reply(textclient, user, "NF_4WINS_OPPONENT_NOT_IN_CHAN", opp_user->nick);
             return;
         }
         game = calloc(1,sizeof(*game));
         game->player[0] = chanuser;
         game->player[1] = opponent;
-        game->textbot = getTextBot();
+        game->textbot = textclient;
         game->state = FOURWINS_STATE_WAITING;
         game->timer = timeq_add(120, module_id, fourwins_timeout, game);
         game->next = fourwins_active_games;
         fourwins_active_games = game;
-        reply(getTextBot(), user, "NF_4WINS_REQUESTED", opp_user->nick);
-        reply(getTextBot(), opp_user, "NF_4WINS_REQUEST", user->nick);
+        reply(textclient, user, "NF_4WINS_REQUESTED", opp_user->nick);
+        reply(textclient, opp_user, "NF_4WINS_REQUEST", user->nick);
     }
 }