[NeoStats-Devel] [Commits] r76 - branches/3.0

[email protected]
Newsgroups gmane.comp.neostats.devel
Message-ID <[email protected]>
Author: DNB
Date: Sat Apr  2 14:40:46 2005
New Revision: 76

Modified:
   branches/3.0/TriviaChan.c
   branches/3.0/TriviaCmds.c
   branches/3.0/TriviaServ.c
Log:
!start and !stop now check if started or stopped to prevent segfaults
when first joining channel games are set to stop to prevent segfaults
code tidyups
cosmetic message errors fixed

Modified: branches/3.0/TriviaChan.c
==============================================================================
--- branches/3.0/TriviaChan.c	(original)
+++ branches/3.0/TriviaChan.c	Sat Apr  2 14:40:46 2005
@@ -138,6 +138,8 @@
 	if (tcn != NULL) {
 		tc = hnode_get(tcn);
 		tc->c = c;
+		tc->active = 0;
+		tc->curquest = NULL;
 		SetChannelModValue (c, tc);
 		if (tc->opchan) {
 			irc_join (tvs_bot, tc->name, "+o");

Modified: branches/3.0/TriviaCmds.c
==============================================================================
--- branches/3.0/TriviaCmds.c	(original)
+++ branches/3.0/TriviaCmds.c	Sat Apr  2 14:40:46 2005
@@ -92,10 +92,14 @@
 		/* nope, get lost, silently exit */
 		return NS_FAILURE;
 	}
-	tc->active = 1;
-	tc->curquest = NULL;
-	irc_prefmsg (tvs_bot, cmdparams->source, "Starting Trivia in %s shortly", tc->name);
-	irc_chanprivmsg (tvs_bot, tc->name, "%s has activated Trivia. Get Ready for the first question!", cmdparams->source->name);
+	if (!tc->active) {
+		tc->active = 1;
+		tc->curquest = NULL;
+		irc_prefmsg (tvs_bot, cmdparams->source, "Starting Trivia in %s shortly", tc->name);
+		irc_chanprivmsg (tvs_bot, tc->name, "%s has activated Trivia. Get Ready for the first question!", cmdparams->source->name);
+	} else {
+		irc_prefmsg (tvs_bot, cmdparams->source, "Trivia is already running in %s", tc->name);
+	}
 	return NS_SUCCESS;
 }
 
@@ -115,12 +119,16 @@
 		/* nope, get lost, silently exit */
 		return NS_FAILURE;
 	}
-	tc->active = 0;
-	if (tc->curquest != NULL) {
-		tc->curquest = NULL;
+	if (tc->active) {
+		tc->active = 0;
+		if (tc->curquest != NULL) {
+			tc->curquest = NULL;
+		}
+		irc_prefmsg (tvs_bot, cmdparams->source, "Trivia Stoped in %s", tc->name);
+		irc_chanprivmsg (tvs_bot, tc->name, "%s has stopped Trivia.", cmdparams->source->name);
+	} else {
+		irc_prefmsg (tvs_bot, cmdparams->source, "Trivia is not currently running in %s", tc->name);
 	}
-	irc_prefmsg (tvs_bot, cmdparams->source, "Trivia Stoped in %s", tc->name);
-	irc_chanprivmsg (tvs_bot, tc->name, "%s has stopped Trivia.", cmdparams->source->name);
 	return NS_SUCCESS;
 }
 

Modified: branches/3.0/TriviaServ.c
==============================================================================
--- branches/3.0/TriviaServ.c	(original)
+++ branches/3.0/TriviaServ.c	Sat Apr  2 14:40:46 2005
@@ -404,7 +404,7 @@
 	TriviaChan *tc;
 	hscan_t hs;
 	hnode_t *hnodes;
-	time_t timediff;	
+	time_t timediff;
 
 	/* reseed the random generator */
 	if (!(rand() % 4)) 
@@ -427,7 +427,7 @@
 			}
 			/* hint processor */
 			if ((tc->questtime - timediff) < 15) {
-				irc_chanprivmsg (tvs_bot, tc->name, "Less than 15 Seconds Remaining, Hurry up!");
+				irc_chanprivmsg (tvs_bot, tc->name, "Less than %ld Seconds Remaining, Hurry up!", (long)(tc->questtime - timediff + 10));
 				continue;
 			}
 			do_hint(tc);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.