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

[email protected]
Newsgroups gmane.comp.neostats.devel
Message-ID <[email protected]>
Author: DNB
Date: Thu Mar 31 22:25:28 2005
New Revision: 70

Modified:
   branches/3.0/TriviaQues.c
   branches/3.0/TriviaServ.h
   branches/3.0/TriviaUser.c
Log:
code tidyups

Modified: branches/3.0/TriviaQues.c
==============================================================================
--- branches/3.0/TriviaQues.c	(original)
+++ branches/3.0/TriviaQues.c	Thu Mar 31 22:25:28 2005
@@ -164,10 +164,9 @@
 		SaveTChan(tc);
 		return;
 	} else {
-		irc_prefmsg (tvs_bot, cmdparams->source, "Syntax Error. /msg %s help !set", tvs_bot->name);
+		irc_prefmsg (tvs_bot, cmdparams->source, "Syntax Error. /msg %s help QS", tvs_bot->name);
 	}
 	return;		
-	irc_prefmsg (tvs_bot, cmdparams->source, "%s used Set", cmdparams->source->name);
 }
 
 /*

Modified: branches/3.0/TriviaServ.h
==============================================================================
--- branches/3.0/TriviaServ.h	(original)
+++ branches/3.0/TriviaServ.h	Thu Mar 31 22:25:28 2005
@@ -82,11 +82,9 @@
 } TriviaChan;
 
 typedef struct TriviaChannelScore {
-	char *prev;
 	char cname[MAXCHANLEN];
 	int score;
 	int lastused;
-	char *next;
 } TriviaChannelScore;
 
 typedef struct TriviaUser {
@@ -94,7 +92,7 @@
 	char lastregnick[MAXNICK];
 	int networkscore;
 	int lastused;
-	TriviaChannelScore *tcs;
+	list_t *tcsl;
 } TriviaUser;
 
 list_t *qfl;

Modified: branches/3.0/TriviaUser.c
==============================================================================
--- branches/3.0/TriviaUser.c	(original)
+++ branches/3.0/TriviaUser.c	Thu Mar 31 22:25:28 2005
@@ -36,8 +36,9 @@
 void tvs_addpoints(Client *u, TriviaChan *tc) 
 {
 	TriviaUser *tu;
-	TriviaChannelScore *ts, *tsn;
+	TriviaChannelScore *ts;
 	Questions *qe;
+	lnode_t *ln;
 	
 	if (!u | !tc->curquest) {
 		nlog(LOG_WARNING, "Can't find user for AddPoints?!");
@@ -54,31 +55,28 @@
 		tu->lastusednick[0] = '\0';
 		tu->networkscore = 0;
 		tu->lastused = 0;
+		tu->tcsl = list_create(-1);
 		ts = ns_calloc(sizeof(TriviaChannelScore));
-		tu->tcs = ts;
-		ts->prev = NULL;
 		strlcpy(ts->cname, tc->c->name, MAXNICK);
 		ts->score = 0;
 		ts->lastused = 0;
-		ts->next = NULL;
+		lnode_create_append(tu->tcsl, ts);
 		SetUserModValue (u, tu);
 	} else {
-		ts = tu->tcs;
-		/* not really a perm loop, just looks like one */
-		while (0 == 0) {
+		ln = list_first(tu->tcsl);
+		while (ln != NULL) {
+			ts = lnode_get(ln);
 			if (!ircstrcasecmp(tc->c->name, ts->cname)) {
 				break;
 			}
-			if (ts->next == NULL) {
-				tsn = ns_calloc(sizeof(TriviaChannelScore));
-				tsn->prev = ts;
-				strlcpy(tsn->cname, tc->c->name, MAXNICK);
-				tsn->score = 0;
-				tsn->lastused = 0;
-				tsn->next = NULL;
-				ts->next = tsn;
-			}
-			ts = ts->next;
+			ln = list_next(tu->tcsl, ln);
+		}
+		if (ln == NULL) {
+			ts = ns_calloc(sizeof(TriviaChannelScore));
+			strlcpy(ts->cname, tc->c->name, MAXNICK);
+			ts->score = 0;
+			ts->lastused = 0;
+			lnode_create_append(tu->tcsl, ts);
 		}
 	}
 	strlcpy(tu->lastusednick, u->name, MAXNICK);
@@ -117,22 +115,20 @@
 
 int UserLeaving (Client *u) {
 	TriviaUser *tu;
-	TriviaChannelScore *ts, *tsp;
+	TriviaChannelScore *ts;
+	lnode_t *ln;
 	
 	tu = (TriviaUser *)GetUserModValue(u);
 	if (tu) {
-		ts = tu->tcs;
-		while (ts->next != NULL) {
-			ts = ts->next;
-		}
-		while (ts->prev != NULL) {
-			tsp = ts;
-			ts = tsp->prev;
-			ts->next = NULL;
-			ns_free(tsp);
+		while (list_count(tu->tcsl) > 0) {
+			ln = list_first(tu->tcsl);
+			ts = lnode_get(ln);
+			ns_free(ts);
+			list_delete(tu->tcsl, ln);
+			lnode_destroy(ln);
 		}
-		tu->tcs = NULL;
-		ns_free(ts);
+		list_destroy_auto(tu->tcsl);
+		tu->tcsl = NULL;
 		ns_free(tu);
 	}
 	return NS_SUCCESS;
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.