hexsha
stringlengths
40
40
size
int64
7
1.05M
ext
stringclasses
13 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
4
269
max_stars_repo_name
stringlengths
5
109
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
9
max_stars_count
int64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
4
269
max_issues_repo_name
stringlengths
5
116
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
9
max_issues_count
int64
1
48.5k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
4
269
max_forks_repo_name
stringlengths
5
116
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
9
max_forks_count
int64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
7
1.05M
avg_line_length
float64
1.21
330k
max_line_length
int64
6
990k
alphanum_fraction
float64
0.01
0.99
author_id
stringlengths
2
40
edad738c6933a31132ed838252b55eb49e03c4f8
546
cpp
C++
lib/src/http_get_video_dir.cpp
asjadenet/videoplayer
551ff1f3122c479a3e4f0c6db73cc50d98a12d50
[ "MIT" ]
1
2019-01-24T01:06:35.000Z
2019-01-24T01:06:35.000Z
lib/src/http_get_video_dir.cpp
asjadenet/videoplayer
551ff1f3122c479a3e4f0c6db73cc50d98a12d50
[ "MIT" ]
null
null
null
lib/src/http_get_video_dir.cpp
asjadenet/videoplayer
551ff1f3122c479a3e4f0c6db73cc50d98a12d50
[ "MIT" ]
null
null
null
#include <HttpGet.h> #include <parse_video_dir.h> #include <Config.h> #include "http_get_video_dir.h" std::string http_get_video_dir(const std::string& host, const std::string& port) { auto result = HttpGet::execute(host, port, "/jsonrpc?request={\"jsonrpc\":\"2.0\",\"method\":\"Files.GetSources\",\"params\":{\"media\":\"video\"},\"id\":1}", 1000); return parse_video_dir(result.body); // return result.body; // return std::to_string(result.status_code); }
36.4
150
0.589744
asjadenet
edb0758d2eaaf4e45aa0bfe39a1d07303c834c1b
692
cpp
C++
recursion/tricky_permutations.cpp
nancyanand2807/algorithm-ds
9f79bd9a37bdf858a512ded44aa33040e8a7b9af
[ "MIT" ]
5
2020-10-01T13:08:35.000Z
2021-02-01T17:51:15.000Z
recursion/tricky_permutations.cpp
nancyanand2807/algorithm-ds
9f79bd9a37bdf858a512ded44aa33040e8a7b9af
[ "MIT" ]
21
2020-10-01T12:58:05.000Z
2020-10-07T11:58:30.000Z
recursion/tricky_permutations.cpp
sansyrox/summer_of_cpp
e07acee254e25febe5b11bc1adc743f5aaf57cc8
[ "MIT" ]
23
2020-10-01T12:59:06.000Z
2020-10-15T13:08:34.000Z
#include<iostream> #include<bits/stdc++.h> using namespace std; #define ll long long #define mp make_pair #define pb push_back vector<string> v; bool find(vector<string> v, string s){ for(auto j:v){ if(j==s) return true; } return false; } void genPerms(string a, int i=0){ if(i==a.length()){ // cout<<a<<endl; if( !find(v,a)){ v.pb(a); } return; } for(int j=i; j<a.length(); j++){ swap(a[i],a[j]); genPerms(a,i+1); // swap(a[i],a[j]); } } int main() { string a; cin>>a; sort(a.begin(), a.end()); genPerms(a,0); for(auto j:v) cout<<j<<endl; return 0; }
16.093023
38
0.498555
nancyanand2807
edb3127b3a39867f4ff418e670cf19564f38cb3d
1,807
hpp
C++
external/boost_1_60_0/qsboost/bind/placeholders.hpp
wouterboomsma/quickstep
a33447562eca1350c626883f21c68125bd9f776c
[ "MIT" ]
1
2019-06-27T17:54:13.000Z
2019-06-27T17:54:13.000Z
external/boost_1_60_0/qsboost/bind/placeholders.hpp
wouterboomsma/quickstep
a33447562eca1350c626883f21c68125bd9f776c
[ "MIT" ]
null
null
null
external/boost_1_60_0/qsboost/bind/placeholders.hpp
wouterboomsma/quickstep
a33447562eca1350c626883f21c68125bd9f776c
[ "MIT" ]
null
null
null
#ifndef QSBOOST_BIND_PLACEHOLDERS_HPP_INCLUDED #define QSBOOST_BIND_PLACEHOLDERS_HPP_INCLUDED // MS compatible compilers support #pragma once #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif // // bind/placeholders.hpp - _N definitions // // Copyright (c) 2002 Peter Dimov and Multi Media Ltd. // Copyright 2015 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt // // See http://www.boost.org/libs/bind/bind.html for documentation. // #include <qsboost/bind/arg.hpp> #include <qsboost/config.hpp> namespace qsboost { namespace placeholders { #if defined(__BORLANDC__) || defined(__GNUC__) && (__GNUC__ < 4) inline qsboost::arg<1> _1() { return qsboost::arg<1>(); } inline qsboost::arg<2> _2() { return qsboost::arg<2>(); } inline qsboost::arg<3> _3() { return qsboost::arg<3>(); } inline qsboost::arg<4> _4() { return qsboost::arg<4>(); } inline qsboost::arg<5> _5() { return qsboost::arg<5>(); } inline qsboost::arg<6> _6() { return qsboost::arg<6>(); } inline qsboost::arg<7> _7() { return qsboost::arg<7>(); } inline qsboost::arg<8> _8() { return qsboost::arg<8>(); } inline qsboost::arg<9> _9() { return qsboost::arg<9>(); } #else QSBOOST_STATIC_CONSTEXPR qsboost::arg<1> _1; QSBOOST_STATIC_CONSTEXPR qsboost::arg<2> _2; QSBOOST_STATIC_CONSTEXPR qsboost::arg<3> _3; QSBOOST_STATIC_CONSTEXPR qsboost::arg<4> _4; QSBOOST_STATIC_CONSTEXPR qsboost::arg<5> _5; QSBOOST_STATIC_CONSTEXPR qsboost::arg<6> _6; QSBOOST_STATIC_CONSTEXPR qsboost::arg<7> _7; QSBOOST_STATIC_CONSTEXPR qsboost::arg<8> _8; QSBOOST_STATIC_CONSTEXPR qsboost::arg<9> _9; #endif } // namespace placeholders } // namespace boost #endif // #ifndef BOOST_BIND_PLACEHOLDERS_HPP_INCLUDED
28.68254
67
0.724958
wouterboomsma
edb4a282b36986958f451763d8cbc554b43ddc19
4,580
cpp
C++
CSE 225L Data Structures and Algorithms/Resources/Codes Previous/Spring-2019-CSE225 1/Lab 13(Unsorted Linked List)/list(9).cpp
diptu/Teaching
20655bb2c688ae29566b0a914df4a3e5936a2f61
[ "MIT" ]
null
null
null
CSE 225L Data Structures and Algorithms/Resources/Codes Previous/Spring-2019-CSE225 1/Lab 13(Unsorted Linked List)/list(9).cpp
diptu/Teaching
20655bb2c688ae29566b0a914df4a3e5936a2f61
[ "MIT" ]
null
null
null
CSE 225L Data Structures and Algorithms/Resources/Codes Previous/Spring-2019-CSE225 1/Lab 13(Unsorted Linked List)/list(9).cpp
diptu/Teaching
20655bb2c688ae29566b0a914df4a3e5936a2f61
[ "MIT" ]
null
null
null
#include "list.h" #include <iostream> using namespace std; template<class T> SinglyLinkedList<T>::SinglyLinkedList() { // cout << "In SinglyLinkedList constructor"<<endl; head = curptr = NULL; length=0; } template<class T> SinglyLinkedList<T>::~SinglyLinkedList() { // cout << "In SinglyLinkedList Destructor" << endl; while(!isEmpty()) deleteStart(); } template<class T> bool SinglyLinkedList<T>::isEmpty() { return head==NULL; } template<class T> int SinglyLinkedList<T>::listSize() { return length; } template<class T> bool SinglyLinkedList<T>::hasNext() { return curptr!=NULL; } template<class T> T SinglyLinkedList<T>::nextItem() { if(isEmpty()) throw ListEmpty(); T val = curptr->data; curptr = curptr->next; return val; } template<class T> void SinglyLinkedList<T>::reset() { curptr == head; } template<class T> void SinglyLinkedList<T>::display() { reset(); while(hasNext()) cout << nextItem() << endl; } template<class T> void SinglyLinkedList<T>::insertAtStart(T value) { node<T>*temp = new node<T>; temp->data = value; temp->next = NULL; if(head==NULL) { head = temp; temp = NULL; } else { temp->next=head; head=temp; } length++; curptr = head; } template<class T> void SinglyLinkedList<T>::insertAtPosition(T value, int pos) { if(pos>length+1 || pos<=0) throw PositionOutOfBound(); if(pos==1) insertAtStart(value); return; node<T>*pre,*cur; node<T>*temp = new node<T>; cur = head; for(int i=1;i<pos;i++) { pre = cur; cur = cur->next; } temp->data = value; temp->next = cur; pre->next=temp; length++; } template<class T> void SinglyLinkedList<T>::insertAtEnd(T val) { insertAtPosition(val,length+1); } template<class T> int SinglyLinkedList<T>::searchItem(T key) { reset(); for(int i=1;hasNext();i++) { if(nextItem()==key) return i; } return 0; } template<class T> void SinglyLinkedList<T>::deleteStart() { if(isEmpty()) throw ListEmpty(); node<T>*temp = head; head = head->next; delete temp; length--; curptr=head; } template<class T> void SinglyLinkedList<T>::deleteAtPosition(int pos) { if(isEmpty()) throw ListEmpty(); if(pos>length+1 || pos<=0) throw PositionOutOfBound(); if(pos==1) deleteStart(); return; node<T>*pre,*cur = head; for(int i=1;i<pos;i++) { pre = cur; cur = cur->next; } pre->next=cur->next; delete cur; length--; } template<class T> void SinglyLinkedList<T>::deleteEnd() { deleteAtPosition(length); } template<class T> T SinglyLinkedList<T>::getValue(int pos) { if(pos>length+1 || pos<=0) throw PositionOutOfBound(); node<T>*cur=head; for(int i=1;i<pos;i++) { cur = cur -> next; } return cur->data; } template<class T> void SinglyLinkedList<T>::setValue(int pos,T val) { if(pos>length+1 || pos<=0) throw PositionOutOfBound(); node<T>*cur=head; for(int i=1;i<pos;i++) cur = cur->next; cur->data = val; } //With Tail Functions template <class T> SinglyLinkedListWithTail<T>::SinglyLinkedListWithTail() { // cout << "In SinglyLinkedListWithTail constructor"<<endl; } template <class T> SinglyLinkedListWithTail<T>::~SinglyLinkedListWithTail() { // cout << "In SinglyLinkedListWithTail destructor"<<endl; } template<class T> void SinglyLinkedListWithTail<T>::insertAtStart(T value) { node<T> *temp = new node<T>; temp->data=value; temp->next=NULL; if(this->head=NULL) { this->head=tail=temp; temp = NULL; } else { temp->next=this->head; this->head = temp; } this->length++; this->curptr=this->head; } template<class T> void SinglyLinkedListWithTail<T>::insertAtEnd(T value) { node<T> *temp=new node<T>; temp->data=value; temp->next=NULL; if(this->head==NULL) { this->curptr=this->head=tail=temp; temp=NULL; } else { tail->next=temp; tail=temp; } (this->length)++; } template<class T> void SinglyLinkedListWithTail<T>::deleteEnd() { if(this->isEmpty())throw ListEmpty(); if(this->length==1) { this->deleteStart(); return; } node<T> *pre,*cur=this->head; while(cur->next!=NULL) { pre=cur; cur=cur->next; } tail=pre; pre->next=NULL; delete cur; (this->length)--; }
17.821012
62
0.591921
diptu
edb66fd9c074a0961add1e263b10476aeda145ab
6,256
cpp
C++
Jelly/src/Enemy.cpp
RikdeRooij/Hazel
029fd852872be2be66f97f8bb9e4ee525751b18d
[ "Apache-2.0" ]
1
2021-06-17T14:15:45.000Z
2021-06-17T14:15:45.000Z
Jelly/src/Enemy.cpp
RikdeRooij/Hazel
029fd852872be2be66f97f8bb9e4ee525751b18d
[ "Apache-2.0" ]
null
null
null
Jelly/src/Enemy.cpp
RikdeRooij/Hazel
029fd852872be2be66f97f8bb9e4ee525751b18d
[ "Apache-2.0" ]
null
null
null
#include "Enemy.h" #include "DebugDraw.h" #include "RaysCastCallback.h" #include "Player.h" #include "JellyGame.h" using namespace Jelly; void CreateSensor(b2Body* physBody, float size, float xsign) { b2PolygonShape shape2; auto s = b2Vec2(size * 0.5f * UNRATIO, size * 0.5f * UNRATIO); auto ss = b2Vec2(size * 0.25f * UNRATIO, size * 0.25f * UNRATIO); shape2.SetAsBox(ss.x, ss.y, { xsign * (s.x + ss.x + 0.1f * UNRATIO), -s.y }, 0); b2FixtureDef fixtureDef2 = (FixtureData::SENSOR); fixtureDef2.isSensor = true; fixtureDef2.shape = &shape2; physBody->CreateFixture(&fixtureDef2); } Enemy::Enemy(b2Body* bd, TextureAtlas textureRef, float w, float h, float scale) : Character(bd, textureRef, w, h, scale) { PM_SCALE = 0.6f; PM_SCALEY = 1.6f; //m_color = { 1.f, 0.3f, 0.3f, 1.f }; dontDestroy = false; //b2CircleShape shape2; //shape2.m_radius = (size*0.5f * UNRATIO); //shape2.m_p = b2Vec2((-size)* UNRATIO, -size * 0.5f * UNRATIO); //CreateSensor(physBody, size, -1); //CreateSensor(physBody, size, 1); m_Particle.ColorBegin = { 0.9f, 0.0f, 0.0f, 1.0f }; m_Particle.ColorEnd = { 0.8f, 0.0f, 0.0f, 0.1f }; } Enemy::~Enemy() {} void Enemy::Update(float dt) { ai_time += dt; Character::Update(dt); } #define MIN_WALL_NORMAL 0.71f #define MIN_TURN_NORMAL 0.16f Character::Input Enemy::UpdateInput() { if (dead) return Input(false, false, false, false); if (!grounded) { ai_move_left = ai_move_right = false; } else if (!ai_move_left && !ai_move_right) { ai_move_left = Random::Float() > 0.5f; ai_move_right = !ai_move_left; ai_time = 0; } if (ai_time > 0.2f) { if (!ai_player_left && ai_move_left && (psc_normal.x > MIN_TURN_NORMAL || psc_normal.x < -0.6f)) { ai_move_left = false; ai_move_right = true; ai_time = 0; } if (!ai_player_right && ai_move_right && (psc_normal.x < -MIN_TURN_NORMAL || psc_normal.x > 0.6f)) { ai_move_left = true; ai_move_right = false; ai_time = 0; } } bool ai_jump = false; auto player = Player::instance; if (player) { auto d = player->GetPosition() - GetPosition(); if (d.y > 0.9f && d.y < 1.6f && abs(d.x) < 1.3f) { if ((d.x <= 0 && ai_move_left) || (d.x >= 0 && ai_move_right)) ai_jump = true; } } Input ninput = Input(ai_move_left, ai_move_right, ai_jump, false); ninput.update_move = true; return ninput; } #define RAY_DX 0.8f #define RAY_DY 0.5f void ApplyImpulse(b2Vec2 forcePos, Jelly::GameObject * hitgo, int xsign) { const float forcex = 7.f; const float forcey = 5.f; hitgo->GetBody()->SetLinearVelocity({ 0,0 }); hitgo->GetBody()->ApplyLinearImpulse({ xsign * forcex, forcey }, forcePos, true); } void ApplyImpulse(Jelly::GameObject * hitgo, float xsign) { const float forcex = 7.f; const float forcey = 5.f; hitgo->GetBody()->SetLinearVelocity({ 0,0 }); hitgo->GetBody()->ApplyLinearImpulseToCenter({ xsign * forcex, forcey }, true); } void Enemy::UpdateCollisions(b2Vec2& vel) { auto go_pos = GetPosition(); Character::UpdateCollisions(vel); ai_player_left = false; ai_player_right = false; if (dead) return; if (ai_move_left) { // left cast RaysCastCallback callback = RaysCastCallback::RayCastVec({ go_pos.x, go_pos.y }, { -RAY_DX, -RAY_DY }); if (!callback.m_hit) psc_normal.x = max(psc_normal.x, (MIN_TURN_NORMAL + 0.02f)); // move right else if (abs(callback.m_normal.x) > MIN_WALL_NORMAL) { psc_normal.x = max(psc_normal.x, (MIN_TURN_NORMAL + 0.02f)); // move right auto hitgo = callback.GetHitGameObject(); if (hitgo && hitgo->m_type == Objects::Player) { ai_player_left = true; if (callback.m_fraction < 0.5f) { ApplyImpulse(callback.m_point, hitgo, -1); static_cast<Player*>(hitgo)->OnHit(this); } } } } if (ai_move_right) { // right cast RaysCastCallback callback = RaysCastCallback::RayCastVec({ go_pos.x, go_pos.y }, { RAY_DX, -RAY_DY }); if (!callback.m_hit) psc_normal.x = min(psc_normal.x, -(MIN_TURN_NORMAL + 0.02f)); // move left else if (abs(callback.m_normal.x) > MIN_WALL_NORMAL) { psc_normal.x = min(psc_normal.x, -(MIN_TURN_NORMAL + 0.02f)); // move left auto hitgo = callback.GetHitGameObject(); if (hitgo && hitgo->m_type == Objects::Player) { ai_player_right = true; if (callback.m_fraction < 0.5f) { ApplyImpulse(callback.m_point, hitgo, 1); static_cast<Player*>(hitgo)->OnHit(this); } } } } } bool Jelly::Enemy::OnCollision(b2Vec2 normal, GameObject* other) { if (dead) return false; if (other && other->m_type == Objects::Player) { //DBG_OUTPUT("CC %.2f", normal.y); if (abs(normal.x) > 0.8f) { ApplyImpulse(other, sign(normal.x)); static_cast<Player*>(other)->OnHit(this); } } return true; } void Jelly::Enemy::OnHit(GameObject* by) { JellyGame::ShakeScreen(); AudioManager::PlaySoundType3D(Sounds::EnemyDie, posx, posy); Die(); } void Jelly::Enemy::Jump(float x, float power) { Character::Jump(x, min(6.5f, power)); } void Jelly::Enemy::Die() { Character::Die(); } #if DEBUG || 1 void Enemy::DebugDraw() const { Character::DebugDraw(); auto go_pos = GetPosition(); //DebugDraw::DrawLine(go_pos, { go_pos.x - RAY_DX, go_pos.y - RAY_DY }, { 1, 0, 0, 1 }); //DebugDraw::DrawLine(go_pos, { go_pos.x + RAY_DX, go_pos.y - RAY_DY }, { 1, 0, 0, 1 }); DebugDraw::DrawRay({ go_pos.x, go_pos.y }, { -RAY_DX, -RAY_DY }, { 1, 0, 0, 1 }); DebugDraw::DrawRay({ go_pos.x, go_pos.y }, { RAY_DX, -RAY_DY }, { 1, 0, 0, 1 }); } #endif
28.053812
111
0.571771
RikdeRooij
edb6fe437d2bb1188d8243cff6280547de498f16
31,577
cpp
C++
libraries/shared/src/SharedUtil.cpp
aoighost/hifi
87cdb4144dd9ab03cd6365c81e0c943a935d675b
[ "Apache-2.0" ]
null
null
null
libraries/shared/src/SharedUtil.cpp
aoighost/hifi
87cdb4144dd9ab03cd6365c81e0c943a935d675b
[ "Apache-2.0" ]
null
null
null
libraries/shared/src/SharedUtil.cpp
aoighost/hifi
87cdb4144dd9ab03cd6365c81e0c943a935d675b
[ "Apache-2.0" ]
null
null
null
// // SharedUtil.cpp // libraries/shared/src // // Created by Stephen Birarda on 2/22/13. // Copyright 2013 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "SharedUtil.h" #include <cassert> #include <cstdlib> #include <cstdio> #include <cstring> #include <cctype> #include <time.h> #include <mutex> #include <glm/glm.hpp> #ifdef _WIN32 #include <windows.h> #endif #ifdef Q_OS_WIN #include "CPUIdent.h" #include <Psapi.h> #endif #ifdef __APPLE__ #include <CoreFoundation/CoreFoundation.h> #endif #include <QtCore/QDebug> #include <QDateTime> #include <QElapsedTimer> #include <QProcess> #include <QSysInfo> #include <QThread> #include "NumericalConstants.h" #include "OctalCode.h" #include "SharedLogging.h" static qint64 usecTimestampNowAdjust = 0; // in usec void usecTimestampNowForceClockSkew(qint64 clockSkew) { ::usecTimestampNowAdjust = clockSkew; } static qint64 TIME_REFERENCE = 0; // in usec static std::once_flag usecTimestampNowIsInitialized; static QElapsedTimer timestampTimer; quint64 usecTimestampNow(bool wantDebug) { std::call_once(usecTimestampNowIsInitialized, [&] { TIME_REFERENCE = QDateTime::currentMSecsSinceEpoch() * USECS_PER_MSEC; // ms to usec timestampTimer.start(); }); quint64 now; quint64 nsecsElapsed = timestampTimer.nsecsElapsed(); quint64 usecsElapsed = nsecsElapsed / NSECS_PER_USEC; // nsec to usec // QElapsedTimer may not advance if the CPU has gone to sleep. In which case it // will begin to deviate from real time. We detect that here, and reset if necessary quint64 msecsCurrentTime = QDateTime::currentMSecsSinceEpoch(); quint64 msecsEstimate = (TIME_REFERENCE + usecsElapsed) / USECS_PER_MSEC; // usecs to msecs int possibleSkew = msecsEstimate - msecsCurrentTime; const int TOLERANCE = 10 * MSECS_PER_SECOND; // up to 10 seconds of skew is tolerated if (abs(possibleSkew) > TOLERANCE) { // reset our TIME_REFERENCE and timer TIME_REFERENCE = QDateTime::currentMSecsSinceEpoch() * USECS_PER_MSEC; // ms to usec timestampTimer.restart(); now = TIME_REFERENCE + ::usecTimestampNowAdjust; if (wantDebug) { qCDebug(shared) << "usecTimestampNow() - resetting QElapsedTimer. "; qCDebug(shared) << " msecsCurrentTime:" << msecsCurrentTime; qCDebug(shared) << " msecsEstimate:" << msecsEstimate; qCDebug(shared) << " possibleSkew:" << possibleSkew; qCDebug(shared) << " TOLERANCE:" << TOLERANCE; qCDebug(shared) << " nsecsElapsed:" << nsecsElapsed; qCDebug(shared) << " usecsElapsed:" << usecsElapsed; QDateTime currentLocalTime = QDateTime::currentDateTime(); quint64 msecsNow = now / 1000; // usecs to msecs QDateTime nowAsString; nowAsString.setMSecsSinceEpoch(msecsNow); qCDebug(shared) << " now:" << now; qCDebug(shared) << " msecsNow:" << msecsNow; qCDebug(shared) << " nowAsString:" << nowAsString.toString("yyyy-MM-dd hh:mm:ss.zzz"); qCDebug(shared) << " currentLocalTime:" << currentLocalTime.toString("yyyy-MM-dd hh:mm:ss.zzz"); } } else { now = TIME_REFERENCE + usecsElapsed + ::usecTimestampNowAdjust; } if (wantDebug) { QDateTime currentLocalTime = QDateTime::currentDateTime(); quint64 msecsNow = now / 1000; // usecs to msecs QDateTime nowAsString; nowAsString.setMSecsSinceEpoch(msecsNow); quint64 msecsTimeReference = TIME_REFERENCE / 1000; // usecs to msecs QDateTime timeReferenceAsString; timeReferenceAsString.setMSecsSinceEpoch(msecsTimeReference); qCDebug(shared) << "usecTimestampNow() - details... "; qCDebug(shared) << " TIME_REFERENCE:" << TIME_REFERENCE; qCDebug(shared) << " timeReferenceAsString:" << timeReferenceAsString.toString("yyyy-MM-dd hh:mm:ss.zzz"); qCDebug(shared) << " usecTimestampNowAdjust:" << usecTimestampNowAdjust; qCDebug(shared) << " nsecsElapsed:" << nsecsElapsed; qCDebug(shared) << " usecsElapsed:" << usecsElapsed; qCDebug(shared) << " now:" << now; qCDebug(shared) << " msecsNow:" << msecsNow; qCDebug(shared) << " nowAsString:" << nowAsString.toString("yyyy-MM-dd hh:mm:ss.zzz"); qCDebug(shared) << " currentLocalTime:" << currentLocalTime.toString("yyyy-MM-dd hh:mm:ss.zzz"); } return now; } float secTimestampNow() { static const auto START_TIME = usecTimestampNow(); const auto nowUsecs = usecTimestampNow() - START_TIME; const auto nowMsecs = nowUsecs / USECS_PER_MSEC; return (float)nowMsecs / MSECS_PER_SECOND; } float randFloat() { return (rand() % 10000)/10000.0f; } int randIntInRange (int min, int max) { return min + (rand() % ((max + 1) - min)); } float randFloatInRange (float min,float max) { return min + ((rand() % 10000)/10000.0f * (max-min)); } float randomSign() { return randomBoolean() ? -1.0 : 1.0; } unsigned char randomColorValue(int miniumum) { return miniumum + (rand() % (256 - miniumum)); } bool randomBoolean() { return rand() % 2; } bool shouldDo(float desiredInterval, float deltaTime) { return randFloat() < deltaTime / desiredInterval; } void outputBufferBits(const unsigned char* buffer, int length, QDebug* continuedDebug) { for (int i = 0; i < length; i++) { outputBits(buffer[i], continuedDebug); } } void outputBits(unsigned char byte, QDebug* continuedDebug) { QDebug debug = qDebug().nospace(); if (continuedDebug) { debug = *continuedDebug; debug.nospace(); } QString resultString; if (isalnum(byte)) { resultString.sprintf("[ %d (%c): ", byte, byte); } else { resultString.sprintf("[ %d (0x%x): ", byte, byte); } debug << qPrintable(resultString); for (int i = 0; i < 8; i++) { resultString.sprintf("%d", byte >> (7 - i) & 1); debug << qPrintable(resultString); } debug << " ]"; } int numberOfOnes(unsigned char byte) { static const int nbits[256] = { 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3, 4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4, 4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2, 3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5, 4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3, 4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3, 3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5, 6,6,7,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6, 4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5, 6,5,6,6,7,5,6,6,7,6,7,7,8 }; return nbits[(unsigned char) byte]; } bool oneAtBit(unsigned char byte, int bitIndex) { return (byte >> (7 - bitIndex) & 1); } void setAtBit(unsigned char& byte, int bitIndex) { byte |= (1 << (7 - bitIndex)); } void clearAtBit(unsigned char& byte, int bitIndex) { if (oneAtBit(byte, bitIndex)) { byte -= (1 << (7 - bitIndex)); } } int getSemiNibbleAt(unsigned char byte, int bitIndex) { return (byte >> (6 - bitIndex) & 3); // semi-nibbles store 00, 01, 10, or 11 } int getNthBit(unsigned char byte, int ordinal) { const int ERROR_RESULT = -1; const int MIN_ORDINAL = 1; const int MAX_ORDINAL = 8; if (ordinal < MIN_ORDINAL || ordinal > MAX_ORDINAL) { return ERROR_RESULT; } int bitsSet = 0; for (int bitIndex = 0; bitIndex < MAX_ORDINAL; bitIndex++) { if (oneAtBit(byte, bitIndex)) { bitsSet++; } if (bitsSet == ordinal) { return bitIndex; } } return ERROR_RESULT; } void setSemiNibbleAt(unsigned char& byte, int bitIndex, int value) { //assert(value <= 3 && value >= 0); byte |= ((value & 3) << (6 - bitIndex)); // semi-nibbles store 00, 01, 10, or 11 } bool isInEnvironment(const char* environment) { char* environmentString = getenv("HIFI_ENVIRONMENT"); return (environmentString && strcmp(environmentString, environment) == 0); } ////////////////////////////////////////////////////////////////////////////////////////// // Function: getCmdOption() // Description: Handy little function to tell you if a command line flag and option was // included while launching the application, and to get the option value // immediately following the flag. For example if you ran: // ./app -i filename.txt // then you're using the "-i" flag to set the input file name. // Usage: char * inputFilename = getCmdOption(argc, argv, "-i"); // Complaints: Brad :) const char* getCmdOption(int argc, const char * argv[],const char* option) { // check each arg for (int i=0; i < argc; i++) { // if the arg matches the desired option if (strcmp(option,argv[i])==0 && i+1 < argc) { // then return the next option return argv[i+1]; } } return NULL; } ////////////////////////////////////////////////////////////////////////////////////////// // Function: getCmdOption() // Description: Handy little function to tell you if a command line option flag was // included while launching the application. Returns bool true/false // Usage: bool wantDump = cmdOptionExists(argc, argv, "-d"); // Complaints: Brad :) bool cmdOptionExists(int argc, const char * argv[],const char* option) { // check each arg for (int i=0; i < argc; i++) { // if the arg matches the desired option if (strcmp(option,argv[i])==0) { // then return the next option return true; } } return false; } void sharedMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) { fprintf(stdout, "%s", message.toLocal8Bit().constData()); } unsigned char* pointToOctalCode(float x, float y, float z, float s) { return pointToVoxel(x, y, z, s); } /// Given a universal point with location x,y,z this will return the voxel /// voxel code corresponding to the closest voxel which encloses a cube with /// lower corners at x,y,z, having side of length S. /// The input values x,y,z range 0.0 <= v < 1.0 /// IMPORTANT: The voxel is returned to you a buffer which you MUST delete when you are /// done with it. unsigned char* pointToVoxel(float x, float y, float z, float s, unsigned char r, unsigned char g, unsigned char b ) { // special case for size 1, the root node if (s >= 1.0f) { unsigned char* voxelOut = new unsigned char; *voxelOut = 0; return voxelOut; } float xTest, yTest, zTest, sTest; xTest = yTest = zTest = sTest = 0.5f; // First determine the voxelSize that will properly encode a // voxel of size S. unsigned int voxelSizeInOctets = 1; while (sTest > s) { sTest /= 2.0f; voxelSizeInOctets++; } auto voxelSizeInBytes = bytesRequiredForCodeLength(voxelSizeInOctets); // (voxelSizeInBits/8)+1; auto voxelBufferSize = voxelSizeInBytes + sizeof(rgbColor); // 3 for color // allocate our resulting buffer unsigned char* voxelOut = new unsigned char[voxelBufferSize]; // first byte of buffer is always our size in octets voxelOut[0]=voxelSizeInOctets; sTest = 0.5f; // reset sTest so we can do this again. unsigned char byte = 0; // we will be adding coding bits here int bitInByteNDX = 0; // keep track of where we are in byte as we go int byteNDX = 1; // keep track of where we are in buffer of bytes as we go unsigned int octetsDone = 0; // Now we actually fill out the voxel code while (octetsDone < voxelSizeInOctets) { if (x >= xTest) { //<write 1 bit> byte = (byte << 1) | true; xTest += sTest/2.0f; } else { //<write 0 bit;> byte = (byte << 1) | false; xTest -= sTest/2.0f; } bitInByteNDX++; // If we've reached the last bit of the byte, then we want to copy this byte // into our buffer. And get ready to start on a new byte if (bitInByteNDX == 8) { voxelOut[byteNDX]=byte; byteNDX++; bitInByteNDX=0; byte=0; } if (y >= yTest) { //<write 1 bit> byte = (byte << 1) | true; yTest += sTest/2.0f; } else { //<write 0 bit;> byte = (byte << 1) | false; yTest -= sTest/2.0f; } bitInByteNDX++; // If we've reached the last bit of the byte, then we want to copy this byte // into our buffer. And get ready to start on a new byte if (bitInByteNDX == 8) { voxelOut[byteNDX]=byte; byteNDX++; bitInByteNDX=0; byte=0; } if (z >= zTest) { //<write 1 bit> byte = (byte << 1) | true; zTest += sTest/2.0f; } else { //<write 0 bit;> byte = (byte << 1) | false; zTest -= sTest/2.0f; } bitInByteNDX++; // If we've reached the last bit of the byte, then we want to copy this byte // into our buffer. And get ready to start on a new byte if (bitInByteNDX == 8) { voxelOut[byteNDX]=byte; byteNDX++; bitInByteNDX=0; byte=0; } octetsDone++; sTest /= 2.0f; } // If we've got here, and we didn't fill the last byte, we need to zero pad this // byte before we copy it into our buffer. if (bitInByteNDX > 0 && bitInByteNDX < 8) { // Pad the last byte while (bitInByteNDX < 8) { byte = (byte << 1) | false; bitInByteNDX++; } // Copy it into our output buffer voxelOut[byteNDX]=byte; byteNDX++; } // copy color data voxelOut[byteNDX]=r; voxelOut[byteNDX+1]=g; voxelOut[byteNDX+2]=b; return voxelOut; } void printVoxelCode(unsigned char* voxelCode) { unsigned char octets = voxelCode[0]; unsigned int voxelSizeInBits = octets*3; unsigned int voxelSizeInBytes = (voxelSizeInBits/8)+1; unsigned int voxelSizeInOctets = (voxelSizeInBits/3); unsigned int voxelBufferSize = voxelSizeInBytes+1+3; // 1 for size, 3 for color qCDebug(shared, "octets=%d",octets); qCDebug(shared, "voxelSizeInBits=%d",voxelSizeInBits); qCDebug(shared, "voxelSizeInBytes=%d",voxelSizeInBytes); qCDebug(shared, "voxelSizeInOctets=%d",voxelSizeInOctets); qCDebug(shared, "voxelBufferSize=%d",voxelBufferSize); for(unsigned int i=0; i < voxelBufferSize; i++) { QDebug voxelBufferDebug = qDebug(); voxelBufferDebug << "i =" << i; outputBits(voxelCode[i], &voxelBufferDebug); } } #ifdef _WIN32 void usleep(int waitTime) { // Use QueryPerformanceCounter for least overhead LARGE_INTEGER now; // ticks QueryPerformanceCounter(&now); static int64_t ticksPerSec = 0; if (ticksPerSec == 0) { LARGE_INTEGER frequency; QueryPerformanceFrequency(&frequency); ticksPerSec = frequency.QuadPart; } // order ops to avoid loss in precision int64_t waitTicks = (ticksPerSec * waitTime) / USECS_PER_SECOND; int64_t sleepTicks = now.QuadPart + waitTicks; // Busy wait with sleep/yield where possible while (true) { QueryPerformanceCounter(&now); if (now.QuadPart >= sleepTicks) { break; } // Sleep if we have at least 1ms to spare const int64_t MIN_SLEEP_USECS = 1000; // msleep is allowed to overshoot, so give it a 100us berth const int64_t MIN_SLEEP_USECS_BERTH = 100; // order ops to avoid loss in precision int64_t sleepFor = ((sleepTicks - now.QuadPart) * USECS_PER_SECOND) / ticksPerSec - MIN_SLEEP_USECS_BERTH; if (sleepFor > MIN_SLEEP_USECS) { Sleep((DWORD)(sleepFor / USECS_PER_MSEC)); // Yield otherwise } else { // Use Qt to delegate, as SwitchToThread is only supported starting with XP QThread::yieldCurrentThread(); } } } #endif // Inserts the value and key into three arrays sorted by the key array, the first array is the value, // the second array is a sorted key for the value, the third array is the index for the value in it original // non-sorted array // returns -1 if size exceeded // originalIndexArray is optional int insertIntoSortedArrays(void* value, float key, int originalIndex, void** valueArray, float* keyArray, int* originalIndexArray, int currentCount, int maxCount) { if (currentCount < maxCount) { int i = 0; if (currentCount > 0) { while (i < currentCount && key > keyArray[i]) { i++; } // i is our desired location // shift array elements to the right if (i < currentCount && i+1 < maxCount) { memmove(&valueArray[i + 1], &valueArray[i], sizeof(void*) * (currentCount - i)); memmove(&keyArray[i + 1], &keyArray[i], sizeof(float) * (currentCount - i)); if (originalIndexArray) { memmove(&originalIndexArray[i + 1], &originalIndexArray[i], sizeof(int) * (currentCount - i)); } } } // place new element at i valueArray[i] = value; keyArray[i] = key; if (originalIndexArray) { originalIndexArray[i] = originalIndex; } return currentCount + 1; } return -1; // error case } int removeFromSortedArrays(void* value, void** valueArray, float* keyArray, int* originalIndexArray, int currentCount, int maxCount) { int i = 0; if (currentCount > 0) { while (i < currentCount && value != valueArray[i]) { i++; } if (value == valueArray[i] && i < currentCount) { // i is the location of the item we were looking for // shift array elements to the left memmove(&valueArray[i], &valueArray[i + 1], sizeof(void*) * ((currentCount-1) - i)); memmove(&keyArray[i], &keyArray[i + 1], sizeof(float) * ((currentCount-1) - i)); if (originalIndexArray) { memmove(&originalIndexArray[i], &originalIndexArray[i + 1], sizeof(int) * ((currentCount-1) - i)); } return currentCount-1; } } return -1; // error case } float SMALL_LIMIT = 10.0f; float LARGE_LIMIT = 1000.0f; int packFloatRatioToTwoByte(unsigned char* buffer, float ratio) { // if the ratio is less than 10, then encode it as a positive number scaled from 0 to int16::max() int16_t ratioHolder; if (ratio < SMALL_LIMIT) { const float SMALL_RATIO_CONVERSION_RATIO = (std::numeric_limits<int16_t>::max() / SMALL_LIMIT); ratioHolder = floorf(ratio * SMALL_RATIO_CONVERSION_RATIO); } else { const float LARGE_RATIO_CONVERSION_RATIO = std::numeric_limits<int16_t>::min() / LARGE_LIMIT; ratioHolder = floorf((std::min(ratio,LARGE_LIMIT) - SMALL_LIMIT) * LARGE_RATIO_CONVERSION_RATIO); } memcpy(buffer, &ratioHolder, sizeof(ratioHolder)); return sizeof(ratioHolder); } int unpackFloatRatioFromTwoByte(const unsigned char* buffer, float& ratio) { int16_t ratioHolder; memcpy(&ratioHolder, buffer, sizeof(ratioHolder)); // If it's positive, than the original ratio was less than SMALL_LIMIT if (ratioHolder > 0) { ratio = (ratioHolder / (float) std::numeric_limits<int16_t>::max()) * SMALL_LIMIT; } else { // If it's negative, than the original ratio was between SMALL_LIMIT and LARGE_LIMIT ratio = ((ratioHolder / (float) std::numeric_limits<int16_t>::min()) * LARGE_LIMIT) + SMALL_LIMIT; } return sizeof(ratioHolder); } int packClipValueToTwoByte(unsigned char* buffer, float clipValue) { // Clip values must be less than max signed 16bit integers assert(clipValue < std::numeric_limits<int16_t>::max()); int16_t holder; // if the clip is less than 10, then encode it as a positive number scaled from 0 to int16::max() if (clipValue < SMALL_LIMIT) { const float SMALL_RATIO_CONVERSION_RATIO = (std::numeric_limits<int16_t>::max() / SMALL_LIMIT); holder = floorf(clipValue * SMALL_RATIO_CONVERSION_RATIO); } else { // otherwise we store it as a negative integer holder = -1 * floorf(clipValue); } memcpy(buffer, &holder, sizeof(holder)); return sizeof(holder); } int unpackClipValueFromTwoByte(const unsigned char* buffer, float& clipValue) { int16_t holder; memcpy(&holder, buffer, sizeof(holder)); // If it's positive, than the original clipValue was less than SMALL_LIMIT if (holder > 0) { clipValue = (holder / (float) std::numeric_limits<int16_t>::max()) * SMALL_LIMIT; } else { // If it's negative, than the original holder can be found as the opposite sign of holder clipValue = -1.0f * holder; } return sizeof(holder); } int packFloatToByte(unsigned char* buffer, float value, float scaleBy) { quint8 holder; const float CONVERSION_RATIO = (255 / scaleBy); holder = floorf(value * CONVERSION_RATIO); memcpy(buffer, &holder, sizeof(holder)); return sizeof(holder); } int unpackFloatFromByte(const unsigned char* buffer, float& value, float scaleBy) { quint8 holder; memcpy(&holder, buffer, sizeof(holder)); value = ((float)holder / (float) 255) * scaleBy; return sizeof(holder); } unsigned char debug::DEADBEEF[] = { 0xDE, 0xAD, 0xBE, 0xEF }; int debug::DEADBEEF_SIZE = sizeof(DEADBEEF); void debug::setDeadBeef(void* memoryVoid, int size) { unsigned char* memoryAt = (unsigned char*)memoryVoid; int deadBeefSet = 0; int chunks = size / DEADBEEF_SIZE; for (int i = 0; i < chunks; i++) { memcpy(memoryAt + (i * DEADBEEF_SIZE), DEADBEEF, DEADBEEF_SIZE); deadBeefSet += DEADBEEF_SIZE; } memcpy(memoryAt + deadBeefSet, DEADBEEF, size - deadBeefSet); } void debug::checkDeadBeef(void* memoryVoid, int size) { assert(memcmp((unsigned char*)memoryVoid, DEADBEEF, std::min(size, DEADBEEF_SIZE)) != 0); } // glm::abs() works for signed or unsigned types template <typename T> QString formatUsecTime(T usecs) { static const int PRECISION = 3; static const int FRACTION_MASK = pow(10, PRECISION); static const T USECS_PER_MSEC = 1000; static const T USECS_PER_SECOND = 1000 * USECS_PER_MSEC; static const T USECS_PER_MINUTE = USECS_PER_SECOND * 60; static const T USECS_PER_HOUR = USECS_PER_MINUTE * 60; QString result; if (glm::abs(usecs) > USECS_PER_HOUR) { if (std::is_integral<T>::value) { result = QString::number(usecs / USECS_PER_HOUR); result += "." + QString::number(((int)(usecs * FRACTION_MASK / USECS_PER_HOUR)) % FRACTION_MASK); } else { result = QString::number(usecs / USECS_PER_HOUR, 'f', PRECISION); } result += " hrs"; } else if (glm::abs(usecs) > USECS_PER_MINUTE) { if (std::is_integral<T>::value) { result = QString::number(usecs / USECS_PER_MINUTE); result += "." + QString::number(((int)(usecs * FRACTION_MASK / USECS_PER_MINUTE)) % FRACTION_MASK); } else { result = QString::number(usecs / USECS_PER_MINUTE, 'f', PRECISION); } result += " mins"; } else if (glm::abs(usecs) > USECS_PER_SECOND) { if (std::is_integral<T>::value) { result = QString::number(usecs / USECS_PER_SECOND); result += "." + QString::number(((int)(usecs * FRACTION_MASK / USECS_PER_SECOND)) % FRACTION_MASK); } else { result = QString::number(usecs / USECS_PER_SECOND, 'f', PRECISION); } result += " secs"; } else if (glm::abs(usecs) > USECS_PER_MSEC) { if (std::is_integral<T>::value) { result = QString::number(usecs / USECS_PER_MSEC); result += "." + QString::number(((int)(usecs * FRACTION_MASK / USECS_PER_MSEC)) % FRACTION_MASK); } else { result = QString::number(usecs / USECS_PER_MSEC, 'f', PRECISION); } result += " msecs"; } else { result = QString::number(usecs) + " usecs"; } return result; } QString formatUsecTime(quint64 usecs) { return formatUsecTime<quint64>(usecs); } QString formatUsecTime(qint64 usecs) { return formatUsecTime<qint64>(usecs); } QString formatUsecTime(float usecs) { return formatUsecTime<float>(usecs); } QString formatUsecTime(double usecs) { return formatUsecTime<double>(usecs); } QString formatSecondsElapsed(float seconds) { QString result; const float SECONDS_IN_DAY = 60.0f * 60.0f * 24.0f; if (seconds > SECONDS_IN_DAY) { float days = floor(seconds / SECONDS_IN_DAY); float rest = seconds - (days * SECONDS_IN_DAY); result = QString::number((int)days); if (days > 1.0f) { result += " days "; } else { result += " day "; } result += QDateTime::fromTime_t(rest).toUTC().toString("h 'hours' m 'minutes' s 'seconds'"); } else { result = QDateTime::fromTime_t(seconds).toUTC().toString("h 'hours' m 'minutes' s 'seconds'"); } return result; } bool similarStrings(const QString& stringA, const QString& stringB) { QStringList aWords = stringA.split(" "); QStringList bWords = stringB.split(" "); float aWordsInB = 0.0f; foreach(QString aWord, aWords) { if (bWords.contains(aWord)) { aWordsInB += 1.0f; } } float bWordsInA = 0.0f; foreach(QString bWord, bWords) { if (aWords.contains(bWord)) { bWordsInA += 1.0f; } } float similarity = 0.5f * (aWordsInB / (float)bWords.size()) + 0.5f * (bWordsInA / (float)aWords.size()); const float SIMILAR_ENOUGH = 0.5f; // half the words the same is similar enough for us return similarity >= SIMILAR_ENOUGH; } void disableQtBearerPoll() { // to work around the Qt constant wireless scanning, set the env for polling interval very high const QByteArray EXTREME_BEARER_POLL_TIMEOUT = QString::number(INT_MAX).toLocal8Bit(); qputenv("QT_BEARER_POLL_TIMEOUT", EXTREME_BEARER_POLL_TIMEOUT); } void printSystemInformation() { // Write system information to log qDebug() << "Build Information"; qDebug().noquote() << "\tBuild ABI: " << QSysInfo::buildAbi(); qDebug().noquote() << "\tBuild CPU Architecture: " << QSysInfo::buildCpuArchitecture(); qDebug().noquote() << "System Information"; qDebug().noquote() << "\tProduct Name: " << QSysInfo::prettyProductName(); qDebug().noquote() << "\tCPU Architecture: " << QSysInfo::currentCpuArchitecture(); qDebug().noquote() << "\tKernel Type: " << QSysInfo::kernelType(); qDebug().noquote() << "\tKernel Version: " << QSysInfo::kernelVersion(); auto macVersion = QSysInfo::macVersion(); if (macVersion != QSysInfo::MV_None) { qDebug() << "\tMac Version: " << macVersion; } auto windowsVersion = QSysInfo::windowsVersion(); if (windowsVersion != QSysInfo::WV_None) { qDebug() << "\tWindows Version: " << windowsVersion; } #ifdef Q_OS_WIN SYSTEM_INFO si; GetNativeSystemInfo(&si); qDebug() << "SYSTEM_INFO"; qDebug().noquote() << "\tOEM ID: " << si.dwOemId; qDebug().noquote() << "\tProcessor Architecture: " << si.wProcessorArchitecture; qDebug().noquote() << "\tProcessor Type: " << si.dwProcessorType; qDebug().noquote() << "\tProcessor Level: " << si.wProcessorLevel; qDebug().noquote() << "\tProcessor Revision: " << QString("0x%1").arg(si.wProcessorRevision, 4, 16, QChar('0')); qDebug().noquote() << "\tNumber of Processors: " << si.dwNumberOfProcessors; qDebug().noquote() << "\tPage size: " << si.dwPageSize << " Bytes"; qDebug().noquote() << "\tMin Application Address: " << QString("0x%1").arg(qulonglong(si.lpMinimumApplicationAddress), 16, 16, QChar('0')); qDebug().noquote() << "\tMax Application Address: " << QString("0x%1").arg(qulonglong(si.lpMaximumApplicationAddress), 16, 16, QChar('0')); const double BYTES_TO_MEGABYTE = 1.0 / (1024 * 1024); qDebug() << "MEMORYSTATUSEX"; MEMORYSTATUSEX ms; ms.dwLength = sizeof(ms); if (GlobalMemoryStatusEx(&ms)) { qDebug().noquote() << QString("\tCurrent System Memory Usage: %1%").arg(ms.dwMemoryLoad); qDebug().noquote() << QString("\tAvail Physical Memory: %1 MB").arg(ms.ullAvailPhys * BYTES_TO_MEGABYTE, 20, 'f', 2); qDebug().noquote() << QString("\tTotal Physical Memory: %1 MB").arg(ms.ullTotalPhys * BYTES_TO_MEGABYTE, 20, 'f', 2); qDebug().noquote() << QString("\tAvail in Page File: %1 MB").arg(ms.ullAvailPageFile * BYTES_TO_MEGABYTE, 20, 'f', 2); qDebug().noquote() << QString("\tTotal in Page File: %1 MB").arg(ms.ullTotalPageFile * BYTES_TO_MEGABYTE, 20, 'f', 2); qDebug().noquote() << QString("\tAvail Virtual Memory: %1 MB").arg(ms.ullAvailVirtual * BYTES_TO_MEGABYTE, 20, 'f', 2); qDebug().noquote() << QString("\tTotal Virtual Memory: %1 MB").arg(ms.ullTotalVirtual * BYTES_TO_MEGABYTE, 20, 'f', 2); } else { qDebug() << "\tFailed to retrieve memory status: " << GetLastError(); } qDebug() << "CPUID"; qDebug() << "\tCPU Vendor: " << CPUIdent::Vendor().c_str(); qDebug() << "\tCPU Brand: " << CPUIdent::Brand().c_str(); for (auto& feature : CPUIdent::getAllFeatures()) { qDebug().nospace().noquote() << "\t[" << (feature.supported ? "x" : " ") << "] " << feature.name.c_str(); } #endif qDebug() << "Environment Variables"; // List of env variables to include in the log. For privacy reasons we don't send all env variables. const QStringList envWhitelist = { "QTWEBENGINE_REMOTE_DEBUGGING" }; auto envVariables = QProcessEnvironment::systemEnvironment(); for (auto& env : envWhitelist) { qDebug().noquote().nospace() << "\t" << (envVariables.contains(env) ? " = " + envVariables.value(env) : " NOT FOUND"); } } bool getMemoryInfo(MemoryInfo& info) { #ifdef Q_OS_WIN MEMORYSTATUSEX ms; ms.dwLength = sizeof(ms); if (!GlobalMemoryStatusEx(&ms)) { return false; } info.totalMemoryBytes = ms.ullTotalPhys; info.availMemoryBytes = ms.ullAvailPhys; info.usedMemoryBytes = ms.ullTotalPhys - ms.ullAvailPhys; PROCESS_MEMORY_COUNTERS_EX pmc; if (!GetProcessMemoryInfo(GetCurrentProcess(), reinterpret_cast<PROCESS_MEMORY_COUNTERS*>(&pmc), sizeof(pmc))) { return false; } info.processUsedMemoryBytes = pmc.PrivateUsage; info.processPeakUsedMemoryBytes = pmc.PeakPagefileUsage; return true; #endif return false; }
36.212156
129
0.611838
aoighost
edbce77cd0d02aadd523124df8bee1350c8fcba2
1,291
cpp
C++
LeetCode/ThousandOne/0438-find_anagram_in_str.cpp
Ginkgo-Biloba/Cpp-Repo1-VS
231c68a055e6bf69a3f7c224e7c0182b67ce5b67
[ "Apache-2.0" ]
null
null
null
LeetCode/ThousandOne/0438-find_anagram_in_str.cpp
Ginkgo-Biloba/Cpp-Repo1-VS
231c68a055e6bf69a3f7c224e7c0182b67ce5b67
[ "Apache-2.0" ]
null
null
null
LeetCode/ThousandOne/0438-find_anagram_in_str.cpp
Ginkgo-Biloba/Cpp-Repo1-VS
231c68a055e6bf69a3f7c224e7c0182b67ce5b67
[ "Apache-2.0" ]
null
null
null
#include "leetcode.hpp" /* 438. 找到字符串中所有字母异位词 给定一个字符串 s 和一个非空字符串 p,找到 s 中所有是 p 的字母异位词的子串,返回这些子串的起始索引。 字符串只包含小写英文字母,并且字符串 s 和 p 的长度都不超过 20100。 说明: 字母异位词指字母相同,但排列不同的字符串。 不考虑答案输出的顺序。 示例 1: 输入: s: "cbaebabacd" p: "abc" 输出: [0, 6] 解释: 起始索引等于 0 的子串是 "cba", 它是 "abc" 的字母异位词。 起始索引等于 6 的子串是 "bac", 它是 "abc" 的字母异位词。 示例 2: 输入: s: "abab" p: "ab" 输出: [0, 1, 2] 解释: 起始索引等于 0 的子串是 "ab", 它是 "ab" 的字母异位词。 起始索引等于 1 的子串是 "ba", 它是 "ab" 的字母异位词。 起始索引等于 2 的子串是 "ab", 它是 "ab" 的字母异位词。 */ vector<int> findAnagrams(string const& str, string const& pat) { // 既然小于 32768,那么可以 short int buf[28]; short* hs = reinterpret_cast<short*>(buf); short* hp = reinterpret_cast<short*>(buf + 14); int ls = static_cast<int>(str.size()); int lp = static_cast<int>(pat.size()); vector<int> ans; if (ls < lp || lp == 0) return ans; memset(buf, 0, sizeof(buf)); for (int i = 0; i < lp - 1; ++i) { ++hs[str[i] - 'a']; ++hp[pat[i] - 'a']; } int lps1 = lp - 1; ++hp[pat[lps1] - 'a']; for (int i = lps1; i < ls; ++i) { ++hs[str[i] - 'a']; int cmp = 0; for (; cmp < 14; ++cmp) { if (buf[cmp] != buf[cmp + 14]) break; } if (cmp == 14) ans.push_back(i - lps1); --hs[str[i - lps1] - 'a']; } return ans; } int main() { output(findAnagrams("cbaebabacd", "abcz"), "findAnagrams"); }
17.445946
62
0.580945
Ginkgo-Biloba
edbf3dda46a1ba091ee6ce6d80ed662cb90df5ab
3,244
hh
C++
src/image/containers.hh
kofuk/pixel-terrain
f39e2a0120aab5a11311f57cfd1ab46efa65fddd
[ "MIT" ]
2
2020-10-16T08:46:45.000Z
2020-11-04T02:19:19.000Z
src/image/containers.hh
kofuk/minecraft-image-generator
ef2f7deb2daac7f7c2cfb468ef39e0cdc8b33db7
[ "MIT" ]
null
null
null
src/image/containers.hh
kofuk/minecraft-image-generator
ef2f7deb2daac7f7c2cfb468ef39e0cdc8b33db7
[ "MIT" ]
null
null
null
// SPDX-License-Identifier: MIT #ifndef CONTAINERS_HH #define CONTAINERS_HH #include <filesystem> #include <thread> #include "logger/logger.hh" #include "nbt/chunk.hh" #include "nbt/region.hh" #include "utils/path_hack.hh" namespace pixel_terrain::image { class options { std::filesystem::path out_path_; bool out_path_is_dir_; unsigned int n_jobs_; bool is_nether_; std::string label_; std::filesystem::path cache_dir_; std::string outname_format_; public: options() { clear(); } void clear() { out_path_ = PATH_STR_LITERAL("."); n_jobs_ = std::thread::hardware_concurrency(); is_nether_ = false; cache_dir_.clear(); outname_format_.clear(); } void set_out_path(std::filesystem::path const &p) { if (!std::filesystem::exists(p)) { out_path_is_dir_ = false; } else { out_path_is_dir_ = std::filesystem::is_directory(p); } out_path_ = p; } [[nodiscard]] auto out_path() const -> std::filesystem::path const & { return out_path_; } [[nodiscard]] auto out_path_is_directory() const -> bool { return out_path_is_dir_; } void set_n_jobs(unsigned int n) { if (n <= 0) { ILOG("Ignoring worker count because it is equal to or less " "than 0.\n"); return; } n_jobs_ = n; } [[nodiscard]] auto n_jobs() const -> unsigned int { return n_jobs_; } void set_is_nether(bool is_nether) { is_nether_ = is_nether; } [[nodiscard]] auto is_nether() const -> bool { return is_nether_; } void set_label(std::string const &label) { label_ = label; } [[nodiscard]] auto label() const -> std::string const & { return label_; } void set_cache_dir(std::filesystem::path const &path) { cache_dir_ = path; } [[nodiscard]] auto cache_dir() const -> std::filesystem::path const & { return cache_dir_; } void set_outname_format(std::string const &fmt) { outname_format_ = fmt; } [[nodiscard]] auto outname_format() const -> std::string const & { return outname_format_; } }; class region_container { anvil::region *region_; options options_; std::filesystem::path out_file_; public: region_container(anvil::region *region, options options, std::filesystem::path out_file) : region_(region), options_(std::move(options)), out_file_(std::move(out_file)) {} ~region_container() { delete region_; } [[nodiscard]] auto get_region() -> anvil::region * { return region_; } [[nodiscard]] auto get_output_path() const -> std::filesystem::path const * { return &out_file_; } [[nodiscard]] auto get_options() const -> options const * { return &options_; } }; } // namespace pixel_terrain::image #endif
27.726496
79
0.550863
kofuk
edc310e89300aec2b6ac2337862772ca3877d685
11,168
cpp
C++
benchmark/MeasurementVectorBenchmark.cpp
rafaelrietmann/ukf
bf53dacafbfee8c7591c48a66b50229f82afe4b4
[ "MIT" ]
320
2015-01-07T05:49:59.000Z
2022-03-31T01:52:15.000Z
benchmark/MeasurementVectorBenchmark.cpp
msnh2012/ukf
04f0a996fee1f49699142bf5b149548a8d3a4ad1
[ "MIT" ]
22
2015-03-03T17:28:32.000Z
2022-02-16T14:46:54.000Z
benchmark/MeasurementVectorBenchmark.cpp
msnh2012/ukf
04f0a996fee1f49699142bf5b149548a8d3a4ad1
[ "MIT" ]
155
2015-02-20T01:18:06.000Z
2022-02-22T01:58:53.000Z
#include <benchmark/benchmark.h> #include <Eigen/Core> #include <Eigen/Geometry> #include "UKF/Types.h" #include "UKF/StateVector.h" #include "UKF/MeasurementVector.h" enum MyStateVectorFields { AngularVelocity, Altitude, Velocity, Attitude }; using MyStateVector = UKF::StateVector< UKF::Field<Velocity, UKF::Vector<3>>, UKF::Field<AngularVelocity, UKF::Vector<3>>, UKF::Field<Attitude, UKF::Quaternion>, UKF::Field<Altitude, real_t> >; enum MyFields { StaticPressure, DynamicPressure, Accelerometer, Gyroscope }; using MV_Fixed = UKF::FixedMeasurementVector< UKF::Field<Accelerometer, UKF::Vector<3>>, UKF::Field<Gyroscope, UKF::Vector<3>>, UKF::Field<StaticPressure, real_t>, UKF::Field<DynamicPressure, real_t> >; namespace UKF { template <> template <> UKF::Vector<3> MV_Fixed::expected_measurement <MyStateVector, Accelerometer>(const MyStateVector& state) { return state.get_field<Attitude>() * UKF::Vector<3>(0, 0, -9.8); } template <> template <> UKF::Vector<3> MV_Fixed::expected_measurement <MyStateVector, Gyroscope>(const MyStateVector& state) { return state.get_field<AngularVelocity>(); } template <> template <> real_t MV_Fixed::expected_measurement <MyStateVector, StaticPressure>(const MyStateVector& state) { return 101.3 - 1.2*(state.get_field<Altitude>() / 100.0); } template <> template <> real_t MV_Fixed::expected_measurement <MyStateVector, DynamicPressure>(const MyStateVector& state) { return 0.5 * 1.225 * state.get_field<Velocity>().squaredNorm(); } } using MV_Dynamic = UKF::DynamicMeasurementVector< UKF::Field<Accelerometer, UKF::Vector<3>>, UKF::Field<Gyroscope, UKF::Vector<3>>, UKF::Field<StaticPressure, real_t>, UKF::Field<DynamicPressure, real_t> >; namespace UKF { template <> template <> UKF::Vector<3> MV_Dynamic::expected_measurement <MyStateVector, Accelerometer>(const MyStateVector& state) { return state.get_field<Attitude>() * UKF::Vector<3>(0, 0, -9.8); } template <> template <> UKF::Vector<3> MV_Dynamic::expected_measurement <MyStateVector, Gyroscope>(const MyStateVector& state) { return state.get_field<AngularVelocity>(); } template <> template <> real_t MV_Dynamic::expected_measurement <MyStateVector, StaticPressure>(const MyStateVector& state) { return 101.3 - 1.2*(state.get_field<Altitude>() / 100.0); } template <> template <> real_t MV_Dynamic::expected_measurement <MyStateVector, DynamicPressure>(const MyStateVector& state) { return 0.5 * 1.225 * state.get_field<Velocity>().squaredNorm(); } } /* Tests to compare set/get performance between fixed and dynamic measurement vectors. */ void MeasurementVectorFixed_SetGetField(benchmark::State& state) { MV_Fixed test_measurement; while(state.KeepRunning()) { test_measurement.set_field<Accelerometer>(UKF::Vector<3>(1, 2, 3)); benchmark::DoNotOptimize(test_measurement.get_field<Accelerometer>()); } } BENCHMARK(MeasurementVectorFixed_SetGetField); void MeasurementVectorDynamic_SetGetField(benchmark::State& state) { MV_Dynamic test_measurement; while(state.KeepRunning()) { test_measurement.set_field<Accelerometer>(UKF::Vector<3>(1, 2, 3)); benchmark::DoNotOptimize(test_measurement.get_field<Accelerometer>()); } } BENCHMARK(MeasurementVectorDynamic_SetGetField); void MeasurementVectorFixed_SigmaPointGeneration(benchmark::State& state) { MyStateVector test_state; MV_Fixed test_measurement; test_measurement.set_field<Accelerometer>(UKF::Vector<3>(0, 0, 0)); test_measurement.set_field<Gyroscope>(UKF::Vector<3>(0, 0, 0)); test_measurement.set_field<StaticPressure>(0); test_measurement.set_field<DynamicPressure>(0); test_state.set_field<Velocity>(UKF::Vector<3>(1, 2, 3)); test_state.set_field<AngularVelocity>(UKF::Vector<3>(1, 0, 0)); test_state.set_field<Attitude>(UKF::Quaternion(1, 0, 0, 0)); test_state.set_field<Altitude>(1000); MyStateVector::CovarianceMatrix covariance = MyStateVector::CovarianceMatrix::Zero(); covariance.diagonal() << 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0; MyStateVector::SigmaPointDistribution sigma_points = test_state.calculate_sigma_point_distribution(covariance); while(state.KeepRunning()) { benchmark::DoNotOptimize(test_measurement.calculate_sigma_point_distribution<MyStateVector>(sigma_points)); } } BENCHMARK(MeasurementVectorFixed_SigmaPointGeneration); void MeasurementVectorDynamic_SigmaPointGeneration(benchmark::State& state) { MyStateVector test_state; MV_Dynamic test_measurement; test_measurement.set_field<Accelerometer>(UKF::Vector<3>(0, 0, 0)); test_measurement.set_field<Gyroscope>(UKF::Vector<3>(0, 0, 0)); test_measurement.set_field<StaticPressure>(0); test_measurement.set_field<DynamicPressure>(0); test_state.set_field<Velocity>(UKF::Vector<3>(1, 2, 3)); test_state.set_field<AngularVelocity>(UKF::Vector<3>(1, 0, 0)); test_state.set_field<Attitude>(UKF::Quaternion(1, 0, 0, 0)); test_state.set_field<Altitude>(1000); MyStateVector::CovarianceMatrix covariance = MyStateVector::CovarianceMatrix::Zero(); covariance.diagonal() << 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0; MyStateVector::SigmaPointDistribution sigma_points = test_state.calculate_sigma_point_distribution(covariance); while(state.KeepRunning()) { benchmark::DoNotOptimize(test_measurement.calculate_sigma_point_distribution<MyStateVector>(sigma_points)); } } BENCHMARK(MeasurementVectorDynamic_SigmaPointGeneration); void MeasurementVectorFixed_FullMeasurementCalculation(benchmark::State& state) { MyStateVector test_state; MV_Fixed test_measurement; test_measurement.set_field<Accelerometer>(UKF::Vector<3>(0, 0, 0)); test_measurement.set_field<Gyroscope>(UKF::Vector<3>(0, 0, 0)); test_measurement.set_field<StaticPressure>(0); test_measurement.set_field<DynamicPressure>(0); test_state.set_field<Velocity>(UKF::Vector<3>(1, 2, 3)); test_state.set_field<AngularVelocity>(UKF::Vector<3>(1, 0, 0)); test_state.set_field<Attitude>(UKF::Quaternion(1, 0, 0, 0)); test_state.set_field<Altitude>(1000); MyStateVector::CovarianceMatrix covariance = MyStateVector::CovarianceMatrix::Zero(); covariance.diagonal() << 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0; MyStateVector::SigmaPointDistribution sigma_points = test_state.calculate_sigma_point_distribution(covariance); MV_Fixed::SigmaPointDistribution<MyStateVector> measurement_sigma_points; MV_Fixed mean_measurement; MV_Fixed::SigmaPointDeltas<MyStateVector> sigma_point_deltas; MV_Fixed::CovarianceMatrix calculated_covariance; while(state.KeepRunning()) { measurement_sigma_points = test_measurement.calculate_sigma_point_distribution<MyStateVector>(sigma_points); mean_measurement = test_measurement.calculate_sigma_point_mean<MyStateVector>(measurement_sigma_points); sigma_point_deltas = mean_measurement.calculate_sigma_point_deltas<MyStateVector>(measurement_sigma_points); calculated_covariance = mean_measurement.calculate_sigma_point_covariance<MyStateVector>(sigma_point_deltas); } } BENCHMARK(MeasurementVectorFixed_FullMeasurementCalculation); void MeasurementVectorDynamic_FullMeasurementCalculation(benchmark::State& state) { MyStateVector test_state; MV_Dynamic test_measurement; test_measurement.set_field<Accelerometer>(UKF::Vector<3>(0, 0, 0)); test_measurement.set_field<Gyroscope>(UKF::Vector<3>(0, 0, 0)); test_measurement.set_field<StaticPressure>(0); test_measurement.set_field<DynamicPressure>(0); test_state.set_field<Velocity>(UKF::Vector<3>(1, 2, 3)); test_state.set_field<AngularVelocity>(UKF::Vector<3>(1, 0, 0)); test_state.set_field<Attitude>(UKF::Quaternion(1, 0, 0, 0)); test_state.set_field<Altitude>(1000); MyStateVector::CovarianceMatrix covariance = MyStateVector::CovarianceMatrix::Zero(); covariance.diagonal() << 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0; MyStateVector::SigmaPointDistribution sigma_points = test_state.calculate_sigma_point_distribution(covariance); MV_Dynamic::SigmaPointDistribution<MyStateVector> measurement_sigma_points( test_measurement.size(), MyStateVector::num_sigma()); MV_Dynamic mean_measurement(test_measurement.size()); MV_Dynamic::SigmaPointDeltas<MyStateVector> sigma_point_deltas(test_measurement.size(), MyStateVector::num_sigma()); MV_Dynamic::CovarianceMatrix calculated_covariance(test_measurement.size(), test_measurement.size()); while(state.KeepRunning()) { measurement_sigma_points = test_measurement.calculate_sigma_point_distribution<MyStateVector>(sigma_points); mean_measurement = test_measurement.calculate_sigma_point_mean<MyStateVector>(measurement_sigma_points); sigma_point_deltas = mean_measurement.calculate_sigma_point_deltas<MyStateVector>(measurement_sigma_points); calculated_covariance = mean_measurement.calculate_sigma_point_covariance<MyStateVector>(sigma_point_deltas); } } BENCHMARK(MeasurementVectorDynamic_FullMeasurementCalculation); void MeasurementVectorFixed_MeasurementCovariance(benchmark::State& state) { MV_Fixed test_measurement, expected_measurement; MV_Fixed::CovarianceVector measurement_covariance; measurement_covariance.set_field<Accelerometer>(UKF::Vector<3>(1, 2, 3)); measurement_covariance.set_field<Gyroscope>(UKF::Vector<3>(4, 5, 6)); measurement_covariance.set_field<StaticPressure>(7); measurement_covariance.set_field<DynamicPressure>(8); expected_measurement.set_field<Accelerometer>(UKF::Vector<3>(1, 2, 3)); expected_measurement.set_field<Gyroscope>(UKF::Vector<3>(4, 5, 6)); expected_measurement.set_field<StaticPressure>(7); expected_measurement.set_field<DynamicPressure>(8); while(state.KeepRunning()) { benchmark::DoNotOptimize(test_measurement.calculate_measurement_covariance( measurement_covariance, expected_measurement)); } } BENCHMARK(MeasurementVectorFixed_MeasurementCovariance); void MeasurementVectorDynamic_MeasurementCovariance(benchmark::State& state) { MV_Dynamic test_measurement, expected_measurement; MV_Dynamic::CovarianceVector measurement_covariance; measurement_covariance.set_field<Accelerometer>(UKF::Vector<3>(1, 2, 3)); measurement_covariance.set_field<Gyroscope>(UKF::Vector<3>(4, 5, 6)); measurement_covariance.set_field<StaticPressure>(7); measurement_covariance.set_field<DynamicPressure>(8); expected_measurement.set_field<Accelerometer>(UKF::Vector<3>(1, 2, 3)); expected_measurement.set_field<Gyroscope>(UKF::Vector<3>(4, 5, 6)); expected_measurement.set_field<StaticPressure>(7); expected_measurement.set_field<DynamicPressure>(8); while(state.KeepRunning()) { benchmark::DoNotOptimize(test_measurement.calculate_measurement_covariance( measurement_covariance, expected_measurement)); } } BENCHMARK(MeasurementVectorDynamic_MeasurementCovariance);
39.323944
120
0.756089
rafaelrietmann
edc774546d5f85f566a8c072ec7c0221d8378532
3,405
cpp
C++
Source/SuperFastHash.cpp
sh4k3n/RakNet
32b8c230b8a9c72542d0eb0d291eec758bb1e970
[ "BSD-2-Clause" ]
4
2019-10-05T20:01:22.000Z
2021-11-30T15:22:03.000Z
Source/SuperFastHash.cpp
sh4k3n/RakNet
32b8c230b8a9c72542d0eb0d291eec758bb1e970
[ "BSD-2-Clause" ]
null
null
null
Source/SuperFastHash.cpp
sh4k3n/RakNet
32b8c230b8a9c72542d0eb0d291eec758bb1e970
[ "BSD-2-Clause" ]
null
null
null
/* * Copyright (c) 2014, Oculus VR, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * */ #include "SuperFastHash.h" #include "NativeTypes.h" #include <stdlib.h> #if !defined(_WIN32) #include <stdint.h> #endif #ifdef _MSC_VER #pragma warning( push ) #pragma warning(disable:4996) #endif #undef get16bits #if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \ || defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__) #define get16bits(d) (*((const uint16_t *) (d))) #else #define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\ +(uint32_t)(((const uint8_t *)(d))[0]) ) #endif static const int INCREMENTAL_READ_BLOCK=65536; uint32_t SuperFastHash (const char * data, int length) { // All this is necessary or the hash does not match SuperFastHashIncremental int bytesRemaining=length; unsigned int lastHash = length; int offset=0; while (bytesRemaining>=INCREMENTAL_READ_BLOCK) { lastHash=SuperFastHashIncremental (data+offset, INCREMENTAL_READ_BLOCK, lastHash ); bytesRemaining-=INCREMENTAL_READ_BLOCK; offset+=INCREMENTAL_READ_BLOCK; } if (bytesRemaining>0) { lastHash=SuperFastHashIncremental (data+offset, bytesRemaining, lastHash ); } return lastHash; // return SuperFastHashIncremental(data,len,len); } uint32_t SuperFastHashIncremental (const char * data, int len, unsigned int lastHash ) { uint32_t hash = (uint32_t) lastHash; uint32_t tmp; int rem; if (len <= 0 || data == NULL) return 0; rem = len & 3; len >>= 2; /* Main loop */ for (;len > 0; len--) { hash += get16bits (data); tmp = (get16bits (data+2) << 11) ^ hash; hash = (hash << 16) ^ tmp; data += 2*sizeof (uint16_t); hash += hash >> 11; } /* Handle end cases */ switch (rem) { case 3: hash += get16bits (data); hash ^= hash << 16; hash ^= data[sizeof (uint16_t)] << 18; hash += hash >> 11; break; case 2: hash += get16bits (data); hash ^= hash << 11; hash += hash >> 17; break; case 1: hash += *data; hash ^= hash << 10; hash += hash >> 1; } /* Force "avalanching" of final 127 bits */ hash ^= hash << 3; hash += hash >> 5; hash ^= hash << 4; hash += hash >> 17; hash ^= hash << 25; hash += hash >> 6; return (uint32_t) hash; } uint32_t SuperFastHashFile (const char * filename) { FILE *fp = fopen(filename, "rb"); if (fp==0) return 0; uint32_t hash = SuperFastHashFilePtr(fp); fclose(fp); return hash; } uint32_t SuperFastHashFilePtr (FILE *fp) { fseek(fp, 0, SEEK_END); int length = ftell(fp); fseek(fp, 0, SEEK_SET); int bytesRemaining=length; unsigned int lastHash = length; char readBlock[INCREMENTAL_READ_BLOCK]; while (bytesRemaining>=(int) sizeof(readBlock)) { fread(readBlock, sizeof(readBlock), 1, fp); lastHash=SuperFastHashIncremental (readBlock, (int) sizeof(readBlock), lastHash ); bytesRemaining-=(int) sizeof(readBlock); } if (bytesRemaining>0) { fread(readBlock, bytesRemaining, 1, fp); lastHash=SuperFastHashIncremental (readBlock, bytesRemaining, lastHash ); } return lastHash; }
25.222222
87
0.648164
sh4k3n
edc84b114b39543cc6ec6b19ae3224a65e227a88
12,302
cpp
C++
security.cpp
Cloudfare/123123123123123
879954a3f628f2173ab221070e1d9bf119304ff7
[ "Apache-2.0" ]
null
null
null
security.cpp
Cloudfare/123123123123123
879954a3f628f2173ab221070e1d9bf119304ff7
[ "Apache-2.0" ]
null
null
null
security.cpp
Cloudfare/123123123123123
879954a3f628f2173ab221070e1d9bf119304ff7
[ "Apache-2.0" ]
null
null
null
#include <Windows.h> #include <TlHelp32.h> #include <tchar.h> #include "xor.h" #include "security.h" CSecurity Security; typedef struct _UNICODE_STRING { USHORT Length; USHORT MaximumLength; PWSTR Buffer; } UNICODE_STRING, *PUNICODE_STRING; typedef struct _LDR_MODULE_DUMMY_ { LIST_ENTRY InLoadOrderModuleList; LIST_ENTRY InMemoryOrderModuleList; LIST_ENTRY InInitializationOrderModuleList; PVOID BaseAddress; PVOID EntryPoint; ULONG SizeOfImage; UNICODE_STRING FullDllName; UNICODE_STRING BaseDllName; ULONG Flags; SHORT LoadCount; SHORT TlsIndex; LIST_ENTRY HashTableEntry; ULONG TimeDateStamp; } LDR_MODULE, *PLDR_MODULE; typedef struct _PEB_LDR_DATA_DUMMY_ { ULONG Length; UCHAR Initialized; PVOID SsHandle; LIST_ENTRY InLoadOrderModuleList; LIST_ENTRY InMemoryOrderModuleList; LIST_ENTRY InInitializationOrderModuleList; PVOID EntryInProgress; } PEB_LDR_DATA, *PPEB_LDR_DATA; typedef struct PEB_DUMMY_ { PVOID Dummy1; PVOID Dummy2; PVOID Dummy3; PPEB_LDR_DATA LDR_Data; } PEB_DUMMY, *PPEB_DUMMY; typedef struct _CLIENT_ID { HANDLE UniqueProcess; HANDLE UniqueThread; } CLIENT_ID, *PCLIENT_ID; typedef struct _RTL_DRIVE_LETTER_CURDIR { USHORT Flags; USHORT Length; ULONG TimeStamp; UNICODE_STRING DosPath; } RTL_DRIVE_LETTER_CURDIR, *PRTL_DRIVE_LETTER_CURDIR; typedef struct _RTL_USER_PROCESS_PARAMETERS { ULONG MaximumLength; ULONG Length; ULONG Flags; ULONG DebugFlags; PVOID ConsoleHandle; ULONG ConsoleFlags; HANDLE StdInputHandle; HANDLE StdOutputHandle; HANDLE StdErrorHandle; UNICODE_STRING CurrentDirectoryPath; HANDLE CurrentDirectoryHandle; UNICODE_STRING DllPath; UNICODE_STRING ImagePathName; UNICODE_STRING CommandLine; PVOID Environment; ULONG StartingPositionLeft; ULONG StartingPositionTop; ULONG Width; ULONG Height; ULONG CharWidth; ULONG CharHeight; ULONG ConsoleTextAttributes; ULONG WindowFlags; ULONG ShowWindowFlags; UNICODE_STRING WindowTitle; UNICODE_STRING DesktopName; UNICODE_STRING ShellInfo; UNICODE_STRING RuntimeData; RTL_DRIVE_LETTER_CURDIR DLCurrentDirectory[0x20]; } RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS; typedef void(*PPEBLOCKROUTINE)(PVOID PebLock); typedef struct _PEB_FREE_BLOCK { _PEB_FREE_BLOCK* Next; DWORD Size; } PEB_FREE_BLOCK, *PPEB_FREE_BLOCK; typedef struct _PEB { BOOLEAN InheritedAddressSpace; BOOLEAN ReadImageFileExecOptions; BOOLEAN BeingDebugged; BOOLEAN Spare; HANDLE Mutant; PVOID ImageBaseAddress; PPEB_LDR_DATA LoaderData; PRTL_USER_PROCESS_PARAMETERS ProcessParameters; PVOID SubSystemData; PVOID ProcessHeap; PVOID FastPebLock; PPEBLOCKROUTINE FastPebLockRoutine; PPEBLOCKROUTINE FastPebUnlockRoutine; ULONG EnvironmentUpdateCount; PVOID* KernelCallbackTable; PVOID EventLogSection; PVOID EventLog; PPEB_FREE_BLOCK FreeList; ULONG TlsExpansionCounter; PVOID TlsBitmap; ULONG TlsBitmapBits[0x2]; PVOID ReadOnlySharedMemoryBase; PVOID ReadOnlySharedMemoryHeap; PVOID* ReadOnlyStaticServerData; PVOID AnsiCodePageData; PVOID OemCodePageData; PVOID UnicodeCaseTableData; ULONG NumberOfProcessors; ULONG NtGlobalFlag; BYTE Spare2[0x4]; LARGE_INTEGER CriticalSectionTimeout; ULONG HeapSegmentReserve; ULONG HeapSegmentCommit; ULONG HeapDeCommitTotalFreeThreshold; ULONG HeapDeCommitFreeBlockThreshold; ULONG NumberOfHeaps; ULONG MaximumNumberOfHeaps; PVOID** ProcessHeaps; PVOID GdiSharedHandleTable; PVOID ProcessStarterHelper; PVOID GdiDCAttributeList; PVOID LoaderLock; ULONG OSMajorVersion; ULONG OSMinorVersion; ULONG OSBuildNumber; ULONG OSPlatformId; ULONG ImageSubSystem; ULONG ImageSubSystemMajorVersion; ULONG ImageSubSystemMinorVersion; ULONG GdiHandleBuffer[0x22]; ULONG PostProcessInitRoutine; ULONG TlsExpansionBitmap; BYTE TlsExpansionBitmapBits[0x80]; ULONG SessionId; } PEB, *PPEB; typedef struct _TEB { NT_TIB Tib; PVOID EnvironmentPointer; CLIENT_ID Cid; PVOID ActiveRpcInfo; PVOID ThreadLocalStoragePointer; PPEB Peb; ULONG LastErrorValue; ULONG CountOfOwnedCriticalSections; PVOID CsrClientThread; PVOID Win32ThreadInfo; ULONG Win32ClientInfo[0x1F]; PVOID WOW32Reserved; ULONG CurrentLocale; ULONG FpSoftwareStatusRegister; PVOID SystemReserved1[0x36]; PVOID Spare1; ULONG ExceptionCode; ULONG SpareBytes1[0x28]; PVOID SystemReserved2[0xA]; ULONG GdiRgn; ULONG GdiPen; ULONG GdiBrush; CLIENT_ID RealClientId; PVOID GdiCachedProcessHandle; ULONG GdiClientPID; ULONG GdiClientTID; PVOID GdiThreadLocaleInfo; PVOID UserReserved[5]; PVOID GlDispatchTable[0x118]; ULONG GlReserved1[0x1A]; PVOID GlReserved2; PVOID GlSectionInfo; PVOID GlSection; PVOID GlTable; PVOID GlCurrentRC; PVOID GlContext; NTSTATUS LastStatusValue; UNICODE_STRING StaticUnicodeString; WCHAR StaticUnicodeBuffer[0x105]; PVOID DeallocationStack; PVOID TlsSlots[0x40]; LIST_ENTRY TlsLinks; PVOID Vdm; PVOID ReservedForNtRpc; PVOID DbgSsReserved[0x2]; ULONG HardErrorDisabled; PVOID Instrumentation[0x10]; PVOID WinSockData; ULONG GdiBatchCount; ULONG Spare2; ULONG Spare3; ULONG Spare4; PVOID ReservedForOle; ULONG WaitingOnLoaderLock; PVOID StackCommit; PVOID StackCommitMax; PVOID StackReserved; } TEB, *PTEB; PPEB_DUMMY __declspec(naked) GetPEB(void) { _asm { mov eax, fs:[0x30]; retn; } } void CSecurity::HideModuleFromPEB(HINSTANCE hInstance) { PPEB_DUMMY PEB = GetPEB(); PLIST_ENTRY FirstEntryInLoadOrder = (PLIST_ENTRY)&PEB->LDR_Data->InLoadOrderModuleList; PLIST_ENTRY FirstEntryInMemoryOrder = (PLIST_ENTRY)&PEB->LDR_Data->InMemoryOrderModuleList; PLIST_ENTRY FirstEntryInInitOrder = (PLIST_ENTRY)&PEB->LDR_Data->InInitializationOrderModuleList; for (PLIST_ENTRY TempEntry = FirstEntryInLoadOrder->Flink; TempEntry != FirstEntryInLoadOrder; TempEntry = TempEntry->Flink) { PLDR_MODULE TempModule = (PLDR_MODULE)((DWORD)TempEntry - 0 * sizeof(LIST_ENTRY)); if (TempModule->BaseAddress == hInstance) { TempEntry->Blink->Flink = TempEntry->Flink; TempEntry->Flink->Blink = TempEntry->Blink; break; } } for (PLIST_ENTRY TempEntry = FirstEntryInMemoryOrder->Flink; TempEntry != FirstEntryInMemoryOrder; TempEntry = TempEntry->Flink) { PLDR_MODULE TempModule = (PLDR_MODULE)((DWORD)TempEntry - 1 * sizeof(LIST_ENTRY)); if (TempModule->BaseAddress == hInstance) { TempEntry->Blink->Flink = TempEntry->Flink; TempEntry->Flink->Blink = TempEntry->Blink; break; } } for (PLIST_ENTRY TempEntry = FirstEntryInInitOrder->Flink; TempEntry != FirstEntryInInitOrder; TempEntry = TempEntry->Flink) { PLDR_MODULE TempModule = (PLDR_MODULE)((DWORD)TempEntry - 2 * sizeof(LIST_ENTRY)); if (TempModule->BaseAddress == hInstance) { TempEntry->Blink->Flink = TempEntry->Flink; TempEntry->Flink->Blink = TempEntry->Blink; break; } } } void CSecurity::RemovePeHeader(DWORD ModuleBase) { PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)ModuleBase; PIMAGE_NT_HEADERS pNTHeader = (PIMAGE_NT_HEADERS)((DWORD)pDosHeader + (DWORD)pDosHeader->e_lfanew); if (pNTHeader->Signature != IMAGE_NT_SIGNATURE) return; if (pNTHeader->FileHeader.SizeOfOptionalHeader) { DWORD Protect; WORD Size = pNTHeader->FileHeader.SizeOfOptionalHeader; VirtualProtect((void*)ModuleBase, Size, PAGE_EXECUTE_READWRITE, &Protect); RtlZeroMemory((void*)ModuleBase, Size); VirtualProtect((void*)ModuleBase, Size, Protect, &Protect); } } void CSecurity::HideModule(HANDLE hModule) { PIMAGE_DOS_HEADER pDOSHeader = (PIMAGE_DOS_HEADER)hModule; if (pDOSHeader->e_magic == IMAGE_DOS_SIGNATURE) { PIMAGE_NT_HEADERS pNTHeader = (PIMAGE_NT_HEADERS)((DWORD)pDOSHeader + (DWORD)pDOSHeader->e_lfanew); if (pNTHeader->Signature == IMAGE_NT_SIGNATURE) { DWORD dwOld, dwSize = pNTHeader->OptionalHeader.SizeOfHeaders; if (VirtualProtect((LPVOID)pDOSHeader, dwSize, PAGE_READWRITE, &dwOld)) { memset((void*)pDOSHeader, 0, dwSize); VirtualProtect((LPVOID)pDOSHeader, dwSize, dwOld, &dwOld); } } _TEB *pTeb = nullptr; _asm { mov eax, fs:[0x18] mov pTeb, eax } PLIST_ENTRY pList = &pTeb->Peb->LoaderData->InLoadOrderModuleList; for (PLIST_ENTRY pEntry = pList->Flink; pEntry != pList; pEntry = pEntry->Flink) { PLDR_MODULE pModule = (PLDR_MODULE)pEntry; if (pModule->BaseAddress == hModule) { pEntry = &pModule->InLoadOrderModuleList; pEntry->Blink->Flink = pEntry->Flink; pEntry->Flink->Blink = pEntry->Blink; memset(pEntry, 0, sizeof(LIST_ENTRY)); pEntry = &pModule->InMemoryOrderModuleList; pEntry->Blink->Flink = pEntry->Flink; pEntry->Flink->Blink = pEntry->Blink; memset(pEntry, 0, sizeof(LIST_ENTRY)); pEntry = &pModule->InInitializationOrderModuleList; pEntry->Blink->Flink = pEntry->Flink; pEntry->Flink->Blink = pEntry->Blink; memset(pEntry, 0, sizeof(LIST_ENTRY)); pEntry = &pModule->HashTableEntry; pEntry->Blink->Flink = pEntry->Flink; pEntry->Flink->Blink = pEntry->Blink; memset(pEntry, 0, sizeof(LIST_ENTRY)); memset(pModule->FullDllName.Buffer, 0, pModule->FullDllName.Length); memset(pModule, 0, sizeof(LDR_MODULE)); break; } } } } bool CSecurity::DestroyModuleHeader(HMODULE hModule) { DWORD dwStartOffset = (DWORD)hModule; IMAGE_DOS_HEADER *pDosHeader = (PIMAGE_DOS_HEADER)dwStartOffset; if (pDosHeader->e_magic != IMAGE_DOS_SIGNATURE) return false; IMAGE_NT_HEADERS *pNtHeader = (PIMAGE_NT_HEADERS)(dwStartOffset + pDosHeader->e_lfanew); if (pNtHeader->Signature != IMAGE_NT_SIGNATURE) return false; DWORD dwOldProtection = NULL; if (!VirtualProtect((PVOID)hModule, pNtHeader->OptionalHeader.SizeOfHeaders, PAGE_EXECUTE_READWRITE, &dwOldProtection)) return false; ZeroMemory((PVOID)hModule, pNtHeader->OptionalHeader.SizeOfHeaders); VirtualProtect((PVOID)hModule, pNtHeader->OptionalHeader.SizeOfHeaders, dwOldProtection, &dwOldProtection); return true; }
34.55618
132
0.624776
Cloudfare
edc89ddec2a77f1500d32cb80448f45dc1a05ff9
604
hpp
C++
src/lang/ast_node_base_class_undefines.hpp
fl4shk/liborangepower
a2aa99a7f9b35cc06ad78976406432913718800b
[ "MIT" ]
2
2019-01-02T02:07:44.000Z
2022-03-21T10:22:18.000Z
src/lang/ast_node_base_class_undefines.hpp
fl4shk/liborangepower
a2aa99a7f9b35cc06ad78976406432913718800b
[ "MIT" ]
null
null
null
src/lang/ast_node_base_class_undefines.hpp
fl4shk/liborangepower
a2aa99a7f9b35cc06ad78976406432913718800b
[ "MIT" ]
1
2019-01-01T02:51:25.000Z
2019-01-01T02:51:25.000Z
//#ifndef liborangepower_lang_ast_node_base_class_undefines_hpp //#define liborangepower_lang_ast_node_base_class_undefines_hpp // lang/ast_node_base_class_undefines.hpp #undef MEMB_VAR #undef _DECL_MEMB_VAR #undef _COPY_MEMB_VAR #undef _INNER_WRAP_DATA #undef _PLUS_RAW_NEWLINE #undef DATA #undef _INNER_ACCEPT_CHILDREN #undef _INNER_DUP #undef CHILDREN #undef SHARED_CONTENTS #undef SHARED_FUNC_CONTENTS_2 #undef CONV_ENUM_CASE #undef CONV_KIND_CASE #undef CONV_ENUM_SWITCH #undef BUILD_KIND_OPERATOR_LSHIFT #undef AST_VISITOR //#endif // liborangepower_lang_ast_node_base_class_undefines_hpp
20.827586
66
0.865894
fl4shk
edc9353c0f0000526ec752051cee6281accf3b4e
1,550
cpp
C++
src/Board/Subgrid.cpp
renanmoreira17/SudokuSolver
62052c2d8a2319cb82f98ef0a9f618653e9e0a90
[ "MIT" ]
null
null
null
src/Board/Subgrid.cpp
renanmoreira17/SudokuSolver
62052c2d8a2319cb82f98ef0a9f618653e9e0a90
[ "MIT" ]
null
null
null
src/Board/Subgrid.cpp
renanmoreira17/SudokuSolver
62052c2d8a2319cb82f98ef0a9f618653e9e0a90
[ "MIT" ]
null
null
null
#include "Subgrid.hpp" #include "ElementList.hpp" #include "ElementWrapper.hpp" #include "Grid.hpp" #include "Tile.hpp" #include <utility> Subgrid::Subgrid(Grid* grid, const short index) : Region(index, RegionType::SUBGRID) , m_grid(grid) { const auto lambda = [&](const std::shared_ptr<Tile>& tile) { tile->setSubgrid(this); }; m_elementList = Region::make_subgrid(index, grid->getGridTiles(), lambda); } Subgrid::Subgrid(Subgrid&& other) : Region(other) { m_grid = other.m_grid; m_index = other.m_index; auto* head = m_elementList->getHead(); do { head->getElement()->setSubgrid(this); } while ((head = head->next())); other.m_grid = nullptr; other.m_elementList = nullptr; } Subgrid& Subgrid::operator=(Subgrid&& other) { if (&other == this) return *this; Region::operator=(std::move(other)); m_grid = other.m_grid; m_index = other.m_index; auto head = m_elementList->getHead(); do { head->getElement()->setSubgrid(this); } while ((head = head->next())); other.m_grid = nullptr; other.m_elementList = nullptr; return *this; } const std::shared_ptr<Tile> Subgrid::getTile(const TileValueType row, const TileValueType col) const { const auto first = m_elementList->cbegin(); return *std::next(first, row * 3 + col); } const std::shared_ptr<Tile> Subgrid::operator()(const TileValueType row, const TileValueType col) const { return getTile(row, col); }
23.484848
100
0.629677
renanmoreira17
edceeea4acc50296e38bf268baa2122e75513c76
528
cc
C++
src/scanner.cc
jorenheit/brainfix
4254fcfb6dc29dd8bb63fbde9db49570ce99971d
[ "MIT" ]
1
2022-02-01T17:13:03.000Z
2022-02-01T17:13:03.000Z
src/scanner.cc
jorenheit/brainfix
4254fcfb6dc29dd8bb63fbde9db49570ce99971d
[ "MIT" ]
null
null
null
src/scanner.cc
jorenheit/brainfix
4254fcfb6dc29dd8bb63fbde9db49570ce99971d
[ "MIT" ]
null
null
null
#include "scanner.ih" std::string Scanner::escape(char c) { switch (c) { case 'n': return std::string(1, '\n'); case 't': return std::string(1, '\t'); case '0': return std::string(1, '\0'); default: return std::string(1, c); } } std::string Scanner::escape(std::string const &matched) { std::string result = matched.substr(0, matched.size() - 2) // remove escape sequence from the back + escape(matched.back()); // replace by escaped charater return result; }
22.956522
85
0.583333
jorenheit
edd5f4c6a6e6747ac841211200f30e239465d367
3,013
hpp
C++
src/input_manager.hpp
r6eve/area776
c39b9d2393a7cdaaa056933fa452ec9adfc8fdce
[ "BSL-1.0" ]
null
null
null
src/input_manager.hpp
r6eve/area776
c39b9d2393a7cdaaa056933fa452ec9adfc8fdce
[ "BSL-1.0" ]
1
2018-06-02T05:38:40.000Z
2018-06-02T07:47:41.000Z
src/input_manager.hpp
r6eve/area776
c39b9d2393a7cdaaa056933fa452ec9adfc8fdce
[ "BSL-1.0" ]
null
null
null
// // Copyright r6eve 2019 - // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // https://www.boost.org/LICENSE_1_0.txt) // #pragma once #include <iostream> #include "def_global.hpp" namespace input_device { enum { up = 0, down, left, right, f, x, space, count, }; } // namespace input_device class InputManager { SDL_Joystick *joystick_ = nullptr; bool press_key_[input_device::count]; bool edge_key_[input_device::count]; public: InputManager() noexcept { const int n = SDL_NumJoysticks(); if (n < 0) { std::cerr << "error: " << SDL_GetError() << '\n'; exit(EXIT_FAILURE); } if (n == 0) { // JoySticks not found. return; } // Only use one of JoySticks. joystick_ = SDL_JoystickOpen(0); } inline void update() { bool new_press_key[input_device::count]; for (int i = 0; i < input_device::count; ++i) { new_press_key[i] = false; } if (joystick_) { SDL_JoystickUpdate(); new_press_key[input_device::f] = SDL_JoystickGetButton(joystick_, 0) == SDL_PRESSED; new_press_key[input_device::x] = SDL_JoystickGetButton(joystick_, 1) == SDL_PRESSED; new_press_key[input_device::up] = SDL_JoystickGetAxis(joystick_, 1) < -256; new_press_key[input_device::down] = SDL_JoystickGetAxis(joystick_, 1) > 256; new_press_key[input_device::left] = SDL_JoystickGetAxis(joystick_, 0) < -256; new_press_key[input_device::right] = SDL_JoystickGetAxis(joystick_, 0) > 256; } const Uint8 *state = SDL_GetKeyboardState(nullptr); new_press_key[input_device::up] = (state[SDL_SCANCODE_UP] == SDL_PRESSED) || (state[SDL_SCANCODE_K] == SDL_PRESSED); new_press_key[input_device::down] = (state[SDL_SCANCODE_DOWN] == SDL_PRESSED) || (state[SDL_SCANCODE_J] == SDL_PRESSED); new_press_key[input_device::left] = (state[SDL_SCANCODE_LEFT] == SDL_PRESSED) || (state[SDL_SCANCODE_H] == SDL_PRESSED); new_press_key[input_device::right] = (state[SDL_SCANCODE_RIGHT] == SDL_PRESSED) || (state[SDL_SCANCODE_L] == SDL_PRESSED); new_press_key[input_device::f] = state[SDL_SCANCODE_F] == SDL_PRESSED; new_press_key[input_device::x] = state[SDL_SCANCODE_X] == SDL_PRESSED; new_press_key[input_device::space] = state[SDL_SCANCODE_SPACE] == SDL_PRESSED; for (int i = 0; i < input_device::count; ++i) { edge_key_[i] = !press_key_[i] && new_press_key[i]; press_key_[i] = new_press_key[i]; } } inline bool edge_key_p(const unsigned char button) const noexcept { return edge_key_[button]; } inline bool press_key_p(const unsigned char button) const noexcept { return press_key_[button]; } ~InputManager() noexcept { if (joystick_) { SDL_JoystickClose(joystick_); } } };
28.158879
80
0.637239
r6eve
edd9d00f8905ab686fa0a2800b5720bd706aff30
21,040
cpp
C++
src/common/WFiles.cpp
laurent22/ConEmu
52d4f91692e3ef9ec35d78e29d03e53f035c9e57
[ "BSD-2-Clause" ]
2
2017-09-17T12:09:16.000Z
2021-05-15T21:36:47.000Z
src/common/WFiles.cpp
laurent22/ConEmu
52d4f91692e3ef9ec35d78e29d03e53f035c9e57
[ "BSD-2-Clause" ]
null
null
null
src/common/WFiles.cpp
laurent22/ConEmu
52d4f91692e3ef9ec35d78e29d03e53f035c9e57
[ "BSD-2-Clause" ]
1
2021-07-16T07:53:55.000Z
2021-07-16T07:53:55.000Z
 /* Copyright (c) 2014-2015 Maximus5 All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #define HIDE_USE_EXCEPTION_INFO #include "common.hpp" #include "WFiles.h" #include "WObjects.h" // Returns true, if application was found in registry: // [HKCU|HKLM]\Software\Microsoft\Windows\CurrentVersion\App Paths // Also, function may change local process %PATH% variable bool SearchAppPaths(LPCWSTR asFilePath, CmdArg& rsFound, bool abSetPath, CmdArg* rpsPathRestore /*= NULL*/) { #if defined(CONEMU_MINIMAL) PRAGMA_ERROR("Must not be included in ConEmuHk"); #endif if (rpsPathRestore) rpsPathRestore->Empty(); if (!asFilePath || !*asFilePath) return false; LPCWSTR pszSearchFile = PointToName(asFilePath); LPCWSTR pszExt = PointToExt(pszSearchFile); // Lets try find it in "App Paths" // "HKCU\Software\Microsoft\Windows\CurrentVersion\App Paths\" // "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" LPCWSTR pszRoot = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\"; HKEY hk; LONG lRc; CmdArg lsName; lsName.Attach(lstrmerge(pszRoot, pszSearchFile, pszExt ? NULL : L".exe")); // Seems like 32-bit and 64-bit registry branches are the same now, but just in case - will check both DWORD nWOW[2] = {WIN3264TEST(KEY_WOW64_32KEY,KEY_WOW64_64KEY), WIN3264TEST(KEY_WOW64_64KEY,KEY_WOW64_32KEY)}; for (int i = 0; i < 3; i++) { bool bFound = false; DWORD nFlags = ((i && IsWindows64()) ? nWOW[i-1] : 0); if ((i == 2) && !nFlags) break; // This is 32-bit OS lRc = RegOpenKeyEx(i ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, lsName, 0, KEY_READ|nFlags, &hk); if (lRc != 0) continue; wchar_t szVal[MAX_PATH+1] = L""; DWORD nType, nSize = sizeof(szVal)-sizeof(szVal[0]); lRc = RegQueryValueEx(hk, NULL, NULL, &nType, (LPBYTE)szVal, &nSize); if (lRc == 0) { wchar_t *pszCheck = NULL; if (nType == REG_SZ) { pszCheck = szVal; } else if (nType == REG_EXPAND_SZ) { pszCheck = ExpandEnvStr(szVal); } // May be quoted if (pszCheck) { LPCWSTR pszPath = Unquote(pszCheck, true); if (FileExists(pszPath)) { // asFilePath will be invalid after .Set rsFound.Set(pszPath); bFound = true; if (pszCheck != szVal) free(pszCheck); // The program may require additional "%PATH%". So, if allowed... if (abSetPath) { nSize = 0; lRc = RegQueryValueEx(hk, L"PATH", NULL, &nType, NULL, &nSize); if (lRc == 0 && nSize) { wchar_t* pszCurPath = GetEnvVar(L"PATH"); wchar_t* pszAddPath = (wchar_t*)calloc(nSize+4,1); wchar_t* pszNewPath = NULL; if (pszAddPath) { lRc = RegQueryValueEx(hk, L"PATH", NULL, &nType, (LPBYTE)pszAddPath, &nSize); if (lRc == 0 && *pszAddPath) { // Если в "%PATH%" этого нет (в начале) - принудительно добавить int iCurLen = pszCurPath ? lstrlen(pszCurPath) : 0; int iAddLen = lstrlen(pszAddPath); bool bNeedAdd = true; if ((iCurLen >= iAddLen) && (pszCurPath[iAddLen] == L';' || pszCurPath[iAddLen] == 0)) { wchar_t ch = pszCurPath[iAddLen]; pszCurPath[iAddLen] = 0; if (lstrcmpi(pszCurPath, pszAddPath) == 0) bNeedAdd = false; pszCurPath[iAddLen] = ch; } // Если пути еще нет if (bNeedAdd) { if (rpsPathRestore) { rpsPathRestore->SavePathVar(pszCurPath); } pszNewPath = lstrmerge(pszAddPath, L";", pszCurPath); if (pszNewPath) { SetEnvironmentVariable(L"PATH", pszNewPath); } else { _ASSERTE(pszNewPath!=NULL && "Allocation failed?"); } } } } SafeFree(pszAddPath); SafeFree(pszCurPath); SafeFree(pszNewPath); } } } } } RegCloseKey(hk); if (bFound) return true; } return false; } // GetFullPathName & ExpandEnvStr wchar_t* GetFullPathNameEx(LPCWSTR asPath) { wchar_t* pszResult = NULL; wchar_t* pszTemp = NULL; if (wcschr(asPath, L'%')) { if ((pszTemp = ExpandEnvStr(asPath)) != NULL) { asPath = pszTemp; } } DWORD cchMax = MAX_PATH+1; pszResult = (wchar_t*)calloc(cchMax,sizeof(*pszResult)); if (pszResult) { wchar_t* pszFilePart; DWORD nLen = GetFullPathName(asPath, cchMax, pszResult, &pszFilePart); if (!nLen || (nLen >= cchMax)) { _ASSERTEX(FALSE && "GetFullPathName failed"); SafeFree(pszResult); } } if (!pszResult) { _ASSERTEX(pszResult!=NULL); pszResult = lstrdup(asPath); } SafeFree(pszTemp); return pszResult; } bool FindFileName(LPCWSTR asPath, CEStr& rsName) { LPCWSTR pszName = wcsrchr(asPath, L'\\'); if (!pszName || pszName[1] == 0) { rsName.Empty(); return false; } else { pszName++; } rsName.Set(pszName); // "." or ".." if (IsDotsName(pszName)) { return true; } bool lbFileFound = false; WIN32_FIND_DATAW fnd = {0}; DWORD nErrCode; HANDLE hFind = FindFirstFile(asPath, &fnd); if (hFind == INVALID_HANDLE_VALUE) { // FindFirstFile может обломаться из-за симлинков nErrCode = GetLastError(); if (nErrCode == ERROR_ACCESS_DENIED) { hFind = CreateFile(asPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (hFind == INVALID_HANDLE_VALUE) hFind = CreateFile(asPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); lbFileFound = (hFind && hFind != INVALID_HANDLE_VALUE); SafeCloseHandle(hFind); } } else { // that may be folder or file rsName.Set(fnd.cFileName); lbFileFound = true; FindClose(hFind); } return lbFileFound; } bool MakePathProperCase(CEStr& rsPath) { if (rsPath.IsEmpty()) return false; bool bFound = false; // Must be full path here with back-slashes _ASSERTE(wcschr(rsPath,L'/')==NULL && wcschr(rsPath,L'\\')!=NULL); // Let loop through folders wchar_t* psz = rsPath.ms_Arg; if (psz[0] == L'\\' && psz[1] == L'\\') { // Network or UNC psz += 2; if ((psz[0] == L'?' || psz[0] == L'.') && psz[1] == L'\\') { psz += 2; if (psz[0] == L'U' && psz[1] == L'N' && psz[2] == L'C' && psz[3] == L'\\') psz += 4; } if (!(isDriveLetter(psz[0]) && psz[1] == L':')) { // "Server\Share\" is expected here, just skip them } } if (isDriveLetter(psz[0]) && psz[1] == L':') { // Uppercase the drive letter CharUpperBuff(psz, 1); psz += 2; if (psz[0] == L'\\') { psz++; // Skip first slash } else { _ASSERTE(psz[0] == L'\\'); } } CEStr lsName; int iName, iFound; while (psz && *psz) { while (*psz == L'\\') psz++; // Hmm? Double slashes? if (!*psz) break; wchar_t* pszSlash = wcschr(psz, L'\\'); if (pszSlash) *pszSlash = 0; bFound = FindFileName(rsPath.ms_Arg, lsName); if (bFound) { iName = lstrlen(psz); iFound = lstrlen(lsName); // If length matches but case differs (do not touch short names like as "PROGRA~1") if ((iName == iFound) && lstrcmp(psz, lsName)) { memmove(psz, lsName.ms_Arg, sizeof(*psz)*iName); } } if (pszSlash) *pszSlash = L'\\'; if (!pszSlash || !bFound) break; psz = pszSlash+1; } return bFound; } int ReadTextFile(LPCWSTR asPath, DWORD cchMax, wchar_t*& rsBuffer, DWORD& rnChars, DWORD& rnErrCode, DWORD DefaultCP /*= 0*/) { HANDLE hFile = CreateFile(asPath, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); if (!hFile || hFile == INVALID_HANDLE_VALUE) { rnErrCode = GetLastError(); return -1; } DWORD nSize = GetFileSize(hFile, NULL); if (!nSize || nSize >= cchMax) { rnErrCode = GetLastError(); CloseHandle(hFile); return -2; } char* pszDataA = (char*)malloc(nSize+5); if (!pszDataA) { _ASSERTE(pszDataA); CloseHandle(hFile); return -3; } pszDataA[nSize] = 0; pszDataA[nSize+1] = 0; pszDataA[nSize+2] = 0; pszDataA[nSize+3] = 0; pszDataA[nSize+4] = 0; DWORD nRead = 0; BOOL bRead = ReadFile(hFile, pszDataA, nSize, &nRead, 0); rnErrCode = GetLastError(); CloseHandle(hFile); if (!bRead || (nRead != nSize)) { free(pszDataA); return -4; } // Определить код.страницу файла if ((DefaultCP == CP_UTF8) || (pszDataA[0] == '\xEF' && pszDataA[1] == '\xBB' && pszDataA[2] == '\xBF')) { bool BOM = (pszDataA[0] == '\xEF' && pszDataA[1] == '\xBB' && pszDataA[2] == '\xBF'); LPCSTR pszNoBom = pszDataA + (BOM ? 3 : 0); DWORD nLenNoBom = nSize - (BOM ? 3 : 0); // UTF-8 BOM rsBuffer = (wchar_t*)calloc(nSize+2,2); if (!rsBuffer) { _ASSERTE(rsBuffer); free(pszDataA); return -5; } int nLen = MultiByteToWideChar(CP_UTF8, 0, pszNoBom, nLenNoBom, rsBuffer, nSize); if ((nLen < 0) || (nLen > (int)nSize)) { SafeFree(pszDataA); SafeFree(rsBuffer); return -6; } rnChars = nLen; } else if ((DefaultCP == 1200) || (pszDataA[0] == '\xFF' && pszDataA[1] == '\xFE')) { bool BOM = (pszDataA[0] == '\xFF' && pszDataA[1] == '\xFE'); if (!BOM) { rsBuffer = (wchar_t*)pszDataA; pszDataA = NULL; rnChars = (nSize >> 1); } else { LPCSTR pszNoBom = pszDataA + 2; DWORD nLenNoBom = nSize - 2; // CP-1200 BOM rsBuffer = lstrdup((wchar_t*)pszNoBom); if (!rsBuffer) { _ASSERTE(rsBuffer); SafeFree(pszDataA); return -7; } rnChars = (nLenNoBom >> 1); } } else { // Plain ANSI rsBuffer = (wchar_t*)calloc(nSize+2,2); _ASSERTE(rsBuffer); int nLen = MultiByteToWideChar(DefaultCP ? DefaultCP : CP_ACP, 0, pszDataA, nSize, rsBuffer, nSize+1); if ((nLen < 0) || (nLen > (int)nSize)) { SafeFree(pszDataA); SafeFree(rsBuffer); return -8; } rnChars = nLen; } SafeFree(pszDataA); return 0; } // Returns negative numbers on errors int WriteTextFile(LPCWSTR asPath, const wchar_t* asBuffer, int anSrcLen/* = -1*/, DWORD OutCP /*= CP_UTF8*/, bool WriteBOM /*= true*/, LPDWORD rnErrCode /*= NULL*/) { int iRc = 0; int iWriteLen = 0; DWORD nWritten = 0; LPCVOID ptrBuf = NULL; char* pszMultibyte = NULL; HANDLE hFile = NULL; if (OutCP == 1200) { ptrBuf = asBuffer; iWriteLen = (anSrcLen >= 0) ? (anSrcLen * sizeof(*asBuffer)) : (lstrlen(asBuffer) * sizeof(*asBuffer)); } else //if (DefaultCP == CP_UTF8) { int iMBLen = WideCharToMultiByte(OutCP, 0, asBuffer, anSrcLen, NULL, 0, NULL, NULL); if (iMBLen < 0) { iRc = -2; goto wrap; } pszMultibyte = (char*)malloc(iMBLen); if (!pszMultibyte) { iRc = -3; goto wrap; } iWriteLen = WideCharToMultiByte(OutCP, 0, asBuffer, anSrcLen, pszMultibyte, iMBLen, NULL, NULL); } if (iWriteLen < 0) { iRc = -2; goto wrap; } hFile = CreateFile(asPath, GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (!hFile || (hFile == INVALID_HANDLE_VALUE)) { iRc = -1; goto wrap; } if (WriteBOM) { char UTF8BOM[] = {'\xEF','\xBB','\xBF'}; char CP1200BOM[] = {'\xFF','\xFE'}; BOOL bWrite = TRUE; DWORD nBomSize = 0; switch (OutCP) { case CP_UTF8: iRc = (WriteFile(hFile, UTF8BOM, 3, &nBomSize, NULL) && (nBomSize == 3)) ? nBomSize : -4; break; case 1200: iRc = (WriteFile(hFile, CP1200BOM, 2, &nBomSize, NULL) && (nBomSize == 2)) ? nBomSize : -4; break; } if (iRc < 0) goto wrap; } if (!WriteFile(hFile, ptrBuf, (DWORD)iWriteLen, &nWritten, NULL) || ((DWORD)iWriteLen != nWritten)) { iRc = -5; goto wrap; } _ASSERTE(iRc >= 0); iRc += nWritten; wrap: if (rnErrCode) *rnErrCode = GetLastError(); if (hFile && (hFile != INVALID_HANDLE_VALUE)) CloseHandle(hFile); SafeFree(pszMultibyte); return iRc; } // asDirectory - folder, where to check files (doesn't have to have trailing "\") // asFileList - "\0" separated, "\0\0" teminated list of file names (may have subfolders) // but if (anListCount != -1) - only first anListCount files in asFileList will be checked bool FilesExists(LPCWSTR asDirectory, LPCWSTR asFileList, bool abAll /*= false*/, int anListCount /*= -1*/) { if (!asDirectory || !*asDirectory) return false; if (!asFileList || !*asFileList) return false; bool bFound = false; wchar_t* pszBuf = NULL; LPCWSTR pszCur = asFileList; int nDirLen = lstrlen(asDirectory); while (*pszCur) { int nNameLen = lstrlen(pszCur); if (asDirectory[nDirLen-1] != L'\\' && *pszCur != L'\\') pszBuf = lstrmerge(asDirectory, L"\\", pszCur); else pszBuf = lstrmerge(asDirectory, pszCur); bool bFile = FileExists(pszBuf); SafeFree(pszBuf); if (bFile) { bFound = true; if (!abAll) break; } else if (abAll) { bFound = false; break; } if (anListCount == -1) { pszCur += nNameLen+1; } else { anListCount--; if (anListCount < 1) break; } } return bFound; } bool IsDotsName(LPCWSTR asName) { return (asName && (asName[0] == L'.' && (asName[1] == 0 || (asName[1] == L'.' && asName[2] == 0)))); } // Useful for searching sources from compilation error log bool FileExistSubDir(LPCWSTR asDirectory, LPCWSTR asFile, int iDepth, CEStr& rsFound) { if (FilesExists(asDirectory, asFile, true, 1)) { rsFound.Attach(JoinPath(asDirectory, asFile)); return true; } else if (iDepth <= 0) { return false; } CEStr lsFind = JoinPath(asDirectory, L"*"); WIN32_FIND_DATAW fnd = {0}; HANDLE hFind = FindFirstFile(lsFind, &fnd); if (!hFind || (hFind == INVALID_HANDLE_VALUE)) { return false; } bool lbFound = false; do { if ((fnd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) { // Each find returns "." and ".." items // We do not need them if (!IsDotsName(fnd.cFileName)) { lsFind.Attach(JoinPath(asDirectory, fnd.cFileName)); int iChildDepth = (iDepth-1); if (lstrcmpi(fnd.cFileName, L".git") == 0 || lstrcmpi(fnd.cFileName, L".svn") == 0) iChildDepth = 0; // do not scan children of ".git", ".svn" // Recursion lbFound = FileExistSubDir(lsFind, asFile, iChildDepth, rsFound); if (lbFound) break; } } } while (FindNextFile(hFind, &fnd)); FindClose(hFind); return lbFound; } bool DirectoryExists(LPCWSTR asPath) { if (!asPath || !*asPath) return false; bool lbFound = false; HANDLE hFind = CreateFile(asPath, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); if (hFind && hFind != INVALID_HANDLE_VALUE) { BY_HANDLE_FILE_INFORMATION fi = {0}; if (GetFileInformationByHandle(hFind, &fi) && (fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { lbFound = true; } CloseHandle(hFind); return lbFound; } // Try to use FindFirstFile? WIN32_FIND_DATAW fnd = {0}; hFind = FindFirstFile(asPath, &fnd); if (hFind == INVALID_HANDLE_VALUE) { return false; } do { if ((fnd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) { // Each find returns "." and ".." items // We do not need them if (!IsDotsName(fnd.cFileName)) { lbFound = TRUE; break; } } } while (FindNextFile(hFind, &fnd)); FindClose(hFind); return (lbFound != FALSE); } bool MyCreateDirectory(wchar_t* asPath) { if (!asPath || !*asPath) return false; BOOL bOk = FALSE; DWORD dwErr = 0; wchar_t* psz1, *pszSlash; psz1 = wcschr(asPath, L'\\'); pszSlash = wcsrchr(asPath, L'\\'); if (pszSlash && (pszSlash == psz1)) pszSlash = NULL; if (pszSlash) { _ASSERTE(*pszSlash == L'\\'); *pszSlash = 0; if ((pszSlash[1] == 0) && DirectoryExists(asPath)) { *pszSlash = L'\\'; return true; } } else { if (DirectoryExists(asPath)) return true; } if (CreateDirectory(asPath, NULL)) { bOk = TRUE; } else { dwErr = GetLastError(); if (pszSlash && (dwErr != ERROR_ACCESS_DENIED)) { bOk = MyCreateDirectory(asPath); } else if (dwErr == ERROR_ALREADY_EXISTS) { _ASSERTE(FALSE && "Must not get here"); } } if (pszSlash) { *pszSlash = L'\\'; } return (bOk != FALSE); } bool FileCompare(LPCWSTR asFilePath1, LPCWSTR asFilePath2) { bool bMatch = false; HANDLE hFile1, hFile2 = NULL; LPBYTE pBuf1 = NULL, pBuf2 = NULL; LARGE_INTEGER lSize1 = {}, lSize2 = {}; DWORD nRead1 = 0, nRead2 = 0; BOOL bRead1, bRead2; hFile1 = CreateFile(asFilePath1, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (!hFile1 || hFile1 == INVALID_HANDLE_VALUE) goto wrap; hFile2 = CreateFile(asFilePath2, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (!hFile2 || hFile2 == INVALID_HANDLE_VALUE) goto wrap; if (!GetFileSizeEx(hFile1, &lSize1) || !lSize1.QuadPart || lSize1.HighPart) goto wrap; if (!GetFileSizeEx(hFile2, &lSize2) || !lSize2.QuadPart || lSize2.HighPart) goto wrap; if (lSize1.QuadPart != lSize2.QuadPart) goto wrap; // Need binary comparision pBuf1 = (LPBYTE)malloc(lSize1.LowPart); pBuf2 = (LPBYTE)malloc(lSize2.LowPart); if (!pBuf1 || !pBuf2) goto wrap; bRead1 = ReadFile(hFile1, pBuf1, lSize1.LowPart, &nRead1, NULL); bRead2 = ReadFile(hFile2, pBuf2, lSize2.LowPart, &nRead2, NULL); if (!bRead1 || !bRead2 || nRead1 != lSize1.LowPart || nRead2 != nRead1) goto wrap; // Comparision bMatch = (memcmp(pBuf1, pBuf2, lSize1.LowPart) == 0); wrap: if (hFile1 && hFile1 != INVALID_HANDLE_VALUE) CloseHandle(hFile1); if (hFile2 && hFile2 != INVALID_HANDLE_VALUE) CloseHandle(hFile2); SafeFree(pBuf1); SafeFree(pBuf2); return bMatch; } #if 0 // This cancels ASYNCHRONOUS calls int apiCancelIoEx(HANDLE hFile, LPOVERLAPPED lpOverlapped) { int iRc = -1; BOOL bRc = FALSE; typedef BOOL (WINAPI* CancelIoEx_t)(HANDLE hFile, LPOVERLAPPED lpOverlapped); static CancelIoEx_t fnCancelIoEx = NULL; static bool fnChecked = false; if (!fnChecked) { HMODULE hKernel = GetModuleHandle(L"Kernel32.dll"); fnCancelIoEx = hKernel ? (CancelIoEx_t)GetProcAddress(hKernel, "CancelIoEx") : NULL; fnChecked = false; } if (fnCancelIoEx) { bRc = fnCancelIoEx(hFile, lpOverlapped); iRc = bRc ? 1 : 0; } return iRc; } #endif // This cancels SYNCHRONOUS calls int apiCancelSynchronousIo(HANDLE hThread) { int iRc = -1; BOOL bRc = FALSE; typedef BOOL (WINAPI* CancelSynchronousIo_t)(HANDLE hThread); static CancelSynchronousIo_t fnCancelSynchronousIo = NULL; static bool fnChecked = false; if (!fnChecked) { HMODULE hKernel = GetModuleHandle(L"Kernel32.dll"); fnCancelSynchronousIo = hKernel ? (CancelSynchronousIo_t)GetProcAddress(hKernel, "CancelSynchronousIo") : NULL; fnChecked = false; } if (fnCancelSynchronousIo) { bRc = fnCancelSynchronousIo(hThread); iRc = bRc ? 1 : 0; } return iRc; } // URLZONE_LOCAL_MACHINE = 0 // URLZONE_INTRANET = 1 // URLZONE_TRUSTED = 2 // URLZONE_INTERNET = 3 // URLZONE_UNTRUSTED = 4 bool HasZoneIdentifier(LPCWSTR asFile, int& nZoneID) { if (!asFile || !*asFile) { _ASSERTE(asFile && *asFile); return false; } bool bHasZone = false; CEStr lsZoneStream = lstrmerge(asFile, L":Zone.Identifier"); #ifdef _DEBUG char szData[128] = ""; DWORD nRead = 0; BOOL bRead; #endif HANDLE hStream = CreateFile(lsZoneStream, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (hStream && (hStream != INVALID_HANDLE_VALUE)) { #ifdef _DEBUG bRead = ReadFile(hStream, szData, sizeof(szData), &nRead, NULL); #endif CloseHandle(hStream); nZoneID = (int)GetPrivateProfileInt(L"ZoneTransfer", L"ZoneId", 3, lsZoneStream); bHasZone = true; } return bHasZone; } bool DropZoneIdentifier(LPCWSTR asFile, DWORD& nErrCode) { CEStr lsZoneStream = lstrmerge(asFile, L":Zone.Identifier"); // First, try to delete "Zone.Identifier" stream if (DeleteFile(lsZoneStream)) return true; nErrCode = GetLastError(); // If failed - try to change it if (WritePrivateProfileString(L"ZoneTransfer", L"ZoneId", 0, lsZoneStream)) return true; nErrCode = GetLastError(); // Access denied? return false; }
24.073227
164
0.649287
laurent22
eddaf1174e8952f6f40aa0b48d5bf99c517752dd
4,852
hpp
C++
include/Siv3D/Random.hpp
cs3238-tsuzu/AIShoot
7c3dbb6e3b49f7d0ae1efe7ca69251ad50477647
[ "MIT" ]
1
2018-05-23T10:57:32.000Z
2018-05-23T10:57:32.000Z
include/Siv3D/Random.hpp
cs3238-tsuzu/AIShoot
7c3dbb6e3b49f7d0ae1efe7ca69251ad50477647
[ "MIT" ]
null
null
null
include/Siv3D/Random.hpp
cs3238-tsuzu/AIShoot
7c3dbb6e3b49f7d0ae1efe7ca69251ad50477647
[ "MIT" ]
null
null
null
//----------------------------------------------- // // This file is part of the Siv3D Engine. // // Copyright (c) 2008-2018 Ryo Suzuki // Copyright (c) 2016-2018 OpenSiv3D Project // // Licensed under the MIT License. // //----------------------------------------------- # pragma once # include <algorithm> # include "Distribution.hpp" # include "Duration.hpp" # include "DefaultRNG.hpp" namespace s3d { /// <summary> /// [0, 1) の範囲の乱数を返します。 /// </summary> /// <remarks> /// グローバルな乱数エンジンを使用します。 /// </remarks> /// <returns> /// [0, 1) の範囲の乱数 /// </returns> inline double Random() { return GetDefaultRNG().generateReal(); } /// <summary> /// 指定した型と範囲の乱数を返します。 /// </summary> /// <param name="min"> /// 生成したい乱数の最小値 /// </param> /// <param name="max"> /// 生成したい乱数の最大値 /// </param> /// <remarks> /// グローバルな乱数エンジンを使用します。 /// </remarks> /// <returns> /// 指定した型と範囲の乱数 /// </returns> template <class Type> inline Type Random(const Type& min, const Type& max) { return UniformDistribution<Type>(min, max)(GetDefaultRNG()); } /// <summary> /// 0 から、指定した範囲までの乱数を返します。 /// </summary> /// <param name="max"> /// 生成したい乱数の最大値 /// </param> /// <remarks> /// グローバルな乱数エンジンを使用します。 /// </remarks> /// <returns> /// 0 以上 max 以下の乱数 /// </returns> template <class Type> inline Type Random(const Type& max) { return Random<Type>(0, max); } /// <summary> /// 指定した型と範囲の乱数を返します。 /// </summary> /// <param name="min"> /// 生成したい乱数の最小値 /// </param> /// <param name="max"> /// 生成したい乱数の最大値 /// </param> /// <remarks> /// グローバルな乱数エンジンを使用します。 /// </remarks> /// <returns> /// 指定した型と範囲の乱数 /// </returns> template <> inline char32 Random<char32>(const char32& min, const char32& max) { return static_cast<char32>(UniformDistribution<uint32>(min, max)(GetDefaultRNG())); } /// <summary> /// 指定した型と範囲の乱数を返します。 /// </summary> /// <param name="min"> /// 生成したい乱数の最小値 /// </param> /// <param name="max"> /// 生成したい乱数の最大値 /// </param> /// <remarks> /// グローバルな乱数エンジンを使用します。 /// </remarks> /// <returns> /// 指定した型と範囲の乱数 /// </returns> template <> inline Duration Random<Duration>(const Duration& min, const Duration& max) { return Duration(Random(min.count(), max.count())); } /// <summary> /// 2 値の乱数を返します。 /// </summary> /// <param name="p"> /// true を返す確率 [0.0, 1.0] /// </param> /// <remarks> /// グローバルな乱数エンジンを使用します。 /// </remarks> /// <returns> /// 確率 p でtrue, 確率 (1-p) で false /// </returns> inline bool RandomBool(const double p = 0.5) { return GetDefaultRNG().generateReal() < p; } /// <summary> /// イテレータの範囲からランダムに値を選択します。 /// </summary> /// <param name="begin"> /// 開始位置 /// </param> /// <param name="end"> /// 終了位置 /// </param> /// <remarks> /// グローバルな乱数エンジンを使用します。 /// </remarks> /// <returns> /// イテレータの範囲からランダムに選択された値 /// </returns> template <class Iterator> inline auto RandomSelect(Iterator begin, Iterator end) { assert(begin != end); std::advance(begin, Random(std::distance(begin, end) - 1)); return *begin; } /// <summary> /// コンテナの中からランダムに値を選択します。 /// </summary> /// <param name="c"> /// コンテナ /// </param> /// <remarks> /// グローバルな乱数エンジンを使用します。 /// </remarks> /// <returns> /// コンテナの中からランダムに選択された値 /// </returns> template <class Container> inline auto RandomSelect(const Container& c) { return RandomSelect(std::begin(c), std::end(c)); } /// <summary> /// リストの中からランダムに値を選択します。 /// </summary> /// <param name="ilist"> /// 値のリスト /// </param> /// <remarks> /// グローバルな乱数エンジンを使用します。 /// </remarks> /// <returns> /// リストの中からランダムに選択された値 /// </returns> template <class Type> inline Type RandomSelect(std::initializer_list<Type> ilist) { return RandomSelect(std::begin(ilist), std::end(ilist)); } /// <summary> /// コンテナの中身をシャッフルします。 /// </summary> /// <param name="c"> /// コンテナ /// </param> /// <returns> /// なし /// </returns> template <class Container> inline void Shuffle(Container& c) { std::shuffle(c.begin(), c.end(), GetDefaultRNG()); } /// <summary> /// 指定した範囲の値をシャッフルします。 /// </summary> /// <param name="first"> /// 範囲の開始位置 /// </param> /// <param name="last"> /// 範囲の終了位置 /// </param> /// <returns> /// なし /// </returns> template <class RandomIt> inline void Shuffle(RandomIt first, RandomIt last) { std::shuffle(first, last, GetDefaultRNG()); } namespace detail { template <class Type> struct RNG_impl { const Type m_min, m_max; constexpr RNG_impl(Type min, Type max) : m_min(min) , m_max(max) {} Type operator()() const { return Random<Type>(m_min, m_max); } }; } template <class Type> inline constexpr auto RNG(const Type& max) { return detail::RNG_impl<Type>(0, max); } template <class Type> inline constexpr auto RNG(const Type& min, const Type& max) { return detail::RNG_impl<Type>(min, max); } }
19.102362
85
0.590066
cs3238-tsuzu
eddbd0b22f7f39d6f011aa22dd60f81737810f49
409
cpp
C++
mordor/tests/statistics.cpp
mtanski/mordor
cf6f0a0f31aec7188286302ceeff3018e6b65cb8
[ "BSD-3-Clause" ]
2
2015-03-19T14:20:28.000Z
2016-03-16T05:04:53.000Z
mordor/tests/statistics.cpp
mtanski/mordor
cf6f0a0f31aec7188286302ceeff3018e6b65cb8
[ "BSD-3-Clause" ]
1
2017-09-09T15:28:11.000Z
2017-09-09T15:28:11.000Z
mordor/tests/statistics.cpp
mtanski/mordor
cf6f0a0f31aec7188286302ceeff3018e6b65cb8
[ "BSD-3-Clause" ]
3
2015-06-02T19:33:39.000Z
2020-09-08T21:45:11.000Z
#include "../statistics.h" #include "../test/test.h" using namespace Mordor; MORDOR_UNITTEST(Statistics, dumpStat) { SumStatistic<int> sumStat("s"); sumStat.add(5); std::ostringstream os; sumStat.dump(os); std::ostringstream expectedOS; expectedOS << typeid(sumStat).name() << ": " << sumStat << " s" << std::endl; MORDOR_TEST_ASSERT_EQUAL(os.str(), expectedOS.str()); }
24.058824
57
0.640587
mtanski
ede4d92a23ef54a2c01fadcae45c92b2e1f04f4f
124,794
cpp
C++
img_molecule_limonene.cpp
emvivre/Chirality-game
b538bec3f6cf7aa5b39d28125f63c207273af22b
[ "WTFPL" ]
null
null
null
img_molecule_limonene.cpp
emvivre/Chirality-game
b538bec3f6cf7aa5b39d28125f63c207273af22b
[ "WTFPL" ]
null
null
null
img_molecule_limonene.cpp
emvivre/Chirality-game
b538bec3f6cf7aa5b39d28125f63c207273af22b
[ "WTFPL" ]
null
null
null
/** * Copyright: (c) 2014 François Lozes <emvivre@urdn.com.ua> * This program is free software; you can redistribute it and/or * modify it under the terms of the Do What The Fuck You Want To * Public License, Version 2, as published by Sam Hocevar. See * http://www.wtfpl.net/ for more details. */ #include "img_molecule_limonene.h" const unsigned char img_molecule_limonene[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x4c, 0x79, 0x8c, 0x1e, 0x4c, 0x7a, 0xea, 0x19, 0x4c, 0x77, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1d, 0x4b, 0x7a, 0xa2, 0x1e, 0x4b, 0x7a, 0xca, 0x20, 0x40, 0x60, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x66, 0x04, 0x1e, 0x4c, 0x7a, 0xb7, 0x1d, 0x4b, 0x79, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x13, 0x4e, 0x76, 0x0c, 0x1e, 0x4b, 0x79, 0x9f, 0x1d, 0x4c, 0x79, 0xf1, 0x1d, 0x4c, 0x7a, 0xe7, 0x1d, 0x4b, 0x79, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x43, 0x79, 0x12, 0x1d, 0x4c, 0x79, 0xa4, 0x1d, 0x4b, 0x79, 0xef, 0x1e, 0x4b, 0x7a, 0xec, 0x1e, 0x4c, 0x7a, 0x85, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x49, 0x6d, 0x06, 0x1d, 0x4a, 0x79, 0x77, 0x1d, 0x4b, 0x7a, 0xd0, 0x1e, 0x4b, 0x7a, 0xf6, 0x1e, 0x4b, 0x7a, 0xf6, 0x1d, 0x4b, 0x7a, 0xd0, 0x1e, 0x4b, 0x79, 0x75, 0x2a, 0x2a, 0x55, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x17, 0x45, 0x74, 0x0a, 0x1d, 0x4c, 0x79, 0x9d, 0x1d, 0x4c, 0x79, 0xf1, 0x1e, 0x4b, 0x7a, 0xec, 0x1d, 0x4c, 0x79, 0x88, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4a, 0x79, 0x5c, 0x1e, 0x4b, 0x7a, 0xc0, 0x1d, 0x4c, 0x7a, 0xf0, 0x1d, 0x4b, 0x79, 0xf9, 0x1e, 0x4c, 0x79, 0xdc, 0x1d, 0x4b, 0x79, 0x8a, 0x20, 0x40, 0x70, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x17, 0x45, 0x74, 0x0a, 0x1d, 0x4c, 0x79, 0x9d, 0x1d, 0x4c, 0x79, 0xf1, 0x1e, 0x4b, 0x7a, 0xec, 0x1d, 0x4c, 0x79, 0x88, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4a, 0x79, 0x5c, 0x1e, 0x4b, 0x7a, 0xc0, 0x1d, 0x4c, 0x7a, 0xf0, 0x1d, 0x4b, 0x79, 0xf9, 0x1e, 0x4c, 0x79, 0xdc, 0x1d, 0x4b, 0x79, 0x8a, 0x20, 0x40, 0x70, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4c, 0x79, 0xae, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4a, 0x77, 0x4e, 0x1e, 0x4c, 0x79, 0xc9, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4c, 0x77, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x40, 0x60, 0x07, 0x1e, 0x4c, 0x79, 0xc1, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4c, 0x79, 0xbe, 0x2a, 0x2a, 0x55, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4b, 0x7a, 0xab, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4b, 0x7a, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1d, 0x4b, 0x79, 0xa5, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4b, 0x79, 0xd4, 0x22, 0x44, 0x77, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4b, 0x7a, 0xab, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4b, 0x7a, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1d, 0x4b, 0x79, 0xa5, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4b, 0x79, 0xd4, 0x22, 0x44, 0x77, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4c, 0x79, 0xcf, 0x1b, 0x4c, 0x77, 0x2e, 0x22, 0x44, 0x77, 0x0e, 0x1e, 0x4b, 0x79, 0x95, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4c, 0x7a, 0xf0, 0x1d, 0x4c, 0x79, 0xcf, 0x1b, 0x4c, 0x77, 0x2e, 0x22, 0x44, 0x77, 0x0e, 0x1e, 0x4b, 0x79, 0x95, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4b, 0x7a, 0xc4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x4a, 0x79, 0x77, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4b, 0x79, 0xef, 0x1c, 0x4b, 0x78, 0x61, 0x17, 0x45, 0x74, 0x15, 0x17, 0x45, 0x74, 0x15, 0x1f, 0x4a, 0x79, 0x62, 0x1d, 0x4c, 0x79, 0xf1, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4b, 0x79, 0x75, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4b, 0x79, 0xcd, 0x1c, 0x49, 0x77, 0x2c, 0x20, 0x40, 0x70, 0x0f, 0x1d, 0x4c, 0x79, 0x99, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x79, 0xcb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x79, 0x64, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xe3, 0x1d, 0x4a, 0x7a, 0x55, 0x18, 0x49, 0x79, 0x14, 0x19, 0x4c, 0x66, 0x09, 0x1e, 0x4b, 0x77, 0x39, 0x1e, 0x4b, 0x7a, 0xca, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4c, 0x79, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4b, 0x79, 0xcd, 0x1c, 0x49, 0x77, 0x2c, 0x20, 0x40, 0x70, 0x0f, 0x1d, 0x4c, 0x79, 0x99, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x79, 0xcb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x79, 0x64, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xe3, 0x1d, 0x4a, 0x7a, 0x55, 0x18, 0x49, 0x79, 0x14, 0x19, 0x4c, 0x66, 0x09, 0x1e, 0x4b, 0x77, 0x39, 0x1e, 0x4b, 0x7a, 0xca, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4c, 0x79, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1f, 0x4c, 0x79, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x44, 0x76, 0x19, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1f, 0x4c, 0x79, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x44, 0x76, 0x19, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4b, 0x79, 0xe9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4b, 0x79, 0xd1, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4c, 0x79, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x78, 0x63, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4c, 0x79, 0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1b, 0x49, 0x76, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x4b, 0x71, 0x1a, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xf4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xc8, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4b, 0x79, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x49, 0x75, 0x22, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4b, 0x79, 0xda, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1b, 0x49, 0x76, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x4b, 0x71, 0x1a, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xf4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xc8, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4b, 0x79, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x49, 0x75, 0x22, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4b, 0x79, 0xda, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x20, 0x40, 0x60, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x20, 0x40, 0x60, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x4c, 0x79, 0xf7, 0x1e, 0x4c, 0x7a, 0xff, 0x18, 0x49, 0x79, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x45, 0x74, 0x15, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4b, 0x7a, 0xf6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x20, 0x40, 0x60, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4b, 0x79, 0xf5, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4c, 0x7a, 0xfa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x20, 0x40, 0x60, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4b, 0x79, 0xf5, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4c, 0x7a, 0xfa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x4c, 0x79, 0xf7, 0x1e, 0x4c, 0x7a, 0xff, 0x18, 0x49, 0x79, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x45, 0x74, 0x15, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4b, 0x7a, 0xf6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4b, 0x7a, 0xf6, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4b, 0x7a, 0xf6, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4b, 0x79, 0xd1, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4b, 0x79, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x4b, 0x78, 0x61, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4c, 0x79, 0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x79, 0xcb, 0x1e, 0x4c, 0x7a, 0xff, 0x1c, 0x4b, 0x76, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x79, 0xcb, 0x1e, 0x4c, 0x7a, 0xff, 0x1c, 0x4b, 0x76, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x4a, 0x79, 0x77, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4c, 0x7a, 0xee, 0x1d, 0x4b, 0x79, 0x5e, 0x18, 0x49, 0x79, 0x14, 0x18, 0x49, 0x79, 0x14, 0x1d, 0x4c, 0x79, 0x60, 0x1d, 0x4b, 0x79, 0xef, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4b, 0x79, 0x75, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x4b, 0x78, 0x61, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4c, 0x7a, 0xe7, 0x1e, 0x4c, 0x79, 0x64, 0x1f, 0x4d, 0x74, 0x20, 0x19, 0x4c, 0x66, 0x09, 0x20, 0x40, 0x60, 0x07, 0x1a, 0x48, 0x76, 0x26, 0x1e, 0x4b, 0x78, 0x65, 0x1d, 0x4b, 0x7a, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x4b, 0x78, 0x61, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4c, 0x7a, 0xe7, 0x1e, 0x4c, 0x79, 0x64, 0x1f, 0x4d, 0x74, 0x20, 0x19, 0x4c, 0x66, 0x09, 0x20, 0x40, 0x60, 0x07, 0x1a, 0x48, 0x76, 0x26, 0x1e, 0x4b, 0x78, 0x65, 0x1d, 0x4b, 0x7a, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x40, 0x60, 0x07, 0x1e, 0x4c, 0x7a, 0xc2, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1d, 0x4c, 0x79, 0xbf, 0x24, 0x49, 0x6d, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x4c, 0x79, 0x92, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x4c, 0x79, 0x92, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x40, 0x60, 0x07, 0x1d, 0x4a, 0x79, 0x77, 0x1e, 0x4b, 0x79, 0xd1, 0x1d, 0x4c, 0x79, 0xf7, 0x1e, 0x4b, 0x7a, 0xf6, 0x1e, 0x4b, 0x79, 0xd1, 0x1e, 0x4b, 0x78, 0x76, 0x24, 0x49, 0x6d, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4b, 0x78, 0x43, 0x1d, 0x4b, 0x7a, 0xab, 0x1e, 0x4c, 0x79, 0xe4, 0x1d, 0x4c, 0x7a, 0xfa, 0x1e, 0x4b, 0x7a, 0xf6, 0x1e, 0x4b, 0x79, 0xd4, 0x1e, 0x4b, 0x78, 0x8d, 0x20, 0x4a, 0x75, 0x2f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4c, 0x7a, 0xff, 0x1e, 0x4c, 0x7a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x4b, 0x78, 0x43, 0x1d, 0x4b, 0x7a, 0xab, 0x1e, 0x4c, 0x79, 0xe4, 0x1d, 0x4c, 0x7a, 0xfa, 0x1e, 0x4b, 0x7a, 0xf6, 0x1e, 0x4b, 0x79, 0xd4, 0x1e, 0x4b, 0x78, 0x8d, 0x20, 0x4a, 0x75, 0x2f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; const unsigned int img_molecule_limonene_width = 284; const unsigned int img_molecule_limonene_height = 18;
371.410714
388
0.658429
emvivre
ede6fa8c309ba99f9686cae131de3ee4d96685c2
64
hpp
C++
src/boost_spirit_home_karma_directive_strict_relaxed.hpp
miathedev/BoostForArduino
919621dcd0c157094bed4df752b583ba6ea6409e
[ "BSL-1.0" ]
10
2018-03-17T00:58:42.000Z
2021-07-06T02:48:49.000Z
src/boost_spirit_home_karma_directive_strict_relaxed.hpp
miathedev/BoostForArduino
919621dcd0c157094bed4df752b583ba6ea6409e
[ "BSL-1.0" ]
2
2021-03-26T15:17:35.000Z
2021-05-20T23:55:08.000Z
src/boost_spirit_home_karma_directive_strict_relaxed.hpp
miathedev/BoostForArduino
919621dcd0c157094bed4df752b583ba6ea6409e
[ "BSL-1.0" ]
4
2019-05-28T21:06:37.000Z
2021-07-06T03:06:52.000Z
#include <boost/spirit/home/karma/directive/strict_relaxed.hpp>
32
63
0.828125
miathedev
edecb85140a0464e8f20644644ec3a45c40539e8
547
cpp
C++
C++_Practice/21_Judgement.cpp
TuringGu/RELearning
a44813d6ae0416631bf5b345a7606cdf3d1a3ffe
[ "MIT" ]
null
null
null
C++_Practice/21_Judgement.cpp
TuringGu/RELearning
a44813d6ae0416631bf5b345a7606cdf3d1a3ffe
[ "MIT" ]
null
null
null
C++_Practice/21_Judgement.cpp
TuringGu/RELearning
a44813d6ae0416631bf5b345a7606cdf3d1a3ffe
[ "MIT" ]
null
null
null
#include <iostream> int main() { int flag{ 0 }; //if else int a = 10, b = 20; int c = a > b ? 10 : 20; // switch std::cout << "enter a number: " << std::endl; std::cin >> flag; switch (flag) { case 1: std::cout << "you entered " << "one" << std::endl; break; case 2: std::cout << "you entered " << "two" << std::endl; break; case 3: std::cout << "you entered " << "three" << std::endl; break; default: std::cout << "you did not enter 1,2,3 " << std::endl; break; } std::cout << "End" << std::endl; return 0; }
16.575758
55
0.52468
TuringGu
edeec01836e0189d3f82c8a0f9967e05fd700abb
1,681
cpp
C++
plugins/scripting/python3/src/Python3/python3streamredirect.cpp
MadManRises/Madgine
c9949bc9cf8b30d63db0da2382c9fbc5b60bcd0f
[ "MIT" ]
5
2018-05-16T14:09:34.000Z
2019-10-24T19:01:15.000Z
plugins/scripting/python3/src/Python3/python3streamredirect.cpp
MadManRises/Madgine
c9949bc9cf8b30d63db0da2382c9fbc5b60bcd0f
[ "MIT" ]
71
2017-06-20T06:41:42.000Z
2021-01-11T11:18:53.000Z
plugins/scripting/python3/src/Python3/python3streamredirect.cpp
MadManRises/Madgine
c9949bc9cf8b30d63db0da2382c9fbc5b60bcd0f
[ "MIT" ]
2
2018-05-16T13:57:25.000Z
2018-05-16T13:57:51.000Z
#include "python3lib.h" #include "python3streamredirect.h" #include "Meta/keyvalue/metatable_impl.h" #include "util/pyobjectutil.h" METATABLE_BEGIN(Engine::Scripting::Python3::Python3StreamRedirect) FUNCTION(write, text) METATABLE_END(Engine::Scripting::Python3::Python3StreamRedirect) namespace Engine { namespace Scripting { namespace Python3 { Python3StreamRedirect::Python3StreamRedirect(std::streambuf *buf) : mBuf(buf) { } Python3StreamRedirect::~Python3StreamRedirect() { while (!mOldStreams.empty()) { reset(mOldStreams.begin()->first); } } void Python3StreamRedirect::redirect(std::string_view name) { if (!mOldStreams[name]) { mOldStreams[name] = PySys_GetObject(name.data()); // borrowed } PySys_SetObject(name.data(), Scripting::Python3::toPyObject(TypedScopePtr { this })); } void Python3StreamRedirect::reset(std::string_view name) { auto it = mOldStreams.find(name); if (it != mOldStreams.end()) { Py_DECREF(PySys_GetObject(name.data())); PySys_SetObject(name.data(), it->second); mOldStreams.erase(it); } } int Python3StreamRedirect::write(std::string_view text) { return mBuf->sputn(text.data(), text.size()); } void Python3StreamRedirect::setBuf(std::streambuf *buf) { mBuf = buf; } std::streambuf* Python3StreamRedirect::buf() const { return mBuf; } } } }
25.861538
97
0.578227
MadManRises
edf05447693d3900c46d11cadb3724b075ae4dbb
1,721
cpp
C++
Qt5Practice/Qt5_test06DifPaint/mainwindow.cpp
whuer-xiaojie/Qt_Test
5d3477f4f59c1c084a448a8a12bf536af5cad274
[ "Apache-2.0" ]
null
null
null
Qt5Practice/Qt5_test06DifPaint/mainwindow.cpp
whuer-xiaojie/Qt_Test
5d3477f4f59c1c084a448a8a12bf536af5cad274
[ "Apache-2.0" ]
null
null
null
Qt5Practice/Qt5_test06DifPaint/mainwindow.cpp
whuer-xiaojie/Qt_Test
5d3477f4f59c1c084a448a8a12bf536af5cad274
[ "Apache-2.0" ]
null
null
null
#include "mainwindow.h" #include "ui_mainwindow.h" #include<QPixmap> #include<QPainter> #include<QPicture> #include<QImage> #include<QDebug> #include<QPaintEvent> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); //QPixmap 绘图 QPixmap pixmap(300,400);//定义一个大小为300*400的pixmap画图设备 pixmap.fill(Qt::white);//背景填充为白色 QPainter P(&pixmap); P.drawPixmap(0,0,width(),height(),QPixmap("../backImage/home")); //P.drawPixmap(0,0,200,300,QPixmap("../backImage/home")); pixmap.save("../Pixmap.png"); //QImage绘图 QImage image(400,300,QImage::Format_ARGB32); QPainter P1(&image); P1.drawImage(0,0,QImage("../backImage/image2")); for(int i=50;i<100;i++)//对绘出来的图进行修改 { for(int j =0;j<50;j++) { image.setPixel(QPoint(i,j),qRgb(0,125,165)); } image.save("../image.png"); } //QPicture绘图 QPicture picture; QPainter P3; P3.begin(&picture); P3.drawPixmap(0,0,200,200,QPixmap("../backImage/image3.jpg")); P3.end(); qDebug()<<"11111111"; picture.save("../picture.png");//保存下来的图片为二进制格式 } MainWindow::~MainWindow() { delete ui; } void MainWindow::paintEvent(QPaintEvent *event)//打开保存下来的图片(QPicture) { //主窗口绘制Picture类型绘制的图 QPicture pic; pic.load("../picture.png"); QPainter P1(this); P1.drawPicture(0,0,pic); //QPixmap类型转换为QImage并在主窗口显示出来 //QPixmap tempImage1; QImage tempImagel; tempImagel.load("../Pixmap.png"); QPixmap tempPixmap1=QPixmap::fromImage(tempImagel); QPainter PtempPixmap(this); PtempPixmap.drawPixmap(0,240,200,200,tempPixmap1); }
25.308824
71
0.627542
whuer-xiaojie
edf300b27119caf77bde5338d5b712ae1f5c9540
3,479
cpp
C++
AppleOpenSource/WebKit2-7609.3.5.1.3/WebProcess/WebPage/WebContextMenu.cpp
lzackx/Zone
bf8a3d2b965c383a691a6e7b61d23db15ce11dba
[ "MIT" ]
null
null
null
AppleOpenSource/WebKit2-7609.3.5.1.3/WebProcess/WebPage/WebContextMenu.cpp
lzackx/Zone
bf8a3d2b965c383a691a6e7b61d23db15ce11dba
[ "MIT" ]
null
null
null
AppleOpenSource/WebKit2-7609.3.5.1.3/WebProcess/WebPage/WebContextMenu.cpp
lzackx/Zone
bf8a3d2b965c383a691a6e7b61d23db15ce11dba
[ "MIT" ]
null
null
null
/* * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). * Copyright (C) 2010 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * */ #include "config.h" #if ENABLE(CONTEXT_MENUS) #include "WebContextMenu.h" #include "ContextMenuContextData.h" #include "UserData.h" #include "WebCoreArgumentCoders.h" #include "WebPage.h" #include "WebPageProxyMessages.h" #include "WebProcess.h" #include <WebCore/ContextMenu.h> #include <WebCore/ContextMenuController.h> #include <WebCore/Frame.h> #include <WebCore/FrameView.h> #include <WebCore/Page.h> namespace WebKit { using namespace WebCore; WebContextMenu::WebContextMenu(WebPage* page) : m_page(page) { } WebContextMenu::~WebContextMenu() { } void WebContextMenu::show() { ContextMenuController& controller = m_page->corePage()->contextMenuController(); Frame* frame = controller.hitTestResult().innerNodeFrame(); if (!frame) return; FrameView* view = frame->view(); if (!view) return; Vector<WebContextMenuItemData> menuItems; RefPtr<API::Object> userData; menuItemsWithUserData(menuItems, userData); auto menuLocation = view->contentsToRootView(controller.hitTestResult().roundedPointInInnerNodeFrame()); ContextMenuContextData contextMenuContextData(menuLocation, menuItems, controller.context()); // Mark the WebPage has having a shown context menu then notify the UIProcess. m_page->contextMenuShowing(); m_page->send(Messages::WebPageProxy::ShowContextMenu(contextMenuContextData, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); } void WebContextMenu::itemSelected(const WebContextMenuItemData& item) { m_page->corePage()->contextMenuController().contextMenuItemSelected(static_cast<ContextMenuAction>(item.action()), item.title()); } void WebContextMenu::menuItemsWithUserData(Vector<WebContextMenuItemData> &menuItems, RefPtr<API::Object>& userData) const { ContextMenuController& controller = m_page->corePage()->contextMenuController(); ContextMenu* menu = controller.contextMenu(); if (!menu) return; // Give the bundle client a chance to process the menu. const Vector<ContextMenuItem>& coreItems = menu->items(); if (m_page->injectedBundleContextMenuClient().getCustomMenuFromDefaultItems(*m_page, controller.hitTestResult(), coreItems, menuItems, userData)) return; menuItems = kitItems(coreItems); } Vector<WebContextMenuItemData> WebContextMenu::items() const { Vector<WebContextMenuItemData> menuItems; RefPtr<API::Object> userData; menuItemsWithUserData(menuItems, userData); return menuItems; } } // namespace WebKit #endif // ENABLE(CONTEXT_MENUS)
32.514019
165
0.748491
lzackx
edf39f22544469d4aa6bdb83a78ce0302183f0fd
16,365
cpp
C++
src/tga_vulkan/WSI_glfw/tga_vulkan_wsi.cpp
Estard/TGA
511f79b61966d12ab652ef80e14a62ad7ab8b40c
[ "MIT" ]
4
2020-11-04T10:49:01.000Z
2021-07-29T10:24:46.000Z
src/tga_vulkan/WSI_glfw/tga_vulkan_wsi.cpp
Estard/TGA
511f79b61966d12ab652ef80e14a62ad7ab8b40c
[ "MIT" ]
null
null
null
src/tga_vulkan/WSI_glfw/tga_vulkan_wsi.cpp
Estard/TGA
511f79b61966d12ab652ef80e14a62ad7ab8b40c
[ "MIT" ]
2
2020-04-17T11:26:07.000Z
2021-06-03T13:59:18.000Z
#include "tga/tga_vulkan/tga_vulkan_WSI.hpp" #include <iostream> #include "GLFW/glfw3.h" namespace tga { VulkanWSI::VulkanWSI() { glfwInit(); } VulkanWSI::~VulkanWSI() { glfwTerminate(); } void VulkanWSI::setVulkanHandles(vk::Instance _instance, vk::PhysicalDevice _pDevice, vk::Device _device, vk::Queue _presentQueue, uint32_t _queueFamiliy) { instance = _instance; pDevice = _pDevice; device = _device; presentQueue = _presentQueue; queueFamiliy = _queueFamiliy; } std::vector<const char *> VulkanWSI::getRequiredExtensions() { uint32_t glfwExtensionCount = 0; const char **glfwExtensions; glfwExtensions = glfwGetRequiredInstanceExtensions(&glfwExtensionCount); std::vector<const char *> extensions; for (uint32_t i = 0; i < glfwExtensionCount; i++) extensions.push_back(glfwExtensions[i]); return extensions; } std::pair<uint32_t, uint32_t> VulkanWSI::screenResolution() { const GLFWvidmode *mode = glfwGetVideoMode(glfwGetPrimaryMonitor()); return {static_cast<uint32_t>(mode->width), static_cast<uint32_t>(mode->height)}; } Window VulkanWSI::createWindow(const WindowInfo &windowInfo) { glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); int width = int(windowInfo.width); int height = int(windowInfo.height); if (!width || !height) { const GLFWvidmode *mode = glfwGetVideoMode(glfwGetPrimaryMonitor()); width = mode->width; height = mode->height; } GLFWwindow *glfwWindow = glfwCreateWindow(width, height, "TGA VULKAN", nullptr, nullptr); VkSurfaceKHR vkSurface; if (glfwCreateWindowSurface(instance, glfwWindow, nullptr, &vkSurface) != VK_SUCCESS) { throw std::runtime_error("failed to create window surface!"); } vk::SurfaceKHR surface{vkSurface}; if (!pDevice.getSurfaceSupportKHR(queueFamiliy, surface)) { instance.destroy(surface); throw std::runtime_error("Cannot use graphics Queue to present to Window"); } auto surfaceFormat = chooseSurfaceFormat(surface); auto presentMode = choosePresentMode(surface, windowInfo.presentMode); auto extent = chooseSwapExtent(surface, windowInfo); auto capabilities = pDevice.getSurfaceCapabilitiesKHR(surface); uint32_t imageCount = std::max(windowInfo.framebufferCount, capabilities.minImageCount); if (capabilities.maxImageCount) imageCount = std::min(imageCount, capabilities.maxImageCount); auto swapchain = device.createSwapchainKHR({{}, surface, imageCount, surfaceFormat.format, surfaceFormat.colorSpace, extent, 1, vk::ImageUsageFlagBits::eColorAttachment, vk::SharingMode::eExclusive, 1, &queueFamiliy, capabilities.currentTransform, vk::CompositeAlphaFlagBitsKHR::eOpaque, presentMode, VK_TRUE}); std::vector<vk::Image> images = device.getSwapchainImagesKHR(swapchain); std::vector<vk::ImageView> imageViews{}; std::vector<vk::Fence> fences{}; std::vector<vk::Semaphore> availabilitySemas{}; std::vector<vk::Semaphore> renderSemas{}; for (auto image : images) { imageViews.emplace_back(device.createImageView({{}, image, vk::ImageViewType::e2D, surfaceFormat.format, {}, {vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1}})); // fences.emplace_back(device.createFence({{vk::FenceCreateFlagBits::eSignaled}})); // availabilitySemas.emplace_back(device.createSemaphore({})); // renderSemas.emplace_back(device.createSemaphore({})); } Window_TV window_tv{surface, swapchain, extent, surfaceFormat.format, images, imageViews, glfwWindow, device.createFence({vk::FenceCreateFlagBits::eSignaled}), device.createSemaphore({}), device.createSemaphore({}), 0}; Window window = Window(TgaWindow(glfwWindow)); windows.emplace(window, window_tv); return window; } void VulkanWSI::free(Window window) { auto &handle = windows[window]; for (auto &imageView : handle.imageViews) device.destroy(imageView); device.destroy(handle.swapchain); instance.destroy(handle.surface); // for(auto &fence : handle.inFlightFences) device.destroy(handle.inFlightFence); // for(auto &sema: handle.imageAvailableSemaphores) device.destroy(handle.imageAvailableSemaphore); // for(auto &sema: handle.renderFinishedSemaphores) device.destroy(handle.renderFinishedSemaphore); glfwDestroyWindow(std::any_cast<GLFWwindow *>(handle.nativeHandle)); windows.erase(window); } void VulkanWSI::setWindowTitle(Window window, const char *title) { auto &handle = getWindow(window); glfwSetWindowTitle(std::any_cast<GLFWwindow *>(handle.nativeHandle), title); } Window_TV &VulkanWSI::getWindow(Window window) { return windows[window]; } uint32_t VulkanWSI::aquireNextImage(Window window) { glfwPollEvents(); auto &handle = windows[window]; auto nextFrame = device.acquireNextImageKHR(handle.swapchain, std::numeric_limits<uint32_t>::max(), handle.imageAvailableSemaphore, vk::Fence()); handle.currentFrameIndex = nextFrame.value; return handle.currentFrameIndex; } void VulkanWSI::pollEvents(Window window) { glfwPollEvents(); (void)window; // Silence compiler warning } void VulkanWSI::presentImage(Window window) { auto &handle = windows[window]; auto res = presentQueue.presentKHR( {1, &handle.renderFinishedSemaphore, 1, &handle.swapchain, &handle.currentFrameIndex}); if (res != vk::Result::eSuccess) std::cerr << "[TGA Vulkan] Warning: Window Surface has become suboptimal\n"; } bool VulkanWSI::windowShouldClose(Window window) { auto &handle = windows[window]; return glfwWindowShouldClose(std::any_cast<GLFWwindow *>(handle.nativeHandle)); } int toGlfwKey(Key key); bool VulkanWSI::keyDown(Window window, Key key) { auto &handle = windows[window]; GLFWwindow *glfwWin = std::any_cast<GLFWwindow *>(handle.nativeHandle); if (key == Key::MouseLeft) return glfwGetMouseButton(glfwWin, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS; if (key == Key::MouseMiddle) return glfwGetMouseButton(glfwWin, GLFW_MOUSE_BUTTON_MIDDLE) == GLFW_PRESS; if (key == Key::MouseRight) return glfwGetMouseButton(glfwWin, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS; auto glfwKey = toGlfwKey(key); return glfwGetKey(glfwWin, glfwKey) == GLFW_PRESS; } std::pair<int, int> VulkanWSI::mousePosition(Window window) { auto &handle = windows[window]; GLFWwindow *glfwWin = std::any_cast<GLFWwindow *>(handle.nativeHandle); double xpos = 0; double ypos = 0; glfwGetCursorPos(glfwWin, &xpos, &ypos); return {int(xpos), int(ypos)}; } vk::SurfaceFormatKHR VulkanWSI::chooseSurfaceFormat(vk::SurfaceKHR surface) { auto formats = pDevice.getSurfaceFormatsKHR(surface); for (const auto &format : formats) { if (format.format == vk::Format::eB8G8R8A8Srgb && format.colorSpace == vk::ColorSpaceKHR::eSrgbNonlinear) return format; } return formats[0]; } vk::PresentModeKHR VulkanWSI::choosePresentMode(vk::SurfaceKHR surface, PresentMode wantedPresentMode) { auto presentModes = pDevice.getSurfacePresentModesKHR(surface); auto presentMode = vk::PresentModeKHR::eFifo; // Always available if (wantedPresentMode == PresentMode::immediate) { for (const auto &mode : presentModes) { if (mode == vk::PresentModeKHR::eMailbox) { return mode; // Prefer Mailbox over Immediate } else if (mode == vk::PresentModeKHR::eImmediate) { presentMode = mode; } } } return presentMode; } vk::Extent2D VulkanWSI::chooseSwapExtent(vk::SurfaceKHR surface, const WindowInfo &windowInfo) { auto capabilities = pDevice.getSurfaceCapabilitiesKHR(surface); if (capabilities.currentExtent.width != std::numeric_limits<uint32_t>::max()) return capabilities.currentExtent; return {std::clamp(windowInfo.width, capabilities.minImageExtent.width, capabilities.maxImageExtent.width), std::clamp(windowInfo.height, capabilities.minImageExtent.height, capabilities.maxImageExtent.height)}; } int toGlfwKey(Key key) { switch (key) { case Key::Space: return GLFW_KEY_SPACE; case Key::Apostrophe: return GLFW_KEY_APOSTROPHE; case Key::Comma: return GLFW_KEY_COMMA; case Key::Minus: return GLFW_KEY_MINUS; case Key::Period: return GLFW_KEY_PERIOD; case Key::Slash: return GLFW_KEY_SLASH; case Key::n0: return GLFW_KEY_0; case Key::n1: return GLFW_KEY_1; case Key::n2: return GLFW_KEY_2; case Key::n3: return GLFW_KEY_3; case Key::n4: return GLFW_KEY_4; case Key::n5: return GLFW_KEY_5; case Key::n6: return GLFW_KEY_6; case Key::n7: return GLFW_KEY_7; case Key::n8: return GLFW_KEY_8; case Key::n9: return GLFW_KEY_9; case Key::Semicolon: return GLFW_KEY_SEMICOLON; case Key::Equal: return GLFW_KEY_EQUAL; case Key::A: return GLFW_KEY_A; case Key::B: return GLFW_KEY_B; case Key::C: return GLFW_KEY_C; case Key::D: return GLFW_KEY_D; case Key::E: return GLFW_KEY_E; case Key::F: return GLFW_KEY_F; case Key::G: return GLFW_KEY_G; case Key::H: return GLFW_KEY_H; case Key::I: return GLFW_KEY_I; case Key::J: return GLFW_KEY_J; case Key::K: return GLFW_KEY_K; case Key::L: return GLFW_KEY_L; case Key::M: return GLFW_KEY_M; case Key::N: return GLFW_KEY_N; case Key::O: return GLFW_KEY_O; case Key::P: return GLFW_KEY_P; case Key::Q: return GLFW_KEY_Q; case Key::R: return GLFW_KEY_R; case Key::S: return GLFW_KEY_S; case Key::T: return GLFW_KEY_T; case Key::U: return GLFW_KEY_U; case Key::V: return GLFW_KEY_V; case Key::W: return GLFW_KEY_W; case Key::X: return GLFW_KEY_X; case Key::Y: return GLFW_KEY_Y; case Key::Z: return GLFW_KEY_Z; case Key::Bracket_Left: return GLFW_KEY_LEFT_BRACKET; case Key::Backslash: return GLFW_KEY_BACKSLASH; case Key::Bracket_Right: return GLFW_KEY_RIGHT_BRACKET; case Key::Grave_Accent: return GLFW_KEY_GRAVE_ACCENT; case Key::World_1: return GLFW_KEY_WORLD_1; case Key::World_2: return GLFW_KEY_WORLD_2; case Key::Escape: return GLFW_KEY_ESCAPE; case Key::Enter: return GLFW_KEY_ENTER; case Key::Tab: return GLFW_KEY_TAB; case Key::Backspace: return GLFW_KEY_BACKSPACE; case Key::Insert: return GLFW_KEY_INSERT; case Key::Delete: return GLFW_KEY_DELETE; case Key::Right: return GLFW_KEY_RIGHT; case Key::Left: return GLFW_KEY_LEFT; case Key::Down: return GLFW_KEY_DOWN; case Key::Up: return GLFW_KEY_UP; case Key::Page_Up: return GLFW_KEY_PAGE_UP; case Key::Page_Down: return GLFW_KEY_PAGE_DOWN; case Key::Home: return GLFW_KEY_HOME; case Key::End: return GLFW_KEY_END; case Key::Caps_Lock: return GLFW_KEY_CAPS_LOCK; case Key::Scroll_Lock: return GLFW_KEY_SCROLL_LOCK; case Key::Num_Lock: return GLFW_KEY_NUM_LOCK; case Key::Print_Screen: return GLFW_KEY_PRINT_SCREEN; case Key::Pause: return GLFW_KEY_PAUSE; case Key::F1: return GLFW_KEY_F1; case Key::F2: return GLFW_KEY_F2; case Key::F3: return GLFW_KEY_F3; case Key::F4: return GLFW_KEY_F4; case Key::F5: return GLFW_KEY_F5; case Key::F6: return GLFW_KEY_F6; case Key::F7: return GLFW_KEY_F7; case Key::F8: return GLFW_KEY_F8; case Key::F9: return GLFW_KEY_F9; case Key::F10: return GLFW_KEY_F10; case Key::F11: return GLFW_KEY_F11; case Key::F12: return GLFW_KEY_F12; case Key::F13: return GLFW_KEY_F13; case Key::F14: return GLFW_KEY_F14; case Key::F15: return GLFW_KEY_F15; case Key::F16: return GLFW_KEY_F16; case Key::F17: return GLFW_KEY_F17; case Key::F18: return GLFW_KEY_F18; case Key::F19: return GLFW_KEY_F19; case Key::F20: return GLFW_KEY_F20; case Key::F21: return GLFW_KEY_F21; case Key::F22: return GLFW_KEY_F22; case Key::F23: return GLFW_KEY_F23; case Key::F24: return GLFW_KEY_F24; case Key::F25: return GLFW_KEY_F25; case Key::KP_0: return GLFW_KEY_KP_0; case Key::KP_1: return GLFW_KEY_KP_1; case Key::KP_2: return GLFW_KEY_KP_2; case Key::KP_3: return GLFW_KEY_KP_3; case Key::KP_4: return GLFW_KEY_KP_4; case Key::KP_5: return GLFW_KEY_KP_5; case Key::KP_6: return GLFW_KEY_KP_6; case Key::KP_7: return GLFW_KEY_KP_7; case Key::KP_8: return GLFW_KEY_KP_8; case Key::KP_9: return GLFW_KEY_KP_9; case Key::KP_Decimal: return GLFW_KEY_KP_DECIMAL; case Key::KP_Divide: return GLFW_KEY_KP_DIVIDE; case Key::KP_Multiply: return GLFW_KEY_KP_MULTIPLY; case Key::KP_Subtract: return GLFW_KEY_KP_SUBTRACT; case Key::KP_Add: return GLFW_KEY_KP_ADD; case Key::KP_Enter: return GLFW_KEY_KP_ENTER; case Key::KP_Equal: return GLFW_KEY_KP_EQUAL; case Key::Shift_Left: return GLFW_KEY_LEFT_SHIFT; case Key::Control_Left: return GLFW_KEY_LEFT_CONTROL; case Key::Alt_Left: return GLFW_KEY_LEFT_ALT; case Key::Super_Left: return GLFW_KEY_LEFT_SUPER; case Key::Shift_Right: return GLFW_KEY_RIGHT_SHIFT; case Key::Control_Right: return GLFW_KEY_RIGHT_CONTROL; case Key::Alt_Right: return GLFW_KEY_RIGHT_ALT; case Key::Super_Right: return GLFW_KEY_RIGHT_SUPER; case Key::Menu: return GLFW_KEY_MENU; default: return GLFW_KEY_UNKNOWN; } } } // namespace tga
46.491477
120
0.586923
Estard
edf4b0b92c379e04b91233be7de3e64e41a4be8e
5,235
hpp
C++
src/detail/chainable_setter.hpp
2bbb/ofxChainableSetting
cbec4deb4d8653a9cb6fe3db1541967395799c64
[ "MIT" ]
2
2017-04-30T19:07:54.000Z
2019-11-26T09:53:04.000Z
src/detail/chainable_setter.hpp
2bbb/ofxChainableSetting
cbec4deb4d8653a9cb6fe3db1541967395799c64
[ "MIT" ]
null
null
null
src/detail/chainable_setter.hpp
2bbb/ofxChainableSetting
cbec4deb4d8653a9cb6fe3db1541967395799c64
[ "MIT" ]
null
null
null
// // chainable_setter.hpp // // Created by ISHII 2bit on 2017/04/14. // // #pragma once #define bbb_chainable_setter_is_loaded #include <utility> #include <iostream> namespace bbb { template <typename parent_type> struct base_setter { void set_parent(parent_type *parent) { this->parent = parent; } protected: parent_type *parent; }; template <typename type, typename parent_type> struct chainable_setter : base_setter<parent_type> { chainable_setter() {} chainable_setter(const chainable_setter &mom) : body(mom.body) {} chainable_setter(chainable_setter &&mom) : body(std::move(mom.body)) {}; chainable_setter(const type &default_value) : body(default_value) {}; chainable_setter(type &&default_value) : body(std::move(default_value)) {}; #pragma mark getter inline type &operator()() { return body; } inline type operator()() const { return body; } #pragma mark cast inline operator type&() { return body; }; inline operator type() const { return body; }; #pragma mark setter inline parent_type &operator()(const chainable_setter &rhs) { body = rhs.body; return *parent; } inline parent_type &operator()(const type &value) { body = value; return *parent; } inline parent_type &operator()(chainable_setter &&rhs) { body = std::move(rhs.body); return *parent; } inline parent_type &operator()(type &&value) { body = std::move(value); return *parent; } #pragma mark assignment inline chainable_setter &operator=(const chainable_setter &b) { body = b.body; return *this; } template <typename other_parent> inline chainable_setter &operator=(const chainable_setter<type, other_parent> &b) { body = b.body; return *this; } inline chainable_setter &operator=(chainable_setter &&b) { body = std::move(b.body); return *this; } template <typename other_parent> inline chainable_setter &operator=(chainable_setter<type, other_parent> &&b) { body = std::move(b.body); return *this; } inline type &operator=(const type &b) { return body = b; } inline type &operator=(type &&b) { return body = std::move(b); } #pragma mark compare equality template <typename other_parent> inline bool operator==(const chainable_setter<type, other_parent> &rhs) const { return body == rhs.body; } inline bool operator==(const type &body) const { return this->body == body; } template <typename other_parent> inline bool operator!=(const chainable_setter<type, other_parent> &rhs) const { return body != rhs.body; } inline bool operator!=(const type &body) const { return this->body != body; } #pragma mark compare order template <typename other_parent> inline auto operator<(const chainable_setter<type, other_parent> &rhs) const -> decltype(type() < type()) { return body < rhs.body; } inline auto operator<(const type &value) const -> decltype(type() < type()) { return body < value; } template <typename other_parent> inline auto operator<=(const chainable_setter<type, other_parent> &rhs) const -> decltype(type() <= type()) { return body <= rhs.body; } inline auto operator<=(const type &value) const -> decltype(type() <= type()) { return body <= value; } template <typename other_parent> inline auto operator>(const chainable_setter<type, other_parent> &rhs) const -> decltype(type() > type()) { return body > rhs.body; } inline auto operator>(const type &value) const -> decltype(type() > type()) { return body > value; } template <typename other_parent> inline auto operator>=(const chainable_setter<type, other_parent> &rhs) const -> decltype(type() >= type()) { return body >= rhs.body; } inline auto operator>=(const type &value) const -> decltype(type() >= type()) { return body >= value; } #pragma swap inline void swap(chainable_setter &b) noexcept { std::swap(body, b.body); } inline void swap(chainable_setter &&b) noexcept { std::swap(body, b.body); } inline void swap(type &b) noexcept { std::swap(body, b); } inline void swap(type &&b) noexcept { std::swap(body, b); } friend void swap(chainable_setter &lhs, chainable_setter &rhs) noexcept { lhs.swap(rhs); } friend void swap(chainable_setter &lhs, type &rhs) noexcept { lhs.swap(rhs); } friend void swap(type &lhs, chainable_setter &rhs) noexcept { rhs.swap(lhs); } private: using base_setter<parent_type>::parent; type body; }; };
34.9
114
0.582426
2bbb
edf90b7a696f5248de310ece4f341c36503e3bb5
2,733
cpp
C++
14.cpp
malkiewiczm/adventofcode2020
8491a5a0be11fa8cfa61d67c97401797c0e7cf6b
[ "Apache-2.0" ]
null
null
null
14.cpp
malkiewiczm/adventofcode2020
8491a5a0be11fa8cfa61d67c97401797c0e7cf6b
[ "Apache-2.0" ]
null
null
null
14.cpp
malkiewiczm/adventofcode2020
8491a5a0be11fa8cfa61d67c97401797c0e7cf6b
[ "Apache-2.0" ]
null
null
null
//#define PARTONE #include "template.hpp" using Map = std::map<I64, I64>; #ifdef PARTONE static I64 mask_digits(const std::string &mask_string, I64 n) { FOR(i, 36) { switch (mask_string[i]) { case '0': n &= ~(1LL << (35 - i)); break; case '1': n |= (1LL << (35 - i)); break; } } return n; } int main(int argc, char **argv) { const char *const fname = (argc >= 2) ? argv[1] : "in.txt"; std::ifstream f(fname); if (! f.good()) { TRACE << "file cannot be opened" << std::endl; die(); } Map mem; { std::string line; std::string mask; while (std::getline(f, line)) { if (line.empty()) continue; if (line[1] == 'a') { // mask mask = &line[7]; } else { // command const size_t end = line.find(']'); if (end == std::string::npos) { TRACE << "bad line" << std::endl; trace(line); die(); } const std::string index_s = line.substr(4, end - 4); const I64 index = std::stoll(index_s.c_str(), nullptr, 10); const std::string value_s = line.substr(end + 4); const I64 value_no_mask = std::stoll(value_s.c_str(), nullptr, 10); const I64 value = mask_digits(mask, value_no_mask); mem[index] = value; } } } I64 sum = 0; for (auto kv : mem) { sum += kv.second; } trace(sum); } #else int main(int argc, char **argv) { const char *const fname = (argc >= 2) ? argv[1] : "in.txt"; std::ifstream f(fname); if (! f.good()) { TRACE << "file cannot be opened" << std::endl; die(); } Map mem; { std::string line; I64 mask = 0; std::vector<int> wild; while (std::getline(f, line)) { if (line.empty()) continue; if (line[1] == 'a') { // mask wild.clear(); mask = 0; const char *m = &line[7]; FOR(i, 36) { switch (m[i]) { case 'X': wild.push_back(i); break; case '1': mask |= (1LL << (35 - i)); break; } } } else { // command const size_t end = line.find(']'); if (end == std::string::npos) { TRACE << "bad line" << std::endl; trace(line); die(); } const std::string index_s = line.substr(4, end - 4); const I64 index_no_mask = std::stoll(index_s.c_str(), nullptr, 10); const std::string value_s = line.substr(end + 4); const I64 value = std::stoll(value_s.c_str(), nullptr, 10); const int to = 1 << static_cast<int>(wild.size()); FOR(i, to) { I64 index = index_no_mask | mask; FOR(j, wild.size()) { if (i & (1 << j)) { index |= 1LL << (35 - wild[j]); } else { index &= ~(1LL << (35 - wild[j])); } } mem[index] = value; } } } } I64 sum = 0; for (auto kv : mem) { sum += kv.second; } trace(sum); } #endif
20.395522
71
0.524332
malkiewiczm
edff6d371e848e70a34c1d3bbf3191e78417298e
8,438
cpp
C++
KinectExplorer-D2D/KinectSettings.cpp
MxWang6/IET_GroupProject_YogaApp
a3f41ecae79a6fda787324dd00831ab20d1879fd
[ "MIT" ]
null
null
null
KinectExplorer-D2D/KinectSettings.cpp
MxWang6/IET_GroupProject_YogaApp
a3f41ecae79a6fda787324dd00831ab20d1879fd
[ "MIT" ]
null
null
null
KinectExplorer-D2D/KinectSettings.cpp
MxWang6/IET_GroupProject_YogaApp
a3f41ecae79a6fda787324dd00831ab20d1879fd
[ "MIT" ]
1
2019-03-18T07:52:11.000Z
2019-03-18T07:52:11.000Z
//------------------------------------------------------------------------------ // <copyright file="KinectSettings.cpp" company="Microsoft"> // Copyright (c) Microsoft Corporation. All rights reserved. // </copyright> //------------------------------------------------------------------------------ #include "stdafx.h" #include "KinectSettings.h" #include "Utility.h" #include "resource.h" #include "KinectWindow.h" #include "CameraColorSettingsViewer.h" #include "CameraExposureSettingsViewer.h" /// <summary> /// Return the chooser mode based on the given command Id /// </summary> /// <param name="commanId">ID of the menu item</param> ChooserMode ConvertCommandIdToChooserMode(WORD commandId) { switch (commandId) { case ID_CHOOSERMODE_DEFAULTSYSTEMTRACKING: return ChooserModeDefault; case ID_CHOOSERMODE_CLOSEST1PLAYER: return ChooserModeClosest1; case ID_CHOOSERMODE_CLOSEST2PLAYER: return ChooserModeClosest2; case ID_CHOOSERMODE_STICKY1PLAYER: return ChooserModeSticky1; case ID_CHOOSERMODE_STICKY2PLAYER: return ChooserModeSticky2; case ID_CHOOSERMODE_MOSTACTIVE1PLAYER: return ChooserModeActive1; case ID_CHOOSERMODE_MOSTACTIVE2PLAYER: return ChooserModeActive2; } return ChooserModeDefault; } /// <summary> /// Constructor /// </summary> /// <param name="pNuiSensor">The pointer to NUI sensor instance</param> /// <param name="pPrimaryView">The pointer to primary viewer instance</param> /// <param name="pSecondaryView">The pointer to secondary viewer instance</param> /// <param name="pColorStream">The pointer to color stream object instance</param> /// <param name="pDepthStream">The pointer to depth stream object instance</param> /// <param name="pSkeletonStream">The pointer to skeleton stream object instance</param> KinectSettings::KinectSettings(INuiSensor* pNuiSensor, NuiStreamViewer* pPrimaryView, NuiStreamViewer* pSecondaryView, NuiColorStream* pColorStream, NuiDepthStream* pDepthStream, NuiSkeletonStream* pSkeletonStream, CameraSettingsViewer* pColorSettingsView, CameraSettingsViewer* pExposureSettingsView) : m_pNuiSensor(pNuiSensor) , m_pPrimaryView(pPrimaryView) , m_pSecondaryView(pSecondaryView) , m_pColorStream(pColorStream) , m_pDepthStream(pDepthStream) , m_pSkeletonStream(pSkeletonStream) , m_pColorSettingsView(pColorSettingsView) , m_pExposureSettingsView(pExposureSettingsView) { m_pNuiSensor->AddRef(); } /// <summary> /// Destructor /// </summary> KinectSettings::~KinectSettings() { SafeRelease(m_pNuiSensor); } /// <summary> /// Process Kinect window menu commands /// </summary> /// <param name="commanId">ID of the menu item</param> /// <param name="param">Parameter passed in along with the commmand ID</param> /// <param name="previouslyChecked">Check status of menu item before command is issued</param> void KinectSettings::ProcessMenuCommand(WORD commandId, WORD param, bool previouslyChecked) { if (ID_COLORSTREAM_PAUSE == commandId) { // Pause color stream if (m_pColorStream) { m_pColorStream->PauseStream(!previouslyChecked); } } else if (ID_COLORSTREAM_RESOLUTION_START <= commandId && ID_COLORSTREAM_RESOLUTION_END >= commandId) { // Set color stream format and resolution if (!m_pColorStream) { return; } switch (commandId) { case ID_RESOLUTION_RGBRESOLUTION640X480FPS30: m_pColorStream->SetImageType(NUI_IMAGE_TYPE_COLOR); m_pColorStream->SetImageResolution(NUI_IMAGE_RESOLUTION_640x480); break; case ID_RESOLUTION_RGBRESOLUTION1280X960FPS12: m_pColorStream->SetImageType(NUI_IMAGE_TYPE_COLOR); m_pColorStream->SetImageResolution(NUI_IMAGE_RESOLUTION_1280x960); break; case ID_RESOLUTION_YUVRESOLUTION640X480FPS15: m_pColorStream->SetImageType(NUI_IMAGE_TYPE_COLOR_YUV); m_pColorStream->SetImageResolution(NUI_IMAGE_RESOLUTION_640x480); break; case ID_RESOLUTION_INFRAREDRESOLUTION640X480FPS30: m_pColorStream->SetImageType(NUI_IMAGE_TYPE_COLOR_INFRARED); m_pColorStream->SetImageResolution(NUI_IMAGE_RESOLUTION_640x480); break; case ID_RESOLUTION_RAWBAYERRESOLUTION640X480FPS30: m_pColorStream->SetImageType(NUI_IMAGE_TYPE_COLOR_RAW_BAYER); m_pColorStream->SetImageResolution(NUI_IMAGE_RESOLUTION_640x480); break; case ID_RESOLUTION_RAWBAYERRESOLUTION1280X960FPS12: m_pColorStream->SetImageType(NUI_IMAGE_TYPE_COLOR_RAW_BAYER); m_pColorStream->SetImageResolution(NUI_IMAGE_RESOLUTION_1280x960); break; default: return; } m_pColorStream->OpenStream(); } else if (ID_DEPTHSTREAM_PAUSE == commandId) { // Pause depth stream if(m_pDepthStream) { m_pDepthStream->PauseStream(!previouslyChecked); } } else if (ID_DEPTHSTREAM_RANGEMODE_START <= commandId && ID_DEPTHSTREAM_RANGEMODE_END >= commandId) { // Set depth stream range mode bool nearMode = false; switch (commandId) { case ID_RANGEMODE_DEFAULT: nearMode = false; break; case ID_RANGEMODE_NEAR: nearMode = true; break; default: return; } if (m_pDepthStream) { m_pDepthStream->SetNearMode(nearMode); } if (m_pSkeletonStream) { m_pSkeletonStream->SetNearMode(nearMode); } } else if (ID_DEPTHSTREAM_RESOLUTION_START <= commandId && ID_DEPTHSTREAM_RESOLUTION_END >= commandId) { // Set depth stream resolution NUI_IMAGE_RESOLUTION resolution = (NUI_IMAGE_RESOLUTION)(commandId - ID_DEPTHSTREAM_RESOLUTION_START); if (m_pDepthStream) { m_pDepthStream->OpenStream(resolution); } } else if (ID_DEPTHSTREAM_DEPTHTREATMENT_START <= commandId && ID_DEPTHSTREAM_DEPTHTREATMENT_END >= commandId) { // Set depth stream treatment mode DEPTH_TREATMENT treatment = (DEPTH_TREATMENT)(commandId - ID_DEPTHSTREAM_DEPTHTREATMENT_START); if (m_pDepthStream) { m_pDepthStream->SetDepthTreatment(treatment); } } else if (ID_SKELETONSTREAM_PAUSE == commandId) { // Pause skeleton stream if (m_pSkeletonStream) { m_pSkeletonStream->PauseStream(!previouslyChecked); } } else if (ID_SKELETONSTREAM_TRACKINGMODE_START <= commandId && ID_SKELETONSTREAM_TRACKINGMODE_END >= commandId) { // Set skeleton track mode if (!m_pSkeletonStream) { return; } switch (commandId) { case ID_TRACKINGMODE_DEFAULT: m_pSkeletonStream->SetSeatedMode(false); break; case ID_TRACKINGMODE_SEATED: m_pSkeletonStream->SetSeatedMode(true); break; default: return; } } else if (ID_SKELETONSTREAM_CHOOSERMODE_START <= commandId && ID_SKELETONSTREAM_CHOOSERMODE_END >= commandId) { // Set skeleton chooser mode if(!m_pSkeletonStream) { return; } m_pSkeletonStream->SetChooserMode(ConvertCommandIdToChooserMode(commandId)); } else { switch (commandId) { // Bring up camera color setting dialog case ID_CAMERA_COLORSETTINGS: m_pColorSettingsView->ShowView(); break; // Bring up camera exposure setting dialog case ID_CAMERA_EXPOSURESETTINGS: m_pExposureSettingsView->ShowView(); break; // Switch the stream display on primary and secondary stream viewers case ID_VIEWS_SWITCH: if (m_pColorStream && m_pDepthStream) { m_pColorStream->SetStreamViewer(m_pDepthStream->SetStreamViewer(m_pColorStream->SetStreamViewer(nullptr))); } break; case ID_FORCE_OFF_IR: m_pNuiSensor->NuiSetForceInfraredEmitterOff(param); break; default: break; } } }
31.962121
301
0.650984
MxWang6
6100753330faec37f7b47b17cd8fdf0fb0302f74
1,375
hpp
C++
cl/sampler.hpp
eti-p-doray/inf8702
1f420f6a6d8df5e9f5dce7c6192b622c761a909a
[ "MIT" ]
null
null
null
cl/sampler.hpp
eti-p-doray/inf8702
1f420f6a6d8df5e9f5dce7c6192b622c761a909a
[ "MIT" ]
null
null
null
cl/sampler.hpp
eti-p-doray/inf8702
1f420f6a6d8df5e9f5dce7c6192b622c761a909a
[ "MIT" ]
null
null
null
#pragma once namespace cl { #pragma once #include "cl/wrapper.hpp" namespace cl { struct sampler_traits { using handle = cl_sampler; using info = cl_sampler_info; static constexpr auto get_info = clGetSamplerInfo; static constexpr auto retain = clRetainSampler; static constexpr auto release = clReleaseSampler; }; class weak_sampler : public base_wrapper<sampler_traits> { public: using base_wrapper::base_wrapper; protected: void create(weak_context ctx, bool normalized_coords, addressing_mode addressing, filter_mode filter) { assert(ctx != nullptr); cl_int error = 0; cl_program id = clCreateSampler( ctx, normalized_coords, static_cast<cl_addressing_mode>(addressing), static_cast<>(filter), &error ); if (!id) throw opencl_error(error); reset(id); } }; enum class addressing_mode { kNone = CL_ADDRESS_NONE, kClampToEdge = CL_ADDRESS_CLAMP_TO_EDGE, kClamp = CL_ADDRESS_CLAMP, kRepeat = CL_ADDRESS_REPEAT, }; enum class filter_mode { kNearest = CL_FILTER_NEAREST, kLinear = CL_FILTER_LINEAR, }; struct sampler : shared_wrapper<weak_sampler> { using shared_wrapper::shared_wrapper; sampler() = default; sampler(weak_context ctx, bool normalized_coords, addressing_mode addressing, filter_mode filter) { create(normalized_coords, addressing, filter); } }; } }
21.825397
105
0.730909
eti-p-doray
61015b823b66adde701611ee03e07b0e57048e28
9,032
cpp
C++
src/dnssd/avahi/poller.cpp
breese/trial.aware
b5b0c74e24d20e6e5f947be1d29bae42ce4377a1
[ "BSL-1.0" ]
2
2019-10-30T17:26:02.000Z
2020-06-21T09:11:02.000Z
src/dnssd/avahi/poller.cpp
breese/trial.aware
b5b0c74e24d20e6e5f947be1d29bae42ce4377a1
[ "BSL-1.0" ]
null
null
null
src/dnssd/avahi/poller.cpp
breese/trial.aware
b5b0c74e24d20e6e5f947be1d29bae42ce4377a1
[ "BSL-1.0" ]
null
null
null
/////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2018 Bjorn Reese <breese@users.sourceforge.net> // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // /////////////////////////////////////////////////////////////////////////////// #include <cassert> #include <new> // std::nothrow #include <memory> #include <chrono> #include <utility> #include <trial/net/io_context.hpp> #include <avahi-common/timeval.h> #include "native_socket.hpp" #include "dnssd/avahi/poller.hpp" using namespace trial::aware; //----------------------------------------------------------------------------- // AvahiWatch //----------------------------------------------------------------------------- // This struct must be in global namespace struct AvahiWatch { AvahiWatch(const trial::net::executor& executor, int fd, AvahiWatchEvent event, AvahiWatchCallback callback, void *userdata) : socket(executor, fd), callback(callback), userdata(userdata), revents(AvahiWatchEvent(0)) { if (event & AVAHI_WATCH_IN) { start_read(); } if (event & AVAHI_WATCH_OUT) { start_write(); } } void update(AvahiWatchEvent /* event */) { // FIXME assert(false); } AvahiWatchEvent get_events() const { return revents; } void start_read() { revents = (AvahiWatchEvent)(revents & ~AVAHI_WATCH_IN); socket.async_read_event(std::bind(&AvahiWatch::process_read, this, std::placeholders::_1, std::placeholders::_2)); } void process_read(const boost::system::error_code& error, std::size_t /* bytes_transferred */) { if (!error) { revents = (AvahiWatchEvent)(revents | AVAHI_WATCH_IN); callback(this, socket.native_handle(), AVAHI_WATCH_IN, userdata); start_read(); } else if (error == boost::asio::error::operation_aborted) { // We are closing down } else { // FIXME } } void start_write() { revents = (AvahiWatchEvent)(revents & ~AVAHI_WATCH_OUT); socket.async_write_event(std::bind(&AvahiWatch::process_write, this, std::placeholders::_1, std::placeholders::_2)); } void process_write(const boost::system::error_code& error, std::size_t /* bytes_transferred */) { if (!error) { revents = (AvahiWatchEvent)(revents | AVAHI_WATCH_OUT); callback(this, socket.native_handle(), AVAHI_WATCH_OUT, userdata); start_write(); } else if (error == boost::asio::error::operation_aborted) { // We are closing down } else { // FIXME } } native_socket socket; AvahiWatchCallback callback; void *userdata; AvahiWatchEvent revents; }; extern "C" AvahiWatch *aware_avahi_watch_new(const AvahiPoll *poll, int fd, AvahiWatchEvent event, AvahiWatchCallback callback, void *userdata) { auto poller = reinterpret_cast<const avahi::poller *>(poll); return new (std::nothrow) AvahiWatch(poller->get_executor(), fd, event, callback, userdata); } extern "C" void aware_avahi_watch_free(AvahiWatch *self) { delete self; } extern "C" void aware_avahi_watch_update(AvahiWatch *self, AvahiWatchEvent event) { self->update(event); } extern "C" AvahiWatchEvent aware_avahi_watch_get_events(AvahiWatch *self) { return self->get_events(); } //----------------------------------------------------------------------------- // AvahiTimeout //----------------------------------------------------------------------------- class avahi_timer; // This struct must be in global namespace struct AvahiTimeout { explicit AvahiTimeout(std::shared_ptr<avahi_timer>); void update(const struct timeval *); void release(); // AvahiTimeout may be deleted before the timer callback is invoked, so the // timer is kept as a shared_ptr, for which this class acts as a simple // wrapper. std::shared_ptr<avahi_timer> timer; }; class avahi_timer : public std::enable_shared_from_this<avahi_timer> { public: static std::shared_ptr<avahi_timer> create(const trial::net::executor& executor, const struct timeval *tv, AvahiTimeoutCallback callback, void *userdata) { auto result = std::make_shared<avahi_timer>(executor, callback, userdata); if (tv) { result->update(tv); } result->set_resource(new (std::nothrow) AvahiTimeout(result)); return result; } avahi_timer(const trial::net::executor& executor, AvahiTimeoutCallback callback, void *userdata) : resource(nullptr), timer(executor), callback(callback), userdata(userdata) { } avahi_timer(const avahi_timer&) = delete; avahi_timer(avahi_timer&&) = delete; avahi_timer& operator= (const avahi_timer&) = delete; avahi_timer& operator= (avahi_timer&&) = delete; ~avahi_timer() { delete resource; } AvahiTimeout *get_resource() const { assert(resource); return resource; } void set_resource(AvahiTimeout *res) { resource = res; } void cancel() { boost::system::error_code dummy; timer.cancel(dummy); } void update(const struct timeval *tv) { if (tv) { const AvahiUsec deadline = ((tv->tv_sec == 0) && (tv->tv_usec == 0)) ? 0 : -avahi_age(tv); boost::system::error_code dummy; timer.expires_from_now(std::chrono::microseconds(deadline), dummy); timer.async_wait(std::bind(&avahi_timer::process_timeout, shared_from_this(), std::placeholders::_1)); } else { cancel(); } } void process_timeout(const boost::system::error_code& error) { if (!error) { callback(resource, userdata); } else if (error == boost::asio::error::operation_aborted) { // We are closing down } else { // FIXME } } AvahiTimeout *resource; boost::asio::basic_waitable_timer<std::chrono::steady_clock> timer; AvahiTimeoutCallback callback; void *userdata; }; AvahiTimeout::AvahiTimeout(std::shared_ptr<avahi_timer> timer) : timer(std::move(timer)) { } void AvahiTimeout::update(const struct timeval *tv) { timer->update(tv); } void AvahiTimeout::release() { timer->cancel(); timer.reset(); } extern "C" AvahiTimeout *aware_avahi_timeout_new(const AvahiPoll *poll, const struct timeval *tv, AvahiTimeoutCallback callback, void *userdata) { auto poller = reinterpret_cast<const avahi::poller *>(poll); auto timer = avahi_timer::create(poller->get_executor(), tv, callback, userdata); return timer->get_resource(); } extern "C" void aware_avahi_timeout_free(AvahiTimeout *self) { self->release(); } extern "C" void aware_avahi_timeout_update(AvahiTimeout *self, const struct timeval *tv) { self->update(tv); } //----------------------------------------------------------------------------- // poller //----------------------------------------------------------------------------- namespace trial { namespace aware { namespace avahi { poller::poller(const trial::net::executor& executor) : executor(executor) { userdata = this; watch_new = &aware_avahi_watch_new; watch_update = &aware_avahi_watch_update; watch_get_events = &aware_avahi_watch_get_events; watch_free = &aware_avahi_watch_free; timeout_new = &aware_avahi_timeout_new; timeout_update = &aware_avahi_timeout_update; timeout_free = &aware_avahi_timeout_free; } trial::net::executor poller::get_executor() const { return executor; } } // namespace avahi } // namespace aware } // namespace trial
26.801187
102
0.525354
breese
610240fecb042f9a4bb1d955683da4362edf0be0
794
hpp
C++
src/Core/CResource.hpp
Sebajuste/Omeglond3D
28a3910b47490ec837a29e40e132369f957aedc7
[ "MIT" ]
1
2019-06-14T08:24:17.000Z
2019-06-14T08:24:17.000Z
src/Core/CResource.hpp
Sebajuste/Omeglond3D
28a3910b47490ec837a29e40e132369f957aedc7
[ "MIT" ]
null
null
null
src/Core/CResource.hpp
Sebajuste/Omeglond3D
28a3910b47490ec837a29e40e132369f957aedc7
[ "MIT" ]
null
null
null
#ifndef _DEF_OMEGLOND3D_CRESOURCE_HPP #define _DEF_OMEGLOND3D_CRESOURCE_HPP #include "IResource.hpp" namespace OMGL3D { namespace CORE { class CResource : public IResource { public: virtual ~CResource(); std::string GetName() const; void SetName(const std::string & name); void AddRef(); unsigned int GetCount() const; void Release(); protected: CResource(); CResource(const std::string &name); private: //friend class ResourceManager; std::string _name; unsigned int _counter; CResource(const CResource &); void operator=(const CResource&); }; } } #endif
15.269231
51
0.539043
Sebajuste
610306273673f04a1537335fe579fc48b6ad3b3b
6,049
hpp
C++
libvast/vast/bloom_filter.hpp
JoeLoser/vast
0380180cba549c0b839b286d8a58f2aaf2759aec
[ "BSD-3-Clause" ]
null
null
null
libvast/vast/bloom_filter.hpp
JoeLoser/vast
0380180cba549c0b839b286d8a58f2aaf2759aec
[ "BSD-3-Clause" ]
7
2021-11-15T01:30:45.000Z
2022-03-04T01:19:21.000Z
libvast/vast/bloom_filter.hpp
satta/vast
6c7587effd4265c4a5de23252bc7c7af3ef78bee
[ "BSD-3-Clause" ]
null
null
null
// _ _____ __________ // | | / / _ | / __/_ __/ Visibility // | |/ / __ |_\ \ / / Across // |___/_/ |_/___/ /_/ Space and Time // // SPDX-FileCopyrightText: (c) 2020 The VAST Contributors // SPDX-License-Identifier: BSD-3-Clause #pragma once #include "vast/bitvector.hpp" #include "vast/bloom_filter_parameters.hpp" #include "vast/detail/operators.hpp" #include "vast/hasher.hpp" #include "vast/legacy_type.hpp" #include "vast/logger.hpp" #include <caf/meta/load_callback.hpp> #include <caf/meta/type_name.hpp> #include <climits> #include <cstddef> #include <numeric> #include <optional> #include <type_traits> #include <utility> #include <vector> namespace vast::policy { /// A policy that controls the cell layout of a Bloom filter. /// If `yes`, the Bloom filter bits are split into *k* equi-distant partitions. /// @relates bloom_filter enum class partitioning { yes, no }; } // namespace vast::policy namespace vast { /// A data structure for probabilistic set membership. /// @tparam HashFunction The hash function to use in the hasher. /// @tparam Hasher The hasher type to generate digests. /// @tparam Partitioning The partitioning policy. template <class HashFunction, template <class> class Hasher = double_hasher, policy::partitioning Partitioning = policy::partitioning::no> class bloom_filter : detail::equality_comparable< bloom_filter<HashFunction, Hasher, Partitioning>> { public: using hash_function = HashFunction; using hasher_type = Hasher<hash_function>; static constexpr policy::partitioning partitioning_policy = Partitioning; /// Constructs a Bloom filter with a fixed size and a hasher. /// @param size The number of cells/bits in the Bloom filter. /// @param hasher The hasher type to generate digests. explicit bloom_filter(size_t size = 0, hasher_type hasher = hasher_type{}) : hasher_{std::move(hasher)}, bits_(size) { // nop } /// Adds an element to the Bloom filter. /// @param x The element to add. /// @returns `false` iff *x* already exists in the filter. template <class T> bool add(T&& x) { auto& digests = hasher_(std::forward<T>(x)); auto unique = false; for (size_t i = 0; i < digests.size(); ++i) { auto bit = bits_[position(i, digests[i])]; unique |= bit == false; bit = true; } return unique; } /// Test whether an element exists in the Bloom filter. /// @param x The element to test. /// @returns `false` if the *x* is not in the set and `true` if *x* may exist /// according to the false-positive probability of the filter. template <class T> bool lookup(T&& x) const { auto& digests = hasher_(std::forward<T>(x)); for (size_t i = 0; i < digests.size(); ++i) if (!bits_[position(i, digests[i])]) return false; return true; } /// @returns The number of cells in the underlying bit vector. [[nodiscard]] size_t size() const { return bits_.size(); } /// @returns An estimate for amount of memory (in bytes) used by this filter. [[nodiscard]] size_t memusage() const { return sizeof(bloom_filter) + bits_.capacity() / CHAR_BIT; } /// @returns The number of hash functions in the hasher. [[nodiscard]] size_t num_hash_functions() const { return hasher_.size(); } // -- concepts -------------------------------------------------------------- friend bool operator==(const bloom_filter& x, const bloom_filter& y) { return x.hasher_ == y.hasher_ && x.bits_ == y.bits_; } template <class Inspector> friend auto inspect(Inspector& f, bloom_filter& x) { auto load_callback = caf::meta::load_callback([&]() -> caf::error { // When deserializing into a vector that was already bigger than // required, CAF will reuse the storage but not release the // excess afterwards. x.bits_.shrink_to_fit(); return caf::none; }); return f(caf::meta::type_name("bloom_filter"), x.hasher_, x.bits_, std::move(load_callback)); } private: template <class Digest> size_t position([[maybe_unused]] size_t i, Digest x) const { if constexpr (partitioning_policy == policy::partitioning::no) return x % bits_.size(); if constexpr (partitioning_policy == policy::partitioning::yes) { auto num_partition_cells = bits_.size() / hasher_.size(); return i * num_partition_cells + (x % num_partition_cells); } } hasher_type hasher_; bitvector<uint64_t> bits_; }; /// Constructs a Bloom filter for a given set of parameters. /// @tparam HashFunction The hash function to use in the hasher. /// @tparam Hasher The hasher type to generate digests. /// @tparam Partitioning The partitioning policy. /// @param xs The Bloom filter parameters. /// @param seeds The seeds for the hash functions. If empty, ascending /// integers from 0 to *k-1* will be used. /// @relates bloom_filter bloom_filter_parameters template <class HashFunction, template <class> class Hasher = double_hasher, policy::partitioning Partitioning = policy::partitioning::no> std::optional<bloom_filter<HashFunction, Hasher, Partitioning>> make_bloom_filter(bloom_filter_parameters xs, std::vector<size_t> seeds = {}) { using result_type = bloom_filter<HashFunction, Hasher, Partitioning>; using hasher_type = typename result_type::hasher_type; if (auto ys = evaluate(xs)) { VAST_DEBUG("evaluated bloom filter parameters: {} {} {} {}", VAST_ARG(ys->k), VAST_ARG(ys->m), VAST_ARG(ys->n), VAST_ARG(ys->p)); if (*ys->m == 0 || *ys->k == 0) return {}; if (seeds.empty()) { if constexpr (std::is_same_v<hasher_type, double_hasher<HashFunction>>) { seeds = {0, 1}; } else { seeds.resize(*ys->k); std::iota(seeds.begin(), seeds.end(), 0); } } else if (seeds.size() != *ys->k) { return {}; } return result_type{*ys->m, hasher_type{*ys->k, std::move(seeds)}}; } return {}; } } // namespace vast
34.565714
79
0.654488
JoeLoser
6106dc7fcfbe213dbe63901912367d8e4d12d64b
5,516
cpp
C++
src/splicigar/main.cpp
preciserobot/rex
91b58e22ea45b56b01a2cdd2ea63b253c9edc467
[ "BSD-4-Clause-UC" ]
null
null
null
src/splicigar/main.cpp
preciserobot/rex
91b58e22ea45b56b01a2cdd2ea63b253c9edc467
[ "BSD-4-Clause-UC" ]
null
null
null
src/splicigar/main.cpp
preciserobot/rex
91b58e22ea45b56b01a2cdd2ea63b253c9edc467
[ "BSD-4-Clause-UC" ]
null
null
null
/* * splicigar - returns cigar lines of possible splice juntion neighboring exons using a given half length * * Created by David Brawand on 12.02.10. * Added exon stringency filter on 14.04.10. * Copyright 2010 UNIL. All rights reserved. * */ #include <cstdio> #include <cstdlib> #include <fstream> #include <iomanip> #include <iostream> #include <vector> #include <unistd.h> #include <time.h> #include <stdio.h> #include <set> #include <map> #include "splicigar.hpp" //namespace using namespace std; /* MAIN */ int main(int argc, char* argv[]) { /* USAGE */ if (argc != 6) { std::cerr << "Usage: " << argv[0] << " junctions (exonfile/-) overhang readlength minimum_intron_size --> writes to COUT " << std::endl; exit(1); } std::cerr << std::endl << " "; std::cerr << std::endl << " spliCigar "; std::cerr << std::endl << " sSs "; std::cerr << std::endl << " .-------------.S "; std::cerr << std::endl << " '._|0.6|_______.\" "; std::cerr << std::endl << " "; std::cerr << std::endl << " " << std::endl << std::endl; /* DECLARATIONS */ char line[200]; int scan[5]; // the infolibs regiomap regions; intmap pairs; int lico = 0; /* DATA READ STARTS HERE */ std::ifstream intronFile(argv[1]); std::ifstream exonFile(argv[2]); int overh = atoi(argv[3]); int readl = atoi(argv[4]); int mintron = atoi(argv[5]); if (overh >= readl) { cerr << "ERROR: OVERHANG greater or equal to READLENGTH" << endl; abort(); } int distance = readl - overh; int idoffset = 0; int skippedIntrons = 0, acceptedIntrons = 0; // READ INTRONS if (intronFile.fail()) { std::cerr << "Error: could not read from intronFile " << argv[1] << std::endl; exit(1); } lico = 0; std::cerr << "Reading introns from file " << argv[1] << std::endl; while (!intronFile.eof() && !intronFile.fail()) { intronFile.getline(line, 200); if (intronFile.eof()) break; sscanf(line, "%d%d%d%d%d", &scan[0], &scan[1], &scan[2], &scan[3], &scan[4]); // id, region, strand, start, end if (regions.find(scan[1]) == regions.end()) { regions.insert(pair<int,Region*>(scan[1], new Region(scan[1], distance))); // create region } if (scan[4] - scan[3] + 1 >= mintron) { // check size regions.find(scan[1])->second->addIntron(scan); // add mapping check mapping compatibility (overwrites mapping) acceptedIntrons++; } else { skippedIntrons++; } std::cerr << "\r" << ++lico; } intronFile.close(); std::cerr << "\r" << "intronFile: " << regions.size() << " regions with " << acceptedIntrons << " introns (" << skippedIntrons << " did not pass length filter of " << mintron << " bases)" << std::endl; // stringency? bool stringency; if (exonFile.fail()) { stringency = false; } else { lico = 0; std::cerr << "Reading exons from file " << argv[2] << std::endl; while (!exonFile.eof() && !exonFile.fail()) { exonFile.getline(line, 200); if (exonFile.eof()) break; sscanf(line, "%d%d%d%d", &scan[0], &scan[1], &scan[2], &scan[3]); if (regions.find(scan[0]) == regions.end()) { regions.insert(pair<int,Region*>(scan[0], new Region(scan[0], distance))); // create region } regions.find(scan[0])->second->addExon(scan); // add mapping check mapping compatibility (overwrites mapping) std::cerr << "\r" << ++lico; } exonFile.close(); std::cerr << "\r" << "exonFile: " << lico << " exons" << std::endl; stringency = true; } int maxi = 0; int cigs = idoffset; // run filter for(regiomap::const_iterator it = regions.begin(); it != regions.end(); ++it){ cigs = it->second->makeCigars(cigs, stringency, readl); std::cerr << "Region " << it->first << " -> " << cigs - idoffset << std::endl; for (intmap::const_iterator aa = it->second->stats.begin(); aa != it->second->stats.end(); ++aa) { maxi = (aa->first > maxi) ? aa->first : maxi; } } //HEADER std::cerr << "SPLICECLASS\t"; for (unsigned int s = 1; s <= maxi; s++) std::cerr << s << "\t"; std::cerr << std::endl; //REGIONSTATS for(regiomap::const_iterator it = regions.begin(); it != regions.end(); ++it){ // stats if (stringency) std::cerr << "R" << it->first << " STRINGENT\t"; else std::cerr << "R" << it->first << "\t\t"; for (unsigned int s = 1; s <= maxi; s++) { if (it->second->stats.find(s) != it->second->stats.end()) std::cerr << it->second->stats.find(s)->second << "\t"; else std::cerr << "0\t"; } std::cerr << std::endl; } // WRITE OUTPUT std::cerr << "Writing Output..."; for(regiomap::const_iterator it = regions.begin(); it != regions.end(); ++it){ for(cigarmultimap::const_iterator rg = it->second->activecigars->begin(); rg != it->second->activecigars->end(); ++rg){ int centralintron = rg->second->centerIntron(distance); std::cout << rg->second->cigarid() << "\t" << centralintron << "\t" << it->first << "\t" << rg->second->cigarstrand() << "\t" << rg->second->starts() << "\t"; for(intronmap::const_iterator sl = rg->second->slices.begin(); sl != rg->second->slices.end(); ++sl){ std::cout << sl->second->from() - 1 << "\t" << sl->second->intronid() << std::endl << rg->second->cigarid() << "\t" << centralintron << "\t" << it->first << "\t" << rg->second->cigarstrand() << "\t" << sl->second->to() + 1 << "\t"; } std::cout << rg->second->ends() << "\t0" << std::endl; } } std::cerr << "DONE" << std::endl; exit(0); // SUCCESS } // end of main
35.358974
235
0.576505
preciserobot
6108a7c0e904093b649846226a7b921d4a75a3ba
11,493
cc
C++
src/raft/raft_message.cc
zerolocusta/raft-in-cpp
9785732ca45d032d33ee45fa08da28b9cd301c5f
[ "MIT" ]
1
2019-10-29T14:47:18.000Z
2019-10-29T14:47:18.000Z
src/raft/raft_message.cc
zerolocusta/simple-raft-kvdb-cpp
9785732ca45d032d33ee45fa08da28b9cd301c5f
[ "MIT" ]
null
null
null
src/raft/raft_message.cc
zerolocusta/simple-raft-kvdb-cpp
9785732ca45d032d33ee45fa08da28b9cd301c5f
[ "MIT" ]
null
null
null
#include <err.h> #include "raft_message.h" namespace raft { PackedMessage::PackedMessage(void *data, uint32_t size) { uint32_t be32 = htobe32(size); data_ = new char[be32 + size]; ::memcpy(data_, &be32, sizeof be32); ::memcpy(data_ + sizeof be32, data, size); size_ = size + sizeof be32; } PackedMessage::PackedMessage(const std::string &str) { if (str.size() > MESSAGE_MAX_SIZE) return; uint32_t strsize = static_cast<uint32_t>(str.size()); uint32_t be32 = htobe32(strsize); data_ = new char[be32 + strsize]; ::memcpy(data_, &be32, sizeof be32); ::memcpy(data_ + sizeof be32, str.data(), strsize); size_ = strsize + sizeof be32; } uint32_t PackedMessage::size() { return size_; } char *PackedMessage::data() const { return data_; } PackedMessage::~PackedMessage() { delete[] data_; } // KVEntryMessage KVEntryMessage::KVEntryMessage(const raft::entry_t &entry) : entry_(entry) { } KVEntryMessage::KVEntryMessage(const raft_msg::KVEntry &kv_entry) : entry_(make_pair(kv_entry.key(), kv_entry.value())) { } KVEntryRawPtr_t KVEntryMessage::genProtoBufKVEntryMessage() { // TODO remember delete this pointer auto kv_entry = new raft_msg::KVEntry(); kv_entry->set_key(entry_.first); kv_entry->set_value(entry_.second); return kv_entry; } // KVEntryMessage END // LogEntryMessage LogEntryMessage::LogEntryMessage(const uint64_t index, const uint64_t term, const raft_msg::CommandType command_type, const raft_msg::KVEntry &kv_entry) : index_(index), term_(term), command_type_(command_type), kv_entry_(std::make_pair(kv_entry.key(), kv_entry.value())) { } LogEntryMessage::LogEntryMessage(const raft_msg::LogEntry &log_entry) : index_(log_entry.index()), term_(log_entry.term()), command_type_(log_entry.command_type()), kv_entry_(std::make_pair(log_entry.entry().key(), log_entry.entry().value())) { } LogEntryRawPtr_t LogEntryMessage::genProtoBufLogEntryMessage() { auto log_entry_ptr = new raft_msg::LogEntry(); log_entry_ptr->set_index(index_); log_entry_ptr->set_term(term_); log_entry_ptr->set_command_type(command_type_); auto kv_entry_message = KVEntryMessage(kv_entry_); log_entry_ptr->set_allocated_entry(kv_entry_message.genProtoBufKVEntryMessage()); return log_entry_ptr; } // LogEntryMessage END // AppendEntriesRequestMessage AppendEntriesRequestMessage::AppendEntriesRequestMessage(const uint64_t term, const uint64_t prev_log_index, const uint64_t prev_log_term, const uint64_t commit_index, const std::string &leader_name, const std::vector<RaftLogEntry> &entries) : term_(term), prev_log_index_(prev_log_index), prev_log_term_(prev_log_term), commit_index_(commit_index), leader_name_(leader_name), raft_log_entries_(entries) { } AppendEntriesRequestMessage::AppendEntriesRequestMessage(const raft_msg::AppendEntriesRequest &append_entries_request) : term_(append_entries_request.term()), prev_log_index_(append_entries_request.prev_log_index()), prev_log_term_(append_entries_request.prev_log_term()), commit_index_(append_entries_request.commit_index()), leader_name_(append_entries_request.leader_name()) { for (auto raft_log_entry : append_entries_request.entries()) { raft_log_entries_.push_back(RaftLogEntry(raft_log_entry.index(), raft_log_entry.term(), raft_log_entry.command_type(), std::make_pair(raft_log_entry.entry().key(), raft_log_entry.entry().value()))); } } std::string AppendEntriesRequestMessage::serializeAsString() { RaftMessage raft_message; auto append_entries_request_ptr = raft_message.mutable_append_entries_request(); append_entries_request_ptr->set_term(term_); append_entries_request_ptr->set_prev_log_index(prev_log_index_); append_entries_request_ptr->set_prev_log_term(prev_log_term_); append_entries_request_ptr->set_commit_index(commit_index_); append_entries_request_ptr->set_leader_name(leader_name_); for (auto e : raft_log_entries_) { auto add_entry_ptr = append_entries_request_ptr->add_entries(); add_entry_ptr->set_index(e.getIndex()); add_entry_ptr->set_term(e.getTerm()); add_entry_ptr->set_command_type((e.getCommand_type())); auto kv_entry_message = KVEntryMessage(entry_t(e.getEntry().first, e.getEntry().second)); add_entry_ptr->set_allocated_entry(kv_entry_message.genProtoBufKVEntryMessage()); } auto data = raft_message.SerializeAsString(); return data; } // AppendEntriesRequestMessage END // AppendEntriesResponseMessage AppendEntriesResponseMessage::AppendEntriesResponseMessage( const uint64_t term, const uint64_t current_index, const uint64_t commit_index, const bool success) : term_(term), current_index_(current_index), commit_index_(commit_index), success_(success) { } AppendEntriesResponseMessage::AppendEntriesResponseMessage(const raft_msg::AppendEntriesResponse &append_entries_response) : term_(append_entries_response.term()), current_index_(append_entries_response.current_index()), commit_index_(append_entries_response.commit_index()), success_(append_entries_response.success()) { } std::string AppendEntriesResponseMessage::serializeAsString() { auto raft_message = RaftMessage(); auto append_entries_response_ptr = raft_message.mutable_append_entries_response(); append_entries_response_ptr->set_term(term_); append_entries_response_ptr->set_commit_index(commit_index_); append_entries_response_ptr->set_current_index(current_index_); append_entries_response_ptr->set_success(success_); return raft_message.SerializeAsString(); } // AppendEntriesResponseMessage END CommandRequestMessage::CommandRequestMessage(const uint64_t command_id, const std::string &passwd, const raft_msg::CommandType command_type, const entry_t &command_entry) : command_id_(command_id), passwd_(passwd), command_type_(command_type), command_entry_(command_entry) { } CommandRequestMessage::CommandRequestMessage(const raft_msg::CommandRequest &command_request) : command_id_(command_request.command_id()), passwd_(command_request.passwd()), command_type_(command_request.command_type()), command_entry_(std::make_pair(command_request.command().key(), command_request.command().value())) { } std::string CommandRequestMessage::serializeAsString() { RaftMessage raft_message; auto command_request_ptr = raft_message.mutable_command_request(); command_request_ptr->set_command_id(command_id_); command_request_ptr->set_passwd(passwd_); command_request_ptr->set_command_type(command_type_); command_request_ptr->set_allocated_command(KVEntryMessage(command_entry_).genProtoBufKVEntryMessage()); return raft_message.SerializeAsString(); } CommandResponseMessage::CommandResponseMessage(const uint64_t command_id, const bool success, const std::string &passwd, const raft_msg::CommandResponseErr err, const entry_t &result) : command_id_(command_id), success_(success), passwd_(passwd), err_(err), result_(result) { } CommandResponseMessage::CommandResponseMessage(const raft_msg::CommandResponse &command_response) : command_id_(command_response.command_id()), success_(command_response.success()), passwd_(command_response.passwd()), err_(command_response.err()), result_(std::make_pair(command_response.result().key(), command_response.result().value())) { } std::string CommandResponseMessage::serializeAsString() { RaftMessage raft_message; auto command_response_ptr = raft_message.mutable_command_response(); command_response_ptr->set_command_id(command_id_); command_response_ptr->set_success(success_); command_response_ptr->set_passwd(passwd_); command_response_ptr->set_err(err_); command_response_ptr->set_allocated_result(KVEntryMessage(result_).genProtoBufKVEntryMessage()); return raft_message.SerializeAsString(); } JoinRequestMessage::JoinRequestMessage(const raft_msg::JoinRole role, const std::string &ipaddr, const std::string &passwd, const std::string &name) : role_(role), ipaddr_(ipaddr), passwd_(passwd), name_(name) { } JoinRequestMessage::JoinRequestMessage(const raft_msg::JoinRequest &join_request) : role_(join_request.role()), ipaddr_(join_request.ipaddr()), passwd_(join_request.passwd()), name_(join_request.myname()) { } std::string JoinRequestMessage::serializeAsString() { RaftMessage raft_message; auto join_request_ptr = raft_message.mutable_join_request(); join_request_ptr->set_role(role_); join_request_ptr->set_ipaddr(ipaddr_); join_request_ptr->set_passwd(passwd_); join_request_ptr->set_myname(name_); return raft_message.SerializeAsString(); } JoinResponseMessage::JoinResponseMessage(const bool success, const std::string &name, const std::string &passwd, const raft_msg::JoinError err) : success_(success), passwd_(passwd), name_(name), err_(err) { } JoinResponseMessage::JoinResponseMessage(const raft_msg::JoinResponse &join_response) : success_(join_response.success()), passwd_(join_response.passwd()), name_(join_response.myname()), err_(join_response.join_err()) { } std::string JoinResponseMessage::serializeAsString() { RaftMessage raft_message; auto join_response_ptr = raft_message.mutable_join_response(); join_response_ptr->set_success(success_); join_response_ptr->set_passwd(passwd_); join_response_ptr->set_myname(name_); join_response_ptr->set_join_err(err_); return raft_message.SerializeAsString(); } VoteRequestMessage::VoteRequestMessage(const uint64_t term, const uint64_t last_log_index, const uint64_t last_log_term) : term_(term), last_log_index_(last_log_index), last_log_term_(last_log_term) { } VoteRequestMessage::VoteRequestMessage(const raft_msg::VoteRequest &vote_request) : term_(vote_request.term()), last_log_index_(vote_request.last_log_index()), last_log_term_(vote_request.last_log_term()) { } std::string VoteRequestMessage::serializeAsString() { RaftMessage raft_message; auto vote_request_ptr = raft_message.mutable_vote_request(); vote_request_ptr->set_term(term_); vote_request_ptr->set_last_log_index(last_log_term_); vote_request_ptr->set_last_log_term(last_log_term_); return raft_message.SerializeAsString(); } VoteResponseMessage::VoteResponseMessage(const uint64_t term, const bool vote_granted) : term_(term), vote_granted_(vote_granted) { } VoteResponseMessage::VoteResponseMessage(const raft_msg::VoteResponse &vote_response) : term_(vote_response.term()), vote_granted_(vote_response.vote_granted()) { } std::string VoteResponseMessage::serializeAsString() { RaftMessage raft_message; auto vote_response_ptr = raft_message.mutable_vote_response(); vote_response_ptr->set_term(term_); vote_response_ptr->set_vote_granted(vote_granted_); return raft_message.SerializeAsString(); } } // namespace raft
37.805921
206
0.740625
zerolocusta
6109d1038242f8cce80a143b956b138ceae87ac5
10,613
hpp
C++
Lib/Chip/Unknown/STMicro/STM32F41x/I2C2.hpp
operativeF/Kvasir
dfbcbdc9993d326ef8cc73d99129e78459c561fd
[ "Apache-2.0" ]
null
null
null
Lib/Chip/Unknown/STMicro/STM32F41x/I2C2.hpp
operativeF/Kvasir
dfbcbdc9993d326ef8cc73d99129e78459c561fd
[ "Apache-2.0" ]
null
null
null
Lib/Chip/Unknown/STMicro/STM32F41x/I2C2.hpp
operativeF/Kvasir
dfbcbdc9993d326ef8cc73d99129e78459c561fd
[ "Apache-2.0" ]
null
null
null
#pragma once #include <Register/Utility.hpp> namespace Kvasir { //Inter-integrated circuit namespace I2c2Cr1{ ///<Control register 1 using Addr = Register::Address<0x40005800,0xffff4004,0x00000000,std::uint32_t>; ///Software reset constexpr Register::FieldLocation<Addr,Register::maskFromRange(15,15),Register::ReadWriteAccess,unsigned> swrst{}; ///SMBus alert constexpr Register::FieldLocation<Addr,Register::maskFromRange(13,13),Register::ReadWriteAccess,unsigned> alert{}; ///Packet error checking constexpr Register::FieldLocation<Addr,Register::maskFromRange(12,12),Register::ReadWriteAccess,unsigned> pec{}; ///Acknowledge/PEC Position (for data reception) constexpr Register::FieldLocation<Addr,Register::maskFromRange(11,11),Register::ReadWriteAccess,unsigned> pos{}; ///Acknowledge enable constexpr Register::FieldLocation<Addr,Register::maskFromRange(10,10),Register::ReadWriteAccess,unsigned> ack{}; ///Stop generation constexpr Register::FieldLocation<Addr,Register::maskFromRange(9,9),Register::ReadWriteAccess,unsigned> stop{}; ///Start generation constexpr Register::FieldLocation<Addr,Register::maskFromRange(8,8),Register::ReadWriteAccess,unsigned> start{}; ///Clock stretching disable (Slave mode) constexpr Register::FieldLocation<Addr,Register::maskFromRange(7,7),Register::ReadWriteAccess,unsigned> nostretch{}; ///General call enable constexpr Register::FieldLocation<Addr,Register::maskFromRange(6,6),Register::ReadWriteAccess,unsigned> engc{}; ///PEC enable constexpr Register::FieldLocation<Addr,Register::maskFromRange(5,5),Register::ReadWriteAccess,unsigned> enpec{}; ///ARP enable constexpr Register::FieldLocation<Addr,Register::maskFromRange(4,4),Register::ReadWriteAccess,unsigned> enarp{}; ///SMBus type constexpr Register::FieldLocation<Addr,Register::maskFromRange(3,3),Register::ReadWriteAccess,unsigned> smbtype{}; ///SMBus mode constexpr Register::FieldLocation<Addr,Register::maskFromRange(1,1),Register::ReadWriteAccess,unsigned> smbus{}; ///Peripheral enable constexpr Register::FieldLocation<Addr,Register::maskFromRange(0,0),Register::ReadWriteAccess,unsigned> pe{}; } namespace I2c2Cr2{ ///<Control register 2 using Addr = Register::Address<0x40005804,0xffffe0c0,0x00000000,std::uint32_t>; ///DMA last transfer constexpr Register::FieldLocation<Addr,Register::maskFromRange(12,12),Register::ReadWriteAccess,unsigned> last{}; ///DMA requests enable constexpr Register::FieldLocation<Addr,Register::maskFromRange(11,11),Register::ReadWriteAccess,unsigned> dmaen{}; ///Buffer interrupt enable constexpr Register::FieldLocation<Addr,Register::maskFromRange(10,10),Register::ReadWriteAccess,unsigned> itbufen{}; ///Event interrupt enable constexpr Register::FieldLocation<Addr,Register::maskFromRange(9,9),Register::ReadWriteAccess,unsigned> itevten{}; ///Error interrupt enable constexpr Register::FieldLocation<Addr,Register::maskFromRange(8,8),Register::ReadWriteAccess,unsigned> iterren{}; ///Peripheral clock frequency constexpr Register::FieldLocation<Addr,Register::maskFromRange(5,0),Register::ReadWriteAccess,unsigned> freq{}; } namespace I2c2Oar1{ ///<Own address register 1 using Addr = Register::Address<0x40005808,0xffff7c00,0x00000000,std::uint32_t>; ///Addressing mode (slave mode) constexpr Register::FieldLocation<Addr,Register::maskFromRange(15,15),Register::ReadWriteAccess,unsigned> addmode{}; ///Interface address constexpr Register::FieldLocation<Addr,Register::maskFromRange(9,8),Register::ReadWriteAccess,unsigned> add10{}; ///Interface address constexpr Register::FieldLocation<Addr,Register::maskFromRange(7,1),Register::ReadWriteAccess,unsigned> add7{}; ///Interface address constexpr Register::FieldLocation<Addr,Register::maskFromRange(0,0),Register::ReadWriteAccess,unsigned> add0{}; } namespace I2c2Oar2{ ///<Own address register 2 using Addr = Register::Address<0x4000580c,0xffffff00,0x00000000,std::uint32_t>; ///Interface address constexpr Register::FieldLocation<Addr,Register::maskFromRange(7,1),Register::ReadWriteAccess,unsigned> add2{}; ///Dual addressing mode enable constexpr Register::FieldLocation<Addr,Register::maskFromRange(0,0),Register::ReadWriteAccess,unsigned> endual{}; } namespace I2c2Dr{ ///<Data register using Addr = Register::Address<0x40005810,0xffffff00,0x00000000,std::uint32_t>; ///8-bit data register constexpr Register::FieldLocation<Addr,Register::maskFromRange(7,0),Register::ReadWriteAccess,unsigned> dr{}; } namespace I2c2Sr1{ ///<Status register 1 using Addr = Register::Address<0x40005814,0xffff2020,0x00000000,std::uint32_t>; ///SMBus alert constexpr Register::FieldLocation<Addr,Register::maskFromRange(15,15),Register::ReadWriteAccess,unsigned> smbalert{}; ///Timeout or Tlow error constexpr Register::FieldLocation<Addr,Register::maskFromRange(14,14),Register::ReadWriteAccess,unsigned> timeout{}; ///PEC Error in reception constexpr Register::FieldLocation<Addr,Register::maskFromRange(12,12),Register::ReadWriteAccess,unsigned> pecerr{}; ///Overrun/Underrun constexpr Register::FieldLocation<Addr,Register::maskFromRange(11,11),Register::ReadWriteAccess,unsigned> ovr{}; ///Acknowledge failure constexpr Register::FieldLocation<Addr,Register::maskFromRange(10,10),Register::ReadWriteAccess,unsigned> af{}; ///Arbitration lost (master mode) constexpr Register::FieldLocation<Addr,Register::maskFromRange(9,9),Register::ReadWriteAccess,unsigned> arlo{}; ///Bus error constexpr Register::FieldLocation<Addr,Register::maskFromRange(8,8),Register::ReadWriteAccess,unsigned> berr{}; ///Data register empty (transmitters) constexpr Register::FieldLocation<Addr,Register::maskFromRange(7,7),Register::Access<Register::AccessType::readOnly,Register::ReadActionType::normal,Register::ModifiedWriteValueType::normal>,unsigned> txe{}; ///Data register not empty (receivers) constexpr Register::FieldLocation<Addr,Register::maskFromRange(6,6),Register::Access<Register::AccessType::readOnly,Register::ReadActionType::normal,Register::ModifiedWriteValueType::normal>,unsigned> rxne{}; ///Stop detection (slave mode) constexpr Register::FieldLocation<Addr,Register::maskFromRange(4,4),Register::Access<Register::AccessType::readOnly,Register::ReadActionType::normal,Register::ModifiedWriteValueType::normal>,unsigned> stopf{}; ///10-bit header sent (Master mode) constexpr Register::FieldLocation<Addr,Register::maskFromRange(3,3),Register::Access<Register::AccessType::readOnly,Register::ReadActionType::normal,Register::ModifiedWriteValueType::normal>,unsigned> add10{}; ///Byte transfer finished constexpr Register::FieldLocation<Addr,Register::maskFromRange(2,2),Register::Access<Register::AccessType::readOnly,Register::ReadActionType::normal,Register::ModifiedWriteValueType::normal>,unsigned> btf{}; ///Address sent (master mode)/matched (slave mode) constexpr Register::FieldLocation<Addr,Register::maskFromRange(1,1),Register::Access<Register::AccessType::readOnly,Register::ReadActionType::normal,Register::ModifiedWriteValueType::normal>,unsigned> addr{}; ///Start bit (Master mode) constexpr Register::FieldLocation<Addr,Register::maskFromRange(0,0),Register::Access<Register::AccessType::readOnly,Register::ReadActionType::normal,Register::ModifiedWriteValueType::normal>,unsigned> sb{}; } namespace I2c2Sr2{ ///<Status register 2 using Addr = Register::Address<0x40005818,0xffff0008,0x00000000,std::uint32_t>; ///acket error checking register constexpr Register::FieldLocation<Addr,Register::maskFromRange(15,8),Register::ReadWriteAccess,unsigned> pec{}; ///Dual flag (Slave mode) constexpr Register::FieldLocation<Addr,Register::maskFromRange(7,7),Register::ReadWriteAccess,unsigned> dualf{}; ///SMBus host header (Slave mode) constexpr Register::FieldLocation<Addr,Register::maskFromRange(6,6),Register::ReadWriteAccess,unsigned> smbhost{}; ///SMBus device default address (Slave mode) constexpr Register::FieldLocation<Addr,Register::maskFromRange(5,5),Register::ReadWriteAccess,unsigned> smbdefault{}; ///General call address (Slave mode) constexpr Register::FieldLocation<Addr,Register::maskFromRange(4,4),Register::ReadWriteAccess,unsigned> gencall{}; ///Transmitter/receiver constexpr Register::FieldLocation<Addr,Register::maskFromRange(2,2),Register::ReadWriteAccess,unsigned> tra{}; ///Bus busy constexpr Register::FieldLocation<Addr,Register::maskFromRange(1,1),Register::ReadWriteAccess,unsigned> busy{}; ///Master/slave constexpr Register::FieldLocation<Addr,Register::maskFromRange(0,0),Register::ReadWriteAccess,unsigned> msl{}; } namespace I2c2Ccr{ ///<Clock control register using Addr = Register::Address<0x4000581c,0xffff3000,0x00000000,std::uint32_t>; ///I2C master mode selection constexpr Register::FieldLocation<Addr,Register::maskFromRange(15,15),Register::ReadWriteAccess,unsigned> fS{}; ///Fast mode duty cycle constexpr Register::FieldLocation<Addr,Register::maskFromRange(14,14),Register::ReadWriteAccess,unsigned> duty{}; ///Clock control register in Fast/Standard mode (Master mode) constexpr Register::FieldLocation<Addr,Register::maskFromRange(11,0),Register::ReadWriteAccess,unsigned> ccr{}; } namespace I2c2Trise{ ///<TRISE register using Addr = Register::Address<0x40005820,0xffffffc0,0x00000000,std::uint32_t>; ///Maximum rise time in Fast/Standard mode (Master mode) constexpr Register::FieldLocation<Addr,Register::maskFromRange(5,0),Register::ReadWriteAccess,unsigned> trise{}; } }
76.352518
218
0.708471
operativeF
610d74b748c83335239dac6f37f23ef2ecd2f6f4
1,411
cpp
C++
codesptb.cpp
ohmyjons/SPOJ-1
870ae3b072a3fbc89149b35fe5649a74512a8f60
[ "Unlicense" ]
264
2015-01-08T10:07:01.000Z
2022-03-26T04:11:51.000Z
codesptb.cpp
ohmyjons/SPOJ-1
870ae3b072a3fbc89149b35fe5649a74512a8f60
[ "Unlicense" ]
17
2016-04-15T03:38:07.000Z
2020-10-30T00:33:57.000Z
codesptb.cpp
ohmyjons/SPOJ-1
870ae3b072a3fbc89149b35fe5649a74512a8f60
[ "Unlicense" ]
127
2015-01-08T04:56:44.000Z
2022-02-25T18:40:37.000Z
// 2014-05-01 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define CUTOFF 30 using namespace std; int buf[200000]; int in() { char c; do c=getchar_unlocked(); while (c<=32); int res=0; do { res=(res<<1)+(res<<3)+c-'0'; c=getchar_unlocked(); } while (c>32); return res; } long long mergesort(int* begin,int* end) { long long res=0; if (end-begin<=CUTOFF) { for (int* i=begin; i<end; i++) for (int* j=begin; j<i; j++) if (*j>*i) res++; sort(begin,end); return res; } else //recursive { int* m=begin+(end-begin)/2; res+=mergesort(begin,m); res+=mergesort(m,end); int* i=begin; int* j=m; int* k=buf; while (i<m&&j<end) if (*i<=*j) { *k++=*i++; res+=(j-m); } else *k++=*j++; memcpy(k,i,(m-i)*sizeof(int)); k+=(m-i); res+=(j-m)*(m-i); memcpy(k,j,(end-j)*sizeof(int)); memcpy(begin,buf,(end-begin)*sizeof(int)); return res; } } int main() { int T,N,i; int a[200000]; T=in(); while (T--) { N=in(); for (i=0; i<N; i++) a[i]=in(); printf("%lld\n",mergesort(a,a+N)); } return 0; }
19.597222
66
0.425939
ohmyjons
6110bb50833f0c21dd6f306bd88923f11fdada6c
328
cc
C++
src/range.cc
xet7/JadeLib
f1b2d7d9179904103baf70c29b5029500fb55bf9
[ "MIT" ]
null
null
null
src/range.cc
xet7/JadeLib
f1b2d7d9179904103baf70c29b5029500fb55bf9
[ "MIT" ]
null
null
null
src/range.cc
xet7/JadeLib
f1b2d7d9179904103baf70c29b5029500fb55bf9
[ "MIT" ]
null
null
null
#include "include/jade.hpp" FUNCTION ARRAY<long> RANGE(long low, long high) { IF (low > high) THEN ABORT("Out of Bounds error in RANGE() function"); END IF (low > 0) high+=1; long array_size = high - low; ARRAY<long> v(array_size); std::iota (std::begin(v), std::end(v), low); return v; }
21.866667
57
0.594512
xet7
6110d4c021446f8d3d019f5f72622a1d51ab371f
255
cpp
C++
EJERCICIOS/Ejercicio 42/factura.cpp
alanmauri/CPP
6d5f0fa24f7d410e2a6caddd1ad01efe9380a3f5
[ "MIT" ]
null
null
null
EJERCICIOS/Ejercicio 42/factura.cpp
alanmauri/CPP
6d5f0fa24f7d410e2a6caddd1ad01efe9380a3f5
[ "MIT" ]
null
null
null
EJERCICIOS/Ejercicio 42/factura.cpp
alanmauri/CPP
6d5f0fa24f7d410e2a6caddd1ad01efe9380a3f5
[ "MIT" ]
null
null
null
#include <iostream> using namespace std; double subtotal; string listaProducto; void agregarProducto(string descripcion, int cantidad, double precio) { listaProducto = listaProducto + descripcion + '\n'; subtotal= subtotal(cantidad * precio); }
15.9375
69
0.752941
alanmauri
6113c5957d5d32655dedd690c6cb0f03d5964e21
997
cpp
C++
src/GameObject.cpp
Delpod/Asimo-s-Escape
4d2a599fcb17f4c76cfda45cb2c310bd01f66faa
[ "Zlib", "Apache-2.0" ]
1
2021-01-19T21:20:35.000Z
2021-01-19T21:20:35.000Z
src/GameObject.cpp
Delpod/Asimo-s-Escape
4d2a599fcb17f4c76cfda45cb2c310bd01f66faa
[ "Zlib", "Apache-2.0" ]
null
null
null
src/GameObject.cpp
Delpod/Asimo-s-Escape
4d2a599fcb17f4c76cfda45cb2c310bd01f66faa
[ "Zlib", "Apache-2.0" ]
null
null
null
#include "GameObject.h" #include "Game.h" GameObject::GameObject(sf::Texture &texture, sf::Vector2f position, sf::IntRect textureRect) : body(nullptr), deadly(false) { m_pSprite.setTexture(texture); m_pSprite.setPosition(position); m_pSprite.setTextureRect(textureRect); m_textureRect = textureRect; } sf::Sprite* GameObject::getSprite() { return &m_pSprite; } void GameObject::setTextureRect(sf::IntRect &textureRect) { m_pSprite.setTextureRect(textureRect); } void GameObject::createCollidable() { bodyDef = new b2BodyDef(); bodyDef->fixedRotation = true; bodyDef->position.Set(m_pSprite.getPosition().x / 32.0f, m_pSprite.getPosition().y / 32.0f); body = Game::Instance()->getWorld()->CreateBody(bodyDef); b2PolygonShape box; box.SetAsBox(m_pSprite.getLocalBounds().width / 64.0f, m_pSprite.getLocalBounds().height / 64.0f, b2Vec2(0.0f, 0.0f), 0.0f); body->CreateFixture(&box, 0.0f); m_pSprite.setPosition(body->GetPosition().x * 32.0f, body->GetPosition().y * 32.0f); }
31.15625
125
0.737212
Delpod
6114ae19ed5a7a6f1d33caf3ca2245d1ea2cd411
5,520
hpp
C++
engine/shadercompiler/src/includer.hpp
redstrate/prism
acb6c5306c6f60088744191f3d3d8713fc6950bd
[ "MIT" ]
18
2020-08-11T18:13:49.000Z
2022-03-08T21:42:54.000Z
engine/shadercompiler/src/includer.hpp
redstrate/prism
acb6c5306c6f60088744191f3d3d8713fc6950bd
[ "MIT" ]
11
2020-08-27T12:37:48.000Z
2022-02-21T05:17:03.000Z
engine/shadercompiler/src/includer.hpp
redstrate/prism
acb6c5306c6f60088744191f3d3d8713fc6950bd
[ "MIT" ]
1
2020-12-08T14:01:48.000Z
2020-12-08T14:01:48.000Z
// // Copyright (C) 2002-2005 3Dlabs Inc. Ltd. // Copyright (C) 2017 Google, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following // disclaimer in the documentation and/or other materials provided // with the distribution. // // Neither the name of 3Dlabs Inc. Ltd. nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // #pragma once #include <vector> #include <string> #include <fstream> #include <algorithm> #include <glslang/Public/ShaderLang.h> // Default include class for normal include convention of search backward // through the stack of active include paths (for nested includes). // Can be overridden to customize. class DirStackFileIncluder : public glslang::TShader::Includer { public: DirStackFileIncluder() : externalLocalDirectoryCount(0) { } IncludeResult* includeLocal(const char* headerName, const char* includerName, size_t inclusionDepth) override { return readLocalPath(headerName, includerName, (int)inclusionDepth); } IncludeResult* includeSystem(const char* headerName, const char* /*includerName*/, size_t /*inclusionDepth*/) override { return readSystemPath(headerName); } // Externally set directories. E.g., from a command-line -I<dir>. // - Most-recently pushed are checked first. // - All these are checked after the parse-time stack of local directories // is checked. // - This only applies to the "local" form of #include. // - Makes its own copy of the path. virtual void pushExternalLocalDirectory(const std::string& dir) { directoryStack.push_back(dir); externalLocalDirectoryCount = (int)directoryStack.size(); } void releaseInclude(IncludeResult* result) override { if (result != nullptr) { delete [] static_cast<tUserDataElement*>(result->userData); delete result; } } ~DirStackFileIncluder() override = default; protected: typedef char tUserDataElement; std::vector<std::string> directoryStack; int externalLocalDirectoryCount; // Search for a valid "local" path based on combining the stack of include // directories and the nominal name of the header. virtual IncludeResult* readLocalPath(const char* headerName, const char* includerName, int depth) { // Discard popped include directories, and // initialize when at parse-time first level. directoryStack.resize(depth + externalLocalDirectoryCount); if (depth == 1) directoryStack.back() = getDirectory(includerName); // Find a directory that works, using a reverse search of the include stack. for (auto it = directoryStack.rbegin(); it != directoryStack.rend(); ++it) { std::string path = *it + '/' + headerName; std::replace(path.begin(), path.end(), '\\', '/'); std::ifstream file(path, std::ios_base::binary | std::ios_base::ate); if (file) { directoryStack.push_back(getDirectory(path)); return newIncludeResult(path, file, (int)file.tellg()); } } return nullptr; } // Search for a valid <system> path. // Not implemented yet; returning nullptr signals failure to find. virtual IncludeResult* readSystemPath(const char* /*headerName*/) const { return nullptr; } // Do actual reading of the file, filling in a new include result. virtual IncludeResult* newIncludeResult(const std::string& path, std::ifstream& file, int length) const { char* content = new tUserDataElement [length]; file.seekg(0, file.beg); file.read(content, length); return new IncludeResult(path, content, length, content); } // If no path markers, return current working directory. // Otherwise, strip file name and return path leading up to it. virtual std::string getDirectory(const std::string) const { //return file::get_domain_path(file::domain::Internal).string(); return ""; } };
39.148936
107
0.669022
redstrate
61165c19c70dab51f3f78b9b3d2896f96b56cf8b
10,092
cpp
C++
LargeBarrelAnalysis/SignalFinderTools.cpp
flukson/j-pet-framework-examples
8f50490b5a21013990aff187fc6da87812a5f8e1
[ "Apache-2.0" ]
null
null
null
LargeBarrelAnalysis/SignalFinderTools.cpp
flukson/j-pet-framework-examples
8f50490b5a21013990aff187fc6da87812a5f8e1
[ "Apache-2.0" ]
null
null
null
LargeBarrelAnalysis/SignalFinderTools.cpp
flukson/j-pet-framework-examples
8f50490b5a21013990aff187fc6da87812a5f8e1
[ "Apache-2.0" ]
null
null
null
/** * @copyright Copyright 2016 The J-PET Framework Authors. All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may find a copy of the License in the LICENCE file. * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * @file SignalFinderToolsTools.cpp */ #include "SignalFinderTools.h" using namespace std; map<int, vector<JPetSigCh>> SignalFinderTools::getSigChsPMMapById(const JPetTimeWindow* timeWindow) { map<int, vector<JPetSigCh>> sigChsPMMap; if (!timeWindow) { WARNING("timeWindow pointer is not set"); return sigChsPMMap; } //map Signal Channels in this Time window according to PM they belong to const unsigned int nSigChs = timeWindow->getNumberOfEvents(); for (unsigned int i = 0; i < nSigChs; i++) { JPetSigCh sigCh = dynamic_cast<const JPetSigCh&>(timeWindow->operator[](i)); int pmt_id = sigCh.getPM().getID(); auto search = sigChsPMMap.find(pmt_id); if (search == sigChsPMMap.end()) { vector<JPetSigCh> tmp; tmp.push_back(sigCh); sigChsPMMap.insert(pair<int, vector<JPetSigCh>>(pmt_id, tmp)); } else { search->second.push_back(sigCh); } } return sigChsPMMap; } //method with loop of building raw signals for whole PM map vector<JPetRawSignal> SignalFinderTools::buildAllSignals( map<int, vector<JPetSigCh>> sigChsPMMap, unsigned int numOfThresholds, JPetStatistics& stats, bool saveControlHistos, double sigChEdgeMaxTime, double sigChLeadTrailMaxTime) { vector<JPetRawSignal> allSignals; for (auto& sigChPair : sigChsPMMap) { vector<JPetRawSignal> currentSignals = buildRawSignals(sigChPair.second, numOfThresholds, stats, saveControlHistos, sigChEdgeMaxTime, sigChLeadTrailMaxTime); allSignals.insert(allSignals.end(), currentSignals.begin(), currentSignals.end()); } return allSignals; } //sorting method bool sortByTimeValue(JPetSigCh sig1, JPetSigCh sig2) { return (sig1.getValue() < sig2.getValue()); } //method creating Raw signals form vector of Signal Channels vector<JPetRawSignal> SignalFinderTools::buildRawSignals( const vector<JPetSigCh>& sigChFromSamePM, unsigned int numOfThresholds, JPetStatistics& stats, bool saveControlHistos, double sigChEdgeMaxTime, double sigChLeadTrailMaxTime) { vector<JPetRawSignal> rawSigVec; //Threshold number check - fixed number equal 4 if (numOfThresholds != 4) { ERROR("This function is ment to work with 4 thresholds only!"); return rawSigVec; } vector<JPetSigCh> tmp; vector<vector<JPetSigCh>> thresholdSigCh(2 * numOfThresholds, tmp); bool errorOccured = false; //division into subvectors according to threshold number: //0-3 leading, 4-7 trailing for (const JPetSigCh& sigCh : sigChFromSamePM) { auto threshNum = sigCh.getThresholdNumber(); if ((threshNum <= 0) || (threshNum > 2 * numOfThresholds)) { ERROR("Threshold number out of range:" + std::to_string(threshNum)); errorOccured = true; break; } if (sigCh.getType() == JPetSigCh::Leading) { thresholdSigCh.at(sigCh.getThresholdNumber() - 1).push_back(sigCh); } else if (sigCh.getType() == JPetSigCh::Trailing) { thresholdSigCh.at(sigCh.getThresholdNumber() + numOfThresholds - 1) .push_back(sigCh); } } if (errorOccured) { return rawSigVec; } //probably not needed vector sorting according to Signal channel time values for (auto thrVec : thresholdSigCh) { sort(thrVec.begin(), thrVec.end(), sortByTimeValue); } assert(thresholdSigCh.size() > 0); while (thresholdSigCh.at(0).size() > 0) { JPetRawSignal rawSig; rawSig.setPM(thresholdSigCh.at(0).at(0).getPM()); rawSig.setBarrelSlot(thresholdSigCh.at(0).at(0).getPM().getBarrelSlot()); //first leading added by default rawSig.addPoint(thresholdSigCh.at(0).at(0)); //looking for points from other thresholds that belong to the same leading edge //and search for equivalent trailing edge points //first thr trailing assert(thresholdSigCh.at(0).size() > 0); assert(thresholdSigCh.size() > 4); int closestTrailingSigCh0 = findTrailingSigCh( thresholdSigCh.at(0).at(0), thresholdSigCh.at(4), sigChLeadTrailMaxTime); if (closestTrailingSigCh0 != -1) { rawSig.addPoint(thresholdSigCh.at(4).at(closestTrailingSigCh0)); thresholdSigCh.at(4).erase(thresholdSigCh.at(4).begin() + closestTrailingSigCh0); } //second thr leading and trailing int nextThrSigChIndex1 = findSigChOnNextThr( thresholdSigCh.at(0).at(0).getValue(), thresholdSigCh.at(1), sigChEdgeMaxTime); if (nextThrSigChIndex1 != -1) { int closestTrailingSigCh1 = findTrailingSigCh( thresholdSigCh.at(0).at(0), thresholdSigCh.at(5), sigChLeadTrailMaxTime); if (closestTrailingSigCh1 != -1) { rawSig.addPoint(thresholdSigCh.at(5).at(closestTrailingSigCh1)); thresholdSigCh.at(5).erase(thresholdSigCh.at(5).begin() + closestTrailingSigCh1); } rawSig.addPoint(thresholdSigCh.at(1).at(nextThrSigChIndex1)); thresholdSigCh.at(1).erase(thresholdSigCh.at(1).begin() + nextThrSigChIndex1); } //third thr leading and trailing int nextThrSigChIndex2 = findSigChOnNextThr( thresholdSigCh.at(0).at(0).getValue(), thresholdSigCh.at(2), sigChEdgeMaxTime); if (nextThrSigChIndex2 != -1) { int closestTrailingSigCh2 = findTrailingSigCh( thresholdSigCh.at(0).at(0), thresholdSigCh.at(6), sigChLeadTrailMaxTime); if (closestTrailingSigCh2 != -1) { rawSig.addPoint(thresholdSigCh.at(6).at(closestTrailingSigCh2)); thresholdSigCh.at(6).erase(thresholdSigCh.at(6).begin() + closestTrailingSigCh2); } rawSig.addPoint(thresholdSigCh.at(2).at(nextThrSigChIndex2)); thresholdSigCh.at(2).erase(thresholdSigCh.at(2).begin() + nextThrSigChIndex2); } //fourth thr leading and trailing int nextThrSigChIndex3 = findSigChOnNextThr( thresholdSigCh.at(0).at(0).getValue(), thresholdSigCh.at(3), sigChEdgeMaxTime); if (nextThrSigChIndex3 != -1) { int closestTrailingSigCh3 = findTrailingSigCh( thresholdSigCh.at(0).at(0), thresholdSigCh.at(7), sigChLeadTrailMaxTime); if (closestTrailingSigCh3 != -1) { rawSig.addPoint(thresholdSigCh.at(7).at(closestTrailingSigCh3)); thresholdSigCh.at(7).erase(thresholdSigCh.at(7).begin() + closestTrailingSigCh3); } rawSig.addPoint(thresholdSigCh.at(3).at(nextThrSigChIndex3)); thresholdSigCh.at(3).erase(thresholdSigCh.at(3).begin() + nextThrSigChIndex3); } //adding created Raw Signal to vector rawSigVec.push_back(rawSig); thresholdSigCh.at(0).erase(thresholdSigCh.at(0).begin() + 0); } //filling controll histograms if (saveControlHistos) { stats.getHisto1D("remainig_leading_sig_ch_per_thr") ->Fill(1, thresholdSigCh.at(0).size()); stats.getHisto1D("remainig_leading_sig_ch_per_thr") ->Fill(2, thresholdSigCh.at(1).size()); stats.getHisto1D("remainig_leading_sig_ch_per_thr") ->Fill(3, thresholdSigCh.at(2).size()); stats.getHisto1D("remainig_leading_sig_ch_per_thr") ->Fill(4, thresholdSigCh.at(3).size()); stats.getHisto1D("remainig_trailing_sig_ch_per_thr") ->Fill(1, thresholdSigCh.at(4).size()); stats.getHisto1D("remainig_trailing_sig_ch_per_thr") ->Fill(2, thresholdSigCh.at(5).size()); stats.getHisto1D("remainig_trailing_sig_ch_per_thr") ->Fill(3, thresholdSigCh.at(6).size()); stats.getHisto1D("remainig_trailing_sig_ch_per_thr") ->Fill(4, thresholdSigCh.at(7).size()); } return rawSigVec; } //method of finding Signal Channels that belong to the same leading edge //not more than sigChEdgeMaxTime away. Defined in ps. int SignalFinderTools::findSigChOnNextThr(Double_t sigChValue, const vector<JPetSigCh>& sigChVec, double sigChEdgeMaxTime) { for (size_t i = 0; i < sigChVec.size(); i++) { if (fabs(sigChValue - sigChVec.at(i).getValue()) < sigChEdgeMaxTime) { return i; } } return -1; } //method of finding trailing edge SigCh that suits certian leading edge SigCh //not further away than sigChLeadTrailMaxTime in ps //if more than one trailing edge SigCh found, returning one with the smallest index //that is equivalent of SigCh earliest in time int SignalFinderTools::findTrailingSigCh(const JPetSigCh& leadingSigCh, const vector<JPetSigCh>& trailingSigChVec, double sigChLeadTrailMaxTime) { vector<int> trailingFoundIdices; for (size_t i = 0; i < trailingSigChVec.size(); i++) { if (fabs(leadingSigCh.getValue() - trailingSigChVec.at(i).getValue()) < sigChLeadTrailMaxTime) trailingFoundIdices.push_back(i); } if (trailingFoundIdices.size() == 0) return -1; sort(trailingFoundIdices.begin(), trailingFoundIdices.end()); return trailingFoundIdices.at(0); }
36.565217
161
0.65329
flukson
61180eead96a97ab80ef88a0f44026a4380f1b2c
2,378
cpp
C++
SensorizerServer/MidiRepeater.cpp
DrumPants/Sensorizer-DrumPants-Firmware
dabd037bb7e475de574a1ebdb21734da075b21cb
[ "Apache-2.0" ]
9
2015-09-30T07:38:17.000Z
2020-01-17T12:35:15.000Z
SensorizerServer/MidiRepeater.cpp
DrumPants/Sensorizer-DrumPants-Firmware
dabd037bb7e475de574a1ebdb21734da075b21cb
[ "Apache-2.0" ]
1
2015-10-03T02:54:08.000Z
2015-10-03T03:09:38.000Z
SensorizerServer/MidiRepeater.cpp
DrumPants/Sensorizer-DrumPants-Firmware
dabd037bb7e475de574a1ebdb21734da075b21cb
[ "Apache-2.0" ]
1
2018-07-10T00:43:47.000Z
2018-07-10T00:43:47.000Z
/** * Copyright 2011-2015 DrumPants, Inc. * * http://developers.drumpants.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "MidiRepeater.h" MidiRepeater::MidiRepeater() { //#if IS_DRUMPANTS // also send to BLE Serial1.begin(BAUD_RATE_BLUETOOTH_LE); //#endif #if ENABLE_USB_MIDI #endif } void MidiRepeater::onSendOutput(byte cmd, byte data1, byte data2) { sendTo(true, cmd, data1, data2); sendTo(false, cmd, data1, data2); } void MidiRepeater::sendTo(bool isBle, byte cmd, byte data1, byte data2) { //Some commands only have one data byte. All cmds less than 0xBn have 2 data bytes //(sort of: http://253.ccarh.org/handout/midiprotocol/) //if( (cmd & 0xF0) <= 0xB0) bool hasSecondArg = ((cmd & 0xF0) <= 0xB0 || (cmd & 0xF0) == 0xE0); //DEBUG_PRINT_NUM("Send to BLE: ", cmd); //#if IS_DRUMPANTS if (isBle) { // also send to BLE Serial1.write(cmd); Serial1.write(data1); if (hasSecondArg) { Serial1.write(data2); } #if ENABLE_USB_MIDI // support for 32-byte class-compliant USB MIDI packets. (DrumPants 2.0) // we send these same as the BLE MIDI, since TranslatingMidiRepeater will send the actual notes, not the sensor IDX, through the MIDI. // we want the actual notes. The sensor IDX should only be sent over serial to the DrumPants 1.0 app. byte status = (cmd & 0xF0); byte header = (status >> 4) & 0x0F; // class-compliant USB MIDI packets must ALWAYS be 32-bytes, zero padded. so we send data2 no matter what. uint8_t midiPacket[] = {header, cmd, data1, data2}; MidiUSB.write(midiPacket, 4); #endif } #if ENABLE_SENDING_MIDI_OVER_USB else { // also send to USB, normal Serial style. (for DrumPants 1.0 app) SerialUSB.write(cmd); SerialUSB.write(data1); if (hasSecondArg) { SerialUSB.write(data2); } } #endif //#endif }
25.031579
136
0.688394
DrumPants
611bb6305af983ebbfc4cec9968b57488a186514
161
cpp
C++
volume4/1327_18Mar2006_1122206.cpp
andriybuday/timus
a5cdc03f3ca8e7878220b8e0a0c72343f98ee1eb
[ "MIT" ]
null
null
null
volume4/1327_18Mar2006_1122206.cpp
andriybuday/timus
a5cdc03f3ca8e7878220b8e0a0c72343f98ee1eb
[ "MIT" ]
null
null
null
volume4/1327_18Mar2006_1122206.cpp
andriybuday/timus
a5cdc03f3ca8e7878220b8e0a0c72343f98ee1eb
[ "MIT" ]
null
null
null
#include <iostream> using namespace std; int main(){ int A, B; cin>>A>>B; if(!(A%2) && !(B%2)){ cout<<(B-A)/2; }else cout<<(B-A)/2 + 1; return 0; }
10.733333
22
0.503106
andriybuday
611d63c817bdc6f56c96bbbe0caf6269e9906993
862
hxx
C++
mod/mod-packages.hxx
build2/brep
d259750511b3c2aaeace49f8ccb1d7f3ad561452
[ "MIT" ]
9
2018-05-30T12:01:14.000Z
2021-04-02T21:21:10.000Z
mod/mod-packages.hxx
build2/brep
d259750511b3c2aaeace49f8ccb1d7f3ad561452
[ "MIT" ]
2
2021-03-28T14:13:39.000Z
2022-01-24T12:57:57.000Z
mod/mod-packages.hxx
build2/brep
d259750511b3c2aaeace49f8ccb1d7f3ad561452
[ "MIT" ]
2
2019-01-09T12:09:39.000Z
2022-03-06T18:43:07.000Z
// file : mod/mod-packages.hxx -*- C++ -*- // license : MIT; see accompanying LICENSE file #ifndef MOD_MOD_PACKAGES_HXX #define MOD_MOD_PACKAGES_HXX #include <libbrep/types.hxx> #include <libbrep/utility.hxx> #include <mod/module-options.hxx> #include <mod/database-module.hxx> namespace brep { class packages: public database_module { public: packages () = default; // Create a shallow copy (handling instance) if initialized and a deep // copy (context exemplar) otherwise. // explicit packages (const packages&); virtual bool handle (request&, response&); virtual const cli::options& cli_options () const {return options::packages::description ();} private: virtual void init (cli::scanner&); private: shared_ptr<options::packages> options_; }; } #endif // MOD_MOD_PACKAGES_HXX
20.52381
74
0.682135
build2
611fe0436a01041dcf73fb89094f3286971f4435
1,326
cpp
C++
test/gl/image_test.cpp
Harrand/Topaz-2
c3cd3f67b1aaf20229075a593c8ffcad5585f362
[ "Apache-2.0" ]
null
null
null
test/gl/image_test.cpp
Harrand/Topaz-2
c3cd3f67b1aaf20229075a593c8ffcad5585f362
[ "Apache-2.0" ]
9
2019-12-22T17:57:29.000Z
2020-03-30T22:06:53.000Z
test/gl/image_test.cpp
Harrand/Topaz-2
c3cd3f67b1aaf20229075a593c8ffcad5585f362
[ "Apache-2.0" ]
null
null
null
// // Created by Harrand on 04/01/2020. // #include "test_framework.hpp" #include "core/core.hpp" #include "core/tz_glad/glad_context.hpp" #include "gl/image.hpp" tz::test::Case checkerboard() { tz::test::Case test_case("tz::gl::Image Checkerboard Tests"); tz::gl::PixelRGBA8 black_pixel{std::byte{}, std::byte{}, std::byte{}, std::byte{255}}; tz::gl::PixelRGBA8 white_pixel{std::byte{255}, std::byte{255}, std::byte{255}, std::byte{255}}; tz::gl::Image<tz::gl::PixelRGBA8> rgba_checkerboard{2, 2}; rgba_checkerboard(0, 0) = black_pixel; rgba_checkerboard(1, 0) = white_pixel; rgba_checkerboard(0, 1) = white_pixel; rgba_checkerboard(1, 1) = black_pixel; topaz_expect(test_case, black_pixel != white_pixel, "Can't tell the difference between black and white pixel."); auto* data = rgba_checkerboard.data(); topaz_expect(test_case, *(data + 0) == black_pixel, "Pixel mismatch"); topaz_expect(test_case, *(data + 1) == white_pixel, "Pixel mismatch"); topaz_expect(test_case, *(data + 2) == white_pixel, "Pixel mismatch"); topaz_expect(test_case, *(data + 3) == black_pixel, "Pixel mismatch"); return test_case; } int main() { tz::test::Unit img; // We require topaz to be initialised. { tz::core::initialise("Image Tests"); img.add(checkerboard()); tz::core::terminate(); } return img.result(); }
31.571429
113
0.696833
Harrand
61230c0d3a9f3e2f6608027e89291572aa254335
8,737
cc
C++
tests/libtests/feassemble/obsolete/TestElasticityExplicitLgDeformCases.cc
Grant-Block/pylith
f6338261b17551eba879da998a5aaf2d91f5f658
[ "MIT" ]
93
2015-01-08T16:41:22.000Z
2022-02-25T13:40:02.000Z
tests/libtests/feassemble/obsolete/TestElasticityExplicitLgDeformCases.cc
Grant-Block/pylith
f6338261b17551eba879da998a5aaf2d91f5f658
[ "MIT" ]
277
2015-02-20T16:27:35.000Z
2022-03-30T21:13:09.000Z
tests/libtests/feassemble/obsolete/TestElasticityExplicitLgDeformCases.cc
Grant-Block/pylith
f6338261b17551eba879da998a5aaf2d91f5f658
[ "MIT" ]
71
2015-03-24T12:11:08.000Z
2022-03-03T04:26:02.000Z
// -*- C++ -*- // // ---------------------------------------------------------------------- // // Brad T. Aagaard, U.S. Geological Survey // Charles A. Williams, GNS Science // Matthew G. Knepley, University of Chicago // // This code was developed as part of the Computational Infrastructure // for Geodynamics (http://geodynamics.org). // // Copyright (c) 2010-2017 University of California, Davis // // See COPYING for license information. // // ---------------------------------------------------------------------- // #include <portinfo> #include "TestElasticityExplicitLgDeformCases.hh" // Implementation of class methods #include "pylith/topology/Mesh.hh" // USES Quadrature<Mesh> #include "pylith/feassemble/Quadrature.hh" // USES Quadrature #include "pylith/feassemble/GeometryTri2D.hh" // USES GeometryTri2D #include "pylith/feassemble/GeometryTet3D.hh" // USES GeometryTet3D #include "pylith/materials/ElasticPlaneStrain.hh" // USES ElasticPlaneStrain #include "pylith/materials/ElasticIsotropic3D.hh" // USES ElasticIsotropic3D #include "spatialdata/spatialdb/GravityField.hh" // USES GravityField // ---------------------------------------------------------------------- #include "data/ElasticityExplicitLgDeformData2DLinear.hh" CPPUNIT_TEST_SUITE_REGISTRATION( pylith::feassemble::TestElasticityExplicitLgDeform2DLinear ); // Setup testing data. void pylith::feassemble::TestElasticityExplicitLgDeform2DLinear::setUp(void) { // setUp TestElasticityExplicitLgDeform::setUp(); _data = new ElasticityExplicitLgDeformData2DLinear(); _gravityField = 0; CPPUNIT_ASSERT(_quadrature); GeometryTri2D geometry; _quadrature->refGeometry(&geometry); _material = new materials::ElasticPlaneStrain; CPPUNIT_ASSERT(_material); CPPUNIT_ASSERT(_data); CPPUNIT_ASSERT_EQUAL(std::string("ElasticPlaneStrain"), std::string(_data->matType)); } // setUp // ---------------------------------------------------------------------- #include "data/ElasticityExplicitLgDeformData2DQuadratic.hh" // :TODO: Update after removing FIAT //CPPUNIT_TEST_SUITE_REGISTRATION( pylith::feassemble::TestElasticityExplicitLgDeform2DQuadratic ); // Setup testing data. void pylith::feassemble::TestElasticityExplicitLgDeform2DQuadratic::setUp(void) { // setUp TestElasticityExplicitLgDeform::setUp(); _data = new ElasticityExplicitLgDeformData2DQuadratic(); _gravityField = 0; CPPUNIT_ASSERT(_quadrature); GeometryTri2D geometry; _quadrature->refGeometry(&geometry); _material = new materials::ElasticPlaneStrain; CPPUNIT_ASSERT(_material); CPPUNIT_ASSERT(_data); CPPUNIT_ASSERT_EQUAL(std::string("ElasticPlaneStrain"), std::string(_data->matType)); } // setUp // ---------------------------------------------------------------------- #include "data/ElasticityExplicitLgDeformData3DLinear.hh" CPPUNIT_TEST_SUITE_REGISTRATION( pylith::feassemble::TestElasticityExplicitLgDeform3DLinear ); // Setup testing data. void pylith::feassemble::TestElasticityExplicitLgDeform3DLinear::setUp(void) { // setUp TestElasticityExplicitLgDeform::setUp(); _data = new ElasticityExplicitLgDeformData3DLinear(); _gravityField = 0; CPPUNIT_ASSERT(_quadrature); GeometryTet3D geometry; _quadrature->refGeometry(&geometry); _material = new materials::ElasticIsotropic3D; CPPUNIT_ASSERT(_material); CPPUNIT_ASSERT(_data); CPPUNIT_ASSERT_EQUAL(std::string("ElasticIsotropic3D"), std::string(_data->matType)); } // setUp // ---------------------------------------------------------------------- #include "data/ElasticityExplicitLgDeformData3DQuadratic.hh" // :TODO: Update after removing FIAT //CPPUNIT_TEST_SUITE_REGISTRATION( pylith::feassemble::TestElasticityExplicitLgDeform3DQuadratic ); // Setup testing data. void pylith::feassemble::TestElasticityExplicitLgDeform3DQuadratic::setUp(void) { // setUp TestElasticityExplicitLgDeform::setUp(); _data = new ElasticityExplicitLgDeformData3DQuadratic(); _gravityField = 0; CPPUNIT_ASSERT(_quadrature); GeometryTet3D geometry; _quadrature->refGeometry(&geometry); _material = new materials::ElasticIsotropic3D; CPPUNIT_ASSERT(_material); CPPUNIT_ASSERT(_data); CPPUNIT_ASSERT_EQUAL(std::string("ElasticIsotropic3D"), std::string(_data->matType)); } // setUp // ---------------------------------------------------------------------- #include "data/ElasticityExplicitLgDeformGravData2DLinear.hh" CPPUNIT_TEST_SUITE_REGISTRATION( pylith::feassemble::TestElasticityExplicitLgDeformGrav2DLinear ); // Setup testing data. void pylith::feassemble::TestElasticityExplicitLgDeformGrav2DLinear::setUp(void) { // setUp TestElasticityExplicitLgDeform::setUp(); _data = new ElasticityExplicitLgDeformGravData2DLinear(); _gravityField = new spatialdata::spatialdb::GravityField(); CPPUNIT_ASSERT(_quadrature); CPPUNIT_ASSERT(_gravityField); GeometryTri2D geometry; _quadrature->refGeometry(&geometry); const PylithScalar accScale = _data->lengthScale / (_data->timeScale * _data->timeScale); const PylithScalar g = 1.0e8 / accScale; const PylithScalar gravityDir[] = { 0.0, -1.0, 0.0 }; _gravityField->gravityAcc(g); _gravityField->gravityDir(gravityDir[0], gravityDir[1], gravityDir[2]); _material = new materials::ElasticPlaneStrain; CPPUNIT_ASSERT(_material); CPPUNIT_ASSERT(_data); CPPUNIT_ASSERT_EQUAL(std::string("ElasticPlaneStrain"), std::string(_data->matType)); } // setUp // ---------------------------------------------------------------------- #include "data/ElasticityExplicitLgDeformGravData2DQuadratic.hh" // :TODO: Update after removing FIAT //CPPUNIT_TEST_SUITE_REGISTRATION( pylith::feassemble::TestElasticityExplicitLgDeformGrav2DQuadratic ); // Setup testing data. void pylith::feassemble::TestElasticityExplicitLgDeformGrav2DQuadratic::setUp(void) { // setUp TestElasticityExplicitLgDeform::setUp(); _data = new ElasticityExplicitLgDeformGravData2DQuadratic(); _gravityField = new spatialdata::spatialdb::GravityField(); CPPUNIT_ASSERT(_quadrature); CPPUNIT_ASSERT(_gravityField); GeometryTri2D geometry; _quadrature->refGeometry(&geometry); const PylithScalar accScale = _data->lengthScale / (_data->timeScale * _data->timeScale); const PylithScalar g = 1.0e8 / accScale; const PylithScalar gravityDir[] = { 0.0, -1.0, 0.0 }; _gravityField->gravityAcc(g); _gravityField->gravityDir(gravityDir[0], gravityDir[1], gravityDir[2]); _material = new materials::ElasticPlaneStrain; CPPUNIT_ASSERT(_material); CPPUNIT_ASSERT(_data); CPPUNIT_ASSERT_EQUAL(std::string("ElasticPlaneStrain"), std::string(_data->matType)); } // setUp // ---------------------------------------------------------------------- #include "data/ElasticityExplicitLgDeformGravData3DLinear.hh" CPPUNIT_TEST_SUITE_REGISTRATION( pylith::feassemble::TestElasticityExplicitLgDeformGrav3DLinear ); // Setup testing data. void pylith::feassemble::TestElasticityExplicitLgDeformGrav3DLinear::setUp(void) { // setUp TestElasticityExplicitLgDeform::setUp(); _data = new ElasticityExplicitLgDeformGravData3DLinear(); _gravityField = new spatialdata::spatialdb::GravityField(); CPPUNIT_ASSERT(_quadrature); CPPUNIT_ASSERT(_gravityField); GeometryTet3D geometry; _quadrature->refGeometry(&geometry); const PylithScalar accScale = _data->lengthScale / (_data->timeScale * _data->timeScale); const PylithScalar g = 1.0e8 / accScale; _gravityField->gravityAcc(g); _material = new materials::ElasticIsotropic3D; CPPUNIT_ASSERT(_material); CPPUNIT_ASSERT(_data); CPPUNIT_ASSERT_EQUAL(std::string("ElasticIsotropic3D"), std::string(_data->matType)); } // setUp // ---------------------------------------------------------------------- #include "data/ElasticityExplicitLgDeformGravData3DQuadratic.hh" // :TODO: Update after removing FIAT //CPPUNIT_TEST_SUITE_REGISTRATION( pylith::feassemble::TestElasticityExplicitLgDeformGrav3DQuadratic ); // Setup testing data. void pylith::feassemble::TestElasticityExplicitLgDeformGrav3DQuadratic::setUp(void) { // setUp TestElasticityExplicitLgDeform::setUp(); _data = new ElasticityExplicitLgDeformGravData3DQuadratic(); _gravityField = new spatialdata::spatialdb::GravityField(); CPPUNIT_ASSERT(_quadrature); CPPUNIT_ASSERT(_gravityField); GeometryTet3D geometry; _quadrature->refGeometry(&geometry); const PylithScalar accScale = _data->lengthScale / (_data->timeScale * _data->timeScale); const PylithScalar g = 1.0e8 / accScale; _gravityField->gravityAcc(g); _material = new materials::ElasticIsotropic3D; CPPUNIT_ASSERT(_material); CPPUNIT_ASSERT(_data); CPPUNIT_ASSERT_EQUAL(std::string("ElasticIsotropic3D"), std::string(_data->matType)); } // setUp // End of file
34.262745
103
0.717409
Grant-Block
6123a40f9c31834647fdf416cd0cada805900218
10,297
cpp
C++
Tests/DisplayModeSelectionTest/main.cpp
HermanLederer/gtaRenderHook
2ce53ce954c2d298717119dd6d02a2e58fff3aed
[ "MIT" ]
null
null
null
Tests/DisplayModeSelectionTest/main.cpp
HermanLederer/gtaRenderHook
2ce53ce954c2d298717119dd6d02a2e58fff3aed
[ "MIT" ]
null
null
null
Tests/DisplayModeSelectionTest/main.cpp
HermanLederer/gtaRenderHook
2ce53ce954c2d298717119dd6d02a2e58fff3aed
[ "MIT" ]
null
null
null
#include <Engine/Common/ISwapchain.h> #include <Engine/D3D11Impl/D3D11DeviceState.h> #include <Engine/IRenderer.h> #include <Engine/VulkanImpl/VulkanDeviceState.h> #include <Engine/VulkanImpl/VulkanShader.h> #include <TestUtils\WindowsSampleWrapper.h> #include <memory> std::unique_ptr<rh::engine::IRenderer> rh::engine::g_pRHRenderer; class DisplayModeTest : public rh::tests::TestSample { public: DisplayModeTest( rh::engine::RenderingAPI api, HINSTANCE inst ) : rh::tests::TestSample( api, inst ) { } bool Initialize( HWND wnd ) override; rh::engine::IFrameBuffer * GetFramebufferForFrame( const rh::engine::SwapchainFrame &frame ); private: rh::engine::IDeviceState *mDeviceState = nullptr; rh::engine::IWindow * mDeviceWindow = nullptr; // rh::engine::ICommandBuffer *mCmdBuffer = nullptr; rh::engine::ISyncPrimitive *mRenderExecute = nullptr; // Per-Frame resources rh::engine::ISyncPrimitive * mImageAquire = nullptr; std::array<rh::engine::IFrameBuffer *, 2> mFrameBuffer{nullptr, nullptr}; // rh::engine::IRenderPass *mRenderPass = nullptr; // rh::engine::IPipeline *m2DPipeline = nullptr; // rh::engine::IBuffer *mVertexBuffer = nullptr; // TestSample interface public: void CustomShutdown() override; // TestSample interface public: void CustomRender() override; }; rh::engine::IFrameBuffer *DisplayModeTest::GetFramebufferForFrame( const rh::engine::SwapchainFrame &frame ) { if ( mFrameBuffer[frame.mImageId] == nullptr ) { std::vector<rh::engine::IImageView *> img_views{frame.mImageView}; rh::engine::FrameBufferCreateParams create_params{}; create_params.width = frame.mWidth; create_params.height = frame.mHeight; create_params.imageViews = img_views; create_params.renderPass = mRenderPass; mFrameBuffer[frame.mImageId] = mDeviceState->CreateFrameBuffer( create_params ); } return mFrameBuffer[frame.mImageId]; } bool DisplayModeTest::Initialize( HWND window ) { mDeviceState = new rh::engine::VulkanDeviceState(); unsigned int adapter_count; assert( mDeviceState->GetAdaptersCount( adapter_count ) ); unsigned int output_count; assert( mDeviceState->GetOutputCount( 0, output_count ) ); unsigned int display_mode_count; assert( mDeviceState->GetDisplayModeCount( 0, display_mode_count ) ); mDeviceState->Init(); rh::engine::DisplayModeInfo dm_info{}; auto r = mDeviceState->GetDisplayModeInfo( 0, dm_info ); assert( r ); rh::engine::OutputInfo info{}; info.displayModeId = 0; info.windowed = true; mDeviceWindow = mDeviceState->CreateDeviceWindow( window, info ); mCmdBuffer = mDeviceState->GetMainCommandBuffer(); mImageAquire = mDeviceState->CreateSyncPrimitive( rh::engine::SyncPrimitiveType::GPU ); mRenderExecute = mDeviceState->CreateSyncPrimitive( rh::engine::SyncPrimitiveType::GPU ); // Basic render pass rh::engine::RenderPassCreateParams render_pass_desc{}; rh::engine::AttachmentDescription render_pass_color_desc{}; render_pass_color_desc.mFormat = rh::engine::ImageBufferFormat::BGRA8; render_pass_color_desc.mSrcLayout = rh::engine::ImageLayout::Undefined; render_pass_color_desc.mDestLayout = rh::engine::ImageLayout::PresentSrc; render_pass_color_desc.mLoadOp = rh::engine::LoadOp::Clear; render_pass_color_desc.mStoreOp = rh::engine::StoreOp::Store; render_pass_color_desc.mStencilLoadOp = rh::engine::LoadOp::DontCare; render_pass_color_desc.mStencilStoreOp = rh::engine::StoreOp::DontCare; render_pass_desc.mAttachments.push_back( render_pass_color_desc ); rh::engine::SubpassDescription main_subpass{}; rh::engine::AttachmentRef color_attach_ref{}; color_attach_ref.mReqLayout = rh::engine::ImageLayout::ColorAttachment; main_subpass.mBindPoint = rh::engine::PipelineBindPoint::Graphics; main_subpass.mColorAttachments.push_back( color_attach_ref ); render_pass_desc.mSubpasses.push_back( main_subpass ); mRenderPass = mDeviceState->CreateRenderPass( render_pass_desc ); rh::engine::ShaderDesc vs_desc{}; vs_desc.mShaderPath = "Im2D.hlsl"; vs_desc.mEntryPoint = "BaseVS"; vs_desc.mShaderStage = rh::engine::ShaderStage::Vertex; auto vs_shader = mDeviceState->CreateShader( vs_desc ); rh::engine::ShaderDesc ps_desc{}; ps_desc.mShaderPath = "Im2D.hlsl"; ps_desc.mEntryPoint = "NoTexPS"; ps_desc.mShaderStage = rh::engine::ShaderStage::Pixel; auto ps_shader = mDeviceState->CreateShader( ps_desc ); rh::engine::ShaderStageDesc vs_stage_desc{}; vs_stage_desc.mShader = vs_shader; vs_stage_desc.mStage = vs_desc.mShaderStage; vs_stage_desc.mEntryPoint = vs_desc.mEntryPoint; rh::engine::ShaderStageDesc ps_stage_desc{}; ps_stage_desc.mShader = ps_shader; ps_stage_desc.mStage = ps_desc.mShaderStage; ps_stage_desc.mEntryPoint = ps_desc.mEntryPoint; rh::engine::PipelineCreateParams pipe_create_params{}; pipe_create_params.mRenderPass = mRenderPass; pipe_create_params.mShaderStages.push_back( vs_stage_desc ); pipe_create_params.mShaderStages.push_back( ps_stage_desc ); m2DPipeline = mDeviceState->CreatePipeline( pipe_create_params ); struct VertexDesc { float x, y, z, w; uint32_t color; float u, v; }; std::vector<VertexDesc> triangle_verticles = { {0, 0, 0, 1, // pos 0xFFFFFFFF, // color 0, 0}, // v0 {0, 720, 0, 1, // pos 0xFFFF0000, // color 0, 0}, // v1 {1280, 0, 0, 1, // pos 0xFF0000FF, // color 0, 0}, // v2 {1280, 0, 0, 1, // pos 0xFF00FF00, // color 0, 0}, // v3 {1280, 720, 0, 1, // pos 0xFFFF0000, // color 0, 0}, // v4 {0, 720, 0, 1, // pos 0xFFFF00FF, // color 0, 0} // v5 }; rh::engine::BufferCreateInfo v_buff_create_info{}; v_buff_create_info.mSize = sizeof( VertexDesc ) * triangle_verticles.size(); v_buff_create_info.mUsage = rh::engine::BufferUsage::VertexBuffer; mVertexBuffer = mDeviceState->CreateBuffer( v_buff_create_info ); mVertexBuffer->Update( triangle_verticles.data(), v_buff_create_info.mSize ); delete vs_shader; delete ps_shader; return true; } void DisplayModeTest::CustomRender() { auto [swapchain, invalidate_framebuffers] = mDeviceWindow->GetSwapchain(); if ( invalidate_framebuffers ) { for ( auto fb : mFrameBuffer ) delete fb; mFrameBuffer[0] = mFrameBuffer[1] = nullptr; } auto frame = swapchain->GetAvaliableFrame( mImageAquire ); // Record frame mCmdBuffer->BeginRecord(); rh::engine::RenderPassBeginInfo info{}; info.m_pRenderPass = mRenderPass; info.m_pFrameBuffer = GetFramebufferForFrame( frame ); info.m_aClearValues = { {rh::engine::ClearValueType::Color, {0, 0, 128, 0xFF}, {}}}; mCmdBuffer->BeginRenderPass( info ); auto fb_info = info.m_pFrameBuffer->GetInfo(); mCmdBuffer->SetViewports( 0, {rh::engine::ViewPort{ 0, // float topLeftX; 0, // float topLeftY; static_cast<float>( fb_info.width ), // float width; static_cast<float>( fb_info.height ), // float height; 0, // float minDepth; 1.0 // float maxDepth; }} ); mCmdBuffer->SetScissors( 0, {rh::engine::Scissor{ 0, // float topLeftX; 0, // float topLeftY; fb_info.width, // float width; fb_info.height // float height; }} ); mCmdBuffer->BindPipeline( m2DPipeline ); mCmdBuffer->BindVertexBuffers( 0, {{mVertexBuffer, 0}} ); mCmdBuffer->Draw( 6, 1, 0, 0 ); mCmdBuffer->EndRenderPass(); mCmdBuffer->EndRecord(); // Submit command buffer mDeviceState->ExecuteCommandBuffer( mCmdBuffer, mImageAquire, mRenderExecute ); swapchain->Present( frame, mRenderExecute ); std::vector<rh::engine::ISyncPrimitive *> exec_prim_list = { mCmdBuffer->ExecutionFinishedPrimitive()}; mDeviceState->Wait( exec_prim_list ); static bool res_switch = true; if ( res_switch ) { rh::engine::DisplayModeInfo dm_info{}; mDeviceState->GetDisplayModeInfo( 25, dm_info ); rh::engine::WindowParams params{}; params.mWidth = dm_info.width; params.mHeight = dm_info.height; mDeviceWindow->SetWindowParams( params ); res_switch = false; } } void DisplayModeTest::CustomShutdown() { delete mVertexBuffer; delete m2DPipeline; delete mRenderPass; for ( auto fb : mFrameBuffer ) delete fb; delete mImageAquire; delete mRenderExecute; delete mDeviceWindow; mDeviceState->Shutdown(); delete mDeviceState; } int APIENTRY wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow ) { UNREFERENCED_PARAMETER( hPrevInstance ); UNREFERENCED_PARAMETER( lpCmdLine ); UNREFERENCED_PARAMETER( nCmdShow ); // Window params initialization rh::tests::WindowsSampleParams initParams; initParams.instance = hInstance; initParams.sampleTitle = TEXT( "DisplayModeTest" ); initParams.windowClass = TEXT( "DISPLAYMODETEST" ); rh::tests::WindowsSampleWrapper sample( initParams, std::make_unique<DisplayModeTest>( rh::engine::RenderingAPI::Vulkan, hInstance ) ); // Initialize test sample. if ( !sample.Init() ) return FALSE; // Run test sample! sample.Run(); return TRUE; }
33.760656
80
0.637953
HermanLederer
612443f025657703c144c9d5c877c3c5c9eabc1e
1,647
cpp
C++
src/renderer/test/hlsl/struct.cpp
Ryp/reaper
da7b3aa4a69b95ced2496214e5cea4eb7823593a
[ "MIT" ]
10
2018-08-16T05:32:46.000Z
2022-02-04T09:55:54.000Z
src/renderer/test/hlsl/struct.cpp
Ryp/reaper
da7b3aa4a69b95ced2496214e5cea4eb7823593a
[ "MIT" ]
null
null
null
src/renderer/test/hlsl/struct.cpp
Ryp/reaper
da7b3aa4a69b95ced2496214e5cea4eb7823593a
[ "MIT" ]
1
2019-05-13T17:56:35.000Z
2019-05-13T17:56:35.000Z
//////////////////////////////////////////////////////////////////////////////// /// Reaper /// /// Copyright (c) 2015-2021 Thibault Schueller /// This file is distributed under the MIT License //////////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include <doctest/doctest.h> #include "renderer/hlsl/Types.h" constexpr u32 vector4_size = 16; TEST_CASE("HLSL structs") { SUBCASE("simple") { struct test1 { hlsl_float a; hlsl_float b; hlsl_float c; hlsl_float d; }; static_assert(sizeof(test1) == vector4_size); struct test2 { hlsl_int2 a; hlsl_float2 b; }; static_assert(sizeof(test2) == vector4_size); struct test3 { hlsl_uint4 a; hlsl_float4 b; }; static_assert(sizeof(test3) == 2 * vector4_size); } SUBCASE("advanced") { struct test1 { hlsl_float b; hlsl_float c; hlsl_float2 d; }; static_assert(sizeof(test1) == vector4_size); struct test2 { hlsl_float4x4 b; hlsl_float c; }; static_assert(sizeof(test2) == 5 * vector4_size); struct test3 { hlsl_float2 c; hlsl_float d; hlsl_float f; hlsl_float3x3 b; hlsl_float3 g; hlsl_float h; hlsl_float4x4 a; }; static_assert(sizeof(test3) == 9 * vector4_size); } }
20.848101
80
0.445052
Ryp
6124bd52c2bea7fbb7f2410dc5d8172ff22320ad
1,921
cpp
C++
aws-cpp-sdk-kinesis-video-archived-media/source/model/TimestampRange.cpp
curiousjgeorge/aws-sdk-cpp
09b65deba03cfbef9a1e5d5986aa4de71bc03cd8
[ "Apache-2.0" ]
2
2019-03-11T15:50:55.000Z
2020-02-27T11:40:27.000Z
aws-cpp-sdk-kinesis-video-archived-media/source/model/TimestampRange.cpp
curiousjgeorge/aws-sdk-cpp
09b65deba03cfbef9a1e5d5986aa4de71bc03cd8
[ "Apache-2.0" ]
null
null
null
aws-cpp-sdk-kinesis-video-archived-media/source/model/TimestampRange.cpp
curiousjgeorge/aws-sdk-cpp
09b65deba03cfbef9a1e5d5986aa4de71bc03cd8
[ "Apache-2.0" ]
1
2019-01-18T13:03:55.000Z
2019-01-18T13:03:55.000Z
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #include <aws/kinesis-video-archived-media/model/TimestampRange.h> #include <aws/core/utils/json/JsonSerializer.h> #include <utility> using namespace Aws::Utils::Json; using namespace Aws::Utils; namespace Aws { namespace KinesisVideoArchivedMedia { namespace Model { TimestampRange::TimestampRange() : m_startTimestampHasBeenSet(false), m_endTimestampHasBeenSet(false) { } TimestampRange::TimestampRange(JsonView jsonValue) : m_startTimestampHasBeenSet(false), m_endTimestampHasBeenSet(false) { *this = jsonValue; } TimestampRange& TimestampRange::operator =(JsonView jsonValue) { if(jsonValue.ValueExists("StartTimestamp")) { m_startTimestamp = jsonValue.GetDouble("StartTimestamp"); m_startTimestampHasBeenSet = true; } if(jsonValue.ValueExists("EndTimestamp")) { m_endTimestamp = jsonValue.GetDouble("EndTimestamp"); m_endTimestampHasBeenSet = true; } return *this; } JsonValue TimestampRange::Jsonize() const { JsonValue payload; if(m_startTimestampHasBeenSet) { payload.WithDouble("StartTimestamp", m_startTimestamp.SecondsWithMSPrecision()); } if(m_endTimestampHasBeenSet) { payload.WithDouble("EndTimestamp", m_endTimestamp.SecondsWithMSPrecision()); } return payload; } } // namespace Model } // namespace KinesisVideoArchivedMedia } // namespace Aws
23.144578
83
0.752212
curiousjgeorge
6124def4434b339515f5a40ce97910faafe6b9e8
13,002
cpp
C++
src/crypto/SecretKey.cpp
Rajan2000/stellar-core
e47d483433ce4f7eaf0a0512e2556beb482c8851
[ "Apache-2.0", "BSD-2-Clause", "MIT", "ECL-2.0", "BSL-1.0", "BSD-3-Clause" ]
10
2019-07-01T19:09:58.000Z
2022-03-13T14:39:06.000Z
src/crypto/SecretKey.cpp
Rajan2000/stellar-core
e47d483433ce4f7eaf0a0512e2556beb482c8851
[ "Apache-2.0", "BSD-2-Clause", "MIT", "ECL-2.0", "BSL-1.0", "BSD-3-Clause" ]
null
null
null
src/crypto/SecretKey.cpp
Rajan2000/stellar-core
e47d483433ce4f7eaf0a0512e2556beb482c8851
[ "Apache-2.0", "BSD-2-Clause", "MIT", "ECL-2.0", "BSL-1.0", "BSD-3-Clause" ]
4
2015-04-11T02:33:46.000Z
2021-11-24T10:27:28.000Z
// Copyright 2014 Stellar Development Foundation and contributors. Licensed // under the Apache License, Version 2.0. See the COPYING file at the root // of this distribution or at http://www.apache.org/licenses/LICENSE-2.0 #include "crypto/SecretKey.h" #include "crypto/BLAKE2.h" #include "crypto/CryptoError.h" #include "crypto/Curve25519.h" #include "crypto/Hex.h" #include "crypto/KeyUtils.h" #include "crypto/Random.h" #include "crypto/StrKey.h" #include "main/Config.h" #include "transactions/SignatureUtils.h" #include "util/HashOfHash.h" #include "util/Math.h" #include "util/RandomEvictionCache.h" #include <Tracy.hpp> #include <chrono> #include <memory> #include <mutex> #include <sodium.h> #include <type_traits> #ifdef MSAN_ENABLED #include <sanitizer/msan_interface.h> #endif namespace stellar { // Process-wide global Ed25519 signature-verification cache. // // This is a pure mathematical function and has no relationship // to the state of the process; caching its results centrally // makes all signature-verification in the program faster and // has no effect on correctness. static std::mutex gVerifySigCacheMutex; static RandomEvictionCache<Hash, bool> gVerifySigCache(0xffff); static uint64_t gVerifyCacheHit = 0; static uint64_t gVerifyCacheMiss = 0; static Hash verifySigCacheKey(PublicKey const& key, Signature const& signature, ByteSlice const& bin) { assert(key.type() == PUBLIC_KEY_TYPE_ED25519); BLAKE2 hasher; hasher.add(key.ed25519()); hasher.add(signature); hasher.add(bin); return hasher.finish(); } SecretKey::SecretKey() : mKeyType(PUBLIC_KEY_TYPE_ED25519) { static_assert(crypto_sign_PUBLICKEYBYTES == sizeof(uint256), "Unexpected public key length"); static_assert(crypto_sign_SEEDBYTES == sizeof(uint256), "Unexpected seed length"); static_assert(crypto_sign_SECRETKEYBYTES == sizeof(uint512), "Unexpected secret key length"); static_assert(crypto_sign_BYTES == sizeof(uint512), "Unexpected signature length"); } SecretKey::~SecretKey() { std::memset(mSecretKey.data(), 0, mSecretKey.size()); } SecretKey::Seed::~Seed() { std::memset(mSeed.data(), 0, mSeed.size()); } PublicKey const& SecretKey::getPublicKey() const { return mPublicKey; } SecretKey::Seed SecretKey::getSeed() const { assert(mKeyType == PUBLIC_KEY_TYPE_ED25519); Seed seed; seed.mKeyType = mKeyType; if (crypto_sign_ed25519_sk_to_seed(seed.mSeed.data(), mSecretKey.data()) != 0) { throw CryptoError("error extracting seed from secret key"); } return seed; } SecretValue SecretKey::getStrKeySeed() const { assert(mKeyType == PUBLIC_KEY_TYPE_ED25519); return strKey::toStrKey(strKey::STRKEY_SEED_ED25519, getSeed().mSeed); } std::string SecretKey::getStrKeyPublic() const { return KeyUtils::toStrKey(getPublicKey()); } bool SecretKey::isZero() const { for (auto i : mSecretKey) { if (i != 0) { return false; } } return true; } Signature SecretKey::sign(ByteSlice const& bin) const { ZoneScoped; assert(mKeyType == PUBLIC_KEY_TYPE_ED25519); Signature out(crypto_sign_BYTES, 0); if (crypto_sign_detached(out.data(), NULL, bin.data(), bin.size(), mSecretKey.data()) != 0) { throw CryptoError("error while signing"); } return out; } SecretKey SecretKey::random() { SecretKey sk; assert(sk.mKeyType == PUBLIC_KEY_TYPE_ED25519); if (crypto_sign_keypair(sk.mPublicKey.ed25519().data(), sk.mSecretKey.data()) != 0) { throw CryptoError("error generating random secret key"); } #ifdef MSAN_ENABLED __msan_unpoison(out.key.data(), out.key.size()); #endif return sk; } struct SignVerifyTestcase { SecretKey key; std::vector<uint8_t> msg; Signature sig; void sign() { sig = key.sign(msg); } void verify() { if (!PubKeyUtils::verifySig(key.getPublicKey(), sig, msg)) { throw std::runtime_error("verify failed"); } } static SignVerifyTestcase create() { SignVerifyTestcase st; st.key = SecretKey::random(); st.msg = randomBytes(256); return st; } }; void SecretKey::benchmarkOpsPerSecond(size_t& sign, size_t& verify, size_t iterations, size_t cachedVerifyPasses) { namespace ch = std::chrono; using clock = ch::high_resolution_clock; using usec = ch::microseconds; std::vector<SignVerifyTestcase> cases; for (size_t i = 0; i < iterations; ++i) { cases.push_back(SignVerifyTestcase::create()); } auto signStart = clock::now(); for (auto& c : cases) { c.sign(); } auto signEnd = clock::now(); auto verifyStart = clock::now(); for (auto pass = 0; pass < cachedVerifyPasses; ++pass) { if (pass == 1) { // If we have more than 1 pass, reset clock after // first so we are only measuring cache-hits. verifyStart = clock::now(); } for (auto& c : cases) { c.verify(); } } auto verifyEnd = clock::now(); auto signUsec = ch::duration_cast<usec>(signEnd - signStart); auto verifyUsec = ch::duration_cast<usec>(verifyEnd - verifyStart); sign = 1000000 / std::max(size_t(1), size_t(signUsec.count() / iterations)); verify = 1000000 / std::max(size_t(1), size_t(verifyUsec.count() / iterations)); } #ifdef BUILD_TESTS static std::vector<uint8_t> getPRNGBytes(size_t n, stellar_default_random_engine& engine) { std::vector<uint8_t> bytes; for (size_t i = 0; i < n; ++i) { bytes.push_back(static_cast<uint8_t>(engine())); } return bytes; } static SecretKey pseudoRandomForTestingFromPRNG(stellar_default_random_engine& engine) { return SecretKey::fromSeed(getPRNGBytes(crypto_sign_SEEDBYTES, engine)); } SecretKey SecretKey::pseudoRandomForTesting() { // Reminder: this is not cryptographic randomness or even particularly hard // to guess PRNG-ness. It's intended for _deterministic_ use, when you want // "slightly random-ish" keys, for test-data generation. return pseudoRandomForTestingFromPRNG(gRandomEngine); } SecretKey SecretKey::pseudoRandomForTestingFromSeed(unsigned int seed) { // Reminder: this is not cryptographic randomness or even particularly hard // to guess PRNG-ness. It's intended for _deterministic_ use, when you want // "slightly random-ish" keys, for test-data generation. stellar_default_random_engine tmpEngine(seed); return pseudoRandomForTestingFromPRNG(tmpEngine); } #endif SecretKey SecretKey::fromSeed(ByteSlice const& seed) { SecretKey sk; assert(sk.mKeyType == PUBLIC_KEY_TYPE_ED25519); if (seed.size() != crypto_sign_SEEDBYTES) { throw CryptoError("seed does not match byte size"); } if (crypto_sign_seed_keypair(sk.mPublicKey.ed25519().data(), sk.mSecretKey.data(), seed.data()) != 0) { throw CryptoError("error generating secret key from seed"); } return sk; } SecretKey SecretKey::fromStrKeySeed(std::string const& strKeySeed) { uint8_t ver; std::vector<uint8_t> seed; if (!strKey::fromStrKey(strKeySeed, ver, seed) || (ver != strKey::STRKEY_SEED_ED25519) || (seed.size() != crypto_sign_SEEDBYTES) || (strKeySeed.size() != strKey::getStrKeySize(crypto_sign_SEEDBYTES))) { throw CryptoError("invalid seed"); } SecretKey sk; assert(sk.mKeyType == PUBLIC_KEY_TYPE_ED25519); if (crypto_sign_seed_keypair(sk.mPublicKey.ed25519().data(), sk.mSecretKey.data(), seed.data()) != 0) { throw CryptoError("error generating secret key from seed"); } return sk; } void PubKeyUtils::clearVerifySigCache() { std::lock_guard<std::mutex> guard(gVerifySigCacheMutex); gVerifySigCache.clear(); } void PubKeyUtils::flushVerifySigCacheCounts(uint64_t& hits, uint64_t& misses) { std::lock_guard<std::mutex> guard(gVerifySigCacheMutex); hits = gVerifyCacheHit; misses = gVerifyCacheMiss; gVerifyCacheHit = 0; gVerifyCacheMiss = 0; } std::string KeyFunctions<PublicKey>::getKeyTypeName() { return "public key"; } bool KeyFunctions<PublicKey>::getKeyVersionIsSupported( strKey::StrKeyVersionByte keyVersion) { switch (keyVersion) { case strKey::STRKEY_PUBKEY_ED25519: return true; default: return false; } } PublicKeyType KeyFunctions<PublicKey>::toKeyType(strKey::StrKeyVersionByte keyVersion) { switch (keyVersion) { case strKey::STRKEY_PUBKEY_ED25519: return PublicKeyType::PUBLIC_KEY_TYPE_ED25519; default: throw CryptoError("invalid public key type"); } } strKey::StrKeyVersionByte KeyFunctions<PublicKey>::toKeyVersion(PublicKeyType keyType) { switch (keyType) { case PublicKeyType::PUBLIC_KEY_TYPE_ED25519: return strKey::STRKEY_PUBKEY_ED25519; default: throw CryptoError("invalid public key type"); } } uint256& KeyFunctions<PublicKey>::getKeyValue(PublicKey& key) { switch (key.type()) { case PUBLIC_KEY_TYPE_ED25519: return key.ed25519(); default: throw CryptoError("invalid public key type"); } } uint256 const& KeyFunctions<PublicKey>::getKeyValue(PublicKey const& key) { switch (key.type()) { case PUBLIC_KEY_TYPE_ED25519: return key.ed25519(); default: throw CryptoError("invalid public key type"); } } bool PubKeyUtils::verifySig(PublicKey const& key, Signature const& signature, ByteSlice const& bin) { ZoneScoped; assert(key.type() == PUBLIC_KEY_TYPE_ED25519); if (signature.size() != 64) { return false; } auto cacheKey = verifySigCacheKey(key, signature, bin); { std::lock_guard<std::mutex> guard(gVerifySigCacheMutex); if (gVerifySigCache.exists(cacheKey)) { ++gVerifyCacheHit; std::string hitStr("hit"); ZoneText(hitStr.c_str(), hitStr.size()); return gVerifySigCache.get(cacheKey); } } std::string missStr("miss"); ZoneText(missStr.c_str(), missStr.size()); bool ok = (crypto_sign_verify_detached(signature.data(), bin.data(), bin.size(), key.ed25519().data()) == 0); std::lock_guard<std::mutex> guard(gVerifySigCacheMutex); ++gVerifyCacheMiss; gVerifySigCache.put(cacheKey, ok); return ok; } PublicKey PubKeyUtils::random() { PublicKey pk; pk.type(PUBLIC_KEY_TYPE_ED25519); pk.ed25519().resize(crypto_sign_PUBLICKEYBYTES); randombytes_buf(pk.ed25519().data(), pk.ed25519().size()); return pk; } #ifdef BUILD_TESTS PublicKey PubKeyUtils::pseudoRandomForTesting() { return SecretKey::pseudoRandomForTesting().getPublicKey(); } #endif static void logPublicKey(std::ostream& s, PublicKey const& pk) { s << "PublicKey:" << std::endl << " strKey: " << KeyUtils::toStrKey(pk) << std::endl << " hex: " << binToHex(pk.ed25519()) << std::endl; } static void logSecretKey(std::ostream& s, SecretKey const& sk) { s << "Seed:" << std::endl << " strKey: " << sk.getStrKeySeed().value << std::endl; logPublicKey(s, sk.getPublicKey()); } void StrKeyUtils::logKey(std::ostream& s, std::string const& key) { // if it's a hex string, display it in all forms try { uint256 data = hexToBin256(key); PublicKey pk; pk.type(PUBLIC_KEY_TYPE_ED25519); pk.ed25519() = data; logPublicKey(s, pk); SecretKey sk(SecretKey::fromSeed(data)); logSecretKey(s, sk); return; } catch (...) { } // see if it's a public key try { PublicKey pk = KeyUtils::fromStrKey<PublicKey>(key); logPublicKey(s, pk); return; } catch (...) { } // see if it's a seed try { SecretKey sk = SecretKey::fromStrKeySeed(key); logSecretKey(s, sk); return; } catch (...) { } s << "Unknown key type" << std::endl; } Hash HashUtils::random() { Hash res; randombytes_buf(res.data(), res.size()); return res; } #ifdef BUILD_TESTS Hash HashUtils::pseudoRandomForTesting() { Hash res; auto bytes = getPRNGBytes(res.size(), gRandomEngine); for (size_t i = 0; i < bytes.size(); ++i) { res[i] = bytes[i]; } return res; } #endif } namespace std { size_t hash<stellar::PublicKey>::operator()(stellar::PublicKey const& k) const noexcept { assert(k.type() == stellar::PUBLIC_KEY_TYPE_ED25519); return std::hash<stellar::uint256>()(k.ed25519()); } }
24.122449
80
0.645439
Rajan2000
61257521d0f747b2a6514ac94431a25b9e1464c9
1,661
hpp
C++
Siv3D/src/Siv3D/Script/Bind/Script_Optional.hpp
Fuyutsubaki/OpenSiv3D
4370f6ebe28addd39bfdd75915c5a18e3e5e9273
[ "MIT" ]
null
null
null
Siv3D/src/Siv3D/Script/Bind/Script_Optional.hpp
Fuyutsubaki/OpenSiv3D
4370f6ebe28addd39bfdd75915c5a18e3e5e9273
[ "MIT" ]
null
null
null
Siv3D/src/Siv3D/Script/Bind/Script_Optional.hpp
Fuyutsubaki/OpenSiv3D
4370f6ebe28addd39bfdd75915c5a18e3e5e9273
[ "MIT" ]
null
null
null
//----------------------------------------------- // // This file is part of the Siv3D Engine. // // Copyright (c) 2008-2018 Ryo Suzuki // Copyright (c) 2016-2018 OpenSiv3D Project // // Licensed under the MIT License. // //----------------------------------------------- # include <Siv3D/Script.hpp> # include <Siv3D/Optional.hpp> # include <Siv3D/Logger.hpp> # include "ScriptBind.hpp" namespace s3d { using namespace AngelScript; struct SOptionalBuffer { asDWORD hasValue; asBYTE data[1]; }; class CScriptOptional { protected: asITypeInfo* objType; SOptionalBuffer* buffer; int32 elementSize; int32 subTypeId; void CreateBuffer(SOptionalBuffer** buf, asUINT hasValue); void Construct(SOptionalBuffer* buf); void SetValue(void* value); void SetValue(SOptionalBuffer* buf, void* value); void* At(SOptionalBuffer* buf); void DeleteBuffer(SOptionalBuffer* buf); //// internal void Destruct(SOptionalBuffer* buf); void Resize(asUINT hasValue); void CopyBuffer(SOptionalBuffer* dst, SOptionalBuffer* src); public: asITypeInfo* GetArrayObjectType() const; CScriptOptional(asITypeInfo* ti); CScriptOptional(void* defVal, asITypeInfo *ti); ~CScriptOptional(); CScriptOptional& operator=(const CScriptOptional& other); CScriptOptional& AssignValue(void* value); CScriptOptional& AssignNone(uint8); //bool opEqual(const CScriptOptional& other) const; //bool opEqualValue(void* value) const; bool opEqualNone(uint8) const; void ResetValue(void* value); void* At(); const void* At() const; bool HasValue() const; void Reset(); void* ValueOr(void* value); }; }
17.860215
62
0.67068
Fuyutsubaki
6125a7bc160209f19904ee64f4166d97fd37a911
7,474
cpp
C++
practice/37-sudoku-solver/LeetCode_37_0144.cpp
manajay/algorithm-list
828b0baed25a743fdb010427f873b29af9587951
[ "MIT" ]
null
null
null
practice/37-sudoku-solver/LeetCode_37_0144.cpp
manajay/algorithm-list
828b0baed25a743fdb010427f873b29af9587951
[ "MIT" ]
null
null
null
practice/37-sudoku-solver/LeetCode_37_0144.cpp
manajay/algorithm-list
828b0baed25a743fdb010427f873b29af9587951
[ "MIT" ]
null
null
null
/** 编写一个程序,通过已填充的空格来解决数独问题。 一个数独的解法需遵循如下规则: 数字 1-9 在每一行只能出现一次。 数字 1-9 在每一列只能出现一次。 数字 1-9 在每一个以粗实线分隔的 3x3 宫内只能出现一次。 空白格用 '.' 表示。 一个数独。 答案被标成红色。 Note: 给定的数独序列只包含数字 1-9 和字符 '.' 。 你可以假设给定的数独只有唯一解。 给定数独永远是 9x9 形式的。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/sudoku-solver 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 * */ #include <iostream> #include <vector> using namespace std; #define N 3 class Solution { vector<vector<int>> rows; vector<vector<int>> cols; vector<vector<int>> boxes; bool sudokuSolved; /** * 这个问题费了我很长时间, 主要是对于 字符越界问题, 更新记录的 细节出了错误 * */ public: void solveSudoku(vector<vector<char>> &board) { /// 后面会存储 1 - 9的索引, 所以开辟数组要大一些 this->rows = vector(9, vector(10, 0)); this->cols = vector(9, vector(10, 0)); this->boxes = vector(9, vector(10, 0)); this->sudokuSolved = false; // 预处理 , 更新初始化面板的数据 for (int i = 0; i < 9; ++i) { for (int j = 0; j < 9; ++j) { if (board[i][j] != '.') { const char d = board[i][j]; // 1. 存储字符 '1' - '0' == 1 placeNumber(board, d - '0', i, j); } } } // 回溯 backtrace(board, 0, 0); cout << "成功" << endl; } void backtrace(vector<vector<char>> &board, int row, int col) { if (board[row][col] != '.') { placeNextNumber(board, row, col); } else { // 放置 1 ~ 9 for (int i = 1; i <= 9; i++) { // 先判断能不能放字符 if (couldPlace(board, i, row, col)) { // 放字符, 并且更新记录 placeNumber(board, i, row, col); board[row][col] = i + '0'; // 继续下一个位置, 这里可能会填充满 placeNextNumber(board, row, col); // 所以要注意 解决的话就直接结束, 否则 恢复 一下, 以供下次尝试 if (!sudokuSolved) { removeNumber(board, i, row, col); } } } } } void placeNumber(vector<vector<char>> &board, int d, int row, int col) { rows[row][d]++; cols[col][d]++; // 要点 : 注意 子数独的 索引 int b_index = (row / 3) * 3 + col / 3; boxes[b_index][d]++; } void placeNextNumber(vector<vector<char>> &board, int row, int col) { // 终止条件 if (row == 8 && col == 8) { sudokuSolved = true; } else if (col == 8) { // 注意这里的数据 上次错了 backtrace(board, row + 1, 0); } else { backtrace(board, row, col + 1); } } void removeNumber(vector<vector<char>> &board, int d, int row, int col) { rows[row][d]--; cols[col][d]--; int b_index = (row / 3) * 3 + col / 3; boxes[b_index][d]--; board[row][col] = '.'; } bool couldPlace(vector<vector<char>> &board, int d, int row, int col) { int b_index = (row / 3) * 3 + col / 3; return rows[row][d] + cols[col][d] + boxes[b_index][d] == 0; } }; // 启发式搜索 , 子数独 优化, class Solution { vector<vector<int>> rows; vector<vector<int>> cols; vector<vector<int>> boxes; vector<int> box_Count; int count; bool sudokuSolved; /** * 这个问题费了我很长时间, 主要是对于 字符越界问题, 更新记录的 细节出了错误 * */ public: void solveSudoku(vector<vector<char>> &board) { /// 后面会存储 1 - 9的索引, 所以开辟数组要大一些 this->rows = vector(9, vector(10, 0)); this->cols = vector(9, vector(10, 0)); this->boxes = vector(9, vector(10, 0)); this->box_Count = vector(9, 0); this->count = 0; this->sudokuSolved = false; // 预处理 , 更新初始化面板的数据 for (int i = 0; i < 9; ++i) { for (int j = 0; j < 9; ++j) { if (board[i][j] != '.') { const char d = board[i][j]; // 1. 存储字符 '1' - '0' == 1 placeNumber(board, d - '0', i, j); } } } // 找最优的数据 // 回溯 int boxIndex = mostPriorityBox(); // 获取指定索引 int row = 0; int col = 0; boxStartIndex(boxIndex, row, col); backtrace(board, row, col, boxIndex); cout << "成功" << endl; } int mostPriorityBox() { int most = 0; for (int i = 0; i < 9; i++) { if (box_Count[i] > box_Count[most]) { most = i; } } } void boxStartIndex(int idx, int &row, int &col) { col = idx % 3 * 3; row = idx / 3 * 3; } void boxEndIndex(int idx, int &row, int &col) { col = idx % 3 * 3 + 2; row = idx / 3 * 3 + 2; } void backtrace(vector<vector<char>> &board, int row, int col, int box_idx) { if (board[row][col] != '.') { placeNextNumber(board, row, col, box_idx); } else { // 放置 1 ~ 9 for (int i = 1; i <= 9; i++) { // 先判断能不能放字符 if (couldPlace(board, i, row, col)) { // 放字符, 并且更新记录 placeNumber(board, i, row, col); board[row][col] = i + '0'; // 继续下一个位置, 这里可能会填充满 placeNextNumber(board, row, col, box_idx); // 所以要注意 解决的话就直接结束, 否则 恢复 一下, 以供下次尝试 if (!sudokuSolved) { removeNumber(board, i, row, col); } } } } } void placeNumber(vector<vector<char>> &board, int d, int row, int col) { rows[row][d]++; cols[col][d]++; // 要点 : 注意 子数独的 索引 int b_index = (row / 3) * 3 + col / 3; boxes[b_index][d]++; box_Count[b_index]++; if (box_Count[b_index] == 9) { count++; } } void placeNextNumber(vector<vector<char>> &board, int row, int col, int box_idx) { // 终止条件 if (count == 9) { sudokuSolved = true; } else { int e_r = 0, e_c = 0; boxEndIndex(box_idx, e_r, e_c); if (row == e_r && col == e_c) { box_idx = mostPriorityBox(); boxStartIndex(e_r, e_c, box_idx); backtrace(board, e_r, e_c, box_idx); } else if (col == e_c) { backtrace(board, row + 1, e_c - 2, box_idx); } else { backtrace(board, row, col + 1, box_idx); } } } void removeNumber(vector<vector<char>> &board, int d, int row, int col) { rows[row][d]--; cols[col][d]--; int b_index = (row / 3) * 3 + col / 3; boxes[b_index][d]--; board[row][col] = '.'; if (box_Count[b_index] == 9) { count--; } box_Count[b_index]--; } bool couldPlace(vector<vector<char>> &board, int d, int row, int col) { int b_index = (row / 3) * 3 + col / 3; return rows[row][d] + cols[col][d] + boxes[b_index][d] == 0; } };
24.187702
84
0.42494
manajay
6126e8cadd5c8cbabda88097dcc69ae11434ae4a
1,756
cc
C++
graph/dfs.cc
mwien/tcr
a0d7db1d360145979c4f24e8ae6f2846ef4b7181
[ "MIT" ]
null
null
null
graph/dfs.cc
mwien/tcr
a0d7db1d360145979c4f24e8ae6f2846ef4b7181
[ "MIT" ]
null
null
null
graph/dfs.cc
mwien/tcr
a0d7db1d360145979c4f24e8ae6f2846ef4b7181
[ "MIT" ]
null
null
null
/* Recursive Depth First Search ** |V| + |E| * Recursive DFS with different options (storing times, connected/unconnected graph). * this is very much pseudocode, needs a lot of problem adaption anyway\\ * \emph{Input:} A source vertex $s$, a target vertex $t$, and adjlist $G$ and the time (0 at the start)\\ * \emph{Output:} Indicates if there is connection between $s$ and $t$. */ //START // globally create adj list etc vector<vector<int>> g; int dtime[n]; int ftime[n]; int vis[n]; int pre[n]; //first call with time = 0 void rec_dfs(int u, int time){ //it might be necessary to store the time of discovery time = time + 1; dtime[u] = time; vis[u] = 1; //new vertex has been discovered //For cycle check vis should be int and 0 are not vis nodes //1 are vis nodes which havent been finished and 2 are finished nodes //cycle exists iff edge to node with vis=1 //when reaching the target return true //not necessary when calculating the DFS-tree for(int i = 0; i < g[u].size(); ++i) { int v = g[u][i]; //exploring a new edge if(!vis[v]) { pre[v] = u; if(rec_dfs(v, time)) return true; } } //storing finishing time time = time + 1; ftime[s] = time; vis[s] = 2; return false; } //if we want to visit the whole graph, even if it is not connected we might use this //make sure all vertices vis value is false etc int time = 0; for(int i = 0; i < n; i++) { if(vis[i] == 0) { //note that we leave out t so this does not work with the below function //adaption will not be too difficult though //time should not always start at zero, change if needed rec_dfs(i, 0); } } }
31.357143
105
0.616173
mwien
612ad4ab4679e0071823ad4a1026640f3d0f6e28
15,460
cc
C++
modules/remote_bitrate_estimator/test/metric_recorder.cc
bighitbiker3/webrtc
276763201d0fe590f19429497df2b33b07c87040
[ "DOC", "BSD-3-Clause" ]
2,151
2020-04-18T07:31:17.000Z
2022-03-31T08:39:18.000Z
modules/remote_bitrate_estimator/test/metric_recorder.cc
modulesio/webrtc
ea143e774b4c00a74b617f272f5a8f71169cf24e
[ "DOC", "BSD-3-Clause" ]
395
2020-04-18T08:22:18.000Z
2021-12-08T13:04:49.000Z
modules/remote_bitrate_estimator/test/metric_recorder.cc
modulesio/webrtc
ea143e774b4c00a74b617f272f5a8f71169cf24e
[ "DOC", "BSD-3-Clause" ]
338
2020-04-18T08:03:10.000Z
2022-03-29T12:33:22.000Z
/* * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #include "modules/remote_bitrate_estimator/test/metric_recorder.h" #include <inttypes.h> #include <algorithm> #include "modules/remote_bitrate_estimator/test/packet_sender.h" #include "typedefs.h" // NOLINT(build/include) namespace webrtc { namespace testing { namespace bwe { namespace { // Holder mean, Manhattan distance for p=1, EuclidianNorm/sqrt(n) for p=2. template <typename T> double NormLp(T sum, size_t size, double p) { return pow(sum / size, 1.0 / p); } } const double kP = 1.0; // Used for Norm Lp. LinkShare::LinkShare(ChokeFilter* choke_filter) : choke_filter_(choke_filter), running_flows_(choke_filter->flow_ids()) { } void LinkShare::PauseFlow(int flow_id) { running_flows_.erase(flow_id); } void LinkShare::ResumeFlow(int flow_id) { running_flows_.insert(flow_id); } uint32_t LinkShare::TotalAvailableKbps() { return choke_filter_->capacity_kbps(); } uint32_t LinkShare::AvailablePerFlowKbps(int flow_id) { uint32_t available_capacity_per_flow_kbps = 0; if (running_flows_.find(flow_id) != running_flows_.end()) { available_capacity_per_flow_kbps = TotalAvailableKbps() / static_cast<uint32_t>(running_flows_.size()); } return available_capacity_per_flow_kbps; } MetricRecorder::MetricRecorder(const std::string algorithm_name, int flow_id, PacketSender* packet_sender, LinkShare* link_share) : algorithm_name_(algorithm_name), flow_id_(flow_id), link_share_(link_share), now_ms_(0), sum_delays_ms_(0), delay_histogram_ms_(), sum_delays_square_ms2_(0), sum_throughput_bytes_(0), last_unweighted_estimate_error_(0), optimal_throughput_bits_(0), last_available_bitrate_per_flow_kbps_(0), start_computing_metrics_ms_(0), started_computing_metrics_(false), num_packets_received_(0) { std::fill_n(sum_lp_weighted_estimate_error_, 2, 0); if (packet_sender != nullptr) packet_sender->set_metric_recorder(this); } void MetricRecorder::SetPlotInformation( const std::vector<std::string>& prefixes, bool plot_delay, bool plot_loss) { assert(prefixes.size() == kNumMetrics); for (size_t i = 0; i < kNumMetrics; ++i) { plot_information_[i].prefix = prefixes[i]; } plot_information_[kThroughput].plot_interval_ms = 100; plot_information_[kSendingEstimate].plot_interval_ms = 100; plot_information_[kDelay].plot_interval_ms = 100; plot_information_[kLoss].plot_interval_ms = 500; plot_information_[kObjective].plot_interval_ms = 1000; plot_information_[kTotalAvailable].plot_interval_ms = 1000; plot_information_[kAvailablePerFlow].plot_interval_ms = 1000; for (int i = kThroughput; i < kNumMetrics; ++i) { plot_information_[i].last_plot_ms = 0; switch (i) { case kSendingEstimate: case kObjective: case kAvailablePerFlow: plot_information_[i].plot = false; break; case kLoss: plot_information_[i].plot = plot_loss; break; case kDelay: plot_information_[i].plot = plot_delay; break; default: plot_information_[i].plot = true; } } } void MetricRecorder::PlotAllDynamics() { for (int i = kThroughput; i < kNumMetrics; ++i) { if (plot_information_[i].plot && now_ms_ - plot_information_[i].last_plot_ms >= plot_information_[i].plot_interval_ms) { PlotDynamics(i); } } } void MetricRecorder::PlotDynamics(int metric) { if (metric == kTotalAvailable) { BWE_TEST_LOGGING_PLOT_WITH_NAME_AND_SSRC( 0, plot_information_[kTotalAvailable].prefix, now_ms_, GetTotalAvailableKbps(), flow_id_, "Available"); } else if (metric == kAvailablePerFlow) { BWE_TEST_LOGGING_PLOT_WITH_NAME_AND_SSRC( 0, plot_information_[kAvailablePerFlow].prefix, now_ms_, GetAvailablePerFlowKbps(), flow_id_, "Available_per_flow"); } else { PlotLine(metric, plot_information_[metric].prefix, plot_information_[metric].time_ms, plot_information_[metric].value); } plot_information_[metric].last_plot_ms = now_ms_; } template <typename T> void MetricRecorder::PlotLine(int windows_id, const std::string& prefix, int64_t time_ms, T y) { BWE_TEST_LOGGING_PLOT_WITH_NAME_AND_SSRC(windows_id, prefix, time_ms, static_cast<double>(y), flow_id_, algorithm_name_); } void MetricRecorder::UpdateTimeMs(int64_t time_ms) { now_ms_ = std::max(now_ms_, time_ms); } void MetricRecorder::UpdateThroughput(int64_t bitrate_kbps, size_t payload_size) { // Total throughput should be computed before updating the time. PushThroughputBytes(payload_size, now_ms_); plot_information_[kThroughput].Update(now_ms_, bitrate_kbps); } void MetricRecorder::UpdateSendingEstimateKbps(int64_t bitrate_kbps) { plot_information_[kSendingEstimate].Update(now_ms_, bitrate_kbps); } void MetricRecorder::UpdateDelayMs(int64_t delay_ms) { PushDelayMs(delay_ms, now_ms_); plot_information_[kDelay].Update(now_ms_, delay_ms); } void MetricRecorder::UpdateLoss(float loss_ratio) { plot_information_[kLoss].Update(now_ms_, loss_ratio); } void MetricRecorder::UpdateObjective() { plot_information_[kObjective].Update(now_ms_, ObjectiveFunction()); } uint32_t MetricRecorder::GetTotalAvailableKbps() { if (link_share_ == nullptr) return 0; return link_share_->TotalAvailableKbps(); } uint32_t MetricRecorder::GetAvailablePerFlowKbps() { if (link_share_ == nullptr) return 0; return link_share_->AvailablePerFlowKbps(flow_id_); } uint32_t MetricRecorder::GetSendingEstimateKbps() { return static_cast<uint32_t>(plot_information_[kSendingEstimate].value); } void MetricRecorder::PushDelayMs(int64_t delay_ms, int64_t arrival_time_ms) { if (ShouldRecord(arrival_time_ms)) { sum_delays_ms_ += delay_ms; sum_delays_square_ms2_ += delay_ms * delay_ms; if (delay_histogram_ms_.find(delay_ms) == delay_histogram_ms_.end()) { delay_histogram_ms_[delay_ms] = 0; } ++delay_histogram_ms_[delay_ms]; } } void MetricRecorder::UpdateEstimateError(int64_t new_value) { int64_t lp_value = pow(static_cast<double>(std::abs(new_value)), kP); if (new_value < 0) { sum_lp_weighted_estimate_error_[0] += lp_value; } else { sum_lp_weighted_estimate_error_[1] += lp_value; } } void MetricRecorder::PushThroughputBytes(size_t payload_size, int64_t arrival_time_ms) { if (ShouldRecord(arrival_time_ms)) { ++num_packets_received_; sum_throughput_bytes_ += payload_size; int64_t current_available_per_flow_kbps = static_cast<int64_t>(GetAvailablePerFlowKbps()); int64_t current_bitrate_diff_kbps = static_cast<int64_t>(GetSendingEstimateKbps()) - current_available_per_flow_kbps; int64_t weighted_estimate_error = (((current_bitrate_diff_kbps + last_unweighted_estimate_error_) * (arrival_time_ms - plot_information_[kThroughput].time_ms)) / 2); UpdateEstimateError(weighted_estimate_error); optimal_throughput_bits_ += ((current_available_per_flow_kbps + last_available_bitrate_per_flow_kbps_) * (arrival_time_ms - plot_information_[kThroughput].time_ms)) / 2; last_available_bitrate_per_flow_kbps_ = current_available_per_flow_kbps; } } bool MetricRecorder::ShouldRecord(int64_t arrival_time_ms) { if (arrival_time_ms >= start_computing_metrics_ms_) { if (!started_computing_metrics_) { start_computing_metrics_ms_ = arrival_time_ms; now_ms_ = arrival_time_ms; started_computing_metrics_ = true; } return true; } else { return false; } } void MetricRecorder::PlotThroughputHistogram( const std::string& title, const std::string& bwe_name, size_t num_flows, int64_t extra_offset_ms, const std::string optimum_id) const { double optimal_bitrate_per_flow_kbps = static_cast<double>( optimal_throughput_bits_ / RunDurationMs(extra_offset_ms)); double neg_error = Renormalize( NormLp(sum_lp_weighted_estimate_error_[0], num_packets_received_, kP)); double pos_error = Renormalize( NormLp(sum_lp_weighted_estimate_error_[1], num_packets_received_, kP)); double average_bitrate_kbps = AverageBitrateKbps(extra_offset_ms); // Prevent the error to be too close to zero (plotting issue). double extra_error = average_bitrate_kbps / 500; std::string optimum_title = optimum_id.empty() ? "optimal_bitrate" : "optimal_bitrates#" + optimum_id; BWE_TEST_LOGGING_LABEL(4, title, "average_bitrate_(kbps)", num_flows); BWE_TEST_LOGGING_LIMITERRORBAR( 4, bwe_name, average_bitrate_kbps, average_bitrate_kbps - neg_error - extra_error, average_bitrate_kbps + pos_error + extra_error, "estimate_error", optimal_bitrate_per_flow_kbps, optimum_title, flow_id_); BWE_TEST_LOGGING_LOG1("RESULTS >>> " + bwe_name + " Channel utilization : ", "%lf %%", 100.0 * static_cast<double>(average_bitrate_kbps) / optimal_bitrate_per_flow_kbps); RTC_UNUSED(pos_error); RTC_UNUSED(neg_error); RTC_UNUSED(extra_error); RTC_UNUSED(optimal_bitrate_per_flow_kbps); } void MetricRecorder::PlotThroughputHistogram(const std::string& title, const std::string& bwe_name, size_t num_flows, int64_t extra_offset_ms) const { PlotThroughputHistogram(title, bwe_name, num_flows, extra_offset_ms, ""); } void MetricRecorder::PlotDelayHistogram(const std::string& title, const std::string& bwe_name, size_t num_flows, int64_t one_way_path_delay_ms) const { double average_delay_ms = static_cast<double>(sum_delays_ms_) / num_packets_received_; int64_t percentile_5_ms = NthDelayPercentile(5); int64_t percentile_95_ms = NthDelayPercentile(95); BWE_TEST_LOGGING_LABEL(5, title, "average_delay_(ms)", num_flows); BWE_TEST_LOGGING_ERRORBAR(5, bwe_name, average_delay_ms, percentile_5_ms, percentile_95_ms, "5th and 95th percentiles", flow_id_); // Log added latency, disregard baseline path delay. BWE_TEST_LOGGING_LOG1("RESULTS >>> " + bwe_name + " Delay average : ", "%lf ms", average_delay_ms - one_way_path_delay_ms); BWE_TEST_LOGGING_LOG1( "RESULTS >>> " + bwe_name + " Delay 5th percentile : ", "%" PRId64 " ms", percentile_5_ms - one_way_path_delay_ms); BWE_TEST_LOGGING_LOG1( "RESULTS >>> " + bwe_name + " Delay 95th percentile : ", "%" PRId64 " ms", percentile_95_ms - one_way_path_delay_ms); RTC_UNUSED(average_delay_ms); RTC_UNUSED(percentile_5_ms); RTC_UNUSED(percentile_95_ms); } void MetricRecorder::PlotLossHistogram(const std::string& title, const std::string& bwe_name, size_t num_flows, float global_loss_ratio) const { BWE_TEST_LOGGING_LABEL(6, title, "packet_loss_ratio_(%)", num_flows); BWE_TEST_LOGGING_BAR(6, bwe_name, 100.0f * global_loss_ratio, flow_id_); BWE_TEST_LOGGING_LOG1("RESULTS >>> " + bwe_name + " Loss Ratio : ", "%f %%", 100.0f * global_loss_ratio); } void MetricRecorder::PlotObjectiveHistogram(const std::string& title, const std::string& bwe_name, size_t num_flows) const { BWE_TEST_LOGGING_LABEL(7, title, "objective_function", num_flows); BWE_TEST_LOGGING_BAR(7, bwe_name, ObjectiveFunction(), flow_id_); } void MetricRecorder::PlotZero() { for (int i = kThroughput; i <= kLoss; ++i) { if (plot_information_[i].plot) { std::stringstream prefix; // TODO(terelius): Since this does not use the BWE_TEST_LOGGING macros, // it hasn't been kept up to date with the plot format. Remove or fix? prefix << "Receiver_" << flow_id_ << "_" + plot_information_[i].prefix; PlotLine(i, prefix.str(), now_ms_, 0); plot_information_[i].last_plot_ms = now_ms_; } } } void MetricRecorder::PauseFlow() { PlotZero(); link_share_->PauseFlow(flow_id_); } void MetricRecorder::ResumeFlow(int64_t paused_time_ms) { UpdateTimeMs(now_ms_ + paused_time_ms); PlotZero(); link_share_->ResumeFlow(flow_id_); } double MetricRecorder::AverageBitrateKbps(int64_t extra_offset_ms) const { int64_t duration_ms = RunDurationMs(extra_offset_ms); if (duration_ms == 0) return 0.0; return static_cast<double>(8 * sum_throughput_bytes_ / duration_ms); } int64_t MetricRecorder::RunDurationMs(int64_t extra_offset_ms) const { return now_ms_ - start_computing_metrics_ms_ - extra_offset_ms; } double MetricRecorder::DelayStdDev() const { if (num_packets_received_ == 0) { return 0.0; } double mean = static_cast<double>(sum_delays_ms_) / num_packets_received_; double mean2 = static_cast<double>(sum_delays_square_ms2_) / num_packets_received_; return sqrt(mean2 - pow(mean, 2.0)); } // Since delay values are bounded in a subset of [0, 5000] ms, // this function's execution time is O(1), independend of num_packets_received_. int64_t MetricRecorder::NthDelayPercentile(int n) const { if (num_packets_received_ == 0) { return 0; } size_t num_packets_remaining = (n * num_packets_received_) / 100; for (auto hist : delay_histogram_ms_) { if (num_packets_remaining <= hist.second) return static_cast<int64_t>(hist.first); num_packets_remaining -= hist.second; } assert(false); return -1; } // The weighted_estimate_error_ was weighted based on time windows. // This function scales back the result before plotting. double MetricRecorder::Renormalize(double x) const { return (x * num_packets_received_) / now_ms_; } inline double U(int64_t x, double alpha) { if (alpha == 1.0) { return log(static_cast<double>(x)); } return pow(static_cast<double>(x), 1.0 - alpha) / (1.0 - alpha); } inline double U(size_t x, double alpha) { return U(static_cast<int64_t>(x), alpha); } // TODO(magalhaesc): Update ObjectiveFunction. double MetricRecorder::ObjectiveFunction() const { const double kDelta = 0.15; // Delay penalty factor. const double kAlpha = 1.0; const double kBeta = 1.0; double throughput_metric = U(sum_throughput_bytes_, kAlpha); double delay_penalty = kDelta * U(sum_delays_ms_, kBeta); return throughput_metric - delay_penalty; } } // namespace bwe } // namespace testing } // namespace webrtc
34.355556
80
0.689909
bighitbiker3
612bea666fa1e8b038903d83fda87357df49a92e
1,690
cpp
C++
Vulkan/Present.cpp
fluffels/jcwk
46ca2bc28f959c8eb0b174c5dc0a522147a1a5f4
[ "MIT" ]
1
2021-06-23T02:02:21.000Z
2021-06-23T02:02:21.000Z
Vulkan/Present.cpp
fluffels/jcwk
46ca2bc28f959c8eb0b174c5dc0a522147a1a5f4
[ "MIT" ]
3
2020-11-12T11:32:33.000Z
2021-05-06T14:42:51.000Z
Vulkan/Present.cpp
fluffels/jcwk
46ca2bc28f959c8eb0b174c5dc0a522147a1a5f4
[ "MIT" ]
null
null
null
#include <limits> #include "Vulkan.h" #undef max void present(Vulkan& vk, VkCommandBuffer* cmds, uint32_t cmdCount) { uint32_t imageIndex = 0; auto result = vkAcquireNextImageKHR( vk.device, vk.swap.handle, std::numeric_limits<uint64_t>::max(), vk.swap.imageReady, VK_NULL_HANDLE, &imageIndex ); if ((result == VK_SUBOPTIMAL_KHR) || (result == VK_ERROR_OUT_OF_DATE_KHR)) { // TODO(jan): implement resize throw std::runtime_error("could not acquire next image"); } else if (result != VK_SUCCESS) { throw std::runtime_error("could not acquire next image"); } VkSubmitInfo submitInfo = {}; submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; submitInfo.commandBufferCount = cmdCount; submitInfo.pCommandBuffers = cmds + (imageIndex * cmdCount); submitInfo.waitSemaphoreCount = 1; submitInfo.pWaitSemaphores = &vk.swap.imageReady; VkPipelineStageFlags waitStages[] = { VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT }; submitInfo.pWaitDstStageMask = waitStages; submitInfo.signalSemaphoreCount = 1; submitInfo.pSignalSemaphores = &vk.swap.cmdBufferDone; vkQueueSubmit(vk.queue, 1, &submitInfo, VK_NULL_HANDLE); VkPresentInfoKHR presentInfo = {}; presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; presentInfo.swapchainCount = 1; presentInfo.pSwapchains = &vk.swap.handle; presentInfo.waitSemaphoreCount = 1; presentInfo.pWaitSemaphores = &vk.swap.cmdBufferDone; presentInfo.pImageIndices = &imageIndex; VKCHECK(vkQueuePresentKHR(vk.queue, &presentInfo)); vkDeviceWaitIdle(vk.device); }
33.8
68
0.698817
fluffels
612d3c0d9affd47146efe213caca6b79c58305f3
769
cpp
C++
src/libs/program/subcommand_option.cpp
jdmclark/gorc
a03d6a38ab7684860c418dd3d2e77cbe6a6d9fc8
[ "Apache-2.0" ]
97
2015-02-24T05:09:24.000Z
2022-01-23T12:08:22.000Z
src/libs/program/subcommand_option.cpp
annnoo/gorc
1889b4de6380c30af6c58a8af60ecd9c816db91d
[ "Apache-2.0" ]
8
2015-03-27T23:03:23.000Z
2020-12-21T02:34:33.000Z
src/libs/program/subcommand_option.cpp
annnoo/gorc
1889b4de6380c30af6c58a8af60ecd9c816db91d
[ "Apache-2.0" ]
10
2016-03-24T14:32:50.000Z
2021-11-13T02:38:53.000Z
#include "subcommand_option.hpp" gorc::subcommand_option::subcommand_option(subcommand_registry &reg, maybe<int> &binding) : reg(reg) , binding(binding) { return; } void gorc::subcommand_option::reset() { binding = nothing; } void gorc::subcommand_option::load_from_arg(std::string const &arg, abstract_argument_queue &args) { binding = reg.start(arg, args); } bool gorc::subcommand_option::has_value() const { return binding.has_value(); } std::unique_ptr<gorc::subcommand_option> gorc::make_subcommand_option( gorc::subcommand_registry &reg, gorc::maybe<int> &binding) { return std::make_unique<subcommand_option>(reg, binding); }
23.30303
74
0.635891
jdmclark
612e20392d3b22b7db972c3d14dbfd3bafdd2a88
2,622
cpp
C++
opengl-gui/src/Widgets/TextArea.cpp
ChewyGumball/opengl_gui
b2bd1803f0cfb01db08c88da5091546076dfc2a3
[ "MIT" ]
2
2019-08-27T00:37:11.000Z
2021-11-25T14:34:23.000Z
opengl-gui/src/Widgets/TextArea.cpp
ChewyGumball/opengl_gui
b2bd1803f0cfb01db08c88da5091546076dfc2a3
[ "MIT" ]
null
null
null
opengl-gui/src/Widgets/TextArea.cpp
ChewyGumball/opengl_gui
b2bd1803f0cfb01db08c88da5091546076dfc2a3
[ "MIT" ]
2
2018-10-18T12:12:28.000Z
2019-08-27T00:36:21.000Z
#include "Widgets/TextArea.h" namespace { std::vector<std::vector<OpenGLGUI::Text>> layoutText(std::string text, std::shared_ptr<OpenGLGUI::FontBrush> fontBrush, int width, int height) { std::vector<std::vector<OpenGLGUI::Text>> lines; std::vector<OpenGLGUI::Text> currentLine; std::shared_ptr<OpenGLGUI::Font> font = fontBrush->font(); int currentLinePosition = 0; int currentLineWidth = 0; for (int i = 0; i < text.size(); i++) { char currentChar = text[i]; if (currentChar == '\n') { currentLine.emplace_back(text.substr(i - currentLinePosition, currentLinePosition), fontBrush); lines.push_back(currentLine); currentLine = std::vector<OpenGLGUI::Text>(); currentLineWidth = 0; currentLinePosition = 0; } else { ftgl::texture_glyph_t *glyph = font->glyphOf(&currentChar); int currentWidth = glyph->advance_x; int kerning = 0; if (currentLinePosition != 0) { kerning = texture_glyph_get_kerning(glyph, &text[i - 1]); } //go to next line if too long if (currentLineWidth + currentWidth + kerning > width) { //find closest previous space character int previousSpaceOffset = 0; char previousChar = text[i - previousSpaceOffset]; while (previousSpaceOffset < currentLinePosition && text[i - previousSpaceOffset] != ' ') { previousSpaceOffset++; } if (previousSpaceOffset == currentLinePosition) { previousSpaceOffset = 0; } currentLine.emplace_back(text.substr(i - currentLinePosition, currentLinePosition - previousSpaceOffset), fontBrush); lines.push_back(currentLine); currentLine = std::vector<OpenGLGUI::Text>(); //start laying out again AFTER the space i -= previousSpaceOffset - 1; currentLineWidth = 0; currentLinePosition = 0; kerning = 0; } currentLineWidth += currentWidth + kerning; currentLinePosition++; } } return lines; } } namespace OpenGLGUI { TextArea::TextArea(std::shared_ptr<std::string> data, std::shared_ptr<FontBrush> font, int width, int height) : Widget(0,0,width,height), textData(data), fontHeight(font->font()->height()), lines(layoutText(*data, font, widgetWidth, widgetHeight)) { } void TextArea::draw(glm::vec2 origin, glm::vec2 canvasSize) { glm::vec2 widgetOrigin = origin + widgetPosition; //glScissor(widgetOrigin.x, widgetOrigin.y, widgetWidth, widgetHeight); int lineCount = 0; for (auto& line : lines) { for (auto& text : line) { text.draw(widgetOrigin - glm::vec2(0, lineCount * fontHeight), canvasSize); lineCount++; } } } }
29.133333
248
0.672769
ChewyGumball
612f38a28d9cbf55c5c8ccca296a1cda791a725f
4,192
cpp
C++
src/libtsduck/crypto/tsCipherChaining.cpp
harmonicinc-com/tsduck
67f25161a3b37b1f3c486d5ef2e013486c3d9893
[ "BSD-2-Clause" ]
542
2017-06-21T07:40:10.000Z
2022-03-29T13:44:39.000Z
src/libtsduck/crypto/tsCipherChaining.cpp
harmonicinc-com/tsduck
67f25161a3b37b1f3c486d5ef2e013486c3d9893
[ "BSD-2-Clause" ]
939
2017-09-01T21:00:42.000Z
2022-03-31T14:39:27.000Z
src/libtsduck/crypto/tsCipherChaining.cpp
harmonicinc-com/tsduck
67f25161a3b37b1f3c486d5ef2e013486c3d9893
[ "BSD-2-Clause" ]
167
2017-10-30T12:07:29.000Z
2022-03-23T11:36:10.000Z
//---------------------------------------------------------------------------- // // TSDuck - The MPEG Transport Stream Toolkit // Copyright (c) 2005-2021, Thierry Lelegard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF // THE POSSIBILITY OF SUCH DAMAGE. // //---------------------------------------------------------------------------- #include "tsCipherChaining.h" //---------------------------------------------------------------------------- // Constructor for subclasses //---------------------------------------------------------------------------- ts::CipherChaining::CipherChaining(BlockCipher* cipher, size_t iv_min_blocks, size_t iv_max_blocks, size_t work_blocks) : algo(cipher), block_size(algo == nullptr ? 0 : algo->blockSize()), iv_min_size(iv_min_blocks * block_size), iv_max_size(iv_max_blocks * block_size), iv(iv_max_blocks * block_size), work(work_blocks * block_size) { } //---------------------------------------------------------------------------- // Default implementation of virtual methods. //---------------------------------------------------------------------------- size_t ts::CipherChaining::minIVSize() const { return iv_min_size; } size_t ts::CipherChaining::maxIVSize() const { return iv_max_size; } //---------------------------------------------------------------------------- // Implementation of BlockCipher interface: //---------------------------------------------------------------------------- size_t ts::CipherChaining::blockSize() const { return algo == nullptr ? 0 : algo->blockSize(); } size_t ts::CipherChaining::minKeySize() const { return algo == nullptr ? 0 : algo->minKeySize(); } size_t ts::CipherChaining::maxKeySize() const { return algo == nullptr ? 0 : algo->maxKeySize(); } bool ts::CipherChaining::isValidKeySize(size_t size) const { return algo == nullptr ? 0 : algo->isValidKeySize(size); } size_t ts::CipherChaining::minRounds() const { return algo == nullptr ? 0 : algo->minRounds(); } size_t ts::CipherChaining::maxRounds() const { return algo == nullptr ? 0 : algo->maxRounds(); } size_t ts::CipherChaining::defaultRounds() const { return algo == nullptr ? 0 : algo->defaultRounds(); } bool ts::CipherChaining::setKeyImpl(const void* key, size_t key_length, size_t rounds) { return algo != nullptr && algo->setKey(key, key_length, rounds); } //---------------------------------------------------------------------------- // Set a new IV. //---------------------------------------------------------------------------- bool ts::CipherChaining::setIV(const void* iv_data, size_t iv_length) { if (iv_min_size == 0 && iv_length == 0) { iv.clear(); return true; } else if (iv_data == nullptr || iv_length < iv_min_size || iv_length > iv_max_size) { iv.clear(); return false; } else { iv.copy(iv_data, iv_length); return true; } }
33.007874
121
0.57896
harmonicinc-com
9ed33833715eff9c6df0fcfce988b29108843402
7,775
cpp
C++
ProjectEuler+/euler-0341.cpp
sarvekash/HackerRank_Solutions
8f48e5b1a6e792a85a10d8c328cd1f5341fb16a8
[ "Apache-2.0" ]
null
null
null
ProjectEuler+/euler-0341.cpp
sarvekash/HackerRank_Solutions
8f48e5b1a6e792a85a10d8c328cd1f5341fb16a8
[ "Apache-2.0" ]
null
null
null
ProjectEuler+/euler-0341.cpp
sarvekash/HackerRank_Solutions
8f48e5b1a6e792a85a10d8c328cd1f5341fb16a8
[ "Apache-2.0" ]
1
2021-05-28T11:14:34.000Z
2021-05-28T11:14:34.000Z
// //////////////////////////////////////////////////////// // # Title // Golomb's self-describing sequence // // # URL // https://projecteuler.net/problem=341 // http://euler.stephan-brumme.com/341/ // // # Problem // The Golomb's self-describing sequence `G(n)` is the only nondecreasing sequence of natural numbers such that `n` appears exactly `G(n)` times in the sequence. // The values of `G(n)` for the first few `n` are // // || 4 || 2 || 2 || 2 || 2 || 2 || 2 || 2 || 2 || 2 || 2 || 2 || 2 || 2 || 2 || 2 || 2 || // || `n` || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12 || 13 || 14 || 15 || ... || // || `G(n)` || 1 || 2 || 2 || 3 || 3 || 4 || 4 || 4 || 5 || 5 || 5 || 6 || 6 || 6 || 6 || ... || // // You are given that `G(10^3) = 86`, `G(10^6) = 6137`. // You are also given that `sum{G(n^3)} = 153506976` for `1 <= n < 10^3`. // // Find `sum{G(n^3)}` for `1 <= n < 10^6`. // // # Solved by // Stephan Brumme // August 2017 // // # Algorithm // I brute forced the first values up to 100 (far more can be found here: https://oeis.org/A001462/b001462.txt ) and observed a certain pattern: // - `G(1) = 1` and there is exactly one `G(x) = 1` // - `G(2) = 2` and there are two `x` such that `G(x) = 2` (it's 2 and 3) // - `G(4) = 3` and there are two `x` such that `G(x) = 3` (it's 4 and 5) // - `G(6) = 4` and there are three `x` such that `G(x) = 4` (it's 6, 7 and 8) // - `G(9) = 5` and there are three `x` such that `G(x) = 5` (it's 9, 10 and 11) // - `G(12) = 6` and there are four `x` such that `G(x) = 6` (it's 12, 13, 14 and 15) // - ... // // ==> the number of identical `G(x)` increments by one after `sum{x * G(x)}` steps: // `1 * G(1) = 1 * 1 = 1` ==> all `G(x > 1)` appear at least twice // `1 * G(1) + 2 * G(2) = 1 + 4 = 5` ==> all `G(x > 5)` appear at least three times // `1 * G(1) + 2 * G(2) + 3 * G(3) = 1 + 4 + 6 = 11` ==> all `G(x > 11)` appear at least four times // I store these products in ''products[]'' (or compute them on-the-fly in the ''LOW_MEMORY'' code path). // // It turns out that `sum{x * G(x)} > {10^6}^3` for `x approx 10 million`. // Brute-forcing the first few million values of the Golomb sequence is no problem using the "recursive" Wikipedia formula: // `a(1) = 1` // `a(n+1) = 1 + a (n + 1 - a( a(n) ) )` // which can be simplified for `a(n)` // `a(n) = 1 + a (n - a( a(n - 1) ) )` // // Once I know the upper limit of the number of elements I make use of a second observation: // I already demonstrated that `G(1..3)` is sufficient to know that any number `6 <= x <= 11` maps to a value to appears three times in the Golomb sequence. // But I still don't know which number ! (it can be 4 or 5) // The sums `G(1) + G(2) = 3` and `G(1) + G(2) + G(3) = 5` have a nice property: // I know there 6 values between those sums (it's 6 to 11). If I find the relative position ''ratio'' between the relevant products, then the sum at the same relative position contains the correct value. // // Let's compute `G(x)` for `x = 10`: // `from = products[2] = 5` // `to = products[3] = 11` // // `ratio = dfrac{10 - from}{to - from} = dfrac{10 - 5}{11 - 5} = dfrac{5}{6} approx 0.83333` // // `low = sums[2] = G(1) + G(2) = 3` // `high = sums[3] = G(1) + G(2) + G(3) = 5` // // `G(10) = low + roundUp((high - low) * ratio) = 3 + roundUp((5 - 3) * 0.83333) = 5` // // (that's good old https://en.wikipedia.org/wiki/Linear_interpolation ) // // My code became a mess when I replaced the temporary containers ''sums'' and ''produces'' by variables. // However, it cut the memory usage by 50%: from about 270 MByte (slightly above the inofficial limit of 256 MByte) down to [135 MByte](/performance/#memory). // ''#define LOW_MEMORY'' is also about twice as fast. // // # Note // The Wikipedia page describes an O(1) formula which is unfortunately only asymptotic correct: // the result is more or less pretty close to the actual value but can't be used to solve this problem. // Nevertheless, the ''fast'' function helped me a lot in my debugging session when some intermediate values were "strange". // // Let's be honest: I discovered the connections between `G(x)` the sums and the products more or less by chance when I spent time on the commuter train home. // It was trial'n'error all the way - and therefore it's definitely not amongst my favorite problems. #include <iostream> #include <vector> #include <cmath> // find the asymptotic value, quite often off by a few numbers (first four digits tend to be okay) // note: unused code, but helped me a lot during debugging double fast(unsigned long long n) { // golden ratio const auto phi = (1 + sqrt(5.0)) / 2; const auto constant = pow(phi, 2 - phi); // see https://en.wikipedia.org/wiki/Golomb_sequence return constant * pow(n, phi - 1); } int main() { unsigned int limit = 1000000; std::cin >> limit; // (10^6)^3 = 10^18 auto cubicLimit = (unsigned long long) limit * limit * limit; // index 0 is not used, golomb(1) = 1 std::vector<unsigned long long> golomb = { 0, 1 }; #define LOW_MEMORY #ifdef LOW_MEMORY // precompute golomb[i] = G(i) // stop when 1*G(1) + 2*G(2) + 3*G(3) + ... + i*G(i) >= 10^18 unsigned long long products = 1; for (unsigned long long i = 2; products < cubicLimit; i++) { // https://en.wikipedia.org/wiki/Golomb_sequence auto current = 1 + golomb[i - golomb[golomb[i - 1]]]; golomb.push_back(current); products += current * i; } #else // precompute golomb[i] = G(i) // and sums[i] = G(1) + G(2) + G(3) + ... + G(i) // and products[i] = 1*G(1) + 2*G(2) + 3*G(3) + ... + i*G(i) std::vector<unsigned long long> sums = { 0, 1 }; std::vector<unsigned long long> products = { 0, 1 }; // stop when products[i] >= 10^18 for (unsigned long long i = 2; products.back() < cubicLimit; i++) { auto current = 1 + golomb[i - golomb[golomb[i - 1]]]; golomb .push_back(current); sums .push_back(current + sums.back()); products.push_back(current * i + products.back()); } #endif // will contain the result unsigned long long sum = 0; #ifdef LOW_MEMORY unsigned long long lastSums = 0; unsigned long long sums = 1; unsigned long long lastProducts = 0; products = 1; #endif // find products[index - 1] < i <= products[index] auto index = 1; for (unsigned long long i = 1; i < limit; i++) { // n = i^3 auto n = i * i * i; // find products[index - 1] < i <= products[index] #ifdef LOW_MEMORY while (products < n) { index++; lastSums = sums; sums += golomb[index]; lastProducts = products; products += golomb[index] * index; } #else while (products[index] < n) index++; #endif // note: n will be in ascending order, therefore I re-use index from previous iterations // in most cases it will be already the correct value // find linear interpolation between products[index - 1] and products[index] #ifdef LOW_MEMORY auto from = lastProducts; auto to = products; #else auto from = products[index - 1]; auto to = products[index]; #endif auto ratio = (n - from) / double(to - from); // and apply it to sums[index - 1] and sums[index] #ifdef LOW_MEMORY auto low = lastSums; auto high = sums; #else auto low = sums[index - 1]; auto high = sums[index]; #endif // round up auto offset = ceil((high - low) * ratio); // note: convert to integer as soon as possible to avoid losing digits due to double's limited precision auto result = (unsigned long long)offset + low; // finished another number ... sum += result; } // solved another problem ! std::cout << sum << std::endl; return 0; }
38.112745
203
0.590611
sarvekash
9ed85862684081952eaa378ce68d29fcbc72a44b
671
cpp
C++
tests/testFrameworkConsistencyTests.cpp
wulcat/Physics3D
dab5574f28f1e2831d568a5ce104f1b4a7bc28bb
[ "MIT" ]
1
2021-02-14T07:07:51.000Z
2021-02-14T07:07:51.000Z
tests/testFrameworkConsistencyTests.cpp
sierra-zero/Physics3D
155aa492dbe83cfd1d8d41ac9180312823a51d8b
[ "MIT" ]
null
null
null
tests/testFrameworkConsistencyTests.cpp
sierra-zero/Physics3D
155aa492dbe83cfd1d8d41ac9180312823a51d8b
[ "MIT" ]
1
2021-03-28T18:51:10.000Z
2021-03-28T18:51:10.000Z
#include "testsMain.h" #include "compare.h" #include "testValues.h" #include "simulation.h" #include "randomValues.h" #include <array> #include "../physics/misc/toString.h" #include "../physics/math/taylorExpansion.h" #define DELTA_T 0.005 TEST_CASE(testEstimateDerivativesOfComputeOverTime) { FullTaylorExpansion<double, 5> startTaylor = createRandomFullTaylorExpansion<double, 5, createRandomDouble>(); logStream << "startTaylor: " << startTaylor << "\n"; std::array<double, 5> points = computeOverTime(startTaylor, DELTA_T); FullTaylorExpansion<double, 5> endTaylor = estimateDerivatives(points, DELTA_T); ASSERT_TOLERANT(startTaylor == endTaylor, 0.01); }
30.5
111
0.76155
wulcat
9eda29730982c2a791c7d3fdbff4d7120bd1c219
10,395
cpp
C++
user_models/src/ican_app_dtnsubscriber.cpp
uclanrl/dt-icansim
3d4288145abe4cafbbd75af2b0bc697c0bebe4e8
[ "bzip2-1.0.6" ]
null
null
null
user_models/src/ican_app_dtnsubscriber.cpp
uclanrl/dt-icansim
3d4288145abe4cafbbd75af2b0bc697c0bebe4e8
[ "bzip2-1.0.6" ]
null
null
null
user_models/src/ican_app_dtnsubscriber.cpp
uclanrl/dt-icansim
3d4288145abe4cafbbd75af2b0bc697c0bebe4e8
[ "bzip2-1.0.6" ]
null
null
null
/* * Copyright (c) 2013, Network Research Lab, University of California, Los Angeles * Coded by Yu-Ting Yu [yutingyu@cs.ucla.edu] * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the distribution. * Neither the name of the University of California, Los Angeles nor the names of its contributors * may be used to endorse or promote products derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "ican_app_dtnsubscriber.h" #include <fstream> CIcanDtnSubscriber::~CIcanDtnSubscriber() { delete m_pRegisteredObject; } CIcanDtnSubscriber::CIcanDtnSubscriber(Node* node, std::string szExpName):m_node(node), m_expName(szExpName) { m_pRegisteredObject = new RegisteredNameSet; } CIcanDtnSubscriber::CIcanDtnSubscriber(Node* node, std::string szConfigName, std::string szExpName):m_node(node), m_expName(szExpName) { m_pRegisteredObject = new RegisteredNameSet; //parse .app ParseConfig(szConfigName); } //----------------------------------------------------------------------------- // FUNCTION PrintDebugInfo() // PURPOSE print debug information //----------------------------------------------------------------------------- void CIcanDtnSubscriber::PrintDebugInfo() { } //----------------------------------------------------------------------------- // FUNCTION EventHandler() // PURPOSE Handle App Client events // PARAMETER Node* node // Message* msg // The event message //----------------------------------------------------------------------------- bool CIcanDtnSubscriber::EventHandler(Node* node, Message* msg) { switch (MESSAGE_GetEvent(msg)) { case MSG_ROUTING_ICAN_DTNSUBSCRIBER_SUBSCRIBE: { IcanDtnAppTimerInfo* sInfo = (IcanDtnAppTimerInfo*) MESSAGE_ReturnInfo(msg); if(!sInfo) { char errorString[MAX_STRING_LENGTH]; sprintf(errorString, "%s, line %d: MSG_ROUTING_ICAN_DTNSUBSCRIBER_SUBSCRIBE returns NULL info", __FILE__, __LINE__); ERROR_ReportError(errorString); } else { #ifdef DEBUG_ICAN_APP PrintTime(node); dbgprintf("receives MSG_ROUTING_ICAN_DTNSUBSCRIBER_SUBSCRIBE"); #endif //register object SetIcanEvent(m_node, 0, MSG_ROUTING_ICAN_DTNMANAGER_SUBSCRIBE, sizeof(IcanDtnAppTimerInfo), sInfo); std::string objName(sInfo->namePrefix); m_pRegisteredObject->insert(objName); m_stat.totalDORegistered++; } MESSAGE_Free(node, msg); return true; break; } case MSG_ROUTING_ICAN_DTNSUBSCRIBER_RECEIVE: { IcanDtnAppTimerInfo* sInfo = (IcanDtnAppTimerInfo*) MESSAGE_ReturnInfo(msg); std::string receivedObjName(sInfo->namePrefix); m_stat.totalDOReceived++; //If I have previously registered this object, unregister this object if(m_pRegisteredObject->find(receivedObjName)!=m_pRegisteredObject->end()){ //calculate delay clocktype startTime = m_RegisterTimeKeeper[receivedObjName]; clocktype delay = getSimTime(node) - startTime; m_delayKeeper[receivedObjName] = delay; m_RegisterTimeKeeper.erase(receivedObjName); //unregister m_pRegisteredObject->erase(receivedObjName); SetIcanEvent(m_node, 0, MSG_ROUTING_ICAN_DTNMANAGER_UNSUBSCRIBE, sizeof(*sInfo), sInfo); } MESSAGE_Free(node, msg); return true; break; } } return false; } //----------------------------------------------------------------------------- // FUNCTION RegisterInterest() // PURPOSE Register Interest to DTNManager //----------------------------------------------------------------------------- void CIcanDtnSubscriber::RegisterInterest() { //register interest } //----------------------------------------------------------------------------- // FUNCTION DataPacketHandler(Node* node, Message* msg) // PURPOSE Does nothing for DTN since the application does not need to handle interest transport // PARAMETER Node* node // pointer to node // Message* msg // Received data packet (format: DataPktHeader|payload) //----------------------------------------------------------------------------- void CIcanDtnSubscriber::DataPacketHandler(Node* node, Message* msg) { MESSAGE_Free(node, msg); } //----------------------------------------------------------------------------- // FUNCTION PrintStat(Node * node, NetworkType networkType) // PURPOSE Print statistics // PARAMETER Node* node // pointer to node // NetworkType networkType // Network type //----------------------------------------------------------------------------- void CIcanDtnSubscriber::PrintStat(Node * node, NetworkType networkType) { //Compute mean, min, max delay clocktype minDelay = 999999999999999999; clocktype maxDelay = 0; clocktype totalDelay = 0; clocktype numDelay = 0; if(m_delayKeeper.size()>0){ //generate delay stat file std::string outputFileName = m_expName + "."+ IntToString(m_node->nodeIndex+1) +".dtnsubstat"; std::ofstream fout(outputFileName.c_str()); for(std::map<std::string, clocktype>::const_iterator itr = m_delayKeeper.begin(); itr != m_delayKeeper.end(); ++itr){ std::string objName = (*itr).first; clocktype delay = (*itr).second; totalDelay += delay; numDelay ++; if(minDelay > delay) minDelay = delay; if(maxDelay < delay) maxDelay = delay; char clockStr[MAX_STRING_LENGTH]; TIME_PrintClockInSecond(delay, clockStr); std::string delayStr(clockStr); fout<<objName<<", "<<delayStr<<std::endl; } fout.close(); } char buf[MAX_STRING_LENGTH]; std::string AppName = "DTNSUB"; // Print statistics sprintf(buf, "Total DOs registered= %u", m_stat.totalDORegistered); IO_PrintStat(node, AppName.c_str(), "ICAN", ANY_DEST, 0, buf); sprintf(buf, "Total DOs received = %u", m_stat.totalDOReceived); IO_PrintStat(node, AppName.c_str(), "ICAN", ANY_DEST, 0, buf); if(numDelay > 0){ clocktype meanDelay = totalDelay / numDelay; char clockStr[MAX_STRING_LENGTH]; TIME_PrintClockInSecond(meanDelay, clockStr); sprintf(buf, "Average Delay= %s", clockStr); IO_PrintStat(node, AppName.c_str(), "ICAN", ANY_DEST, 0, buf); TIME_PrintClockInSecond(minDelay, clockStr); sprintf(buf, "Min Delay= %s", clockStr); IO_PrintStat(node, AppName.c_str(), "ICAN", ANY_DEST, 0, buf); TIME_PrintClockInSecond(maxDelay, clockStr); sprintf(buf, "Max Delay= %s", clockStr); IO_PrintStat(node, AppName.c_str(), "ICAN", ANY_DEST, 0, buf); TIME_PrintClockInSecond(totalDelay, clockStr); sprintf(buf, "Total Delay= %s", clockStr); IO_PrintStat(node, AppName.c_str(), "ICAN", ANY_DEST, 0, buf); sprintf(buf, "Number Delay= %d", numDelay); IO_PrintStat(node, AppName.c_str(), "ICAN", ANY_DEST, 0, buf); } } bool CIcanDtnSubscriber::IsTransferComplete(Node* node) { //Does nothing.. return false; } void CIcanDtnSubscriber::ParseConfig(std::string szConfigName){ //config format: <data_object_ID data_object_size subscribe_time> std::cout<<"Node "<<m_node->nodeIndex+1<<" parsing config "<<szConfigName<<std::endl; std::ifstream inputfile(szConfigName.c_str()); if(inputfile){ const int LINESIZE = 99999; char line[LINESIZE]; memset(line,0,sizeof(char)*LINESIZE); while(inputfile.getline (line,LINESIZE)){ char charObjectId[9999]; int objectSize; char charSubscribeTime[9999]; memset(charObjectId,0,sizeof(char)*9999); memset(charSubscribeTime,0,sizeof(char)*9999); sscanf (line," %s %d %s ", charObjectId, &objectSize, charSubscribeTime); std::string objectID(charObjectId); std::string subscribeTime(charSubscribeTime); std::cout<<"osbject ID: "<<objectID<<" " <<"object size: "<<objectSize<<" " <<"subscribeTime: "<<subscribeTime<<" " <<std::endl; clocktype tPublishTime = (clocktype) TIME_ConvertToClock(subscribeTime.c_str()); IcanDtnAppTimerInfo subinfo; strncpy(subinfo.namePrefix, objectID.c_str(), sizeof(subinfo.namePrefix)); m_RegisterTimeKeeper[objectID] = tPublishTime; subinfo.size = objectSize; SetIcanEvent(m_node, tPublishTime, MSG_ROUTING_ICAN_DTNSUBSCRIBER_SUBSCRIBE, sizeof(IcanDtnAppTimerInfo), &subinfo); memset(line,0,sizeof(char)*LINESIZE); } } else{ ReportError("Subscriber config error"); } inputfile.close(); }
38.076923
187
0.607792
uclanrl
9edbf9448db565c20b097a07588c012e7583c0b1
5,958
cpp
C++
test/MathUtils.test.cpp
Brett208/nas2d-core
f9506540f32d34f3c60bc83b87b34460d582ae81
[ "Zlib" ]
null
null
null
test/MathUtils.test.cpp
Brett208/nas2d-core
f9506540f32d34f3c60bc83b87b34460d582ae81
[ "Zlib" ]
null
null
null
test/MathUtils.test.cpp
Brett208/nas2d-core
f9506540f32d34f3c60bc83b87b34460d582ae81
[ "Zlib" ]
null
null
null
#include "NAS2D/MathUtils.h" #include <gmock/gmock.h> #include <gtest/gtest.h> TEST(MathUtils, lineIntersectsCircle) { const auto circleCenter = NAS2D::Point{0, 0}; // Interior EXPECT_TRUE((lineIntersectsCircle(NAS2D::Point{-1, 0}, NAS2D::Point{1, 0}, circleCenter, 1))); EXPECT_TRUE((lineIntersectsCircle(NAS2D::Point{0, -1}, NAS2D::Point{0, 1}, circleCenter, 1))); EXPECT_TRUE((lineIntersectsCircle(NAS2D::Point{-1, -1}, NAS2D::Point{1, 1}, circleCenter, 1))); EXPECT_TRUE((lineIntersectsCircle(NAS2D::Point{-1, 1}, NAS2D::Point{1, -1}, circleCenter, 1))); EXPECT_TRUE((lineIntersectsCircle(NAS2D::Point{-1, -1}, NAS2D::Point{1, 2}, circleCenter, 1))); EXPECT_TRUE((lineIntersectsCircle(NAS2D::Point{-1, -1}, NAS2D::Point{2, 1}, circleCenter, 1))); // Boundary EXPECT_FALSE((lineIntersectsCircle(NAS2D::Point{-1, -1}, NAS2D::Point{1, -1}, circleCenter, 1))); EXPECT_FALSE((lineIntersectsCircle(NAS2D::Point{-1, 1}, NAS2D::Point{1, 1}, circleCenter, 1))); EXPECT_FALSE((lineIntersectsCircle(NAS2D::Point{-1, -1}, NAS2D::Point{-1, 1}, circleCenter, 1))); EXPECT_FALSE((lineIntersectsCircle(NAS2D::Point{1, -1}, NAS2D::Point{1, 1}, circleCenter, 1))); // Exterior EXPECT_FALSE((lineIntersectsCircle(NAS2D::Point{-1, -2}, NAS2D::Point{1, -2}, circleCenter, 1))); EXPECT_FALSE((lineIntersectsCircle(NAS2D::Point{-1, 2}, NAS2D::Point{1, 2}, circleCenter, 1))); EXPECT_FALSE((lineIntersectsCircle(NAS2D::Point{-2, -1}, NAS2D::Point{-2, 1}, circleCenter, 1))); EXPECT_FALSE((lineIntersectsCircle(NAS2D::Point{2, -1}, NAS2D::Point{2, 1}, circleCenter, 1))); } TEST(MathUtils, divideUpByZero) { EXPECT_THROW(NAS2D::divideUp(0, 0), std::domain_error); EXPECT_THROW(NAS2D::divideUp(1, 0), std::domain_error); EXPECT_THROW(NAS2D::divideUp(2, 0), std::domain_error); EXPECT_THROW(NAS2D::divideUp(256, 0), std::domain_error); } TEST(MathUtils, divideUp) { EXPECT_EQ(0, NAS2D::divideUp(0, 1)); EXPECT_EQ(0, NAS2D::divideUp(0, 2)); EXPECT_EQ(0, NAS2D::divideUp(0, 3)); EXPECT_EQ(1, NAS2D::divideUp(1, 1)); EXPECT_EQ(1, NAS2D::divideUp(1, 2)); EXPECT_EQ(1, NAS2D::divideUp(1, 3)); EXPECT_EQ(2, NAS2D::divideUp(2, 1)); EXPECT_EQ(1, NAS2D::divideUp(2, 2)); EXPECT_EQ(1, NAS2D::divideUp(2, 3)); EXPECT_EQ(1, NAS2D::divideUp(5, 8)); EXPECT_EQ(256, NAS2D::divideUp(256, 1)); EXPECT_EQ(128, NAS2D::divideUp(256, 2)); EXPECT_EQ(86, NAS2D::divideUp(256, 3)); EXPECT_EQ(64, NAS2D::divideUp(256, 4)); EXPECT_EQ(52, NAS2D::divideUp(256, 5)); EXPECT_EQ(43, NAS2D::divideUp(256, 6)); EXPECT_EQ(37, NAS2D::divideUp(256, 7)); EXPECT_EQ(32, NAS2D::divideUp(256, 8)); EXPECT_EQ(29, NAS2D::divideUp(256, 9)); EXPECT_EQ(26, NAS2D::divideUp(256, 10)); EXPECT_EQ(24, NAS2D::divideUp(256, 11)); EXPECT_EQ(22, NAS2D::divideUp(256, 12)); EXPECT_EQ(20, NAS2D::divideUp(256, 13)); } TEST(MathUtils, roundUpPowerOf2) { EXPECT_EQ(1u, NAS2D::roundUpPowerOf2(1)); EXPECT_EQ(2u, NAS2D::roundUpPowerOf2(2)); EXPECT_EQ(4u, NAS2D::roundUpPowerOf2(3)); EXPECT_EQ(4u, NAS2D::roundUpPowerOf2(4)); EXPECT_EQ(8u, NAS2D::roundUpPowerOf2(5)); EXPECT_EQ(8u, NAS2D::roundUpPowerOf2(8)); EXPECT_EQ(16u, NAS2D::roundUpPowerOf2(9)); EXPECT_EQ(16u, NAS2D::roundUpPowerOf2(16)); EXPECT_EQ(32u, NAS2D::roundUpPowerOf2(17)); EXPECT_EQ(32u, NAS2D::roundUpPowerOf2(32)); EXPECT_EQ(64u, NAS2D::roundUpPowerOf2(33)); EXPECT_EQ(64u, NAS2D::roundUpPowerOf2(64)); EXPECT_EQ(128u, NAS2D::roundUpPowerOf2(65)); EXPECT_EQ(128u, NAS2D::roundUpPowerOf2(128)); EXPECT_EQ(256u, NAS2D::roundUpPowerOf2(129)); EXPECT_EQ(256u, NAS2D::roundUpPowerOf2(256)); EXPECT_EQ(512u, NAS2D::roundUpPowerOf2(257)); EXPECT_EQ(512u, NAS2D::roundUpPowerOf2(512)); EXPECT_EQ(1024u, NAS2D::roundUpPowerOf2(513)); EXPECT_EQ(1024u, NAS2D::roundUpPowerOf2(1024)); EXPECT_EQ(2048u, NAS2D::roundUpPowerOf2(1025)); EXPECT_EQ(2048u, NAS2D::roundUpPowerOf2(2048)); EXPECT_EQ(4096u, NAS2D::roundUpPowerOf2(2049)); EXPECT_EQ(4096u, NAS2D::roundUpPowerOf2(4096)); EXPECT_EQ(32768u, NAS2D::roundUpPowerOf2(32768)); EXPECT_EQ(65536u, NAS2D::roundUpPowerOf2(32769)); EXPECT_EQ(65536u, NAS2D::roundUpPowerOf2(65536)); EXPECT_EQ(8388608u, NAS2D::roundUpPowerOf2(8388608)); EXPECT_EQ(16777216u, NAS2D::roundUpPowerOf2(8388609)); EXPECT_EQ(16777216u, NAS2D::roundUpPowerOf2(16777216)); // Largest value before 32-bit overflow of result EXPECT_EQ(2147483648u, NAS2D::roundUpPowerOf2(2147483648)); } TEST(MathUtils, mapDomainToRange) { // Fahrenheit to Celcius EXPECT_NEAR(-18.33333f, NAS2D::scaleLinear(-1.0f, 32.0f, 212.0f, 0.0f, 100.0f), 0.0001f); EXPECT_NEAR(-18.33333f, NAS2D::scaleLinear(-1.0f, 212.0f, 32.0f, 100.0f, 0.0f), 0.0001f); EXPECT_NEAR(0.0f, NAS2D::scaleLinear(32.0f, 32.0f, 212.0f, 0.0f, 100.0f), 0.0001f); EXPECT_NEAR(-17.77777f, NAS2D::scaleLinear(0.0f, 32.0f, 212.0f, 0.0f, 100.0f), 0.0001f); EXPECT_NEAR(-17.22222f, NAS2D::scaleLinear(1.0f, 32.0f, 212.0f, 0.0f, 100.0f), 0.0001f); EXPECT_NEAR(100.0f, NAS2D::scaleLinear(212.0f, 32.0f, 212.0f, 0.0f, 100.0f), 0.0001f); // Celcius to Fahrenheit EXPECT_NEAR(30.2f, NAS2D::scaleLinear(-1.0f, 0.0f, 100.0f, 32.0f, 212.0f), 0.0001f); EXPECT_NEAR(32.0f, NAS2D::scaleLinear(0.0f, 0.0f, 100.0f, 32.0f, 212.0f), 0.0001f); EXPECT_NEAR(33.8f, NAS2D::scaleLinear(1.0f, 0.0f, 100.0f, 32.0f, 212.0f), 0.0001f); EXPECT_NEAR(212.0f, NAS2D::scaleLinear(100.0f, 0.0f, 100.0f, 32.0f, 212.0f), 0.0001f); // unsigned char to normalized float EXPECT_NEAR(0.0f, (NAS2D::scaleLinear<unsigned char, float>(0, 0, 255, 0.0f, 1.0f)), 0.01f); EXPECT_NEAR(0.5f, (NAS2D::scaleLinear<unsigned char, float>(128, 0, 255, 0.0f, 1.0f)), 0.01f); EXPECT_NEAR(1.0f, (NAS2D::scaleLinear<unsigned char, float>(255, 0, 255, 0.0f, 1.0f)), 0.01f); EXPECT_NEAR(-1.0f, (NAS2D::scaleLinear<unsigned char, float>(0, 0, 255, -1.0f, 1.0f)), 0.01f); EXPECT_NEAR(0.0f, (NAS2D::scaleLinear<unsigned char, float>(128, 0, 255, -1.0f, 1.0f)), 0.01f); EXPECT_NEAR(1.0f, (NAS2D::scaleLinear<unsigned char, float>(255, 0, 255, -1.0f, 1.0f)), 0.01f); }
46.546875
98
0.708795
Brett208
9ede447ed61fcffdf1e327dd5c7977b4c8d4b2d3
5,819
cpp
C++
examples/stencils.cpp
MaxZZG/SpatialOps
c673081a6214ac3020d2fa92d09663922815f740
[ "MIT" ]
null
null
null
examples/stencils.cpp
MaxZZG/SpatialOps
c673081a6214ac3020d2fa92d09663922815f740
[ "MIT" ]
null
null
null
examples/stencils.cpp
MaxZZG/SpatialOps
c673081a6214ac3020d2fa92d09663922815f740
[ "MIT" ]
null
null
null
/** The MIT License Copyright (c) 2014-2017 The University of Utah Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \file stencils.cpp \date Jul 10, 2014 \author James C. Sutherland \page example-stencils Using stencils with fields # Goal Illustrate how to use stencil operators within SpatialOps/Nebo # Key Concepts -# There are a number of predefined operators/stencils in SpatialOps. The simplest way to obtain these is via the \link SpatialOps::BasicOpTypes BasicOpTypes\endlink struct. Much of this was covered in \ref example-stencil-type-inference -# Stencils can be stored and retrieved in the \link SpatialOps::OperatorDatabase OperatorDatabase\endlink which provides simple storage and retrieval of operators by type. -# SpatialOps defines many stencils for use on structured, finite-volume meshes. The `build_stencils` function can be used to easily populate an OperatorDatabase with the predefined operators in SpatialOps. # Example Code \c examples/stencils.cpp \include stencils.cpp # Try this Modify \c stencils.cpp to do the following: -# Use two interpolants to calculate `f` at faces and then interpolate back to cell centers: \code{.cpp} f2 <<= interpf2c( interpc2f( f ) ); \endcode To do this: - Obtain the interpolant types. Note that `interpc2f` is already there, and you can use \link SpatialOps::BasicOpTypes BasicOpTypes \endlink \code{.cpp} BasicOpTypes<SVolField>::InterpF2CX \endcode to get the operator type for face to cell interpolation. - Build the `f2` field (use `dfdx` and `fface` as examples). -# Instead of building `dfdx` and `fface` as shown in the example, use the `SpatialFieldStore` as shown in \ref example-field-creation \code{.cpp} SpatFldPtr<SSurfXField> dfdxPtr = SpatialFieldStore::get<SSurfXField>( x ); \endcode Note that you will have a pointer now, so will need to de-reference it as appropriate when using it in nebo statements. \sa \ref example-stencil-type-inference */ #include <spatialops/structured/FVStaggered.h> #include <spatialops/structured/Grid.h> using namespace SpatialOps; // If we are compiling with GPU CUDA support, create fields on the device. // Otherwise, create them on the host. #ifdef ENABLE_CUDA # define LOCATION GPU_INDEX #else # define LOCATION CPU_INDEX #endif #define PI 3.141592653589793 int main() { //---------------------------------------------------------------------------- // Define the domain size and number of points const DoubleVec length(PI,PI,PI); // a cube of length pi on each side const IntVec fieldDim( 10, 1, 1 ); // a 1-D problem //---------------------------------------------------------------------------- // Create fields const bool bcx=true, bcy=true, bcz=true; const IntVec bc(bcx,bcy,bcz); const GhostData nghost(1); const BoundaryCellInfo sVolBCInfo = BoundaryCellInfo::build<SVolField >( bc, bc ); const BoundaryCellInfo ssxBCInfo = BoundaryCellInfo::build<SSurfXField>( bc, bc ); const MemoryWindow sVolWindow( get_window_with_ghost( fieldDim, nghost, sVolBCInfo) ); const MemoryWindow ssxWindow( get_window_with_ghost( fieldDim, nghost, ssxBCInfo ) ); SVolField x( sVolWindow, sVolBCInfo, nghost, NULL, InternalStorage, LOCATION ); SVolField f( sVolWindow, sVolBCInfo, nghost, NULL, InternalStorage, LOCATION ); SSurfXField dfdx( ssxWindow, ssxBCInfo, nghost, NULL, InternalStorage, LOCATION ); SSurfXField fface( ssxWindow, ssxBCInfo, nghost, NULL, InternalStorage, LOCATION ); //---------------------------------------------------------------------------- // Build a grid. This is a convenient way to set coordinate values that will // be used below. const Grid grid( fieldDim, length ); grid.set_coord<XDIR>(x); //---------------------------------------------------------------------------- // Build the operators (stencils). Here we will use predefined stencils that // can be built easily. OperatorDatabase opDB; // holds stencils that can be retrieved easily build_stencils( grid, opDB ); // builds stencils and places them in opDB typedef BasicOpTypes<SVolField>::GradX GradX; // x-derivative operator type typedef BasicOpTypes<SVolField>::InterpC2FX InterpX; // x-interpolant operator type const GradX& gradx = *opDB.retrieve_operator<GradX >(); // retrieve the GradX operator const InterpX& interpx = *opDB.retrieve_operator<InterpX>(); // retrieve the InterpX operator //---------------------------------------------------------------------------- // perform calculations f <<= sin( x ); // Initialize the function value dfdx <<= gradx( f ); // gradient of f at the x-faces fface <<= interpx( f ); // interpolated value of f at the x-faces return 0; }
40.409722
96
0.691184
MaxZZG
9ede70af27567db4985f78d522c08cb52960c29f
28,457
cpp
C++
src/gui/settings.cpp
amoekesch/Kompass
34f8f9d6579f4c221282d79b6b61f678baa0f738
[ "MIT" ]
null
null
null
src/gui/settings.cpp
amoekesch/Kompass
34f8f9d6579f4c221282d79b6b61f678baa0f738
[ "MIT" ]
null
null
null
src/gui/settings.cpp
amoekesch/Kompass
34f8f9d6579f4c221282d79b6b61f678baa0f738
[ "MIT" ]
1
2022-01-29T02:33:54.000Z
2022-01-29T02:33:54.000Z
#include "settings.h" Settings::Settings(TrayIcon *trayIcon, QWidget *parent) : QDialog(parent) { this->trayIcon = trayIcon; setupUi(); setupData(); } /** * Setup dialog elements * @brief Settings::setupUi */ void Settings::setupUi() { /** * ------------------------------------------- * set dialog basics */ this->setWindowTitle(tr("dialogTitle")); this->setWindowIcon(QIcon(":/img/kompass.png")); this->setContentsMargins(0, 0, 0, 0); this->setMinimumSize(800, 494); this->setMaximumSize(800, 494); this->resize(800,494); this->setWindowModality(Qt::WindowModality::ApplicationModal); /** * ------------------------------------------- * checkbox and dropdown controls */ cmbIconConnected = new QComboBox(); cmbIconDisconnected = new QComboBox(); cmbIconConnected->insertItem(trayIcon->indexBlue, tr("iconBlue")); cmbIconConnected->insertItem(trayIcon->indexGreen, tr("iconGreen")); cmbIconConnected->insertItem(trayIcon->indexRed, tr("iconRed")); cmbIconConnected->insertItem(trayIcon->indexWhite, tr("iconWhite")); cmbIconConnected->insertItem(trayIcon->indexBlack, tr("iconBlack")); cmbIconConnected->insertItem(trayIcon->indexGrey25, tr("iconGrey25")); cmbIconConnected->insertItem(trayIcon->indexGrey50, tr("iconGrey50")); cmbIconConnected->insertItem(trayIcon->indexGrey75, tr("iconGrey75")); cmbIconConnected->setItemIcon(trayIcon->indexBlue, trayIcon->iconBlue); cmbIconConnected->setItemIcon(trayIcon->indexGreen, trayIcon->iconGreen); cmbIconConnected->setItemIcon(trayIcon->indexRed, trayIcon->iconRed); cmbIconConnected->setItemIcon(trayIcon->indexWhite, trayIcon->iconWhite); cmbIconConnected->setItemIcon(trayIcon->indexBlack, trayIcon->iconBlack); cmbIconConnected->setItemIcon(trayIcon->indexGrey25, trayIcon->iconGrey25); cmbIconConnected->setItemIcon(trayIcon->indexGrey50, trayIcon->iconGrey50); cmbIconConnected->setItemIcon(trayIcon->indexGrey75, trayIcon->iconGrey75); cmbIconDisconnected->insertItem(trayIcon->indexBlue, tr("iconBlue")); cmbIconDisconnected->insertItem(trayIcon->indexGreen, tr("iconGreen")); cmbIconDisconnected->insertItem(trayIcon->indexRed, tr("iconRed")); cmbIconDisconnected->insertItem(trayIcon->indexWhite, tr("iconWhite")); cmbIconDisconnected->insertItem(trayIcon->indexBlack, tr("iconBlack")); cmbIconDisconnected->insertItem(trayIcon->indexGrey25, tr("iconGrey25")); cmbIconDisconnected->insertItem(trayIcon->indexGrey50, tr("iconGrey50")); cmbIconDisconnected->insertItem(trayIcon->indexGrey75, tr("iconGrey75")); cmbIconDisconnected->setItemIcon(trayIcon->indexBlue, trayIcon->iconBlue); cmbIconDisconnected->setItemIcon(trayIcon->indexGreen, trayIcon->iconGreen); cmbIconDisconnected->setItemIcon(trayIcon->indexRed, trayIcon->iconRed); cmbIconDisconnected->setItemIcon(trayIcon->indexWhite, trayIcon->iconWhite); cmbIconDisconnected->setItemIcon(trayIcon->indexBlack, trayIcon->iconBlack); cmbIconDisconnected->setItemIcon(trayIcon->indexGrey25, trayIcon->iconGrey25); cmbIconDisconnected->setItemIcon(trayIcon->indexGrey50, trayIcon->iconGrey50); cmbIconDisconnected->setItemIcon(trayIcon->indexGrey75, trayIcon->iconGrey75); cmbIconConnected->blockSignals(true); cmbIconDisconnected->blockSignals(true); cmbIconConnected->setCurrentIndex(trayIcon->getCurrentIndexConnected()); cmbIconDisconnected->setCurrentIndex(trayIcon->getCurrentIndexDisconnected()); cmbIconConnected->blockSignals(false); cmbIconDisconnected->blockSignals(false); QObject::connect(cmbIconConnected, &QComboBox::currentTextChanged, [this]() { setEnabled(false); cmbIconConnected->blockSignals(true); trayIcon->setCurrentIndexConnected(cmbIconConnected->currentIndex()); cmbIconConnected->blockSignals(false); displayStatus(QString()); setEnabled(true); }); QObject::connect(cmbIconDisconnected, &QComboBox::currentTextChanged, [this]() { setEnabled(false); cmbIconDisconnected->blockSignals(true); trayIcon->setCurrentIndexDisconnected(cmbIconDisconnected->currentIndex()); cmbIconDisconnected->blockSignals(false); displayStatus(QString()); setEnabled(true); }); cmbTechnology = new QComboBox(); QObject::connect(cmbTechnology, &QComboBox::currentTextChanged, [this]() { setEnabled(false); QString result = saveSettings(QStringList() << "set" << "technology" << cmbTechnology->currentText()); if (result.length() > 0) { result = result.prepend(tr("errorPrefixTechnology")); cmbTechnology->blockSignals(true); cmbTechnology->setCurrentIndex(cmbTechnology->findText(technology, Qt::MatchFlag::MatchFixedString)); cmbTechnology->blockSignals(false); } setupData(); displayStatus(result); setEnabled(true); }); cmbProtocol = new QComboBox(); QObject::connect(cmbProtocol, &QComboBox::currentTextChanged, [this]() { setEnabled(false); QString result = saveSettings(QStringList() << "set" << "protocol" << cmbProtocol->currentText()); if (result.length() > 0) { result = result.prepend(tr("errorPrefixProtocol")); cmbProtocol->blockSignals(true); cmbProtocol->setCurrentIndex(cmbProtocol->findText(protocol, Qt::MatchFlag::MatchFixedString)); cmbProtocol->blockSignals(false); } setupData(); displayStatus(result); setEnabled(true); }); cbFirewall = new ToggleButton(8, 10); QObject::connect(cbFirewall, &ToggleButton::clicked, [this]() { setEnabled(false); QString result = saveSettings(QStringList() << "set" << "firewall" << ((cbFirewall->isChecked()) ? "enabled" : "disabled")); if (result.length() > 0) { result = result.prepend(tr("errorPrefixFirewall")); cbFirewall->blockSignals(true); cbFirewall->setChecked(!cbFirewall->isChecked()); cbFirewall->blockSignals(false); } setupData(); displayStatus(result); setEnabled(true); }); cbCybersec = new ToggleButton(8, 10); QObject::connect(cbCybersec, &ToggleButton::clicked, [this]() { setEnabled(false); QString result = saveSettings(QStringList() << "set" << "cybersec" << ((cbCybersec->isChecked()) ? "enabled" : "disabled")); if (result.length() > 0) { result = result.prepend(tr("errorPrefixCybersec")); cbCybersec->blockSignals(true); cbCybersec->setChecked(!cbCybersec->isChecked()); cbCybersec->blockSignals(false); } setupData(); displayStatus(result); setEnabled(true); }); cbObfuscate = new ToggleButton(8, 10); QObject::connect(cbObfuscate, &ToggleButton::clicked, [this]() { setEnabled(false); QString result = saveSettings(QStringList() << "set" << "obfuscate" << ((cbObfuscate->isChecked()) ? "enabled" : "disabled")); if (result.length() > 0) { result = result.prepend(tr("errorPrefixObfuscate")); cbObfuscate->blockSignals(true); cbObfuscate->setChecked(!cbObfuscate->isChecked()); cbObfuscate->blockSignals(false); } setupData(); displayStatus(result); setEnabled(true); }); cbNotify = new ToggleButton(8, 10); QObject::connect(cbNotify, &ToggleButton::clicked, [this]() { setEnabled(false); QString result = saveSettings(QStringList() << "set" << "notify" << ((cbNotify->isChecked()) ? "enabled" : "disabled")); if (result.length() > 0) { result = result.prepend(tr("errorPrefixNotify")); cbNotify->blockSignals(true); cbNotify->setChecked(!cbNotify->isChecked()); cbNotify->blockSignals(false); } setupData(); displayStatus(result); setEnabled(true); }); cbAutoconnect = new ToggleButton(8, 10); QObject::connect(cbAutoconnect, &ToggleButton::clicked, [this]() { setEnabled(false); QString result = saveSettings(QStringList() << "set" << "autoconnect" << ((cbAutoconnect->isChecked()) ? "enabled" : "disabled")); if (result.length() > 0) { result = result.prepend(tr("errorPrefixAutoconnect")); cbAutoconnect->blockSignals(true); cbAutoconnect->setChecked(!cbAutoconnect->isChecked()); cbAutoconnect->blockSignals(false); } setupData(); displayStatus(result); setEnabled(true); }); cbIPv6 = new ToggleButton(8, 10); QObject::connect(cbIPv6, &ToggleButton::clicked, [this]() { setEnabled(false); QString result = saveSettings(QStringList() << "set" << "ipv6" << ((cbIPv6->isChecked()) ? "enabled" : "disabled")); if (result.length() > 0) { result = result.prepend(tr("errorPrefixIPv6")); cbIPv6->blockSignals(true); cbIPv6->setChecked(!cbIPv6->isChecked()); cbIPv6->blockSignals(false); } setupData(); displayStatus(result); setEnabled(true); }); cbKillswitch = new ToggleButton(8, 10); QObject::connect(cbKillswitch, &ToggleButton::clicked, [this]() { setEnabled(true); QString result = saveSettings(QStringList() << "set" << "killswitch" << ((cbKillswitch->isChecked()) ? "enabled" : "disabled")); if (result.length() > 0) { result = result.prepend(tr("errorPrefixKillswitch")); cbKillswitch->blockSignals(true); cbKillswitch->setChecked(!cbKillswitch->isChecked()); cbKillswitch->blockSignals(false); } setupData(); displayStatus(result); setEnabled(true); }); /** * ------------------------------------------- * Settings: Connection */ QLabel *lblTechnology = new QLabel(tr("lblTechnology")); lblTechnology->setStyleSheet("font-weight: bold;"); lblTechnology->setMinimumWidth(160); QLabel *lblProtocol = new QLabel(tr("lblProtocol")); lblProtocol->setStyleSheet("font-weight: bold;"); lblProtocol->setMinimumWidth(160); QHBoxLayout *layoutTechnology = new QHBoxLayout(); layoutTechnology->addWidget(lblTechnology); layoutTechnology->addWidget(cmbTechnology); layoutTechnology->setStretch(1, 1); QHBoxLayout *layoutProtocol = new QHBoxLayout(); layoutProtocol->addWidget(lblProtocol); layoutProtocol->addWidget(cmbProtocol); layoutProtocol->setStretch(1, 1); QLabel *lblIPv6Toggle = new QLabel(tr("lblIPv6Toggle")); lblIPv6Toggle->setStyleSheet("font-weight: bold;"); QLabel *lblIPv6Details = new QLabel(tr("lblIPv6Details")); lblIPv6Details->setWordWrap(true); QHBoxLayout *layoutIPv6Toggle = new QHBoxLayout(); layoutIPv6Toggle->addWidget(cbIPv6); layoutIPv6Toggle->addSpacing(20); layoutIPv6Toggle->addWidget(lblIPv6Toggle); layoutIPv6Toggle->setStretch(2, 1); QLabel *lblObfuscateToggle = new QLabel(tr("lblObfuscateToggle")); lblObfuscateToggle->setStyleSheet("font-weight: bold;"); QLabel *lblObfuscateDetails = new QLabel(tr("lblObfuscateDetails")); lblObfuscateDetails->setWordWrap(true); QHBoxLayout *layoutObfuscateToggle = new QHBoxLayout(); layoutObfuscateToggle->addWidget(cbObfuscate); layoutObfuscateToggle->addSpacing(20); layoutObfuscateToggle->addWidget(lblObfuscateToggle); layoutObfuscateToggle->setStretch(2, 1); QLabel *lblAutoconnectToggle = new QLabel(tr("lblAutoconnectToggle")); lblAutoconnectToggle->setStyleSheet("font-weight: bold;"); QLabel *lblAutoconnectDetails = new QLabel(tr("lblAutoconnectDetails")); lblAutoconnectDetails->setWordWrap(true); QHBoxLayout *layoutAutoconnectToggle = new QHBoxLayout(); layoutAutoconnectToggle->addWidget(cbAutoconnect); layoutAutoconnectToggle->addSpacing(20); layoutAutoconnectToggle->addWidget(lblAutoconnectToggle); layoutAutoconnectToggle->setStretch(2, 1); QVBoxLayout *layoutConnection = new QVBoxLayout(); layoutConnection->addItem(layoutTechnology); layoutConnection->addSpacing(20); layoutConnection->addItem(layoutProtocol); layoutConnection->addSpacing(20); layoutConnection->addItem(layoutIPv6Toggle); layoutConnection->addSpacing(10); layoutConnection->addWidget(lblIPv6Details); layoutConnection->addSpacing(20); layoutConnection->addItem(layoutObfuscateToggle); layoutConnection->addSpacing(10); layoutConnection->addWidget(lblObfuscateDetails); layoutConnection->addSpacing(20); layoutConnection->addItem(layoutAutoconnectToggle); layoutConnection->addSpacing(10); layoutConnection->addWidget(lblAutoconnectDetails); layoutConnection->addStretch(1); QWidget *wConnection = new QWidget(); wConnection->setLayout(layoutConnection); /** * ------------------------------------------- * Settings: Kill Switch */ QLabel *lblKillswitchToggle = new QLabel(tr("lblKillswitchToggle")); lblKillswitchToggle->setStyleSheet("font-weight: bold;"); QLabel *lblKillswitchDetails = new QLabel(tr("lblKillswitchDetails")); lblKillswitchDetails->setWordWrap(true); QHBoxLayout *layoutKillswitchToggle = new QHBoxLayout(); layoutKillswitchToggle->addWidget(cbKillswitch); layoutKillswitchToggle->addSpacing(20); layoutKillswitchToggle->addWidget(lblKillswitchToggle); layoutKillswitchToggle->setStretch(2, 1); QVBoxLayout *layoutKillswitch = new QVBoxLayout(); layoutKillswitch->addItem(layoutKillswitchToggle); layoutKillswitch->addSpacing(10); layoutKillswitch->addWidget(lblKillswitchDetails); layoutKillswitch->addStretch(1); QWidget *wKillswitch = new QWidget(); wKillswitch->setLayout(layoutKillswitch); /** * ------------------------------------------- * Settings: Cyber Securty */ QLabel *lblCybersecToggle = new QLabel(tr("lblCybersecToggle")); lblCybersecToggle->setStyleSheet("font-weight: bold;"); QLabel *lblCybersecDetails = new QLabel(tr("lblCybersecDetails")); lblCybersecDetails->setWordWrap(true); QHBoxLayout *layoutCybersecToggle = new QHBoxLayout(); layoutCybersecToggle->addWidget(cbCybersec); layoutCybersecToggle->addSpacing(20); layoutCybersecToggle->addWidget(lblCybersecToggle); layoutCybersecToggle->setStretch(2, 1); QVBoxLayout *layoutCybersec = new QVBoxLayout(); layoutCybersec->addItem(layoutCybersecToggle); layoutCybersec->addSpacing(10); layoutCybersec->addWidget(lblCybersecDetails); layoutCybersec->addStretch(1); QWidget *wCybersec = new QWidget(); wCybersec->setLayout(layoutCybersec); /** * ------------------------------------------- * Settings: Firewall */ QLabel *lblFirewallToggle = new QLabel(tr("lblFirewallToggle")); lblFirewallToggle->setStyleSheet("font-weight: bold;"); QLabel *lblFirewallDetails = new QLabel(tr("lblFirewallDetails")); lblFirewallDetails->setWordWrap(true); QHBoxLayout *layoutFirewallToggle = new QHBoxLayout(); layoutFirewallToggle->addWidget(cbFirewall); layoutFirewallToggle->addSpacing(20); layoutFirewallToggle->addWidget(lblFirewallToggle); layoutFirewallToggle->setStretch(2, 1); QVBoxLayout *layoutFirewall = new QVBoxLayout(); layoutFirewall->addItem(layoutFirewallToggle); layoutFirewall->addSpacing(10); layoutFirewall->addWidget(lblFirewallDetails); layoutFirewall->addStretch(1); QWidget *wFirewall = new QWidget(); wFirewall->setLayout(layoutFirewall); /** * ------------------------------------------- * Settings: Notifications */ QLabel *lblNotifyToggle = new QLabel(tr("lblNotifyToggle")); lblNotifyToggle->setStyleSheet("font-weight: bold;"); QLabel *lblNotifyDetails = new QLabel(tr("lblNotifyDetails")); lblNotifyDetails->setWordWrap(true); QHBoxLayout *layoutNotifyToggle = new QHBoxLayout(); layoutNotifyToggle->addWidget(cbNotify); layoutNotifyToggle->addSpacing(20); layoutNotifyToggle->addWidget(lblNotifyToggle); layoutNotifyToggle->setStretch(2, 1); QVBoxLayout *layoutNotify = new QVBoxLayout(); layoutNotify->addItem(layoutNotifyToggle); layoutNotify->addSpacing(10); layoutNotify->addWidget(lblNotifyDetails); layoutNotify->addStretch(1); QWidget *wNotify = new QWidget(); wNotify->setLayout(layoutNotify); /** * ------------------------------------------- * Settings: Kompass */ QLabel *lblIconConnected = new QLabel(tr("lblIconConnected")); lblIconConnected->setStyleSheet("font-weight: bold;"); lblIconConnected->setMinimumWidth(240); QLabel *lblIconConnectedDescription = new QLabel(tr("lblIconConnectedDescription")); lblIconConnectedDescription->setWordWrap(true); QLabel *lblIconDisconnected = new QLabel(tr("lblIconDisconnected")); lblIconDisconnected->setStyleSheet("font-weight: bold;"); lblIconDisconnected->setMinimumWidth(240); QLabel *lblIconDisconnectedDescription = new QLabel(tr("lblIconDisconnectedDescription")); lblIconDisconnectedDescription->setWordWrap(true); QHBoxLayout *layoutIconConnected = new QHBoxLayout(); layoutIconConnected->addWidget(lblIconConnected); layoutIconConnected->addWidget(cmbIconConnected); layoutIconConnected->setStretch(1, 1); QHBoxLayout *layoutIconDisconnected = new QHBoxLayout(); layoutIconDisconnected->addWidget(lblIconDisconnected); layoutIconDisconnected->addWidget(cmbIconDisconnected); layoutIconDisconnected->setStretch(1, 1); QVBoxLayout *layoutKompass = new QVBoxLayout(); layoutKompass->addItem(layoutIconConnected); layoutKompass->addSpacing(10); layoutKompass->addWidget(lblIconConnectedDescription); layoutKompass->addSpacing(20); layoutKompass->addItem(layoutIconDisconnected); layoutKompass->addSpacing(10); layoutKompass->addWidget(lblIconDisconnectedDescription); layoutKompass->addSpacing(20); layoutKompass->addStretch(1); QWidget *wKompass = new QWidget(); wKompass->setLayout(layoutKompass); /** * ------------------------------------------- * add setting detal panels into stack */ stackSettings = new QStackedWidget(); stackSettings->setContentsMargins(20, 25, 20, 20); stackSettings->addWidget(wConnection); stackSettings->addWidget(wKillswitch); stackSettings->addWidget(wCybersec); stackSettings->addWidget(wFirewall); stackSettings->addWidget(wNotify); stackSettings->addWidget(wKompass); /** * ------------------------------------------- * create settings menu */ menu = new KompassMenu(stackSettings); menu->appendMenuItem("\uf0c1", tr("mnConnection"), 0); menu->appendMenuItem("\uf1e2", tr("mnKillswitch"), 1); menu->appendMenuItem("\uf132", tr("mnCybersec"), 2); menu->appendMenuItem("\uf06d", tr("mnFirewall"), 3); menu->appendMenuItem("\uf0a1", tr("mnNotify"), 4); menu->appendMenuItem("\uf14e", tr("mnKompass"), 5); menu->select(0); QVBoxLayout *layoutMenu = new QVBoxLayout(); layoutMenu->setContentsMargins(0, 28, 0, 20); layoutMenu->addWidget(menu); layoutMenu->addStretch(1); QWidget *wxMenuWrapper = new QWidget(); wxMenuWrapper->setMinimumWidth(200); wxMenuWrapper->setMaximumWidth(200); wxMenuWrapper->setAutoFillBackground(true); wxMenuWrapper->setStyleSheet("background: " + this->palette().light().color().name() + ";"); wxMenuWrapper->setLayout(layoutMenu); /** * ------------------------------------------- * create button controls */ QPushButton *pbClose = new QPushButton(); pbClose->setText(tr("pbClose")); pbClose->setIcon(QIcon(":/img/close.png")); pbClose->setMinimumWidth(140); QObject::connect(pbClose, &QPushButton::clicked, [this]() { this->close(); }); QGridLayout *layoutDialogControls = new QGridLayout(); layoutDialogControls->setContentsMargins(20, 0, 20, 15); layoutDialogControls->addWidget(pbClose, 0, 1); layoutDialogControls->setColumnStretch(0, 1); /** * ------------------------------------------- * create dialog layout and add all components */ QGridLayout *layoutMain = new QGridLayout(); layoutMain->setContentsMargins(0, 0, 0, 0); layoutMain->addWidget(wxMenuWrapper, 0, 0, 3, 1); layoutMain->addWidget(stackSettings, 0, 1, 1, 1); layoutMain->addItem(layoutDialogControls, 2, 1, 1, 1); layoutMain->rowStretch(2); layoutMain->columnStretch(1); this->setLayout(layoutMain); } /** * Load and parse data into controls * @brief Settings::setupData */ void Settings::setupData() { /** * ------------------------------------------- * available technologies */ QProcess *commandTechnologies = new QProcess(); commandTechnologies->start("nordvpn", QStringList() << "set" << "technology" << "--help"); commandTechnologies->waitForFinished(); QString outputTechnologies = commandTechnologies->readAllStandardOutput(); // parse output QStringList technologies = outputTechnologies.trimmed().split(QString("\n")); for (QString line : technologies) { if (line.toLower().contains("supported values")) { line = line.mid(line.indexOf(":") + 1); QStringList technologyList = QStringList(); if (line.contains(",")) { technologyList.append(line.split(",")); } else if (line.contains(" or ")) { technologyList.append(line.split(" or ")); } cmbTechnology->blockSignals(true); cmbTechnology->clear(); for (QString technologyElement : technologyList) { technologyElement = technologyElement.replace(QRegularExpression("\\.+$"), ""); cmbTechnology->addItem(technologyElement.trimmed()); } cmbTechnology->blockSignals(false); } } /** * ------------------------------------------- * available protocols */ QProcess *commandProtocols = new QProcess(); commandProtocols->start("nordvpn", QStringList() << "set" << "protocol" << "--help"); commandProtocols->waitForFinished(); QString outputProtocols = commandProtocols->readAllStandardOutput(); // parse output QStringList protocols = outputProtocols.trimmed().split(QString("\n")); for (QString line : protocols) { if (line.toLower().contains("supported values")) { line = line.mid(line.indexOf(":") + 1); QStringList protocolList = QStringList(); if (line.contains(",")) { protocolList.append(line.split(",")); } else if (line.contains(" or ")) { protocolList.append(line.split("or")); } cmbProtocol->blockSignals(true); cmbProtocol->clear(); for (QString protocolElement : protocolList) { protocolElement = protocolElement.replace(QRegularExpression("\\.+$"), ""); cmbProtocol->addItem(protocolElement.trimmed()); } cmbProtocol->blockSignals(false); } } /** * ------------------------------------------- * load current settings */ QProcess *command = new QProcess(); command->start("nordvpn", QStringList() << "settings"); command->waitForFinished(); QString output = command->readAllStandardOutput(); // parse output QStringList lines = output.trimmed().split(QString("\n")); for (QString line : lines) { if (line.trimmed().toLower().contains("technology")) { technology = line.mid(line.indexOf(":") + 1).trimmed(); int index = cmbTechnology->findText(technology, Qt::MatchFlag::MatchFixedString); if (index != -1 ) { cmbTechnology->blockSignals(true); cmbTechnology->setCurrentIndex(index); cmbTechnology->blockSignals(false); } } else if (line.trimmed().toLower().contains("protocol")) { protocol = line.mid(line.indexOf(":") + 1).trimmed(); int index = cmbProtocol->findText(protocol, Qt::MatchFlag::MatchFixedString); if (index != -1 ) { cmbProtocol->blockSignals(true); cmbProtocol->setCurrentIndex(index); cmbProtocol->blockSignals(false); } } else if (line.trimmed().toLower().contains("firewall")) { firewall = line.mid(line.indexOf(":") + 1).trimmed() == "enabled"; cbFirewall->setChecked(firewall); } else if (line.trimmed().toLower().contains("kill")) { killswitch = line.mid(line.indexOf(":") + 1).trimmed() == "enabled"; cbKillswitch->setChecked(killswitch); } else if (line.trimmed().toLower().contains("cybersec")) { cybersec = line.mid(line.indexOf(":") + 1).trimmed() == "enabled"; cbCybersec->setChecked(cybersec); } else if (line.trimmed().toLower().contains("obfuscate")) { obfuscate = line.mid(line.indexOf(":") + 1).trimmed() == "enabled"; cbObfuscate->setChecked(obfuscate); } else if (line.trimmed().toLower().contains("auto")) { autoconnect = line.mid(line.indexOf(":") + 1).trimmed() == "enabled"; cbAutoconnect->setChecked(autoconnect); } else if (line.trimmed().toLower().contains("ipv6")) { ipv6 = line.mid(line.indexOf(":") + 1).trimmed() == "enabled"; cbIPv6->setChecked(ipv6); } else if (line.trimmed().toLower().contains("notify")) { notify = line.mid(line.indexOf(":") + 1).trimmed() == "enabled"; cbNotify->setChecked(notify); } } } void Settings::displayStatus(QString errorMessage) { QMessageBox *msg = new QMessageBox(this); msg->setWindowModality(Qt::WindowModality::ApplicationModal); msg->setWindowIcon(QIcon(":/img/kompass.png")); msg->setDefaultButton(QMessageBox::Ok); msg->setStandardButtons(QMessageBox::Ok); msg->setMinimumSize(600, 357); msg->setMaximumSize(600, 357); if (errorMessage == nullptr || errorMessage.length() == 0) { msg->setWindowTitle(tr("dlgSuccessTitle")); msg->setIcon(QMessageBox::Information); msg->setText(tr("dlgSuccessMessage")); } else { QString html = errorMessage.trimmed().replace("\n", "<br>"); msg->setWindowTitle(tr("dlgErrorTitle")); msg->setIcon(QMessageBox::Warning); msg->setText(tr("dlgErrorMessage")); msg->setInformativeText(html); } msg->show(); msg->activateWindow(); msg->raise(); } void Settings::setEnabled(bool status) { cmbTechnology->setEnabled(status); cmbProtocol->setEnabled(status); cbFirewall->setEnabled(status); cbCybersec->setEnabled(status); cbObfuscate->setEnabled(status); cbNotify->setEnabled(status); cbAutoconnect->setEnabled(status); cbIPv6->setEnabled(status); cbKillswitch->setEnabled(status); } QString Settings::saveSettings(QStringList commands) { QProcess *command = new QProcess(); command->start("nordvpn", commands); command->waitForFinished(); QString output = command->readAllStandardOutput(); QString error = command->readAllStandardError(); if ((error == nullptr || error.trimmed().length() == 0) && !output.contains("successfully", Qt::CaseSensitivity::CaseInsensitive) && !output.contains("already set", Qt::CaseSensitivity::CaseInsensitive) ) { error = output.trimmed(); } return (error == nullptr) ? "" : error.trimmed(); }
37.443421
138
0.640827
amoekesch
9edf986f0f9e9a08f05feccaca123622858ba98b
1,888
hpp
C++
src/include/carve/collection_types.hpp
paulobala/ofxCarveCSG
03ed31758cd866f78252ecbd734b8ed1adffe6f9
[ "MIT" ]
3
2015-05-19T08:46:57.000Z
2020-05-25T06:38:02.000Z
src/include/carve/collection_types.hpp
paulobala/ofxCarveCSG
03ed31758cd866f78252ecbd734b8ed1adffe6f9
[ "MIT" ]
null
null
null
src/include/carve/collection_types.hpp
paulobala/ofxCarveCSG
03ed31758cd866f78252ecbd734b8ed1adffe6f9
[ "MIT" ]
1
2019-05-24T15:32:56.000Z
2019-05-24T15:32:56.000Z
// Begin License: // Copyright (C) 2006-2011 Tobias Sargeant (tobias.sargeant@gmail.com). // All rights reserved. // // This file is part of the Carve CSG Library (http://carve-csg.com/) // // This file may be used under the terms of the GNU General Public // License version 2.0 as published by the Free Software Foundation // and appearing in the file LICENSE.GPL2 included in the packaging of // this file. // // This file is provided "AS IS" with NO WARRANTY OF ANY KIND, // INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE. // End: #pragma once #include <carve.hpp> #include <mesh.hpp> namespace carve { namespace csg { typedef std::pair< carve::mesh::MeshSet<3>::vertex_t *, carve::mesh::MeshSet<3>::vertex_t *> V2; typedef std::pair< carve::mesh::MeshSet<3>::face_t *, carve::mesh::MeshSet<3>::face_t *> F2; static inline V2 ordered_edge( carve::mesh::MeshSet<3>::vertex_t *a, carve::mesh::MeshSet<3>::vertex_t *b) { return V2(std::min(a, b), std::max(a, b)); } static inline V2 flip(const V2 &v) { return V2(v.second, v.first); } // include/carve/csg.hpp include/carve/faceloop.hpp // lib/intersect.cpp lib/intersect_classify_common_impl.hpp // lib/intersect_classify_edge.cpp // lib/intersect_classify_group.cpp // lib/intersect_classify_simple.cpp // lib/intersect_face_division.cpp lib/intersect_group.cpp // lib/intersect_half_classify_group.cpp typedef std::unordered_set<V2> V2Set; // include/carve/csg.hpp include/carve/polyhedron_decl.hpp // lib/csg_collector.cpp lib/intersect.cpp // lib/intersect_common.hpp lib/intersect_face_division.cpp // lib/polyhedron.cpp typedef std::unordered_map< carve::mesh::MeshSet<3>::vertex_t *, carve::mesh::MeshSet<3>::vertex_t *> VVMap; } }
29.5
71
0.683792
paulobala
9ee255db45690eb8a2dbc85303ce700bf39fdcdf
2,735
cpp
C++
doc/4.4.0/MPG/linear.cpp
zayenz/gecode.github.io
e759c2c1940d9a018373bcc6c316d9cb04efa5a0
[ "MIT-feh" ]
1
2020-10-28T06:11:30.000Z
2020-10-28T06:11:30.000Z
doc/4.4.0/MPG/linear.cpp
zayenz/gecode.github.io
e759c2c1940d9a018373bcc6c316d9cb04efa5a0
[ "MIT-feh" ]
1
2019-05-05T11:10:31.000Z
2019-05-05T11:10:31.000Z
doc/4.4.0/MPG/linear.cpp
zayenz/gecode.github.io
e759c2c1940d9a018373bcc6c316d9cb04efa5a0
[ "MIT-feh" ]
4
2019-05-03T18:43:19.000Z
2020-12-17T04:06:59.000Z
/* * Authors: * Christian Schulte <schulte@gecode.org> * * Copyright: * Christian Schulte, 2008-2015 * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software, to deal in the software without restriction, * including without limitation the rights to use, copy, modify, merge, * publish, distribute, sublicense, and/or sell copies of the software, * and to permit persons to whom the software is furnished to do so, subject * to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ #include <gecode/float.hh> using namespace Gecode; class Linear : public TernaryPropagator<Float::FloatView,Float::PC_FLOAT_BND> { public: Linear(Home home, Float::FloatView x0, Float::FloatView x1, Float::FloatView x2) : TernaryPropagator<Float::FloatView,Float::PC_FLOAT_BND> (home,x0,x1,x2) {} static ExecStatus post(Home home, Float::FloatView x0, Float::FloatView x1, Float::FloatView x2) { (void) new (home) Linear(home,x0,x1,x2); return ES_OK; } Linear(Space& home, bool share, Linear& p) : TernaryPropagator<Float::FloatView,Float::PC_FLOAT_BND>(home,share,p) {} virtual Propagator* copy(Space& home, bool share) { return new (home) Linear(home,share,*this); } virtual ExecStatus propagate(Space& home, const ModEventDelta&) { using namespace Float; // create rounding object Rounding r; // prune upper bounds GECODE_ME_CHECK(x0.lq(home,-r.add_down(x1.min(),x2.min()))); GECODE_ME_CHECK(x1.lq(home,-r.add_down(x0.min(),x2.min()))); GECODE_ME_CHECK(x2.lq(home,-r.add_down(x0.min(),x1.min()))); // prune lower bounds GECODE_ME_CHECK(x0.gq(home,-r.add_up(x1.max(),x2.max()))); GECODE_ME_CHECK(x1.gq(home,-r.add_up(x0.max(),x2.max()))); GECODE_ME_CHECK(x2.gq(home,-r.add_up(x0.max(),x1.max()))); return (x0.assigned() && x1.assigned()) ? home.ES_SUBSUMED(*this) : ES_NOFIX; } }; void linear(Home home, FloatVar x0, FloatVar x1, FloatVar x2) { if (home.failed()) return; GECODE_ES_FAIL(Linear::post(home,x0,x1,x2)); }
39.637681
78
0.692139
zayenz
9ee2f3dab5e307e5ba646b7683cfebbbb5798f91
41,408
hpp
C++
[教程] [本人] Counterstrike Global Offensive/Q.hvh陀螺自瞄/bsp_parser.hpp
RuiAoo/Game-Cheating-Tutorial
8d67314d42ae019a7b7d2ed85c2be4f0a2199297
[ "MIT" ]
4
2020-12-25T19:18:06.000Z
2022-03-25T01:55:37.000Z
[教程] [本人] Counterstrike Global Offensive/Q.hvh陀螺自瞄/bsp_parser.hpp
themaoci/Game-Cheating-Tutorial
8d67314d42ae019a7b7d2ed85c2be4f0a2199297
[ "MIT" ]
null
null
null
[教程] [本人] Counterstrike Global Offensive/Q.hvh陀螺自瞄/bsp_parser.hpp
themaoci/Game-Cheating-Tutorial
8d67314d42ae019a7b7d2ed85c2be4f0a2199297
[ "MIT" ]
2
2022-03-22T05:51:02.000Z
2022-03-22T11:34:59.000Z
///-------------------------------------------------------------------------------- ///-- Author ReactiioN ///-- Copyright 2016-2020, ReactiioN ///-- License MIT ///-------------------------------------------------------------------------------- #ifndef BSPPARSERH #define BSPPARSERH #pragma warning(disable : 4005) #define $$$ {} #undef min #define max(x,y) x>y?x:y #define NOMINMAX #ifdef DEBUG #define RN_BSP_PARSER_MESSAGES #endif #include <array> #include <algorithm> #include <cmath> #include <fstream> #include <string> #include <vector> #include <filesystem> #include <d3dx9math.h> #include "obfuscator.hpp" namespace rn::detail { template<std::size_t num_rows, std::size_t num_cols> class matrix_t { using type_array = std::array<float, num_rows * num_cols>; static constexpr std::size_t clamp_index( const std::size_t index ) { return std::clamp(index, std::numeric_limits<size_t>::min(), size() - 1); $$$; } public: matrix_t() { static_assert(num_rows >= 1 && num_cols >= 1, "minimal size for columns and rows is 1"); $$$; } matrix_t( const matrix_t& rhs ) = default; matrix_t( matrix_t&& rhs ) noexcept { *this = std::move(rhs); } explicit matrix_t( const type_array& values ) : _data(values) { } template<typename ...arguments> matrix_t( arguments&& ...args ) : _data{ static_cast<float>(std::forward<arguments>(args))... } { } ~matrix_t() = default; matrix_t& operator = ( const matrix_t& rhs ) = default; matrix_t& operator = ( matrix_t&& rhs ) noexcept { _data = rhs._data; $$$; rhs.clear(); $$$; return *this; $$$; } static constexpr std::size_t size() { return num_rows * num_cols; $$$; } static constexpr std::size_t rows() { return num_rows; $$$; } static constexpr std::size_t cols() { return num_cols; $$$; } static constexpr bool is_vector() { return (num_cols == 1 || num_rows == 1) && (num_cols == 1 ? num_rows : num_cols) <= 4; $$$; } matrix_t& operator += ( const matrix_t& rhs ) { for (std::size_t i = 0; i < size(); ++i) { at(i) += rhs(i); $$$; } return *this; $$$; } matrix_t& operator += ( const float rhs ) { for (std::size_t i = 0; i < size(); ++i) { at(i) += rhs; $$$; } return *this; $$$; } matrix_t& operator -= ( const matrix_t& rhs ) { for (std::size_t i = 0; i < size(); ++i) { at(i) -= rhs(i); $$$; } return *this; $$$; } matrix_t& operator -= ( const float rhs ) { for (std::size_t i = 0; i < size(); ++i) { at(i) -= rhs; $$$; } return *this; $$$; } matrix_t& operator *= ( const float rhs ) { for (std::size_t i = 0; i < size(); ++i) { at(i) *= rhs; $$$; } return *this; $$$; } matrix_t& operator /= ( const float rhs ) { for (std::size_t i = 0; i < size(); ++i) { at(i) /= rhs; $$$; } return *this; $$$; } matrix_t operator + ( const matrix_t& rhs ) const { auto lhs = *this; $$$; lhs += rhs; $$$; return lhs; $$$; } matrix_t operator + ( const float rhs ) const { auto lhs = *this; $$$; lhs += rhs; $$$; return lhs; $$$; } matrix_t operator - ( const matrix_t& rhs ) const { auto lhs = *this; $$$; lhs -= rhs; $$$; return lhs; $$$; } matrix_t operator - ( const float rhs ) const { auto lhs = *this; $$$; lhs -= rhs; $$$; return lhs; $$$; } matrix_t operator * ( const float rhs ) const { auto lhs = *this; $$$; lhs *= rhs; $$$; return lhs; $$$; } matrix_t operator / ( const float rhs ) const { auto lhs = *this; $$$; lhs /= rhs; $$$; return lhs; $$$; } bool operator == ( const matrix_t& rhs ) { for (std::size_t i = 0; i < size(); ++i) { if (at(i) != rhs(i)) { return false; $$$; } } return true; $$$; } bool operator == ( const float rhs ) { for (std::size_t i = 0; i < size(); ++i) { if (at(i) != rhs) { return false; $$$; } } return true; $$$; } bool operator != ( const matrix_t& rhs ) { return !((*this) == rhs); $$$; } bool operator != ( const float rhs ) { return !((*this) == rhs); $$$; } float& operator () ( const std::size_t index ) { return at(index); $$$; } float& operator () ( const std::size_t row_index, const std::size_t col_index ) { return at(row_index, col_index); $$$; } const float& operator () ( const std::size_t index ) const { return at(index); $$$; } const float& operator () ( const std::size_t row_index, const std::size_t col_index ) const { return at(row_index, col_index); $$$; } float& at( const std::size_t index ) { return _data.at(clamp_index(index)); $$$; } float& at( const std::size_t row_index, const std::size_t col_index ) { return at(row_index * num_cols + col_index); $$$; } _NODISCARD const float& at( const std::size_t index ) const { return _data.at(clamp_index(index)); $$$; } _NODISCARD const float& at( const std::size_t row_index, const std::size_t col_index ) const { return at(row_index * num_cols + col_index); $$$; } _NODISCARD bool is_zero() const { return all_of(0.f); $$$; } _NODISCARD bool all_of( const float value ) const { return std::all_of(_data.begin(), _data.end(), [&value](const float x) { return x == value; }); } _NODISCARD float normsqr() const { static_assert(is_vector(), "norm() can only be used on vectors"); $$$; auto value = 0.f; $$$; for (const auto& x : _data) { value += (x * x); $$$; } return value; } _NODISCARD float norm() const { return std::sqrtf(normsqr()); $$$; } matrix_t<1, num_cols> row( const std::size_t index ) { std::array<float, num_cols> values; $$$; for (std::size_t i = 0; i < num_cols; ++i) { values[i] = at(index, i); $$$; } return matrix_t<1, num_cols>(values); $$$; } matrix_t<num_rows, 1> col( const std::size_t index ) { std::array<float, num_rows> values; $$$; for (std::size_t i = 0; i < num_rows; ++i) { values[i] = at(i, index); $$$; } return matrix_t<num_rows, 1>(values); $$$; } void row( const std::size_t index, const matrix_t<1, num_cols>& row_values ) { for (std::size_t i = 0; i < num_cols; ++i) { at(index, i) = row_values; $$$; } } void col( const std::size_t index, const matrix_t<num_rows, 1>& col_values ) { for (std::size_t i = 0; i < num_rows; ++i) { at(i, index) = col_values; $$$; } } void fill( const float value ) { _data.fill(value); $$$; } void clear() { fill(0.f); $$$; } void set( const type_array& values ) { _data = values; $$$; } void normalize() { static_assert(is_vector(), "normalize() can only be used on vectors"); $$$; (*this) /= norm(); $$$; } _NODISCARD matrix_t normalized() const { auto lhs = *this; $$$; lhs.normalize(); $$$; return lhs; $$$; } template<std::size_t rhs_num_rows, std::size_t rhs_num_cols> _NODISCARD float dot( const matrix_t<rhs_num_rows, rhs_num_cols>& rhs ) const { static_assert(is_vector() && matrix_t<rhs_num_rows, rhs_num_cols>::is_vector()); $$$; auto value = 0.f; $$$; const auto length = size() > rhs_num_rows * rhs_num_cols ? rhs_num_rows * rhs_num_cols : size(); $$$; for (std::size_t i = 0; i < length; ++i) { value += at(i) * rhs(i); $$$; } return value; } _NODISCARD matrix_t cross( const matrix_t& rhs ) const { static_assert(size() == 3, "cross() can only be used for 3 dimensional vectors"); $$$; return matrix_t{ at(1) * rhs(2) - at(2) * rhs(1), at(2) * rhs(0) - at(0) * rhs(2), at(0) * rhs(1) - at(1) * rhs(0), }; } _NODISCARD matrix_t ncross( const matrix_t& rhs ) const { auto ret = cross(rhs); $$$; ret.normalize(); $$$; return ret; $$$; } private: type_array _data{}; }; } namespace rn { using angle2 = detail::matrix_t<1, 2>; using angle3 = detail::matrix_t<1, 3>; using matrix3x4 = detail::matrix_t<3, 4>; using matrix4x4 = detail::matrix_t<4, 4>; using vector2 = detail::matrix_t<2, 1>; using vector3 = detail::matrix_t<3, 1>; using vector4 = detail::matrix_t<4, 1>; using vmatrix = matrix4x4; } namespace rn::valve { constexpr bool has_valid_bsp_ident( const std::int32_t ident ) { return ident >= ('P' << 24) + ('S' << 16) + ('B' << 8) + 'V'; } constexpr std::int32_t MAX_BRUSH_LIGHTMAP_DIM_WITHOUT_BORDER = 32; constexpr std::int32_t MAX_BRUSH_LIGHTMAP_DIM_INCLUDING_BORDER = 35; constexpr std::int32_t MAX_DISP_LIGHTMAP_DIM_WITHOUT_BORDER = 128; constexpr std::int32_t MAX_DISP_LIGHTMAP_DIM_INCLUDING_BORDER = 131; constexpr std::int32_t MAX_LIGHTMAP_DIM_WITHOUT_BORDER = MAX_DISP_LIGHTMAP_DIM_WITHOUT_BORDER; constexpr std::int32_t MAX_LIGHTMAP_DIM_INCLUDING_BORDER = MAX_DISP_LIGHTMAP_DIM_INCLUDING_BORDER; constexpr float DIST_EPSILON = 0.03125f; constexpr std::size_t MAX_SURFINFO_VERTS = 32; constexpr std::int32_t BSPVERSION = 19; constexpr std::size_t HEADER_LUMPS = 64; constexpr std::size_t MAX_POLYGONS = 50120; constexpr std::size_t MAX_MOD_KNOWN = 512; constexpr std::size_t MAX_MAP_MODELS = 1024; constexpr std::size_t MAX_MAP_BRUSHES = 8192; constexpr std::size_t MAX_MAP_ENTITIES = 4096; constexpr std::size_t MAX_MAP_ENTSTRING = 256 * 1024; constexpr std::size_t MAX_MAP_NODES = 65536; constexpr std::size_t MAX_MAP_TEXINFO = 12288; constexpr std::size_t MAX_MAP_TEXDATA = 2048; constexpr std::size_t MAX_MAP_LEAFBRUSHES = 65536; constexpr std::size_t MIN_MAP_DISP_POWER = 2; constexpr std::size_t MAX_MAP_DISP_POWER = 4; constexpr std::size_t MAX_MAP_SURFEDGES = 512000; constexpr std::size_t MAX_DISP_CORNER_NEIGHBORS = 4; // NOTE: These are stored in a short in the engine now. Don't use more than 16 bits constexpr std::int32_t SURF_LIGHT = 0x0001; // value will hold the light strength constexpr std::int32_t SURF_SLICK = 0x0002; // effects game physics constexpr std::int32_t SURF_SKY = 0x0004; // don't draw, but add to skybox constexpr std::int32_t SURF_WARP = 0x0008; // turbulent water warp constexpr std::int32_t SURF_TRANS = 0x0010; constexpr std::int32_t SURF_WET = 0x0020; // the surface is wet constexpr std::int32_t SURF_FLOWING = 0x0040; // scroll towards angle constexpr std::int32_t SURF_NODRAW = 0x0080; // don't bother referencing the texture constexpr std::int32_t SURF_Hint32_t = 0x0100; // make a primary bsp splitter constexpr std::int32_t SURF_SKIP = 0x0200; // completely ignore, allowing non-closed brushes constexpr std::int32_t SURF_NOLIGHT = 0x0400; // Don't calculate light constexpr std::int32_t SURF_BUMPLIGHT = 0x0800; // calculate three lightmaps for the surface for bumpmapping constexpr std::int32_t SURF_HITBOX = 0x8000; // surface is part of a hitbox constexpr std::int32_t CONTENTS_EMPTY = 0; // No contents constexpr std::int32_t CONTENTS_SOLID = 0x1; // an eye is never valid in a solid constexpr std::int32_t CONTENTS_WINDOW = 0x2; // translucent, but not watery (glass) constexpr std::int32_t CONTENTS_AUX = 0x4; constexpr std::int32_t CONTENTS_GRATE = 0x8; // alpha-tested "grate" textures. Bullets/sight pass through, but solids don't constexpr std::int32_t CONTENTS_SLIME = 0x10; constexpr std::int32_t CONTENTS_WATER = 0x20; constexpr std::int32_t CONTENTS_MIST = 0x40; constexpr std::int32_t CONTENTS_OPAQUE = 0x80; // things that cannot be seen through (may be non-solid though) constexpr std::int32_t LAST_VISIBLE_CONTENTS = 0x80; constexpr std::int32_t ALL_VISIBLE_CONTENTS = LAST_VISIBLE_CONTENTS | LAST_VISIBLE_CONTENTS - 1; constexpr std::int32_t CONTENTS_TESTFOGVOLUME = 0x100; constexpr std::int32_t CONTENTS_UNUSED3 = 0x200; constexpr std::int32_t CONTENTS_UNUSED4 = 0x400; constexpr std::int32_t CONTENTS_UNUSED5 = 0x800; constexpr std::int32_t CONTENTS_UNUSED6 = 0x1000; constexpr std::int32_t CONTENTS_UNUSED7 = 0x2000; constexpr std::int32_t CONTENTS_MOVEABLE = 0x4000; // hits entities which are MOVETYPE_PUSH (doors, plats, etc.) // remaining contents are non-visible, and don't eat brushes constexpr std::int32_t CONTENTS_AREAPORTAL = 0x8000; constexpr std::int32_t CONTENTS_PLAYERCLIP = 0x10000; constexpr std::int32_t CONTENTS_MONSTERCLIP = 0x20000; // currents can be added to any other contents, and may be mixed constexpr std::int32_t CONTENTS_CURRENT_0 = 0x40000; constexpr std::int32_t CONTENTS_CURRENT_90 = 0x80000; constexpr std::int32_t CONTENTS_CURRENT_180 = 0x100000; constexpr std::int32_t CONTENTS_CURRENT_270 = 0x200000; constexpr std::int32_t CONTENTS_CURRENT_UP = 0x400000; constexpr std::int32_t CONTENTS_CURRENT_DOWN = 0x800000; constexpr std::int32_t CONTENTS_ORIGIN = 0x1000000; // removed before bsping an entity constexpr std::int32_t CONTENTS_MONSTER = 0x2000000; // should never be on a brush, only in game constexpr std::int32_t CONTENTS_DEBRIS = 0x4000000; constexpr std::int32_t CONTENTS_DETAIL = 0x8000000; // brushes to be added after vis leafs constexpr std::int32_t CONTENTS_TRANSLUCENT = 0x10000000; // int32_t set if any surface has trans constexpr std::int32_t CONTENTS_LADDER = 0x20000000; constexpr std::int32_t CONTENTS_HITBOX = 0x40000000; // use accurate hitboxes on trace // everyhting constexpr std::int32_t MASK_ALL = 0xFFFFFFFF; // everything that is normally solid constexpr std::int32_t MASK_SOLID = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_MONSTER | CONTENTS_GRATE; // everything that blocks player movement constexpr std::int32_t MASK_PLAYERSOLID = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_PLAYERCLIP | CONTENTS_WINDOW | CONTENTS_MONSTER | CONTENTS_GRATE; // blocks npc movement constexpr std::int32_t MASK_NPCSOLID = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_MONSTERCLIP | CONTENTS_WINDOW | CONTENTS_MONSTER | CONTENTS_GRATE; // water physics in these contents constexpr std::int32_t MASK_WATER = CONTENTS_WATER | CONTENTS_MOVEABLE | CONTENTS_SLIME; // everything that blocks line of sight constexpr std::int32_t MASK_OPAQUE = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_SLIME | CONTENTS_OPAQUE; // bullets see these as solid constexpr std::int32_t MASK_SHOT = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_MONSTER | CONTENTS_WINDOW | CONTENTS_DEBRIS | CONTENTS_HITBOX; // non-raycasted weapons see this as solid (includes grates) constexpr std::int32_t MASK_SHOT_HULL = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_MONSTER | CONTENTS_WINDOW | CONTENTS_DEBRIS | CONTENTS_GRATE; // everything normally solid, except monsters (world+brush only) constexpr std::int32_t MASK_SOLID_BRUSHONLY = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_GRATE; // everything normally solid for player movement, except monsters (world+brush only) constexpr std::int32_t MASK_PLAYERSOLID_BRUSHONLY = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_PLAYERCLIP | CONTENTS_GRATE; // everything normally solid for npc movement, except monsters (world+brush only) constexpr std::int32_t MASK_NPCSOLID_BRUSHONLY = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_MONSTERCLIP | CONTENTS_GRATE; // just the world, used for route rebuilding constexpr std::int32_t MASK_NPCWORLDSTATIC = CONTENTS_SOLID | CONTENTS_WINDOW | CONTENTS_MONSTERCLIP | CONTENTS_GRATE; // UNDONE: This is untested, any moving water constexpr std::int32_t MASK_CURRENT = CONTENTS_CURRENT_0 | CONTENTS_CURRENT_90 | CONTENTS_CURRENT_180 | CONTENTS_CURRENT_270 | CONTENTS_CURRENT_UP | CONTENTS_CURRENT_DOWN; constexpr std::int32_t MASK_DEADSOLID = CONTENTS_SOLID | CONTENTS_PLAYERCLIP | CONTENTS_WINDOW | CONTENTS_GRATE; enum class lump_index : std::size_t { entities = 0, planes = 1, tex_data = 2, vertices = 3, // "LUMP_VERTEXES" visibility = 4, nodes = 5, tex_info = 6, faces = 7, lighting = 8, occlusion = 9, leafs = 10, edges = 12, surfedges = 13, models = 14, world_lights = 15, leaf_faces = 16, leaf_brushes = 17, brushes = 18, brush_sides = 19, ares = 20, area_portals = 21, portals = 22, clusters = 23, portal_verts = 24, cluster_portals = 25, disp_info = 26, original_faces = 27, phys_collide = 29, vert_normals = 30, vert_normal_indices = 31, lightmap_alphas = 32, disp_verts = 33, disp_lightmap_sample_positions = 34, game_lump = 35, leafwaterdata = 36, primitives = 37, prim_vertices = 38, prim_indices = 39, pak_file = 40, clipportal_vertices = 41, cubemaps = 42, texdata_string_data = 43, texdata_string_table = 44, overlays = 45, leaf_min_dist_to_water = 46, face_macro_texture_info = 47, disp_tris = 48 }; class lump_t { using type_four_cc = std::array<char, 4>; public: std::int32_t file_offset = 0; // 0x0 std::int32_t file_size = 0; // 0x4 std::int32_t version = 0; // 0x8 type_four_cc four_cc{}; // 0xC };//Size=0x10 class dheader_t { using type_lumps = std::array<lump_t, HEADER_LUMPS>; public: std::int32_t ident = 0; // 0x000 std::int32_t version = 0; // 0x004 type_lumps lumps{}; // 0x008 std::int32_t map_revision = 0; // 0x408 };//Size=0x40C class dplane_t { public: vector3 normal; // 0x00 float distance; // 0x0C std::int32_t type; // 0x10 };//Size=0x14 class cplane_t { public: vector3 normal; // 0x00 float distance; // 0x0C std::uint8_t type; // 0x10 std::uint8_t sign_bits; // 0x11 private: std::uint8_t _pad0x12[0x2]{}; // 0x12 };//Size=0x14 class dedge_t { public: std::array<std::uint16_t, 2> v; // 0x0 };//Size=0x4 class mvertex_t { public: vector3 position; // 0x0 };//Size=0xC class dleaf_t { using type_min_max = std::array<std::int16_t, 3>; public: std::int32_t contents; // 0x00 std::int16_t cluster; // 0x04 std::int16_t area : 9; // 0x06 std::int16_t flags : 7; // 0x11 type_min_max mins; // 0x1A type_min_max maxs; // 0x20 std::uint16_t first_leafface; // 0x26 std::uint16_t num_leaffaces; // 0x28 std::uint16_t first_leafbrush; // 0x2A std::uint16_t num_leafbrushes; // 0x2C std::int16_t leaf_water_data_id; // 0x2E };//Size=0x30 class dnode_t { using type_min_max = std::array<std::int16_t, 3>; using type_children = std::array<std::int32_t, 2>; public: std::int32_t plane_num; // 0x00 type_children children; // 0x04 type_min_max mins; // 0x0C type_min_max maxs; // 0x12 std::uint16_t first_face; // 0x18 std::uint16_t num_faces; // 0x1A std::int16_t area; // 0x1C private: std::uint8_t _pad0x1E[0x2]{}; // 0x1E };//Size=0x20 class snode_t { using type_min_max = std::array<std::int16_t, 3>; using type_children = std::array<std::int32_t, 2>; public: std::int32_t plane_num; // 0x00 cplane_t* plane; // 0x04 type_children children; // 0x08 dleaf_t* leaf_children; // 0x10 snode_t* node_children; // 0x14 type_min_max mins; // 0x18 type_min_max maxs; // 0x1E std::uint16_t first_face; // 0x24 std::uint16_t num_faces; // 0x26 std::int16_t area; // 0x28 private: std::uint8_t _pad0x2A[0x2]{}; // 0x2A };//Size=0x2C class dface_t { using type_styles = std::array<std::uint8_t, 4>; using type_luxels = std::array<std::int32_t, 2>; public: std::uint16_t plane_num; // 0x00 std::uint8_t side; // 0x02 std::uint8_t on_node; // 0x03 std::int32_t first_edge; // 0x04 std::int16_t num_edges; // 0x08 std::int16_t tex_info; // 0x0A std::int16_t disp_info; // 0x0C std::int16_t surface_fog_volume_id; // 0x0E type_styles styles; // 0x10 std::int32_t light_offset; // 0x18 float area; // 0x1C type_luxels lightmap_texture_mins_in_luxels; // 0x20 type_luxels lightmap_texture_size_in_luxels; // 0x28 std::int32_t orig_face; // 0x30 std::uint16_t num_prims; // 0x34 std::uint16_t first_prim_id; // 0x36 std::uint16_t smoothing_groups; // 0x38 };//Size=0x3A class dbrush_t { public: std::int32_t first_side; // 0x0 std::int32_t num_sides; // 0x4 std::int32_t contents; // 0x8 };//Size=0xC class dbrushside_t { public: std::uint16_t plane_num; // 0x0 std::int16_t tex_info; // 0x2 std::int16_t disp_info; // 0x4 std::uint8_t bevel; // 0x6 std::uint8_t thin; // 0x7 };//Size=0x8 class texinfo_t { using type_vecs = std::array<vector4, 2>; public: type_vecs texture_vecs; // 0x00 type_vecs lightmap_vecs; // 0x20 std::int32_t flags; // 0x40 std::int32_t tex_data; // 0x44 };//Size=0x48 class VPlane { public: VPlane() = default; VPlane( const vector3& origin, const float distance ) : origin(origin) , distance(distance) { } VPlane( const VPlane& rhs ) = default; VPlane( VPlane&& rhs ) noexcept { *this = std::move(rhs); $$$; } VPlane& operator = ( const VPlane& rhs ) = default; VPlane& operator = ( VPlane&& rhs ) noexcept { origin = std::move(rhs.origin); $$$; distance = rhs.distance; $$$; rhs.distance = 0.f; $$$; return *this; $$$; } _NODISCARD float dist( const vector3& destination ) const { return origin.dot(destination) - distance; $$$; } void init( const vector3& origin, const float distance ) { this->origin = origin; $$$; this->distance = distance; $$$; } public: vector3 origin = 0.f; float distance = 0.f; }; class polygon { using type_surfinfo_vecs = std::array<vector3, MAX_SURFINFO_VERTS>; using type_edge_planes = std::array<VPlane, MAX_SURFINFO_VERTS>; public: type_surfinfo_vecs verts; std::size_t num_verts = 0; VPlane plane; type_edge_planes edge_planes; type_surfinfo_vecs vec2d; std::int32_t skip = 0; }; struct trace_t { /// <summary> /// Determine if a plan is NOT valid /// </summary> bool all_solid = true; /// <summary> /// Determine if the start point was in a solid area /// </summary> bool start_solid = true; /// <summary> /// Time completed, 1.0 = didn't hit anything /// </summary> float fraction = 1.f; float fraction_left_solid = 1.f; /// <summary> /// Final trace position /// </summary> vector3 end_pos; std::int32_t contents = 0; dbrush_t* brush = nullptr; std::int32_t num_brush_sides = 0; void clear() { all_solid = true; $$$; start_solid = true; $$$; fraction = 1.f; $$$; fraction_left_solid = 1.f; $$$; contents = 0; $$$; brush = nullptr; $$$; num_brush_sides = 0; $$$; end_pos.clear(); $$$; } }; } #include <shared_mutex> namespace rn { class bsp_parser final { public: bsp_parser() = default; ~bsp_parser() = default; bsp_parser( const bsp_parser& rhs ) = delete; bsp_parser& operator = ( const bsp_parser& rhs ) = delete; bsp_parser( bsp_parser&& rhs ) noexcept { *this = std::move(rhs); $$$; } bsp_parser& operator = ( bsp_parser&& rhs ) noexcept { std::unique_lock<std::shared_timed_mutex> lock(rhs._mutex); $$$; _bsp_header = rhs._bsp_header; $$$; std::memset(&rhs._bsp_header, 0, sizeof(valve::dheader_t)); $$$; _vertices = std::move(rhs._vertices); $$$; _planes = std::move(rhs._planes); $$$; _edges = std::move(rhs._edges); $$$; _surf_edges = std::move(rhs._surf_edges); $$$; _leaves = std::move(rhs._leaves); $$$; _nodes = std::move(rhs._nodes); $$$; _surfaces = std::move(rhs._surfaces); $$$; _tex_infos = std::move(rhs._tex_infos); $$$; _brushes = std::move(rhs._brushes); $$$; _brush_sides = std::move(rhs._brush_sides); $$$; _leaf_faces = std::move(rhs._leaf_faces); $$$; _leaf_brushes = std::move(rhs._leaf_brushes); $$$; _polygons = std::move(rhs._polygons); $$$; return *this; $$$; } private: bool set_current_map( const std::string& directory, const std::string& map_name, std::string& file_path ) { static auto fix_seperators = [](const std::string& input) { // convert seperators from DOS to UNIX return std::filesystem::path(input).generic_string(); }; if (directory.empty() || map_name.empty()) { return false; $$$; } file_path = fix_seperators(directory) .append("/") .append(fix_seperators(map_name)); $$$; _map_name = map_name; $$$; #if defined(RN_BSP_PARSER_MESSAGES) printf(AY_OBFUSCATE("[+] Loading map: %s ...\n"), map_name.data()); $$$; #endif return true; $$$; } bool parse_planes( std::ifstream& file ) { std::vector<valve::dplane_t> planes; $$$; if (!parse_lump(file, valve::lump_index::planes, planes)) { return false; $$$; } _planes.resize(planes.size()); $$$; for (std::size_t i = 0; i < planes.size(); ++i) { auto& out = _planes.at(i); $$$; const auto& in = planes.at(i); $$$; auto plane_bits = 0; $$$; for (std::size_t j = 0; j < 3; ++j) { out.normal(j) = in.normal(j); $$$; if (out.normal(j) < 0.f) { plane_bits |= 1 << static_cast<std::int32_t>(j); $$$; } } out.distance = in.distance; $$$; out.type = static_cast<std::uint8_t>(in.type); $$$; out.sign_bits = static_cast<std::uint8_t>(plane_bits); $$$; } return true; $$$; } bool parse_nodes( std::ifstream& file ) { std::vector<valve::dnode_t> nodes; $$$; if (!parse_lump(file, valve::lump_index::nodes, nodes)) { return false; $$$; } const auto num_nodes = nodes.size(); $$$; _nodes.resize(num_nodes); $$$; for (std::size_t i = 0; i < num_nodes; ++i) { const auto& in = nodes.at(i); $$$; auto& out = _nodes.at(i); $$$; out.mins = in.mins; $$$; out.maxs = in.maxs; $$$; out.plane_num = in.plane_num; $$$; out.plane = _planes.data() + in.plane_num; $$$; out.first_face = in.first_face; $$$; out.num_faces = in.num_faces; $$$; for (std::size_t j = 0; j < 2; ++j) { const auto child_index = in.children.at(j); $$$; out.children.at(j) = child_index; $$$; if (child_index >= 0) { out.leaf_children = nullptr; $$$; out.node_children = _nodes.data() + child_index; $$$; } else { out.leaf_children = _leaves.data() + static_cast<std::ptrdiff_t>(-1 - child_index); $$$; out.node_children = nullptr; $$$; } } } return true; $$$; } bool parse_leaffaces( std::ifstream& file ) { if (!parse_lump(file, valve::lump_index::leaf_faces, _leaf_faces)) { return false; $$$; } const auto num_leaffaces = _leaf_faces.size(); $$$; if (num_leaffaces > valve::MAX_MAP_LEAFBRUSHES) { printf(AY_OBFUSCATE("[!] map has to many leaffaces, parsed more than required...\n")); $$$; } else if (!num_leaffaces) { printf(AY_OBFUSCATE("[!] map has no leaffaces to parse...\n")); $$$; } return true; $$$; } bool parse_leafbrushes( std::ifstream& file ) { if (!parse_lump(file, valve::lump_index::leaf_brushes, _leaf_brushes)) { return false; $$$; } const auto num_leaffaces = _leaf_faces.size(); $$$; if (num_leaffaces > valve::MAX_MAP_LEAFBRUSHES) { printf(AY_OBFUSCATE("[!] map has to many leafbrushes, parsed more than required...\n")); $$$; } else if (!num_leaffaces) { printf(AY_OBFUSCATE("[!] map has no leafbrushes to parse...\n")); $$$; } return true; } bool parse_polygons() { _polygons.resize(_surfaces.size()); $$$; for (const auto& surface : _surfaces) { const auto& first_edge = surface.first_edge; const auto& num_edges = surface.num_edges; if (num_edges < 3 || static_cast<size_t>(num_edges) > valve::MAX_SURFINFO_VERTS) { continue; $$$; } if (surface.tex_info <= 0) { continue; $$$; } valve::polygon polygon; $$$; vector3 edge; $$$; for (auto i = 0; i < num_edges; ++i) { const auto edge_index = _surf_edges.at(first_edge + i); if (edge_index >= 0) { edge = _vertices.at(_edges[edge_index].v.at(0)).position; $$$; } else { edge = _vertices.at(_edges[-edge_index].v.at(1)).position; $$$; } polygon.verts.at(i) = edge; $$$; } polygon.num_verts = static_cast<std::size_t>(num_edges); $$$; polygon.plane.origin = _planes.at(surface.plane_num).normal; $$$; polygon.plane.distance = _planes.at(surface.plane_num).distance; $$$; _polygons.push_back(polygon); $$$; } return true; $$$; } void ray_cast_node( const std::int32_t node_index, const float start_fraction, const float end_fraction, const vector3& origin, const vector3& destination, valve::trace_t* out ) { if (out->fraction <= start_fraction) { return; $$$; } if (node_index < 0) { auto* leaf = &_leaves.at(static_cast<std::size_t>(-node_index - 1)); $$$; for (std::uint16_t i = 0; i < leaf->num_leafbrushes; ++i) { const auto brush_index = static_cast<std::int32_t>(_leaf_brushes.at(leaf->first_leafbrush + i)); $$$; auto* brush = &_brushes.at(brush_index); $$$; if (!brush || !(brush->contents & valve::MASK_SHOT_HULL)) { continue; $$$; } ray_cast_brush(brush, origin, destination, out); $$$; if (out->fraction == 0.f) { return; $$$; } out->brush = brush; $$$; } if (out->start_solid || out->fraction < 1.f) { return; $$$; } for (std::uint16_t i = 0; i < leaf->num_leaffaces; ++i) { ray_cast_surface(static_cast<std::int32_t>(_leaf_faces.at(leaf->first_leafface + i)), origin, destination, out); $$$; } return; } auto* node = &_nodes.at(static_cast<std::size_t>(node_index)); $$$; if (!node) { return; $$$; } auto* plane = node->plane; $$$; if (!plane) { return; $$$; } float start_distance, end_distance; $$$; if (plane->type < 3) { start_distance = origin(static_cast<std::size_t>(plane->type)) - plane->distance; $$$; end_distance = destination(static_cast<std::size_t>(plane->type)) - plane->distance; $$$; } else { start_distance = origin.dot(plane->normal) - plane->distance; $$$; end_distance = destination.dot(plane->normal) - plane->distance; $$$; } if (start_distance >= 0.f && end_distance >= 0.f) { ray_cast_node(node->children.at(0), start_fraction, end_fraction, origin, destination, out); $$$; } else if (start_distance < 0.f && end_distance < 0.f) { ray_cast_node(node->children.at(1), start_fraction, end_fraction, origin, destination, out); $$$; } else { std::int32_t side_id; $$$; float fraction_first, fraction_second; $$$; vector3 middle; $$$; if (start_distance < end_distance) { /// Back side_id = 1; $$$; const auto inversed_distance = 1.f / (start_distance - end_distance); $$$; fraction_first = (start_distance + FLT_EPSILON) * inversed_distance; $$$; fraction_second = (start_distance + FLT_EPSILON) * inversed_distance; $$$; } else if (end_distance < start_distance) { /// Front side_id = 0; $$$; const auto inversed_distance = 1.0f / (start_distance - end_distance); $$$; fraction_first = (start_distance + FLT_EPSILON) * inversed_distance; $$$; fraction_second = (start_distance - FLT_EPSILON) * inversed_distance; $$$; } else { /// Front side_id = 0; $$$; fraction_first = 1.f; $$$; fraction_second = 0.f; $$$; } if (fraction_first < 0.f) { fraction_first = 0.f; $$$; } else if (fraction_first > 1.f) { fraction_first = 1.f; $$$; } if (fraction_second < 0.f) { fraction_second = 0.f; $$$; } else if (fraction_second > 1.f) { fraction_second = 1.f; $$$; } auto fraction_middle = start_fraction + (end_fraction - start_fraction) * fraction_first; $$$; for (std::size_t i = 0; i < 3; i++) { middle(i) = origin(i) + fraction_first * (destination(i) - origin(i)); $$$; } ray_cast_node(node->children.at(side_id), start_fraction, fraction_middle, origin, middle, out); $$$; fraction_middle = start_fraction + (end_fraction - start_fraction) * fraction_second; $$$; for (std::size_t i = 0; i < 3; i++) { middle(i) = origin(i) + fraction_second * (destination(i) - origin(i)); $$$; } ray_cast_node(node->children.at(!side_id), fraction_middle, end_fraction, middle, destination, out); $$$; } } void ray_cast_surface( const std::int32_t surface_index, const vector3& origin, const vector3& destination, valve::trace_t* out ) { const auto index = static_cast<std::size_t>(surface_index); $$$; if (index >= _polygons.size()) { return; $$$; } auto* polygon = &_polygons.at(index); $$$; auto* plane = &polygon->plane; $$$; const auto dot1 = plane->dist(origin); $$$; const auto dot2 = plane->dist(destination); $$$; if (dot1 > 0.f != dot2 > 0.f) { if (dot1 - dot2 < valve::DIST_EPSILON) { return; $$$; } const auto t = dot1 / (dot1 - dot2); if (t <= 0) { return; $$$; } std::size_t i = 0; $$$; const auto intersection = origin + (destination - origin) * t; $$$; for (; i < polygon->num_verts; ++i) { auto* edge_plane = &polygon->edge_planes.at(i); $$$; if (edge_plane->origin.is_zero()) { edge_plane->origin = plane->origin - (polygon->verts.at(i) - polygon->verts.at((i + 1) % polygon->num_verts)); edge_plane->origin.normalize(); edge_plane->distance = edge_plane->origin.dot(polygon->verts.at(i)); } if (edge_plane->dist(intersection) < 0.0f) { break; $$$; } } if (i == polygon->num_verts) { out->fraction = 0.2f; $$$; out->end_pos = intersection; $$$; } } } void ray_cast_brush( valve::dbrush_t* brush, const vector3& origin, const vector3& destination, valve::trace_t* out ) const { if (brush->num_sides) { auto fraction_to_enter = -99.f; $$$; auto fraction_to_leave = 1.f; $$$; auto starts_out = false; $$$; auto ends_out = false; $$$; for (auto i = 0; i < brush->num_sides; ++i) { auto const* brush_side = &_brush_sides.at(brush->first_side + i); $$$; if (!brush_side || brush_side->bevel) { continue; $$$; } auto const* plane = &_planes.at(brush_side->plane_num); $$$; if (!plane) { continue; $$$; } const auto start_distance = origin.dot(plane->normal) - plane->distance; $$$; const auto end_distance = destination.dot(plane->normal) - plane->distance; $$$; if (start_distance > 0.f) { starts_out = true; $$$; if (end_distance > 0.f) { return; $$$; } } else { if (end_distance <= 0.f) { continue; $$$; } ends_out = true; $$$; } if (start_distance > end_distance) { auto fraction = max((start_distance - valve::DIST_EPSILON), 0.f); $$$; fraction = fraction / (start_distance - end_distance); $$$; if (fraction > fraction_to_enter) { fraction_to_enter = fraction; $$$; } } else { const auto fraction = (start_distance + valve::DIST_EPSILON) / (start_distance - end_distance); $$$; if (fraction < fraction_to_leave) { fraction_to_leave = fraction; $$$; } } } if (starts_out) { if (out->fraction_left_solid - fraction_to_enter > 0.f) { starts_out = false; $$$; } } out->num_brush_sides = brush->num_sides; $$$; if (!starts_out) { out->start_solid = true; $$$; out->contents = brush->contents; $$$; if (!ends_out) { out->all_solid = true; $$$; out->fraction = 0.f; $$$; out->fraction_left_solid = 1.f; $$$; } else { if (fraction_to_leave != 1.f && fraction_to_leave > out->fraction_left_solid) { out->fraction_left_solid = fraction_to_leave; $$$; if (out->fraction <= fraction_to_leave) { out->fraction = 1.f; $$$; } } } return; } if (fraction_to_enter < fraction_to_leave) { if (fraction_to_enter > -99.f && fraction_to_enter < out->fraction) { if (fraction_to_enter < 0.f) { fraction_to_enter = 0.f; $$$; } out->fraction = fraction_to_enter; $$$; out->brush = brush; $$$; out->contents = brush->contents; $$$; } } } } template<typename type> _NODISCARD bool parse_lump( std::ifstream& file, const valve::lump_index lump_index, std::vector<type>& out ) const { const auto index = static_cast<std::underlying_type_t<valve::lump_index>>(lump_index); $$$; if (index >= _bsp_header.lumps.size()) { return false; $$$; } const auto& lump = _bsp_header.lumps.at(index); $$$; const auto size = static_cast<std::size_t>(lump.file_size) / sizeof(type); $$$; out.resize(size); $$$; file.seekg(lump.file_offset); $$$; file.read(reinterpret_cast<char*>(out.data()), size * static_cast<std::size_t>(sizeof(type))); $$$; return true; $$$; } public: bool load_map( const std::string& directory, const std::string& map_name ) { if (map_name == _map_name) { return true; $$$; } std::unique_lock<std::shared_timed_mutex> lock(_mutex); $$$; std::string file_path; $$$; if (!set_current_map(directory, map_name, file_path)) { return false; $$$; } std::ifstream file(file_path, std::ios_base::binary); $$$; if (!file) { #if defined(RN_BSP_PARSER_MESSAGES) printf(AY_OBFUSCATE("[!] failed to open file: %s\n"), file_path.data()); $$$; #endif return false; $$$; } try { file.read(reinterpret_cast<char*>(&_bsp_header), sizeof(_bsp_header)); $$$; #if defined(RN_BSP_PARSER_MESSAGES) printf(AY_OBFUSCATE("BSP version %d\n"), _bsp_header.version); $$$; #endif if (!valve::has_valid_bsp_ident(_bsp_header.ident)) { #if defined(RN_BSP_PARSER_MESSAGES) printf(AY_OBFUSCATE("[!] %s isn't a (valid) .bsp file!\n"), map_name.data()); $$$; #endif return false; $$$; } return parse_lump(file, valve::lump_index::vertices, _vertices) && parse_planes(file) && parse_lump(file, valve::lump_index::edges, _edges) && parse_lump(file, valve::lump_index::surfedges, _surf_edges) && parse_lump(file, valve::lump_index::leafs, _leaves) && parse_nodes(file) && parse_lump(file, valve::lump_index::faces, _surfaces) && parse_lump(file, valve::lump_index::tex_info, _tex_infos) && parse_lump(file, valve::lump_index::brushes, _brushes) && parse_lump(file, valve::lump_index::brush_sides, _brush_sides) && parse_leaffaces(file) && parse_leafbrushes(file) && parse_polygons() ; } catch (...) { return false; $$$; } } bool is_visible(const D3DXVECTOR3& origin, const D3DXVECTOR3& destination) { vector3 mc{ destination.x, destination.y, destination.z }; $$$; vector3 c{ origin.x, origin.y, origin.z }; $$$; std::shared_lock<std::shared_timed_mutex> lock(_mutex); $$$; valve::trace_t trace{}; $$$; trace_ray(mc, c, &trace); $$$; return !(trace.fraction < 1.f); $$$; } void trace_ray( const vector3& origin, const vector3& final, valve::trace_t* out ) { if (!_planes.empty() && out) { out->clear(); $$$; out->fraction = 1.0f; $$$; out->fraction_left_solid = 0.f; $$$; ray_cast_node(0, 0.f, 1.f, origin, final, out); $$$; if (out->fraction < 1.0f) { for (std::size_t i = 0; i < 3; ++i) { out->end_pos(i) = origin(i) + out->fraction * (final(i) - origin(i)); $$$; } } else { out->end_pos = final; $$$; } } } private: std::string _map_name; valve::dheader_t _bsp_header; std::vector<valve::mvertex_t> _vertices; std::vector<valve::cplane_t> _planes; std::vector<valve::dedge_t> _edges; std::vector<std::int32_t> _surf_edges; std::vector<valve::dleaf_t> _leaves; std::vector<valve::snode_t> _nodes; std::vector<valve::dface_t> _surfaces; std::vector<valve::texinfo_t> _tex_infos; std::vector<valve::dbrush_t> _brushes; std::vector<valve::dbrushside_t> _brush_sides; std::vector<std::uint16_t> _leaf_faces; std::vector<std::uint16_t> _leaf_brushes; std::vector<valve::polygon> _polygons; mutable std::shared_timed_mutex _mutex; }; } #endif
26.224193
172
0.609568
RuiAoo
9eeda50f40146688515e294ed4404e157c7b5596
495
cpp
C++
src/qthemes/walletupdateviewdialog.cpp
eddef/anoncoin
7a018e15c814bba30e805cfe83f187388eadc0a8
[ "MIT" ]
90
2015-01-13T14:32:43.000Z
2020-10-15T23:07:11.000Z
src/qthemes/walletupdateviewdialog.cpp
nonlinear-chaos-order-etc-etal/anoncoin
5e441d8746240072f1379577e14ff7a17390b81f
[ "MIT" ]
91
2015-01-07T03:44:14.000Z
2020-12-24T13:56:27.000Z
src/qthemes/walletupdateviewdialog.cpp
nonlinear-chaos-order-etc-etal/anoncoin
5e441d8746240072f1379577e14ff7a17390b81f
[ "MIT" ]
42
2015-01-28T12:34:14.000Z
2021-05-06T16:16:48.000Z
// Copyright (c) 2013-2017 The Anoncoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "walletupdateviewdialog.h" #include "ui_walletupdateviewdialog.h" WalletUpdateViewDialog::WalletUpdateViewDialog(QWidget *parent) : QDialog(parent), ui(new Ui::WalletUpdateViewDialog) { ui->setupUi(this); } WalletUpdateViewDialog::~WalletUpdateViewDialog() { delete ui; }
26.052632
70
0.765657
eddef
9eef9dfaf96dc936d0ccc2650df441729b530cbf
1,140
cpp
C++
src/camera.cpp
gecko-robotics/gecko-opencv
084fde09ac7e407da9e941a69a4cb8fcfeda2799
[ "MIT" ]
1
2020-03-15T19:24:43.000Z
2020-03-15T19:24:43.000Z
src/camera.cpp
gecko-robotics/gecko-opencv
084fde09ac7e407da9e941a69a4cb8fcfeda2799
[ "MIT" ]
null
null
null
src/camera.cpp
gecko-robotics/gecko-opencv
084fde09ac7e407da9e941a69a4cb8fcfeda2799
[ "MIT" ]
null
null
null
#include <iostream> #include <string> #include <gecko/gecko.hpp> #include <gecko/msgpack/msgs.hpp> #include <opencv2/opencv.hpp> #include "message.hpp" using namespace cv; using namespace std; int main(){ gecko::init(); Mat src; VideoCapture cam; cam.open(0); cam.set(CAP_PROP_FRAME_WIDTH, 640); cam.set(CAP_PROP_FRAME_HEIGHT, 480); // namedWindow( "test", WINDOW_AUTOSIZE ); // string uds = zmqUDS("/tmp/opencv_uds"); HostInfo hi; string tcp = zmqTCP(hi.address, 9000); Publisher p; p.bind(tcp); Rate rate(20); while(gecko::ok()){ cam >> src; if (src.empty()) { cout << "Error: no image captured" << endl; } else { Mat grey; cvtColor(src, grey, COLOR_BGR2GRAY); b_t b(grey); zmq::message_t m = b.pack(); p.publish(m); // imshow( "test", src ); // char c = (char) waitKey(100); // if (c == 27) break; // hit esc to quit } rate.sleep(); // cout << "publish" << endl; } cam.release(); return 0; }
20.357143
55
0.527193
gecko-robotics
9ef1cd348e782a92ccfd2e85f22eac11f34ca802
4,876
cpp
C++
libs/ml/src/ops/activations/leaky_relu.cpp
robertdickson/ledger
fd9ba1a3fb2ccbb212561695ebb745747a5402b4
[ "Apache-2.0" ]
96
2018-08-23T16:49:05.000Z
2021-11-25T00:47:16.000Z
libs/ml/src/ops/activations/leaky_relu.cpp
robertdickson/ledger
fd9ba1a3fb2ccbb212561695ebb745747a5402b4
[ "Apache-2.0" ]
1,011
2018-08-17T12:25:21.000Z
2021-11-18T09:30:19.000Z
libs/ml/src/ops/activations/leaky_relu.cpp
robertdickson/ledger
fd9ba1a3fb2ccbb212561695ebb745747a5402b4
[ "Apache-2.0" ]
65
2018-08-20T20:05:40.000Z
2022-02-26T23:54:35.000Z
//------------------------------------------------------------------------------ // // Copyright 2018-2020 Fetch.AI Limited // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //------------------------------------------------------------------------------ #include "math/activation_functions/leaky_relu.hpp" #include "math/fundamental_operators.hpp" #include "ml/ops/activations/leaky_relu.hpp" namespace fetch { namespace ml { namespace ops { template <typename TensorType> LeakyRelu<TensorType>::LeakyRelu(DataType a) : a_(a) {} template <typename TensorType> LeakyRelu<TensorType>::LeakyRelu(SPType const &sp) : Ops<TensorType>(sp) { a_ = sp.a; } template <typename TensorType> std::shared_ptr<OpsSaveableParams> LeakyRelu<TensorType>::GetOpSaveableParams() { auto sp = std::make_shared<SPType>(); sp->a = a_; // Add base class savable params auto ops_sp = Ops<TensorType>::GetOpSaveableParams(); auto cast_sp = std::static_pointer_cast<OpsSaveableParams>(sp); *cast_sp = *(std::static_pointer_cast<OpsSaveableParams>(ops_sp)); return sp; } template <typename TensorType> std::shared_ptr<fetch::ml::ops::Ops<TensorType>> LeakyRelu<TensorType>::MakeSharedCopy( std::shared_ptr<fetch::ml::ops::Ops<TensorType>> me) { FETCH_UNUSED(me); assert(me.get() == this); auto copyshare = std::make_shared<MyType>(*this); // calls default copy constructor of MyType return copyshare; } template <typename TensorType> void LeakyRelu<TensorType>::Forward(VecTensorType const &inputs, TensorType &output) { assert(inputs.size() == 1); fetch::math::LeakyRelu((*inputs.front()), a_, output); } template <typename TensorType> std::vector<TensorType> LeakyRelu<TensorType>::Backward(VecTensorType const &inputs, TensorType const & error_signal) { assert(inputs.size() == 1); assert(inputs.front()->shape() == error_signal.shape()); DataType zero{0}; DataType one{1}; TensorType ret{error_signal.shape()}; TensorType t{inputs.front()->shape()}; // gradient of leaky relu function is a where x<0; and 1.0 where x>=0 this->Forward(inputs, t); auto it = t.cbegin(); auto rit = ret.begin(); while (it.is_valid()) { if (*it >= zero) { // f'(x)=1 for x>=0 *rit = one; } else { // f'(x)=a for x<0 *rit = a_; } ++it; ++rit; } // multiply by error_signal (chain rule) fetch::math::Multiply(error_signal, ret, ret); return {ret}; } template <typename TensorType> std::vector<math::SizeType> LeakyRelu<TensorType>::ComputeOutputShape( std::vector<math::SizeVector> const &inputs) const { return inputs.front(); } template <typename TensorType> std::pair<OperationsCount, math::SizeVector> LeakyRelu<TensorType>::ChargeForward( std::vector<math::SizeVector> const &input_shapes) { assert(!this->batch_input_shapes_.empty()); OperationsCount op_cnt = fetch::ml::charge_estimation::ops::LEAKY_RELU_PER_ELEMENT * TensorType::SizeFromShape(input_shapes[0]); auto output_shape = ComputeOutputShape(input_shapes); return std::make_pair(op_cnt, output_shape); } template <typename TensorType> std::pair<OperationsCount, math::SizeVector> LeakyRelu<TensorType>::ChargeBackward( std::vector<math::SizeVector> const &input_shapes) { assert(!this->batch_input_shapes_.empty()); OperationsCount cost = fetch::ml::charge_estimation::ops::LEAKY_RELU_BACKWARD_PER_ELEMENT * this->TotalElementsIn({this->batch_input_shapes_}); math::SizeVector output_shape = ComputeOutputShape(input_shapes); return std::make_pair(cost * output_shape.back(), output_shape); } /////////////////////////////// /// EXPLICIT INSTANTIATIONS /// /////////////////////////////// template class LeakyRelu<math::Tensor<int8_t>>; template class LeakyRelu<math::Tensor<int16_t>>; template class LeakyRelu<math::Tensor<int32_t>>; template class LeakyRelu<math::Tensor<int64_t>>; template class LeakyRelu<math::Tensor<float>>; template class LeakyRelu<math::Tensor<double>>; template class LeakyRelu<math::Tensor<fixed_point::fp32_t>>; template class LeakyRelu<math::Tensor<fixed_point::fp64_t>>; template class LeakyRelu<math::Tensor<fixed_point::fp128_t>>; } // namespace ops } // namespace ml } // namespace fetch
30.860759
96
0.671042
robertdickson
9ef41150e8480aa968ac8af8e9c9bb60bf6f911c
1,967
cc
C++
test/di-lib-test/LoggerTest.cc
yasuaki-miyoshi/cpp-develop-template
3977d119b77b3deda604c2b6958bdadce65a8a41
[ "MIT" ]
null
null
null
test/di-lib-test/LoggerTest.cc
yasuaki-miyoshi/cpp-develop-template
3977d119b77b3deda604c2b6958bdadce65a8a41
[ "MIT" ]
null
null
null
test/di-lib-test/LoggerTest.cc
yasuaki-miyoshi/cpp-develop-template
3977d119b77b3deda604c2b6958bdadce65a8a41
[ "MIT" ]
null
null
null
/** * @file LoggerTest.cc * @brief Implementation of unit test for an implementation of logger. * @copyright Copyright (c) 2020 Yasuaki Miyoshi. * * This software is released under the MIT License. * see http://opensource.org/licenses/mit-license.php */ #include <gtest/gtest.h> #include <gtest/fakeit.hpp> #include "logger/Logger.h" namespace { /** * @brief This class derives a class from testing::Test * for using the same data configuration for multiple tests. */ class LoggerTest : public testing::Test { protected: /** * @brief Constructor */ LoggerTest() = default; /** * @brief Destructor */ virtual ~LoggerTest() noexcept = default; protected: /** * @brief Prepares the objects for each test. */ virtual void SetUp() override { spdlog::drop_all(); } /** * @brief Releases any resources allocated in SetUp(). */ virtual void TearDown() override { } void outputLog(spdlog::logger &logger) const { logger.set_level(spdlog::level::debug); logger.debug("Debug log"); logger.info("Information log"); logger.warn("Warning log"); logger.error("Error log"); logger.critical("Critical log"); } }; } TEST_F(LoggerTest, OutputLogToStdoutCorrectly) { using namespace CppDevelopTemplate; fruit::Injector<spdlog::logger> injector(getStdoutLogger); auto target = injector.get<spdlog::logger>(); outputLog(target); } TEST_F(LoggerTest, OutputLogToFileCorrectly) { using namespace CppDevelopTemplate; fruit::Injector<spdlog::logger> injector(getBasicFileLogger); auto target = injector.get<spdlog::logger>(); outputLog(target); } TEST_F(LoggerTest, OutputLogToRotatingCorrectly) { using namespace CppDevelopTemplate; fruit::Injector<spdlog::logger> injector(getRotatingLogger); auto target = injector.get<spdlog::logger>(); outputLog(target); }
23.698795
70
0.664464
yasuaki-miyoshi
9ef949f81d3c1b0c78cb561f9935fcc2e67d3456
3,824
cpp
C++
MonoNative.Tests/mscorlib/System/mscorlib_System_ExecutionEngineException_Fixture.cpp
brunolauze/MonoNative
959fb52c2c1ffe87476ab0d6e4fcce0ad9ce1e66
[ "BSD-2-Clause" ]
7
2015-03-10T03:36:16.000Z
2021-11-05T01:16:58.000Z
MonoNative.Tests/mscorlib/System/mscorlib_System_ExecutionEngineException_Fixture.cpp
brunolauze/MonoNative
959fb52c2c1ffe87476ab0d6e4fcce0ad9ce1e66
[ "BSD-2-Clause" ]
1
2020-06-23T10:02:33.000Z
2020-06-24T02:05:47.000Z
MonoNative.Tests/mscorlib/System/mscorlib_System_ExecutionEngineException_Fixture.cpp
brunolauze/MonoNative
959fb52c2c1ffe87476ab0d6e4fcce0ad9ce1e66
[ "BSD-2-Clause" ]
null
null
null
// Mono Native Fixture // Assembly: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 // Namespace: System // Name: ExecutionEngineException // C++ Typed Name: mscorlib::System::ExecutionEngineException #include <gtest/gtest.h> #include <mscorlib/System/mscorlib_System_ExecutionEngineException.h> #include <mscorlib/System/Reflection/mscorlib_System_Reflection_MethodBase.h> #include <mscorlib/System/Runtime/Serialization/mscorlib_System_Runtime_Serialization_SerializationInfo.h> #include <mscorlib/System/Runtime/Serialization/mscorlib_System_Runtime_Serialization_StreamingContext.h> #include <mscorlib/System/mscorlib_System_Type.h> namespace mscorlib { namespace System { //Constructors Tests //ExecutionEngineException() TEST(mscorlib_System_ExecutionEngineException_Fixture,DefaultConstructor) { mscorlib::System::ExecutionEngineException *value = new mscorlib::System::ExecutionEngineException(); EXPECT_NE(NULL, value->GetNativeObject()); } //ExecutionEngineException(mscorlib::System::String message) TEST(mscorlib_System_ExecutionEngineException_Fixture,Constructor_2) { mscorlib::System::ExecutionEngineException *value = new mscorlib::System::ExecutionEngineException(); EXPECT_NE(NULL, value->GetNativeObject()); } //ExecutionEngineException(mscorlib::System::String message, mscorlib::System::Exception innerException) TEST(mscorlib_System_ExecutionEngineException_Fixture,Constructor_3) { mscorlib::System::ExecutionEngineException *value = new mscorlib::System::ExecutionEngineException(); EXPECT_NE(NULL, value->GetNativeObject()); } //Public Methods Tests //Public Properties Tests // Property InnerException // Return Type: mscorlib::System::Exception // Property Get Method TEST(mscorlib_System_ExecutionEngineException_Fixture,get_InnerException_Test) { } // Property HelpLink // Return Type: mscorlib::System::String // Property Get Method TEST(mscorlib_System_ExecutionEngineException_Fixture,get_HelpLink_Test) { } // Property HelpLink // Return Type: mscorlib::System::String // Property Set Method TEST(mscorlib_System_ExecutionEngineException_Fixture,set_HelpLink_Test) { } // Property HResult // Return Type: mscorlib::System::Int32 // Property Get Method TEST(mscorlib_System_ExecutionEngineException_Fixture,get_HResult_Test) { } // Property HResult // Return Type: mscorlib::System::Int32 // Property Set Method TEST(mscorlib_System_ExecutionEngineException_Fixture,set_HResult_Test) { } // Property Message // Return Type: mscorlib::System::String // Property Get Method TEST(mscorlib_System_ExecutionEngineException_Fixture,get_Message_Test) { } // Property Source // Return Type: mscorlib::System::String // Property Get Method TEST(mscorlib_System_ExecutionEngineException_Fixture,get_Source_Test) { } // Property Source // Return Type: mscorlib::System::String // Property Set Method TEST(mscorlib_System_ExecutionEngineException_Fixture,set_Source_Test) { } // Property StackTrace // Return Type: mscorlib::System::String // Property Get Method TEST(mscorlib_System_ExecutionEngineException_Fixture,get_StackTrace_Test) { } // Property TargetSite // Return Type: mscorlib::System::Reflection::MethodBase // Property Get Method TEST(mscorlib_System_ExecutionEngineException_Fixture,get_TargetSite_Test) { } // Property Data // Return Type: mscorlib::System::Collections::IDictionary // Property Get Method TEST(mscorlib_System_ExecutionEngineException_Fixture,get_Data_Test) { } } }
23.9
106
0.744247
brunolauze
9ef9bf801dd957c662893f06f4ecfcb95d457a45
1,812
cpp
C++
src/route/replication_change_handler.cpp
stolet/anna
a2aa8cd962371d1e0ed38b636d1d4c6054eeb228
[ "Apache-2.0" ]
489
2019-08-09T18:50:19.000Z
2022-03-31T20:06:30.000Z
src/route/replication_change_handler.cpp
stolet/anna
a2aa8cd962371d1e0ed38b636d1d4c6054eeb228
[ "Apache-2.0" ]
46
2019-08-27T12:13:09.000Z
2021-10-06T06:05:33.000Z
src/route/replication_change_handler.cpp
stolet/anna
a2aa8cd962371d1e0ed38b636d1d4c6054eeb228
[ "Apache-2.0" ]
109
2019-08-16T03:07:12.000Z
2022-02-26T01:31:17.000Z
// Copyright 2019 U.C. Berkeley RISE Lab // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "route/routing_handlers.hpp" void replication_change_handler(logger log, string &serialized, SocketCache &pushers, map<Key, KeyReplication> &key_replication_map, unsigned thread_id, Address ip) { if (thread_id == 0) { // tell all worker threads about the replication factor change for (unsigned tid = 1; tid < kRoutingThreadCount; tid++) { kZmqUtil->send_string( serialized, &pushers[RoutingThread(ip, tid) .replication_change_connect_address()]); } } ReplicationFactorUpdate update; update.ParseFromString(serialized); for (const auto &key_rep : update.updates()) { Key key = key_rep.key(); log->info("Received a replication factor change for key {}.", key); for (const ReplicationFactor_ReplicationValue &global : key_rep.global()) { key_replication_map[key].global_replication_[global.tier()] = global.value(); } for (const ReplicationFactor_ReplicationValue &local : key_rep.local()) { key_replication_map[key].local_replication_[local.tier()] = local.value(); } } }
38.553191
80
0.663907
stolet
9efb015f6d24c9820019c7a83203c9e64b0c674b
1,861
cc
C++
src/roots/test/tstfdjac.cc
jhchang-lanl/Draco
b8e3bcd38ab739615c1df506268d70bf99929efa
[ "BSD-3-Clause-Open-MPI" ]
43
2017-02-17T23:47:36.000Z
2022-03-14T07:53:43.000Z
src/roots/test/tstfdjac.cc
jhchang-lanl/Draco
b8e3bcd38ab739615c1df506268d70bf99929efa
[ "BSD-3-Clause-Open-MPI" ]
848
2017-01-16T01:03:38.000Z
2022-01-11T18:56:50.000Z
src/roots/test/tstfdjac.cc
jhchang-lanl/Draco
b8e3bcd38ab739615c1df506268d70bf99929efa
[ "BSD-3-Clause-Open-MPI" ]
31
2017-03-02T19:51:15.000Z
2021-09-08T02:33:34.000Z
//--------------------------------------------*-C++-*---------------------------------------------// /*! * \file roots/test/tstfdjac.cc * \author Kent Budge * \date Mon Aug 9 13:39:20 2004 * \note Copyright 2016-2020 Triad National Security, LLC., All rights reserved. */ //------------------------------------------------------------------------------------------------// #include "ds++/Release.hh" #include "ds++/ScalarUnitTest.hh" #include "ds++/Soft_Equivalence.hh" #include "linear/fnorm.hh" #include "roots/fdjac.hh" using namespace std; using namespace rtt_dsxx; using namespace rtt_linear; using namespace rtt_roots; //------------------------------------------------------------------------------------------------// // TESTS //------------------------------------------------------------------------------------------------// void func(const vector<double> &x, vector<double> &fvec) { fvec.resize(2); fvec[0] = 7.2 * x[0] + 3.5 * x[1] + 2.3; fvec[1] = -2.2 * x[0] + 2.7 * x[1] + 5.4; } //------------------------------------------------------------------------------------------------// void tstfdjac(UnitTest &ut) { vector<double> x(2), fvec(2), df; x[0] = 0; x[1] = 0; fnorm(x, fvec, &func); fdjac(x, fvec, df, &func); if (!soft_equiv(df[0 + 2 * 0], 7.2, 1.0e-8)) { ut.failure("fdjac did NOT succeed"); } else { ut.passes("fdjac successful"); } } //------------------------------------------------------------------------------------------------// int main(int argc, char *argv[]) { ScalarUnitTest ut(argc, argv, &release); try { tstfdjac(ut); } UT_EPILOG(ut); } //------------------------------------------------------------------------------------------------// // end of tstfdjac.cc //------------------------------------------------------------------------------------------------//
32.086207
100
0.350887
jhchang-lanl
9efda3f3195a7dca0c9d709754610d53fa42bcdc
5,507
cpp
C++
test/strings.cpp
tilnewman/utilz
401c2efe79bdddb786f04d153e7f443246268948
[ "MIT" ]
null
null
null
test/strings.cpp
tilnewman/utilz
401c2efe79bdddb786f04d153e7f443246268948
[ "MIT" ]
null
null
null
test/strings.cpp
tilnewman/utilz
401c2efe79bdddb786f04d153e7f443246268948
[ "MIT" ]
null
null
null
#include "catch.hpp" #include "utilz/strings.hpp" using namespace utilz; TEST_CASE("upperAndLower", "[upperAndLower]") { CHECK(isUpper('A')); CHECK(isUpper('a') == false); CHECK(isUpper('0') == false); CHECK(isUpper('\0') == false); CHECK(isUpper('\127') == false); CHECK(isUpper('\255') == false); CHECK(isLower('a')); CHECK(isLower('A') == false); CHECK(isLower('0') == false); CHECK(isLower('\0') == false); CHECK(isLower('\127') == false); CHECK(isLower('\255') == false); CHECK(toUpperCopy('a') == 'A'); CHECK(toUpperCopy('A') == 'A'); CHECK(toUpperCopy('0') == '0'); CHECK(toLowerCopy('a') == 'a'); CHECK(toLowerCopy('A') == 'a'); CHECK(toLowerCopy('0') == '0'); CHECK(toUpperCopy("123 abc ABC") == "123 ABC ABC"); CHECK(toLowerCopy("123 abc ABC") == "123 abc abc"); } TEST_CASE("isAndIsNot", "[isAndIsNot]") { CHECK(isAlpha('z')); CHECK(isAlpha('Z')); CHECK(isAlpha('\0') == false); CHECK(isAlpha('\127') == false); CHECK(isAlpha('\255') == false); CHECK(isDigit('0')); CHECK(isDigit('1')); CHECK(isDigit('8')); CHECK(isDigit('9')); CHECK(isDigit('a') == false); CHECK(isDigit('A') == false); CHECK(isDigit('\0') == false); CHECK(isDigit('\127') == false); CHECK(isDigit('\255') == false); CHECK(isPrintable(' ')); CHECK(isPrintable('\t') == false); CHECK(isPrintable('\r') == false); CHECK(isPrintable('\n') == false); CHECK(isPrintable('a')); CHECK(isPrintable('A')); CHECK(isPrintable('0')); CHECK(isPrintable('9')); CHECK(isPrintable('\0') == false); CHECK(isPrintable('\127') == false); CHECK(isPrintable('\255') == false); CHECK(isWhitespace(' ')); CHECK(isWhitespace('\t')); CHECK(isWhitespace('\r')); CHECK(isWhitespace('\n')); CHECK(isWhitespace('a') == false); CHECK(isWhitespace('A') == false); CHECK(isWhitespace('0') == false); CHECK(isWhitespace('9') == false); CHECK(isWhitespace('\0') == false); CHECK(isWhitespace('\127') == false); CHECK(isWhitespace('\255') == false); CHECK(isTypical(' ')); CHECK(isTypical('\t')); CHECK(isTypical('\r')); CHECK(isTypical('\n')); CHECK(isTypical('a')); CHECK(isTypical('A')); CHECK(isTypical('0')); CHECK(isTypical('9')); CHECK(isTypical('\126')); CHECK(isTypical('\0') == false); CHECK(isTypical('\127') == false); CHECK(isTypical('\255') == false); CHECK(isWhitespaceOrNonTypical(' ')); CHECK(isWhitespaceOrNonTypical('\t')); CHECK(isWhitespaceOrNonTypical('\r')); CHECK(isWhitespaceOrNonTypical('\n')); CHECK(isWhitespaceOrNonTypical('a') == false); CHECK(isWhitespaceOrNonTypical('A') == false); CHECK(isWhitespaceOrNonTypical('0') == false); CHECK(isWhitespaceOrNonTypical('9') == false); CHECK(isWhitespaceOrNonTypical('\0')); CHECK(isWhitespaceOrNonTypical('\126') == false); CHECK(isWhitespaceOrNonTypical('\127')); CHECK(isWhitespaceOrNonTypical('\255')); } TEST_CASE("trim", "[trim]") { CHECK(trimWhitespaceCopy("a a") == "a a"); CHECK(trimWhitespaceCopy(" \r\n\t a a \r\t\n ") == "a a"); CHECK(trimNonTypicalCopy("\fa a\f") == "a a"); CHECK(trimWhitespaceAndNonTypicalCopy(" \f\r\n\t a a \r\t\n \f") == "a a"); } TEST_CASE("startAndEndsWith", "[startAndEndsWith]") { CHECK(startsWith("", "") == false); CHECK(startsWith("a", "") == false); CHECK(startsWith("", "a") == false); CHECK(startsWith("a", "b") == false); CHECK(startsWith("aaa", "b") == false); CHECK(startsWith("aaa", "aaaa") == false); CHECK(startsWith("a", "a")); CHECK(startsWith("aa", "aa")); CHECK(startsWith("aaa", "aaa")); CHECK(startsWith("andNowForTesting", "a")); CHECK(startsWith("andNowForTesting", "and")); CHECK(startsWith("andNowForTesting", "n") == false); CHECK(endsWith("", "") == false); CHECK(endsWith("a", "") == false); CHECK(endsWith("", "a") == false); CHECK(endsWith("a", "b") == false); CHECK(endsWith("aaa", "b") == false); CHECK(endsWith("aaa", "aaaa") == false); CHECK(endsWith("a", "a")); CHECK(endsWith("aa", "aa")); CHECK(endsWith("aaa", "aaa")); CHECK(endsWith("andNowForTesting", "a") == false); CHECK(endsWith("andNowForTesting", "and") == false); CHECK(endsWith("andNowForTesting", "n") == false); CHECK(endsWith("andNowForTesting", "g")); CHECK(endsWith("andNowForTesting", "Testing")); } TEST_CASE("replaceAll", "[replaceAll]") { CHECK(replaceAllCopy("", "", "") == ""); CHECK(replaceAllCopy("", "a", "") == ""); CHECK(replaceAllCopy("", "", "b") == ""); CHECK(replaceAllCopy("a", "a", "") == ""); CHECK(replaceAllCopy("a", "", "b") == "a"); CHECK(replaceAllCopy("aa", "a", "b") == "bb"); CHECK(replaceAllCopy("aa", "aa", "b") == "b"); CHECK(replaceAllCopy("This and that.", " ", "_") == "This_and_that."); CHECK(replaceAllCopy("ftp: ftpftp: ftp:", "ftp", "http") == "http: httphttp: http:"); } TEST_CASE("removeAll", "[removeAll]") { CHECK(removeAllCopy("", "") == ""); CHECK(removeAllCopy("a", "") == "a"); CHECK(removeAllCopy("", "a") == ""); CHECK(removeAllCopy("a", "b") == "a"); CHECK(removeAllCopy("aaa", "bbb") == "aaa"); CHECK(removeAllCopy("a", "a") == ""); CHECK(removeAllCopy("aaa", "a") == ""); CHECK(removeAllCopy("ababab", "a") == "bbb"); CHECK(removeAllCopy("ababab", "b") == "aaa"); }
31.83237
89
0.568731
tilnewman
9efdde2c19947cf87fefe1433d0741d9c5b7e81e
1,536
hpp
C++
sprout/cstdint.hpp
EzoeRyou/Sprout
12e12373d0f70543eac5f2ecfbec8f5112765f98
[ "BSL-1.0" ]
1
2016-09-29T21:55:58.000Z
2016-09-29T21:55:58.000Z
sprout/cstdint.hpp
EzoeRyou/Sprout
12e12373d0f70543eac5f2ecfbec8f5112765f98
[ "BSL-1.0" ]
null
null
null
sprout/cstdint.hpp
EzoeRyou/Sprout
12e12373d0f70543eac5f2ecfbec8f5112765f98
[ "BSL-1.0" ]
null
null
null
/*============================================================================= Copyright (c) 2011-2014 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #ifndef SPROUT_CSTDINT_HPP #define SPROUT_CSTDINT_HPP #include <climits> #include <cstdint> #include <sprout/config.hpp> #include <sprout/detail/predef.hpp> // // SPROUT_INT[N]_C // SPROUT_UINT[N]_C // #if SPROUT_CLANG_IN_RANGE((3, 0, 0), (3, 3, 0)) && !defined(__STDC_CONSTANT_MACROS) # define SPROUT_INT8_C(n) n # define SPROUT_UINT8_C(n) n # define SPROUT_INT16_C(n) n # define SPROUT_UINT16_C(n) n # if LONG_MAX == LLONG_MAX # define SPROUT_INT32_C(n) n # define SPROUT_UINT32_C(n) n ## U # define SPROUT_INT64_C(n) n ## UL # define SPROUT_UINT64_C(n) n ## UL # else # define SPROUT_INT32_C(n) n ## L # define SPROUT_UINT32_C(n) n ## UL # define SPROUT_INT64_C(n) n ## ULL # define SPROUT_UINT64_C(n) n ## ULL # endif #else # define SPROUT_INT8_C(n) INT8_C(n) # define SPROUT_UINT8_C(n) UINT8_C(n) # define SPROUT_INT16_C(n) INT16_C(n) # define SPROUT_UINT16_C(n) UINT16_C(n) # define SPROUT_INT32_C(n) INT32_C(n) # define SPROUT_UINT32_C(n) UINT32_C(n) # define SPROUT_INT64_C(n) INT64_C(n) # define SPROUT_UINT64_C(n) UINT64_C(n) #endif #endif // #ifndef SPROUT_CSTDINT_HPP
32
84
0.63737
EzoeRyou
9eff614c1245ec6e8480507a5814ba1b3dfefa66
874
cpp
C++
ColorTransfer/hw2.2/main.cpp
hsinewu/School
2c55a3fd4a7794e64651b66d36f439a11c180b2c
[ "MIT" ]
null
null
null
ColorTransfer/hw2.2/main.cpp
hsinewu/School
2c55a3fd4a7794e64651b66d36f439a11c180b2c
[ "MIT" ]
null
null
null
ColorTransfer/hw2.2/main.cpp
hsinewu/School
2c55a3fd4a7794e64651b66d36f439a11c180b2c
[ "MIT" ]
null
null
null
#include <iostream> #include <cmath> #include <cassert> using namespace std; int printTable(const int h, const int v, const int n){ cout << "\tn\tK\tTHC\tOPT\tL\tmxc\tCL" << endl; int bestk = 0,goodk=0; int mxc = 0; int Uc = h*v/n; double thc = log2(2*n+1); double opt = thc * Uc; for(int k=1,maxk=h*v/n; k<=maxk; ++k){ int l = k*thc; int c = floor(Uc/k)*l; // cout << "\t\t" << k << "\t\t\t" << l << "\t" << c << endl; if(c>mxc){ mxc = c; bestk = k; if(l<=64) goodk = k; } } cout << "\t" << n << "\t" << bestk << "\t" << thc << "\t" << opt << "\t" << floor(bestk*thc) << "\t" << mxc << "\t" << 1-mxc/opt << endl; cout << "optimal k " << bestk << ", affordable k " << goodk << endl; return bestk; } int main(){ int h=512,v=512,n; while(cin){ cout << "\nInput h,v,n" << endl; cin >> h >> v >> n; printTable(h,v,n); } return 0; }
23
138
0.504577
hsinewu
9efff5e0efbbad6219fde5c5ba524aaa8ca40be4
6,136
cpp
C++
src/Library/Core/FileSystem/PermissionSet.cpp
cowlicks/library-core
9a872ab7aa6bc4aba22734705b72dc22ea35ee77
[ "Apache-2.0" ]
null
null
null
src/Library/Core/FileSystem/PermissionSet.cpp
cowlicks/library-core
9a872ab7aa6bc4aba22734705b72dc22ea35ee77
[ "Apache-2.0" ]
null
null
null
src/Library/Core/FileSystem/PermissionSet.cpp
cowlicks/library-core
9a872ab7aa6bc4aba22734705b72dc22ea35ee77
[ "Apache-2.0" ]
1
2020-12-01T14:50:50.000Z
2020-12-01T14:50:50.000Z
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// @project Library ▸ Core /// @file Library/Core/FileSystem/PermissionSet.cpp /// @author Lucas Brémond <lucas@loftorbital.com> /// @license Apache License 2.0 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include <Library/Core/FileSystem/PermissionSet.hpp> #include <Library/Core/Error.hpp> #include <Library/Core/Utilities.hpp> //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// namespace library { namespace core { namespace fs { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// PermissionSet::PermissionSet ( const bool canRead, const bool canWrite, const bool canExecute ) : read_(canRead), write_(canWrite), execute_(canExecute) { } bool PermissionSet::operator == ( const PermissionSet& aPermissionSet ) const { return (read_ == aPermissionSet.read_) && (write_ == aPermissionSet.write_) && (execute_ == aPermissionSet.execute_) ; } bool PermissionSet::operator != ( const PermissionSet& aPermissionSet ) const { return (read_ != aPermissionSet.read_) || (write_ != aPermissionSet.write_) || (execute_ != aPermissionSet.execute_) ; } PermissionSet PermissionSet::operator + ( const PermissionSet& aPermissionSet ) const { return { read_ || aPermissionSet.read_, write_ || aPermissionSet.write_, execute_ || aPermissionSet.execute_ } ; } PermissionSet PermissionSet::operator - ( const PermissionSet& aPermissionSet ) const { PermissionSet permissionSet = { *this } ; if (aPermissionSet.read_) { permissionSet.read_ = false ; } if (aPermissionSet.write_) { permissionSet.write_ = false ; } if (aPermissionSet.execute_) { permissionSet.execute_ = false ; } return permissionSet ; } PermissionSet PermissionSet::operator && ( const PermissionSet& aPermissionSet ) const { return { read_ && aPermissionSet.read_, write_ && aPermissionSet.write_, execute_ && aPermissionSet.execute_ } ; } PermissionSet PermissionSet::operator || ( const PermissionSet& aPermissionSet ) const { return { read_ || aPermissionSet.read_, write_ || aPermissionSet.write_, execute_ || aPermissionSet.execute_ } ; } std::ostream& operator << ( std::ostream& anOutputStream, const PermissionSet& aPermissionSet ) { library::core::utils::Print::Header(anOutputStream, "Permission Set") ; library::core::utils::Print::Line(anOutputStream) << "Read:" << aPermissionSet.read_ ; library::core::utils::Print::Line(anOutputStream) << "Write:" << aPermissionSet.write_ ; library::core::utils::Print::Line(anOutputStream) << "Execute:" << aPermissionSet.execute_ ; library::core::utils::Print::Footer(anOutputStream) ; return anOutputStream ; } bool PermissionSet::isNone ( ) const { return (!read_) && (!write_) && (!execute_) ; } bool PermissionSet::isAll ( ) const { return read_ && write_ && execute_ ; } bool PermissionSet::canRead ( ) const { return read_ ; } bool PermissionSet::canWrite ( ) const { return write_ ; } bool PermissionSet::canExecute ( ) const { return execute_ ; } PermissionSet PermissionSet::None ( ) { return { false, false, false } ; } PermissionSet PermissionSet::R ( ) { return { true, false, false } ; } PermissionSet PermissionSet::W ( ) { return { false, true, false } ; } PermissionSet PermissionSet::X ( ) { return { false, false, true } ; } PermissionSet PermissionSet::RW ( ) { return { true, true, false } ; } PermissionSet PermissionSet::RX ( ) { return { true, false, true } ; } PermissionSet PermissionSet::RWX ( ) { return { true, true, true } ; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
36.52381
167
0.383963
cowlicks
730644d4c1ccf4fd7d9b962bda161f174237706e
20,780
cpp
C++
programs/koinos_chain/main.cpp
joticajulian/koinos-chain
b5db60b427ebb97dabf1acf8108e94bbc75a46d4
[ "MIT" ]
null
null
null
programs/koinos_chain/main.cpp
joticajulian/koinos-chain
b5db60b427ebb97dabf1acf8108e94bbc75a46d4
[ "MIT" ]
null
null
null
programs/koinos_chain/main.cpp
joticajulian/koinos-chain
b5db60b427ebb97dabf1acf8108e94bbc75a46d4
[ "MIT" ]
null
null
null
#include <cstdlib> #include <filesystem> #include <fstream> #include <iostream> #include <string> #include <boost/asio.hpp> #include <boost/asio/signal_set.hpp> #include <boost/program_options.hpp> #include <boost/thread/sync_bounded_queue.hpp> #include <yaml-cpp/yaml.h> #include <google/protobuf/util/json_util.h> #include <koinos/chain/constants.hpp> #include <koinos/chain/controller.hpp> #include <koinos/chain/state.hpp> #include <koinos/crypto/multihash.hpp> #include <koinos/exception.hpp> #include <koinos/mq/client.hpp> #include <koinos/mq/request_handler.hpp> #include <koinos/log.hpp> #include <koinos/broadcast/broadcast.pb.h> #include <koinos/rpc/block_store/block_store_rpc.pb.h> #include <koinos/rpc/mempool/mempool_rpc.pb.h> #include <koinos/util/base58.hpp> #include <koinos/util/conversion.hpp> #include <koinos/util/options.hpp> #include <koinos/util/random.hpp> #include <koinos/util/services.hpp> #define KOINOS_MAJOR_VERSION "0" #define KOINOS_MINOR_VERSION "1" #define KOINOS_PATCH_VERSION "0" #define HELP_OPTION "help" #define VERSION_OPTION "version" #define BASEDIR_OPTION "basedir" #define AMQP_OPTION "amqp" #define AMQP_DEFAULT "amqp://guest:guest@localhost:5672/" #define LOG_LEVEL_OPTION "log-level" #define LOG_LEVEL_DEFAULT "info" #define INSTANCE_ID_OPTION "instance-id" #define STATEDIR_OPTION "statedir" #define JOBS_OPTION "jobs" #define STATEDIR_DEFAULT "blockchain" #define RESET_OPTION "reset" #define GENESIS_DATA_FILE_OPTION "genesis-data" #define GENESIS_DATA_FILE_DEFAULT "genesis_data.json" #define READ_COMPUTE_BANDWITH_LIMIT_OPTION "read-compute-bandwidth-limit" #define READ_COMPUTE_BANDWITH_LIMIT_DEFAULT 10'000'000 using namespace boost; using namespace koinos; const std::string& version_string() { static std::string v_str = "Koinos chain v" KOINOS_MAJOR_VERSION "." KOINOS_MINOR_VERSION "." KOINOS_PATCH_VERSION; return v_str; } void splash() { const char* banner = R"BANNER( _ __ _ | |/ /___ (_)_ __ ___ ___ | ' // _ \| | '_ \ / _ \/ __| | . \ (_) | | | | | (_) \__ \ |_|\_\___/|_|_| |_|\___/|___/)BANNER"; std::cout.write( banner, std::strlen( banner ) ); std::cout << std::endl; const char* launch_message = " ...launching network"; std::cout.write( launch_message, std::strlen( launch_message ) ); std::cout << std::endl << std::flush; } void attach_request_handler( chain::controller& controller, mq::request_handler& mq_reqhandler, const std::string& amqp_url ) { mq_reqhandler.add_rpc_handler( util::service::chain, [&]( const std::string& msg ) -> std::string { rpc::chain::chain_request args; rpc::chain::chain_response resp; if ( args.ParseFromString( msg ) ) { LOG(debug) << "Received rpc: " << args; try { switch( args.request_case() ) { case rpc::chain::chain_request::RequestCase::kReserved: { resp.mutable_reserved(); break; } case rpc::chain::chain_request::RequestCase::kSubmitBlock: { *resp.mutable_submit_block() = controller.submit_block( args.submit_block() ); break; } case rpc::chain::chain_request::RequestCase::kSubmitTransaction: { *resp.mutable_submit_transaction() = controller.submit_transaction( args.submit_transaction() ); break; } case rpc::chain::chain_request::RequestCase::kGetHeadInfo: { *resp.mutable_get_head_info() = controller.get_head_info( args.get_head_info() ); break; } case rpc::chain::chain_request::RequestCase::kGetChainId: { *resp.mutable_get_chain_id() = controller.get_chain_id( args.get_chain_id() ); break; } case rpc::chain::chain_request::RequestCase::kGetForkHeads: { *resp.mutable_get_fork_heads() = controller.get_fork_heads( args.get_fork_heads() ); break; } case rpc::chain::chain_request::RequestCase::kReadContract: { *resp.mutable_read_contract() = controller.read_contract( args.read_contract() ); break; } case rpc::chain::chain_request::RequestCase::kGetAccountNonce: { *resp.mutable_get_account_nonce() = controller.get_account_nonce( args.get_account_nonce() ); break; } case rpc::chain::chain_request::RequestCase::kGetAccountRc: { *resp.mutable_get_account_rc() = controller.get_account_rc( args.get_account_rc() ); break; } case rpc::chain::chain_request::RequestCase::kGetResourceLimits: { *resp.mutable_get_resource_limits() = controller.get_resource_limits( args.get_resource_limits() ); break; } default: { resp.mutable_error()->set_message( "Error: attempted to call unknown rpc" ); } } } catch( const koinos::exception& e ) { auto error = resp.mutable_error(); error->set_message( e.what() ); error->set_data( e.get_json().dump() ); } catch( std::exception& e ) { resp.mutable_error()->set_message( e.what() ); } catch( ... ) { LOG(error) << "Unexpected error while handling rpc: " << args.ShortDebugString(); resp.mutable_error()->set_message( "Unexpected error while handling rpc" ); } } else { LOG(warning) << "Received bad message"; resp.mutable_error()->set_message( "Received bad message" ); } LOG(debug) << "Sending rpc response: " << resp; std::string r; resp.SerializeToString( &r ); return r; } ); mq_reqhandler.add_broadcast_handler( "koinos.block.accept", [&]( const std::string& msg ) { broadcast::block_accepted bam; if ( !bam.ParseFromString( msg ) ) { LOG(warning) << "Could not parse block accepted broadcast"; return; } try { rpc::chain::submit_block_request sub_block; sub_block.set_allocated_block( bam.release_block() ); controller.submit_block( sub_block ); } catch( const boost::exception& e ) { LOG(warning) << "Error handling block broadcast: " << boost::diagnostic_information( e ); } catch( const std::exception& e ) { LOG(warning) << "Error handling block broadcast: " << e.what(); } } ); LOG(info) << "Connecting AMQP request handler..."; mq_reqhandler.connect( amqp_url ); LOG(info) << "Established request handler connection to the AMQP server"; } void index_loop( chain::controller& controller, concurrent::sync_bounded_queue< std::shared_future< std::string > >& rpc_queue, uint64_t last_height ) { while ( true ) { std::shared_future< std::string > future; try { rpc_queue.pull_front( future ); } catch ( const concurrent::sync_queue_is_closed& ) { break; } try { rpc::block_store::block_store_response resp; rpc::block_store::get_blocks_by_height_response* batch = nullptr; if ( resp.ParseFromString( future.get() ) ) { switch( resp.response_case() ) { case rpc::block_store::block_store_response::ResponseCase::kGetBlocksByHeight: { batch = resp.mutable_get_blocks_by_height(); break; } case rpc::block_store::block_store_response::ResponseCase::kError: { KOINOS_THROW( chain::rpc_failure, resp.error().message() ); break; } default: { KOINOS_THROW( chain::rpc_failure, "unexpected block store response" ); break; } } } rpc::chain::submit_block_request sub_block; for ( auto& block_item : *batch->mutable_block_items() ) { sub_block.set_allocated_block( block_item.release_block() ); controller.submit_block( sub_block, last_height ); } } catch ( const boost::exception& e ) { LOG(error) << "Index error: " << boost::diagnostic_information( e ); exit( EXIT_FAILURE ); } catch ( const std::exception& e ) { LOG(error) << "Index error: " << e.what(); exit( EXIT_FAILURE ); } } } void index( chain::controller& controller, std::shared_ptr< mq::client > mq_client ) { using namespace rpc::block_store; try { constexpr uint64_t batch_size = 1000; const auto before = std::chrono::system_clock::now(); LOG(info) << "Retrieving highest block from block store"; rpc::block_store::block_store_request req; req.mutable_get_highest_block(); std::string req_str; req.SerializeToString( &req_str ); auto future = mq_client->rpc( util::service::block_store, req_str ); rpc::block_store::block_store_response resp; block_topology target_head; if( resp.ParseFromString( future.get() ) ) { switch( resp.response_case() ) { case rpc::block_store::block_store_response::ResponseCase::kGetHighestBlock: { target_head.CopyFrom( resp.get_highest_block().topology() ); break; } case rpc::block_store::block_store_response::ResponseCase::kError: { KOINOS_THROW( chain::rpc_failure, resp.error().message() ); break; } default: { KOINOS_THROW( chain::rpc_failure, "unexpected block store response" ); break; } } } else { LOG(error) << "Could not get highest block from block store"; exit( EXIT_FAILURE ); } auto head_info = controller.get_head_info(); if ( head_info.head_topology().height() < target_head.height() ) { LOG(info) << "Indexing to target block: " << target_head; concurrent::sync_bounded_queue< std::shared_future< std::string > > rpc_queue{ 10 }; auto index_thread = std::make_unique< std::thread >( [&]() { index_loop( controller, rpc_queue, target_head.height() ); } ); crypto::multihash last_id = crypto::multihash::zero( crypto::multicodec::sha2_256 ); uint64_t last_height = head_info.head_topology().height(); while ( last_height < target_head.height() ) { auto* by_height_req = req.mutable_get_blocks_by_height(); by_height_req->set_head_block_id( target_head.id() ); by_height_req->set_ancestor_start_height( last_height + 1 ); by_height_req->set_num_blocks( batch_size ); by_height_req->set_return_block( true ); by_height_req->set_return_receipt( false ); req.SerializeToString( &req_str ); rpc_queue.push_back( mq_client->rpc( util::service::block_store, req_str ) ); last_height += batch_size; } rpc_queue.close(); index_thread->join(); auto new_head_info = controller.get_head_info(); const std::chrono::duration< double > duration = std::chrono::system_clock::now() - before; LOG(info) << "Finished indexing " << new_head_info.head_topology().height() - head_info.head_topology().height() << " blocks, took " << duration.count() << " seconds"; } } catch ( const std::exception& e ) { LOG(error) << "Index error: " << e.what(); exit( EXIT_FAILURE ); } } int main( int argc, char** argv ) { try { program_options::options_description options; options.add_options() (HELP_OPTION ",h", "Print this help message and exit") (VERSION_OPTION ",v", "Print version string and exit") (BASEDIR_OPTION ",d", program_options::value< std::string >()->default_value( util::get_default_base_directory().string() ), "Koinos base directory") (AMQP_OPTION ",a", program_options::value< std::string >(), "AMQP server URL") (LOG_LEVEL_OPTION ",l", program_options::value< std::string >(), "The log filtering level") (INSTANCE_ID_OPTION ",i", program_options::value< std::string >(), "An ID that uniquely identifies the instance") (JOBS_OPTION ",j", program_options::value< uint64_t >(), "The number of worker jobs") (READ_COMPUTE_BANDWITH_LIMIT_OPTION",b", program_options::value< uint64_t >(), "The compute bandwidth when reading contracts via the API") (GENESIS_DATA_FILE_OPTION ",g", program_options::value< std::string >(), "The genesis data file") (STATEDIR_OPTION , program_options::value< std::string >(), "The location of the blockchain state files (absolute path or relative to basedir/chain)") (RESET_OPTION , program_options::bool_switch()->default_value(false), "Reset the database"); program_options::variables_map args; program_options::store( program_options::parse_command_line( argc, argv, options ), args ); if ( args.count( HELP_OPTION ) ) { std::cout << options << std::endl; return EXIT_SUCCESS; } if ( args.count( VERSION_OPTION ) ) { const auto& v_str = version_string(); std::cout.write( v_str.c_str(), v_str.size() ); std::cout << std::endl; return EXIT_SUCCESS; } splash(); auto basedir = std::filesystem::path( args[ BASEDIR_OPTION ].as< std::string >() ); if ( basedir.is_relative() ) basedir = std::filesystem::current_path() / basedir; YAML::Node config; YAML::Node global_config; YAML::Node chain_config; auto yaml_config = basedir / "config.yml"; if ( !std::filesystem::exists( yaml_config ) ) { yaml_config = basedir / "config.yaml"; } if ( std::filesystem::exists( yaml_config ) ) { config = YAML::LoadFile( yaml_config ); global_config = config[ "global" ]; chain_config = config[ util::service::chain ]; } std::string amqp_url = util::get_option< std::string >( AMQP_OPTION, AMQP_DEFAULT, args, chain_config, global_config ); std::string log_level = util::get_option< std::string >( LOG_LEVEL_OPTION, LOG_LEVEL_DEFAULT, args, chain_config, global_config ); std::string instance_id = util::get_option< std::string >( INSTANCE_ID_OPTION, util::random_alphanumeric( 5 ), args, chain_config, global_config ); auto statedir = std::filesystem::path( util::get_option< std::string >( STATEDIR_OPTION, STATEDIR_DEFAULT, args, chain_config, global_config ) ); auto genesis_data_file = std::filesystem::path( util::get_option< std::string >( GENESIS_DATA_FILE_OPTION, GENESIS_DATA_FILE_DEFAULT, args, chain_config, global_config ) ); auto reset = util::get_flag( RESET_OPTION, false, args, chain_config, global_config ); auto jobs = util::get_option< uint64_t >( JOBS_OPTION, std::thread::hardware_concurrency(), args, chain_config, global_config ); auto read_compute_limit = util::get_option< uint64_t >( READ_COMPUTE_BANDWITH_LIMIT_OPTION, READ_COMPUTE_BANDWITH_LIMIT_DEFAULT, args, chain_config, global_config ); koinos::initialize_logging( util::service::chain, instance_id, log_level, basedir / util::service::chain ); KOINOS_ASSERT( jobs > 0, koinos::exception, "jobs must be greater than 0" ); if ( config.IsNull() ) { LOG(warning) << "Could not find config (config.yml or config.yaml expected). Using default values"; } if ( statedir.is_relative() ) statedir = basedir / util::service::chain / statedir; if ( !std::filesystem::exists( statedir ) ) std::filesystem::create_directories( statedir ); // Load genesis data if ( genesis_data_file.is_relative() ) genesis_data_file = basedir / util::service::chain / genesis_data_file; KOINOS_ASSERT( std::filesystem::exists( genesis_data_file ), koinos::exception, "unable to locate genesis data file at: ${loc}", ("loc", genesis_data_file.string()) ); std::ifstream gifs( genesis_data_file ); std::stringstream genesis_data_stream; genesis_data_stream << gifs.rdbuf(); std::string genesis_json = genesis_data_stream.str(); gifs.close(); chain::genesis_data genesis_data; google::protobuf::util::JsonParseOptions jpo; google::protobuf::util::JsonStringToMessage( genesis_json, &genesis_data, jpo ); crypto::multihash chain_id = crypto::hash( crypto::multicodec::sha2_256, genesis_data ); LOG(info) << "Chain ID: " << chain_id; LOG(info) << "Number of jobs: " << jobs; chain::controller controller( read_compute_limit ); controller.open( statedir, genesis_data, reset ); asio::io_context main_context, work_context; auto mq_client = std::make_shared< mq::client >(); auto request_handler = mq::request_handler( work_context ); LOG(info) << "Connecting AMQP client..."; mq_client->connect( amqp_url ); LOG(info) << "Established AMQP client connection to the server"; std::string result; LOG(info) << "Attempting to connect to block_store..."; rpc::block_store::block_store_request b_req; b_req.mutable_reserved(); b_req.SerializeToString( &result ); mq_client->rpc( util::service::block_store, result ).get(); LOG(info) << "Established connection to block_store"; result.clear(); LOG(info) << "Attempting to connect to mempool..."; rpc::mempool::mempool_request m_req; m_req.mutable_reserved(); m_req.SerializeToString( &result ); mq_client->rpc( util::service::mempool, result ).get(); LOG(info) << "Established connection to mempool"; index( controller, mq_client ); controller.set_client( mq_client ); attach_request_handler( controller, request_handler, amqp_url ); LOG(info) << "Listening for requests over AMQP"; asio::signal_set signals( main_context, SIGINT, SIGTERM ); signals.async_wait( [&]( const system::error_code& err, int num ) { LOG(info) << "Caught signal, shutting down..."; boost::asio::post( main_context, [&]() { work_context.stop(); main_context.stop(); mq_client->disconnect(); } ); } ); std::vector< std::thread > threads; for ( std::size_t i = 0; i < jobs; i++ ) threads.emplace_back( [&]() { work_context.run(); } ); main_context.run(); for ( auto& t : threads ) t.join(); LOG(info) << "Shut down successfully"; return EXIT_SUCCESS; } catch ( const boost::exception& e ) { LOG(fatal) << boost::diagnostic_information( e ); } catch ( const std::exception& e ) { LOG(fatal) << e.what(); } catch ( ... ) { LOG(fatal) << "Unknown exception"; } return EXIT_FAILURE; }
36.713781
181
0.576275
joticajulian
7307bd870d88963f31631b4c7027563256fb7b7c
14,425
cpp
C++
Desktop/FOSSA-GroundStationControlPanel/FOSSAGSCP/MessageHandlers/FOSSASAT2_MessageHandler.cpp
FOSSASystems/FOSSA-GroundStationControlPanel
af83a09619239abe9fca09e073ab41c68bfd4822
[ "MIT" ]
2
2021-11-07T16:26:46.000Z
2022-03-20T10:14:41.000Z
Desktop/FOSSA-GroundStationControlPanel/FOSSAGSCP/MessageHandlers/FOSSASAT2_MessageHandler.cpp
FOSSASystems/FOSSA-GroundStationControlPanel
af83a09619239abe9fca09e073ab41c68bfd4822
[ "MIT" ]
18
2020-08-28T13:38:36.000Z
2020-09-30T11:08:42.000Z
Desktop/FOSSA-GroundStationControlPanel/FOSSAGSCP/MessageHandlers/FOSSASAT2_MessageHandler.cpp
FOSSASystems/FOSSA-GroundStationControlPanel
af83a09619239abe9fca09e073ab41c68bfd4822
[ "MIT" ]
2
2020-07-29T21:19:28.000Z
2021-08-16T03:58:14.000Z
#include "FOSSASAT2_MessageHandler.h" #include "../systeminformationpane.h" #include "../ui_systeminformationpane.h" #include "../mainwindow.h" #include "../ui_mainwindow.h" #include "../messagelogframe.h" #include "../ui_messagelogframe.h" void FOSSASAT2::MessageHandler::Handle(FOSSASAT2::Messages::SystemInfo msg, systeminformationpane* systemInfoPane) { Ui::systeminformationpane* ui = systemInfoPane->GetUI(); ui->SystemInformation_MPPT_OutputVoltage_SpinBox->setValue(msg.GetMpptOutputVoltage()); ui->SystemInformation_MPPT_OutputCurrent_SpinBox->setValue(msg.GetMpptOutputCurrent()); ui->SystemInformation_UnixTimestamp_LineEdit->setText(QString::number(msg.GetUnixTimestamp())); ui->SystemInformation_PowerConfiguration_TransmissionsEnabled_Enabled_RadioButton->setChecked(msg.IsTransmissionsEnabled()); ui->SystemInformation_PowerConfiguration_TransmissionsEnabled_Disabled_RadioButton->setChecked(!msg.IsTransmissionsEnabled()); ui->SystemInformation_PowerConfiguration_LowPowerMode_Enabled_RadioButton->setChecked(msg.IsLowPowerModeEnabled()); ui->SystemInformation_PowerConfiguration_LowPowerMode_Disabled_RadioButton->setChecked(!msg.IsLowPowerModeEnabled()); ui->SystemInformation_PowerConfiguration_LowPowerActiveMode_LP_RadioButton->setChecked(msg.IsLowPowerModeActive()); ui->SystemInformation_PowerConfiguration_LowPowerActiveMode_Sleep_RadioButton->setChecked(msg.IsSleepMode()); ui->SystemInformation_PowerConfiguration_MPPTTemperatureSwitchEnabled_Enabled_RadioButton->setChecked(msg.GetMpptTemperatureSwitchEnabled()); ui->SystemInformation_PowerConfiguration_MPPTTemperatureSwitchEnabled_Disabled_RadioButton->setChecked(!msg.GetMpptTemperatureSwitchEnabled()); ui->SystemInformation_PowerConfiguration_MPPTKeepAliveEnabled_Enabled_RadioButton->setChecked(msg.GetMpptKeepAliveEnabled()); ui->SystemInformation_PowerConfiguration_MPPTKeepAliveEnabled_Disabled_RadioButton->setChecked(!msg.GetMpptKeepAliveEnabled()); ui->SystemInformation_ResetCounter_SpinBox->setValue(msg.GetResetCounter()); ui->SystemInformation_SolarPanelsPowerInformation_SolarPanelXAVoltage_SpinBox->setValue(msg.GetSolarPanelXaVoltage()); ui->SystemInformation_SolarPanelsPowerInformation_SolarPanelXBVoltage_SpinBox->setValue(msg.GetSolarPanelXbVoltage()); ui->SystemInformation_SolarPanelsPowerInformation_SolarPanelZAVoltage_SpinBox->setValue(msg.GetSolarPanelZaVoltage()); ui->SystemInformation_SolarPanelsPowerInformation_SolarPanelZBVoltage_SpinBox->setValue(msg.GetSolarPanelZbVoltage()); ui->SystemInformation_SolarPanelsPowerInformation_SolarPanelYVoltage_SpinBox->setValue(msg.GetSolarPanelYVoltage()); ui->SystemInformation_TemperatureInformation_BatteryTemperature_DoubleSpinBox->setValue(msg.GetBatteryTemperature()); ui->SystemInformation_TemperatureInformation_OBCBoardTemperature_DoubleSpinBox->setValue(msg.GetObcBoardTemperature()); ui->SystemInformation_FlashInformation_CRCError_SpinBox->setValue(msg.GetFlashSystemInfoPageCrcErrorCounter()); } void FOSSASAT2::MessageHandler::Handle(FOSSASAT2::Messages::PacketInfo msg, systeminformationpane* systemInfoPane) { Ui::systeminformationpane* ui = systemInfoPane->GetUI(); ui->PacketInformation_SNR_SpinBox->setValue(msg.GetSnr()); ui->PacketInformation_RSSI_SpinBox->setValue(msg.GetRssi()); ui->PacketInformation_LoraFrameInformation_NumValidFrames_SpinBox->setValue(msg.GetNumReceivedValidLoraFrames()); ui->PacketInformation_LoraFrameInformation_NumInvalidFrames_SpinBox->setValue(msg.GetNumReceivedInvalidLoraFrames()); ui->PacketInformation_FSKFrameInformation_NumValidFrames_SpinBox->setValue(msg.GetNumReceivedValidFskFrames()); ui->PacketInformation_FSKFrameInformation_NumInvalidFrames_SpinBox->setValue(msg.GetNumReceivedInvalidFskFrames()); } void FOSSASAT2::MessageHandler::Handle(FOSSASAT2::Messages::Statistics msg, systeminformationpane* systemInfoPane) { Ui::systeminformationpane* ui = systemInfoPane->GetUI(); ui->StatisticsControls_Flags_2_Temperatures_Enabled->setChecked(msg.IsTemperaturesIncluded()); ui->StatisticsControls_Flags_2_Temperatures_Disabled->setChecked(!msg.IsTemperaturesIncluded()); ui->StatisticsControls_Flags_2_Currents_Enabled->setChecked(msg.IsCurrentsIncluded()); ui->StatisticsControls_Flags_2_Currents_Disabled->setChecked(!msg.IsCurrentsIncluded()); ui->StatisticsControls_Flags_2_Voltages_Enabled->setChecked(msg.IsVoltagesIncluded()); ui->StatisticsControls_Flags_2_Voltages_Disabled->setChecked(!msg.IsVoltagesIncluded()); ui->StatisticsControls_Flags_2_LightSensors_Enabled->setChecked(msg.IsLightSensorsIncluded()); ui->StatisticsControls_Flags_2_LightSensors_Disabled->setChecked(!msg.IsLightSensorsIncluded()); ui->StatisticsControls_Flags_2_IMU_Enabled->setChecked(msg.IsImuIncluded()); ui->StatisticsControls_Flags_2_IMU_Disabled->setChecked(!msg.IsImuIncluded()); ui->LiveStatistics_Temperatures_PlainTextEdit->clear(); ui->LiveStatistics_Currents_PlainTextEdit->clear(); ui->LiveStatistics_Voltages_PlainTextEdit->clear(); ui->LiveStatistics_LightSensors_PlainTextEdit->clear(); ui->LiveStatistics_IMU_PlainTextEdit->clear(); if (msg.IsTemperaturesIncluded()) { const std::vector<float>& temperatures = msg.GetTemperatures(); for (float temperature : temperatures) { ui->LiveStatistics_Temperatures_PlainTextEdit->appendPlainText(QString::number(temperature) + QString(" ºC\n")); } } if (msg.IsVoltagesIncluded()) { const std::vector<float>& voltages = msg.GetVoltages(); for (float voltage : voltages) { ui->LiveStatistics_Voltages_PlainTextEdit->appendPlainText(QString::number(voltage) + QString(" mV\n")); } } if (msg.IsLightSensorsIncluded()) { const std::vector<float>& lightSensors = msg.GetLightSensors(); for (float lightSensor : lightSensors) { ui->LiveStatistics_LightSensors_PlainTextEdit->appendPlainText(QString::number(lightSensor) + QString(" ???\n")); } } if (msg.IsImuIncluded()) { const std::vector<float>& imus = msg.GetImus(); for (float imu : imus) { ui->LiveStatistics_IMU_PlainTextEdit->appendPlainText(QString::number(imu) + QString(" ???\n")); } } } void FOSSASAT2::MessageHandler::Handle(FOSSASAT2::Messages::FullSystemInfo msg, systeminformationpane* systemInfoPane) { Ui::systeminformationpane* ui = systemInfoPane->GetUI(); ui->SystemInformation_MPPT_OutputVoltage_SpinBox->setValue(msg.GetMpptOutputVoltage()); ui->SystemInformation_MPPT_OutputCurrent_SpinBox->setValue(msg.GetMpptOutputCurrent()); ui->SystemInformation_UnixTimestamp_LineEdit->setText(QString::number(msg.GetUnixTimestamp())); ui->SystemInformation_PowerConfiguration_TransmissionsEnabled_Enabled_RadioButton->setChecked(msg.GetTransmissionsEnabled()); ui->SystemInformation_PowerConfiguration_TransmissionsEnabled_Disabled_RadioButton->setChecked(!msg.GetTransmissionsEnabled()); ui->SystemInformation_PowerConfiguration_LowPowerMode_Enabled_RadioButton->setChecked(msg.GetLowPowerModeEnabled()); ui->SystemInformation_PowerConfiguration_LowPowerMode_Disabled_RadioButton->setChecked(!msg.GetLowPowerModeEnabled()); ui->SystemInformation_PowerConfiguration_LowPowerActiveMode_LP_RadioButton->setChecked(!msg.IsNoLowPowerMode()); ui->SystemInformation_PowerConfiguration_LowPowerActiveMode_Sleep_RadioButton->setChecked(msg.IsSleepMode()); ui->SystemInformation_ResetCounter_SpinBox->setValue(msg.GetResetCounter()); ui->SystemInformation_SolarPanelsPowerInformation_SolarPanelXAVoltage_SpinBox->setValue(msg.GetSolarPanelXaVoltage()); ui->SystemInformation_SolarPanelsPowerInformation_SolarPanelXACurrent_SpinBox->setValue(msg.GetSolarPanelXaCurrent()); ui->SystemInformation_SolarPanelsPowerInformation_SolarPanelXBVoltage_SpinBox->setValue(msg.GetSolarPanelXbVoltage()); ui->SystemInformation_SolarPanelsPowerInformation_SolarPanelXBCurrent_SpinBox->setValue(msg.GetSolarPanelXbCurrent()); ui->SystemInformation_SolarPanelsPowerInformation_SolarPanelZAVoltage_SpinBox->setValue(msg.GetSolarPanelZaVoltage()); ui->SystemInformation_SolarPanelsPowerInformation_SolarPanelZACurrent_SpinBox->setValue(msg.GetSolarPanelZaCurrent()); ui->SystemInformation_SolarPanelsPowerInformation_SolarPanelZBVoltage_SpinBox->setValue(msg.GetSolarPanelZbVoltage()); ui->SystemInformation_SolarPanelsPowerInformation_SolarPanelZBCurrent_SpinBox->setValue(msg.GetSolarPanelZbCurrent()); ui->SystemInformation_SolarPanelsPowerInformation_SolarPanelYVoltage_SpinBox->setValue(msg.GetSolarPanelYVoltage()); ui->SystemInformation_SolarPanelsPowerInformation_SolarPanelYCurrent_SpinBox->setValue(msg.GetSolarPanelYCurrent()); ui->SystemInformation_TemperatureInformation_YPanelTemperature_DoubleSpinBox->setValue(msg.GetSolarPanelYTemperature()); ui->SystemInformation_TemperatureInformation_OBCBoardTemperature_DoubleSpinBox->setValue(msg.GetObcBoardTemperature()); ui->SystemInformation_TemperatureInformation_BottomBoardTemperature_DoubleSpinBox->setValue(msg.GetBottomBoardTemperature()); ui->SystemInformation_TemperatureInformation_BatteryTemperature_DoubleSpinBox->setValue(msg.GetBatteryTemperature()); ui->SystemInformation_TemperatureInformation_SecondBatteryTemperature_DoubleSpinBox->setValue(msg.GetSecondBatteryTemperature()); ui->SystemInformation_TemperatureInformation_MCUTemperature_DoubleSpinBox->setValue(msg.GetMcuTemperature()); ui->SystemInformation_Sensors_YPanelLightSensor_LineEdit->setText(QString::number(msg.GetYPanelLightSensor())); ui->SystemInformation_Sensors_TopBoardLightSensor_LineEdit->setText(QString::number(msg.GetTopBoardLightSensor())); ui->SystemInformation_LastHBridgeFaults_XAxisHBridgeFault_SpinBox->setValue(msg.GetLastXAxisHBridgeFault()); ui->SystemInformation_LastHBridgeFaults_YAxisHBridgeFault_SpinBox->setValue(msg.GetLastYAxisHBridgeFault()); ui->SystemInformation_LastHBridgeFaults_ZAxisHBridgeFault_SpinBox->setValue(msg.GetLastZAxisHBridgeFault()); ui->SystemInformation_FlashInformation_CRCError_SpinBox->setValue(msg.GetFlashSystemInfoPageCrcErrorCounter()); ui->SystemInformation_WindowReceiveLength_LoraWindowReceiveLength_SpinBox->setValue(msg.GetFskWindowReceiveLength()); ui->SystemInformation_WindowReceiveLength_LoraWindowReceiveLength_SpinBox->setValue(msg.GetLoraWindowReceiveLength()); ui->Systeminformation_Sensors_States_LightSensorTop_OK_RadioButton->setChecked(msg.IsLightSensorTop()); ui->Systeminformation_Sensors_States_LightSensorTop_FAIL_RadioButton->setChecked(!msg.IsLightSensorTop()); ui->Systeminformation_Sensors_States_LightSensorY_OK_RadioButton->setChecked(msg.IsLightSensorY()); ui->Systeminformation_Sensors_States_LightSensorY_FAIL_RadioButton->setChecked(!msg.IsLightSensorY()); ui->Systeminformation_Sensors_States_CurrentSensorMPPT_OK_RadioButton->setChecked(msg.IsCurrentSensorMppt()); ui->Systeminformation_Sensors_States_CurrentSensorMPPT_FAIL_RadioButton->setChecked(!msg.IsCurrentSensorMppt()); ui->Systeminformation_Sensors_States_CurrentSensorY_OK_RadioButton->setChecked(msg.IsCurrentSensorY()); ui->Systeminformation_Sensors_States_CurrentSensorY_FAIL_RadioButton->setChecked(!msg.IsCurrentSensorY()); ui->Systeminformation_Sensors_States_CurrentSensorZB_OK_RadioButton->setChecked(msg.IsCurrentSensorZb()); ui->Systeminformation_Sensors_States_CurrentSensorZB_FAIL_RadioButton->setChecked(!msg.IsCurrentSensorZb()); ui->Systeminformation_Sensors_States_CurrentSensorZA_OK_RadioButton->setChecked(msg.IsCurrentSensorZa()); ui->Systeminformation_Sensors_States_CurrentSensorZA_FAIL_RadioButton->setChecked(!msg.IsCurrentSensorZa()); ui->Systeminformation_Sensors_States_CurrentSensorXB_OK_RadioButton->setChecked(msg.IsCurrentSensorXb()); ui->Systeminformation_Sensors_States_CurrentSensorXB_FAIL_RadioButton->setChecked(!msg.IsCurrentSensorXb()); ui->Systeminformation_Sensors_States_CurrentSensorXA_OK_RadioButton->setChecked(msg.IsCurrentSensorXa()); ui->Systeminformation_Sensors_States_CurrentSensorXA_FAIL_RadioButton->setChecked(!msg.IsCurrentSensorXa()); ui->SystemInformation_ADCResult_LastADCSResult_LineEdit->setText(QString::number(msg.GetLastAdcsResult())); } void FOSSASAT2::MessageHandler::Handle(FOSSASAT2::Messages::DeploymentState msg, systeminformationpane* systemInfoPane) { Ui::systeminformationpane* ui = systemInfoPane->GetUI(); ui->SystemInformation_Deployment_Counter_SpinBox->setValue(msg.GetDeploymentCounter()); } void FOSSASAT2::MessageHandler::Handle(FOSSASAT2::Messages::RecordedIMU msg, systeminformationpane* systemInfoPane) { Ui::systeminformationpane* ui = systemInfoPane->GetUI(); ui->SystemInformation_IMUInformation_GryroX_DoubleSpinBox->setValue(msg.GetGyroX()); ui->SystemInformation_IMUInformation_GryroY_DoubleSpinBox->setValue(msg.GetGyroY()); ui->SystemInformation_IMUInformation_GryroZ_DoubleSpinBox->setValue(msg.GetGyroZ()); ui->SystemInformation_IMUInformation_AcceleX_DoubleSpinBox->setValue(msg.GetAcceleX()); ui->SystemInformation_IMUInformation_AcceleX_DoubleSpinBox->setValue(msg.GetAcceleY()); ui->SystemInformation_IMUInformation_AcceleX_DoubleSpinBox->setValue(msg.GetAcceleZ()); ui->SystemInformation_IMUInformation_MagX_DoubleSpinBox->setValue(msg.GetMagnX()); ui->SystemInformation_IMUInformation_MagY_DoubleSpinBox->setValue(msg.GetMagnY()); ui->SystemInformation_IMUInformation_MagZ_DoubleSpinBox->setValue(msg.GetMagnZ()); } void FOSSASAT2::MessageHandler::Handle(FOSSASAT2::Messages::GPSLogState msg, MainWindow* mainWindow) { Ui::MainWindow* ui = mainWindow->GetUI(); ui->GPSControl_GetGPSState_Length_LineEdit->setText(QString::number(msg.GetGpsLogLength())); ui->GPSControl_GetGPSState_LastEntryAddress_LineEdit->setText(QString::number(msg.GetLastNmeaEntryAddr())); ui->GPSControl_GetGPSState_LastFixAddress_LineEdit->setText(QString::number(msg.GetLastNmeaFixAddr())); } void FOSSASAT2::MessageHandler::Handle(FOSSASAT2::Messages::Acknowledge msg, MessageLogFrame* logFrame) { logFrame->RawWriteToLog("Command acknowledged"); }
59.607438
147
0.825511
FOSSASystems
73093e0a1e1b7be8e1f0ba7f223d308cbb3aa8f1
5,499
hpp
C++
Engine/Rendering/Renderer.hpp
seb776/Tricible
fb1b7c7e027231c158a1945d3568777c4092ca6d
[ "Apache-2.0" ]
2
2017-09-08T04:52:01.000Z
2018-10-13T14:30:52.000Z
Engine/Rendering/Renderer.hpp
seb776/Tricible
fb1b7c7e027231c158a1945d3568777c4092ca6d
[ "Apache-2.0" ]
2
2018-10-24T12:48:00.000Z
2018-11-02T16:15:21.000Z
Engine/Rendering/Renderer.hpp
seb776/Tricible
fb1b7c7e027231c158a1945d3568777c4092ca6d
[ "Apache-2.0" ]
1
2018-03-17T23:45:21.000Z
2018-03-17T23:45:21.000Z
#pragma once #include <iostream> #include <vector> #include <CL/cl2.hpp> #include "../Scene/IntersectionInfo.hpp" #include "../Scene/Sphere.hpp" #include "../Scene/Plane.hpp" #include "../Scene/Triangle.hpp" #include "../Scene/ALight.hpp" #include "../Scene/Scene.hpp" #include "../Scene/Camera.hpp" #include "../Tools/Tools.hpp" namespace Tricible { class Renderer { public: int *image; int _resX; int _resY; Scene::Scene *Scene; /* std::vector<AIntersectable *> _objects; std::vector<ALight *> _lights; Camera _camera;*/ public: Renderer(int resX, int resY, int bpp, Scene::Scene *scene) :Scene(scene) { _resX = resX; _resY = resY; image = new int[resX * resY]; } void GetAvaialableHardware() { std::vector<cl::Platform> platforms; cl::Platform::get(&platforms); int platform_id = 0; int device_id = 0; std::cout << "Number of Platforms: " << platforms.size() << std::endl; for (std::vector<cl::Platform>::iterator it = platforms.begin(); it != platforms.end(); ++it) { cl::Platform platform(*it); std::cout << "Platform ID: " << platform_id++ << std::endl; std::cout << "Platform Name: " << platform.getInfo<CL_PLATFORM_NAME>() << std::endl; std::cout << "Platform Vendor: " << platform.getInfo<CL_PLATFORM_VENDOR>() << std::endl; std::vector<cl::Device> devices; platform.getDevices(CL_DEVICE_TYPE_GPU | CL_DEVICE_TYPE_CPU, &devices); for (std::vector<cl::Device>::iterator it2 = devices.begin(); it2 != devices.end(); ++it2) { cl::Device device(*it2); std::cout << "\tDevice " << device_id++ << ": " << std::endl; std::cout << "\t\tDevice Name: " << device.getInfo<CL_DEVICE_NAME>() << std::endl; std::cout << "\t\tDevice Type: " << device.getInfo<CL_DEVICE_TYPE>(); std::cout << " (GPU: " << CL_DEVICE_TYPE_GPU << ", CPU: " << CL_DEVICE_TYPE_CPU << ")" << std::endl; std::cout << "\t\tDevice Vendor: " << device.getInfo<CL_DEVICE_VENDOR>() << std::endl; std::cout << "\t\tDevice Max Compute Units: " << device.getInfo<CL_DEVICE_MAX_COMPUTE_UNITS>() << std::endl; std::cout << "\t\tDevice Global Memory: " << device.getInfo<CL_DEVICE_GLOBAL_MEM_SIZE>() << std::endl; std::cout << "\t\tDevice Max Clock Frequency: " << device.getInfo<CL_DEVICE_MAX_CLOCK_FREQUENCY>() << std::endl; std::cout << "\t\tDevice Max Allocateable Memory: " << device.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>() << std::endl; std::cout << "\t\tDevice Local Memory: " << device.getInfo<CL_DEVICE_LOCAL_MEM_SIZE>() << std::endl; std::cout << "\t\tDevice Available: " << device.getInfo< CL_DEVICE_AVAILABLE>() << std::endl; } std::cout << std::endl; } } Color::RGB RenderNormalizedVecAsNormal(const Point3& vecToVisualizeAsCol, const IntersectionInfo& interInfo) { return Color::RGB((vecToVisualizeAsCol._x * 0.5f + 0.5f) * 255.0f, (vecToVisualizeAsCol._y * 0.5f + 0.5f) * 255.0f, (vecToVisualizeAsCol._z * 0.5f + 0.5f) * 255.0f); } Color::RGB RenderFloatLessThreshold(float value, float threshold) { return Color::RGB((value < threshold ? 255U : 0U), 0U, 0U); } Color::RGB RenderFloatGreaterThreshold(float value, float threshold) { return Color::RGB((value > threshold ? 255U : 0U), 0U, 0U); } Color::RGB RenderDepth(float value, float distMax) { // displays depth uint8_t colDist = Clamp((int32_t)(255 * (1.0f - Clamp01(value / distMax))), 0, 255); return Color::RGB(colDist, colDist, colDist); } Color::RGB RenderPixel(const Point3& pixelVec, const IntersectionInfo& interInfo) { Color::RGB finalColor; Color::RGB diffuseColor; if (interInfo.Object != nullptr) { Point3 normal = Point3(1.0, 1.0, 1.0); interInfo.Object->ComputeNormal(interInfo, normal); // Texture / material lookup if (interInfo.Primitive->Material != nullptr) { diffuseColor = interInfo.Primitive->Material->DiffuseColor; } else { diffuseColor = this->Scene->DefaultDiffuseMaterial.DiffuseColor; } for (ALight *l : Scene->Lights) { Point3 tmp = (l->getPosition() - interInfo.Intersection); tmp.Normalize(); const float mult = Clamp01(tmp.Dot(normal)); if (mult > 0.f) { Color::RGB currentColor = diffuseColor *mult * l->intensity; finalColor += currentColor; } } } else { if (Scene->Skymap != nullptr) { Point3 normVec = pixelVec.Normalize(); auto uvw = Scene::Sphere::ComputeUV(normVec); finalColor = Scene->Skymap->Get360Pixel(uvw._x, uvw._y); //finalColor = Scene->Skymap->Get360PixelBilinearInterpolation(uvw._x, uvw._y); } else { finalColor = Scene->BackgroundColor; } } return finalColor; } void Render() { auto& camera = *Scene->CurrentCamera; for (int y = 0; y < _resY; ++y) { for (int x = 0; x < _resX; ++x) { Point3 vec; camera.GetRay(x - (_resX * .5f), y - (_resY * .5f), vec); vec.Normalize(); Color::RGB finalColor = Color::RGB(); float nearestDist = -1.f; // IntersectionInfo *retainedInter; Point3 normVec = vec; normVec.Normalize(); IntersectionInfo interInfo = IntersectionInfo(); Scene->IntersectsRay(camera.getPosition() + vec, vec, &interInfo, camera.NearClip, camera.FarClip); finalColor = RenderPixel(normVec, interInfo); //finalColor = RenderDepth(interInfo.Distance, 100.0f); image[x + y * _resX] = finalColor.ToInt(); } } } }; }
31.786127
168
0.635025
seb776
730c7cda6ba4a143dc80e99a7e5e12f5523ef53e
1,165
cpp
C++
Ejercicios/Ejercicio44_punto_de_Venta_parte5/Factura.cpp
Maldanar201/LenguajeProgramacion1
5a53c51077c0e41deff8daf40dbe6f0778b41f9c
[ "MIT" ]
null
null
null
Ejercicios/Ejercicio44_punto_de_Venta_parte5/Factura.cpp
Maldanar201/LenguajeProgramacion1
5a53c51077c0e41deff8daf40dbe6f0778b41f9c
[ "MIT" ]
null
null
null
Ejercicios/Ejercicio44_punto_de_Venta_parte5/Factura.cpp
Maldanar201/LenguajeProgramacion1
5a53c51077c0e41deff8daf40dbe6f0778b41f9c
[ "MIT" ]
null
null
null
#include <iostream> using namespace std; double subtotal = 0; string listaProductos; void agregarProducto(string descripcion, int cantidad, double precio) { listaProductos = listaProductos + descripcion + '\n'; subtotal = subtotal + (cantidad * precio); } void imprimirFactura() { //datos de entrada double total = 0, impuesto = 0.15, Monto_impuesto = 0, Calculo_Descuento = 0; int descuento = 0; cout << " ## FACTURA ## " << endl; cout << " ================== " << endl; cout << "\n Ingrese el Monto de descuento (0, 10, 15, 20)"; cin >> descuento; //Proceso Calculo_Descuento = (subtotal * descuento) / 100; Monto_impuesto = (subtotal - descuento) * 0.15; total = subtotal - Calculo_Descuento + Monto_impuesto; //salida cout << " Productos " << endl; cout << listaProductos << endl; cout <<"\n El subtotal es : "<< subtotal << endl; cout <<" Monto de descuento es : "<<Calculo_Descuento<< endl; cout <<" Valor Impuesto es : "<< Monto_impuesto << endl; cout <<" Total a pagar es : "<< total << endl; cout<<endl; system("Pause"); }
27.093023
79
0.593133
Maldanar201
730ee948419c510cd5a0b075b38277b171c9b6ad
1,136
cpp
C++
array/238.product-of-array-except-self.0.cpp
yeweili94/leetcode
900fd11795f760e3d1d646f1f63887d4d22eb46e
[ "MIT" ]
null
null
null
array/238.product-of-array-except-self.0.cpp
yeweili94/leetcode
900fd11795f760e3d1d646f1f63887d4d22eb46e
[ "MIT" ]
null
null
null
array/238.product-of-array-except-self.0.cpp
yeweili94/leetcode
900fd11795f760e3d1d646f1f63887d4d22eb46e
[ "MIT" ]
null
null
null
/* * [238] Product of Array Except Self * * https://leetcode.com/problems/product-of-array-except-self/description/ * * algorithms * Medium (51.44%) * Total Accepted: 174.5K * Total Submissions: 339.1K * Testcase Example: '[1,2,3,4]' * * Given an array nums of n integers where n > 1,  return an array output such * that output[i] is equal to the product of all the elements of nums except * nums[i]. * * Example: * * * Input: [1,2,3,4] * Output: [24,12,8,6] * * * Note: Please solve it without division and in O(n). * * Follow up: * Could you solve it with constant space complexity? (The output array does * not count as extra space for the purpose of space complexity analysis.) * */ class Solution { public: vector<int> productExceptSelf(vector<int>& nums) { int size = nums.size(); vector<int> ret(size, 1); int right = 1; for (int i = 1; i < size; i++) { ret[i] = ret[i-1] * nums[i-1]; } for (int i = size - 2; i >= 0; i--) { right *= nums[i+1]; ret[i] *= right; } return ret; } };
24.695652
78
0.571303
yeweili94
731078e3cca09de9b7f2a58853daab638030ecf5
1,858
hpp
C++
configuration/configmgr/configmgrlib/mod_template_support/Variables.hpp
jeclrsg/HPCC-Platform
c1daafb6060f0c47c95bce98e5431fedc33c592d
[ "Apache-2.0" ]
286
2015-01-03T12:45:17.000Z
2022-03-25T18:12:57.000Z
configuration/configmgr/configmgrlib/mod_template_support/Variables.hpp
jeclrsg/HPCC-Platform
c1daafb6060f0c47c95bce98e5431fedc33c592d
[ "Apache-2.0" ]
9,034
2015-01-02T08:49:19.000Z
2022-03-31T20:34:44.000Z
configuration/configmgr/configmgrlib/mod_template_support/Variables.hpp
cloLN/HPCC-Platform
42ffb763a1cdcf611d3900831973d0a68e722bbe
[ "Apache-2.0" ]
208
2015-01-02T03:27:28.000Z
2022-02-11T05:54:52.000Z
/*############################################################################## HPCC SYSTEMS software Copyright (C) 2018 HPCC Systems®. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ############################################################################## */ #ifndef HPCCSYSTEMS_PLATFORM_INPUTS_HPP #define HPCCSYSTEMS_PLATFORM_INPUTS_HPP #include <string> #include <vector> #include <memory> class Variable; class Variables { public: Variables() = default; ~Variables() = default; void add(const std::shared_ptr<Variable> pVariable); const std::vector<std::shared_ptr<Variable>> &all() const { return m_variables; } std::shared_ptr<Variable> getVariable(const std::string &name, bool throwIfNotFound = true) const; void setInputIndex(size_t idx) { m_curIndex = idx; } std::string doValueSubstitution(const std::string &value) const; void prepare(); void clear(); protected: std::string evaluate(const std::string &expr) const; std::size_t findClosingDelimiter(const std::string &input, std::size_t startPos, const std::string &openDelim, const std::string &closeDelim) const; private: std::vector<std::shared_ptr<Variable>> m_variables; size_t m_curIndex = 0; }; #endif //HPCCSYSTEMS_PLATFORM_INPUTS_HPP
32.596491
156
0.643703
jeclrsg
73154f1463dc0e95144524ce5ad3fa010e1f17b4
400
cpp
C++
02_Practice/Ch10/practice10-13.cpp
khsexk/OOP_by_cpp
803b7f69a0514fc058d20c58ebb2c11bffa66ed0
[ "MIT" ]
null
null
null
02_Practice/Ch10/practice10-13.cpp
khsexk/OOP_by_cpp
803b7f69a0514fc058d20c58ebb2c11bffa66ed0
[ "MIT" ]
null
null
null
02_Practice/Ch10/practice10-13.cpp
khsexk/OOP_by_cpp
803b7f69a0514fc058d20c58ebb2c11bffa66ed0
[ "MIT" ]
null
null
null
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { vector<int> v; cout << "5개의 정수를 입력하세요>> "; for(int i=0 ; i<5 ; i++){ int n; cin >> n; v.push_back(n); } sort(v.begin(), v.end()); vector<int>::iterator it; for(it=v.begin() ; it != v.end() ; it++){ cout << *it << ' '; } cout << endl; }
17.391304
45
0.4725
khsexk
73155ef1a3d923f3e1c6786163620d38f320d553
5,239
cpp
C++
earth_enterprise/src/server/mod_fdb/unpackermanager.cpp
seamusdunlop123/earthenterprise
a2651b1c00dd6230fd5d3d47502d228dbfca0f63
[ "Apache-2.0" ]
1
2019-09-03T06:08:04.000Z
2019-09-03T06:08:04.000Z
earth_enterprise/src/server/mod_fdb/unpackermanager.cpp
seamusdunlop123/earthenterprise
a2651b1c00dd6230fd5d3d47502d228dbfca0f63
[ "Apache-2.0" ]
null
null
null
earth_enterprise/src/server/mod_fdb/unpackermanager.cpp
seamusdunlop123/earthenterprise
a2651b1c00dd6230fd5d3d47502d228dbfca0f63
[ "Apache-2.0" ]
null
null
null
// Copyright 2017 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "server/mod_fdb/unpackermanager.h" #include <map> #include <string> #include <utility> #include "common/geFilePool.h" #include "common/khTypes.h" #include "fusion/portableglobe/servers/fileunpacker/shared/glc_reader.h" #include "fusion/portableglobe/servers/fileunpacker/shared/glc_unpacker.h" #include "server/mod_fdb/apache_fdb_reader.h" #ifdef APLOG_USE_MODULE APLOG_USE_MODULE(fdb); #endif UnpackerManager::UnpackerManager() : file_pool_(-50) { } UnpackerManager::~UnpackerManager() { Reset(); } // Gets glx to targets map of all portables with an associated unpacker. // Used for checking the status of the UnpackerManager. void UnpackerManager::GetPortableToTargetsMap( std::map<std::string, std::vector<std::string> >* portable_to_targets) const { portable_to_targets->clear(); khLockGuard lock(mutex); TargetToPortableMap::const_iterator it = target_to_portable_map_.begin(); for (; it != target_to_portable_map_.end(); ++it) { (*portable_to_targets)[it->second].push_back(it->first); } } // Unregisters portable for serving on specified target path. // Deletes Reader/Unpacker and clears glx from set of registered portables // for specific target path. bool UnpackerManager::UnregisterPortable(const std::string& target_path) { khLockGuard lock(mutex); TargetToPortableMap::iterator it_portable = target_to_portable_map_.find(target_path); if (it_portable != target_to_portable_map_.end()) { // Unregister database. target_to_portable_map_.erase(it_portable); // Delete Reader/Unpacker. TargetToUnpackerMap::iterator it_unpacker = target_to_unpacker_map_.find(target_path); if (it_unpacker != target_to_unpacker_map_.end()) { if (it_unpacker->second.first) { delete it_unpacker->second.first; } if (it_unpacker->second.second) { delete it_unpacker->second.second; } target_to_unpacker_map_.erase(it_unpacker); } return true; } return false; } // Registers glx for serving. void UnpackerManager::RegisterPortable( const std::string& target_path, const std::string& globe_path, request_rec* r) { if (UnregisterPortable(target_path)) { // Warning because normal use of API requires unpublishing before // publishing to the same target path. ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, "Existing glx for target path %s have been unregistered.", target_path.c_str()); } khLockGuard lock(mutex); // Register glx for serving. target_to_portable_map_[target_path] = globe_path; } // Gets Reader/Unpacker for the given target if glx is registered // for serving. // Note: Creates reader/unpacker if they don't exist. UnpackerPair UnpackerManager::GetUnpacker(const std::string& target_path) { khLockGuard lock(mutex); // Check if unpacker already exists and return it. TargetToUnpackerMap::iterator it_unpacker = target_to_unpacker_map_.find(target_path); if (it_unpacker != target_to_unpacker_map_.end()) return it_unpacker->second; // Create unpacker if target path is registered for serving. TargetToPortableMap::const_iterator it_data = target_to_portable_map_.find(target_path); if (it_data != target_to_portable_map_.end()) return CreateUnpacker(target_path, it_data->second); // Target path is not registered for serving. return UnpackerPair(NULL, NULL); } // Resets manager: deletes all readers/unpackers and cleans internal structures. void UnpackerManager::Reset() { khLockGuard lock(mutex); TargetToUnpackerMap::iterator it = target_to_unpacker_map_.begin(); for (; it != target_to_unpacker_map_.end(); ++it) { // Delete reader and unpacker instances. if (it->second.first) { delete it->second.first; } if (it->second.second) { delete it->second.second; } it->second.first = 0; it->second.second = 0; } target_to_unpacker_map_.clear(); target_to_portable_map_.clear(); } // Creates a new reader/unpacker for specified target path and glx. UnpackerPair UnpackerManager::CreateUnpacker( const std::string& target_path, const std::string& globe_path) { // Create unpacker pair. ApacheFdbReader* reader = new ApacheFdbReader(globe_path, file_pool_); std::string suffix = globe_path.substr(globe_path.size() - 3); GlcUnpacker* unpacker = new GlcUnpacker(*reader, suffix == "glc"); UnpackerPair pair(reader, unpacker); std::pair<TargetToUnpackerMap::iterator, bool> ret = target_to_unpacker_map_.insert(TargetToUnpackerMap::value_type( target_path, pair)); assert(ret.second); return pair; }
34.24183
80
0.730292
seamusdunlop123
731628dd670593a284b13b9c50278195008c997e
1,290
cpp
C++
pgadmin/hotdraw/figures/hdRectangleFigure.cpp
jinfroster/pgadmin3
8d573a7f13a8b4161225363f1972d75004589275
[ "PostgreSQL" ]
null
null
null
pgadmin/hotdraw/figures/hdRectangleFigure.cpp
jinfroster/pgadmin3
8d573a7f13a8b4161225363f1972d75004589275
[ "PostgreSQL" ]
null
null
null
pgadmin/hotdraw/figures/hdRectangleFigure.cpp
jinfroster/pgadmin3
8d573a7f13a8b4161225363f1972d75004589275
[ "PostgreSQL" ]
null
null
null
////////////////////////////////////////////////////////////////////////// // // pgAdmin III - PostgreSQL Tools // // Copyright (C) 2002 - 2014, The pgAdmin Development Team // This software is released under the PostgreSQL Licence // // hdRectangleFigure.cpp - A simple rectangle figure // ////////////////////////////////////////////////////////////////////////// #include "pgAdmin3.h" // wxWindows headers #include <wx/wx.h> #include <wx/dcbuffer.h> // App headers #include "hotdraw/figures/hdRectangleFigure.h" #include "hotdraw/main/hdDrawingView.h" hdRectangleFigure::hdRectangleFigure() { } hdRectangleFigure::~hdRectangleFigure() { } void hdRectangleFigure::basicDraw(wxBufferedDC &context, hdDrawingView *view) { hdRect copy = displayBox().gethdRect(view->getIdx()); view->CalcScrolledPosition(copy.x, copy.y, &copy.x, &copy.y); context.DrawRectangle(copy); } void hdRectangleFigure::basicDrawSelected(wxBufferedDC &context, hdDrawingView *view) { hdRect copy = displayBox().gethdRect(view->getIdx()); view->CalcScrolledPosition(copy.x, copy.y, &copy.x, &copy.y); context.DrawRectangle(copy); } void hdRectangleFigure::setRectangle(hdMultiPosRect &rect) { basicDisplayBox = rect; } void hdRectangleFigure::setSize(wxSize &size) { basicDisplayBox.SetSize(size); }
24.339623
85
0.663566
jinfroster
731663b535b4f9e317f23296c5d978eeb59d870d
26,219
cpp
C++
Plugins/Area/Area.cpp
GideonCrawle/unified
2a310e0012badfcc9675bd8c8554613b5354e21a
[ "MIT" ]
null
null
null
Plugins/Area/Area.cpp
GideonCrawle/unified
2a310e0012badfcc9675bd8c8554613b5354e21a
[ "MIT" ]
null
null
null
Plugins/Area/Area.cpp
GideonCrawle/unified
2a310e0012badfcc9675bd8c8554613b5354e21a
[ "MIT" ]
null
null
null
#include "Area.hpp" #include "API/CAppManager.hpp" #include "API/CServerExoApp.hpp" #include "API/CNWSModule.hpp" #include "API/CNWSTrigger.hpp" #include "API/CNWSTile.hpp" #include "API/CNWTileData.hpp" #include "API/CNWSAmbientSound.hpp" #include "API/CResStruct.hpp" #include "API/CNWSCreature.hpp" #include "API/CNWSCreatureStats.hpp" #include "API/Constants.hpp" #include "API/Globals.hpp" using namespace NWNXLib; using namespace NWNXLib::API; static Area::Area* g_plugin; NWNX_PLUGIN_ENTRY Plugin* PluginLoad(Services::ProxyServiceList* services) { g_plugin = new Area::Area(services); return g_plugin; } namespace Area { Area::Area(Services::ProxyServiceList* services) : Plugin(services) { #define REGISTER(func) \ GetServices()->m_events->RegisterEvent(#func, \ [this](ArgumentStack&& args){ return func(std::move(args)); }) REGISTER(GetNumberOfPlayersInArea); REGISTER(GetLastEntered); REGISTER(GetLastLeft); REGISTER(GetPVPSetting); REGISTER(SetPVPSetting); REGISTER(GetAreaSpotModifier); REGISTER(SetAreaSpotModifier); REGISTER(GetAreaListenModifier); REGISTER(SetAreaListenModifier); REGISTER(GetNoRestingAllowed); REGISTER(SetNoRestingAllowed); REGISTER(GetWindPower); REGISTER(SetWindPower); REGISTER(GetWeatherChance); REGISTER(SetWeatherChance); REGISTER(GetFogClipDistance); REGISTER(SetFogClipDistance); REGISTER(GetShadowOpacity); REGISTER(SetShadowOpacity); REGISTER(GetDayNightCycle); REGISTER(SetDayNightCycle); REGISTER(GetSunMoonColors); REGISTER(SetSunMoonColors); REGISTER(CreateTransition); REGISTER(GetTileAnimationLoop); REGISTER(SetTileAnimationLoop); REGISTER(GetTileModelResRef); REGISTER(TestDirectLine); REGISTER(GetMusicIsPlaying); REGISTER(CreateGenericTrigger); REGISTER(AddObjectToExclusionList); REGISTER(RemoveObjectFromExclusionList); REGISTER(ExportGIT); #undef REGISTER } Area::~Area() { } CNWSArea *Area::area(ArgumentStack& args) { const auto areaId = Services::Events::ExtractArgument<ObjectID>(args); if (areaId == Constants::OBJECT_INVALID) { LOG_NOTICE("NWNX_Area function called on OBJECT_INVALID"); return nullptr; } auto *pArea = Globals::AppManager()->m_pServerExoApp->GetAreaByGameObjectID(areaId); if (!pArea) { LOG_NOTICE("NWNX_Area function called on non-area object %x", areaId); } return pArea; } ArgumentStack Area::GetNumberOfPlayersInArea(ArgumentStack&& args) { int32_t retVal = 0; if (auto *pArea = area(args)) { retVal = pArea->m_nPlayersInArea; } return Services::Events::Arguments(retVal); } ArgumentStack Area::GetLastEntered(ArgumentStack&& args) { ObjectID retVal = Constants::OBJECT_INVALID; if (auto *pArea = area(args)) { retVal = static_cast<ObjectID>(pArea->m_oidLastEntered); } return Services::Events::Arguments(retVal); } ArgumentStack Area::GetLastLeft(ArgumentStack&& args) { ObjectID retVal = Constants::OBJECT_INVALID; if (auto *pArea = area(args)) { retVal = static_cast<ObjectID>(pArea->m_oidLastLeft); } return Services::Events::Arguments(retVal); } ArgumentStack Area::GetPVPSetting(ArgumentStack&& args) { int32_t retVal = 0; if (auto *pArea = area(args)) { retVal = pArea->m_nPVPSetting; } return Services::Events::Arguments(retVal); } ArgumentStack Area::SetPVPSetting(ArgumentStack&& args) { if (auto *pArea = area(args)) { auto pvpSetting = Services::Events::ExtractArgument<int32_t>(args); ASSERT_OR_THROW(pvpSetting >= Constants::PvPSetting::MIN); ASSERT_OR_THROW(pvpSetting <= Constants::PvPSetting::MAX); pArea->m_nPVPSetting = pvpSetting; } return Services::Events::Arguments(); } ArgumentStack Area::GetAreaSpotModifier(ArgumentStack&& args) { int32_t retVal = 0; if (auto *pArea = area(args)) { retVal = pArea->m_nAreaSpotModifier; } return Services::Events::Arguments(retVal); } ArgumentStack Area::SetAreaSpotModifier(ArgumentStack&& args) { if (auto *pArea = area(args)) { const auto spotModifier = Services::Events::ExtractArgument<int32_t>(args); pArea->m_nAreaSpotModifier = spotModifier; } return Services::Events::Arguments(); } ArgumentStack Area::GetAreaListenModifier(ArgumentStack&& args) { int32_t retVal = 0; if (auto *pArea = area(args)) { retVal = pArea->m_nAreaListenModifier; } return Services::Events::Arguments(retVal); } ArgumentStack Area::SetAreaListenModifier(ArgumentStack&& args) { if (auto *pArea = area(args)) { const auto listenModifier = Services::Events::ExtractArgument<int32_t>(args); pArea->m_nAreaListenModifier = listenModifier; } return Services::Events::Arguments(); } ArgumentStack Area::GetNoRestingAllowed(ArgumentStack&& args) { int32_t retVal = 0; if (auto *pArea = area(args)) { retVal = pArea->m_bNoRestingAllowed; } return Services::Events::Arguments(retVal); } ArgumentStack Area::SetNoRestingAllowed(ArgumentStack&& args) { if (auto *pArea = area(args)) { const auto noRestingAllowed = Services::Events::ExtractArgument<int32_t>(args); pArea->m_bNoRestingAllowed = !!noRestingAllowed; } return Services::Events::Arguments(); } ArgumentStack Area::GetWindPower(ArgumentStack&& args) { int32_t retVal = 0; if (auto *pArea = area(args)) { retVal = pArea->m_nWindAmount; } return Services::Events::Arguments(retVal); } ArgumentStack Area::SetWindPower(ArgumentStack&& args) { if (auto *pArea = area(args)) { auto windPower = Services::Events::ExtractArgument<int32_t>(args); ASSERT_OR_THROW(windPower >= 0); ASSERT_OR_THROW(windPower <= 2); pArea->m_nWindAmount = windPower; } return Services::Events::Arguments(); } ArgumentStack Area::GetWeatherChance(ArgumentStack&& args) { int32_t retVal = 0; if (auto *pArea = area(args)) { const auto type = Services::Events::ExtractArgument<int32_t>(args); switch (type) { case 0: retVal = pArea->m_nChanceOfRain; break; case 1: retVal = pArea->m_nChanceOfSnow; break; case 2: retVal = pArea->m_nChanceOfLightning; break; default: retVal = 0; break; } } return Services::Events::Arguments(retVal); } ArgumentStack Area::SetWeatherChance(ArgumentStack&& args) { if (auto *pArea = area(args)) { const auto type = Services::Events::ExtractArgument<int32_t>(args); auto chance = Services::Events::ExtractArgument<int32_t>(args); ASSERT_OR_THROW(chance >= 0); ASSERT_OR_THROW(chance <= 100); switch (type) { case 0: pArea->m_nChanceOfRain = chance; break; case 1: pArea->m_nChanceOfSnow = chance; break; case 2: pArea->m_nChanceOfLightning = chance; break; default: break; } } return Services::Events::Arguments(); } ArgumentStack Area::GetFogClipDistance(ArgumentStack&& args) { float retVal = 0.0; if (auto *pArea = area(args)) { retVal = pArea->m_fFogClipDistance; } return Services::Events::Arguments(retVal); } ArgumentStack Area::SetFogClipDistance(ArgumentStack&& args) { if (auto *pArea = area(args)) { auto distance = Services::Events::ExtractArgument<float>(args); ASSERT_OR_THROW(distance >= 0.0); pArea->m_fFogClipDistance = distance; } return Services::Events::Arguments(); } ArgumentStack Area::GetShadowOpacity(ArgumentStack&& args) { int32_t retVal = 0; if (auto *pArea = area(args)) { retVal = pArea->m_nShadowOpacity; } return Services::Events::Arguments(retVal); } ArgumentStack Area::SetShadowOpacity(ArgumentStack&& args) { if (auto *pArea = area(args)) { auto shadowOpacity = Services::Events::ExtractArgument<int32_t>(args); ASSERT_OR_THROW(shadowOpacity >= 0); ASSERT_OR_THROW(shadowOpacity <= 100); pArea->m_nShadowOpacity = shadowOpacity; } return Services::Events::Arguments(); } ArgumentStack Area::GetDayNightCycle(ArgumentStack&& args) { int32_t retVal = 0; if (auto *pArea = area(args)) { if (pArea->m_bUseDayNightCycle) { retVal = 0; } else { retVal = pArea->m_bIsNight + 1; } } return Services::Events::Arguments(retVal); } ArgumentStack Area::SetDayNightCycle(ArgumentStack&& args) { if (auto *pArea = area(args)) { const auto type = Services::Events::ExtractArgument<int32_t>(args); switch (type) { case 0: pArea->m_bUseDayNightCycle = 1; pArea->m_bIsNight = 0; break; case 1: pArea->m_bUseDayNightCycle = 0; pArea->m_bIsNight = 0; break; case 2: pArea->m_bUseDayNightCycle = 0; pArea->m_bIsNight = 1; break; default: break; } } return Services::Events::Arguments(); } ArgumentStack Area::GetSunMoonColors(ArgumentStack&& args) { int32_t retVal = -1; if (auto *pArea = area(args)) { auto type = Services::Events::ExtractArgument<int32_t>(args); ASSERT_OR_THROW(type >= 0); ASSERT_OR_THROW(type <= 3); switch (type) { case 0: retVal = pArea->m_nMoonAmbientColor; break; case 1: retVal = pArea->m_nMoonDiffuseColor; break; case 2: retVal = pArea->m_nSunAmbientColor; break; case 3: retVal = pArea->m_nSunDiffuseColor; break; default: break; } } return Services::Events::Arguments(retVal); } ArgumentStack Area::SetSunMoonColors(ArgumentStack&& args) { if (auto *pArea = area(args)) { auto type = Services::Events::ExtractArgument<int32_t>(args); ASSERT_OR_THROW(type >= 0); ASSERT_OR_THROW(type <= 3); auto color = Services::Events::ExtractArgument<int32_t>(args); ASSERT_OR_THROW(color >= 0); // Switch from RGB to BGR auto swappedColor = (uint32_t)(((color & 0x000000FF) << 16) | (color & 0x0000FF00) | ((color & 0x00FF0000) >> 16)); switch (type) { case 0: pArea->m_nMoonAmbientColor = swappedColor; break; case 1: pArea->m_nMoonDiffuseColor = swappedColor; break; case 2: pArea->m_nSunAmbientColor = swappedColor; break; case 3: pArea->m_nSunDiffuseColor = swappedColor; break; default: break; } } return Services::Events::Arguments(); } ArgumentStack Area::CreateTransition(ArgumentStack&& args) { ObjectID retVal = Constants::OBJECT_INVALID; if (auto *pArea = area(args)) { auto targetOid = Services::Events::ExtractArgument<ObjectID>(args); auto *pTargetObject = Utils::AsNWSObject(Globals::AppManager()->m_pServerExoApp->GetGameObject(targetOid)); if (pTargetObject == nullptr || (pTargetObject->m_nObjectType != Constants::ObjectType::Door && pTargetObject->m_nObjectType != Constants::ObjectType::Waypoint)) { LOG_ERROR("Transition destination object is not valid. Valid targets are doors or waypoints."); return Services::Events::Arguments(retVal); } Vector vTransitionPosition; vTransitionPosition.x = Services::Events::ExtractArgument<float>(args); ASSERT_OR_THROW(vTransitionPosition.x >= 0.0f); ASSERT_OR_THROW(vTransitionPosition.x < pArea->m_nWidth * 10.0f); vTransitionPosition.y = Services::Events::ExtractArgument<float>(args); ASSERT_OR_THROW(vTransitionPosition.y >= 0.0f); ASSERT_OR_THROW(vTransitionPosition.y < pArea->m_nHeight * 10.0f); vTransitionPosition.z = Services::Events::ExtractArgument<float>(args); const auto size = Services::Events::ExtractArgument<float>(args); ASSERT_OR_THROW(size > 0.0f); ASSERT_OR_THROW(vTransitionPosition.x + size < pArea->m_nWidth * 10.0f); ASSERT_OR_THROW(vTransitionPosition.y + size < pArea->m_nHeight * 10.0f); // Create our trigger auto *trigger = new CNWSTrigger(API::Constants::OBJECT_INVALID); trigger->LoadFromTemplate(CResRef("newtransition")); // Stock nwn Area Transition resRef trigger->SetPosition(vTransitionPosition, 0); trigger->CreateNewGeometry(size, vTransitionPosition, pArea); // Set its tag if supplied const auto tag = Services::Events::ExtractArgument<std::string>(args); if (!tag.empty()) { trigger->m_sTag = CExoString(tag.c_str()); Utils::GetModule()->AddObjectToLookupTable(trigger->m_sTag, trigger->m_idSelf); } // Create and assign our transition to the trigger auto *transition = new CNWSTransition(); transition->SetTarget(pTargetObject); trigger->m_pTransition = *transition; // And add to area trigger->AddToArea(pArea, vTransitionPosition.x, vTransitionPosition.y, vTransitionPosition.z, false); retVal = trigger->m_idSelf; } return Services::Events::Arguments(retVal); } ArgumentStack Area::GetTileAnimationLoop(ArgumentStack&& args) { int32_t retVal = -1; if (auto *pArea = area(args)) { const auto tileX = Services::Events::ExtractArgument<float>(args); ASSERT_OR_THROW(tileX >= 0.0f); const auto tileY = Services::Events::ExtractArgument<float>(args); ASSERT_OR_THROW(tileY >= 0.0f); const auto tileAnimLoop = Services::Events::ExtractArgument<int32_t>(args); ASSERT_OR_THROW(tileAnimLoop >= 1); ASSERT_OR_THROW(tileAnimLoop <= 3); if (auto *pTile = pArea->GetTile({tileX, tileY, 0.0f})) { switch(tileAnimLoop) { case 1: retVal = pTile->m_nAnimLoop1; break; case 2: retVal = pTile->m_nAnimLoop2; break; case 3: retVal = pTile->m_nAnimLoop3; break; default: break; } } else { LOG_ERROR("NWNX_Area_GetTileAnimationLoop: invalid tile specified"); } } return Services::Events::Arguments(retVal); } ArgumentStack Area::SetTileAnimationLoop(ArgumentStack&& args) { if (auto *pArea = area(args)) { const auto tileX = Services::Events::ExtractArgument<float>(args); ASSERT_OR_THROW(tileX >= 0.0f); const auto tileY = Services::Events::ExtractArgument<float>(args); ASSERT_OR_THROW(tileY >= 0.0f); const auto tileAnimLoop = Services::Events::ExtractArgument<int32_t>(args); ASSERT_OR_THROW(tileAnimLoop >= 1); ASSERT_OR_THROW(tileAnimLoop <= 3); const auto tileEnabled = !!Services::Events::ExtractArgument<int32_t>(args); if (auto *pTile = pArea->GetTile({tileX, tileY, 0.0f})) { switch(tileAnimLoop) { case 1: pTile->m_nAnimLoop1 = tileEnabled; break; case 2: pTile->m_nAnimLoop2 = tileEnabled; break; case 3: pTile->m_nAnimLoop3 = tileEnabled; break; default: break; } } else { LOG_ERROR("NWNX_Area_SetTileAnimationLoop: invalid tile specified"); } } return Services::Events::Arguments(); } ArgumentStack Area::GetTileModelResRef(ArgumentStack&& args) { std::string retVal = ""; if (auto* pArea = area(args)) { const auto tileX = Services::Events::ExtractArgument<float>(args); ASSERT_OR_THROW(tileX >= 0.0f); const auto tileY = Services::Events::ExtractArgument<float>(args); ASSERT_OR_THROW(tileY >= 0.0f); if (auto *pTile = pArea->GetTile({tileX, tileY, 0.0f})) { retVal = pTile->m_pTileData->GetModelResRef().GetResRefStr(); } else { LOG_ERROR("NWNX_Area_GetTileModelResRef: invalid tile specified"); } } return Services::Events::Arguments(retVal); } ArgumentStack Area::TestDirectLine(ArgumentStack&& args) { int32_t retVal = false; if (auto *pArea = area(args)) { const auto fStartX = Services::Events::ExtractArgument<float>(args); ASSERT_OR_THROW(fStartX >= 0.0f); const auto fStartY = Services::Events::ExtractArgument<float>(args); ASSERT_OR_THROW(fStartY >= 0.0f); const auto fEndX = Services::Events::ExtractArgument<float>(args); ASSERT_OR_THROW(fEndX >= 0.0f); const auto fEndY = Services::Events::ExtractArgument<float>(args); ASSERT_OR_THROW(fEndY >= 0.0f); const auto fPerSpace = Services::Events::ExtractArgument<float>(args); ASSERT_OR_THROW(fPerSpace >= 0.0f); const auto fHeight = Services::Events::ExtractArgument<float>(args); ASSERT_OR_THROW(fHeight >= 0.0f); const auto bIgnoreDoors = Services::Events::ExtractArgument<int32_t>(args); retVal = pArea->TestDirectLine(fStartX, fStartY, fEndX, fEndY, fPerSpace, fHeight, bIgnoreDoors); } return Services::Events::Arguments(retVal); } ArgumentStack Area::GetMusicIsPlaying(ArgumentStack&& args) { int32_t retVal = false; if (auto *pArea = area(args)) { const auto bBattleMusic = Services::Events::ExtractArgument<int32_t>(args) != 0; retVal = bBattleMusic ? pArea->m_pAmbientSound->m_bBattlePlaying : pArea->m_pAmbientSound->m_bMusicPlaying; } return Services::Events::Arguments(retVal); } ArgumentStack Area::CreateGenericTrigger(ArgumentStack&& args) { ObjectID oidTrigger = Constants::OBJECT_INVALID; if (auto *pArea = area(args)) { const auto fX = Services::Events::ExtractArgument<float>(args); ASSERT_OR_THROW(fX >= 0.0f); const auto fY = Services::Events::ExtractArgument<float>(args); ASSERT_OR_THROW(fY >= 0.0f); const auto fZ = Services::Events::ExtractArgument<float>(args); const auto tag = Services::Events::ExtractArgument<std::string>(args); const auto fSize = Services::Events::ExtractArgument<float>(args); ASSERT_OR_THROW(fSize >= 0.0f); Vector vPosition = {fX, fY, fZ}; auto *pTrigger = new CNWSTrigger(); pTrigger->LoadFromTemplate(CResRef("newgeneric")); pTrigger->m_oidCreator = Constants::OBJECT_INVALID; pTrigger->SetPosition(vPosition, 0); pTrigger->CreateNewGeometry(fSize, vPosition, pArea); if (!tag.empty()) { pTrigger->m_sTag = CExoString(tag.c_str()); Utils::GetModule()->AddObjectToLookupTable(pTrigger->m_sTag, pTrigger->m_idSelf); } pTrigger->AddToArea(pArea, vPosition.x, vPosition.y, vPosition.z); oidTrigger = pTrigger->m_idSelf; } return Services::Events::Arguments(oidTrigger); } ArgumentStack Area::AddObjectToExclusionList(ArgumentStack&& args) { const auto oidObject = Services::Events::ExtractArgument<ObjectID>(args); ASSERT_OR_THROW(oidObject != Constants::OBJECT_INVALID); m_ExportExclusionList.emplace(oidObject); return Services::Events::Arguments(); } ArgumentStack Area::RemoveObjectFromExclusionList(ArgumentStack&& args) { const auto oidObject = Services::Events::ExtractArgument<ObjectID>(args); ASSERT_OR_THROW(oidObject != Constants::OBJECT_INVALID); m_ExportExclusionList.erase(oidObject); return Services::Events::Arguments(); } ArgumentStack Area::ExportGIT(ArgumentStack&& args) { int32_t retVal = false; if (auto *pArea = area(args)) { auto fileName = Services::Events::ExtractArgument<std::string>(args); ASSERT_OR_THROW(fileName.size() <= 16); if (fileName.empty()) fileName = pArea->m_cResRef.GetResRefStr(); const auto exportVarTable = !!Services::Events::ExtractArgument<int32_t>(args); const auto exportUUID = !!Services::Events::ExtractArgument<int32_t>(args); const auto objectFilter = Services::Events::ExtractArgument<int32_t>(args); CResGFF resGff; CResStruct resStruct{}; if (resGff.CreateGFFFile(&resStruct, "GIT ", "V3.2")) { CExoArrayList<ObjectID> creatures, items, doors, triggers, encounters, waypoints, sounds, placeables, stores, aoes; std::unordered_map<ObjectID, ObjectID> creatureAreaMap; for (int i = 0; i < pArea->m_aGameObjects.num; i++) { if (auto *pGameObject = Utils::GetGameObject(pArea->m_aGameObjects[i])) { if (m_ExportExclusionList.find(pGameObject->m_idSelf) != m_ExportExclusionList.end()) continue; if (auto *pCreature = Utils::AsNWSCreature(pGameObject)) { if (pCreature->m_pStats->m_bIsPC || pCreature->m_pStats->GetIsDM() || (pCreature->m_nAssociateType > Constants::AssociateType::None && pCreature->m_nAssociateType < Constants::AssociateType::Dominated)) continue; // Temporarily set pCreature's areaID to OBJECT_INVALID // When loading the creatures from the GIT, if the creature's areaID is the same as pArea's it // won't call AddToArea() which leaves all the creatures in limbo. creatureAreaMap.emplace(pGameObject->m_idSelf, pCreature->m_oidArea); pCreature->m_oidArea = Constants::OBJECT_INVALID; creatures.Add(pGameObject->m_idSelf); } else if (Utils::AsNWSItem(pGameObject)) items.Add(pGameObject->m_idSelf); else if (Utils::AsNWSDoor(pGameObject)) doors.Add(pGameObject->m_idSelf); else if (Utils::AsNWSTrigger(pGameObject)) triggers.Add(pGameObject->m_idSelf); else if (Utils::AsNWSEncounter(pGameObject)) encounters.Add(pGameObject->m_idSelf); else if (Utils::AsNWSWaypoint(pGameObject)) waypoints.Add(pGameObject->m_idSelf); else if (Utils::AsNWSSoundObject(pGameObject)) sounds.Add(pGameObject->m_idSelf); else if (Utils::AsNWSPlaceable(pGameObject)) placeables.Add(pGameObject->m_idSelf); else if (Utils::AsNWSStore(pGameObject)) stores.Add(pGameObject->m_idSelf); else if (Utils::AsNWSAreaOfEffectObject(pGameObject)) aoes.Add(pGameObject->m_idSelf); else continue; } } if (objectFilter != 32767) { if (!(objectFilter & 1)) pArea->SaveCreatures(&resGff, &resStruct, creatures, false); if (!(objectFilter & 2)) pArea->SaveItems(&resGff, &resStruct, items, false); if (!(objectFilter & 4)) pArea->SaveTriggers(&resGff, &resStruct, triggers, false); if (!(objectFilter & 8)) pArea->SaveDoors(&resGff, &resStruct, doors, false); if (!(objectFilter & 16)) pArea->SaveAreaEffects(&resGff, &resStruct, aoes, false); if (!(objectFilter & 32)) pArea->SaveWaypoints(&resGff, &resStruct, waypoints, false); if (!(objectFilter & 64)) pArea->SavePlaceables(&resGff, &resStruct, placeables, false); if (!(objectFilter & 128)) pArea->SaveStores(&resGff, &resStruct, stores, false); if (!(objectFilter & 256)) pArea->SaveEncounters(&resGff, &resStruct, encounters, false); // No NWScript OBJECT_TYPE_* constant for Sound Objects pArea->SaveSounds(&resGff, &resStruct, sounds, false); } pArea->SaveProperties(&resGff, &resStruct); if (exportVarTable) pArea->m_ScriptVars.SaveVarTable(&resGff, &resStruct); if (exportUUID) pArea->m_pUUID.SaveToGff(&resGff, &resStruct); retVal = resGff.WriteGFFFile("NWNX:" + fileName, Constants::ResRefType::GIT); // Restore the areaIDs of all creatures for (auto pair : creatureAreaMap) { if (auto *pCreature = Utils::AsNWSCreature(Utils::GetGameObject(pair.first))) pCreature->m_oidArea = pair.second; } } } return Services::Events::Arguments(retVal); } }
29.998856
127
0.599603
GideonCrawle
731929676fcb16cba7fd64e4d1723bda2d455820
1,517
cpp
C++
articulations_point.cpp
tz01x/Algorithm
e64a5ceeff01e1b144866760e1682619d9bb0539
[ "MIT" ]
null
null
null
articulations_point.cpp
tz01x/Algorithm
e64a5ceeff01e1b144866760e1682619d9bb0539
[ "MIT" ]
null
null
null
articulations_point.cpp
tz01x/Algorithm
e64a5ceeff01e1b144866760e1682619d9bb0539
[ "MIT" ]
1
2021-01-18T15:46:34.000Z
2021-01-18T15:46:34.000Z
#include<iostream> #include<vector> using namespace std; int _time=0; const int _size=10; vector<int>graph[_size]; int color[_size]; int prev[_size]; int d[_size]; int f[_size]; int low[_size]; void dfs_visit(int v) { color[v]=1; _time+=1; d[v]=_time; low[v]=d[v]; for(int i=0; i<graph[v].size();i++) { int w=graph[v][i]; if(color[graph[v][i]]==0){ dfs_visit(w); if(low[w]<low[v]) low[v]=low[w]; }else if(color[w]==1){ if(d[w]<low[v]){ low[v]=d[w]; } } if(low[w]>=d[v]){ cout<<v<<" is a articulation point "<<endl; } } _time+=1; color[v]=2; f[v]=_time; } void dfs(int n) { for(int i=0; i<n; i++) { color[i]=0; /// here -1 is referencing infinity d[i]=-1; f[i]=-1; low[i]=-1; } for(int i=0; i<n; i++) { if(color[i]==0) { dfs_visit(i); } } } int main() { int n; cin>>n; if(n<=_size) { int edge; cin>>edge; for(int i=0; i<edge; i++) { int row,col; cin>>row>>col; graph[row].push_back(col); graph[col].push_back(row); } } dfs(n); // cout<<"color"<<endl; // for(int i=0; i<n; i++) // { // cout<<color[i]<<endl; // } }
17.639535
56
0.388926
tz01x
73210595f80820d4bc9a9389717bc0eb0b5f6289
2,586
cpp
C++
BOCA/AG/src/generator.cpp
Raquel29/PC1-IFB-CC
36b55e95373a5f022651545248d8cb66bac1cd3f
[ "MIT" ]
1
2020-05-24T02:22:13.000Z
2020-05-24T02:22:13.000Z
BOCA/AG/src/generator.cpp
danielsaad/PC1-IFB-CC
36b55e95373a5f022651545248d8cb66bac1cd3f
[ "MIT" ]
null
null
null
BOCA/AG/src/generator.cpp
danielsaad/PC1-IFB-CC
36b55e95373a5f022651545248d8cb66bac1cd3f
[ "MIT" ]
4
2019-05-15T10:55:57.000Z
2019-10-26T13:46:48.000Z
#include "testlib.h" #include <bits/stdc++.h> using namespace std; using vi = vector<int>; const int MIN_N = 1; const int MAX_N = 1e5; const double MIN_V = -50.0; const double MAX_V = 50.0; const int rnd_test_n = 50; template <typename T> void append(vector<T> &dest, const vector<T> &orig) { dest.insert(dest.end(), orig.begin(), orig.end()); } string output_tc(vector<double> &temperatures) { ostringstream oss; oss << temperatures.size() << endl; for (size_t i = 0; i < temperatures.size(); i++) { oss << temperatures[i]; oss << (i == temperatures.size() - 1 ? "\n" : " "); } return oss.str(); } vector<double> generate_random_array(int n, double min_v = MIN_V, double max_v = MAX_V) { vector<double> v(n); for (int i = 0; i < n; i++) { v[i] = rnd.next(min_v, max_v); } return v; } vector<string> generate_sample_tests() { vector<string> tests; vector<double> temperatures; temperatures = {25.0, 27.0, 26.0}; tests.push_back(output_tc(temperatures)); temperatures = {-10, 40, -10}; tests.push_back(output_tc(temperatures)); temperatures = {0, 0, 0}; tests.push_back(output_tc(temperatures)); return tests; } string rnd_test(int i) { int min_n = MIN_N; int max_n = MAX_N; if(i<= rnd_test_n-10){ min_n = 1; max_n = 10; } int n = rnd.next(min_n, max_n); auto v = generate_random_array(n,MIN_V,MAX_V); return (output_tc(v)); } vector<string> generate_random_tests() { vector<string> tests; for (int i = 0; i < rnd_test_n; i++) { tests.push_back(rnd_test(i)); } return tests; } string extreme_test_1() { auto v = generate_random_array(MAX_N,MIN_V,MAX_V); return (output_tc(v)); } string extreme_test_2() { auto v = generate_random_array(MAX_N,MAX_V,MAX_V); return (output_tc(v)); } string extreme_test_3() { auto v = generate_random_array(MAX_N,MIN_V,MIN_V); return (output_tc(v)); } vector<string> generate_extreme_tests() { vector<string> tests; tests.push_back(extreme_test_1()); tests.push_back(extreme_test_2()); tests.push_back(extreme_test_3()); return tests; } int main(int argc, char *argv[]) { registerGen(argc, argv, 1); vector<string> tests; size_t test = 0; append(tests, generate_sample_tests()); append(tests, generate_random_tests()); append(tests, generate_extreme_tests()); for (const auto &t : tests) { startTest(++test); cout << t; } return 0; }
24.396226
75
0.617556
Raquel29
7322e7814e7024232046e7411cb1fe1d6e5fab64
4,053
cpp
C++
src/matUtils/describe.cpp
theosanderson/usher
a58c56361cbd40be9dd671afabfa0839aa1cd58e
[ "MIT" ]
null
null
null
src/matUtils/describe.cpp
theosanderson/usher
a58c56361cbd40be9dd671afabfa0839aa1cd58e
[ "MIT" ]
null
null
null
src/matUtils/describe.cpp
theosanderson/usher
a58c56361cbd40be9dd671afabfa0839aa1cd58e
[ "MIT" ]
null
null
null
#include "describe.hpp" std::vector<std::string> mutation_paths(const MAT::Tree& T, std::vector<std::string> samples) { std::vector<std::string> mpaths; mpaths.push_back("sample_id\tpath_from_root"); for (auto sample: samples) { std::string cpath = sample + "\t"; auto root_to_sample = T.rsearch(sample, true); std::reverse(root_to_sample.begin(), root_to_sample.end()); for (auto n: root_to_sample) { for (size_t i=0; i<n->mutations.size(); i++) { cpath += n->mutations[i].get_string(); if (i+1 < n->mutations.size()) { cpath += ","; } } if (n != root_to_sample.back()) { //note, for uncondensed samples with parsimony score 0, //this will leave a > at the end. That's basically fine. cpath += " (" + n->identifier + ") > "; } } mpaths.push_back(cpath); } return mpaths; } std::vector<std::string> clade_paths(MAT::Tree T, std::vector<std::string> clades) { //get the set of clade path strings for printing //similar to the above, construct a series of strings to be printed or redirected later on std::vector<std::string> clpaths; clpaths.push_back("clade\troot_id\tfrom_tree_root\n"); //do a breadth-first search //the first time a clade that is in clades is encountered, that's the root; //get the path of mutations to that root (rsearch), save the unique mutations + that path //unique mutations being ones that occurred in the clade root, and the path being all mutations from that root back to the tree root //then continue. if a clade has already been encountered in the breadth first, its //not clade root, and should be skipped. std::set<std::string> clades_seen; auto dfs = T.breadth_first_expansion(); for (auto n: dfs) { for (auto ann: n->clade_annotations) { if (ann != "") { std::string curpath; //if its one of our target clades and it hasn't been seen... if (std::find(clades.begin(), clades.end(), ann) != clades.end() && clades_seen.find(ann) == clades_seen.end()) { //record the name of the clade curpath += ann + "\t"; curpath += n->identifier + "\t"; //get the ancestral mutations back to the root std::string root = ""; auto root_to_sample = T.rsearch(n->identifier, true); std::reverse(root_to_sample.begin(), root_to_sample.end()); for (auto an: root_to_sample) { for (size_t i=0; i<an->mutations.size(); i++) { root += an->mutations[i].get_string(); if (i+1 < an->mutations.size()) { root += ","; } } if (an != root_to_sample.back()) { root += " > "; } } //save values to the string, mark the clade as seen, and save the string curpath += root; clades_seen.insert(ann); clpaths.push_back(curpath + "\n"); } } } } return clpaths; } std::vector<std::string> all_nodes_paths(MAT::Tree T) { std::vector<std::string> dfs_strings; auto dfs = T.depth_first_expansion(); for (auto n: dfs) { std::string node_path = n->identifier + ": "; for (size_t i=0; i<n->mutations.size(); i++) { node_path += n->mutations[i].get_string(); if (i+1 < n->mutations.size()) { node_path += ","; } } dfs_strings.push_back(node_path); } return dfs_strings; }
44.054348
137
0.506785
theosanderson
7322f78fb03ebbf9e6ec2fceb6d5aaae0ef66312
1,653
cpp
C++
flyweight_handmade/src/main.cpp
Thordreck/design_patterns_cpp
b7b8ccc76ba26b2f63b80a2022616f266001d85d
[ "MIT" ]
1
2020-02-27T09:39:13.000Z
2020-02-27T09:39:13.000Z
flyweight_handmade/src/main.cpp
Thordreck/design_patterns_cpp
b7b8ccc76ba26b2f63b80a2022616f266001d85d
[ "MIT" ]
null
null
null
flyweight_handmade/src/main.cpp
Thordreck/design_patterns_cpp
b7b8ccc76ba26b2f63b80a2022616f266001d85d
[ "MIT" ]
null
null
null
#include <map> #include <string> #include <sstream> #include <iostream> #include <boost/bimap.hpp> // Bad implementation struct BadUser { std::string name; }; // Flyweight implementation using key = uint32_t; struct User { User(const std::string& _first_name, const std::string& _last_name) : first_name_ { add(_first_name) } , last_name_ { add(_last_name) } {} const std::string& first_name() const { return names.left.find(first_name_)->second; } const std::string& last_name() const { return names.left.find(last_name_)->second; } protected: static key add(const std::string& s) { auto it = names.right.find(s); if(it == names.right.end()) { key id = ++seed; names.insert( { seed, s } ); return id; } return it->second; } protected: const key first_name_; const key last_name_; static boost::bimap<key, std::string> names; static key seed; }; std::ostream& operator<<(std::ostream& oss, const User& user) { oss << "First name: " << user.first_name() << " last name: " << user.last_name(); return oss; } key User::seed { 0 }; boost::bimap<key, std::string> User::names {}; int main() { // Bad implementation BadUser user1 { "John Doe" }; BadUser user2 { "John Smith" }; // Flyweight implementation User user3 { "John", "Smith" }; User user4 { "Jane", "Smith" }; std::cout << user3 << std::endl; std::cout << user4 << std::endl; return 0; }
19.915663
71
0.554749
Thordreck
7331dc0b8fe960196a61778f185da6af56508db2
851
cpp
C++
src/Engine/TextureManager.cpp
charlieSewell/YOKAI
4fb39975e58e9a49bc984bc6e844721a7ad9462e
[ "MIT" ]
null
null
null
src/Engine/TextureManager.cpp
charlieSewell/YOKAI
4fb39975e58e9a49bc984bc6e844721a7ad9462e
[ "MIT" ]
null
null
null
src/Engine/TextureManager.cpp
charlieSewell/YOKAI
4fb39975e58e9a49bc984bc6e844721a7ad9462e
[ "MIT" ]
null
null
null
#include "TextureManager.hpp" TextureManager::TextureManager() { textureCount = 0; } TextureManager& TextureManager::getInstance() { static TextureManager instance; return instance; } std::shared_ptr<Texture> TextureManager::getTexture(unsigned int textureID) { return textures.at(textureID).second; } unsigned int TextureManager::loadTexture(const std::string &textureName) { for(auto& texture : textures) { if(texture.second.first == textureName) { return texture.first; } } textures.emplace(textureCount,std::pair(textureName,Texture::Create(textureName))); textureCount++; return(textureCount -1); } void TextureManager::replaceTexture(size_t slot, const std::string &newTexturePath) { textures.at(slot) = std::pair(newTexturePath,Texture::Create(newTexturePath)); }
27.451613
87
0.710928
charlieSewell
73360d0c3164f3f81e58c104dd2a42e81bc1b59f
2,261
cpp
C++
src/DescriptorSets.cpp
ComicSansMS/GhulbusVulkan
b24ffb892a7573c957aed443a3fbd7ec281556e7
[ "MIT" ]
null
null
null
src/DescriptorSets.cpp
ComicSansMS/GhulbusVulkan
b24ffb892a7573c957aed443a3fbd7ec281556e7
[ "MIT" ]
null
null
null
src/DescriptorSets.cpp
ComicSansMS/GhulbusVulkan
b24ffb892a7573c957aed443a3fbd7ec281556e7
[ "MIT" ]
null
null
null
#include <gbVk/DescriptorSets.hpp> #include <gbVk/DescriptorSet.hpp> #include <gbVk/Exceptions.hpp> #include <gbBase/Assert.hpp> namespace GHULBUS_VULKAN_NAMESPACE { DescriptorSets::DescriptorSets(VkDevice logical_device, VkDescriptorPool descriptor_pool, std::vector<VkDescriptorSet> descriptor_sets) :m_descriptorSets(std::move(descriptor_sets)), m_device(logical_device), m_descriptorPool(descriptor_pool), m_hasOwnership(true) { } DescriptorSets::DescriptorSets(VkDevice logical_device, VkDescriptorPool descriptor_pool, std::vector<VkDescriptorSet> descriptor_sets, NonOwning const&) :DescriptorSets(logical_device, descriptor_pool, std::move(descriptor_sets)) { m_hasOwnership = false; } DescriptorSets::~DescriptorSets() { if (m_hasOwnership && !m_descriptorSets.empty()) { vkFreeDescriptorSets(m_device, m_descriptorPool, static_cast<uint32_t>(m_descriptorSets.size()), m_descriptorSets.data()); } } DescriptorSets::DescriptorSets(DescriptorSets&& rhs) noexcept :m_descriptorSets(std::move(rhs.m_descriptorSets)), m_device(rhs.m_device), m_descriptorPool(rhs.m_descriptorPool), m_hasOwnership(rhs.m_hasOwnership) { rhs.m_descriptorSets.clear(); } DescriptorSets& DescriptorSets::operator=(DescriptorSets&& rhs) { if (&rhs != this) { if (m_hasOwnership && !m_descriptorSets.empty()) { vkFreeDescriptorSets(m_device, m_descriptorPool, static_cast<uint32_t>(m_descriptorSets.size()), m_descriptorSets.data()); } m_descriptorSets = std::move(rhs.m_descriptorSets); m_device = rhs.m_device; m_descriptorPool = rhs.m_descriptorPool; m_hasOwnership = rhs.m_hasOwnership; rhs.m_descriptorSets.clear(); } return *this; } uint32_t DescriptorSets::size() const { return static_cast<uint32_t>(m_descriptorSets.size()); } DescriptorSet DescriptorSets::getDescriptorSet(uint32_t index) { GHULBUS_PRECONDITION_DBG((index >= 0) && (index < size())); return DescriptorSet(m_descriptorSets[index]); } VkDescriptorSet* DescriptorSets::getVkDescriptorSets() { return m_descriptorSets.data(); } }
31.402778
119
0.708094
ComicSansMS
7339441b0f7e5ce5f5e4d3a45cf8bae997f721cb
1,399
cpp
C++
src/vpg/ecs/coordinator.cpp
RiscadoA/voxel-platformer
4e7aadad978c333a59f452a8ee9f4612ee128614
[ "MIT" ]
3
2021-03-01T16:00:04.000Z
2022-01-07T03:45:32.000Z
src/vpg/ecs/coordinator.cpp
RiscadoA/voxel-platformer
4e7aadad978c333a59f452a8ee9f4612ee128614
[ "MIT" ]
null
null
null
src/vpg/ecs/coordinator.cpp
RiscadoA/voxel-platformer
4e7aadad978c333a59f452a8ee9f4612ee128614
[ "MIT" ]
2
2021-03-27T03:54:24.000Z
2021-06-22T13:53:07.000Z
#include <vpg/ecs/coordinator.hpp> using namespace vpg::ecs; EntityManager* Coordinator::entity_manager; ComponentManager* Coordinator::component_manager; SystemManager* Coordinator::system_manager; void Coordinator::init() { Coordinator::entity_manager = new EntityManager(); Coordinator::component_manager = new ComponentManager(); Coordinator::system_manager = new SystemManager(); } void Coordinator::terminate() { delete Coordinator::entity_manager; delete Coordinator::component_manager; delete Coordinator::system_manager; } Entity Coordinator::create_entity() { return Coordinator::entity_manager->create(); } void Coordinator::destroy_entity(Entity entity) { Coordinator::entity_manager->destroy(entity); Coordinator::component_manager->entity_destroyed(entity); Coordinator::system_manager->entity_destroyed(entity); } bool Coordinator::add_component(Entity entity, memory::Stream& stream) { std::string type; if (!Coordinator::component_manager->add_component(entity, stream, type)) { return false; } auto signature = Coordinator::entity_manager->get_signature(entity); signature.set(Coordinator::component_manager->get_component_type(type), true); Coordinator::entity_manager->set_signature(entity, signature); Coordinator::system_manager->entity_signature_changed(entity, signature); return true; }
33.309524
82
0.764117
RiscadoA
733aa5dd5cee7e3d0971b9a33b13021549b2bb7c
1,115
cpp
C++
rclcpp/src/rclcpp/generic_publisher.cpp
jlack1987/rclcpp
d107a844eae6f4d6a86515f0b3e469802ab1e785
[ "Apache-2.0" ]
271
2015-04-07T15:26:53.000Z
2022-03-31T17:42:58.000Z
rclcpp/src/rclcpp/generic_publisher.cpp
jlack1987/rclcpp
d107a844eae6f4d6a86515f0b3e469802ab1e785
[ "Apache-2.0" ]
1,676
2015-01-15T23:46:56.000Z
2022-03-31T21:32:06.000Z
rclcpp/src/rclcpp/generic_publisher.cpp
jlack1987/rclcpp
d107a844eae6f4d6a86515f0b3e469802ab1e785
[ "Apache-2.0" ]
299
2015-10-05T16:51:32.000Z
2022-03-30T11:23:18.000Z
// Copyright 2018, Bosch Software Innovations GmbH. // Copyright 2021, Apex.AI Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "rclcpp/generic_publisher.hpp" #include <memory> #include <string> namespace rclcpp { void GenericPublisher::publish(const rclcpp::SerializedMessage & message) { auto return_code = rcl_publish_serialized_message( get_publisher_handle().get(), &message.get_rcl_serialized_message(), NULL); if (return_code != RCL_RET_OK) { rclcpp::exceptions::throw_from_rcl_error(return_code, "failed to publish serialized message"); } } } // namespace rclcpp
31.857143
98
0.750673
jlack1987
733ab413cbd65cc36cd5c460707989d85209d60b
12,434
cpp
C++
Examples/Beginner/02_IntroducingPVRShell/OGLES/OGLESIntroducingPVRShell.cpp
kusharami/PowerVR_Native_SDK
41557a911316126417ce4c92f1b89396f24f39d6
[ "MIT" ]
null
null
null
Examples/Beginner/02_IntroducingPVRShell/OGLES/OGLESIntroducingPVRShell.cpp
kusharami/PowerVR_Native_SDK
41557a911316126417ce4c92f1b89396f24f39d6
[ "MIT" ]
null
null
null
Examples/Beginner/02_IntroducingPVRShell/OGLES/OGLESIntroducingPVRShell.cpp
kusharami/PowerVR_Native_SDK
41557a911316126417ce4c92f1b89396f24f39d6
[ "MIT" ]
null
null
null
/*!********************************************************************************************************************* \File OGLESIntroducingPVRShell.cpp \Title Introduces PVRShell \Author PowerVR by Imagination, Developer Technology Team \Copyright Copyright (c) Imagination Technologies Limited. \brief Shows how to use the PowerVR framework for initialization. This framework allows platform abstraction so applications using it will work on any PowerVR enabled device. ***********************************************************************************************************************/ #include <stdio.h> #include <string.h> #if defined(__APPLE__) && defined (TARGET_OS_IPHONE) #import <OpenGLES/ES2/gl.h> #import <OpenGLES/ES2/glext.h> #else #define GL_GLEXT_PROTOTYPES #include <GLES2/gl2.h> #endif #include "PVRShell/PVRShellNoPVRApi.h" /* * The PowerVR Shell * =========================== The PowerVR shell handles all OS specific initialisation code, and is extremely convenient for writing portable applications. It also has several built in command line features, which allow you to specify attributes like the backbuffer size, vsync and antialiasing modes. The code is constructed around a "PVRShell" superclass. You must define your app using a class which inherits from this, which should implement the following five methods, (which at execution time are essentially called in the order in which they are listed): initApplication: This is called before any API initialisation has taken place, and can be used to set up any application data which does not require API calls, for example object positions, or arrays containing vertex data, before they are uploaded. initView: This is called after the API has initialized, and can be used to do any remaining initialisation which requires API functionality. In this app, it is used to upload the vertex data. renderFrame: This is called repeatedly to draw the geometry. Returning false from this function instructs the app to enter the quit sequence: releaseView: This function is called before the API is released, and is used to release any API resources. In this app, it releases the vertex buffer. quitApplication: This is called last of all, after the API has been released, and can be used to free any leftover user allocated memory. The shell framework starts the application by calling a "NewDemo" function, which must return an instance of the PVRShell class you defined. We will now use the shell to create a "Hello triangle" app, similar to the previous one. */ // Index to bind the attributes to vertex shaders const pvr::uint32 VertexArray = 0; /*!********************************************************************************************************************* To use the shell, you have to inherit a class from PVRShell and implement the five virtual functions which describe how your application initializes, runs and releases the resources. ***********************************************************************************************************************/ class OGLESIntroducingPVRShell : public pvr::Shell { // The vertex and fragment shader OpenGL handles pvr::uint32 vertexShader, fragShader; // The program object containing the 2 shader objects pvr::uint32 programObject; // VBO handle pvr::uint32 vbo; public: // following function must be override virtual pvr::Result initApplication(); virtual pvr::Result initView(); virtual pvr::Result releaseView(); virtual pvr::Result quitApplication(); virtual pvr::Result renderFrame(); }; /*!********************************************************************************************************************* \return Return Result::Success if no error occurred \brief Code in initApplication() will be called by pvr::Shell once per run, before the rendering context is created. Used to initialize variables that are not dependent on it (e.g. external modules, loading meshes, etc.) If the rendering context is lost, initApplication() will not be called again. ***********************************************************************************************************************/ pvr::Result OGLESIntroducingPVRShell::initApplication(){ return pvr::Result::Success; } /*!********************************************************************************************************************* \return Return Result::Success if no error occurred \brief Code in quitApplication() will be called by pvr::Shell once per run, just before exiting the program. If the rendering context is lost, QuitApplication() will not be called. ***********************************************************************************************************************/ pvr::Result OGLESIntroducingPVRShell::quitApplication(){ return pvr::Result::Success; } /*!********************************************************************************************************************* \return Return Result::Success if no error occured \brief Code in initView() will be called by pvr::Shell upon initialization or after a change in the rendering context. Used to initialize variables that are dependant on the rendering context (e.g. textures, vertex buffers, etc.) ***********************************************************************************************************************/ pvr::Result OGLESIntroducingPVRShell::initView() { // Fragment and vertex shaders code const char* pszFragShader = "\ void main (void)\ {\ gl_FragColor = vec4(1.0, 1.0, 0.66 ,1.0);\ }"; const char* pszVertShader = "\ attribute highp vec4 myVertex;\ uniform mediump mat4 myPMVMatrix;\ void main(void)\ {\ gl_Position = myPMVMatrix * myVertex;\ }"; // Create the fragment shader object fragShader = glCreateShader(GL_FRAGMENT_SHADER); // Load the source code into it glShaderSource(fragShader, 1, (const char**)&pszFragShader, NULL); // Compile the source code glCompileShader(fragShader); // Check if compilation succeeded pvr::int32 bShaderCompiled; glGetShaderiv(fragShader, GL_COMPILE_STATUS, &bShaderCompiled); if (!bShaderCompiled) { // An error happened, first retrieve the length of the log message int infoLogLength, numCharsWritten; glGetShaderiv(fragShader, GL_INFO_LOG_LENGTH, &infoLogLength); // Allocate enough space for the message and retrieve it std::vector<char> infoLog; infoLog.resize(infoLogLength); glGetShaderInfoLog(fragShader, infoLogLength, &numCharsWritten, infoLog.data()); // Displays the message in a dialog box when the application quits // using the shell PVRShellSet function with first parameter prefExitMessage. std::string message("Failed to compile fragment shader: "); message += infoLog.data(); this->setExitMessage(message.c_str()); return pvr::Result::InvalidData; } // Loads the vertex shader in the same way vertexShader = glCreateShader(GL_VERTEX_SHADER); glShaderSource(vertexShader, 1, (const char**)&pszVertShader, NULL); glCompileShader(vertexShader); glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &bShaderCompiled); if (!bShaderCompiled) { int infoLogLength, numCharsWritten; glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &infoLogLength); std::vector<char> infoLog; infoLog.resize(infoLogLength); glGetShaderInfoLog(vertexShader, infoLogLength, &numCharsWritten, infoLog.data()); std::string message("Failed to compile vertex shader: "); message += infoLog.data(); this->setExitMessage(message.c_str()); return pvr::Result::InvalidData; } // Create the shader program programObject = glCreateProgram(); // Attach the fragment and vertex shaders to it glAttachShader(programObject, fragShader); glAttachShader(programObject, vertexShader); // Bind the custom vertex attribute "myVertex" to location VERTEX_ARRAY glBindAttribLocation(programObject, VertexArray, "myVertex"); // Link the program glLinkProgram(programObject); // Check if linking succeeded in the same way we checked for compilation success pvr::int32 bLinked; glGetProgramiv(programObject, GL_LINK_STATUS, &bLinked); if (!bLinked) { int infoLogLength, numCharsWritten; glGetProgramiv(programObject, GL_INFO_LOG_LENGTH, &infoLogLength); std::vector<char> infoLog; infoLog.resize(infoLogLength); glGetProgramInfoLog(programObject, infoLogLength, &numCharsWritten, infoLog.data()); std::string message("Failed to link program: "); message += infoLog.data(); this->setExitMessage(message.c_str()); return pvr::Result::InvalidData; } // Actually use the created program glUseProgram(programObject); // Sets the clear color glClearColor(0.00, 0.70, 0.67, 1.0f); // Create VBO for the triangle from our data // Vertex data GLfloat afVertices[] = {-0.4f,-0.4f,0.0f, 0.4f,-0.4f,0.0f, 0.0f,0.4f,0.0f}; // Gen VBO glGenBuffers(1, &vbo); // Bind the VBO glBindBuffer(GL_ARRAY_BUFFER, vbo); // Set the buffer's data glBufferData(GL_ARRAY_BUFFER, 3 * (3 * sizeof(GLfloat)) /* 3 Vertices of 3 floats in size */, afVertices, GL_STATIC_DRAW); // Unbind the VBO glBindBuffer(GL_ARRAY_BUFFER, 0); // Enable culling glEnable(GL_CULL_FACE); return pvr::Result::Success; } /*!********************************************************************************************************************* \return Return Result::Success if no error occurred \brief Code in releaseView() will be called by pvr::Shell when the application quits or before a change in the rendering context. ***********************************************************************************************************************/ pvr::Result OGLESIntroducingPVRShell::releaseView() { // Release Vertex buffer object. glDeleteBuffers(1, &vbo); // Frees the OpenGL handles for the program and the 2 shaders glDeleteProgram(programObject); glDeleteShader(vertexShader); glDeleteShader(fragShader); return pvr::Result::Success; } /*!********************************************************************************************************************* \return Return Result::Success if no error occurred \brief Main rendering loop function of the program. The shell will call this function every frame. ***********************************************************************************************************************/ pvr::Result OGLESIntroducingPVRShell::renderFrame() { // Matrix used for projection model view float afIdentity[] = { 1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 }; // Clears the color buffer. glClear() can also be used to clear the depth or stencil buffer // (GL_DEPTH_BUFFER_BIT or GL_STENCIL_BUFFER_BIT) glClear(GL_COLOR_BUFFER_BIT); // Bind the projection model view matrix (PMVMatrix) to // the associated uniform variable in the shader // First gets the location of that variable in the shader using its name int i32Location = glGetUniformLocation(programObject, "myPMVMatrix"); // Then passes the matrix to that variable glUniformMatrix4fv(i32Location, 1, GL_FALSE, afIdentity); // Bind the VBO glBindBuffer(GL_ARRAY_BUFFER, vbo); // Enable the custom vertex attribute at index VERTEX_ARRAY. // We previously binded that index to the variable in our shader "vec4 MyVertex;" glEnableVertexAttribArray(VertexArray); // Points to the data for this vertex attribute glVertexAttribPointer(VertexArray, 3, GL_FLOAT, GL_FALSE, 0, 0); // Draws a non-indexed triangle array from the pointers previously given. // This function allows the use of other primitive types : triangle strips, lines, ... // For indexed geometry, use the function glDrawElements() with an index list. glDrawArrays(GL_TRIANGLES, 0, 3); // Unbind the VBO glBindBuffer(GL_ARRAY_BUFFER, 0); return pvr::Result::Success; } /*!********************************************************************************************************************* \return Return auto ptr to the demo supplied by the user \brief This function must be implemented by the user of the shell. The user should return its PVRShell object defining the behaviour of the application. ***********************************************************************************************************************/ std::auto_ptr<pvr::Shell> pvr::newDemo(){ return std::auto_ptr<pvr::Shell>(new OGLESIntroducingPVRShell()); }
41.036304
131
0.637044
kusharami
733af3a7744f90b2453a8cffa75262fda58a92cb
29,366
cpp
C++
src/server/game/Battlegrounds/Zones/BattlegroundBG.cpp
Frankenhooker/ArkCORE
0a7be7fc0b67e9ef3de421ab5de6012eac7dec6d
[ "OpenSSL" ]
1
2020-03-27T15:13:49.000Z
2020-03-27T15:13:49.000Z
src/server/game/Battlegrounds/Zones/BattlegroundBG.cpp
Frankenhooker/ArkCORE
0a7be7fc0b67e9ef3de421ab5de6012eac7dec6d
[ "OpenSSL" ]
null
null
null
src/server/game/Battlegrounds/Zones/BattlegroundBG.cpp
Frankenhooker/ArkCORE
0a7be7fc0b67e9ef3de421ab5de6012eac7dec6d
[ "OpenSSL" ]
null
null
null
/* * Copyright (C) 2005 - 2012 MaNGOS <http://www.getmangos.com/> * * Copyright (C) 2008 - 2012 Trinity <http://www.trinitycore.org/> * * Copyright (C) 2010 - 2012 ProjectSkyfire <http://www.projectskyfire.org/> * * Copyright (C) 2011 - 2012 ArkCORE <http://www.arkania.net/> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * 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, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "gamePCH.h" #include "World.h" #include "WorldPacket.h" #include "ObjectMgr.h" #include "BattlegroundMgr.h" #include "Battleground.h" #include "BattlegroundBG.h" #include "Creature.h" #include "Language.h" #include "Object.h" #include "Player.h" #include "Util.h" // these variables aren't used outside of this file, so declare them only here uint32 BG_BG_HonorScoreTicks[BG_HONOR_MODE_NUM] = { 330, // normal honor 200 // holiday }; BattlegroundBG::BattlegroundBG () { m_BuffChange = true; m_BgObjects.resize(BG_BG_OBJECT_MAX); m_BgCreatures.resize(BG_BG_ALL_NODES_COUNT + 5); //+5 for aura triggers m_StartMessageIds[BG_STARTING_EVENT_FIRST] = LANG_BG_BG_START_TWO_MINUTES; m_StartMessageIds[BG_STARTING_EVENT_SECOND] = LANG_BG_BG_START_ONE_MINUTE; m_StartMessageIds[BG_STARTING_EVENT_THIRD] = LANG_BG_BG_START_HALF_MINUTE; m_StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_BG_BG_HAS_BEGUN; } BattlegroundBG::~BattlegroundBG () { } void BattlegroundBG::Update (uint32 diff) { Battleground::Update(diff); if (GetStatus() == STATUS_IN_PROGRESS) { int team_points[BG_TEAMS_COUNT] = { 0, 0 }; for (int node = 0; node < BG_BG_DYNAMIC_NODES_COUNT; ++node) { // 3 sec delay to spawn new banner instead previous despawned one if (m_BannerTimers[node].timer) { if (m_BannerTimers[node].timer > diff) m_BannerTimers[node].timer -= diff; else { m_BannerTimers[node].timer = 0; _CreateBanner(node, m_BannerTimers[node].type, m_BannerTimers[node].teamIndex, false); } } // 1-minute to occupy a node from contested state if (m_NodeTimers[node]) { if (m_NodeTimers[node] > diff) m_NodeTimers[node] -= diff; else { m_NodeTimers[node] = 0; // Change from contested to occupied ! uint8 teamIndex = m_Nodes[node] - 1; m_prevNodes[node] = m_Nodes[node]; m_Nodes[node] += 2; // burn current contested banner _DelBanner(node, BG_BG_NODE_TYPE_CONTESTED, teamIndex); // create new occupied banner _CreateBanner(node, BG_BG_NODE_TYPE_OCCUPIED, teamIndex, true); _SendNodeUpdate(node); _NodeOccupied(node, (teamIndex == 0) ? ALLIANCE : HORDE); // Message to chatlog if (teamIndex == 0) { // FIXME: team and node names not localized SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL, LANG_BG_AB_ALLY, _GetNodeNameId(node)); PlaySoundToAll(BG_BG_SOUND_NODE_CAPTURED_ALLIANCE); } else { // FIXME: team and node names not localized SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_HORDE, NULL, LANG_BG_AB_HORDE, _GetNodeNameId(node)); PlaySoundToAll(BG_BG_SOUND_NODE_CAPTURED_HORDE); } } } for (int team = 0; team < BG_TEAMS_COUNT; ++team) if (m_Nodes[node] == team + BG_BG_NODE_TYPE_OCCUPIED) ++team_points[team]; } // Accumulate points for (int team = 0; team < BG_TEAMS_COUNT; ++team) { int points = team_points[team]; if (!points) continue; m_lastTick[team] += diff; if (m_lastTick[team] > BG_BG_TickIntervals[points]) { m_lastTick[team] -= BG_BG_TickIntervals[points]; m_TeamScores[team] += BG_BG_TickPoints[points]; m_HonorScoreTics[team] += BG_BG_TickPoints[points]; if (!m_IsInformedNearVictory && m_TeamScores[team] > BG_BG_WARNING_NEAR_VICTORY_SCORE) { if (team == BG_TEAM_ALLIANCE) SendMessageToAll(LANG_BG_AB_A_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL); else SendMessageToAll(LANG_BG_AB_H_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL); PlaySoundToAll(BG_BG_SOUND_NEAR_VICTORY); m_IsInformedNearVictory = true; } if (m_TeamScores[team] > BG_BG_MAX_TEAM_SCORE) m_TeamScores[team] = BG_BG_MAX_TEAM_SCORE; if (team == BG_TEAM_ALLIANCE) UpdateWorldState(BG_BG_OP_RESOURCES_ALLY, m_TeamScores[team]); if (team == BG_TEAM_HORDE) UpdateWorldState(BG_BG_OP_RESOURCES_HORDE, m_TeamScores[team]); // update achievement flags // we increased m_TeamScores[team] so we just need to check if it is 500 more than other teams resources uint8 otherTeam = (team + 1) % BG_TEAMS_COUNT; if (m_TeamScores[team] > m_TeamScores[otherTeam] + 500) m_TeamScores500Disadvantage[otherTeam] = true; } } // Test win condition if (m_TeamScores[BG_TEAM_ALLIANCE] >= BG_BG_MAX_TEAM_SCORE) EndBattleground(ALLIANCE); if (m_TeamScores[BG_TEAM_HORDE] >= BG_BG_MAX_TEAM_SCORE) EndBattleground(HORDE); } } void BattlegroundBG::StartingEventCloseDoors () { // despawn banners, auras and buffs for (int obj = BG_BG_OBJECT_BANNER_NEUTRAL; obj < BG_BG_DYNAMIC_NODES_COUNT * 8; ++obj) SpawnBGObject(obj, RESPAWN_ONE_DAY); for (int i = 0; i < BG_BG_DYNAMIC_NODES_COUNT * 3; ++i) SpawnBGObject(BG_BG_OBJECT_SPEEDBUFF_LIGHTHOUSE + i, RESPAWN_ONE_DAY); // Starting doors DoorClose(BG_BG_OBJECT_GATE_A); DoorClose(BG_BG_OBJECT_GATE_H); SpawnBGObject(BG_BG_OBJECT_GATE_A, RESPAWN_IMMEDIATELY); SpawnBGObject(BG_BG_OBJECT_GATE_H, RESPAWN_IMMEDIATELY); // Starting base spirit guides _NodeOccupied(BG_BG_SPIRIT_ALIANCE, ALLIANCE); _NodeOccupied(BG_BG_SPIRIT_HORDE, HORDE); } void BattlegroundBG::StartingEventOpenDoors () { // spawn neutral banners for (int banner = BG_BG_OBJECT_BANNER_NEUTRAL, i = 0; i < 3; banner += 8, ++i) SpawnBGObject(banner, RESPAWN_IMMEDIATELY); for (int i = 0; i < BG_BG_DYNAMIC_NODES_COUNT; ++i) { //randomly select buff to spawn uint8 buff = urand(0, 2); SpawnBGObject(BG_BG_OBJECT_SPEEDBUFF_LIGHTHOUSE + buff + i * 3, RESPAWN_IMMEDIATELY); } DoorOpen(BG_BG_OBJECT_GATE_A); DoorOpen(BG_BG_OBJECT_GATE_H); } void BattlegroundBG::AddPlayer (Player *plr) { Battleground::AddPlayer(plr); //create score and add it to map, default values are set in the constructor BattlegroundBGScore* sc = new BattlegroundBGScore; m_PlayerScores[plr->GetGUID()] = sc; } void BattlegroundBG::RemovePlayer (Player * /*plr*/, uint64 /*guid*/) { } void BattlegroundBG::HandleAreaTrigger (Player *Source, uint32 Trigger) { if (GetStatus() != STATUS_IN_PROGRESS) return; //Area triggers are not handled yet! return; switch (Trigger) { case 3866: // Lighthouse case 3869: // Watterwork case 3867: // Mine case 4020: // Unk1 case 4021: // Unk2 //break; default: sLog->outError("WARNING: Unhandled AreaTrigger in Battleground: %u", Trigger); Source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", Trigger); break; } } /* type: 0-neutral, 1-contested, 3-occupied teamIndex: 0-ally, 1-horde */ void BattlegroundBG::_CreateBanner (uint8 node, uint8 type, uint8 teamIndex, bool delay) { // Just put it into the queue if (delay) { m_BannerTimers[node].timer = 2000; m_BannerTimers[node].type = type; m_BannerTimers[node].teamIndex = teamIndex; return; } uint8 obj = node * 8 + type + teamIndex; SpawnBGObject(obj, RESPAWN_IMMEDIATELY); // handle aura with banner if (!type) return; obj = node * 8 + ((type == BG_BG_NODE_TYPE_OCCUPIED) ? (3 + teamIndex) : 5); SpawnBGObject(obj, RESPAWN_IMMEDIATELY); } void BattlegroundBG::_DelBanner (uint8 node, uint8 type, uint8 teamIndex) { uint8 obj = node * 8 + type + teamIndex; SpawnBGObject(obj, RESPAWN_ONE_DAY); // handle aura with banner if (!type) return; obj = node * 8 + ((type == BG_BG_NODE_TYPE_OCCUPIED) ? (3 + teamIndex) : 5); SpawnBGObject(obj, RESPAWN_ONE_DAY); } int32 BattlegroundBG::_GetNodeNameId (uint8 node) { switch (node) { case BG_BG_NODE_WATERWORKS: return LANG_BG_BG_NODE_WATERWORKS; case BG_BG_NODE_LIGHTHOUSE: return LANG_BG_BG_NODE_LIGHTHOUSE; case BG_BG_NODE_MINE: return LANG_BG_BG_NODE_MINE; default: ASSERT(0) ; } return 0; } void BattlegroundBG::FillInitialWorldStates (WorldPacket& data) { const uint8 plusArray[] = { 0, 2, 3, 0, 1 }; // Node icons for (uint8 node = 0; node < BG_BG_DYNAMIC_NODES_COUNT; ++node) data << uint32(BG_BG_OP_NODEICONS[node]) << uint32((m_Nodes[node] == 0) ? 1 : 0); // Node occupied states for (uint8 node = 0; node < BG_BG_DYNAMIC_NODES_COUNT; ++node) for (uint8 i = 1; i < BG_BG_DYNAMIC_NODES_COUNT; ++i) data << uint32(BG_BG_OP_NODESTATES[node] + plusArray[i]) << uint32((m_Nodes[node] == i) ? 1 : 0); // How many bases each team owns uint8 ally = 0, horde = 0; for (uint8 node = 0; node < BG_BG_DYNAMIC_NODES_COUNT; ++node) if (m_Nodes[node] == BG_BG_NODE_STATUS_ALLY_OCCUPIED) ++ally; else if (m_Nodes[node] == BG_BG_NODE_STATUS_HORDE_OCCUPIED) ++horde; data << uint32(BG_BG_OP_OCCUPIED_BASES_ALLY) << uint32(ally); data << uint32(BG_BG_OP_OCCUPIED_BASES_HORDE) << uint32(horde); // Team scores data << uint32(BG_BG_OP_RESOURCES_MAX) << uint32(BG_BG_MAX_TEAM_SCORE); data << uint32(BG_BG_OP_RESOURCES_WARNING) << uint32(BG_BG_WARNING_NEAR_VICTORY_SCORE); data << uint32(BG_BG_OP_RESOURCES_ALLY) << uint32(m_TeamScores[BG_TEAM_ALLIANCE]); data << uint32(BG_BG_OP_RESOURCES_HORDE) << uint32(m_TeamScores[BG_TEAM_HORDE]); // other unknown data << uint32(0x745) << uint32(0x2); // 37 1861 unk } void BattlegroundBG::_SendNodeUpdate (uint8 node) { // Send node owner state update to refresh map icons on client const uint8 plusArray[] = { 0, 2, 3, 0, 1 }; if (m_prevNodes[node]) UpdateWorldState(BG_BG_OP_NODESTATES[node] + plusArray[m_prevNodes[node]], 0); else UpdateWorldState(BG_BG_OP_NODEICONS[node], 0); UpdateWorldState(BG_BG_OP_NODESTATES[node] + plusArray[m_Nodes[node]], 1); // How many bases each team owns uint8 ally = 0, horde = 0; for (uint8 i = 0; i < BG_BG_DYNAMIC_NODES_COUNT; ++i) if (m_Nodes[i] == BG_BG_NODE_STATUS_ALLY_OCCUPIED) ++ally; else if (m_Nodes[i] == BG_BG_NODE_STATUS_HORDE_OCCUPIED) ++horde; UpdateWorldState(BG_BG_OP_OCCUPIED_BASES_ALLY, ally); UpdateWorldState(BG_BG_OP_OCCUPIED_BASES_HORDE, horde); } void BattlegroundBG::_NodeOccupied (uint8 node, Team team) { if (!AddSpiritGuide(node, BG_BG_SpiritGuidePos[node][0], BG_BG_SpiritGuidePos[node][1], BG_BG_SpiritGuidePos[node][2], BG_BG_SpiritGuidePos[node][3], team)) sLog->outError("Failed to spawn spirit guide! point: %u, team: %u, ", node, team); uint8 capturedNodes = 0; for (uint8 i = 0; i < BG_BG_DYNAMIC_NODES_COUNT; ++i) { if (m_Nodes[node] == GetTeamIndexByTeamId(team) + BG_BG_NODE_TYPE_OCCUPIED && !m_NodeTimers[i]) ++capturedNodes; } if (node >= BG_BG_DYNAMIC_NODES_COUNT) //only dynamic nodes, no start points return; Creature* trigger = GetBGCreature(node + 5); //0-6 spirit guides if (!trigger) trigger = AddCreature(WORLD_TRIGGER, node + 5, team, BG_BG_NodePositions[node][0], BG_BG_NodePositions[node][1], BG_BG_NodePositions[node][2], BG_BG_NodePositions[node][3]); //add bonus honor aura trigger creature when node is accupied //cast bonus aura (+50% honor in 25yards) //aura should only apply to players who have accupied the node, set correct faction for trigger if (trigger) { trigger->setFaction(team == ALLIANCE ? 84 : 83); trigger->CastSpell(trigger, SPELL_HONORABLE_DEFENDER_25Y, false); } } void BattlegroundBG::_NodeDeOccupied (uint8 node) { if (node >= BG_BG_DYNAMIC_NODES_COUNT) return; //remove bonus honor aura trigger creature when node is lost if (node < BG_BG_DYNAMIC_NODES_COUNT) //only dynamic nodes, no start points DelCreature(node + 7); //NULL checks are in DelCreature! 0-6 spirit guides // Those who are waiting to resurrect at this node are taken to the closest own node's graveyard std::vector<uint64> ghost_list = m_ReviveQueue[m_BgCreatures[node]]; if (!ghost_list.empty()) { WorldSafeLocsEntry const *ClosestGrave = NULL; for (std::vector<uint64>::const_iterator itr = ghost_list.begin(); itr != ghost_list.end(); ++itr) { Player* plr = sObjectMgr->GetPlayer(*itr); if (!plr) continue; if (!ClosestGrave) // cache ClosestGrave = GetClosestGraveYard(plr); if (ClosestGrave) plr->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, plr->GetOrientation()); } } if (m_BgCreatures[node]) DelCreature(node); // buff object isn't despawned } /* Invoked if a player used a banner as a gameobject */ void BattlegroundBG::EventPlayerClickedOnFlag (Player *source, GameObject* /*target_obj*/) { if (GetStatus() != STATUS_IN_PROGRESS) return; uint8 node = BG_BG_NODE_LIGHTHOUSE; GameObject* obj = GetBgMap()->GetGameObject(m_BgObjects[node * 8 + 5]); while ((node < BG_BG_DYNAMIC_NODES_COUNT) && ((!obj) || (!source->IsWithinDistInMap(obj, 10)))) { ++node; obj = GetBgMap()->GetGameObject(m_BgObjects[node * 8 + BG_BG_OBJECT_AURA_CONTESTED]); } if (node == BG_BG_DYNAMIC_NODES_COUNT) { sLog->outString("Player %s (GUID: %u) in Battle for Gilneas fired EventPlayerClickedOnFlag() but isn't near any flag", source->GetName(), source->GetGUIDLow()); // this means our player isn't close to any of banners - maybe cheater ?? return; } BattlegroundTeamId teamIndex = GetTeamIndexByTeamId(source->GetTeam()); // Check if player really could use this banner, not cheated if (!(m_Nodes[node] == 0 || teamIndex == m_Nodes[node] % 2)) return; source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); uint32 sound = 0; // If node is neutral, change to contested if (m_Nodes[node] == BG_BG_NODE_TYPE_NEUTRAL) { UpdatePlayerScore(source, SCORE_BASES_ASSAULTED, 1); m_prevNodes[node] = m_Nodes[node]; m_Nodes[node] = teamIndex + 1; // burn current neutral banner _DelBanner(node, BG_BG_NODE_TYPE_NEUTRAL, 0); // create new contested banner _CreateBanner(node, BG_BG_NODE_TYPE_CONTESTED, teamIndex, true); _SendNodeUpdate(node); m_NodeTimers[node] = BG_BG_FLAG_CAPTURING_TIME; // FIXME: team and node names not localized if (teamIndex == 0) SendMessage2ToAll(LANG_BG_AB_NODE_CLAIMED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node), LANG_BG_AB_ALLY); else SendMessage2ToAll(LANG_BG_AB_NODE_CLAIMED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node), LANG_BG_AB_HORDE); sound = BG_BG_SOUND_NODE_CLAIMED; } // If node is contested else if ((m_Nodes[node] == BG_BG_NODE_STATUS_ALLY_CONTESTED) || (m_Nodes[node] == BG_BG_NODE_STATUS_HORDE_CONTESTED)) { // If last state is NOT occupied, change node to enemy-contested if (m_prevNodes[node] < BG_BG_NODE_TYPE_OCCUPIED) { UpdatePlayerScore(source, SCORE_BASES_ASSAULTED, 1); m_prevNodes[node] = m_Nodes[node]; m_Nodes[node] = teamIndex + BG_BG_NODE_TYPE_CONTESTED; // burn current contested banner _DelBanner(node, BG_BG_NODE_TYPE_CONTESTED, !teamIndex); // create new contested banner _CreateBanner(node, BG_BG_NODE_TYPE_CONTESTED, teamIndex, true); _SendNodeUpdate(node); m_NodeTimers[node] = BG_BG_FLAG_CAPTURING_TIME; // FIXME: node names not localized if (teamIndex == BG_TEAM_ALLIANCE) SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node)); else SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); } // If contested, change back to occupied else { UpdatePlayerScore(source, SCORE_BASES_DEFENDED, 1); m_prevNodes[node] = m_Nodes[node]; m_Nodes[node] = teamIndex + BG_BG_NODE_TYPE_OCCUPIED; // burn current contested banner _DelBanner(node, BG_BG_NODE_TYPE_CONTESTED, !teamIndex); // create new occupied banner _CreateBanner(node, BG_BG_NODE_TYPE_OCCUPIED, teamIndex, true); _SendNodeUpdate(node); m_NodeTimers[node] = 0; _NodeOccupied(node, (teamIndex == BG_TEAM_ALLIANCE) ? ALLIANCE : HORDE); // FIXME: node names not localized if (teamIndex == BG_TEAM_ALLIANCE) SendMessage2ToAll(LANG_BG_AB_NODE_DEFENDED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node)); else SendMessage2ToAll(LANG_BG_AB_NODE_DEFENDED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); } sound = (teamIndex == BG_TEAM_ALLIANCE) ? BG_BG_SOUND_NODE_ASSAULTED_ALLIANCE : BG_BG_SOUND_NODE_ASSAULTED_HORDE; } // If node is occupied, change to enemy-contested else { UpdatePlayerScore(source, SCORE_BASES_ASSAULTED, 1); m_prevNodes[node] = m_Nodes[node]; m_Nodes[node] = teamIndex + BG_BG_NODE_TYPE_CONTESTED; // burn current occupied banner _DelBanner(node, BG_BG_NODE_TYPE_OCCUPIED, !teamIndex); // create new contested banner _CreateBanner(node, BG_BG_NODE_TYPE_CONTESTED, teamIndex, true); _SendNodeUpdate(node); _NodeDeOccupied(node); m_NodeTimers[node] = BG_BG_FLAG_CAPTURING_TIME; // FIXME: node names not localized if (teamIndex == BG_TEAM_ALLIANCE) SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node)); else SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); sound = (teamIndex == BG_TEAM_ALLIANCE) ? BG_BG_SOUND_NODE_ASSAULTED_ALLIANCE : BG_BG_SOUND_NODE_ASSAULTED_HORDE; } // If node is occupied again, send "X has taken the Y" msg. if (m_Nodes[node] >= BG_BG_NODE_TYPE_OCCUPIED) { // FIXME: team and node names not localized if (teamIndex == BG_TEAM_ALLIANCE) SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL, LANG_BG_AB_ALLY, _GetNodeNameId(node)); else SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_HORDE, NULL, LANG_BG_AB_HORDE, _GetNodeNameId(node)); } PlaySoundToAll(sound); } bool BattlegroundBG::SetupBattleground () { for (int i = 0; i < BG_BG_DYNAMIC_NODES_COUNT; ++i) { if (!AddObject(BG_BG_OBJECT_BANNER_NEUTRAL + 8 * i, BG_BG_OBJECTID_NODE_BANNER_0 + i, BG_BG_NodePositions[i][0], BG_BG_NodePositions[i][1], BG_BG_NodePositions[i][2], BG_BG_NodePositions[i][3], 0, 0, sin(BG_BG_NodePositions[i][3] / 2), cos(BG_BG_NodePositions[i][3] / 2), RESPAWN_ONE_DAY) || !AddObject(BG_BG_OBJECT_BANNER_CONT_A + 8 * i, BG_BG_OBJECTID_BANNER_CONT_A, BG_BG_NodePositions[i][0], BG_BG_NodePositions[i][1], BG_BG_NodePositions[i][2], BG_BG_NodePositions[i][3], 0, 0, sin(BG_BG_NodePositions[i][3] / 2), cos(BG_BG_NodePositions[i][3] / 2), RESPAWN_ONE_DAY) || !AddObject(BG_BG_OBJECT_BANNER_CONT_H + 8 * i, BG_BG_OBJECTID_BANNER_CONT_H, BG_BG_NodePositions[i][0], BG_BG_NodePositions[i][1], BG_BG_NodePositions[i][2], BG_BG_NodePositions[i][3], 0, 0, sin(BG_BG_NodePositions[i][3] / 2), cos(BG_BG_NodePositions[i][3] / 2), RESPAWN_ONE_DAY) || !AddObject(BG_BG_OBJECT_BANNER_ALLY + 8 * i, BG_BG_OBJECTID_BANNER_A, BG_BG_NodePositions[i][0], BG_BG_NodePositions[i][1], BG_BG_NodePositions[i][2], BG_BG_NodePositions[i][3], 0, 0, sin(BG_BG_NodePositions[i][3] / 2), cos(BG_BG_NodePositions[i][3] / 2), RESPAWN_ONE_DAY) || !AddObject(BG_BG_OBJECT_BANNER_HORDE + 8 * i, BG_BG_OBJECTID_BANNER_H, BG_BG_NodePositions[i][0], BG_BG_NodePositions[i][1], BG_BG_NodePositions[i][2], BG_BG_NodePositions[i][3], 0, 0, sin(BG_BG_NodePositions[i][3] / 2), cos(BG_BG_NodePositions[i][3] / 2), RESPAWN_ONE_DAY) || !AddObject(BG_BG_OBJECT_AURA_ALLY + 8 * i, BG_BG_OBJECTID_AURA_A, BG_BG_NodePositions[i][0], BG_BG_NodePositions[i][1], BG_BG_NodePositions[i][2], BG_BG_NodePositions[i][3], 0, 0, sin(BG_BG_NodePositions[i][3] / 2), cos(BG_BG_NodePositions[i][3] / 2), RESPAWN_ONE_DAY) || !AddObject(BG_BG_OBJECT_AURA_HORDE + 8 * i, BG_BG_OBJECTID_AURA_H, BG_BG_NodePositions[i][0], BG_BG_NodePositions[i][1], BG_BG_NodePositions[i][2], BG_BG_NodePositions[i][3], 0, 0, sin(BG_BG_NodePositions[i][3] / 2), cos(BG_BG_NodePositions[i][3] / 2), RESPAWN_ONE_DAY) || !AddObject(BG_BG_OBJECT_AURA_CONTESTED + 8 * i, BG_BG_OBJECTID_AURA_C, BG_BG_NodePositions[i][0], BG_BG_NodePositions[i][1], BG_BG_NodePositions[i][2], BG_BG_NodePositions[i][3], 0, 0, sin(BG_BG_NodePositions[i][3] / 2), cos(BG_BG_NodePositions[i][3] / 2), RESPAWN_ONE_DAY)) { sLog->outErrorDb("BatteGroundBG: Failed to spawn some objects, Battleground not created!"); return false; } } if (!AddObject(BG_BG_OBJECT_GATE_A, BG_BG_OBJECTID_GATE_A, BG_BG_DoorPositions[0][0], BG_BG_DoorPositions[0][1], BG_BG_DoorPositions[0][2], BG_BG_DoorPositions[0][3], BG_BG_DoorPositions[0][4], BG_BG_DoorPositions[0][5], BG_BG_DoorPositions[0][6], BG_BG_DoorPositions[0][7], RESPAWN_IMMEDIATELY) || !AddObject(BG_BG_OBJECT_GATE_H, BG_BG_OBJECTID_GATE_H, BG_BG_DoorPositions[1][0], BG_BG_DoorPositions[1][1], BG_BG_DoorPositions[1][2], BG_BG_DoorPositions[1][3], BG_BG_DoorPositions[1][4], BG_BG_DoorPositions[1][5], BG_BG_DoorPositions[1][6], BG_BG_DoorPositions[1][7], RESPAWN_IMMEDIATELY)) { sLog->outErrorDb("BatteGroundBG: Failed to spawn door object, Battleground not created!"); return false; } //buffs for (int i = 0; i < BG_BG_DYNAMIC_NODES_COUNT; ++i) { if (!AddObject(BG_BG_OBJECT_SPEEDBUFF_LIGHTHOUSE + 3 * i, Buff_Entries[0], BG_BG_BuffPositions[i][0], BG_BG_BuffPositions[i][1], BG_BG_BuffPositions[i][2], BG_BG_BuffPositions[i][3], 0, 0, sin(BG_BG_BuffPositions[i][3] / 2), cos(BG_BG_BuffPositions[i][3] / 2), RESPAWN_ONE_DAY) || !AddObject(BG_BG_OBJECT_SPEEDBUFF_LIGHTHOUSE + 3 * i + 1, Buff_Entries[1], BG_BG_BuffPositions[i][0], BG_BG_BuffPositions[i][1], BG_BG_BuffPositions[i][2], BG_BG_BuffPositions[i][3], 0, 0, sin(BG_BG_BuffPositions[i][3] / 2), cos(BG_BG_BuffPositions[i][3] / 2), RESPAWN_ONE_DAY) || !AddObject(BG_BG_OBJECT_SPEEDBUFF_LIGHTHOUSE + 3 * i + 2, Buff_Entries[2], BG_BG_BuffPositions[i][0], BG_BG_BuffPositions[i][1], BG_BG_BuffPositions[i][2], BG_BG_BuffPositions[i][3], 0, 0, sin(BG_BG_BuffPositions[i][3] / 2), cos(BG_BG_BuffPositions[i][3] / 2), RESPAWN_ONE_DAY)) sLog->outErrorDb("BatteGroundBG: Failed to spawn buff object!"); } return true; } void BattlegroundBG::Reset () { //call parent's class reset Battleground::Reset(); m_TeamScores[BG_TEAM_ALLIANCE] = 0; m_TeamScores[BG_TEAM_HORDE] = 0; m_lastTick[BG_TEAM_ALLIANCE] = 0; m_lastTick[BG_TEAM_HORDE] = 0; m_HonorScoreTics[BG_TEAM_ALLIANCE] = 0; m_HonorScoreTics[BG_TEAM_HORDE] = 0; m_IsInformedNearVictory = false; bool isBGWeekend = sBattlegroundMgr->IsBGWeekend(GetTypeID()); m_HonorTics = (isBGWeekend) ? BG_BG_BGBGWeekendHonorTicks : BG_BG_NotBGBGWeekendHonorTicks; m_TeamScores500Disadvantage[BG_TEAM_ALLIANCE] = false; m_TeamScores500Disadvantage[BG_TEAM_HORDE] = false; for (uint8 i = 0; i < BG_BG_DYNAMIC_NODES_COUNT; ++i) { m_Nodes[i] = 0; m_prevNodes[i] = 0; m_NodeTimers[i] = 0; m_BannerTimers[i].timer = 0; } for (uint8 i = 0; i < BG_BG_ALL_NODES_COUNT + 3; ++i) //+3 for aura triggers if (m_BgCreatures[i]) DelCreature(i); } void BattlegroundBG::EndBattleground (uint32 winner) { //win reward if (winner == ALLIANCE) RewardHonorToTeam(GetBonusHonorFromKill(1), ALLIANCE); if (winner == HORDE) RewardHonorToTeam(GetBonusHonorFromKill(1), HORDE); //complete map_end rewards (even if no team wins) RewardHonorToTeam(GetBonusHonorFromKill(1), HORDE); RewardHonorToTeam(GetBonusHonorFromKill(1), ALLIANCE); Battleground::EndBattleground(winner); } WorldSafeLocsEntry const* BattlegroundBG::GetClosestGraveYard (Player* player) { BattlegroundTeamId teamIndex = GetTeamIndexByTeamId(player->GetTeam()); // Is there any occupied node for this team? std::vector<uint8> nodes; for (uint8 i = 0; i < BG_BG_DYNAMIC_NODES_COUNT; ++i) if (m_Nodes[i] == teamIndex + 3) nodes.push_back(i); WorldSafeLocsEntry const* good_entry = NULL; // If so, select the closest node to place ghost on if (!nodes.empty()) { float plr_x = player->GetPositionX(); float plr_y = player->GetPositionY(); float mindist = 999999.0f; for (uint8 i = 0; i < nodes.size(); ++i) { WorldSafeLocsEntry const*entry = sWorldSafeLocsStore.LookupEntry(BG_BG_GraveyardIds[nodes[i]]); if (!entry) continue; float dist = (entry->x - plr_x) * (entry->x - plr_x) + (entry->y - plr_y) * (entry->y - plr_y); if (mindist > dist) { mindist = dist; good_entry = entry; } } nodes.clear(); } // If not, place ghost on starting location if (!good_entry) good_entry = sWorldSafeLocsStore.LookupEntry(BG_BG_GraveyardIds[teamIndex + 3]); return good_entry; } void BattlegroundBG::UpdatePlayerScore (Player *Source, uint32 type, uint32 value, bool doAddHonor) { BattlegroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetGUID()); if (itr == m_PlayerScores.end()) // player not found... return; switch (type) { case SCORE_BASES_ASSAULTED: ((BattlegroundBGScore*) itr->second)->BasesAssaulted += value; Source->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, BG_OBJECTIVE_ASSAULT_BASE); break; case SCORE_BASES_DEFENDED: ((BattlegroundBGScore*) itr->second)->BasesDefended += value; Source->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, BG_OBJECTIVE_DEFEND_BASE); break; default: Battleground::UpdatePlayerScore(Source, type, value, doAddHonor); break; } } bool BattlegroundBG::IsAllNodesConrolledByTeam (uint32 team) const { uint32 count = 0; for (int i = 0; i < BG_BG_DYNAMIC_NODES_COUNT; ++i) if ((team == ALLIANCE && m_Nodes[i] == BG_BG_NODE_STATUS_ALLY_OCCUPIED) || (team == HORDE && m_Nodes[i] == BG_BG_NODE_STATUS_HORDE_OCCUPIED)) ++count; return count == BG_BG_DYNAMIC_NODES_COUNT; }
43.248895
2,238
0.657189
Frankenhooker
733daf02579f5fe384df00ed67128d6fdd6be52f
2,362
hh
C++
src/mem/cache/split_mshr_cache.hh
xiaoyaozi5566/DynamicCache
250e7a901f3244f69d0c8de4d3f525a92dbfaac5
[ "BSD-3-Clause" ]
null
null
null
src/mem/cache/split_mshr_cache.hh
xiaoyaozi5566/DynamicCache
250e7a901f3244f69d0c8de4d3f525a92dbfaac5
[ "BSD-3-Clause" ]
null
null
null
src/mem/cache/split_mshr_cache.hh
xiaoyaozi5566/DynamicCache
250e7a901f3244f69d0c8de4d3f525a92dbfaac5
[ "BSD-3-Clause" ]
1
2021-07-05T18:02:56.000Z
2021-07-05T18:02:56.000Z
#include "mem/cache/base.hh" #include "mem/cache/cache.hh" #include "params/BaseCache.hh" #include "stdio.h" typedef BaseCacheParams Params; template <class TagStore> class SplitMSHRCache : public Cache<TagStore> { typedef typename Cache<TagStore>::MemSidePacketQueue MemSidePacketQueue; private: MSHRQueue** mshrQueues; MSHRQueue** writeBuffers; int num_tcs; public: SplitMSHRCache( const Params *p, TagStore *tags ); protected: class SplitMemSidePort : public Cache<TagStore>::MemSidePort{ private: MasterPacketQueue** reqQueues; int num_tcs; public: virtual void recvRetry(){ for( int i=0; i < num_tcs; i++) recvRetry(i); } virtual void recvRetry( int threadID ){ this->reqQueues[threadID]->retry(); } virtual void requestBus(BaseCache::RequestCause cause, Tick time, int threadID, bool isInteresting){ DPRINTF(CachePort, "Asserting bus request for cause %d\n", cause); // if( isInteresting ){ // printf( "interesting in split requestBus with time %lu\n", time ); // if( reqQueues[threadID]->sendEvent.scheduled() ){ // printf( "sendEvent was already scheduled at %lu\n", // reqQueues[threadID]->sendEvent.when() ); // } else { // printf("scheduled at time %lu\n", time); // } // } reqQueues[threadID]->schedSendEvent(time, isInteresting); } SplitMemSidePort(const std::string &_name, Cache<TagStore> *_cache, const std::string &_label) : Cache<TagStore>::MemSidePort( _name, _cache, _label ){ num_tcs = _cache->params->num_tcs; this->reqQueues = new MasterPacketQueue*[_cache->params->num_tcs]; for( int i=0; i < (_cache->params->num_tcs); i++){ this->reqQueues[i] = new MemSidePacketQueue( *_cache, *this, "MasterPacketQueue", i); } } }; virtual MSHRQueue* getMSHRQueue( int threadID ){ return mshrQueues[threadID]; } virtual MSHRQueue* getWriteBuffer( int threadID ){ return writeBuffers[threadID]; } //virtual bool isSplitMSHR() {return true;} virtual int get_num_tcs() {return num_tcs;} };
32.805556
83
0.596528
xiaoyaozi5566
7340d6cd0c5a3f2220523abb7f0dc6014eaf6324
3,550
cpp
C++
romsel_aktheme/arm9/source/windows/smallclock.cpp
ccccmark/TWiLightMenu
1c7ac841044e042829313d8e9d54f1f790d5ac58
[ "MIT" ]
null
null
null
romsel_aktheme/arm9/source/windows/smallclock.cpp
ccccmark/TWiLightMenu
1c7ac841044e042829313d8e9d54f1f790d5ac58
[ "MIT" ]
null
null
null
romsel_aktheme/arm9/source/windows/smallclock.cpp
ccccmark/TWiLightMenu
1c7ac841044e042829313d8e9d54f1f790d5ac58
[ "MIT" ]
null
null
null
/* smallclock.cpp Copyright (C) 2007 Acekard, www.acekard.com Copyright (C) 2007-2009 somebody Copyright (C) 2009 yellow wood goblin This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 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 "smallclock.h" #include "tool/stringtool.h" #include "systemfilenames.h" #include "ui/windowmanager.h" #include "common/inifile.h" #include "common/dsimenusettings.h" using namespace akui; SmallClock::SmallClock() : Window(NULL, "small clock") { _size = Size(0, 0); _position = Point(8, 80); _engine = GE_SUB; _show = false; _colonShow = false; _ampmShow = false; _ampmColor = RGB15(17, 12, 0); } void SmallClock::init() { loadAppearance(SFN_UI_SETTINGS); } Window &SmallClock::loadAppearance(const std::string &aFileName) { CIniFile ini(aFileName); _position.x = ini.GetInt("small clock", "x", 8); _position.y = ini.GetInt("small clock", "y", 80); _show = ini.GetInt("small clock", "show", _show); _ampmPosition.x = ini.GetInt("am pm", "x", 8); _ampmPosition.y = ini.GetInt("am pm", "y", 80); _ampmShow = ini.GetInt("am pm", "show", _ampmShow); _ampmColor = ini.GetInt("am pm", "color", _ampmColor); _numbers = createBMP15FromFile(SFN_CLOCK_NUMBERS_2); _colon = createBMP15FromFile(SFN_CLOCK_COLON_2); return *this; } void SmallClock::drawNumber(u8 id, u8 number) { if (number > 10) return; u8 x = _position.x + id * (_numbers.width()); if (id > 2) { // minute number x -= 2; } if (_numbers.valid()) { u8 w = _numbers.width(); u8 h = _numbers.height() / 10; u8 pitch = _numbers.pitch() >> 1; gdi().maskBlt(_numbers.buffer() + number * pitch * h / 2, x, _position.y, w, h, selectedEngine()); } } void SmallClock::drawColon() { u8 x = _position.x + 2 * _numbers.width(); if (_colon.valid()) { gdi().maskBlt(_colon.buffer(), x-1, _position.y, _colon.width(), _colon.height(), selectedEngine()); } } void SmallClock::draw() { if (!_show) return; u8 hours = datetime().hours(); u8 minutes = datetime().minutes(); const char *ampm = (hours < 12) ? "AM" : "PM"; if (ms().show12hrClock) { if (hours > 12) hours -= 12; if (hours == 0) hours = 12; } u8 number1 = hours / 10; u8 number2 = hours % 10; u8 number3 = minutes / 10; u8 number4 = minutes % 10; //u8 number5 = datetime().seconds() / 10; //u8 number6 = datetime().seconds() % 10; drawNumber(0, number1); drawNumber(1, number2); drawNumber(3, number3); drawNumber(4, number4); if (_colonShow) drawColon(); if (ms().show12hrClock && _ampmShow) { gdi().setPenColor(_ampmColor, _engine); gdi().textOut(_ampmPosition.x, _ampmPosition.y, ampm, _engine); } } void SmallClock::blinkColon() { _colonShow = !_colonShow; }
26.893939
106
0.62169
ccccmark