aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/save.c1
-rw-r--r--src/sell.c4
-rw-r--r--src/util.c12
3 files changed, 7 insertions, 10 deletions
diff --git a/src/save.c b/src/save.c
index 9028bb4..6cd2af2 100644
--- a/src/save.c
+++ b/src/save.c
@@ -64,7 +64,6 @@ void save_handler(struct player_t *player)
struct history_item *hist = stock->history;
while(hist)
{
- printf("WRITING HISTORY ITEM %d\n", hist->action);
write_be32(f, hist->action);
write_be64(f, hist->count);
write_be64(f, hist->price.cents);
diff --git a/src/sell.c b/src/sell.c
index e490711..af4a9aa 100644
--- a/src/sell.c
+++ b/src/sell.c
@@ -19,7 +19,9 @@ void sell_handler(struct player_t *player)
return;
}
- update_handler(player);
+ printf("Updating prices...\n");
+
+ get_stock_info(stock->symbol, &stock->current_price, &stock->fullname);
printf("You currently own %llu shares of '%s' (%s) valued at $%llu.%02llu each.\n",
stock->count, stock->fullname, stock->symbol, stock->current_price.cents / 100, stock->current_price.cents % 100);
diff --git a/src/util.c b/src/util.c
index eb50566..11da5c7 100644
--- a/src/util.c
+++ b/src/util.c
@@ -109,15 +109,12 @@ bool get_stock_info(char *symbol, struct money_t *price, char **name_ret)
free(buf.data);
- /* remove the decimal point */
+ ullong dollars, cents;
- for(int i = 0; i < price_len; ++i)
- {
- if(pricebuf[i] == '.')
- memmove(pricebuf + i, pricebuf + i + 1, price_len - i);
- }
+ /* dirty hack! */
+ sscanf(pricebuf, "%llu.%2llu", &dollars, &cents);
- price->cents = strtoull(pricebuf, NULL, 10);
+ price->cents = dollars * 100 + cents;
free(pricebuf);
@@ -199,7 +196,6 @@ uint16_t to_sys16(uint16_t n)
struct stock_t *find_stock(struct player_t *player, char *sym)
{
- printf("find stock %s\n", sym);
for(int i = 0; i < player->portfolio_len; ++i)
{
if(strcmp(player->portfolio[i].symbol, sym) == 0)