From: John Hodge Date: Sat, 14 Jan 2012 16:18:29 +0000 (+0800) Subject: Added zero-cost testing hack X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=5ea4314d1ee0769f8b521df2c81fe65f3a654959;p=tpg%2Fopendispense2.git Added zero-cost testing hack --- diff --git a/src/server/common.h b/src/server/common.h index 004fbf8..7ad01c5 100644 --- a/src/server/common.h +++ b/src/server/common.h @@ -73,6 +73,7 @@ extern int giNumItems; extern tHandler *gaHandlers[]; extern int giNumHandlers; extern int giDebugLevel; +extern int gbNoCostMode; // === FUNCTIONS === extern void Items_UpdateFile(void); diff --git a/src/server/handler_coke.c b/src/server/handler_coke.c index a899ad5..61b2649 100644 --- a/src/server/handler_coke.c +++ b/src/server/handler_coke.c @@ -223,6 +223,7 @@ int Coke_int_DropSlot(int Slot) if( res == 0 ) { // Oops!, no drink + printf("Drink dispense failed, bit lowered too quickly\n"); return 1; } diff --git a/src/server/itemdb.c b/src/server/itemdb.c index 8f2cfec..632eb50 100644 --- a/src/server/itemdb.c +++ b/src/server/itemdb.c @@ -207,7 +207,10 @@ void Items_ReadFromFile(void) items = realloc( items, (numItems + 1)*sizeof(items[0]) ); items[numItems].Handler = handler; items[numItems].ID = num; - items[numItems].Price = price; + if( gbNoCostMode ) + items[numItems].Price = 0; + else + items[numItems].Price = price; items[numItems].Name = strdup(desc); items[numItems].bHidden = (line[0] == '-'); numItems ++; diff --git a/src/server/main.c b/src/server/main.c index c2ef55c..f2f66c3 100644 --- a/src/server/main.c +++ b/src/server/main.c @@ -36,6 +36,7 @@ void *Periodic_Thread(void *Unused); // === GLOBALS === int giDebugLevel = 0; + int gbNoCostMode = 0; const char *gsCokebankPath = "cokebank.db"; // - Functions called every 20s (or so) #define ciMaxPeriodics 10 @@ -121,7 +122,9 @@ int main(int argc, char *argv[]) gsCoke_ModbusAddress = Config_GetValue("coke_modbus_address", 0); giServer_Port = Config_GetValue_Int("server_port", 0); gsItemListFile = Config_GetValue("items_file", 0); - + + gbNoCostMode = Config_GetValue_Bool("test_mode", 0); + signal(SIGINT, sigint_handler); signal(SIGTERM, sigint_handler); diff --git a/src/server/server.c b/src/server/server.c index e392f73..63b4aa7 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -731,7 +731,7 @@ void Server_int_SendItem(tClient *Client, tItem *Item) } } - if( Item->Price == 0 ) + if( !gbNoCostMode && Item->Price == 0 ) status = "error"; // KNOWN HACK: Naming a slot 'dead' disables it if( strcmp(Item->Name, "dead") == 0 )