void Score::addStaff(unsigned int where) { if(where == 0){ staffs.push_back(Staff()); }else{ staffs.insert(staffs.begin()+(where-1), Staff()); } }
Staff Utils::GetStaffByStaffNo(CString staff_no) { Staff staff; staff.setNo(staff_no); MYSQL mysql; MYSQL_RES *result = NULL; SQLUtils* sqlutils = new SQLUtils("localhost","root","root","work_database",3306); mysql_init(&mysql); string serverName = sqlutils->getServerName(); string userName = sqlutils->getUserName(); string password = sqlutils->getPassword(); string databaseName = sqlutils->getDatabaseName(); int port = sqlutils->getPort(); if (mysql_real_connect(&mysql,serverName.c_str(),userName.c_str(),password.c_str(),databaseName.c_str(),port,NULL,0)) { mysql_set_character_set(&mysql, "gbk"); string sql = "select staff_name, staff_sex, staff_duty, staff_tel from t_staff where staff_no = "; sql.append(1,'\'').append(staff_no).append(1,'\''); mysql_query(&mysql,sql.c_str()); result = mysql_store_result(&mysql); int fieldcount = mysql_num_fields(result); MYSQL_ROW row = NULL; row = mysql_fetch_row(result); while(NULL != row) { for(int i=0; i<fieldcount; i++) { switch(i){ case 0: staff.setName(row[i]); break; case 1: staff.setSex(row[i]); break; case 2: staff.setDuty(row[i]); break; case 3: staff.setTel(row[i]); } } row = mysql_fetch_row(result); } mysql_close(&mysql); return staff; } else{ AfxMessageBox("系统出错"); } return Staff(); }
/* --------------------------------------------------------------------------- * fh_staff: only STAFF, WIZARDS, ROYALTY, (or GOD) may set or clear * the bit. */ static bool fh_staff ( dbref target, dbref player, FLAG flag, int fflags, bool reset ) { if (!Staff(player) && !God(player)) { return false; } return (fh_any(target, player, flag, fflags, reset)); }
bool has_flag(dbref player, dbref it, const UTF8 *flagname) { FLAGNAMEENT *fp = find_flag(flagname); if (!fp) { return false; } FLAGBITENT *fbe = fp->fbe; if ( ( fp->bPositive && (db[it].fs.word[fbe->flagflag] & fbe->flagvalue)) || ( !fp->bPositive && (db[it].fs.word[fbe->flagflag] & fbe->flagvalue) == 0)) { if ( ( (fbe->listperm & CA_STAFF) && !Staff(player)) || ( (fbe->listperm & CA_ADMIN) && !WizRoy(player)) || ( (fbe->listperm & CA_WIZARD) && !Wizard(player)) || ( (fbe->listperm & CA_GOD) && !God(player))) { return false; } // Don't show CONNECT on dark wizards to mortals // if ( isPlayer(it) && (fbe->flagvalue == CONNECTED) && (fbe->flagflag == FLAG_WORD2) && Hidden(it) && !See_Hidden(player)) { return false; } return true; } return false; }
Document &DocumentManager::addDefaultDocument( const SettingsManager &settings_manager) { Document &doc = addDocument(); Score &score = doc.getScore(); auto settings = settings_manager.getReadHandle(); // Add an initial player and instrument. Player player; player.setDescription("Player 1"); player.setTuning(settings->get(Settings::DefaultTuning)); score.insertPlayer(player); Instrument instrument; instrument.setDescription(settings->get(Settings::DefaultInstrumentName) + " 1"); instrument.setMidiPreset(settings->get(Settings::DefaultInstrumentPreset)); score.insertInstrument(instrument); ScoreUtils::addStandardFilters(score); // Add an initial staff, player change, and tempo marker. System system; system.insertStaff(Staff(player.getTuning().getStringCount())); PlayerChange initialPlayers; initialPlayers.insertActivePlayer(0, ActivePlayer(0, 0)); system.insertPlayerChange(initialPlayers); TempoMarker tempo; tempo.setDescription("Moderately"); system.insertTempoMarker(tempo); score.insertSystem(system); return doc; }
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <catch.hpp> #include <actions/removestaff.h> #include <app/caret.h> #include <score/score.h> TEST_CASE("Actions/RemoveStaff", "") { Score score; System system; system.insertStaff(Staff(6)); system.insertStaff(Staff(7)); score.insertSystem(system); ScoreLocation location(score, 0, 1); RemoveStaff action(location); action.redo(); REQUIRE(location.getSystem().getStaves().size() == 1); action.undo(); REQUIRE(location.getSystem().getStaves().size() == 2); }
UTF8 *flag_description(dbref player, dbref target) { // Allocate the return buffer. // int otype = Typeof(target); UTF8 *buff = alloc_mbuf("flag_description"); UTF8 *bp = buff; // Store the header strings and object type. // safe_mb_str(T("Type: "), buff, &bp); safe_mb_str(object_types[otype].name, buff, &bp); safe_mb_str(T(" Flags:"), buff, &bp); if (object_types[otype].perm != CA_PUBLIC) { *bp = '\0'; return buff; } // Store the type-invariant flags. // FLAGNAMEENT *fp; for (fp = gen_flag_names; fp->flagname; fp++) { if (!fp->bPositive) { continue; } FLAGBITENT *fbe = fp->fbe; if (db[target].fs.word[fbe->flagflag] & fbe->flagvalue) { if ( ( (fbe->listperm & CA_STAFF) && !Staff(player)) || ( (fbe->listperm & CA_ADMIN) && !WizRoy(player)) || ( (fbe->listperm & CA_WIZARD) && !Wizard(player)) || ( (fbe->listperm & CA_GOD) && !God(player))) { continue; } // Don't show CONNECT on dark wizards to mortals. // if ( isPlayer(target) && (fbe->flagvalue == CONNECTED) && (fbe->flagflag == FLAG_WORD2) && Hidden(target) && !See_Hidden(player)) { continue; } safe_mb_chr(' ', buff, &bp); safe_mb_str(fp->flagname, buff, &bp); } } // Terminate the string, and return the buffer to the caller. // *bp = '\0'; return buff; }
UTF8 *decode_flags(dbref player, FLAGSET *fs) { UTF8 *buf, *bp; buf = bp = alloc_sbuf("decode_flags"); *bp = '\0'; if (!Good_obj(player)) { mux_strncpy(buf, T("#-2 ERROR"), SBUF_SIZE-1); return buf; } int flagtype = fs->word[FLAG_WORD1] & TYPE_MASK; bool bNeedColon = true; if (object_types[flagtype].lett != ' ') { safe_sb_chr(object_types[flagtype].lett, buf, &bp); bNeedColon = false; } FLAGNAMEENT *fp; for (fp = gen_flag_names; fp->flagname; fp++) { FLAGBITENT *fbe = fp->fbe; if ( !fp->bPositive || fbe->flaglett == ' ') { // Only look at positive-sense entries that have non-space flag // letters. // continue; } if (fs->word[fbe->flagflag] & fbe->flagvalue) { if ( ( (fbe->listperm & CA_STAFF) && !Staff(player)) || ( (fbe->listperm & CA_ADMIN) && !WizRoy(player)) || ( (fbe->listperm & CA_WIZARD) && !Wizard(player)) || ( (fbe->listperm & CA_GOD) && !God(player))) { continue; } // Don't show CONNECT on dark wizards to mortals // if ( flagtype == TYPE_PLAYER && fbe->flagflag == FLAG_WORD2 && fbe->flagvalue == CONNECTED && (fs->word[FLAG_WORD1] & (WIZARD | DARK)) == (WIZARD | DARK) && !See_Hidden(player)) { continue; } if ( bNeedColon && mux_isdigit(fbe->flaglett)) { // We can't allow numerical digits at the beginning. // safe_sb_chr(':', buf, &bp); } safe_sb_chr(fbe->flaglett, buf, &bp); bNeedColon = false; } } *bp = '\0'; return buf; }
bool convert_flags(dbref player, UTF8 *flaglist, FLAGSET *fset, FLAG *p_type) { FLAG type = NOTYPE; FLAGSET flagmask; memset(&flagmask, 0, sizeof(flagmask)); int i; UTF8 *s; bool handled; for (s = flaglist; *s; s++) { handled = false; // Check for object type. // for (i = 0; i <= 7 && !handled; i++) { if ( object_types[i].lett == *s && !( ( (object_types[i].perm & CA_STAFF) && !Staff(player)) || ( (object_types[i].perm & CA_ADMIN) && !WizRoy(player)) || ( (object_types[i].perm & CA_WIZARD) && !Wizard(player)) || ( (object_types[i].perm & CA_GOD) && !God(player)))) { if ( type != NOTYPE && type != i) { UTF8 *p = tprintf(T("%c: Conflicting type specifications."), *s); notify(player, p); return false; } type = i; handled = true; } } // Check generic flags. // if (handled) { continue; } FLAGNAMEENT *fp; for (fp = gen_flag_names; fp->flagname && !handled; fp++) { FLAGBITENT *fbe = fp->fbe; if ( !fp->bPositive || fbe->flaglett == ' ') { continue; } if ( fbe->flaglett == *s && !( ( (fbe->listperm & CA_STAFF) && !Staff(player)) || ( (fbe->listperm & CA_ADMIN) && !WizRoy(player)) || ( (fbe->listperm & CA_WIZARD) && !Wizard(player)) || ( (fbe->listperm & CA_GOD) && !God(player)))) { flagmask.word[fbe->flagflag] |= fbe->flagvalue; handled = true; } } if (!handled) { notify(player, tprintf(T("%c: Flag unknown or not valid for specified object type"), *s)); return false; } } // Return flags to search for and type. // *fset = flagmask; *p_type = type; return true; }