blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 4 201 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 7 100 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 260
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 11.4k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 17
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 80
values | src_encoding stringclasses 28
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 8 9.86M | extension stringclasses 52
values | content stringlengths 8 9.86M | authors listlengths 1 1 | author stringlengths 0 119 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2cb759f6fc66097ed16d336a2c317332ef6b9b82 | f1ab5b96984e4fb4c0e596cedaa284d0f34f373c | /ACMICPC/SWtest/Problem/Simulation/2923.cpp | c4aa3c348032f9cbb83568d42a24a320ea63e279 | [] | no_license | korca0220/Algorithm_study | f551543a124cc8a8f7dbc25a60ce9f2f509d75f4 | 693a1a9c525836f3314b98ac3fb1f8597473c179 | refs/heads/master | 2020-05-18T22:50:02.130214 | 2019-10-12T10:17:22 | 2019-10-12T10:17:22 | 184,698,372 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,723 | cpp | #include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;
int n,m;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};
void bfs(int s, int e, vector<vector<bool>> &check, vector<string> in, vector<pair<int,int>> &group){
queue<pair<int,int>> q;
q.push(make_pair(s,e));
group.push_back(make_pair(s,e));
check[s][e] = true;
while(!q.empty()){
int x = q.front().first;
int y = q.front().second;
q.pop();
for(int i=0; i<4; i++){
int nx = x +dx[i];
int ny = y +dy[i];
if(0<=nx && nx<n && 0<=ny && ny<m){
if(check[nx][ny] == false && in[nx][ny] == 'x'){
q.push(make_pair(nx, ny));
group.push_back(make_pair(nx,ny));
check[nx][ny] = true;
}
}
}
}
}
void simulate(vector<string> &in){
vector<vector<bool>> check(n, vector<bool>(m, false));
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
if(in[i][j] == '.') continue;
if(check[i][j]) continue;
vector<pair<int,int>> group;
bfs(i,j, check, in, group);
vector<int> low(m, -1); // col-low-value
for(auto &p : group){
low[p.second] = max(low[p.second], p.first);
in[p.first][p.second] = '.';
}
int lowest = n;
for(int i,j=0; j<m; j++){
if(low[j] == -1) continue;
for(i=low[j]; i<n && in[i][j]=='.'; i++);
lowest = min(lowest, i-low[j]-1);
}
for(auto &p : group){
p.first += lowest;
in[p.first][p.second] = 'x';
check[p.first][p.second] = true;
}
}
}
}
int main(){
scanf("%d %d", &n, &m);
vector<string> in(n);
for(int i=0; i<n; i++){
cin >> in[i];
}
int shoot;
scanf("%d", &shoot);
for(int i=0; i<shoot; i++){
int height;
scanf("%d", &height);
height = n-height;
if(i%2 == 0){ //left-shoot
for(int j=0; j<m; j++){
if(in[height][j] == 'x'){
in[height][j] = '.';
break;
}
}
}else{ // right-shoot
for(int j=m-1; j>=0; j--){
if(in[height][j] == 'x'){
in[height][j] = '.';
break;
}
}
}
simulate(in);
}
for(int i=0; i<n; i++){
cout << in[i] << "\n";
}
return 0;
} | [
"korca02220@naver.com"
] | korca02220@naver.com |
df26007bd1abf714e1ce4ff18bbb65ddb77d58d4 | e3aefe4afb1a8ea04777202eb5a7792d8da8f844 | /samples/vst-hosting/editorhost/source/editorhost.cpp | 8e627c96bc732c493629c2dd3aed4ff098a342e3 | [] | no_license | eriser/vst3_public_sdk | 570101bf99000bf3fdc6d5712770edbe2ddebc1a | abcdb402a2f09b88d432a392301a5a3c7a72d6de | refs/heads/master | 2021-08-14T10:09:48.094691 | 2017-11-15T10:39:13 | 2017-11-15T10:39:13 | 110,819,785 | 1 | 0 | null | 2017-11-15T10:33:25 | 2017-11-15T10:33:25 | null | UTF-8 | C++ | false | false | 12,092 | cpp | //-----------------------------------------------------------------------------
// Flags : clang-format auto
// Project : VST SDK
//
// Category : EditorHost
// Filename : public.sdk/samples/vst-hosting/editorhost/source/editorhost.cpp
// Created by : Steinberg 09.2016
// Description : Example of opening a plug-in editor
//
//-----------------------------------------------------------------------------
// LICENSE
// (c) 2017, Steinberg Media Technologies GmbH, All Rights Reserved
//-----------------------------------------------------------------------------
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the Steinberg Media Technologies nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE.
//-----------------------------------------------------------------------------
#include "public.sdk/samples/vst-hosting/editorhost/source/editorhost.h"
#include "public.sdk/samples/vst-hosting/editorhost/source/platform/appinit.h"
#include "public.sdk/source/vst/hosting/hostclasses.h"
#include "base/source/fcommandline.h"
#include "pluginterfaces/base/funknown.h"
#include "pluginterfaces/gui/iplugview.h"
#include "pluginterfaces/gui/iplugviewcontentscalesupport.h"
#include "pluginterfaces/vst/ivstaudioprocessor.h"
#include "pluginterfaces/vst/ivsteditcontroller.h"
#include "pluginterfaces/vst/vsttypes.h"
#include <cstdio>
#include <iostream>
//------------------------------------------------------------------------
namespace Steinberg {
FUnknown* gStandardPluginContext = new Vst::HostApplication ();
//------------------------------------------------------------------------
inline bool operator== (const ViewRect& r1, const ViewRect& r2)
{
return memcmp (&r1, &r2, sizeof (ViewRect)) == 0;
}
//------------------------------------------------------------------------
inline bool operator!= (const ViewRect& r1, const ViewRect& r2)
{
return !(r1 == r2);
}
namespace Vst {
namespace EditorHost {
static AppInit gInit (std::make_unique<App> ());
//------------------------------------------------------------------------
class WindowController : public IWindowController, public IPlugFrame
{
public:
WindowController (const IPtr<IPlugView>& plugView);
~WindowController () noexcept override;
void onShow (IWindow& w) override;
void onClose (IWindow& w) override;
void onResize (IWindow& w, Size newSize) override;
Size constrainSize (IWindow& w, Size requestedSize) override;
void onContentScaleFactorChanged (IWindow& window, float newScaleFactor) override;
// IPlugFrame
tresult PLUGIN_API resizeView (IPlugView* view, ViewRect* newSize) override;
private:
tresult PLUGIN_API queryInterface (const TUID _iid, void** obj) override
{
if (FUnknownPrivate::iidEqual (_iid, IPlugFrame::iid) ||
FUnknownPrivate::iidEqual (_iid, FUnknown::iid))
{
*obj = this;
addRef ();
return kResultTrue;
}
if (window)
return window->queryInterface (_iid, obj);
return kNoInterface;
}
uint32 PLUGIN_API addRef () override { return 1000; }
uint32 PLUGIN_API release () override { return 1000; }
IPtr<IPlugView> plugView;
IWindow* window {nullptr};
bool resizeViewRecursionGard {false};
};
//------------------------------------------------------------------------
class ComponentHandler : public IComponentHandler
{
public:
tresult PLUGIN_API beginEdit (ParamID /*id*/) override { return kNotImplemented; }
tresult PLUGIN_API performEdit (ParamID /*id*/, ParamValue /*valueNormalized*/) override
{
return kNotImplemented;
}
tresult PLUGIN_API endEdit (ParamID /*id*/) override { return kNotImplemented; }
tresult PLUGIN_API restartComponent (int32 /*flags*/) override { return kNotImplemented; }
private:
tresult PLUGIN_API queryInterface (const TUID /*_iid*/, void** /*obj*/) override
{
return kNoInterface;
}
uint32 PLUGIN_API addRef () override { return 1000; }
uint32 PLUGIN_API release () override { return 1000; }
};
static ComponentHandler gComponentHandler;
//------------------------------------------------------------------------
App::~App () noexcept
{
}
//------------------------------------------------------------------------
void App::openEditor (const std::string& path, VST3::Optional<VST3::UID> effectID, uint32 flags)
{
std::string error;
module = VST3::Hosting::Module::create (path, error);
if (!module)
{
std::string reason = "Could not create Module for file:";
reason += path;
reason += "\nError: ";
reason += error;
IPlatform::instance ().kill (-1, reason);
}
auto factory = module->getFactory ();
for (auto& classInfo : factory.classInfos ())
{
if (classInfo.category () == kVstAudioEffectClass)
{
if (effectID)
{
if (*effectID != classInfo.ID ())
continue;
}
plugProvider = owned (new PlugProvider (factory, classInfo, true));
break;
}
}
if (!plugProvider)
{
if (effectID)
error =
"No VST3 Audio Module Class with UID " + effectID->toString () + " found in file ";
else
error = "No VST3 Audio Module Class found in file ";
error += path;
IPlatform::instance ().kill (-1, error);
}
auto editController = plugProvider->getController ();
if (!editController)
{
error = "No EditController found (needed for allowing editor) in file " + path;
IPlatform::instance ().kill (-1, error);
}
editController->release (); // plugProvider does an addRef
if (flags & kSetComponentHandler)
editController->setComponentHandler (&gComponentHandler);
createViewAndShow (editController);
if (flags & kSecondWindow)
createViewAndShow (editController);
}
//------------------------------------------------------------------------
void App::createViewAndShow (IEditController* controller)
{
auto view = owned (controller->createView (ViewType::kEditor));
if (!view)
{
IPlatform::instance ().kill (-1, "EditController does not provide its own editor");
}
ViewRect plugViewSize {};
auto result = view->getSize (&plugViewSize);
if (result != kResultTrue)
{
IPlatform::instance ().kill (-1, "Could not get editor view size");
}
auto viewRect = ViewRectToRect (plugViewSize);
auto window = IPlatform::instance ().createWindow ("Editor", viewRect.size,
view->canResize () == kResultTrue,
std::make_shared<WindowController> (view));
if (!window)
{
IPlatform::instance ().kill (-1, "Could not create window");
}
window->show ();
}
//------------------------------------------------------------------------
void App::init (const std::vector<std::string>& cmdArgs)
{
if (cmdArgs.empty ())
{
auto helpText = R"(
usage: EditorHost [options] pluginPath
options:
--componentHandler
set optional component handler on edit controller
--secondWindow
create a second window
--uid UID
use effect class with unique class ID==UID
)";
IPlatform::instance ().kill (0, helpText);
}
VST3::Optional<VST3::UID> uid;
uint32 flags {};
for (auto it = cmdArgs.begin (), end = cmdArgs.end (); it != end; ++it)
{
if (*it == "--componentHandler")
flags |= kSetComponentHandler;
else if (*it == "--secondWindow")
flags |= kSecondWindow;
else if (*it == "--uid")
{
if (++it != end)
uid = VST3::UID::fromString (*it);
if (!uid)
IPlatform::instance ().kill (-1, "wrong argument to --uid");
}
}
openEditor (cmdArgs.back (), std::move (uid), flags);
}
//------------------------------------------------------------------------
WindowController::WindowController (const IPtr<IPlugView>& plugView) : plugView (plugView)
{
}
//------------------------------------------------------------------------
WindowController::~WindowController () noexcept
{
}
//------------------------------------------------------------------------
void WindowController::onShow (IWindow& w)
{
window = &w;
if (!plugView)
return;
auto platformWindow = window->getNativePlatformWindow ();
if (plugView->isPlatformTypeSupported (platformWindow.type) != kResultTrue)
{
IPlatform::instance ().kill (-1, std::string ("PlugView does not support platform type:") +
platformWindow.type);
}
plugView->setFrame (this);
if (plugView->attached (platformWindow.ptr, platformWindow.type) != kResultTrue)
{
IPlatform::instance ().kill (-1, "Attaching PlugView failed");
}
}
//------------------------------------------------------------------------
void WindowController::onClose (IWindow& /*w*/)
{
if (plugView)
{
plugView->setFrame (nullptr);
if (plugView->removed () != kResultTrue)
{
IPlatform::instance ().kill (-1, "Removing PlugView failed");
}
}
window = nullptr;
// TODO maybe quit only when the last window is closed
IPlatform::instance ().quit ();
}
//------------------------------------------------------------------------
void WindowController::onResize (IWindow& /*w*/, Size newSize)
{
if (plugView)
{
ViewRect r {};
r.right = newSize.width;
r.bottom = newSize.height;
ViewRect r2 {};
if (plugView->getSize (&r2) == kResultTrue && r != r2)
plugView->onSize (&r);
}
}
//------------------------------------------------------------------------
Size WindowController::constrainSize (IWindow& /*w*/, Size requestedSize)
{
ViewRect r {};
r.right = requestedSize.width;
r.bottom = requestedSize.height;
if (plugView && plugView->checkSizeConstraint (&r) != kResultTrue)
{
plugView->getSize (&r);
}
requestedSize.width = r.right - r.left;
requestedSize.height = r.bottom - r.top;
return requestedSize;
}
//------------------------------------------------------------------------
void WindowController::onContentScaleFactorChanged (IWindow& /*window*/, float newScaleFactor)
{
FUnknownPtr<IPlugViewContentScaleSupport> css (plugView);
if (css)
{
css->setContentScaleFactor (newScaleFactor);
}
}
//------------------------------------------------------------------------
tresult PLUGIN_API WindowController::resizeView (IPlugView* view, ViewRect* newSize)
{
if (newSize == nullptr || view == nullptr || view != plugView)
return kInvalidArgument;
if (!window)
return kInternalError;
if (resizeViewRecursionGard)
return kResultFalse;
ViewRect r;
if (plugView->getSize (&r) != kResultTrue)
return kInternalError;
if (r == *newSize)
return kResultTrue;
resizeViewRecursionGard = true;
Size size {newSize->right - newSize->left, newSize->bottom - newSize->top};
window->resize (size);
resizeViewRecursionGard = false;
if (plugView->getSize (&r) != kResultTrue)
return kInternalError;
if (r != *newSize)
plugView->onSize (newSize);
return kResultTrue;
}
//------------------------------------------------------------------------
} // EditorHost
} // Vst
} // Steinberg
| [
"scheffle@users.noreply.github.com"
] | scheffle@users.noreply.github.com |
5388205de15f2f048e3b468342ea1f9f465fd2a1 | d1ac37919f48155fc2a2a57b5a7a95f25bad7ef9 | /Longest Prefix_DP.cpp | 17debcadd7e26c43f23f0be74eb9e8d3bae18bcd | [] | no_license | zhudzh/USACO | 708088305e66be1c6e5ac4b8a205323ca2a33e7c | 8c40e60d3af22dee57993bc90966a956eaabcced | refs/heads/master | 2020-07-09T07:41:10.128455 | 2013-10-10T14:35:37 | 2013-10-10T14:35:37 | 13,121,775 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,789 | cpp | /*
ID: zdzapple
LANG: C++
TASK: prefix
*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <climits>
#include <fstream>
#include <math.h>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
using namespace std;
const string input_file = "prefix.in";
const string out_file = "prefix.out";
ifstream fin;
ofstream fout;
void openfile() { fin.open(input_file.c_str()); fout.open(out_file.c_str()); }
void closefile() { fin.close(), fout.close(); }
const int maxp = 200;
const int maxl = 10;
char prim[maxp + 1][maxl + 1];
int nump = 0;
int dp[2000001];
char data[2000001];
int ndata;
void solve()
{
int best, i, j, k;
while (true)
{
fin >> prim[nump];
if (prim[nump][0] != '.')
nump ++;
else
break;
}
ndata = 0;
string s;
while (getline(fin, s))
{
for (i = 0; i < s.size(); ++ i)
data[ndata ++] = s[i];
}
dp[0] = 1;
best = 0;
for (i = 0; i < ndata; ++ i)
{
if (dp[i]) {
best = i;
for (j = 0; j < nump; ++ j)
{
for (k = 0; i + k < ndata && prim[j][k] &&
prim[j][k] == data[i + k]; k ++)
;
if (!prim[j][k])
dp[i + k] = 1;
}
}
}
if (dp[ndata]) best = ndata;
fout << best << endl;
/*
ndata = 0;
while (fscanf (fin, "%s", data+ndata) == 1)
ndata += strlen(data+ndata);
*/
}
int main()
{
openfile();
solve();
closefile();
return 0;
}
| [
"zhudz1989@gmail.com"
] | zhudz1989@gmail.com |
0cf8351e58d675219d22198ebf297b168118c2cc | 2c483ca866b36e658f128866f7e11f4c48863c10 | /Kursovaya2015/Matr.h | fe5364a2b13f173bf93bcc02fcd5e7c59f34afb6 | [] | no_license | sealkeen/Coursework-Dynamic-Arrays-2015 | c3f59e6ad0beb5eaad6d49b304146275f8873a7f | 6de00f66eb5ac99dbfb962946dfe4dc1a25b92c3 | refs/heads/master | 2020-06-10T05:51:36.527316 | 2016-12-10T20:13:22 | 2016-12-10T20:13:22 | null | 0 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 1,498 | h | #include "stdafx.h"
#include "iostream"
using namespace std;
//Определяем тип данных "матрица целых чисел"
typedef int singleElem; //определение типа элементов массива
typedef singleElem *pStringOfElements; //определение типа "указатель на singleElem"
typedef pStringOfElements *pSourceMatr; //определение типа "указатель на указатель на singleElem"
//Определяем дополнительную булевую матрицу, которая служит для определения
//того, какие элементы надо занулить (которые программа не должна сортировать)
typedef bool boolVal; //определение типа элементов массива
typedef boolVal *pBoolStr; //определение типа "указатель на boolVal"
typedef pBoolStr *pBoolMatr; //определение типа "указатель на указатель на boolVal"
class Matr
{
public :
Matr::Matr(int strings, int rows);
Matr::~Matr();
void Matr::InitializeSource();
void Matr::InitializeBool();
void Matr::HandInput();
void Matr::SortVstavka();
void Matr::OutputSourceMatr();
void Matr::OutputBoolMatr();
void Matr::ZanulenieElementov();
private :
int str;
int sto;
pBoolMatr boolMatr;
pSourceMatr srcMatr;
bool allocated;
};
| [
"lettersforlotro@gmail.com"
] | lettersforlotro@gmail.com |
40575e234f3ff893cc6fcbf5a0a635f91533779c | cefd6c17774b5c94240d57adccef57d9bba4a2e9 | /WebKit/Source/WebKit2/UIProcess/API/C/WKMediaCacheManager.cpp | 874ac18ed490fe8beeab0692b9c82f1bae863c9e | [
"BSL-1.0"
] | permissive | adzhou/oragle | 9c054c25b24ff0a65cb9639bafd02aac2bcdce8b | 5442d418b87d0da161429ffa5cb83777e9b38e4d | refs/heads/master | 2022-11-01T05:04:59.368831 | 2014-03-12T15:50:08 | 2014-03-12T15:50:08 | 17,238,063 | 0 | 1 | BSL-1.0 | 2022-10-18T04:23:53 | 2014-02-27T05:39:44 | C++ | UTF-8 | C++ | false | false | 2,302 | cpp | /*
* Copyright (C) 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "WKMediaCacheManager.h"
#include "WKAPICast.h"
#include "WebMediaCacheManagerProxy.h"
using namespace WebKit;
typedef GenericAPICallback<WKArrayRef> ArrayAPICallback;
WKTypeID WKMediaCacheManagerGetTypeID()
{
return toAPI(WebMediaCacheManagerProxy::APIType);
}
void WKMediaCacheManagerGetHostnamesWithMediaCache(WKMediaCacheManagerRef mediaCacheManagerRef, void* context, WKMediaCacheManagerGetHostnamesWithMediaCacheFunction callback)
{
toImpl(mediaCacheManagerRef)->getHostnamesWithMediaCache(ArrayAPICallback::create(context, callback));
}
void WKMediaCacheManagerClearCacheForHostname(WKMediaCacheManagerRef mediaCacheManagerRef, WKStringRef hostname)
{
toImpl(mediaCacheManagerRef)->clearCacheForHostname(toWTFString(hostname));
}
void WKMediaCacheManagerClearCacheForAllHostnames(WKMediaCacheManagerRef mediaCacheManagerRef)
{
toImpl(mediaCacheManagerRef)->clearCacheForAllHostnames();
}
| [
"adzhou@hp.com"
] | adzhou@hp.com |
c02bb4ee14cba17b29f7f2d1a140aed37a747df3 | 9a4e686997d785add1c34f41e0c19ec091df3d8c | /baekjoon/10757.cpp | f4074a30299383edd0e6230ec65b1e656d57e7c3 | [] | no_license | youngyol/Problem-Solving | 25559ce23d367c2260ca52adfb28fcb3af2411f6 | ce129747b7df8b5c836bbc91ee89b9de01c80307 | refs/heads/master | 2021-06-23T16:23:02.335249 | 2019-08-06T14:32:22 | 2019-08-06T14:32:22 | 92,601,368 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,107 | cpp | // https://www.acmicpc.net/problem/10757
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main() {
string str1, str2;
cin >> str1 >> str2;
int str1Size = str1.size(), str2Size = str2.size();
int carry = 0, leftStart = 0, rightStart = 0;
vector <char> answer;
reverse(str1.begin(), str1.end());
reverse(str2.begin(), str2.end());
while (leftStart < str1Size && rightStart < str2Size) {
int tmp = str1[leftStart++] - '0' + str2[rightStart++] - '0' + carry;
carry = tmp / 10;
tmp %= 10;
answer.push_back(tmp + '0');
}
if (str1Size < str2Size) {
for (int i = rightStart; i < str2Size; i++) {
int tmp = str2[i] - '0' + carry;
carry = tmp / 10;
tmp %= 10;
answer.push_back(tmp + '0');
}
}
else {
for (int j = leftStart; j < str1Size; j++) {
int tmp = str1[j] - '0' + carry;
carry = tmp / 10;
tmp %= 10;
answer.push_back(tmp + '0');
}
}
if (carry != 0) answer.push_back(carry + '0');
reverse(answer.begin(), answer.end());
for (char number : answer) {
printf("%c", number);
}
}
| [
"noreply@github.com"
] | noreply@github.com |
10fdf61381325c36782105dfbb46c04d9e6931f0 | cd7dd3ef4e6860b5eb89a8d5248a951133c683d0 | /baseandderived.cpp | 468324d8384c96800a1c2a8552b464c6c97716f6 | [] | no_license | xfanas/Linuxcpp | 131d942bf16c741cf3c5bcda25a718eee41b759c | 3f5a34e66167efe29db38066568de44fc1086d7f | refs/heads/master | 2020-12-03T00:15:43.285983 | 2017-07-02T06:00:30 | 2017-07-02T06:00:30 | 96,005,609 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 977 | cpp | #include <iostream>
#include <string>
using namespace std;
class Base
{
public:
Base(string s) : str_a(s) { }
Base(const Base & that) { str_a = that.str_a; }
void Print() const { cout << "In base: " << str_a << endl; }
protected:
string str_a;
};
class Derived : public Base
{
public:
Derived(string s1,string s2) : Base(s1), str_b(s2) { } // 调用基类构造函数初始化
void Print() const { cout << "In derived: " << str_a + " " + str_b << endl; }
protected:
string str_b;
};
int main()
{
Derived d1( "Hello", "World" );
Base b1( d1 ); // 拷贝构造,派生类至基类,仅复制基类部分
d1.Print(); // Hello World
b1.Print(); // Hello
Base & b2 = d1; // 引用,不调用拷贝构造函数,仅访问基类部分
d1.Print();
b2.Print();
Base * b3 = &d1; // 指针,不调用拷贝构造函数,仅引领基类部分
d1.Print();
b3->Print();
return 1;
}
| [
"root@DESKTOP-LM715O9.localdomain"
] | root@DESKTOP-LM715O9.localdomain |
6daa6b751f5de73b1db79ba4256669382fede3ae | 656d379531512f8f9f94d4de9c35f629084d50a9 | /resume/code_samples/cpp/2015_nita/TimeDomainMetric.h | b2b364c00def5ec449d3dc9cac1ab6bd5e85e4b5 | [] | no_license | rizzinek/personal | da89b7a3178f3f5009b4138c47d0065ff8e5ff90 | 1e15a369930168ab23e0d11b449b0d2a45fcef54 | refs/heads/master | 2020-12-24T08:42:08.856831 | 2018-03-19T14:26:11 | 2018-03-19T14:26:11 | 41,530,123 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,160 | h | #ifndef TIMEDOMAINMETRIC_H
#define TIMEDOMAINMETRIC_H
#include <vector>
/**
* @brief The CTimeDomainMetric class
* base class for voice detection metrics in time domain
*/
class CTimeDomainMetric
{
private:
///only after this number of consecutive blocks are
///considered noise does the metric finally consider
///a block noise
unsigned m_uNoiseDetectionDelay;
///threshold value for the metric
///isSpeech == metric value < threshold
double m_dblThreshold;
///counter for the noise detection delay
unsigned m_uNoiseBlocksCounter;
public:
CTimeDomainMetric(unsigned uNoiseDetectionDelay, double dblThreshold);
//calculates the metric, checks the noise detection delay and
//using these two parameters, makes a decision on whether the block
//is speech or not
bool operator()(const std::vector<double>& vecData);
public:
//internal function for metric calculation
virtual double CalculateMetric(const std::vector<double>& vecData) = 0;
private:
//resets the noise block counter each time a speech block is detected
void ResetNoiseBlockCounter();
};
#endif // TIMEDOMAINMETRIC_H
| [
"the.rizzin@gmail.com"
] | the.rizzin@gmail.com |
df8082f53bdfab0ba88c88345e9ece3b3d0df2d8 | 82c24dac3a655c9621e583722e8912058d7c4cce | /documents/thesis/FINAL_CD/Software/sjSkeletonizer/source/source/core/sjKernelPlugin.h | 600d95b9e5f7b126a497b4396524e0e65342dfa7 | [] | no_license | apinzonf/jeronimo | d79d9bd58c793c1098e50016502b5873e742708a | 3ac0eba69cc94cc8de551d93eeec7a84cc7e2ac1 | refs/heads/master | 2020-05-18T17:18:40.791733 | 2015-11-11T20:30:40 | 2015-11-11T20:30:40 | 37,734,598 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,437 | h | #if defined (WIN32) || defined (_WIN32_)
#pragma once
#endif
#ifndef __SJKERNELPLUGIN__H__
#define __SJKERNELPLUGIN__H__
#include <map>
#include "sjPlugin.h"
#include "sjSystem.h"
#include "sjObserver.h"
namespace sj{
class sjKernelPlugin: public sjSubject{
public:
static const std::string SYS_COMPUTE_WEIGHT_SYSTEM;
static const std::string SYS_COMPUTE_LINE_EQUATIONS_SYSTEM;
static const std::string SYS_COMPUTE_RINGS_SYSTEM;
static const std::string SYS_INIT_LAPLACIAN_SMOOTHING_SYSTEM;
static const std::string SYS_INIT_INDEX_SYSTEM ;
static const std::string SYS_IS_DEGENERATE_VERTEX_SYSTEM;
static const std::string SYS_ITERATE_SMOOTHING_ALGORITHM_SYSTEM;
private:
static sjKernelPlugin _instance;
sjKernelPlugin (void);
sjKernelPlugin (const sjKernelPlugin &);
sjKernelPlugin & operator=(const sjKernelPlugin &);
~sjKernelPlugin (void);
typedef std::map<std::string, sjPlugin * > TypeMapPlugin;
typedef std::map<std::string, sjSystem * > TypeMapsjSystem;
TypeMapPlugin m_plugins;
TypeMapsjSystem m_systems;
public:
static sjKernelPlugin &getInstance(void){
return _instance;
}
bool addPlugin(sjPlugin *);
bool setDefaultSystem(std::string plugin_name);
bool setDefaultSystem(sjPlugin * m_plugin);
bool existSystem(std::string system_name);
sjPlugin * getPlugin(std::string key);
sjSystem * getSystem(std::string system_name);
};
}
#endif //__SJKERNELPLUGIN__H__ | [
"apinozonf@gmail.com"
] | apinozonf@gmail.com |
2b71f59fbe4590b6fb71669d1282cb6af7f99f68 | 693f6694c179ea26c34f4cfd366bcf875edd5511 | /lksh/lksh2015/lksh2015ch/day8/A.cpp | 6779304a5a046d74d25bd3c5a94dee5ad462904a | [] | no_license | romanasa/olymp_codes | db4a2a6af72c5cc1f2e6340f485e5d96d8f0b218 | 52dc950496ab28c4003bf8c96cbcdb0350f0646a | refs/heads/master | 2020-05-07T18:54:47.966848 | 2019-05-22T19:41:38 | 2019-05-22T19:41:38 | 180,765,711 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,534 | cpp | #define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:66777216")
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <ctime>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <deque>
#include <cassert>
#include <cstdlib>
#include <bitset>
#include <algorithm>
#include <string>
#include <list>
#include <fstream>
#include <cstring>
#include <sstream>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define fornn(i, q, n) for (int i = q; i < (ll)n; i++)
#define mp make_pair
#define pk push_back
#define all(v) v.begin(), v.end()
#define times clock() * 1.0 / CLOCKS_PER_SEC
#define prev pprev
#define TASK "sum2"
const double eps = 1e-7;
const double pi = acos(-1.0);
const ll INF = (ll)2e9 + 1;
const ll LINF = (ll)8e18;
const ll inf = (ll)2e9 + 1;
const ll linf = (ll)8e18;
const ll MM = (ll)1e9 + 7;
int solve();
void gen();
int main()
{
#ifdef _DEBUG
freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#else
//freopen(TASK".in", "r", stdin), freopen(TASK".out", "w", stdout);
//freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout), freopen("test.txt", "w", stderr);
#endif
solve();
return 0;
}
ll f[107];
int solve() {
ll n;
cin >> n;
if (n <= 2)
cout << 1;
else if (n <= 4)
cout << n;
else {
f[0] = 1, f[1] = 1;
fornn(i, 2, n + 1)
f[i] = f[i - 1] + f[i - 2];
cout << f[n] - 2;
}
return 0;
} | [
"romanfml31@gmail.com"
] | romanfml31@gmail.com |
97de834132fe467aab3d4b556ba544e16097bcd7 | 3d7ae2a9b0347f420763ba9af7867cb4b0fc740e | /vote.cpp | 73605dafa51739ba49664f4496e51b6f54631648 | [] | no_license | khushi9250/c--practice-programs | c9c24f5c23941d1c4f35b7cd7a8c1ef2e5b1c990 | cac7e55e38dd9c0d2ec8861caef11f3366ea7b14 | refs/heads/master | 2022-12-21T21:50:01.454803 | 2020-09-27T16:09:01 | 2020-09-27T16:09:01 | 295,933,962 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 334 | cpp | #include<iostream>
using namespace std;
int main()
{
int age;
cout<<"enter the age of person: " ;
cin>>age;
if(age>=18)
{
cout<<"You are eligible to vote ";
}
else
{
cout<< "Sorry, You are not eligible to caste your vote.\n";
cout<< "You would be able to caste your vote after " <<18-age <<" year";
}
}
| [
"noreply@github.com"
] | noreply@github.com |
0cb8ed10f498f066c265b617347eaa3a75c9d0f5 | dbbc5c444959d656775061878e195ec59b04a1d5 | /final-exam-unit-test-master/Allocators.cpp | 880e66c2995d8e42706fc9b755d80519bd8c47a7 | [] | no_license | RajeshChilagani/MemoryManager | 062754e8ed9613cc5b091dbfa7965bd2b57b06ec | 5b7462324ea6fcc0eb108181d422d1afb7002584 | refs/heads/master | 2020-09-03T08:26:11.290540 | 2020-01-01T23:22:09 | 2020-01-01T23:22:09 | 219,425,735 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 441 | cpp | #include "MemorySystem.h"
#include <inttypes.h>
#include <stdio.h>
void * __cdecl malloc(size_t i_size)
{
// replace with calls to your HeapManager or FixedSizeAllocators
printf("malloc %zu\n", i_size);
return AllocateMemory(i_size);
}
void __cdecl free(void * i_ptr)
{
// replace with calls to your HeapManager or FixedSizeAllocators
printf("free 0x%" PRIXPTR "\n", reinterpret_cast<uintptr_t>(i_ptr));
return FreeMemory(i_ptr);
} | [
"chilaganirajesh95@gmail.com"
] | chilaganirajesh95@gmail.com |
331dc0e32a793069d35f9b817f6f186669a2ba10 | b0674e882ac6edbc45c1f4c5cfff591d7a7434cd | /cpp_solutions/ninechapter/Binary_Tree_Flipping.cpp | 1fd7d227896cdd94088beaf87a0123ad048a5101 | [] | no_license | SamuelXing/Algorithm | fdcc7397dac2b2fb141300b74272fddf20ccf20d | 03901d805336fb0cafd59ea54ccaa33b76c46d3c | refs/heads/master | 2021-06-05T01:46:12.060692 | 2020-01-10T05:00:38 | 2020-01-10T05:00:38 | 93,777,278 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,183 | cpp | /*
Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same parent node) or empty,
flip it upside down and turn it into a tree where the original right nodes turned into left leaf nodes. Return the new root.
Example
Given a binary tree {1,2,3,4,5}
1
/ \
2 3
/ \
4 5
return the root of the binary tree {4,5,2,#,#,3,1}.
4
/ \
5 2
/ \
3 1
*/
/**
* Definition of TreeNode:
* class TreeNode {
* public:
* int val;
* TreeNode *left, *right;
* TreeNode(int val) {
* this->val = val;
* this->left = this->right = NULL;
* }
* }
*/
class Solution {
public:
void DFS(TreeNode* node){
if(!node->left){
newroot = node;
return;
}
DFS(node->left);
node->left->left = node->right;
node->left->right = node;
node->left = NULL;
node->right = NULL;
}
/*
* @param root: the root of binary tree
* @return: new root
*/
TreeNode * upsideDownBinaryTree(TreeNode * root) {
// write your code here
if(!root) return NULL;
DFS(root);
return newroot;
}
private:
TreeNode* newroot;
};
| [
"sam1796896099@163.com"
] | sam1796896099@163.com |
e0a3e8de76e073f3cb1c2ab5326720c6c78d3df0 | e103d5bb7fc178e86213abec37884ece87f8109c | /ece244lab4/ResistorList.h | 40da253d11a70ec0715276d22ab621fce8f115e7 | [] | no_license | Deep321/Circuits-Node-Network-Solver | 4952d2b8d464df97149753570ce83f3d3a13a0b5 | 2a9e95f24d462ba0a8c8d418c1941c891d2f64d0 | refs/heads/master | 2016-09-06T18:30:18.688534 | 2014-11-18T14:15:25 | 2014-11-18T14:15:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 471 | h |
#ifndef RESISTORLIST_H_
#define RESISTORLIST_H_
#include "Resistor.h"
using namespace std;
class ResistorList {
private:
Resistor* resHead;
int numRes;
public:
void insertRes (string name, double resistance, int endpoints[2]);
bool removeRes (string name);
bool removeAll();
Resistor *findRes (string name);
void print(int nodeKey);
int getNumRes();
Resistor* getresHead();
ResistorList();
~ResistorList();
};
#endif /* RESISTORLIST_H_ */
| [
"Deeptanshu.Prasad@gmail.com"
] | Deeptanshu.Prasad@gmail.com |
1d1c620e609ae9890a38abbb1683c7ce10970fbf | a288af2733d03506e9ec81253495a55a7b2d6863 | /cocos/scripting/lua-bindings/manual/CCLuaStack.h | b32ccb00dd4428c17751a3e8bbd946057053f4c9 | [] | no_license | katichar/Quick-V3.8 | 8601d9786e13ca68fb2b8e8dff278dc45b6c94c9 | 238368601a74e431648f06886a4af85d66a04e64 | refs/heads/master | 2021-01-23T08:49:02.179403 | 2017-09-14T06:53:57 | 2017-09-14T06:53:57 | 102,553,142 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,240 | h | /****************************************************************************
Copyright (c) 2011-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CC_LUA_STACK_H_
#define __CC_LUA_STACK_H_
extern "C" {
#include "lua.h"
}
#include "cocos2d.h"
#include "CCLuaValue.h"
/**
* @addtogroup lua
* @{
*/
NS_CC_BEGIN
/**
* LuaStack is used to manager the operation on the lua_State,eg., push data onto the lua_State, execute the function depended on the lua_State.
* In the current mechanism, there is only one lua_State in one LuaStack object.
*
* @lua NA
* @js NA
*/
class LuaStack : public Ref
{
public:
/**
* Create a LuaStack object, it will new a lua_State.
*/
static LuaStack *create(void);
/**
* Create a LuaStack object with the existed lua_State.
*/
static LuaStack *attach(lua_State *L);
/** Destructor. */
virtual ~LuaStack();
/**
* Method used to get a pointer to the lua_State that the script module is attached to.
*
* @return A pointer to the lua_State that the script module is attached to.
*/
lua_State* getLuaState(void) {
return _state;
}
/**
* Add a path to find lua files in.
*
* @param path to be added to the Lua search path.
*/
virtual void addSearchPath(const char* path);
/**
* Add lua loader.
*
* @param func a function pointer point to the loader function.
*/
virtual void addLuaLoader(lua_CFunction func);
/**
* Reload script code corresponding to moduleFileName.
* If value of package["loaded"][moduleFileName] is existed, it would set the vaule nil.Then,it calls executeString function.
*
* @param moduleFileName String object holding the filename of the script file that is to be executed.
* @return 0 if the string is excuted correctly or other if the string is excuted wrongly.
*/
virtual int reload(const char* moduleFileName);
/**
* Remove the related reference about the Ref object stored in the Lua table by set the value of corresponding key nil:
* The related Lua tables are toluafix_refid_ptr_mapping,toluafix_refid_type_mapping,tolua_value_root and object_Metatable["tolua_ubox"] or tolua_ubox.
* Meanwhile set the corresponding userdata nullptr and remove the all the lua function refrence corresponding to this object.
*
* In current mechanism, this function is called in the destructor of Ref object, developer don't call this functions.
*
* @param object the key object to remove script object.
*/
virtual void removeScriptObjectByObject(Ref* object);
/**
* Remove Lua function reference by nHandler by setting toluafix_refid_function_mapping[nHandle] nil.
*
* @param nHandler the function refrence index to find the correspoinding Lua function pointer.
*/
virtual void removeScriptHandler(int nHandler);
/**
* Reallocate Lua function reference index to the Lua function pointer to add refrence.
*
* @param nHandler the function refrence index to find the correspoinding Lua function pointer.
*/
virtual int reallocateScriptHandler(int nHandler);
/**
* Execute script code contained in the given string.
*
* @param codes holding the valid script code that should be executed.
* @return 0 if the string is excuted correctly,other if the string is excuted wrongly.
*/
virtual int executeString(const char* codes);
/**
* Execute a script file.
*
* @param filename String object holding the filename of the script file that is to be executed.
* @return the return values by calling executeFunction.
*/
virtual int executeScriptFile(const char* filename);
/**
* Execute a scripted global function.
* The function should not take any parameters and should return an integer.
*
* @param functionName String object holding the name of the function, in the global script environment, that is to be executed.
* @return The integer value returned from the script function.
*/
virtual int executeGlobalFunction(const char* functionName);
/**
* Set the stack top index 0.
*/
virtual void clean(void);
/**
* Pushes a integer number with value intVaule onto the stack.
*
* @param intValue a integer number.
*/
virtual void pushInt(int intValue);
/**
* Pushes a float number with value floatValue onto the stack.
*
* @param floatValue a float number.
*/
virtual void pushFloat(float floatValue);
/**
* Pushes a long number with value longValue onto the stack.
*
* @param longValue a long number.
*/
virtual void pushLong(long longValue);
/**
* Pushes a bool value with boolValue onto the stack.
*
* @param boolValue a bool value.
*/
virtual void pushBoolean(bool boolValue);
/**
* Pushes the zero-terminated string pointed to by stringValue onto the stack.
*
* @param stringValue a pointer point to a zero-terminated string stringValue.
*/
virtual void pushString(const char* stringValue);
/**
* Pushes the string pointed to by stringValue with size length onto the stack.
*
* @param stringValue a pointer point to the string stringValue.
* @param length the size.
*/
virtual void pushString(const char* stringValue, int length);
/**
* Pushes a nil value onto the stack.
*/
virtual void pushNil(void);
/**
* Pushes a Ref object onto the stack.
*
* @see toluafix_pushusertype_ccobject.
*/
virtual void pushObject(Ref* objectValue, const char* typeName);
/**
* According to the type of LuaValue, it would called the other push function in the internal.
* type function
* LuaValueTypeInt pushInt
* LuaValueTypeFloat pushFloat
* LuaValueTypeBoolean pushBoolean
* LuaValueTypeString pushString
* LuaValueTypeDict pushLuaValueDict
* LuaValueTypeArray pushLuaValueArray
* LuaValueTypeObject pushObject
*
* @param value a LuaValue object.
*/
virtual void pushLuaValue(const LuaValue& value);
/**
* Pushes a lua table onto the stack.
* The key of table is the key of LuaValueDict which is std::map.
* The value of table is according to the the type of LuaValue of LuaValueDict by calling pushLuaValue,@see pushLuaValue.
*
* @param dict a LuaValueDict object.
*/
virtual void pushLuaValueDict(const LuaValueDict& dict);
/**
* Pushes a lua array table onto the stack.
* The index of array table is begin at 1.
* The value of array table is according to the the type of LuaValue of LuaValueDict by calling pushLuaValue,@see pushLuaValue.
*/
virtual void pushLuaValueArray(const LuaValueArray& array);
/**
* Get the lua function pointer from toluafix_refid_function_mapping table by giving nHanlder.
* If the lua function pointer corresponding to the nHanlder isn't found, it would push nil on the top index of stack, then it would output the error log in the debug model.
*
* @return true if get the no-null function pointer otherwise false.
*/
virtual bool pushFunctionByHandler(int nHandler);
/**
* Execute the lua function on the -(numArgs + 1) index on the stack by the numArgs variables passed.
*
* @param numArgs the number of variables.
* @return 0 if it happen the error or it hasn't return value, otherwise it return the value by calling the lua function.
*/
virtual int executeFunction(int numArgs);
/**
* Execute the lua function corresponding to the nHandler by the numArgs variables passed.
*
* @param nHandler the index count corresponding to the lua function.
* @param numArgs the number of variables.
* @return the return value is the same as executeFunction,please @see executeFunction.
*/
virtual int executeFunctionByHandler(int nHandler, int numArgs);
/**
* Execute the lua function corresponding to the handler by the numArgs variables passed.
* By calling this function, the number of return value is numResults(may be > 1).
* All the return values are stored in the resultArray.
*
* @param handler the index count corresponding to the lua function.
* @param numArgs the number of variables.
* @param numResults the number of return value.
* @param resultArray a array used to store the return value.
* @return 0 if it happen error or it hasn't return value, otherwise return 1.
*/
virtual int executeFunctionReturnArray(int handler,int numArgs,int numResults,__Array& resultArray);
/**
* Execute the lua function corresponding to the handler by the numArgs variables passed.
* By calling this function, the number of return value is numResults(may be > 1).
* All the return values are used in the callback func.
*
* @param handler the index count corresponding to the lua function.
* @param numArgs the number of variables.
* @param numResults the number of return value.
* @param func callback function which is called if the numResults > 0.
* @return 0 if it happen error or it hasn't return value, otherwise return 1.
*/
virtual int executeFunction(int handler, int numArgs, int numResults, const std::function<void(lua_State*,int)>& func);
/**
* Handle the assert message.
*
* @return return true if current _callFromLua of LuaStack is not equal to 0 otherwise return false.
*/
virtual bool handleAssert(const char *msg, const char *cond, const char *file, int line);
/**
* Set the key and sign for xxtea encryption algorithm.
*
* @param key a string pointer
* @param keyLen the length of key
* @param sign a string sign
* @param signLen the length of sign
*/
virtual void setXXTEAKeyAndSign(const char *key, int keyLen, const char *sign, int signLen);
/**
* free the key and sign for xxtea encryption algorithm.
*/
virtual void cleanupXXTEAKeyAndSign();
/**
* Loads a buffer as a Lua chunk.This function uses lua_load to load the Lua chunk in the buffer pointed to by chunk with size chunkSize.
* If it supports xxtea encryption algorithm, the chunk and the chunkSize would be processed by calling xxtea_decrypt to the real buffer and buffer size.
*
* @param L the current lua_State.
* @param chunk the buffer pointer.
* @param chunkSize the size of buffer.
* @param chunkName the name of chunk pointer.
* @return 0, LUA_ERRSYNTAX or LUA_ERRMEM:.
*/
int luaLoadBuffer(lua_State *L, const char *chunk, int chunkSize, const char *chunkName);
/**
* Load the Lua chunks from the zip file
*
* @param zipFilePath file path to zip file.
* @return 1 if load sucessfully otherwise 0.
*/
int loadChunksFromZIP(const char *zipFilePath);
/**
* Load the Lua chunks from current lua_State.
*
* @param L the current lua_State.
* @return 1 if load sucessfully otherwise 0.
*/
int luaLoadChunksFromZIP(lua_State *L);
protected:
LuaStack(void)
: _state(nullptr)
, _callFromLua(0)
, _xxteaEnabled(false)
, _xxteaKey(nullptr)
, _xxteaKeyLen(0)
, _xxteaSign(nullptr)
, _xxteaSignLen(0)
{
}
bool init(void);
bool initWithLuaState(lua_State *L);
lua_State *_state;
int _callFromLua;
bool _xxteaEnabled;
char* _xxteaKey;
int _xxteaKeyLen;
char* _xxteaSign;
int _xxteaSignLen;
};
NS_CC_END
// end group
/// @}
#endif // __CC_LUA_STACK_H_
| [
"runsheng_ma@sina.com"
] | runsheng_ma@sina.com |
7eaef338cb3ef912d5065edc457d980821bcc14a | 2be3960b44fba5a278e34c0c6eec2f47bdc8fbdd | /src/day4/rules.hpp | db7750104847a610e15a564307bc6f6e9ed7aa2d | [] | no_license | Gronner/aoc-2020 | 0eda910281c3d3e2aee9f4ce4f80fd6d97d1d6be | 01a928115ef008a0e1ac293c17af647a96577c38 | refs/heads/main | 2023-02-13T17:20:18.207132 | 2021-01-03T01:18:30 | 2021-01-03T01:18:30 | 317,261,740 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 385 | hpp | #pragma once
#include <string>
bool birth_year_is_valid(std::string birth_year);
bool issue_year_is_valid(std::string issue_year);
bool expiration_year_is_valid(std::string expiration_year);
bool height_is_valid(std::string height);
bool hair_color_is_valid(std::string hair_color);
bool eye_color_is_valid(std::string eye_color);
bool passport_id_is_valid(std::string passport_id);
| [
"felix.braeunling@t-online.de"
] | felix.braeunling@t-online.de |
7bf19773124b744a631a1757a6ab57124468524b | 855da48165e70cd07c3f184714a9c166c537ec35 | /CardDefence/Classes/CsvData.h | b7d0ed25e8be8ee5870955a0602bacfbbe794526 | [] | no_license | wingkit/N001V150303MyLab | 4af547b9fa68cf4b4cca92023baff61e14a46490 | c04538cd1568a7b0558681d2b03bd83976606063 | refs/heads/master | 2016-09-05T17:40:30.456285 | 2015-06-18T16:07:11 | 2015-06-18T16:07:25 | 31,596,585 | 0 | 1 | null | null | null | null | GB18030 | C++ | false | false | 511 | h | /*
描述: Csv文件对象
*/
#ifndef _CsvData_H_
#define _CsvData_H_
#include "cocos2d.h"
USING_NS_CC;
class CsvData : public Ref{
public:
CREATE_FUNC(CsvData);
virtual bool init();
// 添加一行数据
void addLineData(ValueVector lineData);
// 获取某行的数据
ValueVector getSingleLineData(int iLine);
// 获取行列大小
Size getRowColNum();
private:
// 存放Csv文件所有行的数据, 试试这样理解:ValueVector<Value<ValueVector> >
ValueVector m_allLinesVec;
};
#endif | [
"525424725@qq.com"
] | 525424725@qq.com |
66d571d0564990ff2e98da23d613c6d422622df1 | aecf4944523b50424831f8af3debef67e3163b97 | /AlexRR_Editor/SceneUndo.cpp | d8174699bcdadd81a92581094ea46d3f927a1cc8 | [] | no_license | xrLil-Batya/gitxray | bc8c905444e40c4da5d77f69d03b41d5b9cec378 | 58aaa5185f7a682b8cf5f5f376a2e5b6ca16fed4 | refs/heads/main | 2023-03-31T07:43:57.500002 | 2020-12-12T21:12:25 | 2020-12-12T21:12:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,950 | cpp | //----------------------------------------------------
// file: SceneUndo.cpp
//
// Tanya M. : 265-74-96
// 265-86-00
// 251-46-69
// 251-46-70
// 251-46-76
// 251-46-77
// 251-46-78
// 264-89-00
//
//----------------------------------------------------
#include "Pch.h"
#pragma hdrstop
#include "NetDeviceLog.h"
#include "UI_Main.h"
#include "Scene.h"
#include "SceneChunks.h"
#include "FileSystem.h"
//----------------------------------------------------
void EScene::UndoClear(){
while( !m_RedoStack.empty() ){
unlink( m_RedoStack.back().m_FileName );
m_RedoStack.pop_back(); }
while( !m_UndoStack.empty() ){
unlink( m_UndoStack.back().m_FileName );
m_UndoStack.pop_back(); }
}
void EScene::UndoPrepare(){
UndoItem item;
GetTempFileName( FS.m_Temp.m_Path, "undo", 0, item.m_FileName );
Save( item.m_FileName );
m_UndoStack.push_back( item );
while( !m_RedoStack.empty() ){
unlink( m_RedoStack.back().m_FileName );
m_RedoStack.pop_back(); }
if( m_UndoStack.size() > 25 ){
unlink( m_UndoStack.front().m_FileName );
m_UndoStack.pop_front(); }
}
bool EScene::Undo(){
if( !m_UndoStack.empty() ){
Unload();
Load( m_UndoStack.back().m_FileName );
m_RedoStack.push_back( m_UndoStack.back() );
m_UndoStack.pop_back();
if( m_RedoStack.size() > 25 ){
unlink( m_RedoStack.front().m_FileName );
m_RedoStack.pop_front(); }
return true;
}
return false;
}
bool EScene::Redo(){
if( !m_RedoStack.empty() ){
Unload();
Load( m_RedoStack.back().m_FileName );
m_UndoStack.push_back( m_RedoStack.back() );
m_RedoStack.pop_back();
if( m_UndoStack.size() > 25 ){
unlink( m_UndoStack.front().m_FileName );
m_UndoStack.pop_front(); }
return true;
}
return false;
}
//----------------------------------------------------
| [
"admin@localhost"
] | admin@localhost |
23721617a678482ba49bb20343a4169c444c9b2d | 0e40a0486826825c2c8adba9a538e16ad3efafaf | /lib/d3d10/Include/d3dtypes.h | 59ae96704ae8dc7acebace85db892a06608c9950 | [
"MIT"
] | permissive | iraqigeek/iZ3D | 4c45e69a6e476ad434d5477f21f5b5eb48336727 | ced8b3a4b0a152d0177f2e94008918efc76935d5 | refs/heads/master | 2023-05-25T19:04:06.082744 | 2020-12-28T03:27:55 | 2020-12-28T03:27:55 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 77,817 | h | /*==========================================================================;
*
* Copyright (C) Microsoft Corporation. All Rights Reserved.
*
* File: d3dtypes.h
* Content: Direct3D types include file
*
***************************************************************************/
#ifndef _D3DTYPES_H_
#define _D3DTYPES_H_
#ifndef DIRECT3D_VERSION
#define DIRECT3D_VERSION 0x0700
#endif
#if (DIRECT3D_VERSION >= 0x0800)
#pragma message("should not include d3dtypes.h when compiling for DX8 or newer interfaces")
#endif
#include <windows.h>
#include <float.h>
#include "ddraw.h"
#pragma warning(push)
#pragma warning(disable:4201) // anonymous unions warning
#if defined(_X86_) || defined(_IA64_)
#pragma pack(4)
#endif
/* D3DVALUE is the fundamental Direct3D fractional data type */
#define D3DVALP(val, prec) ((float)(val))
#define D3DVAL(val) ((float)(val))
#ifndef DX_SHARED_DEFINES
/*
* This definition is shared with other DirectX components whose header files
* might already have defined it. Therefore, we don't define this type if
* someone else already has (as indicated by the definition of
* DX_SHARED_DEFINES). We don't set DX_SHARED_DEFINES here as there are
* other types in this header that are also shared. The last of these
* shared defines in this file will set DX_SHARED_DEFINES.
*/
typedef float D3DVALUE, *LPD3DVALUE;
#endif /* DX_SHARED_DEFINES */
#define D3DDivide(a, b) (float)((double) (a) / (double) (b))
#define D3DMultiply(a, b) ((a) * (b))
typedef LONG D3DFIXED;
#ifndef RGB_MAKE
/*
* Format of CI colors is
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | alpha | color index | fraction |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
#define CI_GETALPHA(ci) ((ci) >> 24)
#define CI_GETINDEX(ci) (((ci) >> 8) & 0xffff)
#define CI_GETFRACTION(ci) ((ci) & 0xff)
#define CI_ROUNDINDEX(ci) CI_GETINDEX((ci) + 0x80)
#define CI_MASKALPHA(ci) ((ci) & 0xffffff)
#define CI_MAKE(a, i, f) (((a) << 24) | ((i) << 8) | (f))
/*
* Format of RGBA colors is
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | alpha | red | green | blue |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
#define RGBA_GETALPHA(rgb) ((rgb) >> 24)
#define RGBA_GETRED(rgb) (((rgb) >> 16) & 0xff)
#define RGBA_GETGREEN(rgb) (((rgb) >> 8) & 0xff)
#define RGBA_GETBLUE(rgb) ((rgb) & 0xff)
#define RGBA_MAKE(r, g, b, a) ((D3DCOLOR) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)))
/* D3DRGB and D3DRGBA may be used as initialisers for D3DCOLORs
* The float values must be in the range 0..1
*/
#define D3DRGB(r, g, b) \
(0xff000000L | ( ((long)((r) * 255)) << 16) | (((long)((g) * 255)) << 8) | (long)((b) * 255))
#define D3DRGBA(r, g, b, a) \
( (((long)((a) * 255)) << 24) | (((long)((r) * 255)) << 16) \
| (((long)((g) * 255)) << 8) | (long)((b) * 255) \
)
/*
* Format of RGB colors is
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | ignored | red | green | blue |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
#define RGB_GETRED(rgb) (((rgb) >> 16) & 0xff)
#define RGB_GETGREEN(rgb) (((rgb) >> 8) & 0xff)
#define RGB_GETBLUE(rgb) ((rgb) & 0xff)
#define RGBA_SETALPHA(rgba, x) (((x) << 24) | ((rgba) & 0x00ffffff))
#define RGB_MAKE(r, g, b) ((D3DCOLOR) (((r) << 16) | ((g) << 8) | (b)))
#define RGBA_TORGB(rgba) ((D3DCOLOR) ((rgba) & 0xffffff))
#define RGB_TORGBA(rgb) ((D3DCOLOR) ((rgb) | 0xff000000))
#endif
/*
* Flags for Enumerate functions
*/
/*
* Stop the enumeration
*/
#define D3DENUMRET_CANCEL DDENUMRET_CANCEL
/*
* Continue the enumeration
*/
#define D3DENUMRET_OK DDENUMRET_OK
typedef HRESULT (CALLBACK* LPD3DVALIDATECALLBACK)(LPVOID lpUserArg, DWORD dwOffset);
typedef HRESULT (CALLBACK* LPD3DENUMTEXTUREFORMATSCALLBACK)(LPDDSURFACEDESC lpDdsd, LPVOID lpContext);
typedef HRESULT (CALLBACK* LPD3DENUMPIXELFORMATSCALLBACK)(LPDDPIXELFORMAT lpDDPixFmt, LPVOID lpContext);
#ifndef DX_SHARED_DEFINES
/*
* This definition is shared with other DirectX components whose header files
* might already have defined it. Therefore, we don't define this type if
* someone else already has (as indicated by the definition of
* DX_SHARED_DEFINES). We don't set DX_SHARED_DEFINES here as there are
* other types in this header that are also shared. The last of these
* shared defines in this file will set DX_SHARED_DEFINES.
*/
#ifndef D3DCOLOR_DEFINED
typedef DWORD D3DCOLOR;
#define D3DCOLOR_DEFINED
#endif
typedef DWORD *LPD3DCOLOR;
#endif /* DX_SHARED_DEFINES */
typedef DWORD D3DMATERIALHANDLE, *LPD3DMATERIALHANDLE;
typedef DWORD D3DTEXTUREHANDLE, *LPD3DTEXTUREHANDLE;
typedef DWORD D3DMATRIXHANDLE, *LPD3DMATRIXHANDLE;
#ifndef D3DCOLORVALUE_DEFINED
typedef struct _D3DCOLORVALUE {
union {
D3DVALUE r;
D3DVALUE dvR;
};
union {
D3DVALUE g;
D3DVALUE dvG;
};
union {
D3DVALUE b;
D3DVALUE dvB;
};
union {
D3DVALUE a;
D3DVALUE dvA;
};
} D3DCOLORVALUE;
#define D3DCOLORVALUE_DEFINED
#endif
typedef struct _D3DCOLORVALUE *LPD3DCOLORVALUE;
#ifndef D3DRECT_DEFINED
typedef struct _D3DRECT {
union {
LONG x1;
LONG lX1;
};
union {
LONG y1;
LONG lY1;
};
union {
LONG x2;
LONG lX2;
};
union {
LONG y2;
LONG lY2;
};
} D3DRECT;
#define D3DRECT_DEFINED
#endif
typedef struct _D3DRECT *LPD3DRECT;
#ifndef DX_SHARED_DEFINES
/*
* This definition is shared with other DirectX components whose header files
* might already have defined it. Therefore, we don't define this type if
* someone else already has (as indicated by the definition of
* DX_SHARED_DEFINES).
*/
#ifndef D3DVECTOR_DEFINED
typedef struct _D3DVECTOR {
union {
D3DVALUE x;
D3DVALUE dvX;
};
union {
D3DVALUE y;
D3DVALUE dvY;
};
union {
D3DVALUE z;
D3DVALUE dvZ;
};
#if(DIRECT3D_VERSION >= 0x0500)
#if (defined __cplusplus) && (defined D3D_OVERLOADS)
public:
// =====================================
// Constructors
// =====================================
_D3DVECTOR() { }
_D3DVECTOR(D3DVALUE f);
_D3DVECTOR(D3DVALUE _x, D3DVALUE _y, D3DVALUE _z);
_D3DVECTOR(const D3DVALUE f[3]);
// =====================================
// Access grants
// =====================================
const D3DVALUE&operator[](int i) const;
D3DVALUE&operator[](int i);
// =====================================
// Assignment operators
// =====================================
_D3DVECTOR& operator += (const _D3DVECTOR& v);
_D3DVECTOR& operator -= (const _D3DVECTOR& v);
_D3DVECTOR& operator *= (const _D3DVECTOR& v);
_D3DVECTOR& operator /= (const _D3DVECTOR& v);
_D3DVECTOR& operator *= (D3DVALUE s);
_D3DVECTOR& operator /= (D3DVALUE s);
// =====================================
// Unary operators
// =====================================
friend _D3DVECTOR operator + (const _D3DVECTOR& v);
friend _D3DVECTOR operator - (const _D3DVECTOR& v);
// =====================================
// Binary operators
// =====================================
// Addition and subtraction
friend _D3DVECTOR operator + (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
friend _D3DVECTOR operator - (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
// Scalar multiplication and division
friend _D3DVECTOR operator * (const _D3DVECTOR& v, D3DVALUE s);
friend _D3DVECTOR operator * (D3DVALUE s, const _D3DVECTOR& v);
friend _D3DVECTOR operator / (const _D3DVECTOR& v, D3DVALUE s);
// Memberwise multiplication and division
friend _D3DVECTOR operator * (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
friend _D3DVECTOR operator / (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
// Vector dominance
friend int operator < (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
friend int operator <= (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
// Bitwise equality
friend int operator == (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
// Length-related functions
friend D3DVALUE SquareMagnitude (const _D3DVECTOR& v);
friend D3DVALUE Magnitude (const _D3DVECTOR& v);
// Returns vector with same direction and unit length
friend _D3DVECTOR Normalize (const _D3DVECTOR& v);
// Return min/max component of the input vector
friend D3DVALUE Min (const _D3DVECTOR& v);
friend D3DVALUE Max (const _D3DVECTOR& v);
// Return memberwise min/max of input vectors
friend _D3DVECTOR Minimize (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
friend _D3DVECTOR Maximize (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
// Dot and cross product
friend D3DVALUE DotProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
friend _D3DVECTOR CrossProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
#endif
#endif /* DIRECT3D_VERSION >= 0x0500 */
} D3DVECTOR;
#define D3DVECTOR_DEFINED
#endif
typedef struct _D3DVECTOR *LPD3DVECTOR;
/*
* As this is the last of the shared defines to be defined we now set
* D3D_SHARED_DEFINES to flag that fact that this header has defined these
* types.
*/
#define DX_SHARED_DEFINES
#endif /* DX_SHARED_DEFINES */
/*
* Vertex data types supported in an ExecuteBuffer.
*/
/*
* Homogeneous vertices
*/
typedef struct _D3DHVERTEX {
DWORD dwFlags; /* Homogeneous clipping flags */
union {
D3DVALUE hx;
D3DVALUE dvHX;
};
union {
D3DVALUE hy;
D3DVALUE dvHY;
};
union {
D3DVALUE hz;
D3DVALUE dvHZ;
};
} D3DHVERTEX, *LPD3DHVERTEX;
/*
* Transformed/lit vertices
*/
typedef struct _D3DTLVERTEX {
union {
D3DVALUE sx; /* Screen coordinates */
D3DVALUE dvSX;
};
union {
D3DVALUE sy;
D3DVALUE dvSY;
};
union {
D3DVALUE sz;
D3DVALUE dvSZ;
};
union {
D3DVALUE rhw; /* Reciprocal of homogeneous w */
D3DVALUE dvRHW;
};
union {
D3DCOLOR color; /* Vertex color */
D3DCOLOR dcColor;
};
union {
D3DCOLOR specular; /* Specular component of vertex */
D3DCOLOR dcSpecular;
};
union {
D3DVALUE tu; /* Texture coordinates */
D3DVALUE dvTU;
};
union {
D3DVALUE tv;
D3DVALUE dvTV;
};
#if(DIRECT3D_VERSION >= 0x0500)
#if (defined __cplusplus) && (defined D3D_OVERLOADS)
_D3DTLVERTEX() { }
_D3DTLVERTEX(const D3DVECTOR& v, float _rhw,
D3DCOLOR _color, D3DCOLOR _specular,
float _tu, float _tv)
{ sx = v.x; sy = v.y; sz = v.z; rhw = _rhw;
color = _color; specular = _specular;
tu = _tu; tv = _tv;
}
#endif
#endif /* DIRECT3D_VERSION >= 0x0500 */
} D3DTLVERTEX, *LPD3DTLVERTEX;
/*
* Untransformed/lit vertices
*/
typedef struct _D3DLVERTEX {
union {
D3DVALUE x; /* Homogeneous coordinates */
D3DVALUE dvX;
};
union {
D3DVALUE y;
D3DVALUE dvY;
};
union {
D3DVALUE z;
D3DVALUE dvZ;
};
DWORD dwReserved;
union {
D3DCOLOR color; /* Vertex color */
D3DCOLOR dcColor;
};
union {
D3DCOLOR specular; /* Specular component of vertex */
D3DCOLOR dcSpecular;
};
union {
D3DVALUE tu; /* Texture coordinates */
D3DVALUE dvTU;
};
union {
D3DVALUE tv;
D3DVALUE dvTV;
};
#if(DIRECT3D_VERSION >= 0x0500)
#if (defined __cplusplus) && (defined D3D_OVERLOADS)
_D3DLVERTEX() { }
_D3DLVERTEX(const D3DVECTOR& v,
D3DCOLOR _color, D3DCOLOR _specular,
float _tu, float _tv)
{ x = v.x; y = v.y; z = v.z; dwReserved = 0;
color = _color; specular = _specular;
tu = _tu; tv = _tv;
}
#endif
#endif /* DIRECT3D_VERSION >= 0x0500 */
} D3DLVERTEX, *LPD3DLVERTEX;
/*
* Untransformed/unlit vertices
*/
typedef struct _D3DVERTEX {
union {
D3DVALUE x; /* Homogeneous coordinates */
D3DVALUE dvX;
};
union {
D3DVALUE y;
D3DVALUE dvY;
};
union {
D3DVALUE z;
D3DVALUE dvZ;
};
union {
D3DVALUE nx; /* Normal */
D3DVALUE dvNX;
};
union {
D3DVALUE ny;
D3DVALUE dvNY;
};
union {
D3DVALUE nz;
D3DVALUE dvNZ;
};
union {
D3DVALUE tu; /* Texture coordinates */
D3DVALUE dvTU;
};
union {
D3DVALUE tv;
D3DVALUE dvTV;
};
#if(DIRECT3D_VERSION >= 0x0500)
#if (defined __cplusplus) && (defined D3D_OVERLOADS)
_D3DVERTEX() { }
_D3DVERTEX(const D3DVECTOR& v, const D3DVECTOR& n, float _tu, float _tv)
{ x = v.x; y = v.y; z = v.z;
nx = n.x; ny = n.y; nz = n.z;
tu = _tu; tv = _tv;
}
#endif
#endif /* DIRECT3D_VERSION >= 0x0500 */
} D3DVERTEX, *LPD3DVERTEX;
/*
* Matrix, viewport, and tranformation structures and definitions.
*/
#ifndef D3DMATRIX_DEFINED
typedef struct _D3DMATRIX {
#if(DIRECT3D_VERSION >= 0x0500)
#if (defined __cplusplus) && (defined D3D_OVERLOADS)
union {
struct {
#endif
#endif /* DIRECT3D_VERSION >= 0x0500 */
D3DVALUE _11, _12, _13, _14;
D3DVALUE _21, _22, _23, _24;
D3DVALUE _31, _32, _33, _34;
D3DVALUE _41, _42, _43, _44;
#if(DIRECT3D_VERSION >= 0x0500)
#if (defined __cplusplus) && (defined D3D_OVERLOADS)
};
D3DVALUE m[4][4];
};
_D3DMATRIX() { }
_D3DMATRIX( D3DVALUE _m00, D3DVALUE _m01, D3DVALUE _m02, D3DVALUE _m03,
D3DVALUE _m10, D3DVALUE _m11, D3DVALUE _m12, D3DVALUE _m13,
D3DVALUE _m20, D3DVALUE _m21, D3DVALUE _m22, D3DVALUE _m23,
D3DVALUE _m30, D3DVALUE _m31, D3DVALUE _m32, D3DVALUE _m33
)
{
m[0][0] = _m00; m[0][1] = _m01; m[0][2] = _m02; m[0][3] = _m03;
m[1][0] = _m10; m[1][1] = _m11; m[1][2] = _m12; m[1][3] = _m13;
m[2][0] = _m20; m[2][1] = _m21; m[2][2] = _m22; m[2][3] = _m23;
m[3][0] = _m30; m[3][1] = _m31; m[3][2] = _m32; m[3][3] = _m33;
}
D3DVALUE& operator()(int iRow, int iColumn) { return m[iRow][iColumn]; }
const D3DVALUE& operator()(int iRow, int iColumn) const { return m[iRow][iColumn]; }
#if(DIRECT3D_VERSION >= 0x0600)
friend _D3DMATRIX operator* (const _D3DMATRIX&, const _D3DMATRIX&);
#endif /* DIRECT3D_VERSION >= 0x0600 */
#endif
#endif /* DIRECT3D_VERSION >= 0x0500 */
} D3DMATRIX;
#define D3DMATRIX_DEFINED
#endif
typedef struct _D3DMATRIX *LPD3DMATRIX;
#if (defined __cplusplus) && (defined D3D_OVERLOADS)
#include "d3dvec.inl"
#endif
typedef struct _D3DVIEWPORT {
DWORD dwSize;
DWORD dwX;
DWORD dwY; /* Top left */
DWORD dwWidth;
DWORD dwHeight; /* Dimensions */
D3DVALUE dvScaleX; /* Scale homogeneous to screen */
D3DVALUE dvScaleY; /* Scale homogeneous to screen */
D3DVALUE dvMaxX; /* Min/max homogeneous x coord */
D3DVALUE dvMaxY; /* Min/max homogeneous y coord */
D3DVALUE dvMinZ;
D3DVALUE dvMaxZ; /* Min/max homogeneous z coord */
} D3DVIEWPORT, *LPD3DVIEWPORT;
#if(DIRECT3D_VERSION >= 0x0500)
typedef struct _D3DVIEWPORT2 {
DWORD dwSize;
DWORD dwX;
DWORD dwY; /* Viewport Top left */
DWORD dwWidth;
DWORD dwHeight; /* Viewport Dimensions */
D3DVALUE dvClipX; /* Top left of clip volume */
D3DVALUE dvClipY;
D3DVALUE dvClipWidth; /* Clip Volume Dimensions */
D3DVALUE dvClipHeight;
D3DVALUE dvMinZ; /* Min/max of clip Volume */
D3DVALUE dvMaxZ;
} D3DVIEWPORT2, *LPD3DVIEWPORT2;
#endif /* DIRECT3D_VERSION >= 0x0500 */
#if(DIRECT3D_VERSION >= 0x0700)
typedef struct _D3DVIEWPORT7 {
DWORD dwX;
DWORD dwY; /* Viewport Top left */
DWORD dwWidth;
DWORD dwHeight; /* Viewport Dimensions */
D3DVALUE dvMinZ; /* Min/max of clip Volume */
D3DVALUE dvMaxZ;
} D3DVIEWPORT7, *LPD3DVIEWPORT7;
#endif /* DIRECT3D_VERSION >= 0x0700 */
/*
* Values for clip fields.
*/
#if(DIRECT3D_VERSION >= 0x0700)
// Max number of user clipping planes, supported in D3D.
#define D3DMAXUSERCLIPPLANES 32
// These bits could be ORed together to use with D3DRENDERSTATE_CLIPPLANEENABLE
//
#define D3DCLIPPLANE0 (1 << 0)
#define D3DCLIPPLANE1 (1 << 1)
#define D3DCLIPPLANE2 (1 << 2)
#define D3DCLIPPLANE3 (1 << 3)
#define D3DCLIPPLANE4 (1 << 4)
#define D3DCLIPPLANE5 (1 << 5)
#endif /* DIRECT3D_VERSION >= 0x0700 */
#define D3DCLIP_LEFT 0x00000001L
#define D3DCLIP_RIGHT 0x00000002L
#define D3DCLIP_TOP 0x00000004L
#define D3DCLIP_BOTTOM 0x00000008L
#define D3DCLIP_FRONT 0x00000010L
#define D3DCLIP_BACK 0x00000020L
#define D3DCLIP_GEN0 0x00000040L
#define D3DCLIP_GEN1 0x00000080L
#define D3DCLIP_GEN2 0x00000100L
#define D3DCLIP_GEN3 0x00000200L
#define D3DCLIP_GEN4 0x00000400L
#define D3DCLIP_GEN5 0x00000800L
/*
* Values for d3d status.
*/
#define D3DSTATUS_CLIPUNIONLEFT D3DCLIP_LEFT
#define D3DSTATUS_CLIPUNIONRIGHT D3DCLIP_RIGHT
#define D3DSTATUS_CLIPUNIONTOP D3DCLIP_TOP
#define D3DSTATUS_CLIPUNIONBOTTOM D3DCLIP_BOTTOM
#define D3DSTATUS_CLIPUNIONFRONT D3DCLIP_FRONT
#define D3DSTATUS_CLIPUNIONBACK D3DCLIP_BACK
#define D3DSTATUS_CLIPUNIONGEN0 D3DCLIP_GEN0
#define D3DSTATUS_CLIPUNIONGEN1 D3DCLIP_GEN1
#define D3DSTATUS_CLIPUNIONGEN2 D3DCLIP_GEN2
#define D3DSTATUS_CLIPUNIONGEN3 D3DCLIP_GEN3
#define D3DSTATUS_CLIPUNIONGEN4 D3DCLIP_GEN4
#define D3DSTATUS_CLIPUNIONGEN5 D3DCLIP_GEN5
#define D3DSTATUS_CLIPINTERSECTIONLEFT 0x00001000L
#define D3DSTATUS_CLIPINTERSECTIONRIGHT 0x00002000L
#define D3DSTATUS_CLIPINTERSECTIONTOP 0x00004000L
#define D3DSTATUS_CLIPINTERSECTIONBOTTOM 0x00008000L
#define D3DSTATUS_CLIPINTERSECTIONFRONT 0x00010000L
#define D3DSTATUS_CLIPINTERSECTIONBACK 0x00020000L
#define D3DSTATUS_CLIPINTERSECTIONGEN0 0x00040000L
#define D3DSTATUS_CLIPINTERSECTIONGEN1 0x00080000L
#define D3DSTATUS_CLIPINTERSECTIONGEN2 0x00100000L
#define D3DSTATUS_CLIPINTERSECTIONGEN3 0x00200000L
#define D3DSTATUS_CLIPINTERSECTIONGEN4 0x00400000L
#define D3DSTATUS_CLIPINTERSECTIONGEN5 0x00800000L
#define D3DSTATUS_ZNOTVISIBLE 0x01000000L
/* Do not use 0x80000000 for any status flags in future as it is reserved */
#define D3DSTATUS_CLIPUNIONALL ( \
D3DSTATUS_CLIPUNIONLEFT | \
D3DSTATUS_CLIPUNIONRIGHT | \
D3DSTATUS_CLIPUNIONTOP | \
D3DSTATUS_CLIPUNIONBOTTOM | \
D3DSTATUS_CLIPUNIONFRONT | \
D3DSTATUS_CLIPUNIONBACK | \
D3DSTATUS_CLIPUNIONGEN0 | \
D3DSTATUS_CLIPUNIONGEN1 | \
D3DSTATUS_CLIPUNIONGEN2 | \
D3DSTATUS_CLIPUNIONGEN3 | \
D3DSTATUS_CLIPUNIONGEN4 | \
D3DSTATUS_CLIPUNIONGEN5 \
)
#define D3DSTATUS_CLIPINTERSECTIONALL ( \
D3DSTATUS_CLIPINTERSECTIONLEFT | \
D3DSTATUS_CLIPINTERSECTIONRIGHT | \
D3DSTATUS_CLIPINTERSECTIONTOP | \
D3DSTATUS_CLIPINTERSECTIONBOTTOM | \
D3DSTATUS_CLIPINTERSECTIONFRONT | \
D3DSTATUS_CLIPINTERSECTIONBACK | \
D3DSTATUS_CLIPINTERSECTIONGEN0 | \
D3DSTATUS_CLIPINTERSECTIONGEN1 | \
D3DSTATUS_CLIPINTERSECTIONGEN2 | \
D3DSTATUS_CLIPINTERSECTIONGEN3 | \
D3DSTATUS_CLIPINTERSECTIONGEN4 | \
D3DSTATUS_CLIPINTERSECTIONGEN5 \
)
#define D3DSTATUS_DEFAULT ( \
D3DSTATUS_CLIPINTERSECTIONALL | \
D3DSTATUS_ZNOTVISIBLE)
/*
* Options for direct transform calls
*/
#define D3DTRANSFORM_CLIPPED 0x00000001l
#define D3DTRANSFORM_UNCLIPPED 0x00000002l
typedef struct _D3DTRANSFORMDATA {
DWORD dwSize;
LPVOID lpIn; /* Input vertices */
DWORD dwInSize; /* Stride of input vertices */
LPVOID lpOut; /* Output vertices */
DWORD dwOutSize; /* Stride of output vertices */
LPD3DHVERTEX lpHOut; /* Output homogeneous vertices */
DWORD dwClip; /* Clipping hint */
DWORD dwClipIntersection;
DWORD dwClipUnion; /* Union of all clip flags */
D3DRECT drExtent; /* Extent of transformed vertices */
} D3DTRANSFORMDATA, *LPD3DTRANSFORMDATA;
/*
* Structure defining position and direction properties for lighting.
*/
typedef struct _D3DLIGHTINGELEMENT {
D3DVECTOR dvPosition; /* Lightable point in model space */
D3DVECTOR dvNormal; /* Normalised unit vector */
} D3DLIGHTINGELEMENT, *LPD3DLIGHTINGELEMENT;
/*
* Structure defining material properties for lighting.
*/
typedef struct _D3DMATERIAL {
DWORD dwSize;
union {
D3DCOLORVALUE diffuse; /* Diffuse color RGBA */
D3DCOLORVALUE dcvDiffuse;
};
union {
D3DCOLORVALUE ambient; /* Ambient color RGB */
D3DCOLORVALUE dcvAmbient;
};
union {
D3DCOLORVALUE specular; /* Specular 'shininess' */
D3DCOLORVALUE dcvSpecular;
};
union {
D3DCOLORVALUE emissive; /* Emissive color RGB */
D3DCOLORVALUE dcvEmissive;
};
union {
D3DVALUE power; /* Sharpness if specular highlight */
D3DVALUE dvPower;
};
D3DTEXTUREHANDLE hTexture; /* Handle to texture map */
DWORD dwRampSize;
} D3DMATERIAL, *LPD3DMATERIAL;
#if(DIRECT3D_VERSION >= 0x0700)
typedef struct _D3DMATERIAL7 {
union {
D3DCOLORVALUE diffuse; /* Diffuse color RGBA */
D3DCOLORVALUE dcvDiffuse;
};
union {
D3DCOLORVALUE ambient; /* Ambient color RGB */
D3DCOLORVALUE dcvAmbient;
};
union {
D3DCOLORVALUE specular; /* Specular 'shininess' */
D3DCOLORVALUE dcvSpecular;
};
union {
D3DCOLORVALUE emissive; /* Emissive color RGB */
D3DCOLORVALUE dcvEmissive;
};
union {
D3DVALUE power; /* Sharpness if specular highlight */
D3DVALUE dvPower;
};
} D3DMATERIAL7, *LPD3DMATERIAL7;
#endif /* DIRECT3D_VERSION >= 0x0700 */
#if(DIRECT3D_VERSION < 0x0800)
typedef enum _D3DLIGHTTYPE {
D3DLIGHT_POINT = 1,
D3DLIGHT_SPOT = 2,
D3DLIGHT_DIRECTIONAL = 3,
// Note: The following light type (D3DLIGHT_PARALLELPOINT)
// is no longer supported from D3D for DX7 onwards.
D3DLIGHT_PARALLELPOINT = 4,
#if(DIRECT3D_VERSION < 0x0500) // For backward compatible headers
D3DLIGHT_GLSPOT = 5,
#endif
D3DLIGHT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
} D3DLIGHTTYPE;
#else
typedef enum _D3DLIGHTTYPE D3DLIGHTTYPE;
#define D3DLIGHT_PARALLELPOINT (D3DLIGHTTYPE)4
#define D3DLIGHT_GLSPOT (D3DLIGHTTYPE)5
#endif //(DIRECT3D_VERSION < 0x0800)
/*
* Structure defining a light source and its properties.
*/
typedef struct _D3DLIGHT {
DWORD dwSize;
D3DLIGHTTYPE dltType; /* Type of light source */
D3DCOLORVALUE dcvColor; /* Color of light */
D3DVECTOR dvPosition; /* Position in world space */
D3DVECTOR dvDirection; /* Direction in world space */
D3DVALUE dvRange; /* Cutoff range */
D3DVALUE dvFalloff; /* Falloff */
D3DVALUE dvAttenuation0; /* Constant attenuation */
D3DVALUE dvAttenuation1; /* Linear attenuation */
D3DVALUE dvAttenuation2; /* Quadratic attenuation */
D3DVALUE dvTheta; /* Inner angle of spotlight cone */
D3DVALUE dvPhi; /* Outer angle of spotlight cone */
} D3DLIGHT, *LPD3DLIGHT;
#if(DIRECT3D_VERSION >= 0x0700)
typedef struct _D3DLIGHT7 {
D3DLIGHTTYPE dltType; /* Type of light source */
D3DCOLORVALUE dcvDiffuse; /* Diffuse color of light */
D3DCOLORVALUE dcvSpecular; /* Specular color of light */
D3DCOLORVALUE dcvAmbient; /* Ambient color of light */
D3DVECTOR dvPosition; /* Position in world space */
D3DVECTOR dvDirection; /* Direction in world space */
D3DVALUE dvRange; /* Cutoff range */
D3DVALUE dvFalloff; /* Falloff */
D3DVALUE dvAttenuation0; /* Constant attenuation */
D3DVALUE dvAttenuation1; /* Linear attenuation */
D3DVALUE dvAttenuation2; /* Quadratic attenuation */
D3DVALUE dvTheta; /* Inner angle of spotlight cone */
D3DVALUE dvPhi; /* Outer angle of spotlight cone */
} D3DLIGHT7, *LPD3DLIGHT7;
#endif /* DIRECT3D_VERSION >= 0x0700 */
#if(DIRECT3D_VERSION >= 0x0500)
/*
* Structure defining a light source and its properties.
*/
/* flags bits */
#define D3DLIGHT_ACTIVE 0x00000001
#define D3DLIGHT_NO_SPECULAR 0x00000002
#define D3DLIGHT_ALL (D3DLIGHT_ACTIVE | D3DLIGHT_NO_SPECULAR)
/* maximum valid light range */
#define D3DLIGHT_RANGE_MAX ((float)sqrt(FLT_MAX))
typedef struct _D3DLIGHT2 {
DWORD dwSize;
D3DLIGHTTYPE dltType; /* Type of light source */
D3DCOLORVALUE dcvColor; /* Color of light */
D3DVECTOR dvPosition; /* Position in world space */
D3DVECTOR dvDirection; /* Direction in world space */
D3DVALUE dvRange; /* Cutoff range */
D3DVALUE dvFalloff; /* Falloff */
D3DVALUE dvAttenuation0; /* Constant attenuation */
D3DVALUE dvAttenuation1; /* Linear attenuation */
D3DVALUE dvAttenuation2; /* Quadratic attenuation */
D3DVALUE dvTheta; /* Inner angle of spotlight cone */
D3DVALUE dvPhi; /* Outer angle of spotlight cone */
DWORD dwFlags;
} D3DLIGHT2, *LPD3DLIGHT2;
#endif /* DIRECT3D_VERSION >= 0x0500 */
typedef struct _D3DLIGHTDATA {
DWORD dwSize;
LPD3DLIGHTINGELEMENT lpIn; /* Input positions and normals */
DWORD dwInSize; /* Stride of input elements */
LPD3DTLVERTEX lpOut; /* Output colors */
DWORD dwOutSize; /* Stride of output colors */
} D3DLIGHTDATA, *LPD3DLIGHTDATA;
#if(DIRECT3D_VERSION >= 0x0500)
/*
* Before DX5, these values were in an enum called
* D3DCOLORMODEL. This was not correct, since they are
* bit flags. A driver can surface either or both flags
* in the dcmColorModel member of D3DDEVICEDESC.
*/
#define D3DCOLOR_MONO 1
#define D3DCOLOR_RGB 2
typedef DWORD D3DCOLORMODEL;
#endif /* DIRECT3D_VERSION >= 0x0500 */
/*
* Options for clearing
*/
#define D3DCLEAR_TARGET 0x00000001l /* Clear target surface */
#define D3DCLEAR_ZBUFFER 0x00000002l /* Clear target z buffer */
#if(DIRECT3D_VERSION >= 0x0600)
#define D3DCLEAR_STENCIL 0x00000004l /* Clear stencil planes */
#endif /* DIRECT3D_VERSION >= 0x0600 */
/*
* Execute buffers are allocated via Direct3D. These buffers may then
* be filled by the application with instructions to execute along with
* vertex data.
*/
/*
* Supported op codes for execute instructions.
*/
typedef enum _D3DOPCODE {
D3DOP_POINT = 1,
D3DOP_LINE = 2,
D3DOP_TRIANGLE = 3,
D3DOP_MATRIXLOAD = 4,
D3DOP_MATRIXMULTIPLY = 5,
D3DOP_STATETRANSFORM = 6,
D3DOP_STATELIGHT = 7,
D3DOP_STATERENDER = 8,
D3DOP_PROCESSVERTICES = 9,
D3DOP_TEXTURELOAD = 10,
D3DOP_EXIT = 11,
D3DOP_BRANCHFORWARD = 12,
D3DOP_SPAN = 13,
D3DOP_SETSTATUS = 14,
#if(DIRECT3D_VERSION >= 0x0500)
D3DOP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
#endif /* DIRECT3D_VERSION >= 0x0500 */
} D3DOPCODE;
typedef struct _D3DINSTRUCTION {
BYTE bOpcode; /* Instruction opcode */
BYTE bSize; /* Size of each instruction data unit */
WORD wCount; /* Count of instruction data units to follow */
} D3DINSTRUCTION, *LPD3DINSTRUCTION;
/*
* Structure for texture loads
*/
typedef struct _D3DTEXTURELOAD {
D3DTEXTUREHANDLE hDestTexture;
D3DTEXTUREHANDLE hSrcTexture;
} D3DTEXTURELOAD, *LPD3DTEXTURELOAD;
/*
* Structure for picking
*/
typedef struct _D3DPICKRECORD {
BYTE bOpcode;
BYTE bPad;
DWORD dwOffset;
D3DVALUE dvZ;
} D3DPICKRECORD, *LPD3DPICKRECORD;
/*
* The following defines the rendering states which can be set in the
* execute buffer.
*/
#if(DIRECT3D_VERSION < 0x0800)
typedef enum _D3DSHADEMODE {
D3DSHADE_FLAT = 1,
D3DSHADE_GOURAUD = 2,
D3DSHADE_PHONG = 3,
#if(DIRECT3D_VERSION >= 0x0500)
D3DSHADE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
#endif /* DIRECT3D_VERSION >= 0x0500 */
} D3DSHADEMODE;
typedef enum _D3DFILLMODE {
D3DFILL_POINT = 1,
D3DFILL_WIREFRAME = 2,
D3DFILL_SOLID = 3,
#if(DIRECT3D_VERSION >= 0x0500)
D3DFILL_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
#endif /* DIRECT3D_VERSION >= 0x0500 */
} D3DFILLMODE;
typedef struct _D3DLINEPATTERN {
WORD wRepeatFactor;
WORD wLinePattern;
} D3DLINEPATTERN;
#endif //(DIRECT3D_VERSION < 0x0800)
typedef enum _D3DTEXTUREFILTER {
D3DFILTER_NEAREST = 1,
D3DFILTER_LINEAR = 2,
D3DFILTER_MIPNEAREST = 3,
D3DFILTER_MIPLINEAR = 4,
D3DFILTER_LINEARMIPNEAREST = 5,
D3DFILTER_LINEARMIPLINEAR = 6,
#if(DIRECT3D_VERSION >= 0x0500)
D3DFILTER_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
#endif /* DIRECT3D_VERSION >= 0x0500 */
} D3DTEXTUREFILTER;
#if(DIRECT3D_VERSION < 0x0800)
typedef enum _D3DBLEND {
D3DBLEND_ZERO = 1,
D3DBLEND_ONE = 2,
D3DBLEND_SRCCOLOR = 3,
D3DBLEND_INVSRCCOLOR = 4,
D3DBLEND_SRCALPHA = 5,
D3DBLEND_INVSRCALPHA = 6,
D3DBLEND_DESTALPHA = 7,
D3DBLEND_INVDESTALPHA = 8,
D3DBLEND_DESTCOLOR = 9,
D3DBLEND_INVDESTCOLOR = 10,
D3DBLEND_SRCALPHASAT = 11,
D3DBLEND_BOTHSRCALPHA = 12,
D3DBLEND_BOTHINVSRCALPHA = 13,
#if(DIRECT3D_VERSION >= 0x0500)
D3DBLEND_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
#endif /* DIRECT3D_VERSION >= 0x0500 */
} D3DBLEND;
#endif //(DIRECT3D_VERSION < 0x0800)
typedef enum _D3DTEXTUREBLEND {
D3DTBLEND_DECAL = 1,
D3DTBLEND_MODULATE = 2,
D3DTBLEND_DECALALPHA = 3,
D3DTBLEND_MODULATEALPHA = 4,
D3DTBLEND_DECALMASK = 5,
D3DTBLEND_MODULATEMASK = 6,
D3DTBLEND_COPY = 7,
#if(DIRECT3D_VERSION >= 0x0500)
D3DTBLEND_ADD = 8,
D3DTBLEND_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
#endif /* DIRECT3D_VERSION >= 0x0500 */
} D3DTEXTUREBLEND;
#if(DIRECT3D_VERSION < 0x0800)
typedef enum _D3DTEXTUREADDRESS {
D3DTADDRESS_WRAP = 1,
D3DTADDRESS_MIRROR = 2,
D3DTADDRESS_CLAMP = 3,
#if(DIRECT3D_VERSION >= 0x0500)
D3DTADDRESS_BORDER = 4,
D3DTADDRESS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
#endif /* DIRECT3D_VERSION >= 0x0500 */
} D3DTEXTUREADDRESS;
typedef enum _D3DCULL {
D3DCULL_NONE = 1,
D3DCULL_CW = 2,
D3DCULL_CCW = 3,
#if(DIRECT3D_VERSION >= 0x0500)
D3DCULL_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
#endif /* DIRECT3D_VERSION >= 0x0500 */
} D3DCULL;
typedef enum _D3DCMPFUNC {
D3DCMP_NEVER = 1,
D3DCMP_LESS = 2,
D3DCMP_EQUAL = 3,
D3DCMP_LESSEQUAL = 4,
D3DCMP_GREATER = 5,
D3DCMP_NOTEQUAL = 6,
D3DCMP_GREATEREQUAL = 7,
D3DCMP_ALWAYS = 8,
#if(DIRECT3D_VERSION >= 0x0500)
D3DCMP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
#endif /* DIRECT3D_VERSION >= 0x0500 */
} D3DCMPFUNC;
#if(DIRECT3D_VERSION >= 0x0600)
typedef enum _D3DSTENCILOP {
D3DSTENCILOP_KEEP = 1,
D3DSTENCILOP_ZERO = 2,
D3DSTENCILOP_REPLACE = 3,
D3DSTENCILOP_INCRSAT = 4,
D3DSTENCILOP_DECRSAT = 5,
D3DSTENCILOP_INVERT = 6,
D3DSTENCILOP_INCR = 7,
D3DSTENCILOP_DECR = 8,
D3DSTENCILOP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
} D3DSTENCILOP;
#endif /* DIRECT3D_VERSION >= 0x0600 */
typedef enum _D3DFOGMODE {
D3DFOG_NONE = 0,
D3DFOG_EXP = 1,
D3DFOG_EXP2 = 2,
#if(DIRECT3D_VERSION >= 0x0500)
D3DFOG_LINEAR = 3,
D3DFOG_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
#endif /* DIRECT3D_VERSION >= 0x0500 */
} D3DFOGMODE;
#if(DIRECT3D_VERSION >= 0x0600)
typedef enum _D3DZBUFFERTYPE {
D3DZB_FALSE = 0,
D3DZB_TRUE = 1, // Z buffering
D3DZB_USEW = 2, // W buffering
D3DZB_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
} D3DZBUFFERTYPE;
#endif /* DIRECT3D_VERSION >= 0x0600 */
#endif //(DIRECT3D_VERSION < 0x0800)
#if(DIRECT3D_VERSION >= 0x0500)
typedef enum _D3DANTIALIASMODE {
D3DANTIALIAS_NONE = 0,
D3DANTIALIAS_SORTDEPENDENT = 1,
D3DANTIALIAS_SORTINDEPENDENT = 2,
D3DANTIALIAS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
} D3DANTIALIASMODE;
// Vertex types supported by Direct3D
typedef enum _D3DVERTEXTYPE {
D3DVT_VERTEX = 1,
D3DVT_LVERTEX = 2,
D3DVT_TLVERTEX = 3,
D3DVT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
} D3DVERTEXTYPE;
#if(DIRECT3D_VERSION < 0x0800)
// Primitives supported by draw-primitive API
typedef enum _D3DPRIMITIVETYPE {
D3DPT_POINTLIST = 1,
D3DPT_LINELIST = 2,
D3DPT_LINESTRIP = 3,
D3DPT_TRIANGLELIST = 4,
D3DPT_TRIANGLESTRIP = 5,
D3DPT_TRIANGLEFAN = 6,
D3DPT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
} D3DPRIMITIVETYPE;
#endif //(DIRECT3D_VERSION < 0x0800)
#endif /* DIRECT3D_VERSION >= 0x0500 */
/*
* Amount to add to a state to generate the override for that state.
*/
#define D3DSTATE_OVERRIDE_BIAS 256
/*
* A state which sets the override flag for the specified state type.
*/
#define D3DSTATE_OVERRIDE(type) (D3DRENDERSTATETYPE)(((DWORD) (type) + D3DSTATE_OVERRIDE_BIAS))
#if(DIRECT3D_VERSION < 0x0800)
typedef enum _D3DTRANSFORMSTATETYPE {
D3DTRANSFORMSTATE_WORLD = 1,
D3DTRANSFORMSTATE_VIEW = 2,
D3DTRANSFORMSTATE_PROJECTION = 3,
#if(DIRECT3D_VERSION >= 0x0700)
D3DTRANSFORMSTATE_WORLD1 = 4, // 2nd matrix to blend
D3DTRANSFORMSTATE_WORLD2 = 5, // 3rd matrix to blend
D3DTRANSFORMSTATE_WORLD3 = 6, // 4th matrix to blend
D3DTRANSFORMSTATE_TEXTURE0 = 16,
D3DTRANSFORMSTATE_TEXTURE1 = 17,
D3DTRANSFORMSTATE_TEXTURE2 = 18,
D3DTRANSFORMSTATE_TEXTURE3 = 19,
D3DTRANSFORMSTATE_TEXTURE4 = 20,
D3DTRANSFORMSTATE_TEXTURE5 = 21,
D3DTRANSFORMSTATE_TEXTURE6 = 22,
D3DTRANSFORMSTATE_TEXTURE7 = 23,
#endif /* DIRECT3D_VERSION >= 0x0700 */
#if(DIRECT3D_VERSION >= 0x0500)
D3DTRANSFORMSTATE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
#endif /* DIRECT3D_VERSION >= 0x0500 */
} D3DTRANSFORMSTATETYPE;
#else
//
// legacy transform state names
//
typedef enum _D3DTRANSFORMSTATETYPE D3DTRANSFORMSTATETYPE;
#define D3DTRANSFORMSTATE_WORLD (D3DTRANSFORMSTATETYPE)1
#define D3DTRANSFORMSTATE_VIEW (D3DTRANSFORMSTATETYPE)2
#define D3DTRANSFORMSTATE_PROJECTION (D3DTRANSFORMSTATETYPE)3
#define D3DTRANSFORMSTATE_WORLD1 (D3DTRANSFORMSTATETYPE)4
#define D3DTRANSFORMSTATE_WORLD2 (D3DTRANSFORMSTATETYPE)5
#define D3DTRANSFORMSTATE_WORLD3 (D3DTRANSFORMSTATETYPE)6
#define D3DTRANSFORMSTATE_TEXTURE0 (D3DTRANSFORMSTATETYPE)16
#define D3DTRANSFORMSTATE_TEXTURE1 (D3DTRANSFORMSTATETYPE)17
#define D3DTRANSFORMSTATE_TEXTURE2 (D3DTRANSFORMSTATETYPE)18
#define D3DTRANSFORMSTATE_TEXTURE3 (D3DTRANSFORMSTATETYPE)19
#define D3DTRANSFORMSTATE_TEXTURE4 (D3DTRANSFORMSTATETYPE)20
#define D3DTRANSFORMSTATE_TEXTURE5 (D3DTRANSFORMSTATETYPE)21
#define D3DTRANSFORMSTATE_TEXTURE6 (D3DTRANSFORMSTATETYPE)22
#define D3DTRANSFORMSTATE_TEXTURE7 (D3DTRANSFORMSTATETYPE)23
#endif //(DIRECT3D_VERSION < 0x0800)
typedef enum _D3DLIGHTSTATETYPE {
D3DLIGHTSTATE_MATERIAL = 1,
D3DLIGHTSTATE_AMBIENT = 2,
D3DLIGHTSTATE_COLORMODEL = 3,
D3DLIGHTSTATE_FOGMODE = 4,
D3DLIGHTSTATE_FOGSTART = 5,
D3DLIGHTSTATE_FOGEND = 6,
D3DLIGHTSTATE_FOGDENSITY = 7,
#if(DIRECT3D_VERSION >= 0x0600)
D3DLIGHTSTATE_COLORVERTEX = 8,
#endif /* DIRECT3D_VERSION >= 0x0600 */
#if(DIRECT3D_VERSION >= 0x0500)
D3DLIGHTSTATE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
#endif /* DIRECT3D_VERSION >= 0x0500 */
} D3DLIGHTSTATETYPE;
#if(DIRECT3D_VERSION < 0x0800)
typedef enum _D3DRENDERSTATETYPE {
D3DRENDERSTATE_ANTIALIAS = 2, /* D3DANTIALIASMODE */
D3DRENDERSTATE_TEXTUREPERSPECTIVE = 4, /* TRUE for perspective correction */
D3DRENDERSTATE_ZENABLE = 7, /* D3DZBUFFERTYPE (or TRUE/FALSE for legacy) */
D3DRENDERSTATE_FILLMODE = 8, /* D3DFILL_MODE */
D3DRENDERSTATE_SHADEMODE = 9, /* D3DSHADEMODE */
D3DRENDERSTATE_LINEPATTERN = 10, /* D3DLINEPATTERN */
D3DRENDERSTATE_ZWRITEENABLE = 14, /* TRUE to enable z writes */
D3DRENDERSTATE_ALPHATESTENABLE = 15, /* TRUE to enable alpha tests */
D3DRENDERSTATE_LASTPIXEL = 16, /* TRUE for last-pixel on lines */
D3DRENDERSTATE_SRCBLEND = 19, /* D3DBLEND */
D3DRENDERSTATE_DESTBLEND = 20, /* D3DBLEND */
D3DRENDERSTATE_CULLMODE = 22, /* D3DCULL */
D3DRENDERSTATE_ZFUNC = 23, /* D3DCMPFUNC */
D3DRENDERSTATE_ALPHAREF = 24, /* D3DFIXED */
D3DRENDERSTATE_ALPHAFUNC = 25, /* D3DCMPFUNC */
D3DRENDERSTATE_DITHERENABLE = 26, /* TRUE to enable dithering */
#if(DIRECT3D_VERSION >= 0x0500)
D3DRENDERSTATE_ALPHABLENDENABLE = 27, /* TRUE to enable alpha blending */
#endif /* DIRECT3D_VERSION >= 0x0500 */
D3DRENDERSTATE_FOGENABLE = 28, /* TRUE to enable fog blending */
D3DRENDERSTATE_SPECULARENABLE = 29, /* TRUE to enable specular */
D3DRENDERSTATE_ZVISIBLE = 30, /* TRUE to enable z checking */
D3DRENDERSTATE_STIPPLEDALPHA = 33, /* TRUE to enable stippled alpha (RGB device only) */
D3DRENDERSTATE_FOGCOLOR = 34, /* D3DCOLOR */
D3DRENDERSTATE_FOGTABLEMODE = 35, /* D3DFOGMODE */
#if(DIRECT3D_VERSION >= 0x0700)
D3DRENDERSTATE_FOGSTART = 36, /* Fog start (for both vertex and pixel fog) */
D3DRENDERSTATE_FOGEND = 37, /* Fog end */
D3DRENDERSTATE_FOGDENSITY = 38, /* Fog density */
#endif /* DIRECT3D_VERSION >= 0x0700 */
#if(DIRECT3D_VERSION >= 0x0500)
D3DRENDERSTATE_EDGEANTIALIAS = 40, /* TRUE to enable edge antialiasing */
D3DRENDERSTATE_COLORKEYENABLE = 41, /* TRUE to enable source colorkeyed textures */
D3DRENDERSTATE_ZBIAS = 47, /* LONG Z bias */
D3DRENDERSTATE_RANGEFOGENABLE = 48, /* Enables range-based fog */
#endif /* DIRECT3D_VERSION >= 0x0500 */
#if(DIRECT3D_VERSION >= 0x0600)
D3DRENDERSTATE_STENCILENABLE = 52, /* BOOL enable/disable stenciling */
D3DRENDERSTATE_STENCILFAIL = 53, /* D3DSTENCILOP to do if stencil test fails */
D3DRENDERSTATE_STENCILZFAIL = 54, /* D3DSTENCILOP to do if stencil test passes and Z test fails */
D3DRENDERSTATE_STENCILPASS = 55, /* D3DSTENCILOP to do if both stencil and Z tests pass */
D3DRENDERSTATE_STENCILFUNC = 56, /* D3DCMPFUNC fn. Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */
D3DRENDERSTATE_STENCILREF = 57, /* Reference value used in stencil test */
D3DRENDERSTATE_STENCILMASK = 58, /* Mask value used in stencil test */
D3DRENDERSTATE_STENCILWRITEMASK = 59, /* Write mask applied to values written to stencil buffer */
D3DRENDERSTATE_TEXTUREFACTOR = 60, /* D3DCOLOR used for multi-texture blend */
#endif /* DIRECT3D_VERSION >= 0x0600 */
#if(DIRECT3D_VERSION >= 0x0600)
/*
* 128 values [128, 255] are reserved for texture coordinate wrap flags.
* These are constructed with the D3DWRAP_U and D3DWRAP_V macros. Using
* a flags word preserves forward compatibility with texture coordinates
* that are >2D.
*/
D3DRENDERSTATE_WRAP0 = 128, /* wrap for 1st texture coord. set */
D3DRENDERSTATE_WRAP1 = 129, /* wrap for 2nd texture coord. set */
D3DRENDERSTATE_WRAP2 = 130, /* wrap for 3rd texture coord. set */
D3DRENDERSTATE_WRAP3 = 131, /* wrap for 4th texture coord. set */
D3DRENDERSTATE_WRAP4 = 132, /* wrap for 5th texture coord. set */
D3DRENDERSTATE_WRAP5 = 133, /* wrap for 6th texture coord. set */
D3DRENDERSTATE_WRAP6 = 134, /* wrap for 7th texture coord. set */
D3DRENDERSTATE_WRAP7 = 135, /* wrap for 8th texture coord. set */
#endif /* DIRECT3D_VERSION >= 0x0600 */
#if(DIRECT3D_VERSION >= 0x0700)
D3DRENDERSTATE_CLIPPING = 136,
D3DRENDERSTATE_LIGHTING = 137,
D3DRENDERSTATE_EXTENTS = 138,
D3DRENDERSTATE_AMBIENT = 139,
D3DRENDERSTATE_FOGVERTEXMODE = 140,
D3DRENDERSTATE_COLORVERTEX = 141,
D3DRENDERSTATE_LOCALVIEWER = 142,
D3DRENDERSTATE_NORMALIZENORMALS = 143,
D3DRENDERSTATE_COLORKEYBLENDENABLE = 144,
D3DRENDERSTATE_DIFFUSEMATERIALSOURCE = 145,
D3DRENDERSTATE_SPECULARMATERIALSOURCE = 146,
D3DRENDERSTATE_AMBIENTMATERIALSOURCE = 147,
D3DRENDERSTATE_EMISSIVEMATERIALSOURCE = 148,
D3DRENDERSTATE_VERTEXBLEND = 151,
D3DRENDERSTATE_CLIPPLANEENABLE = 152,
#endif /* DIRECT3D_VERSION >= 0x0700 */
//
// retired renderstates - not supported for DX7 interfaces
//
D3DRENDERSTATE_TEXTUREHANDLE = 1, /* Texture handle for legacy interfaces (Texture,Texture2) */
D3DRENDERSTATE_TEXTUREADDRESS = 3, /* D3DTEXTUREADDRESS */
D3DRENDERSTATE_WRAPU = 5, /* TRUE for wrapping in u */
D3DRENDERSTATE_WRAPV = 6, /* TRUE for wrapping in v */
D3DRENDERSTATE_MONOENABLE = 11, /* TRUE to enable mono rasterization */
D3DRENDERSTATE_ROP2 = 12, /* ROP2 */
D3DRENDERSTATE_PLANEMASK = 13, /* DWORD physical plane mask */
D3DRENDERSTATE_TEXTUREMAG = 17, /* D3DTEXTUREFILTER */
D3DRENDERSTATE_TEXTUREMIN = 18, /* D3DTEXTUREFILTER */
D3DRENDERSTATE_TEXTUREMAPBLEND = 21, /* D3DTEXTUREBLEND */
D3DRENDERSTATE_SUBPIXEL = 31, /* TRUE to enable subpixel correction */
D3DRENDERSTATE_SUBPIXELX = 32, /* TRUE to enable correction in X only */
D3DRENDERSTATE_STIPPLEENABLE = 39, /* TRUE to enable stippling */
#if(DIRECT3D_VERSION >= 0x0500)
D3DRENDERSTATE_BORDERCOLOR = 43, /* Border color for texturing w/border */
D3DRENDERSTATE_TEXTUREADDRESSU = 44, /* Texture addressing mode for U coordinate */
D3DRENDERSTATE_TEXTUREADDRESSV = 45, /* Texture addressing mode for V coordinate */
D3DRENDERSTATE_MIPMAPLODBIAS = 46, /* D3DVALUE Mipmap LOD bias */
D3DRENDERSTATE_ANISOTROPY = 49, /* Max. anisotropy. 1 = no anisotropy */
#endif /* DIRECT3D_VERSION >= 0x0500 */
D3DRENDERSTATE_FLUSHBATCH = 50, /* Explicit flush for DP batching (DX5 Only) */
#if(DIRECT3D_VERSION >= 0x0600)
D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT=51, /* BOOL enable sort-independent transparency */
#endif /* DIRECT3D_VERSION >= 0x0600 */
D3DRENDERSTATE_STIPPLEPATTERN00 = 64, /* Stipple pattern 01... */
D3DRENDERSTATE_STIPPLEPATTERN01 = 65,
D3DRENDERSTATE_STIPPLEPATTERN02 = 66,
D3DRENDERSTATE_STIPPLEPATTERN03 = 67,
D3DRENDERSTATE_STIPPLEPATTERN04 = 68,
D3DRENDERSTATE_STIPPLEPATTERN05 = 69,
D3DRENDERSTATE_STIPPLEPATTERN06 = 70,
D3DRENDERSTATE_STIPPLEPATTERN07 = 71,
D3DRENDERSTATE_STIPPLEPATTERN08 = 72,
D3DRENDERSTATE_STIPPLEPATTERN09 = 73,
D3DRENDERSTATE_STIPPLEPATTERN10 = 74,
D3DRENDERSTATE_STIPPLEPATTERN11 = 75,
D3DRENDERSTATE_STIPPLEPATTERN12 = 76,
D3DRENDERSTATE_STIPPLEPATTERN13 = 77,
D3DRENDERSTATE_STIPPLEPATTERN14 = 78,
D3DRENDERSTATE_STIPPLEPATTERN15 = 79,
D3DRENDERSTATE_STIPPLEPATTERN16 = 80,
D3DRENDERSTATE_STIPPLEPATTERN17 = 81,
D3DRENDERSTATE_STIPPLEPATTERN18 = 82,
D3DRENDERSTATE_STIPPLEPATTERN19 = 83,
D3DRENDERSTATE_STIPPLEPATTERN20 = 84,
D3DRENDERSTATE_STIPPLEPATTERN21 = 85,
D3DRENDERSTATE_STIPPLEPATTERN22 = 86,
D3DRENDERSTATE_STIPPLEPATTERN23 = 87,
D3DRENDERSTATE_STIPPLEPATTERN24 = 88,
D3DRENDERSTATE_STIPPLEPATTERN25 = 89,
D3DRENDERSTATE_STIPPLEPATTERN26 = 90,
D3DRENDERSTATE_STIPPLEPATTERN27 = 91,
D3DRENDERSTATE_STIPPLEPATTERN28 = 92,
D3DRENDERSTATE_STIPPLEPATTERN29 = 93,
D3DRENDERSTATE_STIPPLEPATTERN30 = 94,
D3DRENDERSTATE_STIPPLEPATTERN31 = 95,
//
// retired renderstate names - the values are still used under new naming conventions
//
D3DRENDERSTATE_FOGTABLESTART = 36, /* Fog table start */
D3DRENDERSTATE_FOGTABLEEND = 37, /* Fog table end */
D3DRENDERSTATE_FOGTABLEDENSITY = 38, /* Fog table density */
#if(DIRECT3D_VERSION >= 0x0500)
D3DRENDERSTATE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
#endif /* DIRECT3D_VERSION >= 0x0500 */
} D3DRENDERSTATETYPE;
#else
typedef enum _D3DRENDERSTATETYPE D3DRENDERSTATETYPE;
//
// legacy renderstate names
//
#define D3DRENDERSTATE_TEXTUREPERSPECTIVE (D3DRENDERSTATETYPE)4
#define D3DRENDERSTATE_ZENABLE (D3DRENDERSTATETYPE)7
#define D3DRENDERSTATE_FILLMODE (D3DRENDERSTATETYPE)8
#define D3DRENDERSTATE_SHADEMODE (D3DRENDERSTATETYPE)9
#define D3DRENDERSTATE_LINEPATTERN (D3DRENDERSTATETYPE)10
#define D3DRENDERSTATE_ZWRITEENABLE (D3DRENDERSTATETYPE)14
#define D3DRENDERSTATE_ALPHATESTENABLE (D3DRENDERSTATETYPE)15
#define D3DRENDERSTATE_LASTPIXEL (D3DRENDERSTATETYPE)16
#define D3DRENDERSTATE_SRCBLEND (D3DRENDERSTATETYPE)19
#define D3DRENDERSTATE_DESTBLEND (D3DRENDERSTATETYPE)20
#define D3DRENDERSTATE_CULLMODE (D3DRENDERSTATETYPE)22
#define D3DRENDERSTATE_ZFUNC (D3DRENDERSTATETYPE)23
#define D3DRENDERSTATE_ALPHAREF (D3DRENDERSTATETYPE)24
#define D3DRENDERSTATE_ALPHAFUNC (D3DRENDERSTATETYPE)25
#define D3DRENDERSTATE_DITHERENABLE (D3DRENDERSTATETYPE)26
#define D3DRENDERSTATE_ALPHABLENDENABLE (D3DRENDERSTATETYPE)27
#define D3DRENDERSTATE_FOGENABLE (D3DRENDERSTATETYPE)28
#define D3DRENDERSTATE_SPECULARENABLE (D3DRENDERSTATETYPE)29
#define D3DRENDERSTATE_ZVISIBLE (D3DRENDERSTATETYPE)30
#define D3DRENDERSTATE_STIPPLEDALPHA (D3DRENDERSTATETYPE)33
#define D3DRENDERSTATE_FOGCOLOR (D3DRENDERSTATETYPE)34
#define D3DRENDERSTATE_FOGTABLEMODE (D3DRENDERSTATETYPE)35
#define D3DRENDERSTATE_FOGSTART (D3DRENDERSTATETYPE)36
#define D3DRENDERSTATE_FOGEND (D3DRENDERSTATETYPE)37
#define D3DRENDERSTATE_FOGDENSITY (D3DRENDERSTATETYPE)38
#define D3DRENDERSTATE_EDGEANTIALIAS (D3DRENDERSTATETYPE)40
#define D3DRENDERSTATE_ZBIAS (D3DRENDERSTATETYPE)47
#define D3DRENDERSTATE_RANGEFOGENABLE (D3DRENDERSTATETYPE)48
#define D3DRENDERSTATE_STENCILENABLE (D3DRENDERSTATETYPE)52
#define D3DRENDERSTATE_STENCILFAIL (D3DRENDERSTATETYPE)53
#define D3DRENDERSTATE_STENCILZFAIL (D3DRENDERSTATETYPE)54
#define D3DRENDERSTATE_STENCILPASS (D3DRENDERSTATETYPE)55
#define D3DRENDERSTATE_STENCILFUNC (D3DRENDERSTATETYPE)56
#define D3DRENDERSTATE_STENCILREF (D3DRENDERSTATETYPE)57
#define D3DRENDERSTATE_STENCILMASK (D3DRENDERSTATETYPE)58
#define D3DRENDERSTATE_STENCILWRITEMASK (D3DRENDERSTATETYPE)59
#define D3DRENDERSTATE_TEXTUREFACTOR (D3DRENDERSTATETYPE)60
#define D3DRENDERSTATE_WRAP0 (D3DRENDERSTATETYPE)128
#define D3DRENDERSTATE_WRAP1 (D3DRENDERSTATETYPE)129
#define D3DRENDERSTATE_WRAP2 (D3DRENDERSTATETYPE)130
#define D3DRENDERSTATE_WRAP3 (D3DRENDERSTATETYPE)131
#define D3DRENDERSTATE_WRAP4 (D3DRENDERSTATETYPE)132
#define D3DRENDERSTATE_WRAP5 (D3DRENDERSTATETYPE)133
#define D3DRENDERSTATE_WRAP6 (D3DRENDERSTATETYPE)134
#define D3DRENDERSTATE_WRAP7 (D3DRENDERSTATETYPE)135
#define D3DRENDERSTATE_CLIPPING (D3DRENDERSTATETYPE)136
#define D3DRENDERSTATE_LIGHTING (D3DRENDERSTATETYPE)137
#define D3DRENDERSTATE_EXTENTS (D3DRENDERSTATETYPE)138
#define D3DRENDERSTATE_AMBIENT (D3DRENDERSTATETYPE)139
#define D3DRENDERSTATE_FOGVERTEXMODE (D3DRENDERSTATETYPE)140
#define D3DRENDERSTATE_COLORVERTEX (D3DRENDERSTATETYPE)141
#define D3DRENDERSTATE_LOCALVIEWER (D3DRENDERSTATETYPE)142
#define D3DRENDERSTATE_NORMALIZENORMALS (D3DRENDERSTATETYPE)143
#define D3DRENDERSTATE_COLORKEYBLENDENABLE (D3DRENDERSTATETYPE)144
#define D3DRENDERSTATE_DIFFUSEMATERIALSOURCE (D3DRENDERSTATETYPE)145
#define D3DRENDERSTATE_SPECULARMATERIALSOURCE (D3DRENDERSTATETYPE)146
#define D3DRENDERSTATE_AMBIENTMATERIALSOURCE (D3DRENDERSTATETYPE)147
#define D3DRENDERSTATE_EMISSIVEMATERIALSOURCE (D3DRENDERSTATETYPE)148
#define D3DRENDERSTATE_VERTEXBLEND (D3DRENDERSTATETYPE)151
#define D3DRENDERSTATE_CLIPPLANEENABLE (D3DRENDERSTATETYPE)152
//
// retired renderstates - not supported for DX7 interfaces
//
#define D3DRENDERSTATE_TEXTUREHANDLE (D3DRENDERSTATETYPE)1
#define D3DRENDERSTATE_ANTIALIAS (D3DRENDERSTATETYPE)2
#define D3DRENDERSTATE_TEXTUREADDRESS (D3DRENDERSTATETYPE)3
#define D3DRENDERSTATE_WRAPU (D3DRENDERSTATETYPE)5
#define D3DRENDERSTATE_WRAPV (D3DRENDERSTATETYPE)6
#define D3DRENDERSTATE_MONOENABLE (D3DRENDERSTATETYPE)11
#define D3DRENDERSTATE_ROP2 (D3DRENDERSTATETYPE)12
#define D3DRENDERSTATE_PLANEMASK (D3DRENDERSTATETYPE)13
#define D3DRENDERSTATE_TEXTUREMAG (D3DRENDERSTATETYPE)17
#define D3DRENDERSTATE_TEXTUREMIN (D3DRENDERSTATETYPE)18
#define D3DRENDERSTATE_TEXTUREMAPBLEND (D3DRENDERSTATETYPE)21
#define D3DRENDERSTATE_SUBPIXEL (D3DRENDERSTATETYPE)31
#define D3DRENDERSTATE_SUBPIXELX (D3DRENDERSTATETYPE)32
#define D3DRENDERSTATE_STIPPLEENABLE (D3DRENDERSTATETYPE)39
#define D3DRENDERSTATE_OLDALPHABLENDENABLE (D3DRENDERSTATETYPE)42
#define D3DRENDERSTATE_BORDERCOLOR (D3DRENDERSTATETYPE)43
#define D3DRENDERSTATE_TEXTUREADDRESSU (D3DRENDERSTATETYPE)44
#define D3DRENDERSTATE_TEXTUREADDRESSV (D3DRENDERSTATETYPE)45
#define D3DRENDERSTATE_MIPMAPLODBIAS (D3DRENDERSTATETYPE)46
#define D3DRENDERSTATE_ANISOTROPY (D3DRENDERSTATETYPE)49
#define D3DRENDERSTATE_FLUSHBATCH (D3DRENDERSTATETYPE)50
#define D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT (D3DRENDERSTATETYPE)51
#define D3DRENDERSTATE_STIPPLEPATTERN00 (D3DRENDERSTATETYPE)64
#define D3DRENDERSTATE_STIPPLEPATTERN01 (D3DRENDERSTATETYPE)65
#define D3DRENDERSTATE_STIPPLEPATTERN02 (D3DRENDERSTATETYPE)66
#define D3DRENDERSTATE_STIPPLEPATTERN03 (D3DRENDERSTATETYPE)67
#define D3DRENDERSTATE_STIPPLEPATTERN04 (D3DRENDERSTATETYPE)68
#define D3DRENDERSTATE_STIPPLEPATTERN05 (D3DRENDERSTATETYPE)69
#define D3DRENDERSTATE_STIPPLEPATTERN06 (D3DRENDERSTATETYPE)70
#define D3DRENDERSTATE_STIPPLEPATTERN07 (D3DRENDERSTATETYPE)71
#define D3DRENDERSTATE_STIPPLEPATTERN08 (D3DRENDERSTATETYPE)72
#define D3DRENDERSTATE_STIPPLEPATTERN09 (D3DRENDERSTATETYPE)73
#define D3DRENDERSTATE_STIPPLEPATTERN10 (D3DRENDERSTATETYPE)74
#define D3DRENDERSTATE_STIPPLEPATTERN11 (D3DRENDERSTATETYPE)75
#define D3DRENDERSTATE_STIPPLEPATTERN12 (D3DRENDERSTATETYPE)76
#define D3DRENDERSTATE_STIPPLEPATTERN13 (D3DRENDERSTATETYPE)77
#define D3DRENDERSTATE_STIPPLEPATTERN14 (D3DRENDERSTATETYPE)78
#define D3DRENDERSTATE_STIPPLEPATTERN15 (D3DRENDERSTATETYPE)79
#define D3DRENDERSTATE_STIPPLEPATTERN16 (D3DRENDERSTATETYPE)80
#define D3DRENDERSTATE_STIPPLEPATTERN17 (D3DRENDERSTATETYPE)81
#define D3DRENDERSTATE_STIPPLEPATTERN18 (D3DRENDERSTATETYPE)82
#define D3DRENDERSTATE_STIPPLEPATTERN19 (D3DRENDERSTATETYPE)83
#define D3DRENDERSTATE_STIPPLEPATTERN20 (D3DRENDERSTATETYPE)84
#define D3DRENDERSTATE_STIPPLEPATTERN21 (D3DRENDERSTATETYPE)85
#define D3DRENDERSTATE_STIPPLEPATTERN22 (D3DRENDERSTATETYPE)86
#define D3DRENDERSTATE_STIPPLEPATTERN23 (D3DRENDERSTATETYPE)87
#define D3DRENDERSTATE_STIPPLEPATTERN24 (D3DRENDERSTATETYPE)88
#define D3DRENDERSTATE_STIPPLEPATTERN25 (D3DRENDERSTATETYPE)89
#define D3DRENDERSTATE_STIPPLEPATTERN26 (D3DRENDERSTATETYPE)90
#define D3DRENDERSTATE_STIPPLEPATTERN27 (D3DRENDERSTATETYPE)91
#define D3DRENDERSTATE_STIPPLEPATTERN28 (D3DRENDERSTATETYPE)92
#define D3DRENDERSTATE_STIPPLEPATTERN29 (D3DRENDERSTATETYPE)93
#define D3DRENDERSTATE_STIPPLEPATTERN30 (D3DRENDERSTATETYPE)94
#define D3DRENDERSTATE_STIPPLEPATTERN31 (D3DRENDERSTATETYPE)95
//
// retired renderstates - not supported for DX8 interfaces
//
#define D3DRENDERSTATE_COLORKEYENABLE (D3DRENDERSTATETYPE)41
#define D3DRENDERSTATE_COLORKEYBLENDENABLE (D3DRENDERSTATETYPE)144
//
// retired renderstate names - the values are still used under new naming conventions
//
#define D3DRENDERSTATE_BLENDENABLE (D3DRENDERSTATETYPE)27
#define D3DRENDERSTATE_FOGTABLESTART (D3DRENDERSTATETYPE)36
#define D3DRENDERSTATE_FOGTABLEEND (D3DRENDERSTATETYPE)37
#define D3DRENDERSTATE_FOGTABLEDENSITY (D3DRENDERSTATETYPE)38
#endif //(DIRECT3D_VERSION < 0x0800)
#if(DIRECT3D_VERSION < 0x0800)
// Values for material source
typedef enum _D3DMATERIALCOLORSOURCE
{
D3DMCS_MATERIAL = 0, // Color from material is used
D3DMCS_COLOR1 = 1, // Diffuse vertex color is used
D3DMCS_COLOR2 = 2, // Specular vertex color is used
D3DMCS_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
} D3DMATERIALCOLORSOURCE;
#if(DIRECT3D_VERSION >= 0x0500)
// For back-compatibility with legacy compilations
#define D3DRENDERSTATE_BLENDENABLE D3DRENDERSTATE_ALPHABLENDENABLE
#endif /* DIRECT3D_VERSION >= 0x0500 */
#if(DIRECT3D_VERSION >= 0x0600)
// Bias to apply to the texture coordinate set to apply a wrap to.
#define D3DRENDERSTATE_WRAPBIAS 128UL
/* Flags to construct the WRAP render states */
#define D3DWRAP_U 0x00000001L
#define D3DWRAP_V 0x00000002L
#endif /* DIRECT3D_VERSION >= 0x0600 */
#if(DIRECT3D_VERSION >= 0x0700)
/* Flags to construct the WRAP render states for 1D thru 4D texture coordinates */
#define D3DWRAPCOORD_0 0x00000001L // same as D3DWRAP_U
#define D3DWRAPCOORD_1 0x00000002L // same as D3DWRAP_V
#define D3DWRAPCOORD_2 0x00000004L
#define D3DWRAPCOORD_3 0x00000008L
#endif /* DIRECT3D_VERSION >= 0x0700 */
#endif //(DIRECT3D_VERSION < 0x0800)
#define D3DRENDERSTATE_STIPPLEPATTERN(y) (D3DRENDERSTATE_STIPPLEPATTERN00 + (y))
typedef struct _D3DSTATE {
union {
#if(DIRECT3D_VERSION < 0x0800)
D3DTRANSFORMSTATETYPE dtstTransformStateType;
#endif //(DIRECT3D_VERSION < 0x0800)
D3DLIGHTSTATETYPE dlstLightStateType;
D3DRENDERSTATETYPE drstRenderStateType;
};
union {
DWORD dwArg[1];
D3DVALUE dvArg[1];
};
} D3DSTATE, *LPD3DSTATE;
/*
* Operation used to load matrices
* hDstMat = hSrcMat
*/
typedef struct _D3DMATRIXLOAD {
D3DMATRIXHANDLE hDestMatrix; /* Destination matrix */
D3DMATRIXHANDLE hSrcMatrix; /* Source matrix */
} D3DMATRIXLOAD, *LPD3DMATRIXLOAD;
/*
* Operation used to multiply matrices
* hDstMat = hSrcMat1 * hSrcMat2
*/
typedef struct _D3DMATRIXMULTIPLY {
D3DMATRIXHANDLE hDestMatrix; /* Destination matrix */
D3DMATRIXHANDLE hSrcMatrix1; /* First source matrix */
D3DMATRIXHANDLE hSrcMatrix2; /* Second source matrix */
} D3DMATRIXMULTIPLY, *LPD3DMATRIXMULTIPLY;
/*
* Operation used to transform and light vertices.
*/
typedef struct _D3DPROCESSVERTICES {
DWORD dwFlags; /* Do we transform or light or just copy? */
WORD wStart; /* Index to first vertex in source */
WORD wDest; /* Index to first vertex in local buffer */
DWORD dwCount; /* Number of vertices to be processed */
DWORD dwReserved; /* Must be zero */
} D3DPROCESSVERTICES, *LPD3DPROCESSVERTICES;
#define D3DPROCESSVERTICES_TRANSFORMLIGHT 0x00000000L
#define D3DPROCESSVERTICES_TRANSFORM 0x00000001L
#define D3DPROCESSVERTICES_COPY 0x00000002L
#define D3DPROCESSVERTICES_OPMASK 0x00000007L
#define D3DPROCESSVERTICES_UPDATEEXTENTS 0x00000008L
#define D3DPROCESSVERTICES_NOCOLOR 0x00000010L
#if(DIRECT3D_VERSION >= 0x0600)
#if(DIRECT3D_VERSION < 0x0800)
/*
* State enumerants for per-stage texture processing.
*/
typedef enum _D3DTEXTURESTAGESTATETYPE
{
D3DTSS_COLOROP = 1, /* D3DTEXTUREOP - per-stage blending controls for color channels */
D3DTSS_COLORARG1 = 2, /* D3DTA_* (texture arg) */
D3DTSS_COLORARG2 = 3, /* D3DTA_* (texture arg) */
D3DTSS_ALPHAOP = 4, /* D3DTEXTUREOP - per-stage blending controls for alpha channel */
D3DTSS_ALPHAARG1 = 5, /* D3DTA_* (texture arg) */
D3DTSS_ALPHAARG2 = 6, /* D3DTA_* (texture arg) */
D3DTSS_BUMPENVMAT00 = 7, /* D3DVALUE (bump mapping matrix) */
D3DTSS_BUMPENVMAT01 = 8, /* D3DVALUE (bump mapping matrix) */
D3DTSS_BUMPENVMAT10 = 9, /* D3DVALUE (bump mapping matrix) */
D3DTSS_BUMPENVMAT11 = 10, /* D3DVALUE (bump mapping matrix) */
D3DTSS_TEXCOORDINDEX = 11, /* identifies which set of texture coordinates index this texture */
D3DTSS_ADDRESS = 12, /* D3DTEXTUREADDRESS for both coordinates */
D3DTSS_ADDRESSU = 13, /* D3DTEXTUREADDRESS for U coordinate */
D3DTSS_ADDRESSV = 14, /* D3DTEXTUREADDRESS for V coordinate */
D3DTSS_BORDERCOLOR = 15, /* D3DCOLOR */
D3DTSS_MAGFILTER = 16, /* D3DTEXTUREMAGFILTER filter to use for magnification */
D3DTSS_MINFILTER = 17, /* D3DTEXTUREMINFILTER filter to use for minification */
D3DTSS_MIPFILTER = 18, /* D3DTEXTUREMIPFILTER filter to use between mipmaps during minification */
D3DTSS_MIPMAPLODBIAS = 19, /* D3DVALUE Mipmap LOD bias */
D3DTSS_MAXMIPLEVEL = 20, /* DWORD 0..(n-1) LOD index of largest map to use (0 == largest) */
D3DTSS_MAXANISOTROPY = 21, /* DWORD maximum anisotropy */
D3DTSS_BUMPENVLSCALE = 22, /* D3DVALUE scale for bump map luminance */
D3DTSS_BUMPENVLOFFSET = 23, /* D3DVALUE offset for bump map luminance */
#if(DIRECT3D_VERSION >= 0x0700)
D3DTSS_TEXTURETRANSFORMFLAGS = 24, /* D3DTEXTURETRANSFORMFLAGS controls texture transform */
#endif /* DIRECT3D_VERSION >= 0x0700 */
D3DTSS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
} D3DTEXTURESTAGESTATETYPE;
#if(DIRECT3D_VERSION >= 0x0700)
// Values, used with D3DTSS_TEXCOORDINDEX, to specify that the vertex data(position
// and normal in the camera space) should be taken as texture coordinates
// Low 16 bits are used to specify texture coordinate index, to take the WRAP mode from
//
#define D3DTSS_TCI_PASSTHRU 0x00000000
#define D3DTSS_TCI_CAMERASPACENORMAL 0x00010000
#define D3DTSS_TCI_CAMERASPACEPOSITION 0x00020000
#define D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR 0x00030000
#endif /* DIRECT3D_VERSION >= 0x0700 */
/*
* Enumerations for COLOROP and ALPHAOP texture blending operations set in
* texture processing stage controls in D3DRENDERSTATE.
*/
typedef enum _D3DTEXTUREOP
{
// Control
D3DTOP_DISABLE = 1, // disables stage
D3DTOP_SELECTARG1 = 2, // the default
D3DTOP_SELECTARG2 = 3,
// Modulate
D3DTOP_MODULATE = 4, // multiply args together
D3DTOP_MODULATE2X = 5, // multiply and 1 bit
D3DTOP_MODULATE4X = 6, // multiply and 2 bits
// Add
D3DTOP_ADD = 7, // add arguments together
D3DTOP_ADDSIGNED = 8, // add with -0.5 bias
D3DTOP_ADDSIGNED2X = 9, // as above but left 1 bit
D3DTOP_SUBTRACT = 10, // Arg1 - Arg2, with no saturation
D3DTOP_ADDSMOOTH = 11, // add 2 args, subtract product
// Arg1 + Arg2 - Arg1*Arg2
// = Arg1 + (1-Arg1)*Arg2
// Linear alpha blend: Arg1*(Alpha) + Arg2*(1-Alpha)
D3DTOP_BLENDDIFFUSEALPHA = 12, // iterated alpha
D3DTOP_BLENDTEXTUREALPHA = 13, // texture alpha
D3DTOP_BLENDFACTORALPHA = 14, // alpha from D3DRENDERSTATE_TEXTUREFACTOR
// Linear alpha blend with pre-multiplied arg1 input: Arg1 + Arg2*(1-Alpha)
D3DTOP_BLENDTEXTUREALPHAPM = 15, // texture alpha
D3DTOP_BLENDCURRENTALPHA = 16, // by alpha of current color
// Specular mapping
D3DTOP_PREMODULATE = 17, // modulate with next texture before use
D3DTOP_MODULATEALPHA_ADDCOLOR = 18, // Arg1.RGB + Arg1.A*Arg2.RGB
// COLOROP only
D3DTOP_MODULATECOLOR_ADDALPHA = 19, // Arg1.RGB*Arg2.RGB + Arg1.A
// COLOROP only
D3DTOP_MODULATEINVALPHA_ADDCOLOR = 20, // (1-Arg1.A)*Arg2.RGB + Arg1.RGB
// COLOROP only
D3DTOP_MODULATEINVCOLOR_ADDALPHA = 21, // (1-Arg1.RGB)*Arg2.RGB + Arg1.A
// COLOROP only
// Bump mapping
D3DTOP_BUMPENVMAP = 22, // per pixel env map perturbation
D3DTOP_BUMPENVMAPLUMINANCE = 23, // with luminance channel
// This can do either diffuse or specular bump mapping with correct input.
// Performs the function (Arg1.R*Arg2.R + Arg1.G*Arg2.G + Arg1.B*Arg2.B)
// where each component has been scaled and offset to make it signed.
// The result is replicated into all four (including alpha) channels.
// This is a valid COLOROP only.
D3DTOP_DOTPRODUCT3 = 24,
D3DTOP_FORCE_DWORD = 0x7fffffff,
} D3DTEXTUREOP;
/*
* Values for COLORARG1,2 and ALPHAARG1,2 texture blending operations
* set in texture processing stage controls in D3DRENDERSTATE.
*/
#define D3DTA_SELECTMASK 0x0000000f // mask for arg selector
#define D3DTA_DIFFUSE 0x00000000 // select diffuse color
#define D3DTA_CURRENT 0x00000001 // select result of previous stage
#define D3DTA_TEXTURE 0x00000002 // select texture color
#define D3DTA_TFACTOR 0x00000003 // select RENDERSTATE_TEXTUREFACTOR
#if(DIRECT3D_VERSION >= 0x0700)
#define D3DTA_SPECULAR 0x00000004 // select specular color
#endif /* DIRECT3D_VERSION >= 0x0700 */
#define D3DTA_COMPLEMENT 0x00000010 // take 1.0 - x
#define D3DTA_ALPHAREPLICATE 0x00000020 // replicate alpha to color components
#endif //(DIRECT3D_VERSION < 0x0800)
/*
* IDirect3DTexture2 State Filter Types
*/
typedef enum _D3DTEXTUREMAGFILTER
{
D3DTFG_POINT = 1, // nearest
D3DTFG_LINEAR = 2, // linear interpolation
D3DTFG_FLATCUBIC = 3, // cubic
D3DTFG_GAUSSIANCUBIC = 4, // different cubic kernel
D3DTFG_ANISOTROPIC = 5, //
#if(DIRECT3D_VERSION >= 0x0700)
#endif /* DIRECT3D_VERSION >= 0x0700 */
D3DTFG_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
} D3DTEXTUREMAGFILTER;
typedef enum _D3DTEXTUREMINFILTER
{
D3DTFN_POINT = 1, // nearest
D3DTFN_LINEAR = 2, // linear interpolation
D3DTFN_ANISOTROPIC = 3, //
D3DTFN_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
} D3DTEXTUREMINFILTER;
typedef enum _D3DTEXTUREMIPFILTER
{
D3DTFP_NONE = 1, // mipmapping disabled (use MAG filter)
D3DTFP_POINT = 2, // nearest
D3DTFP_LINEAR = 3, // linear interpolation
D3DTFP_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
} D3DTEXTUREMIPFILTER;
#endif /* DIRECT3D_VERSION >= 0x0600 */
/*
* Triangle flags
*/
/*
* Tri strip and fan flags.
* START loads all three vertices
* EVEN and ODD load just v3 with even or odd culling
* START_FLAT contains a count from 0 to 29 that allows the
* whole strip or fan to be culled in one hit.
* e.g. for a quad len = 1
*/
#define D3DTRIFLAG_START 0x00000000L
#define D3DTRIFLAG_STARTFLAT(len) (len) /* 0 < len < 30 */
#define D3DTRIFLAG_ODD 0x0000001eL
#define D3DTRIFLAG_EVEN 0x0000001fL
/*
* Triangle edge flags
* enable edges for wireframe or antialiasing
*/
#define D3DTRIFLAG_EDGEENABLE1 0x00000100L /* v0-v1 edge */
#define D3DTRIFLAG_EDGEENABLE2 0x00000200L /* v1-v2 edge */
#define D3DTRIFLAG_EDGEENABLE3 0x00000400L /* v2-v0 edge */
#define D3DTRIFLAG_EDGEENABLETRIANGLE \
(D3DTRIFLAG_EDGEENABLE1 | D3DTRIFLAG_EDGEENABLE2 | D3DTRIFLAG_EDGEENABLE3)
/*
* Primitive structures and related defines. Vertex offsets are to types
* D3DVERTEX, D3DLVERTEX, or D3DTLVERTEX.
*/
/*
* Triangle list primitive structure
*/
typedef struct _D3DTRIANGLE {
union {
WORD v1; /* Vertex indices */
WORD wV1;
};
union {
WORD v2;
WORD wV2;
};
union {
WORD v3;
WORD wV3;
};
WORD wFlags; /* Edge (and other) flags */
} D3DTRIANGLE, *LPD3DTRIANGLE;
/*
* Line list structure.
* The instruction count defines the number of line segments.
*/
typedef struct _D3DLINE {
union {
WORD v1; /* Vertex indices */
WORD wV1;
};
union {
WORD v2;
WORD wV2;
};
} D3DLINE, *LPD3DLINE;
/*
* Span structure
* Spans join a list of points with the same y value.
* If the y value changes, a new span is started.
*/
typedef struct _D3DSPAN {
WORD wCount; /* Number of spans */
WORD wFirst; /* Index to first vertex */
} D3DSPAN, *LPD3DSPAN;
/*
* Point structure
*/
typedef struct _D3DPOINT {
WORD wCount; /* number of points */
WORD wFirst; /* index to first vertex */
} D3DPOINT, *LPD3DPOINT;
/*
* Forward branch structure.
* Mask is logically anded with the driver status mask
* if the result equals 'value', the branch is taken.
*/
typedef struct _D3DBRANCH {
DWORD dwMask; /* Bitmask against D3D status */
DWORD dwValue;
BOOL bNegate; /* TRUE to negate comparison */
DWORD dwOffset; /* How far to branch forward (0 for exit)*/
} D3DBRANCH, *LPD3DBRANCH;
/*
* Status used for set status instruction.
* The D3D status is initialised on device creation
* and is modified by all execute calls.
*/
typedef struct _D3DSTATUS {
DWORD dwFlags; /* Do we set extents or status */
DWORD dwStatus; /* D3D status */
D3DRECT drExtent;
} D3DSTATUS, *LPD3DSTATUS;
#define D3DSETSTATUS_STATUS 0x00000001L
#define D3DSETSTATUS_EXTENTS 0x00000002L
#define D3DSETSTATUS_ALL (D3DSETSTATUS_STATUS | D3DSETSTATUS_EXTENTS)
#if(DIRECT3D_VERSION >= 0x0500)
typedef struct _D3DCLIPSTATUS {
DWORD dwFlags; /* Do we set 2d extents, 3D extents or status */
DWORD dwStatus; /* Clip status */
float minx, maxx; /* X extents */
float miny, maxy; /* Y extents */
float minz, maxz; /* Z extents */
} D3DCLIPSTATUS, *LPD3DCLIPSTATUS;
#define D3DCLIPSTATUS_STATUS 0x00000001L
#define D3DCLIPSTATUS_EXTENTS2 0x00000002L
#define D3DCLIPSTATUS_EXTENTS3 0x00000004L
#endif /* DIRECT3D_VERSION >= 0x0500 */
/*
* Statistics structure
*/
typedef struct _D3DSTATS {
DWORD dwSize;
DWORD dwTrianglesDrawn;
DWORD dwLinesDrawn;
DWORD dwPointsDrawn;
DWORD dwSpansDrawn;
DWORD dwVerticesProcessed;
} D3DSTATS, *LPD3DSTATS;
/*
* Execute options.
* When calling using D3DEXECUTE_UNCLIPPED all the primitives
* inside the buffer must be contained within the viewport.
*/
#define D3DEXECUTE_CLIPPED 0x00000001l
#define D3DEXECUTE_UNCLIPPED 0x00000002l
typedef struct _D3DEXECUTEDATA {
DWORD dwSize;
DWORD dwVertexOffset;
DWORD dwVertexCount;
DWORD dwInstructionOffset;
DWORD dwInstructionLength;
DWORD dwHVertexOffset;
D3DSTATUS dsStatus; /* Status after execute */
} D3DEXECUTEDATA, *LPD3DEXECUTEDATA;
/*
* Palette flags.
* This are or'ed with the peFlags in the PALETTEENTRYs passed to DirectDraw.
*/
#define D3DPAL_FREE 0x00 /* Renderer may use this entry freely */
#define D3DPAL_READONLY 0x40 /* Renderer may not set this entry */
#define D3DPAL_RESERVED 0x80 /* Renderer may not use this entry */
#if(DIRECT3D_VERSION >= 0x0600)
typedef struct _D3DVERTEXBUFFERDESC {
DWORD dwSize;
DWORD dwCaps;
DWORD dwFVF;
DWORD dwNumVertices;
} D3DVERTEXBUFFERDESC, *LPD3DVERTEXBUFFERDESC;
#define D3DVBCAPS_SYSTEMMEMORY 0x00000800l
#define D3DVBCAPS_WRITEONLY 0x00010000l
#define D3DVBCAPS_OPTIMIZED 0x80000000l
#define D3DVBCAPS_DONOTCLIP 0x00000001l
/* Vertex Operations for ProcessVertices */
#define D3DVOP_LIGHT (1 << 10)
#define D3DVOP_TRANSFORM (1 << 0)
#define D3DVOP_CLIP (1 << 2)
#define D3DVOP_EXTENTS (1 << 3)
#if(DIRECT3D_VERSION < 0x0800)
/* The maximum number of vertices user can pass to any d3d
drawing function or to create vertex buffer with
*/
#define D3DMAXNUMVERTICES ((1<<16) - 1)
/* The maximum number of primitives user can pass to any d3d
drawing function.
*/
#define D3DMAXNUMPRIMITIVES ((1<<16) - 1)
#if(DIRECT3D_VERSION >= 0x0700)
/* Bits for dwFlags in ProcessVertices call */
#define D3DPV_DONOTCOPYDATA (1 << 0)
#endif /* DIRECT3D_VERSION >= 0x0700 */
#endif //(DIRECT3D_VERSION < 0x0800)
//-------------------------------------------------------------------
#if(DIRECT3D_VERSION < 0x0800)
// Flexible vertex format bits
//
#define D3DFVF_RESERVED0 0x001
#define D3DFVF_POSITION_MASK 0x00E
#define D3DFVF_XYZ 0x002
#define D3DFVF_XYZRHW 0x004
#if(DIRECT3D_VERSION >= 0x0700)
#define D3DFVF_XYZB1 0x006
#define D3DFVF_XYZB2 0x008
#define D3DFVF_XYZB3 0x00a
#define D3DFVF_XYZB4 0x00c
#define D3DFVF_XYZB5 0x00e
#endif /* DIRECT3D_VERSION >= 0x0700 */
#define D3DFVF_NORMAL 0x010
#define D3DFVF_RESERVED1 0x020
#define D3DFVF_DIFFUSE 0x040
#define D3DFVF_SPECULAR 0x080
#define D3DFVF_TEXCOUNT_MASK 0xf00
#define D3DFVF_TEXCOUNT_SHIFT 8
#define D3DFVF_TEX0 0x000
#define D3DFVF_TEX1 0x100
#define D3DFVF_TEX2 0x200
#define D3DFVF_TEX3 0x300
#define D3DFVF_TEX4 0x400
#define D3DFVF_TEX5 0x500
#define D3DFVF_TEX6 0x600
#define D3DFVF_TEX7 0x700
#define D3DFVF_TEX8 0x800
#define D3DFVF_RESERVED2 0xf000 // 4 reserved bits
#else
#define D3DFVF_RESERVED1 0x020
#endif //(DIRECT3D_VERSION < 0x0800)
#define D3DFVF_VERTEX ( D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 )
#define D3DFVF_LVERTEX ( D3DFVF_XYZ | D3DFVF_RESERVED1 | D3DFVF_DIFFUSE | \
D3DFVF_SPECULAR | D3DFVF_TEX1 )
#define D3DFVF_TLVERTEX ( D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | \
D3DFVF_TEX1 )
typedef struct _D3DDP_PTRSTRIDE
{
LPVOID lpvData;
DWORD dwStride;
} D3DDP_PTRSTRIDE;
#define D3DDP_MAXTEXCOORD 8
typedef struct _D3DDRAWPRIMITIVESTRIDEDDATA
{
D3DDP_PTRSTRIDE position;
D3DDP_PTRSTRIDE normal;
D3DDP_PTRSTRIDE diffuse;
D3DDP_PTRSTRIDE specular;
D3DDP_PTRSTRIDE textureCoords[D3DDP_MAXTEXCOORD];
} D3DDRAWPRIMITIVESTRIDEDDATA, *LPD3DDRAWPRIMITIVESTRIDEDDATA;
//---------------------------------------------------------------------
// ComputeSphereVisibility return values
//
#define D3DVIS_INSIDE_FRUSTUM 0
#define D3DVIS_INTERSECT_FRUSTUM 1
#define D3DVIS_OUTSIDE_FRUSTUM 2
#define D3DVIS_INSIDE_LEFT 0
#define D3DVIS_INTERSECT_LEFT (1 << 2)
#define D3DVIS_OUTSIDE_LEFT (2 << 2)
#define D3DVIS_INSIDE_RIGHT 0
#define D3DVIS_INTERSECT_RIGHT (1 << 4)
#define D3DVIS_OUTSIDE_RIGHT (2 << 4)
#define D3DVIS_INSIDE_TOP 0
#define D3DVIS_INTERSECT_TOP (1 << 6)
#define D3DVIS_OUTSIDE_TOP (2 << 6)
#define D3DVIS_INSIDE_BOTTOM 0
#define D3DVIS_INTERSECT_BOTTOM (1 << 8)
#define D3DVIS_OUTSIDE_BOTTOM (2 << 8)
#define D3DVIS_INSIDE_NEAR 0
#define D3DVIS_INTERSECT_NEAR (1 << 10)
#define D3DVIS_OUTSIDE_NEAR (2 << 10)
#define D3DVIS_INSIDE_FAR 0
#define D3DVIS_INTERSECT_FAR (1 << 12)
#define D3DVIS_OUTSIDE_FAR (2 << 12)
#define D3DVIS_MASK_FRUSTUM (3 << 0)
#define D3DVIS_MASK_LEFT (3 << 2)
#define D3DVIS_MASK_RIGHT (3 << 4)
#define D3DVIS_MASK_TOP (3 << 6)
#define D3DVIS_MASK_BOTTOM (3 << 8)
#define D3DVIS_MASK_NEAR (3 << 10)
#define D3DVIS_MASK_FAR (3 << 12)
#endif /* DIRECT3D_VERSION >= 0x0600 */
#if(DIRECT3D_VERSION < 0x0800)
#if(DIRECT3D_VERSION >= 0x0700)
// To be used with GetInfo()
#define D3DDEVINFOID_TEXTUREMANAGER 1
#define D3DDEVINFOID_D3DTEXTUREMANAGER 2
#define D3DDEVINFOID_TEXTURING 3
typedef enum _D3DSTATEBLOCKTYPE
{
D3DSBT_ALL = 1, // capture all state
D3DSBT_PIXELSTATE = 2, // capture pixel state
D3DSBT_VERTEXSTATE = 3, // capture vertex state
D3DSBT_FORCE_DWORD = 0xffffffff
} D3DSTATEBLOCKTYPE;
// The D3DVERTEXBLENDFLAGS type is used with D3DRENDERSTATE_VERTEXBLEND state.
//
typedef enum _D3DVERTEXBLENDFLAGS
{
D3DVBLEND_DISABLE = 0, // Disable vertex blending
D3DVBLEND_1WEIGHT = 1, // blend between 2 matrices
D3DVBLEND_2WEIGHTS = 2, // blend between 3 matrices
D3DVBLEND_3WEIGHTS = 3, // blend between 4 matrices
} D3DVERTEXBLENDFLAGS;
typedef enum _D3DTEXTURETRANSFORMFLAGS {
D3DTTFF_DISABLE = 0, // texture coordinates are passed directly
D3DTTFF_COUNT1 = 1, // rasterizer should expect 1-D texture coords
D3DTTFF_COUNT2 = 2, // rasterizer should expect 2-D texture coords
D3DTTFF_COUNT3 = 3, // rasterizer should expect 3-D texture coords
D3DTTFF_COUNT4 = 4, // rasterizer should expect 4-D texture coords
D3DTTFF_PROJECTED = 256, // texcoords to be divided by COUNTth element
D3DTTFF_FORCE_DWORD = 0x7fffffff,
} D3DTEXTURETRANSFORMFLAGS;
// Macros to set texture coordinate format bits in the FVF id
#define D3DFVF_TEXTUREFORMAT2 0 // Two floating point values
#define D3DFVF_TEXTUREFORMAT1 3 // One floating point value
#define D3DFVF_TEXTUREFORMAT3 1 // Three floating point values
#define D3DFVF_TEXTUREFORMAT4 2 // Four floating point values
#define D3DFVF_TEXCOORDSIZE3(CoordIndex) (D3DFVF_TEXTUREFORMAT3 << (CoordIndex*2 + 16))
#define D3DFVF_TEXCOORDSIZE2(CoordIndex) (D3DFVF_TEXTUREFORMAT2)
#define D3DFVF_TEXCOORDSIZE4(CoordIndex) (D3DFVF_TEXTUREFORMAT4 << (CoordIndex*2 + 16))
#define D3DFVF_TEXCOORDSIZE1(CoordIndex) (D3DFVF_TEXTUREFORMAT1 << (CoordIndex*2 + 16))
#endif /* DIRECT3D_VERSION >= 0x0700 */
#else
//
// legacy vertex blend names
//
typedef enum _D3DVERTEXBLENDFLAGS D3DVERTEXBLENDFLAGS;
#define D3DVBLEND_DISABLE (D3DVERTEXBLENDFLAGS)0
#define D3DVBLEND_1WEIGHT (D3DVERTEXBLENDFLAGS)1
#define D3DVBLEND_2WEIGHTS (D3DVERTEXBLENDFLAGS)2
#define D3DVBLEND_3WEIGHTS (D3DVERTEXBLENDFLAGS)3
#endif //(DIRECT3D_VERSION < 0x0800)
#pragma pack()
#pragma warning(pop)
#endif /* _D3DTYPES_H_ */
| [
"github@bo3b.net"
] | github@bo3b.net |
146593b28d7a743b394455346eaecb0449f166f1 | af0ecafb5428bd556d49575da2a72f6f80d3d14b | /CodeJamCrawler/dataset/11_17310_26.cpp | cad61ceef895e03c29e1759b7efc04a6588c9b11 | [] | no_license | gbrlas/AVSP | 0a2a08be5661c1b4a2238e875b6cdc88b4ee0997 | e259090bf282694676b2568023745f9ffb6d73fd | refs/heads/master | 2021-06-16T22:25:41.585830 | 2017-06-09T06:32:01 | 2017-06-09T06:32:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,625 | cpp | #include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <cstring>
#include <math.h>
#include <vector>
#include <set>
using namespace std;
#define PI 3.14159265358979323
#define INF 2123456789
#define NUL 0.0000001
#define PB push_back
#define SZ size()
#define CS c_str()
#define LEN length()
#define CLR clear()
#define EMP empty()
#define INS insert
const int MaxX = 1000005;
int a[MaxX], f[MaxX];
int main(){
freopen("A-large.in", "r", stdin);
freopen("A-large.out", "w", stdout);
int T; scanf("%d", &T);
for (int tt = 1; tt <= T; tt++){
int x, s, r, X, n; scanf("%d%d%d%d%d", &x, &s, &r, &X, &n);
double t = X;
memset(a, 0, sizeof(a));
for (int i = 1; i <= n; i++){
int b, e, w; scanf("%d%d%d", &b, &e, &w);
a[b] += w; a[e] -= w;
}
int tSpeed = s;
for (int i = 0; i < x; i++){
tSpeed += a[i];
f[i] = tSpeed;
}
sort(f, f+x);
//for (int i = 0; i < x; i++) printf("%d ", f[i]); printf("\n");
double sol = 0.0;
for (int i = 0; i < x; i++){
if ( 1.0 / double(f[i] + r - s) < t + NUL ){
sol += 1.0 / double(f[i] + r - s);
t -= 1.0 / double(f[i] + r - s);
}
else if (t < NUL){
sol += 1.0 / double(f[i]);
}
else {
sol += t + (1.0 - double(f[i] + r - s) * t) / double(f[i]);
t = 0.0;
}
//printf("t =
}
printf("Case #%d: %.10lf\n", tt, sol);
}
fclose(stdin); fclose(stdout);
return 0;
}
| [
"nikola.mrzljak@fer.hr"
] | nikola.mrzljak@fer.hr |
3ee0bdd94fb57616b047f4a3996dae02761708a0 | 8dee26bd5cbc848eb09b15bb80a8219e979d82de | /topics/search/poj1095.cc | f49ff904900c72be49c5f75473466b3ab12ff641 | [
"MIT"
] | permissive | LihuaWu/algorithms | b6b996ce8c3f951315eb6baff821184525f8e61c | ea0f177f3d7b6eca667c7d53e76f590b4f5bf9c5 | refs/heads/master | 2021-01-19T09:46:26.751895 | 2017-07-15T13:22:46 | 2017-07-15T13:22:46 | 87,782,908 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,379 | cc | //Tag: dfs catalan
#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define N 300
const int64_t INF =33500000100;
int64_t k[N];
int n, size;
void dfs(int n, int idx) {
// printf("%d node of %dth order\n", n, idx);
int64_t p = 0;
int left = 0;
for (int i = 0; i < n; i++) {
p += k[i] * k[n-1-i];
if (p > idx) {
left = i;
break;
}
}
int right = n-1-left;
int newpos = idx-(p-k[left]*k[n-1-left]);
if (left > 0) {
printf("(");
dfs(left, newpos/k[right]);
printf(")");
}
printf("X");
if (right>0) {
printf("(");
dfs(right, newpos%k[right]);
printf(")");
}
}
int main() {
k[0] = 1;
size = 1;
for (int i = 0; i < N ; i++, size++) {
k[i+1]= 2*(2*i+1)*k[i]/(i+2);
if(k[i+1] > INF || k[i+1] < 0) { break; }
// printf("%ld\n", k[i+1]);
}
while(true) {
cin >> n;
if (n == 0) break;
int idx = 0;
int64_t p = 0;
for (int i = 0; i < size; i++) {
p+= k[i];
if (p > n) {
idx = i;
break;
}
}
// printf("idx=%d size=%d\n", idx, size);
dfs(idx, n-p+k[idx]);
printf("\n");
}
return 0;
}
| [
"wulihua@sogou-inc.com"
] | wulihua@sogou-inc.com |
b0e5210b4e66bdce12015a2b3b7a3348f647aa7a | b8976b65227ccf8e5d0dc74b8f5ef65017b05b63 | /Include/Pickup.hpp | a9c113ea06d91314c2a02ea1b888518aaf77cb81 | [] | no_license | JamieCCH/SpaceAndAsteroids | 088a04dc615f8ec28f11a21feb74920747150284 | 8b33dcdbc4a039e497809501a3fd16b8af06f53c | refs/heads/master | 2020-03-10T04:36:35.866698 | 2018-04-18T08:10:52 | 2018-04-18T08:10:52 | 129,196,535 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 653 | hpp | #pragma once
#include "Entity.hpp"
#include "Command.hpp"
#include "ResourceIdentifiers.hpp"
#include <SFML/Graphics/Sprite.hpp>
class Aircraft;
class Pickup : public Entity
{
public:
enum Type
{
HealthRefill,
MissileRefill,
FireSpread,
FireRate,
TypeCount
};
public:
Pickup(Type type, const TextureHolder& textures);
virtual unsigned int getCategory() const;
virtual sf::FloatRect getBoundingRect() const;
void apply(Aircraft& player) const;
protected:
virtual void drawCurrent(sf::RenderTarget& target, sf::RenderStates states) const;
private:
Type mType;
sf::Sprite mSprite;
};
| [
"jamie.cch@gmail.com"
] | jamie.cch@gmail.com |
57dd10405745b90b905fa1bb300b0d76389c5ecf | 52a506d4d47a26424a91ae626413efbb0a01bea5 | /tests/poisson_evaluate.cpp | b6eb09804f0490b999d054933d2573671918897d | [
"MIT"
] | permissive | rburing/kontsevich_graph_series-cpp | 711912fcc74dda0840e7b1466da625ce5f984451 | 20d443646d7047f5d273c2a44436ef7e5e9b63ca | refs/heads/master | 2021-04-15T16:36:49.828234 | 2019-07-30T13:50:40 | 2019-07-30T13:50:40 | 50,918,226 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,372 | cpp | #include "../kontsevich_graph_series.hpp"
#include "../kontsevich_graph_operator.hpp"
#include "../util/poisson_structure.hpp"
#include "../util/poisson_structure_examples.hpp" // for poisson_structures
#include <ginac/ginac.h>
#include <iostream>
#include <vector>
#include <fstream>
using namespace std;
using namespace GiNaC;
int main(int argc, char* argv[])
{
if (argc != 3 || poisson_structures.find(argv[2]) == poisson_structures.end())
{
cerr << "Usage: " << argv[0] << " <graph-series-filename> <poisson-structure>\n\n"
<< "Poisson structures can be chosen from the following list:\n";
for (auto const& entry : poisson_structures)
{
cerr << "- " << entry.first << "\n";
}
return 1;
}
PoissonStructure& poisson = poisson_structures[argv[2]];
cout << "Coordinates: ";
for (symbol coordinate : poisson.coordinates)
cout << coordinate << " ";
cout << "\n";
cout << "Poisson structure matrix:\n";
cout << "[";
for (auto row = poisson.bivector.begin(); row != poisson.bivector.end(); ++row)
{
cout << "[";
for (auto entry = row->begin(); entry != row->end(); ++entry)
{
cout << *entry;
if (entry + 1 != row->end())
cout << ", ";
}
cout << "]";
if (row + 1 != poisson.bivector.end())
cout << "\n";
}
cout << "]\n\n";
// Reading in graph series:
string graph_series_filename(argv[1]);
ifstream graph_series_file(graph_series_filename);
parser coefficient_reader;
KontsevichGraphSeries<ex> graph_series = KontsevichGraphSeries<ex>::from_istream(graph_series_file, [&coefficient_reader](std::string s) -> ex { return coefficient_reader(s); });
size_t order = graph_series.precision();
for (size_t n = 0; n <= order; ++n)
{
if (graph_series[n] != 0 || n == order)
cout << "h^" << n << ":\n";
for (std::vector<size_t> indegrees : graph_series[n].in_degrees(true))
{
cout << "# ";
for (size_t j = 0; j != indegrees.size(); ++j)
cout << indegrees[j] << " ";
cout << "\n";
map< multi_indexes, ex > coefficients;
for (auto& term : graph_series[n][indegrees])
{
map_operator_coefficients_from_graph(term.second, poisson, [&coefficients, &term](multi_indexes arg_derivatives, GiNaC::ex summand) {
ex result = (term.first * summand).expand();
coefficients[arg_derivatives] += result;
});
}
for (auto& entry : coefficients)
{
cout << "# ";
for (auto mindex = entry.first.begin(); mindex != entry.first.end(); mindex++)
{
cout << "[ ";
for (auto &index : *mindex)
{
cout << poisson.coordinates[index] << " ";
}
cout << "]";
if (mindex + 1 != entry.first.end())
cout << " ";
}
cout << "\n";
ex result = entry.second;
cout << result << "\n";
}
cout.flush();
}
}
}
| [
"ricardo.buring@gmail.com"
] | ricardo.buring@gmail.com |
ec5c3562fb9413200abf2a137dcc2696bae0d1b4 | 9802284a0f2f13a6a7ac93278f8efa09cc0ec26b | /SDK/BP_MP5_RemoveMagInsertMag_functions.cpp | f8f17e5156a67fc0f1add027855652300d74dddf | [] | no_license | Berxz/Scum-SDK | 05eb0a27eec71ce89988636f04224a81a12131d8 | 74887c5497b435f535bbf8608fcf1010ff5e948c | refs/heads/master | 2021-05-17T15:38:25.915711 | 2020-03-31T06:32:10 | 2020-03-31T06:32:10 | 250,842,227 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,230 | cpp |
#include "../SDK.h"
// Name: SCUM, Version: 3.75.21350
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
namespace SDK
{
//---------------------------------------------------------------------------
// Functions
//---------------------------------------------------------------------------
// Function BP_MP5_RemoveMagInsertMag.BP_MP5_RemoveMagInsertMag_C.CanExecuteUsingData
// (Event, Public, HasOutParms, BlueprintCallable, BlueprintEvent, Const)
// Parameters:
// struct FWeaponReloadData* Data (ConstParm, BlueprintVisible, BlueprintReadOnly, Parm, OutParm, ReferenceParm)
// bool ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData)
bool UBP_MP5_RemoveMagInsertMag_C::CanExecuteUsingData(struct FWeaponReloadData* Data)
{
static auto fn = UObject::FindObject<UFunction>("Function BP_MP5_RemoveMagInsertMag.BP_MP5_RemoveMagInsertMag_C.CanExecuteUsingData");
UBP_MP5_RemoveMagInsertMag_C_CanExecuteUsingData_Params params;
params.Data = Data;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
return params.ReturnValue;
}
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"37065724+Berxz@users.noreply.github.com"
] | 37065724+Berxz@users.noreply.github.com |
40df31ecf5331c06c27a0f68d41f7f145695bc29 | e628ac29319ffdfc13dd16500dcb1c21e34dfa0a | /43.타이머 및 프레임고정/20210705_0/playGround.cpp | 69ef6047a474d70d39f8f364ebb1f97c155de8ac | [] | no_license | Rock-and-Stone/academyStorage | af6e211c83045df441abd7983f75c8f3785b1e47 | 23b989219488034ce7a4bec508e7642e852f62a1 | refs/heads/main | 2023-07-12T20:31:54.021002 | 2021-08-18T07:49:10 | 2021-08-18T07:49:10 | 397,496,199 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 2,028 | cpp | #include "pch.h"
#include "playGround.h"
playGround::playGround()
{
}
playGround::~playGround()
{
}
//초기화는 여기에다 해라!!!
HRESULT playGround::init()
{
gameNode::init(true);
IMAGEMANAGER->addImage("배경", "background.bmp", WINSIZEX, WINSIZEY, true,
RGB(255, 0, 255));
IMAGEMANAGER->addImage("bullet", "bullet.bmp", 21, 21, true, RGB(255, 0, 255));
IMAGEMANAGER->addFrameImage("enemy", "ufo.bmp", 0, 0, 530, 32, 10, 1, true, RGB(255, 0, 255));
IMAGEMANAGER->addImage("전", "전.bmp", WINSIZEX, WINSIZEY, true, RGB(255, 0, 255));
IMAGEMANAGER->addImage("후", "후.bmp", WINSIZEX, WINSIZEY, true, RGB(255, 0, 255));
//스페이스 쉽 인스턴스 생성 및 초기화 함수 호출
_ship = new spaceShip;
_ship->init();
_em = new enemyManager;
_em->init();
_em->setMinion();
_ship->setEmMemoryAddressLink(_em);
_em->setSpaceShipMemoryAddressLink(_ship);
_slt = new saveLoadTest;
_fadeOut = 255;
_fadeIn = 0;
_isFadeInOut = false;
return S_OK;
}
//메모리 해제는 여기다 해라!!!!
void playGround::release()
{
gameNode::release();
}
//연산처리는 여기다가!
void playGround::update()
{
gameNode::update();
_ship->update();
_em->update();
_slt->update();
//collision();
if (KEYMANAGER->isOnceKeyDown(VK_RETURN))
{
if (!_isFadeInOut) _isFadeInOut = true;
}
if (_isFadeInOut)
{
_fadeIn++;
_fadeOut--;
if (_fadeIn > 254) _isFadeInOut = false;
}
TIMEMANAGER->getElapsedTime();
}
//여기다 그려줘라!!!
void playGround::render()
{
PatBlt(getMemDC(), 0, 0, WINSIZEX, WINSIZEY, WHITENESS);
//==============위에는 제발 건드리지 마라 ============
//IMAGEMANAGER->findImage("배경")->render(getMemDC());
IMAGEMANAGER->findImage("후")->alphaRender(getMemDC(), _fadeIn);
IMAGEMANAGER->findImage("전")->alphaRender(getMemDC(), _fadeOut);
//_ship->render();
//_em->render();
TIMEMANAGER->render(getMemDC());
//=============== 밑에도 건들지마라 ================
_backBuffer->render(getHDC(), 0, 0);
}
| [
"wodyd031@outlook.kr"
] | wodyd031@outlook.kr |
53e30c62b8d2a6c5cf84c8a938c3d7f1e38d6789 | 10ecd7454a082e341eb60817341efa91d0c7fd0b | /SDK/BP_wld_Garden_pebbles_classes.h | c6cbd773c3d6b0f5f4013f23587dddcde792b23d | [] | no_license | Blackstate/Sot-SDK | 1dba56354524572894f09ed27d653ae5f367d95b | cd73724ce9b46e3eb5b075c468427aa5040daf45 | refs/heads/main | 2023-04-10T07:26:10.255489 | 2021-04-23T01:39:08 | 2021-04-23T01:39:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 755 | h | #pragma once
// Name: SoT, Version: 2.1.0.1
/*!!DEFINE!!*/
/*!!HELPER_DEF!!*/
/*!!HELPER_INC!!*/
#ifdef _MSC_VER
#pragma pack(push, 0x01)
#endif
namespace CG
{
//---------------------------------------------------------------------------
// Classes
//---------------------------------------------------------------------------
// BlueprintGeneratedClass BP_wld_Garden_pebbles.BP_wld_Garden_pebbles_C
// 0x0000 (FullSize[0x04CD] - InheritedSize[0x04CD])
class ABP_wld_Garden_pebbles_C : public ABP_Placement_Garden_C
{
public:
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("BlueprintGeneratedClass BP_wld_Garden_pebbles.BP_wld_Garden_pebbles_C");
return ptr;
}
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"ploszjanos9844@gmail.com"
] | ploszjanos9844@gmail.com |
89c487012032bbee30ca06720f32fe582b2d24ee | 76b6518fbccd64d3bcc16e9ea0c50e655e9ecddb | /Avengers/GameObjects/DomestoStayState.cpp | f60223bdd7c2fb73f13e54b04219be39b1c24844 | [] | no_license | lehoangvyvy997/Game-avengers-C-DirectrX | 5f0246da137029d5429ff2db0f858f46e773e989 | 2f4571b7b4b7213f9c28d9128d9ccd427b941d8f | refs/heads/master | 2020-08-02T19:02:16.888519 | 2019-09-28T09:07:55 | 2019-09-28T09:07:55 | 211,473,535 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,611 | cpp | #include "DomestoStayState.h"
#include <math.h>
DomestoStayState * DomestoStayState::__instance = NULL;
DomestoStayState *DomestoStayState::GetInstance(Domesto *domesto)
{
if (__instance == NULL)
__instance = new DomestoStayState(domesto);
return __instance;
}
DomestoStayState::DomestoStayState(Domesto *domesto)
{
this->domesto = domesto;
switch (domesto->GetType())
{
case DemestoType::STAY_FIRE_STRAIGHT:
this->state_standing_shoot();
break;
case DemestoType::WALK_FIRE_STAIGHT:
this->state_walking();
break;
}
}
DomestoStayState::~DomestoStayState()
{
delete anim;
}
//Lấy trạng thái
StateDomesto DomestoStayState::GetState()
{
return this->stateDomesto;
}
//Set trạng thái
void DomestoStayState::SetState(StateDomesto state)
{
this->stateDomesto = state;
}
// Chuyển state khi timeCount qua mốc thời gian xác định
void DomestoStayState::ChangeStateOverTime(StateDomesto state, float timeOut)
{
if (this->timeCount > timeOut)
{
this->timeCount = 0;
switch (state)
{
case DOMESTO_STATE_WALKING:
this->state_walking();
break;
case DOMESTO_STATE_STANDING_SHOOT:
this->state_standing_shoot();
break;
case DOMESTO_STATE_CROUCH_SHOOT:
this->state_crouch_shoot();
break;
case DOMESTO_STATE_DEAD:
this->state_dead();
break;
default:
break;
}
}
}
void DomestoStayState::state_walking()
{
this->SetState(StateDomesto::DOMESTO_STATE_WALKING);
anim = domesto->GetAnimationsList()[StateDomesto::DOMESTO_STATE_WALKING];
}
void DomestoStayState::state_standing_shoot()
{
this->SetState(StateDomesto::DOMESTO_STATE_STANDING_SHOOT);
anim = domesto->GetAnimationsList()[StateDomesto::DOMESTO_STATE_STANDING_SHOOT];
if (this->shootTimeCount > DOMESTO_TIME_OUT_STAND * 3)
{
this->shootTimeCount = 0;
if (sound_shoot != NULL)
{
delete sound_shoot;
}
sound_shoot = Sound::GetInstance()->LoadSound((LPTSTR)SOUND_BOSS1_LAZE);
Sound::GetInstance()->PlaySound(sound_shoot);
int direction = domesto->IsLeft() ? 1 : 5;
float offsetX = domesto->IsLeft() ? -16 : 16;
float offsetY = 0;
SpawnProjectTile::GetInstance()->SpawnBullet(domesto->GetPositionX() + offsetX, domesto->GetPositionY() + offsetY,
direction, BulletType::ROCKET);
}
this->ChangeStateOverTime(StateDomesto::DOMESTO_STATE_CROUCH_SHOOT,
DOMESTO_TIME_OUT_STAND + DOMESTO_TIME_OUT_STAND_SHOOT);
}
void DomestoStayState::state_crouch_shoot()
{
this->SetState(StateDomesto::DOMESTO_STATE_CROUCH_SHOOT);
anim = domesto->GetAnimationsList()[StateDomesto::DOMESTO_STATE_CROUCH_SHOOT];
if (this->shootTimeCount > DOMESTO_TIME_OUT_CROUCH * 2)
{
this->shootTimeCount = 0;
if (sound_shoot != NULL)
{
delete sound_shoot;
}
sound_shoot = Sound::GetInstance()->LoadSound((LPTSTR)SOUND_BOSS1_LAZE);
Sound::GetInstance()->PlaySound(sound_shoot);
int direction = domesto->IsLeft() ? 1 : 5;
float offsetX = domesto->IsLeft() ? -16 : 16;
float offsetY = -16;
SpawnProjectTile::GetInstance()->SpawnBullet(domesto->GetPositionX() + offsetX, domesto->GetPositionY() + offsetY,
direction, BulletType::ROCKET);
}
this->ChangeStateOverTime(StateDomesto::DOMESTO_STATE_STANDING_SHOOT,
DOMESTO_TIME_OUT_CROUCH + DOMESTO_TIME_OUT_CROUCH_SHOOT);
}
void DomestoStayState::state_dead()
{
this->SetState(StateDomesto::DOMESTO_STATE_DEAD);
anim = domesto->GetAnimationsList()[StateDomesto::DOMESTO_STATE_DEAD];
domesto->SetSpeedX(0);
if (this->timeCount > 200)
{
anim = domesto->GetAnimationsList()[4];
if (sound_dead != NULL)
{
delete sound_dead;
}
sound_dead = Sound::GetInstance()->LoadSound((LPTSTR)SOUND_BOOM);
Sound::GetInstance()->PlaySound(sound_dead);
}
if (this->timeCount > 350)
domesto->disable = true;
}
void DomestoStayState::Colision()
{
}
void DomestoStayState::Update(DWORD dt)
{
timeCount += dt;
this->shootTimeCount += dt;
//Update theo state
switch (stateDomesto)
{
case DOMESTO_STATE_WALKING:
this->state_walking();
break;
case DOMESTO_STATE_STANDING_SHOOT:
this->state_standing_shoot();
break;
case DOMESTO_STATE_CROUCH_SHOOT:
this->state_crouch_shoot();
break;
case DOMESTO_STATE_DEAD:
this->state_dead();
break;
default:
break;
}
}
void DomestoStayState::Render()
{
SpriteData spriteData;
if (this->domesto != NULL)
{
spriteData.width = 24;
spriteData.height = 46;
spriteData.x = domesto->GetPositionX();
spriteData.y = domesto->GetPositionY();
spriteData.scale = 1;
spriteData.angle = 0;
spriteData.isLeft = domesto->IsLeft();
spriteData.isFlipped = domesto->IsFlipped();
}
anim->Render(spriteData);
}
| [
"15521036@gm.uit.edu.vn"
] | 15521036@gm.uit.edu.vn |
491a45532cc442fa79c3fb52e6aabc883824d15d | 60ba61fa79be007e1c4080847e465c430e84ad5c | /Firmware/HCSR04.cpp | fb747c93f69149edf50f8c4b2b32a8d6d5485965 | [
"CC0-1.0"
] | permissive | yanais/Dronepoles | abed4e7a08a79064008df59182b2d2c82a5acddd | 02bb9716b7111650fc1dfc9fa9bb3bb4ec66e254 | refs/heads/master | 2021-01-14T08:56:58.794501 | 2015-12-27T14:06:06 | 2015-12-27T14:06:06 | 48,647,432 | 0 | 0 | null | 2015-12-27T14:12:07 | 2015-12-27T14:12:07 | null | UTF-8 | C++ | false | false | 2,184 | cpp | #include "HCSR04.h"
/**************************************************************/
/* Singelton section - promise just one instance of this class*/
/**************************************************************/
HCSR04* HCSR04::instance = 0;
HCSR04* HCSR04::getInstance()
{
if(instance == 0)
instance = new HCSR04;
return instance;
}
/*End singleton section*/
/***********************/
/*Class implemantation:*/
/***********************/
HCSR04::HCSR04() //HCSR04 constractor function
{
triggerBitMask = digitalPinToBitMask(HCSR04_TRIGGER_PIN); // Get the port register bitmask for the trigger pin.
echoBitMask = digitalPinToBitMask(HCSR04_ECHO_PIN); // Get the port register bitmask for the echo pin.
triggerOutputRegister = portOutputRegister(digitalPinToPort(HCSR04_TRIGGER_PIN)); // Get the output port register for the trigger pin.
echoInputRegister = portInputRegister(digitalPinToPort(HCSR04_ECHO_PIN)); // Get the input port register for the echo pin.
pinMode(HCSR04_TRIGGER_PIN,OUTPUT);
pinMode(HCSR04_ECHO_PIN,INPUT);
}
int HCSR04::read()
{
//Send 10uS high pulse to the trigger pin:
*triggerOutputRegister |= triggerBitMask; // Set trigger pin high
delayMicroseconds(10); // Wait 10uS
*triggerOutputRegister &= ~triggerBitMask; // Set trigger pin low.
//Wait ehco pin to turn up:
uint8_t timeOut = micros() + MAX_EHCO_DOWN; // Set a timeout for waiting echo to raise
while (!(*echoInputRegister & echoBitMask))
{
if (micros() > timeOut)
return TIME_OUT;
}
//Wait echo pin to turn down:
timeOut = micros() + MAX_EHCO_UP; // Set a timeout for waiting echo to fall
while (*echoInputRegister & echoBitMask)
{
if (micros() > timeOut)
return TIME_OUT;
}
return micros() - (timeOut - MAX_EHCO_UP);
}
int HCSR04::readInches() //Convert uS to inches
{
unsigned int echoTime = HCSR04::read();
return (echoTime == TIME_OUT) ? TIME_OUT : echoTime / INCH_ROUNDTRIP_TIME;
}
int HCSR04::readCentimeters() //Convert uS to centimetres
{
unsigned int echoTime = HCSR04::read();
return (echoTime == TIME_OUT) ? TIME_OUT : echoTime / CM_ROUNDTRIP_TIME;
}
/*End class implemantation*/
| [
"matan@robo-plan.com"
] | matan@robo-plan.com |
acf953e610eddf2d9202d2d1e94ef7b9b9797bef | 573255aba2e5b7e58dee81418194f3e09ff2728d | /ark_replacer_chedaki/config.cpp | 1990b3d7484915a1b387f75892c6825cc8dac2be | [] | no_license | Satire-/ARK_Replacer | 1553779bcdd82e42365d9806056ce964f00f1af3 | 8bda21135e20b85d233629f449bb7deebabe4707 | refs/heads/master | 2020-04-16T19:16:56.116734 | 2017-01-12T12:54:59 | 2017-01-12T12:54:59 | 52,472,016 | 0 | 1 | null | 2017-01-12T12:55:00 | 2016-02-24T20:25:02 | C++ | UTF-8 | C++ | false | false | 38,209 | cpp |
class CfgPatches
{
class ARK_Replacer_Chedaki
{
units[] = {"CUP_O_INS_Soldier_AK74","CUP_O_INS_Soldier_Engineer","CUP_O_INS_Soldier","CUP_O_INS_Soldier_Ammo","CUP_O_INS_Soldier_GL","CUP_O_INS_Officer","CUP_O_INS_Medic","CUP_O_INS_Commander","CUP_O_INS_Soldier_AR","CUP_O_INS_Soldier_MG","CUP_O_INS_Soldier_AT","CUP_O_INS_Soldier_AA","CUP_O_INS_Sniper","CUP_O_INS_Soldier_Exp","CUP_O_INS_Saboteur","CUP_O_INS_Story_Lopotev","CUP_O_INS_Story_Bardak","CUP_O_INS_Crew","CUP_O_INS_Pilot","CUP_O_INS_Worker2","CUP_O_INS_Woodlander1","CUP_O_INS_Woodlander2","CUP_O_INS_Woodlander3","CUP_O_INS_Villager3","CUP_O_INS_Villager4","CUP_B_INS_Backpack_Medic","CUP_B_INS_RPG_Backpack","CUP_B_INS_Backpack_AR","CUP_B_INS_Backpack_MG","CUP_B_INS_AlicePack_Exp","CUP_B_INS_AlicePack_Mines","CUP_B_INS_AlicePack_Engineer","CUP_B_INS_AlicePack_Ammo","CUP_Creatures_Military_CHDKZ_Soldier_01","CUP_Creatures_Military_CHDKZ_Soldier_02","CUP_Creatures_Military_CHDKZ_Soldier_03","CUP_Creatures_Military_CHDKZ_Soldier_04","CUP_Creatures_Military_CHDKZ_Soldier_05","CUP_Creatures_Military_CHDKZ_Soldier_06","CUP_Creatures_Military_CHDKZ_Soldier_07","CUP_Creatures_Military_CHDKZ_Soldier_08","CUP_Creatures_Military_CHDKZ_Soldier_09","CUP_Creatures_Military_CHDKZ_Soldier_10","CUP_Creatures_Military_CHDKZ_Soldier_11","CUP_Creatures_Military_CHDKZ_Soldier_12","CUP_Creatures_Military_CHDKZ_Soldier_13","CUP_Creatures_Military_CHDKZ_Soldier_14","CUP_Creatures_Military_CHDKZ_Soldier_15","CUP_Creatures_Military_CHDKZ_Soldier_16","CUP_Creatures_Military_CHDKZ_Soldier_17","CUP_Creatures_Military_CHDKZ_Soldier_18"};
weapons[] = {"CUP_U_O_CHDKZ_Bardak","CUP_U_O_CHDKZ_Commander","CUP_U_O_CHDKZ_Lopotev","CUP_U_O_CHDKZ_Kam_01","CUP_U_O_CHDKZ_Kam_02","CUP_U_O_CHDKZ_Kam_03","CUP_U_O_CHDKZ_Kam_04","CUP_U_O_CHDKZ_Kam_05","CUP_U_O_CHDKZ_Kam_06","CUP_U_O_CHDKZ_Kam_07","CUP_U_O_CHDKZ_Kam_08","CUP_U_O_Pilot_01","CUP_U_O_Worker_02","CUP_U_O_Woodlander_01","CUP_U_O_Woodlander_02","CUP_U_O_Woodlander_03","CUP_U_O_Villager_03","CUP_U_O_Villager_04","CUP_V_O_Ins_Carrier_Rig","CUP_V_O_Ins_Carrier_Rig_MG","CUP_V_O_Ins_Carrier_Rig_Com","CUP_V_O_Ins_Carrier_Rig_Light","CUP_H_ChDKZ_Beret","CUP_H_ChDKZ_Beanie","CUP_H_ChDKZ_Cap"};
requiredVersion = 0.1;
requiredAddons[] = {"CUP_Creatures_Military_Chedaki"};
};
};
class CfgVehicles
{
class Man;
class CAManBase;
class SoldierWB;
class CUP_B_AlicePack_Bedroll;
class CUP_B_AlicePack_Khaki;
class CUP_B_RPGPack_Khaki;
class CUP_B_INS_Backpack_Medic;
class CUP_B_INS_Backpack_AR: CUP_B_AlicePack_Khaki
{
scope = 1;
displayName = "Chedaki AR Pack";
class TransportMagazines
{
class _xx_hlc_45Rnd_545x39_t_rpk
{
magazine = "hlc_45Rnd_545x39_t_rpk";
count = 6;
};
};
};
class CUP_B_INS_AlicePack_Ammo: CUP_B_AlicePack_Bedroll
{
author = "$STR_CUP_AUTHOR_STRING";
scope = 1;
class TransportMagazines
{
class _xx_hlc_30Rnd_762x39_b_ak
{
magazine = "hlc_30Rnd_762x39_b_ak";
count = 4;
};
class _xx_hlc_30Rnd_545x39_B_AK
{
magazine = "hlc_30Rnd_545x39_B_AK";
count = 4;
};
class _xx_hlc_45Rnd_545x39_t_rpk
{
magazine = "hlc_45Rnd_545x39_t_rpk";
count = 2;
};
class _xx_CUP_100Rnd_TE4_LRT4_762x54_PK_Tracer_Green_M
{
magazine = "CUP_100Rnd_TE4_LRT4_762x54_PK_Tracer_Green_M";
count = 1;
};
class _xx_hlc_VOG25_AK
{
magazine = "hlc_VOG25_AK";
count = 6;
};
};
};
class CUP_Creatures_Military_OPFINS_Soldier_Base;
class CUP_Creatures_Military_CHDKZ_Soldier_01;
class CUP_Creatures_Military_CHDKZ_Soldier_02;
class CUP_Creatures_Military_CHDKZ_Soldier_03;
class CUP_Creatures_Military_CHDKZ_Soldier_04;
class CUP_Creatures_Military_CHDKZ_Soldier_05;
class CUP_Creatures_Military_CHDKZ_Soldier_06;
class CUP_Creatures_Military_CHDKZ_Soldier_07;
class CUP_Creatures_Military_CHDKZ_Soldier_08;
class CUP_Creatures_Military_CHDKZ_Soldier_09;
class CUP_Creatures_Military_CHDKZ_Soldier_10;
class CUP_Creatures_Military_CHDKZ_Soldier_11;
class CUP_Creatures_Military_CHDKZ_Soldier_12;
class CUP_Creatures_Military_CHDKZ_Soldier_13;
class CUP_Creatures_Military_CHDKZ_Soldier_14;
class CUP_Creatures_Military_CHDKZ_Soldier_15;
class CUP_Creatures_Military_CHDKZ_Soldier_16;
class CUP_Creatures_Military_CHDKZ_Soldier_17;
class CUP_Creatures_Military_CHDKZ_Soldier_18;
class CUP_O_INS_Soldier_AK74: CUP_Creatures_Military_CHDKZ_Soldier_04
{
author = "$STR_CUP_AUTHOR_STRING";
scope = 2;
scopeCurator = 2;
accuracy = 3.9;
displayName = "Rifleman (AK-74)";
Icon = "iconMan";
weapons[] = {"hlc_rifle_ak74","Throw","Put"};
respawnWeapons[] = {"hlc_rifle_ak74","Throw","Put"};
magazines[] = {"hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","CUP_HandGrenade_RGD5","CUP_HandGrenade_RGD5"};
respawnMagazines[] = {"hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","CUP_HandGrenade_RGD5","CUP_HandGrenade_RGD5"};
linkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig","CUP_H_ChDKZ_Beanie"};
respawnLinkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig","CUP_H_ChDKZ_Beanie"};
Items[] = {"FirstAidKit"};
RespawnItems[] = {"FirstAidKit"};
};
class CUP_O_INS_Soldier_Engineer: CUP_Creatures_Military_CHDKZ_Soldier_04
{
author = "$STR_CUP_AUTHOR_STRING";
scope = 2;
scopeCurator = 2;
accuracy = 3.9;
displayName = "Engineer";
weapons[] = {"hlc_rifle_ak74","Throw","Put"};
respawnWeapons[] = {"hlc_rifle_ak74","Throw","Put"};
magazines[] = {"hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","CUP_HandGrenade_RGD5","CUP_HandGrenade_RGD5"};
respawnMagazines[] = {"hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","CUP_HandGrenade_RGD5","CUP_HandGrenade_RGD5"};
linkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig","CUP_H_ChDKZ_Beanie"};
respawnLinkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig","CUP_H_ChDKZ_Beanie"};
Items[] = {"FirstAidKit"};
RespawnItems[] = {"FirstAidKit"};
backpack = "CUP_B_INS_AlicePack_Engineer";
engineer = 1;
icon = "iconManEngineer";
picture = "pictureRepair";
};
class CUP_O_INS_Soldier: CUP_Creatures_Military_CHDKZ_Soldier_04
{
author = "$STR_CUP_AUTHOR_STRING";
scope = 2;
scopeCurator = 2;
displayName = "Rifleman";
accuracy = 2;
camouflage = 1.4;
weapons[] = {"hlc_rifle_akm","Throw","Put"};
respawnWeapons[] = {"hlc_rifle_akm","Throw","Put"};
magazines[] = {"hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","CUP_HandGrenade_RGD5","CUP_HandGrenade_RGD5"};
respawnMagazines[] = {"hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","CUP_HandGrenade_RGD5","CUP_HandGrenade_RGD5"};
cost = 40000;
linkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig","CUP_H_ChDKZ_Beanie"};
respawnLinkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig","CUP_H_ChDKZ_Beanie"};
Items[] = {"FirstAidKit"};
RespawnItems[] = {"FirstAidKit"};
};
class CUP_O_INS_Soldier_Ammo: CUP_Creatures_Military_CHDKZ_Soldier_07
{
author = "$STR_CUP_AUTHOR_STRING";
scope = 2;
scopeCurator = 2;
displayName = "Ammo Bearer";
accuracy = 2;
camouflage = 1.4;
weapons[] = {"hlc_rifle_akm","Throw","Put"};
respawnWeapons[] = {"hlc_rifle_akm","Throw","Put"};
magazines[] = {"hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","CUP_HandGrenade_RGD5","CUP_HandGrenade_RGD5"};
respawnMagazines[] = {"hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","CUP_HandGrenade_RGD5","CUP_HandGrenade_RGD5"};
cost = 40000;
linkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig"};
respawnLinkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig"};
Items[] = {"FirstAidKit"};
RespawnItems[] = {"FirstAidKit"};
backpack = "CUP_B_INS_AlicePack_Ammo";
};
class CUP_O_INS_Soldier_GL: CUP_Creatures_Military_CHDKZ_Soldier_08
{
author = "$STR_CUP_AUTHOR_STRING";
scope = 2;
scopeCurator = 2;
accuracy = 3.9;
displayName = "Grenadier";
weapons[] = {"hlc_rifle_aks74_GL","Throw","Put"};
respawnWeapons[] = {"hlc_rifle_aks74_GL","Throw","Put"};
magazines[] = {"hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","CUP_1Rnd_HE_GP25_M","CUP_1Rnd_HE_GP25_M","CUP_1Rnd_HE_GP25_M","CUP_1Rnd_HE_GP25_M","CUP_1Rnd_HE_GP25_M","CUP_1Rnd_HE_GP25_M","CUP_1Rnd_HE_GP25_M","CUP_1Rnd_HE_GP25_M"};
respawnMagazines[] = {"hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","CUP_1Rnd_HE_GP25_M","CUP_1Rnd_HE_GP25_M","CUP_1Rnd_HE_GP25_M","CUP_1Rnd_HE_GP25_M","CUP_1Rnd_HE_GP25_M","CUP_1Rnd_HE_GP25_M","CUP_1Rnd_HE_GP25_M","CUP_1Rnd_HE_GP25_M"};
cost = 50000;
linkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig","G_Balaclava_oli"};
respawnLinkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig","G_Balaclava_oli"};
Items[] = {"FirstAidKit"};
RespawnItems[] = {"FirstAidKit"};
};
class CUP_O_INS_Officer: CUP_Creatures_Military_CHDKZ_Soldier_10
{
author = "$STR_CUP_AUTHOR_STRING";
scope = 2;
scopeCurator = 2;
displayName = "Officer";
accuracy = 3.6;
weapons[] = {"hlc_rifle_aks74","Binocular","Throw","Put","CUP_hgun_Makarov"};
respawnWeapons[] = {"hlc_rifle_aks74","Binocular","Throw","Put","CUP_hgun_Makarov"};
magazines[] = {"hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","CUP_HandGrenade_RGD5","CUP_HandGrenade_RGD5","SmokeShell","SmokeShell","CUP_8Rnd_9x18_Makarov_M","CUP_8Rnd_9x18_Makarov_M","CUP_8Rnd_9x18_Makarov_M","CUP_8Rnd_9x18_Makarov_M"};
respawnMagazines[] = {"hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","CUP_HandGrenade_RGD5","CUP_HandGrenade_RGD5","SmokeShell","SmokeShell","CUP_8Rnd_9x18_Makarov_M","CUP_8Rnd_9x18_Makarov_M","CUP_8Rnd_9x18_Makarov_M","CUP_8Rnd_9x18_Makarov_M"};
cost = 600000;
linkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig_Com","CUP_H_ChDKZ_Cap","CUP_NVG_PVS7"};
respawnLinkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig_Com","CUP_H_ChDKZ_Cap","CUP_NVG_PVS7"};
Items[] = {"FirstAidKit"};
RespawnItems[] = {"FirstAidKit"};
class SpeechVariants
{
class Default
{
speechSingular[] = {"veh_infantry_officer_s"};
speechPlural[] = {"veh_infantry_officer_p"};
};
};
textSingular = "$STR_A3_nameSound_veh_infantry_officer_s";
textPlural = "$STR_A3_nameSound_veh_infantry_officer_p";
icon = "iconManOfficer";
};
class CUP_O_INS_Medic: CUP_Creatures_Military_CHDKZ_Soldier_09
{
author = "$STR_CUP_AUTHOR_STRING";
scope = 2;
scopeCurator = 2;
displayName = "Medic";
accuracy = 3.7;
cost = 60000;
attendant = 1;
backpack = "CUP_B_INS_Backpack_Medic";
weapons[] = {"hlc_rifle_aks74u","Throw","Put"};
respawnWeapons[] = {"hlc_rifle_aks74u","Throw","Put"};
magazines[] = {"hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","CUP_HandGrenade_RGD5","SmokeShellOrange"};
respawnMagazines[] = {"hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","CUP_HandGrenade_RGD5","SmokeShellOrange"};
linkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig_Light","CUP_H_ChDKZ_Cap"};
respawnLinkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig_Light","CUP_H_ChDKZ_Cap"};
Items[] = {"FirstAidKit"};
RespawnItems[] = {"FirstAidKit"};
icon = "iconManMedic";
};
class CUP_O_INS_Commander: CUP_Creatures_Military_CHDKZ_Soldier_02
{
author = "$STR_CUP_AUTHOR_STRING";
scope = 2;
scopeCurator = 2;
displayName = "Commander";
accuracy = 3.6;
weapons[] = {"hlc_rifle_aks74u","CUP_hgun_Makarov","Binocular","Throw","Put"};
respawnWeapons[] = {"hlc_rifle_aks74u","CUP_hgun_Makarov","Binocular","Throw","Put"};
magazines[] = {"hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","CUP_8Rnd_9x18_Makarov_M","CUP_8Rnd_9x18_Makarov_M","CUP_8Rnd_9x18_Makarov_M","CUP_8Rnd_9x18_Makarov_M"};
respawnMagazines[] = {"hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","CUP_8Rnd_9x18_Makarov_M","CUP_8Rnd_9x18_Makarov_M","CUP_8Rnd_9x18_Makarov_M","CUP_8Rnd_9x18_Makarov_M"};
cost = 600000;
linkedItems[] = {"ItemGPC","ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_H_ChDKZ_Beret","CUP_NVG_PVS7"};
respawnLinkedItems[] = {"ItemGPC","ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_H_ChDKZ_Beret","CUP_NVG_PVS7"};
Items[] = {"FirstAidKit"};
RespawnItems[] = {"FirstAidKit"};
class SpeechVariants
{
class Default
{
speechSingular[] = {"veh_infantry_officer_s"};
speechPlural[] = {"veh_infantry_officer_p"};
};
};
textSingular = "$STR_A3_nameSound_veh_infantry_officer_s";
textPlural = "$STR_A3_nameSound_veh_infantry_officer_p";
icon = "iconManOfficer";
};
class CUP_O_INS_Soldier_AR: CUP_Creatures_Military_CHDKZ_Soldier_05
{
author = "$STR_CUP_AUTHOR_STRING";
scope = 2;
scopeCurator = 2;
displayName = "Automatic Rifleman";
backpack = "CUP_B_INS_Backpack_AR";
accuracy = 3.7;
cost = 80000;
weapons[] = {"hlc_rifle_rpk74n","Throw","Put"};
respawnWeapons[] = {"hlc_rifle_rpk74n","Throw","Put"};
magazines[] = {"hlc_45Rnd_545x39_t_rpk","hlc_45Rnd_545x39_t_rpk","CUP_HandGrenade_RGD5","CUP_HandGrenade_RGD5","SmokeShell","SmokeShell","hlc_45Rnd_545x39_t_rpk","hlc_45Rnd_545x39_t_rpk","hlc_45Rnd_545x39_t_rpk"};
respawnMagazines[] = {"hlc_45Rnd_545x39_t_rpk","hlc_45Rnd_545x39_t_rpk","CUP_HandGrenade_RGD5","CUP_HandGrenade_RGD5","SmokeShell","SmokeShell","hlc_45Rnd_545x39_t_rpk","hlc_45Rnd_545x39_t_rpk","hlc_45Rnd_545x39_t_rpk"};
linkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig","CUP_H_ChDKZ_Beanie"};
respawnLinkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig","CUP_H_ChDKZ_Beanie"};
Items[] = {"FirstAidKit"};
RespawnItems[] = {"FirstAidKit"};
class SpeechVariants
{
class Default
{
speechSingular[] = {"veh_infantry_MG_s"};
speechPlural[] = {"veh_infantry_MG_p"};
};
};
textSingular = "$STR_A3_nameSound_veh_infantry_MG_s";
textPlural = "$STR_A3_nameSound_veh_infantry_MG_p";
nameSound = "veh_infantry_MG_s";
icon = "iconManMG";
};
class CUP_O_INS_Soldier_MG;
class CUP_O_INS_Soldier_AT: CUP_Creatures_Military_CHDKZ_Soldier_04
{
author = "$STR_CUP_AUTHOR_STRING";
scope = 2;
scopeCurator = 2;
displayName = "AT Specialist";
backpack = "CUP_B_INS_RPG_Backpack";
accuracy = 3.5;
camouflage = 1.6;
threat[] = {1,0.9,0.1};
cost = 120000;
weapons[] = {"hlc_rifle_akm","CUP_launch_RPG7V_PGO7V","Throw","Put"};
respawnWeapons[] = {"hlc_rifle_akm","CUP_launch_RPG7V_PGO7V","Throw","Put"};
magazines[] = {"hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","CUP_PG7VL_M"};
respawnMagazines[] = {"hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","CUP_PG7VL_M"};
linkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig","CUP_H_ChDKZ_Beanie"};
respawnLinkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig","CUP_H_ChDKZ_Beanie"};
Items[] = {"FirstAidKit"};
RespawnItems[] = {"FirstAidKit"};
class SpeechVariants
{
class Default
{
speechSingular[] = {"veh_infantry_AT_s"};
speechPlural[] = {"veh_infantry_AT_p"};
};
};
textSingular = "$STR_A3_nameSound_veh_infantry_AT_s";
textPlural = "$STR_A3_nameSound_veh_infantry_AT_p";
nameSound = "veh_infantry_AT_s";
icon = "iconManAT";
};
class CUP_O_INS_Soldier_AA: CUP_Creatures_Military_CHDKZ_Soldier_05
{
author = "$STR_CUP_AUTHOR_STRING";
scope = 2;
scopeCurator = 2;
displayName = "AA Specialist";
accuracy = 3.5;
camouflage = 1.7;
threat[] = {1,0.5,0.9};
cost = 100000;
weapons[] = {"hlc_rifle_akm","CUP_launch_9K32Strela","Throw","Put"};
respawnWeapons[] = {"hlc_rifle_akm","CUP_launch_9K32Strela","Throw","Put"};
magazines[] = {"hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","CUP_Strela_2_M"};
respawnMagazines[] = {"hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","CUP_Strela_2_M"};
linkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig","CUP_H_ChDKZ_Beanie"};
respawnLinkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig","CUP_H_ChDKZ_Beanie"};
Items[] = {"FirstAidKit"};
RespawnItems[] = {"FirstAidKit"};
class SpeechVariants
{
class Default
{
speechSingular[] = {"veh_infantry_AT_s"};
speechPlural[] = {"veh_infantry_AT_p"};
};
};
textSingular = "$STR_A3_nameSound_veh_infantry_AT_s";
textPlural = "$STR_A3_nameSound_veh_infantry_AT_p";
nameSound = "veh_infantry_AT_s";
icon = "iconManAT";
};
class CUP_O_INS_Sniper: CUP_Creatures_Military_CHDKZ_Soldier_08
{
author = "$STR_CUP_AUTHOR_STRING";
scope = 2;
scopeCurator = 2;
displayName = "Sniper";
accuracy = 3.9;
camouflage = 0.5;
threat[] = {1,0.1,0.1};
cost = 250000;
weapons[] = {"CUP_srifle_SVD_pso","Throw","Put","Binocular"};
respawnWeapons[] = {"CUP_srifle_SVD_pso","Throw","Put","Binocular"};
magazines[] = {"CUP_10Rnd_762x54_SVD_M","CUP_10Rnd_762x54_SVD_M","CUP_10Rnd_762x54_SVD_M","CUP_10Rnd_762x54_SVD_M","CUP_10Rnd_762x54_SVD_M","CUP_10Rnd_762x54_SVD_M","CUP_10Rnd_762x54_SVD_M","CUP_10Rnd_762x54_SVD_M","CUP_HandGrenade_RGD5","CUP_HandGrenade_RGD5","SmokeShell","SmokeShellOrange"};
respawnMagazines[] = {"CUP_10Rnd_762x54_SVD_M","CUP_10Rnd_762x54_SVD_M","CUP_10Rnd_762x54_SVD_M","CUP_10Rnd_762x54_SVD_M","CUP_10Rnd_762x54_SVD_M","CUP_10Rnd_762x54_SVD_M","CUP_10Rnd_762x54_SVD_M","CUP_10Rnd_762x54_SVD_M","CUP_HandGrenade_RGD5","CUP_HandGrenade_RGD5","SmokeShell","SmokeShellOrange"};
linkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig","G_Balaclava_oli"};
respawnLinkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig","G_Balaclava_oli"};
Items[] = {"FirstAidKit"};
RespawnItems[] = {"FirstAidKit"};
class SpeechVariants
{
class Default
{
speechSingular[] = {"veh_infantry_sniper_s"};
speechPlural[] = {"veh_infantry_sniper_p"};
};
};
textSingular = "$STR_A3_nameSound_veh_infantry_sniper_s";
textPlural = "$STR_A3_nameSound_veh_infantry_sniper_p";
nameSound = "veh_infantry_sniper_s";
};
class CUP_O_INS_Soldier_Exp: CUP_Creatures_Military_CHDKZ_Soldier_04
{
author = "$STR_CUP_AUTHOR_STRING";
scope = 2;
scopeCurator = 2;
displayName = "Sapper";
backpack = "CUP_B_INS_AlicePack_Mines";
camouflage = 1;
accuracy = 3.9;
cost = 45000;
canDeactivateMines = 1;
detectSkill = 80;
weapons[] = {"hlc_rifle_akm","Throw","Put"};
respawnWeapons[] = {"hlc_rifle_akm","Throw","Put"};
magazines[] = {"hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","CUP_HandGrenade_RGD5","CUP_HandGrenade_RGD5"};
respawnMagazines[] = {"hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","CUP_HandGrenade_RGD5","CUP_HandGrenade_RGD5"};
linkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig","CUP_H_ChDKZ_Beanie"};
respawnLinkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig","CUP_H_ChDKZ_Beanie"};
Items[] = {"FirstAidKit"};
RespawnItems[] = {"FirstAidKit"};
icon = "iconManEngineer";
};
class CUP_O_INS_Story_Lopotev: CUP_O_INS_Commander
{
author = "$STR_CUP_AUTHOR_STRING";
scope = 2;
scopeCurator = 2;
displayName = "Boss";
model = "\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\CUP_Ins_Lopotev.p3d";
uniformClass = "CUP_U_O_CHDKZ_Lopotev";
hiddenSelectionsTextures[] = {"\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\data\ins_lopotev_co.paa"};
accuracy = 1000;
weapons[] = {"hlc_rifle_G36C","Binocular","Throw","Put","CUP_hgun_Makarov"};
respawnWeapons[] = {"hlc_rifle_G36C","Binocular","Throw","Put","CUP_hgun_Makarov"};
magazines[] = {"hlc_30rnd_556x45_EPR_G36","hlc_30rnd_556x45_EPR_G36","hlc_30rnd_556x45_EPR_G36","CUP_8Rnd_9x18_Makarov_M","CUP_8Rnd_9x18_Makarov_M","CUP_8Rnd_9x18_Makarov_M","CUP_8Rnd_9x18_Makarov_M"};
respawnMagazines[] = {"hlc_30rnd_556x45_EPR_G36","hlc_30rnd_556x45_EPR_G36","hlc_30rnd_556x45_EPR_G36","CUP_8Rnd_9x18_Makarov_M","CUP_8Rnd_9x18_Makarov_M","CUP_8Rnd_9x18_Makarov_M","CUP_8Rnd_9x18_Makarov_M"};
cost = 600000;
linkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","ItemGPS"};
respawnLinkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","ItemGPS"};
Items[] = {"FirstAidKit"};
RespawnItems[] = {"FirstAidKit"};
class SpeechVariants
{
class Default
{
speechSingular[] = {"veh_infantry_officer_s"};
speechPlural[] = {"veh_infantry_officer_p"};
};
};
textSingular = "$STR_A3_nameSound_veh_infantry_officer_s";
textPlural = "$STR_A3_nameSound_veh_infantry_officer_p";
icon = "iconManOfficer";
};
class CUP_O_INS_Crew: CUP_Creatures_Military_CHDKZ_Soldier_06
{
author = "$STR_CUP_AUTHOR_STRING";
scope = 2;
scopeCurator = 2;
displayName = "Crewman";
accuracy = 3.4;
camouflage = 1.4;
cost = 20000;
weapons[] = {"hlc_rifle_aks74u","Throw","Put"};
respawnWeapons[] = {"hlc_rifle_aks74u","Throw","Put"};
magazines[] = {"hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","CUP_HandGrenade_RGD5","CUP_HandGrenade_RGD5"};
respawnMagazines[] = {"hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","CUP_HandGrenade_RGD5","CUP_HandGrenade_RGD5"};
linkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig_Light","CUP_H_TK_TankerHelmet","CUP_NVG_PVS7"};
respawnLinkedItems[] = {"ItemRadio","ItemWatch","ItemCompass","ItemMap","CUP_V_O_Ins_Carrier_Rig_Light","CUP_H_TK_TankerHelmet","CUP_NVG_PVS7"};
Items[] = {"FirstAidKit"};
RespawnItems[] = {"FirstAidKit"};
};
class CUP_O_INS_Pilot: CUP_Creatures_Military_CHDKZ_Soldier_12
{
author = "$STR_CUP_AUTHOR_STRING";
scope = 2;
scopeCurator = 2;
displayName = "Pilot";
class SpeechVariants
{
class Default
{
speechSingular[] = {"veh_infantry_pilot_s"};
speechPlural[] = {"veh_infantry_pilot_p"};
};
};
textSingular = "$STR_A3_nameSound_veh_infantry_pilot_s";
textPlural = "$STR_A3_nameSound_veh_infantry_pilot_p";
nameSound = "veh_infantry_pilot_s";
accuracy = 3.2;
camouflage = 0.8;
cost = 20000;
weapons[] = {"hlc_rifle_aks74u","Throw","Put"};
respawnWeapons[] = {"hlc_rifle_aks74u","Throw","Put"};
magazines[] = {"hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","SmokeShellOrange","SmokeShellBlue"};
respawnMagazines[] = {"hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","hlc_30Rnd_545x39_B_AK","SmokeShellOrange","SmokeShellBlue"};
uniformClass = "CUP_U_O_Pilot_01";
linkedItems[] = {"H_Cap_headphones","ItemWatch"};
respawnLinkedItems[] = {"H_Cap_headphones","ItemWatch"};
};
class CUP_O_INS_Worker2: CUP_Creatures_Military_CHDKZ_Soldier_13
{
author = "$STR_CUP_AUTHOR_STRING";
scope = 2;
scopeCurator = 2;
accuracy = 3.9;
vehicleClass = "CUP_O_Men_ChDKZ_GUER";
editorSubcategory = "CUP_EdSubcat_Personel_Chedaki_ArmedCiv";
displayName = "Local";
uniformClass = "CUP_U_O_Worker_02";
weapons[] = {"hlc_rifle_akm","Throw","Put"};
respawnWeapons[] = {"hlc_rifle_akm","Throw","Put"};
magazines[] = {"hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak"};
respawnMagazines[] = {"hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak"};
icon = "iconMan";
linkedItems[] = {"CUP_H_C_Beanie_02","ItemWatch","ItemMap","ItemCompass"};
respawnlinkedItems[] = {"CUP_H_C_Beanie_02","ItemWatch","ItemMap","ItemCompass"};
};
class CUP_O_INS_Woodlander1: CUP_Creatures_Military_CHDKZ_Soldier_14
{
author = "$STR_CUP_AUTHOR_STRING";
scope = 2;
scopeCurator = 2;
accuracy = 3.9;
vehicleClass = "CUP_O_Men_ChDKZ_GUER";
editorSubcategory = "CUP_EdSubcat_Personel_Chedaki_ArmedCiv";
displayName = "Woodman";
uniformClass = "CUP_U_O_Woodlander_01";
weapons[] = {"hlc_rifle_akm","Throw","Put"};
respawnWeapons[] = {"hlc_rifle_akm","Throw","Put"};
magazines[] = {"hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak"};
respawnMagazines[] = {"hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak"};
icon = "iconMan";
linkedItems[] = {"CUP_H_C_Ushanka_01","ItemWatch","ItemMap","ItemCompass"};
respawnlinkedItems[] = {"CUP_H_C_Ushanka_01","ItemWatch","ItemMap","ItemCompass"};
};
class CUP_O_INS_Woodlander2: CUP_Creatures_Military_CHDKZ_Soldier_15
{
author = "$STR_CUP_AUTHOR_STRING";
scope = 2;
scopeCurator = 2;
accuracy = 3.9;
vehicleClass = "CUP_O_Men_ChDKZ_GUER";
editorSubcategory = "CUP_EdSubcat_Personel_Chedaki_ArmedCiv";
displayName = "Gamekeeper";
uniformClass = "CUP_U_O_Woodlander_02";
weapons[] = {"CUP_srifle_CZ550","Throw","Put"};
respawnWeapons[] = {"CUP_srifle_CZ550","Throw","Put"};
magazines[] = {"CUP_5x_22_LR_17_HMR_M","CUP_5x_22_LR_17_HMR_M","CUP_5x_22_LR_17_HMR_M","CUP_5x_22_LR_17_HMR_M"};
respawnMagazines[] = {"CUP_5x_22_LR_17_HMR_M","CUP_5x_22_LR_17_HMR_M","CUP_5x_22_LR_17_HMR_M","CUP_5x_22_LR_17_HMR_M"};
icon = "iconMan";
linkedItems[] = {"CUP_H_C_Ushanka_02","ItemWatch","ItemMap","ItemCompass"};
respawnlinkedItems[] = {"CUP_H_C_Ushanka_02","ItemWatch","ItemMap","ItemCompass"};
};
class CUP_O_INS_Woodlander3: CUP_Creatures_Military_CHDKZ_Soldier_16
{
author = "$STR_CUP_AUTHOR_STRING";
scope = 2;
scopeCurator = 2;
accuracy = 3.9;
vehicleClass = "CUP_O_Men_ChDKZ_GUER";
editorSubcategory = "CUP_EdSubcat_Personel_Chedaki_ArmedCiv";
displayName = "Forester";
uniformClass = "CUP_U_O_Woodlander_03";
weapons[] = {"hlc_rifle_ak47","Throw","Put"};
respawnWeapons[] = {"hlc_rifle_ak47","Throw","Put"};
magazines[] = {"hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak"};
respawnMagazines[] = {"hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak","hlc_30Rnd_762x39_b_ak"};
icon = "iconMan";
linkedItems[] = {"CUP_H_C_Ushanka_03","ItemWatch","ItemMap","ItemCompass"};
respawnlinkedItems[] = {"CUP_H_C_Ushanka_03","ItemWatch","ItemMap","ItemCompass"};
};
class CUP_O_INS_Villager3: CUP_Creatures_Military_CHDKZ_Soldier_17
{
author = "$STR_CUP_AUTHOR_STRING";
scope = 2;
scopeCurator = 2;
accuracy = 3.9;
vehicleClass = "CUP_O_Men_ChDKZ_GUER";
editorSubcategory = "CUP_EdSubcat_Personel_Chedaki_ArmedCiv";
displayName = "Farmer";
uniformClass = "CUP_U_O_Villager_03";
weapons[] = {"CUP_srifle_CZ550","Throw","Put"};
respawnWeapons[] = {"CUP_srifle_CZ550","Throw","Put"};
magazines[] = {"CUP_5x_22_LR_17_HMR_M","CUP_5x_22_LR_17_HMR_M","CUP_5x_22_LR_17_HMR_M","CUP_5x_22_LR_17_HMR_M"};
respawnMagazines[] = {"CUP_5x_22_LR_17_HMR_M","CUP_5x_22_LR_17_HMR_M","CUP_5x_22_LR_17_HMR_M","CUP_5x_22_LR_17_HMR_M"};
icon = "iconMan";
linkedItems[] = {"CUP_H_C_Beret_03","ItemWatch","ItemMap","ItemCompass"};
respawnlinkedItems[] = {"CUP_H_C_Beret_03","ItemWatch","ItemMap","ItemCompass"};
};
class CUP_O_INS_Villager4: CUP_Creatures_Military_CHDKZ_Soldier_18
{
author = "$STR_CUP_AUTHOR_STRING";
scope = 2;
scopeCurator = 2;
accuracy = 3.9;
vehicleClass = "CUP_O_Men_ChDKZ_GUER";
editorSubcategory = "CUP_EdSubcat_Personel_Chedaki_ArmedCiv";
displayName = "Villager";
uniformClass = "CUP_U_O_Villager_04";
weapons[] = {"CUP_srifle_CZ550","Throw","Put"};
respawnWeapons[] = {"CUP_srifle_CZ550","Throw","Put"};
magazines[] = {"CUP_5x_22_LR_17_HMR_M","CUP_5x_22_LR_17_HMR_M","CUP_5x_22_LR_17_HMR_M","CUP_5x_22_LR_17_HMR_M"};
respawnMagazines[] = {"CUP_5x_22_LR_17_HMR_M","CUP_5x_22_LR_17_HMR_M","CUP_5x_22_LR_17_HMR_M","CUP_5x_22_LR_17_HMR_M"};
icon = "iconMan";
linkedItems[] = {"CUP_H_C_Beret_04","ItemWatch","ItemMap","ItemCompass"};
respawnlinkedItems[] = {"CUP_H_C_Beret_04","ItemWatch","ItemMap","ItemCompass"};
};
};
class cfgWeapons
{
class InventoryItem_Base_F;
class ItemCore;
class VestItem: InventoryItem_Base_F
{
type = 701;
hiddenSelections[] = {};
armor = "5*0";
passThrough = 1;
hitpointName = "HitBody";
};
class CUP_Vest_Ins_Camo_Base: ItemCore
{
scope = 0;
allowedSlots[] = {901};
hiddenSelections[] = {"camo1","camo2"};
class ItemInfo: VestItem
{
hiddenSelections[] = {"camo1","camo2"};
armor = 0;
passThrough = 1;
mass = 0;
containerClass = "Supply0";
class HitpointsProtectionInfo
{
class Body
{
hitpointName = "HitBody";
armor = 0;
passThrough = 1;
};
};
};
};
class CUP_V_O_Ins_Carrier_Rig: CUP_Vest_Ins_Camo_Base
{
scope = 1;
};
class CUP_V_O_Ins_Carrier_Rig_ARM: CUP_Vest_Ins_Camo_Base
{
scope = 2;
dlc = "CUP_Units";
author = "$STR_CUP_AUTHOR_STRING";
displayName = "Pouch Carrier Rig";
picture = "\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\data\ui\icon_v_pouch_carrier_MG_ca.paa";
model = "\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\CUP_Ins_Vest1.p3d";
hiddenSelectionsTextures[] = {"\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\data\lifcik_body_1_co.paa","\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\data\equip_co.paa"};
class ItemInfo: ItemInfo
{
hiddenSelectionsTextures[] = {"\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\data\lifcik_body_1_co.paa","\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\data\equip_co.paa"};
uniformModel = "\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\CUP_Ins_Vest1.p3d";
containerClass = "Supply140";
mass = 80;
class HitpointsProtectionInfo
{
class Chest
{
HitpointName="HitChest";
armor=16;
PassThrough=0.30000001;
};
class Diaphragm
{
HitpointName="HitDiaphragm";
armor=16;
PassThrough=0.30000001;
};
class Abdomen
{
hitpointName="HitAbdomen";
armor=16;
passThrough=0.30000001;
};
class Body
{
hitpointName="HitBody";
armor=16;
passThrough=0.30000001;
};
};
};
};
class CUP_V_O_Ins_Carrier_Rig_MG: CUP_Vest_Ins_Camo_Base
{
scope = 1;
};
class CUP_V_O_Ins_Carrier_Rig_MG_ARM: CUP_Vest_Ins_Camo_Base
{
scope = 2;
dlc = "CUP_Units";
author = "$STR_CUP_AUTHOR_STRING";
displayName = "Pouch Carrier Rig (MG)";
picture = "\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\data\ui\icon_v_pouch_carrier_ca.paa";
model = "\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\CUP_Ins_Vest2.p3d";
hiddenSelectionsTextures[] = {"\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\data\smersh_body_1_co.paa","\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\data\equip_co.paa"};
class ItemInfo: ItemInfo
{
hiddenSelectionsTextures[] = {"\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\data\smersh_body_1_co.paa","\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\data\equip_co.paa"};
uniformModel = "\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\CUP_Ins_Vest2.p3d";
containerClass = "Supply140";
mass = 80;
class HitpointsProtectionInfo
{
class Chest
{
HitpointName="HitChest";
armor=16;
PassThrough=0.30000001;
};
class Diaphragm
{
HitpointName="HitDiaphragm";
armor=16;
PassThrough=0.30000001;
};
class Abdomen
{
hitpointName="HitAbdomen";
armor=16;
passThrough=0.30000001;
};
class Body
{
hitpointName="HitBody";
armor=16;
passThrough=0.30000001;
};
};
};
};
class CUP_V_O_Ins_Carrier_Rig_Com: CUP_Vest_Ins_Camo_Base
{
scope = 1;
};
class CUP_V_O_Ins_Carrier_Rig_Com_ARM: CUP_Vest_Ins_Camo_Base
{
scope = 2;
dlc = "CUP_Units";
author = "$STR_CUP_AUTHOR_STRING";
displayName = "Pouch Carrier Rig (Commander)";
picture = "\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\data\ui\icon_v_pouch_carrier_ca.paa";
model = "\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\CUP_Ins_Vest3.p3d";
hiddenSelectionsTextures[] = {"\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\data\smersh_body_1_co.paa","\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\data\equip_co.paa"};
class ItemInfo: ItemInfo
{
hiddenSelectionsTextures[] = {"\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\data\smersh_body_1_co.paa","\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\data\equip_co.paa"};
uniformModel = "\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\CUP_Ins_Vest3.p3d";
containerClass = "Supply140";
mass = 80;
class HitpointsProtectionInfo
{
class Chest
{
HitpointName="HitChest";
armor=16;
PassThrough=0.30000001;
};
class Diaphragm
{
HitpointName="HitDiaphragm";
armor=16;
PassThrough=0.30000001;
};
class Abdomen
{
hitpointName="HitAbdomen";
armor=16;
passThrough=0.30000001;
};
class Body
{
hitpointName="HitBody";
armor=16;
passThrough=0.30000001;
};
};
};
};
class CUP_V_O_Ins_Carrier_Rig_Light: CUP_Vest_Ins_Camo_Base
{
scope = 1;
};
class CUP_V_O_Ins_Carrier_Rig_Light_ARM: CUP_Vest_Ins_Camo_Base
{
scope = 2;
dlc = "CUP_Units";
author = "$STR_CUP_AUTHOR_STRING";
displayName = "Pouch Carrier Rig (Light)";
picture = "\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\data\ui\icon_v_pouch_carrier_ca.paa";
model = "\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\CUP_Ins_Vest4.p3d";
hiddenSelectionsTextures[] = {"\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\data\smersh_body_1_co.paa","\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\data\equip_co.paa"};
class ItemInfo: ItemInfo
{
hiddenSelectionsTextures[] = {"\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\data\smersh_body_1_co.paa","\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\data\equip_co.paa"};
uniformModel = "\CUP\Creatures\People\Military\CUP_Creatures_People_Military_Chedaki\CUP_Ins_Vest4.p3d";
containerClass = "Supply140";
mass = 80;
class HitpointsProtectionInfo
{
class Chest
{
HitpointName="HitChest";
armor=16;
PassThrough=0.30000001;
};
class Diaphragm
{
HitpointName="HitDiaphragm";
armor=16;
PassThrough=0.30000001;
};
class Abdomen
{
hitpointName="HitAbdomen";
armor=16;
passThrough=0.30000001;
};
class Body
{
hitpointName="HitBody";
armor=16;
passThrough=0.30000001;
};
};
};
};
};
| [
"cwood686@gmail.com"
] | cwood686@gmail.com |
f1272badf10cae1e941607311e9fb4f16587966e | babd69100be262a90a8ba657f258e22ccd1cda8a | /libraries/protocol/smt_util.cpp | dd5449d1b34dab5703f861620bb96047504c05cc | [
"LicenseRef-scancode-warranty-disclaimer",
"MIT"
] | permissive | abitmore/steem | 675f556ec667e0d333dffb636fc15d76e441f459 | 8d26f079e4d9b42225e1576064a8b28fe330f955 | refs/heads/master | 2022-06-25T09:39:54.590538 | 2022-06-17T06:39:39 | 2022-06-17T06:39:39 | 55,368,956 | 2 | 0 | NOASSERTION | 2022-06-18T07:16:08 | 2016-04-03T21:05:18 | C++ | UTF-8 | C++ | false | false | 4,236 | cpp | #include <steem/protocol/smt_util.hpp>
#include <steem/protocol/authority.hpp>
namespace steem { namespace protocol { namespace smt {
namespace unit_target {
bool is_contributor( const unit_target_type& unit_target )
{
return unit_target == SMT_DESTINATION_FROM || unit_target == SMT_DESTINATION_FROM_VESTING;
}
bool is_market_maker( const unit_target_type& unit_target )
{
return unit_target == SMT_DESTINATION_MARKET_MAKER;
}
bool is_rewards( const unit_target_type& unit_target )
{
return unit_target == SMT_DESTINATION_REWARDS;
}
bool is_founder_vesting( const unit_target_type& unit_target )
{
std::string unit_target_str = unit_target;
if ( unit_target_str.size() > std::strlen( SMT_DESTINATION_ACCOUNT_PREFIX ) + std::strlen( SMT_DESTINATION_VESTING_SUFFIX ) )
{
auto pos = unit_target_str.find( SMT_DESTINATION_ACCOUNT_PREFIX );
if ( pos != std::string::npos && pos == 0 )
{
std::size_t suffix_len = std::strlen( SMT_DESTINATION_VESTING_SUFFIX );
if ( !unit_target_str.compare( unit_target_str.size() - suffix_len, suffix_len, SMT_DESTINATION_VESTING_SUFFIX ) )
{
return true;
}
}
}
return false;
}
bool is_vesting( const unit_target_type& unit_target )
{
return unit_target == SMT_DESTINATION_VESTING;
}
bool is_account_name_type( const unit_target_type& unit_target )
{
if ( is_contributor( unit_target ) )
return false;
if ( is_rewards( unit_target ) )
return false;
if ( is_market_maker( unit_target ) )
return false;
if ( is_vesting( unit_target ) )
return false;
return true;
}
bool is_vesting_type( const unit_target_type& unit_target )
{
if ( unit_target == SMT_DESTINATION_FROM_VESTING )
return true;
if ( unit_target == SMT_DESTINATION_VESTING )
return true;
if ( is_founder_vesting( unit_target ) )
return true;
return false;
}
account_name_type get_unit_target_account( const unit_target_type& unit_target )
{
FC_ASSERT( !is_contributor( unit_target ), "Cannot derive an account name from a contributor special destination." );
FC_ASSERT( !is_market_maker( unit_target ), "The market maker unit target is not a valid account." );
FC_ASSERT( !is_rewards( unit_target ), "The rewards unit target is not a valid account." );
if ( is_valid_account_name( unit_target ) )
return account_name_type( unit_target );
// This is a special unit target destination in the form of $alice.vesting
FC_ASSERT( unit_target.size() > std::strlen( SMT_DESTINATION_ACCOUNT_PREFIX ) + std::strlen( SMT_DESTINATION_VESTING_SUFFIX ),
"Unit target '${target}' is malformed", ("target", unit_target) );
std::string str_name = unit_target;
auto pos = str_name.find( SMT_DESTINATION_ACCOUNT_PREFIX );
FC_ASSERT( pos != std::string::npos && pos == 0, "Expected SMT destination account prefix '${prefix}' for unit target '${target}'.",
("prefix", SMT_DESTINATION_ACCOUNT_PREFIX)("target", unit_target) );
std::size_t suffix_len = std::strlen( SMT_DESTINATION_VESTING_SUFFIX );
FC_ASSERT( !str_name.compare( str_name.size() - suffix_len, suffix_len, SMT_DESTINATION_VESTING_SUFFIX ),
"Expected SMT destination vesting suffix '${suffix}' for unit target '${target}'.",
("suffix", SMT_DESTINATION_VESTING_SUFFIX)("target", unit_target) );
std::size_t prefix_len = std::strlen( SMT_DESTINATION_ACCOUNT_PREFIX );
account_name_type unit_target_account = str_name.substr( prefix_len, str_name.size() - suffix_len - prefix_len );
FC_ASSERT( is_valid_account_name( unit_target_account ), "The derived unit target account name '${name}' is invalid.",
("name", unit_target_account) );
return unit_target_account;
}
bool is_valid_emissions_destination( const unit_target_type& unit_target )
{
if ( is_market_maker( unit_target ) )
return true;
if ( is_rewards( unit_target ) )
return true;
if ( is_vesting( unit_target ) )
return true;
if ( is_valid_account_name( unit_target ) )
return true;
if ( is_founder_vesting( unit_target ) )
return true;
return false;
}
} // steem::protocol::smt::unit_target
} } } // steem::protocol::smt
| [
"steve@gerbino.co"
] | steve@gerbino.co |
b543be5cbb792323a2ccbf22d258dda6e51c9614 | 25c8f5b23064485434e3b8b8500416634d01534c | /framework/src/gmsec/internal/RequestDispatcher.cpp | b3bdd043702fc5e6a882101a53c05634ddd38b8f | [] | no_license | jcowan96/GMSEC_API_UE4 | e725251c8cd37b7cd90145cc94eeb2f06f90316a | 6bbcfea64b0dc17cdb8a91dd9f6fc8ac69e84558 | refs/heads/master | 2020-03-26T12:19:41.140015 | 2018-08-15T18:27:21 | 2018-08-15T18:27:21 | 144,886,916 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,197 | cpp |
/*
* Copyright 2007-2018 United States Government as represented by the
* Administrator of The National Aeronautics and Space Administration.
* No copyright is claimed in the United States under Title 17, U.S. Code.
* All Rights Reserved.
*/
/**
* @file RequestDispatcher.cpp
*
* This file contains the Dispatcher class for Request messages.
*
*
*/
#include <gmsec/internal/RequestDispatcher.h>
#include <gmsec/internal/BaseConnection.h>
#include <gmsec/Message.h>
#include <gmsec/Callback.h>
#include <gmsec/ReplyCallback.h>
namespace gmsec
{
namespace internal
{
RequestDispatcher::RequestDispatcher()
:
gmsec::util::Thread(true),
fConn(NULL),
fRequest(NULL),
fReply(NULL),
fRCallbk(NULL),
fCallbk(NULL),
fTimeout(GMSEC_WAIT_FOREVER),
fRunning(false),
mAlive(true)
{
setName("RequestDispatcher");
}
RequestDispatcher::~RequestDispatcher()
{
}
bool RequestDispatcher::init(BaseConnection *conn, Message *req, GMSEC_I32 timeout, Callback *cb)
{
if ((fRunning == false) &&
(conn != NULL) &&
(req != NULL) &&
(cb != NULL))
{
fConn = conn;
fCallbk = cb;
fTimeout = timeout;
fStatus = fConn->CloneMessage(req,fRequest);
return true;
}
return false;
}
bool RequestDispatcher::init(BaseConnection *conn, Message *req, GMSEC_I32 timeout, ReplyCallback *cb)
{
if ((fRunning == false) &&
(conn != NULL) &&
(req != NULL) &&
(cb != NULL))
{
fConn = conn;
fRCallbk = cb;
fTimeout = timeout;
fStatus = fConn->CloneMessage(req,fRequest);
return true;
}
return false;
}
void RequestDispatcher::run()
{
Status result;
fRunning = true;
bool waitForever = false;
bool timeOut = true;
fStatus.ReSet();
fRunning = true;
GMSEC_I32 republish = BaseConnection::REPUBLISH_NEVER;
/* If the timeout is negative, just run forever */
if (fTimeout < 0)
waitForever = true;
while (mAlive && (fTimeout > 0 || waitForever))
{
fReply = NULL;
/* To avoid a thread lock, we check the m_alive */
/* variable every 250 millisecond */
fStatus = fConn->Request(fRequest, 250, fReply, republish);
if (!waitForever)
fTimeout -= 250;
if (fCallbk != NULL)
{
if (!fStatus.isError())
{
ConnectionBuddy extconn(fConn);
fCallbk->OnMessage(extconn.ptr(), fReply);
// clean up reply
fConn->DestroyMessage(fReply);
fReply = NULL;
timeOut = false;
break;
}
}
else if (fRCallbk != NULL)
{
if (fReply != NULL)
{
ConnectionBuddy extconn(fConn);
fRCallbk->OnReply(extconn.ptr(), fRequest, fReply);
fConn->DestroyMessage(fReply);
fReply = NULL;
timeOut = false;
break;
}
}
}
/* If there was an error and the thread hasn't been destroyed */
if (mAlive && timeOut)
{
if (fRCallbk != NULL)
{
ConnectionBuddy extconn(fConn);
fRCallbk->OnError(extconn.ptr(), fRequest, &fStatus, GMSEC_CONNECTION_REQUEST_TIMEOUT);
}
fConn->DispatchError(GMSEC_CONNECTION_REQUEST_TIMEOUT,fRequest,&fStatus);
}
// clean up request
fConn->DestroyMessage(fRequest);
fRequest = NULL;
fRunning = false;
}
void RequestDispatcher::destroy()
{
mAlive = false;
}
} // namespace internal
} // namespace gmsec
| [
"jmcowan@ndc.nasa.gov"
] | jmcowan@ndc.nasa.gov |
228f8a1f56fbf5e6585feaafa7ff56b7b510839b | e6b96681b393ae335f2f7aa8db84acc65a3e6c8d | /atcoder.jp/tenka1-2013-qualb/tenka1_2013_qualB_e/Main.cpp | cd2e4840a490a0a2a5a5d358742ae925713392a4 | [] | no_license | okuraofvegetable/AtCoder | a2e92f5126d5593d01c2c4d471b1a2c08b5d3a0d | dd535c3c1139ce311503e69938611f1d7311046d | refs/heads/master | 2022-02-21T15:19:26.172528 | 2021-03-27T04:04:55 | 2021-03-27T04:04:55 | 249,614,943 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 770 | cpp | #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
cout <<5<<endl;
cout << 4<<' '<< 6<<endl;
cout << 2<<' '<< 5<<endl;
cout << 6<<' '<< 10<<endl;
cout << 1<<' '<< 2<<endl;
cout << 1<<' '<< 6<<endl;
return 0;
}
| [
"okuraofvegetable@gmail.com"
] | okuraofvegetable@gmail.com |
ad6fcd3e48c546b685ba603cf947dbf4e7957f50 | 7707149b6bdb0a726bc8b06503a6b6613af3edda | /projects/MonkVG-iOS/transform.cpp | 725a41a42a0f6833e80dd884d2275d5c64b5deb7 | [
"BSD-3-Clause"
] | permissive | adozenlines/MonkVG | 30124149828656ba96e081a0a2ba1ed2e8815f3f | 734685482990bc74ddae74a97c073bcbf05d2133 | refs/heads/master | 2020-05-20T12:41:18.734344 | 2015-07-30T20:24:18 | 2015-07-30T20:24:18 | 39,282,368 | 1 | 3 | null | 2015-07-18T01:27:46 | 2015-07-18T01:27:45 | null | UTF-8 | C++ | false | false | 12,726 | cpp | #include "transform.hpp"
#include "view.hpp"
#include "constants.hpp"
#include "mat4.hpp"
#include "math.hpp"
#include "unitbezier.hpp"
#include "interpolate.hpp"
#include "platform.hpp"
#include <cstdio>
using namespace MonkVG;
/** Converts the given angle (in radians) to be numerically close to the anchor angle, allowing it to be interpolated properly without sudden jumps. */
static double _normalizeAngle(double angle, double anchorAngle)
{
angle = util::wrap(angle, -M_PI, M_PI);
if (angle == -M_PI) angle = M_PI;
double diff = std::abs(angle - anchorAngle);
if (std::abs(angle - util::M2PI - anchorAngle) < diff) {
angle -= util::M2PI;
}
if (std::abs(angle + util::M2PI - anchorAngle) < diff) {
angle += util::M2PI;
}
return angle;
}
Transform::Transform(const View &view_)
: view(view_)
{
}
#pragma mark - Map View
bool Transform::resize(const std::array<uint16_t, 2> size) {
if (state.width != size[0] || state.height != size[1]) {
view.notifyMapChange(MapChangeRegionWillChange);
state.width = size[0];
state.height = size[1];
state.constrain(state.scale, state.y);
view.notifyMapChange(MapChangeRegionDidChange);
return true;
} else {
return false;
}
}
#pragma mark - Position
const double Transform::getX()
{
return state.x;
}
const double Transform::getY()
{
return state.y;
}
void Transform::moveBy(const double dx, const double dy, const Duration& duration) {
if (std::isnan(dx) || std::isnan(dy)) {
return;
}
_moveBy(dx, dy, duration);
}
void Transform::_moveBy(const double dx, const double dy, const Duration& duration) {
double x = state.x + std::cos(state.angle) * dx + std::sin( state.angle) * dy;
double y = state.y + std::cos(state.angle) * dy + std::sin(-state.angle) * dx;
state.constrain(state.scale, y);
if (duration == Duration::zero()) {
view.notifyMapChange(MapChangeRegionWillChange);
state.x = x;
state.y = y;
view.notifyMapChange(MapChangeRegionDidChange);
} else {
view.notifyMapChange(MapChangeRegionWillChangeAnimated);
const double startX = state.x;
const double startY = state.y;
state.panning = true;
startTransition(
[=](double t) {
state.x = util::interpolate(startX, x, t);
state.y = util::interpolate(startY, y, t);
view.notifyMapChange(MapChangeRegionIsChanging);
return Update::Nothing;
},
[=] {
state.panning = false;
view.notifyMapChange(MapChangeRegionDidChangeAnimated);
}, duration);
}
}
void Transform::setLatLng(const LatLng latLng, const Duration& duration) {
if (std::isnan(latLng.latitude) || std::isnan(latLng.longitude)) {
return;
}
const double m = 1 - 1e-15;
const double f = std::fmin(std::fmax(std::sin(util::DEG2RAD * latLng.latitude), -m), m);
double xn = -latLng.longitude * state.Bc;
double yn = 0.5 * state.Cc * std::log((1 + f) / (1 - f));
_setScaleXY(state.scale, xn, yn, duration);
}
void Transform::setLatLngZoom(const LatLng latLng, const double zoom, const Duration& duration) {
if (std::isnan(latLng.latitude) || std::isnan(latLng.longitude) || std::isnan(zoom)) {
return;
}
double new_scale = std::pow(2.0, zoom);
const double s = new_scale * util::tileSize;
state.Bc = s / 360;
state.Cc = s / util::M2PI;
const double m = 1 - 1e-15;
const double f = std::fmin(std::fmax(std::sin(util::DEG2RAD * latLng.latitude), -m), m);
double xn = -latLng.longitude * state.Bc;
double yn = 0.5 * state.Cc * std::log((1 + f) / (1 - f));
_setScaleXY(new_scale, xn, yn, duration);
}
#pragma mark - Zoom
void Transform::scaleBy(const double ds, const double cx, const double cy, const Duration& duration) {
if (std::isnan(ds) || std::isnan(cx) || std::isnan(cy)) {
return;
}
// clamp scale to min/max values
double new_scale = state.scale * ds;
if (new_scale < state.min_scale) {
new_scale = state.min_scale;
} else if (new_scale > state.max_scale) {
new_scale = state.max_scale;
}
_setScale(new_scale, cx, cy, duration);
}
void Transform::setScale(const double scale, const double cx, const double cy,
const Duration& duration) {
if (std::isnan(scale) || std::isnan(cx) || std::isnan(cy)) {
return;
}
_setScale(scale, cx, cy, duration);
}
void Transform::setZoom(const double zoom, const Duration& duration) {
if (std::isnan(zoom)) {
return;
}
_setScale(std::pow(2.0, zoom), -1, -1, duration);
}
double Transform::getZoom() const {
return state.getZoom();
}
double Transform::getScale() const {
return state.scale;
}
void Transform::_setScale(double new_scale, double cx, double cy, const Duration& duration) {
// Ensure that we don't zoom in further than the maximum allowed.
if (new_scale < state.min_scale) {
new_scale = state.min_scale;
} else if (new_scale > state.max_scale) {
new_scale = state.max_scale;
}
// Zoom in on the center if we don't have click or gesture anchor coordinates.
if (cx < 0 || cy < 0) {
cx = static_cast<double>(state.width) / 2.0;
cy = static_cast<double>(state.height) / 2.0;
}
// Account for the x/y offset from the center (= where the user clicked or pinched)
const double factor = new_scale / state.scale;
const double dx = (cx - static_cast<double>(state.width) / 2.0) * (1.0 - factor);
const double dy = (cy - static_cast<double>(state.height) / 2.0) * (1.0 - factor);
// Account for angle
const double angle_sin = std::sin(-state.angle);
const double angle_cos = std::cos(-state.angle);
const double ax = angle_cos * dx - angle_sin * dy;
const double ay = angle_sin * dx + angle_cos * dy;
const double xn = state.x * factor + ax;
const double yn = state.y * factor + ay;
_setScaleXY(new_scale, xn, yn, duration);
}
void Transform::_setScaleXY(const double new_scale, const double xn, const double yn,
const Duration& duration) {
double scale = new_scale;
double x = xn;
double y = yn;
state.constrain(scale, y);
if (duration == Duration::zero()) {
view.notifyMapChange(MapChangeRegionWillChange);
state.scale = scale;
state.x = x;
state.y = y;
const double s = state.scale * util::tileSize;
state.Bc = s / 360;
state.Cc = s / util::M2PI;
view.notifyMapChange(MapChangeRegionDidChange);
} else {
view.notifyMapChange(MapChangeRegionWillChangeAnimated);
const double startS = state.scale;
const double startX = state.x;
const double startY = state.y;
state.panning = true;
state.scaling = true;
startTransition(
[=](double t) {
state.scale = util::interpolate(startS, scale, t);
state.x = util::interpolate(startX, x, t);
state.y = util::interpolate(startY, y, t);
const double s = state.scale * util::tileSize;
state.Bc = s / 360;
state.Cc = s / util::M2PI;
view.notifyMapChange(MapChangeRegionIsChanging);
return Update::Zoom;
},
[=] {
state.panning = false;
state.scaling = false;
view.notifyMapChange(MapChangeRegionDidChangeAnimated);
}, duration);
}
}
#pragma mark - Angle
void Transform::rotateBy(const double start_x, const double start_y, const double end_x,
const double end_y, const Duration& duration) {
if (std::isnan(start_x) || std::isnan(start_y) || std::isnan(end_x) || std::isnan(end_y)) {
return;
}
double center_x = static_cast<double>(state.width) / 2.0, center_y = static_cast<double>(state.height) / 2.0;
const double begin_center_x = start_x - center_x;
const double begin_center_y = start_y - center_y;
const double beginning_center_dist =
std::sqrt(begin_center_x * begin_center_x + begin_center_y * begin_center_y);
// If the first click was too close to the center, move the center of rotation by 200 pixels
// in the direction of the click.
if (beginning_center_dist < 200) {
const double offset_x = -200, offset_y = 0;
const double rotate_angle = std::atan2(begin_center_y, begin_center_x);
const double rotate_angle_sin = std::sin(rotate_angle);
const double rotate_angle_cos = std::cos(rotate_angle);
center_x = start_x + rotate_angle_cos * offset_x - rotate_angle_sin * offset_y;
center_y = start_y + rotate_angle_sin * offset_x + rotate_angle_cos * offset_y;
}
const double first_x = start_x - center_x, first_y = start_y - center_y;
const double second_x = end_x - center_x, second_y = end_y - center_y;
const double ang = state.angle + util::angle_between(first_x, first_y, second_x, second_y);
_setAngle(ang, duration);
}
void Transform::setAngle(const double new_angle, const Duration& duration) {
if (std::isnan(new_angle)) {
return;
}
_setAngle(new_angle, duration);
}
void Transform::setAngle(const double new_angle, const double cx, const double cy) {
if (std::isnan(new_angle) || std::isnan(cx) || std::isnan(cy)) {
return;
}
double dx = 0, dy = 0;
if (cx >= 0 && cy >= 0) {
dx = (static_cast<double>(state.width) / 2.0) - cx;
dy = (static_cast<double>(state.height) / 2.0) - cy;
_moveBy(dx, dy, Duration::zero());
}
_setAngle(new_angle, Duration::zero());
if (cx >= 0 && cy >= 0) {
_moveBy(-dx, -dy, Duration::zero());
}
}
void Transform::_setAngle(double new_angle, const Duration& duration) {
double angle = _normalizeAngle(new_angle, state.angle);
state.angle = _normalizeAngle(state.angle, angle);
if (duration == Duration::zero()) {
view.notifyMapChange(MapChangeRegionWillChange);
state.angle = angle;
view.notifyMapChange(MapChangeRegionDidChange);
} else {
view.notifyMapChange(MapChangeRegionWillChangeAnimated);
const double startA = state.angle;
state.rotating = true;
startTransition(
[=](double t) {
state.angle = util::wrap(util::interpolate(startA, angle, t), -M_PI, M_PI);
view.notifyMapChange(MapChangeRegionIsChanging);
return Update::Nothing;
},
[=] {
state.rotating = false;
view.notifyMapChange(MapChangeRegionDidChangeAnimated);
}, duration);
}
}
double Transform::getAngle() const {
return state.angle;
}
void Transform::setBearing(double degrees, const Duration& duration) {
setAngle(-degrees * M_PI / 180, duration);
}
void Transform::setBearing(double degrees, double cx, double cy) {
setAngle(-degrees * M_PI / 180, cx, cy);
}
double Transform::getBearing() const {
return -getAngle() / M_PI * 180;
}
#pragma mark - Transition
void Transform::startTransition(std::function<Update(double)> frame,
std::function<void()> finish,
const Duration& duration) {
if (transitionFinishFn) {
transitionFinishFn();
}
transitionStart = Clock::now();
transitionDuration = duration;
transitionFrameFn = [frame, this](const TimePoint now) {
float t = std::chrono::duration<float>(now - transitionStart) / transitionDuration;
if (t >= 1.0) {
Update result = frame(1.0);
transitionFinishFn();
transitionFrameFn = nullptr;
transitionFinishFn = nullptr;
return result;
} else {
util::UnitBezier ease(0, 0, 0.25, 1);
return frame(ease.solve(t, 0.001));
}
};
transitionFinishFn = finish;
}
bool Transform::needsTransition() const {
return !!transitionFrameFn;
}
UpdateType Transform::updateTransitions(const TimePoint& now) {
return static_cast<UpdateType>(transitionFrameFn ? transitionFrameFn(now) : Update::Nothing);
}
void Transform::cancelTransitions() {
if (transitionFinishFn) {
transitionFinishFn();
}
transitionFrameFn = nullptr;
transitionFinishFn = nullptr;
}
void Transform::setGestureInProgress(bool inProgress) {
state.gestureInProgress = inProgress;
}
| [
"seanbatson@seans-MacBook-Pro.local"
] | seanbatson@seans-MacBook-Pro.local |
9ec31d7d837c936fd0d023338856508b7e05408b | 20d0fccab8af5d17adbe397132460fad596da23f | /prog5/EthansHopping/Position.cpp | b72874dc2f39dc39286244e43d44497e8b4485cb | [] | no_license | danfitz7/Prog5 | 3e40b8f96441d6468d622ec441d7e9b61c063524 | 0a65fcd93b53a4a264eeb05f3ea83fb91b986669 | refs/heads/master | 2021-01-10T20:59:48.820903 | 2014-03-05T21:48:09 | 2014-03-05T21:48:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,096 | cpp | //Daniel Fitzgerald
#include <cmath>
#include "prog5.h"
#include "Position.h"
Position::Position():
x(-1), //set both to -1 so if a Position is ever constructed but not later set we will get errors as we should
y(-1)
{}
Position::Position(int X, int Y):
x(X),
y(Y)
{}
Position::Position(int pos) //constructor if given position in terms of field position
{
int row = 0;
while (pos > field.getSize() + 2)
{
row++;
pos -= (field.getSize() + 2);
}
x = row;
y = pos;
}
//euclidean distance to the given position
//TODO: should this be an int?
double Position::distanceFrom(Position other){
int xdiff=x-other.x;
int ydiff=y=other.y;
xdiff*=xdiff;
ydiff*=ydiff;
return sqrt(xdiff+ydiff);
}
//gets the immediately neighbouring position in the given direction
Position Position::neighborOn(Direction d){
int neighborX=x;
int neighborY=y;
switch(d){
case NORTH:
neighborY++;
break;
case EAST:
neighborX++;
break;
case SOUTH:
neighborY--;
break;
case WEST:
neighborX--;
break;
default:
break;
}
return Position(neighborX, neighborY);
}
| [
"danfitz7@hotmail.com"
] | danfitz7@hotmail.com |
2b4e5eade2f881c3bbb13784d12645ec956f946a | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/CMake/CMake-old-new/CMake-old-new/Kitware_CMake_new_file_773.cpp | 4d729a9894d819b17964709d8a4d42babc08f3da | [] | 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 | 4,689 | cpp | /*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Insight Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "cmCreateTestSourceList.h"
// cmCreateTestSourceList
bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
{
if (argsIn.size() < 3)
{
this->SetError("called with wrong number of arguments.");
return false;
}
std::vector<std::string> args;
cmSystemTools::ExpandListArguments(argsIn, args);
std::vector<std::string>::iterator i = args.begin();
const char* sourceList = i->c_str();
++i;
std::string driver = m_Makefile->GetCurrentOutputDirectory();
driver += "/";
driver += *i;
driver += ".cxx";
++i;
std::vector<std::string>::iterator testsBegin = i;
std::ofstream fout(driver.c_str());
if(!fout)
{
std::string err = "Could not create file ";
err += driver;
err += " for cmCreateTestSourceList command.";
this->SetError(err.c_str());
return false;
}
// Create the test driver file
fout << "#include <stdio.h>\n";
fout << "#include <string.h>\n";
fout << "// forward declare test functions\n";
for(i = testsBegin; i != args.end(); ++i)
{
fout << "int " << *i << "(int, char**);\n";
}
fout << "// Create map \n";
fout << "typedef int (*MainFuncPointer)(int , char**);\n";
fout << "struct functionMapEntry\n"
<< "{\n"
<< "const char* name;\n"
<< "MainFuncPointer func;\n"
<< "};\n\n";
fout << "functionMapEntry cmakeGeneratedFunctionMapEntries[] = {\n";
int numTests = 0;
for(i = testsBegin; i != args.end(); ++i)
{
fout << "{\"" << *i << "\", " << *i << "},\n";
numTests++;
}
fout << "};\n";
fout << "int main(int ac, char** av)\n"
<< "{\n";
fout << " int NumTests = " << numTests << ";\n";
fout << " int i;\n";
fout << " if(ac < 2)\n";
fout << " {\n";
fout << " // if there is only one test, then run it with the arguments\n";
fout << " if(NumTests == 1)\n";
fout << " { return (*cmakeGeneratedFunctionMapEntries[0].func)(ac, av); }\n";
fout << " printf(\"Available tests:\\n\");\n";
fout << " for(i =0; i < NumTests; ++i)\n";
fout << " {\n";
fout << " printf(\"%d. %s\\n\", i, cmakeGeneratedFunctionMapEntries[i].name);\n";
fout << " }\n";
fout << " printf(\"To run a test, enter the test number: \");\n";
fout << " int testNum = 0;\n";
fout << " scanf(\"%d\", &testNum);\n";
fout << " if(testNum >= NumTests)\n";
fout << " {\n";
fout << " printf(\"%d is an invalid test number.\\n\", testNum);\n";
fout << " return -1;\n";
fout << " }\n";
fout << " return (*cmakeGeneratedFunctionMapEntries[testNum].func)(ac-1, av+1);\n";
fout << " }\n";
fout << " for(i =0; i < NumTests; ++i)\n";
fout << " {\n";
fout << " if(strcmp(cmakeGeneratedFunctionMapEntries[i].name, av[1]) == 0)\n";
fout << " {\n";
fout << " return (*cmakeGeneratedFunctionMapEntries[i].func)(ac-1, av+1);\n";
fout << " }\n";
fout << " }\n";
fout << " // if there is only one test, then run it with the arguments\n";
fout << " if(NumTests == 1)\n";
fout << " { return (*cmakeGeneratedFunctionMapEntries[0].func)(ac, av); }\n";
fout << " printf(\"Available tests:\\n\");\n";
fout << " for(i =0; i < NumTests; ++i)\n";
fout << " {\n";
fout << " printf(\"%d. %s\\n\", i, cmakeGeneratedFunctionMapEntries[i].name);\n";
fout << " }\n";
fout << " printf(\"Failed: %s is an invalid test name.\\n\", av[1]);\n";
fout << " return -1;\n";
fout << "}\n";
fout.close();
// create the source list
cmSourceFile cfile;
cfile.SetIsAnAbstractClass(false);
cfile.SetName(args[1].c_str(), m_Makefile->GetCurrentOutputDirectory(),
"cxx", false);
m_Makefile->AddSource(cfile, sourceList);
for(i = testsBegin; i != args.end(); ++i)
{
cmSourceFile cfile;
cfile.SetIsAnAbstractClass(false);
cfile.SetName(i->c_str(), m_Makefile->GetCurrentDirectory(),
"cxx", false);
m_Makefile->AddSource(cfile, sourceList);
}
return true;
}
| [
"993273596@qq.com"
] | 993273596@qq.com |
a82cc6762686e56e8ad192071e5c765ab82dabae | bd8bcdb88c102a1ddf2c0f429dbef392296b67af | /include/fengine/Animation/AnimationSystem/SkeletalAnimation.h | 8ed3beaabbca391ebd4889905fb947740e27addf | [
"BSD-2-Clause",
"BSD-3-Clause"
] | permissive | LukasBanana/ForkENGINE | be03cee942b0e20e30a01318c2639de87a72c79c | 8b575bd1d47741ad5025a499cb87909dbabc3492 | refs/heads/master | 2020-05-23T09:08:44.864715 | 2017-01-30T16:35:34 | 2017-01-30T16:35:34 | 80,437,868 | 14 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 3,599 | h | /*
* Skeletal animation header
*
* This file is part of the "ForkENGINE" (Copyright (c) 2014 by Lukas Hermanns)
* See "LICENSE.txt" for license information.
*/
#ifndef __FORK_SKELETAL_ANIMATION_H__
#define __FORK_SKELETAL_ANIMATION_H__
#include "Animation/AnimationSystem/Animation.h"
#include "Animation/Core/KeyframeSequence.h"
#include "Scene/Geometry/Skeleton.h"
#include <string>
#include <vector>
#include <map>
namespace Fork
{
namespace Anim
{
DECL_SHR_PTR(SkeletalAnimation);
/**
Skeletal animation implementation.
\ingroup animation
\todo Incomplete
*/
class FORK_EXPORT SkeletalAnimation : public Animation
{
public:
//! Skeletal animation joint type.
typedef Scene::Skeleton::Joint Joint;
//! Structure to store joint reference and its keyframe sequence.
class FORK_EXPORT KeyframeJoint
{
public:
//! \throws NullPointerException If 'joint' is null.
KeyframeJoint(Joint* joint);
/**
Updates the interpolation of all keyframe joints.
\see KeyframeSequence::Interpolate
*/
static void Update(std::vector<KeyframeJoint>& keyframeJoints, const Playback& playback);
//! Returns the joint reference.
inline Joint* GetJoint() const
{
return joint_;
}
//! Animation keyframe sequence for this joint.
KeyframeSequence keyframeSequence;
private:
Joint* joint_ = nullptr; //!< Reference to the joint node.
};
//! Skeletal joint group structure.
struct FORK_EXPORT JointGroup
{
std::string name; //!< Name of this joint group.
Playback playback; //!< Animation playback for this joint group.
std::vector<KeyframeJoint> keyframeJoints; //!< Keyframe joints in this group.
};
//! \throws NullPointerException If 'skeletojn' is null.
SkeletalAnimation(const Scene::SkeletonPtr& skeleton);
//! Returns Animation::Types::Skeletal.
Types Type() const override;
/**
Updates the playback and transforms the keyframe joints.
The behavior of this function can be controlled by the "animateJointGroup" member.
\remarks You can also update the keyframe joints by yourself:
\code
skeletalAnim->playback.Update(deltaTime);
for (const auto& keyJoint : skeletalAnim->keyframeJoints)
keyJoint.keyframeSequence.Interpolate(keyJoint.GetJoint()->transform, skeletalAnim->playback);
\endcode
\see animateJointGroup
*/
void Update(double deltaTime = 1.0/60.0) override;
//! Returns the mesh skeleton.
inline Scene::Skeleton* GetSkeleton() const
{
return skeleton_.get();
}
//! Keyframe joint list.
std::vector<KeyframeJoint> keyframeJoints;
//! Joint group list.
std::vector<JointGroup> jointGroups;
/**
Specifies whether the joint groups will be animated or all joints together.
If this is true, each joint group can be animated individually. By default false.
*/
bool animateJointGroup = false;
private:
Scene::SkeletonPtr skeleton_;
};
} // /namespace Anim
} // /namespace Fork
#endif
// ======================== | [
"lukas.hermanns90@gmail.com"
] | lukas.hermanns90@gmail.com |
14ae6ee46e14658e97b98f036418cb0cfc8fb205 | a1a8b69b2a24fd86e4d260c8c5d4a039b7c06286 | /build/iOS/Release/include/Fuse.Animations.NothingAnimatorState.h | f0dcd86716ffc4278f5beefc0754ffa21f629d30 | [] | no_license | epireve/hikr-tute | df0af11d1cfbdf6e874372b019d30ab0541c09b7 | 545501fba7044b4cc927baea2edec0674769e22c | refs/heads/master | 2021-09-02T13:54:05.359975 | 2018-01-03T01:21:31 | 2018-01-03T01:21:31 | 115,536,756 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,294 | h | // This file was generated based on /usr/local/share/uno/Packages/Fuse.Animations/1.4.2/Nothing.uno.
// WARNING: Changes might be lost if you edit this file directly.
#pragma once
#include <Fuse.Animations.TrackAnimatorState.h>
namespace g{namespace Fuse{namespace Animations{struct CreateStateParams;}}}
namespace g{namespace Fuse{namespace Animations{struct Nothing;}}}
namespace g{namespace Fuse{namespace Animations{struct NothingAnimatorState;}}}
namespace g{
namespace Fuse{
namespace Animations{
// internal sealed class NothingAnimatorState :18
// {
::g::Fuse::Animations::TrackAnimatorState_type* NothingAnimatorState_typeof();
void NothingAnimatorState__ctor_2_fn(NothingAnimatorState* __this, ::g::Fuse::Animations::Nothing* animator, ::g::Fuse::Animations::CreateStateParams* p);
void NothingAnimatorState__New1_fn(::g::Fuse::Animations::Nothing* animator, ::g::Fuse::Animations::CreateStateParams* p, NothingAnimatorState** __retval);
struct NothingAnimatorState : ::g::Fuse::Animations::TrackAnimatorState
{
void ctor_2(::g::Fuse::Animations::Nothing* animator, ::g::Fuse::Animations::CreateStateParams* p);
static NothingAnimatorState* New1(::g::Fuse::Animations::Nothing* animator, ::g::Fuse::Animations::CreateStateParams* p);
};
// }
}}} // ::g::Fuse::Animations
| [
"i@firdaus.my"
] | i@firdaus.my |
64e04d56aad7123eda2a1449bed152784b397913 | d7626890b0e1fdebd5e19369038e80619528820d | /src/rpc/mining.cpp | 352ade162ee448c798f2784c4808a1e876b535e8 | [
"MIT"
] | permissive | pyujin78/Fashionking-WonCash | 8549bbca518e29ae58bd8392ee0ac7a50323ddae | b3abba221d239cbdb116e9c8518862010cc43c12 | refs/heads/main | 2023-06-12T10:58:02.979778 | 2021-07-04T12:32:07 | 2021-07-04T12:32:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 45,145 | cpp | // Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2015 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "base58.h"
#include "amount.h"
#include "chain.h"
#include "chainparams.h"
#include "consensus/consensus.h"
#include "consensus/params.h"
#include "consensus/validation.h"
#include "core_io.h"
#include "dstencode.h"
#include "init.h"
#include "main.h"
#include "miner.h"
#include "net.h"
#include "pow.h"
#include "pos.h"
#include "rpc/server.h"
#include "txmempool.h"
#include "timedata.h"
#include "util.h"
#include "utilstrencodings.h"
#include "validationinterface.h"
#ifdef ENABLE_WALLET
#include "wallet/wallet.h"
#endif
#include <stdint.h>
#include <boost/assign/list_of.hpp>
#include <univalue.h>
using namespace std;
/**
* Return average network hashes per second based on the last 'lookup' blocks,
* or from the last difficulty change if 'lookup' is nonpositive.
* If 'height' is nonnegative, compute the estimate at the time when a given block was found.
*/
UniValue GetNetworkHashPS(int lookup, int height) {
CBlockIndex *pb = chainActive.Tip();
if (height >= 0 && height < chainActive.Height())
pb = chainActive[height];
if (pb == NULL || !pb->nHeight)
return 0;
// If lookup is -1, then use blocks since last difficulty change.
if (lookup <= 0)
lookup = pb->nHeight % Params().GetConsensus().DifficultyAdjustmentInterval() + 1;
// If lookup is larger than chain, then set it to chain length.
if (lookup > pb->nHeight)
lookup = pb->nHeight;
CBlockIndex *pb0 = pb;
int64_t minTime = pb0->GetBlockTime();
int64_t maxTime = minTime;
for (int i = 0; i < lookup; i++) {
pb0 = pb0->pprev;
int64_t time = pb0->GetBlockTime();
minTime = std::min(time, minTime);
maxTime = std::max(time, maxTime);
}
// In case there's a situation where minTime == maxTime, we don't want a divide by zero exception.
if (minTime == maxTime)
return 0;
arith_uint256 workDiff = pb->nChainWork - pb0->nChainWork;
int64_t timeDiff = maxTime - minTime;
return workDiff.getdouble() / timeDiff;
}
UniValue getnetworkhashps(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() > 2)
throw runtime_error(
"getnetworkhashps ( blocks height )\n"
"\nReturns the estimated network hashes per second based on the last n blocks.\n"
"Pass in [blocks] to override # of blocks, -1 specifies since last difficulty change.\n"
"Pass in [height] to estimate the network speed at the time when a certain block was found.\n"
"\nArguments:\n"
"1. blocks (numeric, optional, default=120) The number of blocks, or -1 for blocks since last difficulty change.\n"
"2. height (numeric, optional, default=-1) To estimate at the time of the given height.\n"
"\nResult:\n"
"x (numeric) Hashes per second estimated\n"
"\nExamples:\n"
+ HelpExampleCli("getnetworkhashps", "")
+ HelpExampleRpc("getnetworkhashps", "")
);
LOCK(cs_main);
return GetNetworkHashPS(params.size() > 0 ? params[0].get_int() : 120, params.size() > 1 ? params[1].get_int() : -1);
}
UniValue generateBlocks(std::shared_ptr<CReserveScript> coinbaseScript, int nGenerate, uint64_t nMaxTries, bool keepScript)
{
static const int nInnerLoopCount = 0x10000;
int nHeightStart = 0;
int nHeightEnd = 0;
int nHeight = 0;
{ // Don't keep cs_main locked
LOCK(cs_main);
nHeightStart = chainActive.Height();
nHeight = nHeightStart;
nHeightEnd = nHeightStart+nGenerate;
}
unsigned int nExtraNonce = 0;
UniValue blockHashes(UniValue::VARR);
while (nHeight < nHeightEnd)
{
std::unique_ptr<CBlockTemplate> pblocktemplate(BlockAssembler(Params()).CreateNewBlock(coinbaseScript->reserveScript, 0, false));
if (!pblocktemplate.get())
throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block");
CBlock *pblock = &pblocktemplate->block;
{
LOCK(cs_main);
IncrementExtraNonce(pblock, chainActive.Tip(), nExtraNonce);
}
while (nMaxTries > 0 && pblock->nNonce < nInnerLoopCount && !CheckProofOfWork(pblock->GetPoWHash(), pblock->nBits, Params().GetConsensus())) {
++pblock->nNonce;
--nMaxTries;
}
if (nMaxTries == 0) {
break;
}
if (pblock->nNonce == nInnerLoopCount) {
continue;
}
CValidationState state;
uint256 hash = pblock->GetHash();
if (!ProcessNewBlock(state, Params(), NULL, pblock, true, NULL, false))
throw JSONRPCError(RPC_INTERNAL_ERROR, "ProcessNewBlock, block not accepted");
++nHeight;
blockHashes.push_back(hash.GetHex());
//mark script as important because it was used at least for one coinbase output if the script came from the wallet
if (keepScript)
{
coinbaseScript->KeepScript();
}
}
return blockHashes;
}
UniValue generate(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"generate numblocks ( maxtries )\n"
"\nMine up to numblocks blocks immediately (before the RPC call returns)\n"
"\nArguments:\n"
"1. numblocks (numeric, required) How many blocks are generated immediately.\n"
"2. maxtries (numeric, optional) How many iterations to try (default = 1000000).\n"
"\nResult\n"
"[ blockhashes ] (array) hashes of blocks generated\n"
"\nExamples:\n"
"\nGenerate 11 blocks\n"
+ HelpExampleCli("generate", "11")
);
int nGenerate = params[0].get_int();
uint64_t nMaxTries = 1000000;
if (params.size() > 1) {
nMaxTries = params[1].get_int();
}
std::shared_ptr<CReserveScript> coinbaseScript;
GetMainSignals().ScriptForMining(coinbaseScript);
// If the keypool is exhausted, no script is returned at all. Catch this.
if (!coinbaseScript)
throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first");
//throw an error if no script was provided
if (coinbaseScript->reserveScript.empty())
throw JSONRPCError(RPC_INTERNAL_ERROR, "No coinbase script available (mining requires a wallet)");
return generateBlocks(coinbaseScript, nGenerate, nMaxTries, true);
}
UniValue generatetoaddress(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 2 || params.size() > 3)
throw runtime_error(
"generatetoaddress numblocks address (maxtries)\n"
"\nMine blocks immediately to a specified address (before the RPC call returns)\n"
"\nArguments:\n"
"1. numblocks (numeric, required) How many blocks are generated immediately.\n"
"2. address (string, required) The address to send the newly generated bitcoin to.\n"
"3. maxtries (numeric, optional) How many iterations to try (default = 1000000).\n"
"\nResult\n"
"[ blockhashes ] (array) hashes of blocks generated\n"
"\nExamples:\n"
"\nGenerate 11 blocks to myaddress\n"
+ HelpExampleCli("generatetoaddress", "11 \"myaddress\"")
);
int nGenerate = params[0].get_int();
uint64_t nMaxTries = 1000000;
if (params.size() > 2) {
nMaxTries = params[2].get_int();
}
CTxDestination destination = DecodeDestination(params[1].get_str());
if (!IsValidDestination(destination)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Error: Invalid address");
}
std::shared_ptr<CReserveScript> coinbaseScript(new CReserveScript());
coinbaseScript->reserveScript = GetScriptForDestination(destination);
return generateBlocks(coinbaseScript, nGenerate, nMaxTries, false);
}
UniValue getmininginfo(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
"getmininginfo\n"
"\nReturns a json object containing mining-related information."
"\nResult:\n"
"{\n"
" \"blocks\": nnn, (numeric) The current block\n"
" \"currentblocksize\": nnn, (numeric) The last block size\n"
" \"currentblocktx\": nnn, (numeric) The last block transaction\n"
" \"difficulty\": xxx.xxxxx (numeric) The current difficulty\n"
" \"errors\": \"...\" (string) Current errors\n"
" \"networkhashps\": nnn, (numeric) The network hashes per second\n"
" \"pooledtx\": n (numeric) The size of the mempool\n"
" \"testnet\": true|false (boolean) If using testnet or not\n"
" \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getmininginfo", "")
+ HelpExampleRpc("getmininginfo", "")
);
LOCK(cs_main);
UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("blocks", (int)chainActive.Height()));
obj.push_back(Pair("currentblocksize", (uint64_t)nLastBlockSize));
obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx));
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
obj.push_back(Pair("errors", GetWarnings("statusbar")));
obj.push_back(Pair("networkhashps", getnetworkhashps(params, false)));
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC()));
obj.push_back(Pair("chain", Params().NetworkIDString()));
return obj;
}
UniValue getstakinginfo(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
"getstakinginfo\n"
"Returns an object containing staking-related information.");
uint64_t nWeight = 0;
if (pwalletMain)
nWeight = pwalletMain->GetStakeWeight();
uint64_t nNetworkWeight = GetPoSKernelPS();
bool staking = nLastCoinStakeSearchInterval && nWeight;
const Consensus::Params& consensusParams = Params().GetConsensus();
int64_t nTargetSpacing = consensusParams.nTargetSpacing;
uint64_t nExpectedTime = staking ? (nTargetSpacing * nNetworkWeight / nWeight) : 0;
UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("enabled", GetBoolArg("-staking", true)));
obj.push_back(Pair("staking", staking));
obj.push_back(Pair("errors", GetWarnings("statusbar")));
obj.push_back(Pair("currentblocksize", (uint64_t)nLastBlockSize));
obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx));
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
obj.push_back(Pair("difficulty", GetDifficulty(GetLastBlockIndex(chainActive.Tip(), true))));
obj.push_back(Pair("search-interval", (int)nLastCoinStakeSearchInterval));
obj.push_back(Pair("weight", (uint64_t)nWeight));
obj.push_back(Pair("netstakeweight", (uint64_t)nNetworkWeight));
obj.push_back(Pair("expectedtime", nExpectedTime));
return obj;
}
// NOTE: Unlike wallet RPC (which use BTC values), mining RPCs follow GBT (BIP 22) in using satoshi amounts
UniValue prioritisetransaction(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 3)
throw runtime_error(
"prioritisetransaction <txid> <priority delta> <fee delta>\n"
"Accepts the transaction into mined blocks at a higher (or lower) priority\n"
"\nArguments:\n"
"1. \"txid\" (string, required) The transaction id.\n"
"2. priority delta (numeric, required) The priority to add or subtract.\n"
" The transaction selection algorithm considers the tx as it would have a higher priority.\n"
" (priority of a transaction is calculated: coinage * value_in_satoshis / txsize) \n"
"3. fee delta (numeric, required) The fee value (in satoshis) to add (or subtract, if negative).\n"
" The fee is not actually paid, only the algorithm for selecting transactions into a block\n"
" considers the transaction as it would have paid a higher (or lower) fee.\n"
"\nResult\n"
"true (boolean) Returns true\n"
"\nExamples:\n"
+ HelpExampleCli("prioritisetransaction", "\"txid\" 0.0 10000")
+ HelpExampleRpc("prioritisetransaction", "\"txid\", 0.0, 10000")
);
LOCK(cs_main);
uint256 hash = ParseHashStr(params[0].get_str(), "txid");
CAmount nAmount = params[2].get_int64();
mempool.PrioritiseTransaction(hash, params[0].get_str(), params[1].get_real(), nAmount);
return true;
}
// NOTE: Assumes a conclusive result; if result is inconclusive, it must be handled by caller
static UniValue BIP22ValidationResult(const CValidationState& state)
{
if (state.IsValid())
return NullUniValue;
std::string strRejectReason = state.GetRejectReason();
if (state.IsError())
throw JSONRPCError(RPC_VERIFY_ERROR, strRejectReason);
if (state.IsInvalid())
{
if (strRejectReason.empty())
return "rejected";
return strRejectReason;
}
// Should be impossible
return "valid?";
}
std::string gbt_vb_name(const Consensus::DeploymentPos pos) {
const struct BIP9DeploymentInfo& vbinfo = VersionBitsDeploymentInfo[pos];
std::string s = vbinfo.name;
if (!vbinfo.gbt_force) {
s.insert(s.begin(), '!');
}
return s;
}
UniValue getblocktemplate(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() > 1)
throw runtime_error(
"getblocktemplate ( TemplateRequest )\n"
"\nIf the request parameters include a 'mode' key, that is used to explicitly select between the default 'template' request or a 'proposal'.\n"
"It returns data needed to construct a block to work on.\n"
"For full specification, see BIPs 22, 23, and 9:\n"
" https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki\n"
" https://github.com/bitcoin/bips/blob/master/bip-0023.mediawiki\n"
" https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki#getblocktemplate_changes\n"
"\nArguments:\n"
"1. TemplateRequest (json object, optional) A json object in the following spec\n"
" {\n"
" \"mode\":\"template\" (string, optional) This must be set to \"template\", \"proposal\" (see BIP 23), or omitted\n"
" \"capabilities\":[ (array, optional) A list of strings\n"
" \"support\" (string) client side supported feature, 'longpoll', 'coinbasetxn', 'coinbasevalue', 'proposal', 'serverlist', 'workid'\n"
" ,...\n"
" ],\n"
" \"rules\":[ (array, optional) A list of strings\n"
" \"support\" (string) client side supported softfork deployment\n"
" ,...\n"
" ]\n"
" }\n"
"\n"
"\nResult:\n"
"{\n"
" \"version\" : n, (numeric) The preferred block version\n"
" \"rules\" : [ \"rulename\", ... ], (array of strings) specific block rules that are to be enforced\n"
" \"vbavailable\" : { (json object) set of pending, supported versionbit (BIP 9) softfork deployments\n"
" \"rulename\" : bitnumber (numeric) identifies the bit number as indicating acceptance and readiness for the named softfork rule\n"
" ,...\n"
" },\n"
" \"vbrequired\" : n, (numeric) bit mask of versionbits the server requires set in submissions\n"
" \"previousblockhash\" : \"xxxx\", (string) The hash of current highest block\n"
" \"transactions\" : [ (array) contents of non-coinbase transactions that should be included in the next block\n"
" {\n"
" \"data\" : \"xxxx\", (string) transaction data encoded in hexadecimal (byte-for-byte)\n"
" \"txid\" : \"xxxx\", (string) transaction id encoded in little-endian hexadecimal\n"
" \"hash\" : \"xxxx\", (string) hash encoded in little-endian hexadecimal (including witness data)\n"
" \"depends\" : [ (array) array of numbers \n"
" n (numeric) transactions before this one (by 1-based index in 'transactions' list) that must be present in the final block if this one is\n"
" ,...\n"
" ],\n"
" \"fee\": n, (numeric) difference in value between transaction inputs and outputs (in Satoshis); for coinbase transactions, this is a negative Number of the total collected block fees (ie, not including the block subsidy); if key is not present, fee is unknown and clients MUST NOT assume there isn't one\n"
" \"sigops\" : n, (numeric) total SigOps cost, as counted for purposes of block limits; if key is not present, sigop cost is unknown and clients MUST NOT assume it is zero\n"
" \"weight\" : n, (numeric) total transaction weight, as counted for purposes of block limits\n"
" \"required\" : true|false (boolean) if provided and true, this transaction must be in the final block\n"
" }\n"
" ,...\n"
" ],\n"
" \"coinbaseaux\" : { (json object) data that should be included in the coinbase's scriptSig content\n"
" \"flags\" : \"xx\" (string) key name is to be ignored, and value included in scriptSig\n"
" },\n"
" \"coinbasevalue\" : n, (numeric) maximum allowable input to coinbase transaction, including the generation award and transaction fees (in Satoshis)\n"
" \"coinbasetxn\" : { ... }, (json object) information for coinbase transaction\n"
" \"target\" : \"xxxx\", (string) The hash target\n"
" \"mintime\" : xxx, (numeric) The minimum timestamp appropriate for next block time in seconds since epoch (Jan 1 1970 GMT)\n"
" \"mutable\" : [ (array of string) list of ways the block template may be changed \n"
" \"value\" (string) A way the block template may be changed, e.g. 'time', 'transactions', 'prevblock'\n"
" ,...\n"
" ],\n"
" \"noncerange\" : \"00000000ffffffff\",(string) A range of valid nonces\n"
" \"sigoplimit\" : n, (numeric) limit of sigops in blocks\n"
" \"sizelimit\" : n, (numeric) limit of block size\n"
" \"curtime\" : ttt, (numeric) current timestamp in seconds since epoch (Jan 1 1970 GMT)\n"
" \"bits\" : \"xxxxxxxx\", (string) compressed target of next block\n"
" \"height\" : n (numeric) The height of the next block\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getblocktemplate", "")
+ HelpExampleRpc("getblocktemplate", "")
);
LOCK(cs_main);
std::string strMode = "template";
UniValue lpval = NullUniValue;
std::set<std::string> setClientRules;
int64_t nMaxVersionPreVB = -1;
if (params.size() > 0)
{
const UniValue& oparam = params[0].get_obj();
const UniValue& modeval = find_value(oparam, "mode");
if (modeval.isStr())
strMode = modeval.get_str();
else if (modeval.isNull())
{
/* Do nothing */
}
else
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode");
lpval = find_value(oparam, "longpollid");
if (strMode == "proposal")
{
const UniValue& dataval = find_value(oparam, "data");
if (!dataval.isStr())
throw JSONRPCError(RPC_TYPE_ERROR, "Missing data String key for proposal");
CBlock block;
if (!DecodeHexBlk(block, dataval.get_str()))
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed");
uint256 hash = block.GetHash();
BlockMap::iterator mi = mapBlockIndex.find(hash);
if (mi != mapBlockIndex.end()) {
CBlockIndex *pindex = mi->second;
if (pindex->IsValid(BLOCK_VALID_SCRIPTS))
return "duplicate";
if (pindex->nStatus & BLOCK_FAILED_MASK)
return "duplicate-invalid";
return "duplicate-inconclusive";
}
CBlockIndex* const pindexPrev = chainActive.Tip();
// TestBlockValidity only supports blocks built on the current Tip
if (block.hashPrevBlock != pindexPrev->GetBlockHash())
return "inconclusive-not-best-prevblk";
CValidationState state;
TestBlockValidity(state, Params(), block, pindexPrev, false, true, true);
return BIP22ValidationResult(state);
}
const UniValue& aClientRules = find_value(oparam, "rules");
if (aClientRules.isArray()) {
for (unsigned int i = 0; i < aClientRules.size(); ++i) {
const UniValue& v = aClientRules[i];
setClientRules.insert(v.get_str());
}
} else {
// NOTE: It is important that this NOT be read if versionbits is supported
const UniValue& uvMaxVersion = find_value(oparam, "maxversion");
if (uvMaxVersion.isNum()) {
nMaxVersionPreVB = uvMaxVersion.get_int64();
}
}
}
if (strMode != "template")
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode");
if (vNodes.empty())
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Bitcoin is not connected!");
if (IsInitialBlockDownload())
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Bitcoin is downloading blocks...");
if (chainActive.Tip()->nHeight > Params().GetConsensus().nLastPOWBlock)
throw JSONRPCError(RPC_MISC_ERROR, "No more PoW blocks");
static unsigned int nTransactionsUpdatedLast;
if (!lpval.isNull())
{
// Wait to respond until either the best block changes, OR a minute has passed and there are more transactions
uint256 hashWatchedChain;
boost::system_time checktxtime;
unsigned int nTransactionsUpdatedLastLP;
if (lpval.isStr())
{
// Format: <hashBestChain><nTransactionsUpdatedLast>
std::string lpstr = lpval.get_str();
hashWatchedChain.SetHex(lpstr.substr(0, 64));
nTransactionsUpdatedLastLP = atoi64(lpstr.substr(64));
}
else
{
// NOTE: Spec does not specify behaviour for non-string longpollid, but this makes testing easier
hashWatchedChain = chainActive.Tip()->GetBlockHash();
nTransactionsUpdatedLastLP = nTransactionsUpdatedLast;
}
// Release the wallet and main lock while waiting
LEAVE_CRITICAL_SECTION(cs_main);
{
checktxtime = boost::get_system_time() + boost::posix_time::minutes(1);
boost::unique_lock<boost::mutex> lock(csBestBlock);
while (chainActive.Tip()->GetBlockHash() == hashWatchedChain && IsRPCRunning())
{
if (!cvBlockChange.timed_wait(lock, checktxtime))
{
// Timeout: Check transactions for update
if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLastLP)
break;
checktxtime += boost::posix_time::seconds(10);
}
}
}
ENTER_CRITICAL_SECTION(cs_main);
if (!IsRPCRunning())
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Shutting down");
// TODO: Maybe recheck connections/IBD and (if something wrong) send an expires-immediately template to stop miners?
}
// Update block
static CBlockIndex* pindexPrev;
static int64_t nStart;
static CBlockTemplate* pblocktemplate;
if (pindexPrev != chainActive.Tip() ||
(mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 5))
{
// Clear pindexPrev so future calls make a new block, despite any failures from here on
pindexPrev = NULL;
// Store the pindexBest used before CreateNewBlock, to avoid races
nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
CBlockIndex* pindexPrevNew = chainActive.Tip();
nStart = GetTime();
// Create new block
if(pblocktemplate)
{
delete pblocktemplate;
pblocktemplate = NULL;
}
CScript scriptDummy = CScript() << OP_TRUE;
pblocktemplate = BlockAssembler(Params()).CreateNewBlock(scriptDummy, 0, false);
if (!pblocktemplate)
throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory");
// Need to update only after we know CreateNewBlock succeeded
pindexPrev = pindexPrevNew;
}
CBlock* pblock = &pblocktemplate->block; // pointer for convenience
const Consensus::Params& consensusParams = Params().GetConsensus();
// Update nTime
UpdateTime(pblock, consensusParams, pindexPrev);
pblock->nNonce = 0;
UniValue aCaps(UniValue::VARR); aCaps.push_back("proposal");
UniValue transactions(UniValue::VARR);
map<uint256, int64_t> setTxIndex;
int i = 0;
BOOST_FOREACH (CTransaction& tx, pblock->vtx) {
uint256 txHash = tx.GetHash();
setTxIndex[txHash] = i++;
if (tx.IsCoinBase())
continue;
UniValue entry(UniValue::VOBJ);
entry.push_back(Pair("data", EncodeHexTx(tx)));
entry.push_back(Pair("hash", txHash.GetHex()));
UniValue deps(UniValue::VARR);
BOOST_FOREACH (const CTxIn &in, tx.vin)
{
if (setTxIndex.count(in.prevout.hash))
deps.push_back(setTxIndex[in.prevout.hash]);
}
entry.push_back(Pair("depends", deps));
int index_in_template = i - 1;
entry.push_back(Pair("fee", pblocktemplate->vTxFees[index_in_template]));
entry.push_back(Pair("sigops", pblocktemplate->vTxSigOpsCost[index_in_template]));
transactions.push_back(entry);
}
UniValue aux(UniValue::VOBJ);
aux.push_back(Pair("flags", HexStr(COINBASE_FLAGS.begin(), COINBASE_FLAGS.end())));
arith_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits);
UniValue aMutable(UniValue::VARR);
aMutable.push_back("time");
aMutable.push_back("transactions");
aMutable.push_back("prevblock");
UniValue result(UniValue::VOBJ);
result.push_back(Pair("capabilities", aCaps));
UniValue aRules(UniValue::VARR);
UniValue vbavailable(UniValue::VOBJ);
for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++i) {
Consensus::DeploymentPos pos = Consensus::DeploymentPos(i);
ThresholdState state = VersionBitsState(pindexPrev, consensusParams, pos, versionbitscache);
switch (state) {
case THRESHOLD_DEFINED:
case THRESHOLD_FAILED:
// Not exposed to GBT at all
break;
case THRESHOLD_LOCKED_IN:
// Ensure bit is set in block version
pblock->nVersion |= VersionBitsMask(consensusParams, pos);
// FALL THROUGH to get vbavailable set...
case THRESHOLD_STARTED:
{
const struct BIP9DeploymentInfo& vbinfo = VersionBitsDeploymentInfo[pos];
vbavailable.push_back(Pair(gbt_vb_name(pos), consensusParams.vDeployments[pos].bit));
if (setClientRules.find(vbinfo.name) == setClientRules.end()) {
if (!vbinfo.gbt_force) {
// If the client doesn't support this, don't indicate it in the [default] version
pblock->nVersion &= ~VersionBitsMask(consensusParams, pos);
}
}
break;
}
case THRESHOLD_ACTIVE:
{
// Add to rules only
const struct BIP9DeploymentInfo& vbinfo = VersionBitsDeploymentInfo[pos];
aRules.push_back(gbt_vb_name(pos));
if (setClientRules.find(vbinfo.name) == setClientRules.end()) {
// Not supported by the client; make sure it's safe to proceed
if (!vbinfo.gbt_force) {
// If we do anything other than throw an exception here, be sure version/force isn't sent to old clients
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Support for '%s' rule requires explicit client support", vbinfo.name));
}
}
break;
}
}
}
result.push_back(Pair("version", pblock->nVersion));
result.push_back(Pair("rules", aRules));
result.push_back(Pair("vbavailable", vbavailable));
result.push_back(Pair("vbrequired", int(0)));
if (nMaxVersionPreVB >= 2) {
// If VB is supported by the client, nMaxVersionPreVB is -1, so we won't get here
// Because BIP 34 changed how the generation transaction is serialized, we can only use version/force back to v2 blocks
// This is safe to do [otherwise-]unconditionally only because we are throwing an exception above if a non-force deployment gets activated
// Note that this can probably also be removed entirely after the first BIP9 non-force deployment (ie, probably segwit) gets activated
aMutable.push_back("version/force");
}
result.push_back(Pair("previousblockhash", pblock->hashPrevBlock.GetHex()));
result.push_back(Pair("transactions", transactions));
result.push_back(Pair("coinbaseaux", aux));
result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue));
result.push_back(Pair("longpollid", chainActive.Tip()->GetBlockHash().GetHex() + i64tostr(nTransactionsUpdatedLast)));
result.push_back(Pair("target", hashTarget.GetHex()));
result.push_back(Pair("mintime", (int64_t)pindexPrev->GetPastTimeLimit()+1));
result.push_back(Pair("mutable", aMutable));
result.push_back(Pair("noncerange", "00000000ffffffff"));
result.push_back(Pair("sigoplimit", (int64_t)MAX_BLOCK_SIGOPS));
result.push_back(Pair("sizelimit", (int64_t)MAX_BLOCK_SIZE));
result.push_back(Pair("curtime", pblock->GetBlockTime()));
result.push_back(Pair("bits", strprintf("%08x", pblock->nBits)));
result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1)));
return result;
}
class submitblock_StateCatcher : public CValidationInterface
{
public:
uint256 hash;
bool found;
CValidationState state;
submitblock_StateCatcher(const uint256 &hashIn) : hash(hashIn), found(false), state() {};
protected:
virtual void BlockChecked(const CBlock& block, const CValidationState& stateIn) {
if (block.GetHash() != hash)
return;
found = true;
state = stateIn;
};
};
UniValue submitblock(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"submitblock \"hexdata\" ( \"jsonparametersobject\" )\n"
"\nAttempts to submit new block to network.\n"
"The 'jsonparametersobject' parameter is currently ignored.\n"
"See https://en.bitcoin.it/wiki/BIP_0022 for full specification.\n"
"\nArguments\n"
"1. \"hexdata\" (string, required) the hex-encoded block data to submit\n"
"2. \"jsonparametersobject\" (string, optional) object of optional parameters\n"
" {\n"
" \"workid\" : \"id\" (string, optional) if the server provided a workid, it MUST be included with submissions\n"
" }\n"
"\nResult:\n"
"\nExamples:\n"
+ HelpExampleCli("submitblock", "\"mydata\"")
+ HelpExampleRpc("submitblock", "\"mydata\"")
);
CBlock block;
if (!DecodeHexBlk(block, params[0].get_str()))
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed");
uint256 hash = block.GetHash();
bool fBlockPresent = false;
{
LOCK(cs_main);
BlockMap::iterator mi = mapBlockIndex.find(hash);
if (mi != mapBlockIndex.end()) {
CBlockIndex *pindex = mi->second;
if (pindex->IsValid(BLOCK_VALID_SCRIPTS))
return "duplicate";
if (pindex->nStatus & BLOCK_FAILED_MASK)
return "duplicate-invalid";
// Otherwise, we might only have the header - process the block before returning
fBlockPresent = true;
}
}
CValidationState state;
submitblock_StateCatcher sc(hash);
RegisterValidationInterface(&sc);
bool fAccepted = ProcessNewBlock(state, Params(), NULL, &block, true, NULL, false);
UnregisterValidationInterface(&sc);
if (fBlockPresent)
{
if (fAccepted && !sc.found)
return "duplicate-inconclusive";
return "duplicate";
}
if (fAccepted)
{
if (!sc.found)
return "inconclusive";
state = sc.state;
}
return BIP22ValidationResult(state);
}
UniValue estimatefee(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"estimatefee nblocks\n"
"\nEstimates the approximate fee per kilobyte needed for a transaction to begin\n"
"confirmation within nblocks blocks.\n"
"\nArguments:\n"
"1. nblocks (numeric)\n"
"\nResult:\n"
"n (numeric) estimated fee-per-kilobyte\n"
"\n"
"A negative value is returned if not enough transactions and blocks\n"
"have been observed to make an estimate.\n"
"-1 is always returned for nblocks == 1 as it is impossible to calculate\n"
"a fee that is high enough to get reliably included in the next block.\n"
"\nExample:\n"
+ HelpExampleCli("estimatefee", "6")
);
RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM));
int nBlocks = params[0].get_int();
if (nBlocks < 1)
nBlocks = 1;
CFeeRate feeRate = mempool.estimateFee(nBlocks);
if (feeRate == CFeeRate(0))
return -1.0;
return ValueFromAmount(feeRate.GetFeePerK());
}
UniValue checkkernel(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"checkkernel [{\"txid\":txid,\"vout\":n},...] [createblocktemplate=false]\n"
"Check if one of given inputs is a kernel input at the moment.\n"
);
RPCTypeCheck(params, boost::assign::list_of(UniValue::VARR)(UniValue::VBOOL));
UniValue inputs = params[0].get_array();
bool fCreateBlockTemplate = params.size() > 1 ? params[1].get_bool() : false;
if (vNodes.empty())
throw JSONRPCError(-9, "FashionkingWoncash is not connected!");
if (IsInitialBlockDownload())
throw JSONRPCError(-10, "FashionkingWoncash is downloading blocks...");
COutPoint kernel;
CBlockIndex* pindexPrev = chainActive.Tip();
CBlockHeader blockHeader = pindexPrev->GetBlockHeader();
unsigned int nBits = GetNextTargetRequired(pindexPrev, &blockHeader, Params().GetConsensus(), true);
int64_t nTime = GetAdjustedTime();
nTime &= ~Params().GetConsensus().nStakeTimestampMask;
for (unsigned int idx = 0; idx < inputs.size(); idx++) {
const UniValue& input = inputs[idx];
const UniValue& o = input.get_obj();
const UniValue& txid_v = find_value(o, "txid");
if (!txid_v.isStr())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing txid key");
string txid = txid_v.get_str();
if (!IsHex(txid))
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected hex txid");
const UniValue& vout_v = find_value(o, "vout");
if (!vout_v.isNum())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing vout key");
int nOutput = vout_v.get_int();
if (nOutput < 0)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout must be positive");
COutPoint cInput(uint256S(txid), nOutput);
if (CheckKernel(pindexPrev, nBits, nTime, cInput))
{
kernel = cInput;
break;
}
}
UniValue result(UniValue::VOBJ);
result.push_back(Pair("found", !kernel.IsNull()));
if (kernel.IsNull())
return result;
UniValue oKernel(UniValue::VOBJ);
oKernel.push_back(Pair("txid", kernel.hash.GetHex()));
oKernel.push_back(Pair("vout", (int64_t)kernel.n));
oKernel.push_back(Pair("time", nTime));
result.push_back(Pair("kernel", oKernel));
if (!fCreateBlockTemplate)
return result;
int64_t nFees;
if (!pwalletMain->IsLocked())
pwalletMain->TopUpKeyPool();
CReserveKey pMiningKey(pwalletMain);
std::unique_ptr<CBlockTemplate> pblocktemplate(BlockAssembler(Params()).CreateNewBlock(pMiningKey.reserveScript, &nFees, true));
if (!pblocktemplate.get())
throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block");
CBlock *pblock = &pblocktemplate->block;
pblock->nTime = pblock->vtx[0].nTime = nTime;
CDataStream ss(SER_DISK, PROTOCOL_VERSION);
ss << *pblock;
result.push_back(Pair("blocktemplate", HexStr(ss.begin(), ss.end())));
result.push_back(Pair("blocktemplatefees", nFees));
CPubKey pubkey;
if (!pMiningKey.GetReservedKey(pubkey))
throw JSONRPCError(RPC_MISC_ERROR, "GetReservedKey failed");
result.push_back(Pair("blocktemplatesignkey", HexStr(pubkey)));
return result;
}
UniValue estimatepriority(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"estimatepriority nblocks\n"
"\nEstimates the approximate priority a zero-fee transaction needs to begin\n"
"confirmation within nblocks blocks.\n"
"\nArguments:\n"
"1. nblocks (numeric)\n"
"\nResult:\n"
"n (numeric) estimated priority\n"
"\n"
"A negative value is returned if not enough transactions and blocks\n"
"have been observed to make an estimate.\n"
"\nExample:\n"
+ HelpExampleCli("estimatepriority", "6")
);
RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM));
int nBlocks = params[0].get_int();
if (nBlocks < 1)
nBlocks = 1;
return mempool.estimatePriority(nBlocks);
}
UniValue estimatesmartfee(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"estimatesmartfee nblocks\n"
"\nWARNING: This interface is unstable and may disappear or change!\n"
"\nEstimates the approximate fee per kilobyte needed for a transaction to begin\n"
"confirmation within nblocks blocks if possible and return the number of blocks\n"
"for which the estimate is valid.\n"
"\nArguments:\n"
"1. nblocks (numeric)\n"
"\nResult:\n"
"{\n"
" \"feerate\" : x.x, (numeric) estimate fee-per-kilobyte (in BTC)\n"
" \"blocks\" : n (numeric) block number where estimate was found\n"
"}\n"
"\n"
"A negative value is returned if not enough transactions and blocks\n"
"have been observed to make an estimate for any number of blocks.\n"
"However it will not return a value below the mempool reject fee.\n"
"\nExample:\n"
+ HelpExampleCli("estimatesmartfee", "6")
);
RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM));
int nBlocks = params[0].get_int();
UniValue result(UniValue::VOBJ);
int answerFound;
CFeeRate feeRate = mempool.estimateSmartFee(nBlocks, &answerFound);
result.push_back(Pair("feerate", feeRate == CFeeRate(0) ? -1.0 : ValueFromAmount(feeRate.GetFeePerK())));
result.push_back(Pair("blocks", answerFound));
return result;
}
UniValue estimatesmartpriority(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"estimatesmartpriority nblocks\n"
"\nWARNING: This interface is unstable and may disappear or change!\n"
"\nEstimates the approximate priority a zero-fee transaction needs to begin\n"
"confirmation within nblocks blocks if possible and return the number of blocks\n"
"for which the estimate is valid.\n"
"\nArguments:\n"
"1. nblocks (numeric)\n"
"\nResult:\n"
"{\n"
" \"priority\" : x.x, (numeric) estimated priority\n"
" \"blocks\" : n (numeric) block number where estimate was found\n"
"}\n"
"\n"
"A negative value is returned if not enough transactions and blocks\n"
"have been observed to make an estimate for any number of blocks.\n"
"However if the mempool reject fee is set it will return 1e9 * MAX_MONEY.\n"
"\nExample:\n"
+ HelpExampleCli("estimatesmartpriority", "6")
);
RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM));
int nBlocks = params[0].get_int();
UniValue result(UniValue::VOBJ);
int answerFound;
double priority = mempool.estimateSmartPriority(nBlocks, &answerFound);
result.push_back(Pair("priority", priority));
result.push_back(Pair("blocks", answerFound));
return result;
}
static const CRPCCommand commands[] =
{ // category name actor (function) okSafeMode
// --------------------- ------------------------ ----------------------- ----------
{ "mining", "getnetworkhashps", &getnetworkhashps, true },
{ "mining", "getmininginfo", &getmininginfo, true },
{ "mining", "prioritisetransaction", &prioritisetransaction, true },
{ "mining", "getblocktemplate", &getblocktemplate, true },
{ "mining", "submitblock", &submitblock, true },
{ "mining", "checkkernel", &checkkernel, true },
{ "mining", "getstakinginfo", &getstakinginfo, true },
{ "generating", "generate", &generate, true },
{ "generating", "generatetoaddress", &generatetoaddress, true },
{ "util", "estimatefee", &estimatefee, true },
{ "util", "estimatepriority", &estimatepriority, true },
{ "util", "estimatesmartfee", &estimatesmartfee, true },
{ "util", "estimatesmartpriority", &estimatesmartpriority, true },
};
void RegisterMiningRPCCommands(CRPCTable &tableRPC)
{
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
tableRPC.appendCommand(commands[vcidx].name, &commands[vcidx]);
}
| [
"hamxa6667@gmail.com"
] | hamxa6667@gmail.com |
795c12cf29e3c246bfcff22e5af14a5c28705818 | 3a20cbc39dbbea2a8977f9e268655ca0c6d62885 | /C/payrollProgram/employee.cpp | 140f60e5028655a6e65d06bf09dad6ebeae24267 | [] | no_license | justSomeGuyWhoLearnedToCode/someSimpleFunctions | 28221cdd6119589969d1468a5bedb6344ababcfd | 2b1f62168fb86f59130922a7266f7c36aaf78ae9 | refs/heads/master | 2021-01-09T05:30:16.572248 | 2017-02-03T00:19:35 | 2017-02-03T00:19:35 | 80,781,214 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 481 | cpp | #include"employee.h"
#include<string>
#include<cstring>
Employee::Employee(char * n, double h, double w){
strcpy(name, n);
hours = h;
wage = w;
}
Employee::Employee(){}
void Employee::setName(char n[]){
strcpy(name, n);
}
void Employee::setHours(double h){
hours = h;
}
void Employee::setWage(double w){
wage = w;
}
const char * Employee::getName() const{
return name;
}
double Employee::getHours() const{
return hours;
}
double Employee::getWage() const{
return wage;
}
| [
"noreply@github.com"
] | noreply@github.com |
378b396f4e87ca5ca80282a04622b1ce3ac77335 | e5e1d16c96bb49edaaa82cb1d6fd6286fe0e2c5b | /src/NoiseGen.h | 54790a38df7bd22bea27e3b42bbecf49f879eee8 | [] | no_license | Goutch/SVO_Raytracer | c1f19b02d213fb47e79a7447f834208e44865d37 | 410d463d436fe7fe96c051220160617ed3e12cb2 | refs/heads/master | 2023-03-07T10:42:31.401179 | 2021-02-19T16:03:58 | 2021-02-19T16:03:58 | 280,725,281 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,118 | h | #pragma once
#include "vector"
#include "FastNoise.h"
enum class NoiseType {
simplex,
fractal,
perlin,
};
class NoiseGen {
FastNoise noise;
std::vector<NoiseType> types;
std::vector<float> weights;
std::vector<float> scales;
int seed;
float offSetX;
float offSetY;
public:
NoiseGen(int seed) {
this->seed = seed;
noise=FastNoise(seed);
}
void addLayer(NoiseType type, float weight, float scale) {
types.emplace_back(type);
weights.emplace_back(weight);
scales.emplace_back(scale);
}
float get(float x, float y) {
float n_value = 0.0f;
for (int i = 0; i < types.size(); ++i) {
switch (types[i]) {
case NoiseType::simplex:
n_value += ((noise.GetSimplex(x * scales[i], y * scales[i]) + 1.0f) / 2.0f) * weights[i];
break;
case NoiseType::perlin:
n_value += ((noise.GetPerlin(x * scales[i], y * scales[i]) + 1.0f) / 2.0f) * weights[i];
break;
case NoiseType::fractal:
n_value += ((noise.GetSimplexFractal(x * scales[i], y * scales[i]) + 1.0f) / 2.0f) * weights[i];
break;
}
}
return n_value;
}
float get(float x, float y, float z) {
float n_value = 0.0f;
for (int i = 0; i < types.size(); ++i) {
switch (types[i]) {
case NoiseType::simplex:
n_value += ((noise.GetSimplex(x * scales[i], y * scales[i], z * scales[i]) + 1.0f) / 2.0f) * weights[i];
break;
case NoiseType::perlin:
n_value += ((noise.GetPerlin(x * scales[i], y * scales[i], z * scales[i]) + 1.0f) / 2.0f) * weights[i];
break;
case NoiseType::fractal:
n_value += ((noise.GetSimplexFractal(x * scales[i], y * scales[i], z * scales[i]) + 1.0f) / 2.0f) * weights[i];
break;
}
}
return n_value;
}
}; | [
"gaboutch@outlook.com"
] | gaboutch@outlook.com |
7b326f7d07682a7dbe2ca7f108a8cff5ea727bc1 | b0e72f95e6dda5221fc1a7a655c00d93ea950534 | /Arithmatic.cpp | 0c79a891bd0cfac2c0bb6b13c33bd27d13791722 | [] | no_license | tahsinsiad/Problemsolving | 5a2d5d11739c9780d8af19a625d4f1eb8149be1e | 930454ad4f485864694bdc65a7f3ff4c9c5bee3d | refs/heads/master | 2020-03-28T01:04:22.883428 | 2018-09-05T07:30:43 | 2018-09-05T07:30:43 | 147,474,553 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 230 | cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
long long int N,M,x,ans,y;
//int a[200];
cin>>N>>M;
x=(N*(N+1))/2;
for(int i=0;i<M;i++)
{
cin>>y;
x=x-y;
}
cout<<x<<endl;
}
| [
"tak.siad16@gmail.com"
] | tak.siad16@gmail.com |
ba2f6bbb9a86b996a2f2c168566774f58506b334 | d9e76f2f1be1ac0c533961bb6b744688f59be5a4 | /GraduationProject/GaussSedelIterationSerialAlgorithm.h | 66128d129110c12be2852bd388da3a263a31b6ca | [] | no_license | man0307/GraduationProjectByCPP | 442dbdc37072aa0010bc162a1bcd5dc9e255f2b2 | edb95fb1d25c56dafb300e5afb6cda32a78afd45 | refs/heads/master | 2020-04-19T08:25:11.886615 | 2019-02-02T03:25:35 | 2019-02-02T03:25:35 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 804 | h | #pragma once
class GaussSedelIterationSerialAlgorithm
{
public:
GaussSedelIterationSerialAlgorithm(int N,double** A, double* B, double* X);
~GaussSedelIterationSerialAlgorithm();
//串行的高斯-赛尔德算法
double* gaussSedelIteration();
double getErrorLimit();
void setErrorLimit(double errorLimit);
int getMaxIterationTimes();
void setMaxIterationTimes(int maxIterationTimes);
//打印结果
void printResult();
private:
//误差率
double errorLimit = 0.0001;
//最大迭代次数
int maxIterationTimes = 10000;
//系数矩阵
double** A;
//常数项
double* B;
//未知数项
double* X;
//结果
double* result;
//矩阵长度
int N;
//误差验证函数
bool meetTheAccuracyRequirements(double* x, double* result, double errorLimit, int length);
};
| [
"1505191091l@qq.com"
] | 1505191091l@qq.com |
635b75f8eb3bcdea95ec964ee945f8255ba4b763 | 40e3ce01cd1dcf0a32fe8b21d5f0a272e32d53d6 | /snake/game.cpp | 879b1944c5a0b9d892f4a58f92d7ab60ddf99695 | [] | no_license | joosu77/cpp_games | d83413850fba0c331a73ff9ca468ba19b31bcb2c | e0085574c9e3efe0278d85de7870cac03e50e538 | refs/heads/master | 2021-01-23T06:34:45.152861 | 2017-09-22T16:08:16 | 2017-09-22T16:08:16 | 86,376,499 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,806 | cpp | #include <iostream>
#include <allegro.h>
#include <chrono>
#include "game.h"
#include "engine.h"
game::game(){
pillx = 1;
pilly = 1;
eat = false;
arrows = true;
vroom.FPS = 4;
vroom.initScreen(10,10);
xloc = vroom.xlen/2;
yloc = vroom.ylen/2;
direction = 'r';
// r, d, l, u
// ekraan
for (int i=0; i<vroom.ylen; i++){
for (int e=0; e<vroom.xlen; e++){
vroom.ekraan[i][e] = ground;
}
}
vroom.ekraan[yloc][xloc] = player;
vroom.ekraan[pilly][pillx] = pill;
lastx.push_back (xloc);
lasty.push_back (yloc);
}
void game::run(){
//menu();
while (true){
vroom.getInput();
brainz();
move();
vroom.printScreen();
std::cout << "hi";
wait(1000/vroom.FPS);
}
}
void game::menu(){
pre = false;
while (key[KEY_ENTER] != true){
vroom.getInput();
brainz();
move();
vroom.printScreen();
std::cout << "PRESS 'ENTER' TO START";
wait(1000/vroom.FPS);
}
pre = true;
vroom.score = 0;
}
void game::brainz(){
if (((vroom.xstick<0) || (vroom.buttons[3]) || (key[KEY_LEFT])) && (direction != 'r')){
direction = 'l';
} else if (((vroom.xstick>0) || (vroom.buttons[1]) || (key[KEY_RIGHT])) && (direction != 'l')){
direction = 'r';
}
if (((vroom.ystick<0) || (vroom.buttons[0]) || (key[KEY_UP])) && (direction != 'u')){
direction = 'd';
} else if (((vroom.ystick>0) || (vroom.buttons[2]) || (key[KEY_DOWN])) && (direction != 'd')){
direction = 'u';
}
if (vroom.buttons[4] && vroom.FPS>0.5){
vroom.FPS=vroom.FPS-0.5;
} else if (vroom.buttons[5]) {
vroom.FPS=vroom.FPS+0.5;
}
if (pillx == xloc && pilly == yloc && eat == false){
vroom.score = vroom.score+1;
vroom.FPS = vroom.FPS + 0.1;
eat = true;
}
}
void game::move(){
if (!eat){
bool draw = true;
for (int i=1; i<lasty.size(); i++){
if (lasty.front() == lasty[i] && lastx.front() == lastx[i]){
draw = false;
}
}
if (draw && !(lasty.front() == pilly && lastx.front() == pillx)){
vroom.ekraan[lasty.front()][lastx.front()] = ground;
}
lastx.erase(lastx.begin());
lasty.erase(lasty.begin());
} else {
// viimase kaigu jooksul on soodud
bool gend = false;
while (!gend){
// votan aja randomisaarimiseks
using namespace std::chrono;
auto epoch = high_resolution_clock::from_time_t(0);
auto now = high_resolution_clock::now();
auto seconds = duration_cast<milliseconds>(now - epoch).count();
long mills = seconds;
if (mills>1000){
mills=mills%1000;
}
// uue pilli paigutamine
eat = false;
if (vroom.score == 1){
vroom.ekraan[pilly][pillx] = ground;
} else {
vroom.ekraan[pilly][pillx] = player;
}
pillx = seconds % vroom.xlen;
pilly = (seconds*(seconds/1000)+1) % vroom.ylen;
if (vroom.ekraan[pilly][pillx] == ground){
gend = true;
}
}
vroom.ekraan[pilly][pillx] = pill;
}
actualMove(direction);
bool surm = false;
for (int i=0; i<lasty.size(); i++){
if (yloc == lasty[i] && xloc == lastx[i]){
surm = true;
}
}
if (surm){
exit(0);
}
lastx.push_back(xloc);
lasty.push_back(yloc);
vroom.ekraan[yloc][xloc] = player;
}
void game::actualMove(char dir){
if (pre){
if (dir == 'u' && yloc<(vroom.ylen-1)){
yloc = yloc + 1;
} else if (dir == 'r' && xloc<(vroom.ylen-1)){
xloc = xloc + 1;
} else if (dir == 'd' && yloc>0){
yloc = yloc - 1;
} else if (dir == 'l' && xloc>0){
xloc = xloc - 1;
} else {
exit(0);
}
} else {
if (dir == 'u' && yloc<(vroom.ylen-1)){
yloc = yloc + 1;
} else if (dir == 'r' && xloc<(vroom.ylen-1)){
xloc = xloc + 1;
} else if (dir == 'd' && yloc>0){
yloc = yloc - 1;
} else if (dir == 'l' && xloc>0){
xloc = xloc - 1;
}
}
}
void game::wait(long milliSeconds){
using namespace std::chrono;
auto start = high_resolution_clock::now();
auto now = high_resolution_clock::now();
auto interval = duration_cast<milliseconds>(now - start).count();
while(interval<milliSeconds){
vroom.getInput();
brainz();
usleep(100000);
now = high_resolution_clock::now();
interval = duration_cast<milliseconds>(now-start).count();
}
}
| [
"joosep.naks@mail.ee"
] | joosep.naks@mail.ee |
8ea7b7bde2e86cdcf3a961d75bc9d27d8272c8ec | 787caee96dc37f654205314acd3144824a27e1a1 | /code/src/Installer/ISOPDel.h | 5a0bea82c4d089bb2332794f2c86b09e62782aec | [] | no_license | zleesz/light-installer | 483d1126f780983d5e784421302eb459d1adb76a | 2b89b321afc517ce9bd242e0582b6eca5a6d9e92 | refs/heads/master | 2020-04-06T06:21:17.609122 | 2012-12-01T07:11:33 | 2012-12-01T07:11:33 | 32,120,002 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 357 | h | #pragma once
#include "isopbase.h"
class CISOPDel :
public CISOPBase
{
public:
CISOPDel(void);
~CISOPDel(void);
public:
const std::wstring toString() const;
OpErrorCode operator()() const;
LONG GetValue() const { return 1; };
ISOPType GetType() const { return ISOP_Type_Del; };
OpErrorCode SetLine(const std::wstring &wstrLine);
};
| [
"leezhisz@gmail.com@1d4ae84b-cad1-9917-5e14-7a3f44723f96"
] | leezhisz@gmail.com@1d4ae84b-cad1-9917-5e14-7a3f44723f96 |
b21fb20505310f7294edcbd6e853c57276c60c8e | e2021e9651b63a6ff9718ba628d3ad9f6b8ae981 | /2352/4446422_AC_157MS_692K.cc | d99f6549dc08d93c74db0d0d09bc1f1154eade06 | [
"Apache-2.0"
] | permissive | fanmengcheng/twilight-poj-solution | 36831f1a9b2d8bc020988e0606b240527a381754 | 3af3f0fb0c5f350cdf6421b943c6df02ee3f2f82 | refs/heads/master | 2020-04-08T22:36:47.267071 | 2015-05-26T10:21:03 | 2015-05-26T10:25:46 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,214 | cc | /**********************************************************************
* Online Judge : POJ
* Problem Title : Stars
* ID : 2352
* Date : 12/2/2008
* Time : 13:8:22
* Computer Name : EVERLASTING-PC
***********************************************************************/
#include<iostream>
using namespace std;
#define MAXC 32000
#define MAXN 15000
int C[MAXC+1];
int Level[MAXN];
int r[MAXN],x[MAXN];
int n,m;
inline int LowBit(int x)
{
return x&(-x);
}
int Sum(int i)
{
int s=0;
while (i>0)
{
s+=C[i];
i-=LowBit(i);
}
return s;
}
void Modify(int i,int delta,int len)
{
while (i<=len)
{
C[i]+=delta;
i+=LowBit(i);
}
}
int main()
{
//freopen("in_2352.txt","r",stdin);
while(scanf("%d",&n)!=-1)
{
for (int i=0;i<n;++i)
{
scanf("%d%d",&x[i],&m);
x[i]++;
}
r[n-1]=x[n-1];
m=0;
for (int i=n-2;i>=0;--i)
{
r[i]=x[i]>r[i+1]?x[i]:r[i+1];
if (m<x[i])
{
m=x[i];
}
}
memset(C,0,sizeof(int)*(m+1));
memset(Level,0,sizeof(int)*n);
for (int i=0;i<n;++i)
{
Level[Sum(x[i])]++;
Modify(x[i],1,r[i]);
}
for (int i=0;i<n;++i)
{
printf("%d\n",Level[i]);
}
}
return 0;
}
| [
"pengx@microsoft.com"
] | pengx@microsoft.com |
b24496c1c26a82e21be01750054b77361cda718b | ce6ee1eb9207dcb6f5460a910bcab075f2041f97 | /hphp/runtime/vm/jit/irlower-bespoke.cpp | 9ededfe9b350651d82ef1b6996e99bdb729a1dbf | [
"MIT",
"Zend-2.0",
"PHP-3.01"
] | permissive | jdx/hhvm | 7532238a8e39c6a97fd61abe4a8f3f5877e3e463 | 607adb0a032f4768ad739ea08fba0b8ef8a5d967 | refs/heads/master | 2023-09-01T15:51:55.384577 | 2021-05-26T17:08:18 | 2021-05-26T17:09:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 29,005 | cpp | /*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#include "hphp/runtime/vm/jit/irlower-bespoke.h"
#include "hphp/runtime/base/bespoke/escalation-logging.h"
#include "hphp/runtime/base/bespoke/layout.h"
#include "hphp/runtime/base/bespoke/logging-profile.h"
#include "hphp/runtime/base/bespoke/monotype-dict.h"
#include "hphp/runtime/base/bespoke/monotype-vec.h"
#include "hphp/runtime/base/bespoke/struct-dict.h"
#include "hphp/runtime/base/mixed-array.h"
#include "hphp/runtime/base/packed-array.h"
#include "hphp/runtime/base/set-array.h"
#include "hphp/runtime/vm/jit/code-gen-cf.h"
#include "hphp/runtime/vm/jit/code-gen-helpers.h"
#include "hphp/runtime/vm/jit/irlower.h"
#include "hphp/runtime/vm/jit/irlower-internal.h"
#include "hphp/runtime/vm/jit/ir-opcode.h"
#include "hphp/runtime/vm/jit/minstr-helpers.h"
#include "hphp/runtime/vm/jit/translator-inline.h"
namespace HPHP { namespace jit { namespace irlower {
//////////////////////////////////////////////////////////////////////////////
// Generic BespokeArrays
namespace {
static void logGuardFailure(TypedValue tv, uint16_t layout, uint64_t sk) {
assertx(tvIsArrayLike(tv));
auto const al = ArrayLayout::FromUint16(layout);
bespoke::logGuardFailure(val(tv).parr, al, SrcKey(sk));
}
}
void cgLogArrayReach(IRLS& env, const IRInstruction* inst) {
auto const data = inst->extra<LogArrayReach>();
auto& v = vmain(env);
auto const args = argGroup(env, inst).imm(data->profile).ssa(0);
auto const target = CallSpec::method(&bespoke::SinkProfile::update);
cgCallHelper(v, env, target, callDest(env, inst), SyncOptions::Sync, args);
}
void cgLogGuardFailure(IRLS& env, const IRInstruction* inst) {
auto const layout = inst->typeParam().arrSpec().layout().toUint16();
auto const sk = inst->marker().sk().toAtomicInt();
auto& v = vmain(env);
auto const args = argGroup(env, inst).typedValue(0).imm(layout).imm(sk);
auto const target = CallSpec::direct(logGuardFailure);
cgCallHelper(v, env, target, callDest(env, inst), SyncOptions::Sync, args);
}
void cgNewLoggingArray(IRLS& env, const IRInstruction* inst) {
auto const data = inst->extra<NewLoggingArray>();
auto const target = [&] {
using Fn = ArrayData*(*)(ArrayData*, bespoke::LoggingProfile*);
return shouldTestBespokeArrayLikes()
? CallSpec::direct(static_cast<Fn>(bespoke::makeBespokeForTesting))
: CallSpec::direct(static_cast<Fn>(bespoke::maybeMakeLoggingArray));
}();
cgCallHelper(vmain(env), env, target, callDest(env, inst), SyncOptions::Sync,
argGroup(env, inst).ssa(0).immPtr(data->profile));
}
void cgProfileArrLikeProps(IRLS& env, const IRInstruction* inst) {
auto const target = CallSpec::direct(bespoke::profileArrLikeProps);
cgCallHelper(vmain(env), env, target, kVoidDest, SyncOptions::Sync,
argGroup(env, inst).ssa(0));
}
//////////////////////////////////////////////////////////////////////////////
// This macro returns a CallSpec to one of several static functions:
//
// - the one on a specific, concrete bespoke layout;
// - the generic one on BespokeArray;
// - the ones on the vanilla arrays (Packed, Mixed, Set);
// - failing all those options, the CallSpec Generic
//
#define CALL_TARGET(Type, Fn, Generic) \
[&]{ \
auto const layout = Type.arrSpec().layout(); \
if (layout.bespoke()) { \
auto const vtable = layout.bespokeLayout()->vtable(); \
if (vtable->fn##Fn) { \
return CallSpec::direct(vtable->fn##Fn); \
} else { \
return CallSpec::direct(BespokeArray::Fn); \
} \
} \
if (layout.vanilla()) { \
if (arr <= TVec) return CallSpec::direct(PackedArray::Fn); \
if (arr <= TDict) return CallSpec::direct(MixedArray::Fn); \
if (arr <= TKeyset) return CallSpec::direct(SetArray::Fn); \
} \
return Generic; \
}()
#define CALL_TARGET_SYNTH(Type, Fn, Generic) \
[&]{ \
auto const layout = Type.arrSpec().layout(); \
if (layout.bespoke()) { \
auto const vtable = layout.bespokeLayout()->vtable(); \
if (vtable->fn##Fn) { \
return CallSpec::direct(vtable->fn##Fn); \
} else { \
return CallSpec::direct(BespokeArray::Fn); \
} \
} \
if (layout.vanilla()) { \
if (arr <= TVec) { \
return CallSpec::direct(SynthesizedArrayFunctions<PackedArray>::Fn); \
} \
if (arr <= TDict) { \
return CallSpec::direct(SynthesizedArrayFunctions<MixedArray>::Fn); \
} \
if (arr <= TKeyset) { \
return CallSpec::direct(SynthesizedArrayFunctions<SetArray>::Fn); \
} \
} \
return Generic; \
}()
CallSpec destructorForArrayLike(Type arr) {
assertx(arr <= TArrLike);
assertx(allowBespokeArrayLikes());
return CALL_TARGET(arr, Release, CallSpec::method(&ArrayData::release));
}
void cgBespokeGet(IRLS& env, const IRInstruction* inst) {
using GetInt = TypedValue (ArrayData::*)(int64_t) const;
using GetStr = TypedValue (ArrayData::*)(const StringData*) const;
auto const getInt =
CallSpec::method(static_cast<GetInt>(&ArrayData::get));
auto const getStr =
CallSpec::method(static_cast<GetStr>(&ArrayData::get));
auto const arr = inst->src(0)->type();
auto const key = inst->src(1)->type();
auto const target = (key <= TInt)
? CALL_TARGET(arr, NvGetInt, getInt)
: CALL_TARGET(arr, NvGetStr, getStr);
auto& v = vmain(env);
auto const args = argGroup(env, inst).ssa(0).ssa(1);
cgCallHelper(v, env, target, callDestTV(env, inst), SyncOptions::Sync, args);
}
void cgBespokeGetThrow(IRLS& env, const IRInstruction* inst) {
using GetInt = TypedValue (ArrayData::*)(int64_t) const;
using GetStr = TypedValue (ArrayData::*)(const StringData*) const;
auto const getInt =
CallSpec::method(static_cast<GetInt>(&ArrayData::getThrow));
auto const getStr =
CallSpec::method(static_cast<GetStr>(&ArrayData::getThrow));
auto const arr = inst->src(0)->type();
auto const key = inst->src(1)->type();
auto const target = (key <= TInt)
? CALL_TARGET_SYNTH(arr, NvGetIntThrow, getInt)
: CALL_TARGET_SYNTH(arr, NvGetStrThrow, getStr);
auto& v = vmain(env);
auto const args = argGroup(env, inst).ssa(0).ssa(1);
cgCallHelper(v, env, target, callDestTV(env, inst), SyncOptions::Sync, args);
}
void cgBespokeSet(IRLS& env, const IRInstruction* inst) {
using SetInt = ArrayData* (ArrayData::*)(int64_t, TypedValue);
using SetStr = ArrayData* (ArrayData::*)(StringData*, TypedValue);
auto const setIntMove =
CallSpec::method(static_cast<SetInt>(&ArrayData::setMove));
auto const setStrMove =
CallSpec::method(static_cast<SetStr>(&ArrayData::setMove));
auto const arr = inst->src(0)->type();
auto const key = inst->src(1)->type();
auto const target = (key <= TInt)
? CALL_TARGET(arr, SetIntMove, setIntMove)
: CALL_TARGET(arr, SetStrMove, setStrMove);
auto& v = vmain(env);
auto const args = argGroup(env, inst).ssa(0).ssa(1).typedValue(2);
cgCallHelper(v, env, target, callDest(env, inst), SyncOptions::Sync, args);
}
void cgBespokeAppend(IRLS& env, const IRInstruction* inst) {
using Append = ArrayData* (ArrayData::*)(TypedValue);
auto const appendMove =
CallSpec::method(static_cast<Append>(&ArrayData::appendMove));
auto const arr = inst->src(0)->type();
auto const target = CALL_TARGET(arr, AppendMove, appendMove);
auto& v = vmain(env);
auto const args = argGroup(env, inst).ssa(0).typedValue(1);
cgCallHelper(v, env, target, callDest(env, inst), SyncOptions::Sync, args);
}
void cgBespokeIterFirstPos(IRLS& env, const IRInstruction* inst) {
auto const arr = inst->src(0)->type();
auto const iterBegin = CallSpec::method(&ArrayData::iter_begin);
auto const target = CALL_TARGET(arr, IterBegin, iterBegin);
auto& v = vmain(env);
auto const args = argGroup(env, inst).ssa(0);
cgCallHelper(v, env, target, callDest(env, inst), SyncOptions::Sync, args);
}
void cgBespokeIterLastPos(IRLS& env, const IRInstruction* inst) {
auto const arr = inst->src(0)->type();
auto const iterLast = CallSpec::method(&ArrayData::iter_last);
auto const target = CALL_TARGET(arr, IterLast, iterLast);
auto& v = vmain(env);
auto const args = argGroup(env, inst).ssa(0);
cgCallHelper(v, env, target, callDest(env, inst), SyncOptions::Sync, args);
}
void cgBespokeIterEnd(IRLS& env, const IRInstruction* inst) {
auto const arr = inst->src(0)->type();
auto const iterEnd = CallSpec::method(&ArrayData::iter_end);
auto const target = CALL_TARGET(arr, IterEnd, iterEnd);
auto& v = vmain(env);
auto const args = argGroup(env, inst).ssa(0);
cgCallHelper(v, env, target, callDest(env, inst), SyncOptions::Sync, args);
}
void cgBespokeIterGetKey(IRLS& env, const IRInstruction* inst) {
auto const arr = inst->src(0)->type();
auto const getPosKey = CallSpec::method(&ArrayData::nvGetKey);
auto const target = CALL_TARGET(arr, GetPosKey, getPosKey);
auto& v = vmain(env);
auto const args = argGroup(env, inst).ssa(0).ssa(1);
cgCallHelper(v, env, target, callDestTV(env, inst), SyncOptions::Sync, args);
}
void cgBespokeIterGetVal(IRLS& env, const IRInstruction* inst) {
auto const arr = inst->src(0)->type();
auto const getPosVal = CallSpec::method(&ArrayData::nvGetVal);
auto const target = CALL_TARGET(arr, GetPosVal, getPosVal);
auto& v = vmain(env);
auto const args = argGroup(env, inst).ssa(0).ssa(1);
cgCallHelper(v, env, target, callDestTV(env, inst), SyncOptions::Sync, args);
}
void cgBespokeEscalateToVanilla(IRLS& env, const IRInstruction* inst) {
auto const target = [&] {
auto const layout = inst->src(0)->type().arrSpec().layout();
auto const vtable = layout.bespokeLayout()->vtable();
if (vtable->fnEscalateToVanilla) {
return CallSpec::direct(vtable->fnEscalateToVanilla);
} else {
return CallSpec::direct(BespokeArray::ToVanilla);
}
}();
auto& v = vmain(env);
auto const reason = inst->src(1)->strVal()->data();
auto const args = argGroup(env, inst).ssa(0).imm(reason);
cgCallHelper(v, env, target, callDest(env, inst), SyncOptions::Sync, args);
}
#undef CALL_TARGET
void cgBespokeElem(IRLS& env, const IRInstruction* inst) {
auto& v = vmain(env);
auto const dest = callDest(env, inst);
auto args = argGroup(env, inst).ssa(0).ssa(1);
auto const target = [&] {
auto const arr = inst->src(0);
auto const key = inst->src(1);
auto const layout = arr->type().arrSpec().layout();
// Bespoke arrays always have specific Elem helper functions.
if (layout.bespoke()) {
args.ssa(2);
auto const vtable = layout.bespokeLayout()->vtable();
if (key->isA(TStr) && vtable->fnElemStr) {
return CallSpec::direct(vtable->fnElemStr);
} else if (key->isA(TInt) && vtable->fnElemInt) {
return CallSpec::direct(vtable->fnElemInt);
} else {
return key->isA(TStr) ? CallSpec::direct(BespokeArray::ElemStr)
: CallSpec::direct(BespokeArray::ElemInt);
}
}
// Aside from known-bespokes, we only specialize certain Elem cases -
// the ones we already have symbols for in the MInstrHelpers namespace.
using namespace MInstrHelpers;
auto const throwOnMissing = inst->src(2)->boolVal();
if (layout.vanilla()) {
if (arr->isA(TDict)) {
return key->isA(TStr)
? CallSpec::direct(throwOnMissing ? elemDictSD : elemDictSU)
: CallSpec::direct(throwOnMissing ? elemDictID : elemDictIU);
}
if (arr->isA(TKeyset) && !throwOnMissing) {
return key->isA(TStr)
? CallSpec::direct(elemKeysetSU)
: CallSpec::direct(elemKeysetIU);
}
}
args.ssa(3);
return key->isA(TStr)
? CallSpec::direct(throwOnMissing ? elemSD : elemSU)
: CallSpec::direct(throwOnMissing ? elemID : elemIU);
}();
cgCallHelper(v, env, target, dest, SyncOptions::Sync, args);
}
//////////////////////////////////////////////////////////////////////////////
// MonotypeVec and MonotypeDict
namespace {
using MonotypeDict = bespoke::MonotypeDict<int64_t>;
// Returns a pointer to a value `off` bytes into the MonotypeDict element at
// the iterator position `pos` in the dict pointed to by `rarr`.
Vptr ptrToMonotypeDictElm(Vout& v, Vreg rarr, Vreg rpos, Type pos, size_t off) {
auto const base = MonotypeDict::entriesOffset() + off;
if (pos.hasConstVal()) {
auto const offset = pos.intVal() * MonotypeDict::elmSize() + base;
if (deltaFits(offset, sz::dword)) return rarr[offset];
}
static_assert(MonotypeDict::elmSize() == 16);
auto posl = v.makeReg();
auto scaled_posl = v.makeReg();
auto scaled_pos = v.makeReg();
v << movtql{rpos, posl};
v << shlli{1, posl, scaled_posl, v.makeReg()};
v << movzlq{scaled_posl, scaled_pos};
return rarr[scaled_pos * int(MonotypeDict::elmSize() / 2) + base];
}
}
void cgLdMonotypeDictTombstones(IRLS& env, const IRInstruction* inst) {
static_assert(MonotypeDict::tombstonesSize() == 2);
auto const rarr = srcLoc(env, inst, 0).reg();
auto const used = dstLoc(env, inst, 0).reg();
vmain(env) << loadzwq{rarr[MonotypeDict::tombstonesOffset()], used};
}
void cgLdMonotypeDictKey(IRLS& env, const IRInstruction* inst) {
auto const rarr = srcLoc(env, inst, 0).reg();
auto const rpos = srcLoc(env, inst, 1).reg();
auto const pos = inst->src(1)->type();
auto const dst = dstLoc(env, inst, 0);
auto& v = vmain(env);
auto const off = MonotypeDict::elmKeyOffset();
auto const ptr = ptrToMonotypeDictElm(v, rarr, rpos, pos, off);
v << load{ptr, dst.reg(0)};
if (dst.hasReg(1)) {
auto const sf = v.makeReg();
auto const intb = v.cns(KindOfInt64);
auto const strb = v.cns(KindOfString);
auto const mask = safe_cast<int32_t>(MonotypeDict::intKeyMask().raw);
auto const layout = rarr[ArrayData::offsetOfBespokeIndex()];
v << testwim{mask, layout, sf};
v << cmovb{CC_Z, sf, intb, strb, dst.reg(1)};
}
}
void cgLdMonotypeDictVal(IRLS& env, const IRInstruction* inst) {
auto const rarr = srcLoc(env, inst, 0).reg();
auto const rpos = srcLoc(env, inst, 1).reg();
auto const pos = inst->src(1)->type();
auto const dst = dstLoc(env, inst, 0);
auto& v = vmain(env);
auto const off = MonotypeDict::elmValOffset();
auto const ptr = ptrToMonotypeDictElm(v, rarr, rpos, pos, off);
v << load{ptr, dst.reg(0)};
if (dst.hasReg(1)) {
v << loadb{rarr[MonotypeDict::typeOffset()], dst.reg(1)};
}
}
void cgLdMonotypeVecElem(IRLS& env, const IRInstruction* inst) {
auto const rarr = srcLoc(env, inst, 0).reg();
auto const ridx = srcLoc(env, inst, 1).reg();
auto const idx = inst->src(1);
auto const type = rarr[bespoke::MonotypeVec::typeOffset()];
auto const value = [&] {
auto const base = bespoke::MonotypeVec::entriesOffset();
if (idx->hasConstVal()) {
auto const offset = idx->intVal() * sizeof(Value) + base;
if (deltaFits(offset, sz::dword)) return rarr[offset];
}
return rarr[ridx * int(sizeof(Value)) + base];
}();
loadTV(vmain(env), inst->dst()->type(), dstLoc(env, inst, 0),
type, value);
}
//////////////////////////////////////////////////////////////////////////////
// StructDict
namespace {
using bespoke::StructDict;
using bespoke::StructLayout;
// Returns none if the layout is an abstract struct layout.
folly::Optional<Slot> getStructSlot(const SSATmp* arr, const SSATmp* key) {
assertx(key->hasConstVal(TStr));
auto const layout = arr->type().arrSpec().layout();
assertx(layout.is_struct());
if (!layout.bespokeLayout()->isConcrete()) return folly::none;
auto const slayout = bespoke::StructLayout::As(layout.bespokeLayout());
return slayout->keySlot(key->strVal());
}
}
void cgAllocBespokeStructDict(IRLS& env, const IRInstruction* inst) {
auto const extra = inst->extra<AllocBespokeStructDict>();
auto& v = vmain(env);
auto const layout = StructLayout::As(extra->layout.bespokeLayout());
auto const target = CallSpec::direct(StructDict::AllocStructDict);
auto const args = argGroup(env, inst)
.imm(layout->sizeIndex())
.imm(layout->extraInitializer());
cgCallHelper(v, env, target, callDest(env, inst), SyncOptions::None, args);
}
void cgInitStructPositions(IRLS& env, const IRInstruction* inst) {
auto const arr = srcLoc(env, inst, 0).reg();
auto const extra = inst->extra<InitStructPositions>();
auto& v = vmain(env);
v << storel{v.cns(extra->numSlots), arr[ArrayData::offsetofSize()]};
auto constexpr kSlotsPerStore = 8;
for (auto i = 0; i < extra->numSlots; i += kSlotsPerStore) {
uint64_t slots = 0;
for (auto j = 0; j < kSlotsPerStore; j++) {
auto const index = i + j;
auto const slot = index < extra->numSlots
? safe_cast<uint8_t>(extra->slots[index])
: static_cast<uint8_t>(KindOfUninit);
slots = slots | (safe_cast<uint64_t>(slot) << (j * 8));
}
v << store{v.cns(slots), arr[StructDict::positionOffset() + i]};
}
}
void cgInitStructElem(IRLS& env, const IRInstruction* inst) {
auto const arr = inst->src(0);
auto const layout = arr->type().arrSpec().layout();
auto const slayout = bespoke::StructLayout::As(layout.bespokeLayout());
auto const rarr = srcLoc(env, inst, 0).reg();
auto const slot = inst->extra<InitStructElem>()->index;
auto const type = rarr[slayout->typeOffsetForSlot(slot)];
auto const data = rarr[slayout->valueOffsetForSlot(slot)];
storeTV(vmain(env), inst->src(1)->type(), srcLoc(env, inst, 1), type, data);
}
void cgNewBespokeStructDict(IRLS& env, const IRInstruction* inst) {
auto const sp = srcLoc(env, inst, 0).reg();
auto const extra = inst->extra<NewBespokeStructDict>();
auto& v = vmain(env);
auto const n = static_cast<size_t>((extra->numSlots + 7) & ~7);
auto const slots = reinterpret_cast<uint8_t*>(v.allocData<uint64_t>(n / 8));
for (auto i = 0; i < extra->numSlots; i++) {
slots[i] = safe_cast<uint8_t>(extra->slots[i]);
}
for (auto i = extra->numSlots; i < n; i++) {
slots[i] = static_cast<uint8_t>(KindOfUninit);
}
auto const layout = StructLayout::As(extra->layout.bespokeLayout());
auto const target = CallSpec::direct(StructDict::MakeStructDict);
auto const args = argGroup(env, inst)
.imm(layout->sizeIndex())
.imm(layout->extraInitializer())
.imm(extra->numSlots)
.dataPtr(slots)
.addr(sp, cellsToBytes(extra->offset.offset));
cgCallHelper(v, env, target, callDest(env, inst), SyncOptions::None, args);
}
void cgLdStructDictElem(IRLS& env, const IRInstruction* inst) {
auto const arr = inst->src(0);
auto const key = inst->src(1);
auto const slot = getStructSlot(arr, key);
if (!slot) return cgBespokeGet(env, inst);
if (*slot == kInvalidSlot) {
always_assert(inst->dst()->isA(TUninit));
return;
}
auto const layout = arr->type().arrSpec().layout();
auto const slayout = bespoke::StructLayout::As(layout.bespokeLayout());
auto const rarr = srcLoc(env, inst, 0).reg();
auto const type = rarr[slayout->typeOffsetForSlot(*slot)];
auto const data = rarr[slayout->valueOffsetForSlot(*slot)];
loadTV(vmain(env), inst->dst()->type(), dstLoc(env, inst, 0), type, data);
}
void cgStructDictGetWithColor(IRLS& env, const IRInstruction* inst) {
auto const arr = inst->src(0);
auto const key = inst->src(1);
auto const dst = dstLoc(env, inst, 0);
auto const rarr = srcLoc(env, inst, 0).reg();
auto const rkey = srcLoc(env, inst, 1).reg();
auto& v = vmain(env);
auto const makeNonstaticCall =
[&](Vout& v, const Vreg& value, const Vreg& type) {
auto const target =
CallSpec::direct(bespoke::StructDict::NvGetStrNonStatic);
auto const args = argGroup(env, inst).ssa(0).ssa(1);
cgCallHelper(v, env, target, callDest(value, type), SyncOptions::Sync,
args);
};
// Is the key certain to be non-static? If so, invoke the non-static helper.
if (!key->type().maybe(TStaticStr)) {
makeNonstaticCall(v, dst.reg(0), dst.reg(1));
return;
}
// 1) Read the string's color. This may be junk if the string is non-static.
auto constexpr layoutMask = StructLayout::kMaxColor;
auto constexpr hashEntrySize =
sizeof(bespoke::StructLayout::PerfectHashEntry);
auto const getColor = [&] {
auto const colorMasked = [&] {
static_assert(folly::isPowTwo(layoutMask + 1));
static_assert(layoutMask <= std::numeric_limits<uint8_t>::max());
auto const colorPremask = v.makeReg();
v << loadzbq{rkey[StringData::colorOffset()], colorPremask};
if (layoutMask == std::numeric_limits<uint8_t>::max()) {
return colorPremask;
} else {
auto const colorMasked = v.makeReg();
v << andqi{uint8_t(layoutMask), colorPremask, colorMasked, v.makeReg()};
return colorMasked;
}
}();
static_assert(hashEntrySize == 8 || hashEntrySize == 16);
if constexpr (hashEntrySize == 16) {
// Without lowptr enabled, we have to use a 16-byte stride.
auto const colorFinal = v.makeReg();
v << lea{colorMasked[colorMasked], colorFinal};
return colorFinal;
} else {
return colorMasked;
}
};
auto constexpr strHashOffset =
offsetof(bespoke::StructLayout::PerfectHashEntry, str);
auto constexpr valHashOffset =
offsetof(bespoke::StructLayout::PerfectHashEntry, valueOffset);
auto constexpr typeHashOffset =
offsetof(bespoke::StructLayout::PerfectHashEntry, typeOffset);
// 2) Obtain the addresses of the string, value offset, and type offset in
// the perfect hash table.
auto const tuple = [&] {
auto const layout = arr->type().arrSpec().layout();
assertx(layout.is_struct());
// 2a) If the layout is known, we can obtain its perfect hash table address
// statically.
if (layout.bespokeLayout()->isConcrete()) {
auto const hashTable = (uintptr_t)
bespoke::StructLayout::hashTableForLayout(layout.bespokeLayout());
auto const base = v.cns(hashTable);
auto const entryWithOffset = [&]() -> std::function<Vptr(size_t)> {
if (key->hasConstVal(TStr)) {
return [&](size_t off) {
auto const offWithColor =
(key->strVal()->color() & layoutMask) * hashEntrySize + off;
return base[offWithColor];
};
}
auto const color = getColor();
return [=](size_t off) { return base[color * 8 + off]; };
}();
return std::make_tuple(
entryWithOffset(strHashOffset),
entryWithOffset(valHashOffset),
entryWithOffset(typeHashOffset)
);
}
// 2b) Otherwise, we'll have to index into the table set to find the
// layout's perfect hash table.
auto const hashTableSet = (uintptr_t) bespoke::StructLayout::hashTableSet();
auto const layoutIndex = v.makeReg();
v << loadzwq{rarr[ArrayData::offsetOfBespokeIndex()], layoutIndex};
auto constexpr hashTableSize =
sizeof(bespoke::StructLayout::PerfectHashTable);
static_assert(folly::isPowTwo(hashTableSize));
auto const layoutShift =
safe_cast<uint8_t>(folly::findLastSet(hashTableSize) - 1);
auto const hashTableOffset = v.makeReg();
v << shlqi{layoutShift, layoutIndex, hashTableOffset, v.makeReg()};
auto const entryWithOffset = [&]() -> std::function<Vptr(size_t)> {
if (key->hasConstVal(TStr)) {
return [&](size_t off) {
auto const offWithColor =
(key->strVal()->color() & layoutMask) * hashEntrySize + off;
return hashTableOffset[v.cns(hashTableSet) + offWithColor];
};
}
auto const base = v.makeReg();
v << lea{hashTableOffset[v.cns(hashTableSet)], base};
auto const color = getColor();
return [=](size_t off) { return base[color * 8 + off]; };
}();
return std::make_tuple(
entryWithOffset(strHashOffset),
entryWithOffset(valHashOffset),
entryWithOffset(typeHashOffset)
);
}();
auto const strPtr = std::get<0>(tuple);
auto const valPtr = std::get<1>(tuple);
auto const typePtr = std::get<2>(tuple);
// 3) Retrieve the string pointer from the perfect hash table.
auto const hashStr = v.makeReg();
emitLdLowPtr(v, strPtr, hashStr, sizeof(LowStringPtr));
// 4) Check if the string pointer matches.
auto const sf = v.makeReg();
v << cmpq{rkey, hashStr, sf};
cond(v, v, CC_E, sf, v.makeTuple({dst.reg(0), dst.reg(1)}),
[&] (Vout& v) {
// 4a) The string matched! Load the value and type offsets out of the
// perfect hash table, and use them to index into the struct.
auto const valueOff = v.makeReg();
auto const typeOff = v.makeReg();
v << loadzwq{valPtr, valueOff};
v << loadzwq{typePtr, typeOff};
auto const value = v.makeReg();
auto const type = v.makeReg();
v << load{rarr[valueOff], value};
v << loadb{rarr[typeOff], type};
return v.makeTuple({value, type});
},
[&] (Vout& v) {
// 4b) The string did not match. If the key is static, then we know the
// field is absent. If the key is non-static, we fall back to the
// non-static lookup routine.
if (key->type() <= TStaticStr) {
return v.makeTuple({v.cns(0), v.cns(KindOfUninit)});
}
auto const value = v.makeReg();
auto const type = v.makeReg();
auto const sf = emitCmpRefCount(v, StaticValue, rkey);
cond(v, v, CC_E, sf, v.makeTuple({value, type}),
[&] (Vout& v) {
return v.makeTuple({v.cns(0), v.cns(KindOfUninit)});
},
[&] (Vout& v) {
auto const callValue = v.makeReg();
auto const callType = v.makeReg();
makeNonstaticCall(v, callValue, callType);
return v.makeTuple({callValue, callType});
},
StringTag{}
);
return v.makeTuple({value, type});
},
StringTag{}
);
}
void cgStructDictSet(IRLS& env, const IRInstruction* inst) {
auto const arr = inst->src(0);
auto const key = inst->src(1);
auto const slot = getStructSlot(arr, key);
if (!slot || (*slot == kInvalidSlot)) return cgBespokeSet(env, inst);
auto& v = vmain(env);
auto const target = CallSpec::direct(bespoke::StructDict::SetStrInSlot);
auto const args = argGroup(env, inst).ssa(0).imm(*slot).typedValue(2);
cgCallHelper(v, env, target, callDest(env, inst), SyncOptions::Sync, args);
}
//////////////////////////////////////////////////////////////////////////////
}}}
| [
"facebook-github-bot@users.noreply.github.com"
] | facebook-github-bot@users.noreply.github.com |
34cd96f28afae42337246a32e5a437807dd9a1e9 | d2190cbb5ea5463410eb84ec8b4c6a660e4b3d0e | /old_hydra/hydra/tags/aug04/mdc/hmdctimecut.cc | b6f4177db53749e5d119c61bdbb584fdcac75150 | [] | no_license | wesmail/hydra | 6c681572ff6db2c60c9e36ec864a3c0e83e6aa6a | ab934d4c7eff335cc2d25f212034121f050aadf1 | refs/heads/master | 2021-07-05T17:04:53.402387 | 2020-08-12T08:54:11 | 2020-08-12T08:54:11 | 149,625,232 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,319 | cc | //*-- AUTHOR : Vladimir Pechenov
//*-- Modified : 17/01/2002 by I. Koenig
///////////////////////////////////////////////////////////////
//HMdcTimeCut
//
// class for cut time1, time2 and time2-time1
// used for beam data only (time1: leading edge, time2
// trailing edge, see http://www-hades.gsi.de/docs/mdc/mdcana).
//
// Using: create the object HMdcTimeCut in a macros
// and set the edges for a cut (see hmdctimecut.h)
// Default seting - cut is absent (all edges = 0).
//
// If you don't need in a cut don't create this object.
//
// cT1L[module],cT1R[module] - cut for time1
// cT2L[module],cT2R[module] - cut for time2
// cLeft[module],cRight[module] - cut for time2-time1
//
// Member fuctions:
// setCut(Float_t cT1L, Float_t cT1R, Float_t cT2L, Float_t cT2R,
// Float_t cLeft, Float_t cRight);
// seting identical cuts for all modules
// setCut(Int_t mod, Float_t cT1L, Float_t cT1R, Float_t cT2L, Float_t cT2R,
// Float_t cLeft, Float_t cRight);
// seting cuts for module mod.
// ...
//
// Static function getExObject return the pointer to
// HMdcTimeCut object. If pointer=0, the object
// not exist:
// HMdcTimeCut* fCut=HMdcTimeCut::getExObject();
//
// Static function getObject return the pointer to
// HMdcTimeCut object. If object is not existing
// it will created:
// HMdcTimeCut* fCut=HMdcTimeCut::getObject();
//
// Examples are in mdcTrackD.C and mdcEfficiency.C
//
//////////////////////////////////////////////////////////////
#include "hmdctimecut.h"
#include "hades.h"
#include "hruntimedb.h"
#include "hmdcparasciifileio.h"
#include "hpario.h"
#include "hmdcdetector.h"
#include "hspectrometer.h"
HMdcTimeCut::HMdcTimeCut(const char* name,const char* title,
const char* context,Int_t s,Int_t m)
: HParSet(name,title,context), fSecs(s) {
setIsUsed(kFALSE);
for (Int_t i=0;i<s; i++) fSecs.AddAt(new HMdcTimeCutSec(m),i);
setNameTitle();
if (gHades) {
fMdc = (HMdcDetector*)(((HSpectrometer*)(gHades->getSetup()))->getDetector("Mdc"));
} else {
fMdc = 0;
}
}
void HMdcTimeCut::clear(void) {
setCut(0.,0.,0.,0.,0.,0.);
}
void HMdcTimeCut::setNameTitle() {
strcpy(detName,"Mdc");
}
HMdcTimeCut* HMdcTimeCut::getExObject() {
HMdcTimeCut* fcut=0;
if( gHades ) {
HRuntimeDb* rdb=gHades->getRuntimeDb();
if( rdb ) fcut=(HMdcTimeCut*)rdb->findContainer("MdcTimeCut");
}
return fcut;
}
HMdcTimeCut* HMdcTimeCut::getObject() {
HMdcTimeCut* fcut=0;
if( gHades ) {
HRuntimeDb* rdb=gHades->getRuntimeDb();
if( rdb ) {
fcut=(HMdcTimeCut*)rdb->getContainer("MdcTimeCut");
}
}
return fcut;
}
void HMdcTimeCut::setCut(Float_t cT1L, Float_t cT1R,
Float_t cT2L, Float_t cT2R,
Float_t cLeft, Float_t cRight) {
for (Int_t s=0;s<getSize();s++) {
HMdcTimeCutSec §or=this->operator[](s);
for(Int_t mod=0;mod<sector.getSize();mod++) {
sector[mod].fill(cT1L,cT1R,cT2L,cT2R,cLeft,cRight);
}
}
isContainer=kTRUE;
}
void HMdcTimeCut::setCut(Float_t* cT1L, Float_t* cT1R,
Float_t* cT2L, Float_t* cT2R,
Float_t* cLeft, Float_t* cRight) {
for (Int_t s=0;s<getSize();s++) {
HMdcTimeCutSec §or=this->operator[](s);
for(Int_t mod=0;mod<sector.getSize();mod++) {
sector[mod].fill(cT1L[mod], cT1R[mod], cT2L[mod], cT2R[mod],
cLeft[mod], cRight[mod]);
}
}
isContainer=kTRUE;
}
void HMdcTimeCut::setCutTime1(Float_t cT1L, Float_t cT1R) {
for (Int_t s=0;s<getSize();s++) {
HMdcTimeCutSec §or=this->operator[](s);
for(Int_t mod=0;mod<sector.getSize();mod++) {
sector[mod].setCutTime1(cT1L, cT1R);
}
}
}
void HMdcTimeCut::setCutTime2(Float_t cT2L, Float_t cT2R) {
for (Int_t s=0;s<getSize();s++) {
HMdcTimeCutSec §or=this->operator[](s);
for(Int_t mod=0;mod<sector.getSize();mod++) {
sector[mod].setCutTime2(cT2L, cT2R);
}
}
}
void HMdcTimeCut::setCutDTime21(Float_t cLeft, Float_t cRight) {
for (Int_t s=0;s<getSize();s++) {
HMdcTimeCutSec §or=this->operator[](s);
for(Int_t mod=0;mod<sector.getSize();mod++) {
sector[mod].setCutTime(cLeft, cRight);
}
}
}
void HMdcTimeCut::setCut(Int_t mod, Float_t cT1L, Float_t cT1R,
Float_t cT2L, Float_t cT2R,
Float_t cLeft, Float_t cRight) {
for (Int_t s=0;s<getSize();s++) {
HMdcTimeCutSec §or=(*this)[s];
if (mod>-1 && mod<sector.getSize()) {
sector[mod].fill(cT1L,cT1R,cT2L,cT2R,cLeft,cRight);
}
}
}
void HMdcTimeCut::setCutTime1(Int_t mod, Float_t cT1L, Float_t cT1R) {
for (Int_t s=0;s<getSize();s++) {
HMdcTimeCutSec §or=(*this)[s];
if (mod>-1 && mod<sector.getSize()) {
sector[mod].setCutTime1(cT1L,cT1R);
}
}
}
void HMdcTimeCut::setCutTime2(Int_t mod, Float_t cT2L, Float_t cT2R) {
for (Int_t s=0;s<getSize();s++) {
HMdcTimeCutSec §or=(*this)[s];
if (mod>-1 && mod<sector.getSize()) {
sector[mod].setCutTime2(cT2L,cT2R);
}
}
}
void HMdcTimeCut::setCutDTime21(Int_t mod, Float_t cLeft, Float_t cRight) {
for (Int_t s=0;s<getSize();s++) {
HMdcTimeCutSec §or=(*this)[s];
if (mod>-1 && mod<sector.getSize()) {
sector[mod].setCutTime(cLeft,cRight);
}
}
}
void HMdcTimeCut::getCut(Int_t s,Int_t mod, Float_t &cT1L, Float_t &cT1R,
Float_t &cT2L, Float_t &cT2R,
Float_t &cLeft, Float_t &cRight) {
HMdcTimeCutMod &m = (*this)[s][mod];
cT1L = m.getCutTime1Left();
cT1R = m.getCutTime1Right();
cT2L = m.getCutTime2Left();
cT2R = m.getCutTime2Right();
cLeft = m.getCutTimeLeft();
cRight = m.getCutTimeRight();
}
Bool_t HMdcTimeCut::cut(HMdcCal1* cal) {
Float_t time1 = cal->getTime1();
Float_t time2 = cal->getTime2();
Float_t dTime = time2-time1;
Int_t mod = cal->getModule();
Int_t sec = cal->getSector();
HMdcTimeCutMod &m = (*this)[sec][mod];
if (m.cutTime1(time1) || m.cutTime2(time2) || m.cutTimesDif(dTime))
return kTRUE;
return kFALSE;
}
Bool_t HMdcTimeCut::cutTime1(HMdcCal1* cal) {
Float_t time1=cal->getTime1();
Int_t mod=cal->getModule();
Int_t sec=cal->getSector();
HMdcTimeCutMod &m = (*this)[sec][mod];
return m.cutTime1(time1);
}
Bool_t HMdcTimeCut::cutTime1(Int_t s,Int_t m,Float_t time1) {
Float_t mytime=time1;
Bool_t check=kTRUE;
HMdcTimeCutMod &mod = (*this)[s][m];
Float_t cuttimeleft =mod.getCutTime1Left();
Float_t cuttimeright=mod.getCutTime1Right();
if(mytime>cuttimeleft && mytime<cuttimeright)
{
check=kTRUE;
}
else
{
check=kFALSE;
}
return check;
}
Bool_t HMdcTimeCut::cutTime2(HMdcCal1* cal) {
Float_t time2=cal->getTime2();
Int_t mod=cal->getModule();
Int_t sec=cal->getSector();
HMdcTimeCutMod &m = (*this)[sec][mod];
return m.cutTime2(time2);
}
Bool_t HMdcTimeCut::cutTime2(Int_t s,Int_t m,Float_t time2) {
Float_t mytime=time2;
Bool_t check=kTRUE;
HMdcTimeCutMod &mod = (*this)[s][m];
Float_t cuttimeleft =mod.getCutTime2Left();
Float_t cuttimeright=mod.getCutTime2Right();
if(mytime>cuttimeleft && mytime<cuttimeright)
{
check=kTRUE;
}
else
{
check=kFALSE;
}
return check;
}
Bool_t HMdcTimeCut::cutTimesDif(HMdcCal1* cal) {
Float_t dTime=cal->getTime2()-cal->getTime1();
Int_t mod=cal->getModule();
Int_t sec=cal->getSector();
HMdcTimeCutMod &m = (*this)[sec][mod];
return m.cutTimesDif(dTime);
}
Bool_t HMdcTimeCut::cutTimesDif(Int_t s,Int_t m,Float_t time1,Float_t time2) {
Float_t mytime1=time1;
Float_t mytime2=time2;
Float_t mytimediff=mytime2-mytime1;
Bool_t check=kTRUE;
HMdcTimeCutMod &mod = (*this)[s][m];
Float_t cuttimeleft =mod.getCutTimeLeft();
Float_t cuttimeright=mod.getCutTimeRight();
if(mytimediff>cuttimeleft && mytimediff<cuttimeright)
{
check=kTRUE;
}
else
{
check=kFALSE;
}
return check;
}
Bool_t HMdcTimeCut::cutComStop(HMdcCal1* cal) {
Float_t time1=cal->getTime1();
Int_t mod=cal->getModule();
Int_t sec=cal->getSector();
HMdcTimeCutMod &m = (*this)[sec][mod];
return m.cutComStop(time1);
}
Bool_t HMdcTimeCut::init(HParIo* inp,Int_t* set) {
// intitializes the container from an input
HDetParIo* input=inp->getDetParIo("HMdcParIo");
if (input) return (input->init(this,set));
return kFALSE;
}
Int_t HMdcTimeCut::write(HParIo* output) {
// writes the container to an output
HDetParIo* out=output->getDetParIo("HMdcParIo");
if (out) return out->write(this);
return -1;
}
void HMdcTimeCut::readline(const char* buf, Int_t* set) {
// decodes one line read from ascii file I/O
Int_t sec,mod,n;
Float_t cT1L,cT1R,cT2L,cT2R,cLeft,cRight;
sscanf(buf,"%i%i%f%f%f%f%f%f",
&sec,&mod,&cT1L,&cT1R,&cT2L,&cT2R,&cLeft,&cRight);
n = sec*4 + mod; //FIXME
if (set[n]) {
if (sec>-1 && sec<6 && mod>-1 && mod<4) {
(*this)[sec][mod].fill(cT1L,cT1R,cT2L,cT2R,cLeft,cRight);
} else {
Error("readLine","Addres: sector_%i, module_%i not known",sec,mod);
}
set[n] = 999;
}
}
void HMdcTimeCut::putAsciiHeader(TString& b) {
b =
"#######################################################################\n"
"# Drift time cuts for noise reduction of the MDC\n"
"# Format:\n"
"# sector mod time1Left time1Right time2Left time2Right tabLeft tabRight\n"
"#######################################################################\n";
}
Bool_t HMdcTimeCut::writeline(char*buf, Int_t s, Int_t m) {
Bool_t r = kTRUE;
if (fMdc)
if (fMdc->getModule(s,m) != 0) {
if (s>-1 && s<getSize()) {
HMdcTimeCutSec §or = (*this)[s];
if (m>-1 && m<sector.getSize()) {
sprintf(buf,"%i %i %6.0f %6.0f %6.0f %6.0f %6.0f %6.0f\n",
s,m,
(*this)[s][m].getCutTime1Left(),
(*this)[s][m].getCutTime1Right(),
(*this)[s][m].getCutTime2Left(),
(*this)[s][m].getCutTime2Right(),
(*this)[s][m].getCutTimeLeft(),
(*this)[s][m].getCutTimeRight());
} else r = kFALSE;
} else r = kFALSE;
} else strcpy(buf,"");
return r;
}
ClassImp(HMdcTimeCut)
ClassImp(HMdcTimeCutMod)
ClassImp(HMdcTimeCutSec)
| [
"waleed.physics@gmail.com"
] | waleed.physics@gmail.com |
190cda9674bee45dcd266f4d604b18f457004919 | 746822256785b6d68393d1dcd964934661502e92 | /ENG/Hitbox.cpp | 1674abd59d9f167bbbd3ba002a09b9c135fa26db | [] | no_license | mgtwsky/ENG | 89eb57fb07b52237552bc6152cc954f8ce850312 | 3f4e4ed6b1ca4d2850657ec0cb596f09ab555842 | refs/heads/master | 2020-05-30T07:12:01.288878 | 2017-02-27T19:27:46 | 2017-02-27T19:27:46 | 69,363,932 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 731 | cpp | #include "pch.h"
#include "Hitbox.h"
Hitbox::Hitbox() : bound{} {}
Hitbox::Hitbox(Vector3 const & position, Vector3 const & extends) : bound{ position, extends } {}
Hitbox::~Hitbox() {}
bool Hitbox::Collides(Hitbox const & hitbox) const {
return bound.Contains(hitbox.bound);
}
bool Hitbox::Intersects(Hitbox const & hitbox) const {
return bound.Contains(hitbox.bound) == ContainmentType::INTERSECTS;
}
Vector3 Hitbox::GetPosition() const {
return Vector3(bound.Center);
}
void Hitbox::SetPosition(Vector3 const & position) {
bound.Center = position;
}
Vector3 Hitbox::GetExtends() const {
return Vector3(bound.Extents);
}
void Hitbox::SetExtends(Vector3 const & extends) {
bound.Extents = Vector3(extends / 2);
}
| [
"gtwsky@gmail.com"
] | gtwsky@gmail.com |
653f206982e4aefd8566899a9a3737e87466a764 | 97fc4c20f8def514e9e2e047e6cf3739922fa7e8 | /URI/1 - Iniciante/1080 - Maior e Posição.cpp | 0e2fb441322e07a74f48f9b91ba2d4d3d18d10be | [] | no_license | pedropaulo42/Maratona-de-Programacao | d52a2460ce4bb1881f9624904775ad5437af0b7b | 7d6211bfb3d4c35d0c09f3e0cbd374ef886bbfc9 | refs/heads/master | 2022-12-30T06:02:24.068294 | 2020-10-20T20:08:05 | 2020-10-20T20:08:05 | 304,159,511 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 230 | cpp | #include <bits/stdc++.h>
using namespace std;
int main(){
int n, maior=0,pos;
for(int i=1;i<=100;i++){
scanf("%d",&n);
if(n>maior){
maior=n;
pos=i;
}
}
printf("%d\n%d\n",maior,pos);
return 0;
} | [
"pedroppaulo42@gmail.com"
] | pedroppaulo42@gmail.com |
9286d06e280d10c92fb91ebc365e89c005805dc9 | 08b8cf38e1936e8cec27f84af0d3727321cec9c4 | /data/crawl/squid/old_hunk_6668.cpp | deda76e21f9ed960e255d78d67b4528bce99e15d | [] | no_license | ccdxc/logSurvey | eaf28e9c2d6307140b17986d5c05106d1fd8e943 | 6b80226e1667c1e0760ab39160893ee19b0e9fb1 | refs/heads/master | 2022-01-07T21:31:55.446839 | 2018-04-21T14:12:43 | 2018-04-21T14:12:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 103 | cpp | if (s != NULL)
free(s);
#if MEM_GEN_TRACE
if (tracefp)
fprintf(tracefp,"f:%p\n",s);
#endif
}
| [
"993273596@qq.com"
] | 993273596@qq.com |
bd0bce1d71fc26818553a4cf8e728223a10ca86f | 3545331f43c29c862488f73459ca1b9e4c19f2b9 | /Interpolation Module/Test/generateRandomTestCases.cpp | 68f345e21c683a3a2d198440ab9c5e32af5ba914 | [] | no_license | KhaledMoataz/ODE_Accelerator | f877e5474b249f3da29252c5c54523893b81233d | ae3b5fd18035aed5fa2a99a6e4a39487dc6adf2e | refs/heads/master | 2022-04-21T12:22:23.511757 | 2020-04-26T09:36:39 | 2020-04-26T09:36:39 | 248,862,572 | 2 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 6,841 | cpp | #include<iostream>
#include <bits/stdc++.h>
#include"../../Fixed Point Arithmetic/test/fixed_point.h"
#include <ctime>
//g++ generateRandomTestCases.cpp -o generateRandomTestCases
const int scaleFactor = 7;
const int numSize = 16;
using namespace std;
void RandomBitset(mt19937 &gen, bitset <FixedPoint_Q9_7::numSize> &a, double p) {
bernoulli_distribution d(p);
for (int i = 0; i < FixedPoint_Q9_7::numSize; ++i) {
a[i] = d(gen);
}
}
float RandmFloatInRange(float M, float N)
{
srand(time(NULL));
return M + (rand() / ( RAND_MAX / (N-M) ) ) ;
}
int main() {
random_device rd;
mt19937 gen(rd());
bernoulli_distribution distribution(0.5);
bitset <FixedPoint_Q9_7::numSize> a, b, result,m;
bool overflow = false;
vector<bitset <FixedPoint_Q9_7::numSize>> time;
int no_of_Us ;
cout<<"Enter num of U's:"<<endl;
cin >> no_of_Us;
cout<<"Enter M size"<<endl;
float M_as_int;
cin >>M_as_int;
m = FixedPoint_Q9_7::floatToBitSet(M_as_int);
float temp = 0;
for (int i = 0; i <no_of_Us+1 ; i++)//generate T's at 0,1,2....etc
{
temp=(float) i;
time.push_back(FixedPoint_Q9_7::floatToBitSet(temp));
}
ofstream cout1("Interpolation_test_cases.txt");
//write M and no of Us
cout1<<M_as_int<<endl;
cout1<<no_of_Us<<endl;
cout1<<(1+(no_of_Us+1)+((no_of_Us+1)*M_as_int)+2)<<endl;
// write m value to the file
cout1<<m<<endl;
// write the times to the file
for (int i = 0; i <no_of_Us+1 ; i++)
{
cout1<<time[i]<<endl;
}
vector<bitset <FixedPoint_Q9_7::numSize>> all_tks;
vector<vector<bitset <FixedPoint_Q9_7::numSize>>> all_uks;
int j = 0;
vector<bitset <FixedPoint_Q9_7::numSize>> old_uz;
while (j < no_of_Us)
{
bool advance = true;
vector<bitset <FixedPoint_Q9_7::numSize>> un,uz,uk;
bitset <FixedPoint_Q9_7::numSize> tn,tz,tk,k,mul_temp,temp1,temp2;
// generate the un and uz
if (j == 0)
{
for (int i = 0; i < M_as_int; i++)
{
RandomBitset(gen, a, 0.5);
RandomBitset(gen, b, 0.5);
un.push_back(a);
uz.push_back(b);
}
}
else{
for (int i = 0; i < M_as_int; i++)
{
RandomBitset(gen, b, 0.5);
uz.push_back(b);
}
un = old_uz;
}
// get values of tn,tz
tn = time[j];
tz = time[j+1];
//generate tk betweeen tn and tz
float tk_in = RandmFloatInRange(j,j+1);
tk = FixedPoint_Q9_7::floatToBitSet(tk_in);
//start calculating Uk
bool negative;
bool subtract = true;
bool carryOut;
for (int w = 0; w < M_as_int; w++)
{ //tk-tn
overflow = false;
subtract = true;
temp1 = FixedPoint_Q9_7::add(tk,tn,subtract,carryOut,overflow,negative);
if (overflow)
{
advance = false;
}
//tz-tk
overflow = false;
subtract = true;
temp2 = FixedPoint_Q9_7::add(tz,tk,subtract,carryOut,overflow,negative);
if (overflow)
{
advance = false;
}
// k = temp1/temp2 (note will use mul mo2qtn)
overflow = false;
k = FixedPoint_Q9_7::divide(temp1,temp2,overflow);
if (overflow)
{
advance = false;
}
//temp1 = uz[i]-un[i]
overflow = false;
subtract = true;
temp1 = FixedPoint_Q9_7::add(uz[w],un[w],subtract,carryOut,overflow,negative);
if (overflow)
{
advance = false;
}
//mul_result = k*temp1
overflow = false;
mul_temp = FixedPoint_Q9_7::multiply(k,temp1,overflow);
if (overflow)
{
advance = false;
}
//result = un[i] + mul_result
overflow = false;
subtract = false;
result = FixedPoint_Q9_7::add(mul_temp,un[w],subtract,carryOut,overflow,negative);
if (overflow)
{
advance = false;
}
//save the result in uk[i]
uk.push_back(result);
}
// after calculating Uk make sure no over flow happend before writing to the file
if (advance)
{
//if here no over flow
//write tk value
//cout1<<tk<<endl;
all_tks.push_back(tk);
//write the U's values
if (j == 0)
{
for (int i = 0; i <un.size() ; i++)
{
cout1<<un[i]<<endl;
}
}
old_uz = uz;
for (int i = 0; i < uz.size(); i++)
{
cout1<<uz[i]<<endl;
}
/*
for (int i = 0; i < uk.size(); i++)
{
cout1<<uk[i]<<endl;
}
*/
all_uks.push_back(uk);
j++;
}
}
//write all tk's values
for (int i = 0; i < all_tks.size(); i++)
{
cout1<<all_tks[i]<<endl;
}
for (int i = 0; i < all_uks.size(); i++)
{
for (int g = 0; g < M_as_int; g++)
{
cout1<<all_uks[i][g]<<endl;
}
}
/*float x,y;
bitset<numSize>a, b, result;
short temp_a, temp_b;
int type;
bool overflow;
while (1) {
overflow = false;
cin >> type; // 0: add, 1: multiply, 2: quit
if (type == 2) break;
cin >> x >> y;
a = FixedPoint_Q9_7::floatToBitSet(x); //Two operands in binary (16 bits).
b= FixedPoint_Q9_7::floatToBitSet(y);
temp_a = (short) a.to_ulong();
temp_b = (short) b.to_ulong();
cout << "First Operand:"; FixedPoint_Q9_7::printFloat(temp_a);
cout << "First Operand (binary): "<<a<<endl;
cout << "Second Operand: "; FixedPoint_Q9_7::printFloat(temp_b);
cout << "Second Operand (binary): "<<b<<endl;
if (type == 1) {
result = FixedPoint_Q9_7::multiply(a,b,overflow);
if(overflow) printf("OVERFLOW\n");
} else {
result = FixedPoint_Q9_7::add(a,b,overflow);
if(overflow) printf("OVERFLOW\n");
}
cout << "Result (Decimal): "; FixedPoint_Q9_7::printFloat(result.to_ulong());
cout << "Result (Binary): " << result << endl;
}
*/
return 0;
}
| [
"YousifGAhmed@gmail.com"
] | YousifGAhmed@gmail.com |
240b657af27ae02f09da69345996e9d94f20f0d6 | 5a3c7ed86ab74f09508ccb35fc9064b54677f537 | /cpp_basic/cpp_basic_project/ch04_02_포인터변수.cpp | 42880da3514ff847e8d7a2c85cda0327c5f457de | [] | no_license | HYUNMIN-HWANG/cpp_basic | 9bc7e3ac3b8edf2973fab7aa4f24cbef6bebbb6a | 84f89e0d21129b86f21204942345bfdf50c2465f | refs/heads/main | 2023-05-31T11:38:38.063756 | 2021-06-12T08:01:52 | 2021-06-12T08:01:52 | 370,554,223 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 432 | cpp | //포인터 : 기억 장소의 주소
//포인터 변수 : 그 주소를 기억하는 변수
//vs.일반변수 : 자료 자체를 저장하기 위해 사용
#include <iostream>
using namespace std;
int main()
{
int a = 100;
cout << "a에 저장된 값 : " << a << endl;
cout << "a의 주소 : " << &a << endl;
return 0;
}
//a에 저장된 값 : 100
//a의 주소 : 012FFB50 <- 16진법으로 표기된다. | [
"noreply@github.com"
] | noreply@github.com |
0719eda780a5fe456c66ee53ee6423ca6733cf49 | c78f01652444caa083ca75211bae6903d98363cb | /devel/.private/mavros_msgs/include/mavros_msgs/Altitude.h | 5888e9b3498ecd5b85ada3022b09fbbca58e4268 | [
"Apache-2.0"
] | permissive | arijitnoobstar/UAVProjectileCatcher | 9179980f8095652811b69b70930f65b17fbb4901 | 3c1bed80df167192cb4b971b58c891187628142e | refs/heads/master | 2023-05-01T11:03:09.595821 | 2021-05-16T15:10:03 | 2021-05-16T15:10:03 | 341,154,017 | 19 | 7 | null | null | null | null | UTF-8 | C++ | false | false | 7,206 | h | // Generated by gencpp from file mavros_msgs/Altitude.msg
// DO NOT EDIT!
#ifndef MAVROS_MSGS_MESSAGE_ALTITUDE_H
#define MAVROS_MSGS_MESSAGE_ALTITUDE_H
#include <string>
#include <vector>
#include <map>
#include <ros/types.h>
#include <ros/serialization.h>
#include <ros/builtin_message_traits.h>
#include <ros/message_operations.h>
#include <std_msgs/Header.h>
namespace mavros_msgs
{
template <class ContainerAllocator>
struct Altitude_
{
typedef Altitude_<ContainerAllocator> Type;
Altitude_()
: header()
, monotonic(0.0)
, amsl(0.0)
, local(0.0)
, relative(0.0)
, terrain(0.0)
, bottom_clearance(0.0) {
}
Altitude_(const ContainerAllocator& _alloc)
: header(_alloc)
, monotonic(0.0)
, amsl(0.0)
, local(0.0)
, relative(0.0)
, terrain(0.0)
, bottom_clearance(0.0) {
(void)_alloc;
}
typedef ::std_msgs::Header_<ContainerAllocator> _header_type;
_header_type header;
typedef float _monotonic_type;
_monotonic_type monotonic;
typedef float _amsl_type;
_amsl_type amsl;
typedef float _local_type;
_local_type local;
typedef float _relative_type;
_relative_type relative;
typedef float _terrain_type;
_terrain_type terrain;
typedef float _bottom_clearance_type;
_bottom_clearance_type bottom_clearance;
typedef boost::shared_ptr< ::mavros_msgs::Altitude_<ContainerAllocator> > Ptr;
typedef boost::shared_ptr< ::mavros_msgs::Altitude_<ContainerAllocator> const> ConstPtr;
}; // struct Altitude_
typedef ::mavros_msgs::Altitude_<std::allocator<void> > Altitude;
typedef boost::shared_ptr< ::mavros_msgs::Altitude > AltitudePtr;
typedef boost::shared_ptr< ::mavros_msgs::Altitude const> AltitudeConstPtr;
// constants requiring out of line definition
template<typename ContainerAllocator>
std::ostream& operator<<(std::ostream& s, const ::mavros_msgs::Altitude_<ContainerAllocator> & v)
{
ros::message_operations::Printer< ::mavros_msgs::Altitude_<ContainerAllocator> >::stream(s, "", v);
return s;
}
template<typename ContainerAllocator1, typename ContainerAllocator2>
bool operator==(const ::mavros_msgs::Altitude_<ContainerAllocator1> & lhs, const ::mavros_msgs::Altitude_<ContainerAllocator2> & rhs)
{
return lhs.header == rhs.header &&
lhs.monotonic == rhs.monotonic &&
lhs.amsl == rhs.amsl &&
lhs.local == rhs.local &&
lhs.relative == rhs.relative &&
lhs.terrain == rhs.terrain &&
lhs.bottom_clearance == rhs.bottom_clearance;
}
template<typename ContainerAllocator1, typename ContainerAllocator2>
bool operator!=(const ::mavros_msgs::Altitude_<ContainerAllocator1> & lhs, const ::mavros_msgs::Altitude_<ContainerAllocator2> & rhs)
{
return !(lhs == rhs);
}
} // namespace mavros_msgs
namespace ros
{
namespace message_traits
{
template <class ContainerAllocator>
struct IsFixedSize< ::mavros_msgs::Altitude_<ContainerAllocator> >
: FalseType
{ };
template <class ContainerAllocator>
struct IsFixedSize< ::mavros_msgs::Altitude_<ContainerAllocator> const>
: FalseType
{ };
template <class ContainerAllocator>
struct IsMessage< ::mavros_msgs::Altitude_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::mavros_msgs::Altitude_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct HasHeader< ::mavros_msgs::Altitude_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct HasHeader< ::mavros_msgs::Altitude_<ContainerAllocator> const>
: TrueType
{ };
template<class ContainerAllocator>
struct MD5Sum< ::mavros_msgs::Altitude_<ContainerAllocator> >
{
static const char* value()
{
return "1296a05dc5b6160be0ae04ba9ed3a3fa";
}
static const char* value(const ::mavros_msgs::Altitude_<ContainerAllocator>&) { return value(); }
static const uint64_t static_value1 = 0x1296a05dc5b6160bULL;
static const uint64_t static_value2 = 0xe0ae04ba9ed3a3faULL;
};
template<class ContainerAllocator>
struct DataType< ::mavros_msgs::Altitude_<ContainerAllocator> >
{
static const char* value()
{
return "mavros_msgs/Altitude";
}
static const char* value(const ::mavros_msgs::Altitude_<ContainerAllocator>&) { return value(); }
};
template<class ContainerAllocator>
struct Definition< ::mavros_msgs::Altitude_<ContainerAllocator> >
{
static const char* value()
{
return "# Altitude information\n"
"#\n"
"# https://mavlink.io/en/messages/common.html#ALTITUDE\n"
"\n"
"std_msgs/Header header\n"
"\n"
"float32 monotonic\n"
"float32 amsl\n"
"float32 local\n"
"float32 relative\n"
"float32 terrain\n"
"float32 bottom_clearance\n"
"\n"
"================================================================================\n"
"MSG: std_msgs/Header\n"
"# Standard metadata for higher-level stamped data types.\n"
"# This is generally used to communicate timestamped data \n"
"# in a particular coordinate frame.\n"
"# \n"
"# sequence ID: consecutively increasing ID \n"
"uint32 seq\n"
"#Two-integer timestamp that is expressed as:\n"
"# * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n"
"# * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n"
"# time-handling sugar is provided by the client library\n"
"time stamp\n"
"#Frame this data is associated with\n"
"string frame_id\n"
;
}
static const char* value(const ::mavros_msgs::Altitude_<ContainerAllocator>&) { return value(); }
};
} // namespace message_traits
} // namespace ros
namespace ros
{
namespace serialization
{
template<class ContainerAllocator> struct Serializer< ::mavros_msgs::Altitude_<ContainerAllocator> >
{
template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m)
{
stream.next(m.header);
stream.next(m.monotonic);
stream.next(m.amsl);
stream.next(m.local);
stream.next(m.relative);
stream.next(m.terrain);
stream.next(m.bottom_clearance);
}
ROS_DECLARE_ALLINONE_SERIALIZER
}; // struct Altitude_
} // namespace serialization
} // namespace ros
namespace ros
{
namespace message_operations
{
template<class ContainerAllocator>
struct Printer< ::mavros_msgs::Altitude_<ContainerAllocator> >
{
template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::mavros_msgs::Altitude_<ContainerAllocator>& v)
{
s << indent << "header: ";
s << std::endl;
Printer< ::std_msgs::Header_<ContainerAllocator> >::stream(s, indent + " ", v.header);
s << indent << "monotonic: ";
Printer<float>::stream(s, indent + " ", v.monotonic);
s << indent << "amsl: ";
Printer<float>::stream(s, indent + " ", v.amsl);
s << indent << "local: ";
Printer<float>::stream(s, indent + " ", v.local);
s << indent << "relative: ";
Printer<float>::stream(s, indent + " ", v.relative);
s << indent << "terrain: ";
Printer<float>::stream(s, indent + " ", v.terrain);
s << indent << "bottom_clearance: ";
Printer<float>::stream(s, indent + " ", v.bottom_clearance);
}
};
} // namespace message_operations
} // namespace ros
#endif // MAVROS_MSGS_MESSAGE_ALTITUDE_H
| [
"arijit.dg@hotmail.com"
] | arijit.dg@hotmail.com |
bff798bd25b0539cd0692d505418865909f9344f | 16da14a9eeb947b1a39c5d82cf29b8d2fc14b383 | /WinModules/Logger/LoggerWin.hpp | bf6605cf569986c603ce2a39cb429d4ef1b49aa1 | [
"MIT"
] | permissive | mikelaud/win-modules | 9df555e89d85af4b2038c197f3212f0df40dcb72 | 06e11efc97594c8496009503fbfe400598965899 | refs/heads/main | 2023-02-09T06:18:12.821176 | 2021-01-03T03:26:23 | 2021-01-03T03:26:23 | 324,874,088 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 427 | hpp | #pragma once
#ifndef LOGGER_WIN_HPP_
#define LOGGER_WIN_HPP_
class LoggerWin {
private: // fields
// void
public: // interface
void log();
public: // factory
LoggerWin();
~LoggerWin();
public: // factory (delete)
LoggerWin(const LoggerWin&) = delete;
LoggerWin(LoggerWin&&) = delete;
LoggerWin& operator=(const LoggerWin&) = delete;
LoggerWin& operator=(LoggerWin&&) = delete;
};
#endif // LOGGER_WIN_HPP_
| [
"mmx.mmx@gmail.com"
] | mmx.mmx@gmail.com |
0cae2f4398c991c6609781ba9be04ecbe76fa921 | 2265190bd4ff267ba99d397f82b4d90fca04ce1b | /deck/test_deck.cpp | 3d0554601520a87bdbe11e976165fd9c7896b90f | [] | no_license | mmikhasenko/deck_amplitude | 89b01da7659f4e60be89aa431d64fe5c0c88c85b | 355a7aed5636e69df52b45559521307225f0186c | refs/heads/master | 2020-04-21T03:40:19.785842 | 2019-02-05T19:06:49 | 2019-02-05T19:06:49 | 169,290,529 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 789 | cpp | #include "deck.h"
#include "pion_nucleon_scattering.h"
#include "deck_pi_n.h"
namespace d = deck;
namespace dp = deck_pi_n;
namespace pn = pion_nucleon_scattering;
int main()
{
pn::SAID_pion_nucleon_pw ( );
double M3pi_i = d::m_pi + d::m_rho + 0.0001;
double M3pi_f = 7.0;
int nstep_x = 200;
double cos_th_i = -1.0;
double cos_th_f = 1.0;
int nstep_y = 200;
int nstep = 500;
int J;
int M;
int S;
int lam;
std::cin >> J;
std::cin >> M;
std::cin >> S;
std::cin >> lam;
d::plot_1d_projection ( J, M, S, lam, M3pi_i, M3pi_f, nstep );
// d::plot_1d_intensity ( cos_th_i,
// cos_th_f,
// nstep );
/*
d::plot_2d_intensity ( M3pi_i,
M3pi_f,
cos_th_i,
cos_th_f,
nstep_x,
nstep_y );
*/
return 0;
}
| [
"andrew.jackura@gmail.com"
] | andrew.jackura@gmail.com |
813a0a785573a6531cc5f414c95566e6f16970cd | 67ed24f7e68014e3dbe8970ca759301f670dc885 | /win10.19042/System32/dsdmo.dll.cpp | fe484b77793b8de84a8adb5493b544f8ec507854 | [] | no_license | nil-ref/dll-exports | d010bd77a00048e52875d2a739ea6a0576c82839 | 42ccc11589b2eb91b1aa82261455df8ee88fa40c | refs/heads/main | 2023-04-20T21:28:05.295797 | 2021-05-07T14:06:23 | 2021-05-07T14:06:23 | 401,055,938 | 1 | 0 | null | 2021-08-29T14:00:50 | 2021-08-29T14:00:49 | null | UTF-8 | C++ | false | false | 420 | cpp | #pragma comment(linker, "/export:DllCanUnloadNow=\"C:\\Windows\\System32\\dsdmo.DllCanUnloadNow\"")
#pragma comment(linker, "/export:DllGetClassObject=\"C:\\Windows\\System32\\dsdmo.DllGetClassObject\"")
#pragma comment(linker, "/export:DllRegisterServer=\"C:\\Windows\\System32\\dsdmo.DllRegisterServer\"")
#pragma comment(linker, "/export:DllUnregisterServer=\"C:\\Windows\\System32\\dsdmo.DllUnregisterServer\"")
| [
"magnus@stubman.eu"
] | magnus@stubman.eu |
0c377683e4b7b2164700f343f2e5f14309b812d8 | 7bd8b4933f2e78d4936d1a4455c84a86b86242fb | /Code/Core/imr_geom_object.hpp | 5038228004115edcaf4ab586fc2f9c856183016d | [] | no_license | dhawt/Immerse | bdbf4470fa6a79da850536efc91272abd01684db | 0f562746f9db33c41a6e047fecb0f49acb513b48 | refs/heads/master | 2016-09-15T23:57:05.086389 | 2012-05-03T19:52:14 | 2012-05-03T19:52:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,735 | hpp | /****************************************************************\
iMMERSE Engine
(C) 1999 No Tears Shed Software
All rights reserved
Filename: IMR_Geom_Object.hpp
Description: Header
\****************************************************************/
#ifndef __IMR_GEOM_OBJECT__HPP
#define __IMR_GEOM_OBJECT__HPP
// Include stuff:
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#include <math.h>
#include "IMR_Geom_Light.hpp"
#include "IMR_Geom_Model.hpp"
#include "IMR_Geom_Poly.hpp"
#include "IMR_Geom_Prim.hpp"
#include "IMR_Matrix.hpp"
#include "IMR_Collide.hpp"
#include "..\CallStatus\IMR_Log.hpp"
#include "..\Foundation\IMR_List.hpp"
#include "..\Foundation\IMR_Time.hpp"
// Constants and macros:
#define IMR_OBJECT_MAXLIGHTS 64
#define IMR_OBJECT_MAXCHILDREN 32
#ifndef IMR_ANIMATION_DONE
#define IMR_ANIMATION_DONE 0
#endif
#ifndef IMR_ANIMATION_ACTIVE
#define IMR_ANIMATION_ACTIVE 1
#endif
#ifndef IMR_MOTION_DONE
#define IMR_MOTION_DONE 0
#endif
#ifndef IMR_MOTION_ACTIVE
#define IMR_MOTION_ACTIVE 1
#endif
// Object class:
class IMR_Object
{
protected:
// Miscellaneous stuff:
char Name[9];
char ModelName[9];
// List stuff:
int Num_Lights, Num_Children;
// Attached stuff (All local positions are relative to the object):
IMR_Light *AttachedLights[IMR_OBJECT_MAXLIGHTS];
IMR_Model *AttachedModel;
IMR_Object *Children[IMR_OBJECT_MAXCHILDREN];
// Position and orientation (relative to parent and global):
IMR_3DPoint RPos, GPos, StartPos, StartAtd;
IMR_Attitude RAtd, GAtd;
IMR_Matrix RotMtrx;
// Animation control stuff:
IMR_3DPoint PosVect, DestPos, AtdVect;
IMR_Attitude DestAtd;
int Animation_Time, Animation_Length, Animation_Status;
// Motion control stuff:
float Motion_TravelSpeed,
Motion_TurnRate;
IMR_3DPoint Motion_TravelVect, Motion_TurnVect;
IMR_Attitude Motion_DestAtd;
int Motion_Time, Motion_Status;
//// BIG HACK ZONE
int Collidable;
//// END BIG HACK ZONE
// Pointer to parent object:
IMR_Object *Parent;
// Protected member functions:
IMR_Light *Get_Light(int ID, int *index);
IMR_Object *Get_Child(char *Name, int *index);
public:
// Constructor and destructor methods:
IMR_Object() { Reset(); };
~IMR_Object() { Reset(); };
// Init and de-init methods:
void Reset(void);
// Name methods:
void Set_Name(char *NewName);
inline char *Get_Name(void) { return Name; };
inline int Is(char *CmpName) { return !stricmp(Name, CmpName); };
// Setup methods:
int Setup(IMR_NamedList<IMR_Model> *GlbMod, IMR_NamedList<IMR_Model> *LocMod);
// Position and orientation methods:
void UpdateCoords(void);
void Set_RelativePos(IMR_3DPoint &Pos) { RPos = Pos; UpdateCoords(); };
void Inc_RelativePos(IMR_3DPoint &Pos) { RPos += Pos; UpdateCoords(); };
void Set_RelativeAtd(IMR_Attitude &Atd) { RAtd = Atd; UpdateCoords(); };
void Inc_RelativeAtd(IMR_Attitude &Atd) { RAtd += Atd; UpdateCoords(); };
inline IMR_3DPoint Get_RelativePos(void) { return RPos; };
inline IMR_Attitude Get_RelativeAtd(void) { return RAtd; };
inline IMR_3DPoint Get_GlobalPos(void) { return GPos; };
inline IMR_Attitude Get_GlobalAtd(void) { return GAtd; };
inline IMR_Matrix Get_RotMatrix(void) { return RotMtrx; };
// Methods accessing parent:
inline IMR_Object *Get_Parent(void) { return Parent; };
// Attached light methods:
inline int Get_Num_Lights(void) { return Num_Lights; };
void Attach_Light(IMR_Light *Lit);
void Detach_Light(int ID);
inline IMR_Light *Get_Light(int index)
{
if (index >= 0 && index < Num_Lights)
return AttachedLights[index];
return NULL;
};
// Attached model methods:
void Set_ModelName(char *MName);
char *Get_ModelName(void) { return ModelName; };
inline int Attach_Model(IMR_Model *Mdl)
{
if (Mdl)
{
AttachedModel = Mdl;
return IMR_OK;
}
IMR_LogMsg(__LINE__, __FILE__, "IMR_Object::Attach_Model(): NULL Model specified!");
return IMRERR_NODATA;
};
inline void Detach_Model(void) { AttachedModel = NULL; };
inline IMR_Model *Get_Model(void) { return AttachedModel; };
int MergeToModel(IMR_Model *Mdl, IMR_3DPoint Offset);
// Child object methods:
int Attach_Child(IMR_Object *Child);
IMR_Object *Detach_Child(char *Name);
inline void Clear_Children(void) { for (int index = 0; index < Num_Children; index ++) Children[index] = NULL; };
int Get_Num_Children(void) { return Num_Children; };
inline IMR_Object *Get_Child(int index)
{
if (index >= 0 && index < Num_Children)
return Children[index];
return NULL;
};
inline IMR_Object *Get_Child(char *Name)
{
IMR_Object *Temp;
if (Is(Name)) return this;
for (int index = 0; index < Num_Children; index ++)
{
Temp = Children[index]->Get_Child(Name);
if (Temp != NULL) return Temp;
}
return NULL;
};
inline IMR_Object *Get_Local_Child(char *Name)
{
for (int index = 0; index < Num_Children; index ++)
if (Children[index] != NULL && Children[index]->Is(Name))
return Children[index];
return NULL;
};
// Animation control methods:
void Animation_Jump(IMR_3DPoint &Pos, IMR_Attitude &Ang);
void Animation_Init(IMR_3DPoint &Pos, IMR_Attitude &Ang, int L);
int Animation_Step(void);
int Animation_Get_Status(void) const { return Animation_Status; };
// Motion control methods:
void Motion_Travel(IMR_3DPoint &Delta, float s);
int Motion_Travel_CheckCollide(IMR_3DPoint &Delta, float s, IMR_Object *Environ, IMR_CollideInfo &CInfo);
void Motion_Turn(IMR_Attitude &Delta, float r);
// Collision detection methods:
IMR_3DPoint CheckCollide(IMR_CollideInfo &CInfo, IMR_3DPoint position, IMR_3DPoint velocity);
//// ANOTHER BIG HACK ZONE
void inline Set_Collidable(void) { Collidable = 1; };
void inline Set_NonCollidable(void) { Collidable = 0; };
//// END ANOTHER BIG HACK ZONE
};
#endif
| [
"daniel@eduschedu.com"
] | daniel@eduschedu.com |
737ff9adc63172af554fa055f3db636d7044234b | 2876225b677e648e3e0b01b1cd6896db777e2d8f | /src/compiler/compiler.cpp | c6a9f3ec0934ea09803b611030bf9d243631739d | [] | no_license | roadtovalley/fast_codec | e9a1d596bb7cebb136f8ea465c8dd137ce69ab4d | d29770667f96343c96f2c35b391c86dd16d21c30 | refs/heads/master | 2021-05-08T18:15:47.880915 | 2016-10-31T13:27:25 | 2016-10-31T13:27:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,587 | cpp | #include <string>
#include <iostream>
#include <boost/program_options.hpp>
#include "config.h"
#include "parser.h"
namespace po = boost::program_options;
int main(int argc, char *argv[])
{
try
{
Config cfg;
po::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
("templates,t", po::value<std::string>(&cfg.templates_), "input templates file")
("tags,a", po::value<std::string>(&cfg.tags_h_), "output file of tags ")
("templates_h,h", po::value<std::string>(&cfg.templates_h_), "output file of message structs")
("templates_encoders_h,e", po::value<std::string>(&cfg.templates_encoders_h_), "output file of encoder function definitions")
("templates_encoders_cpp,c", po::value<std::string>(&cfg.templates_encoders_cpp_), "output file of encoder function implementations")
("msgseqnum_preamble,p", po::value<bool>(&cfg.is_msgseqnum_preamble_), "messages have 4-byte sequence number preamble");
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
if (vm.count("help") || argc == 1) {
std::cout << desc << "\n";
return 1;
}
std::cout << "Compile templates: " << cfg.templates_ << std::endl;
Parser parser;
parser.GenerateCppSources(cfg);
std::cout << "Output files: " << std::endl
<< cfg.tags_h_ << std::endl
<< cfg.templates_h_ << std::endl
<< cfg.templates_encoders_h_ << std::endl
<< cfg.templates_encoders_cpp_ << std::endl;
}
catch (const std::exception& e)
{
std::cout << "std::exception: " << e.what();
}
return 0;
}
| [
"mymrin@gmail.com"
] | mymrin@gmail.com |
5bd2d73f3d36634d37e3bbc11bdff5f98e6208a3 | 74ad7158366876c0026d7cc47d72dc5eed426c9d | /P_10679950.cc.cpp | 7e930078c244b882091b5e05f4ba60286f9f4d70 | [] | no_license | Amenyiwah/cscd205assignment1 | 8e49fe87fe482e3484bbbfc0f99550856689c3f6 | 429ffac939e3fde4f0ac047e7a32e8b6eeace4ca | refs/heads/master | 2020-03-27T13:59:18.572524 | 2018-12-21T09:29:46 | 2018-12-21T09:29:46 | 146,638,136 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 29,242 | cpp | #include <iostream>
#include <vector>
#include <stdlib.h>
#include <string>
//#include <person.h>
using namespace std;
template <class var>
void print(var textline){
cout << textline;
}
//structs
struct course {
int level;
string subjects[10];
};
struct record{
int semester;
int credit_hr;
string course_name;
int mark;
string grade;
};
class person
{
public:
person()
{
//set empty student name = ""
status = "null";
}
//setter functions for student
void setName(string val){
name = val;
}
void setStatus(string val){
status = val;
}
void setAge(int val){
age = val;
}
void setID(int val){
object_id = val;
}
void setIndex(int val){
index = val;
}
void setResidence(string val){
residence = val;
}
void listItems(vector <string> arrayVar){
int len = arrayVar.size();
for (int i=0;i<len;i++){
print(arrayVar[i]);
if ((i+1)%3 == 0){
print("\n");
}else{
print("\t\t");
}
}
}
//getter functions for student
string getName(){
return name;
}
string getStatus(){
return status;
}
int getAge(){
return age;
}
string getResidence(){
return residence;
}
string getType(){
return "person";
}
int getID(){
return object_id;
}
int getIndex(){
return index;
}
void getInfo(){
cout << "\nname : " << getName() << "\nage : " << getAge() << "\nperson ID : " << getID() <<endl;
}
private:
string name;
int age;
int index;
int object_id;
string status;
string residence;
};
struct student{
person details;
float schoolfees;
int level;
string course;
string department;
vector<string> subjects;
vector<record> academic_records;
};
struct staff{
person details;
string job;
string department;
vector<string> subjects;
};
//### functions prototypes ##########
void addStudent(),editStudent(),manageStudent(),GpaCalc(student obj);
void addStaff(),editStaff(),manageStaff(),GpaCalc(student obj);
string lower(string line),gradeCalc(double score);
student Stu_Container[10000];
staff Sta_Container[10000];
int stu_base_id=10440000;
int sta_base_id=11440000;
int stu_count = 0;
int sta_count = 0;
string str;int num;
//#########################################################
//when you get this just edit the print statements i used..
//its the same as cout << [content] <<endl;
//you can beautify all the print statements
//symbols and stuff like that...
//add more options if possible..
//########################################################
int main()
{
//change this statement to something nicer;
print("\nHello... Welcome:)\n");
//############################
string option;
//this is the engine that runs the app
//functions are at the bottom of this file
while (true){
print("\n1. student \n2. staff \n0. exit\n");
print("\nselect person : ");
cin >> str;
if (str == "1"){
print("\nstudent route");//change this print statement
while (true){
print("\n\n1. add \n2. edit \n3. manage \n0. exit");
print("\n\nselect an option : ");
cin >> option;
if (option == "1"){
addStudent();//to add students...
}
else if (option == "2"){
editStudent();//edit stuent object
}
else if (option == "3"){
manageStudent();//manage student object;
}
else if (option == "0"){
break;
}
cin.clear();
}
}
else if (str == "2"){
print("\nstaff route");
while (true){
print("\n\n1. add \n2. edit \n3. manage \n0. exit");
print("\n\nselect an option : ");
cin >> option;
if (option == "1"){
addStaff();
}
else if (option == "2"){
editStaff();
}
else if (option == "3"){
manageStaff();
}
else if (option == "0"){
break;
}
cin.clear();
}
}
else if (str == "0"){
break;
}
}
return 0;
}
void addStudent(){
//add student detail....read class and struct
cin.clear();
print("\n**************adding new student*****************");
student temp;
print("\nAssigned Student ID : ");print(stu_base_id+stu_count);
temp.details.setID(stu_base_id+stu_count);temp.details.setIndex(stu_count);stu_count++;
string str;int num;
print("\nEnter Students Name : ");
cin.ignore();getline(cin, str);cin.clear();
temp.details.setName(str);
print("\nEnter Students Age : ");
cin >> num;
while (cin.fail()){
print("\n( invalid ) Try Again : ");
cin.clear();cin.ignore();cin >> num;
}
temp.details.setAge(num);
//list department for student to choose from
print("\nEnter Department Name : ");
cin >> str;
temp.department = str;
//list course using department
print("\nEnter Students Course : ");
cin >> str;
temp.course = str;
//set controls
print("\nEnter Students Level : ");
cin >> num;
while (cin.fail()){
print("\n( invalid ) Try Again : ");
cin.clear();cin.ignore();cin >> num;
}
while (num != 100 && num != 200 && num != 300 && num != 400){
print("( invalid ) Enter Level : ");
cin >> num;
while (cin.fail()){
print("\n( invalid ) Try Again : ");
cin.clear();cin.ignore();cin >> num;
}
}
temp.level = num;
//set controls
print("\nEnter Students School Fees : ");
cin >> num;
while (cin.fail()){
print("\n( invalid ) Try Again : ");
cin.clear();cin.ignore();cin >> num;
}
temp.schoolfees = num;
//pushing to array
Stu_Container[temp.details.getIndex()] = temp;
print("\nDo you want to add another student? (y/n) : ");
cin >> str;
if (str == "y"){
addStudent();
}
else{
//pass
}
};
void editStudent(){
//search student
int pass = 1;
print("\n( edit ) Enter students ID or 0 to leave : ");
int stu_id;
cin >> stu_id;
while (cin.fail()){
print("\n( invalid ) Try Again : ");
cin.clear();cin.ignore();cin >> stu_id;
}
if (stu_id != 0){
stu_id -= stu_base_id;
//controls
while (stu_id < 0 || stu_id >= stu_count){
print("\n( invalid ) Enter Students ID or 0 to leave : ");
cin >> stu_id;
while (cin.fail()){
cin.clear();cin.ignore();
print("\n( invalid ) Enter valid student ID : ");
cin >> stu_id;
}
if(stu_id != 0){
stu_id -= stu_base_id;
}
else{
pass = 0;
break;
}
}
if (pass == 1){
//found student
print("\nStudent Found\n");
student obj = Stu_Container[stu_id];
//editing student
//list option for edit...eg name ,age etc.
while (true){
print("\n\n1. name \n2. age \n3. level \n4. course \n5. department \n6. student subjects \n7. residence \n0. exit\n");
print("\nWhat do you want to edit : ");
string edit;
cin >> edit;
if (edit == "1"){
print("\nStudents name : ");print(obj.details.getName());
print("\n\nChange to : ");
cin.ignore();getline(cin, str);cin.clear();
}
else if (edit == "2"){
print("\nStudents age : ");print(obj.details.getAge());
print("\n\nChange to : ");
cin >> num;
while (cin.fail()){
print("\n( invalid ) Try Again : ");
cin.clear();cin.ignore();cin >> num;
}
obj.details.setAge(num);
}
else if (edit == "3"){
print("\nStudents level : ");print(obj.level);
print("\n\nChange to : ");
cin >> num;
while (cin.fail()){
print("\n( invalid ) Try Again : ");
cin.clear();cin.ignore();cin >> num;
}
while (num != 100 && num != 200 && num != 300 && num != 400){
print("\n\nChange to 100,200,300 or 400 : ");
cin >> num;
while (cin.fail()){
print("\n( invalid ) Try Again : ");
cin.clear();cin.ignore();cin >> num;
}
}
obj.level = num;
}
else if (edit == "4"){
print("\nStudents course : ");print(obj.course);
cin.ignore();getline(cin, str);cin.clear();
obj.course = str;
}
else if (edit == "5"){
print("\nStudents Department : ");print(obj.department);
print("\n\nChange to : ");
cin.ignore();getline(cin, str);cin.clear();
obj.department = str;
}
else if (edit == "6"){
print("\n\n\nStudents subject : \n");//list obj.subjects;
while (true){
print("1. add subject \n2. remove subject \n0. exit\n");
print("select an option : ");
cin >> str;
if (str == "1"){
cin.ignore();
while (true){
print("\nenter subject to add or use 0 to leave : ");
getline(cin, str);
if (str == "0"){
break;
}
else{
obj.subjects.push_back(str);
record _new;
_new.course_name = str;
_new.mark = -1;
obj.academic_records.push_back(_new);
}
}
}
else if (str == "2"){
cin.ignore();
while (true){
print("\nenter subject to remove or use 0 to leave : ");
getline(cin, str);
if (str == "0"){
break;
}
else{
int len = obj.subjects.size();
for (int i=0;i<len;i++){
if (lower(obj.subjects[i]) == lower(str)){
obj.subjects.erase(obj.subjects.begin()+i);
obj.academic_records.erase(obj.academic_records.begin()+i);
print("\nSubject successfully removed ...");
break;
}
if (i == len-1){
print("\ncant find subject index ...\n");
}
}
}
}
}else if (str == "0"){
break;
}
}
}
else if (edit == "7"){
print("\nStudents Residence : ");print(obj.details.getResidence());
print("\n\nChange to : ");
cin.ignore();getline(cin, str);cin.clear();
cin.clear();obj.details.setResidence(str);
}
else if (edit == "0"){
//commit changes and push
Stu_Container[obj.details.getIndex()] = obj;
break;
}
}
}
}
};
void manageStudent(){
//search student
int pass = 1;
print("\n( manage )Enter students ID or 0 to leave : ");
int stu_id;
cin >> stu_id;
while (cin.fail()){
print("\n( invalid ) Try Again : ");
cin.clear();cin.ignore();cin >> stu_id;
}
if (stu_id != 0){
stu_id -= stu_base_id;
//controls
while (stu_id < 0 || stu_id >= stu_count){
print("\n( invalid ) Enter Students ID or 0 to leave : ");
cin >> stu_id;
while (cin.fail()){
cin.clear();cin.ignore();
print("\n( invalid ) Enter valid student ID : ");
cin >> stu_id;
}
if(stu_id != 0){
stu_id -= stu_base_id;
}
else{
pass = 0;
break;
}
}
if (pass == 1){
//found student
print("\nStudent Found\n");
student obj = Stu_Container[stu_id];
//editing student
while (true){
print("\n\n1. enter students score \n2. show academic records \n3. remove student \n0. exit\n");
print("\nWhat do you want to do : ");
string manage;
cin >> manage;
if (manage == "1"){
int len = obj.subjects.size();
print("Enter the semester? (1,2) : ");
cin >> num;
while (num != 1 && num != 2){
print("Enter the semester? (1,2) : ");
cin >> num;
}
for (int i=0;i<len;i++){
if (obj.academic_records[i].mark == -1){
print("\n\nSubject :\t");print(obj.academic_records[i].course_name);
print("\nDo you want to record marks for this subject : ");
cin >> str;str = lower(str);
while (str != "y" && str != "n"){
print("\nplease choose 'y' or 'n'");
cin >> str;
str = lower(str);
}
if (str == "y"){
int credit_h;
print("\nCredit Hour(s)\t:\t");
cin >> credit_h;
while (0 > credit_h || credit_h > 3){
print("(invalid) Credit Hour(s)\t:\t");
cin >> credit_h;
}
int score;
print("Enter Mark\t:\t");
cin >> score;
while (0 > score || score >100){
print("(invalid) Enter Mark\t:\t");
cin >> score;
}
obj.academic_records[i].mark = score;
obj.academic_records[i].credit_hr = score;
obj.academic_records[i].semester = num;
obj.academic_records[i].grade = gradeCalc(score);
}
}
}
Stu_Container[obj.details.getIndex()] = obj;
}
else if (manage == "2"){
int len = obj.subjects.size();
print("\n\n############################################################################################");
print("\n********************************************************************************************");
print("\nName : ");print(obj.details.getName());print("\tDepartment : ");print(obj.department);
print("\tCourse : ");print(obj.course);print("\tLevel : ");print(obj.level);print("\tGPA :\t");GpaCalc(obj);
print("\n********************************************************************************************");
print("\n============================================================================================");
for (int i=0;i<len;i++){
if (obj.academic_records[i].mark != -1){
print("\n\nSubject :\t");print(obj.academic_records[i].course_name);
print("\t\tMark :\t");print(obj.academic_records[i].mark);
print("\t\tGrade :\t");print(obj.academic_records[i].grade);
}
else{
print("\n\nSubject :\t");print(obj.academic_records[i].course_name);
print("\t\tMark :\t");print("**N/A**");
print("\t\tGrade :\t");print("**N/A**");
}
}
print("\n\n============================================================================================");
print("\n############################################################################################");
}
else if (manage == "3"){
print("\nAre you sure you want to remove student? (y/n) : ");
cin >> str;str = lower(str);
while (str != "y" && str != "n"){
print("\nplease choose 'y' or 'n'");
cin >> str;
str = lower(str);
}
if (str == "y"){
obj.details.setStatus("removed");
Stu_Container[obj.details.getIndex()] = obj;
}
}
else if (manage == "0"){
//commit changes and push
Stu_Container[obj.details.getIndex()] = obj;
break;
}
}
}
}
};
void addStaff(){
//add student detail....read class and struct
cin.clear();
print("\n**************adding new staff*****************");
staff temp;
print("\n\nAssigned Staff ID : ");print(sta_base_id+sta_count);
temp.details.setID(sta_base_id+sta_count);temp.details.setIndex(sta_count);sta_count++;
string str;int num;
print("\nEnter Staff Name : ");
cin.ignore();getline(cin, str);cin.clear();
temp.details.setName(str);
print("\nEnter Staff Age : ");
cin >> num;
while (cin.fail()){
print("\n( invalid ) Try Again : ");
cin.clear();cin.ignore();cin >> num;
}
temp.details.setAge(num);
//list department for student to choose from
print("\nEnter Department Name : ");
cin >> str;
temp.department = str;
//list course using department
print("\nEnter Staffs Job : ");
cin >> str;
temp.job = str;
//list course using department
//pushing to array
Sta_Container[temp.details.getIndex()] = temp;
print("\nDo you want to add another staff? (y/n) : ");
cin >> str;
if (str == "y"){
addStaff();
}
else{
//pass
}
};
void editStaff(){
//search student
int pass = 1;
print("\n( edit ) Enter Staffs ID or 0 to leave : ");
int sta_id;
cin >> sta_id;
while (cin.fail()){
print("\n( invalid ) Try Again : ");
cin.clear();cin.ignore();cin >> sta_id;
}
if (sta_id != 0){
sta_id -= sta_base_id;
//controls
while (sta_id < 0 || sta_id >= stu_count){
print("\n( invalid ) Enter Staffs ID or 0 to leave : ");
cin >> sta_id;
while (cin.fail()){
cin.clear();cin.ignore();
print("\n( invalid ) Enter valid Staff ID : ");
cin >> sta_id;
}
if(sta_id != 0){
sta_id -= sta_base_id;
}
else{
pass = 0;
break;
}
}
if (pass == 1){
//found student
print("\nStaff Found\n");
staff obj = Sta_Container[sta_id];
//editing student
//list option for edit...eg name ,age etc.
while (true){
print("\n\n1. name \n2. age \n3. department \n4. staff subjects \n5. residence \n0. exit\n");
print("\nWhat do you want to edit : ");
string edit;
cin >> edit;
if (edit == "1"){
print("\nStaffs name : ");print(obj.details.getName());
print("\n\nChange to : ");
cin.ignore();getline(cin, str);cin.clear();
}
else if (edit == "2"){
print("\n\nChange to : ");
cin >> num;
while (cin.fail()){
print("\n( invalid ) Try Again : ");
cin.clear();cin.ignore();cin >> num;
}
obj.details.setAge(num);
}
else if (edit == "3"){
print("\nStaffs Department : ");print(obj.department);
print("\n\nChange to : ");
cin.ignore();getline(cin, str);cin.clear();
obj.department = str;
}
else if (edit == "4"){
print("\n\n\nStaffs subject : \n");//list obj.subjects;
while (true){
print("1. add subject \n2. remove subject \n0. exit\n");
print("select an option : ");
cin >> str;
if (str == "1"){
cin.ignore();
while (true){
print("\nenter subject to add or use 0 to leave : ");
getline(cin, str);
if (str == "0"){
break;
}
else{
obj.subjects.push_back(str);
}
}
}
else if (str == "2"){
cin.ignore();
while (true){
print("\nenter subject to remove or use 0 to leave : ");
getline(cin, str);
if (str == "0"){
break;
}
else{
int len = obj.subjects.size();
for (int i=0;i<len;i++){
if (lower(obj.subjects[i]) == lower(str)){
obj.subjects.erase(obj.subjects.begin()+i);
print("\nSubject successfully removed ...");
break;
}
if (i == len-1){
print("\ncant find subject index ...\n");
}
}
}
}
}else if (str == "0"){
break;
}
}
}
else if (edit == "5"){
print("\nStaffs Residence : ");print(obj.details.getResidence());
print("\n\nChange to : ");
cin.ignore();getline(cin, str);cin.clear();
cin.clear();obj.details.setResidence(str);
}
else if (edit == "0"){
//commit changes and push
Sta_Container[obj.details.getIndex()] = obj;
break;
}
}
}
}
};
void manageStaff(){
//search student
int pass = 1;
print("\n( manage )Enter Staffs ID or 0 to leave : ");
int sta_id;
cin >> sta_id;
while (cin.fail()){
print("\n( invalid ) Try Again : ");
cin.clear();cin.ignore();cin >> sta_id;
}
if (sta_id != 0){
sta_id -= sta_base_id;
//controls
while (sta_id < 0 || sta_id >= sta_count){
print("\n( invalid ) Enter Staff ID or 0 to leave : ");
cin >> sta_id;
while (cin.fail()){
cin.clear();cin.ignore();
print("\n( invalid ) Enter valid staff ID : ");
cin >> sta_id;
}
if(sta_id != 0){
sta_id -= sta_base_id;
}
else{
pass = 0;
break;
}
}
if (pass == 1){
//found student
print("\nStaff Found\n");
staff obj = Sta_Container[sta_id];
//editing student
while (true){
print("\n\n1. remove staff \n0. exit\n");
print("\nWhat do you want to do : ");
string manage;
cin >> manage;
if (manage == "1"){
print("\nAre you sure you want to remove staff? (y/n) : ");
cin >> str;str = lower(str);
while (str != "y" && str != "n"){
print("\nplease choose 'y' or 'n'");
cin >> str;
str = lower(str);
}
if (str == "y"){
obj.details.setStatus("removed");
Sta_Container[obj.details.getIndex()] = obj;
}
}
else if (manage == "0"){
//commit changes and push
Sta_Container[obj.details.getIndex()] = obj;
break;
}
}
}
}
};
string lower(string line){
string LOWER = "abcdefghijklmnopqrstuvwxyz";
string UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string ret_lower = "";
int len = line.length();
for (int i=0;i<len;i++){//boy
for (int j=0;j<26;j++){
if (line[i] == UPPER[j]){
ret_lower += LOWER[j];
break;
}
else if (j == 25){
ret_lower += line[i];
}
}
}
return ret_lower;
}
string gradeCalc(double score){
if (79 < score && score <= 100){
return "A";
}
else if(74 < score && score <= 79){
return "B+";
}
else if(69 < score && score <= 74){
return "B";
}
else if(64 < score && score <= 69){
return "C+";
}
else if(59 < score && score <= 64){
return "C";
}
else if(54 < score && score <= 59){
return "D+";
}
else if(49 < score && score <= 54){
return "D";
}
else if(44 < score && score <= 49){
return "E";
}
else if(-1 < score && score <= 44){
return "F";
}
else{
return "invalid mark";
}
}
float getGpaScore(string grade){
if (grade == "A"){
return 4.0;
}
else if (grade == "B+"){
return 3.5;
}
else if (grade == "B"){
return 3.0;
}
else if (grade == "C+"){
return 2.5;
}
else if (grade == "C"){
return 2.0;
}
else if (grade == "D+"){
return 1.5;
}
else if (grade == "D"){
return 1.0;
}
else if (grade == "E"){
return 0.5;
}
else if (grade == "F"){
return 0.0;
}
return -1;
}
void GpaCalc(student obj){
float gpa = 0.0;int tch=0;bool empty_score = false;
int len = obj.academic_records.size();
vector<record> temp_record = obj.academic_records;
for (int i=0;i<len;i++){
if (temp_record[i].mark == -1){
empty_score = true;
cout << "**N/A**";
break;
}
else{
tch += temp_record[i].credit_hr;
gpa += getGpaScore(temp_record[i].grade)*temp_record[i].credit_hr;
}
}
if (empty_score == false){
if (len != 0){
cout << gpa/tch;
}
else{
cout << "**N/A**";
}
}
}
| [
"noreply@github.com"
] | noreply@github.com |
816414ea7b41b6f77de61c90235f1a1064ec6c72 | c3bdc6275a9b040f466e1e05da48d367cdc8ef8a | /libraries/AirQuality_Sensor_Troy/examples/AirQuality_Sensor/AirQuality_Sensor.ino | cf79d7e5b2245b4f8ba952af7b619f33ec6e23fd | [] | no_license | amadues2013/Arduino | 9a6315ca6dc7edbc298d8dba35d521c2d8cd6794 | bf84bf8b191494980b25bfeb77837c82bcf9db48 | refs/heads/master | 2020-05-31T21:19:20.148047 | 2017-02-02T09:14:39 | 2017-02-02T09:14:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,311 | ino | /*
AirQuality Demo V1.0.
connect to A1 to start testing. it will needs about 20s to start
* By: http://www.seeedstudio.com
*/
#include"AirQuality.h"
#include"Arduino.h"
AirQuality airqualitysensor;
int current_quality =-1;
int current_reading = 7;
void setup()
{
Serial.begin(9600);
airqualitysensor.init(14);
}
void loop()
{
current_quality=airqualitysensor.slope();
current_reading = airqualitysensor.numero();
if (current_reading >= 0)// if a valid data returned.
{
Serial.println(current_reading);}
if (current_quality >= 0)// if a valid data returned.
{
if (current_quality==0)
Serial.println(" High pollution! Force signal active");
else if (current_quality==1)
Serial.println(" High pollution!");
else if (current_quality==2)
Serial.println(" Low pollution!");
else if (current_quality ==3)
Serial.println(" Fresh air");
}
}
ISR(TIMER2_OVF_vect)
{
if(airqualitysensor.counter==122)//set 2 seconds as a detected duty
{
airqualitysensor.last_vol=airqualitysensor.first_vol;
airqualitysensor.first_vol=analogRead(A0);
airqualitysensor.counter=0;
airqualitysensor.timer_index=1;
PORTB=PORTB^0x20;
}
else
{
airqualitysensor.counter++;
}
} | [
"git@troykyo.com"
] | git@troykyo.com |
62d63f9b9e9fb74eff63dc14cf899a67d5d4b378 | 6e25c49160136c226fb698da6da570cacdab1156 | /codeforces/975b.cpp | b917f17199ecd88abaef1619dce6cbd6ed7400e6 | [] | no_license | amitkvikram/COMPETITIVE-PROGRAMMING | 627627447f777192e092289989ebc60a8e67ae60 | cfa7ee44884e8739813e4f2779a0eb121bd3aa92 | refs/heads/master | 2021-10-22T11:07:19.763820 | 2019-03-10T03:42:43 | 2019-03-10T03:42:43 | 103,694,836 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,217 | cpp | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::vector<ll> vi;
typedef pair<int,int> pi;
#define ss second
#define ff first
// const int inf = INT_MAX;
bool status = false;
bool is_valid(int n, int m, int i, int j){
return i<n && j<m && i>-1 && j>-1;
}
int adjacent_row[] = {-1, 1, 0, 0};
int adjacent_col[] = {0, 0, -1, 1};
int main(){
vi v(14);
for (int i = 0; i < 14; i++){
cin >> v[i];
}
ll res = 0;
for (int i = 0; i < 14; i++){
vector<ll> tmp;
tmp = v;
ll num = v[i];
tmp[i] = 0;
for (int j = 0; j < 14; j++)
{
tmp[j] += (num / 14);
}
num = num % 14;
for (int j = i + 1; j <= i + num; j++){
tmp[j % 14] += 1;
}
num = 0;
for (int j = 0; j < 14; j++){
// cout << tmp[j] << ' ';
if (tmp[j] % 2 == 0)
num += tmp[j];
}
if (num > res)
res = num;
}
cout << res << endl;
} | [
"amitkvikram@rediffmail.com"
] | amitkvikram@rediffmail.com |
02dedae735101c3e5f59efd57a27899151c21bd4 | ff7b72f7e0eda7e1c92174c786016aec114fb199 | /src/PIDOptimizer.cpp | 8e3948090934e3b1cbc5d7a09c91909248267a55 | [
"MIT"
] | permissive | ichipper/CarND-PID-Control-Project | 895e1f880f99e453405bddf9c88277a4c8ca544a | 837e18d5201c97d561f4525bde7dabf7d1873ebc | refs/heads/master | 2020-04-27T22:23:21.088786 | 2019-03-10T03:10:49 | 2019-03-10T03:10:49 | 174,735,230 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,672 | cpp | #include "PIDOptimizer.h"
#include <iostream>
PIDOptimizer::PIDOptimizer(PID* pid) {
this->pid = pid;
}
PIDOptimizer::~PIDOptimizer() {}
void PIDOptimizer::Initialize(double Kp, double Ki, double Kd, double Kp_d, double Ki_d, double Kd_d) {
total_error = 0.0;
best_error = 9999;
p = {Kp, Ki, Kd};
dp = {Kp_d, Ki_d, Kd_d};
i = 0;
count = 0;
pos_search = true;
p[i] += dp[i];
std::cout << "==========p[" << i << "] += dp[" << i << "]" << std::endl;
pid->Init(p[0], p[1], p[2]);
}
void PIDOptimizer::Twiddle(double cte) {
//i, pos_search, count
//Every time there is new data point coming in, update the total error
total_error += cte*cte;
//std::cout << "total_error=" << total_error << std::endl;
if (count==799) { //End of an eval
//Get average of the total error;
std::cout << "===============i=" << i;
if (pos_search) std::cout << " positive search" << std::endl;
else std::cout << " negative search" << std::endl;
total_error /= (count+1);
if (total_error<best_error) {
if (pos_search) {
best_error = total_error;
best_p = {p[0], p[1], p[2]};
dp[i] *= 1.1;
}
else {
best_error = total_error;
best_p = {p[0], p[1], p[2]};
dp[i] *= 1.1;
}
std::cout << "==========search succeeded, move to next parameter" << std::endl;
i=(i+1)%3;//Proceed to next parameter
pos_search = true;
p[i] += dp[i];
}
else {
if (pos_search) {
std::cout << "==========search failed, move to negative search" << std::endl;
pos_search = false;
p[i] -= 2*dp[i];
}
else {
std::cout << "==========search failed, restore dp[i]" << std::endl;
p[i] += dp[i];
dp[i] *= 0.9;
i=(i+1)%3;//Proceed to next parameter
pos_search = true;
}
}
std::cout << "========================================" << std::endl;
std::cout << "best error=" << best_error << " best Kp=" << best_p[0]
<< " best Ki=" << best_p[1] << " best Kd=" << best_p[2] << std::endl;
std::cout << "current error=" << total_error << " Kp=" << p[0] << " Ki=" << p[1]
<< " Kd=" << p[2] << " Kp_d=" << dp[0] << " Ki_d=" << dp[1] << " Kd_d=" << dp[2]
<< std::endl;
std::cout << "========================================" << std::endl;
//End of evaluation
count = 0;
total_error = 0.0;
pid->Init(p[0], p[1], p[2]);
}
else {
count++;
}
}
void PIDOptimizer::ShowBestParameters() {
std::cout << "best error=" << best_error << " best Kp=" << best_p[0]
<< " best Ki=" << best_p[1] << " best Kd=" << best_p[2] << std::endl;
}
| [
"iceinsouth@gmail.com"
] | iceinsouth@gmail.com |
bb3f71646469408f5b20513055aa9c2167105698 | 2fb6fae81f02902c1c643fbfe1f29b1a2473285b | /GameState.cpp | 251f6bb3537fefd6bec03799da35dc6d9dd5bd46 | [] | no_license | KavyaKadi3/Graphical-TicTacToe | 75a68832e15fc1949c911311ffc1a470266c7805 | 0035fec39b2d768ac4970474d55f0f6b42621b16 | refs/heads/main | 2023-03-07T21:16:51.075625 | 2021-02-24T19:12:00 | 2021-02-24T19:12:00 | 342,006,289 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,860 | cpp | //Final Submission
// GameState.cpp
// TicTacToe
//
// Created by Tarek Abdelrahman on 2019-06-07.
// Modified by Tarek Abdelrahman on 2020-09-17.
// Copyright © 2019-2020 Tarek Abdelrahman. All rights reserved.
//
// Permission is hereby granted to use this code in ECE244 at
// the University of Toronto. It is prohibited to distribute
// this code, either publicly or to third parties.
//
#include "globals.h"
#include "GameState.h"
//Obtaining rows and columns
int GameState::get_selectedColumn() {
return selectedColumn;
}
int GameState::get_selectedRow() {
return selectedRow;
}
//Obtaining valid move, game over, turn and win code
bool GameState::get_moveValid() {
return moveValid;
}
bool GameState::get_gameOver() {
return gameOver;
}
bool GameState:: get_turn() {
return turn;
}
int GameState::get_winCode() {
return winCode;
}
//Setting up rows and columns
void GameState::set_selectedRow(int value) {
selectedRow=value;
}
void GameState::set_selectedColumn(int value) {
selectedColumn=value;
}
//Setting up valid move, game over, turn and win code
void GameState::set_moveValid(bool value) {
moveValid=value;
}
void GameState::set_gameOver(bool value) {
gameOver=value;
}
void GameState::set_turn(bool value) {
turn=value;
}
void GameState::set_winCode(int value) {
winCode=value;
}
//Obtaining and setting game board
int GameState::get_gameBoard(int row, int col) {
return gameBoard[row][col];
}
void GameState:: set_gameBoard(int row, int col, int value) {
gameBoard[row][col]=value;
}
//Game State Constructor
GameState::GameState() {
selectedRow = 0;
selectedColumn = 0;
moveValid = true;
gameOver = false;
turn = true;
winCode= 0;
for (int i=0; i<3; i++) {
for (int j=0; j<3; j++) {
gameBoard[i][j]=0;
}
}
} | [
"noreply@github.com"
] | noreply@github.com |
d05d436d9a62ce48b8e19a040ee3cdb3ee7e51c4 | 98b1e51f55fe389379b0db00365402359309186a | /midterm/cavity_new/cavity/1.64/phi | 8b9db8e4763d75ad1b6ce5505ed8e8b8af4efbb8 | [] | no_license | taddyb/597-009 | f14c0e75a03ae2fd741905c4c0bc92440d10adda | 5f67e7d3910e3ec115fb3f3dc89a21dcc9a1b927 | refs/heads/main | 2023-01-23T08:14:47.028429 | 2020-12-03T13:24:27 | 2020-12-03T13:24:27 | 311,713,551 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,042 | /*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class surfaceScalarField;
location "1.64";
object phi;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 3 -1 0 0 0 0];
internalField nonuniform List<scalar>
760
(
1.2496e-06
-4.66574e-21
1.2496e-06
-1.21963e-21
1.2496e-06
5.04752e-22
1.2496e-06
8.9066e-22
1.2496e-06
4.43686e-22
1.2496e-06
-1.45385e-22
1.2496e-06
-3.44587e-22
1.2496e-06
-7.32006e-22
1.2496e-06
-5.83102e-22
1.2496e-06
-7.19952e-22
1.2496e-06
-8.34423e-22
1.2496e-06
-8.98482e-22
1.2496e-06
-8.55778e-22
1.2496e-06
-1.00079e-21
1.2496e-06
-9.32169e-22
1.2496e-06
-5.22747e-22
1.2496e-06
2.24716e-23
1.2496e-06
3.80884e-22
1.2496e-06
-5.83761e-23
-1.06293e-21
3.74883e-06
2.22598e-21
3.74883e-06
2.38242e-21
3.74883e-06
2.8931e-21
3.74883e-06
2.38615e-21
3.74883e-06
7.84058e-22
3.74883e-06
-1.18465e-21
3.74883e-06
-2.14793e-21
3.74883e-06
-2.69924e-21
3.74883e-06
-3.7998e-21
3.74883e-06
-3.87705e-21
3.74883e-06
-4.16145e-21
3.74883e-06
-4.57233e-21
3.74883e-06
-3.99857e-21
3.74883e-06
-2.93866e-21
3.74883e-06
-2.34535e-21
3.74883e-06
-8.48992e-22
3.74883e-06
1.50201e-21
3.74883e-06
2.13197e-21
3.74883e-06
2.86606e-21
2.2923e-21
6.24807e-06
9.17552e-21
6.24807e-06
7.6451e-21
6.24807e-06
6.6397e-21
6.24807e-06
4.18737e-21
6.24807e-06
1.10989e-21
6.24807e-06
-2.92894e-21
6.24807e-06
-6.09901e-21
6.24807e-06
-9.08923e-21
6.24807e-06
-1.01198e-20
6.24807e-06
-1.0834e-20
6.24807e-06
-9.63257e-21
6.24807e-06
-9.05764e-21
6.24807e-06
-8.28778e-21
6.24807e-06
-6.20268e-21
6.24807e-06
-2.73166e-21
6.24807e-06
8.87739e-22
6.24807e-06
5.08962e-21
6.24807e-06
7.71692e-21
6.24807e-06
9.5747e-21
1.09018e-20
8.74737e-06
1.7913e-20
8.74737e-06
1.49668e-20
8.74737e-06
1.10808e-20
8.74737e-06
6.05604e-21
8.74737e-06
-1.46564e-21
8.74737e-06
-7.21448e-21
8.74737e-06
-1.3483e-20
8.74737e-06
-1.59441e-20
8.74737e-06
-1.70177e-20
8.74737e-06
-1.81036e-20
8.74737e-06
-1.88402e-20
8.74737e-06
-1.7509e-20
8.74737e-06
-1.36122e-20
8.74737e-06
-7.92731e-21
8.74737e-06
-1.65469e-21
8.74737e-06
4.22563e-21
8.74737e-06
1.14918e-20
8.74737e-06
1.69036e-20
8.74737e-06
1.99662e-20
1.93555e-20
1.12467e-05
2.62789e-20
1.12467e-05
2.16563e-20
1.12467e-05
1.4659e-20
1.12467e-05
4.96165e-21
1.12467e-05
-4.87099e-21
1.12467e-05
-1.4148e-20
1.12467e-05
-1.97911e-20
1.12467e-05
-2.5829e-20
1.12467e-05
-2.79531e-20
1.12467e-05
-2.86322e-20
1.12467e-05
-2.69702e-20
1.12467e-05
-2.4799e-20
1.12467e-05
-1.75534e-20
1.12467e-05
-7.76057e-21
1.12467e-05
2.35514e-21
1.12467e-05
1.30524e-20
1.12467e-05
2.01331e-20
1.12467e-05
2.628e-20
1.12467e-05
2.89137e-20
2.88226e-20
1.37462e-05
3.04478e-20
1.37462e-05
2.6093e-20
1.37462e-05
1.58892e-20
1.37462e-05
4.32272e-21
1.37462e-05
-8.42028e-21
1.37462e-05
-2.02125e-20
1.37462e-05
-2.9882e-20
1.37462e-05
-3.39171e-20
1.37462e-05
-3.67232e-20
1.37462e-05
-3.5543e-20
1.37462e-05
-3.36677e-20
1.37462e-05
-2.89259e-20
1.37462e-05
-1.83255e-20
1.37462e-05
-6.4932e-21
1.37462e-05
6.99043e-21
1.37462e-05
1.96436e-20
1.37462e-05
2.88269e-20
1.37462e-05
3.49928e-20
1.37462e-05
3.81144e-20
3.42663e-20
1.62457e-05
3.64304e-20
1.62457e-05
2.60642e-20
1.62457e-05
1.47952e-20
1.62457e-05
-2.15334e-21
1.62457e-05
-1.24586e-20
1.62457e-05
-2.51276e-20
1.62457e-05
-3.36648e-20
1.62457e-05
-3.90753e-20
1.62457e-05
-4.27454e-20
1.62457e-05
-4.29186e-20
1.62457e-05
-3.81375e-20
1.62457e-05
-2.9685e-20
1.62457e-05
-1.93183e-20
1.62457e-05
-3.41837e-21
1.62457e-05
1.20258e-20
1.62457e-05
2.42196e-20
1.62457e-05
3.41271e-20
1.62457e-05
4.28406e-20
1.62457e-05
4.21957e-20
4.14485e-20
1.87454e-05
3.53158e-20
1.87454e-05
2.55545e-20
1.87454e-05
1.08225e-20
1.87454e-05
-2.84801e-21
1.87454e-05
-1.85233e-20
1.87454e-05
-2.68159e-20
1.87454e-05
-3.4592e-20
1.87454e-05
-4.03075e-20
1.87454e-05
-4.37073e-20
1.87454e-05
-4.35862e-20
1.87454e-05
-4.19353e-20
1.87454e-05
-3.06232e-20
1.87454e-05
-1.57935e-20
1.87454e-05
-1.4596e-21
1.87454e-05
1.53221e-20
1.87454e-05
2.94836e-20
1.87454e-05
3.76531e-20
1.87454e-05
4.28507e-20
1.87454e-05
4.44163e-20
4.27681e-20
2.12451e-05
3.74392e-20
2.12451e-05
2.6321e-20
2.12451e-05
9.67927e-21
2.12451e-05
-5.9557e-21
2.12451e-05
-1.98299e-20
2.12451e-05
-2.68116e-20
2.12451e-05
-3.49915e-20
2.12451e-05
-3.84448e-20
2.12451e-05
-3.96256e-20
2.12451e-05
-4.04339e-20
2.12451e-05
-3.43254e-20
2.12451e-05
-2.5462e-20
2.12451e-05
-1.47403e-20
2.12451e-05
-2.12804e-21
2.12451e-05
1.37337e-20
2.12451e-05
2.71946e-20
2.12451e-05
3.51941e-20
2.12451e-05
3.84312e-20
2.12451e-05
4.06771e-20
4.1711e-20
2.3745e-05
3.06162e-20
2.3745e-05
2.13477e-20
2.3745e-05
8.23103e-21
2.3745e-05
-4.74012e-21
2.3745e-05
-1.79693e-20
2.3745e-05
-2.64448e-20
2.3745e-05
-3.12016e-20
2.3745e-05
-3.3642e-20
2.3745e-05
-3.49386e-20
2.3745e-05
-3.36032e-20
2.3745e-05
-2.55593e-20
2.3745e-05
-1.9767e-20
2.3745e-05
-1.26339e-20
2.3745e-05
3.74397e-22
2.3745e-05
1.30476e-20
2.3745e-05
2.47793e-20
2.3745e-05
2.94221e-20
2.3745e-05
3.13165e-20
2.3745e-05
3.44962e-20
3.39887e-20
2.6245e-05
2.13822e-20
2.6245e-05
1.43823e-20
2.6245e-05
4.7658e-21
2.6245e-05
-4.58385e-21
2.6245e-05
-1.0385e-20
2.6245e-05
-1.74459e-20
2.6245e-05
-2.44964e-20
2.6245e-05
-2.94753e-20
2.6245e-05
-2.84705e-20
2.6245e-05
-2.52649e-20
2.6245e-05
-1.8447e-20
2.6245e-05
-1.02746e-20
2.6245e-05
-4.87469e-21
2.6245e-05
-5.60488e-22
2.6245e-05
7.04189e-21
2.6245e-05
1.33545e-20
2.6245e-05
2.56776e-20
2.6245e-05
2.69464e-20
2.6245e-05
2.52741e-20
2.54473e-20
2.87451e-05
7.14723e-21
2.87451e-05
4.02434e-21
2.87451e-05
3.2306e-21
2.87451e-05
-7.49891e-21
2.87451e-05
-7.4127e-21
2.87451e-05
-1.21129e-20
2.87451e-05
-1.58362e-20
2.87451e-05
-1.6434e-20
2.87451e-05
-2.14576e-20
2.87451e-05
-1.82102e-20
2.87451e-05
-1.18883e-20
2.87451e-05
-4.88991e-21
2.87451e-05
4.10652e-21
2.87451e-05
7.74505e-21
2.87451e-05
9.92436e-21
2.87451e-05
1.07193e-20
2.87451e-05
1.41014e-20
2.87451e-05
1.88611e-20
2.87451e-05
1.65822e-20
9.25362e-21
3.12454e-05
4.40007e-23
3.12454e-05
-1.65539e-21
3.12454e-05
-5.48595e-21
3.12454e-05
-3.47893e-21
3.12454e-05
-6.1133e-21
3.12454e-05
-9.03612e-21
3.12454e-05
-1.12292e-20
3.12454e-05
-1.2488e-20
3.12454e-05
-1.20917e-20
3.12454e-05
-6.35886e-21
3.12454e-05
-3.2737e-21
3.12454e-05
3.94444e-21
3.12454e-05
9.51114e-21
3.12454e-05
1.2151e-20
3.12454e-05
1.1296e-20
3.12454e-05
9.83531e-21
3.12454e-05
4.53433e-21
3.12454e-05
2.21088e-21
3.12454e-05
4.42336e-21
2.27029e-21
3.37457e-05
-9.3657e-21
3.37457e-05
-1.05595e-20
3.37457e-05
-9.16355e-21
3.37457e-05
-6.62419e-21
3.37457e-05
-5.16495e-21
3.37457e-05
-3.92805e-21
3.37457e-05
-4.80907e-21
3.37457e-05
-3.95317e-21
3.37457e-05
-2.02627e-21
3.37457e-05
1.29728e-21
3.37457e-05
6.59599e-21
3.37457e-05
1.15933e-20
3.37457e-05
1.04209e-20
3.37457e-05
1.23228e-20
3.37457e-05
1.07511e-20
3.37457e-05
7.70907e-21
3.37457e-05
1.01211e-22
3.37457e-05
1.41316e-21
3.37457e-05
7.39897e-22
-3.06809e-21
3.62462e-05
-1.14933e-20
3.62462e-05
-8.49243e-21
3.62462e-05
-8.02458e-21
3.62462e-05
-7.16204e-21
3.62462e-05
-4.18897e-21
3.62462e-05
-6.08516e-21
3.62462e-05
-6.77252e-21
3.62462e-05
-6.36317e-21
3.62462e-05
8.13307e-22
3.62462e-05
5.25931e-21
3.62462e-05
8.98004e-21
3.62462e-05
1.22934e-20
3.62462e-05
2.12668e-20
3.62462e-05
1.70396e-20
3.62462e-05
7.97155e-21
3.62462e-05
4.90319e-21
3.62462e-05
4.33631e-21
3.62462e-05
-4.16414e-21
3.62462e-05
-7.02474e-21
-8.0145e-21
3.87467e-05
-7.20744e-21
3.87467e-05
-7.66223e-21
3.87467e-05
-4.38567e-21
3.87467e-05
2.51732e-21
3.87467e-05
-7.3168e-22
3.87467e-05
-8.79215e-21
3.87467e-05
-8.8245e-21
3.87467e-05
-6.52892e-21
3.87467e-05
4.29161e-21
3.87467e-05
4.81105e-21
3.87467e-05
7.60068e-21
3.87467e-05
1.10261e-20
3.87467e-05
1.31908e-20
3.87467e-05
1.45082e-20
3.87467e-05
1.02945e-20
3.87467e-05
1.72378e-21
3.87467e-05
-3.48025e-22
3.87467e-05
-3.66235e-21
3.87467e-05
-7.22922e-21
-5.19133e-21
4.12474e-05
-1.93045e-21
4.12474e-05
-3.32634e-21
4.12474e-05
-1.13802e-21
4.12474e-05
-3.78021e-22
4.12474e-05
-2.62241e-21
4.12474e-05
-5.92401e-21
4.12474e-05
-9.30592e-21
4.12474e-05
-4.83862e-21
4.12474e-05
-2.11345e-21
4.12474e-05
2.06524e-21
4.12474e-05
6.52367e-21
4.12474e-05
9.70523e-21
4.12474e-05
1.17272e-20
4.12474e-05
1.42944e-20
4.12474e-05
8.62479e-21
4.12474e-05
9.07367e-22
4.12474e-05
-6.19377e-21
4.12474e-05
-6.61646e-21
4.12474e-05
-4.4039e-21
-3.70162e-21
4.37481e-05
4.43513e-21
4.37481e-05
7.24042e-21
4.37481e-05
5.8584e-21
4.37481e-05
2.50937e-21
4.37481e-05
-5.42453e-21
4.37481e-05
-9.23063e-21
4.37481e-05
-8.03701e-21
4.37481e-05
-1.1128e-20
4.37481e-05
-2.14131e-21
4.37481e-05
6.05532e-21
4.37481e-05
3.73989e-21
4.37481e-05
7.02072e-21
4.37481e-05
9.31394e-21
4.37481e-05
6.48156e-21
4.37481e-05
1.65541e-21
4.37481e-05
-3.66876e-21
4.37481e-05
-7.17761e-21
4.37481e-05
-2.64513e-21
4.37481e-05
-1.89133e-21
-1.72708e-21
4.62488e-05
5.40535e-21
4.62488e-05
3.06836e-21
4.62488e-05
5.73502e-21
4.62488e-05
6.08726e-21
4.62488e-05
-2.03639e-21
4.62488e-05
-2.35478e-21
4.62488e-05
-7.53492e-21
4.62488e-05
-5.61706e-21
4.62488e-05
-1.71959e-21
4.62488e-05
6.0482e-21
4.62488e-05
4.70903e-21
4.62488e-05
-3.17981e-21
4.62488e-05
8.18044e-22
4.62488e-05
1.60233e-22
4.62488e-05
1.61986e-21
4.62488e-05
-4.30254e-22
4.62488e-05
-4.68887e-21
4.62488e-05
-1.68362e-21
4.62488e-05
-1.35893e-21
5.13053e-21
4.87496e-05
4.87496e-05
4.87496e-05
4.87496e-05
4.87496e-05
4.87496e-05
4.87496e-05
4.87496e-05
4.87496e-05
4.87496e-05
4.87496e-05
4.87496e-05
4.87496e-05
4.87496e-05
4.87496e-05
4.87496e-05
4.87496e-05
4.87496e-05
4.87496e-05
)
;
boundaryField
{
movingWall
{
type calculated;
value uniform 0;
}
fixedWalls
{
type calculated;
value uniform 0;
}
left
{
type cyclic;
value nonuniform List<scalar>
20
(
-3.87467e-05
-3.62462e-05
-3.37457e-05
-3.12454e-05
-2.87451e-05
-2.6245e-05
-2.3745e-05
-2.12451e-05
-1.87454e-05
-1.62457e-05
-1.37462e-05
-1.12467e-05
-8.74737e-06
-6.24807e-06
-3.74883e-06
-1.2496e-06
-4.12474e-05
-4.37481e-05
-4.62488e-05
-4.87496e-05
)
;
}
right
{
type cyclic;
value nonuniform List<scalar>
20
(
3.87467e-05
3.62462e-05
3.37457e-05
3.12454e-05
2.87451e-05
2.6245e-05
2.3745e-05
2.12451e-05
1.87454e-05
1.62457e-05
1.37462e-05
1.12467e-05
8.74737e-06
6.24807e-06
3.74883e-06
1.2496e-06
4.12474e-05
4.37481e-05
4.62488e-05
4.87496e-05
)
;
}
frontAndBack
{
type empty;
value nonuniform List<scalar> 0();
}
}
// ************************************************************************* //
| [
"tbindas@pop-os.localdomain"
] | tbindas@pop-os.localdomain | |
d4cfada645878e76519e29d749c739d58ceab434 | ba5484b2ca02477a50e503a19f3eb34276e6b377 | /Projet_modeling/meshquad.cpp | b1ca3e80ca07b67469326c155ca8874b87d5e72f | [] | no_license | mammadov7/-Maillages-Quadrangulaires-et-extrusion. | 968d1e1cbab488fae91050fd5df9b0ec420c928d | fcaee1715a891dcd3b73a709fc6a62c8552b8302 | refs/heads/master | 2022-04-23T13:01:57.041029 | 2020-04-16T22:36:30 | 2020-04-16T22:36:30 | 256,345,026 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,742 | cpp | #include "meshquad.h"
#include "matrices.h"
#include <map>
void MeshQuad::clear()
{
m_points.clear();
m_quad_indices.clear();
// initialisation de nombre des edges
m_nb_ind_edges = 0;
}
int MeshQuad::add_vertex(const Vec3& P)
{
// ajouter P à m_points
m_points.push_back(P);
// renvoyer l'indice du point
return m_points.size()-1;
}
void MeshQuad::add_quad(int i1, int i2, int i3, int i4)
{
m_quad_indices.push_back(i1);
m_quad_indices.push_back(i2);
m_quad_indices.push_back(i3);
m_quad_indices.push_back(i4);
}
void MeshQuad::convert_quads_to_tris(const std::vector<int>& quads, std::vector<int>& tris)
{
int quads_size = quads.size();
tris.clear();
tris.reserve(3*quads_size/2);
// Pour chaque quad on genere 2 triangles
// Attention a repecter l'orientation des triangles
/* quad tris1 tris2
1* 2* 1* 2* 1*
-> +
4* 3* 3* 4* 3*
*/
for( int i = 0; i < quads_size; i += 4 ){
tris.push_back(quads[i]);
tris.push_back(quads[i+1]);
tris.push_back(quads[i+2]);
tris.push_back(quads[i]);
tris.push_back(quads[i+2]);
tris.push_back(quads[i+3]);
}
}
void MeshQuad::convert_quads_to_edges(const std::vector<int>& quads, std::vector<int>& edges)
{
int quads_size = quads.size();
edges.clear();
edges.reserve(quads_size); // ( *2 /2 !)
// Pour chaque quad on genere 4 aretes, 1 arete = 2 indices.
// Mais chaque arete est commune a 2 quads voisins !
// Comment n'avoir qu'une seule fois chaque arete ?
// two dimensional key
std::map<int, std::map<int, int> > m;
for (int i = 0; i < quads_size; i += 4){
// first line
if ( m[quads[i+1]][quads[i]] != 1 )
m[quads[i]][quads[i+1]] = 1;
if ( m[quads[i+2]][quads[i+1]] != 1)
m[quads[i+1]][quads[i+2]] = 1;
if ( m[quads[i+3]][quads[i+2]] != 1)
m[quads[i+2]][quads[i+3]] = 1;
if ( m[quads[i]][quads[i+3]] != 1 )
m[quads[i+3]][quads[i]] = 1;
} //end for
// for accessing outer map
std::map<int, std::map<int, int> >::iterator itr;
// for accessing inner map
std::map<int, int>::iterator ptr;
for (itr = m.begin(); itr != m.end(); itr++) {
for (ptr = itr->second.begin(); ptr != itr->second.end(); ptr++) {
if( ptr->second == 1 ){
edges.push_back(itr->first);
edges.push_back(ptr->first);
} // fin if
} // fin for
}// fin for
}
float MeshQuad::dist( const Vec3& A, const Vec3& B ){
return sqrtf((A.x - B.x)*(A.x - B.x) + (A.y - B.y)*(A.y - B.y) + (A.z - B.z)*(A.z - B.z));
}
void MeshQuad::bounding_sphere(Vec3& C, float& R)
{
int m_points_size = m_points.size();
int max_dist = 0;
int indice_max1, indice_max2;
for (int i = 0; i < m_points_size; i++ ){
for (int j = i+1; j < m_points_size; j++ ){
if ( dist( m_points[i], m_points[j] ) > max_dist ){
indice_max1 = i;
indice_max2 = j;
max_dist = dist( m_points[i], m_points[j] );
}
}
}
/* C = ( A + B) / 2 */
C = vec_sum(m_points[indice_max1],m_points[indice_max2]);
C = vec_div( C, 2 );
R = dist( m_points[indice_max1], m_points[indice_max2] ) / 2;
}
void MeshQuad::create_cube()
{
clear();
int s[8]; //sommets
// ajouter 8 sommets (-1 +1)
s[0] = add_vertex(Vec3(-1,-1,-1));
s[1] = add_vertex(Vec3(-1,1,-1));
s[2] = add_vertex(Vec3(1,1,-1));
s[3] = add_vertex(Vec3(1,-1,-1));
s[4] = add_vertex(Vec3(1,-1,1));
s[5] = add_vertex(Vec3(-1,-1,1));
s[6] = add_vertex(Vec3(-1,1,1));
s[7] = add_vertex(Vec3(1,1,1));
// ajouter 6 faces (sens trigo)
add_quad(s[0],s[3],s[4],s[5]);
add_quad(s[5],s[6],s[1],s[0]);
add_quad(s[4],s[7],s[6],s[5]);
add_quad(s[3],s[2],s[7],s[4]);
add_quad(s[0],s[1],s[2],s[3]);
add_quad(s[1],s[6],s[7],s[2]);
gl_update();
}
Vec3 MeshQuad::normal_of(const Vec3& A, const Vec3& B, const Vec3& C)
{
// Attention a l'ordre des points !
// le produit vectoriel n'est pas commutatif U ^ V = - V ^ U
// ne pas oublier de normaliser le resultat.
Vec3 AB = vec_sub(A,B);
Vec3 AC = vec_sub(A,C);
return vec_normalize( vec_cross(AB, AC) );
}
float MeshQuad::aire_tris( const Vec3& A, const Vec3& B, const Vec3& C ){
// Aire = || AB ^ AC || / 2
Vec3 AB = vec_sub(A,B);
Vec3 AC = vec_sub(A,C);
return vec_length( vec_cross(AB,AC) ) / 2;
}
float MeshQuad::aire_quad( const Vec3& A, const Vec3& B, const Vec3& C, const Vec3& D ){
// Dans un quad concave on peut obtenir de reponses different.
// Cela depends de ordre des points.
// C'est pourquoi on a besoine de verifier 2 cas et prendre le minimum
// Dans tout le quad convex on va toujours obtenir la meme resultat
float Aire1 = aire_tris(A,C,D) + aire_tris(A,B,C);
float Aire2 = aire_tris(B,C,D) + aire_tris(B,A,D);
if ( Aire1 <= Aire2 )
return Aire1;
else
return Aire2;
}
float MeshQuad::angle( const Vec3& A, const Vec3& B, const Vec3& C ){
Vec3 BA = vec_sub(B,A);
Vec3 BC = vec_sub(B,C);
return acosf( vec_dot(BA,BC) / vec_length(BA) / vec_length(BC));
}
bool MeshQuad::is_points_in_quad(const Vec3& P, const Vec3& A, const Vec3& B, const Vec3& C, const Vec3& D)
{
/*
A * Si le point P est dans le quad, la somme des angles
/ \ doit être 360 degrée:
/ \ angle{APB} + angle{BPC} + angle{CPD} + angle{DPA} = 360
/ *P \
/ \
/ * C \
D * * B
*/
// Deuxime methode: avec les aires
// float sum_aires = aire_tris(A,P,B) + aire_tris(B,P,C) + aire_tris(C,P,D) + aire_tris(D,P,A);
// float air_quad = aire_quad(A,B,C,D);
// if( abs( sum_aires - aire_quad ) < 0.000001f )
float sum_angles = angle(A,P,B) + angle(B,P,C) + angle(C,P,D) + angle(D,P,A);
if( abs( sum_angles - 2*M_PI) <= 0.000001f ){ //approximation
return true;
}
else
return false;
}
bool MeshQuad::intersect_ray_quad(const Vec3& P, const Vec3& Dir, int q, Vec3& inter)
{
/* recuperation des indices de points
recuperation des points
q: 0 , 1 , 2 , ...
indices: 0 .. 3, 4 .. 7, 8 .. 11, ...
*/
Vec3 P1 = m_points[ m_quad_indices[ q * 4 ] ];
Vec3 P2 = m_points[ m_quad_indices[ q * 4 + 1 ] ];
Vec3 P3 = m_points[ m_quad_indices[ q * 4 + 2 ] ];
Vec3 P4 = m_points[ m_quad_indices[ q * 4 + 3 ] ];
// calcul de l'equation du plan (N+d)
// n⃗ =P1P2×P1P4; d = -n⃗ . P1
Vec3 normal = normal_of( P1,P2,P4 );
float d = vec_dot(normal,P1);
// calcul de l'intersection rayon plan
// alpha => calcul de I
float alpha = ( d - vec_dot(P,normal)) / ( vec_dot( Dir,normal) );
// I = P + alpha*Dir est dans le plan => calcul de alpha
if ( alpha > 0 && alpha < 1 )
inter = vec_sum( P, vec_mul( Dir, alpha) );
else return false;
// I dans le quad ?
return is_points_in_quad(inter,P1,P2,P3,P4);
}
int MeshQuad::intersected_closest(const Vec3& P, const Vec3& Dir)
{
int inter = -1; // indice de quad plus proche
Vec3 I; // vecteur d'Intersection
int m_nb_quads = m_quad_indices.size()/4;
// on parcours tous les quads
int i = 0;
float dist_min=0; // distance minimal
// distence jusqu'a premier quad
for ( ; i < m_nb_quads; i++ ){
// on teste si il y a intersection avec le rayon
if( intersect_ray_quad( P, Dir, i, I )){
dist_min = dist(P,I);
inter = i;
break;
}
}
//distance plus petite
for ( ; i < m_nb_quads; i++ ){
// on teste si il y a intersection avec le rayon
if( intersect_ray_quad( P, Dir, i, I )){
// on garde le plus proche (de P)
if ( dist_min > dist( P, I ) ){
dist_min = dist(P,I);
inter = i;
}
}
} // fin for
return inter;
}
Mat4 MeshQuad::local_frame(int q)
{
// Repere locale = Matrice de transfo avec
// les trois premieres colones: X,Y,Z locaux
// la derniere colonne l'origine du repere
// ici Z = N et X = AB
// Origine le centre de la face
// longueur des axes : [AB]/2
// recuperation des indices de points
// recuperation des points
Vec3 A = m_points[ m_quad_indices[ q * 4 ] ];
Vec3 B = m_points[ m_quad_indices[ q * 4 + 1 ] ];
Vec3 C = m_points[ m_quad_indices[ q * 4 + 2 ] ];
Vec3 D = m_points[ m_quad_indices[ q * 4 + 3 ] ];
// calcul de Z:N / X:AB -> Y
Vec3 X = vec_normalize( vec_sub(A,B) );
Vec3 Z = normal_of( A,B,C );
Vec3 Y = vec_normalize( vec_cross(X, Z) );
// calcul du centre = (A + B + C + D) / 4
Vec3 centre = vec_div( vec_sum( vec_sum(A,B), vec_sum(C,D) ), 4.0 );
// calcul de la taille
float t = vec_length( vec_sub(A,B)) / 2;
// calcul de la matrice
Vec4 c1 ( X.x, X.y, X.z, 0);
Vec4 c2 ( Y.x, Y.y, Y.z, 0);
Vec4 c3 ( Z.x, Z.y, Z.z, 0);
Vec4 c4 ( centre.x, centre.y, centre.z, 1);
return Mat4(c1,c2,c3,c4)*scale(t) ;
}
void MeshQuad::extrude_quad(int q)
{
// recuperation des indices de points
int i_A = m_quad_indices[ q * 4 ];
int i_B = m_quad_indices[ q * 4 + 1 ];
int i_C = m_quad_indices[ q * 4 + 2 ];
int i_D = m_quad_indices[ q * 4 + 3 ];
// recuperation des points
Vec3 A = m_points[i_A];
Vec3 B = m_points[i_B];
Vec3 C = m_points[i_C];
Vec3 D = m_points[i_D];
// calcul de la normale
Vec3 normal = normal_of( A,B,D );
// calcul de la hauteur = racine carre de aire de quad ABCD( = )
float t = sqrtf( aire_quad(A,B,C,D));
// calcul et ajout des 4 nouveaux points
int i_A1 = add_vertex( vec_sum( A, vec_mul(normal,t) ) );
int i_B1 = add_vertex( vec_sum( B, vec_mul(normal,t) ) );
int i_C1 = add_vertex( vec_sum( C, vec_mul(normal,t) ) );
int i_D1 = add_vertex( vec_sum( D, vec_mul(normal,t) ) );
// on remplace le quad initial par le quad du dessu
m_quad_indices[ q * 4 ] = i_A1;
m_quad_indices[ q * 4 + 1 ] = i_B1;
m_quad_indices[ q * 4 + 2 ] = i_C1;
m_quad_indices[ q * 4 + 3 ] = i_D1;
// on ajoute les 4 quads des cotes
add_quad(i_B, i_C, i_C1, i_B1);
add_quad(i_D, i_D1, i_C1, i_C);
add_quad(i_A, i_A1, i_D1, i_D);
add_quad(i_B, i_B1, i_A1, i_A);
gl_update();
}
void MeshQuad::transfo_quad(int q, const glm::mat4& tr)
{
// recuperation des indices de points
// recuperation des (references de) points
Vec3& A = m_points[ m_quad_indices[ q * 4 ] ];
Vec3& B = m_points[ m_quad_indices[ q * 4 + 1 ] ];
Vec3& C = m_points[ m_quad_indices[ q * 4 + 2 ] ];
Vec3& D = m_points[ m_quad_indices[ q * 4 + 3 ] ];
// generation de la matrice de transfo globale:
// indice utilisation de glm::inverse() et de local_frame
Mat4 loc = local_frame(q);
glm::mat4 global = loc * tr * glm::inverse(loc) ;
// Application au 4 points du quad
Vec4 A4 (A, 1); A4 = global * A4;
Vec4 B4 (B, 1); B4 = global * B4;
Vec4 C4 (C, 1); C4 = global * C4;
Vec4 D4 (D, 1); D4 = global * D4;
A = Vec3(A4.x , A4.y , A4.z );
B = Vec3(B4.x , B4.y , B4.z );
C = Vec3(C4.x , C4.y , C4.z );
D = Vec3(D4.x , D4.y , D4.z );
}
void MeshQuad::decale_quad(int q, float d)
{
transfo_quad(q, translate(0,0,d));
gl_update();
}
void MeshQuad::shrink_quad(int q, float s)
{
transfo_quad(q, scale( 1/s ));
gl_update();
}
void MeshQuad::tourne_quad(int q, float a)
{
transfo_quad(q, rotateZ(a));
gl_update();
}
MeshQuad::MeshQuad():
m_nb_ind_edges(0)
{}
void MeshQuad::gl_init()
{
m_shader_flat = new ShaderProgramFlat();
m_shader_color = new ShaderProgramColor();
//VBO
glGenBuffers(1, &m_vbo);
//VAO
glGenVertexArrays(1, &m_vao);
glBindVertexArray(m_vao);
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
glEnableVertexAttribArray(m_shader_flat->idOfVertexAttribute);
glVertexAttribPointer(m_shader_flat->idOfVertexAttribute, 3, GL_FLOAT, GL_FALSE, 0, 0);
glBindVertexArray(0);
glGenVertexArrays(1, &m_vao2);
glBindVertexArray(m_vao2);
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
glEnableVertexAttribArray(m_shader_color->idOfVertexAttribute);
glVertexAttribPointer(m_shader_color->idOfVertexAttribute, 3, GL_FLOAT, GL_FALSE, 0, 0);
glBindVertexArray(0);
//EBO indices
glGenBuffers(1, &m_ebo);
glGenBuffers(1, &m_ebo2);
}
void MeshQuad::gl_update()
{
//VBO
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
glBufferData(GL_ARRAY_BUFFER, 3 * m_points.size() * sizeof(GLfloat), &(m_points[0][0]), GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
std::vector<int> tri_indices;
convert_quads_to_tris(m_quad_indices,tri_indices);
//EBO indices
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ebo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER,tri_indices.size() * sizeof(int), &(tri_indices[0]), GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
std::vector<int> edge_indices;
convert_quads_to_edges(m_quad_indices,edge_indices);
m_nb_ind_edges = edge_indices.size();
// printf("\n\nEdges: %d\n\n",m_nb_ind_edges);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ebo2);
glBufferData(GL_ELEMENT_ARRAY_BUFFER,m_nb_ind_edges * sizeof(int), &(edge_indices[0]), GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
void MeshQuad::set_matrices(const Mat4& view, const Mat4& projection)
{
viewMatrix = view;
projectionMatrix = projection;
}
void MeshQuad::draw(const Vec3& color)
{
glEnable(GL_CULL_FACE);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1.0f, 1.0f);
m_shader_flat->startUseProgram();
m_shader_flat->sendViewMatrix(viewMatrix);
m_shader_flat->sendProjectionMatrix(projectionMatrix);
glUniform3fv(m_shader_flat->idOfColorUniform, 1, glm::value_ptr(color));
glBindVertexArray(m_vao);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,m_ebo);
glDrawElements(GL_TRIANGLES, 3*m_quad_indices.size()/2,GL_UNSIGNED_INT,0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0);
glBindVertexArray(0);
m_shader_flat->stopUseProgram();
glDisable(GL_POLYGON_OFFSET_FILL);
m_shader_color->startUseProgram();
m_shader_color->sendViewMatrix(viewMatrix);
m_shader_color->sendProjectionMatrix(projectionMatrix);
glUniform3f(m_shader_color->idOfColorUniform, 0.0f,0.0f,0.0f);
glBindVertexArray(m_vao2);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,m_ebo2);
glDrawElements(GL_LINES, m_nb_ind_edges,GL_UNSIGNED_INT,0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0);
glBindVertexArray(0);
m_shader_color->stopUseProgram();
glDisable(GL_CULL_FACE);
}
| [
"a.mammadov1999@gmail.com"
] | a.mammadov1999@gmail.com |
267bcae6e3ba01a3a60d8618efdd08127b2d8757 | da9c4798a6e30152382eb1ba876718b51b9bd4f2 | /nowcoder/newcoder-4048/main.cpp | 6a0c0142c486ffab2c66de4c41b7076e2aa23e59 | [] | no_license | zivyou/labofziv | cb2b51f48b3315a8f408eafa940fdc04e1797bfa | e0319d6bc1bbb417f49275bdd07c28019e4b4089 | refs/heads/master | 2023-08-17T03:10:05.615780 | 2023-08-07T06:42:05 | 2023-08-07T06:42:05 | 6,417,825 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 480 | cpp | #include <iostream>
using namespace std;
int main() {
unsigned int a, b, d;
cin >> a >> b>>d;
unsigned int raw_value = a+b;
int re = 0;
unsigned int c = d;
while (raw_value / c){
c = c * d;
}
c = c/d;
int i = 0;
char str[101]={0};
while (c>=d){
str[i++] = char(raw_value/c + '0');
raw_value = raw_value % c;
c = c/d;
}
str[i] = char(re*10+raw_value + '0');
cout<<str<<endl;
return 0;
} | [
"yzq529@qq.com"
] | yzq529@qq.com |
1fc5d736dc1fd0b542fc54693b999ae212ed7f7d | ac7ad5e2fa30d30fc263e09fe3d93d27c670678a | /find_odd_occurring.cpp | 4fe1b3661cc1d831c1e894b437f2ec4ceee2ac9b | [] | no_license | aditikger/feature-arrays | b0148b25d64a07f056cffbfc7df2b54428109b82 | 580a8fbf93bb55d9c069425b31ad65a948d09494 | refs/heads/master | 2021-09-08T00:06:47.728785 | 2018-03-03T19:17:16 | 2018-03-03T19:17:16 | 120,056,000 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 352 | cpp | #include <iostream>
using namespace std;
int findOdd(int arr[], int n)
{
int res = 0, i = 0;
for (i = 0; i < n; i++)
{
res ^= arr[i];
}
return res;
}
int main(void)
{
int arr[] = {0, 1, 2, 3, 3, 1, 0};
int n = sizeof(arr)/sizeof(arr[0]);
int odd = findOdd(arr, n);
std::cout << odd << std::endl;
return 0;
} | [
"aditikulkarni@MAK.local"
] | aditikulkarni@MAK.local |
fbed0964742c9c9c420965cf148e3ba79b4fa521 | 8c1294bd1ad36c6e709602c385db0e7dff34e181 | /commande.cpp | ee892dbc168203827a2b89d3459402914ede07ce | [] | no_license | Laurie-S/ITC313-TP2 | eabd19d8815417c01c5cda361dd78821e6a818a0 | e4207130d6dc270dd6da76e2a32c26b8140221d9 | refs/heads/master | 2020-09-30T13:48:23.661422 | 2020-02-01T19:08:41 | 2020-02-01T19:08:41 | 227,300,050 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,072 | cpp | #include <iostream>
#include <string>
#include <vector>
#include "produit.h"
#include "commande.h"
#include "client.h"
commande::commande(client client1, vector<produit> produits) : client1_(client1), produit_(produits){
statusCommande_=false;
}
void commande::addProduit(produit prod1){
produit_.push_back(prod1);
}
client commande::getClient(){
return client1_;
}
void commande::livre(){
statusCommande_=true;
}
bool commande::getStatus(){
return statusCommande_;
}
int commande::tailleProd(){
return produit_.size();
}
produit commande::getProduit(int i){
return produit_.at(i);
}
vector<produit> commande::getPdtCom(){
return produit_;
}
ostream& operator << (ostream &out, commande *com1) {
int n;
client client1 = com1->getClient();
out << " ____________________________________________________________________________" << endl;
out << "| COMMANDE |" << endl;
out << "|----------------------------------------------------------------------------|" << endl;
out << "| Nom du client : " << client1.getNom();
n=59-(client1.getNom()).size();
for (int i =0; i<n; i++){
out << " ";
}
out << "|" << endl;
out << "|----------------------------------------------------------------------------| " << endl;
for(int i=0;i<com1->tailleProd();i++){
produit prod1=com1->getProduit(i);
out << &prod1;
}
bool statut = com1->getStatus();
if (statut==false){
out << "|----------------------------------------------------------------------------| " << endl;
out << "| En cours de livraison |" << endl;
}
else{
out << "|----------------------------------------------------------------------------| " << endl;
out << "| Livré |" << endl;
}
out << "|____________________________________________________________________________|" << endl;
out << endl << endl;
return out;
} | [
"laurie.sorel@orange.fr"
] | laurie.sorel@orange.fr |
edb207e27639f72357cce83a56cb08c68e049919 | 7eec256284530e38e2e3b34cfb003fb27d592ccd | /BDOI16B - Beautiful Factorial Game.cpp | b92aa19407adb44e0ce547b7770af2d069933423 | [] | no_license | rudyjayk/SPOJ | 88c6c1c504c0570305737b14249c2e39dc61cb39 | dd961a5efff3c30fbb03dea957e03674f4dea255 | refs/heads/master | 2022-03-04T03:36:39.429095 | 2019-10-28T09:14:42 | 2019-10-28T09:14:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,022 | cpp | #include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll n,k,tc,cs=1;
cin>>tc;
while(tc--){
cin>>n>>k;
ll ans = 1LL<<62;
ll sq = sqrt(k);
for(ll a=2; (a*a)<=k; a++){
if(k%a == 0){
ll b = 0;
while(k%a==0){
b++;
k/=a;
}
ll sum=0, po = a;
while(1){
ll add = n/po;
if(add==0) break;
sum+=add;
po*=a;
}
ans = min(ans,sum/b);
}
}
if(k>1){
ll sum=0, po = k;
while(1){
ll add = n/po;
if(add==0) break;
sum+=add;
po*=k;
}
ans = min(ans,sum);
}
cout<<"Case "<<cs++<<": ";
cout<<ans<<endl;
}
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
b6e60367974401afff578c697378219659326dfa | 04b1803adb6653ecb7cb827c4f4aa616afacf629 | /android_webview/browser/aw_browser_terminator.h | e75bf76adee7ca50278675e3931a84c83c9ecd8e | [
"BSD-3-Clause"
] | permissive | Samsung/Castanets | 240d9338e097b75b3f669604315b06f7cf129d64 | 4896f732fc747dfdcfcbac3d442f2d2d42df264a | refs/heads/castanets_76_dev | 2023-08-31T09:01:04.744346 | 2021-07-30T04:56:25 | 2021-08-11T05:45:21 | 125,484,161 | 58 | 49 | BSD-3-Clause | 2022-10-16T19:31:26 | 2018-03-16T08:07:37 | null | UTF-8 | C++ | false | false | 1,067 | h | // Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ANDROID_WEBVIEW_BROWSER_AW_BROWSER_TERMINATOR_H_
#define ANDROID_WEBVIEW_BROWSER_AW_BROWSER_TERMINATOR_H_
#include <map>
#include "base/macros.h"
#include "components/crash/content/browser/child_exit_observer_android.h"
namespace android_webview {
// This class manages the browser's behavior in response to renderer exits. If
// the application does not successfully handle a renderer crash/kill, the
// browser needs to crash itself.
class AwBrowserTerminator : public crash_reporter::ChildExitObserver::Client {
public:
AwBrowserTerminator();
~AwBrowserTerminator() override;
// crash_reporter::ChildExitObserver::Client
void OnChildExit(
const crash_reporter::ChildExitObserver::TerminationInfo& info) override;
private:
DISALLOW_COPY_AND_ASSIGN(AwBrowserTerminator);
};
} // namespace android_webview
#endif // ANDROID_WEBVIEW_BROWSER_AW_BROWSER_TERMINATOR_H_
| [
"sunny.nam@samsung.com"
] | sunny.nam@samsung.com |
11189d422aaeb3a6723d0497140a0b8dbc83dc3c | a465e841d908d55fc4acd835769fc6b1c80f83af | /SNAKEX/slowfood.cpp | 3fba0ebf7e2ab9061758b1906d0dd35b2b47ce6f | [] | no_license | edwardraymondhe/SnakeGame_Qt | a4f7c197b09bc2ac048e687adbb32cf2ff2d883f | aae0aa7b03344eb0be44fb9a8fe9ade25a5ecc51 | refs/heads/master | 2022-12-03T12:58:27.127534 | 2020-08-22T15:47:17 | 2020-08-22T15:47:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 420 | cpp | #include "slowfood.h"
#include "constants.h"
slowFood::slowFood(qreal x, qreal y, int type){
this->setType(type);
setPos(x, y);
setData(DATA, FOOD);
};
void slowFood::paint(QPainter *painter,
const QStyleOptionGraphicsItem *,
QWidget *)
{
painter->save();
painter->setRenderHint(QPainter::Antialiasing);
painter->fillPath(shape(), Qt::green);
painter->restore();
}
| [
"edward.raymond.he@hotmail.com"
] | edward.raymond.he@hotmail.com |
1bf6c55d9457cf0524bb3f2ecd5b549d5db6ab32 | 5a57809e146bce3a287d951ce07aad2f568a6eb6 | /include/trajectory.hpp | 44fe9ed3a0f8c97af3594cd956ae36b417056554 | [] | no_license | grammers/event_camer_depth_map | 1b3d4d79da4f35673f8a3e79b5112703ca7aab1f | 04754bd2b3280bf66ce32560dffb38a897491952 | refs/heads/main | 2023-01-30T07:36:45.598761 | 2020-12-10T18:27:37 | 2020-12-10T18:27:37 | 303,623,093 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,750 | hpp | #pragma once
#include <map>
#include <ros/time.h>
#include <geometry_utils.hpp>
template<class DerivedTrajectory>
class Trajectory
{
public:
typedef std::map<ros::Time, geometry_utils::Transformation> PoseMap;
DerivedTrajectory& derived()
{ return static_cast<DerivedTrajectory&>(*this); }
Trajectory() {}
Trajectory(const PoseMap& poses)
: poses_(poses)
{}
// Returns T_W_C (mapping points from C to the world frame W)
bool getPoseAt(const ros::Time& t, geometry_utils::Transformation& T) const
{
return derived().getPoseAt(t, T);
}
void getFirstControlPose(geometry_utils::Transformation* T, ros::Time* t) const
{
*t = poses_.begin()->first;
*T = poses_.begin()->second;
}
void getLastControlPose(geometry_utils::Transformation* T, ros::Time* t) const
{
*t = poses_.rbegin()->first;
*T = poses_.rbegin()->second;
}
size_t getNumControlPoses() const
{
return poses_.size();
}
bool print() const
{
size_t control_pose_idx = 0u;
for(auto it : poses_)
{
VLOG(1) << "--Control pose #" << control_pose_idx++ << ". time = " << it.first;
VLOG(1) << "--T = ";
VLOG(1) << it.second;
}
return true;
}
protected:
PoseMap poses_;
};
class LinearTrajectory : public Trajectory<LinearTrajectory>
{
public:
LinearTrajectory() : Trajectory() {}
LinearTrajectory(const PoseMap& poses)
: Trajectory(poses)
{
CHECK_GE(poses_.size(), 2u) << "At least two poses need to be provided";
}
bool getPoseAt(const ros::Time& t, geometry_utils::Transformation& T) const
{
ros::Time t0_, t1_;
geometry_utils::Transformation T0_, T1_;
// Check if it is between two known poses
auto it1 = poses_.upper_bound(t);
if(it1 == poses_.begin())
{
LOG_FIRST_N(WARNING, 5) << "Cannot extrapolate in the past. Requested pose: "
<< t << " but the earliest pose available is at time: "
<< poses_.begin()->first;
return false;
}
else if(it1 == poses_.end())
{
LOG_FIRST_N(WARNING, 5) << "Cannot extrapolate in the future. Requested pose: "
<< t << " but the latest pose available is at time: "
<< (poses_.rbegin())->first;
return false;
}
else
{
auto it0 = std::prev(it1);
t0_ = (it0)->first;
T0_ = (it0)->second;
t1_ = (it1)->first;
T1_ = (it1)->second;
}
// Linear interpolation in SE(3)
auto T_relative = T0_.inverse() * T1_;
auto delta_t = (t - t0_).toSec() / (t1_ - t0_).toSec();
T = T0_ * geometry_utils::Transformation::exp(delta_t * T_relative.log());
return true;
}
};
| [
"samuel.karsson@ltu.se"
] | samuel.karsson@ltu.se |
d752ca7de67ea1d06234b07f3c860c763bbbbe28 | fcbf2a2b1c99bcc47bb010fefd83f040bde6305d | /src/Bar.h | b7e3a97c37621055a01156d4046ea0ea1cc6f63b | [] | no_license | inFamousxD/sorting-sfml-cpp | 47cf3a490d94a9fdfa78bf77723b97d029b023be | 1b518c5e73943c4ffb5a89fa5f5a64d85022bd62 | refs/heads/master | 2023-08-20T00:58:54.340854 | 2021-10-13T11:33:03 | 2021-10-13T11:33:03 | 416,053,802 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 337 | h | #include "Platform/Platform.hpp"
class Bar
{
public:
Bar();
Bar(int height);
Bar(int height, int width, int delta_y);
~Bar();
sf::RectangleShape* getRectangleShape();
int getHeight();
void setHeight(int height);
void hightlight(bool trigger);
private:
int height;
int width;
int delta_y;
sf::RectangleShape* rectangle;
}; | [
"audimankar@gmail.com"
] | audimankar@gmail.com |
6dcf6609ef49778cdbb47ea35a8ba590a7153461 | 7d7c322f87ee4ce290f391eed5938cea526bbba8 | /workvs6/smsV3src/CMNSRC/Cmd_spcl.h | 4a29380f0e830a6604333dd305da4e646928821e | [] | no_license | tatsumiking/GitBackup | 8cc380f5ff29ed11118a1e3c9a28493f693f3588 | 74e7810e6449f5d233fde095a1901d6fd48b8ed6 | refs/heads/master | 2023-04-01T09:43:33.361077 | 2021-03-29T00:11:58 | 2021-03-29T00:11:58 | 326,543,058 | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 3,254 | h | #ifndef __CMD_SPCL_H
#define __CMD_SPCL_H
//C 特殊処理(影付けなど)関係コマンド処理クラス
class CCmdSpcl : public CCmdBase
{
public:
CCmdSpcl(CScrollView* pcview);
public:
DBL m_dRoundRag;
DBL m_dDistance;
int m_nKind;
DBL m_dOutLineMM;
int m_nOutLineKind;
DBL m_dBsx, m_dBsy;
DBL m_dBxmm, m_dBymm;
DBL m_dBtime;
DBL m_dCntrX, m_dCntrY;
DBL m_dTrnsTime;
int m_nBMode;
CDataList* m_pcDataList;
CVect* m_pcVect;
int m_nPcnt;
int m_nXSize, m_nYSize;
int m_nXByte;
DBL m_dFureLimit;
long m_lBitsSize;
CDC *m_pMemDC;
HANDLE m_hBits, m_hTBits;
BYTE *m_lpBits, *m_lpTBits;
CBitmap *m_pBitmap, *m_oldBitmap;
LPBYTE m_lpCusTbl;
XYType *m_lpXYTbl1, *m_lpXYTbl2;
char m_szTitle[RECMAX];
private:
DBL m_dRltvTopx, m_dRltvTopy;
public:
void BitmapFileOut();
UINT ExecOutLineOmit(UINT event, DBL dx, DBL dy);
UINT ExecShadow(UINT event, DBL dx, DBL dy);
UINT ExecOutLine(UINT event, DBL dx, DBL dy);
UINT ExecMarge(UINT event, DBL dx, DBL dy);
UINT ExecRuleOutLine(UINT event, DBL dx, DBL dy);
UINT ExecAreaSlct(UINT event, DBL dx, DBL dy);
UINT ExecBezeToArc(UINT event, DBL dx, DBL dy);
int DialogOutLineInit();
void OutLineDataDraw();
void OutLineGetDMiniMax(LPDBL minix, LPDBL miniy, LPDBL maxx, LPDBL maxy);
void OutLineDataTrns();
void OutLineMain();
void RuleOutLineMain();
int DialogShadowInit();
void ShadowGetDMiniMax(LPDBL minix, LPDBL miniy, LPDBL maxx, LPDBL maxy);
void ShadowDataTrns();
void ShadowMain();
void ShadowDataTrns1();
void ShadowProg1();
void ShadowDataTrns2();
void ShadowProg2();
void ShadowDataTrns3();
void ShadowProg3();
void ShadowDataTrns4();
void ShadowProg4();
void AreaSlctTrace(DBL dx, DBL dy);
void BitMapInit();
void BitMapTraceMain();
void MemoryEnd();
void MemoryInit(DBL xytime);
void ActiveObjectCopy();
void DrawAreaEnd();
void DrawAreaInit(DBL minix, DBL miniy, DBL maxx, DBL maxy);
int BitOnOffCheck(BYTE *lpBits, int xbyte, int x, int y);
void BitOnSet(BYTE *lpBits, int xbyte, int x, int y);
void BitOffSet(BYTE *lpBits, int xbyte, int x, int y);
void BmpFileOut(LPSTR fname, BYTE far *lpBits, int xbyte, int xsize, int ysize);
private:
void BitMapOutLineSet(BYTE *lpBits, BYTE *lpTBits, int xbyte, int xsize, int ysize);
void BitMapTrace(BYTE *lpBits, BYTE *lpTBits, int xbyte, int xsize, int ysize);
void BitMapTarceSetPlgn(BYTE *lpBits, BYTE *lpTBits, int scus, int xbyte, int x, int y);
void NextCusGet(BYTE *lpTBits, int xbyte, int *retx, int *rety, int *retcus);
int FirstCusGet(BYTE *lpBits, int scus, int xbyte, int x, int y);
void CusAddGet(int cus, int *addx, int *addy);
int CusLegal(int cus);
void SetDataListPolygon(XYType *lpXYTbl1, XYType *lpXYTbl2, int points);
void SetXYTblSetPlgn(BYTE *lpTBits, int xbyte, int idx, int tsx, int tsy);
void SetPlgnEnd();
void SetPlgnInit();
void PlgnPointSet(XYType *lpXYTbl1, int points, int tx, int ty);
void PlgnLineToArcRejionSet(CVect *pcVect);
int PlgnCurveChk(CVect *pcVect, int pp1, DBL *retx, DBL *rety, int *retpp);
int PlgnCrclDastance(DBL tx, DBL ty, DBL x0, DBL y0, DBL r, DBL flimit);
void BezeToArcMain(CVect *pcVect);
int BezeToArcFigu(DBL x1, DBL y1, DBL x2, DBL y2, DBL x3, DBL y3, DBL x4, DBL y4, CVect *pcVect, int dp);
};
#endif
| [
"tatsumiking@gmail.com"
] | tatsumiking@gmail.com |
f7eb7c980de22e4881bc1af404ed8ec930f10193 | 055e8458a3a23d5bf2a030f0208488da2e1a4f3a | /Compilers/lab-5&6/translate/tree.h | 19a0587eb0dda292a3f0e176e933b12f9dd6f847 | [] | no_license | Tarosweet/Junior | e9248dcf6ee96b4b5032516d41ef34908ee8e466 | 341932236b3e3e6513f4bf100cd7c148c8662b2a | refs/heads/master | 2022-11-12T13:29:07.350326 | 2020-07-05T14:30:38 | 2020-07-05T14:30:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,788 | h | #ifndef TIGER_TRANSLATE_TREE_H_
#define TIGER_TRANSLATE_TREE_H_
#include <cstdio>
#include "tiger/canon/canon.h"
#include "tiger/frame/temp.h"
/* Forward Declarations */
namespace C {
class Block;
class StmListList;
class ExpRefList;
class StmAndExp;
} // namespace C
namespace T {
class Stm;
class Exp;
class NameExp;
class ExpList;
class StmList;
enum BinOp {
PLUS_OP,
MINUS_OP,
MUL_OP,
DIV_OP,
AND_OP,
OR_OP,
LSHIFT_OP,
RSHIFT_OP,
ARSHIFT_OP,
XOR_OP
};
enum RelOp {
EQ_OP,
NE_OP,
LT_OP,
GT_OP,
LE_OP,
GE_OP,
ULT_OP,
ULE_OP,
UGT_OP,
UGE_OP
};
/*
* Statements
*/
class Stm {
public:
enum Kind { SEQ, LABEL, JUMP, CJUMP, MOVE, EXP };
Kind kind;
Stm(Kind kind) : kind(kind) {}
virtual void Print(FILE* out, int d) const = 0;
/*Lab6 only*/
virtual Stm* Canon(Stm*) = 0;
};
class SeqStm : public Stm {
public:
Stm *left, *right;
SeqStm(Stm* left, Stm* right) : Stm(SEQ), left(left), right(right) {
assert(left);
}
void Print(FILE* out, int d) const override;
/*Lab6 only*/
Stm* Canon(Stm*) override;
};
class LabelStm : public Stm {
public:
TEMP::Label* label;
LabelStm(TEMP::Label* label) : Stm(LABEL), label(label) {}
void Print(FILE* out, int d) const override;
/*Lab6 only*/
Stm* Canon(Stm*) override;
};
class JumpStm : public Stm {
public:
NameExp* exp;
TEMP::LabelList* jumps;
JumpStm(NameExp* exp, TEMP::LabelList* jumps)
: Stm(JUMP), exp(exp), jumps(jumps) {}
void Print(FILE* out, int d) const override;
/*Lab6 only*/
Stm* Canon(Stm*) override;
};
class CjumpStm : public Stm {
public:
RelOp op;
Exp *left, *right;
TEMP::Label *true_label, *false_label;
CjumpStm(RelOp op, Exp* left, Exp* right, TEMP::Label* true_label,
TEMP::Label* false_label)
: Stm(CJUMP),
op(op),
left(left),
right(right),
true_label(true_label),
false_label(false_label) {}
void Print(FILE* out, int d) const override;
/*Lab6 only*/
Stm* Canon(Stm*) override;
};
class MoveStm : public Stm {
public:
Exp *dst, *src;
MoveStm(Exp* dst, Exp* src) : Stm(MOVE), dst(dst), src(src) {}
void Print(FILE* out, int d) const override;
/*Lab6 only*/
Stm* Canon(Stm*) override;
};
class ExpStm : public Stm {
public:
Exp* exp;
ExpStm(Exp* exp) : Stm(EXP), exp(exp) {}
void Print(FILE* out, int d) const override;
/*Lab6 only*/
Stm* Canon(Stm*) override;
};
/*
*Expressions
*/
class Exp {
public:
enum Kind { BINOP, MEM, TEMP, ESEQ, NAME, CONST, CALL };
Kind kind;
Exp(Kind kind) : kind(kind) {}
virtual void Print(FILE* out, int d) const = 0;
/*Lab6 only*/
virtual C::StmAndExp Canon(Exp*) = 0;
};
class BinopExp : public Exp {
public:
BinOp op;
Exp *left, *right;
BinopExp(BinOp op, Exp* left, Exp* right)
: Exp(BINOP), op(op), left(left), right(right) {}
void Print(FILE* out, int d) const override;
/*Lab6 only*/
C::StmAndExp Canon(Exp*) override;
};
class MemExp : public Exp {
public:
Exp* exp;
MemExp(Exp* exp) : Exp(MEM), exp(exp) {}
void Print(FILE* out, int d) const override;
/*Lab6 only*/
C::StmAndExp Canon(Exp*) override;
};
class TempExp : public Exp {
public:
TEMP::Temp* temp;
TempExp(TEMP::Temp* temp) : Exp(TEMP), temp(temp) {}
void Print(FILE* out, int d) const override;
/*Lab6 only*/
C::StmAndExp Canon(Exp*) override;
};
class EseqExp : public Exp {
public:
Stm* stm;
Exp* exp;
EseqExp(Stm* stm, Exp* exp) : Exp(ESEQ), stm(stm), exp(exp) {}
void Print(FILE* out, int d) const override;
/*Lab6 only*/
C::StmAndExp Canon(Exp*) override;
};
class NameExp : public Exp {
public:
TEMP::Label* name;
NameExp(TEMP::Label* name) : Exp(NAME), name(name) {}
void Print(FILE* out, int d) const override;
/*Lab6 only*/
C::StmAndExp Canon(Exp*) override;
};
class ConstExp : public Exp {
public:
int consti;
ConstExp(int consti) : Exp(CONST), consti(consti) {}
void Print(FILE* out, int d) const override;
/*Lab6 only*/
C::StmAndExp Canon(Exp*) override;
};
class CallExp : public Exp {
public:
Exp* fun;
ExpList* args;
CallExp(Exp* fun, ExpList* args) : Exp(CALL), fun(fun), args(args) {}
void Print(FILE* out, int d) const override;
/*Lab6 only*/
C::StmAndExp Canon(Exp*) override;
};
class ExpList {
public:
Exp* head;
ExpList* tail;
ExpList(Exp* head, ExpList* tail) : head(head), tail(tail) {}
};
class StmList {
public:
Stm* head;
StmList* tail;
StmList(Stm* head, StmList* tail) : head(head), tail(tail) {}
void Print(FILE* out) const;
};
RelOp notRel(RelOp); /* a op b == not(a notRel(op) b) */
RelOp commute(RelOp); /* a op b == b commute(op) a */
} // namespace T
#endif // TIGER_TRANSLATE_TREE_H_
| [
"Gusabary@126.com"
] | Gusabary@126.com |
8951cd45c7d99b01924fc8000b0340ca717da3a7 | cd13341f077dabc28aac79eaf79ff5fb4622e293 | /include/SL_Socket_INET_Addr.h | 7d94e1d3adbe4ffa6629a5ff1f83cd69d17d9591 | [
"BSD-2-Clause"
] | permissive | cwschmidt/socketlite | 2607eaeb414b8e7fa2bda6355ef2e17bcc2040e7 | dcb8a03de50b95bcfe2ccd24dbc1ce347de21b3b | refs/heads/master | 2016-09-09T21:34:34.832642 | 2014-02-28T07:20:06 | 2014-02-28T07:20:06 | 34,139,112 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,606 | h | #ifndef SOCKETLITE_SOCKET_INET_ADDR_H
#define SOCKETLITE_SOCKET_INET_ADDR_H
#include "SL_Config.h"
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
#pragma once
#endif
class SOCKETLITE_API SL_Socket_INET_Addr
{
public:
SL_Socket_INET_Addr();
SL_Socket_INET_Addr(bool ipv6);
~SL_Socket_INET_Addr();
void reset();
int set(const char *hostname, ushort port, bool is_ipv6 = false);
int set(const struct sockaddr *addr, int addrlen);
int set(SL_SOCKET fd, bool ipv6);
int set(SL_SOCKET fd);
operator sockaddr* ();
sockaddr* get_addr() const;
int get_addr_size() const;
int get_ip_addr(char *ip_addr, int len) const;
ushort get_port_number() const;
bool is_ipv4() const;
bool is_ipv6() const;
static int get_ip_remote_s(SL_SOCKET fd, char *ip_addr, int ip_len, ushort *port_number);
static int get_ip_local_s(SL_SOCKET fd, char *ip_addr, int ip_len, ushort *port_number);
static int get_ip_s(const struct sockaddr *addr, int addrlen, char *ip_addr, int ip_len, ushort *port_number);
static int get_addr_s(const char *hostname, ushort port, sockaddr *addr, int addrlen);
static ulong get_inet_addr_s(const char *ip);
private:
enum
{
IPV4,
IPV6
}addr_type_;
union
{
sockaddr_in in4;
#ifdef SOCKETLITE_HAVE_IPV6
sockaddr_in6 in6;
#endif
}inet_addr_;
};
#endif
| [
"bolidezhang@gmail.com@e833b10f-1046-261c-ddef-a3d947df9845"
] | bolidezhang@gmail.com@e833b10f-1046-261c-ddef-a3d947df9845 |
518287de857135a2fe6f0e61631af60a01eeb835 | 4ac73653e234703a4ae70b7bf76f63b179d7d102 | /src/ArgsParser/ArgsParserLib.h | 237b6b00866b4fc338c6b534900f2c6cd28c7a25 | [] | no_license | TuNguyen89/CPPSelfLearning | d3ca99711f2d4203c7820145e5126e6ad0b4ead6 | df06043bd406b0a16ff09f030061024a4c59a4ac | refs/heads/master | 2021-09-02T00:45:36.115539 | 2017-12-29T13:38:38 | 2017-12-29T13:38:38 | 115,522,532 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,510 | h | /**
* @ingroup Argument Parse Module
* Argument Parse Module
*/
/*! Argument Parse Module
Example Usage:
@code
@endcode
*/
#ifndef ARGSPARSER_H_
#define ARGSPARSER_H_
#include "string"
#include "map"
#include "list"
namespace UTILITY
{
using std::string;
using std::map;
class Args
{
public:
Args();
~Args();
private:
//map<char, ArgumentMarshaler> argPaser;
void parseSchema();
void parseElement();
};
template <class T>
class ArgumentMarshaler
{
public:
virtual void set(string args);
virtual T get();
};
class BoolArgumentMarshaler : public ArgumentMarshaler<bool>
{
public:
BoolArgumentMarshaler();
~BoolArgumentMarshaler();
void set(string args);
bool get();
private:
bool boolValue;
};
class StringArgumentMarshaler : public ArgumentMarshaler < string >
{
public:
StringArgumentMarshaler();
~StringArgumentMarshaler();
void set(string args);
string get();
private:
string stringValue;
};
class IntegerArgumentMarshaler : public ArgumentMarshaler < int >
{
public:
IntegerArgumentMarshaler();
~IntegerArgumentMarshaler();
void set(string args);
int get();
private:
int integerValue;
};
}
#endif | [
"Thanh.Tu.Nguyen-ext@continental-corporation.com"
] | Thanh.Tu.Nguyen-ext@continental-corporation.com |
fb0eb963dedf8c89de3b6a9de4920704f680295a | f9b362cadc1c3f577c71ca3a325b35972ccf0811 | /llvm/lib/Analysis/PyanzinLoopAnalysis.cpp | aa07546c9139a76d747a8b90fc1a7b655148157d | [
"NCSA",
"LLVM-exception",
"Apache-2.0"
] | permissive | askomyagin/llvm-project | 6f42e0b7d20c621dea3c922a6c8aa759e51cff34 | 2c7f23e602d208c32ff3e09bad26d2cfc6efc9ce | refs/heads/main | 2023-04-14T05:05:49.014776 | 2021-04-30T06:58:48 | 2021-04-30T06:58:48 | 344,217,103 | 0 | 0 | null | 2021-03-03T17:59:46 | 2021-03-03T17:59:46 | null | UTF-8 | C++ | false | false | 1,081 | cpp | #include "llvm/Analysis/PyanzinLoopAnalysis.h"
#include <set>
using namespace llvm;
AnalysisKey PyanzinLoopAnalysis::Key;
PyanzinLoopAnalysis::Result PyanzinLoopAnalysis::run(Loop& L, LoopAnalysisManager& LAM, LoopStandardAnalysisResults& LSA)
{
int64_t updates_count = 0;
if (PHINode* indVar = L.getCanonicalInductionVariable()) {
errs() << "canonical ind variable found" << "\n";
// collect all binary operators which update this induction variable
// in ideal vectorizable case it should be a single binary operator which updates loop induction
SmallVector<BinaryOperator*, 16> updates;
for (unsigned int i = 0; i < indVar->getNumIncomingValues(); i++) {
if (auto* binOp = dyn_cast<BinaryOperator>(indVar->getIncomingValue(i)))
{
if (binOp->getOperand(0) == indVar || binOp->getOperand(1) == indVar) {
updates.push_back(binOp);
}
}
}
updates_count = updates.size();
}
Result res = {updates_count};
return res;
}
| [
"aapyanzin@edu.hse.ru"
] | aapyanzin@edu.hse.ru |
78e22abbc064d9d4b4052f7f62b1a5209575fe1f | 270f6259756f29cd26dd75e46682ff0dfa9ddeb8 | /SGTools/src/exceptions.cxx | d1a5dd5b4e7a3367ca5541d40cd4ac30315f9aec | [] | no_license | atlas-control/control | 79066de6c24dc754808d5cecc11e679520957e00 | 8631c6b8edb576caf247c459c34e158c1b531f50 | refs/heads/master | 2016-08-12T03:03:51.372028 | 2016-02-28T22:29:15 | 2016-02-28T22:29:15 | 52,747,234 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,517 | cxx | // $Id$
/**
* @file SGTools/src/exceptions.cxx
* @author scott snyder <snyder@bnl.gov>
* @date Nov, 2013
* @brief Exceptions that can be thrown by SGTools.
*/
#include "SGTools/exceptions.h"
#include "GaudiKernel/System.h"
#include <sstream>
#include <string>
namespace SG {
/// Helper: Format exception string.
std::string excBadDataProxyCast_format (CLID id, const std::type_info& tid)
{
std::ostringstream os;
os << "Bad cast of DataProxy with CLID " << id
<< " to type " << System::typeinfoName (tid);
return os.str();
}
/**
* @brief Constructor.
* @param id CLID of the DataProxy.
* @param tid Type to which we're trying to convert the object.
*/
ExcBadDataProxyCast::ExcBadDataProxyCast (CLID id, const std::type_info& tid)
: m_what (excBadDataProxyCast_format (id, tid))
{
}
/**
* @brief Return the message for this exception.
*/
const char* ExcBadDataProxyCast::what() const throw()
{
return m_what.c_str();
}
/**
* @brief Throw an ExcBadDataProxyCast exception.
* @param id CLID of the DataProxy.
* @param tid Type to which we're trying to convert the object.
*/
void throwExcBadDataProxyCast (CLID id, const std::type_info& tid)
{
throw ExcBadDataProxyCast (id, tid);
}
//*************************************************************************
/// Helper: Format exception string.
std::string excProxyCollision_format (CLID id,
const std::string& key,
CLID primary_id,
const std::string& primary_key)
{
std::ostringstream os;
os << "ExcProxyCollision: proxy collision for clid/key "
<< id << " / " << key
<< " (primary " << primary_id << " / " << primary_key << ").";
return os.str();
}
/**
* @brief Constructor.
* @param id CLID we're trying to set on the dummy proxy.
* @param key Key we're trying to set on the dummy proxy.
* @param primary_id CLID of the existing proxy.
* @param primary_key Key of the existing proxy.
*/
ExcProxyCollision::ExcProxyCollision (CLID id,
const std::string& key,
CLID primary_id,
const std::string& primary_key)
: std::runtime_error (excProxyCollision_format (id,
key,
primary_id,
primary_key))
{
}
} // namespace SG
| [
"dguest@cern.ch"
] | dguest@cern.ch |
d9f4f10c3da73880da4c6c2f308085da959f47ce | af72d789d4ed3337f493e3bbbe8d98b70280b188 | /00000_大恒图像通用检测系统/CheckSystem/DlgHisErrorInfo.h | 922a46e36937e8fb0cbc28ef7e31fe1133c5f507 | [] | no_license | kongxm889/dahengimage | fd3f5f9ebca86b1fcb680a8567a71ce9340f9790 | a3214964b817d83b4674f472476f6ca990c4719e | refs/heads/master | 2021-12-29T20:15:29.576960 | 2018-01-28T07:27:01 | 2018-01-28T07:27:01 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 746 | h | #pragma once
#include "afxwin.h"
#include "afxcmn.h"
// CDlgHisErrorInfo 对话框
class CDlgHisErrorInfo : public CDialogEx
{
DECLARE_DYNAMIC(CDlgHisErrorInfo)
public:
CDlgHisErrorInfo(CWnd* pParent = NULL); // 标准构造函数
virtual ~CDlgHisErrorInfo();
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_DIALOG_HisErrorInfo };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
int m_iIndexOfCheckGroupSelected{ 0 };
CComboBox m_comboCheckGroup;
CListCtrl m_listctrlDefectStatistics;
virtual BOOL OnInitDialog();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
bool UpdateDefectList();
afx_msg void OnCbnSelchangeComboCheckgourp();
};
| [
"270523124@qq,com"
] | 270523124@qq,com |
668d4d2b472be1db61745c78871b79b2809dd4eb | d2e9282e38dafc4bcff95e330eead9802ba877f1 | /WareHouseManageSystem/warehousemanage/inventorytransfer/addtranmaterial/addtranmaterial.cpp | 9b8024685c1e65bc2c8d4ed55669e14357cb7e50 | [] | no_license | YYC572652645/WareHouseManage | 9baa6c14145b84c9faa483efb19de4a8241369d0 | cd170c80ced5812b0113e31f6b4917d27dc249be | refs/heads/master | 2020-03-13T11:14:30.049664 | 2018-04-26T04:39:09 | 2018-04-26T04:39:09 | 131,097,891 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,550 | cpp | #include "addtranmaterial.h"
#include "ui_addtranmaterial.h"
#include "httpclient/httpkey.h"
/********************* 构造函数 *********************/
AddTranMaterial::AddTranMaterial(QWidget *parent) :
QWidget(parent),
ui(new Ui::addtranmaterial)
,titleBar(NULL)
,widgetType(0)
{
ui->setupUi(this);
this->initControl();
}
/********************* 析构函数 *********************/
AddTranMaterial::~AddTranMaterial()
{
delete ui;
SAFEDELETE(titleBar);
}
/********************* 显示窗口 *********************/
void AddTranMaterial::showWidget(int type)
{
if(type == EDITTYPE)
{
titleBar->setTitle(GLOBALDEF::EDITSTOMATERIAL);
ui->checkBoxAllSelect->setHidden(true);
ui->pushButtonDel->show();
ui->tableWidgetEditData->show();
ui->tableWidgetData->setHidden(true);
}
else
{
titleBar->setTitle(GLOBALDEF::ADDMATERIALNAME);
ui->tableWidgetEditData->setHidden(true);
ui->tableWidgetData->show();
ui->checkBoxAllSelect->show();
ui->pushButtonDel->setHidden(true);
}
ui->checkBoxAllSelect->setChecked(false);
ui->checkBoxAllSelect->setText(tr("全选"));
ui->checkBoxAllSelect->setIcon(QIcon(GLOBALDEF::ALLSELECTIMAGE));
widgetType = type;
this->show();
}
/********************* 初始化控件 *********************/
void AddTranMaterial::initControl()
{
titleBar = new TitleBar(this);
titleBar->setIcon(GLOBALDEF::APPLOGO);
titleBar->subButton(TITLEBAR::MAXMINWIDGET);
this->setWindowFlags(Qt::CoverWindow | Qt::FramelessWindowHint);
SETTABLEWIDGET(ui->tableWidgetData);
SETTABLEWIDGET(ui->tableWidgetEditData);
}
/********************* 改变事件 *********************/
void AddTranMaterial::resizeEvent(QResizeEvent *event)
{
titleBar->resize(this->width(), titleBar->getTitleBarHeight());
}
/********************* 获取原料数据 *********************/
MapList AddTranMaterial::getMapMatList() const
{
return mapMatList;
}
/********************* 设置数据列表 *********************/
void AddTranMaterial::setMapMatList(const MapList &value)
{
mapMatList = value;
for(int i = 0; i < spinBoxList.size(); i ++)
{
SAFEDELETE(spinBoxList[i]);
}
spinBoxList.clear();
ui->tableWidgetData->clearContents();
ui->tableWidgetData->setRowCount(mapMatList.size());
for(int i = 0; i < mapMatList.size(); i ++)
{
ui->tableWidgetData->setItem(i, ZERO, DATA(mapMatList.at(i).value(HTTPKEY::NAME)));
ui->tableWidgetData->setItem(i, ONE, DATA(mapMatList.at(i).value(HTTPKEY::BARCODE)));
ui->tableWidgetData->item(i, 0)->setCheckState(Qt::Unchecked);
ui->tableWidgetData->setItem(i, TWO, DATA(mapMatList.at(i).value(HTTPKEY::COSTPRICE)));
{
QWidget * widget = new QWidget(this);
QHBoxLayout *hBoxLayout = new QHBoxLayout(widget);
QDoubleSpinBox *spinBox = new QDoubleSpinBox(this);
hBoxLayout->addWidget(spinBox);
widget->setLayout(hBoxLayout);
spinBox->setValue(ONE);
hBoxLayout->setMargin(0);
spinBox->setFixedSize(ui->tableWidgetData->columnWidth(THREE), ui->tableWidgetData->rowHeight(ZERO));
spinBox->setFocusPolicy(Qt::NoFocus);
ui->tableWidgetData->setCellWidget(i, THREE, widget);
spinBoxList.append(spinBox);
}
ui->tableWidgetData->setItem(i, FOUR, DATA(tr("元/") + mapMatList.at(i).value(HTTPKEY::UNITNAME)));
SETTABLECENTER(ui->tableWidgetData->item(i, ZERO));
SETTABLECENTER(ui->tableWidgetData->item(i, ONE));
SETTABLECENTER(ui->tableWidgetData->item(i, TWO));
SETTABLECENTER(ui->tableWidgetData->item(i, FOUR));
}
ui->tableWidgetData->scrollToBottom();
}
/********************* 保存事件 *********************/
void AddTranMaterial::on_pushButtonSave_clicked()
{
MapList mapListData;
QByteArray byteArray;
if(widgetType == EDITTYPE)
{
for(int i = 0; i < mapSelectList.size(); i ++)
{
Map mapData;
if(i < spinBoxList.size())
{
if(spinBoxList.at(i)->value() <= 0) return;
mapData[HTTPKEY::NUMBER] = QString::number(spinBoxList.at(i)->value());
}
mapData[HTTPKEY::ALLOTMATERIALID] = mapSelectList.at(i).value(HTTPKEY::ALLOTMATERIALID);
mapListData.append(mapData);
}
if(delListData.size() != 0)
{
byteArray.append(POSTARG::UPDATEALLMAT.arg(HTTPCLIENT->makeJson(delListData), HTTPCLIENT->makeJson(mapListData)));
}
else
{
byteArray.append(POSTARG::UPDATETRANMAT.arg(HTTPCLIENT->makeJson(mapListData)));
}
HTTPCLIENT->postUrlReq(MESSAGEURL(PROTOCOL::URL_ALLOT_UPDATE_ALL_MAT), byteArray, PROTOCOL::URL_ALLOT_UPDATE_ALL_MAT);
}
else
{
for(int i = ui->tableWidgetData->rowCount() - 1; i >= 0 ; i --)
{
if(ui->tableWidgetData->item(i, 0)->checkState() == Qt::Unchecked)
{
mapMatList.removeAt(i);
}
else
{
Map mapData;
if(i < spinBoxList.size())
{
if(spinBoxList.at(i)->value() <= 0) return;
mapData[HTTPKEY::NUMBER] = QString::number(spinBoxList.at(i)->value());
}
mapData[HTTPKEY::MATERIALID] = mapMatList.at(i).value(HTTPKEY::MATERIALID);
mapData[HTTPKEY::ALLOTNUMBER] = mapMatList.at(i).value(HTTPKEY::ALLOTNUMBER);
mapData[HTTPKEY::UNITID] = mapMatList.at(i).value(HTTPKEY::UNITID);
mapData[HTTPKEY::STOREID] = mapMatList.at(i).value(HTTPKEY::STOREID);
mapData[HTTPKEY::COSTPRICE] = mapMatList.at(i).value(HTTPKEY::COSTPRICE);
mapListData.append(mapData);
}
}
QString strPost = POSTARG::ADDTRANMAT.arg(HTTPCLIENT->makeJson(mapListData));
byteArray.append(strPost);
HTTPCLIENT->postUrlReq(MESSAGEURL(PROTOCOL::URL_ALLOT_ADD_MAT), byteArray, PROTOCOL::URL_ALLOT_ADD_MAT);
}
this->close();
}
/********************* 取消事件 *********************/
void AddTranMaterial::on_pushButtonCancel_clicked()
{
this->close();
}
/********************* 单击选中 *********************/
void AddTranMaterial::on_tableWidgetData_clicked(const QModelIndex &index)
{
if( ui->tableWidgetData->item(index.row(), 0)->checkState() == Qt::Checked)
{
ui->tableWidgetData->item(index.row(), 0)->setCheckState(Qt::Unchecked);
}
else
{
ui->tableWidgetData->item(index.row(), 0)->setCheckState(Qt::Checked);
}
}
/************************ 设置数据 ********************/
void AddTranMaterial::setMapSelectList(const MapList &value)
{
mapSelectList = value;
delListData.clear();
setTableEidiData();
}
/************************ 获取选择的列表 ********************/
MapList AddTranMaterial::getMapSelectList() const
{
return mapSelectList;
}
/************************ 删除数据 ********************/
void AddTranMaterial::on_pushButtonDel_clicked()
{
if(NULL == ui->tableWidgetEditData->currentItem()) return;
if(ui->tableWidgetEditData->currentRow() >= mapSelectList.size()) return;
int currentRow = ui->tableWidgetEditData->currentRow();
delListData.append(mapSelectList.at(currentRow).value(HTTPKEY::ALLOTMATERIALID));
mapSelectList.removeAt(ui->tableWidgetEditData->currentRow());
if(currentRow < spinBoxList.size())
{
SAFEDELETE(spinBoxList[currentRow])
}
spinBoxList.removeAt(currentRow);
ui->tableWidgetEditData->removeRow(currentRow);
}
/************************ 设置表格数据 ********************/
void AddTranMaterial::setTableEidiData()
{
for(int i = 0; i < spinBoxList.size(); i ++)
{
SAFEDELETE(spinBoxList[i]);
}
spinBoxList.clear();
ui->tableWidgetEditData->clearContents();
ui->tableWidgetEditData->setRowCount(mapSelectList.size());
for(int i = 0; i < mapSelectList.size(); i ++)
{
ui->tableWidgetEditData->setItem(i, ZERO, DATA(mapSelectList.at(i).value(HTTPKEY::MATERIALNAME)));
ui->tableWidgetEditData->setItem(i, ONE, DATA(mapSelectList.at(i).value(HTTPKEY::BARCODE)));
ui->tableWidgetEditData->setItem(i, TWO, DATA(mapSelectList.at(i).value(HTTPKEY::COSTPRICE)));
{
QWidget * widget = new QWidget(this);
QHBoxLayout *hBoxLayout = new QHBoxLayout(widget);
QDoubleSpinBox *spinBox = new QDoubleSpinBox(this);
hBoxLayout->addWidget(spinBox);
widget->setLayout(hBoxLayout);
spinBox->setValue(mapSelectList.at(i).value(HTTPKEY::NUMBER).toDouble());
hBoxLayout->setMargin(0);
spinBox->setFixedSize(ui->tableWidgetEditData->columnWidth(THREE), ui->tableWidgetEditData->rowHeight(ZERO));
spinBox->setFocusPolicy(Qt::NoFocus);
ui->tableWidgetEditData->setCellWidget(i, THREE, widget);
spinBoxList.append(spinBox);
}
ui->tableWidgetEditData->setItem(i, FOUR, DATA(tr("元/") + mapSelectList.at(i).value(HTTPKEY::UNITNAME)));
SETTABLECENTER(ui->tableWidgetEditData->item(i, ZERO));
SETTABLECENTER(ui->tableWidgetEditData->item(i, ONE));
SETTABLECENTER(ui->tableWidgetEditData->item(i, TWO));
SETTABLECENTER(ui->tableWidgetEditData->item(i, FOUR));
}
ui->tableWidgetEditData->scrollToBottom();
}
/************************ 选择 ********************/
void AddTranMaterial::on_checkBoxAllSelect_clicked()
{
bool checkFlage = ui->checkBoxAllSelect->isChecked();
if(checkFlage)
{
ui->checkBoxAllSelect->setText(tr("全不选"));
ui->checkBoxAllSelect->setIcon(QIcon(GLOBALDEF::NOTSELECTIMAGE));
}
else
{
ui->checkBoxAllSelect->setText(tr("全选"));
ui->checkBoxAllSelect->setIcon(QIcon(GLOBALDEF::ALLSELECTIMAGE));
}
Qt::CheckState checkState = ui->checkBoxAllSelect->isChecked() ? Qt::Checked : Qt::Unchecked;
for(int i = 0; i < ui->tableWidgetData->rowCount(); i ++)
{
ui->tableWidgetData->item(i, 0)->setCheckState(checkState);
}
}
| [
"YYC572652645@163.com"
] | YYC572652645@163.com |
9c72a552e3e5b9be7950c7ed7bede1160be6ca85 | 9f9660f318732124b8a5154e6670e1cfc372acc4 | /Case_save/Case30/case8/200/U | 21ed0d763a7a00e04a23bd058400c414acaa8de9 | [] | no_license | mamitsu2/aircond5 | 9a6857f4190caec15823cb3f975cdddb7cfec80b | 20a6408fb10c3ba7081923b61e44454a8f09e2be | refs/heads/master | 2020-04-10T22:41:47.782141 | 2019-09-02T03:42:37 | 2019-09-02T03:42:37 | 161,329,638 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,069 | // -*- C++ -*-
// File generated by PyFoam - sorry for the ugliness
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "200";
object U;
}
dimensions [ 0 1 -1 0 0 0 0 ];
internalField nonuniform List<vector> 459
(
(0.102798 0.0717101 0)
(-0.144721 0.00290413 0)
(-0.126623 0.00682553 0)
(-0.142328 0.007824 0)
(-0.157558 0.00673937 0)
(-0.170906 0.00475222 0)
(-0.181161 0.002143 0)
(-0.187319 -0.00104547 0)
(-0.188383 -0.00485227 0)
(-0.183289 -0.00943011 0)
(-0.170709 -0.0148965 0)
(-0.149054 -0.0213362 0)
(-0.118084 -0.0295801 0)
(-0.0857805 -0.041412 0)
(-0.0805848 -0.0555912 0)
(0.0320987 0.00920864 0)
(-0.0305345 -0.00983126 0)
(-0.00929476 -0.0141579 0)
(0.00717589 -0.0125452 0)
(0.0168084 -0.00744203 0)
(0.0229226 0.00354643 0)
(0.00478646 0.0149039 0)
(-0.0239844 0.00361744 0)
(-0.0277697 -0.00319563 0)
(-0.0283397 -0.00614909 0)
(-0.0246991 -0.00803185 0)
(-0.0184996 -0.010612 0)
(-0.00789371 -0.0148877 0)
(0.012434 -0.0226763 0)
(0.0252692 -0.0174902 0)
(0.0384858 -0.0146767 0)
(0.0467865 -0.0129049 0)
(0.0555224 -0.00392385 0)
(-0.00955626 0.0235542 0)
(0.314589 0.15635 0)
(-0.168749 0.0210329 0)
(-0.116425 0.0236934 0)
(-0.13865 0.0245456 0)
(-0.155525 0.0225767 0)
(-0.169923 0.018863 0)
(-0.181112 0.0137089 0)
(-0.188361 0.00711186 0)
(-0.190791 -0.00103637 0)
(-0.187512 -0.0108316 0)
(-0.177752 -0.0219601 0)
(-0.160715 -0.033972 0)
(-0.136655 -0.0471717 0)
(-0.108502 -0.062679 0)
(-0.0819001 -0.0782886 0)
(-0.0592874 -0.0833684 0)
(0.0435726 0.0117163 0)
(0.132651 0.0271626 0)
(-0.0208484 0.000727394 0)
(-0.0163365 -0.00992841 0)
(-0.0142428 -0.0145581 0)
(-0.0093564 -0.0153983 0)
(0.0169885 0.00745316 0)
(0.0204496 0.0238339 0)
(0.0111462 0.0140375 0)
(0.0120187 0.00494251 0)
(0.0119964 0.000748536 0)
(0.00893523 -0.00276751 0)
(0.0080256 -0.00728298 0)
(0.011301 -0.0146714 0)
(0.0118327 -0.0233146 0)
(0.00927524 -0.0170192 0)
(0.0175375 -0.0156615 0)
(0.0174545 -0.0175909 0)
(0.0393515 -0.000354614 0)
(-0.0828248 0.0546811 0)
(0.491868 0.239515 0)
(-0.216166 0.0512424 0)
(-0.0979169 0.0463463 0)
(-0.128458 0.0423294 0)
(-0.146016 0.037593 0)
(-0.161255 0.030843 0)
(-0.173639 0.0219666 0)
(-0.182601 0.0108843 0)
(-0.187325 -0.00243328 0)
(-0.18672 -0.0178027 0)
(-0.180848 -0.0349068 0)
(-0.169804 -0.0526697 0)
(-0.1547 -0.070122 0)
(-0.137643 -0.0860045 0)
(-0.121094 -0.0964513 0)
(-0.108791 -0.0949485 0)
(-0.110033 -0.0812176 0)
(0.0929177 0.0419298 0)
(-0.0562757 0.0121043 0)
(-0.0473872 -0.00342197 0)
(-0.048342 -0.0181029 0)
(-0.0452327 -0.0287872 0)
(-0.0432222 -0.0329173 0)
(0.0337345 0.0251524 0)
(0.0341331 0.0164761 0)
(0.0412707 0.00942634 0)
(0.0457169 0.00437761 0)
(0.0455366 2.47262e-05 0)
(0.041021 -0.0044611 0)
(0.0322857 -0.0104486 0)
(0.0115468 -0.017927 0)
(-0.0182725 -0.00166228 0)
(-0.0124151 0.00467873 0)
(-0.0381016 0.0106602 0)
(-0.0800694 0.0225762 0)
(-0.180444 0.0384709 0)
(0.63628 0.309336 0)
(-0.265793 0.0871512 0)
(-0.0730527 0.0702185 0)
(-0.11267 0.0608191 0)
(-0.129273 0.053912 0)
(-0.143916 0.0450217 0)
(-0.156458 0.0334745 0)
(-0.166349 0.0189674 0)
(-0.172773 0.0014222 0)
(-0.174474 -0.0187162 0)
(-0.171803 -0.0402667 0)
(-0.166139 -0.0613277 0)
(-0.159406 -0.0799403 0)
(-0.153954 -0.0939574 0)
(-0.152324 -0.0995695 0)
(-0.158457 -0.0898171 0)
(-0.172721 -0.0514818 0)
(-0.161446 0.0300286 0)
(-0.0965901 0.0313659 0)
(-0.103748 0.0146023 0)
(-0.0868065 -0.00420418 0)
(-0.0831656 -0.0194599 0)
(-0.085345 -0.0302612 0)
(-0.091133 -0.0340094 0)
(-0.0842311 -0.0224529 0)
(-0.0596898 -0.0222873 0)
(-0.0337382 -0.0267884 0)
(-0.00109446 -0.033191 0)
(0.0360968 -0.0304365 0)
(0.0653327 -0.0266157 0)
(0.0924687 -0.0227273 0)
(0.115237 -0.0173742 0)
(0.130944 -0.00915977 0)
(0.131466 0.00524172 0)
(0.11257 0.0240198 0)
(0.0867541 0.0340652 0)
(-0.0319979 0.028469 0)
(0.752163 0.367367 0)
(-0.309687 0.124825 0)
(-0.0452402 0.0904808 0)
(-0.091406 0.0769426 0)
(-0.105512 0.0683509 0)
(-0.117424 0.0578301 0)
(-0.127945 0.0442482 0)
(-0.136591 0.0270427 0)
(-0.142605 0.0060668 0)
(-0.144458 -0.0179594 0)
(-0.142426 -0.0426869 0)
(-0.139015 -0.0650587 0)
(-0.136254 -0.0828685 0)
(-0.135987 -0.0947954 0)
(-0.139376 -0.0995903 0)
(-0.146071 -0.0953388 0)
(-0.151051 -0.0776728 0)
(-0.146286 -0.0417381 0)
(-0.127306 -0.00977397 0)
(-0.104974 -0.0024514 0)
(-0.0870851 -0.0120418 0)
(-0.078385 -0.022307 0)
(-0.074758 -0.0304354 0)
(-0.0720187 -0.0338745 0)
(-0.0635671 -0.0310144 0)
(-0.0473766 -0.0346543 0)
(-0.0268175 -0.042595 0)
(-0.000729942 -0.0519482 0)
(0.0275267 -0.0483313 0)
(0.0511385 -0.0431506 0)
(0.0739522 -0.0378331 0)
(0.0953638 -0.0289546 0)
(0.113918 -0.0123143 0)
(0.127564 0.012479 0)
(0.130395 0.0388093 0)
(0.128579 0.0586516 0)
(0.0946322 0.0678676 0)
(0.11165 0.0680153 0)
(0.0579904 0.0413245 0)
(-0.389963 -0.0387531 0)
(0.829669 0.419396 0)
(-0.346617 0.158727 0)
(-0.0222144 0.100494 0)
(-0.0638616 0.0895106 0)
(-0.0752026 0.0795559 0)
(-0.0831158 0.0673535 0)
(-0.0895538 0.0522073 0)
(-0.0945543 0.0331286 0)
(-0.0976811 0.00956637 0)
(-0.0967085 -0.0178094 0)
(-0.0933875 -0.0450078 0)
(-0.0907764 -0.0673033 0)
(-0.0902495 -0.0829431 0)
(-0.0926808 -0.0915419 0)
(-0.0980875 -0.0926918 0)
(-0.10499 -0.0854527 0)
(-0.109264 -0.0691736 0)
(-0.106264 -0.0473398 0)
(-0.0950021 -0.02858 0)
(-0.0801973 -0.0213992 0)
(-0.0680512 -0.0236253 0)
(-0.0607971 -0.0290678 0)
(-0.0568701 -0.0346866 0)
(-0.0536356 -0.0387466 0)
(-0.0476258 -0.0421961 0)
(-0.0371011 -0.0500917 0)
(-0.0231821 -0.0621204 0)
(-0.00466534 -0.0750404 0)
(0.0154973 -0.0695558 0)
(0.031243 -0.0638373 0)
(0.0476297 -0.0593438 0)
(0.0653852 -0.0509524 0)
(0.0842378 -0.0328382 0)
(0.104559 -0.00184093 0)
(0.119892 0.0334888 0)
(0.129398 0.0616567 0)
(0.126851 0.0743569 0)
(0.132977 0.0762454 0)
(0.140524 0.0774105 0)
(-0.0796042 0.0601836 0)
(0.853537 0.467238 0)
(-0.364728 0.160919 0)
(-0.00215362 0.0749031 0)
(-0.016865 0.0972934 0)
(-0.0310646 0.0917926 0)
(-0.0381883 0.0736967 0)
(-0.0404284 0.0551388 0)
(-0.0402335 0.0343038 0)
(-0.0382674 0.00854028 0)
(-0.0299408 -0.0218614 0)
(-0.0252885 -0.0492353 0)
(-0.0245562 -0.0690539 0)
(-0.0274139 -0.081351 0)
(-0.0335655 -0.0869792 0)
(-0.0420902 -0.0864198 0)
(-0.0510749 -0.0795214 0)
(-0.0575714 -0.0665388 0)
(-0.058648 -0.0508324 0)
(-0.0541838 -0.0376243 0)
(-0.0469974 -0.0311469 0)
(-0.040606 -0.0306931 0)
(-0.0365675 -0.0333388 0)
(-0.0345829 -0.037128 0)
(-0.0336426 -0.041354 0)
(-0.0319634 -0.0477698 0)
(-0.0277262 -0.0593349 0)
(-0.0220005 -0.0752969 0)
(-0.010794 -0.0921566 0)
(0.000401743 -0.0827112 0)
(0.00580403 -0.0758078 0)
(0.0121347 -0.0735373 0)
(0.021275 -0.0689337 0)
(0.0339441 -0.0550319 0)
(0.0518938 -0.0262702 0)
(0.0792877 0.0153583 0)
(0.0967075 0.0488983 0)
(0.107885 0.0648041 0)
(0.123671 0.0691704 0)
(0.164193 0.0847927 0)
(-0.0580232 0.150779 0)
(0.958527 0.489847 0)
(-0.143957 0.145723 0)
(0.0720289 0.0172901 0)
(0.104514 0.0501776 0)
(0.0710603 0.0707315 0)
(0.0466717 0.0575515 0)
(0.0402949 0.0365858 0)
(0.0420732 0.0152915 0)
(0.0472966 -0.0109672 0)
(0.0600053 -0.0343339 0)
(0.061682 -0.0531069 0)
(0.0569117 -0.0666077 0)
(0.0480449 -0.0746826 0)
(0.036289 -0.0776795 0)
(0.0228559 -0.0761416 0)
(0.00941456 -0.070439 0)
(-0.00193863 -0.0608504 0)
(-0.00846843 -0.0498379 0)
(-0.0104956 -0.0406584 0)
(-0.00994186 -0.0354936 0)
(-0.00895878 -0.0343168 0)
(-0.00870834 -0.0356675 0)
(-0.00956602 -0.0380915 0)
(-0.0119941 -0.0413634 0)
(-0.0155881 -0.0481964 0)
(-0.0180707 -0.0618051 0)
(-0.02204 -0.0804181 0)
(-0.0172415 -0.101691 0)
(-0.014724 -0.0843791 0)
(-0.0224882 -0.0747163 0)
(-0.0311549 -0.0737169 0)
(-0.0380046 -0.0730325 0)
(-0.0419018 -0.066825 0)
(-0.0395408 -0.0518598 0)
(-0.0197946 -0.0271763 0)
(0.0106831 0.00736401 0)
(0.0216278 0.0206982 0)
(0.0420986 0.0193832 0)
(0.135199 0.0920733 0)
(-0.528285 0.277649 0)
(1.09947 0.44698 0)
(0.527386 0.295701 0)
(0.517325 0.242498 0)
(0.470631 0.203904 0)
(0.376639 0.173533 0)
(0.297354 0.131794 0)
(0.250567 0.0877261 0)
(0.224665 0.0488573 0)
(0.209781 0.0157154 0)
(0.189149 -0.0134245 0)
(0.168278 -0.0358122 0)
(0.147648 -0.0509643 0)
(0.127123 -0.0595668 0)
(0.106804 -0.0627775 0)
(0.087173 -0.0618369 0)
(0.0690219 -0.0578945 0)
(0.0534238 -0.0520598 0)
(0.0415005 -0.0456112 0)
(0.033328 -0.0400859 0)
(0.0278768 -0.0367477 0)
(0.0237896 -0.0358543 0)
(0.0202618 -0.0366689 0)
(0.0165647 -0.0377629 0)
(0.0107743 -0.0385717 0)
(0.0017992 -0.0428594 0)
(-0.00664016 -0.0558789 0)
(-0.0212951 -0.0744334 0)
(-0.021044 -0.10264 0)
(-0.0250442 -0.0728639 0)
(-0.0469506 -0.0579769 0)
(-0.0753297 -0.0544323 0)
(-0.10638 -0.0498963 0)
(-0.141691 -0.0371813 0)
(-0.181799 -0.0125472 0)
(-0.223071 0.0235242 0)
(-0.259841 0.0623198 0)
(-0.306382 0.0971653 0)
(-0.360996 0.123661 0)
(-0.43887 0.138353 0)
(-0.759002 0.133592 0)
(-0.168985 0.132861 0)
(0.17899 0.19882 0)
(0.252258 0.184089 0)
(0.244403 0.145414 0)
(0.242723 0.101092 0)
(0.244215 0.0597697 0)
(0.242094 0.0253678 0)
(0.233877 -0.00153632 0)
(0.218707 -0.0209656 0)
(0.199083 -0.0334939 0)
(0.177256 -0.0403512 0)
(0.155002 -0.0428309 0)
(0.133678 -0.0421822 0)
(0.114243 -0.0395426 0)
(0.0973166 -0.03593 0)
(0.0832367 -0.0322222 0)
(0.0719118 -0.0290585 0)
(0.0627391 -0.0267983 0)
(0.0550066 -0.025524 0)
(0.0485267 -0.0250452 0)
(0.0426852 -0.0244431 0)
(0.0342418 -0.0227841 0)
(0.0209791 -0.0228876 0)
(0.0099737 -0.0304574 0)
(-0.0147459 -0.0447204 0)
(-0.0198863 -0.0913145 0)
(-0.0263971 -0.0434948 0)
(-0.0494467 -0.0284663 0)
(-0.080743 -0.0262597 0)
(-0.108965 -0.0224987 0)
(-0.134515 -0.012159 0)
(-0.155328 0.00810925 0)
(-0.1746 0.037214 0)
(-0.191214 0.0718279 0)
(-0.201133 0.0959374 0)
(-0.194156 0.0813668 0)
(-0.175366 -0.023938 0)
(-0.291401 -0.259931 0)
(-0.0922312 0.2853 0)
(0.0687544 0.210873 0)
(0.0978142 0.156667 0)
(0.133954 0.124269 0)
(0.17064 0.091066 0)
(0.198324 0.0631637 0)
(0.212764 0.0444068 0)
(0.21506 0.0350581 0)
(0.20901 0.031443 0)
(0.197814 0.0290565 0)
(0.183756 0.0282803 0)
(0.168309 0.0293288 0)
(0.152653 0.0322144 0)
(0.137735 0.0366375 0)
(0.124213 0.0418648 0)
(0.112385 0.0467472 0)
(0.102143 0.0501043 0)
(0.0929887 0.0510759 0)
(0.0843147 0.0487996 0)
(0.0757803 0.0431695 0)
(0.0670284 0.0398501 0)
(0.0569647 0.0488139 0)
(0.0444641 0.0534751 0)
(0.0321046 0.0246506 0)
(0.0106562 0.0406461 0)
(-0.018408 -0.0912562 0)
(-0.043729 0.00701294 0)
(-0.0516182 0.0626448 0)
(-0.0648662 0.0624021 0)
(-0.0731124 0.0570209 0)
(-0.0787456 0.0523705 0)
(-0.0814434 0.0516782 0)
(-0.0780845 0.0631153 0)
(-0.0677254 0.0863833 0)
(-0.0492175 0.11041 0)
(-0.0225054 0.115198 0)
(0.138837 0.03612 0)
(-0.198301 -0.180924 0)
(-0.248864 -0.416741 0)
(-0.503317 -0.108747 0)
(-0.357175 0.178031 0)
(-0.196778 0.072507 0)
(-0.0834599 0.0349694 0)
(0.0395688 0.0096071 0)
(0.105813 -0.021392 0)
(0.156547 -0.050136 0)
(0.187741 -0.0761317 0)
(0.202271 -0.100216 0)
(0.205613 -0.122555 0)
(0.201823 -0.140804 0)
(0.193358 -0.156605 0)
(0.182118 -0.171076 0)
(0.169609 -0.184876 0)
(0.156963 -0.198184 0)
(0.144898 -0.210657 0)
(0.133677 -0.221514 0)
(0.123156 -0.229917 0)
(0.112924 -0.235519 0)
(0.102292 -0.238835 0)
(0.0900667 -0.240992 0)
(0.0756001 -0.24237 0)
(0.0631251 -0.241784 0)
(0.0584242 -0.242722 0)
(0.0484415 -0.253136 0)
(0.0509337 -0.255414 0)
(-0.0180824 -0.267038 0)
(-0.0848372 -0.238313 0)
(-0.0829731 -0.220712 0)
(-0.0808503 -0.222202 0)
(-0.0797644 -0.208176 0)
(-0.0728619 -0.178305 0)
(-0.0559291 -0.143604 0)
(-0.0281065 -0.101669 0)
(0.0248544 -0.0448483 0)
(0.0830299 -0.0304712 0)
(0.138997 -0.0529233 0)
(0.200327 -0.120326 0)
(-0.117517 -0.207463 0)
)
;
boundaryField
{
floor
{
type noSlip;
}
ceiling
{
type noSlip;
}
sWall
{
type noSlip;
}
nWall
{
type noSlip;
}
sideWalls
{
type empty;
}
glass1
{
type noSlip;
}
glass2
{
type noSlip;
}
sun
{
type noSlip;
}
heatsource1
{
type noSlip;
}
heatsource2
{
type noSlip;
}
Table_master
{
type noSlip;
}
Table_slave
{
type noSlip;
}
inlet
{
type fixedValue;
value uniform (0.277164 -0.114805 0);
}
outlet
{
type zeroGradient;
}
} // ************************************************************************* //
| [
"mitsuaki.makino@tryeting.jp"
] | mitsuaki.makino@tryeting.jp | |
f0a4e3a9c10e701cb7302fea3406083330ab429b | a19ec1048939a9b06617ea52a516bfc230abdc72 | /Floor.h | bbf8c8f5d4c3cf44654919c884fdd4dd0c2975f8 | [] | no_license | natelearnscode/FPSGame | c77a50a02b77e971b91ceea233d3031c5c5220fe | d260f7e3b4aaf8e9aeafa9d26a24b395ba90fd3a | refs/heads/master | 2023-03-30T18:19:52.868835 | 2021-04-17T04:01:54 | 2021-04-17T04:01:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,266 | h | #ifndef FLOOR_H
#define FLOOR_H
#include "OBJFileParser.h"
using namespace std;
class Floor {
public:
vector<glm::vec3> locations;
Shader* shader;
OBJFileParser objFileParser;
float* modelData;
GLuint vao;
GLuint vbo[1];
unsigned int texture;
int numLines = 0;
float numTris = 0;
float floorRadius = 1.0f;
int width;
int height;
Floor() {};
bool checkCollision(glm::vec3 position, float playerRadius) {
bool playerInWallX = false;
bool playerInWallY = false;
bool playerInWallZ = false;
for (auto location : locations) {
//Check x values
float wallXMin = (location.x - floorRadius);
float wallXMax = (location.x + floorRadius);
float playerXMin = (position.x - playerRadius);
float playerXMax = (position.x + playerRadius);
bool playerInWallX = playerXMax >= wallXMin && playerXMin <= wallXMax;
//Check y values
float wallYMin = (location.y - floorRadius);
float wallYMax = (location.y + floorRadius);
float playerYMin = (position.y - playerRadius);
float playerYMax = (position.y + playerRadius);
bool playerInWallY = playerYMax >= wallYMin && playerYMin <= wallYMax;
//Check z values
float wallZMin = (location.z - floorRadius);
float wallZMax = (location.z + floorRadius);
float playerZMin = (position.z - playerRadius);
float playerZMax = (position.z + playerRadius);
bool playerInWallZ = playerZMax >= wallZMin && playerZMin <= wallZMax;
if (playerInWallX && playerInWallY && playerInWallZ) {
printf("%d %d %d\n", playerInWallX, playerInWallY, playerInWallZ);
return true;
}
}
return false;
}
void loadModel(Shader* s, int w, int h, int scale) {
shader = s;
//Load model data
modelData = objFileParser.loadOBJFile("models/wall.obj", numLines, numTris);
width = w;
height = h;
for (int i = -1; i < width + 1; i++) {
for (int j = -1; j < height + 1; j++) {
locations.push_back(glm::vec3(j * scale, -2, i * scale));
}
}
//Build VAO from model data
buildVAO();
};
void buildVAO() {
//Load texture
glGenTextures(1, &texture);
glActiveTexture(GL_TEXTURE0); // activate the texture unit first before binding texture
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
int width, height, nrChannels;
unsigned char* data = stbi_load("models/grass.png", &width, &height, &nrChannels, 0);
if (data) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
glGenerateMipmap(GL_TEXTURE_2D);
}
else {
std::cout << "Failed to load texture. Error: " << stbi_failure_reason() << std::endl;
exit(0);
}
stbi_image_free(data);
glUniform1i(glGetUniformLocation(shader->ID, "Texture"), 0);
//Unbind texture
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 0);
//Build a Vertex Array Object. This stores the VBO and attribute mappings in one object
glGenVertexArrays(1, &vao); //Create a VAO
glBindVertexArray(vao); //Bind the above created VAO to the current context
//Allocate memory on the graphics card to store geometry (vertex buffer object)
glGenBuffers(1, vbo); //Create 1 buffer called vbo
glBindBuffer(GL_ARRAY_BUFFER, vbo[0]); //Set the vbo as the active array buffer (Only one buffer can be active at a time)
glBufferData(GL_ARRAY_BUFFER, numLines * sizeof(float), modelData, GL_STATIC_DRAW); //upload vertices to vbo
//Tell OpenGL how to set fragment shader input
GLint posAttrib = glGetAttribLocation(shader->ID, "position");
glVertexAttribPointer(posAttrib, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), 0);
//Attribute, vals/attrib., type, normalized?, stride, offset
//Binds to VBO current GL_ARRAY_BUFFER
glEnableVertexAttribArray(posAttrib);
GLint textAttrib = glGetAttribLocation(shader->ID, "inTextCoord");
glVertexAttribPointer(textAttrib, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(3 * sizeof(float)));
glEnableVertexAttribArray(textAttrib);
GLint normAttrib = glGetAttribLocation(shader->ID, "inNormal");
glVertexAttribPointer(normAttrib, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(5 * sizeof(float)));
glEnableVertexAttribArray(normAttrib);
//GLint colAttrib = glGetAttribLocation(shader->ID, "inColor");
//glVertexAttribPointer(colAttrib, 3, GL_FLOAT, GL_FALSE, 11 * sizeof(float), (void*)(8 * sizeof(float)));
//glEnableVertexAttribArray(colAttrib);
//glBindVertexArray(0); //Unbind the VAO
};
void draw() {
glBindVertexArray(vao);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
shader->setUniformVec3("inColor", glm::vec3(1, 1, 1));
for (int i = 0; i < locations.size(); i++) {
glm::mat4 model = glm::mat4(1);
model = glm::translate(model, locations[i]);
shader->setUniformMatrix("model", model);
glDrawArrays(GL_TRIANGLES, 0, numTris);
}
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 0); //Unbind the texture
glBindVertexArray(0); //Unbind the VAO
};
void cleanUp() {
glDeleteBuffers(1, vbo);
glDeleteVertexArrays(1, &vao);
}
};
#endif
| [
"natemesheshatech@gmail.com"
] | natemesheshatech@gmail.com |
9ca95938a03dc4453bb7940d4ec549e1a71f27d7 | 142715b2cf20074360959387d7dd0e8fe53ea370 | /src/SinkApp.cc | b9ddb2c474b04afa296565c3751a7ad44f6ae690 | [] | no_license | dzegarrar/QoS-on-OMNeT | 3f4361660ac2ee4e7430c13f8a44806fd7d0295c | df98406fec4162e35cc868e5e14b750075beded8 | refs/heads/master | 2021-01-17T21:36:54.443890 | 2011-06-23T03:49:34 | 2011-06-23T03:49:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 832 | cc | //
// 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/.
//
#include "SinkApp.h"
Define_Module(SinkApp);
void SinkApp::initialize()
{
// Do nothing
}
void SinkApp::handleMessage(cMessage *msg)
{
delete msg;
}
| [
"hugozaggo@gmail.com"
] | hugozaggo@gmail.com |
cb19503593d35300967894018348806b6163a3f3 | 065ba2bce925de592f7279821a9f0114f0c921ca | /src/source_repro.h | e33f705300617272d4f6f4ea88b72b7d896d76f4 | [
"MIT"
] | permissive | RickMoynihan/circa | f8bfdd4c583d2f9467e8aeebc51f844878f9a664 | 1fa55e298c22a5eb8e43fc9cb3804c20abbf6026 | refs/heads/master | 2020-12-30T17:50:34.742262 | 2012-12-21T04:01:44 | 2012-12-21T04:01:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,813 | h | // Copyright (c) Andrew Fischer. See LICENSE file for license terms.
#pragma once
#include "common_headers.h"
namespace circa {
void format_block_source(caValue* source, Block* block, Term* format=NULL);
std::string unformat_rich_source(caValue* source);
void format_term_source(caValue* source, Term* term);
void format_term_source_default_formatting(caValue* source, Term* term);
void format_term_source_normal(caValue* source, Term* term);
// Formats source for the given input, as used by the term.
void format_source_for_input(caValue* source, Term* term, int inputIndex);
void format_source_for_input(caValue* source, Term* term, int inputIndex,
const char* defaultPre, const char* defaultPost);
void format_name_binding(caValue* source, Term* term);
void append_phrase(caValue* source, const char* str, Term* term, Name type);
// Convenient overload:
void append_phrase(caValue* source, std::string const& str, Term* term, Name type);
std::string get_block_source_text(Block* block);
std::string get_term_source_text(Term* term);
std::string get_input_source_text(Term* term, int index);
bool should_print_term_source_line(Term* term);
bool is_hidden(Term* term);
int get_first_visible_input_index(Term* term);
std::string get_input_syntax_hint(Term* term, int index, const char* field);
std::string get_input_syntax_hint_optional(Term* term, int index, const char* field,
std::string const& defaultValue);
void set_input_syntax_hint(Term* term, int index, const char* field,
std::string const& value);
void set_input_syntax_hint(Term* term, int index, const char* field, caValue* value);
// Mark the given term as hidden from source reproduction.
void hide_from_source(Term* term);
void set_input_hidden(Term* term, int inputIndex, bool hidden);
} // namespace circa
| [
"paul.hodge.email@gmail.com"
] | paul.hodge.email@gmail.com |
f88e25d3e205591c5250396e7518f033535b55fa | daffb5f31e4f2e1690f4725fad5df9f2382416e3 | /USACO_Dec_2019/Gold/C/C.cpp | 9feefc0943e3e1dfabb04c3a29033f52c4fa8c69 | [] | no_license | cuom1999/CP | 1ad159819fedf21a94c102d7089d12d22bb6bfa2 | 4e37e0d35c91545b3d916bfa1de5076a18f29a75 | refs/heads/master | 2023-06-02T01:57:00.252932 | 2021-06-21T03:41:34 | 2021-06-21T03:41:34 | 242,620,572 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,008 | cpp | #include <bits/stdc++.h>
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define PI ( acos(-1.0) )
#define IN freopen("cowmbat.in","r",stdin)
#define OUT freopen("cowmbat.out","w",stdout)
#define FOR(i,a,b) for(int i=a ; i<=b ; i++)
#define FORD(i,a,b) for(int i=a ; i>=b ; i--)
#define INF 1000000000
#define ll long long int
#define eps (1e-8)
#define sq(x) ( (x)*(x) )
#define all(x) x.begin(),x.end()
#define flog2(n) 64 - __builtin_clzll(n) - 1
#define popcnt(n) __builtin_popcountll(n)
using namespace std;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
int d[30005][55][26];
int cost[26][26];
int n, m, k;
string s;
int dp(int index, int len, int c) {
if (index == n) {
if (len < k) return INF;
return 0;
}
int &res = d[index][len][c];
if (res != -1) return res;
res = INF;
int curChar = s[index] - 'a';
if (len >= k) {
int newLen;
FOR (i, 0, m - 1) {
if (i == c) {
newLen = k;
}
else {
newLen = 1;
}
res = min(res, dp(index + 1, newLen, i) + cost[curChar][i]);
}
}
else {
res = min(res, dp(index + 1, len + 1, c) + cost[curChar][c]);
}
// cout << index << " " << len << " " << c << " " << res << endl;
if (res > INF) res = INF;
return res;
}
int main()
{IN; OUT;
ios::sync_with_stdio(0);
cin.tie(NULL);
cin >> n >> m >> k;
cin >> s;
FOR (i, 0, m - 1) {
FOR (j, 0, m - 1) {
cin >> cost[i][j];
}
}
FOR (k, 0, m - 1) {
FOR (i, 0, m - 1) {
FOR (j, 0, m - 1) {
cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
}
}
}
int firstChar = s[0] - 'a';
int res = INF;
memset(d, -1, sizeof(d));
FOR (i, 0, m - 1) {
res = min(res, dp(1, 1, i) + cost[firstChar][i]);
}
cout << res << endl;
return 0;
} | [
"lephuocdinh99@gmail.com"
] | lephuocdinh99@gmail.com |
7702bda5a5d5671798bda27722872db3eccff1a5 | fdb9dda912af5fb12dd0096a17b829fa612c5907 | /unused/TerrainDecal.cpp | 22f764f596e4978ba865c6d0accb4b3b4610eb64 | [] | no_license | BestAwperEver/Ogre | 26904a5d7e2793ec968ed3d899e5516ad5011d7f | a622848d96aecebc9815db7db0179e2da8ce65f1 | refs/heads/master | 2021-01-11T20:44:09.857819 | 2018-10-18T22:22:57 | 2018-10-18T22:22:57 | 79,166,693 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,200 | cpp | #include "TerrainDecal.h"
#include <boost/lexical_cast.hpp>
bool TerrainDecal::isPosOnTerrain(Ogre::Vector3 pos)
{
// get the terrain boundaries
Ogre::AxisAlignedBox box;
mSceneManager->getOption("MapBoundaries",&box);
// check if pos is in box, ignore y
pos.y = 0;
return box.intersects(pos);
}
std::string TerrainDecal::getMaterialAtPosition(Ogre::Vector3 pos)
{
void* myOptionPtr = &pos;
// check if position is on battlefield
if( isPosOnTerrain(pos) )
{
mSceneManager->getOption ("getMaterialPageName", myOptionPtr);
std::string name = **static_cast<std::string**>(myOptionPtr);
return name;
}
else
return "";
}
void TerrainDecal::addMaterial(std::string matName)
{
// check if material is already decalled
if( mTargets.find(matName) != mTargets.end() )
{
Ogre::LogManager::getSingleton().getDefaultLog()->logMessage("material should be added to decal but was already!");
return;
}
using namespace Ogre;
// get the material ptr
MaterialPtr mat = (MaterialPtr)MaterialManager::getSingleton().getByName(matName);
// create a new pass in the material to render the decal
Pass* pass = mat->getTechnique(0)->createPass();
// set up the decal's texture unit
TextureUnitState *texState = pass->createTextureUnitState(mTexture);
texState->setProjectiveTexturing(true, mFrustum);
texState->setTextureAddressingMode(TextureUnitState::TAM_CLAMP);
texState->setTextureFiltering(FO_POINT, FO_LINEAR, FO_NONE);
// set our pass to blend the decal over the model's regular texture
pass->setSceneBlending(SBT_TRANSPARENT_ALPHA);
pass->setDepthBias(1);
// set the decal to be self illuminated instead of lit by scene lighting
pass->setLightingEnabled(false);
// save pass in map
mTargets[matName] = pass;
Ogre::LogManager::getSingleton().getDefaultLog()->logMessage(std::string("added material to decal: ") + matName +
"(" + Ogre::StringConverter::toString(mTargets.size()) + " materials loaded)");
}
std::map<std::string,Ogre::Pass*>::iterator TerrainDecal::removeMaterial(std::string matName)
{
// remove our pass from the given material
mTargets[matName]->getParent()->removePass(mTargets[matName]->getIndex());
Ogre::LogManager::getSingleton().getDefaultLog()->logMessage(std::string("removed material from decal: ") + matName +
"(" + Ogre::StringConverter::toString(mTargets.size()-1) + " materials loaded)");
// remove from map
return mTargets.erase(mTargets.find(matName));
}
TerrainDecal::TerrainDecal():
mInitialized(false),
mVisible(false),
mNode(0),
mFrustum(0)
{}
TerrainDecal::~TerrainDecal()
{
hide();
// delete frustum
mNode->detachAllObjects();
delete mFrustum;
// destroy node
mNode->getParentSceneNode()->removeAndDestroyChild(mNode->getName());
}
void TerrainDecal::init( Ogre::SceneManager* man, Ogre::Vector2 size, std::string tex )
{
using namespace Ogre;
// set SM
mSceneManager = man;
// init projective decal
// set up the main decal projection frustum
mFrustum = new Ogre::Frustum();
mNode = mSceneManager->getRootSceneNode()->createChildSceneNode();
mNode->attachObject(mFrustum);
mFrustum->setProjectionType(Ogre::PT_ORTHOGRAPHIC);
mNode->setOrientation(Ogre::Quaternion(Ogre::Degree(90),Ogre::Vector3::UNIT_X));
// set given values
updateSize(size);
mTexture = tex; // texture to apply
// load the images for the decal and the filter
auto sourceTexture = TextureManager::getSingleton().load
(mTexture, "General", TEX_TYPE_2D, 1);
mTexture = "DecalTexture";
auto manualTexture = TextureManager::getSingleton().createManual(
"DecalTexture", "General", TEX_TYPE_2D,
sourceTexture->getWidth(), sourceTexture->getHeight(),
sourceTexture->getNumMipmaps(),
sourceTexture->getFormat());
// Get the pixel buffer
Ogre::HardwarePixelBufferSharedPtr pixelBuffer = manualTexture->getBuffer(),
sourcePixelBuffer = sourceTexture->getBuffer();
// Lock the pixel buffer and get a pixel box
pixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD); // for best performance use HBL_DISCARD!
sourcePixelBuffer->lock(Ogre::HardwareBuffer::HBL_READ_ONLY);
const Ogre::PixelBox& pixelBox = pixelBuffer->getCurrentLock();
const Ogre::PixelBox& rockBox = sourcePixelBuffer->getCurrentLock();
Ogre::uint8* pDest = static_cast<Ogre::uint8*>(pixelBox.data);
Ogre::uint8* pSource = static_cast<Ogre::uint8*>(rockBox.data);
memcpy(pDest, pSource, sourceTexture->getWidth()*sourceTexture->getHeight()*4);
pixelBuffer->unlock();
sourcePixelBuffer->unlock();
sourceTexture->unload();
mVisible = false;
mInitialized = true;
}
void TerrainDecal::show()
{
if( !mVisible )
{
mVisible = true;
updatePosition(mPos);
}
}
void TerrainDecal::hide()
{
if( mVisible )
{
// remove all added passes
while( !mTargets.empty() )
removeMaterial(mTargets.begin()->first);
mVisible = false;
}
}
void TerrainDecal::updatePosition( Ogre::Vector3 pos )
{
// don`t do anything if pos didn`t change
if( pos == mPos )
return;
// save the new position
mPos = pos;
mNode->setPosition(pos.x,pos.y+1000,pos.z);
// don`t show if invisible
if( !isVisible() )
return;
// check near pages (up to 4)
std::list<std::string> neededMaterials;
Ogre::Vector3 t;
// x high z high
t = Ogre::Vector3(mPos.x+mSize.x/2.0f,1000,mPos.z+mSize.y/2.0f);
neededMaterials.push_back(getMaterialAtPosition(t));
// x high z low
t = Ogre::Vector3(mPos.x+mSize.x/2.0f,1000,mPos.z-mSize.y/2.0f);
neededMaterials.push_back(getMaterialAtPosition(t));
// x low z low
t = Ogre::Vector3(mPos.x-mSize.x/2.0f,1000,mPos.z-mSize.y/2.0f);
neededMaterials.push_back(getMaterialAtPosition(t));
// x low z high
t = Ogre::Vector3(mPos.x-mSize.x/2.0f,1000,mPos.z+mSize.y/2.0f);
neededMaterials.push_back(getMaterialAtPosition(t));
// remove empties
neededMaterials.remove("");
// remove doubles
neededMaterials.unique();
// compare needed materials with used
// for every used material
std::map<std::string,Ogre::Pass*>::iterator used = mTargets.begin();
while(true)
{
// stop if we are through
if( used == mTargets.end() )
break;
// find in needed
std::list<std::string>::iterator needed =
std::find(neededMaterials.begin(),neededMaterials.end(),used->first);
if( needed == neededMaterials.end() )
{
// material is not needed any longer, so remove it
used = removeMaterial(used->first);
}
else
{
// remove it from needed list, bedause it is already loaded
neededMaterials.remove(used->first);
// go further
used++;
}
}
// add all remaining needed to used list
while( !neededMaterials.empty() )
{
addMaterial(neededMaterials.front());
neededMaterials.erase(neededMaterials.begin());
}
}
Ogre::Vector3 TerrainDecal::getPosition() const {
return mPos;
}
void TerrainDecal::updateSize(Ogre::Vector2 size)
{
if( mSize != size )
{
// save param
mSize = size;
// update aspect ratio
mFrustum->setAspectRatio(mSize.x/mSize.y);
// update height
mFrustum->setOrthoWindowHeight(mSize.y);
}
}
void TerrainDecal::setColour(Ogre::ColourValue colour) {
for (auto it = mTargets.begin(); it != mTargets.end(); ++it) {
it->second->setDiffuse(colour);
}
} | [
"misher-fsh@yandex.ru"
] | misher-fsh@yandex.ru |
edc4837ac49f7d214965420f07a6532c7aac24d6 | 926a43a6cbf54bed26a52ed5251fc162c594aaf6 | /src/regal/RegalDispatcher.h | 8d4fd4e25166758635bd0adb6ac4791d6def9421 | [
"Libpng",
"BSD-3-Clause",
"MIT",
"Unlicense",
"Zlib",
"SGI-B-2.0",
"LicenseRef-scancode-glut",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause"
] | permissive | adhoc-bobcat/regal | c09bce4f2c15ca0b76e055c9b2448c99b1b940d7 | 4b3cc1c0d1b2fa0c7a06db599828f1386be22730 | refs/heads/master | 2021-01-16T20:21:31.536603 | 2013-05-10T20:59:51 | 2013-05-10T21:03:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,936 | h | /*
Copyright (c) 2011 NVIDIA Corporation
Copyright (c) 2011-2012 Cass Everitt
Copyright (c) 2012 Scott Nations
Copyright (c) 2012 Mathias Schott
Copyright (c) 2012 Nigel Stewart
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __REGAL_DISPATCHER_H__
#define __REGAL_DISPATCHER_H__
#include "RegalUtil.h"
REGAL_GLOBAL_BEGIN
#include <vector>
#include "RegalDispatch.h"
REGAL_GLOBAL_END
REGAL_NAMESPACE_BEGIN
struct Dispatcher
{
public:
#if REGAL_DEBUG
DispatchTable debug;
#endif
#if REGAL_ERROR
DispatchTable error;
#endif
#if REGAL_EMULATION
DispatchTable emulation;
#endif
#if REGAL_CACHE
DispatchTable cache;
#endif
#if REGAL_CODE
DispatchTable code;
#endif
#if REGAL_LOG
DispatchTable logging;
#endif
#if REGAL_TRACE
DispatchTable trace;
#endif
DispatchTable driver; // Underlying OpenGL/ES implementation
DispatchTable missing; // Must have this last
public:
Dispatcher();
~Dispatcher();
void push_back(DispatchTable &table, bool enable); // Push to the back of the stack
bool erase (DispatchTable &table); // Remove from dispatch stack
bool insert (DispatchTable &other, DispatchTable &table); // Insert before the other
inline void
enable(DispatchTable &table)
{
table._enabled = true;
}
inline void
disable(DispatchTable &table)
{
table._enabled = false;
}
inline bool isEnabled(DispatchTable &table) const
{
return table._enabled;
}
inline std::size_t size() const
{
return _size;
}
inline DispatchTable &operator[](const std::size_t i)
{
RegalAssert(i<size());
return *_table[i];
}
inline DispatchTable &front()
{
RegalAssert(size());
return *_front;
}
inline DispatchTable &back()
{
RegalAssert(size());
return *_table.back();
}
private:
std::vector<DispatchTable *> _table;
DispatchTable *_front;
std::size_t _size;
};
//
extern void InitDispatchTableCode (DispatchTable &tbl);
extern void InitDispatchTableDebug (DispatchTable &tbl);
extern void InitDispatchTableError (DispatchTable &tbl);
extern void InitDispatchTableEmu (DispatchTable &tbl);
extern void InitDispatchTableLog (DispatchTable &tbl);
extern void InitDispatchTableLoader (DispatchTable &tbl);
extern void InitDispatchTablePpapi (DispatchTable &tbl);
extern void InitDispatchTableStaticES2(DispatchTable &tbl);
extern void InitDispatchTableMissing (DispatchTable &tbl);
extern void InitDispatchTableCache (DispatchTable &tbl);
extern void InitDispatchTableTrace (DispatchTable &tbl);
REGAL_NAMESPACE_END
#endif // __REGAL_DISPATCHER__
| [
"nigels@users.sourceforge.net"
] | nigels@users.sourceforge.net |
cd5bece2536877c90c7574ef749e41c1e3982dd1 | 021b3774cd9c4eec3504c8fae6ccdac210c48c24 | /Graph_nn.cpp | a9a99ee9aa5333b595594d54004f79897d9b2fab | [] | no_license | EML16/CS325_Project4 | d9fed16eb928ff35519aee82399cc3982c38f020 | f3e9802f359e8457a3966b810b2473b9f48a3c8e | refs/heads/master | 2020-06-17T04:53:28.747655 | 2016-12-01T17:55:51 | 2016-12-01T17:55:51 | 75,039,430 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,774 | cpp | #include<cmath>
#include<fstream>
#include<queue>
#include<stack>
#include<limits.h>
#include<limits>
#include<iterator>
#include<map>
#include<set>
#include<list>
#include<exception>
#include<iostream>
#include "Graph_nn.h"
using namespace std;
namespace tsp {
Graph::Graph() {}
Graph::~Graph() {}
Graph::Graph(std::ifstream &ifs)
{
int label;
int x;
int y;
typedef struct {int label; int x; int y;} Node;
std::vector<Node> vertices;
//Read each line of the input file
while(ifs>>label>>x>>y)
{
Node n = {label, x, y};
vertices.push_back(n);
V.push_back(label);
}
std::vector<int> row; //Euclidean distance from a vertex to each of the vertices, including itself
for(auto u : vertices){
for(auto v : vertices){
auto l = (u.x - v.x);
auto h = (u.y - v.y);
int d = std::round(std::sqrt(l*l + h*h)); //Calculate Euclidean distance
row.push_back(d);
}
weight.push_back(row);
row.clear();
}
}
int Graph::nearest_neighbor(int start) {
int pathLength = 0;
std::vector<bool> visited(V.size(), false);
int u = start;
//add start city u in list of vertices V to path
path.push_back(V.at(u));
//remove u city from list of cities
visited.at(u) = true;
//nearest neighbor
int v;
//add city nearest u to path, update path length, and update isVisited
while (path.size() < V.size()) {
//find city with shortest edge
v = find_min(u, visited);
if (!visited.at(v)) {
//add city with shortest edge to path
path.push_back(V.at(v));
//update path length
pathLength += weight.at(u).at(v);
//remove v from list of unvisited vertices and set source city u to previous destination v
u = v; //set u to v
visited.at(v) = true;
}
}
//add path length to return to starting location
pathLength += weight.at(v).at(start);
return pathLength;
}
int Graph::find_min(int u, vector<bool> &visited){
int min = INT_MAX;
int v = 0;
for(int i = 0; i < V.size(); i++){
//if edge weight less than min and city has not been visited, return city label
if ((weight.at(u).at(i) < min) && (i != u) && !visited.at(i)) {
min = weight.at(u).at(i);
v = i;
}
}
return v;
}
int Graph::twoOpt(std::vector<int> &inPath, int &pathLength)
{
int counter = 0;
int old_distance = pathLength;
int n = V.size();
int v1, v2, u1, u2;
for (int i = 0; i < n; i++)
{
u1 = i;
v1 = (i+1) % n;
for (int j = i + 2; (j + 1) % n != i; j++)
{
u2 = j % n;
v2 = (j+1) % n;
auto w1 = weight.at(inPath[u1]).at(inPath[u2]) + weight.at(inPath[v1]).at(inPath[v2]);
auto w2 = weight.at(inPath[u1]).at(inPath[v1]) + weight.at(inPath[u2]).at(inPath[v2]);
if(w1 < w2)
{
pathLength -= w2 - w1;
twoOptSwap(inPath, i + 1, j);
if (pathLength - old_distance < 5 && counter == 5)
break;
if (pathLength - old_distance > 5 )
i = 0;
old_distance = pathLength;
counter++;
}
}
}
return pathLength;
}
void Graph::twoOptSwap(std::vector<int> &inPath, int start, int end)
{
int n = V.size();
while (end - start > 0)
{
int temp = inPath[start % n];
inPath[start % n] = inPath[end % n];
inPath[end % n] = temp;
start++;
end--;
}
}
void Graph::tour(std::ofstream &ofs)
{
int pathLength;
pathLength = nearest_neighbor(0);
twoOpt(path, pathLength);
twoOpt(path, pathLength);
twoOpt(path, pathLength);
twoOpt(path, pathLength);
twoOpt(path, pathLength);
ofs<<pathLength<<endl;
for(auto v: path)
ofs<<v<<endl;
}
} /* namespace tsp */
| [
"kiesslim@oregonstate.edu"
] | kiesslim@oregonstate.edu |
fbebf1e8d10a89ecbaea3202d0646af7d29e27f1 | f5ce63d5e1543c7cdb9b273e159b1a4f1382b7a8 | /Pong/Pong/cButton.cpp | 0c71df166cda08a41279c71c789deb6470ef4062 | [] | no_license | Briken/David-Hesketh-Coursework-Submission-GP1 | 173e937cb38fed48c4d42f966645a4dc0fa8bae0 | 42396e8762ed2ad0495d0b5f354e84c0ed3ee48c | refs/heads/master | 2016-09-01T05:07:44.354259 | 2015-12-10T14:09:46 | 2015-12-10T14:09:46 | 47,753,112 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,548 | cpp | /*
=================
- cButton.cpp
- Header file for class definition - IMPLEMENTATION
=================
*/
#include "cButton.h"
/*
=================================================================
Defualt Constructor
=================================================================
*/
cButton::cButton()
{
spritePos2D.x = 0.0f;
spritePos2D.y = 0.0f;
setSpriteTexCoordData();
spriteTranslation = glm::vec2(0.0f, 0.0f);
spriteScaling = glm::vec2(1.0f, 1.0f);
spriteRotation = 0.0f;
spriteCentre = glm::vec2(0.0f, 0.0f);
}
void cButton::render()
{
setSpriteCentre();
glPushMatrix();
glTranslatef(spritePos2D.x, spritePos2D.y, 0.0f);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, GLTextureID); // Binding of GLtexture name
glBegin(GL_QUADS);
glColor3f(255.0f, 255.0f, 255.0f);
glTexCoord2f(spriteTexCoordData[0].x, spriteTexCoordData[0].y);
glVertex2f(0, 0);
glTexCoord2f(spriteTexCoordData[1].x, spriteTexCoordData[1].y);
glVertex2f(textureWidth, 0);
glTexCoord2f(spriteTexCoordData[2].x, spriteTexCoordData[2].y);
glVertex2f(textureWidth, textureHeight);
glTexCoord2f(spriteTexCoordData[3].x, spriteTexCoordData[3].y);
glVertex2f(0, textureHeight);
glEnd();
glDisable(GL_TEXTURE_2D);
glPopMatrix();
}
void cButton::render(int textureToRender)
{
GLTextureID = textureToRender;
setSpriteCentre();
glPushMatrix();
glTranslatef(spritePos2D.x, spritePos2D.y, 0.0f);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, GLTextureID); // Binding of GLtexture name
glBegin(GL_QUADS);
glColor3f(255.0f, 255.0f, 255.0f);
glTexCoord2f(spriteTexCoordData[0].x, spriteTexCoordData[0].y);
glVertex2f(0, 0);
glTexCoord2f(spriteTexCoordData[1].x, spriteTexCoordData[1].y);
glVertex2f(textureWidth, 0);
glTexCoord2f(spriteTexCoordData[2].x, spriteTexCoordData[2].y);
glVertex2f(textureWidth, textureHeight);
glTexCoord2f(spriteTexCoordData[3].x, spriteTexCoordData[3].y);
glVertex2f(0, textureHeight);
glEnd();
glDisable(GL_TEXTURE_2D);
glPopMatrix();
}
/*
=================================================================
Update the sprite position
=================================================================
*/
void cButton::update()
{
if (m_InputMgr->getLeftMouseBtn())
{
glm::vec2 areaClicked = m_InputMgr->getMouseXY();
if (areaClicked.x >= spritePos2D.x && areaClicked.x <= (spritePos2D.x + textureWidth) && areaClicked.y >= spritePos2D.y && areaClicked.y <= (spritePos2D.y + textureHeight))
{
buttonClickedRC.x = (int)(areaClicked.x - spritePos2D.x) / textureWidth;
buttonClickedRC.y = (int)(areaClicked.y - spritePos2D.y) / textureHeight;
clicked = true;
m_InputMgr->clearBuffers(m_InputMgr->MOUSE_BUFFER);// clear mouse buffer.
}
}
}
gameState cButton::update(gameState theCurrentGameState, gameState newGameState)
{
if (m_InputMgr->getLeftMouseBtn())
{
glm::vec2 areaClicked = m_InputMgr->getMouseXY();
if (areaClicked.x >= spritePos2D.x && areaClicked.x <= (spritePos2D.x + textureWidth) && areaClicked.y >= spritePos2D.y && areaClicked.y <= (spritePos2D.y + textureHeight))
{
buttonClickedRC.x = (int)(areaClicked.x - spritePos2D.x) / textureWidth;
buttonClickedRC.y = (int)(areaClicked.y - spritePos2D.y) / textureHeight;
clicked = true;
m_InputMgr->clearBuffers(m_InputMgr->MOUSE_BUFFER);// clear mouse buffer.
return newGameState;
}
}
return theCurrentGameState;
}
bool cButton::getClicked()
{
return clicked;
}
void cButton::setClicked(bool state)
{
clicked = state;
}
void cButton::update(float deltaTime)
{
}
| [
"brokenbriken@gmail.com"
] | brokenbriken@gmail.com |
7059524e7b16ab6a2b1fb501d6d968bb02bd9cb0 | cb5c9b4168179356c38ef7a7cb0d316ddde28a40 | /src/MonsterCreature.h | f21c539c82862760ff66c303c8026f75f08d0ad7 | [] | no_license | lemi44/gejm | b5b527fcc2dc38e101f89dd47109588cdecda04e | 8657ad0809433353e228a4617e69e1f0fd0e30fc | refs/heads/master | 2021-01-17T12:08:06.957145 | 2017-03-06T11:23:24 | 2017-03-06T11:23:24 | 84,059,167 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,376 | h | #ifndef MONSTERCREATURE_H
#define MONSTERCREATURE_H
#include "Creature.h"
/**
* MonsterCreature is a Creature that should be AI controlled as it hurts PlayerCreature.
* It derives from Creature.
* @see Creature
*/
class MonsterCreature :
public Creature
{
public:
/**
* The default constructor of MonsterCreature.
* @param x X position of MonsterCreature. Defaults to 0.0
* @param y Y position of MonsterCreature. Defaults to 0.0
* @param width width of MonsterCreature. Defaults to 1.0
* @param height height of MonsterCreature. Defaults to 1.0
* @param health health of MonsterCreature. Defaults to 1
* @see Creature
*/
MonsterCreature(double x = 0.0, double y = 0.0, double width = 1.0, double height = 1.0, Uint8 health = 1);
/**
* Default destructor
*/
~MonsterCreature();
/**
* Function for resolving special cases of collision.
* If special case is not found, function calls Creature implementation of onCollision.
* @param collider a pointer to a SolidObject with which MonsterCreature is colliding
* @return void
*/
void onCollision(SolidObject* collider) override;
/**
* Assignment operator is deleted because of constant member initialized on Construction.
*/
MonsterCreature& operator=(MonsterCreature const&) = delete;
};
#endif // MONSTER_H | [
"lemi44@gmail.com"
] | lemi44@gmail.com |
f26de30722237e85af4490bf7a7ef26aaef34697 | cf8480b6bf152cd3d4c7c753870ead1747fb36ec | /迭代器课堂作业/迭代器课堂作业/ListD.h | a816d6f28dfa7310af2c76802e81d79a1af8725d | [] | no_license | cocealx/Code_cpp | d82ca5bad4a8dfe5a875bff6e44fb12cf6b4f5fa | 170df6bfc2b447aa55b2318a180775f87a1b5c0e | refs/heads/master | 2020-03-23T12:52:48.442236 | 2018-08-20T15:25:38 | 2018-08-20T15:25:38 | 141,587,798 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,740 | h | #define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<assert.h>
using namespace std;
template<class T>
struct Listnode
{
typedef Listnode<T> Node;
Listnode(const T& data=T())
:_data(data),
prev(NULL),
next(NULL)
{
}
Node*prev;
Node*next;
T _data;
};
//迭代器
template < class T, class Ref, class Ptr>
class MYiterator
{
public:
self operator++(int)
{
//self t1(_node);
//return t1;//调用两次构造函数
//Node*ret = _node;
//_node = _node->next;
////return self(ret);//编译器会进行优化,函数结束时对象没有释放。所以少调用一次构造函数
//return ret;//隐式调用迭代器的单参构造函数
}
self&operator--()
{
}
self operator--(int)
{
}
bool operator!=(const self&t1)
{
}
Ptr operator->()
{
}
Ref operator*()
{
}
Node* GetNode()
{
}
private:
Node* _node;
};
template <class T>
class MYList
{
public:
template MYList<T> self;
typedef Listnode<T> Node;
typedef MYiterator< T, T&, T*> Iterator;
typedef MYiterator<const T, const T&, const T*> ConstIterator;
MYList()
{
_head = new Node;
_head->next = _head;
_head->prev = _head;
}
MYList(const self& lst )
{
_head = new Node;
_head->next = _head;
_head->prev = _head;
}
//~MYList();
void Pushback(const T &data)
{
}
void PopBack()
{
}
void PushFront(const T&data)
{
}
void PopFront()
{
}
Iterator& Erase(Iterator& pos)
{
}
Iterator Insert(Iterator pos, const T & data)
{
}
Iterator Find(const T&data)
{
}
Iterator Begin()
{
}
ConstIterator Begin()const
{
}
Iterator End()
{
}
ConstIterator End()const
{
}
size_t Size()
{
}
void Clear();
Node*GetNode(const T&data)
{
}
private:
Node* _head;
};
| [
"1975178521@qq.com"
] | 1975178521@qq.com |
760cf3b07e09a0003a8bd230f513bb2a6f1c3f19 | 6ccaee717224338ba1889619a4c73454785588b5 | /Data Structures/Fenwick Trees/Fenwick Tree with one based indexing.cpp | 0e006aa9b1d12bd6545c7cf0b1710bfa51a71bda | [] | no_license | nikhil-seth/cp-log | 7dc69b15d79603637976018f8269d8ed11adb08a | faf123aa41096b19303ecaff00fbc2974491c32f | refs/heads/master | 2021-06-22T02:57:05.031734 | 2021-01-04T14:26:11 | 2021-01-04T14:26:11 | 143,634,576 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,031 | cpp | #include<bits/stdc++.h>
#define ll long long
#define FOR(i,a,b) for(auto i=(a);i<=(b);i++)
#define elif else if
#define FORA(x,arr) for(auto &x:arr)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define fio freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define UL unsigned long
using namespace std;
/* Fenwick Tree
One Based Indexing.
*/
struct FenwickTree{
vector<int> bit;
int n;
FenwickTree(int n){
this->n=n+1;
bit.assign(n+1,0);
}
FenwickTree(vector<int> a):FenwickTree(a.size()){
for(auto i=0;i<a.size();i++){
add(i,a[i]);
}
}
int sum(int r){
int ret=0;
for(++r;r>0;r-=(r&(-r)))
ret+=bit[r];
return ret;
}
int sum(int l,int r){
return sum(r)-sum(l);
}
void add(int idx,int delta){
for(++idx;idx<n;idx+=(idx&-idx))
bit[idx]+=delta;
}
};
int main(){
#ifndef ONLINE_JUDGE
fio
#endif
int n,r;
cin>>n;
vector<int> arr(n);
FORA(x,arr)
cin>>x;
FenwickTree F(arr);
cin>>n;
while(n--){
cin>>r;
cout<<F.sum(r)<<endl;
}
} | [
"rootedguy24@gmail.com"
] | rootedguy24@gmail.com |
b6214316de1a2a56804c87eea95792218554ed40 | f258062f932c15fa21bd49d554824dd59caf784a | /deps/3.1.3/darwin/include/wx/setup_inc.h | 47065972872c85b1bf34cfbda90ac1293c84afdd | [
"MIT"
] | permissive | kusti8/node-wx-napi | 8e83a6bb28a9112a16d738eb13ba65e9d4f62b2d | 00cf7560bfcb1dcf5680f8030e775f8e7dc1cf08 | refs/heads/master | 2022-02-09T16:07:01.372990 | 2020-01-12T21:33:08 | 2020-01-12T21:33:08 | 232,460,161 | 3 | 1 | MIT | 2022-01-22T10:11:27 | 2020-01-08T02:28:40 | C++ | UTF-8 | C++ | false | false | 52,185 | h | ///////////////////////////////////////////////////////////////////////////////
// Name: wx/setup_inc.h
// Purpose: setup.h settings
// Author: Vadim Zeitlin
// Modified by:
// Created:
// Copyright: (c) Vadim Zeitlin
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------
// global settings
// ----------------------------------------------------------------------------
// define this to 0 when building wxBase library - this can also be done from
// makefile/project file overriding the value here
#ifndef wxUSE_GUI
#define wxUSE_GUI 1
#endif // wxUSE_GUI
// ----------------------------------------------------------------------------
// compatibility settings
// ----------------------------------------------------------------------------
// This setting determines the compatibility with 2.8 API: set it to 0 to
// flag all cases of using deprecated functions.
//
// Default is 1 but please try building your code with 0 as the default will
// change to 0 in the next version and the deprecated functions will disappear
// in the version after it completely.
//
// Recommended setting: 0 (please update your code)
#define WXWIN_COMPATIBILITY_2_8 0
// This setting determines the compatibility with 3.0 API: set it to 0 to
// flag all cases of using deprecated functions.
//
// Default is 1 but please try building your code with 0 as the default will
// change to 0 in the next version and the deprecated functions will disappear
// in the version after it completely.
//
// Recommended setting: 0 (please update your code)
#define WXWIN_COMPATIBILITY_3_0 1
// MSW-only: Set to 0 for accurate dialog units, else 1 for old behaviour when
// default system font is used for wxWindow::GetCharWidth/Height() instead of
// the current font.
//
// Default is 0
//
// Recommended setting: 0
#define wxDIALOG_UNIT_COMPATIBILITY 0
// Provide unsafe implicit conversions in wxString to "const char*" or
// "std::string" (depending on wxUSE_STD_STRING_CONV_IN_WXSTRING value).
//
// Default is 1 but only for compatibility reasons, it is recommended to set
// this to 0 because converting wxString to a narrow (non-Unicode) string may
// fail unless a locale using UTF-8 encoding is used, which is never the case
// under MSW, for example, hence such conversions can result in silent data
// loss.
//
// Recommended setting: 0
#define wxUSE_UNSAFE_WXSTRING_CONV 1
// If set to 1, enables "reproducible builds", i.e. build output should be
// exactly the same if the same build is redone again. As using __DATE__ and
// __TIME__ macros clearly makes the build irreproducible, setting this option
// to 1 disables their use in the library code.
//
// Default is 0
//
// Recommended setting: 0
#define wxUSE_REPRODUCIBLE_BUILD 0
// ----------------------------------------------------------------------------
// debugging settings
// ----------------------------------------------------------------------------
// wxDEBUG_LEVEL will be defined as 1 in wx/debug.h so normally there is no
// need to define it here. You may do it for two reasons: either completely
// disable/compile out the asserts in release version (then do it inside #ifdef
// NDEBUG) or, on the contrary, enable more asserts, including the usually
// disabled ones, in the debug build (then do it inside #ifndef NDEBUG)
//
// #ifdef NDEBUG
// #define wxDEBUG_LEVEL 0
// #else
// #define wxDEBUG_LEVEL 2
// #endif
// wxHandleFatalExceptions() may be used to catch the program faults at run
// time and, instead of terminating the program with a usual GPF message box,
// call the user-defined wxApp::OnFatalException() function. If you set
// wxUSE_ON_FATAL_EXCEPTION to 0, wxHandleFatalExceptions() will not work.
//
// This setting is for Win32 only and can only be enabled if your compiler
// supports Win32 structured exception handling (currently only VC++ does)
//
// Default is 1
//
// Recommended setting: 1 if your compiler supports it.
#define wxUSE_ON_FATAL_EXCEPTION 1
// Set this to 1 to be able to generate a human-readable (unlike
// machine-readable minidump created by wxCrashReport::Generate()) stack back
// trace when your program crashes using wxStackWalker
//
// Default is 1 if supported by the compiler.
//
// Recommended setting: 1, set to 0 if your programs never crash
#define wxUSE_STACKWALKER 1
// Set this to 1 to compile in wxDebugReport class which allows you to create
// and optionally upload to your web site a debug report consisting of back
// trace of the crash (if wxUSE_STACKWALKER == 1) and other information.
//
// Default is 1 if supported by the compiler.
//
// Recommended setting: 1, it is compiled into a separate library so there
// is no overhead if you don't use it
#define wxUSE_DEBUGREPORT 1
// Generic comment about debugging settings: they are very useful if you don't
// use any other memory leak detection tools such as Purify/BoundsChecker, but
// are probably redundant otherwise. Also, Visual C++ CRT has the same features
// as wxWidgets memory debugging subsystem built in since version 5.0 and you
// may prefer to use it instead of built in memory debugging code because it is
// faster and more fool proof.
//
// Using VC++ CRT memory debugging is enabled by default in debug build (_DEBUG
// is defined) if wxUSE_GLOBAL_MEMORY_OPERATORS is *not* enabled (i.e. is 0)
// and if __NO_VC_CRTDBG__ is not defined.
// The rest of the options in this section are obsolete and not supported,
// enable them at your own risk.
// If 1, enables wxDebugContext, for writing error messages to file, etc. If
// __WXDEBUG__ is not defined, will still use the normal memory operators.
//
// Default is 0
//
// Recommended setting: 0
#define wxUSE_DEBUG_CONTEXT 0
// If 1, enables debugging versions of wxObject::new and wxObject::delete *IF*
// __WXDEBUG__ is also defined.
//
// WARNING: this code may not work with all architectures, especially if
// alignment is an issue. This switch is currently ignored for mingw / cygwin
//
// Default is 0
//
// Recommended setting: 1 if you are not using a memory debugging tool, else 0
#define wxUSE_MEMORY_TRACING 0
// In debug mode, cause new and delete to be redefined globally.
// If this causes problems (e.g. link errors which is a common problem
// especially if you use another library which also redefines the global new
// and delete), set this to 0.
// This switch is currently ignored for mingw / cygwin
//
// Default is 0
//
// Recommended setting: 0
#define wxUSE_GLOBAL_MEMORY_OPERATORS 0
// In debug mode, causes new to be defined to be WXDEBUG_NEW (see object.h). If
// this causes problems (e.g. link errors), set this to 0. You may need to set
// this to 0 if using templates (at least for VC++). This switch is currently
// ignored for MinGW/Cygwin.
//
// Default is 0
//
// Recommended setting: 0
#define wxUSE_DEBUG_NEW_ALWAYS 0
// ----------------------------------------------------------------------------
// Unicode support
// ----------------------------------------------------------------------------
// These settings are obsolete: the library is always built in Unicode mode
// now, only set wxUSE_UNICODE to 0 to compile legacy code in ANSI mode if
// absolutely necessary -- updating it is strongly recommended as the ANSI mode
// will disappear completely in future wxWidgets releases.
#ifndef wxUSE_UNICODE
#define wxUSE_UNICODE 1
#endif
// wxUSE_WCHAR_T is required by wxWidgets now, don't change.
#define wxUSE_WCHAR_T 1
// ----------------------------------------------------------------------------
// global features
// ----------------------------------------------------------------------------
// Compile library in exception-safe mode? If set to 1, the library will try to
// behave correctly in presence of exceptions (even though it still will not
// use the exceptions itself) and notify the user code about any unhandled
// exceptions. If set to 0, propagation of the exceptions through the library
// code will lead to undefined behaviour -- but the code itself will be
// slightly smaller and faster.
//
// Note that like wxUSE_THREADS this option is automatically set to 0 if
// wxNO_EXCEPTIONS is defined.
//
// Default is 1
//
// Recommended setting: depends on whether you intend to use C++ exceptions
// in your own code (1 if you do, 0 if you don't)
#define wxUSE_EXCEPTIONS 1
// Set wxUSE_EXTENDED_RTTI to 1 to use extended RTTI
//
// Default is 0
//
// Recommended setting: 0 (this is still work in progress...)
#define wxUSE_EXTENDED_RTTI 0
// Support for message/error logging. This includes wxLogXXX() functions and
// wxLog and derived classes. Don't set this to 0 unless you really know what
// you are doing.
//
// Default is 1
//
// Recommended setting: 1 (always)
#define wxUSE_LOG 1
// Recommended setting: 1
#define wxUSE_LOGWINDOW 1
// Recommended setting: 1
#define wxUSE_LOGGUI 1
// Recommended setting: 1
#define wxUSE_LOG_DIALOG 1
// Support for command line parsing using wxCmdLineParser class.
//
// Default is 1
//
// Recommended setting: 1 (can be set to 0 if you don't use the cmd line)
#define wxUSE_CMDLINE_PARSER 1
// Support for multithreaded applications: if 1, compile in thread classes
// (thread.h) and make the library a bit more thread safe. Although thread
// support is quite stable by now, you may still consider recompiling the
// library without it if you have no use for it - this will result in a
// somewhat smaller and faster operation.
//
// Notice that if wxNO_THREADS is defined, wxUSE_THREADS is automatically reset
// to 0 in wx/chkconf.h, so, for example, if you set USE_THREADS to 0 in
// build/msw/config.* file this value will have no effect.
//
// Default is 1
//
// Recommended setting: 0 unless you do plan to develop MT applications
#define wxUSE_THREADS 1
// If enabled, compiles wxWidgets streams classes
//
// wx stream classes are used for image IO, process IO redirection, network
// protocols implementation and much more and so disabling this results in a
// lot of other functionality being lost.
//
// Default is 1
//
// Recommended setting: 1 as setting it to 0 disables many other things
#define wxUSE_STREAMS 1
// Support for positional parameters (e.g. %1$d, %2$s ...) in wxVsnprintf.
// Note that if the system's implementation does not support positional
// parameters, setting this to 1 forces the use of the wxWidgets implementation
// of wxVsnprintf. The standard vsnprintf() supports positional parameters on
// many Unix systems but usually doesn't under Windows.
//
// Positional parameters are very useful when translating a program since using
// them in formatting strings allow translators to correctly reorder the
// translated sentences.
//
// Default is 1
//
// Recommended setting: 1 if you want to support multiple languages
#define wxUSE_PRINTF_POS_PARAMS 1
// Enable the use of compiler-specific thread local storage keyword, if any.
// This is used for wxTLS_XXX() macros implementation and normally should use
// the compiler-provided support as it's simpler and more efficient, but is
// disabled under Windows in wx/msw/chkconf.h as it can't be used if wxWidgets
// is used in a dynamically loaded Win32 DLL (i.e. using LoadLibrary()) under
// XP as this triggers a bug in compiler TLS support that results in crashes
// when any TLS variables are used.
//
// If you're absolutely sure that your build of wxWidgets is never going to be
// used in such situation, either because it's not going to be linked from any
// kind of plugin or because you only target Vista or later systems, you can
// set this to 2 to force the use of compiler TLS even under MSW.
//
// Default is 1 meaning that compiler TLS is used only if it's 100% safe.
//
// Recommended setting: 2 if you want to have maximal performance and don't
// care about the scenario described above.
#define wxUSE_COMPILER_TLS 1
// ----------------------------------------------------------------------------
// Interoperability with the standard library.
// ----------------------------------------------------------------------------
// Set wxUSE_STL to 1 to enable maximal interoperability with the standard
// library, even at the cost of backwards compatibility.
//
// Default is 0
//
// Recommended setting: 0 as the options below already provide a relatively
// good level of interoperability and changing this option arguably isn't worth
// diverging from the official builds of the library.
#define wxUSE_STL 0
// This is not a real option but is used as the default value for
// wxUSE_STD_IOSTREAM, wxUSE_STD_STRING and wxUSE_STD_CONTAINERS_COMPATIBLY.
//
// Set it to 0 if you want to disable the use of all standard classes
// completely for some reason.
#define wxUSE_STD_DEFAULT 1
// Use standard C++ containers where it can be done without breaking backwards
// compatibility.
//
// This provides better interoperability with the standard library, e.g. with
// this option on it's possible to insert std::vector<> into many wxWidgets
// containers directly.
//
// Default is 1.
//
// Recommended setting is 1 unless you want to avoid all dependencies on the
// standard library.
#define wxUSE_STD_CONTAINERS_COMPATIBLY wxUSE_STD_DEFAULT
// Use standard C++ containers to implement wxVector<>, wxStack<>, wxDList<>
// and wxHashXXX<> classes. If disabled, wxWidgets own (mostly compatible but
// usually more limited) implementations are used which allows to avoid the
// dependency on the C++ run-time library.
//
// Default is 0 for compatibility reasons.
//
// Recommended setting: 1 unless compatibility with the official wxWidgets
// build and/or the existing code is a concern.
#define wxUSE_STD_CONTAINERS 0
// Use standard C++ streams if 1 instead of wx streams in some places. If
// disabled, wx streams are used everywhere and wxWidgets doesn't depend on the
// standard streams library.
//
// Notice that enabling this does not replace wx streams with std streams
// everywhere, in a lot of places wx streams are used no matter what.
//
// Default is 1 if compiler supports it.
//
// Recommended setting: 1 if you use the standard streams anyhow and so
// dependency on the standard streams library is not a
// problem
#define wxUSE_STD_IOSTREAM wxUSE_STD_DEFAULT
// Enable minimal interoperability with the standard C++ string class if 1.
// "Minimal" means that wxString can be constructed from std::string or
// std::wstring but can't be implicitly converted to them. You need to enable
// the option below for the latter.
//
// Default is 1 for most compilers.
//
// Recommended setting: 1 unless you want to ensure your program doesn't use
// the standard C++ library at all.
#define wxUSE_STD_STRING wxUSE_STD_DEFAULT
// Make wxString as much interchangeable with std::[w]string as possible, in
// particular allow implicit conversion of wxString to either of these classes.
// This comes at a price (or a benefit, depending on your point of view) of not
// allowing implicit conversion to "const char *" and "const wchar_t *".
//
// Because a lot of existing code relies on these conversions, this option is
// disabled by default but can be enabled for your build if you don't care
// about compatibility.
//
// Default is 0 if wxUSE_STL has its default value or 1 if it is enabled.
//
// Recommended setting: 0 to remain compatible with the official builds of
// wxWidgets.
#define wxUSE_STD_STRING_CONV_IN_WXSTRING wxUSE_STL
// ----------------------------------------------------------------------------
// non GUI features selection
// ----------------------------------------------------------------------------
// Set wxUSE_LONGLONG to 1 to compile the wxLongLong class. This is a 64 bit
// integer which is implemented in terms of native 64 bit integers if any or
// uses emulation otherwise.
//
// This class is required by wxDateTime and so you should enable it if you want
// to use wxDateTime. For most modern platforms, it will use the native 64 bit
// integers in which case (almost) all of its functions are inline and it
// almost does not take any space, so there should be no reason to switch it
// off.
//
// Recommended setting: 1
#define wxUSE_LONGLONG 1
// Set wxUSE_BASE64 to 1, to compile in Base64 support. This is required for
// storing binary data in wxConfig on most platforms.
//
// Default is 1.
//
// Recommended setting: 1 (but can be safely disabled if you don't use it)
#define wxUSE_BASE64 1
// Set this to 1 to be able to use wxEventLoop even in console applications
// (i.e. using base library only, without GUI). This is mostly useful for
// processing socket events but is also necessary to use timers in console
// applications
//
// Default is 1.
//
// Recommended setting: 1 (but can be safely disabled if you don't use it)
#define wxUSE_CONSOLE_EVENTLOOP 1
// Set wxUSE_(F)FILE to 1 to compile wx(F)File classes. wxFile uses low level
// POSIX functions for file access, wxFFile uses ANSI C stdio.h functions.
//
// Default is 1
//
// Recommended setting: 1 (wxFile is highly recommended as it is required by
// i18n code, wxFileConfig and others)
#define wxUSE_FILE 1
#define wxUSE_FFILE 1
// Use wxFSVolume class providing access to the configured/active mount points
//
// Default is 1
//
// Recommended setting: 1 (but may be safely disabled if you don't use it)
#define wxUSE_FSVOLUME 1
// Use wxSecretStore class for storing passwords using OS-specific facilities.
//
// Default is 1
//
// Recommended setting: 1 (but may be safely disabled if you don't use it)
#define wxUSE_SECRETSTORE 1
// Use wxStandardPaths class which allows to retrieve some standard locations
// in the file system
//
// Default is 1
//
// Recommended setting: 1 (may be disabled to save space, but not much)
#define wxUSE_STDPATHS 1
// use wxTextBuffer class: required by wxTextFile
#define wxUSE_TEXTBUFFER 1
// use wxTextFile class: requires wxFile and wxTextBuffer, required by
// wxFileConfig
#define wxUSE_TEXTFILE 1
// i18n support: _() macro, wxLocale class. Requires wxTextFile.
#define wxUSE_INTL 1
// Provide wxFoo_l() functions similar to standard foo() functions but taking
// an extra locale parameter.
//
// Notice that this is fully implemented only for the systems providing POSIX
// xlocale support or Microsoft Visual C++ >= 8 (which provides proprietary
// almost-equivalent of xlocale functions), otherwise wxFoo_l() functions will
// only work for the current user locale and "C" locale. You can use
// wxHAS_XLOCALE_SUPPORT to test whether the full support is available.
//
// Default is 1
//
// Recommended setting: 1 but may be disabled if you are writing programs
// running only in C locale anyhow
#define wxUSE_XLOCALE 1
// Set wxUSE_DATETIME to 1 to compile the wxDateTime and related classes which
// allow to manipulate dates, times and time intervals.
//
// Requires: wxUSE_LONGLONG
//
// Default is 1
//
// Recommended setting: 1
#define wxUSE_DATETIME 1
// Set wxUSE_TIMER to 1 to compile wxTimer class
//
// Default is 1
//
// Recommended setting: 1
#define wxUSE_TIMER 1
// Use wxStopWatch clas.
//
// Default is 1
//
// Recommended setting: 1 (needed by wxSocket)
#define wxUSE_STOPWATCH 1
// Set wxUSE_FSWATCHER to 1 if you want to enable wxFileSystemWatcher
//
// Default is 1
//
// Recommended setting: 1
#define wxUSE_FSWATCHER 1
// Setting wxUSE_CONFIG to 1 enables the use of wxConfig and related classes
// which allow the application to store its settings in the persistent
// storage. Setting this to 1 will also enable on-demand creation of the
// global config object in wxApp.
//
// See also wxUSE_CONFIG_NATIVE below.
//
// Recommended setting: 1
#define wxUSE_CONFIG 1
// If wxUSE_CONFIG is 1, you may choose to use either the native config
// classes under Windows (using .INI files under Win16 and the registry under
// Win32) or the portable text file format used by the config classes under
// Unix.
//
// Default is 1 to use native classes. Note that you may still use
// wxFileConfig even if you set this to 1 - just the config object created by
// default for the applications needs will be a wxRegConfig or wxIniConfig and
// not wxFileConfig.
//
// Recommended setting: 1
#define wxUSE_CONFIG_NATIVE 1
// If wxUSE_DIALUP_MANAGER is 1, compile in wxDialUpManager class which allows
// to connect/disconnect from the network and be notified whenever the dial-up
// network connection is established/terminated. Requires wxUSE_DYNAMIC_LOADER.
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_DIALUP_MANAGER 1
// Compile in classes for run-time DLL loading and function calling.
// Required by wxUSE_DIALUP_MANAGER.
//
// This setting is for Win32 only
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_DYNLIB_CLASS 1
// experimental, don't use for now
#define wxUSE_DYNAMIC_LOADER 1
// Set to 1 to use socket classes
#define wxUSE_SOCKETS 1
// Set to 1 to use ipv6 socket classes (requires wxUSE_SOCKETS)
//
// Notice that currently setting this option under Windows will result in
// programs which can only run on recent OS versions (with ws2_32.dll
// installed) which is why it is disabled by default.
//
// Default is 1.
//
// Recommended setting: 1 if you need IPv6 support
#define wxUSE_IPV6 0
// Set to 1 to enable virtual file systems (required by wxHTML)
#define wxUSE_FILESYSTEM 1
// Set to 1 to enable virtual ZIP filesystem (requires wxUSE_FILESYSTEM)
#define wxUSE_FS_ZIP 1
// Set to 1 to enable virtual archive filesystem (requires wxUSE_FILESYSTEM)
#define wxUSE_FS_ARCHIVE 1
// Set to 1 to enable virtual Internet filesystem (requires wxUSE_FILESYSTEM)
#define wxUSE_FS_INET 1
// wxArchive classes for accessing archives such as zip and tar
#define wxUSE_ARCHIVE_STREAMS 1
// Set to 1 to compile wxZipInput/OutputStream classes.
#define wxUSE_ZIPSTREAM 1
// Set to 1 to compile wxTarInput/OutputStream classes.
#define wxUSE_TARSTREAM 1
// Set to 1 to compile wxZlibInput/OutputStream classes. Also required by
// wxUSE_LIBPNG
#define wxUSE_ZLIB 1
// Set to 1 if liblzma is available to enable wxLZMA{Input,Output}Stream
// classes.
//
// Notice that if you enable this build option when not using configure or
// CMake, you need to ensure that liblzma headers and libraries are available
// (i.e. by building the library yourself or downloading its binaries) and can
// be found, either by copying them to one of the locations searched by the
// compiler/linker by default (e.g. any of the directories in the INCLUDE or
// LIB environment variables, respectively, when using MSVC) or modify the
// make- or project files to add references to these directories.
//
// Default is 0 under MSW, auto-detected by configure.
//
// Recommended setting: 1 if you need LZMA compression.
#define wxUSE_LIBLZMA 0
// If enabled, the code written by Apple will be used to write, in a portable
// way, float on the disk. See extended.c for the license which is different
// from wxWidgets one.
//
// Default is 1.
//
// Recommended setting: 1 unless you don't like the license terms (unlikely)
#define wxUSE_APPLE_IEEE 1
// Joystick support class
#define wxUSE_JOYSTICK 1
// wxFontEnumerator class
#define wxUSE_FONTENUM 1
// wxFontMapper class
#define wxUSE_FONTMAP 1
// wxMimeTypesManager class
#define wxUSE_MIMETYPE 1
// wxProtocol and related classes: if you want to use either of wxFTP, wxHTTP
// or wxURL you need to set this to 1.
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_PROTOCOL 1
// The settings for the individual URL schemes
#define wxUSE_PROTOCOL_FILE 1
#define wxUSE_PROTOCOL_FTP 1
#define wxUSE_PROTOCOL_HTTP 1
// Define this to use wxURL class.
#define wxUSE_URL 1
// Define this to use native platform url and protocol support.
// Currently valid only for MS-Windows.
// Note: if you set this to 1, you can open ftp/http/gopher sites
// and obtain a valid input stream for these sites
// even when you set wxUSE_PROTOCOL_FTP/HTTP to 0.
// Doing so reduces the code size.
//
// This code is experimental and subject to change.
#define wxUSE_URL_NATIVE 0
// Support for wxVariant class used in several places throughout the library,
// notably in wxDataViewCtrl API.
//
// Default is 1.
//
// Recommended setting: 1 unless you want to reduce the library size as much as
// possible in which case setting this to 0 can gain up to 100KB.
#define wxUSE_VARIANT 1
// Support for wxAny class, the successor for wxVariant.
//
// Default is 1.
//
// Recommended setting: 1 unless you want to reduce the library size by a small amount,
// or your compiler cannot for some reason cope with complexity of templates used.
#define wxUSE_ANY 1
// Support for regular expression matching via wxRegEx class: enable this to
// use POSIX regular expressions in your code. You need to compile regex
// library from src/regex to use it under Windows.
//
// Default is 0
//
// Recommended setting: 1 if your compiler supports it, if it doesn't please
// contribute us a makefile for src/regex for it
#define wxUSE_REGEX 1
// wxSystemOptions class
#define wxUSE_SYSTEM_OPTIONS 1
// wxSound class
#define wxUSE_SOUND 1
// Use wxMediaCtrl
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_MEDIACTRL 1
// Use wxWidget's XRC XML-based resource system. Recommended.
//
// Default is 1
//
// Recommended setting: 1 (requires wxUSE_XML)
#define wxUSE_XRC 1
// XML parsing classes. Note that their API will change in the future, so
// using wxXmlDocument and wxXmlNode in your app is not recommended.
//
// Default is the same as wxUSE_XRC, i.e. 1 by default.
//
// Recommended setting: 1 (required by XRC)
#define wxUSE_XML wxUSE_XRC
// Use wxWidget's AUI docking system
//
// Default is 1
//
// Recommended setting: 1
#define wxUSE_AUI 1
// Use wxWidget's Ribbon classes for interfaces
//
// Default is 1
//
// Recommended setting: 1
#define wxUSE_RIBBON 1
// Use wxPropertyGrid.
//
// Default is 1
//
// Recommended setting: 1
#define wxUSE_PROPGRID 1
// Use wxStyledTextCtrl, a wxWidgets implementation of Scintilla.
//
// Default is 1
//
// Recommended setting: 1
#define wxUSE_STC 1
// Use wxWidget's web viewing classes
//
// Default is 1
//
// Recommended setting: 1
#define wxUSE_WEBVIEW 1
// Use the IE wxWebView backend
//
// Default is 1 on MSW
//
// Recommended setting: 1
#ifdef __WXMSW__
#define wxUSE_WEBVIEW_IE 1
#else
#define wxUSE_WEBVIEW_IE 0
#endif
// Use the WebKit wxWebView backend
//
// Default is 1 on GTK and OSX
//
// Recommended setting: 1
#if (defined(__WXGTK__) && !defined(__WXGTK3__)) || defined(__WXOSX__)
#define wxUSE_WEBVIEW_WEBKIT 1
#else
#define wxUSE_WEBVIEW_WEBKIT 0
#endif
// Use the WebKit2 wxWebView backend
//
// Default is 1 on GTK3
//
// Recommended setting: 1
#if defined(__WXGTK3__)
#define wxUSE_WEBVIEW_WEBKIT2 1
#else
#define wxUSE_WEBVIEW_WEBKIT2 0
#endif
// Enable wxGraphicsContext and related classes for a modern 2D drawing API.
//
// Default is 1 except if you're using a compiler without support for GDI+
// under MSW, i.e. gdiplus.h and related headers (MSVC and MinGW >= 4.8 are
// known to have them). For other compilers (e.g. older mingw32) you may need
// to install the headers (and just the headers) yourself. If you do, change
// the setting below manually.
//
// Recommended setting: 1 if supported by the compilation environment
// Notice that we can't use wxCHECK_VISUALC_VERSION() nor wxCHECK_GCC_VERSION()
// here as this file is included from wx/platform.h before they're defined.
#if defined(_MSC_VER) || \
(defined(__MINGW32__) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 8))
#define wxUSE_GRAPHICS_CONTEXT 1
#else
// Disable support for other Windows compilers, enable it if your compiler
// comes with new enough SDK or you installed the headers manually.
//
// Notice that this will be set by configure under non-Windows platforms
// anyhow so the value there is not important.
#define wxUSE_GRAPHICS_CONTEXT 0
#endif
// Enable wxGraphicsContext implementation using Cairo library.
//
// This is not needed under Windows and detected automatically by configure
// under other systems, however you may set this to 1 manually if you installed
// Cairo under Windows yourself and prefer to use it instead the native GDI+
// implementation.
//
// Default is 0
//
// Recommended setting: 0
#define wxUSE_CAIRO 0
// ----------------------------------------------------------------------------
// Individual GUI controls
// ----------------------------------------------------------------------------
// You must set wxUSE_CONTROLS to 1 if you are using any controls at all
// (without it, wxControl class is not compiled)
//
// Default is 1
//
// Recommended setting: 1 (don't change except for very special programs)
#define wxUSE_CONTROLS 1
// Support markup in control labels, i.e. provide wxControl::SetLabelMarkup().
// Currently markup is supported only by a few controls and only some ports but
// their number will increase with time.
//
// Default is 1
//
// Recommended setting: 1 (may be set to 0 if you want to save on code size)
#define wxUSE_MARKUP 1
// wxPopupWindow class is a top level transient window. It is currently used
// to implement wxTipWindow
//
// Default is 1
//
// Recommended setting: 1 (may be set to 0 if you don't wxUSE_TIPWINDOW)
#define wxUSE_POPUPWIN 1
// wxTipWindow allows to implement the custom tooltips, it is used by the
// context help classes. Requires wxUSE_POPUPWIN.
//
// Default is 1
//
// Recommended setting: 1 (may be set to 0)
#define wxUSE_TIPWINDOW 1
// Each of the settings below corresponds to one wxWidgets control. They are
// all switched on by default but may be disabled if you are sure that your
// program (including any standard dialogs it can show!) doesn't need them and
// if you desperately want to save some space. If you use any of these you must
// set wxUSE_CONTROLS as well.
//
// Default is 1
//
// Recommended setting: 1
#define wxUSE_ACTIVITYINDICATOR 1 // wxActivityIndicator
#define wxUSE_ANIMATIONCTRL 1 // wxAnimationCtrl
#define wxUSE_BANNERWINDOW 1 // wxBannerWindow
#define wxUSE_BUTTON 1 // wxButton
#define wxUSE_BMPBUTTON 1 // wxBitmapButton
#define wxUSE_CALENDARCTRL 1 // wxCalendarCtrl
#define wxUSE_CHECKBOX 1 // wxCheckBox
#define wxUSE_CHECKLISTBOX 1 // wxCheckListBox (requires wxUSE_OWNER_DRAWN)
#define wxUSE_CHOICE 1 // wxChoice
#define wxUSE_COLLPANE 1 // wxCollapsiblePane
#define wxUSE_COLOURPICKERCTRL 1 // wxColourPickerCtrl
#define wxUSE_COMBOBOX 1 // wxComboBox
#define wxUSE_COMMANDLINKBUTTON 1 // wxCommandLinkButton
#define wxUSE_DATAVIEWCTRL 1 // wxDataViewCtrl
#define wxUSE_DATEPICKCTRL 1 // wxDatePickerCtrl
#define wxUSE_DIRPICKERCTRL 1 // wxDirPickerCtrl
#define wxUSE_EDITABLELISTBOX 1 // wxEditableListBox
#define wxUSE_FILECTRL 1 // wxFileCtrl
#define wxUSE_FILEPICKERCTRL 1 // wxFilePickerCtrl
#define wxUSE_FONTPICKERCTRL 1 // wxFontPickerCtrl
#define wxUSE_GAUGE 1 // wxGauge
#define wxUSE_HEADERCTRL 1 // wxHeaderCtrl
#define wxUSE_HYPERLINKCTRL 1 // wxHyperlinkCtrl
#define wxUSE_LISTBOX 1 // wxListBox
#define wxUSE_LISTCTRL 1 // wxListCtrl
#define wxUSE_RADIOBOX 1 // wxRadioBox
#define wxUSE_RADIOBTN 1 // wxRadioButton
#define wxUSE_RICHMSGDLG 1 // wxRichMessageDialog
#define wxUSE_SCROLLBAR 1 // wxScrollBar
#define wxUSE_SEARCHCTRL 1 // wxSearchCtrl
#define wxUSE_SLIDER 1 // wxSlider
#define wxUSE_SPINBTN 1 // wxSpinButton
#define wxUSE_SPINCTRL 1 // wxSpinCtrl
#define wxUSE_STATBOX 1 // wxStaticBox
#define wxUSE_STATLINE 1 // wxStaticLine
#define wxUSE_STATTEXT 1 // wxStaticText
#define wxUSE_STATBMP 1 // wxStaticBitmap
#define wxUSE_TEXTCTRL 1 // wxTextCtrl
#define wxUSE_TIMEPICKCTRL 1 // wxTimePickerCtrl
#define wxUSE_TOGGLEBTN 1 // requires wxButton
#define wxUSE_TREECTRL 1 // wxTreeCtrl
#define wxUSE_TREELISTCTRL 1 // wxTreeListCtrl
// Use a status bar class? Depending on the value of wxUSE_NATIVE_STATUSBAR
// below either wxStatusBar95 or a generic wxStatusBar will be used.
//
// Default is 1
//
// Recommended setting: 1
#define wxUSE_STATUSBAR 1
// Two status bar implementations are available under Win32: the generic one
// or the wrapper around native control. For native look and feel the native
// version should be used.
//
// Default is 1 for the platforms where native status bar is supported.
//
// Recommended setting: 1 (there is no advantage in using the generic one)
#define wxUSE_NATIVE_STATUSBAR 1
// wxToolBar related settings: if wxUSE_TOOLBAR is 0, don't compile any toolbar
// classes at all. Otherwise, use the native toolbar class unless
// wxUSE_TOOLBAR_NATIVE is 0.
//
// Default is 1 for all settings.
//
// Recommended setting: 1 for wxUSE_TOOLBAR and wxUSE_TOOLBAR_NATIVE.
#define wxUSE_TOOLBAR 1
#define wxUSE_TOOLBAR_NATIVE 1
// wxNotebook is a control with several "tabs" located on one of its sides. It
// may be used to logically organise the data presented to the user instead of
// putting everything in one huge dialog. It replaces wxTabControl and related
// classes of wxWin 1.6x.
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_NOTEBOOK 1
// wxListbook control is similar to wxNotebook but uses wxListCtrl instead of
// the tabs
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_LISTBOOK 1
// wxChoicebook control is similar to wxNotebook but uses wxChoice instead of
// the tabs
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_CHOICEBOOK 1
// wxTreebook control is similar to wxNotebook but uses wxTreeCtrl instead of
// the tabs
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_TREEBOOK 1
// wxToolbook control is similar to wxNotebook but uses wxToolBar instead of
// tabs
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_TOOLBOOK 1
// wxTaskBarIcon is a small notification icon shown in the system toolbar or
// dock.
//
// Default is 1.
//
// Recommended setting: 1 (but can be set to 0 if you don't need it)
#define wxUSE_TASKBARICON 1
// wxGrid class
//
// Default is 1, set to 0 to cut down compilation time and binaries size if you
// don't use it.
//
// Recommended setting: 1
//
#define wxUSE_GRID 1
// wxMiniFrame class: a frame with narrow title bar
//
// Default is 1.
//
// Recommended setting: 1 (it doesn't cost almost anything)
#define wxUSE_MINIFRAME 1
// wxComboCtrl and related classes: combobox with custom popup window and
// not necessarily a listbox.
//
// Default is 1.
//
// Recommended setting: 1 but can be safely set to 0 except for wxUniv where it
// it used by wxComboBox
#define wxUSE_COMBOCTRL 1
// wxOwnerDrawnComboBox is a custom combobox allowing to paint the combobox
// items.
//
// Default is 1.
//
// Recommended setting: 1 but can be safely set to 0, except where it is
// needed as a base class for generic wxBitmapComboBox.
#define wxUSE_ODCOMBOBOX 1
// wxBitmapComboBox is a combobox that can have images in front of text items.
//
// Default is 1.
//
// Recommended setting: 1 but can be safely set to 0
#define wxUSE_BITMAPCOMBOBOX 1
// wxRearrangeCtrl is a wxCheckListBox with two buttons allowing to move items
// up and down in it. It is also used as part of wxRearrangeDialog.
//
// Default is 1.
//
// Recommended setting: 1 but can be safely set to 0 (currently used only by
// wxHeaderCtrl)
#define wxUSE_REARRANGECTRL 1
// wxAddRemoveCtrl is a composite control containing a control showing some
// items (e.g. wxListBox, wxListCtrl, wxTreeCtrl, wxDataViewCtrl, ...) and "+"/
// "-" buttons allowing to add and remove items to/from the control.
//
// Default is 1.
//
// Recommended setting: 1 but can be safely set to 0 if you don't need it (not
// used by the library itself).
#define wxUSE_ADDREMOVECTRL 1
// ----------------------------------------------------------------------------
// Miscellaneous GUI stuff
// ----------------------------------------------------------------------------
// wxAcceleratorTable/Entry classes and support for them in wxMenu(Bar)
#define wxUSE_ACCEL 1
// Use the standard art provider. The icons returned by this provider are
// embedded into the library as XPMs so disabling it reduces the library size
// somewhat but this should only be done if you use your own custom art
// provider returning the icons or never use any icons not provided by the
// native art provider (which might not be implemented at all for some
// platforms) or by the Tango icons provider (if it's not itself disabled
// below).
//
// Default is 1.
//
// Recommended setting: 1 unless you use your own custom art provider.
#define wxUSE_ARTPROVIDER_STD 1
// Use art provider providing Tango icons: this art provider has higher quality
// icons than the default ones using smaller size XPM icons without
// transparency but the embedded PNG icons add to the library size.
//
// Default is 1 under non-GTK ports. Under wxGTK the native art provider using
// the GTK+ stock icons replaces it so it is normally not necessary.
//
// Recommended setting: 1 but can be turned off to reduce the library size.
#define wxUSE_ARTPROVIDER_TANGO 1
// Hotkey support (currently Windows only)
#define wxUSE_HOTKEY 1
// Use wxCaret: a class implementing a "cursor" in a text control (called caret
// under Windows).
//
// Default is 1.
//
// Recommended setting: 1 (can be safely set to 0, not used by the library)
#define wxUSE_CARET 1
// Use wxDisplay class: it allows enumerating all displays on a system and
// their geometries as well as finding the display on which the given point or
// window lies.
//
// Default is 1.
//
// Recommended setting: 1 if you need it, can be safely set to 0 otherwise
#define wxUSE_DISPLAY 1
// Miscellaneous geometry code: needed for Canvas library
#define wxUSE_GEOMETRY 1
// Use wxImageList. This class is needed by wxNotebook, wxTreeCtrl and
// wxListCtrl.
//
// Default is 1.
//
// Recommended setting: 1 (set it to 0 if you don't use any of the controls
// enumerated above, then this class is mostly useless too)
#define wxUSE_IMAGLIST 1
// Use wxInfoBar class.
//
// Default is 1.
//
// Recommended setting: 1 (but can be disabled without problems as nothing
// depends on it)
#define wxUSE_INFOBAR 1
// Use wxMenu, wxMenuBar, wxMenuItem.
//
// Default is 1.
//
// Recommended setting: 1 (can't be disabled under MSW)
#define wxUSE_MENUS 1
// Use wxNotificationMessage.
//
// wxNotificationMessage allows to show non-intrusive messages to the user
// using balloons, banners, popups or whatever is the appropriate method for
// the current platform.
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_NOTIFICATION_MESSAGE 1
// wxPreferencesEditor provides a common API for different ways of presenting
// the standard "Preferences" or "Properties" dialog under different platforms
// (e.g. some use modal dialogs, some use modeless ones; some apply the changes
// immediately while others require an explicit "Apply" button).
//
// Default is 1.
//
// Recommended setting: 1 (but can be safely disabled if you don't use it)
#define wxUSE_PREFERENCES_EDITOR 1
// wxFont::AddPrivateFont() allows to use fonts not installed on the system by
// loading them from font files during run-time.
//
// Default is 1 except under Unix where it will be turned off by configure if
// the required libraries are not available or not new enough.
//
// Recommended setting: 1 (but can be safely disabled if you don't use it and
// want to avoid extra dependencies under Linux, for example).
#define wxUSE_PRIVATE_FONTS 1
// wxRichToolTip is a customizable tooltip class which has more functionality
// than the stock (but native, unlike this class) wxToolTip.
//
// Default is 1.
//
// Recommended setting: 1 (but can be safely set to 0 if you don't need it)
#define wxUSE_RICHTOOLTIP 1
// Use wxSashWindow class.
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_SASH 1
// Use wxSplitterWindow class.
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_SPLITTER 1
// Use wxToolTip and wxWindow::Set/GetToolTip() methods.
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_TOOLTIPS 1
// wxValidator class and related methods
#define wxUSE_VALIDATORS 1
// Use reference counted ID management: this means that wxWidgets will track
// the automatically allocated ids (those used when you use wxID_ANY when
// creating a window, menu or toolbar item &c) instead of just supposing that
// the program never runs out of them. This is mostly useful only under wxMSW
// where the total ids range is limited to SHRT_MIN..SHRT_MAX and where
// long-running programs can run into problems with ids reuse without this. On
// the other platforms, where the ids have the full int range, this shouldn't
// be necessary.
#ifdef __WXMSW__
#define wxUSE_AUTOID_MANAGEMENT 1
#else
#define wxUSE_AUTOID_MANAGEMENT 0
#endif
// ----------------------------------------------------------------------------
// common dialogs
// ----------------------------------------------------------------------------
// On rare occasions (e.g. using DJGPP) may want to omit common dialogs (e.g.
// file selector, printer dialog). Switching this off also switches off the
// printing architecture and interactive wxPrinterDC.
//
// Default is 1
//
// Recommended setting: 1 (unless it really doesn't work)
#define wxUSE_COMMON_DIALOGS 1
// wxBusyInfo displays window with message when app is busy. Works in same way
// as wxBusyCursor
#define wxUSE_BUSYINFO 1
// Use single/multiple choice dialogs.
//
// Default is 1
//
// Recommended setting: 1 (used in the library itself)
#define wxUSE_CHOICEDLG 1
// Use colour picker dialog
//
// Default is 1
//
// Recommended setting: 1
#define wxUSE_COLOURDLG 1
// wxDirDlg class for getting a directory name from user
#define wxUSE_DIRDLG 1
// TODO: setting to choose the generic or native one
// Use file open/save dialogs.
//
// Default is 1
//
// Recommended setting: 1 (used in many places in the library itself)
#define wxUSE_FILEDLG 1
// Use find/replace dialogs.
//
// Default is 1
//
// Recommended setting: 1 (but may be safely set to 0)
#define wxUSE_FINDREPLDLG 1
// Use font picker dialog
//
// Default is 1
//
// Recommended setting: 1 (used in the library itself)
#define wxUSE_FONTDLG 1
// Use wxMessageDialog and wxMessageBox.
//
// Default is 1
//
// Recommended setting: 1 (used in the library itself)
#define wxUSE_MSGDLG 1
// progress dialog class for lengthy operations
#define wxUSE_PROGRESSDLG 1
// Set to 0 to disable the use of the native progress dialog (currently only
// available under MSW and suffering from some bugs there, hence this option).
#define wxUSE_NATIVE_PROGRESSDLG 1
// support for startup tips (wxShowTip &c)
#define wxUSE_STARTUP_TIPS 1
// text entry dialog and wxGetTextFromUser function
#define wxUSE_TEXTDLG 1
// number entry dialog
#define wxUSE_NUMBERDLG 1
// splash screen class
#define wxUSE_SPLASH 1
// wizards
#define wxUSE_WIZARDDLG 1
// Compile in wxAboutBox() function showing the standard "About" dialog.
//
// Default is 1
//
// Recommended setting: 1 but can be set to 0 to save some space if you don't
// use this function
#define wxUSE_ABOUTDLG 1
// wxFileHistory class
//
// Default is 1
//
// Recommended setting: 1
#define wxUSE_FILE_HISTORY 1
// ----------------------------------------------------------------------------
// Metafiles support
// ----------------------------------------------------------------------------
// Windows supports the graphics format known as metafile which, though not
// portable, is widely used under Windows and so is supported by wxWidgets
// (under Windows only, of course). Both the so-called "Window MetaFiles" or
// WMFs, and "Enhanced MetaFiles" or EMFs are supported in wxWin and, by
// default, EMFs will be used. This may be changed by setting
// wxUSE_WIN_METAFILES_ALWAYS to 1 and/or setting wxUSE_ENH_METAFILE to 0.
// You may also set wxUSE_METAFILE to 0 to not compile in any metafile
// related classes at all.
//
// Default is 1 for wxUSE_ENH_METAFILE and 0 for wxUSE_WIN_METAFILES_ALWAYS.
//
// Recommended setting: default or 0 for everything for portable programs.
#define wxUSE_METAFILE 1
#define wxUSE_ENH_METAFILE 1
#define wxUSE_WIN_METAFILES_ALWAYS 0
// ----------------------------------------------------------------------------
// Big GUI components
// ----------------------------------------------------------------------------
// Set to 0 to disable MDI support.
//
// Requires wxUSE_NOTEBOOK under platforms other than MSW.
//
// Default is 1.
//
// Recommended setting: 1, can be safely set to 0.
#define wxUSE_MDI 1
// Set to 0 to disable document/view architecture
#define wxUSE_DOC_VIEW_ARCHITECTURE 1
// Set to 0 to disable MDI document/view architecture
//
// Requires wxUSE_MDI && wxUSE_DOC_VIEW_ARCHITECTURE
#define wxUSE_MDI_ARCHITECTURE 1
// Set to 0 to disable print/preview architecture code
#define wxUSE_PRINTING_ARCHITECTURE 1
// wxHTML sublibrary allows to display HTML in wxWindow programs and much,
// much more.
//
// Default is 1.
//
// Recommended setting: 1 (wxHTML is great!), set to 0 if you want compile a
// smaller library.
#define wxUSE_HTML 1
// Setting wxUSE_GLCANVAS to 1 enables OpenGL support. You need to have OpenGL
// headers and libraries to be able to compile the library with wxUSE_GLCANVAS
// set to 1 and, under Windows, also to add opengl32.lib and glu32.lib to the
// list of libraries used to link your application (although this is done
// implicitly for Microsoft Visual C++ users).
//
// Default is 1.
//
// Recommended setting: 1 if you intend to use OpenGL, can be safely set to 0
// otherwise.
#define wxUSE_GLCANVAS 1
// wxRichTextCtrl allows editing of styled text.
//
// Default is 1.
//
// Recommended setting: 1, set to 0 if you want compile a
// smaller library.
#define wxUSE_RICHTEXT 1
// ----------------------------------------------------------------------------
// Data transfer
// ----------------------------------------------------------------------------
// Use wxClipboard class for clipboard copy/paste.
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_CLIPBOARD 1
// Use wxDataObject and related classes. Needed for clipboard and OLE drag and
// drop
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_DATAOBJ 1
// Use wxDropTarget and wxDropSource classes for drag and drop (this is
// different from "built in" drag and drop in wxTreeCtrl which is always
// available). Requires wxUSE_DATAOBJ.
//
// Default is 1.
//
// Recommended setting: 1
#define wxUSE_DRAG_AND_DROP 1
// Use wxAccessible for enhanced and customisable accessibility.
// Depends on wxUSE_OLE on MSW.
//
// Default is 1 on MSW, 0 elsewhere.
//
// Recommended setting (at present): 1 (MSW-only)
#ifdef __WXMSW__
#define wxUSE_ACCESSIBILITY 1
#else
#define wxUSE_ACCESSIBILITY 0
#endif
// ----------------------------------------------------------------------------
// miscellaneous settings
// ----------------------------------------------------------------------------
// wxSingleInstanceChecker class allows to verify at startup if another program
// instance is running.
//
// Default is 1
//
// Recommended setting: 1 (the class is tiny, disabling it won't save much
// space)
#define wxUSE_SNGLINST_CHECKER 1
#define wxUSE_DRAGIMAGE 1
#define wxUSE_IPC 1
// 0 for no interprocess comms
#define wxUSE_HELP 1
// 0 for no help facility
// Should we use MS HTML help for wxHelpController? If disabled, neither
// wxCHMHelpController nor wxBestHelpController are available.
//
// Default is 1 under MSW, 0 is always used for the other platforms.
//
// Recommended setting: 1, only set to 0 if you have trouble compiling
// wxCHMHelpController (could be a problem with really ancient compilers)
#define wxUSE_MS_HTML_HELP 1
// Use wxHTML-based help controller?
#define wxUSE_WXHTML_HELP 1
#define wxUSE_CONSTRAINTS 1
// 0 for no window layout constraint system
#define wxUSE_SPLINES 1
// 0 for no splines
#define wxUSE_MOUSEWHEEL 1
// Include mouse wheel support
// Compile wxUIActionSimulator class?
#define wxUSE_UIACTIONSIMULATOR 1
// ----------------------------------------------------------------------------
// wxDC classes for various output formats
// ----------------------------------------------------------------------------
// Set to 1 for PostScript device context.
#define wxUSE_POSTSCRIPT 0
// Set to 1 to use font metric files in GetTextExtent
#define wxUSE_AFM_FOR_POSTSCRIPT 1
// Set to 1 to compile in support for wxSVGFileDC, a wxDC subclass which allows
// to create files in SVG (Scalable Vector Graphics) format.
#define wxUSE_SVG 1
// Should wxDC provide SetTransformMatrix() and related methods?
//
// Default is 1 but can be set to 0 if this functionality is not used. Notice
// that currently wxMSW, wxGTK3 support this for wxDC and all platforms support
// this for wxGCDC so setting this to 0 doesn't change much if neither of these
// is used (although it will still save a few bytes probably).
//
// Recommended setting: 1.
#define wxUSE_DC_TRANSFORM_MATRIX 1
// ----------------------------------------------------------------------------
// image format support
// ----------------------------------------------------------------------------
// wxImage supports many different image formats which can be configured at
// compile-time. BMP is always supported, others are optional and can be safely
// disabled if you don't plan to use images in such format sometimes saving
// substantial amount of code in the final library.
//
// Some formats require an extra library which is included in wxWin sources
// which is mentioned if it is the case.
// Set to 1 for wxImage support (recommended).
#define wxUSE_IMAGE 1
// Set to 1 for PNG format support (requires libpng). Also requires wxUSE_ZLIB.
#define wxUSE_LIBPNG 1
// Set to 1 for JPEG format support (requires libjpeg)
#define wxUSE_LIBJPEG 1
// Set to 1 for TIFF format support (requires libtiff)
#define wxUSE_LIBTIFF 1
// Set to 1 for TGA format support (loading only)
#define wxUSE_TGA 1
// Set to 1 for GIF format support
#define wxUSE_GIF 1
// Set to 1 for PNM format support
#define wxUSE_PNM 1
// Set to 1 for PCX format support
#define wxUSE_PCX 1
// Set to 1 for IFF format support (Amiga format)
#define wxUSE_IFF 0
// Set to 1 for XPM format support
#define wxUSE_XPM 1
// Set to 1 for MS Icons and Cursors format support
#define wxUSE_ICO_CUR 1
// Set to 1 to compile in wxPalette class
#define wxUSE_PALETTE 1
// ----------------------------------------------------------------------------
// wxUniversal-only options
// ----------------------------------------------------------------------------
// Set to 1 to enable compilation of all themes, this is the default
#define wxUSE_ALL_THEMES 1
// Set to 1 to enable the compilation of individual theme if wxUSE_ALL_THEMES
// is unset, if it is set these options are not used; notice that metal theme
// uses Win32 one
#define wxUSE_THEME_GTK 0
#define wxUSE_THEME_METAL 0
#define wxUSE_THEME_MONO 0
#define wxUSE_THEME_WIN32 0
| [
"hello@kusti8.com"
] | hello@kusti8.com |
5d741924b68c9308135abe78a0e1117142ecfdf6 | 6884432907ed4e06937df29d198ae92ce29e94ae | /read_tmva/reader.h | b704be1f202cb0d2dbbf5141f924dd3aafcf9687 | [] | no_license | heymanwasup/MVA | 99578c7031eebe8ed5dea664c7d0bb06031d861e | c9c0d54c0cafa96c1e0d6dbbf80ded5799e6768d | refs/heads/master | 2021-01-02T23:50:54.815338 | 2017-08-29T13:07:15 | 2017-08-29T13:07:15 | 99,508,266 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,267 | h | #include <TMVA/Reader.h>
typedef map<string,float> dict_s2f;
typedef map<string,double> dict_s2d;
bool debug = 0;
TTree * GetTree(string tag)
{
string path = "./data/";
TFile * f = TFile::Open((path+tag+".root").c_str());
TTree * t = (TTree*) f->Get("Nominal");
return t;
}
void BookTree(TTree* tree, dict_s2d& tree_vars )
{
vector<string> all_vars = { "MET","HT","dPhiMETdijet","pTB1","pTB2","mBB","dRBB","dEtaBB","pTJ3","mBBJ" ,"nJ","EventNumberMod2","EventWeight"};
for (string var : all_vars){
tree_vars[var] = 0.;
tree -> SetBranchAddress(var.c_str(),&tree_vars[var]);
}
}
void BookReader(TMVA::Reader* reader, dict_s2f& reader_vars )
{
vector<string> vars = { "MET","HT","dPhiMETdijet","pTB1","pTB2","mBB","dRBB","dEtaBB","pTJ3","mBBJ" };
vector<string> spec = {"nJ","EventNumberMod2"};
for(string var : vars){
reader -> AddVariable(var, &reader_vars[var]);
}
for(string var : spec){
reader -> AddSpectator(var, &reader_vars[var]);
}
reader -> BookMVA("BDT","/afs/cern.ch/user/c/chenc/public/forChangqiao/TMVAClassification_BDTCategories_mva28.weights.xml");
}
void GetEntry(TTree* tree, int n, dict_s2f & reader_vars,dict_s2d& tree_vars )
{
vector<string> vars = { "MET","HT","dPhiMETdijet","pTB1","pTB2","mBB","dRBB","dEtaBB","pTJ3","mBBJ" ,"nJ"};
tree->GetEntry(n);
for (string var : vars){
reader_vars[var] = (float) tree_vars[var];
}
reader_vars["EventNumberMod2"] = ((tree_vars["EventNumberMod2"] == 0.) ? 2. : 1.);
}
template <class T>
void Show( T & vars)
{
for (auto item : vars){
cout <<item.first << "=" << item.second <<endl;
}
}
void ShowInfo(TTree* tree, int n, dict_s2f & reader_vars,dict_s2d& tree_vars )
{
tree->Show(n);
cout <<"-------------------\n"<<endl;
cout <<"reader vars:"<<endl;
Show<dict_s2f>(reader_vars);
cout <<"-------------------\n"<<endl;
cout <<"\ntree vars:"<<endl;
Show<dict_s2d>(tree_vars);
cout <<"-------------------\n"<<endl;
}
void CreateOutputStream(TFile* &file, TH1F* &hist, string tag)
{
file = new TFile (("./data/out_"+tag+".root").c_str(),"recreate");
file -> cd();
hist = new TH1F(("h_"+tag).c_str(),("h_"+tag).c_str(),20000,-2,2);
}
void init_mva(string tag,TMVA::Reader *& reader, TTree *& tree, TFile *& file, TH1F *& hist, dict_s2f & reader_vars,dict_s2d & tree_vars,string input, string xml)
{
reader = new TMVA::Reader();
string path = "./data/";
TFile * f = TFile::Open((path+tag+".root").c_str());
tree = (TTree*) f->Get("Nominal");
BookTree(tree,tree_vars);
BookReader(reader,reader_vars);
file = new TFile (("./data/out_"+tag+".root").c_str(),"recreate");
hist = new TH1F(("h_"+tag).c_str(),("h_"+tag).c_str(),20000,-2,2);
}
void fill_mva(string tag,TMVA::Reader *& reader, TTree *& tree, TFile *& file, TH1F *& hist, dict_s2f & reader_vars,dict_s2d & tree_vars)
{
int N = tree -> GetEntries();
for (int n=0;n<N;n++) {
GetEntry(tree,n,reader_vars,tree_vars);
if (n==0){
ShowInfo(tree,n,reader_vars,tree_vars);
}
float mva = reader -> EvaluateMVA("BDT");
hist -> Fill(mva,tree_vars["EventWeight"]);
//cout << mva << tree_vars["EventWeight"] << endl;
}
file->cd();
hist->Write();
file->Close();
}
#define P(var) cout << #var << " " << var <<endl
void init_roc(TFile* &out,TH1F* &roc,TH1F* &sig,TH1F* &bkg)
{
TFile * fsig = TFile::Open("./data/out_signal.root");
TFile * fbkg = TFile::Open("./data/out_background.root");
sig = (TH1F*)fsig -> Get("h_signal");
bkg = (TH1F*)fbkg -> Get("h_background");
out = new TFile("./data/out_roc.root","recreate");
roc = new TH1F("roc","roc",100,0,1);
P(out);
P(roc);
P(fsig);
P(fbkg);
P(sig);
P(bkg);
}
TH1F* reverse_h(TH1F* h)
{
TH1F * res = (TH1F*)h -> Clone();
int N = h -> GetNbinsX();
for (int n=0;n<N;n++)
{
res->SetBinContent(N-n,h->GetBinContent(n+1));
res->SetBinError(N-n,h->GetBinError(n+1));
}
return res;
}
void fill_roc(TFile* out,TH1F* roc,TH1F* sig,TH1F* bkg,bool reverse=false)
{
// print the pointers
/*
P(out);
P(roc);
P(sig);
P(bkg);
*/
float sum_sig = sig -> Integral();
float sum_bkg = bkg -> Integral();
int nBin = 0;
int N = sig -> GetNbinsX();
if(debug) cout << " num of bins : "<< N <<endl;
TH1F * temp_sig;
TH1F * temp_bkg;
if(reverse){
temp_sig = reverse_h(sig);
temp_bkg = reverse_h(bkg);
} else {
temp_sig = sig;
temp_bkg = bkg;
}
for(int n=N;n>0;n--)
{
float bin_center = nBin*0.01 + 0.005;
float sig_eff_1 = temp_sig -> Integral(n,N)/sum_sig;
float bkg_rej_1 = temp_bkg -> Integral(0,n-1)/sum_bkg;
float diff_1 = abs(bin_center - sig_eff_1);
float sig_eff_2 = temp_sig -> Integral(n-1,N)/sum_sig;
float bkg_rej_2 = temp_bkg -> Integral(0,n-2)/sum_bkg;
float diff_2 = abs(bin_center - sig_eff_2);
if (debug) {
P( bin_center );
P( sig_eff_1 );
P( bkg_rej_1 );
P( diff_1 );
P( sig_eff_2 );
P( bkg_rej_2 );
P( diff_2 );
cout << "-------------------------"<<endl;
}
if (diff_2 > diff_1){
roc -> SetBinContent(nBin+1,bkg_rej_1);
roc -> SetBinError(nBin+1,0);
nBin++;
}
}
out -> cd();
roc -> Write();
// out -> Close();
}
| [
"cheng.chen@cern.ch"
] | cheng.chen@cern.ch |
3be3a615da028bf9531c971908a3064d5db6b9ec | cf1911723d07048c4180ace63afbd6ae60727eb0 | /nnnUtilLib/mysavefolder.cpp | fe1aeab39ca3a2eccd8a73f5d87a5c09eb03da65 | [] | no_license | tinyan/SystemNNN | 57490606973d95aa1e65d6090957b0e25c5b89f8 | 07e18ded880a0998bf5560c05c112b5520653e19 | refs/heads/master | 2023-05-04T17:30:42.406037 | 2023-04-16T03:38:40 | 2023-04-16T03:38:40 | 7,564,789 | 13 | 2 | null | null | null | null | SHIFT_JIS | C++ | false | false | 11,513 | cpp | #include <windows.h>
//#define _ASAKI_PATCH_DEBUG_
#if defined _ASAKI_PATCH_DEBUG_
#else
//#include <shfolder.h>
#include <shlobj.h>
#endif
#include "mySaveFolder.h"
int CMySaveFolder::m_folderType = 0;
BOOL CMySaveFolder::m_createFolderNameFlag = FALSE;
char CMySaveFolder::m_userFolder[1024] = {0};
char CMySaveFolder::m_companyFolder[1024] = {0};
char CMySaveFolder::m_gameFolder[1024] = {0};
char CMySaveFolder::m_fullFolder[1024] = "sav";
char CMySaveFolder::m_companyName[1024] = {0};
char CMySaveFolder::m_gameName[1024] = {0};
char CMySaveFolder::m_saveName[1024] = "sav";
CMySaveFolder::CMySaveFolder()
{
}
CMySaveFolder::~CMySaveFolder()
{
End();
}
void CMySaveFolder::End(void)
{
}
void CMySaveFolder::SetModify(BOOL flg)
{
if (flg)
{
m_createFolderNameFlag = FALSE;
}
}
LPSTR CMySaveFolder::GetUserFolder(void)
{
CreateAllFolderName();
return m_userFolder;
}
LPSTR CMySaveFolder::GetCompanyFolder(void)
{
CreateAllFolderName();
return m_companyFolder;
}
LPSTR CMySaveFolder::GetGameFolder(void)
{
CreateAllFolderName();
return m_gameFolder;
}
LPSTR CMySaveFolder::GetFullFolder(void)
{
CreateAllFolderName();
return m_fullFolder;
}
void CMySaveFolder::ChangeMyFolder(LPSTR companyFolder,LPSTR gameFolder,int type)
{
if (type == MYFOLDER_TYPE_CURRENT)
{
ChangeFolderType(type);
ChangeCompanyFolder(NULL);
ChangeGameFolder(NULL);
}
else
{
ChangeFolderType(type);
ChangeCompanyFolder(companyFolder);
ChangeGameFolder(gameFolder);
}
SetModify();
CreateAllFolderName();
}
void CMySaveFolder::ChangeFolderType(int type,BOOL remakeFlag)
{
m_folderType = type;
SetModify();
#if defined _ASAKI_PATCH_DEBUG_
m_userFolder[0] = 0;
#else
char szPath[_MAX_PATH];
LPITEMIDLIST pidl;
HWND hWnd = NULL;
IMalloc *pMalloc;
if (m_folderType == MYFOLDER_TYPE_CURRENT)
{
m_userFolder[0] = 0;
}
else
{
SHGetMalloc( &pMalloc );
BOOL flg = FALSE;
if (m_folderType == MYFOLDER_TYPE_MYDOCUMENT)
{
if( SUCCEEDED(SHGetSpecialFolderLocation(hWnd,CSIDL_PERSONAL,&pidl)))
{
flg = TRUE;
}
}
else if (SUCCEEDED(SHGetSpecialFolderLocation(hWnd,CSIDL_APPDATA,&pidl)))
{
flg = TRUE;
}
if (flg)
{
SHGetPathFromIDList(pidl,szPath); // パスに変換する
pMalloc->Free(pidl); // 取得したIDLを解放する (CoTaskMemFreeでも可)
int ln = (int)strlen(szPath);
if (ln>1022) ln = 1022;
memcpy(m_userFolder,szPath,ln);
m_userFolder[ln] = 0;
m_userFolder[ln+1] = 0;
}
pMalloc->Release();
}
#endif
// else if (m_folderType == MYFOLDER_TYPE_MYDOCUMENT)
// {
// SHGetFolderPath(NULL,CSIDL_PERSONAL ,NULL,0,m_userFolder);
// }
// else if (m_folderType == MYFOLDER_TYPE_APPDATA)
// {
// SHGetFolderPath(NULL,CSIDL_APPDATA ,NULL,0,m_userFolder);
// }
if (remakeFlag)
{
CreateAllFolderName();
}
}
void CMySaveFolder::ChangeCompanyFolder(LPSTR companyFolder,BOOL remakeFlag)
{
if (companyFolder == NULL)
{
m_companyName[0] = 0;
}
else
{
int ln = (int)strlen(companyFolder);
if (ln>126) ln = 126;
memcpy(m_companyName,companyFolder,ln+1);
m_companyName[ln+1] = 0;
}
SetModify();
if (remakeFlag)
{
CreateAllFolderName();
}
}
void CMySaveFolder::ChangeGameFolder(LPSTR gameFolder,BOOL remakeFlag)
{
if (gameFolder == NULL)
{
m_gameName[0] = 0;
}
else
{
int ln = (int)strlen(gameFolder);
if (ln>254) ln = 254;
memcpy(m_gameName,gameFolder,ln+1);
m_gameName[ln+1] = 0;
}
SetModify();
if (remakeFlag)
{
CreateAllFolderName();
}
}
void CMySaveFolder::ChangeSaveFolder(LPSTR saveFolder,BOOL remakeFlag)
{
if (saveFolder == NULL)
{
m_saveName[0] = 0;
}
else
{
int ln = (int)strlen(saveFolder);
if (ln>126) ln = 126;
memcpy(m_saveName,saveFolder,ln+1);
m_saveName[ln+1] = 0;
}
SetModify();
if (remakeFlag)
{
CreateAllFolderName();
}
}
void CMySaveFolder::CreateAllFolderName(void)
{
if (m_createFolderNameFlag) return;
if (m_companyName[0] == 0)
{
wsprintf(m_companyFolder,"%s",m_userFolder);
}
else
{
if (m_userFolder[0] == 0)
{
wsprintf(m_companyFolder,"%s",m_companyName);
}
else
{
wsprintf(m_companyFolder,"%s\\%s",m_userFolder,m_companyName);
}
}
if (m_gameName[0] == 0)
{
wsprintf(m_gameFolder,"%s",m_companyFolder);
}
else
{
if (m_companyFolder[0] == 0)
{
wsprintf(m_gameFolder,"%s",m_gameName);
}
else
{
wsprintf(m_gameFolder,"%s\\%s",m_companyFolder,m_gameName);
}
}
if (m_saveName[0] == 0)
{
wsprintf(m_fullFolder,"%s",m_gameFolder);
}
else
{
if (m_gameFolder[0] == 0)
{
wsprintf(m_fullFolder,"%s",m_saveName);
}
else
{
wsprintf(m_fullFolder,"%s\\%s",m_gameFolder,m_saveName);
}
}
m_createFolderNameFlag = TRUE;
}
BOOL CMySaveFolder::CreateSubFolder(void)
{
if (m_companyName[0] != 0)
{
LPSTR dirName = GetCompanyFolder();
if (dirName == NULL) return FALSE;
if (CreateDirectory(dirName,NULL) == FALSE)
{
int er = GetLastError();
if (er != ERROR_ALREADY_EXISTS)
{
return FALSE;
}
}
}
if (m_gameName[0] != 0)
{
LPSTR dirName = GetGameFolder();
if (dirName == NULL) return FALSE;
if (CreateDirectory(dirName,NULL) == FALSE)
{
int er = GetLastError();
if (er != ERROR_ALREADY_EXISTS)
{
return FALSE;
}
}
}
if (m_saveName[0] != 0)
{
LPSTR dirName = GetFullFolder();
if (dirName == NULL) return FALSE;
if (CreateDirectory(dirName,NULL) == FALSE)
{
int er = GetLastError();
if (er != ERROR_ALREADY_EXISTS)
{
return FALSE;
}
}
}
return TRUE;
}
BOOL CMySaveFolder::DeleteSaveData(BOOL deleteFolderFlag,BOOL deleteSubFolderFlag,BOOL orgDeleteFlag,BOOL deleteSaveOnly)
{
//first delete save / *.* without *.org
int cnt = 0;
if (1)
{
LPSTR folder = GetFullFolder();
BOOL rt = DeleteSubFolder(folder,deleteSubFolderFlag,orgDeleteFlag,deleteSaveOnly,FALSE);
if (rt == FALSE)
{
return FALSE;
}
}
char debugMessage[1024];
//if empty and name[0] != 0
//user/company/game/sav
//user/company/game
//user/company
if (deleteFolderFlag)
{
BOOL empty = TRUE;
if (empty)
{
if (m_saveName[0] != 0)
{
LPSTR folder = GetFullFolder();
if (folder != NULL)
{
empty = CheckEmptyFolder(folder);
if (empty)
{
if (RemoveDirectory(folder))
{
wsprintf(debugMessage,"\n削除したフォルダ:%s\n",folder);
OutputDebugString(debugMessage);
}
else
{
empty = FALSE;
}
}
}
}
}
if (empty)
{
if (m_gameName[0] != 0)
{
LPSTR folder = GetGameFolder();
if (folder != NULL)
{
empty = CheckEmptyFolder(folder);
if (empty)
{
if (RemoveDirectory(folder))
{
wsprintf(debugMessage,"\n削除したフォルダ:%s\n",folder);
OutputDebugString(debugMessage);
}
else
{
empty = FALSE;
}
}
}
}
}
if (empty)
{
if (m_companyName[0] != 0)
{
LPSTR folder = GetCompanyFolder();
if (folder != NULL)
{
empty = CheckEmptyFolder(folder);
if (empty)
{
if (RemoveDirectory(folder))
{
wsprintf(debugMessage,"\n削除したフォルダ:%s\n",folder);
OutputDebugString(debugMessage);
}
else
{
empty = FALSE;
}
}
}
}
}
}
return TRUE;
}
BOOL CMySaveFolder::DeleteSubFolder(LPSTR subFolder,BOOL deleteSubFolderFlag,BOOL orgDeleteFlag,BOOL deleteSaveOnly,BOOL deleteMyselfFlag)
{
//first delete save / *.* without *.org
int cnt = 0;
if (1)
{
WIN32_FIND_DATA finddata;
char searchName[1024];
LPSTR folder = subFolder;
// if (deleteSaveOnly)
// {
// wsprintf(searchName,"%s\\*.sav",folder);
// }
// else
// {
// wsprintf(searchName,"%s\\*.*",folder);
// }
wsprintf(searchName,"%s\\*.*",folder);
HANDLE hFind = FindFirstFile(searchName,&finddata);
// if (hFind == INVALID_HANDLE_VALUE)
// {
// second = 1;
// wsprintf(searchName,"%s\\*",folder);
// hFind = FindFirstFile(searchName,&finddata);
// }
if (hFind != INVALID_HANDLE_VALUE)
{
while (TRUE)
{
BOOL delok = FALSE;
if (finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
delok = TRUE;
LPSTR filename = finddata.cFileName;
if (strcmp(filename,".") == 0)
{
delok = FALSE;
}
if (strcmp(filename,"..") == 0)
{
delok = FALSE;
}
if (deleteSubFolderFlag && delok)
{
char subSubFolderName[1024];
wsprintf(subSubFolderName,"%s\\%s",subFolder,finddata.cFileName);
BOOL rt = DeleteSubFolder(subSubFolderName,deleteSubFolderFlag,orgDeleteFlag,deleteSaveOnly);
if (rt == FALSE)
{
break;
}
FindClose(hFind);
hFind = FindFirstFile(searchName,&finddata);
if (hFind == INVALID_HANDLE_VALUE)
{
break;
}
}
else
{
if (FindNextFile(hFind,&finddata) == FALSE)
{
break;
}
}
}
else
{
LPSTR filename = finddata.cFileName;
int ln = (int)strlen(filename);
delok = TRUE;
if (orgDeleteFlag == FALSE)
{
if (ln >= 4)
{
char check[6];
memcpy(check,filename+ln-4,4);
check[4] = 0;
check[5] = 0;
if (_stricmp(check,".org") == 0)
{
delok = FALSE;
}
}
}
if (delok)
{
if (deleteSaveOnly)
{
if (ln >= 4)
{
char check[6];
memcpy(check,filename+ln-4,4);
check[4] = 0;
check[5] = 0;
if (_stricmp(check,".sav") != 0)
{
delok = FALSE;
}
}
}
}
if (delok)
{
char deleteFileName[1024];
wsprintf(deleteFileName,"%s\\%s",subFolder,filename);
if (DeleteFile(deleteFileName))
{
cnt++;
FindClose(hFind);
hFind = FindFirstFile(searchName,&finddata);
if (hFind == INVALID_HANDLE_VALUE)
{
break;
}
}
else
{
//error!
FindClose(hFind);
hFind = INVALID_HANDLE_VALUE;
MessageBox(NULL,filename,"削除エラー",MB_ICONEXCLAMATION | MB_OK);
return FALSE;
// break;
}
}
else
{
if (FindNextFile(hFind,&finddata) == FALSE)
{
break;
}
}
}
}
if (hFind != INVALID_HANDLE_VALUE)
{
FindClose(hFind);
}
}
}
char debugMessage[1024];
wsprintf(debugMessage,"\n削除したファイル%d個\n",cnt);
OutputDebugString(debugMessage);
if (deleteMyselfFlag)
{
if (RemoveDirectory(subFolder))
{
wsprintf(debugMessage,"\n削除したフォルダ:%s\n",subFolder);
OutputDebugString(debugMessage);
}
else
{
return FALSE;
}
}
return TRUE;
}
BOOL CMySaveFolder::CheckEmptyFolder(LPSTR folder)
{
WIN32_FIND_DATA finddata;
char searchName[1024];
wsprintf(searchName,"%s\\*",folder);
HANDLE hFind = FindFirstFile(searchName,&finddata);
if (hFind == INVALID_HANDLE_VALUE)
{
return TRUE;
}
while (TRUE)
{
if (finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
BOOL current = FALSE;
LPSTR filename = finddata.cFileName;
if (strcmp(filename,".") == 0)
{
current = TRUE;
}
if (strcmp(filename,"..") == 0)
{
current = TRUE;
}
if (current == FALSE)
{
FindClose(hFind);
return FALSE;
}
if (FindNextFile(hFind,&finddata) == FALSE)
{
FindClose(hFind);
return TRUE;
}
}
else
{
return FALSE;
}
}
return FALSE;
}
/*_*/
| [
"tinyan@mri.biglobe.ne.jp"
] | tinyan@mri.biglobe.ne.jp |
35860304da0966b4b728c0b329281490189edb90 | 20367956891613689a8e114fee5c473e6630cf98 | /arduino/final/string.cpp | fcc4df55bc5f51dc3fab766822bce9ed02b149c3 | [] | no_license | adamjford/CMPUT296 | 4ed110ad9a342bbe034a5913bed81028815dd44f | dd19456aefd99e1c532733671757d45a4fdef4f1 | refs/heads/master | 2021-01-19T11:45:12.707001 | 2013-04-04T22:09:50 | 2013-04-04T22:09:50 | 5,781,651 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 885 | cpp | #include <Arduino.h>
/*
char *strncpy(char *s1, const char *s2, int n) {
boolean hitEndOfs1 = false;
boolean hitEndOfs2 = false;
for(size_t i = 0; i < n; i++) {
char current;
if(hitEndOfs2) {
current = '\0';
}
else {
current = s2[i];
if(current == '\0') {
hitEndOfs2 = true;
}
}
s1[i] = current;
}
return s1;
}
void testcase1() {
char s[5];
char *s1 = s;
const char *s2 = "foo";
s1 = strncpy(s1, s2, 3);
Serial.println(s1);
}
void testcase2() {
char s[5];
char *s1 = s;
const char *s2 = "foo";
s1 = strncpy(s1, s2, 5);
Serial.println(s1);
}
void testcase3() {
char s[5];
char *s1 = s;
const char *s2 = "Hello World!";
s1 = strncpy(s1, s2, 5);
Serial.println(s1);
}
void setup() {
Serial.begin(9600);
testcase1();
testcase2();
testcase3();
}
void loop() {
}
*/
| [
"adam.ford@greatbigsolutions.com"
] | adam.ford@greatbigsolutions.com |
9c77906235cb4505d1671d2accf82311b3483baa | f075d257893e4ec56816975859c2287e1554983a | /Source/ThirdPersonProto1/ObjectiveSystem.cpp | be06e39ff49493b0f94e4820dd05a7f96fd119ba | [] | no_license | david4jsus/ThirdPersonProto1 | dc31207b62e3bed5d3a711d687ed6d3394ed696b | 45236c87aeb07d88b5a7aa05a775547581328c87 | refs/heads/master | 2023-08-13T13:38:15.259134 | 2021-09-18T00:45:44 | 2021-09-18T00:45:44 | 406,988,252 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,506 | cpp | // Fill out your copyright notice in the Description page of Project Settings.
#include "ObjectiveSystem.h"
#include "InGameHUD.h"
ObjectiveSystem::ObjectiveSystem(UWorld* newWorld)
{
// Get world reference
world = newWorld;
// Create some objectives
Objective* objective1 = new Objective(0, FName("obj1"), FText::FromName(FName("Equip yourself")));
Objective* objective2 = new Objective(1, FName("obj2"), FText::FromName(FName("Do a thing")));
Objective* objective3 = new Objective(3, FName("obj3"), FText::FromName(FName("Get to the end")));
objective1->SetNextObjective(objective2);
objective2->SetNextObjective(objective3);
// Add the objectives to the list of objectives
objectiveList.Push(objective1);
objectiveList.Push(objective2);
objectiveList.Push(objective3);
// Set the current objective
currentObjective = objective1;
// Show objective text
//UpdateAndShowObjectiveText(); --> Best to do at a known safe time in the function call tree
}
ObjectiveSystem::~ObjectiveSystem()
{
// Discard the objectives
while (objectiveList.Num() > 0) {
delete objectiveList.Pop();
}
}
Objective* ObjectiveSystem::GetCurrentObjective()
{
return currentObjective;
}
void ObjectiveSystem::ProgressToNextObjective()
{
// Check that there is an objective selected
if (currentObjective) {
// Set current objective as complete
currentObjective->SetComplete(true);
// Proceed to next objective
currentObjective = currentObjective->GetNextObjective();
// Update objective text
UpdateAndShowObjectiveText();
}
}
void ObjectiveSystem::ProgressToNextObjectiveIfNameIs(FName objectiveName)
{
// Check that there is an objective selected
if (currentObjective) {
// Check that the given name matches the name of the current objective
if (currentObjective->GetName().Compare(objectiveName) == 0) {
ProgressToNextObjective();
}
}
}
void ObjectiveSystem::UpdateAndShowObjectiveText()
{
// Get instance of HUD
AInGameHUD* InGameHUD = Cast<AInGameHUD>(world->GetFirstPlayerController()->GetHUD());
// Check that the HUD instance was found
if (!InGameHUD) {
return;
}
// Check that there is an objective selected
if (currentObjective) {
// Interact with the HUD to show the objective text
if (InGameHUD) {
InGameHUD->UpdateAndShowObjectiveText(currentObjective->GetDescription().ToString());
}
}
else {
InGameHUD->HideObjectiveText();
}
}
bool ObjectiveSystem::IsObjectiveComplete(FName objectiveName)
{
// Get the objective with the given name
Objective* objective = GetObjectiveByName(objectiveName);
if (!objective) return false;
// Get the objective's completion status
return objective->IsComplete();
}
void ObjectiveSystem::SetCurrentObjective(Objective* newObjective)
{
currentObjective = newObjective;
}
Objective* ObjectiveSystem::GetObjectiveByName(FName objectiveName)
{
// Cycle through objectives in the list
for (int i = 0; i < objectiveList.Num(); i++) {
// Compare the given name with the current objective's name
if (objectiveName.Compare(objectiveList[i]->GetName()) == 0) {
// If the names match, return this objective
return objectiveList[i];
}
}
// If there are no matches, return null
return nullptr;
}
| [
"david4jsus@gmail.com"
] | david4jsus@gmail.com |
ee9a17351d1db1bee9bb40d617d5622330b5dccc | b181ef00bfaaeac1908533df12ec5ddde801003c | /示例代码/.svn/text-base/CH29_A1.cpp.svn-base | 9959ddf21ec24bc19f84d9c1f134fa3dab9d66e7 | [] | no_license | clarencehua/candcpp | b5c3ab9ea86efc12537df29cee3634f335b7f358 | 77022a497cc5ec443c1de437983986d811e58090 | refs/heads/master | 2020-07-26T16:26:46.058862 | 2019-10-06T08:47:44 | 2019-10-06T08:47:44 | 208,703,235 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 292 |
#include <stdio.h>
template <typename T>
T findmax (T arr[], int len)
{
T val = arr[0];
for(int i=1; i<len ; i++)
{
if(arr[i] > val) val = arr[i];
}
return val;
}
int main()
{
int arr[ 4] = { 1, 42, 87, 100 };
int result = findmax<int> (arr, 4);
return 0;
}
| [
"Administrator@zhangzhenhua.DW-Dev.naritech.cn"
] | Administrator@zhangzhenhua.DW-Dev.naritech.cn | |
98e9afde09249e64a6c711776bf47e504ace932d | 49f88ff91aa582e1a9d5ae5a7014f5c07eab7503 | /gen/third_party/perfetto/protos/perfetto/trace/ftrace/cpu_idle.pbzero.cc | 3674607bea3223827701adbfd2509b3102f20624 | [] | no_license | AoEiuV020/kiwibrowser-arm64 | b6c719b5f35d65906ae08503ec32f6775c9bb048 | ae7383776e0978b945e85e54242b4e3f7b930284 | refs/heads/main | 2023-06-01T21:09:33.928929 | 2021-06-22T15:56:53 | 2021-06-22T15:56:53 | 379,186,747 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 925 | cc | // Autogenerated by the ProtoZero compiler plugin. DO NOT EDIT.
#include "perfetto/trace/ftrace/cpu_idle.pbzero.h"
namespace {
static const ::protozero::ProtoFieldDescriptor kInvalidField = {"", ::protozero::ProtoFieldDescriptor::Type::TYPE_INVALID, 0, false};
}
namespace perfetto {
namespace protos {
namespace pbzero {
static const ::protozero::ProtoFieldDescriptor kFields_CpuIdleFtraceEvent[] = {
{"state", ::protozero::ProtoFieldDescriptor::Type::TYPE_UINT32, 1, 0},
{"cpu_id", ::protozero::ProtoFieldDescriptor::Type::TYPE_UINT32, 2, 0},
};
const ::protozero::ProtoFieldDescriptor* CpuIdleFtraceEvent::GetFieldDescriptor(uint32_t field_id) {
switch (field_id) {
case kStateFieldNumber:
return &kFields_CpuIdleFtraceEvent[0];
case kCpuIdFieldNumber:
return &kFields_CpuIdleFtraceEvent[1];
default:
return &kInvalidField;
}
}
} // Namespace.
} // Namespace.
} // Namespace.
| [
"aoeiuv020@gmail.com"
] | aoeiuv020@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.