unsigned short editable_event::name_to_value ( const std::string & name, editable_event::category_t cat ) { unsigned short result = SEQ64_END_OF_MIDIBYTE_TABLE; if (! name.empty()) { const editable_event::name_value_t * const table = editable_event::sm_category_arrays[cat]; midibyte counter = 0; while (table[counter].event_value != SEQ64_END_OF_MIDIBYTE_TABLE) { if (strings_match(table[counter].event_name, name)) { result = table[counter].event_value; break; } ++counter; } } return result; }
bool dungeon_type::has_visible_terrain() { feature_type *f_ptr = &f_info[FEAT_NONE]; if (dun_char != f_ptr->d_char) return true; if (dun_color != f_ptr->d_color) return true; if (use_graphics) { if (!strings_match(dun_tile, f_ptr->tile_id)) return true; } return false; }
void create_changesets (database_t * db) { size_t total_versions = 0; for (file_t * i = db->files; i != db->files_end; ++i) total_versions += i->versions_end - i->versions; if (total_versions == 0) return; version_t ** version_list = ARRAY_ALLOC (version_t *, total_versions); version_t ** vp = version_list; for (file_t * i = db->files; i != db->files_end; ++i) for (version_t * j = i->versions; j != i->versions_end; ++j) *vp++ = j; assert (vp == version_list + total_versions); qsort (version_list, total_versions, sizeof (version_t *), version_compare_qsort); changeset_t * current = database_new_changeset (db); ARRAY_APPEND (current->versions, version_list[0]); version_list[0]->commit = current; current->time = version_list[0]->time; current->type = ct_commit; for (size_t i = 1; i < total_versions; ++i) { version_t * next = version_list[i]; if (!strings_match (*current->versions, next) || next->time - current->time > fuzz_span || next->time - current->versions_end[-1]->time > fuzz_gap) { ARRAY_TRIM (current->versions); current = database_new_changeset (db); current->time = next->time; current->type = ct_commit; } ARRAY_APPEND (current->versions, version_list[i]); version_list[i]->commit = current; } ARRAY_TRIM (current->versions); free (version_list); // Do a pass through the changesets; this breaks any cycles. heap_t ready_versions; heap_init (&ready_versions, offsetof (version_t, ready_index), version_compare_heap); prepare_for_emission (db, &ready_versions); ssize_t emitted_changesets = 0; changeset_t * changeset; while ((changeset = next_changeset_split (db, &ready_versions))) { changeset_emitted (db, &ready_versions, changeset); ++emitted_changesets; } // Sort the changeset version lists by file. for (changeset_t ** i = db->changesets; i != db->changesets_end; ++i) ARRAY_SORT ((*i)->versions, compare_version_by_file); assert (heap_empty (&ready_versions)); assert (heap_empty (&db->ready_changesets)); assert (emitted_changesets == db->changesets_end - db->changesets); heap_destroy (&ready_versions); }
void KeyboardCommandList::add_keyboard_commands(QGridLayout *return_layout) { int x = 0; int command_count = 0; // Count the number of help commands while (TRUE) { command_desc *cmd_ptr; if (which_keyset == KEYSET_NEW) cmd_ptr = &list_commands_new[x++]; else if (which_keyset == KEYSET_ANGBAND) cmd_ptr = &list_commands_angband[x++]; else /* KEYSET_ROGUE */ cmd_ptr = &list_commands_roguelike[x++]; // Null pointer means we are done if (!cmd_ptr->command_title.length()) break; command_count++; } command_count = (command_count / 3) + 1; x = 0; int row = 0; int col_count = 0; while (TRUE) { command_desc *cmd_ptr; if (which_keyset == KEYSET_NEW) cmd_ptr = &list_commands_new[x++]; else if (which_keyset == KEYSET_ANGBAND) cmd_ptr = &list_commands_angband[x++]; else /* KEYSET_ROGUE */ cmd_ptr = &list_commands_roguelike[x++]; if (row == command_count) { col_count++; row = 0; } int col = col_count * 4; // Null pointer means we are done if (!cmd_ptr->command_title.length()) break; QPointer<QLabel> this_title = new QLabel(); make_standard_label(this_title, QString(cmd_ptr->command_title), TERM_BLUE); return_layout->addWidget(this_title, row, col++, Qt::AlignLeft); QPointer<QLabel> dummy = new QLabel(" "); return_layout->addWidget(dummy, row, col++); QPointer<QLabel> this_key = new QLabel(); make_standard_label(this_key, QString(cmd_ptr->command_key), TERM_BLUE); // HTML throws off the display of this character if (strings_match(QString(cmd_ptr->command_key), QString("<"))) { this_key->setText("<"); this_key->setStyleSheet("color: blue; font-weight: bold;"); } return_layout->addWidget(this_key, row, col++, Qt::AlignLeft); if (col_count < 2) { QPointer<QLabel> dummy = new QLabel(" "); return_layout->addWidget(dummy, row, col); } row++; } QPointer<QLabel> dummy = new QLabel(" "); return_layout->addWidget(dummy, row, 0); }