Changed ENUM_ITEMS to the ENUM_USERS format
[tpg/opendispense2.git] / src / server / server.c
index b072652..85e2025 100644 (file)
@@ -395,13 +395,16 @@ void Server_Cmd_ENUMITEMS(tClient *Client, char *Args)
 {
         int    i;
 
-       sendf(Client->Socket, "201 Items %i", giNumItems);
+       sendf(Client->Socket, "201 Items %i\n", giNumItems);
 
        for( i = 0; i < giNumItems; i ++ ) {
-               sendf(Client->Socket, " %s:%i", gaItems[i].Handler->Name, gaItems[i].ID);
+               sendf(Client->Socket,
+                       "202 Item %s:%i %i %s\n",
+                        gaItems[i].Handler->Name, gaItems[i].ID, gaItems[i].Price, gaItems[i].Name
+                        );
        }
 
-       sendf(Client->Socket, "\n");
+       sendf(Client->Socket, "200 List end\n");
 }
 
 tItem *_GetItemFromString(char *String)
@@ -516,7 +519,7 @@ void Server_Cmd_GIVE(tClient *Client, char *Args)
        // Get recipient
        uid = GetUserID(recipient);
        if( uid == -1 ) {
-               sendf(Client->Socket, "404 Invalid target user");
+               sendf(Client->Socket, "404 Invalid target user\n");
                return ;
        }
 
@@ -571,11 +574,15 @@ void Server_Cmd_ADD(tClient *Client, char *Args)
        reason ++;
 
        // TODO: Check if the current user is in coke/higher
+       if( (GetFlags(Client->UID) & USER_FLAG_TYPEMASK) < USER_TYPE_COKE ) {
+               sendf(Client->Socket, "403 Not in coke\n");
+               return ;
+       }
 
        // Get recipient
        uid = GetUserID(user);
        if( uid == -1 ) {
-               sendf(Client->Socket, "404 Invalid user");
+               sendf(Client->Socket, "404 Invalid user\n");
                return ;
        }
 

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