blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 2
247
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
57
| license_type
stringclasses 2
values | repo_name
stringlengths 4
111
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
58
| visit_date
timestamp[ns]date 2015-07-25 18:16:41
2023-09-06 10:45:08
| revision_date
timestamp[ns]date 1970-01-14 14:03:36
2023-09-06 06:22:19
| committer_date
timestamp[ns]date 1970-01-14 14:03:36
2023-09-06 06:22:19
| github_id
int64 3.89k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 25
values | gha_event_created_at
timestamp[ns]date 2012-06-07 00:51:45
2023-09-14 21:58:52
⌀ | gha_created_at
timestamp[ns]date 2008-03-27 23:40:48
2023-08-24 19:49:39
⌀ | gha_language
stringclasses 159
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 7
10.5M
| extension
stringclasses 111
values | filename
stringlengths 1
195
| text
stringlengths 7
10.5M
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4de3a94005aa5b0fbc4ac73c7900452b3591f237
|
76bd23f86c055b7d94658fd045018761fe45ab7d
|
/Cpp/Chapter13/tabtenn1.cpp
|
bbd47b77082bf50f19ee6a6b618f9bee88d53d42
|
[] |
no_license
|
pmusau17/CodingChallenges
|
bb5db754ea56514ee0c3fb49161ae01021e982e4
|
0b083446e21e84b91c4caf24bb4b212439a06853
|
refs/heads/master
| 2021-06-28T08:54:32.209383
| 2021-05-26T17:48:23
| 2021-05-26T17:48:23
| 234,108,802
| 0
| 0
| null | 2021-05-26T17:48:24
| 2020-01-15T15:19:37
|
C++
|
UTF-8
|
C++
| false
| false
| 756
|
cpp
|
tabtenn1.cpp
|
// tabtenn1.cpp -- base-class mehtods and derived-clas methods
#include "tabtenn1.h"
#include <iostream>
#include <cstring>
// TableTennisPlayer methods
TableTennisPlayer::TableTennisPlayer(const char * fn, const char * ln, bool ht)
{
std::strncpy(firstname,fn,LIM-1);
firstname[LIM-1]='\0';
std::strncpy(lastname,ln,LIM-1);
lastname[LIM-1]='\0';
hasTable = ht;
}
void TableTennisPlayer::Name() const
{
std::cout << lastname << "," << firstname;
}
// RatedPlayer methods/constructors
RatedPlayer::RatedPlayer(unsigned int r, const char * fn, const char * ln, bool ht): TableTennisPlayer(fn,ln,ht)
{
rating = r;
}
RatedPlayer::RatedPlayer(unsigned int r, const TableTennisPlayer & tp): TableTennisPlayer(tp), rating(r)
{
}
|
5442efff2a1659fdec5a2ef5a66c7fff51fec7ad
|
2cab36984d5e3f8d56b19235a44ba31ca259eed5
|
/Wizard/poj3419.cpp
|
56af4d202aedec9689a13be79d40ec8c03793011
|
[] |
no_license
|
sdad120/acmcode
|
c3ba5fdfc40a2710dadcb6d159d0a1025f18c1d4
|
676933842dfc27f8344385c802962c217e8205c0
|
refs/heads/master
| 2016-09-07T18:33:03.115515
| 2015-11-20T05:21:59
| 2015-11-20T05:21:59
| 40,102,617
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,530
|
cpp
|
poj3419.cpp
|
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
#define N 200005
#define MAX 1000000
int n, m;
int a[N], right[N], t[N*4], p[N*10];
void bld(int k, int l, int r){
if (l == r){
t[k] = right[l] - l + 1;
return;
}
int mid = (l + r) / 2;
bld(k*2, l, mid);
bld(k*2+1, mid+1, r);
t[k] = max(t[k*2], t[k*2+1]);
}
int get(int k, int l, int r, int x, int y){
if (x <= l && r <= y){
return t[k];
}
int mid = (l + r) / 2, ret = 0;
if (x <= mid) ret = max(ret, get(k*2, l, mid, x, y));
if (y > mid) ret = max(ret, get(k*2+1, mid+1, r, x, y));
return ret;
}
int main(){
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; ++ i){
scanf("%d", &a[i]);
}
int cntRight = 0;
for (int left = 1; left <= n; ++ left){
while (cntRight + 1 <= n && p[a[cntRight+1]+MAX] == 0){
p[a[++cntRight]+MAX] = 1;
}
right[left] = cntRight;
p[a[left]+MAX] = 0;
}
bld(1, 1, n);
while (m--){
int x, y;
scanf("%d%d", &x, &y); ++ x; ++ y;
int l = x, r = y;
while (l < r){
int mid = (l + r) / 2;
if (right[mid] >= y) r = mid; else l = mid + 1;
}
int ans = 0;
if (right[l] >= y){
ans = y - l + 1;
}
if (l - 1 > 0 && right[l-1] <= y){
ans = max(ans, get(1, 1, n, x, l - 1));
}
printf("%d\n", ans);
}
return 0;
}
|
ee5a6e4acc8563f1ac22daad5fe1ddaa71a72b9e
|
b99e6a122bc377e6eabfe2ece650b3f26eaaa6d8
|
/src/uva/536.cc
|
9d8d71821dec33bb2652581fc2482bea96c8c488
|
[] |
no_license
|
cedric-sun/toys
|
8a853317885a56faf01628d32a94f5e759952c8e
|
492156c0f70d4ddad4f943e7ea1a024a36cdb54b
|
refs/heads/master
| 2023-02-27T01:50:53.148846
| 2021-02-06T22:41:35
| 2021-02-06T22:41:35
| 293,705,256
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 647
|
cc
|
536.cc
|
#include <cstdio>
#include <cstring>
int n;
char pre[30],in[30],l[30],r[30];
int build(int pl,int pr,int il,int ir)
{
if (il>ir) return 0;
char root=pre[pl];
int droot=root-'A'+1;
int p=il;
while (in[p]!=root) p++;
int cnt=p-il;
l[root-'A'+1]=build(pl+1,pl+cnt,il,p-1);
r[root-'A'+1]=build(pl+cnt+1,pr,p+1,ir);
return droot;
}
void dfs(int root)
{
if (l[root])
dfs(l[root]);
if (r[root])
dfs(r[root]);
putchar(root+'A'-1);
}
int main()
{
while (~scanf("%s %s",pre,in))
{
n=strlen(pre);
dfs(build(0,n-1,0,n-1));
putchar('\n');
}
return 0;
}
|
227d9e73423cb01d09dd7b12ce13062dca2c9e73
|
85c261b62ac353640081556623be8a2994c2160b
|
/graf_lista.cpp
|
bbbbdc71560b1cc68bf7f79c9a74bdf1091aa368
|
[] |
no_license
|
filip452/Grafy
|
15b79d75a7f672097396accd2f07ff1993f552ea
|
d10161e35facf025681013c6133486dac2739657
|
refs/heads/main
| 2023-04-25T15:42:14.634634
| 2021-05-10T20:27:11
| 2021-05-10T20:27:11
| 366,167,102
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,597
|
cpp
|
graf_lista.cpp
|
#include "graf_lista.hh"
#include <cstdlib>
#include <ctime>
template<int ROZMIAR>
graf_lista<ROZMIAR>::graf_lista()
{
ilosc_kraw = 0;
}
template<int ROZMIAR>
graf_lista<ROZMIAR>::get_ik()
{
return ilosc_kraw;
}
template<int ROZMIAR>
krawedz graf_lista<ROZMIAR>::get_k(int index)
{
return kraw[index];
}
template<int ROZMIAR>
void graf_lista<ROZMIAR>::set_k(krawedz k)
{
kraw[ilosc_kraw++] = k;
}
template<int ROZMIAR>
void graf_lista<ROZMIAR>::usun(int docel)
{
int poz = 0;
while(kraw[poz].docel != docel)
{
poz++;
}
for(int i = poz; i < ilosc_kraw-1; i++)
kraw[i] = kraw [i+1];
ilosc_kraw--;
}
template<int ROZMIAR>
graf_lista<ROZMIAR>* gr_li_stworz(float gestosc)
{
graf_lista<ROZMIAR> *lista_w;
graf_lista<ROZMIAR> elem;
krawedz kraw;
int wierzcholek = 0;
int nast;
int koniec = ROZMIAR-1;
int zmiana = 1;
int suma = 0;
lista_w = new graf_lista<ROZMIAR>[ROZMIAR];
srand(time(NULL));
for(int i=0; i<ROZMIAR; i++)
suma += i;
for(int i=0; i<=(suma-1)*gestosc; i++)
{
nast = wierzcholek + zmiana;
kraw.waga = rand()%99 + 1;
kraw.docel = nast;
lista_w[wierzcholek].set_k(kraw);
kraw.docel = wierzcholek;
lista_w[nast].set_k(kraw);
wierzcholek++;
if(wierzcholek == koniec)
{
wierzcholek = 0;
zmiana ++;
koniec --;
}
}
return lista_w;
}
|
1d06110e2c09bc7d65b3c5c0a6ab8203bee11d6b
|
e264a42a639444e80769d0b3a0d62ba5d8ea3013
|
/firmware/dlpio8_emu.ino
|
3769925a59f3e2e3e420938e1f0f11fa4820a2bd
|
[
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-public-domain"
] |
permissive
|
huleg/arduino-daq
|
912b9063bad2e53278d2ae4707646f9083f237f8
|
1629dc9404470eb96cb259cdf194270c949263fb
|
refs/heads/master
| 2021-01-11T18:04:33.830218
| 2013-03-11T20:51:51
| 2013-03-11T20:51:51
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,360
|
ino
|
dlpio8_emu.ino
|
/*
* DLP-IO8 compatible data acquisition on Arduino
* This code is placed in the public domain by its author, Ian Harvey.
*/
#include <OneWire.h>
void setup()
{
Serial.begin(115200);
while (!Serial)
; // wait for serial port to connect. Needed for Leonardo only
analogReference(INTERNAL);
//Serial.println("RESET");
}
void printWidth(unsigned val, byte width)
{
unsigned n=1;
while (width-- > 1)
n *= 10;
// n is now the smallest value which fills 'width' digits
while ( val < n )
{
Serial.write('0');
n = n/10;
}
if ( val > 0 )
Serial.print(val);
}
// Analogue input --------------------------
static const byte MAX_ADC_CHANS = 6;
void readVin(byte chan)
{
int val = (chan < MAX_ADC_CHANS) ? analogRead(chan) : 0;
// Map 0-1023 onto 0 to 1.101V output
int mV = val + (val >> 4) + (val >> 6);
printWidth( mV/1000, 1 );
Serial.write( '.' );
printWidth( mV % 1000, 3 );
Serial.print( "V\n\r" );
}
// DS18B20 temperature input -------------
const byte MAX_TEMP_CHANS = 4;
OneWire tempCh1(13);
OneWire tempCh2(12);
OneWire tempCh3(11);
OneWire tempCh4(10);
OneWire *tempChans[MAX_TEMP_CHANS] =
{ &tempCh1, &tempCh2, &tempCh3, &tempCh4 };
void readTemp(unsigned chan)
{
OneWire *ds;
byte i;
byte buf[10];
unsigned int tempReg;
if ( chan >= MAX_TEMP_CHANS ) {
goto fail_exit;
}
ds = tempChans[chan];
if ( !ds->reset() )
{
//Serial.print("<not present>");
goto fail_exit;
}
ds->write(0x33); // READ ROM
for (i=0; i < 8; i++ )
buf[i] = ds->read();
ds->reset();
ds->select(buf);
ds->write(0x44,1); // start conversion, with parasite power on at the end
delay(1000); // maybe 750ms is enough, maybe not
// we might do a ds.depower() here, but the reset will take care of it.
ds->reset();
ds->select(buf);
ds->write(0xBE); // Read Scratchpad
for ( i = 0; i < 9; i++) { // we need 9 bytes
buf[i] = ds->read();
}
if ( buf[8] != OneWire::crc8(buf, 8) )
{
//Serial.print("<CRC mismatch>");
goto fail_exit;
}
tempReg = (buf[1] << 8) | buf[0];
if (tempReg & 0x8000)
{
Serial.write('-');
tempReg = (~tempReg) + 1;
}
printWidth( tempReg >> 4, 3 );
Serial.print('.');
printWidth( ((tempReg & 0xF) * 100) >> 4, 2 );
Serial.write(0xF8);
Serial.print("C\n\r");
return;
fail_exit:
Serial.print("999.9");
Serial.write(0xF8);
Serial.print("C\n\r");
}
void loop()
{
if (Serial.available() <= 0)
return;
unsigned in = Serial.read();
switch(in)
{
case '\'':
Serial.write("Q");
break;
case 'Z': readVin(0); break;
case 'X': readVin(1); break;
case 'C': readVin(2); break;
case 'V': readVin(3); break;
case 'B': readVin(4); break;
case 'N': readVin(5); break;
case 'M': readVin(6); break;
case ',': readVin(7); break;
case '9': readTemp(0); break;
case '0': readTemp(1); break;
case '-': readTemp(2); break;
case '=': readTemp(3); break;
case 'O': readTemp(4); break;
case 'P': readTemp(5); break;
case '[': readTemp(6); break;
case ']': readTemp(7); break;
case ';': break; // Set Temp in deg C - ignored
default:
Serial.write(in);
Serial.write("??");
break;
}
}
|
d13a8b5e565d35c3b5a7527eed37877d9b369d32
|
7d2d40fa1a777e68c9dc59d725aea85da2bb0b02
|
/apc16delft_fake_components/src/grasp_synthesizer.cpp
|
fa912850d0c3577b0dbb585962308cde090fd19b
|
[] |
no_license
|
javanegmond/team_delft-1
|
898f2f6e544bde7750739f3469d68e1e363fa3dd
|
c2125a3319d2c3a774ebb5817d11f7ef9ad28013
|
refs/heads/master
| 2021-01-21T03:41:24.602410
| 2017-09-08T12:09:44
| 2017-09-08T12:09:44
| 101,898,262
| 0
| 0
| null | 2017-08-30T15:28:03
| 2017-08-30T15:28:03
| null |
UTF-8
|
C++
| false
| false
| 1,780
|
cpp
|
grasp_synthesizer.cpp
|
#include <ros/ros.h>
#include <apc16delft_util/managed_node.hpp>
#include <apc16delft_msgs/SynthesizeGrasp.h>
#include <apc16delft_util/managed_node.hpp>
namespace apc16delft {
namespace grasping {
class GraspSynthesizer : public ManagedNode {
ros::ServiceServer synthesize_grasp;
geometry_msgs::Pose pose;
bool synthesizeGrasp(apc16delft_msgs::SynthesizeGrasp::Request & req, apc16delft_msgs::SynthesizeGrasp::Response & res) {
apc16delft_msgs::GraspCandidate candidate;
res.error = 0;
res.message = "Fake result.";
candidate.score = 1.0;
candidate.stamped_pose.header.frame_id = req.object_pose.header.frame_id;
candidate.stamped_pose.pose = pose;
res.candidates.push_back(candidate);
return true;
}
virtual int onConfigure() override {
node_handle.getParam("grasp_position/x" , pose.position.x );
node_handle.getParam("grasp_position/y" , pose.position.y );
node_handle.getParam("grasp_position/z" , pose.position.z );
node_handle.getParam("grasp_orientation/w", pose.orientation.w);
node_handle.getParam("grasp_orientation/x", pose.orientation.x);
node_handle.getParam("grasp_orientation/y", pose.orientation.y);
node_handle.getParam("grasp_orientation/z", pose.orientation.z);
return 0;
}
virtual int onActivate() override {
ROS_INFO_STREAM("Activated!");
synthesize_grasp = node_handle.advertiseService("synthesize_grasp", &GraspSynthesizer::synthesizeGrasp, this);
return 0;
}
virtual int onDeactivate() override {
synthesize_grasp.shutdown();
return 0;
}
};
} // namespace
}
int main(int argc, char * * argv) {
ros::init(argc, argv, ROS_PACKAGE_NAME "_grasp_synthesizer");
apc16delft::grasping::GraspSynthesizer node;
node.configure();
node.activate();
ros::spin();
}
|
b49c6b0302546464d8c8e4b39284bb5f444f8c41
|
a96cbdb9aa0d96bc420f0847a8753a6d3f36bc3a
|
/Lesson_15/Sample7.cpp
|
d3ec23843f41add08c02db3b157e34e37d520302
|
[] |
no_license
|
KamonohashiPerry/cplusplus
|
e1901842e8a9b711a39c86557d81e9cc42e8b2ab
|
970a73df4526c011b9098fcfeb67beab345d71b4
|
refs/heads/master
| 2023-02-06T16:48:21.376905
| 2020-12-27T06:37:22
| 2020-12-27T06:37:22
| 291,221,882
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 455
|
cpp
|
Sample7.cpp
|
#include <iostream>
using namespace std;
int main()
{
int num;
cout << "1~9までの数を入力してください。\n";
cin >> num;
try{
if(num <= 0)
throw "0以下を入力しました";
if(num >= 10)
throw "10以上を入力しました";
cout << num << "です。\n";
}
catch(char* err){
cout << "エラー:" << err << '\n';
return 1;
}
return 0;
}
|
f31120c2ac202050936c799487fed62379f60233
|
9de18ef120a8ae68483b866c1d4c7b9c2fbef46e
|
/src/UserSpaceInstrumentation/AccessTraceesMemoryTest.cpp
|
c7fd480561e79ec43f2e2b5443efb0a921d894a5
|
[
"BSD-2-Clause",
"LicenseRef-scancode-free-unknown"
] |
permissive
|
google/orbit
|
02a5b4556cd2f979f377b87c24dd2b0a90dff1e2
|
68c4ae85a6fe7b91047d020259234f7e4961361c
|
refs/heads/main
| 2023-09-03T13:14:49.830576
| 2023-08-25T06:28:36
| 2023-08-25T06:28:36
| 104,358,587
| 2,680
| 325
|
BSD-2-Clause
| 2023-08-25T06:28:37
| 2017-09-21T14:28:35
|
C++
|
UTF-8
|
C++
| false
| false
| 8,072
|
cpp
|
AccessTraceesMemoryTest.cpp
|
// Copyright (c) 2021 The Orbit Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <absl/strings/numbers.h>
#include <absl/strings/str_format.h>
#include <absl/strings/str_split.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <sys/prctl.h>
#include <sys/wait.h>
#include <unistd.h>
#include <algorithm>
#include <csignal>
#include <cstdint>
#include <iterator>
#include <random>
#include <string>
#include <string_view>
#include <vector>
#include "AccessTraceesMemory.h"
#include "OrbitBase/Logging.h"
#include "OrbitBase/ReadFileToString.h"
#include "OrbitBase/Result.h"
#include "TestUtils/TestUtils.h"
#include "UserSpaceInstrumentation/AddressRange.h"
#include "UserSpaceInstrumentation/Attach.h"
namespace orbit_user_space_instrumentation {
namespace {
using orbit_test_utils::HasErrorWithMessage;
AddressRange AddressRangeFromString(std::string_view string_address) {
AddressRange result{};
const std::vector<std::string> addresses = absl::StrSplit(string_address, '-');
if (addresses.size() != 2) {
ORBIT_FATAL("Not an address range: %s", string_address);
}
if (!absl::numbers_internal::safe_strtou64_base(addresses[0], &result.start, 16)) {
ORBIT_FATAL("Not a number: %s", addresses[0]);
}
if (!absl::numbers_internal::safe_strtou64_base(addresses[1], &result.end, 16)) {
ORBIT_FATAL("Not a number: %s", addresses[1]);
}
return result;
}
// Get the address range of the first consecutive mappings. We can read this range but not more.
[[nodiscard]] ErrorMessageOr<AddressRange> GetFirstContinuousAddressRange(pid_t pid) {
OUTCOME_TRY(auto&& maps, orbit_base::ReadFileToString(absl::StrFormat("/proc/%d/maps", pid)));
const std::vector<std::string> lines = absl::StrSplit(maps, '\n', absl::SkipEmpty());
bool is_first = true;
AddressRange result{};
for (const auto& line : lines) {
const std::vector<std::string> tokens = absl::StrSplit(line, ' ', absl::SkipEmpty());
if (tokens.size() < 2 || tokens[1].size() != 4) continue;
const AddressRange current_range = AddressRangeFromString(tokens[0]);
if (is_first) {
result = current_range;
is_first = false;
} else {
if (current_range.start == result.end) {
result.end = current_range.end;
}
}
}
return result;
}
} // namespace
TEST(AccessTraceesMemoryTest, ReadFailures) {
/* copybara:insert(Test fails once in a while in threadsafe death test style)
GTEST_FLAG_SET(death_test_style, "fast");
*/
pid_t pid = fork();
ORBIT_CHECK(pid != -1);
if (pid == 0) {
prctl(PR_SET_PDEATHSIG, SIGTERM);
// Child just runs an endless loop.
volatile uint64_t counter = 0;
while (true) {
// Endless loops without side effects are UB and recent versions of clang optimize it away.
++counter;
}
}
// Stop the child process using our tooling.
ORBIT_CHECK(!AttachAndStopProcess(pid).has_error());
auto continuous_range_or_error = GetFirstContinuousAddressRange(pid);
ORBIT_CHECK(continuous_range_or_error.has_value());
const auto continuous_range = continuous_range_or_error.value();
const uint64_t address = continuous_range.start;
constexpr uint64_t kMaxLength = 20ul * 1024 * 1024; // 20 MiB
const uint64_t length = std::min(kMaxLength, continuous_range.end - continuous_range.start);
// Good read.
ErrorMessageOr<std::vector<uint8_t>> result = ReadTraceesMemory(pid, address, length);
EXPECT_TRUE(result.has_value());
// Process does not exist.
result = ReadTraceesMemory(-1, address, length);
EXPECT_THAT(result, HasErrorWithMessage("Unable to open file"));
// Read 0 bytes.
EXPECT_DEATH(auto unused_result = ReadTraceesMemory(pid, address, 0), "Check failed");
// Read past the end of the mappings.
result = ReadTraceesMemory(pid, continuous_range.end - length, length + 1);
EXPECT_THAT(result, HasErrorWithMessage("Input/output error"));
// Read from bad address.
result = ReadTraceesMemory(pid, 0, length);
EXPECT_THAT(result, HasErrorWithMessage("Input/output error"));
// Detach and end child.
ORBIT_CHECK(!DetachAndContinueProcess(pid).has_error());
kill(pid, SIGKILL);
waitpid(pid, nullptr, 0);
}
TEST(AccessTraceesMemoryTest, WriteFailures) {
/* copybara:insert(Test fails once in a while in threadsafe death test style)
GTEST_FLAG_SET(death_test_style, "fast");
*/
pid_t pid = fork();
ORBIT_CHECK(pid != -1);
if (pid == 0) {
prctl(PR_SET_PDEATHSIG, SIGTERM);
// Child just runs an endless loop.
volatile uint64_t counter = 0;
while (true) {
// Endless loops without side effects are UB and recent versions of clang optimize it away.
++counter;
}
}
// Stop the child process using our tooling.
ORBIT_CHECK(!AttachAndStopProcess(pid).has_error());
auto continuous_range_or_error = GetFirstContinuousAddressRange(pid);
ORBIT_CHECK(continuous_range_or_error.has_value());
const auto continuous_range = continuous_range_or_error.value();
const uint64_t address = continuous_range.start;
constexpr uint64_t kMaxLength = 20ul * 1024 * 1024; // 20 MiB
const uint64_t length = std::min(kMaxLength, continuous_range.end - continuous_range.start);
// Backup.
auto backup = ReadTraceesMemory(pid, address, length);
ORBIT_CHECK(backup.has_value());
// Good write.
std::vector<uint8_t> bytes(length, 0);
ErrorMessageOr<void> result = WriteTraceesMemory(pid, address, bytes);
EXPECT_FALSE(result.has_error());
// Process does not exist.
result = WriteTraceesMemory(-1, address, bytes);
EXPECT_THAT(result, HasErrorWithMessage("Unable to open file"));
// Write 0 bytes.
EXPECT_DEATH(auto unused_result = WriteTraceesMemory(pid, address, std::vector<uint8_t>()),
"Check failed");
// Write past the end of the mappings.
bytes.push_back(0);
result = WriteTraceesMemory(pid, continuous_range.end - length, bytes);
EXPECT_THAT(result, HasErrorWithMessage("Input/output error"));
// Write to bad address.
result = WriteTraceesMemory(pid, 0, bytes);
EXPECT_THAT(result, HasErrorWithMessage("Input/output error"));
// Restore, detach and end child.
ORBIT_CHECK(!WriteTraceesMemory(pid, address, backup.value()).has_error());
ORBIT_CHECK(!DetachAndContinueProcess(pid).has_error());
kill(pid, SIGKILL);
waitpid(pid, nullptr, 0);
}
TEST(AccessTraceesMemoryTest, ReadWriteRestore) {
pid_t pid = fork();
ORBIT_CHECK(pid != -1);
if (pid == 0) {
prctl(PR_SET_PDEATHSIG, SIGTERM);
// Child just runs an endless loop.
volatile uint64_t counter = 0;
while (true) {
// Endless loops without side effects are UB and recent versions of clang optimize it away.
++counter;
}
}
// Stop the child process using our tooling.
ORBIT_CHECK(!AttachAndStopProcess(pid).has_error());
auto memory_region_or_error = GetExistingExecutableMemoryRegion(pid);
ORBIT_CHECK(memory_region_or_error.has_value());
const uint64_t address = memory_region_or_error.value().start;
constexpr uint64_t kMemorySize = 4u * 1024u;
auto backup = ReadTraceesMemory(pid, address, kMemorySize);
ASSERT_TRUE(backup.has_value());
std::vector<uint8_t> new_data(kMemorySize);
std::mt19937 engine{std::random_device()()};
std::uniform_int_distribution<uint32_t> distribution{0x00, 0xff};
std::generate(std::begin(new_data), std::end(new_data),
[&distribution, &engine]() { return static_cast<uint8_t>(distribution(engine)); });
ASSERT_FALSE(WriteTraceesMemory(pid, address, new_data).has_error());
auto read_back_or_error = ReadTraceesMemory(pid, address, kMemorySize);
ASSERT_TRUE(read_back_or_error.has_value());
EXPECT_EQ(new_data, read_back_or_error.value());
// Restore, detach and end child.
ORBIT_CHECK(WriteTraceesMemory(pid, address, backup.value()).has_value());
ORBIT_CHECK(!DetachAndContinueProcess(pid).has_error());
kill(pid, SIGKILL);
waitpid(pid, nullptr, 0);
}
} // namespace orbit_user_space_instrumentation
|
782700c45509d83cad5d8e15d2275e08cd69c445
|
9da9440bfde05266df9ad6c62983873326bb86e3
|
/cpp/L3/tofile/tofile.cpp
|
806fb647d60461f30848617c22e597b45fe3302f
|
[] |
no_license
|
liruicrecky/Linux
|
76a49bb76f1a83f83fc56a01bbac4c39dcb89dd4
|
4373bbefd84a3e0d7a36c836f3c743a4ba79f979
|
refs/heads/master
| 2021-01-01T19:51:44.724089
| 2015-04-10T15:00:18
| 2015-04-10T15:00:18
| 30,750,177
| 5
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 585
|
cpp
|
tofile.cpp
|
/*************************************************************************
> File Name: tofile.cpp
> Author: Reacky
> Mail:3277632240@qq.com
> Created Time: Fri 06 Mar 2015 08:10:19 PM CST
************************************************************************/
#include<iostream>
#include<string>
#include<fstream>
using std::cout;
using std::cin;
using std::endl;
using std::string;
int main(int argc, char **argv)
{
std::ofstream ofs("1.txt");
int k = 1024;
string str = "LL";
ofs << "k= " << k << endl
<< "str= " << str << endl;
ofs.close();
return 0;
}
|
e68c432ec6900a2d7215a5b93b1814d2a7721a04
|
7b6939c937499bacbf8bcd12415e4efc27a3546b
|
/Cheap Travel.cpp
|
ea77948c0c10be6cc1b00f50d163e33f168b8c59
|
[] |
no_license
|
tasneemria/Codeforces_Solved
|
0c2f18c5e3b3a17a532066df535abcd9221184a8
|
fd54a828b14cf1d1c84d3a95d5726956caf3bc50
|
refs/heads/master
| 2021-07-18T02:01:13.848335
| 2017-10-19T06:52:54
| 2017-10-19T06:52:54
| 107,508,992
| 2
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 525
|
cpp
|
Cheap Travel.cpp
|
#include<bits/stdc++.h>
using namespace std;
int main()
{
double n,m,a,b;
cin>>n>>m>>a>>b;
if(a<=(b/m))
{
cout<<(int)(n*a)<<endl;
}
else
{
int ans = ceil(n/m);
double ans2,need;
int mod;
mod = ((int)n)%((int)m);
ans2 = a*mod;
need = n-mod;
need = need/m;
ans2 = ans2+need*b;
if(ans*b<ans2)
cout<<(int)(ans*b);
else
cout<<(int)ans2;
}
return 0;
}
|
3f02ea978d662cd204b12aba347983393d34cd0f
|
a1cefb58d2359315c0efba047f6d8f3f6bc74962
|
/src/Semaphore.cpp
|
1d6c8bca708d6e49dae5e6ebbd4139b3f8fa0875
|
[
"MIT"
] |
permissive
|
marcovas/mlib
|
2321671f7bd4d986b86ffc36f5eef4be9496d409
|
56ccaffa7a2d47c4b62207ce4bdba4a7a24b64a3
|
refs/heads/master
| 2020-07-04T06:37:32.632478
| 2020-04-26T22:16:55
| 2020-04-26T22:16:55
| 66,155,277
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 755
|
cpp
|
Semaphore.cpp
|
#include "Semaphore.h"
namespace mlib {
Semaphore::Semaphore(unsigned int i): initialCount (i), closed(false)
{
#ifndef _WIN32
sem_init (&semID, 1, initialCount);
#else
handle = CreateSemaphore (0, initialCount, 300, 0);
#endif
}
bool Semaphore::Wait() {
if (closed)
return false;
#ifndef _WIN32
sem_wait (&semID);
#else
WaitForSingleObject (handle, INFINITE);
#endif
return true;
}
bool Semaphore::Signal() {
if (closed)
return false;
#ifndef _WIN32
sem_post (&semID);
#else
ReleaseSemaphore (handle, 1, 0);
#endif
return true;
}
void Semaphore::Close() {
if (closed)
return;
#ifndef _WIN32
sem_destroy (&semID);
#else
CloseHandle (handle);
#endif
closed = true;
}
Semaphore::~Semaphore()
{
Close();
}
}
|
aa31dbd6f09a73a519295a4892d600a9a6d49cd6
|
dd77ce77cf8897d601f11d54d395cf17096ead27
|
/Assignments/Assignment5-6/PetShop/PetShop/CsvRepository.cpp
|
f36a30bc9aafc158fb6d0676418662833248336c
|
[] |
no_license
|
ecaterinacatargiu/OOP
|
9ed636e1c8a95ac99576f1b04d1a23eaf4f64b50
|
14808aa98faf9f03c0890b67106c590f7b482842
|
refs/heads/main
| 2023-03-06T22:26:49.993048
| 2021-02-20T16:20:33
| 2021-02-20T16:20:33
| 340,693,797
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 591
|
cpp
|
CsvRepository.cpp
|
#include "CsvRepository.h"
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
CSVRepository::CSVRepository()
{
}
void CSVRepository::writeAdoption()
{
std::ofstream fout("AdoptionList.csv");
std::vector<Pet> adoptionList = this->getAdopted();
for (auto it : adoptionList)
{
fout << it.getBreed() << "," << it.getName() << "," << it.getAge() << "," << it.getPhoto() << "\n";
}
}
void CSVRepository::showAdoptionList()
{
LPCTSTR file = "AdoptionList.csv";
ShellExecute(NULL, "open", file, NULL, NULL, SW_SHOWNORMAL);
}
CSVRepository::~CSVRepository()
{
}
|
b4c86f53cd1ebae4b8653ae0bfed4f06a41e1873
|
85e3b3f2fe0d8f451938c2abe33e941a387890a4
|
/vector_chain.cpp
|
771a1c9b718a6dca16a6958c42c400a23038bd63
|
[] |
no_license
|
juanjoseamaker/RotaryVectors
|
1b9ad2e5f8a7b80602d1e9f1157aa5493f61d908
|
c310da7d2a29c6fa850d0b05291edd618646192c
|
refs/heads/main
| 2023-05-30T23:47:37.678984
| 2021-06-17T18:58:16
| 2021-06-17T18:58:16
| 376,194,384
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,386
|
cpp
|
vector_chain.cpp
|
#include <vector>
#include <SDL2/SDL.h>
#include <cstdint>
#include <cmath>
#include "vector.hpp"
#include "vector_chain.hpp"
using namespace std;
#define DEFAULT_VECTOR_MAGNITUDE 100
VectorChain::VectorChain(int x, int y) {
posX = x;
posY = y;
selected = 0;
time = 0;
running = false;
addVector();
}
void VectorChain::startRunning() {
running = true;
}
void VectorChain::stopRunning(uint8_t pathBuffer[SCREEN_HEIGHT][SCREEN_WIDTH]) {
running = false;
time = 0;
for(int y = 0; y < SCREEN_HEIGHT; y++) {
for(int x = 0; x < SCREEN_WIDTH; x++) {
pathBuffer[y][x] = 0;
}
}
}
void VectorChain::update(SDL_Renderer *renderer, float frameTime, uint8_t pathBuffer[SCREEN_HEIGHT][SCREEN_WIDTH]) {
if(running) {
time += frameTime;
int x = posX, y = posY;
for(auto &vector : vectorChain) {
vector.draw(renderer, x, y, time, 0, 255, 0);
}
if(y > 0 && y < SCREEN_HEIGHT && x > 0 && x < SCREEN_WIDTH)
pathBuffer[y][x] = 1;
} else {
int x = posX, y = posY;
for(size_t i = 0; i < vectorChain.size(); i++) {
if(selected == i) {
float angularVelocityMagnitude = abs(vectorChain[i].angularVelocity) * 5;
SDL_SetRenderDrawColor(renderer, 0, 0, 255, 0);
SDL_RenderDrawLine(renderer, x, y, x + angularVelocityMagnitude * cos(vectorChain[i].angle + vectorChain[i].angularVelocity),
y + angularVelocityMagnitude * sin(vectorChain[i].angle + vectorChain[i].angularVelocity));
vectorChain[i].draw(renderer, x, y, 0, 255, 0, 0);
} else {
vectorChain[i].draw(renderer, x, y, 0, 0, 255, 0);
}
}
}
}
void VectorChain::selectNext() {
selected++;
if(selected >= vectorChain.size()) selected = 0;
}
void VectorChain::addVector() {
vectorChain.push_back(Vector2(DEFAULT_VECTOR_MAGNITUDE, 0, M_PI));
}
void VectorChain::removeVector() {
if(vectorChain.size() > 1) vectorChain.pop_back();
if(selected >= vectorChain.size()) selected = vectorChain.size() - 1;
}
void VectorChain::changeDirection(float dir) {
vectorChain[selected].angle += dir;
if(vectorChain[selected].angle > 2 * M_PI) vectorChain[selected].angle -= 2 * M_PI;
if(vectorChain[selected].angle < 0) vectorChain[selected].angle += 2 * M_PI;
}
void VectorChain::changeAngularVelocity(float vel) {
vectorChain[selected].angularVelocity += vel;
}
void VectorChain::changeMagnitude(float magnitude) {
vectorChain[selected].magnitude += magnitude;
}
|
5d89c80daea8c796d1dc5ebdf3bdd7e5833c8b29
|
1fdda85a365a07abdd13332ab11cdeb0a9f485cb
|
/src/was/FormRequestBody.cxx
|
01a1875918940cc66761cecba899a33acb708053
|
[] |
no_license
|
CM4all/libcommon
|
5a568ca3fce1ab985ff2ed9464a044bebb5ec5d5
|
5827f2ccec15cf1fbdbffab308268fd7d9ac1943
|
refs/heads/master
| 2023-08-18T08:15:48.015497
| 2023-08-17T14:34:48
| 2023-08-17T14:51:45
| 95,901,877
| 19
| 10
| null | 2018-02-28T21:16:40
| 2017-06-30T15:34:34
|
C++
|
UTF-8
|
C++
| false
| false
| 699
|
cxx
|
FormRequestBody.cxx
|
// SPDX-License-Identifier: BSD-2-Clause
// Copyright CM4all GmbH
// author: Max Kellermann <mk@cm4all.com>
#include "FormRequestBody.hxx"
#include "ExceptionResponse.hxx"
#include "ExpectRequestBody.hxx"
#include "StringRequestBody.hxx"
#include "uri/MapQueryString.hxx"
#include <stdexcept>
namespace Was {
std::multimap<std::string, std::string, std::less<>>
FormRequestBodyToMap(was_simple *w, std::string::size_type limit)
{
ExpectRequestBody(w, "application/x-www-form-urlencoded");
const auto raw = RequestBodyToString(w, limit);
try {
return MapQueryString(raw);
} catch (const std::invalid_argument &e) {
throw BadRequest{"Malformed request body\n"};
}
}
} // namespace Was
|
60a8b13da7de27fb3a797ca3a31a16f7e0c456f2
|
973bca8ad8b005d3460b763add64c35ce4758328
|
/src/states/StatePlayGame.cpp
|
6c2f3cbe5b12507b0bd5d147df2cdd808b5479e0
|
[] |
no_license
|
eivhys/Left-2D-ie
|
648cf2e2bb7f8feda6abc3df1372ff498329fa5b
|
0781207e3ab3c91c313ff73e4b6cf8d50d9f18aa
|
refs/heads/master
| 2022-01-22T02:36:01.016320
| 2016-12-16T16:01:02
| 2016-12-16T16:01:02
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,708
|
cpp
|
StatePlayGame.cpp
|
#include "StatePlayGame.h"
StatePlayGame::StatePlayGame(Game *game) : StateBase(game) {
initButtons();
}
StatePlayGame::~StatePlayGame() {
}
void StatePlayGame::update(float deltaTime) {
}
void StatePlayGame::pause() {
desktop->RemoveAll();
}
void StatePlayGame::resume() {
StateBase::resume();
initButtons();
}
void StatePlayGame::initButtons() {
auto singlePlayerButton = sfg::Button::Create("Single Player");
createButton(singlePlayerButton, sf::Vector2f(550.0f, 280.0f));
singlePlayerButton->GetSignal(sfg::Button::OnLeftClick).Connect(std::bind(&StatePlayGame::buttonSinglePlayerClicked,this));
auto multiplayerButton = sfg::Button::Create("Multiplayer");
createButton(multiplayerButton, sf::Vector2f(550.0f, 370.0f));
multiplayerButton->GetSignal(sfg::Button::OnLeftClick).Connect(std::bind(&StatePlayGame::buttonMultiplayerClicked,this));
auto backButton = sfg::Button::Create("Back");
createButton(backButton, sf::Vector2f(20.0f, 600.0f));
backButton->GetSignal(sfg::Button::OnLeftClick).Connect(std::bind(&StatePlayGame::buttonBackClicked,this));
}
void StatePlayGame::draw(sf::RenderWindow &window) {
sf::Text title("Left[2D]ie", game->getFont(), 140);
title.setColor(sf::Color::Red);
title.setPosition(275, 50);
game->getWindow().draw(title);
}
void StatePlayGame::buttonSinglePlayerClicked() {
game->getStateMachine().setState(StateMachine::StateID::SINGLE_PLAYER);
}
void StatePlayGame::buttonMultiplayerClicked() {
game->getStateMachine().setState(StateMachine::StateID::MULTI_PLAYER);
}
void StatePlayGame::buttonBackClicked() {
game->getStateMachine().setState(StateMachine::StateID::MAIN_MENU);
}
|
b5cae44e91cd548959d9b85f04d21e9447c7cec6
|
aeeba706530c271ef7849f278046c282a4210b95
|
/TP-Fase1-Test/server/xmlServer.h
|
d804dea02da20c3b2c9182fa65e3cb0d015e2799
|
[] |
no_license
|
Titolasanta/Zafiro
|
7a4ede6f92f2dc4e940f2303fb052b15da89c08e
|
75a192de88c348e575a648ce7b1dc4213937a168
|
refs/heads/master
| 2020-03-27T03:54:20.787065
| 2018-11-21T22:25:21
| 2018-11-21T22:25:21
| 145,897,804
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 697
|
h
|
xmlServer.h
|
//
// Created by tito on 11/10/18.
//
#ifndef TP_FASE1_TEST_XMLSERVER_H
#define TP_FASE1_TEST_XMLSERVER_H
#include "../common/pugixml.hpp"
#include "../common/Scene.h"
#include "Model.h"
void cargar_plataformas(pugi::xml_document &doc, Scene& scene, Model &modelo, int level, int limite_vertical, int limite_horizontal);
void cargar_users(pugi::xml_document &doc, std::list<std::string>&);
int get_cant_enemigos_moviles(pugi::xml_document &doc, pugi::xml_document &doc_default, int level, pugi::xml_parse_result result);
int get_cant_enemigos_estaticos(pugi::xml_document &doc, pugi::xml_document &doc_default, int level, pugi::xml_parse_result result);
#endif //TP_FASE1_TEST_XMLSERVER_H
|
676a64c483c66e55d07b6cbf17547e3e8cc3581c
|
7cb0c74386cb08ae52b8e0c2233081f1cc6ac5fb
|
/0027-Remove-Element/leetcode27.cpp
|
e6d0d3492102b41ace9f74d80bc0a6ddf57bb4bc
|
[] |
no_license
|
DoubleYanLee/MyLeetcodeAnswer
|
689886ce5d77936c4c5c5770d0f5654f0e182799
|
776af36b1a7f2ad0f3c2fd13a96a238a1ed81788
|
refs/heads/master
| 2023-02-13T11:29:24.163498
| 2021-01-10T14:25:56
| 2021-01-10T14:25:56
| 298,725,827
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,318
|
cpp
|
leetcode27.cpp
|
//
// Created by Yannie Lee on 2020-09-23.
//
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <queue>
#include <ctime>
#include <stack>
#include <unordered_set>
#include <unordered_map>
using namespace std;
class Solution {
public:
int removeElement(vector<int>& nums, int val) {
if(nums.size() <= 0 ) return 0;
int first = 0, end = nums.size() - 1;
//first表示当前要判断的元素 end表示其后面的元素都是重复的
while(first <= end ){ //没有考虑数组长度为1的情况 没有考虑[3,3]这种
//不能越界了
if(end >= nums.size() || end < 0) break;
if(first >= nums.size() || first < 0) break;
if( nums[first] == val ){
//不用交换,直接就可以不管了 反正只要长度(这样不行,后面的元素就漏扫描了,还是要交换)
//题目中除val的元素要求的必须都在 不能没有啊 也就是不能覆盖
nums[first] = nums[end];
end --;
}
else
first ++;
}
return end + 1;
}
};
int main() {
vector<int> nums ={3,3};
int length = Solution().removeElement(nums, 3);
cout << length << endl;
}
|
72daba7379fa862076cd2dace3638bf88fa14499
|
3d1364484f490017629447873461ec9250b2193d
|
/EHC/src/rts/mm/basic/dll.cc
|
3a6f43ebf76172989bd793380aaea94b8f93a10d
|
[
"BSD-3-Clause",
"BSD-2-Clause"
] |
permissive
|
UU-ComputerScience/uhc
|
531871caa7f24e098bf76e615907955701308464
|
f2b94a90d26e2093d84044b3832a9a3e3c36b129
|
refs/heads/master
| 2021-08-27T22:35:55.556118
| 2018-01-01T22:34:54
| 2018-01-01T22:34:54
| 4,096,511
| 102
| 18
| null | 2021-08-18T21:20:35
| 2012-04-21T14:05:31
|
Haskell
|
UTF-8
|
C++
| false
| false
| 1,002
|
cc
|
dll.cc
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Memory management: Doubly linked list
%%% see associated .ch file for more info.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%[8
#include "../../rts.h"
%%]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% DLL
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%[8
Bool mm_dll_IsEmpty( MM_DLL* dll ) {
return dll->next == dll ;
}
void mm_dll_Init( MM_DLL* dll ) {
dll->next = dll->prev = dll ;
}
void mm_dll_InsertNext( MM_DLL* dllNew, MM_DLL* dll ) {
dllNew->prev = dll ;
dllNew->next = dll->next ;
dll->next->prev = dllNew ;
dll->next = dllNew ;
}
void mm_dll_InsertPrev( MM_DLL* dllNew, MM_DLL* dll ) {
mm_dll_InsertNext( dllNew, dll->prev ) ;
}
void mm_dll_Delete( MM_DLL* dll ) {
dll->next->prev = dll->prev ;
dll->prev->next = dll->next ;
}
%%]
|
b76e2a5f1bdbf69b2bcaea4e8ecfe0cfebbe1d67
|
7888f2f75d277c64bfc71009ec0eb32bc45a1681
|
/Arquivos_Curso_Arduino/arduino_aulas_72/code/Aula_72/Aula_72.ino
|
15314ccb0280ea2a41a289c50f4a407001b21aa3
|
[
"MIT"
] |
permissive
|
maledicente/cursos
|
bba06a0d09037fd8cae69927c996805d513ddb25
|
00ace48da7e48b04485e4ca97b3ca9ba5f33a283
|
refs/heads/master
| 2023-08-12T03:01:02.799974
| 2021-10-11T14:29:35
| 2021-10-11T14:29:35
| 273,795,405
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 268
|
ino
|
Aula_72.ino
|
#define pinorele 7
#define pinosom 4
bool rele;
void setup() {
pinMode(pinorele,OUTPUT);
pinMode(pinosom,INPUT);
rele=false;
digitalWrite(pinorele,rele);
}
void loop() {
if(digitalRead(pinosom)==HIGH){
rele=!rele;
}
digitalWrite(pinorele,rele);
}
|
32062c20be8f183f002eaae707553a8c0156eb83
|
f8487e487684f4bc51f53b73c9080344bcb69c64
|
/src/167.cpp
|
403274daf38e0c365d555767eec7d5b28d0f0016
|
[] |
no_license
|
export-default/uva-problems
|
7a7c1def58d14fa38a953e35f7cf9e457ad727be
|
c66b492e0cfa1c0c88d6c2434f546d074f36449c
|
refs/heads/master
| 2021-05-29T06:26:44.946585
| 2015-06-24T07:51:39
| 2015-06-24T07:51:39
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,137
|
cpp
|
167.cpp
|
#include <iostream>
#include <cstring>
#include <vector>
#include <array>
#include <cmath>
#include <algorithm>
#include <iomanip>
// https://uva.onlinejudge.org/external/1/167.html
constexpr int N = 8;
int board[N][N];
int pos[N];
int maxsum = -1;
bool place(int r, int c) {
for (int i = 0; i < r; ++i) {
if (pos[i] == c || std::abs(r - i) == std::abs(c - pos[i])) {
return false;
}
}
return true;
}
int backtrack(int r, int acc) {
if (r == N) {
maxsum = std::max(maxsum, acc);
} else {
for (int c = 0; c < N; ++c) {
if (place(r, c)) {
pos[r] = c;
backtrack(r + 1, acc + board[r][c]);
}
}
}
}
int highest_score() {
maxsum = -1;
backtrack(0, 0);
return maxsum;
}
int main() {
int k;
std::cin >> k;
for (int icase = 0; icase < k; ++icase) {
for (int i = 0; i < N; ++i) {
for (int j = 0; j < N; ++j) {
std::cin >> board[i][j];
}
}
std::cout << std::setw(5) << std::right << highest_score() << std::endl;
}
}
|
2fc8ce80dc5fcb9fbfdc2bf2385b44689cf4a1c4
|
7f597f759afc110477cf4779a9d3f0b1e6e4c096
|
/DuggooEngine/src/utils/file_io.cpp
|
01e2b6f5cc1c67698be2ca385661abf6f8e8a686
|
[] |
no_license
|
Zn0w/DuggooEngine
|
52454fa08b10f5abd085e6b0774c85ef19a41c92
|
64fe037176f52d7c7f0ba872927271e00254b3ec
|
refs/heads/master
| 2020-04-03T03:38:24.670435
| 2019-10-23T06:33:13
| 2019-10-23T06:33:13
| 154,991,353
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 570
|
cpp
|
file_io.cpp
|
#include "file_io.h"
namespace dg {
std::string readFile(const char* filepath)
{
FILE* file = fopen(filepath, "rt"); // rt stands for 'read text'
fseek(file, 0, SEEK_END); // go to the end of file
unsigned long length = ftell(file); // tell the amount of passed bytes
char* data = (char*)malloc(length + 1); // +1 for termination character
memset(data, 0, length + 1);
fseek(file, 0, SEEK_SET); // go to the beggining of the file
fread(data, 1, length, file);
fclose(file);
std::string result(data);
free(data);
return result;
}
}
|
997996b10491286252a65dc2f22cc9fe3ebc5107
|
2b1711e7cca1fdd5125d0fbb614e2a4f11b281d4
|
/paymasters.cpp
|
273234262d6032f3d0f534cce0199c676840229c
|
[] |
no_license
|
Depik400/Kursovoi
|
86769b7a6d4ae487e8c0ddcf627e8fb202e1191d
|
c84115f3fec683ff22fd493cc8356fc9416131d3
|
refs/heads/master
| 2020-12-01T02:55:25.473980
| 2019-12-28T02:13:48
| 2019-12-28T02:13:48
| 230,545,838
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,558
|
cpp
|
paymasters.cpp
|
#include "paymasters.h"
#include "ui_paymasters.h"
#include "admins.h"
#include "anyStruct.h"
#include "admintableplanes.h"
#include "userlist.h"
#include "passengertable.h"
paymasters::paymasters(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::paymasters)
{
ui->setupUi(this);
ui->BackToAdminWindow->setVisible(false);ui->BackToAdminWindow->setEnabled(false);
}
paymasters::~paymasters()
{
delete ui;
}
void paymasters::on_Logout_clicked()
{
emit ReturnToAuth();
close();
}
void paymasters::MakeUserParameters(UserParameters &Temp)
{
User = Temp;
ui->UserParam->setText(QString(tr("%1:[%2]")).arg(User.FirstName).arg(User.Group));
}
void paymasters::MakePaymasterFromAdmin()
{
ui->BackToAdminWindow->setVisible(true);ui->BackToAdminWindow->setEnabled(true);
}
void paymasters::on_Planes_clicked()
{
AdminTablePlanes *Planes = new AdminTablePlanes();
Planes->setWindowModality(Qt::ApplicationModal);
Planes->MakeWindowForPayMaster();
Planes->show();
}
void paymasters::on_UserList_clicked()
{
UserList *userlist = new UserList();
userlist->setWindowModality(Qt::ApplicationModal);
userlist->SetPayMasterAccess();
userlist->show();
}
void paymasters::on_PassengerList_clicked()
{
PassengerTable *passTable = new PassengerTable();
passTable->setWindowModality(Qt::ApplicationModal);
passTable->show();
}
void paymasters::on_BackToAdminWindow_clicked()
{
emit MakeAdminWin(User);
close();
}
|
2fc78961920bc5fa794bf5dbe1ba1cef299b3f14
|
2fec3c84e6b2fa675857e00cc6dc0aaacc8dc969
|
/ObjectARX 2016/inc/dbid_ops.h
|
ebe393b95f8a1f65b12d87d74275b32676c5ea0c
|
[
"MIT"
] |
permissive
|
presscad/AutoCADPlugin-HeatSource
|
7feb3c26b31814e0899bd10ff39a2e7c72bc764d
|
ab0865402b41fe45d3b509c01c6f114d128522a8
|
refs/heads/master
| 2020-08-27T04:22:23.237379
| 2016-06-24T07:30:15
| 2016-06-24T07:30:15
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,134
|
h
|
dbid_ops.h
|
//////////////////////////////////////////////////////////////////////////////
//
// Copyright 2015 Autodesk, Inc. All rights reserved.
//
// Use of this software is subject to the terms of the Autodesk license
// agreement provided at the time of installation or download, or which
// otherwise accompanies this software in either electronic or hard copy form.
//
//////////////////////////////////////////////////////////////////////////////
//
//
// DESCRIPTION:
//
// This file declares functions called by the app versions of the comparison
// operators of class AcDbObjectId. This file currently contains the c4
// versions of these functions and will be updated to contain c5 versions
// of these functions. Adjacent apps that compile against c4 will thus not
// experience behavioral changes when c5 AutoCAD ships. However, by
// recompiling against c5, adjacent apps can pick up the modified behavior
// of these operators, as the operators themselves will be modified to
// call the new functions in the header dbidapps.h
//
// Presumably, this file will be eliminated, and these functions will be
// collapsed back into dbid.h as inlines, at a later date.
//
// For further description of the AcDbObjectId types, see dbid.h
#ifndef _AD_DBID_OPS_H
#define _AD_DBID_OPS_H 1
#include "adesk.h"
class AcDbStub;
bool
c5ObjIdIsLessThan(const AcDbStub * lhs, const AcDbStub * rhs);
bool
c5ObjIdIsGreaterThan(const AcDbStub * lhs, const AcDbStub * rhs);
bool
c5ObjIdLessThanOrEqual(const AcDbStub * lhs, const AcDbStub * rhs);
bool
c5ObjIdGreaterThanOrEqual(const AcDbStub * lhs, const AcDbStub * rhs);
bool
c5ObjIdIsEqualTo(const AcDbStub * lhs, const AcDbStub * rhs);
bool
c4ObjIdIsLessThan(Adesk::ULongPtr lhs, Adesk::ULongPtr rhs);
bool
c4ObjIdIsGreaterThan(Adesk::ULongPtr lhs, Adesk::ULongPtr rhs);
bool
c4ObjIdLessThanOrEqual(Adesk::ULongPtr lhs, Adesk::ULongPtr rhs);
bool
c4ObjIdGreaterThanOrEqual(Adesk::ULongPtr lhs, Adesk::ULongPtr rhs);
bool
c4ObjIdIsEqualTo(Adesk::ULongPtr lhs, Adesk::ULongPtr rhs);
bool
c4ObjIdNotEqualTo(Adesk::ULongPtr lhs, Adesk::ULongPtr rhs);
#endif
|
b193b6ded81c2d209d5e7850acff19e26825f6f5
|
dc0df97036f7886d873d6aa63e1e0615b8c72826
|
/TextureMaterialMapper/TextureMaterialMapper/MaterialClassifier.cpp
|
962eb58bfff44427a9d654e245eabbe1512da1f1
|
[] |
no_license
|
MinGleP/KHU_TM
|
8eae325bb3b09fc7590c0b6ee5a327f06955ed7a
|
1c5ad02964be05c991c7def2b1c16eb5223d40a2
|
refs/heads/main
| 2023-05-01T05:18:59.378338
| 2021-05-21T10:45:58
| 2021-05-21T10:45:58
| 355,133,306
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 123
|
cpp
|
MaterialClassifier.cpp
|
#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier
//#include "TextureMapper.h"
//#include "FileManager.h"
|
4dea8f835a0416d80a496595c111614e24912b15
|
ab021d5d256716c11aecdeb3dd0d57873c61328a
|
/application/browser/application_service.cc
|
e4c60057b6243d06728de92c75afc75295d2c4bb
|
[
"BSD-3-Clause"
] |
permissive
|
dp7/crosswalk
|
2bf22d1e6eab0029e50db21e499b49b6505f571d
|
507ecac2e06c8abefbaa5b27e72836da34c7429f
|
refs/heads/master
| 2021-01-21T06:11:08.911926
| 2014-09-04T12:55:15
| 2014-09-04T12:55:15
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 9,694
|
cc
|
application_service.cc
|
// Copyright (c) 2013 Intel Corporation. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "xwalk/application/browser/application_service.h"
#include <set>
#include <string>
#include <vector>
#include "base/containers/hash_tables.h"
#include "base/files/file_enumerator.h"
#include "base/file_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "xwalk/application/browser/application.h"
#include "xwalk/application/browser/application_system.h"
#include "xwalk/application/common/application_storage.h"
#include "xwalk/application/common/installer/package.h"
#include "xwalk/application/common/installer/package_installer.h"
#include "xwalk/application/common/application_file_util.h"
#include "xwalk/runtime/browser/runtime_context.h"
#include "xwalk/runtime/browser/runtime.h"
#include "xwalk/runtime/browser/xwalk_runner.h"
#include "xwalk/runtime/common/xwalk_paths.h"
#if defined(OS_TIZEN)
#include "xwalk/application/browser/application_tizen.h"
#endif
namespace xwalk {
namespace application {
namespace {
const base::FilePath::CharType kApplicationDataDirName[] =
FILE_PATH_LITERAL("Storage/ext");
base::FilePath GetStoragePartitionPath(
const base::FilePath& base_path, const std::string& app_id) {
#if defined(OS_WIN)
std::wstring application_id(app_id.begin(), app_id.end());
return base_path.Append(kApplicationDataDirName).Append(application_id);
#else
return base_path.Append(kApplicationDataDirName).Append(app_id);
#endif
}
void CollectUnusedStoragePartitions(RuntimeContext* context,
ApplicationStorage* storage) {
std::vector<std::string> app_ids;
if (!storage->GetInstalledApplicationIDs(app_ids))
return;
scoped_ptr<base::hash_set<base::FilePath> > active_paths(
new base::hash_set<base::FilePath>()); // NOLINT
for (unsigned i = 0; i < app_ids.size(); ++i) {
active_paths->insert(
GetStoragePartitionPath(context->GetPath(), app_ids.at(i)));
}
content::BrowserContext::GarbageCollectStoragePartitions(
context, active_paths.Pass(), base::Bind(&base::DoNothing));
}
} // namespace
ApplicationService::ApplicationService(RuntimeContext* runtime_context,
ApplicationStorage* app_storage)
: runtime_context_(runtime_context),
application_storage_(app_storage) {
CollectUnusedStoragePartitions(runtime_context, app_storage);
}
ApplicationService::~ApplicationService() {
}
Application* ApplicationService::Launch(
scoped_refptr<ApplicationData> application_data,
const Application::LaunchParams& launch_params) {
if (GetApplicationByID(application_data->ID()) != NULL) {
LOG(INFO) << "Application with id: " << application_data->ID()
<< " is already running.";
// FIXME: we need to notify application that it had been attempted
// to invoke and let the application to define the further behavior.
return NULL;
}
#if defined(OS_TIZEN)
Application* application(new ApplicationTizen(application_data,
runtime_context_, this));
#else
Application* application(new Application(application_data,
runtime_context_, this));
#endif
ScopedVector<Application>::iterator app_iter =
applications_.insert(applications_.end(), application);
if (!application->Launch(launch_params)) {
applications_.erase(app_iter);
return NULL;
}
FOR_EACH_OBSERVER(Observer, observers_,
DidLaunchApplication(application));
return application;
}
Application* ApplicationService::Launch(
const std::string& id, const Application::LaunchParams& params) {
scoped_refptr<ApplicationData> application_data =
application_storage_->GetApplicationData(id);
if (!application_data) {
LOG(ERROR) << "Application with id " << id << " is not installed.";
return NULL;
}
return Launch(application_data, params);
}
Application* ApplicationService::Launch(
const base::FilePath& path, const Application::LaunchParams& params) {
if (!base::DirectoryExists(path))
return NULL;
std::string error;
scoped_refptr<ApplicationData> application_data =
LoadApplication(path, Manifest::COMMAND_LINE, &error);
if (!application_data) {
LOG(ERROR) << "Error occurred while trying to launch application: "
<< error;
return NULL;
}
return Launch(application_data, params);
}
namespace {
struct ApplicationRenderHostIDComparator {
explicit ApplicationRenderHostIDComparator(int id) : id(id) { }
bool operator() (Application* application) {
return id == application->GetRenderProcessHostID();
}
int id;
};
struct ApplicationIDComparator {
explicit ApplicationIDComparator(const std::string& app_id)
: app_id(app_id) { }
bool operator() (Application* application) {
return app_id == application->id();
}
std::string app_id;
};
} // namespace
Application* ApplicationService::GetApplicationByRenderHostID(int id) const {
ApplicationRenderHostIDComparator comparator(id);
ScopedVector<Application>::const_iterator found = std::find_if(
applications_.begin(), applications_.end(), comparator);
if (found != applications_.end())
return *found;
return NULL;
}
Application* ApplicationService::GetApplicationByID(
const std::string& app_id) const {
ApplicationIDComparator comparator(app_id);
ScopedVector<Application>::const_iterator found = std::find_if(
applications_.begin(), applications_.end(), comparator);
if (found != applications_.end())
return *found;
return NULL;
}
void ApplicationService::AddObserver(Observer* observer) {
observers_.AddObserver(observer);
}
void ApplicationService::RemoveObserver(Observer* observer) {
observers_.RemoveObserver(observer);
}
void ApplicationService::OnApplicationTerminated(
Application* application) {
ScopedVector<Application>::iterator found = std::find(
applications_.begin(), applications_.end(), application);
CHECK(found != applications_.end());
FOR_EACH_OBSERVER(Observer, observers_,
WillDestroyApplication(application));
applications_.erase(found);
#if !defined(SHARED_PROCESS_MODE)
if (applications_.empty()) {
base::MessageLoop::current()->PostTask(
FROM_HERE, base::MessageLoop::QuitClosure());
}
#endif
}
void ApplicationService::CheckAPIAccessControl(const std::string& app_id,
const std::string& extension_name,
const std::string& api_name, const PermissionCallback& callback) {
Application* app = GetApplicationByID(app_id);
if (!app) {
LOG(ERROR) << "No running application found with ID: "
<< app_id;
callback.Run(UNDEFINED_RUNTIME_PERM);
return;
}
if (!app->UseExtension(extension_name)) {
LOG(ERROR) << "Can not find extension: "
<< extension_name << " of Application with ID: "
<< app_id;
callback.Run(UNDEFINED_RUNTIME_PERM);
return;
}
// Permission name should have been registered at extension initialization.
std::string permission_name =
app->GetRegisteredPermissionName(extension_name, api_name);
if (permission_name.empty()) {
LOG(ERROR) << "API: " << api_name << " of extension: "
<< extension_name << " not registered!";
callback.Run(UNDEFINED_RUNTIME_PERM);
return;
}
// Okay, since we have the permission name, let's get down to the policies.
// First, find out whether the permission is stored for the current session.
StoredPermission perm = app->GetPermission(
SESSION_PERMISSION, permission_name);
if (perm != UNDEFINED_STORED_PERM) {
// "PROMPT" should not be in the session storage.
DCHECK(perm != PROMPT);
if (perm == ALLOW) {
callback.Run(ALLOW_SESSION);
return;
}
if (perm == DENY) {
callback.Run(DENY_SESSION);
return;
}
NOTREACHED();
}
// Then, query the persistent policy storage.
perm = app->GetPermission(PERSISTENT_PERMISSION, permission_name);
// Permission not found in persistent permission table, normally this should
// not happen because all the permission needed by the application should be
// contained in its manifest, so it also means that the application is asking
// for something wasn't allowed.
if (perm == UNDEFINED_STORED_PERM) {
callback.Run(UNDEFINED_RUNTIME_PERM);
return;
}
if (perm == PROMPT) {
// TODO(Bai): We needed to pop-up a dialog asking user to chose one from
// either allow/deny for session/one shot/forever. Then, we need to update
// the session and persistent policy accordingly.
callback.Run(UNDEFINED_RUNTIME_PERM);
return;
}
if (perm == ALLOW) {
callback.Run(ALLOW_ALWAYS);
return;
}
if (perm == DENY) {
callback.Run(DENY_ALWAYS);
return;
}
NOTREACHED();
}
bool ApplicationService::RegisterPermissions(const std::string& app_id,
const std::string& extension_name,
const std::string& perm_table) {
Application* app = GetApplicationByID(app_id);
if (!app) {
LOG(ERROR) << "No running application found with ID: " << app_id;
return false;
}
if (!app->UseExtension(extension_name)) {
LOG(ERROR) << "Can not find extension: "
<< extension_name << " of Application with ID: "
<< app_id;
return false;
}
return app->RegisterPermissions(extension_name, perm_table);
}
} // namespace application
} // namespace xwalk
|
a2f2b9272e24c24db81ee2a8ab937e25a5844fc7
|
c64016ec8ae73ce00f022dc4825fac590822ee85
|
/test.cpp
|
6aca772e4a5d22c6eaf5395989369cc49872bb0e
|
[] |
no_license
|
YXDsimon/DS-hw4
|
4063b0a06d3ab04c8ff23348921d6048a49ac1ac
|
2996cc9e5999175211362aec753c4f82a91166f2
|
refs/heads/master
| 2023-01-07T05:22:32.582382
| 2020-11-03T13:56:57
| 2020-11-03T13:56:57
| 309,702,910
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 212
|
cpp
|
test.cpp
|
#include <iostream>
#include <string>
using namespace std;
int main()
{
string b="abcdefg";
for (string::iterator Ib = b.begin(); Ib != b.end(); Ib++)
{
cout<<*(b.begin()+1)<<endl;
}
}
|
986bbf887ceeb0f7be4246b61301946082ab2a7e
|
be20587040294afb5724a301333d6eb6aee97291
|
/lib/Gripper/Gripper.cpp
|
4bc627932ce5d1c11dacfa5187392aaa993e41d6
|
[
"MIT"
] |
permissive
|
smart-scaffolding/inchworm_embedded
|
d575bb9ce957884e139d630db92cf98706fb9c17
|
04fe08551c6d259c01d14e320f01e374255016ee
|
refs/heads/master
| 2021-08-18T14:00:40.598470
| 2020-09-13T11:17:03
| 2020-09-13T11:17:03
| 221,782,662
| 0
| 1
| null | 2020-02-12T00:14:20
| 2019-11-14T20:38:13
|
C++
|
UTF-8
|
C++
| false
| false
| 5,034
|
cpp
|
Gripper.cpp
|
/*******************************************************************
* Gripper library that allows to enagage and disengage the grippers
* of the robot. This code is designed for the Vex 29 motor controllers.
*
* April 2020 - Josue Contreras and Trevor Rizzo, Swarm Construction MQP
******************************************************************/
#include "Gripper.h"
////////////////////////////////////////////////////////////////
// CONSTRUCTOR
////////////////////////////////////////////////////////////////
/**
* Empty contructor to build object
**/
Gripper::Gripper(){
}
/**
* Constructor to added object properties. Two arguments are optional, zeroposition:
* sets the middle value for the range of values that are mapped. Threshold is not used
* but could serve to implement the write to motor function.
**/
Gripper::Gripper(int gripperPin, bool rotationDirection, bool isEngaged, int buttonPin, bool gripper){
gripperPin = gripperPin;
buttonPin = buttonPin;
pinMode(buttonPin, INPUT_PULLUP);
turnsItterator = 0;
rotationDirection = rotationDirection;
threshold = threshold;
medianPulse = 1500; //motor stops at this pulse width
isEngaged = false;
if(gripper){
turns=4;
}
else{
turns=144;
}
if(rotationDirection){
maxSpeedCCW = -255;
maxSpeedCW = 255;
maxPulse = 2000; //unique value to VEX 29 motorcontrollers
minPulse = 1000; //unique value to VEX 29 motorcontrollers
}else if(!rotationDirection){
maxSpeedCCW = 255;
maxSpeedCW = -255;
maxPulse = 1000; //unique value to VEX 29 motorcontrollers
minPulse = 2000; //unique value to VEX 29 motorcontrollers
}
grip.attach(gripperPin);
}
// void Gripper::begin(void){
// pinMode(buttonPin, INPUT_PULLUP);
// attachInterrupt(digitalPinToInterrupt(buttonPin), Gripper::intService, RISING);
// }
// static void Gripper::intService(void){
// incrementIterator();
// }
////////////////////////////////////////////////////////////////
// FUNCTIONS
////////////////////////////////////////////////////////////////
/**
* Gripper screw turns functions
**/
void Gripper::incrementIterator(void){
turnsItterator++;
last_update = millis();
}
long Gripper::getTurns(void){
return turnsItterator;
}
void Gripper::resetItterator(void){
turnsItterator = 0;
}
void Gripper::screwTurns(void){
if(analogRead(buttonPin)){
incrementIterator();
}
}
/**
* Motor spins CW for pulse widths less than 1500 uS and CCW
* for pulse widths greater than 1500. map() scales the power to a
* pulse width.
**/
void Gripper::write(int power){
pulseWidth = map(power, maxSpeedCCW, maxSpeedCW, maxPulse, minPulse);
grip.writeMicroseconds(pulseWidth);
}
/**
* For gripper engagment and disengament
* TODO: when button added to gripper, add ticks instead of the time delay.
**/
bool Gripper::setGripper(int gState){
if(resetTime){
resetItterator();
resetTime = false;
last_update = millis();
}
switch(gState){
case 0: //nothing happens
write(0);
gripperFinished = true;
break;
case 1: //engage gripper
if(abs(millis() - last_update) < gripper_wait_timeout){
write(maxSpeedCCW);
gripperFinished = false;
isE = false;
Serial.print("Turns: ");
Serial.println(getTurns());
}else{
write(0);
resetTime = true;
gripperFinished = true;
setEngaged(true);
gState = 0;
}
break;
case 2: //disengage gripper
if(getTurns() < turns+2){
write(maxSpeedCW);
gripperFinished = false;
isE = true;
Serial.print("Turns: ");
Serial.println(getTurns());
}else{
write(0);
resetTime = true;
gripperFinished = true;
setEngaged(false);
}
break;
default: //if none are selected
write(0);
gripperFinished = true;
break;
}
return gripperFinished;
}
//// Funciton that uses time to screw
bool Gripper::setGripperwTime(int gState){
if(resetTime){
startTime = millis();
resetTime = false;
}
switch(gState){
case 0: //nothing happens
write(0);
gripperFinished = true;
break;
case 1: //engage gripper
if((int)(millis() - startTime) < time){
write(maxSpeedCCW);
gripperFinished = false;
isE = false;
}else{
write(0);
resetTime = true;
gripperFinished = true;
setEngaged(true);
}
break;
case 2: //disengage gripper
if((int)(millis() - startTime) < time){
write(maxSpeedCW);
gripperFinished = false;
isE = true;
}else{
write(0);
resetTime = true;
gripperFinished = true;
setEngaged(false);
}
break;
default: //if none are selected
write(0);
gripperFinished = true;
break;
}
return gripperFinished;
}
|
d95b0ff6972f8333ef3590ee50cca9c4ec136104
|
caf47e5b0907cf7e43a7b71354f834caafd86ba7
|
/Competitive-Programming/SPOJ/SHAKTI.cpp
|
751205d385b3063118102ede462efa5d827ecdc5
|
[] |
no_license
|
RudraNilBasu/C-CPP-Codes
|
f16b2ac72a0605eac6ffb65c20180baa7193b45f
|
9412123da4ded00fac9b5c7ab14eae3f9727dace
|
refs/heads/master
| 2021-03-13T01:53:05.550539
| 2018-03-31T17:54:38
| 2018-03-31T17:54:38
| 37,644,826
| 1
| 2
| null | 2019-08-26T21:00:29
| 2015-06-18T07:34:54
|
C++
|
UTF-8
|
C++
| false
| false
| 322
|
cpp
|
SHAKTI.cpp
|
#include<stdio.h>
using namespace std;
int a[1000001];
void pre()
{
a[1]=0; // sorry
int i;
for(i=2;i<=1000000;i++) {
a[i]=!a[i-1];
}
}
int main()
{
pre();
int t,n;
scanf("%d",&t);
while(t--) {
scanf("%d",&n);
if(a[n]) {
printf("Thankyou Shaktiman\n");
} else {
printf("Sorry Shaktiman\n");
}
}
}
|
e3a04bc85f50bf42c03526c0b70f7c381e5101cc
|
55a4fa8f0fe859d9683b5dd826a9b8378a6503df
|
/item/sah_server/include/base_def.h
|
ef7b1bf5a0c3c4427ac467f735826f61cf7f8b38
|
[] |
no_license
|
rongc5/test
|
399536df25d3d3e71cac8552e573f6e2447de631
|
acb4f9254ecf647b8f36743899ae38a901b01aa6
|
refs/heads/master
| 2023-06-26T05:38:37.147507
| 2023-06-15T03:33:08
| 2023-06-15T03:33:08
| 33,905,442
| 2
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,861
|
h
|
base_def.h
|
#ifndef __BASE_DEF_H__
#define __BASE_DEF_H__
#include <sys/socket.h>
#include <sys/epoll.h>
#include <pthread.h>
#include <time.h>
#include <errno.h>
#include <string.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdarg.h>
#include <sys/time.h>
#include <dirent.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <openssl/sha.h>
#include <vector>
#include <string>
#include <list>
#include <map>
#include <set>
#include <deque>
//#include <strstream>
#include <sstream>
#include <exception>
#include <memory>
using namespace std;
#define DAFAULT_EPOLL_SIZE 1000
#define DEFAULT_EPOLL_WAITE 20
#define LOG_DATE_FORMAT "%Y-%m-%d %H:%M:%S"
const size_t SEND_BUF_SIZE = 20 * 1024;
const uint64_t CONNECT_TIME_OUT = 180 * 1000;
const int MAX_RECV_SIZE = 1024*20;
const int MAX_SEND_NUM = 5;
const uint32_t MAX_HTTP_HEAD_LEN = 100*1024;
#define MAX_BUF_SIZE 1024 * 10 * 10
#define DEFAULT_LOG_BUCKETLEN 200
/******** 长度定义 *************/
static const uint32_t SIZE_LEN_16 = 16;
static const uint32_t SIZE_LEN_32 = 32;
static const uint32_t SIZE_LEN_64 = 64;
static const uint32_t SIZE_LEN_128 = 128;
static const uint32_t SIZE_LEN_256 = 256;
static const uint32_t SIZE_LEN_512 = 512;
static const uint32_t SIZE_LEN_1024 = 1024;
static const uint32_t SIZE_LEN_2048 = 2048;
static const uint32_t SIZE_LEN_4096 = 4096;
static const uint32_t SIZE_LEN_8192 = 8192;
static const uint32_t SIZE_LEN_16384 = 16384;
static const uint32_t SIZE_LEN_32768 = 32768;
static const uint32_t SIZE_LEN_65536 = 65536;
/***************************/
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef short int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned int uint32_t;
/*****************************/
#define DEFAULT_LOG_MAX_SIZE 50*1024*1024
const int m_prime_list[] = {
1009, 2003, 3001, 4001, 5003, 6007, 7001, 8009, 9001,
10007, 20011, 30011, 40009, 50021, 60013, 70001, 80021, 90001,
100003, 200003, 300007, 400009, 500009, 600011, 700001, 800011, 900001,
1000003,2000003,3000017,4000037,5000011,6000011,7000003,8000009,9000011,
12582917, 25165843, 50331653, 100663319,
201326611, 402653189, 805306457, 1610612741
};
#define CHANNEL_MSG_TAG "c"
const int URLESCAPE[] =
{
//0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0~15
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,//16~31
1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1,//32~47
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,//48~63
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,//64~79
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0,//80~95
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,//96~111
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0,//112~127
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,//128~143
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,//144~150
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,//160~175
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,//176~191
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,//1192~207
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,//208~223
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,//224~239
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1//240~255
};
#define OBJ_ID_BEGIN 100
#define CRLF "\r\n"
#define CRLF2 "\r\n\r\n"
#endif
|
2c358029294bda63c8efb70a8069fda1bd68079f
|
0eff74b05b60098333ad66cf801bdd93becc9ea4
|
/second/download/mutt/gumtree/mutt_repos_function_290_mutt-1.6.2.cpp
|
919270254fda8fb7f433dd126a77ec7793223192
|
[] |
no_license
|
niuxu18/logTracker-old
|
97543445ea7e414ed40bdc681239365d33418975
|
f2b060f13a0295387fe02187543db124916eb446
|
refs/heads/master
| 2021-09-13T21:39:37.686481
| 2017-12-11T03:36:34
| 2017-12-11T03:36:34
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 966
|
cpp
|
mutt_repos_function_290_mutt-1.6.2.cpp
|
int mutt_account_getpass (ACCOUNT* account)
{
char prompt[SHORT_STRING];
if (account->flags & M_ACCT_PASS)
return 0;
#ifdef USE_IMAP
else if ((account->type == M_ACCT_TYPE_IMAP) && ImapPass)
strfcpy (account->pass, ImapPass, sizeof (account->pass));
#endif
#ifdef USE_POP
else if ((account->type == M_ACCT_TYPE_POP) && PopPass)
strfcpy (account->pass, PopPass, sizeof (account->pass));
#endif
#ifdef USE_SMTP
else if ((account->type == M_ACCT_TYPE_SMTP) && SmtpPass)
strfcpy (account->pass, SmtpPass, sizeof (account->pass));
#endif
else if (option (OPTNOCURSES))
return -1;
else
{
snprintf (prompt, sizeof (prompt), _("Password for %s@%s: "),
account->flags & M_ACCT_LOGIN ? account->login : account->user,
account->host);
account->pass[0] = '\0';
if (mutt_get_password (prompt, account->pass, sizeof (account->pass)))
return -1;
}
account->flags |= M_ACCT_PASS;
return 0;
}
|
ad19ec2258a716d852b58f0698863a74ae120303
|
8509dee8ec888fc4c55b3234f1d3c044e64bb00b
|
/Proj/Project 1/Prepping to make the game/Create Lists/Create Game Pieces/main.cpp
|
f4161157c9eced85c2fde08e20e1a4482a1c7940
|
[] |
no_license
|
SonyaSmalley/SmalleySonya_CSC5_40514
|
5a6ab88b65fcf68753be01e2f84568a70f7c1519
|
13ebe936d86267c9954830d4ae223df5aacb11dc
|
refs/heads/master
| 2022-10-01T06:20:59.401025
| 2020-06-08T02:13:27
| 2020-06-08T02:13:27
| 257,962,556
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 779
|
cpp
|
main.cpp
|
/*
* File: main.cpp
* Author: Sonya Smalley
* Created on April 17, 2020, 4:59 PM
* Purpose: Create a file holding the list of game pieces
*/
//System Libraries
#include <iostream>
#include <fstream>
using namespace std;
//Execution Begins Here
int main(int argc, char** argv) {
//Declare Variable Data Types and Constants
ofstream out;
//Open file
out.open("gamePieces.dat");
//Output names of game pieces to the file
out<<"Battleship\n" <<"Car\n" <<"Cat\n" <<"Dog\n"
<<"Guitar\n" <<"Hat\n" <<"Helicopter\n"<<"Iron\n"
<<"Ring\n" <<"Robot\n" <<"Shoe\n"
<<"Thimble\n" <<"Wheelbarrow\n";
//Exit stage right!
out.close();
cout<<"gamePieces.dat file has been created.";
return 0;
}
|
958e8708dad9faccb113f347f271568580c037da
|
769b8509608dcd5443b0de02064108cef82ffd59
|
/Raytracer/main.cpp
|
188ae703b0c06377e5156498041bbec928da9de9
|
[] |
no_license
|
gwengomez/Raytracer---version-ok
|
60509c603210af6cdde2d33b31d6c661f6d19680
|
f6029a8174f2293094668757f63e0756417c6c46
|
refs/heads/master
| 2021-07-07T23:30:58.889925
| 2017-10-04T09:42:21
| 2017-10-04T09:42:21
| 105,752,708
| 0
| 0
| null | null | null | null |
ISO-8859-1
|
C++
| false
| false
| 4,957
|
cpp
|
main.cpp
|
#include<string>
#include <iostream>
#include <vector>
#include "Vecteur3D.h"
#include "Utils.h"
#include "Ray.h"
#include "Sphere.h"
#include "Scene.h"
#include "Box.h"
#include <time.h>
#include <omp.h>
#define M_PI 3.14159265
int main()
{
/*Vecteur3D vecteur0 = Vecteur3D(0, 0, 0);
Vecteur3D vecteur1 = Vecteur3D(1, 2, 3);
Vecteur3D vecteur2 = Vecteur3D(3, 4, 6);
Vecteur3D vecteur3 = Vecteur3D(4, 8, 16);
Vecteur3D vecteur4 = vecteur1.addition(vecteur2); //(4,6,9)
Vecteur3D vecteur5 = vecteur2.soustraction(vecteur1); //(2,2,3)
Vecteur3D vecteur6 = vecteur1.multiplicationTermes(vecteur2); //(3,8,18)
Vecteur3D vecteur7 = vecteur2.divisionTermes(vecteur1); //(3,2,2)
Vecteur3D vecteur7 = vecteur2.divisionTermes(vecteur0); //(0,0,0)
Vecteur3D vecteur8 = vecteur1.multiplicationNombre(5); //(5,10,15)
Vecteur3D vecteur9 = vecteur3.divisionNombre(2); //(2,4,8)
float norme1 = vecteur1.norme(); //3.74165...
float norme2 = vecteur1.normeCarre(); // 14
Vecteur3D vecteur10 = vecteur1.normalize(); //à vérifier à la calculatrice mais en principe correct
Vecteur3D vecteur10 = vecteur0.normalize(); //(0,0,0)
float prodScal = vecteur1.prodScal(vecteur2); //29
Vecteur3D vecteur11 = vecteur1.prodVect(vecteur2); //(0,3,-2)*/
/*float testClamp1 = clamp(5, 2, 10);
float testClamp2 = clamp(1, 2, 10);
float testClamp3 = clamp(15, 2, 10);*/
//save_img();
// Initialise la seed du random
srand(time(0));
Light l = Light(Vecteur3D(0, 0, 0), 200000, 1);
Vecteur3D moy = Vecteur3D(0, 0, 0);
for (auto p : l.getPointsSphere()) {
moy = moy.addition(p.soustraction(l.getPosition()));
}
moy = moy.divisionNombre(l.getPointsSphere().size());
// Caractéristiques de la camera
int const W = 1024;
int const H = 1024;
float fov = 60 * M_PI/180;
Vecteur3D origineCamera = Vecteur3D(0, 0, 20);
// Création des lumieres
//Light l1 = Light(Vecteur3D(0, 20, -35), 250000, 3); // En haut a droite, a la meme profondeur que la sphere centrale
//Light l2 = Light(Vecteur3D(-15, 20, -55), 250000, 3); // En haut a gauche, a la meme profondeur que la sphere centrale
//Light l3 = Light(Vecteur3D(-15, -30, -10), 250000, 3); // En bas a gauche, au premier plan par rapport a la camera
// Creation des spheres
//Sphere s1 = Sphere(Vecteur3D(0, -10, -45), 10, Vecteur3D(1,0,0)); // Sphere centrale, mirroir
//Sphere s2 = Sphere(Vecteur3D(0, -2000-50, 0), 2000, Vecteur3D(0.1, 1, 0.1)); // Sol, vert
//Sphere s3 = Sphere(Vecteur3D(0, 2000+50, 0), 2000, Vecteur3D(0.1, 0.1, 1)); // Plafond, bleu
//Sphere s4 = Sphere(Vecteur3D(-2000 - 50, 0, 0), 2000, Vecteur3D(1, 1, 0.1)); // Mur gauche, jaune
//Sphere s5 = Sphere(Vecteur3D(2000+50, 0, 0), 2000, Vecteur3D(1, 0.1, 1), true); // Mur droit, rose
//Sphere s6 = Sphere(Vecteur3D(0, 0, -2000-100), 2000, Vecteur3D(0.1, 1, 1)); //Mur du fond, cyan
//Sphere s7 = Sphere(Vecteur3D(-25, -30, -80), 15, Vecteur3D(1, 1, 1)); // Sphere en bas a gauche, mirroir
//Sphere s8 = Sphere(Vecteur3D(15, 10, -65), 6, Vecteur3D(1, 0.1, 0.1)); // Sphere en haut legerement a droite, rouge
Light l1 = Light(Vecteur3D(-5, -5, -35), 150000, 3);
Light l2 = Light(Vecteur3D(-5, -5, -45), 150000, 3);
Light l3 = Light(Vecteur3D(-5, 5, -35), 150000, 3);
Light l4 = Light(Vecteur3D(-5, 5, -45), 150000, 3);
Light l5 = Light(Vecteur3D(5, -5, -35), 150000, 3);
Light l6 = Light(Vecteur3D(5, -5, -45), 150000, 3);
Light l7 = Light(Vecteur3D(5, 5, -35), 150000, 3);
Light l8 = Light(Vecteur3D(5, 5, -45), 150000, 3);
Sphere s1 = Sphere(Vecteur3D(-20, -20, -20), 10, Vecteur3D(1, 0, 0));
Sphere s2 = Sphere(Vecteur3D(-20, -20, -60), 10, Vecteur3D(1, 0, 0));
Sphere s3 = Sphere(Vecteur3D(20, -20, -20), 10, Vecteur3D(1, 0, 0));
Sphere s4 = Sphere(Vecteur3D(20, -20, -60), 10, Vecteur3D(1, 0, 0));
Sphere s5 = Sphere(Vecteur3D(-20, 20, -20), 10, Vecteur3D(1, 0, 0));
Sphere s6 = Sphere(Vecteur3D(-20, 20, -60), 10, Vecteur3D(1, 0, 0));
Sphere s7 = Sphere(Vecteur3D(20, 20, -20), 10, Vecteur3D(1, 0, 0));
Sphere s8 = Sphere(Vecteur3D(20, 20, -60), 10, Vecteur3D(1, 0, 0));
// Creation de la scene et ajout des objets
Scene sc = Scene();
sc.addSphere(s1);
sc.addSphere(s2);
sc.addSphere(s3);
sc.addSphere(s4);
sc.addSphere(s5);
sc.addSphere(s6);
sc.addLight(l1);
sc.addLight(l2);
//sc.addLight(l3);
sc.addSphere(s7);
sc.addSphere(s8);
Box boitePrincipale = Box(sc.getSpheres());
// Creation du tableau dynamique contenant les pixels
std::vector<Vecteur3D> pixels(H*W);
int i, j;
#pragma omp parallel
for (i = 0; i < H; i++) {
#pragma omp parallel for schedule(dynamic)
for (j = 0; j < W; j++) {
// Creation du rayon
Ray r = Ray(origineCamera, Vecteur3D(W-j-W/2.0,i-H/2.0,-W/(2.0*tan(fov/2.0))), false);
// Recherche de la couleur du pixel
Vecteur3D couleur = clamp(sc.getCouleur(r, 10), 0, 255);
// On associe au pixel la couleur trouvee
pixels.at(i*W + j) = couleur;;
}
}
// Creation de l'image
save_img(pixels, W, H);
return 0;
}
|
78a0f331f0db9b192ce3876c8276b31ccc1220da
|
81de7d09d92e602d32055b5e84c12d07034e99ce
|
/Tree(트리)/1068_트리.cpp
|
f9d44d6c2ae179d26be75757f773c89e02a4072d
|
[] |
no_license
|
newdeal123/BOJ
|
13499fe476ae1aee2b3174e147b4fafbc071985b
|
20a161e46018fc1baba1710f36d3d29fa3bf20db
|
refs/heads/master
| 2021-08-08T15:41:57.601898
| 2021-06-30T14:41:14
| 2021-06-30T14:41:14
| 164,074,479
| 5
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,818
|
cpp
|
1068_트리.cpp
|
//트리에서 리프 노드란, 자식의 개수가 0인 노드를 말한다.
//
//트리가 주어졌을 때, 노드 중 하나를 제거할 것이다.그 때, 남은 트리에서 리프 노드의 개수를 구하는 프로그램을 작성하시오.
//
//입력
//첫째 줄에 트리의 노드의 개수 N이 주어진다.N은 50보다 작거나 같은 자연수이다.
//둘째 줄에는 0번 노드부터 N - 1번 노드까지, 각 노드의 부모가 주어진다.만약 부모가 없다면(루트) - 1이 주어진다.셋째 줄에는 지울 노드의 번호가 주어진다.
//
//출력
//첫째 줄에 입력으로 주어진 트리에서 입력으로 주어진 노드를 지웠을 때, 리프 노드의 개수를 출력한다.
#include <iostream>
#include <vector>
#define MAX_N 50+2
using namespace std;
int eraseN;
vector <pair<int, bool>> node[MAX_N];
//없앨 부모노드를 인자로받아 bfs로 탐색하면서 bool값을 false로만든다.
void make_false(int parent)
{
for (int i = 0; i < (signed)node[parent].size(); i++)
{
node[parent][i].second = false;
make_false(node[parent][i].first);
}
return;
}
//리프노드를 찾아서 갯수를 반환
int findleaf(int root)
{
if (node[root].size() == 0)
return 1;
int ret = 0;
for (int i = 0; i < (signed) node[root].size(); i++)
{
if (node[root][i].second == true && node[root][i].first != eraseN)
ret += findleaf(node[root][i].first);
}
return ret;
}
int main()
{
int n, root;
cin >> n;
for (int i = 0; i < n; i++)
{
int parent;
cin >> parent;
if (parent == -1)
root = i;
node[parent].push_back(make_pair(i, true));
}
cin >> eraseN;
make_false(eraseN);
if (root == eraseN)
{
cout << "0";
return 0;
}
if (findleaf(root) == 0)
{
cout << "1";
return 0;
}
else
cout << findleaf(root);
}
|
2b50010e44a3b42a28956175cf690b61612a8577
|
dd43b3ef02d5225d57f163c94f6a8e0101451d2d
|
/src/light/lights.h
|
8b20088ddb20a25208fefc88a27a7b04db451037
|
[
"Apache-2.0"
] |
permissive
|
onc/oncgl
|
440714117c1361f64f89a3778df557bd9b05130f
|
521de02321b612e1741a9f3bc6ee6c1a5ae2950b
|
refs/heads/master
| 2021-01-01T16:35:29.955888
| 2019-01-04T21:13:59
| 2019-01-04T21:15:35
| 35,438,140
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,384
|
h
|
lights.h
|
#ifndef ONCGL_LIGHT_LIGHT_H
#define ONCGL_LIGHT_LIGHT_H
#include <glm/glm.hpp>
namespace oncgl {
struct Light {
glm::vec3 color;
float ambient_intensity;
float diffuse_intensity;
Light() {
color = glm::vec3(0.0f);
ambient_intensity = 0.0f;
diffuse_intensity = 0.0f;
}
};
struct DirectionalLight : public Light {
glm::vec3 direction;
DirectionalLight() {
direction = glm::vec3(0.0f);
}
};
struct PointLight : public Light {
glm::vec3 position;
struct {
float constant;
float linear;
float exp;
} attenuation;
PointLight() {
position = glm::vec3(0.0f);
attenuation.constant = 0.0f;
attenuation.linear = 0.0f;
attenuation.exp = 0.0f;
}
/**
* Calculate the bounding-box of the point-light
* The bounding-box is calculated with the attenuation of the light
*
* @returns size of the bounding-box
*/
float CalcBoundingSphere() {
float max_channel = glm::max(glm::max(color.r, color.g), color.b);
return (-attenuation.linear +
glm::sqrt(attenuation.linear * attenuation.linear -
4 * attenuation.exp * (attenuation.exp -
256 * max_channel *
diffuse_intensity))) / 2 *
attenuation.exp;
}
};
} // namespace oncgl
#endif // ONCGL_LIGHT_LIGHT_H
|
da26e9b595337babfe1f0225c7fec54cf75f6972
|
53eae972ba1aae7252930fe7d9e2ed6e96fbfec7
|
/plugboard.cpp
|
831d4c75fa2ff40707abf16ccbe54e2662245fe6
|
[] |
no_license
|
lohyenjeong/Enigma
|
64e0c127caee77ca0255d5afeafb920c427523b5
|
24f84730755e3a5b318eaa6c55d16a9f7d4aa09f
|
refs/heads/master
| 2020-04-03T09:55:32.398403
| 2016-06-14T01:14:04
| 2016-06-14T01:14:04
| 61,080,560
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,754
|
cpp
|
plugboard.cpp
|
#include <iostream>
#include <fstream>
using namespace std;
#include "errors.h"
#include "plugboard.h"
//Function that calls other helper parameters to check the validity of the data
//Returns the relevant error_code if there is an error
//Else returns NO_ERROR
int Plugboard :: check_file(ifstream &data_map){
int error_code = NO_ERROR;
int data_point;
vector<int> data_inputs;
while(data_map >> skipws >> data_point)
data_inputs.push_back(data_point);
int data_size = data_inputs.size();
data_map.clear();
data_map.seekg(0);
//Checks for non-numerials in the input file
error_code = check_non_numeric(data_map);
if(error_code)
return error_code;
//Checks for invalid index (negative numbers of numbers larger than 25)
error_code = check_valid_index(data_inputs, data_size);
if(error_code)
return error_code;
//Checks whether each of the plugboard's parameters are paired
if(check_odd(data_inputs, data_size)){
error_code = INCORRECT_NUMBER_OF_PLUGBOARD_PARAMETERS;
return error_code;
}
//Checks whether there are less than 26 parameters
if(check_size(data_inputs, data_size)){
error_code = INCORRECT_NUMBER_OF_PLUGBOARD_PARAMETERS;
return error_code;
}
//Checks whether there is a repeat in the data
if(check_repeat(data_inputs, data_size)){
error_code = IMPOSSIBLE_PLUGBOARD_CONFIGURATION;
return error_code;
}
return error_code;
}
//Helper function that checks that the data size is not more than 26
//Returns 1 if there is
//Else returns 0
bool Plugboard :: check_size(vector<int>data_inputs, int data_size){
if(data_size > 26){
cerr << "Incorrect number of parameters in ";
return true;
}
else
return false;
}
|
5b4a0d3ade2a10140349144e7c0c9002519c767a
|
dc81c76a02995eb140d10a62588e3791a8c7de0d
|
/HiFreTrade/ShFuGateway/PositionDetailMsg.h
|
55405d347db0c75528349ae0c512b303d91089e5
|
[] |
no_license
|
xbotuk/cpp-proto-net
|
ab971a94899da7749b35d6586202bb4c52991461
|
d685bee57c8bf0e4ec2db0bfa21d028fa90240fd
|
refs/heads/master
| 2023-08-17T00:52:03.883886
| 2016-08-20T03:40:36
| 2016-08-20T03:40:36
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,512
|
h
|
PositionDetailMsg.h
|
#pragma once
#include "message.h"
#include "EntityStructs.h"
#include "ThostFtdcUserApiStruct.h"
class CPositionDetailMsg :
public CMessage
{
public:
CPositionDetailMsg(void);
~CPositionDetailMsg(void);
const PositionDetail* InnerStruct() { return &m_innerData; }
void SetData(CThostFtdcInvestorPositionDetailField* pPosition)
{
SafeStringCopy(m_innerData.caSymbol, pPosition->InstrumentID, SYMBOL_LEN);
SafeStringCopy(m_innerData.caTradeID, pPosition->TradeID, TRADEID_LEN);
m_innerData.cHedgeFlag = pPosition->HedgeFlag;
if(pPosition->Direction == THOST_FTDC_D_Buy)
{
m_innerData.iDirection = LONG_OPEN;
}
else if(pPosition->Direction == THOST_FTDC_D_Sell)
{
m_innerData.iDirection = SHORT_OPEN;
}
SafeStringCopy(m_innerData.caOpenDate, pPosition->OpenDate, TRADINDG_DAY_LEN);
m_innerData.iVolume = pPosition->Volume;
m_innerData.dOpenPrice = pPosition->OpenPrice;
SafeStringCopy(m_innerData.caTradingDay, pPosition->TradingDay, TRADINDG_DAY_LEN);
SafeStringCopy(m_innerData.caExchangeID, pPosition->ExchangeID, EXCHANGEID_LEN);
m_innerData.dCloseProfit = pPosition->CloseProfitByDate;
m_innerData.dPositionProfit = pPosition->PositionProfitByDate;
m_innerData.dMargin = pPosition->Margin;
m_innerData.dMarginRateByMoney = pPosition->MarginRateByMoney;
m_innerData.CloseVolume = pPosition->CloseVolume;
m_innerData.CloseAmount = pPosition->CloseAmount;
}
private:
PositionDetail m_innerData;
};
|
926ac6241aada4df470e585332d6abfa56665313
|
f6d562eca6596cd8fc7cf982a63e64116976ea74
|
/crabpong/main.cpp
|
6fd7131b2990b6ecb936d1d817d263a76fdf0035
|
[] |
no_license
|
karthikramesh18/Crab_Pong
|
3b3d6eb5b9c12ca97eeff0a0c1a2686d9375fde2
|
3db4c6a655f24cc776107d761c04cced1522ec1b
|
refs/heads/master
| 2023-01-01T04:53:53.226187
| 2020-10-28T14:37:26
| 2020-10-28T14:37:26
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,533
|
cpp
|
main.cpp
|
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <math.h>
#include <stdlib.h>
#ifdef __APPLE__
#include <OpenGL/OpenGL.h>
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include "gamedrawer.h"
using namespace std;
const float PI = 3.1415926535f;
//The number of milliseconds between calls to update
const int TIMER_MS = 25;
GameDrawer* gameDrawer;
//Whether the left key is currently depressed
bool isLeftKeyPressed = false;
//Whether the right key is currently depressed
bool isRightKeyPressed = false;
//Starts at 0, then increases until it reaches 2 * PI, then jumps back to 0 and
//repeats. Used to have the camera angle slowly change.
float rotationVar = 0;
void cleanup() {
delete gameDrawer;
cleanupGameDrawer();
}
void handleKeypress(unsigned char key, int x, int y) {
switch (key) {
case '\r': //Enter key
if (gameDrawer->isGameOver()) {
gameDrawer->startNewGame(2.2f, 20);
}
break;
case 27: //Escape key
cleanup();
exit(0);
}
}
void handleSpecialKeypress(int key, int x, int y) {
switch (key) {
case GLUT_KEY_LEFT:
isLeftKeyPressed = true;
if (isRightKeyPressed) {
gameDrawer->setPlayerCrabDir(0);
}
else {
gameDrawer->setPlayerCrabDir(1);
}
break;
case GLUT_KEY_RIGHT:
isRightKeyPressed = true;
if (isLeftKeyPressed) {
gameDrawer->setPlayerCrabDir(0);
}
else {
gameDrawer->setPlayerCrabDir(-1);
}
break;
}
}
void handleSpecialKeyReleased(int key, int x, int y) {
switch (key) {
case GLUT_KEY_LEFT:
isLeftKeyPressed = false;
if (isRightKeyPressed) {
gameDrawer->setPlayerCrabDir(-1);
}
else {
gameDrawer->setPlayerCrabDir(0);
}
break;
case GLUT_KEY_RIGHT:
isRightKeyPressed = false;
if (isLeftKeyPressed) {
gameDrawer->setPlayerCrabDir(1);
}
else {
gameDrawer->setPlayerCrabDir(0);
}
break;
}
}
void initRendering() {
glEnable(GL_DEPTH_TEST);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHTING);
glEnable(GL_NORMALIZE);
glEnable(GL_CULL_FACE);
glShadeModel(GL_SMOOTH);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
initGameDrawer();
}
void handleResize(int w, int h) {
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, (double)w / (double)h, 0.02, 5.0);
}
void drawScene() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.5f, -0.3f, -1.8f);
glRotatef(50, 1, 0, 0);
glRotatef(180, 0, 1, 0);
//This makes the camera rotate slowly over time
glTranslatef(0.5f, 0, 0.5f);
glRotatef(3 * sin(rotationVar), 0, 1, 0);
glTranslatef(-0.5f, 0, -0.5f);
gameDrawer->draw();
glutSwapBuffers();
}
void update(int value) {
gameDrawer->advance((float)TIMER_MS / 1000);
rotationVar += 0.2f * (float)TIMER_MS / 1000;
while (rotationVar > 2 * PI) {
rotationVar -= 2 * PI;
}
glutPostRedisplay();
glutTimerFunc(TIMER_MS, update, 0);
}
int main(int argc, char** argv) {
srand((unsigned int)time(0)); //Seed the random number generator
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(600, 600);
glutCreateWindow("Crabpong Game");
initRendering();
gameDrawer = new GameDrawer();
glutDisplayFunc(drawScene);
glutKeyboardFunc(handleKeypress);
glutSpecialFunc(handleSpecialKeypress);
glutSpecialUpFunc(handleSpecialKeyReleased);
glutReshapeFunc(handleResize);
glutTimerFunc(TIMER_MS, update, 0);
glutMainLoop();
return 0;
}
|
7c873a63f424b19f49f08f86a2228f42941391a5
|
821c3f6235def5b6f7e9d214c3abdcbba3276015
|
/Maman11/Source.cpp
|
9a4dfb8e3e91e60c2d5e92a2e287198cc686302b
|
[] |
no_license
|
mtwig95/basics-Graphics
|
cbed53eafbca2ea7fb0d6032d3d439d9781ed607
|
ed076e94a7df7e81a9606cc1608049dfa5a61816
|
refs/heads/main
| 2023-08-24T00:34:52.771565
| 2021-09-13T17:22:09
| 2021-09-13T17:22:09
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 8,684
|
cpp
|
Source.cpp
|
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <windows.h>
#include <stdlib.h>
#include <iostream>
#define WINDOW_WIDTH 800
#define WINDOW_HEIGHT 700
#define WINDOW_X_OFFSET 0
#define WINDOW_Y_OFFSET 0
void init()
{
glClearColor(0.2, 0.61, 1.0, 0.0); // display window color
glMatrixMode(GL_PROJECTION); // 2D
gluOrtho2D(0.0, 800, 0.0, 700);
glMatrixMode(GL_MODELVIEW);
}
void CAR() {
//The car
glColor3f(0.612, 0.0, 0.612);
glBegin(GL_POLYGON);
glVertex2i(54, 271);
glVertex2i(564, 263);
glVertex2i(564, 310);
glVertex2i(526, 311);
glVertex2i(534, 314);
glVertex2i(550, 337);
glVertex2i(552, 346);
glVertex2i(548, 361);
glVertex2i(540, 371);
glVertex2i(528, 379);
glVertex2i(512, 383);
glVertex2i(457, 466);
glVertex2i(65, 467);
glVertex2i(62, 441);
glVertex2i(61, 432);
glVertex2i(56, 411);
glVertex2i(51, 373);
glVertex2i(46, 330);
glVertex2i(45, 319);
glVertex2i(45, 301);
glVertex2i(46, 285);
glVertex2i(47, 270);
glVertex2i(47, 269);
glEnd();
//Shape of the car
glColor3f(0, 0.0, 0);
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glVertex2i(54, 271);
glVertex2i(564, 263);
glVertex2i(564, 310);
glVertex2i(526, 311);
glVertex2i(534, 314);
glVertex2i(550, 337);
glVertex2i(552, 346);
glVertex2i(548, 361);
glVertex2i(540, 371);
glVertex2i(528, 379);
glVertex2i(512, 383);
glVertex2i(457, 466);
glVertex2i(65, 467);
glVertex2i(62, 441);
glVertex2i(61, 432);
glVertex2i(56, 411);
glVertex2i(51, 373);
glVertex2i(46, 330);
glVertex2i(45, 319);
glVertex2i(45, 301);
glVertex2i(46, 285);
glVertex2i(47, 270);
glVertex2i(47, 269);
glEnd();
//Left window
glColor3f(0.90, 0.90, 0.90);
glBegin(GL_POLYGON);
glVertex2i(80, 457);
glVertex2i(65, 400);
glVertex2i(206, 400);
glVertex2i(206, 457);
glVertex2i(80, 457);
glEnd();
//Middle window
glColor3f(0.90, 0.90, 0.90);
glBegin(GL_POLYGON);
glVertex2i(221, 457);
glVertex2i(221, 400);
glVertex2i(375, 400);
glVertex2i(375, 457);
glVertex2i(221, 457);
glEnd();
//Right window
glColor3f(0.90, 0.90, 0.90);
glBegin(GL_POLYGON);
glVertex2i(387, 457);
glVertex2i(387, 400);
glVertex2i(488, 400);
glVertex2i(454, 457);
glVertex2i(387, 457);
glEnd();
glFlush();
}
void LAND() {
glColor3f(0.9, 0.9, 0.4);
glBegin(GL_POLYGON);
glVertex2i(0, 247);
glVertex2i(0, 0);
glVertex2i(800, 0);
glVertex2i(800, 258);
glVertex2i(780, 267);
glVertex2i(737, 275);
glVertex2i(718, 269);
glVertex2i(693, 253);
glVertex2i(656, 249);
glVertex2i(635, 251);
glVertex2i(618, 264);
glVertex2i(608, 268);
glVertex2i(603, 269);
glVertex2i(571, 269);
glVertex2i(547, 268);
glVertex2i(524, 262);
glVertex2i(461, 248);
glVertex2i(439, 246);
glVertex2i(431, 252);
glVertex2i(407, 259);
glVertex2i(402, 262);
glVertex2i(374, 271);
glVertex2i(343, 268);
glVertex2i(306, 254);
glVertex2i(273, 245);
glVertex2i(240, 248);
glVertex2i(239, 249);
glVertex2i(203, 259);
glVertex2i(173, 266);
glVertex2i(133, 260);
glVertex2i(128, 260);
glVertex2i(126, 259);
glVertex2i(92, 248);
glVertex2i(64, 251);
glVertex2i(52, 256);
glVertex2i(49, 257);
glVertex2i(21, 268);
glVertex2i(9, 269);
glVertex2i(0, 266);
glEnd();
//Small hills of sand
glColor4f(0.9, 0.9, 0.2, 0.8);
glLineWidth(5);
glBegin(GL_LINE_STRIP);
glVertex2i(470, 199);
glVertex2i(491, 208);
glVertex2i(526, 213);
glVertex2i(544, 209);
glVertex2i(553, 201);
glVertex2i(558, 197);
glEnd();
glColor4f(0.9, 0.9, 0.2, 0.8);
glLineWidth(5);
glBegin(GL_LINE_STRIP);
glVertex2i(584, 120);
glVertex2i(611, 142);
glVertex2i(655, 147);
glVertex2i(683, 117);
glVertex2i(687, 98);
glEnd();
glColor4f(0.9, 0.9, 0.2, 0.8);
glLineWidth(5);
glBegin(GL_LINE_STRIP);
glVertex2i(14, 180);
glVertex2i(52, 205);
glVertex2i(83, 207);
glVertex2i(106, 202);
glVertex2i(120, 183);
glVertex2i(119, 166);
glEnd();
glColor4f(0.9, 0.9, 0.0, 0.8);
glLineWidth(5);
glBegin(GL_LINE_STRIP);
glVertex2i(241, 151);
glVertex2i(246, 161);
glVertex2i(273, 176);
glVertex2i(314, 185);
glVertex2i(392, 187);
glVertex2i(419, 177);
glVertex2i(468, 159);
glVertex2i(481, 154);
glVertex2i(484, 152);
glEnd();
glColor4f(0.9, 0.9, 0.0, 0.8);
glLineWidth(5);
glBegin(GL_LINE_STRIP);
glVertex2i(392, 69);
glVertex2i(444, 94);
glVertex2i(531, 89);
glVertex2i(578, 66);
glVertex2i(588, 56);
glEnd();
glColor4f(0.9, 0.8, 0.1, 0.8);
glLineWidth(5);
glBegin(GL_LINE_STRIP);
glVertex2i(14, 104);
glVertex2i(14, 104);
glVertex2i(41, 111);
glVertex2i(65, 119);
glVertex2i(88, 113);
glVertex2i(94, 108);
glVertex2i(105, 105);
glVertex2i(119, 103);
glVertex2i(141, 104);
glVertex2i(151, 106);
glVertex2i(189, 105);
glVertex2i(189, 105);
glEnd();
glColor4f(0.9, 0.8, 0.2, 0.8);
glLineWidth(5);
glBegin(GL_LINE_STRIP);
glVertex2i(142, 20);
glVertex2i(186, 38);
glVertex2i(203, 40);
glVertex2i(234, 40);
glVertex2i(279, 24);
glEnd();
glColor4f(0.9, 0.8, 0.1, 0.8);
glLineWidth(5);
glBegin(GL_LINE_STRIP);
glVertex2i(676, 218);
glVertex2i(688, 243);
glVertex2i(717, 266);
glVertex2i(731, 273);
glVertex2i(759, 268);
glVertex2i(767, 265);
glVertex2i(787, 259);
glVertex2i(792, 255);
glVertex2i(794, 253);
glVertex2i(796, 253);
glVertex2i(798, 251);
glEnd();
glFlush();
}
void WHEEL(GLfloat x, GLfloat y, GLfloat radius) {
GLfloat twicePi = 2.0f * 3.14;
glColor3f(0.0, 0.0, 0.0);
glBegin(GL_TRIANGLE_FAN);
glVertex2f(x, y); // center of circle
for (int i = 0; i <= 20; i++) {
glVertex2f(
x + (radius * cos(i * twicePi / 20)),
y + (radius * sin(i * twicePi / 20))
);
}
glEnd();
}
void NAME()
{
glColor3f(0, 0, 0);
glBegin(GL_POLYGON);
glVertex2i(0, 0);
glVertex2i(0, 400);
glVertex2i(400, 400);
glVertex2i(400, 0);
glEnd();
glColor3f(1, 0, 0);
glRasterPos2i(108, 230);
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'M');
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'a');
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'y');
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 't');
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'a');
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'l');
glRasterPos2i(100, 300);
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'T');
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'w');
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'i');
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'g');
glFlush();
}
void TITLE() // //An old dream
{
glColor3f(1, 1, 1);
glRasterPos2i(131, 500);
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'A');
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'n');
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, ' ');
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'o');
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'l');
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'd');
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, ' ');
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'd');
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'r');
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'e');
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'a');
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'm');
glFlush();
}
void EXIT()
{
glColor3f(1, 0.0, 0.0);
glBegin(GL_POLYGON);
glVertex2i(0, 0);
glVertex2i(0, 130);
glVertex2i(400, 130);
glVertex2i(400, 0);
glEnd();
glColor3f(0.30, 0.30, 0.30);
glRasterPos2i(85, 36);
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, 'E');
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, 'X');
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, 'I');
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, 'T');
glFlush();
}
void Display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glViewport(0, 0, 800, 800);
TITLE();
LAND();
CAR();
WHEEL(130, 256, 34);
WHEEL(376, 256, 34);
glViewport(50, 50, 200, 200);
NAME();
EXIT();
glFlush();
}
void mouseEscape(int button, int state, int x, int y)
{
if (button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN && x <= 148 && x >= 49 && y <= 649 && y >= 614)
{
glutDestroyWindow(glutGetWindow());
exit(0);
glutPostRedisplay();
}
}
void InitGlut(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT);
glutInitWindowPosition(WINDOW_X_OFFSET, WINDOW_Y_OFFSET);
glutCreateWindow("Maman 11 - Maytal Twig");
}
void RegisterCallback()
{
glutDisplayFunc(Display);
glutMouseFunc(mouseEscape);
}
void main(int argc, char** argv)
{
InitGlut(argc, argv);
init();
RegisterCallback();
glutMainLoop();
}
|
b4d76c0275f19dbbfdcf1b2f2435d5866be1bd3c
|
e5f21b933297a05f101af5ee27423c630013552d
|
/mem/cache/replacement_policies/ReplacementPolicies.py.cc
|
ba401895e939774ecdb4f4cb40c1207ef733bf25
|
[] |
no_license
|
zhouzhiyong18/gem5
|
467bf5a3dc64a2a548d6534fae0196054fc5a9c1
|
1eeffe8030e45db6b4cd725ffb3dc73d5d04617d
|
refs/heads/master
| 2020-11-24T14:24:02.868358
| 2020-02-25T09:23:21
| 2020-02-25T09:23:21
| 228,190,356
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,792
|
cc
|
ReplacementPolicies.py.cc
|
#include "sim/init.hh"
namespace {
const std::uint8_t data_m5_objects_ReplacementPolicies[] = {
120,156,197,87,109,111,219,54,16,62,249,45,182,19,59,110,
154,151,173,109,6,245,75,225,181,69,60,20,232,176,13,195,
48,184,155,177,0,75,106,48,233,94,252,97,130,44,210,181,
90,201,18,36,185,139,247,181,251,223,219,221,217,98,106,33,
139,50,99,94,44,155,166,30,81,199,187,135,119,199,163,3,
139,79,17,127,223,226,47,238,25,0,18,191,6,120,0,231,
139,158,49,239,21,192,43,128,95,132,65,17,12,89,4,85,
132,145,1,178,4,127,2,188,7,248,117,80,2,89,6,85,
98,180,162,209,50,200,13,80,101,70,171,26,173,128,172,165,
99,235,26,221,0,185,153,162,91,26,173,130,108,128,170,50,
218,212,104,13,228,54,168,26,163,45,141,214,65,222,73,37,
236,104,116,19,228,221,20,221,213,232,22,200,189,20,221,215,
104,3,228,1,168,6,163,31,105,180,9,242,227,20,189,167,
209,109,144,247,83,9,15,52,218,2,121,8,103,237,79,144,
79,247,47,252,180,145,83,72,168,121,60,239,214,176,57,115,
253,151,195,55,202,73,146,61,188,235,218,177,18,42,244,108,
71,249,106,146,244,3,207,117,102,78,186,58,244,82,151,86,
231,30,54,10,96,96,208,26,13,10,180,4,196,186,1,200,
178,56,107,23,240,177,160,38,126,132,141,175,252,142,99,59,
99,213,137,46,37,91,33,137,118,85,220,25,226,148,71,227,
113,187,66,26,85,177,177,172,137,237,43,203,74,234,124,227,
7,114,234,209,109,137,6,204,66,197,157,243,104,170,120,180,
61,140,147,200,70,245,105,180,115,113,97,141,149,45,85,212,
38,125,47,155,248,59,108,134,83,215,147,157,95,190,248,220,
58,249,254,236,184,147,163,87,150,6,196,142,194,25,155,245,
144,36,146,190,21,131,174,132,186,189,227,222,75,209,207,167,
138,218,34,83,85,210,84,209,58,196,159,230,83,53,114,71,
129,21,133,196,86,153,222,163,104,17,196,134,40,167,203,73,
12,56,158,29,199,162,186,68,192,127,204,2,77,245,40,195,
66,147,188,73,57,193,68,190,24,219,19,71,173,202,198,38,
13,124,150,207,70,204,115,89,14,79,246,207,180,8,114,140,
245,178,65,26,63,201,176,65,83,255,216,123,181,42,9,91,
52,176,157,79,130,55,154,222,170,233,164,231,103,87,153,46,
86,54,189,113,83,211,163,219,53,157,244,124,126,133,233,221,
227,254,7,166,23,83,211,159,94,99,58,110,75,111,42,180,
177,225,118,246,190,0,184,255,32,25,108,75,243,134,100,12,
221,112,78,134,75,19,198,143,177,233,171,200,193,49,246,107,
101,6,35,115,232,5,206,219,216,76,2,115,168,76,119,18,
171,40,81,210,180,99,243,68,188,106,87,175,35,144,141,234,
219,145,237,39,27,151,98,19,26,62,76,194,181,209,75,150,
127,69,18,171,154,222,212,183,150,8,214,190,213,204,16,140,
20,210,51,151,117,43,46,91,120,103,157,142,177,3,139,34,
166,192,154,179,206,39,171,199,195,221,27,186,128,127,203,241,
64,122,190,200,196,3,59,150,61,145,129,191,170,245,187,52,
240,73,190,245,17,207,114,171,4,144,170,63,100,8,160,136,
233,10,113,117,74,232,255,171,148,64,72,149,42,77,44,117,
9,169,51,178,73,197,46,150,185,132,108,17,107,52,163,216,
75,147,64,94,218,136,34,157,56,184,96,59,192,230,116,234,
15,85,196,73,195,77,98,51,196,190,16,253,159,226,47,41,
250,35,55,136,220,196,253,67,153,234,157,235,36,238,228,181,
78,45,99,59,49,199,246,59,156,0,255,48,183,152,99,55,
49,35,69,217,194,155,205,243,210,179,27,230,165,223,221,100,
108,122,1,10,167,153,219,141,235,214,83,108,83,146,162,167,
199,152,150,8,153,76,125,139,84,231,74,177,27,4,30,135,
96,207,246,98,149,208,134,133,122,89,225,220,144,153,104,173,
61,31,208,98,156,144,196,214,7,153,108,199,168,241,197,197,
99,198,65,114,83,154,252,191,83,218,125,20,244,115,38,165,
157,94,157,210,118,179,78,109,144,83,47,194,153,53,119,105,
236,124,123,91,86,95,28,172,211,134,7,40,104,64,18,75,
139,101,224,35,195,121,164,84,127,185,90,209,241,217,201,141,
79,181,65,49,137,81,74,225,87,35,43,217,162,67,122,251,
40,63,252,18,156,220,10,117,33,19,31,46,69,159,167,48,
152,98,12,10,83,161,8,147,6,183,235,185,145,32,246,41,
28,200,171,112,207,166,141,154,198,224,129,32,112,216,94,138,
141,185,224,181,17,77,86,252,6,153,157,251,180,77,43,204,
103,20,255,249,81,72,229,68,204,193,74,119,81,112,49,227,
200,196,27,125,32,21,228,38,66,31,144,184,202,230,122,147,
43,47,174,15,120,171,229,141,135,147,47,71,26,251,42,47,
54,43,178,46,43,89,247,175,231,135,211,111,120,189,233,156,
93,55,234,70,171,176,95,214,87,101,191,200,255,117,252,47,
253,13,45,234,158,172,
};
EmbeddedPython embedded_m5_objects_ReplacementPolicies(
"m5/objects/ReplacementPolicies.py",
"/home/zhouzhiyong/gem5/src/mem/cache/replacement_policies/ReplacementPolicies.py",
"m5.objects.ReplacementPolicies",
data_m5_objects_ReplacementPolicies,
1126,
4327);
} // anonymous namespace
|
49d51b6b7f75f64719c70635d44f7870e6a8fa69
|
cd908f420621e976be211a2b6a8943c0091982ed
|
/Source/TurnRoll/MyGameInstance.h
|
86358ed793849c8bd2b7ec5b22c66863bd17c75c
|
[] |
no_license
|
yortortle/TurnRoll
|
ea1c807e915e1b98bc448b0d5ee2d4ada457a9f4
|
a0fb697b42002ccc87df55dc97e0e29a87c8c276
|
refs/heads/master
| 2023-01-20T21:10:39.476812
| 2020-12-03T00:47:30
| 2020-12-03T00:47:30
| 316,487,520
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,616
|
h
|
MyGameInstance.h
|
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "CharacterState.h"
#include "Engine/GameInstance.h"
#include "MyGameInstance.generated.h"
UCLASS()
class TURNROLL_API UMyGameInstance : public UGameInstance
{
GENERATED_BODY()
UMyGameInstance(const class FObjectInitializer& ObjectInitializer);
public:
//array to store the party members loaded
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Instance Data")
TArray<UCharacterState*> PartyMembers;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Instance Data")
TArray<UCharacterState*> FullParty;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Instance Data")
bool InteractNPC;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Instance Data")
float Gold = 25.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSubclassOf<APawn> CharacterRosterOne;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSubclassOf<APawn> CharacterRosterTwo;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSubclassOf<APawn> CharacterRosterThree;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSubclassOf<APawn> CharacterRosterFour;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSubclassOf<APawn> CharacterRosterFive;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSubclassOf<APawn> CharacterRosterSix;
bool ThreeUnlock;
bool FourUnlock;
bool FiveUnlock;
bool SixUnlock;
protected:
bool isInitialized;
public:
void Init();
UFUNCTION(BluePrintCallable)
void SetCharacters(int f1, int f2);
//void SetCharacters(int f1, int f2);
};
|
43d297e0547fe8db162d35fbc92984ef2e25c866
|
8d6eb3df9a1c9366f71b684d8d71565904716d57
|
/2018夏季度/获取阶乘的商的尾数/获取阶乘的商的尾数/demo.cpp
|
23ac46288bdde650488c3f7c024ec70eb83ef8fb
|
[] |
no_license
|
PrimarySS/ACM-ICPC-Part2
|
0087aee60bc9fc3232bc87ec0bf5daa384dd3085
|
ad459c341ff46bae49f19c56504501fd8a82302d
|
refs/heads/master
| 2020-03-28T20:37:46.118708
| 2018-09-17T08:08:37
| 2018-09-17T08:08:37
| 149,088,787
| 2
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 907
|
cpp
|
demo.cpp
|
/*
As the answer can be quite large, it would be enough for Koyomi just to know the last digit of the
answer in decimal representation. And you're here to provide Koyomi with this knowledge.
Input
The first and only line of input contains two space-separated integers a and b (long long).
Output
Output one line containing a single decimal digit — the last digit of the value that interests Koyomi.
Examples
input
2 4
output
2
input
0 10
output
0
*/
#include<iostream>
using namespace std;
int main()
{
long long a,b,aSum = 1,bSum = 1;
//输入a,b阶乘的阶数
cin >> a >> b;
//获得a阶乘的值
for(long long i = 1; i <= a; i++)
{
aSum = aSum * i;
}
//获得b阶乘的值
for(long long i = 1; i <= b; i++)
{
bSum = bSum * i;
}
//获得a,b阶乘的商
long long finalSum = bSum / aSum;
//输出阶乘商的个位数
cout << finalSum % 10 << endl;
return 0;
}
|
a07010bd6aef725acff8f383f637f0f738a99add
|
904ab19e76feb94da8f62f1996af4418ca300fc9
|
/Проект№5.cpp
|
40b7185eec2f4a88d8576d3fef82ec3d3281d95f
|
[] |
no_license
|
Sergey-Chushev/Task
|
fbf86ac720391b2baa10f37eb2e7c698a2694888
|
ef0a2d2abfc2e882075611caaefed00bf2e5b071
|
refs/heads/master
| 2020-07-30T10:25:30.103119
| 2020-01-17T20:16:37
| 2020-01-17T20:16:37
| 210,192,461
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 275
|
cpp
|
Проект№5.cpp
|
#include <iostream>
using namespace std;
int main()
{
double X, x, v, t, a;
cout << "x = ";
cin >> x;
cout << "v = ";
cin >> v;
cout << "t = ";
cin >> t;
a = -9.8;
cout << "X = " << x + v * t + a * t * t / 2;
return 0;
}
|
87d7bec9ed050a18ba386304d0df90fca48b7806
|
0f2aa1ab8e12967951c202b4a4486a8f6b17ec27
|
/Mp3Image.cpp
|
6ff497f9b12c7c05146dec5c34c5ce173d343ff6
|
[] |
no_license
|
otoboku/oggYSEDbgm
|
665d310157039816d73880d0af35b0943543467a
|
852c5f01919c1c692ae2003cd92df040f580c6ea
|
refs/heads/master
| 2021-01-10T05:59:55.582997
| 2015-11-21T12:41:45
| 2015-11-21T12:41:45
| 47,119,086
| 1
| 0
| null | null | null | null |
SHIFT_JIS
|
C++
| false
| false
| 11,463
|
cpp
|
Mp3Image.cpp
|
// Mp3Image.cpp : 実装ファイル
//
#include "stdafx.h"
#include "ogg.h"
#include "Mp3Image.h"
#include <vorbis/codec.h>
#include <vorbis/vorbisfile.h>
extern BOOL miw;
extern CMp3Image *mi;
extern int killw1;
extern OggVorbis_File vf;
void CMp3Image::OnNcDestroy()
{
CDialog::OnNcDestroy();
// TODO: ここにメッセージ ハンドラ コードを追加します。
killw1=1;
}
// CMp3Image ダイアログ
IMPLEMENT_DYNAMIC(CMp3Image, CDialog)
CMp3Image::CMp3Image(CWnd* pParent /*=NULL*/)
: CDialog(CMp3Image::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDI_PL);
}
CMp3Image::~CMp3Image()
{
}
void CMp3Image::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_STATIC1, m_x);
DDX_Control(pDX, IDC_STATIC2, m_y);
DDX_Control(pDX, IDOK, m_close);
}
BEGIN_MESSAGE_MAP(CMp3Image, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_NCDESTROY()
ON_WM_CREATE()
ON_WM_CLOSE()
ON_BN_CLICKED(IDOK, &CMp3Image::OnBnClickedOk)
ON_WM_SIZE()
ON_WM_SIZING()
END_MESSAGE_MAP()
BYTE bufimage[0x30000f];
// CMp3Image メッセージ ハンドラ
BOOL CMp3Image::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: ここに初期化を追加してください
nnn=1;
RECT r;
GetClientRect(&r);
rcm.top=0;rcm.left=0;rcm.right=r.right;rcm.bottom=r.bottom;
m_close.MoveWindow(r.right-50,50,50,50);
m_x.MoveWindow(r.right-50,110,50,50);
m_y.MoveWindow(r.right-50,140,50,50);
return TRUE; // return TRUE unless you set the focus to a control
// 例外 : OCX プロパティ ページは必ず FALSE を返します。
}
//extern TCHAR karento2[1024];
void CMp3Image::Load(CString s)
{
CString s1,s2;
TCHAR env[256];
GetEnvironmentVariable(_T("temp"),env,sizeof(env));
s1=env;s1+="\\";
s2=s1;
CFile ff;
if(ff.Open(s,CFile::modeRead|CFile::shareDenyNone,NULL)==FALSE){
DestroyWindow();
return;
}
UINT size;
int i, enc;
s.MakeLower();
if (s.Right(3) == "mp3"){
ZeroMemory(bufimage, 2005);
ff.Read(bufimage, 2005);
if (bufimage[0x14] == 0 || bufimage[0x14] == 3) enc = 0; else enc = 1;
for (i = 0; i < 2000; i++){
if (bufimage[i] == 0x41 && bufimage[i + 1] == 0x50 && bufimage[i + 2] == 0x49 && bufimage[i + 3] == 0x43){
break;
}
}
if (i == 2000){
DestroyWindow();
return;
}
size = (UINT)bufimage[i + 4];
size <<= 8;
size |= (UINT)bufimage[i + 5];
size <<= 8;
size |= (UINT)bufimage[i + 6];
size <<= 8;
size |= (UINT)bufimage[i + 7];
enc = bufimage[i + 10];
i += (4 + 4 + 3 + 6);
int flg = 0;
if (bufimage[i] == 'p'){ s1 += _T("111.png"); }
else { s1 += _T("111.jpg"); }
s2 += _T("111.bmp");
for (; i<2000; i++){
if (bufimage[i] == 0)
break;
}
i += 2;
if ((bufimage[i] == 0xff || bufimage[i] == 0xfe)){
for (; i<2000; i++){
if (enc == 1){
if (bufimage[i] == 0 && bufimage[i + 1] == 0){
if (bufimage[i + 1] == 0 && bufimage[i + 2] == 0)
flg = 1;
break;
}
}
else{
if (bufimage[i] == 0)
flg = 1;
break;
}
}
if (i == 2000){
DestroyWindow();
return;
}
i += flg;
if (enc == 1)
i += 2;
}
else i++;
}
else if (s.Right(3) == "m4a"){
ZeroMemory(bufimage, sizeof(bufimage));
ff.Read(bufimage, sizeof(bufimage));
if (bufimage[0x14] == 0 || bufimage[0x14] == 3) enc = 0; else enc = 1;
for (i = 0; i < 0x300000; i++){// 00 06 5D 6A 64 61 74 61
if (bufimage[i] == 0x63 && bufimage[i + 1] == 0x6f && bufimage[i + 2] == 0x76 && bufimage[i + 3] == 0x72 && bufimage[i + 8] == 0x64 && bufimage[i + 9] == 0x61 && bufimage[i + 10] == 0x74 && bufimage[i + 11] == 0x61){
break;
}
}
if (i == 0x300000){
DestroyWindow();
return;
}
i += 4;
size = (UINT)bufimage[i];
size <<= 8;
size |= (UINT)bufimage[i + 1];
size <<= 8;
size |= (UINT)bufimage[i + 2];
size <<= 8;
size |= (UINT)bufimage[i + 3];
size -= 16;
i += 16;
if (bufimage[i + 1] == 0x50 && bufimage[i + 2] == 0x4e && bufimage[i + 3] == 0x47){
s1 += _T("111.png");
}else{
s1 += _T("111.jpg");
}
s2 += _T("111.bmp");
}
else if (s.Right(3) == "ogg"){
CString cc;
int vfiii = FALSE;
for (int iii = 0; iii < vf.vc->comments; iii++){
#if _UNICODE
WCHAR *f; f = new WCHAR[0x300000];
MultiByteToWideChar(CP_UTF8, 0, vf.vc->user_comments[iii], -1, f, 0x300000);
cc = f;
delete [] f;
#else
cc = vf.vc->user_comments[iii];
#endif
if (cc.Left(23) == "METADATA_BLOCK_PICTURE="){
vfiii = TRUE;
char *buf = vf.vc->user_comments[iii];
buf += 23;//Base64
int len;
char *decode = b64_decode(buf, strlen(buf),len);
if (decode[1 + 16 + 16 + 10] == 0x50 && decode[2 + 16 + 16 + 10] == 0x4e && decode[3 + 16 + 16 + 10] == 0x47){
s1 += _T("111.png");
}
else{
s1 += _T("111.jpg");
}
s2 += _T("111.bmp");
CFile fff;
if (fff.Open(s1, CFile::modeCreate | CFile::modeWrite, NULL) == TRUE){
fff.Write(decode+16+16+10, len-16-16-10);
fff.Close();
}
free(decode);
}
}
if (vfiii == FALSE){
DestroyWindow();
return;
}
}
else if (s.Right(4) == "flac") {
ZeroMemory(bufimage, sizeof(bufimage));
ff.Read(bufimage, sizeof(bufimage));
for (i = 0; i < 0x300000; i++) {// 00 06 5D 6A 64 61 74 61
if (bufimage[i] == 'i' && bufimage[i + 1] == 'm' && bufimage[i + 2] == 'a' && bufimage[i + 3] == 'g' && bufimage[i + 4] == 'e' && bufimage[i + 5] == '/' && bufimage[i + 6] == 'j' && bufimage[i + 7] == 'p' && bufimage[i + 8] == 'e' && bufimage[i + 9] == 'g') {
s1 += _T("111.jpg");
break;
}
if (bufimage[i] == 'i' && bufimage[i + 1] == 'm' && bufimage[i + 2] == 'a' && bufimage[i + 3] == 'g' && bufimage[i + 4] == 'e' && bufimage[i + 5] == '/' && bufimage[i + 6] == 'p' && bufimage[i + 7] == 'n' && bufimage[i + 8] == 'g') {
s1 += _T("111.png");
break;
}
}
if (i == 0x300000) {
DestroyWindow();
return;
}
i += 30;
size = (UINT)bufimage[i];
size <<= 8;
size |= (UINT)bufimage[i + 1];
size <<= 8;
size |= (UINT)bufimage[i + 2];
size <<= 8;
size |= (UINT)bufimage[i + 3];
i += 4;
s2 += _T("111.bmp");
}
if (s.Right(3) != "ogg"){
int ijk = i;
CFile fff;
if (fff.Open(s1, CFile::modeCreate | CFile::modeWrite, NULL) == FALSE){
int a = 0;
}
i = ijk;
ff.SeekToBegin();
ff.Seek(i, CFile::begin);
char *b = new char[size];
ff.Read(b, size);
fff.Write(b, size);
delete[] b;
ff.Close();
fff.Close();
}
cdc0 = GetDC();
img.Load(s1);
y=img.GetHeight();
x=img.GetWidth();
if(img.Save(s2)!=S_OK){MessageBox(_T("プログラムにバグがあるか未対応形式です。"));
DestroyWindow();
return;}
CFile::Remove(s1);
//bmpsub = CBitmap::FromHandle(img);
HBITMAP hbmp = (HBITMAP)::LoadImage(
NULL, s2, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION );
dc.CreateCompatibleDC(NULL);
bmpsub = CBitmap::FromHandle( hbmp );
dc.SelectObject(bmpsub);
ReleaseDC(cdc0);
CFile::Remove(s2);
CString str;
str.Format(_T("X: %4d"),x);
m_x.SetWindowText(str);
str.Format(_T("Y: %4d"),y);
m_y.SetWindowText(str);
Invalidate(FALSE);
// InvalidateRect(&rect,FALSE);
}
void CMp3Image::OnPaint()
{
CPaintDC dcc(this); // 描画用のデバイス コンテキスト
/* if (IsIconic())
{
SendMessage(WM_ICONERASEBKGND, (WPARAM) dcc.GetSafeHdc(), 0);
// クライアントの矩形領域内の中央
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// アイコンを描画します。
dcc.DrawIcon(x, y, m_hIcon);
}
else
{
*/ //if(plf!=0)
RECT r;
GetClientRect(&r);
SetStretchBltMode(dcc.m_hDC , HALFTONE); //高画質モード
SetBrushOrgEx(dcc.m_hDC, 0, 0, NULL); //ブラシのずれを防止
dcc.StretchBlt(0,0,r.bottom,r.bottom,&dc,0,0,x,y,SRCCOPY); //伸縮
CDialog::OnPaint();
// }
}
int CMp3Image::Create(CWnd *pWnd)
{
m_pParent = NULL;
BOOL bret = CDialog::Create( CMp3Image::IDD, this);
if( bret == TRUE)
ShowWindow( SW_SHOW);
return bret;
}
void CMp3Image::OnClose()
{
// TODO: ここにメッセージ ハンドラ コードを追加するか、既定の処理を呼び出します。
nnn=0;
DestroyWindow();
CDialog::OnClose();
}
BOOL CMp3Image::DestroyWindow()
{
// TODO: ここに特定なコードを追加するか、もしくは基本クラスを呼び出してください。
img.Destroy();
BOOL rr=CDialog::DestroyWindow();
mi=NULL;
if(nnn)
delete this;
miw=0;
return rr;
}
void CMp3Image::OnBnClickedOk()
{
// TODO: ここにコントロール通知ハンドラ コードを追加します。
DestroyWindow();
}
void CMp3Image::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
// TODO: ここにメッセージ ハンドラ コードを追加します。
Invalidate(FALSE);
}
void CMp3Image::OnSizing(UINT fwSide, LPRECT pRect)
{
CDialog::OnSizing(fwSide, pRect);
RECT r,rr;
// TODO: この位置にメッセージ ハンドラ用のコードを追加してください
//左右比を保つ
r.bottom=rcm.bottom;r.top=rcm.top;
r.right=rcm.right;r.left=rcm.left;
int width,height;
int x,y;
double _x1,_y1;
width=r.right-r.left;
height=r.bottom-r.top;
x=r.bottom-r.top; y=r.right-r.left;xx=(double)y; yy=(double)x;//動画の画像の大きさを獲得
r.bottom=pRect->bottom; r.top=pRect->top;
r.right=pRect->right; r.left=pRect->left;
x1=r.bottom - r.top; y1_=r.right - r.left;xx1=(double)y1_; yy1_=(double)x1;//現在のサイズ獲得
_x1=xx1/xx;
_y1=yy1_/yy;
switch(fwSide){
case WMSZ_TOP:
case WMSZ_BOTTOM:
pRect->right=pRect->left+(int)(width*_y1)-(GetSystemMetrics(SM_CYSIZEFRAME)+::GetSystemMetrics(SM_CYCAPTION));
break;
case WMSZ_LEFT:
case WMSZ_RIGHT:
pRect->bottom=pRect->top+(int)(height*_x1)+(GetSystemMetrics(SM_CYSIZEFRAME)+::GetSystemMetrics(SM_CYCAPTION));
break;
case WMSZ_BOTTOMRIGHT:
if(((double)width<(double)height))
pRect->right=pRect->left+(int)(width*_y1);
else
pRect->bottom=pRect->top+(int)(height*_x1);
break;
case WMSZ_TOPLEFT:
if(((double)width<(double)height))
pRect->left=pRect->right-(int)(width*_y1);
else
pRect->top=pRect->bottom-(int)(height*_x1);
break;
case WMSZ_TOPRIGHT:
if(((double)width<(double)height))
pRect->right=pRect->left+(int)(width*_y1);
else
pRect->top=pRect->bottom-(int)(height*_x1);
break;
case WMSZ_BOTTOMLEFT:
if(((double)width<(double)height))
pRect->left=pRect->right-(int)(width*_y1);
else
pRect->bottom=pRect->top+(int)(height*_x1);
break;
}
RECT rrr;
GetClientRect(&rrr);
m_close.MoveWindow(rrr.right-50,50,50,50);
m_x.MoveWindow(rrr.right-50,110,50,50);
m_y.MoveWindow(rrr.right-50,140,50,50);
//SetWindowPos(NULL, 0,0,pRect->right, pRect->bottom, SWP_NOMOVE|SWP_NOOWNERZORDER);
Invalidate(FALSE);
}
|
c7478adfd1d270759a8a47927b3588b655973d7f
|
da81185b72e228a9427b034b90c0c72f6bd99452
|
/Filter_network/Filter_network.cpp
|
27e6eae88375849a0ff14ddd8a81626add9971f8
|
[] |
no_license
|
kkirsanov/visual-process-connector
|
dd8ff0da1de4119c227a337f55fad952d5642795
|
fcadc49bd9ce948d1eff8421af7851245569aa29
|
refs/heads/master
| 2020-03-24T21:00:00.319170
| 2018-07-31T12:03:53
| 2018-07-31T12:03:53
| 143,008,360
| 1
| 0
| null | null | null | null |
WINDOWS-1251
|
C++
| false
| false
| 5,081
|
cpp
|
Filter_network.cpp
|
// Filter_network.cpp : Defines the initialization routines for the DLL.
//
#include "stdafx.h"
#include "Filter_network.h"
#include "NetDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CFilter_networkApp
BEGIN_MESSAGE_MAP(CFilter_networkApp, CWinApp)
END_MESSAGE_MAP()
// CFilter_networkApp construction
CFilter_networkApp::CFilter_networkApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
// The one and only CFilter_networkApp object
CFilter_networkApp theApp;
// CFilter_networkApp initialization
BOOL CFilter_networkApp::InitInstance()
{
CWinApp::InitInstance();
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
return TRUE;
}
extern "C" PLUGIN_API int isCBIRPlugin = TRUE;
extern "C" PLUGIN_API int isFilterPlugin = TRUE;
extern "C" PLUGIN_API Plugin* init(Core *pCore)
{
NetFilter *pIG = new NetFilter(pCore);
return pIG;
}
NetFilter::NetFilter(Core *pCore): Plugin(pCore){
isStopped = false;
remotePort = 3001;
localPort = 3001;
pThread = NULL;
remoteIP=0;
InPin *pPin = new ImageInputPin(this);
inPins.push_back(pPin);
inPins.push_back(new MeasureInputPin(this));
server=NULL;
pluginType = CORE_PLG_FILTER;
name = "Network";
description = "Network";
}
NetFilter::~NetFilter(){
if (server!=NULL)
delete server;
//if (!pThread)
//pThread->
};
UINT NetFilter::DoModal(){
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CNetDlg* dlg = new CNetDlg( &remoteIP, &remotePort, &localPort, NULL);
if(dlg->DoModal()==IDOK){
};
delete dlg;
return MB_OK;
};
UINT proc(LPVOID Param)
{
NetFilter *p = (NetFilter*)Param;
if (p->isStopped)
return 0;
if (p->server){
p->IsWorking = true;
p->isSended=false;
p->server->Listen();
p->server->Start(p->image, p->counter);
if (p->isStopped)
return 0;
delete p->server;
p->server = NULL;
p->isSended=true;
p->IsWorking=false;
p->Next();
}
return 0;
};
Counter NetFilter::Next(){
AFX_MANAGE_STATE(AfxGetStaticModuleState());
/*
проверить подключение
Если подключены по входному пину, то забрать данные из него и отдать в сеть
Если не подключены то произвести подключение по сети, забрать данные из неё и проверить
тип данных.
Если тип изображение, то создать такой пин и вернуть в него данныевернуть в выходной
*/
counter = Counter();
if (inPins[0]->GetLink()){
StartTiming();
//есть подключение - Забрать изображение из пина
if (server==NULL){
isSended = false;
server = new Server(remoteIP, localPort);
ImageInputPin * pin = (ImageInputPin *) (inPins[0]);
Counter count1;
pCore->AddPinRequest(this, pin);
pCore->RunPinRequest(this);
counter = pin->counter;
image = boost::shared_dynamic_cast<Image>(pin->Get());;
//отправить в сеть
if (!isStopped){
pThread = AfxBeginThread(proc, this);
EndTiming();
while (!isSended){
Sleep(10);
tagMSG message;
while (::PeekMessage(&message,NULL,0,0,PM_REMOVE)){
::TranslateMessage(&message);
::DispatchMessage(&message);
};
}
};
}else{
//Сервер есть, нужно просто обновить изображение
if(server->working){
StartTiming();
ImageInputPin * pin = (ImageInputPin *) (inPins[0]);
pCore->AddPinRequest(this, pin);
pCore->RunPinRequest(this);
counter = pin->counter;
image = boost::shared_dynamic_cast<Image>(pin->Get());;
}
}
}else{
StartTiming();
//нет подключения - забрать данные из сети
Server myServer(remoteIP, remotePort);
int type;
void *data = myServer.Recive(type, counter);
if (type!=0){
if (type==1){//image
image = PImage((Image*)data);
};
//проверить количесво созданных выходных пинов
if (outPins.size()==0){
//если 0 - создать новый
outPins.push_back(new SimpleOutImagePin<NetFilter>(this));
}else{
if (outPins.at(0)->GetDataType()!= CORE_DATA_IMAGE){
//delete Pin
outPins.clear();
//create new
outPins.push_back(new SimpleOutImagePin<NetFilter>(this));
}
}
}
}
EndTiming();
tagMSG message;
while (::PeekMessage(&message,NULL,0,0,PM_REMOVE)){
::TranslateMessage(&message);
::DispatchMessage(&message);
};
return counter;
};
void NetFilter::Serialize(CArchive& ar){
if(ar.IsStoring()){
ar<<remoteIP;
ar<<remotePort;
ar<<localPort;
}else{
ar>>remoteIP;
ar>>remotePort;
ar>>localPort;
}
};
|
51b43e1a47f3f5f16a31c9d4adb87f3adaa686fc
|
35bae09e70265d648d34a9c93d6a3c4c2de91282
|
/arihon/cyukyu/3_2/3_2_6_a.cpp
|
ba63efad7b5bb068d1b224ec55dd4cda9a0e799e
|
[] |
no_license
|
min9813/algorithm_contest
|
06e2055776c9ba969a59e31a4512146f26391be5
|
6f565a118150c1207cea014a5608a68f79899dd6
|
refs/heads/master
| 2020-12-27T04:55:16.091152
| 2020-10-31T07:27:14
| 2020-10-31T07:27:14
| 237,772,690
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,633
|
cpp
|
3_2_6_a.cpp
|
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
// #include <prettyprint.hpp>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;++i)
#define repi(i,n) for(ll i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define slf(n) scanf("%lf", &n);
typedef long long ll;
typedef double lf;
static const ll max_n = 1010;
vector<ll> ps(max_n, 0);
vector<ll> ps_comb(max_n*max_n, 0);
// set<ll> ps;
// set<ll> ps_comb;
// static const ll max_col = 10000;
ll N, M;
void Main(){
// bool is_ok = true;
// printf("------------- V=%lld---------\n", V);
ll N, M, p;
sll(N);
sll(M);
rep(i, N){
sll(p);
// ps.insert(-p);
ps[i] = -p;
}
// ps.insert(0);
ps[N] = 0;
sort(ps.begin(), ps.begin()+N+1);
rep(i, N+1){
rep(j,N+1){
ps_comb[i*(N+1)+j] = ps[i] + ps[j];
}
}
sort(ps_comb.begin(), ps_comb.begin()+(N+1)*(N+1));
ll score = 0;
// for(auto p:ps_comb){
rep(i, (N+1)*(N+1)){
// printf("p=%lld, M=%lld\n",p, M);
ll p = ps_comb[i];
if(-p>=M){
continue;
}else{
ll left_point = M + p;
// ll value = -*lower_bound(ps_comb.begin(), ps_comb.end(), -left_point);
ll value = -*lower_bound(ps_comb.begin(), ps_comb.begin()+(N+1)*(N+1), -left_point);
score = max(value - p, score);
}
}
cout << score << endl;
}
int main(){
Main();
return 0;
}
|
61ce2f2a16e881b3df55ca050d5c538aff3881b3
|
9cda3afaca2031392dc82fc683d52edf5fed999a
|
/DirectX11_Starter/Bullet.cpp
|
3ef29aab008b2fca0030f016b0e62d4b020a1f6c
|
[] |
no_license
|
Rek3650/Engines-Project
|
b6b60d1538e8be98c5f85ac00f89714cc9a24140
|
aee7d1214025cc48ed8ffeb578be9eb67ccde0a5
|
refs/heads/master
| 2016-09-10T22:10:15.708514
| 2015-05-18T23:41:19
| 2015-05-18T23:41:19
| 31,022,042
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 850
|
cpp
|
Bullet.cpp
|
#include "Bullet.h"
Bullet::Bullet(GameEntity* _graphics)
{
graphics = _graphics;
lifeSpan = 5;
timeAlive = 0;
direction = XMFLOAT3(0, 0, 0);
speed = 20;
gravity = 1;
active = false;
onGround = false;
}
Bullet::~Bullet(void)
{
}
void Bullet::Fire(XMFLOAT3 dir)
{
direction = XMFLOAT3(dir.x, 0, dir.z);
active = true;
}
void Bullet::setPos(XMFLOAT3 newPos)
{
graphics->geometry->SetTranslation(newPos);
}
void Bullet::Update(float dt)
{
if(!active)
{
graphics->geometry->SetTranslation(XMFLOAT3(0, 500, 0));
}
else
{
timeAlive += dt;
if(timeAlive > lifeSpan)
{
timeAlive = 0;
active = false;
}
XMFLOAT3 position = graphics->geometry->GetPosition();
position = XMFLOAT3(position.x+(direction.x*speed*dt), position.y, position.z+(direction.z*speed*dt));
graphics->geometry->SetTranslation(position);
}
}
|
dafd30196396d4e31ce7aca50f1dedf9c6d768a4
|
9d729a5b30e9f7439595aaa8748382393592fb54
|
/src/libws_diff/DiffPrinter/diffPrinter.cc
|
95e643a5b603e04956b97a08bd04060478440328
|
[
"Apache-2.0"
] |
permissive
|
isabella232/mod_dup
|
40f2fd2b57bbeb052e6e0935693a8719664e30cf
|
531382c8baeaa6781ddd1cfe4748b2dd0dbf328c
|
refs/heads/master
| 2023-06-05T09:41:29.270680
| 2019-03-18T09:31:11
| 2019-03-18T09:31:11
| 379,221,853
| 0
| 0
|
Apache-2.0
| 2021-06-22T10:36:44
| 2021-06-22T09:59:09
| null |
UTF-8
|
C++
| false
| false
| 905
|
cc
|
diffPrinter.cc
|
/*
* diffPrinter.cc
*
* Created on: Apr 8, 2015
* Author: cvallee
*/
#include "diffPrinter.hh"
#include "jsonDiffPrinter.hh"
#include "multilineDiffPrinter.hh"
#include "utf8JsonDiffPrinter.hh"
namespace LibWsDiff {
diffPrinter* diffPrinter::createDiffPrinter(const std::string& id,
const diffTypeAvailable type){
switch (type) {
case diffTypeAvailable::MULTILINE:
return new multilineDiffPrinter(id);
case diffTypeAvailable::JSON:
return new jsonDiffPrinter(id);
default:
//Default Case is the json case
return new utf8JsonDiffPrinter(id);
}
}
std::string diffPrinter::diffTypeStr(diffPrinter::diffTypeAvailable d)
{
switch (d) {
case diffTypeAvailable::MULTILINE:
return "MULTILINE";
case diffTypeAvailable::JSON:
return "SIMPLEJSON";
default:
return "UTF8JSON";
}
}
}; /* namespace LibWsDiff */
|
834d453652b71ddcff1308054db4cc0ce35dec70
|
d14b5d78b72711e4614808051c0364b7bd5d6d98
|
/third_party/llvm-16.0/llvm/include/llvm/MC/MCPseudoProbe.h
|
f5796f5c7948d28af348f11dde337aae30778555
|
[
"Apache-2.0"
] |
permissive
|
google/swiftshader
|
76659addb1c12eb1477050fded1e7d067f2ed25b
|
5be49d4aef266ae6dcc95085e1e3011dad0e7eb7
|
refs/heads/master
| 2023-07-21T23:19:29.415159
| 2023-07-21T19:58:29
| 2023-07-21T20:50:19
| 62,297,898
| 1,981
| 306
|
Apache-2.0
| 2023-07-05T21:29:34
| 2016-06-30T09:25:24
|
C++
|
UTF-8
|
C++
| false
| false
| 15,274
|
h
|
MCPseudoProbe.h
|
//===- MCPseudoProbe.h - Pseudo probe encoding support ---------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file contains the declaration of the MCPseudoProbe to support the pseudo
// probe encoding for AutoFDO. Pseudo probes together with their inline context
// are encoded in a DFS recursive way in the .pseudoprobe sections. For each
// .pseudoprobe section, the encoded binary data consist of a single or mutiple
// function records each for one outlined function. A function record has the
// following format :
//
// FUNCTION BODY (one for each outlined function present in the text section)
// GUID (uint64)
// GUID of the function's source name which may be different from the
// actual binary linkage name. This GUID will be used to decode and
// generate a profile against the source function name.
// NPROBES (ULEB128)
// Number of probes originating from this function.
// NUM_INLINED_FUNCTIONS (ULEB128)
// Number of callees inlined into this function, aka number of
// first-level inlinees
// PROBE RECORDS
// A list of NPROBES entries. Each entry contains:
// INDEX (ULEB128)
// TYPE (uint4)
// 0 - block probe, 1 - indirect call, 2 - direct call
// ATTRIBUTE (uint3)
// 1 - reserved
// ADDRESS_TYPE (uint1)
// 0 - code address for regular probes (for downwards compatibility)
// - GUID of linkage name for sentinel probes
// 1 - address delta
// CODE_ADDRESS (uint64 or ULEB128)
// code address or address delta, depending on ADDRESS_TYPE
// INLINED FUNCTION RECORDS
// A list of NUM_INLINED_FUNCTIONS entries describing each of the inlined
// callees. Each record contains:
// INLINE SITE
// ID of the callsite probe (ULEB128)
// FUNCTION BODY
// A FUNCTION BODY entry describing the inlined function.
//
// TODO: retire the ADDRESS_TYPE encoding for code addresses once compatibility
// is no longer an issue.
//===----------------------------------------------------------------------===//
#ifndef LLVM_MC_MCPSEUDOPROBE_H
#define LLVM_MC_MCPSEUDOPROBE_H
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/PseudoProbe.h"
#include "llvm/Support/ErrorOr.h"
#include <list>
#include <map>
#include <memory>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <vector>
namespace llvm {
class MCSymbol;
class MCObjectStreamer;
class raw_ostream;
enum class MCPseudoProbeFlag {
// If set, indicates that the probe is encoded as an address delta
// instead of a real code address.
AddressDelta = 0x1,
};
// Function descriptor decoded from .pseudo_probe_desc section
struct MCPseudoProbeFuncDesc {
uint64_t FuncGUID = 0;
uint64_t FuncHash = 0;
std::string FuncName;
MCPseudoProbeFuncDesc(uint64_t GUID, uint64_t Hash, StringRef Name)
: FuncGUID(GUID), FuncHash(Hash), FuncName(Name){};
void print(raw_ostream &OS);
};
class MCDecodedPseudoProbe;
// An inline frame has the form <CalleeGuid, ProbeID>
using InlineSite = std::tuple<uint64_t, uint32_t>;
using MCPseudoProbeInlineStack = SmallVector<InlineSite, 8>;
// GUID to PseudoProbeFuncDesc map
using GUIDProbeFunctionMap =
std::unordered_map<uint64_t, MCPseudoProbeFuncDesc>;
// Address to pseudo probes map.
using AddressProbesMap =
std::unordered_map<uint64_t, std::list<MCDecodedPseudoProbe>>;
class MCDecodedPseudoProbeInlineTree;
class MCPseudoProbeBase {
protected:
uint64_t Guid;
uint64_t Index;
uint8_t Attributes;
uint8_t Type;
// The value should be equal to PseudoProbeReservedId::Last + 1 which is
// defined in SampleProfileProbe.h. The header file is not included here to
// reduce the dependency from MC to IPO.
const static uint32_t PseudoProbeFirstId = 1;
public:
MCPseudoProbeBase(uint64_t G, uint64_t I, uint64_t At, uint8_t T)
: Guid(G), Index(I), Attributes(At), Type(T) {}
bool isEntry() const { return Index == PseudoProbeFirstId; }
uint64_t getGuid() const { return Guid; }
uint64_t getIndex() const { return Index; }
uint8_t getAttributes() const { return Attributes; }
uint8_t getType() const { return Type; }
bool isBlock() const {
return Type == static_cast<uint8_t>(PseudoProbeType::Block);
}
bool isIndirectCall() const {
return Type == static_cast<uint8_t>(PseudoProbeType::IndirectCall);
}
bool isDirectCall() const {
return Type == static_cast<uint8_t>(PseudoProbeType::DirectCall);
}
bool isCall() const { return isIndirectCall() || isDirectCall(); }
void setAttributes(uint8_t Attr) { Attributes = Attr; }
};
/// Instances of this class represent a pseudo probe instance for a pseudo probe
/// table entry, which is created during a machine instruction is assembled and
/// uses an address from a temporary label created at the current address in the
/// current section.
class MCPseudoProbe : public MCPseudoProbeBase {
MCSymbol *Label;
public:
MCPseudoProbe(MCSymbol *Label, uint64_t Guid, uint64_t Index, uint64_t Type,
uint64_t Attributes)
: MCPseudoProbeBase(Guid, Index, Attributes, Type), Label(Label) {
assert(Type <= 0xFF && "Probe type too big to encode, exceeding 2^8");
assert(Attributes <= 0xFF &&
"Probe attributes too big to encode, exceeding 2^16");
}
MCSymbol *getLabel() const { return Label; }
void emit(MCObjectStreamer *MCOS, const MCPseudoProbe *LastProbe) const;
};
// Represents a callsite with caller function name and probe id
using MCPseduoProbeFrameLocation = std::pair<StringRef, uint32_t>;
class MCDecodedPseudoProbe : public MCPseudoProbeBase {
uint64_t Address;
MCDecodedPseudoProbeInlineTree *InlineTree;
public:
MCDecodedPseudoProbe(uint64_t Ad, uint64_t G, uint32_t I, PseudoProbeType K,
uint8_t At, MCDecodedPseudoProbeInlineTree *Tree)
: MCPseudoProbeBase(G, I, At, static_cast<uint8_t>(K)), Address(Ad),
InlineTree(Tree){};
uint64_t getAddress() const { return Address; }
void setAddress(uint64_t Addr) { Address = Addr; }
MCDecodedPseudoProbeInlineTree *getInlineTreeNode() const {
return InlineTree;
}
// Get the inlined context by traversing current inline tree backwards,
// each tree node has its InlineSite which is taken as the context.
// \p ContextStack is populated in root to leaf order
void
getInlineContext(SmallVectorImpl<MCPseduoProbeFrameLocation> &ContextStack,
const GUIDProbeFunctionMap &GUID2FuncMAP) const;
// Helper function to get the string from context stack
std::string
getInlineContextStr(const GUIDProbeFunctionMap &GUID2FuncMAP) const;
// Print pseudo probe while disassembling
void print(raw_ostream &OS, const GUIDProbeFunctionMap &GUID2FuncMAP,
bool ShowName) const;
};
template <typename ProbeType, typename DerivedProbeInlineTreeType>
class MCPseudoProbeInlineTreeBase {
struct InlineSiteHash {
uint64_t operator()(const InlineSite &Site) const {
return std::get<0>(Site) ^ std::get<1>(Site);
}
};
protected:
// Track children (e.g. inlinees) of current context
using InlinedProbeTreeMap = std::unordered_map<
InlineSite, std::unique_ptr<DerivedProbeInlineTreeType>, InlineSiteHash>;
InlinedProbeTreeMap Children;
// Set of probes that come with the function.
std::vector<ProbeType> Probes;
MCPseudoProbeInlineTreeBase() {
static_assert(std::is_base_of<MCPseudoProbeInlineTreeBase,
DerivedProbeInlineTreeType>::value,
"DerivedProbeInlineTreeType must be subclass of "
"MCPseudoProbeInlineTreeBase");
}
public:
uint64_t Guid = 0;
// Root node has a GUID 0.
bool isRoot() const { return Guid == 0; }
InlinedProbeTreeMap &getChildren() { return Children; }
const InlinedProbeTreeMap &getChildren() const { return Children; }
std::vector<ProbeType> &getProbes() { return Probes; }
void addProbes(ProbeType Probe) { Probes.push_back(Probe); }
// Caller node of the inline site
MCPseudoProbeInlineTreeBase<ProbeType, DerivedProbeInlineTreeType> *Parent;
DerivedProbeInlineTreeType *getOrAddNode(const InlineSite &Site) {
auto Ret = Children.emplace(
Site, std::make_unique<DerivedProbeInlineTreeType>(Site));
Ret.first->second->Parent = this;
return Ret.first->second.get();
};
};
// A Tri-tree based data structure to group probes by inline stack.
// A tree is allocated for a standalone .text section. A fake
// instance is created as the root of a tree.
// A real instance of this class is created for each function, either a
// not inlined function that has code in .text section or an inlined function.
class MCPseudoProbeInlineTree
: public MCPseudoProbeInlineTreeBase<MCPseudoProbe,
MCPseudoProbeInlineTree> {
public:
MCPseudoProbeInlineTree() = default;
MCPseudoProbeInlineTree(uint64_t Guid) { this->Guid = Guid; }
MCPseudoProbeInlineTree(const InlineSite &Site) {
this->Guid = std::get<0>(Site);
}
// MCPseudoProbeInlineTree method based on Inlinees
void addPseudoProbe(const MCPseudoProbe &Probe,
const MCPseudoProbeInlineStack &InlineStack);
void emit(MCObjectStreamer *MCOS, const MCPseudoProbe *&LastProbe);
};
// inline tree node for the decoded pseudo probe
class MCDecodedPseudoProbeInlineTree
: public MCPseudoProbeInlineTreeBase<MCDecodedPseudoProbe *,
MCDecodedPseudoProbeInlineTree> {
public:
InlineSite ISite;
// Used for decoding
uint32_t ChildrenToProcess = 0;
MCDecodedPseudoProbeInlineTree() = default;
MCDecodedPseudoProbeInlineTree(const InlineSite &Site) : ISite(Site){};
// Return false if it's a dummy inline site
bool hasInlineSite() const { return !isRoot() && !Parent->isRoot(); }
};
/// Instances of this class represent the pseudo probes inserted into a compile
/// unit.
class MCPseudoProbeSections {
public:
void addPseudoProbe(MCSymbol *FuncSym, const MCPseudoProbe &Probe,
const MCPseudoProbeInlineStack &InlineStack) {
MCProbeDivisions[FuncSym].addPseudoProbe(Probe, InlineStack);
}
// TODO: Sort by getOrdinal to ensure a determinstic section order
using MCProbeDivisionMap = std::map<MCSymbol *, MCPseudoProbeInlineTree>;
private:
// A collection of MCPseudoProbe for each function. The MCPseudoProbes are
// grouped by GUIDs due to inlining that can bring probes from different
// functions into one function.
MCProbeDivisionMap MCProbeDivisions;
public:
const MCProbeDivisionMap &getMCProbes() const { return MCProbeDivisions; }
bool empty() const { return MCProbeDivisions.empty(); }
void emit(MCObjectStreamer *MCOS);
};
class MCPseudoProbeTable {
// A collection of MCPseudoProbe in the current module grouped by
// functions. MCPseudoProbes will be encoded into a corresponding
// .pseudoprobe section. With functions emitted as separate comdats,
// a text section really only contains the code of a function solely, and the
// probes associated with the text section will be emitted into a standalone
// .pseudoprobe section that shares the same comdat group with the function.
MCPseudoProbeSections MCProbeSections;
public:
static void emit(MCObjectStreamer *MCOS);
MCPseudoProbeSections &getProbeSections() { return MCProbeSections; }
#ifndef NDEBUG
static int DdgPrintIndent;
#endif
};
class MCPseudoProbeDecoder {
// GUID to PseudoProbeFuncDesc map.
GUIDProbeFunctionMap GUID2FuncDescMap;
// Address to probes map.
AddressProbesMap Address2ProbesMap;
// The dummy root of the inline trie, all the outlined function will directly
// be the children of the dummy root, all the inlined function will be the
// children of its inlineer. So the relation would be like:
// DummyRoot --> OutlinedFunc --> InlinedFunc1 --> InlinedFunc2
MCDecodedPseudoProbeInlineTree DummyInlineRoot;
/// Points to the current location in the buffer.
const uint8_t *Data = nullptr;
/// Points to the end of the buffer.
const uint8_t *End = nullptr;
/// Whether encoding is based on a starting probe with absolute code address.
bool EncodingIsAddrBased = false;
// Decoding helper function
template <typename T> ErrorOr<T> readUnencodedNumber();
template <typename T> ErrorOr<T> readUnsignedNumber();
template <typename T> ErrorOr<T> readSignedNumber();
ErrorOr<StringRef> readString(uint32_t Size);
public:
using Uint64Set = DenseSet<uint64_t>;
using Uint64Map = DenseMap<uint64_t, uint64_t>;
// Decode pseudo_probe_desc section to build GUID to PseudoProbeFuncDesc map.
bool buildGUID2FuncDescMap(const uint8_t *Start, std::size_t Size);
// Decode pseudo_probe section to build address to probes map for specifed
// functions only.
bool buildAddress2ProbeMap(const uint8_t *Start, std::size_t Size,
const Uint64Set &GuildFilter,
const Uint64Map &FuncStartAddrs);
bool buildAddress2ProbeMap(MCDecodedPseudoProbeInlineTree *Cur,
uint64_t &LastAddr, const Uint64Set &GuildFilter,
const Uint64Map &FuncStartAddrs);
// Print pseudo_probe_desc section info
void printGUID2FuncDescMap(raw_ostream &OS);
// Print pseudo_probe section info, used along with show-disassembly
void printProbeForAddress(raw_ostream &OS, uint64_t Address);
// do printProbeForAddress for all addresses
void printProbesForAllAddresses(raw_ostream &OS);
// Look up the probe of a call for the input address
const MCDecodedPseudoProbe *getCallProbeForAddr(uint64_t Address) const;
const MCPseudoProbeFuncDesc *getFuncDescForGUID(uint64_t GUID) const;
// Helper function to populate one probe's inline stack into
// \p InlineContextStack.
// Current leaf location info will be added if IncludeLeaf is true
// Example:
// Current probe(bar:3) inlined at foo:2 then inlined at main:1
// IncludeLeaf = true, Output: [main:1, foo:2, bar:3]
// IncludeLeaf = false, Output: [main:1, foo:2]
void getInlineContextForProbe(
const MCDecodedPseudoProbe *Probe,
SmallVectorImpl<MCPseduoProbeFrameLocation> &InlineContextStack,
bool IncludeLeaf) const;
const AddressProbesMap &getAddress2ProbesMap() const {
return Address2ProbesMap;
}
AddressProbesMap &getAddress2ProbesMap() { return Address2ProbesMap; }
const GUIDProbeFunctionMap &getGUID2FuncDescMap() const {
return GUID2FuncDescMap;
}
const MCPseudoProbeFuncDesc *
getInlinerDescForProbe(const MCDecodedPseudoProbe *Probe) const;
const MCDecodedPseudoProbeInlineTree &getDummyInlineRoot() const {
return DummyInlineRoot;
}
};
} // end namespace llvm
#endif // LLVM_MC_MCPSEUDOPROBE_H
|
c3a5c08a4dd227124192bce67b7a729f78db6b1e
|
f81124e4a52878ceeb3e4b85afca44431ce68af2
|
/re20_2/processor32/10/U
|
ac94dbbe06dc787cd1abaef8498ea79c8c1bf326
|
[] |
no_license
|
chaseguy15/coe-of2
|
7f47a72987638e60fd7491ee1310ee6a153a5c10
|
dc09e8d5f172489eaa32610e08e1ee7fc665068c
|
refs/heads/master
| 2023-03-29T16:59:14.421456
| 2021-04-06T23:26:52
| 2021-04-06T23:26:52
| 355,040,336
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 21,657
|
U
|
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "10";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField nonuniform List<vector>
392
(
(0.122608 -0.00261542 1.09715e-22)
(0.134709 -0.00260066 1.38454e-22)
(0.146743 -0.00258191 -5.65553e-22)
(0.124819 -0.00783494 -4.68491e-21)
(0.136881 -0.00779038 4.18845e-21)
(0.148874 -0.00773387 -1.62616e-21)
(0.129229 -0.0130241 -8.54063e-22)
(0.141211 -0.01295 -3.07352e-21)
(0.153124 -0.012856 4.1577e-21)
(0.164954 -0.0127462 -5.01882e-21)
(0.135811 -0.0181629 1.30692e-21)
(0.147673 -0.0180594 -1.292e-21)
(0.159467 -0.0179285 -3.80029e-21)
(0.171177 -0.0177757 4.56977e-21)
(0.144526 -0.0232312 2.09613e-20)
(0.156229 -0.023099 -1.29895e-21)
(0.167863 -0.0229319 -1.02235e-20)
(0.179414 -0.0227369 2.17496e-21)
(0.166827 -0.028049 -1.77348e-20)
(0.178262 -0.0278468 1.65847e-20)
(0.189615 -0.027611 1.47275e-21)
(0.179405 -0.0328904 -6.64832e-21)
(0.190602 -0.0326544 6.93436e-21)
(0.201717 -0.0323793 -1.50744e-20)
(0.193888 -0.0376042 -1.31378e-20)
(0.204808 -0.0373362 3.66376e-21)
(0.215648 -0.0370239 8.479e-21)
(0.210191 -0.0421723 -4.81673e-21)
(0.220796 -0.0418743 2.43522e-21)
(0.231325 -0.0415271 -1.09435e-20)
(0.228221 -0.0465767 -1.65735e-20)
(0.238473 -0.0462514 -1.90131e-20)
(0.248653 -0.0458724 -9.29436e-21)
(0.247872 -0.0508007 2.15559e-20)
(0.257736 -0.0504512 -4.56212e-20)
(0.267532 -0.0500436 1.95228e-20)
(0.269035 -0.0548281 -4.65256e-20)
(0.278475 -0.0544581 3.74176e-21)
(0.287854 -0.0540259 1.09942e-20)
(0.29159 -0.0586436 3.00123e-21)
(0.300573 -0.0582575 5.74601e-21)
(0.309501 -0.0578052 -2.39896e-20)
(0.315413 -0.0622334 -2.12335e-20)
(0.323906 -0.061836 2.7487e-21)
(0.332354 -0.0613688 -2.3301e-20)
(0.340752 -0.0608448 2.20239e-20)
(0.348348 -0.0651816 -1.12479e-20)
(0.356287 -0.064705 5.79666e-21)
(0.364187 -0.0641684 -2.00339e-21)
(0.373767 -0.0682834 3.62844e-21)
(0.38117 -0.0678038 2.3784e-20)
(0.388547 -0.0672608 -1.28685e-20)
(0.40003 -0.0711321 -2.41155e-20)
(0.406873 -0.0706565 6.70204e-21)
(0.413704 -0.0701138 3.23467e-20)
(0.427 -0.0737204 -4.85964e-21)
(0.433262 -0.0732562 2.89619e-20)
(0.43953 -0.0727211 -6.77091e-21)
(0.454544 -0.076043 1.53963e-20)
(0.460207 -0.0755981 -5.04767e-21)
(0.465893 -0.0750781 -5.34106e-22)
(0.487575 -0.0776767 -1.39901e-20)
(0.492666 -0.0771801 2.48618e-20)
(0.497793 -0.0766173 -1.21558e-20)
(0.515238 -0.0794836 -5.10258e-20)
(0.519723 -0.0790189 2.45942e-20)
(0.524264 -0.0784834 2.40952e-20)
(0.543068 -0.0810279 1.36719e-22)
(0.546941 -0.0806033 -3.3752e-20)
(0.55089 -0.0801029 2.948e-20)
(0.570944 -0.0823778 4.08608e-20)
(0.574202 -0.0819995 -1.88668e-20)
(0.577556 -0.0815397 1.06987e-20)
(0.59875 -0.0835148 2.58634e-20)
(0.601393 -0.0831931 -2.44983e-20)
(0.604154 -0.0827833 3.99421e-20)
(0.649437 -0.0843224 0)
(0.651264 -0.0840445 0)
(0.65323 -0.0836813 0)
(0.723613 -0.0855072 0)
(0.723979 -0.0853923 0)
(0.724531 -0.0851813 0)
(0.797028 -0.085057 0)
(0.795984 -0.0851671 0)
(0.795166 -0.0851656 0)
(0.867694 -0.0830727 0)
(0.865369 -0.0834535 0)
(0.863301 -0.0837049 0)
(0.933895 -0.0798069 0)
(0.930482 -0.0804844 0)
(0.927344 -0.0810142 0)
(0.994265 -0.0755018 0)
(0.990002 -0.0764853 0)
(0.986015 -0.0773042 0)
(1.04785 -0.0704329 0)
(1.04299 -0.0717142 0)
(1.0384 -0.0728167 0)
(1.09412 -0.0648871 0)
(1.08893 -0.0664422 0)
(1.08397 -0.067808 0)
(1.13298 -0.059133 8.03481e-28)
(1.12768 -0.0609256 8.34602e-29)
(1.12258 -0.0625229 7.57987e-28)
(1.16468 -0.0534008 -8.03481e-28)
(1.15946 -0.0553874 -8.34602e-29)
(1.15441 -0.0571769 -7.57987e-28)
(1.18975 -0.0478718 0)
(1.18476 -0.0500061 0)
(1.17989 -0.0519451 0)
(1.20889 -0.0426746 0)
(1.20423 -0.0449116 0)
(1.19965 -0.0469579 0)
(1.22292 -0.0378885 0)
(1.21865 -0.040187 0)
(1.21442 -0.0423018 0)
(1.23268 -0.0335508 0)
(1.22882 -0.0358751 0)
(1.22497 -0.0380241 0)
(1.23898 -0.029666 0)
(1.23552 -0.0319866 7.45605e-29)
(1.23205 -0.034141 6.82509e-28)
(1.24252 -0.0262155 0)
(1.23945 -0.0285088 -7.45605e-29)
(1.23634 -0.0306454 -6.82509e-28)
(1.24397 -0.0231664 6.44472e-11)
(1.24124 -0.0254142 3.16411e-11)
(1.23847 -0.0275148 0)
(1.24383 -0.0204787 -6.44472e-11)
(1.24142 -0.0226672 -3.16411e-11)
(1.23895 -0.0247178 0)
(1.24256 -0.0181102 -3.07253e-29)
(1.24042 -0.0202292 0)
(1.23822 -0.0222191 0)
(1.24048 -0.0160204 3.07253e-29)
(1.23859 -0.0180623 0)
(1.23663 -0.0199837 0)
(1.23787 -0.0141725 0)
(1.23619 -0.0161316 0)
(1.23443 -0.0179784 0)
(1.23493 -0.0125339 0)
(1.23343 -0.014406 0)
(1.23185 -0.0161736 0)
(1.23181 -0.0110769 0)
(1.23047 -0.0128586 0)
(1.22905 -0.0145434 0)
(1.22862 -0.00977799 0)
(1.22742 -0.0114667 0)
(1.22613 -0.0130656 0)
(1.22544 -0.00861743 0)
(1.22436 -0.0102109 0)
(1.22319 -0.0117216 0)
(1.22234 -0.00757861 0)
(1.22136 -0.00907508 0)
(1.2203 -0.0104954 0)
(1.21934 -0.00664746 0)
(1.21846 -0.00804536 0)
(1.21749 -0.00937355 0)
(1.21649 -0.00581185 0)
(1.2157 -0.00710987 0)
(1.21481 -0.00834439 0)
(1.21381 -0.00506118 -2.5596e-29)
(1.2131 -0.00625822 -1.50825e-27)
(1.21228 -0.00739774 0)
(1.21132 -0.00438602 2.5596e-29)
(1.21067 -0.00548116 1.50825e-27)
(1.20992 -0.00652455 0)
(1.20903 -0.00377783 1.00614e-27)
(1.20843 -0.00477032 -1.58477e-27)
(1.20775 -0.00571662 0)
(1.20694 -0.00322876 -1.00614e-27)
(1.2064 -0.00411798 1.58477e-27)
(1.20576 -0.00496639 0)
(1.20508 -0.00273149 -2.45372e-11)
(1.20458 -0.00351695 -2.44406e-11)
(1.20399 -0.00426682 0)
(1.20343 -0.00227912 2.45372e-11)
(1.20297 -0.00296044 2.44406e-11)
(1.20242 -0.00361123 0)
(1.20202 -0.00186508 0)
(1.20159 -0.00244196 0)
(1.20107 -0.00299325 0)
(1.20083 -0.00148305 0)
(1.20043 -0.00195528 0)
(1.19994 -0.00240673 0)
(1.19988 -0.00112694 9.59321e-28)
(1.1995 -0.00149436 0)
(1.19903 -0.00184573 -9.53183e-28)
(1.19916 -0.0007908 -9.59321e-28)
(1.1988 -0.00105331 0)
(1.19835 -0.00130441 9.53183e-28)
(1.19869 -0.00046875 2.36597e-29)
(1.19834 -0.000626286 1.39955e-27)
(1.19789 -0.000776995 0)
(1.19845 -0.000155255 -2.39138e-29)
(1.1981 -0.000207773 -1.41458e-27)
(1.19766 -0.00025802 0)
(1.20015 0.00074317 0)
(1.19942 0.000516678 0)
(1.19893 0.000304272 -2.37887e-11)
(1.19869 0.000100427 2.40442e-11)
(0.649434 0.0843206 0)
(0.72361 0.0855053 0)
(0.797026 0.0850552 0)
(0.867692 0.0830709 0)
(0.933893 0.0798051 0)
(0.994263 0.0755001 0)
(1.04785 0.0704312 0)
(1.09412 0.0648855 0)
(1.13298 0.0591315 -8.03477e-28)
(1.16468 0.0533994 8.03477e-28)
(1.18974 0.0478704 3.66085e-11)
(1.20889 0.0426732 -3.66085e-11)
(1.22292 0.0378873 1.41121e-27)
(1.23268 0.0335497 -1.41121e-27)
(1.23898 0.0296649 0)
(1.24253 0.0262145 0)
(1.24397 0.0231655 6.44471e-11)
(1.24383 0.0204778 -6.44471e-11)
(1.24256 0.0181094 0)
(1.24048 0.0160197 0)
(1.23787 0.0141718 0)
(1.23493 0.0125333 0)
(1.23181 0.0110763 0)
(1.22862 0.00977746 0)
(1.22544 0.00861694 0)
(1.22234 0.00757817 0)
(1.21934 0.00664706 1.06354e-27)
(1.21649 0.00581148 -1.06354e-27)
(1.21382 0.00506085 2.5596e-29)
(1.21132 0.00438572 -2.5596e-29)
(1.20903 0.00377757 -1.00614e-27)
(1.20694 0.00322853 1.00614e-27)
(1.20508 0.00273129 0)
(1.20343 0.00227895 0)
(1.20202 0.00186494 0)
(1.20083 0.00148293 0)
(1.19988 0.00112685 0)
(1.19916 0.000790737 0)
(1.19869 0.000468712 0)
(1.19845 0.000155242 0)
(0.651261 0.0840425 0)
(0.723977 0.0853902 0)
(0.795982 0.0851651 0)
(0.865367 0.0834516 0)
(0.93048 0.0804825 0)
(0.99 0.0764835 0)
(1.04299 0.0717124 0)
(1.08893 0.0664405 0)
(1.12768 0.060924 -8.34599e-29)
(1.15946 0.0553859 8.34599e-29)
(1.18476 0.0500047 3.56591e-11)
(1.20423 0.0449102 -3.56591e-11)
(1.21865 0.0401857 0)
(1.22882 0.0358739 0)
(1.23552 0.0319855 -7.45604e-29)
(1.23945 0.0285078 7.45604e-29)
(1.24124 0.0254132 3.1641e-11)
(1.24142 0.0226663 -3.1641e-11)
(1.24042 0.0202283 -1.79329e-27)
(1.23859 0.0180615 1.79329e-27)
(1.23619 0.0161309 0)
(1.23343 0.0144053 0)
(1.23047 0.012858 0)
(1.22742 0.0114661 0)
(1.22436 0.0102104 -1.72492e-27)
(1.22136 0.00907463 1.72492e-27)
(1.21846 0.00804495 -1.67054e-27)
(1.2157 0.00710951 1.67054e-27)
(1.2131 0.00625789 -2.55454e-11)
(1.21067 0.00548087 2.55454e-11)
(1.20843 0.00477006 1.58477e-27)
(1.2064 0.00411775 -1.58477e-27)
(1.20458 0.00351675 -1.55355e-27)
(1.20297 0.00296027 1.55355e-27)
(1.20159 0.00244182 0)
(1.20043 0.00195516 0)
(1.1995 0.00149427 -1.51456e-27)
(1.1988 0.00105325 1.51456e-27)
(1.19834 0.000626248 -2.37045e-11)
(1.1981 0.000207761 2.39591e-11)
(0.653227 0.0836791 0)
(0.724529 0.0851791 0)
(0.795164 0.0851635 0)
(0.863299 0.0837028 0)
(0.927342 0.0810122 0)
(0.986014 0.0773023 0)
(1.0384 0.0728149 0)
(1.08397 0.0678063 0)
(1.12258 0.0625212 -3.58406e-11)
(1.15441 0.0571753 3.58406e-11)
(1.17989 0.0519436 0)
(1.19965 0.0469565 0)
(1.21442 0.0423005 0)
(1.22497 0.0380229 0)
(1.23205 0.0341399 -6.82508e-28)
(1.23634 0.0306444 6.82508e-28)
(1.23847 0.0275138 1.24676e-27)
(1.23895 0.0247168 -1.24676e-27)
(1.23822 0.0222183 -2.98749e-11)
(1.23663 0.0199829 2.98749e-11)
(1.23443 0.0179777 0)
(1.23185 0.016173 0)
(1.22905 0.0145428 0)
(1.22613 0.0130651 0)
(1.22319 0.0117211 2.68557e-11)
(1.2203 0.010495 -2.68557e-11)
(1.21749 0.00937314 0)
(1.21481 0.00834402 0)
(1.21228 0.00739741 -2.53601e-11)
(1.20992 0.00652425 2.53601e-11)
(1.20775 0.00571636 2.47814e-11)
(1.20577 0.00496616 -2.47814e-11)
(1.20399 0.00426662 9.76487e-28)
(1.20242 0.00361106 -9.76487e-28)
(1.20107 0.00299311 0)
(1.19994 0.00240662 0)
(1.19903 0.00184564 0)
(0.598747 0.0835132 -2.58734e-20)
(0.60139 0.0831912 2.44446e-20)
(0.604151 0.0827812 -3.99352e-20)
(0.570941 0.0823761 -4.01711e-20)
(0.574199 0.0819976 1.95687e-20)
(0.577554 0.0815375 -1.05204e-20)
(0.543065 0.0810262 2.54632e-22)
(0.546939 0.0806013 3.24159e-20)
(0.550888 0.0801007 -2.86794e-20)
(0.515235 0.0794819 4.898e-20)
(0.51972 0.0790169 -2.4516e-20)
(0.524262 0.0784812 -2.4582e-20)
(0.487573 0.0776749 1.62922e-20)
(0.492663 0.077178 -2.45362e-20)
(0.497791 0.076615 1.16727e-20)
(0.454541 0.0760414 -1.45618e-20)
(0.460204 0.0755962 3.3277e-21)
(0.46589 0.075076 4.33867e-21)
(0.426998 0.0737188 2.06885e-21)
(0.43326 0.0732543 -2.76956e-20)
(0.439527 0.0727189 1.45261e-21)
(0.400027 0.0711304 2.72118e-20)
(0.40687 0.0706545 -6.89088e-21)
(0.413702 0.0701116 -2.9487e-20)
(0.373765 0.0682817 -3.65651e-21)
(0.381167 0.0678019 -2.54013e-20)
(0.388544 0.0672586 1.05587e-20)
(0.348346 0.0651799 1.2476e-20)
(0.356284 0.064703 -2.46715e-21)
(0.364184 0.0641662 4.99186e-21)
(0.315411 0.0622319 1.89793e-20)
(0.323904 0.0618343 -4.99303e-21)
(0.332352 0.0613667 1.86438e-20)
(0.291588 0.0586422 -1.01209e-21)
(0.300571 0.0582557 -4.65399e-21)
(0.309499 0.0578031 2.63158e-20)
(0.269033 0.0548266 4.50252e-20)
(0.278473 0.0544563 -5.15277e-21)
(0.287851 0.0540238 -1.26563e-20)
(0.24787 0.0507992 -1.69493e-20)
(0.257734 0.0504494 4.3836e-20)
(0.26753 0.0500415 -1.75237e-20)
(0.228219 0.0465752 1.18411e-20)
(0.238471 0.0462496 2.17314e-20)
(0.248651 0.0458702 1.17981e-20)
(0.21019 0.0421707 7.93284e-21)
(0.220794 0.0418724 -2.76792e-21)
(0.231323 0.041525 9.21164e-21)
(0.193886 0.0376027 1.15189e-20)
(0.204806 0.0373343 -5.73085e-21)
(0.215647 0.0370217 -9.92378e-21)
(0.179404 0.0328889 5.43706e-21)
(0.1906 0.0326525 -6.44734e-21)
(0.201716 0.0323771 1.39041e-20)
(0.166826 0.0280475 1.91881e-20)
(0.178261 0.0278449 -1.60277e-20)
(0.189614 0.0276088 7.81892e-22)
(0.144525 0.02323 -2.1631e-20)
(0.156228 0.0230974 1.02705e-21)
(0.167862 0.02293 1.02625e-20)
(0.179413 0.0227347 -3.45146e-21)
(0.13581 0.0181617 -1.14809e-21)
(0.147672 0.0180579 1.42426e-21)
(0.159466 0.0179266 3.82904e-21)
(0.171176 0.0177734 -4.64755e-21)
(0.129229 0.0130229 2.15074e-21)
(0.14121 0.0129484 3.06516e-21)
(0.153124 0.0128541 -3.68005e-21)
(0.164954 0.012744 5.58437e-21)
(0.124819 0.00783373 4.00548e-21)
(0.13688 0.00778882 -4.15481e-21)
(0.148874 0.00773197 1.72768e-21)
(0.122608 0.00261421 -2.17185e-22)
(0.134709 0.00259911 1.06814e-22)
(0.146743 0.00258001 5.74519e-22)
)
;
boundaryField
{
inlet
{
type uniformFixedValue;
uniformValue constant (1 0 0);
value nonuniform 0();
}
outlet
{
type pressureInletOutletVelocity;
value nonuniform 0();
}
cylinder
{
type fixedValue;
value nonuniform 0();
}
top
{
type symmetryPlane;
}
bottom
{
type symmetryPlane;
}
defaultFaces
{
type empty;
}
procBoundary32to31
{
type processor;
value nonuniform List<vector>
137
(
(0.11046 -0.00262523 -6.08343e-23)
(0.112711 -0.00786471 -4.1978e-21)
(0.1172 -0.0130738 -3.05431e-21)
(0.1239 -0.0182324 -1.79105e-21)
(0.132773 -0.0233204 1.13261e-20)
(0.155324 -0.0282093 -1.90797e-21)
(0.155324 -0.0282093 -1.90797e-21)
(0.16814 -0.0330778 -2.75067e-21)
(0.1829 -0.0378173 -1.97407e-21)
(0.19952 -0.0424093 -1.0016e-21)
(0.217903 -0.0468356 -3.24641e-20)
(0.237947 -0.0510786 -3.22736e-20)
(0.259538 -0.0551216 -2.5453e-20)
(0.282557 -0.0589488 -1.77889e-20)
(0.306878 -0.0625454 -2.30549e-20)
(0.340375 -0.0655844 5.15274e-21)
(0.340375 -0.0655844 5.15274e-21)
(0.366342 -0.0686854 3.88948e-20)
(0.393178 -0.0715263 3.35943e-21)
(0.420746 -0.0740992 8.33798e-21)
(0.448906 -0.0763981 3.69795e-20)
(0.482525 -0.0780939 2.31642e-20)
(0.482525 -0.0780939 2.31642e-20)
(0.510813 -0.0798639 -1.09141e-20)
(0.539276 -0.0813626 -6.81978e-21)
(0.567789 -0.0826601 4.62425e-20)
(0.596233 -0.0837335 8.13634e-21)
(0.647759 -0.0845006 0)
(0.647759 -0.0845006 0)
(0.723444 -0.0855113 0)
(0.798314 -0.0848197 0)
(0.870294 -0.0825455 0)
(0.9376 -0.0789638 0)
(0.998819 -0.0743351 0)
(1.05298 -0.0689537 0)
(1.09956 -0.063124 0)
(1.13849 -0.057127 -8.26859e-28)
(1.17006 -0.0512 8.26859e-28)
(1.19485 -0.0455264 0)
(1.21362 -0.0402328 0)
(1.22723 -0.0353937 0)
(1.23656 -0.0310401 0)
(1.24242 -0.0271695 7.26491e-28)
(1.24556 -0.0237569 -7.26491e-28)
(1.24664 -0.0207638 3.27933e-11)
(1.24618 -0.0181455 -3.27933e-11)
(1.24462 -0.0158562 0)
(1.24229 -0.0138529 0)
(1.23947 -0.0120965 0)
(1.23635 -0.0105534 0)
(1.23306 -0.00919481 0)
(1.22973 -0.00799659 0)
(1.22643 -0.00693858 0)
(1.22321 -0.00600385 0)
(1.22012 -0.00517803 0)
(1.21719 -0.00444878 0)
(1.21444 -0.00380532 -2.58383e-11)
(1.21188 -0.00323805 2.58383e-11)
(1.20952 -0.00273828 0)
(1.20739 -0.00229803 0)
(1.20547 -0.00190988 0)
(1.20379 -0.00156683 0)
(1.20234 -0.00126225 0)
(1.20113 -0.000989772 0)
(1.20015 -0.000743259 0)
(1.19942 -0.000516741 0)
(1.19893 -0.00030431 -2.36874e-29)
(1.19869 -0.000100439 2.39419e-29)
(1.20032 0.000343123 -7.26394e-29)
(1.19958 0.000230994 7.26394e-29)
(1.19908 0.000132886 -2.37865e-11)
(1.19883 4.33e-05 2.4042e-11)
(0.647756 0.084499 0)
(0.647756 0.084499 0)
(0.723442 0.0855097 0)
(0.798312 0.0848181 0)
(0.870292 0.0825439 0)
(0.937598 0.0789622 0)
(0.998818 0.0743335 0)
(1.05298 0.0689522 0)
(1.09956 0.0631225 0)
(1.13849 0.0571255 -3.90972e-11)
(1.17006 0.0511986 3.90972e-11)
(1.19485 0.0455251 0)
(1.21362 0.0402315 0)
(1.22723 0.0353926 0)
(1.23656 0.0310389 0)
(1.24242 0.0271684 -7.2649e-28)
(1.24556 0.0237559 7.2649e-28)
(1.24664 0.0207629 3.27932e-11)
(1.24618 0.0181446 -3.27932e-11)
(1.24462 0.0158554 0)
(1.24229 0.0138521 0)
(1.23947 0.0120959 1.20319e-27)
(1.23635 0.0105528 -1.20319e-27)
(1.23306 0.00919424 0)
(1.22973 0.00799607 0)
(1.22643 0.0069381 2.76274e-11)
(1.22322 0.00600341 -2.76274e-11)
(1.22013 0.00517763 -1.07068e-27)
(1.21719 0.00444842 1.07068e-27)
(1.21444 0.003805 -2.57283e-29)
(1.21188 0.00323776 2.57283e-29)
(1.20952 0.00273802 0)
(1.20739 0.0022978 0)
(1.20547 0.00190968 9.88056e-28)
(1.20379 0.00156667 -9.88056e-28)
(1.20234 0.00126211 -9.71631e-28)
(1.20113 0.000989657 9.71631e-28)
(1.20113 0.000989657 9.71631e-28)
(0.596231 0.0837321 -9.27027e-21)
(0.567787 0.0826587 -4.5165e-20)
(0.539273 0.0813611 6.948e-21)
(0.51081 0.0798624 9.63328e-21)
(0.482523 0.0780923 -2.2068e-20)
(0.482523 0.0780923 -2.2068e-20)
(0.448903 0.0763968 -3.68874e-20)
(0.420743 0.0740979 -6.87044e-21)
(0.393176 0.071525 -1.79538e-21)
(0.36634 0.068684 -4.24965e-20)
(0.340373 0.065583 -4.12196e-21)
(0.340373 0.065583 -4.12196e-21)
(0.306876 0.0625443 2.09418e-20)
(0.282555 0.0589476 1.86437e-20)
(0.259536 0.0551204 2.42829e-20)
(0.237945 0.0510774 3.51813e-20)
(0.217902 0.0468344 2.73011e-20)
(0.199518 0.0424081 3.75122e-21)
(0.182899 0.0378161 -4.39678e-22)
(0.168138 0.0330766 3.68371e-21)
(0.155323 0.0282081 2.81948e-21)
(0.155323 0.0282081 2.81948e-21)
(0.132772 0.0233196 -1.04186e-20)
(0.123899 0.0182316 2.13448e-21)
(0.117199 0.013073 3.10367e-21)
(0.112711 0.00786385 4.10998e-21)
(0.11046 0.00262437 4.50433e-22)
)
;
}
procBoundary32to33
{
type processor;
value nonuniform List<vector>
137
(
(0.158693 -0.00255996 -1.69457e-22)
(0.160784 -0.00766781 1.39788e-22)
(0.160784 -0.00766781 1.39788e-22)
(0.176688 -0.0126239 9.8684e-22)
(0.182791 -0.0176055 -4.63823e-22)
(0.19087 -0.0225199 6.69729e-21)
(0.200874 -0.0273485 1.23862e-20)
(0.212742 -0.0320733 -5.42283e-21)
(0.226401 -0.0366764 1.13389e-20)
(0.241769 -0.0411409 -9.30477e-21)
(0.258753 -0.0454504 -4.20175e-20)
(0.277254 -0.0495895 1.16859e-20)
(0.297165 -0.0535437 -2.55649e-20)
(0.318371 -0.0572996 -2.96154e-20)
(0.318371 -0.0572996 -2.96154e-20)
(0.349098 -0.0602756 -6.59556e-21)
(0.372046 -0.0635837 -2.05482e-20)
(0.395896 -0.0666666 -9.01927e-21)
(0.420522 -0.0695166 2.47445e-20)
(0.445798 -0.0721279 2.05096e-20)
(0.471597 -0.0744963 -1.26946e-20)
(0.471597 -0.0744963 -1.26946e-20)
(0.502952 -0.0760004 4.34605e-21)
(0.528855 -0.0778895 4.05022e-20)
(0.554908 -0.0795392 -1.13297e-20)
(0.581 -0.0810114 1.14603e-20)
(0.607023 -0.082299 -4.59566e-21)
(0.607023 -0.082299 -4.59566e-21)
(0.655323 -0.0832456 1.82345e-27)
(0.725254 -0.0848877 1.72234e-27)
(0.794559 -0.0850669 -3.84464e-11)
(0.861474 -0.0838423 -3.82925e-11)
(0.924464 -0.081413 -3.8083e-11)
(0.982291 -0.0779759 -7.56298e-11)
(1.03406 -0.0737582 -3.74901e-11)
(1.07925 -0.0690023 0)
(1.11768 -0.0639419 0)
(1.14951 -0.0587851 -3.62142e-11)
(1.17514 -0.0537035 -3.57085e-11)
(1.19516 -0.0488273 0)
(1.21024 -0.0442451 4.681e-28)
(1.22114 -0.0400087 -3.4052e-11)
(1.22857 -0.0361391 -3.34767e-11)
(1.23321 -0.0326341 -3.29001e-11)
(1.23566 -0.0294759 -6.4654e-11)
(1.23644 -0.0266372 -3.17617e-11)
(1.23597 -0.0240861 -3.1208e-11)
(1.2346 -0.02179 -6.13373e-11)
(1.23261 -0.0197177 -6.02926e-11)
(1.2302 -0.0178409 -5.92861e-11)
(1.22755 -0.0161348 -2.91606e-11)
(1.22476 -0.014578 -1.19856e-27)
(1.22194 -0.0131522 0)
(1.21915 -0.011842 -2.07799e-27)
(1.21644 -0.0106341 4.04242e-28)
(1.21384 -0.00951712 -2.7103e-11)
(1.21138 -0.00848119 -5.35364e-11)
(1.20909 -0.00751741 -5.29206e-11)
(1.20697 -0.00661776 -2.61796e-11)
(1.20504 -0.00577486 -3.16314e-28)
(1.2033 -0.00498181 -2.5701e-11)
(1.20178 -0.00423208 -5.10068e-11)
(1.20046 -0.00351941 -5.06678e-11)
(1.19935 -0.00283776 -2.51925e-11)
(1.19847 -0.0021813 -2.50793e-11)
(1.1978 -0.00154427 -4.99887e-11)
(1.19735 -0.000920983 -2.49377e-11)
(1.19713 -0.00030603 -2.5177e-11)
(1.19835 0.00130435 0)
(1.19789 0.000776957 -2.36211e-11)
(1.19766 0.000258007 2.38748e-11)
(0.655321 0.0832432 0)
(0.60702 0.0822967 4.3656e-21)
(0.725252 0.0848853 3.85614e-11)
(0.794557 0.0850646 3.84462e-11)
(0.861472 0.0838401 -7.54977e-28)
(0.924463 0.0814109 0)
(0.982289 0.0779738 2.04771e-27)
(1.03406 0.0737562 -2.03012e-27)
(1.07925 0.0690004 0)
(1.11768 0.0639402 -3.47977e-11)
(1.14951 0.0587835 3.47977e-11)
(1.17514 0.053702 4.82814e-28)
(1.19516 0.0488258 0)
(1.21024 0.0442438 -3.68829e-28)
(1.22114 0.0400075 -3.40519e-11)
(1.22857 0.0361379 -3.34767e-11)
(1.23321 0.032633 6.9806e-28)
(1.23566 0.0294749 -8.37634e-28)
(1.23644 0.0266363 0)
(1.23597 0.0240853 -5.87285e-11)
(1.2346 0.0217892 5.87285e-11)
(1.23261 0.019717 2.24922e-27)
(1.2302 0.0178402 0)
(1.22755 0.0161342 -2.17567e-27)
(1.22476 0.0145774 0)
(1.22194 0.0131517 2.6554e-11)
(1.21915 0.0118415 -2.6554e-11)
(1.21644 0.0106337 -7.89957e-28)
(1.21384 0.00951675 1.21017e-27)
(1.21138 0.00848086 -6.936e-28)
(1.20909 0.00751711 0)
(1.20697 0.0066175 2.46068e-11)
(1.20504 0.00577464 -2.46068e-11)
(1.20331 0.00498162 -1.91755e-27)
(1.20178 0.00423191 0)
(1.20046 0.00351927 -1.05797e-27)
(1.19935 0.00283765 0)
(1.19835 0.00130435 0)
(1.19847 0.00218121 -7.17069e-29)
(0.60702 0.0822967 4.3656e-21)
(0.580997 0.081009 -1.06487e-20)
(0.554906 0.0795368 1.10033e-20)
(0.528853 0.077887 -1.45814e-20)
(0.502949 0.0759979 -2.10909e-21)
(0.471594 0.074494 1.23158e-20)
(0.471594 0.074494 1.23158e-20)
(0.445795 0.0721255 -1.74081e-20)
(0.42052 0.0695142 -2.68373e-20)
(0.395893 0.0666641 8.88664e-21)
(0.372043 0.0635811 2.22711e-20)
(0.34075 0.0608425 8.12864e-22)
(0.34075 0.0608425 8.12864e-22)
(0.318368 0.0572972 2.85469e-20)
(0.297163 0.0535413 2.45359e-20)
(0.277252 0.0495871 -7.59476e-21)
(0.258751 0.0454479 3.90894e-20)
(0.241767 0.0411384 9.86811e-21)
(0.226399 0.0366739 -1.19063e-20)
(0.212741 0.0320708 5.01758e-21)
(0.200873 0.027346 -1.29061e-20)
(0.190869 0.0225173 -4.10798e-21)
(0.182791 0.0176029 -1.26306e-22)
(0.176687 0.0126214 -1.4383e-21)
(0.160784 0.00766557 -3.68507e-22)
(0.160784 0.00766557 -3.68507e-22)
(0.158693 0.00255772 3.98078e-22)
)
;
}
}
// ************************************************************************* //
|
|
610eeaefd9cb0201160ed0ed328d080eb6690d50
|
a760c40ea11a8958aa527f4673522d341abc81d6
|
/proteintools/proteintools/EnergyEvaluator.cpp
|
d33ebb3ff1891b12a8acbccc682ebf9fff8d6bbd
|
[
"MIT"
] |
permissive
|
saliksyed/protein-tools-cpp
|
9c895ecb6faa25b471a48ffd8920391ae6c1f432
|
0101d1e0da125bcb36e70291290d25387999e197
|
refs/heads/master
| 2021-07-09T22:12:02.756229
| 2017-10-10T19:11:03
| 2017-10-10T19:11:03
| 105,791,034
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,755
|
cpp
|
EnergyEvaluator.cpp
|
//
// EnergyEvaluator.cpp
// proteintools
//
// Created by Salik Syed on 10/8/17.
// Copyright © 2017 N/A. All rights reserved.
//
#include "EnergyEvaluator.hpp"
#include <math.h>
#include <iostream>
float EnergyEvaluator::getEnergy(Eigen::Matrix4Xf * atomParams, Eigen::Matrix4Xf* atoms) {
return 0.0;
}
float CPUEvaluator::getEnergy(Eigen::Matrix4Xf * atomParams, Eigen::Matrix4Xf* atoms) {
float energy = 0.0;
for(size_t i = 0; i < _atomCount - 1; i++) {
float charge1 = atomParams->col(i).y();
float sigma1 = atomParams->col(i).z();
float epsilon1 = atomParams->col(i).w();
Eigen::Vector3f pos1 = atoms->col(i).head<3>();
for(size_t j = i + 1; j < _atomCount; j++) {
float charge2 = atomParams->col(j).y();
float sigma2 = atomParams->col(j).z();
float epsilon2 = atomParams->col(j).w();
Eigen::Vector3f pos2 = atoms->col(j).head<3>();
Eigen::Vector3f l = pos1 - pos2;
float rij = l.norm();
float r0ij = pow(2.0, 1/6.0) * (sigma1 + sigma2) * 0.5;
float eij = _lj14scale * epsilon1 * epsilon2;
float e0 = _c14scale;
float electrostatic = (charge1 * charge2) / (4.0 * M_PI * e0 * rij);
float r0ij_rij = (r0ij/rij);
float lennardJones = eij * pow(r0ij_rij, 12.0f) - 2.0f * pow(r0ij_rij, 6.0f);
energy += lennardJones + electrostatic;
}
}
return energy;
}
OpenGLEvaluator::OpenGLEvaluator(unsigned int atomCount, float lj14scale, float c14scale) : EnergyEvaluator(atomCount, lj14scale, c14scale) {
}
float OpenGLEvaluator::getEnergy(Eigen::Matrix4Xf * atomParamsIn, Eigen::Matrix4Xf* atomsIn) {
return 0.0;
}
|
6e54ec407f02c244bb787d6ada17479081eb35f3
|
8c2b2e80ae213c550fa419cd6341eb561f42f505
|
/scratch/6-csma-cd/apps.cc
|
0d866d1df22f3152202d9e626078f857739ae400
|
[] |
no_license
|
codeShaurya/ns3-network-simulator
|
b776228903cecd48a19c3e2037823c26374c09ba
|
e8da42204efefffbcdeae56ad7f3b90bc4c83452
|
refs/heads/master
| 2020-04-03T06:16:11.691767
| 2018-11-16T12:48:36
| 2018-11-16T12:48:36
| 155,070,236
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,829
|
cc
|
apps.cc
|
#include <ostream>
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/stats-module.h"
#include "csmaca-apps.h"
using namespace ns3;
NS_LOG_COMPONENT_DEFINE("CsmacaApps");
TypeId
CsmacaSender::GetTypeId(void)
{
static TypeId tid = TypeId("CsmacaSender")
.SetParent<Application>()
.AddConstructor<CsmacaSender>()
.AddAttribute("PacketSize", "The size of packets transmitted.",
UintegerValue(1500),
MakeUintegerAccessor(&CsmacaSender::m_pktSize),
MakeUintegerChecker<uint32_t>(1))
.AddAttribute("Destination", "Target host address.",
Ipv4AddressValue("255.255.255.255"),
MakeIpv4AddressAccessor(&CsmacaSender::m_destAddr),
MakeIpv4AddressChecker())
.AddAttribute("Port", "Destination app port.",
UintegerValue(1603),
MakeUintegerAccessor(&CsmacaSender::m_destPort),
MakeUintegerChecker<uint32_t>(0))
.AddAttribute("Interval", "Delay between transmissions.",
StringValue("ns3::ConstantRandomVariable[Constant=1]"),
MakePointerAccessor(&CsmacaSender::m_interval),
MakePointerChecker<RandomVariableStream>())
.AddAttribute("Stream", "Random Stream.",
StringValue("ns3::UniformRandomVariable[Stream=-1]"),
MakePointerAccessor(&CsmacaSender::m_random),
MakePointerChecker<RandomVariableStream>())
.AddTraceSource("Tx", "A new packet is created and is sent",
MakeTraceSourceAccessor(&CsmacaSender::m_txTrace));
return tid;
}
CsmacaSender::CsmacaSender()
{
NS_LOG_FUNCTION_NOARGS();
m_interval = CreateObject<ConstantRandomVariable>();
m_random = CreateObject<UniformRandomVariable>();
m_socket = 0;
}
CsmacaSender::~CsmacaSender()
{
NS_LOG_FUNCTION_NOARGS();
}
void CsmacaSender::DoDispose(void)
{
NS_LOG_FUNCTION_NOARGS();
m_socket = 0;
Application::DoDispose();
}
void CsmacaSender::StartApplication()
{
NS_LOG_FUNCTION_NOARGS();
if (m_socket == 0)
{
Ptr<SocketFactory> socketFactory = GetNode()->GetObject<SocketFactory>(UdpSocketFactory::GetTypeId());
m_socket = socketFactory->CreateSocket();
m_socket->Bind();
}
Simulator::Cancel(m_sendEvent);
m_sendEvent = Simulator::ScheduleNow(&CsmacaSender::SendPacket, this);
}
void CsmacaSender::StopApplication()
{
NS_LOG_FUNCTION_NOARGS();
Simulator::Cancel(m_sendEvent);
}
void CsmacaSender::SendPacket()
{
NS_LOG_FUNCTION_NOARGS();
NS_LOG_INFO("Sending packet at " << Simulator::Now() << " to " << m_destAddr);
Ptr<Packet> packet = Create<Packet>(m_pktSize);
m_socket->SendTo(packet, 0, InetSocketAddress(m_destAddr, m_destPort));
m_txTrace(packet);
double interval = m_interval->GetValue();
double logval = -log(m_random->GetValue());
Time nextTxTime = Seconds(interval * logval);
NS_LOG_INFO("nextTime:" << nextTxTime << " in:" << interval << " log:" << logval);
m_sendEvent = Simulator::Schedule(nextTxTime, &CsmacaSender::SendPacket, this);
m_numSendPkts++;
}
TypeId
CsmacaReceiver::GetTypeId(void)
{
static TypeId tid = TypeId("CsmacaReceiver")
.SetParent<Application>()
.AddConstructor<CsmacaReceiver>()
.AddAttribute("Port", "Listening port.",
UintegerValue(1603),
MakeUintegerAccessor(&CsmacaReceiver::m_port),
MakeUintegerChecker<uint32_t>())
.AddAttribute("NumPackets", "Total number of packets to recv.", UintegerValue(0),
MakeUintegerAccessor(&CsmacaReceiver::m_numPkts),
MakeUintegerChecker<uint32_t>(0))
.AddTraceSource("Rx", "CsmacaReceiver data packet",
MakeTraceSourceAccessor(&CsmacaReceiver::m_rxTrace));
return tid;
}
CsmacaReceiver::CsmacaReceiver()
{
NS_LOG_FUNCTION_NOARGS();
m_socket = 0;
}
CsmacaReceiver::~CsmacaReceiver()
{
NS_LOG_FUNCTION_NOARGS();
}
void CsmacaReceiver::DoDispose(void)
{
NS_LOG_FUNCTION_NOARGS();
m_socket = 0;
Application::DoDispose();
}
void CsmacaReceiver::StartApplication()
{
NS_LOG_FUNCTION_NOARGS();
if (m_socket == 0)
{
Ptr<SocketFactory> socketFactory = GetNode()->GetObject<SocketFactory>(UdpSocketFactory::GetTypeId());
m_socket = socketFactory->CreateSocket();
InetSocketAddress local =
InetSocketAddress(Ipv4Address::GetAny(), m_port);
m_socket->Bind(local);
}
m_socket->SetRecvCallback(MakeCallback(&CsmacaReceiver::Receive, this));
}
void CsmacaReceiver::StopApplication()
{
NS_LOG_FUNCTION_NOARGS();
if (m_socket != 0)
{
m_socket->SetRecvCallback(MakeNullCallback<void, Ptr<Socket>>());
}
}
void CsmacaReceiver::Receive(Ptr<Socket> socket)
{
Ptr<Packet> packet;
Address from;
while ((packet = socket->RecvFrom(from)))
{
if (InetSocketAddress::IsMatchingType(from))
{
InetSocketAddress::ConvertFrom(from).GetIpv4();
m_rxTrace(m_numPkts, packet);
}
}
}
|
d6c45fb4bb8f735e4adaf239645e5eda53df459c
|
e70c94573156f75712dfa6216672610a86a3471e
|
/CharacterKoopa.h
|
6a6bd9e37a18f391416d14e149bc33ef67536d41
|
[] |
no_license
|
Ethan-Greaves/Super-Mario-level
|
77d6a0198fc74d6f3e9566adc14ef943b39e22d1
|
c1872980e34fd046f4b5b6992b8b8991e452526d
|
refs/heads/master
| 2022-06-15T08:52:32.811938
| 2019-03-12T22:15:58
| 2019-03-12T22:15:58
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 999
|
h
|
CharacterKoopa.h
|
#pragma once
#include "SDL.h"
#include "Character.h"
#include "Texture2D.h"
#include "Constants.h"
class CharacterKoopa : public Character
{
public:
CharacterKoopa(SDL_Renderer * renderer, std::string imagePath, Vector2D startPosition, LevelMap * map, FACING startFacing, float movementSpeed)
: Character(renderer, imagePath, startPosition, map)
{
mFacingDirection = startFacing;
mMovementSpeed = movementSpeed;
mPosition = startPosition;
mInjured = false;
mDead = false;
mSingleSpriteWidth = mTexture->GetWidth() / 2; //2sprites on spritesheet in 1 row
mSingleSpriteHeight = mTexture->GetHeight();
};
~CharacterKoopa();
void Render();
void Update(float deltaTime, SDL_Event e);
void TakeDamage();
void Jump();
void SetDead();
bool GetDead();
bool IsInjured();
private:
float mSingleSpriteWidth;
float mSingleSpriteHeight;
bool mInjured;
float mInjuredTime;
float mMovementSpeed;
bool mDead;
void FlipRightWayUp();
};
|
c0627e3d3370d2f716b26daad24930e86a96fbaa
|
a3c6c8c0a2b324bf867e78e0ca8b322ff8841933
|
/firmwareGauge/simulation/main.cpp
|
836d51332409f96237471aa5047ed60be5b489f1
|
[] |
no_license
|
songcn206/SombreroBms
|
de79951e8c9a46d859956339436050bc28938aed
|
f3c33880192616e8d89ace658786e29069518dac
|
refs/heads/master
| 2021-09-27T13:28:14.321806
| 2018-11-09T00:11:30
| 2018-11-09T00:11:30
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 676
|
cpp
|
main.cpp
|
//#include <iostream>
#include <unistd.h>
#include <string>
#include <list>
#include <time.h>
#include <pthread.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>
#include "gfxareas.h"
#include "keypress.h"
#include "app.h"
#include "sdlcalls.h"
using namespace std;
void main_loop(Cappdata *app)
{
while (!app->m_bquit)
{
//printf("loop\n");
handle_input_events(app);
app->render_gui();
usleep(7000);
}
}
int main(int argc, char **argv)
{
int width;
int height;
Cappdata *app;
width = 1024;
height = 758;
// Central class
app = new Cappdata(width, height);
main_loop(app);
delete app;
}
|
fb6ae17afc01cc396c36525ec01b27ac50957bdd
|
cc0800273b691e6fb33f47729dcc1409aa3ba1c2
|
/c언어/Plus Plus.cpp
|
cda62194304f47df7868987be106ff7862f1faf4
|
[] |
no_license
|
munyeol-Yoon/C-practice
|
525e8c89dff49783a2faafb9b92239db9dc0527b
|
6f0a563d321aa0a6b66701a8e3f859d8c768eef7
|
refs/heads/master
| 2020-07-10T12:10:23.241448
| 2019-08-25T07:20:54
| 2019-08-25T07:20:54
| 204,260,108
| 0
| 0
| null | null | null | null |
UHC
|
C++
| false
| false
| 333
|
cpp
|
Plus Plus.cpp
|
#include <stdio.h>
int main(void)
{
int x = 0;
printf("현재의 x 는 %d 입니다.\n", x);
x++;
printf("현재의 x 는 %d 입니다.\n", x);
printf("현재의 x 는 %d 입니다.\n", x--);
printf("현재의 x 는 %d 입니다.\n", x);
printf("현재의 x 는 %d 입니다.\n", --x);
return 0;
}
|
37da8546865a1ccfca12cb5e2cf65da401d5a269
|
2d36522eb41d861d52fd4236cf6936fae451db32
|
/Shooter/Map/Map.h
|
fd949f05837269041cc4f9606442a2ed84811760
|
[
"BSD-2-Clause-Views"
] |
permissive
|
michaelschrandt/personal_projects
|
3c7413cd1f2d8a9a2603cd484b76ed70a3c32b2c
|
7d4200176a7ebbff3233a86c870da910217c3a4e
|
refs/heads/master
| 2016-09-06T17:30:00.932703
| 2013-01-03T23:56:15
| 2013-01-03T23:56:15
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 545
|
h
|
Map.h
|
// Michael Schrandt
//
// Map is a 2d grid of tiles.
#pragma once
#include <iostream>
#include <fstream>
#include "Tile.h"
#include "TileFactory.h"
using namespace std;
class Map
{
public:
//Map();
Map(std::string);
~Map();
void update() {tileFactory.update(); }
int getHeight() { return height; }
int getWidth() { return width; }
void draw(sf::Rect<int>&);
void draw();
Tile**& operator[](unsigned int i) {return grid[i];}
TileFactory tileFactory;
private:
int width;
int height;
Tile*** grid; //2d array of tile pointers
};
|
0c1c78c4fb99faf2a5e566a3d560300a8ec5e838
|
e89824729833e518d712186fee0956b91cf9a4f3
|
/tcp_svr/svr/runner.cpp
|
9beb1a236c15d3d41c79604570e8a22cb0c6b840
|
[] |
no_license
|
njuicsgz/cpp
|
586b1744de130c33b184fa8215a7100dd07b3664
|
bfa11a0c9444fb91208c785a0f2b9e08ada07e4b
|
refs/heads/master
| 2021-01-20T06:56:56.161143
| 2015-05-05T03:08:41
| 2015-05-05T03:08:41
| 24,262,338
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,888
|
cpp
|
runner.cpp
|
#include <sys/time.h>
#include <unistd.h>
#include <iostream>
#include "runner.h"
#include "Helper.h"
#include "CSessionMgr.h"
#include "limits.h"
using namespace network;
using namespace std;
static const size_t C_READ_BUFFER_SIZE = 4096;
CReqAcceptor::CReqAcceptor(CEPoller& epoller, CachedConn& collection, MQ& Q) :
_epoller(epoller), _conns(collection), _flow(0), _Q(Q)
{
}
CReqAcceptor::~CReqAcceptor()
{
}
void CReqAcceptor::Init(const std::string& sHost, unsigned short port)
{
try
{
_listen.create();
_listen.set_reuseaddr();
_listen.bind(port, sHost);
_listen.listen();
} catch (socket_error& err)
{
Err("[Runner]:maybe ip or port is invalid.CReqAcceptor::Init,%s",
err.what());
assert(false);
}
}
void CReqAcceptor::OnConnect(CSockAttacher &sock, int flow)
{
}
void CReqAcceptor::Run()
{
for (;;)
{
try
{
CSockAttacher sock(-1);
_listen.accept(sock);
sock.set_nonblock();
sock.set_reuseaddr();
unsigned tempflow = _flow++;
_conns.AddConn(sock.fd(), tempflow);
_epoller.add(sock.fd());
OnConnect(sock, tempflow);
string strIP;
port_t ulPort;
sock.get_peer_name(strIP, ulPort);
MapFlow2IP(strIP, tempflow);
} catch (socket_error& err)
{
if (err._err_no == EINTR || err._err_no == EAGAIN)
continue;
}
}
}
CReceiver::CReceiver(CEPoller& epoller, CachedConn& collection, MQ& Q) :
_epoller(epoller), _conns(collection), _Q(Q)
{
}
CReceiver::~CReceiver()
{
}
void CReceiver::Run()
{
unsigned long long count = 0;
unsigned long long fail = 0;
for (;;)
{
CEPollResult res = _epoller.wait(C_EPOLL_WAIT);
for (CEPollResult::iterator it = res.begin(); it != res.end(); it++)
{
int fd = it->data.fd;
unsigned flow = 0;
//没有EPOLLIN和EPOLLOUT事件
if (!(it->events & (EPOLLIN | EPOLLOUT)))
{
Warn("%s", "[Runner]:NOT EPOLLIN | EPOLLOUT\n");
_conns.CloseConn(fd);
continue;
}
//EPOLLOUT事件
if (it->events & EPOLLOUT)
{
unsigned flow = 0;
int sent = _conns.Send(fd, flow);
if (sent == 0)
{
try
{
_epoller.modify(fd, EPOLLIN | EPOLLERR | EPOLLHUP);
} catch (exception& ex)
{
_conns.CloseConn(fd);
}
continue;
} else if (sent < 0)
{
_conns.CloseConn(fd);
}
}
//EPOLLIN事件
if (!(it->events & EPOLLIN))
{
continue;
}
int rcv = _conns.Recv(fd, flow);
if (rcv <= 0)
{
_conns.CloseConn(fd);
continue;
}
for (int i = 0; i < 100; i++)
{
Message msg(flow);
int msg_len = _conns.GetMessage(fd, msg);
if (msg_len == 0)
{
break;
}
else if (msg_len < 0)
{
_conns.CloseConn(fd);
break;
} else
{
if (!_Q.Enqueue(msg))
{
fail++;
break;
} else
{
count++;
continue;
}
}
}
}
}
}
CRspSender::CRspSender(CachedConn& collection, MQ& Q, CEPoller& epoller) :
_conns(collection), _Q(Q), _epoller(epoller)
{
}
CRspSender::~CRspSender()
{
}
void CRspSender::Run()
{
unsigned long long count = 0;
unsigned long long fail = 0;
for (;;)
{
Message msg(ULONG_MAX);
if (!_Q.Dequeue(msg))
{
continue;
}
int length;
char* sData = msg.GetMessage(length);
if (sData == NULL)
{
_conns.CloseConnect(msg.Flow());
continue;
}
int fd = -1;
int ret = _conns.Send(msg.Flow(), sData, length, fd);
if (ret > 0)
{
try
{
_epoller.modify(fd);
} catch (exception& ex)
{
_conns.CloseConn(fd);
}
count++;
} else
{
_conns.CloseConn(fd);
fail++;
}
}
}
|
57fc0f1bb96ef0616e07db9c026c22a390fc43f7
|
48e4c9712b38a90b819c84db064422e1088c4565
|
/toolchains/motoezx/qt/include/ezxam/Idle_Setup.h
|
bb48bb2b4fd20ac831e608f0451b8e90248d201c
|
[] |
no_license
|
blchinezu/EZX-SDK_CPP-QT-SDL
|
8e4605ed5940805f49d76e7700f19023dea9e36b
|
cbb01e0f1dd03bdf8b071f503c4e3e43b2e6ac33
|
refs/heads/master
| 2020-06-05T15:25:21.527826
| 2020-05-15T11:11:13
| 2020-05-15T11:11:13
| 39,446,244
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,225
|
h
|
Idle_Setup.h
|
//write by wangbin wbsecg1@gmail.com
/********************************************************
**libezxam.so.1.0.0
**2010年 07月 06日 星期二 18:11:58 CST
libraries depends:
ezxam,dmnative,ezx-cmseccert,ezxdrmsp,ezxphone
*************************************************************/
#ifndef IDLE_SETUP_H
#define IDLE_SETUP_H
#include <AM_Shortcut.h>
#include <SETUP_SET_Manager.h>
class Idle_Setup :public SETUP_SET_Manager
{
public:
Idle_Setup();
~Idle_Setup();
void getS3Info(bool&, bool&);
void setS3Info(bool, bool);
void setS3BaseURL(QString);
void setS3AddNewURL(QString);
bool getHideS3WhenAutoSelectFail();
void setEnableS3Feature(bool);
bool getS3KillStatus();
void setS3KillStatus(bool);
AM_Shortcut getShortcut(int);
AM_Shortcut getDefaultShortcut(int);
void setShortcut(int, QString);
void getShortcutItem(SETUP_SET_Manager&, int);
bool isShortcutFreeze(int);
void setShortcutFreeze(int, bool);
bool getOTAEnabled();
bool getIgnoreOTAUrlUpdate();
virtual bool flush();
void doAutoSelection(bool&, bool&, bool);
void setDisableEnableStatus(bool);
//bool isItemAvailable(set_item_t);
//void setItemAvailable(set_item_t, bool);
private:
};
#endif //IDLE_SETUP_H
|
d9ae95130e0e88e892ce0fbc56701c8936a1c66d
|
3c89528fa43ccd6bd22e593eac571aefa00766e0
|
/src/main/cpp/Balau/Lang/Property/Parser/PropertyScanner.cpp
|
19c445b2cd28059539277e63575e33f91490f138
|
[
"BSL-1.0"
] |
permissive
|
pylot/balau
|
f371e54ec94e7ebc08d973105bd17e052e8a7157
|
079a7ad4dfa35f179454b543af9d3f10c870f271
|
refs/heads/master
| 2020-09-21T15:58:18.897256
| 2019-11-24T09:00:21
| 2019-11-24T09:00:21
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,439
|
cpp
|
PropertyScanner.cpp
|
// @formatter:off
//
// Balau core C++ library
//
// Copyright (C) 2017 Bora Software (contact@borasoftware.com)
//
// Licensed under the Boost Software License - Version 1.0 - August 17th, 2003.
// See the LICENSE file for the full license text.
//
#include "PropertyScanner.hpp"
namespace Balau::Lang::Property {
PropertyToken PropertyScanner::getNextToken() {
readNextChar();
if (Balau::Character::isBlank(currentChar)) {
return createBlankToken();
}
switch (currentChar) {
case U'{': {
return PropertyToken::OpenCurly;
}
case U'}': {
return PropertyToken::CloseCurly;
}
case U'@': {
return PropertyToken::Arobase;
}
case U':': {
return PropertyToken::Colon;
}
case U'=': {
return PropertyToken::Equals;
}
case U'\r':
case U'\n': {
return createLineBreakToken();
}
case U'#': {
return PropertyToken::Hash;
}
case U'!': {
return PropertyToken::Exclamation;
}
case std::char_traits<char32_t>::eof(): {
return PropertyToken::EndOfFile;
}
case U'\\': {
readNextChar();
if (Balau::Character::isBlank(currentChar)) {
return PropertyToken::EscapedBlank;
}
switch (currentChar) {
case U'{': {
return PropertyToken::EscapedOpenCurly;
}
case U'}': {
return PropertyToken::EscapedCloseCurly;
}
case U'@': {
return PropertyToken::EscapedArobase;
}
case U':': {
return PropertyToken::EscapedColon;
}
case U'=': {
return PropertyToken::EscapedEquals;
}
case U'#': {
return PropertyToken::EscapedHash;
}
case U'!': {
return PropertyToken::EscapedExclamation;
}
case U'\\': {
return PropertyToken::EscapedBackSlash;
}
case U'\r':
case U'\n': {
createLineBreakToken();
return PropertyToken::EscapedLineBreak;
}
default: {
return PropertyToken::EscapedChar;
}
}
}
default: {
do {
readNextChar();
} while (!Character::isWhitespace(currentChar)
&& currentChar != U'{'
&& currentChar != U'}'
&& currentChar != U':'
&& currentChar != U'='
&& currentChar != U'#'
&& currentChar != U'!'
&& currentChar != U'\\'
&& currentChar != U'\t'
&& currentChar != U'\r'
&& currentChar != U'\n'
&& currentChar != std::char_traits<char32_t>::eof()
);
putBackCurrentChar();
return PropertyToken::Text;
}
}
}
} // namespace Balau::Lang::Property
|
4f48a40ecf8f9d1eb77fae16d228ccede035f53b
|
85a60704b2db0f56c22b7ebfef71095fe2cd5f15
|
/src/model/HomeScreenMainDailyModel.h
|
e20b200aa1297469690b468c352c4ba571b74d71
|
[] |
no_license
|
FrancisLaiLD/francislai-01
|
e77caf13bfd3a593bd785adf970e23a88cd62f00
|
7bea841d686f26441db9031f48881a97052fdb20
|
refs/heads/master
| 2020-03-23T18:08:19.686706
| 2018-09-26T14:25:58
| 2018-09-26T14:25:58
| 141,891,523
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,025
|
h
|
HomeScreenMainDailyModel.h
|
#ifndef HOMESCREEN_MAIN_DAILY_MODEL_H
#define HOMESCREEN_MAIN_DAILY_MODEL_H
#include <QObject>
#include <QDateTime>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include "../Component/WeatherComponent.h"
#include "../Component/DeviceComponent.h"
#include "../Common/App_Enum.h"
#include "HomeListDeviceModel.h"
class HomeScreen_Main_Daily_Model : public QObject
{
Q_OBJECT
public:
explicit HomeScreen_Main_Daily_Model(QObject *parent = nullptr, QQmlApplicationEngine* cAppEngine = nullptr);
Q_PROPERTY(WeatherComponent* leftWeather READ leftWeather WRITE setLeftWeather NOTIFY leftWeatherChanged)
Q_PROPERTY(WeatherComponent* rightWeather READ rightWeather WRITE setRightWeather NOTIFY rightWeatherChanged)
Q_PROPERTY(QList<QObject*> listDevice READ listDevice WRITE setListDevice NOTIFY listDeviceChanged)
Q_PROPERTY(QDateTime timeUpdate READ timeUpdate WRITE setTimeUpdate NOTIFY timeUpdateChanged)
void initContextProperty();
/* DEFINES GETTER AND SETTER FUNCTIONS OF PROPERTY */
WeatherComponent *leftWeather() const;
void setLeftWeather(WeatherComponent *leftWeather);
WeatherComponent *rightWeather() const;
void setRightWeather(WeatherComponent *rightWeather);
QDateTime timeUpdate() const;
void setTimeUpdate(const QDateTime &timeUpdate);
QList<QObject*> listDevice() const;
void setListDevice(QList<QObject*> listDevice);
HomeListDeviceModel *homeListDevice() const;
void setHomeListDevice(HomeListDeviceModel *value);
private:
QQmlApplicationEngine* p_qqmlEngine;
WeatherComponent *m_leftWeather;
WeatherComponent *m_rightWeather;
QList<QObject*> m_listDevice;
QDateTime m_timeUpdate;
HomeListDeviceModel* p_homeListDevice;
signals:
void timeUpdateChanged();
void leftWeatherChanged();
void rightWeatherChanged();
void listDeviceChanged();
public slots:
};
#endif // HOMESCREEN_MAIN_DAILY_MODEL_H
|
7eaf39a77676a26632cd838fbd49269432056105
|
54fb1ce2c932fdd4c0155739b922a25e5297bb12
|
/queueFcn.cpp
|
45872645bc867b68986883f6d176a82d4ccafdf0
|
[] |
no_license
|
amirpourshafiee/structs
|
0c5d66faf3488b8553743593842370a3c119145f
|
a44b5321e8acb7aed91cedc18768b94145be5bfa
|
refs/heads/master
| 2021-01-19T17:16:50.845760
| 2017-03-03T02:31:09
| 2017-03-03T02:31:09
| 82,431,513
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,122
|
cpp
|
queueFcn.cpp
|
//
// queueFcn.cpp
//
//
// Created by amir on 2/18/17.
//
//
// First In First Out
#include <stdio.h>
#define MAX 50
int que_arr[MAX];
int rear = -1;
int front = -1;
void enque (){
int add-item;
if (rear== MAX-1)
pritnf ("QUEUE OVERFLOW!!!")
else{
if (front = -1){
front = 0;
scanf("%d", &add_item);
rear = rear + 1;
que_arr[rear]
}
}
}
void deque (){
if (front==-1 || front>rear)
printf("QUEUE UNDERFLOW");
else{
front = front + 1;
}
}
void display(){
int i;
if (front == -1)
printf("\nQUEUE EMPTY\n")
for (i=front; i<= rear; i++)
printf("%d \n", que_arr[i]);
}
// Hernessed
//int main (){
// int choice;
// switch (choice)
// {
// case 1:
// enque();
// break;
// case 2:
// deque();
// break;
// case 3:
// display();
// break;
// case 4:
// exit(1);
// default;
// printf("wrong choice");
// }
// return 0;
//}
|
3184ad2ded9411c98bf34b48afb4341c77cebcea
|
6fc5748266fa1fa12d324d192dbc4edda5ea24fc
|
/code/ghostlib/gh_logger.h
|
88078a1da724496f6007783708ba8bec23807f69
|
[] |
no_license
|
abardam/ghost-system
|
906486d2e1bddcbdd6d697418a89c4eeae9ed3b0
|
bd221326c890317cf37570a602e8856ed9a0fb91
|
refs/heads/master
| 2016-08-08T14:24:27.348627
| 2015-06-05T00:56:14
| 2015-06-05T00:56:14
| 20,339,932
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 351
|
h
|
gh_logger.h
|
#pragma once
#include <vector>
struct Log{
std::vector<int> q;
int nminus;
int nplus;
int nextra1;
int nextra2;
Log():
nminus(0),
nplus(0),
nextra1(0),
nextra2(0)
{
};
};
Log ghlog;
void addq(int n){
if(n==0)
ghlog.nplus++;
else if(n==1)
ghlog.nminus++;
else if(n==2)
ghlog.nextra1++;
else if(n==3)
ghlog.nextra2++;
}
|
abecdd3cebcb3b3588971427994b61746bdfdfd3
|
f02a2f65c974c9959f83c9d2e651b661190394c4
|
/src/Bloch/BlochB.cc
|
c0c21bb291515361f0b7d5037b315f8dd4725427
|
[
"BSD-2-Clause",
"BSD-3-Clause"
] |
permissive
|
kaustubhmote/gamma
|
f207afd5f17ebc0a0b66dc82631256c854667e49
|
c83a7c242c481d2ecdfd49ba394fea3d5816bccb
|
refs/heads/main
| 2023-03-14T12:18:59.566123
| 2021-03-03T17:58:07
| 2021-03-03T17:58:07
| 419,639,294
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 12,244
|
cc
|
BlochB.cc
|
/* BlochB.cc ****************************************************-*-c++-*-
** **
** G A M M A **
** **
** Bloch Equation B1 and Offset Matrix Implementation **
** **
** Copyright (c) 1995 **
** S.A. Smith **
** National High Magnetic Field Laboratory **
** 1800 E. Paul Dirac Drive **
** Tallahassee Florida, 32306-4005 **
** **
** $Header: $
** **
*************************************************************************/
/*************************************************************************
** **
** Description **
** **
** This file contains functions which generate basic evolution matrices **
** for use in magnetization vector evolution under the phenomenological **
** Bloch equations. In the simplest case the returned array will be **
** a 3x3 matrix which appears as **
** **
** [ 0 -w + w g*B * sin(phi) ] **
** | 0 rf 1 | **
** | | **
** B = | w - w 0 -g*B * cos(phi) | **
** | 0 rf 1 | **
** | | **
** [ -gB * sin(phi) gB * cos(phi) 0 | **
** [ 1 1 ] **
** t **
** and this will act on the magnetization vector |M> = [Mx My Mz]. **
** In a more general context, the above array will be a single block **
** on the diagonal of a larger matrix of dimension 3N x 3N where N is **
** the number of sub-vectors in a general magnetization vector . In **
** that case, the array appears as **
** **
** [ [B ] 0 0 . . . 0 ] **
** | [ 0] | **
** | [B ] 0 . . . 0 | **
** | 0 [ 1] | **
** | [B ] . . . 0 | **
** B = | 0 0 [ 2] | **
** | . . . 0 | **
** | . . . . . . | **
** | . . . . . . 0 | **
** | . . . . . . | **
** | . . . [B ] | **
** [ 0 0 0 . . . [ N-1] ] **
** **
** t **
** and will act on the magnetization vector |M> = ||M >|M >....|M >. **
** 0 1 N-1 **
** **
*************************************************************************/
#ifndef BlochB_cc_ // Is file already included?
# define BlochB_cc_ 1 // If no, then remember it
# if defined(GAMPRAGMA) // Using the GNU compiler?
# pragma implementation
# endif
#include <Bloch/BlochB.h> // Include our interface
#include <Bloch/Bloch.h> // Include Bloch auxiliary
#include <Basics/Gutils.h> // Include paramter query
#include <Basics/StringCut.h> // Include Gform function
// ____________________________________________________________________________
// A Single Component RF-Field Matrix Functions
// ____________________________________________________________________________
/* These are just direct functions which return 3x3 matrices applicable to
a "single" magnetization vector with only components {Mx, My, Mz}. In such
a case the user can just input the field strength, offset, and phase.
Input gamB1 : Applied RF field strength (Hz)
Wrf : Applied RF offset (Hz)
phi : Applied RF phase (degrees)
argc: Number of arguments
argv: Array of arguments
qn : Query index
Output R : 3x3 Bloch offset & field matrix
Note : B is output in 1/sec */
BlochMx BlochB(double gamB1, double w, double phi)
{
matrix B(3, 3, complex0);
gamB1 *= HZ2RAD; // Switch rf strength to rad/sec
phi *= DEG2RAD; // Switch phase to radians
w *= HZ2RAD; // Switch offset to rad/sec
double GBSphi = gamB1*sin(phi);
double GBCphi = gamB1*cos(phi);
B.put(-w,0,1); // Set <1|K|2> to -w
B.put(GBSphi,0,2); // <1|K|3> to gamB1*sin(phi)
B.put(w,1,0); // Set <2|K|1> to w
B.put(-GBCphi,1,2); // <2|K|3> to -gamB1*cos(phi)
B.put(-GBSphi,2,0); // <3|K|1> to -gamB1*sin(phi)
B.put( GBCphi,2,1); // <3|K|2> to gamB1*cos(phi)
return BlochMx(B);
}
// ____________________________________________________________________________
// B Two Component RF-Field Matrix Functions
// ____________________________________________________________________________
/* These are just direct functions which return 6x6 matrices applicable to
a magnetization vector with two sub-vectors: |M> = ||M1>|M2>> having the
components {M1x, M1y, M1z, M2x, M2y, M2z}. In such a case the user can just
respective field strengths, offsets, and field phases.
Input gamB1 : Applied RF field strength (Hz)
W1 : Offset of 1st sub-vector (Hz)
W2 : Offset of 2nd sub-vector (Hz)
phi : Applied RF phase (degrees)
argc: Number of arguments
argv: Array of arguments
qn : Query index
Output R : 3x3 Bloch offset & field matrix
Note : B is output in 1/sec */
BlochMx BlochB(double gamB1, double w1, double w2, double phi)
{
matrix B(6, 6, complex0);
gamB1 *= HZ2RAD; // Switch rf strength to rad/sec
phi *= DEG2RAD; // Switch phase to radians
w1 *= HZ2RAD; // Switch 1st offset to rad/sec
w2 *= HZ2RAD; // Switch 2nd offset to rad/sec
B.put(-w1,0,1); // Set <0|K|1> to -w1
B.put(gamB1*PIx2*sin(phi),0,2); // <0|K|2> to gamB1*sin(phi)
B.put(w1,1,0); // Set <1|K|0> to w1
B.put(-gamB1*PIx2*cos(phi),1,2); // <1|K|2> to -gamB1*cos(phi)
B.put(-gamB1*PIx2*sin(phi),2,0); // <2|K|0> to -gamB1*sin(phi)
B.put( gamB1*PIx2*cos(phi),2,1); // <2|K|1> to gamB1*cos(phi)
B.put(-w2,3,4); // Set <3|K|4> to -w2
B.put(gamB1*PIx2*sin(phi),3,5); // <3|K|5> to gamB1*sin(phi)
B.put(w2,4,3); // Set <4|K|3> to w2
B.put(-gamB1*PIx2*cos(phi),4,5); // <4|K|5> to -gamB1*cos(phi)
B.put(-gamB1*PIx2*sin(phi),5,3); // <5|K|3> to -gamB1*sin(phi)
B.put( gamB1*PIx2*cos(phi),5,4); // <5|K|4> to gamB1*cos(phi)
return BlochMx(B);
}
BlochMx BlochB(double gamB11, double w1, double phi1,
double gamB12, double w2, double phi2)
{
matrix B(6, 6, complex0);
gamB11 *= HZ2RAD; // Switch 1st rf strength to rad/sec
gamB12 *= HZ2RAD; // Switch 2nd rf strength to rad/sec
phi1 *= DEG2RAD; // Switch 1st phase to radians
phi2 *= DEG2RAD; // Switch 2nd phase to radians
w1 *= HZ2RAD; // Switch 1st offset to rad/sec
w2 *= HZ2RAD; // Switch 2nd offset to rad/sec
B.put(-w1,0,1); // Set <0|K|1> to -w1
B.put(gamB11*PIx2*sin(phi1),0,2); // <0|K|2> to gamB11*sin(phi1)
B.put(w1,1,0); // Set <1|K|0> to w1
B.put(-gamB11*PIx2*cos(phi1),1,2); // <1|K|2> to -gamB11*cos(phi1)
B.put(-gamB11*PIx2*sin(phi1),2,0); // <2|K|0> to -gamB11*sin(phi1)
B.put(gamB11*PIx2*cos(phi1),2,1); // <2|K|1> to gamB11*cos(phi1)
B.put(-w2,3,4); // Set <3|K|4> to -w2
B.put(gamB12*PIx2*sin(phi2),3,5); // <3|K|5> to gamB12*sin(phi2)
B.put(w2,4,3); // Set <4|K|3> to w2
B.put(-gamB12*PIx2*cos(phi2),4,5); // <4|K|5> to -gamB12*cos(phi2)
B.put(-gamB12*PIx2*sin(phi2),5,3); // <5|K|3> to -gamB12*sin(phi2)
B.put(gamB12*PIx2*cos(phi2),5,4); // <5|K|4> to gamB12*cos(phi2)
return BlochMx(B);
}
// ____________________________________________________________________________
// C Multi-Component RF-Field Matrix Functions
// ____________________________________________________________________________
BlochMx BlochB(std::vector<double> gamB1s, std::vector<double> Ws)
{
int N = gamB1s.size();
std::vector<double> phis(N,0.0);
return BlochB(gamB1s, Ws, phis);
}
BlochMx BlochB(std::vector<double> gamB1s, std::vector<double> Ws,
std::vector<double> phis)
{
int N = gamB1s.size();
matrix B(3*N, 3*N, complex0);
double w, gB1, phi;
for(int i=0; i<N; i++)
{
w = Ws[i] * HZ2RAD;
gB1 = gamB1s[i] * HZ2RAD;
phi = phis[i] * DEG2RAD;
B.put(-w, 3*i, 3*i+1);
B.put(gB1*PIx2*sin(phi), 3*i, 3*i+2);
B.put(w, 3*i+1, 3*i);
B.put(-gB1*PIx2*cos(phi), 3*i+1, 3*1+2);
B.put(-gB1*PIx2*sin(phi), 3*i+2, 3*i);
B.put(gB1*PIx2*cos(phi), 3*i+2, 3*i+1);
}
return BlochMx(B);
}
// ____________________________________________________________________________
// D RF-Field Functions Defined Over A Bloch System
// ____________________________________________________________________________
/* These are functions that will return 3Nx3N matrices where N is the number
of sub-vectors contained in the magnetization vector. In this case the
magnetization vector contains N sub-vectors each of which has components
{Mxi, Myi, Mzi}. In Bloch system keeps track of how many sub-vectors and
their respective offsets, applied fields, & field phases. The magnetization
vector which this is intended to evolve appears as
t
|M> = ||M >|M >....|M >
0 1 N-1
Input sys : Bloch system
Output B : 3Nx3N Bloch field & offset matrix
Note : B is output in 1/sec & blocked */
BlochMx BlochB(const BlochSys& sys) { return sys.B(); }
// ____________________________________________________________________________
// E Interactive Functions
// ____________________________________________________________________________
BlochMx BlochB(int argc, char* argv[], double& gamB1, double& w, double& phi, int& qn)
{
int magB = DoubleMag(gamB1);
int magW = DoubleMag(w);
double sfB, sfW;
std::string uB, uW;
uB = HzUnits(magB, sfB);
uW = HzUnits(magW, sfW);
std::string msgB = "\n\tRF-Field Strength (gamma*B1) in " + uB
+ " [" + Gform("%8.4f", gamB1*sfB) + "]? ";
std::string msgW = "\n\tVector Offset Frequency in " + uW
+ " [" + Gform("%8.4f", w*sfW) + "]? ";
ask_set(argc, argv, qn++, msgB, gamB1);
if(gamB1)
{
std::string msgP = "\n\tRF-Field Phase Angle (0=x) in Degrees ["
+ Gform("%8.4f", phi) + "]? ";
ask_set(argc, argv, qn++, msgP, phi);
}
ask_set(argc, argv, qn, msgW, w);
return BlochB(gamB1, w, phi);
}
// ____________________________________________________________________________
// F Deprecated Functions
// ____________________________________________________________________________
/* These are marked for removal in a future version. They will work but will
issue warning messages. */
matrix K_matrix(matrix& R, double gamB1, double w, double phi)
{
std::string hdr("Bloch Module");
GAMMAerror(hdr, 4, "K_matrix", 1);
GAMMAerror(hdr, 6, "BlochB", 1);
GAMMAerror(hdr, 6, "BlochR");
return R + BlochB(gamB1, w, phi);
}
matrix K_matrix(int argc, char* argv[], matrix& R,
double& gamB1, double& w, double& phi, int& qn)
{
std::string hdr("Bloch Module");
GAMMAerror(hdr, 4, "K_matrix", 1);
GAMMAerror(hdr, 6, "BlochB", 1);
GAMMAerror(hdr, 6, "BlochR");
return R + BlochB(argc, argv, gamB1, w, phi, qn);
}
#endif // BlochB.cc
|
77bc5aedee751066dbb56019ad07549a7afced7c
|
7ce91a98ae434dbb48099699b0b6bcaa705ba693
|
/TestModule/HK1/Users/20133105/Bai1.cpp
|
df05e820a4eaa5a3d2df8e8c1772a1a5588a563f
|
[] |
no_license
|
ngthvan1612/OJCore
|
ea2e33c1310c71f9375f7c5cd0a7944b53a1d6bd
|
3ec0752a56c6335967e5bb4c0617f876caabecd8
|
refs/heads/master
| 2023-04-25T19:41:17.050412
| 2021-05-12T05:29:40
| 2021-05-12T05:29:40
| 357,612,534
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 560
|
cpp
|
Bai1.cpp
|
#include <stdio.h>
void tinhdiem1(int x,int y);
void nhap(int &x, int &y, int &z , int &t, int &u, int &v );
void xuat(int A,int B,int C);
void main ()
{
int x,y,z,t,u,v;
nhap(x,y,z,t,u,v);
int A,B;
tinhdiem1(x,y);
xuat(A,B);
}
void nhap(int &x, int &y, int &z , int &t, int &u, int &v )
{
scanf("%d%d%d%d%d%d",&x,&y,&z,&t,&u,&v);
}
void xuat(int A,int B)
{
printf("%d%d",A,B);
}
void tinhdiem1(int &x,int &y)
{
int A=0;
int B=0;
if (x>y)
{
A=A+5;
B=B;
}
else
if (x==y)
{
A=A+1;
B=B+1;
}
else
if (x<y)
{
A=A;
B=B+5;
}
}
|
9bad7da364223231a7b77ece5c49235f6fef8711
|
61b23cadab2249c09fae26cb9485314207f4eab3
|
/src/frontend/iterators/IteratorUtils.tpp
|
73682f7dde5e8ddbc07df9c20f96934e7087de8b
|
[
"MIT"
] |
permissive
|
matthewbdwyer/tipc
|
c3fc058958b540830be15a2a24321dd4e60f2d69
|
92bc57d0c2f63e9d14ac6eca3fb28368ed2fa3a5
|
refs/heads/main
| 2023-08-17T03:40:51.183052
| 2023-08-15T21:09:30
| 2023-08-15T21:09:30
| 205,929,620
| 62
| 32
|
MIT
| 2023-09-02T21:38:23
| 2019-09-02T20:13:09
|
C++
|
UTF-8
|
C++
| false
| false
| 1,316
|
tpp
|
IteratorUtils.tpp
|
#include "IteratorImpl.h"
namespace IteratorUtils {
/*! \fn are_equal
* \brief A templated utility to check if to iterators are logically equal.
*
* Equality means of the same type and at the same point in the traversal process.
*/
template<typename T>
bool are_equal(T *lhs, const IteratorImpl &rhs) {
// Different iterator implementations cannot be equal.
auto rhs_downcast = dynamic_cast<decltype(lhs)>(&rhs);
if(rhs_downcast == nullptr) {
return false;
}
// If the underlying trees roots are different then the iterators are not equal.
SyntaxTree const &lhs_tree = lhs->get_tree();
SyntaxTree const &rhs_tree = rhs_downcast->get_tree();
if(lhs_tree.getRoot() != rhs_tree.getRoot()) {
return false;
}
// If we have processed a different number of nodes these iterators cannot be at the same point and are not equal.
// NB: Fragile, there is no guarantee an implementation has a stack.
std::stack<SyntaxTree> const &lhs_stack = lhs->stack;
std::stack<SyntaxTree> const &rhs_stack = rhs_downcast->stack;
if(lhs_stack.size() != rhs_stack.size()) {
return false;
}
if(lhs_stack.empty() && rhs_stack.empty()) {
return true;
}
return lhs_stack.top().getRoot() == rhs_stack.top().getRoot();
}
}
|
e169ca3d97d7edca3cfb538da69cc25bb3bd06d9
|
0440fcb4ff56e43c4faf855e441e70a99a30186a
|
/busmaster/Sources/FrameProcessor/FrameProcessor_LIN.h
|
69e23581b0cb9fc150900caaf6919686f80ea364
|
[] |
no_license
|
MarcSerraLear/UDS_Busmaster
|
0383d1d1349dc3d0e29762c1457821807f530b5d
|
9f624aa11ebc4041d6048088ac02960f38a80293
|
refs/heads/master
| 2020-05-17T12:35:02.189914
| 2014-04-14T13:44:27
| 2014-04-14T13:44:27
| 12,892,058
| 5
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,982
|
h
|
FrameProcessor_LIN.h
|
/*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU 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, see <http://www.gnu.org/licenses/>.
*/
/**
* \file FrameProcessor_LIN.h
* \brief Definition file for CFrameProcessor_LIN class.
* \author Shashank Vernekar
* \copyright Copyright (c) 2011, Robert Bosch Engineering and Business Solutions. All rights reserved.
*
* Definition file for CFrameProcessor_LIN class.
*/
#pragma once
#include "Include/BaseDefs.h"
#include "BaseFrameProcessor_LIN.h"
#include "FrameProcessor_Common.h"
#include "Format/FormatMsgLIN.h"
#include "DIL_Interface/DIL_Interface_extern.h"
#include "DIL_Interface/BaseDIL_LIN.h"
class CFrameProcessor_LIN : public CBaseFrameProcessor_LIN, CFrameProcessor_Common
{
private:
SLINPROC_PARAMS m_sLINProcParams;
CLINBufFSE m_ouFSEBufLIN;
CFormatMsgLIN m_ouFormatMsgLIN;
CBaseDIL_LIN* m_pouDilLINInterface;
void vEmptyLogObjArray(CLogObjArray& omLogObjArray);
// To create a new logging object
CBaseLogObject* CreateNewLogObj(const CString& omStrVersion);
// To delete a logging object
void DeleteLogObj(CBaseLogObject*& pouLogObj);
// To create the time mode mapping
void CreateTimeModeMapping(SYSTEMTIME& CurrSysTime, UINT64& unAbsTime);
public:
CFrameProcessor_LIN(); // Constructor
~CFrameProcessor_LIN(); // Destructor
BOOL InitInstance(void);
int ExitInstance(void);
void vRetrieveDataFromBuffer(void);
/* STARTS IMPLEMENTATION OF THE INTERFACE FUNCTIONS... */
// To initialise this module
HRESULT FPL_DoInitialisation(SLINPROC_PARAMS* psInitParams);
// To modify the filtering scheme of a logging block
HRESULT FPL_ApplyFilteringScheme(USHORT ushLogBlkID,
const SFILTERAPPLIED_LIN& sFilterObj);
// Getter for the filtering scheme of a logging block
HRESULT FPL_GetFilteringScheme(USHORT ushLogBlk,
SFILTERAPPLIED_LIN& sFilterObj);
// To enable/disable updation of the client flexray frame buffer.
HRESULT FPL_SetClientLINBufON(BOOL bEnable);
// To get the flexray buffer of this module
CBaseLINBufFSE* FPL_GetLINBuffer(void);
void FPL_vCloseLogFile();
BOOL FPL_IsDataLogged(void);
BOOL FPL_IsThreadBlocked(void);
void FPL_DisableDataLogFlag(void);
// Query function - current filtering status
// BOOL FPC_IsFilterON(void);
/* USE COMMON BASE CLASS ALIAS FUNCTIONS */
/* Call to enable/disable logging for a particular block. Having ushBlk equal
to FOR_ALL, signifies the operation to be performed for all the blocks */
HRESULT FPL_EnableLoggingBlock(USHORT ushBlk, BOOL bEnable);
// To enable/disable logging
HRESULT FPL_EnableLogging(BOOL bEnable);
/* Call to enable/disable logging for a particular block. Having ushBlk equal
to FOR_ALL, signifies the operation to be performed for all the blocks */
// HRESULT FPL_EnableFilter(USHORT ushBlk, BOOL bEnable);
// Query function - client flexray buffer updation status (OFF/ON)
BOOL FPL_IsClientLINBufON(void);
HRESULT FPL_EnableFilter(USHORT ushBlk, BOOL bEnable);
// Query function - current logging status (OFF/ON).
BOOL FPL_IsLoggingON(void);
// PTV[1.6.4]
BOOL FPL_IsLINDataLogged(void);
BOOL FPL_IsLINThreadBlocked(void);
void FPL_DisableLINDataLogFlag(void);
// Query function - current filtering status
BOOL FPL_IsFilterON(void);
// To log a string
HRESULT FPL_LogString(CString& omStr);
// To add a logging block; must be in editing mode
HRESULT FPL_AddLoggingBlock(const SLOGINFO& sLogObject);
// To remove a logging block by its index in the list; editing mode prerequisite
HRESULT FPL_RemoveLoggingBlock(USHORT ushBlk);
// Getter for total number of logging blocks
USHORT FPL_GetLoggingBlockCount(void);
// To clear the logging block list
HRESULT FPL_ClearLoggingBlockList(void);
// Getter for a logging block by specifying its index in the list
HRESULT FPL_GetLoggingBlock(USHORT ushBlk, SLOGINFO& sLogObject);
// Setter for a logging block by specifying its index in the list
HRESULT FPL_SetLoggingBlock(USHORT ushBlk, const SLOGINFO& sLogObject);
// To reset or revoke the modifications made
HRESULT FPL_Reset(void);
// To confirm the modifications made
HRESULT FPL_Confirm(void);
// To start logging block editing session
HRESULT FPL_StartEditingSession(void);
// To stop logging block editing session
HRESULT FPL_StopEditingSession(BOOL bConfirm);
// Getter for the logging configuration data
HRESULT FPL_GetConfigData(BYTE** ppvConfigData, UINT& unLength);
// For writing in to XML
HRESULT FPL_GetConfigData(xmlNodePtr pxmlNodePtr);
// Setter for the logging configuration data
HRESULT FPL_SetConfigData(BYTE* pvDataStream, const CString& omStrVersion);
//MVN
HRESULT FPL_SetConfigData(xmlDocPtr pDoc);
//~MVN
// To update the associated database list to logger
HRESULT FPL_SetDatabaseFiles(const CStringArray& omList);
// To update the channel baud rate info to logger
HRESULT FPL_SetChannelBaudRateDetails(SCONTROLLER_DETAILS_LIN* controllerDetails,
int nNumChannels,ETYPE_BUS eBus);
//Shashank
/* ENDS IMPLEMENTATION OF THE INTERFACE FUNCTIONS... */
};
|
b1e6bcd0003607b8db9578987473059f25c6e91d
|
0d4b5cf2b136202151bed99a93fc25d90ff8635e
|
/src/aho_corasick/trie.hpp
|
9ea5efe9516557076c79c6a34277008993633173
|
[
"MIT"
] |
permissive
|
AdamLutka/php-multisearch
|
1c2072c2005eb33a22f6d1c43f1cd7b1a5720290
|
0c0937b7815c91155839500389536d57e61c366c
|
refs/heads/master
| 2020-04-24T22:59:45.300426
| 2019-06-08T13:23:50
| 2019-06-08T13:23:50
| 172,329,513
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 10,493
|
hpp
|
trie.hpp
|
#ifndef MULTISEARCH_AHOC_TRIE_HPP
#define MULTISEARCH_AHOC_TRIE_HPP
#include <cstdint>
#include <cstddef>
#include <vector>
#include <queue>
#include <algorithm>
#include <limits>
#include <stdexcept>
#define NULL_NODE_INDEX UINT32_MAX
#define ROOT_NODE_INDEX 0
namespace multisearch
{
namespace ahocorasick
{
template<typename KeyT, typename ValueT>
class Trie
{
public:
using TrieT = Trie<KeyT, ValueT>;
using KeyPartT = typename KeyT::value_type;
private:
using NodeIndexT = std::uint32_t;
struct TrieNode
{
using ChildrenT = std::vector<NodeIndexT>;
NodeIndexT parent = NULL_NODE_INDEX;
NodeIndexT fail = NULL_NODE_INDEX;
NodeIndexT output = NULL_NODE_INDEX;
bool is_terminal = false;
ChildrenT children;
KeyPartT key_part;
ValueT value;
explicit TrieNode(const KeyPartT& kp) : key_part(kp) {}
};
typename TrieNode::ChildrenT::const_iterator find_child(const TrieNode& node, const KeyPartT& key_part) const
{
for (auto it = node.children.cbegin(); it != node.children.cend(); ++it)
{
if (nodes_[*it].key_part == key_part)
{
return it;
}
}
return node.children.cend();
}
void insert_child(TrieNode& node, NodeIndexT child)
{
node.children.push_back(child);
}
void sort_children()
{
for (auto& node : nodes_)
{
std::sort(node.children.begin(), node.children.end(), [this](const NodeIndexT & a, const NodeIndexT & b) {
return this->nodes_[a].key_part < this->nodes_[b].key_part;
});
}
}
void build_automaton()
{
std::queue<NodeIndexT> queue;
auto& root = nodes_[ROOT_NODE_INDEX];
for (auto child_index : root.children)
{
auto& child = nodes_[child_index];
child.fail = ROOT_NODE_INDEX;
child.output = root.is_terminal ? ROOT_NODE_INDEX : NULL_NODE_INDEX;
for (auto child_child_index : child.children)
{
queue.push(child_child_index);
}
}
while (!queue.empty())
{
auto current_index = queue.front();
auto& current = nodes_[current_index];
queue.pop();
for (auto child_index : current.children)
{
queue.push(child_index);
}
// fail
auto fail = nodes_[current.parent].fail;
while (fail != NULL_NODE_INDEX)
{
auto& fail_node = nodes_[fail];
auto it = find_child(fail_node, current.key_part);
if (it != fail_node.children.end())
{
current.fail = *it;
break;
}
else if (fail == ROOT_NODE_INDEX)
{
current.fail = ROOT_NODE_INDEX;
break;
}
fail = fail_node.fail;
}
// output
fail = current.fail;
while (fail != NULL_NODE_INDEX)
{
auto& fail_node = nodes_[fail];
if (fail_node.is_terminal)
{
current.output = fail;
break;
}
fail = fail_node.fail;
}
}
}
NodeIndexT find_node(const KeyT& key)
{
NodeIndexT current = ROOT_NODE_INDEX;
for (auto& key_part : key)
{
auto it = find_child(nodes_[current], key_part);
if (it == nodes_[current].children.end())
{
return NULL_NODE_INDEX;
}
current = *it;
}
return current;
}
std::vector<TrieNode> nodes_;
bool need_build_ = false;
bool need_sort_ = false;
public:
class iterator
{
public:
class value_type
{
public:
friend iterator;
value_type(const KeyT& k) : key(k) {}
const KeyT& getKey() const { return key; }
ValueT& getValue() const { return *value; }
private:
KeyT key;
ValueT* value = nullptr;
};
using iterator_category = std::forward_iterator_tag;
using difference_type = void;
using pointer = value_type*;
using reference = value_type&;
iterator(TrieT& trie, const NodeIndexT& node_index, const KeyT& key) : trie_(trie), current_node_(node_index), value_(key)
{
if (node_index != NULL_NODE_INDEX && !trie_.nodes_[current_node_].is_terminal)
{
this->operator++();
}
}
iterator& operator ++()
{
if (current_node_ != NULL_NODE_INDEX)
{
value_.value = nullptr;
while (current_node_ != NULL_NODE_INDEX)
{
typename TrieNode::ChildrenT::const_iterator it;
while ((it = trie_.nodes_[current_node_].children.cbegin()) != trie_.nodes_[current_node_].children.cend())
{
current_node_ = *it;
value_.key.push_back(trie_.nodes_[current_node_].key_part);
if (trie_.nodes_[current_node_].is_terminal)
{
return *this;
}
}
while (trie_.nodes_[current_node_].parent != NULL_NODE_INDEX)
{
auto& pnode = trie_.nodes_[current_node_];
auto& parent = trie_.nodes_[pnode.parent];
auto it = trie_.find_child(parent, pnode.key_part);
current_node_ = pnode.parent;
value_.key.pop_back();
if (++it == parent.children.end())
{
continue;
}
current_node_ = *it;
auto& nnode = trie_.nodes_[current_node_];
value_.key.push_back(nnode.key_part);
if (nnode.is_terminal)
{
return *this;
}
else
{
break;
}
}
if (trie_.nodes_[current_node_].parent == NULL_NODE_INDEX)
{
current_node_ = NULL_NODE_INDEX;
}
}
}
return *this;
}
const reference operator *()
{
if (current_node_ != NULL_NODE_INDEX && value_.value == nullptr)
{
value_.value = &trie_.nodes_[current_node_].value;
}
return value_;
}
const pointer operator ->()
{
return std::addressof(this->operator*());
}
bool operator ==(const iterator& it) const
{
return &trie_ == &it.trie_ && current_node_ == it.current_node_;
}
bool operator !=(const iterator& it) const
{
return !(*this == it);
}
private:
TrieT& trie_;
NodeIndexT current_node_;
value_type value_;
};
class search_iterator
{
public:
class value_type
{
public:
friend search_iterator;
const KeyT& getKey() const { return key; }
ValueT& getValue() const { return *value; }
std::size_t getPosition() { return position; }
private:
KeyT key;
ValueT* value = nullptr;
std::size_t position = 0;
};
using pointer = value_type *;
using reference = value_type &;
search_iterator(TrieT& trie, const KeyT& haystack) : trie_(trie), haystack_(haystack), haystack_it_(haystack_.cbegin()) {}
bool operator ++()
{
value_.value = nullptr;
if (output_ != NULL_NODE_INDEX && trie_.nodes_[output_].output != NULL_NODE_INDEX)
{
output_ = trie_.nodes_[output_].output;
return true;
}
while (haystack_it_ != haystack_.cend())
{
do
{
auto& node = trie_.nodes_[node_];
auto it = trie_.find_child(node, *haystack_it_);
if (it != node.children.end())
{ // we found next step
node_ = *it;
break;
}
else if (node.fail != NULL_NODE_INDEX)
{ // we go back using failure link
node_ = node.fail;
}
else
{ // we are in the root and there is no next step
break;
}
} while (true);
++haystack_it_;
if (trie_.nodes_[node_].is_terminal)
{
output_ = node_;
return true;
}
}
return false;
}
const reference operator *()
{
if (value_.value == nullptr)
{
value_.key.clear();
auto curr = output_;
while (trie_.nodes_[curr].parent != NULL_NODE_INDEX)
{
value_.key.push_back(trie_.nodes_[curr].key_part);
curr = trie_.nodes_[curr].parent;
}
std::reverse(value_.key.begin(), value_.key.end());
value_.value = &trie_.nodes_[output_].value;
value_.position = (haystack_it_ - haystack_.cbegin()) - value_.key.size();
}
return value_;
}
const pointer operator ->()
{
return std::addressof(this->operator*());
}
private:
TrieT& trie_;
const KeyT haystack_;
typename KeyT::const_iterator haystack_it_;
NodeIndexT node_ = ROOT_NODE_INDEX;
NodeIndexT output_ = NULL_NODE_INDEX;
value_type value_;
};
Trie()
{
nodes_.emplace_back(0);
}
void insert(const KeyT& key, const ValueT& value)
{
NodeIndexT current = ROOT_NODE_INDEX;
for (auto& key_part : key)
{
auto it = find_child(nodes_[current], key_part);
NodeIndexT child_index;
if (it == nodes_[current].children.end())
{
child_index = nodes_.size();
if (child_index == NULL_NODE_INDEX)
{
throw std::runtime_error("There is no space left inside the trie.");
}
nodes_.emplace_back(key_part);
nodes_[child_index].parent = current;
insert_child(nodes_[current], child_index);
}
else
{
child_index = *it;
}
current = child_index;
}
nodes_[current].value = value;
nodes_[current].is_terminal = true;
need_build_ = true;
need_sort_ = true;
}
bool remove(const KeyT& key)
{
auto current = find_node(key);
if (current != NULL_NODE_INDEX && nodes_[current].is_terminal)
{
nodes_[current].is_terminal = false;
return true;
}
else
{
return false;
}
}
search_iterator search_in(const KeyT& haystack)
{
if (need_build_)
{
build_automaton();
need_build_ = false;
}
return search_iterator(*this, haystack);
}
std::size_t get_byte_size() const
{
std::size_t size = 0;
for (auto& node : nodes_)
{
size += sizeof(TrieNode) + sizeof(typename TrieNode::ChildrenT::value_type) * node.children.size();
}
return size;
}
std::size_t get_nodes_count() const
{
return nodes_.size();
}
iterator begin()
{
if (need_sort_)
{
sort_children();
need_sort_ = false;
}
return iterator(*this, ROOT_NODE_INDEX, KeyT());
}
iterator end()
{
return iterator(*this, NULL_NODE_INDEX, KeyT());
}
iterator find(const KeyT& key)
{
auto current = find_node(key);
if (current != NULL_NODE_INDEX && nodes_[current].is_terminal)
{
return iterator(*this, current, key);
}
else
{
return end();
}
}
};
}
}
#endif
|
829b77360bea79c295c3f5233128066ba1bff020
|
785df77400157c058a934069298568e47950e40b
|
/TnbGeo/include/Pnt3dI.hxx
|
1eb6c9d80076ec767dbf27c4ffa6d6dcc904896a
|
[] |
no_license
|
amir5200fx/Tonb
|
cb108de09bf59c5c7e139435e0be008a888d99d5
|
ed679923dc4b2e69b12ffe621fc5a6c8e3652465
|
refs/heads/master
| 2023-08-31T08:59:00.366903
| 2023-08-31T07:42:24
| 2023-08-31T07:42:24
| 230,028,961
| 9
| 3
| null | 2023-07-20T16:53:31
| 2019-12-25T02:29:32
|
C++
|
UTF-8
|
C++
| false
| false
| 1,819
|
hxx
|
Pnt3dI.hxx
|
#pragma once
inline std::tuple<Standard_Real, Standard_Real, Standard_Real>
tnbLib::Pnt3d::Components() const
{
auto t = std::make_tuple(X(), Y(), Z());
return std::move(t);
}
namespace tnbLib
{
inline Pnt3d operator+(const Pnt3d& P1, const Pnt3d& P2)
{
Pnt3d Temp = P1;
Temp += P2;
return std::move(Temp);
}
inline Pnt3d operator-(const Pnt3d& P1, const Pnt3d& P2)
{
Pnt3d Temp = P1;
Temp -= P2;
return std::move(Temp);
}
inline Pnt3d operator+(const Pnt3d& P1, const Standard_Real Scalar)
{
Pnt3d Temp = P1;
Temp += Scalar;
return std::move(Temp);
}
inline Pnt3d operator+(const Standard_Real Scalar, const Pnt3d& P1)
{
Pnt3d Temp = P1;
Temp += Scalar;
return std::move(Temp);
}
inline Pnt3d operator-(const Pnt3d& P1, const Standard_Real Scalar)
{
Pnt3d Temp = P1;
Temp -= Scalar;
return std::move(Temp);
}
inline Pnt3d operator*(const Pnt3d& P1, const Standard_Real Scalar)
{
Pnt3d Temp = P1;
Temp *= Scalar;
return std::move(Temp);
}
inline Pnt3d operator*(const Standard_Real Scalar, const Pnt3d& P1)
{
Pnt3d Temp = P1;
Temp *= Scalar;
return std::move(Temp);
}
inline Pnt3d operator/(const Pnt3d& P1, const Standard_Real Scalar)
{
Pnt3d Temp = P1;
Temp /= Scalar;
return std::move(Temp);
}
inline Pnt3d CrossProduct(const Pnt3d & v1, const Pnt3d & v2)
{
Pnt3d a(v1.Y()*v2.Z() - v2.Y()*v1.Z(), v1.Z()*v2.X() - v1.X()*v2.Z(), v1.X()*v2.Y() - v2.X()*v1.Y());
return std::move(a);
}
inline Standard_Real DotProduct(const Pnt3d & P1, const Pnt3d & P2)
{
return P1.X()*P2.X() + P1.Y()*P2.Y() + P1.Z()*P2.Z();
}
inline Standard_Real Distance(const Pnt3d& P1, const Pnt3d& P2)
{
return P1.Distance(P2);
}
inline Standard_Real SquareDistance(const Pnt3d& P1, const Pnt3d& P2)
{
return P1.SquareDistance(P2);
}
}
|
0b403c86e76af3ea2d491ec4781a43405ab4cb9b
|
048fe615b129decad471b451313f424734cd5ab6
|
/mainwindow.cpp
|
d2b3e0328bb96532b5e96e10004f7154d3678540
|
[] |
no_license
|
waleramir/CPP-2019-2020-HW10
|
f9eca99209c43e7b686d6322e9449531fed3f3c9
|
68b7aebf064dd531f8a30c1081323ee8c6232c35
|
refs/heads/master
| 2021-03-30T13:13:02.064026
| 2020-03-24T06:10:00
| 2020-03-24T06:10:00
| 248,057,851
| 0
| 0
| null | 2020-03-17T19:38:07
| 2020-03-17T19:38:06
| null |
UTF-8
|
C++
| false
| false
| 2,479
|
cpp
|
mainwindow.cpp
|
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "singletonelogger.h"
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_RedPushButton_clicked()
{
SingletoneLogger::GetInstance().AppendLog("RedPushButton is clicked");
CorrectOrderCheck(Color::Red);
}
void MainWindow::on_BluePushButton_clicked()
{
SingletoneLogger::GetInstance().AppendLog("BluePushButton is clicked");
CorrectOrderCheck(Color::Blue);
}
void MainWindow::on_YellowPushButton_clicked()
{
SingletoneLogger::GetInstance().AppendLog("YellowPushButton is clicked");
CorrectOrderCheck(Color::Yellow);
}
void MainWindow::on_GreenPushButton_clicked()
{
SingletoneLogger::GetInstance().AppendLog("GreenPushButton is clicked");
CorrectOrderCheck(Color::Green);
}
void MainWindow::on_pushButton_clicked()
{
ui->pushButton->setEnabled(false);
checkIndex = 0;
isStarted = true;
ui->LogLabel->setText("Click color buttons in the right order!");
std::random_shuffle(order.begin(), order.end());
size_t sec = 1000;
for (auto const& e : order)
{
QTimer::singleShot(sec, this, [=] { ChangeFrameColor(e); });
sec += 1000;
}
QTimer::singleShot(5000, this, [=] {
ui->ColorFrame->setStyleSheet("background-color: transparent");
ui->pushButton->setEnabled(true);
});
}
void MainWindow::ChangeFrameColor(Color color)
{
switch (color)
{
case Color::Red:
ui->ColorFrame->setStyleSheet("background-color:red; border: 3px solid gray");
break;
case Color::Blue:
ui->ColorFrame->setStyleSheet("background-color:blue; border: 3px solid gray");
break;
case Color::Yellow:
ui->ColorFrame->setStyleSheet("background-color:yellow; border: 3px solid gray");
break;
case Color::Green:
ui->ColorFrame->setStyleSheet("background-color:green; border: 3px solid gray");
break;
}
}
void MainWindow::CorrectOrderCheck(Color color)
{
if (isStarted)
{
if (order.at(checkIndex) != color)
{
SingletoneLogger::GetInstance().AppendLog("You lose!");
ui->LogLabel->setText("You lose!");
isStarted = false;
}
else if (checkIndex == 3)
{
SingletoneLogger::GetInstance().AppendLog("You win!");
ui->LogLabel->setText("You win!");
isStarted = false;
}
checkIndex++;
}
else
ui->LogLabel->setText("Click the Start button!");
}
|
83759bf47e831a01e54314cfaae256cfc782993c
|
41352cd56ac6c95d7bb71aca8be26deddfc25549
|
/101-200/LeetCode 139 Word Break.cpp
|
222bf3abb12500c4284df3ba5556c4d9e4334653
|
[] |
no_license
|
xiexnot/LeetCode
|
6da864d5fb6aa610271bd1f4e8ab30ec7d651877
|
70a8242a346c7f07e5fcc1810cfaa2ca611eb1a8
|
refs/heads/master
| 2021-01-09T21:51:56.457289
| 2017-03-14T17:28:02
| 2017-03-14T17:28:02
| 49,901,278
| 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 1,517
|
cpp
|
LeetCode 139 Word Break.cpp
|
#include <iostream>
#include <cstring>
#include <string.h>
#include <vector>
using namespace std;
class Solution {
public:
bool wordBreak(string s, vector<string>& wordDict) {
int stringSize = s.size();
string tmp_s;
//cout << stringSize << endl;
vector<bool> isValid(stringSize, false);
// 我不知道为什么,如果写stringIndex- wordDict[dictIndex].size()值就会溢出 而写成 stringIndex - int(wordDict[dictIndex].size()) 就正确了
for (int stringIndex = 0; stringIndex<stringSize; stringIndex++){
for (int dictIndex = 0; dictIndex < wordDict.size(); dictIndex++){
if (stringIndex - int(wordDict[dictIndex].size()) < -1)
continue;
if (stringIndex - int(wordDict[dictIndex].size()) == -1) {
tmp_s = s;
if (tmp_s.substr(0,wordDict[dictIndex].size())==wordDict[dictIndex])
isValid[stringIndex] = true;
continue;
}
if (stringIndex - int(wordDict[dictIndex].size()) >= 0) {
if (isValid[stringIndex - int(wordDict[dictIndex].size())] == false)
continue;
tmp_s = s;
if (tmp_s.substr( stringIndex - int(wordDict[dictIndex].size())+1, int(wordDict[dictIndex].size()) ) == wordDict[dictIndex])
isValid[stringIndex] = true;
}
}
}
return isValid[stringSize-1];
}
};
int main(){
string s = "leetcode";
vector<string> wordDict;
wordDict.push_back("leet");
wordDict.push_back("code");
cout << Solution().wordBreak(s, wordDict);
}
|
825b8e62ce55d0f655273984bb8676ebe04bde8c
|
4ed3846c9070925af3be59d40a5ff4af925af492
|
/melody/melody.ino
|
10a7b4ae61c8e30f94afe3d4e5f8a0743180da8e
|
[] |
no_license
|
FSpaceLab/musicalBuzzer
|
677f03dd1d7acd12680fc7dfeb3567c3143b3252
|
9b68a96663f161ce46ae60b412857689ada797f3
|
refs/heads/master
| 2021-06-26T21:21:17.088835
| 2017-09-16T19:10:07
| 2017-09-16T19:10:07
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,785
|
ino
|
melody.ino
|
int buzzer = 9;
int button = 2;
// ноти та їх частоти
int frq[] = {262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494, 523,
554, 587, 622, 659, 698, 740, 0, 247, 233, 220, 208, 196, 185, 174};
int fa0=frq[26], fa_dies0=frq[25],
sol0=frq[24], sol_dies0=frq[23],
la0=frq[22], la_dies0=frq[21],
si0=frq[20],
doo=frq[0], do_dies=frq[1],
re=frq[2], re_dies=frq[3],
mi=frq[4],
fa=frq[5], fa_dies=frq[6],
sol=frq[7], sol_dies=frq[8],
la=frq[9], la_dies=frq[10],
si=frq[11],
doo2=frq[12], doo_dies2=frq[13],
re2=frq[14], re_dies2=frq[15],
mi2=frq[16],
fa2=frq[17], fa_dies2=frq[18],
nul=frq[19];
// тривалість нот
int SEMIB = 700; // semibreve - ціла нота
int HALF = 350; // half-note - половинна нота
int QUART = 175; // quarter noet - четвертинна нота
int POINT = 150;
int PAUSE = 0;
int count = 0;
// мелодії
int sword_areas[] = {doo,SEMIB, doo,SEMIB, doo,HALF, re,HALF, re_dies,HALF,
doo,HALF, re,SEMIB, re,SEMIB, re,SEMIB, re,HALF, re_dies,HALF,
fa,SEMIB, fa,SEMIB, fa,HALF, re_dies,HALF, re,HALF,
doo,HALF, re_dies,SEMIB, doo,SEMIB, doo,SEMIB};
int star_wars[] = {sol,SEMIB, sol,SEMIB, sol,SEMIB, re_dies,HALF+POINT, la_dies,QUART,
sol,SEMIB, re_dies,HALF+POINT, la_dies,QUART, sol,SEMIB, nul,PAUSE+SEMIB,
re2,SEMIB, re2,SEMIB, re2,SEMIB, re_dies2,HALF+POINT, la_dies,QUART,
fa_dies,SEMIB, re_dies,HALF+POINT, la_dies,QUART, sol,SEMIB, nul,PAUSE+SEMIB,};
int slaven[] = {mi,SEMIB+POINT, mi,HALF, mi,HALF, re,HALF, mi,HALF, fa,HALF, sol,SEMIB+POINT,
fa,HALF, mi,SEMIB, re,SEMIB, doo,SEMIB, mi,SEMIB, si0,SEMIB, mi,SEMIB,
la0,HALF, sol_dies0,HALF, la0,HALF, si0,HALF, doo,SEMIB, re,SEMIB,
mi,SEMIB+POINT, mi,HALF, mi,HALF, re,HALF, mi,HALF, fa,HALF, sol,SEMIB+POINT,
fa,HALF, mi,SEMIB, re,SEMIB, doo,SEMIB, la0,SEMIB, mi,SEMIB, sol_dies0,SEMIB,
la0,SEMIB+SEMIB, la0,SEMIB};
void setup() {
pinMode(buzzer, OUTPUT);
Serial.begin(9600);
pinMode(button, INPUT);
}
void loop() {
if (digitalRead(button) == LOW){
if (count == 0)
play(slaven, sizeof(sword_areas)/2);
else if (count == 1)
play(sword_areas, sizeof(sword_areas)/2);
else if (count == 2)
play(star_wars, sizeof(star_wars)/2);
count++;
}
}
void play(int*melody, int len){
delay(750);
for (int i = 0; i < len; i++){
tone(buzzer, melody[i]);
delay(melody[++i]);
noTone(buzzer);
delay(75);
if (digitalRead(button) == LOW)
break;
}
}
|
cee1d296192834a91a51933cbd03fc7cac77fd25
|
c08ef583d7700f734502aa624276046a0f55e63b
|
/Ficheros/AsteroidsManager.h
|
4e1d118e3fe1bbeceefdf1fdf130578af19a5235
|
[] |
no_license
|
jorgerodrigar/Asteroids
|
9c86577f6a0e6acacf4c314669d37c71699ce7cc
|
85c6d15a5c59961be896e57fde314c58098df983
|
refs/heads/master
| 2021-01-25T11:48:18.492270
| 2018-04-17T11:05:19
| 2018-04-17T11:05:19
| 123,428,212
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,617
|
h
|
AsteroidsManager.h
|
#ifndef ASTEROIDMANAGER_H_
#define ASTEROIDMANAGER_H_
#include "GameObject.h"
#include "Observer.h"
#include "Observable.h"
#include "ImageRenderer.h"
#include "CircularMotionPhysics.h"
#include "RotationPhysics.h"
#include "checkML.h"
//gestor de asteroides
class AstroidsManager : public GameObject, public Observer, public Observable {
public:
AstroidsManager(SDLGame* game) :GameObject(game){
SDL_Rect rect;
rect.x = 0;
rect.y = 0;
rect.w = 145;
rect.h = 130;
//componentes que tendran todos los asteroides
astroidImage_ = ImageRenderer(game->getResources()->getImageTexture(Resources::asteroid), rect);
circularPhysics_ = CircularMotionPhysics();
rotationPhysics_ = RotationPhysics(2.0);
numOfAstroids_ = 0;
}
virtual ~AstroidsManager(){
for (int i = 0; i < astroids_.size(); i++) delete(astroids_[i]);
}
virtual void handleInput(Uint32 time, const SDL_Event& event){}
virtual void update(Uint32 time){ for (int i = 0; i < astroids_.size(); i++)if (astroids_[i]->getActive())astroids_[i]->update(time); }
virtual void render(Uint32 time){ for (int i = 0; i < astroids_.size(); i++)if (astroids_[i]->getActive())astroids_[i]->render(time); }
virtual vector<Asteroid*>& getAstroids(){ return astroids_; }
virtual void receive(Message* msg);
private:
Asteroid* getAstroid();
void initAsteroids();
vector<Asteroid*> astroids_;//vector de todos los asteroides del juego (activos e inactivos)
ImageRenderer astroidImage_;
CircularMotionPhysics circularPhysics_;
RotationPhysics rotationPhysics_;
int numOfAstroids_, numAstroidsInicial = 5;
};
#endif /* ASTEROIDMANAGER_H_ */
|
89a5dda5b7d7a07617265cd236443de8842ac688
|
372f25110b5e8b629bcea81b6a8ed08dcab3b5f9
|
/my9291.h
|
f00e29bd8d18b1c0b0800b3831d5f30725a3b635
|
[] |
no_license
|
marcin-kasinski/ESPManager
|
bfdde5a4e835069616c1beae7f75b25b053591e3
|
40b96859ec431190171df049590a510ab65c98e9
|
refs/heads/master
| 2021-06-23T22:28:35.781112
| 2021-02-09T16:43:55
| 2021-02-09T16:43:55
| 203,177,783
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,905
|
h
|
my9291.h
|
/*
#ifndef _my9291_h
#define _my9291_h
#include <Arduino.h>
#ifdef DEBUG_MY9291
#if ARDUINO_ARCH_ESP8266
#define DEBUG_MSG_MY9291(...) DEBUG_MY9291.printf( __VA_ARGS__ )
#elif ARDUINO_ARCH_AVR
#define DEBUG_MSG_MY9291(...) { char buffer[80]; snprintf(buffer, sizeof(buffer), __VA_ARGS__ ); DEBUG_MY9291.print(buffer); }
#endif
#else
#define DEBUG_MSG_MY9291(...)
#endif
typedef enum my9291_cmd_one_shot_t {
MY9291_CMD_ONE_SHOT_DISABLE = 0X00,
MY9291_CMD_ONE_SHOT_ENFORCE = 0X01,
} my9291_cmd_one_shot_t;
typedef enum my9291_cmd_reaction_t {
MY9291_CMD_REACTION_FAST = 0X00,
MY9291_CMD_REACTION_SLOW = 0X01,
} my9291_cmd_reaction_t;
typedef enum my9291_cmd_bit_width_t {
MY9291_CMD_BIT_WIDTH_16 = 0X00,
MY9291_CMD_BIT_WIDTH_14 = 0X01,
MY9291_CMD_BIT_WIDTH_12 = 0X02,
MY9291_CMD_BIT_WIDTH_8 = 0X03,
} my9291_cmd_bit_width_t;
typedef enum my9291_cmd_frequency_t {
MY9291_CMD_FREQUENCY_DIVIDE_1 = 0X00,
MY9291_CMD_FREQUENCY_DIVIDE_4 = 0X01,
MY9291_CMD_FREQUENCY_DIVIDE_16 = 0X02,
MY9291_CMD_FREQUENCY_DIVIDE_64 = 0X03,
} my9291_cmd_frequency_t;
typedef enum my9291_cmd_scatter_t {
MY9291_CMD_SCATTER_APDM = 0X00,
MY9291_CMD_SCATTER_PWM = 0X01,
} my9291_cmd_scatter_t;
typedef struct {
my9291_cmd_scatter_t scatter:1;
my9291_cmd_frequency_t frequency:2;
my9291_cmd_bit_width_t bit_width:2;
my9291_cmd_reaction_t reaction:1;
my9291_cmd_one_shot_t one_shot:1;
unsigned char resv:1;
} __attribute__ ((aligned(1), packed)) my9291_cmd_t;
typedef struct {
unsigned int red;
unsigned int green;
unsigned int blue;
unsigned int white;
unsigned int warm;
} my9291_color_t;
#define MY9291_COMMAND_DEFAULT { \
.scatter = MY9291_CMD_SCATTER_APDM, \
.frequency = MY9291_CMD_FREQUENCY_DIVIDE_1, \
.bit_width = MY9291_CMD_BIT_WIDTH_8, \
.reaction = MY9291_CMD_REACTION_FAST, \
.one_shot = MY9291_CMD_ONE_SHOT_DISABLE, \
.resv = 0 \
}
class my9291 {
public:
my9291(unsigned char di, unsigned char dcki, my9291_cmd_t command, unsigned char channels = 4);
void setColor(my9291_color_t color);
my9291_color_t getColor();
void setState(bool state);
bool getState();
private:
void _di_pulse(unsigned int times);
void _dcki_pulse(unsigned int times);
void _set_cmd(my9291_cmd_t command);
void _send();
void _write(unsigned int data, unsigned char bit_length);
my9291_cmd_t _command;
unsigned char _channels = 4;
bool _state = false;
my9291_color_t _color = {0, 0, 0, 0, 0};
unsigned char _pin_di;
unsigned char _pin_dcki;
};
#endif
*/
|
b2dd27975ce525d374f9a735ff7d5ec26d92299c
|
a2c1d471a40791ded0d87dbbe765a4490830d6d0
|
/primitive_calculator.cpp
|
f288f57b84d803308610078d233775a1294312be
|
[] |
no_license
|
iCodeIN/algorithmic-toolbox
|
92d6347c590c1aaeccf2c8c0a2f26b7594b22dd1
|
41d027c1739cd3bfed0d02c28134d5cf23306667
|
refs/heads/main
| 2023-02-10T18:30:11.201716
| 2020-12-28T06:34:57
| 2020-12-28T06:34:57
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 847
|
cpp
|
primitive_calculator.cpp
|
#include<bits/stdc++.h>
using namespace std;
vector<int> optimal_sequence(int n) {
vector<int>res;
if(n==1)
{
res = {1};
return res;
}
vector<int>dp(n+1);
dp[0]=0;
dp[1]=0;
int i,a,b,c,mini;
for(i=2;i<=n;i++)
{
dp[i] = dp[i-1] + 1;
if(i%2==0)
dp[i] = min(dp[i], dp[i/2] + 1);
if(i%3==0)
dp[i] = min(dp[i], dp[i/3] + 1);
}
for(i=n;i>1;)
{
res.push_back(i);
if(dp[i] == dp[i-1] + 1)
{
i=i-1;
}
else if((i%2==0) && (dp[i] == 1 + dp[i/2]))
{
i=i/2;
}
else if((i%3==0) && (dp[i] == 1 + dp[i/3]))
{
i=i/3;
}
}
res.push_back(1);
reverse(res.begin(),res.end());
return res;
}
int main() {
int n;
std::cin >> n;
vector<int> sequence = optimal_sequence(n);
std::cout << sequence.size() - 1 << std::endl;
for (size_t i = 0; i < sequence.size(); ++i) {
std::cout << sequence[i] << " ";
}
}
|
35cfd1dd908e9869061bc2fcf099099269e18502
|
13e0eecafe1347f218bf8083b3f848c5e17bf0ef
|
/lib/inc/SocketTemplate.h
|
a94e43835057544aa138c4509f23500ce988ac41
|
[] |
no_license
|
psemchyshyn/GoodAsio
|
4d058336224501b5ae215d8c2b7533961737d022
|
8379937bb7ad9b5b2b7b6406b546549027fc46ec
|
refs/heads/master
| 2023-05-20T03:15:16.220010
| 2021-06-11T12:42:28
| 2021-06-11T12:42:28
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 717
|
h
|
SocketTemplate.h
|
#ifndef ECHO_SERVER_SOCKETTEMPLATE_H
#define ECHO_SERVER_SOCKETTEMPLATE_H
#include <string>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/epoll.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <iostream>
#include <fstream>
#include "TimeMeasurement.h"
#include <vector>
#include <algorithm>
#include <set>
class ServerSocket;
class Socket {
protected:
int fd_;
public:
explicit Socket(int fd);;
int get_fd() const;
virtual ~Socket();
virtual void sread() =0;
virtual void swrite(){};
};
#endif //ECHO_SERVER_SOCKETTEMPLATE_H
|
5b5497e31575ae2ee6aefc63761b2b7d3be4bc17
|
f397d08afdc45479dafe124f4664628b8c31e473
|
/c17/type/type.cpp
|
786cb6b2d44335ce5d7d9390218d9e1847c979bd
|
[] |
no_license
|
eiselekd/lang
|
15e2110a0682f422d8cb424e100e3452b0ca00c6
|
a35dc9490071ca55a2ea42ca52eb0b3a93ff0a7b
|
refs/heads/master
| 2021-07-20T16:06:56.223511
| 2021-06-24T18:46:33
| 2021-06-24T18:46:33
| 95,143,543
| 0
| 0
| null | 2020-09-04T04:48:20
| 2017-06-22T18:10:55
|
C
|
UTF-8
|
C++
| false
| false
| 973
|
cpp
|
type.cpp
|
#include <iostream>
#include <string>
#include <array>
#include <map>
#include <functional>
#include <memory>
#include "method_c.h"
struct classdef {
std::map<int, method *> tbl;
struct classdef *super;
void add_method(int id, method *m) {
decltype(tbl)::iterator i;
if ((i = tbl.find(id)) != tbl.end()) {
}
tbl.insert({id,m});
}
method *
lookup(int id)
{
decltype(this) c = this;
decltype(tbl)::iterator i;
while ((i = tbl.find(id)) == tbl.end()) {
c = c->super;
if (!c)
return 0;
}
return i->second;
};
template<class Ld, typename = void>
void add_c_method(int id, Ld &&f)
{
tbl[id] = new method_c(std::forward<Ld>(f));
};
};
void f1(int a, int b) {
};
struct classdef_object : classdef {
classdef_object() {
add_c_method<decltype(f1)>(1, f1);
add_c_method(2, []() {} );
}
};
#ifdef _GEN_TYPE_MAIN_
int
main(int argc, char **argv) {
classdef_object c;
return 0;
}
#endif
|
ca2d9834cd4b84ecf95a936f5fcf4a7d4d7213de
|
ebe5abd1ffa82fbcd45b430cf8360d111f0344c8
|
/04-Collision/MainScene.cpp
|
54a8bb9305f35d92cc527de61117f5c6a9d5daf4
|
[] |
no_license
|
khduy/castle_vania
|
f421ccf733d51452a12dd0f5b57f513e659d59a2
|
3793c0a916b5c6aad5c4d18058d98955972d1924
|
refs/heads/master
| 2023-02-03T16:31:18.296964
| 2020-12-21T01:53:53
| 2020-12-21T01:53:53
| 299,236,391
| 0
| 1
| null | 2020-10-22T09:09:34
| 2020-09-28T08:11:21
|
C++
|
UTF-8
|
C++
| false
| false
| 66,707
|
cpp
|
MainScene.cpp
|
#include "MainScene.h"
MainScene::MainScene()
{
LoadResources();
}
MainScene::~MainScene()
{
SAFE_DELETE(tileMap);
SAFE_DELETE(board);
SAFE_DELETE(gridGame);
}
void MainScene::KeyState(BYTE* state)
{
if (simon->GetFreeze() == true) // disable control
return;
if (simon->GetIsDeadth() || isWaitingToResetGame || isGameOver) // Nếu Simon chết hoặc game over và đang đợi reset game thì ko quan tâm phím
return;
// Nếu Simon đang tự đi
if (simon->GetIsAutoGoX() == true) // Đang chế độ tự đi thì ko xét phím
return;
if (camera->GetIsAutoGoX()) // Camera đang chế độ tự đi thì ko xét phím
return;
if (simon->isHurting) // Simon đang bị thương thì ko quan tâm phím
return;
if (Game::GetInstance()->IsKeyDown(DIK_UP) && Game::GetInstance()->IsKeyDown(DIK_A) && simon->isProcessingOnStair == 0 && !simon->isAttacking)
{
simon->Attack(simon->GetTypeSubWeapon()); // Attack với vũ khí phụ Simon nhặt dc
}
else
if (!simon->isJumping)
{
if (Game::GetInstance()->IsKeyDown(DIK_UP) && simon->isAttacking == false)
{
if (!simon->isOnStair) // Simon chưa trên thang
{
for (UINT i = 0; i < listObj.size(); i++)
if (listObj[i]->GetType() == TAG::STAIR_BOTTOM)
{
if (simon->isCollisionAxisYWithBrick && simon->isCollitionObjectWithObject(listObj[i])) // nếu va chạm với trục y brick và STAIR BOTOM
{
GameObject* gameobj = dynamic_cast<GameObject*>(listObj[i]);
simon->directionStair = gameobj->GetDirection(); // Lưu hướng của cầu thang đang đi vào simon
simon->directionY = -1; // Hướng đi lên
simon->SetDirection(simon->directionStair); // Hướng của simon khi đi lên là hướng của cầu thang
simon->isOnStair = true; // Set trạng thái đang trên cầu thang
simon->passedDistance = 0;
// Trường hợp Simon va chạm 1 trong 2 bìa của StairTop
if (simon->GetX() < gameobj->GetX())
{
// Biên phải
simon->SetAutoGoX(1, gameobj->GetDirection(), gameobj->GetX() - simon->GetX(), SIMON_WALKING_SPEED);
// Hướng sau khi autogo phải là hướng của cầu thang: gameobj->GetDirection()
}
else // Biên trái
simon->SetAutoGoX(-1, gameobj->GetDirection(), simon->GetX() - gameobj->GetX(), SIMON_WALKING_SPEED);
// DebugOut(L"bat dau len cau thang!\n");
return;
}
}
}
else // Nếu Simon đã trên cầu thang
{
DebugOut(L"Da o tren cau thang!\n");
if (simon->isProcessingOnStair == 0 || simon->isProcessingOnStair == 3) // Kết thúc xử lí trước đó
{
simon->isWalking = true;
simon->isProcessingOnStair = 1;
simon->directionY = -1; // Hướng đi lên
simon->SetDirection(simon->directionStair); // Hướng của simon khi đi lên là hướng của cầu thang
simon->SetSpeed(simon->GetDirection() * SIMON_SPEED_ONSTAIR, -1 * SIMON_SPEED_ONSTAIR);
float vvx, vvy;
simon->GetSpeed(vvx, vvy);
//DebugOut(L"vy = %f\n", vvy);
}
}
}
else
{
if (Game::GetInstance()->IsKeyDown(DIK_DOWN) && simon->isAttacking == false) // Ngược lại nếu nhấn nút xuống
{
if (!simon->isOnStair) // Chưa trên cầu thang
{
int CountCollisionTop = 0;
for (UINT i = 0; i < listObj.size(); i++)
if (listObj[i]->GetType() == TAG::STAIR_TOP)
{
if (simon->isCollitionObjectWithObject(listObj[i])
&&
simon->isCollisionAxisYWithBrick
) // Nếu va chạm với STAIR TOP
{
GameObject* gameobj = dynamic_cast<GameObject*>(listObj[i]);
simon->directionStair = gameobj->GetDirection(); // lưu hướng của cầu thang đang đi vào simon
simon->directionY = 1;// hướng đi xuống
simon->SetDirection(simon->directionStair);// hướng của simon khi đi xuống là hướng của cầu thang
simon->isOnStair = true; // set trạng thái đang trên cầu thang
simon->passedDistance = 0;
if (simon->GetX() < gameobj->GetX())
{
simon->SetAutoGoX(1, -gameobj->GetDirection(), gameobj->GetX() - simon->GetX(), SIMON_WALKING_SPEED);
// hướng sau khi autogo phải là hướng của cầu thang: gameobj->GetDirection()
}
else
simon->SetAutoGoX(-1, -gameobj->GetDirection(), simon->GetX() - gameobj->GetX(), SIMON_WALKING_SPEED);
CountCollisionTop++;
return;
}
}
if (CountCollisionTop == 0) // Ko đụng stair top, tức là ngồi bt
{
simon->Sit();
if (Game::GetInstance()->IsKeyDown(DIK_RIGHT))
simon->Right();
if (Game::GetInstance()->IsKeyDown(DIK_LEFT))
simon->Left();
return;
}
}
else // Đã ở trên cầu thang thì có thể đi xuống
{
if (simon->isProcessingOnStair == 0 || simon->isProcessingOnStair == 3) // Kết thúc xử lí trước đó
{
simon->isWalking = true;
simon->isProcessingOnStair = 1;
simon->directionY = 1; // Hướng đi xuống
simon->SetDirection(simon->directionStair * -1); // Hướng của simon khi đi xuóng là ngược của cầu thang
simon->SetSpeed(simon->GetDirection() * SIMON_SPEED_ONSTAIR, SIMON_SPEED_ONSTAIR);
}
}
}
else
{
simon->Stop();
}
}
}
// Trạng thái nhảy theo 1 hướng thì ko thể attack hay đổi chiều Simon
if (simon->isJumping && simon->isWalking)
return;
if (simon->isOnStair) // Nếu đang trên thang thì không xét loại đi trái phải
return;
// Simon tấn công khi đang nhảy
if (simon->isAttacking && simon->isJumping)
return;
if (simon->isAttacking) // Nếu Simon đang attack thì không thể đi tiếp
{
float vx, vy;
simon->GetSpeed(vx, vy);
simon->SetSpeed(0, vy);
return;
}
// Nếu đang nhảy thì ko thể đổi chiều Simon
if (simon->isJumping)
return;
// Simon đang tấn công thì ko thể đi dc
if (Game::GetInstance()->IsKeyDown(DIK_RIGHT) && simon->isSitting == false)
{
simon->Right();
simon->Go();
}
else
if (Game::GetInstance()->IsKeyDown(DIK_LEFT) && simon->isSitting == false)
{
simon->Left();
simon->Go();
}
else
{
simon->Stop();
}
}
void MainScene::OnKeyDown(int KeyCode)
{
if (KeyCode == DIK_R) // render bbox debug
{
if (isDebug_RenderBBox == 0)
isDebug_RenderBBox = 1;
else
isDebug_RenderBBox = 0;
}
if (simon->GetFreeze() == true) // Đang bóng băng thì không quan tâm phím
return;
#pragma region Xử lý nút khi trong màn hình chọn option khi reset game và gameover
if (isGameOver)
{
switch (KeyCode)
{
case DIK_UP:
{
GameOverSelectedOption = GAMEOVER_SELECT_CONTINUE;
break;
}
case DIK_DOWN:
{
GameOverSelectedOption = GAMEOVER_SELECT_END;
break;
}
case DIK_RETURN:
{
// Xét option lựa chọn để reset hoặc thoát game
if (GameOverSelectedOption == GAMEOVER_SELECT_CONTINUE)
{
simon = new Simon(camera); // Reset lại Simon
InitGame(); // Reset lại các biến, object
isGameOver = false;
}
else
if (GameOverSelectedOption == GAMEOVER_SELECT_END)
{
DestroyWindow(Game::GetInstance()->GetWindowHandle()); // Thoát game
}
break;
}
}
return;
}
if (simon->GetIsDeadth() || isWaitingToResetGame) // Nếu Simon chết hoặc đang chờ reset game thì ko quan tâm phím
{
return;
}
#pragma endregion
if (simon->GetIsAutoGoX()) // Simon đang ơ chế độ tự đi thì ko xét phím
return;
if (camera->GetIsAutoGoX()) // Camera đang ở chế độ tự đi thì ko xét phím
return;
if (simon->isHurting) // Simon đang bị thương thì ko quan tâm phím
return;
if (!(Game::GetInstance()->IsKeyDown(DIK_UP) && Game::GetInstance()->IsKeyDown(DIK_A) && simon->isProcessingOnStair != 0 && simon->isAttacking == true))
if (KeyCode == DIK_A && simon->isProcessingOnStair == 0) // Không phải đang xử lí việc đi trên thang thì đc đánh
{
simon->Attack(TAG::MORNINGSTAR);
}
// Nếu Simon đang nhảy thì ko bắt lệnh nhảy
if (simon->isJumping && simon->isWalking)
return;
// Nếu Simon đang attack thì ko cho nhảy
if (simon->isAttacking)
return;
if (KeyCode == DIK_S && simon->isOnStair == false)
{
if (simon->isJumping == false) // Nếu đang nhảy thì ko cho ấn S nữa
if (Game::GetInstance()->IsKeyDown(DIK_LEFT) || Game::GetInstance()->IsKeyDown(DIK_RIGHT))
{
simon->Stop();
simon->SetSpeed(SIMON_WALKING_SPEED * simon->GetDirection(), -SIMON_VJUMP);
simon->isJumping = 1;
simon->isWalking = 1;
}
else
{
simon->Jump();
}
}
#pragma region Keydown Debug
if (KeyCode == DIK_U)
{
if (isDebug_Untouchable == 1)
isDebug_Untouchable = 0;
else
isDebug_Untouchable = 1;
}
if (KeyCode == DIK_1)
{
DebugOut(L"[SET POSITION SIMON] x = .... \n");
simon->SetPosition(3940, 100);
isAllowToCreateFishmen = false;
}
#pragma endregion
}
void MainScene::OnKeyUp(int KeyCode)
{
if (simon->GetFreeze() == true) // Đang bóng băng thì không quan tâm phím
{
return;
}
//if (simon->GetIsDeadth() || isWaitingToResetGame || isGameOver) // Nếu Simon chết hoặc game over và đang đợi reset game thì ko quan tâm phím
//{
// return;
//}
}
void MainScene::LoadResources()
{
TextureManager* _textureManager = TextureManager::GetInstance();
tileMap = new Map();
gridGame = new Grid();
camera = new Camera(SCREEN_WIDTH, SCREEN_HEIGHT);
simon = new Simon(camera);
board = new Board(BOARD_DEFAULT_POSITION_X, BOARD_DEFAULT_POSITION_Y);
gameTime = new GameTime();
gameSound = GameSound::GetInstance();
_spriteLagerHeart = new Sprite(TextureManager::GetInstance()->GetTexture(TAG::LARGEHEART), 100);
InitGame();
}
void MainScene::InitGame()
{
LoadMap(TAG::MAP1);
simon->Init();
gameTime->SetTime(0); // Đếm lại thời gian đã chơi bắt đầu từ 0
PlayGameMusic(); // Bắt đầu chạy âm thanh game
}
// Load map thì reset lại các grid, enemy, cử lý qua cửa, gameover
void MainScene::ResetResource()
{
gridGame->ReloadGrid();
listItem.clear();
listEffect.clear();
listEnemy.clear();
listWeaponOfEnemy.clear();
camera->SetAllowFollowSimon(true);
isHandlingGoThroughTheDoor1 = false; // Ban đầu chưa cần xử lí qua cửa 1
isWentThroughTheDoor1 = false;
isHandlingGoThroughTheDoor2 = false; // Ban đầu chưa cần xử lí qua cửa 2
isWentThroughTheDoor2 = false;
isUsingInvisibilityPotion = false; // Ban đầu thì Simon chưa tàng hình
isUsingCross = false; // Ban đầu Simon chưa nhắt dc thánh giá
// Boss
if (phantomBat != NULL)
{
phantomBat->ResetResource();
}
// Ghost
CurrentGhostEnemyCount = 0;
CreateGhostTime = 0;
isWaitingToCreateGhost = false; // Lúc đầu thì tạo ghost luôn và không cần chờ
// Black Panther
isAllowCreatePanther = true;
CurrentPantherEnemyCount = 0;
// Bat
CreateBatTime = 0;
WaitingTimeToCreateBat = 0;
isAllowToCreateBat = 0;
// Fishmen
isAllowToCreateFishmen = false;
CreateFishmenTime = 0;
WaitingtimeToCreateFishmen = 0;
CurrentFishmenEnemyCount = 0;
/* Set các biến xử lý cho màn đen chờ reset game*/
isWaitingToResetGame = true;
WaitedTimeToResetGame = 0;
/*Xử lý gameover*/
isGameOver = false;
GameOverSelectedOption = GAMEOVER_SELECT_CONTINUE;
}
void MainScene::Update(DWORD dt)
{
// Nếu gameover thì ko Update nữa
if (isGameOver)
return;
// Xử lí freeze
if (simon->GetFreeze() == true)
{
simon->UpdateFreeze(dt);
if (simon->GetFreeze() == true)// dang freeze thì k update
return;
}
//===================================================================================================//
#pragma region Debug Update
if (isDebug_Untouchable == 1)
simon->StartUntouchable();
#pragma endregion
#pragma region Xử lí khi đang vẽ màn đen chờ trước khi bắt đầu game
if (isWaitingToResetGame)
{
WaitedTimeToResetGame += dt; // Nếu chưa chờ đủ thời gian thì sẽ chờ tiếp
if (WaitedTimeToResetGame >= LIMIT_TIME_WAITING_TO_RESET_GAME) // Đã chờ đủ thì reset biến cờ
{
isWaitingToResetGame = false;
}
else
return;
}
#pragma endregion
#pragma region Update game time và health của Simon
// Không đang clear state 3 mới xét trạng thái chết
if (!isAllowHandleClearStage3)
{
if (gameTime->GetPassedTime() >= MAX_GAME_TIME || simon->GetHealth() <= 0) // Hết thời gian hoặc hết máu
{
if (simon->GetIsDeadth())
{
simon->WaitedTimeAfterDeath += dt;
if (simon->WaitedTimeAfterDeath >= 1500)
{
bool result = simon->LoseLife(); // Đã khôi phục x,y
if (result == true) // Nếu Simon còn mạng để chơi tiếp, giảm mạng reset máu xong
{
camera->RestorePosition(); // Khôi phục vị trí camera;
camera->RestoreBoundary(); // Khôi phục biên camera
gameTime->SetTime(0);
PlayGameMusic();
ResetResource(); // Reset lại game
}
else
{
isGameOver = true;
}
return;
}
}
else // Nếu Simon chưa chết mà hết máu hoặc time thì set trạng thái isDeadth
{
simon->SetDeadth();
}
}
else
{
if (isAllowHandleClearStage3 == false) // Nếu ko đang xử lí Clear State 3 thì đếm time bình thường
{
gameTime->Update(dt);
}
}
if (MAX_GAME_TIME - gameTime->GetPassedTime() <= 30) // Còn lại 30 giây thì bật sound loop
{
if (gameTime->GetIsChanged()) // Kiểm tra _passedTime đã thay đổi thì mới play nhạc. Nếu chỉ kt <=30s thì cứ mỗi deltatime nó sẽ Play nhạc -> thừa
{
gameSound->Play(Sound::soundStopTimer);
}
}
}
#pragma endregion
// Phần xử lý map 2
#pragma region Xử lý đi qua Gate 1
if (isHandlingGoThroughTheDoor1) // Simon chạm cửa thì bắt đầu xử lí
{
if (isWentThroughTheDoor1 == false) // Simon chưa hoàn thành việc qua cửa
{
if (camera->GetXCam() >= GATE1_POSITION_CAM_BEFORE_GO) // Camera đã AutoGo xong đến vị trí 2825.0f
{
simon->SetAutoGoX(1, 1, abs(GATE1_POSITION_CAM_AFTER_GO + DISTANCE_AUTO_WALK_AFTER_GATE - simon->GetX()), SIMON_WALKING_SPEED); // bắt đầu cho simon di chuyển tự động đến vị trí tiếp theo
}
}
else
{
if (camera->GetXCam() >= GATE1_POSITION_CAM_AFTER_GO)
{
camera->SetBoundary(GATE1_POSITION_CAM_AFTER_GO, camera->GetBoundaryRight());
camera->SetBoundaryBackup(camera->GetBoundaryLeft(), camera->GetBoundaryRight());
camera->SetAllowFollowSimon(true);
isHandlingGoThroughTheDoor1 = false; // Xong việc xử lí qua cửa 1
camera->StopAutoGoX(); // Dừng việc tự di chuyển
}
}
}
#pragma endregion
//===================================================================================================//
#pragma region Xử lý qua Gate 2
if (isHandlingGoThroughTheDoor2) // Siimon chạm cửa thì bắt đầu xử lí
{
if (isWentThroughTheDoor2 == false) // Simon chưa hoàn thành việc qua cửa
{
if (camera->GetXCam() >= GATE2_POSITION_CAM_BEFORE_GO) // Camera đã auto go xong đến vị trí 3840.0f
{
simon->SetAutoGoX(1, 1, abs(GATE2_POSITION_CAM_AFTER_GO + DISTANCE_AUTO_WALK_AFTER_GATE - simon->GetX()), SIMON_WALKING_SPEED); // Bắt đầu cho simon di chuyển tự động đến vị trí tiếp theo
}
}
else
{
if (camera->GetXCam() >= GATE2_POSITION_CAM_AFTER_GO)
{
camera->SetBoundary(GATE2_POSITION_CAM_AFTER_GO, camera->GetBoundaryRight());
camera->SetBoundaryBackup(camera->GetBoundaryLeft(), camera->GetBoundaryRight());
camera->SetAllowFollowSimon(true);
isHandlingGoThroughTheDoor2 = false; // Xong việc xử lí qua cửa 2
camera->StopAutoGoX(); // Dừng việc tự di chuyển
}
}
}
#pragma endregion
//===================================================================================================//
gridGame->GetListObject(listObj, camera);
simon->Update(dt, &listObj);
if (camera->AllowFollowSimon())
camera->SetPosition(simon->GetX() - SCREEN_WIDTH / 2 + 30, camera->GetYCam()); // Cho camera chạy theo Simon
camera->Update(dt);
//===================================================================================================//
//============= Xử lý các vùng tạo enemy===========//
if (mapCurrent == TAG::MAP2)
{
#pragma region Vùng tạo Ghost
if (mapCurrent == TAG::MAP2)
{
DWORD now = GetTickCount(); // Biến update giá trị thời gian để dùng cho việc reset thời gian tạo ghost
if (isWaitingToCreateGhost == false) // Nếu không phải chờ xử lí thì vào xử lí tạo ghost
{
#pragma region Vùng 1 & 2, vùng trc khi qua cửa 1
// Simon nằm trong vùng ngoài cùng của map 2 hoặc phần gần cầu thang qua cửa 1
if ((simon->GetX() >= GHOST_ZONE1_LEFT && simon->GetX() <= GHOST_ZONE1_RIGHT) || (simon->GetX() > GHOST_ZONE2_LEFT && simon->GetX() < GHOST_ZONE2_RIGHT))
{
if (now - CreateGhostTime >= WAIT_TIME_BETWEEN_TWO_GHOST_IS_CREATED) // Nếu đã chờ >= 1s thì cho phép tạo Ghost
{
if (CurrentGhostEnemyCount < 3)
{
if (simon->GetVx() > 0) // vx > 0 thì Simon đang đi về bên phải
{
// Cho ghost chạy từ bên phải qua, hướng là -1
listEnemy.push_back(new Ghost(camera->GetXCam() + camera->GetWidth(), 326 - 10, -1)); // 34 là framewidth của ghost
}
else
if (simon->GetVx() < 0) // vx < 0 thì Simon đang đi về bên trái
{
// Cho ghost chạy từ bên trái qua , hướng là 1
listEnemy.push_back(new Ghost(camera->GetXCam() - 34, 326 - 10, 1));
}
else // Nếu Simon đứng yên thì random
{
int random = rand() % 2; // Tỉ lệ 50%
if (random == 0) // Đi từ bên trái
{
listEnemy.push_back(new Ghost(camera->GetXCam() - 34, 326 - 10, 1));
}
else // Đi từ bên phải
{
listEnemy.push_back(new Ghost(camera->GetXCam() + camera->GetWidth(), 326 - 10, -1));
}
}
CurrentGhostEnemyCount++;
if (CurrentGhostEnemyCount == 3)
{
isWaitingToCreateGhost = true; // Phải chờ đến khi cả 3 ghost bị giết thì mới dc tạo tiếp
isAllowCheckTimeWaitToCreateGhost = false;
}
CreateGhostTime = now; // Set lại thời điểm đã tạo ghost cuối
}
}
}
#pragma endregion
#pragma region Vùng 3, vùng sau khi qua cửa 2
if ((simon->GetX() >= GHOST_ZONE3_LEFT && simon->GetX() <= GHOST_ZONE3_RIGHT)) // Simon ở giữa 2 vùng tạo Ghost
{
if (now - CreateGhostTime >= WAIT_TIME_BETWEEN_TWO_GHOST_IS_CREATED) // Nếu chờ >= 1s thì cho phép tạo Ghost
{
if (CurrentGhostEnemyCount < 3)
{
int random = rand() % 2; // Tỉ lệ 50%
switch (random)
{
case 0: // Ghost ở trên, 2 vùng mỗi vùng tạo ra 1 con Ghost
{
if (simon->GetX() <= GHOST_ZONE3_COLUMN1)
{
listEnemy.push_back(new Ghost(camera->GetXCam() + camera->GetWidth(), 185, -1)); // Bên phải chạy qua trái
break;
}
else
if (GHOST_ZONE3_COLUMN2 <= simon->GetX())
{
listEnemy.push_back(new Ghost(camera->GetXCam() - 34, 185, 1)); // Bên trái qua phải
break;
}
}
case 1: // Ghost ở dưới, tạo ra 1 con
{
if (simon->GetVx() > 0) // Simon đang đi qua bên phải
listEnemy.push_back(new Ghost(camera->GetXCam() + camera->GetWidth(), 330, -1));// Bên phải chạy qua trái
else
if (simon->GetVx() < 0) // Simon đang đi qua bên trái
listEnemy.push_back(new Ghost(camera->GetXCam() - 34, 330, 1)); // Đi từ trái qua phải
else // Nếu Simon đứng yên thì random vị trí xuất hiện
{
if (rand() % 2 == 0)
listEnemy.push_back(new Ghost(camera->GetXCam() + camera->GetWidth(), 330, -1)); // Bên phải chạy qua trái
else
listEnemy.push_back(new Ghost(camera->GetXCam() - 34, 330, 1)); // đi từ trái qua phải
}
break;
}
}
CurrentGhostEnemyCount++;
if (CurrentGhostEnemyCount == 3)
{
isWaitingToCreateGhost = true; // Phải chờ đến khi cả 3 ghost bị giết hoặc out camera (chết)
isAllowCheckTimeWaitToCreateGhost = false;
}
CreateGhostTime = now; // Set lại thời điểm đã tạo ghost cuối
}
}
}
#pragma endregion
}
else
{
if (isAllowCheckTimeWaitToCreateGhost)
{
if (now - BeginWaitingToCreateGhostTime >= WAIT_TIME_BEFORE_ALLOW_TO_CREATE_GHOST) // Đã chờ đủ 2.5s
{
isWaitingToCreateGhost = false; // Không phải chờ nữa
}
}
}
}
#pragma endregion
#pragma region Vùng tạo Panther
// Nếu Simon đang nằm trong vùng tạo báo thì cho phép tạo báo
if (REGION_CREATE_PANTHER_BOUNDARY_LEFT < simon->GetX() && simon->GetX() < REGION_CREATE_PANTHER_BOUNDARY_RIGHT)
{
if (isAllowCreatePanther)
{
if (CurrentPantherEnemyCount == 0) // Không còn Panther nào sống thì mới dc tạo lại cả 3
{
// Hướng mặt của Panther quay về hướng simon
int directionPanther = abs(REGION_CREATE_PANTHER_BOUNDARY_LEFT - simon->GetX()) < abs(REGION_CREATE_PANTHER_BOUNDARY_RIGHT - simon->GetX()) ? -1 : 1;
listEnemy.push_back(new BlackPanther(1398.0f, 225.0f, directionPanther, directionPanther == -1 ? 20.0f : 9.0f, simon));
listEnemy.push_back(new BlackPanther(1783.0f, 160.0f, directionPanther, directionPanther == -1 ? 278.0f : 180.0f, simon));
listEnemy.push_back(new BlackPanther(1923.0f, 225.0f, directionPanther, directionPanther == -1 ? 68.0f : 66.0f, simon));
CurrentPantherEnemyCount += 3;
}
isAllowCreatePanther = false;
}
}
else // Nếu Simon ngoài vùng tạo báo thì dừng việc tạo báo
{
isAllowCreatePanther = true;
}
#pragma endregion
#pragma region Vùng tạo dơi
if (isAllowToCreateBat)
{
DWORD now = GetTickCount(); // Bắt đầu lấy thời gian để tính toán thời gian chờ tạo dơi
if (now - CreateBatTime >= WaitingTimeToCreateBat) // Đủ thời gian chờ
{
CreateBatTime = now; // Đặt lại thời gian đã tạo bat
// Xét toạ độ Simon đang đứng so với biên toạ độ để lấy hướng bay ra cho dơi
// Ở bên phần 2 của screen trc cửa 2 thì dơi bay từ bên phải qua hoặc Simon mới qua cửa 1 (Chưa qua hồ cá), or Simon đứng trên phần gạch trc cửa 2
if (simon->GetX() < CREATE_BAT_BOUNDARY_DIVISION_DIRECTION_X || (simon->GetX() > CREATE_BAT_BOUNDARY_DIVISION_DIRECTION_X && simon->GetY() > CREATE_BAT_BOUNDARY_DIVISION_DIRECTION_Y))
listEnemy.push_back(new Bat(camera->GetXCam() + camera->GetWidth() - 10, simon->GetY() + 40, -1));
else // Dơi bay từ bên trái qua khi Simon đã qua hồ cá
listEnemy.push_back(new Bat(camera->GetXCam() - 10, simon->GetY() + 40, 1));
WaitingTimeToCreateBat = 4000 + (rand() % 3000); // Random thời gian tạo dơi >= 4s
}
}
#pragma endregion
#pragma region Vùng tạo Fishmen
if (isAllowToCreateFishmen && CurrentFishmenEnemyCount < 2) // Chỉ dc tạo 2 Fishmen
{
DWORD now = GetTickCount();
if (now - CreateFishmenTime >= WaitingtimeToCreateFishmen) // Đã đủ thời gian chờ cho phép tạo Fishmen
{
CreateFishmenTime = now; // Đặt lại thời điểm đã tạo
float appearPositionX = 0; // Vị trí xuất hiện random của Fishmen
#pragma region Xét vị trí Simon để random vị trí xuất hiện cho Fishmen
if (FISHMEN_ZONE_1_LEFT < simon->GetX() && simon->GetX() <= FISHMEN_ZONE_1_RIGHT)
{
appearPositionX = (rand() % 2) ? (FISHMEN_POS_3) : (FISHMEN_POS_4);
}
if (FISHMEN_ZONE_2_LEFT < simon->GetX() && simon->GetX() <= FISHMEN_ZONE_2_RIGHT)
{
appearPositionX = (rand() % 2) ? (FISHMEN_POS_1) : ((rand() % 2) ? (FISHMEN_POS_3) : (FISHMEN_POS_4));
}
if (FISHMEN_ZONE_3_LEFT < simon->GetX() && simon->GetX() <= FISHMEN_ZONE_3_RIGHT)
{
appearPositionX = (rand() % 2) ? (FISHMEN_POS_4) : (FISHMEN_POS_5);
}
if (FISHMEN_ZONE_4_LEFT < simon->GetX() && simon->GetX() <= FISHMEN_ZONE_4_RIGHT)
{
appearPositionX = (rand() % 2) ? (FISHMEN_POS_3) : (FISHMEN_POS_5);
}
if (FISHMEN_ZONE_5_LEFT < simon->GetX() && simon->GetX() <= FISHMEN_ZONE_5_RIGHT)
{
appearPositionX = (rand() % 2) ? (FISHMEN_POS_4) : (FISHMEN_POS_6);
}
if (FISHMEN_ZONE_6_LEFT < simon->GetX() && simon->GetX() <= FISHMEN_ZONE_6_RIGHT)
{
appearPositionX = (rand() % 2) ? (FISHMEN_POS_5) : ((rand() % 2) ? (FISHMEN_POS_7) : (FISHMEN_POS_8));
}
if (FISHMEN_ZONE_7_LEFT < simon->GetX() && simon->GetX() <= FISHMEN_ZONE_7_RIGHT)
{
appearPositionX = (rand() % 2) ? (FISHMEN_POS_6) : (FISHMEN_POS_8);
}
if (FISHMEN_ZONE_8_LEFT < simon->GetX() && simon->GetX() <= FISHMEN_ZONE_8_RIGHT)
{
appearPositionX = (rand() % 2) ? (FISHMEN_POS_6) : (FISHMEN_POS_7);
}
#pragma endregion
int directionFishmen = appearPositionX < simon->GetX() ? 1 : -1;
float appearPositionY = FISHMEN_POS_Y;
listEnemy.push_back(new Fishmen(appearPositionX, appearPositionY, directionFishmen, simon, &listWeaponOfEnemy, camera));
CurrentFishmenEnemyCount++;
STEAM_ADD_EFFECT(listEffect, appearPositionX, appearPositionY); // Thêm hiệu ứng bọt nước vào effect list
gameSound->Play(Sound::soundSplashwater); // Chạy âm thanh khi cá trồi lên mặt nước
WaitingtimeToCreateFishmen = 2000 + (rand() % 2000); // >= 2s
}
}
#pragma endregion
}
//===================================================================================================//
#pragma region Phần update các object
for (UINT i = 0; i < listObj.size(); i++)
listObj[i]->Update(dt, &listObj); // Đã kiểm tra "Alive" lúc lấy từ lưới ra
for (UINT i = 0; i < listItem.size(); i++)
if (listItem[i]->GetFinish() == false)
listItem[i]->Update(dt, &listObj); // Trong các hàm update chỉ kiểm tra va chạm với đất
for (UINT i = 0; i < listEffect.size(); i++)
if (listEffect[i]->GetFinish() == false)
listEffect[i]->Update(dt);
if (!simon->IsUsingWeapon(TAG::STOPWATCH)) // Nếu ko đang dùng StopWatch thì không update enemy
{
for (UINT i = 0; i < listEnemy.size(); i++)
{
GameObject* enemy = listEnemy[i];
if (enemy->GetHealth() > 0) // Còn máu
{
switch (enemy->GetType())
{
case TAG::GHOST:
{
if (camera->CHECK_OBJECT_IN_CAMERA(enemy) == false) // Vượt khỏi cam
{
enemy->SetHealth(0); // Ra khỏi cam thì coi như enemy đã chết
CurrentGhostEnemyCount--; // Giảm số lượng ghost hiện tại
if (CurrentGhostEnemyCount == 0)
{
BeginWaitingToCreateGhostTime = GetTickCount(); // Set thời điểm hiện tại để tính toán thời gian cho phép tạo lại Ghost
isWaitingToCreateGhost = true;
isAllowCheckTimeWaitToCreateGhost = true;
}
}
else
enemy->Update(dt, &listObj);
break;
}
case TAG::PANTHER:
{
if (camera->CHECK_OBJECT_IN_CAMERA(enemy)) // nếu Panther nằm trong camera thì update
// Vì do Grid load object nền (Brick) dựa vào vùng camera, nên có nguy cơ khiến 1 số object Panther không xét được va chạm đất
{
enemy->Update(dt, &listObj);
}
else // Nằm ngoài camera
{
BlackPanther* objPanther = dynamic_cast<BlackPanther*>(enemy);
if (objPanther->GetIsStart()) // Ngoài cam và đã được kích hoạt rồi
{
objPanther->SetHealth(0); // Cho Panther chết
CurrentPantherEnemyCount--;
}
}
break;
}
case TAG::BAT:
{
if (isAllowToCreateBat)
{
if (camera->CHECK_OBJECT_IN_CAMERA(enemy)) // Nếu nằm trong camera thì update
{
enemy->Update(dt);
}
else
{
enemy->SetHealth(0); // Ra khỏi cam coi như chết
}
}
else enemy->SetHealth(0); // Trong trường hợp Simon đụng trúng cửa 2
break;
}
case TAG::FISHMEN:
{
if (camera->CHECK_OBJECT_IN_CAMERA(enemy)) // Nếu nằm trong camera thì update
{
enemy->Update(dt, &listObj);
}
else
{
enemy->SetHealth(0); // Ra khỏi cam coi như chết
CurrentFishmenEnemyCount--;
}
break;
}
default:
break;
}
}
}
// Update Boss
if (phantomBat != NULL)
phantomBat->Update(dt, &listObj);
}
// Update vũ khí của enemy
for (UINT i = 0; i < listWeaponOfEnemy.size(); i++)
{
if (listWeaponOfEnemy[i]->GetFinish() == false)
{
listWeaponOfEnemy[i]->Update(dt, &listObj);
}
}
#pragma endregion
//===================================================================================================//
#pragma region Các update khác
HandleInvisibilityPotion(dt);
HandleCross(dt);
HandleClearStage3(dt); // Xử lí clear stage và end game sau khi diệt xong Boss
if (!simon->GetIsDeadth())
{
CheckCollision();
}
#pragma endregion
}
void MainScene::Render()
{
if (isWaitingToResetGame) // Nếu đang ở màn đen trước khi bắt đầu game
return; // Thoát và ko vẽ gì
// Chưa hết game thì render bình thường
if (!isGameOver)
{
tileMap->DrawMap(camera);
for (UINT i = 0; i < listObj.size(); i++)
listObj[i]->Render(camera);
for (UINT i = 0; i < listItem.size(); i++)
if (listItem[i]->GetFinish() == false)
listItem[i]->Render(camera);
for (UINT i = 0; i < listEffect.size(); i++)
if (listEffect[i]->GetFinish() == false)
listEffect[i]->Render(camera);
for (UINT i = 0; i < listEnemy.size(); i++)
listEnemy[i]->Render(camera);
for (UINT i = 0; i < listWeaponOfEnemy.size(); i++)
listWeaponOfEnemy[i]->Render(camera);
if (phantomBat != NULL)
phantomBat->Render(camera);
simon->Render(camera);
board->Render(simon, StageCurrent, MAX_GAME_TIME - gameTime->GetPassedTime(), phantomBat);
}
else
{
// Render option khi game over
EndGameText.Draw(200, 200, "GAME OVER");
EndGameText.Draw(215, 250, "CONTINUE");
EndGameText.Draw(215, 280, "END");
switch (GameOverSelectedOption)
{
case GAMEOVER_SELECT_CONTINUE:
{
_spriteLagerHeart->Draw(175, 245);
break;
}
case GAMEOVER_SELECT_END:
{
_spriteLagerHeart->Draw(175, 275);
break;
}
}
}
}
void MainScene::LoadMap(TAG mapType)
{
mapCurrent = mapType;
switch (mapType)
{
case TAG::MAP1:
gridGame->SetFilePath("Resources/map/file_gameobject_map1.txt");
tileMap->LoadMap(TAG::MAP1);
camera->SetAllowFollowSimon(true);
camera->SetBoundary(0.0f, (float)(tileMap->GetMapWidth() - camera->GetWidth())); // set biên camera dựa vào kích thước map
camera->SetPosition(0, 0);
simon->SetPosition(SIMON_DEFAULT_POSITION);
simon->SetCheckPoint(SIMON_DEFAULT_POSITION);
StageCurrent = 1;
break;
case TAG::MAP2:
gridGame->SetFilePath("Resources/map/file_gameobject_map2.txt");
tileMap->LoadMap(TAG::MAP2);
camera->SetAllowFollowSimon(true);
camera->SetPosition(0, 0);
camera->SetBoundary(0, CAMERA_BOUNDARY_BEFORE_GO_GATE1_RIGHT); // biên camera khi chưa qua cửa
simon->SetPosition(SIMON_DEFAULT_POSITION);
simon->SetCheckPoint(SIMON_DEFAULT_POSITION);
break;
}
ResetResource();
}
#pragma region Các hàm check va chạm
void MainScene::CheckCollision()
{
CheckCollisionWeapon(listObj);
CheckCollisionSimonItem();
CheckCollisionSimonAndHiddenObject();
CheckCollisionSimonWithGate();
if (!isHandlingGoThroughTheDoor1 && !isHandlingGoThroughTheDoor2) // Ko phải đang xử lí qua cửa
CheckCollisionWithEnemy(); // Kiểm tra va chạm vũ khí với enemy và Simon với enemy
CheckCollisionWithBoss();
}
void MainScene::CheckCollisionWeapon(vector<GameObject*> listObj) // Kiểm tra va chạm của vũ khí
{
for (auto& objWeapon : simon->mapWeapon)
{
if (objWeapon.second->GetFinish() == false) // Vũ khí không đang hoạt động
{
for (UINT i = 0; i < listObj.size(); i++) {
if (objWeapon.second->GetLastTimeAttack() > listObj[i]->GetLastTimeAttacked()) // Nếu chưa xét va chạm của lượt attack này ở các frame trước
{
if (objWeapon.second->isCollision(listObj[i]) == true) // Nếu có va chạm
{
bool RunEffectHit = false;
GameObject* gameObj = listObj[i];
switch (gameObj->GetType()) {
case TAG::TORCH:
gameObj->SubHealth(1);
listItem.push_back(DropItem(gameObj->GetId(), gameObj->GetType(), gameObj->GetX() + 5, gameObj->GetY()));
RunEffectHit = true;
break;
case TAG::CANDLE:
{
gameObj->SubHealth(1);
listItem.push_back(DropItem(gameObj->GetId(), gameObj->GetType(), gameObj->GetX() + 5, gameObj->GetY()));
RunEffectHit = true; // Hiệu ứng hit
break;
}
#pragma region Phần va chạm với Enemy và Boss
case TAG::GHOST:
{
gameObj->SubHealth(1);
simon->SetScore(simon->GetScore() + 100);
if (rand() % 2 == 1) // Tỉ lệ 50%
{
listItem.push_back(DropItem(gameObj->GetId(), gameObj->GetType(), gameObj->GetX() + 5, gameObj->GetY()));
}
RunEffectHit = true;
CurrentGhostEnemyCount--; // Giảm số lượng Ghost đang hoạt động
if (CurrentGhostEnemyCount == 0)
{
BeginWaitingToCreateGhostTime = GetTickCount(); // Set lại thời gian chờ là thời điểm hiện tại
isWaitingToCreateGhost = true;
isAllowCheckTimeWaitToCreateGhost = true;
}
break;
}
case TAG::PANTHER:
{
gameObj->SubHealth(1);
simon->SetScore(simon->GetScore() + 200);
if (rand() % 2 == 1) // tỉ lệ 50%
{
listItem.push_back(DropItem(gameObj->GetId(), gameObj->GetType(), gameObj->GetX() + 5, gameObj->GetY()));
}
RunEffectHit = true;
CurrentPantherEnemyCount--; // giảm số lượng Panther đang hoạt động
break;
}
case TAG::BAT:
{
gameObj->SubHealth(1);
simon->SetScore(simon->GetScore() + 200);
if (rand() % 2 == 1) // Tỉ lệ 50%
{
listItem.push_back(DropItem(gameObj->GetId(), gameObj->GetType(), gameObj->GetX() + 5, gameObj->GetY()));
}
RunEffectHit = true;
break;
}
case TAG::FISHMEN:
{
gameObj->SubHealth(1);
simon->SetScore(simon->GetScore() + 300);
if (rand() % 2 == 1) // tỉ lệ 50%
listItem.push_back(DropItem(gameObj->GetId(), gameObj->GetType(), gameObj->GetX() + 5, gameObj->GetY()));
RunEffectHit = true;
CurrentFishmenEnemyCount--; // giảm số lượng Fishmen đang hoạt động
break;
}
case TAG::PHANTOMBAT:
{
if (objWeapon.second->GetType() == TAG::MORNINGSTAR)
{
MorningStar* morningstar = dynamic_cast<MorningStar*>(objWeapon.second);
if (morningstar->GetLevel() > 0) // Level 1 hoặc 2
gameObj->SubHealth(24 / 8); // 8 hit chết
else
gameObj->SubHealth(24 / 12); // 12 hit chết, 1 hit -2 máu của Boss
}
else // Vũ khí khác MorningStar
gameObj->SubHealth(24 / 12); // 12 hit chết
if (gameObj->GetHealth() == 0) // Khi Boss chết
{
for (int u = 0; u < 2; u++)
{
for (int v = 0; v < 3; v++)
{
listEffect.push_back(new Fire(gameObj->GetX() + v * FIRE_WIDTH, gameObj->GetY() + u * FIRE_HEIGHT - 10, 3)); // Hiệu ứng lửa, 2 hàng 3 cột
RunEffectHit = false;
}
}
RunEffectHit = false;
gameSound->Play(Sound::soundHit);
listItem.push_back(new CrystalBall(CRYSTALBALL_DEFAULT_POSITION_X, CRYSTALBALL_DEFAULT_POSITION_y));
}
else // Boss chưa chết thì có hiệu ứng lửa khi đánh
{
RunEffectHit = true;
}
break;
}
#pragma endregion
#pragma region Phần va chạm với gạch
case TAG::BRICK:
{
if (objWeapon.second->GetType() != TAG::MORNINGSTAR) // Nếu ko là MORNINGSTAR thì bỏ qua
break;
GameObject* gameObject = listObj[i];
if (gameObject->GetHealth() > 0)
{
switch (gameObject->GetId())
{
case 39: // id 39 : brick 4 ô-> chỉ hiện effect, chỗ rơi đùi gà
{
gameObject->SubHealth(1);
HIT_ADD_EFFECT(listEffect, gameObject); // Hiệu ứng hit
BROKEN_BRICK_ADD_EFFECT(listEffect, gameObject); // Hiệu ứng BrokenBrick
gameSound->Play(Sound::soundBrokenBrick);
break;
}
case 40: // id 40: brick 3 ô-> effect, chỗ rơi đùi gà
{
gameObject->SubHealth(1);
listItem.push_back(DropItem(gameObject->GetId(), gameObject->GetType(), gameObject->GetX(), gameObject->GetY()));
HIT_ADD_EFFECT(listEffect, gameObject); // Hiệu ứng hit
BROKEN_BRICK_ADD_EFFECT(listEffect, gameObject); // Hiệu ứng BrokenBrick
break;
}
case 72: // id 72: brick -> bonus, map 2 phần ngoài cùng
{
gameObject->SubHealth(1);
listItem.push_back(DropItem(gameObject->GetId(), gameObject->GetType(), gameObject->GetX(), gameObject->GetY()));
HIT_ADD_EFFECT(listEffect, gameObject); // Hiệu ứng hit
BROKEN_BRICK_ADD_EFFECT(listEffect, gameObject); // Hiệu ứng BrokenBrick
gameSound->Play(Sound::soundBrokenBrick);
gameSound->Play(Sound::soundDisplayMonney);
break;
}
case 51: // id 51: brick 2 -> effect, dưới hồ bên phải ngoài cùng
{
gameObject->SubHealth(1);
HIT_ADD_EFFECT(listEffect, gameObject); // Hiệu ứng hit
BROKEN_BRICK_ADD_EFFECT(listEffect, gameObject); // Hiệu ứng BrokenBrick
gameSound->Play(Sound::soundBrokenBrick);
break;
}
case 104: // id 104: double shot, trong phần Boss
{
gameObject->SubHealth(1);
listItem.push_back(DropItem(gameObject->GetId(), gameObject->GetType(), gameObject->GetX(), gameObject->GetY()));
gameSound->Play(Sound::soundBrokenBrick);
HIT_ADD_EFFECT(listEffect, gameObject); // Hiệu ứng hit
BROKEN_BRICK_ADD_EFFECT(listEffect, gameObject); // Hiệu ứng BrokenBrick
break;
}
}
}
break;
}
#pragma endregion
}
if (RunEffectHit)
{
listEffect.push_back(new Hit(listObj[i]->GetX() + 10, listObj[i]->GetY() + 14)); // Hiệu ứng hit
listEffect.push_back(new Fire(gameObj->GetX() - 5, gameObj->GetY() + 8)); // Hiệu ứng lửa
gameSound->Play(Sound::soundHit);
// Nếu Dagger va chạm với object thì sẽ mất
if (objWeapon.second->GetType() == TAG::DAGGER)
{
objWeapon.second->SetFinish(true);
}
}
// Nếu object bị đánh trúng thì update thời gian bị đánh lần cuối (Update của weapon đã có update last time attack của weapon)
gameObj->SetLastTimeAttacked(objWeapon.second->GetLastTimeAttack());
}
}
}
}
}
}
void MainScene::CheckCollisionSimonItem()
{
for (UINT i = 0; i < listItem.size(); i++)
{
if (listItem[i]->GetFinish() == false && listItem[i]->IsWaitingToDisplay() == false) // Chưa kết thúc thời gian hiển thị và không phải đang chờ để hiển thị
{
if (simon->isCollisionWithItem(listItem[i]) == true) // Có va chạm với item
{
switch (listItem[i]->GetType())
{
// Các item khác
case TAG::LARGEHEART:
simon->SetHeartCollect(simon->GetHeartCollect() + 5);
listItem[i]->SetFinish(true);
gameSound->Play(Sound::soundCollectItem); // Âm thanh nhặt item
break;
case TAG::UPGRADEMORNINGSTAR:
{
MorningStar* objMorningStar = dynamic_cast<MorningStar*>(simon->mapWeapon[TAG::MORNINGSTAR]);
objMorningStar->UpgradeLevel(); // Nâng cấp roi
listItem[i]->SetFinish(true);
simon->SetFreeze(true); // Bật trạng thái đóng băng Simon
gameSound->Play(Sound::soundCollectWeapon); // Âm thanh nhặt vũ khí
break;
}
case TAG::POTROAST: // Đùi gà
{
listItem[i]->SetFinish(true);
simon->SetHealth(min(simon->GetHealth() + 6, SIMON_DEFAULT_HEALTH)); // Tăng 6 đơn vị máu
gameSound->Play(Sound::soundCollectItem); // Âm thanh nhặt item
break;
}
case TAG::ITEMDOUBLESHOT:
{
simon->SetIsUsingDoubleShot(true); // Cho phép chế độ Double Shot
listItem[i]->SetFinish(true);
gameSound->Play(Sound::soundCollectItem); // Âm thanh nhặt item
break;
}
case TAG::SMALLHEART:
{
simon->SetHeartCollect(simon->GetHeartCollect() + 1);
listItem[i]->SetFinish(true);
break;
}
case TAG::CRYSTALBALL:
{
listItem[i]->SetFinish(true);
if (gameSound->GetIsSoundPlaying(Sound::music_PhantomBat))
{
gameSound->Stop(Sound::music_PhantomBat);
}
gameSound->Play(Sound::musicClearState);
isAllowHandleClearStage3 = true; // Cho phép clear state và end game
break;
}
//====================================================================//
//Sub weapon item
case TAG::ITEMDAGGER:
{
simon->PickUpSubWeapon(TAG::DAGGER);
listItem[i]->SetFinish(true);
break;
}
case TAG::ITEMHOLYWATER:
{
simon->PickUpSubWeapon(TAG::HOLYWATER);
listItem[i]->SetFinish(true);
break;
}
case TAG::ITEMTHROWINGAXE:
{
simon->PickUpSubWeapon(TAG::THROWINGAXE);
listItem[i]->SetFinish(true);
break;
}
case TAG::INVISIBILITYPOTION:
{
isUsingInvisibilityPotion = true;
simon->SetTexture(TextureManager::GetInstance()->GetTexture(TAG::SIMON_TRANS));
listItem[i]->SetFinish(true);
gameSound->Play(Sound::soundInvisibilityPotion_Begin);
break;
}
case TAG::ITEMBOOMERANG:
{
simon->PickUpSubWeapon(TAG::BOOMERANG);
listItem[i]->SetFinish(true);
break;
}
case TAG::STOPWATCH:
{
simon->PickUpSubWeapon(TAG::STOPWATCH);
listItem[i]->SetFinish(true);
break;
}
// Nếu Simon nhặt dc thánh giá thì sẽ xoá hết enemy trong map
case TAG::CROSS:
{
isUsingCross = true;
Cross_WaitedTime = 0;
Cross_ChangeColorBackground_WaitedTime = 0;
board->SetTexure(TextureManager::GetInstance()->GetTexture(TAG::BOARD_TRANS)); // Đổi thành Board màu nền trong suốt
/*Xóa hết enemy*/
for (UINT k = 0; k < listEnemy.size(); k++)
{
GameObject* enemy = listEnemy[k];
if (enemy->GetHealth() > 0) // còn máu
{
enemy->SetHealth(0);
listEffect.push_back(new Fire(enemy->GetX() - 5, enemy->GetY() + 8)); // Hiệu ứng lửa
}
}
CurrentGhostEnemyCount = 0;
BeginWaitingToCreateGhostTime = GetTickCount(); // Set thời điểm hiện tại
isWaitingToCreateGhost = true;
isAllowCheckTimeWaitToCreateGhost = true;
CurrentFishmenEnemyCount = 0;
CurrentEnemyBatCount = 0;
CurrentPantherEnemyCount = 0;
/*Xóa hết enemy*/
listItem[i]->SetFinish(true);
gameSound->Play(Sound::soundHolyCross);
break;
}
//=====================================================================//
/* Xử lí ăn tiền */
case TAG::MONEY_RED_BAG:
{
listItem[i]->SetFinish(true);
simon->SetScore(simon->GetScore() + 100);
listEffect.push_back(new MoneyEffect(listItem[i]->GetX(), listItem[i]->GetY(), TAG::EFFECT_MONEY_100));
gameSound->Play(Sound::soundCollectItem); // Âm thanh nhặt item
break;
}
case TAG::MONEY_PURPLE_BAG:
{
listItem[i]->SetFinish(true);
simon->SetScore(simon->GetScore() + 400);
listEffect.push_back(new MoneyEffect(listItem[i]->GetX(), listItem[i]->GetY(), TAG::EFFECT_MONEY_400));
gameSound->Play(Sound::soundCollectItem); // Âm thanh nhặt item
break;
}
case TAG::MONEY_WHITE_BAG:
{
listItem[i]->SetFinish(true);
simon->SetScore(simon->GetScore() + 700);
listEffect.push_back(new MoneyEffect(listItem[i]->GetX(), listItem[i]->GetY(), TAG::EFFECT_MONEY_700));
gameSound->Play(Sound::soundCollectItem); // Âm thanh nhặt item
break;
}
case TAG::BONUS:
{
listItem[i]->SetFinish(true);
simon->SetScore(simon->GetScore() + 1000);
listEffect.push_back(new MoneyEffect(listItem[i]->GetX(), listItem[i]->GetY(), TAG::EFFECT_MONEY_1000));
gameSound->Play(Sound::soundCollectItem); // Âm thanh nhặt item
break;
}
/* Xử lí ăn tiền */
}
}
}
}
}
void MainScene::CheckCollisionSimonAndHiddenObject()
{
for (UINT i = 0; i < listObj.size(); i++)
{
if (listObj[i]->GetType() == TAG::OBJECT_HIDDEN)
{
GameObject* object = listObj[i];
if (object->GetHealth() > 0)
{
if (simon->isCollitionObjectWithObject(object)) // Có va chạm với object xảy ra
{
if (mapCurrent == TAG::MAP1)
{
switch (object->GetId())
{
case 7: // Hiden object ở cửa
LoadMap(TAG::MAP2);
return;
case 8: // Hiden object của bonus ở map 1
listItem.push_back(DropItem(object->GetId(), object->GetType(), simon->GetX(), simon->GetY()));
gameSound->Play(Sound::soundDisplayMonney);
break;
}
object->SubHealth(1);
}
if (mapCurrent == TAG::MAP2)
{
switch (object->GetId())
{
case 67: // Đụng trúng box xác nhận simon đã qua GATE1
{
if (isHandlingGoThroughTheDoor1)
{
isWentThroughTheDoor1 = true;
camera->SetAutoGoX(abs(GATE1_POSITION_CAM_AFTER_GO - camera->GetXCam()), SIMON_WALKING_SPEED);
simon->SetCheckPoint(simon->GetX(), 0); // backup lại vị trí sau khi qua màn
}
StageCurrent = 2;// Set hiển thị đang ở stage 2
object->SubHealth(1);
// Cho phép tạo dơi
CreateBatTime = GetTickCount();
WaitingTimeToCreateBat = 3000;
isAllowToCreateBat = true;
camera->SetPositionBackup(camera->GetXCam(), camera->GetYCam());
DebugOut(L"Xac nhan qua xong cua 1!\n");
break;
}
case 65: //id 65 : object ẩn->bonus
{
listItem.push_back(DropItem(object->GetId(), object->GetType(), simon->GetX(), simon->GetY()));
object->SetHealth(0);
gameSound->Play(Sound::soundDisplayMonney);
break;
}
case 66: //id 66: object ẩn -> chạm nước -> chết
{
simon->SetHealth(0);
gameSound->Play(Sound::soundFallingDownWaterSurface);
break;
}
case 94: // Đụng trúng box xác nhận simon đã qua GATE2
{
if (isHandlingGoThroughTheDoor2)
{
// Di chuyển camera qua phần cuối
isWentThroughTheDoor2 = true;
camera->SetAutoGoX(abs(GATE2_POSITION_CAM_AFTER_GO - camera->GetXCam()), SIMON_WALKING_SPEED);
simon->SetCheckPoint(simon->GetX(), 0); // backup lại vị trí sau khi qua màn
}
StageCurrent = 3; // Set hiển thị Simon đang ở stage 3
object->SubHealth(1);
//isAllowToCreateBat = false; // Ngưng không tạo Bat nữa
DebugOut(L"Xac nhan qua xong cua 2!\n");
break;
}
#pragma region Lên & xuống hồ nước phía trái
case 41: // id 41: object ẩn -> Bắt đầu xuống hồ nước
{
camera->SetPosition(camera->GetXCam(), CAMERA_POSITION_Y_LAKE);
camera->SetBoundary(CAMERA_BOUNDARY_LAKE_LEFT, CAMERA_BOUNDARY_LAKE_RIGHT);
simon->SetPosition(3150, 405);
object->SetHealth(0);
isAllowToCreateBat = false; // Không cho tạo Bat
isAllowToCreateFishmen = true; // Cho phép tạo Fishmen
gridGame->Insert(GRID_INSERT_OBJECT__GETOUTLAKE_LEFT); // Thêm object ẩn để có thể đi lên
break;
}
case 45: // id 45: object ẩn -> Trở lên trước khi xuống hồ nước
{
camera->SetPosition(camera->GetXCam(), 0);
simon->SetPosition(3152, 345);
object->SetHealth(0);
isAllowToCreateBat = true; // Cho phép tạo Bat
isAllowToCreateFishmen = false; // Ngừng việc tạo Fishmen
gridGame->Insert(GRID_INSERT_OBJECT__GETDOWNLAKE_LEFT); // Thêm object ẩn để có thể đi xuống sau khi đã lên lại
break;
}
#pragma endregion
#pragma region Lên & xuống hồ nước phía Phải
case 81: // id 81: object ẩn -> Ra khỏi hồ nước phía phải
{
camera->SetPosition(camera->GetXCam(), 0);
simon->SetPosition(3806, 361);
object->SetHealth(0);
isAllowToCreateBat = true;
WaitingTimeToCreateBat = 3000 + rand() % 1000; // Random thời gian chờ tạo Bat, >= 4s
isAllowToCreateFishmen = false; // Ngừng việc tạo Fishmen
// Thêm bên trái trong trường hợp Simon rớt ngược lại qua phần cửa đầu tiên
gridGame->Insert(GRID_INSERT_OBJECT__GETDOWLAKE_RIGHT); // Thêm object ẩn để có thể đi xuống sau khi đã lên lại
gridGame->Insert(GRID_INSERT_OBJECT__GETDOWNLAKE_LEFT); // Thêm object ẩn để có thể đi xuống sau khi đã lên lại
break;
}
case 86: // id 86: object ẩn -> Vào hồ nước phía phải
{
camera->SetPosition(camera->GetXCam(), CAMERA_POSITION_Y_LAKE);
simon->SetPosition(3825, 450);
object->SetHealth(0);
isAllowToCreateBat = false; // Không cho tạo Bat
isAllowToCreateFishmen = true; // Cho phép tạo Fishmen
gridGame->Insert(GRID_INSERT_OBJECT__GETOUTLAKE_RIGHT); // Thêm object ẩn để có thể đi xuống sau khi đã lên lại
break;
}
#pragma endregion
case 124: // id 124 : kích hoạt boss
{
phantomBat->Start();
camera->SetBoundary(camera->GetBoundaryRight(), camera->GetBoundaryRight());
camera->SetAllowFollowSimon(false);
if (gameSound->GetIsSoundPlaying(Sound::musicState1))
{
gameSound->Stop(Sound::musicState1);
}
gameSound->Play(Sound::music_PhantomBat, true);
object->SetHealth(0);
break;
}
default:
break;
}
}
}
}
}
}
}
void MainScene::CheckCollisionSimonWithGate()
{
for (UINT i = 0; i < listObj.size(); i++)
{
if (listObj[i]->GetType() == TAG::GATE)
{
if (simon->isCollitionObjectWithObject(listObj[i]))
{
Gate* objGate = dynamic_cast<Gate*>(listObj[i]);
if (mapCurrent == TAG::MAP2)
{
switch (objGate->GetId())
{
case 64: // Gate 1
{
if (objGate->GetStart() == 0)
{
// Di chuyển camera đến GATE1_POSITION_CAM_BEFORE_GO = 2825.0f
camera->SetBoundary(camera->GetBoundaryLeft(), camera->GetBoundaryRight() + 9999.0f); // Mở biên phải rộng ra thêm để chạy AutoGo
camera->SetAutoGoX(abs(GATE1_POSITION_CAM_BEFORE_GO - camera->GetXCam()), SIMON_WALKING_SPEED);
#pragma region Stop simon
simon->SetSpeed(0, simon->GetVy()); // Cho Simon dừng, tránh trường hợp không vào được trạng thái stop trong KeyState()
simon->isWalking = 0;
if (simon->isSitting == true) // Nếu simon đang ngồi
{
simon->isSitting = 0; // Hủy trạng thái ngồi
simon->SetY(simon->GetY() - PULL_UP_SIMON_AFTER_SITTING); // Kéo Simon lên, trừ đi để bằng với kích thước frame, do khi ngồi phải trừ đi phần khoảng trống dưới frame ngồi
}
#pragma endregion
isHandlingGoThroughTheDoor1 = true; // Bật trạng thái xử lí qua cửa
isWentThroughTheDoor1 = false;
objGate->Start();
DebugOut(L"Simon dung trung cua!\n");
break;
}
break;
}
case 93: // Gate 2
{
if (objGate->GetStart() == 0)
{
camera->SetBoundary(camera->GetBoundaryLeft(), CAMERA_BOUNDARY_BOSS_RIGHT); // Mở biên phải rộng ra thêm để chạy AutoGo
camera->SetAutoGoX(abs(GATE2_POSITION_CAM_BEFORE_GO - camera->GetXCam()), SIMON_WALKING_SPEED);
#pragma region Stop simon
simon->SetSpeed(0, simon->GetVy()); // Cho simon dừng, tránh trường hợp không vào được trạng thái stop trong KeyState()
simon->isWalking = 0;
if (simon->isSitting == true) // Nếu simon đang ngồi
{
simon->isSitting = 0; // Hủy trạng thái ngồi
simon->SetY(simon->GetY() - PULL_UP_SIMON_AFTER_SITTING); // Kéo simon lên
}
#pragma endregion
isHandlingGoThroughTheDoor2 = true; // Bật trạng thái xử lí qua cửa
isWentThroughTheDoor2 = false;
isAllowToCreateBat = false; // Ngừng việc tạo dơi
objGate->Start();
DebugOut(L"Simon dung trung cua 2!\n");
// Khởi tạo Boss
if (phantomBat == NULL)
phantomBat = new PhantomBat(simon, camera, &listWeaponOfEnemy); // Thêm vũ khí của Boss vào list
break;
}
break;
}
default:
break;
}
}
}
}
}
}
void MainScene::CheckCollisionWithEnemy()
{
CheckCollisionWeapon(listEnemy); // Xét va chạm vũ khí với enemy
CheckCollisionSimonWithEnemy(); // Xét va chạm giữa Simon và enemy
}
void MainScene::CheckCollisionSimonWithEnemy()
{
// Nếu Simon đã ở trạng thái ko thể va chạm đủ thời gian tối đa thì sẽ có thể va chạm lại
if (GetTickCount() - simon->startUntouchableTime > SIMON_UNTOUCHABLE_TIME)
{
simon->startUntouchableTime = 0;
simon->isUntouchable = false;
}
if (isUsingInvisibilityPotion) // Ko sử dụng thuốc tàng hình thì mới xét va chạm
{
return;
}
// Phần xét va chạm với enemy
if (simon->isUntouchable == false) // Nếu Simon ko còn trong trạng thái ko thể va chạm thì sẽ xét va chạm bình thường
{
#pragma region Va chạm với Enemy bình thường
for (UINT i = 0; i < listEnemy.size(); i++)
{
GameObject* gameobj = dynamic_cast<GameObject*> (listEnemy[i]);
if (gameobj->GetHealth() > 0) // Enemy còn sống
{
LPCOLLISIONEVENT e = simon->SweptAABBEx(gameobj);
bool isCollision = false;
if (e->t > 0 && e->t <= 1) // Có va chạm
{
simon->SetHurt(e);
isCollision = true;
}
if (isCollision == false && simon->checkAABB(gameobj) == true)
{
LPCOLLISIONEVENT e = new CollisionEvent(1.0f, (float)-simon->GetDirection(), 0.0f, NULL);
simon->SetHurt(e);
isCollision = true;
}
if (isCollision)
{
if (gameobj->GetType() == TAG::BAT) // Nếu va chạm với dơi thì dơi sẽ chết
{
listEffect.push_back(new Fire(gameobj->GetX() - 5, gameobj->GetY() + 8)); // Hiệu ứng lửa
gameobj->SetHealth(0);
}
return; // Giảm chi phí duyệt, vì nếu Simon đang ở trạng thái untouchable thì ko xét va chạm
}
}
}
#pragma endregion
}
// Phần xét va chạm với weapon của enemy
if (simon->isUntouchable == false)
{
#pragma region Phần xét va chạm với vũ khí của enemy
for (UINT i = 0; i < listWeaponOfEnemy.size(); i++)
{
if (listWeaponOfEnemy[i]->GetFinish() == false)
{
LPCOLLISIONEVENT e = simon->SweptAABBEx(listWeaponOfEnemy[i]);
if (e->t > 0 && e->t <= 1) // Có va chạm
{
simon->SetHurt(e);
return; // Giảm chi phí duyệt, vì nếu Simon đang ở trạng thái untouchable thì ko xét va chạm
}
if (simon->checkAABB(listWeaponOfEnemy[i]) == true) // Nếu có va chạm
{
LPCOLLISIONEVENT e = new CollisionEvent(1.0f, (float)-simon->GetDirection(), 0.0f, NULL);
simon->SetHurt(e);
return;
}
}
}
#pragma endregion
}
}
void MainScene::CheckCollisionWithBoss()
{
// Boss chưa khởi tạo hoặc chết thì ko xét va chạm
if (phantomBat == NULL)
return;
if (phantomBat->GetHealth() <= 0)
return;
vector<GameObject*> listObj{ phantomBat };
CheckCollisionWeapon(listObj); // Check va chạm giữa Boss và vũ khí của Simon
if (isUsingInvisibilityPotion) // Nếu Simon đang dùng thuốc tàng hình thì ko xét va chạm
return;
// Nếu Simon đã ở trạng thái ko thể va chạm đủ thời gian tối đa thì sẽ có thể va chạm lại
if (GetTickCount() - simon->startUntouchableTime > SIMON_UNTOUCHABLE_TIME)
{
simon->startUntouchableTime = 0;
simon->isUntouchable = false;
}
if (simon->isUntouchable == false) // Nếu Simon ko ở trạng thái ko thể va chạm thì mới xét
{
if (phantomBat->GetHealth() > 0) // Nếu Boss còn sống thì mới xét va chạm
{
LPCOLLISIONEVENT e = simon->SweptAABBEx(phantomBat);
if (e->t > 0 && e->t <= 1) // Có va chạm
{
simon->SetHurt(e);
return; // Giảm chi phí duyệt, vì nếu Simon đang ở trạng thái untouchable thì ko xét va chạm
}
if (simon->checkAABB(phantomBat) == true)
{
LPCOLLISIONEVENT e = new CollisionEvent(1.0f, (float)-simon->GetDirection(), 0.0f, NULL);
simon->SetHurt(e);
return;
}
}
}
}
Item* MainScene::DropItem(int Id, TAG Type, float X, float Y) // Xử lí rớt item
{
if (mapCurrent == TAG::MAP1)
{
if (Type == TAG::TORCH)
{
if (Id == 1 || Id == 4)
return new LargeHeart(X, Y);
if (Id == 2 || Id == 3)
return new UpgradeMorningStar(X, Y);
if (Id == 5)
return new ItemDagger(X, Y);
}
if (Type == TAG::OBJECT_HIDDEN)
{
if (Id == 8)
return new Bonus(1240, 305);
}
}
if (mapCurrent == TAG::MAP2)
{
#pragma region Phần rơi đồ khi đánh nến
if (Type == TAG::CANDLE)
{
switch (Id)
{
case 2: // Ngay đầu map 2
return new MoneyBag(X, Y, TAG::MONEY_WHITE_BAG);
break;
// Temp
/*case 3:
return new ItemBoomerang(X, Y);
break;
case 4:
return new ItemThrowingAxe(X, Y);
break;*/
case 23: case 98: // Trc 2 cửa
return new Cross(X, Y);
break;
case 71: // Nằm ở phần có báo đen
return new ItemHolyWater(X, Y);
break;
case 76:
return new ItemStopWatch(X, Y);
break;
case 109: // Nằm gần gate 2
return new InvisibilityPotion(X, Y);
break;
case 111: // Nằm gần cầu thang gate 2
return new ItemThrowingAxe(X, Y);
break;
default:
{
int random = rand() % 15;
switch (random)
{
case 0:
return new MoneyBag(X, Y, TAG::MONEY_RED_BAG);
break;
case 1:
return new MoneyBag(X, Y, TAG::MONEY_WHITE_BAG);
break;
case 2:
return new MoneyBag(X, Y, TAG::MONEY_PURPLE_BAG);
break;
default:
return new SmallHeart(X, Y);
break;
}
break;
}
}
}
#pragma endregion
#pragma region Phần rơi đồ khi đánh Enemy
if (Type == TAG::GHOST || Type == TAG::PANTHER || Type == TAG::BAT || Type == TAG::FISHMEN)
{
int random = rand() % 15;
if (random == 4) // Nếu random ra upgrade MorningStar
{
MorningStar* morningstar = dynamic_cast<MorningStar*>(simon->mapWeapon[TAG::MORNINGSTAR]);
while (morningstar->GetLevel() == 2 && random == 4) // Nếu MorningStar đã max level thì random lại
{
random = rand() % 15;
}
}
switch (random)
{
case 0:
return new LargeHeart(X, Y);
break;
case 1:
return new SmallHeart(X, Y);
break;
case 2:
return new ItemDagger(X, Y);
break;
case 3:
return new Bonus(X, Y);
break;
case 4:
return new UpgradeMorningStar(X, Y);
break;
case 5:
return new ItemHolyWater(X, Y);
break;
case 6:
return new ItemStopWatch(X, Y);
break;
case 7:
return new ItemThrowingAxe(X, Y);
break;
case 8:
return new InvisibilityPotion(X, Y);
break;
case 9:
return new ItemBoomerang(X, Y);
break;
default: // còn lại là SmallHeart
return new SmallHeart(X, Y);
break;
}
}
#pragma endregion
#pragma region Phần rơi đồ khi đánh gạch
if (Type == TAG::BRICK)
{
switch (Id)
{
case 40: // Đùi gà
return new PotRoast(X, Y);
break;
case 72: // Phần ngoài cùng của map 2
return new Bonus(X, Y);
break;
case 104: // Double shot, trong phần đánh boss
return new ItemDoubleShot(X, Y);
break;
default:
return new SmallHeart(X, Y);
break;
}
}
if (Type == TAG::OBJECT_HIDDEN)
{
if (Id == 65)
return new Bonus(3763.0f, 587.0f);
}
}
#pragma endregion
return new LargeHeart(X, Y);
}
#pragma endregion
#pragma region Các hàm xử lý khác
void MainScene::HandleInvisibilityPotion(DWORD dt)
{
if (isUsingInvisibilityPotion)
{
InvisibilityPotion_WaitedTime += dt; // Đếm thời gian sử dụng thuốc
// Nếu đã hết thời gian sử dụng thì sẽ ngưng
if (InvisibilityPotion_WaitedTime >= INVISIBILITYPOTION_LIMITTIMEWAIT)
{
isUsingInvisibilityPotion = false; // Kết thúc
InvisibilityPotion_WaitedTime = 0;
gameSound->Play(Sound::soundInvisibilityPotion_End);
simon->SetTexture(TextureManager::GetInstance()->GetTexture(TAG::SIMON));
}
}
}
void MainScene::HandleCross(DWORD dt)
{
if (isUsingCross)
{
/* Xử lí thời gian hoạt động, nếu hết thời gian sử dụng thì trả về bình thường*/
Cross_WaitedTime += dt;
if (Cross_WaitedTime >= CROSS_MAXUSINGTIME)
{
isUsingCross = false;
D3DBACKGROUND_COLOR = BACKGROUND_DEFAULT_COLOR; // Trả về màu nền mặc định
board->SetTexure(TextureManager::GetInstance()->GetTexture(TAG::BOARD)); // Đổi thành Board màu bt
}
else
{
/*Xử lí đổi màu nền*/
Cross_ChangeColorBackground_WaitedTime += dt;
if (Cross_ChangeColorBackground_WaitedTime >= Cross_ChangeColorBackground_MaxWaitingTime) // Xét xem đã tới thời điểm đổi màu nên hay chưa
{
Cross_ChangeColorBackground_WaitedTime = 0;
Cross_ChangeColorBackground_MaxWaitingTime = rand() % 100;
/*Đổi màu nền*/
if (D3DBACKGROUND_COLOR == BACKGROUND_DEFAULT_COLOR)
{
D3DBACKGROUND_COLOR = CROSS_COLOR_BACKGROUND;
}
else
{
D3DBACKGROUND_COLOR = BACKGROUND_DEFAULT_COLOR;
}
}
}
}
}
void MainScene::PlayGameMusic()
{
gameSound->StopAll();// Tắt hết các âm thanh
gameSound->Play(Sound::musicState1, true); // Mở nhạc nền
}
// Xử lý clear state 3 khi Simon hạ dc Boss
void MainScene::HandleClearStage3(DWORD dt)
{
if (isAllowHandleClearStage3)
{
// Xét các trạng thái xử lý khi clear state
switch (HandleClearStage3Status)
{
case CLEARSTAGE3_HANDLE_HEALTH_STATUS:
{
WaitedTimeTo_ClearState3 += dt; // Đếm thời gian chờ để xử lý máu
if (WaitedTimeTo_ClearState3 >= CLEARSTAGE3_LIMITTIME_WAITING_TO_HANDLE_HEALTH)
{
WaitedTimeTo_ClearState3 = 0; // Reset đếm thời gian chờ
if (simon->GetHealth() < SIMON_DEFAULT_HEALTH) // Hồi lại đầy máu nếu Simon có mất máu
{
simon->SetHealth(simon->GetHealth() + 1);
}
else
{
HandleClearStage3Status = CLEARSTAGE3_HANDLE_GETSCORE_TIME_STATUS; // Chuyển sang trạng thái tính điểm trên thời gian còn lại
}
}
break;
}
case CLEARSTAGE3_HANDLE_GETSCORE_TIME_STATUS:
{
WaitedTimeTo_ClearState3 += dt; // Đếm thời gian chờ để xử lý tính điểm trên thời gian còn lại
if (WaitedTimeTo_ClearState3 >= CLEARSTAGE3_LIMITTIME_WAITING_TO_HANDLE_GETSCORE_TIME)
{
WaitedTimeTo_ClearState3 = 0; // Reset đếm thời gian chờ
if (MAX_GAME_TIME - gameTime->GetPassedTime() > 0) // Thời gian chơi còn lại > 0
{
simon->SetScore(simon->GetScore() + 10); // Mỗi giây còn lại sẽ +10 điểm
gameTime->SetTime(gameTime->GetPassedTime() + 1); // Giảm số giây còn lại
gameSound->Play(Sound::soundGetScoreTimer, true);
}
else
{
HandleClearStage3Status = CLEARSTATG3_HANDLE_GETSCORE_HEART_STATUS; // Chuyển sang trạng thái tính điểm dựa trên số tím còn lại
WaitedTimeTo_ClearState3 = 0;
gameSound->Stop(Sound::soundGetScoreTimer);
}
}
break;
}
case CLEARSTATG3_HANDLE_GETSCORE_HEART_STATUS:
{
WaitedTimeTo_ClearState3 += dt; // Đếm thời gian chờ để xử lý tính điểm trên số heart còn lại
if (WaitedTimeTo_ClearState3 >= CLEARSTAGE3_LIMITTIME_WAITING_TO_HANDLE_GETSCORE_HEART)
{
WaitedTimeTo_ClearState3 = 0;
if (simon->GetHeartCollect() > 0) // Số heart còn lại > 0
{
simon->SetScore(simon->GetScore() + 100); // Mỗi heart còn lại sẽ +100 điểm
simon->SetHeartCollect(simon->GetHeartCollect() - 1); // giảm 1 heart
gameSound->Play(Sound::soundGetScoreHeart, true);
}
else
{
gameSound->Stop(Sound::soundGetScoreHeart);
HandleClearStage3Status = CLEARSTAGE3_HANDLE_DONE_STATUS; // Chuyển sang trạng thái xử lý kết thúc và end game
}
}
break;
}
case CLEARSTAGE3_HANDLE_DONE_STATUS:
{
WaitedTimeTo_ClearState3 += dt; // Đếm thời gian chờ để xử lý end game
if (WaitedTimeTo_ClearState3 >= CLEARSTAGE3_LIMITTIMEWAIT_HANDLE_OPENGAMEOVER)
{
isAllowHandleClearStage3 = false; // Dừng trạng thái clear stage
isGameOver = true; // Bật bảng hiện gameover
}
break;
}
default:
break;
}
}
}
#pragma endregion
|
d006926cffbc0f9370fc7b31073293a73c3e76ea
|
a7da7133d8e6a1660ddf8468c80f2392960b467f
|
/148A-InsomniaCure.cpp
|
e5fff9666d7528da1638ec51db190b3d518e539f
|
[] |
no_license
|
devvrho/CODEFORCES
|
5a69c39119aab5297d0edfa16fa4e8ce38d810af
|
63b6f0d160a2ce73753417edcb6c0076b742fc16
|
refs/heads/master
| 2023-03-17T14:13:47.392724
| 2021-03-05T19:50:53
| 2021-03-05T19:50:53
| 271,351,347
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,011
|
cpp
|
148A-InsomniaCure.cpp
|
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
double k, l, m, n, d;
cin >> k >> l >> m >> n >> d;
vector<double> dragons;
vector<double> multiples;
double answer = 0;
//get multiples in a vector
//then sort them
//then remove any duplicates
multiples.push_back(k);
multiples.push_back(l);
multiples.push_back(m);
multiples.push_back(n);
sort(multiples.begin(), multiples.end());
multiples.erase( unique( multiples.begin(), multiples.end() ), multiples.end() );
int size = multiples.size();
for( int i = 1; i <= d; i++ ){
dragons.push_back(i);
}
for( int i = 0; i < d; i++ )
{
for( int j = 0; j < size; j++ )
{
if(dragons[i] != 0){
if(fmod(dragons[i],multiples[j]) == 0){
answer++;
dragons[i] = 0;
}
}
}
}
cout << answer << endl;
}
|
0bb434e367636dee2f61c01f72065eac11beb81a
|
eda03521b87da8bdbef6339b5b252472a5be8d23
|
/Userland/Libraries/LibPDF/Fonts/Type1FontProgram.h
|
dadc9c1546072331e6410c4138beb4fb09fa4b8c
|
[
"BSD-2-Clause"
] |
permissive
|
SerenityOS/serenity
|
6ba3ffb242ed76c9f335bd2c3b9a928329cd7d98
|
ef9b6c25fafcf4ef0b44a562ee07f6412aeb8561
|
refs/heads/master
| 2023-09-01T13:04:30.262106
| 2023-09-01T08:06:28
| 2023-09-01T10:45:38
| 160,083,795
| 27,256
| 3,929
|
BSD-2-Clause
| 2023-09-14T21:00:04
| 2018-12-02T19:28:41
|
C++
|
UTF-8
|
C++
| false
| false
| 3,430
|
h
|
Type1FontProgram.h
|
/*
* Copyright (c) 2023, Rodrigo Tobar <rtobarc@gmail.com>.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Debug.h>
#include <AK/SourceLocation.h>
#include <LibGfx/Font/Font.h>
#include <LibGfx/Path.h>
#include <LibPDF/Encoding.h>
#include <LibPDF/Error.h>
namespace PDF {
class Encoding;
class Type1FontProgram : public RefCounted<Type1FontProgram> {
public:
RefPtr<Gfx::Bitmap> rasterize_glyph(DeprecatedFlyString const& char_name, float width, Gfx::GlyphSubpixelOffset subpixel_offset);
Gfx::FloatPoint glyph_translation(DeprecatedFlyString const& char_name, float width) const;
RefPtr<Encoding> encoding() const { return m_encoding; }
protected:
struct AccentedCharacter {
AccentedCharacter(u8 base_char_code, u8 accent_char_code, float adx, float ady)
: base_character(Encoding::standard_encoding()->get_name(base_char_code))
, accent_character(Encoding::standard_encoding()->get_name(accent_char_code))
, accent_origin(adx, ady)
{
}
DeprecatedFlyString base_character;
DeprecatedFlyString accent_character;
Gfx::FloatPoint accent_origin;
};
class Glyph {
public:
bool has_width() const { return m_width.has_value(); }
float width() const { return m_width.value(); }
void set_width(float width)
{
m_width = width;
}
Gfx::Path& path() { return m_path; }
Gfx::Path const& path() const { return m_path; }
bool is_accented_character() const { return m_accented_character.has_value(); }
AccentedCharacter const& accented_character() const { return m_accented_character.value(); }
void set_accented_character(AccentedCharacter&& accented_character)
{
m_accented_character = move(accented_character);
}
private:
Gfx::Path m_path;
Optional<float> m_width;
Optional<AccentedCharacter> m_accented_character;
};
struct GlyphParserState {
Glyph glyph;
Gfx::FloatPoint point;
bool flex_feature { false };
size_t flex_index;
Array<float, 14> flex_sequence;
size_t sp { 0 };
Array<float, 48> stack;
u8 n_hints { 0 };
size_t postscript_sp { 0 };
Array<float, 24> postscript_stack;
};
static PDFErrorOr<Glyph> parse_glyph(ReadonlyBytes const&, Vector<ByteBuffer> const&, GlyphParserState&, bool is_type2);
static Error error(
DeprecatedString const& message
#ifdef PDF_DEBUG
,
SourceLocation loc = SourceLocation::current()
#endif
);
void set_encoding(RefPtr<Encoding>&& encoding)
{
m_encoding = move(encoding);
}
void set_font_matrix(Gfx::AffineTransform&& font_matrix)
{
m_font_matrix = move(font_matrix);
}
PDFErrorOr<void> add_glyph(DeprecatedFlyString name, Glyph&& glyph)
{
TRY(m_glyph_map.try_set(move(name), move(glyph)));
return {};
}
void consolidate_glyphs();
private:
HashMap<DeprecatedFlyString, Glyph> m_glyph_map;
Gfx::AffineTransform m_font_matrix;
RefPtr<Encoding> m_encoding;
Gfx::Path build_char(DeprecatedFlyString const& char_name, float width, Gfx::GlyphSubpixelOffset subpixel_offset);
Gfx::AffineTransform glyph_transform_to_device_space(Glyph const& glyph, float width) const;
};
}
|
04617c66fb238f691ad2568b90aab6ca36d679b2
|
6bc86f99630725070a543e895af5e307c572079c
|
/old_src/Camera.hpp
|
b4da6c5b4940babd23fd24eee747f98c0f699bfc
|
[] |
no_license
|
IanStJohn/Patty
|
ff57b02e473f78ec729e003bf4722cd676bda8bc
|
1171f8322b971a41a37ba59dfea3c67dd003763b
|
refs/heads/main
| 2023-03-30T13:11:10.608798
| 2021-04-07T21:08:47
| 2021-04-07T21:08:47
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,781
|
hpp
|
Camera.hpp
|
#pragma once
#include "Object.hpp"
#include <glm/vec3.hpp>
#include <glm/gtc/matrix_transform.hpp>
namespace PattyEngine {
class Camera : public Object {
public:
Camera(
std::string name,
Object *parent,
float horizontalAngle = 3.14f,
float verticalAngle = 0.0f,
float initialFoV = 45.0f,
float nearClippingPlane = 0.1f,
float farClippingPlane = 100.0f,
glm::vec3 position = glm::vec3(),
glm::vec3 scale = glm::vec3(1.0f),
glm::vec3 rotation = glm::vec3()
) : Object(name, parent, position, scale, rotation) {
this->horizontalAngle = horizontalAngle;
this->verticalAngle = verticalAngle;
this->initialFoV = initialFoV;
this->nearClippingPlane = nearClippingPlane;
this->farClippingPlane = farClippingPlane;
projection = view = glm::mat4();
direction = right = up = glm::vec3();
}
void update();
void handle(SDL_Event *e) {}
glm::mat4 getProjection() { return projection; }
glm::vec3 getDirection() { return direction; }
glm::vec3 getRight() { return right; }
glm::mat4 getView() { return view; }
void incrementPosition(glm::vec3 amount) { this->position += amount; }
protected:
glm::mat4 projection, view;
glm::vec3 direction, right, up;
float horizontalAngle = 3.14f;
float verticalAngle = 0.0f;
float initialFoV = 45.0f;
float nearClippingPlane = 0.1f, farClippingPlane = 100.0f;
};
}
|
dba849073d27a4d1a0cf13979010ddd0c5d54962
|
a11e2edaa536604d5bdc867f5f1e04bbc0b58700
|
/AggroEngine/src/Subsystem/Graphics/Impl/OpenGL/CommandTree/ShadowMap/DrawElements/DrawShadowElements.hpp
|
72565a8666e025c0f72ed04d17bdacb4a5cc900f
|
[] |
no_license
|
Argo15/Aggro-Engine
|
bd9be7b996ec0c3c9e70fe10ee4d02fc3e57ab18
|
7df2211900e6b3572a06f3195cbb357d23677e5f
|
refs/heads/master
| 2021-12-31T12:23:12.208908
| 2021-10-07T22:10:32
| 2021-10-07T22:10:32
| 72,375,974
| 6
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 324
|
hpp
|
DrawShadowElements.hpp
|
#pragma once
#include "Layer.hpp"
#include "ShadowMapBuffer.hpp"
class DrawShadowElements : public Layer
{
private:
ShadowMapBuffer *m_shadowMapBuf;
public:
DrawShadowElements(ShadowMapBuffer *shadowMapBuf);
shared_ptr<CommandTreeItem> getCommands(RenderOptions &renderOptions, shared_ptr<RenderNode> renderNodes);
};
|
400c16d5750e9ce03d6621f48d9c8edce28f85a3
|
1c1de7c39fc3c78fe90fc00274ea7b9170c3f97f
|
/Hackerrank Problems/hackerrank6of30.cpp
|
660d6a97b54c7823839faaad8e4ce86b26359621
|
[] |
no_license
|
shyam640/MY-WORKS
|
198d12e9ba4b5d8e110fab87deb69c4a382877a7
|
ec3244461028a4db9303d5ad044ec490b1070467
|
refs/heads/master
| 2023-08-10T16:00:50.943826
| 2021-02-28T04:54:36
| 2021-02-28T04:54:36
| 310,534,063
| 0
| 0
| null | 2021-02-27T18:03:52
| 2020-11-06T08:17:48
|
C++
|
UTF-8
|
C++
| false
| false
| 446
|
cpp
|
hackerrank6of30.cpp
|
#include<iostream>
#include<stdlib.h>
using namespace std;
int main(){
system("CLS");
int t;
cin>>t;
for(int test_case=0;test_case<t;test_case++){
string s1 ;
cin>>s1;
for(int i=0;i<s1.length();i++){
if(i%2==0){
cout<<s1[i];
}
}cout<<" ";
for(int i=0;i<s1.length();i++){
if(i%2!=0){
cout<<s1[i];
}
}
cout<<endl;
}
return 0;
}
|
a82bc826e05032389da121709bc52a71eedbf054
|
fbe41e566c97638d2fc56d405bd273633a5f4cbb
|
/otui/creature.h
|
bfe9269d168f4998f1ab76a88c8d11bdd4082389
|
[] |
no_license
|
gubailovo/OTUIEditor
|
de06c0bfc301dc7b6d964fe9ac42860f21b6fdc7
|
60a68ceef95a6c1b0eff556404a437b4951b7223
|
refs/heads/master
| 2023-03-15T16:07:00.933570
| 2020-12-25T12:17:52
| 2020-12-25T12:17:52
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 311
|
h
|
creature.h
|
#ifndef CREATURE_H
#define CREATURE_H
#include "widget.h"
namespace OTUI {
class Creature : public Widget
{
public:
Creature();
Creature(QString widgetId);
Creature(QString widgetId, QString dataPath, QString imagePath);
~Creature();
};
}
#endif // CREATURE_H
|
02be68cf83bdfff214f419020ae61e503683395c
|
8b4e130b67d3fe6f678eaec26b791e6b0a829769
|
/ModSteach.h
|
f7946b8299f442b0e1351ddea5cbe197ce082e9e
|
[
"MIT"
] |
permissive
|
rajkumarnaman/Office-Management-System
|
21a615f93666282fd8d5e5b19fa6142fa986c630
|
26e43bb643e4f36177524e68ba3945133c435feb
|
refs/heads/main
| 2023-06-06T11:42:39.641169
| 2021-06-28T07:06:56
| 2021-06-28T07:06:56
| 380,933,462
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,061
|
h
|
ModSteach.h
|
#ifndef MODSTEACH_H
#define MODSTEACH_H
//(*Headers(ModSteach)
#include <wx/button.h>
#include <wx/frame.h>
#include <wx/stattext.h>
//*)
class ModSteach: public wxFrame
{
public:
ModSteach(wxWindow* parent,wxWindowID id=wxID_ANY,const wxPoint& pos=wxDefaultPosition,const wxSize& size=wxDefaultSize);
virtual ~ModSteach();
//(*Declarations(ModSteach)
wxButton* Button1;
wxButton* Button2;
wxButton* Button3;
wxButton* Button4;
wxButton* Button5;
wxStaticText* StaticText4;
//*)
protected:
//(*Identifiers(ModSteach)
static const long ID_BUTTON1;
static const long ID_BUTTON2;
static const long ID_BUTTON3;
static const long ID_BUTTON4;
static const long ID_BUTTON5;
static const long ID_STATICTEXT4;
//*)
private:
//(*Handlers(ModSteach)
void OnButton1Click(wxCommandEvent& event);
void OnButton2Click(wxCommandEvent& event);
void OnButton3Click(wxCommandEvent& event);
void OnButton4Click(wxCommandEvent& event);
void OnButton5Click(wxCommandEvent& event);
//*)
DECLARE_EVENT_TABLE()
};
#endif
|
fa9d47abf6f9113632bea19a36a7de9340b9aef6
|
0ef9326cd8d12c1bf7779fb9bea470e0251a48f9
|
/OpenGL/FoundationOfCG/Assignment7/Assignment7-Meshes/Assignment7-Meshes/Meshes/texture.cpp
|
5b0fc2163951008d85b2836412b421150c127d62
|
[] |
no_license
|
nintymiles/CGLearning
|
dad2c73e29e9758a5f5ce740d3c38fc4c4c2543f
|
fe7a6e5e263c07dada70fe2824c6e9f0ee702a20
|
refs/heads/master
| 2022-10-27T12:30:08.717173
| 2022-10-17T07:46:06
| 2022-10-17T07:46:06
| 165,070,684
| 85
| 17
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,358
|
cpp
|
texture.cpp
|
#include <vector>
#include <string>
#include "ppm.h"
#include "asstcommon.h"
#include "texture.h"
#include "material.h"
using namespace std;
ImageTexture::ImageTexture(const string& ppmFileName, bool srgb) {
int width, height;
vector<PackedPixel> pixData;
ppmRead(ppmFileName.c_str(), width, height, pixData);
glBindTexture(GL_TEXTURE_2D, tex);
//glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
//如果srgb==false,则(!srgb)==true == 1,此时设置internal format为GL_RGB,否则设置为GL_SRGB
//实际使用中unsized rgb格式效果更好,why?fragment shader以linear方式使用color?
glTexImage2D(GL_TEXTURE_2D, 0, (!srgb) ? GL_RGB : GL_SRGB, width, height,0, GL_RGB, GL_UNSIGNED_BYTE, &pixData[0]);
//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512,
// 0, GL_RGB, GL_UNSIGNED_BYTE, &pixData[0]);
//不使用渐进式纹理,但是使用了对应的过滤器,导致错误。
glGenerateMipmap(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
checkGlError("Error Loading Texture");
}
|
c15151a1a8017e16a29cf24d2788b0d539d80682
|
cedfd68ed55ca0e46b2c4eec2b87b93143171744
|
/crossgene.cpp
|
9a2216bf667bdf178e08ef5227a76fa0cb9cf7e4
|
[] |
no_license
|
Szustarol/CrossGene
|
0e6c1f10724b0537b9402bea68283d24e9e0f466
|
d4036095bd4338c05fb8f5aba150fefd6d407f01
|
refs/heads/master
| 2022-12-05T01:50:56.580454
| 2020-08-29T15:02:29
| 2020-08-29T15:02:29
| 263,743,887
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 402
|
cpp
|
crossgene.cpp
|
#include <iostream>
#include "defines.hpp"
#include "Translations/strings.hpp"
#include "Widgets/main_window.hpp"
#include <gtkmm.h>
int main(int argc, char ** argv){
if constexpr(DEBUG_MODE){
std::cout << program_name << " is starting." << std::endl;
}
auto app = Gtk::Application::create(argc, argv, "gene.cross");
main_window mw;
return app->run(mw);
return 0;
}
|
c066f5ef8fef1cd7010e6f2ba2aaf0c8efeb0997
|
c133088a8b87571bacb4fa27da2c3b6a87ce8c86
|
/geekforgeeks/3rd week/minindexchar.cpp
|
854b2102286d685c9b66ead878b6d46f06330b6e
|
[] |
no_license
|
ssen110/cpp
|
2073bf32a91fbc6b4e788143e14baea7c6c2bfa2
|
7443a430f785561b1667e8e8635831afa680a173
|
refs/heads/master
| 2022-07-07T00:21:03.683716
| 2022-06-24T03:59:41
| 2022-06-24T03:59:41
| 246,741,917
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 537
|
cpp
|
minindexchar.cpp
|
#include <iostream>
#include <unordered_map>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int testcases;
cin>>testcases;
while(testcases--)
{
string S1,S2;
cin>>S1;
cin>>S2;
char c;
unordered_map<char , int > m;
int i=0;
int flag=0;
for(i=0;i<S2.length();i++)
m[S2[i]]=1;
for(i=0;i<S1.length();i++)
{
if(m.find(S1[i])!=m.end())
{
cout<<S1[i]<<endl;
flag=1;
break;
}
}
if(flag==0)
cout<<'$'<<endl;
}
return 0;
}
|
ec8088a7fda5748219372c430a5ae944fc8bfe81
|
7d302735577aae9f62f34e8086e5935b43d593e7
|
/DirectXGame/DirectXCore/State.cpp
|
21dfc673438293382c8073abe060f177128e3542
|
[
"MIT"
] |
permissive
|
nguyenlamlll/DirectX-11-Game
|
c8f683d57f5d27a81e29aa616dce60a8e7d2b6b1
|
560ae6d9b44cef7882c5fc93192160fae7da791d
|
refs/heads/develop
| 2020-03-28T10:47:31.633691
| 2018-12-03T14:14:46
| 2018-12-03T14:14:46
| 148,145,340
| 2
| 1
|
MIT
| 2018-12-16T05:02:34
| 2018-09-10T11:31:53
|
C++
|
UTF-8
|
C++
| false
| false
| 619
|
cpp
|
State.cpp
|
#include "stdafx.h"
#include "State.h"
#include "GameObject.h"
using namespace DirectXCore;
State::State()
{
}
DirectXCore::State::State(GameObject* _gameObject, std::vector<std::string> _originalStateList)
{
attachedGameObject = _gameObject;
//stateList = _originalStateList;
stateList.insert(stateList.end(), _originalStateList.begin(), _originalStateList.end());
}
State::~State()
{
}
bool DirectXCore::State::FindState(std::string state)
{
return std::find(stateList.begin(), stateList.end(), state) != stateList.end();
}
void DirectXCore::State::SetState(std::string _state)
{
currentState = _state;
}
|
496d8ecf071bb08d67b3b918490ae85ed9419680
|
9f429cbc4d09f454aea41865a68d4045d4043e01
|
/src/iopipe.cpp
|
fc752a51b00359bbf35d5b7a5d2c2701dc08590e
|
[] |
no_license
|
jason99chang/RShell
|
719bc793d1a68fc9f435640c7bb0740fa8b02457
|
1bf8bb6ab887ea9b1106fedcb9b99c87c0d037e4
|
refs/heads/master
| 2021-01-14T05:24:34.759209
| 2019-06-19T11:52:15
| 2019-06-19T11:52:15
| 242,611,837
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,313
|
cpp
|
iopipe.cpp
|
/**
I have been using switch statements because I was used to doing them when I was still programming in Java (years ago),
I also thought that maybe there would be more cases so a switch statement would've been more effective that a bunch out
if statements, when checking for the status of fork, but forgot that there was basically only two values that fork can return,
they were -1 or 0. I also thought that there would be multiple exit statuses so there would be more cases to handle (for piping)
but again, there would only a couple (2) that I called in this class' execution function. They were: exit(1) and exit(0).
I am rewriting this function so I can demonstrate that I know what piping does.
Updated so that it checks command execution because it would be
redunant to check everything if the command doesn't even run.
Removed status variable because we can just return the the result (bool)
by error checking each phase.
We will continue using exit calls alongside returns because we would still
like to know the current status of the program. Unless I find another way for
the function to give the user a boolean result without influencing the actual
logic.
I have learned that exit(1) is for exiting due to a failure
On the contrary, exit(0) would be formally defined as an EXIT_SUCCESS
Below are the notes that I took from reading and watching online videos on how to do pipe.
If fork is called and it returns a negative value, that means the creation of the child process has failed.
Returns 0 to newly created child process
Make a file descriptor array of size 2 (fd[2])
Notes are continued in the PSUEDOCODE comments block starting 4 lines below.
**/
#include "../header/iopipe.h"
#include "../header/base.h"
#include "../header/connector.h"
#include <fcntl.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <cstdlib>
#include <iostream>
using namespace std;
/**
Forward declaration of classes neccessary for the class to compile without errors or VTable error at runtime.
**/
class Base;
class Connector;
bool IOPipe::execute() {
/**
ORIGINAL PSEUDO CODE (INITIAL IDEA GOING INTO THE ASSIGNMENT)
We are going to be utilizing the pipe function (inherent sys call) so that we can double check if anything goes wrong before even doing the piping process.
check if the initial pipe has an error (< 0), before doing anything, waste of space
pipe1 gets the initial pipe (we use this to see if there is any errors initially)
If pipe1 passes, fork pid1
Check for errors
if == 0
Basically means a success, so now we have to create another child process
If < 0
Error in fork
after creating another fork while inside the pid1 we also need to error check
If < 0 there’s an error in creating the child process
But if successful, we need to copy the desc using the dup2 function, then check if it’s < 0 because then that would mean there are errors
If left doesn’t work obviously return false (then check if right execution returns false)
execute left and right accordingly after copying the file_desc into the array
Check if they fail when they close
While loop for WIFEXITED (to set the status values)
waitpid (wait for process to end), pass through the pointer to the status int
If status is 0 return true but if anything else return false because that would mean that it has failed (the piping command)
necessary variables - file descriptor integer array
initial pipe of file_desc (error checking only)
Pid1 and pid2 (two children processes)
singular integer for status (temp)
**/
/**
Variable declarations here
**/
int file_desc[2];
pid_t pid1, pid2;
if (pipe(file_desc) < 0) {
perror("pipe");
exit(1);
return false;
/**
NOTE: I read online that you should be checking the statuses of each of the child processes,
but I feel like it is not complettely
necessary if you are solely asked to implement a check whether or not the commands ran properly or not.
**/
} else {
//create first fork (child process), and again, check for errors
pid1 = fork();
if (pid1 < 0) {
perror("fork");
exit(1);
return false;
} else {
if (pid1 == 0) {
// cout << "good job" << endl;
//if success, call fork again
pid2 = fork();
if (pid2 < 0) {
perror("fork");
exit(1);
return false;
}
if (pid2 == 0) {
//attempt left side piping
dup2(file_desc[1], 1);
close(file_desc[0]);
if (left->execute() == false) {
cout << "left execution failed" << endl;
exit(1);
return false;
}
exit(0); //success termination
} else {
//attempt right side piping
dup2(file_desc[0], 0);
close(file_desc[1]);
if (right->execute() == false) {
cout << "right execution failed" << endl;
exit(1);
return false;
}
exit(0); //success termination
}
}
}
//fixed infinite loop issue by ending the process here.
// cout << "we made it if we got to here." << endl;
/**
If we have reached this point, that MUST mean that the piping execution has been complete and ran without errors.
**/
exit(0);
return true;
}
return false;
}
string IOPipe::getCommand() {
return left->getCommand() + " | " + right->getCommand();
}
|
5ce8c3580145f2c301e4bc337d8e28bc579dd233
|
2b1b459706bbac83dad951426927b5798e1786fc
|
/zircon/kernel/lib/arch/include/lib/arch/random.h
|
853236c6c6dbfe842482a45e2799a710acf443c2
|
[
"MIT",
"BSD-2-Clause",
"BSD-3-Clause"
] |
permissive
|
gnoliyil/fuchsia
|
bc205e4b77417acd4513fd35d7f83abd3f43eb8d
|
bc81409a0527580432923c30fbbb44aba677b57d
|
refs/heads/main
| 2022-12-12T11:53:01.714113
| 2022-01-08T17:01:14
| 2022-12-08T01:29:53
| 445,866,010
| 4
| 3
|
BSD-2-Clause
| 2022-10-11T05:44:30
| 2022-01-08T16:09:33
|
C++
|
UTF-8
|
C++
| false
| false
| 1,622
|
h
|
random.h
|
// Copyright 2021 The Fuchsia Authors
//
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT
#ifndef ZIRCON_KERNEL_LIB_ARCH_INCLUDE_LIB_ARCH_RANDOM_H_
#define ZIRCON_KERNEL_LIB_ARCH_INCLUDE_LIB_ARCH_RANDOM_H_
#include <cstdint>
#include <optional>
namespace arch {
// There are two flavors of CPU random number generation:
// 1. reseeded occasionally as the hardware chooses
// 2. reseeded immediately on request
// The second offers stronger randomness guarantees when it's available,
// but may deplete the available random state more quickly than the first.
template <bool Reseed>
struct Random {
// Returns true if the hardware supports the operation.
// If this returns false, it's not safe to call Get()!
[[gnu::const]] static bool Supported();
// Fetch a random value if it can be gotten quickly. If the hardware doesn't
// succeed on the first try, This does a recommended standard number of
// retries by default (argument is std::nullopt), or the exact number passed.
// Returns std::nullopt if no value is immediately available. Simply looping
// will eventually make one available, but on a CPU not stressed with other
// uses of the RNG hardware the standard retries should suffice so this
// failing should be considered unusual.
static std::optional<uint64_t> Get(std::optional<unsigned int> retries = std::nullopt);
};
extern template struct Random<false>;
extern template struct Random<true>;
} // namespace arch
#endif // ZIRCON_KERNEL_LIB_ARCH_INCLUDE_LIB_ARCH_RANDOM_H_
|
88714eb20b254391f6bcc643958b6721817e4d0a
|
4cfe15029a3ba86134f60700e8a1eb3f94a63f58
|
/SideScroller/Enemyhandler.cpp
|
775bf94041d0bfab1a25a38cd2a24b7960d53e77
|
[] |
no_license
|
scaepz/shapist-game
|
70e51a91cc0ddc871e464a7e55d4d02276cf42aa
|
965c7fd9ba8c20c3f6c27edf92b5f5fbc6f00ee9
|
refs/heads/master
| 2021-01-01T05:20:00.423583
| 2016-05-25T18:14:19
| 2016-05-25T18:14:19
| 56,383,298
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 428
|
cpp
|
Enemyhandler.cpp
|
#include "EnemyHandler.h"
CEnemyHandler::CEnemyHandler()
{
}
CEnemyHandler::~CEnemyHandler()
{
}
void CEnemyHandler::HandleEnemies()
{
for (int i = 0; i < enemyVector->size(); i++)
{
}
int size = enemyVector->size();
for (int i = 0; i < size; i++)
{
if (enemyVector->at(i)->GetHP() <= 0)
{
if (enemyVector->at(i)->Die())
{
vm->DeleteObject(enemyVector->at(i));
size--;
i--;
}
}
}
}
|
719d83240a12b050fa7a327dcab8dbaed53c8c9b
|
4baffe507a2d6f7e3ccb15500ed7e09b0ddfd60d
|
/BOJ_1325_DFS_BFS_hack/main.cpp
|
a4c3ca0c026c1b65c2509159a5049a796348b6f2
|
[] |
no_license
|
junyoungKimGit/algorithm
|
52dba39dff3d8e5043ac53db359dcc195a24c1ca
|
bb73b98acb57d8d9b08fc06820e63142ab711272
|
refs/heads/master
| 2022-08-09T12:51:49.484357
| 2022-07-17T07:20:33
| 2022-07-17T07:20:33
| 143,444,010
| 0
| 0
| null | null | null | null |
UHC
|
C++
| false
| false
| 1,105
|
cpp
|
main.cpp
|
//BOJ 1325 효율적인 해킹
#include <iostream>
using namespace std;
#define MAX_N (10001)
short gMap[MAX_N][MAX_N];
short gVisited[MAX_N];
short gRank[MAX_N];
int N, M;
int max(int aA, int aB)
{
return aA > aB ? aA : aB;
}
void dfs(int aCurrent, int aCnt, int aTestcase)
{
for (int i = 1; i <= N; i++)
{
if (gVisited[i] != aTestcase && gMap[aCurrent][i] == 1)
{
dfs(i, aCnt + 1, aTestcase);
}
}
gRank[aCurrent] = max(gRank[aCurrent], aCnt);
}
void findSolve()
{
for (int i = 1; i <= N; i++)
{
if(gRank[i] == -1)
dfs(i, 0, i);
}
}
int main()
{
int sChild = 0;
int sParent = 0;
int sMaxRank = 0;
cin >> N >> M;
for (int i = 0; i < M; i++)
{
cin >> sChild >> sParent;
gMap[sChild][sParent] = 1;
gRank[sChild] = -1;
}
findSolve();
for (int i = 1; i <= N; i++)
{
sMaxRank = max(sMaxRank, gRank[i]);
//cout << "gRank : " << gRank[i] << endl;
}
bool sIsFirst = true;
for (int i = 1; i <= N; i++)
{
if (sMaxRank == gRank[i])
{
if (sIsFirst == false)
{
cout << " ";
}
cout << i;
sIsFirst = false;
}
}
return 0;
}
|
cc01b60eefaa7e9f5f5b645cdf3aa7ec1692fce8
|
5821daeb6fa1420ecb9de6c5f774075b7921d54d
|
/SlidingTiles/Resources.h
|
e1954b57500458f2b134774ec54a58fe9469b31c
|
[] |
no_license
|
hnefatl/SlidingTiles
|
6830e56410fee9d9bb6aec8293f8bc371336c5c1
|
5e5f2432b0bffea29c4d31fa7be24c2dda54d662
|
refs/heads/master
| 2021-01-20T12:01:01.315002
| 2013-11-16T22:36:00
| 2013-11-16T22:36:00
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 266
|
h
|
Resources.h
|
#ifndef _RESOURCES_H
#define _RESOURCES_H
#include <string>
namespace Resources
{
namespace Sprites
{
const std::string Particle="Resources\\Sprites\\Particle.png";
};
namespace Fonts
{
const std::string Arial="Resources\\Fonts\\Arial.ttf";
};
};
#endif
|
fd71444d1cc77402be027bc6a2eed50c4809e3a8
|
71b2b46399f271a7718dc1d9d30efca26b072f31
|
/Sorts.cpp
|
36a3100dd4023db1fda65a9e8664100f1c92d10a
|
[] |
no_license
|
PavelUltra/Array-Sort
|
3cc7d10e88bb501848f70514f6ff9f3eb6c08ca8
|
52342eabf8d619b716a73574934fac8fd885266a
|
refs/heads/master
| 2023-06-03T15:19:44.291395
| 2021-06-18T04:43:21
| 2021-06-18T04:43:21
| 378,029,448
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,718
|
cpp
|
Sorts.cpp
|
#include <stdio.h>
#include <malloc.h>
#include <unistd.h>
#include <stdlib.h>
#include <sstream>
#include <iostream>
#include <SFML/Graphics.hpp>
sf::RenderWindow window(sf::VideoMode(500, 350), "SFML works!");
int my_time = 0; //время сортировки
int swaps = 0; //количество свапов
void draw_array(int* A,int N){
/*проинициализировать шрифты нужно один раз, поэтому мы должны распознать самый первый вход в функцию
для этого введем статический флаг*/
static int flag = 0;
static sf::Font font; //объявление шрифта
if(flag == 0){
font.loadFromFile("consola.ttf"); //инициализация шрифта
flag++;
}
int weight = 500/N; //ширина столбца
sf::RectangleShape* rectangles = new sf::RectangleShape[N]; //объявление массва прямоугольников
for (int i = 0; i < N; i++)
{
rectangles[i] = sf::RectangleShape(sf::Vector2f(weight,3*A[i])); //инициализация прямоугольников
rectangles[i].move(weight*i,350-3*A[i]); //позиционирование прямоугольников
window.draw(rectangles[i]); //прорисовка
}
sf::Text text("", font, 20); //задание параметров текста
std::ostringstream swaps_text; //потог для ввода текста
swaps_text<<swaps;
std::ostringstream time_text;
time_text<<swaps;
text.setString("Swaps:" + swaps_text.str() + " " + "Time:" + time_text.str()); //сам текст
text.setPosition(10,10); //позиционирование текста
window.draw(text); //прорисовка текста
window.display(); //отображение всего нарисованного на экране
sleep(1); //задержка
window.clear(); //очищение экрана
my_time++;
swaps++;
}
void swap(int &A, int &B,int *D,int N){ //Функция для свапанья
int C = A;
A = B;
B = C;
draw_array(D,N); //Рисуем каждый сват
}
void Bubble_sort(int *A,int N){ //пузырьковая сортировка
for (int i = 0; i < N; i++)
{
for (int j = 1; j < N-i; j++)
{
if(A[j-1]>A[j]){
swap(A[j-1],A[j],A,N);
}
}
}
}
void Insertion_sort(int *A,int N){ //Сортировка вставками
for (int i = 1; i < N; i++)
{
for (int j = i; j > 0; j--)
{
if(A[j-1]>A[j]){
swap(A[j-1],A[j],A,N);
}
}
}
}
void print_array(int *A,int N){ //Вывод массива
for (int i = 0; i < N; printf("%d ",A[i++]));
printf("\n");
}
void counter_sort(int*A,int N){ //Сортировка подсчетом
int min = A[0];
int max = A[0];
for (int i = 0; i < N; i++)
{
if (min>A[i])
{
min = A[i];
}
if (max<A[i])
{
max = A[i];
}
}
int denomenator=min;
for (int i = 0; i < N; i++)
{
A[i] -= denomenator;
}
max-=denomenator;
int *B = (int*)malloc(sizeof(int)*max);
for (int i = 0; i < max;B[i++] = 0);
for (int i = 0; i < N; i++)
{
B[A[i]]++;
}
int summ = 0;
for (int i = 0; i <= max; i++){
for (int j = 0; j <B[i]; j++,summ++){
A[summ] = i+denomenator;
}
}
delete[] B;
}
/*Быструю сортировку обычно пишут так, что бы её можно было вызвать рекурсивно
Однако тогда эта сортировка будет отличаться по выхову от других функций,
что не позволит вызывать её из массива указателей на функции. Поэтому придется
создать промежуточную функцию quick_sort, сигнатура которой совпадает с остальными
функциями с сортировками. Эта функция будет вызывать quick_req_sort в которой уже и
находится текст основной сортировки*/
void quick_req_sort(int *A, int first, int last,int N) //сама быстрая сортировка
{
if (first < last)
{
int left = first, right = last, middle = A[(left + right) / 2];
do
{
while (A[left] < middle) left++;
while (A[right] > middle) right--;
if (left <= right)
{
swap(A[left],A[right],A,N);
left++;
right--;
}
} while (left <= right);
quick_req_sort(A, first, right,N);
quick_req_sort(A, left, last,N);
}
}
void quick_sort(int*A,int N){ //Промежуточное звено
quick_req_sort(A,0,N-1,N);
}
void break_array(int*A,int N){ //Самая главная сортировка
for (int i = 0; i < 10; i++)
{
A[i] = rand()%100;
}
}
int main()
{
typedef void(f)(int*A,int N); //массив, хранящий вызываемые сортировки
f* Mass[3] = {Bubble_sort,Insertion_sort,quick_sort};
int A[10] = {83,86,77,17,93,35,86,92,49,21};
while (window.isOpen()) //Открытие окна с грачикой
{
window.clear(); //Очистка экрана
for (int i = 0; i < 3; i++) //Рисование всех сортировок (которые можно нарисовать)
{
break_array(A,10);
sleep(1);
Mass[i](A,10);
sleep(1);
window.clear();
window.display();
swaps = 0;
my_time = 0;
}
window.close(); //Закрырие окна с графикой
}
return 0;
}
|
3896406c9cc6dc3b3464677a07c137da107d3abd
|
2d98f202e981b1a49eb37b6697170d803f2d215f
|
/Src/FM79979Engine/FishingFun/Win32Test/GameObjectSelector.h
|
3ee0a65b2f493575b4eb7030d3f352c2975c5dac
|
[] |
no_license
|
fatmingwang/FM79979
|
bb1274241605f490b8e216f930a2c5aaba86f669
|
735f204bd70773c2482e15b3105a8680cf119706
|
refs/heads/master
| 2023-07-09T00:47:02.782514
| 2023-06-23T10:23:27
| 2023-06-23T10:23:27
| 43,816,834
| 7
| 3
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,579
|
h
|
GameObjectSelector.h
|
#ifndef _GAME_OBJECT_SELECTOR_H_
#define _GAME_OBJECT_SELECTOR_H_
//<cGameObjectSelector Name="">
// <cButtonDialog Description="">
// <cMPDI MPDIList="" MPDI=""/>
// </cButtonDialog>
// <cGameItemInfoButton>
// <cButtonDialog Description="">
// <cMPDI MPDIList="" MPDI=""/>
// </cButtonDialog>
// <cRenderObjectVector>
// <cFontWithFrame GlyphRenderName="" Text="" />
// <SubMPDI cMPDIList="" cMPDI="" cSubMPDI=""/>
// </cFontWithFrame>
// <cFontWithFrame GlyphRenderName="" Text="" />
// <SubMPDI cMPDIList="" cMPDI="" cSubMPDI=""/>
// </cFontWithFrame>
// </cRenderObjectVector>
// <cGameItemInfoButton>
//</cGameObjectSelector>
class cGameItemInfoButton:public cButtonDialog
{
protected:
cRenderObjectVector* m_pDescriptionFontFrameVector;
public:
cGameItemInfoButton();
cGameItemInfoButton(cGameItemInfoButton*e_pGameItemInfoButton);
cGameItemInfoButton(TiXmlElement*e_pElement);
~cGameItemInfoButton();
static cGameItemInfoButton*GetMe(TiXmlElement*e_pElement);
virtual void Update(float e_fElpaseTime);
virtual void Render();
void ChangeText(int e_iIndex,const WCHAR*e_strText);
void ChangeText(int e_iIndex,std::wstring e_strText);
void ChangeBG(const WCHAR*e_strPuzzeleImageUnitName,const WCHAR*e_strPuzzleImageName = 0);
};
typedef void (*AssignGameObjectInfo)(NamedTypedObject*e_pSrc,cGameItemInfoButton*e_pGameItemInfoButton,int e_iType);
class cFishRodAndFishThreadData;
class cGameObjectSelector:public cFMWorkingObjectChanger<cGameItemInfoButton>
{
cNamedTypedObjectVector<NamedTypedObject>* m_pGameItemInfoReferenceData;
cFishRodAndFishThreadData* m_pFishRodAndFishThreadData;
//
TiXmlElement* m_pTemplateElement;
TiXmlElement* m_pGameItemInfoButtonTemplateElement;
cButtonDialog* m_pButtonDialog;
public:
cGameObjectSelector(TiXmlElement*e_pTemplateElement);
cGameObjectSelector(cGameObjectSelector*e_pGameObjectSelector);
~cGameObjectSelector();
CLONE_MYSELF(cGameObjectSelector);
DEFINE_TYPE_INFO();
void SetGameItemInfoReferenceData(cNamedTypedObjectVector<NamedTypedObject>*e_pTargetSource,int e_iType);
virtual void Update(float e_fElpaseTime);
virtual void Render();
virtual void Destroy();
virtual void MouseDown(int e_iPosX,int e_iPosY);
virtual void MouseMove(int e_iPosX,int e_iPosY);
virtual void MouseUp(int e_iPosX,int e_iPosY);
AssignGameObjectInfo AssignGameObjectInfoFun;
bool IsSatisfiedCondition();
const WCHAR* GetSelectItemName();
};
#endif
|
d9a26989169cb1d01ac8a2a271639291f80a357b
|
542e7226496c17d325209dac6c0ff13115d757dc
|
/tests/MemoryManager.test.cpp
|
a5d0a4415fe74b343ec4ef4231b9635a7ca6ff18
|
[
"Apache-2.0"
] |
permissive
|
ElJerry/GeneticAlgorithmLib
|
03c6b87e9ed1f29d4877ce1aeac267cec9b9f40b
|
ac9d3a89e8b0ec8373dd7dfcf0a44506dbc3eec9
|
refs/heads/master
| 2023-08-23T17:00:55.584076
| 2021-09-13T05:26:23
| 2021-09-13T05:26:23
| 240,850,382
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,120
|
cpp
|
MemoryManager.test.cpp
|
#include <catch2.h>
#include <../src/MemoryManager.h>
TEST_CASE("MemoryManager works as expected")
{
int MAX_MEM_SIZE = 500;
MemoryManager<int> manager(MAX_MEM_SIZE);
SECTION("MemoryManager creates a maximum of MAX_MEM_SIZE elements")
{
int times = MAX_MEM_SIZE;
while (times--)
{
manager.create(times);
}
int error = manager.create(999);
REQUIRE(error == -1);
}
SECTION("MemoryManager destroys memory and allows new creations")
{
int times = MAX_MEM_SIZE;
while (times--)
{
manager.destroy(times);
}
times = MAX_MEM_SIZE;
while (times--)
{
int handle = manager.create(times);
REQUIRE(handle != -1);
}
}
SECTION("MemoryManager returns -1 when there is no memory left")
{
int times = MAX_MEM_SIZE;
while (times--)
{
int handle = manager.create(times);
REQUIRE(handle != -1);
}
int handle = manager.create(999);
REQUIRE(handle == -1);
}
}
|
bcfa36fca0737e35b082be0f2ac6c7133b56251d
|
41dffbadeb57abc6cc071125356fca20ab9dea64
|
/Polymorphism/binaryOperatorOverloading.cpp
|
abc307d9d4c3e3d8e7c77e88bb2a4ff88a69fb9b
|
[] |
no_license
|
gulshanyadav01/Object-Oriented-programming
|
e7c06e818eb6b69ca26040191911f487a89996cc
|
f73890e66e64042d6e23862ad7da2299d99a334b
|
refs/heads/master
| 2023-07-27T09:44:01.515109
| 2021-08-26T14:37:02
| 2021-08-26T14:37:02
| 395,389,076
| 0
| 0
| null | 2021-08-19T07:47:42
| 2021-08-12T17:00:44
|
C++
|
UTF-8
|
C++
| false
| false
| 686
|
cpp
|
binaryOperatorOverloading.cpp
|
#include<iostream>
using namespace std;
class Test {
int a, b;
public:
Test(){
a = b = 0;
}
Test(int x, int y){
a = x, b = y;
}
Test operator + (Test t ){
Test temp;
temp.a = a + t.a;
temp.b = b + t.b;
return temp;
}
void disp(){
cout << "value of a " << a << endl;
cout << "value of b" << b << endl;
}
};
int main(){
Test t1, t2, t3;
t1 = Test(10, 20);
t2 = Test(30, 40);
t3 = t1 + t2;
t1.disp();
t2.disp();
t3.disp();
}
|
88594d7c3c4d9de6577c16abb7b810f05b43fdbc
|
8f8f87c0ffacf8509ee5f32f74447f64887ef501
|
/problems/leetcode/6-zigzag-conversion/main.cpp
|
c1e5d8e079c30df02eb4002fdde465561274c971
|
[] |
no_license
|
godcrampy/competitive
|
c32eb1baf355fa9697f4ea69bea1e8e2d346e14c
|
e42f3000296c7b40e6a4c368dd17241ebb678d18
|
refs/heads/master
| 2023-03-28T17:05:15.776334
| 2021-04-03T13:40:15
| 2021-04-03T13:40:15
| 206,922,544
| 6
| 3
| null | 2020-10-01T13:22:40
| 2019-09-07T05:51:30
|
C++
|
UTF-8
|
C++
| false
| false
| 456
|
cpp
|
main.cpp
|
#include <string>
#include <vector>
using namespace std;
int row_number(int numRows, int t) {
int x = (numRows - 1) * 2;
return min(t % x, x - (t % x));
}
string convert(string s, int numRows) {
if (numRows <= 1) return s;
vector<string> table(numRows);
for (int i = 0; i < s.length(); ++i) {
int r = row_number(numRows, i);
table[r] += s.substr(i, 1);
}
string ret;
for (auto str : table) {
ret += str;
}
return ret;
}
|
cc12ada964b447864d8f131d50f7a686eeb6a652
|
4ed32fad3e7cb410aeb375b6a949374662d48e96
|
/humidity_DHT22_to_SD/humidity_DHT22_to_SD.ino
|
c071f68f9c94111ef32d2dbb9f2adc0ff1332dee
|
[
"MIT"
] |
permissive
|
pitbull36/humidity_DHT22_to_SD
|
26d1b040bec5380c1c3890d80539011c439b96b1
|
5d0e4317194f41934e086f55ebe251bfb846fd3d
|
refs/heads/main
| 2023-07-11T17:37:46.004171
| 2021-08-05T07:28:30
| 2021-08-05T07:28:30
| 335,244,538
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,290
|
ino
|
humidity_DHT22_to_SD.ino
|
// for temp sens
#include <DHT.h>
#include <Adafruit_Sensor.h>
// for SD reader
#include <SPI.h>
#include <SD.h>
#define DHTPIN 2
#define DHTTYPE DHT22
// this will be needed to keep track of the time and decide when to log data and turn on/off the LED
// while still being able to check for the pressed button
unsigned long previousMillis4Interval = 0; // to keep track of time
unsigned long previousMillis4onoff = 0; // to keep track of time
//unsigned long previousMillis4off = 0; // to keep track of time
long ontime = 59000; // milliseconds of on-time
long interval = 60000; // interval for writing data
long offtime = 61000; // milliseconds of off-time
bool on = false;
bool interv = false;
// DHT SENSOR: Initialize DHT sensor for normal 16mhz Arduino:
DHT dht = DHT(DHTPIN, DHTTYPE);
// SD MOUDLE: change this to match your SD shield or module, the CS pin of the SD module
const int chipSelect = 10;
// PUSH BUTTON on the proto board
const int buttonPin = 1;
const int debounceDelay = 10; // milliseconds to wait until stable
// LEDs on the proto board
const int ledPinRed = 8; // the number of the output pin
const int ledPinButton = 7; // the number of the output pin
// USEFUL VARIABLES: initialise ID, will use it later to print it to file
int id = 1;
bool flag = false;
File myFile; // file to write in
// DEBOUNCE FUNCTION
boolean debounce(int pin)
{
boolean state;
boolean previousState;
previousState = digitalRead(pin); // store switch state
for(int counter=0; counter < debounceDelay; counter++)
{
delay(1); // wait for 1 millisecond
state = digitalRead(pin); // read the pin
if( state != previousState)
{
counter = 0; // reset the counter if the state changes
previousState = state; // and save the current state
}
}
// here when the switch state has been stable longer than the debounce period
return state;
}
void setup()
{
// LED on the proto board
pinMode(ledPinRed, OUTPUT);
pinMode(ledPinButton, OUTPUT);
// PUSH BUTTON on the proto board as an input
pinMode(buttonPin, INPUT);
// Begin serial communication at a baud rate of 9600:
Serial.begin(9600);
// Setup DHT sensor:
dht.begin();
// initialise SD card
Serial.print("Initializing SD card...");
if (!SD.begin()) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
// initialise data file with headers
myFile = SD.open("data.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.print("Initialising data file...");
// write the headers every time the Arudino starts (ID, Temp, Hum, Flag)
myFile.print("ID");myFile.print(",");myFile.print("Temperature");myFile.print(",");myFile.print("Humidity");myFile.print(",");myFile.println("Flag");
// close the file:
myFile.close();
Serial.println("Done, all good!");
}
// // Check if the file was written, by reading it
// myFile = SD.open("data.txt");
// if (myFile) {
// Serial.println("data.txt:");
//
// // read from the file until empty
// while (myFile.available()) {
// Serial.write(myFile.read());
// }
// // close the file
// myFile.close();
// } else {
// // if the file didn't open
// Serial.println("error opening the file");
// }
}
void loop()
{
// READ THE BUTTON
if(debounce(buttonPin))
{
digitalWrite(ledPinButton, LOW);
} else {
digitalWrite(ledPinButton, HIGH);
flag = true;
}
// this is the current time
unsigned long currentMillis = millis();
//Serial.println(currentMillis - previousMillis4onoff);
// Read the humidity (in %)
float h = dht.readHumidity();
// Read the temperature (in Celsius)
float t = dht.readTemperature();
// Check if everything's good with the reading from the DHT22:
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
if((currentMillis - previousMillis4onoff >= interval) && (interv == false))
{
interv = true;
//ledState = HIGH; // turn it on
Serial.println("sono nel interval e scrivo...");
// write on the txt the temperature and humidity taken from the sensor every minute
myFile = SD.open("data.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
//Serial.print("Writing to file...");
// now check if flag == true, that is, if the button was pressed to signal an event
// if there was an event, write 1 in the "flag" column
// else write 0
if (flag == true){
myFile.print(id);myFile.print(",");myFile.print(t);myFile.print(",");myFile.print(h);myFile.print(",");myFile.println(1);
Serial.print(id);Serial.print(",");Serial.print(t);Serial.print(",");Serial.print(h);Serial.print(",");Serial.println(1);
flag = false;
}
else {
myFile.print(id);myFile.print(",");myFile.print(t);myFile.print(",");myFile.print(h);myFile.print(",");myFile.println(0);
Serial.print(id);Serial.print(",");Serial.print(t);Serial.print(",");Serial.print(h);Serial.print(",");Serial.println(0);
}
// close the file:
myFile.close();
// increase ID
id ++;
//previousMillis4onoff = currentMillis; // Remember the time
// turn the red led off
//digitalWrite(8, LOW);
//digitalWrite(ledPin, ledState); // Update the actual LED
}
}
if ((currentMillis - previousMillis4onoff >= ontime) && (on == false))
{
on = true;
Serial.println("sono nel ONON");
digitalWrite(ledPinRed, HIGH);
// // Debug on serial
// Serial.print("Humidity: ");
// Serial.print(h);
// Serial.print("%\n");
// Serial.print("Temperature: ");
// Serial.print(t);
// Serial.print("\n");
//ledState = LOW; // Turn it off
// turn the red led on
//digitalWrite(8, HIGH);
//previousMillis4onoff = currentMillis; // Remember the time
//digitalWrite(ledPin, ledState); // Update the actual LED
}
if ((currentMillis - previousMillis4onoff >= offtime)){
Serial.println("sono nel OFFOFF");
digitalWrite(ledPinRed, LOW);
previousMillis4onoff = currentMillis; // Remember the time
interv = false;
on = false;
}
}
|
3c52f531763618878d8d6ce19974b80594a963d3
|
091afb7001e86146209397ea362da70ffd63a916
|
/inst/include/nt2/include/functions/scalar/nblines.hpp
|
746b3e6da7cadd4d6afd3050bdfca62192e1a619
|
[] |
no_license
|
RcppCore/RcppNT2
|
f156b58c08863243f259d1e609c9a7a8cf669990
|
cd7e548daa2d679b6ccebe19744b9a36f1e9139c
|
refs/heads/master
| 2021-01-10T16:15:16.861239
| 2016-02-02T22:18:25
| 2016-02-02T22:18:25
| 50,460,545
| 15
| 1
| null | 2019-11-15T22:08:50
| 2016-01-26T21:29:34
|
C++
|
UTF-8
|
C++
| false
| false
| 182
|
hpp
|
nblines.hpp
|
#ifndef NT2_INCLUDE_FUNCTIONS_SCALAR_NBLINES_HPP_INCLUDED
#define NT2_INCLUDE_FUNCTIONS_SCALAR_NBLINES_HPP_INCLUDED
#include <nt2/core/include/functions/scalar/nblines.hpp>
#endif
|
6986156e21f7d52e29abf8495cccb7d46c0f7183
|
7d178081186238739f0c0377e393f320912f3759
|
/exporter/main.cpp
|
443acc18ed472e10c23e6d0325f65a254aa8c7ae
|
[] |
no_license
|
martin-pr/maya-mesh-export
|
1e41b5942ed971fac3f836a1466c1cee15d90ce4
|
8e8a3b89aab80deba4237a7ef243f06713e97e49
|
refs/heads/master
| 2016-09-08T01:51:42.555500
| 2012-04-21T17:59:11
| 2012-04-21T17:59:11
| 4,097,821
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 13,949
|
cpp
|
main.cpp
|
#include "main.h"
#include <cassert>
#include <maya/MFnPlugin.h>
#include <maya/MSelectionList.h>
#include <maya/MDagPath.h>
#include <maya/MFnMesh.h>
#include <maya/MItSelectionList.h>
#include <maya/MFn.h>
#include <maya/MFloatPointArray.h>
#include <maya/MFloatVectorArray.h>
#include <maya/MFnSkinCluster.h>
#include <maya/MItDependencyGraph.h>
#include <maya/MDagPathArray.h>
#include <maya/MItGeometry.h>
#include <maya/MFnDependencyNode.h>
#include <maya/MFnTransform.h>
#include <maya/MQuaternion.h>
#include <maya/MAnimControl.h>
#include <maya/MCommandResult.h>
#include "maya_stream.h"
#include "tag.h"
using namespace std;
// put the mesh to binding pose
// according to http://nccastaff.bournemouth.ac.uk/jmacey/RobTheBloke/www/research/maya/mfnskinning.htm
// and http://svn6.assembla.com/svn/p400roguelike/P400Roguelike/OgreSDK/Tools/MayaExport/src/skeleton.cpp
// DOES IT WORK?!
void bindingPose(const bool& set) {
static bool isInBindingPose = false;
MStatus status;
// set the binding pose
if(set) {
if(!isInBindingPose) {
isInBindingPose = true;
// disable IK
status = MGlobal::executeCommand("doEnableNodeItems false all");
assert(status == MStatus::kSuccess);
// save the current pose
status = MGlobal::executeCommand("dagPose -save -name savedPose");
assert(status == MStatus::kSuccess);
// and move the mesh to the binding pose
status = MGlobal::executeCommand("dagPose -restore -global -bindPose");
assert(status == MStatus::kSuccess);
}
}
// undo the binding pose
else if(isInBindingPose) {
isInBindingPose = false;
// restore the saved pose
status = MGlobal::executeCommand("dagPose -restore -global -name savedPose");
assert(status == MStatus::kSuccess);
// turn on the IK back
status = MGlobal::executeCommand("doEnableNodeItems true all");
assert(status == MStatus::kSuccess);
}
}
exporter::exporter() {
}
void* exporter::creator() {
return new exporter;
}
MStatus exporter::doIt(const MArgList& argList) {
maya_stream mout;
MStatus status;
MCommandResult result;
status = MGlobal::executeCommand("fileDialog -mode 1 -defaultFileName export.xml -title XMLExporter", result);
assert(status == MStatus::kSuccess);
MString filename;
status = result.getResult(filename);
assert(status == MStatus::kSuccess);
if(filename.length() > 0) {
mout << "exporting... " << filename.asChar() << endl;
tag::openFile(filename.asChar());
tag root("export");
// get active selection iterator
MSelectionList activeList;
MGlobal::getActiveSelectionList(activeList);
MStringArray list;
activeList.getSelectionStrings(list);
mout << " selection: ";
for(unsigned a=0;a<list.length();a++)
mout << list[a] << " ";
mout << endl;
for(unsigned a=0;a<activeList.length();a++) {
MDagPath mesh;
MObject component;
status = activeList.getDagPath(a, mesh, component);
if(status == MStatus::kSuccess) {
// get only meshes
if(mesh.hasFn(MFn::kMesh)) {
// get the mesh function set
MFnMesh meshFn(mesh, &status);
assert(status == MStatus::kSuccess);
//////////////////////////////////
// output the mesh name
mout << " Mesh: " << meshFn.name() << endl;
tag m("mesh");
// set the mesh to the binding pose
bindingPose(true);
//////////////////////////////////
// get the mesh vertices
{
tag t_vertices("vertices");
MFloatPointArray vertices;
status = meshFn.getPoints(vertices);
assert(status == MStatus::kSuccess);
mout << " " << vertices.length() << " vertices" << endl;
for(unsigned a=0;a<vertices.length();a++) {
tag v("vertex");
v.addAttribute("x", vertices[a].x);
v.addAttribute("y", vertices[a].y);
v.addAttribute("z", vertices[a].z);
}
}
//////////////////////////////////
// output the polygons
{
tag t_polys("polygons");
mout << " " << meshFn.numPolygons() << " polygons" << endl;
MIntArray vertexList;
for(int p=0;p<meshFn.numPolygons();p++) {
tag t_poly("polygon");
status = meshFn.getPolygonVertices(p, vertexList);
assert(status == MStatus::kSuccess);
for(unsigned a=0;a<vertexList.length();a++) {
tag t_vert("vertex");
t_vert.addAttribute("id", vertexList[a]);
}
}
}
//////////////////////////////////
// the skinning info
// looking for input msh and its skinning cluster
MPlug sourceMesh = meshFn.findPlug("inMesh", &status);
assert(status == MStatus::kSuccess);
MObject skinObject;
for(MItDependencyGraph iter(sourceMesh, MFn::kSkinClusterFilter, MItDependencyGraph::kUpstream, MItDependencyGraph::kBreadthFirst); !iter.isDone(); iter.next())
skinObject = iter.currentItem();
MFnSkinCluster skinFn(skinObject, &status);
if(status != MStatus::kSuccess)
mout << " No skinning cluster found." << endl;
else {
mout << " Skinning: " << skinFn.name() << endl;
// influencing bones
MDagPathArray boneDagPaths;
const unsigned skinBoneCount = skinFn.influenceObjects(boneDagPaths, &status);
assert(status == MStatus::kSuccess);
{
tag t_skin("skinning");
mout << " " << skinBoneCount << " bones" << endl;
// iterate through the geometry and get the skinning weights
MDoubleArray weights;
unsigned boneCount;
unsigned maxNonzeroCount = 0;
unsigned singleWeightCount = 0;
unsigned almostSingleWeightCount = 0;
unsigned vertexCount = 0;
for(MItGeometry geomIter(mesh); !geomIter.isDone(); geomIter.next()) {
tag t_vertex("vertex");
// get the component (vertex)
MObject component = geomIter.component(&status);
assert(status == MStatus::kSuccess);
// get the weights
status = skinFn.getWeights(mesh, component, weights, boneCount);
assert(status == MStatus::kSuccess);
// count the non-zero ones
unsigned nonzeroCount = 0, almostNonzeroCount = 0;
for(unsigned a=0;a<weights.length();a++) {
if(weights[a] > 0.0) {
tag t_weight("weight");
nonzeroCount++;
t_weight.addAttribute("bone", a);
t_weight.addAttribute("weight", weights[a]);
}
if(weights[a] > 0.01)
almostNonzeroCount++;
}
if(maxNonzeroCount < nonzeroCount)
maxNonzeroCount = nonzeroCount;
if(nonzeroCount == 1)
singleWeightCount++;
if(almostNonzeroCount == 1)
almostSingleWeightCount++;
vertexCount++;
}
mout << " vertex count: " << vertexCount << endl;
mout << " single weighted: " << singleWeightCount << endl;
mout << " almost single weighted: " << almostSingleWeightCount << endl;
mout << " max weight count: " << maxNonzeroCount << endl;
}
//////////////////////////////////
// skeleton gets exported only if a skinning cluster was found
{
mout << " Skeleton: " << endl;
tag t_skel("skeleton");
// process all bones
mout << " " << boneDagPaths.length() << " bones" << endl;
for(unsigned b=0;b<boneDagPaths.length();b++) {
// get the bone node + name
MFnDagNode nodeFn(boneDagPaths[b], &status);
assert(status == MStatus::kSuccess);
mout << " bone " << b << ": " << nodeFn.name() << endl;
tag t_bone("bone");
t_bone.addAttribute("name", nodeFn.name().asChar());
// process the transformation object
MFnTransform transFn(boneDagPaths[b], &status);
assert(status == MStatus::kSuccess);
// construct the parent index
// - if no parent -> parent index = -1
// - if no parent found in the current set of bones -> set parent index to -1
// - if parent exists -> set the parentIndex to its index value
assert(transFn.parentCount() <= 1);
int parentIndex = -1;
if(transFn.parentCount() > 0) {
MObject par = transFn.parent(0, &status);
assert(status == MStatus::kSuccess);
MFnDagNode parentFn(par, &status);
assert(status == MStatus::kSuccess);
for(int a=0;a<(int)boneDagPaths.length();a++) {
MFnDagNode testFn(boneDagPaths[a], &status);
assert(status == MStatus::kSuccess);
if(testFn.name() == parentFn.name()) {
assert(parentIndex < 0);
parentIndex = a;
}
}
}
mout << " parent " << parentIndex << endl;
t_bone.addAttribute("parent", parentIndex);
// rotation
{
MQuaternion rot;
status = transFn.getRotation(rot);
assert(status == MStatus::kSuccess);
//mout << " rot " << rot.x << " " << rot.y << " " << rot.z << " " << rot.w << endl;
tag t_rot("rotation");
t_rot.addAttribute("x", rot.x);
t_rot.addAttribute("y", rot.y);
t_rot.addAttribute("z", rot.z);
t_rot.addAttribute("w", rot.w);
}
// translation
{
MVector tr = transFn.getTranslation(MSpace::kObject, &status);
assert(status == MStatus::kSuccess);
//mout << " tr " << tr.x << " " << tr.y << " " << tr.z << endl;
tag t_tr("translation");
t_tr.addAttribute("x", tr.x);
t_tr.addAttribute("y", tr.y);
t_tr.addAttribute("z", tr.z);
}
}
}
// put the mesh back to normal (assuming no animation was exported, which would do that somewhere above)
// according to http://nccastaff.bournemouth.ac.uk/jmacey/RobTheBloke/www/research/maya/mfnskinning.htm
// DOES IT WORK?!
status = MGlobal::executeCommand("doEnableNodeItems true all");
assert(status == MStatus::kSuccess);
//////////////////////////////////
// animation export
{
// put the model back to the animated state
bindingPose(false);
// get the number of frames
mout << " Animation - from " << MAnimControl::animationStartTime() << " to " << MAnimControl::animationEndTime() << endl;
tag t_anim("animation");
/*// save the frames
for(MTime t = MAnimControl::animationStartTime(); t <= MAnimControl::animationEndTime(); t++) {
MAnimControl::setCurrentTime(t);
tag t_frame("frame");
// go through all the bones
for(unsigned b=0;b<boneDagPaths.length();b++) {
tag t_bone("bone");
// process the transformation object
MFnTransform transFn(boneDagPaths[b], &status);
assert(status == MStatus::kSuccess);
// rotation
{
MQuaternion rot;
status = transFn.getRotation(rot);
assert(status == MStatus::kSuccess);
//mout << " rot " << rot.x << " " << rot.y << " " << rot.z << " " << rot.w << endl;
tag t_rot("rotation");
t_rot.addAttribute("x", rot.x);
t_rot.addAttribute("y", rot.y);
t_rot.addAttribute("z", rot.z);
t_rot.addAttribute("w", rot.w);
}
// translation
{
MVector tr = transFn.getTranslation(MSpace::kObject, &status);
assert(status == MStatus::kSuccess);
//mout << " tr " << tr.x << " " << tr.y << " " << tr.z << endl;
tag t_tr("translation");
t_tr.addAttribute("x", tr.x);
t_tr.addAttribute("y", tr.y);
t_tr.addAttribute("z", tr.z);
}
}
}
*/
// go through all the bones
for(unsigned b=0;b<boneDagPaths.length();b++) {
tag t_bone("bone");
for(MTime t = MAnimControl::animationStartTime(); t <= MAnimControl::animationEndTime(); t++) {
MAnimControl::setCurrentTime(t);
tag t_frame("frame");
// process the transformation object
MFnTransform transFn(boneDagPaths[b], &status);
assert(status == MStatus::kSuccess);
// rotation
{
MQuaternion rot;
status = transFn.getRotation(rot);
assert(status == MStatus::kSuccess);
//mout << " rot " << rot.x << " " << rot.y << " " << rot.z << " " << rot.w << endl;
tag t_rot("rotation");
t_rot.addAttribute("x", rot.x);
t_rot.addAttribute("y", rot.y);
t_rot.addAttribute("z", rot.z);
t_rot.addAttribute("w", rot.w);
}
// translation
{
MVector tr = transFn.getTranslation(MSpace::kObject, &status);
assert(status == MStatus::kSuccess);
//mout << " tr " << tr.x << " " << tr.y << " " << tr.z << endl;
tag t_tr("translation");
t_tr.addAttribute("x", tr.x);
t_tr.addAttribute("y", tr.y);
t_tr.addAttribute("z", tr.z);
}
}
}
}
}
}
}
}
bindingPose(false);
}
return MS::kSuccess;
}
MStatus initializePlugin( MObject obj )
{
MFnPlugin plugin( obj, "Martin Prazak", "1.0", "Any");
MStatus status = plugin.registerCommand( "meshExport", exporter::creator );
CHECK_MSTATUS_AND_RETURN_IT( status );
return status;
}
MStatus uninitializePlugin( MObject obj )
{
MFnPlugin plugin( obj );
MStatus status = plugin.deregisterCommand( "meshExport" );
CHECK_MSTATUS_AND_RETURN_IT( status );
return status;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.