After a rage with TRS, allowed `dispense acct` to take -ve, disabled new background...
[tpg/opendispense2.git] / src / client / main.c
index ddc0e39..342441a 100644 (file)
@@ -661,7 +661,7 @@ int ShowNCursesUI(void)
                username = pwd->pw_name;
        }
        // Get balance
-       snprintf(balance_str, sizeof balance_str, "$%i.%02i", giUserBalance/100, giUserBalance%100);
+       snprintf(balance_str, sizeof balance_str, "$%i.%02i", giUserBalance/100, abs(giUserBalance)%100);
        
        // Enter curses mode
        initscr();
@@ -885,6 +885,8 @@ int ShowItemAt(int Row, int Col, int Width, int Index, int bHilighted)
        // Width = 0, don't print
        if( Width > 0 )
        {
+               // 4 preceding, 5 price
+               int nameWidth = Width - 4 - 5;
                move( Row, Col );
                
                if( Index >= 0 )
@@ -894,26 +896,26 @@ int ShowItemAt(int Row, int Col, int Width, int Index, int bHilighted)
                        {
                        case 0:
                                if( bHilighted )
-                                       printw("-> ");
+                                       printw("->  ");
                                else
-                                       printw("   ");
+                                       printw("    ");
                                break;
                        case 1:
-                               printw("SLD");
+                               printw("SLD ");
                                break;
                        
                        default:
                        case -1:
-                               printw("ERR");
+                               printw("ERR ");
                                break;
                        }
                        
-                       printw(" %s", name);
+                       printw("%-*.*s", nameWidth, nameWidth, name);
                
-                       getyx(stdscr, _y, _x);
+//                     getyx(stdscr, _y, _x);
                        // Assumes max 4 digit prices
-                       times = Width - 5 - (_x - Col); // TODO: Better handling for large prices
-                       while(times--)  addch(' ');
+//                     times = Width - 5 - (_x - Col); // TODO: Better handling for large prices
+//                     while(times--)  addch(' ');
                        
                        printw(" %4i", price);
                }
@@ -1486,6 +1488,12 @@ int Dispense_AlterBalance(int Socket, const char *Username, int Ammount, const c
                printf("Dry Run - No action\n");
                return 0;
        }
+
+       // Sanity
+       if( Ammount == 0 ) {
+               printf("An ammount would be nice\n");
+               return 1;
+       }
        
        sendf(Socket, "ADD %s %i %s\n", Username, Ammount, Reason);
        buf = ReadLine(Socket);
@@ -1561,13 +1569,13 @@ int Dispense_Give(int Socket, const char *Username, int Ammount, const char *Rea
        
        if( Ammount < 0 ) {
                printf("Sorry, you can only give, you can't take.\n");
-               return -1;
+               return 1;
        }
        
        // Fast return on zero
        if( Ammount == 0 ) {
                printf("Are you actually going to give any?\n");
-               return 0;
+               return 1;
        }
        
        // Check for a dry run
@@ -1621,7 +1629,7 @@ int Dispense_Donate(int Socket, int Ammount, const char *Reason)
        // Fast return on zero
        if( Ammount == 0 ) {
                printf("Are you actually going to give any?\n");
-               return 0;
+               return 1;
        }
        
        // Check for a dry run

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