blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 2 247 | content_id stringlengths 40 40 | detected_licenses listlengths 0 57 | license_type stringclasses 2 values | repo_name stringlengths 4 111 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 58 | visit_date timestamp[ns]date 2015-07-25 18:16:41 2023-09-06 10:45:08 | revision_date timestamp[ns]date 1970-01-14 14:03:36 2023-09-06 06:22:19 | committer_date timestamp[ns]date 1970-01-14 14:03:36 2023-09-06 06:22:19 | github_id int64 3.89k 689M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 25 values | gha_event_created_at timestamp[ns]date 2012-06-07 00:51:45 2023-09-14 21:58:52 ⌀ | gha_created_at timestamp[ns]date 2008-03-27 23:40:48 2023-08-24 19:49:39 ⌀ | gha_language stringclasses 159 values | src_encoding stringclasses 34 values | language stringclasses 1 value | is_vendor bool 1 class | is_generated bool 2 classes | length_bytes int64 7 10.5M | extension stringclasses 111 values | filename stringlengths 1 195 | text stringlengths 7 10.5M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
862a3730ec0990e23ff790ffde37df3c926a0ba8 | 8b932bdeb1fda0406dc15aaa1b55f1cfb61056e2 | /assets/code/code06.cpp | e44e9aa62c5df68313a6491a69bbab5f4ad89dc0 | [] | no_license | xiaoxiang10086/xiaoxiang10086.github.io | 7aa98c62be168a20eb632a3d15e7dfd2421bb408 | e8788428e88decf5252935f670f48946a56e1b28 | refs/heads/master | 2023-09-03T17:40:55.706271 | 2021-10-13T02:26:54 | 2021-10-13T02:26:54 | 254,653,706 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 238 | cpp | code06.cpp | class Solution {
public:
vector<int> reversePrint(ListNode* head) {
//递归
if(!head)
return {};
vector<int> a = reversePrint(head->next);
a.push_back(head->val);
return a;
}
}; |
623a274b16d49ea2a230e02359c459043a3f7c95 | 44016924ae5ef9766ee8acbf80519a1c42a7146a | /lab1/result/MyInt.cpp | d38ed9d760e4c726b0a54a40ef927c64acd9e055 | [] | no_license | an-st-u/TPnTPO | 487f2c2f77b22d490d7ab32bcfa094a7dec8bdc9 | 8041d4a6edd92904214eff867e32cc9cc3addf2c | refs/heads/master | 2021-01-17T15:30:24.757272 | 2016-05-31T21:28:03 | 2016-05-31T21:28:03 | 53,268,344 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,069 | cpp | MyInt.cpp | #include <iostream>
#include <conio.h>
#include "MyInt.h"
#include "MyException.h"
//êîíñòðóêòîðû
MyInt::MyInt(){
n=0;
}
MyInt::MyInt( int n){
this-> n=n;
}
//Ôóíêöèÿ sscanf() èäåíòè÷íà ôóíêöèè scanf(), íî äàííûå ÷èòàþòñÿ èç ìàññèâà,
//àäðåñóåìîãî ïàðàìåòðîì buf, à íå èç ñòàíäàðòíîãî ïîòîêà ââîäà stdin.
MyInt::MyInt( char *str){
std::cout << str << n;
}
MyInt::MyInt(MyInt& B)
{
n=B.n;
}
MyInt& MyInt::operator= (const MyInt& B){
n=B.n;
return *this;
}
MyInt::~MyInt(){}
MyInt MyInt::operator- (){ // óíàðíûé ìèíóñ -A
MyInt buf;
long long a;
a= -n;
if((a < INT_MIN) || (a > INT_MAX)) {
throw new OutOfInt("-A", n, a);
}
buf.n = (int)a;
return buf;
}
MyInt MyInt::operator- (const MyInt& B){ // B-A
MyInt buf;
long long c;
c = n - B.n;
if (( c < INT_MIN) || (c > INT_MAX)) { // ñ ëîíãîì íå ñðàáîòàë
throw new OutOfInt("*" ,n, B.n, c);
}
buf.n = (int)c;
return buf;
}
bool MyInt::operator==(MyInt B){
return (n == B.n);
}
bool MyInt::operator>(const MyInt& B){
return (n > B.n);
}
bool MyInt::operator< (const MyInt B){
return (n < B.n);
}
bool MyInt::operator<= (const MyInt B){
return (n <= B.n);
}
bool MyInt::operator>= (const MyInt B){
return (n >= B.n);
}
bool MyInt::operator!= (MyInt B){
return (n != B.n);
}
MyInt MyInt::operator+ (MyInt B){ //a+B
MyInt buf;
long c;
c = n+ B.n;;
if (( c < INT_MIN) || (c > INT_MAX)) {
throw new OutOfInt("*" ,n, B.n, c);
}
buf.n = c;
return buf.n;
}
MyInt MyInt::operator/ (MyInt B){ //A/B
MyInt buf;
long long c;
if(B.n == 0){
throw new DivisionByZero(B.n);
}else{
c = n / B.n;
}
if(c <= INT_MIN || c >= INT_MAX)
throw new OutOfInt("*" ,n, B.n, c);
buf.n = (int)c;
return buf;
}
MyInt MyInt::operator* (MyInt B){ // óìíîæåíèå òèïà B*A ìåòîä êëàññà
MyInt buf;
long long c;
c = n * B.n;
if (( c < INT_MIN) || (c > INT_MAX)) {
throw new OutOfInt("*" ,n, B.n, c);
}
buf.n=(int)c;
return buf;
}
MyInt operator*(int m, const MyInt &B){ // áèíàðíîå óìíîæåíèå, òèï 2*A äðóã êëàññà
MyInt buf;
long long c;
c = m* B.n;
if (( c < INT_MIN) || (c > INT_MAX)) {
throw new OutOfInt("*" ,m,B.n, c);
}
buf.m=(int)c;
return buf.m;
}
MyInt MyInt::operator*(int m){ // áèíàðíîå óìíîæåíèå, òèï A*2 äðóã êëàññà
MyInt buf;
long long c;
c = m * n;
if (( c < INT_MIN) || (c > INT_MAX)) {
throw new OutOfInt("*" ,m,n, c);
}
buf.n=(int)c;
return buf.n;
}
void operator<<(std::ostream& os, const MyInt &B)
{
os << B.n << " "<< std::endl;
}
|
6a26c0e6902166f1463faf382d46d6e1c4301b46 | fba7423bb84aaf9699d5cedc7cdb31284a2dec48 | /B/DZ/2_1/Race/user.h | 84f52e6736e7e6d294de37756468c5e910a365f7 | [] | no_license | Ken1g/Parallel_programming | b767595f7edba55657cc0a18deda024ab2b4514b | f5f8ab4fe7d72210c6b7f31bb5103fa2cc9c3a36 | refs/heads/master | 2020-04-07T06:35:46.013351 | 2019-01-18T05:16:18 | 2019-01-18T05:16:18 | 158,142,343 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 358 | h | user.h | #ifndef USER_H
#define USER_H
#include <QObject>
class User : public QObject {
Q_OBJECT
public:
inline void SetId(const int id);
explicit User(QObject *parent = nullptr);
signals:
void Send(const int id);
public slots:
void Recv(const int id);
private:
int Id;
};
void User::SetId(const int id) {
Id = id;
}
#endif // USER_H
|
c447db010e9ff51c90d03a97c27d9e6c9d88086d | ead3d2b70465ba2ca4b8c271c91ec91edfabeec6 | /api/reader/stationsreader.h | 10de182d03f30344a89f987f36e5a66b4715ff31 | [] | no_license | iRail/libqtrail | 8badc845efe7566b7e68fb2f86cf218c809788d3 | 0f795317c279959794542b9eae9743742dc5b70c | refs/heads/master | 2021-01-25T12:01:42.627206 | 2011-06-30T12:20:40 | 2011-06-30T12:20:40 | 1,627,224 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 803 | h | stationsreader.h | //
// Configuration
//
// Include guard
#ifndef STATIONSREADER_H
#define STATIONSREADER_H
// Includes
#include <QHash>
#include <QDateTime>
#include "api/reader.h"
#include "api/data/station.h"
namespace iRail
{
class StationsReader : public Reader
{
Q_OBJECT
public:
// Construction and destruction
StationsReader();
// Reader interface
void readDocument();
// Basic I/O
double version() const;
QDateTime timestamp() const;
QList<Station*> stations() const;
private:
// Member data
double mVersion;
QDateTime mTimestamp;
QList<Station*> mStations;
// Tag readers
QList<Station*> readStations();
Station* readStation();
};
}
#endif // STATIONSREADER_H
|
351213ad472b0816f4356958b2956031ee25c8c4 | 941214a73266366edbf48a05971c8c83512bfcda | /cpp-2016/include/sjk/tests/dll/win-test-dll/win-test-dll.cpp | db97b39accc520ae7c0a9f581df0e1a6bf793ba7 | [] | no_license | sjk7/edu | 19c2f570c5addc02dbcb675cb4c37c578ecbb839 | 41842fca23d46b3d7709f40117e26490fd06b22b | refs/heads/master | 2020-06-15T19:37:16.043521 | 2017-11-19T05:48:18 | 2017-11-19T05:48:18 | 75,267,497 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 512 | cpp | win-test-dll.cpp | // win-test-dll.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
#include "win-test-dll.h"
// This is an example of an exported variable
WINTESTDLL_API int nwintestdll=0;
// This is an example of an exported function.
WINTESTDLL_API int fnwintestdll(void)
{
return 42;
}
int CAPI test_a_function()
{
return 77;
}
// This is the constructor of a class that has been exported.
// see win-test-dll.h for the class definition
Cwintestdll::Cwintestdll()
{
return;
}
|
b8b3421d08ccc91ba1ccad8ca8cda74ad5c59c14 | a4a52b549ac1bf9266ecbe58c1e8388331c947bf | /include/expressions/primitive.hpp | 6c8fece3427beb407a850368c0077f5b0f624a23 | [
"MIT"
] | permissive | vimlord/Lomda | 56074de148351ddddf8845320b7926f98e3de5fb | 70cb7a9616c50fde3af62400fdcf945c63fad810 | refs/heads/master | 2021-10-18T05:13:37.569775 | 2019-02-08T04:27:32 | 2019-02-08T18:05:57 | 114,925,147 | 5 | 1 | MIT | 2019-02-14T02:17:59 | 2017-12-20T19:49:35 | C++ | UTF-8 | C++ | false | false | 6,615 | hpp | primitive.hpp | #ifndef _EXPRESSIONS_PRIMITIVE_HPP_
#define _EXPRESSIONS_PRIMITIVE_HPP_
#include "baselang/expression.hpp"
#include "value.hpp"
#include "types.hpp"
#include <initializer_list>
#include <utility>
class PrimitiveExp : public Expression {
public:
Exp optimize();
};
/**
* Denotes an ADT.
*/
class AdtExp : public Expression {
private:
std::string name, kind;
Exp *args;
public:
AdtExp(std::string n, std::string k, Exp *xs)
: name(n), kind(k), args(xs) {}
~AdtExp() {
for (int i = 0; args[i]; i++)
delete args[i];
delete[] args;
}
Val evaluate(Env);
Val derivativeOf(std::string, Env, Env);
Type* typeOf(Tenv);
Exp clone();
std::string toString();
bool postprocessor(HashMap<std::string,bool> *vars);
};
/**
* Denotes a dictionary.
*/
class DictExp : public Expression {
private:
LinkedList<std::string> *keys;
LinkedList<Exp> *vals;
public:
DictExp() : keys(new LinkedList<std::string>), vals(new LinkedList<Exp>) {}
DictExp(LinkedList<std::string> *ks, LinkedList<Exp> *vs) : keys(ks), vals(vs) {}
DictExp(std::initializer_list<std::pair<std::string, Exp>>);
~DictExp() {
delete keys;
while (!vals->isEmpty()) delete vals->remove(0);
delete vals;
}
Val evaluate(Env);
Val derivativeOf(std::string, Env, Env);
Type* typeOf(Tenv);
Exp clone();
std::string toString();
bool postprocessor(HashMap<std::string,bool> *vars) {
auto it = vals->iterator();
auto res = true;
while (res && it->hasNext())
res = it->next()->postprocessor(vars);
delete it;
return res;
}
Exp optimize();
};
/**
* Denotes false.
*/
class FalseExp : public PrimitiveExp {
public:
FalseExp() {}
Val evaluate(Env);
Type* typeOf(Tenv tenv);
Exp clone() { return new FalseExp(); }
std::string toString() { return "false"; }
};
/**
* Denotes a member of the set of 32 bit unsigned integers.
*/
class IntExp : public PrimitiveExp {
private:
int val;
public:
IntExp(int = 0);
Val evaluate(Env);
Type* typeOf(Tenv tenv);
Val derivativeOf(std::string, Env, Env);
int get() { return val; }
Exp clone() { return new IntExp(val); }
std::string toString();
};
/**
* Expression that yields closures (lambdas)
*/
class LambdaExp : public Expression {
private:
std::string *xs;
Exp exp;
public:
LambdaExp(std::string*, Exp);
~LambdaExp() { delete[] xs; delete exp; }
Val evaluate(Env);
Val derivativeOf(std::string, Env, Env);
Type* typeOf(Tenv);
std::string *getXs() { return xs; }
Exp clone();
std::string toString();
bool postprocessor(HashMap<std::string,bool> *vars);
Exp optimize() { exp = exp->optimize(); return this; }
};
/**
* Expression that represents a list of expressions.
*/
class ListExp : public Expression, public ArrayList<Exp> {
public:
ListExp();
ListExp(Exp*);
ListExp(List<Exp>* l);
~ListExp();
Val evaluate(Env);
Val derivativeOf(std::string, Env, Env);
Type* typeOf(Tenv);
Exp clone();
std::string toString();
bool postprocessor(HashMap<std::string,bool> *vars) {
auto res = true;
for (int i = 0; i < size(); i++) {
res = get(i)->postprocessor(vars);
}
return res;
}
Exp optimize();
};
/**
* Expression that represents a 32-bit floating point real number.
*/
class RealExp : public PrimitiveExp {
private:
float val;
public:
RealExp(float = 0);
Val evaluate(Env);
Type* typeOf(Tenv tenv);
Val derivativeOf(std::string, Env, Env);
Exp clone() { return new RealExp(val); }
std::string toString();
};
/**
* Denotes a string within the language.
*/
class StringExp : public PrimitiveExp {
private:
std::string val;
public:
StringExp(std::string s) : val(s) {}
Val evaluate(Env) { return new StringVal(val); }
Type* typeOf(Tenv) { return new StringType; }
Exp clone() { return new StringExp(val); }
std::string toString();
};
/**
* Denotes true.
*/
class TrueExp : public PrimitiveExp {
public:
TrueExp() {}
Val evaluate(Env);
Type* typeOf(Tenv tenv);
Exp clone() { return new TrueExp(); }
std::string toString() { return "true"; }
};
/**
* Denotes a tuple, which consists of two expressions.
*/
class TupleExp : public Expression {
private:
Exp left;
Exp right;
public:
TupleExp(Exp l, Exp r) : left(l), right(r) {}
~TupleExp() { delete left; delete right; }
Val evaluate(Env);
Val derivativeOf(std::string, Env, Env);
Type* typeOf(Tenv tenv);
std::string toString();
Exp clone() { return new TupleExp(left->clone(), right->clone()); }
bool postprocessor(HashMap<std::string,bool> *vars) {
return left->postprocessor(vars) && right->postprocessor(vars);
}
Exp optimize() { left = left->optimize(); right = right->optimize(); return this; }
};
// Get the value of a variable
class VarExp : public Expression {
private:
std::string id;
public:
VarExp(std::string s) : id(s) {}
Val evaluate(Env env);
Type* typeOf(Tenv tenv);
Exp clone() { return new VarExp(id); }
std::string toString();
Val derivativeOf(std::string, Env, Env);
bool postprocessor(HashMap<std::string,bool> *vars) {
if (vars->hasKey(id)) return true;
throw_err("", "undefined reference to variable " + id);
return false;
}
/**
* Constant propagation will trivially replace the variable if
* the variable name matches.
*/
};
class VoidExp : public PrimitiveExp {
public:
VoidExp() {}
Val evaluate(Env) { return new VoidVal; }
Type* typeOf(Tenv) { return new VoidType; }
std::string toString() { return "void"; }
Exp clone() { return new VoidExp; }
};
#endif
|
c32750fda604d79dc51f9878dd623b16a5a46697 | 8f62104e09af1f614525de20b847969bda36ca9c | /src/Population.hpp | b50735b0b5215d0b7a6fb15bddda9d554f765ff1 | [
"BSD-3-Clause"
] | permissive | drurya96/forqs_mod | 534cd8213c394ba2dfde80e1f581aa607954783a | b77ac174663354b116a46bb91d1bc8e4c021d654 | refs/heads/master | 2023-06-07T00:46:18.142627 | 2019-10-28T19:23:31 | 2019-10-28T19:23:31 | 218,119,009 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,312 | hpp | Population.hpp | //
// Population.hpp
//
// Created by Darren Kessner with John Novembre
//
// Copyright (c) 2013 Regents of the University of California
// 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 UCLA nor the names of its contributors may be used to endorse or
// promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _POPULATION_HPP_
#define _POPULATION_HPP_
#include "DataVector.hpp"
#include "PopulationData.hpp"
#include "ChromosomePairRange.hpp"
#include "shared_ptr.hpp"
#include <vector>
class MatingDistribution
{
public:
struct Entry
{
double weight;
size_t first;
std::string first_fitness;
size_t second;
std::string second_fitness;
mutable bool valid;
Entry(double _weight = 0, size_t _first = 0, size_t _second = 0)
: weight(_weight), first(_first), second(_second), valid(true)
{}
Entry(double _weight,
size_t _first, const std::string& _first_fitness,
size_t _second, const std::string& _second_fitness)
: weight(_weight),
first(_first), first_fitness(_first_fitness),
second(_second), second_fitness(_second_fitness), valid(true)
{}
};
typedef std::vector<Entry> Entries;
std::string default_fitness_function;
void push_back(const Entry& entry);
const Entries& entries() const {return entries_;}
const std::vector<double>& cumulative_weights() const {return cumulative_weights_;}
bool empty() const {return entries_.empty();}
void validate_entries(const PopulationDataPtrs& population_datas) const;
const Entry& random() const;
private:
Entries entries_;
std::vector<double> cumulative_weights_;
double total_weight() const {return cumulative_weights_.empty() ? 0 : cumulative_weights_.back();}
};
bool operator==(const MatingDistribution::Entry& a, const MatingDistribution::Entry& b);
bool operator!=(const MatingDistribution::Entry& a, const MatingDistribution::Entry& b);
bool operator==(const MatingDistribution& a, const MatingDistribution& b);
bool operator!=(const MatingDistribution& a, const MatingDistribution& b);
std::ostream& operator<<(std::ostream& os, const MatingDistribution::Entry& entry);
std::ostream& operator<<(std::ostream& os, const MatingDistribution& md);
std::istream& operator>>(std::istream& is, MatingDistribution::Entry& entry);
std::istream& operator>>(std::istream& is, MatingDistribution& md);
class Population;
typedef shared_ptr<Population> PopulationPtr;
typedef std::vector<PopulationPtr> PopulationPtrs;
typedef shared_ptr<PopulationPtrs> PopulationPtrsPtr;
class Population
{
public:
struct Config
{
size_t population_size;
// for generating population from nothing
size_t chromosome_pair_count;
unsigned int id_offset;
// for generating population from a previous generation
MatingDistribution mating_distribution;
Config()
: population_size(0), chromosome_pair_count(0), id_offset(0)
{}
};
typedef std::vector<Config> Configs;
size_t population_size() const {return population_size_;}
size_t chromosome_pair_count() const {return chromosome_pair_count_;}
bool empty() const {return (population_size_ == 0);}
void read_text(std::istream& is);
void write_text(std::ostream& os) const;
void read_binary(std::istream& is);
void write_binary(std::ostream& os) const;
void create_organisms(const Config& config,
const PopulationPtrs& populations,
const PopulationDataPtrs& population_datas,
const RecombinationPositionGeneratorPtrs& recombination_position_generators);
// convenience function: creates new generation from previous by calling create_organisms() for each Population
static PopulationPtrsPtr create_populations(const Configs& configs,
const PopulationPtrs& previous,
const PopulationDataPtrs& population_datas,
const RecombinationPositionGeneratorPtrs& recombination_position_generators);
// implementation-dependent range iteration
virtual void allocate_memory() = 0;
virtual ChromosomePairRangeIterator begin() = 0;
virtual const ChromosomePairRangeIterator begin() const = 0;
virtual ChromosomePairRangeIterator end() = 0;
virtual const ChromosomePairRangeIterator end() const = 0;
virtual ChromosomePairRange chromosome_pair_range(size_t organism_index) = 0;
virtual const ChromosomePairRange chromosome_pair_range(size_t organism_index) const = 0;
virtual ~Population() {}
protected:
Population()
: population_size_(0), chromosome_pair_count_(0)
{}
size_t population_size_;
size_t chromosome_pair_count_;
private:
// disallow copying
Population(Population&);
Population& operator=(Population&);
};
bool operator==(const Population::Config& a, const Population::Config& b);
bool operator!=(const Population::Config& a, const Population::Config& b);
std::ostream& operator<<(std::ostream& os, const Population::Config& config);
std::istream& operator>>(std::istream& is, Population::Config& config);
// multiple generations: each generation is Population::Configs, one Config per population
std::ostream& operator<<(std::ostream& os, const std::vector<Population::Configs>& generations);
std::istream& operator>>(std::istream& is, std::vector<Population::Configs>& generations);
bool operator==(const Population& a, const Population& b);
bool operator!=(const Population& a, const Population& b);
std::ostream& operator<<(std::ostream& os, const Population& p); // calls write_text()
std::istream& operator>>(std::istream& is, Population& p); // calls read_text()
#endif // _POPULATION_HPP_
|
ee33ead0f2b181df92dd10e1d40a942130283f88 | 51171b5f72136d556c13c210a2281f0295c11cf3 | /PastExams/exam_11092020.cpp | a9f59bac18b05d44e8be5365e3873e4684274328 | [] | no_license | IasonManolas/CompetitiveProgrammingCourse | c8c4ebffd1e8859cc5620abcf6dc4676be0700cc | 6378794851e28aa8268080158e7b062408a50c90 | refs/heads/master | 2023-02-26T22:57:38.980634 | 2021-02-09T10:28:55 | 2021-02-09T10:28:55 | 295,980,821 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,168 | cpp | exam_11092020.cpp | #include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, a, b) for (int i = a; i <= b; i++)
#define REP_R(i, a, b) for (int i = a; i >= b; i--)
#define F first
#define S second
#define PB push_back
#define MP make_pair
typedef vector<int64_t> vi;
typedef pair<int64_t, int64_t> pi;
int main() {
int64_t n, m;
cin >> n >> m;
vector<set<int64_t>> pointsPerNumSeg(
n); // pointsPerNumSeg[i] contains all the points that are
// contained in i number of segments
vi prefixSumSegments(n + 1, 0);
int i = 0;
while (i++ != n) {
int64_t l, r;
cin >> l >> r;
prefixSumSegments[l]++;
prefixSumSegments[r + 1]--;
}
// compute number of segments per point
int64_t counter = 0;
for (int64_t i = 0; i < n; i++) {
counter += prefixSumSegments[i];
pointsPerNumSeg[counter].insert(i);
}
while (m--) {
int64_t i, j, k;
cin >> i >> j >> k;
const set<int64_t> &points = pointsPerNumSeg[k];
const auto &pIt = points.lower_bound(i);
if (pIt != points.end() && *pIt <= j) {
cout << 1 << endl;
} else {
cout << 0 << endl;
}
}
return 0;
}
|
042455b792d53fcfecc9d7791770a2af6d0e9c01 | 9cfa7e78aec394e13f737746c947d1aea75adc4f | /ir-rgb-light-controller/ir-rgb-light-controller.ino | bf4e215832446573ef5f8c07d43cd2aae0b719e2 | [] | no_license | skeletorsue/arduino-ir-led-controller | 7921046ac3cd3ee667e554e8008d9c38e1e790ef | 7b843c9423610296870ce71c6af03217450aae6e | refs/heads/master | 2021-01-10T03:22:14.985872 | 2016-02-29T17:30:00 | 2016-02-29T17:30:00 | 52,806,171 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,985 | ino | ir-rgb-light-controller.ino | #include <IRremote.h>
int RECV_PIN = 11;
int RED_PIN = 5;
int RED_PIN_VALUE = 0;
int GREEN_PIN = 6;
int GREEN_PIN_VALUE = 0;
int BLUE_PIN = 9;
int BLUE_PIN_VALUE = 0;
int FADE_SPEED = 3;
unsigned long PORTS[6] = {
0x5EA17887, // off
0x1FEA05F, // computer
0x1FEE01F, // xbox 360
0x1FE10EF, // wii
0x1FE906F, // xbox one
0x1FED827 // chromecast
};
char* COLORS[6] = {
"000000", // black
"00ff00", // green
"0000ff", // blue
"95FFFF", // light blue
"0000ff", // blue
"ff0000" // red
};
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
Serial.println("Hello world!");
Serial.begin(9600); // Start serial
irrecv.enableIRIn(); // Start the receiver
pinMode(RED_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT);
pinMode(BLUE_PIN, OUTPUT);
// used to test the lights
lightTest();
}
void loop() {
if (irrecv.decode(&results)) {
for (int i = 0; i < 6; i++)
{
if (results.value == PORTS[i])
{
setLights(COLORS[i]);
break;
}
}
irrecv.resume(); // Receive the next value
}
}
void p(char *fmt, ... ) {
char buf[128]; // resulting string limited to 128 chars
va_list args;
va_start (args, fmt );
vsnprintf(buf, 128, fmt, args);
va_end (args);
Serial.println(buf);
}
void setLights(char* color_code) {
String color_string = color_code;
// start convoluted way to get parts of the color hex
String r_str = color_string.substring(0, 2);
String g_str = color_string.substring(2, 4);
String b_str = color_string.substring(4, 6);
char r_hex[3];
char b_hex[3];
char g_hex[3];
r_str.toCharArray(r_hex, 3);
g_str.toCharArray(g_hex, 3);
b_str.toCharArray(b_hex, 3);
// end convoluted way to get parts of the color hex
// conver the hex parts to decimal
int r_dec = strtol(r_hex, NULL, 16);
int g_dec = strtol(g_hex, NULL, 16);
int b_dec = strtol(b_hex, NULL, 16);
p("Setting color code to: %s", color_code);
p("r: %d", r_dec);
p("g: %d", g_dec);
p("b: %d", b_dec);
// we want to fade the color change. So this will loop and change every color by 1 (if necessary) until they line up.
while (RED_PIN_VALUE != r_dec || GREEN_PIN_VALUE != g_dec || BLUE_PIN_VALUE != b_dec) {
// we only want to change the red pin if it's not already correct
if (r_dec != RED_PIN_VALUE) {
if (r_dec < RED_PIN_VALUE ) {
setRed(RED_PIN_VALUE - 1);
} else {
setRed(RED_PIN_VALUE + 1);
}
}
// we only want to change the green pin if it's not already correct
if (g_dec != GREEN_PIN_VALUE) {
if (g_dec < GREEN_PIN_VALUE ) {
setGreen(GREEN_PIN_VALUE - 1);
} else {
setGreen(GREEN_PIN_VALUE + 1);
}
}
// we only want to change the blue pin if it's not already correct
if (b_dec != BLUE_PIN_VALUE) {
if (b_dec < BLUE_PIN_VALUE ) {
setBlue(BLUE_PIN_VALUE - 1);
} else {
setBlue(BLUE_PIN_VALUE + 1);
}
}
delay(FADE_SPEED);
}
}
void setRed(int val) {
RED_PIN_VALUE = val;
analogWrite(RED_PIN, val);
}
void setGreen(int val) {
GREEN_PIN_VALUE = val;
analogWrite(GREEN_PIN, val);
}
void setBlue (int val) {
BLUE_PIN_VALUE = val;
analogWrite(BLUE_PIN, val);
}
void lightTest() {
Serial.println("Starting light test sequence");
int i;
// fade through the rgb scale
for (i = 0; i < 256; i++) {
setRed(i);
delay(5);
}
for (i = 255; i >= 0; i--) {
setRed(i);
delay(5);
}
for (i = 0; i < 256; i++) {
setGreen(i);
delay(5);
}
for (i = 255; i >= 0; i--) {
setGreen(i);
delay(5);
}
for (i = 0; i < 256; i++) {
setBlue(i);
delay(5);
}
for (i = 255; i >= 0; i--) {
setBlue(i);
delay(5);
}
// cycle through each of the programmed colors
for (int i = 0; i < 6; i++) {
setLights(COLORS[i]);
}
// default to the lights being off
setLights("000000");
Serial.println("Light test sequence has completed, how did it look?");
}
|
602264578500417ac059aae929033ee1e1387f1b | 98b5e8528945f70d60d0615c3d37c9730baeddfe | /include/tator/graphics/PrimitiveFactory.hpp | e28560bab1afdb1a8430a4d10728da5780ca21ba | [] | no_license | ablack94/tator | 913f66c3a2d56212c2c495c4c2998f6861fe7237 | 3583c5a3d582a7f03a4554820978e38b3eb2cad9 | refs/heads/master | 2021-01-21T05:15:17.022553 | 2017-07-16T19:54:17 | 2017-07-16T19:54:17 | 83,160,100 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 253 | hpp | PrimitiveFactory.hpp | // Andrew Black
// July 02, 2017
#pragma once
#ifndef HG_TATOR_GRAPHICS_PRIMITIVEFACTORY_HPP
#define HG_TATOR_GRAPHICS_PRIMITIVEFACTORY_HPP
namespace tator {
namespace graphics {
class PrimitiveFactory {
public:
};
} // graphics
} // tator
#endif |
ec3fae7906edbced58bab4d05cd98d7b8406652c | f2ecb72a28fda51ef40c2caac4c48f29bab802e0 | /workdir_DsBranchingFractions/FilterTools_fDsSkim/HardElectronFilter.cc | 46ed5adc920adfd069e18c04c8556af7e2ff4b83 | [] | no_license | benitezj/PhDAnalysisSoftware | e5536705269c24e80c0efbc0f73618e898f0d80a | bb7af4eef48ca9c31360e150687330992c9b7312 | refs/heads/master | 2016-09-02T00:28:06.829752 | 2014-08-14T16:09:53 | 2014-08-14T16:09:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,061 | cc | HardElectronFilter.cc | //--------------------------------------------------------------------------
// File and Version Information:
// $Id: HardElectronFilter.cc,v 1.2 2005/08/04 16:41:48 desilva Exp $
//
// Description:
// Class HardElectronFilter - fast filter for the SL analysis
//
// Environment:
// Software developed for the BaBar Detector at the SLAC B-Factory.
//
// Author List:
// Bob Kowalewski Adapted from ISLTagFilter; cuts on tight electrons
// with p*>1.0 GeV (based on tag words); cut on BGFMultiHadron must be
// done separately (with TCL filter). Cuts on R2 and nTrk are coded,
// but the default values amount to no cut for BGFMultiHadron events.
//
//--------------------------------------------------------------------------
#include "BaBar/BaBar.hh"
//-----------------------
// This Class's Header --
//-----------------------
#include "FilterTools/HardElectronFilter.hh"
// also defines the class variables
//-------------
// C Headers --
//-------------
#include <assert.h>
#include <math.h>
//---------------
// C++ Headers --
//---------------
//-------------------------------
// Collaborating Class Headers --
//-------------------------------
#include "TagData/TagTransient.hh"
#include "TagData/TagTransientBoolIter.hh"
#include "TagData/TagTransientIntIter.hh"
#include "TagData/TagTransientFloatIter.hh"
#include "AbsEnv/AbsEnv.hh"
#include "GenEnv/GenEnv.hh"
#include "ErrLogger/ErrLog.hh"
#include "Framework/AbsParmGeneral.hh"
using std::endl;
//-----------------------------------------------------------------------
// Local Macros, Typedefs, Structures, Unions and Forward Declarations --
//-----------------------------------------------------------------------
//----------------
// Constructors --
//----------------
HardElectronFilter::HardElectronFilter(
const char* const theName,
const char* const theDescription )
: TagFilterModule( theName, theDescription )
, _nTrkCut (new AbsParmGeneral<int> ("nTrkCut", this, 3 ))
, _r2Cut (new AbsParmGeneral<float> ("r2Cut", this, 1.0 ))
, _minTagMom (new AbsParmGeneral<float> ("tagCut", this, 1.0 ))
{
commands()->append(_nTrkCut);
commands()->append(_r2Cut);
commands()->append(_minTagMom);
_nPassed = 0;
_nPass1 = 0;
_nPass2 = 0;
_nPass3 = 0;
_nPass4 = 0;
}
//--------------
// Destructor --
//--------------
// The destructor should be limited to undoing the work of the constructor
HardElectronFilter::~HardElectronFilter( )
{
delete _nTrkCut;
delete _r2Cut;
delete _minTagMom;
}
//--------------
// Operations --
//--------------
AppResult
HardElectronFilter::beginJob( AbsEvent* anEvent )
{
ErrMsg(trace)<<"begin Job"<<endmsg;
return AppResult::OK;
}
AppResult
HardElectronFilter::event( AbsEvent* anEvent )
{
// Build the tag accessor using the base class
TagFilterModule::event( anEvent );
float R2;
int nTrk;
bool status(false);
bool passed(false);
// float highPTightMuon(-10.0);
float highPTightElectron(-10.0);
if ( 0 != tag( ) )
{
status = tag( )->getInt( nTrk, "nTracks" );
status &= tag( )->getFloat(R2, "R2");
// status &= tag( )->getFloat(highPTightMuon,"muonTight1cm" );
status &= tag( )->getFloat(highPTightElectron,"elecTight1cm" );
}
// bool highMuon(false), highElectron(false);
bool allOk(true);
if ( true == status ) {
_nPass1++;
if ( nTrk > _nTrkCut->value() ) _nPass2++;
else allOk=false;
if ( R2 <= _r2Cut->value() ) _nPass3++;
else allOk=false;
if ( fabs(highPTightElectron) >= _minTagMom->value() ) _nPass4++;
else allOk=false;
}
else allOk=false;
if (allOk)
{
passed = true;
_nPassed ++;
}
setPassed (passed);
return AppResult::OK;
}
AppResult
HardElectronFilter::endJob( AbsEvent* anEvent )
{
ErrMsg(routine) <<" end HardElectron Filter Job" << endl
<<" EVENTS PASSED: " << _nPassed
<<" status " << _nPass1
<<" nTrk " << _nPass2
<<" R2 " << _nPass3
<<" elec " << _nPass4
<< endmsg;
return AppResult::OK;
}
|
c2e379385e265e9da05cf03c62b30173e3165c4b | 116ce5364a395e4a8afb9ee7fc5cefb4ddd44a21 | /ImgProc/controller/ringbuffer.h | 08fa26cb5bab792f2f1e2ed32471282dcc374170 | [] | no_license | JasonZhuGit/stuOpenCV | 034def36cda3783c0f5b3283e68dc61ca0842b07 | f0829dc3a31f10b2912c4f2f35314f60526c982f | refs/heads/master | 2021-09-08T22:26:56.952169 | 2018-03-12T12:57:23 | 2018-03-12T12:57:23 | 91,866,097 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,929 | h | ringbuffer.h | #ifndef RINGBUFFER_H
#define RINGBUFFER_H
template <class T>
class RingBuffer
{
public:
RingBuffer(int bufferSize=10);
~RingBuffer();
T * dataArray; //data
int arraySize;
int head;
int tail;
int cursor;
int prevVldNum;
int nextVldNum;
void setTail(int pos);
void tailForward(int steps=1);
void headForward(int steps=1);
void cursorForward(int steps=1);
void cursorRecede(int steps=1);
bool isEmpty();
bool isFull();
void reset();
void push(T newData);
void add(T newData);
bool getCursor(T &rtValue);
bool getPrev(int prevSteps, T &rtValue);
bool getNext(int nextSteps, T &rtValue);
};
template <class T>
RingBuffer<T>::RingBuffer(int bufferSize)
{
arraySize = (bufferSize + 1) >=2 ? (bufferSize + 1) : 2;
head = 0;
tail = 0;
cursor = -1;
prevVldNum = -1;
nextVldNum = 0;
dataArray = new T[arraySize];
// for (int i=0; i<arraySize; i++){
// dataArray[i] = 0;
// }
}
template <class T>
RingBuffer<T>::~RingBuffer()
{
// for (int i=0; i<arraySize; i++){
// dataArray[i] = 0;
// }
delete []dataArray;
}
template <class T>
void RingBuffer<T>::setTail(int pos)
{
pos = pos%arraySize;
tail = pos;
}
template <class T>
void RingBuffer<T>::tailForward(int steps)
{
tail = (tail + steps) % arraySize;
}
template <class T>
void RingBuffer<T>::headForward(int steps)
{
head = (head + steps) % arraySize;
}
template <class T>
void RingBuffer<T>::cursorForward(int steps)
{
steps = steps <= nextVldNum ? steps : nextVldNum;
cursor = (cursor + steps) % arraySize;
nextVldNum = 0;
prevVldNum = prevVldNum + steps;
// prevVldNum = prevVldNum <= arraySize - 2 ? prevVldNum : arraySize - 2;
}
template <class T>
void RingBuffer<T>::cursorRecede(int steps)
{
steps = steps % arraySize;
steps = steps <= prevVldNum ? steps : prevVldNum;
cursor = (cursor + (arraySize - steps)) % arraySize;
prevVldNum = prevVldNum - steps;
nextVldNum = nextVldNum + steps;
}
template <class T>
bool RingBuffer<T>::isEmpty()
{
if (tail == head)
return true;
else
return false;
}
template <class T>
bool RingBuffer<T>::isFull()
{
if ((tail + 1)%arraySize == head)
return true;
else
return false;
}
template <class T>
void RingBuffer<T>::reset()
{
delete []dataArray;
dataArray = 0;
dataArray = new T[arraySize];
head = 0;
tail = 0;
cursor = -1;
prevVldNum = -1;
nextVldNum = 0;
}
template <class T>
void RingBuffer<T>::push(T newData)
{
dataArray[tail] = newData;
tailForward(1);
}
template <class T>
void RingBuffer<T>::add(T newData)
{
if ((cursor + 1) % arraySize != tail){
tail = (cursor + 1) % arraySize;
}
if (isFull()){
headForward(1);
prevVldNum = arraySize - 2;
}else{
prevVldNum ++;
}
push(newData);
cursor = (cursor + 1) % arraySize;
nextVldNum = 0;
}
template <class T>
bool RingBuffer<T>::getCursor(T &rtValue)
{
if (cursor < 0){
return false;
}else{
rtValue = dataArray[cursor];
return true;
}
}
template <class T>
bool RingBuffer<T>::getPrev(int prevSteps, T & rtValue)
{
if (prevSteps > prevVldNum){
return false;
}else{
int index = (cursor + arraySize - prevSteps) % arraySize;
rtValue = dataArray[index];
return true;
}
}
template <class T>
bool RingBuffer<T>::getNext(int nextSteps, T &rtValue)
{
if (nextSteps > nextVldNum){
return false;
}else{
int index = (cursor + nextSteps) % arraySize;
rtValue = dataArray[index];
return true;
}
}
#endif // RINGBUFFER_H
|
5f6cd11dc17af9dd6f1d237393f37fdaca06b6d9 | e30e9a05829baf54b28a4a953c98f6ea2ca5f3cf | /ITMO/2008/20080913/G/sol.cpp | c6bfecd2a883704994316da546f02eaf354a647a | [] | no_license | ailyanlu/ACM-13 | fdaf4fea13c3ef4afc39a522e12c5dee52a66a24 | 389ec1e7f9201639a22ce37ea8a44969424b6764 | refs/heads/master | 2018-02-24T00:33:02.205005 | 2013-01-09T18:03:08 | 2013-01-09T18:03:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,358 | cpp | sol.cpp | #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
using namespace std;
vector <int> cups, plsc, plnum, plcup;
vector <vector <bool> > plm;
int n, k;
int csc=-1;
int cans=-1;
int main (void)
{
freopen ("greed.in", "r", stdin);
freopen ("greed.out", "w", stdout);
scanf ("%d%d", &n, &k);
plnum.resize(k);
for (int i=0; i<k-1; ++i){
scanf ("%d", &plnum[i]);
}
for (int q=1; q<n; ++q){
cups.assign(n, 1); // candies in cups
plsc.assign(k, 0); // scores of players
plcup.assign(k, 0); // number of cup where players stand
plnum.back()=q; // number of our player
plm.assign(k, vector <bool> (n, false)); // for detecting cycles
int cand = n;
while (cand){
for (int i=0; i<k; ++i){ // moves
if (plcup[i]!=-1){
plcup[i]=(plnum[i]+plcup[i])%n;
if (plm[i][plcup[i]]){
plcup[i]=-1;
}
else{
plm[i][plcup[i]]=true;
plsc[i]+=cups[plcup[i]];
cand-=cups[plcup[i]];
cups[plcup[i]]=0;
}
}
}
}
if (plsc[k-1]>csc){
csc=plsc[k-1];
cans=q;
}
}
printf ("%d\n", cans);
return 0;
} |
e329f91cdcbf49ef58b4886b835003323225d756 | 4cd21b8d531fc56053122da74ad29429d04fa07a | /msformat.cpp | ce3a6847b58bd429170f2233581bc28ade1ebf5f | [
"Apache-2.0"
] | permissive | gchen98/macs | 4de1ef430b5593ed5a483df2b90796b3585aed75 | 85b0475231fb32dab70e7ae0c81b0603151b4da7 | refs/heads/master | 2021-01-19T22:13:36.714947 | 2019-10-17T21:42:34 | 2019-10-17T21:42:34 | 32,548,997 | 17 | 8 | null | 2018-02-26T19:19:39 | 2015-03-19T22:13:22 | C++ | UTF-8 | C++ | false | false | 5,666 | cpp | msformat.cpp |
/**
Copyright 2019 Gary K. Chen (gchen98@gmail.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
**/
#include<iostream>
#include<iomanip>
#include<fstream>
#include<cstdlib>
#include<sstream>
#include "constants.h"
using namespace std;
int main(int argc,char * argv[]){
int totalpos;
int totalpersons;
ostringstream oss,oss_tree;
srand(time(NULL));
double r = rand();
oss<<TEMPFILE_PREFIX<<r;
oss_tree<<TREEFILE_PREFIX<<r;
string tempfile=oss.str();
ofstream haploDataFile(tempfile.data());
string treefile=oss_tree.str();
ofstream treeDataFile(treefile.data());
double * positions = NULL;
bool ** genotypes = NULL;
bool slashprint = true;
bool bPrintNewick = false;
string line,constant;
while(getline(cin,line)){
istringstream tokens(line);
tokens>>constant;
//cout<<line<<endl;
if (constant.compare(COMMAND)==0){
string commandline;
bool printed=false;
while(tokens){
tokens>>commandline;
if (printed){ cout<<" "; }
cout<<commandline;
printed=true;
}
cout<<endl;
// print the MS output header here
}else if(constant.compare(SEED)==0){
string seed;
tokens>>seed;
//getline(cin,line);
// print the MS output header here
cout<<seed<<endl;
}else if(constant.compare(NEWICKTREE)==0){
bPrintNewick = true;
string tree;
tokens>>tree;
treeDataFile<<tree<<endl;
}else if(constant.compare(MUTATIONSITE)==0){
string index,position,mutationTime,mutations;
tokens>>index>>position>>mutationTime>>mutations;
haploDataFile<<index<<FIELD_DELIMITER<<position<<FIELD_DELIMITER
<<mutations<<endl;
//getline(cin,line);
//while(line.compare(HAPLOEND)!=0){
// haploDataFile<<line<<endl;
// getline(cin,line);
//}
}else if (constant.compare(TOTALSAMPLES)==0){
treeDataFile.close();
haploDataFile.close();
tokens>>totalpersons;
}else if (constant.compare(TOTALSITES)==0){
tokens>>totalpos;
}else if (line.compare(SNPBEGIN)==0){
if (slashprint){
cout<<endl<<"//"<<endl;
slashprint = false;
}
if (bPrintNewick){
ifstream treeDataIn(treefile.data());
string line;
while(getline(treeDataIn,line)){
cout<<line<<endl;
}
treeDataIn.close();
}
cout<<"segsites: "<<totalpos<<endl;
cout<<"positions:";
positions = new double[totalpos];
genotypes = new bool * [totalpersons];
for (int i=0;i<totalpersons;++i){
genotypes[i] = new bool[totalpos];
}
ifstream haploDataFile(tempfile.data());
// read in the positions
getline(cin,line);
istringstream input(line);
int cur_snp_index = -1;
double cur_snp_pos = 0.;
string cur_haplo;
for (int i=0;i<totalpos;++i){
int selectedsnp;
input>>selectedsnp;
string haploline;
do{
getline(haploDataFile,haploline);
istringstream haploInput(haploline);
haploInput>>cur_snp_index>>cur_snp_pos>>cur_haplo;
}while(selectedsnp!=cur_snp_index);
positions[i] = cur_snp_pos;
for (int j=0;j<totalpersons;++j){
char cur_char = cur_haplo[j];
switch(cur_char){
case '0':
genotypes[j][i] = 0;
break;
case '1':
genotypes[j][i] = 1;
break;
}
}
}
haploDataFile.close();
remove(tempfile.data());
}
//getline(cin,line);
else if (line.compare(SNPEND)==0){
// print output in MS format now
for (int i=0;i<totalpos;++i){
cout<<" "<< setprecision(14)<<positions[i];
}
cout<<endl;
// cleanup arrays
delete [] positions;
for (int j=0;j<totalpersons;++j){
for (int i=0;i<totalpos;++i){
cout<<genotypes[j][i];
}
cout<<endl;
}
for (int i=0;i<totalpersons;++i){
genotypes[i] = new bool[totalpos];
}
delete [] genotypes;
// we can print the slashes for the next iteration
slashprint = true;
haploDataFile.open(tempfile.data());
treeDataFile.open(treefile.data());
}
}
haploDataFile.close();
remove(tempfile.data());
treeDataFile.close();
remove(treefile.data());
}
|
0d8506d2e32e09e9e90692e3b1a760ba7cc5607f | 6892eadb87ffa5e8f9bb377a18d63fb46d94b43c | /src/wifidata.h | d9d795864a44d04d9b7a1d78b1bd6b555efa43a6 | [] | no_license | THKDev/esp8266_dht22 | 578a3be4cc27e125f44e1cf61a688f2210c7391a | 20b045d0464a4e34c14b10b27185f8d803cd665c | refs/heads/master | 2021-01-11T01:14:20.411748 | 2016-10-12T20:12:53 | 2016-10-12T20:12:53 | 70,737,480 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 630 | h | wifidata.h | class WifiData
{
public:
/** WiFi SSID */
static constexpr const char* SSID() {
return "";
}
/** WiFi password */
static constexpr const char* WIFI_PWD() {
return "";
}
/** hostname of this IoT ESP8266 device */
static constexpr const char* HOSTNAME() {
return "";
}
/** name of openhab server */
static constexpr const char* SERVERNAME() {
return "";
}
/** port of openhab server */
static constexpr const uint16_t SERVERPORT() {
return 0;
}
};
|
6dd52d34d2eb9f48fa42468644156576c4a4a2e6 | ab200372821e5fd38d3c621ecb0977fa3175663c | /Include/Engine/DeferredBuffer.h | d731d79c74e460ccb915dfc77e359449a2e13f14 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-happy-bunny",
"BSD-3-Clause",
"Libpng",
"MIT",
"FTL",
"LicenseRef-scancode-warranty-disclaimer",
"Zlib",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | xuxiaowei007/NekoEngine | 969deab915ccfe674e3a988a13b8477611704d36 | b74f8e62e128e5985c742d6448d7262157029dbf | refs/heads/master | 2018-01-14T22:01:12.097291 | 2016-08-25T05:40:50 | 2016-08-25T05:40:50 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,930 | h | DeferredBuffer.h | /* NekoEngine
*
* DeferredRenderer.h
* Author: Alexandru Naiman
*
* Deferred rendering buffer
*
* -----------------------------------------------------------------------------
*
* Copyright (c) 2015-2016, Alexandru Naiman
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder 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 ALEXANDRU NAIMAN "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL ALEXANDRU NAIMAN BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#define GB_TEX_POSITION 0
#define GB_TEX_NORMAL 1
#define GB_TEX_COLOR_SPECULAR 2
#define GB_TEX_MATERIAL_INFO 3
#define GB_TEX_DEPTH_STENCIL 4
#define GB_TEX_LIGHT 5
#define GB_TEX_BRIGHT 6
#define GB_TEX_LIGHT_ACCUM 7
#define GB_FBO_GEOMETRY 0
#define GB_FBO_LIGHT 1
#define GB_FBO_BRIGHT 2
#define GB_FBO_LIGHT_ACCUM 3
#include <Engine/Engine.h>
#include <Engine/Shader.h>
#include <Scene/Object.h>
#include <Engine/SSAO.h>
#include <Engine/HBAO.h>
#include <Renderer/Renderer.h>
#include <Engine/ShadowMap.h>
typedef struct LIGHT_SCENE_DATA
{
glm::vec4 CameraPositionAndAmbient;
glm::vec4 AmbientColorAndRClear;
glm::vec4 FogColorAndRFog;
glm::vec4 FrameSizeAndSSAO;
glm::mat4 CameraWorld;
} LightSceneData;
typedef struct LIGHT_DATA
{
glm::vec3 LightPosition;
float padding0;
glm::vec3 LightColor;
float padding1;
glm::vec4 LightDirectionAndShadow;
glm::vec4 LightAttenuationAndData;
glm::mat4 LightWorld;
glm::mat4 LightProjection;
} LightData;
class DeferredBuffer
{
public:
ENGINE_API static int Initialize() noexcept;
ENGINE_API static int GetWidth() noexcept { return _fboWidth; }
ENGINE_API static int GetHeight() noexcept { return _fboHeight; }
ENGINE_API static RTexture* GetPositionTexture() noexcept { return _gbTextures[GB_TEX_POSITION]; }
ENGINE_API static RTexture* GetNormalTexture() noexcept { return _gbTextures[GB_TEX_NORMAL]; }
ENGINE_API static RTexture* GetDepthTexture() noexcept { return _gbTextures[GB_TEX_DEPTH_STENCIL]; }
ENGINE_API static RShader* GetGeometryShader() noexcept { return _geometryShader->GetRShader(); }
ENGINE_API static void SetAmbientColor(glm::vec3 &color, float intensity) noexcept;
ENGINE_API static void SetFogColor(glm::vec3 &color) noexcept;
ENGINE_API static void SetFogProperties(float clear, float start) noexcept;
ENGINE_API static void BindGeometry() noexcept;
ENGINE_API static void BindLighting() noexcept;
ENGINE_API static void Unbind() noexcept;
ENGINE_API static void RenderLighting() noexcept;
ENGINE_API static void ScreenResized(int width, int height) noexcept;
ENGINE_API static void CopyLight(RFramebuffer* destFbo) noexcept;
ENGINE_API static void CopyColor(RFramebuffer* destFbo) noexcept;
ENGINE_API static void CopyBrightness(RFramebuffer* destFbo) noexcept;
ENGINE_API static void CopyDepth(RFramebuffer* destFbo) noexcept;
ENGINE_API static void CopyStencil(RFramebuffer* destFbo) noexcept;
ENGINE_API static void EnableAO(bool enable) noexcept;
ENGINE_API static void Release() noexcept;
private:
static RFramebuffer* _fbos[4];
static RTexture* _gbTextures[8];
static uint64_t _gbTexHandles[7];
static uint32_t _fboWidth, _fboHeight;
static Shader *_geometryShader, *_lightingShader;
static SSAO *_ssao;
static HBAO *_hbao;
static int _samples;
static Object *_lightSphere;
static ShadowMap *_shadow;
static RBuffer *_sceneLightUbo, *_lightUbo, *_lightMatrixUbo;
static void _Bind() noexcept;
static bool _GenerateTextures() noexcept;
static bool _AttachTextures() noexcept;
static void _DeleteTextures() noexcept;
DeferredBuffer() { }
// Console variable functions
static void _RegisterCVars();
};
|
98e9e5eb2770b425da1e2435ae7b156edcc17dc5 | ae2f0cedac8339127a670d39499e519f558382f5 | /main.cpp | 1f68ec9a545d47a456bba2097504df1fe729d162 | [] | no_license | theilmbh/HyperbolicScatter | 87a2ca529afedb992e611a2a9b98c9a9a72bfe7d | 3698fa8f75e6dd1491b9037380ed01b06fe819e4 | refs/heads/master | 2020-07-23T21:09:43.969628 | 2016-08-29T15:19:28 | 2016-08-29T15:19:28 | 66,732,582 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 453 | cpp | main.cpp | #include "poincaredisk.h"
#include "interactivehyperbolicscatterplot.h"
#include <QApplication>
#include <QtWidgets>
#include <QObject>
#include <QHBoxLayout>
#include <QSizePolicy>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
InteractiveHyperbolicScatterPlot *win = new InteractiveHyperbolicScatterPlot();
win->setWindowTitle("Hyberbolic Multidimensional Scaling Visualization");
win->show();
return a.exec();
}
|
01553f2dc13a3b00feb77bae9522246a01c7cb48 | be2744f43865b43c3e9983a02e13426129b283c4 | /Source/Engine/Graphics/Graphics_Texture.hpp | fd01ce3c0f4b891b9ea65a73a332434d6daa076c | [] | no_license | BryanRobertson/Alba | e94ef8f2b68c6f97023cbcf9ba977056fd38e739 | cba532d0c7ef2631a240f70f07bf1d258867bb3a | refs/heads/master | 2023-02-20T08:22:59.884655 | 2021-01-23T00:50:15 | 2021-01-23T00:50:15 | 112,042,539 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,857 | hpp | Graphics_Texture.hpp | #pragma once
#include "Graphics_API.hpp"
#include "Core_BasicTypes.hpp"
#include "Core_StringHash.hpp"
#include "Core_SharedPtr.hpp"
#include "Core_Resource.hpp"
#include "Core_ResourceRepository.hpp"
#include "Core_Any.hpp"
namespace Alba
{
namespace Graphics
{
//-----------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------
class Texture;
//-----------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------
typedef Core::ResourceHandle<Texture> TextureHandle;
typedef Core::ResourceId<Texture> TextureId;
//-----------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------
enum class TextureType
{
Texture1D,
Texture2D,
Texture3D
};
//-----------------------------------------------------------------------------------------
// Name : Texture
// Desc : Represents a texture
//-----------------------------------------------------------------------------------------
class ALBA_GRAPHICS_API Texture final : public Core::Resource<Texture>
{
typedef Core::Resource<Texture> Super;
public:
//=================================================================================
// Public Static Methods
//=================================================================================
static TextureHandle Get(TextureType aTextureType, Core::StringView aFileName);
static TextureHandle Create(TextureType aTextureType, Core::StringView aFileName);
static TextureHandle Get(Core::NoCaseStringHash32 aResourceNameId);
static TextureHandle CreateFromFile(Core::StringView aFileName);
//=================================================================================
// Public Constructors
//=================================================================================
Texture() = default;
Texture(const Core::NoCaseStringHash32 aResourceNameId, TextureId anId);
Texture(const Texture& aCopyFrom) = delete;
Texture(Texture&& aMoveFrom) = default;
//=================================================================================
// Public Methods
//=================================================================================
Texture& operator= (const Texture& aCopyFrom) = delete;
Texture& operator= (Texture&& aMoveFrom) = default;
inline const Core::Any& GetPlatformData() const;
inline Core::Any& GetPlatformDataMutable();
private:
//=================================================================================
// Private Methods
//=================================================================================
bool LoadFromFile(Core::StringView aFileName);
//=================================================================================
// Private Data
//=================================================================================
TextureType myTextureType = TextureType::Texture2D;
Core::Any myPlatformData;
};
//-----------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------
inline const Core::Any& Texture::GetPlatformData() const
{
return myPlatformData;
}
//-----------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------
inline Core::Any& Texture::GetPlatformDataMutable()
{
return myPlatformData;
}
}
} |
04e599944556c342e7821014b3b559bb0c8134d2 | 38e225ceb02592645a22b1c60dd02a6a7f82b335 | /PYRAMID.cpp | 4a08d6f79a23e6eef8faad22ca23beefb2071d1a | [] | no_license | JFCowboy/Training-Competitive-Programming | d420cbd78f899c468bebe7a717ffe16290ba8664 | f8f1469dd797aef274dbee88635c66f023cd7bed | refs/heads/master | 2021-01-01T19:47:54.280595 | 2019-06-03T19:15:49 | 2019-06-03T19:15:49 | 98,684,909 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,179 | cpp | PYRAMID.cpp | #include<bits/stdc++.h>
#define INF 0x7fffffff
#define INFLL 1e17
#define PI 2*acos(0.0)
#define show(x) cout<< #x <<" is "<< x <<"\n"
using namespace std;
#define FS first
#define SC second
#define PB(t) push_back(t)
#define ALL(t) t.begin(),t.end()
#define MP(x, y) make_pair((x), (y))
#define Fill(a,c) memset(&a, c, sizeof(a))
#define POPCOUNT __builtin_popcount
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<PII> VPII;
int main() {
#ifndef ONLINE_JUDGE
//freopen("input.txt", "rt", stdin);
//freopen("output.txt", "wt", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(NULL);
for (int N; cin >> N;) {
VPII blocks;
int h, w;
for (int i = 0; i < N; i++) {
cin >> h >> w;
blocks.PB(PII(min(h, w), max(h, w)));
}
sort(ALL(blocks));
int idx = 1;
for (int i = 0; i < N; i++) {
if (blocks[i].FS >= idx) {
idx++;
//cout << blocks[i].FS << ", " << blocks[i].SC << "\n";
}
}
cout << idx - 1 << "\n";
}
return 0;
}
|
b102d03dc9bd45294ee1ff27a26c9ffb74488e8d | cda5454668a4bef547fd514d92e08eaa41fdb12a | /HexViewer/slicedlg.cpp | 939767fa99d05aa9c86818371ad6a093c6aece0a | [] | no_license | yuwuyi/HexViewer | b49ea65a081661487c4a939ee15d761750f5469f | 0e3eff8a7ea1ca0a3a8dd6a4f9bc016c3ac0815e | refs/heads/master | 2020-12-24T16:49:25.684120 | 2013-05-17T14:08:02 | 2013-05-17T14:08:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 371 | cpp | slicedlg.cpp | #include "slicedlg.h"
SliceDlg::SliceDlg(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
Qt::WindowFlags flags = windowFlags();
flags |= Qt::WindowStaysOnTopHint;
setWindowFlags(flags);
}
SliceDlg::~SliceDlg()
{
}
void SliceDlg::changeDirection(int dir) {
emit dirChanged(dir);
}
void SliceDlg::changeOffset(int offset) {
emit offsetChanged(offset);
} |
ae38636164f5b229b42cfd9a92f837c511ff0065 | e9e24546106a24ee03728185b0695417709a58cd | /algorithm_tests/old_code/test_2D_spline.cpp | 27aae0724c94493ca5017d183a6d807576bfcf2a | [] | no_license | Bhare8972/RFD_modelling | 883db23508f48322c02150ad0e97b84a0e6d2aef | bce58d410609df6058637dcbd876ae24ed4358a8 | refs/heads/master | 2021-01-17T03:16:34.734754 | 2017-01-16T13:24:20 | 2017-01-16T13:24:20 | 52,374,905 | 0 | 0 | null | 2016-11-05T15:16:46 | 2016-02-23T16:45:48 | C++ | UTF-8 | C++ | false | false | 3,532 | cpp | test_2D_spline.cpp |
#include <cmath>
#include "GSL_utils.hpp"
#include "constants.hpp"
#include "spline_2D.hpp"
#include "arrays_IO.hpp"
using namespace std;
class test_function
{
public:
int num_tests;
test_function()
{
num_tests=0;
}
inline double operator()(double X, double Y)
{
num_tests++;
return sin(3*X);
//return exp(-X*Y/(3.1415926))*sin(3*X);
//double RET=0.5;
//if(Y<X)
// {
// RET=Y/X;
//}
//else
//{
// RET=(2*PI-Y)/(2*PI-X);
//}
//if( RET!=RET ) return 0.0;
//else if( RET>1 ) return 1;
// else return RET;
}
};
class gaussian : public functor_1D
{
public:
double width;
double amp;
double X0;
gaussian(double width_, double amp_, double X0_)
{
width=width_;
amp=amp_;
X0=X0_;
}
double call(double X)
{
double P=(X-X0)/(width);
return amp*std::exp( -P*P*0.5 );
}
};
class some_peak_func : public functor_1D
{
public:
double call(double X)
{
if(X<PI)
{
return X/PI;
}
else
{
return (2*PI-X)/PI;
}
}
};
int main()
{
test_function F;
adaptive_2DSpline spline(F, 1E5, 0, 0, 2*3.1415926, 2*3.1415926);
print(F.num_tests, "function calls");
////test just interpolation ability
size_t nx=400;
size_t ny=400;
auto X=linspace(0, 2*3.1415926, nx);
auto Y=linspace(0, 2*3.1415926, ny);
gsl::vector output(nx*ny);
for(size_t x_i=0; x_i<nx; x_i++)
{
for(size_t y_i=0; y_i<ny; y_i++)
{
output[x_i + nx*y_i]=spline.call(X[x_i], Y[y_i]);
}
}
//write to file
arrays_output tables_out;
shared_ptr<doubles_output> X_table=make_shared<doubles_output>(X);
tables_out.add_array(X_table);
shared_ptr<doubles_output> Y_table=make_shared<doubles_output>(Y);
tables_out.add_array(Y_table);
shared_ptr<doubles_output> spline_table=make_shared<doubles_output>(output);
tables_out.add_array(spline_table);
binary_output fout("./2D_tst_A");
tables_out.write_out( &fout);
fout.flush();
print("tested spline sampling");
//sample the gaussian in 1D
//gaussian K(3.1415926/4.0, 1, 3.1415926);
some_peak_func K;
auto G_spline =adaptive_sample_retSpline(&K, 0.1, 0, 2*3.1415926 );
G_spline->set_upper_fill();
G_spline->set_lower_fill();
//show the samples
auto gaussian_points=G_spline->callv(X);
arrays_output tables_out_2;
shared_ptr<doubles_output> X_table_2=make_shared<doubles_output>(X);
tables_out_2.add_array(X_table_2);
shared_ptr<doubles_output> Y_table_2=make_shared<doubles_output>(gaussian_points);
tables_out_2.add_array(Y_table_2);
binary_output fout2("./2D_tst_B");
tables_out_2.write_out( &fout2);
fout2.flush();
print("tested gaussian", G_spline->x_vals.size()-1, "splines");
//do our integration!!!!
auto integrate_spline= spline.integrate_along_Y(G_spline);
//show the samples
auto integration_points=integrate_spline->callv(X);
arrays_output tables_out_3;
shared_ptr<doubles_output> X_table_3=make_shared<doubles_output>(X);
tables_out_3.add_array(X_table_3);
shared_ptr<doubles_output> Y_table_3=make_shared<doubles_output>(integration_points);
tables_out_3.add_array(Y_table_3);
binary_output fout3("./2D_tst_C");
tables_out_3.write_out( &fout3);
print("tested integrator");
}
|
862ab0baeea0b2fd0faad30f7e3ca42aa10e5f36 | ac1ab4558209da23e8239a6568ebd627cf4556dc | /Tile.h | 4fdf7a69003755186bc400a3db784f8dc802c6ff | [] | no_license | Daniele-db2/ElaboratoN7 | 5f01cb39f27fb6311f15d44c989702c0de8911e9 | b23fa01c7eb38cf64edc3b1846fe2fd65d3d6fe9 | refs/heads/master | 2022-12-31T16:27:57.987646 | 2020-10-02T13:24:00 | 2020-10-02T13:24:00 | 299,594,921 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 156 | h | Tile.h | #ifndef ELABORATON7_TILE_H
#define ELABORATON7_TILE_H
class Tile {
public:
Tile();
~Tile();
char maps[3] = {};
};
#endif //ELABORATON7_TILE_H |
541080230b5b1ab53c17a70e39d335f0f563bce8 | 77ad804197ec2fdc0a58b36a45084145c56f4c2b | /DeskAssistant/src/version.h | ea839faa7bbfe8e816c0209b592810a7dca96df5 | [] | no_license | camark/SourceCounter | 0ca23c5bf673b3b0eb24e4068155157a08d058f2 | 4bd470c6e2ee8257415587fe0249c009d7063197 | refs/heads/master | 2021-01-17T09:06:44.963094 | 2015-06-03T03:01:43 | 2015-06-03T03:01:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 847 | h | version.h | #ifndef VERSION_H
#define VERSION_H
namespace AutoVersion{
//Date Version Types
static const char DATE[] = "03";
static const char MONTH[] = "03";
static const char YEAR[] = "2009";
static const double UBUNTU_VERSION_STYLE = 9.03;
//Software Status
static const char STATUS[] = "Release";
static const char STATUS_SHORT[] = "r";
//Standard Version Type
static const long MAJOR = 1;
static const long MINOR = 2;
static const long BUILD = 26;
static const long REVISION = 44;
//Miscellaneous Version Types
static const long BUILDS_COUNT = 645;
#define RC_FILEVERSION 1,2,26,44
#define RC_FILEVERSION_STRING "1, 2, 26, 44\0"
static const char FULLVERSION_STRING[] = "1.2.26.44";
//These values are to keep track of your versioning state, don't modify them.
static const long BUILD_HISTORY = 79;
}
#endif //VERSION_H
|
33d0dea28e7608dafc45bc628f748baea08ad5ba | 19d41c4ae325277636383885388c83dd1555f8cf | /atcoder/DP/dp_g.cpp | 816b4464dfb6e5035c87e21cde8bf9a53545eff3 | [] | no_license | henrytsui000/online-judge | 5fd0f7b5c747fb5bfd5f84fb616b9f7346e8abaf | 337aa1d52d587fb653ceeb8b3ee64668804f5b13 | refs/heads/master | 2022-05-28T13:56:04.705485 | 2022-05-19T13:33:43 | 2022-05-19T13:33:43 | 226,999,858 | 3 | 0 | null | 2022-02-02T03:22:06 | 2019-12-10T01:10:15 | C++ | UTF-8 | C++ | false | false | 856 | cpp | dp_g.cpp | #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define pb emplace_back
#define endl '\n'
const int maxn = 1e5+5;
#define int long long
vector<int> edge[maxn];
int cnt[maxn];
queue<int> qu;
int dis[maxn];
int32_t main(){
IOS;
int n,m;
cin>>n>>m;
rep(i,m){
int a,b;
cin>>a>>b;
edge[a].pb(b);
cnt[b]++;
}
rep1(i,n)
if(!cnt[i])
qu.push(i);
int ans=0;
while(!qu.empty()){
for(auto x:edge[qu.front()]){
dis[x]=max(dis[x],dis[qu.front()]+1);
cnt[x]--;
ans=max(ans,dis[x]);
if(!cnt[x])
qu.push(x);
}
qu.pop();
}
cout<<ans<<endl;
return 0;
} |
ebb8767583e0e902657902445b0850170169869e | c5e26167d000f9d52db0a1491c7995d0714f8714 | /洛谷/P1598 垂直柱状图.cpp | b62e9877f9e4fb18b1323319be49a30f2b778546 | [] | no_license | memset0/OI-Code | 48d0970685a62912409d75e1183080ec0c243e21 | 237e66d21520651a87764c385345e250f73b245c | refs/heads/master | 2020-03-24T21:23:04.692539 | 2019-01-05T12:38:28 | 2019-01-05T12:38:28 | 143,029,281 | 18 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,011 | cpp | P1598 垂直柱状图.cpp | // ==============================
// author: memset0
// website: https://memset0.cn
// ==============================
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int read() {
int x = 0; bool m = 0; char c = getchar();
while (!isdigit(c) && c != '-') c = getchar();
if (c == '-') m = 1, c = getchar();
while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
if (m) return -x; else return x;
}
char c;
int a[26];
int main() {
// freopen("INPUT", "r", stdin);
// freopen("OUTPUT", "w", stdout);
while (c = getchar()) {
if (c == -1) break;
if ('A' <= c && c <= 'Z')
a[c - 'A']++;
}
int maxx = 0;
for (int i = 0; i < 26; i++)
maxx = max(maxx, a[i]);
for (int j = maxx; j; j--) {
for (int i = 0; i < 26; i++) {
if (i) putchar(' ');
putchar(a[i] >= j ? '*' : ' ');
}
putchar('\n');
}
for (int i = 0; i < 26; i++) {
if (i) putchar(' ');
putchar('A' + i);
}
putchar('\n');
return 0;
} |
a6df39b0ec254615daf31f90be1286d342fd81a1 | ad478cfcfdf6439cc3a944b1430cd8f5dfca44ac | /udp_demo/s.cpp | b908c20d25ea0d9c1511c83f7ef2be505eb19b62 | [] | no_license | rexyl/Belleman-ford-node | ea338d99e67dc3bcfd9270e5913d250fe13749d0 | 61f653e8cec0d47f4b8df36d9e5668aaf86e4a28 | refs/heads/master | 2021-01-10T05:08:28.842631 | 2015-12-21T18:38:06 | 2015-12-21T18:38:06 | 47,584,417 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,924 | cpp | s.cpp | // sender
#include <iostream> // std::cout
#include <fstream> // std::ifstream
#include <stdlib.h>
#include <unistd.h>
#include <dirent.h>
#include <stdio.h>
#include <string.h>
#include <netdb.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <thread>
#include <time.h>
#include <sys/time.h>
#include <vector>
#include <algorithm>
#include <unordered_map>
int sendfd;
struct sockaddr_in myaddr, remaddr;
void init_sendsock(int port){
if ((sendfd=socket(AF_INET, SOCK_DGRAM, 0))==-1)
printf("socket created\n");
memset((char *)&myaddr, 0, sizeof(myaddr));
myaddr.sin_family = AF_INET;
myaddr.sin_addr.s_addr = htonl(INADDR_ANY);
myaddr.sin_port = htons(port);
if (bind(sendfd, (struct sockaddr *)&myaddr, sizeof(myaddr)) < 0) {
perror("bind failed");
return 0;
}
}
void send_string_to(string ip,int port,string content){
string server = ip;
memset((char *) &remaddr, 0, sizeof(remaddr));
int slen=sizeof(remaddr);
remaddr.sin_family = AF_INET;
remaddr.sin_port = htons(port);
if (inet_aton(server.c_str(), &remaddr.sin_addr)==0) {
fprintf(stderr, "inet_aton() failed\n");
exit(1);
}
//std::string s = "here we go with first one!";
if (sendto(sendfd, content.c_str(), content.size(), 0, (struct sockaddr *)&remaddr, slen)==-1)
perror("sendto");
}
int main(int argc, char const *argv[])
{
//int sendfd; /* receive socket */
int recvlen;
/* create a socket */
if ((sendfd=socket(AF_INET, SOCK_DGRAM, 0))==-1)
printf("socket created\n");
std::string server = "127.0.0.1";
/* bind it to all local addresses and pick any port number */
struct sockaddr_in myaddr, remaddr;
memset((char *)&myaddr, 0, sizeof(myaddr));
myaddr.sin_family = AF_INET;
myaddr.sin_addr.s_addr = htonl(INADDR_ANY);
myaddr.sin_port = htons(5000);
if (bind(sendfd, (struct sockaddr *)&myaddr, sizeof(myaddr)) < 0) {
perror("bind failed");
return 0;
}
/* now define remaddr, the address to whom we want to send messages */
/* For convenience, the host address is expressed as a numeric IP address */
/* that we will convert to a binary format via inet_aton */
memset((char *) &remaddr, 0, sizeof(remaddr));
int slen=sizeof(remaddr);
remaddr.sin_family = AF_INET;
remaddr.sin_port = htons(4119);
if (inet_aton(server.c_str(), &remaddr.sin_addr)==0) {
fprintf(stderr, "inet_aton() failed\n");
exit(1);
}
std::string s = "here we go with first one!";
if (sendto(sendfd, s.c_str(), s.size(), 0, (struct sockaddr *)&remaddr, slen)==-1)
perror("sendto");
remaddr.sin_port = htons(4120);
s = "here we go with second one!";
if (sendto(sendfd, s.c_str(), s.size(), 0, (struct sockaddr *)&remaddr, slen)==-1)
perror("sendto");
return 0;
} |
535ef3fcb546e5749570e1d3daf8bc6cf4f539f6 | 58ed5cda1443024c0595730ff93ccc5b6efa52f2 | /ic_map.cpp | 82d120b94af7a382f950c0cb479207b85c1dde08 | [] | no_license | fenixnix/InfinityArena | a10b80ebccc5a4f5e67ba2b16109cd721a0686af | b5e95c030ea39d43d56d8f5da72e45f6b515deba | refs/heads/master | 2020-03-27T20:31:18.217700 | 2018-09-02T10:17:16 | 2018-09-02T10:17:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 20,847 | cpp | ic_map.cpp | #include "ic_map.h"
#include "global.h"
#include "Build/buildingfactory.h"
#include "obj/objfactory.h"
#include "gaia/nixgaiatype.h"
#include "obj/obj_beast.h"
using namespace nixgaia;
IC_Map* IC_Map::s_pInstance = 0;
IC_Map::IC_Map()
{
cout<<__FUNCTION__<<endl;
}
IC_Map::~IC_Map()
{
freeMap();
}
IC_Map *IC_Map::Instance()
{
if(s_pInstance == 0){
s_pInstance = new IC_Map;
}
return s_pInstance;
}
void IC_Map::generateFromGaia(string fileName)
{
cout<<__FUNCTION__<<": "<<fileName<<"==";
doc.Clear();
cout<< doc.LoadFile(fileName.c_str())<<endl;
XMLElement* root = doc.RootElement();
mapWidth = atoi(root->Attribute("width"));
mapHeight = atoi(root->Attribute("height"));
mapLevel = atoi(root->Attribute("level"));
type = string(root->Attribute("type"));
cout<<__FUNCTION__<<" Map Size: "<<mapWidth<<"*"<<mapHeight<<endl;
freeMap();
create(mapWidth,mapHeight,"home");
cout<<"Item Container Size:"<<mapItems.size()<<endl;
XMLNode* layer = root->FirstChild();
while(layer){
cout<<layer->ToElement()->Name()<<endl;
if(string(layer->ToElement()->Name()) == "layer"){
// cout<<layer->ToElement()->Attribute("name")<<endl;
if(string(layer->ToElement()->Attribute("name")) == "ecoregion"){
cout<<"load map unit"<<endl;
XMLElement* d = layer->FirstChildElement("data");
string src(d->FirstChild()->ToText()->Value());
mapTerraData = Base64::decode(src);
}
}
createWall();
if(string(layer->ToElement()->Name()) == "ObjectLayer"){
if(string(layer->ToElement()->Attribute("name")) == "object"){
cout<<"load map object"<<endl;
XMLElement* d = layer->FirstChildElement("data");
string src(d->FirstChild()->ToText()->Value());
vector<unsigned char> objData;
objData = Base64::decode(src);
for(int i = 0;i<objData.size();i++){
ObjectType type = (ObjectType)objData[i];
switch(type){
case nixgaia::NOTHING: break;
case nixgaia::TREE:BuildingFactory::the()->createDirectly("tree",i%mapWidth,i/mapWidth);break;
case nixgaia::BUSH:BuildingFactory::the()->createDirectly("bush",i%mapWidth,i/mapWidth);break;break;
case PILE:putItem(i%mapWidth,i/mapWidth,Item_Common::create("pile",6));break;
//case BEAST:Obj_Beast::create("deer",i%mapWidth,i/mapWidth);break;
default:break;
}
}
}
BuildingFactory::the()->createDirectly("Idol",mapWidth/2+0.5,mapWidth/2+0.5);
}
layer = layer->NextSibling();
}
cout<<__FUNCTION__<<": finish"<<endl;
}
void IC_Map::createWall()
{
int w = mapWidth;
int h = mapHeight;
B2Physx::the()->createBlockWall(-0.5,-0.5,w-0.5,-0.5);
B2Physx::the()->createBlockWall(-0.5,-0.5,-0.5,h-0.5);
B2Physx::the()->createBlockWall(w-0.5,h-0.5,w-0.5,-0.5);
B2Physx::the()->createBlockWall(w-0.5,h-0.5,-0.5,h-0.5);
for(int j = 0;j<h;j++){
for(int i = 0;i<w;i++){
int id = IC_Map::Instance()->getTerra(i,j);
if(id != CLIFF){
if(IC_Map::Instance()->getTerra(i+1,j) == CLIFF){
B2Physx::the()->createBlockWall(i+0.5,j-0.5,i+0.5,j+0.5);
}
if(IC_Map::Instance()->getTerra(i,j+1) == CLIFF){
B2Physx::the()->createBlockWall(i-0.5,j+0.5,i+0.5,j+0.5);
}
if(IC_Map::Instance()->getTerra(i-1,j) == CLIFF){
B2Physx::the()->createBlockWall(i-0.5,j-0.5,i-0.5,j+0.5);
}
if(IC_Map::Instance()->getTerra(i,j-1) == CLIFF){
B2Physx::the()->createBlockWall(i-0.5,j-0.5,i+0.5,j-0.5);
}
}
}
}
}
void IC_Map::draw()
{
}
void IC_Map::draw(float x, float y, float r)
{
glEnable(GL_DEPTH_TEST);
int w = mapWidth;
int h = mapHeight;
NGLRender *render = NGLRender::the();
render->setMode(MODE_TEX);
for(int j = 0;j<h;j++){
for(int i = 0;i<w;i++){
float d = Global::distance(x,y,i,j);
if(d<r){
int id = getTerra(i,j);
if(id != CLIFF){
render->useTex(id);
//render->useTex(string("tree"));
render->drawFloor(i,j);
if(getTerra(i+1,j) == CLIFF){
render->useTex(CLIFF);
render->drawWall(i+0.5,j+0.5,i+0.5,j-0.5);
}
if(getTerra(i,j+1) == CLIFF){
render->useTex(CLIFF);
render->drawWall(i-0.5,j+0.5,i+0.5,j+0.5);
}
if(getTerra(i-1,j) == CLIFF){
render->useTex(CLIFF);
render->drawWall(i-0.5,j+0.5,i-0.5,j-0.5);
}
if(getTerra(i,j-1) == CLIFF){
render->useTex(CLIFF);
render->drawWall(i-0.5,j-0.5,i+0.5,j-0.5);
}
}
if(id == CLIFF){
render->drawCeil(i,j);
}
}
}
}
render->setMode(MODE_SPRITE);
render->setSpriteSize(128);
BuildingFactory::the()->draw3D(x,y,r);
drawItems(x,y,r);
}
void IC_Map::drawItems(float x, float y, float r)
{
NGLRender *render = NGLRender::the();
render->setMode(MODE_SPRITE);
for(auto itr = mapContainers.begin();itr!=mapContainers.end();itr++){
MapContainer* mc = *itr;
float d = Global::distance(x,y,mc->x,mc->y);
if(d<r){
//render->useTex("pile");
//render->drawPoint(mc->x,mc->y,0.2);
mc->item->drawOnMap(mc->x,mc->y);
}
//mc->item->drawOnMap(mc->x,mc->y);
}
}
void IC_Map::freeMap()
{
B2Physx::the()->clearWall();
for(auto itr = mapContainers.begin();itr!=mapContainers.end();itr++){
delete (*itr)->item;
delete (*itr);
}
mapBuildings.clear();
mapTerraData.clear();
mapItems.clear();
mapContainers.clear();
access.clear();
BuildingFactory::the()->clear();
cout<<__FUNCTION__<<__LINE__<<endl;
Global::the()->world.loadTeam();
cout<<__FUNCTION__<<__LINE__<<endl;
ObjFactory::Instance()->clear();
cout<<__FUNCTION__<<__LINE__<<endl;
Global::the()->world.putTeam();
cout<<__FUNCTION__<<__LINE__<<endl;
}
void IC_Map::create(int w, int h, string name)
{
mapName = name;
mapWidth = w;
mapHeight = h;
//Data
freeMap();
mapTerraData.assign(w*h,0);
mapItems.assign(mapWidth*mapHeight,NULL);
mapBuildings.assign(mapWidth*mapHeight,NULL);
}
void IC_Map::loadMap(string fileName)
{
cout<<__FUNCTION__<<": "<<fileName<<"==";
doc.Clear();
cout<< doc.LoadFile(fileName.c_str())<<endl;
XMLElement* root = doc.RootElement();
mapWidth = atoi(root->Attribute("width"));
mapHeight = atoi(root->Attribute("height"));
mapLevel = atoi(root->Attribute("level"));
type = string(root->Attribute("type"));
cout<<__FUNCTION__<<" Map Size: "<<mapWidth<<"*"<<mapHeight<<endl;
freeMap();
create(mapWidth,mapHeight,"home");
cout<<"Item Container Size:"<<mapItems.size()<<endl;
XMLNode* layer = root->FirstChild();
while(layer){
cout<<layer->ToElement()->Name()<<endl;
if(string(layer->ToElement()->Name()) == "layer"){
// cout<<layer->ToElement()->Attribute("name")<<endl;
if(string(layer->ToElement()->Attribute("name")) == "ecoregion"){
cout<<"load ecoregion"<<endl;
XMLElement* d = layer->FirstChildElement("data");
string src(d->FirstChild()->ToText()->Value());
mapTerraData = Base64::decode(src);
}
if(string(layer->ToElement()->Attribute("name")) == "build"){
cout<<"load build"<<endl;
XMLNode* n = layer->FirstChild();
while(n){
string classify = n->ToElement()->Name();
//cout<<classify<<endl;
int x = atoi(n->ToElement()->Attribute("x"));
int y = atoi(n->ToElement()->Attribute("y"));
if(classify == "Idol"){
BuildingFactory::the()->createDirectly(classify,x,y);
}else{
BuildingFactory::the()->createDirectly(string("Tree"),x,y);
}
n = n->NextSibling();
}
}
if(string(layer->ToElement()->Attribute("name")) == "item"){
cout<<"load item"<<endl;
XMLNode* n = layer->FirstChild();
int itemCount = 0;
while(n){
itemCount ++;
string classify = n->ToElement()->Name();
int x = atoi(n->ToElement()->Attribute("x"));
int y = atoi(n->ToElement()->Attribute("y"));
putItem(x,y,Item_Common::create(classify,10));
n = n->NextSibling();
}
cout<<"Item Count: "<<itemCount<<endl;
}
if(string(layer->ToElement()->Attribute("name")) == "access"){
cout<<"load item"<<endl;
XMLNode* n = layer->FirstChild();
int itemCount = 0;
while(n){
MapAccess ac;
ac.id = string(n->ToElement()->Name());
ac.srcLoc.x = n->ToElement()->IntAttribute("src_x");
ac.srcLoc.y = n->ToElement()->IntAttribute("src_y");
ac.dstLoc.x = n->ToElement()->IntAttribute("dst_x");
ac.dstLoc.y = n->ToElement()->IntAttribute("dst_y");
access.push_back(ac);
n = n->NextSibling();
}
cout<<"Item Count: "<<itemCount<<endl;
}
}
layer = layer->NextSibling();
}
cout<<__FUNCTION__<<": finish"<<endl;
}
void IC_Map::saveMap(string fileName)
{
// doc.Clear();
// XMLDeclaration *declare = doc.NewDeclaration("xml version=\"1.0\" encoding=\"UTF-8\"");
// doc.LinkEndChild(declare);
// doc.LinkEndChild(doc.NewComment("Infinity Chaos tiled map Info"));
// XMLElement* root = doc.NewElement("map");doc.LinkEndChild(root);
// root->SetAttribute("width",mapWidth);
// root->SetAttribute("height",mapHeight);
// root->SetAttribute("level",mapLevel);
// XMLElement* tileSet = doc.NewElement("tileset");root->LinkEndChild(tileSet);
// tileSet->SetAttribute("source","tileSet.tsx");
// tileSet->SetAttribute("orientation","orthogonal");
// //tileSet->SetAttribute("name",tileSetName.c_str());
// //可以包含下列元素:属性(自Tiled0.8.0版本),图像,图块
// XMLElement* layer = doc.NewElement("layer");root->LinkEndChild(layer);
// layer->SetAttribute("name","ecoregion");
// layer->SetAttribute("opacity",1.0f);
// layer->SetAttribute("visible",true);
// XMLElement* data = doc.NewElement("data");layer->LinkEndChild(data);
// data->SetAttribute("encoding","base64");
// string ds = Base64::encode(this->mapTerraData);
// XMLText* textData = doc.NewText(ds.c_str());data->LinkEndChild(textData);
// XMLElement* buildlayer = doc.NewElement("layer");root->LinkEndChild(buildlayer);
// buildlayer->SetAttribute("name","build");
// buildlayer->SetAttribute("opacity",1.0f);
// buildlayer->SetAttribute("visible",true);
// for(int i = 0;i<buildData.size();i++){
// IC_BuildObject *bo = (IC_BuildObject*)buildData.at(i);
// XMLElement* build = doc.NewElement((bo->getBuildClassify()).c_str());
// build->SetAttribute("x",bo->getLocX());
// build->SetAttribute("y",bo->getLocY());
// buildlayer->LinkEndChild(build);
// }
// XMLElement* itemlayer = doc.NewElement("layer");root->LinkEndChild(itemlayer);
// itemlayer->SetAttribute("name","item");
// itemlayer->SetAttribute("opacity",1.0f);
// itemlayer->SetAttribute("visible",true);
// for(int j = 0; j<mapHeight; j++){
// for(int i = 0; i<mapWidth; i++){
// if(itemMapData.at(j*mapWidth+i)!=0){
// IC_ItemObject *bo = (IC_ItemObject*)itemMapData.at(j*mapWidth+i);
// XMLElement* item = doc.NewElement(bo->itemClassify.c_str());
// item->SetAttribute("x",i);
// item->SetAttribute("y",j);
// itemlayer->LinkEndChild(item);
// }
// }
// }
// doc.SaveFile(fileName.c_str());
}
//void IC_Map::draw(int x, int y, int r)
//{
// sdl_render2D::Instance()->tileMap.begin();
// int w = IC_Map::Instance()->getMapWidth();
// int h = IC_Map::Instance()->getMapHeight();
// for(int j = 0;j<h;j++){
// for(int i = 0;i<w;i++){
// int id = IC_Map::Instance()->getTerra(i,j);
// sdl_render2D::Instance()->tileMap.draw(i,j,id-1);
// }
// }
// sdl_render2D::Instance()->tileMap.end();
//}
void IC_Map::setTerra(int x, int y, unsigned char v)
{
if((x<0)||(x>=mapWidth)||(y<0)||(y>=mapHeight)){
return;
}
mapTerraData.at(y*mapWidth+x) = v;
}
unsigned char IC_Map::getTerra(int x, int y)
{
if((x<0)||(x>=mapWidth)||(y<0)||(y>=mapHeight)){
return 0;
}
return mapTerraData.at(y*mapWidth+x);
}
void IC_Map::randomRound(int &x, int &y)
{
int w,h;
w = getMapWidth();
h = getMapHeight();
if(rand()%2){
if(rand()%2){
x = 0;
}else{
x = w-1;
}
y = rand()%h;
}else{
if(rand()%2){
y = 0;
}else{
y = h-1;
}
x = rand()%w;
}
}
inline int IC_Map::nearIntValue(float v)
{
return floor(v+0.5);
}
void IC_Map::getNearIntPos(float x, float y, int &map_x, int &map_y)
{
map_x = nearIntValue(x);
map_y = nearIntValue(y);
}
void IC_Map::getFloorSpace(float x, float y, float w, float h, float &cx, float &cy, int &ix, int &iy)
{
//cout<<__FUNCTION__<<":";
//cout<<x<<"*"<<y<<"*"<<w<<"*"<<h;
float tlx = x-w/2.0f+0.5f;
float tly = y-h/2.0f+0.5f;
IC_Map::getNearIntPos(tlx,tly,ix,iy);
cx = ix+w/2.0f-0.5;
cy = iy+h/2.0f-0.5;
}
void IC_Map::getBuildingTopLeft(Building *b, int &ix, int &iy)
{
cout<<__FUNCTION__<<endl;
//cout<<x<<"*"<<y<<"*"<<w<<"*"<<h;
float tlx = b->x-b->w/2.0f+0.5f;
float tly = b->y-b->h/2.0f+0.5f;
IC_Map::getNearIntPos(tlx,tly,ix,iy);
}
//put item 2 near diff place
Item* IC_Map::putItem(int x, int y, Item *item)
{
cout<<__FUNCTION__<<" x:"<<x<<" y:"<<y<<endl;
int px = x;
int py = y;
int count = 0;
Item * tit = item;
while(tit){
//change place to stack;
Item* it = mapItems[px+mapWidth*py];
if(it==nullptr){
it = tit;
MapContainer* mc = new MapContainer;
mc->x = x;
mc->y = y;
mc->item = tit;
mapContainers.push_back(mc);
mapItems[px+mapWidth*py] = mc->item;
//cout<<"items:"<<items[px+py*mapWidth]<<endl;
return nullptr;
}
if(it->isCommon()&&tit->isCommon()){
Item_Common* itmc = Item_Common::convert(it);
Item_Common* itmcd = Item_Common::convert(tit);
tit = itmc->stack(itmcd);
}
count++;
}
return nullptr;
}
Item *IC_Map::putItemf(float fx, float fy, Item *item)
{
int x,y;
IC_Map::getNearIntPos(fx,fy,x,y);
return putItem(x,y,item);
}
Item *IC_Map::takeItem(int x, int y)
{
//cout<<__FUNCTION__<<" "<<x<<"*"<<y;
Item* tmp = mapItems[x+y*mapWidth];
if(tmp == NULL){
//cout<<"empty place!"<<endl;
return nullptr;
}
mapItems[x+y*mapWidth] = nullptr;
for(auto i = mapContainers.begin();i!=mapContainers.end();){
MapContainer* mc = *i;
if((mc->x == x)&&(mc->y == y)){
delete mc;
i = mapContainers.erase(i);
}else{
i++;
}
}
return tmp;
}
Item *IC_Map::takeItemf(float fx, float fy)
{
int x,y;
IC_Map::getNearIntPos(fx,fy,x,y);
return takeItem(x,y);
}
void IC_Map::putBuilding(Building *build)
{
//cout<<__FUNCTION__<<build<<" "<<build->x<<" "<<build->y<<" "<<build->w<<" "<<build->h;
int x,y;
//float fx,fy;
getFloorSpace(build->x,build->y,build->w,build->h,build->x,build->y,x,y);
//cout<<" "<<x<<" "<<y;
for(int row = y;row<(build->w+y);row++){
for(int col = x;col<(build->w+x);col++){
mapBuildings[row*mapWidth+col] = build;
//cout<<"*"<<row*mapWidth+col;
}
}
//cout<<endl;
}
void IC_Map::buildingOperate(float x, float y, float delta)
{
//cout<<__FUNCTION__;
int ix,iy;
getNearIntPos(x,y,ix,iy);
//cout<<"*"<<ix<<"*"<<iy;
//cout<<endl;
return buildingOperate(ix,iy,delta);
}
void IC_Map::buildingOperate(int x, int y, float delta)
{
//cout<<"pos: "<<x<<"*"<<y<<endl;
Building* bd = IC_Map::Instance()->takeBuilding(x,y);
if(bd){
//cout<<__FUNCTION__<<bd<<endl;
bd->operate();
bd->active();
//cout<<__FUNCTION__<<__LINE__<<endl;
}
}
Building *IC_Map::takeBuilding(float x, float y)
{
cout<<__FUNCTION__;
int ix,iy;
getNearIntPos(x,y,ix,iy);
cout<<"*"<<ix<<"*"<<iy;
cout<<endl;
return takeBuilding(ix,iy);
}
Building *IC_Map::takeBuilding(int x, int y)
{
if((x<0)||(x>=mapWidth)||(y<0)||(y>=mapHeight)){
return nullptr;
}
return mapBuildings[x+y*mapWidth];
}
void IC_Map::destoryBuilding(Building *build)
{
cout<<__FUNCTION__<<build<< endl;
int x,y;
getBuildingTopLeft(build,x,y);
for(int row = y;row<y+build->h;row++){
for(int col = x; col<x+build->w;col++){
mapBuildings[col+row*mapWidth] = nullptr;
}
}
}
void IC_Map::destroyBuilding(float x, float y)
{
destoryBuilding(takeBuilding(x,y));
}
bool IC_Map::checkAccess(float x, float y, MapAccess &ac)
{
for(auto itr = access.begin();itr!=access.end();itr++){
float d = Global::distance(x,y,itr->srcLoc.x,itr->srcLoc.y);
if(d<0.5f){
ac = *itr;
return true;
}
}
return false;
}
bool IC_Map::isEmpty(int x, int y)
{
if(mapBuildings[x+y*mapWidth]){
//cout<<__FUNCTION__<<":building"<<endl;
return false;
}
if(mapItems[x+y*mapWidth]){
//cout<<__FUNCTION__<<":item"<<endl;
return false;
}
return true;
}
void IC_Map::drawItems()
{
//cout<<__FUNCTION__<<endl;
for(auto itr = mapContainers.begin();itr!=mapContainers.end();itr++){
MapContainer* mc = *itr;
mc->item->drawOnMap(mc->x,mc->y);
}
}
//void IC_Map::createBuilding(int x, int y, string classify)
//{
// IC_Object* obj = IC_BuildPrefab::Instance()->create(x,y,classify);
// buildData.push_back(obj);
// buildMapData.at(y*mapWidth+x) = obj;
//}
//void IC_Map::createItem(int x, int y, string classify)
//{
// IC_Object* obj = IC_ItemPrefab::Instance()->create(classify,1,10);
// //itemData.push_back(obj);
// itemMapData.at(y*mapWidth+x) = obj;
//}
//void IC_Map::eraseGroundItem(int x, int y)
//{
// if((x<0)||(x>=mapWidth)||(y<0)||(y>=mapHeight)){
// return;
// }
// itemMapData.at(y*mapWidth+x) = 0;
//}
//IC_Object *IC_Map::getBuild(int x, int y)
//{
// if((x<0)||(x>=mapWidth)||(y<0)||(y>=mapHeight)){
// return 0;
// }
// return buildMapData.at(y*mapWidth+x);
//}
//IC_Object *IC_Map::getItem(int x, int y)
//{
// if((x<0)||(x>=mapWidth)||(y<0)||(y>=mapHeight)){
// return 0;
// }
// return itemMapData.at(y*mapWidth+x);
//}
int IC_Map::getMapWidth() const
{
return mapWidth;
}
int IC_Map::getMapHeight() const
{
return mapHeight;
}
int IC_Map::getMapLevel() const
{
return mapLevel;
}
string IC_Map::getType() const
{
return type;
}
string IC_Map::getType(string fileName)
{
XMLDocument d;
cout<<__FUNCTION__<<fileName;
cout<< d.LoadFile(fileName.c_str())<<endl;
XMLElement* root = d.RootElement();
return string(root->Attribute("type"));
}
|
876409190363128c46dddd927c1275f408efdf20 | 239bc5bc7e571a6af864b2da2afb002df4a66086 | /PSP assgn/pattern.cpp | 584c57b37c24e108ae4b013afeeb16a1cad12320 | [] | no_license | Attyuttam/CplusplusCodesForCoreCSSubjects | 1d025b8e970c2c9b51c84e8280685c3c4d2f357b | a9be8f202f0e4d7d5022a7a498fb415c95bba38a | refs/heads/master | 2021-04-15T14:28:11.306547 | 2018-03-22T14:07:53 | 2018-03-22T14:07:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 504 | cpp | pattern.cpp | #include<iostream>
using namespace std;
int main()
{
int n,i,j,k;
cout<<"Enter the value of n: ";
cin>>n;
for(i=1;i<=n;i++){
for(k=n-1;k>=i;k--){
cout<<" ";
}
for(j=1;j<=(2*i-1);j++){
cout<<"*";
}
cout<<endl;
}
for(i=1;i<=n-1;i++){
for(k=1;k<=i;k++){
cout<<" ";
}
for(j=1;j<=(2*(n-i))-1;j++){
cout<<"*";
}
cout<<endl;
}
}
|
0e344f4a78d4ebdfbca82dc14189612bfbda9278 | 18904ac4e30a87b7c9d5ae569502b60589ed47b0 | /source/graphics/OamManager.cpp | 275512f8c65c4566c78c80cb0d29426c5682141b | [
"MIT",
"Zlib",
"Apache-2.0",
"BSD-2-Clause",
"CC0-1.0"
] | permissive | JoaoBaptMG/gba-modern | a51bce4464e3347cbea216808bafb440347f8e0d | dfb5757d25cbfa7ee795fa8be521f010661b2293 | refs/heads/master | 2023-07-19T18:32:12.849729 | 2023-06-26T14:17:27 | 2023-06-26T14:41:45 | 201,576,240 | 83 | 5 | MIT | 2020-12-01T11:07:13 | 2019-08-10T03:52:52 | C++ | UTF-8 | C++ | false | false | 2,717 | cpp | OamManager.cpp | //--------------------------------------------------------------------------------
// OamManager.cpp
//--------------------------------------------------------------------------------
// Provides a convenient way to push sprites into the drawing queue, as well
// as sorting them
//--------------------------------------------------------------------------------
#include "OamManager.hpp"
#include "graphics.hpp"
#include "util/gba-assert.hpp"
UniqueOamHandle::UniqueOamHandle() : handle(graphics::oam.newHandle()) {}
UniqueOamHandle::~UniqueOamHandle()
{
if (handle == NoObj) return;
graphics::oam.freeHandle(handle);
}
OBJ_ATTR& UniqueOamHandle::operator*() const
{
return graphics::oam.shadowOAM[graphics::oam.pos[handle]];
}
void UniqueOamHandle::setAttrs(u16 attr0, u16 attr1, u16 attr2, u16 prio) const
{
auto& obj = operator*();
obj.attr0 = attr0;
obj.attr1 = attr1;
obj.attr2 = attr2;
obj.fill = prio;
}
UniqueOamHandle::UniqueOamHandle(UniqueOamHandle&& other) : handle(other.handle)
{
other.handle = NoObj;
}
UniqueOamHandle& UniqueOamHandle::operator=(UniqueOamHandle&& other)
{
std::swap(handle, other.handle);
return *this;
}
void OamManager::init()
{
// First, initialize the shadow OAM
oam_init(shadowOAM, MaxObjs);
// Then, initialize the pos array, which doubles as a free list array
firstFreePos = 0;
for (u32 i = 1; i < MaxObjs; i++)
pos[i-1] = i;
pos[MaxObjs-1] = NoObj;
objCount = prevObjCount = 0;
projectilePrio = 0;
}
u8 OamManager::newHandle()
{
// Assert with an error
ASSERT(objCount < MaxObjs);
u8 nextObj = firstFreePos;
firstFreePos = pos[nextObj];
pos[nextObj] = objCount;
idByPos[objCount] = nextObj;
objCount++;
return nextObj;
}
void OamManager::freeHandle(u8 handle)
{
// Move all the ones back
for (u32 i = pos[handle]+1; i < objCount; i++)
{
pos[idByPos[i]]--;
shadowOAM[i-1] = shadowOAM[i];
idByPos[i-1] = idByPos[i];
}
objCount--;
pos[handle] = firstFreePos;
firstFreePos = handle;
}
void OamManager::copyToOAM()
{
u32 postProjObjs = objCount - preProjPos;
u32 prevPostProjObjs = prevObjCount - prevPreProjPos;
// Copy to OAM and to its back
oam_copy(oam_mem, shadowOAM, preProjPos);
oam_copy(oam_mem+MaxObjs-postProjObjs, shadowOAM+preProjPos, postProjObjs);
if (preProjPos < prevPreProjPos)
obj_hide_multi(oam_mem+preProjPos, prevPreProjPos - preProjPos);
if (postProjObjs < prevPostProjObjs)
obj_hide_multi(oam_mem+MaxObjs-prevPostProjObjs, prevPostProjObjs - postProjObjs);
prevObjCount = objCount;
prevPreProjPos = preProjPos;
}
|
10a71cc8586ca10335b36b853896af24e1b96836 | 08dc0f54727f8a3f8a39aa1126b2e19a06969f8b | /src/rendering/shaders/blockshader.h | 66df74fc0621ddaa609be1a4758d080d30254dd2 | [] | no_license | Eae02/mc-renderer | ca781990d4a55448339d28ad39cf39408e2da986 | d2669c062bfa1f093211d6da1e43a969f2537f18 | refs/heads/master | 2021-01-21T10:42:42.652834 | 2019-01-19T14:58:43 | 2019-01-19T15:01:00 | 101,983,446 | 7 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 409 | h | blockshader.h | #pragma once
#include "shader.h"
namespace MCR
{
class BlockShader : public Shader
{
public:
BlockShader(RenderPassInfo renderPassInfo, const VkDescriptorBufferInfo& renderSettingsBufferInfo);
void Bind(CommandBuffer& cb, VkDescriptorSet shadowDescriptorSet, BindModes mode) const;
private:
static const Shader::CreateInfo s_createInfo;
UniqueDescriptorSet m_globalDescriptorSet;
};
}
|
cffdf75c9f20d7a8e732195961115b9baee04ae1 | 2253daa653cc1d84231e01413ddc0be8dd4cc599 | /FPE_ProcCmdLine.hpp | 86b95b99c4939f88308a05822c4263a74bb93729 | [
"MIT"
] | permissive | clockworkengineer/DifferenceEngine | 87c1d0413d998c779ae6691e0c9b9de8a84500c4 | 4b0278f61aaba5cfdd11df2e54bd9493cd205922 | refs/heads/master | 2022-12-05T23:47:16.227393 | 2020-08-16T07:51:06 | 2020-08-16T07:51:06 | 73,412,524 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,409 | hpp | FPE_ProcCmdLine.hpp | #ifndef FPE_PROCCMDLINE_HPP
#define FPE_PROCCMDLINE_HPP
//
// C++ STL
//
#include <string>
#include <unordered_map>
#include <memory>
#include <sstream>
//
// Program components.
//
#include "FPE_TaskAction.hpp"
// =========
// NAMESPACE
// =========
namespace FPE_ProcCmdLine {
//
// Command line option data. Note all option values are treated as strings
// so they may be stored in the optionsMap unordered map.
//
struct FPEOptions {
std::shared_ptr<FPE_TaskActions::TaskAction> action {nullptr}; // Task action function details
std::unordered_map<std::string, std::string> map {}; // Options map
};
// Get command line options
FPEOptions fetchCommandLineOptions(int argc, char* argv[]);
//
// Get option map value and return as type T
//
template <typename T>
T getOption(const FPEOptions& options, const std::string& option) {
T value;
auto entry = options.map.find(option);
if (entry != options.map.end()) {
std::istringstream optionStingStream {entry->second};
optionStingStream >> value;
return (value);
} else {
return ( T { }); // Return default for type
}
}
} // namespace FPE_ProcCmdLine
#endif /* FPE_PROCCMDLINE_HPP */
|
b993edaf4378732f24037545393caee46e90b9ba | e1693e396a7f69b79b3fdbba315535576f332e77 | /GameOfLifeExecution.cpp | 2de797cb23599f3084cf5823a05332b4895c09a7 | [] | no_license | ReconditeRose/ArduinoGameOfLife | cb5aca0dfd41f0569cb6c1c315d7346ac4d63649 | 4079ec078389db366744e48e240a9c92476967d2 | refs/heads/master | 2021-01-19T22:29:45.344898 | 2015-04-18T21:04:57 | 2015-04-18T21:04:57 | 34,158,922 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,530 | cpp | GameOfLifeExecution.cpp | #include "GameOfLifeExecution.h"
/*
---------------Game of Life Code---------------
The cells are updated byte by byte. The previous and current
bytes are kept track of to save on space.
*/
void stepOfLife(byte * cell_Array) {
int k, kminor;
byte mask, val, left, right, pc, j;
byte prevLineConfig[LCD_Y / 8];
byte updateLineConfig[LCD_Y / 8];
byte sumTotal[8];
int i;
for (i = 0; i < LCD_Y / 8; i++)
prevLineConfig[i] = 0;
for (i = 0; i < LCD_X; i++) {
kminor = -1;
for (j = 0; j < LCD_Y / 8; j++) {
updateLineConfig[j] = cell_Array[i + j * LCD_X];
}
for (k = 0; k < LCD_X * LCD_Y / 8; k += LCD_X) {
kminor++;
mask = 0x01;
val = cell_Array[i + k];
left = 0;
right = 0;
left = prevLineConfig[kminor];
if (i != (LCD_X - 1))
right = cell_Array[i + k + 1];
else
right = 0;
for (j = 0; j < 8; j++)
sumTotal[j] = 0;
if (k != 0) {
if ((cell_Array[i + k - 84] & 0x80) == 0x80)
sumTotal[0]++;
if (i != (LCD_X - 1))
if ((cell_Array[i + k - 83] & 0x80) == 0x80)
sumTotal[0]++;
if ((prevLineConfig[kminor - 1] & 0x80) == 0x80)
sumTotal[0]++;
}
if (kminor != (LCD_Y / 8 - 1)) {
if ((cell_Array[i + k + 84] & 0x01) == 0x01)
sumTotal[7]++;
if (i != (LCD_X - 1))
if ((cell_Array[i + k + 85] & 0x01) == 0x01)
sumTotal[7]++;
if ((prevLineConfig[kminor + 1] & 0x01) == 0x01)
sumTotal[7]++;
}
for (j = 0; j < 8; j++) {
pc = 0;
if ((left & mask) == mask)
pc++;
if ((right & mask) == mask)
pc++;
sumTotal[j] += pc;
if (j > 0)
sumTotal[j - 1] += pc;
if (j < 7)
sumTotal[j + 1] += pc;
if ((val & mask) == mask) {
if (j > 0)
sumTotal[j - 1]++;
if (j < 7)
sumTotal[j + 1]++;
}
mask = mask << 1;
}
mask = 0x01;
for (j = 0; j < 8; j++) {
if (sumTotal[j] == 3)
updateLineConfig[kminor] |= mask;
else if (sumTotal[j] == 2)
updateLineConfig[kminor] = updateLineConfig[kminor];
else
updateLineConfig[kminor] &= (~mask);
mask = mask << 1;
}
}
for (j = 0; j < LCD_Y / 8; j++) {
prevLineConfig[j] = cell_Array[i + j * LCD_X];
cell_Array[i + j * LCD_X] = updateLineConfig[j];
}
}
}
|
10e9d8108c0cfd2c359d565e7cac632f011ec6a5 | 7bfcd9d9bc389d8b0a422830dbd3b741a4f7067b | /boj/15686.cpp | 8e3de5380af092d638a8d358a7d23fa4b833c8db | [] | no_license | taehyeok-jang/algorithms | d0a762e5b4abc92b77287b11ff01d9591422c7d9 | 7254984d5b394371c0e96b93912aebc42a45f8cb | refs/heads/master | 2023-04-02T23:45:00.740807 | 2021-03-28T14:35:05 | 2021-03-28T14:35:05 | 123,245,936 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,541 | cpp | 15686.cpp | #include <cstdio>
struct coord{
int x, y;
};
const int MX = 55;
int home_cnt, chicken_cnt;
coord chicken[MX], home[MX * 2];
int ans, N, M;
int map[MX][MX];
int abs(int a) { return a<0? -a:a; }
int min(int a, int b) { return a<b? a:b;}
int manhatten_dist(int x1, int y1, int x2, int y2) { return abs(x1 - x2) + abs(y1 - y2); }
int chicken_dist(bool *selected) {
int sum = 0;
for(int i=0; i<home_cnt; i++) {
int tmp = 0x7fffffff;
for(int j=0; j<chicken_cnt; j++)
if(selected[j])
tmp = min(tmp, manhatten_dist(home[i].x, home[i].y, chicken[j].x, chicken[j].y));
sum += tmp;
}
return sum;
}
void solve() {
for(int i=1; i<(1<<chicken_cnt); i++) {
bool selected[MX] = {false, };
int selected_cnt = 0;
for(int j=0; j<chicken_cnt; j++)
if(i&(1<<j))
selected[j]=1, selected_cnt++;
if(selected_cnt==M)
ans = min(ans, chickent_dist(selected));
}
}
int main() {
scanf("%d%d", &N, &M);
ans = 0x7fffffff;
for (int i = 0; i < N; i++){
for (int j = 0; j < N; j++) {
scanf("%d", &map[i][j]);
if(map[i][j]==1) {
home[home_cnt].x = j;
home[home_cnt].y = i;
home_cnt++;
}
else if(map[i][j]==2) {
chicken[chicken_cnt].x = j;
chicken[chicken_cnt].y = i;
chicken_cnt++;
}
}
}
solve();
printf("%d", ans);
} |
efdbc4e0e0daff9a76b23fc05adfe23bcc402dab | 268897959da125ca7712b5517ac3e074ea591d80 | /seconds.cpp | fa0fa367aed230c2d50b3f81e75516e513c65a88 | [] | no_license | kmccoy1012/Some-of-my-C-Work | 6d214a06891da1bb4b2d8a625ce357e66d59e400 | fc8be04ee6b8fdcd6fc99b02c2945d23a97f1970 | refs/heads/master | 2020-12-24T10:03:34.096321 | 2017-03-22T01:11:38 | 2017-03-22T01:11:38 | 73,248,689 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,304 | cpp | seconds.cpp | /*******************************************
Name: Brian M. Morgan
Class: IST163, 11:00
Dates of Coding: January 24, 2011
Help Received: Entire Class
********************************************/
#include<iostream>
using namespace std;
// constants
const int SEC_PER_MINUTE = 60;
const int SEC_PER_HOUR = 3600;
const int MIN_PER_HOUR = 60;
// Main Function
int main()
{
// variable declaration
int total_seconds; //input
int hours, minutes, seconds; //output
// intro
cout << "This program asks the user for the total time in elapsed seconds" << endl
<< "and output the equivalent in hours, minutes, and seconds." << endl
<< "-------------------------------------------------------------------"
<< endl << endl;
// get the total elapsed seconds from the user
cout << "Enter the total elapsed time in seconds: ";
cin >> total_seconds;
cout << "Enter the total time in minutes; ";
cin >> total_minutes;
// calculate hours, minutes, and seconds
hours = total_seconds / SEC_PER_HOUR;
minutes = total_seconds % SEC_PER_HOUR / MIN_PER_HOUR;
seconds = total_seconds % SEC_PER_MINUTE;
// output the answer
cout << "Total Elapsed time is "<< hours << ":" << minutes << ":" << seconds << endl << endl;
// exit main
return 0;
} |
dd7f4714a4785c97b0fb73dea707e30618667da0 | ec7e6320932aff23a647a68a60bd2f4507b16929 | /src/RollButton1.h | 0cbca87577ced211f6b5d1b15db4c59c67608326 | [] | no_license | DhruvBandaria/COMP397_MidTerm | 5aa1690025d38218a8333b85022d8097cf5fef3e | d05a1d067726b205e7c2fac2bc00bcf7ea08048b | refs/heads/master | 2021-01-06T23:06:08.826336 | 2020-02-19T02:05:18 | 2020-02-19T02:05:18 | 241,507,314 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 327 | h | RollButton1.h | #pragma once
#ifndef __ROLL_BUTTON_1__
#define __ROLL_BUTTON_1__
#include "Button.h"
class SecondScene;
class RollButton1 : public Button
{
public:
RollButton1();
~RollButton1();
bool ButtonClick() override;
bool ButtonClick(SecondScene* sender);
private:
bool m_isClicked;
};
#endif /* defined (__START_BUTTON__) */ |
d424e798cbbdac4cd5487cec3cb47aa64fa3d3b2 | b0c66358ae5c0386db5887e2609929e753c38d18 | /arch/tc/srm784/ValueDivision.cpp | 58b3614c578f31af5741efa5dc6b94f81adb69ce | [] | no_license | michalsvagerka/competitive | e7683133ee5f108429135a3a19b3bbaa6732ea9f | 07f084dff6c1ba6f151c93bf78405574456100e4 | refs/heads/master | 2021-06-07T14:54:35.516490 | 2020-07-07T08:17:56 | 2020-07-07T08:19:09 | 113,440,107 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,257 | cpp | ValueDivision.cpp | #include "../l/lib.h"
class ValueDivision {
public:
vector <int> getArray(vector <int> A) {
int N = A.size();
map<int, vector<int>> Pos;
for (int i = 0; i < N; ++i) {
Pos[A[i]].push_back(i);
}
int mx = 1e9+7;
while (true) {
auto it = Pos.lower_bound(mx);
if (it == Pos.begin()) break;
--it;
mx = it->x;
if (mx == 1) break;
vector<int> pos = it->y;
sort(pos.begin(),pos.end());
int g = pos.size();
if (g >= 2) {
Pos[mx].clear();
for (int i = 0; i < g-1; ++i) {
Pos[mx-1].push_back(pos[i]);
}
Pos[mx].push_back(pos[g-1]);
}
}
vector<int> Ans(N);
for (auto i: Pos) {
for (int j: i.y) {
Ans[j] = i.x;
}
}
return Ans;
}
void solve(istream& cin, ostream& cout) {
cout << getArray({2, 3, 3}) << '\n';
cout << getArray({1, 5, 7, 4, 5, 4, 1}) << '\n';
cout << getArray({7}) << '\n';
cout << getArray({7, 4}) << '\n';
cout << getArray({7, 7, 7, 7}) << '\n';
}
};
|
f129f24395fc92d48f204c1a48b525b63c43ce8b | 9e28005b84f7540655d32cf17815615b2bc6c39f | /plik.cpp | 828a9cdc72ac3e9cef1eb534544548ad9e8184fd | [] | no_license | KubaBBB/Company-shop-toys- | 1c976145a1e8826c17a6b0e9576bc6be0f3573a5 | 94be9e36932c9ca5a0c391d5ca70a3e6a18fe84d | refs/heads/master | 2021-01-23T00:02:13.171579 | 2017-03-21T06:06:03 | 2017-03-21T06:06:03 | 85,692,005 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 591 | cpp | plik.cpp |
#include"plik.h"
#include <iomanip>
using namespace std;
Pracownicy :: Pracownicy()
{
imie = "pusto";
nazwisko = "pusto";
NIP = "0";
PESEL = "0";
}
Pracownicy :: Pracownicy( string name , string surname , string nip , string pesel)
{
imie = name;
nazwisko = surname;
NIP = nip;
PESEL = pesel;
}
void Pracownicy :: print() const
{
using namespace std;
cout << setw(10) << "Imie: " << imie << endl;
cout << setw(10) << "nazwisko: " << nazwisko << endl;
cout << setw(10) << "NIP: " << NIP << endl;
cout << setw(10) << "PESEL: " << PESEL << endl;
}
Pracownicy :: ~Pracownicy() {}
|
bad9ae62c836a4039bb8c00967dc8c72d1e870d9 | 27a7b51c853902d757c50cb6fc5774310d09385a | /[Client]LUNA/GMToolManager.cpp | 297357464b4df0ba37db9ca36c670765a08dd63a | [] | no_license | WildGenie/LUNAPlus | f3ce20cf5b685efe98ab841eb1068819d2314cf3 | a1d6c24ece725df097ac9a975a94139117166124 | refs/heads/master | 2021-01-11T05:24:16.253566 | 2015-06-19T21:34:46 | 2015-06-19T21:34:46 | 71,666,622 | 4 | 2 | null | 2016-10-22T21:27:35 | 2016-10-22T21:27:34 | null | UHC | C++ | false | false | 130,130 | cpp | GMToolManager.cpp | #include "stdafx.h"
#ifdef _GMTOOL_
#include "GMToolManager.h"
#include "ObjectManager.h"
#include "ItemManager.h"
#include "CheatMsgParser.h"
#include "FilteringTable.h"
#include "ChatManager.h"
#include "MHMap.h"
#include "Commdlg.h"
#include "CommCtrl.h"
#include "MHFile.h"
#include "cSkillTreeManager.h"
#include "MainGame.h"
#include "../[cc]skill/client/manager/skillmanager.h"
#include "../[cc]skill/client/info/activeskillinfo.h"
#include "WeatherManager.h"
#include "DungeonMgr.h"
#include "cResourceManager.h"
#include "GameIn.h"
#include "BigMapDlg.h"
#include "TileManager.h"
extern HWND _g_hWnd;
extern HINSTANCE g_hInst;
GLOBALTON(CGMToolManager)
//extern HWND ghWnd;
extern int g_MapChannelNum[100];
CGMToolManager::CGMToolManager()
{
m_hWndDlg = NULL;
ZeroMemory( m_hWndSub, sizeof( m_hWndSub ) );
m_nSelectMenu = eMenu_Count;
m_bShow = FALSE;
m_bCanUse = FALSE;
m_bSubShow = FALSE;
m_cbChannelCount = 0;
m_hWndChatList = NULL;
m_nNumNow = 0;
m_nNumWait = 0;
m_nBufLen = 0;
m_bLogin = FALSE;
m_nPower = eGM_POWER_MAX; //3
m_hWndLoginDlg = NULL;
//임시
m_nNullMove = 0;
}
CGMToolManager::~CGMToolManager()
{
}
BOOL CGMToolManager::CreateGMDialog()
{
if( m_hWndDlg ) return FALSE;
m_hWndDlg = CreateDialog( g_hInst, MAKEINTRESOURCE(IDD_GMDIALOG), _g_hWnd, GMDlgProc );
m_hWndLoginDlg = CreateDialog( g_hInst, MAKEINTRESOURCE(IDD_GMLOGIN), _g_hWnd, GMLoginDlgProc );
CreateGMSubDialog();
// CHEATMGR->SetCheatEnable( TRUE );
return TRUE;
}
BOOL CGMToolManager::CreateGMSubDialog()
{
m_hWndSub[eMenu_Move] = CreateDialog( g_hInst, MAKEINTRESOURCE(IDD_GM_MOVE_DIALOG), m_hWndDlg, GMSubMoveDlgProc );
m_hWndSub[eMenu_Where] = CreateDialog( g_hInst, MAKEINTRESOURCE(IDD_GM_WHERE_DIALOG), m_hWndDlg, GMSubWhereDlgProc );
m_hWndSub[eMenu_Item] = CreateDialog( g_hInst, MAKEINTRESOURCE(IDD_GM_ITEM_DIALOG), m_hWndDlg, GMSubItemDlgProc );
m_hWndSub[eMenu_Hide] = CreateDialog( g_hInst, MAKEINTRESOURCE(IDD_GM_HIDE_DIALOG), m_hWndDlg, GMSubHideDlgProc );
m_hWndSub[eMenu_PK] = CreateDialog( g_hInst, MAKEINTRESOURCE(IDD_GM_PK_DIALOG), m_hWndDlg, GMSubPKDlgProc );
m_hWndSub[eMenu_Discon] = CreateDialog( g_hInst, MAKEINTRESOURCE(IDD_GM_DISCON_DIALOG), m_hWndDlg, GMSubDisconDlgProc );
m_hWndSub[eMenu_ForbidChat] = CreateDialog( g_hInst, MAKEINTRESOURCE(IDD_GM_CHAT_DIALOG), m_hWndDlg, GMSubForbidChatDlgProc );
m_hWndSub[eMenu_Mob] = CreateDialog( g_hInst, MAKEINTRESOURCE(IDD_GM_REGEN_DIALOG), m_hWndDlg, GMSubRegenDlgProc );
m_hWndSub[eMenu_Counsel]= CreateDialog( g_hInst, MAKEINTRESOURCE(IDD_GM_COUNSEL_DIALOG), m_hWndDlg, GMSubCounselDlgProc );
m_hWndSub[eMenu_Notice] = CreateDialog( g_hInst, MAKEINTRESOURCE(IDD_GM_NOTICE_DIALOG), m_hWndDlg, GMSubNoticeDlgProc );
m_hWndSub[eMenu_Event] = CreateDialog( g_hInst, MAKEINTRESOURCE(IDD_GM_EVENT_DIALOG), m_hWndDlg, GMSubEventDlgProc );
m_hWndSub[eMenu_EventMap] = CreateDialog( g_hInst, MAKEINTRESOURCE(IDD_GM_EVENTMAP_DIALOG), m_hWndDlg, GMSubEventMapDlgProc );
m_hWndSub[eMenu_EventNotify] = CreateDialog( g_hInst, MAKEINTRESOURCE(IDD_GM_EVENTNOTIFY_DIALOG), m_hWndDlg, GMSubEventNotifyDlgProc );
m_hWndSub[eMenu_Weather]= CreateDialog( g_hInst, MAKEINTRESOURCE(IDD_GM_WEATHER_DIALOG), m_hWndDlg, GMWeatherDlgProc );
m_hWndSub[eMenu_Dungeon]= CreateDialog( g_hInst, MAKEINTRESOURCE(IDD_GM_DUNGEON_DIALOG), m_hWndDlg, GMDungeonDlgProc );
return TRUE;
}
BOOL CGMToolManager::DestroyGMDialog()
{
if( !m_hWndDlg ) return FALSE;
SaveChatList();
// DestroyWindow( m_hWndDlg );
m_hWndDlg = NULL;
m_hWndLoginDlg = NULL;
DestroyGMSubDialog();
m_nSelectMenu = eMenu_Count;
return TRUE;
}
BOOL CGMToolManager::DestroyGMSubDialog()
{
for( int i = 0 ; i < eMenu_Count ; ++i )
{
if( m_hWndSub[i] )
{
// DestroyWindow( m_hWndSub[i] );
m_hWndSub[i] = NULL;
}
}
return TRUE;
}
void CGMToolManager::ShowGMDialog( BOOL bShow, BOOL bUpdate )
{
if( !m_hWndDlg ) return;
if( !m_bCanUse ) return;
//여기서부터 로그인(Login) 체크 하는곳
if( bShow && !m_bLogin && MAINGAME->GetUserLevel() == eUSERLEVEL_GM )
{
ShowWindow( m_hWndLoginDlg, SW_SHOW );
return;
}
else if( MAINGAME->GetUserLevel() > eUSERLEVEL_GM )
{
return;
}
//여기까지
if( bShow )
{
ShowWindow( m_hWndDlg, SW_SHOWNA );
SetPositionByMainWindow();
/*
// 100613 ONS Developer와 GM은 Move, Item&Skill, Hide, Mob기능만 이용가능.
BOOL bIsEnable = TRUE;
if( MAINGAME->GetUserLevel() == eUSERLEVEL_GM ||
MAINGAME->GetUserLevel() == eUSERLEVEL_DEVELOPER )
{
bIsEnable = FALSE;
}
else
{
bIsEnable = TRUE;
}
EnableWindow( GetDlgItem( m_hWndDlg, IDC_GM_MNBTN_WHERE ), bIsEnable );
EnableWindow( GetDlgItem( m_hWndDlg, IDC_GM_MNBTN_PK ), bIsEnable );
EnableWindow( GetDlgItem( m_hWndDlg, IDC_GM_MNBTN_DISCON ), bIsEnable );
EnableWindow( GetDlgItem( m_hWndDlg, IDC_GM_MNBTN_FORBIDCHAT ), bIsEnable );
EnableWindow( GetDlgItem( m_hWndDlg, IDC_GM_MNBTN_COUNSEL ), bIsEnable );
EnableWindow( GetDlgItem( m_hWndDlg, IDC_GM_MNBTN_NOTICE ), bIsEnable );
EnableWindow( GetDlgItem( m_hWndDlg, IDC_GM_MNBTN_EVENT ), bIsEnable );
EnableWindow( GetDlgItem( m_hWndDlg, IDC_GM_MNBTN_EVENTMAP ), bIsEnable );
EnableWindow( GetDlgItem( m_hWndDlg, IDC_GM_MNBTN_EVENTNOTIFY ), bIsEnable );
EnableWindow( GetDlgItem( m_hWndDlg, IDC_GM_MNBTN_WEATHER ), bIsEnable );
EnableWindow( GetDlgItem( m_hWndDlg, IDC_GM_MNBTN_DUNGEON ), bIsEnable );
*/
}
else
{
GMTOOLMGR->OnClickMenu( eMenu_Count );
ShowWindow( m_hWndDlg, SW_HIDE );
}
if( bUpdate )
m_bShow = bShow;
//임시로 여기위치
static int bRegist = FALSE;
int i;
char bufNum[20];
//combobox등록
if( !bRegist )
{
// if( m_hWndSub[eMenu_Item] )
{
ITEMMGR->SetItemIfoPositionHead();
ITEM_INFO* pInfo = NULL;
char cbItemString[MAX_ITEMNAME_LENGTH+16];
while( (pInfo=ITEMMGR->GetItemInfoData()) != NULL )
{
wsprintf( cbItemString, "%s(%d)", pInfo->ItemName, pInfo->ItemIdx );
if( pInfo->Category == eItemCategory_Equip )
{
switch( pInfo->EquipType )
{
case eEquipType_Weapon:
{
// if( pInfo->Grade == 0 )
SendDlgItemMessage( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_WEAPON, CB_ADDSTRING, 0, (LPARAM)cbItemString );
}
break;
case eEquipType_Armor:
{
// if( pInfo->Grade == 0 )
SendDlgItemMessage( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_CLOTHES, CB_ADDSTRING, 0, (LPARAM)cbItemString );
}
break;
case eEquipType_Accessary:
case eEquipType_Pet:
{
SendDlgItemMessage( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_ACCESSORY, CB_ADDSTRING, 0, (LPARAM)cbItemString );
}
break;
}
}
else if( pInfo->Category == eItemCategory_Expend )
{
SendDlgItemMessage( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_POTION, CB_ADDSTRING, 0, (LPARAM)cbItemString );
}
else
{
SendDlgItemMessage( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_ETC, CB_ADDSTRING, 0, (LPARAM)cbItemString );
}
}
SendDlgItemMessage( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_WEAPON, CB_SETCURSEL, 0, 0 );
SendDlgItemMessage( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_CLOTHES, CB_SETCURSEL, 0, 0 );
SendDlgItemMessage( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_ACCESSORY, CB_SETCURSEL, 0, 0 );
SendDlgItemMessage( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_POTION, CB_SETCURSEL, 0, 0 );
SendDlgItemMessage( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_ETC, CB_SETCURSEL, 0, 0 );
SendDlgItemMessage( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_SKILL, CB_SETCURSEL, 0, 0 );
EnableWindow( GetDlgItem( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_SKILLSUNG ), FALSE );
//Grade
for( i = 0 ; i <= 9 ; ++i )
{
wsprintf( bufNum, "+%d", i );
SendDlgItemMessage( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_WEAPONGRADE, CB_ADDSTRING, 0, (LPARAM)bufNum );
SendDlgItemMessage( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_CLOTHESGRADE, CB_ADDSTRING, 0, (LPARAM)bufNum );
}
SendDlgItemMessage( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_WEAPONGRADE, CB_SETCURSEL, 0, 0 );
SendDlgItemMessage( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_CLOTHESGRADE, CB_SETCURSEL, 0, 0 );
SetDlgItemInt( m_hWndSub[eMenu_Item], IDC_GMITEM_EDT_POTION, 1, TRUE );
SetDlgItemInt( m_hWndSub[eMenu_Item], IDC_GMITEM_EDT_ETC, 1, TRUE );
SendDlgItemMessage( m_hWndSub[eMenu_Item], IDC_GMITEM_SPN_POTION, UDM_SETRANGE, 0, (LPARAM)MAKELONG(50, 1) );
SendDlgItemMessage( m_hWndSub[eMenu_Item], IDC_GMITEM_SPN_ETC, UDM_SETRANGE, 0, (LPARAM)MAKELONG(50, 1) );
}
{
CheckDlgButton(
m_hWndSub[eMenu_Mob],
IDC_GMREGEN_SUMMON_MONSTER_CHECK,
TRUE);
CheckDlgButton(
m_hWndSub[eMenu_Mob],
IDC_GMREGEN_SUMMON_VEHICLE_CHECK,
TRUE);
SendMessage(
m_hWndSub[eMenu_Mob],
WM_COMMAND,
IDC_GMREGEN_SUMMON_MONSTER_CHECK,
BN_CLICKED);
ITEMMGR->SetItemIfoPositionHead();
for(const ITEM_INFO* pInfo = ITEMMGR->GetItemInfoData();
0 < pInfo;
pInfo = ITEMMGR->GetItemInfoData())
{
SendDlgItemMessage( m_hWndSub[eMenu_Mob], IDC_GMREGEN_CMB_ITEM, CB_ADDSTRING, 0, (LPARAM)pInfo->ItemName );
}
SendDlgItemMessage( m_hWndSub[eMenu_Mob], IDC_GMREGEN_CMB_ITEM, CB_SETCURSEL, 0, 0 );
for(MAPTYPE i = 1; i < MAX_MAP_NUM; ++i )
{
LPCTSTR pStrMap = GetMapName(i);
if(0 == _tcsicmp("?", pStrMap))
{
continue;
}
SendDlgItemMessage( m_hWndSub[eMenu_Mob], IDC_GMREGEN_CMB_MAP, CB_ADDSTRING, 0, (LPARAM)pStrMap );
SendDlgItemMessage( m_hWndSub[eMenu_Move], IDC_GMMOVE_CMB_MAP, CB_ADDSTRING, 0, (LPARAM)pStrMap );
SendDlgItemMessage( m_hWndSub[eMenu_Discon], IDC_GMDISCON_CMB_MAP, CB_ADDSTRING, 0, (LPARAM)pStrMap );
SendDlgItemMessage( m_hWndSub[eMenu_PK], IDC_GMPK_CMB_MAP, CB_ADDSTRING, 0, (LPARAM)pStrMap );
SendDlgItemMessage( m_hWndSub[eMenu_Notice], IDC_GMNOTICE_CMB_MAP, CB_ADDSTRING, 0, (LPARAM)pStrMap );
if(DungeonMGR->IsDungeonMap(MAPTYPE(i)))
{
SendDlgItemMessage( m_hWndSub[eMenu_Dungeon], IDC_GMDUNGEON_CMB_MAPLIST, CB_ADDSTRING, 0, (LPARAM)pStrMap );
}
}
SendDlgItemMessage( m_hWndSub[eMenu_Mob], IDC_GMREGEN_CMB_MAP, CB_SETCURSEL, 0, 0 );
SendDlgItemMessage( m_hWndSub[eMenu_Move], IDC_GMMOVE_CMB_MAP, CB_SETCURSEL, 0, 0 );
SendDlgItemMessage( m_hWndSub[eMenu_Discon], IDC_GMDISCON_CMB_MAP, CB_SETCURSEL, 0, 0 );
SendDlgItemMessage( m_hWndSub[eMenu_PK], IDC_GMPK_CMB_MAP, CB_SETCURSEL, 0, 0 );
SendDlgItemMessage( m_hWndSub[eMenu_Notice], IDC_GMNOTICE_CMB_MAP, CB_SETCURSEL, 0, 0 );
SendDlgItemMessage( m_hWndSub[eMenu_Dungeon], IDC_GMDUNGEON_CMB_MAPLIST, CB_SETCURSEL, 0, 0 );
}
#ifdef _TL_LOCAL_
SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_ADDSTRING, 0, (LPARAM)"Character Exp" );
SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_ADDSTRING, 0, (LPARAM)"Item Drop" );
SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_ADDSTRING, 0, (LPARAM)"Money Drop" );
SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_ADDSTRING, 0, (LPARAM)"---" );
SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_ADDSTRING, 0, (LPARAM)"---" );
SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_ADDSTRING, 0, (LPARAM)"---" );
SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_ADDSTRING, 0, (LPARAM)"---" );
SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_ADDSTRING, 0, (LPARAM)"---" );
SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_ADDSTRING, 0, (LPARAM)"---" );
SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_ADDSTRING, 0, (LPARAM)"Money Amount" );
SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_ADDSTRING, 0, (LPARAM)"---" );
#else
SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_ADDSTRING, 0, (LPARAM)"경험치율" );
SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_ADDSTRING, 0, (LPARAM)"아이템드랍율" );
SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_ADDSTRING, 0, (LPARAM)"돈드랍율" );
SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_ADDSTRING, 0, (LPARAM)"받는데미지율" );
SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_ADDSTRING, 0, (LPARAM)"주는데미지율" );
SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_ADDSTRING, 0, (LPARAM)"내력소모율" );
SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_ADDSTRING, 0, (LPARAM)"운기조식속도" );
SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_ADDSTRING, 0, (LPARAM)"파티경험치율" );
SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_ADDSTRING, 0, (LPARAM)"특기수련치율" );
SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_ADDSTRING, 0, (LPARAM)"돈드랍액수율" );
SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_ADDSTRING, 0, (LPARAM)"무공경험치율" );
#endif
SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_SETCURSEL, 0, 0 );
bRegist = TRUE;
}
}
BOOL CGMToolManager::IsGMDialogMessage( LPMSG pMessage)
{
if( IsWindow( m_hWndDlg ) && IsDialogMessage( m_hWndDlg, pMessage ) )
return TRUE;
if( m_nSelectMenu < eMenu_Count )
if( m_hWndSub[m_nSelectMenu] )
{
if( IsWindow( m_hWndSub[m_nSelectMenu] ) && IsDialogMessage( m_hWndSub[m_nSelectMenu], pMessage ) )
return TRUE;
}
return FALSE;
}
void CGMToolManager::SetPositionByMainWindow()
{
RECT rcMain, rcDlg;
GetWindowRect( _g_hWnd, &rcMain );
GetWindowRect( m_hWndDlg, &rcDlg );
int nDlgWidth = rcDlg.right - rcDlg.left;
int X = rcMain.left - nDlgWidth;
if( X < 0 ) X = rcMain.left;
int Y = rcMain.top+GetSystemMetrics(SM_CYSIZEFRAME)+GetSystemMetrics(SM_CYCAPTION);
SetWindowPos( m_hWndDlg, NULL, X, Y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
SetPositionSubDlg();
}
void CGMToolManager::SetPositionSubDlg()
{
RECT rcDlg;
GetWindowRect( m_hWndDlg, &rcDlg );
if( m_nSelectMenu < eMenu_Count )
{
if( m_hWndSub[m_nSelectMenu] )
{
int subX = rcDlg.right;
int subY = rcDlg.top + 36 + m_nSelectMenu * 28;
if(m_nSelectMenu == eMenu_Dungeon)
subY = rcDlg.top + 36;
SetWindowPos( m_hWndSub[m_nSelectMenu], NULL, subX, subY, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
}
}
}
void CGMToolManager::OnClickMenu( int nMenu )
{
switch( nMenu )
{
case eMenu_Move:
{
switch( m_nPower )
{
case eGM_POWER_MONITOR: break;
case eGM_POWER_PATROLLER: break;
case eGM_POWER_AUDITOR: break;
case eGM_POWER_EVENTER: break;
case eGM_POWER_QA: break;
}
}
break;
case eMenu_Where:
{
switch( m_nPower )
{
case eGM_POWER_MONITOR: break;
case eGM_POWER_PATROLLER: break;
case eGM_POWER_AUDITOR: break;
case eGM_POWER_EVENTER: break;
case eGM_POWER_QA: break;
}
}
break;
case eMenu_Item:
{
switch( m_nPower )
{
case eGM_POWER_MONITOR: return; break;
case eGM_POWER_PATROLLER: return; break;
case eGM_POWER_AUDITOR: return; break;
case eGM_POWER_EVENTER: break;
case eGM_POWER_QA: return; break;
}
}
break;
case eMenu_Hide:
{
switch( m_nPower )
{
case eGM_POWER_MONITOR: break;
case eGM_POWER_PATROLLER: break;
case eGM_POWER_AUDITOR: break;
case eGM_POWER_EVENTER: break;
case eGM_POWER_QA: break;
}
}
break;
case eMenu_Chat:
{
switch( m_nPower )
{
case eGM_POWER_MONITOR: break;
case eGM_POWER_PATROLLER: break;
case eGM_POWER_AUDITOR: break;
case eGM_POWER_EVENTER: break;
case eGM_POWER_QA: break;
}
}
break;
case eMenu_PK:
{
switch( m_nPower )
{
case eGM_POWER_MONITOR: return; break;
case eGM_POWER_PATROLLER: return; break;
case eGM_POWER_AUDITOR: return; break;
case eGM_POWER_EVENTER: break;
case eGM_POWER_QA: break;
}
}
break;
case eMenu_Discon:
{
switch( m_nPower )
{
case eGM_POWER_MONITOR: return; break;
case eGM_POWER_PATROLLER: return; break;
case eGM_POWER_AUDITOR: break;
case eGM_POWER_EVENTER: break;
case eGM_POWER_QA: break;
}
}
break;
case eMenu_ForbidChat:
{
switch( m_nPower )
{
case eGM_POWER_MONITOR: return; break;
case eGM_POWER_PATROLLER: return; break;
case eGM_POWER_AUDITOR: break;
case eGM_POWER_EVENTER: break;
case eGM_POWER_QA: return; break;
}
}
break;
case eMenu_Mob:
{
switch( m_nPower )
{
case eGM_POWER_MONITOR: return; break;
case eGM_POWER_PATROLLER: return; break;
case eGM_POWER_AUDITOR: return; break;
case eGM_POWER_EVENTER: break;
case eGM_POWER_QA: break;
}
}
break;
case eMenu_Counsel:
{
switch( m_nPower )
{
case eGM_POWER_MONITOR: return; break;
case eGM_POWER_PATROLLER: return; break;
case eGM_POWER_AUDITOR: break;
case eGM_POWER_EVENTER: break;
case eGM_POWER_QA: return; break;
}
}
break;
case eMenu_Notice:
{
switch( m_nPower )
{
case eGM_POWER_MONITOR: break;
case eGM_POWER_PATROLLER: return; break;
case eGM_POWER_AUDITOR: break;
case eGM_POWER_EVENTER: break;
case eGM_POWER_QA: break;
}
}
break;
case eMenu_Event:
{
switch( m_nPower )
{
case eGM_POWER_MONITOR: return; break;
case eGM_POWER_PATROLLER: return; break;
case eGM_POWER_AUDITOR: return; break;
case eGM_POWER_EVENTER: break;
case eGM_POWER_QA: break;
}
}
break;
case eMenu_EventMap:
{
switch( m_nPower )
{
case eGM_POWER_MONITOR: break;
case eGM_POWER_PATROLLER: break;
case eGM_POWER_AUDITOR: break;
case eGM_POWER_EVENTER: break;
case eGM_POWER_QA: break;
}
}
break;
case eMenu_EventNotify:
{
switch( m_nPower )
{
case eGM_POWER_MONITOR: break;
case eGM_POWER_PATROLLER: return; break;
case eGM_POWER_AUDITOR: break;
case eGM_POWER_EVENTER: break;
case eGM_POWER_QA: break;
}
}
break;
case eMenu_Weather:
{
switch( m_nPower )
{
case eGM_POWER_MONITOR: break;
case eGM_POWER_PATROLLER: return; break;
case eGM_POWER_AUDITOR: break;
case eGM_POWER_EVENTER: break;
case eGM_POWER_QA: break;
}
}
break;
}
// 090909 ONS 아이템 윈도우를 활성화하기전 스킬리스트를 설정한다.
switch( nMenu )
{
case eMenu_Move:
{
if( !IsDlgButtonChecked(m_hWndDlg, IDC_GM_MNBTN_MOVE ) &&
IsDlgButtonChecked(m_hWndSub[eMenu_Move],IDC_GMMOVE_BTN_MINIMAP) &&
SendMessage( GetDlgItem( m_hWndSub[eMenu_Move], IDC_GMMOVE_CHK_MINIMAP_ON ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
GMTOOLMGR->ActiveMiniMap( TRUE );
}
break;
case eMenu_Item:
{
char cbSkillString[MAX_PATH] = {0};
const SkillData* pSkillList = GetSkillTreeList();
SendDlgItemMessage( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_SKILL, CB_RESETCONTENT, 0, 0 );
int nCount = 0;
for(cSkillInfo* pSkillInfo = SKILLMGR->GetSkillInfo( pSkillList[nCount++].index );
0 < pSkillInfo;
pSkillInfo = SKILLMGR->GetSkillInfo( pSkillList[nCount++].index ))
{
for (DWORD level=0; level < pSkillList[nCount].level; ++level)
{
pSkillInfo = SKILLMGR->GetSkillInfo( pSkillList[nCount].index + level );
if(0 == pSkillInfo)
{
continue;
}
wsprintf( cbSkillString, "%s(%d)", pSkillInfo->GetName(), pSkillInfo->GetIndex());
SendDlgItemMessage( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_SKILL, CB_ADDSTRING, 0, (LPARAM)cbSkillString);
}
}
SendDlgItemMessage( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_SKILL, CB_SETCURSEL, 0, 0 );
SendDlgItemMessage( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_SKILLSUNG, CB_SETCURSEL, 0, 0 );
}
break;
case eMenu_Weather:
{
// 등록된 날씨 정보를 메뉴에 등록시킨다.
SendDlgItemMessage( m_hWndSub[eMenu_Weather], IDC_GMWEATHER_CMB_TYPE, CB_RESETCONTENT, 0, 0 );
WEATHERMGR->AddGMToolMenu();
}
break;
}
if( IsDlgButtonChecked(m_hWndDlg, IDC_GM_MNBTN_MOVE ) )
{
GMTOOLMGR->ActiveMiniMap( FALSE );
}
if( nMenu >= eMenu_Count )
{
if( m_nSelectMenu < eMenu_Count )
{
if( m_hWndSub[m_nSelectMenu] )
ShowWindow( m_hWndSub[m_nSelectMenu], SW_HIDE );
CheckDlgButton( m_hWndDlg, IDC_GM_MNBTN_MOVE + m_nSelectMenu, BST_UNCHECKED );
}
m_nSelectMenu = eMenu_Count;
CheckDlgButton( m_hWndDlg, IDC_GM_MNBTN_NONE, BST_CHECKED );
m_bSubShow = FALSE;
SetFocus( _g_hWnd );
}
else
{
if( m_nSelectMenu == nMenu )
{
if( m_hWndSub[m_nSelectMenu] )
ShowWindow( m_hWndSub[m_nSelectMenu], SW_HIDE );
CheckDlgButton( m_hWndDlg, IDC_GM_MNBTN_MOVE + m_nSelectMenu, BST_UNCHECKED );
m_nSelectMenu = eMenu_Count;
CheckDlgButton( m_hWndDlg, IDC_GM_MNBTN_NONE, BST_CHECKED );
m_bSubShow = FALSE;
SetFocus( _g_hWnd );
}
else
{
ShowWindow( m_hWndSub[m_nSelectMenu], SW_HIDE );
CheckDlgButton( m_hWndDlg, IDC_GM_MNBTN_MOVE + m_nSelectMenu, BST_UNCHECKED );
m_nSelectMenu = nMenu;
SetPositionSubDlg();
CheckDlgButton( m_hWndDlg, IDC_GM_MNBTN_MOVE + m_nSelectMenu, BST_CHECKED );
if( m_hWndSub[m_nSelectMenu] )
AnimateWindow( m_hWndSub[m_nSelectMenu], 200, AW_SLIDE | AW_HOR_POSITIVE );
m_bSubShow = TRUE;
}
}
}
BOOL CGMToolManager::OnGMMoveCommand( int nMethod )
{
if( !HERO ) return FALSE;
if( !m_hWndSub[eMenu_Move] ) return FALSE;
SetFocus( _g_hWnd );
if( nMethod == 0 )
{
BOOL bRt;
VECTOR3 pos;
pos.x = GetDlgItemInt( m_hWndSub[eMenu_Move], IDC_GMMOVE_EDT_X, &bRt, TRUE ) * 100.0f;
if( !bRt ) return FALSE;
pos.y = 0;
pos.z = GetDlgItemInt( m_hWndSub[eMenu_Move], IDC_GMMOVE_EDT_Y, &bRt, TRUE ) * 100.0f;
if( !bRt ) return FALSE;
MOVE_POS msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_MOVE_SYN;
msg.dwObjectID = gHeroID;
msg.dwMoverID = gHeroID;
msg.cpos.Compress(&pos);
NETWORK->Send(&msg,sizeof(msg));
}
else if( nMethod == 1 )
{
char buf[MAX_NAME_LENGTH+1] = {0,};
int nLen = GetDlgItemText( m_hWndSub[eMenu_Move], IDC_GMMOVE_EDT_NAME, buf, MAX_NAME_LENGTH+1 );
if( nLen > MAX_NAME_LENGTH || nLen < 4 ) return FALSE;
if( strncmp( HERO->GetObjectName(), buf, MAX_NAME_LENGTH+1 ) == 0 ) //자기 자신
return FALSE;
MSG_NAME_DWORD msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_MOVETOCHAR_SYN;
msg.dwObjectID = gHeroID;
msg.dwData = 0;
SafeStrCpy( msg.Name, buf, MAX_NAME_LENGTH + 1 );
NETWORK->Send(&msg, sizeof(msg));
}
else if( nMethod == 2)
{
char buf[MAX_MAP_NAME_LENGTH+1] = {0,};
//int nLen = GetDlgItemText( m_hWndSub[eMenu_Move], IDC_GMMOVE_EDT_MAP, buf, MAX_NAME_LENGTH+1);
int nLen = GetDlgItemText( m_hWndSub[eMenu_Move], IDC_GMMOVE_CMB_MAP, buf, MAX_MAP_NAME_LENGTH+1 );
if( nLen > MAX_MAP_NAME_LENGTH ) return FALSE;
WORD wMapNum = GetMapNumForName( buf );
if( wMapNum == 0 ) return FALSE;
//BOOL bRt;
//int nChannel = GetDlgItemInt( m_hWndSub[eMenu_Move], IDC_GMMOVE_EDT_CHANNEL, &bRt, TRUE );
//int nChannel = GetDlgItemInt( m_hWndSub[eMenu_Move], IDC_GMMOVE_CMB_CHANNEL, &bRt, TRUE );
int nChannel = SendDlgItemMessage( m_hWndSub[eMenu_Move], IDC_GMMOVE_CMB_CHANNEL, CB_GETCURSEL, 0, 0 ) + 1;
//if( bRt )
//if( m_cbChannelCount > 0 && nChannel > 0 && nChannel <= m_cbChannelCount )
if(0<nChannel &&nChannel<=g_MapChannelNum[wMapNum])
{
nChannel = nChannel - 1; //0부터 시작하는 인덱스라 -1
}
MSG_NAME_DWORD2 msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_CHANGEMAP_SYN;
msg.dwObjectID = gHeroID;
msg.dwData1 = (DWORD)wMapNum;
msg.dwData2 = (DWORD)nChannel;
msg.Name[0] = 0; //hero
NETWORK->Send( &msg, sizeof(msg) );
}
else if( nMethod == 3)
{
// 100427 ONS NPC로의 이동처리 추가
int nIndex = SendDlgItemMessage( m_hWndSub[eMenu_Move], IDC_GMMOVE_CMB_NPC, CB_GETCURSEL, 0, 0 );
VECTOR3 pos = m_NpcList[nIndex].Pos;
MOVE_POS msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_MOVE_SYN;
msg.dwObjectID = gHeroID;
msg.dwMoverID = gHeroID;
msg.cpos.Compress(&pos);
NETWORK->Send(&msg,sizeof(msg));
}
return TRUE;
}
BOOL CGMToolManager::OnUserMoveCommand( int nMethod )
{
if( !m_hWndSub[eMenu_Move] ) return FALSE;
SetFocus( _g_hWnd );
char UserName[MAX_NAME_LENGTH+1] = {0,};
int nLength = GetDlgItemText( m_hWndSub[eMenu_Move], IDC_GMMOVE_EDT_USER, UserName, MAX_NAME_LENGTH+1 );
if( nLength > MAX_NAME_LENGTH || nLength < 4 ) return FALSE;
if( (FILTERTABLE->IsInvalidCharInclude((unsigned char*)UserName)) == TRUE )
return FALSE;
if( nMethod == 0 )
{
BOOL bRt;
VECTOR3 pos;
pos.x = GetDlgItemInt( m_hWndSub[eMenu_Move], IDC_GMMOVE_EDT_X, &bRt, TRUE ) * 100.0f;
if( !bRt ) return FALSE;
pos.y = 0;
pos.z = GetDlgItemInt( m_hWndSub[eMenu_Move], IDC_GMMOVE_EDT_Y, &bRt, TRUE ) * 100.0f;
if( !bRt ) return FALSE;
MOVE_POS_USER msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_MOVEUSER_SYN;
msg.dwObjectID = gHeroID;
SafeStrCpy( msg.Name, UserName, MAX_NAME_LENGTH + 1 );
msg.cpos.Compress(&pos);
NETWORK->Send(&msg,sizeof(msg));
}
else if( nMethod == 1 )
{
if( strncmp( HERO->GetObjectName(), UserName, MAX_NAME_LENGTH ) == 0 ) //자기 자신
return FALSE;
MSG_NAME_DWORD msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_MOVETOCHAR_SYN;
msg.dwObjectID = gHeroID;
msg.dwData = 1; //데려오기
SafeStrCpy( msg.Name, UserName, MAX_NAME_LENGTH + 1 );
NETWORK->Send(&msg, sizeof(msg));
}
else if( nMethod == 2 )
{
char buf[MAX_MAP_NAME_LENGTH+1] = {0,};
int nLen = GetDlgItemText( m_hWndSub[eMenu_Move], IDC_GMMOVE_CMB_MAP, buf, MAX_MAP_NAME_LENGTH+1 );
if( nLen > MAX_MAP_NAME_LENGTH ) return FALSE;
WORD wMapNum = GetMapNumForName( buf );
int nChannel = SendDlgItemMessage( m_hWndSub[eMenu_Move], IDC_GMMOVE_CMB_CHANNEL, CB_GETCURSEL, 0, 0 ) + 1;
if(0<nChannel &&nChannel<=g_MapChannelNum[wMapNum])
{
nChannel = nChannel - 1;
}
MSG_NAME_DWORD2 msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_CHANGEMAP_SYN;
msg.dwObjectID = gHeroID;
msg.dwData1 = (DWORD)wMapNum;
msg.dwData2 = (DWORD)nChannel;
SafeStrCpy( msg.Name, UserName, MAX_NAME_LENGTH + 1 );
NETWORK->Send( &msg, sizeof(msg) );
}
else if( nMethod == 3 )
{
int nIndex = SendDlgItemMessage( m_hWndSub[eMenu_Move], IDC_GMMOVE_CMB_NPC, CB_GETCURSEL, 0, 0 );
VECTOR3 pos = m_NpcList[nIndex].Pos;
MOVE_POS_USER msg;
ZeroMemory( &msg, sizeof(msg) );
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_MOVEUSER_SYN;
msg.dwObjectID = gHeroID;
SafeStrCpy( msg.Name, UserName, MAX_NAME_LENGTH + 1 );
msg.cpos.Compress(&pos);
NETWORK->Send(&msg,sizeof(msg));
}
return TRUE;
}
BOOL CGMToolManager::OnItemCommand()
{
if( !m_hWndSub[eMenu_Item] ) return FALSE;
SetFocus( _g_hWnd );
int nResult = 0;
WORD wCount = 1;
char buf[64];
DWORD idx = (DWORD)-1;
if( SendMessage( GetDlgItem( m_hWndSub[eMenu_Item], IDC_GMITEM_BTN_WEAPON ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
GetDlgItemText( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_WEAPON, buf, MAX_ITEMNAME_LENGTH+16 );
sscanf(strrchr(buf,'('), "(%lu)", &idx);
int nSel = SendDlgItemMessage( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_WEAPONGRADE, CB_GETCURSEL, 0, 0 );
if( nSel > 0 && nSel <= 9 )
wsprintf( buf, "%s+%d", buf, nSel );
nResult = 1; //1:Item
}
else if( SendMessage( GetDlgItem( m_hWndSub[eMenu_Item], IDC_GMITEM_BTN_CLOTHES ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
GetDlgItemText( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_CLOTHES, buf, MAX_ITEMNAME_LENGTH+16 );
sscanf(strrchr(buf,'('), "(%lu)", &idx);
int nSel = SendDlgItemMessage( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_CLOTHESGRADE, CB_GETCURSEL, 0, 0 );
if( nSel > 0 && nSel <= 9 )
wsprintf( buf, "%s+%d", buf, nSel );
nResult = 1; //1:Item
}
else if( SendMessage( GetDlgItem( m_hWndSub[eMenu_Item], IDC_GMITEM_BTN_ACCESSORY ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
GetDlgItemText( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_ACCESSORY, buf, MAX_ITEMNAME_LENGTH+16 );
sscanf(strrchr(buf,'('), "(%lu)", &idx);
nResult = 1; //1:Item
}
else if( SendMessage( GetDlgItem( m_hWndSub[eMenu_Item], IDC_GMITEM_BTN_POTION ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
GetDlgItemText( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_POTION, buf, MAX_ITEMNAME_LENGTH+16 );
sscanf(strrchr(buf,'('), "(%lu)", &idx);
BOOL rt;
int nCount = GetDlgItemInt( m_hWndSub[eMenu_Item], IDC_GMITEM_EDT_POTION, &rt, TRUE );
if( rt )
{
if( nCount < 0 ) nCount = 0;
else if( nCount > 99 ) nCount = 99;
wCount = (WORD)nCount;
nResult = 1; //1:Item;
}
}
else if( SendMessage( GetDlgItem( m_hWndSub[eMenu_Item], IDC_GMITEM_BTN_ETC ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
GetDlgItemText( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_ETC, buf, MAX_ITEMNAME_LENGTH+16 );
sscanf(strrchr(buf,'('), "(%lu)", &idx);
BOOL rt;
int nCount = GetDlgItemInt( m_hWndSub[eMenu_Item], IDC_GMITEM_EDT_ETC, &rt, TRUE );
if( rt )
{
if( nCount < 0 ) nCount = 0;
else if( nCount > 50 ) nCount = 50;
wCount = (WORD)nCount;
nResult = 1; //1:Item;
}
}
else if( SendMessage( GetDlgItem( m_hWndSub[eMenu_Item], IDC_GMITEM_BTN_MONEY ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
BOOL rt;
DWORD dwMoney = GetDlgItemInt( m_hWndSub[eMenu_Item], IDC_GMITEM_EDT_MONEY, &rt, TRUE );
if( !rt ) return FALSE;
SetDlgItemInt( m_hWndSub[eMenu_Item], IDC_GMITEM_EDT_MONEY, 0, TRUE );
MSG_DWORD msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_MONEY_SYN;
msg.dwObjectID = gHeroID;
msg.dwData = dwMoney;
NETWORK->Send( &msg, sizeof(msg) );
}
// 090831 ONS 스킬포인트 획득 추가
else if( SendMessage( GetDlgItem( m_hWndSub[eMenu_Item], IDC_GMITEM_BTN_SKILLPOINT ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
BOOL rt;
DWORD dwpoint = GetDlgItemInt( m_hWndSub[eMenu_Item], IDC_GMITEM_EDT_SKILLPOINT, &rt, TRUE );
if( !rt ) return FALSE;
SetDlgItemInt( m_hWndSub[eMenu_Item], IDC_GMITEM_EDT_SKILLPOINT, 0, TRUE );
MSG_DWORD msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_SKILLPOINT_SYN;
msg.dwObjectID = gHeroID;
msg.dwData = dwpoint;
NETWORK->Send( &msg, sizeof(msg) );
}
else if( SendMessage( GetDlgItem( m_hWndSub[eMenu_Item], IDC_GMITEM_BTN_SKILL ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
// 090909 ONS 스킬획득 기능 추가
GetDlgItemText( m_hWndSub[eMenu_Item], IDC_GMITEM_CMB_SKILL, buf, MAX_ITEMNAME_LENGTH+16 );
sscanf(strrchr(buf,'('), "(%lu)", &idx);
cSkillInfo* pInfo = SKILLMGR->GetSkillInfo( idx );
if( pInfo == NULL ) return FALSE;
MSG_DWORD_WORD msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_UPDATE_SKILL_SYN;
msg.dwObjectID = gHeroID;
msg.dwData = (pInfo->GetIndex()/100)*100 +1;
msg.wData = WORD(pInfo->GetIndex() % 100);
NETWORK->Send(&msg,sizeof(msg));
}
if( nResult == 1 )
{
if (idx == -1) return FALSE;
ITEM_INFO* pInfo = ITEMMGR->GetItemInfo(idx);
if( pInfo == NULL ) return FALSE;
MSG_DWORD_WORD msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_ITEM_SYN;
msg.dwObjectID = gHeroID;
msg.dwData = pInfo->ItemIdx;
msg.wData = wCount;
NETWORK->Send(&msg,sizeof(msg));
}
return TRUE;
}
BOOL CGMToolManager::OnDisconCommand()
{
if( !m_hWndSub[eMenu_Discon] ) return FALSE;
SetFocus( _g_hWnd );
char buf[MAX_NAME_LENGTH+1] = { 0, };
if( SendMessage( GetDlgItem( m_hWndSub[eMenu_Discon], IDC_GMDISCON_BTN_USER ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
int nLen = GetDlgItemText( m_hWndSub[eMenu_Discon], IDC_GMDISCON_EDT_CHAR, buf, MAX_NAME_LENGTH+1 );
if( nLen < 4 || nLen > MAX_NAME_LENGTH )
return FALSE;
if( strncmp( HERO->GetObjectName(), buf, MAX_NAME_LENGTH ) == 0 )
return FALSE;
if( (FILTERTABLE->IsInvalidCharInclude((unsigned char*)buf)) == TRUE )
return FALSE;
MSG_NAME msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_BANCHARACTER_SYN;
msg.dwObjectID = gHeroID;
SafeStrCpy( msg.Name, buf, MAX_NAME_LENGTH + 1 );
NETWORK->Send( &msg,sizeof(msg) );
}
else //map전체
{
int nLen = GetDlgItemText( m_hWndSub[eMenu_Discon], IDC_GMDISCON_CMB_MAP, buf, MAX_NAME_LENGTH+1 );
if( nLen > MAX_NAME_LENGTH )
return FALSE;
WORD wMapNum = GetMapNumForName( buf );
if( wMapNum == 0 ) return FALSE;
WORD wExceptSelf = 0;
if( SendMessage( GetDlgItem( m_hWndSub[eMenu_Discon], IDC_GMDISCON_BTN_EXCEPTSELF ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
wExceptSelf = 1;
//channel도 구분할 필요가 있는가... Agent가 채널을 알고 있나?
MSG_WORD2 msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_BANMAP_SYN;
msg.dwObjectID = gHeroID;
msg.wData1 = wMapNum;
msg.wData2 = wExceptSelf;
NETWORK->Send( &msg, sizeof(msg) );
}
return TRUE;
}
BOOL CGMToolManager::OnForbidChatCommand( int nMethod )
{
if( !HERO ||
!m_hWndSub[eMenu_ForbidChat] )
{
return FALSE;
}
SetFocus( _g_hWnd );
char Name[MAX_NAME_LENGTH+1] = { 0, };
int nLen = GetDlgItemText( m_hWndSub[eMenu_ForbidChat], IDC_GMCHAT_EDT_USER, Name, MAX_NAME_LENGTH+1 );
if( strncmp( HERO->GetObjectName(), Name, MAX_NAME_LENGTH ) == 0 ||
nLen < 4 ||
nLen > MAX_NAME_LENGTH ||
(FILTERTABLE->IsInvalidCharInclude((unsigned char*)Name)) == TRUE )
{
return FALSE;
}
if( 1 == nMethod )
{
char Reason[MAX_CHAT_LENGTH+1] = { 0, };
nLen = GetDlgItemText( m_hWndSub[eMenu_ForbidChat], IDC_GMCHAT_EDT_REASON, Reason, MAX_CHAT_LENGTH+1 );
if( nLen < 1 || nLen > 100 )
{
return FALSE;
}
BOOL rt = FALSE;
const int nSecond = GetDlgItemInt( m_hWndSub[eMenu_ForbidChat], IDC_GMCHAT_EDT_SEC, &rt, TRUE);
if(FALSE == rt)
{
return FALSE;
}
MSG_FORBID_CHAT msg;
ZeroMemory( &msg, sizeof(msg) );
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_FORBID_CHAT_SYN;
msg.dwObjectID = gHeroID;
msg.dwData = nSecond;
SafeStrCpy( msg.Name, Name, MAX_NAME_LENGTH+1 );
SafeStrCpy( msg.Reason, Reason, MAX_CHAT_LENGTH+1 );
NETWORK->Send(&msg,sizeof(msg));
}
else
{
MSG_NAME msg;
ZeroMemory( &msg, sizeof(msg) );
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_PERMIT_CHAT_SYN;
msg.dwObjectID = gHeroID;
SafeStrCpy( msg.Name, Name, MAX_NAME_LENGTH+1 );
NETWORK->Send(&msg,sizeof(msg));
}
return TRUE;
}
BOOL CGMToolManager::OnWhereCommand()
{
if( !m_hWndSub[eMenu_Where] ) return FALSE;
SetFocus( _g_hWnd );
MSG_NAME msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_WHEREIS_SYN;
msg.dwObjectID = gHeroID;
int nLen = GetDlgItemText( m_hWndSub[eMenu_Where], IDC_GMWHERE_EDT_USER, msg.Name, MAX_NAME_LENGTH+1 );
if( nLen < 4 || nLen > MAX_NAME_LENGTH ) return FALSE;
msg.Name[MAX_NAME_LENGTH] = 0;
if( (FILTERTABLE->IsInvalidCharInclude((unsigned char*)msg.Name)) == TRUE )
{
return TRUE;
}
NETWORK->Send( &msg, sizeof(msg) );
//초기화
SetDlgItemText( m_hWndSub[eMenu_Where], IDC_GMWHERE_EDT_MAP, "" );
SetDlgItemInt( m_hWndSub[eMenu_Where], IDC_GMWHERE_EDT_CHANNEL, 0, TRUE );
SetDlgItemInt( m_hWndSub[eMenu_Where], IDC_GMWHERE_EDT_X, 0, TRUE );
SetDlgItemInt( m_hWndSub[eMenu_Where], IDC_GMWHERE_EDT_Y, 0, TRUE );
//
return TRUE;
}
void CGMToolManager::DisplayWhereInfo( char* MapName, int nChannel, int nX, int nY )
{
if( !m_hWndSub[eMenu_Where] ) return;
SetFocus( _g_hWnd );
SetDlgItemText( m_hWndSub[eMenu_Where], IDC_GMWHERE_EDT_MAP, MapName );
SetDlgItemInt( m_hWndSub[eMenu_Where], IDC_GMWHERE_EDT_CHANNEL, nChannel, FALSE );
SetDlgItemInt( m_hWndSub[eMenu_Where], IDC_GMWHERE_EDT_X, nX, FALSE );
SetDlgItemInt( m_hWndSub[eMenu_Where], IDC_GMWHERE_EDT_Y, nY, FALSE );
}
BOOL CGMToolManager::OnHideCommand()
{
if( !m_hWndSub[eMenu_Hide] ) return FALSE;
SetFocus( _g_hWnd );
// char buf[MAX_NAME_LENGTH+1] = {0,};
int nLen = 0;
BOOL bHide = TRUE;
if( SendMessage( GetDlgItem( m_hWndSub[eMenu_Hide], IDC_GMHIDE_BTN_HIDE ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
bHide = TRUE;
else
bHide = FALSE;
// 06. 05 HIDE NPC - 이영준
if( SendMessage( GetDlgItem( m_hWndSub[eMenu_Hide], IDC_GMHIDE_BTN_NPC ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
CObject* pObject = OBJECTMGR->GetSelectedObject();
if( !pObject ) return FALSE;
if( pObject->GetObjectKind() != eObjectKind_Npc ) return FALSE;
MSG_WORD3 msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_NPCHIDE_SYN;
msg.dwObjectID = gHeroID;
msg.wData1 = ((CNpc*)pObject)->GetNpcUniqueIdx();
msg.wData2 = (WORD)SendDlgItemMessage( m_hWndSub[eMenu_Hide], IDC_GMHIDE_CMB_CHANNEL, CB_GETCURSEL, 0, 0 );
msg.wData3 = !bHide;
NETWORK->Send( &msg, sizeof(msg) );
return TRUE;
}
else
{
MSG_NAME_DWORD msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_HIDE_SYN;
msg.dwObjectID = gHeroID;
msg.dwData = (DWORD)bHide;
if( SendMessage( GetDlgItem( m_hWndSub[eMenu_Hide], IDC_GMHIDE_BTN_USER ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
nLen = GetDlgItemText( m_hWndSub[eMenu_Hide], IDC_GMHIDE_EDT_USER, msg.Name, MAX_NAME_LENGTH+1 );
if( nLen < 4 || nLen > MAX_NAME_LENGTH )
return FALSE;
}
else
{
msg.Name[0] = 0; //hero
}
msg.Name[MAX_NAME_LENGTH] = 0;
NETWORK->Send( &msg, sizeof(msg) );
return TRUE;
}
}
BOOL CGMToolManager::OnPKCommand()
{
if( !m_hWndSub[eMenu_PK] ) return FALSE;
SetFocus( _g_hWnd );
char buf[MAX_NAME_LENGTH+1] = {0,};
int nLen = GetDlgItemText( m_hWndSub[eMenu_PK], IDC_GMPK_CMB_MAP, buf, MAX_NAME_LENGTH+1 );
if( nLen > MAX_NAME_LENGTH ) return FALSE;
WORD wMapNum = GetMapNumForName( buf );
if( wMapNum == 0 ) return FALSE;
MSG_WORD2 msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_PKALLOW_SYN;
msg.dwObjectID = gHeroID;
msg.wData1 = wMapNum;
if( SendMessage( GetDlgItem( m_hWndSub[eMenu_PK], IDC_GMPK_BTN_NOPK ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
msg.wData2 = 0; //not allow
}
else
{
msg.wData2 = 1; //allow
}
NETWORK->Send(&msg,sizeof(msg));
return TRUE;
}
BOOL CGMToolManager::OnRegenCommand()
{
if( !m_hWndSub[eMenu_Mob] ) return FALSE;
SetFocus( _g_hWnd );
char buf[MAX_ITEMNAME_LENGTH+1] = {0};
if( SendMessage( GetDlgItem( m_hWndSub[eMenu_Mob], IDC_GMREGEN_BTN_MODEDIRECT ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
const HWND menuHandle = m_hWndSub[eMenu_Mob];
const int nSelectedSel = SendMessage(
GetDlgItem(menuHandle, IDC_GMREGEN_CMB_MOBNAME),
CB_GETCURSEL,
0,
0);
const DWORD monsterKind = SendMessage(
GetDlgItem(menuHandle, IDC_GMREGEN_CMB_MOBNAME),
CB_GETITEMDATA,
nSelectedSel,
0);
BOOL rt = FALSE;
const int nMobCount = GetDlgItemInt(
menuHandle,
IDC_GMREGEN_EDT_MOBNUM,
&rt,
TRUE);
if(FALSE == rt)
{
return FALSE;
}
else if(0 == GetDlgItemText(
menuHandle,
IDC_GMREGEN_CMB_MAP,
buf,
sizeof(buf) / sizeof(*buf)))
{
return FALSE;
}
const MAPTYPE wMapNum = GetMapNumForName(
buf);
if(0 == wMapNum)
{
return FALSE;
}
const int nChannel = SendDlgItemMessage(
menuHandle,
IDC_GMREGEN_CMB_CHANNEL,
CB_GETCURSEL,
0,
0);
if(0 > nChannel)
{
return FALSE;
}
else if(nChannel > g_MapChannelNum[wMapNum])
{
return FALSE;
}
const float nX = float(GetDlgItemInt(
menuHandle,
IDC_GMREGEN_EDT_X,
&rt,
TRUE));
if(FALSE == rt)
{
return FALSE;
}
const float nY = float(GetDlgItemInt(
menuHandle,
IDC_GMREGEN_EDT_Y,
&rt,
TRUE));
if(FALSE == rt)
{
return FALSE;
}
const int nRad = GetDlgItemInt(
menuHandle,
IDC_GMREGEN_EDT_RAD,
&rt,
TRUE );
if(FALSE == rt)
{
return FALSE;
}
else if(0 == GetDlgItemText(
menuHandle,
IDC_GMREGEN_CMB_ITEM,
buf,
sizeof(buf) / sizeof(*buf)))
{
return FALSE;
}
const ITEM_INFO* const pInfo = ITEMMGR->FindItemInfoForName(
buf);
if(0 == pInfo)
{
return FALSE;
}
const int nDropRatio = GetDlgItemInt(
menuHandle,
IDC_GMREGEN_EDT_ITEM,
&rt,
TRUE);
const VehicleScript& vehicleScript = GAMERESRCMNGR->GetVehicleScript(
monsterKind);
if(0 == vehicleScript.mMonsterKind)
{
MSG_EVENT_MONSTERREGEN message;
ZeroMemory(
&message,
sizeof(message));
message.Category = MP_CHEAT;
message.Protocol = MP_CHEAT_EVENT_MONSTER_REGEN;
message.dwObjectID = gHeroID;
message.MonsterKind = WORD(monsterKind);
message.cbMobCount = BYTE(min(100, max(nMobCount, 1)));
message.wMap = wMapNum;
message.cbChannel = (BYTE)nChannel;
message.Pos.x = max(0, nX * 100);
message.Pos.z = max(0, nY * 100);
message.wRadius = WORD(min(10000, max(0, nRad * 100)));
message.ItemID = pInfo->ItemIdx;
message.dwDropRatio = min(100, max(0, nDropRatio));
NETWORK->Send(
&message,
sizeof(message));
}
else
{
MSG_DWORD4 message;
ZeroMemory(
&message,
sizeof(message));
message.Category = MP_CHEAT;
message.Protocol = MP_CHEAT_VEHICLE_SUMMON_SYN;
message.dwObjectID = gHeroID;
message.dwData1 = monsterKind;
message.dwData2 = DWORD(nX * 100);
message.dwData3 = DWORD(nY * 100);
NETWORK->Send(
&message,
sizeof(message));
}
return TRUE;
}
else if( SendMessage( GetDlgItem( m_hWndSub[eMenu_Mob], IDC_GMREGEN_BTN_MODEFILE ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
char lpstrFile[MAX_PATH] = {0,};
GetDlgItemText( m_hWndSub[eMenu_Mob], IDC_GMREGEN_EDT_FILE, lpstrFile, MAX_PATH );
if( lpstrFile[0] == 0 )
return FALSE;
CMHFile fp;
if( !fp.Init( lpstrFile, "rt" ) )
return FALSE;
char buff[256]={0,};
while(1)
{
fp.GetString(buff);
if(fp.IsEOF())
break;
if(buff[0] == '@')
{
fp.GetLineX(buff, 256);
continue;
}
if( strcmp( buff, "$REGEN" ) == 0 )
{
DWORD dwGroup = fp.GetDword();
if( dwGroup == 0 )
{
fp.Release();
return FALSE;
}
if((fp.GetString())[0] == '{')
{
MSG_EVENT_MONSTERREGEN msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_EVENT_MONSTER_REGEN;
msg.dwObjectID = gHeroID;
msg.MonsterKind = WORD(GAMERESRCMNGR->GetMonsterIndexForName(fp.GetString()));
msg.cbMobCount = fp.GetByte();
msg.wMap = GetMapNumForName( fp.GetString() );
msg.cbChannel = fp.GetByte();
msg.Pos.x = (float)fp.GetWord() * 100.0f;
msg.Pos.z = (float)fp.GetWord() * 100.0f;
msg.wRadius = fp.GetWord()*100;
ITEM_INFO* pInfo = ITEMMGR->FindItemInfoForName( fp.GetString() );
if( pInfo )
msg.ItemID = pInfo->ItemIdx;
else
msg.ItemID = 0;
msg.dwDropRatio = fp.GetDword();
//if( msg.MonsterKind == 0 || msg.wMap == 0 || msg.cbChannel > m_cbChannelCount
if( msg.MonsterKind == 0 || msg.wMap == 0 || msg.cbChannel > g_MapChannelNum[msg.wMap]
|| ( msg.ItemID == 0 && msg.dwDropRatio != 0 ) )
{
ASSERT(0);
}
else
{
NETWORK->Send( &msg,sizeof(msg) );
}
}
else
{
fp.Release();
return FALSE;
}
if((fp.GetString())[0] != '}')
{
fp.Release();
return FALSE;
}
}
}
fp.Release();
return TRUE;
}
else if( SendMessage( GetDlgItem( m_hWndSub[eMenu_Mob], IDC_GMREGEN_BTN_DELETE ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
MSGBASE msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_EVENT_MONSTER_DELETE;
msg.dwObjectID = gHeroID;
NETWORK->Send( &msg, sizeof(msg) );
return TRUE;
}
else if( SendMessage( GetDlgItem( m_hWndSub[eMenu_Mob], IDC_GMREGEN_BTN_UNSUMMON_VEHICLE ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
TCHAR text[MAX_PATH] = {0};
GetDlgItemText(
m_hWndSub[eMenu_Mob],
IDC_GMREGEN_VEHICLE_DROPDOWN,
text,
sizeof(text) / sizeof(*text));
LPCTSTR textSeperator = "[], ";
LPCTSTR textPositionX = _tcstok(
text,
textSeperator);
LPCTSTR textPositionY = _tcstok(
0,
textSeperator);
MSG_DWORD2 message;
ZeroMemory(
&message,
sizeof(message));
message.Category = MP_CHEAT;
message.Protocol = MP_CHEAT_VEHICLE_UNSUMMON_SYN;
message.dwObjectID = gHeroID;
message.dwData1 = _ttoi(
textPositionX ? textPositionX : "") * 100;
message.dwData2 = _ttoi(
textPositionY ? textPositionY : "") * 100;
NETWORK->Send(
&message,
sizeof(message));
return TRUE;
}
else if(SendMessage(GetDlgItem(m_hWndSub[eMenu_Mob], IDC_GMREGEN_SCRIPT_RADIO), BM_GETCHECK, 0, 0) == BST_CHECKED)
{
TCHAR textObject[MAX_PATH] = {0};
GetDlgItemText(
m_hWndSub[eMenu_Mob],
IDC_SCRIPT_OBJECT_EDIT,
textObject,
_countof(textObject));
TCHAR textFileName[MAX_PATH] = {0};
GetDlgItemText(
m_hWndSub[eMenu_Mob],
IDC_SCRIPT_FILE_EDIT,
textFileName,
_countof(textFileName));
LPCTSTR textSeperator = " ";
LPCTSTR textObjectIndex = _tcstok(
textObject,
textSeperator);
MSG_GUILDNOTICE message;
ZeroMemory(
&message,
sizeof(message));
message.Category = MP_CHEAT;
message.Protocol = MP_CHEAT_MONSTER_SCRIPT_SYN;
message.dwObjectID = gHeroID;
message.dwGuildId = _ttoi(
textObjectIndex ? textObjectIndex : "");
SafeStrCpy(
message.Msg,
textFileName,
_countof(message.Msg));
NETWORK->Send(
&message,
sizeof(message));
}
return FALSE;
}
#define MAX_PREFACE_LENGTH 30
BOOL CGMToolManager::OnNoticeCommand()
{
if( !m_hWndSub[eMenu_Notice] ) return FALSE;
SetFocus( _g_hWnd );
char buf[MAX_CHAT_LENGTH+1] = {0,};
char bufMap[MAX_NAME_LENGTH+1] = {0,};
int nLen = GetWindowText( GetDlgItem( m_hWndSub[eMenu_Notice], IDC_GMNOTICE_EDT_PREFACE ), buf, MAX_PREFACE_LENGTH+1 );
int nLen2 = GetWindowText( GetDlgItem( m_hWndSub[eMenu_Notice], IDC_GMNOTICE_EDT_NOTICE ), buf+nLen, MAX_CHAT_LENGTH-MAX_PREFACE_LENGTH );
if( nLen2 == 0 ) return FALSE;
// if( strlen( buf ) == 0 ) return FALSE;
MSG_CHAT_WORD msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_NOTICE_SYN;
msg.dwObjectID = gHeroID;
SafeStrCpy( msg.Msg, buf, MAX_CHAT_LENGTH+1 );
if( SendMessage( GetDlgItem( m_hWndSub[eMenu_Notice], IDC_GMNOTICE_BTN_ALLMAP ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
msg.wData = 0;
}
else
{
GetDlgItemText( m_hWndSub[eMenu_Notice], IDC_GMNOTICE_CMB_MAP, bufMap, MAX_NAME_LENGTH+1 );
msg.wData = GetMapNumForName(bufMap);
}
NETWORK->Send( &msg, msg.GetMsgLength() );
SetWindowText( GetDlgItem( m_hWndSub[eMenu_Notice], IDC_GMNOTICE_EDT_NOTICE ), "" );
SetFocus( GetDlgItem( m_hWndSub[eMenu_Notice], IDC_GMNOTICE_EDT_NOTICE ) );
return TRUE;
}
BOOL CGMToolManager::OnEventCommand()
{
if( !m_hWndSub[eMenu_Notice] ) return FALSE;
SetFocus( _g_hWnd );
//정보 읽어 오기
int nEvent = SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_GETCURSEL, 0, 0 )+1;
BOOL rt;
int nRatio = GetDlgItemInt( m_hWndSub[eMenu_Event], IDC_GMEVENT_EDT_RATE, &rt, TRUE );
// 071210 LYW --- GMToolManager : 이벤트 경험치만 기능을 살린다.
// 경험치 최고 30배로 제한을 둔다.
if( nRatio > 3000 )
{
MessageBox( NULL, CHATMGR->GetChatMsg(1476), "GM-Tool", MB_OK) ;
return FALSE ;
}
MSG_WORD2 msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_EVENT_SYN;
msg.dwObjectID = gHeroID;
msg.wData1 = WORD(nEvent);
msg.wData2 = WORD(nRatio);
NETWORK->Send( &msg, sizeof(msg) );
CHATMGR->AddMsg( CTC_TOGM, "Event Applied!" );
return TRUE;
}
BOOL CGMToolManager::OnEventNotifyCommand( BOOL bOn )
{
if( !m_hWndSub[eMenu_EventNotify] ) return FALSE;
SetFocus( _g_hWnd );
if( bOn )
{
//정보 읽어 오기
char bufTitle[32] = {0,};
char bufContext[128] = {0,};
int nLen = 0;
nLen = GetWindowText( GetDlgItem( m_hWndSub[eMenu_EventNotify], IDC_GMEVENTNOTIFY_EDT_TITLE ), bufTitle, 32 );
if( nLen <=0 )
{
CHATMGR->AddMsg( CTC_TOGM, "Input Notify Title!" );
return FALSE;
}
nLen = GetWindowText( GetDlgItem( m_hWndSub[eMenu_EventNotify], IDC_GMEVENTNOTIFY_EDT_CONTEXT ), bufContext, 128 );
if( nLen <=0 )
{
CHATMGR->AddMsg( CTC_TOGM, "Input Notify Context!" );
return FALSE;
}
if( !m_hWndSub[eMenu_Notice] ) return FALSE;
SetFocus( _g_hWnd );
//정보 읽어 오기
int nEvent = SendDlgItemMessage( m_hWndSub[eMenu_Event], IDC_GMEVENT_CMB_EVENT, CB_GETCURSEL, 0, 0 )+1;
bufTitle[31] = 0;
bufContext[127] = 0;
MSG_EVENTNOTIFY_ON msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_EVENTNOTIFY_ON;
msg.dwObjectID = gHeroID;
memset( msg.EventList, 0, sizeof(BYTE)*eEvent_Max );
msg.EventList[nEvent] = 1;
SafeStrCpy( msg.strTitle, bufTitle, 32 );
SafeStrCpy( msg.strContext, bufContext, 128 );
NETWORK->Send( &msg, sizeof(msg) );
}
else
{
MSGBASE msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_EVENTNOTIFY_OFF;
msg.dwObjectID = gHeroID;
NETWORK->Send( &msg, sizeof(msg) );
}
return TRUE;
}
//---KES GM툴 로그아웃 처리 추가
void CGMToolManager::LogOut()
{
m_bLogin = FALSE;
m_nPower = eGM_POWER_MAX;
}
//-------------------------
void CGMToolManager::Login( BOOL bLogin, int nGMPower )
{
static char power_str[eGM_POWER_MAX][16] = { "Master", "Monitor", "Patroller", "Auditor", "Eventer", "QA" };
char buf[128];
if( bLogin )
{
wsprintf( buf, "< GM Power : %s >", power_str[nGMPower] );
MessageBox( m_hWndLoginDlg, buf, "Login OK!", MB_OK );
m_bLogin = TRUE;
m_nPower = nGMPower;
ShowWindow( m_hWndLoginDlg, SW_HIDE );
}
else
{
if( nGMPower == 1) //nGMPower = error code : if bLogin == FALSE
{
MessageBox( m_hWndLoginDlg, "Invalid ID/PW", "Login Failed!", MB_OK );
}
else
{
MessageBox( m_hWndLoginDlg, "Error!", "Login Failed!", MB_OK );
}
}
}
void SetChannelFromMap(HWND hWnd, int nMapCBoxID, int nChannelCBoxID)
{
const MAPTYPE mapType = GetMapNumForName(
GetMapName(MAP->GetMapNum()));
if(_countof(g_MapChannelNum) < mapType)
{
return;
}
SendDlgItemMessage(
hWnd,
nChannelCBoxID,
CB_RESETCONTENT,
0,
0);
switch(nMapCBoxID)
{
case IDC_GMREGEN_CMB_MAP:
SendDlgItemMessage( hWnd, nChannelCBoxID, CB_ADDSTRING, 0, (LPARAM)"all" );
break;
}
for(WORD channel = 1 ; channel <= g_MapChannelNum[mapType] ; ++channel)
{
TCHAR text[MAX_PATH] = {0};
_stprintf(
text,
"%u",
channel);
SendDlgItemMessage( hWnd, nChannelCBoxID, CB_ADDSTRING, 0, (LPARAM)text );
}
switch(nMapCBoxID)
{
case IDC_GMREGEN_CMB_MAP:
SendDlgItemMessage( hWnd, nChannelCBoxID, CB_SETCURSEL, gChannelNum-1, 0 );
break;
default:
SendDlgItemMessage( hWnd, nChannelCBoxID, CB_SETCURSEL, gChannelNum, 0 );
break;
}
}
INT_PTR CALLBACK GMLoginDlgProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch(message)
{
case WM_INITDIALOG:
{
RECT rcGame;
RECT rcDlg;
POINT pt;
GetClientRect( hWnd, &rcDlg );
GetClientRect( _g_hWnd, &rcGame );
pt.x = rcGame.left;
pt.y = rcGame.top;
ClientToScreen( _g_hWnd, &pt );
const DISPLAY_INFO& dispInfo = GAMERESRCMNGR->GetResolution();
int x = ( ( dispInfo.dwWidth - ( rcDlg.right - rcDlg.left ) ) / 2 ) + pt.x;
int y = ( ( dispInfo.dwHeight - ( rcDlg.bottom - rcDlg.top ) ) / 2 ) + pt.y;
// 070202 LYW --- End.
SetWindowPos( hWnd, NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER );
SendMessage( GetDlgItem( hWnd, IDC_GMLOGIN_EDT_ID ), EM_LIMITTEXT, MAX_NAME_LENGTH+1, 0 );
SendMessage( GetDlgItem( hWnd, IDC_GMLOGIN_EDT_PW ), EM_LIMITTEXT, MAX_NAME_LENGTH+1, 0 );
}
return TRUE;
case WM_COMMAND:
{
if( HIWORD( wParam ) == BN_CLICKED )
{
if( LOWORD( wParam ) == IDC_GMLOGIN_BTN_CONNECT )
{
char strID[MAX_NAME_LENGTH+1];
char strPW[MAX_NAME_LENGTH+1];
GetWindowText( GetDlgItem(hWnd, IDC_GMLOGIN_EDT_ID), strID, MAX_NAME_LENGTH+1 );
GetWindowText( GetDlgItem(hWnd, IDC_GMLOGIN_EDT_PW), strPW, MAX_NAME_LENGTH+1 );
if( strID[0] == 0 || strPW[0] == 0 )
{
MessageBox( hWnd, "Input ID/PW", "Error", MB_OK );
return TRUE;
}
MSG_NAME2 msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_GM_LOGIN_SYN;
msg.dwObjectID = gHeroID;
SafeStrCpy( msg.str1, strID, MAX_NAME_LENGTH+1 );
SafeStrCpy( msg.str2, strPW, MAX_NAME_LENGTH+1 );
NETWORK->Send( &msg, sizeof(msg) );
SetWindowText( GetDlgItem(hWnd, IDC_GMLOGIN_EDT_ID), "" );
SetWindowText( GetDlgItem(hWnd, IDC_GMLOGIN_EDT_PW), "" );
}
else if( LOWORD( wParam ) == IDC_GMLOGIN_BTN_CANCEL )
{
ShowWindow( hWnd, SW_HIDE );
SetWindowText( GetDlgItem(hWnd, IDC_GMLOGIN_EDT_ID), "" );
SetWindowText( GetDlgItem(hWnd, IDC_GMLOGIN_EDT_PW), "" );
}
}
}
return TRUE;
}
return FALSE;
}
INT_PTR CALLBACK GMDlgProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch(message)
{
case WM_INITDIALOG:
{
CheckDlgButton( hWnd, IDC_GM_MNBTN_NONE, BST_CHECKED );
//#ifdef TAIWAN_LOCAL //중국은 이벤트 활성화 안됨
// EnableWindow( GetDlgItem( hWnd, IDC_GM_MNBTN_EVENT ), FALSE );
//#endif
}
return FALSE; //not active
case WM_NCHITTEST:
case WM_RBUTTONDOWN:
case WM_LBUTTONDOWN:
{
SetFocus( _g_hWnd );
}
break;
case WM_COMMAND:
{
if( HIWORD( wParam ) == BN_CLICKED )
{
GMTOOLMGR->OnClickMenu( LOWORD( wParam ) - IDC_GM_MNBTN_MOVE );
}
}
return TRUE;
case WM_MOVE:
{
GMTOOLMGR->SetPositionSubDlg();
}
break;
case WM_CLOSE:
{
GMTOOLMGR->ShowGMDialog( FALSE, TRUE );
}
return TRUE;
}
return FALSE;
}
INT_PTR CALLBACK GMSubMoveDlgProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_INITDIALOG:
{
CheckRadioButton( hWnd, IDC_GMMOVE_BTN_ME, IDC_GMMOVE_BTN_USER, IDC_GMMOVE_BTN_ME );
CheckRadioButton( hWnd, IDC_GMMOVE_BTN_XY, IDC_GMMOVE_BTN_NPC, IDC_GMMOVE_BTN_XY );
CheckDlgButton( hWnd, IDC_GMMOVE_CHK_MINIMAP_ON, TRUE);
SetChannelFromMap(hWnd, IDC_GMMOVE_CMB_MAP, IDC_GMMOVE_CMB_CHANNEL);
}
return FALSE; //not active
case WM_COMMAND:
{
if( HIWORD( wParam ) == BN_CLICKED )
{
switch( LOWORD( wParam ) )
{
case IDC_GMMOVE_OK: //Do Move
{
if( SendMessage( GetDlgItem( hWnd, IDC_GMMOVE_BTN_XY ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
if( SendMessage( GetDlgItem( hWnd, IDC_GMMOVE_BTN_ME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
GMTOOLMGR->OnGMMoveCommand( 0 );
else
GMTOOLMGR->OnUserMoveCommand( 0 );
}
else if( SendMessage( GetDlgItem( hWnd, IDC_GMMOVE_BTN_NAME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
if( SendMessage( GetDlgItem( hWnd, IDC_GMMOVE_BTN_ME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
GMTOOLMGR->OnGMMoveCommand( 1 );
else
GMTOOLMGR->OnUserMoveCommand( 1 );
}
else if( SendMessage( GetDlgItem( hWnd, IDC_GMMOVE_BTN_MAP ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
if( SendMessage( GetDlgItem( hWnd, IDC_GMMOVE_BTN_ME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
GMTOOLMGR->OnGMMoveCommand( 2 );
else
GMTOOLMGR->OnUserMoveCommand( 2 );
}
// 100427 ONS NPC로의 이동처리 추가
else if( SendMessage( GetDlgItem( hWnd, IDC_GMMOVE_BTN_NPC ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
if( SendMessage( GetDlgItem( hWnd, IDC_GMMOVE_BTN_ME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
GMTOOLMGR->OnGMMoveCommand( 3 );
else
GMTOOLMGR->OnUserMoveCommand( 3 );
}
}
break;
case IDC_GMMOVE_CANCEL:
{
GMTOOLMGR->OnClickMenu( eMenu_Count );
SetFocus( _g_hWnd );
}
break;
case IDC_GMMOVE_BTN_ME:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_USER ), FALSE );
if( SendMessage( GetDlgItem( hWnd, IDC_GMMOVE_BTN_NAME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_NAME ), TRUE );
}
SetWindowText( GetDlgItem( hWnd, IDC_GMMOVE_BTN_NAME ), "Character" );
}
break;
case IDC_GMMOVE_BTN_USER:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_USER ), TRUE );
CObject* pObject = OBJECTMGR->GetSelectedObject();
if( pObject )
if( pObject->GetObjectKind() == eObjectKind_Player )
{
SetDlgItemText( hWnd, IDC_GMMOVE_EDT_USER, pObject->GetObjectName() );
}
SetFocus( GetDlgItem( hWnd, IDC_GMMOVE_EDT_USER ) );
//IDC_GMMOVE_BTN_NAME이 체크되어 있고
//IDC_GMMOVE_EDT_NAME가 enable이면 disable로
if( SendMessage( GetDlgItem( hWnd, IDC_GMMOVE_BTN_NAME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_NAME ), FALSE );
}
SetWindowText( GetDlgItem( hWnd, IDC_GMMOVE_BTN_NAME ), "To GM" );
//character글씨를 To GM 으로?
}
break;
case IDC_GMMOVE_BTN_XY:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_X ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_Y ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_NAME ), FALSE );
//EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_MAP ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CMB_MAP ), FALSE );
//EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_CHANNEL ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CMB_CHANNEL ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CMB_NPC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CHK_MINIMAP_ON ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CHK_MINIMAP_OFF ), FALSE );
SetFocus( GetDlgItem( hWnd, IDC_GMMOVE_EDT_X ) );
}
break;
case IDC_GMMOVE_BTN_NAME:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_X ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_Y ), FALSE );
//EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_NAME ), TRUE );
//EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_MAP ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CMB_MAP ), FALSE );
//EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_CHANNEL ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CMB_CHANNEL ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CMB_NPC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CHK_MINIMAP_ON ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CHK_MINIMAP_OFF ), FALSE );
if( SendMessage( GetDlgItem( hWnd, IDC_GMMOVE_BTN_ME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_NAME ), TRUE );
CObject* pObject = OBJECTMGR->GetSelectedObject();
if( pObject )
if( pObject->GetObjectKind() == eObjectKind_Player )
{
SetDlgItemText( hWnd, IDC_GMMOVE_EDT_NAME, pObject->GetObjectName() );
}
SetFocus( GetDlgItem( hWnd, IDC_GMMOVE_EDT_NAME ) );
}
}
break;
case IDC_GMMOVE_BTN_MAP:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_X ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_Y ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_NAME ), FALSE );
//EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_MAP ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CMB_MAP ), TRUE );
//EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_CHANNEL ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CMB_CHANNEL ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CMB_NPC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CHK_MINIMAP_ON ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CHK_MINIMAP_OFF ), FALSE );
//SetFocus( GetDlgItem( hWnd, IDC_GMMOVE_EDT_MAP ) );
SetFocus( GetDlgItem( hWnd, IDC_GMMOVE_CMB_MAP ) );
SetChannelFromMap(hWnd, IDC_GMMOVE_CMB_MAP, IDC_GMMOVE_CMB_CHANNEL);
}
break;
// 100427 ONS 맵이동 NPC목록 추가
case IDC_GMMOVE_BTN_NPC:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_X ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_Y ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_NAME ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CMB_MAP ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CMB_CHANNEL ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CMB_NPC ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CHK_MINIMAP_ON ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CHK_MINIMAP_OFF ), FALSE );
GMTOOLMGR->SetNpcList();
SetFocus( GetDlgItem( hWnd, IDC_GMMOVE_CMB_NPC ) );
}
break;
case IDC_GMMOVE_BTN_MINIMAP:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_X ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_Y ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_EDT_NAME ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CMB_MAP ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CMB_CHANNEL ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CMB_NPC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CHK_MINIMAP_ON ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMMOVE_CHK_MINIMAP_OFF ), TRUE );
if( SendMessage( GetDlgItem( hWnd, IDC_GMMOVE_CHK_MINIMAP_ON ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
GMTOOLMGR->ActiveMiniMap( TRUE );
}
}
break;
case IDC_GMMOVE_CHK_MINIMAP_ON:
case IDC_GMMOVE_CHK_MINIMAP_OFF:
{
GMTOOLMGR->ActiveMiniMap( (LOWORD( wParam ) == IDC_GMMOVE_CHK_MINIMAP_ON) ? TRUE : FALSE );
}
break;
}
}
else if( HIWORD( wParam ) == CBN_SELENDOK )
{
switch( LOWORD( wParam ) )
{
case IDC_GMMOVE_CMB_MAP:
{
SetChannelFromMap(hWnd, IDC_GMMOVE_CMB_MAP, IDC_GMMOVE_CMB_CHANNEL);
}
break;
}
}
}
return TRUE;
case WM_SETFOCUS:
{
#ifdef TAIWAN_LOCAL
HIMC hIMC = ImmGetContext( _g_hWnd );
ImmSetOpenStatus( hIMC, TRUE );
ImmReleaseContext( _g_hWnd, hIMC );
HWND hWndIme = ImmGetDefaultIMEWnd( _g_hWnd );
SendMessage( hWndIme, WM_IME_CONTROL, IMC_OPENSTATUSWINDOW, 0 );
#endif
}
break;
case WM_KILLFOCUS:
{
#ifdef TAIWAN_LOCAL
HIMC hIMC = ImmGetContext( _g_hWnd );
ImmSetOpenStatus( hIMC, FALSE );
ImmNotifyIME( hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0 );
ImmNotifyIME( hIMC, NI_CLOSECANDIDATE, 0, 0 );
ImmReleaseContext( _g_hWnd, hIMC );
HWND hWndIme = ImmGetDefaultIMEWnd( _g_hWnd );
SendMessage( hWndIme, WM_IME_CONTROL, IMC_CLOSESTATUSWINDOW, 0 );
#endif
}
break;
}
return FALSE;
}
INT_PTR CALLBACK GMSubForbidChatDlgProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_COMMAND:
{
if( HIWORD( wParam ) == BN_CLICKED )
{
switch( LOWORD( wParam ) )
{
case IDC_GMCHAT_BTN_FORBID:
{
GMTOOLMGR->OnForbidChatCommand(1);
}
break;
case IDC_GMCHAT_BTN_PERMIT:
{
GMTOOLMGR->OnForbidChatCommand(0);
}
break;
case IDC_GMBLOCK_BTN_CANCEL:
{
GMTOOLMGR->OnClickMenu( eMenu_Count );
SetFocus( _g_hWnd );
}
break;
case IDC_GMBLOCK_BTN_USER:
{
SetFocus( GetDlgItem( hWnd, IDC_GMBLOCK_EDT_CHAR ) );
CObject* pObject = OBJECTMGR->GetSelectedObject();
if( pObject )
if( pObject->GetObjectKind() == eObjectKind_Player )
{
SetDlgItemText( hWnd, IDC_GMBLOCK_EDT_CHAR, pObject->GetObjectName() );
}
}
break;
}
}
}
return TRUE;
case WM_SETFOCUS:
{
#ifdef TAIWAN_LOCAL
HIMC hIMC = ImmGetContext( _g_hWnd );
ImmSetOpenStatus( hIMC, TRUE );
ImmReleaseContext( _g_hWnd, hIMC );
HWND hWndIme = ImmGetDefaultIMEWnd( _g_hWnd );
SendMessage( hWndIme, WM_IME_CONTROL, IMC_OPENSTATUSWINDOW, 0 );
#endif
}
break;
case WM_KILLFOCUS:
{
#ifdef TAIWAN_LOCAL
HIMC hIMC = ImmGetContext( _g_hWnd );
ImmSetOpenStatus( hIMC, FALSE );
ImmNotifyIME( hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0 );
ImmNotifyIME( hIMC, NI_CLOSECANDIDATE, 0, 0 );
ImmReleaseContext( _g_hWnd, hIMC );
HWND hWndIme = ImmGetDefaultIMEWnd( _g_hWnd );
SendMessage( hWndIme, WM_IME_CONTROL, IMC_CLOSESTATUSWINDOW, 0 );
#endif
}
break;
}
return FALSE;
}
INT_PTR CALLBACK GMSubHideDlgProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_INITDIALOG:
{
CheckRadioButton( hWnd, IDC_GMHIDE_BTN_ME, IDC_GMHIDE_BTN_NPC, IDC_GMHIDE_BTN_ME );
CheckRadioButton( hWnd, IDC_GMHIDE_BTN_HIDE, IDC_GMHIDE_BTN_SHOW, IDC_GMHIDE_BTN_HIDE );
//SetChannelFromMap(hWnd, IDC_GMHIDE_CMB_MA, IDC_GMHIDE_CMB_CHANNEL);
}
return FALSE;
case WM_COMMAND:
{
if( HIWORD( wParam ) == BN_CLICKED )
{
switch( LOWORD( wParam ) )
{
case IDC_GMHIDE_BTN_APPLY:
{
GMTOOLMGR->OnHideCommand();
}
break;
case IDC_GMHIDE_BTN_CANCEL:
{
GMTOOLMGR->OnClickMenu( eMenu_Count );
SetFocus( _g_hWnd );
}
break;
case IDC_GMHIDE_BTN_ME:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMHIDE_EDT_USER ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMHIDE_CMB_CHANNEL ), FALSE );
CheckDlgButton( hWnd, IDC_GMHIDE_BTN_NPC, FALSE );
}
break;
case IDC_GMHIDE_BTN_USER:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMHIDE_EDT_USER ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMHIDE_CMB_CHANNEL ), FALSE );
SetFocus( GetDlgItem( hWnd, IDC_GMHIDE_EDT_USER ) );
CObject* pObject = OBJECTMGR->GetSelectedObject();
if( pObject )
if( pObject->GetObjectKind() == eObjectKind_Player )
{
SetDlgItemText( hWnd, IDC_GMHIDE_EDT_USER, pObject->GetObjectName() );
}
CheckDlgButton( hWnd, IDC_GMHIDE_BTN_NPC, FALSE );
}
break;
case IDC_GMHIDE_BTN_NPC:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMHIDE_EDT_USER ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMHIDE_CMB_CHANNEL ), TRUE );
CheckDlgButton( hWnd, IDC_GMHIDE_BTN_ME, FALSE );
CheckDlgButton( hWnd, IDC_GMHIDE_BTN_USER, FALSE );
}
break;
}
}
}
return TRUE;
case WM_SETFOCUS:
{
#ifdef TAIWAN_LOCAL
HIMC hIMC = ImmGetContext( _g_hWnd );
ImmSetOpenStatus( hIMC, TRUE );
ImmReleaseContext( _g_hWnd, hIMC );
HWND hWndIme = ImmGetDefaultIMEWnd( _g_hWnd );
SendMessage( hWndIme, WM_IME_CONTROL, IMC_OPENSTATUSWINDOW, 0 );
#endif
}
break;
case WM_KILLFOCUS:
{
#ifdef TAIWAN_LOCAL
HIMC hIMC = ImmGetContext( _g_hWnd );
ImmSetOpenStatus( hIMC, FALSE );
ImmNotifyIME( hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0 );
ImmNotifyIME( hIMC, NI_CLOSECANDIDATE, 0, 0 );
ImmReleaseContext( _g_hWnd, hIMC );
HWND hWndIme = ImmGetDefaultIMEWnd( _g_hWnd );
SendMessage( hWndIme, WM_IME_CONTROL, IMC_CLOSESTATUSWINDOW, 0 );
#endif
}
break;
}
return FALSE;
}
INT_PTR CALLBACK GMSubWhereDlgProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_INITDIALOG:
{
CheckDlgButton( hWnd, IDC_GMWHERE_BTN_USER, BST_CHECKED );
CheckDlgButton( hWnd, IDC_GMWHERE_BTN_MAP, BST_CHECKED );
CheckDlgButton( hWnd, IDC_GMWHERE_BTN_XY, BST_CHECKED );
}
return FALSE;
case WM_COMMAND:
{
if( HIWORD( wParam ) == BN_CLICKED )
{
switch( LOWORD( wParam ) )
{
case IDC_GMWHERE_BTN_WHERE:
{
GMTOOLMGR->OnWhereCommand();
}
break;
case IDC_GMWHERE_BTN_CANCEL:
{
GMTOOLMGR->OnClickMenu( eMenu_Count );
SetFocus( _g_hWnd );
}
break;
case IDC_GMWHERE_BTN_MAP:
{
}
break;
case IDC_GMWHERE_BTN_XY:
{
}
break;
}
}
}
return TRUE;
case WM_SETFOCUS:
{
#ifdef TAIWAN_LOCAL
HIMC hIMC = ImmGetContext( _g_hWnd );
ImmSetOpenStatus( hIMC, TRUE );
ImmReleaseContext( _g_hWnd, hIMC );
HWND hWndIme = ImmGetDefaultIMEWnd( _g_hWnd );
SendMessage( hWndIme, WM_IME_CONTROL, IMC_OPENSTATUSWINDOW, 0 );
#endif
}
break;
case WM_KILLFOCUS:
{
#ifdef TAIWAN_LOCAL
HIMC hIMC = ImmGetContext( _g_hWnd );
ImmSetOpenStatus( hIMC, FALSE );
ImmNotifyIME( hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0 );
ImmNotifyIME( hIMC, NI_CLOSECANDIDATE, 0, 0 );
ImmReleaseContext( _g_hWnd, hIMC );
HWND hWndIme = ImmGetDefaultIMEWnd( _g_hWnd );
SendMessage( hWndIme, WM_IME_CONTROL, IMC_CLOSESTATUSWINDOW, 0 );
#endif
}
break;
}
return FALSE;
}
INT_PTR CALLBACK GMSubItemDlgProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_INITDIALOG:
{
CheckRadioButton( hWnd, IDC_GMITEM_BTN_WEAPON, IDC_GMITEM_BTN_ABILITY, IDC_GMITEM_BTN_WEAPON );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_BTN_SEARCH ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDIT_SEARCH), TRUE );
SetWindowText( GetDlgItem( hWnd, IDC_GMITEM_SEARCHFROM), "from Weapon List");
}
return FALSE;
case WM_COMMAND:
{
if( HIWORD( wParam ) == BN_CLICKED )
{
switch( LOWORD( wParam ) )
{
case IDC_GMITEM_BTN_SEARCH:
{
int nCurSelDlgID = -1;
int nCurSelCBID = -1;
if( SendMessage( GetDlgItem( hWnd, IDC_GMITEM_BTN_WEAPON ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
nCurSelDlgID = IDC_GMITEM_BTN_WEAPON;
nCurSelCBID = IDC_GMITEM_CMB_WEAPON;
}
else if( SendMessage( GetDlgItem( hWnd, IDC_GMITEM_BTN_CLOTHES ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
nCurSelDlgID = IDC_GMITEM_BTN_CLOTHES;
nCurSelCBID = IDC_GMITEM_CMB_CLOTHES;
}
else if( SendMessage( GetDlgItem( hWnd, IDC_GMITEM_BTN_ACCESSORY ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
nCurSelDlgID = IDC_GMITEM_BTN_ACCESSORY;
nCurSelCBID = IDC_GMITEM_CMB_ACCESSORY;
}
else if( SendMessage( GetDlgItem( hWnd, IDC_GMITEM_BTN_SKILLBOOK ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
nCurSelDlgID = IDC_GMITEM_BTN_SKILLBOOK;
nCurSelCBID = IDC_GMITEM_CMB_SKILLBOOK;
}
else if( SendMessage( GetDlgItem( hWnd, IDC_GMITEM_BTN_POTION ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
nCurSelDlgID = IDC_GMITEM_BTN_POTION;
nCurSelCBID = IDC_GMITEM_CMB_POTION;
}
else if( SendMessage( GetDlgItem( hWnd, IDC_GMITEM_BTN_ETC ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
nCurSelDlgID = IDC_GMITEM_BTN_ETC;
nCurSelCBID = IDC_GMITEM_CMB_ETC;
}
// 090909 ONS 스킬 검색처리 추가
else if( SendMessage( GetDlgItem( hWnd, IDC_GMITEM_BTN_SKILL ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
nCurSelDlgID = IDC_GMITEM_BTN_SKILL;
nCurSelCBID = IDC_GMITEM_CMB_SKILL;
}
if(-1<nCurSelDlgID && -1<nCurSelCBID)
{
HWND hWndCB = GetDlgItem(hWnd, IDC_GMITEM_EDIT_SEARCH);
int nSel = SendDlgItemMessage( hWnd, nCurSelCBID, CB_GETCURSEL, 0, 0 );
int nCount = SendDlgItemMessage( hWnd, nCurSelCBID, CB_GETCOUNT, 0, 0 );
char szSearch[256] = {0,};
GetWindowText(hWndCB, szSearch, 255);
if(2 <= strlen(szSearch))
{
int i, nFind=-1;
for(i=nSel+1; i<nCount; i++)
{
char szName[256] = {0,};
SendDlgItemMessage( hWnd, nCurSelCBID, CB_GETLBTEXT, i, (LPARAM)szName );
if(strstr(szName, szSearch) != NULL)
{
SendDlgItemMessage( hWnd, nCurSelCBID, CB_SETCURSEL, nFind, 0 );
nFind = i;
break;
}
}
if(-1 < nFind)
{
SendDlgItemMessage( hWnd, nCurSelCBID, CB_SETCURSEL, nFind, 0 );
// 090909 ONS 검색된 스킬의 레벨범위를 표시한다.
if(nCurSelDlgID == IDC_GMITEM_BTN_SKILL && nCurSelCBID == IDC_GMITEM_CMB_SKILL)
{
cSkillInfo* pSkillInfo = NULL ;
const SkillData* pSkillList = GetSkillTreeList();
pSkillInfo = SKILLMGR->GetSkillInfo( pSkillList[nSel].index );
if(pSkillInfo)
{
for(int j=0; j<30; j++)
{
SendDlgItemMessage( hWnd, IDC_GMITEM_CMB_SKILLSUNG, CB_DELETESTRING, 0, 0 );
}
for(int i=0; i<pSkillList[nFind].level; i++)
{
char bufNum[20];
wsprintf( bufNum, "%d", i+1 );
SendDlgItemMessage( hWnd, IDC_GMITEM_CMB_SKILLSUNG, CB_ADDSTRING, 0, (LPARAM)bufNum );
}
SendDlgItemMessage( hWnd, IDC_GMITEM_CMB_SKILLSUNG, CB_SETCURSEL, 0, 0 );
}
}
}
}
}
}
break;
case IDC_GMITEM_BTN_GET:
{
GMTOOLMGR->OnItemCommand();
}
break;
case IDC_GMITEM_BTN_CANCEL:
{
GMTOOLMGR->OnClickMenu( eMenu_Count );
SetFocus( _g_hWnd );
}
break;
case IDC_GMITEM_BTN_WEAPON:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_WEAPON ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_WEAPONGRADE ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_CLOTHES ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_CLOTHESGRADE ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_ACCESSORY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILLBOOK ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_SPN_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_SPN_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_MONEY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILL ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILLSUNG ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_ABILITY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_BTN_SEARCH ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDIT_SEARCH), TRUE );
SetWindowText( GetDlgItem( hWnd, IDC_GMITEM_SEARCHFROM), "from Weapon List");
}
break;
case IDC_GMITEM_BTN_CLOTHES:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_WEAPON ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_WEAPONGRADE ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_CLOTHES ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_CLOTHESGRADE ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_ACCESSORY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILLBOOK ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_SPN_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_SPN_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_MONEY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILL ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILLSUNG ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_ABILITY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_BTN_SEARCH ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDIT_SEARCH), TRUE );
SetWindowText( GetDlgItem( hWnd, IDC_GMITEM_SEARCHFROM), "from Clothes List");
}
break;
case IDC_GMITEM_BTN_ACCESSORY:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_WEAPON ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_WEAPONGRADE ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_CLOTHES ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_CLOTHESGRADE ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_ACCESSORY ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILLBOOK ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_SPN_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_SPN_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_MONEY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILL ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILLSUNG ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_ABILITY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_BTN_SEARCH ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDIT_SEARCH), TRUE );
SetWindowText( GetDlgItem( hWnd, IDC_GMITEM_SEARCHFROM), "from Accessory List");
}
break;
case IDC_GMITEM_BTN_SKILLBOOK:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_WEAPON ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_WEAPONGRADE ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_CLOTHES ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_CLOTHESGRADE ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_ACCESSORY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILLBOOK ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_SPN_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_SPN_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_MONEY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILL ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILLSUNG ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_ABILITY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_BTN_SEARCH ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDIT_SEARCH), TRUE );
SetWindowText( GetDlgItem( hWnd, IDC_GMITEM_SEARCHFROM), "from SkillBook List");
}
break;
case IDC_GMITEM_BTN_POTION:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_WEAPON ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_WEAPONGRADE ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_CLOTHES ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_CLOTHESGRADE ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_ACCESSORY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILLBOOK ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_POTION ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_POTION ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_SPN_POTION ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_SPN_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_MONEY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILL ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILLSUNG ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_ABILITY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_BTN_SEARCH ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDIT_SEARCH), TRUE );
SetWindowText( GetDlgItem( hWnd, IDC_GMITEM_SEARCHFROM), "from Potion List");
}
break;
case IDC_GMITEM_BTN_ETC:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_WEAPON ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_WEAPONGRADE ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_CLOTHES ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_CLOTHESGRADE ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_ACCESSORY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILLBOOK ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_SPN_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_ETC ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_ETC ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_SPN_ETC ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_MONEY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILL ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILLSUNG ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_ABILITY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_BTN_SEARCH ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDIT_SEARCH), TRUE );
SetWindowText( GetDlgItem( hWnd, IDC_GMITEM_SEARCHFROM), "from Etc List");
}
break;
case IDC_GMITEM_BTN_MONEY:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_WEAPON ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_WEAPONGRADE ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_CLOTHES ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_CLOTHESGRADE ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_ACCESSORY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILLBOOK ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_SPN_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_SPN_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_MONEY ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILL ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILLSUNG ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_ABILITY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_BTN_SEARCH ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDIT_SEARCH), FALSE );
SetWindowText( GetDlgItem( hWnd, IDC_GMITEM_SEARCHFROM), "from List");
}
break;
case IDC_GMITEM_BTN_SKILL:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_WEAPON ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_WEAPONGRADE ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_CLOTHES ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_CLOTHESGRADE ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_ACCESSORY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILLBOOK ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_SPN_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_SPN_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_MONEY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILL ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILLSUNG ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_ABILITY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_BTN_SEARCH ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDIT_SEARCH), TRUE );
SetWindowText( GetDlgItem( hWnd, IDC_GMITEM_SEARCHFROM), "from Skill List");
}
break;
case IDC_GMITEM_BTN_ABILITY:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_WEAPON ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_WEAPONGRADE ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_CLOTHES ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_CLOTHESGRADE ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_ACCESSORY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILLBOOK ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_SPN_POTION ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_SPN_ETC ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_MONEY ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILL ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_CMB_SKILLSUNG ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDT_ABILITY ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_BTN_SEARCH ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMITEM_EDIT_SEARCH), FALSE );
}
break;
}
}
else if( HIWORD( wParam ) == CBN_SELCHANGE )
{
if( LOWORD( wParam ) == IDC_GMITEM_CMB_SKILL )
{
char buf[64];
//GetDlgItemText( hWnd, IDC_GMITEM_CMB_SKILL, buf, MAX_ITEMNAME_LENGTH+1 );
int nSel = SendDlgItemMessage( hWnd, IDC_GMITEM_CMB_SKILL, CB_GETCURSEL, 0, 0 );
SendDlgItemMessage( hWnd, IDC_GMITEM_CMB_SKILL, CB_GETLBTEXT, nSel, (LPARAM)buf );
// 090904 ONS 선택된 스킬의 최대레벨을 표시한다.
// 레벨리스트 초기화
for(int j=0; j<30; j++)
{
SendDlgItemMessage( hWnd, IDC_GMITEM_CMB_SKILLSUNG, CB_DELETESTRING, 0, 0 );
}
cSkillInfo* pSkillInfo = NULL ;
const SkillData* pSkillList = GetSkillTreeList();
pSkillInfo = SKILLMGR->GetSkillInfo( pSkillList[nSel].index );
if(pSkillInfo)
{
for(int i=0; i<pSkillList[nSel].level; i++)
{
char bufNum[20];
wsprintf( bufNum, "%d", i+1 );
SendDlgItemMessage( hWnd, IDC_GMITEM_CMB_SKILLSUNG, CB_ADDSTRING, 0, (LPARAM)bufNum );
}
SendDlgItemMessage( hWnd, IDC_GMITEM_CMB_SKILLSUNG, CB_SETCURSEL, 0, 0 );
}
}
}
}
return TRUE;
case WM_SETFOCUS:
{
#ifdef TAIWAN_LOCAL
HIMC hIMC = ImmGetContext( _g_hWnd );
ImmSetOpenStatus( hIMC, TRUE );
ImmReleaseContext( _g_hWnd, hIMC );
HWND hWndIme = ImmGetDefaultIMEWnd( _g_hWnd );
SendMessage( hWndIme, WM_IME_CONTROL, IMC_OPENSTATUSWINDOW, 0 );
#endif
}
break;
case WM_KILLFOCUS:
{
#ifdef TAIWAN_LOCAL
HIMC hIMC = ImmGetContext( _g_hWnd );
ImmSetOpenStatus( hIMC, FALSE );
ImmNotifyIME( hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0 );
ImmNotifyIME( hIMC, NI_CLOSECANDIDATE, 0, 0 );
ImmReleaseContext( _g_hWnd, hIMC );
HWND hWndIme = ImmGetDefaultIMEWnd( _g_hWnd );
SendMessage( hWndIme, WM_IME_CONTROL, IMC_CLOSESTATUSWINDOW, 0 );
#endif
}
break;
}
return FALSE;
}
INT_PTR CALLBACK GMSubRegenDlgProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_INITDIALOG:
{
CheckRadioButton( hWnd, IDC_GMREGEN_BTN_MODEDIRECT, IDC_GMREGEN_BTN_DELETE, IDC_GMREGEN_BTN_MODEDIRECT );
SetDlgItemInt( hWnd, IDC_GMREGEN_EDT_MOBNUM, 1, TRUE );
//SetDlgItemInt( hWnd, IDC_GMREGEN_EDT_CHANNEL, 0, TRUE );
SetDlgItemInt( hWnd, IDC_GMREGEN_EDT_RAD, 10, TRUE );
SetDlgItemInt( hWnd, IDC_GMREGEN_EDT_X, 0, TRUE );
SetDlgItemInt( hWnd, IDC_GMREGEN_EDT_Y, 0, TRUE );
SetDlgItemInt( hWnd, IDC_GMREGEN_EDT_ITEM, 0, TRUE );
SetChannelFromMap(hWnd, IDC_GMREGEN_CMB_MAP, IDC_GMREGEN_CMB_CHANNEL);
}
return FALSE;
case WM_COMMAND:
{
if( HIWORD( wParam ) == BN_CLICKED )
{
switch( LOWORD( wParam ) )
{
case IDC_GMREGEN_BTN_APPLY:
{
GMTOOLMGR->OnRegenCommand();
}
break;
case IDC_GMREGEN_BTN_CANCEL:
{
GMTOOLMGR->OnClickMenu( eMenu_Count );
SetFocus( _g_hWnd );
}
break;
case IDC_GMREGEN_BTN_MODEDIRECT:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_CMB_MOBNAME ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_MOBNUM ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_CMB_MAP ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_CMB_CHANNEL ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_X ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_Y ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_BTN_MYPOS ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_RAD ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_CMB_ITEM ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_ITEM ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_SUMMON_MONSTER_CHECK ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_SUMMON_VEHICLE_CHECK ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_BTN_OPEN ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_FILE ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_VEHICLE_GET_BUTTON ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_VEHICLE_DROPDOWN ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_SCRIPT_OBJECT_EDIT ), FALSE);
EnableWindow( GetDlgItem( hWnd, IDC_SCRIPT_OBJECT_FIND_BUTTON ), FALSE);
EnableWindow( GetDlgItem( hWnd, IDC_SCRIPT_FILE_EDIT ), FALSE);
EnableWindow( GetDlgItem( hWnd, IDC_SCRIPT_FILE_OPEN_BUTTON ), FALSE);
}
break;
case IDC_GMREGEN_BTN_MODEFILE:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_CMB_MOBNAME ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_MOBNUM ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_CMB_MAP ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_CMB_CHANNEL ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_X ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_Y ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_BTN_MYPOS ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_RAD ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_CMB_ITEM ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_ITEM ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_SUMMON_MONSTER_CHECK ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_SUMMON_VEHICLE_CHECK ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_BTN_OPEN ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_FILE ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_VEHICLE_GET_BUTTON ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_VEHICLE_DROPDOWN ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_SCRIPT_OBJECT_EDIT ), FALSE);
EnableWindow( GetDlgItem( hWnd, IDC_SCRIPT_OBJECT_FIND_BUTTON ), FALSE);
EnableWindow( GetDlgItem( hWnd, IDC_SCRIPT_FILE_EDIT ), FALSE);
EnableWindow( GetDlgItem( hWnd, IDC_SCRIPT_FILE_OPEN_BUTTON ), FALSE);
}
break;
case IDC_GMREGEN_BTN_DELETE:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_CMB_MOBNAME ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_MOBNUM ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_CMB_MAP ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_CMB_CHANNEL ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_X ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_Y ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_BTN_MYPOS ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_RAD ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_CMB_ITEM ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_ITEM ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_SUMMON_MONSTER_CHECK ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_SUMMON_VEHICLE_CHECK ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_BTN_OPEN ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_FILE ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_VEHICLE_GET_BUTTON ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_VEHICLE_DROPDOWN ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_SCRIPT_OBJECT_EDIT ), FALSE);
EnableWindow( GetDlgItem( hWnd, IDC_SCRIPT_OBJECT_FIND_BUTTON ), FALSE);
EnableWindow( GetDlgItem( hWnd, IDC_SCRIPT_FILE_EDIT ), FALSE);
EnableWindow( GetDlgItem( hWnd, IDC_SCRIPT_FILE_OPEN_BUTTON ), FALSE);
}
break;
case IDC_GMREGEN_BTN_UNSUMMON_VEHICLE:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_CMB_MOBNAME ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_MOBNUM ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_CMB_MAP ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_CMB_CHANNEL ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_X ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_Y ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_BTN_MYPOS ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_RAD ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_CMB_ITEM ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_ITEM ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_SUMMON_MONSTER_CHECK ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_SUMMON_VEHICLE_CHECK ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_BTN_OPEN ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_FILE ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_VEHICLE_GET_BUTTON ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_VEHICLE_DROPDOWN ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_SCRIPT_OBJECT_EDIT ), FALSE);
EnableWindow( GetDlgItem( hWnd, IDC_SCRIPT_OBJECT_FIND_BUTTON ), FALSE);
EnableWindow( GetDlgItem( hWnd, IDC_SCRIPT_FILE_EDIT ), FALSE);
EnableWindow( GetDlgItem( hWnd, IDC_SCRIPT_FILE_OPEN_BUTTON ), FALSE);
}
break;
case IDC_GMREGEN_SCRIPT_RADIO:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_CMB_MOBNAME ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_MOBNUM ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_CMB_MAP ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_CMB_CHANNEL ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_X ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_Y ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_BTN_MYPOS ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_RAD ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_CMB_ITEM ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_ITEM ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_SUMMON_MONSTER_CHECK ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_SUMMON_VEHICLE_CHECK ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_BTN_OPEN ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_EDT_FILE ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_VEHICLE_GET_BUTTON ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMREGEN_VEHICLE_DROPDOWN ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_SCRIPT_OBJECT_EDIT ), TRUE);
EnableWindow( GetDlgItem( hWnd, IDC_SCRIPT_OBJECT_FIND_BUTTON ), TRUE);
EnableWindow( GetDlgItem( hWnd, IDC_SCRIPT_FILE_EDIT ), TRUE);
EnableWindow( GetDlgItem( hWnd, IDC_SCRIPT_FILE_OPEN_BUTTON ), TRUE);
}
break;
case IDC_GMREGEN_BTN_MYPOS:
{
if( HERO )
{
VECTOR3 vPos;
HERO->GetPosition( &vPos );
SetDlgItemInt( hWnd, IDC_GMREGEN_EDT_X, (UINT)(vPos.x / 100.0f), TRUE );
SetDlgItemInt( hWnd, IDC_GMREGEN_EDT_Y, (UINT)(vPos.z / 100.0f), TRUE );
}
SetDlgItemText( hWnd, IDC_GMREGEN_CMB_MAP, GetMapName( MAP->GetMapNum() ) );
SetChannelFromMap(hWnd, IDC_GMREGEN_CMB_MAP, IDC_GMREGEN_CMB_CHANNEL);
SendDlgItemMessage( hWnd, IDC_GMREGEN_CMB_CHANNEL, CB_SETCURSEL, gChannelNum+1, 0 );
}
break;
case IDC_GMREGEN_BTN_OPEN:
{
//파일 다이얼로그
char lpstrFile[MAX_PATH] = "";
OPENFILENAME OFN;
ZeroMemory( &OFN, sizeof( OPENFILENAME ) );
OFN.lStructSize = sizeof( OPENFILENAME );
OFN.hwndOwner = hWnd;
OFN.lpstrFilter = "Text Files (.txt)\0*.txt\0All Files (*.*)\0*.*\0";
OFN.lpstrFile = lpstrFile;
OFN.nMaxFile = MAX_PATH;
OFN.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
if( GetOpenFileName( &OFN ) != 0 )
{
SetDlgItemText( hWnd, IDC_GMREGEN_EDT_FILE, OFN.lpstrFile );
}
}
break;
case IDC_GMREGEN_SUMMON_MONSTER_CHECK:
case IDC_GMREGEN_SUMMON_VEHICLE_CHECK:
{
SendDlgItemMessage(
hWnd,
IDC_GMREGEN_CMB_MOBNAME,
CB_RESETCONTENT,
0,
0);
const BOOL isCheckedMonster = IsDlgButtonChecked(
hWnd,
IDC_GMREGEN_SUMMON_MONSTER_CHECK);
const BOOL isCheckedVehicle = IsDlgButtonChecked(
hWnd,
IDC_GMREGEN_SUMMON_VEHICLE_CHECK);
int index = 0;
for(const BASE_MONSTER_LIST* baseMonsterList = GAMERESRCMNGR->GetMonsterListInfo(++index);
0 < baseMonsterList;
baseMonsterList = GAMERESRCMNGR->GetMonsterListInfo(++index))
{
TCHAR text[MAX_PATH] = _T(" * * * * * ");
const VehicleScript& vehicleScript = GAMERESRCMNGR->GetVehicleScript(
baseMonsterList->MonsterKind);
if(0 == vehicleScript.mMonsterKind)
{
if(FALSE == isCheckedMonster)
{
continue;
}
_stprintf(
text,
_T("%s(%u), lv%d"),
baseMonsterList->Name,
baseMonsterList->MonsterKind,
baseMonsterList->Level);
}
else if(isCheckedVehicle)
{
_stprintf(
text,
_T("%s(%u), %d seat"),
baseMonsterList->Name,
baseMonsterList->MonsterKind,
vehicleScript.mSeatSize);
}
LRESULT ret = SendDlgItemMessage(
hWnd,
IDC_GMREGEN_CMB_MOBNAME,
CB_ADDSTRING,
0,
LPARAM(text));
// MonsterKind를 Data로 등록
SendDlgItemMessage(
hWnd,
IDC_GMREGEN_CMB_MOBNAME,
CB_SETITEMDATA,
WPARAM(ret),
LPARAM(baseMonsterList->MonsterKind));
}
SendDlgItemMessage(
hWnd,
IDC_GMREGEN_CMB_MOBNAME,
CB_SETCURSEL,
0,
0);
}
break;
case IDC_GMREGEN_VEHICLE_GET_BUTTON:
{
MSGBASE message;
ZeroMemory(
&message,
sizeof(message));
message.Category = MP_CHEAT;
message.Protocol = MP_CHEAT_VEHICLE_GET_SYN;
message.dwObjectID = gHeroID;
NETWORK->Send(
&message,
sizeof(message));
}
break;
case IDC_SCRIPT_OBJECT_FIND_BUTTON:
{
CObject* const object = OBJECTMGR->GetSelectedObject();
if(0 == object ||
FALSE == (eObjectKind_Monster & object->GetObjectKind()))
{
MessageBox(
0,
"Select monster, please",
"Alert",
MB_OK);
break;
}
TCHAR text[MAX_PATH] = {0};
_stprintf(
text,
"%u %s",
object->GetID(),
object->GetObjectName());
SetDlgItemText(
hWnd,
IDC_SCRIPT_OBJECT_EDIT,
text);
}
break;
case IDC_SCRIPT_FILE_OPEN_BUTTON:
{
TCHAR currentDirectory[MAX_PATH] = {0};
GetCurrentDirectory(
_countof(currentDirectory),
currentDirectory);
TCHAR text[MAX_PATH] = {0};
OPENFILENAME openFileName = {0};
openFileName.lStructSize = sizeof(openFileName);
openFileName.hwndOwner = hWnd;
openFileName.lpstrFilter = "Bin Files\0*.bin";
openFileName.lpstrFile = text;
openFileName.nMaxFile = _countof(text);
openFileName.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
openFileName.lpstrInitialDir = "system\\resource\\AiScript";
if(0 == GetOpenFileName(&openFileName))
{
SetCurrentDirectory(
currentDirectory);
break;
}
TCHAR textDrive[_MAX_DRIVE] = {0};
TCHAR textDirectory[_MAX_DIR] = {0};
TCHAR textFileName[_MAX_FNAME] = {0};
TCHAR textExtension[_MAX_EXT] = {0};
_splitpath(
openFileName.lpstrFile,
textDrive,
textDirectory,
textFileName,
textExtension);
_stprintf(
text,
"%s%s",
textFileName,
textExtension);
SetDlgItemText(
hWnd,
IDC_SCRIPT_FILE_EDIT,
text);
SetCurrentDirectory(
currentDirectory);
}
break;
}
}
else if( HIWORD( wParam ) == CBN_SELENDOK )
{
switch( LOWORD( wParam ) )
{
case IDC_GMREGEN_CMB_MAP:
{
SetChannelFromMap(hWnd, IDC_GMREGEN_CMB_MAP, IDC_GMREGEN_CMB_CHANNEL);
}
break;
}
}
}
return TRUE;
case WM_SETFOCUS:
{
#ifdef TAIWAN_LOCAL
HIMC hIMC = ImmGetContext( _g_hWnd );
ImmSetOpenStatus( hIMC, TRUE );
ImmReleaseContext( _g_hWnd, hIMC );
HWND hWndIme = ImmGetDefaultIMEWnd( _g_hWnd );
SendMessage( hWndIme, WM_IME_CONTROL, IMC_OPENSTATUSWINDOW, 0 );
#endif
}
break;
case WM_KILLFOCUS:
{
#ifdef TAIWAN_LOCAL
HIMC hIMC = ImmGetContext( _g_hWnd );
ImmSetOpenStatus( hIMC, FALSE );
ImmNotifyIME( hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0 );
ImmNotifyIME( hIMC, NI_CLOSECANDIDATE, 0, 0 );
ImmReleaseContext( _g_hWnd, hIMC );
HWND hWndIme = ImmGetDefaultIMEWnd( _g_hWnd );
SendMessage( hWndIme, WM_IME_CONTROL, IMC_CLOSESTATUSWINDOW, 0 );
#endif
}
break;
}
return FALSE;
}
INT_PTR CALLBACK GMSubDisconDlgProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_INITDIALOG:
{
CheckRadioButton( hWnd, IDC_GMDISCON_BTN_USER, IDC_GMDISCON_BTN_MAP, IDC_GMDISCON_BTN_USER );
}
return FALSE;
case WM_COMMAND:
{
if( HIWORD( wParam ) == BN_CLICKED )
{
switch( LOWORD( wParam ) )
{
case IDC_GMDISCON_BTN_APPLY:
{
GMTOOLMGR->OnDisconCommand();
}
break;
case IDC_GMDISCON_BTN_CANCEL:
{
GMTOOLMGR->OnClickMenu( eMenu_Count );
SetFocus( _g_hWnd );
}
break;
case IDC_GMDISCON_BTN_USER:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMDISCON_EDT_CHAR ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMDISCON_CMB_MAP ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMDISCON_BTN_EXCEPTSELF ), FALSE );
}
break;
case IDC_GMDISCON_BTN_MAP:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMDISCON_EDT_CHAR ), FALSE );
EnableWindow( GetDlgItem( hWnd, IDC_GMDISCON_CMB_MAP ), TRUE );
EnableWindow( GetDlgItem( hWnd, IDC_GMDISCON_BTN_EXCEPTSELF ), TRUE );
}
break;
}
}
}
return TRUE;
case WM_SETFOCUS:
{
#ifdef TAIWAN_LOCAL
HIMC hIMC = ImmGetContext( _g_hWnd );
ImmSetOpenStatus( hIMC, TRUE );
ImmReleaseContext( _g_hWnd, hIMC );
HWND hWndIme = ImmGetDefaultIMEWnd( _g_hWnd );
SendMessage( hWndIme, WM_IME_CONTROL, IMC_OPENSTATUSWINDOW, 0 );
#endif
}
break;
case WM_KILLFOCUS:
{
#ifdef TAIWAN_LOCAL
HIMC hIMC = ImmGetContext( _g_hWnd );
ImmSetOpenStatus( hIMC, FALSE );
ImmNotifyIME( hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0 );
ImmNotifyIME( hIMC, NI_CLOSECANDIDATE, 0, 0 );
ImmReleaseContext( _g_hWnd, hIMC );
HWND hWndIme = ImmGetDefaultIMEWnd( _g_hWnd );
SendMessage( hWndIme, WM_IME_CONTROL, IMC_CLOSESTATUSWINDOW, 0 );
#endif
}
break;
}
return FALSE;
}
INT_PTR CALLBACK GMSubPKDlgProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_INITDIALOG:
{
CheckRadioButton( hWnd, IDC_GMPK_BTN_MAP, IDC_GMPK_BTN_MAP, IDC_GMPK_BTN_MAP );
CheckRadioButton( hWnd, IDC_GMPK_BTN_NOPK, IDC_GMPK_BTN_ALLOW, IDC_GMPK_BTN_NOPK );
SetChannelFromMap(hWnd, IDC_GMPK_CMB_MAP, IDC_GMPK_CMB_CHANNEL);
}
return FALSE;
case WM_COMMAND:
{
if( HIWORD( wParam ) == BN_CLICKED )
{
switch( LOWORD( wParam ) )
{
case IDC_GMPK_BTN_APPLY:
{
GMTOOLMGR->OnPKCommand();
}
break;
case IDC_GMPK_BTN_CANCEL:
{
GMTOOLMGR->OnClickMenu( eMenu_Count );
SetFocus( _g_hWnd );
}
break;
}
}
else if( HIWORD( wParam ) == CBN_SELENDOK )
{
switch( LOWORD( wParam ) )
{
case IDC_GMPK_CMB_MAP:
{
SetChannelFromMap(hWnd, IDC_GMREGEN_CMB_MAP, IDC_GMPK_CMB_CHANNEL);
}
break;
}
}
}
return TRUE;
case WM_SETFOCUS:
{
#ifdef TAIWAN_LOCAL
HIMC hIMC = ImmGetContext( _g_hWnd );
ImmSetOpenStatus( hIMC, TRUE );
ImmReleaseContext( _g_hWnd, hIMC );
HWND hWndIme = ImmGetDefaultIMEWnd( _g_hWnd );
SendMessage( hWndIme, WM_IME_CONTROL, IMC_OPENSTATUSWINDOW, 0 );
#endif
}
break;
case WM_KILLFOCUS:
{
#ifdef TAIWAN_LOCAL
HIMC hIMC = ImmGetContext( _g_hWnd );
ImmSetOpenStatus( hIMC, FALSE );
ImmNotifyIME( hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0 );
ImmNotifyIME( hIMC, NI_CLOSECANDIDATE, 0, 0 );
ImmReleaseContext( _g_hWnd, hIMC );
HWND hWndIme = ImmGetDefaultIMEWnd( _g_hWnd );
SendMessage( hWndIme, WM_IME_CONTROL, IMC_CLOSESTATUSWINDOW, 0 );
#endif
}
break;
}
return FALSE;
}
INT_PTR CALLBACK GMSubEventDlgProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_INITDIALOG:
{
CheckRadioButton( hWnd, IDC_GMCHAT_BTN_USER, IDC_GMCHAT_BTN_MAP, IDC_GMCHAT_BTN_USER );
}
return FALSE;
case WM_COMMAND:
{
if( HIWORD( wParam ) == BN_CLICKED )
{
switch( LOWORD( wParam ) )
{
case IDC_GMEVENT_BTN_APPLY:
{
GMTOOLMGR->OnEventCommand();
}
break;
case IDC_GMEVENT_BTN_CLOSE:
{
GMTOOLMGR->OnClickMenu( eMenu_Count );
SetFocus( _g_hWnd );
}
break;
}
}
}
break;
}
return FALSE;
}
INT_PTR CALLBACK GMSubNoticeDlgProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_INITDIALOG:
{
CheckRadioButton( hWnd, IDC_GMNOTICE_BTN_ALLMAP, IDC_GMNOTICE_BTN_MAP, IDC_GMNOTICE_BTN_ALLMAP );
//입력에디트 제한글자 설정 //focus
SendMessage( GetDlgItem( hWnd, IDC_GMNOTICE_EDT_PREFACE ), EM_LIMITTEXT, MAX_PREFACE_LENGTH, 0 );
SendMessage( GetDlgItem( hWnd, IDC_GMNOTICE_EDT_NOTICE ), EM_LIMITTEXT, MAX_CHAT_LENGTH - MAX_PREFACE_LENGTH, 0 );
SetFocus( GetDlgItem( hWnd, IDC_GMNOTICE_EDT_PREFACE ) );
}
return FALSE;
case WM_COMMAND:
{
if( HIWORD( wParam ) == BN_CLICKED )
{
switch( LOWORD( wParam ) )
{
case IDC_GMNOTICE_OK:
{
GMTOOLMGR->OnNoticeCommand();
}
break;
case IDC_GMNOTICE_CANCEL:
{
GMTOOLMGR->OnClickMenu( eMenu_Count );
SetFocus( _g_hWnd );
}
break;
case IDC_GMNOTICE_BTN_ALLMAP:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMNOTICE_CMB_MAP ), FALSE );
}
break;
case IDC_GMNOTICE_BTN_MAP:
{
EnableWindow( GetDlgItem( hWnd, IDC_GMNOTICE_CMB_MAP ), TRUE );
}
break;
}
}
}
return TRUE;
case WM_CLOSE:
{
GMTOOLMGR->OnClickMenu( eMenu_Count );
SetFocus( _g_hWnd );
}
return TRUE;
case WM_SETFOCUS:
{
#ifdef TAIWAN_LOCAL
HIMC hIMC = ImmGetContext( _g_hWnd );
ImmSetOpenStatus( hIMC, TRUE );
ImmReleaseContext( _g_hWnd, hIMC );
HWND hWndIme = ImmGetDefaultIMEWnd( _g_hWnd );
SendMessage( hWndIme, WM_IME_CONTROL, IMC_OPENSTATUSWINDOW, 0 );
#endif
}
break;
case WM_KILLFOCUS:
{
#ifdef TAIWAN_LOCAL
HIMC hIMC = ImmGetContext( _g_hWnd );
ImmSetOpenStatus( hIMC, FALSE );
ImmNotifyIME( hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0 );
ImmNotifyIME( hIMC, NI_CLOSECANDIDATE, 0, 0 );
ImmReleaseContext( _g_hWnd, hIMC );
HWND hWndIme = ImmGetDefaultIMEWnd( _g_hWnd );
SendMessage( hWndIme, WM_IME_CONTROL, IMC_CLOSESTATUSWINDOW, 0 );
#endif
}
break;
}
return FALSE;
}
INT_PTR CALLBACK GMSubEventMapDlgProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_INITDIALOG:
{
CheckDlgButton( hWnd, IDC_GMEVENTMAP_BTN_USER, BST_CHECKED );
CheckDlgButton( hWnd, IDC_GMEVENTMAP_BTN_CHNANNEL, BST_CHECKED );
CheckDlgButton( hWnd, IDC_GMEVENTMAP_BTN_TEAM, BST_CHECKED );
CheckDlgButton( hWnd, IDC_GMEVENTMAP_BTN_CHNANNEL2, BST_CHECKED );
SendMessage( GetDlgItem( hWnd, IDC_GMEVENTMAP_EDT_CHAR ), EM_LIMITTEXT, MAX_NAME_LENGTH+1, 0 );
}
return FALSE;
case WM_COMMAND:
{
if( HIWORD( wParam ) == BN_CLICKED )
{
switch( LOWORD( wParam ) )
{
case IDC_GMEVENTMAP_BTN_CLOSE:
{
GMTOOLMGR->OnClickMenu( eMenu_Count );
SetFocus( _g_hWnd );
}
break;
case IDC_GMEVENTMAP_BTN_USER:
{
CObject* pObject = OBJECTMGR->GetSelectedObject();
if( pObject )
if( pObject->GetObjectKind() == eObjectKind_Player )
{
SetDlgItemText( hWnd, IDC_GMEVENTMAP_EDT_CHAR, pObject->GetObjectName() );
}
}
break;
}
}
}
break;
}
return FALSE;
}
INT_PTR CALLBACK GMSubEventNotifyDlgProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_INITDIALOG:
{
CheckDlgButton( hWnd, IDC_GMEVENTNOTIFY_BTN_NOTIFY, BST_CHECKED );
// CheckDlgButton( hWnd, IDC_GMEVENTNOTIFY_BTN_SOUND, BST_CHECKED );
SendMessage( GetDlgItem( hWnd, IDC_GMEVENTNOTIFY_EDT_TITLE ), EM_LIMITTEXT, 10, 0 );
SendMessage( GetDlgItem( hWnd, IDC_GMEVENTNOTIFY_EDT_CONTEXT ), EM_LIMITTEXT, 40, 0 );
}
return FALSE;
case WM_COMMAND:
{
if( HIWORD( wParam ) == BN_CLICKED )
{
switch( LOWORD( wParam ) )
{
case IDC_GMEVENTNOTIFY_BTN_ON:
{
GMTOOLMGR->OnEventNotifyCommand( TRUE );
}
break;
case IDC_GMEVENTNOTIFY_BTN_OFF:
{
GMTOOLMGR->OnEventNotifyCommand( FALSE );
}
break;
case IDC_GMEVENTNOTIFY_BTN_CLOSE:
{
GMTOOLMGR->OnClickMenu( eMenu_Count );
SetFocus( _g_hWnd );
}
break;
}
}
}
break;
}
return FALSE;
}
INT_PTR CALLBACK GMWeatherDlgProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_COMMAND:
{
if( HIWORD( wParam ) == BN_CLICKED )
{
switch( LOWORD( wParam ) )
{
case IDC_GMWEATHER_BTN_APPLY:
{
char weatherTxt[MAX_PATH]={0,};
int nSel = SendDlgItemMessage( hWnd, IDC_GMWEATHER_CMB_TYPE, CB_GETCURSEL, 0, 0 );
SendDlgItemMessage( hWnd, IDC_GMWEATHER_CMB_TYPE, CB_GETLBTEXT, nSel, (LPARAM)weatherTxt );
BOOL rt;
int nIntensity = GetDlgItemInt( hWnd, IDC_GMWEATHER_EDIT_INTENSITY, &rt, TRUE );
if( !rt ) break;
WEATHERMGR->EffectOn( weatherTxt, WORD(nIntensity));
CHATMGR->AddMsg( CTC_TOGM, "Weather Effect On : %s[%d]", weatherTxt, nIntensity );
}
break;
case IDC_GMWEATHER_BTN_STOP:
{
WEATHERMGR->EffectOff();
CHATMGR->AddMsg( CTC_TOGM, "Weather Effect Off" );
}
break;
case IDC_GMWEATHER_BTN_SHOW_INFO:
{
WEATHERMGR->ShowDebugState( TRUE );
}
break;
case IDC_GMWEATHER_BTN_HIDE_INFO:
{
WEATHERMGR->ShowDebugState( FALSE );
}
break;
}
}
}
break;
}
return FALSE;
}
INT_PTR CALLBACK GMDungeonDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch( message )
{
case WM_COMMAND:
{
if( HIWORD( wParam ) == BN_CLICKED )
{
switch( LOWORD( wParam ) )
{
case IDC_GMDUNGEON_BTN_GETINFO:
{
GMTOOLMGR->OnDungeonGetInfo_Syn();
}
break;
case IDC_GMDUNGEON_BTN_GETDETAILINFO:
{
int nSel = SendDlgItemMessage( hWnd, IDC_GMDUNGEON_LSB_DUNGEONLIST, LB_GETCURSEL, 0, 0 );
if(nSel<1 || MAX_DUNGEON_NUM<nSel)
return FALSE;
GMTOOLMGR->OnDungeonGetDetailInfo_Syn(nSel);
}
break;
case IDC_GMDUNGEON_BTN_CLEARDETAILINFO:
{
GMTOOLMGR->DungeonClearDetailInfo();
}
break;
case IDC_GMDUNGEON_BTN_MORNITORING:
{
int nSel = SendDlgItemMessage( hWnd, IDC_GMDUNGEON_LSB_DUNGEONLIST, LB_GETCURSEL, 0, 0 );
if(nSel<1 || MAX_DUNGEON_NUM<nSel)
return FALSE;
GMTOOLMGR->OnDungeonMornitoring_Syn(nSel);
}
break;
}
}
}
break;
default:
break;
}
return FALSE;
}
WNDPROC OldEditProc;
WNDPROC OldChatProc;
HWND hWndComboID;
INT_PTR CALLBACK GMSubCounselDlgProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_INITDIALOG:
{
//입력에디트 제한글자 설정 //focus
SendMessage( GetDlgItem( hWnd, IDC_GMCOUNSEL_EDT_INPUT ), EM_LIMITTEXT, 127, 0 );
SetFocus( GetDlgItem( hWnd, IDC_GMCOUNSEL_EDT_INPUT ) );
OldEditProc = (WNDPROC)SetWindowLong( GetDlgItem( hWnd, IDC_GMCOUNSEL_EDT_INPUT ),
GWL_WNDPROC, (LONG)GMCounselEditProc);
OldChatProc = (WNDPROC)SetWindowLong( GetDlgItem( hWnd, IDC_GMCOUNSEL_EDT_CHAT ),
GWL_WNDPROC, (LONG)GMCounselChatProc);
hWndComboID = GetDlgItem( hWnd, IDC_GMCOUNSEL_CMB_ID );
SendMessage( hWndComboID, CB_INSERTSTRING, 0, (LPARAM)"----------------" );
GMTOOLMGR->SetChatListHwnd( GetDlgItem( hWnd, IDC_GMCOUNSEL_EDT_CHAT ) );
}
return FALSE;
case WM_COMMAND:
{
if( HIWORD( wParam ) == BN_CLICKED )
{
switch( LOWORD( wParam ) )
{
case IDC_GMCOUNSEL_BTN_SAVE:
{
char FileName[MAX_PATH] = "";
OPENFILENAME OFN;
memset( &OFN, 0, sizeof(OPENFILENAME) );
OFN.lStructSize = sizeof(OPENFILENAME);
OFN.hwndOwner = hWnd;
OFN.lpstrFilter = "Text Files(*.txt)\0*.txt\0";
OFN.lpstrFile = FileName;
OFN.nMaxFile = MAX_PATH;
OFN.lpstrDefExt = "txt";
OFN.Flags = OFN_OVERWRITEPROMPT;
if( GetSaveFileName(&OFN) != 0 )
{
GMTOOLMGR->CaptureChat( FileName );
}
}
break;
}
}
}
return TRUE;
case WM_CLOSE:
{
GMTOOLMGR->OnClickMenu( eMenu_Count );
SetFocus( _g_hWnd );
}
return TRUE;
case WM_DESTROY:
{
SetWindowLong( GetDlgItem( hWnd, IDC_GMCOUNSEL_EDT_INPUT ), GWL_WNDPROC, (LONG)OldEditProc );
SetWindowLong( GetDlgItem( hWnd, IDC_GMCOUNSEL_EDT_CHAT ), GWL_WNDPROC, (LONG)OldChatProc );
}
return TRUE;
case WM_SETFOCUS:
{
#ifdef TAIWAN_LOCAL
HIMC hIMC = ImmGetContext( _g_hWnd );
ImmSetOpenStatus( hIMC, TRUE );
ImmReleaseContext( _g_hWnd, hIMC );
HWND hWndIme = ImmGetDefaultIMEWnd( _g_hWnd );
SendMessage( hWndIme, WM_IME_CONTROL, IMC_OPENSTATUSWINDOW, 0 );
#endif
}
break;
case WM_KILLFOCUS:
{
#ifdef TAIWAN_LOCAL
HIMC hIMC = ImmGetContext( _g_hWnd );
ImmSetOpenStatus( hIMC, FALSE );
ImmNotifyIME( hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0 );
ImmNotifyIME( hIMC, NI_CLOSECANDIDATE, 0, 0 );
ImmReleaseContext( _g_hWnd, hIMC );
HWND hWndIme = ImmGetDefaultIMEWnd( _g_hWnd );
SendMessage( hWndIme, WM_IME_CONTROL, IMC_CLOSESTATUSWINDOW, 0 );
#endif
}
break;
}
return FALSE;
}
LRESULT CALLBACK GMCounselEditProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_KEYDOWN:
{
if( wParam == VK_RETURN )
{
char buf[128];
GetWindowText( hWnd, buf, 127 );
if( buf[0] == 0 ) return TRUE;
char Name[MAX_NAME_LENGTH+2] = {0,};
int nLen = GetWindowText( hWndComboID, Name, MAX_NAME_LENGTH+1 );
if( nLen < 4 || nLen > MAX_NAME_LENGTH )
return TRUE;
// 아이디확인 - RaMa 04.10.20
if( (FILTERTABLE->IsInvalidCharInclude((unsigned char*)Name)) == TRUE )
{
CHATMGR->AddMsg(CTC_SYSMSG, CHATMGR->GetChatMsg(368));
return TRUE;
}
//---귓말 보내기
MSG_CHAT data;
data.Category = MP_CHAT;
data.Protocol = MP_CHAT_WHISPER_SYN;
data.dwObjectID = gHeroID;
SafeStrCpy( data.Name, Name, MAX_NAME_LENGTH+1 );
SafeStrCpy( data.Msg, buf, MAX_CHAT_LENGTH+1 );
// NETWORK->Send(&data,sizeof(data));
NETWORK->Send(&data,data.GetMsgLength()); //CHATMSG 040324
SetWindowText( hWnd, "" );
return TRUE;
}
else if( wParam == VK_F8 )
{
GMTOOLMGR->RemoveIdFromList();
}
}
break;
}
return CallWindowProc( OldEditProc, hWnd, message, wParam, lParam );
}
LRESULT CALLBACK GMCounselChatProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_CHAR:
case WM_LBUTTONDOWN:
return TRUE;
}
return CallWindowProc( OldChatProc, hWnd, message, wParam, lParam );
}
void CGMToolManager::RemoveIdFromList()
{
char Name[MAX_NAME_LENGTH+2] = {0,};
int nLen = GetWindowText( hWndComboID, Name, MAX_NAME_LENGTH+1 );
if( nLen < 4 || nLen > MAX_NAME_LENGTH )
return;
int nIndex = SendMessage( hWndComboID, CB_FINDSTRING, 0, (LPARAM)Name );
if( nIndex != CB_ERR && nIndex != m_nNumNow )
{
SendMessage( hWndComboID, CB_DELETESTRING, nIndex, 0 );
SendMessage( hWndComboID, CB_SETCURSEL, 0, 0 );
if( nIndex > m_nNumNow )
--m_nNumWait;
else
--m_nNumNow;
}
}
void CGMToolManager::AddChatMsg( char* pName, char* pMsg, int nKind )
{
if( !m_hWndChatList ) return;
char buf[160];
if( nKind == 1 ) //했다.
{
wsprintf( buf, "*%-20s: %s", pName, pMsg );
int nIndex = SendMessage( hWndComboID, CB_FINDSTRING, 0, (LPARAM)pName );
if( nIndex == CB_ERR )
{
SendMessage( hWndComboID, CB_INSERTSTRING, 0, (LPARAM)pName );
++m_nNumNow;
}
else if( nIndex != 0 )
{
SendMessage( hWndComboID, CB_DELETESTRING, nIndex, 0 );
SendMessage( hWndComboID, CB_INSERTSTRING, 0, (LPARAM)pName );
SendMessage( hWndComboID, CB_SETCURSEL, 0, 0 );
}
if( m_nNumNow > 10 )
{
SendMessage( hWndComboID, CB_DELETESTRING, 10, 0 ); //제일 아래것 지우기
--m_nNumNow;
}
}
else if( nKind == 2 ) //받았다.
{
wsprintf( buf, "FROM %-16s: %s", pName, pMsg );
int nIndex = SendMessage( hWndComboID, CB_FINDSTRING, 0, (LPARAM)pName );
if( nIndex == CB_ERR )
{
SendMessage( hWndComboID, CB_INSERTSTRING, m_nNumNow, (LPARAM)pName );
++m_nNumWait;
}
int nCount = SendMessage( hWndComboID, CB_GETCOUNT, 0, 0 );
if( m_nNumWait > 10 )
{
SendMessage( hWndComboID, CB_DELETESTRING, nCount-1, 0 ); //제일 아래것 지우기
--m_nNumWait;
}
}
else if( nKind == 3 ) //에러
{
wsprintf( buf, "%22s - %s -", pName, pMsg );
}
int nLen = strlen( buf );
buf[nLen] = 13;
buf[nLen+1] = 10;
buf[nLen+2] = 0;
SendMessage( m_hWndChatList, EM_REPLACESEL, FALSE, (LPARAM)buf );
strcpy( m_strChatList+m_nBufLen, buf );
m_nBufLen += (nLen+2);
//너무 많이 차면 지우자.
if( m_nBufLen > 1024*10 )
{
char FileName[MAX_PATH];
SYSTEMTIME ti;
GetLocalTime( &ti );
wsprintf( FileName, "GM_Counsel/%s%02d%02d%02d.txt", HERO->GetObjectName(), ti.wYear, ti.wMonth, ti.wDay );
m_nBufLen -= 1024;
DIRECTORYMGR->SetLoadMode(eLM_Root);
CreateDirectory( "GM_Counsel", NULL );
HANDLE hFile;
hFile = CreateFile( FileName, GENERIC_WRITE, 0, NULL,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
if( hFile == INVALID_HANDLE_VALUE )
return;
DWORD dwWritten;
SetFilePointer( hFile, 0, NULL, FILE_END );
WriteFile( hFile, m_strChatList, 1024, &dwWritten, NULL );
CloseHandle( hFile );
memmove( m_strChatList, m_strChatList+1024, m_nBufLen );
m_strChatList[m_nBufLen] = 0;
SetWindowText( m_hWndChatList, m_strChatList );
SendMessage( m_hWndChatList, EM_SETSEL, m_nBufLen, m_nBufLen );
}
}
void CGMToolManager::CaptureChat( char* FileName )
{
HANDLE hFile;
hFile = CreateFile( FileName, GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
if( hFile == INVALID_HANDLE_VALUE )
return;
DWORD dwWritten;
WriteFile( hFile, m_strChatList, m_nBufLen, &dwWritten, NULL );
CloseHandle( hFile );
}
void CGMToolManager::SaveChatList()
{
if( m_strChatList[0] == 0 ) return;
char FileName[MAX_PATH];
SYSTEMTIME ti;
GetLocalTime( &ti );
CHero* hero = OBJECTMGR->GetHero();
if( hero )
{
wsprintf( FileName, "GM_Counsel/%s%02d%02d%02d.txt", hero->GetObjectName(), ti.wYear, ti.wMonth, ti.wDay );
}
DIRECTORYMGR->SetLoadMode(eLM_Root);
CreateDirectory( "GM_Counsel", NULL );
HANDLE hFile;
hFile = CreateFile( FileName, GENERIC_WRITE, 0, NULL,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
if( hFile == INVALID_HANDLE_VALUE )
return;
DWORD dwWritten;
SetFilePointer( hFile, 0, NULL, FILE_END );
WriteFile( hFile, m_strChatList, m_nBufLen, &dwWritten, NULL );
CloseHandle( hFile );
m_strChatList[0] = 0;
m_nBufLen = 0;
SetWindowText( m_hWndChatList, "" );
}
void CGMToolManager::AddWeatherType( LPCTSTR weatherName )
{
SendDlgItemMessage( m_hWndSub[eMenu_Weather], IDC_GMWEATHER_CMB_TYPE, CB_ADDSTRING, 0, (LPARAM)weatherName );
}
BOOL CGMToolManager::OnDungeonGetInfo_Syn()
{
if( !m_hWndSub[eMenu_Dungeon] ) return FALSE;
SetFocus( _g_hWnd );
char buf[256] = {0,};
int nLen = GetDlgItemText( m_hWndSub[eMenu_Dungeon], IDC_GMDUNGEON_CMB_MAPLIST, buf, MAX_MAP_NAME_LENGTH+1 );
if( nLen == 0 ) return FALSE;
buf[MAX_MAP_NAME_LENGTH] = 0;
WORD wMapNum = GetMapNumForName( buf );
if( wMapNum == 0 ) return FALSE;
MSG_WORD2 msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_DUNGEON_GETINFOALL_SYN;
msg.dwObjectID = gHeroID;
msg.wData1 = wMapNum;
msg.wData2 = 0;
NETWORK->Send( &msg, sizeof(msg) );
return TRUE;
}
void CGMToolManager::DungeonGetInfo_Ack(MSGBASE* pMsg)
{
MSG_DUNGEON_INFO_ALL* pmsg = (MSG_DUNGEON_INFO_ALL*)pMsg;
if(pmsg->dwObjectID != gHeroID)
return;
int nIndex = 0;
char buf[256] = {0,};
SendDlgItemMessage( m_hWndSub[eMenu_Dungeon], IDC_GMDUNGEON_LSB_DUNGEONLIST, LB_RESETCONTENT, 0, 0 );
if(! pmsg->dwDungeonNum)
{
SendDlgItemMessage( m_hWndSub[eMenu_Dungeon], IDC_GMDUNGEON_LSB_DUNGEONLIST, LB_INSERTSTRING, WPARAM(-1), (LPARAM)"No Active Dungeons" );
}
else
{
sprintf(buf, "Active Dungeons : %d, Players in Dungeons : %d", pmsg->dwDungeonNum, pmsg->dwUserNum);
SendDlgItemMessage( m_hWndSub[eMenu_Dungeon], IDC_GMDUNGEON_LSB_DUNGEONLIST, LB_INSERTSTRING, nIndex, (LPARAM)buf);
for(DWORD i=0; i<pmsg->dwDungeonNum; i++)
{
sprintf(buf, "[%03d] : Channel(%d), PartyIdx(%d), PlayerNum(%d), Point(%d), ",
i, pmsg->DungeonInfo[i].dwChannel, pmsg->DungeonInfo[i].dwPartyIndex, pmsg->DungeonInfo[i].dwJoinPlayerNum,
pmsg->DungeonInfo[i].dwPoint);
if(pmsg->DungeonInfo[i].difficulty == eDIFFICULTY_EASY)
strcat(buf, "Level(Easy)");
else if(pmsg->DungeonInfo[i].difficulty == eDIFFICULTY_NORMAL)
strcat(buf, "Level(Normal)");
else if(pmsg->DungeonInfo[i].difficulty == eDIFFICULTY_HARD)
strcat(buf, "Level(Hard)");
else
strcat(buf, "Level(None)");
nIndex = SendDlgItemMessage( m_hWndSub[eMenu_Dungeon], IDC_GMDUNGEON_LSB_DUNGEONLIST, LB_INSERTSTRING, WPARAM(-1), (LPARAM)buf );
SendDlgItemMessage( m_hWndSub[eMenu_Dungeon], IDC_GMDUNGEON_LSB_DUNGEONLIST, LB_SETITEMDATA, nIndex, (LPARAM)pmsg->DungeonInfo[i].dwChannel );
}
}
}
BOOL CGMToolManager::OnDungeonGetDetailInfo_Syn(int nIndex)
{
if( !m_hWndSub[eMenu_Where] ) return FALSE;
SetFocus( _g_hWnd );
char buf[256] = {0,};
int nLen = GetDlgItemText( m_hWndSub[eMenu_Dungeon], IDC_GMDUNGEON_CMB_MAPLIST, buf, MAX_MAP_NAME_LENGTH+1 );
if( nLen == 0 ) return FALSE;
buf[MAX_MAP_NAME_LENGTH] = 0;
WORD wMapNum = GetMapNumForName( buf );
if( wMapNum == 0 ) return FALSE;
WORD wChannel = WORD(SendDlgItemMessage( m_hWndSub[eMenu_Dungeon], IDC_GMDUNGEON_LSB_DUNGEONLIST, LB_GETITEMDATA, nIndex, 0 ));
if( wChannel == 0) return FALSE;
MSG_WORD3 msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_DUNGEON_GETINFOONE_SYN;
msg.dwObjectID = gHeroID;
msg.wData1 = wMapNum;
msg.wData2 = wChannel;
msg.wData3 = 0;
NETWORK->Send( &msg, sizeof(msg) );
return TRUE;
}
void CGMToolManager::DungeonGetDetailInfo_Ack(MSGBASE* pMsg)
{
MSG_DUNGEON_INFO_ONE* pmsg = (MSG_DUNGEON_INFO_ONE*)pMsg;
if(pmsg->dwObjectID != gHeroID)
return;
char buf[256] = {0,};
strcpy(&m_strDetailInfo[0], "");
sprintf(&m_strDetailInfo[0], "- Player List\r\n");
int i;
PARTY_MEMBER member;
for(i=0; i<MAX_PARTY_LISTNUM; i++)
{
member = pmsg->DungeonInfo.PartyMember[i];
if(member.dwMemberID)
{
const WORD index = ( 1 < member.mJobGrade ? member.mJob[ member.mJobGrade - 1 ] : 1 );
const WORD job = ( member.mJob[ 0 ] * 1000 ) + ( ( member.mRace + 1 ) * 100 ) + ( member.mJobGrade * 10 ) + index;
char* pClass = RESRCMGR->GetMsg(RESRCMGR->GetClassNameNum(job));
sprintf(buf, "[%s (%d)] : %s\r\n", member.Name, member.Level, pClass);
strcat(&m_strDetailInfo[0], buf);
}
}
strcat(m_strDetailInfo, "\r\n");
strcat(m_strDetailInfo, "- Active Warp List\r\n");
for(i=0; i<MAX_DUNGEON_WARP; i++)
{
if(pmsg->DungeonInfo.warpState[i].dwIndex &&
pmsg->DungeonInfo.warpState[i].bActive)
{
sprintf(buf, "[Warp %02d] : ON\r\n", i);
strcat(&m_strDetailInfo[0], buf);
}
}
strcat(m_strDetailInfo, "\r\n");
strcat(m_strDetailInfo, "- Active Switch List\r\n");
for(i=0; i<MAX_DUNGEON_SWITCH; i++)
{
if(pmsg->DungeonInfo.switchState[i])
{
sprintf(buf, "[Switch %02d] : ON\r\n", i);
strcat(&m_strDetailInfo[0], buf);
}
}
SetWindowText( GetDlgItem( m_hWndSub[eMenu_Dungeon], IDC_GMDUNGEON_EDT_DETAILINFO ), &m_strDetailInfo[0] );
}
void CGMToolManager::DungeonClearDetailInfo()
{
SetWindowText( GetDlgItem( m_hWndSub[eMenu_Dungeon], IDC_GMDUNGEON_EDT_DETAILINFO ), "" );
}
BOOL CGMToolManager::OnDungeonMornitoring_Syn(int nIndex)
{
if( !m_hWndSub[eMenu_Dungeon] ) return FALSE;
SetFocus( _g_hWnd );
char buf[256] = {0,};
int nLen = GetDlgItemText( m_hWndSub[eMenu_Dungeon], IDC_GMDUNGEON_CMB_MAPLIST, buf, MAX_MAP_NAME_LENGTH+1 );
if( nLen == 0 ) return FALSE;
buf[MAX_MAP_NAME_LENGTH] = 0;
WORD wMapNum = GetMapNumForName( buf );
if( wMapNum == 0 || wMapNum == MAP->GetMapNum()) return FALSE;
WORD wChannel = WORD(SendDlgItemMessage( m_hWndSub[eMenu_Dungeon], IDC_GMDUNGEON_LSB_DUNGEONLIST, LB_GETITEMDATA, nIndex, 0 ));
if( wChannel == 0) return FALSE;
MSG_WORD3 msg;
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_DUNGEON_OBSERVER_SYN;
msg.dwObjectID = gHeroID;
msg.wData1 = wMapNum;
msg.wData2 = wChannel;
msg.wData3 = 0;
NETWORK->Send( &msg, sizeof(msg) );
return TRUE;
}
void CGMToolManager::SetVehicle(const MSG_SKILL_LIST& message)
{
SendDlgItemMessage(
m_hWndSub[eMenu_Mob],
IDC_GMREGEN_VEHICLE_DROPDOWN,
CB_RESETCONTENT,
0,
0);
for(DWORD index = 0; message.mSize > index; ++index)
{
const SKILL_BASE& data = message.mData[index];
const VECTOR3 position = {
LOWORD(data.dwDBIdx),
0,
HIWORD(data.dwDBIdx),
};
const DWORD monsterKind = data.wSkillIdx;
const BASE_MONSTER_LIST* const baseMonsterList = GAMERESRCMNGR->GetMonsterListInfo(
monsterKind);
TCHAR text[MAX_PATH] = {0};
_stprintf(
text,
"[%05.0f, %05.0f] %s",
position.x / 100.0f,
position.z / 100.0f,
baseMonsterList ? baseMonsterList->Name : "?");
SendDlgItemMessage(
m_hWndSub[eMenu_Mob],
IDC_GMREGEN_VEHICLE_DROPDOWN,
CB_ADDSTRING,
0,
LPARAM(text));
}
SendDlgItemMessage(
m_hWndSub[eMenu_Mob],
IDC_GMREGEN_VEHICLE_DROPDOWN,
CB_SETCURSEL,
0,
0);
}
void CGMToolManager::InitNpcData()
{
m_NpcList.clear();
}
void CGMToolManager::SetNpcData( DWORD dwIndex, const char* pName, VECTOR3 pos )
{
NPCINFO NpcInfo;
ZeroMemory( &NpcInfo, sizeof(NpcInfo) );
NpcInfo.Index = dwIndex;
SafeStrCpy( NpcInfo.Name, pName, MAX_NAME_LENGTH + 1 );
NpcInfo.Pos.x = pos.x;
NpcInfo.Pos.z = pos.z;
m_NpcList.push_back( NpcInfo );
}
void CGMToolManager::SetNpcList()
{
SendDlgItemMessage( m_hWndSub[eMenu_Move], IDC_GMMOVE_CMB_NPC, CB_RESETCONTENT, 0, 0 );
for( DWORD i = 0; i < m_NpcList.size(); i++ )
{
SendDlgItemMessage( m_hWndSub[eMenu_Move], IDC_GMMOVE_CMB_NPC, CB_ADDSTRING, 0, (LPARAM)m_NpcList[i].Name );
}
SendDlgItemMessage( m_hWndSub[eMenu_Move], IDC_GMMOVE_CMB_NPC, CB_SETCURSEL, 0, 0 );
}
void CGMToolManager::ActiveMiniMap( BOOL val )
{
CBigMapDlg* pDlg = GAMEIN->GetBigMapDialog();
if( pDlg )
pDlg->SetActive( val );
}
BOOL CGMToolManager::MoveOnMiniMap( float pos_x, float pos_z )
{
if( !IsDlgButtonChecked(m_hWndDlg, IDC_GM_MNBTN_MOVE ) ) return FALSE;
if( !SendMessage( GetDlgItem( m_hWndSub[eMenu_Move], IDC_GMMOVE_CHK_MINIMAP_ON ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
return FALSE;
VECTOR3 destPos = {0};
destPos.x = pos_x * 100.0f;
destPos.y = 0.0f;
destPos.z = pos_z * 100.0f;
destPos.x = (int(destPos.x / TILECOLLISON_DETAIL) + 0.5f) * TILECOLLISON_DETAIL;
destPos.y = 0;
destPos.z = (int(destPos.z / TILECOLLISON_DETAIL) + 0.5f) * TILECOLLISON_DETAIL;
if(MAP->CollisionCheck_OneTile( &destPos ) == FALSE)
return TRUE;
if( SendMessage( GetDlgItem( m_hWndSub[eMenu_Move], IDC_GMMOVE_BTN_ME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
{
MOVE_POS msg;
ZeroMemory( &msg, sizeof(msg) );
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_MOVE_SYN;
msg.dwObjectID = gHeroID;
msg.dwMoverID = gHeroID;
msg.cpos.Compress(&destPos);
NETWORK->Send(&msg,sizeof(msg));
}
else
{
char buf[MAX_NAME_LENGTH+1] = {0,};
int nLen = GetDlgItemText( m_hWndSub[eMenu_Move], IDC_GMMOVE_EDT_USER, buf, MAX_NAME_LENGTH+1 );
if( nLen > MAX_NAME_LENGTH || nLen < 4 ) return TRUE;
if( (FILTERTABLE->IsInvalidCharInclude((unsigned char*)buf)) == TRUE )
return TRUE;
MOVE_POS_USER msg;
ZeroMemory( &msg, sizeof(msg) );
msg.Category = MP_CHEAT;
msg.Protocol = MP_CHEAT_MOVEUSER_SYN;
msg.dwObjectID = gHeroID;
SafeStrCpy( msg.Name, buf, MAX_NAME_LENGTH + 1 );
msg.cpos.Compress(&destPos);
NETWORK->Send(&msg,sizeof(msg));
}
return TRUE;
}
#endif //_GMTOOL_
|
cad862e0fe7190aff5d7b4557c994b061b8f0346 | f57572a3830720f328d0d423dc67659f9069c89f | /libraries/HT1632Basic/HT1632Basic.cpp | 25b0f8a79b98db5bba8ea49aa3e187beb6d2c63c | [] | no_license | mrrwa/core | 3cd00207446a6d4043ce75bb1c3cb584d501969c | 61ea3c1a5bd2852e8d5a7e883db43687e0c84148 | refs/heads/master | 2021-01-13T02:11:31.268112 | 2019-08-05T21:09:42 | 2019-08-05T21:09:42 | 26,453,646 | 2 | 7 | null | 2019-08-05T21:09:44 | 2014-11-10T20:13:21 | C++ | UTF-8 | C++ | false | false | 2,328 | cpp | HT1632Basic.cpp | #include "HT1632Basic.h"
#define HTstartsys 0b100000000010 //start system oscillator
#define HTstopsys 0b100000000000 //stop sytem oscillator and LED duty <default
#define HTsetclock 0b100000110000 //set clock to master with internal RC <default
#define HTsetlayout 0b100001000000 //NMOS 32*8 // 0b100-0010-ab00-0 a:0-NMOS,1-PMOS; b:0-32*8,1-24*16 default:ab=10
#define HTledon 0b100000000110 //start LEDs
#define HTledoff 0b100000000100 //stop LEDs <default
#define HTsetbright 0b100101000000 //set brightness b=0..15 add b<<1 //0b1001010xxxx0 xxxx:brightness 0..15=1/16..16/16 PWM
#define HTblinkon 0b100000010010 //Blinking on
#define HTblinkoff 0b100000010000 //Blinking off <default
#define HTwrite 0b1010000000 // 101-aaaaaaa-dddd-dddd-dddd-dddd-dddd-... aaaaaaa:nibble adress 0..3F (5F for 24*16)
void HT1632Basic::Setup(uint8_t strobePin, uint8_t clkPin, uint8_t dataPin)
{
strobe = strobePin;
pinMode(strobe, OUTPUT);
digitalWrite(strobe, HIGH);
clk = clkPin;
pinMode(clk, OUTPUT);
digitalWrite(clk, HIGH);
data = dataPin;
pinMode(data, OUTPUT);
digitalWrite(data, HIGH);
Command(HTstartsys);
Command(HTledon);
Command(HTsetclock);
Command(HTsetlayout);
Command(HTsetbright+(8<<1));
Command(HTblinkoff);
}
void HT1632Basic::SendBuffer(LEDBuffer Buffer)
{
digitalWrite(strobe, LOW);
Send(HTwrite, 10);
for (uint8_t mtx=0; mtx<4; mtx++) //sending 8x8-matrices left to right, rows top to bottom, MSB left
for (uint8_t row=0; row<8; row++) { //while leds[] is organized in columns for ease of use.
uint8_t q = 0;
for (uint8_t col=0;col<8;col++)
q = (q << 1) | ( ( Buffer[col + (mtx << 3)] >> row) & 1 ) ;
Send(q,8);
}
digitalWrite(strobe,HIGH);
}
void HT1632Basic::Send(uint16_t dataVal, uint8_t bits)
{
uint16_t bit = ((uint16_t)1)<<(bits-1);
while(bit)
{
digitalWrite(clk,LOW);
if (dataVal & bit)
digitalWrite(data,HIGH);
else
digitalWrite(data,LOW);
digitalWrite(clk,HIGH);
bit >>= 1;
}
}
void HT1632Basic::Command(uint16_t data)
{
digitalWrite(strobe,LOW);
Send(data,12);
digitalWrite(strobe,HIGH);
}
void HT1632Basic::Brightness(uint8_t level)
{
Command(HTsetbright + ( (level & 15) <<1 ) );
}
|
f2aa2094a980ad5b78dc8861482dfa15dec1f1d2 | 24cd5e12df1ec12596a6ba4cecc051c83e63453f | /gropt/Manifolds/NStQOrth/NStQOrth.cpp | ed465f8a3c20a373c5285d2c51060cc05ec58bca | [] | no_license | jdtuck/fdasrvf_MATLAB | d6fe4b980469f63e060c663c814c4be794beb2d8 | a21652b12f37db1747cc7702a17e10e13caaf347 | refs/heads/master | 2023-08-30T21:42:47.706998 | 2023-08-21T23:07:27 | 2023-08-21T23:07:27 | 46,132,779 | 10 | 6 | null | 2018-03-17T23:58:09 | 2015-11-13T16:15:59 | C++ | UTF-8 | C++ | false | false | 47,605 | cpp | NStQOrth.cpp |
#include "Manifolds/NStQOrth/NStQOrth.h"
/*Define the namespace*/
namespace ROPTLIB{
NStQOrth::NStQOrth(integer r, integer c)
{
n = r;
p = c;
IsIntrApproach = true;
HasHHR = false;
HasLockCon = false;
UpdBetaAlone = false;
name.assign("Noncompact Stiefel manifold quotient orthogonal group");
IntrinsicDim = r * c - c * (c - 1) / 2;
ExtrinsicDim = r * c;
metric = NSOHGZ;
VecTran = NSOPARALLELIZATION;
EMPTYEXTR = new NSOVector(r, c);
EMPTYINTR = new NSOVector(IntrinsicDim);
};
// Choose the default parameters
void NStQOrth::ChooseNSOParamsSet1(void)
{
metric = NSOHGZ;
VecTran = NSOPARALLELIZATION;
};
void NStQOrth::ChooseNSOParamsSet2(void)
{
metric = NSOEUC;
VecTran = NSOPARALLELIZATION;
};
void NStQOrth::ChooseNSOParamsSet3(void)
{
metric = NSOQEUC;
VecTran = NSOPARALLELIZATION;
};
void NStQOrth::ChooseNSOParamsSet4(void)
{
metric = NSOHGZ;
VecTran = NSOPROJECTION;
};
void NStQOrth::ChooseNSOParamsSet5(void)
{
metric = NSOEUC;
VecTran = NSOPROJECTION;
};
void NStQOrth::ChooseNSOParamsSet6(void)
{
metric = NSOQEUC;
VecTran = NSOPROJECTION;
};
NStQOrth::~NStQOrth(void)
{
delete EMPTYEXTR;
delete EMPTYINTR;
};
double NStQOrth::Metric(Variable *x, Vector *etax, Vector *xix) const
{
//Vector *exetax = EMPTYEXTR->ConstructEmpty();
//Vector *exxix = EMPTYEXTR->ConstructEmpty();
//ObtainExtr(x, etax, exetax);
//ObtainExtr(x, xix, exxix);
//double result = Manifold::Metric(x, exetax, exxix);
//delete exetax;
//delete exxix;
if (IsIntrApproach)
return Manifold::Metric(x, etax, xix);
printf("Warning: Metric for extrinsic representation has not been done!\n");
return 0;
};
void NStQOrth::CheckParams(void) const
{
std::string NSOMetricnames[NSOMETRICLENGTH] = { "NSOEUC", "NSOQEUC", "NSOHGZ" };
std::string NSOVTnames[NSOVECTORTRANSPORTLENGTH] = { "NSOPARALLELIZATION", "NSOPROJECTION" };
Manifold::CheckParams();
printf("%s PARAMETERS:\n", name.c_str());
if (p == 1)
{
printf("n :%15d,\t", n);
printf("metric :%15s\n", NSOMetricnames[metric].c_str());
printf("VecTran :%15s\n", NSOVTnames[VecTran].c_str());
}
else
{
printf("n :%15d,\t", n);
printf("p :%15d\n", p);
printf("metric :%15s\t", NSOMetricnames[metric].c_str());
printf("VecTran :%15s\n", NSOVTnames[VecTran].c_str());
}
};
void NStQOrth::EucGradToGrad(Variable *x, Vector *egf, Vector *gf, const Problem *prob) const
{
if (metric == NSOEUC)
EucGradToGradEUC(x, egf, gf, prob);
else
if (metric == NSOHGZ)
EucGradToGradHGZ(x, egf, gf, prob);
else
if (metric == NSOQEUC)
EucGradToGradQEUC(x, egf, gf, prob);
else
printf("warning: NStQOrth::EucGradToGrad has not been done for this metric!\n");
};
void NStQOrth::EucHvToHv(Variable *x, Vector *etax, Vector *exix, Vector* xix, const Problem *prob) const
{
if (metric == NSOEUC)
EucHvToHvEUC(x, etax, exix, xix, prob);
else
if (metric == NSOHGZ)
EucHvToHvHGZ(x, etax, exix, xix, prob);
else
if (metric == NSOQEUC)
EucHvToHvQEUC(x, etax, exix, xix, prob);
else
printf("warning: NStQOrth::EucHvToHv has not been done for this metric!\n");
};
void NStQOrth::Projection(Variable *x, Vector *v, Vector *result) const
{
if (IsIntrApproach)
IntrProjection(x, v, result);
else
ExtrProjection(x, v, result);
};
void NStQOrth::Retraction(Variable *x, Vector *etax, Variable *result, double stepsize) const
{
if (IsIntrApproach)
{
Vector *exetax = EMPTYEXTR->ConstructEmpty();
ObtainExtr(x, etax, exetax);
Manifold::Retraction(x, exetax, result, 1);
delete exetax;
}
else
{
Manifold::Retraction(x, etax, result, 1);
}
};
void NStQOrth::coTangentVector(Variable *x, Vector *etax, Variable *y, Vector *xiy, Vector *result) const
{
printf("warning:NStQOrth::coTangentVector has not been done!\n");
xiy->CopyTo(result);
};
void NStQOrth::DiffRetraction(Variable *x, Vector *etax, Variable *y, Vector *xix, Vector *result, bool IsEtaXiSameDir) const
{
if (IsIntrApproach)
{
Vector *exxix = EMPTYEXTR->ConstructEmpty();
Vector *exresult = EMPTYEXTR->ConstructEmpty();
ObtainExtr(x, xix, exxix);
ExtrProjection(y, exxix, exresult);
ObtainIntr(y, exresult, result);
delete exxix;
delete exresult;
}
else
{
ExtrProjection(y, xix, result);
}
};
double NStQOrth::Beta(Variable *x, Vector *etax) const
{
return 1;
};
void NStQOrth::ComputeHHR(Variable *x)
{
const double *xM = x->ObtainReadData();
SharedSpace *HouseHolderResult = new SharedSpace(2, x->Getsize()[0], x->Getsize()[1]);
double *ptrHHR = HouseHolderResult->ObtainWriteEntireData();
SharedSpace *HHRTau = new SharedSpace(1, x->Getsize()[1]);
double *tau = HHRTau->ObtainWriteEntireData();
integer N = x->Getsize()[0], P = x->Getsize()[1], inc = 1;
// ptrHHR <- xM, details: http://www.netlib.org/lapack/explore-html/da/d6c/dcopy_8f.html
integer Length = N * P;
dcopy_(&Length, const_cast<double *> (xM), &inc, ptrHHR, &inc);
integer *jpvt = new integer[P];
integer info;
integer lwork = -1;
double lworkopt;
// compute the size of space required in the dgeqp3
#ifndef MATLAB_MEX_FILE
dgeqp3_(&N, &P, ptrHHR, &N, jpvt, tau, &lworkopt, &lwork, &info);
#else
dgeqp3_(&N, &P, ptrHHR, &N, jpvt, tau, &lworkopt, &lwork, &info);
#endif
lwork = static_cast<integer> (lworkopt);
double *work = new double[lwork];
for (integer i = 0; i < P; i++)
jpvt[i] = i + 1;
// QR decomposition for ptrHHR using Householder reflections. Householder reflectors and R are stored in ptrHHR.
// details: http://www.netlib.org/lapack/explore-html/db/de5/dgeqp3_8f.html
#ifndef MATLAB_MEX_FILE
dgeqp3_(&N, &P, ptrHHR, &N, jpvt, tau, work, &lwork, &info);
#else
dgeqp3_(&N, &P, ptrHHR, &N, jpvt, tau, work, &lwork, &info);
#endif
x->AddToTempData("HHR", HouseHolderResult);
x->AddToTempData("HHRTau", HHRTau);
if (info < 0)
printf("Error in qr decomposition in NStQOrth::ComputeHHR!\n");
for (integer i = 0; i < P; i++)
{
if (jpvt[i] != (i + 1))
printf("Error in qf retraction in NStQOrth::ComputeHHR!\n");
}
delete[] jpvt;
delete[] work;
};
void NStQOrth::ObtainIntr(Variable *x, Vector *etax, Vector *result) const
{
if (metric == NSOEUC)
ObtainIntrEUC(x, etax, result);
else
if (metric == NSOHGZ)
ObtainIntrHGZ(x, etax, result);
else
if (metric == NSOQEUC)
ObtainIntrQEUC(x, etax, result);
else
printf("warning: NStQOrth::ObtainIntr has not been done for this metric!\n");
};
void NStQOrth::ObtainExtr(Variable *x, Vector *intretax, Vector *result) const
{
if (metric == NSOEUC)
ObtainExtrEUC(x, intretax, result);
else
if (metric == NSOHGZ)
ObtainExtrHGZ(x, intretax, result);
else
if (metric == NSOQEUC)
ObtainExtrQEUC(x, intretax, result);
else
printf("warning: NStQOrth::ObtainExtr has not been done for this metric!\n");
};
void NStQOrth::IntrProjection(Variable *x, Vector *v, Vector *result) const
{
v->CopyTo(result);
};
void NStQOrth::ExtrProjection(Variable *x, Vector *v, Vector *result) const
{
if (metric == NSOEUC || metric == NSOHGZ)
ExtrProjectionEUCorHGZ(x, v, result);
else
if (metric == NSOQEUC)
ExtrProjectionQEUC(x, v, result);
else
printf("Warning: NStQOrth::ExtrProjection has not been done for this Riemannian metric!\n");
};
void NStQOrth::ExtrProjectionQEUC(Variable *x, Vector *v, Vector *result) const
{
const double *xM = x->ObtainReadData();
const double *vptr = v->ObtainReadData();
double *XTX = new double[p * p * 2];
double *XTV = XTX + p * p;
// XTX <- XM^T XM
Matrix MxM(xM, n, p), MXTX(XTX, p, p), MV(vptr, n, p), MXTV(XTV, p, p);
Matrix::DGEMM(GLOBAL::DONE, MxM, true, MxM, false, GLOBAL::DZERO, MXTX);
// XTV <- XM^T V
Matrix::DGEMM(GLOBAL::DONE, MxM, true, MV, false, GLOBAL::DZERO, MXTV);
// XTV <- XTV - XTV^T
for (integer i = 0; i < p; i++)
{
for (integer j = i; j < p; j++)
{
XTV[i + j * p] -= XTV[j + i * p];
XTV[j + i * p] = -XTV[i + j * p];
}
}
v->CopyTo(result);
double *resultTV = result->ObtainWritePartialData();
Matrix Mresult(resultTV, n, p);
Matrix::DSYL(MXTX, MXTX, MXTV);
Matrix::DGEMM(GLOBAL::DNONE, MxM, false, MXTV, false,
GLOBAL::DONE, Mresult);
delete[] XTX;
};
void NStQOrth::ExtrProjectionEUCorHGZ(Variable *x, Vector *v, Vector *result) const
{
const double *xM = x->ObtainReadData();
const double *V = v->ObtainReadData();
double *XTX = new double[2 * p * p];
double *XTV = XTX + p * p;
Matrix MxM(xM, n, p), MXTX(XTX, p, p), MV(V, n, p), MXTV(XTV, p, p);
// XHX <- XM^T XM
Matrix::DGEMM(GLOBAL::DONE, MxM, true, MxM, false, GLOBAL::DZERO, MXTX);
// XHV <- XM^H V
Matrix::DGEMM(GLOBAL::DONE, MxM, true, MV, false, GLOBAL::DZERO, MXTV);
integer N = n, P = p, info;
#ifndef MATLAB_MEX_FILE
// solve for (XTX)^{-1} XTV
dpotrf_(GLOBAL::L, &P, XTX, &P, &info);
dpotrs_(GLOBAL::L, &P, &P, XTX, &P, XTV, &P, &info);
#else
// solve for (XTX)^{-1} XTV
dpotrf_(GLOBAL::L, &P, (double *)XTX, &P, &info);
dpotrs_(GLOBAL::L, &P, &P, (double *)XTX, &P, (double *)XTV, &P, &info);
#endif
if (info != 0)
{
printf("warning: dpotrs failed in NStQOrth::ExtrProjection with info:%d!\n", info);
}
// XTV <- (XTV - XTV^T)/2
for (integer i = 0; i < p; i++)
{
for (integer j = i; j < p; j++)
{
XTV[i + j * p] -= XTV[j + i * p];
XTV[j + i * p] = -XTV[i + j * p];
}
}
for (integer i = 0; i < p * p; i++)
{
XTV[i] /= 2;
}
v->CopyTo(result);
double *resultTV = result->ObtainWritePartialData();
Matrix MresultTV(resultTV, n, p);
Matrix::DGEMM(GLOBAL::DNONE, MxM, false, MXTV, false, GLOBAL::DONE, MresultTV);
delete[] XTX;
};
void NStQOrth::EucGradToGradEUC(Variable *x, Vector *egf, Vector *gf, const Problem *prob) const
{
if (prob->GetUseHess())
{
Vector *segf = egf->ConstructEmpty();
segf->NewMemoryOnWrite(); // I don't remember the reason. It seems to be required.
egf->CopyTo(segf);
SharedSpace *Sharedegf = new SharedSpace(segf);
x->AddToTempData("EGrad", Sharedegf);
}
egf->CopyTo(gf);
double *gfv = gf->ObtainWriteEntireData();
//Y / (x'*x) use compute HHR in NstQorth
if (!x->TempDataExist("HHR"))
ComputeHHR(x);
const SharedSpace *HHR = x->ObtainReadTempData("HHR");
const double *ptrHHR = HHR->ObtainReadData();
double *YT = new double[n * p];
/*YT = Y^T*/
for (integer i = 0; i < n; i++)
{
for (integer j = 0; j < p; j++)
{
YT[j + i * p] = gfv[i + j * n];
}
}
integer info, N = n, P = p;
#ifndef MATLAB_MEX_FILE
dtrtrs_(GLOBAL::U, GLOBAL::T, GLOBAL::N, &P, &N, const_cast<double *> (ptrHHR), &N, YT, &P, &info);
dtrtrs_(GLOBAL::U, GLOBAL::N, GLOBAL::N, &P, &N, const_cast<double *> (ptrHHR), &N, YT, &P, &info);
#else
dtrtrs_(GLOBAL::U, GLOBAL::T, GLOBAL::N, &P, &N, const_cast<double *> (ptrHHR), &N, YT, &P, &info);
dtrtrs_(GLOBAL::U, GLOBAL::N, GLOBAL::N, &P, &N, const_cast<double *> (ptrHHR), &N, YT, &P, &info);
#endif
/*YT = Y^T*/
for (integer i = 0; i < n; i++)
{
for (integer j = 0; j < p; j++)
{
gfv[i + j * n] = YT[j + i * p];
}
}
delete[] YT;
double half = 0.5;
integer length = n * p;
dscal_(&length, &half, gfv, &GLOBAL::IONE);
double *tempspace = new double[p * p];
const double *Y = x->ObtainReadData();
/*tempspace2 = Y^T * gfv */
dgemm_(GLOBAL::T, GLOBAL::N, &P, &P, &N, &GLOBAL::DONE, const_cast<double *> (Y), &N, gfv, &N, &GLOBAL::DZERO, tempspace, &P);
/*compute (Y^T Y)^{-1} tempspace2. It is also R^{-1} R^{-T} tempspace2 */
dtrtrs_(GLOBAL::U, GLOBAL::T, GLOBAL::N, &P, &P, const_cast<double *> (ptrHHR), &N, tempspace, &P, &info);
dtrtrs_(GLOBAL::U, GLOBAL::N, GLOBAL::N, &P, &P, const_cast<double *> (ptrHHR), &N, tempspace, &P, &info);
double nhalf = -0.5;
/*final result: gfv = (I - 1/2 * Y * (Y^T Y)^{-1}Y^T) gfv */
dgemm_(GLOBAL::N, GLOBAL::N, &N, &P, &P, &nhalf, const_cast<double *> (Y), &N, tempspace, &P, &GLOBAL::DONE, gfv, &N);
delete[] tempspace;
//ExtrProjection(x, gf, gf); Not necessary since gf is already in the horizontal space.
};
void NStQOrth::EucHvToHvEUC(Variable *x, Vector *etax, Vector *exix, Vector* xix, const Problem *prob) const
{
const double *Y = x->ObtainReadData();
const double *etaxTV = etax->ObtainReadData();
const SharedSpace *Sharedegf = x->ObtainReadTempData("EGrad");
Vector *egfx = Sharedegf->GetSharedElement();
const double *egfTV = egfx->ObtainReadData();
if (!x->TempDataExist("HHR"))
ComputeHHR(x);
const SharedSpace *HHR = x->ObtainReadTempData("HHR");
const double *ptrHHR = HHR->ObtainReadData();
double *tmp = new double[n * p * 2 + p * p * 4];
double *YYinvYTEH = tmp + n * p;
double *EGYYinv = YYinvYTEH + p * p;
double *YTeta = EGYYinv + n * p;
double *EtaTEGYYinv = YTeta + p * p;
double *YYinvYTEGYYinv = EtaTEGYYinv + p * p;
/*tmp = Egrad^T*/
for (integer i = 0; i < n; i++)
{
for (integer j = 0; j < p; j++)
{
tmp[j + i * p] = egfTV[i + j * n];
}
}
integer info, N = n, P = p;
dtrtrs_(GLOBAL::U, GLOBAL::T, GLOBAL::N, &P, &N, const_cast<double *> (ptrHHR), &N, tmp, &P, &info);
dtrtrs_(GLOBAL::U, GLOBAL::N, GLOBAL::N, &P, &N, const_cast<double *> (ptrHHR), &N, tmp, &P, &info);
/*EGYYinv = Egrad * (Y^T * Y)^{-1}*/
for (integer i = 0; i < n; i++)
{
for (integer j = 0; j < p; j++)
{
EGYYinv[i + j * n] = tmp[j + i * p];
}
}
/*YYinvYTEH = (Y^T * Y)^{-1} * Y^T * EHess */
const double *exixTV = exix->ObtainReadData();
dgemm_(GLOBAL::T, GLOBAL::N, &P, &P, &N, &GLOBAL::DONE, const_cast<double *> (Y), &N, const_cast<double *> (exixTV), &N, &GLOBAL::DZERO, YYinvYTEH, &P);
dtrtrs_(GLOBAL::U, GLOBAL::T, GLOBAL::N, &P, &P, const_cast<double *> (ptrHHR), &N, YYinvYTEH, &P, &info);
dtrtrs_(GLOBAL::U, GLOBAL::N, GLOBAL::N, &P, &P, const_cast<double *> (ptrHHR), &N, YYinvYTEH, &P, &info);
/*YYinvYTEGYYinv = (Y^T * Y)^{-1} * Y^T * Egrad * (Y^T * Y)^{-1}*/
dgemm_(GLOBAL::T, GLOBAL::N, &P, &P, &N, &GLOBAL::DONE, const_cast<double *> (Y), &N, EGYYinv, &N, &GLOBAL::DZERO, YYinvYTEGYYinv, &P);
dtrtrs_(GLOBAL::U, GLOBAL::T, GLOBAL::N, &P, &P, const_cast<double *> (ptrHHR), &N, YYinvYTEGYYinv, &P, &info);
dtrtrs_(GLOBAL::U, GLOBAL::N, GLOBAL::N, &P, &P, const_cast<double *> (ptrHHR), &N, YYinvYTEGYYinv, &P, &info);
/*EtaTEGYYinv = eta^T * Egrad * (Y^T * Y)^{-1}*/
dgemm_(GLOBAL::T, GLOBAL::N, &P, &P, &N, &GLOBAL::DONE, const_cast<double *> (etaxTV), &N, EGYYinv, &N, &GLOBAL::DZERO, EtaTEGYYinv, &P);
/*YTeta = Y^T * eta */
dgemm_(GLOBAL::T, GLOBAL::N, &P, &P, &N, &GLOBAL::DONE, const_cast<double *> (Y), &N, const_cast<double *> (etaxTV), &N, &GLOBAL::DZERO, YTeta, &P);
exix->CopyTo(xix);
double *xixTV = xix->ObtainWritePartialData();
double half = 0.5, nhalf = -0.5;
/*xix = EucHess - 0.5 * Y * (Y^T * Y)^{-1} * Y^T * EucHess */
dgemm_(GLOBAL::N, GLOBAL::N, &N, &P, &P, &nhalf, const_cast<double *> (Y), &N, YYinvYTEH, &P, &GLOBAL::DONE, xixTV, &N);
/*xix = EucHess - 0.5 * Y * (Y^T * Y)^{-1} * Y^T * EucHess - 0.5 * Y * (Y^T * Y)^{-1} * Egrad^T * eta */
dgemm_(GLOBAL::N, GLOBAL::T, &N, &P, &P, &nhalf, const_cast<double *>(Y), &N, EtaTEGYYinv, &P, &GLOBAL::DONE, xixTV, &N);
/*xix = EucHess - 0.5 * Y * (Y^T * Y)^{-1} * Y^T * EucHess - 0.5 * Y * (Y^T * Y)^{-1} * Egrad^T * eta - Egrad * (Y^T * Y)^{-1} * Y * eta */
dgemm_(GLOBAL::N, GLOBAL::N, &N, &P, &P, &GLOBAL::DNONE, const_cast<double *>(EGYYinv), &N, YTeta, &P, &GLOBAL::DONE, xixTV, &N);
/*xix = EucHess - 0.5 * Y * (Y^T * Y)^{-1} * Y^T * EucHess - 0.5 * Y * (Y^T * Y)^{-1} * Egrad^T * eta - Egrad * (Y^T * Y)^{-1} * Y * eta
+ Y * (Y^T * Y)^{-1} * Y^T * Egrad * (Y^T * Y)^{-1} * Y^T * eta */
dgemm_(GLOBAL::N, GLOBAL::N, &P, &P, &P, &GLOBAL::DONE, YYinvYTEGYYinv, &P, YTeta, &P, &GLOBAL::DZERO, tmp, &P);
dgemm_(GLOBAL::N, GLOBAL::N, &N, &P, &P, &GLOBAL::DONE, const_cast<double *>(Y), &N, tmp, &P, &GLOBAL::DONE, xixTV, &N);
integer length = n * p;
dscal_(&length, &half, xixTV, &GLOBAL::IONE);
/*tmp = xix^T*/
for (integer i = 0; i < n; i++)
{
for (integer j = 0; j < p; j++)
{
tmp[j + i * p] = xixTV[i + j * n];
}
}
dtrtrs_(GLOBAL::U, GLOBAL::T, GLOBAL::N, &P, &N, const_cast<double *> (ptrHHR), &N, tmp, &P, &info);
dtrtrs_(GLOBAL::U, GLOBAL::N, GLOBAL::N, &P, &N, const_cast<double *> (ptrHHR), &N, tmp, &P, &info);
/*xix = xix * (Y^T * Y)^{-1}*/
for (integer i = 0; i < n; i++)
{
for (integer j = 0; j < p; j++)
{
xixTV[i + j * n] = tmp[j + i * p];
}
}
delete[] tmp;
ExtrProjection(x, xix, xix);
};
void NStQOrth::ObtainIntrEUC(Variable *x, Vector *etax, Vector *result) const
{
if (!x->TempDataExist("HHR"))
{
ComputeHHR(x);
}
const double *xM = x->ObtainReadData();
const double *etaxTV = etax->ObtainReadData();
const SharedSpace *HHR = x->ObtainReadTempData("HHR");
const SharedSpace *HHRTau = x->ObtainReadTempData("HHRTau");
double *resultTV = result->ObtainWriteEntireData();
const double *ptrHHR = HHR->ObtainReadData();
const double *ptrHHRTau = HHRTau->ObtainReadData();
integer N = x->Getsize()[0], P = x->Getsize()[1], inc = 1, Length = N * P;
integer info;
integer lwork = -1;
double lworkopt;
double *tempspace = new double[n * p];
// compute the size of space required in the dormqr
#ifndef MATLAB_MEX_FILE
dormqr_(GLOBAL::L, GLOBAL::T, &N, &P, &P, (const_cast<double *> (ptrHHR)), &N,
(const_cast<double *> (ptrHHRTau)), tempspace, &N, &lworkopt, &lwork, &info);
#else
dormqr_(GLOBAL::L, GLOBAL::T, &N, &P, &P, (const_cast<double *> (ptrHHR)), &N,
(const_cast<double *> (ptrHHRTau)), tempspace, &N, &lworkopt, &lwork, &info);
#endif
lwork = static_cast<integer> (lworkopt);
double *work = new double[lwork];
// tempspace <- etaxTV, details: http://www.netlib.org/lapack/explore-html/da/d6c/dcopy_8f.html
dcopy_(&Length, const_cast<double *> (etaxTV), &inc, tempspace, &inc);
// tempspace <- Q^T * tempspace, where Q is the orthogonal matrix defined as the product elementary reflectors defined by ptrHHR and ptrHHRTau,
// details: http://www.netlib.org/lapack/explore-html/da/d82/dormqr_8f.html
#ifndef MATLAB_MEX_FILE
dormqr_(GLOBAL::L, GLOBAL::T, &N, &P, &P, (const_cast<double *> (ptrHHR)), &N,
(const_cast<double *> (ptrHHRTau)), tempspace, &N, work, &lwork, &info);
#else
dormqr_(GLOBAL::L, GLOBAL::T, &N, &P, &P, (const_cast<double *> (ptrHHR)), &N,
(const_cast<double *> (ptrHHRTau)), tempspace, &N, work, &lwork, &info);
#endif
double sign = 0;
for (integer i = 0; i < p; i++)
{
sign = (ptrHHR[i + n * i] >= 0) ? 1 : -1;
#ifndef MATLAB_MEX_FILE
dscal_(&P, &sign, tempspace + i, &N);
#else
dscal_(&P, &sign, tempspace + i, &N);
#endif
}
double *L = new double[p * p];
for (integer i = 0; i < p; i++)
{
for (integer j = 0; j < i; j++)
{
L[j + i * p] = 0;
}
sign = (ptrHHR[i + n * i] >= 0) ? 1 : -1;
for (integer j = i; j < p; j++)
{
L[j + i * p] = ptrHHR[i + n * j] * sign;
}
}
double *tempspaceL = new double[n * p];
Matrix MtL(tempspaceL, n, p), ML(L, p, p), Mtempspace(tempspace, n, p);
Matrix::DGEMM(GLOBAL::DONE, Mtempspace, false, ML, false, GLOBAL::DZERO, MtL);
delete[] L;
delete[] tempspace;
/*Matrix MxM(xM, n, p), MetaxTV(etaxTV, n, p), Mtempspace((double *)tempspace, p, p, n);
Matrix::CGEMM(GLOBAL::ZONE, MxM, true, MetaxTV, false, GLOBAL::ZZERO, Mtempspace);*/
double r2 = sqrt(2.0);
double factor = 1;//-- sqrt(Manifold::Metric(x, x, x));
integer idx = 0;
for (integer i = 0; i < p; i++)
{
resultTV[idx] = 2 * tempspaceL[i + i * n] / factor;
idx++;
}
for (integer i = 0; i < p; i++)
{
for (integer j = i + 1; j < p; j++)
{
resultTV[idx] = 2 * r2 * tempspaceL[j + i * n] / factor;
idx++;
}
}
for (integer i = 0; i < p; i++)
{
for (integer j = p; j < n; j++)
{
resultTV[idx] = r2 * tempspaceL[j + i * n];
idx++;
}
}
delete[] work;
delete[] tempspaceL;
};
void NStQOrth::ObtainExtrEUC(Variable *x, Vector *intretax, Vector *result) const
{
if (!x->TempDataExist("HHR"))
{
ComputeHHR(x);
}
const double *xM = x->ObtainReadData();
const SharedSpace *HHR = x->ObtainReadTempData("HHR");
const SharedSpace *HHRTau = x->ObtainReadTempData("HHRTau");
const double *ptrHHR = HHR->ObtainReadData();
const double *ptrHHRTau = HHRTau->ObtainReadData();
const double *intretaxTV = intretax->ObtainReadData();
double *resultTV = result->ObtainWriteEntireData();
integer N = x->Getsize()[0], P = x->Getsize()[1], inc = 1, Length = N * P;
integer info;
integer idx = 0;
// doublecomplex *S = new doublecomplex[p * p];
double r2 = sqrt(2.0);
double factor = 1;//-- sqrt(Manifold::Metric(x, x, x));
for (integer i = 0; i < p; i++)
{
resultTV[i + i * n] = intretaxTV[idx] * factor / 2;
idx++;
}
for (integer i = 0; i < p; i++)
{
for (integer j = i + 1; j < p; j++)
{
resultTV[j + i * n] = intretaxTV[idx] / r2 / 2 * factor;
resultTV[i + j * n] = intretaxTV[idx] / r2 / 2 * factor;
idx++;
}
}
for (integer i = 0; i < p; i++)
{
for (integer j = p; j < n; j++)
{
resultTV[j + i * n] = intretaxTV[idx] / r2;
idx++;
}
}
double sign = 0;
for (integer i = 0; i < p; i++)
{
sign = (ptrHHR[i + n * i] >= 0) ? 1 : -1;
// result(i, :) <- sign * result(i, :), details: http://www.netlib.org/lapack/explore-html/d4/dd0/dscal_8f.html
#ifndef MATLAB_MEX_FILE
dscal_(&P, &sign, resultTV + i, &N);
#else
dscal_(&P, &sign, resultTV + i, &N);
#endif
}
integer lwork = -1;
double lworkopt;
// compute the size of space required in the dormqr
#ifndef MATLAB_MEX_FILE
dormqr_(GLOBAL::L, GLOBAL::N, &N, &P, &P, (const_cast<double *> (ptrHHR)), &N,
(const_cast<double *> (ptrHHRTau)), resultTV, &N, &lworkopt, &lwork, &info);
#else
dormqr_(GLOBAL::L, GLOBAL::N, &N, &P, &P, (const_cast<double *> (ptrHHR)), &N,
(const_cast<double *> (ptrHHRTau)), resultTV, &N, &lworkopt, &lwork, &info);
#endif
lwork = static_cast<integer> (lworkopt);
double *work = new double[lwork];
// resultTV <- Q * resultTV, where Q is the orthogonal matrix defined as the product elementary reflectors defined by ptrHHR and ptrHHRTau,
// details: http://www.netlib.org/lapack/explore-html/da/d82/dormqr_8f.html
#ifndef MATLAB_MEX_FILE
dormqr_(GLOBAL::L, GLOBAL::N, &N, &P, &P, (const_cast<double *> (ptrHHR)), &N,
(const_cast<double *> (ptrHHRTau)), resultTV, &N, work, &lwork, &info);
#else
dormqr_(GLOBAL::L, GLOBAL::N, &N, &P, &P, (const_cast<double *> (ptrHHR)), &N,
(const_cast<double *> (ptrHHRTau)), resultTV, &N, work, &lwork, &info);
#endif
delete[] work;
double *L = new double[p * p + n * p];
double *r_T = L + p * p;
for (integer i = 0; i < p; i++)
{
for (integer j = 0; j < i; j++)
{
L[j + i * p] = 0;
}
sign = (ptrHHR[i + n * i] >= 0) ? 1 : -1;
for (integer j = i; j < p; j++)
{
L[j + i * p] = ptrHHR[i + n * j] * sign;
}
}
/*r_T <- resultTV transpose*/
for (integer i = 0; i < n; i++)
{
for (integer j = 0; j < p; j++)
{
r_T[j + i * p] = resultTV[i + j * n];
}
}
#ifndef MATLAB_MEX_FILE
/*solve linear system L^H M = r_T, the solution M is stored in r_T*/
dtrtrs_(GLOBAL::L, GLOBAL::C, GLOBAL::N, &P, &N, L, &P, r_T, &P, &info);
#else
dtrtrs_(GLOBAL::L, GLOBAL::C, GLOBAL::N, &P, &N, L, &P, r_T, &P, &info);
#endif
/*resultTV <- r_T transpose*/
for (integer i = 0; i < n; i++)
{
for (integer j = 0; j < p; j++)
{
resultTV[i + j * n] = r_T[j + i * p];
}
}
delete[] L;
};
void NStQOrth::EucGradToGradQEUC(Variable *x, Vector *egf, Vector *gf, const Problem *prob) const
{
if (prob->GetUseHess())
{
Vector *segf = egf->ConstructEmpty();
segf->NewMemoryOnWrite(); // I don't remember the reason. It seems to be required.
egf->CopyTo(segf);
SharedSpace *Sharedegf = new SharedSpace(segf);
x->AddToTempData("EGrad", Sharedegf);
}
ExtrProjection(x, egf, gf);
};
void NStQOrth::EucHvToHvQEUC(Variable *x, Vector *etax, Vector *exix, Vector* xix, const Problem *prob) const
{
ExtrProjection(x, exix, xix);
};
void NStQOrth::ObtainIntrQEUC(Variable *x, Vector *etax, Vector *result) const
{
if (!x->TempDataExist("HHR"))
{
ComputeHHR(x);
}
const double *xM = x->ObtainReadData();
const double *etaxTV = etax->ObtainReadData();
const SharedSpace *HHR = x->ObtainReadTempData("HHR");
const SharedSpace *HHRTau = x->ObtainReadTempData("HHRTau");
double *resultTV = result->ObtainWriteEntireData();
const double *ptrHHR = HHR->ObtainReadData();
const double *ptrHHRTau = HHRTau->ObtainReadData();
integer N = x->Getsize()[0], P = x->Getsize()[1], inc = 1, Length = N * P;
integer info;
integer lwork = -1;
double lworkopt;
double *tempspace = new double[n * p];
// compute the size of space required in the dormqr
dormqr_(GLOBAL::L, GLOBAL::T, &N, &P, &P, (const_cast<double *> (ptrHHR)), &N,
(const_cast<double *> (ptrHHRTau)), tempspace, &N, &lworkopt, &lwork, &info);
lwork = static_cast<integer> (lworkopt);
double *work = new double[lwork];
// tempspace <- etaxTV, details: http://www.netlib.org/lapack/explore-html/da/d6c/dcopy_8f.html
dcopy_(&Length, const_cast<double *> (etaxTV), &inc, tempspace, &inc);
// tempspace <- Q^T * tempspace, where Q is the orthogonal matrix defined as the product elementary reflectors defined by ptrHHR and ptrHHRTau,
// details: http://www.netlib.org/lapack/explore-html/da/d82/dormqr_8f.html
dormqr_(GLOBAL::L, GLOBAL::T, &N, &P, &P, (const_cast<double *> (ptrHHR)), &N,
(const_cast<double *> (ptrHHRTau)), tempspace, &N, work, &lwork, &info);
delete[] work;
double sign = 0;
for (integer i = 0; i < p; i++)
{
sign = (ptrHHR[i + n * i] >= 0) ? 1 : -1;
dscal_(&P, &sign, tempspace + i, &N);
}
double *L = new double[p * p];
for (integer i = 0; i < p; i++)
{
for (integer j = 0; j < i; j++)
{
L[j + i * p] = 0;
}
sign = (ptrHHR[i + n * i] >= 0) ? 1 : -1;
for (integer j = i; j < p; j++)
{
L[j + i * p] = ptrHHR[i + n * j] * sign;
}
}
/* Ltempspace = L* tempspace(1:p, 1:p) */
double *Ltempspace = new double[p * p];
dgemm_(GLOBAL::N, GLOBAL::N, &P, &P, &P, &GLOBAL::DONE, L, &P, tempspace, &N, &GLOBAL::DZERO, Ltempspace, &P);
for (integer i = 0; i < P; i++)
{
for (integer j = 0; j < P; j++)
tempspace[j + i * n] = Ltempspace[j + i * p];
}
delete[] Ltempspace;
double *resultptr = result->ObtainWriteEntireData();
integer idx = 0;
for (integer i = 0; i < p; i++)
{
for (integer j = i; j < p; j++)
{
resultptr[idx] = tempspace[j + i * n];
idx++;
}
}
for (integer i = 0; i < p; i++)
{
for (integer j = p; j < n; j++)
{
resultptr[idx] = tempspace[j + i * n];
idx++;
}
}
delete[] tempspace;
/* Above: result is then R^{-T} S + K. Next, we first find the coefficients of the etax under a non-orthonormal basis.
Then orthonormalize the basis and update the coefficient. To the end, we find the non-orthogonal basis and store it in B.
Then use qr decomposition to find the matrix R. Then use the matrix R to find the coefficient vector under the orthonormalized
basis. total complexity is O(p^6) + O(n p)*/
/* cholesky decomposition */
double *B = new double[p * p * p * (p + 1) / 2];
idx = 0;
for (integer i = 0; i < p * p * p * (p + 1) / 2; i++)
B[i] = 0;
for (integer i = 0; i < p; i++)
{
for (integer j = i; j < p; j++)
{
B[j + i * p + idx * p * p] = 1;
B[i + j * p + idx * p * p] = 1;
dtrtrs_(GLOBAL::L, GLOBAL::N, GLOBAL::N, &P, &P, L, &P, B + idx * p * p, &P, &info);
idx++;
}
}
delete[] L;
integer *jpvt = new integer[p * (p + 1) / 2];
double *tau = new double[p * (p + 1) / 2];
lwork = -1;
integer dim = p * (p + 1) / 2;
integer Psquare = p * p;
lworkopt;
// compute the size of space required in the dgeqp3
dgeqp3_(&Psquare, &dim, B, &Psquare, jpvt, tau, &lworkopt, &lwork, &info);
lwork = static_cast<integer> (lworkopt);
work = new double[lwork];
for (integer i = 0; i < p * (p + 1) / 2; i++)
jpvt[i] = i + 1;
// QR decomposition for ptrHHR using Householder reflections. Householder reflectors and R are stored in ptrHHR.
// details: http://www.netlib.org/lapack/explore-html/db/de5/dgeqp3_8f.html
dgeqp3_(&Psquare, &dim, B, &Psquare, jpvt, tau, work, &lwork, &info);
delete tau;
delete[] work;
delete[]jpvt;
SharedSpace *SharedBL = new SharedSpace(2, dim, dim);
double *BL = SharedBL->ObtainWriteEntireData();
for (integer i = 0; i < dim; i++)
{
for (integer j = 0; j < i; j++)
{
BL[j + i * dim] = 0;
}
sign = (B[i + p * p * i] >= 0) ? 1 : -1;
for (integer j = i; j < dim; j++)
{
BL[j + i * dim] = B[i + p * p * j] * sign;
}
}
delete[] B;
tempspace = new double[dim];
dgemm_(GLOBAL::T, GLOBAL::N, &dim, &GLOBAL::IONE, &dim, &GLOBAL::DONE, BL, &dim, resultptr, &dim, &GLOBAL::DZERO, tempspace, &dim);
dcopy_(&dim, tempspace, &GLOBAL::IONE, resultptr, &GLOBAL::IONE);
delete[] tempspace;
x->AddToTempData("BL", SharedBL);
};
void NStQOrth::ObtainExtrQEUC(Variable *x, Vector *intretax, Vector *result) const
{
if (!x->TempDataExist("HHR"))
{
ComputeHHR(x);
}
const double *xM = x->ObtainReadData();
const SharedSpace *HHR = x->ObtainReadTempData("HHR");
const SharedSpace *HHRTau = x->ObtainReadTempData("HHRTau");
const SharedSpace *BL = x->ObtainReadTempData("BL");
const double *ptrHHR = HHR->ObtainReadData();
const double *ptrHHRTau = HHRTau->ObtainReadData();
const double *ptrBL = BL->ObtainReadData();
const double *intretaxTV = intretax->ObtainReadData();
double *resultTV = result->ObtainWriteEntireData();
integer dim = p * (p + 1) / 2, info;
double *tempspace = new double[dim];
dcopy_(&dim, const_cast<double *> (intretaxTV), &GLOBAL::IONE, tempspace, &GLOBAL::IONE);
dtrtrs_(GLOBAL::L, GLOBAL::T, GLOBAL::N, &dim, &GLOBAL::IONE, const_cast<double *>(ptrBL), &dim, tempspace, &dim, &info);
integer N = n, P = p, Length = N * P;
integer idx = 0;
for (integer i = 0; i < p; i++)
{
for (integer j = i; j < p; j++)
{
resultTV[j + i * n] = tempspace[idx];
resultTV[i + j * n] = resultTV[j + i * n];
idx++;
}
}
for (integer i = 0; i < p; i++)
{
for (integer j = p; j < n; j++)
{
resultTV[j + i * n] = intretaxTV[idx];
idx++;
}
}
delete[] tempspace;
double *L = new double[p * p];
double sign = 0;
for (integer i = 0; i < p; i++)
{
for (integer j = 0; j < i; j++)
{
L[j + i * p] = 0;
}
sign = (ptrHHR[i + n * i] >= 0) ? 1 : -1;
for (integer j = i; j < p; j++)
{
L[j + i * p] = ptrHHR[i + n * j] * sign;
}
}
dtrtrs_(GLOBAL::L, GLOBAL::N, GLOBAL::N, &P, &P, L, &P, resultTV, &N, &info);
delete[] L;
/*=========*/
sign = 0;
for (integer i = 0; i < p; i++)
{
sign = (ptrHHR[i + n * i] >= 0) ? 1 : -1;
// result(i, :) <- sign * result(i, :), details: http://www.netlib.org/lapack/explore-html/d4/dd0/dscal_8f.html
#ifndef MATLAB_MEX_FILE
dscal_(&P, &sign, resultTV + i, &N);
#else
dscal_(&P, &sign, resultTV + i, &N);
#endif
}
integer lwork = -1;
double lworkopt;
// compute the size of space required in the dormqr
#ifndef MATLAB_MEX_FILE
dormqr_(GLOBAL::L, GLOBAL::N, &N, &P, &P, (const_cast<double *> (ptrHHR)), &N,
(const_cast<double *> (ptrHHRTau)), resultTV, &N, &lworkopt, &lwork, &info);
#else
dormqr_(GLOBAL::L, GLOBAL::N, &N, &P, &P, (const_cast<double *> (ptrHHR)), &N,
(const_cast<double *> (ptrHHRTau)), resultTV, &N, &lworkopt, &lwork, &info);
#endif
lwork = static_cast<integer> (lworkopt);
double *work = new double[lwork];
// resultTV <- Q * resultTV, where Q is the orthogonal matrix defined as the product elementary reflectors defined by ptrHHR and ptrHHRTau,
// details: http://www.netlib.org/lapack/explore-html/da/d82/dormqr_8f.html
#ifndef MATLAB_MEX_FILE
dormqr_(GLOBAL::L, GLOBAL::N, &N, &P, &P, (const_cast<double *> (ptrHHR)), &N,
(const_cast<double *> (ptrHHRTau)), resultTV, &N, work, &lwork, &info);
#else
dormqr_(GLOBAL::L, GLOBAL::N, &N, &P, &P, (const_cast<double *> (ptrHHR)), &N,
(const_cast<double *> (ptrHHRTau)), resultTV, &N, work, &lwork, &info);
#endif
delete[] work;
};
void NStQOrth::EucGradToGradHGZ(Variable *x, Vector *egf, Vector *gf, const Problem *prob) const
{
if (prob->GetUseHess())
{
Vector *segf = egf->ConstructEmpty();
segf->NewMemoryOnWrite(); // I don't remember the reason. It seems to be required.
egf->CopyTo(segf);
SharedSpace *Sharedegf = new SharedSpace(segf);
x->AddToTempData("EGrad", Sharedegf);
}
egf->CopyTo(gf);
double *gfv = gf->ObtainWriteEntireData();
//Y / (x'*x) use compute HHR in NstQorth
if (!x->TempDataExist("HHR"))
ComputeHHR(x);
const SharedSpace *HHR = x->ObtainReadTempData("HHR");
const double *ptrHHR = HHR->ObtainReadData();
double *YT = new double[n * p];
/*YT = Y^T*/
for (integer i = 0; i < n; i++)
{
for (integer j = 0; j < p; j++)
{
YT[j + i * p] = gfv[i + j * n];
}
}
integer info, N = n, P = p;
#ifndef MATLAB_MEX_FILE
dtrtrs_(GLOBAL::U, GLOBAL::T, GLOBAL::N, &P, &N, const_cast<double *> (ptrHHR), &N, YT, &P, &info);
dtrtrs_(GLOBAL::U, GLOBAL::N, GLOBAL::N, &P, &N, const_cast<double *> (ptrHHR), &N, YT, &P, &info);
#else
dtrtrs_(GLOBAL::U, GLOBAL::T, GLOBAL::N, &P, &N, const_cast<double *> (ptrHHR), &N, YT, &P, &info);
dtrtrs_(GLOBAL::U, GLOBAL::N, GLOBAL::N, &P, &N, const_cast<double *> (ptrHHR), &N, YT, &P, &info);
#endif
/*YT = Y^T*/
for (integer i = 0; i < n; i++)
{
for (integer j = 0; j < p; j++)
{
gfv[i + j * n] = YT[j + i * p];
}
}
delete[] YT;
//ExtrProjection(x, gf, gf); Not necessary since gf is already in the horizontal space.
};
void NStQOrth::EucHvToHvHGZ(Variable *x, Vector *etax, Vector *exix, Vector* xix, const Problem *prob) const
{
const double *Y = x->ObtainReadData();
const double *etaxTV = etax->ObtainReadData();
const SharedSpace *Sharedegf = x->ObtainReadTempData("EGrad");
Vector *egfx = Sharedegf->GetSharedElement();
const double *egfTV = egfx->ObtainReadData();
if (!x->TempDataExist("HHR"))
ComputeHHR(x);
const SharedSpace *HHR = x->ObtainReadTempData("HHR");
const double *ptrHHR = HHR->ObtainReadData();
double *tmp = new double[n * p * 2 + p * p * 3];
double *EGYYinv = tmp + n * p;
double *YTEGYYinv = EGYYinv + n * p;
double *EtaTEGYYinv = YTEGYYinv + p * p;
double *EtaTY = EtaTEGYYinv + p * p;
/*tmp = Egrad^T*/
for (integer i = 0; i < n; i++)
{
for (integer j = 0; j < p; j++)
{
tmp[j + i * p] = egfTV[i + j * n];
}
}
integer info, N = n, P = p;
dtrtrs_(GLOBAL::U, GLOBAL::T, GLOBAL::N, &P, &N, const_cast<double *> (ptrHHR), &N, tmp, &P, &info);
dtrtrs_(GLOBAL::U, GLOBAL::N, GLOBAL::N, &P, &N, const_cast<double *> (ptrHHR), &N, tmp, &P, &info);
/*EGYYinv = Egrad * (Y^T * Y)^{-1}*/
for (integer i = 0; i < n; i++)
{
for (integer j = 0; j < p; j++)
{
EGYYinv[i + j * n] = tmp[j + i * p];
}
}
/*YTEGYYinv = Y^T * Egrad * (Y^T * Y)^{-1}*/
dgemm_(GLOBAL::T, GLOBAL::N, &P, &P, &N, &GLOBAL::DONE, const_cast<double *> (Y), &N, EGYYinv, &N, &GLOBAL::DZERO, YTEGYYinv, &P);
/*EtaTEGYYinv = eta^T * Egrad * (Y^T * Y)^{-1}*/
dgemm_(GLOBAL::T, GLOBAL::N, &P, &P, &N, &GLOBAL::DONE, const_cast<double *> (etaxTV), &N, EGYYinv, &N, &GLOBAL::DZERO, EtaTEGYYinv, &P);
/*EtaTY = eta^T * Y */
dgemm_(GLOBAL::T, GLOBAL::N, &P, &P, &N, &GLOBAL::DONE, const_cast<double *> (etaxTV), &N, const_cast<double *> (Y), &N, &GLOBAL::DZERO, EtaTY, &P);
exix->CopyTo(xix);
double *xixTV = xix->ObtainWritePartialData();
double half = 0.5, nhalf = -0.5;
/*xix = EucHess - 0.5 * Egrad * (Y^T * Y)^{-1} * Y^T * eta */
dgemm_(GLOBAL::N, GLOBAL::T, &N, &P, &P, &nhalf, EGYYinv, &N, EtaTY, &P, &GLOBAL::DONE, xixTV, &N);
/*xix = EucHess - 0.5 * Egrad * (Y^T * Y)^{-1} * Y^T * eta - 0.5 * Y * (Y^T * Y)^{-1} Egrad^T * eta */
dgemm_(GLOBAL::N, GLOBAL::T, &N, &P, &P, &nhalf, const_cast<double *>(Y), &N, EtaTEGYYinv, &P, &GLOBAL::DONE, xixTV, &N);
/*xix = EucHess - 0.5 * Egrad * (Y^T * Y)^{-1} * Y^T * eta - 0.5 * Y * (Y^T * Y)^{-1} Egrad^T * eta + 0.5 * eta * Y^T * Egrad * (Y^T * Y)^{-1} */
dgemm_(GLOBAL::N, GLOBAL::N, &N, &P, &P, &half, const_cast<double *>(etaxTV), &N, YTEGYYinv, &P, &GLOBAL::DONE, xixTV, &N);
/*xix = EucHess - 0.5 * Egrad * (Y^T * Y)^{-1} * Y^T * eta - 0.5 * Y * (Y^T * Y)^{-1} Egrad^T * eta + 0.5 * eta * Y^T * Egrad * (Y^T * Y)^{-1}
- 0.5 * Y * eta^T * Egrad * (Y^T * Y)^{-1} */
dgemm_(GLOBAL::N, GLOBAL::N, &N, &P, &P, &nhalf, const_cast<double *>(Y), &N, EtaTEGYYinv, &P, &GLOBAL::DONE, xixTV, &N);
/*xix = EucHess - 0.5 * Egrad * (Y^T * Y)^{-1} * Y^T * eta - 0.5 * Y * (Y^T * Y)^{-1} Egrad^T * eta + 0.5 * eta * Y^T * Egrad * (Y^T * Y)^{-1}
- 0.5 * Y * eta^T * Egrad * (Y^T * Y)^{-1} + 0.5 * eta *(Y^T * Y)^{-1} Egrad^T Y */
dgemm_(GLOBAL::N, GLOBAL::T, &N, &P, &P, &half, const_cast<double *>(etaxTV), &N, YTEGYYinv, &P, &GLOBAL::DONE, xixTV, &N);
/*xix = EucHess - 0.5 * Egrad * (Y^T * Y)^{-1} * Y^T * eta - 0.5 * Y * (Y^T * Y)^{-1} Egrad^T * eta + 0.5 * eta * Y^T * Egrad * (Y^T * Y)^{-1}
- 0.5 * Y * eta^T * Egrad * (Y^T * Y)^{-1} + 0.5 * eta *(Y^T * Y)^{-1} Egrad^T Y - 0.5 * Egrad * (Y^T * Y)^{-1} * eta^T * Y */
dgemm_(GLOBAL::N, GLOBAL::N, &N, &P, &P, &nhalf, EGYYinv, &N, EtaTY, &P, &GLOBAL::DONE, xixTV, &N);
/*tmp = xix^T*/
for (integer i = 0; i < n; i++)
{
for (integer j = 0; j < p; j++)
{
tmp[j + i * p] = xixTV[i + j * n];
}
}
dtrtrs_(GLOBAL::U, GLOBAL::T, GLOBAL::N, &P, &N, const_cast<double *> (ptrHHR), &N, tmp, &P, &info);
dtrtrs_(GLOBAL::U, GLOBAL::N, GLOBAL::N, &P, &N, const_cast<double *> (ptrHHR), &N, tmp, &P, &info);
/*xix = xix * (Y^T * Y)^{-1}*/
for (integer i = 0; i < n; i++)
{
for (integer j = 0; j < p; j++)
{
xixTV[i + j * n] = tmp[j + i * p];
}
}
delete[] tmp;
ExtrProjection(x, xix, xix);
};
void NStQOrth::ObtainIntrHGZ(Variable *x, Vector *etax, Vector *result) const
{
if (!x->TempDataExist("HHR"))
{
ComputeHHR(x);
}
const double *xM = x->ObtainReadData();
const double *etaxTV = etax->ObtainReadData();
const SharedSpace *HHR = x->ObtainReadTempData("HHR");
const SharedSpace *HHRTau = x->ObtainReadTempData("HHRTau");
double *resultTV = result->ObtainWriteEntireData();
const double *ptrHHR = HHR->ObtainReadData();
const double *ptrHHRTau = HHRTau->ObtainReadData();
integer N = x->Getsize()[0], P = x->Getsize()[1], inc = 1, Length = N * P;
integer info;
integer lwork = -1;
double lworkopt;
double *tempspace = new double[n * p];
// compute the size of space required in the dormqr
#ifndef MATLAB_MEX_FILE
dormqr_(GLOBAL::L, GLOBAL::T, &N, &P, &P, (const_cast<double *> (ptrHHR)), &N,
(const_cast<double *> (ptrHHRTau)), tempspace, &N, &lworkopt, &lwork, &info);
#else
dormqr_(GLOBAL::L, GLOBAL::T, &N, &P, &P, (const_cast<double *> (ptrHHR)), &N,
(const_cast<double *> (ptrHHRTau)), tempspace, &N, &lworkopt, &lwork, &info);
#endif
lwork = static_cast<integer> (lworkopt);
double *work = new double[lwork];
// tempspace <- etaxTV, details: http://www.netlib.org/lapack/explore-html/da/d6c/dcopy_8f.html
dcopy_(&Length, const_cast<double *> (etaxTV), &inc, tempspace, &inc);
// tempspace <- Q^T * tempspace, where Q is the orthogonal matrix defined as the product elementary reflectors defined by ptrHHR and ptrHHRTau,
// details: http://www.netlib.org/lapack/explore-html/da/d82/dormqr_8f.html
#ifndef MATLAB_MEX_FILE
dormqr_(GLOBAL::L, GLOBAL::T, &N, &P, &P, (const_cast<double *> (ptrHHR)), &N,
(const_cast<double *> (ptrHHRTau)), tempspace, &N, work, &lwork, &info);
#else
dormqr_(GLOBAL::L, GLOBAL::T, &N, &P, &P, (const_cast<double *> (ptrHHR)), &N,
(const_cast<double *> (ptrHHRTau)), tempspace, &N, work, &lwork, &info);
#endif
double sign = 0;
for (integer i = 0; i < p; i++)
{
sign = (ptrHHR[i + n * i] >= 0) ? 1 : -1;
#ifndef MATLAB_MEX_FILE
dscal_(&P, &sign, tempspace + i, &N);
#else
dscal_(&P, &sign, tempspace + i, &N);
#endif
}
double *L = new double[p * p];
for (integer i = 0; i < p; i++)
{
for (integer j = 0; j < i; j++)
{
L[j + i * p] = 0;
}
sign = (ptrHHR[i + n * i] >= 0) ? 1 : -1;
for (integer j = i; j < p; j++)
{
L[j + i * p] = ptrHHR[i + n * j] * sign;
}
}
double *tempspaceL = new double[n * p];
Matrix MtL(tempspaceL, n, p), ML(L, p, p), Mtempspace(tempspace, n, p);
Matrix::DGEMM(GLOBAL::DONE, Mtempspace, false, ML, false, GLOBAL::DZERO, MtL);
delete[] L;
delete[] tempspace;
/*Matrix MxM(xM, n, p), MetaxTV(etaxTV, n, p), Mtempspace((double *)tempspace, p, p, n);
Matrix::CGEMM(GLOBAL::ZONE, MxM, true, MetaxTV, false, GLOBAL::ZZERO, Mtempspace);*/
double r2 = sqrt(2.0);
double factor = 1;//-- sqrt(Manifold::Metric(x, x, x));
integer idx = 0;
for (integer i = 0; i < p; i++)
{
resultTV[idx] = tempspaceL[i + i * n] / factor;
idx++;
}
for (integer i = 0; i < p; i++)
{
for (integer j = i + 1; j < p; j++)
{
resultTV[idx] = r2 * tempspaceL[j + i * n] / factor;
idx++;
}
}
for (integer i = 0; i < p; i++)
{
for (integer j = p; j < n; j++)
{
resultTV[idx] = tempspaceL[j + i * n];
idx++;
}
}
delete[] work;
delete[] tempspaceL;
};
void NStQOrth::ObtainExtrHGZ(Variable *x, Vector *intretax, Vector *result) const
{
if (!x->TempDataExist("HHR"))
{
ComputeHHR(x);
}
const double *xM = x->ObtainReadData();
const SharedSpace *HHR = x->ObtainReadTempData("HHR");
const SharedSpace *HHRTau = x->ObtainReadTempData("HHRTau");
const double *ptrHHR = HHR->ObtainReadData();
const double *ptrHHRTau = HHRTau->ObtainReadData();
const double *intretaxTV = intretax->ObtainReadData();
double *resultTV = result->ObtainWriteEntireData();
integer N = x->Getsize()[0], P = x->Getsize()[1], inc = 1, Length = N * P;
integer info;
integer idx = 0;
// doublecomplex *S = new doublecomplex[p * p];
double r2 = sqrt(2.0);
double factor = 1;//-- sqrt(Manifold::Metric(x, x, x));
for (integer i = 0; i < p; i++)
{
resultTV[i + i * n] = intretaxTV[idx] * factor;
idx++;
}
for (integer i = 0; i < p; i++)
{
for (integer j = i + 1; j < p; j++)
{
resultTV[j + i * n] = intretaxTV[idx] / r2 * factor;
resultTV[i + j * n] = intretaxTV[idx] / r2 * factor;
idx++;
}
}
for (integer i = 0; i < p; i++)
{
for (integer j = p; j < n; j++)
{
resultTV[j + i * n] = intretaxTV[idx];
idx++;
}
}
double sign = 0;
for (integer i = 0; i < p; i++)
{
sign = (ptrHHR[i + n * i] >= 0) ? 1 : -1;
// result(i, :) <- sign * result(i, :), details: http://www.netlib.org/lapack/explore-html/d4/dd0/dscal_8f.html
#ifndef MATLAB_MEX_FILE
dscal_(&P, &sign, resultTV + i, &N);
#else
dscal_(&P, &sign, resultTV + i, &N);
#endif
}
integer lwork = -1;
double lworkopt;
// compute the size of space required in the dormqr
#ifndef MATLAB_MEX_FILE
dormqr_(GLOBAL::L, GLOBAL::N, &N, &P, &P, (const_cast<double *> (ptrHHR)), &N,
(const_cast<double *> (ptrHHRTau)), resultTV, &N, &lworkopt, &lwork, &info);
#else
dormqr_(GLOBAL::L, GLOBAL::N, &N, &P, &P, (const_cast<double *> (ptrHHR)), &N,
(const_cast<double *> (ptrHHRTau)), resultTV, &N, &lworkopt, &lwork, &info);
#endif
lwork = static_cast<integer> (lworkopt);
double *work = new double[lwork];
// resultTV <- Q * resultTV, where Q is the orthogonal matrix defined as the product elementary reflectors defined by ptrHHR and ptrHHRTau,
// details: http://www.netlib.org/lapack/explore-html/da/d82/dormqr_8f.html
#ifndef MATLAB_MEX_FILE
dormqr_(GLOBAL::L, GLOBAL::N, &N, &P, &P, (const_cast<double *> (ptrHHR)), &N,
(const_cast<double *> (ptrHHRTau)), resultTV, &N, work, &lwork, &info);
#else
dormqr_(GLOBAL::L, GLOBAL::N, &N, &P, &P, (const_cast<double *> (ptrHHR)), &N,
(const_cast<double *> (ptrHHRTau)), resultTV, &N, work, &lwork, &info);
#endif
delete[] work;
double *L = new double[p * p + n * p];
double *r_T = L + p * p;
for (integer i = 0; i < p; i++)
{
for (integer j = 0; j < i; j++)
{
L[j + i * p] = 0;
}
sign = (ptrHHR[i + n * i] >= 0) ? 1 : -1;
for (integer j = i; j < p; j++)
{
L[j + i * p] = ptrHHR[i + n * j] * sign;
}
}
/*r_T <- resultTV transpose*/
for (integer i = 0; i < n; i++)
{
for (integer j = 0; j < p; j++)
{
r_T[j + i * p] = resultTV[i + j * n];
}
}
#ifndef MATLAB_MEX_FILE
/*solve linear system L^H M = r_T, the solution M is stored in r_T*/
dtrtrs_(GLOBAL::L, GLOBAL::C, GLOBAL::N, &P, &N, L, &P, r_T, &P, &info);
#else
dtrtrs_(GLOBAL::L, GLOBAL::C, GLOBAL::N, &P, &N, L, &P, r_T, &P, &info);
#endif
/*resultTV <- r_T transpose*/
for (integer i = 0; i < n; i++)
{
for (integer j = 0; j < p; j++)
{
resultTV[i + j * n] = r_T[j + i * p];
}
}
delete[] L;
};
void NStQOrth::VectorTransport(Variable *x, Vector *etax, Variable *y, Vector *xix, Vector *result) const
{
if (VecTran == NSOPARALLELIZATION && !HasHHR)
{
return Manifold::VectorTransport(x, etax, y, xix, result);
}
if (VecTran == NSOPROJECTION && !HasHHR)
{
if (IsIntrApproach)
{
VectorTransportProj(x, etax, y, xix, result);
}
else
printf("Warning: Vector transport by projection has not been done for extrinsic approach!\n");
return;
}
if (HasHHR)
return LCVectorTransport(x, etax, y, xix, result);
printf("Error: VectorTransport has not been done!\n");
};
void NStQOrth::VectorTransportProj(Variable *x, Vector *etax, Variable *y, Vector *xix, Vector *result) const
{
Vector *exxix = EMPTYEXTR->ConstructEmpty();
ObtainExtr(x, xix, exxix);
ObtainIntr(y, exxix, result);
delete exxix;
};
}; /*end of ROPTLIB namespace*/
|
076a8b19a089e12c3b62ebafb1e54de81ee93322 | 24d3527ca20f8600d03f4634c8785c88931d73fe | /Chapitre_3/TD_Barre/main.cpp | 9f771e2cae7c871fa0d338329330be9e5ab2e691 | [] | no_license | GeoffreyBeranger/Apprendre_Cpp | 803bb847fc17f397dec5afb028a645f4117b6bb7 | 2321d5b3997af2a6a25ab5637ef592316a794be2 | refs/heads/master | 2020-07-19T17:34:11.497367 | 2020-01-09T07:27:17 | 2020-01-09T07:27:17 | 206,487,755 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 638 | cpp | main.cpp | #include <iostream>
#include "barreoctogonecreuse.h"
using namespace std;
/**
* @brief main
* @version 1.0
* @date 20/09/2019
* @details Programme Principal qui créer une barre en initialisant ses paramètres,
* Puis affiche sa Section et sa Masse
* @return
*/
int main()
{
///Création d'un objet BarreOctogoneCreuse
barreOctogoneCreuse uneBarre("A1234",5,5,"Fer",5,3);
///Affichage de la section de cette barre
cout << uneBarre.CalculerSection() << endl;
///Affichage de la Masse de cette Barre
cout << "La Masse de votre Barre est de : " << uneBarre.CalculerMasse() << endl;
return 0;
}
|
25545d9c1e2a0d8e069d394e4310c83afd027d49 | ce39d750fe93bc30894b7ea747d3b9f11e75c5ec | /src/base/mat.cpp | 14fc71908114bf6126102e7e64233e7455575139 | [
"MIT"
] | permissive | vidits-kth/py-itpp | 3c61c367e186cc66acb7453b362356c9bc7819fa | 488ccf8845d06f25c6712f38a1a7faeff3a61be2 | refs/heads/master | 2022-07-06T15:27:14.942667 | 2022-06-13T08:56:01 | 2022-06-13T08:56:01 | 95,443,680 | 18 | 8 | null | 2018-07-23T21:56:02 | 2017-06-26T12:22:23 | C++ | UTF-8 | C++ | false | false | 1,363 | cpp | mat.cpp | //! -------------------------------------------------------------------------
//!
//! Copyright (C) 2016 CC0 1.0 Universal (CC0 1.0)
//!
//! The person who associated a work with this deed has dedicated the work to
//! the public domain by waiving all of his or her rights to the work
//! worldwide under copyright law, including all related and neighboring
//! rights, to the extent allowed by law.
//!
//! You can copy, modify, distribute and perform the work, even for commercial
//! purposes, all without asking permission.
//!
//! See the complete legal text at
//! <https://creativecommons.org/publicdomain/zero/1.0/legalcode>
//!
//! -------------------------------------------------------------------------
#include "mat.h"
//! Create wrappers within the mat module
PYBIND11_MODULE(mat, m)
{
// Default Matrix Type
generate_itpp_mat_wrapper<double>(m, "mat");
// Default Complex Matrix Type
generate_itpp_mat_wrapper<std::complex<double> >(m, "cmat");
// Default Float Matrix Type
generate_itpp_mat_wrapper<float>(m, "fmat");
// Default Complex Float Matrix Type
generate_itpp_mat_wrapper<std::complex<float> >(m, "cfmat");
// Integer matrix
generate_itpp_mat_wrapper<int>(m, "imat");
// short int matrix
generate_itpp_mat_wrapper<short int>(m, "smat");
// bin matrix
generate_itpp_mat_wrapper<itpp::bin>(m, "bmat");
}
|
a43d800e06e7ce5c8895b6abd6787a6085e2f7ea | c13e9f87a99d5993837b0da806cf906ea2e3868a | /10_clock/clock_pattern/include/statistics.h | 9a0d1f9511ed209d4a2585ca9b1fe9bf9e095395 | [] | no_license | eugene536/soft_design | bb7977f6d1bc87406a471fda3f5be36eb573472a | 9c8804d2890d1a637dea5f74640af3b958ebc659 | refs/heads/master | 2021-06-13T03:37:31.179584 | 2017-04-01T07:53:11 | 2017-04-01T07:53:11 | 69,736,308 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,210 | h | statistics.h | //
// Created by eugene on 1.4.2017
//
#pragma once
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <cstdint>
#include <chrono>
struct event_statistics {
typedef uint32_t statistics_t;
typedef std::string name_t;
virtual ~event_statistics() {}
virtual void inc_event(name_t const & name) = 0;
virtual statistics_t get_event_statistics(name_t const & name) = 0;
virtual std::map<name_t, statistics_t> get_all_event_statistics() const = 0;
virtual void print() = 0;
};
template<typename ClockT>
struct event_statistics_last_hour
: event_statistics
{
typedef typename ClockT::time_point time_point;
typedef std::queue<time_point> time_points_t;
typedef std::map<name_t, time_points_t> timed_statistics_t;
event_statistics_last_hour(std::chrono::hours interesting_period = std::chrono::hours(1))
: _interesting_period(interesting_period)
{}
void inc_event(const event_statistics::name_t &name) {
time_points_t & points = _statistics[name];
points.push(ClockT::now());
}
statistics_t get_event_statistics(const name_t &name) override {
using namespace std::chrono;
time_points_t & points = _statistics.at(name);
event_statistics_last_hour::time_point cur_time = ClockT::now();
while (duration_cast<hours>(cur_time - points.front()) > _interesting_period) {
points.pop();
}
if (points.size() > 1) {
uint32_t whole_time =
duration_cast<seconds>(points.back() - points.front()).count();
double part_of_minute = whole_time * 1.0 / 60;
return points.size() / part_of_minute;
} else if (points.size() == 1) {
return points.size();
} else {
return 0;
}
}
std::map<name_t, statistics_t> get_all_event_statistics() const override {
return {};
}
void print() override {
for (auto const & p: _statistics) {
std::cerr << p.first << " " << get_event_statistics(p.first) << std::endl;
}
}
std::chrono::hours _interesting_period;
timed_statistics_t _statistics;
};
|
a64f9cb998ab5214345e8a3c8262d0a1873a544c | 63a3053a1c276cc39733c57c597e335895ee9269 | /enemy.cpp | 40cb2a0e1b802fc3fb4de266f862670b0eaa4742 | [] | no_license | axwl03/2018-pd2-Project3 | ee45c4119a30e3fb7771a585d4d247261ad3cb85 | bcc2f8b28f1f2a55267b7356c8bf006be63ce630 | refs/heads/master | 2020-03-22T10:38:52.238883 | 2018-07-06T01:33:44 | 2018-07-06T01:33:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,998 | cpp | enemy.cpp | #include "enemy.h"
Enemy::Enemy(int h, int character_ID): Human(h)
{
setPixmap(character.at(character_ID));
setScale(0.4);
setZValue(1);
setRotation(180);
setData(0, "enemy");
if(h == 100)
w = new weapon(1);
if(h > 100)
w = new weapon(4);
w->setData(0, -10);
w->setRotation(180);
healthbar = new QGraphicsRectItem;
healthbar->setBrush(Qt::green);
rx = qrand()%700+100;
ry = qrand()%100+200;
}
Enemy::Enemy(int h, int character_ID, bool e): Human(h){ //1 vs 1 mode p2
setPixmap(character.at(character_ID));
setScale(0.4);
setZValue(1);
setRotation(180);
setData(0, "enemy");
if(character_ID == 0){
setScale(0.4);
w1 = new weapon(2);
w2 = new weapon(0);
}
if(character_ID == 1){
setScale(0.42);
w1 = new weapon(2);
w2 = new weapon(3);
}
if(character_ID == 2){
setScale(0.4);
w1 = new weapon(1);
w2 = new weapon(3);
}
w1->setRotation(180);
w1->setData(0, -w1->data(0).toInt());
w2->setRotation(180);
w2->setData(0, -w2->data(0).toInt());
w = w1;
healthbar = new QGraphicsRectItem;
healthbar->setBrush(Qt::green);
}
Enemy::~Enemy(){}
void Enemy::move(){
if(rx - x() > 0)
setPos(x()+1,y());
if(rx - x() < 0)
setPos(x()-1,y());
if(ry - y() > 0)
setPos(x(), y()+1);
if(ry - y() < 0)
setPos(x(), y()-1);
}
void Enemy::setItemPos(){
w->setPos(x()-pixmap().width()*scale()/1.6, y()-pixmap().height()*scale()/1.6+w->pixmap().height()*w->scale());
healthbar->setRect(x()-pixmap().width()*scale()/2-health/2, y()-pixmap().height()*scale()-20, health, 5);
if(health > 50)
healthbar->setBrush(Qt::green);
if(health <= 50 && health > 20)
healthbar->setBrush(Qt::yellow);
if(health <= 20)
healthbar->setBrush(Qt::red);
}
void Enemy::setNewPosition(){
rx = qrand()%700+100;
ry = qrand()%100+200;
}
|
4af9d1f126d04de4e3623c910d54078c94fd2d52 | 42f54f9e45e4ac8bb9cad2b1221197b499d4e0ca | /src/simd/ps3/Simd4i.h | aaae344ff982b5e74e250208d06c799c11a904af | [] | no_license | swordow/Waveworks | 3512ec3a0c890d824033e3a434db48567f9b2d44 | bcb9fac9a618b36e29757996b7df93404075dfd3 | refs/heads/master | 2020-11-26T22:32:39.889841 | 2017-02-16T04:28:24 | 2017-02-16T04:28:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,185 | h | Simd4i.h | // This code contains NVIDIA Confidential Information and is disclosed to you
// under a form of NVIDIA software license agreement provided separately to you.
//
// Notice
// NVIDIA Corporation and its licensors retain all intellectual property and
// proprietary rights in and to this software and related documentation and
// any modifications thereto. Any use, reproduction, disclosure, or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA Corporation is strictly prohibited.
//
// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
//
// Information and code furnished is believed to be accurate and reliable.
// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
// information or for any infringement of patents or other rights of third parties that may
// result from its use. No license is granted by implication or otherwise under any patent
// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
// This code supersedes and replaces all information previously supplied.
// NVIDIA Corporation products are not authorized for use as critical
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
// Copyright (c) 2008-2014 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#pragma once
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// factory implementation
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
template <>
inline Simd4iFactory<const int&>::operator Simd4i() const
{
return (vec_uint4)vec_splat(vec_lvlx(0, (int*)&v), 0);
}
inline Simd4iFactory<detail::FourTuple>::operator Simd4i() const
{
return (const vec_uint4&)v;
}
template <int i>
inline Simd4iFactory<detail::IntType<i> >::operator Simd4i() const
{
return (vec_uint4)vec_splat_s32(i);
}
template <>
inline Simd4iFactory<detail::IntType<0x80000000> >::operator Simd4i() const
{
vec_uint4 mask = (vec_uint4)vec_splat_s32(-1);
return vec_sl(mask, mask);
}
template <>
inline Simd4iFactory<const int*>::operator Simd4i() const
{
return (vec_uint4)vec_or(vec_lvlx(0, const_cast<int*>(v)), vec_lvrx(16, const_cast<int*>(v)));
}
template <>
inline Simd4iFactory<detail::AlignedPointer<int> >::operator Simd4i() const
{
return (vec_uint4)vec_ld(0, const_cast<int*>(v.ptr));
}
template <>
inline Simd4iFactory<detail::OffsetPointer<int> >::operator Simd4i() const
{
return (vec_uint4)vec_ld(v.offset, const_cast<int*>(v.ptr));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// expression template
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
template <>
inline ComplementExpr<Simd4i>::operator Simd4i() const
{
return vec_nor(v.u4, v.u4);
}
Simd4i operator&(const ComplementExpr<Simd4i>& complement, const Simd4i& v)
{
return vec_andc(v.u4, complement.v.u4);
}
Simd4i operator&(const Simd4i& v, const ComplementExpr<Simd4i>& complement)
{
return vec_andc(v.u4, complement.v.u4);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// operator implementations
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Simd4i simdi::operator==(const Simd4i& v0, const Simd4i& v1)
{
return (vec_uint4)vec_cmpeq(v0.u4, v1.u4);
}
Simd4i simdi::operator<(const Simd4i& v0, const Simd4i& v1)
{
return (vec_uint4)vec_cmplt((vec_int4)v0.u4, (vec_int4)v1.u4);
}
Simd4i simdi::operator>(const Simd4i& v0, const Simd4i& v1)
{
return (vec_uint4)vec_cmpgt((vec_int4)v0.u4, (vec_int4)v1.u4);
}
ComplementExpr<Simd4i> operator~(const Simd4i& v)
{
return ComplementExpr<Simd4i>(v);
}
Simd4i operator&(const Simd4i& v0, const Simd4i& v1)
{
return vec_and(v0.u4, v1.u4);
}
Simd4i operator|(const Simd4i& v0, const Simd4i& v1)
{
return vec_or(v0.u4, v1.u4);
}
Simd4i operator^(const Simd4i& v0, const Simd4i& v1)
{
return vec_xor(v0.u4, v1.u4);
}
Simd4i operator<<(const Simd4i& v, int shift)
{
return vec_sl(v.u4, vec_splat((vec_uint4)vec_lvlx(0, &shift), 0));
}
Simd4i operator>>(const Simd4i& v, int shift)
{
return vec_sr(v.u4, vec_splat((vec_uint4)vec_lvlx(0, &shift), 0));
}
Simd4i operator<<(const Simd4i& v, const Simd4i& shift)
{
return vec_sl(v.u4, shift.u4);
}
Simd4i operator>>(const Simd4i& v, const Simd4i& shift)
{
return vec_sr(v.u4, shift.u4);
}
Simd4i simdi::operator+(const Simd4i& v0, const Simd4i& v1)
{
return vec_add(v0.u4, v1.u4);
}
Simd4i simdi::operator-(const Simd4i& v)
{
return vec_sub((vec_uint4)vec_splat_s32(0), v.u4);
}
Simd4i simdi::operator-(const Simd4i& v0, const Simd4i& v1)
{
return vec_sub(v0.u4, v1.u4);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function implementations
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Simd4i simd4i(const Simd4f& v)
{
return (vec_uint4)v.f4;
}
Simd4i truncate(const Simd4f& v)
{
return vec_cts(v.f4, 0);
}
int (&simdi::array(Simd4i& v))[4]
{
return (int(&)[4])v;
}
const int (&simdi::array(const Simd4i& v))[4]
{
return (const int(&)[4])v;
}
void store(int* ptr, const Simd4i& v)
{
vec_stvlx((vec_int4)v.u4, 0, ptr);
vec_stvrx((vec_int4)v.u4, 16, ptr);
}
void storeAligned(int* ptr, const Simd4i& v)
{
vec_stvlx((vec_int4)v.u4, 0, ptr);
}
void storeAligned(int* ptr, unsigned int offset, const Simd4i& v)
{
vec_stvlx((vec_int4)v.u4, offset, ptr);
}
template <size_t i>
Simd4i splat(Simd4i const& v)
{
return vec_splat(v.u4, i);
}
Simd4i select(Simd4i const& mask, Simd4i const& v0, Simd4i const& v1)
{
return vec_sel(v1.u4, v0.u4, mask.u4);
}
int simdi::allEqual(const Simd4i& v0, const Simd4i& v1)
{
return vec_all_eq(v0.u4, v1.u4);
}
int simdi::allEqual(const Simd4i& v0, const Simd4i& v1, Simd4i& outMask)
{
int r = simdi::allEqual(v0, v1);
outMask = simdi::operator==(v0, v1);
return r;
}
int simdi::anyEqual(const Simd4i& v0, const Simd4i& v1)
{
return vec_any_eq(v0.u4, v1.u4);
}
int simdi::anyEqual(const Simd4i& v0, const Simd4i& v1, Simd4i& outMask)
{
int r = simdi::anyEqual(v0, v1);
outMask = simdi::operator==(v0, v1);
return r;
}
int simdi::allGreater(const Simd4i& v0, const Simd4i& v1)
{
return vec_all_gt(v0.u4, v1.u4);
}
int simdi::allGreater(const Simd4i& v0, const Simd4i& v1, Simd4i& outMask)
{
int r = simdi::allGreater(v0, v1);
outMask = simdi::operator>(v0, v1);
return r;
}
int simdi::anyGreater(const Simd4i& v0, const Simd4i& v1)
{
return vec_any_gt(v0.u4, v1.u4);
}
int simdi::anyGreater(const Simd4i& v0, const Simd4i& v1, Simd4i& outMask)
{
int r = simdi::anyGreater(v0, v1);
outMask = simdi::operator>(v0, v1);
return r;
}
int allTrue(const Simd4i& v)
{
return vec_all_lt((vec_int4)v.u4, vec_splat_s32(0));
}
int anyTrue(const Simd4i& v)
{
return vec_any_lt((vec_int4)v.u4, vec_splat_s32(0));
}
|
40132cb02d7b689db47443f34ba4ba1afab7243a | 2df435494fbc176ff6b1eb08b8e6aaf62c8eba7c | /Chapter 4/ex_4_83.cpp | 669d90464f545286b4e22e66d46ddde025bbccf0 | [] | no_license | alanlyyy/C-Sedgewick-Data-Structures | 540c86f01e078ba778ee48ca89afebed3cb3c892 | bba5fb8fcdc48e1eec76c3744332a5a706926956 | refs/heads/main | 2023-02-28T05:36:21.209951 | 2021-02-05T03:14:09 | 2021-02-05T03:14:09 | 313,140,524 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,005 | cpp | ex_4_83.cpp | #include "Poly_linked_list.h"
#include <iostream>
int main_4_83() {
//x^5 +2x
Poly_linked_list<float> x(1, 2), onex(1, 1);
Poly_linked_list<float> x2(1, 2);
Poly_linked_list<float> two_x(2, 1);
Poly_linked_list<float> one(1, 0);
Poly_linked_list<float> neg_one(-1, 0);
Poly_linked_list<float> zero(0, 0, 3);
Poly_linked_list<float> zero_2(0, 0);
Poly_linked_list<float> zero_3(0, 0);
Poly_linked_list<float> five_x(-5, 1);
Poly_linked_list<float> zero_4(0, 0);
Poly_linked_list<float> zero_5(0, 0);
Poly_linked_list<float> x6(1, 6);
Poly_linked_list<float> two_x4(2, 4);
Poly_linked_list<float> six_x(6, 1);
Poly_linked_list<float> minus_nine(-9, 0);
Poly_linked_list<float> zero_6(0, 0);
Poly_linked_list<float> x3(1, 3);
Poly_linked_list<float> three(3, 0);
Poly_linked_list<float> zero_comp(0, 0);
//x2 +2x + 1
zero += x;
zero += (onex+onex);
zero += one;
zero.print_coefficients();
//x+1
zero_2 += onex;
zero_2 += one;
Poly_linked_list<float> t = zero / zero_2;
//Poly_linked_list<float> t2 = zero_2 / zero;
std::cout << "Remainder: " << std::endl;
//2x^2 -5x -1
zero_3 += five_x;
zero_3 += (x2 + x2);
zero_3 += neg_one;
zero_3.print_coefficients();
//x-3
zero_4 += (neg_one + neg_one);
zero_4 += neg_one;
zero_4 += onex;
zero_4.print_coefficients();
Poly_linked_list<float> t3 = zero_3 / zero_4;
//Poly_linked_list<float> t4 = zero_4 / zero_3;
std::cout << "Missing Terms:" << std::endl;
//x^6 + 2x^4 + 6x -9
zero_5 += x6;
zero_5 += two_x4;
zero_5 += six_x;
zero_5 += minus_nine;
zero_5.print_coefficients();
//x^3 + 3
zero_6 += x3;
zero_6 += three;
zero_6.print_coefficients();
zero_5 / zero_6;
//x2 +2x + 1
zero_comp += x;
zero_comp += (onex + onex);
zero_comp += one;
//test composition
std::cout << "f(g(4) = 11 :" << zero_4.eval(7.0) << std::endl;
std::cout << "f(g(4) = 11 :" << zero_comp.eval(4) << std::endl;
std::cout << "f(g(4) = 11 :" << zero_comp.composition(zero_4, 7.0) << std::endl;
return 0;
} |
fa2c13d02245e7eb0f8d21cc471253a9c64aaaa3 | 35e72193b6a3772cc4dbfeba8ad8b1fd414d86a8 | /1lab/main.cpp | a1f51e8bc7a5beb27d446ec8fbafe3ecb8f3cfaf | [] | no_license | ThePigeonKing/CPP-labs | 2d56ab1e82fc5707e79afaad18fed503b79b3d2f | 246dd809e8641c7abe28d0adae69038e256801b7 | refs/heads/main | 2023-08-04T16:47:02.455296 | 2021-09-21T22:11:33 | 2021-09-21T22:11:33 | 407,123,561 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 821 | cpp | main.cpp | #include <iostream>
#include "struct.h"
#define DEBUG 1
int main(int argc, char const *argv[]) {
int num1 = 0, num2 = 0;
std::vector<double> vec;
lab1::Matrix *matr = new lab1::Matrix;
try {
matr->input();
if (DEBUG) {
matr->print_cords();
matr->print_matr();
}
vec = matr->do_business(0);
std::cout << YELLOW << "Vec.size = " << vec.size() << RESET << std::endl;
std::cout << "{";
for (auto i = 0; i < vec.size(); ++i) {
std::cout << " " << vec[i];
}
std::cout << " }" << std::endl;
} catch (const std::invalid_argument &e) {
std::cerr << RED << e.what() << RESET << std::endl;
} catch (const std::runtime_error &e) {
//delete matr;
std::cerr << RED << e.what() << RESET << std::endl;
}
delete matr;
return 0;
}
|
575f9eb208345d278831cabbf70ff0d9965bd667 | a15fd48e165064ae5c247f91dfb635fc62a215d7 | /IG1App/Dragon.h | 518fe191f73abaa6adcfb4df361333560c5c0e50 | [] | no_license | MiguelZh/Physics-IG | d0ec7d8d370d369ea3976ccd809590dbfbca0f84 | 7179959ee436a47f6ca0fa5c328c61f5e600f9fc | refs/heads/master | 2020-04-24T16:00:51.094045 | 2019-05-27T13:52:00 | 2019-05-27T13:52:00 | 172,090,894 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 193 | h | Dragon.h | #pragma once
#include "Entity.h"
class Dragon final : public Entity {
public:
Dragon(GLuint vertices);
~Dragon();
void render(Camera const &camera) override;
void update() override;
};
|
0ebc5074e5804ffd8179fe5d044799427ff0bfe0 | 602e0f4bae605f59d23688cab5ad10c21fc5a34f | /MyToolKit/OwspClient/CIpmsClient.h | 1e541022ecdf57beb4ab829624b55e68eff03fdc | [] | no_license | yanbcxf/cpp | d7f26056d51f85254ae1dd2c4e8e459cfefb2fb6 | e059b02e7f1509918bbc346c555d42e8d06f4b8f | refs/heads/master | 2023-08-04T04:40:43.475657 | 2023-08-01T14:03:44 | 2023-08-01T14:03:44 | 172,408,660 | 8 | 5 | null | null | null | null | GB18030 | C++ | false | false | 3,477 | h | CIpmsClient.h | #pragma once
#define MAX_JSON 2048
class CIpmsClient : public BaseClient
{
public:
typedef void (responseHandler)(void * pUserContext, int nResult, unsigned char * pData, int dataLength);
CIpmsClient(UsageEnvironment& env, string strIPAddr, int nPort, string strDeviceSN, bool bControlBox);
~CIpmsClient();
enum { PACKET_0 = 0, PACKET_DATA };
class RequestRecord {
public:
RequestRecord(unsigned cseq, responseHandler* handler, void * pUserContext,
char* url, u_int32 body_len, unsigned char * body_data);
// alternative constructor for creating "PLAY" requests that include 'absolute' time values
virtual ~RequestRecord();
RequestRecord*& next() { return fNext; }
unsigned& cseq() { return fCSeq; }
//char const* commandName() const { return fCommandName; }
responseHandler*& handler() { return fHandler; }
void * userContext() { return fUserContext; }
char f_url[256];
u_int32 f_body_len;
unsigned char * f_body_data;
struct timeval f_tvSubmitTime;
private:
RequestRecord* fNext;
unsigned fCSeq;
//char const* fCommandName;
responseHandler* fHandler;
void * fUserContext;
};
//////////////////////////////////////////////////////////////////////////
void _memcpy(unsigned char * mm_vPkgData, int mm_vPkgLen, unsigned char * vPkgData, int curPos, int vPkgLen);
void SendDataByBuffer(unsigned char * vPkgData, int vPkgLen, bool bMark);
void handleResponseBytes(int newBytesRead);
virtual void handleConnected();
virtual void handleDestoryed();
virtual unsigned sendRequest(RequestRecord* request);
static void TestTaskFunc(void* clientData);
static void TestHeartBeatFunc(void * clientData);
static void CheckTimeOuntFunc(void* clientData);
void TimeoutProcess();
unsigned sendRegisterCommand(void * pUserContext);
unsigned sendKeepAlive();
unsigned sendDevStatePush();
unsigned sendEleReport();
unsigned sendOfflineEleReport();
unsigned sendDeviceAlarm();
private:
//////////////////////////////////////////////////////////////////////////
class RequestQueue {
public:
RequestQueue();
RequestQueue(RequestQueue& origQueue); // moves the queue contents to the new queue
virtual ~RequestQueue();
void enqueue(RequestRecord* request); // "request" must not be NULL
RequestRecord* dequeue();
void putAtHead(RequestRecord* request); // "request" must not be NULL
RequestRecord* findByCSeq(unsigned cseq);
Boolean isEmpty() const { return fHead == NULL; }
private:
RequestRecord* fHead;
RequestRecord* fTail;
};
RequestQueue fRequestsAwaitingConnection, fRequestsAwaitingResponse;
private:
string m_strServerIp;
int m_nPort;
// 协议解析
unsigned int m_nStatus;
unsigned int m_nContenLength;
string m_strHeader;
string m_strCookie;
//发送缓冲区
unsigned char m_vPkgData[1500]; //MTU 1500 1440
int m_vPkgLen;
responseHandler* m_pHandler;
TaskToken m_TimeoutTask;
TaskToken m_HeartbeatTask;
public:
string DeviceSN;
bool isControlBox;
int DeviceType;
string DeviceName;
string DeviceMac;
string SessionID;
int Upload;
int Fre;
int ACEnable;
int DHCP;
string IpAddr;
string GateWay;
string NetMask;
string DNS1;
string DNS2;
int PortNum;
int CollectEnable[64];
int PortState[64];
int PortAC[64];
string Dev;
int FanLevel;
int Open1;
int Open2;
int Relay1State;
int Relay2State;
int AC;
string Time;
int AlarmNum;
string AlarmDescription;
string AlarmTime;
int AlarmPort;
};
|
3744ad666c9ed6e7ea567a8cd910bb2181affbc3 | b11366dcda38475a86078913bb12882af2a86cd7 | /gbsgui/framework/GLang_EN.hpp | 2b128a1d500e34b39a29efc67338fd65ce7f5744 | [] | no_license | Khanhtv97/escale | 669b2b1e59a4773fbf9295666bd7f52b6e8178c4 | 12d1911f8a3a483a378c7ed6726df2ddba9ec0ad | refs/heads/master | 2022-08-15T07:46:35.466752 | 2020-04-15T10:25:53 | 2020-04-15T10:25:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 32,950 | hpp | GLang_EN.hpp | //////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) GBS 2012 All Right Reserved, http://gbs-jsc.com. //
// This source is subject to the GBS Permissive License. Please see the License.txt //
// file for more information. //
// //
// file: GLang_EN.hpp //
//////////////////////////////////////////////////////////////////////////////////////
#ifndef G_L_EN_HPP_
#define G_L_EN_HPP_
#include <string>
using namespace std;
#include "GLanguage.hpp"
//namespace GBS {
//namespace STM {
//namespace Framework {
//////////////////////////////////////////////////////////////////////////////////////
void GLanguage::Initialize_EN(string* l)
{
l[_L_OK] .assign("OK");
l[_L_CANCEL] .assign("Cancel");
l[_L_CANCEL1] .assign("Cancel");
l[_L_YES] .assign("Yes");
l[_L_NO] .assign("No");
l[_L_DENY] .assign("Deny");
l[_L_DENY1] .assign("Cancel");
l[_L_IGNORE] .assign("Ignore");
l[_L_DVBS] .assign("Digital Video Broadcasting — Satellite");
l[_L_GUIDE_BACK_TO_MENU] .assign("Previous Menu");
l[_L_ON] .assign("On");
l[_L_OFF] .assign("Off");
l[_L_LOCK] .assign("Lock");
l[_L_UNLOCK] .assign("Unlock");
l[_L_AUTO] .assign("Auto");
l[_L_RESET] .assign("Reset");
l[_L_WATTING] .assign("Please wait a moment .");
l[_L_SAVE] .assign("Save");
l[_L_SAVING] .assign("Saving ...");
l[_L_LOCKUNLOCK] .assign("Lock / Unlock");
l[_L_DEFAULT] .assign("Default");
l[_L_PRESS_OK] .assign("Press OK");
//GUIDE
l[_L_GUIDE_DELETE] .assign("Delete");
l[_L_GUIDE_DELETE_ALL] .assign("Delete All");
l[_L_GUIDE_SPACE] .assign("Space");
l[_L_GUIDE_EXIT] .assign("Exit");
l[_L_GUIDE_SORT] .assign("Sort");
l[_L_GUIDE_SORT_AZ] .assign("Sort A-Z");
l[_L_GUIDE_SORT_ZA] .assign("Sort Z-A");
l[_L_GUIDE_FIND] .assign("Find");
l[_L_GUIDE_ADD] .assign("Add");
l[_L_GUIDE_MOVE] .assign("Move");
l[_L_GUIDE_ADD_SYMBOL] .assign("Add Symbol");
//COMMON
l[_L_CYCLE] .assign("Cycle");
l[_L_CYCLE_ONCE] .assign("Once");
l[_L_CYCLE_DAILY] .assign("Daily");
l[_L_CYCLE_WEEKLY] .assign("Weekly");
l[_L_MODE] .assign("Mode");
l[_L_MODE_ALARM] .assign("Alarm");
l[_L_MODE_STANDBY] .assign("Standby");
l[_L_MODE_RECORD] .assign("Record");
l[_L_MODE_NOT_DEFINED] .assign("Not Defined");
l[_L_NO_CHANNEL] .assign("No Channel");
l[_L_NO_SIGNAL] .assign("No Signal");
l[_L_NO_AUDIO] .assign("No Audio Signal ");
l[_L_SCRAMBLE_CHANNEL] .assign("Scramble channel");
l[_L_SIGNAL_NOT_GOOD] .assign("Signal Quality Low");
//MAIN MENU
l[_L_MAIN_MENU_CHANNEL_MANAGER] .assign("Channel Manager");
l[_L_MAIN_MENU_CHANNEL_MANAGER_CHANNEL_LIST] .assign("Channel List");
l[_L_MAIN_MENU_CHANNEL_MANAGER_EDIT_FAV_CHANNELS] .assign("Edit Favorite Channel");
l[_L_MAIN_MENU_CHANNEL_MANAGER_PIP_DUAL_TV] .assign("PIP - Dual TV");
l[_L_MAIN_MENU_INSTALLATION] .assign("Installation");
l[_L_MAIN_MENU_INSTALLATION_CHANNEL_SEARCH] .assign("Channel Search");
l[_L_MAIN_MENU_INSTALLATION_AUTO_SEARCH] .assign("Auto Search");
l[_L_MAIN_MENU_INSTALLATION_MANUAL_SEARCH] .assign("Manual Search");
l[_L_MAIN_MENU_INSTALLATION_TRANSPONDER_LIST] .assign("Transponder List");
l[_L_MAIN_MENU_INSTALLATION_FACTORY_RESET] .assign("Factory Reset");
l[_L_MAIN_MENU_INSTALLATION_DECODER_INFO] .assign("Decoder Information");
l[_L_MAIN_MENU_INSTALLATION_VIEWING_CARD] .assign("Viewing Card");
l[_L_MAIN_MENU_YOUR_PREFERENCES] .assign("Setting");
l[_L_MAIN_MENU_YOUR_PREFERENCES_LANGUAGE_SETTING] .assign("Language Setting");
l[_L_MAIN_MENU_YOUR_PREFERENCES_TV_SETTINGS] .assign("STB Setting");
l[_L_MAIN_MENU_YOUR_PREFERENCES_PARENTAL_CONTROL] .assign("Parental Control");
l[_L_MAIN_MENU_YOUR_PREFERENCES_DISPLAY_SETTING] .assign("Display Setting");
l[_L_MAIN_MENU_YOUR_PREFERENCES_TIMER_MANAGER] .assign("Timer Manager");
l[_L_MAIN_MENU_MAIL_BOX] .assign("Mail Box");
l[_L_MAIN_MENU_UTILITIES] .assign("Utilities");
l[_L_MAIN_MENU_GAMES_GSNAKE] .assign("Snake");
// Utilities
l[_L_UTILITIES_MEDIA] .assign("Movie / Music");
l[_L_UTILITIES_IMAGE] .assign("Image Viewer");
l[_L_IMAGE_UNABLE_OPEN_FILE] .assign("Unable open this file");
l[_L_GAMES_HIGHSCORE] .assign("High score");
l[_L_GAMES_SETTING] .assign("Settings");
l[_L_GAMES_GUIDE_SPEED] .assign("Game Speed");
l[_L_GAMES_GUIDE_MODE] .assign("Game Mode");
l[_L_GAMES_GUIDE_MODE_DETAIL_1] .assign("Game Mode 1");
l[_L_GAMES_GUIDE_MODE_DETAIL_2] .assign("Game Mode 2");
l[_L_GAMES_SETTING_SPEED_LOW] .assign("Slow");
l[_L_GAMES_SETTING_SPEED_MED] .assign("Normal");
l[_L_GAMES_SETTING_SPEED_HI] .assign("Fast");
l[_L_GAMES_SETTING_MODE_NONE] .assign("Free run");
l[_L_GAMES_SETTING_MODE_MAPS] .assign("Maps");
l[_L_GAMES_GUIDE_PAUSE] .assign("Pause");
l[_L_GAMES_GUIDE_CHANGE_PAGE] .assign("Change page");
l[_L_GAMES_ERR_NO_RECORD] .assign("No new record !");
l[_L_GAMES_SUDOKU] .assign("Sudoku");
l[_L_GAMES_LEVEL_TITLE] .assign("Level : ");
l[_L_GAMES_TIMER_TITLE] .assign("Timer : ");
l[_L_GAMES_NEW_PUZZLE_TITLE] .assign("New Puzzle");
l[_L_GAMES_EASY] .assign("Easy");
l[_L_GAMES_MEDIUM] .assign("Medium");
l[_L_GAMES_HARD] .assign("Hard");
l[_L_GAMES_CLEAR] .assign("Clear");
l[_L_GAMES_REPLAY] .assign("Replay");
l[_L_GAMES_CONGRATULATION] .assign("Congratulation");
l[_L_GAMES_SOLVED] .assign("Game is solved !");
l[_L_GAMES_LINE] .assign("Line");
l[_L_GAMES_LINE_NEXT] .assign("Next ball");
l[_L_GAMES_LINE_BALL] .assign("Ball :");
l[_L_GAMES_LINE_SCORE] .assign("Score :");
l[_L_GAMES_LINE_MOVE_SELECT] .assign("Select/Move");
l[_L_GAMES_LINE_GAME_OVER] .assign("Game Over");
//Chinese Chess game
l[_L_GAMES_CHINESECHESS] .assign("Chess");
l[_L_GAMES_COMPUTER_WIN] .assign("Computer Win ");
l[_L_GAMES_HUMAN_WIN] .assign("Human Win ");
l[_L_GAMES_COMPUTER_MOVE] .assign("Computer move ");
l[_L_GAMES_HUMAN_MOVE] .assign("Human move ");
l[_L_GAMES_SOKOBAN] .assign("Sokoban");
l[_L_GAMES_SOKOBAN_PUSH] .assign("Push");
l[_L_GAMES_SOKOBAN_NEXT_LEVEL] .assign("Next Level");
l[_L_GAMES_SOKOBAN_UNDO] .assign("Undo");
//FormDisplaySetting
l[_L_FORM_DISPLAY_SETTING_TITLE] .assign("Display Setting");
l[_L_FORM_DISPLAY_SETTING_DISPLAY_TRANSPARENCY] .assign("Display Transparency");
l[_L_FORM_DISPLAY_SETTING_CHANNEL_BANNER_TIMEOUT] .assign("Channel Banner Timeout");
l[_L_FORM_DISPLAY_SETTING_TIME_ZONE] .assign("Time Zone");
l[_L_FORM_DISPLAY_SETTING_ALWAYS] .assign("Always");
//FormLanguageSetting
l[_L_FORM_LANGUAGE_SETTING_LANGUAGE_SETTING_TITLE] .assign("Language Setting");
l[_L_FORM_LANGUAGE_SETTING_MENU_LANGUAGE] .assign("Menu Language");
l[_L_FORM_LANGUAGE_SETTING_AUDIO_LANGUAGE] .assign("Audio Language");
l[_L_FORM_LANGUAGE_SETTING_SUBTITLE] .assign("Subtitle");
l[_L_FORM_LANGUAGE_SETTING_SUBTITLE_LANGUAGE] .assign("Subtitle Language");
l[_L_FORM_LANGUAGE_SETTING_VIETNAMESE] .assign("Vietnamese");
l[_L_FORM_LANGUAGE_SETTING_ENGLISH] .assign("English");
l[_L_FORM_LANGUAGE_SETTING_FIRST_LANGUAGE] .assign("First Language");
l[_L_FORM_LANGUAGE_SETTING_SECOND_LANGUAGE] .assign("Second Language");
l[_L_FORM_LANGUAGE_SETTING_TELETEXT] .assign("Teletext");
l[_L_FORM_LANGUAGE_SETTING_TELETEXT_LANGUAGE] .assign("Teletext Language");
//Form Default Setting
l[_L_FORM_DEFAULT_SETTING_CONFIRM] .assign("Are you sure ?");
l[_L_FORM_DEFAULT_SETTING_WARNING] .assign("All data settings and channels will be lost");
l[_L_FORM_DEFAULT_SETTING_WAITING] .assign("Resetting to factory data");
//Form Letter Box
l[_L_FORM_LETTER_BOX_TITLE] .assign("Mail Box");
l[_L_FORM_LETTER_BOX_MESS] .assign("No message received.");
//Form Parental control
l[_L_FORM_PARENTAL_CONTROL_TITLE] .assign("Parental Control");
l[_L_FORM_PARENTAL_CONTROL_MORALITY_LEVEL] .assign("Morality Level");
l[_L_FORM_PARENTAL_CONTROL_DECODER_LOCK] .assign("Decoder Lock");
l[_L_FORM_PARENTAL_CONTROL_CHANNEL_LOCK] .assign("Channel Lock");
l[_L_FORM_PARENTAL_CONTROL_CHANGE_PARENTAL_CODE] .assign("Change PIN Code");
l[_L_FORM_PARENTAL_CONTROL_UNDER_10_AGE] .assign("Not recommended under 10 age");
l[_L_FORM_PARENTAL_CONTROL_UNDER_12_AGE] .assign("Not recommended under 12 age");
l[_L_FORM_PARENTAL_CONTROL_UNDER_16_AGE] .assign("Not recommended under 16 age");
l[_L_FORM_PARENTAL_CONTROL_UNDER_18_AGE] .assign("Not recommended under 18 age");
//Form Parental control
l[_L_FORM_CHANGE_PASSWORD_CREATE_PARENTAL_CODE] .assign("New PIN");
l[_L_FORM_CHANGE_PASSWORD_CONFIRM] .assign("Confirm");
//Form Notification Change Password
l[_L_FORM_NOTIFICATION_PASSWORD_CHANGED_SUCCESS] .assign("PIN code changed.");
l[_L_FORM_NOTIFICATION_PASSWORD_CHANGED_FAIL] .assign("PIN code mismatched.");
//Form Authentication of Password
l[_L_FORM_AUTHEN_PASSWORD_ENTER_PASSWORD] .assign("Enter Password");
l[_L_FORM_AUTHEN_PASSWORD_RETRY] .assign("Retry");
l[_L_FORM_AUTHEN_PASSWORD_TITLE_SYSTEM_SETTING] .assign("System Setting");
//Form SetTopBox info
l[_L_FORM_DECODER_INFORMATION_TITLE] .assign("Decoder Information");
l[_L_FORM_DECODER_INFORMATION_MODEL_NAME] .assign("Model Name");
l[_L_FORM_DECODER_INFORMATION_SOFTWARE_VERSION] .assign("Software Version");
l[_L_FORM_DECODER_INFORMATION_LOADER_VERSION] .assign("Loader Version");
l[_L_FORM_DECODER_INFORMATION_DECODER_CA_SN] .assign("Decoder CA S/N");
l[_L_FORM_DECODER_INFORMATION_CAK_VERSION] .assign("CAK Version");
l[_L_FORM_DECODER_INFORMATION_SOFTWARE_STATE] .assign("Software State");
l[_L_FORM_DECODER_INFORMATION_PROJECT_INFORMATION] .assign("Project Information");
l[_L_FORM_DECODER_INFORMATION_DECODER_SERIAL_NUMBER] .assign("Decoder Serial Number");
l[_L_FORM_DECODER_INFORMATION_USAGE_ID] .assign("Usage ID");
l[_L_FORM_DECODER_INFORMATION_LAST_UPDATE] .assign("Last Update");
l[_L_FORM_DECODER_INFORMATION_GUIDE_UPDATE_SOFTWARE] .assign("OTA Update Software");
l[_L_FORM_DECODER_INFORMATION_GUIDE_UPDATE_SOFTWARE_USB] .assign("USB Update Software");
l[_L_FORM_DECODER_INFORMATION_SOFTWARE_STATE_MANUFACTURE] .assign("Manufacture");
l[_L_FORM_DECODER_INFORMATION_SOFTWARE_STATE_DECLARATION] .assign("Declaration");
l[_L_FORM_DECODER_INFORMATION_SOFTWARE_STATE_REGISTRATION] .assign("Registration");
l[_L_FORM_DECODER_INFORMATION_SOFTWARE_STATE_UNKNOWN] .assign("Unknown");
//Form TV Settings
l[_L_FORM_TV_SETTINGS_TITLE] .assign("STB Settings");
l[_L_FORM_TV_SETTINGS_TV_STANDARD] .assign("TV Standard");
l[_L_FORM_TV_SETTINGS_TV_RESOLUTION] .assign("TV Resolution");
l[_L_FORM_TV_SETTINGS_ERR_RECOVERY] .assign("Error Recovery");
l[_L_FORM_TV_SETTINGS_SCREEN_RATIO] .assign("Screen Ratio");
l[_L_FORM_TV_SETTINGS_ASPECT_CONVERSION] .assign("Wide Mode");
l[_L_FORM_TV_SETTINGS_DIGITAL_DOLBY] .assign("Digital Dolby");
l[_L_FORM_TV_SETTINGS_RF_OUTPUT] .assign("RF Output");
l[_L_FORM_TV_SETTINGS_RF_CHANNEL] .assign("RF Channel");
l[_L_FORM_TV_SETTINGS_ADJUST_VIDEO] .assign("Adjust Video");
l[_L_FORM_TV_SETTINGS_LCN] .assign("LCN");
l[_L_FORM_TV_SETTINGS_ANTENPOWER] .assign("Antenna Power 5V");
l[_L_FORM_TV_SETTINGS_SHORT_CIRCUIT] .assign("Failed, please check antenna!");
l[_L_FORM_TV_SETTINGS_FREQUENCY_MODE] .assign("Frequency Mode");
l[_L_FORM_TV_SETTINGS_AUTOSCAN_MODE] .assign("Auto Scan Mode");
l[_L_FORM_TV_SETTINGS_CONTROL_VOLUME] .assign("Intelligent Volume Control");
l[_L_FORM_HDTV_RESIZE_LETTER_BOX] .assign("Letter Box");
l[_L_FORM_HDTV_RESIZE_PAN_SCAN] .assign("Pan & Scan");
l[_L_FORM_HDTV_RESIZE_COMBINED] .assign("Combined");
//VideoControl
l[_L_VIDEO_CONTROL_TITLE] .assign("Video Settings");
l[_L_VIDEO_CONTROL_BRIGHTNESS] .assign("Brightness");
l[_L_VIDEO_CONTROL_COLOR] .assign("Color");
l[_L_VIDEO_CONTROL_CONTRAST] .assign("Contrast");
l[_L_VIDEO_CONTROL_DISPLAY_TRANSPARENCY] .assign("Display Transparency");
l[_L_VIDEO_CONTROL_ERR_RECOVERY_HIGH] .assign("High");
l[_L_VIDEO_CONTROL_ERR_RECOVERY_FULL] .assign("Full");
//FormChannelList
l[_L_FORM_CHANNEL_LIST_TITLE] .assign("Channel List");
l[_L_FORM_CHANNEL_LIST_TV_ALL] .assign("TV - All");
l[_L_FORM_CHANNEL_LIST_ENTER_NAME] .assign("Enter name: ");
l[_L_FORM_CHANNEL_LIST_GUIDE_FREE] .assign("Free");
l[_L_FORM_CHANNEL_LIST_COPY] .assign("Copy");
l[_L_FORM_CHANNEL_LIST_PASTE] .assign("Paste");
l[_L_FORM_CHANNEL_LIST_SORT_AND_PASTE] .assign("Sort / Paste");
l[_L_FORM_CHANNEL_LIST_OK_EXIT] .assign("Save / Exit");
l[_L_FORM_CHANNEL_LIST_EDIT] .assign("Rename");
l[_L_FORM_CHANNEL_LIST_DELETE] .assign("Delete");
l[_L_FORM_CHANNEL_LIST_GUIDE_SCRAMBLE] .assign("Scramble");
l[_L_FORM_CHANNEL_LIST_GUIDE_ALL] .assign("All");
l[_L_FORM_CHANNEL_LIST_GUIDE_STRING_SEARCH] .assign("String search");
l[_L_FORM_CHANNEL_LIST_TITLE_SORT] .assign("Sort");
l[_L_FORM_CHANNEL_LIST_BACKUP_RESTORE] .assign("Export / import channel");
l[_L_FORM_CHANNEL_LIST_BACKUP_DATA] .assign("Export channel");
l[_L_FORM_CHANNEL_LIST_RESTORE_DATA] .assign("Import channel");
l[_L_FORM_CHANNEL_LIST_RESTORE_DATA_BY_USB] .assign("Import channel list from USB");
l[_L_FORM_CHANNEL_LIST_BACKUP_DATA_DONE] .assign("Export channel successful");
l[_L_FORM_CHANNEL_LIST_RESTORE_DATA_DONE] .assign("Import channel successful");
l[_L_FORM_CHANNEL_LIST_EDIT_CHANNEL_NUMBER] .assign("Edit channel number");
l[_L_FORM_EDIT_CHANNEL_NUMBER_CURRENT] .assign("Current nummber :");
l[_L_FORM_EDIT_CHANNEL_NUMBER_NEW] .assign("New nummber : ");
//Form show error lock channel mess
l[_L_FORM_SHOW_LOCK_CHANNEL_ERROR_MESS1] .assign("To enable this function,");
l[_L_FORM_SHOW_LOCK_CHANNEL_ERROR_MESS2] .assign("please create your parental code");
//FormSortChannel
l[_L_FORM_SORT_CHANNEL_SORT_BY_DEFAULT] .assign("Sort by default");
l[_L_FORM_SORT_CHANNEL_SORT_BY_Aa_Zz] .assign("Sort by Aa - Zz");
l[_L_FORM_SORT_CHANNEL_SORT_BY_Zz_Aa] .assign("Sort by Zz - Aa");
//Form Full Channel List
l[_L_FORM_FULL_CHANNEL_LIST_LOCK_ERROR_MESS] .assign("[Channel lock] is inactive");
//Form Fav List
l[_L_FORM_FAVORITE_LIST_TITLE] .assign("Favorite List");
l[_L_FORM_FAVORITE_LIST_RENAME_ERROR] .assign("Duplicate group name.");
l[_L_FORM_FAVORITE_LIST_1] .assign("Movie");
l[_L_FORM_FAVORITE_LIST_2] .assign("Children");
l[_L_FORM_FAVORITE_LIST_3] .assign("News");
l[_L_FORM_FAVORITE_LIST_4] .assign("Healthy");
l[_L_FORM_FAVORITE_LIST_5] .assign("Sport");
l[_L_FORM_FAVORITE_LIST_6] .assign("Music");
l[_L_FORM_FAVORITE_LIST_7] .assign("Economic");
l[_L_FORM_FAVORITE_LIST_8] .assign("Technology");
//FORM MANAGE FAV CHANNEL
l[_L_FORM_MANAGE_FAVORITE_CHANNEL_GUIDE_FAV_LIST] .assign("Favorite List");
l[_L_FORM_MANAGE_FAVORITE_CHANNEL_GUIDE_RENAME_GROUP] .assign("Rename Group");
l[_L_FORM_MANAGE_FAVORITE_CHANNEL_ALL_CHANNEL] .assign("TV All");
l[_L_FORM_MANAGE_FAVORITE_CHANNEL_ALREADY] .assign("This channel already exists in the favorite list");
//FORM TRANSPONDER LIST
l[_L_FORM_TRANSPONDER_LIST_TITLE] .assign("Transponder List");
l[_L_FORM_TRANSPONDER_LIST_LIST_CHANNEL_TITLE] .assign("Channel");
l[_L_FORM_TRANSPONDER_LIST_LIST_EDIT_TRANSPONDER] .assign("Edit Transponder");
l[_L_FORM_TRANSPONDER_LIST_LIST_DELETE_TRANSPONDER] .assign("Delete Transponder");
l[_L_FORM_TRANSPONDER_LIST_LIST_NEW_TRANSPONDER] .assign("New Transponder");
//FORM NEW TRANSPONDER
l[_L_FORM_NEW_TRANSPONDER_NEW_TP_TITLE] .assign("New Transponder");
l[_L_FORM_NEW_TRANSPONDER_EDIT_TP_TITLE] .assign("Edit Transponder");
l[_L_FORM_NEW_TRANSPONDER_FREQUENCY] .assign("Frequency");
l[_L_FORM_NEW_TRANSPONDER_SYMBOL_RATE] .assign("Symbol Rate");
l[_L_FORM_NEW_TRANSPONDER_POLARIZATION] .assign("Polarization");
l[_L_FORM_NEW_TRANSPONDER_FEC] .assign("Fec");
l[_L_FORM_NEW_TRANSPONDER_MODULATION] .assign("Modulation");
l[_L_FORM_NEW_TRANSPONDER_TRANSPONDER_EXIST] .assign("Transponder already exist");
//FORM CHANNEL SCAN
l[_L_FORM_CHANNEL_SCAN_TITLE] .assign("Search");
l[_L_FORM_CHANNEL_SCAN_TV_CHANNEL] .assign("TV");
l[_L_FORM_CHANNEL_SCAN_TV_RADIO] .assign("Radio");
l[_L_FORM_CHANNEL_SCAN_CHANNEL_NUM] .assign("Channel Number: ");
l[_L_FORM_CHANNEL_SCAN_SEARCH_FAIL] .assign("No channel found");
l[_L_FORM_CHANNEL_SCAN_SEARCH_SUCCESS] .assign("Search Success");
l[_L_FORM_CHANNEL_SCAN_SEARCH_CONTINUE] .assign("Press OK to continue.");
l[_L_FORM_CHANNEL_SCAN_SEARCH_SAVING] .assign("Successful. Now saving...");
//FORM CHANNEL SCAN SETTINGS
l[_L_FORM_CHANNEL_SCAN_SETTINGS_TITLE] .assign("Channel Search");
l[_L_FORM_CHANNEL_SCAN_SETTINGS_SATELLITE] .assign("Satellite");
l[_L_FORM_CHANNEL_SCAN_SETTINGS_LNB_FREQUENCY] .assign("LNB Frequency");
l[_L_FORM_CHANNEL_SCAN_SETTINGS_LNB_POWER] .assign("LNB Power");
l[_L_FORM_CHANNEL_SCAN_SETTINGS_22KHZ_TONE] .assign("22 Khz Tone");
l[_L_FORM_CHANNEL_SCAN_SETTINGS_TRANSPONDER_LIST] .assign("Transponder List");
l[_L_FORM_MANUAL_SCAN_SETTING_TITLE] .assign("Manual Scan");
l[_L_FORM_MANUAL_SCAN_SETTING_CHANNEL_NO] .assign("Channel No");
l[_L_FORM_SCAN_DVBT_FREQUENCY] .assign("DVB-T Scan Frequency: %d.%d MHz, BW: %d MHz");
l[_L_FORM_SCAN_DVBT2_FREQUENCY] .assign("DVB-T2 Scan Frequency: %d.%d MHz, BW: %d MHz");
l[_L_FORM_SCAN_DVBC_FREQUENCY] .assign("DVB-C Scan Frequency: %d.%d MHz, BW: %d MHz");
l[_L_FORM_MANUAL_SCAN_SETTING_SCAN_FREQUENCY] .assign("Scan Frequency");
l[_L_FORM_DVBC_SCAN_SETTINGS_START_FREQUENCY] .assign("Start Frequency");
l[_L_FORM_DVBC_SCAN_SETTINGS_END_FREQUENCY] .assign("End Frequency");
l[_L_FORM_DVBC_SCAN_SETTINGS_SYMBOL_RATE] .assign("Symbol Rate");
l[_L_FORM_DVBC_SCAN_SETTINGS_MODULATION] .assign("Const.");
l[_L_FORM_DVBC_SCAN_SETTINGS_NETWORK] .assign("Network");
l[_L_FORM_SCAN_SETTINGS_SYMBOLRATE_LIMIT] .assign("Sym can't be smaller than %d ");
//FORM TIMER MANAGER
l[_L_FORM_TIMER_MANAGER_TITLE] .assign("Timer Manager");
l[_L_FORM_TIMER_MANAGER_TIMER_LIST_TITLE] .assign("Timer List");
l[_L_FORM_TIMER_MANAGER_TIMER_NO_EVENT] .assign("No Event");
l[_L_FORM_TIMER_MANAGER_GUIDE_EDIT_TIMER] .assign("Edit Timer");
l[_L_FORM_ADD_TIMER_TITLE] .assign("Add Timer");
l[_L_FORM_ADD_TIMER_CHANNEL] .assign("Channel");
l[_L_FORM_ADD_TIMER_DATE] .assign("Date");
l[_L_FORM_ADD_TIMER_DATE_SUN] .assign("Sun");
l[_L_FORM_ADD_TIMER_DATE_MON] .assign("Mon");
l[_L_FORM_ADD_TIMER_DATE_TUE] .assign("Tue");
l[_L_FORM_ADD_TIMER_DATE_WED] .assign("Wed");
l[_L_FORM_ADD_TIMER_DATE_THU] .assign("Thu");
l[_L_FORM_ADD_TIMER_DATE_FRI] .assign("Fri");
l[_L_FORM_ADD_TIMER_DATE_SAT] .assign("Sat");
l[_L_FORM_ADD_TIMER_START_TIME] .assign("Start Time");
l[_L_FORM_ADD_TIMER_DURATION] .assign("Duration");
l[_L_FORM_ADD_TIMER_SAVE_TIMER] .assign("Save Timer");
l[_L_FORM_DELETE_TIMER_MESS_DELETE_ALL] .assign("Delete all timers ?");
l[_L_FORM_DELETE_TIMER_MESS_DELETE_TIMER] .assign("Delete this timer ?");
l[_L_FORM_SHOW_TIMER_ERROR_MESS] .assign("Start time is invalid.");
l[_L_FORM_SHOW_TIMER_DURATION_ERROR_MESS] .assign("Duration is invalid.");
l[_L_FORM_SHOW_TIMER_DATE_ERROR_MESS] .assign("Start date is invalid.");
l[_L_FORM_SHOW_TIMER_DAY_ERROR_MESS] .assign("Please select a day !");
l[_L_FORM_SHOW_TIMER_DUPLICATE_TIMER_ERROR_MESS] .assign("Same timer already exist!");
l[_L_FORM_SHOW_TIMER_OVERLAPPED_ERROR_MESS] .assign("Timers are overlapped !");
l[_L_FORM_POPUP_EXECUTE_ALARM_MODE_TIMER_MESS] .assign("Channel change will occur in a few seconds.");
l[_L_FORM_POPUP_EXECUTE_RECORD_MODE_TIMER_MESS] .assign("Record is going to start in a few seconds.");
l[_L_FORM_POPUP_EXECUTE_STANDBY_MODE_TIMER_MESS] .assign("Standby mode will occur in a few seconds.");
l[_L_FORM_POPUP_EXECUTE_TIMER_SELECT_BUTTON_MESS] .assign("Press cancel button to abort.");
l[_L_FORM_POPUP_EXECUTE_TIMER_CONFLICT_FREQ_MESS] .assign("Terminate this record ?");
// FORM UPGRADE FIRMWARE
l[_L_FORM_UPGRADE_FIRMWARE_TITLE] .assign("OTA Update");
l[_L_FORM_UPGRADE_FIRMWARE_SATELLITE] .assign("Satellite");
l[_L_FORM_UPGRADE_FIRMWARE_TRANSPONDER_LIST] .assign("Transponder List");
l[_L_FORM_UPGRADE_FIRMWARE_UPDATE_SOFTWARE] .assign("Update Software");
l[_L_FORM_UPGRADE_FIRMWARE_CURRENT_VERSION] .assign("No new software");
l[_L_FORM_UPGRADE_FIRMWARE_WAITTINGS_USB] .assign("Power ON, USB is plugged !");
l[_L_FORM_UPGRADE_FIRMWARE_SUCCESS] .assign("Completed, restart device !");
l[_L_FORM_UPGRADE_FIRMWARE_FAILED] .assign("Failed, please try again !");
l[_L_FORM_UPGRADE_FIRMWARE_FAILED_FORMAT] .assign("File format is not valid !");
l[_L_FORM_UPGRADE_FIRMWARE_FAILED_SIGN] .assign("Failed, incorrect signature !");
//FORM STORAGE INFO
l[_L_FORM_STORAGE_INFO_TITLE] .assign("Storage");
l[_L_FORM_STORAGE_INFO_INFORM_FULL] .assign("Failed, USB is full");
l[_L_FORM_STORAGE_INFO_INFORM_REC_ERROR_MESSAGE] .assign("Total failed blocks: %u");
l[_L_FORM_STORAGE_INFO_INFORM_FILE_OPERATION_INPROGRESS] .assign("File operation in progress !");
l[_L_FORM_STORAGE_INFO_INFORM_CANNOT_MOUNT_USB] .assign("Failed, USB not found !");
l[_L_FORM_STORAGE_INFO_INFORM_CANNOT_DELETE_FILE] .assign("Failed to delete file !");
l[_L_FORM_STORAGE_INFO_INFORM_CANNOT_COPY_FILE] .assign("Failed to copy file !");
l[_L_FORM_STORAGE_INFO_INFORM_CANNOT_RENAME_FILE] .assign("Failed to rename file !");
l[_L_FORM_STORAGE_INFO_INFORM_CANNOT_STOP_RECORDING] .assign("Failed to stop recording !");
l[_L_FORM_STORAGE_INFO_INFORM_CANNOT_STOP_PLAYING] .assign("Failed to stop playing !");
l[_L_FORM_STORAGE_INFO_INFORM_CANNOT_START_PLAYING] .assign("Failed to start playback !");
l[_L_FORM_STORAGE_INFO_INFORM_CHANNEL_LOCKED] .assign("Failed, channel locked !");
l[_L_FORM_STORAGE_INFO_INFORM_COPY_PLAYABLE_FILE_ONLY] .assign("Copy playable file only !");
l[_L_FORM_STORAGE_INFO_INFORM_COPY_FILE_NAME_NOT_VALID] .assign("File name is not valid !");
l[_L_FORM_STORAGE_INFO_INFORM_COPY_DONE] .assign("Copy done !");
l[_L_FORM_STORAGE_INFO_INFORM_HOT_UNPLUG_USB] .assign("USB connection lost");
l[_L_FORM_STORAGE_INFO_INFORM_FILE_NOT_SUPPORT] .assign("Format not support !");
l[_L_FORM_STORAGE_INFO_INFORM_RECORDING_IN_PROGRESS] .assign("Failed, still recording !");
l[_L_FORM_STORAGE_INFO_INFORM_CHANNEL_NOT_EXIST] .assign("Channel is not valid !");
//FORM CONFIRM MESSAGE
l[_L_FORM_CONFIRM_TITLE] .assign("Warning");
l[_L_FORM_CONFIRM_EXIT_RECORD_MESSAGE] .assign("Stop recording ?");
l[_L_FORM_CONFIRM_EXIT_PLAYBACK_MESSAGE] .assign("Exit from playback ?");
l[_L_FORM_CONFIRM_DELETE_FILE_MESSAGE] .assign("Delete this file ?");
l[_L_FORM_CONFIRM_RENAME_FILE_MESSAGE] .assign("Rename this file ?");
l[_L_FORM_CONFIRM_RENAME_FILE_AGAIN_MESSAGE] .assign("Failed, Continue rename this file ?");
l[_L_FORM_CONFIRM_EXIT_GAME_SNAKE] .assign("Exit game ?");
l[_L_FORM_CONFIRM_RESTART_GAME_SNAKE] .assign("Continue game ?");
//FORM INPUT TEXT
l[_L_FORM_INPUT_TITLE] .assign("Text box");
l[_L_FORM_INPUT_STATIC] .assign("Old name: ");
l[_L_FORM_INPUT_DYNAMIC] .assign("New name: ");
l[_L_FORM_INPUT_INFORM_TEXT_LENGTH_MAX] .assign("Maximum of 13 characters !");
// FORM EPG ONE CHANNEL
l[_L_FORM_EPG_ONE_CHANNEL_TITLE] .assign("Program Guide");
l[_L_FORM_EPG_ONE_CHANNEL_GUIDE_EPG_TYPE] .assign("EPG Type Select");
l[_L_FORM_EPG_ONE_CHANNEL_GUIDE_SAVE_TIMER] .assign("Save Timer");
l[_L_FORM_EPG_ONE_CHANNEL_GUIDE_NEXT_DAY] .assign("Next Day");
l[_L_FORM_EPG_ONE_CHANNEL_GUIDE_PREVIOUS_DAY] .assign("Previous");
l[_L_FORM_EPG_ONE_CHANNEL_WARNING_NO_EVENT] .assign("No EPG data");
// FORM EPG ONE CHANNEL
l[_L_FORM_EPG_FULL_TITLE] .assign("Program Guide");
//FORM EPG FULL_TIMER MANAGER
l[_L_FORM_EPG_FULL_TIMER_MANAGER_TITLE] .assign("Reserve");
//KEYBOARD
l[_L_KEYBOARD_TITLE] .assign("Keyboard");
//FORM_REC_PLAYBACK
l[_L_FORM_PLAYBACK_FILE_LIST_TITLE] .assign("Playback List");
//REBOOT
l[_L_REBOOT] .assign("Device is restarting ...");
//FORM STARTUP
l[_L_FORM_STARTUP_MESSSAGE] .assign("Great Bear Stars");
l[_L_FORM_STARTUP_GOTO_SCAN_CHANNEL] .assign("STB is going to scan channel automatically ...");
//FORM INFOCHANNEL
l[_L_FORM_INFO_CHANNEL_TITTLE] .assign("Channel Information");
l[_L_FORM_INFO_CHANNEL_NAME] .assign("Channel Name");
l[_L_FORM_INFO_CHANNEL_FREQ] .assign("Frequency");
l[_L_FORM_INFO_CHANNEL_NUMBER] .assign("Channel Number");
l[_L_FORM_INFO_CHANNEL_SERVICE_ID] .assign("Service ID");
l[_L_FORM_INFO_CHANNEL_NETWORK_ID] .assign("Network ID");
l[_L_FORM_INFO_CHANNEL_TUNER_STATUS] .assign("Tuner Status");
l[_L_FORM_INFO_CHANNEL_TUNER_NONE] .assign("NONE");
l[_L_FORM_INFO_CHANNEL_TUNER_UNLOCKED] .assign("UNLOCKED");
l[_L_FORM_INFO_CHANNEL_TUNER_LOCKED] .assign("LOCKED");
l[_L_FORM_INFO_CHANNEL_TUNER_IDLE] .assign("IDLE");
l[_L_FORM_INFO_CHANNEL_TUNER_STANDBY] .assign("STANDBY");
l[_L_FORM_INFO_CHANNEL_TUNER_SCANNING] .assign("SCANNING");
//FORM PIP CONTROL
l[_L_FORM_PIP_CONTROL_TITTLE] .assign("PIP Control");
l[_L_FORM_PIP_CONTROL_CHANN] .assign("Open PIP");
l[_L_FORM_PIP_CONTROL_CLOSE] .assign("Close PIP");
l[_L_FORM_PIP_CONTROL_OUTPUT] .assign("Output");
l[_L_FORM_PIP_CONTROL_POS] .assign("Position");
l[_L_FORM_PIP_CONTROL_SWAP] .assign("Swap view");
l[_L_FORM_PIP_OUTPUT_HDMI] .assign("HDMI");
l[_L_FORM_PIP_OUTPUT_AV] .assign("AV");
l[_L_FORM_PIP_OUTPUT_ALL] .assign("All");
l[_L_FORM_PIP_CONTROL_POS_TOPLEFT] .assign("Top - Left");
l[_L_FORM_PIP_CONTROL_POS_TOPRIGHT] .assign("Top - Right");
l[_L_FORM_PIP_CONTROL_POS_BOTLEFT] .assign("Bottom - Left");
l[_L_FORM_PIP_CONTROL_POS_BOTRIGHT] .assign("Bottom - Right");
l[_L_FORM_ERROR_PIP_IN_PROGRESS] .assign("Failed, PIP in progress !");
l[_L_FORM_PIP_CONTROL_SWAP_WARNING_PLAYBACK] .assign("Can not swap view");
l[_L_FORM_PIP_CONTROL_OPEN_PLAYING_CHANNEL] .assign("Channel is playing in main TV");
l[_L_FORM_PIP_CONTROL_OPEN_PIP_CHANNEL] .assign("Channel is playing in PIP");
l[_L_FORM_PIP_CONTROL_NO_SIGNAL_FOUND] .assign("No signal found!");
l[_L_FORM_PIP_CONTROL_OPEN_AUDIO_CHANNEL] .assign("Can't open a radio channel!");
l[_L_FORM_PIP_CONTROL_SWAP_AUDIO_CHANNEL] .assign("Can't swap a radio channel!");
l[_L_FORM_PIP_CONTROL_DUAL_TV] .assign("Open Dual TV");
l[_L_FORM_PIP_CONTROL_CLOSE_DUAL_TV] .assign("Close Dual TV");
l[_L_FORM_ERROR_DUAL_TV_IN_PROGRESS] .assign("Failed, Dual TV in progress !");
//FORM_CHANNEL_LOCK_CONTROL
l[_L_FORM_CHANNEL_LOCK_CONTROL_TITTLE] .assign("Lock Control");
l[_L_FORM_CHANNEL_LOCK_CONTROL_TYPE] .assign("Lock Type");
l[_L_FORM_CHANNEL_LOCK_CONTROL_START] .assign("Start");
l[_L_FORM_CHANNEL_LOCK_CONTROL_END] .assign("End");
l[_L_FORM_CHANNEL_LOCK_CONTROL_LOCK] .assign("Lock");
l[_L_FORM_CHANNEL_LOCK_CONTROL_UNLOCK] .assign("Unlock");
l[_L_FORM_CHANNEL_LOCK_CONTROL_ALL] .assign("All Time");
l[_L_FORM_CHANNEL_LOCK_CONTROL_EDIT] .assign("Edit");
//FRONT PANEL
l[_L_FRONT_PANEL_POWER_OFF] .assign("On / Off");
l[_L_FRONT_PANEL_ADJUST_VOLUME] .assign("Volume");
l[_L_FRONT_PANEL_SCAN_AUTO] .assign("Scan Auto");
//DVR PLAYING
l[_L_PLAYING_SPEED_UP] .assign("1X");
l[_L_PLAYING_SPEED_DOWN] .assign("-1X");
l[_L_PLAYING_CHANGE_LOOP] .assign("Loop");
l[_L_OPEN_PLAYBACK_LIST] .assign("Select file");
//DEMO VERSION
l[_L_DEMO_VERSION] .assign("GBS-HD DEMO VERSION");
l[_L_DEMO_VERSION_TIME_REACHED] .assign("Demo expired, STB is stopping!");
}
//////////////////////////////////////////////////////////////////////////////////////
//} //Framework
//} //STM
//} //GBS
#endif /* G_L_EN_HPP_ */
|
fd942646eebffb39359b33ec17ba1fbb414916ae | 67b3a346e44787741e3eb2e8b2fc889ef580bcba | /WORD_OCC.CPP | 2cca8b58d6154c445a73450f8675c771e4b2c2ee | [
"MIT"
] | permissive | harshsiloiya98/cplusplus-random | 30d6d4f42c2f31aedab3d9b834d9495146481bb6 | 98d7410be82d9e7e79e10a87dec05d7bec2e75f5 | refs/heads/master | 2021-01-16T18:55:13.992706 | 2017-08-12T17:15:06 | 2017-08-12T17:15:06 | 100,126,475 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 566 | cpp | WORD_OCC.CPP | #include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
void main()
{
clrscr();
char txt[50], word[15], temp[15];
int count = 0;
cout<<"Enter text: ";
gets(txt);
cout<<"\nEnter word you want to search: ";
gets(word);
int len = strlen(txt);
for (int i = 0; i < len; i++)
{
for (int j = 0; txt[i] != ' ' && txt[i] != '\0'; j++,i++)
temp[j] = txt[i];
temp[j]='\0';
if(strcmp(temp,word) == 0)
count++;
}
cout<<"\nNo. of occurrences of the word "<<word<<": "<<count;
getch();
} |
850386ed0e9b6a5cfc6379512434b28a5580749f | 1c7762a6996a175695e27bae80c900c47cceb92d | /Garnet/src/Garnet/ExecTime.cpp | ebd36579a06b93f233a698dc536e119c7d9f5f50 | [] | no_license | kojirosugiura/Darwin | 553d0c50a97e9b2601158276b0f619a1ed32a333 | 9b0251c689d1b28a67b4caf6843c69e6c42c2cce | refs/heads/master | 2020-12-11T07:31:10.867071 | 2016-05-24T16:46:39 | 2016-05-24T16:46:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,924 | cpp | ExecTime.cpp | #include <string>
#include <map>
#include <cstdint>
#include <Garnet/Garnet.h>
namespace {
const Garnet::ExecTimeEntry _execTimeDefault[] = {
{ "end", 1 , },
{ "start", 1 , },
{ "printhash_v1d", 1000 , },
{ "printhash_i1b", 1000 , },
{ "printhash_i3b", 1000 , },
{ "printhash_a1d", 1000 , },
{ "printvalue_v1d", 1000 , },
{ "printvalue_s", 1000 , },
{ "printvalue_a1d", 1000 , },
{ "v1d_zero", 1 , },
{ "v1d_move_v1d", 1 , },
{ "v1d_avgpixel_i1b", 383 , },
{ "v1d_maxpixel_i1b", 1551 , },
{ "v1d_minpixel_i1b", 876 , },
{ "v1d_fgarea_i1b", 880 , },
{ "v1d_bgarea_i1b", 880 , },
{ "v1d_fgareav_i1b_v1d", 880 , },
{ "v1d_bgareav_i1b_v1d", 880 , },
{ "v1d_masscenterbx_i1b", 880 , },
{ "v1d_masscenterby_i1b", 880 , },
{ "v1d_psnr_i1b_i1b", 3375 , },
{ "v1d_vnegate_v1d", 8 , },
{ "v1d_vadd_v1d_v1d", 3 , },
{ "v1d_valgebraicprod_v1d_v1d", 4 , },
{ "v1d_valgebraicsum_v1d_v1d", 12 , },
{ "v1d_vdiff_v1d_v1d", 4 , },
{ "v1d_vlogicalprod_v1d_v1d", 6 , },
{ "v1d_vlogicalsum_v1d_v1d", 8 , },
{ "v1d_vsubtract_v1d_v1d", 2 , },
{ "v1d_distance_v1d_v1d_v1d_v1d", 6 , },
{ "v1d_select_v1d_v1d", 6 , },
{ "v1d_select_v1d_v1d_v1d_v1d", 6 , },
{ "v1d_adjust_v1d", 4 , },
{ "v1d_averagea_a1d", 4 , },
{ "v1d_invert_v1d", 2 , },
{ "v1d_maxa_a1d", 5 , },
{ "v1d_mina_a1d", 5 , },
{ "v1d_msea_a1d_v1d", 5 , },
{ "v1d_numa_a1d", 5 , },
{ "v1d_numeqa_a1d_v1d", 5 , },
{ "v1d_numgreatera_a1d_v1d", 5 , },
{ "v1d_numgreatereqa_a1d_v1d", 5 , },
{ "v1d_numlessa_a1d_v1d", 5 , },
{ "v1d_numlesseqa_a1d_v1d", 5 , },
{ "v1d_percentv_v1d_v1d", 5 , },
{ "v1d_rmsa_a1d", 5 , },
{ "v1d_sqrt_v1d", 5 , },
{ "v1d_stdeva_a1d", 5 , },
{ "v1d_suma_a1d", 5 , },
{ "v1d_vaddv_v1d_v1d", 5 , },
{ "v1d_vdivv_v1d_v1d", 5 , },
{ "v1d_vmultiplyv_v1d_v1d", 5 , },
{ "v1d_vsignflip_v1d", 5 , },
{ "v1d_vexp_v1d", 3 , },
{ "v1d_vinvertc_v1d", 4 , },
{ "i1b_zero", 79 , },
{ "i3b_zero", 240 , },
{ "i1b_move_i1b", 50 , },
{ "i3b_move_i3b", 150 , },
{ "i1b_split1st_i3b", 218 , },
{ "i1b_split2nd_i3b", 193 , },
{ "i1b_split3rd_i3b", 512 , },
{ "i3b_bgr2hsv_i3b", 1000 , },
{ "i3b_bgr2yuv_i3b", 1000 , },
{ "i1b_bgr2gray_i3b", 366 , },
{ "i1b_dilate3x3_i1b", 1708 , },
{ "i1b_erode3x3_i1b", 2281 , },
{ "i1b_thin_i1b", 10000 , },
{ "i1b_laplacian3x3_i1b", 3598 , },
{ "i1b_laplacian2nd3x3_i1b", 3600 , },
{ "i1b_median3x3_i1b", 5359 , },
{ "i1b_sharpen3x3_i1b", 5709 , },
{ "i1b_smooth3x3_i1b", 6266 , },
{ "i1b_sobel3x3_i1b", 11950 , },
{ "i1b_sobelx3x3_i1b", 11021 , },
{ "i1b_sobely3x3_i1b", 16498 , },
{ "i1b_negate_i1b", 431 , },
{ "i1b_projectionx_i1b", 3786 , },
{ "i1b_projectiony_i1b", 4524 , },
{ "i1b_connection4_i1b", 10000 , },
{ "i1b_connection8_i1b", 10000 , },
{ "i1b_outline4_i1b", 10000 , },
{ "i1b_outline8_i1b", 10000 , },
{ "i1b_segment_i1b", 20000 , },
{ "i1b_add_i1b_i1b", 137 , },
{ "i1b_diff_i1b_i1b", 138 , },
{ "i1b_algebraicprod_i1b_i1b", 801 , },
{ "i1b_algebraicsum_i1b_i1b", 6153 , },
{ "i1b_boundedprod_i1b_i1b", 2529 , },
{ "i1b_logicalprod_i1b_i1b", 195 , },
{ "i1b_logicalsum_i1b_i1b", 230 , },
{ "i1b_subtract_i1b_i1b", 155 , },
{ "i1b_highpass_i1b_v1d", 77705 , },
{ "i1b_lowpass_i1b_v1d", 99026 , },
{ "i1b_threshold_i1b", 2243 , },
{ "i1b_thresholdinv_i1b", 2063 , },
{ "i1b_thresholdv_i1b_v1d", 170 , },
{ "i1b_thresholdinvv_i1b_v1d", 186 , },
{ "i1b_binarize_i1b", 2413 , },
{ "i1b_binarizeinv_i1b", 1802 , },
{ "i1b_binarizev_i1b_v1d", 196 , },
{ "i1b_binarizeinvv_i1b_v1d", 225 , },
{ "i1b_bigblob4_i1b_v1d", 20000 , },
{ "i1b_bigblob8_i1b_v1d", 20000 , },
{ "i1b_addv_i1b_v1d", 2335 , },
{ "i1b_fillv_v1d", 658 , },
{ "i1b_modavgv_i1b_v1d", 577 , },
{ "i1b_multiplyv_i1b_v1d", 1188 , },
{ "i1b_subtractv_i1b_v1d", 1478 , },
{ "i1b_noisev_v1d", 20000 , },
{ "i1b_select_i1b_i1b_v1d_v1d", 39 , },
{ "a1d_zero", 1 , },
{ "a1d_move_a1d", 1 , },
{ "a1d_aabsolute_a1d", 6 , },
{ "a1d_aaddv_a1d_v1d", 6 , },
{ "a1d_adivv_a1d_v1d", 6 , },
{ "a1d_adivv_v1d_a1d", 6 , },
{ "a1d_asubtractv_a1d_v1d", 6 , },
{ "a1d_asubtractv_v1d_a1d", 6 , },
};
std::map<uint16_t, uint32_t> _opCodeToValue;
}//end of local namespace
void Garnet::initializeExecTimeTable(const PicturePerfect::PicturePerfectEnginePtr engine, const ExecTimeEntry* first, const ExecTimeEntry* last)
{
_opCodeToValue.clear();
if ( first == 0 || last == 0 ) {
first = _execTimeDefault;
last = _execTimeDefault + sizeof(_execTimeDefault) / sizeof(_execTimeDefault[0]);
}
for (auto it = first; it != last; it++) {
_opCodeToValue[engine->getOpCode(it->opName)] = it->unitTime;
}
}
uint32_t Garnet::getOpExecTime(uint16_t opCode)
{
return _opCodeToValue.at(opCode);
}
|
2a4afcbb9f91e85b839c1797f0bafa3078c9d4d4 | 5e5252641e6045f61f3a9dc232ab619067af223e | /SourceCode/ROS/lobos_cloud_pubsub/src/lobos_cloud_pubsub/RangeImageSubscriber.cpp | 69234541b11a5443d58657d54d49e98d8a28c68f | [] | no_license | nwpuautolanding/OOR | 6f29e8f82a468ff0315f7f2f964ef2ad1253f037 | ba1d5d132751207b3d9c2bc3a45abba806d6f7a7 | refs/heads/master | 2020-04-01T06:29:39.390949 | 2013-12-18T21:45:28 | 2013-12-18T21:45:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,726 | cpp | RangeImageSubscriber.cpp |
#include <iostream>
#include <lobos_cloud_pubsub/RangeImageSubscriber.hpp>
RangeImageSubscriber::RangeImageSubscriber (ros::NodeHandle nh, std::string imageRangeTopicName, std::string cameraInfoTopicName) {
isThereNewDepthImage = false;
isThereNewRangeImage = false;
isThereNewCameraInfo = false;
angularResolution = 0.5f;
rangeImageSub = nh.subscribe (imageRangeTopicName, 1, &RangeImageSubscriber::depthImageCallback, this);
cameraInfoSub= nh.subscribe (cameraInfoTopicName, 1, &RangeImageSubscriber::cameraInfoCallback, this);
}
RangeImageSubscriber::~RangeImageSubscriber() {
}
void RangeImageSubscriber::depthImageCallback (const sensor_msgs::ImageConstPtr& msg) {
boost::lock_guard<boost::mutex> lock(my_mutex);
localDepthImage = msg;
isThereNewDepthImage = true;
computeRangeImage ();
}
void RangeImageSubscriber::cameraInfoCallback (const sensor_msgs::CameraInfoConstPtr& msg) {
boost::lock_guard<boost::mutex> lock(my_mutex);
localImageInfo = msg;
isThereNewCameraInfo = true;
computeRangeImage ();
}
void RangeImageSubscriber::computeRangeImage() {
if (isThereNewCameraInfo && isThereNewDepthImage) {
isThereNewRangeImage = false;
isThereNewCameraInfo = false;
isThereNewRangeImage = true;
//std::cout << "localDepthimagesize " << localDepthImage->height << " " << localDepthImage->width << std::endl;
localRangeImage.setDepthImage(reinterpret_cast<const float*> (&localDepthImage->data[0]),
(int)localDepthImage->width, (int)localDepthImage->height,
//3.3930780975300314e+02, 2.4273913761751615e+02,
//5.9421434211923247e+02, 5.9104053696870778e+02, angularResolution);
(float)localImageInfo->P[2], (float)localImageInfo->P[6],
(float)localImageInfo->P[0], (float)localImageInfo->P[5]);
//std::cout << "Image infog: ";
//for (int i = 0; i < 12; i++) {
// std::cout << localImageInfo->P[i] << " ";
//}
//std::cout << std::endl;
//std::cout << "localRangeImagesize: " << localRangeImage.height << " " << localRangeImage.width << std::endl;
}
}
/**
* Getters
*/
pcl::RangeImagePlanar RangeImageSubscriber::getCurrentRangeImage() {
boost::lock_guard<boost::mutex> lock(my_mutex);
isThereNewRangeImage = false;
pcl::RangeImagePlanar tmp;
localRangeImage.copyTo(tmp);
return tmp;
}
bool RangeImageSubscriber::getIsThereNewData () {
boost::lock_guard<boost::mutex> lock(my_mutex);
return isThereNewRangeImage;
}
|
f787f97e3467f221db245db7d6a387079868dd9b | 43454a86cee4edaf6f52c3b4fd9bc64f959c60d0 | /SimpleMockDemoProjekt/SimpleMockDemoProjekt/Aktor.h | d96d968d10f1a3090c701daa4a8b66bc73961fb3 | [] | no_license | JoWagnerAtLimagoDe/VWCPPUnit | dcf9ea6c6ee97c73aa966cb10f69ef4349587eff | a86433a2fd5f6d275e5f7e3fdd35376d5e4666c8 | refs/heads/master | 2023-02-07T19:20:44.735891 | 2020-12-17T07:32:18 | 2020-12-17T07:32:18 | 321,283,977 | 0 | 2 | null | 2020-12-14T20:02:01 | 2020-12-14T08:39:02 | C++ | UTF-8 | C++ | false | false | 148 | h | Aktor.h | #pragma once
struct ParameterStruct
{
int x;
int y;
int z;
};
// Dependency
class Aktor
{
public:
virtual void doIt(ParameterStruct p)=0;
};
|
b39791068afdc1bed4a372fd8295e3f5a5ca62ec | e6bd63485c983572ab009a3a5883ed57bc0161b8 | /doc&src/028-光线/PhotoResistor/PhotoResistor.ino | a305adee6fe7b448b33a06df633225c03b1bad24 | [] | no_license | zhounanshu/AirQualityMonitor | 88daecc08ebfe326cae717aa3735150e450fb5bf | 9dac402a3c75c1d66cefaf6db8a9cb9ceb3b7c9a | refs/heads/master | 2016-09-06T18:23:51.472404 | 2016-03-05T02:55:43 | 2016-03-05T02:55:43 | 31,352,843 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 270 | ino | PhotoResistor.ino | #include "SensorLib.h"
#include "Adafruit_GFX.h"
#include <Wire.h>
PhotoResistor photoresistor(2);
void setup(){
Serial.begin(115200);
}
void loop(){
Serial.println("PhotoResistor------test");
Serial.println(photoresistor.getPin());
delay(500);
}
|
81ea4a0994e5c9da706ed50511892f9708663944 | 7e3da674fa01418096b4b822cc167e4843a0adf9 | /Dotm/Dotm/game/camera.h | 3d1d48ca05803da4820ab40b9a7a0008c0dac1c7 | [] | no_license | AlexKoukoulas2074245K/Defence_of_the_Moderns | 2936822200a9194b898443a1adff2566f111735d | dc89190917fef8014783fc183caf21a135d4e8d7 | refs/heads/master | 2021-01-13T00:48:58.413565 | 2016-02-18T21:43:00 | 2016-02-18T21:43:00 | 47,927,196 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,999 | h | camera.h | /* -----------------------------------------------
Author: Alex Koukoulas
Date: 22/12/2015
File name: camera.h
File description: The interface of a class
representing a virtual camera in the game
world along with its children.
----------------------------------------------- */
#pragma once
#include "../util/math.h"
#include "../dotmdef.h"
/* =============
Class: Camera
============= */
class Camera
{
public:
Camera();
virtual
~Camera();
virtual void
update();
void
moveCamera(const direction dir,
const real32 amount);
void
rotateCamera(const direction dir,
const real32 amount);
void
panCamera(const direction dir,
const real32 amount);
mat4x4
calculateViewMatrix() logical_const;
mat4x4
calculateProjectionMatrix() logical_const;
void
calculateFrustum(math::Frustum* outFrustum) logical_const;
const vec3f&
getPosition() logical_const;
protected:
static const vec3f CAM_DEFAULT_FORWARD;
static const vec3f CAM_DEFAULT_RIGHT;
static const vec3f CAM_DEFAULT_UP;
static const real32 CAM_ZNEAR;
static const real32 CAM_ZFAR;
protected:
vec3f m_position;
vec3f m_forward;
vec3f m_up;
vec3f m_right;
real32 m_pitch;
real32 m_yaw;
real32 m_roll;
real32 m_fov;
real32 m_leftDragArea;
real32 m_rightDragArea;
real32 m_topDragArea;
real32 m_bottomDragArea;
real32 m_xDragSpeed;
real32 m_yDragSpeed;
real32 m_minZoom;
real32 m_maxZoom;
real32 m_zoomSpeed;
real32 m_moveSpeed;
real32 m_lookSpeed;
};
/* ==========================
Class: WorldViewCamera
========================== */
class WorldViewCamera: public Camera
{
public:
WorldViewCamera();
~WorldViewCamera();
void
update();
private:
void
screenEdgeTest();
}; |
05995e8669908a98b2e84739061740089cc93e07 | 6f154afa302efeac5256e82c973616c0a428d3d5 | /src/main/strategy_engine_common/StrategyTests/StrategyB1.h | 0b69d40759890f0c9f2b49a985d75e2cecb9c081 | [] | no_license | clhongooo/trading_engine | 2ff58cc5d6cf7bef0a619549a4b4d63f923483dd | d4d74ad7ba21caa01f49054d63cdd8b2317d1702 | refs/heads/master | 2020-06-03T21:38:44.509346 | 2019-07-05T10:16:24 | 2019-07-05T10:16:24 | 191,741,370 | 0 | 1 | null | 2019-06-13T10:23:32 | 2019-06-13T10:23:32 | null | UTF-8 | C++ | false | false | 1,762 | h | StrategyB1.h | #ifndef STRATEGIES_STRATEGYB1_H_
#define STRATEGIES_STRATEGYB1_H_
#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics.hpp>
#include <vector>
#include "Sma.hpp"
#include "SDateTime.h"
#include "SFunctional.h"
#include "../Strategies/StrategyBase.h"
class StrategyB1 : public StrategyBase {
public:
enum TRAINMODE {TM_MAXPROFIT=1,TM_MAXSHARPE=2};
typedef struct {
double m_trainingperiod ;
int m_ma_period ;
const vector<double> * m_v_hist_forsma ;
const vector<double> * m_v_hist_forpnl ;
vector<int> * m_v_signal_trail;
vector<bool> * m_v_disable_days;
double * m_pdAvgPnL ;
double * m_pdSharpe ;
WEIGHTING_SCHEME m_ws ;
double m_curbInSmpReturn ;
} TestRunParm;
StrategyB1();
virtual ~StrategyB1();
bool TrainUpParam(const YYYYMMDDHHMMSS &, const double, const vector<double> &, const vector<double> &, const TRAINMODE, const WEIGHTING_SCHEME, map<double,int> &, map<double,int> &, map<double,int> &, const double);
void SetParamRange(const double, const double, const double);
void SetParamRange(const double, const double, const double, const double, const double, const double);
protected:
bool TestRun(const TestRunParm &);
//--------------------------------------------------
// Strategy objects
//--------------------------------------------------
double m_ma_period_1_low;
double m_ma_period_1_high;
double m_ma_period_1_adj;
double m_ma_period_2_low;
double m_ma_period_2_high;
double m_ma_period_2_adj;
};
#endif /* STRATEGIES_STRATEGYB1_H_ */
|
07f1f59dba1390846905e2ae2e0dc8c5d3483330 | af63606bcbc2720472b9cc01d9f4cc7356c65e61 | /Two Pointer.cpp | 28a0f47e0c3bb0f123ebb85f6c0c4744e8972a1a | [] | no_license | 007sahil/Codes | 187b50c7c2852a879b517da815207aebe8687d9f | 9f847e27a198bf14704d4825bfa5a9ac060ae715 | refs/heads/master | 2021-01-20T13:13:48.743611 | 2017-09-05T10:57:29 | 2017-09-05T10:57:29 | 101,740,727 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 730 | cpp | Two Pointer.cpp | // Given an array containing N integers, you need to find the length of the smallest
//contiguous subarray that contains atleast KK distinct elements in it. Output "−1" if no such subarray exists.
//Solution ::
#include<bits/stdc++.h>
int main(){
int n,k;
cin>>n>>k;
int l = 0, r = 0, ans = INT_MAX;
int A[n+1];
for(int i=0;i<n;i++)
cin>>A[i];
map <int , int > cnt;
set<int> s;
while ( l < n ) {
while ( r < n && s.size() < k ) {
s.insert(A[r]);
cnt[A[r]]++;
r++;
}
if (s.size() >=k) {
ans = min(ans, r-l);
}
if ( cnt[A[l]] == 1 ) s.erase(A[l]);
cnt[A[l]]--;
l++;
}
if ( ans == INT_MAX ) ans = -1;
cout << ans << endl;
return 0;
}
|
6100ca4cdb8ba242ff69bc1e3702280a35420f5d | eab5908a0932ec682d8a011fb4a4f437ad4794ae | /Codeforces/GeneralProblems/281A.cpp | 04a9e5cc9a20d6b36f095a5b70aae0b90ec4c6a9 | [] | no_license | AngelRodriguez319/CompetitiveProgramming | c872fe5873d966d0528a4ca7044b15ecaea0e019 | 38ed9e6cf99afdb9a155e20ab85839ffd68c427c | refs/heads/main | 2023-07-16T20:25:13.590834 | 2021-08-31T01:27:58 | 2021-08-31T01:27:58 | 393,792,213 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 279 | cpp | 281A.cpp | #include <iostream>
#include <string>
using namespace std;
// Author: Angel Gabriel Rodriguez
// Date: March / 09 / 2021
// https://codeforces.com/problemset/problem/281/A
int main(){
string word;
cin >> word;
word[0] = toupper(word[0]);
cout << word << endl;
return 0;
} |
45a393d67169bb58418cd518fc994e3d42f1c1db | 2d64eeba9ef99a2839d8d7993b59e848e2ead852 | /extension.cpp | dab4aa3f73de94b314a68025c278a85a54edeb83 | [] | no_license | XutaxKamay/double_ext | a1d4a0fea868662b06cfa6f99280f19d6facaf4e | 5012a92ca8f3f7df4d0d3ecd1aa20c6a02fc6c41 | refs/heads/master | 2023-03-19T13:43:31.834605 | 2021-03-08T13:01:45 | 2021-03-08T13:01:45 | 240,868,666 | 7 | 7 | null | 2021-03-08T13:01:47 | 2020-02-16T10:03:17 | C++ | UTF-8 | C++ | false | false | 37,106 | cpp | extension.cpp | /**
* vim: set ts=4 :
* =============================================================================
* SourceMod Double Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#include "extension.h"
#include "IHandleSys.h"
#include "smsdk_ext.h"
#include <cmath>
#include <string>
#include <limits>
HandleType_t g_DoubleType = 0;
/**
* @file extension.cpp
* @brief Implement extension code here.
*/
Double g_Double; /**< Global singleton for extension's main interface */
const sp_nativeinfo_t g_DoubleNatives[] =
{
{"Double.IsNaN.get", native_DoubleIsNaN},
{"Double.Double", native_DoubleConstructor},
{"Double.FromString", native_DoubleFromString},
{"Double.FromFloat", native_DoubleFromFloat},
{"Double.FromInt", native_DoubleFromInt},
{"Double.ToString", native_DoubleToString},
{"Double.ToInt", native_DoubleToInt},
{"Double.ToFloat", native_DoubleToFloat},
{"Double.GreaterThan", native_DoubleGreaterThan},
{"Double.LessThan", native_DoubleLessThan},
{"Double.EqualTo", native_DoubleEqualTo},
{"Double.Clone", native_DoubleClone},
{"Double.AbsoluteRef", native_DoubleAbsoluteRef},
{"Double.Absolute", native_DoubleAbsolute},
{"Double.ModuloRef", native_DoubleModuloRef},
{"Double.Modulo", native_DoubleModulo},
{"Double.AddRef", native_DoubleAddRef},
{"Double.Add", native_DoubleAdd},
{"Double.SubtractRef", native_DoubleSubtractRef},
{"Double.Subtract", native_DoubleSubtract},
{"Double.MultiplyRef", native_DoubleMultiplyRef},
{"Double.Multiply", native_DoubleMultiply},
{"Double.DivideRef", native_DoubleDivideRef},
{"Double.Divide", native_DoubleDivide},
{"Double.PowRef", native_DoublePowRef},
{"Double.Pow", native_DoublePow},
{"Double.SquareRootRef", native_DoubleSquareRootRef},
{"Double.SquareRoot", native_DoubleSquareRoot},
{"Double.AtanRef", native_DoubleAtanRef},
{"Double.Atan", native_DoubleAtan},
{"Double.Atan2Ref", native_DoubleAtan2Ref},
{"Double.Atan2", native_DoubleAtan2},
{"Double.SineRef", native_DoubleSineRef},
{"Double.Sine", native_DoubleSine},
{"Double.ArcSineRef", native_DoubleArcSineRef},
{"Double.ArcSine", native_DoubleArcSine},
{"Double.TangentRef", native_DoubleTangentRef},
{"Double.Tangent", native_DoubleTangent},
{"Double.CosineRef", native_DoubleCosineRef},
{"Double.Cosine", native_DoubleCosine},
{"Double.ArcConsineRef", native_DoubleArcCosineRef},
{"Double.ArcConsine", native_DoubleArcCosine},
{"Double_IsNaN", native_Double_IsNaN},
{"Double_FromString", native_Double_FromString},
{"Double_FromFloat", native_Double_FromFloat},
{"Double_FromInt", native_Double_FromInt},
{"Double_ToString", native_Double_ToString},
{"Double_ToInt", native_Double_ToInt},
{"Double_ToFloat", native_Double_ToFloat},
{"Double_GreaterThan", native_Double_GreaterThan},
{"Double_LessThan", native_Double_LessThan},
{"Double_EqualTo", native_Double_EqualTo},
{"Double_Absolute", native_Double_Absolute},
{"Double_Modulo", native_Double_Modulo},
{"Double_Add", native_Double_Add},
{"Double_Subtract", native_Double_Subtract},
{"Double_Multiply", native_Double_Multiply},
{"Double_Divide", native_Double_Divide},
{"Double_Pow", native_Double_Pow},
{"Double_SquareRoot", native_Double_SquareRoot},
{"Double_Atan", native_Double_Atan},
{"Double_Atan2", native_Double_Atan2},
{"Double_Sine", native_Double_Sine},
{"Double_ArcSine", native_Double_ArcSine},
{"Double_Tangent", native_Double_Tangent},
{"Double_Cosine", native_Double_Cosine},
{"Double_ArcConsine", native_Double_ArcCosine},
{nullptr, nullptr},
};
bool Double::SDK_OnLoad(char *error, size_t maxlen, bool late)
{
HandleError err;
g_DoubleType = handlesys->CreateType("Double", this, 0, nullptr, nullptr, myself->GetIdentity(), &err);
if (g_DoubleType == 0)
{
snprintf(error, maxlen, "Could not create Double handle type (err: %d)", err);
}
sharesys->AddNatives(myself, g_DoubleNatives);
sharesys->RegisterLibrary(myself, "double_ext");
return true;
}
void Double::OnHandleDestroy(HandleType_t type, void *object)
{
if (type == g_DoubleType)
{
delete static_cast<pdouble_t>(object);
}
}
cell_t Double::CreateHandle(IPluginContext* const pContext, pdouble_t value)
{
auto pDouble = new double;
if (value)
{
*pDouble = *value;
}
HandleError handleError;
auto handle = handlesys->CreateHandle(g_DoubleType, pDouble, pContext->GetIdentity(), myself->GetIdentity(), &handleError);
if (handle == BAD_HANDLE)
{
delete pDouble;
return pContext->ThrowNativeError("Cannot create double handle (err: %d)", handleError);
}
return static_cast<cell_t>(handle);
}
HandleError Double::ReadHandle(IPluginContext* const pContext, const Handle_t& handle, pdouble_t* value)
{
HandleSecurity security(pContext->GetIdentity(), myself->GetIdentity());
return handlesys->ReadHandle(handle, g_DoubleType, &security, reinterpret_cast<void**>(value));
}
double Double::ReadArray(IPluginContext *const pContext, const cell_t param)
{
cell_t *value;
pContext->LocalToPhysAddr(param, &value);
double returnValue;
memcpy(&returnValue, value, sizeof(double));
return returnValue;
}
void Double::ToArray(IPluginContext *const pContext, const cell_t param, double value)
{
cell_t *address;
pContext->LocalToPhysAddr(param, &address);
memcpy(address, &value, sizeof(double));
}
cell_t native_DoubleConstructor(IPluginContext *pContext, const cell_t *)
{
return Double::CreateHandle(pContext);
}
cell_t native_DoubleFromString(IPluginContext *pContext, const cell_t *params)
{
char *str;
pContext->LocalToString(params[1], &str);
auto value = std::atof(str);
return Double::CreateHandle(pContext, &value);
}
cell_t native_DoubleFromFloat(IPluginContext *pContext, const cell_t *params)
{
auto value = static_cast<double>(sp_ctof(params[1]));
return Double::CreateHandle(pContext, &value);
}
cell_t native_DoubleFromInt(IPluginContext *pContext, const cell_t *params)
{
auto value = static_cast<double>(params[1]);
return Double::CreateHandle(pContext, &value);
}
cell_t native_DoubleIsNaN(IPluginContext *pContext, const cell_t *params)
{
auto handle = static_cast<Handle_t>(params[1]);
pdouble_t value;
auto err = Double::ReadHandle(pContext, handle, &value);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading double handle (err: %d)", err);
}
return std::isnan(*value) || std::isinf(*value);
}
cell_t native_DoubleToString(IPluginContext *pContext, const cell_t *params)
{
auto handle = static_cast<Handle_t>(params[1]);
pdouble_t value;
auto err = Double::ReadHandle(pContext, handle, &value);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading double handle (err: %d)", err);
}
char* str;
pContext->LocalToString(params[2], &str);
auto maxlen = static_cast<size_t>(params[3]);
char format[16];
snprintf(format, 16, "%%.%if", params[4]);
snprintf(str, maxlen, format, *value);
return static_cast<cell_t>(handle);
}
cell_t native_DoubleToInt(IPluginContext *pContext, const cell_t *params)
{
auto handle = static_cast<Handle_t>(params[1]);
pdouble_t value;
auto err = Double::ReadHandle(pContext, handle, &value);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading double handle (err: %d)", err);
}
return static_cast<int>(*value);
}
cell_t native_DoubleToFloat(IPluginContext *pContext, const cell_t *params)
{
auto handle = static_cast<Handle_t>(params[1]);
pdouble_t value;
auto err = Double::ReadHandle(pContext, handle, &value);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading double handle (err: %d)", err);
}
return sp_ftoc(static_cast<float>(*value));
}
cell_t native_DoubleGreaterThan(IPluginContext *pContext, const cell_t *params)
{
auto handleLeft = static_cast<Handle_t>(params[1]);
auto handleRight = static_cast<Handle_t>(params[2]);
pdouble_t valueLeft, valueRight;
auto errLeft = Double::ReadHandle(pContext, handleLeft, &valueLeft);
auto errRight = Double::ReadHandle(pContext, handleRight, &valueRight);
if (errLeft != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading left double handle (err: %d)", errLeft);
}
if (errLeft != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading right double handle (err: %d)", errRight);
}
return *valueLeft > *valueRight;
}
cell_t native_DoubleLessThan(IPluginContext *pContext, const cell_t *params)
{
auto handleLeft = static_cast<Handle_t>(params[1]);
auto handleRight = static_cast<Handle_t>(params[2]);
pdouble_t valueLeft, valueRight;
auto errLeft = Double::ReadHandle(pContext, handleLeft, &valueLeft);
auto errRight = Double::ReadHandle(pContext, handleRight, &valueRight);
if (errLeft != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading left double handle (err: %d)", errLeft);
}
if (errLeft != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading right double handle (err: %d)", errRight);
}
return *valueLeft < *valueRight;
}
cell_t native_DoubleEqualTo(IPluginContext *pContext, const cell_t *params)
{
auto handleLeft = static_cast<Handle_t>(params[1]);
auto handleRight = static_cast<Handle_t>(params[2]);
pdouble_t valueLeft, valueRight;
auto errLeft = Double::ReadHandle(pContext, handleLeft, &valueLeft);
auto errRight = Double::ReadHandle(pContext, handleRight, &valueRight);
if (errLeft != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading left double handle (err: %d)", errLeft);
}
if (errLeft != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading right double handle (err: %d)", errRight);
}
return *valueLeft == *valueRight;
}
cell_t native_DoubleClone(IPluginContext *pContext, const cell_t *params)
{
auto handle = static_cast<Handle_t>(params[1]);
pdouble_t value;
auto err = Double::ReadHandle(pContext, handle, &value);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading double handle (err: %d)", err);
}
return Double::CreateHandle(pContext, value);
}
cell_t native_DoubleAbsoluteRef(IPluginContext *pContext, const cell_t *params)
{
auto handle = static_cast<Handle_t>(params[1]);
pdouble_t value;
auto err = Double::ReadHandle(pContext, handle, &value);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading double handle (err: %d)", err);
}
*value = std::abs(*value);
return static_cast<cell_t>(handle);
}
cell_t native_DoubleAbsolute(IPluginContext *pContext, const cell_t *params)
{
auto handle = static_cast<Handle_t>(params[1]);
pdouble_t value;
auto err = Double::ReadHandle(pContext, handle, &value);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading double handle (err: %d)", err);
}
auto retValue = std::abs(*value);
return Double::CreateHandle(pContext, &retValue);
}
cell_t native_DoubleModuloRef(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
auto secondHandle = static_cast<Handle_t>(params[2]);
pdouble_t secondValue;
err = Double::ReadHandle(pContext, secondHandle, &secondValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading second double handle (err: %d)", err);
}
*refValue = std::fmod(*refValue, *secondValue);
return static_cast<cell_t>(refHandle);
}
cell_t native_DoubleModulo(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
auto secondHandle = static_cast<Handle_t>(params[2]);
pdouble_t secondValue;
err = Double::ReadHandle(pContext, secondHandle, &secondValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading second double handle (err: %d)", err);
}
auto retValue = std::fmod(*refValue, *secondValue);
return Double::CreateHandle(pContext, &retValue);
}
cell_t native_DoubleAddRef(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
auto secondHandle = static_cast<Handle_t>(params[2]);
pdouble_t secondValue;
err = Double::ReadHandle(pContext, secondHandle, &secondValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading second double handle (err: %d)", err);
}
*refValue = *refValue + *secondValue;
return static_cast<cell_t>(refHandle);
}
cell_t native_DoubleAdd(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
auto secondHandle = static_cast<Handle_t>(params[2]);
pdouble_t secondValue;
err = Double::ReadHandle(pContext, secondHandle, &secondValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading second double handle (err: %d)", err);
}
auto retValue = *refValue + *secondValue;
return Double::CreateHandle(pContext, &retValue);
}
cell_t native_DoubleSubtractRef(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
auto secondHandle = static_cast<Handle_t>(params[2]);
pdouble_t secondValue;
err = Double::ReadHandle(pContext, secondHandle, &secondValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading second double handle (err: %d)", err);
}
*refValue = *refValue - *secondValue;
return static_cast<cell_t>(refHandle);
}
cell_t native_DoubleSubtract(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
auto secondHandle = static_cast<Handle_t>(params[2]);
pdouble_t secondValue;
err = Double::ReadHandle(pContext, secondHandle, &secondValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading second double handle (err: %d)", err);
}
auto retValue = (*refValue - *secondValue);
return Double::CreateHandle(pContext, &retValue);
}
cell_t native_DoubleMultiplyRef(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
auto secondHandle = static_cast<Handle_t>(params[2]);
pdouble_t secondValue;
err = Double::ReadHandle(pContext, secondHandle, &secondValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading second double handle (err: %d)", err);
}
*refValue = *refValue **secondValue;
return static_cast<cell_t>(refHandle);
}
cell_t native_DoubleMultiply(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
auto secondHandle = static_cast<Handle_t>(params[2]);
pdouble_t secondValue;
err = Double::ReadHandle(pContext, secondHandle, &secondValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading second double handle (err: %d)", err);
}
auto retValue = (*refValue * *secondValue);
return Double::CreateHandle(pContext, &retValue);
}
cell_t native_DoubleDivideRef(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
auto secondHandle = static_cast<Handle_t>(params[2]);
pdouble_t secondValue;
err = Double::ReadHandle(pContext, secondHandle, &secondValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading second double handle (err: %d)", err);
}
*refValue = *refValue / *secondValue;
return static_cast<cell_t>(refHandle);
}
cell_t native_DoubleDivide(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
auto secondHandle = static_cast<Handle_t>(params[2]);
pdouble_t secondValue;
err = Double::ReadHandle(pContext, secondHandle, &secondValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading second double handle (err: %d)", err);
}
auto retValue = (*refValue / *secondValue);
return Double::CreateHandle(pContext, &retValue);
}
cell_t native_DoublePowRef(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
auto secondHandle = static_cast<Handle_t>(params[2]);
pdouble_t secondValue;
err = Double::ReadHandle(pContext, secondHandle, &secondValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading second double handle (err: %d)", err);
}
*refValue = std::pow(*refValue, *secondValue);
return static_cast<cell_t>(refHandle);
}
cell_t native_DoublePow(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
auto secondHandle = static_cast<Handle_t>(params[2]);
pdouble_t secondValue;
err = Double::ReadHandle(pContext, secondHandle, &secondValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading second double handle (err: %d)", err);
}
auto retValue = std::pow(*refValue, *secondValue);
return Double::CreateHandle(pContext, &retValue);
}
cell_t native_DoubleSquareRootRef(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
*refValue = std::sqrt(*refValue);
return static_cast<cell_t>(refHandle);
}
cell_t native_DoubleSquareRoot(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
auto retValue = std::sqrt(*refValue);
return Double::CreateHandle(pContext, &retValue);
}
cell_t native_DoubleAtanRef(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
*refValue = std::atan(*refValue);
return static_cast<cell_t>(refHandle);
}
cell_t native_DoubleAtan(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
auto retValue = std::atan(*refValue);
return Double::CreateHandle(pContext, &retValue);
}
cell_t native_DoubleAtan2Ref(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
auto secondHandle = static_cast<Handle_t>(params[2]);
pdouble_t secondValue;
err = Double::ReadHandle(pContext, secondHandle, &secondValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading second double handle (err: %d)", err);
}
*refValue = std::atan2(*refValue, *secondValue);
return static_cast<cell_t>(refHandle);
}
cell_t native_DoubleAtan2(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
auto secondHandle = static_cast<Handle_t>(params[2]);
pdouble_t secondValue;
err = Double::ReadHandle(pContext, secondHandle, &secondValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading second double handle (err: %d)", err);
}
auto retValue = std::atan2(*refValue, *secondValue);
return Double::CreateHandle(pContext, &retValue);
}
cell_t native_DoubleSineRef(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
*refValue = std::sin(*refValue);
return static_cast<cell_t>(refHandle);
}
cell_t native_DoubleSine(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
auto retValue = std::sin(*refValue);
return Double::CreateHandle(pContext, &retValue);
}
cell_t native_DoubleArcSineRef(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
*refValue = std::asin(*refValue);
return static_cast<cell_t>(refHandle);
}
cell_t native_DoubleArcSine(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
auto retValue = std::asin(*refValue);
return Double::CreateHandle(pContext, &retValue);
}
cell_t native_DoubleTangentRef(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
*refValue = std::tan(*refValue);
return static_cast<cell_t>(refHandle);
}
cell_t native_DoubleTangent(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
auto retValue = std::tan(*refValue);
return Double::CreateHandle(pContext, &retValue);
}
cell_t native_DoubleCosineRef(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
*refValue = std::cos(*refValue);
return static_cast<cell_t>(refHandle);
}
cell_t native_DoubleCosine(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
auto retValue = std::cos(*refValue);
return Double::CreateHandle(pContext, &retValue);
}
cell_t native_DoubleArcCosineRef(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
*refValue = std::acos(*refValue);
return static_cast<cell_t>(refHandle);
}
cell_t native_DoubleArcCosine(IPluginContext *pContext, const cell_t *params)
{
auto refHandle = static_cast<Handle_t>(params[1]);
pdouble_t refValue;
auto err = Double::ReadHandle(pContext, refHandle, &refValue);
if (err != HandleError_None)
{
return pContext->ThrowNativeError("Error with reading ref. double handle (err: %d)", err);
}
auto retValue = std::acos(*refValue);
return Double::CreateHandle(pContext, &retValue);
}
// native bool Double_IsNaN(any double[2]);
cell_t native_Double_IsNaN(IPluginContext *pContext, const cell_t *params)
{
double value = Double::ReadArray(pContext, params[1]);
Double::ToArray(pContext, params[2], value);
return (std::isnan(value) || std::isinf(value));
}
// native void Double_FromString(char[] value, any double[2]);
cell_t native_Double_FromString(IPluginContext *pContext, const cell_t *params)
{
char *str;
pContext->LocalToString(params[1], &str);
double value = std::atof(str);
Double::ToArray(pContext, params[2], value);
return 0;
}
// native void Double_FromFloat(float value, any double[2]);
cell_t native_Double_FromFloat(IPluginContext *pContext, const cell_t *params)
{
double value = static_cast<double>(sp_ctof(params[1]));
Double::ToArray(pContext, params[2], value);
return 0;
}
// native void Double_FromInt(int value, any double[2]);
cell_t native_Double_FromInt(IPluginContext *pContext, const cell_t *params)
{
double value = static_cast<double>(params[1]);
Double::ToArray(pContext, params[2], value);
return 0;
}
// native void Double_ToString(any double[2], char[] buffer, int maxlen, int precision = 18);
cell_t native_Double_ToString(IPluginContext *pContext, const cell_t *params)
{
double value = Double::ReadArray(pContext, params[1]);
char *str;
pContext->LocalToString(params[2], &str);
size_t maxlen = static_cast<size_t>(params[3]);
char format[16];
snprintf(format, 16, "%%.%if", params[4]);
snprintf(str, maxlen, format, value);
return 0;
}
// native int Double_ToInt(any double[2]);
cell_t native_Double_ToInt(IPluginContext *pContext, const cell_t *params)
{
double value = Double::ReadArray(pContext, params[1]);
return static_cast<int>(value);
}
// native float Double_ToFloat(any double[2]);
cell_t native_Double_ToFloat(IPluginContext *pContext, const cell_t *params)
{
double value = Double::ReadArray(pContext, params[1]);
return sp_ftoc(static_cast<float>(value));
}
// native bool Double_GreaterThan(any left[2], any right[2]);
cell_t native_Double_GreaterThan(IPluginContext *pContext, const cell_t *params)
{
double left = Double::ReadArray(pContext, params[1]);
double right = Double::ReadArray(pContext, params[2]);
return left > right;
}
// native bool Double_LessThan(any left[2], any right[2]);
cell_t native_Double_LessThan(IPluginContext *pContext, const cell_t *params)
{
double left = Double::ReadArray(pContext, params[1]);
double right = Double::ReadArray(pContext, params[2]);
return left < right;
}
// native bool Double_EqualTo(any left[2], any right[2]);
cell_t native_Double_EqualTo(IPluginContext *pContext, const cell_t *params)
{
double left = Double::ReadArray(pContext, params[1]);
double right = Double::ReadArray(pContext, params[2]);
return left == right;
}
// native void Double_Absolute(any input[2], any output[2]);
cell_t native_Double_Absolute(IPluginContext *pContext, const cell_t *params)
{
double value = Double::ReadArray(pContext, params[1]);
Double::ToArray(pContext, params[2], std::abs(value));
return 0;
}
// native void Double_Modulo(any input[2], any denominator[2], any output[2]);
cell_t native_Double_Modulo(IPluginContext *pContext, const cell_t *params)
{
double input = Double::ReadArray(pContext, params[1]);
double denominator = Double::ReadArray(pContext, params[2]);
Double::ToArray(pContext, params[3], std::fmod(input, denominator));
return 0;
}
// native void Double_Add(any left[2], any right[2], any output[2]);
cell_t native_Double_Add(IPluginContext *pContext, const cell_t *params)
{
double left = Double::ReadArray(pContext, params[1]);
double right = Double::ReadArray(pContext, params[2]);
Double::ToArray(pContext, params[3], left + right);
return 0;
}
// native void Double_Subtract(any left[2], any right[2], any output[2]);
cell_t native_Double_Subtract(IPluginContext *pContext, const cell_t *params)
{
double left = Double::ReadArray(pContext, params[1]);
double right = Double::ReadArray(pContext, params[2]);
Double::ToArray(pContext, params[3], left - right);
return 0;
}
// native void Double_Multiply(any left[2], any right[2], any output[2]);
cell_t native_Double_Multiply(IPluginContext *pContext, const cell_t *params)
{
double left = Double::ReadArray(pContext, params[1]);
double right = Double::ReadArray(pContext, params[2]);
Double::ToArray(pContext, params[3], left * right);
return 0;
}
// native void Double_Divide(any left[2], any right[2], any output[2]);
cell_t native_Double_Divide(IPluginContext *pContext, const cell_t *params)
{
double left = Double::ReadArray(pContext, params[1]);
double right = Double::ReadArray(pContext, params[2]);
Double::ToArray(pContext, params[3], left / right);
return 0;
}
// native void Double_Pow(any left[2], any right[2], any output[2]);
cell_t native_Double_Pow(IPluginContext *pContext, const cell_t *params)
{
double left = Double::ReadArray(pContext, params[1]);
double right = Double::ReadArray(pContext, params[2]);
Double::ToArray(pContext, params[3], std::pow(left, right));
return 0;
}
// native void Double_SquareRoot(any input[2], any output[2]);
cell_t native_Double_SquareRoot(IPluginContext *pContext, const cell_t *params)
{
double value = Double::ReadArray(pContext, params[1]);
Double::ToArray(pContext, params[2], std::sqrt(value));
return 0;
}
// native void Double_Atan(any input[2], any output[2]);
cell_t native_Double_Atan(IPluginContext *pContext, const cell_t *params)
{
double value = Double::ReadArray(pContext, params[1]);
Double::ToArray(pContext, params[2], std::atan(value));
return 0;
}
// native void Double_Atan2(any left[2], any right[2], any output[2]);
cell_t native_Double_Atan2(IPluginContext *pContext, const cell_t *params)
{
double left = Double::ReadArray(pContext, params[1]);
double right = Double::ReadArray(pContext, params[2]);
Double::ToArray(pContext, params[2], std::atan2(left, right));
return 0;
}
// native void Double_Sine(any angle[2], any output[2]);
cell_t native_Double_Sine(IPluginContext *pContext, const cell_t *params)
{
double value = Double::ReadArray(pContext, params[1]);
Double::ToArray(pContext, params[2], std::sin(value));
return 0;
}
// native void Double_ArcSine(any angle[2], any output[2]);
cell_t native_Double_ArcSine(IPluginContext *pContext, const cell_t *params)
{
double value = Double::ReadArray(pContext, params[1]);
Double::ToArray(pContext, params[2], std::asin(value));
return 0;
}
// native void Double_Tangent(any angle[2], any output[2]);
cell_t native_Double_Tangent(IPluginContext *pContext, const cell_t *params)
{
double value = Double::ReadArray(pContext, params[1]);
Double::ToArray(pContext, params[2], std::tan(value));
return 0;
}
// native void Double_Cosine(any angle[2], any output[2]);
cell_t native_Double_Cosine(IPluginContext *pContext, const cell_t *params)
{
double value = Double::ReadArray(pContext, params[1]);
Double::ToArray(pContext, params[2], std::cos(value));
return 0;
}
// native void Double_ArcCosine(any angle[2], any output[2]);
cell_t native_Double_ArcCosine(IPluginContext *pContext, const cell_t *params)
{
double value = Double::ReadArray(pContext, params[1]);
Double::ToArray(pContext, params[2], std::acos(value));
return 0;
}
SMEXT_LINK(&g_Double);
|
192b3fac98d2802e45c2d9f291422b871181a3e4 | 1bb6a0b3692b5468f7d148788298320ac3ba2a23 | /Practice/Club_2021_37/d.cpp | e50f59e30727e609cb1f25f4784280a995d310af | [] | no_license | ablondal/comp-prog | ee6ea5c0b32d7fbe0321a4b9919a9cec23fe85f6 | 725e369476993307874f9f5d6e2e7299918251a0 | refs/heads/master | 2022-10-08T05:40:39.206721 | 2022-09-25T22:29:49 | 2022-09-25T22:29:49 | 243,620,860 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 705 | cpp | d.cpp | #include <bits/stdc++.h>
using namespace std;
// incomplete
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
ll DP[107][100007] = {{0}};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, w;
cin >> n >> w;
vector<ll> ws(n), vs(n);
rep(i,0,n){
cin >> ws[i] >> vs[i];
}
rep(i,0,n){
rep(W,0,w+1){
if (ws[i] + W <= w){
DP[i+1][ws[i]+W] = max(DP[i+1][ws[i]+W], DP[i][W] + vs[i]);
}
DP[i+1][W] = max(DP[i+1][W], DP[i][W]);
DP[i+1][W] = max(DP[i+1][W], DP[i+1][W-1]);
}
}
cout << DP[n][w] << endl;
} |
c18fc575c2666ca9b32022b4f80cc65979bdb782 | bb0b7ed3d858d01c1ff562f9f242679c65ad8b85 | /src/Drawable.h | 2ec69b80043fce80973810c4c191eee37ab71508 | [] | no_license | imclab/Lemur | 24436aa9f14ee451452e1efe6564344a9668f407 | 506fd9dc1f32e2070ef3b225f2228bbfdafc2b8b | refs/heads/master | 2020-04-07T21:04:31.771626 | 2013-08-01T22:52:59 | 2013-08-01T22:52:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,267 | h | Drawable.h | //
// Drawable.h
// Lemur
//
// Created by Omer Shapira on 01/07/13.
//
//
#pragma once
#include "ofxIldaPoly.h"
#include "LemurTimeFunction.h"
using namespace ofxIlda;
namespace Lemur {
class Drawable {
protected:
string name;
float time;
vector<ofxIlda::Poly> polys;
timeFuncRef timeFunc;
ofPoint center;
float size;
public:
void setup(){}
virtual void update(){}
virtual void draw(){}
Drawable(string name=""): name(name) { timeFunc = timeFuncRef(new TimeFunction()); }
Drawable(timeFuncRef timeFunc, string name=""): name(name), timeFunc(timeFunc){}
void setTime(float t){time = timeFunc->get(t);}
void setName(string &s) { name = s; }
const string& getName(){ return name; }
const vector<ofxIlda::Poly> getPolys(){return polys;}
void setTimeFunction(timeFuncRef t){timeFunc = t;}
void scale(float scaleBy){
findCenter();
for (int i = 0; i<polys.size(); i++) {
polys[i].scaleAboutPoint(scaleBy, center);
}
findCenter();
}
void fitToCanvas(){
findCenter();
scale(1/size);
translate(ofPoint(0.5,0.5,0));
}
void translate(ofPoint p){
for (int i = 0 ; i<polys.size() ; i++)
{
polys[i].translate(p);
}
//TODO: make "Changed"
findCenter();
}
ofRectangle getBoundingBox(){
ofRectangle rect = ofRectangle(0,0,0,0);
for (int i = 0 ; i< polys.size(); i++){
ofRectangle b = polys[i].getBoundingBox();
rect.growToInclude(b);
}
return rect;
}
void findCenter(){
ofRectangle b = getBoundingBox();
//TODO: Check if this is correct
center = b.getPosition();
size = MAX(b.getWidth(), b.getHeight());
}
};
}
//TODO: Must find a way to sequence the Polys inside one drawable. Do they move independently? Are they locked? (OmerShapira)
|
741b47db471eb8fac4e87b5410b330e5f45a4858 | 47558f2ee578bf9ffccac7a23d0a8398e93345c3 | /Clouded/Clouded/Source/Input/Keyboard.h | df4c73aa02b32b1953fb78151f7dd9cef7c7885e | [] | no_license | StanPepels/Clouded-C- | 9c08c989cf0c7a27dd18fd43e11afb57334df24d | 219026690a068f4e7900c30d90876497848d4bda | refs/heads/master | 2018-09-19T20:24:28.174454 | 2018-06-29T17:27:08 | 2018-06-29T17:27:08 | 111,549,236 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 106 | h | Keyboard.h | #pragma once
class Keyboard
{
public:
static constexpr int num_keys = 256;
bool states[num_keys];
}; |
9ec0db3b60b0cf5f7fc0df67f6ead5be3535b07a | 1c42ffc8bcf325ea16326d635d931048ed068077 | /Image_Process parts/reforcor_image_PMG_PROCZ/bitz/baisc.cpp | 7cfeb337c0a0bd06cf3c5e4261f84ef57df1d92a | [] | no_license | zeplaz/SIDRN | 964cf9ce2d3441b3b2b938c3c21dbc02f1ca0ec3 | cbf34dfc17c52c40ffbb1b77f15f29fbd3fdba7a | refs/heads/master | 2020-04-15T01:05:40.215449 | 2020-01-05T19:55:38 | 2020-01-05T19:55:38 | 164,263,335 | 0 | 0 | null | 2019-05-24T18:59:28 | 2019-01-06T00:45:49 | C++ | UTF-8 | C++ | false | false | 186 | cpp | baisc.cpp | //
informz
image objects set for proper stripe out all freinz
finsh obj factory
and image process production
create masks and apply_intensity_scaler
_+X and wtire! fix file reading
|
b31b999fa1c57a45f1f24b04bbc6c08f38399a18 | 916688c367136f98951a5aa4a182badc55c9c1c7 | /RUDPNet/RUDPAddr.cpp | e6511b3c4263759e5327afbb569278789cefdd80 | [
"MIT"
] | permissive | RoyMoon/blakstar_p2p | 944fd38c8b1e6ba7a8448ec1ecc1446570cecdf1 | 2cef547dd0a5b4cc19365c25f985317ff088709b | refs/heads/master | 2020-04-28T11:50:56.135420 | 2019-02-28T16:36:49 | 2019-02-28T16:36:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,041 | cpp | RUDPAddr.cpp | #include "StdAfx.h"
#include "RUDPAddr.h"
#include <winsock2.h>
RUDPAddr::RUDPAddr():
m_ulIP(0),
m_usPort(0)
{
}
RUDPAddr::RUDPAddr(const char* pszIP , unsigned short usPort):
m_ulIP(0),
m_usPort(0)
{
m_ulIP = inet_addr(pszIP);
m_usPort = usPort;
}
RUDPAddr::RUDPAddr(unsigned long ulIP , unsigned short usPort):
m_ulIP(0),
m_usPort(0)
{
m_ulIP = ulIP;
m_usPort = usPort;
}
void
RUDPAddr::Reset()
{
m_ulIP = 0;
m_usPort = 0;
}
unsigned short
RUDPAddr::GetPort() const
{
return m_usPort;
}
unsigned long
RUDPAddr::GetIP() const
{
return m_ulIP;
}
bool
RUDPAddr::operator==(const RUDPAddr & r)
{
if( m_ulIP == r.m_ulIP && m_usPort == r.m_usPort )
return true;
return false;
}
RUDPAddr&
RUDPAddr::operator=(const RUDPAddr& c)
{
m_ulIP = c.GetIP();
m_usPort = c.GetPort();
return (*this);
}
bool
RUDPAddr::operator!=(const RUDPAddr & r)
{
if( m_ulIP == r.m_ulIP && m_usPort == r.m_usPort )
return false;
return true;
} |
3d10055ccfce9919ddd4075eb6e347356938100a | c9f1d3c5be054451eff383a8336351492be9d207 | /branches/qanalitza/src/polynomial.cpp | 276170a29aff3bb0748c9d07b752c32efda3f06a | [] | no_license | BackupTheBerlios/kalgebra-svn | 7ddfb20fe6f8310f3da0c5fe78d790b44a369929 | 411a1514f690670fb383452e6a69afe4ce789e20 | refs/heads/master | 2021-01-01T06:38:22.841384 | 2007-02-19T18:36:19 | 2007-02-19T18:36:19 | 40,774,359 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,366 | cpp | polynomial.cpp | #include "polynomial.h"
Polynomial::Polynomial() : m_err(false){}
Polynomial::~Polynomial(){}
bool Polynomial::isPoly(const QDomElement& s){
bool ispoly=false;
//qDebug("<%s>%s", s.tagName().ascii(), s.childNodes().item(0).toElement().tagName().ascii());
if(s.tagName()=="apply" && s.childNodes().item(0).toElement().tagName()=="plus"){
ispoly=true;
for(unsigned int i=1;i<s.childNodes().length() && ispoly ; i++){
ispoly=Monomial::isMono(s.childNodes().item(i).toElement()) || Scalar::isScalar(s.childNodes().item(i).toElement());
}
} else if(Monomial::isMono(s)) ispoly=true;
return ispoly;
}
bool Polynomial::setValue(const QDomElement& s){
bool ispoly=false;
m_var="";
poly.clear();
Monomial m = Monomial(0., 0., "");
if(s.tagName()=="apply" && s.childNodes().item(0).toElement().tagName()=="plus"){
ispoly=true;
for(unsigned int i=1;i<s.childNodes().length() && ispoly; i++){
if(Monomial::isMono(s.childNodes().item(i).toElement())){
m.setValue(s.childNodes().item(i).toElement());
*this += m;
} else if(Scalar::isScalar(s.childNodes().item(i).toElement())){
m.setValue(s.childNodes().item(i).toElement());
*this += m;
} else {
ispoly=false;
}
m_var=m.var;
}
} else if(Monomial::isMono(s)) {
m.setValue(s);
poly.append(m);
ispoly=true;
}
return ispoly;
}
QDomElement Polynomial::value(QDomDocument d){
QDomElement e;
e=d.createElement("apply");
e.appendChild(d.createElement("plus"));
for(QValueList<Monomial>::iterator it = poly.begin(); it != poly.end(); ++it) {
e.appendChild((*it).value(d));
}
return e;
}
/*******************************************/
/**************Operadors a saco*************/
/*****************PolyOpMono****************/
/*******************************************/
Polynomial Polynomial::operator+(const Monomial& m){
Polynomial p = *this;
bool found=false;
for(QValueList<Monomial>::iterator it = p.poly.begin(); !found && it != p.poly.end(); ++it) {
if((*it).exp==m.exp) {
(*it)+=m;
found=true;
}
}
if(!found)
p.poly.append(m);
return p;
}
Polynomial Polynomial::operator+=(const Monomial& m){
bool found=false;
for(QValueList<Monomial>::iterator it = poly.begin(); !found && it != poly.end(); ++it) {
if((*it).exp==m.exp) {
(*it)+=m;
found=true;
}
}
if(!found)
poly.append(m);
// qDebug("hola += %f", m.m.value());
return *this;
}
Polynomial Polynomial::operator*(const Monomial& m){
Polynomial p = *this;
for(QValueList<Monomial>::iterator it = p.poly.begin(); it != p.poly.end(); ++it) {
(*it)*=m;
}
return p;
}
Polynomial Polynomial::operator*=(const Monomial& m){
for(QValueList<Monomial>::iterator it = poly.begin(); it != poly.end(); ++it) {
(*it)*=m;
}
return *this;
}
Polynomial Polynomial::operator-(const Monomial& m){
Polynomial p = *this;
bool found=false;
for(QValueList<Monomial>::iterator it = p.poly.begin(); !found && it != p.poly.end(); ++it) {
if((*it).exp==m.exp) {
(*it)-=m;
found=true;
}
}
if(!found)
p.poly.append(-m);
return p;
}
Polynomial Polynomial::operator-=(const Monomial& m){
bool found=false;
for(QValueList<Monomial>::iterator it = poly.begin(); !found && it != poly.end(); ++it) {
if((*it).exp==m.exp) {
(*it)-=m;
found=true;
}
}
if(!found)
poly.append(-m);
return *this;
}
Polynomial Polynomial::operator/(const Monomial& m){
Polynomial p = *this;
for(QValueList<Monomial>::iterator it = p.poly.begin(); it != p.poly.end(); ++it) {
(*it)/=m;
}
return p;
}
Polynomial Polynomial::operator/=(const Monomial& m){
for(QValueList<Monomial>::iterator it = poly.begin(); it != poly.end(); ++it) {
(*it)*=m;
}
return *this;
}
/*******************************************/
/**************Operadors a saco*************/
/*****************PolyOpPoly****************/
/*******************************************/
Polynomial Polynomial::operator+(Polynomial &a){
Polynomial p=*this;
for(QValueList<Monomial>::iterator it = a.poly.begin(); it != a.poly.end(); ++it) {
p+=(*it);
}
return p;
}
Polynomial Polynomial::operator+=(Polynomial a){
for(QValueList<Monomial>::iterator it = a.poly.begin(); it != a.poly.end(); ++it) {
*this+=(*it);
}
return *this;
}
Polynomial Polynomial::operator*(Polynomial &a){
Polynomial p=Polynomial();
for(QValueList<Monomial>::iterator it = a.poly.begin(); it != a.poly.end(); ++it) {
Monomial m=(*it);
p+= *this*m;
(*it).print("It's meeeeee");
}
return p;
}
Polynomial Polynomial::operator*=(Polynomial &a){
Polynomial p=Polynomial();
for(QValueList<Monomial>::iterator it = a.poly.begin(); it != a.poly.end(); ++it) {
Monomial m=(*it);
p+= *this*m;
}
*this = p;
return *this;
}
Polynomial Polynomial::operator-(Polynomial &a){
Polynomial p=*this;
for(QValueList<Monomial>::iterator it = a.poly.begin(); it != a.poly.end(); ++it) {
p-=(*it);
}
return p;
}
Polynomial Polynomial::operator-=(Polynomial &a){
for(QValueList<Monomial>::iterator it = a.poly.begin(); it != a.poly.end(); ++it) {
*this-=(*it);
}
return *this;
}
Polynomial Polynomial::operator-() const {
Polynomial p=*this;
for(QValueList<Monomial>::iterator it = p.poly.begin(); it != p.poly.end(); ++it) {
(*it)=-(*it);
}
return *this;
}
Polynomial Polynomial::operator/( Polynomial &a){
Polynomial p=*this;
for(QValueList<Monomial>::iterator it = a.poly.begin(); it != a.poly.end(); ++it) {
p/=(*it);
}
return p;
}
Polynomial Polynomial::operator/=( Polynomial &a){
for(QValueList<Monomial>::iterator it = a.poly.begin(); it != a.poly.end(); ++it) {
*this/=(*it);
}
return *this;
}
Polynomial Polynomial::pow(const Scalar &exp){
Polynomial p = *this;
for(int i=exp.value(); i>0; i--){
*this *= p;
}
return *this;
}
Polynomial Polynomial::operator++(){return *this+=Monomial(1.,0., m_var);}
// Polynomial Polynomial::operator--(){return *this-=Monomial(1.,0.);}
Polynomial Polynomial::operator++(int){return *this+=Monomial(1.,0., m_var);}
// Polynomial Polynomial::operator--(int){return *this-=Monomial(1.,0.);}
Scalar Polynomial::degree() {
Scalar max=0.0;
for(QValueList<Monomial>::iterator it = poly.begin(); it != poly.end(); ++it) {
if((*it).exp>max)
max=(*it).exp;
}
return max;
}
Scalar Polynomial::member(const Scalar &exp) {
for(QValueList<Monomial>::iterator it = poly.begin(); it != poly.end(); ++it) {
if((*it).exp==exp)
return (*it).m;
}
return Scalar(0.);
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/////////// ///////////////
/////////// Monomial Class ///////////////
/////////// ///////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
bool Monomial::isMono(const QDomElement& s){
bool ret=false;
if(s.tagName()=="ci") {
ret= true;
} else if(s.tagName()=="apply" && s.childNodes().length()==3){
if(s.childNodes().item(0).toElement().tagName()=="power" && s.childNodes().item(1).toElement().tagName()=="ci" && Scalar::isScalar(s.childNodes().item(2).toElement()))
ret= true;
else if(s.childNodes().item(0).toElement().tagName()=="times" && Scalar::isScalar(s.childNodes().item(1).toElement()) && s.childNodes().item(2).toElement().tagName()=="ci")//2x
ret= true;
else if(s.childNodes().item(0).toElement().tagName()=="times" && Scalar::isScalar(s.childNodes().item(1).toElement()) && s.childNodes().item(2).toElement().tagName()=="apply" && s.childNodes().item(2).childNodes().item(0).toElement().tagName()=="power" && s.childNodes().item(2).childNodes().item(1).toElement().tagName()=="ci" && Scalar::isScalar(s.childNodes().item(2).childNodes().item(2).toElement()))
ret= true;
}
return ret;
}
bool Monomial::setValue(const QDomElement& s){ //We don't allow x^(1/2) as a monomial, even though exp is a double value
bool ret=false;
m=1.;
exp=1.;
if(s.tagName()=="ci") {
var=s.text();
ret=true;
} else if(s.tagName()=="apply" && s.childNodes().length()==3){
if(s.childNodes().item(0).toElement().tagName()=="power" && s.childNodes().item(1).toElement().tagName()=="ci" && Scalar::isScalar(s.childNodes().item(2).toElement())) { //x^2
var = s.childNodes().item(1).toElement().text();
exp.setValue(s.childNodes().item(2).toElement());
ret=true;
} else if(s.childNodes().item(0).toElement().tagName()=="times" && Scalar::isScalar(s.childNodes().item(1).toElement()) && s.childNodes().item(2).toElement().tagName()=="ci") {//3x
m.setValue(s.childNodes().item(1).toElement());
var = s.childNodes().item(2).toElement().text();
ret=true;
} else if(s.childNodes().item(0).toElement().tagName()=="times" && Scalar::isScalar(s.childNodes().item(1).toElement()) && s.childNodes().item(2).toElement().tagName()=="apply" && s.childNodes().item(2).childNodes().item(0).toElement().tagName()=="power" && s.childNodes().item(2).childNodes().item(1).toElement().tagName()=="ci" && Scalar::isScalar(s.childNodes().item(2).childNodes().item(2).toElement())){ //3x^2
m.setValue(s.childNodes().item(1).toElement());
exp.setValue(s.childNodes().item(2).childNodes().item(2).toElement());
var = s.childNodes().item(2).childNodes().item(1).toElement().text();
ret=true;
}
}
return ret;
}
QDomElement Monomial::value(QDomDocument d){
QDomElement e;
if(exp.value()==0.0){
e.appendChild(exp.value(d));
qDebug("bonks");
} else if(m.value()==1. && exp.value()==1.0){
e=d.createElement("ci");
e.appendChild(d.createTextNode(var));
} else if(m.value()!=1. && exp.value() == 1.0){
e=d.createElement("apply");
e.appendChild(d.createElement("times"));
QDomElement q = d.createElement("cn");
q.appendChild(m.value(d));
e.appendChild(q);
QDomElement v = d.createElement("ci");
v.appendChild(d.createTextNode(var));
e.appendChild(v);
} else if(m.value()==1. && exp.value() != 1.0){
e=d.createElement("apply");
e.appendChild(d.createElement("power"));
QDomElement v = d.createElement("ci");
v.appendChild(d.createTextNode(var));
e.appendChild(v);
QDomElement q = d.createElement("cn");
q.appendChild(exp.value(d));
e.appendChild(q);
} else if(m.value()!=1. && exp.value() != 1.0){
qDebug("%f%s^%f", m.value(), var.ascii(), exp.value() );
e=d.createElement("apply");
e.appendChild(d.createElement("times"));
QDomElement q = d.createElement("cn");
q.appendChild(m.value(d));
e.appendChild(q);
QDomElement k=d.createElement("apply");;
k.appendChild(d.createElement("power"));
QDomElement v = d.createElement("ci");
v.appendChild(d.createTextNode(var));
QDomElement y = d.createElement("cn");
y.appendChild(exp.value(d));
k.appendChild(v);
k.appendChild(y);
e.appendChild(k);
}
return e;
}
void Polynomial::print(QString append="") {
qDebug("%s%s", append.ascii(), str().ascii());
}
QString Polynomial::str() {
QString res=QString("");
QValueList<Monomial>::iterator it = poly.begin();
res += (*it).str();
++it;
for(; it != poly.end(); ++it) {
res += "+"+(*it).str();
}
return res;
}
|
4528f1dc9c66d2454e5bd7ef8137ddc60a5a66a6 | 7da302151b535f052b7bdd96a08e6d18c1542133 | /Big_number1185.cpp | 941bf4643b36b1f1fc3a6470146848b404606d04 | [] | no_license | NawazShorif/Programming-Solution | 72aa5414cd50213cb91c379cb46a91e9a7548ac0 | b823ce67bb2fe9e9bde52b223530dc400fab66e5 | refs/heads/master | 2021-01-10T15:48:52.783503 | 2017-02-20T15:23:34 | 2017-02-20T15:23:34 | 55,224,618 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 884 | cpp | Big_number1185.cpp | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
vector<int> n;
int input=1000;
int test;
cin>>test;
while(scanf("%d",&input)==1 && --test)
{
int temp=input-1;
while(input)
{
n.push_back(input%10);
input/=10;
}
for(int i=temp; i>1; i--)
{
int carry=0;
for(int j=0; j<n.size(); j++)
{
int temp1=n[j]*i+carry;
n[j]=temp1%10;
carry=temp1/10;
}
while(carry)
{
n.push_back(carry%10);
carry/=10;
}
}
if(temp+1==0)
n.push_back(1);
cout<<n.size()<<endl;
n.clear();
}
return 0;
}
|
438b838ec82778f303c5377e8071a9ad158be0e2 | 974897eae62d73db4aa1bdfda4efa41c4e9dd0ed | /Source/MV/Utility/stopwatch.cpp | fc65412339e79359080783f011ae6d115c3c7274 | [] | no_license | Devacor/Bindstone | 71670d3d1e37d578a8616baad4a2b4dba36ff327 | 6b204c945d437456d79189509526962b89499839 | refs/heads/master | 2023-02-17T08:52:35.874390 | 2020-10-19T08:04:19 | 2020-10-19T08:04:19 | 40,729,765 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,356 | cpp | stopwatch.cpp | #include "stopwatch.h"
namespace MV {
double Stopwatch::check(){
if(paused){
return pausetime-prevtime + timeOffset;
}
return timerfunc(false);
}
double Stopwatch::check() const {
if (paused) {
return pausetime - prevtime + timeOffset;
} else if(started) {
return programTime() - prevtime + timeOffset;
} else {
return 0.0;
}
}
double Stopwatch::pause(){
pausetime = programTime();
paused = true;
return timerfunc(false);
}
double Stopwatch::resume(){
if(paused){
prevtime+=programTime()-pausetime;
}
paused = false;
return timerfunc(false);
}
void Stopwatch::start(){
timerfunc(true);
}
double Stopwatch::stop(){
started = false;
if(paused) {
return pausetime-prevtime + timeOffset;
} else {
return programTime()-prevtime + timeOffset;
}
}
double Stopwatch::reset() {
auto result = stop();
start();
return result;
}
double Stopwatch::timerfunc(bool reset){
double curtime = programTime();
if(!started) {
prevtime=curtime;
started = true;
return timeOffset;
} else {
double diff=curtime-prevtime;
if(reset){
prevtime=curtime;
for (auto&& deltaValue : deltaVals) {
deltaValue.second = 0.0;
}
}
return diff+timeOffset;
}
}
double Stopwatch::delta(const std::string &deltaName, bool resetDelta, double addOverflow){
if(deltaVals.find(deltaName) == deltaVals.end()){ //if no delta by that name is found
deltaVals[deltaName] = check(); //set the delta to the current time
return 0;
}
double PreviousTime = deltaVals[deltaName];
double CurrentTime = check();
if(resetDelta){
deltaVals[deltaName] = CurrentTime + addOverflow; //update delta
}
return CurrentTime - PreviousTime;
}
double Stopwatch::delta(bool a_resetDelta /*= true*/) {
return delta("_!_", a_resetDelta);
}
void Stopwatch::setTimeOffset(double offsetMilliseconds ){
timeOffset = offsetMilliseconds;
}
double Stopwatch::getTimeOffset(){
return timeOffset;
}
bool Stopwatch::frame(double timeToWait) {
return frame("_!_", timeToWait);
}
bool Stopwatch::frame(const std::string &deltaName, double timeToWait) {
if(!isStarted()){
start();
}
auto deltaTime = delta(deltaName, false);
if(deltaTime >= timeToWait){
delta(deltaName, true, timeToWait - deltaTime);
return true;
}
return false;
}
}
|
c358320e0dabc7bcf5d23ede1ca46d2fb09b7024 | a0c28e1b55990dbba37e2a8b34951c397551b721 | /algorithmic-heights/fibo.cpp | 7de69f4b6bb3bab1a2fe3b3754b471154f6110af | [
"Unlicense"
] | permissive | lbovard/rosalind | 26ec6f11438e40e316f04b90398dacfba0bb0dc0 | 92d0bde3282caf6af512114bdc0133ee3a1d6418 | refs/heads/master | 2021-01-20T10:35:36.824358 | 2015-12-11T10:19:41 | 2015-12-11T10:19:41 | 14,078,474 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,417 | cpp | fibo.cpp | /*
This is a very straight forward implementation of the Fibonacci algorithm.
Since this site doesn't run on the server, a fast implementation isn't required.
Furthermore, given the restriction that N<=25, a simple non-recursive implementation
that uses the previous values will suffice.
Furthermore, we know that F_{n} = O(\phi ^{n}) ~ O(1.6^n) which gives ~126,000 for N=25
The actual answer is F_{25} = 75025 but this is fine since we are aren't really in an asymptotic regime.
A quick numerical calculation reveals that around N~70 is this approximation much more valid, where the
above answer differs by only 2% from the real.
This result tells us that we can fit the answer safely in an integer. However, I have used unsigned long ints
just because I can and it allows us to compute up to F_{93} correctly. For higher values, we would have to have
some form of large integers to accurately compute the numbers. However, most problems that require this high value
of Fibonacci typically ask you mod 2^64 which means that all our calculations can safely fit in to a 64-bit integer.
In those cases, we have to be clever about what algorithms we are using.
*/
#include <iostream>
typedef unsigned long int uint64;
int main() {
uint64 a,b,c,n;
a=1,b=0;
std::cin >> n;
for(unsigned int i=0;i<n;i++) {
c=a+b;
b=a;
a=c;
}
std::cout << b << std::endl;
return 0;
}
|
290a20ac7cb1b029aaca1370b5bcc4eba6b5f200 | b4b4e324cbc6159a02597aa66f52cb8e1bc43bc1 | /C++ code/Young Turing Program/比賽中寫的code/p13.cpp | 0656860c9431e85d7b89b50a53b3dcf9eef63602 | [] | no_license | fsps60312/old-C-code | 5d0ffa0796dde5ab04c839e1dc786267b67de902 | b4be562c873afe9eacb45ab14f61c15b7115fc07 | refs/heads/master | 2022-11-30T10:55:25.587197 | 2017-06-03T16:23:03 | 2017-06-03T16:23:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 715 | cpp | p13.cpp | #include<cstdio>
#include<cassert>
using namespace std;
int N,M;
char G[5000][5001];
bool Check(int i,int j)
{
if(i<0||j<0||i>=N||j>=M)return false;
return G[i][j]=='*';
}
int main()
{
// freopen("in.txt","r",stdin);
while(scanf("%d%d",&N,&M)==2)
{
if(N==0&&M==0)break;
for(int i=0;i<N;i++)scanf("%s",G[i]);
static int kase=0;
if(kase)puts("");
printf("#%d:\n",++kase);
for(int i=0;i<N;i++)
{
for(int j=0;j<M;j++)
{
if(G[i][j]=='*')putchar('*');
else
{
int cnt=0;
static int d[8][2]={{0,-1},{0,1},{-1,0},{1,0},{1,-1},{1,1},{-1,-1},{-1,1}};
for(int k=0;k<8;k++)if(Check(i+d[k][0],j+d[k][1]))++cnt;
putchar('0'+cnt);
}
}
puts("");
}
}
return 0;
}
|
1a029741e190833dce6aed1d22ea750b9b15ee1c | ccf4b46fa34fb8660161df27624ed741140a893a | /src/uwin/applet/UwinGeneral.cpp | 642af712ccf92ca22775b0659acb14630742f26b | [] | no_license | d9748336/uwin | 978b7a1a50db3444b02ebd0cc7e760675f7e04eb | 0c520f4cbb014c2f73dea5dfc284b236fa507c53 | refs/heads/master | 2020-03-25T17:46:37.017479 | 2018-08-08T10:13:45 | 2018-08-08T10:13:45 | 143,995,222 | 1 | 0 | null | 2018-08-08T10:00:34 | 2018-08-08T10:00:33 | null | UTF-8 | C++ | false | false | 7,357 | cpp | UwinGeneral.cpp | // UwinGeneral.cpp : implementation file
//
#include "stdafx.h"
#include "testcpl.h"
#include "UwinGeneral.h"
#include "globals.h"
#include <uwin_keys.h>
#include <signal.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#if UWIN_MAGIC==0
# define string(a)
#else
# define stringize(a) #a
# define string(a) "." stringize(a)
#endif
#ifdef STANDALONE
# define SHMEM_NAME "uwin.standalone" string(UWIN_MAGIC)
#endif
#ifndef SHMEM_NAME
# define SHMEM_NAME "uwin.v1" string(UWIN_MAGIC)
#endif
/////////////////////////////////////////////////////////////////////////////
// CUwinGeneral property page
IMPLEMENT_DYNCREATE(CUwinGeneral, CPropertyPage)
CUwinGeneral::CUwinGeneral() : CPropertyPage(CUwinGeneral::IDD)
{
//{{AFX_DATA_INIT(CUwinGeneral)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
*m_Release = 0;
}
CUwinGeneral::~CUwinGeneral()
{
}
void CUwinGeneral::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CUwinGeneral)
DDX_Control(pDX, IDC_COMBO_RELEASE, m_ComboRelease);
DDX_Control(pDX, IDC_COMBO_LOGLEVEL, m_ComboLogLevel);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CUwinGeneral, CPropertyPage)
//{{AFX_MSG_MAP(CUwinGeneral)
ON_CBN_SELENDOK(IDC_COMBO_LOGLEVEL, OnSelendokComboLoglevel)
ON_CBN_SELENDOK(IDC_COMBO_RELEASE, OnSelendokComboRelease)
ON_EN_CHANGE(IDC_EDIT_LICENCEKEY, OnChangeEditLicencekey)
ON_EN_CHANGE(IDC_EDIT_REGUSER, OnChangeEditReguser)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUwinGeneral message handlers
BOOL CUwinGeneral::OnApply()
{
// TODO: Add your specialized code here and/or call the base class
ProcessInstalledReleaseRequest();
SetModified(FALSE);
return CPropertyPage::OnApply();
}
void CUwinGeneral::ProcessInstalledReleaseRequest()
{
char* release;
char* root;
char cmd[1024];
if(!(release = regOps.GetRelease()))
return;
if(*m_Release && strcmp(m_Release, release))
{
// Get install directory for current release
if(!(root = regOps.GetRoot()))
{
::MessageBox(NULL, "Cannot determine release root directory", "UWIN Change Release", MB_OK);
return;
}
sprintf(cmd, "Stop UWIN release %s and restart UWIN release %s?", release, m_Release);
if(::MessageBox(NULL, cmd, "UWIN Change Release", MB_YESNO|MB_ICONWARNING) == IDYES)
{
// release.exe does all the work
sprintf(cmd, "\"%s/var/uninstall/release.exe\" %s", root, m_Release);
if(system(cmd) || !regOps.SetRelease(m_Release))
{
::MessageBox(NULL, "Release change failed", "UWIN Change Release", MB_OK);
return;
}
}
}
}
BOOL CUwinGeneral::OnInitDialog()
{
CPropertyPage::OnInitDialog();
// TODO: Add extra initialization here
// Set System information
SetOsVersion();
// Set uwin information
SetUwinRelease();
// Set registered user information
SetRegisteredUser();
// Set licence key information
SetLicenceKey();
// Set error logging level
SetErrorLoggingLevel();
// Set installed UWIN releases
SetInstalledUwinReleases();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CUwinGeneral::SetOsVersion()
{
CString system;
sysInfo.GetSysInfo(system);
SetDlgItemText(IDC_EDIT_OSVERSION, system);
}
void CUwinGeneral::SetUwinRelease()
{
/*
* The below definition is taken from
* %UWIN_INSTALL_ROOT%\usr\include\ast\limits.h
*/
#define _POSIX_NAME_MAX 14
/*
* The below structure is taken from
* %UWIN_INSTALL_ROOT%\usr\include\sys\utsname.h
*/
struct utsname
{
char sysname[_POSIX_NAME_MAX];
char nodename[_POSIX_NAME_MAX];
char release[_POSIX_NAME_MAX];
char version[_POSIX_NAME_MAX];
char machine[_POSIX_NAME_MAX];
}info;
char* release;
char uname_string[256];
char sysdll_path[MAX_PATH], dll_str[MAX_PATH];
HINSTANCE hPosix, hAst;
int res= 0, (*suname)(struct utsname *),(*skill)(int,int);
HANDLE running = OpenFileMapping(FILE_MAP_ALL_ACCESS,FALSE,SHMEM_NAME);
if(GetSystemDirectory(sysdll_path,sizeof(sysdll_path)) == FALSE)
goto err;
// Load proper ast dll
if(release = regOps.GetRelease())
{
if(!strcmp(release, "1.6"))
sprintf(dll_str, "%s\\ast52.dll", sysdll_path);
else
sprintf(dll_str, "%s\\ast54.dll", sysdll_path);
hAst = LoadLibrary(dll_str);
}
// Load posix.dll
sprintf(dll_str, "%s\\posix.dll", sysdll_path);
if((hPosix = LoadLibrary(dll_str)) == NULL)
goto err;
// Get uname() function pointer
if((suname = (int (*)(struct utsname *))GetProcAddress(hPosix,"uname")) == NULL)
goto err;
// Call uname()
if(((*suname)(&info)) < 0)
goto err;
sprintf(uname_string,"%s %s %s %s", info.sysname, info.release, info.version, info.machine);
SetDlgItemText(IDC_EDIT_UWINVERSION, uname_string);
res = 1;
err:
/* if uwin wasn't running then kill the init process */
if(running)
CloseHandle(running);
else if(hPosix && (skill = (int(*)(int,int))GetProcAddress(hPosix,"kill")))
(*skill)(1,SIGTERM);
// Unload ast54.dll
if(hAst)
FreeLibrary(hAst);
// Unload posix.dll
if(hPosix)
FreeLibrary(hPosix);
if(!res)
SetDlgItemText(IDC_EDIT_UWINVERSION, "None");
return;
}
void CUwinGeneral::SetRegisteredUser()
{
SetDlgItemText(IDC_EDIT_REGUSER, "www.opensource.org/licenses/" LICENSE_ID);
}
void CUwinGeneral::SetLicenceKey()
{
SetDlgItemText(IDC_EDIT_LICENCEKEY, "uwin-users@research.att.com");
}
void CUwinGeneral::SetErrorLoggingLevel()
{
m_ComboLogLevel.SetCurSel(0);
}
void CUwinGeneral::SetInstalledUwinReleases()
{
DWORD i;
LONG ret;
HKEY key;
char* rel;
char release[64];
if((ret=RegOpenKeyEx( HKEY_LOCAL_MACHINE,UWIN_KEY,0,KEY_ENUMERATE_SUB_KEYS|KEY_WOW64_64KEY,&key)) != ERROR_SUCCESS)
return;
i = 0;
while (RegEnumKey(key, i++, release, sizeof(release)) == ERROR_SUCCESS)
m_ComboRelease.AddString(release);
RegCloseKey(key);
// Set the selection text
if (rel = regOps.GetRelease())
{
i = m_ComboRelease.FindStringExact(-1, rel);
if(i != CB_ERR)
m_ComboRelease.SetCurSel(i);
strcpy(m_Release, rel);
}
return;
}
void CUwinGeneral::OnSelendokComboLoglevel()
{
// TODO: Add your control notification handler code here
}
void CUwinGeneral::OnSelendokComboRelease()
{
// TODO: Add your control notification handler code here
char release[64];
if (m_ComboRelease.GetLBText(m_ComboRelease.GetCurSel(), release) != CB_ERR)
{
if(strcmp(m_Release, release))
{
strcpy(m_Release, release);
SetModified(TRUE);
}
}
}
void CUwinGeneral::OnChangeEditLicencekey()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CPropertyPage::OnInitDialog()
// function to send the EM_SETEVENTMASK message to the control
// with the ENM_CHANGE flag ORed into the lParam mask.
// TODO: Add your control notification handler code here
}
void CUwinGeneral::OnChangeEditReguser()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CPropertyPage::OnInitDialog()
// function to send the EM_SETEVENTMASK message to the control
// with the ENM_CHANGE flag ORed into the lParam mask.
// TODO: Add your control notification handler code here
}
|
31722aeba38de29faf2ebfce39f7ee99d5ab5632 | 56df675a4dfb1c5940c7e5846502e34765a2ff59 | /09-PCL_and_ICP/catkin_ws/src/pcl_example/src/icp_example.cpp | db4e2fde508a6361aec7fc8d3cbce825732d9c96 | [] | no_license | 7haomeng/Sening_Intelligent_System | e6d2ab121203f45df57d74b89da4ed7517e9a367 | 6d5e2b5fed00d646ce8fe8079f9ea8512a41234d | refs/heads/master | 2022-11-14T04:26:57.150131 | 2020-07-07T08:13:11 | 2020-07-07T08:13:11 | 257,192,307 | 2 | 0 | null | 2020-04-20T07:26:08 | 2020-04-20T06:32:41 | PostScript | UTF-8 | C++ | false | false | 7,437 | cpp | icp_example.cpp | #include <iostream>
#include <vector>
#include <ros/ros.h>
#include <boost/foreach.hpp>
#include <vector>
#include <Eigen/Core>
#include <string>
// PCL library
#include <pcl_ros/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/features/normal_3d.h>
#include <pcl/io/ply_io.h>
#include <pcl/common/transforms.h>
#include <pcl/common/common.h>
#include <pcl/common/centroid.h>
#include <pcl/filters/passthrough.h>
#include <pcl/filters/filter.h>
#include <pcl/filters/filter.h>
#include <pcl/filters/voxel_grid.h>
#include <pcl/filters/extract_indices.h>
#include <pcl/filters/conditional_removal.h>
#include <pcl/filters/statistical_outlier_removal.h>
#include <pcl/kdtree/kdtree.h>
#include <pcl/registration/icp.h>
typedef pcl::PointCloud<pcl::PointXYZRGB> PointCloudXYZRGB;
typedef pcl::PointCloud<pcl::PointXYZRGBNormal> PointCloudXYZRGBNormal;
using namespace std;
void addNormal(PointCloudXYZRGB::Ptr cloud, PointCloudXYZRGBNormal::Ptr cloud_with_normals)
{
/*Add normal to PointXYZRGB
Args:
cloud: PointCloudXYZRGB
cloud_with_normals: PointXYZRGBNormal
*/
pcl::PointCloud<pcl::Normal>::Ptr normals ( new pcl::PointCloud<pcl::Normal> );
pcl::search::KdTree<pcl::PointXYZRGB>::Ptr searchTree (new pcl::search::KdTree<pcl::PointXYZRGB>);
searchTree->setInputCloud ( cloud );
pcl::NormalEstimation<pcl::PointXYZRGB, pcl::Normal> normalEstimator;
normalEstimator.setInputCloud ( cloud );
normalEstimator.setSearchMethod ( searchTree );
//normalEstimator.setKSearch ( 50 );
normalEstimator.setRadiusSearch (0.01);
normalEstimator.compute ( *normals );
pcl::concatenateFields( *cloud, *normals, *cloud_with_normals );
vector<int> indices;
pcl::removeNaNNormalsFromPointCloud(*cloud_with_normals, *cloud_with_normals, indices);
return;
}
void point_preprocess(PointCloudXYZRGB::Ptr cloud)
{
/*Preprocess point before ICP
Args:
cloud: PointCloudXYZRGB
*/
//////////////Step1. Remove Nan////////////
printf("Original point number: %d\n",cloud->points.size());
vector<int> indices;
pcl::removeNaNFromPointCloud(*cloud, *cloud, indices);
//////////////Step2. Downsample////////////
pcl::VoxelGrid<pcl::PointXYZRGB> sor;
sor.setInputCloud (cloud);
sor.setLeafSize (0.004f, 0.004f, 0.004f);
sor.filter (*cloud);
copyPointCloud(*cloud, *cloud);
printf("Downsampled point number: %d\n",cloud->points.size());
//////////////Step3. Denoise//////////////
pcl::StatisticalOutlierRemoval<pcl::PointXYZRGB> sor2;
if (cloud->points.size()>100){
sor2.setInputCloud (cloud);
sor2.setMeanK (50);
sor2.setStddevMulThresh (0.5);
sor2.filter (*cloud);
}
vector<int> indices2;
pcl::removeNaNFromPointCloud(*cloud, *cloud, indices2);
printf("Donoised point number: %d\n",cloud->points.size());
return;
}
Eigen::Matrix4f initial_guess(PointCloudXYZRGB::Ptr cloud_src, PointCloudXYZRGB::Ptr cloud_target)
{
Eigen::Vector4f src_centroid, target_centroid;
pcl::compute3DCentroid (*cloud_src, src_centroid);
pcl::compute3DCentroid (*cloud_target, target_centroid);
Eigen::Matrix4f tf_tran = Eigen::Matrix4f::Identity();
Eigen::Matrix4f tf_rot = Eigen::Matrix4f::Identity();
//
Eigen::Matrix3f covariance;
pcl::computeCovarianceMatrixNormalized(*cloud_src, src_centroid, covariance);
Eigen::SelfAdjointEigenSolver<Eigen::Matrix3f> eigen_solver(covariance, Eigen::ComputeEigenvectors);
Eigen::Matrix3f eigenVectorsPCA = eigen_solver.eigenvectors();
Eigen::Vector3f eigenValuesPCA = eigen_solver.eigenvalues();
Eigen::Matrix3f covariance2;
pcl::computeCovarianceMatrixNormalized(*cloud_target, target_centroid, covariance2);
Eigen::SelfAdjointEigenSolver<Eigen::Matrix3f> eigen_solver2(covariance2, Eigen::ComputeEigenvectors);
Eigen::Matrix3f eigenVectorsPCA2 = eigen_solver2.eigenvectors();
// Eigen::Quaternion<float> rot_q = Eigen::Quaternion<float>::FromTwoVectors(eigenVectorsPCA.row(0),eigenVectorsPCA2.row(0));
Eigen::Matrix3f R ;
R = eigenVectorsPCA2 * eigenVectorsPCA.inverse();
for (int i = 0;i<3;i++)
for (int j = 0;j<3;j++)
tf_rot(i,j) = R(i,j);
tf_tran(0,3) = target_centroid[0] - src_centroid[0];
tf_tran(1,3) = target_centroid[1] - src_centroid[1];
tf_tran(2,3) = target_centroid[2] - src_centroid[2];
Eigen::Matrix4f tf = tf_rot * tf_tran ;
return tf;
}
Eigen::Matrix4f point_2_plane_icp(PointCloudXYZRGB::Ptr cloud_src, PointCloudXYZRGB::Ptr cloud_target, PointCloudXYZRGBNormal::Ptr trans_cloud)
{
PointCloudXYZRGBNormal::Ptr cloud_source_normals ( new PointCloudXYZRGBNormal );
PointCloudXYZRGBNormal::Ptr cloud_target_normals ( new PointCloudXYZRGBNormal );
addNormal( cloud_src, cloud_source_normals );
addNormal( cloud_target, cloud_target_normals );
pcl::IterativeClosestPointWithNormals<pcl::PointXYZRGBNormal, pcl::PointXYZRGBNormal>::Ptr icp ( new pcl::IterativeClosestPointWithNormals<pcl::PointXYZRGBNormal, pcl::PointXYZRGBNormal> () );
icp->setMaximumIterations ( 2000 );
// icp.setMaxCorrespondenceDistance(1);
icp->setTransformationEpsilon(1e-10);
icp->setEuclideanFitnessEpsilon(0.01);
icp->setInputSource ( cloud_source_normals ); // not cloud_source, but cloud_source_trans!
icp->setInputTarget ( cloud_target_normals );
// registration
icp->align ( *trans_cloud ); // use cloud with normals for ICP
if ( icp->hasConverged() ){
cout << "icp score: " << icp->getFitnessScore() << endl;
}
else
cout << "Not converged." << endl;
Eigen::Matrix4f inverse_transformation = icp->getFinalTransformation();
}
int main(int argc, char** argv)
{
ros::init(argc, argv, "icp");
ros::NodeHandle nh;
ros::Publisher model_publisher = nh.advertise<sensor_msgs::PointCloud2> ("/camera/model", 1);
ros::Publisher cloud_publisher = nh.advertise<sensor_msgs::PointCloud2> ("/camera/cloud", 1);
ros::Publisher initial_guess_tf_publisher = nh.advertise<sensor_msgs::PointCloud2> ("/camera/ini_guess", 1);
ros::Publisher registered_cloud_publisher = nh.advertise<sensor_msgs::PointCloud2> ("/camera/registered_cloud", 1);
/*Load pre-scanned Model and observed cloud*/
PointCloudXYZRGB::Ptr model(new PointCloudXYZRGB);
PointCloudXYZRGB::Ptr cloud(new PointCloudXYZRGB);
PointCloudXYZRGB::Ptr ini_guess_tf_cloud(new PointCloudXYZRGB);
PointCloudXYZRGBNormal::Ptr registered_cloud(new PointCloudXYZRGBNormal);
string model_path;
string cloud_path;
nh.getParam("model_path", model_path);
nh.getParam("cloud_path", cloud_path);
printf("Load model\n");
pcl::io::loadPLYFile<pcl::PointXYZRGB>(model_path, *model);
printf("Finish Load model\n");
pcl::PolygonMesh mesh;
pcl::io::loadPLYFile(cloud_path, mesh);
pcl::fromPCLPointCloud2( mesh.cloud, *cloud );
printf("Finish Load model\n");
model ->header.frame_id = "/map";
cloud ->header.frame_id = "/map";
point_preprocess(model);
point_preprocess(cloud);
printf("Initial guess\n");
Eigen::Matrix4f tf1 = initial_guess(cloud, model);
pcl::transformPointCloud (*cloud, *ini_guess_tf_cloud, tf1);
printf("ICP\n");
Eigen::Matrix4f tf2 = point_2_plane_icp(ini_guess_tf_cloud, model, registered_cloud);
Eigen::Matrix4f final_tf = tf1 * tf2;
cout << final_tf << endl;
while (ros::ok()){
model_publisher.publish(model);
cloud_publisher.publish(cloud);
initial_guess_tf_publisher.publish(ini_guess_tf_cloud);
registered_cloud_publisher.publish(registered_cloud);
}
return 0;
}
|
3f1a8d3073a7ef4e9b8c5881db0b2a82d6ced439 | 6591f72482056734ea4b40e53cc629ffebf28929 | /hw-3/d.cpp | b998fc9721207f30466b2f2107c8a14ca04c722b | [] | no_license | error1707/algo-hw | 44d9f6ed16ed28cbd7e1cf65ce7240f1d3d5846a | e71b4cf0bcb4be98cc0112642176c1c0c30aa60b | refs/heads/master | 2022-12-25T20:20:08.306583 | 2020-10-09T12:45:21 | 2020-10-09T12:45:21 | 293,856,395 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,700 | cpp | d.cpp | #include <iostream>
#include <vector>
using namespace std;
bool dfs(int v, vector<bool>& used, const vector<vector<int>>& routes, vector<int>& matching){
if(used[v]) {
return false;
}
used[v] = true;
for(auto to : routes[v]) {
if(matching[to] == -1 or dfs(matching[to], used, routes, matching)) {
matching[to] = v;
return true;
}
}
return false;
}
void kuhn(const vector<vector<int>>& routes, vector<int>& matching) {
vector <bool> used(routes.size());
for (int i = 0; i < routes.size(); ++i) {
used.assign(used.size(), false);
dfs(i, used, routes, matching);
}
}
struct Client {
int time, a, b, c, d;
};
int drive(Client c) {
return abs(c.a - c.c) + abs(c.b - c.d);
}
int drive(Client f, Client s) {
return abs(f.c - s.a) + abs(f.d - s.b);
}
int main() {
int n, pairs = 0, from, to, h, m, start_time;
char tmp;
string s;
cin >> n;
vector<vector<int>> routes(n);
vector<Client> clients(n);
for (int i = 0; i < n; ++i) {
cin >> h >> tmp >> m;
clients[i].time = h * 60 + m;
cin >> clients[i].a >> clients[i].b >> clients[i].c >> clients[i].d;
}
for (int i = 0; i < n - 1; ++i) {
start_time = clients[i].time + drive(clients[i]);
for (int j = i + 1; j < n; ++j) {
if(start_time + drive(clients[i], clients[j]) < clients[j].time) {
routes[i].push_back(j);
}
}
}
vector<int> matching(n, -1);
kuhn(routes, matching);
for(auto i : matching) {
if(i != -1) {
++pairs;
}
}
cout << n - pairs << '\n';
return 0;
} |
bf3a4ff7ba362baeb0d307d5c973878b9653648a | 9476baf4b0f2254efa7b5386d9b1d2da6e639055 | /chapter07/7-2.cpp | b9ae25ed8d43ecc23d0f4e4ef902feca3e61d8fd | [] | no_license | shrimpie/cracking_the_coding_interview | 16a3fbe3e945e922b4e3423484c8c58a9a5324b6 | a96f093bcbafcb0a63d23dc49560df0c4c31738d | refs/heads/master | 2021-06-09T06:16:56.385340 | 2016-11-12T00:35:51 | 2016-11-12T00:35:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,033 | cpp | 7-2.cpp | // 7.2 Imagine you have a call center with three levels of employees: fresher,
// technical lead (TL), product manager (PM). There can be multiple
// employees, but only one TL or PM. An incoming telephone call must be
// allocated to a fresher who is free. If a fresher can't handle the call,
// he or she must escalate the call to technical lead. If the TL is not
// free or not able to handle it, then the call should be escalated to PM.
// Design the classes and data structures for this problem. Implement a
// method get_call_handler().
// Solution
// All three ranks of employees have different work to be done, so those
// specific functions are profile specific. We should keep these specific
// things within their respective class.
// There are a few things which are common to them, like addresses, name, job
// title, age, etc. These things can be kept in one class and can be extended
// / inherited by others.
// Finally, there should be one CallHandler class which would route the calss
// to the concerned person.
// ............................................................................
// Note: On any object oriented design question, there are many ways to design
// the objects. Discuss the trade-offs of different solutions with your
// interviewer. You should usually design for long term code flexibility and
// maintainance.
// ............................................................................
#include <iostream>
#include <vector>
#include <queue>
#include <unistd.h>
#include <thread>
#include <ostream>
#include <sstream>
#include <mutex>
using namespace std;
class Logger {
public:
// destructor is called when output is collected and
// the temporary Logger() dies (after the ";").
~Logger() {
Logger::mutex_.lock(); // make sure I am the only one writing
std::cout << buffer_.str(); // write
std::cout << std::flush; // push to output
Logger::mutex_.unlock(); // I am done, now other threads can write
}
// funny construct you need to chain logs with "<<" like
// in std::cout << "var = " << var;
template <typename T>
Logger &operator<<(T input) {
buffer_ << input;
return *this;
}
private:
// collect the output from chained << calls
std::ostringstream buffer_;
// mutex shared between all instances of Logger
static std::mutex mutex_;
};
// define the static variable. This line must be in one .cpp file
std::mutex Logger::mutex_;
class Call
{
int id = 1;
int rank = 0; // minimal rank of employee who can handle this call
public:
Call(int r, int i=0) : rank(r), id(i) {}
void reply(string msg) {}
void disconnect() {}
int get_id()
{
return id;
}
int get_rank()
{
return rank;
}
void set_rank(int r)
{
rank = r;
}
};
class CallHandler;
class Employee
{
static CallHandler* call_handler;
int rank; // 0 - fresher, 1 - techincal lead, 2 - product manager
int id;
mutex* mtx;
public:
bool free;
Employee(int r, int i) : rank(r), id(i), free(true)
{
mtx = new mutex();
}
bool is_free()
{
return free;
}
void set_busy()
{
mtx->lock();
free = false;
mtx->unlock();
}
void set_free()
{
mtx->lock();
free = true;
mtx->unlock();
}
int get_id()
{
return id;
}
int get_rank()
{
return rank;
}
void receive_call(Call* call)
{
Logger() << "Employee (id: " << id << ", rank: " << rank
<< ") dealing with call (id: " << call->get_id() << ", rank: "
<< call->get_rank() << ").\n";
sleep(rand() % 3 + 1);
call_handled(call);
}
void call_handled(Call* call) // Call is complete
{
Logger() << "Employee (id: " << id << ", rank: " << rank
<< ") done with call (id: " << call->get_id() << ", rank: "
<< call->get_rank() << ").\n";
set_free();
}
void cannot_handle(Call* call); // escalate call
};
class Fresher : public Employee
{
public:
Fresher(int id) : Employee(0, id)
{
}
};
class TechLead : public Employee
{
public:
TechLead(int id) : Employee(1, id)
{
}
};
class PM : public Employee
{
public:
PM(int id) : Employee(2, id)
{
}
};
class CallHandler
{
static const int levels = 3; // We have 3 levels of employees
static const int num_freshers = 5; // We have 5 freshers
static const int num_techlead = 3; //
static const int num_pm = 1;
vector<vector<Employee*> >* employee_levels;
vector<queue<Call*> >* call_queues;
queue<thread*> workers;
public:
CallHandler()
{
employee_levels = new vector<vector<Employee*> >(levels);
employee_levels->push_back(vector<Employee*>());
for(int i = 0; i < num_freshers; ++i)
(*employee_levels)[0].push_back(new Fresher(i+1));
employee_levels->push_back(vector<Employee*>());
for(int i = 0; i < num_techlead; ++i)
(*employee_levels)[1].push_back(new TechLead(i+1));
employee_levels->push_back(vector<Employee*>());
for(int i = 0; i < num_pm; ++i)
(*employee_levels)[2].push_back(new PM(i+1));
call_queues = new vector<queue<Call*> >(levels);
}
Employee* get_call_handler(Call*);
void dispatch(Call* c)
{
thread* t = new thread(&CallHandler::dispatch_call, this, c);
workers.push(t);
}
void check_queue()
{
while(true)
{
usleep(5000);
for(int i = 0; i < levels; ++i)
{
if(!(*call_queues)[i].empty())
{
Call* c = (*call_queues)[i].front();
(*call_queues)[i].pop();
// Logger() << "Get call (id: " << c->get_id()
// << ", rank: " << c->get_rank() << ") from queue \n";
dispatch(c);
}
}
}
}
void do_work()
{
while(true)
{
usleep(5000);
if(!workers.empty())
{
thread* t = workers.front();
t->join();
workers.pop();
}
}
}
// routes the call to an available employee, or adds to a queue
void dispatch_call(Call*);
void get_next_call(Employee* e)
{
// look for call for e's rank
int rank = e->get_rank();
if(!(*call_queues)[rank].empty())
{
Call* c = (*call_queues)[rank].front();
(*call_queues)[rank].pop();
dispatch(c);
}
Logger() << "Call queues for rank " << rank << " now empty.\n";
}
};
void Employee::cannot_handle(Call* call) // escalate call
{
call->set_rank(rank + 1);
call_handler->dispatch(call);
set_free();
call_handler->get_next_call(this); // looking for waiting call
}
Employee* CallHandler::get_call_handler(Call* call)
{
for(int level = call->get_rank(); level < levels; ++level)
{
vector<Employee*> employee_level = (*employee_levels)[level];
for(auto e : employee_level)
{
if(e->is_free())
{
e->set_busy();
return e;
}
}
}
return NULL;
}
// routes the call to an available employee, or adds to a queue
void CallHandler::dispatch_call(Call* call)
{
// Try to route the call to an employee with minimal rank
// Logger() << "dispatching..." << '\n';
Employee* emp = get_call_handler(call);
if(emp != NULL)
{
Logger() << "Get employee (id: " << emp->get_id()
<< ", rank: " << emp->get_rank() << ").\n";
}
if(emp != NULL)
emp->receive_call(call);
else // Place the call into queue according to its rank
{
// Logger() << "No employee available, put the call in queue.\n";
(*call_queues)[call->get_rank()].push(call);
}
}
class CallCenter
{
queue<Call*>* calls;
static int handled_calls;
CallHandler* call_handler;
public:
CallCenter(CallHandler* ch) : call_handler(ch)
{
calls = new queue<Call*>();
}
Call* get_call()
{
if(!calls->empty())
{
Call* c = calls->front();
calls->pop();
return c;
}
Logger() << "No new calls available.\n";
return NULL;
}
void add_call(Call* c)
{
calls->push(c);
}
bool has_calls()
{
return !(calls->empty());
}
void generate_rand_calls()
{
while(true)
{
sleep(1);
srand(time(NULL));
if(rand() % 10 > 4)
{
int rank = rand() % 3;
Logger() << "Call id: " << ++handled_calls
<< ", rank: " << rank << '\n';
add_call(new Call(rank, handled_calls));
}
}
}
void check_calls()
{
while(true)
{
usleep(5000);
if(!calls->empty())
{
Call* c = get_call();
call_handler->dispatch(c);
}
}
}
};
int CallCenter::handled_calls = 0;
CallHandler* CH = new CallHandler();
CallHandler* Employee::call_handler = CH;
int main()
{
CallCenter cc(CH);
thread* call_gen = new thread(&CallCenter::generate_rand_calls, &cc);
thread* call_checker = new thread(&CallCenter::check_calls, &cc);
thread* dispatcher = new thread(&CallHandler::do_work, CH);
thread* queue_checker = new thread(&CallHandler::check_queue, CH);
call_gen->join();
call_checker->join();
dispatcher->join();
queue_checker->join();
return 0;
}
// Note: this thing now works, but my computer gets hot..., maybe using thread
// is not a great idea, especially with a while(true), how could you do this
// use interrupts instead?
// With sleep in each thread, the while(true) now stops hogging the CPU, but
// not sure it's the best answer.
|
12fab396d42a4b10c7514eed4fdd220aad13cb5a | 174e53d2b36ad89d4421b97817c9b5c84db9612a | /src/include/Flock.h | f22059b3842bb0dc72eb08d132ef32ddc6ed4ff9 | [] | no_license | nkyllonen/5611_HW3 | 4d358adb39ade3516213b429117a7fcbefcb007d | 3a9f68b40d1f187427c2f78eeba5879c967e390d | refs/heads/master | 2021-04-26T23:16:11.375532 | 2018-04-03T20:05:07 | 2018-04-03T20:05:07 | 123,960,825 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,078 | h | Flock.h | #ifndef FLOCK_INCLUDED
#define FLOCK_INCLUDED
#include "glad.h" //Include order can matter here
#ifdef __APPLE__
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
#elif __linux__
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
#else
#include <SDL.h>
#include <SDL_opengl.h>
#endif
#define GLM_FORCE_RADIANS
#include "glm/glm.hpp"
#include "glm/gtc/matrix_transform.hpp"
#include "glm/gtc/type_ptr.hpp"
#include "Vec3D.h"
#include "Node.h"
#include "Agent.h"
#include "PRM.h"
#include "CSpace.h"
class Flock
{
private:
Agent** followers;
Agent** leaders;
int num_followers = 0;
int num_leaders = 0;
float neighborhood_r = 40.0;
float max_vel = 50.0;
float max_acc = 50.0;
CSpace* myCSpace;
float error = 0.5;
public:
//PUBLIC VARIABLES
float k_sep = 0.8;
float k_all = 1.0;
float k_coh = 2.0;
float k_obs = 5.0;
Flock();
Flock(int nf, int nl, PRM* myPRM, CSpace* cs, int model_start, int model_verts);
~Flock();
//OTHERS
void update(float dt);
void draw(GLuint shader);
};
#endif
|
cc84008d53ded17b0211b7ef52d740bccfea8417 | 596205f1194c2f43c082071fa249f264816a6210 | /trunk/source/libvm/CentralVM.cpp | e4750b2d69b8bb60d1f0de1d8ed2983dc83a8e33 | [] | no_license | anat/epitivo | ec2a00fd244ecf6bd1a2d3b9d750619f863c3ae4 | 78e3ec6a1f8eddd000eb5d60776e3a6fd0060ade | refs/heads/master | 2020-03-27T18:47:57.238066 | 2011-07-04T10:05:52 | 2011-07-04T10:05:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 629 | cpp | CentralVM.cpp | #include "CentralVM.hpp"
namespace vm
{
CentralVM *CentralVM::_instance = 0;
CentralVM::CentralVM() {}
CentralVM::~CentralVM() {}
CentralVM* CentralVM::GetInstance()
{
if (!_instance)
_instance = new CentralVM;
return _instance;
}
void CentralVM::DelInstance()
{
if (_instance)
delete _instance;
}
void CentralVM::LoadFile(QString const & filePath)
{
_currentMediaPath = filePath;
}
void CentralVM::loadImage(QString const & filePath)
{
}
void CentralVM::loadMusic(QString const & filePath)
{
}
void CentralVM::loadVideo(QString const & filePath)
{
}
}
|
c58bede96dba78d39c076e423a842e64bbe0f7cb | 8d6c298d5b37ac55c777a3215e8668fdfef3fd4a | /modules/DotnetPlugins/plugin_instance.hpp | 7d089732f31fefefa3d282bbcf75c5b52af63c33 | [] | no_license | kain64/nscp | 326d2c7223b7bec3c88ec5f8b66bb14d92b6ae7a | 58b6d2bcf910b57c84b8271c4392f937898e970b | refs/heads/master | 2021-01-14T10:52:28.874449 | 2016-08-28T15:22:18 | 2016-08-28T15:22:18 | 66,774,814 | 0 | 0 | null | 2016-08-28T15:10:23 | 2016-08-28T15:10:23 | null | UTF-8 | C++ | false | false | 2,636 | hpp | plugin_instance.hpp | #pragma once
#include "Vcclr.h"
#include <clr/clr_scoped_ptr.hpp>
#include <string>
#include <boost/enable_shared_from_this.hpp>
typedef cli::array<System::Byte> protobuf_data;
std::string to_nstring(System::String^ s);
System::String^ to_mstring(const std::string &s);
std::string to_nstring(protobuf_data^ byteArray);
protobuf_data^ to_pbd(const std::string &buffer);
class plugin_manager_interface;
class internal_plugin_instance {
private:
std::string dll;
std::string type;
gcroot<System::Type^> typeInstance;
gcroot<NSCP::Core::IPlugin^> plugin;
gcroot<NSCP::Core::PluginInstance^> instance;
public:
internal_plugin_instance::internal_plugin_instance(std::string dll, std::string type) : dll(dll), type(type) {}
bool load_dll(boost::shared_ptr<internal_plugin_instance> self, plugin_manager_interface *manager, std::string alias, int plugin_id);
bool load_plugin(int mode);
bool unload_plugin();
int onCommand(std::string command, std::string request, std::string &response);
int onSubmit(std::wstring channel, std::string request, std::string &response);
virtual NSCP::Core::PluginInstance^ get_instance() {
return instance;
}
};
typedef boost::shared_ptr<internal_plugin_instance> internal_plugin_instance_ptr;
class plugin_manager_interface {
public:
virtual bool register_command(std::string command, internal_plugin_instance_ptr plugin) = 0;
virtual nscapi::core_wrapper* get_core() = 0;
};
ref class CoreImpl : public NSCP::Core::ICore {
private:
plugin_manager_interface *manager;
clr::clr_scoped_ptr<internal_plugin_instance_ptr> internal_instance;
nscapi::core_wrapper* get_core();
public:
CoreImpl(plugin_manager_interface *manager);
virtual NSCP::Core::Result^ query(protobuf_data^ request);
virtual NSCP::Core::Result^ exec(System::String^ target, protobuf_data^ request);
virtual NSCP::Core::Result^ submit(System::String^ channel, protobuf_data^ request);
virtual bool reload(System::String^ module);
virtual NSCP::Core::Result^ settings(protobuf_data^ request);
virtual NSCP::Core::Result^ registry(protobuf_data^ request);
virtual void log(protobuf_data^ request);
// Local
virtual NSCP::Core::PluginInstance^ getInstance() {
return (*internal_instance)->get_instance();
}
void set_instance(internal_plugin_instance_ptr newInstance) {
internal_instance.reset(new internal_plugin_instance_ptr(newInstance));
}
};
struct plugin_manager {
virtual bool register_command(std::string command, internal_plugin_instance_ptr plugin) = 0;
virtual nscapi::core_wrapper* get_core() = 0;
}; |
5f1773f6093581c2cdfce08cbbc4bc8d9c1a4f73 | 04213a643e1d37f6e23e503a4f30d734019cddd8 | /beluga/net/Channel.h | 4b8dcf4bca146285487c4f5b76c728a98fa56116 | [
"MIT"
] | permissive | ZhangSenyan/beluga | 57cfb876c2cb0777f607b2972f3218e58003a811 | 1a44f062e82d0edd6bace9ab5ff0c5745e99d881 | refs/heads/master | 2020-06-01T18:12:43.472970 | 2019-07-27T03:08:11 | 2019-07-27T03:08:11 | 190,877,248 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,303 | h | Channel.h | /**
* @author Zhang Senyan
* Date: 2019-04-13
*
*/
#ifndef BELUGA_CHANNEL_H
#define BELUGA_CHANNEL_H
#include <functional>
#include <sys/epoll.h>
#include <memory>
#include "beluga/beluga.h"
class Connection;
class Channel{
public:
explicit Channel(int fd);
~Channel();
private:
//事件处理函数
beluga::CallFunc _readhandler;
beluga::CallFunc _writehandler;
beluga::CallFunc _errorhandler;
//所属Connection的文件句柄
int _fd;
__uint32_t _events;
__uint32_t _revents;
//所属的Connection
std::weak_ptr<Connection> _holder;
public:
//关联所属Connection
void setHolder(const std::shared_ptr<Connection> &holder);
//注册事件处理函数
void setReadHandler(beluga::CallFunc readhandler);
void setWriteHandler(beluga::CallFunc writehandler);
void setErrorHandler(beluga::CallFunc errorhandler);
void handleEvents();
int getFD();
void setFD(int fd);
__uint32_t getEvents();
void setEvents(__uint32_t events);
//获取返回事件
__uint32_t getRevents();
//设定返回事件
void setRevents(__uint32_t revents);
void addEvents(__uint32_t events);
void removeEvents(__uint32_t events);
bool expired();
};
#endif //BELUGA_CHANNEL_H
|
f7d16d03e4292755ef704d6b6662076354fd58a1 | 12043db0f57f5d9402a99507648bcbb4d9417452 | /Programming_Abstractions/Chapter_01/Exercise_11/Exercise_11/circular_arc.cpp | 3b92d455b9fdc77ab0a325cb91c9024aa292cfd8 | [] | no_license | daniellozuz/CPP | a8afb1ae3353bd483cf953fac8a70b0b1446023c | fdc8957158522fc27aa55a44b3e45333157b843f | refs/heads/master | 2021-05-12T08:31:17.581023 | 2018-03-07T23:41:45 | 2018-03-07T23:41:45 | 117,283,294 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 344 | cpp | circular_arc.cpp | #include <iostream>
#define PRECISION 100
using namespace std;
int main(void) {
double area = 0.0;
double width = 2.0 / PRECISION;
for (int i = 0; i < PRECISION; i++)
area += width * sqrt(2 * 2 - i * i * width * width);
cout << "Approximation of pi equals " << area << endl;
cin.get();
return 0;
}
|
9fb77526449d4d9b06bfddc58a1db710abe8d16b | cbf187c628e9aef224c6cc432a3c63401567d6c7 | /train/new.cpp | 4a843a536dba0a197fb4f7f21c5ec5789d59cdd2 | [] | no_license | WayKwin/WD_backup | 64bbddcd1fc8b64dd5d941766f9f66636aef5c5a | e2e0005b9f0e06bb20d4b9d0c86106e9e8842148 | refs/heads/master | 2020-03-10T03:56:44.044819 | 2018-08-30T15:30:54 | 2018-08-30T15:30:54 | 129,179,507 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,222 | cpp | new.cpp | t way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way
find right way sd
find right way
find right way
find right way
find right way:w
find right way
find right way
find right way
find right way
find right way
|
67da97ba3fab01d8acf62ceb9156830679b6e90a | 77a8093c6df9acdba49bc993a01bc4583d1a0cbe | /date.cpp | 3c72c72981056a5d8185da98cbb9047255afabd9 | [] | no_license | fenixD3/Database-class | ed57e3a7de699f438b9e6cccc89016427ef2ba61 | e04ef86a444816900b3b9b20c2d489cd680ef947 | refs/heads/master | 2022-11-22T02:25:20.106848 | 2020-07-29T08:20:13 | 2020-07-29T08:20:13 | 268,055,231 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,267 | cpp | date.cpp | #include "date.h"
#include <stdexcept>
#include <string>
#include <iomanip>
Date::Date(const uint16_t& n_year, const uint16_t &n_month, const uint16_t &n_day)
: year(n_year)
, month(n_month)
, day(n_day) {}
uint16_t Date::GetYear() const
{
return year;
}
uint16_t Date::GetMonth() const
{
return month;
}
uint16_t Date::GetDay() const
{
return day;
}
Date ParseDate(istream& is)
{
int16_t year, month, day;
is >> year;
if (year < 0 || year > 9999)
throw invalid_argument("Wrong year: " + to_string(month));
SkipSymbol(is);
is >> month;
if (month < 1 || month > 12)
throw invalid_argument("Wrong month: " + to_string(month));
SkipSymbol(is);
is >> day;
if (day < 1 || day > 31)
throw invalid_argument("Wrong day: " + to_string(day));
return Date(year, month, day);
}
void SkipSymbol(istream& is)
{
char d = is.peek();
if (d == '-')
is.ignore(1);
else
{
string delim = {d};
throw invalid_argument("Wrong delimetr: " + delim);
}
}
ostream& operator<<(ostream& out, const Date& date)
{
out << setw(4) << setfill('0') << date.GetYear() << '-' << setw(2)
<< setfill('0') << date.GetMonth() << '-' << setw(2) << setfill('0') << date.GetDay();
return out;
}
bool operator<(const Date& lhs, const Date& rhs)
{
return make_tuple(lhs.GetYear(), lhs.GetMonth(), lhs.GetDay()) < make_tuple(rhs.GetYear(), rhs.GetMonth(), rhs.GetDay());
}
bool operator<=(const Date& lhs, const Date& rhs)
{
return make_tuple(lhs.GetYear(), lhs.GetMonth(), lhs.GetDay()) <= make_tuple(rhs.GetYear(), rhs.GetMonth(), rhs.GetDay());
}
bool operator>(const Date& lhs, const Date& rhs)
{
return make_tuple(lhs.GetYear(), lhs.GetMonth(), lhs.GetDay()) > make_tuple(rhs.GetYear(), rhs.GetMonth(), rhs.GetDay());
}
bool operator>=(const Date& lhs, const Date& rhs)
{
return make_tuple(lhs.GetYear(), lhs.GetMonth(), lhs.GetDay()) >= make_tuple(rhs.GetYear(), rhs.GetMonth(), rhs.GetDay());
}
bool operator==(const Date& lhs, const Date& rhs)
{
return make_tuple(lhs.GetYear(), lhs.GetMonth(), lhs.GetDay()) == make_tuple(rhs.GetYear(), rhs.GetMonth(), rhs.GetDay());
}
bool operator!=(const Date& lhs, const Date& rhs)
{
return make_tuple(lhs.GetYear(), lhs.GetMonth(), lhs.GetDay()) != make_tuple(rhs.GetYear(), rhs.GetMonth(), rhs.GetDay());
}
|
5aad302e196eebd0f143f0e70592f7c69c04979a | 1926d274623a32a6b834b66366f2bcec672cbd9c | /DetectLineOut/Scelton/DetectLineOut/DetectLineState.h | 18cc3af66e8d813e53a90c6c173656d0ba4eda15 | [] | no_license | class-snct-rikitakelab/e-konbu2012 | 968f3cf173a298de1aad8f0dcf8fc5c5d24a96bd | 01405c50d7c5580bacba923f86281895a0c7a723 | refs/heads/master | 2020-05-29T10:06:04.033860 | 2013-04-03T12:24:55 | 2013-04-03T12:24:55 | 9,192,781 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 297 | h | DetectLineState.h | #ifndef DETECTLINEOUT_DETECT_LINE_STATE_H
#define DETECTLINEOUT_DETECT_LINE_STATE_H
#include <string>
#include <vector>
#include <list>
#include <iostream>
#include <assert.h>
namespace DetectLineOut
{
typedef enum
{
OnLine,
OutOfLine
} DetectLineState;
} // namespace DetectLineOut
#endif
|
a6ca9f4bf41bc9823cb403a28cfe9c4e9508289f | 453ef442430b58701b4e67bc9c6d55cc0d7aeb3f | /workspace/src/SlalomBlackyInfomation/SlBkActionInfomation.cpp | 4395444fcc8502410b831b8b06f9765040f034c4 | [] | no_license | sakiyama02/chanponship | 6d6348eb3e200b7682aa3ec3917e2c7746f754cb | 2dccb2670d03db301434c223d3b80beed55a24d3 | refs/heads/master | 2023-09-06T00:12:07.740578 | 2021-10-22T02:33:11 | 2021-10-22T02:33:11 | 419,940,625 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,944 | cpp | SlBkActionInfomation.cpp | //SlBkActionInfomation
//スラロームブラッキーアクションインフォメーション
//
#include "../../include/SlalomBlackyInfomation/SlBkActionInfomation.h"
SlBkActionInfomation::SlBkActionInfomation(){
memset(changeInfoData,0,sizeof(ChangeInfo) * SLALOMBLACKY_NUM);
int16 index = 0;
//template
/*
//rgb切り替え設定
//r :rの切り替え値
//g :gの切り替え値
//b :bの切り替え値
//condition:切り替え地点の範囲指定(HIGH.LOW.NONE)
changeInfoData[index].rgb_data.r=0;
changeInfoData[index].rgb_data.g=0;
changeInfoData[index].rgb_data.b=0;
changeInfoData[index].rgb_data.condition=NONE;
//座標切り替え設定
//xPosition :x座標の切り替え値
//yPosition :y座標の切り替え値
//xCondition:x座標切り替え地点の範囲指定(HIGH.LOW.NONE)
//yCondition:y座標切り替え地点の範囲指定(HIGH.LOW.NONE)
changeInfoData[index].pos_info_data.potision.xPosition=0f;
changeInfoData[index].pos_info_data.potision.yPosition=0f;
changeInfoData[index].pos_info_data.xCondition=NONE;
changeInfoData[index].pos_info_data.yCondition=NONE;
//向き切り替え設定
//direction:向きの切り替え値
//condition:向きの切り替え地点の範囲指定(HIGH.LOW.NONE)
changeInfoData[index].direction_data.direction=0;
changeInfoData[index].direction_data.condition=NONE;
//距離の切り替え設定
//distance:距離の切り替え値
changeInfoData[index].distance=0;
//v値切り替え値設定
//v:v値の切り替え値
//condition:v値の切り替え地点の範囲指定(HIGH.LOW.NONE)
changeInfoData[index].vData.v=0;
changeInfoData[index].vData.condition=NONE;
//s値切り替え値設定
//s:s値の切り替え値
//condition:s値の切り替え地点の範囲指定(HIGH.LOW.NONE)
changeInfoData[index].sData.s=0;
changeInfoData[index].sData.condition=NONE;
//切り替え方法
//judge:切り替え方法の指定
//(JUDGE_RGB,JUDGE_POS,JUDGE_DIS,
//JUDGE_DIR,JUDGE_NONE,JUDGE_SEND)
changeInfoData[index].judge=JUDGE_NONE;
//機体の動作設定
//section_act:機体の動作設定
//(LINE_TRACE,STRAIGHT,CURVE,LINE_CURVE,TURN,ARM_ACTION)
changeInfoData[index].section_act=STRAIGHT;
//機体の速度設定
//speed:速度の設定
changeInfoData[index].speed=0;
index++;
*/
//1
/*
changeInfoData[index].direction_data.direction=147;
changeInfoData[index].direction_data.condition=HIGH;
changeInfoData[index].distance=0;
changeInfoData[index].judge=JUDGE_DIR;
changeInfoData[index].section_act=TURN;
changeInfoData[index].speed=10;
*/
changeInfoData[index].direction_data.direction=147;
changeInfoData[index].direction_data.condition=HIGH;
changeInfoData[index].judge=JUDGE_DIR;
changeInfoData[index].section_act=CURVE;
changeInfoData[index].speed=20;//5;
index++;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//2
changeInfoData[index].vData.v=45;
changeInfoData[index].vData.condition=LOW;
changeInfoData[index].judge=JUDGE_V;
changeInfoData[index].section_act=STRAIGHT;
changeInfoData[index].speed=25;
index++;
//3
changeInfoData[index].pos_info_data.potision.xPosition=350*2*0.3527;
//changeInfoData[index].pos_info_data.potision.yPosition=3110;//3096
changeInfoData[index].pos_info_data.xCondition=LOW;
changeInfoData[index].pos_info_data.yCondition=NONE;//LOW
changeInfoData[index].distance=0;
changeInfoData[index].judge=JUDGE_POS;
changeInfoData[index].section_act=STRAIGHT;
changeInfoData[index].speed=25;
index++;
//4
changeInfoData[index].direction_data.direction=180;
changeInfoData[index].direction_data.condition=HIGH;
changeInfoData[index].judge=JUDGE_DIR;
changeInfoData[index].section_act=CURVE;
changeInfoData[index].speed=10;//5;
index++;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//5
changeInfoData[index].pos_info_data.potision.xPosition=225;
changeInfoData[index].pos_info_data.potision.yPosition=2960;
changeInfoData[index].pos_info_data.xCondition=NONE;
changeInfoData[index].pos_info_data.yCondition=LOW;
changeInfoData[index].distance=0;
changeInfoData[index].judge=JUDGE_POS;
changeInfoData[index].section_act=STRAIGHT;
changeInfoData[index].speed=25;
index++;
//**************************************************************************
//6
changeInfoData[index].pos_info_data.potision.xPosition=225;
changeInfoData[index].pos_info_data.potision.yPosition=2850;//2933//2860
changeInfoData[index].pos_info_data.xCondition=NONE;
changeInfoData[index].pos_info_data.yCondition=LOW;
changeInfoData[index].distance=0;
changeInfoData[index].judge=JUDGE_POS;
changeInfoData[index].section_act=ARM_ACTION;
changeInfoData[index].speed=15;
index++;
//7
changeInfoData[index].pos_info_data.potision.xPosition=225;
changeInfoData[index].pos_info_data.potision.yPosition=2835;//2912
changeInfoData[index].pos_info_data.xCondition=NONE;
changeInfoData[index].pos_info_data.yCondition=LOW;
changeInfoData[index].distance=0;
changeInfoData[index].judge=JUDGE_POS;
changeInfoData[index].section_act=ARMDOWN_ACTION;
changeInfoData[index].speed=10;
index++;
//8
changeInfoData[index].pos_info_data.potision.xPosition=225;
changeInfoData[index].pos_info_data.potision.yPosition=2835;//2876+//2780
changeInfoData[index].pos_info_data.xCondition=NONE;
changeInfoData[index].pos_info_data.yCondition=LOW;
changeInfoData[index].distance=0;
changeInfoData[index].judge=JUDGE_POS;
changeInfoData[index].section_act=STRAIGHT;
changeInfoData[index].speed=20;
index++;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//9
//changeInfoData[index].direction_data.direction=205;
//changeInfoData[index].direction_data.condition=HIGH;
//changeInfoData[index].judge=JUDGE_DIR;
changeInfoData[index].vData.v=90;
changeInfoData[index].vData.condition=LOW;
changeInfoData[index].judge=JUDGE_V;
changeInfoData[index].section_act=CURVE;
changeInfoData[index].speed=10;//5;
index++;
//10
changeInfoData[index].pos_info_data.potision.xPosition=200;
changeInfoData[index].pos_info_data.potision.yPosition=2600;//2876
changeInfoData[index].pos_info_data.xCondition=NONE;
changeInfoData[index].pos_info_data.yCondition=LOW;
changeInfoData[index].distance=0;
changeInfoData[index].judge=JUDGE_POS;
changeInfoData[index].section_act=LINE_TRACE;
changeInfoData[index].speed=10;
index++;
//11
changeInfoData[index].pos_info_data.potision.xPosition=200;
changeInfoData[index].pos_info_data.potision.yPosition=2600;//2876
changeInfoData[index].pos_info_data.xCondition=NONE;
changeInfoData[index].pos_info_data.yCondition=LOW;
changeInfoData[index].distance=0;
changeInfoData[index].judge=JUDGE_POS;
changeInfoData[index].section_act=LINE_TRACE;
changeInfoData[index].speed=10;
index++;
//12
changeInfoData[index].sData.s=80;
changeInfoData[index].sData.condition=HIGH;
changeInfoData[index].distance=0;
changeInfoData[index].judge=JUDGE_S;
changeInfoData[index].section_act=LINE_TRACE;
changeInfoData[index].speed=10;
index++;
}
SlBkActionInfomation::~SlBkActionInfomation(){
delete(changeInfoData);
}
int8 SlBkActionInfomation::getter(int16 scene_num,ChangeInfo* change_info){
memcpy(change_info,&changeInfoData[scene_num],sizeof(ChangeInfo));
return SYS_OK;
}
|
f17b939f706131bc6213b640e266a818d9304a80 | 40a50b4035360c1732963c3d159b6e7c1f44ce08 | /netlib.h | 09640924f64914f649001f9ee0b104325c69c41e | [] | no_license | jinyuttt/netlib | 5a1cb04088ea50a29c7f751eb56c27888bd60160 | 48a2a27fe0b2d3ce064b3fe19eb7088060b60bd0 | refs/heads/master | 2021-08-11T11:18:02.644278 | 2017-11-13T16:20:19 | 2017-11-13T16:20:19 | 110,571,082 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 144 | h | netlib.h | #ifndef NETLIB_H
#define NETLIB_H
#include "netlib_global.h"
class NETLIBSHARED_EXPORT NetLib
{
public:
NetLib();
};
#endif // NETLIB_H
|
95729a0c584bbd08673f161a2ab57e7f96e3b472 | 83375008c0eb9b75fb69f254976220f20714cb47 | /include/curves/polynomial_splines_containers.hpp | 9552a5c2645adb3bd961b2e6c66f0d42672757b0 | [] | no_license | liuxinren/pointCloudProcessing | a8911f2dc5c1be0e4e1656109bb7f12049d2785a | 379274c8d56ef7cbac465df924c1dc6d2d7042c2 | refs/heads/master | 2022-04-06T00:19:18.588329 | 2020-02-20T08:02:18 | 2020-02-20T08:02:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 816 | hpp | polynomial_splines_containers.hpp | //
// Created by cyz on 19-4-15.
//
#ifndef POINTCLOUDPROCESSING_POLYNOMIAL_SPLINES_CONTAINERS_HPP
#define POINTCLOUDPROCESSING_POLYNOMIAL_SPLINES_CONTAINERS_HPP
/*
* polynomial_splines_containers.hpp
*
* Created on: Mar 7, 2017
* Author: Dario Bellicoso
*/
#pragma once
// curves
#include "curves/PolynomialSplineContainer.hpp"
namespace curves {
using PolynomialSplineContainerLinear = PolynomialSplineContainer<1>;
using PolynomialSplineContainerQuadratic = PolynomialSplineContainer<2>;
using PolynomialSplineContainerCubic = PolynomialSplineContainer<3>;
using PolynomialSplineContainerQuartic = PolynomialSplineContainer<4>;
using PolynomialSplineContainerQuintic = PolynomialSplineContainer<5>;
}
#endif //POINTCLOUDPROCESSING_POLYNOMIAL_SPLINES_CONTAINERS_HPP
|
2853ae0949d9b915675beadf3f7efb360da0934c | 9f98ea0a48097c60f74a831f3f52e982f7bc96ec | /window/ajoutsemestres.h | a3ae9ea6bbc05237da30bee24e0252c81a7af9a5 | [] | no_license | roddehugo/utprofiler | ff25b7ce04061392fb7eca6b798524254d660365 | 6a47a89f682fa8615eb3245d4967d1e15cc4dddf | refs/heads/master | 2021-03-12T20:46:49.890194 | 2015-06-06T20:12:10 | 2015-06-06T20:12:10 | 20,707,899 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 773 | h | ajoutsemestres.h | #ifndef AJOUTSEMESTRES_H
#define AJOUTSEMESTRES_H
#include <QDialog>
#include "dao/Factories.h"
#include <QTableWidget>
#include <QListWidget>
#include <QDialog>
#include <QDebug>
namespace Ui {
class ajoutSemestres;
}
/**
* @brief classe QDialog ajout semestre
* @details
* @return
*/
class ajoutSemestres : public QDialog
{
Q_OBJECT
public:
explicit ajoutSemestres(Factory* factory,QWidget *parent = 0);
~ajoutSemestres();
public slots:
void saveDossier();
void on_ajouterItem();
void on_retirerItem();
void deleteSemestres();
private:
QTableWidget* m_pTableWidget;
QStringList m_TableHeader;
Ui::ajoutSemestres *ui;
Factory* fac;
QList<Semestre*> toDelete;
};
#endif // AJOUTSEMESTRES_H
|
ebb1781df438475b50cb29f8d26b613a50fd9514 | 350f15c692712bfc52ce74104e3ddb9ebdb180f6 | /include/rpi_vector.h | ba59340a70dc9498d9ca7546d3737b0845ad4a6c | [] | no_license | adampetrus/raspberry-helicopter-common | be0803265c833d2c739b33466e0f0058483b304b | a4a928a4d466a689e7849331b303cc024e268149 | refs/heads/master | 2016-09-14T01:23:56.375779 | 2016-05-15T19:50:11 | 2016-05-15T19:50:11 | 58,880,174 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 798 | h | rpi_vector.h | #ifndef RPI_VECTOR_H
#define RPI_VECTOR_H
#include <QByteArray>
QByteArray fromDouble(double d);
double fromHex(QByteArray h);
double earth_radius();
double math_pi();
class rpi_vector {
public:
rpi_vector();
rpi_vector(const rpi_vector &s);
rpi_vector(double a,double b,double c,bool latlong=false);
void setVector(double a,double b,double c,bool latlong=false);
double cartX();
double cartY();
double cartZ();
double latitude();
double longitude();
double height();
rpi_vector operator-(const rpi_vector &s);
protected:
void calc();
bool mode;
bool calcd;
double x;
double y;
double z;
double lat;
double longit;
double theta;
double r;
};
#endif // RPI_VECTOR_H
|
2816b104734f0cb72b1d506588bfcff6e125c3c4 | 02ee0c15fc9254cf1c202a642fc2940a24659d42 | /Canon SDK Source/Code Sample/VC/RAWDevelop/CtrlPanelSheet.cpp | 4d246b08c55031ee89ad7bfd57539e0657174446 | [] | no_license | redperez/Automated-Macro-Rail-for-Focus-Stacking | 9c6805266979feff8c665902e4eb1f0fe4f065e9 | 9dcf7327829f7c58d9dc5fa84663c159ec82cea4 | refs/heads/master | 2022-08-12T18:06:46.180722 | 2022-07-30T18:47:32 | 2022-07-30T18:47:32 | 134,415,877 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,303 | cpp | CtrlPanelSheet.cpp | /******************************************************************************
* *
* PROJECT : EOS Digital Software Development Kit EDSDK *
* NAME : CtrlPanelSheet.cpp *
* *
* Description: This is the Sample code to show the usage of EDSDK. *
* *
* *
*******************************************************************************
* *
* Written and developed by Camera Design Dept.53 *
* Copyright Canon Inc. 2006 All Rights Reserved *
* *
*******************************************************************************
* File Update Information: *
* DATE Identify Comment *
* ----------------------------------------------------------------------- *
* 06-03-22 F-001 create first version. *
* *
******************************************************************************/
#include "stdafx.h"
#include "RAWDevelop.h"
#include "CtrlPanelSheet.h"
#include ".\ctrlpanelsheet.h"
// CCtrlPanelSheet
IMPLEMENT_DYNAMIC(CCtrlPanelSheet, CPropertySheet)
CCtrlPanelSheet::CCtrlPanelSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
}
CCtrlPanelSheet::CCtrlPanelSheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
AddPage(&m_ProcessPage);
AddPage(&m_SavePage);
}
CCtrlPanelSheet::~CCtrlPanelSheet()
{
}
BEGIN_MESSAGE_MAP(CCtrlPanelSheet, CPropertySheet)
END_MESSAGE_MAP()
// CCtrlPanelSheet
|
ee2649795f200f282e6f47dc9beff99a205b96c4 | e4f80dded2215ef2d4e84034da56eda23beafa9e | /Functions/Structure_as_parameter.cpp | 1168197e2dc51e46a1555c18986a81989f0d444d | [] | no_license | TanishGuleria/Data-Structure | 6c2dd9c06dd11263c86ae9ca21e7b7f9422a6b83 | fe446abdba8cdaa9e240fafc9af9fbac55ebbfb3 | refs/heads/master | 2023-04-20T23:58:54.575606 | 2021-05-16T20:33:55 | 2021-05-16T20:33:55 | 366,140,982 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 331 | cpp | Structure_as_parameter.cpp | #include<bits/stdc++.h>
using namespace std;
struct student{
string name;
int marks[5];
};
struct student * getval(struct student *s1)
{
s1->name = "tanish";
s1->marks[0] = 1;
}
int main()
{
struct student *p;
p= (struct student*)malloc(sizeof(struct student));
p= getval(p);
cout<<p->name;
cout<<p->marks[0];
}
|
f3d6b83a930459154bec512d06c7518cc6c7386b | 70450f0c551adf47b450468e424f4f90bebfb58d | /clsim/public/clsim/I3CLSimModuleHelper.h | 013c1e89c6b24c8f1606acf95fe1664530575e80 | [
"LicenseRef-scancode-unknown",
"BSD-2-Clause",
"MIT"
] | permissive | hschwane/offline_production | ebd878c5ac45221b0631a78d9e996dea3909bacb | e14a6493782f613b8bbe64217559765d5213dc1e | refs/heads/master | 2023-03-23T11:22:43.118222 | 2021-03-16T13:11:22 | 2021-03-16T13:11:22 | 280,381,714 | 0 | 0 | MIT | 2020-07-17T09:20:29 | 2020-07-17T09:20:29 | null | UTF-8 | C++ | false | false | 3,116 | h | I3CLSimModuleHelper.h | /**
* Copyright (c) 2011, 2012
* Claudio Kopper <claudio.kopper@icecube.wisc.edu>
* and the IceCube Collaboration <http://www.icecube.wisc.edu>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*
* $Id: I3CLSimModuleHelper.h 178168 2019-12-19 21:40:33Z jvansanten $
*
* @file I3CLSimModuleHelper.h
* @version $Revision: 178168 $
* @date $Date: 2019-12-19 14:40:33 -0700 (Thu, 19 Dec 2019) $
* @author Claudio Kopper
*/
#ifndef I3CLSIMMODULEHELPER_H_INCLUDED
#define I3CLSIMMODULEHELPER_H_INCLUDED
#include "phys-services/I3RandomService.h"
#include "clsim/random_value/I3CLSimRandomValue.h"
#include "clsim/function/I3CLSimFunction.h"
#include "clsim/I3CLSimMediumProperties.h"
#include "clsim/I3CLSimSimpleGeometryFromI3Geometry.h"
#include "clsim/I3CLSimStepToPhotonConverterOpenCL.h"
#include "clsim/I3CLSimLightSourceParameterization.h"
#include "clsim/I3CLSimOpenCLDevice.h"
#include <vector>
#include <string>
namespace I3CLSimModuleHelper {
I3CLSimStepToPhotonConverterOpenCLPtr
initializeOpenCL(const I3CLSimOpenCLDevice &device,
I3RandomServicePtr rng,
I3CLSimSimpleGeometryConstPtr geometry,
I3CLSimMediumPropertiesConstPtr medium,
I3CLSimFunctionConstPtr wavelengthGenerationBias,
const std::vector<I3CLSimRandomValueConstPtr> &wavelengthGenerators,
bool enableDoubleBuffering,
bool doublePrecision,
bool stopDetectedPhotons,
bool saveAllPhotons,
double saveAllPhotonsPrescale,
double fixedNumberOfAbsorptionLengths,
double pancakeFactor,
uint32_t photonHistoryEntries,
uint32_t limitWorkgroupSize);
I3CLSimRandomValueConstPtr
makeCherenkovWavelengthGenerator(I3CLSimFunctionConstPtr wavelengthGenerationBias,
bool generateCherenkovPhotonsWithoutDispersion,
I3CLSimMediumPropertiesConstPtr mediumProperties);
I3CLSimRandomValueConstPtr
makeWavelengthGenerator(I3CLSimFunctionConstPtr unbiasedSpectrum,
I3CLSimFunctionConstPtr wavelengthGenerationBias,
I3CLSimMediumPropertiesConstPtr mediumProperties);
};
#endif //I3CLSIMMODULEHELPER_H_INCLUDED
|
c6517d05c0ad61efab4f2669ac2344961d8ed9fa | ecca91eca07e54f3db698abe8087fee4b35fba38 | /SDUT/Contset4/1007/main.cpp | c56ea506881c75ff564faa0b6b93a048fd8b97ed | [] | no_license | ACLB/ACM | 8eb85c2f5b150f71cf47a8f48bd6981ba0f9023c | 36ecb2010cc5b2b12d925ee78161ca12356c26e1 | refs/heads/master | 2021-01-17T01:51:25.196637 | 2018-02-09T09:42:15 | 2018-02-09T09:42:15 | 60,836,482 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,551 | cpp | main.cpp | #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
const int Max = 251000;
typedef struct node
{
int Id;
node *next[26];
}No;
char s[15],t[15];
int num;
int pre[Max*2];
int deg[Max*2];
No * Creat()
{
No *p;
p = new No;
p->Id = -1;
for(int i = 0;i<26;i++) p->next[i] = NULL;
return p;
}
int Build(No * p,char *str)
{
int len = strlen(str);
int ne;
for(int i = 0;i<len;i++)
{
ne = str[i]-'a';
if(p->next[ne] == NULL) p->next[ne] = Creat();
p = p->next[ne];
}
if(p->Id == -1) p->Id = ++num;
return p->Id;
}
int Find(int x)
{
return pre[x] == 0?x:pre[x] = Find(pre[x]);
}
void Union(int x,int y)
{
int Fx = Find(x);
int Fy = Find(y);
if(Fx != Fy)
{
pre[Fx] = Fy;
}
}
int main()
{
No *root;
root = Creat();
num = 0;
memset(pre,0,sizeof(pre));
memset(deg,0,sizeof(deg));
while(~scanf("%s %s",s,t))
{
int u = Build(root,s);
int v = Build(root,t);
deg[u]++;
deg[v]++;
Union(u,v);
}
int cnt1 = 0;
int cnt2 = 0;
for(int i = 1;i<=num;i++)
{
if(Find(i)== i)
{
cnt1++;
}
if(deg[i]%2)
{
cnt2++;
}
if(cnt1>1 ||cnt2>2) break;
}
if(cnt1<=1&&(cnt2 ==0 || cnt2 == 2)) printf("Possible\n");
else printf("Impossible\n");
return 0;
}
|
28acbd9cd46375a1d7db903bf45c4bb2b346d628 | c84a1a57ba5e4956ea57a3bc045d0f05c60fb913 | /Hmwk/Assignment_6/Gaddis_8thEd_Chapter7_Probl9_Payroll/main.cpp | 5fa39540839ad2c677615866fdfda9ac15817313 | [] | no_license | bradleymckenzie/McKenzie-Bradley-CSC-5-40107 | 0330dd361cf0767e933bbae436f6629fdc99d7a7 | a2ad627c6bb80681cd6ffabb5492fc6467af267c | refs/heads/master | 2021-01-20T11:21:20.984305 | 2017-02-09T21:25:56 | 2017-02-09T21:25:56 | 78,146,344 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,935 | cpp | main.cpp | /*
File: main.cpp
Author: Bradley McKenzie
Created on February 6, 2017
Purpose: Payroll
*/
//System Libraries
#include <iostream>
#include <iomanip>
using namespace std;
//User Libraries
//Global Constants
//Such as PI, Vc, -> Math/Science Values
//as well as conversions from system of units to another
//Function Prototypes
//Executable code begins here!!!
int main(int argc, char** argv) {
//Declare Variables
const int SIZE=7;
int empId[SIZE]={5658845,4520125,7895122,8777541,8451277,1302850,7580489};
int hours[SIZE];
float payRate[SIZE];
float wages[SIZE];
//Input Values
cout<<" --------------------------------------------"<<endl;
cout<<" Employee Payroll"<<endl;
cout<<" --------------------------------------------"<<endl;
for(int i=0;i<SIZE;i++){//get employee
cout<<"Enter the Number of Hours Worked by ID "<<empId[i]<<": ";
cin>>hours[i];
cout<<endl;
while(hours[i]<0){//Invalid Input
cout<<"Error: Invalid ID, Reenter: ";
cin>>hours[i];
cout<<endl;
}
cout<<"Enter the Hourly Pay Rate of ID "<<empId[i]<<": $";//get the pay rate
cin>>payRate[i];
cout<<endl;
if(payRate[i]<15){
cout<<"Error: Must be Greater than $15, Reenter: ";
cin>>payRate[i];
cout<<endl;
}
while(payRate[i]<0){
cout<<"Error: Must be a Positive Number, Reenter: ";
cin>>hours[i];
}
wages[i]=hours[i]*payRate[i];
}
//Process by mapping inputs to outputs
//Output Values
cout<<"-------------------------------------------------"<<endl;
for(int x=0;x<SIZE;x++){
cout<<"Employee: "<<empId[x]<<" Hours: "<<hours[x]<<" Gross Wages: $";
cout<<fixed<<setprecision(2);
cout<<wages[x]<<endl;
}
cout<<"-------------------------------------------------"<<endl;
//Exit stage right!
return 0;
}
|
0f1f1aca8a6929185f2782a66cbcddab7a399233 | a565dc8a731c4166548d3e3bf8156c149d793162 | /PLATFORM/TI_EVM_3530/SRC/APPS/Vox/VoiceModem/Modem.cpp | 44e085db468c473c8bc3d666f86e8d19cd6e6068 | [] | no_license | radtek/MTI_WINCE317_BSP | eaaf3147d3de9a731a011b61f30d938dc48be5b5 | 32ea5df0f2918036f4b53a4b3aabecb113213cc6 | refs/heads/master | 2021-12-08T13:09:24.823090 | 2016-03-17T15:27:44 | 2016-03-17T15:30:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,751 | cpp | Modem.cpp | /** =============================================================================
*
* Copyright (c) 2011 Micronet
* All rights reserved.
*
*
* Title: C module template
* Author(s): Michael Streshinsky
* Creation Date: 7-Apr-2011
*
* Revision Histiory:
*
* Date Author Description
* ---------------------------------------------------------------------------
*
* =============================================================================
*/
/********************** INCLUDES **********************************************/
//#include "stdafx.h"
//#include <windows.h>
#include "modem.h"
#include <commctrl.h>
#include <mmsystem.h>
#include <MicUserSdk.h>
//#include <gsm_api.h>
#include "comm.h"
#include "Line.h"
#include "MuxMdm.h"
/********************** LOCAL CONSTANTS ***************************************/
/*********** LOCAL STRUCTURES, ENUMS, AND TYPEDEFS ****************************/
/****************** STATIC FUNCTION PROTOTYPES *********************************/
/*********************** LOCAL MACROS *****************************************/
/********************* GLOBAL VARIABLES ***************************************/
/********************* STATIC VARIABLES ***************************************/
BOOL gModemOn = FALSE;
int modemAudioProfile = -1;
HANDLE g_hCom = INVALID_HANDLE_VALUE;
TCHAR g_ComPort[8] = L"COM0:";
HANDLE g_hLineThr = NULL;
BOOL isModemExists(void)
{
UINT32 power;
INT32 iRet;
iRet = MIC_GSMGetPowerStatus(&power);
if( iRet != GSM_OK )
return(FALSE);
else
return(TRUE);
}
/******************** FUNCTION DEFINITIONS ************************************/
/**
* @fn BOOL burnData(const BYTE *data, int len)
*
* @param const BYTE *data
* @param int len
*
* @return status of operation
*
* @retval TRUE success
* @retval FALSE error
*
* @brief burn incoming data to Flash ( S-record format )
*
*/
/*
BOOL TMP_bExample(const uint8 u8Parameter)
{
return FALSE;
}
*/
BOOL modemOn(VMODEM_CONTEXT_s *pVModemContext)
{
INT32 retPower, ret;
BOOL bRes;
if( gModemOn == TRUE )
return(TRUE);
if( modemAudioProfile == -1 )
{
gModemOn = FALSE;
return(FALSE);
}
//INT32 MIC_GSMPower(INT32 power);
retPower = MIC_GSMPower(1);
// MIC_GSMVoice workaround
// The problem is that QSS command returns
// "SIM NOT INSERTED" status , but
// If let its some delay, it returns "SIM INSERTED"
Sleep(350);
if( g_hCom == INVALID_HANDLE_VALUE )
{
g_hCom = __OpenComPort(g_ComPort);
if( g_hCom == INVALID_HANDLE_VALUE )
{
MIC_GSMPower(0);
return(FALSE);
}
}
//Sleep(350);
ret = MIC_GSMVoice(g_hCom, 1, modemAudioProfile);
if( ret == ERROR_SUCCESS )
{
#if 0
// Test ATZ influence
bRet = sendATCmdApp(g_hCom, "ATZ\r\n", respStr);
bRet = sendATCmdApp(g_hCom, "AT#DVI?\r\n", respStr);
bRet = sendATCmdApp(g_hCom, "AT+FCLASS=8\r\n", respStr);
bRet = sendATCmdApp(g_hCom, "ATX0\r\n", respStr);
bRet = sendATCmdApp(g_hCom, "AT&D0\r\n", respStr);
bRet = sendATCmdApp(g_hCom, "AT#DIALMODE=0\r\n", respStr);
#endif
bRes = sendATCmdApp(g_hCom, "AT#DIALMODE=1");
bRes = sendATCmdApp(g_hCom, "ATE1");
// Create Line Thread
pVModemContext->hCom = g_hCom;
g_hLineThr = CreateThread(0, 0, LineThread, pVModemContext, 0, 0 );
gModemOn = TRUE;
return(TRUE);
}
else
{
gModemOn = FALSE;
CloseHandle(g_hCom);
g_hCom = INVALID_HANDLE_VALUE;
MIC_GSMPower(0);
RETAILMSG(1, (L"DIGVOICE:%S, MIC_GSMVoice Error = %d\r\n",__FUNCTION__, ret));
return(FALSE);
}
}
BOOL modemOnMux(VMODEM_CONTEXT_s *pVModemContext)
{
INT32 ret;
BOOL bRet;
if( gModemOn == TRUE )
return(TRUE);
if( modemAudioProfile == -1 )
{
gModemOn = FALSE;
return(FALSE);
}
// Anyway test if COM6 is accessable
if( !testVoicePort(L"COM6:", 30000) )
return(FALSE);
g_hCom = __OpenComPort(L"COM6:");
if( g_hCom == INVALID_HANDLE_VALUE )
{
TurnOffMuxModem();
return(FALSE);
}
ret = MIC_GSMVoice(g_hCom, 1, modemAudioProfile);
if( ret == ERROR_SUCCESS )
{
// Create Line Thread
bRet = sendATCmdApp(g_hCom, "AT#DIALMODE=1");
bRet = sendATCmdApp(g_hCom, "ATE1");
pVModemContext->hCom = g_hCom;
g_hLineThr = CreateThread(0, 0, LineThread, pVModemContext, 0, 0 );
gModemOn = TRUE;
return(TRUE);
}
else
{
gModemOn = FALSE;
CloseHandle(g_hCom);
g_hCom = INVALID_HANDLE_VALUE;
TurnOffMuxModem();
RETAILMSG(1, (L"DIGVOICE:%S, MIC_GSMVoice Error = %d\r\n",__FUNCTION__, ret));
return(FALSE);
}
return(TRUE);
}
BOOL modemOff(VMODEM_CONTEXT_s *pVModemContext)
{
INT32 ret;
// First, close Line Thread
if(g_hLineThr)
{
SetCommMask(pVModemContext->hCom, 0);
//TapiUnlock();
WaitForSingleObject(g_hLineThr, 5000 /*INFINITE*/);
//TapiLock();
CloseHandle(g_hLineThr);
g_hLineThr = NULL;
}
if( pVModemContext->bMux == FALSE )
{
//INT32 MIC_GSMPower(INT32 power);
if( g_hCom != INVALID_HANDLE_VALUE )
{
ret = MIC_GSMVoice(g_hCom, 0, 3);
ret = MIC_GSMPower(0);
}
gModemOn = FALSE;
if( g_hCom != INVALID_HANDLE_VALUE )
{
CloseHandle(g_hCom);
g_hCom = INVALID_HANDLE_VALUE;
pVModemContext->hCom = g_hCom;
}
if( ( ret != 0 )&& ( ret != GSM_ERROR_CONTROLLED_BY_MUX ) )
{
//wsprintf( myTest, _T("GSM Modem turn off failure") );
//SetDlgItemText( hDlg, IDC_STATUS1, myTest );
return(FALSE);
}
else
{
//wsprintf( myTest, _T("GSM Modem turned off") );
//SetDlgItemText( hDlg, IDC_STATUS1, myTest );
return(TRUE);
}
}
else
{
TurnOffMuxModem();
gModemOn = FALSE;
if( g_hCom != INVALID_HANDLE_VALUE )
{
CloseHandle(g_hCom);
g_hCom = INVALID_HANDLE_VALUE;
pVModemContext->hCom = g_hCom;
}
return(TRUE);
}
}
BOOL modemOnTest(void)
{
INT32 ret;
if( gModemOn == TRUE )
return(TRUE);
if( g_hCom == INVALID_HANDLE_VALUE )
{
g_hCom = __OpenComPortTest(g_ComPort);
if( g_hCom == INVALID_HANDLE_VALUE )
return(FALSE);
}
if( modemAudioProfile != -1 )
{
ret = MIC_GSMVoice(g_hCom, 1, modemAudioProfile);
}
else
{
gModemOn = FALSE;
return(FALSE);
}
if( ret == 0 )
{
gModemOn = TRUE;
return(TRUE);
}
else
{
gModemOn = FALSE;
return(FALSE);
}
}
void modemSetAudioProfile(DWORD pfofile)
{
modemAudioProfile = pfofile;
}
BOOL isModemOn(void)
{
return( gModemOn );
}
INT32 modemVoiceDial(const char *pCmdStr)
{
//char atCmd[MAX_SIZE_TO_READ];
return( MIC_GSMVoiceCMD(g_hCom, GSM_VOICE_DIAL, pCmdStr) );
#if 0
//sendATCmdApp(pContext->hCom, "AT+CLCC");
strcpy(atCmd, "ATD");
strcat(atCmd, pCmdStr);
strcat(atCmd, ";");
if( !sendATCmdApp(g_hCom, atCmd))
{
RETAILMSG(1, (L"DIGVOICE:%S, Voice DIAL Error = %d\r\n",__FUNCTION__, GSM_ERROR_AT_CMD));
return(GSM_ERROR_AT_CMD);
}
return(0);
#endif
}
INT32 modemVoiceHangUp(void)
{
return( MIC_GSMVoiceCMD(g_hCom, GSM_VOICE_HANG_UP, NULL) );
#if 0
if( !sendATCmdApp(g_hCom, "ATH"))
{
RETAILMSG(1, (L"DIGVOICE:%S, Voice DIAL Error = %d\r\n",__FUNCTION__, GSM_ERROR_AT_CMD));
return(GSM_ERROR_AT_CMD);
}
return(0);
#endif
}
INT32 modemVoiceAnswer(void)
{
return( MIC_GSMVoiceCMD(g_hCom, GSM_VOICE_ANSWER, NULL) );
#if 0
if( !sendATCmdApp(g_hCom, "ATA"))
{
RETAILMSG(1, (L"DIGVOICE:%S, Voice DIAL Error = %d\r\n",__FUNCTION__, GSM_ERROR_AT_CMD));
return(GSM_ERROR_AT_CMD);
}
return(0);
#endif
} |
dafbf5b309dbf13c10b27f9e66f161ed3bcd26ba | aae4c67b345f50b86cf6783adb75fb3d0886895d | /HeapDataFlow/dataflow.h | eee92724662020cf4438ca22916ad7bbac7fac56 | [] | no_license | charlh7/HeapAnalysisProject | e18ade212774dbfd87d0da81f700980d9ff5eeaa | b575a94245bb1d58027a18e14ef719637c22a84c | refs/heads/main | 2023-05-14T08:17:32.301842 | 2021-06-04T16:05:50 | 2021-06-04T16:05:50 | 369,065,974 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,685 | h | dataflow.h | //Helper Functions to assist in Liveness Analysis
#include <vector>
#include "llvm/IR/Instructions.h"
using namespace llvm;
// ECE 5984 S18 Assignment 2: dataflow.h
// Group:
// http://www.cs.cmu.edu/~15745/15745_assignment2/code/Dataflow/
////////////////////////////////////////////////////////////////////////////////
#ifndef __CLASSICAL_DATAFLOW_H__
#define __CLASSICAL_DATAFLOW_H__
#include <stdio.h>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <utility>
#include "llvm/IR/Instructions.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/IR/Constants.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/IR/ValueMap.h"
#include "llvm/IR/CFG.h"
#include "llvm/Support/raw_ostream.h"
// Add definitions (and code, depending on your strategy) for your dataflow
// abstraction here.
//These two functions work together to perform two tasks:
// 1: count the number of variables defined within the function
// 2: add each binary instruction to a vector (Since we are only interested in Instructions with Binary Operators)
unsigned valueCount(Function &F, std::vector<Instruction*> &instVector);
unsigned addBBVals(BasicBlock* BB, std::vector<Instruction*> &instVector);
void outputBitVector(BitVector &bVector);
void outputValuesFromBVector(BitVector &bVector, std::vector<Instruction*> &instVector);
//std::string getShortValueName(Value * v);
//Returns a BitVector representing all of the definitions within the current BasicBlock
BitVector getDef(BasicBlock* BB, std::vector<Instruction*> instVector, BitVector &bVector);
//Returns a BitVector representing all uses within the current BasicBlock
BitVector getUse(BasicBlock* BB, std::vector<Instruction*> instVector, BitVector &bVector);
//A helper function that checks all of the operands of each instruction in the defVector
void checkOperands(std::vector<Instruction*> defVector, std::vector<Value*> opVector, BitVector &bVector);
std::vector<Value*> operandsToVector(Instruction *inst);
/*BitVector getIn(BasicBlock* BB, BitVector &origVector, BitVector &defVector, BitVector &useVector, std::vector<Instruction*> instVector, bool loop);
BitVector getOut(BasicBlock* BB, BitVector &origVector, std::vector<Instruction*> instVector);
*/
class BBInfo {
//InOutBB InOutBB();
public:
BBInfo(BitVector emptyVector); //Initialize all of the In's and Outs to Zero Vector
BitVector Def;
BitVector Use;
BitVector In;
BitVector Out;
BasicBlock* thisBlock;
std::vector<BBInfo*> successors;
void getIn();
void getOut();
void getSuccessors();
};
void addSuccessors(BBInfo* currentBB, std::vector<BBInfo*> BBInfoList);
std::string getShortValueName(Value * v);
#endif
|
cf66a144555d2d4e849c0e4c6fe0cf1a33f81cdb | 05a6f3d9555b0040316ce7941123832e6b7adda5 | /nowcoder2/b.cpp | 4ef2af3b8755888673a34b087acf835e62e16d74 | [] | no_license | Artoriaxx/c-Program | 66a509fa636d6fe1d5f88ab6f38a60eec74ba354 | 147045c2cde76413fe55d04de53ae1f1ab5b3e59 | refs/heads/master | 2021-11-28T19:36:04.972854 | 2021-11-20T08:25:14 | 2021-11-20T08:25:14 | 225,846,728 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,041 | cpp | b.cpp | #include <bits/stdc++.h>
#define pdd pair<double, double>
using namespace std;
typedef long long ll;
struct READ {
inline char read() {
#ifdef _WIN32
return getchar();
#endif
static const int IN_LEN = 1 << 18 | 1;
static char buf[IN_LEN], *s, *t;
return (s == t) && (t = (s = buf) + fread(buf, 1, IN_LEN, stdin)), s == t ? -1 : *s++;
}
template <typename _Tp> inline READ & operator >> (_Tp&x) {
static char c11, boo;
for(c11 = read(),boo = 0; !isdigit(c11); c11 = read()) {
if(c11 == -1) return *this;
boo |= c11 == '-';
}
for(x = 0; isdigit(c11); c11 = read()) x = x * 10 + (c11 ^ '0');
boo && (x = -x);
return *this;
}
} in;
const int N = 2e5 + 50;
const double eps = 1e-8;
int x[N], y[N];
template <typename T> T cross(T a, T b, T c, T d) {
return a * d - b * c;
}
bool check(pdd a, pdd b) {
if (fabs(a.first - b.first) > eps) return false;
if (fabs(a.second - b.second) > eps) return false;
return true;
}
int main() {
int n; in >> n;
for (int i = 1; i <= n; i++) in >> x[i] >> y[i];
int mx = 0;
vector<pdd> s;
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
if (x[i] * y[j] - x[j] * y[i] == 0) continue;
ll a11 = 2 * x[i], a12 = 2 * y[i], a13 = x[i] * x[i] + y[i] * y[i];
ll a21 = 2 * x[j], a22 = 2 * y[j], a23 = x[j] * x[j] + y[j] * y[j];
ll d0 = cross(a11, a12, a21, a22);
ll d1 = cross(a13, a12, a23, a22);
ll d2 = cross(a11, a13, a21, a23);
s.push_back(pdd((double)d1 / d0, (double)d2 / d0));
}
}
sort(s.begin(), s.end());
int now = 1;
for (int i = 1; i < s.size(); i++) {
if (check(s[i], s[i - 1])) now++;
else now = 1;
mx = max(mx, now);
}
for (int i = 1; i <= 2000; i++) {
if ((i - 1) * i / 2 == mx) {
printf("%d\n", i);
break;
}
}
return 0;
} |
a8f9751912cc8ab0c84db47249026ed5641dc3a4 | e398a585764f16511a70d0ef33a3b61da0733b69 | /3790.1830/src/wdm/bda/europa/src/dgtltransportoutinterface.cpp | 3f6455379617ad5572b472e652cfab3860cc33c6 | [
"MIT"
] | permissive | MichaelDavidGK/WinDDK | f9e4fc6872741ee742f8eace04b2b3a30b049495 | eea187e357d61569e67292ff705550887c4df908 | refs/heads/master | 2020-05-30T12:26:40.125588 | 2019-06-01T13:28:10 | 2019-06-01T13:28:10 | 189,732,991 | 0 | 0 | null | 2019-06-01T12:58:11 | 2019-06-01T12:58:11 | null | UTF-8 | C++ | false | false | 14,474 | cpp | dgtltransportoutinterface.cpp | //////////////////////////////////////////////////////////////////////////////
//
// (C) Philips Semiconductors 2001
// All rights are reserved. Reproduction in whole or in part is prohibited
// without the written consent of the copyright owner.
//
// Philips reserves the right to make changes without notice at any time.
// Philips makes no warranty, expressed, implied or statutory, including but
// not limited to any implied warranty of merchantability or fitness for any
// particular purpose, or that the use will not infringe any third party
// patent, copyright or trademark. Philips must not be liable for any loss
// or damage arising from its use.
//
//////////////////////////////////////////////////////////////////////////////
#include "34AVStrm.h"
#include "DgtlTransportOutInterface.h"
#include "DgtlTransportOut.h"
//////////////////////////////////////////////////////////////////////////////
//
// Description:
// This is the dispatch function for the pin create event of the transport
// output pin. It creates a new pin by instantiating an object of class
// CDgtlTransportOut and calling its Create() member function.
//
// Return Value:
// STATUS_UNSUCCESSFUL Operation failed due to invalid
// arguments.
// STATUS_INSUFFICIENT_RESOURCES Unable to create class
// CVampTransportStream
// STATUS_SUCCESS Operation succeeded.
//
//////////////////////////////////////////////////////////////////////////////
NTSTATUS DgtlTransportOutCreate
(
IN PKSPIN pKSPin, // Pointer to the pin object
IN PIRP pIrp // Pointer to the Irp that is involved with this
// operation.
)
{
_DbgPrintF(DEBUGLVL_BLAB,(""));
_DbgPrintF(DEBUGLVL_BLAB,("Info: DgtlTransportOutCreate called"));
if(!pKSPin || !pIrp)
{
_DbgPrintF(DEBUGLVL_ERROR,("Error: Invalid argument"));
return STATUS_UNSUCCESSFUL;
}
CDgtlTransportOut* pDgtlTransportOut =
new (NON_PAGED_POOL) CDgtlTransportOut();
if(!pDgtlTransportOut)
{
//memory allocation failed
_DbgPrintF(DEBUGLVL_ERROR,
("Error: DgtlTransportOut creation failed, not enough memory"));
return STATUS_INSUFFICIENT_RESOURCES;
}
if( pDgtlTransportOut->Create(pKSPin, pIrp) != STATUS_SUCCESS )
{
_DbgPrintF( DEBUGLVL_ERROR,
("Error: DgtlTransportOut creation failed"));
delete pDgtlTransportOut;
pDgtlTransportOut = NULL;
return STATUS_UNSUCCESSFUL;
}
//store the DgtlTransportOut object for later use in the
//Context of KSPin
pKSPin->Context = pDgtlTransportOut;
return STATUS_SUCCESS;
}
//////////////////////////////////////////////////////////////////////////////
//
// Description:
// This is the dispatch function for the pin remove event of the transport
// output pin. It removes the current pin by calling the Remove() member
// function of the pin object and deleting the object itself.
//
// Return Value:
// STATUS_UNSUCCESSFUL Operation failed due to invalid
// arguments.
// STATUS_SUCCESS Operation succeeded.
//
//////////////////////////////////////////////////////////////////////////////
NTSTATUS DgtlTransportOutRemove
(
IN PKSPIN pKSPin, // Pointer to the pin object
IN PIRP pIrp // Pointer to the Irp that is involved with this
// operation.
)
{
_DbgPrintF(DEBUGLVL_BLAB,(""));
_DbgPrintF(DEBUGLVL_BLAB,("Info: DgtlTransportOutClose called"));
//parameters valid?
if(!pKSPin || !pIrp)
{
_DbgPrintF(DEBUGLVL_ERROR,("Error: Invalid argument"));
return STATUS_UNSUCCESSFUL;
}
//get the pDgtlTransportOut object out of the Context of Pin
CDgtlTransportOut* pDgtlTransportOut =
static_cast<CDgtlTransportOut*>(pKSPin->Context);
if(!pDgtlTransportOut)
{
//no VampDevice object available
_DbgPrintF(
DEBUGLVL_ERROR,
("Error: DgtlTransportOutClose failed, no pDgtlTransportOut found"));
return STATUS_UNSUCCESSFUL;
}
//call class function
NTSTATUS Status = pDgtlTransportOut->Remove(pKSPin, pIrp);
//de-allocate memory for our pDgtlTransportOut class
delete pDgtlTransportOut;
pDgtlTransportOut = NULL;
//remove the pDgtlTransportOut object from the
//context structure of Pin
pKSPin->Context = NULL;
if( Status != STATUS_SUCCESS)
{
_DbgPrintF( DEBUGLVL_ERROR,
("Error: Class function called without success"));
return STATUS_UNSUCCESSFUL;
}
return STATUS_SUCCESS;
}
//////////////////////////////////////////////////////////////////////////////
//
// Description:
// This is the pin dispatch function for the process event of the transport
// output pin. It calls the Process() member function of the corresponding
// pin object.
//
// Return Value:
// STATUS_UNSUCCESSFUL Operation failed due to invalid
// arguments.
// STATUS_SUCCESS Operation succeeded.
//
//////////////////////////////////////////////////////////////////////////////
NTSTATUS DgtlTransportOutProcess
(
IN PKSPIN pKSPin // Pointer to the pin object
)
{
//_DbgPrintF(DEBUGLVL_BLAB,(""));
//_DbgPrintF(DEBUGLVL_BLAB,("Info: DgtlTransportOutProcess called"));
if(!pKSPin)
{
_DbgPrintF( DEBUGLVL_ERROR,
("Error: DgtlTransportOutProcess: Invalid argument"));
return STATUS_UNSUCCESSFUL;
}
//get the pDgtlTransportOut object out of
//the Context of Pin
CDgtlTransportOut* pDgtlTransportOut =
static_cast<CDgtlTransportOut*>(pKSPin->Context);
if(!pDgtlTransportOut)
{
//no VampDevice object available
_DbgPrintF(
DEBUGLVL_ERROR,
("Error: DgtlTransportOutProcess: DgtlTransportOutProcess failed,\
no pDgtlTransportOut found"));
return STATUS_UNSUCCESSFUL;
}
return pDgtlTransportOut->Process(pKSPin);
}
//////////////////////////////////////////////////////////////////////////////
//
// Description:
// This is the pin dispatch function for the SETDEVICESTATE event of the
// transport output pin. Dependend on the current and next state it calls
// the member functions Open(), Close(), Start() and Stop() of the
// corresponding pin object.
//
// Return Value:
// STATUS_UNSUCCESSFUL Operation failed due to invalid
// arguments.
// STATUS_SUCCESS Operation succeeded.
//
//////////////////////////////////////////////////////////////////////////////
NTSTATUS DgtlTransportOutSetDeviceState
(
IN PKSPIN pKSPin, // Pointer to KSPIN.
IN KSSTATE ToState, // State that has to be active after this call.
IN KSSTATE FromState // State that was active before this call.
)
{
_DbgPrintF(DEBUGLVL_BLAB,(""));
_DbgPrintF(DEBUGLVL_BLAB,("Info: DgtlTransportOutSetDeviceState called"));
_DbgPrintF(DEBUGLVL_BLAB,
("Info: From state 0x%02X to state 0x%02X", FromState, ToState));
//parameters valid?
if( !pKSPin )
{
_DbgPrintF(DEBUGLVL_ERROR,("Error: Invalid argument"));
return STATUS_UNSUCCESSFUL;
}
//get the pDgtlTransportOut class object out of the KS pin context
CDgtlTransportOut* pDgtlTransportOut =
static_cast <CDgtlTransportOut*> (pKSPin->Context);
//class object found?
if( !pDgtlTransportOut )
{
_DbgPrintF(DEBUGLVL_ERROR,
("Error: No digital transport stream pin class object found"));
return STATUS_UNSUCCESSFUL;
}
// get the KS device object out of the KS pin object
// (Device where the pin is part of)
PKSDEVICE pKSDevice = KsGetDevice(pKSPin);
if( !pKSDevice )
{
_DbgPrintF( DEBUGLVL_ERROR,("Error: Cannot get connection to KS device"));
return NULL;
}
//get the VampDevice object out of the Context of KSDevice
CVampDevice* pVampDevice = static_cast <CVampDevice*> (pKSDevice->Context);
if (!pVampDevice)
{
_DbgPrintF(DEBUGLVL_ERROR, ("Error: cannot get connection to device object\n"));
return STATUS_UNSUCCESSFUL;
}
NTSTATUS status = STATUS_SUCCESS;
switch(ToState)
{
case KSSTATE_ACQUIRE:
_DbgPrintF(DEBUGLVL_BLAB,
("Info: KSSTATE_ACQUIRE TS stream called"));
switch(FromState)
{
case KSSTATE_RUN:
//stream is running, stop it
status = pDgtlTransportOut->Stop(pKSPin);
break;
case KSSTATE_PAUSE:
//stream is opened/stopped, do nothing
break;
case KSSTATE_STOP:
status = pVampDevice->SetOwnerProcessHandle(PsGetCurrentProcess());
if (status != STATUS_SUCCESS) break;
//stream is closed, aquire it
status = pDgtlTransportOut->Open(pKSPin);
if (status != STATUS_SUCCESS) pVampDevice->SetOwnerProcessHandle(NULL);
break;
default:
_DbgPrintF(DEBUGLVL_ERROR,
("Error: Invalid state transition"));
status = STATUS_UNSUCCESSFUL;
break;
}
break;
case KSSTATE_RUN:
_DbgPrintF(DEBUGLVL_BLAB,("Info: KSSTATE_RUN TS stream called"));
switch(FromState)
{
case KSSTATE_ACQUIRE:
//stream is open, start it
status = pDgtlTransportOut->Start(pKSPin);
break;
case KSSTATE_PAUSE:
//stream is opened/stopped, start it
status = pDgtlTransportOut->Start(pKSPin);
break;
case KSSTATE_STOP:
//stream is closed, open and start it
status = pDgtlTransportOut->Open(pKSPin);
if(status == STATUS_SUCCESS)
{
status = pDgtlTransportOut->Start(pKSPin);
}
break;
default:
_DbgPrintF(DEBUGLVL_ERROR,
("Error: Invalid state transition"));
status = STATUS_UNSUCCESSFUL;
break;
}
break;
case KSSTATE_PAUSE:
_DbgPrintF(DEBUGLVL_BLAB,
("Info: KSSTATE_PAUSE TS stream called"));
switch(FromState)
{
case KSSTATE_ACQUIRE:
//stream is open, do nothing
break;
case KSSTATE_RUN:
//stream is opened/started, stop it
status = pDgtlTransportOut->Stop(pKSPin);
break;
case KSSTATE_STOP:
//stream is closed, open it
status = pDgtlTransportOut->Open(pKSPin);
break;
default:
_DbgPrintF(DEBUGLVL_ERROR,
("Error: Invalid state transition"));
status = STATUS_UNSUCCESSFUL;
break;
}
break;
case KSSTATE_STOP:
_DbgPrintF(DEBUGLVL_BLAB,("Info: KSSTATE_STOP TS stream called"));
pVampDevice->SetOwnerProcessHandle(NULL);
switch(FromState)
{
case KSSTATE_ACQUIRE:
//stream is open, close it
status = pDgtlTransportOut->Close(pKSPin);
break;
case KSSTATE_RUN:
//stream is opened/started, stop and close it
status = pDgtlTransportOut->Stop(pKSPin);
if(status == STATUS_SUCCESS)
{
status = pDgtlTransportOut->Close(pKSPin);
}
break;
case KSSTATE_PAUSE:
//stream is opened, close it
status = pDgtlTransportOut->Close(pKSPin);
break;
default:
_DbgPrintF(DEBUGLVL_ERROR,
("Error: Invalid state transition"));
status = STATUS_UNSUCCESSFUL;
break;
}
break;
default:
_DbgPrintF(DEBUGLVL_ERROR,("Error: Invalid state transition"));
status = STATUS_UNSUCCESSFUL;
break;
}
return status;
}
//////////////////////////////////////////////////////////////////////////////
//
// Description:
// This is the pin dispatch function for the framing allocator handler of
// the transport output pin.
//
// Return Value:
// STATUS_UNSUCCESSFUL Operation failed due to invalid
// arguments.
// STATUS_SUCCESS Operation succeeded.
//
//////////////////////////////////////////////////////////////////////////////
NTSTATUS DgtlTransportOutAllocatorPropertyHandler
(
IN PIRP pIrp, // Pointer to the Irp that is
// involved with this operation.
IN PKSPROPERTY pKSProperty, // Property information (not used
// here)
IN OUT PKSALLOCATOR_FRAMING pAllocator // Pointer to the allocator
// structure
)
{
_DbgPrintF(DEBUGLVL_BLAB,(""));
_DbgPrintF(DEBUGLVL_BLAB,
("Info: DgtlTransportOutAllocatorPropertyHandler called"));
if(!pIrp || !pKSProperty || !pAllocator)
{
_DbgPrintF(DEBUGLVL_ERROR,("Error: Invalid argument"));
return STATUS_UNSUCCESSFUL;
}
//fill allocator structure
pAllocator->FileAlignment = FILE_BYTE_ALIGNMENT;
pAllocator->Frames = NUM_TS_STREAM_BUFFER;
pAllocator->FrameSize = M2T_BYTES_IN_LINE * M2T_LINES_IN_FIELD;
pAllocator->PoolType = NonPagedPool;
pAllocator->RequirementsFlags = KSALLOCATOR_REQUIREMENTF_SYSTEM_MEMORY;
pAllocator->Reserved = 0;
return STATUS_SUCCESS;
}
|
2358365035fcdb8f5ecec46b85a1c669aebdf1b9 | 4a1affb5b4241ae5ab451578239ecdcd775f4649 | /src/WebcamNotFoundException.cpp | a73824defa511e30b0877ed91ace079ff6daa46d | [
"MIT"
] | permissive | loick111/surveillance | ef84fad742720f79b3c87b4330c7a70a6c45024c | 1bb89f387780703d7aa0fbabfd3f3e302bd1cf30 | refs/heads/master | 2020-12-25T16:13:48.139458 | 2016-06-20T22:55:50 | 2016-06-20T22:55:50 | 61,585,912 | 0 | 0 | null | 2016-06-20T22:56:22 | 2016-06-20T22:56:22 | null | UTF-8 | C++ | false | false | 149 | cpp | WebcamNotFoundException.cpp | /**
* @author Thomas Munoz
*/
#include "WebcamNotFoundException.h"
const char * WebcamNotFoundException::what(){
return "Webcam not found";
} |
b558b233b0b7d412d6781f4758ecfb81e5cf474c | 8900f908380b003da572f5e9605f35d2dcfbbc7c | /third_party/jpeg-xl/lib/extras/enc/exr.cc | ae98484c9cd7135bc33ba7bd517993a8efd677b4 | [
"Zlib",
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause",
"LicenseRef-scancode-generic-cla"
] | permissive | dgozman/gecko-dev | 1c10436cff84394a9a6fd8ea55948d8c346b6a62 | ec70291da1b9ae3334de90fa4891d7d1de78a217 | refs/heads/master | 2022-11-13T20:48:38.202640 | 2022-08-01T19:03:41 | 2022-08-01T19:03:41 | 227,497,205 | 0 | 0 | NOASSERTION | 2019-12-12T01:48:51 | 2019-12-12T01:48:50 | null | UTF-8 | C++ | false | false | 7,749 | cc | exr.cc | // Copyright (c) the JPEG XL Project Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "lib/extras/enc/exr.h"
#include <ImfChromaticitiesAttribute.h>
#include <ImfIO.h>
#include <ImfRgbaFile.h>
#include <ImfStandardAttributes.h>
#include <vector>
#include "lib/extras/packed_image_convert.h"
#include "lib/jxl/alpha.h"
#include "lib/jxl/color_encoding_internal.h"
#include "lib/jxl/color_management.h"
#include "lib/jxl/enc_color_management.h"
#include "lib/jxl/enc_image_bundle.h"
namespace jxl {
namespace extras {
namespace {
namespace OpenEXR = OPENEXR_IMF_NAMESPACE;
namespace Imath = IMATH_NAMESPACE;
// OpenEXR::Int64 is deprecated in favor of using uint64_t directly, but using
// uint64_t as recommended causes build failures with previous OpenEXR versions
// on macOS, where the definition for OpenEXR::Int64 was actually not equivalent
// to uint64_t. This alternative should work in all cases.
using ExrInt64 = decltype(std::declval<OpenEXR::IStream>().tellg());
size_t GetNumThreads(ThreadPool* pool) {
size_t exr_num_threads = 1;
JXL_CHECK(RunOnPool(
pool, 0, 1,
[&](size_t num_threads) {
exr_num_threads = num_threads;
return true;
},
[&](uint32_t /* task */, size_t /*thread*/) {}, "DecodeImageEXRThreads"));
return exr_num_threads;
}
class InMemoryOStream : public OpenEXR::OStream {
public:
// `bytes` must outlive the InMemoryOStream.
explicit InMemoryOStream(std::vector<uint8_t>* const bytes)
: OStream(/*fileName=*/""), bytes_(*bytes) {}
void write(const char c[], const int n) override {
if (bytes_.size() < pos_ + n) {
bytes_.resize(pos_ + n);
}
std::copy_n(c, n, bytes_.begin() + pos_);
pos_ += n;
}
ExrInt64 tellp() override { return pos_; }
void seekp(const ExrInt64 pos) override {
if (bytes_.size() + 1 < pos) {
bytes_.resize(pos - 1);
}
pos_ = pos;
}
private:
std::vector<uint8_t>& bytes_;
size_t pos_ = 0;
};
Status EncodeImageEXR(const ImageBundle& ib, const ColorEncoding& c_desired,
ThreadPool* pool, std::vector<uint8_t>* bytes) {
// As in `DecodeImageEXR`, `pool` is only used for pixel conversion, not for
// actual OpenEXR I/O.
OpenEXR::setGlobalThreadCount(GetNumThreads(pool));
ColorEncoding c_linear = c_desired;
c_linear.tf.SetTransferFunction(TransferFunction::kLinear);
JXL_RETURN_IF_ERROR(c_linear.CreateICC());
ImageMetadata metadata = *ib.metadata();
ImageBundle store(&metadata);
const ImageBundle* linear;
JXL_RETURN_IF_ERROR(
TransformIfNeeded(ib, c_linear, GetJxlCms(), pool, &store, &linear));
const bool has_alpha = ib.HasAlpha();
const bool alpha_is_premultiplied = ib.AlphaIsPremultiplied();
OpenEXR::Header header(ib.xsize(), ib.ysize());
const PrimariesCIExy& primaries = c_linear.HasPrimaries()
? c_linear.GetPrimaries()
: ColorEncoding::SRGB().GetPrimaries();
OpenEXR::Chromaticities chromaticities;
chromaticities.red = Imath::V2f(primaries.r.x, primaries.r.y);
chromaticities.green = Imath::V2f(primaries.g.x, primaries.g.y);
chromaticities.blue = Imath::V2f(primaries.b.x, primaries.b.y);
chromaticities.white =
Imath::V2f(c_linear.GetWhitePoint().x, c_linear.GetWhitePoint().y);
OpenEXR::addChromaticities(header, chromaticities);
OpenEXR::addWhiteLuminance(header, ib.metadata()->IntensityTarget());
// Ensure that the destructor of RgbaOutputFile has run before we look at the
// size of `bytes`.
{
InMemoryOStream os(bytes);
OpenEXR::RgbaOutputFile output(
os, header, has_alpha ? OpenEXR::WRITE_RGBA : OpenEXR::WRITE_RGB);
// How many rows to write at once. Again, the OpenEXR documentation
// recommends writing the whole image in one call.
const int y_chunk_size = ib.ysize();
std::vector<OpenEXR::Rgba> output_rows(ib.xsize() * y_chunk_size);
for (size_t start_y = 0; start_y < ib.ysize(); start_y += y_chunk_size) {
// Inclusive.
const size_t end_y = std::min(start_y + y_chunk_size - 1, ib.ysize() - 1);
output.setFrameBuffer(output_rows.data() - start_y * ib.xsize(),
/*xStride=*/1, /*yStride=*/ib.xsize());
JXL_RETURN_IF_ERROR(RunOnPool(
pool, start_y, end_y + 1, ThreadPool::NoInit,
[&](const uint32_t y, size_t /* thread */) {
const float* const JXL_RESTRICT input_rows[] = {
linear->color().ConstPlaneRow(0, y),
linear->color().ConstPlaneRow(1, y),
linear->color().ConstPlaneRow(2, y),
};
OpenEXR::Rgba* const JXL_RESTRICT row_data =
&output_rows[(y - start_y) * ib.xsize()];
if (has_alpha) {
const float* const JXL_RESTRICT alpha_row =
ib.alpha().ConstRow(y);
if (alpha_is_premultiplied) {
for (size_t x = 0; x < ib.xsize(); ++x) {
row_data[x] =
OpenEXR::Rgba(input_rows[0][x], input_rows[1][x],
input_rows[2][x], alpha_row[x]);
}
} else {
for (size_t x = 0; x < ib.xsize(); ++x) {
row_data[x] = OpenEXR::Rgba(alpha_row[x] * input_rows[0][x],
alpha_row[x] * input_rows[1][x],
alpha_row[x] * input_rows[2][x],
alpha_row[x]);
}
}
} else {
for (size_t x = 0; x < ib.xsize(); ++x) {
row_data[x] = OpenEXR::Rgba(input_rows[0][x], input_rows[1][x],
input_rows[2][x], 1.f);
}
}
},
"EncodeImageEXR"));
output.writePixels(/*numScanLines=*/end_y - start_y + 1);
}
}
return true;
}
class EXREncoder : public Encoder {
std::vector<JxlPixelFormat> AcceptedFormats() const override {
std::vector<JxlPixelFormat> formats;
for (const uint32_t num_channels : {1, 2, 3, 4}) {
for (const JxlDataType data_type : {JXL_TYPE_FLOAT, JXL_TYPE_FLOAT16}) {
for (JxlEndianness endianness : {JXL_BIG_ENDIAN, JXL_LITTLE_ENDIAN}) {
formats.push_back(JxlPixelFormat{/*num_channels=*/num_channels,
/*data_type=*/data_type,
/*endianness=*/endianness,
/*align=*/0});
}
}
}
return formats;
}
Status Encode(const PackedPixelFile& ppf, EncodedImage* encoded_image,
ThreadPool* pool = nullptr) const override {
encoded_image->icc.clear();
CodecInOut io;
JXL_RETURN_IF_ERROR(ConvertPackedPixelFileToCodecInOut(ppf, pool, &io));
encoded_image->bitstreams.clear();
encoded_image->bitstreams.reserve(io.frames.size());
for (const ImageBundle& ib : io.frames) {
encoded_image->bitstreams.emplace_back();
JXL_RETURN_IF_ERROR(EncodeImageEXR(ib, io.metadata.m.color_encoding, pool,
&encoded_image->bitstreams.back()));
}
return true;
}
};
} // namespace
std::unique_ptr<Encoder> GetEXREncoder() {
return jxl::make_unique<EXREncoder>();
}
Status EncodeImageEXR(const CodecInOut* io, const ColorEncoding& c_desired,
ThreadPool* pool, std::vector<uint8_t>* bytes) {
return EncodeImageEXR(io->Main(), c_desired, pool, bytes);
}
} // namespace extras
} // namespace jxl
|
c1a93846e051a6ff3ea41697508f764644624eaf | 9754fc02add0c14ba0a7d77deaa9b56c3addbed7 | /src/Entity/Player/player.h | f723634d50741e931c79f3a5c8e9dc0710914928 | [] | no_license | dm67x/arkanoid | f75d87d7c3833d1c1a5dd9b435781b9c7b1cf50f | 462797e3272368f715bf62c72fe2c3be685c917a | refs/heads/master | 2022-12-21T15:41:27.837308 | 2018-12-17T10:54:11 | 2018-12-17T10:54:11 | 298,024,385 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 640 | h | player.h | #ifndef PLAYER_H
#define PLAYER_H
#include "Entity/Ball/ball.h"
#include "Entity/Ship/ship.h"
#include "vector2.h"
#include <vector>
namespace Entities
{
class Player : public Entity
{
private:
Entities::Ship * ship;
std::vector<Entities::Ball *> balls;
std::string name;
int score;
public:
Player(const std::string name);
~Player() override;
void setActive(bool active) override;
void setPosition(Vector2<float> position);
void addScore(int points);
void resetScore();
inline const int getScore() { return score; }
};
}
#endif |
ffebed763d25647b0c36859514745ab74450583d | 0b64390633e6dd6d99f650c5fa50f00d72211bbe | /dmtoeuro.cpp | 50ed223257f018ec2e4df5004f2f1da328655ed4 | [] | no_license | iq0x/cpp | 91501e04865c15424a4036bad305b0d52fc679bd | c38c2f21dbc67f5c16391d9d2eda793e713559b0 | refs/heads/main | 2023-07-17T18:06:31.474273 | 2021-08-28T23:02:01 | 2021-08-28T23:02:01 | 397,408,038 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 274 | cpp | dmtoeuro.cpp | #include <iostream>
int main() {
double dm;
double result;
std::cout << "DM to EURO Converter\n";
std::cout << "DM:";
std::cin >> dm;
result = dm * 1.95583;
std::cout << result;
std::cout << " Euro";
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.