int TimedMilestonePath::Eval(Real t,Config& x) const { Assert(!edges.empty()); if(t < 0) { x = Begin(); return -1; } for(size_t i=0;i<edges.size();i++) { if(t <= durations[i]) { if(durations[i] == 0) x=edges[i]->Start(); else edges[i]->Eval(t/durations[i],x); return (int)i; } t -= durations[i]; } //fall through: t is longer than path x = End(); return edges.size(); }
//==============================================================// // // //==============================================================// void vrWrapper::Render() { Begin(); if ( object ) { vrTriObject2 *o = ( vrTriObject2* )object; if ( o ) o->Render(); } End(); }
String String::Reverse() const { if (Length() < 2) { return String(*this); } String result; result.Allocate(Length()); Iterator dest = result.MutableEnd(); for (ConstIterator src = Begin(); src != End(); ++src) { --dest; *dest = *src; } return result; }
bool TextTable::SaveToBinary(Serializer& serializer) { serializer.Refresh(); BYTE byMargin = 1; serializer << byMargin; TABLE::iterator iter; for (iter = Begin(); End() != iter; iter++) { sTEXT_TBLDAT* pTableData = (sTEXT_TBLDAT*)(iter->second); serializer << pTableData->tblidx; serializer << (WORD)((pTableData->wstrText).size()); serializer.In((pTableData->wstrText).c_str(), (int)((pTableData->wstrText).size() * sizeof(WCHAR))); } return true; }
/* * Draw a square with 3D relief */ void gl_list_square_bevelled_plain (fpoint tl, fpoint br, texp tex, fsize tex_tl, fsize tex_br, fsize uv, color hi, color med, color lo, fsize bevel) { fpoint a = {tl.x, tl.y}; fpoint b = {br.x, tl.y}; fpoint c = {br.x, br.y}; fpoint d = {tl.x, br.y}; fpoint a1 = {tl.x + bevel.width, tl.y + bevel.height}; fpoint b1 = {br.x - bevel.width, tl.y + bevel.height}; fpoint c1 = {br.x - bevel.width, br.y - bevel.height}; fpoint d1 = {tl.x + bevel.width, br.y - bevel.height}; glEnable(GL_TEXTURE_2D); /* * Draw the central flat square */ Begin(GL_TRIANGLE_FAN); glcolor(med); vertex(tl, br, a.x, a.y, tex_tl, tex_br, uv); vertex(tl, br, b.x, b.y, tex_tl, tex_br, uv); vertex(tl, br, c.x, c.y, tex_tl, tex_br, uv); vertex(tl, br, d.x, d.y, tex_tl, tex_br, uv); End(); /* * Now draw the bevelled border */ glcolor(lo); quaduv(tl, br, c1, c, d, d1, tex_tl, tex_br, uv); glcolor(hi); quaduv(tl, br, a, a1, d1, d, tex_tl, tex_br, uv); glcolor(hi); quaduv(tl, br, a, b, b1, a1, tex_tl, tex_br, uv); glcolor(lo); quaduv(tl, br, b, c, c1, b1, tex_tl, tex_br, uv); }
void BH280::LoopOfflineExample() { /* ***************************** hand thread ***************************** */ Begin(VEL_CONTROL); double T=0.0; gettimeofday(&lc, NULL); while (shouldRun) { gettimeofday(&now, NULL); T+=diffclock(&now,&lc); ReadFromHand(); double f=0.2;//Hz double value = 0.8*PI/3 + (PI/4*sin( f* T*2*PI)); if(!pps) { int m=1; Cons.cValues[m]=value; int temp=(int)((PositionControlC(m) * props.scaleIN[m])+0.5); result=bh.RTSetVelocity(m + '1', temp); m=0; Cons.cValues[m]=value; temp=(int)((PositionControl(m) * props.scaleIN[m])+0.5); result=bh.RTSetVelocity(m + '1', temp); m=3; Cons.cValues[m]=1; temp=(int)((PositionControl(m) * props.scaleIN[m])+0.5); result=bh.RTSetVelocity(m + '1', temp); } bh.RTUpdate(); RememberData(); } bh.RTAbort(); result = bh.Command("t"); cout<<"Terminating thread bh280\n"; }
LLBC_Array::Iter LLBC_Array::Replace(LLBC_Array::Iter n0, Obj *o) { if (UNLIKELY(o)) { LLBC_SetLastError(LLBC_ERROR_ARG); return End(); } if (!(n0 >= Begin() && n0 < End())) { LLBC_SetLastError(LLBC_ERROR_ARG); return End(); } _objs[n0._idx]->Release(); _objs[n0._idx] = o; _objs[n0._idx]->Retain(); return n0; }
void Painter::DrawTextOp(int x, int y, int angle, const wchar *text, Font font, Color ink, int n, const int *dx) { Begin(); EvenOdd(true); if(angle) Rotate(angle * M_2PI / 36000); if(n < 0) n = wstrlen(text); double *ddx = NULL; Buffer<double> h; if(dx) { h.Alloc(n); ddx = h; for(int i = 0; i < n; i++) ddx[i] = dx[i]; } Text(x, y, text, font, n, ddx); Fill(ink); End(); }
_JATTA_EXPORT Jatta::String Jatta::JSON::Object::ToString() { Jatta::String ret = "{\n"; Jatta::JSON::ind++; for (std::map<Jatta::String, Jatta::JSON::Value>::iterator e = Begin(); e != End();) { ret += Jatta::JSON::__Indent(); ret += '"'; ret += e->first; ret += "\": "; ret += e->second.ToString(); if (++e != End()) ret += ','; ret += "\n"; } Jatta::JSON::ind--; ret += Jatta::JSON::__Indent(); ret += "}"; return ret; }
//-------------------------------------------------------------------------------------- // Class: YARPSoundDeviceDriver // Method: open // Description: (public) this is one of the external visible method. It supports the // abstraction (open,close,IOCtl). //-------------------------------------------------------------------------------------- int YARPSoundDeviceDriver::open (void *res) { int ret; SoundResources& d = RES(system_resources); Begin (); //Start the thread first. The identifier is necesary in the lower level /*************************************************************************** * The thread ID is necesary to run the waveIn call that uses it to assing * * the callback message to this thread. Therefore, the Body part of the * * thread will receive the messages (linked internally to hardware * * interrupts) generated by the low level sound driver. * ***************************************************************************/ ((SoundOpenParameters *)res)->m_callbackthread_identifier = this->identifier; ret = d._initialize (*(SoundOpenParameters *)res); return ret; }
VGraphicPath::VGraphicPath( const VPolygon& inPolygon) { _Init( false, true); Begin(); sLONG count = inPolygon.GetPointCount(); if (count >= 2) { VPoint pt; inPolygon.GetNthPoint( 1, pt); BeginSubPathAt( pt); VPoint ptStart = pt; for (sLONG index = 2; index <= count; index++) { inPolygon.GetNthPoint( index, pt); AddLineTo( pt); } if (pt != ptStart) CloseSubPath(); } End(); }
size_t List<T>::Remove (const T& t) // Remove all copies of t // This doesn't use member priviledge, so could be an external function // It gives the archetype for interaction between Remove(i) and ++i { size_t count(0); Iterator i = Begin(); while (i != End()) { if (t == *i) { i = Remove(i); ++count; } else { ++i; } } return (count); } // end Remove(t)
void LLBC_Array::SerializeInl(LLBC_Stream &s, bool extended) const { LLBC_STREAM_BEGIN_WRITE(s); LLBC_STREAM_WRITE(static_cast<uint64>(_size)); ConstIter it = Begin(), endIt = End(); for (; it != endIt; it++) { if (!extended) { LLBC_STREAM_WRITE(*it); } else { LLBC_STREAM_WRITE_EX(*it); } } LLBC_STREAM_END_WRITE(); }
void VGraphicPath::BeginSubPathAt(const VPoint& inLocalPoint) { #if !GRAPHIC_MIXED_GDIPLUS_D2D if (!VWinD2DGraphicContext::IsAvailable()) { #endif fLastPoint = VPoint((GReal)inLocalPoint.GetX(), (GReal)inLocalPoint.GetY()); fPath->StartFigure(); #if !GRAPHIC_MIXED_GDIPLUS_D2D } #endif #if ENABLE_D2D if (VWinD2DGraphicContext::IsAvailable()) { if (!fGeomSink) { Begin(); if (!fGeomSink) return; } if (!fFigureIsClosed) //do not forget to close current figure before opening new figure to prevent really nasty artifacts... fGeomSink->EndFigure( D2D1_FIGURE_END_OPEN); fGeomSink->BeginFigure( D2D1::Point2F( inLocalPoint.GetX(), inLocalPoint.GetY()), D2D1_FIGURE_BEGIN_FILLED); fFigureIsClosed = false; } #endif fPolygon.AddPoint(inLocalPoint); if (fComputeBoundsAccurate) _addPointToBounds( inLocalPoint); _ComputeBounds(); if (fCreateStorageForCrispEdges) fDrawCmds.push_back( VGraphicPathDrawCmd( GPDCT_BEGIN_SUBPATH_AT, inLocalPoint)); }
/*********************************************** PROGRAMME PRINCIPAL **/ int main(int argc, char* argv[]) { // vérification nombre arguments if (argc < 2) { printf("usage : %s <OPTION|command> [TASK]\n%s --help to print some help\n", argv[0], argv[0]); exit(1); } // création de la structure partagée key_t k = ftok(argv[0], 'x'); int ssid = shmget(k, sizeof(StrShared), IPC_CREAT | 0777); sha = shmat(ssid, NULL, 0); // lecture de la configuration GetConfig(); // initialisation de la structure InitShared(); // début du traitement Begin(argc, argv); // ne pas détruire la mémoire s'il reste des instances if (sha->instance > 1) { sha->instance--; shmdt(sha); } else { // dernière instance en cours sha->instance--; // sauvegarde des files d'attente SaveTasks(); // destruction structure partagée shmdt(sha); shmctl(ssid, IPC_RMID, NULL); } return 0; }
void ConfDb::OpenDb(const string& dbFile, bool needInit) { sqlite3_open(dbFile.c_str(), &mDbConn); SetupPragma(); if (needInit) { ExecSql(SQL_CREATE_TABLE_CONF); Begin(); FORMAT_SQL(SQL_INSERT_CONF_INT, KEY_WND_X, 0); ExecSql(); FORMAT_SQL(SQL_INSERT_CONF_INT, KEY_WND_Y, 0); ExecSql(); FORMAT_SQL(SQL_INSERT_CONF_INT, KEY_WND_WIDTH, 0); ExecSql(); FORMAT_SQL(SQL_INSERT_CONF_INT, KEY_WND_HEIGHT, 0); ExecSql(); FORMAT_SQL(SQL_INSERT_CONF_STR, KEY_LAST_OPEN_PATH, ""); ExecSql(); Commit(); } }
void msg_valor_depositado_banco_handler(int socket, mensagem_s *msg) { if (msg->size < HEADER_SIZE + 4) { disconnect(socket); return; } fprintf(stdout, "MENSAGEM: CMSG_VALOR_DEPOSITADO_BANCO"); int token = msg_recv_int(msg); mensagem_s * s = preparePacket(SMSG_VALOR_DEPOSITADO_RESPONSE); //obter a session activa Session *session = GetSession(token); if (session && session->sessionExpire >= currTime) { if (session->cliente->flags == ACCESS_LEVEL_ENTIDADE || session->cliente->flags == ACCESS_LEVEL_CLIENTE) { msg_put_short(ERROR_CODE_TIPO_CONTA_INVALIDA, s); } else { int total = 0; for (LinkedListNode * p = Begin(dbContas); p != NULL; p = Next(p)) { Conta * conta = p->element; total += conta->saldo; } msg_put_short(ERROR_CODE_SUCCESS, s); msg_put_int(total, s); } } else { msg_put_short(ERROR_CODE_SESSAO_EXPIROU, s); } finalizePacket(s); sendData(socket, s); free(s); }
/** Store sample data for all instances in collection. */ void StatisticalLogicalDiskEnumeration::SampleDisks() { SCXCoreLib::SCXThreadLock lock(m_lock); #if defined(linux) m_deps->RefreshProcDiskStats(); #endif for (EntityIterator iter = Begin(); iter != End(); iter++) { SCXCoreLib::SCXHandle<StatisticalLogicalDiskInstance> disk = *iter; try { disk->Sample(); } catch (const SCXCoreLib::SCXException& e) { SCX_LOGERROR(m_log, std::wstring(L"StatisticalLogicalDiskEnumeration::SampleDisks() - Unexpected exception caught: ").append( e.What()).append(L" - ").append(e.Where()).append( L"; for logical disk ").append(disk->m_device) ); } } }
void SpriteBatch::Flush() { //Game drawn in negative //Game hUD drawn in positive Begin(); //Sprites FlushSprites(m_SpriteQueue); //First background text for(auto& textDesc : m_TextBackQueue) { FlushText(textDesc); } //Clean all variables again m_WorldMatBuffer.clear(); m_VertexBuffer.clear(); m_UvCoordBuffer.clear(); m_CurrentSprite = 0; m_CurrentHudSprite = 0; //HUD FlushSprites(m_HudSpriteQueue); //Front text for(auto& textDesc : m_TextFrontQueue) { FlushText(textDesc); } //Clean all variables again m_WorldMatBuffer.clear(); m_VertexBuffer.clear(); m_UvCoordBuffer.clear(); m_CurrentSprite = 0; m_CurrentHudSprite = 0; End(); }
void Snake::Update() { if(!Reset && millis() > StartTime + Delay) { StartTime = millis(); // while not in range, and selected voxel is not currently turned on if(Length <= 0 || !Cube->InRange(Cur_x + Dir_x,Cur_y + Dir_y,Cur_z + Dir_z) ||Cube->GetVoxel(Cur_x + Dir_x,Cur_y + Dir_y,Cur_z + Dir_z) == 1) { Reset = !CalculateDirection(); } Cur_x += Dir_x; Cur_y += Dir_y; Cur_z += Dir_z; Length--; AddBody(Cur_x,Cur_y,Cur_z); } else if(Reset && millis()-(Delay+2000) > StartTime) { DeleteArray(); Begin(); } }
int main() { Begin(); Start(); Draw(); for (; Create();) { Refresh(); bool next = true; for (int a = 0; next; a++) { int limit = 50000 / level; if (!pause && a > limit) { a = 0; next = Fall(); Refresh(); } if (kbhit()) { next = Load(); Refresh(); } BonusPauses(); } } return 0; }
virtual void Visit(const AbstractAirspace &airspace) override { if (warnings.IsAcked(airspace)) return; AirspaceClass airspace_class = airspace.GetType(); if (settings.fill_mode == AirspaceRendererSettings::FillMode::NONE || settings.classes[airspace_class].fill_mode == AirspaceClassRendererSettings::FillMode::NONE) return; Begin(); SetBufferPens(airspace); switch (airspace.GetShape()) { case AbstractAirspace::Shape::CIRCLE: VisitCircle((const AirspaceCircle &)airspace); break; case AbstractAirspace::Shape::POLYGON: VisitPolygon((const AirspacePolygon &)airspace); break; } }
decltype(std::declval<T>().Get()) DNSHandler::begin (const String & name, Args &&... args) { auto ptr=std::unique_ptr<Query>(new T(std::forward<Args>(args)...)); return lock.Execute([&] () mutable { auto p=ptr.get(); auto pair=queries.emplace( p, std::move(ptr) ); try { issue_command(); p->Begin( channel, name, complete ); wait.WakeAll(); } catch (...) { queries.erase(pair.first); throw; } return reinterpret_cast<T *>(p)->Get(); }); }
bool BRCWriter::WriteJumpTable(Symbols &syms) { Begin(); for (auto sym : syms) { SymData *s = sym.second; if (s->data.size()) { BrowseData *gl = nullptr, *ex = nullptr; for (auto b : s->data) { if (b->type == ObjBrowseInfo::eFuncStart) { if (b->qual == ObjBrowseInfo::eExternal) { ex = b; } else { gl = b; } } } if (!gl) gl = ex; if (gl) { int st = gl->startLine; int end = gl->funcEndLine; if (!Insert(fileMap[gl->fileIndex], st, end, s->index)) return false; } } } End(); return true; }
void VGraphicPath::AddLineTo(const VPoint& inDestPoint) { #if !GRAPHIC_MIXED_GDIPLUS_D2D if (!VWinD2DGraphicContext::IsAvailable()) { #endif Gdiplus::PointF d = Gdiplus::PointF(inDestPoint.GetX(), inDestPoint.GetY()); fPath->AddLine(Gdiplus::PointF(fLastPoint.x,fLastPoint.y), d); fLastPoint.x = d.X; fLastPoint.y = d.Y; #if !GRAPHIC_MIXED_GDIPLUS_D2D } #endif #if ENABLE_D2D if (VWinD2DGraphicContext::IsAvailable()) { if (!fGeomSink) { Begin(); if (!fGeomSink) return; } fGeomSink->AddLine( D2D1::Point2F( inDestPoint.GetX(), inDestPoint.GetY())); } #endif fPolygon.AddPoint(inDestPoint); if (fComputeBoundsAccurate) _addPointToBounds( inDestPoint); _ComputeBounds(); if (fCreateStorageForCrispEdges) fDrawCmds.push_back( VGraphicPathDrawCmd( GPDCT_ADD_LINE_TO, inDestPoint)); }
/* ?host (staff message, event list, start an event) */ local void cHost(const char *command, const char *params, Player *p, const Target *target) { /* Send a host message if the player isn't a staff member. */ if (!capman->HasCapability(p,CAP_IS_STAFF)) { if (IS_ALLOWED(chat->GetPlayerChatMask(p), MSG_MODCHAT)) { Arena *arena = p->arena; if (params) { chat->SendModMessage("(Host) {%s} %s: %s", arena->name, p->name, params); chat->SendMessage(p, "Message has been sent to online staff"); } else { chat->SendMessage(p, "Invalid syntax. Please use ?host <arena/event> to request an event be hosted."); } return; } } /* Host list or an event if the player is a staff member. */ if (!isalpha(params[0]) && params[0] != '-') { chat->SendMessage(p, "-------------------------------------------------------------------"); chat->SendMessage(p, "| Paintball | Two teams face off in a game of paintball (soccer). |"); chat->SendMessage(p, "-------------------------------------------------------------------"); chat->SendMessage(p, "Parameters: goals: -g(#)"); chat->SendMessage(p, " ships: -s(#)"); chat->SendMessage(p, "Example: ?start paintball -g(5) -s(1,2,3)"); } else { Begin(p, p->arena, params); } }
int main(int argc, char* argv[]) { CreateWindow("GLM core and GLM extensions for intermediate mode", 640, 480, false); Begin(640, 480); bool Exit = false; while(!Exit) { SDL_Event Event; while(SDL_PollEvent(&Event)) { switch(Event.type) { case SDL_QUIT: case SDL_KEYDOWN: Exit = true; break; } } static float Time = 0.0f; Time += 0.1f; Render(Time); SDL_GL_SwapBuffers(); } End(); DeleteWindow(); return 0; }
char *String0::Insert(int pos, int count, const char *s) { ASSERT(pos >= 0 && count >= 0 && pos <= GetCount()); int len = GetCount(); int newlen = len + count; char *str = (char *)Begin(); if(newlen < GetAlloc() && !IsSharedRef()/* && !(s >= str && s <= str + len)*/) { if(s >= str + pos && s <= str + len) s += count; if(pos < len) memmove(str + pos + count, str + pos, len - pos); if(IsSmall()) SLen() = newlen; else LLen() = newlen; str[newlen] = 0; if(s) memcpy(str + pos, s, count); return str + pos; } char kind; char *p = Alloc(max(2 * len, newlen), kind); if(pos > 0) memcpy(p, str, pos); if(pos < len) memcpy(p + pos + count, str + pos, len - pos); if(s) memcpy(p + pos, s, count); p[newlen] = 0; Free(); ptr = p; LLen() = newlen; SLen() = 15; chr[KIND] = kind; return ptr + pos; }
String String::Trim(bool left, bool right) const { if (HasChars()) { ConstIterator begin = Begin(), end = End(); while (left && begin != end && begin->IsWhiteSpace()) { ++begin; } while (right && end > begin && (end - 1)->IsWhiteSpace()) { --end; } if (end > begin) { return SubString(begin, end); } } return String(); }
ConstIterator Find(const Value &value) const { ConstIterator start(Begin()); if (start.fReferenceIterator != fReferenceVector.end()) { for (; start.fReferenceIterator != fReferenceVector.end(); ++start.fReferenceIterator, ++start.fMyIterator) { if (*start.fReferenceIterator == value) { MyConstIterator myIt = fMyVector.Find(value); CHK(&*myIt == &*start.fMyIterator); return start; } } CHK(fMyVector.Find(value) == fMyVector.End()); CHK(start.fMyIterator == fMyVector.End()); return start; } CHK(fMyVector.Find(value) == fMyVector.End()); return start; }