Esempio n. 1
0
File: land.c Progetto: Dinth/naev
/**
 * @brief Updates the commodity window.
 *    @param wid Window to update.
 *    @param str Unused.
 */
static void commodity_update( unsigned int wid, char* str )
{
   (void)str;
   char buf[PATH_MAX];
   char *comname;
   Commodity *com;

   comname = toolkit_getList( wid, "lstGoods" );
   if ((comname==NULL) || (strcmp( comname, "None" )==0)) {
      snprintf( buf, PATH_MAX,
         "NA Tons\n"
         "NA Credits/Ton\n"
         "\n"
         "NA Tons\n" );
      window_modifyText( wid, "txtDInfo", buf );
      window_modifyText( wid, "txtDesc", "No outfits available." );
   }
   com = commodity_get( comname );

   /* modify text */
   snprintf( buf, PATH_MAX,
         "%d Tons\n"
         "%"CREDITS_PRI" Credits/Ton\n"
         "\n"
         "%d Tons\n",
         pilot_cargoOwned( player.p, comname ),
         planet_commodityPrice( land_planet, com ),
         pilot_cargoFree(player.p));
   window_modifyText( wid, "txtDInfo", buf );
   window_modifyText( wid, "txtDesc", com->description );
}
Esempio n. 2
0
static int commodity_canSell( char *name )
{
   int failure;

   failure = 0;

   if (pilot_cargoOwned( player.p, name ) == 0) {
      land_errDialogueBuild("You can't sell something you don't have!");
      failure = 1;
   }

   return !failure;
}