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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
06c8b1aeab39e7a6a391249500899b4a07e30588
| 420
|
cpp
|
C++
|
src/src/XESystem/QueueManager.cpp
|
devxkh/FrankE
|
72faca02759b54aaec842831f3c7a051e7cf5335
|
[
"MIT"
] | 11
|
2017-01-17T15:02:25.000Z
|
2020-11-27T16:54:42.000Z
|
src/src/XESystem/QueueManager.cpp
|
devxkh/FrankE
|
72faca02759b54aaec842831f3c7a051e7cf5335
|
[
"MIT"
] | 9
|
2016-10-23T20:15:38.000Z
|
2018-02-06T11:23:17.000Z
|
src/src/XESystem/QueueManager.cpp
|
devxkh/FrankE
|
72faca02759b54aaec842831f3c7a051e7cf5335
|
[
"MIT"
] | 2
|
2019-08-29T10:23:51.000Z
|
2020-04-03T06:08:34.000Z
|
#include <XESystem/QueueManager.hpp>
namespace XE
{
QueueManager::QueueManager()
: m_rwqueue(500)
{
}
void QueueManager::push(OnFunctionHandler Handler)
{
bool succeeded = m_rwqueue.enqueue(Handler);
}
void QueueManager::TriggerAllHandler(sf::Uint16 max)
{
OnFunctionHandler tmp;
while (m_rwqueue.peek() && max > 0)
{
bool succeeded = m_rwqueue.try_dequeue(tmp);
tmp();
max--;
}
}
}
| 14.482759
| 53
| 0.678571
|
devxkh
|
06cc382b8032aa3a6239cc9a6cb94f4cce75a7d0
| 7,457
|
cpp
|
C++
|
benchmarks/sso.cpp
|
Wentzell/nda
|
69106a64799e7942bf4b1b78fdadf3e7c9477c70
|
[
"Apache-2.0"
] | 3
|
2021-05-26T08:53:25.000Z
|
2021-06-13T00:39:10.000Z
|
benchmarks/sso.cpp
|
smile1103/nda
|
ff2239b910a5964942833e07d282a8cea32cb6fa
|
[
"Apache-2.0"
] | 10
|
2020-08-11T21:02:47.000Z
|
2022-01-26T19:21:34.000Z
|
benchmarks/sso.cpp
|
smile1103/nda
|
ff2239b910a5964942833e07d282a8cea32cb6fa
|
[
"Apache-2.0"
] | 4
|
2021-05-24T12:43:08.000Z
|
2022-02-28T01:33:03.000Z
|
// Copyright (c) 2020 Simons Foundation
//
// 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.txt
//
// 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 "./bench_common.hpp"
static void dyn_alloc(benchmark::State &state) {
const int N = state.range(0);
while (state.KeepRunning()) { nda::array<double, 1> A(N); }
}
BENCHMARK(dyn_alloc)->Arg(1)->Arg(2)->Arg(3)->Arg(4)->Arg(10)->Arg(15); //->Arg(30)->Arg(50)->Arg(100)->Arg(500);
//static void dyn_alloc_and_loop(benchmark::State &state) {
//const int N = state.range(0);
//while (state.KeepRunning()) {
//nda::array<double, 1> A(N);
//for (int i = 0; i < N - 1; ++i) benchmark::DoNotOptimize(A(i) = i);//fnt(i));
//}
//}
//BENCHMARK(dyn_alloc_and_loop)->Arg(1)->Arg(2)->Arg(3)->Arg(4)->Arg(10)->Arg(15);//->Arg(30)->Arg(50)->Arg(100)->Arg(500);
static void dyn_loop_only(benchmark::State &state) {
const int N = state.range(0);
nda::array<double, 1> A(N);
while (state.KeepRunning()) {
for (int i = 0; i < N - 1; ++i) benchmark::DoNotOptimize(A(i) = i); //fnt(i));
}
}
BENCHMARK(dyn_loop_only)->Arg(1)->Arg(2)->Arg(3)->Arg(4)->Arg(10)->Arg(15); //->Arg(30)->Arg(50)->Arg(100)->Arg(500);
// ------------------
static void sso_alloc(benchmark::State &state) {
const int N = state.range(0);
using a_t = nda::basic_array<long, 1, nda::C_layout, 'A', nda::sso<100>>;
while (state.KeepRunning()) {
a_t A(N);
benchmark::DoNotOptimize(A(0));
}
}
BENCHMARK(sso_alloc)->Arg(1)->Arg(2)->Arg(3)->Arg(4)->Arg(10)->Arg(15); //->Arg(30)->Arg(50)->Arg(100);//->Arg(500);
/*static void sso_alloc_handle(benchmark::State &state) {*/
//const int N = state.range(0);
//using a_t = nda::basic_array<long, 1, nda::C_layout, 'A', nda::sso<100>>;
//while (state.KeepRunning()) {
//benchmark::DoNotOptimize(A(0));
//}
//}
//BENCHMARK(sso_alloc_handle)->Arg(1)->Arg(2)->Arg(3)->Arg(4)->Arg(10)->Arg(15);//->Arg(30)->Arg(50)->Arg(100);//->Arg(500);
//static void sso_alloc_and_loop(benchmark::State &state) {
//const int N = state.range(0);
//using a_t = nda::basic_array<long, 1, nda::C_layout, 'A', nda::sso<15>>;
//while (state.KeepRunning()) {
//a_t A(N);
//for (int i = 0; i < N - 1; ++i) benchmark::DoNotOptimize(A(i) = i);//fnt(i));
//}
//}
//BENCHMARK(sso_alloc_and_loop)->Arg(1)->Arg(2)->Arg(3)->Arg(4)->Arg(10)->Arg(15);//->Arg(30)->Arg(50)->Arg(100);//->Arg(500);
static void sso_loop_only(benchmark::State &state) {
const int N = state.range(0);
using a_t = nda::basic_array<long, 1, nda::C_layout, 'A', nda::sso<100>>;
a_t A(N);
while (state.KeepRunning()) {
for (int i = 0; i < N - 1; ++i) benchmark::DoNotOptimize(A(i) = i); //fnt(i));
}
}
BENCHMARK(sso_loop_only)->Arg(1)->Arg(2)->Arg(3)->Arg(4)->Arg(10)->Arg(15)->Arg(100); //->Arg(30)->Arg(50)->Arg(100);//->Arg(500);
static void sso_loop_only_restrict(benchmark::State &state) {
const int N = state.range(0);
using a_t = nda::basic_array<long, 1, nda::C_layout, 'A', nda::sso<100>>;
a_t A(N);
nda::basic_array_view<long, 1, nda::C_layout, 'A', nda::no_alias_accessor, nda::borrowed> v{A};
//nda::basic_array_view<long, 1, nda::C_layout, 'A', nda::default_accessor, nda::borrowed> v{A};
while (state.KeepRunning()) {
for (int i = 0; i < N - 1; ++i) benchmark::DoNotOptimize(v(i) = i); //fnt(i));
}
}
BENCHMARK(sso_loop_only_restrict)->Arg(1)->Arg(2)->Arg(3)->Arg(4)->Arg(10)->Arg(15)->Arg(100); //->Arg(30)->Arg(50)->Arg(100);//->Arg(500);
// ------------------
static void stack_alloc(benchmark::State &state) {
const int N = state.range(0);
while (state.KeepRunning()) {
nda::stack_array<long, 1, nda::static_extents(15)> A(N);
benchmark::DoNotOptimize(A(0));
}
}
BENCHMARK(stack_alloc)->Arg(1)->Arg(2)->Arg(3)->Arg(4)->Arg(10)->Arg(15); //->Arg(30)->Arg(50)->Arg(100);//->Arg(500);
//static void stack_alloc_and_loop(benchmark::State &state) {
//const int N = state.range(0);
//while (state.KeepRunning()) {
//nda::stack_array<long, 1, nda::static_extents(15)> A(N);
//for (int i = 0; i < N - 1; ++i) benchmark::DoNotOptimize(A(i) = i);//fnt(i));
//}
//}
//BENCHMARK(stack_alloc_and_loop)->Arg(1)->Arg(2)->Arg(3)->Arg(4)->Arg(10)->Arg(15);//->Arg(30)->Arg(50)->Arg(100);//->Arg(500);
static void stack_loop_only(benchmark::State &state) {
const int N = state.range(0);
nda::stack_array<long, 1, nda::static_extents(15)> A(N);
nda::basic_array_view<long, 1, nda::C_layout, 'A', nda::no_alias_accessor, nda::borrowed> v{A};
while (state.KeepRunning()) {
for (int i = 0; i < N - 1; ++i) benchmark::DoNotOptimize(A(i) = i); //fnt(i));
//for (int i = 0; i < N - 1; ++i) benchmark::DoNotOptimize(v(i) = i);//fnt(i));
}
}
BENCHMARK(stack_loop_only)->Arg(1)->Arg(2)->Arg(3)->Arg(4)->Arg(10)->Arg(15); //->Arg(30)->Arg(50)->Arg(100);//->Arg(500);
// ------------------
using alloc_t = nda::mem::segregator<8 * 100, nda::mem::multiple_bucket<8 * 100>, nda::mem::mallocator>;
static void mbucket_alloc(benchmark::State &state) {
const int N = state.range(0);
while (state.KeepRunning()) {
nda::basic_array<long, 1, nda::C_layout, 'A', nda::heap_custom_alloc<alloc_t>> A(N);
benchmark::DoNotOptimize(A(0));
}
}
BENCHMARK(mbucket_alloc)->Arg(1)->Arg(2)->Arg(3)->Arg(4)->Arg(10)->Arg(15); //->Arg(30)->Arg(50)->Arg(100);//->Arg(500);
#if 0
// -------- 2d------------
static void dyn_alloc2d(benchmark::State &state) {
const int N = state.range(0);
while (state.KeepRunning()) {
nda::array<double, 2> A(N,N);
for (int i = 0; i < N - 1; ++i)
for (int j = 0; j < N - 1; ++j) benchmark::DoNotOptimize(A(i,j) = i+2*j);//fnt(i));
}
}
BENCHMARK(dyn_alloc2d)->Arg(1)->Arg(2)->Arg(3)->Arg(4)->Arg(10)->Arg(15);//->Arg(30)->Arg(50)->Arg(100)->Arg(500);
static void stack_alloc2d(benchmark::State &state) {
const int N = state.range(0);
while (state.KeepRunning()) {
nda::stack_array<double, 2, nda::static_extents(15,15)> A;
for (int i = 0; i < N - 1; ++i)
for (int j = 0; j < N - 1; ++j) benchmark::DoNotOptimize(A(i,j) = i+2*j);//fnt(i));
}
}
BENCHMARK(stack_alloc2d)->Arg(1)->Arg(2)->Arg(3)->Arg(4)->Arg(10)->Arg(15);//->Arg(30)->Arg(50)->Arg(100);//->Arg(500);
static void dyn_alloc2d_loop_only(benchmark::State &state) {
const int N = state.range(0);
nda::array<double, 2> A(N,N);
while (state.KeepRunning()) {
for (int i = 0; i < N - 1; ++i)
for (int j = 0; j < N - 1; ++j) benchmark::DoNotOptimize(A(i,j) = i+2*j);//fnt(i));
}
}
BENCHMARK(dyn_alloc2d_loop_only)->Arg(1)->Arg(2)->Arg(3)->Arg(4)->Arg(10)->Arg(15);//->Arg(30)->Arg(50)->Arg(100)->Arg(500);
static void stack_alloc2d_loop_only(benchmark::State &state) {
const int N = state.range(0);
nda::stack_array<double, 2, nda::static_extents(15,15)> A;
while (state.KeepRunning()) {
for (int i = 0; i < N - 1; ++i)
for (int j = 0; j < N - 1; ++j) benchmark::DoNotOptimize(A(i,j) = i+2*j);//fnt(i));
}
}
BENCHMARK(stack_alloc2d_loop_only)->Arg(1)->Arg(2)->Arg(3)->Arg(4)->Arg(10)->Arg(15);//->Arg(30)->Arg(50)->Arg(100);//->Arg(500);
#endif
| 37.472362
| 139
| 0.610701
|
Wentzell
|
06cc90626241a950f8c5956a6e4cc5e3863eb823
| 634
|
hpp
|
C++
|
qubus/include/qubus/scheduling/round_robin_scheduler.hpp
|
qubusproject/Qubus
|
0feb8d6df00459c5af402545dbe7c82ee3ec4b7c
|
[
"BSL-1.0"
] | null | null | null |
qubus/include/qubus/scheduling/round_robin_scheduler.hpp
|
qubusproject/Qubus
|
0feb8d6df00459c5af402545dbe7c82ee3ec4b7c
|
[
"BSL-1.0"
] | null | null | null |
qubus/include/qubus/scheduling/round_robin_scheduler.hpp
|
qubusproject/Qubus
|
0feb8d6df00459c5af402545dbe7c82ee3ec4b7c
|
[
"BSL-1.0"
] | null | null | null |
#ifndef QUBUS_SCHEDULING_ROUND_ROBIN_SCHEDULER_HPP
#define QUBUS_SCHEDULING_ROUND_ROBIN_SCHEDULER_HPP
#include <qubus/scheduling/scheduler.hpp>
#include <hpx/include/lcos.hpp>
#include <vector>
namespace qubus
{
class round_robin_scheduler final : public scheduler
{
public:
virtual ~round_robin_scheduler() = default;
hpx::future<void> schedule(const symbol_id& func, execution_context ctx) override;
void add_resource(vpu &execution_resource) override;
private:
std::vector<vpu *> execution_resources_;
std::size_t next_endpoint_ = 0;
mutable hpx::lcos::local::mutex scheduling_mutex_;
};
}
#endif
| 20.451613
| 86
| 0.771293
|
qubusproject
|
06d26b0b39ef546f92e2d4dfc09ad3003b2271cb
| 913
|
cpp
|
C++
|
Subset Sums.cpp
|
Eggag/USACO
|
05eb5ebd73652ea5718e8e5832fac5ee3e946ccb
|
[
"MIT"
] | 8
|
2018-10-27T04:29:01.000Z
|
2021-11-29T05:48:06.000Z
|
Subset Sums.cpp
|
Eggag/USACO
|
05eb5ebd73652ea5718e8e5832fac5ee3e946ccb
|
[
"MIT"
] | null | null | null |
Subset Sums.cpp
|
Eggag/USACO
|
05eb5ebd73652ea5718e8e5832fac5ee3e946ccb
|
[
"MIT"
] | null | null | null |
/*
ID: egor_ga1
PROG: subset
LANG: C++11
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define all(v) v.begin(), v.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
freopen("subset.in", "r", stdin);
freopen("subset.out", "w", stdout);
//This is a classic DP problem
ll n;
cin >> n;
ll ways[1000];
ways[0] = 1;
//If the sum of the sequence is odd, we can't split into 2 equal subsets
if(((n * (n + 1)) / 2) % 2 != 0){
cout << "0" << endl;
return 0;
}
for(int i = 1; i <= n; i++){
for(int j = (n * (n + 1))/2; j >= i; j--){
ways[j] += ways[j - i];
}
}
cout << ways[n * (n + 1)/4]/2 << endl;
return 0;
}
/*
Things to look out for:
- Integer overflows
- Array bounds
- Special cases
Be careful!
*/
| 19.020833
| 73
| 0.588171
|
Eggag
|
06d3e7f0c59cfbe1c429f0a5f2f98cd785a1440d
| 2,201
|
cpp
|
C++
|
PiratesEngine/src/Platform/OpenGl/OpenGLVertexArray.cpp
|
michaelzaki-12/PiratesEngine
|
69e875eb2d21350c499245316351552bc217cbcb
|
[
"MIT"
] | null | null | null |
PiratesEngine/src/Platform/OpenGl/OpenGLVertexArray.cpp
|
michaelzaki-12/PiratesEngine
|
69e875eb2d21350c499245316351552bc217cbcb
|
[
"MIT"
] | null | null | null |
PiratesEngine/src/Platform/OpenGl/OpenGLVertexArray.cpp
|
michaelzaki-12/PiratesEngine
|
69e875eb2d21350c499245316351552bc217cbcb
|
[
"MIT"
] | null | null | null |
#include "PEPCH.h"
#include "OpenGLVertexArray.h"
#include <GLAD/glad.h>
namespace Pirates
{
static GLenum ShaderDataTypeToOpenGLBaseType(ShaderDataType type)
{
switch (type)
{
case Pirates::ShaderDataType::None:
case Pirates::ShaderDataType::Float: return GL_FLOAT;
case Pirates::ShaderDataType::Float2:return GL_FLOAT;
case Pirates::ShaderDataType::Float3:return GL_FLOAT;
case Pirates::ShaderDataType::Float4:return GL_FLOAT;
case Pirates::ShaderDataType::Mat3:return GL_FLOAT;
case Pirates::ShaderDataType::Mat4:return GL_FLOAT;
case Pirates::ShaderDataType::Int:return GL_INT;
case Pirates::ShaderDataType::Int2:return GL_INT;
case Pirates::ShaderDataType::Int3:return GL_INT;
case Pirates::ShaderDataType::Int4:return GL_INT;
case Pirates::ShaderDataType::Bool:return GL_BOOL;
}
PR_CORE_ASSERT(false, "UnKnown ShaderType");
return 0;
}
OpenGLVertexArray::OpenGLVertexArray()
{
PR_PROFILE_FUNCTION();
glCreateVertexArrays(1, &m_RendererID);
}
OpenGLVertexArray::~OpenGLVertexArray()
{
PR_PROFILE_FUNCTION();
glDeleteVertexArrays(1, &m_RendererID);
}
void OpenGLVertexArray::Bind() const
{
PR_PROFILE_FUNCTION();
glBindVertexArray(m_RendererID);
}
void OpenGLVertexArray::UnBind() const
{
PR_PROFILE_FUNCTION();
glBindVertexArray(0);
}
void OpenGLVertexArray::AddVertexBuffer(const Ref<VertexBuffer>& vertexbuffer)
{
PR_PROFILE_FUNCTION();
glBindVertexArray(m_RendererID);
vertexbuffer->Bind();
uint32_t index = 0;
const auto& layout = vertexbuffer->GetLayout();
for (const auto& element : (BufferLayout)layout)
{
glEnableVertexAttribArray(index);
glVertexAttribPointer(index,
element.GetComponentsCount(),
ShaderDataTypeToOpenGLBaseType(element.Type),
element.Normolized ? GL_TRUE : GL_FALSE,
layout.GetStride(),
(const void*)(UINT_PTR)element.OffSet);
index++;
}
m_VertexBuffer.push_back(vertexbuffer);
}
void OpenGLVertexArray::SetIndexBuffer(const Ref<IndexBuffer>& indexbuffer)
{
PR_PROFILE_FUNCTION();
glBindVertexArray(m_RendererID);
indexbuffer->Bind();
m_IndexBuffer = indexbuffer;
}
void OpenGLVertexArray::SetLayout(const BufferLayout layout)
{
}
}
| 25.894118
| 79
| 0.75602
|
michaelzaki-12
|
06d6d982cf1ce3f9048569b10f0b8e2832a8516e
| 4,246
|
cpp
|
C++
|
QPropertyTree/IconXPMCache.cpp
|
koalefant/yasli
|
2096ed8a59ae9c7da467d8de8f1eb811a989dc39
|
[
"MIT"
] | 8
|
2021-07-08T18:06:33.000Z
|
2022-01-17T18:29:57.000Z
|
QPropertyTree/IconXPMCache.cpp
|
koalefant/yasli
|
2096ed8a59ae9c7da467d8de8f1eb811a989dc39
|
[
"MIT"
] | null | null | null |
QPropertyTree/IconXPMCache.cpp
|
koalefant/yasli
|
2096ed8a59ae9c7da467d8de8f1eb811a989dc39
|
[
"MIT"
] | 1
|
2021-12-31T15:52:56.000Z
|
2021-12-31T15:52:56.000Z
|
/**
* yasli - Serialization Library.
* Copyright (C) 2007-2013 Evgeny Andreeshchev <eugene.andreeshchev@gmail.com>
* Alexander Kotliar <alexander.kotliar@gmail.com>
*
* This code is distributed under the MIT License:
* http://www.opensource.org/licenses/MIT
*/
#include <memory>
#include "IconXPMCache.h"
#include "QPropertyTree.h"
#include "yasli/decorators/IconXPM.h"
#include "PropertyTree/Unicode.h"
#include <QApplication>
#include <QStyleOption>
#include <QPainter>
#include <QBitmap>
#ifndef _MSC_VER
# define _stricmp strcasecmp
#endif
// ---------------------------------------------------------------------------
namespace property_tree {
IconXPMCache::~IconXPMCache()
{
flush();
}
void IconXPMCache::flush()
{
IconToBitmap::iterator it;
for (it = iconToImageMap_.begin(); it != iconToImageMap_.end(); ++it)
delete it->second.bitmap;
iconToImageMap_.clear();
}
struct RGBAImage
{
int width_;
int height_;
std::vector<Color> pixels_;
RGBAImage() : width_(0), height_(0) {}
};
bool IconXPMCache::parseXPM(RGBAImage* out, const yasli::IconXPM& icon)
{
if (icon.lineCount < 3) {
return false;
}
// parse values
std::vector<Color> pixels;
int width = 0;
int height = 0;
int charsPerPixel = 0;
int colorCount = 0;
int hotSpotX = -1;
int hotSpotY = -1;
int scanResult = sscanf(icon.source[0], "%d %d %d %d %d %d", &width, &height, &colorCount, &charsPerPixel, &hotSpotX, &hotSpotY);
if (scanResult != 4 && scanResult != 6)
return false;
if (charsPerPixel > 4)
return false;
if(icon.lineCount != 1 + colorCount + height) {
YASLI_ASSERT(0 && "Wrong line count");
return false;
}
// parse colors
std::vector<std::pair<int, Color> > colors;
colors.resize(colorCount);
for (int colorIndex = 0; colorIndex < colorCount; ++colorIndex) {
const char* p = icon.source[colorIndex + 1];
int code = 0;
for (int charIndex = 0; charIndex < charsPerPixel; ++charIndex) {
if (*p == '\0')
return false;
code = (code << 8) | *p;
++p;
}
colors[colorIndex].first = code;
while (*p == '\t' || *p == ' ')
++p;
if (*p == '\0')
return false;
if (*p != 'c' && *p != 'g')
return false;
++p;
while (*p == '\t' || *p == ' ')
++p;
if (*p == '\0')
return false;
if (*p == '#') {
++p;
if (strlen(p) == 6) {
int colorCode;
if(sscanf(p, "%x", &colorCode) != 1)
return false;
Color color((colorCode & 0xff0000) >> 16,
(colorCode & 0xff00) >> 8,
(colorCode & 0xff),
255);
colors[colorIndex].second = color;
}
}
else {
if(_stricmp(p, "None") == 0)
colors[colorIndex].second = Color(0, 0, 0, 0);
else if (_stricmp(p, "Black") == 0)
colors[colorIndex].second = Color(0, 0, 0, 255)/*GetSysColor(COLOR_BTNTEXT)*/;
else {
// unknown color
colors[colorIndex].second = Color(255, 0, 0, 255);
}
}
}
// parse pixels
pixels.resize(width * height);
int pi = 0;
for (int y = 0; y < height; ++y) {
const char* p = icon.source[1 + colorCount + y];
if (strlen(p) != width * charsPerPixel)
return false;
for (int x = 0; x < width; ++x) {
int code = 0;
for (int i = 0; i < charsPerPixel; ++i) {
code = (code << 8) | *p;
++p;
}
for (size_t i = 0; i < size_t(colorCount); ++i)
if (colors[i].first == code)
pixels[pi] = colors[i].second;
++pi;
}
}
out->pixels_.swap(pixels);
out->width_ = width;
out->height_ = height;
return true;
}
QImage* IconXPMCache::getImageForIcon(const yasli::IconXPM& icon)
{
IconToBitmap::iterator it = iconToImageMap_.find(icon.source);
if (it != iconToImageMap_.end())
return it->second.bitmap;
RGBAImage image;
if (!parseXPM(&image, icon))
return 0;
BitmapCache& cache = iconToImageMap_[icon.source];
cache.pixels.swap(image.pixels_);
cache.bitmap = new QImage((unsigned char*)&cache.pixels[0], image.width_, image.height_, QImage::Format_ARGB32);
return cache.bitmap;
}
// ---------------------------------------------------------------------------
}
| 23.202186
| 131
| 0.563825
|
koalefant
|
06d82f4a4c233169129ee6b723e58247a8d85bbb
| 4,100
|
cpp
|
C++
|
GHW. Marinosyan/Compression/main.cpp
|
MTigra/Data-Structures-and-Algorithms
|
c1db3a3396e6bcad93c4f32a38534eff8393b35e
|
[
"Apache-2.0"
] | 1
|
2017-01-27T07:43:29.000Z
|
2017-01-27T07:43:29.000Z
|
GHW. Marinosyan/Compression/main.cpp
|
MTigra/Data-Structures-and-Algorithms
|
c1db3a3396e6bcad93c4f32a38534eff8393b35e
|
[
"Apache-2.0"
] | 1
|
2018-11-08T22:21:21.000Z
|
2018-11-08T22:21:21.000Z
|
GHW. Marinosyan/Compression/main.cpp
|
MTigra/Data-Structures-and-Algorithms
|
c1db3a3396e6bcad93c4f32a38534eff8393b35e
|
[
"Apache-2.0"
] | 3
|
2018-09-17T09:30:30.000Z
|
2018-11-08T21:40:42.000Z
|
/*
* КДЗ-1 по дисциплине Алгоритмы и структуры данных
* Мариносян Никита Арамович, БПИ151, 01.12.2016
* Среда разработки: CLion
*
* Состав проекта:
* main.cpp - главный файл;
* huffman.cpp, huffman.h - реализация алгоритма Хаффмана
* shannon-fano.cpp, shannon-fano.h - реализация алгоритма Шеннона-Фано
* utilities.cpp, utilities.h - универсальные функции: архивация, разархивация, подсчет частоты)
*
* Сделано:
* 1. Реализованы алгоритмы кодировок Хаффмана и Шеннона-Фано
* 2. Реализована архивация и разархивация файлов с помощью данных алгоритмов
* 3. Произведена оценка количества элементарных операций каждого алгоритма
* 4. Составлен отчет о проделанной работе (см. Marinosyan_Report.pdf)
*/
#include <cstdlib>
#include "huffman.h"
#include "shannon-fano.h"
/*
* Method to do the compression
* using Huffman algorithm
*/
void compress_H(string ipath) {
// Create output file path
string opath = ipath.substr(0, ipath.length() - 3) + "haff";
// Do compression
huffman_compression(ipath, opath);
}
/*
* Method to do the decompression
* using Huffman algorithm
*/
void decompress_H(string ipath) {
// Create output file path
string opath = ipath.substr(0, ipath.length() - 5) + "-unz-h.txt";
// Do decompression
decompressFile(ipath, opath);
}
/*
* Method to do the compression
* using Shannon-Fano algorithm
*/
void compress_SF(string ipath) {
// Create output file path
string opath = ipath.substr(0, ipath.length() - 3) + "shan";
// Do compression
sf_compression(ipath, opath);
}
/*
* Method to do the decompression
* using Shannon-Fano algorithm
*/
void decompress_SF(string ipath) {
// Create output file path
string opath = ipath.substr(0, ipath.length() - 5) + "-unz-s.txt";
// Do decompression
decompressFile(ipath, opath);
}
int main(int argc, char* argv[]) {
// Check if the call was
// made properly
if (argc != 3) {
cout << "Incorrect number of arguments!" << endl;
return 0;
}
// Check if the file exists
std::ifstream file(argv[1]);
if (!file.good()) {
// File does not exist
cout << "File does not exist!" << endl;
return 0;
}
file.close();
// Call the method
// selected by user
if (atoi(argv[2]) == 1) { // Huffman compression
// Check if the file
// has proper extension
string ipath = argv[1];
if (ipath.substr(ipath.length() - 4, ipath.length() - 1) != ".txt") {
cout << "Incorrect file extension! It must be .txt" << endl;
return 0;
}
// Do compression
compress_H(argv[1]);
}
else if (atoi(argv[2]) == 2) { // Huffman decompression
// Check if the file
// has proper extension
string ipath = argv[1];
if (ipath.substr(ipath.length() - 5, ipath.length() - 1) != ".haff") {
cout << "Incorrect file extension! It must be .haff" << endl;
return 0;
}
// Do decompression
decompress_H(argv[1]);
}
else if (atoi(argv[2]) == 3) { // Shannon-Fano compression
// Check if the file
// has proper extension
string ipath = argv[1];
if (ipath.substr(ipath.length() - 4, ipath.length() - 1) != ".txt") {
cout << "Incorrect file extension! It must be .txt" << endl;
return 0;
}
// Do compression
compress_SF(argv[1]);
}
else if (atoi(argv[2]) == 4) { // Shannon-Fano decompression
// Check if the file
// has proper extension
string ipath = argv[1];
if (ipath.substr(ipath.length() - 5, ipath.length() - 1) != ".shan") {
cout << "Incorrect file extension! It must be .shan" << endl;
return 0;
}
// Do decompression
decompress_SF(argv[1]);
}
else { // Invalid flag
cout << "No method for this flag found. Flag value must in range [1,4]." << endl;
return 0;
}
cout << "operations: "<< operations;
return 0;
}
| 26.797386
| 96
| 0.596341
|
MTigra
|
06d91a8d7fa8f92a70b0fb0b8ed70c4a35a789b8
| 11,766
|
cpp
|
C++
|
Aufgaben/Aufgabenblatt 3/SuffixTree/SuffixBaum.cpp
|
streusselhirni/hfict-aad
|
a9ddbf306ba36bb9299021f102281cd1e2824f45
|
[
"MIT"
] | null | null | null |
Aufgaben/Aufgabenblatt 3/SuffixTree/SuffixBaum.cpp
|
streusselhirni/hfict-aad
|
a9ddbf306ba36bb9299021f102281cd1e2824f45
|
[
"MIT"
] | null | null | null |
Aufgaben/Aufgabenblatt 3/SuffixTree/SuffixBaum.cpp
|
streusselhirni/hfict-aad
|
a9ddbf306ba36bb9299021f102281cd1e2824f45
|
[
"MIT"
] | null | null | null |
//
// Created by Nicolas Haenni on 28.09.18.
//
#include <iostream>
#include "SuffixBaum.h"
#define MAX_CHAR 256
SuffixBaum::SuffixBaum(std::string input1, std::string input2) : root(nullptr), lastNewNode(nullptr),
activeNode(nullptr), activeEdge(-1),
activeLength(0), remainingSuffixCount(0), leafEnd(-1),
rootEnd(nullptr), splitEnd(nullptr),
size(-1), size1(-1) {
std::string tmp = input1 + "#" + input2 + "$";
this->text = new char[tmp.size()];
strcpy(text, tmp.c_str());
this->buildSuffixTree();
this->getLongestCommonSubstring();
}
/**
* Creates a new Node in the Tree
* @param start - The input character string index of the first character on the
* path from its parent to this node
* @param end - The input character string index of the last character on the path
* from its parent to this node
* @return - A pointer to the newly created node
*/
SuffixTreeNode *SuffixBaum::newNode(int start, int *end) {
auto node = new SuffixTreeNode;
for (int i = 0; i < MAX_CHAR; i++) {
node->children[i] = nullptr;
}
node->suffixLink = root;
node->start = start;
node->end = end;
// suffixIndex (the number of the suffix this leaf contains)
// will be set to -1 (no leaf, no suffix) by default and
// actual suffix index will be set later for leaves
node->suffixIndex = -1;
return node;
}
/**
* Counts the length of the edge from its parent to Node n
* @param n - Node whose leaf should be counted
* @return - The number of characters on the edge from its parent to this node
*/
int SuffixBaum::edgeLength(SuffixTreeNode *n) {
if (n == root) return 0;
return *(n->end) - (n->start) + 1;
}
/**
* Walk down the tree using the count/skip trick. If the activeLength (from activePoint) is greater
* than the edge to the node, change activePoint to be counting from currNode.
* @param currNode - Node to start from to walk down
* @return - 0 when walk down not necessary, 1 when walk down successful
*/
int SuffixBaum::walkDown(SuffixTreeNode *currNode) {
// activePoint change for walk down. If activeLength is
// greater than current edge length, set next interval
// node as activeNode and adjust activeEdge and activeLength
// accordingly to represent same activePoint
if (activeLength >= edgeLength(currNode)) {
activeEdge += edgeLength(currNode);
activeLength -= edgeLength(currNode);
activeNode = currNode;
return 1;
}
return 0;
}
/**
* Takes care of the phases and extensions necessary to extend the suffixTree
* @param pos - Position index of input string character for which the suffixes
* need to be added
*/
void SuffixBaum::extendSuffixTree(int pos) {
// Extension rule 1: If the path from the root labelled
// S[j..i] ends at leaf edge (i.e. S[i] is last character
// on leaf edge) then character S[i+1] is just added to the
// end of the label on that leaf edge.
// Does all extensions from 1 to i for character i.
// For pos = 3 ('abc'): To be added 'abc', 'bc', 'c'; already added: 'a', 'ab')
// 'c' just need to be added to the already existing paths
leafEnd = pos;
// Increment remainingSuffixCount to show that a new suffix
// is yet to be added to the tree (eg. 'c')
remainingSuffixCount++;
// Set lastNewNode to nullptr while starting a new phase
// to show that there is no internal node waiting for
// it's suffix link to be reset in current phase
lastNewNode = nullptr;
while (remainingSuffixCount > 0) {
// active point change for activeLength zero
if (activeLength == 0) activeEdge = pos;
// If there is no outgoing edge starting with activeEdge
// from activeNode
if (activeNode->children[text[activeEdge]] == nullptr) {
// Rule 2: New leaf edge gets created starting from an
// existing node (activeNode)
activeNode->children[text[activeEdge]] =
newNode(pos, &leafEnd);
// If there is an internal node waiting for it's suffix
// link to be set, point the suffix link from that last
// internal node to current activeNode. Then set lastNewNode
// tp nullptr to show that no more nodes are waiting for
// suffix link reset
if (lastNewNode != nullptr) {
lastNewNode->suffixLink = activeNode;
lastNewNode = nullptr;
}
}
// If there is an outgoing edge starting with activeEdge from
// activeNode
else {
// Get the next node at the end of edge starting with activeEdge
SuffixTreeNode *next = activeNode->children[text[activeEdge]];
if (walkDown(next)) { // Do walk down
// If walk down was successfull (activeLength < edgeLength)
// go to next extension
continue;
}
// Rule 3 (current character being processes is already on edge
if (text[next->start + activeLength] == text[pos]) {
// If a newly created node is waiting for it's suffixLink
// to be set, then set it to current activeNode
if (lastNewNode != nullptr && activeNode != root) {
lastNewNode->suffixLink = activeNode;
lastNewNode = nullptr;
}
// active point change for extension rule 3: The activePoint
// is incremented because we used rule 3 (Suffix is already implicitly in tree)
activeLength++;
// Stop all further processing in this phase and move to next
// phase
break;
}
// We will be here when activePoint is in middle of an edge being
// traversed and current character is not on the edge. In this case
// we add a new internal node and a new leaf edge going of of that
// node. This is extension rule 2.
splitEnd = new int;
*splitEnd = next->start + activeLength - 1;
// New internal node
auto *split = newNode(next->start, splitEnd);
activeNode->children[text[activeEdge]] = split;
// New leaf coming out of internal node
split->children[text[pos]] = newNode(pos, &leafEnd);
next->start += activeLength;
split->children[text[next->start]] = next;
// If there is an internal node created in last extensions of same
// phase which is still waiting for its suffix link to be set, do it
if (lastNewNode != nullptr) {
lastNewNode->suffixLink = split;
}
// Make the current newly created internal node wait for it's suffix
// link to be set.
lastNewNode = split;
}
// A suffix got added in tree, decrement the count of suffixed yet to be added
remainingSuffixCount--;
// activePoint change for extension rule 2 c1
if (activeNode == root && activeLength > 0) {
activeLength--;
activeEdge = pos - remainingSuffixCount + 1;
}
else if (activeNode != root) {
activeNode = activeNode->suffixLink;
}
}
}
/**
* Print the characters from index i to j
* @param i - Input string character index to start from
* @param j - Input string character index to print to
*/
void SuffixBaum::print(int i, int j) {
int k;
for (k = i; k <= j && text[k] != '#'; k++) {
std::cout << text[k];
}
if (k <= j) printf("#");
}
void SuffixBaum::setSuffixIndex(SuffixTreeNode *n, int labelHeight) {
if (n == nullptr) return;
if (n->start != -1) { // A non-root node
// Print the label on edge from parent to current node
// this->print(n->start, *(n->end));
}
int leaf = 1;
int i;
for (i = 0; i < MAX_CHAR; i++) {
// If all children are nullptr, we are on a leaf
if (n->children[i] != nullptr) {
// This is no leaf
// Print suffix index (uncomment if necessary)
// if (leaf == 1 && n->start != -1) {
// std::cout << " " << n->suffixIndex << std::endl;
// }
// Since current node is not a leaf as it has outgoing edges from it
leaf = 0;
// Check children of current node
this->setSuffixIndex(n->children[i],
labelHeight + edgeLength(n->children[i]));
}
}
if (leaf == 1) {
// We are on a leaf
for (i = n->start; i <= *(n->end); i++) {
if (text[i] == '#') {
n->end = new int;
*(n->end) = i;
}
}
n->suffixIndex = size - labelHeight;
// Print suffix index
// printf(" [%d]\n", n->suffixIndex);
}
}
SuffixBaum::~SuffixBaum() {
if (root != nullptr) this->deleteSuffixTree(root);
}
void SuffixBaum::deleteSuffixTree(SuffixTreeNode *n) {
int i;
for (i = 0; i < MAX_CHAR; i++) {
if (n->children[i] != nullptr) {
delete (n->children[i]);
}
}
if (n->suffixIndex == -1) {
delete (n->end);
}
}
void SuffixBaum::buildSuffixTree() {
size = strlen(text);
int i;
rootEnd = new int;
*rootEnd = 01;
// Root is a specual node with stat and end indices as
// -1 as it has no parent
root = newNode(-1, rootEnd);
activeNode = root; // First activeNode will be root
for (i = 0; i < size; i++) {
extendSuffixTree(i);
}
int labelHeight = 0;
this->setSuffixIndex(root, labelHeight);
}
int SuffixBaum::doTraversal(SuffixTreeNode *n, int labelHeight, int *maxHeight, int *substringStartIndex) {
if (n == nullptr) {
return 0;
}
int i = 0;
int ret = -1;
if (n->suffixIndex < 0) { // If it is internal node
for (i = 0; i < MAX_CHAR; i++) {
if (n->children[i] != nullptr) {
ret = doTraversal(n->children[i],
labelHeight + edgeLength(n->children[i]),
maxHeight, substringStartIndex);
if (n->suffixIndex == -1) n->suffixIndex = ret;
else if ((n->suffixIndex == -2 && ret == -3) ||
(n->suffixIndex == -3 && ret == -2) ||
n->suffixIndex == -4) {
n->suffixIndex = -4; // Mark node as XY
if (*maxHeight < labelHeight) {
*maxHeight = labelHeight;
*substringStartIndex = *(n->end) - labelHeight + 1;
}
}
}
}
}
else if (n->suffixIndex > -1 && n->suffixIndex < size1) {
return -2; // Mark node as X
}
else if (n->suffixIndex >= size1) { //Suffix of Y
return -3; // Mark node as Y
}
return n->suffixIndex;
}
void SuffixBaum::getLongestCommonSubstring() {
int maxHeight = 0;
int substringStartIndex = 0;
doTraversal(root, 0, &maxHeight, &substringStartIndex);
int k;
for (k = 0; k < maxHeight; k++) {
printf("%c", text[k + substringStartIndex]);
}
if (k == 0) printf("No common substring");
else printf("\n(length: %d)", maxHeight);
printf("\n");
}
| 35.654545
| 119
| 0.554734
|
streusselhirni
|
06da69dfd94081d9216bf3383507c849b36cc460
| 1,178
|
cpp
|
C++
|
TWatch_2021_Library/src/drive/Power/power.cpp
|
Xinyuan-LilyGO/T-Watch-2021
|
4b604c39e143deb7b268889114cb81fb420cf65c
|
[
"MIT"
] | 34
|
2021-08-10T11:12:15.000Z
|
2022-03-30T11:57:15.000Z
|
TWatch_2021_Library/src/drive/Power/power.cpp
|
Xinyuan-LilyGO/T-Watch-2021
|
4b604c39e143deb7b268889114cb81fb420cf65c
|
[
"MIT"
] | 2
|
2021-10-03T23:58:16.000Z
|
2022-01-11T02:01:58.000Z
|
TWatch_2021_Library/src/drive/Power/power.cpp
|
Xinyuan-LilyGO/T-Watch-2021
|
4b604c39e143deb7b268889114cb81fb420cf65c
|
[
"MIT"
] | 11
|
2021-10-02T05:17:39.000Z
|
2022-03-30T11:59:41.000Z
|
#include "../../TWatch_hal.h"
#if defined(TWatch_HAL_Power)
void TWatchClass::Power_Init()
{
pinMode(TWATCH_PWR_ON, OUTPUT);
pinMode(TWATCH_BAT_ADC, INPUT);
digitalWrite(TWATCH_PWR_ON, HIGH);
}
void TWatchClass::Power_Updata(uint32_t millis, uint32_t time_ms)
{
static uint32_t Millis;
static uint32_t power_sub;
static uint8_t cnt;
if (millis - Millis > time_ms)
{
if (cnt < 50)
{
power_sub += analogRead(TWATCH_BAT_ADC);
cnt++;
}
else
{
uint32_t Pow = power_sub / cnt;
float Volts = (Pow * 3.3 * 2 / 4096);
Pow_percent = ((constrain(Volts, 3.7, 4.2) - 3.7) / 0.5) * 100;
power_sub = cnt = 0;
Serial.printf("Volts:%d\r\n", Pow);
}
Millis = millis;
}
}
uint8_t TWatchClass::Get_Power()
{
uint16_t b = 0;
uint8_t n = 20;
// measure n times
for (uint8_t i = 0; i < n; i++)
{
b = b + analogRead(TWATCH_BAT_ADC);
}
b = b / n;
float vol = ((b * 3.3) / 4096 + 0.1);
vol = vol < 1.4 ? 0 : (vol - 1.4) / 0.6 * 100;
return constrain(vol, 0, 100);
}
#endif
| 21.814815
| 75
| 0.531409
|
Xinyuan-LilyGO
|
06dbe0e44a45d4d7bc9743ce7b7bc274a96a4494
| 435
|
c++
|
C++
|
test/core/range_tests.c++
|
rendering-io/magma
|
b6503a5dadc36ff38d6c8ba221b08e600fd09050
|
[
"MIT"
] | null | null | null |
test/core/range_tests.c++
|
rendering-io/magma
|
b6503a5dadc36ff38d6c8ba221b08e600fd09050
|
[
"MIT"
] | null | null | null |
test/core/range_tests.c++
|
rendering-io/magma
|
b6503a5dadc36ff38d6c8ba221b08e600fd09050
|
[
"MIT"
] | null | null | null |
#include <gtest/gtest.h>
#include <magma/core/range.h>
#include <vector>
using namespace magma;
TEST(input_range, range_based_for_equals_source_data) {
std::vector<int> v;
v.push_back(1);
v.push_back(2);
v.push_back(3);
auto range = input_range<int>{begin(v), end(v)};
std::vector<int> out;
for (auto i : range) {
out.push_back(i);
}
for (auto i = 0; i < v.size(); ++i) {
ASSERT_EQ(out[i], v[i]);
}
}
| 17.4
| 55
| 0.625287
|
rendering-io
|
06e057a5efe7a556af04f9172f14b9120b482dc4
| 1,846
|
cpp
|
C++
|
demo_source/BST_demo.cpp
|
yhlim1225/OSS_G6
|
c88f78eefeacf89893ace3f07bbdf3ebb1923244
|
[
"MIT"
] | null | null | null |
demo_source/BST_demo.cpp
|
yhlim1225/OSS_G6
|
c88f78eefeacf89893ace3f07bbdf3ebb1923244
|
[
"MIT"
] | 5
|
2019-11-24T07:30:12.000Z
|
2019-12-19T04:43:52.000Z
|
demo_source/BST_demo.cpp
|
yhlim1225/OSS_G6
|
c88f78eefeacf89893ace3f07bbdf3ebb1923244
|
[
"MIT"
] | 2
|
2019-12-01T07:09:18.000Z
|
2019-12-09T16:46:38.000Z
|
//The MIT License (MIT)
//Copyright (c) 2019 OSS_G6. All rights reserved.
//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.
#include<iostream>
#include<vector>
#include"BST.h"
using namespace std;
int main()
{
struct node* root = NULL;
struct node* root1 = NULL;
struct node* root2 = NULL;
root1 = Insert(30, root1);
Insert(20, root1);
Insert(50, root1);
Insert(10, root1);
Insert(80, root1);
Insert(40, root1);
Insert(70, root1);
PrintPreorder(root1);
Delete(70, root1);
Delete(20, root1);
Delete(50, root1);
PrintPreorder(root1);
Insert(70, root1);
Insert(20, root1);
PrintPreorder(root1);
root1 = Balance(root1);
PrintPreorder(root1);
root2 = Insert(50, root2);
Insert(60, root2);
Insert(90, root2);
PrintPreorder(root2);
root2 = Balance(root2);
PrintPreorder(root2);
cout << endl;
return 0;
}
| 25.287671
| 79
| 0.736728
|
yhlim1225
|
06e0a720c773f04262ffb3bad912443be21f2aeb
| 2,482
|
cpp
|
C++
|
zhang/graph/trace1.cpp
|
costarzhang/C-Plus-Plus
|
fa21e83f9c17adce4f8c46d53dcba4eacbbfa809
|
[
"MIT"
] | null | null | null |
zhang/graph/trace1.cpp
|
costarzhang/C-Plus-Plus
|
fa21e83f9c17adce4f8c46d53dcba4eacbbfa809
|
[
"MIT"
] | null | null | null |
zhang/graph/trace1.cpp
|
costarzhang/C-Plus-Plus
|
fa21e83f9c17adce4f8c46d53dcba4eacbbfa809
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <vector>
using namespace std;
int move_x[8] = {1, 2, 2, 1, -1, -2, -2, -1};
int move_y[8] = {2, 1, -1, -2, -2, -1, 1, 2};
void Judge(vector<vector<int>> &pan, vector<vector<int>> &flag, vector<vector<int>> &path, int m, int n, int &edge, int count, int &found)
{
if (found) //设定找到一次就可以退出了
return;
if (count >= edge * edge) //当记录次数等于8*8=64次,说明马已经踏过了所有棋盘
{
found += 1;
//把记录的路径保存在path中
for (int i = 0; i < edge; i++)
{
for (int j = 0; j < edge; j++)
path[i][j] = flag[i][j];
}
return;
}
if (m > edge - 1 || n > edge - 1 || m < 0 || n < 0 || flag[m][n] != 0) //边界条件,出了边界就退回,悬崖勒马
return;
count++; //满足在边界之内,没有被访问过,计数加1
flag[m][n] = count; //对应节点记录访问顺序,第几次被访问的
/*贪心算法,确定下一次的方向*/
int count_next[8] = {-1, -1, -1, -1, -1, -1, -1, -1};
for (int i = 0; i < edge; i++)
{
int m_next = m + move_x[i];
int n_next = n + move_y[i];
if (m_next < edge && n_next < edge && m_next >= 0 && n_next >= 0 && flag[m_next][n_next] == 0)
{
count_next[i]++;
for (int j = 0; j < edge; j++)
{
int m_next_next = m_next + move_x[j];
int n_next_next = n_next + move_y[j];
if (m_next_next < edge && n_next_next < edge && m_next_next >= 0 && n_next_next >= 0 && flag[m_next_next][n_next_next] == 0)
count_next[i]++;
}
}
}
int opt_direct = 0; //记录下一步的方向
for (int i = 0; i < edge; i++)
{
if (count_next[opt_direct] == -1)
opt_direct = i;
if ((count_next[i] < count_next[opt_direct]) && count_next[i] != -1)
{
opt_direct = i;
}
}
Judge(pan, flag, path, m + move_x[opt_direct], n + move_y[opt_direct], edge, count, found); //采用递归,进行下一步的搜索
flag[m][n] = 0; //回溯,对应节点标记清零
}
int main()
{
int m, n;
int edge;
int found = 0;
cin >> edge >> m >> n;
vector<vector<int>> pan(edge, vector<int>(edge, 0));
vector<vector<int>> flag(edge, vector<int>(edge, 0));
vector<vector<int>> path(edge, vector<int>(edge, 0));
Judge(pan, flag, path, m, n, edge, 0, found);
cout << found << endl;
for (int i = 0; i < edge; i++)
{
for (int j = 0; j < edge; j++)
cout << path[i][j] << " ";
cout << endl;
}
system("pause");
return 0;
}
| 28.204545
| 140
| 0.476229
|
costarzhang
|
06e662930f124e19f066d4712a6597c70fc33951
| 15,264
|
cpp
|
C++
|
asc/src/solver_structure.cpp
|
inquisitor101/ASC2D
|
73ea575496340ad2486014525c6aec9c42c5d453
|
[
"MIT"
] | null | null | null |
asc/src/solver_structure.cpp
|
inquisitor101/ASC2D
|
73ea575496340ad2486014525c6aec9c42c5d453
|
[
"MIT"
] | null | null | null |
asc/src/solver_structure.cpp
|
inquisitor101/ASC2D
|
73ea575496340ad2486014525c6aec9c42c5d453
|
[
"MIT"
] | null | null | null |
#include "solver_structure.hpp"
CSolver::CSolver
(
CConfig *config_container,
CGeometry *geometry_container,
CInitial *initial_container,
CElement **element_container,
CSpatial **spatial_container,
unsigned short iZone
)
/*
* Constructor, used to initialize CSolver in zone: iZone.
*/
{
// Zone ID.
zoneID = iZone;
// Polynomial order.
nPoly = config_container->GetnPolySolZone(iZone);
// Number of nodes for solution DOFs in 2D.
nDOFsSol2D = element_container[iZone]->GetnDOFsSol2D();
// Number of elements.
nElem = geometry_container->GetGeometryZone(iZone)->GetnElem();
// Number of boundaries in this zone. Note, this is always fixed as 4.
nBoundary = nFace;
// Initialize element data container.
Data_Preprocessing(config_container,
geometry_container,
initial_container,
element_container[iZone],
iZone);
// Initialize boundary data container.
Boundary_Preprocessing(config_container,
geometry_container,
initial_container,
element_container,
iZone);
}
CSolver::~CSolver
(
void
)
/*
* Destructor for CSolver class, frees allocated memory.
*/
{
if( InvMassMatrix != nullptr ) delete [] InvMassMatrix;
for(unsigned long i=0; i<data_container.size(); i++)
if( data_container[i] ) delete data_container[i];
for(unsigned short i=0; i<boundary_container.size(); i++)
if( boundary_container[i] ) delete boundary_container[i];
}
void CSolver::Data_Preprocessing
(
CConfig *config_container,
CGeometry *geometry_container,
CInitial *initial_container,
CElement *element_container,
unsigned short iZone
)
/*
* Function that preprocess the data container.
*/
{
// Initialize element data structure container.
data_container.resize(nElem, nullptr);
// Flag for error detection.
bool ErrorDetected = false;
// Check what type of solver we are dealing with.
switch( config_container->GetTypeSolver(iZone) ){
// Pure Euler solver.
case(SOLVER_EE):
{
// Check what type of buffer layer this is, if any.
switch( config_container->GetTypeBufferLayer(iZone) ){
// EE-type data container.
case(NO_LAYER):
{
// Initialize the data structure.
for(unsigned long iElem=0; iElem<nElem; iElem++){
// Data container of type Euler.
data_container[iElem] = new CEEData(config_container,
geometry_container,
initial_container,
element_container,
iZone, iElem);
// Check if allocation failed.
if( !data_container[iElem] )
Terminate("CSolver::Data_Preprocessing", __FILE__, __LINE__,
"Allocation failed for data_container.");
}
break;
}
// Sponge EE-type data container.
case(SPONGE_LAYER):
{
// Initialize the data structure.
for(unsigned long iElem=0; iElem<nElem; iElem++){
// Data container of type sponge Euler.
data_container[iElem] = new CEESpongeData(config_container,
geometry_container,
initial_container,
element_container,
iZone, iElem);
// Check if allocation failed.
if( !data_container[iElem] )
Terminate("CSolver::Data_Preprocessing", __FILE__, __LINE__,
"Allocation failed for data_container.");
}
break;
}
// PML EE-type data container.
case(PML_LAYER):
{
// Initialize the data structure.
for(unsigned long iElem=0; iElem<nElem; iElem++){
// Data container of type PML Euler.
data_container[iElem] = new CEEPMLData(config_container,
geometry_container,
initial_container,
element_container,
iZone, iElem);
// Check if allocation failed.
if( !data_container[iElem] )
Terminate("CSolver::Data_Preprocessing", __FILE__, __LINE__,
"Allocation failed for data_container.");
}
break;
}
// Otherwise, flag for an error.
default: ErrorDetected = true;
}
break;
}
default:
Terminate("CEESolver::Data_Preprocessing", __FILE__, __LINE__,
"Type of solver specified is unknown.");
}
if( ErrorDetected )
Terminate("CEESolver::Data_Preprocessing", __FILE__, __LINE__,
"Type of buffer layer specified is unknown.");
}
void CSolver::Boundary_Preprocessing
(
CConfig *config_container,
CGeometry *geometry_container,
CInitial *initial_container,
CElement **element_container,
unsigned short iZone
)
/*
* Function that preprocess the boundary container and initialize it.
*/
{
// Header for output.
std::cout << "----------------------------------------------"
"----------------------------------------------\n";
std::cout << "Processing boundary of type: "
<< DisplaySolverType( config_container->GetTypeSolver(iZone) )
<< " in: "
<< "iZone(" << iZone << "): "
<< DisplayTypeZone(config_container->GetTypeZone(iZone))
<< std::endl;
// Initialize the needed number of boundaries in this zone.
boundary_container.resize(nBoundary, nullptr);
// Loop over every boundary and specify input condition.
for(unsigned short iBoundary=0; iBoundary<nBoundary; iBoundary++){
// Check which boundary condition to apply.
switch( config_container->GetTypeBC(iZone, iBoundary) ){
case(BC_INTERFACE):
{
// Initialize interface/periodic boundary.
switch( config_container->GetTypeSolver(iZone) ){
// Pure EE interface boundary.
case( SOLVER_EE ):
{
// Check what type of buffer layer this is, if any.
switch( config_container->GetTypeBufferLayer(iZone) ){
// Physical or sponge EE-type spatial container.
case(NO_LAYER): case(SPONGE_LAYER):
{
// Initialize interface/periodic boundary.
boundary_container[iBoundary] = new CEEInterfaceBoundary(config_container,
geometry_container,
initial_container,
element_container,
iZone, iBoundary);
break;
}
// PML EE-type spatial container.
case(PML_LAYER):
{
// Initialize interface/periodic boundary.
boundary_container[iBoundary] = new CEEPMLInterfaceBoundary(config_container,
geometry_container,
initial_container,
element_container,
iZone, iBoundary);
break;
}
default:
Terminate("CSolver::Boundary_Preprocessing", __FILE__, __LINE__,
"Unknown buffer layer specified for the interface boundary.");
}
break;
}
default:
Terminate("CSolver::Boundary_Preprocessing", __FILE__, __LINE__,
"Unknown solver specified for the interface boundary.");
}
// Break out of the interface case.
break;
}
case(BC_SYMMETRY):
{
// Initialize symmetry boundary.
boundary_container[iBoundary] = new CEESymmetryBoundary(config_container,
geometry_container,
initial_container,
element_container,
iZone, iBoundary);
break;
}
case(BC_CBC_OUTLET):
{
// Initialize characteristic outlet boundary.
boundary_container[iBoundary] = new CEEOutletCBC(config_container,
geometry_container,
initial_container,
element_container,
iZone, iBoundary);
break;
}
case(BC_CBC_INLET):
{
// Initialize characteristic inlet boundary.
boundary_container[iBoundary] = new CEEInletCBC(config_container,
geometry_container,
initial_container,
element_container,
iZone, iBoundary);
break;
}
case(BC_STATIC_OUTLET):
{
// Initialize subsonic static-condition outlet boundary.
boundary_container[iBoundary] = new CEEStaticOutletBoundary(config_container,
geometry_container,
initial_container,
element_container,
iZone, iBoundary);
break;
}
case(BC_STATIC_INLET):
{
// Initialize subsonic static-condition inlet boundary.
boundary_container[iBoundary] = new CEEStaticInletBoundary(config_container,
geometry_container,
initial_container,
element_container,
iZone, iBoundary);
break;
}
case(BC_TOTAL_INLET):
{
// Initialize subsonic static-condition inlet boundary.
boundary_container[iBoundary] = new CEETotalInletBoundary(config_container,
geometry_container,
initial_container,
element_container,
iZone, iBoundary);
break;
}
case(BC_SUPERSONIC_OUTLET):
{
// Initialize supersonic outlet boundary.
boundary_container[iBoundary] = new CEESupersonicOutletBoundary(config_container,
geometry_container,
initial_container,
element_container,
iZone, iBoundary);
break;
}
case(BC_SUPERSONIC_INLET):
{
// Initialize supersonic inlet boundary.
boundary_container[iBoundary] = new CEESupersonicInletBoundary(config_container,
geometry_container,
initial_container,
element_container,
iZone, iBoundary);
break;
}
default:
Terminate("CSolver::Boundary_Preprocessing", __FILE__, __LINE__,
"Boundary condition is unknown!");
}
}
// Report progress.
std::cout << "Done." << std::endl;
}
CEESolver::CEESolver
(
CConfig *config_container,
CGeometry *geometry_container,
CInitial *initial_container,
CElement **element_container,
CSpatial **spatial_container,
unsigned short iZone
)
:
CSolver
(
config_container,
geometry_container,
initial_container,
element_container,
spatial_container,
iZone
)
/*
* Constructor, used to initialize CEESolver in zone: iZone.
*/
{
// Compute the inverse mass matrix in this zone.
ComputeInvMassMatrix(config_container,
geometry_container,
element_container[iZone]);
}
CEESolver::~CEESolver
(
void
)
/*
* Destructor for CEESolver class, frees allocated memory.
*/
{
}
as3double CEESolver::ComputeTimeStep
(
unsigned long iElem,
const as3vector1d<as3double> &hElem
)
/*
* Function that computes the time step per input element.
*/
{
// CFL-dependant coefficient.
// const as3double f1 = 1.0/( nDim*(2.0*nPoly+1.0) );
const as3double f1 = 1.0/(nPoly*nPoly);
// Abbreviation.
const as3double gm1 = GAMMA_MINUS_ONE;
const as3double ovhx = 1.0/hElem[XDIM];
const as3double ovhy = 1.0/hElem[YDIM];
// Extract current element solution.
auto& sol = data_container[iElem]->GetDataDOFsSol();
// Inverse of spectral radius and time step.
as3double radInv = 1.0, dt = 0.0;
// Loop across all nodes and determine the largest eigenvalue.
for(unsigned short l=0; l<nDOFsSol2D; l++){
// Abbreviation.
const as3double ovrho = 1.0/sol[0][l];
// Compute primitive variables.
const as3double u = ovrho*sol[1][l];
const as3double v = ovrho*sol[2][l];
const as3double p = gm1*(sol[3][l]
- 0.5*(u*sol[1][l] + v*sol[2][l]) );
// Compute the local speed of sound.
const as3double a = sqrt(GAMMA*p*ovrho);
// Compute largest eigenvalues.
const as3double lmbx = fabs(u)+a;
const as3double lmby = fabs(v)+a;
// Compute the inverse of the spectral radius.
radInv = std::max( radInv, ovhx*lmbx );
radInv = std::max( radInv, ovhy*lmby );
// radInv = std::max( radInv, ovhx*lmbx + ovhy*lmby );
}
// Compute actual time step by including the stability coefficient.
dt = f1/radInv;
// Return computed value.
return dt;
}
void CEESolver::ComputeInvMassMatrix
(
CConfig *config_container,
CGeometry *geometry_container,
CElement *element_container
)
/*
* Function that computes the inverse mass matrix.
*/
{
// Obtain number of solution DOFs in 2D.
unsigned short nDOFsSol2D = element_container->GetnDOFsSol2D();
// Reserve memory needed for the inverse mass matrix.
InvMassMatrix = new as3double[nDOFsSol2D*nDOFsSol2D]();
// Check if allocation failed.
if( InvMassMatrix == nullptr )
Terminate("CEESolver::ComputeInvMassMatrix", __FILE__, __LINE__,
"Allocation failed for InvMassMatrix.");
// Compute mass matrix.
element_container->ComputeMassMatrix(nDOFsSol2D, InvMassMatrix);
// Compute inverse of mass matrix.
ComputeInverseMatrix(nDOFsSol2D, InvMassMatrix);
}
| 31.8
| 95
| 0.535705
|
inquisitor101
|
06e78773fdfeffa711d903dc6dfe1b00ecfcb230
| 2,608
|
cpp
|
C++
|
binding/python/terms.cpp
|
GreyMerlin/owl_cpp
|
ccc6128dbd08dcf7fcbe6679ec6acd714732bbb6
|
[
"BSL-1.0"
] | null | null | null |
binding/python/terms.cpp
|
GreyMerlin/owl_cpp
|
ccc6128dbd08dcf7fcbe6679ec6acd714732bbb6
|
[
"BSL-1.0"
] | 1
|
2021-08-04T13:29:57.000Z
|
2021-08-04T14:10:49.000Z
|
binding/python/terms.cpp
|
GreyMerlin/owl_cpp
|
ccc6128dbd08dcf7fcbe6679ec6acd714732bbb6
|
[
"BSL-1.0"
] | 1
|
2020-09-21T22:25:57.000Z
|
2020-09-21T22:25:57.000Z
|
/** @file "/owlcpp/binding/python/terms.cpp"
part of owlcpp project.
@n @n Distributed under the Boost Software License, Version 1.0; see doc/license.txt.
@n Copyright Mikhail K Levin 2013
*******************************************************************************/
#include "boost/python.hpp"
namespace bp = boost::python;
#include "boost/mpl/for_each.hpp"
namespace bmp = boost::mpl;
#include <map>
#include "rdf/iri_tag_vector.hpp"
#include "rdf/node_tag_vector_system.hpp"
#include "rdf/node_tag_vector_owl.hpp"
namespace t = owlcpp::terms;
template<class T> struct Ns_tag_name {
static std::string get() {return T::prefix();}
};
template<> struct Ns_tag_name<t::empty> {
static std::string get() {return "empty";}
};
template<> struct Ns_tag_name<t::blank> {
static std::string get() {return "blank";}
};
typedef std::map<owlcpp::Ns_id, bp::object> map_t;
class Ns_tag_inserter {
public:
explicit Ns_tag_inserter(map_t& map) : map_(&map){}
template<class Ns> static std::string iri() {return Ns::iri();}
template<class Ns> static std::string pref() {return Ns::prefix();}
template<class T> void operator()(T const& t) const {
(*map_)[T::id()] =
bp::class_<T>(Ns_tag_name<T>::get().c_str())
.add_static_property("id", &T::id)
.add_static_property("iri", &iri<T>)
.add_static_property("prefix", &pref<T>)
;
}
private:
mutable map_t* map_;
};
template<class T> struct Term_tag_name {
static std::string get() {
return
Ns_tag_name<typename T::ns_type>::get() +
"_" +
T::fragment()
;
}
};
class Term_tag_inserter {
public:
Term_tag_inserter(map_t const& map) : map_(map) {}
template<class T> static char const* fragment() {return T::fragment().c_str();}
template<class T> void operator()(T const& t) const {
bp::class_<T>(Term_tag_name<T>::get().c_str())
.add_static_property("id", &T::id)
.add_static_property("fragment", &fragment<T>)
.add_static_property("ns_type", map_.find(T::ns_type::id())->second)
;
}
private:
map_t const& map_;
};
BOOST_PYTHON_MODULE(terms) {
map_t map;
Ns_tag_inserter nti(map);
bmp::for_each<t::mpl_vector_iris_t>(nti);
Term_tag_inserter tti(map);
bmp::for_each<t::mpl_vector_terms_system_t>(tti);
bmp::for_each<t::mpl_vector_terms_rdfs_t>(tti);
bmp::for_each<t::mpl_vector_terms_rdf_t>(tti);
bmp::for_each<t::mpl_vector_terms_xsd_t>(tti);
bmp::for_each<t::mpl_vector_terms_owl1_t>(tti);
bmp::for_each<t::mpl_vector_terms_owl2_t>(tti);
}
| 29.977011
| 85
| 0.638037
|
GreyMerlin
|
06e998b66cd209db0f631e0ae6cd92c7a43d32c5
| 2,057
|
cpp
|
C++
|
Source/Server/Core/Utils/Strings.cpp
|
stosSe4r/ds3os
|
1e7819449ce12efc618e26f4abca6448cf819b37
|
[
"MIT"
] | null | null | null |
Source/Server/Core/Utils/Strings.cpp
|
stosSe4r/ds3os
|
1e7819449ce12efc618e26f4abca6448cf819b37
|
[
"MIT"
] | null | null | null |
Source/Server/Core/Utils/Strings.cpp
|
stosSe4r/ds3os
|
1e7819449ce12efc618e26f4abca6448cf819b37
|
[
"MIT"
] | null | null | null |
/*
* Dark Souls 3 - Open Server
* Copyright (C) 2021 Tim Leonard
*
* This program is free software; licensed under the MIT license.
* You should have received a copy of the license along with this program.
* If not, see <https://opensource.org/licenses/MIT>.
*/
#include "Core/Utils/Strings.h"
#include <sstream>
#include <iomanip>
#include <string>
std::string BytesToHex(const std::vector<uint8_t>& Bytes)
{
std::stringstream ss;
for (uint8_t Value : Bytes)
{
ss << std::uppercase << std::setfill('0') << std::setw(2) << std::hex << (int)Value;
//ss << " ";
}
return ss.str();
}
bool IsCharRenderable(char c)
{
return c >= 32 && c <= 126;
}
std::string BytesToString(const std::vector<uint8_t>& Bytes, const std::string& LinePrefix)
{
static int column_width = 16;
std::string result = "";
for (size_t i = 0; i < Bytes.size(); i += column_width)
{
std::string hex = "";
std::string chars = "";
for (size_t r = i; r < i + column_width && r < Bytes.size(); r++)
{
uint8_t Byte = Bytes[r];
hex += StringFormat("%02X ", Byte);
chars += IsCharRenderable((char)Byte) ? (char)Byte : '.';
}
result += StringFormat("%s%-48s \xB3 %s\n", LinePrefix.c_str(), hex.c_str(), chars.c_str());
}
return result;
}
std::string TrimString(const std::string& input)
{
size_t startWhiteCount = 0;
size_t endWhiteCount = 0;
for (size_t i = 0; i < input.size(); i++)
{
if (input[i] < 32)
{
startWhiteCount++;
}
else
{
break;
}
}
for (size_t i = 0; i < input.size(); i++)
{
if (input[input.size() - (i + 1)] < 32)
{
endWhiteCount++;
}
else
{
break;
}
}
if (startWhiteCount + endWhiteCount >= input.size())
{
return "";
}
return input.substr(startWhiteCount, input.size() - startWhiteCount - endWhiteCount);
}
| 21.882979
| 100
| 0.536218
|
stosSe4r
|
06e9b34c30917fe04124ad66ad7845a003a53b23
| 2,833
|
cpp
|
C++
|
src/modules/network/protocols/http/http_server_request_factory.cpp
|
dubcanada/TideSDKLite
|
f2f3959e8d464c1096bd5e0963149a3589d54a25
|
[
"Apache-2.0"
] | 2
|
2015-11-05T01:53:44.000Z
|
2015-12-17T06:52:12.000Z
|
src/modules/network/protocols/http/http_server_request_factory.cpp
|
aykutb/TideSDK
|
267e1cb86dc2dc7bef136a78a6f2177233bad233
|
[
"Apache-2.0"
] | null | null | null |
src/modules/network/protocols/http/http_server_request_factory.cpp
|
aykutb/TideSDK
|
267e1cb86dc2dc7bef136a78a6f2177233bad233
|
[
"Apache-2.0"
] | 1
|
2015-07-12T19:35:36.000Z
|
2015-07-12T19:35:36.000Z
|
/**
* This file has been modified from its orginal sources.
*
* Copyright (c) 2012 Software in the Public Interest Inc (SPI)
* Copyright (c) 2012 David Pratt
*
* 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.
*
***
* Copyright (c) 2008-2012 Appcelerator 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 "http_server_request.h"
#include "http_server_response.h"
#include "http_server_request_factory.h"
namespace ti
{
class HTTPRequestHandler : public Poco::Net::HTTPRequestHandler {
public:
HTTPRequestHandler(TiMethodRef callback)
: m_callback(callback)
{
}
virtual void handleRequest(Poco::Net::HTTPServerRequest&, Poco::Net::HTTPServerResponse&);
private:
TiMethodRef m_callback;
};
void HTTPRequestHandler::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response) {
// XXX(Josh): The request and response object's lifetime is limited to this functions call.
// If the developer should keep a reference to these around past the callback lifetime and then
// attempts to access it may result in a crash!
ValueList args;
args.push_back(Value::NewObject(new HttpServerRequest(request)));
args.push_back(Value::NewObject(new HttpServerResponse(response)));
RunOnMainThread(m_callback, args);
}
HttpServerRequestFactory::HttpServerRequestFactory(Host *host, TiMethodRef callback) :
host(host),
callback(callback)
{
}
HttpServerRequestFactory::~HttpServerRequestFactory()
{
}
Poco::Net::HTTPRequestHandler* HttpServerRequestFactory::createRequestHandler(
const Poco::Net::HTTPServerRequest& request)
{
return new HTTPRequestHandler(callback);
}
}
| 35.4125
| 124
| 0.712319
|
dubcanada
|
06eaa73f23ea35e1b33c1d33515bfa871a84853d
| 1,109
|
cpp
|
C++
|
android-31/android/media/MediaMetadataRetriever_BitmapParams.cpp
|
YJBeetle/QtAndroidAPI
|
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
|
[
"Apache-2.0"
] | 12
|
2020-03-26T02:38:56.000Z
|
2022-03-14T08:17:26.000Z
|
android-31/android/media/MediaMetadataRetriever_BitmapParams.cpp
|
YJBeetle/QtAndroidAPI
|
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
|
[
"Apache-2.0"
] | 1
|
2021-01-27T06:07:45.000Z
|
2021-11-13T19:19:43.000Z
|
android-30/android/media/MediaMetadataRetriever_BitmapParams.cpp
|
YJBeetle/QtAndroidAPI
|
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
|
[
"Apache-2.0"
] | 3
|
2021-02-02T12:34:55.000Z
|
2022-03-08T07:45:57.000Z
|
#include "../graphics/Bitmap_Config.hpp"
#include "./MediaMetadataRetriever_BitmapParams.hpp"
namespace android::media
{
// Fields
// QJniObject forward
MediaMetadataRetriever_BitmapParams::MediaMetadataRetriever_BitmapParams(QJniObject obj) : JObject(obj) {}
// Constructors
MediaMetadataRetriever_BitmapParams::MediaMetadataRetriever_BitmapParams()
: JObject(
"android.media.MediaMetadataRetriever$BitmapParams",
"()V"
) {}
// Methods
android::graphics::Bitmap_Config MediaMetadataRetriever_BitmapParams::getActualConfig() const
{
return callObjectMethod(
"getActualConfig",
"()Landroid/graphics/Bitmap$Config;"
);
}
android::graphics::Bitmap_Config MediaMetadataRetriever_BitmapParams::getPreferredConfig() const
{
return callObjectMethod(
"getPreferredConfig",
"()Landroid/graphics/Bitmap$Config;"
);
}
void MediaMetadataRetriever_BitmapParams::setPreferredConfig(android::graphics::Bitmap_Config arg0) const
{
callMethod<void>(
"setPreferredConfig",
"(Landroid/graphics/Bitmap$Config;)V",
arg0.object()
);
}
} // namespace android::media
| 25.790698
| 107
| 0.761046
|
YJBeetle
|
06eaaaec227088277ad99f473d53a52d757589e7
| 566
|
cpp
|
C++
|
6. Polymorphism/3. Operator Overloading/11. Assignment/3.SelfAssignment.cpp
|
Imran4424/C-Plus-Plus-Object-Oriented
|
a9c16ce6506b4cc0f3ec82fdf2e750bec50aab79
|
[
"MIT"
] | 3
|
2019-11-06T15:43:06.000Z
|
2020-06-05T10:47:28.000Z
|
6. Polymorphism/3. Operator Overloading/11. Assignment/3.SelfAssignment.cpp
|
Imran4424/C-Plus-Plus-Object-Oriented
|
a9c16ce6506b4cc0f3ec82fdf2e750bec50aab79
|
[
"MIT"
] | null | null | null |
6. Polymorphism/3. Operator Overloading/11. Assignment/3.SelfAssignment.cpp
|
Imran4424/C-Plus-Plus-Object-Oriented
|
a9c16ce6506b4cc0f3ec82fdf2e750bec50aab79
|
[
"MIT"
] | 1
|
2019-09-06T03:37:08.000Z
|
2019-09-06T03:37:08.000Z
|
#include <iostream>
using namespace std;
class Box
{
private: int length, width, height;
public: Box(int length = 0; int width = 0; int height = 0)
{
this -> length = length;
this -> width = width;
this -> height = height;
}
public: int Area()
{
return length * width;
}
public: int Volume()
{
return length * width * height;
}
Box& operator= (const Box &steel)
{
length = steel.length;
width = steel.width;
height = steel.height;
return *this;
}
};
int main(int argc, char const *argv[])
{
Box red;
red = red;
return 0;
}
| 13.47619
| 59
| 0.614841
|
Imran4424
|
06eb3ed44377cb46487eede8d7644a741ca179fd
| 295
|
cpp
|
C++
|
atcoder.jp/abc152/abc152_c/Main.cpp
|
shikij1/AtCoder
|
7ae2946efdceaea3cc8725e99a2b9c137598e2f8
|
[
"MIT"
] | null | null | null |
atcoder.jp/abc152/abc152_c/Main.cpp
|
shikij1/AtCoder
|
7ae2946efdceaea3cc8725e99a2b9c137598e2f8
|
[
"MIT"
] | null | null | null |
atcoder.jp/abc152/abc152_c/Main.cpp
|
shikij1/AtCoder
|
7ae2946efdceaea3cc8725e99a2b9c137598e2f8
|
[
"MIT"
] | null | null | null |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, p;
cin >> n;
set<int> st;
int count = 0;
for (int i = 0; i < n; i++) {
cin >> p;
st.insert(p);
if (*st.begin() >= p) {
count++;
}
}
cout << count << endl;
}
| 17.352941
| 33
| 0.4
|
shikij1
|
06efb206d66952f329dd4a4e44511f441135f525
| 1,932
|
cpp
|
C++
|
tests/math/test_matrix_vector.cpp
|
ToruNiina/Coffee-mill
|
343a6b89f7bc4645d596809aac9009db1c5ec0d8
|
[
"MIT"
] | 4
|
2017-12-11T07:26:34.000Z
|
2021-02-01T07:33:37.000Z
|
tests/math/test_matrix_vector.cpp
|
ToruNiina/Coffee-mill
|
343a6b89f7bc4645d596809aac9009db1c5ec0d8
|
[
"MIT"
] | null | null | null |
tests/math/test_matrix_vector.cpp
|
ToruNiina/Coffee-mill
|
343a6b89f7bc4645d596809aac9009db1c5ec0d8
|
[
"MIT"
] | null | null | null |
#define BOOST_TEST_MODULE "test_matrix_vector"
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
#include <boost/test/unit_test.hpp>
#else
#define BOOST_TEST_NO_LIB
#include <boost/test/included/unit_test.hpp>
#endif
#include <mill/math/Vector.hpp>
#include <random>
constexpr static unsigned int seed = 32479327;
constexpr static std::size_t N = 10000;
BOOST_AUTO_TEST_CASE(multiple_unit_matrix_and_vector)
{
std::mt19937 mt(seed);
std::uniform_real_distribution<double> uni(-1.0, 1.0);
const mill::Matrix<double, 3, 3> E(1., 0., 0., 0., 1., 0., 0., 0., 1.);
for(std::size_t test_times=0; test_times<N; ++test_times)
{
const mill::Vector<double, 3> lhs(uni(mt), uni(mt), uni(mt));
const mill::Vector<double, 3> same = E * lhs;
BOOST_CHECK_EQUAL(lhs[0], same[0]);
BOOST_CHECK_EQUAL(lhs[1], same[1]);
BOOST_CHECK_EQUAL(lhs[2], same[2]);
}
for(std::size_t test_times=0; test_times<N; ++test_times)
{
const mill::Vector<double, 3> lhs(uni(mt), uni(mt), uni(mt));
const mill::Matrix<double, 1, 3> same = mill::transpose(lhs) * E;
const mill::Vector<double, 3> rhs = mill::transpose(same);
BOOST_CHECK_EQUAL(lhs[0], rhs[0]);
BOOST_CHECK_EQUAL(lhs[1], rhs[1]);
BOOST_CHECK_EQUAL(lhs[2], rhs[2]);
}
}
BOOST_AUTO_TEST_CASE(multiple_matrix_and_vector)
{
std::mt19937 mt(seed);
std::uniform_real_distribution<double> uni(-1.0, 1.0);
for(std::size_t test_times=0; test_times<N; ++test_times)
{
const double coef = uni(mt);
const mill::Matrix<double, 3, 3> M(coef, 0., 0., 0., coef, 0., 0., 0., coef);
const mill::Vector<double, 3> lhs(uni(mt), uni(mt), uni(mt));
const mill::Vector<double, 3> same = M * lhs;
BOOST_CHECK_EQUAL(lhs[0] * coef, same[0]);
BOOST_CHECK_EQUAL(lhs[1] * coef, same[1]);
BOOST_CHECK_EQUAL(lhs[2] * coef, same[2]);
}
}
| 31.672131
| 85
| 0.634576
|
ToruNiina
|
06f1bbde1ac97440192f1a1195cc4909e0b84ec1
| 5,914
|
cpp
|
C++
|
Engine/Core/Private/Platform/Windows/WindowsDeviceManager.cpp
|
ILLmew/Seagull-Engine-v2
|
ea89ebe742ac16ab9e86c82ff1ccfeac354d6598
|
[
"MIT"
] | 3
|
2021-05-06T12:26:35.000Z
|
2021-09-27T10:58:23.000Z
|
Engine/Core/Private/Platform/Windows/WindowsDeviceManager.cpp
|
ILLmew/Seagull-Engine-v2
|
ea89ebe742ac16ab9e86c82ff1ccfeac354d6598
|
[
"MIT"
] | null | null | null |
Engine/Core/Private/Platform/Windows/WindowsDeviceManager.cpp
|
ILLmew/Seagull-Engine-v2
|
ea89ebe742ac16ab9e86c82ff1ccfeac354d6598
|
[
"MIT"
] | null | null | null |
#include "StdAfx.h"
#include "Platform/OS.h"
#include "System/Logger.h"
#ifdef SG_PLATFORM_WINDOWS
namespace SG
{
//////////////////////////////////////////////////////////////////////////////////////////////////////
/// DeviceManager
//////////////////////////////////////////////////////////////////////////////////////////////////////
// used to avoid using friend function in Monitor.
// TODO: have issues on PC having more than one monitor.
static Rect tempMonitorRect;
static Rect tempWorkRect;
static BOOL _EnumMonitorCallback(HMONITOR monitor, HDC hdc, LPRECT pRect, LPARAM pUser)
{
Monitor* pMonitor = (Monitor*)pUser;
MONITORINFOEXW info = {};
info.cbSize = sizeof(info);
::GetMonitorInfoW(monitor, &info);
tempMonitorRect = { info.rcMonitor.left, info.rcMonitor.top, info.rcMonitor.right, info.rcMonitor.bottom };
tempWorkRect = { info.rcWork.left, info.rcWork.top, info.rcWork.right, info.rcWork.bottom };
return TRUE;
}
void DeviceManager::OnInit()
{
CollectInfos();
}
void DeviceManager::OnShutdown()
{
}
void DeviceManager::CollectInfos()
{
// count the monitors
int monitorCount = 0;
int adapterCount = 0;
DISPLAY_DEVICEW adapter = {};
adapter.cb = sizeof(adapter);
for (int adapterIndex = 0;; ++adapterIndex)
{
if (!EnumDisplayDevicesW(NULL, adapterIndex, &adapter, 0)) // if the adapter exists
break;
++adapterCount;
if (!(adapter.StateFlags & DISPLAY_DEVICE_ACTIVE))
continue;
for (int displayIndex = 0;; displayIndex++)
{
DISPLAY_DEVICEW display;
display.cb = sizeof(display);
if (!EnumDisplayDevicesW(adapter.DeviceName, displayIndex, &display, 0)) // if the monitor exists
break;
++monitorCount;
}
}
// collect informations for monitor
mAdapters.resize(adapterCount);
mMonitors.resize(monitorCount);
int monitorIndex = 0;
int adapterIndex = 0;
wstring prevAdapterDisplayName = L"";
mAdapterCount = 0;
if (monitorCount)
{
DISPLAY_DEVICEW adapter = {};
adapter.cb = sizeof(adapter);
for (int adapterIndex = 0;; ++adapterIndex)
{
if (!EnumDisplayDevicesW(NULL, adapterIndex, &adapter, 0)) // if the adapter exists
break;
Adapter* pAdapter = &mAdapters[adapterIndex];
pAdapter->mName = adapter.DeviceName;
pAdapter->mDisplayName = adapter.DeviceString;
if (prevAdapterDisplayName != pAdapter->mDisplayName)
{
++mAdapterCount;
prevAdapterDisplayName = pAdapter->mDisplayName;
}
if (!(adapter.StateFlags & DISPLAY_DEVICE_ACTIVE))
{
pAdapter->bIsActive = false;
continue;
}
pAdapter->bIsActive = true;
SG_LOG_INFO("Adapter name: %ws", adapter.DeviceString);
for (int displayIndex = 0;; displayIndex++)
{
DISPLAY_DEVICEW display;
display.cb = sizeof(display);
if (!EnumDisplayDevicesW(adapter.DeviceName, displayIndex, &display, 0)) // if the monitor exists
break;
Monitor* pMonitor = &mMonitors[monitorIndex];
pMonitor->mAdapterName = adapter.DeviceName;
pMonitor->mName = display.DeviceString;
pMonitor->mIndex = monitorIndex;
SG_LOG_INFO("Monitor name: %ws", pMonitor->mName.c_str());
::EnumDisplayMonitors(NULL, NULL, _EnumMonitorCallback, (LPARAM)(pMonitor));
pMonitor->mMonitorRect = tempMonitorRect;
pMonitor->mWorkRect = tempWorkRect;
// add the current monitor to the adapter
pAdapter->mMonitors.emplace_back(pMonitor);
if ((adapter.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)) // if it is the primary monitor
pMonitor->bIsPrimary = true;
else
pMonitor->bIsPrimary = false;
++monitorIndex;
}
}
}
else
{
SG_LOG_WARN("No monitor is active or discovered!");
SG_ASSERT(false);
}
// collect all the supported resolutions
for (auto& e : mMonitors)
{
Monitor* pMonitor = &e;
DEVMODEW devMode = {};
devMode.dmSize = sizeof(DEVMODEW);
devMode.dmFields = DM_PELSHEIGHT | DM_PELSWIDTH;
EnumDisplaySettingsW(pMonitor->mAdapterName.c_str(), ENUM_CURRENT_SETTINGS, &devMode);
pMonitor->mDefaultResolution.width = devMode.dmPelsWidth;
pMonitor->mDefaultResolution.height = devMode.dmPelsHeight;
DWORD currentIndex = 0;
while (EnumDisplaySettingsW(pMonitor->mAdapterName.c_str(), currentIndex++, &devMode))
{
Resolution res = { devMode.dmPelsWidth, devMode.dmPelsHeight };
bool bIsRepeat = false;
for (auto& e : pMonitor->mResolutions) // get rid of the repeat resolution
{
if (e == res)
{
bIsRepeat = true;
break;
}
}
if (bIsRepeat)
continue;
//SG_LOG_INFO(" resolution: (%d, %d)", res.width, res.height);
pMonitor->mResolutions.emplace_back(res);
}
}
}
SG::Monitor* DeviceManager::GetMonitor(UInt32 index)
{
for (auto& e : mMonitors)
{
if (e.mIndex == index)
return &e;
}
return nullptr;
}
SG::Monitor* DeviceManager::GetPrimaryMonitor()
{
for (auto& e : mMonitors)
{
if (e.bIsPrimary)
return &e;
}
return nullptr;
}
SG::Vector2f DeviceManager::GetDpiScale() const
{
HDC hdc = ::GetDC(NULL);
const float dpiScale = 96.0f; // TODO: maybe this can be set somewhere
Vector2f dpi;
if (hdc)
{
//dpi.x = (float)::GetDeviceCaps(hdc, LOGPIXELSX) / dpiScale;
//dpi.y = (float)::GetDeviceCaps(hdc, LOGPIXELSY) / dpiScale;
dpi[0] = (float)::GetDeviceCaps(hdc, LOGPIXELSX) / dpiScale;
dpi[1] = (float)::GetDeviceCaps(hdc, LOGPIXELSY) / dpiScale;
}
else
{
float systemDpi = ::GetDpiForSystem() / 96.0f;
dpi[0] = systemDpi;
dpi[1] = systemDpi;
}
::ReleaseDC(NULL, hdc);
return eastl::move(dpi);
}
SG::UInt32 DeviceManager::GetAdapterCount() const
{
return mAdapterCount;
}
SG::Adapter* DeviceManager::GetPrimaryAdapter()
{
for (auto& adapter : mAdapters)
{
if (adapter.bIsActive)
return &adapter;
}
return nullptr;
}
}
#endif // SG_PLATFORM_WINDOWS
| 26.401786
| 109
| 0.65049
|
ILLmew
|
06f1f8b7c2f9a5ac26f8b0aea66729578b2698fd
| 1,024
|
cpp
|
C++
|
Tankerfield/Tankerfield/Bullet_Missile.cpp
|
gamificalostudio/Tankerfield
|
f3801c5286ae836c0fd62392cc14be081b5c74e8
|
[
"MIT"
] | 7
|
2019-03-11T11:31:36.000Z
|
2019-05-18T08:03:35.000Z
|
Tankerfield/Tankerfield/Bullet_Missile.cpp
|
gamificalostudio/Tankerfield
|
f3801c5286ae836c0fd62392cc14be081b5c74e8
|
[
"MIT"
] | 86
|
2019-03-27T14:36:16.000Z
|
2019-06-10T18:43:52.000Z
|
Tankerfield/Tankerfield/Bullet_Missile.cpp
|
gamificalostudio/Tankerfield
|
f3801c5286ae836c0fd62392cc14be081b5c74e8
|
[
"MIT"
] | 1
|
2019-09-10T17:37:44.000Z
|
2019-09-10T17:37:44.000Z
|
#include "Bullet_Missile.h"
#include "PerfTimer.h"
#include "App.h"
#include "M_Audio.h"
#include "M_Collision.h"
#include "M_ObjManager.h"
#include "Obj_Explosion.h"
#include "Obj_Tank.h"
Bullet_Missile::Bullet_Missile(fPoint pos) : Obj_Bullet(pos)
{
shot_sound = app->audio->LoadFx("audio/Fx/tank/weapons/double_missile.wav", 128);
app->audio->PlayFx(shot_sound);
}
void Bullet_Missile::OnTriggerEnter(Collider * collider_1, float dt)
{
if (player != nullptr)
{
Obj_Explosion* explosion_obj = (Obj_Explosion*)app->objectmanager->CreateObject(ObjectType::EXPLOSION, pos_map);
explosion_obj->SetExplosionDamage(explosion_damage);
}
return_to_pool = true;
}
bool Bullet_Missile::Update(float dt)
{
pos_map += direction * speed * dt;
if (bullet_life_ms_timer.ReadMs() >= bullet_life_ms)
{
Obj_Explosion* explosion_obj = (Obj_Explosion*)app->objectmanager->CreateObject(ObjectType::EXPLOSION, pos_map);
explosion_obj->SetExplosionDamage(explosion_damage);
return_to_pool = true;
}
return true;
}
| 23.272727
| 114
| 0.75293
|
gamificalostudio
|
06f6b62ae033a094ba20aa06a08a37450e6d83a3
| 984
|
tcc
|
C++
|
src/jsoncpp_impl/JXXON/Accessor/GetMapElements_shared_ptr.tcc
|
jxx-project/JXXON
|
313bb4e5ab42385741a41fb4032585159c8721c6
|
[
"BSL-1.0"
] | null | null | null |
src/jsoncpp_impl/JXXON/Accessor/GetMapElements_shared_ptr.tcc
|
jxx-project/JXXON
|
313bb4e5ab42385741a41fb4032585159c8721c6
|
[
"BSL-1.0"
] | null | null | null |
src/jsoncpp_impl/JXXON/Accessor/GetMapElements_shared_ptr.tcc
|
jxx-project/JXXON
|
313bb4e5ab42385741a41fb4032585159c8721c6
|
[
"BSL-1.0"
] | null | null | null |
//
// Copyright (C) 2018 Dr. Michael Steffens
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef JXXON_Accessor_GetMapElements_shared_ptr_INCLUDED
#define JXXON_Accessor_GetMapElements_shared_ptr_INCLUDED
#include "JXXON/Error.h"
#include "JXXON/Json.h"
#include "JXXON/Json/Impl.h"
namespace JXXON { namespace Accessor { namespace {
template<typename T>
void populateMap(
Json::MapType<T>& map,
const ::Json::Value& value,
const std::function<typename T::element_type(const ::Json::Value::const_iterator&)>& valueAsT)
{
if (!value.isNull()) {
if (value.isObject()) {
try {
for (auto i = value.begin(); i != value.end(); ++i) {
map.addElement(i.key().asString(), i->isNull() ? T() : std::make_shared<typename T::element_type>(valueAsT(i)));
}
} catch (std::exception& e) {
throw Error(e.what());
}
} else {
throw Error("Not an object");
}
}
}
}}} // namespace JXXON::Accessor::
#endif // JXXON_Accessor_GetMapElements_shared_ptr_INCLUDED
| 24
| 117
| 0.682927
|
jxx-project
|
06f909791ab3f474cb6f80343bcbfb2fb413eb28
| 2,788
|
cpp
|
C++
|
Nesis/Common/CanAerospace/StaticHelper.cpp
|
jpoirier/x-gauges
|
8261b19a9678ad27db44eb8c354f5e66bd061693
|
[
"BSD-3-Clause"
] | 3
|
2015-11-08T07:17:46.000Z
|
2019-04-05T17:08:05.000Z
|
Nesis/Common/CanAerospace/StaticHelper.cpp
|
jpoirier/x-gauges
|
8261b19a9678ad27db44eb8c354f5e66bd061693
|
[
"BSD-3-Clause"
] | null | null | null |
Nesis/Common/CanAerospace/StaticHelper.cpp
|
jpoirier/x-gauges
|
8261b19a9678ad27db44eb8c354f5e66bd061693
|
[
"BSD-3-Clause"
] | null | null | null |
/***************************************************************************
* *
* Copyright (C) 2007 by Kanardia d.o.o. [see www.kanardia.eu] *
* Writen by: *
* Ales Krajnc [ales.krajnc@kanardia.eu] *
* Rok Markovic [rok.markovic@kanardia.eu] *
* *
* Status: Open Source *
* *
* License: GPL - GNU General Public License *
* See 'COPYING.html' for more details about the license. *
* *
***************************************************************************/
#include "Defines.h"
#include "KanardiaHardwareUnits.h"
#include "StaticHelper.h"
namespace can {
const char* apcDataTypes[] = {
"No Data",
"Error",
"Float",
"Long",
"ULong",
"BLong",
"Short",
"UShort",
"BShort",
"Char",
"UChar",
"BChar",
"Short2",
"UShort2",
"BShort2",
"Char4",
"UChar4",
"BChar4",
"Char2",
"UChar2",
"BChar2",
"MemId",
"Chksum",
"AChar",
"AChar2",
"AChar4",
"Char3",
"UChar3",
"BChar3",
"AChar3",
"DoubleH",
"DoubleL"
};
const char* GetDataTypeText(DataType eDataType)
{
if(eDataType < (int)COUNTOF(apcDataTypes))
return apcDataTypes[eDataType];
else
return "N/A";
}
//-----------------------------------------------------------------------------
const char* GetHardwareName(uint8_t byId)
{
static const char* pacNames[] = {
"Invalid unit",
"Magu",
"Daqu",
"Airu",
"Mabu",
"Mabu Sec",
"Seru",
"Flu",
"Canu",
"Kalu",
"Nesis",
"Nesis Sec"
};
if(byId <= KHU_LAST_uC_UNIT)
return pacNames[byId];
else
return "Unknown unit";
}
//-----------------------------------------------------------------------------
struct Vendor
{
const char* pcName;
uint32_t uiId;
};
Vendor aVendors[] = {
{ "Kanardia", 0x16748a73 },
{ "FlyTech", 0x36020a26 },
{ "Pipistrel", 0x77551400 }
};
int GetVendorCount()
{
return COUNTOF(aVendors);
}
uint32_t GetVendorHash(int i)
{
if(i<GetVendorCount())
return aVendors[i].uiId;
return 0;
}
const char* GetVendorName(int i)
{
if(i<GetVendorCount())
return aVendors[i].pcName;
return NULL;
}
int FindVendorIndex(uint32_t uiHash)
{
for(int i=0; i<GetVendorCount(); i++)
if(GetVendorHash(i) == uiHash)
return i;
return -1; // Not found.
}
//-----------------------------------------------------------------------------
} // can namespace
| 20.5
| 79
| 0.421449
|
jpoirier
|
660577f0e38a4436fb9a66a227b91083f2b19457
| 2,255
|
hpp
|
C++
|
src/core/NEON/kernels/arm_gemm/interleave_indirect.hpp
|
Ehsan-aghapour/AI-Sheduling-Reprodution
|
657dfa7c875445ab275c8a4418bbf29ed4d94891
|
[
"MIT"
] | 2,313
|
2017-03-24T16:25:28.000Z
|
2022-03-31T03:00:30.000Z
|
src/core/NEON/kernels/arm_gemm/interleave_indirect.hpp
|
Ehsan-aghapour/AI-Sheduling-Reprodution
|
657dfa7c875445ab275c8a4418bbf29ed4d94891
|
[
"MIT"
] | 952
|
2017-03-28T07:05:58.000Z
|
2022-03-30T09:54:02.000Z
|
src/core/NEON/kernels/arm_gemm/interleave_indirect.hpp
|
Ehsan-aghapour/AI-Sheduling-Reprodution
|
657dfa7c875445ab275c8a4418bbf29ed4d94891
|
[
"MIT"
] | 714
|
2017-03-24T22:21:51.000Z
|
2022-03-18T19:49:57.000Z
|
/*
* Copyright (c) 2020 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
* 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.
*/
#include <cstddef>
#include <cstdint>
#include "convolution_parameters.hpp"
#include "convolver.hpp"
#include "utils.hpp"
namespace arm_gemm {
template<unsigned int height_vectors, unsigned int block, VLType vlt, typename TIn, typename TOut>
void IndirectInterleave(TOut *out, const TIn * const * const *ptr, unsigned int stringlen, unsigned int rounded_stringlen, unsigned int y0, unsigned int ymax, unsigned int k0, unsigned int kmax, bool, int32_t);
template<unsigned int height_vectors, unsigned int block, VLType vlt, typename TIn, typename TOut>
void ConvolutionInterleave(TOut *out, const TIn *in, size_t in_stride, const convolver<TIn> &conv, const unsigned int rounded_stringlen, const unsigned int y0, const unsigned int ymax, const unsigned int k0, const unsigned int kmax, bool, int32_t);
template<unsigned int height_vectors, unsigned int block, VLType vlt, typename TIn, typename TOut>
void Interleave(TOut *out, const TIn *in, size_t in_stride, const unsigned int y0, const unsigned int ymax, const unsigned int k0, const unsigned int kmax, bool, int32_t);
} // namespace arm_gemm
| 51.25
| 248
| 0.772062
|
Ehsan-aghapour
|
6607d25ac47c58311a6f9ffd6a962ba94408bcbc
| 1,119
|
cpp
|
C++
|
659. Split Array into Consecutive Subsequences.cpp
|
rajeev-ranjan-au6/Leetcode_Cpp
|
f64cd98ab96ec110f1c21393f418acf7d88473e8
|
[
"MIT"
] | 3
|
2020-12-30T00:29:59.000Z
|
2021-01-24T22:43:04.000Z
|
659. Split Array into Consecutive Subsequences.cpp
|
rajeevranjancom/Leetcode_Cpp
|
f64cd98ab96ec110f1c21393f418acf7d88473e8
|
[
"MIT"
] | null | null | null |
659. Split Array into Consecutive Subsequences.cpp
|
rajeevranjancom/Leetcode_Cpp
|
f64cd98ab96ec110f1c21393f418acf7d88473e8
|
[
"MIT"
] | null | null | null |
class Solution {
public:
bool isPossible(vector<int>& nums) {
unordered_map<int, int>m, f;
for(auto x: nums) m[x]++;
for(auto x: nums){
if(!m[x]) continue;
else if(f[x]){
f[x]--;
f[x + 1]++;
}
else if(m[x + 1] && m[x + 2]){
m[x + 1]--;
m[x + 2]--;
f[x + 3]++;
}
else return false;
m[x]--;
}
return true;
}
};
class Solution {
public:
bool isPossible(vector<int>& nums) {
unordered_map<int, int>m, t;
for (int& x: nums) {
++m[x];
}
for (int& x: nums) {
if (!m[x]) {
continue;
}
--m[x];
if (t[x]) {
--t[x];
++t[x + 1];
} else if (m[x + 1] && m[x + 2]) {
--m[x + 1];
--m[x + 2];
++t[x + 3];
} else {
return false;
}
}
return true;
}
};
| 21.941176
| 46
| 0.291332
|
rajeev-ranjan-au6
|
660cb898994464032fd438a6ca87874b22c583dd
| 2,672
|
cpp
|
C++
|
Examples/Chess/src/chess/chess-piece.cpp
|
JoachimHerber/Bembel-Game-Engine
|
5c4e46c5a15356af6e997038a8d76065b0691b50
|
[
"MIT"
] | 2
|
2018-01-02T14:07:54.000Z
|
2021-07-05T08:05:21.000Z
|
Examples/Chess/src/chess/chess-piece.cpp
|
JoachimHerber/Bembel-Game-Engine
|
5c4e46c5a15356af6e997038a8d76065b0691b50
|
[
"MIT"
] | null | null | null |
Examples/Chess/src/chess/chess-piece.cpp
|
JoachimHerber/Bembel-Game-Engine
|
5c4e46c5a15356af6e997038a8d76065b0691b50
|
[
"MIT"
] | null | null | null |
#include "chess-piece.h"
#include "../selection-component.h"
#include "chess-piece-type.h"
#include "player.h"
using namespace bembel::kernel;
using namespace bembel::base;
using namespace bembel::graphics;
ChessPiece::ChessPiece(
ChessPieceType* type,
Scene* scene,
unsigned owner,
const glm::ivec2& start_pos)
: scene(scene)
, type(type)
, original_type(type)
, owner(owner)
, start_positon(start_pos)
, positon(start_pos)
, is_alive(false)
, entity(scene->createEntity()) {
this->scene->createComponent<PositionComponent>(this->entity)->position =
2.0f * glm::vec3(start_pos.x, 0, start_pos.y);
scene->createComponent<RotationComponent>(this->entity)->rotation =
glm::angleAxis(glm::radians(owner == 0 ? 180.f : 1.0f), glm::vec3(0, 1, 0));
scene->createComponent<GeometryComponent>(this->entity)->model =
type->getModles()[owner];
scene->createComponent<SelectionComponent>(this->entity)->state =
SelectionComponent::State::UNSELECTABLE;
// selectComp->stat = SelectionComponent::SELECTABLE;
}
void ChessPiece::promote(ChessPieceType* type) {
this->type = type;
this->scene->getComponent<GeometryComponent>(this->entity)->model =
type->getModles()[this->owner];
}
ChessPieceType* ChessPiece::getType() const {
return this->type;
}
Scene* ChessPiece::getScene() const {
return this->scene;
}
unsigned ChessPiece::getOwner() const {
return this->owner;
}
const glm::ivec2& ChessPiece::getPositon() const {
return this->positon;
}
void ChessPiece::setPosition(const glm::ivec2& pos) {
this->has_moved = true;
this->positon = pos;
this->scene->getComponent<PositionComponent>(this->entity)->position =
2.0f * glm::vec3(pos.x, 0, pos.y);
}
Scene::EntityID ChessPiece::getEntity() {
return this->entity;
}
bool ChessPiece::isAlive() const {
return this->is_alive;
}
void ChessPiece::kill() {
auto posComp = this->scene->getComponent<PositionComponent>(this->entity);
posComp->position.y -= -1000;
this->is_alive = true;
}
void ChessPiece::reset() {
this->setPosition(this->start_positon);
this->is_alive = true;
this->has_moved = false;
this->type = this->original_type;
this->scene->getComponent<GeometryComponent>(this->entity)->model =
this->type->getModles()[this->owner];
}
bool ChessPiece::hasMoved() const {
return this->has_moved;
}
void ChessPiece::updatePossibleMoves(const ChessBoard& board) {
this->possible_moves.clear();
if(this->is_alive) {
this->type->getMoveSet().getAvailableMoves(
this, board, this->possible_moves);
}
}
const std::vector<MoveSet::Move>& ChessPiece::getPossibleMoves() const {
return this->possible_moves;
}
| 24.513761
| 80
| 0.706961
|
JoachimHerber
|
660d6eb475ae4f27bd98426e77b164e14789c2c6
| 4,557
|
cpp
|
C++
|
test/unit/ut_semaphore/ut_semaphore.cpp
|
moslevin/Mark3
|
780aeae99d47cb0ddae611b80597305ec852e588
|
[
"BSD-3-Clause"
] | 11
|
2018-09-13T12:12:18.000Z
|
2021-05-12T23:11:09.000Z
|
test/unit/ut_semaphore/ut_semaphore.cpp
|
moslevin/Mark3
|
780aeae99d47cb0ddae611b80597305ec852e588
|
[
"BSD-3-Clause"
] | 1
|
2019-02-18T20:37:22.000Z
|
2019-02-18T20:37:22.000Z
|
test/unit/ut_semaphore/ut_semaphore.cpp
|
moslevin/Mark3
|
780aeae99d47cb0ddae611b80597305ec852e588
|
[
"BSD-3-Clause"
] | 8
|
2018-09-13T12:12:27.000Z
|
2021-07-04T10:59:44.000Z
|
/*===========================================================================
_____ _____ _____ _____
___| _|__ __|_ |__ __|__ |__ __| __ |__ ______
| \ / | || \ || | || |/ / ||___ |
| \/ | || \ || \ || \ ||___ |
|__/\__/|__|_||__|\__\ __||__|\__\ __||__|\__\ __||______|
|_____| |_____| |_____| |_____|
--[Mark3 Realtime Platform]--------------------------------------------------
Copyright (c) 2012 - 2019 m0slevin, all rights reserved.
See license.txt for more information
===========================================================================*/
//---------------------------------------------------------------------------
#include "kerneltypes.h"
#include "kernel.h"
#include "../ut_platform.h"
#include "ksemaphore.h"
#include "thread.h"
#include "memutil.h"
#include "driver.h"
//===========================================================================
// Local Defines
//===========================================================================
namespace
{
using namespace Mark3;
Thread clThread;
K_WORD aucStack[PORT_KERNEL_DEFAULT_STACK_SIZE];
Semaphore clSem1;
Semaphore clSem2;
volatile uint8_t u8Counter = 0;
} // anonymous namespace
namespace Mark3
{
//===========================================================================
// Define Test Cases Here
//===========================================================================
TEST(ut_semaphore_count)
{
// Test - verify that we can only increment a counting semaphore to the
// maximum count.
// Verify that a counting semaphore with an initial count of zero and a
// maximum count of 10 can only be posted 10 times before saturaiton and
// failure.
Semaphore clTestSem;
clTestSem.Init(0, 10);
for (int i = 0; i < 10; i++) { EXPECT_TRUE(clTestSem.Post()); }
EXPECT_FALSE(clTestSem.Post());
}
//===========================================================================
TEST(ut_semaphore_post_pend)
{
auto lPostPend = [](void* param_) {
auto* pclSem = static_cast<Semaphore*>(param_);
while (1) {
pclSem->Pend();
u8Counter++;
}
};
// Test - Make sure that pending on a semaphore causes a higher-priority
// waiting thread to block, and that posting that semaphore from a running
// lower-priority thread awakens the higher-priority thread
clSem1.Init(0, 1);
clThread.Init(aucStack, sizeof(aucStack), 7, lPostPend, (void*)&clSem1);
clThread.Start();
for (int i = 0; i < 10; i++) { clSem1.Post(); }
// Verify all 10 posts have been acknowledged by the high-priority thread
EXPECT_EQUALS(u8Counter, 10);
// After the test is over, kill the test thread.
clThread.Exit();
// Test - same as above, but with a counting semaphore instead of a
// binary semaphore. Also using a default value.
clSem2.Init(10, 10);
// Restart the test thread.
u8Counter = 0;
clThread.Init(aucStack, sizeof(aucStack), 7, lPostPend, (void*)&clSem2);
clThread.Start();
// We'll kill the thread as soon as it blocks.
clThread.Exit();
// semaphore should have pended 10 times before returning.
EXPECT_EQUALS(u8Counter, 10);
}
//===========================================================================
TEST(ut_semaphore_timed)
{
auto lTimedSem = [](void* param_) {
auto* pclSem = static_cast<Semaphore*>(param_);
Thread::Sleep(20);
pclSem->Post();
Scheduler::GetCurrentThread()->Exit();
};
Semaphore clTestSem;
Semaphore clTestSem2;
clTestSem.Init(0, 1);
clThread.Init(aucStack, sizeof(aucStack), 7, lTimedSem, (void*)&clTestSem);
clThread.Start();
EXPECT_FALSE(clTestSem.Pend(10));
Thread::Sleep(20);
// Pretty nuanced - we can only re-init the semaphore under the knowledge
// that there's nothing blocking on it already... don't do this in
// production
clTestSem2.Init(0, 1);
clThread.Init(aucStack, sizeof(aucStack), 7, lTimedSem, (void*)&clTestSem2);
clThread.Start();
EXPECT_TRUE(clTestSem2.Pend(30));
}
//===========================================================================
// Test Whitelist Goes Here
//===========================================================================
TEST_CASE_START
TEST_CASE(ut_semaphore_count), TEST_CASE(ut_semaphore_post_pend), TEST_CASE(ut_semaphore_timed), TEST_CASE_END
} // namespace Mark3
| 32.319149
| 110
| 0.507571
|
moslevin
|
660e7684082c8d169e8024b5adff21757016f2cf
| 463
|
cpp
|
C++
|
1_screen_pipeline/02_build_cre/src/paths.cpp
|
weng-lab/SCREEN
|
e8e7203e2f9baa2de70e2f75bdad3ae24b568367
|
[
"MIT"
] | 5
|
2020-07-30T02:35:20.000Z
|
2020-12-24T01:26:47.000Z
|
1_screen_pipeline/02_build_cre/src/paths.cpp
|
weng-lab/SCREEN
|
e8e7203e2f9baa2de70e2f75bdad3ae24b568367
|
[
"MIT"
] | 6
|
2021-03-04T10:30:11.000Z
|
2022-03-16T16:47:47.000Z
|
1_screen_pipeline/02_build_cre/src/paths.cpp
|
weng-lab/SCREEN
|
e8e7203e2f9baa2de70e2f75bdad3ae24b568367
|
[
"MIT"
] | 2
|
2020-12-08T10:05:02.000Z
|
2022-03-10T09:41:19.000Z
|
//
// SPDX-License-Identifier: MIT
// Copyright (c) 2016-2020 Michael Purcaro, Henry Pratt, Jill Moore, Zhiping Weng
//
#include "paths.hpp"
namespace bib {
const std::string FileNames::AllGenes = "all-genes.txt";
const std::string FileNames::PcGenes = "pc-genes.txt";
const std::string FileNames::Tads = "tads.txt";
const std::string FileNames::cREs = "cREs.bed";
const std::string FileNames::EnsembleToID = "ensebleToID.txt";
} // namespace bib
| 27.235294
| 81
| 0.699784
|
weng-lab
|
66162f0c3c3438c5eef1f40d16a262abb503b556
| 9,867
|
cpp
|
C++
|
devtools/lit/unittests/ShellLexerTest.cpp
|
normal-coder/polarphp
|
a06e1f8781b4b75a2ca8cf2c22e0aa62631866fe
|
[
"PHP-3.01"
] | 1
|
2019-01-28T01:33:49.000Z
|
2019-01-28T01:33:49.000Z
|
devtools/lit/unittests/ShellLexerTest.cpp
|
normal-coder/polarphp
|
a06e1f8781b4b75a2ca8cf2c22e0aa62631866fe
|
[
"PHP-3.01"
] | null | null | null |
devtools/lit/unittests/ShellLexerTest.cpp
|
normal-coder/polarphp
|
a06e1f8781b4b75a2ca8cf2c22e0aa62631866fe
|
[
"PHP-3.01"
] | null | null | null |
// This source file is part of the polarphp.org open source project
//
// Copyright (c) 2017 - 2018 polarphp software foundation
// Copyright (c) 2017 - 2018 zzu_softboy <zzu_softboy@163.com>
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://polarphp.org/LICENSE.txt for license information
// See https://polarphp.org/CONTRIBUTORS.txt for the list of polarphp project authors
//
// Created by polarboy on 2018/09/16.
#include <gtest/gtest.h>
#include "ShellUtil.h"
#include <filesystem>
using polar::lit::ShLexer;
using polar::lit::ShellTokenType;
TEST(ShellLexerTest, testBasic)
{
std::list<std::any> tokens = ShLexer("a|b>c&d<e;f").lex();
ASSERT_EQ(tokens.size(), 11);
std::list<std::any>::iterator iter = tokens.begin();
{
std::any tokenAny = *iter;
ASSERT_EQ(tokenAny.type(), typeid(ShellTokenType));
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "a");
ASSERT_EQ(std::get<1>(token), -1);
}
++iter;
{
std::any tokenAny = *iter;
ASSERT_EQ(tokenAny.type(), typeid(ShellTokenType));
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "|");
ASSERT_EQ(std::get<1>(token), -1);
}
++iter;
{
std::any tokenAny = *iter;
ASSERT_EQ(tokenAny.type(), typeid(ShellTokenType));
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "b");
ASSERT_EQ(std::get<1>(token), -1);
}
++iter;
{
std::any tokenAny = *iter;
ASSERT_EQ(tokenAny.type(), typeid(ShellTokenType));
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), ">");
ASSERT_EQ(std::get<1>(token), -1);
}
++iter;
{
std::any tokenAny = *iter;
ASSERT_EQ(tokenAny.type(), typeid(ShellTokenType));
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "c");
ASSERT_EQ(std::get<1>(token), -1);
}
++iter;
{
std::any tokenAny = *iter;
ASSERT_EQ(tokenAny.type(), typeid(ShellTokenType));
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "&");
ASSERT_EQ(std::get<1>(token), -1);
}
++iter;
{
std::any tokenAny = *iter;
ASSERT_EQ(tokenAny.type(), typeid(ShellTokenType));
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "d");
ASSERT_EQ(std::get<1>(token), -1);
}
++iter;
{
std::any tokenAny = *iter;
ASSERT_EQ(tokenAny.type(), typeid(ShellTokenType));
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "<");
ASSERT_EQ(std::get<1>(token), -1);
}
++iter;
{
std::any tokenAny = *iter;
ASSERT_EQ(tokenAny.type(), typeid(ShellTokenType));
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "e");
ASSERT_EQ(std::get<1>(token), -1);
}
++iter;
{
std::any tokenAny = *iter;
ASSERT_EQ(tokenAny.type(), typeid(ShellTokenType));
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), ";");
ASSERT_EQ(std::get<1>(token), -1);
}
++iter;
{
std::any tokenAny = *iter;
ASSERT_EQ(tokenAny.type(), typeid(ShellTokenType));
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "f");
ASSERT_EQ(std::get<1>(token), -1);
}
}
TEST(ShellLexerTest, testRedirectionTokens)
{
{
std::list<std::any> tokens = ShLexer("a2>c").lex();
ASSERT_EQ(tokens.size(), 3);
std::list<std::any>::iterator iter = tokens.begin();
{
std::any tokenAny = *iter;
ASSERT_EQ(tokenAny.type(), typeid(ShellTokenType));
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "a2");
ASSERT_EQ(std::get<1>(token), -1);
}
++iter;
{
std::any tokenAny = *iter;
ASSERT_EQ(tokenAny.type(), typeid(ShellTokenType));
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), ">");
ASSERT_EQ(std::get<1>(token), -1);
}
++iter;
{
std::any tokenAny = *iter;
ASSERT_EQ(tokenAny.type(), typeid(ShellTokenType));
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "c");
ASSERT_EQ(std::get<1>(token), -1);
}
}
{
std::list<std::any> tokens = ShLexer("a 2>c").lex();
ASSERT_EQ(tokens.size(), 3);
std::list<std::any>::iterator iter = tokens.begin();
{
std::any tokenAny = *iter;
ASSERT_EQ(tokenAny.type(), typeid(ShellTokenType));
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "a");
ASSERT_EQ(std::get<1>(token), -1);
}
++iter;
{
std::any tokenAny = *iter;
ASSERT_EQ(tokenAny.type(), typeid(ShellTokenType));
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), ">");
ASSERT_EQ(std::get<1>(token), 2);
}
++iter;
{
std::any tokenAny = *iter;
ASSERT_EQ(tokenAny.type(), typeid(ShellTokenType));
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "c");
ASSERT_EQ(std::get<1>(token), -1);
}
}
}
TEST(ShellLexerTest, testQuoting)
{
{
std::list<std::any> tokens = ShLexer(R"('a')").lex();
ASSERT_EQ(tokens.size(), 1);
std::list<std::any>::iterator iter = tokens.begin();
{
std::any tokenAny = *iter;
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "a");
ASSERT_EQ(std::get<1>(token), -1);
}
}
{
std::list<std::any> tokens = ShLexer(R"("hello\"world")").lex();
ASSERT_EQ(tokens.size(), 1);
std::list<std::any>::iterator iter = tokens.begin();
{
std::any tokenAny = *iter;
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "hello\"world");
ASSERT_EQ(std::get<1>(token), -1);
}
}
{
std::list<std::any> tokens = ShLexer(R"("hello\'world")").lex();
ASSERT_EQ(tokens.size(), 1);
std::list<std::any>::iterator iter = tokens.begin();
{
std::any tokenAny = *iter;
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "hello\\'world");
ASSERT_EQ(std::get<1>(token), -1);
}
}
{
std::list<std::any> tokens = ShLexer(R"("hello\\\\world")").lex();
ASSERT_EQ(tokens.size(), 1);
std::list<std::any>::iterator iter = tokens.begin();
{
std::any tokenAny = *iter;
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "hello\\\\world");
ASSERT_EQ(std::get<1>(token), -1);
}
}
{
std::list<std::any> tokens = ShLexer(R"(he"llo wo"rld)").lex();
ASSERT_EQ(tokens.size(), 1);
std::list<std::any>::iterator iter = tokens.begin();
{
std::any tokenAny = *iter;
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "hello world");
ASSERT_EQ(std::get<1>(token), -1);
}
}
{
std::list<std::any> tokens = ShLexer(R"(a\ b a\\b)").lex();
ASSERT_EQ(tokens.size(), 2);
std::list<std::any>::iterator iter = tokens.begin();
{
{
std::any tokenAny = *iter;
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "a b");
ASSERT_EQ(std::get<1>(token), -1);
}
++iter;
{
std::any tokenAny = *iter;
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "a\\b");
ASSERT_EQ(std::get<1>(token), -1);
}
}
}
{
std::list<std::any> tokens = ShLexer(R"("" "")").lex();
ASSERT_EQ(tokens.size(), 2);
std::list<std::any>::iterator iter = tokens.begin();
{
{
std::any tokenAny = *iter;
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "");
ASSERT_EQ(std::get<1>(token), -1);
}
++iter;
{
std::any tokenAny = *iter;
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "");
ASSERT_EQ(std::get<1>(token), -1);
}
}
}
{
std::list<std::any> tokens = ShLexer(R"(a\ b)", true).lex();
ASSERT_EQ(tokens.size(), 2);
std::list<std::any>::iterator iter = tokens.begin();
{
{
std::any tokenAny = *iter;
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "a\\");
ASSERT_EQ(std::get<1>(token), -1);
}
++iter;
{
std::any tokenAny = *iter;
ShellTokenType &token = std::any_cast<ShellTokenType &>(tokenAny);
ASSERT_EQ(std::get<0>(token), "b");
ASSERT_EQ(std::get<1>(token), -1);
}
}
}
}
| 33.907216
| 85
| 0.560657
|
normal-coder
|
661f37f1d64155fc4a3ac30345d0ae4fdd261a72
| 10,616
|
cpp
|
C++
|
HW6/Helbling-Hokeemon.cpp
|
cole-h/CISP-400
|
d73b0794a768f8f01bd68867e8950159bb3f2476
|
[
"MIT"
] | 1
|
2020-08-09T16:45:45.000Z
|
2020-08-09T16:45:45.000Z
|
HW6/Helbling-Hokeemon.cpp
|
cole-h/CISP-400
|
d73b0794a768f8f01bd68867e8950159bb3f2476
|
[
"MIT"
] | null | null | null |
HW6/Helbling-Hokeemon.cpp
|
cole-h/CISP-400
|
d73b0794a768f8f01bd68867e8950159bb3f2476
|
[
"MIT"
] | 1
|
2022-03-20T00:06:05.000Z
|
2022-03-20T00:06:05.000Z
|
/*
** Hokeemon.cpp - Homework 6: Hokeemon
** Cole Helbling, CISP 400
** 31 March 2018
*/
#include <algorithm>
#include <cassert>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <memory>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
class Creature;
// Function Prototypes
void Feed(vector<unique_ptr<Creature>> &);
void Listen(vector<unique_ptr<Creature>> &);
void Menu(vector<unique_ptr<Creature>> &, char &);
void PassTime(vector<unique_ptr<Creature>> &);
void Play(vector<unique_ptr<Creature>> &);
void ProgramGreeting();
void Resurrect(vector<unique_ptr<Creature>> &);
// Specification 6 - Implement with an abstract base class called Creature()
class Creature
{
public:
bool dead = false;
bool unresponsive = false;
int boredom = 0;
int hunger = 0;
string mood;
string name;
// Specification 3 - Use a constructor to initialize hunger and boredom to random numbers between 0 - 9
// NOTE - Hunger is initialized to random between 0 - 4 due to death occurring at 10
Creature(string n)
{
// Feature 1 - Name creature
name = n;
hunger = rand() % 5;
boredom = rand() % 10;
// Feature 3 - Assert to make sure hunger and boredom don't underflow
assert(hunger >= 0);
assert(boredom >= 0);
}
virtual string getName() = 0;
virtual void incrementHunger() = 0;
virtual void incrementBoredom() = 0;
// Feature 2 - Moods based on boredom level
void setMood()
{
if (boredom >= 0 && boredom < 5)
mood = "Happy";
if (boredom >= 5 && boredom < 10)
mood = "OK";
if (boredom >= 10 && boredom < 15)
mood = "Frustrated";
if (boredom >= 15 && boredom < 20)
mood = "Mad";
if (boredom >= 20)
mood = "Catatonic";
if (hunger >= 10)
mood = "Dead";
}
string getMood()
{
return mood;
}
int getHunger()
{
return hunger;
}
int getBoredom()
{
return boredom;
}
void decrementHunger()
{
hunger -= 4;
if (hunger < 0)
hunger = 0;
}
void decrementBoredom()
{
boredom -= 4;
if (boredom < 0)
boredom = 0;
}
void setDead(int revive = 0)
{
if (revive)
{
dead = false;
unresponsive = false;
}
if (!revive)
{
dead = true;
cout << this->getName() << " just died from neglect! You monster!\n";
}
}
void setCatatonic()
{
unresponsive = true;
cout << this->getName() << " is now unresponsive due to neglect.\n";
}
int getStatus()
{
if (dead)
return 1;
if (unresponsive)
return 2;
return 0;
}
void Reset()
{
hunger = 0;
boredom = 0;
setMood();
}
};
// Specification 7a - Instantiate using child classes (at least 2), each child represents a different type of Hokeemon.
class Big : public Creature
{
public:
Big(string n) : Creature(n)
{
}
string getName()
{
return "Big " + name;
}
void incrementHunger()
{
if (hunger < 10)
hunger += 2;
}
void incrementBoredom()
{
if (boredom < 20)
boredom += 2;
}
};
// Specification 7b - Instantiate using child classes (at least 2), each child represents a different type of Hokeemon.
class Small : public Creature
{
public:
Small(string n) : Creature(n)
{
}
string getName()
{
return "Small " + name;
}
void incrementHunger()
{
if (hunger < 10)
hunger++;
}
void incrementBoredom()
{
if (boredom < 20)
boredom++;
}
};
int main()
{
srand(time(NULL));
char choice;
int max = (rand() % 6) + 1;
string name;
vector<unique_ptr<Creature>> creatures;
vector<string> names;
ProgramGreeting();
cout << "You have been given " << max << " creatures, congratulations!\n";
for (int i = 0; i < max; i++)
{
cout << "Input the name of creature #" << i + 1 << ": ";
cin >> name;
names.push_back(name);
}
for (int i = 0; i < max; i++)
{
int random = rand() % 2;
if (random == 1)
creatures.push_back(make_unique<Big>(names[i]));
else if (random == 0)
creatures.push_back(make_unique<Small>(names[i]));
creatures[i]->setMood();
}
do
{
cin.clear();
cin.sync();
Menu(creatures, choice);
PassTime(creatures);
} while (choice != 'q' && choice != 'Q');
cout << "\nGoodbye! Your living creatures will be released back into the wild.\n";
return 0;
}
void ProgramGreeting()
{
cout << "Welcome to HW6, \"Hokeemon\", a Pokemon wannabe! 'Big' creatures gain hunger and boredom twice as fast as 'Small' creatures.\n\n";
}
// Specification 1 - You will need to implement a PassTime() method which will increase hunger and boredom by 1. This will be called after Listen, Play or Feed.
void PassTime(vector<unique_ptr<Creature>> & creatures)
{
for (size_t i = 0, max = creatures.size(); i != max; i++)
{
creatures[i]->incrementHunger();
creatures[i]->incrementBoredom();
// Specification 4 - If hunger exceeds 10, your Hokeemon will die of starvation!
if (creatures[i]->getHunger() >= 10 && creatures[i]->getStatus() != 1)
creatures[i]->setDead();
// Specification 5 - If boredom exceeds 20, your hokeemon will slip into an unresponsive, catatonic state.
if (creatures[i]->getBoredom() >= 20 && creatures[i]->getStatus() == 0)
creatures[i]->setCatatonic();
creatures[i]->setMood();
}
}
// Specification 2 - Create a numeric menu which will allow you to select Listen, Play, Feed, or Quit. Do not accept any other options.
void Menu(vector<unique_ptr<Creature>> & creatures, char & choice)
{
size_t j = 0;
for (size_t i = 0, max = creatures.size(); i != max; i++)
{
if (creatures[i]->getStatus() == 1)
j++;
if (j >= max)
{
cout << "\nAll your creatures are dead. Seek professional help before you cause harm to living beings.\n";
choice = 'q';
return;
}
}
cout << "\n\nl :: Listen to a creature\np :: Play with a creature\nf :: Feed a creature\nr :: Resurrect a dead creature at the cost of a living creature\nq :: Exit\n\n";
cin >> choice;
switch (choice)
{
case 'l':
case 'L':
Listen(creatures);
break;
case 'p':
case 'P':
Play(creatures);
break;
case 'f':
case 'F':
Feed(creatures);
break;
case 'Q':
case 'q':
break;
// Feature 4 - Resurrect creature at the cost of another (basically necromancy)
case 'r':
case 'R':
Resurrect(creatures);
break;
// Feature 5 - Print all creature's data (pre-PassTime()), hidden
case 'a':
for (size_t i = 0, max = creatures.size(); i != max; i++)
cout << creatures[i]->getName() << ": " << creatures[i]->getMood() << "\t" << creatures[i]->getBoredom() << " " << creatures[i]->getHunger() << " " << creatures[i]->getStatus() << endl;
cout << endl;
break;
default:
cout << "Invalid choice.\n";
break;
}
}
void Listen(vector<unique_ptr<Creature>> & creatures)
{
size_t index;
cout << "Which creature would you like to listen to? ";
cin >> index;
while (cin.fail() || index < 0 || index > (creatures.size() - 1))
{
cin.clear();
cin.ignore();
cout << "Invalid choice.\nWhich creature would you like to listen to? ";
cin >> index;
}
if (creatures[index]->getStatus() == 0)
cout << creatures[index]->getName() << ": My hunger is at " << creatures[index]->getHunger() << " out of 10,\n\t\tmy boredom is at " << creatures[index]->getBoredom() << " out of 20,\n\t\tand my mood is " << creatures[index]->getMood() << ".\n";
else if (creatures[index]->getStatus() == 1)
cout << creatures[index]->getName() << " is dead.\n";
else if (creatures[index]->getStatus() == 2)
cout << creatures[index]->getName() << " is unresponsive.\n";
return;
}
void Play(vector<unique_ptr<Creature>> & creatures)
{
size_t index;
cout << "Which creature would you like to play with? ";
cin >> index;
while (cin.fail() || index < 0 || index > (creatures.size() - 1))
{
cin.clear();
cin.ignore();
cout << "Invalid choice.\nWhich creature would you like to play with? ";
cin >> index;
}
if (creatures[index]->getStatus() == 0)
{
creatures[index]->decrementBoredom();
cout << creatures[index]->getName() << ": Yippee! My boredom is now at " << creatures[index]->getBoredom() << " out of 20.\n";
}
else if (creatures[index]->getStatus() == 1)
cout << creatures[index]->getName() << " is dead.\n";
else if (creatures[index]->getStatus() == 2)
cout << creatures[index]->getName() << " is unresponsive.\n";
return;
}
void Feed(vector<unique_ptr<Creature>> & creatures)
{
size_t index;
cout << "Which creature would you like to feed? ";
cin >> index;
while (cin.fail() || index < 0 || index > (creatures.size() - 1))
{
cin.clear();
cin.ignore();
cout << "Invalid choice.\nWhich creature would you like to feed? ";
cin >> index;
}
if (creatures[index]->getStatus() == 0)
{
creatures[index]->decrementHunger();
cout << creatures[index]->getName() << ": Yummy! My hunger is now at " << creatures[index]->getHunger() << " out of 10.\n";
}
else if (creatures[index]->getStatus() == 1)
cout << creatures[index]->getName() << " is dead.\n";
else if (creatures[index]->getStatus() == 2)
cout << creatures[index]->getName() << " is unresponsive.\n";
return;
}
void Resurrect(vector<unique_ptr<Creature>> & creatures)
{
size_t revive, kill;
if (creatures.size() < 2)
{
cout << "You need at least 2 creatures to trade lives.\n";
return;
}
cout << "Which creature would you like to revive, and at the cost of which other creature? ";
cin >> revive >> kill;
while (cin.fail() || revive < 0 || kill < 0 || revive > (creatures.size() - 1) || kill > (creatures.size() - 1))
{
cin.clear();
cin.ignore();
cout << "One of your choices was invalid.\nWhich creature would you like to revive, and at the cost of which other creature? ";
cin >> revive >> kill;
}
if (creatures[revive]->getStatus() == 1 && creatures[kill]->getStatus() == 0)
{
creatures[revive]->Reset();
cout << "Reviving " << creatures[revive]->getName() << ".\nThe creature now has 0 hunger and 0 boredom. Do take better care of it this time.\n";
creatures[revive]->setDead(1);
creatures[kill]->setDead();
}
else if (creatures[revive]->getStatus() != 1)
cout << creatures[revive]->getName() << " is not (yet) dead.\n";
else if (creatures[kill]->getStatus() != 0)
cout << creatures[kill]->getName() << " is nota valid candidate.\n";
return;
}
| 24.072562
| 248
| 0.604088
|
cole-h
|
6625ac20637b329b68f7ac8ef029fb7751639c04
| 1,830
|
cpp
|
C++
|
lib/smooth/core/util/string_util.cpp
|
luuvt/lms
|
8f53ddeb62e9ca328acb36b922bf72e223ff3753
|
[
"Apache-2.0"
] | 283
|
2017-07-18T15:31:42.000Z
|
2022-03-30T12:05:03.000Z
|
lib/smooth/core/util/string_util.cpp
|
luuvt/lms
|
8f53ddeb62e9ca328acb36b922bf72e223ff3753
|
[
"Apache-2.0"
] | 131
|
2017-08-23T18:49:03.000Z
|
2021-11-29T08:03:21.000Z
|
lib/smooth/core/util/string_util.cpp
|
luuvt/lms
|
8f53ddeb62e9ca328acb36b922bf72e223ff3753
|
[
"Apache-2.0"
] | 53
|
2017-12-31T13:34:21.000Z
|
2022-02-04T11:26:49.000Z
|
/*
Smooth - A C++ framework for embedded programming on top of Espressif's ESP-IDF
Copyright 2019 Per Malmberg (https://gitbub.com/PerMalmberg)
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 <string>
#include <algorithm>
namespace smooth::core::string_util
{
void replace_all(std::string& s, const std::string& token, const std::string& replacement)
{
auto pos = s.find(token);
while (pos != std::string::npos)
{
s.replace(pos, token.length(), replacement);
pos = s.find(token);
}
}
bool icontains(const std::string& s, const std::string& to_find)
{
auto iequal = [](const unsigned char c, const unsigned char c2)
{
return std::tolower(c) == std::tolower(c2);
};
return std::search(s.begin(), s.end(), to_find.begin(), to_find.end(), iequal) != s.end();
}
bool equals(const std::string& s, const std::string& s2)
{
return s == s2;
}
bool iequals(const std::string& s, const std::string& s2)
{
return std::equal(s.begin(), s.end(), s2.begin(), s2.end(),
[](unsigned char c, unsigned char c2) {
return std::toupper(c) == std::toupper(c2);
});
}
}
| 32.105263
| 98
| 0.603825
|
luuvt
|
662788ddca8eb5ac1918817ce0b3a0701c6a075b
| 21,660
|
cpp
|
C++
|
clib/TextCompare.cpp
|
dehilsterlexis/eclide-1
|
0c1685cc7165191b5033d450c59aec479f01010a
|
[
"Apache-2.0"
] | 8
|
2016-08-29T13:34:18.000Z
|
2020-12-04T15:20:36.000Z
|
clib/TextCompare.cpp
|
dehilsterlexis/eclide-1
|
0c1685cc7165191b5033d450c59aec479f01010a
|
[
"Apache-2.0"
] | 221
|
2016-06-20T19:51:48.000Z
|
2022-03-29T20:46:46.000Z
|
clib/TextCompare.cpp
|
dehilsterlexis/eclide-1
|
0c1685cc7165191b5033d450c59aec479f01010a
|
[
"Apache-2.0"
] | 13
|
2016-06-24T15:59:31.000Z
|
2022-01-01T11:48:20.000Z
|
#include "StdAfx.h"
#include "TextCompare.h"
namespace CLIB
{
// ===========================================================================
CLine::CLine() : m_origText(_T("\r\n"))
{
m_type = TYPE_UNKNOWN;
hash_string(m_origText);
m_charType.resize(m_origText.length(), CLine::TYPE_MATCH);
}
CLine::CLine(TYPE type) : m_origText(_T("\r\n"))
{
m_type = type;
hash_string(m_origText);
m_charType.resize(m_origText.length(), CLine::TYPE_MATCH);
}
CLine::CLine(const std::_tstring & text) : m_origText(text)
{
m_type = TYPE_UNKNOWN;
hash_string(m_origText);
m_charType.resize(m_origText.length(), CLine::TYPE_MATCH);
}
void CLine::SetType(TYPE type)
{
if (m_type == TYPE_UNKNOWN)
m_type = type;
}
CLine::TYPE CLine::GetType() const
{
return m_type;
}
int CLine::GetLength() const
{
return m_origText.size();
}
void CLine::SetCharType(size_t charPos, TYPE type)
{
if (charPos < m_charType.size())
m_charType[charPos] = type;
}
CLine::TYPE CLine::GetCharType(size_t charPos) const
{
return m_charType[charPos];
}
const TCHAR * CLine::GetText() const
{
return m_origText.c_str();
}
unsigned int CLine::Distance(const CLine & other) const
{
const std::_tstring & source = m_origText;
const std::_tstring & target = other.m_origText;
// Step 1
#define CUTOFF 160
const int n = source.length() > CUTOFF ? CUTOFF : source.length();
const int m = target.length() > CUTOFF ? CUTOFF : target.length();
if (n == 0) {
return m;
}
if (m == 0) {
return n;
}
typedef std::vector< std::vector<int> > Tmatrix;
Tmatrix matrix(n+1);
// Size the vectors in the 2.nd dimension. Unfortunately C++ doesn't
// allow for allocation on declaration of 2.nd dimension of vec of vec
for (int i = 0; i <= n; i++) {
matrix[i].resize(m+1);
}
// Step 2
for (int i = 0; i <= n; i++) {
matrix[i][0]=i;
}
for (int j = 0; j <= m; j++) {
matrix[0][j]=j;
}
// Step 3
for (int i = 1; i <= n; i++) {
const TCHAR s_i = source[i-1];
// Step 4
for (int j = 1; j <= m; j++) {
const TCHAR t_j = target[j-1];
// Step 5
int cost;
if (s_i == t_j) {
cost = 0;
}
else {
cost = 1;
}
// Step 6
const int above = matrix[i-1][j];
const int left = matrix[i][j-1];
const int diag = matrix[i-1][j-1];
int cell = min( above + 1, min(left + 1, diag + cost));
// Step 6A: Cover transposition, in addition to deletion,
// insertion and substitution. This step is taken from:
// Berghel, Hal ; Roach, David : "An Extension of Ukkonen's
// Enhanced Dynamic Programming ASM Algorithm"
// (http://www.acm.org/~hlb/publications/asm/asm.html)
if (i>2 && j>2) {
int trans=matrix[i-2][j-2]+1;
if (source[i-2]!=t_j) trans++;
if (s_i!=target[j-2]) trans++;
if (cell>trans) cell=trans;
}
matrix[i][j]=cell;
}
}
// Step 7
return matrix[n][m];
}
bool CLine::Equals(const CLine & other, unsigned int level) const
{
if (level == 0)
return other.GetHash() == GetHash();
else if(level == 1)
return other.GetAnchorHash() == GetAnchorHash();
return Distance(other) < level;
}
int CLine::GetAnchorHash() const
{
return m_anchorHash;
}
int CLine::GetHash() const
{
return m_hash;
}
void CLine::hash_string(const std::_tstring & s)
{
// Calc Hash
boost::crc_32_type computer;
computer.reset();
computer.process_bytes(s.c_str(), sizeof(TCHAR) * s.length());
m_hash = computer.checksum();
// Calc Anchor Hash
bool prevIsGraph = true;
static boost::crc_32_type anchorComputer;
anchorComputer.reset();
for (unsigned int i = 0; i < s.length(); ++i)
{
bool isGraph = iswgraph(s[i]) != 0 || s[i] == '\r' || s[i] == '\n';
if (isGraph)
anchorComputer.process_bytes(&s[i], sizeof(TCHAR));
prevIsGraph = isGraph;
}
m_anchorHash = anchorComputer.checksum();
}
// ===========================================================================
const TCHAR * const GUID_START = _T("{EE9F6CEA-6904-4a9e-8D15-F2E225A8C02D}Start{EE9F6CEA-6904-4a9e-8D15-F2E225A8C02D}");
const TCHAR * const GUID_END = _T("{EE9F6CEA-6904-4a9e-8D15-F2E225A8C02D} End {EE9F6CEA-6904-4a9e-8D15-F2E225A8C02D}");
CLine startLine(GUID_START);
CLine endLine(GUID_END);
bool IsDummyLine(const CLine & line)
{
ATLASSERT((line.Equals(startLine, 0) || line.Equals(endLine, 0)) == false);
return (line.Equals(startLine, 0) || line.Equals(endLine, 0));
}
CTable::CTable()
{
}
CTable::CTable(const std::_tstring & table, bool line)
{
m_rows.push_back(CLine(GUID_START));
if (line)
parse_line(table);
else
parse_rows(table);
m_rows.push_back(CLine(GUID_END));
}
CTable::CTable(const CTable & table, unsigned int from, unsigned int to)
{
m_rows.push_back(CLine(GUID_START));
if (from == 0)
++from;
if (to == table.size())
--to;
for (unsigned int i = from; i < to; ++i)
m_rows.push_back(table[i]);
m_rows.push_back(CLine(GUID_END));
}
size_t CTable::size() const
{
return m_rows.size();
}
CLine & CTable::operator[](int pos)
{
return m_rows[pos];
}
const CLine & CTable::operator[](int pos) const
{
return m_rows[pos];
}
void CTable::push_back(const CLine & row)
{
m_rows.push_back(row);
}
void CTable::Insert(int pos, int length, CLine::TYPE type)
{
m_rows.insert(m_rows.begin() + pos, CLine());
Mark(pos, length, type);
}
void CTable::Mark(int start, int length, CLine::TYPE type)
{
for(int i = start; i < start + length; ++i)
{
m_rows[i].SetType(type);
}
}
void CTable::Get(CLineVector & results)
{
results.clear();
results.reserve(m_rows.size() - 2);
for(CLineVector::iterator itr = m_rows.begin(); itr != m_rows.end();)
{
CLineVector::iterator this_itr = itr++;
if (this_itr != m_rows.begin() && itr != m_rows.end())
results.push_back(*this_itr);
}
}
void CTable::parse_rows(const std::_tstring & table)
{
std::_tstring line;
for(std::size_t i = 0; i < table.size(); ++i)
{
line += table[i];
if (table[i] == _T('\n'))
{
m_rows.push_back(CLine(line));
line = _T("");
}
}
if (line.size())
m_rows.push_back(CLine(line));
}
void CTable::parse_line(const std::_tstring & table)
{
for(std::size_t i = 0; i < table.size(); ++i)
{
std::_tstring tchar;
tchar.resize(1, table[i]);
m_rows.push_back(CLine(tchar));
}
}
// ===========================================================================
CMatchBlock::CMatchBlock()
{
m_base_pos = 0;
m_comp_pos = 0;
m_length = 0;
}
CMatchBlock::CMatchBlock(int base_pos, int comp_pos, int length) : m_base_pos(base_pos), m_comp_pos(comp_pos), m_length(length)
{
}
int CMatchBlock::GetBasePos() const
{
return m_base_pos;
}
int CMatchBlock::GetCompPos() const
{
return m_comp_pos;
}
int CMatchBlock::GetLength() const
{
return m_length;
}
bool CMatchBlock::BaseContains(int pos) const
{
return pos >= m_base_pos && pos < m_base_pos + m_length;
}
bool CMatchBlock::BaseOverlaps(const CMatchBlock & other) const
{
return (other.BaseContains(m_base_pos) || BaseContains(other.m_base_pos));
}
bool CMatchBlock::CompContains(int pos) const
{
return pos >= m_comp_pos && pos < m_comp_pos + m_length;
}
bool CMatchBlock::CompOverlaps(const CMatchBlock & other) const
{
return (other.CompContains(m_comp_pos) || CompContains(other.m_comp_pos));
}
bool CMatchBlock::Overlaps(const CMatchBlock & other) const
{
return (BaseOverlaps(other) || CompOverlaps(other));
}
bool CMatchBlock::OverlapAndSplit(const CMatchBlock & other, CMatchBlockVector & additionalBlocks)
{
// Three Senarios: Other overlaps start of this. Other Overlaps end of this. This is contained between start and end of Other.
ATLASSERT(m_length <= other.m_length);
if (BaseOverlaps(other) && CompOverlaps(other)) //This is contained in Other
{
}
else if (BaseOverlaps(other))
{
}
else if(CompOverlaps(other))
{
}
else
{
ATLASSERT(!Overlaps(other));
return false;
}
return true;
}
bool CMatchBlock::IsBaseBefore(const CMatchBlock & other) const
{
return (m_base_pos + m_length - 1 < other.m_base_pos);
}
bool CMatchBlock::IsBaseAfter(const CMatchBlock & other) const
{
return (other.m_base_pos + other.m_length - 1 < m_base_pos);
}
bool CMatchBlock::IsCompBefore(const CMatchBlock & other) const
{
return (m_comp_pos + m_length - 1 < other.m_comp_pos);
}
bool CMatchBlock::IsCompAfter(const CMatchBlock & other) const
{
return (other.m_comp_pos + other.m_length - 1 < m_comp_pos);
}
class CMatchBlockCompareLength
{
public:
bool operator ()(const CMatchBlock & l, const CMatchBlock & r)
{
if (l.GetLength() == r.GetLength())
{
if (l.GetBasePos() == r.GetBasePos())
return l.GetCompPos() < r.GetCompPos();
return l.GetBasePos() < r.GetBasePos();
}
return l.GetLength() > r.GetLength();
}
};
class CMatchBlockCompareBase
{
public:
bool operator ()(const CMatchBlock & l, const CMatchBlock & r)
{
return l.GetBasePos() < r.GetBasePos();
}
};
class CMatchBlockCompareComp
{
public:
bool operator ()(const CMatchBlock & l, const CMatchBlock & r)
{
return l.GetCompPos() < r.GetCompPos();
}
};
// ===========================================================================
CAnchors::CAnchors(const CTable & baseTable, const CTable & compTable, int accuracy) : m_baseTable(baseTable), m_compTable(compTable), m_accuracy(accuracy)
{
m_anchors.clear();
m_moved.clear();
// Calculate all matches.
CMatchBlockVector matches;
CalculateMatches(matches); //matches are sorted -> largest length, smallest basePos, smallest compPos.
// Remove out of sequence (moved lines).
for(CMatchBlockVector::iterator matches_itr = matches.begin(); matches_itr != matches.end(); ++matches_itr)
{
bool fits_in = m_anchors.size() == 0 ? true : false;
for (CMatchBlockVector::iterator anchors_next_itr = m_anchors.begin(); anchors_next_itr != m_anchors.end();)
{
CMatchBlockVector::iterator anchors_itr = anchors_next_itr++;
if (anchors_itr == m_anchors.begin() && matches_itr->IsBaseBefore(*anchors_itr) && matches_itr->IsCompBefore(*anchors_itr))
{
fits_in = true;
break;
}
if (anchors_next_itr != m_anchors.end() && matches_itr->IsBaseAfter(*anchors_itr) && matches_itr->IsCompAfter(*anchors_itr) &&
matches_itr->IsBaseBefore(*anchors_next_itr) && matches_itr->IsCompBefore(*anchors_next_itr))
{
fits_in = true;
break;
}
if (anchors_next_itr == m_anchors.end() && matches_itr->IsBaseAfter(*anchors_itr) && matches_itr->IsCompAfter(*anchors_itr))
{
fits_in = true;
break;
}
}
if (fits_in)
{
m_anchors.push_back(*matches_itr);
std::sort(m_anchors.begin(), m_anchors.end(), CMatchBlockCompareBase());
}
else
{
m_moved.push_back(*matches_itr);
}
}
std::sort(m_moved.begin(), m_moved.end(), CMatchBlockCompareBase());
}
void CAnchors::GetResults(CLineVector & baseResult, CLineVector & compResult)
{
for(size_t i = 1; i < m_baseTable.size() - 1; ++i)
{
CLine line = m_baseTable[i];
if (AnchorsBaseContains(i))
line.SetType(CLine::TYPE_MATCH);
else
line.SetType(CLine::TYPE_SIMILAR);
baseResult.push_back(line);
}
for(size_t i = 1; i < m_compTable.size() - 1; ++i)
{
CLine line = m_compTable[i];
if (AnchorsCompContains(i))
line.SetType(CLine::TYPE_MATCH);
else
line.SetType(CLine::TYPE_SIMILAR);
compResult.push_back(line);
}
}
void AppendTable(CLineVector & lineVector, const CTable & table, CLine::TYPE type)
{
for (int i = 1; i < (int)table.size() - 1; ++i)
{
CLine line = table[i];
line.SetType(type);
lineVector.push_back(line);
}
}
void AppendBlankLines(CLineVector & lineVector, const CTable & otherTable, CLine::TYPE type)
{
for (int i = 1; i < (int)otherTable.size() - 1; ++i)
{
CLine line;
if (!IsDummyLine(line))
{
line.SetType(otherTable[i].GetType() == CLine::TYPE_MOVED ? CLine::TYPE_MATCH : type);
lineVector.push_back(line);
}
}
}
void SetCharTypes(CLine & line, const CLineVector & lineVector)
{
int charPos = 0;
for(CLineVector::const_iterator itr = lineVector.begin(); itr != lineVector.end(); ++itr)
{
switch(itr->GetType())
{
case CLine::TYPE_DELETED:
case CLine::TYPE_SIMILAR:
case CLine::TYPE_MOVED:
line.SetCharType(charPos, CLine::TYPE_SIMILAR);
break;
}
charPos++;
}
}
void CAnchors::GetPaddedResults(CLineVector & baseResult, CLineVector & compResult) const
{
unsigned int matchCount = GetMatchCount();
unsigned int gapCount = GetGapCount();
unsigned int matchPos = 0;
unsigned int gapPos = 0;
while(matchPos < matchCount)
{
{
CTable baseTable, compTable;
GetMatch(matchPos, baseTable, compTable);
for (int i = 1; i < (int)baseTable.size() - 1; ++i)
{
CLine baseLine = baseTable[i];
CLine compLine = compTable[i];
CLine::TYPE type = baseLine.Equals(compLine, 0) ? CLine::TYPE_MATCH : CLine::TYPE_SIMILAR;
if (type == CLine::TYPE_SIMILAR)
{
CTable baseLineTable(baseLine.GetText(), true);
CTable compLineTable(compLine.GetText(), true);
CAnchors lineAnchors(baseLineTable, compLineTable, 0);
CLineVector baseLineVector, compLineVector;
lineAnchors.GetResults(baseLineVector, compLineVector);
SetCharTypes(baseLine, baseLineVector);
SetCharTypes(compLine, compLineVector);
}
baseLine.SetType(type);
compLine.SetType(type);
baseResult.push_back(baseLine);
compResult.push_back(compLine);
}
ATLASSERT(baseResult.size() == compResult.size());
++matchPos;
}
if (gapPos < gapCount)
{
CTable baseTable, compTable;
GetGap(gapPos, baseTable, compTable);
if (baseTable.size() <= 2) //Added lines
{
ATLASSERT(compTable.size() > 2);
AppendBlankLines(baseResult, compTable, CLine::TYPE_ADDED);
AppendTable(compResult, compTable, CLine::TYPE_ADDED);
}
else if (compTable.size() <= 2) //Deleted lines
{
ATLASSERT(baseTable.size() > 2);
AppendTable(baseResult, baseTable, CLine::TYPE_DELETED);
AppendBlankLines(compResult, baseTable, CLine::TYPE_DELETED);
}
else if (m_accuracy > 35) // Don't recurse too much.
{
AppendTable(baseResult, baseTable, CLine::TYPE_DELETED);
AppendBlankLines(compResult, baseTable, CLine::TYPE_DELETED);
AppendBlankLines(baseResult, compTable, CLine::TYPE_ADDED);
AppendTable(compResult, compTable, CLine::TYPE_ADDED);
}
else
{
CAnchors gapAnchors(baseTable, compTable, m_accuracy + 5);
gapAnchors.GetPaddedResults(baseResult, compResult);
}
ATLASSERT(baseResult.size() == compResult.size());
++gapPos;
}
}
}
bool Contains(const CMatchBlockVector & itmes, unsigned int pos, bool comp)
{
for (CMatchBlockVector::const_iterator item_itr = itmes.begin(); item_itr != itmes.end(); ++item_itr)
{
if (comp && item_itr->CompContains(pos))
return true;
if (!comp && item_itr->BaseContains(pos))
return true;
}
return false;
}
bool CAnchors::AnchorsBaseContains(unsigned int pos) const
{
return Contains(m_anchors, pos, false);
}
bool CAnchors::AnchorsCompContains(unsigned int pos) const
{
return Contains(m_anchors, pos, true);
}
bool CAnchors::MovedBaseContains(unsigned int pos) const
{
return Contains(m_moved, pos, false);
}
bool CAnchors::MovedCompContains(unsigned int pos) const
{
return Contains(m_moved, pos, true);
}
unsigned int CAnchors::GetMatchCount() const
{
return m_anchors.size();
}
void CAnchors::GetMatch(int match, CTable & baseTable, CTable & compTable) const
{
ATLASSERT(match >= 0 && (unsigned int)match < GetMatchCount());
for (CMatchBlockVector::const_iterator anchors_itr = m_anchors.begin(); anchors_itr != m_anchors.end(); ++anchors_itr)
{
if (--match < 0)
{
baseTable = CTable(m_baseTable, anchors_itr->GetBasePos(), anchors_itr->GetBasePos() + anchors_itr->GetLength());
compTable = CTable(m_compTable, anchors_itr->GetCompPos(), anchors_itr->GetCompPos() + anchors_itr->GetLength());
break;
}
}
}
unsigned int CAnchors::GetGapCount() const
{
ATLASSERT(m_anchors.size() >= 1); //Because of dummy 1st and last lines...
return m_anchors.size() - 1;
}
void CAnchors::GetGap(int gap, CTable & baseTable, CTable & compTable) const
{
ATLASSERT(gap >= 0 && (unsigned int)gap < GetGapCount());
for (CMatchBlockVector::const_iterator anchors_next_itr = m_anchors.begin(); anchors_next_itr != m_anchors.end();)
{
CMatchBlockVector::const_iterator anchors_itr = anchors_next_itr++;
if (--gap < 0)
{
baseTable = CTable(m_baseTable, anchors_itr->GetBasePos() + anchors_itr->GetLength(), anchors_next_itr->GetBasePos());
compTable = CTable(m_compTable, anchors_itr->GetCompPos() + anchors_itr->GetLength(), anchors_next_itr->GetCompPos());
for(int i = 0; i < anchors_next_itr->GetBasePos() - (anchors_itr->GetBasePos() + anchors_itr->GetLength()); ++i)
{
if (MovedBaseContains(anchors_itr->GetBasePos() + anchors_itr->GetLength() + i))
baseTable[i + 1].SetType(CLine::TYPE_MOVED);
}
for(int i = 0; i < anchors_next_itr->GetCompPos() - (anchors_itr->GetCompPos() + anchors_itr->GetLength()); ++i)
{
if (MovedCompContains(anchors_itr->GetCompPos() + anchors_itr->GetLength() + i))
compTable[i + 1].SetType(CLine::TYPE_MOVED);
}
break;
}
}
}
void CAnchors::CalculateMatches(CMatchBlockVector & tidied_matches) const
{
CMatchBlockVector matches;
int base_total = m_baseTable.size();
int comp_total = m_compTable.size();
for(int i = 0; i < base_total; ++i)
{
for(int j = 0; j < comp_total; ++j)
{
int match_length = 0;
int match_i = i, match_j = j;
while (match_i < base_total && match_j < comp_total && m_baseTable[match_i].Equals(m_compTable[match_j], m_accuracy))
{
++match_i;
++match_j;
++match_length;
}
for (int all_lengths = 1; all_lengths <= match_length; ++all_lengths)
matches.push_back(CMatchBlock(i, j, all_lengths));
j += match_length;
}
}
// Remove overlaps
bool foundOverlap = true;
//while(foundOverlap)
{
std::sort(matches.begin(), matches.end(), CMatchBlockCompareLength());
for(CMatchBlockVector::iterator matches_itr = matches.begin(); matches_itr != matches.end(); ++matches_itr)
{
foundOverlap = false;
int basePos = matches_itr->GetBasePos();
for(CMatchBlockVector::iterator tidied_matches_itr = tidied_matches.begin(); tidied_matches_itr != tidied_matches.end(); ++tidied_matches_itr)
{
if (matches_itr->Overlaps(*tidied_matches_itr))
{
foundOverlap = true;
break;
}
}
if (!foundOverlap)
// break;
//else
tidied_matches.push_back(*matches_itr);
}
}
}
// ===========================================================================
void TextCompare(const std::_tstring & base, const std::_tstring & comp, CLineVector & baseResult, CLineVector & compResult)
{
if (base.length() == 0 && comp.length() == 0)
return;
CTable baseTable(base);
CTable compTable(comp);
CAnchors compare(baseTable, compTable, 1);
compare.GetPaddedResults(baseResult, compResult);
}
// ===========================================================================
}
| 29.875862
| 155
| 0.579594
|
dehilsterlexis
|
6629235e76a1a3b2d12122c8f6bd85273f47dd7e
| 1,444
|
cpp
|
C++
|
test/to_container.cpp
|
CornedBee/range-v3
|
99a9f5f70e65dfcf6bbc8894bf2a22d8f5d4552a
|
[
"MIT"
] | null | null | null |
test/to_container.cpp
|
CornedBee/range-v3
|
99a9f5f70e65dfcf6bbc8894bf2a22d8f5d4552a
|
[
"MIT"
] | null | null | null |
test/to_container.cpp
|
CornedBee/range-v3
|
99a9f5f70e65dfcf6bbc8894bf2a22d8f5d4552a
|
[
"MIT"
] | null | null | null |
// Range v3 library
//
// Copyright Eric Niebler 2014
//
// Use, modification and distribution is subject to 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)
//
// Project home: https://github.com/ericniebler/range-v3
#include <list>
#include <vector>
#include <range/v3/core.hpp>
#include <range/v3/to_container.hpp>
#include <range/v3/view/iota.hpp>
#include <range/v3/view/transform.hpp>
#include <range/v3/action/sort.hpp>
#include "./simple_test.hpp"
#include "./test_utils.hpp"
int main()
{
using namespace ranges;
auto lst0 = view::ints | view::transform([](int i){return i*i;}) | view::take(10)
| to_<std::list>();
static_assert((bool)Same<decltype(lst0), std::list<int>>(), "");
::check_equal(lst0, {0,1,4,9,16,25,36,49,64,81});
auto vec0 = view::ints | view::transform([](int i){return i*i;}) | view::take(10)
| to_vector | action::sort(std::greater<int>{});
static_assert((bool)Same<decltype(vec0), std::vector<int>>(), "");
::check_equal(vec0, {81,64,49,36,25,16,9,4,1,0});
auto vec1 = view::ints | view::transform([](int i){return i*i;}) | view::take(10)
| to_<std::vector<long>>() | action::sort(std::greater<int>{});
static_assert((bool)Same<decltype(vec1), std::vector<long>>(), "");
::check_equal(vec1, {81,64,49,36,25,16,9,4,1,0});
return ::test_result();
}
| 33.581395
| 85
| 0.641274
|
CornedBee
|
662ad04f8535bd0dc7e99eb360718418e438b1fc
| 3,631
|
hh
|
C++
|
src/callow/preconditioner/Preconditioner.hh
|
RLReed/libdetran
|
77637c788823e0a14aae7e40e476a291f6f3184b
|
[
"MIT"
] | null | null | null |
src/callow/preconditioner/Preconditioner.hh
|
RLReed/libdetran
|
77637c788823e0a14aae7e40e476a291f6f3184b
|
[
"MIT"
] | null | null | null |
src/callow/preconditioner/Preconditioner.hh
|
RLReed/libdetran
|
77637c788823e0a14aae7e40e476a291f6f3184b
|
[
"MIT"
] | null | null | null |
//----------------------------------*-C++-*----------------------------------//
/**
* @file Preconditioner.hh
* @brief Preconditioner
* @author Jeremy Roberts
* @date Sep 18, 2012
*/
//---------------------------------------------------------------------------//
#ifndef callow_PRECONDITIONER_HH_
#define callow_PRECONDITIONER_HH_
#include "callow/callow_export.hh"
#include "callow/callow_config.hh"
#include "callow/vector/Vector.hh"
#include <string>
namespace callow
{
/**
* @class Preconditioner
* @brief Defines a preconditioner for linear solves
*
* Consider the linear system
* \f[
* \mathbf{A}x = b \, .
* \f]
* When using iterative methods to solve this system,
* one can often make the system easier to solve. Suppose
* we define an operator \f$ \mathbf{P} \f$ such that
* \f$ \mathbf{P}^{-1} \mathbf{A} \approx \mathbf{I} \f$.
* If the action of \f$ \mathbf{P}^{-1} \f$ is relatively
* easy to compute (as compared to inverting \mathbf{A}),
* \f$ \mathbf{P} \f$ is a good preconditioner.
*
* We apply a precondition on the left to obtain the
* modified system
* \f[
* \mathbf{P^{-1} A}x = \mathbf{P}^{-1} b \, ,
* \f]
* or on the right to get
* \f[
* \mathbf{AP^{-1}} \overbrace{\mathbf{P}x}^{y} = b \, ,
* \f]
* following which we solve
* \f[
* x = \mathbf{P}^{-1} y \, .
* \f]
*
* Within callow, the Jacobi and ILU(0) preconditioners are
* available along with user-defined shell preconditioners.
* If built with PETSc, all preconditioners are available (to PETSc)
* as shells. Otherwise, the user can set PETSc preconditioners
* with PetscSolver parameters.
*/
class CALLOW_EXPORT Preconditioner
{
public:
//-------------------------------------------------------------------------//
// TYPEDEFS
//-------------------------------------------------------------------------//
typedef detran_utilities::SP<Preconditioner> SP_preconditioner;
//-------------------------------------------------------------------------//
// CONSTRUCTOR & DESTRUCTOR
//-------------------------------------------------------------------------//
Preconditioner(std::string name)
: d_name(name)
{
/* ... */
};
virtual ~Preconditioner(){};
#ifdef DETRAN_ENABLE_PETSC
/**
* set the PETSc preconditioner and do other setup
*
* this should only be called by PetscSolver
*/
void set_petsc_pc(PC pc);
/// return petsc preconditioner
PC petsc_pc() {return d_petsc_pc;}
#endif
/// Return the PC name
std::string name() const {return d_name;}
//-------------------------------------------------------------------------//
// ABSTRACT INTERFACE -- ALL PRECONDITIONERS MUST IMPLEMENT THIS
//-------------------------------------------------------------------------//
/// solve Px = b
virtual void apply(Vector &b, Vector &x) = 0;
protected:
/// pc name
std::string d_name;
#ifdef DETRAN_ENABLE_PETSC
/// PETSc preconditioner
PC d_petsc_pc;
#endif
};
#ifdef DETRAN_ENABLE_PETSC
// this is the function petsc actual calls; internally, it redirects
// to our own operation. all callow preconditioners are viewed by
// petsc as shells.
PetscErrorCode pc_apply_wrapper(PC pc, Vec b, Vec x);
#endif
CALLOW_TEMPLATE_EXPORT(detran_utilities::SP<Preconditioner>)
} // end namespace callow
#include "Preconditioner.i.hh"
#endif // callow_PRECONDITIONER_HH_
//---------------------------------------------------------------------------//
// end of file Preconditioner.hh
//---------------------------------------------------------------------------//
| 27.507576
| 79
| 0.522721
|
RLReed
|
662bd6d227f0653d692b6162b3e752ff52d7bd37
| 1,693
|
hxx
|
C++
|
macros.hxx
|
Arcoth/VTMPL
|
d83e4c6ab2e931bce60761997c782d6679a7cba4
|
[
"BSL-1.0"
] | null | null | null |
macros.hxx
|
Arcoth/VTMPL
|
d83e4c6ab2e931bce60761997c782d6679a7cba4
|
[
"BSL-1.0"
] | null | null | null |
macros.hxx
|
Arcoth/VTMPL
|
d83e4c6ab2e931bce60761997c782d6679a7cba4
|
[
"BSL-1.0"
] | null | null | null |
/* Copyright (c) Arcoth@c-plusplus.net, 2013-2014.
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 MACROS_HXX_INCLUDED
#define MACROS_HXX_INCLUDED
#include <type_traits>
# define VTMPL_SPLIT_1(s, x, m) m(s, x)
# define VTMPL_SPLIT_4(s, x, m) VTMPL_SPLIT_1 (s, x, m), VTMPL_SPLIT_1 (s, x+1 , m), VTMPL_SPLIT_1 (s, x+2 , m), VTMPL_SPLIT_1 (s, x+3 , m)
# define VTMPL_SPLIT_16(s, x, m) VTMPL_SPLIT_4 (s, x, m), VTMPL_SPLIT_4 (s, x+4 , m), VTMPL_SPLIT_4 (s, x+8 , m), VTMPL_SPLIT_4 (s, x+12 , m)
# define VTMPL_SPLIT_64(s, x, m) VTMPL_SPLIT_16 (s, x, m), VTMPL_SPLIT_16 (s, x+16 , m), VTMPL_SPLIT_16 (s, x+32 , m), VTMPL_SPLIT_16 (s, x+48 , m)
# define VTMPL_SPLIT_256(s, x, m) VTMPL_SPLIT_64 (s, x, m), VTMPL_SPLIT_64 (s, x+64 , m), VTMPL_SPLIT_64 (s, x+128, m), VTMPL_SPLIT_64 (s, x+194, m)
# define VTMPL_SPLIT_1024(s, x, m) VTMPL_SPLIT_256(s, x, m), VTMPL_SPLIT_256(s, x+256, m), VTMPL_SPLIT_256(s, x+512, m), VTMPL_SPLIT_256(s, x+768, m)
# define VTMPL_ARRAY_SPLIT(s, x) ( x < sizeof(s) ? s[x] : decltype(*s)() )
#define VTMPL_AUTO_RETURN(...) -> decltype(__VA_ARGS__) {return (__VA_ARGS__);}
#define VTMPL_DEFINE_FORWARDER(name, impl) \
template <typename... Args> \
constexpr auto name( Args&&... args ) \
VTMPL_AUTO_RETURN( (impl)(::std::forward<Args>(args)...) )
#define VTMPL_DEFINE_CTOR_FORWARDER(name, base) \
template <typename... Args> \
constexpr name( Args&&... args ) \
base(::std::forward<Args>(args)...)
#endif // MACROS_HXX_INCLUDED
| 47.027778
| 149
| 0.638512
|
Arcoth
|
662f169616685a6d724af75805c536a614946fee
| 584
|
cpp
|
C++
|
src/Game/velocityHandler.cpp
|
LeandreBl/cautious-fiesta
|
21a08135253f6fea51835d81cce4a9920113fd18
|
[
"Apache-2.0"
] | 3
|
2019-10-30T16:22:54.000Z
|
2020-12-10T20:23:40.000Z
|
src/Game/velocityHandler.cpp
|
LeandreBl/cautious-fiesta
|
21a08135253f6fea51835d81cce4a9920113fd18
|
[
"Apache-2.0"
] | 63
|
2019-10-06T12:05:11.000Z
|
2019-12-09T16:22:46.000Z
|
src/Game/velocityHandler.cpp
|
LeandreBl/cautious-fiesta
|
21a08135253f6fea51835d81cce4a9920113fd18
|
[
"Apache-2.0"
] | null | null | null |
#include "GameManager.hpp"
#include "UdpConnection.hpp"
#include "GoPlayer.hpp"
namespace cf {
int UdpConnect::velocityHandler(sfs::Scene &scene, GameManager &manager, Serializer &s)
{
uint64_t id;
sf::Vector2f acceleration;
sf::Vector2f speed;
s >> id >> speed >> acceleration;
id += 1000;
auto *go = scene.getGameObject(id);
if (go == nullptr) {
std::cerr << "Can't find object " << id << std::endl;
return -1;
}
auto v = go->getComponents<sfs::Velocity>();
for (auto &&i : v) {
i->acceleration = acceleration;
i->speed = speed;
}
return 0;
}
} // namespace cf
| 22.461538
| 87
| 0.657534
|
LeandreBl
|
6633cc13c8634802a408ef2d61c5b4cc990ff148
| 4,799
|
cpp
|
C++
|
action_generator/3rdparty/diverse_short_paths/src/KDiverseShort.cpp
|
anpl-technion/anpl_mrbsp
|
973734fd2d1c7bb5e1405922300add489f088e81
|
[
"MIT"
] | 1
|
2021-12-03T03:11:20.000Z
|
2021-12-03T03:11:20.000Z
|
action_generator/3rdparty/diverse_short_paths/src/KDiverseShort.cpp
|
anpl-technion/anpl_mrbsp
|
973734fd2d1c7bb5e1405922300add489f088e81
|
[
"MIT"
] | null | null | null |
action_generator/3rdparty/diverse_short_paths/src/KDiverseShort.cpp
|
anpl-technion/anpl_mrbsp
|
973734fd2d1c7bb5e1405922300add489f088e81
|
[
"MIT"
] | 1
|
2021-12-03T03:11:23.000Z
|
2021-12-03T03:11:23.000Z
|
/*
* KDiverseShort.cpp
*/
#include "KDiverseShort.h"
#include "Graph.h"
#include "Path.h"
#include "TestData.h"
// Constructors, destructors
KDiverseShort::KDiverseShort (const TestData *data, PathDistanceMeasure *pDist)
: too_long(false), i(0), c(0), testData(data)
{
// Set up path storage and nearest neighbors
Path::setDistanceFunction(boost::bind(&PathDistanceMeasure::distance, pDist, _1, _2));
pDistName = pDist->getName();
pathArray = new Path[testData->getK()];
pathNN = new ompl::NearestNeighborsGNAT<Path>();
pathNN->setDistanceFunction(&Path::distance);
seconds = 0;
}
KDiverseShort::~KDiverseShort ()
{
delete [] pathArray;
delete pathNN;
}
// Public methods
void KDiverseShort::timedRun ()
{
// Time the execution
clock_t start = clock();
run();
clock_t end = clock();
seconds = ((double)(end-start))/CLOCKS_PER_SEC;
// Label the results
const double d = testData->getMinDistance();
if (d <= std::numeric_limits<double>::epsilon())
{
const double l = testData->getMaxLength();
if (l == std::numeric_limits<double>::infinity())
description << ", no filtering";
else
description << ", filtering for maximum length " << l;
}
else
description << ", filtering for pairwise distance " << d;
description << " (" << pDistName << ")";
}
void KDiverseShort::clear ()
{
// Prepare for future runs
too_long = false;
i = 0;
c = 0;
pathNN->clear();
description.str("");
}
void KDiverseShort::saveSet () const
{
// Open a file and save each path in turn
std::ofstream fout("paths.txt");
for (std::size_t j = 0; j < i; j++)
{
pathArray[j].saveOMPLFormat(fout);
}
}
void KDiverseShort::saveNodes () const
{
// Open a file and save each path in turn
std::ofstream fout("paths.txt");
for (std::size_t j = 0; j < i; j++)
{
pathArray[j].saveGephiFormat(fout);
fout << "\n";
}
}
void KDiverseShort::print () const
{
std::cout << "Description: " << description.str() << "\n";
std::cout << " Found " << i << " of " << testData->getK() << " requested paths.\n";
const double shortest = findShortestLength();
std::cout << "\tshortest path length: " << shortest << "\n";
const double longest = findLongestLength();
std::cout << "\tlongest path length: " << longest << " (" << longest/shortest << " times as long)\n";
std::cout << "\tmin distance to nearest neighbor: " << minNearestPathDistance() << "\n";
std::cout << "\tmean distance to nearest neighbor: " << meanNearestPathDistance() << "\n";
std::cout << " Completed in " << seconds << " seconds\n\n\n";
}
double KDiverseShort::findShortestLength () const
{
// Assume it's the first one
if (i > 0)
return pathArray[0].getLength();
else
return std::numeric_limits<double>::quiet_NaN();
}
double KDiverseShort::findLongestLength () const
{
double longest = 0;
for (std::size_t j = 0; j < i; j++)
{
if (pathArray[j].getLength() > longest)
longest = pathArray[j].getLength();
}
return longest;
}
double KDiverseShort::minNearestPathDistance () const
{
double min = std::numeric_limits<double>::infinity();
for (std::size_t j = 0; j < i; j++)
{
double d = nearestPathDistance(j);
if (d < min)
min = d;
}
return min;
}
double KDiverseShort::meanNearestPathDistance () const
{
double sum = 0;
for (std::size_t j = 0; j < i; j++)
{
sum += nearestPathDistance(j);
}
return sum/i;
}
double KDiverseShort::nearestPathDistance (const std::size_t which) const
{
std::vector<Path> ret(2);
pathNN->nearestK(pathArray[which], 2, ret);
if (ret[1].getGraph() == nullptr)
return std::numeric_limits<double>::infinity();
return Path::distance(pathArray[which], ret[1]);
}
// Protected methods
bool KDiverseShort::tooLong () const
{
return too_long;
}
bool KDiverseShort::needMore () const
{
return i < testData->getK();
}
bool KDiverseShort::considerPath(const Path &path)
{
// Update user on progress during long runs
if (++c % 10000 == 0)
std::cout << "Success rate: " << i << "/" << c << "\n";
// Reject path if it is too long
if (path.getLength() > testData->getMaxLength())
{
too_long = true;
return false;
}
// Reject path if it is too close to others
if (i > 0)
{
const Path &nearest = pathNN->nearest(path);
if (Path::distance(path, nearest) < testData->getMinDistance())
return false;
}
// Path meets criteria
pathArray[i++] = path;
pathNN->add(pathArray[i-1]);
return true;
}
| 25.526596
| 106
| 0.597625
|
anpl-technion
|
663472dff4e918fc3b415005bd1c66cbcf56f683
| 5,656
|
cpp
|
C++
|
pdMultiExample/src/ofApp.cpp
|
chikashimiyama/ofxPd
|
ca528059423bc5ebda1ad3ccfe61b6daa141a708
|
[
"BSD-2-Clause",
"MIT-CMU"
] | 2
|
2018-04-08T03:36:15.000Z
|
2019-06-16T16:51:50.000Z
|
pdMultiExample/src/ofApp.cpp
|
cuinjune/ofxPd
|
f5ff0c2ff359e8c1f04b9b5ee494869b5d35f418
|
[
"BSD-2-Clause",
"MIT-CMU"
] | null | null | null |
pdMultiExample/src/ofApp.cpp
|
cuinjune/ofxPd
|
f5ff0c2ff359e8c1f04b9b5ee494869b5d35f418
|
[
"BSD-2-Clause",
"MIT-CMU"
] | null | null | null |
/*
* Copyright (c) 2015 Dan Wilcox <danomatika@gmail.com>
*
* BSD Simplified License.
* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
*
* See https://github.com/danomatika/ofxPd for documentation
*
*/
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup() {
ofSetFrameRate(60);
ofSetVerticalSync(true);
//ofSetLogLevel("Pd", OF_LOG_VERBOSE); // see verbose info inside
// the number of libpd ticks per buffer,
// used to compute the audio buffer len: tpb * blocksize (always 64)
#ifdef TARGET_LINUX_ARM
// longer latency for Raspberry PI
int ticksPerBuffer = 32; // 32 * 64 = buffer len of 2048
int numInputs = 0; // no built in mic
#else
int ticksPerBuffer = 8; // 8 * 64 = buffer len of 512
int numInputs = 1;
#endif
int numOutputs = 2;
// setup OF sound stream
ofSoundStreamSettings settings;
settings.numInputChannels = numInputs;
settings.numOutputChannels = numOutputs;
settings.sampleRate = 44100;
settings.bufferSize = ofxPd::blockSize() * ticksPerBuffer;
settings.setInListener(this);
settings.setOutListener(this);
ofSoundStreamSetup(settings);
// allocate pd instance handles
instanceMutex.lock();
pdinstance1 = pdinstance_new();
pdinstance2 = pdinstance_new();
instanceMutex.unlock();
// set a "current" instance before pd.init() or else Pd will make
// an unnecessary third "default" instance
instanceMutex.lock();
pd_setinstance(pdinstance1);
instanceMutex.unlock();
// setup Pd
//
// set 4th arg to true for queued message passing using an internal ringbuffer,
// this is useful if you need to control where and when the message callbacks
// happen (ie. within a GUI thread)
//
// note: you won't see any message prints until update() is called since
// the queued messages are processed there, this is normal
//
// ... here we'd sure like to be able to have number of channels be
// per-instance. The sample rate is still global within Pd but we might
// also consider relaxing that restrction.
//
if(!pd.init(numOutputs, numInputs, 44100, ticksPerBuffer, false)) {
ofExit(1);
}
pd.setReceiver(this);
// allocate instance output buffers
outputBufferSize = numOutputs*ticksPerBuffer*ofxPd::blockSize();
outputBuffer1 = new float[outputBufferSize];
outputBuffer2 = new float[outputBufferSize];
memset(outputBuffer1, 0, outputBufferSize);
memset(outputBuffer2, 0, outputBufferSize);
instanceMutex.lock();
pd_setinstance(pdinstance1); // talk to first pd instance
instanceMutex.unlock();
// audio processing on
pd.start();
// open patch
pd.openPatch("test.pd");
instanceMutex.lock();
pd_setinstance(pdinstance2); // talk to the second pd instance
instanceMutex.unlock();
// audio processing on
pd.start();
// open patch
pd.openPatch("test.pd");
// The following two messages can be sent without setting the pd instance
// and anyhow the symbols are global so they may affect multiple instances.
// However, if the messages change anything in the pd instance structure
// (DSP state; current time; list of all canvases n our instance) those
// changes will apply to the current Pd nstance, so the earlier messages,
// for instance, were sensitive to which was the current one.
//
// Note also that I'm using the fact that $0 is set to 1003, 1004, ...
// as patches are opened, it would be better to open the patches with
// settable $1, etc parameters to openPatch().
// [; pd frequency 220 (
pd << StartMessage() << 440.0f << FinishMessage("1003-frequency", "float");
// [; pd frequency 440 (
pd << StartMessage() << 880.0f << FinishMessage("1004-frequency", "float");
}
//--------------------------------------------------------------
void ofApp::update() {
ofBackground(100, 100, 100);
// since this is a test and we don't know if init() was called with
// queued = true or not, we check it here
if(pd.isQueued()) {
// process any received messages, if you're using the queue
pd.receiveMessages();
}
// // run for 1 second and exit
// if(ofGetElapsedTimef() > 1.0) {
// ofExit(); // exit app
// }
}
//--------------------------------------------------------------
void ofApp::draw() {}
//--------------------------------------------------------------
void ofApp::exit() {
// cleanup
ofSoundStreamStop();
}
//--------------------------------------------------------------
void ofApp::audioReceived(float * input, int bufferSize, int nChannels) {
// process audio input for instance 1
instanceMutex.lock();
pd_setinstance(pdinstance1);
instanceMutex.unlock();
pd.audioIn(input, bufferSize, nChannels);
// process audio input for instance 2
pd_setinstance(pdinstance2);
pd.audioIn(input, bufferSize, nChannels);
}
//--------------------------------------------------------------
void ofApp::audioRequested(float * output, int bufferSize, int nChannels) {
// process audio output for instance 1
instanceMutex.lock();
pd_setinstance(pdinstance1);
instanceMutex.unlock();
pd.audioOut(outputBuffer1, bufferSize, nChannels);
// process audio output for instance 2
instanceMutex.lock();
pd_setinstance(pdinstance2);
instanceMutex.unlock();
pd.audioOut(outputBuffer2, bufferSize, nChannels);
// mix the two instance output buffers together
for(int i = 0; i < outputBufferSize; i += 1) {
output[i] = (outputBuffer1[i] + outputBuffer2[i]) * 0.5f; // mix
}
}
//--------------------------------------------------------------
void ofApp::print(const std::string& message) {
cout << message << endl;
}
| 30.907104
| 80
| 0.654349
|
chikashimiyama
|
663662fee77d85d3786f5c16a3053bbe9502ed05
| 924
|
cpp
|
C++
|
Applications/DataExplorer/DataView/MshItem.cpp
|
norihiro-w/ogs
|
ac990b1aa06a583dba3e32efa3009ef0c6f46ae4
|
[
"BSD-4-Clause"
] | null | null | null |
Applications/DataExplorer/DataView/MshItem.cpp
|
norihiro-w/ogs
|
ac990b1aa06a583dba3e32efa3009ef0c6f46ae4
|
[
"BSD-4-Clause"
] | 25
|
2015-02-04T20:34:21.000Z
|
2018-12-10T20:19:57.000Z
|
Applications/DataExplorer/DataView/MshItem.cpp
|
norihiro-w/ogs
|
ac990b1aa06a583dba3e32efa3009ef0c6f46ae4
|
[
"BSD-4-Clause"
] | null | null | null |
/**
* \file
* \author Karsten Rink
* \date 2010-05-17
* \brief Implementation of the MshItem class.
*
* \copyright
* Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#include "MshItem.h"
#include "MeshLib/Vtk/VtkMappedMeshSource.h"
/**
* Constructor.
* \param data The data associated with each column
* \param parent The parent item in the tree
* \param grid The mesh associated with this item
*/
MshItem::MshItem(const QList<QVariant> &data, TreeItem* parent, const MeshLib::Mesh* mesh)
: TreeItem(data, parent)
{
_mesh_source = MeshLib::VtkMappedMeshSource::New();
static_cast<MeshLib::VtkMappedMeshSource*>(_mesh_source)->SetMesh(mesh);
}
MshItem::~MshItem()
{
_mesh_source->Delete();
}
| 26.4
| 90
| 0.681818
|
norihiro-w
|
6639e49ba8a50776a8d6d604111c44ad43ed92c0
| 8,195
|
hh
|
C++
|
dune/gdt/spaces/basis/default.hh
|
pymor/dune-gdt
|
fabc279a79e7362181701866ce26133ec40a05e0
|
[
"BSD-2-Clause"
] | 4
|
2018-10-12T21:46:08.000Z
|
2020-08-01T18:54:02.000Z
|
dune/gdt/spaces/basis/default.hh
|
dune-community/dune-gdt
|
fabc279a79e7362181701866ce26133ec40a05e0
|
[
"BSD-2-Clause"
] | 154
|
2016-02-16T13:50:54.000Z
|
2021-12-13T11:04:29.000Z
|
dune/gdt/spaces/basis/default.hh
|
dune-community/dune-gdt
|
fabc279a79e7362181701866ce26133ec40a05e0
|
[
"BSD-2-Clause"
] | 5
|
2016-03-02T10:11:20.000Z
|
2020-02-08T03:56:24.000Z
|
// This file is part of the dune-gdt project:
// https://github.com/dune-community/dune-gdt
// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved.
// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
// or GPL-2.0+ (http://opensource.org/licenses/gpl-license)
// with "runtime exception" (http://www.dune-project.org/license.html)
// Authors:
// Felix Schindler (2018)
// René Fritze (2018)
// Tobias Leibner (2018)
#ifndef DUNE_GDT_SPACES_BASIS_DEFAULT_HH
#define DUNE_GDT_SPACES_BASIS_DEFAULT_HH
#include <dune/xt/common/memory.hh>
#include <dune/xt/functions/interfaces/grid-function.hh>
#include <dune/gdt/exceptions.hh>
#include <dune/gdt/local/finite-elements/interfaces.hh>
#include "interface.hh"
namespace Dune {
namespace GDT {
/**
* Applies no transformation in evaluate, but left-multiplication by the geometry transformations jacobian inverse
* transpose in jacobian.
*/
template <class GV, size_t r = 1, size_t rC = 1, class R = double>
class DefaultGlobalBasis : public GlobalBasisInterface<GV, r, rC, R>
{
using ThisType = DefaultGlobalBasis;
using BaseType = GlobalBasisInterface<GV, r, rC, R>;
public:
using BaseType::d;
using typename BaseType::D;
using typename BaseType::E;
using typename BaseType::ElementType;
using typename BaseType::GridViewType;
using typename BaseType::LocalizedType;
using FiniteElementFamilyType = LocalFiniteElementFamilyInterface<D, d, R, r, rC>;
DefaultGlobalBasis(const ThisType&) = default;
DefaultGlobalBasis(ThisType&&) = default;
ThisType& operator=(const ThisType&) = delete;
ThisType& operator=(ThisType&&) = delete;
DefaultGlobalBasis(const GridViewType& grid_view,
const FiniteElementFamilyType& local_finite_elements,
const int order)
: grid_view_(grid_view)
, local_finite_elements_(local_finite_elements)
, fe_order_(order)
, max_size_(0)
{}
size_t max_size() const override final
{
return max_size_;
}
using BaseType::localize;
std::unique_ptr<LocalizedType> localize() const override final
{
return std::make_unique<LocalizedDefaultGlobalBasis>(*this);
}
void update_after_adapt() override final
{
max_size_ = 0;
for (const auto& gt : grid_view_.indexSet().types(0))
max_size_ = std::max(max_size_, local_finite_elements_.get(gt, fe_order_).size());
}
private:
class LocalizedDefaultGlobalBasis : public LocalizedGlobalFiniteElementInterface<E, r, rC, R>
{
using ThisType = LocalizedDefaultGlobalBasis;
using BaseType = LocalizedGlobalFiniteElementInterface<E, r, rC, R>;
static_assert(rC == 1,
"Not implemented for rC > 1, check that all functions (especially jacobians(...)) work properly "
"before removing this assert!");
public:
using typename BaseType::DerivativeRangeType;
using typename BaseType::DomainType;
using typename BaseType::ElementType;
using typename BaseType::LocalFiniteElementType;
using typename BaseType::RangeType;
LocalizedDefaultGlobalBasis(const DefaultGlobalBasis<GV, r, rC, R>& self)
: BaseType()
, self_(self)
{}
LocalizedDefaultGlobalBasis(const ThisType&) = delete;
LocalizedDefaultGlobalBasis(ThisType&&) = default;
ThisType& operator=(const ThisType&) = delete;
ThisType& operator=(ThisType&&) = delete;
// required by XT::Functions::ElementFunctionSet
size_t max_size(const XT::Common::Parameter& /*param*/ = {}) const override final
{
return self_.max_size_;
}
protected:
void post_bind(const ElementType& elemnt) override final
{
auto&& new_geometry_type = elemnt.type();
if (geometry_type_ != new_geometry_type) {
geometry_type_ = new_geometry_type;
current_local_fe_ = XT::Common::ConstStorageProvider<LocalFiniteElementInterface<D, d, R, r, rC>>(
self_.local_finite_elements_.get(geometry_type_, self_.fe_order_));
size_ = current_local_fe_.access().size();
order_ = current_local_fe_.access().basis().order();
}
}
public:
size_t size(const XT::Common::Parameter& /*param*/ = {}) const override final
{
DUNE_THROW_IF(!current_local_fe_.valid(), Exceptions::not_bound_to_an_element_yet, "");
return size_;
}
int order(const XT::Common::Parameter& /*param*/ = {}) const override final
{
DUNE_THROW_IF(!current_local_fe_.valid(), Exceptions::not_bound_to_an_element_yet, "");
return order_;
}
using BaseType::evaluate;
using BaseType::jacobians;
void evaluate(const DomainType& point_in_reference_element,
std::vector<RangeType>& result,
const XT::Common::Parameter& /*param*/ = {}) const override final
{
DUNE_THROW_IF(!current_local_fe_.valid(), Exceptions::not_bound_to_an_element_yet, "");
this->assert_inside_reference_element(point_in_reference_element);
current_local_fe_.access().basis().evaluate(point_in_reference_element, result);
}
void jacobians(const DomainType& point_in_reference_element,
std::vector<DerivativeRangeType>& result,
const XT::Common::Parameter& /*param*/ = {}) const override final
{
DUNE_THROW_IF(!current_local_fe_.valid(), Exceptions::not_bound_to_an_element_yet, "");
this->assert_inside_reference_element(point_in_reference_element);
// evaluate jacobian of shape functions
current_local_fe_.access().basis().jacobian(point_in_reference_element, result);
// Apply transformation:
// Let f: E -> R^r be a basis function, and g: E' -> E be the mapping from reference to actual element, then f
// \circ g is a shape function. We have the chain rule J_f = J(f \circ g \circ g^{-1}) = J(f \circ g) J_g^{-1}.
// Applying the transpose to that equation gives
// J_f^T = J_g^{-T} J(f \circ g)^T,
// so we have to multiply J_inv_T from the left to the transposed shape function jacobians (i.e. the shape
// function gradients) to get the transposed jacobian of the basis function (basis function gradient).
const auto J_inv_T = this->element().geometry().jacobianInverseTransposed(point_in_reference_element);
auto tmp_value = result[0][0];
const size_t basis_size = current_local_fe_.access().basis().size();
for (size_t ii = 0; ii < basis_size; ++ii)
for (size_t rr = 0; rr < r; ++rr) {
J_inv_T.mv(result[ii][rr], tmp_value);
result[ii][rr] = tmp_value;
}
} // ... jacobian(...)
// required by LocalizedGlobalFiniteElementInterface
const LocalFiniteElementType& finite_element() const override final
{
return current_local_fe_.access();
}
DynamicVector<R> default_data(const GeometryType& /*geometry_type*/) const override final
{
return DynamicVector<R>();
}
DynamicVector<R> backup() const override final
{
return DynamicVector<R>();
}
void restore(const ElementType& elemnt, const DynamicVector<R>& data) override final
{
this->bind(elemnt);
DUNE_THROW_IF(data.size() != 0, Exceptions::finite_element_error, "data.size() = " << data.size());
}
using BaseType::interpolate;
void interpolate(const std::function<RangeType(const DomainType&)>& element_function,
const int order,
DynamicVector<R>& dofs) const override final
{
current_local_fe_.access().interpolation().interpolate(element_function, order, dofs);
}
private:
const DefaultGlobalBasis<GV, r, rC, R>& self_;
XT::Common::ConstStorageProvider<LocalFiniteElementInterface<D, d, R, r, rC>> current_local_fe_;
size_t size_;
int order_;
Dune::GeometryType geometry_type_;
}; // class LocalizedDefaultGlobalBasis
const GridViewType& grid_view_;
const FiniteElementFamilyType& local_finite_elements_;
const int fe_order_;
size_t max_size_;
}; // class DefaultGlobalBasis
} // namespace GDT
} // namespace Dune
#endif // DUNE_GDT_SPACES_BASIS_DEFAULT_HH
| 35.942982
| 117
| 0.690909
|
pymor
|
6639f875a1aaa210bee14f2a1e2986be42d9bd2a
| 14,650
|
cpp
|
C++
|
modules/tracktion_engine/model/automation/modifiers/tracktion_EnvelopeFollowerModifier.cpp
|
jbloit/tracktion_engine
|
b3fa7d6a3a404f64ae419abdf9c801d672cffb16
|
[
"MIT",
"Unlicense"
] | null | null | null |
modules/tracktion_engine/model/automation/modifiers/tracktion_EnvelopeFollowerModifier.cpp
|
jbloit/tracktion_engine
|
b3fa7d6a3a404f64ae419abdf9c801d672cffb16
|
[
"MIT",
"Unlicense"
] | null | null | null |
modules/tracktion_engine/model/automation/modifiers/tracktion_EnvelopeFollowerModifier.cpp
|
jbloit/tracktion_engine
|
b3fa7d6a3a404f64ae419abdf9c801d672cffb16
|
[
"MIT",
"Unlicense"
] | null | null | null |
/*
,--. ,--. ,--. ,--.
,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2018
'-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
| | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
`---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
Tracktion Engine uses a GPL/commercial licence - see LICENCE.md for details.
*/
namespace tracktion_engine
{
//==============================================================================
/**
Calculates the RMS of a continuous signal.
N.B. this isn't a mathematically correct RMS but a reasonable estimate.
*/
class RunningRMS
{
public:
/** Creates an empty RunningRMS. */
RunningRMS() = default;
/** Sets the sample rate to use for detection. */
inline void setSampleRate (float newSampleRate) noexcept
{
sampleRate = newSampleRate;
update();
}
/** Returns the current RMS for a new input sample. */
inline float processSingleSample (float in) noexcept
{
state += (juce::square (in) - state) * coefficient;
return std::sqrt (state);
}
private:
float state = 0.0f;
float coefficient = 1.0f;
float sampleRate = 44100.0f;
void update() noexcept
{
coefficient = 1.0f - std::exp (-2.0f * juce::MathConstants<float>::pi * 100.0f / sampleRate);
state = 0.0f;
}
};
//==============================================================================
/**
Envelope follower with adjustable attack/release parameters as well as several
detection and time constant modes.
*/
class EnvelopeFollowerModifier::EnvelopeFollower
{
public:
//==============================================================================
/** The available detection modes. */
enum DetectionMode
{
peakMode = 0,
msMode,
rmsMode
};
/** The available time constant modes modes. */
enum TimeConstantMode
{
digitalTC = 0,
slowDigitalTC,
analogTC
};
//==============================================================================
/** Creates a default EnvelopeFollower. */
EnvelopeFollower() = default;
/** Sets the sample rate to use.
This should be called before any of the parameter methods.
*/
void setSampleRate (float newSampleRate) noexcept
{
sampleRate = newSampleRate;
rms.setSampleRate (newSampleRate);
attackCoeff = getDelta (attackTimeMs);
releaseCoeff = getDelta (releaseTimeMs);
holdSamples = (int) msToSamples (holdTimeMs, sampleRate);
reset();
}
/** Resets the detection and current envelope. */
void reset() noexcept
{
envelope = 0.0f;
}
//==============================================================================
/** Sets the attack time. */
void setAttackTime (float attackMs)
{
attackTimeMs = attackMs;
attackCoeff = getDelta (attackTimeMs);
}
/** Sets the hold time. */
void setHoldTime (float holdMs)
{
holdTimeMs = holdMs;
holdSamples = (int) msToSamples (holdMs, sampleRate);
}
/** Sets the release time. */
void setReleaseTime (float releaseMs)
{
releaseTimeMs = releaseMs;
releaseCoeff = getDelta (releaseTimeMs);
}
/** Sets the detection mode to use. */
void setDetectMode (DetectionMode newDetectionMode)
{
detectMode = newDetectionMode;
}
/** Sets the time constant to be used. */
void setTimeConstantMode (TimeConstantMode newTC)
{
if (! setIfDifferent (timeConstantMode, newTC))
return;
switch (timeConstantMode)
{
case digitalTC: timeConstant = -2.0f; break; // log (1%)
case slowDigitalTC: timeConstant = -1.0f; break; // log (10%)
case analogTC: timeConstant = -0.43533393574791066201247090699309f; break; // log (36.7%)
}
attackCoeff = getDelta (attackTimeMs);
releaseCoeff = getDelta (releaseTimeMs);
}
//==============================================================================
/** Returns the envelope for a new sample. */
float processSingleSample (float input)
{
switch (detectMode)
{
case peakMode:
{
input = std::abs (input);
break;
}
case msMode:
{
input = juce::square (std::abs (input));
break;
}
case rmsMode:
{
input = rms.processSingleSample (input);
break;
}
}
if (input > envelope)
{
envelope = attackCoeff * (envelope - input) + input;
holdSamplesLeft = holdSamples;
}
else if (holdSamplesLeft > 0)
{
--holdSamplesLeft;
}
else
{
envelope = releaseCoeff * (envelope - input) + input;
}
jassert (! std::isnan (envelope));
jassert (envelope == 0.0f || std::isnormal (envelope));
envelope = juce::jlimit (0.0f, 1.0f, envelope);
return envelope;
}
protected:
float attackCoeff = 0.0f;
float releaseCoeff = 0.0f;
float envelope = 0.0f;
float attackTimeMs = 0.0f;
float holdTimeMs = 0.0f;
float releaseTimeMs = 0.0f;
float sampleRate = 44100.0f;
float timeConstant = -2.0f;
int holdSamples = 0, holdSamplesLeft = 0;
DetectionMode detectMode = peakMode;
TimeConstantMode timeConstantMode = digitalTC;
RunningRMS rms;
inline float getDelta (float timeMs)
{
return std::exp (timeConstant / (timeMs * sampleRate * 0.001f));
}
inline double msToSamples (double numMiliseconds, double sr)
{
return numMiliseconds * 0.001 * sr;
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (EnvelopeFollower)
};
//==============================================================================
EnvelopeFollowerModifier::EnvelopeFollowerModifier (Edit& e, const juce::ValueTree& v)
: Modifier (e, v)
{
auto um = &edit.getUndoManager();
gainDb.referTo (state, IDs::gainDb, um, 0.0f);
attack.referTo (state, IDs::attack, um, 100.0f);
hold.referTo (state, IDs::hold, um, 0.0f);
release.referTo (state, IDs::release, um, 500.0f);
depth.referTo (state, IDs::depth, um, 1.0f);
offset.referTo (state, IDs::offset, um, 0.0f);
lowPassEnabled.referTo (state, IDs::lowPassEnabled, um, false);
highPassEnabled.referTo (state, IDs::highPassEnabled, um, false);
lowPassFrequency.referTo (state, IDs::lowPassFrequency, um, 2000.0f);
highPassFrequency.referTo (state, IDs::highPassFrequency, um, 500.0f);
auto addDiscreteParam = [this] (const juce::String& paramID, const juce::String& name,
juce::Range<float> valueRange, juce::CachedValue<float>& val,
const juce::StringArray& labels) -> AutomatableParameter*
{
auto* p = new DiscreteLabelledParameter (paramID, name, *this, valueRange, labels.size(), labels);
addAutomatableParameter (p);
p->attachToCurrentValue (val);
return p;
};
auto addParam = [this] (const juce::String& paramID, const juce::String& name,
juce::NormalisableRange<float> valueRange, float centreVal,
juce::CachedValue<float>& val, const juce::String& suffix) -> AutomatableParameter*
{
valueRange.setSkewForCentre (centreVal);
auto* p = new SuffixedParameter (paramID, name, *this, valueRange, suffix);
addAutomatableParameter (p);
p->attachToCurrentValue (val);
return p;
};
const juce::NormalisableRange<float> freqRange (20.0f, 20000.0f);
gainDbParam = addParam ("gainDb", TRANS("Gain"), { -20.0f, 20.0f, 0.001f }, 0.0f, gainDb, "dB");
attackParam = addParam ("attack", TRANS("Attack"), { 1.0f, 5000.0f }, 50.0f, attack, "ms");
holdParam = addParam ("hold", TRANS("Hold"), { 0.0f, 5000.0f }, 50.0f, hold, "ms");
releaseParam = addParam ("release", TRANS("Release"), { 1.0f, 5000.0f }, 50.0f, release, "ms");
depthParam = addParam ("depth", TRANS("Depth"), { -1.0f, 1.0f }, 0.0f, depth, {});
offsetParam = addParam ("offset", TRANS("Offset"), { 0.0f, 1.0f }, 0.5f, offset, {});
lowPassEnabledParam = addDiscreteParam ("lowPassEnabled", TRANS("Low-pass Enabled"), { 0.0f, 1.0f }, lowPassEnabled, modifier::getEnabledNames());
highPassEnabledParam = addDiscreteParam ("highPassEnabled", TRANS("High-pass Enabled"), { 0.0f, 1.0f }, highPassEnabled, modifier::getEnabledNames());
lowPassFrequencyParam = addParam ("lowPassFrequency", TRANS("Low-pass Frequency"), freqRange, 700.0f, lowPassFrequency, "Hz");
highPassFrequencyParam = addParam ("highPassFrequency", TRANS("High-pass Frequency"), freqRange, 700.0f, highPassFrequency, "Hz");
changedTimer.setCallback ([this]
{
changedTimer.stopTimer();
changed();
});
state.addListener (this);
envelopeFollower = std::make_unique<EnvelopeFollower>();
}
EnvelopeFollowerModifier::~EnvelopeFollowerModifier()
{
state.removeListener (this);
notifyListenersOfDeletion();
for (auto p : getAutomatableParameters())
p->detachFromCurrentValue();
deleteAutomatableParameters();
}
//==============================================================================
float EnvelopeFollowerModifier::getCurrentValue()
{
return (getEnvelopeValue() * depthParam->getCurrentValue()) + offsetParam->getCurrentValue();
}
AutomatableParameter::ModifierAssignment* EnvelopeFollowerModifier::createAssignment (const juce::ValueTree& v)
{
return new Assignment (v, *this);
}
juce::StringArray EnvelopeFollowerModifier::getAudioInputNames()
{
return { TRANS("Audio input left"),
TRANS("Audio input right") };
}
void EnvelopeFollowerModifier::initialise (double newSampleRate, int)
{
prepareToPlay (newSampleRate);
}
void EnvelopeFollowerModifier::deinitialise()
{
reset();
}
void EnvelopeFollowerModifier::applyToBuffer (const PluginRenderContext& pc)
{
setEditTime (pc.editTime);
if (pc.destBuffer == nullptr)
return;
updateParameterStreams (pc.editTime);
juce::AudioBuffer<float> ab (pc.destBuffer->getArrayOfWritePointers(),
pc.destBuffer->getNumChannels(),
pc.bufferStartSample,
pc.bufferNumSamples);
processBlock (ab);
}
//==============================================================================
EnvelopeFollowerModifier::Assignment::Assignment (const juce::ValueTree& v, const EnvelopeFollowerModifier& evm)
: AutomatableParameter::ModifierAssignment (evm.edit, v),
envelopeFollowerModifierID (evm.itemID)
{
}
bool EnvelopeFollowerModifier::Assignment::isForModifierSource (const ModifierSource& source) const
{
if (auto* mod = dynamic_cast<const EnvelopeFollowerModifier*> (&source))
return mod->itemID == envelopeFollowerModifierID;
return false;
}
EnvelopeFollowerModifier::Ptr EnvelopeFollowerModifier::Assignment::getEnvelopeFollowerModifier() const
{
if (auto mod = findModifierTypeForID<EnvelopeFollowerModifier> (edit, envelopeFollowerModifierID))
return mod;
return {};
}
//==============================================================================
void EnvelopeFollowerModifier::prepareToPlay (double newSampleRate)
{
envelopeFollower->setSampleRate ((float) newSampleRate);
}
void EnvelopeFollowerModifier::processBlock (const juce::AudioBuffer<float>& ab)
{
envelopeFollower->setAttackTime (attackParam->getCurrentValue());
envelopeFollower->setHoldTime (holdParam->getCurrentValue());
envelopeFollower->setReleaseTime (releaseParam->getCurrentValue());
auto gainVal = juce::Decibels::decibelsToGain (gainDbParam->getCurrentValue());
const bool lowPass = getBoolParamValue (*lowPassEnabledParam);
const bool highPass = getBoolParamValue (*highPassEnabledParam);
const int numChannels = ab.getNumChannels();
const int numSamples = ab.getNumSamples();
const float** samples = ab.getArrayOfReadPointers();
float envelope = 0.0f;
AudioScratchBuffer scratch (1, numSamples);
float* scratchData = scratch.buffer.getWritePointer (0);
// Find max of all channels
for (int i = 0; i < numSamples; ++i)
{
float sample = 0.0f;
for (int c = 0; c < numChannels; ++c)
sample = std::max (sample, std::abs (samples[c][i]));
scratchData[i] = sample * gainVal;
}
// Filter if required
if (setIfDifferent (currentLowPassFrequency, lowPassFrequencyParam->getCurrentValue()))
lowPassFilter.setCoefficients (juce::IIRCoefficients::makeLowPass (getSampleRate(), currentLowPassFrequency));
if (setIfDifferent (currentHighPassFrequency, highPassFrequencyParam->getCurrentValue()))
highPassFilter.setCoefficients (juce::IIRCoefficients::makeHighPass (getSampleRate(), currentHighPassFrequency));
if (lowPass)
lowPassFilter.processSamples (scratchData, numSamples);
if (highPass)
highPassFilter.processSamples (scratchData, numSamples);
// Process envelope
for (int i = 0; i < numSamples; ++i)
envelope = envelopeFollower->processSingleSample (scratchData[i]);
jassert (! std::isnan (envelope));
envelopeValue.store (envelope, std::memory_order_release);
}
void EnvelopeFollowerModifier::reset()
{
envelopeFollower->reset();
}
void EnvelopeFollowerModifier::valueTreeChanged()
{
if (! changedTimer.isTimerRunning())
changedTimer.startTimerHz (30);
}
}
| 34.389671
| 189
| 0.563481
|
jbloit
|
6639fb3bdec4e21a4bdc0144aabecc2ce8af0ea6
| 1,121
|
hpp
|
C++
|
shared/include/assets/sprite.hpp
|
alexdevteam/arpiyi
|
d4bf99d00fd50a715c1c871a01f618923d339938
|
[
"MIT"
] | 6
|
2020-04-06T14:23:40.000Z
|
2021-12-08T00:57:56.000Z
|
shared/include/assets/sprite.hpp
|
alexdevteam/arpiyi
|
d4bf99d00fd50a715c1c871a01f618923d339938
|
[
"MIT"
] | 30
|
2020-04-06T13:29:54.000Z
|
2020-05-22T13:48:12.000Z
|
shared/include/assets/sprite.hpp
|
alexdevteam/arpiyi
|
d4bf99d00fd50a715c1c871a01f618923d339938
|
[
"MIT"
] | 4
|
2020-04-11T23:25:09.000Z
|
2020-04-23T18:18:17.000Z
|
#ifndef ARPIYI_SPRITE_HPP
#define ARPIYI_SPRITE_HPP
#include "asset.hpp"
#include "asset_manager.hpp"
#include "texture.hpp"
#include "util/math.hpp"
#include <anton/math/vector2.hpp>
#include <filesystem>
namespace fs = std::filesystem;
// Anton math library
namespace aml = anton::math;
namespace arpiyi::assets {
struct [[assets::serialize]] [[meta::dir_name("sprites")]] Sprite {
/// Texture of the sprite. Not owned by it
Handle<assets::Texture> texture;
aml::Vector2 uv_min;
aml::Vector2 uv_max;
std::string name;
/// Where this sprite originates from. Goes from {0,0} (Upper left) to {1,1} (Lower right).
aml::Vector2 pivot;
[[nodiscard]] math::IVec2D get_size_in_pixels() const {
const auto tex = *texture.get();
return {static_cast<i32>((uv_max.x - uv_min.x) * tex.w),
static_cast<i32>((uv_max.y - uv_min.y) * tex.h)};
}
};
template<> struct LoadParams<Sprite> {
fs::path path;
};
template<> RawSaveData raw_get_save_data(Sprite const&);
template<> void raw_load(Sprite&, LoadParams<Sprite> const&);
}
#endif // ARPIYI_SPRITE_HPP
| 25.477273
| 95
| 0.676182
|
alexdevteam
|
66416bc7d6b59f53b54cca4ecaf476b38043b33e
| 688
|
hpp
|
C++
|
graph/flow/minimum_cost_flow/minimum_cost_flow_with_minimum_flow_constraint.hpp
|
emthrm/library
|
0876ba7ec64e23b5ec476a7a0b4880d497a36be1
|
[
"Unlicense"
] | 1
|
2021-12-26T14:17:29.000Z
|
2021-12-26T14:17:29.000Z
|
graph/flow/minimum_cost_flow/minimum_cost_flow_with_minimum_flow_constraint.hpp
|
emthrm/library
|
0876ba7ec64e23b5ec476a7a0b4880d497a36be1
|
[
"Unlicense"
] | 3
|
2020-07-13T06:23:02.000Z
|
2022-02-16T08:54:26.000Z
|
graph/flow/minimum_cost_flow/minimum_cost_flow_with_minimum_flow_constraint.hpp
|
emthrm/library
|
0876ba7ec64e23b5ec476a7a0b4880d497a36be1
|
[
"Unlicense"
] | null | null | null |
#pragma once
#include <limits>
template <template <typename, typename> class C, typename T, typename U>
struct MinimumCostFlowWithMinimumFlowConstraint {
const U uinf;
MinimumCostFlowWithMinimumFlowConstraint(int n, const U M, const U uinf = std::numeric_limits<U>::max())
: M(M), uinf(uinf), mcf(n, uinf) {}
void add_edge(int src, int dst, T lb, T ub, U cost) {
mcf.add_edge(src, dst, ub - lb, cost);
mcf.add_edge(src, dst, lb, cost - M);
lb_sum += lb;
}
U solve(int s, int t, T flow) {
U tmp = mcf.solve(s, t, flow);
return tmp == uinf ? uinf : tmp + M * lb_sum;
}
private:
const U M;
T lb_sum = 0;
C<T, U> mcf;
};
| 25.481481
| 107
| 0.609012
|
emthrm
|
664170f0b9193f56d97133001ac3fb37958b5d0f
| 1,320
|
cpp
|
C++
|
src/jointFactory.cpp
|
bach74/Lisa
|
6f79b909f734883cd05a0ccf8679199ae2e301cf
|
[
"MIT",
"Unlicense"
] | 2
|
2016-06-23T21:20:19.000Z
|
2020-03-25T15:01:07.000Z
|
src/jointFactory.cpp
|
bach74/Lisa
|
6f79b909f734883cd05a0ccf8679199ae2e301cf
|
[
"MIT",
"Unlicense"
] | null | null | null |
src/jointFactory.cpp
|
bach74/Lisa
|
6f79b909f734883cd05a0ccf8679199ae2e301cf
|
[
"MIT",
"Unlicense"
] | null | null | null |
// =============================================================================
// JointFactory.cpp
//
// Copyright (C) 2007-2012 by Bach
// This file is part of the LiSA project.
// The LiSA project is licensed under MIT license.
//
// =============================================================================
#include "stdafx.h"
#include "jointFactory.h"
#include "jointRevolute.h"
#include "jointD6.h"
Joint* JointFactory::createJoint(NxJoint* joint)
{
NxJointType jointType = joint->getType();
if (jointType == NX_JOINT_REVOLUTE)
{
NxRevoluteJoint* revJoint = (NxRevoluteJoint*)joint;
// if motor is not enabled, don't add a controller
NxMotorDesc mot;
if (revJoint->getMotor(mot))
{
// enable joint TODO
}
return new JointRevolute(joint);
}
else if (jointType == NX_JOINT_D6)
{
return new JointD6(joint);
/* The joint springs themselves act as PD controllers in PhysX
(the targetValue in the spring descriptor). It is a very useful feature for motion control.
It seems to be pretty accurate than normal PD.
I guess its using some acceleration constraints than torques like in traditional PD? */
}
else if (jointType != NX_JOINT_FIXED)
{
throw Exception("Joint type not supported", "joint.cpp");
}
return NULL;
}
JointFactory::~JointFactory(void)
{
}
| 24.90566
| 93
| 0.623485
|
bach74
|
66421f9d942f2603df80cdadc956af5b498c955e
| 711
|
cpp
|
C++
|
src/systems/sources/dirty.cpp
|
hexoctal/zenith
|
eeef065ed62f35723da87c8e73a6716e50d34060
|
[
"MIT"
] | 2
|
2021-03-18T16:25:04.000Z
|
2021-11-13T00:29:27.000Z
|
src/systems/sources/dirty.cpp
|
hexoctal/zenith
|
eeef065ed62f35723da87c8e73a6716e50d34060
|
[
"MIT"
] | null | null | null |
src/systems/sources/dirty.cpp
|
hexoctal/zenith
|
eeef065ed62f35723da87c8e73a6716e50d34060
|
[
"MIT"
] | 1
|
2021-11-13T00:29:30.000Z
|
2021-11-13T00:29:30.000Z
|
/**
* @file
* @author __AUTHOR_NAME__ <mail@host.com>
* @copyright 2021 __COMPANY_LTD__
* @license <a href="https://opensource.org/licenses/MIT">MIT License</a>
*/
#include "../dirty.hpp"
#include "../../utils/assert.hpp"
#include "../../components/dirty.hpp"
namespace Zen {
extern entt::registry g_registry;
bool IsDirty (Entity entity)
{
auto dirty = g_registry.try_get<Components::Dirty>(entity);
ZEN_ASSERT(dirty, "The entity has no 'Dirty' component.");
return dirty->value;
}
void SetDirty (Entity entity, bool value)
{
auto dirty = g_registry.try_get<Components::Dirty>(entity);
ZEN_ASSERT(dirty, "The entity has no 'Dirty' component.");
dirty->value = value;
}
} // namespace Zen
| 20.911765
| 74
| 0.697609
|
hexoctal
|
6652089624a97b7fd91dbe096965d0e7ddde4caf
| 251
|
cpp
|
C++
|
core/utils/test/src/main.cpp
|
nicsor/BreadCrumbs
|
9ee5111d87d7a71b0a3910c14c4751eb3f1635ab
|
[
"MIT"
] | null | null | null |
core/utils/test/src/main.cpp
|
nicsor/BreadCrumbs
|
9ee5111d87d7a71b0a3910c14c4751eb3f1635ab
|
[
"MIT"
] | null | null | null |
core/utils/test/src/main.cpp
|
nicsor/BreadCrumbs
|
9ee5111d87d7a71b0a3910c14c4751eb3f1635ab
|
[
"MIT"
] | null | null | null |
/**
* @file main.cpp
*
* @brief Test runner for utils.
*
* @author Nicolae Natea
* Contact: nicu@natea.ro
*/
#include <gtest/gtest.h>
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
| 14.764706
| 43
| 0.629482
|
nicsor
|
5946d915c47f7b26b5d415a84128b88dfcd0236b
| 2,625
|
cpp
|
C++
|
src/wall.cpp
|
ParthGoyal1508/Jetpack-Joyride
|
17acbcbf705c5869072ca192738e43f36b14dd22
|
[
"MIT"
] | null | null | null |
src/wall.cpp
|
ParthGoyal1508/Jetpack-Joyride
|
17acbcbf705c5869072ca192738e43f36b14dd22
|
[
"MIT"
] | null | null | null |
src/wall.cpp
|
ParthGoyal1508/Jetpack-Joyride
|
17acbcbf705c5869072ca192738e43f36b14dd22
|
[
"MIT"
] | null | null | null |
#include "wall.h"
#include "main.h"
using namespace std;
Wall::Wall(float x, float y, color_t color) {
this->position = glm::vec3(x, y, 0);
static const GLfloat vertex_buffer_data[] = {
-3.0f, 3.0f, 0.0f,//block A
-3.0f, -1.0f, 0.0f,
0.0f, 3.0f, 0.0f,
0.0f, 3.0f, 0.0f,
-3.0f, -1.0f, 0.0f,
0.0f, -1.0f, 0.0f,
0.0f, 3.0f, 0.0f,//side triangle
0.0f, 2.75f, 0.0f,
0.25f, 2.75f, 0.0f,
0.0f, -0.75f, 0.0f,//side triangle
0.0f, -1.0f, 0.0f,
0.25f, -0.75f, 0.0f,
-3.25f, -0.75f, 0.0f,//side triangle
-3.0f, -0.75f, 0.0f,
-3.0f, -1.0f, 0.0f,
-3.0f, 3.0f, 0.0f,//side triangle
-3.0f, 2.75f, 0.0f,
-3.25f, 2.75f, 0.0f,
-3.25f, 2.75f, 0.0f,//rectangle
-3.25f, -0.75f, 0.0f,
-3.0f, -0.75f, 0.0f,
-3.0f, 2.75f, 0.0f,
-3.25f, 2.75f, 0.0f,
-3.0f, -0.75f, 0.0f,
0.0f, 2.75f, 0.0f,//rectangle
0.0f, -0.75f, 0.0f,
0.25f, -0.75f, 0.0f,
0.25f, 2.75f, 0.0f,
0.0f, 2.75f, 0.0f,
0.25f, -0.75f, 0.0f,
1.5f, 3.0f, 0.0f,//block B
1.5f, -1.0f, 0.0f,
2.5f, 3.0f, 0.0f,
2.5f, 3.0f, 0.0f,
1.5f, -1.0f, 0.0f,
2.5f, -1.0f, 0.0f,
2.5f, 3.0f, 0.0f,//side triangle
2.5f, 2.75f, 0.0f,
2.75f, 2.75f, 0.0f,
2.5f, -0.75f, 0.0f,//side triangle
2.5f, -1.0f, 0.0f,
2.75f, -0.75f, 0.0f,
1.25f, -0.75f, 0.0f,//side triangle
1.5f, -0.75f, 0.0f,
1.5f, -1.0f, 0.0f,
1.5f, 3.0f, 0.0f,//side triangle
1.5f, 2.75f, 0.0f,
1.25f, 2.75f, 0.0f,
1.25f, 2.75f, 0.0f,//rectangle
1.25f, -0.75f, 0.0f,
1.5f, -0.75f, 0.0f,
1.5f, 2.75f, 0.0f,
1.25f, 2.75f, 0.0f,
1.5f, -0.75f, 0.0f,
2.5f, 2.75f, 0.0f,//rectangle
2.5f, -0.75f, 0.0f,
2.75f, -0.75f, 0.0f,
2.75f, 2.75f, 0.0f,
2.5f, 2.75f, 0.0f,
2.75f, -0.75f, 0.0f,
};
this->object = create3DObject(GL_TRIANGLES, 20 * 3, vertex_buffer_data, COLOR_GREY, GL_FILL);
}
void Wall::draw(glm::mat4 VP) {
Matrices.model = glm::mat4(0.5f);
glm::mat4 translate = glm::translate (this->position); // glTranslatef
Matrices.model *= (translate);
glm::mat4 MVP = VP * Matrices.model;
glUniformMatrix4fv(Matrices.MatrixID, 1, GL_FALSE, &MVP[0][0]);
draw3DObject(this->object);
}
void Wall::set_position(float x, float y) {
this->position = glm::vec3(x, y, 0);
}
| 24.53271
| 97
| 0.463238
|
ParthGoyal1508
|
595cc13cedf4c180c1372860cdbf27314b9c7ecb
| 7,079
|
cpp
|
C++
|
case-studies/PoDoFo/podofo/cib/podofo/doc/PdfCMapEncoding.h.cpp
|
satya-das/cib
|
369333ea58b0530b8789a340e21096ba7d159d0e
|
[
"MIT"
] | 30
|
2018-03-05T17:35:29.000Z
|
2022-03-17T18:59:34.000Z
|
case-studies/PoDoFo/podofo/cib/podofo/doc/PdfCMapEncoding.h.cpp
|
satya-das/cib
|
369333ea58b0530b8789a340e21096ba7d159d0e
|
[
"MIT"
] | 2
|
2016-05-26T04:47:13.000Z
|
2019-02-15T05:17:43.000Z
|
case-studies/PoDoFo/podofo/cib/podofo/doc/PdfCMapEncoding.h.cpp
|
satya-das/cib
|
369333ea58b0530b8789a340e21096ba7d159d0e
|
[
"MIT"
] | 5
|
2019-02-15T05:09:22.000Z
|
2021-04-14T12:10:16.000Z
|
#include "podofo/base/PdfCompilerCompat.h"
#include "podofo/base/PdfDictionary.h"
#include "podofo/base/PdfEncoding.h"
#include "podofo/base/PdfName.h"
#include "podofo/base/PdfObject.h"
#include "podofo/base/PdfRefCountedBuffer.h"
#include "podofo/base/PdfString.h"
#include "podofo/doc/PdfCMapEncoding.h"
#include "podofo/doc/PdfFont.h"
#include "__zz_cib_CibPoDoFo-class-down-cast.h"
#include "__zz_cib_CibPoDoFo-delegate-helper.h"
#include "__zz_cib_CibPoDoFo-generic.h"
#include "__zz_cib_CibPoDoFo-ids.h"
#include "__zz_cib_CibPoDoFo-type-converters.h"
#include "__zz_cib_CibPoDoFo-mtable-helper.h"
#include "__zz_cib_CibPoDoFo-proxy-mgr.h"
namespace __zz_cib_ {
using namespace ::PoDoFo;
template <>
struct __zz_cib_Delegator<::PoDoFo::PdfCMapEncoding> : public ::PoDoFo::PdfCMapEncoding {
using __zz_cib_Delegatee = __zz_cib_::__zz_cib_Delegator<::PoDoFo::PdfCMapEncoding>;
using __zz_cib_AbiType = __zz_cib_Delegatee*;
using __zz_cib_Proxy = __zz_cib_Proxy_t<::PoDoFo::PdfCMapEncoding>;
using __zz_cib_ProxyDeleter = __zz_cib_ProxyDeleter_t<::PoDoFo::PdfCMapEncoding>;
using ::PoDoFo::PdfCMapEncoding::PdfCMapEncoding;
static __zz_cib_AbiType __zz_cib_decl __zz_cib_Copy_0(const __zz_cib_Delegatee* __zz_cib_obj) {
return new __zz_cib_Delegatee(*__zz_cib_obj);
}
static void __zz_cib_decl __zz_cib_Delete_1(__zz_cib_Delegatee* __zz_cib_obj) {
delete __zz_cib_obj;
}
static __zz_cib_AbiType __zz_cib_decl __zz_cib_New_2(__zz_cib_AbiType_t<::PoDoFo::PdfObject*> pObject, __zz_cib_AbiType_t<::PoDoFo::PdfObject*> pToUnicode) {
return new __zz_cib_Delegatee( __zz_cib_::__zz_cib_FromAbiType<::PoDoFo::PdfObject*>(pObject),
__zz_cib_::__zz_cib_FromAbiType<::PoDoFo::PdfObject*>(pToUnicode));
}
static __zz_cib_AbiType_t<::PoDoFo::PdfString> __zz_cib_decl ConvertToUnicode_3(const __zz_cib_Delegatee* __zz_cib_obj, __zz_cib_AbiType_t<const ::PoDoFo::PdfString&> rEncodedString, __zz_cib_AbiType_t<const ::PoDoFo::PdfFont*> pFont) {
return __zz_cib_ToAbiType<::PoDoFo::PdfString>(
__zz_cib_obj->::PoDoFo::PdfCMapEncoding::ConvertToUnicode(
__zz_cib_::__zz_cib_FromAbiType<const ::PoDoFo::PdfString&>(rEncodedString),
__zz_cib_::__zz_cib_FromAbiType<const ::PoDoFo::PdfFont*>(pFont)
)
);
}
static __zz_cib_AbiType_t<void> __zz_cib_decl AddToDictionary_4(const __zz_cib_Delegatee* __zz_cib_obj, __zz_cib_AbiType_t<::PoDoFo::PdfDictionary&> rDictionary) {
__zz_cib_obj->::PoDoFo::PdfCMapEncoding::AddToDictionary(
__zz_cib_::__zz_cib_FromAbiType<::PoDoFo::PdfDictionary&>(rDictionary)
);
}
static __zz_cib_AbiType_t<::PoDoFo::PdfRefCountedBuffer> __zz_cib_decl ConvertToEncoding_5(const __zz_cib_Delegatee* __zz_cib_obj, __zz_cib_AbiType_t<const ::PoDoFo::PdfString&> rString, __zz_cib_AbiType_t<const ::PoDoFo::PdfFont*> pFont) {
return __zz_cib_ToAbiType<::PoDoFo::PdfRefCountedBuffer>(
__zz_cib_obj->::PoDoFo::PdfCMapEncoding::ConvertToEncoding(
__zz_cib_::__zz_cib_FromAbiType<const ::PoDoFo::PdfString&>(rString),
__zz_cib_::__zz_cib_FromAbiType<const ::PoDoFo::PdfFont*>(pFont)
)
);
}
static __zz_cib_AbiType_t<bool> __zz_cib_decl IsAutoDelete_6(const __zz_cib_Delegatee* __zz_cib_obj) {
return __zz_cib_ToAbiType<bool>(
__zz_cib_obj->::PoDoFo::PdfCMapEncoding::IsAutoDelete()
);
}
static __zz_cib_AbiType_t<bool> __zz_cib_decl IsSingleByteEncoding_7(const __zz_cib_Delegatee* __zz_cib_obj) {
return __zz_cib_ToAbiType<bool>(
__zz_cib_obj->::PoDoFo::PdfCMapEncoding::IsSingleByteEncoding()
);
}
static __zz_cib_AbiType_t<::PoDoFo::pdf_uint16> __zz_cib_decl GetCharCode_8(const __zz_cib_Delegatee* __zz_cib_obj, __zz_cib_AbiType_t<int> nIndex) {
return __zz_cib_ToAbiType<::PoDoFo::pdf_uint16>(
__zz_cib_obj->::PoDoFo::PdfCMapEncoding::GetCharCode(
__zz_cib_::__zz_cib_FromAbiType<int>(nIndex)
)
);
}
static __zz_cib_AbiType_t<const ::PoDoFo::PdfName&> __zz_cib_decl GetID_9(const __zz_cib_Delegatee* __zz_cib_obj) {
return __zz_cib_ToAbiType<const ::PoDoFo::PdfName&>(
__zz_cib_obj->::PoDoFo::PdfCMapEncoding::GetID()
);
}
static __zz_cib_AbiType_t<const ::PoDoFo::PdfEncoding*> __zz_cib_decl GetBaseEncoding_10(const __zz_cib_Delegatee* __zz_cib_obj) {
return __zz_cib_ToAbiType<const ::PoDoFo::PdfEncoding*>(
__zz_cib_obj->::PoDoFo::PdfCMapEncoding::GetBaseEncoding()
);
}
static void __zz_cib_decl __zz_cib_RegisterProxy(::PoDoFo::PdfCMapEncoding* obj, __zz_cib_Proxy proxy, __zz_cib_ProxyDeleter deleter) {
__zz_cib_ProxyManagerDelegator::__zz_cib_RegisterProxy(obj, proxy, deleter);
}
static ::PoDoFo::PdfEncoding* __zz_cib_decl __zz_cib_CastTo__zz_cib_Class350(::PoDoFo::PdfCMapEncoding* __zz_cib_obj) {
return __zz_cib_obj;
}
static ::PoDoFo::PdfCMapEncoding* __zz_cib_decl __zz_cib_CastFrom__zz_cib_Class350(::PoDoFo::PdfEncoding* __zz_cib_obj) {
return __zz_cib_DownCast<::PoDoFo::PdfCMapEncoding*>(__zz_cib_obj);
}
};
}
namespace __zz_cib_ {
namespace __zz_cib_Class333 {
using namespace ::PoDoFo;
namespace __zz_cib_Class412 {
const __zz_cib_MethodTable* __zz_cib_GetMethodTable() {
static const __zz_cib_MTableEntry methodArray[] = {
reinterpret_cast<__zz_cib_MTableEntry> (&__zz_cib_::__zz_cib_Delegator<::PoDoFo::PdfCMapEncoding>::__zz_cib_Copy_0),
reinterpret_cast<__zz_cib_MTableEntry> (&__zz_cib_::__zz_cib_Delegator<::PoDoFo::PdfCMapEncoding>::__zz_cib_Delete_1),
reinterpret_cast<__zz_cib_MTableEntry> (&__zz_cib_::__zz_cib_Delegator<::PoDoFo::PdfCMapEncoding>::__zz_cib_New_2),
reinterpret_cast<__zz_cib_MTableEntry> (&__zz_cib_::__zz_cib_Delegator<::PoDoFo::PdfCMapEncoding>::ConvertToUnicode_3),
reinterpret_cast<__zz_cib_MTableEntry> (&__zz_cib_::__zz_cib_Delegator<::PoDoFo::PdfCMapEncoding>::AddToDictionary_4),
reinterpret_cast<__zz_cib_MTableEntry> (&__zz_cib_::__zz_cib_Delegator<::PoDoFo::PdfCMapEncoding>::ConvertToEncoding_5),
reinterpret_cast<__zz_cib_MTableEntry> (&__zz_cib_::__zz_cib_Delegator<::PoDoFo::PdfCMapEncoding>::IsAutoDelete_6),
reinterpret_cast<__zz_cib_MTableEntry> (&__zz_cib_::__zz_cib_Delegator<::PoDoFo::PdfCMapEncoding>::IsSingleByteEncoding_7),
reinterpret_cast<__zz_cib_MTableEntry> (&__zz_cib_::__zz_cib_Delegator<::PoDoFo::PdfCMapEncoding>::GetCharCode_8),
reinterpret_cast<__zz_cib_MTableEntry> (&__zz_cib_::__zz_cib_Delegator<::PoDoFo::PdfCMapEncoding>::GetID_9),
reinterpret_cast<__zz_cib_MTableEntry> (&__zz_cib_::__zz_cib_Delegator<::PoDoFo::PdfCMapEncoding>::GetBaseEncoding_10),
reinterpret_cast<__zz_cib_MTableEntry> (&__zz_cib_::__zz_cib_Delegator<::PoDoFo::PdfCMapEncoding>::__zz_cib_CastTo__zz_cib_Class350),
reinterpret_cast<__zz_cib_MTableEntry> (&__zz_cib_::__zz_cib_Delegator<::PoDoFo::PdfCMapEncoding>::__zz_cib_CastFrom__zz_cib_Class350),
reinterpret_cast<__zz_cib_MTableEntry> (&__zz_cib_::__zz_cib_Delegator<::PoDoFo::PdfCMapEncoding>::__zz_cib_RegisterProxy)
};
static const __zz_cib_MethodTable methodTable = { methodArray, 14 };
return &methodTable;
}
}}}
| 56.632
| 242
| 0.787541
|
satya-das
|
5961c387358a7081b46a720255ef91aafa3f61e6
| 2,838
|
cpp
|
C++
|
SVEngine/src/event/SVEvent.cpp
|
SVEChina/SVEngine
|
56174f479a3096e57165448142c1822e7db8c02f
|
[
"MIT"
] | 34
|
2018-09-28T08:28:27.000Z
|
2022-01-15T10:31:41.000Z
|
SVEngine/src/event/SVEvent.cpp
|
SVEChina/SVEngine
|
56174f479a3096e57165448142c1822e7db8c02f
|
[
"MIT"
] | null | null | null |
SVEngine/src/event/SVEvent.cpp
|
SVEChina/SVEngine
|
56174f479a3096e57165448142c1822e7db8c02f
|
[
"MIT"
] | 8
|
2018-10-11T13:36:35.000Z
|
2021-04-01T09:29:34.000Z
|
//
// SVEvent.cpp
// SVEngine
// Copyright 2017-2020
// yizhou Fu,long Yin,longfei Lin,ziyu Xu,xiaofan Li,daming Li
//
#include "SVEvent.h"
SVEvent::SVEvent() {
eventType = EVN_T_NONE;
eventName = "";
}
SVEvent::~SVEvent() {
}
bool SVEvent::isEqual(SVEventPtr _event) {
return strcmp(eventName.c_str(), _event->eventName.c_str()) == 0;
}
//
SVEvtRecycle::SVEvtRecycle(){
m_obj = nullptr;
}
//
SVPersonEvent::SVPersonEvent() {
personID = -1;
}
SVPersonEvent::~SVPersonEvent() {
}
bool SVPersonEvent::isEqual(SVEventPtr _event) {
bool t_flag = SVEvent::isEqual(_event);
SVPersonEventPtr t_person_event = DYN_TO_SHAREPTR(SVPersonEvent, _event);
if(t_person_event->personID!=personID){
t_flag = false;
}
return t_flag;
}
//
SVAnimateEvent::SVAnimateEvent() {
eventType = EVN_T_ANIMATE;
resid = 0;
m_AnimateName = "";
}
bool SVAnimateEvent::isEqual(SVEventPtr _event) {
bool t_flag = SVPersonEvent::isEqual(_event);
if (t_flag) {
SVAnimateEventPtr tempEvent = DYN_TO_SHAREPTR(SVAnimateEvent,_event);
if (!tempEvent || m_AnimateName != tempEvent->m_AnimateName)
t_flag = false;
}
return t_flag;
}
//解析事件
SVParseEvent::SVParseEvent() {
eventType = EVN_T_PARSE;
isloadEffect = false;
resid = 0;
screenName = "";
}
SVParseEvent::~SVParseEvent() {
}
//
SVFaceShapeEvent::SVFaceShapeEvent(){
m_faceSmooth = 0;
m_eyeSmooth = 0;
}
SVFaceShapeEvent::~SVFaceShapeEvent(){
m_faceSmooth = 0;
m_eyeSmooth = 0;
}
//拾取焦点信息
SVPickGetEvent::SVPickGetEvent(SVNodePtr _node){
eventType = EVN_T_PICK_GET_NODE;
m_pNode = _node;
}
SVPickGetEvent::~SVPickGetEvent(){
m_pNode = nullptr;
}
//拾取焦点信息
SVPickGetUIEvent::SVPickGetUIEvent(SVNodePtr _node){
eventType = EVN_T_PICK_GET_UI;
m_pNode = _node;
}
SVPickGetUIEvent::~SVPickGetUIEvent(){
m_pNode = nullptr;
}
SVPickGetNothingEvent::SVPickGetNothingEvent(){
eventType = EVN_T_PICK_GET_NOTHING;
}
SVPickGetNothingEvent::~SVPickGetNothingEvent(){
}
//丢失焦点
SVPickLoseEvent::SVPickLoseEvent(SVNodePtr _node){
m_pNode = _node;
}
SVPickLoseEvent::~SVPickLoseEvent(){
m_pNode = nullptr;
}
//改变信息
SVPickChangeEvent::SVPickChangeEvent(SVNodePtr _getnode,SVNodePtr _losenode){
m_pLastNode = _getnode;
m_pNewNode = _losenode;
}
SVPickChangeEvent::~SVPickChangeEvent(){
m_pLastNode = nullptr;
m_pNewNode = nullptr;
}
//
SVRedPacketEvent::SVRedPacketEvent(){
}
SVRedPacketEvent::~SVRedPacketEvent(){
}
SVEffectMusicEvent::SVEffectMusicEvent(){
eventType = EVN_T_EFFECT_MUSIC_LOAD;
eventName = "SVEffectMusicEvent";
}
SVEffectMusicEvent::~SVEffectMusicEvent(){
}
//
SVEventPersonExpression::SVEventPersonExpression(){
;
}
SVEventPersonExpression::~SVEventPersonExpression(){
}
| 18.076433
| 77
| 0.696265
|
SVEChina
|
596b411da6a4640880d6406f48d7b6da1900fb49
| 1,565
|
cpp
|
C++
|
src/Matrix.cpp
|
PalasanRares/WaterSim
|
ccdffc9d7442ca5bbbb9a2f807db127a9bda2740
|
[
"MIT"
] | null | null | null |
src/Matrix.cpp
|
PalasanRares/WaterSim
|
ccdffc9d7442ca5bbbb9a2f807db127a9bda2740
|
[
"MIT"
] | null | null | null |
src/Matrix.cpp
|
PalasanRares/WaterSim
|
ccdffc9d7442ca5bbbb9a2f807db127a9bda2740
|
[
"MIT"
] | null | null | null |
#include "Matrix.hpp"
#include "elements/Eraser.hpp"
#include "elements/liquids/Water.hpp"
#include "elements/liquids/Acid.hpp"
Matrix::Matrix(const int width, const int height) : width(width), height(height) {
matrix = new Element**[width];
for (int i = 0; i < width; i++) {
matrix[i] = new Element*[height];
for (int j = 0; j < height; j++) {
matrix[i][j] = new Eraser();
}
}
}
Element*** Matrix::getMatrix() {
return matrix;
}
const int Matrix::getWidth() {
return width;
}
const int Matrix::getHeight() {
return height;
}
Element* Matrix::getPosition(const int& i, const int& j) {
return matrix[i][j];
}
bool Matrix::checkPosition(const int& i, const int& j) {
return i >= 0 && i < width && j >= 0 && j < height;
}
void Matrix::setPosition(const int& i, const int& j, Element* element) {
delete matrix[i][j];
matrix[i][j] = element;
}
void Matrix::swapPosition(const int& i, const int& j, const int& ii, const int& jj) {
Element* aux = matrix[i][j];
matrix[i][j] = matrix[ii][jj];
matrix[ii][jj] = aux;
}
void Matrix::updateMatrix() {
for (int i = 0; i < width; i++) {
for (int j = height - 1; j >= 0; j--) {
matrix[i][j]->update(this, i, j);
}
}
}
void Matrix::refreshMatrix() {
for (int i = 0; i < width; i++) {
for (int j = height - 1; j >= 0; j--) {
matrix[i][j]->setUpdated(false);
}
}
}
Matrix::~Matrix() {
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
delete matrix[i][j];
}
delete[] matrix[i];
}
delete[] matrix;
}
| 21.736111
| 85
| 0.574441
|
PalasanRares
|
596b54d228deb9784b0b52e8de87da967791f449
| 12,425
|
cpp
|
C++
|
projects/atLib/source/Statistics/atBPGNetwork.cpp
|
mbatc/atLib
|
7e3a69515f504a05a312d234291f02863e291631
|
[
"MIT"
] | 1
|
2019-09-17T18:02:16.000Z
|
2019-09-17T18:02:16.000Z
|
projects/atLib/source/Statistics/atBPGNetwork.cpp
|
mbatc/atLib
|
7e3a69515f504a05a312d234291f02863e291631
|
[
"MIT"
] | null | null | null |
projects/atLib/source/Statistics/atBPGNetwork.cpp
|
mbatc/atLib
|
7e3a69515f504a05a312d234291f02863e291631
|
[
"MIT"
] | null | null | null |
// -----------------------------------------------------------------------------
// The MIT License
//
// Copyright(c) 2020 Michael Batchelor,
//
// 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.
// -----------------------------------------------------------------------------
#include "atBPGNetwork.h"
#include "atMath.h"
atBPGNetwork::atBPGNetwork(int64_t inputSize, int64_t outputSize, int64_t layerCount, int64_t layerSize)
{
m_layerSize = layerSize;
m_layers.resize(1 + atMax(0, layerCount));
m_layers[0].nNodes = inputSize;
for (int64_t i = 1; i < m_layers.size() + 1; ++i)
{
int64_t nextLayerNodeCount = outputSize;
if (i < m_layers.size())
{
m_layers[i].nNodes = layerSize;
nextLayerNodeCount = layerSize;
}
m_layers[i - 1].weights = atMatrixNxM<double>(m_layers[i - 1].nNodes, nextLayerNodeCount);
m_layers[i - 1].biases = atMatrixNxM<double>(1, nextLayerNodeCount);
// Randomize values to begin with
for (double &val : m_layers[i - 1].weights.m_data)
val = atClamp((double)(rand() % 500) / 500, 0.1, 1.0);
for (double &val : m_layers[i - 1].biases.m_data)
val = double(rand() % 1000ll - 500) / 500;
}
m_nOutputs = outputSize;
m_nInputs = inputSize;
}
atVector<double> atBPGNetwork::Predict(const atVector<double> &input) { return Predict(input, nullptr, nullptr).m_data; }
bool atBPGNetwork::Train(const atVector<atVector<double>> &inputs, const atVector<atVector<double>> &outputs)
{
atMatrixNxM<double> costGradient; // Cost gradient matrix
atVector<atMatrixNxM<double>> biasAdjustments;
atVector<atMatrixNxM<double>> weightAdjustments;
// For each training set
for (int64_t i = 0; i < inputs.size(); ++i)
{
const atVector<double> &set = inputs[i]; // Input set
const atVector<double> &goal = outputs[i]; // Target values
// Get the networks current prediction for the input set
// We also need to store the activates at each layer to perform back propagation
atVector<atMatrixNxM<double>> activations;
atVector<atMatrixNxM<double>> rawActivations;
Predict(set, &activations, &rawActivations);
weightAdjustments.resize(activations.size() - 1);
biasAdjustments.resize(activations.size() - 1);
atMatrixNxM<double> prevLayerRawActivationCostInfluence;
for (int64_t currentLayer = activations.size() - 1; currentLayer > 0; --currentLayer)
{
atMatrixNxM<double> ¤tLayerRawActivations = rawActivations[currentLayer];
atMatrixNxM<double> &prevLayerRawActivations = rawActivations[currentLayer - 1];
atMatrixNxM<double> ¤tLayerActivations = activations[currentLayer];
atMatrixNxM<double> &prevLayerActivations = activations[currentLayer - 1];
// Raw activation influences on the cost function for the previous layer
atMatrixNxM<double> currentLayerRawWeightCostInfluence = prevLayerRawActivationCostInfluence;
prevLayerRawActivationCostInfluence = atMatrixNxM<double>(1, prevLayerActivations.m_rows, 0);
// Weight influences on the cost function for this layer
atMatrixNxM<double> layerWeightCostInfluence(currentLayerActivations.m_rows, prevLayerActivations.m_rows);
atMatrixNxM<double> layerLayerBiasCostInfluence(1, prevLayerRawActivations.m_rows);
for (int64_t currentLayerNode = 0; currentLayerNode < currentLayerActivations.m_rows; ++currentLayerNode)
{
// double a = currentLayerActivations[currentLayerNode]; // Current layer activation value
for (int64_t prevLayerNode = 0; prevLayerNode < prevLayerActivations.m_rows; ++prevLayerNode)
{
// double aPrev = prevLayerActivations[prevLayerNode]; // Previous layer activation value
// Compute derivative of the current layers activation with respect to the rawActivation
double sigmoidActivationInfluence = 1;
if (m_activationFunc)
sigmoidActivationInfluence = atDerivative<double, double>(currentLayerRawActivations[currentLayerNode], m_activationFunc, 0.01);
if (currentLayerRawWeightCostInfluence.m_rows == 0) // The current layer is the output layer
{
// Compute derivative of the Cost function with respect to the current layers activation
double activationCostInfluence = 2 * (currentLayerActivations[currentLayerNode] - goal[currentLayerNode]);
sigmoidActivationInfluence *= activationCostInfluence;
}
else
{
sigmoidActivationInfluence *= m_layers[currentLayer - 1].weights(prevLayerNode, currentLayerNode) * currentLayerRawWeightCostInfluence(currentLayerNode, 0);
}
// Compute derivative of the current layers activation with respect to the current layers weight
double activationWeightInfluence = prevLayerActivations[prevLayerNode];
// Compute derivative of the Cost function with respect to the previous layers raw activation
double prevRawWeightCostInfluence = sigmoidActivationInfluence;
// Compute derivative of the Cost function with respect to the weight
double weightCostInfluence = prevRawWeightCostInfluence * activationWeightInfluence;
// Add the weight influence to the weight cost influence
layerWeightCostInfluence(prevLayerNode, currentLayerNode) += weightCostInfluence;
layerLayerBiasCostInfluence(prevLayerNode, 0) += prevRawWeightCostInfluence;
// Add the previous layers cost influence contributed by each node in this layer
prevLayerRawActivationCostInfluence(prevLayerNode, 0) += prevRawWeightCostInfluence;
}
}
if (weightAdjustments[currentLayer - 1].m_rows != layerWeightCostInfluence.m_rows)
weightAdjustments[currentLayer - 1] = layerWeightCostInfluence;
else
weightAdjustments[currentLayer - 1] = weightAdjustments[currentLayer - 1] + layerWeightCostInfluence;
if (biasAdjustments[currentLayer - 1].m_rows == 0)
biasAdjustments[currentLayer - 1] = prevLayerRawActivationCostInfluence;
else
biasAdjustments[currentLayer - 1] = biasAdjustments[currentLayer - 1] + prevLayerRawActivationCostInfluence;
}
}
// Adjust the training rate so that it depends on the number of nodes in the network
double trainingAmount = m_trainingRate / (outputs.size() * m_nOutputs);
for (int64_t i = 0; i < m_layers.size(); ++i)
m_layers[i].weights = m_layers[i].weights - weightAdjustments[i].Mul(trainingAmount).Apply([](double val) { return atClamp(val, -1.0, 1.0); });
for (int64_t i = 0; i < m_layers.size(); ++i)
m_layers[i].biases = m_layers[i].biases - biasAdjustments[i].Mul(trainingAmount);
return true;
}
void atBPGNetwork::SetActivationFunction(std::function<double(double)> func) { m_activationFunc = func; }
const atMatrixNxM<double>& atBPGNetwork::GetLayerWeights(int64_t layer) const { return m_layers[layer].weights; }
const atMatrixNxM<double>& atBPGNetwork::GetLayerBiases(int64_t layer) const { return m_layers[layer].biases; }
int64_t atBPGNetwork::LayerCount() const { return m_layers.size(); }
int64_t atBPGNetwork::InputCount() const { return m_nInputs; }
int64_t atBPGNetwork::OutputCount() const { return m_nOutputs; }
void atBPGNetwork::SetTrainingRate(const double &rate) { m_trainingRate = rate; }
const double &atBPGNetwork::GetTrainingRate() const { return m_trainingRate; }
bool atBPGNetwork::SetLayerWeights(int64_t layer, const atMatrixNxM<double> &weights)
{
atMatrixNxM<double> &mat = m_layers[layer].weights;
if (mat.m_columns != weights.m_columns || mat.m_rows != weights.m_rows)
return false;
mat = weights;
return true;
}
bool atBPGNetwork::SetLayerBiases(int64_t layer, const atMatrixNxM<double> &biases)
{
atMatrixNxM<double> &mat = m_layers[layer].biases;
if (mat.m_columns != biases.m_columns || mat.m_rows != biases.m_rows)
return false;
mat = biases;
return true;
}
atBPGNetwork::Layer::Layer()
: weights(0, 0)
, biases(0, 0)
{}
int64_t atBPGNetwork::StreamWrite(atWriteStream *pStream, const atBPGNetwork *pData, const int64_t count)
{
int64_t ret = 0;
for (int64_t i = 0; i < count; ++i)
ret += atStreamWrite(pStream, &pData[i].m_layers, 1);
return ret;
}
int64_t atBPGNetwork::StreamRead(atReadStream *pStream, atBPGNetwork *pData, const int64_t count)
{
int64_t ret = 0;
for (int64_t i = 0; i < count; ++i)
ret += atStreamRead(pStream, &pData[i].m_layers, 1);
return ret;
}
atMatrixNxM<double> atBPGNetwork::Predict(const atVector<double> &input, atVector<atMatrixNxM<double>> *pActivations, atVector<atMatrixNxM<double>> *pRawActivations)
{
atMatrixNxM<double> activations(1, input.size());
memcpy(activations.m_data.data(), input.data(), input.size() * sizeof(double));
if (pRawActivations)
pRawActivations->push_back(activations);
if (pActivations)
pActivations->push_back(activations);
for (int64_t i = 0; i < m_layers.size(); ++i)
{
activations = (m_layers[i].weights * activations + m_layers[i].biases);
if (pRawActivations)
pRawActivations->push_back(activations);
if (m_activationFunc)
activations = activations.Apply(m_activationFunc);
if (pActivations)
pActivations->push_back(activations);
}
return activations;
}
void atSerialize(atObjectDescriptor *pSerialized, const atBPGNetwork &src)
{
pSerialized->Add("learnRate").Serialize(src.m_trainingRate);
pSerialized->Add("nOutputs").Serialize(src.m_nOutputs);
pSerialized->Add("layers").Serialize(src.m_layers);
}
void atDeserialize(const atObjectDescriptor &serialized, atBPGNetwork *pDst)
{
serialized["learnRate"].Deserialize(&pDst->m_trainingRate);
serialized["nOutputs"].Deserialize(&pDst->m_nOutputs);
serialized["layers"].Deserialize(&pDst->m_layers);
if (pDst->m_layers.size() > 0)
{
pDst->m_nInputs = pDst->m_layers.front().nNodes;
pDst->m_nOutputs = pDst->m_layers.back().nNodes;
}
}
void atSerialize(atObjectDescriptor *pSerialized, const atBPGNetwork::Layer &src)
{
pSerialized->Add("nNodes").Serialize(src.nNodes);
pSerialized->Add("bias").Serialize(src.biases.Transpose());
pSerialized->Add("weight").Serialize(src.weights);
}
void atDeserialize(const atObjectDescriptor &serialized, atBPGNetwork::Layer *pDst)
{
serialized.Get("nNodes").Deserialize(&pDst->nNodes);
serialized.Get("bias").Deserialize(&pDst->biases);
serialized.Get("weight").Deserialize(&pDst->weights);
pDst->biases = pDst->biases.Transpose();
}
int64_t atStreamRead(atReadStream *pStream, atBPGNetwork::Layer *pData, const int64_t count)
{
int64_t ret = 0;
for (int64_t i = 0; i < count; ++i)
{
ret += atStreamRead(pStream, &pData[i].weights, 1);
ret += atStreamRead(pStream, &pData[i].biases, 1);
}
return ret;
}
int64_t atStreamWrite(atWriteStream *pStream, const atBPGNetwork::Layer *pData, const int64_t count)
{
int64_t ret = 0;
for (int64_t i = 0; i < count; ++i)
{
ret += atStreamWrite(pStream, &pData[i].weights, 1);
ret += atStreamWrite(pStream, &pData[i].biases, 1);
}
return ret;
}
int64_t atStreamRead(atReadStream *pStream, atBPGNetwork *pData, const int64_t count) { return atBPGNetwork::StreamRead(pStream, pData, count); }
int64_t atStreamWrite(atWriteStream *pStream, const atBPGNetwork *pData, const int64_t count) { return atBPGNetwork::StreamWrite(pStream, pData, count); }
| 42.55137
| 168
| 0.716217
|
mbatc
|
5974479cbe0768abdeb2fd62190d4977a1efef09
| 1,246
|
hpp
|
C++
|
engine/include/krao.hpp
|
insanityinc/laq-engine
|
323225589335ce1f95409de25dca878cccb9233a
|
[
"MIT"
] | null | null | null |
engine/include/krao.hpp
|
insanityinc/laq-engine
|
323225589335ce1f95409de25dca878cccb9233a
|
[
"MIT"
] | null | null | null |
engine/include/krao.hpp
|
insanityinc/laq-engine
|
323225589335ce1f95409de25dca878cccb9233a
|
[
"MIT"
] | null | null | null |
/*
* Copyright (c) 2018 João Afonso. All rights reserved.
*/
#ifndef ENGINE_INCLUDE_KRAO_H_
#define ENGINE_INCLUDE_KRAO_H_
#include <vector>
#include "include/block.hpp"
namespace engine {
void krao(const FilteredBitVectorBlock& A,
const DecimalVectorBlock& B,
FilteredDecimalVectorBlock *C);
void krao(const FilteredBitVectorBlock& A,
const FilteredBitVectorBlock& B,
FilteredBitVectorBlock *C);
void krao(const FilteredDecimalVectorBlock& A,
const FilteredBitVectorBlock& B,
FilteredDecimalVectorBlock* C);
void krao(const FilteredBitVectorBlock& A,
const BitmapBlock& B,
FilteredBitmapBlock *C);
void krao(const FilteredBitmapBlock& A,
const BitmapBlock& B,
FilteredBitmapBlock *C,
Size Bnrows);
void krao(const BitmapBlock& A,
const FilteredBitmapBlock& B,
FilteredBitmapBlock *C,
Size Bnrows);
void krao(const FilteredBitmapBlock& A,
const FilteredBitVectorBlock& B,
FilteredBitmapBlock* C);
void krao(const FilteredBitmapBlock& A,
const DecimalVectorBlock& B,
FilteredDecimalMapBlock *C);
} // namespace engine
#endif // ENGINE_INCLUDE_KRAO_H_
| 25.428571
| 55
| 0.684591
|
insanityinc
|
597bc4e46e269ac91f09b45697e53e9ed9dc4199
| 11,193
|
cpp
|
C++
|
Patches/FogAdjustments.cpp
|
TheMachineAmbassador/Silent-Hill-2-Enhancements
|
41650db4a97ca6085db69446e7a20042b344e77f
|
[
"Zlib"
] | null | null | null |
Patches/FogAdjustments.cpp
|
TheMachineAmbassador/Silent-Hill-2-Enhancements
|
41650db4a97ca6085db69446e7a20042b344e77f
|
[
"Zlib"
] | null | null | null |
Patches/FogAdjustments.cpp
|
TheMachineAmbassador/Silent-Hill-2-Enhancements
|
41650db4a97ca6085db69446e7a20042b344e77f
|
[
"Zlib"
] | null | null | null |
/**
* Copyright (C) 2022 Elisha Riedlinger
*
* This software is provided 'as-is', without any express or implied warranty. In no event will the
* authors be held liable for any damages arising from the use of this software.
* Permission is granted to anyone to use this software for any purpose, including commercial
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
* original software. If you use this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
* being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include "Patches.h"
#include "Common\Utils.h"
#include "Logging\Logging.h"
// Variables for ASM
DWORD CameraConditionFlag = 0x00;
void *FogFrontPointer;
void *FogBackPointer;
void *jmpFogReturnAddr;
void *jmpBlueCreekFogReturnAddr;
void *NewEnvFogRGB;
void *OriginalEnvFogRGB;
void *jmpFinalAreaBossAddr1;
void *jmpFinalAreaBossAddr2;
// Fog values
constexpr float NewFrontFog = 2200.0f;
constexpr float NewBackFog = 2800.0f;
constexpr float OriginalFrontFog = 8000.0f;
constexpr float OriginalBackFog = 12000.0f;
constexpr float BlueCreekNewFog = 4200.0f;
constexpr float BlueCreekOriginalFog = 3000.0f;
constexpr float FinalAreaCameraYOrientation = -15750.0f;
// ASM functions to adjust fog values for Angela cutscene
__declspec(naked) void __stdcall FogAdjustmentASM()
{
__asm
{
pushf
push ecx
cmp CameraConditionFlag, 0x01
je near CheckCutsceneID // jumps to check cutscene ID if camera conditions were already met
mov eax, dword ptr ds : [CutscenePosAddr]
cmp dword ptr ds : [eax], 0x4767DA5D
jne near ConditionsNotMet // jumps if camera is not facing the door
CheckCutsceneID:
mov eax, dword ptr ds : [CutsceneIDAddr]
cmp dword ptr ds : [eax], 0x12
jne near ConditionsNotMet // jumps if not angela mirror cutscene
// Conditions Met
mov CameraConditionFlag, 0x01 // writes 01 to indicate that camera conditions have been met
mov ecx, NewFrontFog
mov eax, dword ptr ds : [FogFrontPointer]
mov dword ptr ds : [eax], ecx // set new fog front value
mov ecx, NewBackFog
mov eax, dword ptr ds : [FogBackPointer]
mov dword ptr ds : [eax], ecx // set new fog back value
jmp near ExitFunction
ConditionsNotMet:
mov CameraConditionFlag, 0x00 // writes 00 to indicate that camera conditions have not been met
mov eax, dword ptr ds : [FogFrontPointer]
mov eax, dword ptr ds : [eax]
cmp eax, NewFrontFog
jne near ExitFunction // jumps if fog front value is not the new fog front value
mov eax, dword ptr ds : [FogBackPointer]
mov eax, dword ptr ds : [eax]
cmp eax, NewBackFog
jne near ExitFunction // jumps if fog back value is not the new fog back value
mov ecx, OriginalFrontFog
mov eax, dword ptr ds : [FogFrontPointer]
mov dword ptr ds : [eax], ecx // restores original fog front value; 8000 flt
mov ecx, OriginalBackFog
mov eax, dword ptr ds : [FogBackPointer]
mov dword ptr ds : [eax], ecx // restores original fog back value; 12000 flt
ExitFunction:
mov eax, dword ptr ds : [FogFrontPointer]
mov eax, dword ptr ds : [eax]
pop ecx
popf
jmp jmpFogReturnAddr
}
}
// ASM functions to adjust fog values for Blue Creek Apt Room 209
__declspec(naked) void __stdcall BlueCreekFogAdjustmentASM()
{
__asm
{
pushf
push eax
push ecx
mov eax, dword ptr ds : [RoomIDAddr]
cmp dword ptr ds : [eax], 0x28
jne near ConditionsNotMet // jumps if not Blue Creek Apt Room 209
mov ecx, BlueCreekNewFog
mov eax, dword ptr ds : [FogFrontPointer]
mov dword ptr ds : [eax], ecx // new fog value
jmp near ExitFunction
ConditionsNotMet:
mov ecx, BlueCreekOriginalFog
mov eax, dword ptr ds : [FogFrontPointer]
mov dword ptr ds : [eax], ecx // original fog value; 3000 flt
ExitFunction:
pop ecx
pop eax
popf
jmp jmpBlueCreekFogReturnAddr
}
}
// ASM final boss area 1
__declspec(naked) void __stdcall FinalAreaBoss1ASM()
{
__asm
{
mov eax, dword ptr ds : [RoomIDAddr]
cmp dword ptr ds : [eax], 0xBB
jne near NotFinalBoss
mov eax, dword ptr ds : [InGameCameraPosYAddr]
movss xmm0, dword ptr ds : [FinalAreaCameraYOrientation]
comiss xmm0, dword ptr ds : [eax]
jbe near NotFinalBoss
mov eax, dword ptr ds : [NewEnvFogRGB]
jmp near ExitASM
NotFinalBoss:
mov eax, dword ptr ds : [OriginalEnvFogRGB]
ExitASM:
mov eax, dword ptr ds : [eax]
jmp jmpFinalAreaBossAddr1
}
}
// ASM final boss area 2
__declspec(naked) void __stdcall FinalAreaBoss2ASM()
{
__asm
{
push eax
mov eax, dword ptr ds : [RoomIDAddr]
cmp dword ptr ds : [eax], 0xBB
jne near NotFinalBoss
mov eax, dword ptr ds : [InGameCameraPosYAddr]
movss xmm0, dword ptr ds : [FinalAreaCameraYOrientation]
comiss xmm0, dword ptr ds : [eax]
jbe near NotFinalBoss
pop eax
push 0
jmp near ExitASM
NotFinalBoss:
pop eax
push 1
ExitASM:
push 0x1C
push eax
jmp jmpFinalAreaBossAddr2
}
}
void PatchFogParameters()
{
// Get Fog address
constexpr BYTE FogSearchBytes[]{ 0x8B, 0xF8, 0x81, 0xE7, 0xFF, 0x00, 0x00, 0x00, 0xC1, 0xE7, 0x10, 0x25, 0x00, 0xFF, 0x00, 0xFF, 0x0B, 0xF7, 0x0B, 0xF0, 0x56 };
DWORD FogAddr = SearchAndGetAddresses(0x00479E71, 0x0047A111, 0x0047A321, FogSearchBytes, sizeof(FogSearchBytes), 0x00);
// Checking address pointer
if (!FogAddr)
{
Logging::Log() << __FUNCTION__ << " Error: failed to find memory address!";
return;
}
jmpFogReturnAddr = (void*)(FogAddr - 0x1A);
// Get Blue Creek return address
constexpr BYTE BlueCreekFogSearchBytes[]{ 0x85, 0xC0, 0xDF, 0xE0, 0x0F, 0x84, 0x90, 0x01, 0x00, 0x00, 0xF6, 0xC4, 0x44, 0x7A, 0x2A };
FogAddr = SearchAndGetAddresses(0x0047BE75, 0x0047C115, 0x0047C325, BlueCreekFogSearchBytes, sizeof(BlueCreekFogSearchBytes), 0x00);
// Checking address pointer
if (!FogAddr)
{
Logging::Log() << __FUNCTION__ << " Error: failed to find memory address!";
return;
}
jmpBlueCreekFogReturnAddr = (void*)(FogAddr + 0x23);
// Check for valid code before updating
if (!CheckMemoryAddress(jmpFogReturnAddr, "\x8B\x0D", 2) ||
!CheckMemoryAddress(jmpBlueCreekFogReturnAddr, "\xC7\x05", 2))
{
Logging::Log() << __FUNCTION__ << " Error: memory addresses don't match!";
return;
}
// Fog front and back addresses
memcpy(&FogFrontPointer, (void*)((DWORD)jmpFogReturnAddr - 4), sizeof(DWORD));
FogBackPointer = (void*)((DWORD)FogFrontPointer - 4);
// New environment fog RGB
constexpr BYTE NewEnvFogSearchBytes[]{ 0x90, 0x90, 0x90, 0x8B, 0x44, 0x24, 0x04, 0x8B, 0x0D };
NewEnvFogRGB = (void*)ReadSearchedAddresses(0x004798ED, 0x00479B8D, 0x00479D9D, NewEnvFogSearchBytes, sizeof(NewEnvFogSearchBytes), 0x09);
// Checking address pointer
if (!NewEnvFogRGB)
{
Logging::Log() << __FUNCTION__ << " Error: failed to find memory address!";
return;
}
// Fog parameters for final boss area address 1
constexpr BYTE FinalBossAddr1SearchBytes[]{ 0x90, 0x90, 0x90, 0x81, 0xEC, 0xB4, 0x02, 0x00, 0x00, 0xA1 };
DWORD FinalBossAddr1 = SearchAndGetAddresses(0x0050221D, 0x0050254D, 0x00501E6D, FinalBossAddr1SearchBytes, sizeof(FinalBossAddr1SearchBytes), 0x09);
// Checking address pointer
if (!FinalBossAddr1)
{
Logging::Log() << __FUNCTION__ << " Error: failed to find memory address!";
return;
}
OriginalEnvFogRGB = (void*)*(DWORD*)(FinalBossAddr1 + 1);
jmpFinalAreaBossAddr1 = (void*)(FinalBossAddr1 + 5);
// Fog parameters for final boss area address 2
constexpr BYTE FinalBossAddr2SearchBytes[]{ 0x8B, 0x08, 0x6A, 0x01, 0x6A, 0x1C, 0x50, 0xFF, 0x91, 0xC8, 0x00, 0x00, 0x00, 0xA1 };
DWORD FinalBossAddr2 = SearchAndGetAddresses(0x005038B5, 0x00503BE5, 0x00503505, FinalBossAddr2SearchBytes, sizeof(FinalBossAddr2SearchBytes), 0x02);
// Checking address pointer
if (!FinalBossAddr2)
{
Logging::Log() << __FUNCTION__ << " Error: failed to find memory address!";
return;
}
jmpFinalAreaBossAddr2 = (void*)(FinalBossAddr2 + 5);
// Get room ID address
RoomIDAddr = GetRoomIDPointer();
// Get cutscene ID address
CutsceneIDAddr = GetCutsceneIDPointer();
// Get cutscene camera position address
CutscenePosAddr = GetCutscenePosPointer();
// Get Camera in-game position Y
InGameCameraPosYAddr = GetInGameCameraPosYPointer();
// Checking address pointers
if (!RoomIDAddr || !CutsceneIDAddr || !CutscenePosAddr || !InGameCameraPosYAddr)
{
Logging::Log() << __FUNCTION__ << " Error: failed to get cutscene ID or position address!";
return;
}
// Update SH2 code
Logging::Log() << "Updating Fog Parameters...";
WriteJMPtoMemory((BYTE*)((DWORD)jmpFogReturnAddr - 5), *FogAdjustmentASM);
WriteJMPtoMemory((BYTE*)((DWORD)jmpBlueCreekFogReturnAddr - 10), *BlueCreekFogAdjustmentASM, 10);
WriteJMPtoMemory((BYTE*)FinalBossAddr1, FinalAreaBoss1ASM);
WriteJMPtoMemory((BYTE*)FinalBossAddr2, FinalAreaBoss2ASM);
}
// Slow the fog movement in certain areas of the game to better match the PS2's fog movements
void RunFogSpeed()
{
static float *FogSpeed = nullptr;
if (!FogSpeed)
{
RUNONCE();
constexpr BYTE SearchBytes[]{ 0xD9, 0x5C, 0x24, 0x5C, 0xD9, 0xC9, 0xD8, 0x44, 0x24, 0x60, 0xD9, 0x5C, 0x24, 0x60, 0xDB, 0x44, 0x24, 0x44, 0xD8, 0x3D };
FogSpeed = (float*)ReadSearchedAddresses(0x0048683D, 0x00486ADD, 0x00486CED, SearchBytes, sizeof(SearchBytes), 0x14);
if (!FogSpeed)
{
Logging::Log() << __FUNCTION__ << " Error: failed to find memory address!";
return;
}
}
static float *JamesFogInfluence = nullptr;
if (!JamesFogInfluence)
{
RUNONCE();
constexpr BYTE SearchBytes[]{ 0xC1, 0xE0, 0x18, 0x0B, 0xC3, 0x55, 0x89, 0x84, 0x24, 0x80, 0x00, 0x00, 0x00, 0xE8 };
JamesFogInfluence = (float*)ReadSearchedAddresses(0x00488ACB, 0x00488D6B, 0x00488F7B, SearchBytes, sizeof(SearchBytes), 0x14);
if (!JamesFogInfluence)
{
Logging::Log() << __FUNCTION__ << " Error: failed to find memory address!";
return;
}
}
LOG_ONCE("Setting Fog Speed Fix...");
switch (GetRoomID())
{
case 0x03:
case 0x04:
case 0x08:
case 0x8E:
case 0xB0:
case 0xBB:
case 0xBD:
case 0xC0:
case 0xC2:
case 0xCA:
case 0xC4:
case 0xD3:
case 0xD4:
{
constexpr float value = 0.25f;
if (*FogSpeed != value)
{
*FogSpeed = value;
}
break;
}
case 0x07:
case 0x8F:
case 0x90:
{
constexpr float value = 0.50f;
if (*FogSpeed != value)
{
*FogSpeed = value;
}
break;
}
}
static bool ValueSet = false;
// Prevents fog from "sticking" to James during certain parts of the Forest trail
if (GetRoomID() == 0x03 && GetJamesPosY() >= 1125.0f && GetJamesPosY() <= 1575.0f)
{
if (!ValueSet)
{
ValueSet = true;
float Value = 10.0f;
UpdateMemoryAddress(JamesFogInfluence, &Value, sizeof(float));
}
}
else
{
if (ValueSet)
{
ValueSet = false;
float Value = 200.0f;
UpdateMemoryAddress(JamesFogInfluence, &Value, sizeof(float));
}
}
}
| 30.169811
| 161
| 0.716698
|
TheMachineAmbassador
|
59821ad2edcb7a1d379b03a278e45ab1efa35b2e
| 1,821
|
cpp
|
C++
|
Engine/media/audio/clip_myjgmod.cpp
|
monkey0506/ags
|
2f96ddf47e944efea2534386a4004849eb71372b
|
[
"Artistic-2.0"
] | 21
|
2019-05-08T23:50:29.000Z
|
2021-04-28T07:59:17.000Z
|
Engine/media/audio/clip_myjgmod.cpp
|
monkey0506/ags
|
2f96ddf47e944efea2534386a4004849eb71372b
|
[
"Artistic-2.0"
] | null | null | null |
Engine/media/audio/clip_myjgmod.cpp
|
monkey0506/ags
|
2f96ddf47e944efea2534386a4004849eb71372b
|
[
"Artistic-2.0"
] | 6
|
2019-05-19T04:30:15.000Z
|
2022-01-29T05:26:46.000Z
|
//=============================================================================
//
// Adventure Game Studio (AGS)
//
// Copyright (C) 1999-2011 Chris Jones and 2011-20xx others
// The full list of copyright holders can be found in the Copyright.txt
// file, which is part of this source code distribution.
//
// The AGS source code is provided under the Artistic License 2.0.
// A copy of this license can be found in the file License.txt and at
// http://www.opensource.org/licenses/artistic-license-2.0.php
//
//=============================================================================
#include "media/audio/audiodefines.h"
#ifdef JGMOD_MOD_PLAYER
#include "media/audio/clip_myjgmod.h"
#include "media/audio/audiointernaldefs.h"
int MYMOD::poll()
{
if (done)
return done;
if (is_mod_playing() == 0)
done = 1;
return done;
}
void MYMOD::set_volume(int newvol)
{
vol = newvol;
if (!done)
set_mod_volume(newvol);
}
void MYMOD::destroy()
{
stop_mod();
destroy_mod(tune);
tune = NULL;
}
void MYMOD::seek(int patnum)
{
if (is_mod_playing() != 0)
goto_mod_track(patnum);
}
int MYMOD::get_pos()
{
if (!is_mod_playing())
return -1;
return mi.trk;
}
int MYMOD::get_pos_ms()
{
return 0; // we don't know ms offset
}
int MYMOD::get_length_ms()
{ // we don't know ms
return 0;
}
void MYMOD::restart()
{
if (tune != NULL) {
stop_mod();
done = 0;
play_mod(tune, 0);
}
}
int MYMOD::get_voice()
{
// MOD uses so many different voices it's not practical to keep track
return -1;
}
int MYMOD::get_sound_type() {
return MUS_MOD;
}
int MYMOD::play() {
play_mod(tune, repeat);
return 1;
}
MYMOD::MYMOD() : SOUNDCLIP() {
}
#endif // #ifdef JGMOD_MOD_PLAYER
| 18.581633
| 79
| 0.571664
|
monkey0506
|
5986d79ca0a1e1183f2b80e17c83283c4e365916
| 7,376
|
cpp
|
C++
|
testing/integration_testing/external/imagick_test.cpp
|
stian-svedenborg/xyuv
|
c725b4f926ef3c5311878b0b8b9c4dacbbf0db34
|
[
"MIT"
] | 5
|
2015-08-13T18:46:45.000Z
|
2018-04-18T18:51:43.000Z
|
testing/integration_testing/external/imagick_test.cpp
|
stian-svedenborg/xyuv
|
c725b4f926ef3c5311878b0b8b9c4dacbbf0db34
|
[
"MIT"
] | 18
|
2015-08-19T13:25:30.000Z
|
2017-05-08T10:55:48.000Z
|
testing/integration_testing/external/imagick_test.cpp
|
stian-svedenborg/xyuv
|
c725b4f926ef3c5311878b0b8b9c4dacbbf0db34
|
[
"MIT"
] | 3
|
2016-07-21T12:18:06.000Z
|
2018-05-19T05:32:32.000Z
|
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2016 Stian Valentin Svedenborg
*
* 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.
*/
#include <gtest/gtest.h>
#include <xyuv/structures/conversion_matrix.h>
#include <xyuv/structures/format.h>
#include <xyuv/frame.h>
#include <xyuv/external/magick_wrapper.h>
#include "../../xyuv/src/config_parser.h"
#include <xyuv/yuv_image.h>
#include <xyuv.h>
#include <Magick++.h>
#include "../../TestResources.h"
using namespace xyuv;
class ImageMagickWrapperTest : public ::testing::TestWithParam<std::string> {
protected:
void read_write_store_image(const std::string & fmt_name);
};
static void compare_colors(const Magick::ColorRGB & expected, const Magick::ColorRGB & observed, bool expected_has_alpha, bool observed_has_alpha ) {
ASSERT_NEAR(expected.red(), observed.red(), 1.1f/(0x1<<8));
ASSERT_NEAR(expected.green(), observed.green(), 1.1f/(0x1<<8));
ASSERT_NEAR(expected.blue(), observed.blue(), 1.1f/(0x1<<8));
if (expected_has_alpha) {
ASSERT_NEAR(expected.alpha(), observed.alpha(), 1.1f / (0x1 << 8));
}
else if (observed_has_alpha) {
ASSERT_NEAR(1.0f, observed.alpha(), 1.1f /(0x1 << 8));
}
}
TEST_F(ImageMagickWrapperTest, RGB_to_and_from_YUV) {
Magick::Image image_expected(Resources::get().get_png_path(Resources::TestImage::LENA));
::conversion_matrix conversion_matrix = Resources::get().config().get_conversion_matrix("bt601");
const magick_wrapper img(image_expected);
::yuv_image yuv_image = rgb_to_yuv_image( img, conversion_matrix );
Magick::Image image_observed(Magick::Geometry(yuv_image.image_w, yuv_image.image_h), Magick::Color("black"));
magick_wrapper img2(image_observed);
yuv_image_to_rgb(&img2, yuv_image, conversion_matrix);
ASSERT_EQ(image_expected.matte(), image_observed.matte());
#if 1
const Magick::PixelPacket * expected_pixels = image_expected.getConstPixels(0,0, image_expected.columns(), image_expected.rows());
const Magick::PixelPacket * observed_pixels = image_observed.getConstPixels(0,0, image_observed.columns(), image_observed.rows());
for (uint32_t y = 0; y < image_expected.rows(); y++) {
for ( uint32_t x = 0; x < image_expected.columns(); x++) {
compare_colors(
Magick::Color(expected_pixels[image_expected.columns()*y + x]),
Magick::Color(observed_pixels[image_observed.columns()*y + x]),
image_expected.matte(),
image_observed.matte()
);
}
}
#endif
// image_observed.write("testing/integration_testing/test_data/lena_out.png");
}
void ImageMagickWrapperTest::read_write_store_image(const std::string & fmt_name) {
std::cout << "[ FORMAT ] " << GetParam() << std::endl;
Magick::Image image_expected = Resources::get().get_png_path(Resources::TestImage::LENA);
::conversion_matrix conversion_matrix = Resources::get().config().get_conversion_matrix("bt601");
::format_template fmt_template = Resources::get().config().get_format_template(fmt_name);
::chroma_siting chroma_siting; // Pick a valid chroma siting.
try {
auto sitings = Resources::get().config().get_chroma_sitings(fmt_template.subsampling);
std::string siting_string = *sitings.begin();
chroma_siting = Resources::get().config().get_chroma_siting(siting_string);
} catch (std::exception & e) {
FAIL() << e.what();
return;
}
const magick_wrapper img(image_expected);
// Prepare format
format fmt = create_format(
image_expected.columns(),
image_expected.rows(),
fmt_template,
conversion_matrix,
chroma_siting );
::frame frame = read_frame_from_rgb_image(img, fmt);
Magick::Image image_observed(Magick::Geometry(image_expected.columns(), image_expected.rows()), Magick::Color("black"));
magick_wrapper img2(image_observed);
write_frame_to_rgb_image(&img2, frame);
#if 0
const Magick::PixelPacket * expected_pixels = image_expected.getConstPixels(0,0, image_expected.columns(), image_expected.rows());
const Magick::PixelPacket * observed_pixels = image_observed.getConstPixels(0,0, image_observed.columns(), image_observed.rows());
for (uint32_t y = 0; y < image_expected.rows(); y++) {
for ( uint32_t x = 0; x < image_expected.columns(); x++) {
compare_colors(
Magick::Color(expected_pixels[image_expected.columns()*y + x]),
Magick::Color(observed_pixels[image_observed.columns()*y + x]),
image_expected.matte(),
image_observed.matte()
);
}
}
#endif
image_observed.write("testing/integration_testing/test_data/output/observed_image_via_" + fmt_name + ".png");
}
TEST_P(ImageMagickWrapperTest, ReadWriteStoreImage) {
read_write_store_image(GetParam());
}
INSTANTIATE_TEST_CASE_P(, ImageMagickWrapperTest, ::testing::ValuesIn(Resources::get().get_all_formats()));
TEST_F(ImageMagickWrapperTest, MinimalTest) {
::conversion_matrix conversion_matrix = Resources::get().config().get_conversion_matrix("bt601");
// Prepare a single pixel value.
Magick::ColorRGB expected_color;
expected_color.red( 0.333 );
expected_color.green( 0.653 );
expected_color.blue( 0.80 );
expected_color.alpha(0.5);
// Prepare a simple image.
Magick::Image image_expected(Magick::Geometry(1,1,0,0), expected_color);
// Activate alpha.
image_expected.matte(true);
// Set once more after activating alpha
*image_expected.setPixels(0,0,1,1) = expected_color;
image_expected.syncPixels();
// Create a blank image to store the result.
Magick::Image image_observed(Magick::Geometry(1,1,0,0), Magick::Color("black"));
image_observed.matte(true);
// Convert to and from a yuv_image.
const magick_wrapper proxy(image_expected);
yuv_image yuv_representation = rgb_to_yuv_image(proxy, conversion_matrix );
magick_wrapper proxy_out(image_observed);
yuv_image_to_rgb(&proxy_out, yuv_representation, conversion_matrix );
// Compare
Magick::Color observed_color = *Magick::Pixels(image_observed).get(0,0,1,1);
compare_colors(expected_color, observed_color, true, true);
}
| 40.086957
| 149
| 0.699024
|
stian-svedenborg
|
5989ce11965156c45be40c78babf6c10f3f55745
| 153
|
cpp
|
C++
|
Carbonite/Source/Renderer/RTRenderer.cpp
|
Carcass-Project/Carbonite
|
8b0c7be2c730bb2b5c734725fcb480b8b1945205
|
[
"MIT"
] | null | null | null |
Carbonite/Source/Renderer/RTRenderer.cpp
|
Carcass-Project/Carbonite
|
8b0c7be2c730bb2b5c734725fcb480b8b1945205
|
[
"MIT"
] | null | null | null |
Carbonite/Source/Renderer/RTRenderer.cpp
|
Carcass-Project/Carbonite
|
8b0c7be2c730bb2b5c734725fcb480b8b1945205
|
[
"MIT"
] | null | null | null |
#include "PCH.h"
#include "Renderer/RTRenderer.h"
void RTRenderer::initImpl()
{
}
void RTRenderer::deinitImpl()
{
}
void RTRenderer::renderImpl()
{
}
| 10.2
| 32
| 0.699346
|
Carcass-Project
|
598bd82ab625adf95d988a51bba1be1e90e94703
| 3,615
|
cpp
|
C++
|
micrOS/micrOS_Storage.cpp
|
becker88/ArduOS
|
cc6a8edba4fed17be871acdbf801937e1d55a960
|
[
"MIT"
] | 28
|
2018-01-03T13:09:27.000Z
|
2022-01-18T02:16:06.000Z
|
micrOS/micrOS_Storage.cpp
|
becker88/ArduOS
|
cc6a8edba4fed17be871acdbf801937e1d55a960
|
[
"MIT"
] | 2
|
2019-03-11T04:01:20.000Z
|
2021-04-15T16:01:22.000Z
|
micrOS/micrOS_Storage.cpp
|
becker88/ArduOS
|
cc6a8edba4fed17be871acdbf801937e1d55a960
|
[
"MIT"
] | 6
|
2018-03-20T13:49:10.000Z
|
2021-07-12T13:14:34.000Z
|
//
// micrOS Storage Media System
//
#include <SPI.h>
#include <SD.h>
#include "micrOS_Storage.h"
#include "kernel.h"
#include "Kernel_Returns.h"
Sd2Card MicroSD;
SdVolume IOLowLevelVolume;
uint32_t VolumeSize;
//Pin 10 for MCUFRIEND's SDCard! Change accordingly.
kern_return_t initialize_storage_driver() {
pinMode(10, OUTPUT);
digitalWrite(10, HIGH);
if (!SD.begin(10, 11, 12, 13)) {
#ifdef EMILY_KERN_DEBUG
Serial.println(F("Failed to initialize the card"));
#endif
return KERN_FAILURE; //We failed...
}
else {
if (getStorageMediaDevice() == KERN_SUCCESS) {
return KERN_SUCCESS; //Yay
}
return KERN_FAILURE;
}
}
struct Device LowLevelDeviceProviderForIO;
kern_return_t getStorageMediaDevice() {
while (!MicroSD.init(SPI_HALF_SPEED, 10, 11, 12, 13)) {
#ifdef EMILY_KERN_DEBUG
Serial.println(F("Failed to initialize the card, please make sure it is plugged in, and the Chip Select is properly specified!"));
#endif
return KERN_FAILURE;
}
switch (MicroSD.type()) {
case SD_CARD_TYPE_SD1:
strcpy(LowLevelDeviceProviderForIO.device_type, "SD1");
break;
case SD_CARD_TYPE_SD2:
strcpy(LowLevelDeviceProviderForIO.device_type, "SD2");
break;
case SD_CARD_TYPE_SDHC:
strcpy(LowLevelDeviceProviderForIO.device_type, "SDHC");
break;
default:
strcpy(LowLevelDeviceProviderForIO.device_type, "NIL");
return KERN_FAILURE;
}
if (IOLowLevelVolume.init(MicroSD)) {
LowLevelDeviceProviderForIO.device_initialized = true;
}
else {
#ifdef EMILY_KERN_DEBUG
Serial.println("SD Card Type is not available");
#endif
return KERN_FAILURE;
}
LowLevelDeviceProviderForIO.volumeType = 1;
LowLevelDeviceProviderForIO.volumeTypeDec = IOLowLevelVolume.fatType();
VolumeSize = IOLowLevelVolume.blocksPerCluster(); // Clusters = a collection of blocks
VolumeSize *= IOLowLevelVolume.clusterCount(); // Clusterfuck
VolumeSize /= 2; // SD card => 512 bytes
LowLevelDeviceProviderForIO.volumeSizeInKB = VolumeSize;
LowLevelDeviceProviderForIO.volumeSizeInGB = (float)VolumeSize / 1e+6;
LowLevelDeviceProviderForIO.BlocksCount = IOLowLevelVolume.blocksPerCluster() * IOLowLevelVolume.clusterCount();
#ifdef EMILY_KERN_DEBUG
Serial.println("[storagemediad] SD Card initialized.");
Serial.print("[storagemediad] Mounted Storage Media type: ");
Serial.println(LowLevelDeviceProviderForIO.device_type);
Serial.print("[storagemediad] Partition Style: FAT");
Serial.println(LowLevelDeviceProviderForIO.volumeTypeDec);
Serial.print("[storagemediad] Volume size: ");
Serial.print(LowLevelDeviceProviderForIO.volumeSizeInKB);
Serial.println(" Kilobytes");
Serial.print("[storagemediad] Volume size: ");
Serial.print(LowLevelDeviceProviderForIO.volumeSizeInGB);
Serial.println(" Gigabytes");
Serial.print("[storagemediad] Clusters: ");
Serial.println(IOLowLevelVolume.clusterCount());
Serial.print("[storagemediad] Blocks per cluster: ");
Serial.println(LowLevelDeviceProviderForIO.BlocksCount);
#endif
return KERN_SUCCESS;
}
kern_return_t eraseStorageMediaAtPath() {
uint32_t const ERASE_SIZE = 262144L;
uint32_t firstBlock = 0;
uint32_t lastBlock;
uint16_t walk = 0;
do {
lastBlock = firstBlock + ERASE_SIZE - 1;
if (lastBlock >= MicroSD.cardSize()) lastBlock = MicroSD.cardSize() - 1;
if (!MicroSD.erase(firstBlock, lastBlock)) {
#ifdef EMILY_KERN_DEBUG
Serial.println(F("[StorageMediad] Failed to format SD card!"));
#endif
return KERN_FAILURE;
}
if ((walk++) % 32 == 31);
firstBlock += ERASE_SIZE;
} while (firstBlock < MicroSD.cardSize());
return KERN_SUCCESS;
}
| 32.276786
| 132
| 0.745228
|
becker88
|
598c7c2cf3545ce826693e3f12356080aa8da4d6
| 2,519
|
cpp
|
C++
|
Piscines/CPP/day04/ex00/Sorcerer.cpp
|
SpeedFireSho/42-1
|
5d7ce17910794a28ca44d937651b961feadcff11
|
[
"MIT"
] | 84
|
2020-10-13T14:50:11.000Z
|
2022-01-11T11:19:36.000Z
|
Piscines/CPP/day04/ex00/Sorcerer.cpp
|
SpeedFireSho/42-1
|
5d7ce17910794a28ca44d937651b961feadcff11
|
[
"MIT"
] | null | null | null |
Piscines/CPP/day04/ex00/Sorcerer.cpp
|
SpeedFireSho/42-1
|
5d7ce17910794a28ca44d937651b961feadcff11
|
[
"MIT"
] | 43
|
2020-09-10T19:26:37.000Z
|
2021-12-28T13:53:55.000Z
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Sorcerer.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jaleman <jaleman@student.42.us.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/07/08 21:28:35 by jaleman #+# #+# */
/* Updated: 2017/07/08 21:28:36 by jaleman ### ########.fr */
/* */
/* ************************************************************************** */
#include "Sorcerer.hpp"
/*
** Constructors
*/
Sorcerer::Sorcerer(void)
{
this->_name = "Bella";
this->_title = "la Sopla Vela";
std::cout << this->_name << ", " << this->_title << ", is born !" \
<< std::endl;
return ;
}
Sorcerer::Sorcerer(const Sorcerer &src)
{
*this = src;
return ;
}
Sorcerer::Sorcerer(std::string name, std::string title)
{
this->_name = name;
this->_title = title;
std::cout << this->_name << ", " << this->_title << ", is born !" \
<< std::endl;
return ;
}
/*
** Destructors
*/
Sorcerer::~Sorcerer(void)
{
std::cout << this->_name << ", " << this->_title \
<< ", is dead. Consequences will never be the same !" \
<< std::endl;
return ;
}
/*
** Operators
*/
Sorcerer
&Sorcerer::operator= (const Sorcerer &rhs)
{
if (this != &rhs)
{
this->_name = rhs._name;
this->_title = rhs._title;
}
return (*this);
}
std::ostream
&operator<< (std::ostream &out, const Sorcerer &rhs)
{
out << "I am " << rhs.getName() << ", " << rhs.getTitle() \
<< ", and I like ponies ! " << std::endl;
return (out);
}
/*
** Set methods
*/
void
Sorcerer::setName(std::string name)
{
this->_name = name;
return ;
}
void
Sorcerer::setTitle(std::string title)
{
this->_title = title;
return ;
}
void
Sorcerer::polymorph(const Victim &victim) const
{
return (victim.getPolymorphed());
}
/*
** Get methods
*/
std::string
Sorcerer::getName(void) const
{
return (this->_name);
}
std::string
Sorcerer::getTitle(void) const
{
return (this->_title);
}
| 21.529915
| 80
| 0.39738
|
SpeedFireSho
|
598e4c4f2f87aceec61ba7fff8959248caaef759
| 2,450
|
cpp
|
C++
|
Source/StateMachine.cpp
|
ace13/MiniLD57
|
5035d6b19eac1bfc5b6289790286713274247375
|
[
"MIT"
] | null | null | null |
Source/StateMachine.cpp
|
ace13/MiniLD57
|
5035d6b19eac1bfc5b6289790286713274247375
|
[
"MIT"
] | null | null | null |
Source/StateMachine.cpp
|
ace13/MiniLD57
|
5035d6b19eac1bfc5b6289790286713274247375
|
[
"MIT"
] | null | null | null |
#include "StateMachine.hpp"
using namespace Revertris;
StateMachine::StateMachine() :
mStateSwitch(new osg::Switch), mCurState(nullptr), mCurStateID(IState::None)
{
}
StateMachine::~StateMachine()
{
for (auto& state : mStateMap)
{
mStateSwitch->removeChild(state.second->getScene());
delete state.second;
}
}
bool StateMachine::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, osg::Object* obj, osg::NodeVisitor* nv)
{
return (mCurState && mCurState->handle(ea, aa, obj, nv));
}
void StateMachine::addState(IState* st)
{
IState::State name = st->getState();
if (mStateMap.count(name) > 0)
{
OSG_FATAL << "Trying to add state " << name << " twice!" << std::endl;
throw std::runtime_error("Adding duplicate state.");
}
if (!st)
{
OSG_FATAL << "Adding null state!" << std::endl;
throw std::runtime_error("Adding null state.");
}
mStateMap[name] = st;
mStateSwitch->addChild(st->getScene());
st->init();
}
void StateMachine::removeState(IState::State name)
{
if (mStateMap.count(name) == 0)
{
OSG_WARN << "Trying to remove nonexistant state, ignoring." << std::endl;
return;
}
auto& state = mStateMap[name];
mStateSwitch->removeChild(state->getScene());
mStateMap.erase(name);
delete state;
}
IState* StateMachine::operator[](IState::State name) const
{
if (mStateMap.count(name) == 0)
return nullptr;
return mStateMap.at(name);
}
void StateMachine::setCurState(IState::State name)
{
if (mStateMap.count(name) == 0)
{
OSG_WARN << "Changing to nonexistant state, acting as if State_None." << std::endl;
name = IState::None;
}
if (name == IState::None)
{
mStateSwitch->setAllChildrenOff();
mCurState = nullptr;
mCurStateID = name;
return;
}
auto& state = mStateMap[name];
mStateSwitch->setSingleChildOn(mStateSwitch->getChildIndex(state->getScene()));
mCurState = state;
mCurStateID = name;
}
IState* StateMachine::getCurState() const
{
return mCurState;
}
IState::State StateMachine::getCurStateID() const
{
return mCurStateID;
}
osg::Node* StateMachine::getScene() const
{
return mStateSwitch.get();
}
StateMachine* StateMachine::getInstance()
{
static osg::ref_ptr<StateMachine> sMachine = new StateMachine;
return sMachine.get();
}
| 21.875
| 128
| 0.638776
|
ace13
|
5993def22438b5b9a35d42f54316932460699f12
| 8,740
|
cpp
|
C++
|
examples/002-readme-examples/example.cpp
|
MichaelTrikergiotis/mtl-examples
|
ac95c85a7d73847a2331da8b54e382b23d8f0a05
|
[
"MIT"
] | 2
|
2021-01-10T13:55:24.000Z
|
2021-09-02T17:07:55.000Z
|
examples/002-readme-examples/example.cpp
|
MichaelTrikergiotis/mtl-examples
|
ac95c85a7d73847a2331da8b54e382b23d8f0a05
|
[
"MIT"
] | null | null | null |
examples/002-readme-examples/example.cpp
|
MichaelTrikergiotis/mtl-examples
|
ac95c85a7d73847a2331da8b54e382b23d8f0a05
|
[
"MIT"
] | null | null | null |
// various examples from the readme.md of mtl by Michael Trikergiotis
// 15/11/2020
//
// These examples are taken from the readme.md of mtl :
// https://github.com/MichaelTrikergiotis/mtl
//
// Copyright (c) Michael Trikergiotis. All Rights Reserved.
// Licensed under the MIT license. See LICENSE in the project root for license information.
// C++ standard library headers we have to include
#include <string> // std::string
#include <vector> // std::vector
#include <cmath> // std::sqrt, std::pow
#include <cstdlib> // std::exit
// mtl headers we have to include
#include "../mtl/string.hpp" // mtl::string::split, mtl::string::join_all, mtl::string::join
#include "../mtl/console.hpp" // mtl::console::println, mtl::console::print
#include "../mtl/random.hpp" // mtl::rng
#include "../mtl/stopwatch.hpp" // mtl::chrono::stopwatch
#include "../mtl/filesystem.hpp" // mtl::filesystem::write_all_lines,
// mtl::filesystem::read_all_lines
// How to split an std::string using the mtl.
void example_1()
{
const std::string names = "Joe, Jill, Bill, Nick, Maria, Helen";
// split an std::string to tokens by the given delimiter
std::vector<std::string> tokens = mtl::string::split(names, ", ");
// check the result is what we want
std::vector<std::string> desired_result { "Joe", "Jill", "Bill", "Nick", "Maria", "Helen" };
if(tokens == desired_result)
{
// mtl::console::println can print one or more arguments of various types to the console
// with each argument on a new line
mtl::console::println("Example 1 produced correct results.");
}
else
{
mtl::console::println("Error. Example 1 produced incorrect results!!!");
}
}
// How to join multiple elements of a container to an std::string using the mtl.
void example_2()
{
const std::vector<std::string> tokens { "Joe", "Jill", "Bill", "Nick", "Maria", "Helen" };
// join all elements of a container to an std::string each seperate with a delimiter
std::string joined_names = mtl::string::join_all(tokens.begin(), tokens.end(), ", ");
// check the result is what we want
const std::string names = "Joe, Jill, Bill, Nick, Maria, Helen";
if(joined_names == names)
{
mtl::console::println("Example 2 produced correct results.");
}
else
{
mtl::console::println("Error. Example 2 produced incorrect results!!!");
}
}
// How to join variables of different types and then print them to console.
void example_3()
{
const std::string planet = " planet ";
// join multiple different types of arguments to an std::string
std::string message = mtl::string::join("Hello from ", 'a', planet, 12.24f,
" light-years away.");
// mtl::console::println can print one or more arguments of various types to the console with
// each argument on a new line
mtl::console::println(message);
// mtl::console::print can print one or more arguments of various types to the console,
// this will produce the same output as the lines above but please note for that to happen the
// last argument here is a newline character
mtl::console::print("Hello from ", 'a', planet, 12.24f, " light-years away.", '\n');
// check the result is what we want
const std::string desired_result = "Hello from a planet 12.24 light-years away.";
if(message == desired_result)
{
mtl::console::println("Example 3 produced correct results.");
}
else
{
mtl::console::println("Error. Example 3 produced incorrect results!!!");
}
}
// How to generate a random number between 1 and 10 using the mtl.
void example_4()
{
// create a random number generator that will generate integers from 1 to 10
mtl::rng<int> random_num_gen (1, 10);
// generate a new random integer from 1 to 10
int random_number = random_num_gen.next();
// check the result is what we want
if((random_number >= 1) && ( random_number <= 10))
{
mtl::console::println("Example 4 produced correct results.");
}
else
{
mtl::console::println("Error. Example 4 produced incorrect results!!!");
}
}
// Just create a function that takes some time to finish.
void my_super_slow_function()
{
size_t size = 1000000;
mtl::console::println("Started some math calculations to simulate a slow function.");
std::vector<double> numbers;
for(size_t i = 0; i < size; i++)
{
// perform some expensive math functions
double number = std::sqrt(std::pow(std::sqrt(static_cast<double>(i + 10)), 1.01));
numbers.push_back(number);
}
mtl::console::println("Finished math calculations to simulate a slow function.");
}
// How to time a function with a stopwatch using the mtl.
void example_5()
{
// create a stopwatch
mtl::chrono::stopwatch sw;
// start the stopwatch
sw.start();
// call the function we want to measure
my_super_slow_function();
// stop the stopwatch
sw.stop();
// get the elapsed time in microseconds, there are also functions that allow you to get the
// elapsed time in nanoseconds, milliseconds, seconds and minutes
// the non-Unicode shorthand for microseconds is us
double time_taken_us = sw.elapsed_micro();
mtl::console::print("my_super_slow_function() finished execution in ", time_taken_us,
" microseconds.\n");
// check the result is what we want
if(time_taken_us > 100.0)
{
mtl::console::println("Example 5 produced correct results.");
}
else
{
mtl::console::println("Error. Example 5 produced incorrect results!!!");
}
}
// How to write the elements of a container each on a newline of a file and how to read all lines
// from a file using the mtl.
void example_6()
{
const std::vector<std::string> countries { "Italy", "Brazil", "Greece", "Japan" };
// write all elements of the container each on a new line
bool written_ok = mtl::filesystem::write_all_lines("countries.txt", countries.begin(),
countries.end());
// check that we could write the file correctly
if(written_ok)
{
mtl::console::println("The file was written correctly for example 6.");
}
// if we couldn't write the file print an error message and exit
else
{
mtl::console::println("Error. Couldn't write to file. Exiting.");
std::exit(1);
}
std::vector<std::string> read_countries;
// read all lines of a file to a container, the container element type has to be std::string
bool read_ok = mtl::filesystem::read_all_lines("countries.txt", read_countries);
// check that we could read the file correctly and also the result is what we want
if (read_ok)
{
mtl::console::println("The file was read correctly for example 6.");
if(countries == read_countries)
{
mtl::console::println("Example 6 produced correct results.");
}
else
{
mtl::console::println("Error. Example 6 produced incorrect results!!!");
}
}
else
{
mtl::console::println("Error. The file for example 6 was not read correctly!!!");
}
}
int main()
{
// print the examples with dividers between them.
mtl::console::println("-----------");
mtl::console::println("[EXAMPLE 1]");
mtl::console::println("-----------");
example_1();
mtl::console::println("\n===============================================\n");
mtl::console::println("-----------");
mtl::console::println("[EXAMPLE 2]");
mtl::console::println("-----------");
example_2();
mtl::console::println("\n===============================================\n");
mtl::console::println("-----------");
mtl::console::println("[EXAMPLE 3]");
mtl::console::println("-----------");
example_3();
mtl::console::println("\n===============================================\n");
mtl::console::println("-----------");
mtl::console::println("[EXAMPLE 4]");
mtl::console::println("-----------");
example_4();
mtl::console::println("\n===============================================\n");
mtl::console::println("-----------");
mtl::console::println("[EXAMPLE 5]");
mtl::console::println("-----------");
example_5();
mtl::console::println("\n===============================================\n");
mtl::console::println("-----------");
mtl::console::println("[EXAMPLE 6]");
mtl::console::println("-----------");
example_6();
}
| 35.384615
| 98
| 0.602746
|
MichaelTrikergiotis
|
59954831f182d90c0a5167004023c917d1ea6b0f
| 2,566
|
hpp
|
C++
|
include/Nazara/Shader/Ast/IndexRemapperVisitor.hpp
|
jayrulez/NazaraEngine
|
e0310cd141f3cc11dbe8abfd5bfedf6b61de1a99
|
[
"BSD-3-Clause-Clear",
"Apache-2.0",
"MIT"
] | null | null | null |
include/Nazara/Shader/Ast/IndexRemapperVisitor.hpp
|
jayrulez/NazaraEngine
|
e0310cd141f3cc11dbe8abfd5bfedf6b61de1a99
|
[
"BSD-3-Clause-Clear",
"Apache-2.0",
"MIT"
] | null | null | null |
include/Nazara/Shader/Ast/IndexRemapperVisitor.hpp
|
jayrulez/NazaraEngine
|
e0310cd141f3cc11dbe8abfd5bfedf6b61de1a99
|
[
"BSD-3-Clause-Clear",
"Apache-2.0",
"MIT"
] | null | null | null |
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
// This file is part of the "Nazara Engine - Shader module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_SHADER_AST_INDEXREMAPPERVISITOR_HPP
#define NAZARA_SHADER_AST_INDEXREMAPPERVISITOR_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Shader/Config.hpp>
#include <Nazara/Shader/Ast/AstCloner.hpp>
#include <functional>
namespace Nz::ShaderAst
{
class NAZARA_SHADER_API IndexRemapperVisitor : public AstCloner
{
public:
struct Callbacks;
IndexRemapperVisitor() = default;
IndexRemapperVisitor(const IndexRemapperVisitor&) = delete;
IndexRemapperVisitor(IndexRemapperVisitor&&) = delete;
~IndexRemapperVisitor() = default;
StatementPtr Clone(Statement& statement, const Callbacks& callbacks);
IndexRemapperVisitor& operator=(const IndexRemapperVisitor&) = delete;
IndexRemapperVisitor& operator=(IndexRemapperVisitor&&) = delete;
struct Callbacks
{
std::function<std::size_t(std::size_t previousIndex)> aliasIndexGenerator;
std::function<std::size_t(std::size_t previousIndex)> constIndexGenerator;
std::function<std::size_t(std::size_t previousIndex)> funcIndexGenerator;
std::function<std::size_t(std::size_t previousIndex) > structIndexGenerator;
//std::function<std::size_t()> typeIndexGenerator;
std::function<std::size_t(std::size_t previousIndex)> varIndexGenerator;
};
private:
StatementPtr Clone(DeclareAliasStatement& node) override;
StatementPtr Clone(DeclareConstStatement& node) override;
StatementPtr Clone(DeclareExternalStatement& node) override;
StatementPtr Clone(DeclareFunctionStatement& node) override;
StatementPtr Clone(DeclareStructStatement& node) override;
StatementPtr Clone(DeclareVariableStatement& node) override;
ExpressionPtr Clone(AliasValueExpression& node) override;
ExpressionPtr Clone(ConstantExpression& node) override;
ExpressionPtr Clone(FunctionExpression& node) override;
ExpressionPtr Clone(StructTypeExpression& node) override;
ExpressionPtr Clone(VariableValueExpression& node) override;
void HandleType(ExpressionValue<ExpressionType>& exprType);
ExpressionType RemapType(const ExpressionType& exprType);
struct Context;
Context* m_context;
};
inline StatementPtr RemapIndices(Statement& statement, const IndexRemapperVisitor::Callbacks& callbacks);
}
#include <Nazara/Shader/Ast/IndexRemapperVisitor.inl>
#endif // NAZARA_SHADER_AST_INDEXREMAPPERVISITOR_HPP
| 37.188406
| 106
| 0.788387
|
jayrulez
|
5998b3a0017d2a611026b3955755b81fb6d169dc
| 4,291
|
cpp
|
C++
|
Equipment.cpp
|
b4naser/Emberrain
|
c49d42208ed65c8950687315988ae6ba63552782
|
[
"MIT"
] | null | null | null |
Equipment.cpp
|
b4naser/Emberrain
|
c49d42208ed65c8950687315988ae6ba63552782
|
[
"MIT"
] | null | null | null |
Equipment.cpp
|
b4naser/Emberrain
|
c49d42208ed65c8950687315988ae6ba63552782
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <iomanip>
#include <Windows.h>
#include "Equipment.h"
using namespace std;
Equipment::Equipment()
{
this->weapon = new Weapon();
this->shield = new Shield();
this->armor = new Armor();
this->boots = new Boots();
this->crystals = 0;
}
int Equipment::getDefense() const
{
return this->shield->getDefenseValue() + this->armor->getDefenseValue() + this->boots->getDefenseValue();
}
int Equipment::getEnergy() const
{
return this->shield->getAddEnergyValue();
}
int Equipment::getAttack() const
{
return this->weapon->getAttackValue();
}
int Equipment::getDodgeRate() const
{
return this->boots->getAddDodgeRateValue();
}
int Equipment::getHp() const
{
return this->armor->getAddHpValue();
}
int Equipment::getCrystals() const
{
return crystals;
}
void Equipment::addCrystals(int x)
{
this->crystals += x;
}
void Equipment::subCrystals(int x)
{
this->crystals -= x;
}
void Equipment::show()
{
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
COORD cursorPos{25, 5};
SetConsoleCursorPosition(hConsole, cursorPos);
SetConsoleTextAttribute(hConsole, 12);
cout << "Krysztaly: " << this->getCrystals();
cursorPos.Y += 2;
SetConsoleCursorPosition(hConsole, cursorPos);
SetConsoleTextAttribute(hConsole, 3);
cout << "Miecz____________ Koszt ulepszenia: " << this->weapon->getLevel() * 20;
SetConsoleTextAttribute(hConsole, 7);
cursorPos.Y += 1;
SetConsoleCursorPosition(hConsole, cursorPos);
cout << "Atak: " << weapon->getAttackValue();
cursorPos.Y += 2;
SetConsoleCursorPosition(hConsole, cursorPos);
SetConsoleTextAttribute(hConsole, 3);
cout << "Zbroja___________ Koszt ulepszenia: " << this->armor->getLevel() * 20;
SetConsoleTextAttribute(hConsole, 7);
cursorPos.Y += 1;
SetConsoleCursorPosition(hConsole, cursorPos);
cout << "Obrona: " << armor->getDefenseValue();
cursorPos.Y += 1;
SetConsoleCursorPosition(hConsole, cursorPos);
cout << "Zdrowie: " << armor->getAddHpValue();
cursorPos.Y += 2;
SetConsoleCursorPosition(hConsole, cursorPos);
SetConsoleTextAttribute(hConsole, 3);
cout << "Tarcza___________ Koszt ulepszenia: " << this->shield->getLevel() * 20;
SetConsoleTextAttribute(hConsole, 7);
cursorPos.Y += 1;
SetConsoleCursorPosition(hConsole, cursorPos);
cout << "Obrona: " << shield->getDefenseValue();
cursorPos.Y += 1;
SetConsoleCursorPosition(hConsole, cursorPos);
cout << "Energia: " << shield->getAddEnergyValue();
cursorPos.Y += 2;
SetConsoleCursorPosition(hConsole, cursorPos);
SetConsoleTextAttribute(hConsole, 3);
cout << "Buty_____________ Koszt ulepszenia: " << this->boots->getLevel() * 20;
SetConsoleTextAttribute(hConsole, 7);
cursorPos.Y += 1;
SetConsoleCursorPosition(hConsole, cursorPos);
cout << "Obrona: " << boots->getDefenseValue();
cursorPos.Y += 1;
SetConsoleCursorPosition(hConsole, cursorPos);
cout << "Unik: " << boots->getAddDodgeRateValue();
SetConsoleTextAttribute(hConsole, 15);
cursorPos.Y += 2;
SetConsoleCursorPosition(hConsole, cursorPos);
cout << "z: Ulepsz miecz";
cursorPos.Y += 1;
SetConsoleCursorPosition(hConsole, cursorPos);
cout << "x: Ulepsz zbroje";
cursorPos.Y += 1;
SetConsoleCursorPosition(hConsole, cursorPos);
cout << "c: Ulepsz tarcze";
cursorPos.Y += 1;
SetConsoleCursorPosition(hConsole, cursorPos);
cout << "v: Ulepsz buty";
cursorPos.Y += 1;
SetConsoleCursorPosition(hConsole, cursorPos);
cout << "m: Mapa";
}
void Equipment::command(char cmd)
{
switch (cmd)
{
case 'z':
if ((this->getCrystals() - this->weapon->getLevel() * 20) >= 0)
{
this->subCrystals(this->weapon->getLevel() * 20);
this->weapon->upgrade();
}
break;
case 'x':
if ((this->getCrystals() - this->armor->getLevel() * 20) >= 0)
{
this->subCrystals(this->armor->getLevel() * 20);
this->armor->upgrade();
}
break;
case 'c':
if ((this->getCrystals() - this->shield->getLevel() * 20) >= 0)
{
this->subCrystals(this->shield->getLevel() * 20);
this->shield->upgrade();
}
break;
case 'v':
if ((this->getCrystals() - this->boots->getLevel() * 20) >= 0)
{
this->subCrystals(this->boots->getLevel() * 20);
this->boots->upgrade();
}
break;
}
system("cls");
}
Equipment::~Equipment()
{
delete this->weapon;
delete this->shield;
delete this->armor;
delete this->boots;
}
| 25.849398
| 106
| 0.692146
|
b4naser
|
599ca206c324c067f40fef7aa82f8c60ef71be00
| 263
|
hpp
|
C++
|
game/sources/data/zombie_0.png.data.hpp
|
BlackMATov/gba-game
|
3e557c4f90d6d37205511bf704dc33243ef36954
|
[
"MIT"
] | 4
|
2019-01-20T16:10:56.000Z
|
2022-02-16T22:12:58.000Z
|
game/sources/data/zombie_0.png.data.hpp
|
BlackMATov/gba-game
|
3e557c4f90d6d37205511bf704dc33243ef36954
|
[
"MIT"
] | null | null | null |
game/sources/data/zombie_0.png.data.hpp
|
BlackMATov/gba-game
|
3e557c4f90d6d37205511bf704dc33243ef36954
|
[
"MIT"
] | 1
|
2019-01-21T08:50:39.000Z
|
2019-01-21T08:50:39.000Z
|
#pragma once
#include <cstdint>
#include <cstddef>
namespace embedded_data {
extern const std::uint16_t* zombie_0;
extern const std::size_t zombie_0_bytes;
extern const std::uint16_t zombie_0_width;
extern const std::uint16_t zombie_0_height;
}
| 21.916667
| 47
| 0.749049
|
BlackMATov
|
599e90116ee5e4b2b3512e32e5783c5dcf1aff05
| 371
|
cpp
|
C++
|
test-snippets/iterative_fibonacci_series.cpp
|
aditya2000/coding-practice
|
9b425704dd2ccadeb89b51051d0ef7f0642ea334
|
[
"MIT"
] | null | null | null |
test-snippets/iterative_fibonacci_series.cpp
|
aditya2000/coding-practice
|
9b425704dd2ccadeb89b51051d0ef7f0642ea334
|
[
"MIT"
] | null | null | null |
test-snippets/iterative_fibonacci_series.cpp
|
aditya2000/coding-practice
|
9b425704dd2ccadeb89b51051d0ef7f0642ea334
|
[
"MIT"
] | 1
|
2018-10-02T14:27:59.000Z
|
2018-10-02T14:27:59.000Z
|
/*
@author - Naveen Rohilla
Objective : To display fibonacci series upto N
Approach :
iterative approach - displays the element inside the loop
*/
#include<iostream>
using namespace std;
#define N 10
int main()
{
int a=0,b=1,c,i=3;
cout<<a<<" ";
cout<<b<<" ";
do
{
c=a+b;
cout<<c<<" ";
a=b;
b=c;
i++;
}while(i<=N);
return 0;
}
| 12.793103
| 57
| 0.566038
|
aditya2000
|
59a5eeeaf2733780ac6bad5d332816977acc5eef
| 1,921
|
cpp
|
C++
|
Deitel/Chapter17/examples/17.14/ClientData.cpp
|
SebastianTirado/Cpp-Learning-Archive
|
fb83379d0cc3f9b2390cef00119464ec946753f4
|
[
"MIT"
] | 19
|
2019-09-15T12:23:51.000Z
|
2020-06-18T08:31:26.000Z
|
Deitel/Chapter17/examples/17.14/ClientData.cpp
|
eirichan/CppLearingArchive
|
07a4baf63f0765d41eb0cc6d32a4c9d2ae1d5bac
|
[
"MIT"
] | 15
|
2021-12-07T06:46:03.000Z
|
2022-01-31T07:55:32.000Z
|
Deitel/Chapter17/examples/17.14/ClientData.cpp
|
eirichan/CppLearingArchive
|
07a4baf63f0765d41eb0cc6d32a4c9d2ae1d5bac
|
[
"MIT"
] | 13
|
2019-06-29T02:58:27.000Z
|
2020-05-07T08:52:22.000Z
|
/*
* =====================================================================================
*
* Filename:
*
* Description:
*
* Version: 1.0
* Created: Thanks to github you know it
* Revision: none
* Compiler: g++
*
* Author: Mahmut Erdem ÖZGEN m.erdemozgen@gmail.com
*
*
* =====================================================================================
*/
#include "ClientData.hpp"
#include <string>
// default ClientData constructor
ClientData::ClientData(int accountNumberValue, std::string lastNameValue,
std::string firstNameValue, double balanceValue) {
setAccountNumber(accountNumberValue);
setLastName(lastNameValue);
setFirstName(firstNameValue);
setBalance(balanceValue);
}
// get account-number value
int ClientData::getAccountNumber() const { return accountNumber; }
// set account-number value
void ClientData::setAccountNumber(int accountNumberValue) {
accountNumber = accountNumberValue;
}
// get last-name value
std::string ClientData::getLastName() const { return lastName; }
// set last-name value
void ClientData::setLastName(std::string lastNameString) {
// copy at most 15 characters from string to lastName
int length = lastNameString.size();
length = (length < 15 ? length : 14);
lastNameString.copy(lastName, length);
lastName[length] = '\0';
}
// get first-name value
std::string ClientData::getFirstName() const { return firstName; }
// set first-name value
void ClientData::setFirstName(std::string firstNameString) {
int length = firstNameString.size();
length = (length < 10 ? length : 9);
firstNameString.copy(firstName, length);
firstName[length] = '\0';
}
// get balance value
double ClientData::getBalance() const { return balance; }
// set balance value
void ClientData::setBalance(double balanceValue) { balance = balanceValue; }
| 33.12069
| 88
| 0.626757
|
SebastianTirado
|
59a904672270a7b95ba580726acf3ccdc66d7de4
| 3,844
|
cpp
|
C++
|
infra/syntax/XmlFormatter.cpp
|
oguzcanphilips/embeddedinfralib
|
f1b083d61a34d123d34ab7cd51267377aa2f7855
|
[
"Unlicense"
] | 1
|
2021-05-18T07:21:59.000Z
|
2021-05-18T07:21:59.000Z
|
infra/syntax/XmlFormatter.cpp
|
oguzcanphilips/embeddedinfralib
|
f1b083d61a34d123d34ab7cd51267377aa2f7855
|
[
"Unlicense"
] | null | null | null |
infra/syntax/XmlFormatter.cpp
|
oguzcanphilips/embeddedinfralib
|
f1b083d61a34d123d34ab7cd51267377aa2f7855
|
[
"Unlicense"
] | null | null | null |
#include "infra/syntax/XmlFormatter.hpp"
namespace
{
namespace
{
void InsertPredefinedEntity(infra::TextOutputStream& stream, char c)
{
switch (c)
{
case '<': stream << "<"; break;
case '>': stream << ">"; break;
case '&': stream << "&"; break;
case '\'': stream << "'"; break;
case '"': stream << """; break;
}
}
std::tuple<std::size_t, infra::BoundedConstString> NonEscapedSubString(infra::BoundedConstString string, std::size_t start)
{
std::size_t escape = std::min(string.find_first_of("<>&'\"", start), string.size());
infra::BoundedConstString nonEscapedSubString = string.substr(start, escape - start);
for (std::size_t control = start; control != escape; ++control)
if (string[control] < 0x20)
{
escape = control;
nonEscapedSubString = string.substr(start, escape - start);
break;
}
return std::make_tuple(escape, nonEscapedSubString);
}
void InsertEscapedContent(infra::TextOutputStream& stream, infra::BoundedConstString content)
{
std::size_t start = 0;
while (start != content.size())
{
std::size_t escape;
infra::BoundedConstString nonEscapedSubString;
std::tie(escape, nonEscapedSubString) = NonEscapedSubString(content, start);
start = escape;
if (!nonEscapedSubString.empty())
stream << nonEscapedSubString;
if (escape != content.size())
{
InsertPredefinedEntity(stream, content[escape]);
++start;
}
}
}
}
}
namespace infra
{
XmlFormatter::XmlFormatter(infra::TextOutputStream& stream)
: stream(infra::inPlace, stream.Writer(), infra::noFail)
{
*this->stream << R"(<?xml version="1.0" encoding="ISO-8859-1" ?>)";
}
XmlTagFormatter XmlFormatter::Tag(const char* tagName)
{
return XmlTagFormatter(*stream, tagName);
}
XmlTagFormatter::XmlTagFormatter(infra::TextOutputStream& stream, const char* tagName)
: stream(infra::inPlace, stream.Writer(), infra::noFail)
, tagName(tagName)
{
*this->stream << "<" << tagName;
}
XmlTagFormatter::~XmlTagFormatter()
{
if (stream != infra::none)
if (empty)
*stream << " />";
else
*stream << "</" << tagName << ">";
}
XmlTagFormatter::XmlTagFormatter(XmlTagFormatter&& other)
: stream(other.stream)
{
other.stream = infra::none;
}
XmlTagFormatter& XmlTagFormatter::operator=(XmlTagFormatter&& other)
{
stream = other.stream;
other.stream = infra::none;
return *this;
}
void XmlTagFormatter::Attribute(const char* name, infra::BoundedConstString value)
{
*stream << " " << name << R"(=")" << value << R"(")";
}
void XmlTagFormatter::Content(infra::BoundedConstString string)
{
CloseBeginTag();
InsertEscapedContent(*stream, string);
}
XmlTagFormatter XmlTagFormatter::Tag(const char* tagName)
{
CloseBeginTag();
return XmlTagFormatter(*stream, tagName);
}
void XmlTagFormatter::Element(const char* tagName, infra::BoundedConstString content)
{
auto element = Tag(tagName);
element.Content(content);
}
void XmlTagFormatter::CloseBeginTag()
{
if (empty)
{
empty = false;
*stream << ">";
}
}
}
| 28.902256
| 131
| 0.53538
|
oguzcanphilips
|
59af58fff525e62140fccf2e54f863764fa7fddb
| 11,497
|
cpp
|
C++
|
src/main.cpp
|
luebbe/WordClock
|
218bf9f626c495f690b11d11637cbab0b65c284b
|
[
"MIT"
] | 5
|
2020-12-17T20:03:58.000Z
|
2022-01-19T21:57:06.000Z
|
src/main.cpp
|
luebbe/WordClock
|
218bf9f626c495f690b11d11637cbab0b65c284b
|
[
"MIT"
] | null | null | null |
src/main.cpp
|
luebbe/WordClock
|
218bf9f626c495f690b11d11637cbab0b65c284b
|
[
"MIT"
] | null | null | null |
#include <FastLED.h>
#include <ESP8266WiFi.h>
#include <Ticker.h>
#include <AsyncMqttClient.h>
#include <BH1750.h>
#include "OtaHelper.h"
#include "TimeHelper.h"
#include "WordClock.h"
#include "StatusAnimation.h"
#include "SnakeAnimation.h"
#include "RainbowAnimation.h"
#include "ArduinoBorealis.h"
#include "MatrixAnimation.h"
#include "debugutils.h"
#include "secrets.h"
#include "..\include\Version.h"
// #define DEBUG
#define FW_NAME "Word Clock"
#define FW_VERSION VERSION
#define FW_DATE BUILD_TIMESTAMP
#define PIN_LED D1 // on D1 Mini
#define PIN_SDA D6 // on D1 Mini
#define PIN_SCL D7 // on D1 Mini
#define PIN_ADC A0 // on D1 Mini
#define COLOR_ORDER GRB
#define CHIPSET WS2812
// LED matrix of 11x10 pixels with 0,0 at the bottom left
// The matrix has to be the *first* section of the LED chain, because of the "safety pixel"
#define MATRIX_WIDTH 11
#define MATRIX_HEIGHT 10
// Minimum and initial brightness for LEDs
#define BRIGHTNESS 20
// Observed maximum daylight lux values around noon. Adjust this to the light levels at your clock's location.
// The LEDs will reach maximum brightness at this lux level and above.
#define DAYLIGHT_LUX 2500
#define SEND_STATS_INTERVAL 60000UL // Send stats every 60 seconds
#define SEND_LIGHT_INTERVAL 5000UL // Send light level every 5 seconds
#define CHECK_LIGHT_INTERVAL 50UL // Check light level 20 times per second
// Params for width, height and number of extra LEDs are defined in WordClock.h
#define NUM_LEDS (MATRIX_WIDTH * MATRIX_HEIGHT) + MINUTE_LEDS + SECOND_LEDS
#define FIRST_MINUTE (MATRIX_WIDTH * MATRIX_HEIGHT)
CRGB leds_plus_safety_pixel[NUM_LEDS + 1]; // The first pixel in this array is the safety pixel for "out of bounds" results. Never use this array directly!
CRGB *const leds(leds_plus_safety_pixel + 1); // This is the "off-by-one" array that we actually work with and which is passed to FastLED!
LedMatrix ledMatrix(MATRIX_WIDTH, MATRIX_HEIGHT);
LedEffect *_ledEffect = nullptr;
BH1750 lightMeter;
OtaHelper otaHelper(&ledMatrix, leds, NUM_LEDS);
StatusAnimation statusAnimation(&ledMatrix, leds, NUM_LEDS);
SnakeAnimation snakeAnimation(&ledMatrix, leds, NUM_LEDS);
WordClock wordClock(&ledMatrix, leds, NUM_LEDS, onGetTime);
RainbowAnimation rainbowAnimation(&ledMatrix, leds, NUM_LEDS);
BorealisAnimation borealisAnimation(&ledMatrix, leds, NUM_LEDS);
MatrixAnimation matrixAnimation(&ledMatrix, leds, NUM_LEDS);
WiFiEventHandler wifiConnectHandler;
WiFiEventHandler wifiDisconnectHandler;
Ticker wifiReconnectTimer;
AsyncMqttClient mqttClient;
Ticker mqttReconnectTimer;
uint8_t _displayMode = 0;
bool _modeChanged = false;
ulong _lastStatsSent = 0;
ulong _lastLightLevelCheck = 0;
ulong _lastLightSent = 0;
float _lux = NAN;
byte _mtReg = 0;
Uptime _uptime;
Uptime _uptimeMqtt;
Uptime _uptimeWifi;
#ifdef DEBUG
#define cMqttPrefix "wordclockdebug/"
#else
#define cMqttPrefix "wordclock/"
#endif
// Status
#define cIpTopic cMqttPrefix "$localip"
#define cMacTopic cMqttPrefix "$mac"
#define cStateTopic cMqttPrefix "$state"
#define cFirmwareTopic cMqttPrefix "$fw/"
#define cFirmwareName cFirmwareTopic "name"
#define cFirmwareVersion cFirmwareTopic "version"
#define cFirmwareDate cFirmwareTopic "date"
// Statistics
#define cStatsTopic cMqttPrefix "$stats/"
#define cSignalTopic cStatsTopic "signal"
#define cHeapTopic cStatsTopic "freeheap"
#define cUptimeTopic cStatsTopic "uptime"
#define cUptimeWifiTopic cStatsTopic "uptimewifi"
#define cUptimeMqttTopic cStatsTopic "uptimemqtt"
// Operation mode
#define cLightlevelTopic cMqttPrefix "lightlevel"
#define cBrightnessTopic cMqttPrefix "brightness"
#define cModeTopic cMqttPrefix "mode"
#define cModeSetTopic cMqttPrefix "mode/set"
void sendState()
{
DEBUG_PRINTLN("Sending State");
mqttClient.publish(cBrightnessTopic, 1, true, String(FastLED.getBrightness()).c_str());
mqttClient.publish(cModeTopic, 1, true, String(_displayMode).c_str());
mqttClient.publish(cLightlevelTopic, 1, true, String(_lux).c_str());
}
void sendStats()
{
DEBUG_PRINTLN("Sending Statistics");
mqttClient.publish(cSignalTopic, 1, true, String(WiFi.RSSI()).c_str());
mqttClient.publish(cHeapTopic, 1, true, String(ESP.getFreeHeap()).c_str());
_uptime.update();
_uptimeWifi.update();
_uptimeMqtt.update();
char statusStr[20 + 1];
itoa(_uptime.getSeconds(), statusStr, 10);
mqttClient.publish(cUptimeTopic, 1, true, statusStr);
itoa(_uptimeWifi.getSeconds(), statusStr, 10);
mqttClient.publish(cUptimeWifiTopic, 1, true, statusStr);
itoa(_uptimeMqtt.getSeconds(), statusStr, 10);
mqttClient.publish(cUptimeMqttTopic, 1, true, statusStr);
}
void setMode(uint8_t mode)
{
DEBUG_PRINTLN("Set Mode");
if ((mode <= 255) && (mode != _displayMode))
{
_displayMode = mode;
_modeChanged = true;
FastLED.clear(true);
DEBUG_PRINTF("=%d\r\n", _displayMode);
switch (_displayMode)
{
case 0:
_ledEffect = &wordClock;
break;
case 1:
_ledEffect = &rainbowAnimation;
break;
case 2:
_ledEffect = &borealisAnimation;
break;
case 3:
_ledEffect = &matrixAnimation;
break;
case 4:
_ledEffect = &snakeAnimation;
break;
default:
_ledEffect = &wordClock;
}
sendState();
}
}
// MQTT connection and event handling
void connectToMqtt()
{
DEBUG_PRINTLN("Connecting to MQTT.");
statusAnimation.setStatus(CLOCK_STATUS::MQTT_DISCONNECTED);
mqttClient.connect();
}
void onMqttConnect(bool sessionPresent)
{
DEBUG_PRINTLN("Connected to MQTT.");
statusAnimation.setStatus(CLOCK_STATUS::MQTT_CONNECTED);
_uptimeMqtt.reset();
_ledEffect = &wordClock;
_modeChanged = true;
mqttClient.subscribe(cModeSetTopic, 1);
mqttClient.publish(cFirmwareName, 1, true, FW_NAME);
mqttClient.publish(cFirmwareVersion, 1, true, FW_VERSION);
mqttClient.publish(cFirmwareDate, 1, true, FW_DATE);
mqttClient.publish(cIpTopic, 1, true, WiFi.localIP().toString().c_str());
mqttClient.publish(cMacTopic, 1, true, WiFi.macAddress().c_str());
mqttClient.publish(cStateTopic, 1, true, "ready");
sendState();
}
void onMqttDisconnect(AsyncMqttClientDisconnectReason reason)
{
DEBUG_PRINTLN("Disconnected from MQTT.");
statusAnimation.setStatus(CLOCK_STATUS::MQTT_DISCONNECTED);
if (WiFi.isConnected())
{
mqttReconnectTimer.once(2, connectToMqtt);
}
}
void onMqttMessage(char *topic, char *payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total)
{
DEBUG_PRINTF("topic: %s: ", topic);
// THIS IS ONLY FOR SHORT PAYLOADS!!!
// payload is in fact byte*, NOT char*!!!
if (index == 0)
{
std::string value;
value.assign((const char *)payload, len);
DEBUG_PRINTF("%s\r\n", value.c_str());
if (strcmp(topic, cModeSetTopic) == 0)
{
setMode(atoi(value.c_str()));
}
}
}
// WiFi connection and event handling
void connectToWifi()
{
DEBUG_PRINTLN("Connecting to Wi-Fi.");
statusAnimation.setStatus(CLOCK_STATUS::WIFI_DISCONNECTED);
WiFi.begin(WIFI_SSID, WIFI_PASS);
}
void onWifiConnect(const WiFiEventStationModeGotIP &event)
{
DEBUG_PRINTLN("Connected to Wi-Fi.");
statusAnimation.setStatus(CLOCK_STATUS::WIFI_CONNECTED);
_uptimeWifi.reset();
connectToMqtt();
// initialize NTP Client after WiFi is connected
timeClient.begin();
}
void onWifiDisconnect(const WiFiEventStationModeDisconnected &event)
{
DEBUG_PRINTLN("Disconnected from Wi-Fi.");
statusAnimation.setStatus(CLOCK_STATUS::WIFI_DISCONNECTED);
mqttReconnectTimer.detach(); // ensure we don't reconnect to MQTT while reconnecting to Wi-Fi
wifiReconnectTimer.once(2, connectToWifi);
}
// Automatic brightness adjustment for LEDs via BH1750 light sensor
void adjustBrightness(float lux)
{
// lux = 1..65535 convert to 1..255
// Limit to observed maximum value.
if (lux > DAYLIGHT_LUX)
{
lux = DAYLIGHT_LUX;
}
// scale to 1..255
uint8_t brightness = round(lux * 255 / DAYLIGHT_LUX);
// never go below the minimal brightness
if (brightness < BRIGHTNESS)
{
brightness = BRIGHTNESS;
}
FastLED.setBrightness(brightness);
}
void setMTreg(uint8_t mtReg)
{
if (_mtReg != mtReg)
{
_mtReg = mtReg;
lightMeter.setMTreg(mtReg);
// if (lightMeter.setMTreg(mtReg))
// {
// // DEBUG_PRINTF("Setting MTReg to %d\r\n", mtReg);
// }
// else
// {
// DEBUG_PRINTF("Error setting MTReg to %d\r\n", mtReg);
// }
}
}
void checkLightLevel()
{
const byte cMtRegBright = 32;
const byte cMtRegTypical = 69;
const byte cMtRegDark = 138;
if (lightMeter.measurementReady(true))
{
_lux = lightMeter.readLightLevel();
// DEBUG_PRINTF("Light: %7.1f lx mtReg=%d\r\n", _lux, _mtReg);
if (_lux < 0)
{
DEBUG_PRINTLN(F("Light: Error condition detected"));
}
else if (_lux > 40000.0)
{
// reduce measurement time - needed in direct sun light
setMTreg(cMtRegBright);
adjustBrightness(_lux);
}
else if (_lux > 10.0)
{
// typical light environment
setMTreg(cMtRegTypical);
adjustBrightness(_lux);
}
else // 0 <= _lux <= 10.0
{
// very low light environment
setMTreg(cMtRegDark);
adjustBrightness(_lux);
}
}
}
void setup()
{
Serial.begin(SERIAL_SPEED);
DEBUG_PRINTLN();
DEBUG_PRINTLN();
Wire.begin(PIN_SDA, PIN_SCL);
lightMeter.begin(BH1750::CONTINUOUS_LOW_RES_MODE); // Run in Low-Res mode to allow faster sampling
FastLED.addLeds<CHIPSET, PIN_LED, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setMaxPowerInVoltsAndMilliamps(5, 2000); // FastLED power management set at 5V, 2A
FastLED.setBrightness(BRIGHTNESS);
FastLED.setDither(BINARY_DITHER);
FastLED.clear(true);
// Initialize random number generator
randomSeed(analogRead(PIN_ADC));
setMode(random(1, 5));
otaHelper.init();
wordClock.init();
wifiConnectHandler = WiFi.onStationModeGotIP(onWifiConnect);
wifiDisconnectHandler = WiFi.onStationModeDisconnected(onWifiDisconnect);
mqttClient.onConnect(onMqttConnect);
mqttClient.onDisconnect(onMqttDisconnect);
mqttClient.onMessage(onMqttMessage);
mqttClient.setServer(MQTT_HOST, MQTT_PORT);
mqttClient.setWill(cStateTopic, 1, true, "lost");
_uptime.reset();
connectToWifi();
}
void loop()
{
bool update = false;
// Do it in two steps in order to always get the overlay if there is one. A simple '||' will skip the second check if the first evaluates to true
if ((_ledEffect && _ledEffect->paint(_modeChanged)))
{
// Reset "force" repaint flag
_modeChanged = false;
update = true;
}
if (statusAnimation.paint(_modeChanged))
{
update = true;
}
if (update)
{
FastLED.show();
}
ulong _millis = millis();
// Check light level 20 times per second
if ((_millis - _lastLightLevelCheck >= CHECK_LIGHT_INTERVAL) || (_lastLightLevelCheck == 0))
{
checkLightLevel();
_lastLightLevelCheck = _millis;
}
if (WiFi.isConnected())
{
if (mqttClient.connected())
{
// Send status every 60 seconds
if ((_millis - _lastStatsSent >= SEND_STATS_INTERVAL) || (_lastStatsSent == 0))
{
sendStats();
_lastStatsSent = _millis;
}
// Send state (brightness/mode) every 5 seconds
if ((_millis - _lastLightSent >= SEND_LIGHT_INTERVAL) || (_lastLightSent == 0))
{
sendState();
_lastLightSent = _millis;
}
}
ArduinoOTA.handle();
}
}
| 26.248858
| 158
| 0.717318
|
luebbe
|
59b580e5b1ec45200b8dea17acf5af09526787e3
| 7,590
|
cpp
|
C++
|
HelperFunctions/populateVkPhysicalDeviceDeviceGeneratedCommandsPropertiesNV.cpp
|
dkaip/jvulkan-natives-Linux-x86_64
|
ea7932f74e828953c712feea11e0b01751f9dc9b
|
[
"Apache-2.0"
] | null | null | null |
HelperFunctions/populateVkPhysicalDeviceDeviceGeneratedCommandsPropertiesNV.cpp
|
dkaip/jvulkan-natives-Linux-x86_64
|
ea7932f74e828953c712feea11e0b01751f9dc9b
|
[
"Apache-2.0"
] | null | null | null |
HelperFunctions/populateVkPhysicalDeviceDeviceGeneratedCommandsPropertiesNV.cpp
|
dkaip/jvulkan-natives-Linux-x86_64
|
ea7932f74e828953c712feea11e0b01751f9dc9b
|
[
"Apache-2.0"
] | null | null | null |
/*
* Copyright 2020 Douglas Kaip
*
* 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.
*/
/*
* populateVkPhysicalDeviceDeviceGeneratedCommandsPropertiesNV.cpp
*
* Created on: Sep 8, 2020
* Author: Douglas Kaip
*/
#include "JVulkanHelperFunctions.hh"
#include "slf4j.hh"
extern const char *voidMethodErrorText;
namespace jvulkan
{
void populateVkPhysicalDeviceDeviceGeneratedCommandsPropertiesNV(
JNIEnv *env,
jobject jVkPhysicalDeviceDeviceGeneratedCommandsPropertiesNVObject,
const VkPhysicalDeviceDeviceGeneratedCommandsPropertiesNV *vkPhysicalDeviceDeviceGeneratedCommandsPropertiesNV)
{
jboolean handlingException = env->ExceptionCheck();
if (handlingException == true)
{
LOGWARN(env, "%s", "handlingException was already true...clearing");
env->ExceptionClear();
}
jclass theClass = env->GetObjectClass(jVkPhysicalDeviceDeviceGeneratedCommandsPropertiesNVObject);
if (env->ExceptionOccurred())
{
LOGERROR(env, "%s", "Could not find class for jVkPhysicalDeviceDeviceGeneratedCommandsPropertiesNVObject");
return;
}
///////////////////////////////////////////////////////////////////////////
jmethodID methodId = env->GetMethodID(theClass, "setMaxGraphicsShaderGroupCount", "(I)V");
if (env->ExceptionOccurred())
{
LOGERROR(env, "%s", "Could not find method id setMaxGraphicsShaderGroupCount");
return;
}
env->CallVoidMethod(jVkPhysicalDeviceDeviceGeneratedCommandsPropertiesNVObject, methodId, vkPhysicalDeviceDeviceGeneratedCommandsPropertiesNV->maxGraphicsShaderGroupCount);
if (env->ExceptionOccurred())
{
LOGERROR(env, "%s", voidMethodErrorText);
return;
}
///////////////////////////////////////////////////////////////////////////
methodId = env->GetMethodID(theClass, "setMaxIndirectSequenceCount", "(I)V");
if (env->ExceptionOccurred())
{
LOGERROR(env, "%s", "Could not find method id setMaxIndirectSequenceCount");
return;
}
env->CallVoidMethod(jVkPhysicalDeviceDeviceGeneratedCommandsPropertiesNVObject, methodId, vkPhysicalDeviceDeviceGeneratedCommandsPropertiesNV->maxIndirectSequenceCount);
if (env->ExceptionOccurred())
{
LOGERROR(env, "%s", voidMethodErrorText);
return;
}
///////////////////////////////////////////////////////////////////////////
methodId = env->GetMethodID(theClass, "setMaxIndirectCommandsTokenCount", "(I)V");
if (env->ExceptionOccurred())
{
LOGERROR(env, "%s", "Could not find method id setMaxIndirectCommandsTokenCount");
return;
}
env->CallVoidMethod(jVkPhysicalDeviceDeviceGeneratedCommandsPropertiesNVObject, methodId, vkPhysicalDeviceDeviceGeneratedCommandsPropertiesNV->maxIndirectCommandsTokenCount);
if (env->ExceptionOccurred())
{
LOGERROR(env, "%s", voidMethodErrorText);
return;
}
///////////////////////////////////////////////////////////////////////////
methodId = env->GetMethodID(theClass, "setMaxIndirectCommandsStreamCount", "(I)V");
if (env->ExceptionOccurred())
{
LOGERROR(env, "%s", "Could not find method id setMaxIndirectCommandsStreamCount");
return;
}
env->CallVoidMethod(jVkPhysicalDeviceDeviceGeneratedCommandsPropertiesNVObject, methodId, vkPhysicalDeviceDeviceGeneratedCommandsPropertiesNV->maxIndirectCommandsStreamCount);
if (env->ExceptionOccurred())
{
LOGERROR(env, "%s", voidMethodErrorText);
return;
}
///////////////////////////////////////////////////////////////////////////
methodId = env->GetMethodID(theClass, "setMaxIndirectCommandsTokenOffset", "(I)V");
if (env->ExceptionOccurred())
{
LOGERROR(env, "%s", "Could not find method id setMaxIndirectCommandsTokenOffset");
return;
}
env->CallVoidMethod(jVkPhysicalDeviceDeviceGeneratedCommandsPropertiesNVObject, methodId, vkPhysicalDeviceDeviceGeneratedCommandsPropertiesNV->maxIndirectCommandsTokenOffset);
if (env->ExceptionOccurred())
{
LOGERROR(env, "%s", voidMethodErrorText);
return;
}
///////////////////////////////////////////////////////////////////////////
methodId = env->GetMethodID(theClass, "setMaxIndirectCommandsStreamStride", "(I)V");
if (env->ExceptionOccurred())
{
LOGERROR(env, "%s", "Could not find method id setMaxIndirectCommandsStreamStride");
return;
}
env->CallVoidMethod(jVkPhysicalDeviceDeviceGeneratedCommandsPropertiesNVObject, methodId, vkPhysicalDeviceDeviceGeneratedCommandsPropertiesNV->maxIndirectCommandsStreamStride);
if (env->ExceptionOccurred())
{
LOGERROR(env, "%s", voidMethodErrorText);
return;
}
///////////////////////////////////////////////////////////////////////////
methodId = env->GetMethodID(theClass, "setMinSequencesCountBufferOffsetAlignment", "(I)V");
if (env->ExceptionOccurred())
{
LOGERROR(env, "%s", "Could not find method id setMinSequencesCountBufferOffsetAlignment");
return;
}
env->CallVoidMethod(jVkPhysicalDeviceDeviceGeneratedCommandsPropertiesNVObject, methodId, vkPhysicalDeviceDeviceGeneratedCommandsPropertiesNV->minSequencesCountBufferOffsetAlignment);
if (env->ExceptionOccurred())
{
LOGERROR(env, "%s", voidMethodErrorText);
return;
}
///////////////////////////////////////////////////////////////////////////
methodId = env->GetMethodID(theClass, "setMinSequencesIndexBufferOffsetAlignment", "(I)V");
if (env->ExceptionOccurred())
{
LOGERROR(env, "%s", "Could not find method id setMinSequencesIndexBufferOffsetAlignment");
return;
}
env->CallVoidMethod(jVkPhysicalDeviceDeviceGeneratedCommandsPropertiesNVObject, methodId, vkPhysicalDeviceDeviceGeneratedCommandsPropertiesNV->minSequencesIndexBufferOffsetAlignment);
if (env->ExceptionOccurred())
{
LOGERROR(env, "%s", voidMethodErrorText);
return;
}
///////////////////////////////////////////////////////////////////////////
methodId = env->GetMethodID(theClass, "setMinIndirectCommandsBufferOffsetAlignment", "(I)V");
if (env->ExceptionOccurred())
{
LOGERROR(env, "%s", "Could not find method id setMinIndirectCommandsBufferOffsetAlignment");
return;
}
env->CallVoidMethod(jVkPhysicalDeviceDeviceGeneratedCommandsPropertiesNVObject, methodId, vkPhysicalDeviceDeviceGeneratedCommandsPropertiesNV->minIndirectCommandsBufferOffsetAlignment);
if (env->ExceptionOccurred())
{
LOGERROR(env, "%s", voidMethodErrorText);
return;
}
}
}
| 41.027027
| 193
| 0.619631
|
dkaip
|
59b5b20a57009407c99ba65835bcc5411304ea88
| 6,642
|
cpp
|
C++
|
ui/ui_cdkey.cpp
|
kugelrund/Elite-Reinforce
|
a2fe0c0480ff2d9cdc241b9e5416ee7f298f00ca
|
[
"DOC"
] | 10
|
2017-07-04T14:38:48.000Z
|
2022-03-08T22:46:39.000Z
|
ui/ui_cdkey.cpp
|
UberGames/SP-Mod-Source-Code
|
04e0e618d1ee57a2919f1a852a688c03b1aa155d
|
[
"DOC"
] | null | null | null |
ui/ui_cdkey.cpp
|
UberGames/SP-Mod-Source-Code
|
04e0e618d1ee57a2919f1a852a688c03b1aa155d
|
[
"DOC"
] | 2
|
2017-04-23T18:24:44.000Z
|
2021-11-19T23:27:03.000Z
|
#include "ui_local.h"
#include "gameinfo.h"
//===================================================================
//
// CDKey Menu
//
//===================================================================
// menu action identifiers
#define ID_MAINMENU 100
#define ID_CONTROLS 101
#define ID_VIDEO 102
#define ID_SOUND 103
#define ID_CDKEY 104
#define ART_FRAME "menu/common/cdkey"
#define ART_WORMHOLE "menu/wormhole/wormhole"
static menuframework_s s_cdkey_menu;
void M_CDKey_Graphics (void)
{
UI_MenuFrame(&s_cdkey_menu);
UI_Setup_MenuButtons();
ui.R_SetColor( colorTable[CT_DKPURPLE2]);
UI_DrawHandlePic(30,203, 47, 121, uis.whiteShader); // Long left hand column square
UI_DrawHandlePic(30,327, 47, 28, uis.whiteShader); // Long left hand column square
UI_DrawHandlePic(30,358, 47, 31, uis.whiteShader); // Long left hand column square
// Numbers for left hand column squares
UI_DrawProportionalString( 73, 206, "ST-181",UI_RIGHT|UI_TINYFONT, colorTable[CT_BLACK]);
UI_DrawProportionalString( 73, 330, "65",UI_RIGHT|UI_TINYFONT, colorTable[CT_BLACK]);
UI_DrawProportionalString( 73, 361, "201",UI_RIGHT|UI_TINYFONT, colorTable[CT_BLACK]);
ui.R_SetColor( colorTable[CT_WHITE]);
UI_DrawNamedPic(97, 160, 512, 256, ART_WORMHOLE);
UI_DrawProportionalString( 611, 165, "WORMHOLE STRUCTURE", UI_RIGHT | UI_SMALLFONT, colorTable[CT_LTORANGE]);
UI_DrawProportionalString( 419, 321, "POINT SINGULARITY", UI_TINYFONT, colorTable[CT_LTORANGE]);
UI_DrawProportionalString( 360, 221, "VERTERONE MEMBRANE", UI_TINYFONT, colorTable[CT_LTORANGE]);
UI_DrawProportionalString( 265, 329, "POSITIVE CTL REGION", UI_TINYFONT, colorTable[CT_LTORANGE]);
UI_DrawProportionalString( 199, 288, "NEGATIVE CTL REGION", UI_TINYFONT, colorTable[CT_LTORANGE]);
UI_DrawProportionalString( 287, 184, "RING SINGULARITY", UI_TINYFONT, colorTable[CT_LTORANGE]);
UI_DrawProportionalString( 158, 230, "FTR PIPELINE", UI_TINYFONT, colorTable[CT_LTORANGE]);
ui.R_SetColor( colorTable[CT_DKBLUE1]);
UI_DrawHandlePic( 80,358, 185, 18, uis.whiteShader); // Bar behind ENTER CD KEY
UI_DrawHandlePic( 118,417, 128, 18, uis.whiteShader); // Bar behind ACCEPT
UI_DrawHandlePic( 267, 376, 8, 59, uis.whiteShader); // Right hand side of box
UI_DrawNamedPic(263, 358, 16, 32, ART_FRAME);
UI_DrawProportionalString( 146, 358, "ENTER CD KEY", UI_SMALLFONT, colorTable[CT_LTORANGE]);
UI_DrawProportionalString( 152, 418, "ACCEPT", UI_SMALLFONT, colorTable[CT_LTORANGE]);
ui.R_SetColor( colorTable[CT_DKGREY2]);
UI_DrawHandlePic( 95,383, 160, 20, uis.whiteShader); // Grey square to type in
ui.R_SetColor( colorTable[CT_WHITE]);
UI_DrawHandlePic( 95,402, 160, 1, uis.whiteShader); // White line to type above
ui.R_SetColor( colorTable[CT_DKPURPLE1]);
UI_DrawHandlePic( 516,208, 21, 8, uis.whiteShader); // Bar above labels
UI_DrawHandlePic( 541,208, 21, 8, uis.whiteShader); // Bar above labels
UI_DrawHandlePic( 566,208, 21, 8, uis.whiteShader); // Bar above labels
UI_DrawHandlePic( 591,208, 21, 8, uis.whiteShader); // Bar above labels
UI_DrawHandlePic( 516,399, 21, 8, uis.whiteShader); // Bar above labels
UI_DrawHandlePic( 541,399, 21, 8, uis.whiteShader); // Bar above labels
UI_DrawHandlePic( 566,399, 21, 8, uis.whiteShader); // Bar above labels
UI_DrawHandlePic( 591,399, 21, 8, uis.whiteShader); // Bar above labels
UI_DrawProportionalString( 516, 223, "DIM : 74156", UI_TINYFONT, colorTable[CT_LTORANGE]);
UI_DrawProportionalString( 516, 237, "XYS DG : 21", UI_TINYFONT, colorTable[CT_LTORANGE]);
UI_DrawProportionalString( 516, 251, "VGVH-A : 129430", UI_TINYFONT, colorTable[CT_LTORANGE]);
UI_DrawProportionalString( 516, 275, "TTFN : 98231", UI_TINYFONT, colorTable[CT_LTORANGE]);
UI_DrawProportionalString( 516, 289, "BB IO : 45", UI_TINYFONT, colorTable[CT_LTORANGE]);
UI_DrawProportionalString( 516, 303, "R-T-PPL : 32", UI_TINYFONT, colorTable[CT_LTORANGE]);
UI_DrawProportionalString( 516, 317, "B1 YOT : 810257", UI_TINYFONT, colorTable[CT_LTORANGE]);
UI_DrawProportionalString( 516, 341, "XTR NTL: 171", UI_TINYFONT, colorTable[CT_LTORANGE]);
UI_DrawProportionalString( 516, 355, "HGH NTL: 1348", UI_TINYFONT, colorTable[CT_LTORANGE]);
UI_DrawProportionalString( 516, 369, "MED NTL: 45333", UI_TINYFONT, colorTable[CT_LTORANGE]);
UI_DrawProportionalString( 516, 383, "LOW NTL: 29", UI_TINYFONT, colorTable[CT_LTORANGE]);
// Menu frame numbers
UI_DrawProportionalString( 74, 66, "67811",UI_RIGHT|UI_TINYFONT, colorTable[CT_BLACK]);
UI_DrawProportionalString( 74, 84, "5656",UI_RIGHT|UI_TINYFONT, colorTable[CT_BLACK]);
UI_DrawProportionalString( 74, 188, "76-0021",UI_RIGHT|UI_TINYFONT, colorTable[CT_BLACK]);
UI_DrawProportionalString( 74, 395, "456181",UI_RIGHT|UI_TINYFONT, colorTable[CT_BLACK]);
}
/*
=================
M_CDKey_MenuDraw
=================
*/
void M_CDKey_MenuDraw (void)
{
M_CDKey_Graphics();
Menu_Draw( &s_cdkey_menu );
}
/*
=================
CDKey_MenuEvent
=================
*/
static void CDKey_MenuEvent( void* ptr, int notification )
{
menuframework_s* m;
if (notification != QM_ACTIVATED)
return;
m = ((menucommon_s*)ptr)->parent;
switch (((menucommon_s*)ptr)->id)
{
case ID_VIDEO:
UI_PopMenu();
UI_VideoDataMenu();
return;
case ID_CONTROLS:
UI_PopMenu();
UI_SetupWeaponsMenu();
break;
case ID_SOUND:
UI_PopMenu();
UI_SoundMenu();
break;
case ID_CDKEY:
break;
case ID_MAINMENU:
UI_PopMenu();
break;
}
}
/*
=================
M_CDKey_MenuKey
=================
*/
static sfxHandle_t M_CDKey_MenuKey( int key )
{
return Menu_DefaultKey( &s_cdkey_menu, key );
}
/*
===============
CDKeyMenu_Cache
===============
*/
void CDKeyMenu_Cache( void )
{
ui.R_RegisterShaderNoMip(ART_FRAME);
ui.R_RegisterShaderNoMip(ART_WORMHOLE);
}
/*
===============
CDKeyMenu_Init
===============
*/
void CDKeyMenu_Init(void)
{
CDKeyMenu_Cache();
s_cdkey_menu.nitems = 0;
s_cdkey_menu.wrapAround = qtrue;
s_cdkey_menu.draw = M_CDKey_MenuDraw;
s_cdkey_menu.key = M_CDKey_MenuKey;
s_cdkey_menu.fullscreen = qtrue;
s_cdkey_menu.wrapAround = qfalse;
s_cdkey_menu.descX = MENU_DESC_X;
s_cdkey_menu.descY = MENU_DESC_Y;
s_cdkey_menu.titleX = MENU_TITLE_X;
s_cdkey_menu.titleY = MENU_TITLE_Y;
s_cdkey_menu.titleI = MNT_CONTROLSMENU_TITLE;
s_cdkey_menu.footNoteEnum = MNT_CDKEY;
SetupMenu_TopButtons(&s_cdkey_menu,MENU_CDKEY,NULL);
}
/*
===============
UI_CDKeyMenu
===============
*/
void UI_CDKeyMenu( void)
{
if (!s_cdkey_menu.initialized)
{
CDKeyMenu_Init();
}
UI_PushMenu( &s_cdkey_menu);
}
| 31.037383
| 111
| 0.704005
|
kugelrund
|
59b90204ed19628aacbf05e179c8dd567f9df61f
| 5,003
|
cpp
|
C++
|
lw2/matrix.cpp
|
Grigory2001/cpp_labs
|
3cf3b2b24ba9c55d7edc9dfdee4b6bc3f8f45ee0
|
[
"MIT"
] | null | null | null |
lw2/matrix.cpp
|
Grigory2001/cpp_labs
|
3cf3b2b24ba9c55d7edc9dfdee4b6bc3f8f45ee0
|
[
"MIT"
] | null | null | null |
lw2/matrix.cpp
|
Grigory2001/cpp_labs
|
3cf3b2b24ba9c55d7edc9dfdee4b6bc3f8f45ee0
|
[
"MIT"
] | null | null | null |
#include "matrix.h"
Matrix::Matrix(unsigned rows, unsigned cols, double initial = 0){
_rows = rows;
_cols = cols;
v.resize(rows);
for (unsigned i = 0; i < v.size(); i++)
{
v[i].resize(cols, initial);
}
}
Matrix::Matrix(const Matrix &other)
{
_cols = other.get_cols();
_rows = other.get_rows();
v = other.v;
}
Matrix Matrix::operator+(const Matrix &other){
Matrix tmp(_cols, _rows, 0.0);
if(_cols != other.get_cols() || _rows != other.get_rows())
{
throw invalid_argument("cols and rows not equal");
}
unsigned i, j;
for (i = 0; i < _rows; i++)
{
for (j = 0; j < _cols; j++)
{
tmp.v[i][j] = this->v[i][j] + other.v[i][j];
}
}
return tmp;
}
Matrix Matrix::operator-(const Matrix & other){
Matrix diff(_cols, _rows, 0.0);
if(_cols != other.get_cols() || _rows != other.get_rows())
{
throw invalid_argument("cols and rows not equal");
}
unsigned i,j;
for (i = 0; i < _rows; i++)
{
for (j = 0; j < _cols; j++)
{
diff.v[i][j] = this->v[i][j] - other.v[i][j];
}
}
return diff;
}
Matrix Matrix::operator*(const Matrix & other){
Matrix multip(_rows, other.get_cols(), 0.0);
if(_cols != other.get_rows())
{
throw invalid_argument("cols != rows");
}
unsigned i,j,k;
double temp = 0.0;
for (i = 0; i < _rows; i++)
{
for (j = 0; j < other.get_cols(); j++)
{
temp = 0.0;
for (k = 0; k < _cols; k++)
{
temp += v[i][k] * other.v[k][j];
}
multip.v[i][j] = temp;
}
}
return multip;
}
Matrix Matrix::operator*(double scalar){
Matrix tmp(_rows,_cols,0.0);
unsigned i,j;
for (i = 0; i < _rows; i++)
{
for (j = 0; j < _cols; j++)
{
tmp.v[i][j] = v[i][j] * scalar;
}
}
return tmp;
}
unsigned Matrix::get_rows() const
{
return _rows;
}
unsigned Matrix::get_cols() const
{
return _cols;
}
void Matrix::set_val(int i, int j, double val)
{
v[i][j] = val;
}
double Matrix::dot_product(const Matrix &other_vec) {
double res = 0;
for (int i = 0; i < _rows; i++) {
double a, b;
res += v[0][i] * other_vec.v[0][i];
}
return res;
}
double Matrix::vector_norm() {
return sqrt(inner_product(v[0].begin(), v[0].end(), v[0].begin(), 0.0));
}
double Matrix::frobenius_norm()
{
Matrix temp(*this);
unsigned int i,j;
for (i = 0; i < _rows; i++)
{
for (j = 0; j < _cols; j++)
{
temp.v[i][j] *= temp.v[i][j];
}
}
double sum = 0;
for (i = 0; i < _rows; i++)
{
for (j = 0; j < _cols; j++)
{
sum += temp.v[i][j];
}
}
return sum;
}
Matrix Matrix::adamar_product(const Matrix& other)
{
Matrix temp(_cols, _rows, 0.0);
if(_cols != other.get_cols() || _rows != other.get_rows())
{
throw invalid_argument("cols and rows not equal");
}
unsigned int i,j;
for (i = 0; i < _rows; i++)
{
for (j = 0; j < _cols; j++)
{
temp.v[i][j] = v[i][j] + other.v[i][j];
}
}
return temp;
}
double Matrix::det()
{
int N = v.size();
double det = 1;
for (int i = 0; i < N; ++i) {
double pivotElement = v[i][i];
int pivotRow = i;
for (int row = i + 1; row < N; ++row) {
if (std::abs(v[row][i]) > std::abs(pivotElement)) {
pivotElement = v[row][i];
pivotRow = row;
}
}
if (pivotElement == 0.0) {
return 0.0;
}
if (pivotRow != i) {
v[i].swap(v[pivotRow]);
det *= -1.0;
}
det *= pivotElement;
for (int row = i + 1; row < N; ++row) {
for (int col = i + 1; col < N; ++col) {
v[row][col] -= v[row][i] * v[i][col] / pivotElement;
}
}
}
return det;
}
double Matrix::trace()
{
double tmp = 0;
if (_cols != _rows)
{
throw invalid_argument("not square matrix");
}
for (unsigned i = 0; i < _cols; i++)
{
tmp += v[i][i];
}
return tmp;
}
Matrix Matrix::transpose()
{
Matrix tmp(_cols, _rows, 0.0);
for (unsigned i = 0; i < _cols; i++)
{
for (unsigned j = 0; j < _rows; j++) {
tmp.v[i][j] = v[j][i];
}
}
return tmp;
}
ostream& operator<<(ostream& os, const Matrix& m)
{
for (int i = 0; i < m._rows; ++i) {
os << m.v[i][0];
for (int j = 1; j < m._cols; ++j) {
os << " " << m.v[i][j];
}
os << endl;
}
return os;
}
istream& operator>>(istream& is, Matrix& m)
{
for (int i = 0; i < m._rows; ++i) {
for (int j = 0; j < m._cols; ++j) {
is >> m.v[i][j];
}
}
return is;
}
| 19.542969
| 74
| 0.452129
|
Grigory2001
|
59c3a879c1297af54ddfecbd09bdc80f90e5a814
| 524
|
cpp
|
C++
|
ablateLibrary/domain/field.cpp
|
UBCHREST/ablate
|
02a5b390ba4e257b96bd19f4604c269598dccd9d
|
[
"BSD-3-Clause"
] | 3
|
2021-01-19T21:29:10.000Z
|
2021-08-20T19:54:49.000Z
|
ablateLibrary/domain/field.cpp
|
UBCHREST/ablate
|
02a5b390ba4e257b96bd19f4604c269598dccd9d
|
[
"BSD-3-Clause"
] | 124
|
2021-01-14T15:30:48.000Z
|
2022-03-28T14:44:31.000Z
|
ablateLibrary/domain/field.cpp
|
UBCHREST/ablate
|
02a5b390ba4e257b96bd19f4604c269598dccd9d
|
[
"BSD-3-Clause"
] | 17
|
2021-02-10T22:34:57.000Z
|
2022-03-21T18:46:06.000Z
|
#include "field.hpp"
#include <map>
static const std::map<std::string, ablate::domain::FieldType> stringToFieldLocation = {
{"sol", ablate::domain::FieldType::SOL}, {"SOL", ablate::domain::FieldType::SOL}, {"AUX", ablate::domain::FieldType::AUX}, {"aux", ablate::domain::FieldType::AUX}};
std::istream& ablate::domain::operator>>(std::istream& is, ablate::domain::FieldType& v) {
// get the key string
std::string enumString;
is >> enumString;
v = stringToFieldLocation.at(enumString);
return is;
}
| 40.307692
| 168
| 0.673664
|
UBCHREST
|
59c6f7ac4735c69d8e144aacd0e06c5fabb768e7
| 1,081
|
cpp
|
C++
|
src/snwc/snwc.cpp
|
Sojourn/snowda
|
432118a9ae561b8d6119cd34d1935a08a70e49cc
|
[
"MIT"
] | null | null | null |
src/snwc/snwc.cpp
|
Sojourn/snowda
|
432118a9ae561b8d6119cd34d1935a08a70e49cc
|
[
"MIT"
] | null | null | null |
src/snwc/snwc.cpp
|
Sojourn/snowda
|
432118a9ae561b8d6119cd34d1935a08a70e49cc
|
[
"MIT"
] | null | null | null |
#include "snwc.h"
const char *src =
"a = 3"
"b = 4"
"c = a + b + a";
int main(int argc, char **argv) {
AstTranslator translator(src);
const Code &code = translator.code();
std::vector<uint16_t> frame;
frame.resize(code.stack);
for (const Instruction &inst: code.insts) {
switch (inst.kind) {
case InstructionKind::Load:
memcpy(&frame[inst.data[0]], &inst.data[1], sizeof(uint16_t));
break;
case InstructionKind::Move:
frame[inst.data[0]] = frame[inst.data[1]];
break;
case InstructionKind::Add:
frame[inst.data[0]] = frame[inst.data[1]] + frame[inst.data[2]];
break;
case InstructionKind::Subtract:
frame[inst.data[0]] = frame[inst.data[1]] - frame[inst.data[2]];
break;
default:
abort();
}
}
for (std::pair<std::string, uint8_t> var : code.vars) {
std::cout << var.first << " = " << frame[var.second] << std::endl;
}
std::system("pause");
return EXIT_SUCCESS;
}
| 27.025
| 76
| 0.53839
|
Sojourn
|
59c75ae05efbe16ce03c4f3a0b36ed07995e47b3
| 9,545
|
hpp
|
C++
|
shared/include/ucfb_writer.hpp
|
SleepKiller/shaderpatch
|
4bda848df0273993c96f1d20a2cf79161088a77d
|
[
"MIT"
] | 13
|
2019-03-25T09:40:12.000Z
|
2022-03-13T16:12:39.000Z
|
shared/include/ucfb_writer.hpp
|
SleepKiller/shaderpatch
|
4bda848df0273993c96f1d20a2cf79161088a77d
|
[
"MIT"
] | 110
|
2018-10-16T09:05:43.000Z
|
2022-03-16T23:32:28.000Z
|
shared/include/ucfb_writer.hpp
|
SleepKiller/swbfii-shaderpatch
|
b49ce3349d4dd09b19237ff4766652166ba1ffd4
|
[
"MIT"
] | 1
|
2020-02-06T20:32:50.000Z
|
2020-02-06T20:32:50.000Z
|
#pragma once
#include "compose_exception.hpp"
#include "magic_number.hpp"
#include "small_function.hpp"
#include "utility.hpp"
#include <algorithm>
#include <concepts>
#include <cstdint>
#include <filesystem>
#include <fstream>
#include <iterator>
#include <ostream>
#include <span>
#include <stdexcept>
#include <string>
#include <string_view>
#include <type_traits>
#include <utility>
#include <gsl/gsl>
namespace sp::ucfb {
struct Writer_headerless_t {
};
inline constexpr Writer_headerless_t writer_headerless{};
// clang-format off
template<typename T>
concept Writer_target_position = requires(const T& target) {
{ target.position() } -> std::copyable;
{ target.position() } -> std::convertible_to<std::uint32_t>;
};
template<typename T>
concept Writer_target_output = requires(T& target, std::span<const std::byte> out_data,
std::invoke_result_t<decltype(&T::position), T> position) {
{ target.write(out_data) };
{ target.write_at_position(out_data, position) };
};
template<typename T>
concept Writer_target = Writer_target_position<T> && Writer_target_output<T>;
// clang-format on
class Writer_target_ostream {
public:
explicit Writer_target_ostream(std::ostream& out) : _out{out}
{
Expects(out.good());
}
auto position() const -> std::streampos
{
return _out.tellp();
}
void write(std::span<const std::byte> out_data)
{
_out.write(reinterpret_cast<const char*>(out_data.data()), out_data.size());
}
void write_at_position(std::span<const std::byte> out_data, std::streampos position)
{
const auto cur_pos = _out.tellp();
_out.seekp(position);
write(out_data);
_out.seekp(cur_pos);
}
private:
std::ostream& _out;
};
template<typename T>
class Writer_target_container {
public:
explicit Writer_target_container(T& out) : _out{out} {}
auto position() const noexcept -> std::size_t
{
return _out.size();
}
void write(std::span<const std::byte> out_data)
{
_out.insert(_out.end(), out_data.begin(), out_data.end());
}
void write_at_position(std::span<const std::byte> out_data, std::size_t position)
{
if (position + out_data.size() > _out.size()) {
_out.resize(position + out_data.size());
}
auto where = _out.begin();
std::ranges::advance(where, position);
std::ranges::copy(out_data, where);
}
private:
T& _out;
};
template<Writer_target Output, typename Last_act, typename Writer_type>
class Writer_child : public Writer_type {
static_assert(std::is_invocable_v<Last_act, decltype(Writer_type::_size)>);
public:
Writer_child(Output& output, const Magic_number mn, Last_act last_act)
: Writer_type{mn, output}, _last_act{std::move(last_act)}
{
}
Writer_child(const Writer_child&) = delete;
Writer_child& operator=(const Writer_child&) = delete;
Writer_child(Writer_child&&) = delete;
Writer_child& operator=(Writer_child&&) = delete;
~Writer_child()
{
_last_act(Writer_type::_size);
}
private:
Last_act _last_act;
};
template<Writer_target Output>
class Writer {
public:
enum class Alignment : bool { aligned, unaligned };
template<typename... Output_args>
Writer(const Magic_number root_mn,
Output_args&&... output) requires std::constructible_from<Output, Output_args...>
: _out{std::forward<Output_args>(output)...}
{
_out.write(std::as_bytes(std::span{&root_mn, 1}));
_size_pos = _out.position();
_out.write(std::as_bytes(std::span{&size_place_hold, 1}));
}
template<typename... Output_args>
Writer(const Writer_headerless_t,
Output_args&&... output) requires std::constructible_from<Output, Output_args...>
: _out{std::forward<Output_args>(output)...}, _headerless{true}
{
}
~Writer()
{
if (_headerless) return;
const auto chunk_size = static_cast<std::int32_t>(_size);
_out.write_at_position(std::as_bytes(std::span{&chunk_size, 1}), _size_pos);
}
Writer() = delete;
Writer(const Writer&) = delete;
Writer& operator=(const Writer&) = delete;
Writer(Writer&&) = delete;
Writer& operator=(Writer&&) = delete;
auto emplace_child(const Magic_number mn)
{
const auto last_act = [this](auto child_size) {
increase_size(child_size);
};
align_file();
increase_size(8);
return Writer_child<Output, decltype(last_act), Writer>{_out, mn, last_act};
}
void write(const std::span<const std::byte> span,
Alignment alignment = Alignment::aligned)
{
_out.write(span);
increase_size(span.size());
if (alignment == Alignment::aligned) align_file();
}
template<typename Type>
void write(const std::span<Type> span, Alignment alignment = Alignment::aligned)
{
write(std::as_bytes(span), alignment);
}
template<typename Type>
void write(const Type& value, Alignment alignment = Alignment::aligned)
{
static_assert(std::is_standard_layout_v<Type>,
"Type must be standard layout!");
static_assert(std::is_trivially_destructible_v<Type>,
"Type must be trivially destructible!");
static_assert(!std::is_same_v<std::remove_cvref_t<Type>, Alignment>,
"Type must not be the Alignment type!");
write(std::span{&value, 1}, alignment);
}
void write(const std::string_view string, Alignment alignment = Alignment::aligned)
{
write(std::span{string}, Alignment::unaligned);
write('\0', alignment);
}
void write(const std::string& string, Alignment alignment = Alignment::aligned)
{
write(std::string_view{string}, alignment);
}
template<typename... Args>
auto write(const Args&... args)
-> std::enable_if_t<!std::disjunction_v<std::is_same<Alignment, Args>...>>
{
(this->write(args, Alignment::aligned), ...);
}
template<typename... Args>
auto write_unaligned(const Args&... args)
-> std::enable_if_t<!std::disjunction_v<std::is_same<Alignment, Args>...>>
{
(this->write(args, Alignment::unaligned), ...);
}
auto pad(const std::uint32_t amount, Alignment alignment = Alignment::aligned)
{
for (auto i = 0u; i < amount; ++i) {
write(std::array{std::byte{}}, Alignment::unaligned);
}
if (alignment == Alignment::aligned) align_file();
}
auto pad_unaligned(const std::uint32_t amount)
{
return pad(amount, Alignment::unaligned);
}
auto absolute_size() const noexcept -> std::uint32_t
{
return gsl::narrow_cast<std::uint32_t>(_out.position());
}
private:
template<Writer_target Output, typename Last_act, typename Writer_type>
friend class Writer_child;
using Position = std::invoke_result_t<decltype(&Output::position), Output>;
constexpr static std::uint32_t size_place_hold = 0;
constexpr static std::int64_t write_alignment = 4;
void increase_size(const std::int64_t len)
{
_size += len;
if (_size > std::numeric_limits<std::int32_t>::max()) {
throw std::runtime_error{"ucfb file too large!"};
}
Ensures(_size <= std::numeric_limits<std::int32_t>::max());
}
void align_file()
{
constexpr std::array<const std::byte, 4> data{};
const auto alignment_bytes =
static_cast<std::size_t>(next_multiple_of<write_alignment>(_size) - _size);
if (alignment_bytes == 0) return;
write(std::span{data}.subspan(0, alignment_bytes), Alignment::unaligned);
}
Output _out;
Position _size_pos;
std::int64_t _size{};
const bool _headerless = false;
};
using File_writer = Writer<Writer_target_ostream>;
template<typename T>
struct Memory_writer : Writer<Writer_target_container<T>> {
using Writer<Writer_target_container<T>>::Writer;
};
template<typename T>
Memory_writer(const Magic_number, T&) -> Memory_writer<T>;
template<typename T>
Memory_writer(const Writer_headerless_t, T&) -> Memory_writer<T>;
//! \brief Helping for writing _from_ an alignment in a chunk.
//!
//! \tparam alignment The alignment to write till.
//!
//! \param writer The writer to write the data to.
//! \param data The data to write.
//!
//! This function does writes two things, first at the current position in writer it writes
//! the offset (in a uint32) from _after_ it that the data will be written. Then it write the data.
template<std::size_t alignment, Writer_target Output>
inline void write_at_alignment(Writer<Output>& writer,
const std::span<const std::byte> data) noexcept
{
// Calculate needed alignment.
const auto align_from_size = writer.absolute_size() + sizeof(std::uint32_t);
const auto aligned_offset =
next_multiple_of<alignment>(align_from_size) - align_from_size;
// Write alignment offset.
writer.write(gsl::narrow_cast<std::uint32_t>(aligned_offset));
// Pad until aligned.
writer.pad_unaligned(gsl::narrow_cast<std::uint32_t>(aligned_offset));
// Write data.
writer.write(data);
}
inline auto open_file_for_output(const std::filesystem::path& file_path) -> std::ofstream
{
using namespace std::literals;
std::ofstream file;
file.open(file_path, std::ios::binary);
if (!file.is_open()) {
throw compose_exception<std::runtime_error>("Unable to open file "sv,
file_path, " for output."sv);
}
return file;
}
}
| 26.736695
| 99
| 0.665165
|
SleepKiller
|
59c9ac4a0d8d024fd37705a9549b7b5eb701a5df
| 26,205
|
cpp
|
C++
|
src/cui/sas5/sas5.cpp
|
MaiReo/crass
|
11579527090faecab27f98b1e221172822928f57
|
[
"BSD-3-Clause"
] | 1
|
2021-07-21T00:58:45.000Z
|
2021-07-21T00:58:45.000Z
|
src/cui/sas5/sas5.cpp
|
MaiReo/crass
|
11579527090faecab27f98b1e221172822928f57
|
[
"BSD-3-Clause"
] | null | null | null |
src/cui/sas5/sas5.cpp
|
MaiReo/crass
|
11579527090faecab27f98b1e221172822928f57
|
[
"BSD-3-Clause"
] | null | null | null |
#include <windows.h>
#include <tchar.h>
#include <crass_types.h>
#include <acui.h>
#include <cui.h>
#include <package.h>
#include <resource.h>
#include <cui_error.h>
#include <utility.h>
#include <stdio.h>
// M:\すたじお緑茶\片恋いの月~体験版~
struct acui_information sas5_cui_information = {
_T("秋山構平"), /* copyright */
_T("Solfa Standard Novel System"), /* system */
_T(".iar .war"), /* package */
_T("0.5.0"), /* revision */
_T("痴漢公賊"), /* author */
_T("2008-7-5 19:23"), /* date */
NULL, /* notion */
ACUI_ATTRIBUTE_LEVEL_DEVELOP
};
#pragma pack (1)
typedef struct {
s8 magic[4]; // "war "
u32 head_size;
u32 index_entries;
u32 entry_size;
} war_header_t;
typedef struct {
u32 offset;
u32 length;
u32 unknown0; // 0
u32 unknown1; // 0
u32 unknown2; // -1
u8 type; // 0(PCM), 1 or 2(OGG)
u8 pad[3];
} war_entry_t;
typedef struct {
s8 magic[4]; // "iar "
u16 version;
u16 pad;
u32 header_size;
} iar_header_t;
typedef struct {
u32 info_header_size;
u32 build_time;
u32 dir_entries;
u32 file_entries;
u32 total_entries;
} iar_info_header_t;
typedef struct { // 0x40
u16 flags; // 低6为不能全为0;bit9 - data是否存在data_offset
u8 pad;
u8 is_compressed; // 0 or 1
u32 unknown0; // (0)肯定是一个长度字段
u32 uncomprlen;
u32 palette_length;
u32 comprlen;
u32 unknown1; // (0)
/* 文字显示的起始位置的坐标(10,10)视为原点的话,
* 那么该这里的坐标是相对于文字显示的起始位置的相对坐标的负值
*(背景框为10,表示背景框左上角位于该原点(-10,-10)的位置上),
* 右边的方框位置自然都是负值)
*/
u32 orig_x;
u32 orig_y;
s32 width;
s32 height;
u32 pitch;
u32 unknown7;
// 下面的字段,version 2和3才有
u32 left_top_x; // 左上角相对于绘图背景原点的坐标(不是屏幕原点坐标)
u32 left_top_y;
u32 right_top_x; // 右上角相对于绘图背景右上角的坐标(不是屏幕原点坐标)
u32 right_top_y;
} img_header_t;
typedef struct {
u32 base_image_id;
u32 start_line;
u32 lines;
} img_delta_header_t;
typedef struct {
u32 info_size; // 0x10
u32 data_size;
u16 FormatTag;
u16 Channels;
u32 SamplesPerSec;
u32 AvgBytesPerSec;
u16 BlockAlign;
u16 BitsPerSample;
} au_wav_header_t;
#pragma pack ()
typedef struct {
s8 name[MAX_PATH];
u32 offset;
u32 length;
} my_iar_entry_t;
static int debug;
static BYTE *sas5_resource;
static char *sas5_current_resource;
#define flag_shift \
flag >>= 1; \
if (flag <= 0xffff) { \
flag = compr[0] | (compr[1] << 8) | 0xffff0000; \
compr += 2; \
}
static void iar_uncompress(BYTE *uncompr, BYTE *compr)
{
u32 flag = 0;
while (1) {
u32 offset, copy_bytes;
flag_shift;
if (flag & 1)
*uncompr++ = *compr++;
else {
u32 tmp;
flag_shift;
if (flag & 1) {
offset = 1;
flag_shift;
tmp = flag & 1;
flag_shift;
if (!(flag & 1)) {
offset = 513;
flag_shift;
if (!(flag & 1)) {
offset = 1025;
flag_shift;
tmp = (flag & 1) | (tmp << 1);
flag_shift;
if (!(flag & 1)) {
offset = 2049;
flag_shift;
tmp = (flag & 1) | (tmp << 1);
flag_shift;
if (!(flag & 1)) {
offset = 4097;
flag_shift;
tmp = (flag & 1) | (tmp << 1);
}
}
}
}
offset = offset + ((tmp << 8) | *compr++);
flag_shift;
if (flag & 1)
copy_bytes = 3;
else {
flag_shift;
if (flag & 1)
copy_bytes = 4;
else {
flag_shift;
if (flag & 1)
copy_bytes = 5;
else {
flag_shift;
if (flag & 1)
copy_bytes = 6;
else {
flag_shift;
if (flag & 1) {
flag_shift;
if (flag & 1)
copy_bytes = 8;
else
copy_bytes = 7;
} else {
flag_shift;
if (flag & 1) {
copy_bytes = *compr++ + 17;
} else {
flag_shift;
copy_bytes = (flag & 1) << 2;
flag_shift;
copy_bytes |= (flag & 1) << 1;
flag_shift;
copy_bytes |= flag & 1;
copy_bytes += 9;
}
}
}
}
}
}
} else { // 外while外
flag_shift;
copy_bytes = 2;
if (flag & 1) {
flag_shift;
offset = (flag & 1) << 10;
flag_shift;
offset |= (flag & 1) << 9;
flag_shift;
offset = (offset | *compr++ | ((flag & 1) << 8)) + 256;
} else {
offset = *compr++ + 1;
if (offset == 256)
break;
}
}
for (DWORD i = 0; i < copy_bytes; i++) {
*uncompr = *(uncompr - offset);
uncompr++;
}
}
}
}
static void *my_malloc(DWORD len)
{
return malloc(len);
}
static void decrypt(BYTE *buf, DWORD len)
{
BYTE key = 0;
for (DWORD i = 0; i < len; i++) {
BYTE v = buf[i];
buf[i] ^= key;
key += v + 18;
}
}
static int __sas5_get_resource_name(DWORD res_load_id, char *name,
char *pack_name)
{
int ret = 0;
if (!sas5_resource) {
char tmp[MAX_PATH];
strcpy(tmp, pack_name);
char *p = strstr(tmp, ".");
if (p)
*p = 0;
sprintf(name, "%s%_%05d", tmp, res_load_id);
return ret;
}
char *resr;
u32 total_entries;
if (sas5_current_resource) {
total_entries = 1;
resr = sas5_current_resource;
} else {
resr = (char *)sas5_resource;
total_entries = *(u32 *)resr;
resr += 4;
}
for (DWORD i = 0; i < total_entries; ++i) {
char *res_name = resr;
resr += strlen(res_name) + 1;
char *res_type = resr;
resr += strlen(res_type) + 1;
char *res_mode = resr;
resr += strlen(res_mode) + 1;
u32 res_info_sz = *(u32 *)resr;
resr += 4;
char *info = resr;
char *pkg_name = info;
info += strlen(pkg_name) + 1;
u32 res_id = *(u32 *)info; // 所在的封包的内部id
resr += res_info_sz;
if (strstr(pkg_name, pack_name)) {
if (res_load_id == res_id) {
strcpy(name, res_name);
break;
}
}
}
if (i != total_entries) {
sas5_current_resource = resr;
ret = 1;
} else { // not found
char tmp[MAX_PATH];
strcpy(tmp, pack_name);
char *p = strstr(tmp, ".");
if (p)
*p = 0;
sprintf(name, "%s%_%05d", tmp, res_load_id);
sas5_current_resource = NULL;
ret = 2;
}
return ret;
}
static void sas5_get_resource_name(DWORD res_load_id, char *name,
char *pack_name)
{
int ret = __sas5_get_resource_name(res_load_id, name, pack_name);
if (ret == 2)
__sas5_get_resource_name(res_load_id, name, pack_name);
}
/********************* sec5 *********************/
static int sas5_sec5_match(struct package *pkg)
{
s8 magic[4];
u32 version;
if (pkg->pio->open(pkg, IO_READONLY))
return -CUI_EOPEN;
if (pkg->pio->read(pkg, magic, sizeof(magic))) {
pkg->pio->close(pkg);
return -CUI_EREAD;
}
if (strncmp(magic, "SEC5", 4)) {
pkg->pio->close(pkg);
return -CUI_EMATCH;
}
if (pkg->pio->read(pkg, &version, sizeof(version))) {
pkg->pio->close(pkg);
return -CUI_EREAD;
}
if (version - 100000 > 2000) {
pkg->pio->close(pkg);
return -CUI_EMATCH;
}
return 0;
}
static int sas5_sec5_extract_resource(struct package *pkg,
struct package_resource *pkg_res)
{
BYTE *sec5_data;
u32 sec5_size;
if (pkg->pio->length_of(pkg, &sec5_size))
return -CUI_ELEN;
sec5_data = (BYTE *)malloc(sec5_size);
if (!sec5_data)
return -CUI_EMEM;
if (pkg->pio->readvec(pkg, sec5_data, sec5_size, 0, IO_SEEK_SET)) {
free(sec5_data);
return -CUI_EREADVEC;
}
BYTE *p = sec5_data + 4;
*(u32 *)p = 2000;
p += 4;
while (p < sec5_data + sec5_size) {
u32 magic = *(u32 *)p; // block magic
p += 4;
u32 seg_len = *(u32 *)p;
p += 4;
if (!strncmp((char *)&magic, "ENDS", 4)) {
break;
} else if (!strncmp((char *)&magic, "RESR", 4)) {
// 所有内部资源文件列表
;
} else if (!strncmp((char *)&magic, "VARS", 4)) {
;
} else if (!strncmp((char *)&magic, "CZIT", 4)) {
;
} else if (!strncmp((char *)&magic, "OPTN", 4)) {
// ms是游戏设置相关的变量和设定值
;
} else if (!strncmp((char *)&magic, "CODE", 4)) {
decrypt(p, seg_len);
} else if (!strncmp((char *)&magic, "EXPL", 4)) {
;
} else if (!strncmp((char *)&magic, "VARA", 4)) {
;
} else if (!strncmp((char *)&magic, "RTFC", 4)) {
// 所有游戏文件列表
// [0](4)文件数量
// [4](-1)文件名1
// ...
;
}
p += seg_len;
}
pkg_res->raw_data = sec5_data;
pkg_res->raw_data_length = sec5_size;
return 0;
}
static int sas5_sec5_save_resource(struct resource *res,
struct package_resource *pkg_res)
{
if (res->rio->create(res))
return -CUI_ECREATE;
if (pkg_res->raw_data && pkg_res->raw_data_length) {
if (res->rio->write(res, pkg_res->raw_data, pkg_res->raw_data_length)) {
res->rio->close(res);
return -CUI_EWRITE;
}
}
res->rio->close(res);
return 0;
}
static void sas5_sec5_release_resource(struct package *pkg,
struct package_resource *pkg_res)
{
if (pkg_res->raw_data) {
free(pkg_res->raw_data);
pkg_res->raw_data = NULL;
}
}
static void sas5_sec5_release(struct package *pkg,
struct package_directory *pkg_dir)
{
pkg->pio->close(pkg);
}
static cui_ext_operation sas5_sec5_operation = {
sas5_sec5_match, /* match */
NULL, /* extract_directory */
NULL, /* parse_resource_info */
sas5_sec5_extract_resource, /* extract_resource */
sas5_sec5_save_resource, /* save_resource */
sas5_sec5_release_resource, /* release_resource */
sas5_sec5_release /* release */
};
/********************* iar *********************/
static int sas5_iar_match(struct package *pkg)
{
iar_header_t iar_header;
iar_info_header_t iar_info;
if (pkg->pio->open(pkg, IO_READONLY))
return -CUI_EOPEN;
if (pkg->pio->read(pkg, &iar_header, sizeof(iar_header))) {
pkg->pio->close(pkg);
return -CUI_EREAD;
}
if (strncmp(iar_header.magic, "iar ", 4)
|| (iar_header.version != 1 && iar_header.version != 2 && iar_header.version != 3)
|| iar_header.header_size < sizeof(iar_header)) {
pkg->pio->close(pkg);
return -CUI_EMATCH;
}
if (pkg->pio->read(pkg, &iar_info, sizeof(iar_info))) {
pkg->pio->close(pkg);
return -CUI_EREAD;
}
if (iar_info.info_header_size < sizeof(iar_info) || iar_info.total_entries > iar_info.file_entries) {
pkg->pio->close(pkg);
return -CUI_EMATCH;
}
if (pkg->lst) {
int ret = sas5_sec5_match(pkg->lst);
if (ret) {
pkg->pio->close(pkg);
return ret;
}
BYTE *sec5_data;
u32 sec5_size;
if (pkg->pio->length_of(pkg->lst, &sec5_size)) {
pkg->pio->close(pkg->lst);
pkg->pio->close(pkg);
return -CUI_ELEN;
}
sec5_data = (BYTE *)malloc(sec5_size);
if (!sec5_data) {
pkg->pio->close(pkg->lst);
pkg->pio->close(pkg);
return -CUI_EMEM;
}
if (pkg->pio->readvec(pkg->lst, sec5_data, sec5_size, 0, IO_SEEK_SET)) {
free(sec5_data);
pkg->pio->close(pkg->lst);
pkg->pio->close(pkg);
return -CUI_EREADVEC;
}
BYTE *p = sec5_data + 4;
p += 4;
while (p < sec5_data + sec5_size) {
u32 magic = *(u32 *)p;
p += 4;
u32 seg_len = *(u32 *)p;
p += 4;
if (!strncmp((char *)&magic, "RESR", 4)) {
sas5_resource = (BYTE *)malloc(seg_len + 1);
if (!sas5_resource) {
free(sec5_data);
pkg->pio->close(pkg->lst);
pkg->pio->close(pkg);
return -CUI_EMEM;
}
memcpy(sas5_resource, p, seg_len);
sas5_resource[seg_len - 1] = 0;
sas5_current_resource = NULL;
break;
}
p += seg_len;
}
free(sec5_data);
pkg->pio->close(pkg->lst);
}
return 0;
}
static int sas5_iar_extract_directory(struct package *pkg,
struct package_directory *pkg_dir)
{
iar_header_t iar_header;
iar_info_header_t iar_info;
my_iar_entry_t *index_buffer;
DWORD index_length;
DWORD offset_buffer_length;
u32 fsize;
void *offset_buffer;
if (pkg->pio->length_of(pkg, &fsize))
return -CUI_ELEN;
if (pkg->pio->readvec(pkg, &iar_header, sizeof(iar_header), 0, IO_SEEK_SET))
return -CUI_EREADVEC;
if (pkg->pio->read(pkg, &iar_info, sizeof(iar_info)))
return -CUI_EREAD;
index_length = iar_info.total_entries * sizeof(my_iar_entry_t);
index_buffer = (my_iar_entry_t *)malloc(index_length);
if (!index_buffer)
return -CUI_EMEM;
char pkg_name[MAX_PATH];
unicode2sj(pkg_name, MAX_PATH, pkg->name, -1);
if (iar_header.version < 3) {
offset_buffer_length = iar_info.total_entries * 4;
offset_buffer = malloc(offset_buffer_length);
if (!offset_buffer) {
free(index_buffer);
return -CUI_EMEM;
}
if (pkg->pio->read(pkg, offset_buffer, offset_buffer_length)) {
free(offset_buffer);
free(index_buffer);
return -CUI_EREAD;
}
for (DWORD i = 0; i < iar_info.total_entries - 1; ++i) {
sas5_get_resource_name(i, index_buffer[i].name, pkg_name);
index_buffer[i].offset = ((u32 *)offset_buffer)[i];
index_buffer[i].length = ((u32 *)offset_buffer)[i+1] - ((u32 *)offset_buffer)[i];
}
sas5_get_resource_name(i, index_buffer[i].name, pkg_name);
index_buffer[i].offset = ((u32 *)offset_buffer)[i];
index_buffer[i].length = fsize - ((u32 *)offset_buffer)[i];
} else {
offset_buffer_length = iar_info.total_entries * 8;
offset_buffer = malloc(offset_buffer_length);
if (!offset_buffer) {
free(index_buffer);
return -CUI_EMEM;
}
if (pkg->pio->read(pkg, offset_buffer, offset_buffer_length)) {
free(offset_buffer);
free(index_buffer);
return -CUI_EREAD;
}
for (DWORD i = 0; i < iar_info.total_entries - 1; ++i) {
index_buffer[i].offset = (u32)((u64 *)offset_buffer)[i];
index_buffer[i].length = (u32)((u64 *)offset_buffer)[i+1] - (u32)((u64 *)offset_buffer)[i];
sas5_get_resource_name(i, index_buffer[i].name, pkg_name);
}
sas5_get_resource_name(i, index_buffer[i].name, pkg_name);
index_buffer[i].offset = (u32)((u64 *)offset_buffer)[i];
index_buffer[i].length = fsize - (u32)((u64 *)offset_buffer)[i];
}
free(offset_buffer);
package_set_private(pkg, (void *)iar_header.version);
pkg_dir->index_entries = iar_info.total_entries;
pkg_dir->directory = index_buffer;
pkg_dir->directory_length = index_length;
pkg_dir->index_entry_length = sizeof(my_iar_entry_t);
return 0;
}
static int sas5_iar_parse_resource_info(struct package *pkg,
struct package_resource *pkg_res)
{
my_iar_entry_t *my_iar_entry;
my_iar_entry = (my_iar_entry_t *)pkg_res->actual_index_entry;
strncpy(pkg_res->name, my_iar_entry->name, 64);
pkg_res->name_length = -1; /* -1表示名称以NULL结尾 */
pkg_res->raw_data_length = my_iar_entry->length;
pkg_res->actual_data_length = 0; /* 数据都是明文 */
pkg_res->offset = my_iar_entry->offset;
return 0;
}
static int sas5_iar_extract_resource(struct package *pkg,
struct package_resource *pkg_res)
{
BYTE *compr, *uncompr, *palette;
img_header_t header;
int version;
DWORD offset;
int bpp;
#if 0
if (pkg_res->flags & PKG_RES_FLAG_RAW) {
compr = (BYTE *)malloc(pkg_res->raw_data_length);
if (!compr)
return -CUI_EMEM;
if (pkg->pio->readvec(pkg, pkg_res->raw_data_length, pkg_res->offset, IO_SEEK_SET)) {
free(compr);
return -CUI_EREADVEC;
}
pkg_res->raw_data = compr;
return 0;
}
#endif
version = (int)package_get_private(pkg);
if (version == 1) {
if (pkg->pio->readvec(pkg, &header, sizeof(header) - 16, pkg_res->offset, IO_SEEK_SET))
return -CUI_EREADVEC;
header.left_top_x = 0;
header.left_top_y = 0;
header.right_top_x = 0;
header.right_top_y = 0;
offset = pkg_res->offset + sizeof(header) - 16;
} else {
if (pkg->pio->readvec(pkg, &header, sizeof(header), pkg_res->offset, IO_SEEK_SET))
return -CUI_EREADVEC;
offset = pkg_res->offset + sizeof(header);
}
if (header.width < 0
|| header.height < 0
|| header.width >= 0x20000
|| header.height >= 0x20000
|| !header.uncomprlen
|| !header.comprlen
|| header.uncomprlen >= 0x4000000
|| header.comprlen >= 0x4000000
|| header.unknown0 >= 0x100000
|| header.palette_length >= 0x100000
|| header.is_compressed >= 2
|| !(header.flags & 0x3F) )
return CUI_EMATCH;
if (header.flags & 0x0200) { // 有palette
palette = (BYTE *)malloc(header.palette_length);
if (!palette)
return -CUI_EMEM;
if (pkg->pio->readvec(pkg, palette, header.palette_length, offset, IO_SEEK_SET)) {
free(palette);
return -CUI_EREADVEC;
}
offset += header.palette_length;
if (debug)
printf("%s: palette\n", pkg_res->name);
} else
palette = NULL;
compr = (BYTE *)malloc(header.comprlen);
if (!compr) {
free(palette);
return -CUI_EMEM;
}
if (pkg->pio->readvec(pkg, compr, header.comprlen, offset, IO_SEEK_SET)) {
free(compr);
free(palette);
return -CUI_EREADVEC;
}
uncompr = (BYTE *)malloc(header.uncomprlen);
if (!uncompr) {
free(compr);
free(palette);
return -CUI_EMEM;
}
if (header.is_compressed == 1)
iar_uncompress(uncompr, compr);
else if (!header.is_compressed)
memcpy(uncompr, compr, header.uncomprlen);
free(compr);
if (pkg_res->flags & PKG_RES_FLAG_RAW) {
pkg_res->actual_data = uncompr;
pkg_res->actual_data_length = header.uncomprlen;
return 0;
}
// printf("%x %x(%d) %x %x %x @ %p\n", header.width,header.pitch,header.pitch/header.width,header.height,
// header.palette_length, header.uncomprlen,palette);
// printf("%x\n", header.flags);
header.flags &= 0x093f;
// bpp = header.pitch / header.width;
bpp = 0;
switch (header.flags) {
case 0x01:
bpp = 8;
if (debug)
printf("%s: 1\n", pkg_res->name);
break;
case 0x02:
bpp = 8;
break;
case 0x1c:
bpp = 24;
break;
case 0x3c:
bpp = 32;
break;
case 0x11c:
if (debug)
printf("%s: 11c %x %x %x %x %x %x\n", pkg_res->name,
header.uncomprlen, palette,
header.palette_length, header.width,
header.height, bpp);
break;
case 0x13c:
if (debug)
printf("%s: 13c %x %x %x %x %x %x\n", pkg_res->name,
header.uncomprlen, palette,
header.palette_length, header.width,
header.height, bpp);
break;
case 0x81c: // 差分数据
bpp = 24;
if (debug)
printf("%s: 81c %x %x %x %x %x %x\n", pkg_res->name,
header.uncomprlen, palette,
header.palette_length, header.width,
header.height, bpp);
break;
case 0x83c: // 差分数据
bpp = 32;
break;
default:
free(uncompr);
free(palette);
return -CUI_EMATCH;
}
#if 1 // TODO
if (header.flags == 0x81c || header.flags == 0x83c) {
WORD Bpp = bpp / 8;
DWORD pitch = (header.width * Bpp + 3) & ~3;
DWORD img_size = pitch * header.height;
BYTE *img = (BYTE *)malloc(img_size);
if (!img) {
free(uncompr);
free(palette);
return -CUI_EMEM;
}
memset(img, 0, img_size);
img_delta_header_t *delta = (img_delta_header_t *)uncompr;
BYTE *p = uncompr + sizeof(img_delta_header_t);
BYTE *cur_line = img + pitch * delta->start_line;
for (DWORD d = 0; d < delta->lines; ++d) {
BYTE *dst = cur_line;
DWORD cnt = *(u16 *)p;
p += 2;
for (DWORD i = 0; i < cnt; ++i) {
u16 pos = *(u16 *)p * Bpp;
p += 2;
u16 count = *(u16 *)p * Bpp;
p += 2;
dst += pos;
memcpy(dst, p, count);
p += count;
dst += count;
}
cur_line += pitch;
}
if (MyBuildBMPFile(img, img_size, NULL, 0, header.width,
0 - header.height, bpp, (BYTE **)&pkg_res->actual_data,
&pkg_res->actual_data_length, my_malloc)) {
free(img);
free(uncompr);
free(palette);
return -CUI_EMEM;
}
free(img);
free(uncompr);
free(palette);
pkg_res->flags |= PKG_RES_FLAG_REEXT;
pkg_res->replace_extension = _T(".bmp");
return 0;
}
#endif
if (bpp) {
if (MyBuildBMPFile(uncompr, header.uncomprlen, palette, header.palette_length, header.width,
0 - header.height, bpp, (BYTE **)&pkg_res->actual_data, &pkg_res->actual_data_length, my_malloc)) {
free(uncompr);
free(palette);
return -CUI_EMEM;
}
free(uncompr);
pkg_res->flags |= PKG_RES_FLAG_REEXT;
pkg_res->replace_extension = _T(".bmp");
} else {
pkg_res->actual_data = uncompr;
pkg_res->actual_data_length = header.uncomprlen;
}
free(palette);
return 0;
}
static int sas5_iar_save_resource(struct resource *res,
struct package_resource *pkg_res)
{
if (res->rio->create(res))
return -CUI_ECREATE;
if (pkg_res->actual_data && pkg_res->actual_data_length) {
if (res->rio->write(res, pkg_res->actual_data, pkg_res->actual_data_length)) {
res->rio->close(res);
return -CUI_EWRITE;
}
} else if (pkg_res->raw_data && pkg_res->raw_data_length) {
if (res->rio->write(res, pkg_res->raw_data, pkg_res->raw_data_length)) {
res->rio->close(res);
return -CUI_EWRITE;
}
}
res->rio->close(res);
return 0;
}
static void sas5_iar_release_resource(struct package *pkg,
struct package_resource *pkg_res)
{
if (pkg_res->actual_data) {
free(pkg_res->actual_data);
pkg_res->actual_data = NULL;
}
if (pkg_res->raw_data) {
free(pkg_res->raw_data);
pkg_res->raw_data = NULL;
}
}
static void sas5_iar_release(struct package *pkg,
struct package_directory *pkg_dir)
{
if (sas5_resource) {
free(sas5_resource);
sas5_resource = NULL;
sas5_current_resource = NULL;
}
if (pkg_dir->directory) {
free(pkg_dir->directory);
pkg_dir->directory = NULL;
}
pkg->pio->close(pkg);
}
static cui_ext_operation sas5_iar_operation = {
sas5_iar_match, /* match */
sas5_iar_extract_directory, /* extract_directory */
sas5_iar_parse_resource_info, /* parse_resource_info */
sas5_iar_extract_resource, /* extract_resource */
sas5_iar_save_resource, /* save_resource */
sas5_iar_release_resource, /* release_resource */
sas5_iar_release /* release */
};
/********************* war *********************/
static int sas5_war_match(struct package *pkg)
{
war_header_t war_header;
if (pkg->pio->open(pkg, IO_READONLY))
return -CUI_EOPEN;
if (pkg->pio->read(pkg, &war_header, sizeof(war_header))) {
pkg->pio->close(pkg);
return -CUI_EREAD;
}
if (strncmp(war_header.magic, "war ", 4)) {
pkg->pio->close(pkg);
return -CUI_EMATCH;
}
if (pkg->lst) {
int ret = sas5_sec5_match(pkg->lst);
if (ret) {
pkg->pio->close(pkg);
return ret;
}
BYTE *sec5_data;
u32 sec5_size;
if (pkg->pio->length_of(pkg->lst, &sec5_size)) {
pkg->pio->close(pkg->lst);
pkg->pio->close(pkg);
return -CUI_ELEN;
}
sec5_data = (BYTE *)malloc(sec5_size);
if (!sec5_data) {
pkg->pio->close(pkg->lst);
pkg->pio->close(pkg);
return -CUI_EMEM;
}
if (pkg->pio->readvec(pkg->lst, sec5_data, sec5_size, 0, IO_SEEK_SET)) {
free(sec5_data);
pkg->pio->close(pkg->lst);
pkg->pio->close(pkg);
return -CUI_EREADVEC;
}
BYTE *p = sec5_data + 4;
p += 4;
while (p < sec5_data + sec5_size) {
u32 magic = *(u32 *)p;
p += 4;
u32 seg_len = *(u32 *)p;
p += 4;
if (!strncmp((char *)&magic, "RESR", 4)) {
sas5_resource = (BYTE *)malloc(seg_len + 1);
if (!sas5_resource) {
free(sec5_data);
pkg->pio->close(pkg->lst);
pkg->pio->close(pkg);
return -CUI_EMEM;
}
memcpy(sas5_resource, p, seg_len);
sas5_resource[seg_len - 1] = 0;
sas5_current_resource = NULL;
break;
}
p += seg_len;
}
free(sec5_data);
pkg->pio->close(pkg->lst);
}
return 0;
}
static int sas5_war_extract_directory(struct package *pkg,
struct package_directory *pkg_dir)
{
war_header_t war_header;
if (pkg->pio->readvec(pkg, &war_header, sizeof(war_header), 0, IO_SEEK_SET))
return -CUI_EREADVEC;
DWORD index_length = war_header.index_entries * sizeof(war_entry_t);
war_entry_t *index_buffer = (war_entry_t *)malloc(index_length);
if (!index_buffer)
return -CUI_EMEM;
if (pkg->pio->read(pkg, index_buffer, index_length)) {
free(index_buffer);
return -CUI_EREAD;
}
pkg_dir->index_entries = war_header.index_entries;
pkg_dir->directory = index_buffer;
pkg_dir->directory_length = index_length;
pkg_dir->index_entry_length = sizeof(war_entry_t);
return 0;
}
static int sas5_war_parse_resource_info(struct package *pkg,
struct package_resource *pkg_res)
{
war_entry_t *war_entry = (war_entry_t *)pkg_res->actual_index_entry;
char pkg_name[MAX_PATH];
unicode2sj(pkg_name, MAX_PATH, pkg->name, -1);
sas5_get_resource_name(pkg_res->index_number,
pkg_res->name, pkg_name);
pkg_res->name_length = -1; /* -1表示名称以NULL结尾 */
pkg_res->raw_data_length = war_entry->length;
pkg_res->actual_data_length = 0; /* 数据都是明文 */
pkg_res->offset = war_entry->offset;
if (debug)
printf("%s: %x %x %x %x %x %x\n",pkg_res->name,
war_entry->length, war_entry->offset,
war_entry->unknown0, war_entry->unknown1,
war_entry->unknown2, war_entry->type);
return 0;
}
static int sas5_war_extract_resource(struct package *pkg,
struct package_resource *pkg_res)
{
BYTE *raw = (BYTE *)malloc(pkg_res->raw_data_length);
if (!raw)
return -CUI_EMEM;
if (pkg->pio->readvec(pkg, raw, pkg_res->raw_data_length,
pkg_res->offset, IO_SEEK_SET)) {
free(raw);
return -CUI_EREADVEC;
}
war_entry_t *war_entry = (war_entry_t *)pkg_res->actual_index_entry;
if (war_entry->type == 2) {
pkg_res->flags |= PKG_RES_FLAG_REEXT;
pkg_res->replace_extension = _T(".ogg");
pkg_res->raw_data = raw;
} else if (war_entry->type == 0) {
au_wav_header_t *wav = (au_wav_header_t *)raw;
BYTE *pcm = raw + sizeof(au_wav_header_t);
if (MySaveAsWAVE(pcm, wav->data_size, wav->FormatTag,
wav->Channels, wav->SamplesPerSec, wav->BitsPerSample,
NULL, 0, (BYTE **)&pkg_res->actual_data,
&pkg_res->actual_data_length, my_malloc)) {
free(raw);
return -CUI_EMEM;
}
free(raw);
pkg_res->flags |= PKG_RES_FLAG_REEXT;
pkg_res->replace_extension = _T(".wav");
} else
pkg_res->raw_data = raw;
return 0;
}
static cui_ext_operation sas5_war_operation = {
sas5_war_match, /* match */
sas5_war_extract_directory, /* extract_directory */
sas5_war_parse_resource_info, /* parse_resource_info */
sas5_war_extract_resource, /* extract_resource */
sas5_iar_save_resource, /* save_resource */
sas5_iar_release_resource, /* release_resource */
sas5_iar_release /* release */
};
int CALLBACK sas5_register_cui(struct cui_register_callback *callback)
{
if (callback->add_extension(callback->cui, _T(".iar"), _T(".bmp"),
NULL, &sas5_iar_operation, CUI_EXT_FLAG_PKG | CUI_EXT_FLAG_DIR))
return -1;
if (callback->add_extension(callback->cui, _T(".war"), NULL,
NULL, &sas5_war_operation, CUI_EXT_FLAG_PKG | CUI_EXT_FLAG_DIR))
return -1;
if (callback->add_extension(callback->cui, _T(".sec5"), _T(".sec5_"),
NULL, &sas5_sec5_operation, CUI_EXT_FLAG_PKG))
return -1;
if (get_options("debug"))
debug = 1;
else
debug = 0;
sas5_resource = NULL;
sas5_current_resource = NULL;
return 0;
}
}
| 23.418231
| 105
| 0.636863
|
MaiReo
|
59cedac791af3780cdbf577d4c42954148d3c8d8
| 388
|
cpp
|
C++
|
src/apps/tcp_server/share_data.cpp
|
rnascunha/xerock
|
a8d1ab46fa87c300ab9737e4d5c71b9311c17a48
|
[
"MIT"
] | null | null | null |
src/apps/tcp_server/share_data.cpp
|
rnascunha/xerock
|
a8d1ab46fa87c300ab9737e4d5c71b9311c17a48
|
[
"MIT"
] | null | null | null |
src/apps/tcp_server/share_data.cpp
|
rnascunha/xerock
|
a8d1ab46fa87c300ab9737e4d5c71b9311c17a48
|
[
"MIT"
] | 1
|
2021-03-10T13:02:13.000Z
|
2021-03-10T13:02:13.000Z
|
#include "share_data.hpp"
#include "make.hpp"
namespace Apps{
namespace TCP_Server{
void Data_Share::read_handler(Byte_Array data,
boost::asio::ip::tcp::endpoint const& ep,
boost::asio::ip::tcp::endpoint const& local_ep)
{
Core::Propagator::write_all(
Byte_Array(
make_tcp_server_received_message(
ep,
local_ep,
data)
));
}
}//TCP_Server
}//Apps
| 17.636364
| 49
| 0.677835
|
rnascunha
|
59d101495d2232c0243c988c7b4f0816d5ecccb5
| 694
|
cpp
|
C++
|
PROBLEM_C/Codeforces- 1037C. Equalize.cpp
|
mirazib71/CODEFORCES
|
d92969874dd3826a771bb7b1dc32437418b1c706
|
[
"MIT"
] | null | null | null |
PROBLEM_C/Codeforces- 1037C. Equalize.cpp
|
mirazib71/CODEFORCES
|
d92969874dd3826a771bb7b1dc32437418b1c706
|
[
"MIT"
] | null | null | null |
PROBLEM_C/Codeforces- 1037C. Equalize.cpp
|
mirazib71/CODEFORCES
|
d92969874dd3826a771bb7b1dc32437418b1c706
|
[
"MIT"
] | null | null | null |
/// Codeforces- 1037C. Equalize
/// Category: greedy .(easy)
/// 1 0 or 0 1
/// 0 1 1 0 we have to swap these situations.
/// otherwise we will flip bits in a string
/// this is optimal choice .
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
int n;
string a,b;
cin>>n;
cin>>a>>b;
int ans=0;
/// swapping
for(int i=0;i<(int)a.size();i++)
{
if(a[i]!=a[i+1] && a[i]!=b[i] && a[i+1]!=b[i+1])
{
swap(a[i],a[i+1]);
ans++;
}
}
/// flipping
for(int i=0;i<(int)a.size();i++)
{
if(a[i]!=b[i]) ans++;
}
cout<<ans<<endl;
return 0;
}
| 14.458333
| 56
| 0.463977
|
mirazib71
|
59d6a1963fba8f7fcfa1d4b1088c3601dd03bebf
| 79,388
|
cpp
|
C++
|
Tools/STM32FW/STM32Cube_FW_F7_V1.16.2/Projects/STM32756G_EVAL/Demonstrations/TouchGFX/Gui/generated/images/src/CustomControls/control_menu_shadow_top.cpp
|
ramkumarkoppu/NUCLEO-F767ZI-ESW
|
85e129d71ee8eccbd0b94b5e07e75b6b91679ee8
|
[
"MIT"
] | null | null | null |
Tools/STM32FW/STM32Cube_FW_F7_V1.16.2/Projects/STM32756G_EVAL/Demonstrations/TouchGFX/Gui/generated/images/src/CustomControls/control_menu_shadow_top.cpp
|
ramkumarkoppu/NUCLEO-F767ZI-ESW
|
85e129d71ee8eccbd0b94b5e07e75b6b91679ee8
|
[
"MIT"
] | null | null | null |
Tools/STM32FW/STM32Cube_FW_F7_V1.16.2/Projects/STM32756G_EVAL/Demonstrations/TouchGFX/Gui/generated/images/src/CustomControls/control_menu_shadow_top.cpp
|
ramkumarkoppu/NUCLEO-F767ZI-ESW
|
85e129d71ee8eccbd0b94b5e07e75b6b91679ee8
|
[
"MIT"
] | null | null | null |
// Generated by imageconverter. Please, do not edit!
#include <touchgfx/hal/Config.hpp>
LOCATION_EXTFLASH_PRAGMA
KEEP extern const unsigned char _control_menu_shadow_top[] LOCATION_EXTFLASH_ATTRIBUTE = { // 116x34 ARGB8888 pixels.
0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,
0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,
0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,
0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,
0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,
0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x10,0xf7,
0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,
0x30,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x28,0x20,0x08,0xf7,0x30,0x20,0x08,0xf7,
0x28,0x20,0x08,0xf3,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xf3,0x28,0x20,0x08,0xef,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xf3,0x28,0x20,0x08,0xf3,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xf3,0x28,0x20,0x08,0xef,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xef,
0x28,0x20,0x08,0xf3,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xf3,0x28,0x20,0x08,0xf3,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xf3,0x28,0x20,0x08,0xef,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xf3,0x28,0x20,0x08,0xf3,0x30,0x20,0x10,0xef,0x30,0x20,0x10,0xf3,0x28,0x20,0x08,0xf3,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xef,0x28,0x20,0x08,0xf3,
0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xef,0x28,0x20,0x08,0xf3,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xf3,0x28,0x20,0x08,0xef,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xf3,0x28,0x20,0x08,0xf3,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xf3,0x28,0x20,0x08,0xf3,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xf3,0x28,0x20,0x08,0xf3,0x30,0x20,0x10,0xf3,
0x30,0x20,0x10,0xf3,0x28,0x20,0x08,0xef,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xf3,0x28,0x20,0x08,0xef,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xf3,0x28,0x20,0x08,0xef,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xf3,0x28,0x20,0x08,0xf3,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xf3,0x28,0x20,0x08,0xf3,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xf3,
0x28,0x20,0x08,0xf3,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xef,0x28,0x20,0x08,0xf3,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xf3,0x28,0x20,0x08,0xf3,0x30,0x20,0x10,0xef,0x30,0x20,0x10,0xf3,0x28,0x20,0x08,0xf3,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xf3,0x28,0x20,0x08,0xef,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xef,0x28,0x20,0x08,0xef,
0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xf3,0x28,0x20,0x08,0xf3,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xef,0x28,0x20,0x08,0xf3,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xf3,0x28,0x20,0x08,0xf3,0x30,0x20,0x10,0xf3,0x30,0x20,0x10,0xf3,0x28,0x20,0x08,0xf3,0x30,0x20,0x10,0xef,0x30,0x20,0x10,0xf3,0x28,0x20,0x08,0xf3,0x30,0x20,0x10,0xf3,
0x30,0x20,0x10,0xef,0x28,0x20,0x08,0xf3,0x30,0x20,0x08,0xf3,0x30,0x20,0x10,0xef,0x28,0x20,0x08,0xef,0x30,0x20,0x08,0xf3,0x30,0x20,0x10,0xf3,0x28,0x20,0x10,0xf3,0x30,0x20,0x08,0xf3,0x30,0x20,0x10,0xf3,0x28,0x20,0x10,0xf3,0x30,0x20,0x08,0xef,0x30,0x20,0x10,0xf3,0x28,0x20,0x10,0xf3,0x30,0x20,0x08,0xf3,0x30,0x20,0x10,0xef,
0x28,0x20,0x10,0xf3,0x30,0x20,0x08,0xf3,0x30,0x20,0x10,0xf3,0x28,0x20,0x10,0xf3,0x30,0x20,0x08,0xef,0x30,0x20,0x10,0xef,0x28,0x20,0x10,0xef,0x28,0x20,0x08,0xf3,
0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,
0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xef,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,
0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,
0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,
0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,
0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xef,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,
0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x28,0x20,0x10,0xef,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,
0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xeb,0x28,0x20,0x10,0xeb,0x28,0x20,0x08,0xeb,0x30,0x20,0x08,0xef,0x30,0x20,0x10,0xeb,0x28,0x20,0x08,0xef,0x30,0x20,0x08,0xeb,
0x30,0x20,0x08,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x30,0x20,0x08,0xe7,
0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,
0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,
0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,
0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,
0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,
0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x28,0x20,0x10,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,
0x28,0x20,0x10,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x28,0x20,0x10,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x28,0x20,0x10,0xe7,0x30,0x20,0x08,0xe7,0x30,0x20,0x08,0xe7,0x28,0x20,0x10,0xe7,0x30,0x20,0x08,0xe7,0x28,0x20,0x08,0xe7,0x28,0x20,0x10,0xe7,0x30,0x20,0x08,0xe7,0x28,0x20,0x08,0xe7,0x30,0x20,0x10,0xe7,
0x28,0x20,0x08,0xdf,0x30,0x20,0x10,0xdf,0x28,0x20,0x08,0xdf,0x30,0x20,0x10,0xdf,0x28,0x20,0x08,0xdf,0x28,0x20,0x10,0xdf,0x30,0x20,0x08,0xdf,0x28,0x20,0x08,0xdf,0x30,0x20,0x10,0xdf,0x28,0x20,0x08,0xdf,0x28,0x20,0x08,0xdf,0x30,0x20,0x10,0xdf,0x28,0x20,0x08,0xdf,0x28,0x20,0x08,0xdf,0x30,0x20,0x10,0xe3,0x28,0x20,0x08,0xdf,
0x28,0x20,0x08,0xdf,0x30,0x20,0x10,0xe3,0x28,0x20,0x08,0xdf,0x28,0x20,0x08,0xdf,0x30,0x20,0x10,0xdf,0x28,0x20,0x08,0xdf,0x28,0x20,0x08,0xdf,0x30,0x20,0x10,0xe3,0x28,0x20,0x08,0xdf,0x28,0x20,0x08,0xe3,0x30,0x20,0x10,0xdf,0x28,0x20,0x08,0xdf,0x28,0x20,0x08,0xdf,0x30,0x20,0x10,0xe3,0x28,0x20,0x08,0xdf,0x28,0x20,0x08,0xe3,
0x30,0x20,0x10,0xdf,0x28,0x20,0x08,0xdf,0x28,0x20,0x08,0xdf,0x30,0x20,0x10,0xdf,0x28,0x20,0x08,0xdf,0x28,0x20,0x08,0xdf,0x30,0x20,0x10,0xdf,0x28,0x20,0x08,0xdf,0x28,0x20,0x08,0xdf,0x30,0x20,0x10,0xe3,0x28,0x20,0x08,0xe3,0x28,0x20,0x08,0xdf,0x30,0x20,0x10,0xe3,0x28,0x20,0x08,0xdf,0x28,0x20,0x08,0xe3,0x30,0x20,0x10,0xe3,
0x28,0x20,0x08,0xdf,0x28,0x20,0x08,0xdf,0x30,0x20,0x10,0xdf,0x28,0x20,0x08,0xdf,0x28,0x20,0x08,0xdf,0x30,0x20,0x10,0xdf,0x28,0x20,0x08,0xdf,0x28,0x20,0x08,0xdf,0x30,0x20,0x10,0xe3,0x28,0x20,0x08,0xdf,0x28,0x20,0x08,0xdf,0x30,0x20,0x10,0xdf,0x28,0x20,0x08,0xdf,0x28,0x20,0x10,0xdf,0x30,0x20,0x08,0xe3,0x28,0x20,0x08,0xe3,
0x28,0x20,0x10,0xdf,0x30,0x20,0x08,0xe3,0x28,0x20,0x08,0xe3,0x28,0x20,0x10,0xdf,0x30,0x20,0x08,0xe3,0x28,0x20,0x08,0xdf,0x28,0x20,0x10,0xdf,0x30,0x20,0x08,0xdf,0x28,0x20,0x08,0xdf,0x28,0x20,0x10,0xe3,0x30,0x20,0x08,0xdf,0x28,0x20,0x08,0xdf,0x28,0x20,0x10,0xdf,0x30,0x20,0x08,0xe3,0x28,0x20,0x08,0xdf,0x28,0x20,0x10,0xdf,
0x30,0x20,0x08,0xdf,0x28,0x20,0x08,0xdf,0x28,0x20,0x10,0xe3,0x30,0x20,0x08,0xdf,0x28,0x20,0x08,0xdf,0x28,0x20,0x10,0xdf,0x30,0x20,0x08,0xe3,0x28,0x20,0x08,0xdf,0x28,0x20,0x10,0xe3,0x30,0x20,0x08,0xdf,0x28,0x20,0x08,0xe3,0x28,0x20,0x10,0xdf,0x30,0x20,0x08,0xdf,0x28,0x20,0x08,0xdf,0x28,0x20,0x10,0xdf,0x30,0x20,0x08,0xdf,
0x28,0x20,0x08,0xdf,0x28,0x20,0x10,0xe3,0x30,0x20,0x08,0xdf,0x28,0x20,0x08,0xdf,0x28,0x20,0x10,0xdf,0x30,0x20,0x08,0xdf,0x28,0x20,0x08,0xe3,0x28,0x20,0x10,0xdf,0x30,0x20,0x08,0xdf,0x28,0x20,0x08,0xe3,0x28,0x20,0x10,0xe3,0x30,0x20,0x08,0xdf,0x28,0x20,0x08,0xdf,0x30,0x20,0x10,0xdf,0x30,0x20,0x08,0xdf,0x30,0x20,0x08,0xdf,
0x28,0x20,0x10,0xdf,0x28,0x20,0x08,0xdf,0x30,0x20,0x08,0xdf,0x28,0x20,0x10,0xdf,
0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xdb,0x28,0x20,0x10,0xdb,0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xdb,0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xd7,0x28,0x20,0x08,0xdb,
0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xd7,0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xd7,0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xdb,
0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xd7,0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xd7,0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xd7,0x30,0x20,0x10,0xdb,
0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xd7,0x28,0x20,0x08,0xd7,0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xd7,0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xdb,
0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xd7,0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xd7,0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xd7,0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xd7,0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xdb,
0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xd7,0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xd7,0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xd7,0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xdb,
0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xdb,0x28,0x20,0x10,0xdb,0x30,0x20,0x08,0xdb,0x30,0x20,0x08,0xdb,0x28,0x20,0x10,0xdb,0x30,0x20,0x08,0xd7,0x30,0x20,0x08,0xdb,0x28,0x20,0x10,0xd7,0x30,0x20,0x08,0xdb,0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xd7,0x30,0x20,0x10,0xdb,0x28,0x20,0x08,0xdb,
0x28,0x20,0x10,0xdb,0x28,0x20,0x08,0xdb,0x30,0x20,0x08,0xdb,0x28,0x20,0x10,0xdb,0x30,0x20,0x08,0xdb,0x30,0x20,0x08,0xdb,0x28,0x20,0x10,0xdb,0x30,0x20,0x08,0xdb,
0x30,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x30,0x20,0x08,0xd3,0x30,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x30,0x20,0x08,0xd3,0x28,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,
0x30,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x30,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x30,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x30,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x30,0x20,0x10,0xd3,0x28,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x30,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,
0x30,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x30,0x20,0x10,0xd3,0x28,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x30,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x30,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x30,0x20,0x10,0xd3,0x28,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x30,0x20,0x10,0xd3,
0x28,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x30,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x30,0x20,0x10,0xd3,0x28,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x30,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x30,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x30,0x20,0x10,0xd3,0x28,0x20,0x10,0xd3,
0x28,0x20,0x08,0xd3,0x30,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x28,0x20,0x08,0xd3,0x30,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x30,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x30,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x30,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,
0x30,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x30,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x30,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x30,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x30,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x30,0x20,0x08,0xd3,
0x28,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x30,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x30,0x20,0x08,0xd3,0x28,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x30,0x20,0x08,0xd3,0x28,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x30,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,0x28,0x20,0x08,0xd3,0x30,0x20,0x10,0xd3,0x28,0x20,0x08,0xd3,
0x28,0x20,0x10,0xd3,0x30,0x20,0x08,0xd3,0x30,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x30,0x20,0x08,0xd3,0x30,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x28,0x20,0x10,0xd3,0x30,0x20,0x08,0xd3,0x28,0x20,0x08,0xd3,0x28,0x20,0x10,0xd3,0x30,0x20,0x08,0xd3,
0x28,0x20,0x08,0xcb,0x30,0x20,0x10,0xcb,0x28,0x20,0x08,0xcb,0x28,0x20,0x10,0xcb,
0x30,0x20,0x08,0xcb,0x28,0x20,0x08,0xcb,0x30,0x20,0x10,0xcb,0x30,0x20,0x08,0xcb,0x28,0x20,0x08,0xcb,0x28,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x28,0x20,0x10,0xcb,0x28,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x28,0x20,0x10,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x28,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,
0x30,0x20,0x08,0xcb,0x28,0x20,0x10,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x28,0x20,0x10,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x28,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x28,0x20,0x10,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x28,0x20,0x10,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,
0x28,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x28,0x20,0x10,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x28,0x20,0x10,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x28,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x28,0x20,0x10,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x28,0x20,0x10,0xcb,
0x30,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x28,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x28,0x20,0x10,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x10,0xcb,0x28,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x10,0xcb,0x28,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x10,0xcb,0x28,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,
0x30,0x20,0x10,0xcb,0x28,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x10,0xcb,0x28,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x10,0xcb,0x28,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x10,0xcb,0x28,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x10,0xcb,0x28,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x10,0xcb,
0x28,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x10,0xcb,0x28,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x10,0xcb,0x28,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x10,0xcb,0x28,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x10,0xcb,0x28,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x10,0xcb,0x28,0x20,0x08,0xcb,
0x30,0x20,0x08,0xcb,0x30,0x20,0x10,0xcb,0x28,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x28,0x20,0x10,0xcb,0x28,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x28,0x20,0x10,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x28,0x20,0x10,0xcb,0x30,0x20,0x08,0xcb,0x30,0x20,0x08,0xcb,0x28,0x20,0x10,0xcb,0x30,0x20,0x08,0xcb,0x28,0x20,0x08,0xcb,
0x28,0x20,0x08,0xc3,0x30,0x20,0x08,0xc3,0x30,0x20,0x10,0xc3,0x28,0x20,0x08,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x30,0x20,0x10,0xc3,0x28,0x20,0x08,0xc3,0x30,0x20,0x10,0xc3,0x28,0x20,0x08,0xc3,0x30,0x20,0x08,0xc3,0x30,0x20,0x10,0xc3,0x28,0x20,0x08,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,
0x30,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,
0x28,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,
0x28,0x20,0x08,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x28,0x20,0x08,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,
0x30,0x20,0x08,0xc3,0x28,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,
0x28,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x28,0x20,0x08,0xc3,0x30,0x20,0x10,0xc3,0x28,0x20,0x08,0xc3,
0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x30,0x20,0x08,0xc3,0x30,0x20,0x10,0xc3,0x28,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,0x28,0x20,0x08,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x10,0xc3,
0x28,0x20,0x08,0xc3,0x30,0x20,0x10,0xc3,0x30,0x20,0x08,0xc3,0x28,0x20,0x08,0xc3,
0x28,0x20,0x08,0xba,0x30,0x20,0x10,0xba,0x28,0x20,0x08,0xba,0x30,0x20,0x08,0xba,0x28,0x20,0x10,0xba,0x28,0x20,0x08,0xba,0x28,0x20,0x08,0xba,0x30,0x20,0x10,0xbe,0x28,0x20,0x08,0xba,0x30,0x20,0x10,0xba,0x28,0x20,0x10,0xba,0x28,0x20,0x08,0xbe,
0x30,0x20,0x08,0xba,0x30,0x20,0x10,0xba,0x28,0x20,0x08,0xba,0x30,0x20,0x08,0xba,0x28,0x20,0x10,0xbe,0x30,0x20,0x08,0xbe,0x30,0x20,0x08,0xba,0x28,0x20,0x10,0xbe,0x30,0x20,0x08,0xbe,0x30,0x20,0x10,0xba,0x28,0x20,0x08,0xba,0x30,0x20,0x08,0xbe,0x30,0x20,0x10,0xba,0x28,0x20,0x08,0xba,0x30,0x20,0x08,0xba,0x30,0x20,0x10,0xba,
0x28,0x20,0x08,0xba,0x30,0x20,0x10,0xbe,0x30,0x20,0x08,0xba,0x28,0x20,0x08,0xbe,0x30,0x20,0x10,0xba,0x30,0x20,0x08,0xba,0x28,0x20,0x08,0xbe,0x30,0x20,0x08,0xbe,0x30,0x20,0x10,0xba,0x28,0x20,0x08,0xbe,0x30,0x20,0x10,0xba,0x30,0x20,0x08,0xba,0x28,0x20,0x08,0xba,0x30,0x20,0x10,0xbe,0x30,0x20,0x08,0xba,0x28,0x20,0x08,0xba,
0x30,0x20,0x08,0xbe,0x30,0x20,0x10,0xba,0x28,0x20,0x08,0xba,0x30,0x20,0x08,0xba,0x30,0x20,0x10,0xba,0x28,0x20,0x08,0xba,0x30,0x20,0x10,0xba,0x30,0x20,0x08,0xbe,0x28,0x20,0x08,0xbe,0x30,0x20,0x10,0xba,0x30,0x20,0x08,0xbe,0x28,0x20,0x10,0xbe,0x30,0x20,0x08,0xbe,0x30,0x20,0x08,0xba,0x28,0x20,0x10,0xba,0x30,0x20,0x08,0xbe,
0x30,0x20,0x10,0xba,0x28,0x20,0x08,0xba,0x30,0x20,0x08,0xba,0x30,0x20,0x10,0xba,0x28,0x20,0x08,0xbe,0x30,0x20,0x08,0xba,0x30,0x20,0x10,0xba,0x28,0x20,0x08,0xba,0x30,0x20,0x08,0xba,0x30,0x20,0x10,0xba,0x28,0x20,0x08,0xbe,0x30,0x20,0x08,0xba,0x30,0x20,0x10,0xba,0x28,0x20,0x08,0xbe,0x30,0x20,0x08,0xba,0x30,0x20,0x10,0xba,
0x28,0x20,0x08,0xba,0x30,0x20,0x08,0xba,0x30,0x20,0x10,0xba,0x28,0x20,0x08,0xba,0x30,0x20,0x08,0xba,0x30,0x20,0x10,0xbe,0x28,0x20,0x08,0xba,0x30,0x20,0x08,0xbe,0x30,0x20,0x10,0xba,0x28,0x20,0x08,0xba,0x30,0x20,0x08,0xba,0x30,0x20,0x10,0xba,0x28,0x20,0x08,0xbe,0x30,0x20,0x08,0xba,0x30,0x20,0x10,0xba,0x28,0x20,0x08,0xba,
0x30,0x20,0x08,0xba,0x30,0x20,0x10,0xbe,0x28,0x20,0x08,0xba,0x30,0x20,0x08,0xba,0x30,0x20,0x10,0xbe,0x28,0x20,0x08,0xba,0x30,0x20,0x08,0xba,0x30,0x20,0x10,0xbe,0x28,0x20,0x08,0xbe,0x28,0x20,0x08,0xba,0x28,0x20,0x10,0xba,0x30,0x20,0x08,0xbe,0x28,0x20,0x08,0xba,0x30,0x20,0x10,0xba,0x30,0x20,0x08,0xbe,0x28,0x20,0x08,0xba,
0x30,0x20,0x10,0xba,0x28,0x20,0x08,0xba,0x30,0x20,0x08,0xba,0x28,0x20,0x10,0xba,0x28,0x20,0x08,0xbe,0x30,0x20,0x08,0xba,0x28,0x20,0x10,0xbe,0x30,0x20,0x10,0xba,
0x30,0x20,0x08,0xb2,0x28,0x20,0x10,0xb2,0x28,0x20,0x08,0xb2,0x30,0x20,0x10,0xb6,0x30,0x20,0x10,0xb2,0x30,0x20,0x08,0xb6,0x28,0x20,0x08,0xb2,0x28,0x20,0x10,0xb6,
0x30,0x20,0x08,0xb2,0x28,0x20,0x08,0xb2,0x30,0x20,0x08,0xb2,0x28,0x20,0x10,0xb6,0x28,0x20,0x08,0xb6,0x30,0x20,0x10,0xb6,0x28,0x20,0x08,0xb6,0x28,0x20,0x08,0xb2,0x30,0x20,0x10,0xb6,0x28,0x20,0x08,0xb2,0x30,0x20,0x08,0xb2,0x28,0x20,0x10,0xb2,0x28,0x20,0x08,0xb2,0x30,0x20,0x08,0xb2,0x28,0x20,0x10,0xb2,0x30,0x20,0x08,0xb6,
0x28,0x20,0x08,0xb2,0x28,0x20,0x10,0xb6,0x30,0x20,0x08,0xb2,0x28,0x20,0x08,0xb6,0x28,0x20,0x10,0xb6,0x30,0x20,0x08,0xb2,0x28,0x20,0x08,0xb2,0x28,0x20,0x10,0xb2,0x30,0x20,0x10,0xb6,0x28,0x20,0x08,0xb2,0x28,0x20,0x08,0xb2,0x30,0x20,0x10,0xb2,0x28,0x20,0x08,0xb2,0x28,0x20,0x08,0xb6,0x30,0x20,0x10,0xb6,0x28,0x20,0x08,0xb2,
0x28,0x20,0x10,0xb2,0x30,0x20,0x08,0xb2,0x28,0x20,0x10,0xb6,0x28,0x20,0x08,0xb2,0x30,0x20,0x08,0xb6,0x28,0x20,0x10,0xb6,0x28,0x20,0x08,0xb2,0x30,0x20,0x08,0xb6,0x28,0x20,0x10,0xb2,0x28,0x20,0x08,0xb6,0x30,0x20,0x08,0xb2,0x28,0x20,0x10,0xb2,0x28,0x20,0x08,0xb2,0x30,0x20,0x08,0xb2,0x28,0x20,0x08,0xb6,0x28,0x20,0x10,0xb2,
0x30,0x20,0x08,0xb6,0x28,0x20,0x08,0xb2,0x28,0x20,0x10,0xb2,0x30,0x20,0x08,0xb6,0x28,0x20,0x08,0xb2,0x28,0x20,0x10,0xb2,0x30,0x20,0x08,0xb6,0x28,0x20,0x10,0xb6,0x28,0x20,0x08,0xb2,0x30,0x20,0x10,0xb6,0x28,0x20,0x08,0xb2,0x28,0x20,0x10,0xb6,0x30,0x20,0x08,0xb6,0x28,0x20,0x10,0xb2,0x28,0x20,0x08,0xb6,0x30,0x20,0x10,0xb2,
0x28,0x20,0x08,0xb2,0x28,0x20,0x10,0xb2,0x30,0x20,0x08,0xb6,0x28,0x20,0x10,0xb6,0x28,0x20,0x08,0xb2,0x30,0x20,0x10,0xb6,0x28,0x20,0x08,0xb2,0x28,0x20,0x10,0xb2,0x30,0x20,0x08,0xb6,0x28,0x20,0x10,0xb2,0x28,0x20,0x08,0xb2,0x30,0x20,0x10,0xb6,0x28,0x20,0x08,0xb2,0x28,0x20,0x10,0xb6,0x30,0x20,0x08,0xb2,0x28,0x20,0x10,0xb2,
0x28,0x20,0x08,0xb2,0x30,0x20,0x10,0xb6,0x28,0x20,0x08,0xb2,0x28,0x20,0x08,0xb6,0x30,0x20,0x10,0xb2,0x28,0x20,0x08,0xb6,0x28,0x20,0x08,0xb2,0x30,0x20,0x10,0xb2,0x28,0x20,0x08,0xb6,0x28,0x20,0x10,0xb6,0x30,0x20,0x08,0xb2,0x30,0x20,0x08,0xb6,0x28,0x20,0x10,0xb6,0x30,0x20,0x08,0xb2,0x30,0x20,0x10,0xb6,0x28,0x20,0x08,0xb6,
0x28,0x20,0x08,0xb2,0x30,0x20,0x10,0xb2,0x28,0x20,0x08,0xb6,0x30,0x20,0x08,0xb6,0x28,0x20,0x10,0xb2,0x30,0x20,0x08,0xb6,0x30,0x20,0x10,0xb2,0x30,0x20,0x08,0xb6,0x28,0x20,0x08,0xb2,0x30,0x20,0x10,0xb6,0x28,0x20,0x08,0xb2,0x28,0x20,0x08,0xb6,
0x30,0x20,0x08,0xaa,0x28,0x20,0x08,0xaa,0x30,0x20,0x08,0xae,0x28,0x20,0x08,0xaa,
0x28,0x20,0x10,0xaa,0x30,0x20,0x08,0xaa,0x30,0x20,0x08,0xaa,0x28,0x20,0x10,0xaa,0x30,0x20,0x08,0xaa,0x30,0x20,0x08,0xaa,0x28,0x20,0x10,0xaa,0x30,0x20,0x08,0xaa,0x30,0x20,0x08,0xaa,0x28,0x20,0x10,0xaa,0x30,0x20,0x08,0xaa,0x30,0x20,0x10,0xaa,0x28,0x20,0x08,0xaa,0x28,0x20,0x08,0xaa,0x30,0x20,0x10,0xae,0x30,0x20,0x08,0xaa,
0x28,0x20,0x08,0xaa,0x28,0x20,0x10,0xaa,0x30,0x20,0x10,0xaa,0x28,0x20,0x08,0xaa,0x30,0x20,0x08,0xaa,0x30,0x20,0x10,0xaa,0x28,0x20,0x08,0xaa,0x30,0x20,0x08,0xae,0x30,0x20,0x10,0xaa,0x28,0x20,0x08,0xaa,0x30,0x20,0x08,0xaa,0x30,0x20,0x10,0xaa,0x28,0x20,0x08,0xaa,0x30,0x20,0x08,0xaa,0x30,0x20,0x10,0xaa,0x28,0x20,0x10,0xaa,
0x30,0x20,0x08,0xaa,0x30,0x20,0x08,0xaa,0x28,0x20,0x10,0xaa,0x30,0x20,0x08,0xae,0x30,0x20,0x08,0xaa,0x28,0x20,0x10,0xaa,0x30,0x20,0x08,0xaa,0x30,0x20,0x10,0xaa,0x28,0x20,0x08,0xaa,0x30,0x20,0x10,0xaa,0x30,0x20,0x08,0xaa,0x28,0x20,0x08,0xaa,0x30,0x20,0x10,0xaa,0x30,0x20,0x08,0xaa,0x28,0x20,0x08,0xaa,0x30,0x20,0x10,0xaa,
0x30,0x20,0x10,0xaa,0x28,0x20,0x08,0xaa,0x30,0x20,0x10,0xaa,0x30,0x20,0x08,0xaa,0x28,0x20,0x10,0xaa,0x30,0x20,0x08,0xaa,0x30,0x20,0x10,0xaa,0x28,0x20,0x08,0xaa,0x30,0x20,0x08,0xaa,0x30,0x20,0x10,0xaa,0x28,0x20,0x08,0xaa,0x30,0x20,0x08,0xaa,0x30,0x20,0x10,0xaa,0x28,0x20,0x08,0xaa,0x30,0x20,0x08,0xaa,0x30,0x20,0x10,0xaa,
0x28,0x20,0x08,0xaa,0x30,0x20,0x08,0xaa,0x30,0x20,0x10,0xaa,0x28,0x20,0x08,0xae,0x30,0x20,0x08,0xaa,0x30,0x20,0x10,0xaa,0x28,0x20,0x08,0xaa,0x30,0x20,0x08,0xaa,0x30,0x20,0x10,0xaa,0x28,0x20,0x08,0xaa,0x30,0x20,0x08,0xaa,0x30,0x20,0x10,0xaa,0x28,0x20,0x08,0xaa,0x30,0x20,0x08,0xaa,0x30,0x20,0x10,0xaa,0x28,0x20,0x08,0xaa,
0x30,0x20,0x08,0xaa,0x30,0x20,0x10,0xaa,0x28,0x20,0x08,0xae,0x30,0x20,0x08,0xaa,0x30,0x20,0x10,0xaa,0x28,0x20,0x08,0xaa,0x30,0x20,0x08,0xae,0x30,0x20,0x10,0xaa,0x28,0x20,0x08,0xaa,0x30,0x20,0x08,0xaa,0x30,0x20,0x10,0xaa,0x28,0x20,0x08,0xaa,0x30,0x20,0x08,0xaa,0x28,0x20,0x10,0xaa,0x28,0x20,0x08,0xaa,0x30,0x20,0x08,0xaa,
0x28,0x20,0x10,0xaa,0x30,0x20,0x08,0xaa,0x30,0x20,0x08,0xaa,0x28,0x20,0x10,0xaa,0x30,0x20,0x08,0xaa,0x28,0x20,0x10,0xaa,0x30,0x20,0x08,0xaa,0x28,0x20,0x10,0xaa,0x28,0x20,0x08,0xaa,0x30,0x20,0x08,0xaa,0x28,0x20,0x10,0xaa,0x28,0x20,0x08,0xae,0x30,0x20,0x08,0xaa,0x30,0x20,0x10,0xaa,0x28,0x20,0x08,0xaa,0x30,0x20,0x08,0xae,
0x28,0x20,0x10,0xa2,0x30,0x20,0x08,0xa2,0x30,0x20,0x10,0xa2,0x28,0x20,0x08,0xa2,0x28,0x20,0x08,0xa2,0x30,0x20,0x10,0xa2,0x28,0x20,0x08,0xa2,0x30,0x20,0x08,0xa2,0x28,0x20,0x10,0xa6,0x28,0x20,0x08,0xa2,0x30,0x20,0x10,0xa2,0x28,0x20,0x08,0xa2,0x30,0x20,0x08,0xa2,0x28,0x20,0x10,0xa2,0x28,0x20,0x08,0xa2,0x30,0x20,0x08,0xa2,
0x30,0x20,0x10,0xa2,0x28,0x20,0x08,0xa2,0x30,0x20,0x10,0xa2,0x30,0x20,0x08,0xa6,0x28,0x20,0x08,0xa2,0x30,0x20,0x10,0xa2,0x30,0x20,0x08,0xa2,0x28,0x20,0x08,0xa6,0x28,0x20,0x10,0xa2,0x30,0x20,0x08,0xa2,0x28,0x20,0x10,0xa2,0x30,0x20,0x08,0xa2,0x28,0x20,0x08,0xa2,0x28,0x20,0x10,0xa2,0x30,0x20,0x08,0xa6,0x28,0x20,0x08,0xa2,
0x28,0x20,0x10,0xa6,0x30,0x20,0x08,0xa2,0x28,0x20,0x08,0xa2,0x28,0x20,0x08,0xa6,0x30,0x20,0x10,0xa2,0x28,0x20,0x08,0xa2,0x28,0x20,0x08,0xa2,0x30,0x20,0x10,0xa2,0x28,0x20,0x08,0xa2,0x28,0x20,0x08,0xa2,0x30,0x20,0x10,0xa2,0x28,0x20,0x08,0xa2,0x28,0x20,0x08,0xa2,0x30,0x20,0x10,0xa2,0x28,0x20,0x08,0xa2,0x28,0x20,0x10,0xa2,
0x30,0x20,0x08,0xa6,0x28,0x20,0x10,0xa2,0x28,0x20,0x08,0xa2,0x30,0x20,0x08,0xa6,0x28,0x20,0x08,0xa2,0x28,0x20,0x10,0xa2,0x30,0x20,0x08,0xa2,0x28,0x20,0x08,0xa2,0x28,0x20,0x08,0xa2,0x30,0x20,0x10,0xa6,0x28,0x20,0x08,0xa2,0x28,0x20,0x10,0xa2,0x30,0x20,0x08,0xa6,0x28,0x20,0x08,0xa2,0x28,0x20,0x10,0xa2,0x30,0x20,0x08,0xa2,
0x28,0x20,0x08,0xa2,0x28,0x20,0x10,0xa2,0x30,0x20,0x08,0xa2,0x28,0x20,0x08,0xa2,0x28,0x20,0x10,0xa2,0x30,0x20,0x08,0xa2,0x28,0x20,0x08,0xa2,0x28,0x20,0x10,0xa2,0x30,0x20,0x08,0xa6,0x28,0x20,0x08,0xa2,0x28,0x20,0x10,0xa2,0x30,0x20,0x08,0xa2,0x28,0x20,0x08,0xa2,0x28,0x20,0x10,0xa6,0x30,0x20,0x08,0xa2,0x28,0x20,0x08,0xa2,
0x28,0x20,0x10,0xa6,0x30,0x20,0x08,0xa2,0x28,0x20,0x08,0xa2,0x28,0x20,0x10,0xa2,0x30,0x20,0x08,0xa2,0x28,0x20,0x08,0xa6,0x28,0x20,0x10,0xa2,0x30,0x20,0x08,0xa2,0x28,0x20,0x08,0xa6,0x28,0x20,0x10,0xa2,0x30,0x20,0x08,0xa2,0x28,0x20,0x10,0xa2,0x28,0x20,0x08,0xa2,0x30,0x20,0x10,0xa6,0x28,0x20,0x08,0xa2,0x30,0x20,0x08,0xa2,
0x30,0x20,0x10,0xa2,0x30,0x20,0x08,0xa2,0x28,0x20,0x10,0xa2,0x28,0x20,0x08,0xa2,0x30,0x20,0x08,0xa2,0x28,0x20,0x10,0xa2,0x28,0x20,0x08,0xa2,0x30,0x20,0x08,0xa2,0x28,0x20,0x10,0xa2,0x30,0x20,0x08,0xa6,0x30,0x20,0x08,0xa2,0x28,0x20,0x10,0xa2,0x30,0x20,0x08,0xa2,0x28,0x20,0x08,0xa2,0x30,0x20,0x10,0xa2,0x28,0x20,0x08,0xa2,
0x30,0x20,0x10,0xa2,0x28,0x20,0x08,0xa2,0x30,0x20,0x10,0xa2,0x28,0x20,0x08,0xa2,
0x28,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x30,0x20,0x08,0x9a,0x28,0x20,0x10,0x9a,0x30,0x20,0x08,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x30,0x20,0x08,0x9a,0x28,0x20,0x08,0x9a,0x28,0x20,0x10,0x9a,
0x30,0x20,0x08,0x9a,0x30,0x20,0x08,0x9a,0x28,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x08,0x9a,0x28,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,
0x30,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x08,0x9a,
0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x30,0x20,0x08,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x30,0x20,0x08,0x9a,
0x28,0x20,0x10,0x9a,0x30,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,
0x30,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x30,0x20,0x08,0x9a,0x28,0x20,0x10,0x9a,0x30,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x30,0x20,0x08,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,
0x30,0x20,0x08,0x9a,0x28,0x20,0x08,0x9a,0x28,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x08,0x9a,0x28,0x20,0x10,0x9a,0x30,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x08,0x9a,0x28,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x08,0x9a,0x28,0x20,0x10,0x9a,
0x30,0x20,0x08,0x9a,0x30,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x08,0x9a,0x28,0x20,0x10,0x9a,0x28,0x20,0x08,0x9a,0x30,0x20,0x08,0x9a,0x28,0x20,0x10,0x9a,
0x30,0x20,0x08,0x92,0x28,0x20,0x08,0x92,0x28,0x20,0x08,0x92,0x30,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x30,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x28,0x20,0x08,0x92,
0x30,0x20,0x10,0x92,0x30,0x20,0x08,0x92,0x28,0x20,0x08,0x92,0x30,0x20,0x10,0x92,0x28,0x20,0x08,0x92,0x30,0x20,0x10,0x92,0x30,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x30,0x20,0x08,0x92,0x30,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x30,0x20,0x08,0x92,0x30,0x20,0x10,0x92,0x28,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x30,0x20,0x08,0x92,
0x30,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x30,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x30,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x28,0x20,0x08,0x92,0x30,0x20,0x10,0x92,0x28,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x30,0x20,0x10,0x92,0x28,0x20,0x08,0x92,0x28,0x20,0x08,0x92,0x30,0x20,0x10,0x92,0x28,0x20,0x10,0x92,0x28,0x20,0x08,0x92,
0x30,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x28,0x20,0x08,0x92,0x30,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x28,0x20,0x08,0x92,0x30,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x28,0x20,0x08,0x92,0x30,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x28,0x20,0x10,0x92,0x30,0x20,0x08,0x92,0x28,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x30,0x20,0x08,0x92,
0x28,0x20,0x10,0x92,0x28,0x20,0x08,0x92,0x30,0x20,0x08,0x92,0x28,0x20,0x08,0x92,0x28,0x20,0x08,0x92,0x30,0x20,0x10,0x92,0x28,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x30,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x28,0x20,0x08,0x92,0x30,0x20,0x10,0x92,0x28,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x30,0x20,0x08,0x92,0x28,0x20,0x10,0x92,
0x28,0x20,0x08,0x92,0x30,0x20,0x10,0x92,0x28,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x30,0x20,0x08,0x92,0x28,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x30,0x20,0x08,0x92,0x28,0x20,0x08,0x92,0x28,0x20,0x08,0x92,0x30,0x20,0x10,0x92,0x28,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x30,0x20,0x08,0x92,0x28,0x20,0x08,0x92,0x28,0x20,0x10,0x92,
0x30,0x20,0x08,0x92,0x28,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x30,0x20,0x08,0x92,0x30,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x30,0x20,0x10,0x92,0x30,0x20,0x08,0x92,0x28,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x30,0x20,0x08,0x92,0x28,0x20,0x08,0x92,0x30,0x20,0x10,0x92,0x28,0x20,0x08,0x92,0x30,0x20,0x10,0x92,0x30,0x20,0x08,0x92,
0x28,0x20,0x10,0x92,0x30,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x28,0x20,0x08,0x92,0x30,0x20,0x08,0x92,0x28,0x20,0x10,0x92,0x28,0x20,0x08,0x92,0x30,0x20,0x08,0x92,0x30,0x20,0x10,0x92,0x28,0x20,0x08,0x92,0x30,0x20,0x08,0x92,0x30,0x20,0x08,0x92,
0x28,0x20,0x08,0x8a,0x30,0x20,0x10,0x86,0x30,0x20,0x10,0x86,0x28,0x20,0x08,0x8a,
0x28,0x20,0x08,0x8a,0x30,0x20,0x10,0x8a,0x30,0x20,0x08,0x86,0x28,0x20,0x08,0x8a,0x28,0x20,0x10,0x8a,0x30,0x20,0x08,0x8a,0x28,0x20,0x10,0x8a,0x30,0x20,0x08,0x8a,0x28,0x20,0x08,0x8a,0x28,0x20,0x10,0x86,0x30,0x20,0x08,0x8a,0x28,0x20,0x08,0x8a,0x28,0x20,0x10,0x86,0x30,0x20,0x08,0x8a,0x28,0x20,0x08,0x8a,0x28,0x20,0x08,0x86,
0x30,0x20,0x10,0x8a,0x30,0x20,0x08,0x86,0x28,0x20,0x08,0x86,0x28,0x20,0x10,0x8a,0x30,0x20,0x08,0x86,0x30,0x20,0x08,0x86,0x28,0x20,0x10,0x8a,0x30,0x20,0x08,0x8a,0x28,0x20,0x08,0x86,0x30,0x20,0x10,0x86,0x30,0x20,0x08,0x8a,0x28,0x20,0x08,0x86,0x30,0x20,0x08,0x86,0x30,0x20,0x08,0x8a,0x28,0x20,0x10,0x8a,0x30,0x20,0x08,0x8a,
0x30,0x20,0x08,0x86,0x28,0x20,0x10,0x8a,0x30,0x20,0x08,0x86,0x30,0x20,0x08,0x8a,0x28,0x20,0x10,0x8a,0x30,0x20,0x08,0x86,0x30,0x20,0x10,0x8a,0x28,0x20,0x08,0x8a,0x30,0x20,0x10,0x8a,0x30,0x20,0x08,0x8a,0x28,0x20,0x08,0x86,0x30,0x20,0x10,0x8a,0x30,0x20,0x08,0x86,0x28,0x20,0x08,0x8a,0x30,0x20,0x10,0x86,0x30,0x20,0x08,0x8a,
0x28,0x20,0x08,0x8a,0x30,0x20,0x10,0x8a,0x30,0x20,0x08,0x86,0x28,0x20,0x08,0x8a,0x30,0x20,0x10,0x8a,0x30,0x20,0x10,0x86,0x28,0x20,0x08,0x8a,0x30,0x20,0x10,0x8a,0x30,0x20,0x08,0x86,0x28,0x20,0x08,0x8a,0x30,0x20,0x10,0x8a,0x30,0x20,0x08,0x86,0x28,0x20,0x08,0x8a,0x30,0x20,0x08,0x8a,0x30,0x20,0x10,0x8a,0x28,0x20,0x08,0x8a,
0x30,0x20,0x08,0x8a,0x30,0x20,0x10,0x8a,0x28,0x20,0x08,0x8a,0x30,0x20,0x08,0x8a,0x30,0x20,0x10,0x86,0x28,0x20,0x08,0x8a,0x30,0x20,0x08,0x8a,0x30,0x20,0x10,0x8a,0x28,0x20,0x08,0x86,0x30,0x20,0x10,0x8a,0x30,0x20,0x08,0x8a,0x28,0x20,0x10,0x86,0x30,0x20,0x08,0x8a,0x30,0x20,0x10,0x8a,0x28,0x20,0x08,0x8a,0x30,0x20,0x08,0x8a,
0x30,0x20,0x10,0x8a,0x28,0x20,0x08,0x86,0x30,0x20,0x08,0x86,0x30,0x20,0x10,0x86,0x28,0x20,0x08,0x8a,0x30,0x20,0x10,0x86,0x28,0x20,0x08,0x8a,0x28,0x20,0x08,0x8a,0x30,0x20,0x10,0x86,0x28,0x20,0x08,0x8a,0x30,0x20,0x08,0x8a,0x30,0x20,0x10,0x86,0x28,0x20,0x08,0x8a,0x30,0x20,0x08,0x8a,0x28,0x20,0x10,0x8a,0x30,0x20,0x08,0x86,
0x28,0x20,0x08,0x8a,0x28,0x20,0x08,0x8a,0x30,0x20,0x10,0x86,0x28,0x20,0x08,0x8a,0x30,0x20,0x08,0x8a,0x30,0x20,0x10,0x8a,0x28,0x20,0x08,0x86,0x30,0x20,0x08,0x8a,0x30,0x20,0x10,0x8a,0x28,0x20,0x08,0x86,0x30,0x20,0x10,0x8a,0x28,0x20,0x08,0x8a,0x30,0x20,0x08,0x8a,0x28,0x20,0x10,0x8a,0x28,0x20,0x10,0x86,0x30,0x20,0x08,0x8a,
0x28,0x20,0x08,0x7d,0x30,0x20,0x08,0x82,0x30,0x20,0x10,0x7d,0x28,0x20,0x08,0x7d,0x30,0x20,0x08,0x82,0x28,0x20,0x10,0x7d,0x30,0x20,0x08,0x7d,0x30,0x20,0x08,0x82,0x28,0x20,0x10,0x7d,0x28,0x20,0x08,0x7d,0x30,0x20,0x08,0x82,0x28,0x20,0x10,0x7d,0x30,0x20,0x08,0x7d,0x28,0x20,0x08,0x82,0x30,0x20,0x10,0x7d,0x30,0x20,0x08,0x82,
0x28,0x20,0x10,0x82,0x30,0x20,0x10,0x82,0x30,0x20,0x08,0x82,0x28,0x20,0x10,0x7d,0x28,0x20,0x08,0x7d,0x30,0x20,0x08,0x82,0x30,0x20,0x10,0x82,0x28,0x20,0x10,0x82,0x28,0x20,0x08,0x82,0x30,0x20,0x08,0x82,0x28,0x20,0x10,0x82,0x28,0x20,0x08,0x7d,0x30,0x20,0x08,0x7d,0x28,0x20,0x10,0x82,0x30,0x20,0x08,0x82,0x28,0x20,0x10,0x82,
0x28,0x20,0x10,0x82,0x30,0x20,0x08,0x82,0x28,0x20,0x08,0x7d,0x30,0x20,0x10,0x7d,0x28,0x20,0x08,0x82,0x28,0x20,0x08,0x82,0x30,0x20,0x10,0x82,0x28,0x20,0x08,0x7d,0x28,0x20,0x08,0x82,0x30,0x20,0x10,0x7d,0x28,0x20,0x08,0x82,0x28,0x20,0x08,0x7d,0x30,0x20,0x10,0x7d,0x28,0x20,0x08,0x82,0x28,0x20,0x10,0x82,0x30,0x20,0x08,0x82,
0x28,0x20,0x10,0x82,0x28,0x20,0x08,0x7d,0x30,0x20,0x08,0x7d,0x28,0x20,0x10,0x82,0x28,0x20,0x08,0x7d,0x30,0x20,0x10,0x82,0x28,0x20,0x08,0x82,0x28,0x20,0x08,0x7d,0x30,0x20,0x08,0x82,0x28,0x20,0x08,0x82,0x28,0x20,0x10,0x82,0x30,0x20,0x08,0x82,0x28,0x20,0x10,0x82,0x28,0x20,0x08,0x7d,0x30,0x20,0x08,0x82,0x28,0x20,0x10,0x7d,
0x28,0x20,0x08,0x82,0x30,0x20,0x10,0x82,0x28,0x20,0x08,0x7d,0x28,0x20,0x08,0x82,0x30,0x20,0x10,0x82,0x28,0x20,0x08,0x82,0x28,0x20,0x08,0x7d,0x30,0x20,0x10,0x82,0x28,0x20,0x08,0x82,0x28,0x20,0x08,0x7d,0x30,0x20,0x10,0x7d,0x28,0x20,0x08,0x82,0x28,0x20,0x08,0x7d,0x30,0x20,0x10,0x82,0x28,0x20,0x08,0x82,0x28,0x20,0x08,0x82,
0x30,0x20,0x10,0x7d,0x28,0x20,0x08,0x82,0x28,0x20,0x08,0x7d,0x30,0x20,0x10,0x7d,0x28,0x20,0x08,0x82,0x28,0x20,0x10,0x7d,0x30,0x20,0x08,0x82,0x28,0x20,0x08,0x82,0x30,0x20,0x10,0x7d,0x30,0x20,0x08,0x7d,0x30,0x20,0x08,0x82,0x28,0x20,0x10,0x7d,0x28,0x20,0x08,0x82,0x30,0x20,0x08,0x82,0x28,0x20,0x10,0x82,0x28,0x20,0x08,0x7d,
0x30,0x20,0x08,0x7d,0x28,0x20,0x10,0x82,0x30,0x20,0x08,0x82,0x30,0x20,0x10,0x7d,0x28,0x20,0x08,0x7d,0x30,0x20,0x10,0x82,0x28,0x20,0x08,0x7d,0x28,0x20,0x08,0x7d,0x30,0x20,0x10,0x7d,0x28,0x20,0x08,0x82,0x28,0x20,0x08,0x7d,0x30,0x20,0x10,0x7d,0x28,0x20,0x08,0x82,0x30,0x20,0x08,0x82,0x28,0x20,0x10,0x7d,0x30,0x20,0x08,0x7d,
0x28,0x20,0x08,0x82,0x30,0x20,0x10,0x7d,0x28,0x20,0x08,0x82,0x28,0x20,0x08,0x7d,
0x28,0x20,0x08,0x75,0x28,0x20,0x08,0x79,0x30,0x20,0x10,0x75,0x28,0x20,0x08,0x75,0x30,0x20,0x08,0x75,0x28,0x20,0x10,0x75,0x28,0x20,0x08,0x79,0x30,0x20,0x08,0x75,0x30,0x20,0x10,0x75,0x28,0x20,0x08,0x79,0x30,0x20,0x08,0x75,0x30,0x20,0x10,0x75,
0x28,0x20,0x08,0x79,0x30,0x20,0x10,0x75,0x28,0x20,0x08,0x75,0x28,0x20,0x08,0x75,0x30,0x20,0x08,0x75,0x28,0x20,0x08,0x75,0x30,0x20,0x10,0x75,0x28,0x20,0x08,0x75,0x28,0x20,0x08,0x75,0x30,0x20,0x10,0x75,0x28,0x20,0x08,0x75,0x30,0x20,0x08,0x75,0x30,0x20,0x10,0x75,0x28,0x20,0x08,0x75,0x30,0x20,0x10,0x75,0x30,0x20,0x08,0x75,
0x28,0x20,0x10,0x79,0x28,0x20,0x08,0x75,0x30,0x20,0x08,0x75,0x30,0x20,0x10,0x75,0x28,0x20,0x08,0x75,0x28,0x20,0x08,0x75,0x30,0x20,0x10,0x75,0x28,0x20,0x08,0x75,0x30,0x20,0x08,0x75,0x30,0x20,0x10,0x75,0x28,0x20,0x08,0x75,0x30,0x20,0x10,0x75,0x30,0x20,0x08,0x75,0x28,0x20,0x08,0x75,0x30,0x20,0x10,0x79,0x30,0x20,0x08,0x75,
0x28,0x20,0x08,0x75,0x30,0x20,0x10,0x75,0x30,0x20,0x08,0x75,0x28,0x20,0x08,0x75,0x30,0x20,0x10,0x75,0x30,0x20,0x08,0x79,0x28,0x20,0x08,0x79,0x30,0x20,0x10,0x75,0x30,0x20,0x08,0x75,0x28,0x20,0x08,0x75,0x30,0x20,0x10,0x75,0x30,0x20,0x10,0x75,0x28,0x20,0x08,0x75,0x30,0x20,0x08,0x75,0x30,0x20,0x08,0x75,0x28,0x20,0x10,0x75,
0x30,0x20,0x08,0x75,0x30,0x20,0x10,0x75,0x28,0x20,0x08,0x79,0x30,0x20,0x08,0x75,0x30,0x20,0x10,0x75,0x28,0x20,0x08,0x75,0x30,0x20,0x08,0x75,0x30,0x20,0x10,0x75,0x28,0x20,0x08,0x75,0x30,0x20,0x08,0x75,0x30,0x20,0x10,0x75,0x28,0x20,0x08,0x75,0x30,0x20,0x08,0x79,0x30,0x20,0x10,0x75,0x28,0x20,0x08,0x75,0x30,0x20,0x08,0x75,
0x30,0x20,0x10,0x75,0x28,0x20,0x08,0x75,0x30,0x20,0x08,0x75,0x30,0x20,0x10,0x75,0x28,0x20,0x08,0x75,0x30,0x20,0x08,0x75,0x30,0x20,0x10,0x75,0x28,0x20,0x08,0x79,0x30,0x20,0x08,0x75,0x30,0x20,0x10,0x75,0x28,0x20,0x08,0x79,0x28,0x20,0x08,0x79,0x28,0x20,0x10,0x75,0x30,0x20,0x08,0x75,0x28,0x20,0x10,0x75,0x30,0x20,0x10,0x75,
0x30,0x20,0x08,0x75,0x28,0x20,0x08,0x75,0x30,0x20,0x10,0x75,0x28,0x20,0x08,0x75,0x30,0x20,0x10,0x75,0x28,0x20,0x08,0x75,0x28,0x20,0x08,0x79,0x30,0x20,0x10,0x75,0x30,0x20,0x08,0x75,0x28,0x20,0x08,0x79,0x30,0x20,0x10,0x79,0x30,0x20,0x08,0x75,0x28,0x20,0x10,0x79,0x30,0x20,0x08,0x75,0x30,0x20,0x08,0x75,0x28,0x20,0x10,0x75,
0x28,0x20,0x08,0x75,0x30,0x20,0x08,0x79,0x28,0x20,0x10,0x75,0x30,0x20,0x08,0x75,0x30,0x20,0x10,0x79,0x28,0x20,0x08,0x75,0x30,0x20,0x08,0x75,0x30,0x20,0x10,0x75,
0x30,0x20,0x08,0x6d,0x28,0x20,0x10,0x6d,0x28,0x20,0x08,0x6d,0x30,0x20,0x10,0x6d,0x30,0x20,0x08,0x6d,0x28,0x20,0x10,0x6d,0x28,0x20,0x08,0x6d,0x30,0x20,0x10,0x6d,
0x28,0x20,0x08,0x6d,0x30,0x20,0x10,0x6d,0x28,0x20,0x08,0x6d,0x28,0x20,0x08,0x6d,0x30,0x20,0x10,0x6d,0x30,0x20,0x08,0x6d,0x28,0x20,0x10,0x6d,0x30,0x20,0x08,0x6d,0x28,0x20,0x08,0x6d,0x28,0x20,0x10,0x6d,0x30,0x20,0x08,0x6d,0x30,0x20,0x08,0x6d,0x30,0x20,0x10,0x71,0x28,0x20,0x08,0x6d,0x28,0x20,0x08,0x6d,0x30,0x20,0x10,0x6d,
0x28,0x20,0x08,0x6d,0x28,0x20,0x08,0x6d,0x30,0x20,0x08,0x6d,0x30,0x20,0x10,0x6d,0x28,0x20,0x08,0x6d,0x30,0x20,0x08,0x6d,0x28,0x20,0x10,0x6d,0x30,0x20,0x08,0x6d,0x30,0x20,0x08,0x6d,0x28,0x20,0x10,0x6d,0x30,0x20,0x08,0x6d,0x28,0x20,0x08,0x71,0x30,0x20,0x10,0x6d,0x28,0x20,0x08,0x6d,0x28,0x20,0x08,0x6d,0x30,0x20,0x10,0x6d,
0x28,0x20,0x08,0x6d,0x28,0x20,0x08,0x6d,0x30,0x20,0x10,0x6d,0x28,0x20,0x08,0x6d,0x28,0x20,0x08,0x6d,0x30,0x20,0x10,0x6d,0x28,0x20,0x08,0x6d,0x28,0x20,0x08,0x6d,0x30,0x20,0x10,0x6d,0x28,0x20,0x08,0x6d,0x28,0x20,0x10,0x6d,0x30,0x20,0x08,0x6d,0x28,0x20,0x08,0x6d,0x28,0x20,0x08,0x6d,0x30,0x20,0x10,0x6d,0x28,0x20,0x08,0x6d,
0x28,0x20,0x10,0x6d,0x30,0x20,0x10,0x6d,0x28,0x20,0x08,0x6d,0x28,0x20,0x08,0x6d,0x30,0x20,0x10,0x6d,0x28,0x20,0x08,0x6d,0x28,0x20,0x10,0x6d,0x30,0x20,0x08,0x6d,0x28,0x20,0x10,0x6d,0x28,0x20,0x08,0x6d,0x30,0x20,0x10,0x6d,0x28,0x20,0x10,0x6d,0x28,0x20,0x08,0x6d,0x30,0x20,0x10,0x6d,0x28,0x20,0x08,0x6d,0x28,0x20,0x10,0x6d,
0x30,0x20,0x08,0x6d,0x28,0x20,0x10,0x6d,0x28,0x20,0x08,0x6d,0x30,0x20,0x10,0x6d,0x28,0x20,0x08,0x6d,0x28,0x20,0x08,0x6d,0x30,0x20,0x10,0x6d,0x28,0x20,0x08,0x6d,0x28,0x20,0x08,0x6d,0x30,0x20,0x10,0x6d,0x28,0x20,0x10,0x6d,0x28,0x20,0x08,0x6d,0x30,0x20,0x08,0x6d,0x30,0x20,0x10,0x6d,0x28,0x20,0x08,0x6d,0x30,0x20,0x10,0x6d,
0x30,0x20,0x08,0x6d,0x28,0x20,0x08,0x6d,0x28,0x20,0x08,0x6d,0x30,0x20,0x08,0x6d,0x28,0x20,0x10,0x6d,0x30,0x20,0x08,0x6d,0x28,0x20,0x08,0x6d,0x30,0x20,0x10,0x71,0x30,0x20,0x08,0x6d,0x28,0x20,0x08,0x6d,0x28,0x20,0x10,0x6d,0x30,0x20,0x08,0x6d,0x28,0x20,0x08,0x6d,0x28,0x20,0x10,0x6d,0x30,0x20,0x08,0x6d,0x28,0x20,0x08,0x6d,
0x28,0x20,0x10,0x6d,0x30,0x20,0x08,0x6d,0x30,0x20,0x10,0x6d,0x28,0x20,0x08,0x6d,0x30,0x20,0x10,0x6d,0x30,0x20,0x08,0x6d,0x28,0x20,0x08,0x6d,0x28,0x20,0x10,0x6d,0x30,0x20,0x08,0x6d,0x28,0x20,0x08,0x6d,0x28,0x20,0x10,0x6d,0x30,0x20,0x08,0x6d,
0x30,0x20,0x08,0x65,0x30,0x20,0x10,0x65,0x28,0x20,0x08,0x65,0x30,0x20,0x08,0x65,
0x28,0x20,0x10,0x65,0x30,0x20,0x08,0x65,0x30,0x20,0x08,0x65,0x28,0x20,0x08,0x65,0x30,0x20,0x10,0x65,0x28,0x20,0x08,0x65,0x30,0x20,0x10,0x65,0x28,0x20,0x08,0x69,0x28,0x20,0x08,0x65,0x30,0x20,0x10,0x65,0x28,0x20,0x08,0x65,0x30,0x20,0x10,0x65,0x30,0x20,0x10,0x65,0x28,0x20,0x08,0x65,0x28,0x20,0x08,0x65,0x30,0x20,0x10,0x65,
0x28,0x20,0x10,0x65,0x30,0x20,0x08,0x65,0x30,0x20,0x08,0x65,0x28,0x20,0x10,0x65,0x30,0x20,0x08,0x65,0x28,0x20,0x10,0x65,0x28,0x20,0x08,0x65,0x30,0x20,0x08,0x65,0x28,0x20,0x10,0x65,0x30,0x20,0x08,0x65,0x28,0x20,0x10,0x65,0x28,0x20,0x08,0x65,0x30,0x20,0x08,0x65,0x30,0x20,0x10,0x65,0x28,0x20,0x08,0x65,0x30,0x20,0x10,0x65,
0x28,0x20,0x10,0x65,0x30,0x20,0x08,0x65,0x30,0x20,0x08,0x65,0x28,0x20,0x10,0x65,0x30,0x20,0x08,0x65,0x30,0x20,0x10,0x65,0x28,0x20,0x08,0x65,0x30,0x20,0x10,0x65,0x30,0x20,0x08,0x65,0x28,0x20,0x10,0x65,0x30,0x20,0x08,0x65,0x30,0x20,0x10,0x65,0x28,0x20,0x08,0x65,0x30,0x20,0x08,0x65,0x30,0x20,0x10,0x65,0x28,0x20,0x10,0x65,
0x30,0x20,0x10,0x65,0x30,0x20,0x08,0x65,0x28,0x20,0x08,0x65,0x30,0x20,0x08,0x65,0x30,0x20,0x08,0x65,0x28,0x20,0x10,0x65,0x30,0x20,0x08,0x65,0x30,0x20,0x08,0x65,0x28,0x20,0x10,0x65,0x30,0x20,0x08,0x65,0x30,0x20,0x08,0x65,0x28,0x20,0x10,0x65,0x30,0x20,0x08,0x65,0x30,0x20,0x08,0x65,0x28,0x20,0x08,0x65,0x30,0x20,0x08,0x65,
0x30,0x20,0x08,0x65,0x28,0x20,0x10,0x65,0x30,0x20,0x08,0x65,0x30,0x20,0x08,0x65,0x28,0x20,0x10,0x65,0x30,0x20,0x08,0x65,0x30,0x20,0x08,0x65,0x28,0x20,0x10,0x65,0x30,0x20,0x08,0x65,0x30,0x20,0x10,0x65,0x28,0x20,0x10,0x65,0x30,0x20,0x08,0x65,0x30,0x20,0x08,0x65,0x28,0x20,0x10,0x65,0x30,0x20,0x08,0x65,0x28,0x20,0x08,0x65,
0x28,0x20,0x10,0x65,0x30,0x20,0x08,0x65,0x28,0x20,0x08,0x65,0x30,0x20,0x10,0x65,0x30,0x20,0x08,0x65,0x28,0x20,0x10,0x65,0x30,0x20,0x08,0x65,0x28,0x20,0x08,0x65,0x30,0x20,0x10,0x65,0x28,0x20,0x08,0x69,0x28,0x20,0x08,0x65,0x30,0x20,0x10,0x65,0x28,0x20,0x08,0x65,0x30,0x20,0x10,0x65,0x30,0x20,0x08,0x65,0x28,0x20,0x08,0x65,
0x30,0x20,0x10,0x65,0x30,0x20,0x10,0x65,0x28,0x20,0x08,0x65,0x30,0x20,0x08,0x65,0x28,0x20,0x10,0x65,0x28,0x20,0x08,0x65,0x30,0x20,0x08,0x65,0x28,0x20,0x10,0x65,0x28,0x20,0x08,0x65,0x30,0x20,0x10,0x65,0x28,0x20,0x08,0x65,0x30,0x20,0x08,0x65,0x30,0x20,0x10,0x65,0x28,0x20,0x08,0x65,0x30,0x20,0x08,0x65,0x28,0x20,0x10,0x65,
0x28,0x20,0x08,0x5d,0x28,0x20,0x08,0x5d,0x30,0x20,0x10,0x5d,0x28,0x20,0x08,0x5d,0x28,0x20,0x08,0x5d,0x30,0x20,0x10,0x5d,0x28,0x20,0x08,0x5d,0x30,0x20,0x10,0x5d,0x28,0x20,0x08,0x5d,0x30,0x20,0x08,0x5d,0x30,0x20,0x10,0x5d,0x28,0x20,0x08,0x5d,0x30,0x20,0x08,0x5d,0x28,0x20,0x10,0x5d,0x28,0x20,0x08,0x5d,0x30,0x20,0x08,0x5d,
0x30,0x20,0x10,0x5d,0x28,0x20,0x08,0x5d,0x30,0x20,0x08,0x5d,0x28,0x20,0x10,0x5d,0x28,0x20,0x08,0x5d,0x30,0x20,0x08,0x5d,0x28,0x20,0x10,0x5d,0x30,0x20,0x08,0x5d,0x30,0x20,0x08,0x5d,0x28,0x20,0x10,0x5d,0x30,0x20,0x10,0x5d,0x28,0x20,0x08,0x5d,0x30,0x20,0x08,0x5d,0x28,0x20,0x10,0x5d,0x30,0x20,0x08,0x5d,0x28,0x20,0x08,0x5d,
0x28,0x20,0x10,0x5d,0x30,0x20,0x08,0x5d,0x28,0x20,0x08,0x5d,0x28,0x20,0x08,0x5d,0x30,0x20,0x10,0x5d,0x28,0x20,0x08,0x5d,0x30,0x20,0x08,0x5d,0x28,0x20,0x10,0x5d,0x28,0x20,0x08,0x5d,0x30,0x20,0x08,0x5d,0x28,0x20,0x10,0x5d,0x30,0x20,0x08,0x5d,0x28,0x20,0x08,0x5d,0x28,0x20,0x08,0x5d,0x30,0x20,0x10,0x5d,0x28,0x20,0x08,0x5d,
0x28,0x20,0x08,0x5d,0x30,0x20,0x10,0x5d,0x28,0x20,0x08,0x5d,0x28,0x20,0x08,0x5d,0x30,0x20,0x08,0x5d,0x28,0x20,0x10,0x5d,0x28,0x20,0x10,0x5d,0x30,0x20,0x08,0x5d,0x28,0x20,0x08,0x5d,0x28,0x20,0x10,0x5d,0x30,0x20,0x08,0x5d,0x28,0x20,0x08,0x5d,0x28,0x20,0x10,0x5d,0x30,0x20,0x08,0x5d,0x28,0x20,0x08,0x5d,0x28,0x20,0x10,0x5d,
0x30,0x20,0x08,0x5d,0x28,0x20,0x10,0x5d,0x28,0x20,0x10,0x5d,0x30,0x20,0x08,0x5d,0x28,0x20,0x08,0x5d,0x28,0x20,0x10,0x5d,0x30,0x20,0x08,0x5d,0x28,0x20,0x08,0x5d,0x28,0x20,0x10,0x5d,0x30,0x20,0x08,0x5d,0x28,0x20,0x08,0x5d,0x28,0x20,0x10,0x5d,0x30,0x20,0x08,0x5d,0x28,0x20,0x08,0x5d,0x28,0x20,0x08,0x5d,0x30,0x20,0x10,0x5d,
0x28,0x20,0x08,0x5d,0x30,0x20,0x08,0x5d,0x30,0x20,0x08,0x5d,0x30,0x20,0x10,0x5d,0x28,0x20,0x08,0x5d,0x28,0x20,0x08,0x5d,0x30,0x20,0x10,0x5d,0x28,0x20,0x08,0x5d,0x28,0x20,0x08,0x5d,0x30,0x20,0x10,0x5d,0x28,0x20,0x10,0x5d,0x30,0x20,0x08,0x5d,0x30,0x20,0x10,0x5d,0x28,0x20,0x08,0x5d,0x30,0x20,0x10,0x5d,0x28,0x20,0x08,0x5d,
0x28,0x20,0x08,0x5d,0x30,0x20,0x10,0x5d,0x28,0x20,0x08,0x5d,0x28,0x20,0x08,0x5d,0x30,0x20,0x10,0x5d,0x28,0x20,0x08,0x5d,0x30,0x20,0x08,0x5d,0x30,0x20,0x10,0x5d,0x28,0x20,0x08,0x5d,0x30,0x20,0x08,0x5d,0x30,0x20,0x10,0x5d,0x28,0x20,0x08,0x5d,0x30,0x20,0x08,0x5d,0x28,0x20,0x10,0x5d,0x30,0x20,0x08,0x5d,0x28,0x20,0x08,0x5d,
0x28,0x20,0x10,0x5d,0x30,0x20,0x08,0x5d,0x30,0x20,0x08,0x5d,0x28,0x20,0x10,0x5d,
0x28,0x20,0x08,0x55,0x30,0x20,0x10,0x55,0x30,0x20,0x08,0x55,0x28,0x20,0x10,0x55,0x30,0x20,0x08,0x55,0x28,0x20,0x08,0x55,0x30,0x20,0x10,0x55,0x28,0x20,0x08,0x55,0x28,0x20,0x08,0x55,0x30,0x20,0x10,0x55,0x28,0x20,0x08,0x55,0x30,0x20,0x08,0x55,
0x30,0x20,0x10,0x55,0x28,0x20,0x08,0x55,0x30,0x20,0x08,0x55,0x28,0x20,0x08,0x55,0x28,0x20,0x10,0x55,0x30,0x20,0x08,0x55,0x30,0x20,0x08,0x55,0x28,0x20,0x10,0x55,0x30,0x20,0x08,0x55,0x28,0x20,0x08,0x55,0x28,0x20,0x10,0x55,0x30,0x20,0x08,0x55,0x28,0x20,0x08,0x55,0x30,0x20,0x08,0x55,0x28,0x20,0x10,0x51,0x30,0x20,0x08,0x55,
0x28,0x20,0x08,0x55,0x30,0x20,0x10,0x51,0x30,0x20,0x08,0x55,0x28,0x20,0x10,0x55,0x30,0x20,0x08,0x55,0x30,0x20,0x10,0x55,0x28,0x20,0x08,0x51,0x30,0x20,0x08,0x55,0x30,0x20,0x10,0x55,0x28,0x20,0x08,0x55,0x28,0x20,0x08,0x55,0x30,0x20,0x10,0x55,0x30,0x20,0x08,0x55,0x28,0x20,0x08,0x55,0x30,0x20,0x10,0x55,0x28,0x20,0x08,0x55,
0x30,0x20,0x10,0x55,0x30,0x20,0x08,0x55,0x28,0x20,0x10,0x55,0x30,0x20,0x08,0x55,0x30,0x20,0x08,0x55,0x28,0x20,0x10,0x55,0x30,0x20,0x08,0x55,0x30,0x20,0x08,0x55,0x28,0x20,0x08,0x55,0x30,0x20,0x10,0x51,0x30,0x20,0x08,0x55,0x28,0x20,0x08,0x55,0x30,0x20,0x10,0x55,0x30,0x20,0x08,0x51,0x28,0x20,0x10,0x55,0x30,0x20,0x08,0x55,
0x30,0x20,0x08,0x55,0x28,0x20,0x10,0x55,0x30,0x20,0x08,0x55,0x30,0x20,0x08,0x55,0x28,0x20,0x10,0x55,0x30,0x20,0x08,0x55,0x30,0x20,0x08,0x55,0x28,0x20,0x10,0x55,0x30,0x20,0x08,0x55,0x30,0x20,0x08,0x55,0x28,0x20,0x10,0x55,0x30,0x20,0x08,0x55,0x30,0x20,0x10,0x55,0x28,0x20,0x08,0x55,0x30,0x20,0x08,0x55,0x30,0x20,0x10,0x55,
0x28,0x20,0x08,0x55,0x30,0x20,0x08,0x55,0x30,0x20,0x10,0x55,0x28,0x20,0x08,0x55,0x28,0x20,0x10,0x55,0x28,0x20,0x08,0x55,0x30,0x20,0x10,0x55,0x28,0x20,0x08,0x55,0x30,0x20,0x10,0x55,0x30,0x20,0x08,0x55,0x28,0x20,0x10,0x55,0x30,0x20,0x08,0x55,0x28,0x20,0x08,0x55,0x30,0x20,0x10,0x55,0x28,0x20,0x08,0x55,0x28,0x20,0x08,0x55,
0x30,0x20,0x08,0x55,0x30,0x20,0x10,0x55,0x28,0x20,0x08,0x55,0x30,0x20,0x08,0x55,0x30,0x20,0x10,0x55,0x28,0x20,0x08,0x55,0x30,0x20,0x10,0x55,0x30,0x20,0x08,0x55,0x28,0x20,0x08,0x55,0x28,0x20,0x10,0x55,0x30,0x20,0x08,0x55,0x28,0x20,0x08,0x55,0x28,0x20,0x10,0x55,0x30,0x20,0x08,0x55,0x28,0x20,0x10,0x55,0x30,0x20,0x08,0x55,
0x28,0x20,0x08,0x55,0x30,0x20,0x10,0x55,0x30,0x20,0x08,0x55,0x28,0x20,0x10,0x55,0x28,0x20,0x08,0x55,0x30,0x20,0x10,0x55,0x28,0x20,0x08,0x55,0x30,0x20,0x08,0x55,
0x30,0x20,0x08,0x49,0x28,0x20,0x08,0x4d,0x30,0x20,0x10,0x4d,0x30,0x20,0x08,0x4d,0x28,0x20,0x10,0x4d,0x30,0x20,0x08,0x4d,0x30,0x20,0x08,0x4d,0x28,0x20,0x10,0x4d,
0x30,0x20,0x08,0x49,0x28,0x20,0x10,0x4d,0x28,0x20,0x08,0x4d,0x30,0x20,0x10,0x49,0x28,0x20,0x08,0x4d,0x30,0x20,0x10,0x4d,0x30,0x20,0x08,0x4d,0x28,0x20,0x10,0x49,0x28,0x20,0x08,0x49,0x30,0x20,0x08,0x49,0x28,0x20,0x10,0x4d,0x30,0x20,0x08,0x4d,0x30,0x20,0x08,0x4d,0x28,0x20,0x10,0x49,0x30,0x20,0x08,0x4d,0x28,0x20,0x10,0x49,
0x28,0x20,0x10,0x4d,0x30,0x20,0x08,0x4d,0x30,0x20,0x08,0x49,0x28,0x20,0x10,0x49,0x28,0x20,0x08,0x4d,0x30,0x20,0x08,0x49,0x28,0x20,0x10,0x49,0x28,0x20,0x08,0x4d,0x30,0x20,0x08,0x49,0x28,0x20,0x10,0x49,0x28,0x20,0x10,0x4d,0x30,0x20,0x08,0x49,0x28,0x20,0x08,0x4d,0x30,0x20,0x10,0x49,0x30,0x20,0x08,0x49,0x28,0x20,0x10,0x4d,
0x28,0x20,0x08,0x4d,0x30,0x20,0x10,0x49,0x28,0x20,0x08,0x49,0x28,0x20,0x08,0x4d,0x30,0x20,0x10,0x49,0x28,0x20,0x08,0x4d,0x28,0x20,0x08,0x49,0x30,0x20,0x10,0x4d,0x28,0x20,0x08,0x4d,0x28,0x20,0x08,0x49,0x30,0x20,0x10,0x4d,0x28,0x20,0x10,0x4d,0x28,0x20,0x08,0x49,0x30,0x20,0x08,0x49,0x28,0x20,0x10,0x4d,0x28,0x20,0x08,0x4d,
0x30,0x20,0x08,0x4d,0x28,0x20,0x10,0x49,0x28,0x20,0x08,0x4d,0x30,0x20,0x10,0x49,0x28,0x20,0x08,0x4d,0x28,0x20,0x10,0x49,0x30,0x20,0x08,0x4d,0x28,0x20,0x08,0x49,0x28,0x20,0x10,0x49,0x30,0x20,0x08,0x4d,0x28,0x20,0x08,0x4d,0x28,0x20,0x10,0x49,0x30,0x20,0x08,0x49,0x28,0x20,0x10,0x4d,0x28,0x20,0x08,0x49,0x30,0x20,0x08,0x4d,
0x28,0x20,0x10,0x4d,0x28,0x20,0x08,0x4d,0x30,0x20,0x10,0x4d,0x28,0x20,0x08,0x4d,0x28,0x20,0x10,0x49,0x30,0x20,0x08,0x49,0x30,0x20,0x08,0x4d,0x28,0x20,0x10,0x4d,0x30,0x20,0x08,0x4d,0x30,0x20,0x10,0x4d,0x28,0x20,0x08,0x4d,0x28,0x20,0x08,0x49,0x30,0x20,0x10,0x4d,0x28,0x20,0x08,0x49,0x30,0x20,0x08,0x49,0x28,0x20,0x10,0x4d,
0x30,0x20,0x08,0x4d,0x30,0x20,0x08,0x49,0x28,0x20,0x10,0x49,0x28,0x20,0x08,0x4d,0x30,0x20,0x08,0x49,0x28,0x20,0x10,0x49,0x28,0x20,0x08,0x4d,0x30,0x20,0x10,0x4d,0x28,0x20,0x08,0x49,0x28,0x20,0x08,0x49,0x30,0x20,0x10,0x4d,0x30,0x20,0x08,0x49,0x28,0x20,0x08,0x49,0x30,0x20,0x10,0x4d,0x30,0x20,0x08,0x4d,0x28,0x20,0x08,0x49,
0x30,0x20,0x10,0x4d,0x28,0x20,0x08,0x49,0x30,0x20,0x08,0x4d,0x28,0x20,0x10,0x4d,0x28,0x20,0x08,0x4d,0x30,0x20,0x08,0x49,0x28,0x20,0x10,0x4d,0x30,0x20,0x08,0x49,0x30,0x20,0x08,0x49,0x28,0x20,0x10,0x4d,0x28,0x20,0x08,0x4d,0x30,0x20,0x08,0x49,
0x28,0x20,0x08,0x41,0x28,0x20,0x10,0x45,0x28,0x20,0x08,0x41,0x30,0x20,0x08,0x41,
0x28,0x20,0x10,0x45,0x28,0x20,0x08,0x41,0x30,0x20,0x10,0x45,0x28,0x20,0x08,0x41,0x30,0x20,0x08,0x45,0x30,0x20,0x08,0x45,0x28,0x20,0x10,0x45,0x30,0x20,0x08,0x41,0x28,0x20,0x08,0x41,0x28,0x20,0x10,0x41,0x30,0x20,0x08,0x41,0x30,0x20,0x08,0x45,0x28,0x20,0x10,0x45,0x30,0x20,0x08,0x41,0x28,0x20,0x10,0x41,0x28,0x20,0x08,0x41,
0x30,0x20,0x10,0x41,0x30,0x20,0x08,0x41,0x28,0x20,0x08,0x45,0x30,0x20,0x08,0x45,0x30,0x20,0x10,0x45,0x28,0x20,0x08,0x41,0x30,0x20,0x08,0x45,0x28,0x20,0x10,0x45,0x30,0x20,0x08,0x41,0x30,0x20,0x08,0x45,0x28,0x20,0x10,0x45,0x30,0x20,0x08,0x45,0x30,0x20,0x08,0x41,0x28,0x20,0x08,0x45,0x30,0x20,0x10,0x45,0x28,0x20,0x08,0x41,
0x28,0x20,0x08,0x45,0x30,0x20,0x10,0x41,0x30,0x20,0x08,0x45,0x28,0x20,0x08,0x41,0x30,0x20,0x10,0x45,0x30,0x20,0x08,0x41,0x28,0x20,0x08,0x41,0x30,0x20,0x10,0x45,0x30,0x20,0x08,0x45,0x28,0x20,0x08,0x41,0x30,0x20,0x10,0x45,0x30,0x20,0x10,0x41,0x28,0x20,0x08,0x41,0x30,0x20,0x08,0x45,0x30,0x20,0x10,0x45,0x28,0x20,0x08,0x41,
0x30,0x20,0x08,0x45,0x30,0x20,0x10,0x41,0x28,0x20,0x08,0x41,0x30,0x20,0x10,0x41,0x30,0x20,0x08,0x45,0x28,0x20,0x08,0x45,0x30,0x20,0x10,0x41,0x30,0x20,0x08,0x45,0x28,0x20,0x08,0x45,0x30,0x20,0x10,0x45,0x30,0x20,0x08,0x41,0x28,0x20,0x10,0x45,0x30,0x20,0x08,0x41,0x30,0x20,0x08,0x45,0x28,0x20,0x10,0x45,0x30,0x20,0x08,0x45,
0x30,0x20,0x08,0x41,0x28,0x20,0x10,0x45,0x30,0x20,0x08,0x45,0x30,0x20,0x08,0x41,0x28,0x20,0x10,0x41,0x30,0x20,0x08,0x45,0x30,0x20,0x08,0x41,0x28,0x20,0x10,0x45,0x30,0x20,0x08,0x45,0x28,0x20,0x10,0x45,0x28,0x20,0x08,0x41,0x30,0x20,0x08,0x45,0x30,0x20,0x08,0x41,0x28,0x20,0x10,0x41,0x30,0x20,0x08,0x41,0x30,0x20,0x08,0x45,
0x28,0x20,0x10,0x41,0x28,0x20,0x08,0x45,0x30,0x20,0x08,0x41,0x28,0x20,0x10,0x41,0x28,0x20,0x08,0x45,0x30,0x20,0x08,0x45,0x30,0x20,0x10,0x41,0x28,0x20,0x10,0x45,0x30,0x20,0x08,0x45,0x30,0x20,0x08,0x45,0x28,0x20,0x10,0x41,0x30,0x20,0x08,0x41,0x30,0x20,0x08,0x45,0x28,0x20,0x10,0x41,0x28,0x20,0x08,0x45,0x30,0x20,0x10,0x41,
0x28,0x20,0x08,0x41,0x28,0x20,0x10,0x45,0x30,0x20,0x08,0x41,0x28,0x20,0x10,0x45,0x30,0x20,0x08,0x41,0x30,0x20,0x08,0x45,0x28,0x20,0x10,0x41,0x30,0x20,0x08,0x41,0x30,0x20,0x10,0x41,0x28,0x20,0x08,0x45,0x28,0x20,0x10,0x41,0x30,0x20,0x08,0x45,0x30,0x20,0x08,0x41,0x28,0x20,0x10,0x45,0x30,0x20,0x10,0x41,0x28,0x20,0x08,0x45,
0x30,0x20,0x08,0x3c,0x30,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x08,0x3c,0x30,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x08,0x3c,0x30,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x10,0x3c,
0x30,0x20,0x08,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x08,0x3c,0x28,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x08,0x3c,0x28,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x10,0x3c,
0x28,0x20,0x08,0x3c,0x30,0x20,0x08,0x3c,0x30,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x28,0x20,0x10,0x3c,0x30,0x20,0x08,0x3c,0x28,0x20,0x08,0x3c,0x28,0x20,0x08,0x3c,
0x30,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x08,0x3c,0x28,0x20,0x10,0x3c,0x30,0x20,0x08,0x3c,0x28,0x20,0x08,0x3c,0x28,0x20,0x10,0x3c,0x30,0x20,0x08,0x3c,0x28,0x20,0x08,0x3c,0x28,0x20,0x10,0x3c,0x30,0x20,0x08,0x3c,0x28,0x20,0x08,0x3c,0x28,0x20,0x10,0x3c,
0x30,0x20,0x08,0x3c,0x28,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x08,0x3c,0x28,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x08,0x3c,0x30,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x28,0x20,0x10,0x3c,0x30,0x20,0x08,0x3c,
0x28,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x08,0x3c,0x28,0x20,0x10,0x3c,0x30,0x20,0x08,0x3c,0x30,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x08,0x3c,0x28,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x08,0x3c,0x28,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x08,0x3c,
0x30,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x08,0x3c,0x30,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x08,0x3c,0x28,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x08,0x3c,0x28,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x08,0x3c,0x30,0x20,0x10,0x3c,0x28,0x20,0x08,0x3c,0x30,0x20,0x08,0x3c,0x28,0x20,0x10,0x3c,
0x28,0x20,0x08,0x3c,0x30,0x20,0x08,0x3c,0x30,0x20,0x08,0x3c,0x28,0x20,0x10,0x3c,
0x28,0x20,0x08,0x34,0x30,0x20,0x08,0x34,0x28,0x20,0x10,0x34,0x28,0x20,0x08,0x34,0x30,0x20,0x08,0x34,0x30,0x20,0x10,0x34,0x28,0x20,0x08,0x34,0x30,0x20,0x08,0x34,0x28,0x20,0x10,0x30,0x28,0x20,0x08,0x34,0x30,0x20,0x08,0x34,0x28,0x20,0x10,0x34,
0x30,0x20,0x08,0x34,0x28,0x20,0x08,0x34,0x30,0x20,0x10,0x34,0x28,0x20,0x10,0x34,0x28,0x20,0x08,0x34,0x30,0x20,0x08,0x34,0x30,0x20,0x10,0x34,0x28,0x20,0x08,0x34,0x30,0x20,0x08,0x34,0x28,0x20,0x10,0x34,0x30,0x20,0x10,0x34,0x28,0x20,0x08,0x30,0x30,0x20,0x10,0x34,0x30,0x20,0x08,0x34,0x28,0x20,0x10,0x34,0x30,0x20,0x08,0x34,
0x30,0x20,0x08,0x34,0x28,0x20,0x10,0x34,0x30,0x20,0x08,0x34,0x28,0x20,0x08,0x34,0x28,0x20,0x10,0x34,0x30,0x20,0x08,0x34,0x28,0x20,0x08,0x34,0x30,0x20,0x10,0x34,0x30,0x20,0x08,0x34,0x28,0x20,0x08,0x34,0x30,0x20,0x10,0x34,0x30,0x20,0x08,0x34,0x28,0x20,0x08,0x34,0x30,0x20,0x10,0x34,0x30,0x20,0x08,0x34,0x28,0x20,0x08,0x34,
0x30,0x20,0x10,0x34,0x30,0x20,0x10,0x34,0x28,0x20,0x08,0x34,0x30,0x20,0x08,0x34,0x30,0x20,0x10,0x34,0x28,0x20,0x08,0x34,0x30,0x20,0x08,0x34,0x28,0x20,0x10,0x34,0x30,0x20,0x08,0x34,0x28,0x20,0x08,0x34,0x28,0x20,0x10,0x34,0x30,0x20,0x08,0x34,0x30,0x20,0x10,0x34,0x28,0x20,0x08,0x34,0x30,0x20,0x08,0x34,0x30,0x20,0x10,0x34,
0x28,0x20,0x08,0x34,0x30,0x20,0x08,0x34,0x30,0x20,0x10,0x34,0x28,0x20,0x08,0x34,0x30,0x20,0x08,0x34,0x30,0x20,0x10,0x34,0x28,0x20,0x08,0x34,0x30,0x20,0x10,0x34,0x30,0x20,0x08,0x34,0x28,0x20,0x08,0x34,0x30,0x20,0x10,0x34,0x30,0x20,0x08,0x34,0x28,0x20,0x08,0x34,0x30,0x20,0x10,0x34,0x28,0x20,0x08,0x34,0x28,0x20,0x08,0x34,
0x30,0x20,0x10,0x34,0x30,0x20,0x08,0x34,0x28,0x20,0x08,0x34,0x30,0x20,0x10,0x34,0x28,0x20,0x08,0x34,0x30,0x20,0x08,0x34,0x28,0x20,0x10,0x34,0x28,0x20,0x08,0x34,0x30,0x20,0x08,0x34,0x28,0x20,0x10,0x34,0x30,0x20,0x08,0x34,0x30,0x20,0x08,0x34,0x28,0x20,0x10,0x34,0x30,0x20,0x08,0x34,0x30,0x20,0x08,0x34,0x28,0x20,0x10,0x34,
0x30,0x20,0x08,0x34,0x30,0x20,0x10,0x34,0x28,0x20,0x08,0x34,0x28,0x20,0x10,0x34,0x30,0x20,0x08,0x34,0x28,0x20,0x08,0x34,0x28,0x20,0x10,0x34,0x30,0x20,0x08,0x34,0x28,0x20,0x08,0x34,0x30,0x20,0x10,0x34,0x30,0x20,0x08,0x34,0x28,0x20,0x08,0x34,0x30,0x20,0x10,0x34,0x28,0x20,0x10,0x34,0x28,0x20,0x08,0x34,0x30,0x20,0x08,0x34,
0x28,0x20,0x10,0x34,0x28,0x20,0x08,0x34,0x30,0x20,0x08,0x34,0x30,0x20,0x10,0x34,0x28,0x20,0x10,0x34,0x28,0x20,0x08,0x34,0x30,0x20,0x08,0x34,0x28,0x20,0x08,0x34,
0x28,0x20,0x08,0x2c,0x30,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x10,0x2c,0x28,0x20,0x08,0x2c,0x30,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x08,0x2c,
0x30,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x10,0x2c,0x28,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,0x30,0x20,0x10,0x2c,0x28,0x20,0x08,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x08,0x2c,0x30,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x08,0x2c,0x28,0x20,0x08,0x2c,0x30,0x20,0x10,0x2c,
0x28,0x20,0x08,0x2c,0x28,0x20,0x08,0x2c,0x30,0x20,0x10,0x2c,0x28,0x20,0x08,0x2c,0x28,0x20,0x08,0x2c,0x30,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x08,0x2c,0x30,0x20,0x10,0x2c,0x28,0x20,0x10,0x2c,0x28,0x20,0x08,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x10,0x2c,0x28,0x20,0x08,0x2c,0x30,0x20,0x10,0x2c,0x28,0x20,0x08,0x2c,
0x28,0x20,0x10,0x2c,0x30,0x20,0x10,0x2c,0x28,0x20,0x08,0x2c,0x28,0x20,0x08,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x10,0x2c,0x28,0x20,0x08,0x2c,0x30,0x20,0x10,0x2c,0x28,0x20,0x08,0x2c,0x30,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,0x30,0x20,0x10,0x2c,0x28,0x20,0x08,0x2c,0x30,0x20,0x08,0x2c,
0x28,0x20,0x10,0x2c,0x28,0x20,0x08,0x2c,0x30,0x20,0x10,0x2c,0x28,0x20,0x08,0x2c,0x28,0x20,0x08,0x2c,0x30,0x20,0x10,0x2c,0x28,0x20,0x08,0x2c,0x28,0x20,0x08,0x2c,0x30,0x20,0x10,0x2c,0x28,0x20,0x08,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x08,0x2c,0x28,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,
0x30,0x20,0x10,0x2c,0x28,0x20,0x08,0x2c,0x30,0x20,0x10,0x2c,0x28,0x20,0x08,0x2c,0x28,0x20,0x08,0x2c,0x30,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x08,0x2c,0x30,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x08,0x2c,0x28,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x08,0x2c,
0x28,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x08,0x2c,0x28,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x08,0x2c,0x30,0x20,0x10,0x2c,0x28,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x08,0x2c,0x28,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,0x30,0x20,0x08,0x2c,
0x28,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,0x28,0x20,0x10,0x2c,0x30,0x20,0x08,0x2c,
0x28,0x20,0x08,0x24,0x30,0x20,0x08,0x24,0x30,0x20,0x10,0x24,0x28,0x20,0x08,0x24,
0x28,0x20,0x08,0x24,0x30,0x20,0x10,0x24,0x28,0x20,0x08,0x24,0x28,0x20,0x10,0x24,0x30,0x20,0x08,0x24,0x30,0x20,0x08,0x24,0x28,0x20,0x08,0x24,0x30,0x20,0x08,0x24,0x28,0x20,0x10,0x28,0x28,0x20,0x08,0x24,0x30,0x20,0x08,0x24,0x28,0x20,0x08,0x24,0x30,0x20,0x10,0x28,0x28,0x20,0x08,0x24,0x28,0x20,0x10,0x24,0x30,0x20,0x10,0x24,
0x28,0x20,0x08,0x24,0x30,0x20,0x08,0x24,0x30,0x20,0x10,0x28,0x28,0x20,0x08,0x24,0x30,0x20,0x08,0x24,0x30,0x20,0x10,0x24,0x28,0x20,0x08,0x24,0x30,0x20,0x10,0x24,0x28,0x20,0x08,0x24,0x28,0x20,0x10,0x24,0x30,0x20,0x08,0x24,0x28,0x20,0x08,0x24,0x30,0x20,0x10,0x24,0x30,0x20,0x08,0x24,0x28,0x20,0x08,0x24,0x30,0x20,0x10,0x24,
0x28,0x20,0x08,0x24,0x30,0x20,0x08,0x24,0x30,0x20,0x10,0x24,0x28,0x20,0x10,0x28,0x30,0x20,0x08,0x24,0x30,0x20,0x08,0x24,0x28,0x20,0x10,0x28,0x30,0x20,0x08,0x24,0x30,0x20,0x08,0x24,0x28,0x20,0x08,0x28,0x30,0x20,0x10,0x24,0x28,0x20,0x08,0x24,0x28,0x20,0x08,0x24,0x30,0x20,0x08,0x28,0x28,0x20,0x10,0x24,0x28,0x20,0x08,0x24,
0x30,0x20,0x08,0x24,0x28,0x20,0x10,0x24,0x30,0x20,0x08,0x28,0x28,0x20,0x08,0x24,0x30,0x20,0x10,0x24,0x30,0x20,0x08,0x24,0x28,0x20,0x08,0x28,0x30,0x20,0x10,0x24,0x30,0x20,0x08,0x24,0x28,0x20,0x10,0x24,0x30,0x20,0x08,0x24,0x30,0x20,0x10,0x24,0x28,0x20,0x08,0x24,0x28,0x20,0x08,0x24,0x30,0x20,0x10,0x24,0x28,0x20,0x08,0x24,
0x28,0x20,0x10,0x24,0x30,0x20,0x08,0x28,0x28,0x20,0x08,0x24,0x28,0x20,0x10,0x24,0x30,0x20,0x08,0x24,0x28,0x20,0x08,0x24,0x30,0x20,0x10,0x24,0x30,0x20,0x08,0x24,0x28,0x20,0x08,0x24,0x28,0x20,0x10,0x24,0x30,0x20,0x08,0x24,0x28,0x20,0x08,0x24,0x28,0x20,0x10,0x24,0x30,0x20,0x08,0x28,0x30,0x20,0x08,0x24,0x28,0x20,0x10,0x24,
0x30,0x20,0x08,0x28,0x30,0x20,0x10,0x24,0x28,0x20,0x08,0x28,0x30,0x20,0x10,0x24,0x28,0x20,0x08,0x24,0x30,0x20,0x10,0x24,0x28,0x20,0x08,0x28,0x30,0x20,0x08,0x24,0x28,0x20,0x10,0x24,0x28,0x20,0x08,0x24,0x30,0x20,0x08,0x24,0x28,0x20,0x10,0x24,0x30,0x20,0x08,0x24,0x30,0x20,0x08,0x24,0x28,0x20,0x08,0x24,0x30,0x20,0x10,0x28,
0x30,0x20,0x08,0x24,0x28,0x20,0x10,0x24,0x28,0x20,0x08,0x28,0x30,0x20,0x08,0x24,0x28,0x20,0x10,0x24,0x30,0x20,0x08,0x24,0x28,0x20,0x08,0x28,0x30,0x20,0x10,0x28,0x28,0x20,0x08,0x24,0x30,0x20,0x08,0x24,0x28,0x20,0x10,0x24,0x28,0x20,0x08,0x24,0x30,0x20,0x08,0x24,0x28,0x20,0x10,0x24,0x30,0x20,0x08,0x24,0x28,0x20,0x10,0x24,
0x28,0x20,0x08,0x20,0x28,0x20,0x10,0x1c,0x30,0x20,0x08,0x20,0x30,0x20,0x08,0x20,0x28,0x20,0x10,0x20,0x30,0x20,0x08,0x20,0x30,0x20,0x08,0x20,0x28,0x20,0x10,0x20,0x28,0x20,0x10,0x20,0x30,0x20,0x08,0x20,0x28,0x20,0x08,0x20,0x30,0x20,0x10,0x20,0x30,0x20,0x08,0x20,0x28,0x20,0x08,0x20,0x30,0x20,0x10,0x20,0x28,0x20,0x10,0x20,
0x30,0x20,0x08,0x20,0x30,0x20,0x08,0x20,0x28,0x20,0x08,0x20,0x28,0x20,0x08,0x20,0x30,0x20,0x10,0x20,0x28,0x20,0x10,0x20,0x28,0x20,0x08,0x20,0x30,0x20,0x08,0x1c,0x28,0x20,0x10,0x20,0x30,0x20,0x08,0x20,0x28,0x20,0x08,0x20,0x30,0x20,0x08,0x20,0x30,0x20,0x10,0x20,0x28,0x20,0x08,0x20,0x30,0x20,0x10,0x20,0x28,0x20,0x08,0x20,
0x28,0x20,0x08,0x20,0x30,0x20,0x10,0x20,0x28,0x20,0x08,0x20,0x30,0x20,0x10,0x20,0x28,0x20,0x08,0x20,0x28,0x20,0x08,0x20,0x30,0x20,0x08,0x20,0x28,0x20,0x08,0x20,0x28,0x20,0x08,0x1c,0x30,0x20,0x08,0x20,0x28,0x20,0x10,0x20,0x28,0x20,0x10,0x1c,0x30,0x20,0x08,0x20,0x30,0x20,0x10,0x20,0x28,0x20,0x08,0x20,0x30,0x20,0x08,0x20,
0x30,0x20,0x10,0x20,0x28,0x20,0x08,0x20,0x30,0x20,0x08,0x1c,0x28,0x20,0x10,0x20,0x28,0x20,0x08,0x20,0x30,0x20,0x08,0x20,0x28,0x20,0x10,0x1c,0x28,0x20,0x08,0x20,0x30,0x20,0x08,0x20,0x28,0x20,0x10,0x20,0x28,0x20,0x08,0x20,0x30,0x20,0x08,0x20,0x28,0x20,0x10,0x20,0x28,0x20,0x08,0x20,0x30,0x20,0x08,0x20,0x30,0x20,0x10,0x20,
0x28,0x20,0x08,0x20,0x30,0x20,0x10,0x20,0x30,0x20,0x08,0x20,0x28,0x20,0x08,0x20,0x30,0x20,0x10,0x20,0x30,0x20,0x08,0x20,0x30,0x20,0x08,0x20,0x28,0x20,0x10,0x20,0x30,0x20,0x08,0x20,0x28,0x20,0x08,0x20,0x28,0x20,0x10,0x20,0x30,0x20,0x08,0x20,0x30,0x20,0x10,0x20,0x28,0x20,0x08,0x20,0x30,0x20,0x10,0x20,0x28,0x20,0x08,0x20,
0x28,0x20,0x08,0x1c,0x30,0x20,0x10,0x20,0x28,0x20,0x08,0x20,0x28,0x20,0x08,0x20,0x30,0x20,0x10,0x1c,0x28,0x20,0x08,0x20,0x30,0x20,0x08,0x1c,0x28,0x20,0x10,0x20,0x30,0x20,0x08,0x20,0x28,0x20,0x08,0x20,0x30,0x20,0x10,0x20,0x30,0x20,0x08,0x20,0x28,0x20,0x10,0x20,0x30,0x20,0x08,0x20,0x28,0x20,0x08,0x20,0x28,0x20,0x10,0x20,
0x30,0x20,0x10,0x20,0x28,0x20,0x08,0x20,0x28,0x20,0x08,0x20,0x30,0x20,0x10,0x1c,0x30,0x20,0x08,0x20,0x28,0x20,0x08,0x20,0x30,0x20,0x10,0x20,0x28,0x20,0x08,0x20,0x30,0x20,0x10,0x20,0x28,0x20,0x08,0x20,0x28,0x20,0x08,0x20,0x30,0x20,0x10,0x20,0x30,0x20,0x08,0x1c,0x28,0x20,0x08,0x20,0x30,0x20,0x10,0x20,0x28,0x20,0x08,0x20,
0x30,0x20,0x08,0x20,0x28,0x20,0x10,0x20,0x30,0x20,0x08,0x20,0x28,0x20,0x08,0x20,
0x30,0x20,0x08,0x18,0x28,0x20,0x10,0x18,0x28,0x20,0x08,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x10,0x18,0x28,0x20,0x08,0x18,0x30,0x20,0x08,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x10,0x18,0x28,0x20,0x08,0x18,0x30,0x20,0x10,0x18,0x28,0x20,0x10,0x18,
0x28,0x20,0x08,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x10,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x08,0x18,0x30,0x20,0x10,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x08,0x18,0x30,0x20,0x08,0x18,0x30,0x20,0x10,0x18,0x28,0x20,0x08,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x10,0x18,0x28,0x20,0x08,0x18,0x30,0x20,0x10,0x18,0x28,0x20,0x08,0x18,
0x30,0x20,0x08,0x18,0x28,0x20,0x10,0x18,0x30,0x20,0x08,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x10,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x08,0x18,0x30,0x20,0x10,0x18,0x30,0x20,0x10,0x18,0x28,0x20,0x08,0x18,0x30,0x20,0x10,0x18,0x30,0x20,0x10,0x18,0x28,0x20,0x08,0x18,0x30,0x20,0x08,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x08,0x18,
0x28,0x20,0x10,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x08,0x18,0x30,0x20,0x10,0x18,0x28,0x20,0x10,0x18,0x30,0x20,0x08,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x10,0x18,0x30,0x20,0x08,0x18,0x30,0x20,0x10,0x18,0x28,0x20,0x10,0x18,0x30,0x20,0x08,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x10,0x18,0x30,0x20,0x08,0x18,0x30,0x20,0x08,0x18,
0x28,0x20,0x10,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x08,0x18,0x28,0x20,0x10,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x08,0x18,0x28,0x20,0x10,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x08,0x18,0x28,0x20,0x10,0x18,0x30,0x20,0x10,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x08,0x18,0x30,0x20,0x10,0x18,0x28,0x20,0x08,0x18,0x28,0x20,0x08,0x18,
0x30,0x20,0x10,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x08,0x18,0x30,0x20,0x10,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x10,0x18,0x30,0x20,0x08,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x10,0x18,0x28,0x20,0x08,0x18,0x30,0x20,0x08,0x18,0x30,0x20,0x10,0x18,0x28,0x20,0x08,0x18,0x28,0x20,0x08,0x18,0x30,0x20,0x10,0x18,0x28,0x20,0x08,0x18,
0x30,0x20,0x08,0x18,0x30,0x20,0x10,0x18,0x28,0x20,0x08,0x18,0x30,0x20,0x10,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x08,0x18,0x28,0x20,0x10,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x08,0x18,0x28,0x20,0x10,0x18,0x30,0x20,0x08,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x10,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x10,0x18,0x30,0x20,0x08,0x18,
0x28,0x20,0x10,0x18,0x28,0x20,0x08,0x18,0x30,0x20,0x10,0x18,0x30,0x20,0x08,0x18,0x28,0x20,0x08,0x18,0x30,0x20,0x10,0x18,0x28,0x20,0x08,0x18,0x30,0x20,0x08,0x18,
0x30,0x20,0x08,0x14,0x30,0x20,0x10,0x10,0x28,0x20,0x08,0x14,0x30,0x20,0x10,0x14,0x30,0x20,0x08,0x14,0x28,0x20,0x10,0x14,0x28,0x20,0x08,0x14,0x30,0x20,0x08,0x14,
0x30,0x20,0x08,0x10,0x28,0x20,0x08,0x14,0x30,0x20,0x08,0x10,0x30,0x20,0x08,0x10,0x28,0x20,0x10,0x14,0x30,0x20,0x08,0x14,0x30,0x20,0x08,0x14,0x28,0x20,0x10,0x14,0x28,0x20,0x08,0x10,0x28,0x20,0x10,0x14,0x30,0x20,0x10,0x14,0x28,0x20,0x08,0x14,0x28,0x20,0x08,0x14,0x30,0x20,0x10,0x10,0x30,0x20,0x08,0x14,0x28,0x20,0x10,0x14,
0x30,0x20,0x08,0x14,0x30,0x20,0x08,0x14,0x28,0x20,0x10,0x10,0x28,0x20,0x08,0x10,0x30,0x20,0x08,0x14,0x28,0x20,0x10,0x10,0x28,0x20,0x08,0x14,0x30,0x20,0x08,0x14,0x30,0x20,0x10,0x14,0x28,0x20,0x08,0x14,0x28,0x20,0x08,0x10,0x30,0x20,0x08,0x10,0x28,0x20,0x08,0x14,0x28,0x20,0x08,0x14,0x30,0x20,0x10,0x10,0x28,0x20,0x08,0x14,
0x28,0x20,0x10,0x14,0x30,0x20,0x10,0x10,0x30,0x20,0x08,0x14,0x28,0x20,0x08,0x14,0x30,0x20,0x10,0x10,0x28,0x20,0x08,0x14,0x30,0x20,0x08,0x14,0x28,0x20,0x10,0x10,0x28,0x20,0x08,0x14,0x30,0x20,0x08,0x14,0x28,0x20,0x10,0x14,0x28,0x20,0x08,0x14,0x30,0x20,0x08,0x14,0x28,0x20,0x08,0x10,0x30,0x20,0x10,0x14,0x28,0x20,0x08,0x14,
0x28,0x20,0x10,0x10,0x30,0x20,0x08,0x14,0x28,0x20,0x10,0x10,0x28,0x20,0x08,0x10,0x30,0x20,0x10,0x14,0x30,0x20,0x08,0x10,0x28,0x20,0x10,0x10,0x30,0x20,0x08,0x14,0x30,0x20,0x08,0x10,0x28,0x20,0x10,0x10,0x30,0x20,0x08,0x14,0x30,0x20,0x10,0x10,0x28,0x20,0x08,0x10,0x28,0x20,0x08,0x14,0x30,0x20,0x10,0x10,0x28,0x20,0x08,0x10,
0x28,0x20,0x10,0x14,0x30,0x20,0x08,0x14,0x30,0x20,0x08,0x10,0x28,0x20,0x10,0x14,0x28,0x20,0x08,0x10,0x30,0x20,0x08,0x10,0x28,0x20,0x10,0x14,0x30,0x20,0x08,0x10,0x28,0x20,0x08,0x14,0x28,0x20,0x10,0x14,0x30,0x20,0x08,0x14,0x30,0x20,0x10,0x14,0x28,0x20,0x08,0x14,0x30,0x20,0x10,0x14,0x28,0x20,0x08,0x14,0x30,0x20,0x08,0x14,
0x28,0x20,0x10,0x10,0x30,0x20,0x08,0x14,0x28,0x20,0x10,0x10,0x28,0x20,0x08,0x14,0x30,0x20,0x08,0x10,0x28,0x20,0x10,0x10,0x28,0x20,0x08,0x14,0x30,0x20,0x08,0x14,0x30,0x20,0x10,0x10,0x28,0x20,0x08,0x10,0x30,0x20,0x10,0x14,0x30,0x20,0x08,0x14,0x28,0x20,0x10,0x14,0x30,0x20,0x08,0x14,0x28,0x20,0x08,0x14,0x28,0x20,0x10,0x14,
0x30,0x20,0x08,0x10,0x28,0x20,0x08,0x14,0x30,0x20,0x10,0x10,0x28,0x20,0x08,0x14,0x30,0x20,0x08,0x14,0x28,0x20,0x10,0x14,0x28,0x20,0x08,0x10,0x30,0x20,0x08,0x14,0x28,0x20,0x10,0x14,0x28,0x20,0x08,0x14,0x30,0x20,0x10,0x10,0x28,0x20,0x08,0x14,
0x28,0x20,0x08,0x0c,0x28,0x20,0x08,0x0c,0x30,0x20,0x10,0x0c,0x28,0x20,0x08,0x0c,
0x30,0x20,0x08,0x0c,0x30,0x20,0x10,0x0c,0x28,0x20,0x10,0x0c,0x28,0x20,0x10,0x0c,0x30,0x20,0x10,0x0c,0x28,0x20,0x08,0x0c,0x28,0x20,0x10,0x10,0x30,0x20,0x08,0x0c,0x28,0x20,0x08,0x0c,0x28,0x20,0x10,0x0c,0x30,0x20,0x08,0x0c,0x30,0x20,0x08,0x0c,0x28,0x20,0x10,0x0c,0x30,0x20,0x08,0x0c,0x30,0x20,0x08,0x0c,0x28,0x20,0x10,0x0c,
0x28,0x20,0x08,0x0c,0x30,0x20,0x08,0x0c,0x28,0x20,0x10,0x0c,0x28,0x20,0x08,0x0c,0x30,0x20,0x08,0x0c,0x30,0x20,0x10,0x0c,0x28,0x20,0x08,0x0c,0x30,0x20,0x10,0x0c,0x30,0x20,0x08,0x0c,0x28,0x20,0x10,0x10,0x28,0x20,0x08,0x0c,0x30,0x20,0x10,0x0c,0x28,0x20,0x08,0x0c,0x30,0x20,0x10,0x0c,0x30,0x20,0x10,0x0c,0x28,0x20,0x08,0x0c,
0x30,0x20,0x08,0x0c,0x30,0x20,0x10,0x0c,0x28,0x20,0x08,0x0c,0x30,0x20,0x08,0x0c,0x28,0x20,0x08,0x0c,0x28,0x20,0x10,0x10,0x28,0x20,0x08,0x0c,0x30,0x20,0x10,0x0c,0x28,0x20,0x08,0x0c,0x30,0x20,0x10,0x0c,0x28,0x20,0x08,0x0c,0x30,0x20,0x08,0x0c,0x30,0x20,0x10,0x0c,0x28,0x20,0x08,0x0c,0x30,0x20,0x10,0x0c,0x30,0x20,0x10,0x0c,
0x28,0x20,0x08,0x10,0x30,0x20,0x08,0x0c,0x28,0x20,0x08,0x0c,0x30,0x20,0x10,0x0c,0x30,0x20,0x08,0x0c,0x28,0x20,0x08,0x0c,0x30,0x20,0x10,0x0c,0x28,0x20,0x08,0x0c,0x30,0x20,0x08,0x0c,0x28,0x20,0x10,0x0c,0x28,0x20,0x08,0x0c,0x30,0x20,0x08,0x0c,0x28,0x20,0x10,0x0c,0x28,0x20,0x08,0x10,0x30,0x20,0x08,0x0c,0x30,0x20,0x10,0x0c,
0x28,0x20,0x08,0x0c,0x30,0x20,0x08,0x0c,0x30,0x20,0x08,0x0c,0x28,0x20,0x10,0x0c,0x30,0x20,0x08,0x0c,0x28,0x20,0x08,0x0c,0x30,0x20,0x10,0x10,0x30,0x20,0x10,0x0c,0x28,0x20,0x08,0x0c,0x28,0x20,0x08,0x0c,0x30,0x20,0x10,0x0c,0x28,0x20,0x08,0x0c,0x30,0x20,0x10,0x0c,0x28,0x20,0x08,0x0c,0x28,0x20,0x08,0x0c,0x30,0x20,0x10,0x0c,
0x28,0x20,0x08,0x0c,0x30,0x20,0x08,0x0c,0x28,0x20,0x10,0x0c,0x28,0x20,0x08,0x0c,0x30,0x20,0x08,0x0c,0x30,0x20,0x10,0x0c,0x28,0x20,0x08,0x0c,0x30,0x20,0x10,0x0c,0x30,0x20,0x08,0x0c,0x28,0x20,0x08,0x0c,0x30,0x20,0x10,0x0c,0x28,0x20,0x08,0x0c,0x28,0x20,0x08,0x0c,0x30,0x20,0x10,0x0c,0x28,0x20,0x08,0x0c,0x28,0x20,0x08,0x0c,
0x30,0x20,0x10,0x0c,0x30,0x20,0x08,0x0c,0x28,0x20,0x10,0x0c,0x30,0x20,0x08,0x0c,0x30,0x20,0x08,0x10,0x28,0x20,0x10,0x0c,0x30,0x20,0x08,0x0c,0x30,0x20,0x08,0x0c,0x28,0x20,0x10,0x0c,0x30,0x20,0x08,0x0c,0x30,0x20,0x08,0x10,0x28,0x20,0x10,0x0c,0x30,0x20,0x08,0x0c,0x30,0x20,0x08,0x0c,0x28,0x20,0x10,0x0c,0x30,0x20,0x08,0x0c,
0x28,0x20,0x08,0x08,0x30,0x20,0x10,0x08,0x28,0x20,0x08,0x08,0x28,0x20,0x08,0x08,0x30,0x20,0x10,0x08,0x28,0x20,0x08,0x08,0x30,0x20,0x08,0x08,0x30,0x20,0x08,0x08,0x28,0x20,0x08,0x08,0x30,0x20,0x10,0x08,0x30,0x20,0x10,0x08,0x28,0x20,0x08,0x08,0x30,0x20,0x08,0x08,0x28,0x20,0x10,0x08,0x28,0x20,0x08,0x08,0x30,0x20,0x08,0x08,
0x28,0x20,0x10,0x08,0x30,0x20,0x08,0x08,0x30,0x20,0x08,0x08,0x28,0x20,0x10,0x08,0x30,0x20,0x08,0x08,0x30,0x20,0x08,0x08,0x28,0x20,0x10,0x08,0x28,0x20,0x08,0x08,0x30,0x20,0x10,0x08,0x28,0x20,0x08,0x08,0x28,0x20,0x08,0x08,0x30,0x20,0x10,0x08,0x30,0x20,0x08,0x08,0x28,0x20,0x08,0x08,0x30,0x20,0x10,0x08,0x28,0x20,0x08,0x08,
0x28,0x20,0x08,0x08,0x30,0x20,0x08,0x08,0x28,0x20,0x10,0x08,0x28,0x20,0x08,0x08,0x30,0x20,0x10,0x0c,0x28,0x20,0x10,0x08,0x30,0x20,0x08,0x08,0x30,0x20,0x08,0x08,0x30,0x20,0x10,0x08,0x28,0x20,0x08,0x08,0x30,0x20,0x08,0x08,0x30,0x20,0x08,0x08,0x28,0x20,0x10,0x08,0x28,0x20,0x08,0x08,0x30,0x20,0x08,0x08,0x28,0x20,0x10,0x08,
0x28,0x20,0x08,0x08,0x30,0x20,0x08,0x08,0x28,0x20,0x08,0x08,0x28,0x20,0x10,0x08,0x30,0x20,0x08,0x08,0x28,0x20,0x10,0x08,0x30,0x20,0x08,0x08,0x28,0x20,0x08,0x08,0x30,0x20,0x10,0x08,0x28,0x20,0x08,0x08,0x30,0x20,0x08,0x08,0x30,0x20,0x10,0x08,0x28,0x20,0x08,0x0c,0x30,0x20,0x08,0x08,0x30,0x20,0x10,0x08,0x28,0x20,0x08,0x08,
0x30,0x20,0x10,0x08,0x28,0x20,0x08,0x08,0x28,0x20,0x08,0x08,0x30,0x20,0x10,0x08,0x28,0x20,0x10,0x08,0x28,0x20,0x08,0x08,0x30,0x20,0x10,0x08,0x30,0x20,0x08,0x08,0x28,0x20,0x08,0x08,0x28,0x20,0x10,0x08,0x30,0x20,0x08,0x08,0x30,0x20,0x08,0x08,0x28,0x20,0x10,0x0c,0x30,0x20,0x08,0x08,0x30,0x20,0x08,0x08,0x28,0x20,0x10,0x08,
0x30,0x20,0x08,0x08,0x30,0x20,0x08,0x08,0x28,0x20,0x10,0x08,0x28,0x20,0x08,0x08,0x30,0x20,0x08,0x08,0x30,0x20,0x10,0x08,0x28,0x20,0x10,0x08,0x30,0x20,0x08,0x08,0x30,0x20,0x08,0x08,0x28,0x20,0x10,0x08,0x28,0x20,0x08,0x08,0x30,0x20,0x08,0x08,0x28,0x20,0x10,0x08,0x30,0x20,0x08,0x08,0x30,0x20,0x10,0x08,0x28,0x20,0x08,0x08,
0x30,0x20,0x08,0x08,0x30,0x20,0x10,0x08,0x28,0x20,0x08,0x08,0x28,0x20,0x08,0x08,0x30,0x20,0x10,0x08,0x28,0x20,0x08,0x08,0x28,0x20,0x08,0x08,0x30,0x20,0x10,0x08,0x28,0x20,0x08,0x08,0x28,0x20,0x10,0x08,0x30,0x20,0x08,0x08,0x28,0x20,0x08,0x08,0x28,0x20,0x10,0x08,0x30,0x20,0x08,0x08,0x28,0x20,0x10,0x08,0x28,0x20,0x08,0x08,
0x30,0x20,0x08,0x08,0x28,0x20,0x10,0x08,0x30,0x20,0x08,0x08,0x28,0x20,0x08,0x08,
0x30,0x20,0x08,0x04,0x30,0x20,0x10,0x04,0x28,0x20,0x08,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x28,0x20,0x08,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x28,0x20,0x08,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x08,0x04,0x30,0x20,0x10,0x04,
0x30,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x28,0x20,0x08,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x28,0x20,0x08,0x04,0x30,0x20,0x10,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x08,0x04,0x30,0x20,0x10,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x30,0x20,0x08,0x04,
0x28,0x20,0x08,0x04,0x30,0x20,0x10,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x08,0x04,0x30,0x20,0x10,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x08,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x28,0x20,0x08,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x30,0x20,0x08,0x04,
0x30,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x30,0x20,0x08,0x04,0x30,0x20,0x10,0x04,0x28,0x20,0x08,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x30,0x20,0x08,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x28,0x20,0x08,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x28,0x20,0x08,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x10,0x04,
0x28,0x20,0x08,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x30,0x20,0x08,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x30,0x20,0x08,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x08,0x04,0x30,0x20,0x10,0x04,0x28,0x20,0x08,0x04,0x28,0x20,0x08,0x04,0x30,0x20,0x10,0x04,
0x28,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x30,0x20,0x08,0x04,0x30,0x20,0x10,0x04,0x28,0x20,0x08,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x28,0x20,0x08,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x28,0x20,0x08,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x10,0x04,
0x28,0x20,0x08,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x28,0x20,0x08,0x04,0x30,0x20,0x10,0x04,0x28,0x20,0x08,0x04,0x30,0x20,0x08,0x04,0x30,0x20,0x10,0x04,0x28,0x20,0x08,0x04,0x30,0x20,0x08,0x04,0x30,0x20,0x10,0x04,0x28,0x20,0x08,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x10,0x04,
0x30,0x20,0x08,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x30,0x20,0x08,0x04,0x28,0x20,0x10,0x04,0x30,0x20,0x08,0x04
};
| 282.519573
| 320
| 0.797262
|
ramkumarkoppu
|
59d99ba994308c475f232ea5e6a902956a04a72b
| 696
|
cpp
|
C++
|
10 Days of Statistics/Day_6/CLT_3.cpp
|
yurkovak/HackerRank
|
a10136e508692f98e76e7c27d9cd801a3380f8ba
|
[
"MIT"
] | null | null | null |
10 Days of Statistics/Day_6/CLT_3.cpp
|
yurkovak/HackerRank
|
a10136e508692f98e76e7c27d9cd801a3380f8ba
|
[
"MIT"
] | null | null | null |
10 Days of Statistics/Day_6/CLT_3.cpp
|
yurkovak/HackerRank
|
a10136e508692f98e76e7c27d9cd801a3380f8ba
|
[
"MIT"
] | null | null | null |
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <math.h>
// using namespace std;
float CDF(float mean, float stdev, float x){
float erf_arg = (x - mean) / (pow(2, 0.5) * stdev);
return (1 + erf(erf_arg))/2.;
}
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
float n;
float mean, stdev;
float percentage, z_score;
std::cin >> n;
std::cin >> mean >> stdev;
std::cin >> percentage >> z_score;
float A = mean - z_score*stdev / pow(n, 0.5);
float B = mean + z_score*stdev / pow(n, 0.5);
printf ("%.2f\n", A);
printf ("%.2f\n", B);
return 0;
}
| 22.451613
| 79
| 0.586207
|
yurkovak
|
59db631c18954ef2592d11406e5cd920d60895ec
| 7,823
|
cpp
|
C++
|
main/mz-dumper.cpp
|
Fetrovsky/bintool
|
3c9d871d4ca2dff8b3b7cefc924da3e9408858a2
|
[
"BSD-3-Clause"
] | null | null | null |
main/mz-dumper.cpp
|
Fetrovsky/bintool
|
3c9d871d4ca2dff8b3b7cefc924da3e9408858a2
|
[
"BSD-3-Clause"
] | null | null | null |
main/mz-dumper.cpp
|
Fetrovsky/bintool
|
3c9d871d4ca2dff8b3b7cefc924da3e9408858a2
|
[
"BSD-3-Clause"
] | null | null | null |
#include "mz-dumper.h"
#include <chrono>
#include <ctime>
#include <iostream>
#include <mz/mz.h>
using std::chrono::seconds;
using std::chrono::system_clock;
using std::chrono::time_point;
using std::chrono::operator""y;
using std::cout;
using std::endl;
using typeid_t = void const*;
template<typename Optional_Header_Type>
void Show_MZ_Optional_Header(Optional_Header_Type const& oh);
void Show_MZ_Image_Data_Directory_Summary(MZ::Image_Data_Directories const& idd);
void Show_MZ_Section_Table(MZ const& mz);
void Show_MZ_File_Details(MZ const& mz)
{
auto const format_name = Get_File_Format_Name(mz.Get_File_Format());
auto coff_header = mz.Get_Header();
auto timestamp = time_point<system_clock>(std::chrono::seconds(coff_header.Time_Date_Stamp));
auto time = system_clock::to_time_t(timestamp);
std::string timestamp_as_string = std::ctime(&time);
timestamp_as_string = timestamp_as_string.substr(0, timestamp_as_string.length() - 1);
cout
<< "Portable Executable file details:"
<< "\n Signature: " << coff_header.Signature
<< "\n Machine: " << Get_Machine_Type_Name(coff_header.Machine)
<< "\n Number_Of_Sections: " << coff_header.Number_Of_Sections
<< "\n Time_Date_Stamp: " << timestamp_as_string
<< "\n Pointer_to_Symbol_Table: " << coff_header.Pointer_to_Symbol_Table
<< "\n Number_Of_Symbols: " << coff_header.Number_Of_Symbols
<< "\n Size_Of_Optional_Header: " << coff_header.Size_Of_Optional_Header
<< "\n Characteristics: " << int(coff_header.Characteristics);
auto const characteristics = Get_Image_File_Characteristics_Names(coff_header.Characteristics);
for (auto const ch: characteristics)
cout << "\n " << ch;
cout << '\n';
switch (auto optional_header = mz.Get_Optional_Header();
optional_header.index())
{
case 0:
cout << "Optional Header not present." << endl;
break;
case 1:
Show_MZ_Optional_Header(std::get<MZ::Optional_Header>(optional_header));
break;
case 2:
Show_MZ_Optional_Header(std::get<MZ::Optional_Header_Plus>(optional_header));
break;
}
Show_MZ_Section_Table(mz);
}
template <typename T>
struct wrapper {
static void const* const id;
};
template<typename T>
void const* const wrapper<T>::id = nullptr;
template<typename T>
constexpr typeid_t typeof()
{
return &wrapper<T>::id;
}
template<typename Optional_Header_Type>
void Show_MZ_Optional_Header(Optional_Header_Type const& oh)
{
cout
<< "\n OptionalHeader:"
<< "\n Magic: " << Get_Magic_Number_Name(oh.Magic)
<< "\n Major_Linker_Version: " << int(oh.Major_Linker_Version)
<< "\n Minor_Linker_Version: " << int(oh.Minor_Linker_Version)
<< "\n Size_Of_Code: " << oh.Size_Of_Code
<< "\n Size_Of_Initialized_Data: " << oh.Size_Of_Initialized_Data
<< "\n Size_Of_Uninitialized_Data: " << oh.Size_Of_Uninitialized_Data
<< "\n Address_Of_Entry_Point: " << oh.Address_Of_Entry_Point
<< "\n Base_Of_Code: " << oh.Base_Of_Code;
if constexpr(typeof<Optional_Header_Type>() == typeof<MZ::Optional_Header>())
cout << "\n Base_Of_Data: " << oh.Base_Of_Data;
cout
<< "\n Image_Base: " << oh.Image_Base
<< "\n Section_Alignment: " << oh.Section_Alignment
<< "\n File_Alignment: " << oh.File_Alignment
<< "\n Major_Operating_System_Version: " << oh.Major_Operating_System_Version
<< "\n Minor_Operating_System_Version: " << oh.Minor_Operating_System_Version
<< "\n Major_Image_Version: " << oh.Major_Image_Version
<< "\n Minor_Image_Version: " << oh.Minor_Image_Version
<< "\n Major_Subsystem_Version: " << oh.Major_Subsystem_Version
<< "\n Minor_Subsystem_Version: " << oh.Minor_Subsystem_Version
<< "\n Win32_Version_Value: " << oh.Win32_Version_Value
<< "\n Size_Of_Image: " << oh.Size_Of_Image
<< "\n Size_Of_Headers: " << oh.Size_Of_Headers
<< "\n Check_Sum: " << oh.Check_Sum
<< "\n Subsystem: " << Get_Subsystem_Name(oh.Subsystem)
<< "\n Dll_Characteristics: " << int(oh.Dll_Characteristics);
auto const characteristics = Get_Image_DLL_Characteristics_Names(oh.Dll_Characteristics);
for (auto const ch: characteristics)
cout << "\n " << ch;
cout
<< "\n Size_Of_Stack_Reserve: " << oh.Size_Of_Stack_Reserve
<< "\n Size_Of_Stack_Commit: " << oh.Size_Of_Stack_Commit
<< "\n Size_Of_Heap_Reserve: " << oh.Size_Of_Heap_Reserve
<< "\n Size_Of_Heap_Commit: " << oh.Size_Of_Heap_Commit
<< "\n Loader_Flags: " << oh.Loader_Flags
<< "\n Number_Of_Rva_And_Sizes: " << oh.Number_Of_Rva_And_Sizes << std::endl;
Show_MZ_Image_Data_Directory_Summary(oh.Image_Data_Directories);
}
template<typename Stream>
Stream& operator<<(Stream& stream, MZ::Image_Data_Directories::Entry const& idde)
{
auto const start = idde.Virtual_Address;
auto const size = idde.Size;
auto const end = start + size;
if (size == 0)
{
stream << "N/A";
} else {
stream << std::hex << "0x" << start << "..0x" << end << " (0x" << size << "=" << std::dec << size << ")";
}
return stream;
}
void Show_MZ_Image_Data_Directory_Summary(MZ::Image_Data_Directories const& idd)
{
cout
<< "\n Image Data Directories:"
<< "\n Export_Table: " << idd.Export_Table
<< "\n Import_Table: " << idd.Import_Table
<< "\n Resource_Table: " << idd.Resource_Table
<< "\n Exception_Table: " << idd.Exception_Table
<< "\n Certificate_Table: " << idd.Certificate_Table
<< "\n Base_Relocation_Table: " << idd.Base_Relocation_Table
<< "\n Debug: " << idd.Debug
<< "\n Architecture: " << idd.Architecture
<< "\n Global_Ptr: " << idd.Global_Ptr
<< "\n TLS_Table: " << idd.TLS_Table
<< "\n Load_Config_Table: " << idd.Load_Config_Table
<< "\n Bound_Import: " << idd.Bound_Import
<< "\n IAT: " << idd.IAT
<< "\n Delay_Import_Descriptor: " << idd.Delay_Import_Descriptor
<< "\n CLR_Runtime_Header: " << idd.CLR_Runtime_Header
<< "\n Reserved_MBZ: " << idd.Reserved_MBZ << std::endl;
}
void Show_MZ_Section_Header(MZ const& mz, int i, MZ::Section_Header const& sh)
{
auto const Section_Name = mz.Get_Section_Name(sh);
cout
<< "\n Section " << i << ": " << Section_Name
<< "\n Virtual_Size: " << sh.Virtual_Size
<< "\n Virtual_Address: " << sh.Virtual_Address
<< "\n Size_Of_Raw_Data: " << sh.Size_Of_Raw_Data
<< "\n Pointer_To_Raw_Data: " << sh.Pointer_To_Raw_Data
<< "\n Pointer_To_Relocations: " << sh.Pointer_To_Relocations
<< "\n Pointer_To_Linenumbers: " << sh.Pointer_To_Linenumbers
<< "\n Number_Of_Relocations: " << sh.Number_Of_Relocations
<< "\n Number_Of_Linenumbers: " << sh.Number_Of_Linenumbers
<< "\n Characteristics: " << (std::hex) << uint32_t(sh.Characteristics);
auto const characteristics = Get_Section_Characteristics_Names(sh.Characteristics);
for (auto const ch: characteristics)
cout << "\n " << ch;
cout << std::endl;
}
void Show_MZ_Section_Table(MZ const& mz)
{
auto const Number_Of_Sections = mz.Get_Number_of_Sections();
cout << "\n Image has " << Number_Of_Sections << " sections:";
for (int i = 0; i < Number_Of_Sections; ++i)
Show_MZ_Section_Header(mz, i, mz.Get_Section_Header(i));
}
| 37.075829
| 113
| 0.62917
|
Fetrovsky
|
59e6053fba61ff1ad19c8d92171ed35baae7426b
| 8,207
|
cpp
|
C++
|
src/oxtfGraphReader.cpp
|
MRKonrad/itkTensorFlow
|
f4712784ba52a1f28103a098277f6ddc5c3731c5
|
[
"MIT"
] | null | null | null |
src/oxtfGraphReader.cpp
|
MRKonrad/itkTensorFlow
|
f4712784ba52a1f28103a098277f6ddc5c3731c5
|
[
"MIT"
] | null | null | null |
src/oxtfGraphReader.cpp
|
MRKonrad/itkTensorFlow
|
f4712784ba52a1f28103a098277f6ddc5c3731c5
|
[
"MIT"
] | null | null | null |
//
// Created by Konrad Werys on 01/04/2019.
//
#include "oxtfGraphReader.h"
#include "oxtfUtils.h"
#include "tf_utils.hpp"
namespace oxtf {
int GraphReader::readGraph() {
// check path
if (_graphPath.empty()) {
std::cerr << "Can't load graph" << std::endl;
return 1; //EXIT_FAILURE
}
// try loading
_graph = tf_utils::LoadGraph(_graphPath.c_str());
// check if success
if (_graph == nullptr) {
std::cerr << "Can't load graph" << std::endl;
return 1; //EXIT_FAILURE
}
TF_Operation *op;
std::size_t pos = 0;
while ((op = TF_GraphNextOperation(_graph, &pos)) != nullptr) {
const char *name = TF_OperationName(op);
const char *type = TF_OperationOpType(op);
const char *device = TF_OperationDevice(op);
const int num_outputs = TF_OperationNumOutputs(op);
const int num_inputs = TF_OperationNumInputs(op);
int64_t tempOpDims;
std::vector<std::int64_t> tempOpSize;
TF_DataType tempOpType;
int result = GetOpOutputInfo(_graph, op, 0, &tempOpDims, &tempOpSize, &tempOpType);
if (result != 0)
continue;
// ----------------------------
// --- getting input params ---
// ----------------------------
if ( ( _inputOperationDims == 0 ) // skip if already set
&& ( tempOpDims == 4 ) ) { // consider only ops with 4 dims
if ( (tempOpSize[1] > 1 || tempOpSize[1] == -1) // consider only x == -1 or x > 1
&& (tempOpSize[2] > 1 || tempOpSize[2] == -1)) { // consider only y == -1 or y > 1
if (num_outputs == 1) {
_inputOperationName = name;
_inputOperationDims = tempOpDims;
_inputOperationSize = tempOpSize;
_inputOperationType = tempOpType;
}
}
}
// -----------------------------
// --- getting output params ---
// -----------------------------
// TODO: find more pretty solution, currently overwriting the all output params with each operation.
// Can i get the number of the operations in the graph?
_outputOperationName = name;
_outputOperationDims = tempOpDims;
_outputOperationSize = tempOpSize;
_outputOperationType = tempOpType;
// biggest x and y
if (tempOpDims >= 3){
if ( tempOpSize[1] > _operationWithBiggest2nd3rdSize[1]
&& tempOpSize[2] > _operationWithBiggest2nd3rdSize[2] ){
_operationWithBiggest2nd3rdSize = tempOpSize;
}
}
}
// if has not been set print to cerr
if (_inputOperationDims == 0){
std::cerr << "inputOperation has not been found" << std::endl;
return 1; // EXIT_FAILURE
}
// if has not been set print to cerr
if (_outputOperationDims == 0){
std::cerr << "outputOperation has not been found" << std::endl;
return 1; // EXIT_FAILURE
}
std::cout << "inputOperationName: " << _inputOperationName << std::endl;
std::cout << "outputOperationName: " << _outputOperationName << std::endl;
return 0; //EXIT_SUCCESS
}
void
GraphReader::setGraphPath(const std::string &_graphPath) {
GraphReader::_graphPath = _graphPath;
}
const std::string &
GraphReader::getGraphPath() const {
return _graphPath;
}
TF_Graph *
GraphReader::getGraph() const {
return _graph;
}
const std::string &
GraphReader::getInputOperationName() const {
return _inputOperationName;
}
int64_t
GraphReader::getInputOperationDims() const {
return _inputOperationDims;
}
const std::vector<int64_t> &
GraphReader::getInputOperationSize() const {
return _inputOperationSize;
}
TF_DataType
GraphReader::getInputOperationType() const {
return _inputOperationType;
}
const std::string &
GraphReader::getOutputOperationName() const {
return _outputOperationName;
}
int64_t
GraphReader::getOutputOperationDims() const {
return _outputOperationDims;
}
const std::vector<int64_t> &
GraphReader::getOutputOperationSize() const {
return _outputOperationSize;
}
TF_DataType
GraphReader::getOutputOperationType() const {
return _outputOperationType;
}
const std::vector<int64_t> &
GraphReader::getOperationWithBiggest2nd3rdSize() const {
return _operationWithBiggest2nd3rdSize;
}
GraphReader::GraphReader() {
_graphPath = "";
_graph = nullptr;
_inputOperationName = "";
_inputOperationDims = 0;
_inputOperationType = TF_FLOAT;
_outputOperationName = "";
_outputOperationDims = 0;
_outputOperationType = TF_FLOAT;
_operationWithBiggest2nd3rdSize.resize(3, -1);
}
GraphReader::~GraphReader() {
tf_utils::DeleteGraph(_graph);
}
void GraphReader::disp(){
std::cout << "GraphReader" << std::endl;
std::cout << " graphPath: " << _graphPath << std::endl;
std::cout << " inputOperationName: " << _inputOperationName
<< " inputOperationType: " << TFDataTypeToString(_inputOperationType);
std::cout << " inputOperationSize: [ ";
for (int i = 0; i < _inputOperationSize.size(); ++i){
std::cout << _inputOperationSize[i] << " ";
}
std::cout << " ]" << std::endl;
std::cout << " outputOperationName: " << _outputOperationName
<< " outputOperationDims: " << _outputOperationDims
<< " outputOperationType: " << TFDataTypeToString(_outputOperationType);
std::cout << " outputOperationSize: [ ";
for (int i = 0; i < _outputOperationSize.size(); ++i){
std::cout << _outputOperationSize[i] << " ";
}
std::cout << " ]" << std::endl;
std::cout << " operationWithBiggest2nd3rdSize: [ ";
for (int i = 0; i < _operationWithBiggest2nd3rdSize.size(); ++i){
std::cout << _operationWithBiggest2nd3rdSize[i] << " ";
}
std::cout << " ]"<< std::endl;
}
int
GraphReader::GetOpOutputInfo(TF_Graph* graph, TF_Operation* op, int nth_output, std::int64_t *num_dims, std::vector<std::int64_t> *dims, TF_DataType *type) {
TF_Status* status = TF_NewStatus();
const int num_outputs = TF_OperationNumOutputs(op);
if (num_outputs == 0){
return 1; //EXIT_FAILURE
}
if (nth_output > num_outputs){
std::cout << "Incorrect nth_output: " << nth_output << ". Number of outputs: " << num_outputs << std::endl;
return 1; //EXIT_FAILURE
}
const TF_Output output = {op, nth_output};
*type = TF_OperationOutputType(output);
const std::int64_t temp_num_dims = TF_GraphGetTensorNumDims(graph, output, status);
if (TF_GetCode(status) != TF_OK) {
std::cout << "Can't get tensor dimensionality" << std::endl;
return 1; //EXIT_FAILURE
}
if (temp_num_dims < 0){
//std::cout << "Tensor dim < 0" << std::endl;
return 2; //EXIT_FAILURE
}
*num_dims = temp_num_dims;
std::vector<std::int64_t> temp_dims(*num_dims);
TF_GraphGetTensorShape(graph, output, temp_dims.data(), *num_dims, status);
if (TF_GetCode(status) != TF_OK) {
std::cout << "Can't get get tensor shape" << std::endl;
return 1; //EXIT_FAILURE
}
dims->clear();
for (int j = 0; j < *num_dims; ++j) {
dims->push_back(temp_dims[j]);
}
TF_DeleteStatus(status);
return 0; //EXIT_SUCCESS
}
} //namespace oxtf
| 30.969811
| 161
| 0.549165
|
MRKonrad
|
59e72ccba44ec1a9abeaea345f489edc4389d680
| 17,436
|
hpp
|
C++
|
src/architecture/x86/encoder.hpp
|
Midi12/cx_assembler
|
1c1f800344a231fd13e52f90f4fd3e2160c84a84
|
[
"MIT"
] | 17
|
2021-07-12T18:10:37.000Z
|
2022-03-06T20:45:01.000Z
|
src/architecture/x86/encoder.hpp
|
Midi12/cx_assembler
|
1c1f800344a231fd13e52f90f4fd3e2160c84a84
|
[
"MIT"
] | null | null | null |
src/architecture/x86/encoder.hpp
|
Midi12/cx_assembler
|
1c1f800344a231fd13e52f90f4fd3e2160c84a84
|
[
"MIT"
] | 1
|
2021-07-15T06:54:45.000Z
|
2021-07-15T06:54:45.000Z
|
#pragma once
#include <experimental/array>
#include <tuple>
#include <utility>
#include "instruction_db.hpp"
#include "instruction_db.g.hpp"
#include "opcode_extension.hpp"
#include "operands.hpp"
#include "rex.hpp"
namespace cx_assembler::x86 {
namespace internal {
constexpr std::uint8_t prefix_16bit = 0x66;
constexpr std::uint8_t prefix_overridesize = 0x67;
template <typename... Ts>
struct _sizeof {
constexpr static std::size_t value = (sizeof(Ts) + ...);
};
template <typename... Ts>
inline constexpr auto _sizeof_v = _sizeof<Ts...>::value;
template <e_instruction_id Id, typename Op1, typename Op2>
struct _sizeof_prefixes {
constexpr static std::size_t value =
has_prefix<Id>() +
has_prefix_0f<Id>() +
((Register16<Op1> || (!IsVoidOperand<Op2> && Register16<Op2>)) || (Memory<Op1> && Op1::size == 16) ? 1 : 0) +
((Memory<Op1> && Register32<typename Op1::value_type>) || (!IsVoidOperand<Op2> && Memory<Op2> && Register32<typename Op2::value_type>) ? 1 : 0);
};
template <e_instruction_id Id, typename Op1, typename Op2>
inline constexpr auto _sizeof_prefixes_v = _sizeof_prefixes<Id, Op1, Op2>::value;
template<typename... Bytes>
constexpr std::array<std::uint8_t, sizeof...(Bytes)> make_bytes(Bytes&&... args) noexcept {
return { std::uint8_t(std::forward<Bytes>(args))... };
}
template <e_instruction_id Id, typename Op1, typename Op2, typename ...Args> requires DerivesBaseOperand<Op1> && (DerivesBaseOperand<Op2> || IsVoidOperand<Op2>)
constexpr auto encode(instruction_desc desc, Args&& ...args) {
auto tuple = std::make_tuple(std::forward<Args>(args)...);
auto has_rex = []() constexpr {
if constexpr (Immediate<Op2> || IsVoidOperand<Op2>) {
return (Id != e_instruction_id::call &&
Id != e_instruction_id::jmp
) && needs_rex<Op1>();
} else {
return needs_rex<Op1, Op2>();
}
};
constexpr auto size = has_rex() + _sizeof_prefixes_v<Id, Op1, Op2> + _sizeof_v<Args...>;
std::array<std::uint8_t, size> arr {};
int j = 0;
if constexpr ((Memory<Op1> && Register32<typename Op1::value_type>) || (!IsVoidOperand<Op2> && Memory<Op2> && Register32<typename Op2::value_type>)) {
arr[j++] = prefix_overridesize;
}
if constexpr ((Register16<Op1> || (!IsVoidOperand<Op2> && Register16<Op2>)) || (Memory<Op1> && Op1::size == 16)) {
arr[j++] = prefix_16bit;
}
if constexpr (has_rex()) {
if constexpr (Immediate<Op2> || IsVoidOperand<Op2>) {
arr[j++] = encode_rex<Op1>();
} else {
arr[j++] = encode_rex<Op1, Op2>();
}
}
if constexpr (has_prefix<Id>()) {
arr[j++] = desc.prefix();
}
if constexpr (has_prefix_0f<Id>()) {
arr[j++] = desc.prefix_0f();
}
auto emit = [] <typename T> (std::array<std::uint8_t, size>& arr, int& j, const T& value) {
for (int i = 0; i < sizeof(T); i++) {
arr[j++] = static_cast<std::uint8_t>(value >> (i * 8));
}
};
std::apply([&arr, &j, &emit](auto&&... args) {
((emit(arr, j, args)), ...);
}, tuple);
return arr;
}
}
template <typename Op1, typename Op2> requires (Register<Op1> || Memory<Op1>) && (Register<Op2> || Memory<Op2>)
consteval auto encode_opcode_alu(const std::uint8_t& opcode) {
return static_cast<std::uint8_t>(
(opcode & 0b11111100) +
(Memory<Op2> ? 0b10 : 0b00) + // setup bit `d`
(Op1::size > 8 ? 0b01 : 0b00)// setup bit `s`
);
}
template <typename Op1, typename Op2> requires (Register<Op1> || Memory<Op1>) && (Immediate<Op2>)
consteval auto encode_opcode_alu(const std::uint8_t& opcode) {
return static_cast<std::uint8_t>(
(opcode & 0b11111100) +
(false ? 0b10 : 0b00) + // setup bit `x` : todo : change to handle onebyte sign extend (1), constant same size as operand (0)
(Op2::size > 8 ? 0b01 : 0b00)// setup bit `s`
);
}
template <typename Reg> requires Register<Reg>
consteval auto encode_opcode_pushpop(const std::uint8_t& opcode, const Reg& reg) {
return static_cast<std::uint8_t>(opcode + static_cast<std::uint8_t>(reg.id()));
}
template <e_instruction_id Id, typename Op1, typename Op2> requires (Register<Op1> || Memory<Op1>) && (Register<Op2> || Memory<Op2> || Immediate<Op2>)
consteval auto encode_alu(instruction_desc desc, Op1 op1, Op2 op2) {
auto id = desc.id();
auto opcode = desc.primary_opcode();
if constexpr (Immediate<Op2>) {
// Immediate src operands use the 80h opcode
opcode = encode_opcode_alu<Op1, Op2>(0x80);
typename Op2::value_type value = static_cast<typename Op2::value_type>(op2.value());
return internal::encode<Id, Op1, Op2>(desc, opcode, encode_modrm(opcodeext_alu(id), op1, op2), value);
} else {
// src operand is Register or Memory
opcode = encode_opcode_alu<Op1, Op2>(opcode);
if constexpr (Memory<Op1> && Immediate<typename Op1::value_type>) {
return internal::encode<Id, Op1, Op2>(
desc,
opcode,
encode_modrm(op1, op2),
encode_sib_nodisp(op1, op2),
static_cast<std::uint32_t>(op1.value().value())
);
} else if constexpr (Memory<Op2> && Immediate<typename Op2::value_type>) {
return internal::encode<Id, Op1, Op2>(
desc,
opcode,
encode_modrm(op1, op2),
encode_sib_nodisp(op1, op2),
static_cast<std::uint32_t>(op2.value().value())
);
} else {
return internal::encode<Id, Op1, Op2>(
desc,
opcode,
encode_modrm(op1, op2)
);
}
}
}
template <e_instruction_id Id, typename Op1, typename Op2> requires Integer<Op2>
consteval auto encode_alu(instruction_desc desc, const Op1& op1, const Op2& op2) {
return encode_alu<Id>(desc, op1, immediate<typename truncate_as<Op1>::type>(op2));
}
template <typename Op1, typename Op2> requires (Register<Op1> || Memory<Op1>) && (Register<Op2> || Memory<Op2> ||Immediate<Op2>)
consteval auto encode_opcode_bt(const std::uint8_t& opcode) {
return static_cast<std::uint8_t>(
(opcode & 0b11111110) +
(!Immediate<Op2> ? 0b01 : 0b00)// setup bit `s`
);
}
template <e_instruction_id Id, typename Op1, typename Op2> requires (Register<Op1> || Memory<Op1>) && (Register<Op2> || Memory<Op2> || Immediate<Op2>)
consteval auto encode_bt(instruction_desc desc, Op1 op1, Op2 op2) {
auto id = desc.id();
auto opcode = desc.primary_opcode();
if constexpr (Immediate<Op2>) {
// Immediate src use 0xBA opcode
opcode = 0xBA;
return internal::encode<Id, Op1, Op2>(
desc, opcode, encode_modrm(opcodeext_bt(id), op1, op2), op2.value()
);
} else {
opcode = encode_opcode_bt<Op1, Op2>(opcode);
return internal::encode<Id, Op1, Op2>(
desc, opcode, encode_modrm(op1, op2)
);
}
}
template <e_instruction_id Id, typename Op1, typename Op2> requires Integer<Op2>
consteval auto encode_bt(instruction_desc desc, const Op1& op1, const Op2& op2) {
return encode_bt<Id>(desc, op1, immediate<std::uint8_t>(op2));
}
template <e_instruction_id Id, typename Op1>
consteval auto encode_call(instruction_desc desc, const Op1& op1) {
auto id = desc.id();
auto opcode = desc.primary_opcode();
if constexpr (Immediate<Op1>) {
opcode = 0xE8;
return internal::encode<Id, Op1, Void>(
desc, opcode, op1.value()
);
} else {
return internal::encode<Id, Op1, Void>(
desc, opcode, encode_modrm(opcodeext_ff(id), op1)
);
}
}
template <e_instruction_id Id, typename Op1> requires Integer<Op1>
consteval auto encode_call(instruction_desc desc, const Op1& op1) {
return encode_call<Id>(desc, immediate<std::uint32_t>(op1));
}
template <e_instruction_id Id, typename Op1> requires Immediate8<Op1>
consteval auto encode_jcc(instruction_desc desc, Op1 op1) {
auto opcode = desc.primary_opcode();
return internal::encode<Id, Op1, Void>(desc, opcode, op1.value());
}
template <e_instruction_id Id, typename Op1> requires (Immediate<Op1> || Register<Op1> || (Memory<Op1> && Register<typename Op1::value_type>))
consteval auto encode_jmp(instruction_desc desc, Op1 op1) {
auto id = desc.id();
auto opcode = desc.primary_opcode();
if constexpr (Immediate8<Op1>) {
opcode = static_cast<std::uint8_t>(0xeb);
return internal::encode<Id, Op1, Void>(
desc, opcode, op1.value()
);
} else if constexpr (Register<Op1> || (Memory<Op1> && Register<typename Op1::value_type>)) {
opcode = static_cast<std::uint8_t>(0xff);
return internal::encode<Id, Op1, Void>(
desc, opcode, encode_modrm(opcodeext_ff(id), op1)
);
} else if constexpr (Immediate<Op1>) {
return internal::encode<Id, Op1, Void>(
desc, opcode, op1.value()
);
}
}
template <int Len>
consteval auto encode_nop() {
if constexpr (Len == 1) {
return std::experimental::make_array<std::uint8_t>(0x90);
} else if constexpr (Len == 2) {
return std::experimental::make_array<std::uint8_t>(0x66, 0x90);
} else if constexpr (Len == 3) {
return std::experimental::make_array<std::uint8_t>(0x0F, 0x1F, 0x00);
} else if constexpr (Len == 4) {
return std::experimental::make_array<std::uint8_t>(0x0F, 0x1F, 0x40, 0x00);
} else if constexpr (Len == 5) {
return std::experimental::make_array<std::uint8_t>(0x0F, 0x1F, 0x44, 0x00, 0x00);
} else if constexpr (Len == 6) {
return std::experimental::make_array<std::uint8_t>(0x66, 0x0F, 0x1F, 0x44, 0x00, 0x00);
} else if constexpr (Len == 7) {
return std::experimental::make_array<std::uint8_t>(0x0F, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00);
} else if constexpr (Len == 8) {
return std::experimental::make_array<std::uint8_t>(0x0F, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00);
} else if constexpr (Len == 9) {
return std::experimental::make_array<std::uint8_t>(0x66, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00);
}
}
template <typename Op1, typename Op2> requires (Register<Op1> || Memory<Op1>) && (Register<Op2> || Memory<Op2> || Immediate<Op2>)
consteval auto encode_opcode_mov(const std::uint8_t& opcode) {
return static_cast<std::uint8_t>(
(opcode & 0b11111110) +
(Op2::size > 8 ? 0b01 : 0b00)// setup bit `s`
);
}
template <e_instruction_id Id, typename Op1, typename Op2> requires (Register<Op1> || Memory<Op1>) && (Register<Op2> || Memory<Op2> || Immediate<Op2>)
consteval auto encode_mov(instruction_desc desc, Op1 op1, Op2 op2) {
auto opcode = desc.primary_opcode();
if constexpr (Immediate<Op2>) {
if constexpr (Id != e_instruction_id::movabs) {
opcode = encode_opcode_mov<Op1, Op2>(0xC6);
return internal::encode<Id, Op1, Op2>(desc, opcode, encode_modrm(op1), op2.value());
} else {
return internal::encode<Id, Op1, Op2>(desc, opcode, op2.value());
}
} else {
opcode = encode_opcode_mov<Op1, Op2>(opcode);
return internal::encode<Id, Op1, Op2>(desc, opcode, encode_modrm(op1, op2));
}
}
template <e_instruction_id Id, typename Op1, typename Op2> requires Integer<Op2>
consteval auto encode_mov(instruction_desc desc, const Op1& op1, const Op2& op2) {
if constexpr (Id == e_instruction_id::movabs) {
return encode_mov<Id>(desc, op1, immediate<std::uint64_t>(op2));
} else {
return encode_mov<Id>(desc, op1, immediate<typename truncate_as<Op1>::type>(op2));
}
}
template <e_instruction_id Id, typename Op1> requires Register<Op1>
consteval auto encode_pop(instruction_desc desc, const Op1& op1) {
auto primary_opcode = desc.primary_opcode();
return std::experimental::make_array<std::uint8_t>(encode_opcode_pushpop(primary_opcode, op1));
}
template <e_instruction_id Id, typename Op1> requires (Register<Op1> || (Immediate<Op1> && (Op1::size == 8 || Op1::size == 32)))
consteval auto encode_push(instruction_desc desc, const Op1& op1) {
auto primary_opcode = desc.primary_opcode();
if constexpr (Immediate<Op1>) {
primary_opcode = 0x68;
if constexpr (Immediate8<Op1>) {
primary_opcode = 0x6A;
}
return internal::encode<Id, Op1, Void>(desc, primary_opcode, op1.value());
} else if constexpr (Register<Op1>) {
return std::experimental::make_array<std::uint8_t>(encode_opcode_pushpop(primary_opcode, op1));
}
}
template <e_instruction_id Id>
consteval auto encode_push(instruction_desc desc, const std::uint32_t& val) {
return encode_push<Id, imm32>(desc, imm32(val));
}
template <e_instruction_id Id, typename Op1> requires Immediate<Op1>
consteval auto encode_ret(instruction_desc desc, const Op1& op1) {
auto value = static_cast<std::uint16_t>(op1.value());
auto opcode = static_cast<std::uint8_t>(desc.primary_opcode() - 1);
return internal::encode<Id, Op1, Void>(desc, opcode, value);
}
template <e_instruction_id Id, typename Op1> requires Integer<Op1>
consteval auto encode_ret(instruction_desc desc, const Op1& op1) {
return encode_ret<Id>(desc, immediate<std::uint16_t>(op1));
}
template <e_instruction_id Id, typename Op1, typename Op2>
consteval auto encode(const Op1& op1, const Op2& op2) {
constexpr auto desc = find_instruction_desc<Id>();
if constexpr (desc.encoding() == e_encoding::alu) {
return encode_alu<Id>(desc, op1, op2);
} else if constexpr (desc.encoding() == e_encoding::bt) {
return encode_bt<Id>(desc, op1, op2);
} else if constexpr (desc.encoding() == e_encoding::mov) {
return encode_mov<Id>(desc, op1, op2);
} else {
static_assert("Failed to encode instruction");
}
}
template <e_instruction_id Id, typename Op1>
consteval auto encode(const Op1& op1) {
constexpr auto desc = find_instruction_desc<Id>();
if constexpr (desc.encoding() == e_encoding::ret) {
return encode_ret<Id>(desc, op1);
} else if constexpr (desc.encoding() == e_encoding::call) {
return encode_call<Id>(desc, op1);
} else if constexpr (desc.encoding() == e_encoding::pop) {
return encode_pop<Id>(desc, op1);
} else if constexpr (desc.encoding() == e_encoding::push) {
return encode_push<Id>(desc, op1);
} else if constexpr (desc.encoding() == e_encoding::jcc) {
return encode_jcc<Id>(desc, op1);
} else if constexpr (desc.encoding() == e_encoding::jmp) {
return encode_jmp<Id>(desc, op1);
} else {
static_assert("Failed to encode instruction");
}
}
template <e_instruction_id Id>
consteval auto encode() {
constexpr auto desc = find_instruction_desc<Id>();
constexpr auto size = (desc.prefix() != 0) + (desc.prefix_0f() != 0) + 1 /* _primary_opcode */ + (desc.secondary_opcode() != 0);
std::array<std::uint8_t, size> arr {};
int i = 0;
if (desc.prefix() != 0) {
arr[i++] = desc.prefix();
}
if (desc.prefix_0f() != 0) {
arr[i++] = desc.prefix_0f();
}
if (desc.primary_opcode() != 0) {
arr[i++] = desc.primary_opcode();
}
if (desc.secondary_opcode() != 0) {
arr[i++] = desc.secondary_opcode();
}
return arr;
}
template <e_instruction_id Id, typename ...Args>
consteval auto encode(Args&& ...args) {
return encode<Id, Args...>(std::forward<Args>(args)...);
}
}
| 40.929577
| 168
| 0.568651
|
Midi12
|
59e76a8e062fe5f05439964380b667a3c0124dce
| 48
|
hpp
|
C++
|
src/boost_graph_fruchterman_reingold.hpp
|
miathedev/BoostForArduino
|
919621dcd0c157094bed4df752b583ba6ea6409e
|
[
"BSL-1.0"
] | 10
|
2018-03-17T00:58:42.000Z
|
2021-07-06T02:48:49.000Z
|
src/boost_graph_fruchterman_reingold.hpp
|
miathedev/BoostForArduino
|
919621dcd0c157094bed4df752b583ba6ea6409e
|
[
"BSL-1.0"
] | 2
|
2021-03-26T15:17:35.000Z
|
2021-05-20T23:55:08.000Z
|
src/boost_graph_fruchterman_reingold.hpp
|
miathedev/BoostForArduino
|
919621dcd0c157094bed4df752b583ba6ea6409e
|
[
"BSL-1.0"
] | 4
|
2019-05-28T21:06:37.000Z
|
2021-07-06T03:06:52.000Z
|
#include <boost/graph/fruchterman_reingold.hpp>
| 24
| 47
| 0.833333
|
miathedev
|
59ea1959bf89148a5f80bc343352aad4f67105ab
| 3,793
|
cpp
|
C++
|
Firmware/app/alpha_nvc/main/nvs.cpp
|
eptecon/NoiseDetector
|
99c2cf4440a50f7b5511168a0ddaf7cdccc219c0
|
[
"MIT"
] | null | null | null |
Firmware/app/alpha_nvc/main/nvs.cpp
|
eptecon/NoiseDetector
|
99c2cf4440a50f7b5511168a0ddaf7cdccc219c0
|
[
"MIT"
] | null | null | null |
Firmware/app/alpha_nvc/main/nvs.cpp
|
eptecon/NoiseDetector
|
99c2cf4440a50f7b5511168a0ddaf7cdccc219c0
|
[
"MIT"
] | null | null | null |
//
// Created by Oleksandra Baga on 12.05.18.
//
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "nvs_flash.h"
#include "esp_err_to_name.c"
#include "nvs.h"
int16_t referenceVoltage = -1;
int16_t isBuzzerOn = -1;
int16_t isLedOn = -1;
int16_t noiseThreshold = -1;
esp_err_t err;
/******************************************************/
void nvs_init() {
err = nvs_flash_init();
if (err == ESP_ERR_NVS_NO_FREE_PAGES) {
// NVS partition was truncated and needs to be erased
// Retry nvs_flash_init
ESP_ERROR_CHECK(nvs_flash_erase());
err = nvs_flash_init();
}
ESP_ERROR_CHECK(err);
}
nvs_handle nvs_esp32_open() {
nvs_handle nvc_open_handle;
printf("\n");
printf("Opening Non-Volatile Storage (NVS) handle... ");
err = nvs_open("storage", NVS_READWRITE, &nvc_open_handle);
if (err != ESP_OK) {
printf("Error (%s) opening NVS handle!\n", esp_err_to_name(err));
} else {
printf("Done\n");
}
return nvc_open_handle;
}
int nvs_read_value(int varType) {
int16_t savedValue;
nvs_handle handle = nvs_esp32_open();
switch (varType) {
case NO_VARIABLE:
break;
case VARIABLE_SET_VOLTAGE:
printf("Reading reference voltage from NVS ...");
err = nvs_get_i16(handle, "refVoltage", &savedValue);
break;
case VARIABLE_SET_SOUND:
printf("Reading buzzer settings from NVS ...");
err = nvs_get_i16(handle, "buzzer", &savedValue);
break;
case VARIABLE_SET_LED:
printf("Reading LED settings from NVS ...");
err = nvs_get_i16(handle, "led", &savedValue);
break;
case VARIABLE_SET_THRESHOLD:
printf("Reading noise threshold from NVS ...");
err = nvs_get_i16(handle, "threshold", &savedValue);
break;
default:
break;
}
switch (err) {
case ESP_OK:
printf("Done\n");
printf("NVS Value = %d\n\n", savedValue);
break;
case ESP_ERR_NVS_NOT_FOUND:
printf("The value is not initialized yet!\n");
savedValue = -1;
break;
default :
printf("Error (%s) reading!\n", esp_err_to_name(err));
savedValue = -1;
}
nvs_close(handle);
return savedValue;
}
void nvs_write_value(int varType, int16_t value) {
nvs_handle handle = nvs_esp32_open();
switch (varType) {
case NO_VARIABLE:
break;
case VARIABLE_SET_VOLTAGE:
printf("Updating reference voltage in NVS ... ");
err = nvs_set_i16(handle, "refVoltage", value);
break;
case VARIABLE_SET_SOUND:
printf("Reading reference voltage from NVS ...");
err = nvs_set_i16(handle, "buzzer", value);
break;
case VARIABLE_SET_LED:
printf("Reading reference voltage from NVS ...");
err = nvs_set_i16(handle, "led", value);
break;
case VARIABLE_SET_THRESHOLD:
printf("Reading reference voltage from NVS ...");
err = nvs_set_i16(handle, "threshold", value);
break;
default:
break;
}
printf((err != ESP_OK) ? "Failed!\n" : "Done\n");
// Commit written value.
// After setting any values, nvs_commit() must be called to ensure changes are written
// to flash storage. Implementations may write to storage at other times,
// but this is not guaranteed.
printf("Committing updates in NVS ... ");
err = nvs_commit(handle);
printf((err != ESP_OK) ? "Failed!\n" : "Done\n");
nvs_close(handle);
}
| 28.734848
| 90
| 0.576852
|
eptecon
|
59ef478bbf4abc9533f542790e4f357f8da02245
| 12,009
|
cpp
|
C++
|
cache/current/debug.cpp
|
hcbozo/GUI
|
b243eafbf07ece3b09b32c46e36a4eb32708de8e
|
[
"MIT"
] | 3
|
2020-05-07T13:33:30.000Z
|
2021-06-04T17:18:25.000Z
|
cache/current/debug.cpp
|
bozotics/GUI
|
b243eafbf07ece3b09b32c46e36a4eb32708de8e
|
[
"MIT"
] | null | null | null |
cache/current/debug.cpp
|
bozotics/GUI
|
b243eafbf07ece3b09b32c46e36a4eb32708de8e
|
[
"MIT"
] | null | null | null |
#include "camera.h"
/*
This program will be run when it is connected to a laptop and the GUI program is launched
*/
void picam::debug()
{
debugCheck = true;
debugImages[0] = Mat::zeros(prop.height, prop.width, CV_8UC3);
Mat imageToSend, tempMat;
int imageSize, dualMode = 0, angle, distance;
unsigned int frameNum = 0, localBallCnt = 0, localGoalCnt = 0, localFieldCnt = 0;
int16_t conv;
vector<vector<Point> > contours;
Rect pBound, rBound;
RotatedRect bBound, yBound, fBound;
Point2f bBoundPoints[4], yBoundPoints[4], fBoundPoints[4];
socketConnect();
sendImageDims();
thread threadCommands(&picam::receiveCommands, this); //thread for receiving from the computer
thread threadFrame(&picam::getFrame, this); //thread for reading frames from the camera
thread threadBall(&picam::processBall, this); //thread for tracking ball
thread threadGoal(&picam::processGoal, this); //thread for tracking goal
thread threadField(&picam::processField, this); //thread for tracking field
while(!stopped.load(memory_order_acq_rel)) //will run until pause command is sent or GUI is closed
{
if(frameNum != bufferPosition.load(memory_order_acq_rel))
{
frameNum = bufferPosition.load(memory_order_acq_rel);
//generate the image for different modes
debugImages[0] = image[frameNum].clone();
//cout << image[frameNum].rows << " " << image[frameNum].cols << endl;
cvtColor(debugImages[0], debugImages[1], COLOR_BGR2HSV);
debugImages[5] = debugImages[0].clone();
debugImages[6] = debugImages[0].clone();
debugImages[7] = debugImages[0].clone();
medianBlur(debugImages[1], debugImages[2], 3);
if(trackType < 4)
inRangeHSV(trackType, debugImages[2], debugImages[8], tempMat);
else
inRangeHSV(0, debugImages[2], debugImages[8], tempMat);
cvtColor(debugImages[8], debugImages[3], COLOR_GRAY2BGR);
dilate(debugImages[8], debugImages[8], kernel, Point(-1, -1), 3);
erode(debugImages[8], debugImages[8], kernel, Point(-1, -1), 3);
bitwise_and(circleMask, debugImages[8], debugImages[8]); //change to bitwise_and to remove circle
cvtColor(debugImages[8], debugImages[4], COLOR_GRAY2BGR);
findContours(debugImages[8], contours, RETR_TREE, CHAIN_APPROX_SIMPLE);
if(contours.size() > 0)
{
for (vector<Point> contour : contours){
drawContours(debugImages[5], vector<vector<Point> >(1,contour), -1, CV_RGB(0, 0, 0), 1, 8);
}
sort(contours.begin(), contours.end(), [](const vector<Point>& c1, const vector<Point>& c2){
return contourArea(c1, false) < contourArea(c2, false);
});
}
//read data the tracking threads
read.lock();
if(trackType == 0 || trackType == 4){
if(localBallCnt < ballCnt.load(memory_order_acq_rel))
{
localBallCnt = ballCnt.load(memory_order_acq_rel);
rBound = rBall[localBallCnt%3];
pBound = pBall[localBallCnt%3];
if(rBound.width != 0)
{
distance = (int)sqrt(pow(rBound.x, 2) + pow(rBound.y, 2));
angle = (int)(atan2(rBound.y, rBound.x)/PI*180+360);
if(angle >= 360) angle-=360;
cout << rBound.x << ", " << rBound.y << ": " << distance << " " << angle << endl;
//inttochar(distance, sendArray, arrayPos);
//inttochar(angle, sendArray, arrayPos);
rBound.x = distanceUnmapper((double)rBound.x, prop.x);
rBound.y = distanceUnmapper((double)rBound.y, prop.y);
if((dualMode==0 && showFrame==6) || (dualMode==1 && showFrame2==6) || trackType == 4)
rectangle(debugImages[(!dualMode) ? showFrame : showFrame2], rBound, CV_RGB(255,165,0), 2);
}
if(pBound.width != 0)
{
pBound.x = distanceUnmapper((double)pBound.x, prop.x);
pBound.y = distanceUnmapper((double)pBound.y, prop.y);
if((dualMode==0 && showFrame==6) || (dualMode==1 && showFrame2==6) || trackType == 4)
rectangle(debugImages[(!dualMode) ? showFrame : showFrame2], pBound, CV_RGB(255,69,0), 2);
}
}
}
if(trackType == 1 || trackType == 2 || trackType == 4){
if(localGoalCnt < goalCnt.load(memory_order_acq_rel))
{
localGoalCnt = goalCnt.load(memory_order_acq_rel);
bBound = bGoal[localGoalCnt%3];
yBound = yGoal[localGoalCnt%3];
if(bBound.size.width != 1000)
{
int aveX = 0, aveY = 0;
bBound.points(bBoundPoints);
for(int i = 0 ; i < 4; ++i)
{
aveX += bBoundPoints[i].x;
aveY += bBoundPoints[i].y;
}
if((dualMode==0 && showFrame==6) || (dualMode==1 && showFrame2==6) || trackType == 4)
{
for (int i = 0; i < 4; i++)
line(debugImages[(!dualMode) ? showFrame : showFrame2], bBoundPoints[i], bBoundPoints[(i+1)%4], CV_RGB(0, 0, 255), 2);
circle(debugImages[(!dualMode) ? showFrame : showFrame2], Point((int)aveX/4, (int)aveY/4), 1, Scalar(0, 255, 0), 1);
}
aveX = (aveX/4)-prop.x;
aveY = (aveY/4)-prop.y;
distance = (int)distanceMapper(sqrt(pow(aveX, 2) + pow(aveY, 2)), zero);
angle = (int)(atan2(aveY, aveX)/PI*180+360);
if(angle >= 360) angle-=360;
cout << "goal: " << distance << " " << angle << endl;
}
if(yBound.size.width != 1000)
{
yBound.points(yBoundPoints);
if((dualMode==0 && showFrame==6) || (dualMode==1 && showFrame2==6) || trackType == 4)
for (int i = 0; i < 4; i++)
line(debugImages[(!dualMode) ? showFrame : showFrame2], yBoundPoints[i], yBoundPoints[(i+1)%4], CV_RGB(255, 255, 0), 2);
}
}
}
if(trackType == 3 || trackType == 4){
if(localFieldCnt < fieldCnt.load(memory_order_acq_rel))
{
localFieldCnt = fieldCnt.load(memory_order_acq_rel);
fBound = field[localFieldCnt%3];
if(fBound.size.width != 1000)
{
fBound.points(fBoundPoints);
if((dualMode==0 && showFrame==6) || (dualMode==1 && showFrame2==6) || trackType == 4)
for (int i = 0; i < 4; i++)
line(debugImages[(!dualMode) ? showFrame : showFrame2], fBoundPoints[i], fBoundPoints[(i+1)%4], CV_RGB(0, 255, 0), 2);
}
}
}
imageToSend = debugImages[(!dualMode) ? showFrame : showFrame2].reshape(0,1);
read.unlock();
imageSize = imageToSend.total() * imageToSend.elemSize();
conv = htons(dualMode);
send(socketIdentity, (char*)&conv, sizeof(uint16_t), 0);
send(socketIdentity, imageToSend.data, imageSize, 0);
dualMode = (dualMode+1)%2; //select the other frame to send over in the next iteration
}
else
usleep(2000);
}
cout << "debug\n";
//clean up procedure
threadCommands.join();
threadFrame.join();
threadBall.join();
threadGoal.join();
threadField.join();
close(socketIdentity);
Camera.release();
}
/*
Commands are orgnised in such a way:
type:
0 Stop program
1-24 Colour values for tracking
25 White balance red value
26 White balance blue value
27 Exposure Compensation
28 Brightness
29 Saturation
30 Shutter speed
31 ISO
32 Mode of screen 1
33 Mode of screen 2
34 Tracktype
value:
value of a setting for the chosen type
*/
void picam::receiveCommands()
{
int type, val, prevType = 0, prevVal = 1;
while(!stopped.load(memory_order_acq_rel)){
recv(socketIdentity, (char*)&type, sizeof(uint16_t), 0);
recv(socketIdentity, (char*)&val, sizeof(uint16_t), 0);
type = ntohs(type);
val = ntohs(val);
if(type != prevType || val != prevVal)
{
read.lock();
prevType = type;
prevVal = val;
if(type == 0) stopped.store(true, memory_order_acq_rel);
else if(type <= 24)
{
tempThres[type-1] = val;
if((type-1)%6 <= 2 && (type-1)%6 >= 0){
if(val > tempThres[type+2]){
thres[type-1] = tempThres[type-1];
thres[type+2] = tempThres[type+2];
}
}
else if((type-1)%6 <=5 && (type-1)%6 >= 3){
if(val < tempThres[type-4]){
thres[type-1] = tempThres[type-1];
thres[type-4] = tempThres[type-4];
}
}
}
else if(type == 25)
{
prop.configVal[0] = val;
Camera.setAWB_RB((float)prop.configVal[0]/10.0, (float)prop.configVal[1]/10.0);
}
else if(type == 26)
{
prop.configVal[1] = val;
Camera.setAWB_RB((float)prop.configVal[0]/10.0, (float)prop.configVal[1]/10.0);
}
else if(type == 27) Camera.setExposureCompensation(val);
else if(type == 28) Camera.setBrightness(val);
else if(type == 29) Camera.setSaturation(val);
else if(type == 30) Camera.setShutterSpeed(val);
else if(type == 31) Camera.setISO(val);
else if(type == 32) showFrame = val;
else if(type == 33) showFrame2 = val;
else if(type == 34) trackType = val;
read.unlock();
}
}
cout << "commands\n";
}
void picam::socketConnect()
{
struct addrinfo addrinfo_hints;
struct addrinfo* addrinfo_resp;
const char* hostname = "192.168.7.17";
int port = 12345;
// Specify criteria for address structs to be returned by getAddrinfo
memset(&addrinfo_hints, 0, sizeof(addrinfo_hints));
addrinfo_hints.ai_socktype = SOCK_STREAM;
addrinfo_hints.ai_family = AF_INET;
// Populate addr_info_resp with address responses matching hints
if (getaddrinfo(hostname, to_string(port).c_str(),
&addrinfo_hints, &addrinfo_resp) != 0) {
perror("Couldn't connect to host!");
exit(1);
}
// Create socket file descriptor for server
socketIdentity = socket(addrinfo_resp->ai_family, addrinfo_resp->ai_socktype, addrinfo_resp->ai_protocol);
if (socketIdentity == -1) {
perror("Error opening socket");
exit(1);
}
// Connect to server specified in address struct, assign process to server
// file descriptor
if (connect(socketIdentity, addrinfo_resp->ai_addr,addrinfo_resp->ai_addrlen) == -1) {
perror("Error connecting to address");
exit(1);
}
free(addrinfo_resp);
}
void picam::sendImageDims()
{
// Send number of rows to server
if (send(socketIdentity, (char*)&prop.width, sizeof(prop.width), 0) == -1) {
perror("Error sending rows");
exit(1);
}
// Send number of cols to server
if (send(socketIdentity, (char*)&prop.height, sizeof(prop.height), 0) == -1) {
perror("Error sending cols");
exit(1);
}
}
| 41.98951
| 152
| 0.536431
|
hcbozo
|
59f16c6658088da17b6c8f2abf1b46ce2611a36c
| 818
|
cpp
|
C++
|
Sources/Engine/Graphics/VertexFormats/VertexPositionTexture.cpp
|
jdelezenne/Sonata
|
fb1b1b64a78874a0ab2809995be4b6f14f9e4d56
|
[
"MIT"
] | null | null | null |
Sources/Engine/Graphics/VertexFormats/VertexPositionTexture.cpp
|
jdelezenne/Sonata
|
fb1b1b64a78874a0ab2809995be4b6f14f9e4d56
|
[
"MIT"
] | null | null | null |
Sources/Engine/Graphics/VertexFormats/VertexPositionTexture.cpp
|
jdelezenne/Sonata
|
fb1b1b64a78874a0ab2809995be4b6f14f9e4d56
|
[
"MIT"
] | null | null | null |
/*=============================================================================
VertexPositionTexture.cpp
Project: Sonata Engine
Author: Julien Delezenne
=============================================================================*/
#include "VertexPositionTexture.h"
namespace SonataEngine
{
const VertexElement VertexPositionTexture::VertexElements[] =
{
VertexElement(0, 0, VertexFormat_Float3, VertexSemantic_Position, 0),
VertexElement(0, 12, VertexFormat_Float2, VertexSemantic_TextureCoordinate, 0)
};
const int VertexPositionTexture::ElementCount = 2;
const int VertexPositionTexture::SizeInBytes = sizeof(VertexPositionTexture);
VertexPositionTexture::VertexPositionTexture(const Vector3& position, const Vector2& textureCoordinate)
{
Position = position;
TextureCoordinate = textureCoordinate;
}
}
| 30.296296
| 103
| 0.663814
|
jdelezenne
|
94013edf38b17032aa44dbfdfb6f838decc6fcf4
| 7,836
|
cpp
|
C++
|
kernel/src/core/virtualmemory.cpp
|
Remco123/CactusOS
|
de4c61211c2908cf1a27d8ccbeb6340133772454
|
[
"MIT"
] | 87
|
2019-03-04T21:16:20.000Z
|
2022-01-30T15:10:44.000Z
|
kernel/src/core/virtualmemory.cpp
|
Remco123/CactusOS
|
de4c61211c2908cf1a27d8ccbeb6340133772454
|
[
"MIT"
] | 5
|
2019-04-24T10:33:55.000Z
|
2021-06-13T09:46:28.000Z
|
kernel/src/core/virtualmemory.cpp
|
Remco123/CactusOS
|
de4c61211c2908cf1a27d8ccbeb6340133772454
|
[
"MIT"
] | 2
|
2020-11-13T08:56:09.000Z
|
2021-08-01T06:38:31.000Z
|
#include <core/virtualmemory.h>
#include <system/log.h>
#include <system/debugger.h>
using namespace CactusOS;
using namespace CactusOS::common;
using namespace CactusOS::core;
using namespace CactusOS::system;
void VirtualMemoryManager::ReloadCR3()
{
asm volatile("movl %cr3,%eax");
asm volatile("movl %eax,%cr3");
}
void VirtualMemoryManager::Initialize()
{
BootConsole::WriteLine("Intializing Paging");
// Re-use the page directory setup by the loader
PageDirectory* pageDirectory = (PageDirectory*)&BootPageDirectory;
// Set the last pde to the page directory itself
// With this we can use recursive page tables
PageDirectoryEntry lastPDE;
MemoryOperations::memset(&lastPDE, 0, sizeof(PageDirectoryEntry));
lastPDE.frame = virt2phys((uint32_t)&BootPageDirectory) / PAGE_SIZE;
lastPDE.readWrite = 1;
lastPDE.pageSize = FOUR_KB;
lastPDE.present = 1;
pageDirectory->entries[1023] = lastPDE;
/*
What we do here is create a new pagetable for the kernel, currently is mapped by a 4mb page by the bootloader
But because we can (at least should) not access the physical allocated block directly, we need to add
it to the page directory first. But when we do that the physical page table is empty or contains junk, here is where the problem occurs.
Because of the junk qemu sometimes crashes and this could be possible on real hardware as well.
So for now just use the 4mb page for the kernel setup by the loader until we find a solution to this.
*/
#if 0
//One pagetable for the kernel
void* kernelPageTablePhysAddress = PhysicalMemoryManager::AllocateBlock();
PageDirectoryEntry kernelPDE;
MemoryOperations::memset(&kernelPDE, 0, sizeof(PageDirectoryEntry));
kernelPDE.frame = (uint32_t)kernelPageTablePhysAddress / PAGE_SIZE;
kernelPDE.readWrite = 1;
kernelPDE.pageSize = FOUR_KB;
kernelPDE.present = 1;
pageDirectory->entries[KERNEL_PTNUM] = kernelPDE;
//Fill in the page table
PageTable* kernelPageTable = (PageTable*)GetPageTableAddress(KERNEL_PTNUM);
for(uint16_t i = 0; i < 1024; i++)
{
kernelPageTable->entries[i].frame = i;
kernelPageTable->entries[i].isUser = 0;
kernelPageTable->entries[i].readWrite = 1;
kernelPageTable->entries[i].present = 1;
}
#endif
// Here we map some pages for the initial kernel heap
for(uint32_t i = KERNEL_HEAP_START; i < KERNEL_HEAP_START + KERNEL_HEAP_SIZE; i += PAGE_SIZE)
AllocatePage(GetPageForAddress(i, true), true, true);
// The first 4mb are identity mapped, this is needed for the smbios and the vm86 code
MemoryOperations::memset(&pageDirectory->entries[0], 0, sizeof(PageDirectoryEntry));
pageDirectory->entries[0].frame = (uint32_t)PhysicalMemoryManager::AllocateBlock() / PAGE_SIZE;
pageDirectory->entries[0].pageSize = FOUR_KB;
pageDirectory->entries[0].present = 1;
pageDirectory->entries[0].readWrite = 1;
pageDirectory->entries[0].isUser = 1;
// Create required entries for the first 4 MB of memory
PageTable* fourMB_PT = (PageTable*)GetPageTableAddress(0);
MemoryOperations::memset(fourMB_PT, 0, sizeof(PageTable));
// Make whole first block kernel accessable (except for the first 4096 bytes)
// This way we can catch null-pointers
for(uint16_t i = 1; i < 1024; i++)
{
fourMB_PT->entries[i].frame = i; // Identity map memory
fourMB_PT->entries[i].isUser = 0; // Only for kernel
fourMB_PT->entries[i].readWrite = 1; // We should be able to write to it (for VESA and stuff)
fourMB_PT->entries[i].present = 1; // Makes sense I hope
}
// Create entries required for VM86
for(uint32_t i = PAGE_SIZE; i < pageRoundUp(1_MB); i += PAGE_SIZE) {
uint16_t index = PAGETBL_INDEX(i);
fourMB_PT->entries[index].isUser = 1;
}
// Create entry 0 as well, just don't mark it as present (yet)
fourMB_PT->entries[0].frame = 0;
fourMB_PT->entries[0].isUser = 1;
fourMB_PT->entries[0].readWrite = 1;
fourMB_PT->entries[0].present = 0; // Very Important!
// Finally reload the cr3 register
ReloadCR3();
}
PageTableEntry* VirtualMemoryManager::GetPageForAddress(uint32_t virtualAddress, bool shouldCreate, bool readWrite, bool userPages)
{
uint32_t pageDirIndex = PAGEDIR_INDEX(virtualAddress);
uint32_t pageTableIndex = PAGETBL_INDEX(virtualAddress);
PageDirectory* pageDir = (PageDirectory*)PAGE_DIRECTORY_ADDRESS;
if(pageDir->entries[pageDirIndex].present == 0 && shouldCreate)
{
void* pageTablePhys = PhysicalMemoryManager::AllocateBlock();
MemoryOperations::memset(&pageDir->entries[pageDirIndex], 0, sizeof(PageDirectoryEntry));
pageDir->entries[pageDirIndex].frame = (uint32_t)pageTablePhys / PAGE_SIZE;
pageDir->entries[pageDirIndex].readWrite = readWrite;
pageDir->entries[pageDirIndex].isUser = userPages;
pageDir->entries[pageDirIndex].pageSize = FOUR_KB;
pageDir->entries[pageDirIndex].present = 1;
PageTable* pageTableVirt = (PageTable*)GetPageTableAddress(pageDirIndex);
MemoryOperations::memset(pageTableVirt, 0, sizeof(PageTable));
return &(pageTableVirt->entries[pageTableIndex]);
}
PageTable* pageTable = (PageTable*)GetPageTableAddress(pageDirIndex);
return &pageTable->entries[pageTableIndex];
}
void VirtualMemoryManager::AllocatePage(PageTableEntry* page, bool kernel, bool writeable)
{
void* p = PhysicalMemoryManager::AllocateBlock();
if(!p)
return;
page->present = 1;
page->readWrite = writeable ? 1 : 0;
page->isUser = kernel ? 0 : 1;
page->frame = (uint32_t)p / PAGE_SIZE;
}
void VirtualMemoryManager::FreePage(PageTableEntry* page)
{
void* addr = (void*)(page->frame * PAGE_SIZE);
if(addr)
PhysicalMemoryManager::FreeBlock(addr);
page->present = 0;
}
void* VirtualMemoryManager::GetPageTableAddress(uint16_t pageTableNumber)
{
uint32_t ret = PAGE_TABLE_ADDRESS;
ret |= (pageTableNumber << PAGE_OFFSET_BITS);
return (void*)ret;
}
void* VirtualMemoryManager::virtualToPhysical(void* virtAddress)
{
uint32_t pd_offset = PAGEDIR_INDEX(virtAddress);
uint32_t pt_offset = PAGETBL_INDEX(virtAddress);
uint32_t p_offset = PAGEFRAME_INDEX(virtAddress);
PageTable* pageTable = (PageTable*)(PAGE_TABLE_ADDRESS + (PAGE_SIZE * pd_offset));
PageTableEntry pageTableEntry = pageTable->entries[pt_offset];
uint32_t physAddress = (pageTableEntry.frame * PAGE_SIZE) | p_offset;
return (void*)physAddress;
}
void VirtualMemoryManager::mapVirtualToPhysical(void* physAddress, void* virtAddress, bool kernel, bool writeable)
{
PageTableEntry* page = GetPageForAddress((uint32_t)virtAddress, true, writeable, !kernel);
page->frame = (uint32_t)physAddress / PAGE_SIZE;
page->isUser = kernel ? 0 : 1;
page->readWrite = writeable ? 1 : 0;
page->present = 1;
invlpg(virtAddress);
}
void VirtualMemoryManager::mapVirtualToPhysical(void* physAddress, void* virtAddress, uint32_t size, bool kernel, bool writeable)
{
if(size % PAGE_SIZE != 0) {
Log(Error, "mapVirtualToPhysical(): Size is not devisible by PAGE_SIZE. Size = %d.", size);
return;
}
for(uint32_t i = 0; i < size; i += PAGE_SIZE)
{
mapVirtualToPhysical((void*)((uint32_t)physAddress + i), (void*)((uint32_t)virtAddress + i), kernel, writeable);
}
}
void VirtualMemoryManager::SwitchPageDirectory(uint32_t physAddr)
{
asm volatile("mov %0, %%cr3" :: "r"(physAddr));
}
uint32_t VirtualMemoryManager::GetPageDirectoryAddress()
{
uint32_t cr3;
asm volatile("mov %%cr3, %0" : "=r"(cr3));
return cr3;
}
| 37.492823
| 144
| 0.696529
|
Remco123
|
9402eff23a9cb3618d903f34b4b001f7c8683b5c
| 1,711
|
cpp
|
C++
|
test/suites/LoginLeasedTest.cpp
|
eburghar/cconfd
|
7e053b695e07bc0858902db7d24b62499936ff29
|
[
"Apache-2.0",
"MIT"
] | null | null | null |
test/suites/LoginLeasedTest.cpp
|
eburghar/cconfd
|
7e053b695e07bc0858902db7d24b62499936ff29
|
[
"Apache-2.0",
"MIT"
] | null | null | null |
test/suites/LoginLeasedTest.cpp
|
eburghar/cconfd
|
7e053b695e07bc0858902db7d24b62499936ff29
|
[
"Apache-2.0",
"MIT"
] | null | null | null |
#include "components/LoginLeased.h"
#include <gtest/gtest.h>
// TODO test reply error
// {
// "errors": [
// "{\"kind\":\"Status\",\"apiVersion\":\"v1\",\"metadata\":{},\"status\":\"Failure\",\"message\":\"tokenreviews.authentication.k8s.io is forbidden: User \\\"system:serviceaccount:default:default\\\" cannot create resource \\\"tokenreviews\\\" in API group \\\"authentication.k8s.io\\\" at the cluster scope\",\"reason\":\"Forbidden\",\"details\":{\"group\":\"authentication.k8s.io\",\"kind\":\"tokenreviews\"},\"code\":403}"
// ]
// }
class LoginLeasedTest : public ::testing::Test
{
protected:
LoginLeasedTest()
: injector(getLoginLeasedComponent)
, login(injector)
{}
void SetUp() override{};
// injector delete all injected object, so it must be bound to Fixture
// lifetime hence declared as member and initialized in constructor
fruit::Injector<Login> injector;
Login* login;
};
// Login creation
TEST_F(LoginLeasedTest, Create)
{
std::string token;
// no token has been set
ASSERT_FALSE(login->getToken(token));
// login is not valid without token
ASSERT_FALSE(login->isValid());
}
// Login validity
TEST_F(LoginLeasedTest, Validity)
{
const std::string token = "test";
ASSERT_TRUE(login->setToken(token, std::chrono::minutes(1)));
// login with token is valid
ASSERT_TRUE(login->isValid());
std::string token2;
// token has been set
ASSERT_TRUE(login->getToken(token2));
// an values equals
ASSERT_EQ(token, token2);
}
// Login expired
TEST_F(LoginLeasedTest, Expired)
{
const std::string token = "test";
ASSERT_TRUE(login->setToken(token, std::chrono::minutes(-1)));
// login has expired
ASSERT_FALSE(login->isValid());
}
| 28.516667
| 429
| 0.681473
|
eburghar
|
940560556f4357acf04ddbe007222266e2a24bf2
| 10,445
|
cpp
|
C++
|
src/Rendering/GUI/QtGUI/PPropertyWidget.cpp
|
devenguo/peridyno
|
e9e18a9aa676664e9be75140fad987d3b1ad2fc1
|
[
"Apache-2.0"
] | null | null | null |
src/Rendering/GUI/QtGUI/PPropertyWidget.cpp
|
devenguo/peridyno
|
e9e18a9aa676664e9be75140fad987d3b1ad2fc1
|
[
"Apache-2.0"
] | null | null | null |
src/Rendering/GUI/QtGUI/PPropertyWidget.cpp
|
devenguo/peridyno
|
e9e18a9aa676664e9be75140fad987d3b1ad2fc1
|
[
"Apache-2.0"
] | null | null | null |
#include "PPropertyWidget.h"
#include "Module.h"
#include "Node.h"
#include "SceneGraph.h"
#include "NodeEditor/QtNodeWidget.h"
#include "NodeEditor/QtModuleWidget.h"
#include "PCustomWidgets.h"
#include "Common.h"
#include <QGroupBox>
#include <QLabel>
#include <QCheckBox>
#include <QPushButton>
#include <QSlider>
#include <QSpinBox>
#include <QRegularExpression>
#include <QMessageBox>
namespace dyno
{
QBoolFieldWidget::QBoolFieldWidget(FBase* field)
: QGroupBox()
{
m_field = field;
FVar<bool>* f = TypeInfo::cast<FVar<bool>>(m_field);
if (f == nullptr)
{
return;
}
this->setStyleSheet("border:none");
QGridLayout* layout = new QGridLayout;
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
this->setLayout(layout);
QLabel* name = new QLabel();
name->setFixedSize(160, 18);
name->setText(FormatFieldWidgetName(field->getObjectName()));
QCheckBox* checkbox = new QCheckBox();
//checkbox->setFixedSize(40, 18);
layout->addWidget(name, 0, 0);
layout->addWidget(checkbox, 0, 1);
connect(checkbox, SIGNAL(stateChanged(int)), this, SLOT(changeValue(int)));
checkbox->setChecked(f->getData());
}
void QBoolFieldWidget::changeValue(int status)
{
FVar<bool>* f = TypeInfo::cast<FVar<bool>>(m_field);
if (f == nullptr)
{
return;
}
if (status == Qt::Checked)
{
f->setValue(true);
f->update();
}
else if (status == Qt::PartiallyChecked)
{
//m_pLabel->setText("PartiallyChecked");
}
else
{
f->setValue(false);
f->update();
}
emit fieldChanged();
}
QIntegerFieldWidget::QIntegerFieldWidget(FBase* field)
: QGroupBox()
{
m_field = field;
FVar<int>* f = TypeInfo::cast<FVar<int>>(m_field);
if (f == nullptr)
{
return;
}
this->setStyleSheet("border:none");
QGridLayout* layout = new QGridLayout;
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
this->setLayout(layout);
QLabel* name = new QLabel();
name->setFixedSize(160, 18);
name->setText(FormatFieldWidgetName(field->getObjectName()));
QSpinBox* spinner = new QSpinBox;
spinner->setValue(f->getData());
layout->addWidget(name, 0, 0);
layout->addWidget(spinner, 0, 1, Qt::AlignRight);
this->connect(spinner, SIGNAL(valueChanged(int)), this, SLOT(changeValue(int)));
}
void QIntegerFieldWidget::changeValue(int value)
{
FVar<int>* f = TypeInfo::cast<FVar<int>>(m_field);
if (f == nullptr)
{
return;
}
f->setValue(value);
f->update();
emit fieldChanged();
}
QRealFieldWidget::QRealFieldWidget(FBase* field)
: QGroupBox()
{
m_field = field;
this->setStyleSheet("border:none");
QGridLayout* layout = new QGridLayout;
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
this->setLayout(layout);
QLabel* name = new QLabel();
name->setFixedSize(160, 18);
name->setText(FormatFieldWidgetName(field->getObjectName()));
QDoubleSlider* slider = new QDoubleSlider;
//slider->setFixedSize(80,18);
//slider->setRange(m_field->getMin(), m_field->getMax());
slider->setRange(0, 1);
QLabel* spc = new QLabel();
spc->setFixedSize(10, 18);
QDoubleSpinner* spinner = new QDoubleSpinner;
spinner->setFixedSize(100, 18);
//spinner->setRange(m_field->getMin(), m_field->getMax());
spinner->setRange(0, 1);
layout->addWidget(name, 0, 0);
layout->addWidget(slider, 0, 1);
layout->addWidget(spc, 0, 2);
layout->addWidget(spinner, 0, 3, Qt::AlignRight);
QObject::connect(slider, SIGNAL(valueChanged(double)), spinner, SLOT(setValue(double)));
QObject::connect(spinner, SIGNAL(valueChanged(double)), slider, SLOT(setValue(double)));
QObject::connect(spinner, SIGNAL(valueChanged(double)), this, SLOT(changeValue(double)));
std::string template_name = field->getTemplateName();
if (template_name == std::string(typeid(float).name()))
{
FVar<float>* f = TypeInfo::cast<FVar<float>>(m_field);
slider->setValue((double)f->getValue());
}
else if(template_name == std::string(typeid(double).name()))
{
FVar<double>* f = TypeInfo::cast<FVar<double>>(m_field);
slider->setValue(f->getValue());
}
FormatFieldWidgetName(field->getObjectName());
}
void QRealFieldWidget::changeValue(double value)
{
std::string template_name = m_field->getTemplateName();
if (template_name == std::string(typeid(float).name()))
{
FVar<float>* f = TypeInfo::cast<FVar<float>>(m_field);
f->setValue((float)value);
f->update();
}
else if (template_name == std::string(typeid(double).name()))
{
FVar<double>* f = TypeInfo::cast<FVar<double>>(m_field);
f->setValue(value);
f->update();
}
emit fieldChanged();
}
QVector3FieldWidget::QVector3FieldWidget(FBase* field)
: QGroupBox()
{
m_field = field;
this->setStyleSheet("border:none");
QGridLayout* layout = new QGridLayout;
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
this->setLayout(layout);
QLabel* name = new QLabel();
name->setFixedSize(160, 18);
name->setText(FormatFieldWidgetName(field->getObjectName()));
spinner1 = new QDoubleSpinner;
spinner1->setRange(m_field->getMin(), m_field->getMax());
spinner2 = new QDoubleSpinner;
spinner2->setRange(m_field->getMin(), m_field->getMax());
spinner3 = new QDoubleSpinner;
spinner3->setRange(m_field->getMin(), m_field->getMax());
layout->addWidget(name, 0, 0);
layout->addWidget(spinner1, 0, 1);
layout->addWidget(spinner2, 0, 2);
layout->addWidget(spinner3, 0, 3);
std::string template_name = m_field->getTemplateName();
double v1 = 0;
double v2 = 0;
double v3 = 0;
if (template_name == std::string(typeid(Vec3f).name()))
{
FVar<Vec3f>* f = TypeInfo::cast<FVar<Vec3f>>(m_field);
auto v = f->getData();
v1 = v[0];
v2 = v[1];
v3 = v[2];
}
else if (template_name == std::string(typeid(Vec3d).name()))
{
FVar<Vec3d>* f = TypeInfo::cast<FVar<Vec3d>>(m_field);
auto v = f->getData();
v1 = v[0];
v2 = v[1];
v3 = v[2];
}
spinner1->setValue(v1);
spinner2->setValue(v2);
spinner3->setValue(v3);
QObject::connect(spinner1, SIGNAL(valueChanged(double)), this, SLOT(changeValue(double)));
QObject::connect(spinner2, SIGNAL(valueChanged(double)), this, SLOT(changeValue(double)));
QObject::connect(spinner3, SIGNAL(valueChanged(double)), this, SLOT(changeValue(double)));
}
void QVector3FieldWidget::changeValue(double value)
{
double v1 = spinner1->value();
double v2 = spinner2->value();
double v3 = spinner3->value();
std::string template_name = m_field->getTemplateName();
if (template_name == std::string(typeid(Vec3f).name()))
{
FVar<Vec3f>* f = TypeInfo::cast<FVar<Vec3f>>(m_field);
f->setValue(Vec3f((float)v1, (float)v2, (float)v3));
f->update();
}
else if (template_name == std::string(typeid(Vec3d).name()))
{
FVar<Vec3d>* f = TypeInfo::cast<FVar<Vec3d>>(m_field);
f->setValue(Vec3d(v1, v2, v3));
f->update();
}
emit fieldChanged();
}
//QWidget-->QVBoxLayout-->QScrollArea-->QWidget-->QGridLayout
PPropertyWidget::PPropertyWidget(QWidget *parent)
: QWidget(parent)
, m_main_layout()
{
m_main_layout = new QVBoxLayout;
m_scroll_area = new QScrollArea;
m_main_layout->setContentsMargins(0, 0, 0, 0);
m_main_layout->setSpacing(0);
m_main_layout->addWidget(m_scroll_area);
m_scroll_area->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
m_scroll_area->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
m_scroll_area->setWidgetResizable(true);
m_scroll_layout = new QGridLayout;
m_scroll_layout->setAlignment(Qt::AlignLeft | Qt::AlignTop);
QWidget * m_scroll_widget = new QWidget;
m_scroll_widget->setLayout(m_scroll_layout);
m_scroll_area->setWidget(m_scroll_widget);
setMinimumWidth(250);
setLayout(m_main_layout);
}
PPropertyWidget::~PPropertyWidget()
{
m_widgets.clear();
}
QSize PPropertyWidget::sizeHint() const
{
return QSize(20, 20);
}
QWidget* PPropertyWidget::addWidget(QWidget* widget)
{
m_scroll_layout->addWidget(widget);
m_widgets.push_back(widget);
return widget;
}
void PPropertyWidget::removeAllWidgets()
{
//TODO: check whether m_widgets[i] should be explicitly deleted
for (int i = 0; i < m_widgets.size(); i++)
{
m_scroll_layout->removeWidget(m_widgets[i]);
delete m_widgets[i];
}
m_widgets.clear();
}
void PPropertyWidget::showProperty(Module* module)
{
// clear();
updateContext(module);
}
void PPropertyWidget::showProperty(Node* node)
{
// clear();
updateContext(node);
}
void PPropertyWidget::showBlockProperty(Qt::QtNode& block)
{
auto dataModel = block.nodeDataModel();
auto node = dynamic_cast<Qt::QtNodeWidget*>(dataModel);
if (node != nullptr)
{
this->showProperty(node->getNode().get());
}
else
{
auto module = dynamic_cast<Qt::QtModuleWidget*>(dataModel);
if (module != nullptr)
{
this->showProperty(module->getModule());
}
}
}
void PPropertyWidget::updateDisplay()
{
// PVTKOpenGLWidget::getCurrentRenderer()->GetActors()->RemoveAllItems();
// SceneGraph::getInstance().draw();
// PVTKOpenGLWidget::getCurrentRenderer()->GetRenderWindow()->Render();
}
void PPropertyWidget::updateContext(OBase* base)
{
if (base == nullptr)
{
return;
}
this->removeAllWidgets();
std::vector<FBase*>& fields = base->getParameters();
for each (FBase* var in fields)
{
if (var != nullptr)
{
if (var->getClassName() == std::string("FVar"))
{
this->addScalarFieldWidget(var);
}
}
}
}
void PPropertyWidget::addScalarFieldWidget(FBase* field)
{
std::string template_name = field->getTemplateName();
if (template_name == std::string(typeid(bool).name()))
{
auto fw = new QBoolFieldWidget(field);
this->connect(fw, SIGNAL(fieldChanged()), this, SLOT(updateDisplay()));
this->addWidget(fw);
}
else if (template_name == std::string(typeid(int).name()))
{
auto fw = new QIntegerFieldWidget(field);
this->connect(fw, SIGNAL(fieldChanged()), this, SLOT(updateDisplay()));
this->addWidget(fw);
// this->addWidget(new QIntegerFieldWidget(new FVar<int>()));
}
else if (template_name == std::string(typeid(float).name()))
{
this->addWidget(new QRealFieldWidget(field));
}
else if (template_name == std::string(typeid(Vec3f).name()))
{
this->addWidget(new QVector3FieldWidget(field));
}
}
void PPropertyWidget::addArrayFieldWidget(FBase* field)
{
}
}
| 23.524775
| 92
| 0.676783
|
devenguo
|
9409af82c2afbfe7f0613a32702af5cadefbe753
| 29,541
|
cpp
|
C++
|
ThirdParty/JSBSim/include/models/FGFCS.cpp
|
Lynnvon/FlightSimulator
|
2dca6f8364b7f4972a248de3dbc3a711740f5ed4
|
[
"MIT"
] | 1
|
2022-02-03T08:29:35.000Z
|
2022-02-03T08:29:35.000Z
|
ThirdParty/JSBSim/include/models/FGFCS.cpp
|
Lynnvon/FlightSimulator
|
2dca6f8364b7f4972a248de3dbc3a711740f5ed4
|
[
"MIT"
] | null | null | null |
ThirdParty/JSBSim/include/models/FGFCS.cpp
|
Lynnvon/FlightSimulator
|
2dca6f8364b7f4972a248de3dbc3a711740f5ed4
|
[
"MIT"
] | null | null | null |
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Module: FGFCS.cpp
Author: Jon Berndt
Date started: 12/12/98
Purpose: Model the flight controls
Called by: FDMExec
------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.org) -------------
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser 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 Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser 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.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
FUNCTIONAL DESCRIPTION
--------------------------------------------------------------------------------
This class models the flight controls for a specific airplane
HISTORY
--------------------------------------------------------------------------------
12/12/98 JSB Created
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <iomanip>
#include "FGFCS.h"
#include "input_output/FGModelLoader.h"
#include "models/flight_control/FGFilter.h"
#include "models/flight_control/FGDeadBand.h"
#include "models/flight_control/FGGain.h"
#include "models/flight_control/FGPID.h"
#include "models/flight_control/FGSwitch.h"
#include "models/flight_control/FGSummer.h"
#include "models/flight_control/FGKinemat.h"
#include "models/flight_control/FGFCSFunction.h"
#include "models/flight_control/FGActuator.h"
#include "models/flight_control/FGAccelerometer.h"
#include "models/flight_control/FGMagnetometer.h"
#include "models/flight_control/FGGyro.h"
#include "models/flight_control/FGWaypoint.h"
#include "models/flight_control/FGAngles.h"
#include "models/flight_control/FGDistributor.h"
#include "models/flight_control/FGLinearActuator.h"
#include "FGFCSChannel.h"
using namespace std;
namespace JSBSim {
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGFCS::FGFCS(FGFDMExec* fdm) : FGModel(fdm), ChannelRate(1)
{
int i;
Name = "FGFCS";
systype = stFCS;
fdmex = fdm;
DaCmd = DeCmd = DrCmd = DfCmd = DsbCmd = DspCmd = 0;
PTrimCmd = YTrimCmd = RTrimCmd = 0.0;
GearCmd = GearPos = 1; // default to gear down
BrakePos.resize(FGLGear::bgNumBrakeGroups);
TailhookPos = WingFoldPos = 0.0;
bind();
for (i=0;i<NForms;i++) {
DePos[i] = DaLPos[i] = DaRPos[i] = DrPos[i] = 0.0;
DfPos[i] = DsbPos[i] = DspPos[i] = 0.0;
}
Debug(0);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGFCS::~FGFCS()
{
ThrottleCmd.clear();
ThrottlePos.clear();
MixtureCmd.clear();
MixturePos.clear();
PropAdvanceCmd.clear();
PropAdvance.clear();
PropFeatherCmd.clear();
PropFeather.clear();
unsigned int i;
for (i=0;i<SystemChannels.size();i++) delete SystemChannels[i];
SystemChannels.clear();
Debug(1);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGFCS::InitModel(void)
{
if (!FGModel::InitModel()) return false;
unsigned int i;
for (i=0; i<ThrottlePos.size(); i++) ThrottlePos[i] = 0.0;
for (i=0; i<MixturePos.size(); i++) MixturePos[i] = 0.0;
for (i=0; i<ThrottleCmd.size(); i++) ThrottleCmd[i] = 0.0;
for (i=0; i<MixtureCmd.size(); i++) MixtureCmd[i] = 0.0;
for (i=0; i<PropAdvance.size(); i++) PropAdvance[i] = 0.0;
for (i=0; i<PropFeather.size(); i++) PropFeather[i] = 0.0;
DaCmd = DeCmd = DrCmd = DfCmd = DsbCmd = DspCmd = 0;
PTrimCmd = YTrimCmd = RTrimCmd = 0.0;
TailhookPos = WingFoldPos = 0.0;
for (i=0;i<NForms;i++) {
DePos[i] = DaLPos[i] = DaRPos[i] = DrPos[i] = 0.0;
DfPos[i] = DsbPos[i] = DspPos[i] = 0.0;
}
// Reset the channels components.
for (unsigned int i=0; i<SystemChannels.size(); i++) SystemChannels[i]->Reset();
return true;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Notes: In this logic the default engine commands are set. This is simply a
// sort of safe-mode method in case the user has not defined control laws for
// throttle, mixture, and prop-advance. The throttle, mixture, and prop advance
// positions are set equal to the respective commands. Any control logic that is
// actually present in the flight_control or autopilot section will override
// these simple assignments.
bool FGFCS::Run(bool Holding)
{
unsigned int i;
if (FGModel::Run(Holding)) return true; // fast exit if nothing to do
if (Holding) return false;
RunPreFunctions();
for (i=0; i<ThrottlePos.size(); i++) ThrottlePos[i] = ThrottleCmd[i];
for (i=0; i<MixturePos.size(); i++) MixturePos[i] = MixtureCmd[i];
for (i=0; i<PropAdvance.size(); i++) PropAdvance[i] = PropAdvanceCmd[i];
for (i=0; i<PropFeather.size(); i++) PropFeather[i] = PropFeatherCmd[i];
// Execute system channels in order
for (i=0; i<SystemChannels.size(); i++) {
if (debug_lvl & 4) cout << " Executing System Channel: " << SystemChannels[i]->GetName() << endl;
ChannelRate = SystemChannels[i]->GetRate();
SystemChannels[i]->Execute();
}
ChannelRate = 1;
RunPostFunctions();
return false;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFCS::SetDaLPos( int form , double pos )
{
switch(form) {
case ofRad:
DaLPos[ofRad] = pos;
DaLPos[ofDeg] = pos*radtodeg;
break;
case ofDeg:
DaLPos[ofRad] = pos*degtorad;
DaLPos[ofDeg] = pos;
break;
case ofNorm:
DaLPos[ofNorm] = pos;
}
DaLPos[ofMag] = fabs(DaLPos[ofRad]);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFCS::SetDaRPos( int form , double pos )
{
switch(form) {
case ofRad:
DaRPos[ofRad] = pos;
DaRPos[ofDeg] = pos*radtodeg;
break;
case ofDeg:
DaRPos[ofRad] = pos*degtorad;
DaRPos[ofDeg] = pos;
break;
case ofNorm:
DaRPos[ofNorm] = pos;
}
DaRPos[ofMag] = fabs(DaRPos[ofRad]);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFCS::SetDePos( int form , double pos )
{
switch(form) {
case ofRad:
DePos[ofRad] = pos;
DePos[ofDeg] = pos*radtodeg;
break;
case ofDeg:
DePos[ofRad] = pos*degtorad;
DePos[ofDeg] = pos;
break;
case ofNorm:
DePos[ofNorm] = pos;
}
DePos[ofMag] = fabs(DePos[ofRad]);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFCS::SetDrPos( int form , double pos )
{
switch(form) {
case ofRad:
DrPos[ofRad] = pos;
DrPos[ofDeg] = pos*radtodeg;
break;
case ofDeg:
DrPos[ofRad] = pos*degtorad;
DrPos[ofDeg] = pos;
break;
case ofNorm:
DrPos[ofNorm] = pos;
}
DrPos[ofMag] = fabs(DrPos[ofRad]);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFCS::SetDfPos( int form , double pos )
{
switch(form) {
case ofRad:
DfPos[ofRad] = pos;
DfPos[ofDeg] = pos*radtodeg;
break;
case ofDeg:
DfPos[ofRad] = pos*degtorad;
DfPos[ofDeg] = pos;
break;
case ofNorm:
DfPos[ofNorm] = pos;
}
DfPos[ofMag] = fabs(DfPos[ofRad]);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFCS::SetDsbPos( int form , double pos )
{
switch(form) {
case ofRad:
DsbPos[ofRad] = pos;
DsbPos[ofDeg] = pos*radtodeg;
break;
case ofDeg:
DsbPos[ofRad] = pos*degtorad;
DsbPos[ofDeg] = pos;
break;
case ofNorm:
DsbPos[ofNorm] = pos;
}
DsbPos[ofMag] = fabs(DsbPos[ofRad]);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFCS::SetDspPos( int form , double pos )
{
switch(form) {
case ofRad:
DspPos[ofRad] = pos;
DspPos[ofDeg] = pos*radtodeg;
break;
case ofDeg:
DspPos[ofRad] = pos*degtorad;
DspPos[ofDeg] = pos;
break;
case ofNorm:
DspPos[ofNorm] = pos;
}
DspPos[ofMag] = fabs(DspPos[ofRad]);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFCS::SetThrottleCmd(int engineNum, double setting)
{
if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < 0) {
for (unsigned int ctr=0; ctr<ThrottleCmd.size(); ctr++)
ThrottleCmd[ctr] = setting;
} else {
ThrottleCmd[engineNum] = setting;
}
} else {
cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()
<< " engines exist, but attempted throttle command is for engine "
<< engineNum << endl;
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFCS::SetThrottlePos(int engineNum, double setting)
{
if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < 0) {
for (unsigned int ctr=0; ctr<ThrottlePos.size(); ctr++)
ThrottlePos[ctr] = setting;
} else {
ThrottlePos[engineNum] = setting;
}
} else {
cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()
<< " engines exist, but attempted throttle position setting is for engine "
<< engineNum << endl;
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGFCS::GetThrottleCmd(int engineNum) const
{
if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < 0) {
cerr << "Cannot get throttle value for ALL engines" << endl;
} else {
return ThrottleCmd[engineNum];
}
} else {
cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()
<< " engines exist, but throttle setting for engine " << engineNum
<< " is selected" << endl;
}
return 0.0;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGFCS::GetThrottlePos(int engineNum) const
{
if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < 0) {
cerr << "Cannot get throttle value for ALL engines" << endl;
} else {
return ThrottlePos[engineNum];
}
} else {
cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()
<< " engines exist, but attempted throttle position setting is for engine "
<< engineNum << endl;
}
return 0.0;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFCS::SetMixtureCmd(int engineNum, double setting)
{
if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < 0) {
for (unsigned int ctr=0; ctr<MixtureCmd.size(); ctr++)
MixtureCmd[ctr] = setting;
} else {
MixtureCmd[engineNum] = setting;
}
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFCS::SetMixturePos(int engineNum, double setting)
{
if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < 0) {
for (unsigned int ctr=0; ctr<MixtureCmd.size(); ctr++)
MixturePos[ctr] = MixtureCmd[ctr];
} else {
MixturePos[engineNum] = setting;
}
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFCS::SetPropAdvanceCmd(int engineNum, double setting)
{
if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < 0) {
for (unsigned int ctr=0; ctr<PropAdvanceCmd.size(); ctr++)
PropAdvanceCmd[ctr] = setting;
} else {
PropAdvanceCmd[engineNum] = setting;
}
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFCS::SetPropAdvance(int engineNum, double setting)
{
if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < 0) {
for (unsigned int ctr=0; ctr<PropAdvanceCmd.size(); ctr++)
PropAdvance[ctr] = PropAdvanceCmd[ctr];
} else {
PropAdvance[engineNum] = setting;
}
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFCS::SetFeatherCmd(int engineNum, bool setting)
{
if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < 0) {
for (unsigned int ctr=0; ctr<PropFeatherCmd.size(); ctr++)
PropFeatherCmd[ctr] = setting;
} else {
PropFeatherCmd[engineNum] = setting;
}
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFCS::SetPropFeather(int engineNum, bool setting)
{
if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < 0) {
for (unsigned int ctr=0; ctr<PropFeatherCmd.size(); ctr++)
PropFeather[ctr] = PropFeatherCmd[ctr];
} else {
PropFeather[engineNum] = setting;
}
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGFCS::Load(Element* document)
{
if (document->GetName() == "autopilot") {
Name = "Autopilot: ";
systype = stAutoPilot;
} else if (document->GetName() == "flight_control") {
Name = "FCS: ";
systype = stFCS;
} else if (document->GetName() == "system") {
Name = "System: ";
systype = stSystem;
}
// Load interface properties from document
if (!FGModel::Upload(document, true))
return false;
Name += document->GetAttributeValue("name");
Debug(2);
Element* channel_element = document->FindElement("channel");
while (channel_element) {
FGFCSChannel* newChannel = 0;
string sOnOffProperty = channel_element->GetAttributeValue("execute");
string sChannelName = channel_element->GetAttributeValue("name");
if (!channel_element->GetAttributeValue("execrate").empty())
ChannelRate = channel_element->GetAttributeValueAsNumber("execrate");
else
ChannelRate = 1;
if (sOnOffProperty.length() > 0) {
FGPropertyNode* OnOffPropertyNode = PropertyManager->GetNode(sOnOffProperty);
if (OnOffPropertyNode == 0) {
cerr << channel_element->ReadFrom() << highint << fgred
<< "The On/Off property, " << sOnOffProperty << " specified for channel "
<< channel_element->GetAttributeValue("name") << " is undefined or not "
<< "understood. The simulation will abort" << reset << endl;
throw("Bad system definition");
} else
newChannel = new FGFCSChannel(this, sChannelName, ChannelRate,
OnOffPropertyNode);
} else
newChannel = new FGFCSChannel(this, sChannelName, ChannelRate);
SystemChannels.push_back(newChannel);
if (debug_lvl > 0)
cout << endl << highint << fgblue << " Channel "
<< normint << channel_element->GetAttributeValue("name") << reset << endl;
Element* component_element = channel_element->GetElement();
while (component_element) {
try {
if ((component_element->GetName() == string("lag_filter")) ||
(component_element->GetName() == string("lead_lag_filter")) ||
(component_element->GetName() == string("washout_filter")) ||
(component_element->GetName() == string("second_order_filter")) )
{
newChannel->Add(new FGFilter(this, component_element));
} else if ((component_element->GetName() == string("pure_gain")) ||
(component_element->GetName() == string("scheduled_gain")) ||
(component_element->GetName() == string("aerosurface_scale")))
{
newChannel->Add(new FGGain(this, component_element));
} else if (component_element->GetName() == string("summer")) {
newChannel->Add(new FGSummer(this, component_element));
} else if (component_element->GetName() == string("deadband")) {
newChannel->Add(new FGDeadBand(this, component_element));
} else if (component_element->GetName() == string("switch")) {
newChannel->Add(new FGSwitch(this, component_element));
} else if (component_element->GetName() == string("kinematic")) {
newChannel->Add(new FGKinemat(this, component_element));
} else if (component_element->GetName() == string("fcs_function")) {
newChannel->Add(new FGFCSFunction(this, component_element));
} else if (component_element->GetName() == string("pid")) {
newChannel->Add(new FGPID(this, component_element));
} else if (component_element->GetName() == string("integrator")) {
// <integrator> is equivalent to <pid type="trap">
Element* c1_el = component_element->FindElement("c1");
if (!c1_el) {
cerr << component_element->ReadFrom();
throw("INTEGRATOR component " + component_element->GetAttributeValue("name")
+ " does not provide the parameter <c1>");
}
c1_el->ChangeName("ki");
if (!c1_el->HasAttribute("type"))
c1_el->AddAttribute("type", "trap");
newChannel->Add(new FGPID(this, component_element));
} else if (component_element->GetName() == string("actuator")) {
newChannel->Add(new FGActuator(this, component_element));
} else if (component_element->GetName() == string("sensor")) {
newChannel->Add(new FGSensor(this, component_element));
} else if (component_element->GetName() == string("accelerometer")) {
newChannel->Add(new FGAccelerometer(this, component_element));
} else if (component_element->GetName() == string("magnetometer")) {
newChannel->Add(new FGMagnetometer(this, component_element));
} else if (component_element->GetName() == string("gyro")) {
newChannel->Add(new FGGyro(this, component_element));
} else if ((component_element->GetName() == string("waypoint_heading")) ||
(component_element->GetName() == string("waypoint_distance")))
{
newChannel->Add(new FGWaypoint(this, component_element));
} else if (component_element->GetName() == string("angle")) {
newChannel->Add(new FGAngles(this, component_element));
} else if (component_element->GetName() == string("distributor")) {
newChannel->Add(new FGDistributor(this, component_element));
} else if (component_element->GetName() == string("linear_actuator")) {
newChannel->Add(new FGLinearActuator(this, component_element));
} else {
cerr << "Unknown FCS component: " << component_element->GetName() << endl;
}
} catch(string& s) {
cerr << highint << fgred << endl << " " << s << endl;
cerr << reset << endl;
return false;
}
component_element = channel_element->GetNextElement();
}
channel_element = document->FindNextElement("channel");
}
PostLoad(document, FDMExec);
return true;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGFCS::GetBrake(FGLGear::BrakeGroup bg)
{
return BrakePos[bg];
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SGPath FGFCS::FindFullPathName(const SGPath& path) const
{
SGPath name = FGModel::FindFullPathName(path);
if (systype != stSystem || !name.isNull()) return name;
name = CheckPathName(FDMExec->GetFullAircraftPath()/string("Systems"), path);
if (!name.isNull()) return name;
return CheckPathName(FDMExec->GetSystemsPath(), path);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
string FGFCS::GetComponentStrings(const string& delimiter) const
{
string CompStrings = "";
bool firstime = true;
int total_count=0;
for (unsigned int i=0; i<SystemChannels.size(); i++)
{
for (unsigned int c=0; c<SystemChannels[i]->GetNumComponents(); c++)
{
if (firstime) firstime = false;
else CompStrings += delimiter;
CompStrings += SystemChannels[i]->GetComponent(c)->GetName();
total_count++;
}
}
return CompStrings;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
string FGFCS::GetComponentValues(const string& delimiter) const
{
std::ostringstream buf;
bool firstime = true;
int total_count=0;
for (unsigned int i=0; i<SystemChannels.size(); i++)
{
for (unsigned int c=0; c<SystemChannels[i]->GetNumComponents(); c++)
{
if (firstime) firstime = false;
else buf << delimiter;
buf << setprecision(9) << SystemChannels[i]->GetComponent(c)->GetOutput();
total_count++;
}
}
return buf.str();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFCS::AddThrottle(void)
{
ThrottleCmd.push_back(0.0);
ThrottlePos.push_back(0.0);
MixtureCmd.push_back(0.0); // assume throttle and mixture are coupled
MixturePos.push_back(0.0);
PropAdvanceCmd.push_back(0.0); // assume throttle and prop pitch are coupled
PropAdvance.push_back(0.0);
PropFeatherCmd.push_back(false);
PropFeather.push_back(false);
unsigned int num = (unsigned int)ThrottleCmd.size()-1;
bindThrottle(num);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGFCS::GetDt(void) const
{
return FDMExec->GetDeltaT()*rate;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFCS::bind(void)
{
PropertyManager->Tie("fcs/aileron-cmd-norm", this, &FGFCS::GetDaCmd, &FGFCS::SetDaCmd);
PropertyManager->Tie("fcs/elevator-cmd-norm", this, &FGFCS::GetDeCmd, &FGFCS::SetDeCmd);
PropertyManager->Tie("fcs/rudder-cmd-norm", this, &FGFCS::GetDrCmd, &FGFCS::SetDrCmd);
PropertyManager->Tie("fcs/flap-cmd-norm", this, &FGFCS::GetDfCmd, &FGFCS::SetDfCmd);
PropertyManager->Tie("fcs/speedbrake-cmd-norm", this, &FGFCS::GetDsbCmd, &FGFCS::SetDsbCmd);
PropertyManager->Tie("fcs/spoiler-cmd-norm", this, &FGFCS::GetDspCmd, &FGFCS::SetDspCmd);
PropertyManager->Tie("fcs/pitch-trim-cmd-norm", this, &FGFCS::GetPitchTrimCmd, &FGFCS::SetPitchTrimCmd);
PropertyManager->Tie("fcs/roll-trim-cmd-norm", this, &FGFCS::GetRollTrimCmd, &FGFCS::SetRollTrimCmd);
PropertyManager->Tie("fcs/yaw-trim-cmd-norm", this, &FGFCS::GetYawTrimCmd, &FGFCS::SetYawTrimCmd);
PropertyManager->Tie("fcs/left-aileron-pos-rad", this, ofRad, &FGFCS::GetDaLPos, &FGFCS::SetDaLPos);
PropertyManager->Tie("fcs/left-aileron-pos-deg", this, ofDeg, &FGFCS::GetDaLPos, &FGFCS::SetDaLPos);
PropertyManager->Tie("fcs/left-aileron-pos-norm", this, ofNorm, &FGFCS::GetDaLPos, &FGFCS::SetDaLPos);
PropertyManager->Tie("fcs/mag-left-aileron-pos-rad", this, ofMag, &FGFCS::GetDaLPos);
PropertyManager->Tie("fcs/right-aileron-pos-rad", this, ofRad, &FGFCS::GetDaRPos, &FGFCS::SetDaRPos);
PropertyManager->Tie("fcs/right-aileron-pos-deg", this, ofDeg, &FGFCS::GetDaRPos, &FGFCS::SetDaRPos);
PropertyManager->Tie("fcs/right-aileron-pos-norm", this, ofNorm, &FGFCS::GetDaRPos, &FGFCS::SetDaRPos);
PropertyManager->Tie("fcs/mag-right-aileron-pos-rad", this, ofMag, &FGFCS::GetDaRPos);
PropertyManager->Tie("fcs/elevator-pos-rad", this, ofRad, &FGFCS::GetDePos, &FGFCS::SetDePos);
PropertyManager->Tie("fcs/elevator-pos-deg", this, ofDeg, &FGFCS::GetDePos, &FGFCS::SetDePos);
PropertyManager->Tie("fcs/elevator-pos-norm", this, ofNorm, &FGFCS::GetDePos, &FGFCS::SetDePos);
PropertyManager->Tie("fcs/mag-elevator-pos-rad", this, ofMag, &FGFCS::GetDePos);
PropertyManager->Tie("fcs/rudder-pos-rad", this,ofRad, &FGFCS::GetDrPos, &FGFCS::SetDrPos);
PropertyManager->Tie("fcs/rudder-pos-deg", this,ofDeg, &FGFCS::GetDrPos, &FGFCS::SetDrPos);
PropertyManager->Tie("fcs/rudder-pos-norm", this,ofNorm, &FGFCS::GetDrPos, &FGFCS::SetDrPos);
PropertyManager->Tie("fcs/mag-rudder-pos-rad", this,ofMag, &FGFCS::GetDrPos);
PropertyManager->Tie("fcs/flap-pos-rad", this,ofRad, &FGFCS::GetDfPos, &FGFCS::SetDfPos);
PropertyManager->Tie("fcs/flap-pos-deg", this,ofDeg, &FGFCS::GetDfPos, &FGFCS::SetDfPos);
PropertyManager->Tie("fcs/flap-pos-norm", this,ofNorm, &FGFCS::GetDfPos, &FGFCS::SetDfPos);
PropertyManager->Tie("fcs/speedbrake-pos-rad", this,ofRad, &FGFCS::GetDsbPos, &FGFCS::SetDsbPos);
PropertyManager->Tie("fcs/speedbrake-pos-deg", this,ofDeg, &FGFCS::GetDsbPos, &FGFCS::SetDsbPos);
PropertyManager->Tie("fcs/speedbrake-pos-norm", this,ofNorm, &FGFCS::GetDsbPos, &FGFCS::SetDsbPos);
PropertyManager->Tie("fcs/mag-speedbrake-pos-rad", this,ofMag, &FGFCS::GetDsbPos);
PropertyManager->Tie("fcs/spoiler-pos-rad", this, ofRad, &FGFCS::GetDspPos, &FGFCS::SetDspPos);
PropertyManager->Tie("fcs/spoiler-pos-deg", this, ofDeg, &FGFCS::GetDspPos, &FGFCS::SetDspPos);
PropertyManager->Tie("fcs/spoiler-pos-norm", this, ofNorm, &FGFCS::GetDspPos, &FGFCS::SetDspPos);
PropertyManager->Tie("fcs/mag-spoiler-pos-rad", this, ofMag, &FGFCS::GetDspPos);
PropertyManager->Tie("gear/gear-pos-norm", this, &FGFCS::GetGearPos, &FGFCS::SetGearPos);
PropertyManager->Tie("gear/gear-cmd-norm", this, &FGFCS::GetGearCmd, &FGFCS::SetGearCmd);
PropertyManager->Tie("fcs/left-brake-cmd-norm", this, &FGFCS::GetLBrake, &FGFCS::SetLBrake);
PropertyManager->Tie("fcs/right-brake-cmd-norm", this, &FGFCS::GetRBrake, &FGFCS::SetRBrake);
PropertyManager->Tie("fcs/center-brake-cmd-norm", this, &FGFCS::GetCBrake, &FGFCS::SetCBrake);
PropertyManager->Tie("gear/tailhook-pos-norm", this, &FGFCS::GetTailhookPos, &FGFCS::SetTailhookPos);
PropertyManager->Tie("fcs/wing-fold-pos-norm", this, &FGFCS::GetWingFoldPos, &FGFCS::SetWingFoldPos);
PropertyManager->Tie("simulation/channel-dt", this, &FGFCS::GetChannelDeltaT);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Technically, this function should probably bind propulsion type specific controls
// rather than mixture and prop-advance.
void FGFCS::bindThrottle(unsigned int num)
{
string tmp;
tmp = CreateIndexedPropertyName("fcs/throttle-cmd-norm", num);
PropertyManager->Tie( tmp.c_str(), this, num, &FGFCS::GetThrottleCmd,
&FGFCS::SetThrottleCmd);
tmp = CreateIndexedPropertyName("fcs/throttle-pos-norm", num);
PropertyManager->Tie( tmp.c_str(), this, num, &FGFCS::GetThrottlePos,
&FGFCS::SetThrottlePos);
tmp = CreateIndexedPropertyName("fcs/mixture-cmd-norm", num);
PropertyManager->Tie( tmp.c_str(), this, num, &FGFCS::GetMixtureCmd,
&FGFCS::SetMixtureCmd);
tmp = CreateIndexedPropertyName("fcs/mixture-pos-norm", num);
PropertyManager->Tie( tmp.c_str(), this, num, &FGFCS::GetMixturePos,
&FGFCS::SetMixturePos);
tmp = CreateIndexedPropertyName("fcs/advance-cmd-norm", num);
PropertyManager->Tie( tmp.c_str(), this, num, &FGFCS::GetPropAdvanceCmd,
&FGFCS::SetPropAdvanceCmd);
tmp = CreateIndexedPropertyName("fcs/advance-pos-norm", num);
PropertyManager->Tie( tmp.c_str(), this, num, &FGFCS::GetPropAdvance,
&FGFCS::SetPropAdvance);
tmp = CreateIndexedPropertyName("fcs/feather-cmd-norm", num);
PropertyManager->Tie( tmp.c_str(), this, num, &FGFCS::GetFeatherCmd,
&FGFCS::SetFeatherCmd);
tmp = CreateIndexedPropertyName("fcs/feather-pos-norm", num);
PropertyManager->Tie( tmp.c_str(), this, num, &FGFCS::GetPropFeather,
&FGFCS::SetPropFeather);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// The bitmasked value choices are as follows:
// unset: In this case (the default) JSBSim would only print
// out the normally expected messages, essentially echoing
// the config files as they are read. If the environment
// variable is not set, debug_lvl is set to 1 internally
// 0: This requests JSBSim not to output any messages
// whatsoever.
// 1: This value explicity requests the normal JSBSim
// startup messages
// 2: This value asks for a message to be printed out when
// a class is instantiated
// 4: When this value is set, a message is displayed when a
// FGModel object executes its Run() method
// 8: When this value is set, various runtime state variables
// are printed out periodically
// 16: When set various parameters are sanity checked and
// a message is printed out when they go out of bounds
void FGFCS::Debug(int from)
{
if (debug_lvl <= 0) return;
if (debug_lvl & 1) { // Standard console startup message output
if (from == 2) { // Loader
cout << endl << " " << Name << endl;
}
}
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
if (from == 0) cout << "Instantiated: FGFCS" << endl;
if (from == 1) cout << "Destroyed: FGFCS" << endl;
}
if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
}
if (debug_lvl & 8 ) { // Runtime state variables
}
if (debug_lvl & 16) { // Sanity checking
}
if (debug_lvl & 64) {
if (from == 0) { // Constructor
}
}
}
}
| 35.548736
| 106
| 0.586338
|
Lynnvon
|
940c62dc543c5dc496011419ba7d98be92c490aa
| 104
|
cpp
|
C++
|
sources/source.cpp
|
lapsizm/SharedPtr
|
3eaafcff91f8dbbe4ae906dbfdcaa33d74382222
|
[
"MIT"
] | null | null | null |
sources/source.cpp
|
lapsizm/SharedPtr
|
3eaafcff91f8dbbe4ae906dbfdcaa33d74382222
|
[
"MIT"
] | null | null | null |
sources/source.cpp
|
lapsizm/SharedPtr
|
3eaafcff91f8dbbe4ae906dbfdcaa33d74382222
|
[
"MIT"
] | null | null | null |
// Copyright 2020 Kirill Murygin murygin_280702@mail.ru
#include <source.hpp>
void foo(){
return;
}
| 13
| 55
| 0.721154
|
lapsizm
|
940d2d24319568a91b342d91873f371ed88a2ff9
| 6,254
|
cpp
|
C++
|
KFPlugin/KFRelationDatabase/KFRelationDatabaseRedis.cpp
|
282951387/KFrame
|
5d6e953f7cc312321c36632715259394ca67144c
|
[
"Apache-2.0"
] | 1
|
2021-04-26T09:31:32.000Z
|
2021-04-26T09:31:32.000Z
|
KFPlugin/KFRelationDatabase/KFRelationDatabaseRedis.cpp
|
282951387/KFrame
|
5d6e953f7cc312321c36632715259394ca67144c
|
[
"Apache-2.0"
] | null | null | null |
KFPlugin/KFRelationDatabase/KFRelationDatabaseRedis.cpp
|
282951387/KFrame
|
5d6e953f7cc312321c36632715259394ca67144c
|
[
"Apache-2.0"
] | null | null | null |
#include "KFRelationDatabaseRedis.hpp"
#include "KFBasicDatabase/KFBasicDatabaseInterface.h"
namespace KFrame
{
#define __RELATION_REDIS_DRIVER__ _kf_redis->Create( __STRING__( relation ) )
std::string KFRelationDatabaseRedis::FormatRelationKey( const std::string& relationname, uint64 firstid, uint64 secondid, bool bothway )
{
auto id1 = firstid;
auto id2 = secondid;
if ( bothway )
{
id1 = __MIN__( firstid, secondid );
id2 = __MAX__( firstid, secondid );
}
return __DATABASE_KEY_3__( relationname, id1, id2 );
}
void KFRelationDatabaseRedis::QueryRelationList( const std::string& listname, const std::string& relationname, uint64 playerid, RelationListType& relationlist )
{
auto redisdriver = __RELATION_REDIS_DRIVER__;
auto queryidlist = redisdriver->SMembers( __DATABASE_KEY_2__( listname, playerid ) );
if ( queryidlist->_value.empty() )
{
return;
}
for ( auto& strid : queryidlist->_value )
{
auto relationid = __TO_UINT64__( strid );
// 好友的基本信息
StringMap relationdata;
_kf_basic_database->QueryBasicAttribute( relationid, relationdata );
if ( relationdata.empty() )
{
continue;
}
// 好友的关系属性
auto relationkey = FormatRelationKey( relationname, playerid, relationid, true );
auto kfquery = redisdriver->HGetAll( relationkey );
relationdata.insert( kfquery->_value.begin(), kfquery->_value.end() );
relationlist.emplace( relationid, relationdata );
}
}
void KFRelationDatabaseRedis::QueryInviteList( const std::string& listname, const std::string& relationname, uint64 playerid, RelationListType& relationlist )
{
auto redisdriver = __RELATION_REDIS_DRIVER__;
auto queryidlist = redisdriver->SMembers( __DATABASE_KEY_2__( listname, playerid ) );
if ( queryidlist->_value.empty() )
{
return;
}
StringList removelist;
for ( auto& strid : queryidlist->_value )
{
auto relationid = __TO_UINT64__( strid );
// 邀请信息
auto relationkey = FormatRelationKey( relationname, playerid, relationid, false );
auto kfinvitedata = redisdriver->HGetAll( relationkey );
if ( kfinvitedata->_value.empty() )
{
removelist.push_back( strid );
continue;
}
StringMap relationdata;
_kf_basic_database->QueryBasicAttribute( relationid, relationdata );
if ( relationdata.empty() )
{
continue;
}
relationdata.insert( kfinvitedata->_value.begin(), kfinvitedata->_value.end() );
relationlist.emplace( relationid, relationdata );
}
if ( !removelist.empty() )
{
// 删除已经过期的邀请信息
redisdriver->SRem( __DATABASE_KEY_2__( listname, playerid ), removelist );
}
}
bool KFRelationDatabaseRedis::RelationExist( const std::string& listname, uint64 playerid, uint64 targetid )
{
auto redisdriver = __RELATION_REDIS_DRIVER__;
auto kfquery = redisdriver->SIsMember( __DATABASE_KEY_2__( listname, playerid ), targetid );
return kfquery->_value != _invalid_int;
}
uint32 KFRelationDatabaseRedis::RelationCount( const std::string& listname, uint64 playerid )
{
auto redisdriver = __RELATION_REDIS_DRIVER__;
auto kfquery = redisdriver->SCard( __DATABASE_KEY_2__( listname, playerid ) );
return kfquery->_value;
}
void KFRelationDatabaseRedis::AddRelation( const std::string& listname, const std::string& relationname, uint64 playerid, uint64 targetid, bool bothway )
{
auto redisdriver = __RELATION_REDIS_DRIVER__;
auto relationkey = FormatRelationKey( relationname, playerid, targetid, bothway );
redisdriver->WriteMulti();
redisdriver->SAdd( __DATABASE_KEY_2__( listname, playerid ), targetid );
redisdriver->HSet( relationkey, __STRING__( time ), KFGlobal::Instance()->_real_time );
redisdriver->WriteExec();
}
void KFRelationDatabaseRedis::RemoveRelation( const std::string& listname, const std::string& relationname, uint64 playerid, uint64 targetid, bool bothway )
{
auto redisdriver = __RELATION_REDIS_DRIVER__;
auto relationkey = FormatRelationKey( relationname, playerid, targetid, bothway );
redisdriver->WriteMulti();
redisdriver->Del( relationkey );
redisdriver->SRem( __DATABASE_KEY_2__( listname, playerid ), targetid );
redisdriver->WriteExec();
}
void KFRelationDatabaseRedis::AddInvite( const std::string& listname, const std::string& relationname, uint64 playerid, uint64 targetid, const std::string& message, uint64 keeptime )
{
auto redisdriver = __RELATION_REDIS_DRIVER__;
auto invitekey = FormatRelationKey( relationname, playerid, targetid, false );
StringMap values;
values[ __STRING__( message ) ] = message;
values[ __STRING__( time ) ] = __TO_STRING__( KFGlobal::Instance()->_real_time );
redisdriver->WriteMulti();
redisdriver->SAdd( __DATABASE_KEY_2__( listname, playerid ), targetid );
redisdriver->HMSet( invitekey, values );
if ( keeptime > 0u )
{
redisdriver->Expire( invitekey, keeptime );
}
redisdriver->WriteExec();
}
bool KFRelationDatabaseRedis::IsRefuse( const std::string& refusename, uint64 playerid )
{
auto redisdriver = __RELATION_REDIS_DRIVER__;
auto kfresult = redisdriver->HGetUInt64( __DATABASE_KEY_2__( __STRING__( refuse ), playerid ), refusename );
return kfresult->_value != _invalid_int;
}
void KFRelationDatabaseRedis::SetRefuse( const std::string& refusename, uint64 playerid, uint32 refusevalue )
{
auto redisdriver = __RELATION_REDIS_DRIVER__;
redisdriver->HSet( __DATABASE_KEY_2__( __STRING__( refuse ), playerid ), refusename, refusevalue );
}
}
| 39.0875
| 186
| 0.644388
|
282951387
|
940e86197e999b3205aa47686e5fc2d5fbd82c19
| 3,586
|
cpp
|
C++
|
src/gfx/Viewport.cpp
|
murataka/two
|
f6f9835de844a38687e11f649ff97c3fb4146bbe
|
[
"Zlib"
] | 578
|
2019-05-04T09:09:42.000Z
|
2022-03-27T23:02:21.000Z
|
src/gfx/Viewport.cpp
|
murataka/two
|
f6f9835de844a38687e11f649ff97c3fb4146bbe
|
[
"Zlib"
] | 14
|
2019-05-11T14:34:56.000Z
|
2021-02-02T07:06:46.000Z
|
src/gfx/Viewport.cpp
|
murataka/two
|
f6f9835de844a38687e11f649ff97c3fb4146bbe
|
[
"Zlib"
] | 42
|
2019-05-11T16:04:19.000Z
|
2022-01-24T02:21:43.000Z
|
// Copyright (c) 2019 Hugo Amiard hugo.amiard@laposte.net
// This software is provided 'as-is' under the zlib License, see the LICENSE.txt file.
// This notice and the license may not be removed or altered from any source distribution.
#ifdef TWO_MODULES
module;
#include <bgfx/bgfx.h>
#include <gfx/Cpp20.h>
module TWO(gfx);
#else
#include <bgfx/bgfx.h>
#include <ecs/ECS.hpp>
#include <geom/Intersect.h>
#include <gfx/Viewport.h>
#include <gfx/Camera.h>
#include <gfx/Item.h>
#include <gfx/Renderer.h>
#include <gfx/Froxel.h>
#include <gfx/Shot.h>
#include <gfx/RenderTarget.h>
#endif
//#define NO_OCCLUSION_CULLING
namespace two
{
GridECS s_viewer_ecs;
GridECS* g_viewer_ecs = &s_viewer_ecs;
static uint16_t viewportIndex = 1;
Viewport::Viewport(Camera& camera, Scene& scene, const vec4& rect, bool scissor)
: m_camera(&camera)
, m_scene(&scene)
, m_index(viewportIndex++)
, m_rect(rect)
, m_scissor(scissor)
, m_culler(construct<Culler>(*this))
{
(Entt&)(*this) = { &s_viewer_ecs, s_viewer_ecs.create() };
}
Viewport::~Viewport()
{}
void Viewport::pass(const Pass& pass)
{
const FrameBuffer& fbo = *pass.m_fbo;
const ushort4 rect = ushort4(m_rect * vec2(fbo.m_size));
bgfx::setViewRect(pass.m_index, rect.x, rect.y, rect.width, rect.height);
bgfx::setViewTransform(pass.m_index, value_ptr(m_camera->m_view), value_ptr(m_camera->m_proj));
bgfx::setViewFrameBuffer(pass.m_index, *pass.m_fbo);
bgfx::setViewClear(pass.m_index, BGFX_CLEAR_NONE);
if(m_scissor)
bgfx::setViewScissor(pass.m_index, rect.x, rect.y, rect.width, rect.height);
}
void Viewport::cull(Render& render)
{
#ifndef NO_OCCLUSION_CULLING
m_culler->render(render);
#else
UNUSED(render);
#endif
}
void Viewport::render(Render& render)
{
if(m_rect.height != 0.f)
{
const vec2 size = m_rect.size * vec2(render.m_fbo->m_size);
m_camera->m_aspect = size.x / size.y;
}
m_camera->update();
if(m_clusters)
{
const uvec4 rect = uvec4(m_rect * vec2(render.m_fbo->m_size));
m_clusters->m_dirty |= uint8_t(Froxelizer::Dirty::Viewport) | uint8_t(Froxelizer::Dirty::Projection);
m_clusters->update(rect, m_camera->m_proj, m_camera->m_near, m_camera->m_far);
m_clusters->clusterize_lights(*m_camera, render.m_shot.m_lights);
m_clusters->upload();
}
for(RenderTask& task : m_tasks)
task(render);
}
void Viewport::set_clustered(GfxSystem& gfx)
{
if(m_rect.width != 0.f && m_rect.height != 0.f && !m_clusters)
{
m_clustered = true;
m_clusters = make_unique<Froxelizer>(gfx);
m_clusters->setup();
}
}
/*void hmdUpdate()
{
// Set view and projection matrix for view 0.
const bgfx::HMD* hmd = bgfx::getHMD();
if(NULL != hmd && 0 != (hmd->flags & BGFX_HMD_RENDERING))
{
float view[16];
bx::mtxQuatTranslationHMD(view, hmd->eye[0].rotation, eye);
bgfx::setViewTransform(0, view, hmd->eye[0].projection, BGFX_VIEW_STEREO, hmd->eye[1].projection);
// Set view 0 default viewport.
//
// Use HMD's width/height since HMD's internal frame buffer size
// might be much larger than window size.
bgfx::setViewRect(0, 0, 0, hmd->width, hmd->height);
}
else
}*/
Ray Viewport::ray(const vec2& pos)
{
// coord in NDC
float xNDC = (pos.x / float(m_rect.width)) * 2.0f - 1.0f;
float yNDC = ((float(m_rect.height) - pos.y) / float(m_rect.height)) * 2.0f - 1.0f;
return m_camera->ray({ xNDC, yNDC });
}
vec3 Viewport::raycast(const Plane& plane, const vec2& pos)
{
Ray ray = this->ray(pos);
return plane_segment_intersection(plane, { ray.m_start, ray.m_end });
}
}
| 26.175182
| 104
| 0.687395
|
murataka
|
940ffcefeabe7b8820fdf8356cd64a2bd008000f
| 4,484
|
cpp
|
C++
|
Src/Data/QvtkDentalFixture.cpp
|
wuzhuobin/QvtkProject
|
30bfc798aca0e79043438aa16840464e6731e38c
|
[
"RSA-MD"
] | 1
|
2018-09-10T12:14:43.000Z
|
2018-09-10T12:14:43.000Z
|
Src/Data/QvtkDentalFixture.cpp
|
wuzhuobin/QvtkProject
|
30bfc798aca0e79043438aa16840464e6731e38c
|
[
"RSA-MD"
] | 3
|
2018-05-22T11:00:59.000Z
|
2018-12-07T09:36:19.000Z
|
Src/Data/QvtkDentalFixture.cpp
|
wuzhuobin/QvtkProject
|
30bfc798aca0e79043438aa16840464e6731e38c
|
[
"RSA-MD"
] | null | null | null |
// me
#include "QvtkDentalFixture.h"
// qt
#include <QStandardItem>
#include <QCoreApplication>
#include <QDebug>
namespace Q {
namespace vtk {
Q_VTK_DATA_CPP(DentalFixture);
DentalFixture::DentalFixture()
{
this->m_dentalFixtureBrand = this->createAttribute(K.DentalFixtureBrand, "", true);
this->m_dentalFixtureModel = this->createAttribute(K.DentalFixtureModel, "", true);
this->m_dentalFixtureShape = this->createAttribute(K.DentalFixtureShape, "", true);
this->m_dentalFixtureLength = this->createAttribute(K.DentalFixtureLength, 0.0, true);
this->m_dentalFixtureRadius = this->createAttribute(K.DentalFixtureRadius, 0.0, true);
this->insertSlotFunction(this->m_dentalFixtureBrand, &DentalFixture::setDentalFixtureBrand);
this->insertSlotFunction(this->m_dentalFixtureModel, &DentalFixture::setDentalFixtureModel);
this->insertSlotFunction(this->m_dentalFixtureShape, &DentalFixture::setDentalFixtureShape);
this->insertSlotFunction(this->m_dentalFixtureLength, &DentalFixture::setDentalFixtureLength);
this->insertSlotFunction(this->m_dentalFixtureRadius, &DentalFixture::setDentalFixtureRadius);
}
DentalFixture::~DentalFixture()
{
}
bool DentalFixture::readData(QString rootDirectory)
{
QString path;
if (rootDirectory.isEmpty()) {
return AnnotationPolyData::readData(rootDirectory);
}
else {
if (this->getRelativePath().isEmpty() ||
this->getRelativePath().first().isEmpty()) {
qCritical() << "getRelativePath() is empty. ";
return false;
}
path = QCoreApplication::applicationDirPath() + "/DentalFixture/" + this->getRelativePath().first();
}
if (!this->getDataSet())
{
qCritical() << "data is a null ptr. ";
return false;
}
// When the path starts with ":", it is in the QRC
if (path.startsWith(":"))
{
return readQRC(path, this->getPolyData());
}
else {
return readDataSuffix(path, this->getPolyData());
}
}
QString DentalFixture::getDentalFixtureBrand() const
{
return DentalFixture::getAttribute(this->m_dentalFixtureBrand).toString();
}
QString DentalFixture::getDentalFixtureModel() const
{
return DentalFixture::getAttribute(this->m_dentalFixtureModel).toString();
}
QString DentalFixture::getDentalFixtureShape() const
{
return DentalFixture::getAttribute(this->m_dentalFixtureShape).toString();
}
double DentalFixture::getDentalFixtureLength() const
{
return DentalFixture::getAttribute(this->m_dentalFixtureLength).toDouble();
}
double DentalFixture::getDentalFixtureRadius() const
{
return DentalFixture::getAttribute(this->m_dentalFixtureRadius).toDouble();
}
void DentalFixture::setDentalFixtureBrand(QString brand)
{
DentalFixture::setAttribute(this->m_dentalFixtureBrand, brand);
emit dentalFixtureBrandChanged(brand);
}
void DentalFixture::setDentalFixtureModel(QString model)
{
DentalFixture::setAttribute(this->m_dentalFixtureModel, model);
emit dentalFixtureModelChanged(model);
}
void DentalFixture::setDentalFixtureShape(QString shape)
{
DentalFixture::setAttribute(this->m_dentalFixtureShape, shape);
emit dentalFixtureShapeChanged(shape);
}
void DentalFixture::setDentalFixtureLength(double length)
{
DentalFixture::setAttribute(this->m_dentalFixtureLength, length);
emit dentalFixtureLengthChanged(length);
}
void DentalFixture::setDentalFixtureRadius(double radius)
{
DentalFixture::setAttribute(this->m_dentalFixtureRadius, radius);
emit dentalFixtureRadiusChanged(radius);
}
void DentalFixture::setDentalFixtureBrand(Data * data, QStandardItem * item)
{
DentalFixture* self = static_cast<DentalFixture*>(data);
self->setDentalFixtureBrand(DentalFixture::getAttribute(item).toString());
}
void DentalFixture::setDentalFixtureModel(Data * data, QStandardItem * item)
{
DentalFixture* self = static_cast<DentalFixture*>(data);
self->setDentalFixtureModel(DentalFixture::getAttribute(item).toString());
}
void DentalFixture::setDentalFixtureShape(Data * data, QStandardItem * item)
{
DentalFixture* self = static_cast<DentalFixture*>(data);
self->setDentalFixtureShape(DentalFixture::getAttribute(item).toString());
}
void DentalFixture::setDentalFixtureLength(Data * data, QStandardItem * item)
{
DentalFixture* self = static_cast<DentalFixture*>(data);
self->setDentalFixtureLength(DentalFixture::getAttribute(item).toDouble());
}
void DentalFixture::setDentalFixtureRadius(Data * data, QStandardItem * item)
{
DentalFixture* self = static_cast<DentalFixture*>(data);
self->setDentalFixtureRadius(DentalFixture::getAttribute(item).toDouble());
}
}
}
| 30.297297
| 102
| 0.781891
|
wuzhuobin
|
941488b9258af3872ca0df27ba1a683705926c5f
| 479
|
cpp
|
C++
|
arduino/library/MotionHandler.cpp
|
FaresMehanna/Monitor-And-Control-Server-Room
|
29caea1501a5174c63ba87c47545c889b9cf2e51
|
[
"MIT"
] | null | null | null |
arduino/library/MotionHandler.cpp
|
FaresMehanna/Monitor-And-Control-Server-Room
|
29caea1501a5174c63ba87c47545c889b9cf2e51
|
[
"MIT"
] | null | null | null |
arduino/library/MotionHandler.cpp
|
FaresMehanna/Monitor-And-Control-Server-Room
|
29caea1501a5174c63ba87c47545c889b9cf2e51
|
[
"MIT"
] | null | null | null |
#include "MotionHandler.h"
MotionHandler::MotionHandler(ErrorHandler& _errorHandler, uint8_t _pin) : errorHandler(_errorHandler) {
motion = false;
pin = _pin;
timer = millis();
}
void MotionHandler::setup(void) {
pinMode(pin, INPUT);
}
void MotionHandler::loop(void) {
if(digitalRead(pin) == HIGH) {
motion = true;
timer = millis();
} else if (millis() - timer > PIR_SENSOR_UP_TIME) {
motion = false;
}
}
boolean MotionHandler::isMotion(void) {
return motion;
}
| 19.958333
| 103
| 0.697286
|
FaresMehanna
|
9418562ce25fc356d4e34355dd07cd5067c6e13e
| 6,844
|
cpp
|
C++
|
src/domain/domain.cpp
|
srom/nbias
|
be8cf8dd623038dcf08d38ed3d19f635ee2dbeae
|
[
"MIT"
] | null | null | null |
src/domain/domain.cpp
|
srom/nbias
|
be8cf8dd623038dcf08d38ed3d19f635ee2dbeae
|
[
"MIT"
] | null | null | null |
src/domain/domain.cpp
|
srom/nbias
|
be8cf8dd623038dcf08d38ed3d19f635ee2dbeae
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <cmath>
#include <string>
#include <sstream>
#include <unordered_map>
#include <utility>
#include <boost/algorithm/string.hpp>
#include <xtensor/xarray.hpp>
#include "csv.hpp"
#include "../probability/probability_util.cpp"
using namespace std;
using namespace csv;
const double LOG_10 = log((double) 10);
struct ProteinDomain {
string id;
string query;
string description;
ProteinDomain() :id{""}, query{""}, description{""} {}
ProteinDomain(
const string& domain_id,
const string& domain_query,
const string& domain_description = ""
) {
id = domain_id;
query = domain_query;
description = domain_description;
}
ProteinDomain(const ProteinDomain& d) {
id = d.id;
query = d.query;
description = d.description;
}
};
bool operator==(const ProteinDomain& a, const ProteinDomain& b) {
return a.id == b.id;
}
bool operator!=(const ProteinDomain& a, const ProteinDomain& b) {
return !(a == b);
}
bool operator<(const ProteinDomain& a, const ProteinDomain& b) {
return a.id < b.id;
}
bool operator<=(const ProteinDomain& a, const ProteinDomain& b) {
return (a < b || a == b) && !(b < a);
}
bool operator>(const ProteinDomain& a, const ProteinDomain& b) {
return b < a;
}
bool operator>=(const ProteinDomain& a, const ProteinDomain& b) {
return (a > b || a == b) && !(a < b);
}
namespace std {
template <>
struct hash<ProteinDomain> {
size_t operator()(const ProteinDomain& pd) const {
return hash<string>()(pd.id);
}
};
}
class ProteinDomains {
vector<ProteinDomain> keys;
unordered_map<ProteinDomain, vector<string>> protein_id_map;
public:
ProteinDomains(istream& is) :keys{}, protein_id_map{} {
string line;
int i = 0;
while (getline(is, line)) {
if (i == 0 || line.empty()) {
++i;
continue;
}
++i;
vector<string> elements;
boost::split(elements, line, boost::is_any_of(","));
if (elements.size() < 4) {
throw runtime_error(
"ProteinDomains: at least 4 columns expected "
"but got: " + to_string(elements.size())
);
}
string protein_id = elements[1];
string query = elements[2];
string full_id = elements[3];
vector<string> id_parts;
boost::split(id_parts, full_id, boost::is_any_of("."));
string id = id_parts[0];
ProteinDomain domain(id, query);
if (protein_id_map.find(domain) == protein_id_map.end()) {
protein_id_map[domain] = vector<string>{protein_id};
keys.push_back(domain);
} else {
protein_id_map[domain].push_back(protein_id);
}
}
}
vector<ProteinDomain> Keys() {
return keys;
}
vector<string> ProteinIds(const ProteinDomain& key) {
return protein_id_map[key];
}
size_t size() {
return keys.size();
}
xt::xarray<double> Probabilities(
const ProteinDomain& key,
GeneProbabilies& probs,
const bool random = false
) {
auto protein_ids = ProteinIds(key);
xt::xarray<double> probabilities = xt::zeros<double>({protein_ids.size()});
int k = 0;
for (const string protein_id : protein_ids) {
probabilities[k] = probs.Get(protein_id, random);
++k;
}
return probabilities;
}
};
string EvidenceStrength(double evidence) {
if (evidence <= 0) {
return "Negative";
} else if (evidence <= 0.5) {
return "Weak";
} else if (evidence <= 1.0) {
return "Substantial";
} else if (evidence <= 1.5) {
return "Strong";
} else if (evidence <= 2.0) {
return "Very Strong";
} else {
return "Decisive";
}
}
template <typename T>
string to_string_with_precision(const T val, const int n = 8)
{
ostringstream out;
out.precision(n);
out << fixed << val;
return out.str();
}
struct DomainProbability {
ProteinDomain domain;
double log_probability;
double log_probability_random;
size_t n_elements;
double evidence;
string evidence_strength;
DomainProbability(
const ProteinDomain& d,
const double& log_p,
const double& log_pr,
const size_t n_el
) {
if (isinf(log_p) || isinf(log_pr)) {
throw runtime_error("DomainProbability: -inf log probability encountered for domain " + d.query);
} else if (isnan(log_p) || isnan(log_pr)) {
throw runtime_error("DomainProbability: NaN log probability encountered for domain " + d.query);
} else if (log_p > 0 || log_pr > 0) {
throw runtime_error("DomainProbability: log probability > 0 encountered for domain " + d.query);
} else if (n_el == 0) {
throw runtime_error("DomainProbability: n_elements is zero for domain " + d.query);
}
domain = ProteinDomain(d);
log_probability = log_p;
log_probability_random = log_pr;
n_elements = n_el;
evidence = (log_probability - log_probability_random) / LOG_10;
evidence_strength = EvidenceStrength(evidence);
}
vector<string> Record() {
return vector<string>{
domain.id,
domain.query,
domain.description,
to_string_with_precision(log_probability),
to_string_with_precision(log_probability_random),
to_string(n_elements),
to_string_with_precision(evidence),
evidence_strength,
};
}
static vector<string> RecordHeader() {
return vector<string>{
"id",
"query",
"description",
"log_probability",
"log_probability_random",
"n_elements",
"evidence",
"evidence_strength",
};
}
};
bool operator==(const DomainProbability& a, const DomainProbability& b) {
return a.evidence == b.evidence;
}
bool operator!=(const DomainProbability& a, const DomainProbability& b) {
return !(a == b);
}
bool operator<(const DomainProbability& a, const DomainProbability& b) {
return a.evidence < b.evidence;
}
bool operator<=(const DomainProbability& a, const DomainProbability& b) {
return (a < b || a == b) && !(b < a);
}
bool operator>(const DomainProbability& a, const DomainProbability& b) {
return b < a;
}
bool operator>=(const DomainProbability& a, const DomainProbability& b) {
return (a > b || a == b) && !(a < b);
}
vector<DomainProbability> LoadDomainProbabilities(const string& path) {
CSVReader reader(path);
vector<DomainProbability> out;
for (CSVRow& row: reader) {
ProteinDomain domain(
row["id"].get<string>(),
row["query"].get<string>(),
row["description"].get<string>()
);
out.push_back(
DomainProbability(
domain,
row["log_probability"].get<double>(),
row["log_probability_random"].get<double>(),
row["n_elements"].get<size_t>()
)
);
}
return out;
}
unordered_map<string, pair<string, string>> LoadDomainMetadata(const string& path) {
CSVReader reader(path);
unordered_map<string, pair<string, string>> out;
for (CSVRow& row: reader) {
string domain_id = row["id"].get<string>();
string domain_query = row["query"].get<string>();
string domain_description = row["description"].get<string>();
out[domain_id] = make_pair(domain_query, domain_description);
}
return out;
}
| 24.098592
| 100
| 0.673437
|
srom
|
9418cf1714190879633f4609024ecf8e5b979b7c
| 918
|
cpp
|
C++
|
HW/hw1/src/main.cpp
|
amirnn/Engineering-Mathematics
|
99dd270dba8ca3357259afb9195a9136b33510d8
|
[
"MIT"
] | null | null | null |
HW/hw1/src/main.cpp
|
amirnn/Engineering-Mathematics
|
99dd270dba8ca3357259afb9195a9136b33510d8
|
[
"MIT"
] | null | null | null |
HW/hw1/src/main.cpp
|
amirnn/Engineering-Mathematics
|
99dd270dba8ca3357259afb9195a9136b33510d8
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <eigen3/Eigen/Dense>
#include <vector>
#include <cmath>
#include <boost/numeric/odeint.hpp>
#include "gnuplot-iostream.h"
#include "system_function.h"
namespace odeint = boost::numeric::odeint;
int main()
{
state_type x(2); // a vector with size 2.
x[0] = 1.0; // start at x=1.0, p=0.0
x[1] = 0.0;
std::vector<state_type> x_vec;
std::vector<double> times;
size_t steps = odeint::integrate(harmonic_oscillator,
x, 0.0, 10.0, 0.1,
push_back_state_and_time(x_vec, times));
std::vector<double> position;
for (size_t i = 0; i <= steps; i++)
{
position.push_back(x_vec[i][0]);
}
/* output */
Gnuplot gp;
gp << "plot '-' using 1:2 with linespoint" << std::endl;
gp.send1d(std::make_tuple(times, position));
// for (size_t i = 0; i <= steps; i++)
// {
// std::cout << times[i] << '\t' << x_vec[i][0] << '\t' << x_vec[i][1] << '\n';
// }
return 0;
}
| 24.157895
| 81
| 0.610022
|
amirnn
|
941a0244d43eab217be8744cb8464ae09dc5b6ca
| 9,127
|
cpp
|
C++
|
Ex2 - Canny/src/canny.cpp
|
zuimrs/ImageProcess
|
8a699668c71e45e7910a6bfcb3ab0589d878cbfa
|
[
"MIT"
] | 1
|
2018-06-20T12:29:52.000Z
|
2018-06-20T12:29:52.000Z
|
Ex2 - Canny/src/canny.cpp
|
zuimrs/ImageProcess
|
8a699668c71e45e7910a6bfcb3ab0589d878cbfa
|
[
"MIT"
] | null | null | null |
Ex2 - Canny/src/canny.cpp
|
zuimrs/ImageProcess
|
8a699668c71e45e7910a6bfcb3ab0589d878cbfa
|
[
"MIT"
] | null | null | null |
#include "canny.h"
#include <iostream>
#include "CImg.h"
#include <vector>
#define gFilterx 3
#define gFiltery 3
#define sigma 1
#define threshold_low 30
#define threshold_high 50
using namespace cimg_library;
Canny::Canny(const char * filename)
{
this->img.load(filename);
if(this->img.empty())
{
std::cout << "Could not open or find the image" <<std:: endl;
return;
}
vector<vector<float> >filter = createFilter(gFilterx,gFiltery,sigma);
//Print filter
for (int i = 0; i < filter.size(); ++i)
{
for (int j = 0; j < filter[i].size(); ++j)
{
cout << filter[i][j] << " ";
}
}
cout << endl;
this->grayscaled = this->toGrayScale();
this->gFiltered = this->useFilter(this->grayscaled,filter);
this->sFiltered = this->sobel();
this->non = this->nonMaxSupp();
this->thres = this->threshold(this->non,threshold_low,threshold_high);
this->img.display("Original");
this->grayscaled.display("GrayScaled");
this->gFiltered.display("Gaussian Blur");
this->sFiltered.display("Sobel Filtered");
this->non.display("Non-Maxima Supp");
this->thres.display("Final");
}
CImg<float> Canny::toGrayScale()
{
CImg<float> gray(this->img._width,this->img._height,1,1);
cimg_forXY(this->img,x,y)
{
float r = this->img._atXY(x,y,0,0);
float g = this->img._atXY(x,y,0,1);
float b = this->img._atXY(x,y,0,2);
float newValue = (r * 0.2126 + g * 0.7152 + b * 0.0722);
gray._atXY(x,y) = newValue;
}
return gray;
}
vector<vector<float> > Canny::createFilter(int row,int column,float sigmaIn)
{
vector<vector<float> > filter;
for (int i = 0; i < row; i++)
{
vector<float> col;
for (int j = 0; j < column; j++)
{
col.push_back(-1);
}
filter.push_back(col);
}
float coordSum = 0;
float constant = 2.0 * sigmaIn * sigmaIn;
// Sum is for normalization
float sum = 0.0;
for (int x = - row/2; x <= row/2; x++)
{
for (int y = -column/2; y <= column/2; y++)
{
coordSum = (x*x + y*y);
filter[x + row/2][y + column/2] = (exp(-(coordSum) / constant)) / (M_PI * constant);
sum += filter[x + row/2][y + column/2];
}
}
// Normalize the Filter
for (int i = 0; i < row; i++)
for (int j = 0; j < column; j++)
filter[i][j] /= sum;
return filter;
}
CImg<float> Canny::useFilter(CImg<float> img_in,vector<vector<float> >filterIn)
{
int size = (int)filterIn.size()/2;
CImg<float> filteredImg(img_in._width - 2*size, img_in._height - 2*size, 1,1);
for (int i = size; i < img_in._width - size; i++)
{
for (int j = size; j < img_in._height - size; j++)
{
float sum = 0;
for (int x = 0; x < filterIn.size(); x++)
for (int y = 0; y < filterIn.size(); y++)
{
sum += filterIn[x][y] * (float)(img_in._atXY(i + x - size, j + y - size));
}
filteredImg._atXY(i-size, j-size) = sum;
}
}
return filteredImg;
}
CImg<float> Canny::sobel()
{
//Sobel X Filter
float x1[] = {-1.0, 0, 1.0};
float x2[] = {-2.0, 0, 2.0};
float x3[] = {-1.0, 0, 1.0};
vector<vector<float> > xFilter(3);
xFilter[0].assign(x1, x1+3);
xFilter[1].assign(x2, x2+3);
xFilter[2].assign(x3, x3+3);
//Sobel Y Filter
float y1[] = {1.0, 2.0, 1.0};
float y2[] = {0, 0, 0};
float y3[] = {-1.0, -2.0, -1.0};
vector<vector<float> > yFilter(3);
yFilter[0].assign(y1, y1+3);
yFilter[1].assign(y2, y2+3);
yFilter[2].assign(y3, y3+3);
//Limit Size
int size = (int)xFilter.size()/2;
CImg<float> filteredImg(gFiltered._width - 2*size, gFiltered._height - 2*size, 1,1);
CImg<float> tmp(gFiltered._width - 2*size, gFiltered._height - 2*size, 1,1); //AngleMap
this->angles = tmp;
for (int i = size; i < gFiltered._width - size; i++)
{
for (int j = size; j < gFiltered._height - size; j++)
{
float sumx = 0;
float sumy = 0;
for (int x = 0; x < xFilter.size(); x++)
for (int y = 0; y < xFilter.size(); y++)
{
sumx += xFilter[y][x] * (float)(gFiltered._atXY(i + x - size, j + y - size)); //Sobel_X Filter Value
sumy += yFilter[y][x] * (float)(gFiltered._atXY(i + x - size, j + y - size)); //Sobel_Y Filter Value
}
float sumxsq = sumx*sumx;
float sumysq = sumy*sumy;
float sq2 = sqrt(sumxsq + sumysq);
if(sq2 > 255) //Unsigned Char Fix
sq2 =255;
filteredImg._atXY(i-size, j-size) = sq2;
if(sumx==0) //Arctan Fix
angles._atXY(i-size, j-size) = 90;
else
angles._atXY(i-size, j-size) = atan(sumy/sumx)*360/3.1415926;
}
}
return filteredImg;
}
CImg<float> Canny::nonMaxSupp()
{
CImg<float> nonMaxSupped (sFiltered._width-2, sFiltered._height-2, 1,1);
for (int i=1; i< sFiltered._width - 1; i++) {
for (int j=1; j<sFiltered._height - 1; j++) {
float Tangent = angles._atXY(i,j);
nonMaxSupped._atXY(i-1, j-1) = sFiltered._atXY(i,j);
//Horizontal Edge
if (((-22.5 < Tangent) && (Tangent <= 22.5)) || ((157.5 < Tangent) && (Tangent <= -157.5)))
{
if ((sFiltered._atXY(i,j) < sFiltered._atXY(i,j+1)) || (sFiltered._atXY(i,j) < sFiltered._atXY(i,j-1)))
nonMaxSupped._atXY(i-1, j-1) = 0;
}
//Vertical Edge
if (((-112.5 < Tangent) && (Tangent <= -67.5)) || ((67.5 < Tangent) && (Tangent <= 112.5)))
{
if ((sFiltered._atXY(i,j) < sFiltered._atXY(i+1,j)) || (sFiltered._atXY(i,j) < sFiltered._atXY(i-1,j)))
nonMaxSupped._atXY(i-1, j-1) = 0;
}
//-45 Degree Edge
if (((-67.5 < Tangent) && (Tangent <= -22.5)) || ((112.5 < Tangent) && (Tangent <= 157.5)))
{
if ((sFiltered._atXY(i,j) < sFiltered._atXY(i-1,j+1)) || (sFiltered._atXY(i,j) < sFiltered._atXY(i+1,j-1)))
nonMaxSupped._atXY(i-1, j-1) = 0;
}
//45 Degree Edge
if (((-157.5 < Tangent) && (Tangent <= -112.5)) || ((22.5 < Tangent) && (Tangent <= 67.5)))
{
if ((sFiltered._atXY(i,j) < sFiltered._atXY(i+1,j+1)) || (sFiltered._atXY(i,j) < sFiltered._atXY(i-1,j-1)))
nonMaxSupped._atXY(i-1, j-1) = 0;
}
}
}
return nonMaxSupped;
}
CImg<float> Canny::threshold(CImg<float> imgin,int low, int high)
{
if(low > 255)
low = 255;
if(high > 255)
high = 255;
CImg<float> EdgeMat(imgin._width, imgin._height, 1,1);
for (int i=0; i<imgin._width; i++)
{
for (int j = 0; j<imgin._height; j++)
{
EdgeMat._atXY(i,j) = imgin._atXY(i,j);
if(EdgeMat._atXY(i,j) > high)
EdgeMat._atXY(i,j) = 255;
else if(EdgeMat._atXY(i,j) < low)
EdgeMat._atXY(i,j) = 0;
else
{
bool anyHigh = false;
bool anyBetween = false;
for (int x=i-1; x < i+2; x++)
{
for (int y = j-1; y<j+2; y++)
{
if(x <= 0 || y <= 0 || EdgeMat._height || y > EdgeMat._width) //Out of bounds
continue;
else
{
if(EdgeMat._atXY(x,y) > high)
{
EdgeMat._atXY(i,j) = 255;
anyHigh = true;
break;
}
else if(EdgeMat._atXY(x,y) <= high && EdgeMat._atXY(x,y) >= low)
anyBetween = true;
}
}
if(anyHigh)
break;
}
if(!anyHigh && anyBetween)
for (int x=i-2; x < i+3; x++)
{
for (int y = j-1; y<j+3; y++)
{
if(x < 0 || y < 0 || x > EdgeMat._height || y > EdgeMat._width) //Out of bounds
continue;
else
{
if(EdgeMat._atXY(x,y) > high)
{
EdgeMat._atXY(i,j) = 255;
anyHigh = true;
break;
}
}
}
if(anyHigh)
break;
}
if(!anyHigh)
EdgeMat._atXY(i,j) = 0;
}
}
}
return EdgeMat;
}
| 30.73064
| 123
| 0.4559
|
zuimrs
|
941ed907e30d2805fa59600e405898cd810dc07c
| 7,676
|
cpp
|
C++
|
llarp/pathbuilder.cpp
|
liilac/loki-network
|
411ef0fe8706a2b76ab437e7a7b48d291756b518
|
[
"Zlib"
] | null | null | null |
llarp/pathbuilder.cpp
|
liilac/loki-network
|
411ef0fe8706a2b76ab437e7a7b48d291756b518
|
[
"Zlib"
] | null | null | null |
llarp/pathbuilder.cpp
|
liilac/loki-network
|
411ef0fe8706a2b76ab437e7a7b48d291756b518
|
[
"Zlib"
] | null | null | null |
#include <buffer.hpp>
#include <nodedb.hpp>
#include <path.hpp>
#include <pathbuilder.hpp>
#include <router.hpp>
#include <functional>
namespace llarp
{
template < typename User >
struct AsyncPathKeyExchangeContext
{
typedef llarp::path::Path Path_t;
typedef llarp::path::PathSet PathSet_t;
PathSet_t* pathset = nullptr;
Path_t* path = nullptr;
typedef std::function< void(AsyncPathKeyExchangeContext< User >*) > Handler;
User* user = nullptr;
Handler result;
size_t idx = 0;
llarp::Router* router = nullptr;
llarp_threadpool* worker = nullptr;
llarp::Logic* logic = nullptr;
llarp::Crypto* crypto = nullptr;
LR_CommitMessage LRCM;
static void
HandleDone(void* u)
{
AsyncPathKeyExchangeContext< User >* ctx =
static_cast< AsyncPathKeyExchangeContext< User >* >(u);
ctx->result(ctx);
delete ctx;
}
static void
GenerateNextKey(void* u)
{
AsyncPathKeyExchangeContext< User >* ctx =
static_cast< AsyncPathKeyExchangeContext< User >* >(u);
// current hop
auto& hop = ctx->path->hops[ctx->idx];
auto& frame = ctx->LRCM.frames[ctx->idx];
// generate key
ctx->crypto->encryption_keygen(hop.commkey);
hop.nonce.Randomize();
// do key exchange
if(!ctx->crypto->dh_client(hop.shared, hop.rc.enckey, hop.commkey,
hop.nonce))
{
llarp::LogError("Failed to generate shared key for path build");
delete ctx;
return;
}
// generate nonceXOR valueself->hop->pathKey
ctx->crypto->shorthash(hop.nonceXOR, llarp::Buffer(hop.shared));
++ctx->idx;
bool isFarthestHop = ctx->idx == ctx->path->hops.size();
if(isFarthestHop)
{
hop.upstream = hop.rc.pubkey.data();
}
else
{
hop.upstream = ctx->path->hops[ctx->idx].rc.pubkey.data();
}
// build record
LR_CommitRecord record;
record.version = LLARP_PROTO_VERSION;
record.txid = hop.txID;
record.rxid = hop.rxID;
record.tunnelNonce = hop.nonce;
record.nextHop = hop.upstream;
record.commkey = llarp::seckey_topublic(hop.commkey);
auto buf = frame.Buffer();
buf->cur = buf->base + EncryptedFrame::OverheadSize;
// encode record
if(!record.BEncode(buf))
{
// failed to encode?
llarp::LogError("Failed to generate Commit Record");
delete ctx;
return;
}
// use ephameral keypair for frame
SecretKey framekey;
ctx->crypto->encryption_keygen(framekey);
if(!frame.EncryptInPlace(framekey, hop.rc.enckey, ctx->crypto))
{
llarp::LogError("Failed to encrypt LRCR");
delete ctx;
return;
}
if(isFarthestHop)
{
// farthest hop
ctx->logic->queue_job({ctx, &HandleDone});
}
else
{
// next hop
llarp_threadpool_queue_job(ctx->worker, {ctx, &GenerateNextKey});
}
}
AsyncPathKeyExchangeContext(llarp::Crypto* c) : crypto(c)
{
}
/// Generate all keys asynchronously and call hadler when done
void
AsyncGenerateKeys(Path_t* p, llarp::Logic* l, llarp_threadpool* pool,
User* u, Handler func)
{
path = p;
logic = l;
user = u;
result = func;
worker = pool;
for(size_t idx = 0; idx < MAXHOPS; ++idx)
{
LRCM.frames[idx].Randomize();
}
llarp_threadpool_queue_job(pool, {this, &GenerateNextKey});
}
};
void
pathbuilder_generated_keys(AsyncPathKeyExchangeContext< path::Builder >* ctx)
{
RouterID remote = ctx->path->Upstream();
const ILinkMessage* msg = &ctx->LRCM;
if(!ctx->router->SendToOrQueue(remote, msg))
{
llarp::LogError("failed to send LRCM");
return;
}
// persist session with router until this path is done
ctx->router->PersistSessionUntil(remote, ctx->path->ExpireTime());
// add own path
ctx->router->paths.AddOwnPath(ctx->pathset, ctx->path);
}
namespace path
{
Builder::Builder(llarp::Router* p_router, struct llarp_dht_context* p_dht,
size_t pathNum, size_t hops)
: llarp::path::PathSet(pathNum)
, router(p_router)
, dht(p_dht)
, numHops(hops)
{
p_router->paths.AddPathBuilder(this);
p_router->crypto.encryption_keygen(enckey);
}
Builder::~Builder()
{
router->paths.RemovePathBuilder(this);
}
bool
Builder::SelectHop(llarp_nodedb* db, const RouterContact& prev,
RouterContact& cur, size_t hop, PathRole roles)
{
(void)roles;
if(hop == 0)
return router->NumberOfConnectedRouters()
&& router->GetRandomConnectedRouter(cur);
size_t tries = 5;
do
{
--tries;
if(db->select_random_hop(prev, cur, hop))
return true;
} while(router->routerProfiling.IsBad(cur.pubkey) && tries > 0);
return false;
}
const byte_t*
Builder::GetTunnelEncryptionSecretKey() const
{
return enckey;
}
bool
Builder::ShouldBuildMore(llarp_time_t now) const
{
return llarp::path::PathSet::ShouldBuildMore(now) && now > lastBuild
&& now - lastBuild > buildIntervalLimit;
}
void
Builder::BuildOne(PathRole roles)
{
std::vector< RouterContact > hops;
if(SelectHops(router->nodedb, hops, roles))
Build(hops, roles);
}
bool
Builder::SelectHops(llarp_nodedb* nodedb,
std::vector< RouterContact >& hops, PathRole roles)
{
hops.resize(numHops);
size_t idx = 0;
while(idx < numHops)
{
if(idx == 0)
{
if(!SelectHop(nodedb, hops[0], hops[0], 0, roles))
{
llarp::LogError("failed to select first hop");
return false;
}
}
else
{
if(!SelectHop(nodedb, hops[idx - 1], hops[idx], idx, roles))
{
/// TODO: handle this failure properly
llarp::LogWarn("Failed to select hop ", idx);
return false;
}
}
++idx;
}
return true;
}
llarp_time_t
Builder::Now() const
{
return router->Now();
}
void
Builder::Build(const std::vector< RouterContact >& hops, PathRole roles)
{
lastBuild = Now();
// async generate keys
AsyncPathKeyExchangeContext< Builder >* ctx =
new AsyncPathKeyExchangeContext< Builder >(&router->crypto);
ctx->router = router;
ctx->pathset = this;
auto path = new llarp::path::Path(hops, this, roles);
path->SetBuildResultHook(std::bind(&llarp::path::Builder::HandlePathBuilt,
this, std::placeholders::_1));
ctx->AsyncGenerateKeys(path, router->logic, router->tp, this,
&pathbuilder_generated_keys);
}
void
Builder::HandlePathBuilt(Path* p)
{
buildIntervalLimit = MIN_PATH_BUILD_INTERVAL;
PathSet::HandlePathBuilt(p);
}
void
Builder::HandlePathBuildTimeout(Path* p)
{
// linear backoff
buildIntervalLimit += 1000;
PathSet::HandlePathBuildTimeout(p);
}
void
Builder::ManualRebuild(size_t num, PathRole roles)
{
llarp::LogDebug("manual rebuild ", num);
while(num--)
BuildOne(roles);
}
} // namespace path
} // namespace llarp
| 26.560554
| 80
| 0.576081
|
liilac
|
94242b3f4080987d8c0a8e66eb9f768f11b24bcd
| 124,699
|
cpp
|
C++
|
Source/ComponentScript.cpp
|
JellyBitStudios/JellyBitEngine
|
4b975a50bb1934dfdbdf72e0c96c53a713e6cfa4
|
[
"MIT"
] | 10
|
2019-02-05T07:57:21.000Z
|
2021-10-17T13:44:31.000Z
|
Source/ComponentScript.cpp
|
JellyBitStudios/JellyBitEngine
|
4b975a50bb1934dfdbdf72e0c96c53a713e6cfa4
|
[
"MIT"
] | 178
|
2019-02-26T17:29:08.000Z
|
2019-06-05T10:55:42.000Z
|
Source/ComponentScript.cpp
|
JellyBitStudios/JellyBitEngine
|
4b975a50bb1934dfdbdf72e0c96c53a713e6cfa4
|
[
"MIT"
] | 2
|
2020-02-27T18:57:27.000Z
|
2020-05-28T01:19:59.000Z
|
#include "Application.h"
#include "ModuleInput.h"
#include "ModuleResourceManager.h"
#include "ScriptingModule.h"
#include "ModuleLayers.h"
#include "ModuleGOs.h"
#include "ComponentScript.h"
#include "ResourceScript.h"
#include "ResourcePrefab.h"
#include "imgui/imgui.h"
#include "imgui/imgui_internal.h"
#include "imgui/imgui_stl.h"
#include <mono/metadata/assembly.h>
#include <mono/jit/jit.h>
#include <mono/metadata/mono-config.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/attrdefs.h>
ComponentScript::ComponentScript(std::string scriptName, GameObject* gameObject) : scriptName(scriptName), Component(gameObject, ComponentTypes::ScriptComponent)
{
UUID = App->GenerateRandomNumber();
}
ComponentScript::ComponentScript(ComponentScript& copy, GameObject* parent, bool includeComponents) : scriptName(copy.scriptName), Component(parent, ComponentTypes::ScriptComponent)
{
UUID = App->GenerateRandomNumber();
this->scriptResUUID = copy.scriptResUUID;
App->res->SetAsUsed(scriptResUUID);
MonoObject* original = copy.GetMonoComponent();
MonoObject* newInstance = mono_object_clone(original); //In theory it copies all the public variables too
InstanceClass(newInstance);
if(includeComponents)
App->scripting->AddScriptComponent(this);
}
ComponentScript::~ComponentScript()
{
if (scriptResUUID != 0)
{
ResourceScript* scriptRes = (ResourceScript*)App->res->GetResource(scriptResUUID);
if (scriptRes)
App->res->SetAsUnused(scriptRes->GetUuid());
scriptResUUID = 0;
}
App->scripting->ClearScriptComponent(this);
}
void ComponentScript::OnSystemEvent(System_Event event)
{
Component::OnSystemEvent(event);
switch (event.type)
{
case System_Event_Type::LoadFinished:
{
if (tempBuffer != nullptr)
{
LoadPublicVars(tempBuffer);
delete[] tempBuffer;
tempBuffer = nullptr;
}
tempBufferBytes = 0u;
break;
}
case System_Event_Type::GameObjectDestroyed:
{
MonoObject* monoInstance = GetMonoComponent();
if (!monoInstance)
return;
MonoClass* monoClass = mono_object_get_class(monoInstance);
void* it = NULL;
MonoClassField* field = NULL;
do
{
field = mono_class_get_fields(monoClass, &it);
if (field)
{
MonoType* type = mono_field_get_type(field);
char* typeName = mono_type_get_name(type);
if (strcmp(typeName, "JellyBitEngine.GameObject") == 0)
{
MonoObject* storedMO;
mono_field_get_value(monoInstance, field, &storedMO);
if (!storedMO)
{
continue;
}
int address;
mono_field_get_value(storedMO, mono_class_get_field_from_name(mono_object_get_class(storedMO), "cppAddress"), &address);
GameObject* storedGO = (GameObject*)address;
if (storedGO == event.goEvent.gameObject)
{
//Our referenced GO is being destroyed!
mono_field_set_value(monoInstance, field, NULL);
}
}
}
} while (field != NULL);
}
}
}
void ComponentScript::Awake()
{
ResourceScript* scriptRes = (ResourceScript*)App->res->GetResource(scriptResUUID);
if (scriptRes && scriptRes->awakeMethod && !awaked)
{
MonoObject* exc = nullptr;
if (IsTreeActive())
{
awaked = true;
mono_runtime_invoke(scriptRes->awakeMethod, GetMonoComponent(), NULL, &exc);
if (exc)
{
System_Event event;
event.type = System_Event_Type::Pause;
App->PushSystemEvent(event);
App->Pause();
MonoString* exceptionMessage = mono_object_to_string(exc, NULL);
char* toLogMessage = mono_string_to_utf8(exceptionMessage);
CONSOLE_LOG(LogTypes::Error, toLogMessage);
mono_free(toLogMessage);
}
}
}
}
void ComponentScript::Start()
{
ResourceScript* scriptRes = (ResourceScript*)App->res->GetResource(scriptResUUID);
if (scriptRes && scriptRes->startMethod)
{
MonoObject* exc = nullptr;
if (IsTreeActive())
{
mono_runtime_invoke(scriptRes->startMethod, GetMonoComponent(), NULL, &exc);
if (exc)
{
System_Event event;
event.type = System_Event_Type::Pause;
App->PushSystemEvent(event);
App->Pause();
MonoString* exceptionMessage = mono_object_to_string(exc, NULL);
char* toLogMessage = mono_string_to_utf8(exceptionMessage);
CONSOLE_LOG(LogTypes::Error, toLogMessage);
mono_free(toLogMessage);
}
}
}
}
void ComponentScript::PreUpdate()
{
ResourceScript* scriptRes = (ResourceScript*)App->res->GetResource(scriptResUUID);
if (scriptRes && scriptRes->preUpdateMethod)
{
MonoObject* exc = nullptr;
if (IsTreeActive())
{
mono_runtime_invoke(scriptRes->preUpdateMethod, GetMonoComponent(), NULL, &exc);
if (exc)
{
System_Event event;
event.type = System_Event_Type::Pause;
App->PushSystemEvent(event);
App->Pause();
MonoString* exceptionMessage = mono_object_to_string(exc, NULL);
char* toLogMessage = mono_string_to_utf8(exceptionMessage);
CONSOLE_LOG(LogTypes::Error, toLogMessage);
mono_free(toLogMessage);
}
}
}
}
void ComponentScript::Update()
{
ResourceScript* scriptRes = (ResourceScript*)App->res->GetResource(scriptResUUID);
if (scriptRes && scriptRes->updateMethod)
{
MonoObject* exc = nullptr;
if (IsTreeActive())
{
mono_runtime_invoke(scriptRes->updateMethod, GetMonoComponent(), NULL, &exc);
if (exc)
{
System_Event event;
event.type = System_Event_Type::Pause;
App->PushSystemEvent(event);
App->Pause();
MonoString* exceptionMessage = mono_object_to_string(exc, NULL);
char* toLogMessage = mono_string_to_utf8(exceptionMessage);
CONSOLE_LOG(LogTypes::Error, toLogMessage);
mono_free(toLogMessage);
}
}
}
}
void ComponentScript::PostUpdate()
{
ResourceScript* scriptRes = (ResourceScript*)App->res->GetResource(scriptResUUID);
if (scriptRes && scriptRes->postUpdateMethod)
{
MonoObject* exc = nullptr;
if (IsTreeActive())
{
mono_runtime_invoke(scriptRes->postUpdateMethod, GetMonoComponent(), NULL, &exc);
if (exc)
{
System_Event event;
event.type = System_Event_Type::Pause;
App->PushSystemEvent(event);
App->Pause();
MonoString* exceptionMessage = mono_object_to_string(exc, NULL);
char* toLogMessage = mono_string_to_utf8(exceptionMessage);
CONSOLE_LOG(LogTypes::Error, toLogMessage);
mono_free(toLogMessage);
}
}
}
}
void ComponentScript::OnEnableMethod()
{
ResourceScript* scriptRes = (ResourceScript*)App->res->GetResource(scriptResUUID);
if (scriptRes && scriptRes->enableMethod)
{
MonoObject* exc = nullptr;
if (IsTreeActive())
{
mono_runtime_invoke(scriptRes->enableMethod, GetMonoComponent(), NULL, &exc);
if (exc)
{
System_Event event;
event.type = System_Event_Type::Pause;
App->PushSystemEvent(event);
App->Pause();
MonoString* exceptionMessage = mono_object_to_string(exc, NULL);
char* toLogMessage = mono_string_to_utf8(exceptionMessage);
CONSOLE_LOG(LogTypes::Error, toLogMessage);
mono_free(toLogMessage);
}
}
}
}
void ComponentScript::OnDisableMethod()
{
ResourceScript* scriptRes = (ResourceScript*)App->res->GetResource(scriptResUUID);
if (scriptRes && scriptRes->disableMethod)
{
MonoObject* exc = nullptr;
mono_runtime_invoke(scriptRes->disableMethod, GetMonoComponent(), NULL, &exc);
if (exc)
{
System_Event event;
event.type = System_Event_Type::Pause;
App->PushSystemEvent(event);
App->Pause();
MonoString* exceptionMessage = mono_object_to_string(exc, NULL);
char* toLogMessage = mono_string_to_utf8(exceptionMessage);
CONSOLE_LOG(LogTypes::Error, toLogMessage);
mono_free(toLogMessage);
}
}
}
void ComponentScript::OnStop()
{
ResourceScript* scriptRes = (ResourceScript*)App->res->GetResource(scriptResUUID);
if (scriptRes && scriptRes->stopMethod)
{
MonoObject* exc = nullptr;
if (IsTreeActive())
{
awaked = false;
mono_runtime_invoke(scriptRes->stopMethod, GetMonoComponent(), NULL, &exc);
if (exc)
{
System_Event event;
event.type = System_Event_Type::Pause;
App->PushSystemEvent(event);
App->Pause();
MonoString* exceptionMessage = mono_object_to_string(exc, NULL);
char* toLogMessage = mono_string_to_utf8(exceptionMessage);
CONSOLE_LOG(LogTypes::Error, toLogMessage);
mono_free(toLogMessage);
}
}
}
}
void ComponentScript::FixedUpdate()
{
ResourceScript* scriptRes = (ResourceScript*)App->res->GetResource(scriptResUUID);
if (scriptRes && scriptRes->fixedUpdateMethod)
{
MonoObject* exc = nullptr;
if (IsTreeActive())
{
mono_runtime_invoke(scriptRes->fixedUpdateMethod, GetMonoComponent(), NULL, &exc);
if (exc)
{
System_Event event;
event.type = System_Event_Type::Pause;
App->PushSystemEvent(event);
App->Pause();
MonoString* exceptionMessage = mono_object_to_string(exc, NULL);
char* toLogMessage = mono_string_to_utf8(exceptionMessage);
CONSOLE_LOG(LogTypes::Error, toLogMessage);
mono_free(toLogMessage);
}
}
}
}
void ComponentScript::OnDrawGizmos()
{
ResourceScript* scriptRes = (ResourceScript*)App->res->GetResource(scriptResUUID);
if (scriptRes && scriptRes->onDrawGizmos)
{
MonoObject* exc = nullptr;
if (IsTreeActive())
{
mono_runtime_invoke(scriptRes->onDrawGizmos, GetMonoComponent(), NULL, &exc);
if (exc)
{
System_Event event;
event.type = System_Event_Type::Pause;
App->PushSystemEvent(event);
App->Pause();
MonoString* exceptionMessage = mono_object_to_string(exc, NULL);
char* toLogMessage = mono_string_to_utf8(exceptionMessage);
CONSOLE_LOG(LogTypes::Error, toLogMessage);
mono_free(toLogMessage);
}
}
}
}
void ComponentScript::OnDrawGizmosSelected()
{
ResourceScript* scriptRes = (ResourceScript*)App->res->GetResource(scriptResUUID);
if (scriptRes && scriptRes->onDrawGizmosSelected)
{
MonoObject* exc = nullptr;
if (IsTreeActive())
{
mono_runtime_invoke(scriptRes->onDrawGizmosSelected, GetMonoComponent(), NULL, &exc);
if (exc)
{
System_Event event;
event.type = System_Event_Type::Pause;
App->PushSystemEvent(event);
App->Pause();
MonoString* exceptionMessage = mono_object_to_string(exc, NULL);
char* toLogMessage = mono_string_to_utf8(exceptionMessage);
CONSOLE_LOG(LogTypes::Error, toLogMessage);
mono_free(toLogMessage);
}
}
}
}
void ComponentScript::OnCollisionEnter(Collision& collision)
{
ResourceScript* scriptRes = (ResourceScript*)App->res->GetResource(scriptResUUID);
if (scriptRes && scriptRes->OnCollisionEnterMethod)
{
MonoObject* exc = nullptr;
if (IsTreeActive())
{
//Set the collision object
MonoClass* collisionClass = mono_class_from_name(App->scripting->internalImage, "JellyBitEngine", "Collision");
MonoObject* collisionOBJ = mono_object_new(App->scripting->domain, collisionClass);
mono_runtime_object_init(collisionOBJ);
//Set the gameObject
mono_field_set_value(collisionOBJ, mono_class_get_field_from_name(collisionClass, "gameObject"), App->scripting->MonoObjectFrom(collision.GetGameObject()));
//Set the collider
mono_field_set_value(collisionOBJ, mono_class_get_field_from_name(collisionClass, "collider"), App->scripting->MonoComponentFrom((Component*)collision.GetCollider()));
//Set the impulse
MonoClass* vector3Class = mono_class_from_name(App->scripting->internalImage, "JellyBitEngine", "Vector3");
math::float3 impulse = collision.GetImpulse();
mono_field_set_value(collisionOBJ, mono_class_get_field_from_name(collisionClass, "impulse"), &impulse);
//Set the relative velocity
math::float3 relativeVelocity = collision.GetRelativeVelocity();
mono_field_set_value(collisionOBJ, mono_class_get_field_from_name(collisionClass, "relativeVelocity"), &relativeVelocity);
//Set the contacts
std::vector<ContactPoint> contacts = collision.GetContactPoints();
float numContacts = contacts.size();
mono_field_set_value(collisionOBJ, mono_class_get_field_from_name(collisionClass, "contactCount"), &numContacts);
MonoClass* ContactPointClass = mono_class_from_name(App->scripting->internalImage, "JellyBitEngine", "ContactPoint");
MonoArray* contactArray = mono_array_new(App->scripting->domain, ContactPointClass, numContacts);
for (int i = 0; i < numContacts; ++i)
{
ContactPoint contact = contacts[i];
MonoObject* contactOBJ = mono_object_new(App->scripting->domain, ContactPointClass);
mono_runtime_object_init(contactOBJ);
//Set normal
math::float3 normal = contact.GetNormal();
mono_field_set_value(contactOBJ, mono_class_get_field_from_name(ContactPointClass, "normal"), &normal);
//Set other collider
mono_field_set_value(contactOBJ, mono_class_get_field_from_name(ContactPointClass, "otherCollider"), App->scripting->MonoComponentFrom((Component*)contact.GetOtherCollider()));
//Set point
math::float3 point = contact.GetPoint();
mono_field_set_value(contactOBJ, mono_class_get_field_from_name(ContactPointClass, "point"), &point);
//Set separation
float separation = contact.GetSeparation();
mono_field_set_value(contactOBJ, mono_class_get_field_from_name(ContactPointClass, "separation"), &separation);
//Set this collider
mono_field_set_value(contactOBJ, mono_class_get_field_from_name(ContactPointClass, "thisCollider"), App->scripting->MonoComponentFrom((Component*)contact.GetThisCollider()));
mono_array_setref(contactArray, i, contactOBJ);
}
mono_field_set_value(collisionOBJ, mono_class_get_field_from_name(collisionClass, "contacts"), contactArray);
void* params[1];
params[0] = collisionOBJ;
mono_runtime_invoke(scriptRes->OnCollisionEnterMethod, GetMonoComponent(), params, &exc);
if (exc)
{
System_Event event;
event.type = System_Event_Type::Pause;
App->PushSystemEvent(event);
App->Pause();
MonoString* exceptionMessage = mono_object_to_string(exc, NULL);
char* toLogMessage = mono_string_to_utf8(exceptionMessage);
CONSOLE_LOG(LogTypes::Error, toLogMessage);
mono_free(toLogMessage);
}
}
}
}
void ComponentScript::OnCollisionStay(Collision& collision)
{
ResourceScript* scriptRes = (ResourceScript*)App->res->GetResource(scriptResUUID);
if (scriptRes && scriptRes->OnCollisionStayMethod)
{
MonoObject* exc = nullptr;
if (IsTreeActive())
{
//Set the collision object
MonoClass* collisionClass = mono_class_from_name(App->scripting->internalImage, "JellyBitEngine", "Collision");
MonoObject* collisionOBJ = mono_object_new(App->scripting->domain, collisionClass);
mono_runtime_object_init(collisionOBJ);
//Set the gameObject
mono_field_set_value(collisionOBJ, mono_class_get_field_from_name(collisionClass, "gameObject"), App->scripting->MonoObjectFrom(collision.GetGameObject()));
//Set the collider
mono_field_set_value(collisionOBJ, mono_class_get_field_from_name(collisionClass, "collider"), App->scripting->MonoComponentFrom((Component*)collision.GetCollider()));
//Set the impulse
math::float3 impulse = collision.GetImpulse();
mono_field_set_value(collisionOBJ, mono_class_get_field_from_name(collisionClass, "impulse"), &impulse);
//TODO: RELATIVE VELOCITY?
//Set the contacts
std::vector<ContactPoint> contacts = collision.GetContactPoints();
float numContacts = contacts.size();
mono_field_set_value(collisionOBJ, mono_class_get_field_from_name(collisionClass, "contactCount"), &numContacts);
MonoClass* ContactPointClass = mono_class_from_name(App->scripting->internalImage, "JellyBitEngine", "ContactPoint");
MonoArray* contactArray = mono_array_new(App->scripting->domain, ContactPointClass, numContacts);
for (int i = 0; i < numContacts; ++i)
{
ContactPoint contact = contacts[i];
MonoObject* contactOBJ = mono_object_new(App->scripting->domain, ContactPointClass);
mono_runtime_object_init(contactOBJ);
//Set normal
math::float3 normal = contact.GetNormal();
mono_field_set_value(contactOBJ, mono_class_get_field_from_name(ContactPointClass, "normal"), &normal);
//Set other collider
mono_field_set_value(contactOBJ, mono_class_get_field_from_name(ContactPointClass, "otherCollider"), App->scripting->MonoComponentFrom((Component*)collision.GetCollider()));
//Set point
math::float3 point = contact.GetPoint();
mono_field_set_value(contactOBJ, mono_class_get_field_from_name(ContactPointClass, "point"), &point);
//Set separation
float separation = contact.GetSeparation();
mono_field_set_value(contactOBJ, mono_class_get_field_from_name(ContactPointClass, "separation"), &separation);
//TODO: SET THIS COLLIDER
//mono_field_set_value(contactOBJ, mono_class_get_field_from_name(ContactPointClass, "thisCollider"), App->scripting->MonoComponentFrom((Component*)collision.GetThiCollider()));
mono_array_setref(contactArray, i, contactOBJ);
}
mono_field_set_value(collisionOBJ, mono_class_get_field_from_name(collisionClass, "contacts"), contactArray);
void* params[1];
params[0] = collisionOBJ;
mono_runtime_invoke(scriptRes->OnCollisionStayMethod, GetMonoComponent(), NULL, &exc);
if (exc)
{
System_Event event;
event.type = System_Event_Type::Pause;
App->PushSystemEvent(event);
App->Pause();
MonoString* exceptionMessage = mono_object_to_string(exc, NULL);
char* toLogMessage = mono_string_to_utf8(exceptionMessage);
CONSOLE_LOG(LogTypes::Error, toLogMessage);
mono_free(toLogMessage);
}
}
}
}
void ComponentScript::OnCollisionExit(Collision& collision)
{
ResourceScript* scriptRes = (ResourceScript*)App->res->GetResource(scriptResUUID);
if (scriptRes && scriptRes->OnCollisionExitMethod)
{
MonoObject* exc = nullptr;
if (IsTreeActive())
{
//Set the collision object
MonoClass* collisionClass = mono_class_from_name(App->scripting->internalImage, "JellyBitEngine", "Collision");
MonoObject* collisionOBJ = mono_object_new(App->scripting->domain, collisionClass);
mono_runtime_object_init(collisionOBJ);
//Set the gameObject
mono_field_set_value(collisionOBJ, mono_class_get_field_from_name(collisionClass, "gameObject"), App->scripting->MonoObjectFrom(collision.GetGameObject()));
//Set the collider
mono_field_set_value(collisionOBJ, mono_class_get_field_from_name(collisionClass, "collider"), App->scripting->MonoComponentFrom((Component*)collision.GetCollider()));
//Set the impulse
math::float3 impulse = collision.GetImpulse();
mono_field_set_value(collisionOBJ, mono_class_get_field_from_name(collisionClass, "impulse"), &impulse);
//TODO: RELATIVE VELOCITY?
//Set the contacts
std::vector<ContactPoint> contacts = collision.GetContactPoints();
float numContacts = contacts.size();
mono_field_set_value(collisionOBJ, mono_class_get_field_from_name(collisionClass, "contactCount"), &numContacts);
MonoClass* ContactPointClass = mono_class_from_name(App->scripting->internalImage, "JellyBitEngine", "ContactPoint");
MonoArray* contactArray = mono_array_new(App->scripting->domain, ContactPointClass, numContacts);
for (int i = 0; i < numContacts; ++i)
{
ContactPoint contact = contacts[i];
MonoObject* contactOBJ = mono_object_new(App->scripting->domain, ContactPointClass);
mono_runtime_object_init(contactOBJ);
//Set normal
math::float3 normal = contact.GetNormal();
mono_field_set_value(contactOBJ, mono_class_get_field_from_name(ContactPointClass, "normal"), &normal);
//Set other collider
mono_field_set_value(contactOBJ, mono_class_get_field_from_name(ContactPointClass, "otherCollider"), App->scripting->MonoComponentFrom((Component*)collision.GetCollider()));
//Set point
math::float3 point = contact.GetPoint();
mono_field_set_value(contactOBJ, mono_class_get_field_from_name(ContactPointClass, "point"), &point);
//Set separation
float separation = contact.GetSeparation();
mono_field_set_value(contactOBJ, mono_class_get_field_from_name(ContactPointClass, "separation"), &separation);
//TODO: SET THIS COLLIDER
//mono_field_set_value(contactOBJ, mono_class_get_field_from_name(ContactPointClass, "thisCollider"), App->scripting->MonoComponentFrom((Component*)collision.GetThiCollider()));
mono_array_setref(contactArray, i, contactOBJ);
}
mono_field_set_value(collisionOBJ, mono_class_get_field_from_name(collisionClass, "contacts"), contactArray);
void* params[1];
params[0] = collisionOBJ;
mono_runtime_invoke(scriptRes->OnCollisionExitMethod, GetMonoComponent(), params, &exc);
if (exc)
{
System_Event event;
event.type = System_Event_Type::Pause;
App->PushSystemEvent(event);
App->Pause();
MonoString* exceptionMessage = mono_object_to_string(exc, NULL);
char* toLogMessage = mono_string_to_utf8(exceptionMessage);
CONSOLE_LOG(LogTypes::Error, toLogMessage);
mono_free(toLogMessage);
}
}
}
}
void ComponentScript::OnTriggerEnter(Collision& collision)
{
ResourceScript* scriptRes = (ResourceScript*)App->res->GetResource(scriptResUUID);
if (scriptRes && scriptRes->OnTriggerEnterMethod)
{
MonoObject* exc = nullptr;
if (IsTreeActive())
{
MonoObject* collider = App->scripting->MonoComponentFrom((Component*)collision.GetCollider());
void* args[1];
args[0] = collider;
mono_runtime_invoke(scriptRes->OnTriggerEnterMethod, GetMonoComponent(), args, &exc);
if (exc)
{
System_Event event;
event.type = System_Event_Type::Pause;
App->PushSystemEvent(event);
App->Pause();
MonoString* exceptionMessage = mono_object_to_string(exc, NULL);
char* toLogMessage = mono_string_to_utf8(exceptionMessage);
CONSOLE_LOG(LogTypes::Error, toLogMessage);
mono_free(toLogMessage);
}
}
}
}
void ComponentScript::OnTriggerStay(Collision& collision)
{
ResourceScript* scriptRes = (ResourceScript*)App->res->GetResource(scriptResUUID);
if (scriptRes && scriptRes->OnTriggerStayMethod)
{
MonoObject* exc = nullptr;
if (IsTreeActive())
{
MonoObject* collider = App->scripting->MonoComponentFrom((Component*)collision.GetCollider());
void* args[1];
args[0] = collider;
mono_runtime_invoke(scriptRes->OnTriggerStayMethod, GetMonoComponent(), args, &exc);
if (exc)
{
System_Event event;
event.type = System_Event_Type::Pause;
App->PushSystemEvent(event);
App->Pause();
MonoString* exceptionMessage = mono_object_to_string(exc, NULL);
char* toLogMessage = mono_string_to_utf8(exceptionMessage);
CONSOLE_LOG(LogTypes::Error, toLogMessage);
mono_free(toLogMessage);
}
}
}
}
void ComponentScript::OnTriggerExit(Collision& collision)
{
ResourceScript* scriptRes = (ResourceScript*)App->res->GetResource(scriptResUUID);
if (scriptRes && scriptRes->OnTriggerExitMethod)
{
MonoObject* exc = nullptr;
if (IsTreeActive())
{
MonoObject* collider = App->scripting->MonoComponentFrom((Component*)collision.GetCollider());
void* args[1];
args[0] = collider;
mono_runtime_invoke(scriptRes->OnTriggerExitMethod, GetMonoComponent(), args, &exc);
if (exc)
{
System_Event event;
event.type = System_Event_Type::Pause;
App->PushSystemEvent(event);
App->Pause();
MonoString* exceptionMessage = mono_object_to_string(exc, NULL);
char* toLogMessage = mono_string_to_utf8(exceptionMessage);
CONSOLE_LOG(LogTypes::Error, toLogMessage);
mono_free(toLogMessage);
}
}
}
}
void ComponentScript::OnEnable()
{
if (App->GetEngineState() == engine_states::ENGINE_PLAY)
{
OnEnableMethod();
Awake();
}
}
void ComponentScript::OnDisable()
{
if (App->GetEngineState() == engine_states::ENGINE_PLAY)
OnDisableMethod();
}
void ComponentScript::OnUniqueEditor()
{
#ifndef GAMEMODE
//TODO: RECEIVE THOSE EVENTS THOUGH THE PARENT ONEDITOR()
/*if (ImGui::Checkbox(("###ACTIVE_SCRIPT" + std::to_string(UUID)).data(), &isActive))
{
if (isActive)
{
if (App->GetEngineState() == engine_states::ENGINE_PLAY)
this->OnEnableMethod();
}
else
{
if (App->GetEngineState() == engine_states::ENGINE_PLAY)
this->OnDisableMethod();
}
}
ImGui::SameLine();*/
float PosX = ImGui::GetCursorPosX();
bool opened = ImGui::CollapsingHeader(std::string("##Script" + std::to_string(UUID)).data()); ImGui::SameLine();
if (ImGui::IsItemClicked(1))
{
ImGui::OpenPopup(std::string("##Script" + std::to_string(UUID)).data());
}
ImGui::SetNextWindowSize({ 150, 45 });
ImGuiWindowFlags wflags = 0;
wflags |= ImGuiWindowFlags_::ImGuiWindowFlags_NoScrollbar;
bool deleted = false;
if (ImGui::BeginPopup(std::string("##Script" + std::to_string(UUID)).data(), wflags))
{
if (ImGui::MenuItem("Delete Component"))
{
System_Event event;
event.compEvent.type = System_Event_Type::ComponentDestroyed;
event.compEvent.component = this;
App->PushSystemEvent(event);
parent->EraseComponent(this);
deleted = true;
App->scripting->DestroyScript(this);
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}
if (deleted)
return;
ImGuiDragDropFlags flags = 0;
flags |= ImGuiDragDropFlags_::ImGuiDragDropFlags_SourceNoHoldToOpenOthers;
if (ImGui::BeginDragDropSource(flags))
{
ImGui::BeginTooltip();
ImGui::Text(std::string(scriptName + " (Script)").data());
ImGui::EndTooltip();
ComponentScript* thisOne = (ComponentScript*)this;
ImGui::SetDragDropPayload("DraggingComponents", &thisOne, sizeof(ComponentScript));
ImGui::EndDragDropSource();
}
ImGui::SetCursorPosX(PosX + 20);
ImGui::Text(std::string(scriptName + " (Script)").data());
if (opened)
{
ImGui::NewLine();
ImGui::Text(".cs File: "); ImGui::SameLine();
ImVec2 drawingPos = ImGui::GetCursorScreenPos();
drawingPos = { drawingPos.x - 10, drawingPos.y };
ImGui::SetCursorScreenPos(drawingPos);
float buttonWidth = 2 * ImGui::GetWindowWidth() / 3;
ImGui::ButtonEx("##csFile", { (float)buttonWidth, 15 }, ImGuiButtonFlags_::ImGuiButtonFlags_Disabled);
if (ImGui::IsItemHovered())
{
ImDrawList* drawList = ImGui::GetWindowDrawList();
drawList->AddRectFilled(drawingPos, { drawingPos.x + buttonWidth, drawingPos.y + 15 }, ImGui::GetColorU32(ImGuiCol_::ImGuiCol_ButtonHovered));
}
if (ImGui::IsItemClicked(0))
{
ImDrawList* drawList = ImGui::GetWindowDrawList();
drawList->AddRectFilled(drawingPos, { drawingPos.x + buttonWidth, drawingPos.y + 15 }, ImGui::GetColorU32(ImGuiCol_::ImGuiCol_ButtonActive));
}
ResourceScript* scriptRes = (ResourceScript*)App->res->GetResource(scriptResUUID);
if (ImGui::IsItemHovered())
{
ImGui::BeginTooltip();
ImGui::Text("\"%s\"\n\nThe .cs file attached to this script component.\nDo not move the script for now!", scriptRes ? scriptRes->GetFile() : "null");
ImGui::EndTooltip();
}
ImGui::SetCursorScreenPos({ drawingPos.x + 7, drawingPos.y });
//Calculate the text fitting the button rect
std::string originalText = scriptRes ? scriptRes->GetFile() : "";
std::string clampedText;
ImVec2 textSize = ImGui::CalcTextSize(originalText.data());
if (textSize.x > buttonWidth)
{
float maxTextLenght = (originalText.length() * (buttonWidth)) / textSize.x;
clampedText = originalText.substr(0, maxTextLenght - 7);
clampedText.append("(...)");
}
else
clampedText = originalText;
ImGui::Text(clampedText.data());
ImGui::NewLine();
if (!GetMonoComponent())
{
ImGui::TextColored({ .5,0,0,1 }, "SCRIPT WITH ERRORS, CHECK IT");
return;
}
//Script fields
void* iterator = 0;
MonoClassField* field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), &iterator);
while (field != nullptr)
{
MonoType* type = mono_field_get_type(field);
std::string typeName = mono_type_full_name(type);
std::string fieldName = mono_field_get_name(field);
MonoString* fieldNameCS = mono_string_new(App->scripting->domain, (char*)fieldName.data());
MonoReflectionType* myClassType = mono_type_get_object(App->scripting->domain, mono_class_get_type(mono_object_get_class(GetMonoComponent())));
bool hidden = FieldHasHideInInspector(myClassType, fieldNameCS);
if(!hidden)
{
uint32_t flags = mono_field_get_flags(field);
if (!(flags & MONO_FIELD_ATTR_STATIC))
{
bool serialized = FieldHasSerializeField(myClassType, fieldNameCS);
if ( (flags & MONO_FIELD_ATTR_PUBLIC) || serialized)
{
//This field is public and not static.
//Show the field, check the type and adapt the gui to it.
if (typeName == "bool")
{
bool varState; mono_field_get_value(GetMonoComponent(), field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::Checkbox(("##" + fieldName + std::to_string(UUID)).data(), &varState))
{
mono_field_set_value(GetMonoComponent(), field, &varState);
}
}
else if (typeName == "single") //this is a float, idk
{
float varState; mono_field_get_value(GetMonoComponent(), field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputFloat(("##" + fieldName + std::to_string(UUID)).data(), &varState))
{
mono_field_set_value(GetMonoComponent(), field, &varState);
}
}
else if (typeName == "double")
{
double varState;
mono_field_get_value(GetMonoComponent(), field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputDouble(("##" + fieldName + std::to_string(UUID)).data(), &varState))
{
mono_field_set_value(GetMonoComponent(), field, &varState);
}
}
else if (typeName == "System.Decimal")
{
//We cant convert System.Decimal, since we do not have this decimal precision in any C++ type.
}
else if (typeName == "sbyte")
{
int8_t varState;
mono_field_get_value(GetMonoComponent(), field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputScalar(("##" + fieldName + std::to_string(UUID)).data(), ImGuiDataType_::ImGuiDataType_S32, &varState))
{
mono_field_set_value(GetMonoComponent(), field, &varState);
}
}
else if (typeName == "byte")
{
uint8_t varState;
mono_field_get_value(GetMonoComponent(), field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputScalar(("##" + fieldName + std::to_string(UUID)).data(), ImGuiDataType_::ImGuiDataType_U32, &varState))
{
mono_field_set_value(GetMonoComponent(), field, &varState);
}
}
else if (typeName == "int16")
{
int16_t varState;
mono_field_get_value(GetMonoComponent(), field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputScalar(("##" + fieldName + std::to_string(UUID)).data(), ImGuiDataType_::ImGuiDataType_S32, &varState))
{
mono_field_set_value(GetMonoComponent(), field, &varState);
}
}
else if (typeName == "uint16")
{
uint16_t varState;
mono_field_get_value(GetMonoComponent(), field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputScalar(("##" + fieldName + std::to_string(UUID)).data(), ImGuiDataType_::ImGuiDataType_U32, &varState))
{
mono_field_set_value(GetMonoComponent(), field, &varState);
}
}
else if (typeName == "int")
{
int32_t varState;
mono_field_get_value(GetMonoComponent(), field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputScalar(("##" + fieldName + std::to_string(UUID)).data(), ImGuiDataType_::ImGuiDataType_S32, &varState))
{
mono_field_set_value(GetMonoComponent(), field, &varState);
}
}
else if (typeName == "uint")
{
uint32_t varState;
mono_field_get_value(GetMonoComponent(), field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputScalar(("##" + fieldName + std::to_string(UUID)).data(), ImGuiDataType_::ImGuiDataType_U32, &varState))
{
mono_field_set_value(GetMonoComponent(), field, &varState);
}
}
else if (typeName == "long")
{
int64_t varState;
mono_field_get_value(GetMonoComponent(), field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputScalar(("##" + fieldName + std::to_string(UUID)).data(), ImGuiDataType_::ImGuiDataType_S64, &varState))
{
mono_field_set_value(GetMonoComponent(), field, &varState);
}
}
else if (typeName == "ulong")
{
uint64_t varState;
mono_field_get_value(GetMonoComponent(), field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputScalar(("##" + fieldName + std::to_string(UUID)).data(), ImGuiDataType_::ImGuiDataType_U64, &varState))
{
mono_field_set_value(GetMonoComponent(), field, &varState);
}
}
else if (typeName == "char")
{
int temp;
mono_field_get_value(GetMonoComponent(), field, &temp);
char varState = (char)temp;
std::string stringToModify = std::string(1, varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputText(("##" + fieldName + std::to_string(UUID)).data(), &stringToModify))
{
MonoString* newString = mono_string_new(App->scripting->domain, stringToModify.data());
temp = (int)stringToModify[0];
mono_field_set_value(GetMonoComponent(), field, &temp);
}
}
else if (typeName == "string")
{
MonoString* varState;
mono_field_get_value(GetMonoComponent(), field, &varState);
if (!varState)
varState = mono_string_new(App->scripting->domain, "");
char* convertedString = mono_string_to_utf8(varState);
std::string stringToModify = convertedString;
ImGui::PushStyleColor(ImGuiCol_::ImGuiCol_FrameBg, { 0.26f, 0.59f, 0.98f, 0.5f });
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputText(("##" + fieldName + std::to_string(UUID)).data(), &stringToModify))
{
MonoString* newString = mono_string_new(App->scripting->domain, stringToModify.data());
mono_field_set_value(GetMonoComponent(), field, newString);
}
ImGui::PopStyleColor();
mono_free(convertedString);
}
else if (typeName == "JellyBitEngine.GameObject")
{
uint buttonWidth = 0.65 * ImGui::GetWindowWidth();
float varState; mono_field_get_value(GetMonoComponent(), field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
cursorPos = { cursorPos.x, cursorPos.y - 5 };
ImGui::ButtonEx(("##" + fieldName + std::to_string(UUID)).data(), { (float)buttonWidth, 20 }, ImGuiButtonFlags_::ImGuiButtonFlags_Disabled);
//Case 1: Dragging Real GameObjects
if (ImGui::BeginDragDropTarget())
{
const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("GAMEOBJECTS_HIERARCHY", ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoDrawDefaultRect);
if (payload)
{
GameObject* go = *(GameObject**)payload->Data;
if (ImGui::IsMouseReleased(0))
{
MonoObject* monoObject = App->scripting->MonoObjectFrom(go);
mono_field_set_value(GetMonoComponent(), field, monoObject);
}
}
ImGui::EndDragDropTarget();
}
//Case 2: Dragging Prefabs
if (ImGui::BeginDragDropTarget())
{
const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("PREFAB_RESOURCE", ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoDrawDefaultRect);
if (payload)
{
ResourcePrefab* prefab = *(ResourcePrefab**)payload->Data;
if (ImGui::IsMouseReleased(0))
{
MonoObject* oldObject;
mono_field_get_value(GetMonoComponent(), field, &oldObject);
if (oldObject != nullptr)
{
GameObject* oldGameObject = App->scripting->GameObjectFrom(oldObject);
if (oldGameObject)
{
if (oldGameObject->prefab)
{
App->res->SetAsUnused(oldGameObject->prefab->GetUuid());
}
}
}
App->res->SetAsUsed(prefab->GetUuid());
MonoObject* monoObject = App->scripting->MonoObjectFrom(prefab->GetRoot());
mono_field_set_value(GetMonoComponent(), field, monoObject);
}
}
ImGui::EndDragDropTarget();
}
if (ImGui::IsItemClicked(0))
{
ImDrawList* drawList = ImGui::GetWindowDrawList();
drawList->AddRectFilled(cursorPos, { cursorPos.x + buttonWidth, cursorPos.y + 20 }, ImGui::GetColorU32(ImGuiCol_::ImGuiCol_ButtonActive));
}
else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem))
{
ImDrawList* drawList = ImGui::GetWindowDrawList();
drawList->AddRectFilled(cursorPos, { cursorPos.x + buttonWidth, cursorPos.y + 20 }, ImGui::GetColorU32(ImGuiCol_::ImGuiCol_ButtonHovered));
if (App->input->GetKey(SDL_SCANCODE_BACKSPACE) == KEY_DOWN)
{
MonoObject* oldObject;
mono_field_get_value(GetMonoComponent(), field, &oldObject);
if (oldObject != nullptr)
{
GameObject* oldGameObject = App->scripting->GameObjectFrom(oldObject);
if (oldGameObject)
{
if (oldGameObject->prefab)
{
App->res->SetAsUnused(oldGameObject->prefab->GetUuid());
}
}
}
mono_field_set_value(GetMonoComponent(), field, NULL);
}
}
//Button text
MonoObject* monoObject;
mono_field_get_value(GetMonoComponent(), field, &monoObject);
std::string text;
if (monoObject)
{
bool destroyed;
mono_field_get_value(monoObject, mono_class_get_field_from_name(mono_object_get_class(monoObject), "destroyed"), &destroyed);
if (!destroyed)
{
GameObject* gameObject = App->scripting->GameObjectFrom(monoObject);
if (gameObject)
{
if (gameObject->prefab)
text = gameObject->GetName() + std::string(" (Prefab)");
else
text = gameObject->GetName() + std::string(" (GameObject)");
}
}
else
{
mono_field_set_value(GetMonoComponent(), field, NULL);
}
}
else
{
text = "NULL (GameObject)";
}
ImGui::SetCursorScreenPos({ cursorPos.x + 5, cursorPos.y + 3 });
ImGui::Text(text.data());
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 4 });
}
else if (typeName == "JellyBitEngine.Transform")
{
uint buttonWidth = 0.65 * ImGui::GetWindowWidth();
float varState; mono_field_get_value(GetMonoComponent(), field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
cursorPos = { cursorPos.x, cursorPos.y - 5 };
ImGui::ButtonEx(("##" + fieldName + std::to_string(UUID)).data(), { (float)buttonWidth, 20 }, ImGuiButtonFlags_::ImGuiButtonFlags_Disabled);
if (ImGui::BeginDragDropTarget())
{
const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("GAMEOBJECTS_HIERARCHY", ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoDrawDefaultRect);
if (payload)
{
GameObject* go = *(GameObject**)payload->Data;
if (ImGui::IsMouseReleased(0))
{
MonoObject* monoObject = App->scripting->MonoObjectFrom(go);
MonoObject* monoTransform;
mono_field_get_value(monoObject, mono_class_get_field_from_name(mono_object_get_class(monoObject), "transform"), &monoTransform);
mono_field_set_value(GetMonoComponent(), field, monoTransform);
}
}
ImGui::EndDragDropTarget();
}
if (ImGui::IsItemClicked(0))
{
ImDrawList* drawList = ImGui::GetWindowDrawList();
drawList->AddRectFilled(cursorPos, { cursorPos.x + buttonWidth, cursorPos.y + 20 }, ImGui::GetColorU32(ImGuiCol_::ImGuiCol_ButtonActive));
}
else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem))
{
ImDrawList* drawList = ImGui::GetWindowDrawList();
drawList->AddRectFilled(cursorPos, { cursorPos.x + buttonWidth, cursorPos.y + 20 }, ImGui::GetColorU32(ImGuiCol_::ImGuiCol_ButtonHovered));
if (App->input->GetKey(SDL_SCANCODE_BACKSPACE) == KEY_DOWN)
{
mono_field_set_value(GetMonoComponent(), field, NULL);
}
}
//Button text
MonoObject* monoTransform;
mono_field_get_value(GetMonoComponent(), field, &monoTransform);
MonoObject* monoObject;
if (monoTransform)
mono_field_get_value(monoTransform, mono_class_get_field_from_name(mono_object_get_class(monoTransform), "gameObject"), &monoObject);
std::string text;
if (monoTransform)
{
bool destroyed;
mono_field_get_value(monoObject, mono_class_get_field_from_name(mono_object_get_class(monoObject), "destroyed"), &destroyed);
if (!destroyed)
{
GameObject* gameObject = App->scripting->GameObjectFrom(monoObject);
text = gameObject->GetName() + std::string(" (Transform)");
}
else
{
mono_field_set_value(GetMonoComponent(), field, NULL);
}
}
else
{
text = "NULL (Transform)";
}
ImGui::SetCursorScreenPos({ cursorPos.x + 5, cursorPos.y + 3 });
ImGui::Text(text.data());
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 4 });
}
else if (typeName == "JellyBitEngine.LayerMask")
{
uint32_t bits;
mono_field_get_value(GetMonoComponent(), field, &bits);
std::string enabled;
uint totalLayers = 0u;
uint amountEnabled = 0u;
for (uint i = 0; i < MAX_NUM_LAYERS; ++i)
{
const char* layerName = App->layers->NumberToName(i);
if (strcmp(layerName, "") == 0)
continue;
totalLayers++;
enabled = (bits >> i) & 1U == 1 ? layerName : enabled;
amountEnabled += (bits >> i) & 1U == 1 ? 1 : 0;
}
const char* title = amountEnabled == 0 ? "None" : amountEnabled == 1 ? enabled.data() : totalLayers == amountEnabled ? "Everything" : "Multiple Selected";
ImGui::PushItemWidth(150.0f);
if (ImGui::BeginCombo((fieldName + "##" + std::to_string(UUID)).data(), title))
{
for (uint i = 0; i < MAX_NUM_LAYERS; ++i)
{
const char* layerName = App->layers->NumberToName(i);
if (strcmp(layerName, "") == 0)
continue;
if (ImGui::Selectable(layerName, (bits >> i) & 1U == 1 ? true : false, ImGuiSelectableFlags_::ImGuiSelectableFlags_DontClosePopups))
{
bits ^= 1UL << i;
mono_field_set_value(GetMonoComponent(), field, &bits);
}
}
ImGui::EndCombo();
}
ImGui::PopItemWidth();
}
else if (typeName == "JellyBitEngine.Vector3")
{
math::float3 varState;
mono_field_get_value(GetMonoComponent(), field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::DragFloat3(("##" + fieldName + std::to_string(UUID)).data(), varState.ptr()))
{
mono_field_set_value(GetMonoComponent(), field, &varState);
}
}
else if (mono_class_is_enum(mono_type_get_class(type)))
{
//A public enum
//Get the saved value, as int and as string
MonoClass* enumClass = mono_get_enum_class();
int32_t enumValue;
mono_field_get_value(GetMonoComponent(), field, &enumValue);
MonoObject* enumOBJ = mono_field_get_value_object(App->scripting->domain, field, GetMonoComponent());
MonoMethodDesc* ToStringDesc = mono_method_desc_new("Enum::ToString", false);
MonoMethod* ToStringMethod = mono_method_desc_search_in_class(ToStringDesc, enumClass);
mono_method_desc_free(ToStringDesc);
MonoObject* ret = mono_runtime_invoke(ToStringMethod, enumOBJ, NULL, NULL);
MonoString* monoString = mono_object_to_string(ret, NULL);
char* string = mono_string_to_utf8(monoString);
//Create the combo
if (ImGui::BeginCombo((fieldName + std::string("##") + std::to_string(UUID)).data(), string))
{
//ImGui::TextColored({ 1,0,0,1 }, "IN PROGRESS");
//Get the number of values this enum has
MonoMethodDesc* GetValuesDesc = mono_method_desc_new("Enum::GetValues", false);
MonoMethod* GetValuesMethod = mono_method_desc_search_in_class(GetValuesDesc, enumClass);
mono_method_desc_free(GetValuesDesc);
MonoMethodDesc* ParseDesc = mono_method_desc_new("Enum::Parse", false);
MonoMethod* ParseMethod = mono_method_desc_search_in_class(ParseDesc, enumClass);
mono_method_desc_free(ParseDesc);
MonoMethodDesc* GetTypeDesc = mono_method_desc_new("object::GetType", false);
MonoMethod* GetTypeMethod = mono_method_desc_search_in_class(GetTypeDesc, mono_get_object_class());
mono_method_desc_free(GetTypeDesc);
MonoObject* enumType = mono_runtime_invoke(GetTypeMethod, enumOBJ, NULL, NULL);
void* params[1];
params[0] = enumType;
MonoArray* values = (MonoArray*)mono_runtime_invoke(GetValuesMethod, NULL, params, NULL);
uint numValues = mono_array_length(values);
for (int i = 0; i < numValues; ++i)
{
void* nameParams[2];
nameParams[0] = enumType;
nameParams[1] = mono_string_new(App->scripting->domain, std::to_string(i).data());
MonoObject* stringOBJ = mono_runtime_invoke(ParseMethod, NULL, nameParams, NULL);
MonoString* stringCS = mono_object_to_string(stringOBJ, NULL);
char* stringcpp = mono_string_to_utf8(stringCS);
if (ImGui::Selectable(stringcpp))
{
mono_field_set_value(GetMonoComponent(), field, &i);
}
mono_free(stringcpp);
}
ImGui::EndCombo();
}
mono_free(string);
}
else if (mono_type_is_struct(type))
{
MonoObject* structOBJ = mono_field_get_value_object(App->scripting->domain, field, GetMonoComponent());
OnStructEditor(structOBJ, field);
mono_field_set_value(GetMonoComponent(), field, mono_object_unbox(structOBJ));
}
}
}
}
field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), (void**)&iterator);
}
ImGui::NewLine();
}
#endif
}
void ComponentScript::OnStructEditor(MonoObject* structOBJ, MonoClassField* structField)
{
#ifndef GAMEMODE
MonoClass* structClass = mono_object_get_class(structOBJ);
const char* name = mono_class_get_name(structClass);
std::string structFieldName = mono_field_get_name(structField);
if (ImGui::TreeNode((structFieldName + "##" + std::to_string(UUID)).data()))
{
void* iterator = 0;
MonoClassField* field = nullptr;
do
{
field = mono_class_get_fields(structClass, &iterator);
if (field)
{
MonoType* type = mono_field_get_type(field);
std::string fieldName = mono_field_get_name(field);
std::string typeName = mono_type_full_name(type);
MonoString* fieldNameCS = mono_string_new(App->scripting->domain, (char*)fieldName.data());
MonoReflectionType* myClassType = mono_type_get_object(App->scripting->domain, mono_class_get_type(structClass));
bool hidden = FieldHasHideInInspector(myClassType, fieldNameCS);
if (!hidden)
{
uint32_t flags = mono_field_get_flags(field);
if (!(flags & MONO_FIELD_ATTR_STATIC))
{
bool serialized = FieldHasSerializeField(myClassType, fieldNameCS);
if ((flags & MONO_FIELD_ATTR_PUBLIC) || serialized)
{
if (typeName == "bool")
{
bool varState; mono_field_get_value(structOBJ, field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::Checkbox(("##" + fieldName + std::to_string(UUID)).data(), &varState))
{
mono_field_set_value(structOBJ, field, &varState);
}
}
else if (typeName == "single") //this is a float, idk
{
float varState; mono_field_get_value(structOBJ, field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputFloat(("##" + fieldName + std::to_string(UUID)).data(), &varState))
{
mono_field_set_value(structOBJ, field, &varState);
}
}
else if (typeName == "double")
{
double varState;
mono_field_get_value(structOBJ, field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputDouble(("##" + fieldName + std::to_string(UUID)).data(), &varState))
{
mono_field_set_value(structOBJ, field, &varState);
}
}
else if (typeName == "System.Decimal")
{
//We cant convert System.Decimal, since we do not have this decimal precision in any C++ type.
}
else if (typeName == "sbyte")
{
int8_t varState;
mono_field_get_value(structOBJ, field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputScalar(("##" + fieldName + std::to_string(UUID)).data(), ImGuiDataType_::ImGuiDataType_S32, &varState))
{
mono_field_set_value(structOBJ, field, &varState);
}
}
else if (typeName == "byte")
{
uint8_t varState;
mono_field_get_value(structOBJ, field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputScalar(("##" + fieldName + std::to_string(UUID)).data(), ImGuiDataType_::ImGuiDataType_U32, &varState))
{
mono_field_set_value(structOBJ, field, &varState);
}
}
else if (typeName == "int16")
{
int16_t varState;
mono_field_get_value(structOBJ, field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputScalar(("##" + fieldName + std::to_string(UUID)).data(), ImGuiDataType_::ImGuiDataType_S32, &varState))
{
mono_field_set_value(structOBJ, field, &varState);
}
}
else if (typeName == "uint16")
{
uint16_t varState;
mono_field_get_value(structOBJ, field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputScalar(("##" + fieldName + std::to_string(UUID)).data(), ImGuiDataType_::ImGuiDataType_U32, &varState))
{
mono_field_set_value(structOBJ, field, &varState);
}
}
else if (typeName == "int")
{
int32_t varState;
mono_field_get_value(structOBJ, field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputScalar(("##" + fieldName + std::to_string(UUID)).data(), ImGuiDataType_::ImGuiDataType_S32, &varState))
{
mono_field_set_value(structOBJ, field, &varState);
}
}
else if (typeName == "uint")
{
uint32_t varState;
mono_field_get_value(structOBJ, field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputScalar(("##" + fieldName + std::to_string(UUID)).data(), ImGuiDataType_::ImGuiDataType_U32, &varState))
{
mono_field_set_value(structOBJ, field, &varState);
}
}
else if (typeName == "long")
{
int64_t varState;
mono_field_get_value(structOBJ, field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputScalar(("##" + fieldName + std::to_string(UUID)).data(), ImGuiDataType_::ImGuiDataType_S64, &varState))
{
mono_field_set_value(structOBJ, field, &varState);
}
}
else if (typeName == "ulong")
{
uint64_t varState;
mono_field_get_value(structOBJ, field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputScalar(("##" + fieldName + std::to_string(UUID)).data(), ImGuiDataType_::ImGuiDataType_U64, &varState))
{
mono_field_set_value(structOBJ, field, &varState);
}
}
else if (typeName == "char")
{
int temp;
mono_field_get_value(structOBJ, field, &temp);
char varState = (char)temp;
std::string stringToModify = std::string(1, varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputText(("##" + fieldName + std::to_string(UUID)).data(), &stringToModify))
{
MonoString* newString = mono_string_new(App->scripting->domain, stringToModify.data());
temp = (int)stringToModify[0];
mono_field_set_value(structOBJ, field, &temp);
}
}
else if (typeName == "string")
{
MonoString* varState = nullptr;
mono_field_get_value(structOBJ, field, &varState);
if (!varState)
varState = mono_string_new(App->scripting->domain, "");
char* convertedString = mono_string_to_utf8(varState);
std::string stringToModify = convertedString;
ImGui::PushStyleColor(ImGuiCol_::ImGuiCol_FrameBg, { 0.26f, 0.59f, 0.98f, 0.5f });
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::InputText(("##" + fieldName + std::to_string(UUID)).data(), &stringToModify))
{
MonoString* newString = mono_string_new(App->scripting->domain, stringToModify.data());
mono_field_set_value(structOBJ, field, newString);
}
ImGui::PopStyleColor();
mono_free(convertedString);
}
else if (typeName == "JellyBitEngine.Vector3")
{
math::float3 varState;
mono_field_get_value(structOBJ, field, &varState);
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y + 5 });
ImGui::Text(fieldName.data()); ImGui::SameLine();
cursorPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos({ cursorPos.x, cursorPos.y - 5 });
if (ImGui::DragFloat3(("##" + fieldName + std::to_string(UUID)).data(), varState.ptr()))
{
mono_field_set_value(structOBJ, field, &varState);
}
}
else if (typeName == "JellyBitEngine.LayerMask")
{
uint32_t bits;
mono_field_get_value(structOBJ, field, &bits);
std::string enabled;
uint totalLayers = 0u;
uint amountEnabled = 0u;
for (uint i = 0; i < MAX_NUM_LAYERS; ++i)
{
const char* layerName = App->layers->NumberToName(i);
if (strcmp(layerName, "") == 0)
continue;
totalLayers++;
enabled = (bits >> i) & 1U == 1 ? layerName : enabled;
amountEnabled += (bits >> i) & 1U == 1 ? 1 : 0;
}
const char* title = amountEnabled == 0 ? "None" : amountEnabled == 1 ? enabled.data() : totalLayers == amountEnabled ? "Everything" : "Multiple Selected";
ImGui::PushItemWidth(150.0f);
if (ImGui::BeginCombo((fieldName + "##" + std::to_string(UUID)).data(), title))
{
for (uint i = 0; i < MAX_NUM_LAYERS; ++i)
{
const char* layerName = App->layers->NumberToName(i);
if (strcmp(layerName, "") == 0)
continue;
if (ImGui::Selectable(layerName, (bits >> i) & 1U == 1 ? true : false, ImGuiSelectableFlags_::ImGuiSelectableFlags_DontClosePopups))
{
bits ^= 1UL << i;
mono_field_set_value(structOBJ, field, &bits);
}
}
ImGui::EndCombo();
}
ImGui::PopItemWidth();
}
else if (mono_class_is_enum(mono_type_get_class(type)))
{
//A public enum
//Get the saved value, as int and as string
MonoClass* enumClass = mono_get_enum_class();
int32_t enumValue;
mono_field_get_value(structOBJ, field, &enumValue);
MonoObject* enumOBJ = mono_field_get_value_object(App->scripting->domain, field, structOBJ);
MonoMethodDesc* ToStringDesc = mono_method_desc_new("Enum::ToString", false);
MonoMethod* ToStringMethod = mono_method_desc_search_in_class(ToStringDesc, enumClass);
mono_method_desc_free(ToStringDesc);
MonoObject* ret = mono_runtime_invoke(ToStringMethod, enumOBJ, NULL, NULL);
MonoString* monoString = mono_object_to_string(ret, NULL);
char* string = mono_string_to_utf8(monoString);
//Create the combo
if (ImGui::BeginCombo((fieldName + std::string("##") + std::to_string(UUID)).data(), string))
{
//ImGui::TextColored({ 1,0,0,1 }, "IN PROGRESS");
//Get the number of values this enum has
MonoMethodDesc* GetValuesDesc = mono_method_desc_new("Enum::GetValues", false);
MonoMethod* GetValuesMethod = mono_method_desc_search_in_class(GetValuesDesc, enumClass);
mono_method_desc_free(GetValuesDesc);
MonoMethodDesc* ParseDesc = mono_method_desc_new("Enum::Parse", false);
MonoMethod* ParseMethod = mono_method_desc_search_in_class(ParseDesc, enumClass);
mono_method_desc_free(ParseDesc);
MonoMethodDesc* GetTypeDesc = mono_method_desc_new("object::GetType", false);
MonoMethod* GetTypeMethod = mono_method_desc_search_in_class(GetTypeDesc, mono_get_object_class());
mono_method_desc_free(GetTypeDesc);
MonoObject* enumType = mono_runtime_invoke(GetTypeMethod, enumOBJ, NULL, NULL);
void* params[1];
params[0] = enumType;
MonoArray* values = (MonoArray*)mono_runtime_invoke(GetValuesMethod, NULL, params, NULL);
uint numValues = mono_array_length(values);
for (int i = 0; i < numValues; ++i)
{
void* nameParams[2];
nameParams[0] = enumType;
nameParams[1] = mono_string_new(App->scripting->domain, std::to_string(i).data());
MonoObject* stringOBJ = mono_runtime_invoke(ParseMethod, NULL, nameParams, NULL);
MonoString* stringCS = mono_object_to_string(stringOBJ, NULL);
char* stringcpp = mono_string_to_utf8(stringCS);
if (ImGui::Selectable(stringcpp))
{
mono_field_set_value(structOBJ, field, &i);
}
mono_free(stringcpp);
}
ImGui::EndCombo();
}
mono_free(string);
}
else if (mono_type_is_struct(type))
{
MonoObject* childOBJ = mono_field_get_value_object(App->scripting->domain, field, structOBJ);
OnStructEditor(childOBJ, field);
mono_field_set_value(structOBJ, field, mono_object_unbox(childOBJ));
}
}
}
}
}
} while (field);
ImGui::TreePop();
}
#endif
}
uint ComponentScript::GetInternalSerializationBytes()
{
//My resource uuid + public vars
return sizeof(uint32_t) + GetPublicVarsSerializationBytes();
}
void ComponentScript::OnInternalSave(char*& cursor)
{
uint bytes = sizeof(uint32_t);
uint32_t resUID = scriptResUUID;
memcpy(cursor, &resUID, bytes);
cursor += bytes;
SavePublicVars(cursor);
}
void ComponentScript::OnInternalLoad(char*& cursor)
{
uint bytes = sizeof(uint32_t);
memcpy(&scriptResUUID, cursor, bytes);
cursor += bytes;
ResourceScript* scriptRes = (ResourceScript*)App->res->GetResource(scriptResUUID);
if (scriptRes)
{
scriptName = scriptRes->scriptName;
App->res->SetAsUsed(scriptRes->GetUuid());
}
else
CONSOLE_LOG(LogTypes::Error, "A ComponentScript lost his ResourceScript reference!");
InstanceClass();
tempBufferBytes = ComponentScript::GetPublicVarsSerializationBytesFromBuffer(cursor);
tempBuffer = new char[tempBufferBytes];
memcpy(tempBuffer, cursor, tempBufferBytes);
cursor += tempBufferBytes;
}
uint ComponentScript::GetPublicVarsSerializationBytes() const
{
uint bytes = sizeof(uint);
void* iterator = 0;
if (!GetMonoComponent())
return 0;
MonoClassField* field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), &iterator);
while (field != nullptr)
{
uint32_t flags = mono_field_get_flags(field);
if (flags & MONO_FIELD_ATTR_PUBLIC && !(flags & MONO_FIELD_ATTR_STATIC))
{
MonoType* type = mono_field_get_type(field);
std::string typeName = mono_type_full_name(type);
std::string fieldName = mono_field_get_name(field);
VarType varType;
if (typeName == "bool")
{
varType = VarType::BOOL;
uint nameLenght = fieldName.length();
bytes += (sizeof(varType) + sizeof(uint) + nameLenght + sizeof(bool));
}
else if (typeName == "single")
{
varType = VarType::FLOAT;
uint nameLenght = fieldName.length();
bytes += (sizeof(varType) + sizeof(uint) + nameLenght + sizeof(float));
}
else if (typeName == "double")
{
varType = VarType::DOUBLE;
uint nameLenght = fieldName.length();
bytes += (sizeof(varType) + sizeof(uint) + nameLenght + sizeof(double));
}
else if (typeName == "sbyte")
{
varType = VarType::INT8;
uint nameLenght = fieldName.length();
bytes += (sizeof(varType) + sizeof(uint) + nameLenght + sizeof(int8_t));
}
else if (typeName == "byte")
{
varType = VarType::UINT8;
uint nameLenght = fieldName.length();
bytes += (sizeof(varType) + sizeof(uint) + nameLenght + sizeof(uint8_t));
}
else if (typeName == "int16")
{
varType = VarType::INT16;
uint nameLenght = fieldName.length();
bytes += (sizeof(varType) + sizeof(uint) + nameLenght + sizeof(int16_t));
}
else if (typeName == "uint16")
{
varType = VarType::UINT16;
uint nameLenght = fieldName.length();
bytes += (sizeof(varType) + sizeof(uint) + nameLenght + sizeof(uint16_t));
}
else if (typeName == "int")
{
varType = VarType::INT;
uint nameLenght = fieldName.length();
bytes += (sizeof(varType) + sizeof(uint) + nameLenght + sizeof(int));
}
else if (typeName == "uint")
{
varType = VarType::UINT;
uint nameLenght = fieldName.length();
bytes += (sizeof(varType) + sizeof(uint) + nameLenght + sizeof(uint));
}
else if (typeName == "long")
{
varType = VarType::INT64;
uint nameLenght = fieldName.length();
bytes += (sizeof(varType) + sizeof(uint) + nameLenght + sizeof(long));
}
else if (typeName == "ulong")
{
varType = VarType::UINT64;
uint nameLenght = fieldName.length();
bytes += (sizeof(varType) + sizeof(uint) + nameLenght + sizeof(uint64_t));
}
else if (typeName == "char")
{
varType = VarType::CHAR;
uint nameLenght = fieldName.length();
bytes += (sizeof(varType) + sizeof(uint) + nameLenght + sizeof(char));
}
else if (typeName == "string")
{
varType = VarType::STRING;
uint nameLenght = fieldName.length();
MonoString* varState; mono_field_get_value(GetMonoComponent(), field, &varState);
char* cString = mono_string_to_utf8(varState);
std::string defString(cString);
uint stringLenght = defString.size();
bytes += (sizeof(varType) + sizeof(uint) + nameLenght + sizeof(uint) + stringLenght);
mono_free(cString);
}
else if (typeName == "JellyBitEngine.GameObject")
{
varType = VarType::GAMEOBJECT;
uint nameLenght = fieldName.length();
bytes += (sizeof(varType) + sizeof(uint) + nameLenght + sizeof(uint32_t));
}
else if (typeName == "JellyBitEngine.Transform")
{
varType = VarType::TRANSFORM;
uint nameLenght = fieldName.length();
bytes += (sizeof(varType) + sizeof(uint) + nameLenght + sizeof(uint32_t));
}
else if (typeName == "JellyBitEngine.LayerMask")
{
varType = VarType::LAYERMASK;
uint nameLenght = fieldName.length();
bytes += (sizeof(varType) + sizeof(uint) + nameLenght + sizeof(uint32_t));
}
else if (mono_class_is_enum(mono_type_get_class(type)))
{
varType = VarType::ENUM;
uint nameLenght = fieldName.length();
bytes += (sizeof(varType) + sizeof(uint) + nameLenght + sizeof(uint32_t));
}
else if (mono_type_is_struct(type))
{
varType = VarType::STRUCT;
uint nameLenght = fieldName.length();
int alignment = 0;
int size = mono_type_size(type, &alignment);
bytes += (sizeof(varType) + sizeof(uint) + nameLenght + sizeof(uint) + size);
}
}
field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), (void**)&iterator);
}
return bytes;
}
uint ComponentScript::GetPublicVarsSerializationBytesFromBuffer(char* buffer) const
{
char* cursor = buffer;
uint totalSize = 0;
uint numVars = 0;
uint bytes = sizeof(uint);
memcpy(&numVars, cursor, bytes);
totalSize += bytes;
cursor += bytes;
for (int i = 0; i < numVars; i++)
{
//Load type
VarType varType;
uint bytes = sizeof(VarType);
memcpy(&varType, cursor, bytes);
totalSize += bytes;
cursor += bytes;
//Load lenght + string
bytes = sizeof(uint);
uint nameLenght;
memcpy(&nameLenght, cursor, bytes);
totalSize += bytes;
cursor += bytes;
bytes = nameLenght;
std::string varName;
varName.resize(nameLenght);
memcpy((void*)varName.c_str(), cursor, bytes);
totalSize += bytes;
varName.resize(nameLenght);
cursor += bytes;
//Load data
switch (varType)
{
case VarType::BOOL:
{
bytes = sizeof(bool);
bool var;
memcpy(&var, cursor, bytes);
totalSize += bytes;
cursor += bytes;
break;
}
case VarType::FLOAT:
{
bytes = sizeof(float);
float var;
memcpy(&var, cursor, bytes);
totalSize += bytes;
cursor += bytes;
void* iterator = 0;
break;
}
case VarType::DOUBLE:
{
bytes = sizeof(double);
double var;
memcpy(&var, cursor, bytes);
totalSize += bytes;
cursor += bytes;
break;
}
case VarType::INT8:
{
bytes = sizeof(signed char);
int8_t var;
memcpy(&var, cursor, bytes);
totalSize += bytes;
cursor += bytes;
break;
}
case VarType::UINT8:
{
bytes = sizeof(unsigned char);
uint8_t var;
memcpy(&var, cursor, bytes);
totalSize += bytes;
cursor += bytes;
break;
}
case VarType::INT16:
{
bytes = sizeof(short);
int16_t var;
memcpy(&var, cursor, bytes);
totalSize += bytes;
cursor += bytes;
break;
}
case VarType::UINT16:
{
bytes = sizeof(unsigned short);
uint16_t var;
memcpy(&var, cursor, bytes);
totalSize += bytes;
cursor += bytes;
break;
}
case VarType::INT:
{
bytes = sizeof(int);
int32_t var;
memcpy(&var, cursor, bytes);
totalSize += bytes;
cursor += bytes;
break;
}
case VarType::UINT:
{
bytes = sizeof(uint);
uint32_t var;
memcpy(&var, cursor, bytes);
totalSize += bytes;
cursor += bytes;
break;
}
case VarType::INT64:
{
bytes = sizeof(long long);
int64_t var;
memcpy(&var, cursor, bytes);
totalSize += bytes;
cursor += bytes;
break;
}
case VarType::UINT64:
{
bytes = sizeof(unsigned long long);
uint64_t var;
memcpy(&var, cursor, bytes);
totalSize += bytes;
cursor += bytes;
break;
}
case VarType::CHAR:
{
bytes = sizeof(char);
char var;
memcpy(&var, cursor, bytes);
totalSize += bytes;
cursor += bytes;
break;
}
case VarType::STRING:
{
bytes = sizeof(uint);
uint stringLength;
memcpy(&stringLength, cursor, bytes);
totalSize += bytes;
cursor += bytes;
bytes = stringLength;
std::string string;
string.resize(stringLength);
memcpy((void*)string.c_str(), cursor, bytes);
totalSize += bytes;
string.resize(stringLength);
cursor += bytes;
break;
}
case VarType::GAMEOBJECT:
{
bytes = sizeof(uint32_t);
uint32_t uid;
memcpy(&uid, cursor, bytes);
totalSize += bytes;
cursor += bytes;
break;
}
case VarType::TRANSFORM:
{
bytes = sizeof(uint32_t);
uint32_t uid;
memcpy(&uid, cursor, bytes);
totalSize += bytes;
cursor += bytes;
break;
}
case VarType::LAYERMASK:
{
//DeSerialize the var value
bytes = sizeof(uint32_t);
uint32_t var;
memcpy(&var, cursor, bytes);
totalSize += bytes;
cursor += bytes;
break;
}
case VarType::ENUM:
{
//DeSerialize the var value
bytes = sizeof(uint32_t);
uint32_t var;
memcpy(&var, cursor, bytes);
totalSize += bytes;
cursor += bytes;
break;
}
case VarType::STRUCT:
{
bytes = sizeof(uint32_t);
uint32_t size;
memcpy(&size, cursor, bytes);
totalSize += bytes + size;
cursor += bytes + size;
break;
}
default:
break;
}
}
return totalSize;
}
void ComponentScript::SavePublicVars(char*& cursor)
{
uint numVars = 0;
void* iterator = 0;
if (!GetMonoComponent())
return;
MonoClassField* field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), &iterator);
while (field != nullptr)
{
uint32_t flags = mono_field_get_flags(field);
MonoType* type = mono_field_get_type(field);
std::string typeName = mono_type_full_name(type);
MonoString* fieldNameCS = mono_string_new(App->scripting->domain, mono_field_get_name(field));
MonoReflectionType* myClassType = mono_type_get_object(App->scripting->domain, mono_class_get_type(mono_object_get_class(GetMonoComponent())));
bool hidden = FieldHasHideInInspector(myClassType, fieldNameCS);
if (!hidden)
{
uint32_t flags = mono_field_get_flags(field);
if (!(flags & MONO_FIELD_ATTR_STATIC))
{
bool serialized = FieldHasSerializeField(myClassType, fieldNameCS);
if ((flags & MONO_FIELD_ATTR_PUBLIC) || serialized)
{
if (typeName == "bool" ||
typeName == "single" ||
typeName == "double" ||
typeName == "sbyte" ||
typeName == "byte" ||
typeName == "int16" ||
typeName == "uint16" ||
typeName == "int" ||
typeName == "uint" ||
typeName == "long" ||
typeName == "ulong" ||
typeName == "char" ||
typeName == "string" ||
typeName == "JellyBitEngine.GameObject" ||
typeName == "JellyBitEngine.Transform" ||
typeName == "JellyBitEngine.LayerMask" ||
mono_class_is_enum(mono_type_get_class(type)) ||
mono_type_is_struct(type))
{
//Only count the serializable ones
numVars++;
}
}
}
}
field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), (void**)&iterator);
}
uint bytes = sizeof(uint);
memcpy(cursor, &numVars, bytes);
cursor += bytes;
iterator = 0;
field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), &iterator);
while (field != nullptr)
{
MonoString* fieldNameCS = mono_string_new(App->scripting->domain, mono_field_get_name(field));
MonoReflectionType* myClassType = mono_type_get_object(App->scripting->domain, mono_class_get_type(mono_object_get_class(GetMonoComponent())));
uint32_t flags = mono_field_get_flags(field);
bool hidden = FieldHasHideInInspector(myClassType, fieldNameCS);
if (!hidden)
{
uint32_t flags = mono_field_get_flags(field);
if (!(flags & MONO_FIELD_ATTR_STATIC))
{
bool serialized = FieldHasSerializeField(myClassType, fieldNameCS);
if ((flags & MONO_FIELD_ATTR_PUBLIC) || serialized)
{
MonoType* type = mono_field_get_type(field);
std::string typeName = mono_type_full_name(type);
std::string fieldName = mono_field_get_name(field);
VarType varType;
if (typeName == "bool")
{
varType = VarType::BOOL;
//Serialize the varType
bytes = sizeof(varType);
memcpy(cursor, &varType, bytes);
cursor += bytes;
//Serialize the varName (lenght + string)
bytes = sizeof(uint);
uint nameLenght = fieldName.length();
memcpy(cursor, &nameLenght, bytes);
cursor += bytes;
bytes = nameLenght;
memcpy(cursor, fieldName.c_str(), bytes);
cursor += bytes;
//Serialize the var value
bytes = sizeof(bool);
bool varState; mono_field_get_value(GetMonoComponent(), field, &varState);
memcpy(cursor, &varState, bytes);
cursor += bytes;
}
else if (typeName == "single")
{
varType = VarType::FLOAT;
//Serialize the varType
bytes = sizeof(varType);
memcpy(cursor, &varType, bytes);
cursor += bytes;
//Serialize the varName (lenght + string)
bytes = sizeof(uint);
uint nameLenght = fieldName.length();
memcpy(cursor, &nameLenght, bytes);
cursor += bytes;
bytes = nameLenght;
memcpy(cursor, fieldName.c_str(), bytes);
cursor += bytes;
//Serialize the var value
bytes = sizeof(float);
float varState; mono_field_get_value(GetMonoComponent(), field, &varState);
memcpy(cursor, &varState, bytes);
cursor += bytes;
}
else if (typeName == "double")
{
varType = VarType::DOUBLE;
//Serialize the varType
bytes = sizeof(varType);
memcpy(cursor, &varType, bytes);
cursor += bytes;
//Serialize the varName (lenght + string)
bytes = sizeof(uint);
uint nameLenght = fieldName.length();
memcpy(cursor, &nameLenght, bytes);
cursor += bytes;
bytes = nameLenght;
memcpy(cursor, fieldName.c_str(), bytes);
cursor += bytes;
//Serialize the var value
bytes = sizeof(double);
double varState; mono_field_get_value(GetMonoComponent(), field, &varState);
memcpy(cursor, &varState, bytes);
cursor += bytes;
}
else if (typeName == "sbyte")
{
varType = VarType::INT8;
//Serialize the varType
bytes = sizeof(varType);
memcpy(cursor, &varType, bytes);
cursor += bytes;
//Serialize the varName (lenght + string)
bytes = sizeof(uint);
uint nameLenght = fieldName.length();
memcpy(cursor, &nameLenght, bytes);
cursor += bytes;
bytes = nameLenght;
memcpy(cursor, fieldName.c_str(), bytes);
cursor += bytes;
//Serialize the var value
bytes = sizeof(int8_t);
int8_t varState; mono_field_get_value(GetMonoComponent(), field, &varState);
memcpy(cursor, &varState, bytes);
cursor += bytes;
}
else if (typeName == "byte")
{
varType = VarType::UINT8;
//Serialize the varType
bytes = sizeof(varType);
memcpy(cursor, &varType, bytes);
cursor += bytes;
//Serialize the varName (lenght + string)
bytes = sizeof(uint);
uint nameLenght = fieldName.length();
memcpy(cursor, &nameLenght, bytes);
cursor += bytes;
bytes = nameLenght;
memcpy(cursor, fieldName.c_str(), bytes);
cursor += bytes;
//Serialize the var value
bytes = sizeof(uint8_t);
uint8_t varState; mono_field_get_value(GetMonoComponent(), field, &varState);
memcpy(cursor, &varState, bytes);
cursor += bytes;
}
else if (typeName == "int16")
{
varType = VarType::INT16;
//Serialize the varType
bytes = sizeof(varType);
memcpy(cursor, &varType, bytes);
cursor += bytes;
//Serialize the varName (lenght + string)
bytes = sizeof(uint);
uint nameLenght = fieldName.length();
memcpy(cursor, &nameLenght, bytes);
cursor += bytes;
bytes = nameLenght;
memcpy(cursor, fieldName.c_str(), bytes);
cursor += bytes;
//Serialize the var value
bytes = sizeof(int16_t);
int16_t varState; mono_field_get_value(GetMonoComponent(), field, &varState);
memcpy(cursor, &varState, bytes);
cursor += bytes;
}
else if (typeName == "uint16")
{
varType = VarType::UINT16;
//Serialize the varType
bytes = sizeof(varType);
memcpy(cursor, &varType, bytes);
cursor += bytes;
//Serialize the varName (lenght + string)
bytes = sizeof(uint);
uint nameLenght = fieldName.length();
memcpy(cursor, &nameLenght, bytes);
cursor += bytes;
bytes = nameLenght;
memcpy(cursor, fieldName.c_str(), bytes);
cursor += bytes;
//Serialize the var value
bytes = sizeof(uint16_t);
uint16_t varState; mono_field_get_value(GetMonoComponent(), field, &varState);
memcpy(cursor, &varState, bytes);
cursor += bytes;
}
else if (typeName == "int")
{
varType = VarType::INT;
//Serialize the varType
bytes = sizeof(varType);
memcpy(cursor, &varType, bytes);
cursor += bytes;
//Serialize the varName (lenght + string)
bytes = sizeof(uint);
uint nameLenght = fieldName.length();
memcpy(cursor, &nameLenght, bytes);
cursor += bytes;
bytes = nameLenght;
memcpy(cursor, fieldName.c_str(), bytes);
cursor += bytes;
//Serialize the var value
bytes = sizeof(int32_t);
int32_t varState; mono_field_get_value(GetMonoComponent(), field, &varState);
memcpy(cursor, &varState, bytes);
cursor += bytes;
}
else if (typeName == "uint")
{
varType = VarType::UINT;
//Serialize the varType
bytes = sizeof(varType);
memcpy(cursor, &varType, bytes);
cursor += bytes;
//Serialize the varName (lenght + string)
bytes = sizeof(uint);
uint nameLenght = fieldName.length();
memcpy(cursor, &nameLenght, bytes);
cursor += bytes;
bytes = nameLenght;
memcpy(cursor, fieldName.c_str(), bytes);
cursor += bytes;
//Serialize the var value
bytes = sizeof(uint32_t);
uint32_t varState; mono_field_get_value(GetMonoComponent(), field, &varState);
memcpy(cursor, &varState, bytes);
cursor += bytes;
}
else if (typeName == "long")
{
varType = VarType::INT64;
//Serialize the varType
bytes = sizeof(varType);
memcpy(cursor, &varType, bytes);
cursor += bytes;
//Serialize the varName (lenght + string)
bytes = sizeof(uint);
uint nameLenght = fieldName.length();
memcpy(cursor, &nameLenght, bytes);
cursor += bytes;
bytes = nameLenght;
memcpy(cursor, fieldName.c_str(), bytes);
cursor += bytes;
//Serialize the var value
bytes = sizeof(int64_t);
int64_t varState; mono_field_get_value(GetMonoComponent(), field, &varState);
memcpy(cursor, &varState, bytes);
cursor += bytes;
}
else if (typeName == "ulong")
{
varType = VarType::UINT64;
//Serialize the varType
bytes = sizeof(varType);
memcpy(cursor, &varType, bytes);
cursor += bytes;
//Serialize the varName (lenght + string)
bytes = sizeof(uint);
uint nameLenght = fieldName.length();
memcpy(cursor, &nameLenght, bytes);
cursor += bytes;
bytes = nameLenght;
memcpy(cursor, fieldName.c_str(), bytes);
cursor += bytes;
//Serialize the var value
bytes = sizeof(uint64_t);
uint64_t varState; mono_field_get_value(GetMonoComponent(), field, &varState);
memcpy(cursor, &varState, bytes);
cursor += bytes;
}
else if (typeName == "char")
{
varType = VarType::CHAR;
//Serialize the varType
bytes = sizeof(varType);
memcpy(cursor, &varType, bytes);
cursor += bytes;
//Serialize the varName (lenght + string)
bytes = sizeof(uint);
uint nameLenght = fieldName.length();
memcpy(cursor, &nameLenght, bytes);
cursor += bytes;
bytes = nameLenght;
memcpy(cursor, fieldName.c_str(), bytes);
cursor += bytes;
//Serialize the var value
bytes = sizeof(char);
char varState; mono_field_get_value(GetMonoComponent(), field, &varState);
memcpy(cursor, &varState, bytes);
cursor += bytes;
}
else if (typeName == "string")
{
varType = VarType::STRING;
//Serialize the varType
bytes = sizeof(varType);
memcpy(cursor, &varType, bytes);
cursor += bytes;
//Serialize the varName (lenght + string)
bytes = sizeof(uint);
uint nameLenght = fieldName.length();
memcpy(cursor, &nameLenght, bytes);
cursor += bytes;
bytes = nameLenght;
memcpy(cursor, fieldName.c_str(), bytes);
cursor += bytes;
//Serialize the var value
MonoString* varState; mono_field_get_value(GetMonoComponent(), field, &varState);
char* cString = mono_string_to_utf8(varState);
std::string defString(cString);
bytes = sizeof(uint);
uint stringLenght = defString.size();
memcpy(cursor, &stringLenght, bytes);
cursor += bytes;
bytes = stringLenght;
memcpy(cursor, defString.c_str(), bytes);
cursor += bytes;
mono_free(cString);
}
else if (typeName == "JellyBitEngine.GameObject")
{
varType = VarType::GAMEOBJECT;
MonoObject* monoObject; mono_field_get_value(GetMonoComponent(), field, &monoObject);
GameObject* serializableGO = monoObject ? App->scripting->GameObjectFrom(monoObject) : nullptr;
//Serialize the varType
bytes = sizeof(varType);
memcpy(cursor, &varType, bytes);
cursor += bytes;
//Serialize the varName (lenght + string)
bytes = sizeof(uint);
uint nameLenght = fieldName.length();
memcpy(cursor, &nameLenght, bytes);
cursor += bytes;
bytes = nameLenght;
memcpy(cursor, fieldName.c_str(), bytes);
cursor += bytes;
//Here save the UID of the gameObject you have referenced
uint32_t uid = serializableGO ? serializableGO->GetUUID() : 0;
bytes = sizeof(uint32_t);
memcpy(cursor, &uid, bytes);
cursor += bytes;
}
else if (typeName == "JellyBitEngine.Transform")
{
varType = VarType::TRANSFORM;
MonoObject* transformObj; mono_field_get_value(GetMonoComponent(), field, &transformObj);
MonoObject* monoObject;
transformObj ? mono_field_get_value(transformObj, mono_class_get_field_from_name(mono_object_get_class(transformObj), "gameObject"), &monoObject) : monoObject = nullptr;
GameObject* serializableGO = monoObject ? App->scripting->GameObjectFrom(monoObject) : nullptr;
//Serialize the varType
bytes = sizeof(varType);
memcpy(cursor, &varType, bytes);
cursor += bytes;
//Serialize the varName (lenght + string)
bytes = sizeof(uint);
uint nameLenght = fieldName.length();
memcpy(cursor, &nameLenght, bytes);
cursor += bytes;
bytes = nameLenght;
memcpy(cursor, fieldName.c_str(), bytes);
cursor += bytes;
//Here save the UID of the transform->gameObject you have referenced
uint32_t uid = serializableGO ? serializableGO->GetUUID() : 0;
bytes = sizeof(uint32_t);
memcpy(cursor, &uid, bytes);
cursor += bytes;
}
else if (typeName == "JellyBitEngine.LayerMask")
{
varType = VarType::LAYERMASK;
//Serialize the varType
bytes = sizeof(varType);
memcpy(cursor, &varType, bytes);
cursor += bytes;
//Serialize the varName (length + string)
bytes = sizeof(uint);
uint nameLenght = fieldName.length();
memcpy(cursor, &nameLenght, bytes);
cursor += bytes;
bytes = nameLenght;
memcpy(cursor, fieldName.c_str(), bytes);
cursor += bytes;
//Serialize the var value
uint32_t varState = 0;
mono_field_get_value(GetMonoComponent(), field, &varState);
bytes = sizeof(uint32_t);
memcpy(cursor, &varState, bytes);
cursor += bytes;
}
else if (mono_class_is_enum(mono_type_get_class(type)))
{
varType = VarType::ENUM;
//Serialize the varType
bytes = sizeof(varType);
memcpy(cursor, &varType, bytes);
cursor += bytes;
//Serialize the varName (length + string)
bytes = sizeof(uint);
uint nameLenght = fieldName.length();
memcpy(cursor, &nameLenght, bytes);
cursor += bytes;
bytes = nameLenght;
memcpy(cursor, fieldName.c_str(), bytes);
cursor += bytes;
//Serialize the var value
int32_t value;
mono_field_get_value(GetMonoComponent(), field, &value);
bytes = sizeof(uint32_t);
memcpy(cursor, &value, bytes);
cursor += bytes;
}
else if (mono_type_is_struct(type))
{
varType = VarType::STRUCT;
//Serialize the varType
bytes = sizeof(varType);
memcpy(cursor, &varType, bytes);
cursor += bytes;
//Serialize the varName (length + string)
bytes = sizeof(uint);
uint nameLenght = fieldName.length();
memcpy(cursor, &nameLenght, bytes);
cursor += bytes;
bytes = nameLenght;
memcpy(cursor, fieldName.c_str(), bytes);
cursor += bytes;
//Serialize the var value
int alignment = 0;
uint size = mono_type_size(type, &alignment);
bytes = sizeof(uint);
memcpy(cursor, &size, bytes);
cursor += bytes;
char* value = new char[size];
mono_field_get_value(GetMonoComponent(), field, value);
bytes = size;
memcpy(cursor, value, bytes);
cursor += bytes;
}
}
}
}
field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), (void**)&iterator);
}
}
void ComponentScript::LoadPublicVars(char*& buffer)
{
char* cursor = buffer;
if (!GetMonoComponent())
return;
uint numVars = 0;
uint bytes = sizeof(uint);
memcpy(&numVars, cursor, bytes);
cursor += bytes;
for (int i = 0; i < numVars; i++)
{
//Load type
VarType varType;
uint bytes = sizeof(VarType);
memcpy(&varType, cursor, bytes);
cursor += bytes;
//Load lenght + string
bytes = sizeof(uint);
uint nameLenght;
memcpy(&nameLenght, cursor, bytes);
cursor += bytes;
bytes = nameLenght;
std::string varName;
varName.resize(nameLenght);
memcpy((void*)varName.c_str(), cursor, bytes);
varName.resize(nameLenght);
cursor += bytes;
//Load data
switch (varType)
{
case VarType::BOOL:
{
bytes = sizeof(bool);
bool var;
memcpy(&var, cursor, bytes);
cursor += bytes;
void* iterator = 0;
MonoClassField* field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), &iterator);
while (field != nullptr)
{
uint32_t flags = mono_field_get_flags(field);
MonoString* fieldNameCS = mono_string_new(App->scripting->domain, mono_field_get_name(field));
MonoReflectionType* myClassType = mono_type_get_object(App->scripting->domain, mono_class_get_type(mono_object_get_class(GetMonoComponent())));
bool hidden = FieldHasHideInInspector(myClassType, fieldNameCS);
if (!hidden)
{
uint32_t flags = mono_field_get_flags(field);
if (!(flags & MONO_FIELD_ATTR_STATIC))
{
bool serialized = FieldHasSerializeField(myClassType, fieldNameCS);
if ((flags & MONO_FIELD_ATTR_PUBLIC) || serialized)
{
MonoType* type = mono_field_get_type(field);
std::string typeName = mono_type_full_name(type);
std::string fieldName = mono_field_get_name(field);
if (typeName == "bool" && fieldName == varName)
{
mono_field_set_value(GetMonoComponent(), field, &var);
break;
}
}
}
}
field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), (void**)&iterator);
}
break;
}
case VarType::FLOAT:
{
bytes = sizeof(float);
float var;
memcpy(&var, cursor, bytes);
cursor += bytes;
void* iterator = 0;
MonoClassField* field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), &iterator);
while (field != nullptr)
{
uint32_t flags = mono_field_get_flags(field);
MonoString* fieldNameCS = mono_string_new(App->scripting->domain, mono_field_get_name(field));
MonoReflectionType* myClassType = mono_type_get_object(App->scripting->domain, mono_class_get_type(mono_object_get_class(GetMonoComponent())));
bool hidden = FieldHasHideInInspector(myClassType, fieldNameCS);
if (!hidden)
{
uint32_t flags = mono_field_get_flags(field);
if (!(flags & MONO_FIELD_ATTR_STATIC))
{
bool serialized = FieldHasSerializeField(myClassType, fieldNameCS);
if ((flags & MONO_FIELD_ATTR_PUBLIC) || serialized)
{
MonoType* type = mono_field_get_type(field);
std::string typeName = mono_type_full_name(type);
std::string fieldName = mono_field_get_name(field);
if (typeName == "single" && fieldName == varName)
{
mono_field_set_value(GetMonoComponent(), field, &var);
break;
}
}
}
}
field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), (void**)&iterator);
}
break;
}
case VarType::DOUBLE:
{
bytes = sizeof(double);
double var;
memcpy(&var, cursor, bytes);
cursor += bytes;
void* iterator = 0;
MonoClassField* field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), &iterator);
while (field != nullptr)
{
uint32_t flags = mono_field_get_flags(field);
MonoString* fieldNameCS = mono_string_new(App->scripting->domain, mono_field_get_name(field));
MonoReflectionType* myClassType = mono_type_get_object(App->scripting->domain, mono_class_get_type(mono_object_get_class(GetMonoComponent())));
bool hidden = FieldHasHideInInspector(myClassType, fieldNameCS);
if (!hidden)
{
uint32_t flags = mono_field_get_flags(field);
if (!(flags & MONO_FIELD_ATTR_STATIC))
{
bool serialized = FieldHasSerializeField(myClassType, fieldNameCS);
if ((flags & MONO_FIELD_ATTR_PUBLIC) || serialized)
{
MonoType* type = mono_field_get_type(field);
std::string typeName = mono_type_full_name(type);
std::string fieldName = mono_field_get_name(field);
if (typeName == "double" && fieldName == varName)
{
mono_field_set_value(GetMonoComponent(), field, &var);
break;
}
}
}
}
field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), (void**)&iterator);
}
break;
}
case VarType::INT8:
{
bytes = sizeof(int8_t);
int8_t var;
memcpy(&var, cursor, bytes);
cursor += bytes;
void* iterator = 0;
MonoClassField* field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), &iterator);
while (field != nullptr)
{
uint32_t flags = mono_field_get_flags(field);
MonoString* fieldNameCS = mono_string_new(App->scripting->domain, mono_field_get_name(field));
MonoReflectionType* myClassType = mono_type_get_object(App->scripting->domain, mono_class_get_type(mono_object_get_class(GetMonoComponent())));
bool hidden = FieldHasHideInInspector(myClassType, fieldNameCS);
if (!hidden)
{
uint32_t flags = mono_field_get_flags(field);
if (!(flags & MONO_FIELD_ATTR_STATIC))
{
bool serialized = FieldHasSerializeField(myClassType, fieldNameCS);
if ((flags & MONO_FIELD_ATTR_PUBLIC) || serialized)
{
MonoType* type = mono_field_get_type(field);
std::string typeName = mono_type_full_name(type);
std::string fieldName = mono_field_get_name(field);
if (typeName == "sbyte" && fieldName == varName)
{
mono_field_set_value(GetMonoComponent(), field, &var);
break;
}
}
}
}
field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), (void**)&iterator);
}
break;
}
case VarType::UINT8:
{
bytes = sizeof(uint8_t);
uint8_t var;
memcpy(&var, cursor, bytes);
cursor += bytes;
void* iterator = 0;
MonoClassField* field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), &iterator);
while (field != nullptr)
{
uint32_t flags = mono_field_get_flags(field);
MonoString* fieldNameCS = mono_string_new(App->scripting->domain, mono_field_get_name(field));
MonoReflectionType* myClassType = mono_type_get_object(App->scripting->domain, mono_class_get_type(mono_object_get_class(GetMonoComponent())));
bool hidden = FieldHasHideInInspector(myClassType, fieldNameCS);
if (!hidden)
{
uint32_t flags = mono_field_get_flags(field);
if (!(flags & MONO_FIELD_ATTR_STATIC))
{
bool serialized = FieldHasSerializeField(myClassType, fieldNameCS);
if ((flags & MONO_FIELD_ATTR_PUBLIC) || serialized)
{
MonoType* type = mono_field_get_type(field);
std::string typeName = mono_type_full_name(type);
std::string fieldName = mono_field_get_name(field);
if (typeName == "byte" && fieldName == varName)
{
mono_field_set_value(GetMonoComponent(), field, &var);
break;
}
}
}
}
field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), (void**)&iterator);
}
break;
}
case VarType::INT16:
{
bytes = sizeof(int16_t);
int16_t var;
memcpy(&var, cursor, bytes);
cursor += bytes;
void* iterator = 0;
MonoClassField* field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), &iterator);
while (field != nullptr)
{
uint32_t flags = mono_field_get_flags(field);
MonoString* fieldNameCS = mono_string_new(App->scripting->domain, mono_field_get_name(field));
MonoReflectionType* myClassType = mono_type_get_object(App->scripting->domain, mono_class_get_type(mono_object_get_class(GetMonoComponent())));
bool hidden = FieldHasHideInInspector(myClassType, fieldNameCS);
if (!hidden)
{
uint32_t flags = mono_field_get_flags(field);
if (!(flags & MONO_FIELD_ATTR_STATIC))
{
bool serialized = FieldHasSerializeField(myClassType, fieldNameCS);
if ((flags & MONO_FIELD_ATTR_PUBLIC) || serialized)
{
MonoType* type = mono_field_get_type(field);
std::string typeName = mono_type_full_name(type);
std::string fieldName = mono_field_get_name(field);
if (typeName == "int16" && fieldName == varName)
{
mono_field_set_value(GetMonoComponent(), field, &var);
break;
}
}
}
}
field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), (void**)&iterator);
}
break;
}
case VarType::UINT16:
{
bytes = sizeof(uint16_t);
uint16_t var;
memcpy(&var, cursor, bytes);
cursor += bytes;
void* iterator = 0;
MonoClassField* field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), &iterator);
while (field != nullptr)
{
uint32_t flags = mono_field_get_flags(field);
MonoString* fieldNameCS = mono_string_new(App->scripting->domain, mono_field_get_name(field));
MonoReflectionType* myClassType = mono_type_get_object(App->scripting->domain, mono_class_get_type(mono_object_get_class(GetMonoComponent())));
bool hidden = FieldHasHideInInspector(myClassType, fieldNameCS);
if (!hidden)
{
uint32_t flags = mono_field_get_flags(field);
if (!(flags & MONO_FIELD_ATTR_STATIC))
{
bool serialized = FieldHasSerializeField(myClassType, fieldNameCS);
if ((flags & MONO_FIELD_ATTR_PUBLIC) || serialized)
{
MonoType* type = mono_field_get_type(field);
std::string typeName = mono_type_full_name(type);
std::string fieldName = mono_field_get_name(field);
if (typeName == "uint16" && fieldName == varName)
{
mono_field_set_value(GetMonoComponent(), field, &var);
break;
}
}
}
}
field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), (void**)&iterator);
}
break;
}
case VarType::INT:
{
bytes = sizeof(int32_t);
int32_t var;
memcpy(&var, cursor, bytes);
cursor += bytes;
void* iterator = 0;
MonoClassField* field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), &iterator);
while (field != nullptr)
{
uint32_t flags = mono_field_get_flags(field);
MonoString* fieldNameCS = mono_string_new(App->scripting->domain, mono_field_get_name(field));
MonoReflectionType* myClassType = mono_type_get_object(App->scripting->domain, mono_class_get_type(mono_object_get_class(GetMonoComponent())));
bool hidden = FieldHasHideInInspector(myClassType, fieldNameCS);
if (!hidden)
{
uint32_t flags = mono_field_get_flags(field);
if (!(flags & MONO_FIELD_ATTR_STATIC))
{
bool serialized = FieldHasSerializeField(myClassType, fieldNameCS);
if ((flags & MONO_FIELD_ATTR_PUBLIC) || serialized)
{
MonoType* type = mono_field_get_type(field);
std::string typeName = mono_type_full_name(type);
std::string fieldName = mono_field_get_name(field);
if (typeName == "int" && fieldName == varName)
{
mono_field_set_value(GetMonoComponent(), field, &var);
break;
}
}
}
}
field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), (void**)&iterator);
}
break;
}
case VarType::UINT:
{
bytes = sizeof(uint32_t);
uint32_t var;
memcpy(&var, cursor, bytes);
cursor += bytes;
void* iterator = 0;
MonoClassField* field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), &iterator);
while (field != nullptr)
{
uint32_t flags = mono_field_get_flags(field);
MonoString* fieldNameCS = mono_string_new(App->scripting->domain, mono_field_get_name(field));
MonoReflectionType* myClassType = mono_type_get_object(App->scripting->domain, mono_class_get_type(mono_object_get_class(GetMonoComponent())));
bool hidden = FieldHasHideInInspector(myClassType, fieldNameCS);
if (!hidden)
{
uint32_t flags = mono_field_get_flags(field);
if (!(flags & MONO_FIELD_ATTR_STATIC))
{
bool serialized = FieldHasSerializeField(myClassType, fieldNameCS);
if ((flags & MONO_FIELD_ATTR_PUBLIC) || serialized)
{
MonoType* type = mono_field_get_type(field);
std::string typeName = mono_type_full_name(type);
std::string fieldName = mono_field_get_name(field);
if (typeName == "uint" && fieldName == varName)
{
mono_field_set_value(GetMonoComponent(), field, &var);
break;
}
}
}
}
field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), (void**)&iterator);
}
break;
}
case VarType::INT64:
{
bytes = sizeof(int64_t);
int64_t var;
memcpy(&var, cursor, bytes);
cursor += bytes;
void* iterator = 0;
MonoClassField* field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), &iterator);
while (field != nullptr)
{
uint32_t flags = mono_field_get_flags(field);
MonoString* fieldNameCS = mono_string_new(App->scripting->domain, mono_field_get_name(field));
MonoReflectionType* myClassType = mono_type_get_object(App->scripting->domain, mono_class_get_type(mono_object_get_class(GetMonoComponent())));
bool hidden = FieldHasHideInInspector(myClassType, fieldNameCS);
if (!hidden)
{
uint32_t flags = mono_field_get_flags(field);
if (!(flags & MONO_FIELD_ATTR_STATIC))
{
bool serialized = FieldHasSerializeField(myClassType, fieldNameCS);
if ((flags & MONO_FIELD_ATTR_PUBLIC) || serialized)
{
MonoType* type = mono_field_get_type(field);
std::string typeName = mono_type_full_name(type);
std::string fieldName = mono_field_get_name(field);
if (typeName == "long" && fieldName == varName)
{
mono_field_set_value(GetMonoComponent(), field, &var);
break;
}
}
}
}
field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), (void**)&iterator);
}
break;
}
case VarType::UINT64:
{
bytes = sizeof(uint64_t);
uint64_t var;
memcpy(&var, cursor, bytes);
cursor += bytes;
void* iterator = 0;
MonoClassField* field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), &iterator);
while (field != nullptr)
{
uint32_t flags = mono_field_get_flags(field);
MonoString* fieldNameCS = mono_string_new(App->scripting->domain, mono_field_get_name(field));
MonoReflectionType* myClassType = mono_type_get_object(App->scripting->domain, mono_class_get_type(mono_object_get_class(GetMonoComponent())));
bool hidden = FieldHasHideInInspector(myClassType, fieldNameCS);
if (!hidden)
{
uint32_t flags = mono_field_get_flags(field);
if (!(flags & MONO_FIELD_ATTR_STATIC))
{
bool serialized = FieldHasSerializeField(myClassType, fieldNameCS);
if ((flags & MONO_FIELD_ATTR_PUBLIC) || serialized)
{
MonoType* type = mono_field_get_type(field);
std::string typeName = mono_type_full_name(type);
std::string fieldName = mono_field_get_name(field);
if (typeName == "ulong" && fieldName == varName)
{
mono_field_set_value(GetMonoComponent(), field, &var);
break;
}
}
}
}
field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), (void**)&iterator);
}
break;
}
case VarType::CHAR:
{
bytes = sizeof(char);
char var;
memcpy(&var, cursor, bytes);
cursor += bytes;
void* iterator = 0;
MonoClassField* field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), &iterator);
while (field != nullptr)
{
uint32_t flags = mono_field_get_flags(field);
MonoString* fieldNameCS = mono_string_new(App->scripting->domain, mono_field_get_name(field));
MonoReflectionType* myClassType = mono_type_get_object(App->scripting->domain, mono_class_get_type(mono_object_get_class(GetMonoComponent())));
bool hidden = FieldHasHideInInspector(myClassType, fieldNameCS);
if (!hidden)
{
uint32_t flags = mono_field_get_flags(field);
if (!(flags & MONO_FIELD_ATTR_STATIC))
{
bool serialized = FieldHasSerializeField(myClassType, fieldNameCS);
if ((flags & MONO_FIELD_ATTR_PUBLIC) || serialized)
{
MonoType* type = mono_field_get_type(field);
std::string typeName = mono_type_full_name(type);
std::string fieldName = mono_field_get_name(field);
if (typeName == "char" && fieldName == varName)
{
mono_field_set_value(GetMonoComponent(), field, &var);
break;
}
}
}
}
field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), (void**)&iterator);
}
break;
}
case VarType::STRING:
{
bytes = sizeof(uint);
uint stringLength;
memcpy(&stringLength, cursor, bytes);
cursor += bytes;
bytes = stringLength;
std::string string;
string.resize(stringLength);
memcpy((void*)string.c_str(), cursor, bytes);
string.resize(stringLength); //TODO: Check if names are deSerializing well with this resize
cursor += bytes;
void* iterator = 0;
MonoClassField* field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), &iterator);
while (field != nullptr)
{
uint32_t flags = mono_field_get_flags(field);
MonoString* fieldNameCS = mono_string_new(App->scripting->domain, mono_field_get_name(field));
MonoReflectionType* myClassType = mono_type_get_object(App->scripting->domain, mono_class_get_type(mono_object_get_class(GetMonoComponent())));
bool hidden = FieldHasHideInInspector(myClassType, fieldNameCS);
if (!hidden)
{
uint32_t flags = mono_field_get_flags(field);
if (!(flags & MONO_FIELD_ATTR_STATIC))
{
bool serialized = FieldHasSerializeField(myClassType, fieldNameCS);
if ((flags & MONO_FIELD_ATTR_PUBLIC) || serialized)
{
MonoType* type = mono_field_get_type(field);
std::string typeName = mono_type_full_name(type);
std::string fieldName = mono_field_get_name(field);
if (typeName == "string" && fieldName == varName)
{
MonoString* monoString = mono_string_new(App->scripting->domain, string.c_str());
mono_field_set_value(GetMonoComponent(), field, monoString);
break;
}
}
}
}
field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), (void**)&iterator);
}
break;
}
case VarType::GAMEOBJECT:
{
bytes = sizeof(uint32_t);
uint32_t uid;
memcpy(&uid, cursor, bytes);
cursor += bytes;
GameObject* go = nullptr;
if (uid != 0)
{
ResourcePrefab* prefab = (ResourcePrefab*)App->res->GetResource(uid);
if (!prefab)
{
go = App->GOs->GetGameObjectByUID(uid);
if (!go)
{
CONSOLE_LOG(LogTypes::Error, "A Script lost a Gameobject reference");
}
}
else
{
prefab->IncreaseReferences();
go = prefab->GetRoot();
}
}
MonoObject* monoObject = go ? App->scripting->MonoObjectFrom(go) : nullptr;
void* iterator = 0;
MonoClassField* field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), &iterator);
while (field != nullptr)
{
uint32_t flags = mono_field_get_flags(field);
MonoString* fieldNameCS = mono_string_new(App->scripting->domain, mono_field_get_name(field));
MonoReflectionType* myClassType = mono_type_get_object(App->scripting->domain, mono_class_get_type(mono_object_get_class(GetMonoComponent())));
bool hidden = FieldHasHideInInspector(myClassType, fieldNameCS);
if (!hidden)
{
uint32_t flags = mono_field_get_flags(field);
if (!(flags & MONO_FIELD_ATTR_STATIC))
{
bool serialized = FieldHasSerializeField(myClassType, fieldNameCS);
if ((flags & MONO_FIELD_ATTR_PUBLIC) || serialized)
{
MonoType* type = mono_field_get_type(field);
std::string typeName = mono_type_full_name(type);
std::string fieldName = mono_field_get_name(field);
if (typeName == "JellyBitEngine.GameObject" && fieldName == varName)
{
mono_field_set_value(GetMonoComponent(), field, monoObject);
break;
}
}
}
}
field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), (void**)&iterator);
}
break;
}
case VarType::TRANSFORM:
{
bytes = sizeof(uint32_t);
uint32_t uid;
memcpy(&uid, cursor, bytes);
cursor += bytes;
GameObject* go = nullptr;
if (uid != 0)
{
ResourcePrefab* prefab = (ResourcePrefab*)App->res->GetResource(uid);
if (!prefab)
{
go = App->GOs->GetGameObjectByUID(uid);
if (!go)
{
CONSOLE_LOG(LogTypes::Error, "A Script lost a Transform reference");
}
}
else
{
App->res->SetAsUsed(uid);
go = prefab->GetRoot();
}
}
MonoObject* monoObject = go ? App->scripting->MonoObjectFrom(go) : nullptr;
void* iterator = 0;
MonoClassField* field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), &iterator);
while (field != nullptr)
{
uint32_t flags = mono_field_get_flags(field);
MonoString* fieldNameCS = mono_string_new(App->scripting->domain, mono_field_get_name(field));
MonoReflectionType* myClassType = mono_type_get_object(App->scripting->domain, mono_class_get_type(mono_object_get_class(GetMonoComponent())));
bool hidden = FieldHasHideInInspector(myClassType, fieldNameCS);
if (!hidden)
{
uint32_t flags = mono_field_get_flags(field);
if (!(flags & MONO_FIELD_ATTR_STATIC))
{
bool serialized = FieldHasSerializeField(myClassType, fieldNameCS);
if ((flags & MONO_FIELD_ATTR_PUBLIC) || serialized)
{
MonoType* type = mono_field_get_type(field);
std::string typeName = mono_type_full_name(type);
std::string fieldName = mono_field_get_name(field);
if (typeName == "JellyBitEngine.Transform" && fieldName == varName)
{
if (monoObject)
{
MonoObject* monoTransform;
mono_field_get_value(monoObject, mono_class_get_field_from_name(mono_object_get_class(monoObject), "transform"), &monoTransform);
mono_field_set_value(GetMonoComponent(), field, monoTransform);
}
else
{
mono_field_set_value(GetMonoComponent(), field, nullptr);
}
break;
}
}
}
}
field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), (void**)&iterator);
}
break;
}
case VarType::LAYERMASK:
{
//DeSerialize the var value
bytes = sizeof(uint32_t);
uint32_t var = 0u;
memcpy(&var, cursor, bytes);
cursor += bytes;
void* iterator = 0;
MonoClassField* field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), &iterator);
while (field != nullptr)
{
uint32_t flags = mono_field_get_flags(field);
MonoString* fieldNameCS = mono_string_new(App->scripting->domain, mono_field_get_name(field));
MonoReflectionType* myClassType = mono_type_get_object(App->scripting->domain, mono_class_get_type(mono_object_get_class(GetMonoComponent())));
bool hidden = FieldHasHideInInspector(myClassType, fieldNameCS);
if (!hidden)
{
uint32_t flags = mono_field_get_flags(field);
if (!(flags & MONO_FIELD_ATTR_STATIC))
{
bool serialized = FieldHasSerializeField(myClassType, fieldNameCS);
if ((flags & MONO_FIELD_ATTR_PUBLIC) || serialized)
{
MonoType* type = mono_field_get_type(field);
std::string typeName = mono_type_full_name(type);
std::string fieldName = mono_field_get_name(field);
if (typeName == "JellyBitEngine.LayerMask" && fieldName == varName)
{
mono_field_set_value(GetMonoComponent(), field, &var);
break;
}
}
}
}
field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), (void**)&iterator);
}
break;
}
case VarType::ENUM:
{
//DeSerialize the var value
bytes = sizeof(uint32_t);
uint32_t var;
memcpy(&var, cursor, bytes);
cursor += bytes;
void* iterator = 0;
MonoClassField* field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), &iterator);
while (field != nullptr)
{
uint32_t flags = mono_field_get_flags(field);
MonoString* fieldNameCS = mono_string_new(App->scripting->domain, mono_field_get_name(field));
MonoReflectionType* myClassType = mono_type_get_object(App->scripting->domain, mono_class_get_type(mono_object_get_class(GetMonoComponent())));
bool hidden = FieldHasHideInInspector(myClassType, fieldNameCS);
if (!hidden)
{
uint32_t flags = mono_field_get_flags(field);
if (!(flags & MONO_FIELD_ATTR_STATIC))
{
bool serialized = FieldHasSerializeField(myClassType, fieldNameCS);
if ((flags & MONO_FIELD_ATTR_PUBLIC) || serialized)
{
MonoType* type = mono_field_get_type(field);
MonoClass* classCSharp = mono_type_get_class(type);
if (classCSharp && mono_class_is_enum(classCSharp))
{
std::string typeName = mono_type_full_name(type);
std::string fieldName = mono_field_get_name(field);
if (fieldName == varName)
{
mono_field_set_value(GetMonoComponent(), field, &var);
break;
}
}
}
}
}
field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), (void**)&iterator);
}
break;
}
case VarType::STRUCT:
{
//DeSerialize the var value
bytes = sizeof(uint);
uint32_t size;
memcpy(&size, cursor, bytes);
cursor += bytes;
char* structContent = new char[size];
memcpy(structContent, cursor, size);
cursor += size;
void* iterator = 0;
MonoClassField* field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), &iterator);
while (field != nullptr)
{
uint32_t flags = mono_field_get_flags(field);
MonoString* fieldNameCS = mono_string_new(App->scripting->domain, mono_field_get_name(field));
MonoReflectionType* myClassType = mono_type_get_object(App->scripting->domain, mono_class_get_type(mono_object_get_class(GetMonoComponent())));
bool hidden = FieldHasHideInInspector(myClassType, fieldNameCS);
if (!hidden)
{
uint32_t flags = mono_field_get_flags(field);
if (!(flags & MONO_FIELD_ATTR_STATIC))
{
bool serialized = FieldHasSerializeField(myClassType, fieldNameCS);
if ((flags & MONO_FIELD_ATTR_PUBLIC) || serialized)
{
MonoType* type = mono_field_get_type(field);
if (mono_type_is_struct(type))
{
std::string fieldName = mono_field_get_name(field);
if (fieldName == varName)
{
mono_field_set_value(GetMonoComponent(), field, structContent);
break;
}
}
}
}
}
field = mono_class_get_fields(mono_object_get_class(GetMonoComponent()), (void**)&iterator);
}
break;
}
default:
break;
}
}
}
void ComponentScript::TemporalSave()
{
if (tempBuffer != nullptr)
{
delete[] tempBuffer;
tempBuffer = nullptr;
//TODO: WHEN THIS HAPPENS AND WHY?
}
tempBufferBytes = GetPublicVarsSerializationBytes();
if (tempBufferBytes != 0)
{
tempBuffer = new char[tempBufferBytes];
char* cursor = tempBuffer;
SavePublicVars(cursor);
}
}
void ComponentScript::TemporalLoad()
{
if (tempBuffer != nullptr)
{
char* cursor = tempBuffer;
LoadPublicVars(cursor);
delete[] tempBuffer;
tempBuffer = nullptr;
tempBufferBytes = 0u;
}
}
void ComponentScript::InstanceClass()
{
if (scriptResUUID == 0)
return;
ResourceScript* scriptRes = (ResourceScript*)App->res->GetResource(scriptResUUID);
if (!scriptRes)
{
System_Event event;
event.compEvent.type = System_Event_Type::ComponentDestroyed;
event.compEvent.component = this;
App->PushSystemEvent(event);
return;
}
if (!App->scripting->scriptsImage)
return;
MonoClass* klass = mono_class_from_name(App->scripting->scriptsImage, "", scriptName.data());
if (!klass)
return;
MonoObject* compInstance = mono_object_new(App->scripting->domain, klass);
if (compInstance == nullptr)
{
CONSOLE_LOG(LogTypes::Error, "A ComponentScript could not create its monoInstance. Name: %s", scriptName.data());
return;
}
mono_runtime_object_init(compInstance);
int gameObjectAddress = (int)GetParent();
int componentAddress = (int)this;
mono_field_set_value(compInstance, mono_class_get_field_from_name(klass, "gameObjectAddress"), &gameObjectAddress);
mono_field_set_value(compInstance, mono_class_get_field_from_name(klass, "componentAddress"), &componentAddress);
mono_field_set_value(compInstance, mono_class_get_field_from_name(klass, "gameObject"), App->scripting->MonoObjectFrom(GetParent()));
monoCompHandle = mono_gchandle_new(compInstance, true);
}
void ComponentScript::InstanceClass(MonoObject* _classInstance)
{
if (scriptResUUID == 0)
return;
ResourceScript* scriptRes = (ResourceScript*)App->res->GetResource(scriptResUUID);
if (!scriptRes)
{
System_Event event;
event.compEvent.type = System_Event_Type::ComponentDestroyed;
event.compEvent.component = this;
App->PushSystemEvent(event);
return;
}
MonoClass* klass = mono_class_from_name(App->scripting->scriptsImage, "", scriptName.data());
if (!klass)
return;
int gameObjectAddress = (int)GetParent();
int componentAddress = (int)this;
mono_field_set_value(_classInstance, mono_class_get_field_from_name(klass, "gameObjectAddress"), &gameObjectAddress);
mono_field_set_value(_classInstance, mono_class_get_field_from_name(klass, "componentAddress"), &componentAddress);
mono_field_set_value(_classInstance, mono_class_get_field_from_name(klass, "gameObject"), App->scripting->MonoObjectFrom(GetParent()));
monoCompHandle = mono_gchandle_new(_classInstance, true);
}
bool ComponentScript::FieldHasHideInInspector(MonoReflectionType* classType, MonoString* fieldName)
{
MonoClass* HideInInspectorClass = mono_class_from_name(App->scripting->internalImage, "JellyBitEngine", "HideInInspector");
MonoMethodDesc* isHiddenDesc = mono_method_desc_new("JellyBitEngine.HideInInspector::IsHidden", true);
MonoMethod* isHiddenMethod = mono_method_desc_search_in_class(isHiddenDesc, HideInInspectorClass);
mono_method_desc_free(isHiddenDesc);
void* params[2];
params[0] = classType;
params[1] = fieldName;
MonoObject* ret = mono_runtime_invoke(isHiddenMethod, NULL, params, NULL);
return *(bool*)mono_object_unbox(ret);
}
bool ComponentScript::FieldHasSerializeField(MonoReflectionType* classType, MonoString* fieldName)
{
MonoClass* SerializeFieldClass = mono_class_from_name(App->scripting->internalImage, "JellyBitEngine", "SerializeField");
MonoMethodDesc* IsSerializableDesc = mono_method_desc_new("JellyBitEngine.SerializeField::IsSerializable", true);
MonoMethod* IsSerializableMethod = mono_method_desc_search_in_class(IsSerializableDesc, SerializeFieldClass);
mono_method_desc_free(IsSerializableDesc);
void* params[2];
params[0] = classType;
params[1] = fieldName;
MonoObject* ret = mono_runtime_invoke(IsSerializableMethod, NULL, params, NULL);
return *(bool*)mono_object_unbox(ret);
}
| 31.019652
| 181
| 0.664288
|
JellyBitStudios
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.