bool CSECEditor::MoveForwardIndexing (TEXTPOS &textPos) { TEXTPOS tempPos=textPos; unsigned int uiBracketCount=0; SkipSpacesForward (tempPos); if (IsEnd (tempPos) || GetCharacter (tempPos) != '[') { return (false); }; do { if (GetCharacter (tempPos) == '[') { ++uiBracketCount; } else if (GetCharacter (tempPos) == ']') { --uiBracketCount; }; MoveForward (tempPos); } while (!IsEnd (tempPos) && uiBracketCount != 0); if (uiBracketCount != 0) { return (false); }; textPos = tempPos; return (true); }
void SetParameters( void* obj, const ClassAccessors& accessors, const ParameterBox& paramBox) { // we can choose to iterate through the parameters in either way: // either by iterating through the accessors in "accessors" and pulling // values from the parameter box... // or by iterating through the parameters in "paramBox" and pushing those // values in. // We have to consider array cases -- perhaps it easier to go through the // parameters in the parameter box for (auto i=paramBox.Begin(); !i.IsEnd(); ++i) { const auto nameStart = i.Name(); const auto nameEnd = XlStringEnd(nameStart); auto arrayBracket = std::find(nameStart, nameEnd, '['); if (arrayBracket == nameEnd) { accessors.TryOpaqueSet( obj, Hash64(nameStart, nameEnd), i.RawValue(), i.Type(), false); } else { auto arrayIndex = XlAtoUI32((const char*)(arrayBracket+1)); accessors.TryOpaqueSet( obj, Hash64(nameStart, arrayBracket), arrayIndex, i.RawValue(), i.Type(), false); } } }
void CSECEditor::SkipSpacesForward (TEXTPOS &textPos) { while (!IsEnd (textPos) && isspace (GetCharacter (textPos))) { MoveForward (textPos); }; }
void ArAIProperty::Update(float dt) { ArProperty::Update(dt); // update the behavior tree mAIRoot->execute((void*) this); auto gameEntity = GetEntity<ArGameEntity>(); if (gameEntity->IsDead()) { ClearAIList(); } if (mAIList.empty()) { UpdateDummyAI(dt); return; } auto pAI = mAIList.front(); while (pAI->IsEnd()) { PopCommand(); if (mAIList.empty()) { return; } pAI = mAIList.front(); } pAI->Update(dt); }
void ResourceSerializer::SerializeToBinary(const char* szReadPath, const char* szSavePath, const char* szFilename) { FileSystem::FileData fileData(255); FileSystem::GetListOfFiles(szReadPath, "*.tga", fileData); SDL_RWops* pRW = NULL; if(szSavePath != NULL) { const size_t uSize = 255; char sFullPath[uSize]; SDL_strlcpy(sFullPath, szSavePath, uSize); SDL_strlcat(sFullPath, szFilename, uSize); pRW = SDL_RWFromFile(sFullPath, "wb"); } else { pRW = SDL_RWFromFile(szFilename, "wb"); } ASSERT(pRW != NULL); SDL_RWwrite(pRW, &s_szWatermark[0], SDL_strlen(s_szWatermark) * sizeof(char), 1); for(auto it = fileData.Begin(); !it.IsEnd(); ++it) { IMGHeader imgHeader; SDL_Surface* pSurface = IMG_tga::Load((*it), &imgHeader); if(pSurface != NULL) { imgHeader.hasPalette = pSurface->format->palette != NULL ? true : false; U8String sName; str::GetFilenameAsIs((*it), sName); StringCRC hash(sName.CStr()); int iSize = (imgHeader.width * imgHeader.height) * 4; uint32 uHashName = hash.Get(); uint32 uBlockSize = (uint32)(sizeof(neko::IMGHeader) + ((size_t)iSize) * sizeof(Uint8)) + (imgHeader.hasPalette ? sizeof(neko::IMGPalette) : (size_t)0); SDL_RWwrite(pRW, &uBlockSize, sizeof(uint32), 1); SDL_RWwrite(pRW, &uHashName, sizeof(uint32), 1); SDL_RWwrite(pRW, &imgHeader, sizeof(neko::IMGHeader), 1); if(imgHeader.hasPalette) { IMGPalette palette; palette.ncolor = pSurface->format->palette->ncolors; Color::Copy(palette.color, *pSurface->format->palette->colors); SDL_RWwrite(pRW, &palette, sizeof(neko::IMGPalette), 1); } SDL_RWwrite(pRW, pSurface->pixels, iSize * sizeof(Uint8), 1); } } uint32 uEnd = 0; SDL_RWwrite(pRW, &uEnd, sizeof(uint32), 1); SDL_RWclose(pRW); }
void CrossNearSelector::Iterator::FindNextFullNear() { size_t nearSize = 0; while(!IsEnd() && (nearSize == 0)) { CONearPtr& near = m_Parent->m_NearObjects[m_Index]; if (!near) near = CONearPtr(new CONear); CircleObjectPtr& obj = m_Parent->m_Objects[m_Index]; if (near->RadiusMoveArea < obj->Radius || !m_Parent->IsNear(near->LastCenter, near->RadiusMoveArea, obj->Center)) { near->LastCenter = obj->Center; if (near->RadiusNearArea < obj->Radius) near->RadiusNearArea = obj->Radius * 10.0; else { if (near->NearObjects.size() > m_Parent->m_BestNeighborsCount) near->RadiusNearArea = near->RadiusNearArea * 0.70; else near->RadiusNearArea = near->RadiusNearArea * 1.3; if (near->RadiusNearArea < obj->Radius * 3.0) near->RadiusNearArea = obj->Radius * 3.0; } near->RadiusMoveArea = near->RadiusNearArea * 0.5; m_Parent->CalculateNear(near, m_Index); } nearSize = near->NearObjects.size(); if (nearSize == 0) m_Index++; } }
bool CArgsParser::GetValue(int *pValue) const { if (IsEnd()) return false; *pValue=_wtoi(m_ppszArgList[m_CurPos]); return true; }
bool CArgsParser::GetValue(DWORD *pValue) const { if (IsEnd()) return false; *pValue=wcstoul(m_ppszArgList[m_CurPos],NULL,0); return true; }
bool CArgsParser::IsSwitch() const { if (IsEnd()) return false; return m_ppszArgList[m_CurPos][0]==L'-' || m_ppszArgList[m_CurPos][0]==L'/'; }
IGameToken *This() { if(IsEnd()) return 0; else return m_it->second; }
/* 自定义动作 */ void move() { while(!IsEnd()) { if(IsRightWall()) { if(!IsFrontWall()) { step(); } else { turnLeft(); } } else { turnLeft(); turnLeft(); turnLeft(); step(); } } return ; }
/////////////////////////////////////////////////////////////////////////////// // GetNoun // note -- you can only call this once after the verb (it eats the rest // of the line!) /////////////////////////////////////////////////////////////////////////////// static void GetNoun( TSTRING& noun ) { static TSTRING prevNoun; TCHAR buf[1024]; TCIN.getline( buf, 1024 ); // // find the end of the noun... // TCHAR* pStart = buf; TCHAR* end = &buf[1023]; while( IsSpace(*pStart) && (! IsEnd(*pStart)) && (pStart < end) ) pStart++; if( IsEnd( *pStart ) || (pStart >= end) ) { // no noun! noun = _T(""); return; } TCHAR* pCur = pStart; bool bQuote = false; if( *pCur == _T('\"') ) { bQuote = true; pCur++; pStart++; } while( pCur < end ) { if( (! bQuote) && IsSpace(*pCur) ) break; if( *pCur == _T('\"') && bQuote) break; pCur++; } noun.assign(pStart, (pCur - pStart)); if( noun.compare( _T("!$") ) == 0 ) { noun = prevNoun; } prevNoun = noun; }
CrossNearSelector::Iterator::Iterator(CrossNearSelector* a_Parent) { m_Index = 0; m_NearIndex = 0; m_Parent = a_Parent; if (!IsEnd()) FindNextFullNear(); }
//全体動作 int CBossChenMiddle::Thread() { TSunFunctionCallback<CBossChenMiddle> fn; TSunFunctionCallback<CBossChenBase> fnb; //出現 flag = 0; deffence = 0; //会話 g_pPlayer->Talk(); pTalk = new CTalkChen1(); pTalk->Start(); while( !pTalk->IsEnd() ) mt3.Suspend(); SAFE_DELETE(pTalk); g_pPlayer->Resume(); //通常攻撃 fnb.SetFunction(this,&CBossChenBase::NormalAtack1); mt.Start(&fnb,0x8000); while( !IsEnd() ) mt3.Suspend(); mt.Stop(); //陰陽「太極図」 SpellCard(); fn.SetFunction(this,&CBossChenMiddle::Taikyoku); mt.Start(&fn,0x8000); while( !IsEnd() ) mt3.Suspend(); SpellEnd(); mt.Stop(); this->AddItem(ITEM_BOMB,1); //エフェクト flag = 0; deffence = 0; g_lEffect.Add( new CEffectBreak( GetX(), GetY() )); mt3.Suspend( 60 ); //退却 for( int i = 0; i < 46; i++ ) { x += 5; mt3.Suspend(); } return 1; }
bool BufferStream::CanRead() const { if (MEDUSA_FLAG_HAS(Operations(), StreamDataOperation::Read)) { return !IsEnd(); } return false; }
bool CArgsParser::GetText(LPWSTR pszText,int MaxLength) const { if (IsEnd()) return false; if (::lstrlen(m_ppszArgList[m_CurPos])>=MaxLength) return false; ::lstrcpy(pszText,m_ppszArgList[m_CurPos]); return true; }
bool CSECEditor::MoveForwardIdentifier (TEXTPOS &textPos) { TEXTPOS tempPos=textPos; SkipSpacesForward (tempPos); if (IsEnd (tempPos) || !IsIdentifier (GetCharacter (tempPos))) { return (false); }; do { MoveForward (tempPos); } while (!IsEnd (tempPos) && IsIdentifier (GetCharacter (tempPos))); textPos = tempPos; return (true); }
bool TScanTable::Find(TKey key) { for (Reset(); !IsEnd(); GoNext()) { Eff++; if (pRec[curr].GetKey() == key) return true; } return false; }
void LuaVM::LoadFiles(const char* szPath) const { FileSystem::FileData files(255); FileSystem::GetListOfFiles(szPath, "*.lua", files); for(auto it = files.Begin(); !it.IsEnd(); ++it) { ExecuteFile((*it)); } }
IGameToken *Next() { if(IsEnd()) return 0; else { IGameToken *pCurrent=m_it->second; std::advance(m_it, 1); return pCurrent; } }
void CrossSelector::Iterator::Next() { if (IsEnd()) return; const size_t size = m_Parent->m_Objects.size(); m_Index2++; if (m_Index2 >= size) { m_Index1++; m_Index2 = m_Index1 + 1; } }
void SomeToOtherSelector::Iterator::Next() { if (IsEnd()) return; const size_t size = m_Parent->m_OtherObjects.size(); m_OtherIndex++; if (m_OtherIndex >= size) { m_SomeIndex++; m_OtherIndex = 0; } }
void CrossNearSelector::Iterator::Next() { if (IsEnd()) return; const size_t nearSize = m_Parent->m_NearObjects[m_Index]->NearObjects.size(); m_NearIndex++; if (m_NearIndex >= nearSize) { m_Index++; m_NearIndex = 0; FindNextFullNear(); } }
void CSvnProp::Read(const char* data, const char* dataEnd) { //Read 'copy from' data //Rev std::string value; for(;data != dataEnd && !IsEnd(*data); ++data) value += *data; m_copyFromRev = atoi(value.c_str()); //Path Skip(&data, dataEnd); value.clear(); for(;data != dataEnd && !IsEnd(*data); ++data) value += *data; m_copyFromPath = value; //Props Skip(&data, dataEnd); while(data != dataEnd) data = ReadSingle(data, dataEnd); }
String XmlParser::ReadTextE() { StringBuffer out; for(;;) { String t = ReadText(); if(!IsNull(t)) out.Cat(t); else if(IsEnd()) { PassEnd(); return out; } else Skip(); } }
const char* CSvnProp::ReadSingle(const char* data, const char* dataEnd) { //name std::string name; for(;data != dataEnd && !IsSkip(*data); ++data) name += *data; Skip(&data, dataEnd); std::string value; for(;data != dataEnd && !IsEnd(*data); ++data) value += *data; Skip(&data, dataEnd); m_NameVal[name].swap(value); return data; }
bool CSECEditor::MoveForwardComponent (TEXTPOS &textPos) { TEXTPOS tempPos=textPos; SkipSpacesForward (tempPos); if (IsEnd (tempPos) || GetCharacter (tempPos) != '.') { return (false); }; MoveForward (tempPos); textPos = tempPos; return (true); }
std::string EntryIteratorImpl::GetPath() { if (IsEnd()) { return ""; } EntryAddr addr = current_index_->GetEntryAddr(entry_pos_); assert(current_index_->IsAddrUsed(addr)); if (!current_index_->IsAddrUsed(addr)) { return ""; } if (current_index_->IsLargeEntry()) { EntryLarge *el = static_cast<EntryLarge*>(current_index_->GetEntryByAddr(addr)); return el->path; } EntryShort *es = static_cast<EntryShort*>(current_index_->GetEntryByAddr(addr)); return es->path; }
//全体動作 int CBossMystiaMiddle::Thread(){ TSunFunctionCallback<CBossMystiaMiddle> fn; TSunFunctionCallback<CBossMystiaBase> fnb; //出現 flag = 0; deffence = 0; /* for( int i = 0; i < 46; i++ ){ x -= 5; mt3.Suspend(); } mt3.Suspend(30); */ //会話 g_pPlayer->Talk(); pTalk = new CTalkMystia1(); pTalk->Start(); while( !pTalk->IsEnd() ) mt3.Suspend(); SAFE_DELETE(pTalk); g_pPlayer->Resume(); //通常攻撃 SetHP(1000); SetTime(20); fnb.SetFunction(this,&CBossMystiaBase::NormalAtack1); mt.Start(&fnb,0x8000); while( !IsEnd() ) mt3.Suspend(); mt.Stop(); this->AddItem(ITEM_1UP,1); //エフェクト flag = 0; deffence = 0; g_lEffect.Add( new CEffectBreak( GetX(), GetY() )); mt3.Suspend( 60 ); //退却 for( int i = 0; i < 46; i++ ){ x += 5; mt3.Suspend(); } return 1; }
void CmdUart_t::IProcessByte(uint8_t b) { uint8_t d=0; if(b == '#') RxState = rsCmdCode1; // If # is received anywhere, start again else switch(RxState) { case rsCmdCode1: if(TryConvertToDigit(b, &d)) { CmdCode = d << 4; RxState = rsCmdCode2; } else IResetCmd(); break; case rsCmdCode2: if(TryConvertToDigit(b, &d)) { CmdCode |= d; RxState = rsData1; } else IResetCmd(); break; case rsData1: if(TryConvertToDigit(b, &d)) { *PCmdWrite = d << 4; RxState = rsData2; } else if(IsDelimiter(b)) return; // skip delimiters else if(IsEnd(b)) { UartCmdCallback(CmdCode, CmdData, (PCmdWrite - CmdData)); IResetCmd(); } else IResetCmd(); break; case rsData2: if(TryConvertToDigit(b, &d)) { *PCmdWrite |= d; RxState = rsData1; // Prepare to rx next byte if(PCmdWrite < (CmdData + (UART_CMDDATA_SZ-1))) PCmdWrite++; } else IResetCmd(); // Delimiters and End symbols are not allowed in the middle of byte break; default: break; } // switch }