string query_look() { string look; calculate_totals(); look = this_object()->query_long()+"The box has "+total+" coins in it, "+ "worth "+total_value+" silvers: "+silver+" silver, "+gold+" gold, "+ ""+platinum+" platinum, and "+mithril+" mithril.\n"; return look; }
int add_command(string cmd) { int number; string type; if(cmd) { sscanf(cmd, "%d %s", number, type); } if(number && type) { if(number > 30000 || total + number > 30000) { message("info","You can't fit more than 30000 coins inside the box.\n", this_player()); } else if(this_player()->debit(type,number)) { message("info","You put "+number+" "+type+" coins into the box.\n", this_player()); message("info",""+this_player()->query_cap_name()+" puts "+number+" "+ ""+type+" coins into "+possessive(this_player())+" box.\n", environment(this_player()),this_player()); coins=clone_object("/std/coins.c"); coins->set_type(type); coins->set_number(number); coins->move(this_object(),1); calculate_totals(); } else { message("info","You don't seem to have "+number+" "+type+" coins.\n", this_player()); } return 1; } return notify_fail("Syntax: 'add <number> <coin type>'\n"); }
void analyse_data() { hash_node_type* n = NULL; if(options.paused == 1) { return; } // Zero totals memset(&totals, 0, sizeof totals); if(options.freezeorder) { screen_hash_clear(); } else { screen_list_clear(); hash_delete_all(screen_hash); } while(hash_next_item(history, &n) == HASH_STATUS_OK) { history_type* d = (history_type*)n->rec; host_pair_line* screen_line; union { host_pair_line **h_p_l_pp; void **void_pp; } u_screen_line = { &screen_line }; addr_pair ap; int i; int tsent, trecv; tsent = trecv = 0; ap = *(addr_pair*)n->key; /* Aggregate hosts, if required */ if(options.aggregate_src) { memset(&ap.src6, '\0', sizeof(ap.src6)); } if(options.aggregate_dest) { memset(&ap.dst6, '\0', sizeof(ap.dst6)); } /* Aggregate ports, if required */ if(options.showports == OPTION_PORTS_DEST || options.showports == OPTION_PORTS_OFF) { ap.src_port = 0; } if(options.showports == OPTION_PORTS_SRC || options.showports == OPTION_PORTS_OFF) { ap.dst_port = 0; } if(options.showports == OPTION_PORTS_OFF) { ap.protocol = 0; } if(hash_find(screen_hash, &ap, u_screen_line.void_pp) == HASH_STATUS_KEY_NOT_FOUND) { screen_line = xcalloc(1, sizeof *screen_line); hash_insert(screen_hash, &ap, screen_line); screen_line->ap = ap; } screen_line->total_sent += d->total_sent; screen_line->total_recv += d->total_recv; for(i = 0; i < HISTORY_LENGTH; i++) { int j; int ii = (HISTORY_LENGTH + history_pos - i) % HISTORY_LENGTH; for(j = 0; j < HISTORY_DIVISIONS; j++) { if(i < history_divs[j]) { screen_line->recv[j] += d->recv[ii]; screen_line->sent[j] += d->sent[ii]; } } } } make_screen_list(); calculate_totals(); }