Misc changes - Fixed coke, shut up boot, fixed disabled users dispensing
authorJohn Hodge <[email protected]>
Wed, 19 Oct 2011 05:24:28 +0000 (13:24 +0800)
committerJohn Hodge <[email protected]>
Wed, 19 Oct 2011 05:24:28 +0000 (13:24 +0800)
src/server/dispense.c
src/server/handler_coke.c
src/server/itemdb.c
src/server/server.c

index 15962a3..b0a5936 100644 (file)
@@ -319,9 +319,12 @@ int _GetMinBalance(int Account)
 
 /**
  * \brief Check if a transfer is possible
 
 /**
  * \brief Check if a transfer is possible
+ * \return Boolean success
  */
 int _CanTransfer(int Source, int Destination, int Ammount)
 {
  */
 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) )
        if( Ammount > 0 )
        {
                if( Bank_GetBalance(Source) - Ammount < _GetMinBalance(Source) )
index 15cb8d3..fb58f79 100644 (file)
@@ -73,20 +73,21 @@ int Coke_InitHandler()
                // Reset the slot names.
                // - Dunno why this is needed, but the machine plays silly
                //   sometimes.
                // 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() )
                {
                if( !WaitForColon() )
                {
-                       Writef("n1 Slot1\n");
+                       Writef("n1 Slot1\r\n");
                        WaitForColon();
                        WaitForColon();
-                       Writef("n2 Slot2\n");
+                       Writef("n2 Slot2\r\n");
                        WaitForColon();
                        WaitForColon();
-                       Writef("n3 Slot3\n");
+                       Writef("n3 Slot3\r\n");
                        WaitForColon();
                        WaitForColon();
-                       Writef("n4 Slot4\n");
+                       Writef("n4 Slot4\r\n");
                        WaitForColon();
                        WaitForColon();
-                       Writef("n5 Slot5\n");
+                       Writef("n5 Slot5\r\n");
+                       WaitForColon();
+                       Writef("n6 Coke\r\n");
                        WaitForColon();
                        WaitForColon();
-                       Writef("n6 Coke\n");
                        
                        Coke_int_UpdateSlotStatuses();
                }
                        
                        Coke_int_UpdateSlotStatuses();
                }
index 49fb743..8f2cfec 100644 (file)
@@ -16,6 +16,8 @@
 #include <sys/stat.h>
 #include <time.h>
 
 #include <sys/stat.h>
 #include <time.h>
 
+#define DUMP_ITEMS     0
+
 // === IMPORTS ===
 extern tHandler        gCoke_Handler;
 extern tHandler        gSnack_Handler;
 // === 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;        
 
                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);
                printf("Item '%s' - %i cents, %s:%i\n", desc, price, type, num);
+               #endif
 
                handler = NULL;
                for( i = 0; i < giNumHandlers; i ++ )
 
                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( items[i].Handler != handler )       continue;
                        if( items[i].ID != num )        continue;
 
+                       #if DUMP_ITEMS
                        printf("Redefinition of %s:%i, updated\n", handler->Name, num);
                        printf("Redefinition of %s:%i, updated\n", handler->Name, num);
+                       #endif
                        items[i].Price = price;
                        free(items[i].Name);
                        items[i].Name = strdup(desc);
                        items[i].Price = price;
                        free(items[i].Name);
                        items[i].Name = strdup(desc);
index 32e4c10..1faa6fe 100644 (file)
@@ -18,8 +18,9 @@
 #include <string.h>
 #include <limits.h>
 #include <stdarg.h>
 #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
 
 #define        DEBUG_TRACE_CLIENT      0
 #define HACK_NO_REFUNDS        1
@@ -166,6 +167,7 @@ void Server_Start(void)
                }
                if( pid != 0 ) {
                        // Parent, quit
                }
                if( pid != 0 ) {
                        // Parent, quit
+                       printf("Forked child %i\n", pid);
                        exit(0);
                }
                // In child
                        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);
                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
        }
 
                #endif
        }
 

UCC git Repository :: git.ucc.asn.au