From 0e15ed888a4d398530a74a6b713414e649767358 Mon Sep 17 00:00:00 2001
From: John Hodge <tpg@ucc.asn.au>
Date: Wed, 19 Oct 2011 13:24:28 +0800
Subject: [PATCH] Misc changes - Fixed coke, shut up boot, fixed disabled users
 dispensing

---
 src/server/dispense.c     |  3 +++
 src/server/handler_coke.c | 15 ++++++++-------
 src/server/itemdb.c       |  6 ++++++
 src/server/server.c       |  8 ++++++--
 4 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/src/server/dispense.c b/src/server/dispense.c
index 15962a3..b0a5936 100644
--- a/src/server/dispense.c
+++ b/src/server/dispense.c
@@ -319,9 +319,12 @@ int _GetMinBalance(int Account)
 
 /**
  * \brief Check if a transfer is possible
+ * \return Boolean success
  */
 int _CanTransfer(int Source, int Destination, int Ammount)
 {
+	if( Bank_GetFlags(Source) & USER_FLAG_DISABLED )
+		return 0;
 	if( Ammount > 0 )
 	{
 		if( Bank_GetBalance(Source) - Ammount < _GetMinBalance(Source) )
diff --git a/src/server/handler_coke.c b/src/server/handler_coke.c
index 15cb8d3..fb58f79 100644
--- a/src/server/handler_coke.c
+++ b/src/server/handler_coke.c
@@ -73,20 +73,21 @@ int Coke_InitHandler()
 		// Reset the slot names.
 		// - Dunno why this is needed, but the machine plays silly
 		//   sometimes.
-		Writef("n0 Slot0\n");
+		Writef("n0 Slot0\r\n");
 		if( !WaitForColon() )
 		{
-			Writef("n1 Slot1\n");
+			Writef("n1 Slot1\r\n");
 			WaitForColon();
-			Writef("n2 Slot2\n");
+			Writef("n2 Slot2\r\n");
 			WaitForColon();
-			Writef("n3 Slot3\n");
+			Writef("n3 Slot3\r\n");
 			WaitForColon();
-			Writef("n4 Slot4\n");
+			Writef("n4 Slot4\r\n");
 			WaitForColon();
-			Writef("n5 Slot5\n");
+			Writef("n5 Slot5\r\n");
+			WaitForColon();
+			Writef("n6 Coke\r\n");
 			WaitForColon();
-			Writef("n6 Coke\n");
 			
 			Coke_int_UpdateSlotStatuses();
 		}
diff --git a/src/server/itemdb.c b/src/server/itemdb.c
index 49fb743..8f2cfec 100644
--- a/src/server/itemdb.c
+++ b/src/server/itemdb.c
@@ -16,6 +16,8 @@
 #include <sys/stat.h>
 #include <time.h>
 
+#define DUMP_ITEMS	0
+
 // === IMPORTS ===
 extern tHandler	gCoke_Handler;
 extern tHandler	gSnack_Handler;
@@ -169,7 +171,9 @@ void Items_ReadFromFile(void)
 		price = atoi( line + matches[3].rm_so );
 		desc  = line + matches[4].rm_so;	
 
+		#if DUMP_ITEMS
 		printf("Item '%s' - %i cents, %s:%i\n", desc, price, type, num);
+		#endif
 
 		handler = NULL;
 		for( i = 0; i < giNumHandlers; i ++ )
@@ -190,7 +194,9 @@ void Items_ReadFromFile(void)
 			if( items[i].Handler != handler )	continue;
 			if( items[i].ID != num )	continue;
 
+			#if DUMP_ITEMS
 			printf("Redefinition of %s:%i, updated\n", handler->Name, num);
+			#endif
 			items[i].Price = price;
 			free(items[i].Name);
 			items[i].Name = strdup(desc);
diff --git a/src/server/server.c b/src/server/server.c
index 32e4c10..1faa6fe 100644
--- a/src/server/server.c
+++ b/src/server/server.c
@@ -18,8 +18,9 @@
 #include <string.h>
 #include <limits.h>
 #include <stdarg.h>
-#include <signal.h>
-#include <ident.h>
+#include <signal.h>	// Signal handling
+#include <ident.h>	// AUTHIDENT
+#include <time.h>	// time(2)
 
 #define	DEBUG_TRACE_CLIENT	0
 #define HACK_NO_REFUNDS	1
@@ -166,6 +167,7 @@ void Server_Start(void)
 		}
 		if( pid != 0 ) {
 			// Parent, quit
+			printf("Forked child %i\n", pid);
 			exit(0);
 		}
 		// In child
@@ -178,6 +180,8 @@ void Server_Start(void)
 		freopen("/dev/null", "r", stdin);
 		freopen(gsServer_LogFile, "a", stdout);
 		freopen(gsServer_ErrorLog, "a", stderr);
+		fprintf(stdout, "OpenDispense 2 Server Started at %lld\n", (long long)time(NULL));
+		fprintf(stderr, "OpenDispense 2 Server Started at %lld\n", (long long)time(NULL));
 		#endif
 	}
 
-- 
GitLab