static int ReadObject(CurPos &cp, const char *ObjName) { unsigned char obj; unsigned short len; while ((obj = GetObj(cp, len)) != 0xFF) { switch (obj) { case CF_COLOR: if (ReadColors(cp, ObjName) == -1) return -1; break; #ifdef CONFIG_OBJ_MESSAGES case CF_COMPRX: { long file, line, msg; const char *regexp; if (GetObj(cp, len) != CF_INT) return -1; if (GetNum(cp, file) == 0) return -1; if (GetObj(cp, len) != CF_INT) return -1; if (GetNum(cp, line) == 0) return -1; if (GetObj(cp, len) != CF_INT) return -1; if (GetNum(cp, msg) == 0) return -1; if (GetObj(cp, len) != CF_REGEXP) return -1; if ((regexp = GetCharStr(cp, len)) == 0) return -1; if (AddCRegexp(file, line, msg, regexp) == 0) return -1; } break; #endif #ifdef CONFIG_OBJ_CVS case CF_CVSIGNRX: { const char *regexp; if (GetObj(cp, len) != CF_REGEXP) return -1; if ((regexp = GetCharStr(cp, len)) == 0) return -1; if (AddCvsIgnoreRegexp(regexp) == 0) return -1; } break; #endif #ifdef CONFIG_OBJ_SVN case CF_SVNIGNRX: { const char *regexp; if (GetObj(cp, len) != CF_REGEXP) return -1; if ((regexp = GetCharStr(cp, len)) == 0) return -1; if (AddSvnIgnoreRegexp(regexp) == 0) return -1; } break; #endif case CF_SETVAR: { long what; if (GetNum(cp, what) == 0) return -1; switch (GetObj(cp, len)) { case CF_STRING: { const char *val = GetCharStr(cp, len); if (len == 0) return -1; if (SetGlobalString(what, val) != 0) return -1; } break; case CF_INT: { long num; if (GetNum(cp, num) == 0) return -1; if (SetGlobalNumber(what, num) != 0) return -1; } break; default: return -1; } } break; case CF_END: return 0; default: return -1; } } return -1; }
static int ReadCommands(CurPos &cp, const char *Name) { STARTFUNC("ReadCommands"); LOG << "Name = " << (Name != NULL ? Name : "(null)") << ENDLINE; unsigned char obj; unsigned short len; long Cmd = NewCommand(Name); long cmdno; if (GetObj(cp, len) != CF_INT) ENDFUNCRC(-1); if (GetNum(cp, cmdno) == 0) ENDFUNCRC(-1); if (cmdno != (Cmd | CMD_EXT)) { fprintf(stderr, "Bad Command map %s -> %ld != %ld\n", Name, Cmd, cmdno); ENDFUNCRC(-1); } while ((obj = GetObj(cp, len)) != 0xFF) { switch (obj) { case CF_COMMAND: { // char *s; long cnt; long ign; long cmd; // if ((s = GetCharStr(cp, len)) == 0) return -1; if (GetNum(cp, cmd) == 0) ENDFUNCRC(-1); if (GetObj(cp, len) != CF_INT) ENDFUNCRC(-1); if (GetNum(cp, cnt) == 0) ENDFUNCRC(-1); if (GetObj(cp, len) != CF_INT) ENDFUNCRC(-1); if (GetNum(cp, ign) == 0) ENDFUNCRC(-1); // if (cmd != CmdNum(s)) { // fprintf(stderr, "Bad Command Id: %s -> %d\n", s, cmd); // return -1; // } if (AddCommand(Cmd, cmd, cnt, ign) == 0) { if (Name == 0 || strcmp(Name, "xx") != 0) { fprintf(stderr, "Bad Command Id: %ld\n", cmd); ENDFUNCRC(-1); } } } break; case CF_STRING: { const char *s = GetCharStr(cp, len); if (s == 0) ENDFUNCRC(-1); if (AddString(Cmd, s) == 0) ENDFUNCRC(-1); } break; case CF_INT: { long num; if (GetNum(cp, num) == 0) ENDFUNCRC(-1); if (AddNumber(Cmd, num) == 0) ENDFUNCRC(-1); } break; case CF_VARIABLE: { long num; if (GetNum(cp, num) == 0) ENDFUNCRC(-1); if (AddVariable(Cmd, num) == 0) ENDFUNCRC(-1); } break; case CF_CONCAT: if (AddConcat(Cmd) == 0) ENDFUNCRC(-1); break; case CF_END: ENDFUNCRC(Cmd); default: ENDFUNCRC(-1); } } ENDFUNCRC(-1); }
void CMSPeakList::Rank(void) { int i; for(i = 1; i <= GetNum(); i++) GetMZI()[i-1].SetRank() = i; }
static void Parms(void) { char err; char h[1024]; unsigned long i; err = 0; for (;;) { osi_NextArg(h, 1024ul); if (h[0U]==0) break; if ((h[0U]=='-' && h[1U]) && h[2U]==0) { if (h[1U]=='u') usbrobust = 0; else if (h[1U]=='s') sumoff = 1; else if (h[1U]=='a') withalti = 1; else if (h[1U]=='f') { /* ELSIF h[1]="i" THEN NextArg(h); IF h[0]>" " THEN symt:=h[0]; IF h[1]>" " THEN symb:=h[1] ELSE symb:=0C END; ELSE Error("-i <icon> (house /-)") END; */ osi_NextArg(basefilename, 1024ul); if (basefilename[0U]==0) Error("-f filename", 12ul); } else if (h[1U]=='t') { osi_NextArg(h, 1024ul); i = 0UL; while ((h[i] && h[i]!=':') && i<1023UL) { ttynamee[i] = h[i]; ++i; } ttynamee[i] = 0; if (h[i]) { ++i; if (!GetNum(h, 1024ul, 0, &i, &baud)) { Error("need ttydevice:baud", 20ul); } } } else if (h[1U]=='m') { osi_NextArg(h, 1024ul); i = 0UL; if (!GetNum(h, 1024ul, 0, &i, &mediantime)) { Error("-m <seconds>", 13ul); } if (mediantime>499UL) { aprsstr_IntToStr(499L, 1UL, h, 1024ul); aprsstr_Append(h, 1024ul, " maximum -m", 12ul); Error(h, 1024ul); } } else if (h[1U]=='f') { osi_NextArg(h, 1024ul); i = 0UL; if (!GetNum(h, 1024ul, 0, &i, &comptyp) || comptyp>2UL) { Error("-f <format> 0=uncomp, 1=comp, 2=mic-e", 38ul); } } else if (h[1U]=='v') verb = 1; else { if (h[1U]=='h') { osic_WrLn(); osi_WrStrLn("Read serial GPS and make position string to inser\ t into APRS-beacon", 68ul); osi_WrStrLn(" -a altitude on", 47ul); osi_WrStrLn(" -f <filename> writes <fn.lat\ > <fn.long> and <filename.alt>", 80ul); osi_WrStrLn(" -h this", 40ul); /* WrStrLn(' -i <icon> 2 Icon chars "/-" (House), "/>" (Car)...'); */ osi_WrStrLn(" -m <seconds> time to read g\ ps to make median position", 76ul); osi_WrStrLn(" -s GPS Checksum c\ heck OFF", 58ul); osi_WrStrLn(" -t <tty>:<baud> default /dev/t\ tyS0:9600", 59ul); osi_WrStrLn(" -u not retry unti\ l open removable USB tty", 74ul); osi_WrStrLn(" -v verbous", 43ul); osi_WrStrLn(" example: -t /dev/ttyS0:9600 -u -f test -i \"/-\\ " -a -m 30 -v", 61ul); osic_WrLn(); X2C_ABORT(); } err = 1; } } else {
INT CActionItem::Lua_GetNum(LuaPlus::LuaState* pState) //得到每个格子里头的数量 { pState->PushInteger(GetNum()); return 1; }
VOID CActionItem::AddReference(tActionReference* pRef,BOOL bIsInMenuToolbar) { //如果没有,加入 if(m_setReference.find(pRef) == m_setReference.end()) { m_setReference.insert(pRef); } //刷新Check信息 pRef->SetCheck(m_bChecked); pRef->SetDefault(CActionSystem::GetMe()->GetDefaultAction() == this); switch(GetType()) { case AOT_ITEM: { //物品的每组的个数显示在右下角 tObject_Item* pItem = (tObject_Item*)GetImpl(); if( pItem->GetTypeOwner() == tObject_Item::IO_BOOTH ||pItem->GetTypeOwner() == tObject_Item::IO_BOOTH_CALLBACK ||pItem->GetTypeOwner() == tObject_Item::IO_CITY_SHOP) { INT nGroupNumber = GetNum(); if(nGroupNumber > 1) { CHAR szTemp[32]; _snprintf(szTemp, 32, "%d", nGroupNumber); pRef->SetCornerChar(tActionReference::ANP_BOTRIGHT, szTemp); } else { pRef->SetCornerChar(tActionReference::ANP_BOTRIGHT, ""); } //有限物品的最大数量显示在左上角 INT nMaxNumber = pItem->GetMax(); if(nMaxNumber > 1) { CHAR szTemp[32]; _snprintf(szTemp, 32, "%d", nMaxNumber); pRef->Enable(); pRef->SetCornerChar(tActionReference::ANP_TOPLEFT, szTemp); } else if(nMaxNumber == 0) { pRef->Disable(); pRef->SetCornerChar(tActionReference::ANP_TOPLEFT, ""); } else { pRef->Enable(); pRef->SetCornerChar(tActionReference::ANP_TOPLEFT, ""); } } else if( pItem->GetTypeOwner() == tObject_Item::IO_MYSELF_PACKET || pItem->GetTypeOwner() == tObject_Item::IO_MYSELF_BANK || pItem->GetTypeOwner() == tObject_Item::IO_MYEXBOX || pItem->GetTypeOwner() == tObject_Item::IO_OTHEREXBOX || pItem->GetTypeOwner() == tObject_Item::IO_MISSIONBOX || pItem->GetTypeOwner() == tObject_Item::IO_MYSTALLBOX || pItem->GetTypeOwner() == tObject_Item::IO_OTSTALLBOX || pItem->GetTypeOwner() == tObject_Item::IO_QUESTVIRTUALITEM || pItem->GetTypeOwner() == tObject_Item::IO_ITEMBOX || pItem->GetTypeOwner() == tObject_Item::IO_PS_SELFBOX || pItem->GetTypeOwner() == tObject_Item::IO_PS_OTHERBOX ) { INT nGroupNumber = GetNum(); //AxTrace(0, 0, "%s:GroupNumber=%d", pItem->GetName(), nGroupNumber); if(bIsInMenuToolbar == TRUE) { CHAR szTemp[32]; _snprintf(szTemp, 32, "%d", CDataPool::GetMe()->UserBag_CountItemByIDTable(pItem->GetIdTable())); pRef->SetCornerChar(tActionReference::ANP_BOTRIGHT, szTemp); } else if(nGroupNumber > 1) { CHAR szTemp[32]; _snprintf(szTemp, 32, "%d", nGroupNumber); pRef->SetCornerChar(tActionReference::ANP_BOTRIGHT, szTemp); } else { pRef->SetCornerChar(tActionReference::ANP_BOTRIGHT, ""); } } } break; default: pRef->SetCornerChar(tActionReference::ANP_BOTRIGHT, ""); break; } UpdateCoolDown(); }
static int ReadColorize(CurPos &cp, EColorize *Colorize, const char *ModeName) { unsigned char obj; unsigned short len; long LastState = -1; while ((obj = GetObj(cp, len)) != 0xFF) { switch (obj) { case CF_COLOR: if (ReadHilitColors(cp, Colorize, ModeName) == -1) return -1; break; case CF_KEYWORD: { const char *colorstr; if ((colorstr = GetCharStr(cp, len)) == 0) return -1; unsigned int Col; unsigned int ColBg, ColFg; if (sscanf(colorstr, "%1X %1X", &ColFg, &ColBg) != 2) return 0; Col = ColFg | (ColBg << 4); int color = ChColor(Col); if (ReadKeywords(cp, &Colorize->Keywords, color) == -1) return -1; } break; case CF_HSTATE: { long stateno; long color; if (Colorize->hm == 0) Colorize->hm = new HMachine(); assert(Colorize->hm != 0); if (GetNum(cp, stateno) == 0) return -1; assert(stateno == LastState + 1); obj = GetObj(cp, len); assert(obj == CF_INT); if (GetNum(cp, color) == 0) return -1; HState newState; newState.InitState(); newState.color = color; Colorize->hm->AddState(newState); LastState = stateno; } break; case CF_HTRANS: { HTrans newTrans; long nextState; long matchFlags; const char *match; long color; if (GetNum(cp, nextState) == 0) return -1; obj = GetObj(cp, len); assert(obj == CF_INT); if (GetNum(cp, matchFlags) == 0) return -1; obj = GetObj(cp, len); assert(obj == CF_INT); if (GetNum(cp, color) == 0) return -1; obj = GetObj(cp, len); assert(matchFlags & MATCH_REGEXP ? obj == CF_REGEXP : obj == CF_STRING); if ((match = GetCharStr(cp, len)) == 0) return -1; newTrans.InitTrans(); newTrans.matchFlags = matchFlags; newTrans.nextState = nextState; newTrans.color = color; if (newTrans.matchFlags & MATCH_REGEXP) { newTrans.regexp = RxCompile(match); newTrans.matchLen = 0; } else if ((newTrans.matchFlags & MATCH_SET) || (newTrans.matchFlags & MATCH_NOTSET)) { newTrans.matchLen = 1; newTrans.match = (char *)malloc(256/8); assert(newTrans.match != NULL); SetWordChars(newTrans.match, match); } else { newTrans.match = strdup(match); newTrans.matchLen = strlen(match); } Colorize->hm->AddTrans(newTrans); } break; case CF_HWTYPE: { long nextKwdMatchedState; long nextKwdNotMatchedState; long nextKwdNoCharState; long options; const char *wordChars; obj = GetObj(cp, len); assert(obj == CF_INT); if (GetNum(cp, nextKwdMatchedState) == 0) return -1; obj = GetObj(cp, len); assert(obj == CF_INT); if (GetNum(cp, nextKwdNotMatchedState) == 0) return -1; obj = GetObj(cp, len); assert(obj == CF_INT); if (GetNum(cp, nextKwdNoCharState) == 0) return -1; obj = GetObj(cp, len); assert(obj == CF_INT); if (GetNum(cp, options) == 0) return -1; obj = GetObj(cp, len); assert(obj == CF_STRING); if ((wordChars = GetCharStr(cp, len)) == 0) return -1; Colorize->hm->LastState()->options = options; Colorize->hm->LastState()->nextKwdMatchedState = nextKwdMatchedState; Colorize->hm->LastState()->nextKwdNotMatchedState = nextKwdNotMatchedState; Colorize->hm->LastState()->nextKwdNoCharState = nextKwdNoCharState; if (wordChars && *wordChars) { Colorize->hm->LastState()->wordChars = (char *)malloc(256/8); assert(Colorize->hm->LastState()->wordChars != NULL); SetWordChars(Colorize->hm->LastState()->wordChars, wordChars); } } break; case CF_HWORDS: { const char *colorstr; int color; if ((colorstr = GetCharStr(cp, len)) == 0) return -1; color = hcPlain_Keyword; if (strcmp(colorstr, "-") != 0) { const char *Value = colorstr; int Col; if (*Value == '-') { Value++; if (sscanf(Value, "%1X", &Col) != 1) return -1; Col |= (hcPlain_Background & 0xF0); } else if (Value[1] == '-') { if (sscanf(Value, "%1X", &Col) != 1) return -1; Col <<= 4; Col |= (hcPlain_Background & 0x0F); } else { unsigned int ColBg, ColFg; if (sscanf(colorstr, "%1X %1X", &ColFg, &ColBg) != 2) return 0; Col = ColFg | (ColBg << 4); } color = Col; } if (ReadKeywords(cp, &Colorize->hm->LastState()->keywords, color) == -1) return -1; } break; case CF_SETVAR: { long what; if (GetNum(cp, what) == 0) return -1; switch (GetObj(cp, len)) { case CF_STRING: { const char *val = GetCharStr(cp, len); if (len == 0) return -1; if (SetColorizeString(Colorize, what, val) != 0) return -1; } break; /* case CF_INT: { long num; if (GetNum(cp, num) == 0) return -1; if (SetModeNumber(Mode, what, num) != 0) return -1; } break;*/ default: return -1; } } break; case CF_END: return 0; default: return -1; } } return -1; }
bool CMusicStudioDoc::LoadMWMusicFile(CArchive &ar) { if (!ar.IsLoading()) { return false; } OnNewDocument(); mGenericInfo = CString(_T("Originaly converted from the MW music file: ")) + ar.GetFile()->GetFileName() + _T("\x0d\x0a"); Music music; CStringA filenameA(ar.GetFile()->GetFilePath()); const char *filename = filenameA.GetBuffer(); music.LoadMusic(filename); music.Compact(); ZeroMemory(mTracks,sizeof(mTracks)); ZeroMemory(mTablesControls,sizeof(mTablesControls)); ZeroMemory(mTablesValues,sizeof(mTablesValues)); for (int i = 0 ; i < MusicStudio1::MusicFile::kMaxEnvelopes ; i++) { mEnvelopeNames[i] = ""; mEnvelopes[i] = MusicStudio1::Envelope(); } OptimiseTables(true); const std::vector<Block> &tracks = music.getTracks(); size_t channelPos[3] = {0,0,0}; size_t blockIndex = 0; int channel = 0; for (size_t blockIndex = 0 ; blockIndex < tracks.size() ; blockIndex++) { channel = blockIndex % MusicStudio1::MusicFile::kMaxTracks; if (channelPos[channel] >= MusicStudio1::MusicFile::kMaxTrackLength) { break; } const Block &trackBlock = tracks[blockIndex]; for (size_t i = 0 ; i < trackBlock.size() ; i++) { if (trackBlock[i] == 0xff ) { mTracks[channel][channelPos[channel]] = MusicStudio1::kMusicPlayer_LoopTrack; channelPos[channel]++; break; } else if (trackBlock[i] == 0xfe ) { mTracks[channel][channelPos[channel]] = MusicStudio1::kMusicPlayer_StopAllTracks; channelPos[channel]++; break; } else if (trackBlock[i] == 0xfd ) { // TODO: fade down? mTracks[channel][channelPos[channel]] = MusicStudio1::kMusicPlayer_StopAllTracks; channelPos[channel]++; break; } if ((trackBlock[i] & 0x40) == 0x40) { // TODO: Loop start/end across a range of track entries // Ignore for now i++; } unsigned char numTimes = trackBlock[i]; i++; unsigned char sequence = trackBlock[i]; // TODO: Output a warning if the sequence/block index is out of range of MusicStudio1::MusicFile::kMaxBlocks ? // Finally the sequence number if (sequence >= MusicStudio1::MusicFile::kMaxBlocks) { continue; } if (numTimes > 2) { mTracks[channel][channelPos[channel]] = MusicStudio1::kMusicPlayer_RepeatBlock | numTimes; channelPos[channel]++; if (channelPos[channel] >= MusicStudio1::MusicFile::kMaxTrackLength) { break; } } // Finally the sequence number // The sequence range is less in this format mTracks[channel][channelPos[channel]] = sequence & (MusicStudio1::MusicFile::kMaxBlocks - 1); channelPos[channel]++; if (channelPos[channel] >= MusicStudio1::MusicFile::kMaxTrackLength) { break; } // Small optimisation to avoid a repeat block instruction being output if (numTimes == 2) { mTracks[channel][channelPos[channel]] = mTracks[channel][channelPos[channel]-1]; channelPos[channel]++; } } } const std::vector<Block> &sequences = music.getSequences(); for (size_t sequence = 0 ; sequence < sequences.size() ; sequence++) { if (sequence >= MusicStudio1::MusicFile::kMaxBlocks) { break; } const Block &sequenceBlock = sequences[sequence]; CString blockText; unsigned char lastEnv = 0xff; unsigned char lastDur = 0xff; for (size_t i = 0 ; i < sequenceBlock.size() ; i++) { unsigned char lengthByte = sequenceBlock[i]; i++; if (lengthByte == 0xff) { break; } if (lengthByte & 0x80) { // Change envelope if (i >= sequenceBlock.size()) { break; } unsigned char env = sequenceBlock[i]; i++; if (env & 0x80) { // TODO: Bend instead of voice change? } else { if (env != lastEnv) { lastEnv = env; blockText += L"ENV:" + GetNum(lastEnv) + L"\r\n"; } } } lengthByte = lengthByte & 0x3f; if (lengthByte != lastDur) { lastDur = lengthByte; blockText += L"DUR:" + GetNum(lastDur) + L"\r\n"; } if (i >= sequenceBlock.size()) { break; } unsigned char noteByte = sequenceBlock[i]; noteByte &= 0x7f; blockText += CString(MusicStudio1::BlockEntry::GetNoteFromNumber(noteByte).c_str()) + L"\r\n"; } mBlocks[sequence] = blockText; } const std::vector<Block> &effect1 = music.getEffect1(); const std::vector<Block> &effect2 = music.getEffect2(); for (size_t effect = 0 ; effect < effect1.size() ; effect++) { if (effect >= MusicStudio1::MusicFile::kMaxEnvelopes) { break; } mEnvelopeNames[effect] = _T("A note"); mEnvelopes[effect].mAttackDecay = effect1[effect][0]; mEnvelopes[effect].mSustainRelease = effect1[effect][1]; mEnvelopes[effect].mAllowVoiceEffects = true; int nextTableWave = getNextFreeTableControl(MusicStudio1::kTableIndex_Wave); int nextTableNote = getNextFreeTableControl(MusicStudio1::kTableIndex_Note); int nextTablePulse = getNextFreeTableControl(MusicStudio1::kTableIndex_Pulse); if (nextTableWave > 0) { mEnvelopes[effect].mActiveTableWave = true; mEnvelopes[effect].mTableWave = nextTableWave; mTablesControls[MusicStudio1::kTableIndex_Wave][nextTableWave] = effect1[effect][2]; mTablesControls[MusicStudio1::kTableIndex_Wave][nextTableWave+1] = 0xff; if ( (effect1[effect][2] & MusicStudio1::kSIDVoiceControl_Mask_Pulse) && nextTablePulse > 0) { mEnvelopes[effect].mActiveTablePulse = true; mEnvelopes[effect].mTablePulse = nextTablePulse; mTablesControls[MusicStudio1::kTableIndex_Pulse][nextTablePulse] = effect1[effect][4] & 0x0f; mTablesValues[MusicStudio1::kTableIndex_Pulse][nextTablePulse] = effect1[effect][4]; mTablesControls[MusicStudio1::kTableIndex_Pulse][nextTablePulse+1] = 0xff; // TODO: effect1[effect][5] is used for "PULSE WIDTH MODULATION CODE" } // Handle: ATK NOTE SPECIAL if ( (effect1[effect][3] & 0x20) && nextTableNote > 0 ) { mEnvelopes[effect].mActiveTableNote = true; mEnvelopes[effect].mTableNote = nextTableNote; if (effect2[effect][1] == 0) { mTablesControls[MusicStudio1::kTableIndex_Note][nextTableNote] = 0xb0 | (effect1[effect][7] & 0x0f); mTablesValues[MusicStudio1::kTableIndex_Note][nextTableNote] = 0; mTablesControls[MusicStudio1::kTableIndex_Note][nextTableNote+1] = 0xff; } else { mTablesControls[MusicStudio1::kTableIndex_Note][nextTableNote] = 0x10 | (effect1[effect][7] & 0x0f); mTablesValues[MusicStudio1::kTableIndex_Note][nextTableNote] = effect2[effect][1]; mTablesControls[MusicStudio1::kTableIndex_Note][nextTableNote+1] = 0x20; mTablesControls[MusicStudio1::kTableIndex_Note][nextTableNote+2] = 0xff; } } } // OptimiseTables(true); } return true; }
static int ReadEventMap(CurPos &cp, EEventMap *Map, const char * /*MapName*/) { unsigned char obj; unsigned short len; while ((obj = GetObj(cp, len)) != 0xFF) { switch (obj) { case CF_KEY: { EKey *Key; const char *s; int Cmd; if ((s = GetCharStr(cp, len)) == 0) return -1; if ((Key = SetKey(Map, s)) == 0) return -1; if ((obj = GetObj(cp, len)) != CF_KEYSUB) return -1; if ((Cmd = ReadCommands(cp, 0)) == -1) return -1; Key->Cmd = Cmd; } break; #ifdef CONFIG_ABBREV case CF_ABBREV: { EAbbrev *Ab; const char *s; const char *x; int Cmd; if ((s = GetCharStr(cp, len)) == 0) return -1; obj = GetObj(cp, len); if (obj == CF_KEYSUB) { if ((Cmd = ReadCommands(cp, 0)) == -1) return -1; Ab = new EAbbrev(s, Cmd); } else if (obj == CF_STRING) { x = GetCharStr(cp, len); Ab = new EAbbrev(s, x); } else return -1; if (Ab) { Map->AddAbbrev(Ab); } } break; #endif case CF_SETVAR: { long what; if (GetNum(cp, what) == 0) return -1; switch (GetObj(cp, len)) { case CF_STRING: { const char *val = GetCharStr(cp, len); if (len == 0) return -1; if (SetEventString(Map, what, val) != 0) return -1; } break; /* case CF_INT: { long num; if (GetNum(cp, num) == 0) return -1; if (SetModeNumber(Mode, what, num) != 0) return -1; } break;*/ default: return -1; } } break; case CF_END: return 0; default: return -1; } } return -1; }
yylex() /*****************Lexical analizer routine******************/ {int t,i; int c; symbol *s; lex: SkipBlanks(); if (!compfl && c != '#') { /*Ignore this line */ ignline: if ((int)c == EOF) return E_O_F; if (!GetString(symb,sizeof(symb))) { Error("Unclosed conditional bracket at EOF"); return E_O_F; }; #if BUFFERED f_char= ' '; /*any char. diff. from the '\n' */ #endif c= '\n'; }; if (c == '#' && !compfl) { SkipBlanks(); if (c=='i' || c=='I') goto ignline; UnGetChar(c); c= '#'; compfl= -1; }; if (c=='%') goto ignline; /* %comment line */ if (c=='/') { if ((c=GetChar())=='*') { /*Comment */ comm: while ((int)(c=GetChar()) != EOF && c != '*'); if ((int)c==EOF) return E_O_F; while ((c=GetChar()) == '*'); if (c != '/') goto comm; goto lex; /*get the next symbol */ }; UnGetChar(c); c= '/'; }; if (c=='\'') { yylval.Num= GetChar(); if ((c=GetChar()) != '\'') Error("' expected"); return NUM; }; if (isdigit(c)) { /*Number */ if (c=='0') { c= GetChar(); if (c=='x' || c=='X') { /*0xHEXALNUMBER */ GetHexNum(&yylval.Num); return NUM; }; if (isdigit(c)) { /*Octal number */ UnGetChar(c); GetOctalNum(&yylval.Num); return NUM; }; }; UnGetChar(c); if (!isdigit(c)) yylval.Num= 0; else GetNum(&yylval.Num); return NUM; }; if (c=='_' || isalpha(c)) { /*Identifier */ register symbol *blk= blkptr; i= 0; while (c=='_' || isalnum(c)) { symb[i++]= c; c= GetChar(); }; UnGetChar(c); symb[i++]= 0; do { s= LookUp(symb,blk); if (!blk) break; blk= blk->Block; } while (!s); if (!s) { s= Insert(symb,SYM,0); if (!s) { Error("Symbol table is overflowed, symbol:%s",symb); return E_O_F; }; s->Block= blkptr; }; idnptr= s; yylval.Sym= s; if (s->Type == NUM) return SYM; /********** yylval.Num= s->Val; return NUM; }; **********/ return s->Type; }; if ((int)c == EOF) return E_O_F; t= (int)c; if (c=='=' || c=='<' || c=='>') { i= GetChar(); if (c==i) t= (c=='<'? SHL: c=='>'? SHR: EQ); else UnGetChar(i); }; yylval.Num= t; /*Delimiter */ return t; }
void FReferenceSkeleton::RemoveDuplicateBones(const UObject* Requester, TArray<FBoneIndexType> & DuplicateBones) { const int32 NumBones = GetNum(); DuplicateBones.Empty(); TMap<FName, int32> BoneNameCheck; bool bRemovedBones = false; for (int32 BoneIndex = NumBones - 1; BoneIndex >= 0; BoneIndex--) { const FName& BoneName = GetBoneName(BoneIndex); const int32* FoundBoneIndexPtr = BoneNameCheck.Find(BoneName); // Not a duplicate bone, track it. if (FoundBoneIndexPtr == NULL) { BoneNameCheck.Add(BoneName, BoneIndex); } else { const int32 DuplicateBoneIndex = *FoundBoneIndexPtr; DuplicateBones.Add(DuplicateBoneIndex); UE_LOG(LogAnimation, Warning, TEXT("RemoveDuplicateBones: duplicate bone name (%s) detected for (%s)! Indices: %d and %d. Removing the latter."), *BoneName.ToString(), *GetNameSafe(Requester), DuplicateBoneIndex, BoneIndex); // Remove duplicate bone index, which was added later as a mistake. RefBonePose.RemoveAt(DuplicateBoneIndex, 1); RefBoneInfo.RemoveAt(DuplicateBoneIndex, 1); // Now we need to fix all the parent indices that pointed to bones after this in the array // These must be after this point in the array. for (int32 j = DuplicateBoneIndex; j < GetNum(); j++) { if (GetParentIndex(j) >= DuplicateBoneIndex) { RefBoneInfo[j].ParentIndex -= 1; } } // Update entry in case problem bones were added multiple times. BoneNameCheck.Add(BoneName, BoneIndex); // We need to make sure that any bone that has this old bone as a parent is fixed up bRemovedBones = true; } } // If we've removed bones, we need to rebuild our name table. if (bRemovedBones || (NameToIndexMap.Num() == 0)) { RebuildNameToIndexMap(); } // Make sure our arrays are in sync. checkSlow((RefBoneInfo.Num() == RefBonePose.Num()) && (RefBoneInfo.Num() == NameToIndexMap.Num())); // Additionally normalize all quaternions to be safe. for (int32 BoneIndex = 0; BoneIndex < GetNum(); BoneIndex++) { RefBonePose[BoneIndex].NormalizeRotation(); } }
/*======================================================================*/ BOOLEAN LeeComoFecha (T_Palabra palabra) { STATIC char tmp[4]; STATIC int i; STATIC int dia, mes, anyo; STATIC char sep; /* leer dia */ STATIC int cont; CALCULA_STKLEN (); cont = GetNum (palabra, &dia); if ((dia < 1) || (dia > 31)) return 0; /* 0 < dia < 32 */ /* leer separador */ sep = palabra[cont]; if ((sep != '-') && (sep != '/')) return 0; /* leer mes */ if (isdigit ((unsigned char) palabra[++cont])) /* pasa separador */ cont += GetNum (&palabra[cont], &mes); /* obtener mes (numero) */ else { /* obtener mes (letras) */ strcpy (tmp, "123"); for (i = 0; i < 3; i++) tmp[i] = tolower (palabra[cont++]); for (mes = 0; mes < 12; mes++) if (!strcmp (tmp, mes_abr[mes])) break; /* salir si se encuentra */ mes++; } if ((mes < 1) || (mes > 12)) return 0; /* 0 < mes < 13 */ /* leer separador */ if (palabra[cont] != sep) return 0; /* leer anyo */ cont += GetNum (&palabra[++cont], &anyo); /* pasar separador y obtener anyo */ if ((anyo == 0) || (anyo > 9999)) return 0; if (palabra[cont]) return 0; LeeNum (dia, UNO); CreaPalabra ("de"); CreaPalabra (Meses[mes - 1]); if (anyo > 999) { if (anyo > 1999) { CreaPalabra ("del"); LeeNum (anyo / 1000, UN); /* mil, no uno mil */ AnyadeAPalabra ("míl"); } else { CreaPalabra ("de"); CreaPalabra ("míl"); } } else CreaPalabra ("del"); LeeNum (anyo % 1000, UNO); return 1; }
int GetToken(int fReportError) { for (; ; ) { /* skip whitespace */ while (iswhite( curChar)) OurGetChar(); /* take care of 'random' symbols use */ if (curChar == SYMUSESTART) GetSymbol(fReportError, curChar); token.sym.name[0] = L'\0'; /* remember location of token */ token.row = curLin; token.col = curCol; /* determine if token is EOF, number, string, or keyword */ token.type = EOFMARK; switch (curChar) { case EOFMARK: break; case SGNCHAR: case L'~': if (fReportError & TOKEN_NOEXPRESSION) GetNumNoExpression(); else GetNum(); break; case STRCHAR: GetStr(); break; default: if (curChar == L'(' && !(fReportError & TOKEN_NOEXPRESSION)) GetNum(); else if (iswdigit( curChar)) { if (fReportError & TOKEN_NOEXPRESSION) GetNumNoExpression(); else GetNum(); if (curChar == SYMUSESTART) GetSymbol(fReportError, curChar); } else { if (!GetKwd( fReportError)) continue; if (token.type == TKLSTR) { GetLStr(); break; } } } break; } return token.type; }